Skip to content

fix: CLI JSON safety and Windows vector race condition (#981 #982) - #984

Merged
ajianaz merged 1 commit into
developfrom
fix/p7-cli-json-vector-race
Aug 10, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/p7-cli-json-vector-race

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

What

Closes the last 2 remaining issues from cora re-scan: manual JSON construction and Windows cross-process race condition.

Why

Issues #981 and #982 were deferred in PR #983 as lower priority. This PR closes them out — completing all 10 issues from the cora scan audit.

Changes

#981 — CLI manual JSON construction

  • doc.rs: 2 locations replaced format!() string interpolation with serde_json::json!() for document create and delete JSON output
  • mod.rs: 3 locations replaced manual println!("{{...}}") with serde_json::json!() for pin, unpin, and importance JSON output
  • Prevents corrupted JSON output when slugs/ids contain quotes, backslashes, or other special characters

#982 — Windows vector race condition

  • Replaced unlock-rename-relock pattern with retry-based rename using exponential backoff (10ms → 640ms, ~7 retries)
  • After successful rename, reopens and re-locks the file to refresh the handle
  • Eliminates the race window where another process could access the partially-written file between unlock and rename

Testing

  • cargo fmt --all pass
  • cargo clippy --workspace --all-targets — 0 warnings
  • cargo test --workspace — 476 passed, 0 failed
  • Pre-commit: fmt + clippy + cora review all passed

- Replace 5 manual format!() JSON constructions with serde_json::json!()
  in doc.rs (2) and mod.rs (3) — prevents corrupted output when
  slugs/ids contain quotes or backslashes (#981)
- Replace unlock-rename-relock pattern in Windows save() with retry-
  based rename using exponential backoff — eliminates race window
  where another process could access the partially-written file (#982)
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 1f90a0d into develop Aug 10, 2026
13 checks passed
@ajianaz
ajianaz deleted the fix/p7-cli-json-vector-race branch August 10, 2026 02:40
ajianaz added a commit that referenced this pull request Aug 13, 2026
)

- Replace 5 manual format!() JSON constructions with serde_json::json!()
  in doc.rs (2) and mod.rs (3) — prevents corrupted output when
  slugs/ids contain quotes or backslashes (#981)
- Replace unlock-rename-relock pattern in Windows save() with retry-
  based rename using exponential backoff — eliminates race window
  where another process could access the partially-written file (#982)

Co-authored-by: ajianaz <[email protected]>
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