Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
92423fa
Report native session freshness in health
lukemaj Nov 25, 2026
41e9528
Cover Router rollouts and report incomplete health scans
lukemaj Nov 25, 2026
2249476
Surface permission errors during health source discovery
lukemaj Nov 25, 2026
4aec14d
Match health freshness to native import accounting
lukemaj Nov 25, 2026
6bfb5ff
Revalidate Grok metadata and follow symlinked SQLite WAL files
lukemaj Nov 25, 2026
fe00d36
Keep Grok transcripts importable and revalidate Router freshness
lukemaj Nov 25, 2026
4493cf4
Preserve freshness gaps on malformed Grok metadata
lukemaj Nov 25, 2026
03e098b
Keep freshness timestamps on unchanged Grok replays
lukemaj Nov 25, 2026
fe4ced6
Advance Grok freshness only after a complete session import
lukemaj Nov 25, 2026
e4e8060
Track complete Grok sync separately from transcript imports
lukemaj Nov 25, 2026
b785555
Preserve Grok source identity and timestamps on retry
lukemaj Nov 25, 2026
d25a987
Recover first partial Grok transcript by native source identity
lukemaj Nov 25, 2026
4584bd9
Defer Grok transcripts when native identity is unknown
lukemaj Nov 25, 2026
af16e49
Wait for Grok identity when initial summary is absent or empty
lukemaj Nov 25, 2026
b120a9d
Resolve Grok identity from native event records
lukemaj Nov 25, 2026
6954eb0
Preserve supported Grok identity fallback and summary precedence
lukemaj Nov 25, 2026
0e79f00
Require valid native evidence for Grok identity lookup
lukemaj Nov 25, 2026
a660c3b
Use validated Grok tool notifications for identity recovery
lukemaj Nov 25, 2026
8336bc2
Use valid Grok message updates for native identity
lukemaj Nov 25, 2026
cd6b493
Accept known Grok lifecycle updates as identity evidence
lukemaj Nov 25, 2026
843de0e
Keep Router sync independent of timestamp probe access
lukemaj Nov 25, 2026
d6f41d6
Keep native paths out of freshness scan errors
lukemaj Nov 25, 2026
0f6252f
Validate health timestamps and redact ledger diagnostics
lukemaj Nov 25, 2026
71bdd48
Reject malformed timestamps in ledger health
lukemaj Nov 25, 2026
4a185b0
Count OpenCode child record creation in ledger freshness
lukemaj Nov 25, 2026
a71c375
Keep health reporting after OpenCode visibility query errors
lukemaj Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-observer",
"version": "1.5.3",
"version": "1.6.0",
"description": "Measure agent work across Codex, Claude Code, OpenCode and Grok Build from native records, and compare behavior by model and AgentsMD version.",
"author": {
"name": "toolboxmd",
Expand Down
2 changes: 1 addition & 1 deletion .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-observer",
"version": "1.5.3",
"version": "1.6.0",
"description": "Measure agent work across Codex, Claude Code, OpenCode and Grok Build from native records, and compare behavior by model and AgentsMD version.",
"author": {
"name": "toolboxmd",
Expand Down
2 changes: 1 addition & 1 deletion .grok-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-observer",
"version": "1.5.3",
"version": "1.6.0",
"description": "Measure agent work across Codex, Claude Code, OpenCode and Grok Build from native records, and compare behavior by model and AgentsMD version.",
"author": {
"name": "toolboxmd",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [1.6.0] - 2026-11-25

### Added

- Report native session freshness in health and fail when the ledger falls behind

## [1.5.3] - 2026-11-23

### Changed
Expand Down
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ agent-observer sessions list --project myapp --since 2026-09-01
agent-observer diagnose --since 2026-09-01 # repeated work and behavior incidents
agent-observer thread-misuse --since 2026-10-01 # deep Chromeria spawns, cross-thread messages
agent-observer compare --by agentsmd # behavior per AgentsMD version
agent-observer health # live sessions Observer cannot see
agent-observer health # session visibility and ledger freshness
agent-observer claims --session claude:<id> # final-report claims checked against tool calls
agent-observer delegation-modes --since 2026-10-01 # planner delegation versus a dispatcher thread
agent-observer event show <id> [<id> ...] # full tool input, result and assistant text from the native log
Expand Down Expand Up @@ -708,11 +708,26 @@ the process, directory and fix. Missing, failed, malformed or timed-out process
scans are reported as unavailable with a reason; each `ps` or `lsof` invocation
has a five-second timeout, and other health checks continue.

Health exits 0 when it finds no invisible sessions, unavailable scans or Cue
schema/read failures; it exits 4 when any is reported, and 2 for invalid
command-line arguments. Optional missing or unsynced Cue evidence stays visible
without failing health. An unread ledger
is reported as unknown and does not by itself change the exit status.
Health also compares the newest native record with the newest successful ledger
import for each harness. It counts native sources newer than that harness's
latest import. Claude, Codex and Muse use transcript file modification times.
Codex includes rollouts imported by Model Router.
Grok counts each session directory once using its newest event log or session
metadata file.
OpenCode counts sessions by their latest session, message or part timestamp.
Chromeria and Router use database and WAL modification times. These comparisons
measure lag for each harness. Individual missing imports can predate its newest
successful import.

Health exits 4 for an invisible session, an unavailable check, a Cue
schema/read failure, or a freshness gap. A gap means native records exist and
the ledger has no import for that harness, or the newest native record is more
than 3600 seconds newer than its latest import. Set
`health --sync-interval-seconds N` to match your sync cadence.
`health --json` includes the interval and the `ledger_freshness` map, with
Unix timestamps in seconds, newer-source counts, lag and status. Health
exits 0 when its checks pass and 2 for invalid arguments. Optional missing
or unsynced Cue evidence stays visible without failing health.

## Ledger schema 3

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.3
1.6.0
17 changes: 12 additions & 5 deletions agent_observer/adapters/bare.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from typing import Callable

from . import t3
from .discovery import path_info

TURN_ITEMS = "orchestration_v2_projection_turn_items"
# Chromeria ids every receipt ``bare-receipt:<provider thread>:<native id>``
Expand Down Expand Up @@ -74,12 +75,13 @@ def _receipts(path: str) -> dict:
return roots


def receipt_roots(harness: str) -> tuple[list, dict]:
def receipt_roots(harness: str, *, strict: bool = False) -> tuple[list, dict]:
"""Recorded roots (None when a receipt names none) and the base report."""
path = t3.state_path()
path = t3.state_path(strict=strict)
report = {"state_db": path, "state": "unused", "receipts": 0, "roots": 0,
"gaps": []}
if not os.path.exists(path):
exists = path_info(path) is not None if strict else os.path.exists(path)
if not exists:
report["state"] = "no T3 state"
return [], report
try:
Expand All @@ -95,13 +97,16 @@ def receipt_roots(harness: str) -> tuple[list, dict]:


def discover(harness: str,
paths_under: Callable[[str], list[str]]) -> tuple[list[str], dict]:
paths_under: Callable[[str], list[str]], *,
strict: bool = False) -> tuple[list[str], dict]:
"""Record paths under every receipt root for harness, plus the report.

paths_under(root) lists one root's records. Roots are canonical, so
aliases of one directory are read once.
"""
rows, report = receipt_roots(harness)
rows, report = receipt_roots(harness, strict=strict)
if strict and report["state"] == "unreadable T3 state":
raise OSError(report["error"])
roots, gaps = [], []
for root in rows:
if not isinstance(root, str) or not root:
Expand All @@ -116,6 +121,8 @@ def discover(harness: str,
gaps.append({"root": real, "reason": "missing on this machine"})
continue
except OSError:
if strict:
raise
gaps.append({"root": real, "reason": "unreadable"})
continue
roots.append(real)
Expand Down
8 changes: 4 additions & 4 deletions agent_observer/adapters/claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from __future__ import annotations

import glob
import json
import os
import sqlite3
Expand All @@ -22,6 +21,7 @@
from ..identity import SessionIdentity, skill_from_path
from ..ingest import (JsonlSource, MissingNativeId, fingerprint, insert_event,
iso_ts, text_hash)
from .discovery import record_paths

HARNESS = "claude"
SEMANTICS = "claude:input_excludes_cache,output_includes_thinking"
Expand Down Expand Up @@ -219,10 +219,10 @@ def _mark_finalized(con, rid: str) -> None:
" VALUES(?, ?)", (rid, _time.time()))


def discover(root: str | None = None) -> list[str]:
def discover(root: str | None = None, *, strict: bool = False) -> list[str]:
root = root or DEFAULT_ROOT
main = glob.glob(os.path.join(root, "*", "*.jsonl"))
subs = glob.glob(os.path.join(root, "*", "*", "subagents", "agent-*.jsonl"))
main = record_paths(root, "*", "*.jsonl", strict=strict)
subs = record_paths(root, "*", "*", "subagents", "agent-*.jsonl", strict=strict)
return sorted(main + subs)


Expand Down
29 changes: 15 additions & 14 deletions agent_observer/adapters/codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from __future__ import annotations

import glob
import json
import math
import os
Expand All @@ -23,6 +22,7 @@
from ..ingest import (JsonlSource, MissingNativeId, fingerprint, insert_event,
iso_ts, stored_path, text_hash)
from . import bare
from .discovery import record_paths


def _native_ordinal(obj) -> int | None:
Expand Down Expand Up @@ -223,30 +223,31 @@ def _validate_bucket(bucket, *, allow_none: bool = True):
raise _MalformedUsage("malformed usage counter")


def _rollout_paths(root: str) -> list[str]:
def _rollout_paths(root: str, *, strict: bool = False) -> list[str]:
"""Rollout files under root. A missing directory contributes none."""
return glob.glob(os.path.join(root, "**", "rollout-*.jsonl"), recursive=True)
return record_paths(root, "**", "rollout-*.jsonl", strict=strict)


def _live_and_archived(live_root: str, archive_root: str) -> list[str]:
def _live_and_archived(live_root: str, archive_root: str, *, strict: bool = False) -> list[str]:
"""One home's live rollouts plus archived ones whose basename is not live."""
live = _rollout_paths(live_root)
live = _rollout_paths(live_root, strict=strict)
live_names = {os.path.basename(path) for path in live}
archived = [path for path in _rollout_paths(archive_root)
archived = [path for path in _rollout_paths(archive_root, strict=strict)
if os.path.basename(path) not in live_names]
return live + archived


def _bare_home(root: str) -> list[str]:
def _bare_home(root: str, *, strict: bool = False) -> list[str]:
"""A bare receipt root (``<home>/sessions``) plus its sibling archive."""
return _live_and_archived(
root, os.path.join(os.path.dirname(root), "archived_sessions"))
root, os.path.join(os.path.dirname(root), "archived_sessions"), strict=strict)


def _default_paths() -> tuple[list[str], dict]:
def _default_paths(*, strict: bool = False) -> tuple[list[str], dict]:
"""The normal home plus every Chromeria bare root, and the bare report."""
paths = _live_and_archived(DEFAULT_ROOT, ARCHIVE_ROOT)
found, report = bare.discover(HARNESS, _bare_home)
paths = _live_and_archived(DEFAULT_ROOT, ARCHIVE_ROOT, strict=strict)
found, report = bare.discover(HARNESS, lambda root: _bare_home(root, strict=strict),
strict=strict)
return sorted(paths + found), report


Expand All @@ -256,7 +257,7 @@ def _stored(con: sqlite3.Connection, paths: list[str]) -> list[str]:
return sorted({stored_path(con, HARNESS, path, seen) for path in paths})


def discover(root: str | None = None) -> list[str]:
def discover(root: str | None = None, *, strict: bool = False) -> list[str]:
"""Rollout files under one root, or every default home.

An explicit root is that directory only. With root unset, scan
Expand All @@ -267,8 +268,8 @@ def discover(root: str | None = None) -> list[str]:
stay. Dedup is by basename, not by thread id.
"""
if root:
return sorted(_rollout_paths(root))
return _default_paths()[0]
return sorted(_rollout_paths(root, strict=strict))
return _default_paths(strict=strict)[0]


def sync(con: sqlite3.Connection, root: str | None = None, full: bool = False,
Expand Down
66 changes: 66 additions & 0 deletions agent_observer/adapters/discovery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Native file discovery with an option to surface access errors."""

import glob
import os
import stat
from fnmatch import fnmatchcase


def path_info(path: str) -> os.stat_result | None:
"""Missing paths are optional and access errors are meaningful."""
try:
return os.stat(path)
except (FileNotFoundError, NotADirectoryError):
return None


def sqlite_mtime(path: str) -> float | None:
"""Newest database or WAL with frames, following the database's symlinks."""
path = os.path.realpath(path)
stamps = []
for candidate, min_size in ((path, 0), (path + "-wal", 33)):
info = path_info(candidate)
if info is not None and stat.S_ISREG(info.st_mode) and info.st_size >= min_size:
stamps.append(info.st_mtime)
return max(stamps, default=None)


def record_paths(root: str, *parts: str, strict: bool = False) -> list[str]:
"""Match adapter layouts. Strict discovery must distinguish empty and unreadable."""
if not strict:
return glob.glob(os.path.join(root, *parts), recursive="**" in parts)
return list(_walk(root, parts))


def _walk(path, parts, ancestors=frozenset()):
info = path_info(path)
if info is None:
return
if not parts:
if stat.S_ISREG(info.st_mode):
yield path
return
if not stat.S_ISDIR(info.st_mode):
return
pattern, *rest = parts
if pattern == "**":
key = (info.st_dev, info.st_ino)
if key in ancestors:
return
yield from _walk(path, rest)
children = ancestors | {key}
for name in _visible_entries(path):
yield from _walk(os.path.join(path, name), parts, children)
elif "*" in pattern:
for name in _visible_entries(path):
if fnmatchcase(name, pattern):
yield from _walk(os.path.join(path, name), rest)
else:
yield from _walk(os.path.join(path, pattern), rest)


def _visible_entries(path: str) -> list[str]:
try:
return [name for name in os.listdir(path) if not name.startswith(".")]
except (FileNotFoundError, NotADirectoryError):
return []
Loading