Skip to content

feat(usage): add one spend ledger and attribute live child spend - #104

Open
ofriw wants to merge 3 commits into
mainfrom
stack/01-spend-ledger
Open

ofriw wants to merge 3 commits into
mainfrom
stack/01-spend-ledger

Conversation

@ofriw

@ofriw ofriw commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Stack: 2/13 · base stack/00-deps · stack #116

Umbrella: #72 (kept as a draft).

Why

One usage reader for the session branch, child ledger, and classifier calls. Spawn flushes child spend live and carries the inherited provider/model identity.

Review focus

Review the spend identity rules and the live flush ordering. The sink must never write to the next run.

Out of scope

Everything above this layer. The next PR carries the dependency.

Tests run

npm run typecheck, npm test (usage, spawn)

@ofriw
ofriw added this pull request to stack #116 October 28, 2026 09:56
@ofriw
ofriw marked this pull request as ready for review October 28, 2026 10:23
Base automatically changed from stack/00-deps to main November 12, 2026 11:22
Resolve 10 conflicts:
- spawn route contract keeps provider/modelId on inherited routes (spend ledger attribution)
- pi floor 1.2.0 + Vitest/eslint/knip toolchain adopted from main
- delete retired test.yml and run-node-test.mjs (modify/delete)
- regenerate package-lock.json; convert usage tests to Vitest
@github-actions

Copy link
Copy Markdown

Unit test coverage

lines statements functions branches
Total 88.75% (3779/4258) 88.87% (3905/4394) 93.48% (761/814) 79.92% (2691/3367)
Base (6e8cd36) 88.65% (3689/4161) 88.78% (3815/4297) 93.34% (743/796) 79.96% (2619/3275)
Change +0.09 +0.09 +0.15 -0.05
Coverage per file (53)
File lines statements functions branches
as-promise.ts 100% (2/2) 100% (2/2) 100% (2/2) 100% (0/0)
frontmatter-cache.ts 95.83% (92/96) 95.83% (92/96) 100% (23/23) 93.91% (108/115)
handoff/boundary.ts 96.42% (135/140) 96.57% (141/146) 100% (23/23) 93.87% (92/98)
handoff/command.ts 100% (16/16) 100% (16/16) 100% (3/3) 95% (19/20)
handoff/copy.ts 100% (16/16) 100% (16/16) 100% (0/0) 100% (0/0)
handoff/eligibility.ts 100% (18/18) 100% (18/18) 100% (5/5) 100% (30/30)
handoff/format.ts 100% (17/17) 100% (17/17) 100% (7/7) 100% (12/12)
handoff/tool.ts 100% (32/32) 100% (32/32) 100% (5/5) 100% (31/31)
index.ts 95.98% (359/374) 96.08% (368/383) 91.93% (57/62) 92.83% (246/265)
model-groups/autocomplete.ts 93.02% (40/43) 92% (46/50) 94.44% (17/18) 76.66% (23/30)
model-groups/availability.ts 100% (2/2) 100% (2/2) 100% (2/2) 100% (2/2)
model-groups/command.ts 78.57% (11/14) 78.57% (11/14) 80% (4/5) 87.5% (7/8)
model-groups/constraints/engine.ts 91.66% (11/12) 92.85% (13/14) 100% (7/7) 87.5% (7/8)
model-groups/constraints/modalities.ts 92.15% (47/51) 92.3% (60/65) 90.24% (37/41) 91.52% (54/59)
model-groups/constraints/presentation.ts 100% (16/16) 100% (16/16) 100% (6/6) 62.5% (5/8)
model-groups/constraints/registry.ts 100% (9/9) 100% (12/12) 100% (4/4) 100% (4/4)
model-groups/constraints/resolution.ts 100% (1/1) 100% (2/2) 100% (2/2) 100% (0/0)
model-groups/constraints/types.ts 0% (0/0) 0% (0/0) 0% (0/0) 0% (0/0)
model-groups/display.ts 98.14% (53/54) 98.18% (54/55) 100% (3/3) 98% (49/50)
model-groups/modalities.ts 100% (7/7) 100% (7/7) 100% (3/3) 100% (0/0)
model-groups/modality.ts 100% (29/29) 100% (30/30) 100% (2/2) 100% (34/34)
model-groups/names.ts 100% (1/1) 100% (1/1) 100% (1/1) 100% (0/0)
model-groups/prompt.ts 100% (7/7) 100% (7/7) 100% (3/3) 83.33% (5/6)
model-groups/router.ts 98.24% (112/114) 98.36% (120/122) 100% (30/30) 92.59% (100/108)
model-groups/store.ts 94.69% (250/264) 94.77% (254/268) 100% (51/51) 90.09% (200/222)
model-groups/tui.ts 90.05% (616/684) 90.2% (645/715) 89.47% (119/133) 80.32% (351/437)
model-groups/types.ts 100% (5/5) 100% (5/5) 100% (1/1) 100% (0/0)
notebook/pager.ts 94.33% (50/53) 94.33% (50/53) 90% (9/10) 85.36% (35/41)
notebook/prompt.ts 100% (12/12) 100% (12/12) 100% (6/6) 85.71% (12/14)
notebook/rehydration.ts 100% (57/57) 100% (58/58) 100% (6/6) 92% (46/50)
notebook/store.ts 96.82% (61/63) 96.96% (64/66) 100% (14/14) 89.47% (34/38)
notebook/tools.ts 96.72% (59/61) 96.72% (59/61) 100% (13/13) 78.43% (40/51)
notebook/topic-tool.ts 100% (9/9) 100% (9/9) 100% (3/3) 100% (8/8)
notebook/topic.ts 100% (14/14) 100% (14/14) 100% (3/3) 100% (6/6)
notifications.ts 100% (44/44) 100% (44/44) 100% (21/21) 100% (2/2)
os-sandbox.ts 80.51% (62/77) 80.76% (63/78) 94.11% (16/17) 84.21% (48/57)
prompt-sections.ts 100% (21/21) 100% (22/22) 100% (6/6) 100% (10/10)
readonly-bash.ts 62.8% (439/699) 62.98% (451/716) 76.47% (52/68) 53.5% (359/671)
readonly-boundary.ts 94.73% (18/19) 94.73% (18/19) 100% (4/4) 86.66% (13/15)
readonly-rehydration.ts 100% (12/12) 100% (13/13) 100% (1/1) 100% (10/10)
resolve-path.ts 88.88% (8/9) 88.88% (8/9) 100% (1/1) 50% (1/2)
runtime-singletons.ts 100% (9/9) 100% (9/9) 80% (4/5) 100% (4/4)
spawn/index.ts 97.15% (239/246) 97.27% (250/257) 100% (51/51) 91.04% (183/201)
spawn/renderer.ts 89.34% (503/563) 89.35% (512/573) 91.66% (77/84) 74.05% (334/451)
spawn/shared.ts 100% (13/13) 100% (14/14) 100% (2/2) 100% (8/8)
state.ts 96.55% (56/58) 96.55% (56/58) 83.33% (10/12) 100% (2/2)
system-prompt.ts 100% (3/3) 100% (5/5) 100% (4/4) 100% (0/0)
temp-dir.ts 80% (4/5) 80% (4/5) 100% (1/1) 100% (0/0)
thinking-levels.ts 100% (2/2) 100% (2/2) 100% (1/1) 100% (0/0)
time/format.ts 93.33% (28/30) 93.54% (29/31) 100% (10/10) 80% (12/15)
tui.ts 100% (25/25) 100% (25/25) 100% (1/1) 92.85% (26/28)
usage.ts 96.29% (78/81) 96.29% (78/81) 100% (16/16) 81.25% (65/80)
watchdog.ts 100% (49/49) 100% (49/49) 100% (12/12) 96.42% (54/56)

Commit 4054a07, attempt 1 of the workflow run; the HTML report is in that attempt's coverage artifact.

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