session-runner: record its sessions into swarm.db so monitors can see them #81

Closed
opened 2026-08-25 03:38:03 +00:00 by ben · 2 comments
Owner

A ready-for-session drainer session is invisible to every monitor: session-runner.sh writes nothing to swarm.db (its only trace is session-runner.log on the host), so neither the per-repo TUI's Monitor/Run tabs nor the fleet monitor's Fleet/Runs tabs can show a running or past session, and a wedged session has no #435-style open-process marker anywhere.

Wanted: session-runner records into the SAME host swarm.db the swarm uses —

  • a runs row per session it actually starts (trigger session), verdict on exit — NOT one per empty cron tick (ticks that find no claimable ticket record nothing, or the db drowns in noise at */10);
  • a processes row for the live session (kind session), ended_at closed by the same EXIT-trap discipline run-swarm uses, so an open row = believed alive = the wedge marker monitors already understand;
  • attempts/spend where the session shape allows (issue number is known at claim).

Blast radius: swarm-db.py schema is unchanged (kinds/triggers are free-text); session-runner.sh + its offline test updated in the same commit. Monitors need no change — the fleet monitor's RUNNING NOW / Runs / WEDGE columns pick sessions up for free once the rows exist. Follow-up from the fleet-monitor arc (#64–#74).

A `ready-for-session` drainer session is invisible to every monitor: `session-runner.sh` writes nothing to `swarm.db` (its only trace is `session-runner.log` on the host), so neither the per-repo TUI's Monitor/Run tabs nor the fleet monitor's Fleet/Runs tabs can show a running or past session, and a wedged session has no #435-style open-process marker anywhere. Wanted: session-runner records into the SAME host `swarm.db` the swarm uses — - a `runs` row per session it actually starts (trigger `session`), verdict on exit — NOT one per empty cron tick (ticks that find no claimable ticket record nothing, or the db drowns in noise at */10); - a `processes` row for the live session (kind `session`), `ended_at` closed by the same EXIT-trap discipline run-swarm uses, so an open row = believed alive = the wedge marker monitors already understand; - `attempts`/`spend` where the session shape allows (issue number is known at claim). Blast radius: `swarm-db.py` schema is unchanged (kinds/triggers are free-text); `session-runner.sh` + its offline test updated in the same commit. Monitors need no change — the fleet monitor's RUNNING NOW / Runs / WEDGE columns pick sessions up for free once the rows exist. Follow-up from the fleet-monitor arc (#64–#74).

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

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

close-report for #81 — status success

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

envelope
{
  "issue": 81,
  "status": "success",
  "commits": [
    "a705d38"
  ],
  "changed_files": [
    "STATUS.md",
    "session-runner.sh",
    "tests/session-runner-test.sh"
  ],
  "tests": [
    {
      "command": "bash tests/session-runner-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: $t; done",
      "exit_code": 0
    }
  ],
  "criteria": {
    "a runs row per session it actually starts (trigger `session`), verdict on exit — NOT one per empty cron tick": "session-runner.sh opens the run row (swarmdb_run_start ... session) at the session-start choke point after claim+checkout, gated by session_recorded; verdict stamped on exit by sr_on_exit (advanced/not-advanced/limit-parked/killed:*). Test 17a asserts trigger=session + verdict=advanced + ended_at set; 17d/17e assert an absorbed and a nothing-workable tick write NO run row",
    "a processes row for the live session (kind `session`), ended_at closed by the same EXIT-trap discipline run-swarm uses": "swarmdb proc-open --kind session --ref $$ at the choke point; sr_on_exit proc-closes it, with SIGTERM/SIGINT routed through the trap exactly as run-swarm does; a SIGKILL leaves the row open = wedge. Test 17a/17b/17c assert kind=session and a closed (ended_at set) process row on graceful exit",
    "attempts/spend where the session shape allows (issue number is known at claim)": "swarmdb attempt --issue $pick inserts at the choke point (DEFAULT fail) and is promoted to success only on the advanced outcome (invariant 1). Test 17a asserts issue 25 status success; 17b asserts a noop session's attempt stays fail. Spend is intentionally omitted and documented: the plain -p text session carries no token-usage payload (unlike main.mts's RunResult) — the ticket's 'where the session shape allows'",
    "swarm-db.py schema is unchanged (kinds/triggers are free-text)": "no change to swarm-db.py; session/session are new free-text values in existing kind/trigger columns (git diff shows swarm-db.py untouched)",
    "session-runner.sh + its offline test updated in the same commit": "commit a705d38 changes both session-runner.sh and tests/session-runner-test.sh (group 17, five cases)",
    "Monitors need no change": "no monitor/TUI files changed; the fleet monitor reads runs/processes/attempts by column and picks the rows up for free"
  },
  "summary": "session-runner.sh now records a session it actually starts into the host swarm.db (runs/processes/attempts) with run-swarm's kills-finalise EXIT-trap discipline, so monitors see it — with a five-case offline test.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #81 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 81, "status": "success", "commits": [ "a705d38" ], "changed_files": [ "STATUS.md", "session-runner.sh", "tests/session-runner-test.sh" ], "tests": [ { "command": "bash tests/session-runner-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: $t; done", "exit_code": 0 } ], "criteria": { "a runs row per session it actually starts (trigger `session`), verdict on exit — NOT one per empty cron tick": "session-runner.sh opens the run row (swarmdb_run_start ... session) at the session-start choke point after claim+checkout, gated by session_recorded; verdict stamped on exit by sr_on_exit (advanced/not-advanced/limit-parked/killed:*). Test 17a asserts trigger=session + verdict=advanced + ended_at set; 17d/17e assert an absorbed and a nothing-workable tick write NO run row", "a processes row for the live session (kind `session`), ended_at closed by the same EXIT-trap discipline run-swarm uses": "swarmdb proc-open --kind session --ref $$ at the choke point; sr_on_exit proc-closes it, with SIGTERM/SIGINT routed through the trap exactly as run-swarm does; a SIGKILL leaves the row open = wedge. Test 17a/17b/17c assert kind=session and a closed (ended_at set) process row on graceful exit", "attempts/spend where the session shape allows (issue number is known at claim)": "swarmdb attempt --issue $pick inserts at the choke point (DEFAULT fail) and is promoted to success only on the advanced outcome (invariant 1). Test 17a asserts issue 25 status success; 17b asserts a noop session's attempt stays fail. Spend is intentionally omitted and documented: the plain -p text session carries no token-usage payload (unlike main.mts's RunResult) — the ticket's 'where the session shape allows'", "swarm-db.py schema is unchanged (kinds/triggers are free-text)": "no change to swarm-db.py; session/session are new free-text values in existing kind/trigger columns (git diff shows swarm-db.py untouched)", "session-runner.sh + its offline test updated in the same commit": "commit a705d38 changes both session-runner.sh and tests/session-runner-test.sh (group 17, five cases)", "Monitors need no change": "no monitor/TUI files changed; the fleet monitor reads runs/processes/attempts by column and picks the rows up for free" }, "summary": "session-runner.sh now records a session it actually starts into the host swarm.db (runs/processes/attempts) with run-swarm's kills-finalise EXIT-trap discipline, so monitors see it — with a five-case offline test.", "reason": "", "blockers": [], "no_code_change": "" } ``` </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.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#81
No description provided.