Always-on host activity sampler — per-minute slot/killswitch/load record independent of the TUI #97

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

From the 2026-08-25 observability review — the requirement is "exactly what each machine was doing for every minute of the day".

Symptom. The only over-time sampling today is the fleet monitor's operator-local samples.py db, and its own docstring concedes it records only while the TUI happens to be running. With triage/heal/drives also unrecorded (sibling tickets), idle vs. busy is inferred from runs gaps and is currently wrong.

Direction. A tiny host-side cron (every minute) appending one line: epoch, each pooled slot's holder (flock probe + marker contents), killswitch state, limit-park state, loadavg/mem. Append-only file (or a host_samples table in swarm.db), rotated. The probe can then serve recent samples so the TUI's Loss/util views measure reality instead of sampling opportunistically. Even with all activity tickets landed, the sampler is the ground truth that catches anything the event writers miss — the two records cross-check each other.

Registry-driven install like the backstop/session crons (onboarding/host-state-lib.sh), no product literals in the harness.

From the 2026-08-25 observability review — the requirement is "exactly what each machine was doing for every minute of the day". **Symptom.** The only over-time sampling today is the fleet monitor's operator-local `samples.py` db, and its own docstring concedes it records only while the TUI happens to be running. With triage/heal/drives also unrecorded (sibling tickets), idle vs. busy is inferred from `runs` gaps and is currently wrong. **Direction.** A tiny host-side cron (every minute) appending one line: epoch, each pooled slot's holder (flock probe + marker contents), killswitch state, limit-park state, loadavg/mem. Append-only file (or a `host_samples` table in swarm.db), rotated. The probe can then serve recent samples so the TUI's Loss/util views measure reality instead of sampling opportunistically. Even with all activity tickets landed, the sampler is the ground truth that catches anything the event writers miss — the two records cross-check each other. Registry-driven install like the backstop/session crons (`onboarding/host-state-lib.sh`), no product literals in the harness.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.
Ruling: ready-for-agent. Two-way door — the work is a registry directive + installer following the exact pattern already proven for the backstop/session crons (onboarding/host-state-lib.sh); revertible via the registry, provable by onboarding/tests. The agent's job is the registry/installer code, not manually operating any specific host — same posture as every other registry-driven directive already merged here.

Agent Brief

Category: enhancement
Summary: An always-on, per-minute host activity sampler independent of the TUI.

Current behavior:
The only over-time sampling today is the fleet monitor's operator-local samples.py db, which — by its own docstring — records only while the TUI happens to be running. With triage/heal/drive activity also unrecorded today (sibling tickets), idle vs. busy is inferred from gaps in runs and currently reads wrong.

Desired behavior:
A tiny host-side cron, ticking every minute, appends one record: epoch, each pooled slot's holder (from the existing flock probe + marker contents), killswitch state, limit-park state, and loadavg/mem — to an append-only store (a file, or a host_samples table in swarm.db), rotated so it doesn't grow unbounded. The probe can then serve recent samples so TUI Loss/util views measure reality instead of only sampling opportunistically. Installed registry-driven, the same way the backstop/session crons already are — no product literals in the harness.

Key interfaces:

  • onboarding/host-state-lib.sh's registry parser/installer (the backstop-schedule/session-schedule pattern is the template for a new per-minute directive).
  • The pooled-slot flock probe and marker contents already used by host-capacity-lib.sh.
  • Whatever probe endpoint serves recent samples to the TUI.

Acceptance criteria:

  • A per-minute cron entry installs registry-driven, matching the existing backstop/session cron mechanism
  • Each tick appends one record with epoch, slot holders, killswitch state, limit-park state, loadavg/mem
  • The store is rotated/bounded, not unbounded
  • The probe can serve recent samples
  • onboarding/tests cover the new registry directive and installer behavior

Out of scope:

  • Replacing the runs/processes-based recording the sibling tickets add — this is a cross-check, not a replacement
  • The fleet monitor's own samples.py
> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** Ruling: `ready-for-agent`. Two-way door — the work is a registry directive + installer following the exact pattern already proven for the backstop/session crons (`onboarding/host-state-lib.sh`); revertible via the registry, provable by `onboarding/tests`. The agent's job is the registry/installer code, not manually operating any specific host — same posture as every other registry-driven directive already merged here. ## Agent Brief **Category:** enhancement **Summary:** An always-on, per-minute host activity sampler independent of the TUI. **Current behavior:** The only over-time sampling today is the fleet monitor's operator-local `samples.py` db, which — by its own docstring — records only while the TUI happens to be running. With triage/heal/drive activity also unrecorded today (sibling tickets), idle vs. busy is inferred from gaps in `runs` and currently reads wrong. **Desired behavior:** A tiny host-side cron, ticking every minute, appends one record: epoch, each pooled slot's holder (from the existing flock probe + marker contents), killswitch state, limit-park state, and loadavg/mem — to an append-only store (a file, or a `host_samples` table in swarm.db), rotated so it doesn't grow unbounded. The probe can then serve recent samples so TUI Loss/util views measure reality instead of only sampling opportunistically. Installed registry-driven, the same way the backstop/session crons already are — no product literals in the harness. **Key interfaces:** - `onboarding/host-state-lib.sh`'s registry parser/installer (the `backstop-schedule`/`session-schedule` pattern is the template for a new per-minute directive). - The pooled-slot flock probe and marker contents already used by `host-capacity-lib.sh`. - Whatever probe endpoint serves recent samples to the TUI. **Acceptance criteria:** - [ ] A per-minute cron entry installs registry-driven, matching the existing backstop/session cron mechanism - [ ] Each tick appends one record with epoch, slot holders, killswitch state, limit-park state, loadavg/mem - [ ] The store is rotated/bounded, not unbounded - [ ] The probe can serve recent samples - [ ] `onboarding/tests` cover the new registry directive and installer behavior **Out of scope:** - Replacing the `runs`/`processes`-based recording the sibling tickets add — this is a cross-check, not a replacement - The fleet monitor's own `samples.py`
Author
Member

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

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

close-report for #97 — status success

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

envelope
{
  "issue": 97,
  "status": "success",
  "commits": [
    "4e74251d19d87fe700566a3e4578358942c8b993"
  ],
  "changed_files": [
    "STATUS.md",
    "fleet-tui/probe.py",
    "fleet-tui/tests/test_probe.py",
    "onboarding/host-state-lib.sh",
    "onboarding/tests/host-state-lib-test.sh"
  ],
  "tests": [
    {
      "command": "bash onboarding/tests/host-state-lib-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 per-minute cron entry installs registry-driven, matching the existing backstop/session cron mechanism": "onboarding/host-state-lib.sh: new `sampler-schedule` directive (default `* * * * *`) parsed/emitted like backstop-schedule/session-schedule; host_state_render_cron emits one `<home>/factory-cron/host-sampler-tick.sh` cron line; host_state_install writes the generated tick alongside backstop-tick.sh. Tests: 'render_cron emits exactly one sampler line', 'install writes the generated sampler tick script, executable (#97)'.",
    "Each tick appends one record with epoch, slot holders, killswitch state, limit-park state, loadavg/mem": "host_state_render_sampler generates a tick that appends one TSV line: epoch, loadavg + MemAvailable/MemTotal, kill-switch on/off, limit-park account+age, and each pooled slot's held/free via a non-blocking read-fd flock probe + marker content. Test RUNS the generated tick offline asserting every field ('sampler probes a held slot as held, a free slot as free', 'sampler records a fresh limit park as the exhausted account, with an age', etc.).",
    "The store is rotated/bounded, not unbounded": "The generated tick tail-trims the store to HOST_SAMPLER_MAX_LINES (default 10080 = a week of minutes) every tick. Test: 'sampler rotates the store to its line cap (never grows unbounded)'.",
    "The probe can serve recent samples": "fleet-tui/probe.py gains --host-samples (+ --host-samples-n, default 120), dumping the last N records verbatim newest-last; absent store fills errors without crashing. Verified manually (python3) and covered by fleet-tui/tests/test_probe.py (test_host_samples_served_newest_last, test_host_samples_absent_store_is_an_error_not_a_crash).",
    "onboarding/tests cover the new registry directive and installer behavior": "onboarding/tests/host-state-lib-test.sh: +23 checks for the sampler-schedule directive (accept/override/refuse-malformed), the rendered per-minute unguarded log-shipping cron line, the generated tick run offline (slot probe, killswitch, limit-park fresh/stale, rotation), and install writing the executable sampler tick. Suite: 144 passed, 0 failed; full offline loop green."
  },
  "summary": "Added an always-on, per-minute host activity sampler (registry-driven cron rendering a generated tick that records slot holders, killswitch, limit-park and load/mem to a bounded store), with the probe serving recent samples.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #97 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 97, "status": "success", "commits": [ "4e74251d19d87fe700566a3e4578358942c8b993" ], "changed_files": [ "STATUS.md", "fleet-tui/probe.py", "fleet-tui/tests/test_probe.py", "onboarding/host-state-lib.sh", "onboarding/tests/host-state-lib-test.sh" ], "tests": [ { "command": "bash onboarding/tests/host-state-lib-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 per-minute cron entry installs registry-driven, matching the existing backstop/session cron mechanism": "onboarding/host-state-lib.sh: new `sampler-schedule` directive (default `* * * * *`) parsed/emitted like backstop-schedule/session-schedule; host_state_render_cron emits one `<home>/factory-cron/host-sampler-tick.sh` cron line; host_state_install writes the generated tick alongside backstop-tick.sh. Tests: 'render_cron emits exactly one sampler line', 'install writes the generated sampler tick script, executable (#97)'.", "Each tick appends one record with epoch, slot holders, killswitch state, limit-park state, loadavg/mem": "host_state_render_sampler generates a tick that appends one TSV line: epoch, loadavg + MemAvailable/MemTotal, kill-switch on/off, limit-park account+age, and each pooled slot's held/free via a non-blocking read-fd flock probe + marker content. Test RUNS the generated tick offline asserting every field ('sampler probes a held slot as held, a free slot as free', 'sampler records a fresh limit park as the exhausted account, with an age', etc.).", "The store is rotated/bounded, not unbounded": "The generated tick tail-trims the store to HOST_SAMPLER_MAX_LINES (default 10080 = a week of minutes) every tick. Test: 'sampler rotates the store to its line cap (never grows unbounded)'.", "The probe can serve recent samples": "fleet-tui/probe.py gains --host-samples (+ --host-samples-n, default 120), dumping the last N records verbatim newest-last; absent store fills errors without crashing. Verified manually (python3) and covered by fleet-tui/tests/test_probe.py (test_host_samples_served_newest_last, test_host_samples_absent_store_is_an_error_not_a_crash).", "onboarding/tests cover the new registry directive and installer behavior": "onboarding/tests/host-state-lib-test.sh: +23 checks for the sampler-schedule directive (accept/override/refuse-malformed), the rendered per-minute unguarded log-shipping cron line, the generated tick run offline (slot probe, killswitch, limit-park fresh/stale, rotation), and install writing the executable sampler tick. Suite: 144 passed, 0 failed; full offline loop green." }, "summary": "Added an always-on, per-minute host activity sampler (registry-driven cron rendering a generated tick that records slot holders, killswitch, limit-park and load/mem to a bounded store), with the probe serving recent samples.", "reason": "", "blockers": [], "no_code_change": "" } ``` </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#97
No description provided.