recall: content_hash truncates SHA-256 to 48 bits and ON CONFLICT overwrites on collision
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 81.1k
- Forks
- 5.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 35
Description
content_hash() truncates SHA-256 to 12 hex characters (48 bits) and the store uses ON CONFLICT to overwrite, so two different outputs that collide silently overwrite one another - the older entry is gone and its hash now resolves to unrelated content.
At the default max_entries = 200 the birthday probability is around 1e-10, so this is a low-severity robustness note rather than a live bug. Widening the prefix (16 hex is 64 bits) or treating a conflict with differing content as an insert rather than a replace would remove the class.
Surfaced during review of #3278; the truncation is pre-existing behaviour in that PR's design.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the content_hash() implementation and the store code that uses ON CONFLICT, then read the surrounding handling of cached entries and the design discussed in #3278. Determine the intended collision behavior before changing it; done means differing content cannot silently replace an existing entry and the behavior is covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100