Skip to content

feat(dashboard): usage source-health parity, host-card cleanup, and opt-in runtime debug - #120

Merged
pacphi merged 1 commit into
mainfrom
feat/usage-source-health-parity-and-runtime-debug
Aug 6, 2026
Merged

pacphi merged 1 commit into
mainfrom
feat/usage-source-health-parity-and-runtime-debug

Conversation

@pacphi

@pacphi pacphi commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Usage source-health parity (ADR-0023 §7): sourceHealth covered only the two secondary/corrective sources (OpenCode's SQLite store, Codex's thread ledger) and never the primary Claude/Codex transcript roots — an unreadable ~/.claude/projects or ~/.codex/sessions still silently read as an ordinary empty result. New rootHealth() closes that gap with the same ok/absent/degraded vocabulary (fs error codes as the bounded reason). Verified grounded, not invented: Anthropic documents the Claude transcript path directly; Codex's ledger and OpenCode's db are real but undocumented internals, confirmed via their own upstream bug trackers.
  • Host-grouped chips: the dashboard now renders one chip per host (3), not one per field (4) — Codex's transcript-root and thread-ledger statuses fold into a single "Codex" chip instead of reading as a confusing fourth entry.
  • Usage "by host" panel cleanup: all three hosts always render (grayed out when idle, never hidden by setup state), fit one row, drop the stale "claude vs codex" label for a live "N active of 3" count, and OpenCode gets its own dot color.
  • Opt-in runtime debug flag: AK_RUNTIME_DEBUG=1 traces controller discovery stage-by-stage to a bounded, owner-only log — mirrors the existing AK_STATUSLINE_DEBUG contract, built to debug an Observability gap (a live controller process not surfacing) without needing print-debugging every time it recurs.
  • Docs: ADR-0023 updated (§5, §7, update note, Consequences, References); USAGE-SCORECARD-METRICS.md, TROUBLESHOOTING.md, adr/README.md synced; drifted file:line citations in TRANSCRIPTS.md/USAGE-SCORECARD-METRICS.md re-anchored.

Test plan

  • pnpm run check (typecheck + lint + markdown lint + build + full test suite) passes locally
  • New/updated tests: tests/kit/usage-index.test.mjs (root-health ok/absent/degraded incl. ENOTDIR), tests/kit/live-process-sessions.test.mjs (debug flag opt-in/redaction/unwritable-sink), tests/dashboard.test.cjs (grouped-chip fixtures)
  • CI green on this PR

🤖 Generated with Claude Code

…pt-in runtime debug

ADR-0023's sourceHealth field covered only the two secondary/corrective local
sources (OpenCode's SQLite store, Codex's thread ledger) and never the primary
Claude/Codex transcript roots themselves — an unreadable or missing
~/.claude/projects or ~/.codex/sessions still silently read as an ordinary
empty result, the exact failure class ADR-0023 exists to close, just left
open on the two sources every installation actually depends on. Verified the
fix is grounded, not invented: Anthropic documents the Claude transcript path
directly (Data usage page, hooks' transcript_path field); Codex's rollout
directory is real and load-bearing for `codex resume`; the Codex ledger and
OpenCode's db are real but undocumented internals, confirmed only via their
own upstream bug trackers.

Also traced and fixed a related Observability gap: runtime process discovery
had no way to explain "why didn't this controller show up" short of reading
source, and the Usage "by host" panel had drifted from a two-host binary
(claude vs codex) to three supported hosts without adjusting its layout or
labeling.

* Usage source-health parity (ADR-0023 §7)
  - usage-index.mjs: new rootHealth() reports ok/absent/degraded for the
    Claude and Codex transcript roots, with fs error codes (ENOENT, EACCES,
    ENOTDIR) as the bounded reason — same vocabulary already used for
    OpenCode/codexLedger.
  - sourceHealth now carries all four fields: claude, codex, opencode,
    codexLedger.
  - Dashboard renders by HOST, not by field: three chips for three hosts.
    Codex's chip folds its transcript-root and thread-ledger statuses
    together (worse status leads, both sub-statuses stay visible in the
    chip's detail text) instead of appearing as a fourth, confusingly
    "duplicate" Codex entry.
  - Tests: root-health ok/absent/degraded (including an unreadable-root
    ENOTDIR case) in usage-index.test.mjs; updated dashboard.test.cjs
    fixtures/assertions for the new grouping.

* Usage "by host" panel cleanup
  - All three hosts (claude/codex/opencode) always render, grayed out via
    the existing .idle styling when a host has no sessions in the window —
    never hidden based on whether `ak setup --<host>` was ever run. The
    scorecard reflects observed transcript evidence, not inferred setup
    state.
  - Cards now fit one row (.pcard min-width 190px -> 130px) instead of
    wrapping OpenCode onto its own row.
  - Replaced the static, now-inaccurate "claude vs codex" label with a live
    "N active of 3" count.
  - OpenCode gets its own dot color (purple) instead of silently sharing
    Claude's orange.

* Opt-in runtime discovery debug flag
  - process-sessions.mjs: AK_RUNTIME_DEBUG=1 traces the controller-discovery
    pipeline stage by stage (survey row count, per-PID host classification,
    nested-child exclusions, cwd resolution, final result count) to
    $XDG_STATE_HOME/agentic-kit/runtime-debug.log.
  - Mirrors the existing AK_STATUSLINE_DEBUG contract: off by default,
    owner-only 0600, bounded/reset at 64 KiB, diagnostic failures can never
    break discovery. Narrower redaction than the statusline diagnostic by
    necessity: raw argv/command strings are still never logged, but cwd
    paths are, since resolving "why didn't project X show up" is the flag's
    entire purpose and a local directory path isn't a secret.
  - AK_RUNTIME_DEBUG_FILE overrides the log path (test/operator seam).
  - Tests: opt-in gating, stage coverage, argv redaction, owner-only mode,
    and unwritable-sink safety in live-process-sessions.test.mjs.

* Docs
  - ADR-0023: updated §7 (host-grouped chip rationale, grounding citations)
    and §5 (AK_RUNTIME_DEBUG), update note, Consequences, References.
  - USAGE-SCORECARD-METRICS.md, TROUBLESHOOTING.md, adr/README.md synced to
    the four-field/three-chip model and the new debug flag.
  - TRANSCRIPTS.md / USAGE-SCORECARD-METRICS.md: re-anchored file:line
    citations that drifted from the usage-index.mjs edits (verified against
    tests/kit/doc-citations.test.mjs).
@pacphi
pacphi merged commit 30c31f8 into main Aug 6, 2026
11 checks passed
@pacphi
pacphi deleted the feat/usage-source-health-parity-and-runtime-debug branch August 6, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant