Repository navigation
perf(check): borrow key and facts when writing the file-fact cache entry (#11205) - #11643
Conversation
…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
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
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. View limit details
|
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
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.
Governing issue or accepted claim: #11205
Acceptance delta (one sentence): Cold
ripr checkfile-fact cache writes no longer deep-clone each file'sFileFactsand cache key before encoding, with entry bytes and integrity digest unchanged.Change
RepoFileFactCache::store_file_factsbuilt an ownedFileFactCacheEnvelope::new(key.clone(), facts.clone()), deep-cloning every parsedFileFactsper cold write, only to serialize it (once for the digest, once for the entry). It now uses a borrowingFileFactCacheEnvelopeRefwith identical field names/order, the omittedpayload_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_digestalready streams into SHA-256 andFileFactsserialization 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).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
real_file_facts_keep_original_cache_bytes_and_integritynow asserts the borrowed path's digest and encoded bytes equal the owned envelope's (and the independentto_vec/pretty oracle). Newstore_file_facts_writes_the_owned_envelope_bytesasserts the entry on disk equals the owned envelope's encoding.content_hash/file_pathfield order in the borrowed envelope fails both tests; restored.cmpofcheck --jsonbetween main and this build on cold tokio: identical for--base HEAD~1and--base HEAD~10.cargo xtask precommitexit 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