Relationships
#4578 Team mode: serve-driven and member runs of one behavior collide on its method summary ('version 1 is already live'), and a report lease lapse can fail a run whose steps succeeded (#4567 follow-ups)
Opened by stack72 · 11/10/2026· Shipped 11/10/2026
Follow-ups from swamp-club#4567 (PR #3704, the workflow report lock), found while testing it. The full notes are in ~/Desktop/swamp-4567-follow-ups.md. Items 1 and 2 are ship blockers for team mode and gate dogfood run 7 (swamp-club#4374). The rest ride in the same PR. Line numbers are at #4567's merge 4b7469c6.
1. Blocker: serve-driven and member runs of the same behavior step collide on report-swamp-method-summary
- What happens: serve runs a workflow in its own process (scheduled, webhook or
--server) while a member runs the same workflow, and both execute the same behavior step. Serve's run fails withPartitionsRefusedError: Data report-swamp-method-summary version 1 is already live. - It's already on main: it reproduced on
39b46f90a, before #4567, failing 2 of 3 runs. It was found in #4567's barrier test before that test's step was switched to anassert. - It's F40 at the step level: the method summary's version is allocated without the exclusion the step's lease should give.
- Check first: does serve's own step lock exclude a member's lease on the same behavior for read-kind methods and for method-scope reports?
integration/serve_datastore_locks_test.tsclaims "a lease is serve's own model lock, so serve's runs and callers exclude each other". Confirm it against a real serve, not only the harness. - Repro: the barrier case in
integration/serve_upstream_workflow_report_race_test.ts, with its step changed back toStepTask.modelMethod("web", "noop"). - Fix: every writer of a behavior's method summary allocates its version under the same exclusion, whether it's serve's run or a member's, so overlapping runs both succeed with consecutive versions.
- Test: a serve-driven run and a member's run of one behavior step, overlapping. Both succeed, red on main.
2. Blocker: a report lease that lapses can fail or cancel a run whose steps all succeeded
- Where:
workflow_run.ts:461-472.stepLockHookis built withonLeaseLost→stepLeaseLost.abort→cancelOnLeaseLost(abort), and the same hook is reused asreportLock. - What happens: if the workflow lock's lease lapses while a slow report runs (after
run.complete()), the lapse aborts the command, and the run may exit cancelled or non-zero although every step succeeded. That breaks #4431's exit contract. - Fix: give the report lock an
onLeaseLostthat turns a lapse intoreport_failedinstead of cancelling the command. Make the run tracker and the saved record agree. - Test: fake a lease lapse during
runForin the CLI path. The run keeps its succeeded result and exit code, with areport_failed.
Also in this PR
--skip-reportsstill takes the workflow lock (runWorkflowReports,execution_service.ts:8926). Take no lock when no workflow-scope report will run: resolve the selected reports first, and lock only if the list isn't empty. Test:--skip-reportsmakes noreportLockcall.Waiting for the report lock ignores cancellation (
execution_service.ts:8929). Pass the run's abort signal. Test: a cancel while waiting on a held workflow lock ends the wait promptly.CLI resume wiring is untested: removing the
reportLockline inworkflow_resume.ts:526passes every test. Add a team-mode resume case or a request pin that fails without it.Polish:
- rethrow unexpected errors from the report flush, as
flushStepLockdoes, instead of downgrading them toreport_failed; - emit one
report_failedper selected workflow-scope report, not one under the made-up name "workflow-scope reports"; - include each refusal's
messagein the JSON error'srefusals; - run reports under
processLockHolderMarker.runHoldingwith the lock's held ids.
- rethrow unexpected errors from the report flush, as
Team-mode read runs take the behavior's lock. On v3, a
readorlistmodel method runtakes no lock (#1992), yet saves at least its method summary. In team mode that can collide on a version, as in item 1, or be refused aslease-lostwhile another member holds the behavior's lease.methodRunLockModereturns"run"for read and list methods when the checkout writes through serve, and for serve's own read runs on a team datastore (claimed by serve). Solo v3 and v2 keep #1992's lockless reads; an offline read run keeps its local-lock-only rule.- Reproduce first: a member's read-kind run overlapping another member's leased run of the same behavior, and the same with serve's own read run. Record which failure shows; the test is red on main.
- Report the request counts of a team-mode read run before and after (one lock and its release added).
- Update
design/primitives/behaviors.mdanddesign/enablers/datastores.mdto say team mode locks read runs, and why.
Must not regress
- #4567's overlapping-runs race test.
- #4574's request counts per workflow (the final record riding the report batch).
- No acknowledged write lost.
Done when
The tests above pass, red on main where marked. Dogfood run 7 shows serve-driven runs overlapping member runs of the same workflow with no method-summary refusals, and every member's workflows at 93% or better. Overlapping team-mode model method runs of one behavior, read-kind ones included and from members or serve, all succeed with consecutive method-summary versions and no lease-lost refusals.
Shipped
Click a lifecycle step above to view its details.
Sign in to post a ripple.