Repository navigation
fix(storage): compact retained history and reclaim orphan bodies - #4718
Closed
ScriptedAlchemy wants to merge 4 commits into
Closed
ScriptedAlchemy wants to merge 4 commits into
ScriptedAlchemy wants to merge 4 commits into
Conversation
|
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.
Summary
TD could store the same tool result in both replay metadata and its compressed canonical body, retain unreferenced canonical bodies, and move compactable history into uncompressed files. Metadata-only updates also rewrote the search index, while bounded incremental vacuum reclaimed only one page regardless of its requested budget.
This change removes those sources of storage and write amplification through the existing ingestion, registered-store retention, and authorized writer paths.
Changes
Keep one recoverable copy of tool evidence
contentonly when it is a plain string exactly equal to the canonical raw body. The existing verified reader reconstructs it for replay. Structured content, media and external-payload placeholders retain their current behavior.Compress retained history without creating new payload files
retention_offloadfiles return to ordinary inline storage. Larger qualifying files use the existing compressed canonical-body representation when that representation is smaller.Reduce background work and make reclamation accurate
Dependency integration
Includes #4721 through its commit ancestry. Grafeo's allocation APIs are maintained directly in the fork's main branch, pinned by the lockfile to
5116be3c; the local Bazel patch is removed. There is no transitive dependency churn.The replay-token-accounting changes in #4712 and Hermes integration changes in #4711 remain independent.
Regression coverage
Added or extended regressions cover exact replay recovery, Unicode and representation-cost boundaries, canonical sharing and corruption, owner-aware GC bootstrap and races, cursor/budget continuation, stale candidates, receipt/authority failures and transaction rollback. Additional cases cover unchanged summary convergence during verified restoration, ordinary subsequent invalidation, FTS content/NULL/row-ID updates, populated incremental vacuum and rollback, and continuation without raw-drop work.
Validation
Passed:
CARGO_BUILD_JOBS=1 cargo check --profile bounded-test -p tracedecay-lcm --lib --tests --locked.CARGO_BUILD_JOBS=1 cargo check --profile bounded-test -p tracedecay-global-db --lib --tests --locked.CARGO_BUILD_JOBS=1 cargo check --profile bounded-test -p tracedecay-maintenance --lib --tests --locked.CARGO_BUILD_JOBS=1 cargo check --profile bounded-test -p tracedecay-rusqlite-runtime --lib --tests --locked.git diff --checkon the storage changes.Passed:
CARGO_BUILD_JOBS=1 cargo check --profile bounded-test -p tracedecay --no-default-features --lib --locked. This validates the daemon library wiring in the minimal feature configuration. Full production-feature builds and daemon runtime tests remain outside this check.Two test-only integer inference/decoding issues found during the compiler gates were corrected, and the affected global-db and writer gates passed on rerun.
The new Rust runtime regressions have not executed. Test-binary code generation for the large
asupersyncdependency was killed by the 8 GiB environment limit in prior bounded attempts, including a serialized run. Compiler checks and direct SQLite probes are reported separately and are not Rust runtime-suite passes. Bazel was not run, per the requested Cargo validation workflow.Rollout and limits
This PR remains draft until the new Rust runtime regressions can execute on a runner with enough memory. The code has not been deployed and no operator history or live database was modified.
Generic media/tool-payload encodings are unchanged. Restoration itself does not claim reclaimed disk bytes: old files await existing GC ownership checks and grace; physical database shrink depends on later checkpoint/compaction work. Production before/after disk savings have not been measured.
Implemented and reviewed with GPT-6 Astra Pro in ChatGPT.