Repository navigation
docs(537): decide against /v1/batches — a fan-out is the caller's loop - #861
Conversation
rossoctl#537 asked whether P6 needs a batch resource now that a working async fan-out exists to measure a caller-side loop against. It does not. A fan-out is N sessions, each holding one async turn, submitted in a loop and collected by N status reads. Everything /v1/batches would own already lives somewhere better: bounded concurrency is admission (the slot cap and MOCA_ASYNC_QUEUED_PER_OWNER), per-item state, retry and cancel are per-turn, and a group identity — when a caller needs one — is rossoctl#279's parentSessionId tree under rossoctl#401, of which a flat batch is the degenerate case. One call instead of N is all that remains, and leaf runtime dominates N round trips. Records the decision where the deferral was written (ADR-0047's alternatives, the P6AF spec's §4.4, MU1's rossoctl#279 amendment), with the loop's limits stated so a caller can size it: a session per leaf, the per-owner 429, a fan-out width of SH_WORKERS × replicas, and collection inside LEAF_RESULT_TTL_SECONDS. The one real gap it names — collecting N results without N polls — is rossoctl#392's owner-scoped event stream, not a batch noun. The archetypes guide gains the "N leaves are N sessions" sentence, which it never said and which an idempotency-key default silently punishes. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
The decision record is clear, and it's placed where each deferral was originally written. I checked the factual claims against main: the idempotencyKey default to the session id (turn-handlers.ts:131), MOCA_ASYNC_QUEUED_PER_OWNER, LEAF_RESULT_TTL_SECONDS, and archetypes requirements §7.3. All match. Two small suggestions and one nit inline.
| `async: true` answers `202 {sessionId, turnId}`. Over the fan-out quota it answers 429 | ||
| `async_quota_exhausted`. **N leaves are N sessions**, one async turn each — `idempotencyKey` | ||
| defaults to the session id, so a second async turn on a session whose first is still running is | ||
| deduplicated onto it rather than queued behind it. There is no batch resource and none is coming |
There was a problem hiding this comment.
suggestion: "N leaves are N sessions" reads as a rule, but spec §4.3 explicitly lets one session hold several queued turns when the caller passes distinct idempotencyKeys (turn-result.ts's per-turn result key exists for exactly that). Consider adding "unless you pass distinct idempotencyKeys, in which case ordering is yours", so the guide doesn't contradict §4.3.
There was a problem hiding this comment.
Taken, in 7669697. The line now reads "deduplicated onto it rather than queued behind it — unless you pass distinct idempotencyKeys, which does queue several turns on one session and makes their ordering yours to manage, a responsibility the queue does not take (spec §4.3)". That last clause is §4.3's own wording ("takes responsibility for the ordering, which the queue does not promise"), so the guide now points at the exception instead of overriding it.
| @@ -606,7 +644,8 @@ Retention beyond 24 h and richer artifacts are out of scope here; §12 lists the | |||
| delivered both: seven-day retention, and a base commit plus a diffstat on every captured patch.) | |||
|
|
|||
| The caller polls the turn record for state, and the result store for the artifact. Whether N-way | |||
There was a problem hiding this comment.
suggestion: The edit leaves "Whether N-way collection needs no /v1/batches: …", which no longer parses. Drop "Whether": "N-way collection needs no /v1/batches: §4.4's closing amendment records …".
| richer artifacts; per-class concurrency caps, for which `async_claim_denied_full` against | ||
| interactive `429`s is the measurement that would justify them; `/v1/batches` (#537) once a working | ||
| fan-out exists to measure against; the documentation updates in #690 (ADR-0041's "Still owed" note, | ||
| interactive `429`s is the measurement that would justify them; the documentation updates in #690 (ADR-0041's "Still owed" note, |
There was a problem hiding this comment.
nit: Removing the /v1/batches clause left this line ~129 chars, unwrapped against the surrounding ~100-col prose. Cosmetic only (lint passes).
There was a problem hiding this comment.
Rewrapped in 7669697 — the paragraph's last three lines are now 99/97/100 chars, matching the surrounding prose. Checked with prettier --check (the repo binary, since this worktree has no node_modules) and scripts/check-doc-links.py: both clean.
- `dispatch-archetypes.md`: "N leaves are N sessions" read as a rule, which contradicted spec §4.3 -- distinct `idempotencyKey`s do queue several turns on one session. The caveat, and whose problem their ordering is, is now on the line. - spec §5.4: the removed `/v1/batches` clause left "Whether N-way collection needs no `/v1/batches`:", which no longer parsed. Dropped the "Whether". - ADR-0047: rewrapped the ~129-char line the same removal left, to the surrounding ~100. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Follow-up to the 82ddf4f review. 7669697 fixes all three items: the dispatch-archetypes caveat for distinct idempotencyKeys (matches spec §4.3), the spec §5.4 sentence, and the ADR-0047 rewrap. Nothing new. CI note: proto failed in "Build and test remote-worker" on this docs-only head (no Go/proto change, and it passed on 82ddf4f), so it looks like the known flake. Please re-run it before merging.
…red test The second flake blocking an unrelated docs PR's CI (rossoctl#861): FAIL test/sandbox-token.transport.test.ts > clears the timer when the Exec ends first: no late Abort reaches the worker AssertionError: expected 4 to be +0 4 is DEADLINE_EXCEEDED. `exp` is `Math.floor(Date.now() / 1000) + ttlSeconds`, so a ttl of 1 leaves between 1 ms and 1 s of real budget depending on where in the second the token is minted -- and this test deliberately runs with `sandboxLeewayS: 0`, so the Exec has to finish inside whatever that was. A ttl of 2 guarantees at least a second of it. The assertion is unweakened: the sleep after the Exec is 2.5 s, which is past exp however much was left, so a timer that was NOT cleared still delivers its late Abort and still fails the test. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…erting it `proto` failed on an unrelated docs PR (#861) with burst_test.go:137: Idle() = false after every frame was delivered: the unsent accounting leaked and passed on a re-run: the test asserted Idle() the instant it observed the last frame, which does not prove the accounting has caught up. The fake stream records a frame INSIDE Send while `unsent` drops only after Send returns, and the pool goroutine drops `inflight` only after runOne returns -- the same lag the `settle` helper exists for. The `DeferredNow == 0` wait just above does not cover either: drainDeferred drops that counter the moment the frame is handed to outbound. So it is a wait now, which still fails on a genuine leak -- as a timeout. Verified by deleting the sender's `unsent.Add(-1)`: the test fails in 3 s with "timed out waiting for Idle()". No production code changed. The two other bare `Idle()` asserts in this package are ordered: both follow Serve returning, and Serve's teardown closes `outbound` and waits for the sender goroutine before it does. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
Conflicts in ADR-0047's "Also owed" paragraph and the spec's §4.4/§4.5 boundary: rossoctl#861 landed rossoctl#537's decision against /v1/batches while this branch rewrote the same paragraph and renamed §4.5. Kept both — the rossoctl#537 amendment block, §4.5's new "Cancellation" title (a running leaf is cancellable now), and rossoctl#391's fairness/rossoctl#859 amendments, with /v1/batches dropped from the owed list since rossoctl#537 decided against it. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
Closes #537.
#537 asked whether P6 needs a batch resource now that a working async fan-out exists to measure a
caller-side loop against. It does not. This is the recorded decision the issue's acceptance asks
for — docs only, no code and no API change.
The decision
A fan-out is the caller's loop: N leaves are N sessions, each holding one async turn, submitted in a
loop and collected by N status reads. Everything
/v1/batcheswould own already lives somewherebetter:
MOCA_ASYNC_QUEUED_PER_OWNER. Aconcurrencyfield on a batch would be a third number free todisagree with those two.
with dead-lettering, and
DELETEon the turn.parentSessionId— a tree, which Coding-agent subagents B16: design — durable orchestration (declarative continuations vs re-entrant leaves) #401'sdeclarative continuations own. A flat batch is that graph's degenerate case, so shipping it first
would commit
/v1to the special case of a general shape nobody has designed.items it chose, and leaf runtime dominates N submission round trips.
Evidence beyond the design: #279's resolution left
/v1/batchesconditional on "a real batch"appearing; the #490 migration responses named no batch dependency (nor an async fan-out one at all);
and the archetype requirements already assign batching by rule or class, batch size and locality
grouping to the external orchestrator
(
docs/specs/2026-06-26-pipeline-archetypes-requirements.md§7.3).The one real gap is collecting N results without N polls — there is no list-turns route and no
owner-scoped stream today. Its answer is #392's owner-scoped event stream, not a batch noun. What
would reopen this: a group-level operation that cannot be written as a loop (one cancel for the
group, or one read of every result), or a caller whose wall clock is set by submission round trips
rather than by leaf runtime.
What the loop costs, stated so a caller can size it
A session create per leaf, because
idempotencyKeydefaults to the session id and a sessiontherefore holds one async turn in flight;
429 async_quota_exhaustedatMOCA_ASYNC_QUEUED_PER_OWNERnon-terminal turns, answered by waiting for one to finish rather thanby retrying; a fan-out width of
SH_WORKERS× replicas, raised by hand since queue-depth scaling wasdropped; and collection inside
LEAF_RESULT_TTL_SECONDS, after which only the record's terminalstate remains.
Where the decision is recorded
Each edit sits where the deferral was originally written, so no "decided once measurable" placeholder
survives:
docs/adrs/0047-p6-async-fan-out-in-worker-drain.md/v1/batches); removed from the follow-up-owed listdocs/specs/2026-11-05-p6-async-fan-out-design.mddocs/specs/2026-09-08-multi-user-control-plane-design.md/v1/batchesis deferred until a working fan-out can measure whether it is needed" now records the answerdocs/concepts/dispatch-archetypes.mdidempotencyKey-defaults-to-the-session-id dedup silently punishes a caller who assumes one session can hold the whole fan-outVerification
Docs only: no
.ts, no OpenAPI document and no contract version touched, so there is nothing totypecheck or test and no changelog entry to bump (
grep -rn "v1/batches"overpackages,harness,scriptsand.githubfinds nothing). Prettier reports all four files conformant.Assisted-By: Claude Code