Labels
No labels
P0
P1
P2
P3
bug
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#590
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Reviewing
pipeline.dbdispatches/token accounting during responsibility-refactor batch 5, 2026-09-15.Observed
dispatches.input_tokens/output_tokens/cache_read_tokens/cache_creation_tokensare all 0 for implementations tied to #583, #565, #566, and #572-#574. Rows for #584 and #585 carry populated token values. No orchestrator-role dispatch row exists, so main-loop token usage is never recorded at all.Reproduce
Expected
Every dispatch row carries usage figures. Consider adding an orchestrator-role dispatch row so main-loop token usage is captured alongside subagent dispatches.
Origin
Investigation 2026-09-15: NULL, not 0, and the cause is timing
The token columns on the affected rows are NULL. The report renders NULL as 0.
Usage is read lazily from
agents.transcript_pathbyDispatch#record_usage!(runner/dispatch.rb:43), and only whenos-sdlc-runner implementation-reportruns. A missing transcript file returns nil and leaves the row NULL. The transcript directories for every affected worktree are gone. Rows written before a by-hand report call have usage; rows after it do not. No format problem exists.Lazy reading is correct and must stay (ADR-0175). Measured on 12 dispatches from #594 and #595: the final assistant turn, the one carrying
message.usage, lands 9 to 39 seconds afterdispatches.completed_at, because an agent settles its own dispatch and then keeps writing.Slice
Sweep NULL usage at the next subagent start, so every dispatch except the last is stamped while its transcript still exists. Add a catch-all for the last dispatch at worktree finish.
Owner sketch
Change 1, sweep at subagent start.
DispatchCommands.subagent_start(runner/dispatch_commands.rb:28) runs in the SubagentStart hook of the next agent. Every earlier agent on the implementation has returned, so their transcripts are complete.record_usage!already returns nil on a missing file, so a row that cannot be read stays NULL and is retried on the next start. Inline, not a side process: one JSON Lines scan per row, milliseconds, and a failure is visible in the hook output instead of lost in a fork.Change 2, catch-all at worktree finish.
plugins/os/lib/worktree_cli_finish.rb:163removes the worktree. The os plugin cannot require os-sdlc (ADR-0157, ADR-0174). Guarded shell-out before removal:--sweep-onlystamps usage and prints nothing. Record the coupling in an ADR that amends ADR-0157.The existing report call on a terminal payload stays as written in the implement skill.
Cases
.sdlc/pipeline.dbpresent: NULL rows with existing transcripts are stamped beforegit worktree remove..sdlc/pipeline.db: no shell-out, finish unchanged.implementation-report --sweep-only: stamps, prints nothing, exit 0.Acceptance criteria
Non-goals
completed_atis written.~/.claude/projects/<worktree-slug>. Unknown, out of scope.Resolution
Done: NULL (not 0) token columns fixed: StartSubagent sweeps earlier dispatches' missing usage before inserting the new row; implementation-report --sweep-only IMPLEMENTATION_ID stamps one implementation silently; worktree finish --implementation ID runs the sweep before git worktree remove. Lazy read kept per ADR-0175 (usage-bearing turn lands 9-39 s after completed_at).
Evidence: commit
88cd513merged98a4f40on main 2026-09-15; os-sdlc suite 1220 runs 0 failures; os suite 22 runs 0 failures; plan and investigation in the 2026-09-15 comment on this ticketFollow-ups: #598 main-loop token usage (split, filed); affected rows are unrecoverable, transcripts gone; cause of ~/.claude/projects/ deletion unknown, no ticket by user decision