Skip to content

Fix claude-code usage-ingestion freeze (Workflow "failed" rows) + add Weekly plan receipt row - #169

Merged
mikehasa merged 2 commits into
mainfrom
fix/journal-failed-and-weekly-row
Aug 28, 2026
Merged

Fix claude-code usage-ingestion freeze (Workflow "failed" rows) + add Weekly plan receipt row#169
mikehasa merged 2 commits into
mainfrom
fix/journal-failed-and-weekly-row

Conversation

@mikehasa

Copy link
Copy Markdown
Owner

Two independent fixes surfaced while dogfooding the app.

1. Fix: claude-code usage ingestion frozen by Workflow "failed" journal rows

The Claude Code Workflow tool writes a metadata journal at
<project>/<root>/subagents/workflows/wf_*/journal.jsonl. It now emits a third
row type — {"type":"failed","agentId":...,"key":...} — when a workflow agent
dies. The metadata-only validator (_validate_claude_workflow_journal)
recognized only started/result, so a failed row raised
claude_workflow_journal_schema_drift.

That validation runs before any transcript is parsed and fails closed for the
whole home, so a single unrecognized journal row aborted the entire claude-code
usage scan. Effect: usage/cost ingestion stopped (parsed=0, consecutive
failures climbing) while already-stored sessions kept rendering — the source
showed "degraded / 1 error" with no visible loss of sessions.

Fix: accept failed as a known no-usage lifecycle row. Keys stay exact-set, so
a journal row carrying token usage still fails closed (the safety guard is
unchanged). Regression test added.

2. Feature: a dedicated "Weekly plan" receipt row

The Task's calibrated share of its client's weekly plan already rides the
receipt as dimensions.cost.plan_share, but was shown only as a suffix on the
macOS Cost line and not at all on the CLI/TUI. Promote it to its own "Weekly
plan" row across the macOS app, CLI and TUI (the API payload already carries
it). No calibration or computation changed.

Wording is single-sourced (receipt.plan_share_headline /
ReceiptPlanShare.rowSummary) and stays calibrated-or-nothing: a percentage
only once calibrated, otherwise a named calibration state, never a fabricated
number. The now-duplicate share suffix is dropped from the macOS Cost row and
cost KPI tile.

Tests

  • pytest full suite: 2658 passed.
  • swift test (macOS app): 164 passed.
  • Added: workflow-journal failed-row acceptance; plan_share_headline state
    coverage; "Weekly plan" row assertions in the CLI/TUI renderer tests.

The Claude Code Workflow tool records a per-agent lifecycle journal at
<project>/<root>/subagents/workflows/wf_*/journal.jsonl. It now emits a third
row type, {"type":"failed","agentId":...,"key":...}, when a workflow agent
dies. The metadata-only validator recognized only "started" and "result", so a
"failed" row raised claude_workflow_journal_schema_drift.

That validation runs before any transcript is parsed and fails closed for the
whole home, so one unrecognized journal row aborted the entire claude-code
usage scan -- freezing usage/cost ingestion while already-stored sessions kept
rendering.

Accept "failed" as a known no-usage lifecycle row (keys stay exact-set, so a
row carrying usage still fails closed). Add a regression test.
The Task's calibrated share of its client's weekly plan already rides the
receipt as dimensions.cost.plan_share, but was shown only as a suffix on the
Cost line (macOS) and not at all on the CLI/TUI. Promote it to its own
"Weekly plan" row across the macOS app, CLI and TUI (the API already carries
it).

Wording is single-sourced (receipt.plan_share_headline / ReceiptPlanShare
.rowSummary) and stays calibrated-or-nothing: a percentage only once
calibrated, otherwise a named calibration state, never a fabricated number.
Drop the now-duplicate share suffix from the macOS Cost row and cost KPI tile.
@mikehasa
mikehasa merged commit 8bb84c3 into main Aug 28, 2026
4 checks passed
@mikehasa
mikehasa deleted the fix/journal-failed-and-weekly-row branch August 28, 2026 17:04
@mikehasa mikehasa mentioned this pull request Aug 28, 2026
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