Skip to main content
← Back to list
01Issue
BugShippedSwamp CLIPublic
Assigneesstack72

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 with PartitionsRefusedError: 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 an assert.
  • 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.ts claims "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 to StepTask.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. stepLockHook is built with onLeaseLost → stepLeaseLost.abort → cancelOnLeaseLost(abort), and the same hook is reused as reportLock.
  • 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 onLeaseLost that turns a lapse into report_failed instead of cancelling the command. Make the run tracker and the saved record agree.
  • Test: fake a lease lapse during runFor in the CLI path. The run keeps its succeeded result and exit code, with a report_failed.

Also in this PR

  1. --skip-reports still 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-reports makes no reportLock call.

  2. 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.

  3. CLI resume wiring is untested: removing the reportLock line in workflow_resume.ts:526 passes every test. Add a team-mode resume case or a request pin that fails without it.

  4. Polish:

    • rethrow unexpected errors from the report flush, as flushStepLock does, instead of downgrading them to report_failed;
    • emit one report_failed per selected workflow-scope report, not one under the made-up name "workflow-scope reports";
    • include each refusal's message in the JSON error's refusals;
    • run reports under processLockHolderMarker.runHolding with the lock's held ids.
  5. Team-mode read runs take the behavior's lock. On v3, a read or list model method run takes 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 as lease-lost while another member holds the behavior's lease. methodRunLockMode returns "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.md and design/enablers/datastores.md to 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.

02Bog Flow
✓OPEN✓TRIAGED✓IN PROGRESS✓SHIPPED+ 1 MOREASSIGNED+ 5 MOREREVIEW+ 12 MOREPR_LINKED+ 2 MORESESSION_SUMMARIZED

Shipped

11/10/2026, 6:01:23 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack7211/10/2026, 12:17:37 PM

Sign in to post a ripple.