Skip to content

docs(spec): P4 — per-Exec microVM sandbox tier, warm-standby-provisioned - #247

Merged
pdettori merged 6 commits into
rossoctl:mainfrom
pdettori:docs/p4-microvm-sandbox
Sep 10, 2026
Merged

pdettori merged 6 commits into
rossoctl:mainfrom
pdettori:docs/p4-microvm-sandbox

Conversation

@pdettori

@pdettori pdettori commented Sep 9, 2026

Copy link
Copy Markdown
Member

What

Design + ADR for P4 — MicroVM sandbox tier: replace the sandbox tier's bash -c-in-a-container with one ephemeral microVM per Exec, behind the unchanged Attach wire contract, so the isolation boundary for agent-authored code moves from namespaces+seccomp to KVM at per-call granularity.

Design only — no code. Delivers E10 (lifecycle primitives) and E11 (density + replenishment ceiling) as specified experiments.

  • docs/specs/2026-09-09-p4-microvm-sandbox-design.md (new)
  • docs/adrs/0035-per-exec-microvm-warm-standby.md (new)
  • docs/specs/README.md — P4 row: planned → this design
  • docs/adrs/README.md — ADR-0035 index entry

Why now

docs/specs/README.md:84 recorded P4 as "infra-gated … no nested KVM on the m6i cluster." That gate has expired. AWS enabled nested virtualization on virtual EC2 instances in Feb 2026 (C8i/M8i/R8i, all commercial regions), and P6 establishes a non-Kubernetes VM substrate where a bare-metal host needs no cluster. So the experiment runs on a cheap nested instance for iteration and a *.metal instance for the authoritative number, instead of waiting for a bare-metal Kubernetes pool.

The load-bearing decision: warm standby

Replenishment costs ~10–25ms, which cannot sit inside a 15ms request. It does not have to. Within one leaf run, Execs are separated by model round trips of hundreds of milliseconds, so vmpool holds D paused standby VMs per active run, and the request path is only:

pop Ready VM → vsock write → run → collect → SIGKILL → (async) replenish

The <15ms target is met by relocating VM creation, not by making restore faster — and the design's real constraint becomes replenishment throughput, which is exactly what E11 measures. The per-call property is preserved intact: each VM still serves one Exec and is destroyed.

D defaults to 2, derived from code rather than taste: createPodEditOps composes read + write (operations.ts:78-79), so one tool call can be two back-to-back Execs with no model in between.

Cost to the rest of the system: one proto field

No new SandboxTransport, so no conformance-battery entry — P6 §3.1a's objection to a direct sandbox path does not apply, because this changes what sits behind the existing contract. remote-worker is untouched and becomes E11's container arm, which makes "the container path cannot regress" a structural fact rather than a test result, and makes the A/B an image swap.

The one change is ExecRequest.workspace_key, and it is required for correctness, not convenience: leases are keyed by run id (sandbox-lease.ts:3) and nothing on the wire carries it, so without the field consecutive leaseholders of one sandbox_id inherit the previous run's workspace — which is today's leak. Preserving a "zero harness change" headline here would have been buying a talking point with a security bug.

Verified, not assumed

Every platform fact in §2.4 comes from Firecracker's snapshot documentation, and four of them changed the design:

Documented fact Design consequence
Listening vsock sockets survive restore A guest agent parked in accept() is documented behaviour, not a trick
Resuming one snapshot repeatedly is documented insecure (IDs, RNG seeds, tokens duplicated) Forces the invariant that nothing secret or unique exists in the golden snapshot, plus a guest kernel ≥ 5.18 so VMGenID actually reseeds. Both tested
Host resources must be at the same relative paths Jailer chroot per VM, not drive-path patching — which also removes a step from the replenishment budget
Guest wall clock resumes from the snapshot moment clock_realtime: true, or date, file mtimes and git timestamps are wrong in every VM

Independently: Firecracker has no virtio-fs (urunc VMM matrix) and virtio-fs DAX was removed (TrEnv-X §3), so neither "just use virtio-fs on Firecracker" nor "virtio-fs is zero-copy" was available.

The VMM is a seam, but the constraint is correctness

ext4 is not a shared-disk filesystem. Pre-mounting a per-run block image in D standbys corrupts it with zero concurrent Execs — purely from having a warm pool. So the Firecracker arm is measurable only with mount-at-acquire (mount on the hot path, Execs serialized per run), and E10 must measure that variant or it measures something incorrect. Cloud Hypervisor + virtio-fs has neither problem.

The counterweight, so the table is honest: virtio-fs moves guest path resolution onto the host, into virtiofsd, making it the confinement boundary for the whole design — so it runs unprivileged and sandboxed, and the symlink-escape hazard it introduces does not exist on the block arm.

What is explicitly not claimed

  • Not that the VMM cannot be escaped — the claim is that the boundary moved, not that KVM is unbreakable.
  • Not cost/resource-seconds, multi-host, or the gVisor/Kata arms P4's row also lists.
  • The largest live risk is stated rather than buried: Cloud Hypervisor's snapshot caveats are unverified, while §4.3's correctness argument prefers it. Confirming them is step 0 of the build order, ahead of any code.

Reviewer notes

Two judgement calls worth a second opinion:

  1. §9 puts path confinement and SANDBOX_TOKEN delivery for the container path out of scope — they are real holes today (§2.3) but are remote-worker changes to a tier this slice replaces. Sibling issues rather than scope creep, but that is a call.
  2. This PR rewrites the P4 registry row on the grounds that its infra gate expired.

Verification

  • make lint passes — all pre-commit hooks including gitleaks
  • Formatted with the pinned Prettier (changed files only, since Prettier ignores .gitignore and would walk sibling worktrees)
  • Self-review: no placeholders; every referenced repo path exists; line-number citations spot-checked (sharing.ts:13 and its c === 1 throw, .gitignore:27-30, run-leaf.ts:434); the P4 row is still at README.md:84 after Prettier reflowed the table, so both citations to it remain accurate
  • Branch is one commit on top of main — no unrelated commits

Refs #57.

Replaces the sandbox tier's `bash -c`-in-a-container with one ephemeral
microVM per `Exec`, behind the unchanged `Attach` wire contract, so the
isolation boundary moves from namespaces+seccomp to KVM at per-call
granularity. No new `SandboxTransport`, so no conformance-battery entry;
the only harness change is one additive `workspace_key` proto field, which
is required for correctness — leases are keyed by run id and nothing on the
wire carries it, so without it consecutive leaseholders inherit the previous
run's workspace.

The load-bearing decision is warm standby. Replenishment costs ~10–25ms and
cannot sit inside a 15ms request; within one leaf run, `Exec`s are separated
by model round trips, so `vmpool` holds D paused standby VMs per active run
and the hot path is pop → vsock write → run → SIGKILL. The <15ms target is
met by relocating VM creation, not by a faster restore, and the real
constraint becomes replenishment throughput — which is what E11 measures.

Verified against Firecracker's snapshot documentation rather than assumed:
listening vsock sockets survive restore (so a guest agent parked in
`accept()` is documented behaviour, not a trick); resuming one snapshot
repeatedly is documented as insecure (hence the no-secrets-in-the-snapshot
invariant, plus a guest kernel >= 5.18 so VMGenID actually reseeds); host
resources must be at the same relative paths (hence a jailer chroot per VM
rather than drive-path patching); and the guest wall clock resumes stale
(hence clock_realtime). Independently: ext4 is not a shared-disk filesystem,
so pre-mounting a per-run block image in D standbys corrupts it with zero
concurrent Execs — which makes the VMM choice a correctness question rather
than a latency one, and biases it toward Cloud Hypervisor + virtio-fs.

P4's stated infra gate — "no nested KVM on the m6i cluster" — is retired by
EC2 nested virtualization on C8i/M8i/R8i (Feb 2026) plus P6's VM substrate.

Adds ADR-0035 and updates the milestone registry and ADR index. Design only;
no code.

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

@cwiklik cwiklik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Design review of 7d3464c. I verified every citation in §2 and §10 against 45a218d — the commit §2 pins — plus both external claims the "why now" rests on. They hold, including the ones that would have been easy to get wrong.

The AWS nested-virt claim is exact. Feb 16 2026, C8i/M8i/R8i, "available in all commercial regions," and the announcement's own framing is that nested VMs previously required bare metal — which is precisely the gate README.md:84 recorded. The gate really has expired, so "why now" is not a rationalisation.

Every repo citation resolves, and says what the spec says it says. sandbox.proto:49-55 is the Exec message with streaming at :54; ExecRequest (:86) uses fields 1–2, so workspace_key = 3 is genuinely free. In operations.ts, :24/:34/:67/:128/:136 are cat/stat -c %s/base64 -d >/test -e/ls -1A in the order the §2.2 table lists them, createPodEditOps at :77 does compose read+write at :78-79, and createPodBashOps wraps an arbitrary command at :107-108. paths.ts's "returned unchanged (mirrors the SSH example's naive prefix replace)" is verbatim and shQuote is at :2; config.ts:26 is podCwd ?? '/workspace'; sandbox-lease.ts:3 is "member = leaf id" and :15-17 is the expiry-sweep sentence §4.4 copies rather than reinvents; main.go:95 reads SANDBOX_TOKEN from the environment; sharing.ts:13 is detectKnee with the c === 1 throw two lines below it. transport.ts:57-73 confirms §2.1's load-bearing claim — three implementations, GrpcRelayTransport declaring remote-abort at :63 — so §4.1 is right that honouring DEFAULT_OUTPUT_CAP owes no new declared mechanism. Module path, go 1.25.0 and internal/{exec,relaytest,session} match; so do .gitignore:27-30 and the driver-local/consolidated split at experiment-results.md:3-4.

I have one blocking objection, and it is narrow: §3.4's empty-workspace_key semantics are a fail-open on the single property this slice exists to establish, and §8 pins the fail-open as intended behaviour. Inline.

The rest is unusually well-reasoned, in ways worth naming because they are the parts a later reader will be tempted to simplify away. Deriving D from operations.ts:78-79 instead of picking 2. The PSS-not-RSS note, which prevents an error that would abandon a working design by more than an order of magnitude in the direction that looks like failure. And reading the ext4 constraint as a bound on what E10 is permitted to measure at all — "pre-mounted standbys corrupt it with zero concurrent Execs" — rather than as a preference between VMMs, which is what makes §4.3 a correctness argument instead of a benchmark plan.

Three non-blocking items: §7.4's "house style" citation points at unrelated SWE-bench machinery and the convention does not exist yet; §7.2's decision table leaves uncovered the band the spec's own example numbers land in; and this PR invalidates its own README.md:84 citation. Plus one nit.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Docs (specs + ADRs), and every source citation they make
Agent/IDE config (.claude/.vscode): none
Commits: 1, signed off, Assisted-By per house convention (not Co-Authored-By)
CI: 12/12 green on 7d3464c, lint included — so prettier and gitleaks are satisfied
PR body: ## What rather than ## Summary; no pr-verifier workflow runs in this repo, so not flagged

### 3.4 The one wire change

`ExecRequest` gains `string workspace_key = 3`, populated by the harness from the lease's run id.
Empty means "today's single shared workspace", so it is backward-compatible and `remote-worker`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

must-fix — an empty workspace_key is specified as "today's single shared workspace," and on the microVM path that is the cross-run bleed §2.3 describes, reached through the new door.

The backward-compatibility argument is correct for remote-worker, which ignores the field. But §8 extends it to the new worker (:643): "an old harness against a new worker, and a new harness against remote-worker, both behave exactly as now." "As now" is config.ts:26's process-wide /workspace. So a microvm-worker serving Execs with an empty key puts every run in one workspace directory — and in that configuration §1's claim that "no state and no compromise carries from one tool call to the next," and the ADR's that "§2.3's cross-tenant reads … are closed on this path," are both false.

What makes this worth blocking rather than noting is that three independent safeguards go blind on the same empty string:

  1. WorkspaceRoot/<workspace_key> (§4.4) collapses to one directory for all runs.
  2. Pools are per-run, keyed on workspace_key (§4.3) — so every run draws standbys from one pool, and the mounted-workspace binding that section's whole argument rests on stops distinguishing runs.
  3. §6's "each VM carries its workspace_key and Exec asserts the popped VM matches" — the row annotated "cheap assertion, catastrophic bug" — passes trivially when every key is "".

And §8's cross-run-bleed gate cannot see any of it: it drives "two interleaved workspace_keys," both non-empty by construction. The design therefore has a test for the property, a pin that permits violating it, and nothing that catches the permitted violation.

The fix is a sentence, and it is the posture the rest of §6 already takes — "never fall back to running commands on the host," "fail the unit at start" rather than degrade:

microvm-worker rejects an empty workspace_key with a counted ExecError. Empty is backward compatibility for remote-worker only; on the VM path there is no correct workspace to choose, so there is nothing to fall back to.

Then scope §8's pin to the container arm — which is where its position in the build order says it was actually conceived. Step 5 delivers the proto field and step 6 delivers microvm-worker, so at the moment the pin becomes "provable" the new worker does not exist; it acquires its microVM meaning silently one step later. Adding the complement as a gate closes the loop: an empty key on the VM path is refused, and that refusal is asserted.

This also makes §3.4's own argument land harder rather than softer. The section already says that hiding the field to preserve a "zero harness change" headline would be "buying a talking point with a security bug" — the empty-key fallback is the same purchase, one paragraph later and for the same headline.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 8f0531f — you're right, and the fix is the sentence you drafted.

§3.4 now states that microvm-worker refuses an empty workspace_key with a counted ExecError, with your three-safeguards argument recorded as the reason: WorkspaceRoot/<key> collapsing to one directory, §4.3's per-run pools all drawing from one pool whose mounted-workspace binding no longer distinguishes runs, and §6's popped-VM key assertion passing trivially when every key is equal. §8's pin is retitled "empty ⇒ today's behaviour on the container arm" and says explicitly that it is not extended to microvm-worker; a new gate, "Empty key is refused", sits directly above the container-arm pin as its complement, so the bleed gate no longer tests a property another pin permits violating.

One consequence your comment didn't name, now stated in §9 rather than left for step 6: /turn cannot use the VM tier this slice. It never leases (run-turn.ts:57 resolves a single pod via resolveSandboxConfig), so it has no run id to populate the key with, and §10's file table changes run-leaf.ts only. With the refusal in place that path is container-only — which is consistent with §7 driving leaves, and better than an empty key quietly meaning "share one workspace". Giving /turn a request-scoped key is the same plumbing MU2 owes it for pool selection.

ADR-0035 carries both the refusal and the /turn consequence.


### 7.4 Falsifiable predictions

Recorded up front, house style (`experiments/test/predictions.test.ts`):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion — experiments/test/predictions.test.ts is not this convention; it is the SWE-bench output-format test.

All 13 lines of it assert one thing: that predictionRecord() produces the predictions.jsonl shape (instance_id, model_name_or_path, model_patch). Every other predict* occurrence under experiments/ is the same machinery — swebench/merge_predictions.py, swebench/evaluate.sh, workload.ts. It is a name collision, not a precedent.

And the convention it is cited for does not exist yet: falsifiable appears nowhere in docs/specs/ or docs/adrs/ on main, and no spec records predictions up front. That matters more than a wrong path, because §7.4 is the strongest methodological commitment in the document and "house style" makes it sound already paid for. A prediction that can be quietly reinterpreted once the numbers arrive is a hypothesis, not a commitment — so if these four are to bind, something has to record them before the first rung, and §10's file table lists no such thing.

Two honest options. Drop the parenthetical and say plainly that this spec introduces the practice, with the four predictions recorded in deploy/microvm/EXPERIMENTS.md beside the results that will judge them. Or keep a mechanism and name it in §10 — a deploy/microvm/predictions.json written before the first rung, with a test asserting it is unchanged once results land. The second is barely more work and has the side effect of making the claim of a house style true for whichever spec comes next.

Either way it is worth fixing precisely because the rest of the document earns the right to be trusted on citations: :62 opens §2 with "Traced in the tree at 45a218d, not inferred," and every one of those citations checks out. This is the one that does not, and it is in the section asking for the most credit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed and fixed in 8f0531f. I read the file rather than take it on faith: 13 lines, asserting predictionRecord() produces {instance_id, model_name_or_path, model_patch}. A name collision, exactly as you say. Also confirmed falsifiable appears in no spec or ADR on main, so the convention was cited before it existed.

Took your second option, since it makes the claim true for whichever spec comes next. §7.4 now opens by saying this spec introduces the practice — with the predictions.test.ts parenthetical gone and the collision named so nobody re-cites it — and the four predictions are written to deploy/microvm/predictions.json before the first rung, pinned by a test asserting the file is unchanged once results land. §10's file table lists it as a new file.


| Result | Action |
| --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| Warm hot path **< 5ms metal / < 8ms nested** and replenishment CPU **< 25ms metal / < 40ms nested** | Proceed as designed. The VMM is then chosen on the correctness/security axis of §4.3, which cuts both ways |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion — the decision table leaves the middle uncovered, and the spec's own example numbers land in it.

Three rules, and between them: on metal, a warm hot path in [5, 15) ms matches no row — it fails "proceed as designed" without triggering "the design fails on its own terms." Replenishment CPU in [25, 50] ms on metal is the same gap. Nested has thresholds only for proceeding (< 8ms / < 40ms) with no counterpart to ≥ 15ms or > 50ms, so no nested result can fire either negative rule.

This is not hypothetical. :512 sets the anchor at "a 4ms baseline would make this a 3× regression," and prediction 2 (:580) expects the warm hot path "within 2× of the container baseline" — so the document's own illustrative numbers predict ~8ms on metal, squarely in the gap. Worse, a 7ms metal result would satisfy the design's stated <15ms target (the thesis at :22, restated in §3.2) while failing the proceed threshold here, so the two numbers the spec commits to disagree about the same outcome and nothing says which governs.

Rules written before the data are worth most in exactly the band where someone would otherwise argue; as written the table covers only the bands nobody would argue about. One row fixes it — proceed with the split pre-authorised, or proceed but re-price against the container baseline instead of against 15ms, or hold for a metal re-run. Any of the three is defensible; the value is in choosing now rather than after a rung produces 8ms.

Worth settling what nested governs, too. If nested exists for iteration and metal is authoritative — which is what the cross-cut at :520 implies — then saying so explicitly ("no nested result fires a stop rule") closes the nested half of the gap by scope rather than by inventing two more thresholds.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 8f0531f. Of your three defensible options I took re-price against the container baseline, because it also settles the internal disagreement you identified rather than just filling the band.

New row: warm hot path [5, 15) ms metal, or replenishment CPU [25, 50] ms metal → proceed, re-priced against the container baseline instead of against 15ms, with §3.3's split pre-authorised if the ratio exceeds 2×. The reasoning is stated so the choice isn't arbitrary: 15ms is an absolute borrowed from the tool-call budget, while the ratio is what this tier can actually be held to — at a 1ms baseline, 8ms is an 8× regression that no absolute target would catch. ≥ 15ms stays a hard stop regardless of ratio, since past it the budget is gone whatever the container costs.

Nested: closed by scope, as you suggested, rather than by inventing two more thresholds. "Nested fires no stop rule" is now explicit — a nested result above the proceed thresholds schedules a metal run; it never by itself stops the design or mandates the split.

- **Not claimed: that the VMM cannot be escaped.** We claim the boundary moved from namespaces+seccomp
to KVM, not that KVM is unbreakable. §9 keeps that out of scope deliberately.

**The registry's stated blocker for P4 has expired.** `docs/specs/README.md:84` records P4 as

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion — this PR invalidates its own citation. After merge, README.md:84 is the row you rewrote.

I checked both sides. On 45a218d, line 84 is the old P4 row: "infra-gated: bare-metal pool vs Kata peer-pods vs gVisor — no nested KVM on the m6i cluster." On this branch, line 84 is the new row, which says that gate "is retired." The line number is stable — your verification note is right about that — but the content moved, so the check confirmed the wrong invariant. A reader following the citation lands on a row asserting the opposite of the quoted text, and the quoted phrase no longer appears anywhere in the file; only the shortened "no nested KVM" survives, inside the row that retires it.

The ADR carries the same sentence (0035-per-exec-microvm-warm-standby.md:17).

The fix is the convention this spec already uses one section later. :62 pins its citations to a commit — "Traced in the tree at 45a218d, not inferred" — so do that here, plus past tense: "docs/specs/README.md:84 recorded P4 as … (at 45a218d; this slice rewrites that row)." That keeps the claim checkable indefinitely rather than only until this PR merges, which is the same reason §2 pins a commit at all.

As a check on scope: this is the only citation in the PR with that problem — the other README-relative references are to files this branch does not modify.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Verified both sides before fixing — at 45a218d line 84 is the old planned row with the quoted text; on this branch it is the new row asserting the gate is retired. Fixed in 8f0531f.

§1 now reads: at 45a218d, docs/specs/README.md:84 recorded P4 as "…" — pinned to that commit and past tense, with an explicit note that this slice rewrites the row, so the quotation stays checkable indefinitely rather than only until merge. Same convention §2 uses one section later, for the same reason.

ADR-0035:17 carried the same sentence and got the same treatment.

`sh-test-redis` container on `:6379`.

**Git remotes here.** An HTTPS proxy MITMs GitHub with a private CA, so every `git` network command
needs `-c http.sslCAInfo=/Users/paolo/.cortex/ca/ca.crt`, and `gh`'s GraphQL-backed subcommands fail

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit — /Users/paolo/.cortex/ca/ca.crt is a machine-specific absolute path in a committed spec.

§10 is addressed to "a fresh session," which is the one reader guaranteed not to have that path. $HOME/.cortex/ca/ca.crt works for anyone whose bridge is installed in the usual place. Better still, git config --global http.sslCAInfo <path> set once removes the need to remember the flag on every network command, which is what this paragraph is really trying to prevent — and it fixes gh's HTTPS calls at the same time, leaving only the GraphQL note standing.

No secret is exposed — it is a CA certificate path, and lint's gitleaks pass agrees — so this is purely about the instruction being followable by the reader it is written for.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 8f0531f, taking the better option you flagged rather than just the $HOME substitution. §10 now recommends setting it once — git config --global http.sslCAInfo "$HOME/.cortex/ca/ca.crt" — instead of passing -c http.sslCAInfo=… on every command, notes that this also fixes gh's HTTPS calls, and leaves only the GraphQL-subcommand caveat standing. The curl fallback uses $HOME too.

The warm pool's accumulating cost was under-specified: a single IdleReclaim
governed both dropping a run's paused standby VMs and deleting its workspace,
and nothing said what triggers it.

Three gaps, each now answered in the spec:

- "Swept by the next acquire" (sandbox-lease.ts:15-17) does not transfer. That
  works because every acquirer touches one shared ZSET; here the state is a
  per-run map and the run needing reclamation is the one issuing no requests.
  So the sweep is stated: every key on every Exec, plus a ReclaimScanInterval
  ticker, so an idle host converges to zero standbys.

- The accumulator is the last Exec of every run, not a rare leak: an
  unconditional refill hands D standbys to a run as it stops working. At D=2
  and 100 runs finishing in one window that is ~50 GiB of guests that never
  serve a command. ReplenishDelay (200ms) suppresses that refill; the model
  round trip is hundreds of ms, so it costs nothing a run will notice.

- One TTL cannot serve both halves. A resumed gate presents the SAME
  workspace_key (run-leaf.ts:76 — toSessionId is deterministic), so an
  aggressive TTL would delete a parked run's uncommitted edits, which for a
  solve leaf is the candidate patch. Split into StandbyIdle (90s, RAM, costs
  one cold acquire) and WorkspaceIdle (2h, state, unrecoverable if early),
  with RunParked as the state a gated run sits in.

Explicit release is recorded as deferred rather than assumed: a Release variant
on the existing ServerFrame oneof, sent only on a terminal LeafResult and never
on paused, is the one signal a timer cannot infer — but it is a second wire
change against §3.4's one, with a stated trigger in §9.

Also: E10 rung 4 prices paused and bulk teardown, not just in-flight; E11
reports idle standby residency and parked runs as distinct quantities;
prediction 5 makes convergence falsifiable; §8 gates that a parked run keeps
its tree; §6 gains rows for idle accumulation, reclaim storms, and the inverse
(deleting a parked workspace). ADR-0035's consequences updated to match.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
… is per-dispatch

The previous commit claimed a resumed gate "expects its tree", so an early
workspace TTL would destroy uncommitted agent edits. Checking that against the
code shows it is wrong in both halves, and the corrected version is simpler.

What the code actually does:

- cleanupWorkspace runs in a `finally` (run-leaf.ts:665, :816), so it fires on
  EVERY dispatch exit — including the `paused` return, which sits inside that
  try. The harness already removes the worktree when a leaf pauses at a gate.
- The tree is a detached worktree at a pinned commit (converge.ts:38, idempotent
  on an existing dir), so re-creating it yields the same bytes. Continuity
  across dispatches is the Redis session log, never the filesystem.
- The leaf kind that does hold uncommitted edits — solve — has no gate path at
  all (realProduceSolve): it converges, edits, captures the diff and cleans up
  within one dispatch.

So "is the run finished?" is indeed unanswerable — a session can sit on HITL
approval indefinitely — but nothing needs it answered. The question is "has the
dispatch exited?", which the harness computes exactly and already acts on. Both
thresholds are therefore crash backstops for a dispatch that died before its
`finally`, not lifecycle: firing early costs a re-converge, never data. Two of
them only because RAM is urgent and disk is not. Release needs no
terminal-vs-paused distinction either — it rides the same `finally`.

Also adds §4.5, an owed decision found while tracing this: /workspace/repo is
shared across leaves on a pooled pod, and it lives INSIDE the dir P4 makes
per-run — so every run pays a full fetch, seconds of it, which in E11 would look
like a replenishment ceiling. Three candidate shapes recorded (host-shared repo
mount, per-run clone with alternates, pre-seeded snapshot), plus a §7.5
requirement to time converge separately and a §6 row. The config-bundle cache
goes the other way and the spec already says so at §5.1.

§8's gates change accordingly: "a parked run keeps its tree" is replaced by
"parked, then resumed" and "reclaim, then re-dispatch" — the two properties that
actually make the thresholds safe to fire.

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

@cwiklik cwiklik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Second pass, on a7c4805 (two new commits since review 5159243396). The new work is on a different axis from my earlier findings — reclamation — so I reviewed it fresh and re-checked the five open items.

None of the five findings from 5159243396 are addressed. They are unchanged in substance and only renumbered, so the earlier inline comments still read correctly against the current file:

Prior finding Was Now Status
must-fix — empty workspace_key fails open :228 :232 (pin at :800) open, unchanged
suggestion — predictions.test.ts miscitation :577 :720 open, unchanged
suggestion — uncovered decision bands :526 :662 open, unchanged
suggestion — README.md:84 self-refuting citation :45 :45 + ADR :17 open, unchanged
nit — /Users/paolo/… absolute path :724 :889 open, unchanged

On a7c4805 itself. Self-correcting a commit you just pushed, in public, with the code that disproves it quoted line by line, is the right instinct and I would rather review this than the version that quietly kept going. The correction is also right about the two things it set out to fix: cleanupWorkspace really does sit in a finally (run-leaf.ts:665, :816), the tree really is a detached worktree at a pinned commit (converge.ts:38), and realProduceSolve really has no gate path — so "firing early costs a re-converge, never data" is a sound conclusion and the two-threshold split is well motivated.

But the mechanism it now rests on does not cross the boundary this design introduces, and that is a blocking finding — detailed inline at :388. In short: cleanupWorkspace is transport.exec(buildCleanupScript(runId)) (converge.ts:76), a command sent through the sandbox, and the script removes only /workspace/leaves/<runId>. On the microVM path that is an Exec — it cannot reach the host-side WorkspaceRoot/<workspace_key> that vmpool created, and vmpool cannot tell it apart from any other command, so it refreshes the idle clock and schedules a refill. The "primary teardown" is therefore the exact final Exec that §4.4 names as the accumulating case. The sign is inverted.

Worth noting the shape, because it is now three for three: this is the same error as my still-open must-fix at :232 (§8 pinning container-path behaviour onto microvm-worker) and as the README.md:84 citation (verifying line stability when content was the load-bearing part) — a fact established on the container path, carried across to the VM path without re-checking that the mechanism itself crosses. Everything on the harness side of these claims is correct; what is missing each time is the step asking whether it is still true once the sandbox is a VM on another host.

§4.5 is the strongest thing in either new commit and I would not want it lost in the above. Noticing that /workspace/repo lives inside the directory P4 makes per-run — so converge's shared-repo-plus-worktree structure (converge.ts:30-38, fetch under a per-pod flock) silently degrades to a full fetch per run — is a cost larger than every millisecond the design optimises, and it was found by tracing rather than by measurement. Recording it as an owed decision with three candidate shapes, plus §7.5's requirement to time converge separately, is better than guessing at it now. The observation that it would surface in E11 as throughput falling off with active runs, indistinguishable from a replenishment ceiling, is exactly the kind of thing that invalidates a rung silently.

Also verified on the new material: the ADR's consequences track the spec; MaxReclaimsPerScan as a munmap-storm bound is consistent with E10 rung 4's new bulk-teardown variant; prediction 5 is genuinely falsifiable (it names a bound, a direction, and a quantity that must not move); §8's two new gates — "parked, then resumed" and "reclaim, then re-dispatch" — do test the properties that make the thresholds safe, which is a real improvement on "a parked run keeps its tree"; and the 50 GiB arithmetic is right for its stated inputs (200 × 256 MiB). One inconsistency in that paragraph's window, inline at :422.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Docs (specs + ADRs), and every source citation the new commits make
Agent/IDE config (.claude/.vscode): none — re-run on the full diff at a7c4805, clean
Commits: 3, all signed off, Assisted-By per house convention
CI status: passing (12/12 on a7c4805, lint included)
Base: still 45a218d; docs-only, +1139/−10 across 4 files

| Bracket | Mechanism |
| ------- | --------------------------------------------------------------------------------------- |
| Entry | `convergeWorkspace` on first use — idempotent, a no-op if the tree is already there |
| Exit | `cleanupWorkspace` in a **`finally`** (`run-leaf.ts:665`, `:816`) — **every** exit path |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

must-fix — this finally is not a teardown on the microVM path. It is an Exec, which makes it the trigger for the accumulation §4.4 exists to bound, not the cure.

Both citations resolve, so the correction in a7c4805 was right to trust them that far. What they do is the problem:

// converge.ts:76
export async function cleanupWorkspace(transport: SandboxTransport, runId: string) {
  try { await transport.exec(buildCleanupScript(runId), { timeout: 60 }); } catch { /* ignore */ }
}

// converge.ts:44-51 — "Remove the per-leaf worktree and prune orphans"
`REPO=/workspace/repo; LEAF=${sq(LEAF)}`,
`git -C "$REPO" worktree remove --force "$LEAF" 2>/dev/null || rm -rf "$LEAF"`,
`git -C "$REPO" worktree prune 2>/dev/null || true`,

So it is (a) a command sent through the sandbox, not a host-side operation, and (b) scoped to /workspace/leaves/<runId> — it never touches /workspace or /workspace/repo. Three consequences, and the third is the one that inverts the argument:

  1. It cannot reach the directory vmpool created. The command runs inside an ephemeral VM whose mount is WorkspaceRoot/<workspace_key>. A guest can delete inside its mount; it cannot delete the host-side per-run directory, and §4.4 is about that directory.
  2. vmpool cannot tell it apart from any other command. Nothing on the wire marks it as terminal — that is precisely what §9's Release variant would add. So it is not a signal at all.
  3. It is an Exec, so it does the two things §4.4 says an Exec does: refreshes the run's idle clock, and schedules a replenishment. Under ReplenishDelay the harness's own cleanup is therefore the last Exec of the run that mints a standby nothing will ever use — the systematic case at :422, arriving through the mechanism now named as its remedy.

Two further qualifications the prose drops, both minor next to the above:

  • "every exit path" is not exact. :816 sits under if (converging) (run-leaf.ts:813), and converging = selected != null && !!env.repoUrl && !!env.ref (:727). A verdict leaf dispatched without repoUrl/ref never calls it.
  • :665 hardcodes the transport: cleanupWorkspace(KubectlTransport(selected.config), sid) — so the solve path's cleanup goes to a pod by kubectl exec regardless of which transport served the run. :816 does prefer selected?.transport, so the two sites differ. On P4's single VM host there is no pod for the :665 form to reach.

What survives. The three supporting facts are all correct — detached worktree at a pinned commit (converge.ts:38, idempotent per :34/:38), continuity in the Redis session log, realProduceSolve capturing its diff and cleaning up within one dispatch. So the conclusion holds: re-deriving a tree is free of consequence, and both thresholds are safe to fire early. Keep all of that.

What has to change is the claim built on top of it, in three places:

  • This row (:388) — the harness brackets its worktree per dispatch, inside the workspace. The workspace itself is bracketed by nothing the worker can observe.
  • §6's "Workspace leak" row (:574) is backwards. It makes WorkspaceIdle "the backstop for a dispatch that died before reaching" the finally. On the VM path WorkspaceIdle is not a backstop — it is the only thing that ever deletes a workspace, which is what the pre-correction commit had right.
  • ADR 0035:145-146 carries the same sentence and needs the same scoping.

That re-promotion has a consequence worth stating rather than leaving implicit, because §4.5 sharpens it: if WorkspaceIdle is the sole deletion path, then at 2h every run's full repo fetch stays on disk for two hours after it stops working. §4.5 establishes that each run now pays that fetch; together they make retained trees the disk high-water mark rather than an edge case, and the §2.4 quota bounds each one without bounding the sum. Either size WorkspaceIdle against that number or take Release into this slice.

On §9 (:817): the proposal itself is still sound — adding a Release frame at that same call site does work, and Pool.Reclaim is the right entry point. Only the rationale needs rewording, since "sent from the finally that already calls cleanupWorkspace" currently reads as though that finally already reaches the worker. It would be the first thing that does.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right, and this was the load-bearing error in a7c4805 — fixed in 8f0531f. I verified the two mechanics myself rather than take them from the quote: cleanupWorkspace is transport.exec(buildCleanupScript(runId)), and the script touches only /workspace/leaves/<runId> (worktree remove --force / rm -rf), never /workspace or /workspace/repo.

What changed:

  • §4.4's bracket table gains a "Reaches the host dir?" column — both rows no — and the prose now says plainly that the harness brackets its worktree while the workspace is bracketed by nothing the worker can observe. So on the VM path WorkspaceIdle is not a backstop; it is the only thing that ever deletes a workspace. Your two further qualifications are in as well: :816 under if (converging) (run-leaf.ts:813, :727) so it is not universal, and :665 hardcoding KubectlTransport(selected.config), aiming at a pod a single VM host does not have.
  • §6's "Workspace leak" row is re-promoted accordingly, and notes that §2.4's per-workspace quota bounds each workspace without bounding their sum.
  • §9's rationale is reworded to "emitted from the same finally — not by that call, which never leaves the guest", plus the observation that Release would also have to cover the if (converging) and hardcoded-transport gaps, which is a harness fix rather than a protocol one.

Your point 3 went further than I had registered, and it invalidates a claim I made rather than merely mis-scoping one: because the cleanup Exec is a run's last wire event, ReplenishDelay cannot take the residual to zero — it pops a standby and schedules a refill 200ms later with the run already over. My "a run that has finished never triggers a refill at all" was simply wrong. §4.4 now says so explicitly, a new §6 row ("Cleanup Exec looks like work") records the mechanism, and the paragraph ends on Release being the only thing that removes the residual — which is the honest case for taking it into this slice rather than filing it as a nice-to-have.

On the disk high-water mark you raised at the end: WorkspaceIdle is now 30m interim, and §4.5 explicitly owns the final number, because as sole deletion path it retains whatever §4.5 leaves per run — option 1 leaves a cheap worktree, options 2/3 a full object store, where (runs per WorkspaceIdle) × repo size is the figure and a tens-of-minutes timer is the wrong instrument. Both sections state that the two decisions are one.

Everything under "What survives" was kept: the pinned-commit worktree, continuity in the Redis session log, and realProduceSolve capturing its diff within one dispatch — so early reclamation is still free of consequence, which is the conclusion the correction was for.


**The accumulating case is the last `Exec` of every run, not a rare leak.** Every `Exec` schedules a
replenishment, so an unconditional refill hands D fresh standbys to a run at the exact moment it stops
issuing work, and they sit paused until the sweep. At D=2, a 5-minute threshold and 100 runs finishing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion — the arithmetic uses a threshold the spec does not set, and it is the paragraph that has to carry ReplenishDelay.

"At D=2, a 5-minute threshold and 100 runs finishing inside that window" — but StandbyIdle is 90s (:274, :407, and :820 restates it). The 50 GiB is right for its own inputs (200 × 256 MiB = 51,200 MiB), so nothing is miscalculated; the window is simply 3.3× the default, and the run count that fits a window scales with it. At the same completion rate and 90s, the figure is nearer ~30 runs and ~15 GiB.

Still a large number, and still enough to carry the section's point — which is why it is worth using. 15 GiB attributable to a setting the design chose, quoted against the threshold the design actually sets, is harder to argue with than 50 GiB against a threshold that appears nowhere else. As written a reader who checks (and this spec's readers do — :62 invites it) finds the two numbers disagreeing and has to work out which governs.

If the 5-minute figure is deliberate — the pre-StandbyIdle illustration, i.e. what a naive threshold would have cost — then say so, since that framing makes the same point more strongly: it prices the decision rather than the hazard.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 8f0531f, and I kept both numbers per your last paragraph, since they price different things. §4.4 now carries a small table:

Window Runs finishing in it Paused VMs (D=2) At 256 MiB guests
5 min — what a naive TTL costs ~100 200 ≈50 GiB
90s — StandbyIdle as set here ~30 60 ≈15 GiB

labelled "the first prices the decision, the second the residual". That way the 50 GiB figure keeps doing the rhetorical work it was doing without disagreeing with :274.

Related, from your other comment on this push: ~15 GiB is a standing cost, not a transient one, because the cleanup Exec means ReplenishDelay cannot take it to zero. That is now stated in the same section.

…tions)

All seven verified against the tree before acting; all seven were right.

must-fix — empty workspace_key on the VM path (§3.4, §8). The additive-field
pin extended "empty means today's shared workspace" to microvm-worker, where
that IS the cross-run bleed §2.3 describes: one directory for every run, one
standby pool whose per-run mount binding no longer distinguishes runs, and §6's
popped-VM key assertion passing trivially. microvm-worker now REFUSES an empty
key with a counted ExecError; the compatibility pin is scoped to the container
arm and a gate asserts the refusal. Consequence stated rather than left to be
discovered at step 6: /turn never leases, so it has no key and cannot use the
VM tier this slice (§9).

must-fix — the harness `finally` is an Exec, not host-side teardown (§4.4, §6,
§9, ADR). cleanupWorkspace sends `worktree remove` THROUGH the sandbox, scoped
to /workspace/leaves/<runId>; it never touches /workspace or /workspace/repo,
and a guest cannot delete the host dir its mount points at. So WorkspaceIdle is
re-promoted to the ONLY deletion path, which the pre-correction commit had
right. Worse, that cleanup is an Exec vmpool cannot distinguish from work: it
pops a standby, refreshes the idle clock and triggers a refill for a run that is
over — so ReplenishDelay cannot take the residual to zero, and only a Release
frame can. Also noted: `:816` is under `if (converging)` so it is not universal,
and `:665` hardcodes KubectlTransport, aiming at a pod a VM host does not have.
The three supporting facts survive, so early reclamation is still free.

suggestion — arithmetic used a 5-minute window while StandbyIdle is 90s. Both
figures now given and labelled: ~50 GiB prices the naive threshold, ~15 GiB is
the residual at the chosen default.

suggestion — E10's decision table left [5,15)ms metal and [25,50]ms CPU
uncovered, which is where the spec's own numbers land (4ms baseline × prediction
2's 2x). Added the middle-band row, and resolved which number governs: the ratio
in that band, 15ms as a hard stop regardless. Nested now explicitly fires no
stop rule.

suggestion — predictions.test.ts is the SWE-bench predictions.jsonl shape test,
not a house style, and "falsifiable" appears in no spec on main. §7.4 now says
this spec introduces the practice, with deploy/microvm/predictions.json written
before the first rung and pinned by a test (§10).

suggestion — §1 cited README.md:84 for a row this PR rewrites. Pinned to
45a218d and past tense; same fix in the ADR.

nit — machine-specific CA path replaced with $HOME, plus the global
http.sslCAInfo setting that removes the per-command flag.

WorkspaceIdle drops 2h → 30m as an interim, and §4.5 now owns the final value:
as the sole deletion path it retains whatever §4.5 leaves per run, so a
host-shared repo mount makes it cheap and a per-run clone does not.

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

@cwiklik cwiklik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Third pass, on 8f0531f. All seven findings from 5159243396 and 5160539559 are fixed, and I checked each against the tree rather than against the commit message — including the two the commit reports as already verified.

Prior finding Fix Verified
must-fix — empty workspace_key fails open §3.4 refuses it with a counted ExecError; §8 gains "Empty key is refused"; §8's pin scoped to the container arm yes
must-fix — the finally is an Exec, not a teardown §4.4's bracket table gains "Reaches the host dir?" (both no); WorkspaceIdle re-promoted at :413; new §6 row "Cleanup Exec looks like work" yes
suggestion — predictions.test.ts miscitation §7.4 now says "This spec introduces the practice rather than following one"; deploy/microvm/predictions.json added to §10 yes
suggestion — uncovered decision bands middle-band row added, "the ratio governs", plus "Nested fires no stop rule" yes
suggestion — README.md:84 self-refuting pinned to 45a218d in past tense, in both spec and ADR yes
suggestion — 5-minute window vs 90s StandbyIdle both kept as a two-row table (90s → ~15 GiB, 5m → 50 GiB), which prices decision and residual separately yes
nit — /Users/paolo/… $HOME, plus the global http.sslCAInfo setting yes

The volunteered consequence checks out too: /turn never leases, so it has no run id to populate workspace_key with, and §3.4 now refuses an empty one — run-turn.ts:57 returns {config: await resolveSandboxConfig(env, headCwd)} with no lease, and :401's own comment reads "absent ⇒ resolve from the environment (/turn)". Recording it as a §9 boundary rather than discovering it in step 6 is the right outcome of tracing.

§4.4 is now the strongest section in the document. "The harness brackets its worktree; the workspace is bracketed by nothing the worker can observe" is the sentence the whole reclamation design needed, and the honest ending — that ReplenishDelay cannot take the residual to zero, so Release is the only thing that removes it, "which is the honest case for taking Release into this slice" — is a stronger position than the one it replaced, arrived at by conceding a claim rather than defending it.

Which is why the one blocking finding is what it is. It is not a new mistake: it is that retraction not reaching the end of the file. The corrected mechanism landed in §4.4 and in the ADR (0035:141 "narrows the tail but cannot close it", :145 "the mechanism, not a backstop") — both exactly right. Three downstream sites still assert the retracted version, and two of them are the artifacts this spec designates as binding:

  • §7.4's prediction 5 (:807) still predicts the post-final-Exec refill is zero VMs. §4.4 now says it is D. Inline.
  • §8's reclamation gate (:851) carries the same sentence as a blocking gate, so the retracted claim would become a red test against a correct worker.
  • §9's deferral rationale (:892-899) is the pre-retraction one, and now contradicts :413 and :474 in the same commit. Inline.

All three are mechanical — the correct replacement text already exists in §4.4 and the ADR, and none of them needs a new decision. I am blocking on it rather than filing it as a suggestion for one reason: §10's new predictions.json is written before rung 1 with a test asserting it is unchanged once results land. That guard is the right fix for my earlier finding, and it is precisely what makes this the wrong moment to leave prediction 5 wrong — the error would be frozen at the moment the immutability guard is added, and correcting it afterwards trips the guard that was just built.

One suggestion (:294 still says 2h) and one nit (MU2) inline. Nothing else in the fix commit needs changing.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Docs (specs + ADRs), every source citation the fix commit makes, and the spec's internal cross-references
Agent/IDE config (.claude/.vscode): none — re-run on the full diff at 8f0531f, clean
Commits: 4, all signed off, Assisted-By per house convention
CI status: passing (12/12 on 8f0531f, lint included)
Base: still 45a218d; docs-only, +1232/−10 across 4 files

`ls`/`find`-heavy commands rather than in `cat`.
5. **Idle standby residency returns to zero** within `StandbyIdle + ReclaimScanInterval` of a rung's last
`Exec` on an otherwise idle host, while **workspace count does not change** until `WorkspaceIdle`; and
`ReplenishDelay` holds the post-final-`Exec` refill to **zero** VMs rather than D. This predicts the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

must-fix — this prediction asserts the claim this commit retracts 330 lines earlier, and it is the one prediction two other sections read off.

ReplenishDelay holds the post-final-Exec refill to zero VMs rather than D.

Against §4.4 (:474-478), added in this same commit:

ReplenishDelay cannot take the residual to zero, and the reason is the cleanup Exec above. A dispatch's last wire event is cleanupWorkspace … it pops a standby, refreshes the run's idle clock, and schedules a refill that fires 200ms later with the run already over.

So the two sections do not merely differ in emphasis — a correct implementation falsifies this prediction by the maximum possible margin. Predicted zero; §4.4 says D. And D-per-finishing-run is the residual the new window table prices at ~15 GiB, so the spec already states the right number in one section and predicts its opposite in another.

Why this is blocking rather than a stale sentence. Prediction 5 is load-bearing for two decisions, both in the same §7.5 sentence (:770-774):

StandbyIdle, WorkspaceIdle, ReplenishDelay and ReclaimScanInterval are held at their §4.1 defaults and recorded, not swept. … §7.4's fifth prediction is what makes them falsifiable at one setting; a rung that violates it is the signal to sweep them, and §9's explicit-release trigger reads off the same metric.

  1. It is the sole justification for holding four knobs constant. A correct worker violates it on rung 1, which §7.5 reads as "the signal to sweep them" — so the experiment plan's response to a correct implementation is to add four dimensions to runs × D × GuestRAMBytes, chasing a mechanism the document already knows is wrong.
  2. §9's pull-in trigger reads off the same metric. With the prediction inverted, its failure carries no information: it fires on every correct run, so the condition that decides whether Release enters the slice is satisfied by construction rather than by evidence — which is the one thing §4.4 wanted it to be evidence for.

And §10's new deploy/microvm/predictions.json — added in this commit, written before the first rung, with a test asserting it is unchanged once results land — is what turns this from cheap to expensive. That guard is the right answer to my earlier finding. It also means this is the last moment the prediction is free to edit: after it is written, correcting prediction 5 trips the immutability test that was just added, and the alternative is the quiet reinterpretation §7.4 exists to prevent.

§8 carries the same sentence as a blocking gate (:851), which is the worse of the two consequences:

ReplenishDelay means a run's final Exec mints no replacement standby, while an Exec arriving inside the delay window is still served

§8's list is "all blocking," so an implementer writes that test, runs it against a worker that behaves as §4.4 describes, gets a red, and makes the worker match the test. The retracted claim becomes code — by the mechanism §8 exists to prevent. (That line is also 127 columns against ~105 for its neighbours, so it reads as a late hand-edit; worth rewrapping while you are in it.)

The replacement is already written. §4.4's window table is the residual prediction, so prediction 5's third clause can predict the residual's magnitude instead of its absence:

… and a run's final Exec — the cleanup Exec — does mint D standbys, which StandbyIdle ages out within one ReclaimScanInterval, so idle standby residency tracks (runs finishing per StandbyIdle) × D × GuestRAMBytes and not zero.

That is a stronger commitment than the current one, not a weaker one: it names a quantity that must appear, a direction, and a bound, where "zero" names only an absence. It also gives §7.5 a violation that means something — residency materially above that product is replenishment misbehaving, which is the signal §7.5 wanted — and gives §9's trigger a real threshold. §8's gate then becomes the assertion that pins it: the final Exec mints D, and StandbyIdle is what removes them, which is exactly the behaviour Release would be bought to improve on.

The second clause of prediction 5 ("workspace count does not change until WorkspaceIdle") is unaffected and correct — it is the one §4.4's re-promotion makes stronger.

- **The `fastTransport`/`streamTransport` split.** Kept as a priced one-line fallback on
`Exec.streaming` (§3.3), taken only if §7.2's third rule fires.
- **An explicit release signal from the harness.** A `Release{workspace_key}` variant on the existing
`ServerFrame` oneof, sent from the `finally` that already calls `cleanupWorkspace`, making it the primary

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

must-fix (same retraction, second site) — §9's bullet is the pre-retraction rationale, so the document now carries two deferral arguments for the same item, and §4.4 refutes this one.

The corrected argument is at :494-499 and is materially better: deferred because Release is a second wire change against §3.4's load-bearing "one wire change", with Pool.Reclaim already the entry point so the deferral costs no structure. That reason survives the retraction. This bullet's does not, in three places:

  1. :894 — "with both idle thresholds as crash backstops (§4.4)". But :413, added in this commit: "on the VM path WorkspaceIdle is not a backstop — it is the only thing that ever deletes a workspace." The ADR got this right (0035:145: "They are the mechanism, not a backstop"); §9 is the only place still calling them backstops, which is the exact claim the pass-2 finding was about.
  2. :896 — "because ReplenishDelay plus a 90s StandbyIdle should already bound the RAM cost." This is verbatim the rationale :474 retracts. It is also the reason §4.4 replaced: keeping it here re-states, as the justification for deferring, the thing the document now says is impossible.
  3. :897 — "Pulled in when E11 shows idle standby residency … is a material fraction of resident memory." Against :498: "the residual arithmetic above plus §4.5's retained fetches are that condition being partly met already." One section says the trigger is partly met now; this one says wait for E11. Worth resolving explicitly, because it is the difference between Release being in scope and not.

Also :893 — "sent from the finally that already calls cleanupWorkspace, making it the primary reclamation trigger" — is the wording I flagged last pass. The corrected form did land, at :487-488: "emitted from the same finally that calls cleanupWorkspace — not by that call, which never leaves the guest." That is exactly right. It went into §4.4 rather than into §9, so reading the file top-down the correction appears made and the older sentence 400 lines later still reads as authoritative.

Cheapest fix, and the one that stops this recurring: make §9's bullet a pointer. Name the item, state the wire-change reason in one clause, and defer to §4.4 for the mechanism and the trigger. §9 is an index of what is out of scope; §4.4 is where the argument lives and where it has now been corrected twice. Two copies of a rationale in one document is what produced this drift, and a third edit will hit it again.

If Release is coming into this slice on the strength of §4.4's closing sentence, then §9's bullet and this whole thread go away — which would be the cleanest resolution of all four points above. That is your call; what cannot ship is the document making both arguments.

MaxCommittedBytes int64 // memory-budget admission gate (§7.3)
MemoryReserveBytes int64 // host headroom never committed
StandbyIdle time.Duration // no Exec for this long → drop standbys, KEEP workspace; 90s (§4.4)
WorkspaceIdle time.Duration // no Exec for this long → delete the workspace too; 2h (§4.4)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion — the struct still carries 2h, and it is the value a rung is actually configured from.

Everywhere else in the PR moved: :437's table says 30m, :439-441 argues for it by name ("WorkspaceIdle is 30m rather than the 2h an earlier draft of this section assumed"), :536-539 ties it to §4.5, and the ADR says "30m, interim." This comment is the only 2h left that is not deliberately describing the old draft — and it is the operative one, because §7.5 (:770) holds the four knobs "at their §4.1 defaults," which is this struct.

Worth carrying the caveat rather than just the number, since §4.5 explicitly owns the final value:

WorkspaceIdle time.Duration // no Exec for this long → delete the workspace too; 30m interim, §4.5 owns the final value (§4.4)

A bare 30m in the struct will read as settled to whoever implements step 7, which is the reading §4.4 and §4.5 both take trouble to prevent.

- **The `/turn` path on the microVM tier.** It never leases (`run-turn.ts:57`), so it has no run id to
populate `workspace_key` with, and §3.4 refuses an empty one on the VM path rather than letting it mean
"share one workspace". Interactive sessions therefore stay on the container tier this slice; giving
`/turn` a request-scoped key is the same plumbing MU2 owes it for pool selection.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit — MU2 resolves to nothing a reader can look up.

MU1 is real — docs(spec): MU1 multi-user control plane (#238) and docs(spec): close four MU1 gaps… (#243) — so the series is established and the intent is clear enough. But there is no MU2 issue, no MU2 anywhere in the tree at 45a218d, and no milestones configured on the repo, so "the same plumbing MU2 owes it for pool selection" points at a commitment that exists only in your head at the moment of writing.

Naming the issue, or "the next multi-user slice (MU1 is #238)", keeps the claim checkable — the same reason §2 pins its citations to a commit instead of to main. Cheap now; the alternative is a reader in six months trying to work out whether MU2 was renamed, merged, or dropped.

… nit

§4.4's correction (post-final-Exec refill is D standbys, not zero,
aged out by StandbyIdle) hadn't propagated to three downstream sites
that still asserted the retracted "zero" claim:

- §7.4 prediction 5's third clause
- §8's reclamation-path unit test description
- §9's Release deferral bullet, which also still called the idle
  thresholds "crash backstops" and repeated the retracted 90s/RAM
  rationale — collapsed into a pointer at §4.4 instead of a second
  copy of the argument

Also: the Config struct still carried WorkspaceIdle's superseded 2h
value (everywhere else in the doc moved to 30m interim, §4.5 owns
final); and the MU2 reference resolved to no such issue, reworded to
name MU1 (rossoctl#238) instead.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

@cwiklik cwiklik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fourth pass, on d660dac — a 16/15-line commit touching the spec only. All four findings from 5167566056 are fixed, and the retraction now reaches the end of the file.

Finding Fix at d660dac Verified
must-fix — prediction 5 asserted the retracted "zero" claim :807-810 now predicts the residual's magnitude and direction instead of its absence yes
must-fix — §8's gate carried the same sentence as a blocking test :853-856 rewritten; also drops the unwrapped 127-col line yes
must-fix — §9's deferral rationale was the pre-retraction one collapsed to a pointer at §4.4 yes
suggestion — Config struct still said 2h 30m interim, §4.5 owns the final value (§4.4) yes
nit — MU2 resolved to nothing "the next multi-user slice (MU1 is #238)" yes

Checked for residue rather than trusting the diff: no occurrence of "to zero VMs", "crash backstop", "mints no" or the "ReplenishDelay plus a 90s StandbyIdle should already bound the RAM cost" rationale survives anywhere in the document. The only remaining 2h is the deliberate historical reference at :440-441 ("the 2h an earlier draft of this section assumed"), which should stay — it is what makes the 30m choice legible.

§9's collapse to a pointer is better than the fix I asked for. I suggested rewording; you deleted the second copy of the argument instead, so §9 now names the item, gives the one-clause wire-change reason, and defers to §4.4 for mechanism, residual and trigger. Two copies of that rationale is what produced the drift across three commits — this is the edit that stops it recurring rather than correcting it once more.

One suggestion, and it is a correction to my own wording: "mints D standbys" is the phrasing I drafted at :807 last pass, and you adopted it verbatim. It is loose in a way that matters slightly for §8's gate. Inline. The residual arithmetic built on it — (runs finishing per StandbyIdle) × D × GuestRAMBytes — is unaffected and correct, which is why this is a suggestion rather than a repeat of the finding it descends from: the previous version had the sign inverted, this one has the right magnitude and is wrong only about which VM the final Exec creates.

One nit, on the commit rather than the content. d660dac carries Co-Authored-By: Claude Sonnet 5 <[email protected]>, where the other four commits on this PR use Assisted-By: Claude (Anthropic AI) <[email protected]> — the house convention. Not worth a rebase on its own; worth catching if the branch is ever amended.


Approving. Across four passes this PR has taken eight findings, two of which required conceding a mechanism rather than adjusting prose, and the concessions were made in the direction of the weaker claim each time — §4.4 is a stronger section for having lost its original argument twice. The two things I would still call out as the document's best work are unchanged from earlier passes: §4.5's discovery that /workspace/repo sits inside the per-run directory, found by tracing rather than measurement, and §4.4's "the harness brackets its worktree; the workspace is bracketed by nothing the worker can observe."

This supersedes my three earlier CHANGES_REQUESTED reviews (5159243396 on 7d3464c, 5160539559 on a7c4805, 5167566056 on 8f0531f) — GitHub takes the latest review per reviewer, so nothing needs dismissing.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Docs (specs + ADRs), plus the spec's internal cross-references
Agent/IDE config (.claude/.vscode): none — re-run on the full diff at d660dac, clean
Commits: 5, all signed off (see the trailer nit above)
CI status: passing (12/12 on d660dac, lint included)
Base: still 45a218d; docs-only, +1233/−10 across 4 files

`ls`/`find`-heavy commands rather than in `cat`.
5. **Idle standby residency returns to zero** within `StandbyIdle + ReclaimScanInterval` of a rung's last
`Exec` on an otherwise idle host, while **workspace count does not change** until `WorkspaceIdle`; and
a run's final `Exec` — the cleanup `Exec` — **does** mint D standbys, which `StandbyIdle` ages out

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion — "mints D standbys" is off by D−1, and the phrasing is mine, so this is me correcting my own draft rather than a new finding.

§4.4 is unambiguous about the mechanics: ReplenishDelay waits "before refilling a popped slot" (:467), a following Exec is "served from the D−1 standbys still Ready" (:470), and the cleanup Exec "pops a standby … and schedules a refill that fires 200ms later" (:476-477). So the final Exec mints one VM — its own replacement. What it leaves behind is D: the D−1 that were never popped, plus that replacement.

The quantity the section actually needs is the residual, and you have it right — (runs finishing per StandbyIdle) × D × GuestRAMBytes is D per finished run. Only the verb is wrong, so nothing downstream of the arithmetic moves.

Where it does bite is §8 (:853-856), because that is a blocking gate rather than prose, and there it lands twice:

a run's final Exec mints D replacement standbys after ReplenishDelay, which StandbyIdle ages out rather than reclaiming immediately, while an Exec arriving inside the delay window is served from them without a cold acquire

  1. "mints D replacement standbys" — a test asserting D creations goes red against a correct worker that creates 1. That is the same shape as the finding this commit fixes, one layer down.
  2. "served from them" — the antecedent is the replacements, but inside the delay window the refill has not fired yet. Per :470 it is served from the D−1 still Ready. As written the gate asserts the wrong pool state at the wrong moment, which is the one thing that window exists to pin.

Two edits, keeping your structure:

:807 —

a run's final Exec — the cleanup Exec — pops a standby and mints its replacement, so the run's full complement of D stands idle rather than being reclaimed, which StandbyIdle ages out within one ReclaimScanInterval; idle standby residency therefore tracks (runs finishing per StandbyIdle) × D × GuestRAMBytes and not zero.

:853 —

a run's final Exec mints its replacement standby after ReplenishDelay, leaving D idle, which StandbyIdle ages out rather than reclaiming immediately, while an Exec arriving inside the delay window is served from the D−1 still Ready without a cold acquire

The second version is also the more useful gate: "1 minted, D idle, D−1 serving inside the window" pins three distinct numbers, where "D minted" pins one and gets it wrong. And prediction 5 keeps everything it gained this commit — a named quantity, a direction, and a bound, rather than an absence.

Corrects the reviewer's own draft wording from the previous fix.
§4.4 is unambiguous that a popped slot is refilled with one VM
(ReplenishDelay guards "a popped slot"; the following Exec is
served from "the D-1 standbys still Ready"), so the cleanup Exec
mints one replacement — what it leaves idle is the run's full
complement of D (the D-1 never popped, plus that replacement).

Fixes two sites that said "mints D standbys": §7.4 prediction 5 and
§8's reclamation gate. The latter is a blocking test description,
where asserting D creations (rather than 1) would go red against a
correct worker, and "served from them" pointed at the replacement
rather than the D-1 still Ready during the delay window. The
residual arithmetic downstream, (runs finishing per StandbyIdle) x
D x GuestRAMBytes, is unaffected — only the verb was wrong.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori merged commit 35ef4be into rossoctl:main Sep 10, 2026
12 checks passed
@pdettori
pdettori deleted the docs/p4-microvm-sandbox branch September 10, 2026 14:50
pdettori added a commit that referenced this pull request Sep 15, 2026
….md structure

Task 21 (E11 -- density, the replenishment ceiling, and the write-up), scoped to
instrument-only per the hardware corrections (F1): build the sweep driver, its
correctness gate, and the write-up structure -- not the headline number.

- experiments/src/microvm-density.ts: analyzeLadder() reuses detectKnee(degradeX=2)
  rather than inventing a second detector, attributes the bound (replenishment /
  memory / process-count / cpu) by first-crossing signal across rungs, refuses a
  ladder that saturated the harness lease cap (P6 Sec6's lesson: a harness-side
  refusal misread as a VM-tier limit), and scores predictions 1 and 3 against
  deploy/microvm/predictions.json's pinned ids (2, 4, 5 need data this ladder
  shape does not carry, so they read inconclusive rather than guess).
- experiments/test/microvm-density.test.ts: the brief's cases verbatim.
- deploy/microvm/e11-density.sh: the sweep driver. Sigma PSS from
  /proc/<pid>/smaps_rollup only, never RSS (F4); SH_SUBSTRATE is a required,
  explicit label -- nested-m8i on this box, never metal (F3); Cloud Hypervisor is
  absent as an arm because it does not restore past "Restoring virtio-console
  __console", not because it was slower (F5); records which Sec4.5 repo-cache
  shape a run used without deciding among the three (F7); discloses
  leaseSaturations-always-0 and the closed-loop-per-slot driving bias rather than
  hiding either.
- deploy/microvm/tests/e11-density.test.sh: cluster-free structural gate for the
  above, shellcheck-clean.
- deploy/microvm/EXPERIMENTS.md: E11 section written to spec Sec7's structure only
  -- per-rung metrics table, the five predictions with verdicts as
  `pending (metal)`, the Sec7.7 claim template with quantities as named blanks.
  No sweep was run against real, nested, or metal hardware for this task.
- docs/experiment-results.md: pointer to deploy/microvm/EXPERIMENTS.md, the same
  driver-local / consolidated split E1/E3/E4 and E2/E5 already use.
- docs/specs/README.md: P4 row status column only -- asserts the "no nested KVM"
  infra gate is retired, without implying the performance question is settled.
  The row's descriptive prose (already updated by PR #247) is untouched.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants