#663 consumer half: heavy-capacity consumers must honour /tmp/matou-drive-wanted before claiming — a protected .sandcastle/ + .forgejo/ change #664

Closed
opened 2026-08-22 12:47:54 +00:00 by matou-build-agent · 1 comment

Why this is a separate issue

#663 (ADR 0184's all-or-nothing acquire starves the rehearsal drive) was ruled to be fixed by an intent-file reservation (option 1). That fix has two halves:

  • Producer (shipped in #663's commit, unprotected scripts/): scripts/rehearsal-cycle.sh writes /tmp/matou-drive-wanted the moment a ready, unblocked drive is about to acquire host capacity, persists it across skipped */2 ticks, and removes it on completion/abandonment via an EXIT trap. Reservation helpers (host_capacity_drive_reserve / _release / _wanted / _skip_bump / _skip_reset) live in scripts/lib/host-capacity-lib.sh with offline tests in scripts/tests/host-capacity-lib-test.sh. The drive's own skip line now carries a consecutive-tick count (skipped N consecutive tick(s)), closing the observability gap.

  • Consumer (THIS issue): the heavy-capacity consumers must check the reservation before claiming a NEW task and decline (yield, exit 0) if it is present — in-flight work is never interrupted, only new starts held back, bounding starvation to one worker run. Their skip line must ALSO carry the consecutive-tick count.

Why the producer's agent could not do the consumer half

The #663 triage ruling asserted the consumer edits were to "an ordinary logic change to an unprotected file within" .sandcastle/. That is factually wrong about the #445 boundary. .sandcastle/protected-paths-lib.sh sets PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo" — it fingerprints the entire .sandcastle/ and .forgejo/ trees, not a named subset. Every consumer call site is inside that protected set:

  • .sandcastle/claim-next-task.sh / .sandcastle/claim-lib.sh (the swarm's task claim)
  • .sandcastle/run-swarm.sh, .sandcastle/run-triage.sh
  • .sandcastle/session-runner.sh
  • .sandcastle/host-capacity-lib.sh (the vendored dev-factory copy — needs the same host_capacity_drive_wanted predicate; note ADR 0184 point 6: this file is vendored byte-identical from Matou/dev-factory per ADR 0180, so the predicate belongs upstream and is re-vendored via a FACTORY_REF bump)
  • .forgejo/workflows/swarm.yml / triage.yml (inline the pool try-order pre-checkout, ADR 0184 point 1)

A swarm worker editing any of these is rolled back and fails the run loud (#445). This needs an interactive session's standing (ADR 0174), and the dev-factory copy needs an upstream change + re-vendor.

What to build

  1. Add host_capacity_drive_wanted ([ -e /tmp/matou-drive-wanted ]) to the dev-factory host-capacity-lib.sh and re-vendor .sandcastle/host-capacity-lib.sh (mirror the producer copy in scripts/lib/host-capacity-lib.sh on idss main, which already defines it and the reserve/release/skip helpers).
  2. In each consumer's NEW-task claim entry point, before claiming: if host_capacity_drive_wanted, log deferring to a ready drive — skipped N consecutive tick(s) (persist the count the same way, e.g. a per-consumer /tmp/matou-<consumer>-drive-defer-count) and yield (exit 0). Never interrupt in-flight work — check only at the point of starting NEW work.
  3. swarm.yml / triage.yml inline the same pre-claim check (they cannot source a repo file pre-checkout — mirror ADR 0184 point 1's inline convention).

Proof

Offline: extend .sandcastle/tests/host-capacity-lib-test.sh (or the yield tests) with a reservation-respected case (consumer yields when /tmp/matou-drive-wanted present, claims when absent). Live: the next standing-drive tick (#652/#657) under a busy queue — the drive should now win within one worker-run drain, and both sides' logs should show the climbing count.

Two-way door

Revertible by removing the pre-claim check; provable by the offline suite + the live tick. No credential, security-posture, member-trust, data-destruction, or spend surface — the machinery-boundary standing (a session per ADR 0174/#445), not a one-way door, is the only reason this is not an ordinary agent ticket.

Filed by the #663 producer-half agent (sandcastle) while working #663.

## Why this is a separate issue #663 (ADR 0184's all-or-nothing acquire starves the rehearsal drive) was ruled to be fixed by an **intent-file reservation** (option 1). That fix has two halves: - **Producer** (shipped in #663's commit, unprotected `scripts/`): `scripts/rehearsal-cycle.sh` writes `/tmp/matou-drive-wanted` the moment a ready, unblocked drive is about to acquire host capacity, persists it across skipped `*/2` ticks, and removes it on completion/abandonment via an EXIT trap. Reservation helpers (`host_capacity_drive_reserve` / `_release` / `_wanted` / `_skip_bump` / `_skip_reset`) live in `scripts/lib/host-capacity-lib.sh` with offline tests in `scripts/tests/host-capacity-lib-test.sh`. The drive's own skip line now carries a consecutive-tick **count** (`skipped N consecutive tick(s)`), closing the observability gap. - **Consumer** (THIS issue): the heavy-capacity consumers must **check the reservation before claiming a NEW task and decline (yield, exit 0) if it is present** — in-flight work is never interrupted, only new starts held back, bounding starvation to one worker run. Their skip line must ALSO carry the consecutive-tick count. ## Why the producer's agent could not do the consumer half The #663 triage ruling asserted the consumer edits were to "an ordinary logic change to an unprotected file within" `.sandcastle/`. **That is factually wrong about the #445 boundary.** `.sandcastle/protected-paths-lib.sh` sets `PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo"` — it fingerprints the **entire** `.sandcastle/` and `.forgejo/` trees, not a named subset. Every consumer call site is inside that protected set: - `.sandcastle/claim-next-task.sh` / `.sandcastle/claim-lib.sh` (the swarm's task claim) - `.sandcastle/run-swarm.sh`, `.sandcastle/run-triage.sh` - `.sandcastle/session-runner.sh` - `.sandcastle/host-capacity-lib.sh` (the vendored dev-factory copy — needs the same `host_capacity_drive_wanted` predicate; note ADR 0184 point 6: this file is vendored byte-identical from `Matou/dev-factory` per ADR 0180, so the predicate belongs upstream and is re-vendored via a `FACTORY_REF` bump) - `.forgejo/workflows/swarm.yml` / `triage.yml` (inline the pool try-order pre-checkout, ADR 0184 point 1) A swarm worker editing any of these is rolled back and fails the run loud (#445). This needs an interactive session's standing (ADR 0174), and the dev-factory copy needs an upstream change + re-vendor. ## What to build 1. Add `host_capacity_drive_wanted` (`[ -e /tmp/matou-drive-wanted ]`) to the dev-factory `host-capacity-lib.sh` and re-vendor `.sandcastle/host-capacity-lib.sh` (mirror the producer copy in `scripts/lib/host-capacity-lib.sh` on idss `main`, which already defines it and the reserve/release/skip helpers). 2. In each consumer's NEW-task claim entry point, before claiming: if `host_capacity_drive_wanted`, log `deferring to a ready drive — skipped N consecutive tick(s)` (persist the count the same way, e.g. a per-consumer `/tmp/matou-<consumer>-drive-defer-count`) and yield (exit 0). Never interrupt in-flight work — check only at the point of starting NEW work. 3. `swarm.yml` / `triage.yml` inline the same pre-claim check (they cannot source a repo file pre-checkout — mirror ADR 0184 point 1's inline convention). ## Proof Offline: extend `.sandcastle/tests/host-capacity-lib-test.sh` (or the yield tests) with a reservation-respected case (consumer yields when `/tmp/matou-drive-wanted` present, claims when absent). Live: the next standing-drive tick (#652/#657) under a busy queue — the drive should now win within one worker-run drain, and both sides' logs should show the climbing count. ## Two-way door Revertible by removing the pre-claim check; provable by the offline suite + the live tick. No credential, security-posture, member-trust, data-destruction, or spend surface — the machinery-boundary standing (a session per ADR 0174/#445), not a one-way door, is the only reason this is not an ordinary agent ticket. _Filed by the #663 producer-half agent (sandcastle) while working #663._
Author
Member

Close report

Ruled by agent under ADR 0174 — veto anytime.

What landed. The #664 consumer half, done properly this time:

  • Matou/dev-factory@1b7abc2 — ports the full drive-reservation API into host-capacity-lib.sh (host_capacity_drive_wanted/_reserve/_release/_skip_bump/_skip_reset, TTL-bounded) and adds host_capacity_consumer_defer_bump/_reset (keyed by an explicit counter PATH, not a hard-coded name, so three consumers on three cadences keep independent streaks and tests never touch real host /tmp); session-runner.sh checks it before host_capacity_acquire_heavy and logs deferring to a ready drive — skipped N consecutive tick(s). Tests: tests/host-capacity-lib-test.sh 13 groups, tests/session-runner-test.sh 9 (new case 9).
  • Matou/dev-factory@ab5bfa6 — self-pin bump 59c53bd→baa6281→1b7abc2.
  • Matou/idss@90b66e0d — re-vendors .sandcastle/ at the new pin (FACTORY_REF/FACTORY_MANIFEST, host-capacity-lib.sh, session-runner.sh, their tests, plus heal.sh's unrelated-but-safe upstream #10 pickup); .forgejo/workflows/swarm.yml/triage.yml (idss-local, not vendored) gain the matching inline consecutive-defer count; scripts/tests/drive-reservation-guard-test.sh rewritten to scan for the guard's closing fi instead of a hard-coded line count, and to assert the count climbs 1→2 and resets on release/expiry (17 checks).

Why the fix landed twice. The immediately-prior commit (b0497958) attempted this ticket but hand-edited .sandcastle/host-capacity-lib.sh and .sandcastle/session-runner.sh directly — both are FACTORY_MANIFEST entries vendored byte-identical from Matou/dev-factory per ADR 0180, and editing them here is exactly the ownership-inversion bug class that ADR retired. bash .sandcastle/check-harness-drift.sh failed red on it the moment this session ran it (first action taken on the ticket). That commit was also missing the ticket's explicit ask — "their skip line must ALSO carry the consecutive-tick count" — the consumer yield lines only reported the bare fact of standing down, no count. This session corrected both: landed the fix in Matou/dev-factory (with its own tests) instead of the local checkout, then re-vendored.

Scope guard — a ruling under ADR 0174 rule 1. Re-vendoring required onboard.sh vendor --force (the tool refuses a partial pin bump when ANY vendored file has been hand-edited locally). That force-overwrite would have silently reverted 7 OTHER .sandcastle/ files already drifted from the OLD pin before this session touched anything (limit-lib.sh, preflight-swarm.sh, rehearsal-report.sh, run-swarm.sh, sweep-lib.sh, and 2 tests) — genuine local fixes (e.g. run-swarm.sh's Claude-auth-refusal classification) never ported upstream, unrelated to #664. Backed those 7 up before the forced vendor, restored them after — same drift state as before this session, no regression, no scope creep. Filed as a follow-up: #666 (ready-for-session, same protected-path standing this ticket needed).

Proof. bash .sandcastle/check-harness-drift.sh — clean for every file this ticket owns (the 7 pre-existing unrelated files still flagged, unchanged from before this session — see #666). Full green sweep: scripts/tests/host-capacity-lib-test.sh 11, scripts/tests/drive-reservation-guard-test.sh 17, .sandcastle/tests/host-capacity-lib-test.sh 13, .sandcastle/tests/session-runner-test.sh 9, .sandcastle/tests/heal-test.sh 9, .sandcastle/tests/preflight-swarm-test.sh 3, .sandcastle/tests/sweep-lib-test.sh 10, plus every other .sandcastle/tests/*.sh and scripts/tests/*.sh in a full sweep (no regressions). bash -n clean on every touched shell file; both workflow YAMLs parse.

Live proof (the next standing-drive tick under a busy queue, per the ticket's own Proof section) is still owed — this session cannot fire a live drive itself (#577/ADR 0184, the same reason #644/#647 session-runner sessions note). The offline suite above is the two-way-door proof; veto anytime.

## Close report Ruled by agent under ADR 0174 — veto anytime. **What landed.** The #664 consumer half, done properly this time: - `Matou/dev-factory@1b7abc2` — ports the full drive-reservation API into `host-capacity-lib.sh` (`host_capacity_drive_wanted`/`_reserve`/`_release`/`_skip_bump`/`_skip_reset`, TTL-bounded) and adds `host_capacity_consumer_defer_bump`/`_reset` (keyed by an explicit counter PATH, not a hard-coded name, so three consumers on three cadences keep independent streaks and tests never touch real host `/tmp`); `session-runner.sh` checks it before `host_capacity_acquire_heavy` and logs `deferring to a ready drive — skipped N consecutive tick(s)`. Tests: `tests/host-capacity-lib-test.sh` 13 groups, `tests/session-runner-test.sh` 9 (new case 9). - `Matou/dev-factory@ab5bfa6` — self-pin bump `59c53bd→baa6281→1b7abc2`. - `Matou/idss@90b66e0d` — re-vendors `.sandcastle/` at the new pin (`FACTORY_REF`/`FACTORY_MANIFEST`, `host-capacity-lib.sh`, `session-runner.sh`, their tests, plus `heal.sh`'s unrelated-but-safe upstream #10 pickup); `.forgejo/workflows/swarm.yml`/`triage.yml` (idss-local, not vendored) gain the matching inline consecutive-defer count; `scripts/tests/drive-reservation-guard-test.sh` rewritten to scan for the guard's closing `fi` instead of a hard-coded line count, and to assert the count climbs 1→2 and resets on release/expiry (17 checks). **Why the fix landed twice.** The immediately-prior commit (`b0497958`) attempted this ticket but hand-edited `.sandcastle/host-capacity-lib.sh` and `.sandcastle/session-runner.sh` directly — both are `FACTORY_MANIFEST` entries vendored byte-identical from `Matou/dev-factory` per ADR 0180, and editing them here is exactly the ownership-inversion bug class that ADR retired. `bash .sandcastle/check-harness-drift.sh` failed red on it the moment this session ran it (first action taken on the ticket). That commit was also missing the ticket's explicit ask — "their skip line must ALSO carry the consecutive-tick count" — the consumer yield lines only reported the bare fact of standing down, no count. This session corrected both: landed the fix in `Matou/dev-factory` (with its own tests) instead of the local checkout, then re-vendored. **Scope guard — a ruling under ADR 0174 rule 1.** Re-vendoring required `onboard.sh vendor --force` (the tool refuses a partial pin bump when ANY vendored file has been hand-edited locally). That force-overwrite would have silently reverted 7 OTHER `.sandcastle/` files already drifted from the OLD pin **before this session touched anything** (`limit-lib.sh`, `preflight-swarm.sh`, `rehearsal-report.sh`, `run-swarm.sh`, `sweep-lib.sh`, and 2 tests) — genuine local fixes (e.g. `run-swarm.sh`'s Claude-auth-refusal classification) never ported upstream, unrelated to #664. Backed those 7 up before the forced vendor, restored them after — same drift state as before this session, no regression, no scope creep. Filed as a follow-up: #666 (`ready-for-session`, same protected-path standing this ticket needed). **Proof.** `bash .sandcastle/check-harness-drift.sh` — clean for every file this ticket owns (the 7 pre-existing unrelated files still flagged, unchanged from before this session — see #666). Full green sweep: `scripts/tests/host-capacity-lib-test.sh` 11, `scripts/tests/drive-reservation-guard-test.sh` 17, `.sandcastle/tests/host-capacity-lib-test.sh` 13, `.sandcastle/tests/session-runner-test.sh` 9, `.sandcastle/tests/heal-test.sh` 9, `.sandcastle/tests/preflight-swarm-test.sh` 3, `.sandcastle/tests/sweep-lib-test.sh` 10, plus every other `.sandcastle/tests/*.sh` and `scripts/tests/*.sh` in a full sweep (no regressions). `bash -n` clean on every touched shell file; both workflow YAMLs parse. Live proof (the next standing-drive tick under a busy queue, per the ticket's own Proof section) is still owed — this session cannot fire a live drive itself (#577/ADR 0184, the same reason #644/#647 session-runner sessions note). The offline suite above is the two-way-door proof; veto anytime.
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#664
No description provided.