Skip to content

feat(workflow): mark the pinned version in the revision history - #8577

Draft
yangzhang75 wants to merge 4 commits into
apache:mainfrom
yangzhang75:pin/5-anchor
Draft

yangzhang75 wants to merge 4 commits into
apache:mainfrom
yangzhang75:pin/5-anchor

Conversation

@yangzhang75

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Which version is the public one should be answerable, and the answer should be a row the author
can already see — the version panel is where they go to look at, and restore, an earlier version.

  • A pin leaves an anchor in the revision history. Its delta is the identity patch, so replaying
    that row returns what was published however many edits pile up later. An existing version row
    cannot stand in: one replays to the content as it was before the change it records, so it
    names the wrong thing by exactly one save. Pinning again with nothing changed reuses the anchor
    rather than adding a twin, and workflow.published_version_id names it.
  • The anchor is a marker, not an edit. It is always shown, so the author can find and restore
    what the public has, but it must not start the panel's aggregation window — the save it was
    pinned from is seconds older and would otherwise be folded into it and disappear.
  • The public view is dated by the version on show, not by the author's most recent private
    edit, and the share dialog names the same date from the same row, so the two cannot disagree.
  • Pinning takes the row's lock first. Two pins racing would otherwise both read before either
    wrote, and both insert an anchor.

Any related issues, documentation, discussions?

Closes #7941
Part of #7828. Design discussion: #7128. Stacked on #7853, #8575 and #8576; until those merge
this PR shows their commits too, and the review here is the last one.

How was this PR tested?

8 new cases in WorkflowPublishSpec and WorkflowVersionResourceSpec (567 in the dashboard
package):

  • an anchor the author can identify in the panel, and the save it was pinned from still visible
    beside it rather than folded into it;
  • pinning again unchanged reusing the anchor instead of adding a second one;
  • the version the pin was taken from surviving after the pin is dropped;
  • the public view dated by the pinned version, and the same date reported by the share dialog;
  • a workflow that is following carrying no anchor at all.

scalafmtCheckAll clean.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 5)

🤖 Generated with Claude Code

yangzhang75 and others added 4 commits September 16, 2026 12:36
A public workflow follows the author's latest content, as publishing has
always done. This adds the other state: the author pins the version they
have now, and the public copy stops moving until they pin again.

`is_public` stays the on/off switch; `published_content` is the pin, NULL
while following. `WorkflowPublishService` owns the two states, and three
endpoints expose them: POST and DELETE `/workflow/pin/{wid}` to pin and
unpin, GET `/workflow/publish-status/{wid}` for what the author is shown.
Publishing and unpublishing move through the same service, so unpublishing
drops the pin rather than leaving a private workflow carrying one.

Two paths are narrowed so a pin can hold. A save wrote the whole row back,
so a publish landing while a save was in flight was silently rolled back,
and a request body could set the publish columns itself; saves now write
only name, description and content. Creating a workflow clears the publish
columns for the same reason.

Nothing reads the pinned copy yet: every workflow is in the following
state it is in today, and nothing on screen changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
With a version pinned, a workflow has two copies: the author's working
copy and the frozen one on public show. This routes every read that
serves a viewer without granted access through the frozen copy, and
freezes the name and description with the graph.

`WorkflowPublishService.publicCopyOf` returns the three fields as a
group, so a surface cannot pick up the published graph under a title the
author has not published; `WorkflowAccessResource.hasGrantedAccess` is
the seam that decides which copy a caller gets. Granted access -- owner,
shared, project member -- keeps tracking the author's latest, because
sharing is not publishing.

Name and description freeze because they are as public as the graph: if
only the graph froze, a report about a title could be answered by editing
the title while the pinned copy still advertised it.

Routed through it: opening a workflow, the hub's read, Clone, Duplicate,
`/workflow_name`, `/workflow_description` and the size a listing shows.
A workflow that follows the author's latest -- every workflow today --
is served exactly what it is served now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Search and the listings it feeds were reading the author's live columns,
which for a pinned workflow is the one copy the public cannot open. A
draft would turn up in a public search under a title nobody has seen, and
the card would advertise a name the detail page does not show.

Each filter is now applied to whichever copy the caller may see:
`onVisibleCopy` builds the same filter twice -- over the live columns for
rows the caller was granted access to, over the frozen ones for rows they
reach only because the workflow is public -- and ORs the two. A
disjunction over bare columns rather than a CASE, so each side stays
eligible for its own fulltext index. Unpinned public rows fall back to
the live columns, so a following workflow searches exactly as it does now.

Listings carry two more things from the same query: the frozen name and
description to show a viewer without granted access, and whether the copy
on show is behind the author's working copy. `constructWhereClause` takes
`includePublic` for this; the other builders accept and ignore it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The author can pin a version, and their working copy then moves on. This
gives them a way back to what the public is seeing: pinning leaves an
anchor in the revision history they already use, and the panel marks it
as the one currently public, so restoring the published version is the
restore they already know.

The anchor is a version row whose delta is the identity patch, so
replaying it returns exactly what was pinned however many edits pile up
after. An existing row cannot stand in: a version row replays to the
content as it was *before* the change it records. Pinning content that is
already the pinned one reuses its anchor rather than adding a twin, and
the read that decides takes a row lock so two pins racing cannot both
insert.

Two consequences the anchor forces:

- It must not start the version panel's aggregation window. It lands
  seconds after the save it freezes, and the panel folds close-together
  versions into the newest, which would hide the author's own save behind
  a row they never made.
- The revision history is now readable only with granted access, or while
  nothing is pinned. Replaying a version folds deltas back from the
  author's current content, so listing versions of a pinned workflow would
  hand a public viewer the very edits the pin is holding back.

`publish-status` carries the pinned version's date, read from the version
row so the dialog and the panel print one value rather than two clocks'.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @aglinxinyuan, @tanishqgandhi1908
    You can notify them by mentioning @aglinxinyuan, @tanishqgandhi1908 in a comment.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 2 better · 🔴 3 worse · ⚪ 10 noise (<±5%) · 0 without baseline

Compared against main 471e53c benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 401 0.245 24,531/29,830/29,830 us 🟢 -9.0% / 🔴 +105.5%
🔴 bs=100 sw=10 sl=64 785 0.479 126,797/140,467/140,467 us 🔴 +9.1% / 🔴 +40.6%
bs=1000 sw=10 sl=64 903 0.551 1,103,799/1,177,335/1,177,335 us ⚪ within ±5% / 🔴 +22.7%
Baseline details

Latest main 471e53c from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 401 tuples/sec 431 tuples/sec 839.58 tuples/sec -7.0% -52.2%
bs=10 sw=10 sl=64 MB/s 0.245 MB/s 0.263 MB/s 0.512 MB/s -6.8% -52.2%
bs=10 sw=10 sl=64 p50 24,531 us 24,494 us 11,937 us +0.2% +105.5%
bs=10 sw=10 sl=64 p95 29,830 us 32,764 us 14,976 us -9.0% +99.2%
bs=10 sw=10 sl=64 p99 29,830 us 32,764 us 19,204 us -9.0% +55.3%
bs=100 sw=10 sl=64 throughput 785 tuples/sec 825 tuples/sec 1,096 tuples/sec -4.8% -28.4%
bs=100 sw=10 sl=64 MB/s 0.479 MB/s 0.504 MB/s 0.669 MB/s -5.0% -28.4%
bs=100 sw=10 sl=64 p50 126,797 us 116,227 us 94,033 us +9.1% +34.8%
bs=100 sw=10 sl=64 p95 140,467 us 145,786 us 99,939 us -3.6% +40.6%
bs=100 sw=10 sl=64 p99 140,467 us 145,786 us 110,148 us -3.6% +27.5%
bs=1000 sw=10 sl=64 throughput 903 tuples/sec 907 tuples/sec 1,128 tuples/sec -0.4% -19.9%
bs=1000 sw=10 sl=64 MB/s 0.551 MB/s 0.554 MB/s 0.688 MB/s -0.5% -20.0%
bs=1000 sw=10 sl=64 p50 1,103,799 us 1,099,923 us 921,191 us +0.4% +19.8%
bs=1000 sw=10 sl=64 p95 1,177,335 us 1,171,908 us 959,735 us +0.5% +22.7%
bs=1000 sw=10 sl=64 p99 1,177,335 us 1,171,908 us 988,604 us +0.5% +19.1%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,499.10,200,128000,401,0.245,24531.19,29830.07,29830.07
1,100,10,64,20,2549.21,2000,1280000,785,0.479,126797.06,140466.86,140466.86
2,1000,10,64,20,22149.36,20000,12800000,903,0.551,1103799.02,1177334.66,1177334.66

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.03279% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.76%. Comparing base (f9b899a) to head (127a900).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...shboard/user/workflow/WorkflowPublishService.scala 86.53% 4 Missing and 10 partials ⚠️
...ra/web/resource/dashboard/SearchQueryBuilder.scala 50.00% 1 Missing ⚠️
...esource/dashboard/WorkflowSearchQueryBuilder.scala 97.82% 1 Missing ⚠️
...rce/dashboard/user/workflow/WorkflowResource.scala 98.36% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8577      +/-   ##
============================================
- Coverage     92.91%   92.76%   -0.16%     
- Complexity     4884     4906      +22     
============================================
  Files          1224     1226       +2     
  Lines         51298    51619     +321     
  Branches       6322     6368      +46     
============================================
+ Hits          47664    47884     +220     
- Misses         2070     2160      +90     
- Partials       1564     1575      +11     
Flag Coverage Δ *Carryforward flag
access-control-service 71.78% <ø> (ø) Carriedforward from dbcf2ec
agent-service 99.32% <ø> (ø) Carriedforward from dbcf2ec
amber 88.64% <93.03%> (-0.37%) ⬇️
computing-unit-managing-service 54.61% <ø> (ø) Carriedforward from dbcf2ec
config-service 87.25% <ø> (ø) Carriedforward from dbcf2ec
file-service 81.53% <ø> (ø) Carriedforward from dbcf2ec
frontend 96.68% <ø> (ø) Carriedforward from dbcf2ec
notebook-migration-service 83.73% <ø> (ø) Carriedforward from dbcf2ec
pyamber 98.47% <ø> (ø) Carriedforward from dbcf2ec
workflow-compiling-service 74.09% <ø> (ø) Carriedforward from dbcf2ec

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mark the pinned version in the revision history

2 participants