fix: case registry duplicate Case Nos and override proof bypass - #104
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix: case registry duplicate Case Nos and override proof bypass#104cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
- allocate_case_no: create registry when missing instead of returning a fixed DEL-001; add fcntl exclusive lock and fsync to prevent duplicate Case Nos under concurrent transcript saves; reset counters on year rollover - watchdog: require OverrideProof.verify() for override actions instead of accepting any non-empty proof string or action_type containing 'override' - Add regression tests for missing registry, concurrency, year rollover, invalid override proofs Co-authored-by: Jack J Burleson // LJM <Exios66@users.noreply.github.com>
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
Fixes two critical correctness bugs found in recent litigation/executive changes.
Bug 1: Duplicate / stale Case Nos (
litigation/run.py)Impact: Every transcript saved without an existing
courtroom/case-registry.yamlreceived the same Case No (YYYY-DEL-001-001). Concurrent saves could also corrupt the registry or assign duplicate numbers via unlocked read-modify-write.Root cause:
allocate_case_no()returned a hardcoded number when the registry was missing and wrote updates without file locking.Fix: Create the registry on first use, use
fcntlexclusive locking withfsync, and reset per-category counters on calendar year rollover.Bug 2: Executive override auth bypass (
executive/watchdog.py)Impact: Override actions bypassed judicial approval checks if
action_typecontained"override"or any non-emptyoverride_proofwas present — no HMAC verification was performed. An attacker could log rogue overrides with a fake proof string.Root cause: Watchdog only checked for presence of proof, never called
OverrideProof.verify().Fix: Override actions now require a valid HMAC proof; unapproved non-override actions still alert as before.
Validation
python3 -m pytest tests/— 66 passed