Repository navigation
fix(accounting): refuse oversized savings ledger token counts - #4727
Closed
ScriptedAlchemy wants to merge 1 commit into
Closed
ScriptedAlchemy wants to merge 1 commit into
ScriptedAlchemy wants to merge 1 commit into
Conversation
Reject unrepresentable before/after token counts before inserting into SQLite's signed INTEGER columns. Preserve exact stored savings evidence. Cover invalid boundaries and the largest representable count. Refs #4447
|
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
This was referenced Nov 3, 2026
Owner
Author
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.
Root cause
Refs #4447 (partial accounting correctness).
The registered savings-ledger recorder accepts unsigned
before_tokensandafter_tokens, but persisted them withas i64. SQLite INTEGER columns are signed. A validu64exceedingi64::MAXbecame a negative persisted count, corrupting ledger evidence and downstream savings history. The adjacent project-total projection already uses checked conversion; the ledger did not.Change
i64values in the existing registered, transactional savings-ledger insert. No schema, identity, authorization, scheduling, or policy changes.before, oversizedafter, maximumu64, zero writes after refusals, and successful round-trip of the largest representable count.Validation
Reviewed the exact two-file commit diff against
masterat32afec6f67644f4c9a9e777f757709557367b23a; no other files changed. Verified via a native Python/SQLite mechanism probe that the former lossy signed cast persists2^63as-2^63. This probe is not a Rust test pass.Not run: Rust compilation, rustfmt, Bazel or new Rust regression: this execution has no TraceDecay checkout, Bazel or Rust formatting toolchain. Hosted CI should execute
//crates/tracedecay-global-db:unit_teston this isolated branch before merge.Remaining issue scope
This prevents one ledger data-corruption path, but does not complete #4447. Durable per-response deduplication, reset-epoch semantics for queued responses, and full MCP accounting lifecycle validation remain. The earlier project-total consolidation has already landed in #4698. Keep #4447 open. CI repair/merge belongs to the existing PR automation.