Skip to content

fix(store): consolidate mutation guards - #107

Merged
steipete merged 1 commit into
mainfrom
refactor/guard-consolidation
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
refactor/guard-consolidation

Conversation

@steipete

@steipete steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • consolidate both synchronous file-store directory walkers behind one guarded helper
  • pin the initial store-root canonical path and filesystem identity, then revalidate both for every walked segment
  • reuse the shared existing-ancestor resolver for deny-mutation comparisons
  • centralize the root write resolve/deny/path-alias prologue while preserving the move fallback's final-symlink overwrite exception

Investigation corrections

The divergent store walker was a live root-swap bug, but the vulnerable side was the private walker: recomputing the root realpath after a redirect followed the replacement and accepted it. The non-private walker's hoisted canonical root already rejected that redirect. The shared implementation is stricter than both because it pins the original canonical path and inode and revalidates them per segment.

The two ancestor-loop predicates were behaviorally equivalent for the reported Windows spellings after their common path resolution step. This PR still removes the duplicate implementation and adds a native-Windows table for drive-relative, device-root, and UNC spellings so future drift is impossible, but does not claim a Windows behavior change.

Proof

  • new root-swap regression fails against origin/main (the private write succeeds) and passes on this branch for both private and non-private entry points
  • native Windows deny-mutation table passes for C:foo, the extended-length C drive root, and a UNC share root
  • pnpm check
  • pnpm test:security
  • git diff --check
  • Codex autoreview: clean, no actionable findings

Production source is reduced by 41 lines; including focused regressions and the changelog, the net change is +32 lines.

@steipete
steipete requested a review from a team as a code owner August 3, 2026 00:11
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 8:15 PM ET / August 3, 2026, 00:15 UTC.

ClawSweeper review

What this changes

The PR unifies synchronous file-store directory guards, pins the original root identity during parent creation, and reuses the shared existing-ancestor canonicalizer for mutation-deny comparisons.

Merge readiness

⛔ Blocked until real behavior proof is added - 4 items remain

Keep this PR open: it addresses a concrete synchronous store-root swap weakness with a focused consolidation, but the available review evidence lacks inspectable after-fix runtime proof and one Windows Node 24 check is failing. No discrete correctness defect is evident in the submitted diff from source review, so the next step is to diagnose that platform result and provide redacted real-run evidence before merge.

Priority: P1
Reviewed head: a126bc256dfcad47d23d9c3601f496077b80cc87

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source patch and focused regressions are coherent, but missing inspectable real behavior proof remains a merge gate and the supplied Windows job is failing.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body describes successful local regressions and checks, but contains no inspectable after-fix terminal output, runtime log, recording, or linked artifact; please post redacted evidence and update the PR body to trigger a fresh review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body describes successful local regressions and checks, but contains no inspectable after-fix terminal output, runtime log, recording, or linked artifact; please post redacted evidence and update the PR body to trigger a fresh review.
Evidence reviewed 5 items Current-main gap: Current main validates each walked directory's canonical path remains inside the initially resolved root, but it does not re-stat or re-realpath the store root after each segment; a root replacement can therefore make the pre-loop root reference stale.
Proposed confinement hardening: The branch retains the initial root stat and canonical path, then rejects a symlinked, non-directory, identity-changed, or canonically changed root after every parent-walk segment.
Focused regression coverage: The added regression exercises a root rename followed by replacement with an outside symlink for both private and non-private synchronous stores, and asserts no outside file is written.
Findings None None.
Security None None.

How this fits together

The synchronous file-store layer creates and validates parent directories before writing beneath a caller-configured root. It receives attacker-controlled relative paths and filesystem metadata, then either returns a verified parent guard or rejects symlink, root-swap, and workspace-escape conditions.

flowchart LR
  A[Store write request] --> B[Resolve store root and target]
  B --> C[Pin canonical root and identity]
  C --> D[Walk or create parent segments]
  D --> E[Revalidate root and segment paths]
  E --> F[Verified parent guard]
  F --> G[Write file or reject unsafe path]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body describes successful local regressions and checks, but contains no inspectable after-fix terminal output, runtime log, recording, or linked artifact; please post redacted evidence and update the PR body to trigger a fresh review.
  • Resolve merge risk (P1) - The supplied check state includes a failed Node 24 Windows job, so merging before its cause is understood could regress supported Windows path or identity behavior.
  • Resolve merge risk (P1) - The PR body describes successful live regressions, but it provides no inspectable redacted terminal output, recording, log, or artifact demonstrating the after-fix behavior.
  • Complete next step (P2) - The remaining gates are contributor-provided runtime proof and diagnosis of an observed platform check failure, not a bounded automated repair request.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope 7 files affected; 188 added, 156 removed The consolidation spans synchronous store guards, mutation denial, root-write helper reuse, and focused regressions.
Platform validation 1 completed Windows Node 24 check failed The modified platform-sensitive canonicalization path needs a concrete diagnosis before merge.

Merge-risk options

Maintainer options:

  1. Diagnose the Windows failure before merge (recommended)
    Resolve the failed Windows Node 24 check and retain focused coverage for both root-swap protection and supported Windows canonicalization behavior.
  2. Pause for platform analysis
    Hold the PR if the failed check exposes an unresolved Windows filesystem-identity or path-canonicalization incompatibility.

Technical review

Best possible solution:

Preserve the shared pinned-root guard, repair or explain the Windows-specific check failure, and add redacted after-fix terminal evidence showing both store modes reject a root swap without writing outside the configured root.

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

Yes, from source: the added focused test defines a concrete root rename-and-symlink swap during the synchronous parent walk, and current main lacks the branch's per-segment root identity revalidation. This review did not execute it because the target checkout is read-only.

Is this the best way to solve the issue?

Yes, conditionally: using one guard for both synchronous store modes removes the divergent implementation while preserving the existing guarded-helper boundary. The Windows check must be resolved before that solution can be accepted as cross-platform safe.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The PR addresses a plausible root-swap escape affecting synchronous file-store writes.
  • add merge-risk: 🚨 compatibility: The unified guard can change which synchronous private and non-private store writes are accepted or rejected.
  • add merge-risk: 🚨 security-boundary: The patch changes root confinement, path canonicalization, and filesystem-identity checks for untrusted write paths.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body describes successful local regressions and checks, but contains no inspectable after-fix terminal output, runtime log, recording, or linked artifact; please post redacted evidence and update the PR body to trigger a fresh review.

Label justifications:

  • P1: The PR addresses a plausible root-swap escape affecting synchronous file-store writes.
  • merge-risk: 🚨 security-boundary: The patch changes root confinement, path canonicalization, and filesystem-identity checks for untrusted write paths.
  • merge-risk: 🚨 compatibility: The unified guard can change which synchronous private and non-private store writes are accepted or rejected.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body describes successful local regressions and checks, but contains no inspectable after-fix terminal output, runtime log, recording, or linked artifact; please post redacted evidence and update the PR body to trigger a fresh review.

Evidence

What I checked:

  • Current-main gap: Current main validates each walked directory's canonical path remains inside the initially resolved root, but it does not re-stat or re-realpath the store root after each segment; a root replacement can therefore make the pre-loop root reference stale. (src/file-store-boundary.ts:184, 947fa83fd43e)
  • Proposed confinement hardening: The branch retains the initial root stat and canonical path, then rejects a symlinked, non-directory, identity-changed, or canonically changed root after every parent-walk segment. (src/file-store-boundary.ts:212, a126bc256dfc)
  • Focused regression coverage: The added regression exercises a root rename followed by replacement with an outside symlink for both private and non-private synchronous stores, and asserts no outside file is written. (test/guard-consolidation.test.ts:15, a126bc256dfc)
  • Current implementation provenance: Blame attributes the current synchronous parent-guard implementation to the v0.5.1 release commit, which is the available current-main provenance for this code path. (src/file-store-boundary.ts:158, 16e1bd489ae8)
  • Platform validation signal: The supplied PR check state reports the Node 24 Windows check as failed, while other completed checks listed in the context pass; no failure log was available in the read-only checkout to establish a line-level defect.

Likely related people:

  • steipete: The current synchronous guard is attributed by blame to Peter Steinberger's release commit, and the PR context identifies the same contributor as the author of this focused root-swap repair. (role: recent area contributor; confidence: medium; commits: 16e1bd489ae8, a126bc256dfc; files: src/file-store-boundary.ts, src/file-store.ts, test/guard-consolidation.test.ts)

Rank-up moves

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

  • Post redacted terminal output from the root-swap regression for private and non-private stores.
  • Diagnose and fix or explain the failed Node 24 Windows check.
  • After updating the PR body with proof, request a fresh review if it does not trigger automatically.

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.

@steipete
steipete merged commit be27814 into main Aug 3, 2026
41 of 42 checks passed
@steipete
steipete deleted the refactor/guard-consolidation branch August 3, 2026 01:05
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. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant