Fix claude-code usage-ingestion freeze (Workflow "failed" rows) + add Weekly plan receipt row - #169
Merged
Merged
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thirdrow type —
{"type":"failed","agentId":...,"key":...}— when a workflow agentdies. The metadata-only validator (
_validate_claude_workflow_journal)recognized only
started/result, so afailedrow raisedclaude_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, consecutivefailures climbing) while already-stored sessions kept rendering — the source
showed "degraded / 1 error" with no visible loss of sessions.
Fix: accept
failedas a known no-usage lifecycle row. Keys stay exact-set, soa 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 themacOS 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 percentageonly 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
pytestfull suite: 2658 passed.swift test(macOS app): 164 passed.failed-row acceptance;plan_share_headlinestatecoverage; "Weekly plan" row assertions in the CLI/TUI renderer tests.