Skip to content

refactor: centralize absolute directory result handling - #764

Closed
steipete wants to merge 1 commit into
mainfrom
codex/absolute-directory-result-owner
Closed

steipete wants to merge 1 commit into
mainfrom
codex/absolute-directory-result-owner

Conversation

@steipete

@steipete steipete commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

HOLD — do not merge. Functional qualification and CI passed, but the completed performance study failed its predeclared gate. Early policy rejection was observed to be 24.3% slower; its baseline control also failed, limiting causal attribution. The measured head stays frozen, and this draft receives no production-line reduction credit on main.

ensureAbsoluteDirectory wraps successful private guard and prefix results, then repeatedly unwraps them to propagate failure. This proposal lets those helpers return their useful value directly and makes the public operation responsible for returning its existing classified-failure Result. It would remove 40 production code lines while retaining every filesystem observation, guard and await site.

Only failure records created by the operation enter its private WeakSet. Nested catches recognize those records without inspecting arbitrary thrown values, and the public boundary removes the marker before returning them. Operational exceptions still reject; a previously returned Result cannot be mistaken for a new internal failure. Public types, defaults and error mappings remain unchanged.

Functional qualification passed at 83222e0aa775725bbf83eb563044f11d574219f6 against baseline e8cc7e3dcfe96e39d187168aa7ae84918ef65300:

  • Four focused source lanes passed 111 cases each, including all 66 new regressions, with zero skips: baseline Node 24 and candidate Node 24, Node 22 and Bun 1.4.2.
  • Six installed-package processes passed 72 scenarios. All 12 complete microtrace arrays matched between baseline and candidate within their runtime. Optional native dependencies were omitted and native mode was off.
  • Public declarations matched byte-for-byte. Descriptor, instrumentation and fixture cleanup passed.
  • CI run 36527796878 passed on its first attempt: 28 executed jobs and three conditional skips. CodeQL remains skipped while the PR is a draft.
  • Managed P2 review reported one test-count finding. Independent source tracing rejected it because it omitted the loop iteration after successful mkdir; all unchanged assertions then passed in the four runtime lanes.

The fixed performance study completed all 96 scheduled processes on AWS Linux x64, Node 24.21.0, with 16 available CPUs and every measured child 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 had two independent installations of their respective package tarball. No samples were excluded, no gates or order were changed, and no acceptance rerun is planned. An independent offline audit reconstructed every sample mean from its raw sequential durations exactly and confirmed the same two failed gates.

Workload Baseline µs Candidate µs Candidate / baseline One-sided 95% upper ratio
Existing, depth 1 89.7979 89.4775 0.996431 1.006032
Existing, depth 8 134.3867 131.8940 0.981452 0.995488
Missing, depth 1 239.1657 244.4956 1.022286 1.046650
Missing, depth 8 1378.0675 1380.4814 1.001752 1.005082
Early policy rejection 45.1929 56.1834 1.243190 1.315444
Late guard rejection 88.9783 89.0302 1.000584 1.014639
Ordinary rejection 89.0599 90.2665 1.013547 1.024160

These latencies are geometric means of each arm's per-block median of five 20-call means; they are not request-tail measurements. Each workload required a source upper ratio and both bidirectional same-source control upper ratios of at most 1.10. Early policy rejection also failed its baseline control, with an upper ratio of 1.109925; its candidate control passed at 1.093104. All other source and control gates passed. Both failed gates require HOLD under the frozen protocol, irrespective of the successful process exit code.

The runner has been released and all evidence retained. This is an internal refactor with no demonstrated speedup; no changelog entry is proposed.

@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: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. 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: blocked before merge. Reviewed September 29, 2026, 3:06 AM ET / 07:06 UTC (Revision 2).

ClawSweeper review

What this changes

The branch moves classified failures from private absolute-directory helpers to one public Result boundary and adds regression tests for directory races and unusual thrown values.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open for maintainer disposition. Current main does not contain this refactor, and the PR’s frozen performance study failed its declared acceptance gate despite strong reported functional qualification.

Priority: P3
Reviewed head: 83222e0aa775725bbf83eb563044f11d574219f6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch has substantial functional evidence and no definite correctness finding, but its own frozen performance gate failed.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies the author as MEMBER, so the external-contributor proof gate does not apply. The PR body now reports installed-package directory scenarios and cross-runtime comparisons for the changed operation; its performance gate nevertheless failed. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies the author as MEMBER, so the external-contributor proof gate does not apply. The PR body now reports installed-package directory scenarios and cross-runtime comparisons for the changed operation; its performance gate nevertheless failed. No stored-data contract changes.
Evidence reviewed 9 items Current main: The pinned main version still uses private success-or-failure wrappers, so the central failure boundary proposed here is not already implemented.
Introduced behavior: The pinned introduced diff adds a private WeakSet marker and converts marked failures at the public operation boundary.
Guard sequence: The proposed operation still checks the parent before inspection and creation, checks it after child guard acquisition, and checks the final guard before success.
Findings None None.
Security None None.

How this fits together

The absolute-directory helper accepts a trusted absolute path, inspects its existing segments, and guards directory identity while creating missing segments. Durable directory setup consumes its success path or classified policy failure.

flowchart LR
  A[Trusted absolute path] --> B[Validate input]
  B --> C[Inspect existing segments]
  C --> D[Check directory identity]
  D --> E[Create missing segments]
  E --> F[Final identity check]
  F --> G[Path or policy result]
Loading

Decision needed

Question Recommendation
Should this failed-gate, frozen refactor be retired, or should a revised design receive a new performance study? Retire the measured branch: Leave the failed-gate head unmerged and close it after maintainer disposition.

Why: The declared gate blocks this measured head, while deciding whether the internal simplification merits further work is a maintainer tradeoff.

Before merge

  • Resolve merge risk (P1) - The reported early policy rejection ratio was 1.243 against the declared 1.10 gate. A failed baseline control limits causal attribution, but the frozen protocol still requires HOLD before this internal refactor can merge.
  • Complete next step (P2) - Keep this measured head unmerged; a maintainer should decide whether to retire it or sponsor a separately evaluated redesign.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test lines production +83/-121 (net -38), tests +270 The refactor reduces source size while adding focused failure-path coverage.

Merge-risk options

Maintainer options:

  1. Honor the failed gate (recommended)
    Keep the measured head unmerged and retire the draft unless maintainers sponsor a new design.
  2. Evaluate a new design
    Require a separately declared study of a revised implementation before it becomes a merge candidate.

Technical review

Best possible solution:

Retain the current implementation unless a separately evaluated design preserves the directory safety contract and meets a newly declared acceptance gate.

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

Not applicable: this PR refactors existing behavior rather than reporting a user failure. Its tests specify concrete race and rejection scenarios, and the body reports package comparisons.

Is this the best way to solve the issue?

No for this measured head: the single public conversion boundary is coherent, but its declared performance gate failed. A revised design would need a separate evaluation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is an internal cleanup with no reported user-facing regression.
  • merge-risk: 🚨 other: The declared performance gate failed for early policy rejection, a merge concern outside the more specific risk labels.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies the author as MEMBER, so the external-contributor proof gate does not apply. The PR body now reports installed-package directory scenarios and cross-runtime comparisons for the changed operation; its performance gate nevertheless failed. No stored-data contract changes.

Evidence

What I checked:

  • Current main: The pinned main version still uses private success-or-failure wrappers, so the central failure boundary proposed here is not already implemented. (src/absolute-path.ts:50, e8cc7e3dcfe9)
  • Introduced behavior: The pinned introduced diff adds a private WeakSet marker and converts marked failures at the public operation boundary. (src/absolute-path.ts:51, 83222e0aa775)
  • Guard sequence: The proposed operation still checks the parent before inspection and creation, checks it after child guard acquisition, and checks the final guard before success. (src/absolute-path.ts:261, 83222e0aa775)
  • Public contract: The documented helper returns classified path-policy failures and rethrows operational filesystem failures; it does not itself enforce root confinement. (docs/advanced.md:58, e8cc7e3dcfe9)
  • Regression coverage: The added tests cover guard reinspection, previous-result reuse, concurrent calls, thrown values, EEXIST retries, and observation order. This read-only review did not execute them. (test/absolute-directory-result-contract.test.ts:17, 83222e0aa775)
  • Reported qualification and hold: The PR body reports 72 installed-package scenarios, cross-runtime focused cases, matching microtraces, and passing CI. Its frozen performance study reports an early policy rejection ratio of 1.243190 against a 1.10 gate; a baseline control also failed, limiting causal attribution. The author explicitly states HOLD. refactor: centralize absolute directory result handling #764.

Likely related people:

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

Rank-up moves

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

  • For any successor design, declare a new performance protocol before measuring early policy rejection.

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-29T05:49:29.802Z sha 83222e0 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Closing this one in favor of #765, which reworks the same function (ensureAbsoluteDirectory) in a simpler way.

Both drafts remove the same Result wrapping and unwrapping. This one does it by threading a private WeakSet marker through nested catches, so a reader has to reason about marker ownership at every catch site. #765 does it by calling the existing synchronous guard implementations directly (captureDirectoryGuard/assertDirectoryGuard in native mode, exactly what the async wrappers already did). It also passed all seven of its source-comparison gates.

This draft's own study also measured a real source-side regression. Early policy rejection went from 45.2 µs to 56.2 µs (ratio 1.243, one-sided upper bound 1.315). That is outside the noise that failed the control arms elsewhere.

The measurements and functional qualification here are still useful as a record, so the branch is left in place.

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

Labels

merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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