Skip to content

fix: case registry locking, watchdog proof verification, viewer matching, export paths - #125

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-issues-757b
Draft

fix: case registry locking, watchdog proof verification, viewer matching, export paths#125
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-issues-757b

Conversation

@cursor

@cursor cursor Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Nightly critical-correctness scan identified four high-severity bugs in recent litigation/executive/portal code paths.

Bugs fixed

1. Duplicate Case Nos under concurrency (litigation/run.py)

  • Impact: Concurrent transcript saves could corrupt case-registry.yaml and assign duplicate Case Nos.
  • Root cause: allocate_case_no read/wrote the registry without file locking; missing registry returned a hardcoded case number without persisting state; no year rollover reset.
  • Fix: Exclusive fcntl lock, create registry on first use, reset per-category counters on calendar year change, atomic write with fsync.

2. Watchdog override bypass (executive/watchdog.py)

  • Impact: Any non-empty override_proof string bypassed judicial approval checks — forged overrides were accepted.
  • Root cause: Watchdog only checked proof presence, never verified HMAC via OverrideProof.verify().
  • Fix: Require and cryptographically verify override proofs; alert on missing/invalid proofs.

3. Wrong transcript served (litigation/viewer.py)

  • Impact: Substring matching (name in stem) could serve the wrong transcript (e.g. query bar matching foo-bar).
  • Fix: Exact/prefix/suffix matching via _resolve_transcript().

4. Export path double-prefix (courtroom/portal/export_transcript.py)

  • Impact: Paths like courtroom/transcripts/foo.md resolved to nonexistent courtroom/courtroom/transcripts/foo.md.
  • Fix: resolve_transcript_path() strips redundant courtroom/ prefix.

Validation

  • 69 tests passing (including new regression tests for all four fixes)
  • Concurrent case-number allocation test confirms uniqueness under 8-thread load
Open in Web View Automation 

…ing, export paths

- allocate_case_no: create registry when missing, exclusive fcntl lock, fsync,
  and year rollover reset to prevent duplicate Case Nos under concurrent saves
- watchdog: require OverrideProof.verify() for override actions instead of
  skipping checks when action_type contains override or proof is non-empty
- litigation viewer: resolve transcripts by exact/prefix/suffix rules, not
  arbitrary substring match (bar must not match foo-bar)
- export_transcript: resolve_transcript_path strips courtroom/ prefix so
  repo-root paths do not double-prefix to courtroom/courtroom/transcripts

Co-authored-by: Jack J Burleson // LJM <Exios66@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant