factory gap: wire the TUI data layer — RunResult capture, attempts/spend writers, verdict.json, drive heartbeat #574
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Reference
Matou/idss#574
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Gap
The TUI's data layer is designed but not wired (survey:
docs/research/2026-08-15-factory-reengineering-survey.md§state):main.mtsdiscards the entireRunResult—iterations[].usage(thespendrow, verbatim),sessionId,commits[].sha,logFilePath. Consequence:attemptsandspendtables have zero production writers (only the test suite exercises them);swarm-db.sh issue N/spend-weeklyreturn empty in production; thedocker eventsworker-birth watcher exists only to reconstruct what the return value already knows.close_outcomewire cut at both ends: the column exists (swarm-db.py:57),close-report.sh:48computes exactly that value, neither side connects.verdict.json— the reporter must be handed the rc by argument; the "red drive with zero red legs" branch papers over it.verdict-lib.shalready implements the pattern; the drive just doesn't use it.{leg, status: "running", startedAt}record (single highest-value TUI addition)./tmp/matou-{swarm,triage,seam}-verdict.txt) — two repos would stomp each other without the global lock.All two-way doors; agent-shaped once approved. Filed ready-for-human per Ben's instruction — re-arm at will.
Ben ruled (2026-08-19, live session): the factory block is delegated under ADR 0174 — dispatched to the agent/session lanes with dependency edges wired; veto via the tracker anytime.
Routed to
ready-for-session— this slice edits protected.sandcastle/pathsPicked up by swarm agent (run 7734). Stopping without code changes: every core part of this ticket edits protected
.sandcastle/machinery, which a swarm worker cannot land — the protected-paths fence (#445,.sandcastle/protected-paths-lib.sh) fingerprints.sandcastle/.forgejobefore/after the run, rolls back any change, and reds the run. Per ADR 0174 §5 anddocs/agents/triage-labels.md, protected.sandcastle/paths are theready-for-sessionlane, notready-for-agent.Where each part lives (protected unless noted):
RunResultcapture →.sandcastle/main.mts— protectedclose_outcomewire →.sandcastle/swarm-db.py+.sandcastle/close-report.sh— protectedverdict.json→.sandcastle/verdict-lib.sh+.sandcastle/rehearsal-report.sh— protected (writerscripts/rehearsal-*is not, but the reporter is)scripts/rehearsal-executor.sh(unprotected) but consumed via.sandcastle/rehearsal-report.shlegs.jsonin-flight record → writerscripts/rehearsal-cycle.sh(unprotected) + reader.sandcastle/rehearsal-report.sh— protected reader/tmp/matou-{swarm,triage,seam}-verdict.txt→.sandcastle/verdict-lib.sh+.sandcastle/run-*.sh— protectedParts 4/5 have unprotected writer halves, but each is only useful once its protected reader half lands, so no closeable subset exists for the agent lane. The whole slice needs an interactive session's standing.
Re-arm: run this from a session (which can edit
.sandcastle/), keeping the labelready-for-session. No one-way door here — nothing on ADR 0174 §3's list — so this is notready-for-human.Ruled by agent under ADR 0174 — veto anytime.
Session-runner (ADR 0174 / #538), re-armed per Ben's 2026-08-19 "re-arm at will" note on this ticket and the same day's factory-block delegation. A prior swarm attempt (run 7734, comment above) correctly stopped without code: every core part of this ticket edits protected
.sandcastle/machinery, which only a session's standing can land.All six gaps landed, each with an offline test, commit
1980f6b:close-report.shprints one structuredSANDCASTLE_ATTEMPT issue=N outcome=O commits=csvstdout line in every outcome (success or gate-refused) — a deliberate protocol line, not worker chain-of-thought prose.main.mtsnow captures theRunResultit used to discard and shells out to a new.sandcastle/record-run-result.sh, which parses those markers out of the combined stdout, zips them againstRunResult.iterations[]in iteration order (a same-issue retry within one iteration dedupes to its last outcome), and writesswarm.db'sattempts/spend/eventsrows — previously zero production writers, only exercised by the test suite.run-swarm.shexportsSWARM_DB_RUN_IDso main.mts's writes land under the exact run id its ownrunsrow uses.close_outcomewire — the value is the gate's verdict (refusedwhen the gate refuses the close, never the agent's self-declared"success"claim), computed right where the ticket named it (close-report.sh:48'sstatusvar) and now carried through toswarm-db.py'sattempts.close_outcomecolumn via the same marker line.verdict.json—journey.droplet.spec.ts/journey.selfhosted.spec.tsnow writeartifacts/verdict.jsonunconditionally inafterAll(ADR 0183 clause 5's exact schema), via a newcomputeVerdict()inlegs.ts.rehearsal-report.shtreats it as authoritative over the caller-passed rc when present, closing the "red drive with zero red legs" rc-passing hazard structurally (the run dir now says green-or-red on its own).scripts/lib/drive-status-lib.shwrites a repo-tagged/tmpJSON record carrying the in-flight drive's PID/target, written byrehearsal-cycle.shthe moment its lock is held and cleared on every exit;oc_droplet_create(scripts/lib/rehearsal-droplet.sh) fills in the droplet name+IP once known.legs.ts'srunRecordedLegnow pushes a{leg, status: "running", startedAt}record before a leg'sfn()starts, replacing it in place once the leg settles — the survey's named highest-value TUI addition, so a hung leg is visible on disk instead of indistinguishable from a working one for the whole of a 20-minute budget.computeVerdicttreats a leftoverrunningrecord as forcingred./tmp/matou-{swarm,triage,seam}-verdict.txtare now/tmp/matou-<repo-tag>-*-verdict.txtinrun-swarm.sh/run-triage.sh/heal.sh(reader) andscripts/seam-smoke.sh(via a new dependency-freescripts/lib/repo-tag-lib.sh, since seam-smoke.sh has noFORGEJO_API/tracker env to derive a tag from — it uses the git remote instead, same "owner-repo" shapeheal.sh'sREPO_TAGalready computed, so reader and writers always agree).Why a two-way door: every change is a commit plus an offline
.sandcastle/tests/*.sh/ vitest test — no live-infra action, no credential, no destructive step. Nothing on ADR 0174 §3's one-way-door list.Proof: all 39
.sandcastle/tests/*.shscripts green, the extendedapp/tests/e2e/fixtures/legs.test.ts(7 vitest cases) green, and the fullapp/tests/e2e/fixturesvitest suite (78 tests) green — all run fresh after every change, including after a real ordering bug caught in self-review (the drive-status write inrehearsal-cycle.shoriginally landed before.sandcastle/.envwas sourced, which would have silently dropped.env'sREHEARSAL_DRIVE_TARGET=selfhostedoverride — fixed before commit).pnpm exec tsc --noEmitclean on every touched TypeScript file (pre-existing unrelated errors insrc/bootstrap.ts/tests/unit/appShell.test.tsconfirmed present onorigin/mainbefore this change, viagit stash).Pushed to
origin/mainas1980f6b. STATUS.md updated in the same commit (header, milestone log, and the "Blocked on Ben" queue entry marking #574 resolved).