Repository navigation
test(k8s): prove the async leaf consumer on deploy/k8s, and document its capacity - #765
Conversation
…its capacity The consumer's pod wiring (SH_ASYNC_DRAIN in moca-settings, the supervisor env ref, the sticky setup.sh validation) already ships. What was missing is the proof that it drains on a real cluster, and the answer to the capacity question rossoctl#688 asks: nothing autoscales it. Async fan-out is `replicas` x `SH_WORKERS` wide, and that is a number an operator sets. No HPA, no metrics adapter, no KEDA (retired in ADR-0041): the drain shares one admission budget with interactive turns, so queue depth is the wrong signal for the front door, and a scale-down would evict a pod holding a leaf mid-run. `async_queue_depth` and `async_oldest_age_ms` are there to alert on instead. Two new smoke claims, both opt-in with the drain itself: - claim 13: five async leaves on a stack that runs two at a time all reach `responded`, and the first one's result text carries its tool output -- so the leaf really ran, which `responded` alone does not show. A read of `async_queue_depth` that returns a number (0 included) is the proof the ConfigMap key reached a worker process; `"NaN"` means it reached none. - claim 14: rossoctl#389's crash-redelivery acceptance on deploy/k8s. A 40 s leaf outlasts the 20 s SHUTDOWN_GRACE_MS, its pod is deleted mid-run, and the turn finishes on delivery 2 or later. An absent SH_ASYNC_DRAIN skips both claims; an unreadable moca-settings FAILs them, because a failed read cannot say "the drain is off" -- the same rule the tiers read already follows. Both branches are covered in tests/smoke.test.sh, and CI brings its kind stack up with SH_ASYNC_DRAIN=1 or the claims never run. Refs rossoctl#688, rossoctl#686, rossoctl#389 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
K8S-SMOKE-ASYNC-SLOW contains K8S-SMOKE-ASYNC, and `plan()` took the first key the prompt contained. So the slow prompt got the fast script: the leaf claim 14 means to interrupt ran `echo async-leaf-ok` and was `responded` before the claim could see it `running`. It failed honestly -- "the leaf never reached running within 60s, so the delete below would prove nothing: responded 1" -- which is how the kind run found this. Sorting the matches by length fixes the whole class rather than renaming one marker, since nothing stops the next pair from colliding the same way. The mock's own suite now covers both markers, and asserts the one thing that distinguishes them: ASYNC carries no sleep, ASYNC-SLOW sleeps 40 s. Reverting the one-line fix fails that check and nothing else. Refs rossoctl#688 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…s not a failed leaf Review of rossoctl#765 found four defects in the new async claims, all in what the smoke reports rather than what it runs: - The arming check tested `== NaN || -z` instead of requiring a number, so a /metrics without the gauge key (an older supervisor, with SH_ASYNC_DRAIN sticky in moca-settings) read as `null` through jq and PASSED the one check that is supposed to prove a worker armed. It now requires ^[0-9]+$. - That same FAIL told an unreachable admin port it had the knob off, sending the reader to the ConfigMap. One message now names both causes, because the reading alone cannot tell them apart. - mint_api printed its own ko AND returned 1, so one failed mint produced two FAIL lines -- and in claim 14 the second one said the leaf never finished after the pod delete, when the leaf was merely unreadable. mint_api now judges nothing; each caller owns its verdict, and claim 14 skips the 240 s of 401s it would have polled. - `bad=''` sat inside `if ((async_ok))` while the verdict read it on another branch: correct only by branch order, and an unbound-variable abort under set -u after any reorder. Moved beside async_ok=1. - The pass line printed the gauge as "at the last 202" when slot 0 refreshes it every 10 s, so CI printed depth 0 beside "5 of 5 still queued". The suite gains a scenario for the arming check: /metrics answering `{}` and answering nothing, both FAILs, naming both causes. Reverting the one-line check fails it. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
This PR adds smoke claims 13 (five async leaves fanned out over two drain slots) and 14 (crash redelivery after a supervisor pod delete), turns on SH_ASYNC_DRAIN=1 in the kind CI stack, documents the consumer and the no-autoscaler capacity rule in README §4/§14, and fixes mock-anthropic.mjs to pick the longest marker instead of the first. No must-fix issues. The skip-vs-fail handling for an unreadable moca-settings, the numeric arming check, and the re-mint after rollout are all done carefully and covered by tests. On head I ran deploy/k8s/tests/smoke.test.sh (all passed, including the 3 new cases) and deploy/microvm/tests/mock-anthropic.test.sh (PASS). I also checked is_terminal against TURN_STATES in turn-record.ts: it matches isTerminalState, with only queued/running/paused treated as pending. Two inline notes: one suggestion and one nit.
I could not fetch the k8s-kind-e2e job log (TLS timeout on the log endpoint), so I did not confirm from the log that claims 13 and 14 ran rather than skipped. The job passed in 7m28s.
Author: cwiklik (CONTRIBUTOR — returning external)
Areas reviewed: Shell, CI/GitHub Actions, Docs, JS (mock model), tests
Agent/IDE config (.claude/.vscode): none
Commits: 3 commits, all signed-off: yes
CI status: passing (19/19 checks)
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| SID='' pod='' tid='' st_err='' | ||
| if new_session quiet; then | ||
| # Not one already terminating from claim 9: deleting it again would prove nothing. | ||
| pod="$(kc -n "$NS" get pods -l app=moca-supervisor -o json 2>/dev/null | |
There was a problem hiding this comment.
suggestion: The pod to delete is chosen here, before the leaf is even submitted, as the first non-terminating moca-supervisor pod. That is the right pod only while replicas: 1 (base today). With an overlay running more than one supervisor pod (README §4 now tells operators to raise replicas), the leaf may be claimed by a different pod. The delete then interrupts nothing, and the claim fails with "it was never redelivered". That is a false FAIL on a healthy stack, and its message points at the drain.
Suggested fix: either assert or skip when the deployment has more than one ready replica (kc get deploy moca-supervisor -o jsonpath='{.status.readyReplicas}'), or say in the claim comment and in README §14.5 that claim 14 assumes a single supervisor pod. Claim 9 has the same assumption, so a shared guard would cover both.
There was a problem hiding this comment.
Confirmed, and it is worse than a claim-14 problem: claim 9 picks its pod the same way and cannot know which pod the port-forward chose either, so both claims are coin flips above one replica. And §4 of the README now tells operators to raise replicas themselves, so it is a stack this PR invites.
Fixed in efafb17 with the shared guard you suggested — one one_pod helper off {.status.readyReplicas}, consulted by claim 9 and claim 14, both skipping with a note above one. Two details worth naming:
- The count is read once, before claim 9, not per claim. Nothing scales this deployment (that is §4's whole point), so it cannot change mid-run, and claim 9's own delete must not make claim 14 read a number mid-rollout.
- An unreadable count counts as 1, i.e. the claims still run. A guard that cannot read itself must not silently cancel two claims; if the pod it picked turns out wrong the FAIL still names that pod.
I did not take the other option (deleting the pod that actually holds the leaf). The turn record carries no consumer or worker id, so the only path is XPENDING on the stream inside redis-0 plus parsing moca-<pod>-w<N> back into a pod name — new coupling to the stream key, the group name and the consumer-id format, in code no CI stack would ever execute, since everything here ships replicas: 1.
Claim 13 is not gated: it deletes nothing. README §14.5 states the single-pod assumption and says to scale to one for the run. The suite gained a three-replica scenario asserting both skips, that nothing is deleted, that no claim mentions redelivery, and that claim 13 still runs; disabling the guard fails it.
| jq -r '[.items[] | select(.metadata.deletionTimestamp == null)][0].metadata.name // empty' 2>/dev/null || true)" | ||
| tid="$(submit_async async-crash "$SID" "$(ask K8S-SMOKE-ASYNC-SLOW 'sleep 40; echo async-slow-ok')")" | ||
| fi | ||
| is_running() { [[ "$(turn_state "$1" "$2")" == running* ]]; } |
There was a problem hiding this comment.
nit: is_running is defined inside claim 14's else branch, while its siblings (turn_state, is_terminal, await_turn) are defined with the other helpers near line 287. Moving it up there would keep all the helpers in one place, and keep the function out of a conditional.
There was a problem hiding this comment.
Moved in efafb17, next to await_turn and is_terminal with a one-line comment saying it is a wait_for predicate.
…ad of failing it Review of rossoctl#765: claims 9 and 14 both pick a supervisor pod BEFORE the work they interrupt starts, and neither can learn which pod the Service or the queue then handed it to. At `replicas: 1` -- every overlay here -- that is the right pod. Above one it is a coin flip: the delete interrupts nothing, the leaf finishes on attempt 1, and claim 14 fails a healthy stack saying "it was never redelivered", pointing at the drain. README §4 now tells operators to raise `replicas` themselves, so this is a stack we invite. Both claims now consult one `one_pod` guard and skip with a note above one ready replica. The count is read once (nothing scales this deployment, by design), and an unreadable count counts as 1 -- a guard that cannot read itself must not silently cancel two claims. Claim 13 deletes nothing and is not gated. Also moves `is_running` out of claim 14's else branch up to the other turn helpers, where its siblings live. The suite gains a three-replica scenario: both claims must note-and-skip, nothing may be deleted, no claim may mention redelivery, and claim 13 must still run. Disabling the guard fails it. 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.
Verdict: APPROVE. Incremental review of 2a45bbc..efafb17. The new one_pod guard (read once from readyReplicas, with an unreadable count treated as 1) makes claims 9 and 14 skip with a note above one supervisor pod instead of failing a healthy stack. Claim 13 stays ungated, is_running now sits with the other helpers, README §14 states the single-pod assumption, and the new 3-replica test case asserts both skips, no pod delete, and that claim 13 still runs. That closes the multi-replica false-FAIL concern raised at 2a45bbc. I agree that targeting the pod which actually holds the leaf isn't worth the XPENDING/consumer-id coupling.
One nit inline, about readyReplicas vs .spec.replicas.
Author: cwiklik (MEMBER — maintainer) · Agent/IDE config: none · Commits: all signed off · CI: green at submission.
| # nothing and the claim would fail a healthy stack. So both SKIP there. Read once: nothing scales | ||
| # this deployment (README §4), so the count cannot change mid-run. An unreadable count counts as 1 -- | ||
| # a guard that cannot read itself must not silently cancel two claims. | ||
| sup_replicas="$(kc -n "$NS" get deployment moca-supervisor -o jsonpath='{.status.readyReplicas}' 2>/dev/null || true)" |
There was a problem hiding this comment.
nit: readyReplicas counts only Ready pods, so it misses both ways. Mid-rollout (base maxSurge: 1) it can briefly read 2, which gives a spurious skip. A second pod that is running but not Ready reads as 1, yet its drain loop can still claim claim 14's leaf. .spec.replicas is the operator's intent and the number README §14 tells them to set to 1. Consider reading that, or the larger of the two.
There was a problem hiding this comment.
Both ways, confirmed: base/supervisor.yaml:20 is maxUnavailable: 0, maxSurge: 1, so under replicas: 1 a rollout has two Ready pods for a moment, and a pod that is running but not Ready is the worse half — its drain loop claims from the same group whatever readyReplicas says.
Now reads both in one call and takes the larger (8e6df050):
sup_replicas="$(kc -n "$NS" get deployment moca-supervisor -o jsonpath='{.spec.replicas} {.status.readyReplicas}' 2>/dev/null || true)"
sup_pods=1
for n in $sup_replicas; do
if [[ "$n" =~ ^[0-9]+$ ]] && ((n > sup_pods)); then sup_pods="$n"; fi
done
A spurious skip costs a note; a spurious FAIL costs someone a bisect. Both skip notes now say "the supervisor runs N pods" rather than "N are ready", and the offline scenario pins the asymmetric case (MOCK_SUP_REPLICAS='1 3'): with the max replaced by the spec field alone, claim 9 judges that stack and the suite fails.
clawgenti
left a comment
There was a problem hiding this comment.
No correctness blockers found: the new claims, the mock's longest-match fix and the CI knob do what the PR body says, and smoke.test.sh / mock-anthropic.test.sh pass locally (CI's kind e2e is green too). Inline: is_terminal leaves out the paused terminal state, the README calls per-pod counters "deployment-wide", the claim 13/14 verdict branches have no offline coverage, and one README sentence is ambiguous about which claims skip.
Author: cwiklik (CONTRIBUTOR — returning external)
Areas reviewed: commit conventions, shell (quoting, set -euo pipefail, bash 3.2 array idioms, token handling), CI workflow change, tests (smoke.test.sh and mock-anthropic.test.sh run locally; assertions and skip paths), docs accuracy (README §4/§8/§14 and the PR body checked against leaf-drain-loop.ts, async-worker.ts, pool.ts, admin.ts, turn-handlers.ts, setup.sh), security
Agent/IDE config (.claude/.vscode): none
Commits: 4 commits, all signed-off: yes
CI status: passing
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| jq -r 'select(.state) | "\(.state) \(.attempts // 0)"' 2>/dev/null || true | ||
| } | ||
| # A prompt leaf ends `responded`; the rest are the other terminal states a failure would land in. | ||
| is_terminal() { case "$1" in responded | done | solved | failed | cancelled | lost) return 0 ;; *) return 1 ;; esac; } |
There was a problem hiding this comment.
suggestion is_terminal leaves out paused, which is a terminal state as far as the control plane is concerned (isTerminalState in turn-record.ts is everything except queued/running), and one asyncFinalizeState can return. If a leaf ends paused, claim 13 keeps polling until its 240 s deadline and claim 14's await_turn runs out its whole budget before failing with a confusing "did not finish". The verdict would still be FAIL, but it arrives minutes late and says the wrong thing. Add paused, or mirror the control plane's rule directly: case "$1" in queued | running | '') return 1 ;; *) return 0 ;; esac.
There was a problem hiding this comment.
Right, and the list was the wrong shape to begin with — turn-record.ts:31 is s !== 'queued' && s !== 'running', so any state added there would silently become non-terminal here. Took your second form (8e6df050):
is_terminal() { case "$1" in queued | running | '') return 1 ;; *) return 0 ;; esac; }
'' stays non-terminal because both polling loops call this on a read that may have failed, and an unreadable turn is not a finished one.
The regression test asserts the read count, not just the FAIL: with the old list a paused leaf polled 2154 times (the full 240 s) and still produced the same =paused 1 message, so the message alone could not tell "reported it" from "waited four minutes for it".
|
|
||
| | Reading | Means | | ||
| | ------------------------- | -------------------------------------------------------------------- | | ||
| | `async_claims` | leaves claimed, deployment-wide | |
There was a problem hiding this comment.
suggestion "deployment-wide" doesn't match the code. pool.ts aggregates() sums asyncClaims over the workers of one supervisor process, and /metrics is reached through a port-forward to one pod. Each worker's tally is also cumulative per process (createAsyncTally), so it resets when a worker or pod restarts. Something like "leaves claimed by this pod's workers since they started" would be accurate, and the same caveat applies to the other three counters in this table.
There was a problem hiding this comment.
Confirmed on both halves: pool.ts's TelemetryAggregates sums "the workers that reported them" — one supervisor process, so one pod — and createAsyncTally (async-worker.ts:178) is a plain object in the worker's own memory, so a respawned worker contributes from zero. /metrics is reached by a port-forward to one pod on top of that.
Reworded in 8e6df050, and the paragraph under the table now carries the caveat for all four:
The four counters are one pod's, not the deployment's:
/metricsanswers from whichever pod you reached, each worker counts in its own memory, and a worker that respawns starts its own count at zero. Atreplicas> 1 (section 4) add the pods up yourself. The two gauges describe the one shared queue, so every pod's slot 0 reports the same numbers.
The gauges keep "from slot 0 only" — they describe the one Redis stream, so they are the same number from any pod.
| '{type: "tool_result", preview: (if $env == "1" then {content: [{type: "text", text: ($t + "\n")}]} | tojson else $t end)}' | | ||
| sed 's/^/data: /' | ||
| jq -nc --arg s "$sid" '{type: "done", sessionId: $s}' | sed 's/^/data: /' ;; | ||
| */metrics) printf '%s' "${MOCK_METRICS-}" ;; |
There was a problem hiding this comment.
suggestion The mock curl has no */v1/sessions/*/turns* route: a submit falls into the */v1/sessions/* PATCH branch and gets back a body with no turnId. So no offline case reaches claim 13's success path (responded x5 plus the async-leaf-ok text check), its bad= reporting, or any of claim 14's verdicts (attempts < 2, timeout, re-mint failure). All four new cases cover skip/arming branches only. A small stateful /turns mock (POST returns a turnId, GET returns a scripted state/attempts/result.text) would let the suite pin the responded/attempts >= 2 logic, which today only the live kind job exercises.
There was a problem hiding this comment.
Correct, and worse than untested: every offline run was failing claim 13 at submission (POST .../turns on s9 returned no turnId: {"sessionId":"turns","model":""} — the PATCH branch answering), so the paths 2a45bbcc rewrote had no coverage at all.
Added in 8e6df050. POST hands out t1, t2, ... and keeps the prompt; GET answers queued — or running, for claim 14's K8S-SMOKE-ASYNC-SLOW leaf — on the FIRST read and the final state after that, so a poll waiting for a change gets one. MOCK_ASYNC_STATE/MOCK_ASYNC_TEXT and MOCK_ASYNC_SLOW_STATE/MOCK_ASYNC_ATTEMPTS set what it lands on.
Six verdicts now covered, where the suite had none:
- claim 13 passes with all five
respondedand the tool's output inresult.text, keeping its still-queued note - claim 14 passes on delivery 2 after the pod delete
- a leaf that
paused(the regression test for theis_terminalthread) - a leaf that
failed - a leaf that responded without running its tool
attempts1, i.e. a delete that interrupted nothing
Each one was negative-checked by reverting the fix it guards.
| its Kind stack up with `SH_ASYNC_DRAIN=1`, so both run on every `k8s-kind-e2e` (section 8). | ||
|
|
||
| Claim 14 **assumes one supervisor pod**, as claim 9 does: it picks the pod before submitting the | ||
| leaf, and cannot learn which pod's drain then claimed it. Above `replicas: 1` both claims skip with |
There was a problem hiding this comment.
nit "both claims skip" is ambiguous here. Earlier in §14.5, "both" meant claims 13 and 14, but the multi-replica guard only skips claims 9 and 14; claim 13 still runs (smoke.test.sh asserts this). Suggest "claims 9 and 14 skip with a note".
There was a problem hiding this comment.
Taken (8e6df050): "Above replicas: 1 claims 9 and 14 skip with a note". §14.5's first paragraph uses "both" for 13 and 14, so the pronoun pointed at the wrong pair two sentences later.
…a counts, cover claims 13-14 offline Second review round on rossoctl#765. - `is_terminal` was a list of six states and `paused` was not among them, though the control plane calls it terminal (isTerminalState, turn-record.ts). A paused leaf would have made claim 13 poll to its 240 s deadline and claim 14 burn its whole budget. Mirror the rule instead of the list: everything but `queued`, `running` and an empty read. - The replica guard read `.status.readyReplicas` alone, which misses both ways: mid-rollout (base `maxSurge: 1`) it can read 2 under `replicas: 1`, and a pod that is running but not Ready reads as 1 while its drain loop can still claim claim 14's leaf. Read both numbers and take the larger. - The mock curl had no `/v1/sessions/*/turns` route, so every offline run failed claim 13 at submission and claims 13 and 14's verdicts were exercised only by the live Kind job. Add a scripted one -- POST hands out a turn id, GET answers `queued`/`running` once and then the final state -- and six scenarios over it: the two passing verdicts, a leaf that pauses, one that fails, one that responds without running its tool, and one the delete never interrupted. The paused scenario asserts the poll count, which is what tells "reported it" from "polled it for four minutes". - README §14.3's four counters were labelled deployment-wide; they are one pod's (`aggregates()` sums one supervisor process's workers, each counting in its own memory). §14.5's "both claims" now names claims 9 and 14. 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.
Verdict: APPROVE. Follow-up review of efafb17..8e6df05. Every item raised at efafb17 is addressed, and I checked each against the diff. The replica guard now takes the larger of .spec.replicas and .status.readyReplicas (and the '1 3' test pins that case). is_terminal mirrors the control plane's isTerminalState rule, so paused is terminal and an empty read is not. The README counter table and its new paragraph describe the counters as per-pod and reset on respawn. The new stateful /turns mock finally gives claims 13 and 14 offline coverage of their pass verdicts and of the paused/failed/no-tool-output/attempts-1 failures, and the paused case is bounded by read count. No new issues.
Author: cwiklik (MEMBER — maintainer) · Agent/IDE config: none · Commits: all signed off · CI: green at submission.
Sixteen ADRs still said Proposed although their decisions are in code on main. Each status line now names the merged PRs that implemented it and the date the core landed (format of ADR-0042), and notes what is still owed where only part is built: - 0028 (rossoctl#170, rossoctl#201, rossoctl#340; its KEDA transport removed by ADR-0041) - 0029 (rossoctl#171), 0030 (rossoctl#214), 0031 (rossoctl#214, rossoctl#225) - 0032 (rossoctl#249, rossoctl#350, as amended by MI1) - 0035 (rossoctl#251; ADR-0048 adds lease mode beside it) - 0036 (rossoctl#347), 0038 (rossoctl#458), 0039 (rossoctl#467), 0040 (rossoctl#481) - 0043 (rossoctl#560, rossoctl#588, rossoctl#600, rossoctl#615), 0044 (rossoctl#563), 0045 (rossoctl#620) - 0046 (phase 1: rossoctl#630, rossoctl#641, rossoctl#646; phase 2 owed) - 0047 (M1 and M3: rossoctl#704, rossoctl#713, rossoctl#717, rossoctl#765; M2 owed) - 0048 (rossoctl#706, rossoctl#763, rossoctl#802, rossoctl#808, rossoctl#814; off by default until the security review's lease sections are signed off) The README index follows, and its 0033 row, which still said Proposed after rossoctl#249 accepted the ADR, is corrected. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Docs and agent-facing text that the code no longer matches, found by an issue triage against main: - The microVM guest and the SBX sandbox have no network device, but reach the hosts on moca-egress's allowlist through the host's proxy (P4.1 #581-#583; SBX egress #641/#646). Concepts, guides, P4-ON-P6, the VM README, research-smoke, hardening, maturity, the demo's limits, the SBX user guide and direct-client doc said "no network" outright. So did the sandbox MCP instructions, the tool descriptions and the sbx status text agents read, which made agents refuse allowlisted calls (#779). - openapi.yaml said the worker enforces a turn's caps; nothing does yet (#391). - harness-openapi.yaml called /turn and /runs "deliberately not described", while change-policy decision 3 makes them supported aliases (#507). - The changelog is now the API changelog for both documents, with an index of the data-plane versions; both OpenAPI files point at it, and change-policy decision 5's follow-up is done (#511). - upgrades.md and change-policy: the configRef ordering only matters from before v0.5.0 or for a bundle-format change (#512, #510). - dispatch-archetypes and maturity: deploy/k8s's async drain is proven by its smoke claims (#688, #765). - Specs: slice 3's relay restart is graceful since #462 (#453); MI1 §2.2 gains a status note for the scrub (#350) and the vsock hop. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…status (#389, #380) #389's items 1-4 landed in #717 and the deploy/k8s half in #765. Item 5, "retire #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 #391 lands runLeaf takes an optional AbortSignal and the regression #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 #380. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
Closes #688.
The consumer's pod wiring already shipped with #389:
SH_ASYNC_DRAINinmoca-settings, thesupervisor env ref in
base/supervisor.yaml, andsetup.sh's sticky validation (only1or empty,and the
moca.dev/settings-hashannotation rolls the pods in the same apply). Both overlays inheritit from base, so neither needed a change. What was missing is the proof it drains on a real cluster,
and the answer to the capacity question #688 asks.
Capacity: nothing autoscales it
Async fan-out is
replicasxSH_WORKERSwide -- the drain loop takes one leaf per iteration, sotwo per pod by default -- and that width is a number an operator sets.
No HPA, no metrics adapter, no KEDA (retired in ADR-0041), by design:
for the front door: scaling on it would add pods that cannot admit anything;
but it is churn bought for nothing;
async_queue_depthandasync_oldest_age_msalready exist. They are for alerting, and fortelling you to raise
replicasyourself.README §4 carries the rule; new §14 documents the consumer end to end -- how to turn it on, how to
check it actually armed, how to submit and poll, which metrics to watch, and what is still M2.
Two new smoke claims
Both are opt-in with the drain itself, and both are the last claims of the run (claim 14 costs a
rollout, and claim 11's restart count must not see it).
Claim 13 -- five async leaves on a stack that runs two at a time all reach
responded, and thefirst one's
result.textcarries its tool output. The second half matters:respondedalone doesnot show the leaf ran, only that something finished it. The claim also reads
async_queue_depthoff the admin port, where a number (0 included) is positive proof the ConfigMap key reached a worker
process -- only an armed worker in slot 0 runs that timer at all, so
"NaN"means it reached none.Five sessions, not five turns on one:
idempotencyKeydefaults to the session id, so the latterwould collapse onto the first turn.
Claim 14 -- #389's crash-redelivery acceptance, on
deploy/k8s. A 40 s leaf deliberatelyoutlasts the 20 s
SHUTDOWN_GRACE_MSso the first attempt cannot finish; its supervisor pod isdeleted mid-run; the turn finishes on delivery 2 or later. Redelivery is
claim()'s ownXAUTOCLAIMstep past the 90 s idle floor, not the dead-letter reaper -- hence the 240 s budget(floor + rollout + a second 40 s run).
An absent
SH_ASYNC_DRAINskips both claims; an unreadablemoca-settingsfails them,because a failed read cannot say "the drain is off". That is the same rule the
SH_SANDBOX_TIERSread above it already follows, and both branches are covered in
tests/smoke.test.sh.CI brings its kind stack up with
SH_ASYNC_DRAIN=1, or the new claims would never run.Verification
deploy/k8s/tests/smoke.test.sh: green, 3 new cases (the skip branch, the unreadable-ConfigMapbranch, and claim 14 deferring to claim 13's verdict rather than claiming the knob is unset).
SKIP=hadolint-docker make lint: clean. No TypeScript changed.umask 077, never on argv;mint_apiwas extracted toa function because the token's 900 s ttl is shorter than the async claims' polling, so they
re-mint rather than inherit an expiring one.
Not run: the OCP half of the acceptance. I have no OpenShift cluster. Claims 13 and 14 are
neither tier- nor target-gated, so
--target ocpshould work, but the one thing an OCP run wouldcatch that reading cannot is whether that overlay's supervisor pod has the same
SH_CONTROL_PLANE_URL/SH_EXCHANGE_TOKENpair Kind's does -- without both,shouldArmAsyncrefuses with a log line and claim 13 fails on the
"NaN"gauge.Assisted-By: Claude Code