Fix cumulative tokens for resumed workflow runs - #2353
Conversation
Resumed DAG runs discarded token usage from earlier failed executions because resume hydration restored only node outputs. Changes: - Restore cumulative token usage from completed-node events - Seed resumed DAG token counters with prior usage - Add reconciliation and malformed-event regression coverage Fixes #2352
Fixed:\n- Log malformed persisted gate token metadata with run and node context\n- Avoid warnings for absent optional historical token usage\n- Cover resume snapshot hydration into DAG execution\n\nTests added:\n- Gate-token fallback, missing token usage, and resume hydration coverage\n\nSkipped:\n- None
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⚡ Self-Fix Report (Aggressive)Status: COMPLETE Fixes Applied (3 total)
View all fixes
Tests Added
Skipped (0)(none — all findings addressed) Suggested Follow-up Issues(none) Validation✅ Type check | ✅ Lint | ✅ Tests ( Self-fix by Archon · aggressive mode · fixes pushed to |
Summary
workflow:nodes must report total provider usage for the complete workflow-run ID.node_completedevents, then seeds the existing DAG accumulator before the terminal completion write.UX Journey
Before
After
Architecture Diagram
Before
After
Connection inventory (list every module-to-module edge, mark changes):
node_completedrows only.Label Snapshot
risk: mediumsize: Mcore, workflows, testsworkflows:resume-accountingChange Metadata
bugmultiLinked Issue
Validation Evidence (required)
Commands and result summary:
bun run type-check bun run lint bun run format:check bun run test bun run validatebun run validatepassing after bundled-default regeneration. Focused coverage included DAG executor (441), executor (69), sub-run (12), workflow-event DB (19), and store-adapter (13) tests..archon/bundled-default drift; the later validation record refreshed the local generated bundle and reports the complete suite passed. Those local workflow-definition/generated-file edits are intentionally not part of this PR.Security Impact (required)
No)No)No; provider-usage accounting only, not credential handling)No)Yes, describe risk and mitigation: not applicable.Compatibility / Migration
Yes)No)No)Human Verification (required)
What was personally validated beyond CI:
node_skipped_prior_successrows do not double-count usage; outputs still restore during resume.Side Effects / Blast Radius (required)
Rollback Plan (required)
8d3bbfbc87e6456f716ec7cb2b204a42d7521df4after merge.node_completedevents.Risks and Mitigations
node_completedevents contribute usage;node_skipped_prior_successevents restore outputs without contributing tokens.Fixes #2352