claim harness vs tracker latency — stale-claim sweeper, liveness ≠ tracker-slow, budgets sized to p95 (split from #1270 B) #1279

Closed
opened 2026-09-06 23:23:57 +00:00 by ben · 1 comment
Owner

Why

Split from #1270 Part B on Ben's ruling (2026-09-06). On the #1235 archive drive (2026-09-05/06) the tracker cost more wall-clock than the model did: #1246 waited 80 min and #1247 nearly 3 h on claim churn alone. Companion: #1245 (reporter re-query by sig after a 503-after-store).

What is wrong

.sandcastle/claim-lib.sh:

  • claim_alive_runs = actions/tasks?limit=100 capped at CLAIM_ALIVE_MAX_TIME=14 s; CLAIM_NEXT_DEADLINE=26 s. A slow tracker (observed p95 well above 14 s on 09-05/06) reads as "run dead".
  • A lost claim DELETEs its own swarm-claim comment; that DELETE fails on the same slow tracker, so stale claim comments linger and starve the next claim (12 stale claims were hand-deleted on #1247 before a live claim won).

Ask (two-way, ADR 0174)

  1. Stale-claim sweeper keyed on run-swarm-verdicts.log completion: a claim whose run has a recorded verdict (or whose run id is absent from actions/tasks across N consecutive successful polls) is swept, not trusted.
  2. Liveness ≠ tracker-slow: a timed-out or 5xx actions/tasks poll must back off and retry (bounded), never conclude the run is dead and drop the claim.
  3. Budgets sized to the tracker's observed p95, not a fixed 14 s — measure from the claim log, make the constants env-tunable with the measured defaults.
  4. Tests in .sandcastle/tests/ for each: stale sweep, slow-tracker retry, budget defaults.

Protected path (.sandcastle/**, #445) → ready-for-session. Independent of #1270 Part A and of #1280.

## Why Split from #1270 Part B on Ben's ruling (2026-09-06). On the #1235 archive drive (2026-09-05/06) the tracker cost more wall-clock than the model did: #1246 waited 80 min and #1247 nearly 3 h on claim churn alone. Companion: #1245 (reporter re-query by sig after a 503-after-store). ## What is wrong `.sandcastle/claim-lib.sh`: - `claim_alive_runs` = `actions/tasks?limit=100` capped at `CLAIM_ALIVE_MAX_TIME=14 s`; `CLAIM_NEXT_DEADLINE=26 s`. A slow tracker (observed p95 well above 14 s on 09-05/06) reads as "run dead". - A lost claim DELETEs its own `swarm-claim` comment; that DELETE fails on the same slow tracker, so stale claim comments linger and starve the next claim (12 stale claims were hand-deleted on #1247 before a live claim won). ## Ask (two-way, ADR 0174) 1. **Stale-claim sweeper** keyed on `run-swarm-verdicts.log` completion: a claim whose run has a recorded verdict (or whose run id is absent from `actions/tasks` across N consecutive successful polls) is swept, not trusted. 2. **Liveness ≠ tracker-slow**: a timed-out or 5xx `actions/tasks` poll must back off and retry (bounded), never conclude the run is dead and drop the claim. 3. **Budgets sized to the tracker's observed p95**, not a fixed 14 s — measure from the claim log, make the constants env-tunable with the measured defaults. 4. Tests in `.sandcastle/tests/` for each: stale sweep, slow-tracker retry, budget defaults. Protected path (`.sandcastle/**`, #445) → `ready-for-session`. Independent of #1270 Part A and of #1280.

Close-report — landed (agent, ADR 0174)

All four asks landed as two-way changes (revertible commits, proven by offline tests). Every changed file is vendored from Matou/dev-factory (#445), so — exactly like sibling #1270 Part A — the fix landed upstream first and was re-vendored here.

Commits

  • Matou/dev-factory@51c8dc6 — the fix at source (root files).
  • Matou/idss@d42da82d — FACTORY_REF cf2efb0→51c8dc6, re-vendored .sandcastle/**, STATUS.md.

What landed (.sandcastle/claim-lib.sh + producers)

  1. Stale-claim sweeper keyed on run-swarm-verdicts.log. New claim_run_terminal <run> reads the host-side verdict log; a claim whose run has a recorded terminal verdict is swept by janitor_sweep without consulting the tracker — breaking the #1247 deadlock where every alive poll timed out and the old janitor (fail-closed) could sweep nothing, and 12 stale claims had to be hand-deleted. The verdict log now carries a trailing run=<id> field (runlog_line, additive — pre-existing lines and callers that omit it stay byte-identical; run-swarm.sh/landing-lib.sh stamp SWARM_RUN_ID). The pre-merge pr-opened breadcrumb (written while the run is still alive) is explicitly not terminal.

  2. Liveness ≠ tracker-slow. A timed-out/5xx actions/tasks poll now backs off and retries (bounded — CLAIM_ALIVE_RETRIES / CLAIM_ALIVE_RETRY_SLEEP) instead of concluding "run dead": default 2 for the host janitor, 0 for the in-sandbox prefetch (bound by the 30 s prompt-expansion budget, idss#1195). Absence-based sweeps now require CLAIM_ABSENCE_THRESHOLD (default 2) consecutive absent successful polls (file-backed streak) so one slow/partial-200 can't false-sweep a live run. Every fail-closed invariant preserved (review finding 1, #20, #28, #468): no verdict + no alive data ⇒ claim kept.

  3. Budgets sized to p95. CLAIM_ALIVE_MAX_TIME raised 14→20 s (over the observed p95 that tripped on 09-05/06, still under the 26 s deadline). All new constants are env-tunable with the measured defaults.

  4. Measurement, honestly: there is no dedicated claim-latency log on the host to compute an exact p95 from — the prior evidence was 5 hand-samples (8.5–12.2 s, 09-03). So the ticket's "measure from the claim log" is now enabled: opt-in CLAIM_LATENCY_LOG records <epoch> dur=<n>s rc=<n> per read, so the next tuning measures from disk instead of guessing. 20 s is the defensible interim default.

Proof (offline, no network — .sandcastle/tests/)

  • claim-lib-test.sh: 40→67 checks. New: verdict-log signals (terminal vs pr-opened breadcrumb, prefix-collision, missing log), retry recovery + bound + rc-nonzero-on-exhaustion, latency log (on/off/per-attempt), tracker-down sweep via verdict log (the #1247 case), absence threshold + streak reset, default constants.
  • runlog-lib-test.sh: 9→11 groups (the run= field additive; no-id line unchanged).
  • Regression-clean: claim-next-task-test, landing-lib-test, schedule-lib-test, run-swarm-stages-test, check-harness-drift-test, session-runner-test, verify-lib-test, record-run-result-test, run-swarm-drive-yield-test all green; drift gate green.

Independent of #1270 Part A and #1280. Companion #1245 already landed (ffc95aed). Ruled by agent under ADR 0174 — veto anytime.

## Close-report — landed (agent, ADR 0174) All four asks landed as **two-way** changes (revertible commits, proven by offline tests). Every changed file is **vendored from `Matou/dev-factory` (#445)**, so — exactly like sibling #1270 Part A — the fix landed upstream first and was re-vendored here. **Commits** - `Matou/dev-factory@51c8dc6` — the fix at source (root files). - `Matou/idss@d42da82d` — FACTORY_REF `cf2efb0`→`51c8dc6`, re-vendored `.sandcastle/**`, `STATUS.md`. **What landed (`.sandcastle/claim-lib.sh` + producers)** 1. **Stale-claim sweeper keyed on `run-swarm-verdicts.log`.** New `claim_run_terminal <run>` reads the host-side verdict log; a claim whose run has a recorded **terminal** verdict is swept by `janitor_sweep` **without consulting the tracker** — breaking the #1247 deadlock where every alive poll timed out and the old janitor (fail-closed) could sweep *nothing*, and 12 stale claims had to be hand-deleted. The verdict log now carries a trailing `run=<id>` field (`runlog_line`, **additive** — pre-existing lines and callers that omit it stay byte-identical; `run-swarm.sh`/`landing-lib.sh` stamp `SWARM_RUN_ID`). The pre-merge `pr-opened` breadcrumb (written while the run is *still alive*) is explicitly **not** terminal. 2. **Liveness ≠ tracker-slow.** A timed-out/5xx `actions/tasks` poll now **backs off and retries** (bounded — `CLAIM_ALIVE_RETRIES` / `CLAIM_ALIVE_RETRY_SLEEP`) instead of concluding "run dead": default **2** for the host janitor, **0** for the in-sandbox prefetch (bound by the 30 s prompt-expansion budget, `idss#1195`). Absence-based sweeps now require `CLAIM_ABSENCE_THRESHOLD` (default **2**) **consecutive absent successful polls** (file-backed streak) so one slow/partial-200 can't false-sweep a live run. Every fail-closed invariant preserved (review finding 1, #20, #28, #468): **no verdict + no alive data ⇒ claim kept**. 3. **Budgets sized to p95.** `CLAIM_ALIVE_MAX_TIME` raised **14→20 s** (over the observed p95 that tripped on 09-05/06, still under the 26 s deadline). All new constants are env-tunable with the measured defaults. 4. **Measurement, honestly:** there is **no dedicated claim-latency log** on the host to compute an exact p95 from — the prior evidence was 5 hand-samples (8.5–12.2 s, 09-03). So the ticket's "measure from the claim log" is now *enabled*: opt-in `CLAIM_LATENCY_LOG` records `<epoch> dur=<n>s rc=<n>` per read, so the next tuning measures from disk instead of guessing. 20 s is the defensible interim default. **Proof (offline, no network — `.sandcastle/tests/`)** - `claim-lib-test.sh`: **40→67** checks. New: verdict-log signals (terminal vs `pr-opened` breadcrumb, prefix-collision, missing log), retry recovery + bound + rc-nonzero-on-exhaustion, latency log (on/off/per-attempt), **tracker-down sweep via verdict log** (the #1247 case), absence threshold + streak reset, default constants. - `runlog-lib-test.sh`: **9→11** groups (the `run=` field additive; no-id line unchanged). - Regression-clean: `claim-next-task-test`, `landing-lib-test`, `schedule-lib-test`, `run-swarm-stages-test`, `check-harness-drift-test`, `session-runner-test`, `verify-lib-test`, `record-run-result-test`, `run-swarm-drive-yield-test` all green; drift gate green. Independent of #1270 Part A and #1280. Companion #1245 already landed (`ffc95aed`). Ruled by agent under ADR 0174 — veto anytime.
matou-build-agent 2026-09-07 01:20:16 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#1279
No description provided.