Observability: run-triage leaves no durable trace — record it in swarm.db and stop deleting its claude log #91

Closed
opened 2026-08-26 03:02:19 +00:00 by matou-build-agent · 3 comments

From the 2026-08-25 observability review (per-minute machine timeline / per-action durations / per-action tokens).

Symptom. A triage run occupies a pooled heavy slot for up to 45 minutes (timeout 2700, run-triage.sh) yet leaves no timeline record anywhere: no runs/processes row in swarm.db, no runlog line, and the captured claude log is deleted by the EXIT trap after the verdict is written (run-triage.sh:47). The verdict file itself is overwritten every run (verdict-lib.sh verdict_init starts with rm -f), so history is one-deep. A machine busy triaging reads as idle in the TUI's RUNNING column and is missing from util_24h.

Direction. Mirror what #81 did for session-runner: on an actually-started triage (not an absorbed tick) open a runs row (trigger triage), a processes row (kind triage), close both on exit with the verdict; keep the claude log as evidence (move it under the host logdir instead of rm -f) and record its path as a run-scoped event. Token capture for the call is the companion spend ticket.

Same commit: tests/ coverage per CLAUDE.md.

From the 2026-08-25 observability review (per-minute machine timeline / per-action durations / per-action tokens). **Symptom.** A triage run occupies a pooled heavy slot for up to 45 minutes (`timeout 2700`, `run-triage.sh`) yet leaves no timeline record anywhere: no `runs`/`processes` row in swarm.db, no runlog line, and the captured claude log is deleted by the EXIT trap after the verdict is written (`run-triage.sh:47`). The verdict file itself is overwritten every run (`verdict-lib.sh` `verdict_init` starts with `rm -f`), so history is one-deep. A machine busy triaging reads as **idle** in the TUI's RUNNING column and is missing from `util_24h`. **Direction.** Mirror what #81 did for session-runner: on an actually-started triage (not an absorbed tick) open a `runs` row (trigger `triage`), a `processes` row (kind `triage`), close both on exit with the verdict; keep the claude log as evidence (move it under the host logdir instead of `rm -f`) and record its path as a run-scoped event. Token capture for the call is the companion spend ticket. Same commit: `tests/` coverage per CLAUDE.md.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.
Ruling: ready-for-agent. This is a two-way door — it adds new, additive swarm.db rows and moves a log file's destination; a later commit or label change reverts it cleanly, and correctness is provable by tests/*.sh coverage of the same shape #81 already proved for session-runner. No credentials, security posture, member-facing trust, data loss, or spend decision is involved.

Agent Brief

Category: enhancement
Summary: Give triage runs a durable trace in swarm.db and stop deleting the captured claude log.

Current behavior:
A triage run that actually invokes claude occupies a pooled heavy slot for up to 45 minutes but leaves no runs/processes row in swarm.db and no runlog line. The captured claude log is deleted by the run's EXIT trap once the verdict is written, and the verdict file itself is overwritten on every run, so history is one-deep. A host busy triaging currently reads as idle in any util/timeline view built from runs.

Desired behavior:
On an actually-started triage (a run that reaches the claude call — not a deferred/absorbed tick such as limit-parked, drive-yielded, or lock-busy), a runs row (trigger triage) and a processes row (kind triage) are opened before the claude call and closed on every exit path with the run's real verdict. The captured claude log is preserved under a durable host-side logdir instead of removed, and its path is recorded as a run-scoped event.

Key interfaces:

  • The swarmdb_run_start / swarmdb_run_end / proc-open / proc-close helpers already used by session-runner's recording path — mirror that call shape rather than inventing a new one.
  • The EXIT trap that currently deletes the captured log.
  • The verdict write must still happen exactly once per run.

Acceptance criteria:

  • A triage run that reaches the claude call opens a runs + processes row before invoking claude
  • Both rows close (ended_at set) on every exit path, success or failure
  • The captured claude log is moved to a durable host-side path instead of deleted, and that path is recorded as a run-scoped event
  • A deferred/yielded tick does NOT open a runs row — only an actually-started triage does
  • tests/*.sh cover the new behavior

Out of scope:

  • Token/spend capture for the triage claude call (companion ticket #94)
  • Per-minute host sampling (#97)
> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** Ruling: `ready-for-agent`. This is a two-way door — it adds new, additive `swarm.db` rows and moves a log file's destination; a later commit or label change reverts it cleanly, and correctness is provable by `tests/*.sh` coverage of the same shape #81 already proved for session-runner. No credentials, security posture, member-facing trust, data loss, or spend decision is involved. ## Agent Brief **Category:** enhancement **Summary:** Give triage runs a durable trace in swarm.db and stop deleting the captured claude log. **Current behavior:** A triage run that actually invokes claude occupies a pooled heavy slot for up to 45 minutes but leaves no `runs`/`processes` row in swarm.db and no runlog line. The captured claude log is deleted by the run's EXIT trap once the verdict is written, and the verdict file itself is overwritten on every run, so history is one-deep. A host busy triaging currently reads as idle in any util/timeline view built from `runs`. **Desired behavior:** On an actually-started triage (a run that reaches the claude call — not a deferred/absorbed tick such as limit-parked, drive-yielded, or lock-busy), a `runs` row (trigger `triage`) and a `processes` row (kind `triage`) are opened before the claude call and closed on every exit path with the run's real verdict. The captured claude log is preserved under a durable host-side logdir instead of removed, and its path is recorded as a run-scoped event. **Key interfaces:** - The `swarmdb_run_start` / `swarmdb_run_end` / `proc-open` / `proc-close` helpers already used by session-runner's recording path — mirror that call shape rather than inventing a new one. - The EXIT trap that currently deletes the captured log. - The verdict write must still happen exactly once per run. **Acceptance criteria:** - [ ] A triage run that reaches the claude call opens a `runs` + `processes` row before invoking claude - [ ] Both rows close (`ended_at` set) on every exit path, success or failure - [ ] The captured claude log is moved to a durable host-side path instead of deleted, and that path is recorded as a run-scoped event - [ ] A deferred/yielded tick does NOT open a `runs` row — only an actually-started triage does - [ ] `tests/*.sh` cover the new behavior **Out of scope:** - Token/spend capture for the triage claude call (companion ticket #94) - Per-minute host sampling (#97)
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=1545
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=1545 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #91 — status success

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

envelope
{
  "issue": 91,
  "status": "success",
  "commits": [
    "6b26363"
  ],
  "changed_files": [
    "run-triage.sh",
    "tests/run-triage-test.sh",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash tests/run-triage-test.sh",
      "exit_code": 0
    },
    {
      "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL; done",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A triage run that reaches the claude call opens a runs + processes row before invoking claude": "run-triage.sh choke point after verdict_stage: swarmdb_run_start (trigger triage) + proc-open (kind triage) before the claude while-loop; test 91a asserts trigger/kind rows exist",
    "Both rows close (ended_at set) on every exit path, success or failure": "triage_on_exit closes proc + run on the EXIT trap; tests 91a (clean) and 91b (fault) assert ended_at IS NOT NULL on both runs and processes",
    "The captured claude log is moved to a durable host-side path instead of deleted, and that path is recorded as a run-scoped event": "triage_on_exit mv -f $triage_log -> $TRIAGE_LOGDIR/<runid>.log then swarmdb_event kind triage_log; tests 91a/91b assert the event detail is an existing file under the logdir carrying the captured body",
    "A deferred/yielded tick does NOT open a runs row — only an actually-started triage does": "recording is past the limit-park/drive-yield/nothing-untriaged early exits; triage_recorded stays 0 otherwise; test 91d asserts no run row for all three deferred paths",
    "tests/*.sh cover the new behavior": "tests/run-triage-test.sh gains dbq/db_reset harness and 4 new scenarios (91a-91d); 14 scenarios pass"
  },
  "summary": "Triage runs now open a repo-scoped runs+processes trace in swarm.db and preserve their claude log under a durable host logdir instead of deleting it.",
  "blockers": []
}
**close-report** for #91 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 91, "status": "success", "commits": [ "6b26363" ], "changed_files": [ "run-triage.sh", "tests/run-triage-test.sh", "STATUS.md" ], "tests": [ { "command": "bash tests/run-triage-test.sh", "exit_code": 0 }, { "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL; done", "exit_code": 0 } ], "criteria": { "A triage run that reaches the claude call opens a runs + processes row before invoking claude": "run-triage.sh choke point after verdict_stage: swarmdb_run_start (trigger triage) + proc-open (kind triage) before the claude while-loop; test 91a asserts trigger/kind rows exist", "Both rows close (ended_at set) on every exit path, success or failure": "triage_on_exit closes proc + run on the EXIT trap; tests 91a (clean) and 91b (fault) assert ended_at IS NOT NULL on both runs and processes", "The captured claude log is moved to a durable host-side path instead of deleted, and that path is recorded as a run-scoped event": "triage_on_exit mv -f $triage_log -> $TRIAGE_LOGDIR/<runid>.log then swarmdb_event kind triage_log; tests 91a/91b assert the event detail is an existing file under the logdir carrying the captured body", "A deferred/yielded tick does NOT open a runs row — only an actually-started triage does": "recording is past the limit-park/drive-yield/nothing-untriaged early exits; triage_recorded stays 0 otherwise; test 91d asserts no run row for all three deferred paths", "tests/*.sh cover the new behavior": "tests/run-triage-test.sh gains dbq/db_reset harness and 4 new scenarios (91a-91d); 14 scenarios pass" }, "summary": "Triage runs now open a repo-scoped runs+processes trace in swarm.db and preserve their claude log under a durable host logdir instead of deleting it.", "blockers": [] } ``` </details>
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/dev-factory#91
No description provided.