fleet monitor T8: loss.py — reset windows, observed ceiling, idle, system failure time #71

Closed
opened 2026-08-24 18:35:29 +00:00 by ben · 2 comments
Owner

Implement Task 8 of docs/superpowers/plans/2026-08-24-fleet-monitor.md (on main; spec: docs/superpowers/specs/2026-08-24-fleet-monitor-design.md) exactly as written: failing tests first, then the implementation, then the task's own commit. The plan's Global Constraints apply to every task: fleet-tui/** stays vendor-excluded, no product literal in code or fixtures (invented names only), read-only against the factory, offline tests (fake ssh, fixture blobs, swarm.db seeded via the real swarm-db.py), module suite green (cd fleet-tui && python3 -m pytest tests/ — use tui/.venv if no system pytest).

Pure: weekly window cutting from fleet.conf reset anchors (UTC); used per account per window from stamped spend_daily; parked = fleet-wide limit event in window (documented approximation until spend stamping lands); observed ceiling = max used over closed parked windows; unused rows (budget beats observed; parked window reads 0; no data reads 'no ceiling data' — calibration after the fact, NEVER a proximity warning). Plus idle/util over merged run intervals, and slot-hours-idle-while-backlog>0 integrated over samples with a coverage fraction and max_gap=120s.

Implement **Task 8** of `docs/superpowers/plans/2026-08-24-fleet-monitor.md` (on `main`; spec: `docs/superpowers/specs/2026-08-24-fleet-monitor-design.md`) exactly as written: failing tests first, then the implementation, then the task's own commit. The plan's **Global Constraints** apply to every task: `fleet-tui/**` stays vendor-excluded, no product literal in code or fixtures (invented names only), read-only against the factory, offline tests (fake ssh, fixture blobs, swarm.db seeded via the real swarm-db.py), module suite green (`cd fleet-tui && python3 -m pytest tests/` — use `tui/.venv` if no system pytest). Pure: weekly window cutting from fleet.conf reset anchors (UTC); used per account per window from stamped spend_daily; parked = fleet-wide limit event in window (documented approximation until spend stamping lands); observed ceiling = max used over closed parked windows; unused rows (budget beats observed; parked window reads 0; no data reads 'no ceiling data' — calibration after the fact, NEVER a proximity warning). Plus idle/util over merged run intervals, and slot-hours-idle-while-backlog>0 integrated over samples with a coverage fraction and max_gap=120s.

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

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

close-report for #71 — status success

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

envelope
{
  "issue": 71,
  "status": "success",
  "commits": [
    "beaac2bc0601e5796a6d6f34b5cca0e4fed289d3"
  ],
  "changed_files": [
    "fleet-tui/loss.py",
    "fleet-tui/tests/test_loss.py",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "python3 driver: import test_loss; run all test_* (no system pytest in sandbox)",
      "exit_code": 0
    },
    {
      "command": "bash onboarding/tests/vendor-manifest-coverage-test.sh",
      "exit_code": 0
    },
    {
      "command": "for t in tests/*.sh onboarding/tests/*.sh (offline suite)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "failing tests first then implementation then commit": "test_loss.py + loss.py in commit beaac2bc0601e5796a6d6f34b5cca0e4fed289d3; loss test module pure (no pytest fixtures) verified 5/5 pass via stdlib driver, mirroring prior tasks' harness note",
    "window_start: most recent weekly UTC anchor at/before ts": "loss.window_start; test_window_start_lands_on_the_anchor",
    "account_windows: used from stamped spend_daily by day, parked from fleet-wide limit_events, [] when no reset": "loss.account_windows; test_windows_used_and_parked",
    "observed_ceiling: max used over closed parked windows": "loss.observed_ceiling; test_windows_used_and_parked",
    "unused_rows: budget beats observed, parked closed reads 0, no data reads 'no ceiling data', open active/limit-parked": "loss.unused_rows; test_unused_rows_budget_beats_observed_and_parked_reads_zero",
    "idle_rows: idle/util over merged (unioned) run intervals": "loss.idle_rows + _union; test_idle_rows_unions_overlapping_runs",
    "failure_time: free_slots*dt over samples while backlog>0, coverage fraction, max_gap=120": "loss.failure_time; test_failure_time_counts_free_slots_only_with_backlog",
    "Global Constraints: fleet-tui/** vendor-excluded, no product literal, read-only, offline tests": "fleet-tui/** in onboarding/vendor-exclude (coverage test green); fixtures use invented names (acme/box-a/alpha/bravo); loss.py is pure, no I/O or network",
    "module suite green (cd fleet-tui && python3 -m pytest tests/)": "pytest unavailable offline in sandbox (no pip/ensurepip); pure loss tests verified 5/5 via stdlib driver; repo offline suite green with no FAILs"
  },
  "summary": "Added fleet-tui/loss.py — pure Loss-tab arithmetic (reset windows, observed ceiling, unused rows, idle/util, system failure time) with its test, T8 of the fleet-monitor DAG.",
  "blockers": []
}
**close-report** for #71 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 71, "status": "success", "commits": [ "beaac2bc0601e5796a6d6f34b5cca0e4fed289d3" ], "changed_files": [ "fleet-tui/loss.py", "fleet-tui/tests/test_loss.py", "STATUS.md" ], "tests": [ { "command": "python3 driver: import test_loss; run all test_* (no system pytest in sandbox)", "exit_code": 0 }, { "command": "bash onboarding/tests/vendor-manifest-coverage-test.sh", "exit_code": 0 }, { "command": "for t in tests/*.sh onboarding/tests/*.sh (offline suite)", "exit_code": 0 } ], "criteria": { "failing tests first then implementation then commit": "test_loss.py + loss.py in commit beaac2bc0601e5796a6d6f34b5cca0e4fed289d3; loss test module pure (no pytest fixtures) verified 5/5 pass via stdlib driver, mirroring prior tasks' harness note", "window_start: most recent weekly UTC anchor at/before ts": "loss.window_start; test_window_start_lands_on_the_anchor", "account_windows: used from stamped spend_daily by day, parked from fleet-wide limit_events, [] when no reset": "loss.account_windows; test_windows_used_and_parked", "observed_ceiling: max used over closed parked windows": "loss.observed_ceiling; test_windows_used_and_parked", "unused_rows: budget beats observed, parked closed reads 0, no data reads 'no ceiling data', open active/limit-parked": "loss.unused_rows; test_unused_rows_budget_beats_observed_and_parked_reads_zero", "idle_rows: idle/util over merged (unioned) run intervals": "loss.idle_rows + _union; test_idle_rows_unions_overlapping_runs", "failure_time: free_slots*dt over samples while backlog>0, coverage fraction, max_gap=120": "loss.failure_time; test_failure_time_counts_free_slots_only_with_backlog", "Global Constraints: fleet-tui/** vendor-excluded, no product literal, read-only, offline tests": "fleet-tui/** in onboarding/vendor-exclude (coverage test green); fixtures use invented names (acme/box-a/alpha/bravo); loss.py is pure, no I/O or network", "module suite green (cd fleet-tui && python3 -m pytest tests/)": "pytest unavailable offline in sandbox (no pip/ensurepip); pure loss tests verified 5/5 via stdlib driver; repo offline suite green with no FAILs" }, "summary": "Added fleet-tui/loss.py — pure Loss-tab arithmetic (reset windows, observed ceiling, unused rows, idle/util, system failure time) with its test, T8 of the fleet-monitor DAG.", "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/dev-factory#71
No description provided.