feat: git locks doctor, a read-only invariant check of the store (0.5.0) - #29
Merged
Merged
Conversation
One finding line per broken invariant as it is found, then one doctor line with the store, the reading basis (refs and records in the one snapshot, and the clock), the checks run, the count and the verdict. Invariants: every job record decodes and names its own job; every path a record lists has a path ref at that record; every path ref points at a record some job ref points at, and that record lists the path; every child's parent exists, is live and has the same holder, and no parent chain cycles; every semaphore has meta and gen, its records decode, and its live slots fit its capacity. Exit 0 healthy, 1 with findings, 2 when the store cannot be read, which is never reported healthy. Paths are hashed in one hash-object process, so the process count does not grow with the store. Nothing is repaired. Version 0.5.0. Also: field_v and json_paths_v no longer declare locals a caller could name (a local named rest swallowed the caller's rest, the same trap CONTRIBUTING already records for write_blob). Closes #19
Takes the review follow-ups (fields keyed by record and name, decimal ttl, sweep guard, with traps) under the doctor. The snapshot module conflict resolves to the keyed-fields version; the test suite keeps both appended sections.
|
Warning Review limit reachedNext included review available in 20 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (9)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Roadmap item 3 (#19).
git locks doctorreads one snapshot and checks it, writing nothing. Onefindingline per broken invariant as it is found, then onedoctorline with the store, the reading basis (refs and records in that snapshot, and the clock), the checks run, the count and the verdict. Exit 0 healthy, 1 with findings, 2 when the store cannot be read, which is never reported healthy.The invariants, each with a test that corrupts a store by hand (direct
update-refandhash-object -won the store) and counts the finding:record-decodes) and names its own job (job-ref-name)path-ref-missing,path-ref-elsewhere)path-ref-orphan), and that record lists the path (path-ref-stray)parent-missing), is live (parent-expired) and has the same holder (parent-holder); no parent chain cycles (family-cycle)metaandgen(sem-meta,sem-gen), its records decode (sem-record), and its live slots fit its capacity (sem-capacity)unknown-ref)Paths are hashed in one
hash-objectprocess (each path becomes a temp file, one call hashes them all with--no-filters, the same bytespath_refhashes from stdin), so the suite asserts the git process count is the same for 3 locks and 33. An unreadable store exits 2 with astore-readerror and no doctor line. Findings come in ref order, so output is stable.Schema:
finding_lineanddoctor_lineadded; every line the tests provoke validates. README: a commands row and a contract paragraph ("What the invariants are, and how to see them hold"). Repair is deliberately not a mode of this command.Also fixes a shadowing bug found on the way:
field_vandjson_paths_vdeclared locals a caller could name (rest,line), the same trap CONTRIBUTING records forwrite_blob.Version 0.5.0. 366 checks green, lint clean. Branched from #28 so the diff against main is the doctor only.
Closes #19