Skip to content

feat(tracking,mcp): sigmap budget — session spend ledger + get_budget (F1, v8.23) - #509

Merged
manojmallick merged 1 commit into
developfrom
feat/budget-ledger-508
Jul 28, 2026
Merged

feat(tracking,mcp): sigmap budget — session spend ledger + get_budget (F1, v8.23)#509
manojmallick merged 1 commit into
developfrom
feat/budget-ledger-508

Conversation

@manojmallick

Copy link
Copy Markdown
Owner

Closes #508. First item of plan v8.23 "Agent Economy" — F1.

What

  • src/tracking/budget.jsbudgetStatus(): per-session estimated SigMap-emitted tokens (spent/baseline/saved) from the existing gain log, optional budget (remaining, pct, over-budget flag), context freshness (age + stale vs contextTtlDays).
  • Session identity: SIGMAP_SESSION env override, else UTC day bucket; recordUsage now stamps every entry; legacy entries match day buckets by timestamp prefix.
  • CLI sigmap budget [--json] [--session] [--budget] (memory-command pattern) · MCP get_budget (21st tool) with degrade-gracefully advice at ≥80% budget.
  • Config: sessionBudgetTokens / contextTtlDays, both opt-in null defaults.

Honesty scope (deliberate, per the improvement-plan audit)

This is a SigMap-spend ledger, not a chat budget — a CLI cannot see conversation history or model output. All values are chars/4 estimates and labeled as such in every surface (unit: estimated-tokens). No prompt-cache/injection-TTL claims — context freshness only.

Tests

  • 7 new tests in test/integration/budget.test.js (session stamping, filtering, budget math, TTL staleness, CLI JSON, MCP handler + tool count)
  • Tool-count guards advanced 20→21 in 9 test files + README + mcp.md
  • Full suite: 123 passed, 0 failed (129 files) · supply-chain local audit PASS

🤖 Generated with Claude Code

…ool (closes #508)

v8.23 F1: queryable session spend ledger over the existing gain log.
Scope honesty per the plan audit: counts tokens SigMap emitted (chars/4
estimates, labeled), not the host chat's spend; context freshness age
instead of prompt-cache claims.

- src/tracking/budget.js: sessionKey (SIGMAP_SESSION env or UTC day
  bucket), budgetStatus (per-session spent/baseline/saved, optional
  budget remaining/pct, context age + stale vs contextTtlDays)
- recordUsage stamps session; legacy entries match day buckets by ts
- defaults: sessionBudgetTokens, contextTtlDays (both opt-in, null)
- CLI: sigmap budget [--json] [--session <key>] [--budget <tokens>]
- MCP: get_budget (21st tool) with degrade-gracefully advice near budget
- bundle rebuilt (146 modules); tool-count guards advanced 20→21 across
  9 test files, README, mcp.md; llms regenerated; 7 new tests (129 files)
@manojmallick
manojmallick merged commit 52640ad into develop Jul 28, 2026
5 checks passed
@manojmallick
manojmallick deleted the feat/budget-ledger-508 branch July 28, 2026 19:24
manojmallick added a commit that referenced this pull request Jul 28, 2026
- CHANGELOG 8.23.0 'Agent Economy I': sigmap budget spend ledger +
  get_budget MCP tool (#508, PR #509)
- version sync via sync-versions.mjs; benchmarks re-run — metrics
  unchanged from v8.22 (hit@5 82.2%, honest lift 1.59x, hard split
  33.3% vs grep 53.3%, token reduction 96.8%); benchmark id advanced
  to sigmap-v8.23-main via gen-benchmark-latest + sync-metrics
- docs-vp: cli.md budget section (80 commands), config.md
  sessionBudgetTokens/contextTtlDays rows, mcp.md get_budget row,
  roadmap v8.23.0 entry + stats line fix (82.2%/1.59x/21 tools),
  snapshot labels bumped to v8.23
- docs/index.html softwareVersion 8.23.0; llms regenerated
- suite: 123 passed, 0 failed
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