Skip to content

perf(check): borrow key and facts when writing the file-fact cache entry (#11205) - #11643

Merged
EffortlessSteven merged 1 commit into
mainfrom
claude/perf-fact-write
Oct 31, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
claude/perf-fact-write

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Governing issue or accepted claim: #11205
Acceptance delta (one sentence): Cold ripr check file-fact cache writes no longer deep-clone each file's FileFacts and cache key before encoding, with entry bytes and integrity digest unchanged.

Change

RepoFileFactCache::store_file_facts built an owned FileFactCacheEnvelope::new(key.clone(), facts.clone()), deep-cloning every parsed FileFacts per cold write, only to serialize it (once for the digest, once for the entry). It now uses a borrowing FileFactCacheEnvelopeRef with identical field names/order, the omitted payload_digest, and the same digest domain (ripr-cache:FileFactCacheEnvelope:v1). The owned envelope remains for decode/validate and tests. Digest definition, schema, cache keys and the integrity contract are untouched.

Investigated and not cuttable without touching the contract: the digest pass and the entry pass serialize different bytes (compact vs pretty), so they cannot share one serialization; semantic_body_digest already streams into SHA-256 and FileFacts serialization is already borrowed.

Profile

tokio depth-30 clone, cold ripr check --base HEAD~1 --json, release (stripped, so per-function callgrind symbols are unavailable on this build; totals only).

Ir
before (main 7aa158b) 30,410,726,136
after 30,248,209,150
delta -162,516,986 (-0.53%)

The issue's inclusive shares (store_file_facts ~6.9%, serialize ~6.1%, expected_digest ~4.7%) are dominated by serialization/hashing that must keep identical bytes; the clone was the only avoidable part found.

Proof

  • Differential: real_file_facts_keep_original_cache_bytes_and_integrity now asserts the borrowed path's digest and encoded bytes equal the owned envelope's (and the independent to_vec/pretty oracle). New store_file_facts_writes_the_owned_envelope_bytes asserts the entry on disk equals the owned envelope's encoding.
  • Mutation check: swapping content_hash/file_path field order in the borrowed envelope fails both tests; restored.
  • cmp of check --json between main and this build on cold tokio: identical for --base HEAD~1 and --base HEAD~10.
  • cargo xtask precommit exit 0.

Not verified: byte-for-byte comparison of whole cache directories across the two binaries (the analyzer identity is a binary hash, so entries legitimately differ between builds); covered instead by the unit differential.


Generated by Claude Code

…try (#11205)

The cold write cloned the whole FileFacts and four key strings into an
owned envelope only to serialize it twice. A borrowing envelope with the
same field order and digest domain writes identical bytes and digest.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019WPmWp4vdysYyymwvPKycS
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 148 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: aa73d525-1cbb-4184-8bfc-84a3fb50bc7f
Commits

Reviewing files that changed from the base of the PR and between 0998076 and 2fab5c2.

Files selected for processing: 3
  • changelog.d/11205-fact-write-no-clone.md
  • crates/ripr/src/analysis/seam_cache.rs
  • crates/ripr/src/analysis/seam_cache/digest_tests.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 31, 2026 13:43
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision

  • Needs verification checks before upstream.

Verification questions

  • Confirm no test corrupts the borrowed payload and proves digest validation fails, so the complete integrity contract is not red/green distinguished by the new path.
  • Confirm a sibling scan of all FileFactCacheEnvelope construction and encoding call sites is not present in the supplied evidence.
  • Confirm the borrowed and owned envelopes are compared for exact bytes and digest, but the new disk test does not independently validate the actual stored integrity digest.

Refuted

  • The owned envelope should have been replaced entirely by the borrowing helper to avoid duplicated structure.; refuted because: That would unnecessarily widen the change into decoding/validation and test APIs; the current twin is limited to the write-side serialization boundary and is guarded by differential tests.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • The planned ripr sensor failed with exit code 2, leaving route-level trust dependent on the late cargo-test receipt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants