Skip to content

refactor(infra): share path existence policy - #134630

Merged
vincentkoc merged 1 commit into
mainfrom
refactor-path-may-exist
Sep 1, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor-path-may-exist

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Several runtime, Doctor, Web Push, workspace, device identity, and plugin uninstall paths independently implemented the same conservative filesystem-existence rule. Keeping seven copies made a security-sensitive fail-closed policy easy to drift.

Why This Change Was Made

This consolidates the exact shipped rule in one private infrastructure helper: lstatSync success means present, only ENOENT means absent, and every other error remains potentially present. Existing migration and uninstall policy wrappers remain with their owners; no SDK, barrel, config, package, or SQLite surface was added.

@openclaw/fs-safe was not reused because its existence helper follows links with statSync and treats every error as absence, which would change dangling-symlink and ENOTDIR behavior.

User Impact

No intended user-visible behavior change. Operators keep the same fail-closed handling for inaccessible or ambiguous retired state, with one canonical policy instead of seven copies.

Evidence

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Sep 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 1, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 10:22 PM ET / September 1, 2026, 02:22 UTC.

ClawSweeper review

What this changes

The PR consolidates repeated synchronous filesystem path probes into a shared infrastructure helper while retaining each migration and uninstall owner’s surrounding policy.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer review. Current main still contains the duplicated predicate bodies, while the introduced helper preserves their lstatSync/only-ENOENT semantics and no concrete regression was found.

Priority: P3
Reviewed head: 5fd6e62d3acde8432d240d3699eb6c04aef78d68

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation is a focused, net-negative consolidation with direct contract coverage and no identified correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, behavior-preserving refactor is exempt from the external contributor proof gate; the focused test directly exercises the new predicate’s relevant filesystem states.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, behavior-preserving refactor is exempt from the external contributor proof gate; the focused test directly exercises the new predicate’s relevant filesystem states.
Evidence reviewed 5 items Introduced shared predicate: The introduced helper uses lstatSync; it returns false only for an exact ENOENT and preserves fail-closed handling for every other error.
Current-main necessity: Fetched current main has no shared helper and retains the same local lstatSync predicate in the device-identity owner; the PR head is not an ancestor of fetched main.
Owner wrappers remain intact: The shared migration wrapper still probes both source and claim paths, preserving the policy used by multiple Doctor migration callers.
Findings None None.
Security None None.

How this fits together

Legacy-state migration guards, device identity initialization, Web Push setup, and plugin uninstall planning probe local paths before acting. The shared helper supplies the conservative presence result, and each owning flow decides whether to block, migrate, or continue.

flowchart LR
A[Legacy state or plugin path] --> B[Shared path probe]
B --> C{Definite ENOENT?}
C -->|Yes| D[Continue owner flow]
C -->|No or uncertain| E[Owner safety or migration guard]
E --> F[Doctor guidance or protected action]
Loading

Before merge

  • Complete next step (P2) - No repairable defect was found; the maintainer-authored and maintainer-labeled PR needs ordinary exact-head CI completion and human review.
Agent review details

Security

None.

PR surface

Source -50, Tests +24, Other -4. Total -30 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 10 40 90 -50
Tests 1 24 0 +24
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 7 -4
Total 12 67 97 -30

Review metrics

Metric Value Why it matters
Production vs test delta production +40/-90 (net -50); tests +24; guard metadata +3/-7 The refactor removes duplicated production predicates while adding focused coverage for the shared filesystem contract.

Stored data model

Persistent data-model change detected: migration/backfill/repair: config/assertion-safety-baseline.txt, migration/backfill/repair: src/infra/push-web.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Retain one canonical conservative probe and land it after normal maintainer review and exact-head CI complete successfully.

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

Not applicable: this PR refactors an existing internal predicate rather than addressing a separately reported user failure.

Is this the best way to solve the issue?

Yes. A narrow shared helper preserves the exact current predicate while owner-specific source/claim and authorization logic remains at its existing boundaries.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a behavior-preserving internal cleanup with no reported user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, behavior-preserving refactor is exempt from the external contributor proof gate; the focused test directly exercises the new predicate’s relevant filesystem states.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (1 earlier review cycle)
  • reviewed 2026-09-01T01:49:08.343Z sha 5fd6e62 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review September 1, 2026 02:16
@vincentkoc
vincentkoc merged commit c50533f into main Sep 1, 2026
329 of 330 checks passed
@vincentkoc
vincentkoc deleted the refactor-path-may-exist branch September 1, 2026 02:27
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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