feat(tracking,mcp): sigmap budget — session spend ledger + get_budget (F1, v8.23) - #509
Merged
Merged
Conversation
…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
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
2 tasks
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.
Closes #508. First item of plan v8.23 "Agent Economy" — F1.
What
src/tracking/budget.js—budgetStatus(): 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 vscontextTtlDays).SIGMAP_SESSIONenv override, else UTC day bucket;recordUsagenow stamps every entry; legacy entries match day buckets by timestamp prefix.sigmap budget [--json] [--session] [--budget](memory-command pattern) · MCPget_budget(21st tool) with degrade-gracefully advice at ≥80% budget.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
test/integration/budget.test.js(session stamping, filtering, budget math, TTL staleness, CLI JSON, MCP handler + tool count)🤖 Generated with Claude Code