Skip to content

fix(lock): retain exact bigint identities for cleanup - #719

Merged
steipete merged 3 commits into
mainfrom
codex/fix-sidecar-bigint-identity-20260927
Sep 27, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/fix-sidecar-bigint-identity-20260927

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Failed raw sidecar acquisition could retain rounded numeric device/inode IDs and later treat a different file as its own during no-token cleanup. Capture bigint stats throughout async/sync acquisition, snapshot matching, Root snapshot capture, and exit cleanup. Reject unsafe numeric IDs in the shared cleanup comparator so older in-process receipts cannot authorize deletion. Token ownership and unknown-Windows-identity safeguards remain intact.

Synthetic regressions use distinct IDs above 2^53 that round to the same JavaScript number. They prove that failed async/sync acquisition preserves the successor, closes both descriptors, and retains the original error, for both device and inode collisions. All six collision tests fail against the baseline and pass with the fix. Additional large-ID Root stale-reclaim tests prove that unchanged locks remain reclaimable.

The requested sameFileIdentityForCleanup / .ino audit also found numeric directory comparisons in file-store pruning; those observations now use bigint, with a regression preserving a directory changed during listing. Expiry-only metadata stays numeric where fractional milliseconds matter. Other cleanup/deletion families already obtain bigint stats: creation, publication, temporary files/workspaces, moves, native operations, queues, Root removal, and case/suffix probes. Remaining numeric fast paths in Root removal and temporary-workspace/stat admission validate safe integers against exact identities or obtain bigint observations; directory receipts retain private exact provenance, and numeric public metadata is not deletion authority. Unsafe legacy inputs additionally fail closed in the shared comparator.

Validation at 3e99f29953f621f29ed8ed0175bc2741db39b823:

  • Hosted CI and coverage passed, including Linux, macOS, and Windows.
  • Final focused suites: 236 tests passed across eight files. Earlier broader lock suites passed 964 tests (17 skips).
  • Build, file-size/boundary lint, documentation examples, package checks, and Codex autoreview through P2 passed. The local full check hit three timeouts in unchanged watch/recursive-remove stress tests; their isolated rerun passed (45 tests, 17 skips). Hosted full checks passed.

The first CI run caught two follow-ups addressed here: native creation bypassed the raw test's injected fs.open failure, and synchronous Root disk snapshots still supplied numeric stats to comparison on large-ID Windows filesystems. The fixture now explicitly selects the raw implementation; Root snapshots now retain bigint metadata too. A legacy success fixture uses exact stats, consistent with the new rejection of unsafe numeric receipts.

No changelog edits. Leave unmerged for the 0.21.1 decision.

@steipete
steipete requested a review from a team as a code owner September 27, 2026 03:44
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 27, 2026, 12:58 AM ET / 04:58 UTC (Revision 4).

ClawSweeper review

What this changes

The branch captures bigint file identities for sidecar lock cleanup and FileStore pruning, adds collision regressions, and documents rejection of unsafe legacy receipts.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open. Current main and v0.21.0 still have the lossy lock cleanup path, and this PR is a distinct safety repair. The mixed-version cleanup effect and release timing need a maintainer decision.

Priority: P2
Reviewed head: 37c271f09a4f1ccb96254a81f3b8a5d4f0688ec5
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch and production-path filesystem evidence provide good signal, with release documentation and mixed-version coverage still outstanding.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The linked hosted run at the prior head exercised production async and sync lock acquisition on real temporary files with injected colliding identities: the successor remained, descriptors closed, and unchanged Root locks were reclaimed. The relevant source and test blobs are identical at this head; shared-manager legacy-receipt coverage remains an upgrade-risk gap. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The linked hosted run at the prior head exercised production async and sync lock acquisition on real temporary files with injected colliding identities: the successor remained, descriptors closed, and unchanged Root locks were reclaimed. The relevant source and test blobs are identical at this head; shared-manager legacy-receipt coverage remains an upgrade-risk gap. No stored-data contract changes.
Evidence reviewed 9 items Current main remains affected: The main-branch cleanup comparator accepts unsafe numeric identities, and raw acquisition records numeric descriptor stats.
Introduced cleanup boundary: The new comparator rejects any unsafe numeric device or inode before it can authorize cleanup.
Final removal decision: No-token cleanup compares the observed and current identities before removing a sidecar; token-owned cleanup retains its separate token and byte checks.
Findings 1 actionable finding [P3] Add the cleanup safety fix to Unreleased
Security None None.

How this fits together

fs-safe uses sidecar files to coordinate exclusive access to protected files, then checks ownership evidence before removing them. FileStore pruning checks directory identity before acting on a listing of expired entries.

flowchart LR
 A[Lock request] --> B[Sidecar file]
 B --> C[Exact identity snapshot]
 C --> D{Identity still matches?}
 D -->|Yes| E[Guarded removal]
 D -->|No| F[Preserve changed file]
 G[Store directory listing] --> H[Directory identity check]
 H --> D
Loading

Decision needed

Question Recommendation
Should this lock-cleanup safety fix ship in v0.21.1 once its Unreleased note and mixed-version cleanup regression are in place? Include in v0.21.1: Add the upgrade note and mixed-version regression, then ship the safety fix in the next patch release.

Why: The PR explicitly leaves release timing open, and a lock retained from an older in-process receipt is an intentional upgrade effect that needs release-owner acceptance.

Before merge

  • Add the cleanup safety fix to Unreleased (P3) - The changed documentation describes a fail-closed upgrade effect, but the branch has no Unreleased entry. Repository policy calls for a concise entry for behavior fixes and compatibility requirements; this finding from the prior review remains unresolved.
  • Resolve merge risk (P1) - When an older package copy leaves an unsafe numeric receipt in shared process state, the new check can retain its sidecar and block reacquisition until the application applies its stale-lock recovery policy. The final mixed-version cleanup outcome and release guidance remain unapproved.
  • Complete next step (P2) - Add the Unreleased note and mixed-version final-cleanup regression, then obtain the v0.21.1 release decision.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P3] Add the cleanup safety fix to Unreleased — docs/sidecar-lock.md:64
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test lines production +40/-30; tests +175/-5 The safety change is bounded and adds substantially more regression coverage than production code.

Merge-risk options

Maintainer options:

  1. Prove the mixed-version outcome (recommended)
    Exercise an unsafe legacy receipt through final shared-manager cleanup and document the resulting retained-lock recovery before merge.
  2. Accept retained locks
    The release owner may explicitly accept fail-closed retention with clear operator recovery guidance.

Technical review

Best possible solution:

Keep exact identities through cleanup, fail closed on rounded legacy receipts, and document safe recovery for a retained lock.

Do we have a high-confidence way to reproduce the issue?

Yes. Current-main source shows numeric cleanup observations, and the new tests define a precise collision and replacement scenario; this read-only review did not execute the baseline.

Is this the best way to solve the issue?

Yes. Exact bigint observations and fail-closed comparison address the rounding hazard at its source; mixed-version cleanup still needs release guidance.

Full review comments:

  • [P3] Add the cleanup safety fix to Unreleased — docs/sidecar-lock.md:64
    The changed documentation describes a fail-closed upgrade effect, but the branch has no Unreleased entry. Repository policy calls for a concise entry for behavior fixes and compatibility requirements; this finding from the prior review remains unresolved.
    Confidence: 0.98

Overall correctness: patch is correct
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against eac699e65bef.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a concrete filesystem cleanup hazard that requires large device or inode values to trigger.
  • merge-risk: 🚨 compatibility: Older in-process numeric receipts may now leave a sidecar in place, requiring the application's recovery policy.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The linked hosted run at the prior head exercised production async and sync lock acquisition on real temporary files with injected colliding identities: the successor remained, descriptors closed, and unchanged Root locks were reclaimed. The relevant source and test blobs are identical at this head; shared-manager legacy-receipt coverage remains an upgrade-risk gap. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The linked hosted run at the prior head exercised production async and sync lock acquisition on real temporary files with injected colliding identities: the successor remained, descriptors closed, and unchanged Root locks were reclaimed. The relevant source and test blobs are identical at this head; shared-manager legacy-receipt coverage remains an upgrade-risk gap. No stored-data contract changes.

Evidence

What I checked:

  • Current main remains affected: The main-branch cleanup comparator accepts unsafe numeric identities, and raw acquisition records numeric descriptor stats. (src/file-identity.ts:47, eac699e65bef)
  • Introduced cleanup boundary: The new comparator rejects any unsafe numeric device or inode before it can authorize cleanup. (src/file-identity.ts:47, 37c271f09a4f)
  • Final removal decision: No-token cleanup compares the observed and current identities before removing a sidecar; token-owned cleanup retains its separate token and byte checks. (src/sidecar-lock-reclaim.ts:277, 37c271f09a4f)
  • Production-path collision coverage: The tests call real async and sync acquisition over temporary files, inject colliding large identities, and observe that a successor remains while descriptors close. (test/sidecar-lock-bigint-cleanup.test.ts:38, 37c271f09a4f)
  • Hosted after-fix validation: The linked hosted CI run passed at the prior reviewed head; the collision test and central source blobs are identical at the current head. (test/sidecar-lock-bigint-cleanup.test.ts:39, 3e99f29953f6)
  • Mixed-version behavior: The documentation states that unsafe numeric identities from older in-process receipts cannot authorize cleanup; shared-manager final cleanup with such a receipt has no introduced regression. (docs/sidecar-lock.md:64, 37c271f09a4f)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add the Unreleased note and a shared-manager unsafe legacy-receipt final-cleanup regression.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-27T03:47:19.610Z sha 9a54c21 :: needs changes before merge. :: [P3] Add the cleanup safety fix to Unreleased
  • reviewed 2026-09-27T04:20:03.401Z sha 3e99f29 :: blocked before merge. :: [P3] Add the cleanup safety fix to Unreleased
  • reviewed 2026-09-27T04:36:40.394Z sha 3e99f29 :: blocked before merge. :: [P3] Add the cleanup safety fix to Unreleased

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. proof: sufficient Contributor real behavior proof is sufficient. labels Sep 27, 2026
@steipete
steipete merged commit 22672b0 into main Sep 27, 2026
36 checks passed
@steipete
steipete deleted the codex/fix-sidecar-bigint-identity-20260927 branch September 27, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant