Skip to content

health: report when the ledger is behind the machine's native session records #149

Done

Description

@lukemaj

What: agent-observer health reports how far the ledger is behind the machine's native session records and fails when it is behind.
Why: rocky and cavallo kept running agent sessions after 3 Nov while their sync failed every hour, and nothing in Observer could tell: health only looks for running sessions with no transcript, never for recorded sessions missing from the ledger.
So what: A worker adds the freshness check to health in this repository; the broken sync jobs themselves are runbook#38.

Outcome

Any person or agent who runs health on a machine learns whether that machine's ledger covers its recent agent work, and the answer is a failure when it does not.

Evidence

  • rocky and cavallo: sync log shows exit=2 every hour since 2026-11-03 (can't open file .../.local/bin/agent-observer); see lukemaj/runbook#38.
  • Native session files modified since 2026-11-03 (find -newermt): rocky Claude 160, Codex 61, Grok 810; cavallo Claude 90, Codex 124, Grok 1143. None of this work is in their ledgers.
  • agent_observer/health.py checks only running sessions without a transcript ("running session has no transcript: it is invisible to Observer"). On bestia health printed "checked 133 Claude sessions and 0 agent processes: 0 invisible", which says nothing about ledger freshness.
  • The 25 Nov Agent Observer review could cover bestia only, and did not notice until the user pointed out that rocky and cavallo had sessions.

Acceptance criteria

  • health reports, per harness, the time of the newest native record and of the newest ledger import, and the count of native session sources newer than the ledger.
  • health exits nonzero and names the gap when native records are newer than the ledger by more than one sync interval (configurable), including when the ledger was never synced.
  • health --json carries the same fields so a scheduled job or the weekly review can read them without transcripts.
  • Existing invisible-session findings keep working.

Required proof

Tests with fixture native records newer than the ledger (stale, never synced, current). A run on a copy of a stale ledger reports the gap.

Non-goals

No sync scheduling, alert delivery or install changes (runbook#38); no cross-machine transport; no change to attribution (#105).

Blockers

None.

Elon record

Requirements and who asked: The user, 25 Nov: Observer not knowing its ledger is behind real sessions is the bigger problem.
Deleted: A new daemon, a cross-machine aggregator and a separate monitor; health already exists and is the place people and agents check.
Bottleneck: health has no freshness check, so a dead sync looks healthy.
Checked myself: Read both machines' sync logs and counted their native session files over ssh; read agent_observer/health.py; ran health on bestia.

Activity

  1. lukemaj commented on Nov 25, 2026

    @lukemaj
    ContributorAuthor

    What PR #150 adds per-harness ledger freshness to agent-observer health.
    Why The live-session checks returned success while native records were newer than the ledger.
    So what CI and independent review passed. PR #150 is ready for merge approval.

    • Head a71c37599888d8da2aa9170d69bed87b2fbaa084, version 1.6.0.
    • A SQLite query error marks OpenCode visibility unavailable and leaves freshness output intact. The CLI fixture reproduces a missing update column and a corrupt SQLite file. Testing both the visibility query and freshness output in the same CLI invocation catches failures that either check in isolation misses.
    • All 53 health tests, git diff --check, and versionctl release-check --json passed. Independent review passed on this head with no blocking findings. All 1,004 tests and GitHub proof passed.
    • A read-only SQLite copy of bestia's ledger produced the following output at a 120-second interval. The scratch copy was removed after proof.
    exit 4
    checked 134 Claude sessions and 0 agent processes: 0 invisible
    Ledger freshness (sync interval: 120 seconds)
    - t3: stale, newest native 2026-11-25T21:02:42+01:00, newest import 2026-11-25T20:53:11+01:00, 1 newer sources, lag 570 seconds
    - codex: stale, newest native 2026-11-25T21:02:40+01:00, newest import 2026-11-25T20:51:20+01:00, 9 newer sources, lag 680 seconds
    - claude: stale, newest native 2026-11-25T21:00:54+01:00, newest import 2026-11-25T20:51:26+01:00, 3 newer sources, lag 568 seconds
    - opencode: current, newest native 2026-11-17T20:42:20+01:00, newest import 2026-11-17T20:50:31+01:00, 0 newer sources, lag 0 seconds
    - grok: stale, newest native 2026-11-25T21:02:42+01:00, newest import 2026-11-25T20:51:32+01:00, 30 newer sources, lag 670 seconds
    - muse: current, newest native 2026-11-14T18:34:48+01:00, newest import 2026-11-14T18:51:00+01:00, 0 newer sources, lag 0 seconds
    - router: no native records, newest native unknown, newest import unknown, 0 newer sources
    JSON exit 4 ['claude', 'codex', 'grok', 't3']
    

    CI and review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions