Skip to content

refactor: reuse synchronous absolute directory guards - #765

Merged
steipete merged 1 commit into
mainfrom
codex/absolute-native-guard-result-owner
Oct 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/absolute-native-guard-result-owner

Conversation

@steipete

@steipete steipete commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

HOLD: performance qualification is inconclusive. All seven source-comparison gates passed, but the early-policy candidate control exceeded the predeclared 1.10 upper-ratio limit. This draft stays unmerged, with its measured head and complete dataset frozen. The proposed 21-line reduction receives no credit on main.

ensureAbsoluteDirectory uses separate capture/assert Result adapters and an error-reinspection helper around directory guards whose filesystem work is already synchronous. This proposal shares that Result handling and calls the existing guard implementations in native path mode. It removes 21 production code lines, counting all new imports, types and callers, while retaining every filesystem observation and the public async method.

Native guard bodies and the existing async/sync wrappers are unchanged. Forward prefix inspection, parent and child identities, the EEXIST loop, getter order and asynchronous mkdir remain. The new internal exports stay outside the supported package export map. Removing private Promise layers changes scheduling; concurrent reinspection must still refuse according to the filesystem state actually observed. Stable error identity, classification and getter behavior remain covered.

Functional qualification passed at candidate d3a15d6ff74a44dc4c66d454ad4591742e0774f6 against baseline e8cc7e3dcfe96e39d187168aa7ae84918ef65300:

  • Four focused source lanes passed 114 cases each, including 66 contract and three queued-swap cases, with zero skips: baseline Node 24 and candidate Node 24, Node 22 and Bun 1.4.2. The baseline tests use an explicit test-only overlay; packages come from pristine source.
  • Six installed-package lanes passed 90 scenarios with optional native dependencies omitted and native mode off. All 12 raw microtraces and 18 queued-case journals were retained. The two failure traces use 4/6 private ticks in the candidate versus 7/9 in the baseline; concrete filesystem/error event order is preserved. The queued removal case reports the observed state: baseline absence/not-found with its exact ENOENT cause, candidate symlink with no cause; both refuse before mkdir.
  • Public export, API snapshot and strict installed-declaration checks passed. Manual declaration inspection confirms only intended internal additions; every existing signature is unchanged. All 124 transport/bootstrap/functional child processes settled successfully, with descriptor, fixture and instrumentation cleanup verified.
  • CI run 36535677792 passed all 28 executed jobs on attempt 1, with three conditional skips. Regular benchmarks passed. Coverage tests passed on all platforms on attempt 1; Windows artifact upload hit DNS ENOTFOUND, and the failed-job retry completed coverage successfully on attempt 2. CodeQL remains skipped while this PR is a draft.
  • Independent source and functional-artifact reviews passed. Managed P2 product review reported no actionable findings. Two proof-retention gaps were fixed and reviewed before execution; neither changed the product or acceptance gates.

The fixed performance study completed all 96 scheduled processes on AWS Linux x64, Node 24.21.0, with 16 CPUs available and measured children pinned to CPU 0. It retained all 67,200 timed durations and 3,360 sample means across 24 balanced four-arm blocks. Baseline and candidate each used two separate installations of their respective tarball. No samples were excluded or added, no thresholds or order changed, and no acceptance rerun is planned.

Workload Candidate / baseline Source upper ratio Baseline control upper Candidate control upper
Existing, depth 1 0.994886 1.003300 1.014363 1.013924
Existing, depth 8 0.996638 1.007537 1.021891 1.026619
Missing, depth 1 1.032720 1.062517 1.050317 1.058992
Missing, depth 8 0.988886 0.991424 1.008107 1.006068
Early policy rejection 1.036544 1.095017 1.098523 1.129630 — fail
Late guard rejection 0.945545 0.958627 1.015887 1.053706
Ordinary rejection 1.017844 1.033069 1.025899 1.040877

The protocol requires all seven one-sided source bounds and all 14 bidirectional control bounds to be at most 1.10. Each block uses the median of five 20-call means for each arm; the bounds use the fixed denominator-23 sample standard deviation and t critical value 1.7138715277470473. These are per-workload method-latency bounds, not request-tail or simultaneous-family confidence claims.

The sole failing control compares two copies of the same candidate tarball: C1/C0 point ratio 1.054013, upper ratio 1.129630. It prevents acceptance under the fixed protocol and does not establish a slowdown caused by the refactor. All source bounds passed; 13 of 14 controls passed. Process exit 0 establishes completion of the study, not acceptance.

Both test leases are released, all evidence is retained, and no changelog entry or speedup claim is proposed. The unchanged production counter remains 57,029 on main; 57,008 is the unmerged candidate count.

@clawsweeper

clawsweeper Bot commented Sep 29, 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 P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 30, 2026, 8:49 PM ET / October 1, 2026, 00:49 UTC (Revision 3).

ClawSweeper review

What this changes

The branch reuses synchronous directory guards inside the asynchronous absolute-directory helper and adds tests for filesystem swaps and classified failures.

Merge readiness

✅ Ready for maintainer review

Keep open: current main does not contain this refactor. The later coordinator comment lifts the performance hold, and GitHub records identical changed-file blobs for the measured and current heads. No actionable defect was found.

Priority: P3
Reviewed head: fea4b9e2a13451a5c5d24aaf4542eb3965b399ba

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch and race coverage provide normal good review confidence, with the earlier performance hold addressed in discussion.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-author proof exemption applies. The PR nevertheless reports installed-package runs through absolute-directory creation, including observed fail-closed swap behavior; GitHub shows identical measured-head and current-head source blobs. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-author proof exemption applies. The PR nevertheless reports installed-package runs through absolute-directory creation, including observed fail-closed swap behavior; GitHub shows identical measured-head and current-head source blobs. No stored-data contract changes.
Evidence reviewed 9 items Current main: The pinned main revision still uses separate asynchronous guard adapters, so the branch's central cleanup remains unique.
Introduced implementation: The new shared adapter calls the existing guard bodies in native mode; the public helper retains its await points around guard checks.
Guard boundary: The reused guard implementation rejects symlinks and non-directories, then checks directory identity and canonical path before accepting the guard.
Findings None None.
Security None None.

How this fits together

The absolute-directory helper receives a configured absolute path, checks existing segments, and creates missing directories. It returns the completed path or a classified failure; durable-directory creation also calls it.

flowchart LR
  A[Absolute path and options] --> B[Inspect existing segments]
  B --> C[Capture directory guard]
  C --> D[Check directory identity]
  D --> E[Create missing segments]
  E --> F[Final guard check]
  F --> G[Completed path or failure]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed lines production +38/−62; tests +493 The branch reduces production code while adding targeted contract and race coverage.
Declared performance bounds 20 passed, 1 failed The later hold-lift comment addresses the one failed same-tarball control.

Root-cause cluster

Relationship: canonical
Canonical: #765
Summary: The closed, unmerged alternative overlaps this refactor, while the current PR is the remaining landing candidate.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep the shared native guard path with the public asynchronous Result contract and fail-closed checks around directory creation.

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

Not applicable: this PR proposes an internal refactor rather than reporting a bug. Its tests specify concrete filesystem-swap scenarios, but this read-only review did not execute them.

Is this the best way to solve the issue?

Yes: calling the existing native guard bodies through one Result adapter is a narrow cleanup, and the added tests cover the scheduling and failure contracts affected by removing Promise layers.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a bounded internal refactor with no established user-facing regression.
  • merge-risk: 🚨 compatibility: Removing private Promise layers changes which race state can determine a failure code, while the documented and tested outcomes remain fail-closed.
  • merge-risk: 🚨 other: One same-tarball performance control failed its declared bound; the later coordinator comment lifts the hold for the identical patch.
  • 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: The member-author proof exemption applies. The PR nevertheless reports installed-package runs through absolute-directory creation, including observed fail-closed swap behavior; GitHub shows identical measured-head and current-head source blobs. No stored-data contract changes.

Evidence

What I checked:

  • Current main: The pinned main revision still uses separate asynchronous guard adapters, so the branch's central cleanup remains unique. (src/absolute-path.ts:74, f1659dba775c)
  • Introduced implementation: The new shared adapter calls the existing guard bodies in native mode; the public helper retains its await points around guard checks. (src/absolute-path.ts:73, fea4b9e2a134)
  • Guard boundary: The reused guard implementation rejects symlinks and non-directories, then checks directory identity and canonical path before accepting the guard. (src/directory-guard.ts:99, fea4b9e2a134)
  • Public contract: The documented helper returns classified path-policy failures and rethrows operational filesystem failures; the newly exported guard functions are absent from the package export map. (docs/advanced.md:58, fea4b9e2a134)
  • Race coverage: Added tests exercise queued parent and child substitutions and classify the filesystem state observed during reinspection. (test/absolute-directory-guard-scheduling.test.ts:45, fea4b9e2a134)
  • Measured-head identity: GitHub reports identical blob SHAs for all four changed files at measured head d3a15d6 and current head fea4b9e. (fea4b9e2a134)

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)

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 (2 earlier review cycles)
  • reviewed 2026-09-29T07:19:13.606Z sha d3a15d6 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-29T09:19:39.018Z sha d3a15d6 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Sep 29, 2026
@steipete

steipete commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

The coordinator has reviewed this diff and lifted the performance hold. createAsyncDirectoryGuard(dir) was exactly captureDirectoryGuard(dir, "native"), and assertAsyncDirectoryGuard was exactly assertDirectoryGuard(guard, "native"); this removes Promise layers around synchronous work. All seven source gates passed, and only a same-tarball control failed. Retained awaits preserve the yield points exercised by the new queued-substitution race tests. Competing PR #764 is closed.

@steipete
steipete force-pushed the codex/absolute-native-guard-result-owner branch from d3a15d6 to fea4b9e Compare October 1, 2026 00:43
@steipete
steipete marked this pull request as ready for review October 1, 2026 00:45
@steipete
steipete requested a review from a team as a code owner October 1, 2026 00:45
@steipete
steipete merged commit ecec23e into main Oct 1, 2026
45 checks passed
@steipete
steipete deleted the codex/absolute-native-guard-result-owner branch October 1, 2026 00:59
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: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. 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