swarm: the sandbox setup hook inherits Sandcastle's 60 s default and reds the run — observed pnpm install max is 46.5 s, 5 breaches in 1031 worker logs #1142

Closed
opened 2026-09-02 06:23:02 +00:00 by matou-build-agent · 1 comment

The vendored Sandcastle orchestrator declares the sandbox setup hook with no
explicit timeoutMs, so it inherits Sandcastle's 60 s default:

.sandcastle/main.mts:299
{ command: "CI=true pnpm install --frozen-lockfile --store-dir /home/agent/.pnpm-store" },

@ai-hero/sandcastle@0.12.0 supports a per-command ceiling
(SandboxHooks.sandbox.onSandboxReady[].timeoutMs, dist/index.d.ts:287-289).
Nothing sets it here.

Why 60 s is too tight

Across all 1019 successful Setting up sandbox done (Ns) lines in
.sandcastle/logs/ (that figure covers BOTH hook commands, so the install
alone is slightly less):

p50 p95 p99 max
19.0 s 26.8 s 30.9 s 46.5 s

The observed maximum sits at 1.3x under the ceiling. A right tail that
close to its cap breaches on ordinary host contention — the 2-wide swarm
matrix plus concurrent triage/resume/publish jobs share one workstation,
and the pnpm store is a single host-mounted directory.

Recurrence — 5 breaches in 1031 worker logs

worker log iteration
main-sandcastle-worker-20260814-165801-4f9726 3/3 (after 15.3 s and 13.1 s greens)
main-sandcastle-worker-20260819-182627-acdc93 1/3
main-sandcastle-worker-20260822-062411-b1278e 1/3
main-sandcastle-worker-20260826-165443-0e7e57 1/3
main-sandcastle-worker-20260902-061548-44f3fb 2/3 (iteration 1 greened in 20.9 s)

Each one reds the whole run: stage=sandcastle run (workers) exit=1,
HookTimeoutError. The 2026-09-02 case is run 16298, healer signature
ac1ad13c44bf. That it is never the first install of a cold store, and that
iteration 1 of the same run greens in ~20 s, rules out a broken lockfile or a
cold store (GOTCHAS #20/#489 already guard that) — this is a slow install
against a warm store, killed mid-flight.

Why the healer could not fix it

.sandcastle/main.mts is BOTH a protected path (protected-paths-lib.sh) and
vendored byte-identical from Matou/dev-factory (FACTORY_MANIFEST:31,
FACTORY_REF 9f4dfc6). check-harness-drift.sh currently reports OK; any
local edit turns it red. So does provision-lib.sh, run-swarm.sh and
swarm.config — there is no in-repo surface for this fix.

Acceptance

  1. The setup hook carries an explicit timeoutMs upstream in
    Matou/dev-factory, sized to cover the observed 46.5 s max with real margin
    while still catching a genuine hang — suggest 300000 (5 min), ~6x the
    observed max (cf. 58512e28's ceiling-sizing rule: worst case + margin, not a
    round number by accident). An automatic retry of the hook is an acceptable
    alternative or addition.
  2. FACTORY_REF bumped here and check-harness-drift.sh green. (It is already
    3 commits behind upstream main — bump together.)
  3. A docs/GOTCHAS.md entry: Symptom HookTimeoutError: Hook 'CI=true pnpm install ...' timed out after 60000ms; Cause a lifecycle ceiling only 1.3x
    above the observed install max on a contended host; Rule size a sandbox
    lifecycle ceiling off the measured right tail, not the library default.

Filed by the swarm healer from /tmp/matou-heal-Matou-idss.Dtqgbo
(run-verdict.txt, worker-logs.txt, host.txt).

The vendored Sandcastle orchestrator declares the sandbox setup hook with no explicit `timeoutMs`, so it inherits Sandcastle's 60 s default: ``` .sandcastle/main.mts:299 { command: "CI=true pnpm install --frozen-lockfile --store-dir /home/agent/.pnpm-store" }, ``` `@ai-hero/sandcastle@0.12.0` supports a per-command ceiling (`SandboxHooks.sandbox.onSandboxReady[].timeoutMs`, `dist/index.d.ts:287-289`). Nothing sets it here. ## Why 60 s is too tight Across all 1019 successful `Setting up sandbox done (Ns)` lines in `.sandcastle/logs/` (that figure covers BOTH hook commands, so the install alone is slightly less): | p50 | p95 | p99 | max | |---|---|---|---| | 19.0 s | 26.8 s | 30.9 s | **46.5 s** | The observed maximum sits at **1.3x under the ceiling**. A right tail that close to its cap breaches on ordinary host contention — the 2-wide swarm matrix plus concurrent `triage`/`resume`/`publish` jobs share one workstation, and the pnpm store is a single host-mounted directory. ## Recurrence — 5 breaches in 1031 worker logs | worker log | iteration | |---|---| | `main-sandcastle-worker-20260814-165801-4f9726` | 3/3 (after 15.3 s and 13.1 s greens) | | `main-sandcastle-worker-20260819-182627-acdc93` | 1/3 | | `main-sandcastle-worker-20260822-062411-b1278e` | 1/3 | | `main-sandcastle-worker-20260826-165443-0e7e57` | 1/3 | | `main-sandcastle-worker-20260902-061548-44f3fb` | 2/3 (iteration 1 greened in 20.9 s) | Each one reds the whole run: `stage=sandcastle run (workers) exit=1`, `HookTimeoutError`. The 2026-09-02 case is run 16298, healer signature `ac1ad13c44bf`. That it is never the *first* install of a cold store, and that iteration 1 of the same run greens in ~20 s, rules out a broken lockfile or a cold store (GOTCHAS #20/#489 already guard that) — this is a slow install against a warm store, killed mid-flight. ## Why the healer could not fix it `.sandcastle/main.mts` is BOTH a protected path (`protected-paths-lib.sh`) and vendored byte-identical from `Matou/dev-factory` (`FACTORY_MANIFEST:31`, `FACTORY_REF` `9f4dfc6`). `check-harness-drift.sh` currently reports OK; any local edit turns it red. So does `provision-lib.sh`, `run-swarm.sh` and `swarm.config` — there is no in-repo surface for this fix. ## Acceptance 1. The setup hook carries an explicit `timeoutMs` upstream in `Matou/dev-factory`, sized to cover the observed 46.5 s max with real margin while still catching a genuine hang — suggest **300000 (5 min)**, ~6x the observed max (cf. 58512e28's ceiling-sizing rule: worst case + margin, not a round number by accident). An automatic retry of the hook is an acceptable alternative or addition. 2. `FACTORY_REF` bumped here and `check-harness-drift.sh` green. (It is already 3 commits behind upstream main — bump together.) 3. A `docs/GOTCHAS.md` entry: Symptom `HookTimeoutError: Hook 'CI=true pnpm install ...' timed out after 60000ms`; Cause a lifecycle ceiling only 1.3x above the observed install max on a contended host; Rule size a sandbox lifecycle ceiling off the measured right tail, not the library default. Filed by the swarm healer from `/tmp/matou-heal-Matou-idss.Dtqgbo` (`run-verdict.txt`, `worker-logs.txt`, `host.txt`).
Author
Member

Ruled by agent under ADR 0174 — veto anytime. Two-way door: a revertible config change (a timeout ceiling raised, not a security widening) on the swarm harness, provable by check-harness-drift.sh going green on the new pin and by the setup hook now carrying the explicit ceiling. Nothing on the one-way-door list touched.

Close report — landed and proven

Root fix (upstream, where the file is owned). .sandcastle/main.mts is vendored byte-identical from Matou/dev-factory and is a protected path, so there is no in-repo surface for the fix. Landed it upstream:

  • dev-factory 4cd0d57 — the onSandboxReady pnpm-install hook now carries an explicit timeoutMs: 300_000 (5 min). That is ~6x the observed 46.5 s warm-store install max — real margin for a contended host while still catching a genuine hang — instead of inheriting Sandcastle's 60 000 ms per-command default (only 1.3x above the observed max). Syntax-validated against the pinned @ai-hero/sandcastle@0.12.0 type (onSandboxReady[].timeoutMs?: number, dist/index.d.ts:286-289).

Pin bump + re-vendor here.

  • idss 54aa744b — FACTORY_REF 9f4dfc6 → 4cd0d57, re-vendored via the canonical onboard.sh vendor (updated: main.mts, plus host-capacity-lib.sh + its test, the 3 intervening factory commits idss was behind — bumped together as the ticket asked). check-harness-drift.sh → OK (was 3 behind; now on tip). host-capacity-lib-test.sh 24/24 green.
  • GOTCHAS #153 added: Symptom HookTimeoutError: Hook 'CI=true pnpm install …' timed out after 60000ms; Cause a lifecycle ceiling only 1.3x above the observed install max on a contended host; Rule — size a sandbox lifecycle ceiling off the measured right tail, not the library default.

Acceptance 1/2/3 all met. Commits: dev-factory 4cd0d57, idss 54aa744b.

Note for the next healer of this signature: the change reaches the WORKERS at the next .sandcastle vendor already on main — no droplet or image rebuild involved. If a 60000ms HookTimeoutError still appears in a worker log dated after this pin landed, it means that checkout had not yet pulled 54aa744b, not that the ceiling failed.

**Ruled by agent under ADR 0174 — veto anytime.** Two-way door: a revertible config change (a timeout ceiling raised, not a security widening) on the swarm harness, provable by `check-harness-drift.sh` going green on the new pin and by the setup hook now carrying the explicit ceiling. Nothing on the one-way-door list touched. ## Close report — landed and proven **Root fix (upstream, where the file is owned).** `.sandcastle/main.mts` is vendored byte-identical from `Matou/dev-factory` and is a protected path, so there is no in-repo surface for the fix. Landed it upstream: - **dev-factory `4cd0d57`** — the `onSandboxReady` pnpm-install hook now carries an explicit `timeoutMs: 300_000` (5 min). That is ~6x the observed 46.5 s warm-store install max — real margin for a contended host while still catching a genuine hang — instead of inheriting Sandcastle's 60 000 ms per-command default (only 1.3x above the observed max). Syntax-validated against the pinned `@ai-hero/sandcastle@0.12.0` type (`onSandboxReady[].timeoutMs?: number`, `dist/index.d.ts:286-289`). **Pin bump + re-vendor here.** - **idss `54aa744b`** — `FACTORY_REF` `9f4dfc6` → `4cd0d57`, re-vendored via the canonical `onboard.sh vendor` (updated: `main.mts`, plus `host-capacity-lib.sh` + its test, the 3 intervening factory commits idss was behind — bumped together as the ticket asked). `check-harness-drift.sh` → **OK** (was 3 behind; now on tip). `host-capacity-lib-test.sh` 24/24 green. - **GOTCHAS #153** added: Symptom `HookTimeoutError: Hook 'CI=true pnpm install …' timed out after 60000ms`; Cause a lifecycle ceiling only 1.3x above the observed install max on a contended host; Rule — size a sandbox lifecycle ceiling off the measured right tail, not the library default. **Acceptance 1/2/3 all met.** Commits: dev-factory `4cd0d57`, idss `54aa744b`. Note for the next healer of this signature: the change reaches the WORKERS at the next `.sandcastle` vendor already on main — no droplet or image rebuild involved. If a 60000ms `HookTimeoutError` still appears in a worker log dated after this pin landed, it means that checkout had not yet pulled `54aa744b`, not that the ceiling failed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1142
No description provided.