Skip to content

test: pin the sync /runs disconnect contract, and retire its interim status (#389, #380) - #878

Merged
cwiklik merged 2 commits into
rossoctl:mainfrom
cwiklik:feat/389-runs-disconnect-contract
Nov 18, 2026
Merged

cwiklik merged 2 commits into
rossoctl:mainfrom
cwiklik:feat/389-runs-disconnect-contract

Conversation

@cwiklik

@cwiklik cwiklik commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Closes the last open scope item on #389, and closes #380.

Why this is a doc-and-test change, not a behaviour change

#389's items 1–4 landed in #717, and the deploy/k8s half in #765 — neither was noted
on the issue, so #389 reads as unstarted when only item 5 is left: "retire #380's interim
contract."

#380 pinned this behaviour: a synchronous POST /runs leaf keeps running, and writes its
result record, after its client disconnects.
It was called interim because async leaf
turns (#389) were meant to supersede it. Retiring it does not mean wiring a
disconnect-abort into /runs:

  • mocactl depends on the behaviour. Its subagent path posts /v1/runs and then polls
    GET /runs/status (packages/mocactl/src/transport/leaf-turn.ts), so it is deliberately
    not holding the socket when the run ends. An abort on disconnect would strand every
    subagent.
  • Flipping it is a breaking change under docs/reference/change-policy.md ("changing a
    default so that behaviour … changes"), on a route the policy keeps as a frozen, supported
    alias.
  • What "interim" was actually about — a sync run lost on a worker restart with no retry —
    is answered by async turns (ADR-0047 M1–M3), which have crash redelivery. The gap closes by
    offering an alternative, not by changing this route.

So the behaviour stays and stops being interim: a test pins it, ADR-0028 records why, and the
/v1/runs description states it.

What changed

File Change
packages/server/test/server.test.ts One test: block runLeaf, req.destroy() mid-leaf, then assert the record is readable at /runs/status and that runLeaf received no signal argument.
docs/adrs/0028-async-prompt-dispatch.md Dated amendment: permanent, not interim, with the reasoning and the test that holds it.
docs/api/harness-openapi.yaml States the disconnect contract on /v1/runs. Also corrects the stale claim that the authenticated async replacement is "designed and not yet implemented" — M1–M3 have shipped, and that sentence pointed readers away from the very path this amendment recommends.

The second assertion is what makes #380's acceptance real. Once #391 lands, runLeaf takes
an optional AbortSignal and handleRunLeafParsed still passes none, so the regression #380
feared — someone copying /turn's abort wiring here — is a one-line edit with nothing
standing in its way. /turn's opposite contract is already pinned in the same file, so it is
referenced in a comment rather than re-tested; the two must not converge.

No info.version bump. Both doc edits are prose — no field, route or error code changes.
The changelog's rule is that the minor is bumped for additive changes, and the change policy
says text meant for people is not a contract. The contract suite passes unchanged, which is
the check on that call.

Verification

  • packages/server: 33 files, 593 tests passed (rebased on upstream/main @ f748ac86).
  • packages/control-plane/test/openapi-contract.test.ts: 21 passed, unchanged.
  • make typecheck: clean. SKIP=hadolint-docker make lint: clean (Docker is down locally).
  • Negative control, which is the point of the change: temporarily wired an abort signal
    from handleRunLeafParsed into runLeaf, confirmed the new test fails
    (expected AbortSignal { aborted: true } to be undefined), then reverted. src/server.ts
    is untouched by this PR.

Not in this change

#380's item 3 — a live disconnect check in deploy/k8s/smoke.sh "mirroring deploy/vm's" —
refers to a file that does not exist: deploy/vm has research-smoke.sh and setup-vm.sh,
and neither it nor deploy/k8s/smoke.sh has such a check. Recorded as dissolved in the ADR
amendment rather than silently dropped.

Assisted-By: Claude Code

…status (rossoctl#389, rossoctl#380)

rossoctl#389's items 1-4 landed in rossoctl#717 and the deploy/k8s half in rossoctl#765. Item 5, "retire
rossoctl#380's interim contract", is the last one, and the evidence settles it against
the obvious reading: a disconnect must still not cancel a sync /runs leaf.

mocactl's subagent path posts /v1/runs and then reads /runs/status
(packages/mocactl/src/transport/leaf-turn.ts), so it is not holding the socket
when the run ends -- an abort would strand every subagent. Flipping it is also
breaking under the change policy, on a route kept as a frozen alias. What the
"interim" framing was about, a sync run lost on a worker restart, is answered by
async turns (ADR-0047 M1-M3), which have redelivery.

So the behaviour stays and stops being interim: a test pins it, ADR-0028 records
why, and the /v1/runs description states it. The test also asserts no signal
reaches runLeaf, because once rossoctl#391 lands runLeaf takes an optional AbortSignal
and the regression rossoctl#380 feared is a one-line edit.

Also corrects harness-openapi.yaml, which still called the authenticated async
replacement "designed and not yet implemented" after M1-M3 shipped.

No info.version bump: both doc edits are prose, not contract changes.

Closes rossoctl#380.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
@cwiklik
cwiklik requested a review from pdettori as a code owner November 18, 2026 00:39
@cwiklik cwiklik added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 18, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clawgenti Code Review

Doc-and-test change pinning the sync /runs disconnect contract (ADR-0028 amendment, OpenAPI note, and a regression test in server.test.ts). Reviewed docs, OpenAPI and the new test.

No blocking issues. The test is well constructed — it asserts both halves of the contract (record still written after req.destroy(), and no 4th signal argument reaching runLeaf), and the comment explains why the two routes must not converge. The ADR's claim that #380's third item refers to a nonexistent file checks out against deploy/vm.

Author: cwiklik (CONTRIBUTOR — returning external)
Areas reviewed: Docs, OpenAPI, Tests
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes (DCO pass)
CI status: passing

All checks pass. Ready for human review.

Generated by RepoMan github-pr-review@9672454 (https://github.com/rossoctl/agent-skills/blob/96724547c162978f58d845b9a8331a679bf39444/skills/github-pr-review/SKILL.md).

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pdettori pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This changes only tests and docs; src/server.ts is not touched. It pins the existing rule that a sync /runs run keeps going after the client disconnects, and turns #380's interim status into a permanent, documented decision in ADR-0028 and the OpenAPI spec. I checked the PR's claims against upstream/main and they hold up: mocactl's leaf-turn.ts posts /v1/runs and then polls /runs/status, the change-policy quote is accurate, deploy/vm has no disconnect smoke check to mirror, and handleRunLeafParsed passes no signal today. The record-written assertion is the real behaviour guard and it is sound. The no-signal assertion is narrower than it looks (inline suggestion).

Author: cwiklik (MEMBER — maintainer)
Areas reviewed: TypeScript test, Docs (ADR, OpenAPI YAML)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, signed off: yes
CI status: all checks passing

Comment thread packages/server/test/server.test.ts Outdated

// ...and no signal reached the leaf, so the no-abort wiring fails loudly rather than only
// through its effect. runLeaf(env, config) -- a 4th `signal` argument means someone wired it.
expect(runLeaf.mock.calls[runLeaf.mock.calls.length - 1][3]).toBeUndefined();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: This guard only catches one way of wiring a signal. runLeaf is (env, config?, deps?) (harness/src/run-leaf.ts:419), so index [3] only fails if the signal arrives as a new 4th argument. If it's passed as the 3rd argument, inside deps, or on config, the test still passes. Those are the more likely shapes, given executeTurn takes input.signal. The negative control in the PR body used the same 4th-argument shape as the test, so it doesn't show the guard is robust.

Proposed fix, which pins today's exact call:

// handleRunLeafParsed calls runLeaf(body, buildConfig(auth)): two arguments, no signal on either
const args = runLeaf.mock.lastCall!;
expect(args).toHaveLength(2);
expect(args[1]).not.toHaveProperty('signal');

Any deliberate arity change then has to touch this test, which is the point.

Comment thread docs/adrs/0028-async-prompt-dispatch.md Outdated

`POST /runs` and `/v1/runs` keep running after the client's socket goes away, and write the result
record when they finish; `GET /runs/status` serves it afterwards. `/turn` does the opposite — it
aborts the in-flight turn on disconnect (`packages/server/src/server.ts`, ADR-0029 §3.6). The

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ADR-0029 has no §3.6. The disconnect → abort section is §3.6 of the spec, docs/specs/2026-08-26-turn-sse-streaming-design.md.


A client disconnect does not cancel the run: it finishes and persists its result record,
which `GET /runs/status` serves afterwards, so submit-then-poll is supported here. This is
permanent, not interim (ADR-0028). `POST /v1/turn` is the opposite and aborts on

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "POST /v1/turn is the opposite and aborts on disconnect" leaves out detachable turns. ADR-0040 and SH_TURN_DETACH=1 let a turn opt out of the abort, as this same file describes under DETACHABLE TURNS. Suggest "aborts on disconnect unless the turn is detachable". The same applies to "/turn does the opposite" in the ADR-0028 amendment.

Comment thread docs/adrs/0028-async-prompt-dispatch.md Outdated
asymmetry was accidental, and #380 filed it as an **interim** contract to be retired once async
leaf turns on P6 (#389) gave detached work a better home.

Async turns have now shipped (ADR-0047, M1–M3), and the retirement goes the other way: **the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "M1–M3 shipped" is correct, because #388 lifted the async tenancy gate (packages/control-plane/src/turn-exchange.ts:167). But ADR-0047's status line still says "M2, which lifts the single-tenancy gate, owed". A reader following this amendment to ADR-0047 will find the two ADRs disagree. Cite #388 here, or refresh ADR-0047's status line in this PR.

Review on rossoctl#878:

- the no-signal guard only caught a 4th argument, which is the least likely
  shape. Pin the call instead -- two arguments, no `signal` on either -- so a
  signal on `config`, inside `deps` or as a third argument fails it too.
  Verified by patching both shapes into `handleRunLeafParsed` and watching the
  test fail.
- `/turn` aborts on disconnect UNLESS the turn is detachable (ADR-0040,
  SH_TURN_DETACH=1), which the asymmetry's two statements left out.
- the disconnect-abort section is §3.6 of the turn-SSE streaming spec, not of
  ADR-0029.
- cite rossoctl#388 for M2's gate lift, since ADR-0047's status line predates it (rossoctl#856
  refreshes that line).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
@cwiklik

cwiklik commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@pdettori all four addressed in 05ccf858.

suggestion — the no-signal guard was narrower than it looked. Correct, and the negative control in the PR body was circular (it reproduced the same 4th-argument shape the assertion tested). Took your proposed fix: pin the call itself rather than one position.

const args = runLeaf.mock.lastCall!;
expect(args).toHaveLength(2);
expect(args[1]).not.toHaveProperty('signal');

Checked against both of the shapes you named, by patching handleRunLeafParsed and watching it fail rather than assuming:

  • signal on config → expected { redisUrl: undefined, …(6) } to not have property "signal"
  • signal as a third deps argument → expected [ …(3) ] to have a length of 2 but got 3

server.ts is unchanged in the commit; those were temporary.

nit — ADR-0029 §3.6. Fixed: it is §3.6 of docs/specs/2026-08-26-turn-sse-streaming-design.md, now linked there.

nit — detachable turns. Fixed in both statements. The ADR and the openapi description now say /turn aborts on disconnect unless the turn is detachable (ADR-0040, SH_TURN_DETACH=1), each noting it is the one /turn that outlives its client — which makes the asymmetry the amendment is about sharper, not weaker.

nit — ADR-0047's status line. Took the "cite #388" half deliberately: #856 already refreshes that line (it is the per-turn-budgets PR and rewrites the whole status header to "all three milestones implemented"), so editing it here would collide for no gain. The amendment now reads "M2's single-tenancy gate was lifted by #388, which ADR-0047's own status line predates", which is true whichever lands first.

Also updated the ADR's description of what the test pins, so it matches the stronger assertion.

Green locally: make lint, make typecheck, packages/server/test/server.test.ts 17/17.

Assisted-By: Claude Code

@cwiklik
cwiklik merged commit bd00a39 into rossoctl:main Nov 18, 2026
17 checks passed
webchang added a commit to webchang/moca that referenced this pull request Nov 18, 2026
Brings rossoctl#878 (the sync /runs disconnect contract), rossoctl#880 (the RUNBOOK's
reproduction recipe) and rossoctl#882 (deploy/k8s SH_WORKSPACE_IDLE for the
container worker, default 8h). No conflicts.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@pdettori pdettori added this to the v0.11.0 milestone Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coding-agent subagents A1: pin "a client disconnect doesn't cancel sync /runs" as an interim contract

3 participants