rehearsal-cycle: wire the harness drive-holder/drive-log primitives and pre-mint the run dir so the fleet monitor can see a drive (slots, legs, verdict, history) #1058

Closed
opened 2026-08-31 06:09:14 +00:00 by ben · 3 comments
Owner

Symptom

The fleet monitor (dev-factory fleet-tui/, spec 2026-08-28 slot-aware fleet) cannot see a rehearsal drive: 2026-08-31 04:31Z the droplet drive (#1051 regression run) was at leg 4 with box clan-lab-rehearsal-72b0ecd4 up, and the monitor showed lock held, no holder record on both slots and no drive in flight. Same on the device host. The Drive tab's history is empty by construction: no host has ever written a drive-log.jsonl.

Cause

scripts/rehearsal-cycle.sh acquires capacity with host_capacity_acquire_exclusive / host_capacity_acquire_heavy and writes our own drive-status record, but never calls the harness's durable drive primitives host_capacity_drive_log_start / host_capacity_drive_log_end (.sandcastle/host-capacity-lib.sh, dev-factory #93 — the harness half landed; this one-liner consumer half never got a ticket). Those two calls are the ONLY writers of (a) the kind=drive slot-holder sidecars the monitor's slot rows read and (b) ~/swarm/state/drive-log.jsonl, the append-only history the Drive tab's HISTORY table reads.

Second gap: the holder can carry the run dir (HOST_CAPACITY_DRIVE_RUN_DIR) so the monitor can tail artifacts/legs.json and read artifacts/verdict.json live — but the stamp is minted inside scripts/smoke-private-path.sh (stamp="$(date -u +%Y%m%dT%H%M%SZ)"; run_dir=…/$stamp, ≈L557) after the cycle has already won capacity, so the cycle cannot name the run dir when the holder is written.

Fix

In scripts/rehearsal-cycle.sh, right after capacity is won and drive_status_start runs (≈L157-175):

  1. Pre-mint the stamp in the cycle — use the same date -u +%Y%m%dT%H%M%SZ format and set cycle_start to the SAME value (today cycle_start is computed at ≈L381 immediately before the drive; #918's staleness compare stamp < cycle_start stays valid when they are equal). Compute run_dir="$root/test-results/drive-$target/$stamp" and export HOST_CAPACITY_DRIVE_RUN_DIR="$run_dir". Keep the post-drive find … | tail -1 as the fallback only if the override was not honoured.
  2. scripts/smoke-private-path.sh honours an override: stamp="${REHEARSAL_RUN_STAMP:-$(date -u +%Y%m%dT%H%M%SZ)}" (or a full REHEARSAL_RUN_DIR), so the cycle's pre-minted dir is the one the driver writes legs.json/verdict.json into.
  3. export HOST_CAPACITY_DRIVE_REPO="$REPO_SLUG" (the knob dev-factory #118 adds) and call host_capacity_drive_log_start "$stamp" "${REHEARSAL_HOST:-$(hostname -s)}" "$target" — id = the run stamp so the monitor's row, the run dir and the reporter's evidence share one identifier. Under DRIVE_EXCLUSIVE=slot the harness (post-#118) labels whichever slot acquire_heavy actually won.
  4. host_capacity_drive_log_end "$stamp" "$verdict" after the verdict is known (green/red/park), and host_capacity_drive_log_end "$stamp" ended in the EXIT trap as the crash/abandonment fallback (idempotent: the trap must skip when the explicit end already ran).
  5. Add drive_status_set_droplet's box name to nothing new — the monitor reads the box from the drive-status file via the host registry's drive-status Matou/idss /tmp/matou-Matou-idss-rehearsal-drive-status.json line (added on both hosts 2026-08-31). Keep drive-status-lib.sh unchanged.

Tests (same commit)

Offline test beside scripts/tests/rehearsal-drive-exclusive-test.sh: with a shimmed host_capacity_*/nix and a fake smoke script, assert (a) HOST_CAPACITY_DRIVE_RUN_DIR names the dir the smoke shim actually writes into; (b) drive_log_start is called once with id = stamp after capacity, drive_log_end exactly once with the verdict (trap path does not double-write); (c) cycle_start == stamp so rehearsal_report_decision does not park a fresh run as stale. smoke-private-path.sh override test: env set → run dir equals it; unset → today's behaviour.

Depends on

dev-factory #118 (holder placement + HOST_CAPACITY_DRIVE_REPO) landing and this repo's .sandcastle/FACTORY_REF bumped past it. Steps 1, 2 and the drive_log_end wiring do not depend on it; step 3's repo knob does — if the pin has not moved yet, wire everything else and leave the repo export as a TODO referencing #118 rather than passing the repo slug in the target position.

## Symptom The fleet monitor (dev-factory `fleet-tui/`, spec 2026-08-28 slot-aware fleet) cannot see a rehearsal drive: 2026-08-31 04:31Z the `droplet` drive (#1051 regression run) was at leg 4 with box `clan-lab-rehearsal-72b0ecd4` up, and the monitor showed `lock held, no holder record` on both slots and `no drive in flight`. Same on the `device` host. The Drive tab's history is empty by construction: no host has ever written a `drive-log.jsonl`. ## Cause `scripts/rehearsal-cycle.sh` acquires capacity with `host_capacity_acquire_exclusive` / `host_capacity_acquire_heavy` and writes our own `drive-status` record, but never calls the harness's durable drive primitives `host_capacity_drive_log_start` / `host_capacity_drive_log_end` (`.sandcastle/host-capacity-lib.sh`, dev-factory #93 — the harness half landed; this one-liner consumer half never got a ticket). Those two calls are the ONLY writers of (a) the `kind=drive` slot-holder sidecars the monitor's slot rows read and (b) `~/swarm/state/drive-log.jsonl`, the append-only history the Drive tab's HISTORY table reads. Second gap: the holder can carry the run dir (`HOST_CAPACITY_DRIVE_RUN_DIR`) so the monitor can tail `artifacts/legs.json` and read `artifacts/verdict.json` live — but the stamp is minted inside `scripts/smoke-private-path.sh` (`stamp="$(date -u +%Y%m%dT%H%M%SZ)"; run_dir=…/$stamp`, ≈L557) after the cycle has already won capacity, so the cycle cannot name the run dir when the holder is written. ## Fix In `scripts/rehearsal-cycle.sh`, right after capacity is won and `drive_status_start` runs (≈L157-175): 1. Pre-mint the stamp in the cycle — use the same `date -u +%Y%m%dT%H%M%SZ` format and set `cycle_start` to the SAME value (today `cycle_start` is computed at ≈L381 immediately before the drive; #918's staleness compare `stamp < cycle_start` stays valid when they are equal). Compute `run_dir="$root/test-results/drive-$target/$stamp"` and `export HOST_CAPACITY_DRIVE_RUN_DIR="$run_dir"`. Keep the post-drive `find … | tail -1` as the fallback only if the override was not honoured. 2. `scripts/smoke-private-path.sh` honours an override: `stamp="${REHEARSAL_RUN_STAMP:-$(date -u +%Y%m%dT%H%M%SZ)}"` (or a full `REHEARSAL_RUN_DIR`), so the cycle's pre-minted dir is the one the driver writes `legs.json`/`verdict.json` into. 3. `export HOST_CAPACITY_DRIVE_REPO="$REPO_SLUG"` (the knob dev-factory #118 adds) and call `host_capacity_drive_log_start "$stamp" "${REHEARSAL_HOST:-$(hostname -s)}" "$target"` — `id` = the run stamp so the monitor's row, the run dir and the reporter's evidence share one identifier. Under `DRIVE_EXCLUSIVE=slot` the harness (post-#118) labels whichever slot `acquire_heavy` actually won. 4. `host_capacity_drive_log_end "$stamp" "$verdict"` after the verdict is known (green/red/park), and `host_capacity_drive_log_end "$stamp" ended` in the EXIT trap as the crash/abandonment fallback (idempotent: the trap must skip when the explicit end already ran). 5. Add `drive_status_set_droplet`'s box name to nothing new — the monitor reads the box from the `drive-status` file via the host registry's `drive-status Matou/idss /tmp/matou-Matou-idss-rehearsal-drive-status.json` line (added on both hosts 2026-08-31). Keep `drive-status-lib.sh` unchanged. ## Tests (same commit) Offline test beside `scripts/tests/rehearsal-drive-exclusive-test.sh`: with a shimmed `host_capacity_*`/`nix` and a fake smoke script, assert (a) `HOST_CAPACITY_DRIVE_RUN_DIR` names the dir the smoke shim actually writes into; (b) `drive_log_start` is called once with id = stamp after capacity, `drive_log_end` exactly once with the verdict (trap path does not double-write); (c) `cycle_start == stamp` so `rehearsal_report_decision` does not park a fresh run as stale. `smoke-private-path.sh` override test: env set → run dir equals it; unset → today's behaviour. ## Depends on dev-factory #118 (holder placement + `HOST_CAPACITY_DRIVE_REPO`) landing and this repo's `.sandcastle/FACTORY_REF` bumped past it. Steps 1, 2 and the `drive_log_end` wiring do not depend on it; step 3's repo knob does — if the pin has not moved yet, wire everything else and leave the repo export as a TODO referencing #118 rather than passing the repo slug in the `target` position.

swarm-claim host=matou-dev-server-01 run=15067
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=15067 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1058 — status success

⛔ close-report gates REFUSED this close — the following claims did not verify:

  • commit 37c4f0464 is not a valid commit object (fabricated, or never pushed)
  • changed_files: 'scripts/rehearsal-cycle.sh' is not in the diff of the claimed commits
  • changed_files: 'scripts/smoke-private-path.sh' is not in the diff of the claimed commits
  • changed_files: 'scripts/tests/rehearsal-drive-log-test.sh' is not in the diff of the claimed commits
  • changed_files: 'scripts/tests/rehearsal-staleness-park-test.sh' is not in the diff of the claimed commits
  • changed_files: 'STATUS.md' is not in the diff of the claimed commits
envelope
{
  "issue": 1058,
  "status": "success",
  "commits": [
    "37c4f0464"
  ],
  "changed_files": [
    "scripts/rehearsal-cycle.sh",
    "scripts/smoke-private-path.sh",
    "scripts/tests/rehearsal-drive-log-test.sh",
    "scripts/tests/rehearsal-staleness-park-test.sh",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/rehearsal-drive-log-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/rehearsal-staleness-park-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/rehearsal-drive-exclusive-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/rehearsal-cycle.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/smoke-private-path.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Cycle calls the harness drive-log primitives (start after capacity, end with verdict + idempotent trap fallback)": "scripts/rehearsal-cycle.sh sources .sandcastle/host-capacity-lib.sh and calls host_capacity_drive_log_start in the drive-log-premint block and host_capacity_drive_log_end via rehearsal_drive_log_end_once (verdict once, trap 'ended' fallback); proven by rehearsal-drive-log-test.sh end-once checks",
    "Pre-mint the run dir so HOST_CAPACITY_DRIVE_RUN_DIR names the dir the driver writes into, cycle_start == stamp": "drive-log-premint block sets stamp=date, cycle_start=$stamp, run_dir=test-results/drive-$target/$stamp, exports HOST_CAPACITY_DRIVE_RUN_DIR + REHEARSAL_RUN_STAMP; rehearsal-drive-log-test.sh asserts cycle_start==stamp and the driver writes into HOST_CAPACITY_DRIVE_RUN_DIR",
    "smoke-private-path.sh honours the override (env set -> run dir equals it; unset -> today's behaviour)": "rehearsal-run-override sentinel block: stamp=${REHEARSAL_RUN_STAMP:-date}, run_dir=${REHEARSAL_RUN_DIR:-...}; rehearsal-drive-log-test.sh override checks (RUN_DIR wins, RUN_STAMP names dir, unset date-stamped)",
    "drive_log_end exactly once with the verdict; trap does not double-write; cycle_start==stamp so a fresh run is not parked stale": "rehearsal_drive_log_end_once guard + rehearsal-drive-log-test.sh end-once assertions (one line with verdict; crash-only=ended)",
    "HOST_CAPACITY_DRIVE_REPO dependency on dev-factory #118 handled": "FACTORY_REF 9f4dfc6 has no HOST_CAPACITY_DRIVE_REPO; left as TODO(#118), target rides target position per issue guidance"
  },
  "summary": "Wired the rehearsal cycle to the harness drive-log/holder primitives and pre-minted the run dir so the fleet monitor can see a drive's slots, legs, verdict and history.",
  "blockers": []
}
**close-report** for #1058 — status `success` :no_entry: **close-report gates REFUSED this close** — the following claims did not verify: - commit 37c4f0464 is not a valid commit object (fabricated, or never pushed) - changed_files: 'scripts/rehearsal-cycle.sh' is not in the diff of the claimed commits - changed_files: 'scripts/smoke-private-path.sh' is not in the diff of the claimed commits - changed_files: 'scripts/tests/rehearsal-drive-log-test.sh' is not in the diff of the claimed commits - changed_files: 'scripts/tests/rehearsal-staleness-park-test.sh' is not in the diff of the claimed commits - changed_files: 'STATUS.md' is not in the diff of the claimed commits <details><summary>envelope</summary> ```json { "issue": 1058, "status": "success", "commits": [ "37c4f0464" ], "changed_files": [ "scripts/rehearsal-cycle.sh", "scripts/smoke-private-path.sh", "scripts/tests/rehearsal-drive-log-test.sh", "scripts/tests/rehearsal-staleness-park-test.sh", "STATUS.md" ], "tests": [ { "command": "bash scripts/tests/rehearsal-drive-log-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/rehearsal-staleness-park-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/rehearsal-drive-exclusive-test.sh", "exit_code": 0 }, { "command": "bash -n scripts/rehearsal-cycle.sh", "exit_code": 0 }, { "command": "bash -n scripts/smoke-private-path.sh", "exit_code": 0 } ], "criteria": { "Cycle calls the harness drive-log primitives (start after capacity, end with verdict + idempotent trap fallback)": "scripts/rehearsal-cycle.sh sources .sandcastle/host-capacity-lib.sh and calls host_capacity_drive_log_start in the drive-log-premint block and host_capacity_drive_log_end via rehearsal_drive_log_end_once (verdict once, trap 'ended' fallback); proven by rehearsal-drive-log-test.sh end-once checks", "Pre-mint the run dir so HOST_CAPACITY_DRIVE_RUN_DIR names the dir the driver writes into, cycle_start == stamp": "drive-log-premint block sets stamp=date, cycle_start=$stamp, run_dir=test-results/drive-$target/$stamp, exports HOST_CAPACITY_DRIVE_RUN_DIR + REHEARSAL_RUN_STAMP; rehearsal-drive-log-test.sh asserts cycle_start==stamp and the driver writes into HOST_CAPACITY_DRIVE_RUN_DIR", "smoke-private-path.sh honours the override (env set -> run dir equals it; unset -> today's behaviour)": "rehearsal-run-override sentinel block: stamp=${REHEARSAL_RUN_STAMP:-date}, run_dir=${REHEARSAL_RUN_DIR:-...}; rehearsal-drive-log-test.sh override checks (RUN_DIR wins, RUN_STAMP names dir, unset date-stamped)", "drive_log_end exactly once with the verdict; trap does not double-write; cycle_start==stamp so a fresh run is not parked stale": "rehearsal_drive_log_end_once guard + rehearsal-drive-log-test.sh end-once assertions (one line with verdict; crash-only=ended)", "HOST_CAPACITY_DRIVE_REPO dependency on dev-factory #118 handled": "FACTORY_REF 9f4dfc6 has no HOST_CAPACITY_DRIVE_REPO; left as TODO(#118), target rides target position per issue guidance" }, "summary": "Wired the rehearsal cycle to the harness drive-log/holder primitives and pre-minted the run dir so the fleet monitor can see a drive's slots, legs, verdict and history.", "blockers": [] } ``` </details>

close-report for #1058 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1058,
  "status": "success",
  "commits": [
    "37c4f046c7b67920ce8300fcc2f0b9b66267cb7f"
  ],
  "changed_files": [
    "scripts/rehearsal-cycle.sh",
    "scripts/smoke-private-path.sh",
    "scripts/tests/rehearsal-drive-log-test.sh",
    "scripts/tests/rehearsal-staleness-park-test.sh",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/rehearsal-drive-log-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/rehearsal-staleness-park-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/rehearsal-drive-exclusive-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/rehearsal-cycle.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/smoke-private-path.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Cycle calls the harness drive-log primitives (start after capacity, end with verdict + idempotent trap fallback)": "scripts/rehearsal-cycle.sh sources .sandcastle/host-capacity-lib.sh and calls host_capacity_drive_log_start in the drive-log-premint block and host_capacity_drive_log_end via rehearsal_drive_log_end_once (verdict once, trap 'ended' fallback); proven by rehearsal-drive-log-test.sh end-once checks",
    "Pre-mint the run dir so HOST_CAPACITY_DRIVE_RUN_DIR names the dir the driver writes into, cycle_start == stamp": "drive-log-premint block sets stamp=date, cycle_start=$stamp, run_dir=test-results/drive-$target/$stamp, exports HOST_CAPACITY_DRIVE_RUN_DIR + REHEARSAL_RUN_STAMP; rehearsal-drive-log-test.sh asserts cycle_start==stamp and the driver writes into HOST_CAPACITY_DRIVE_RUN_DIR",
    "smoke-private-path.sh honours the override (env set -> run dir equals it; unset -> today's behaviour)": "rehearsal-run-override sentinel block: stamp=${REHEARSAL_RUN_STAMP:-date}, run_dir=${REHEARSAL_RUN_DIR:-...}; rehearsal-drive-log-test.sh override checks (RUN_DIR wins, RUN_STAMP names dir, unset date-stamped)",
    "drive_log_end exactly once with the verdict; trap does not double-write; cycle_start==stamp so a fresh run is not parked stale": "rehearsal_drive_log_end_once guard + rehearsal-drive-log-test.sh end-once assertions (one line with verdict; crash-only=ended)",
    "HOST_CAPACITY_DRIVE_REPO dependency on dev-factory #118 handled": "FACTORY_REF 9f4dfc6 has no HOST_CAPACITY_DRIVE_REPO; left as TODO(#118), target rides target position per issue guidance"
  },
  "summary": "Wired the rehearsal cycle to the harness drive-log/holder primitives and pre-minted the run dir so the fleet monitor can see a drive's slots, legs, verdict and history.",
  "blockers": []
}
**close-report** for #1058 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1058, "status": "success", "commits": [ "37c4f046c7b67920ce8300fcc2f0b9b66267cb7f" ], "changed_files": [ "scripts/rehearsal-cycle.sh", "scripts/smoke-private-path.sh", "scripts/tests/rehearsal-drive-log-test.sh", "scripts/tests/rehearsal-staleness-park-test.sh", "STATUS.md" ], "tests": [ { "command": "bash scripts/tests/rehearsal-drive-log-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/rehearsal-staleness-park-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/rehearsal-drive-exclusive-test.sh", "exit_code": 0 }, { "command": "bash -n scripts/rehearsal-cycle.sh", "exit_code": 0 }, { "command": "bash -n scripts/smoke-private-path.sh", "exit_code": 0 } ], "criteria": { "Cycle calls the harness drive-log primitives (start after capacity, end with verdict + idempotent trap fallback)": "scripts/rehearsal-cycle.sh sources .sandcastle/host-capacity-lib.sh and calls host_capacity_drive_log_start in the drive-log-premint block and host_capacity_drive_log_end via rehearsal_drive_log_end_once (verdict once, trap 'ended' fallback); proven by rehearsal-drive-log-test.sh end-once checks", "Pre-mint the run dir so HOST_CAPACITY_DRIVE_RUN_DIR names the dir the driver writes into, cycle_start == stamp": "drive-log-premint block sets stamp=date, cycle_start=$stamp, run_dir=test-results/drive-$target/$stamp, exports HOST_CAPACITY_DRIVE_RUN_DIR + REHEARSAL_RUN_STAMP; rehearsal-drive-log-test.sh asserts cycle_start==stamp and the driver writes into HOST_CAPACITY_DRIVE_RUN_DIR", "smoke-private-path.sh honours the override (env set -> run dir equals it; unset -> today's behaviour)": "rehearsal-run-override sentinel block: stamp=${REHEARSAL_RUN_STAMP:-date}, run_dir=${REHEARSAL_RUN_DIR:-...}; rehearsal-drive-log-test.sh override checks (RUN_DIR wins, RUN_STAMP names dir, unset date-stamped)", "drive_log_end exactly once with the verdict; trap does not double-write; cycle_start==stamp so a fresh run is not parked stale": "rehearsal_drive_log_end_once guard + rehearsal-drive-log-test.sh end-once assertions (one line with verdict; crash-only=ended)", "HOST_CAPACITY_DRIVE_REPO dependency on dev-factory #118 handled": "FACTORY_REF 9f4dfc6 has no HOST_CAPACITY_DRIVE_REPO; left as TODO(#118), target rides target position per issue guidance" }, "summary": "Wired the rehearsal cycle to the harness drive-log/holder primitives and pre-minted the run dir so the fleet monitor can see a drive's slots, legs, verdict and history.", "blockers": [] } ``` </details>
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.

Reference
Matou/idss#1058
No description provided.