Skip to content

perf: reuse owned directory identity during cleanup - #760

Merged
steipete merged 1 commit into
mainfrom
codex/owned-cleanup-identity
Oct 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/owned-cleanup-identity

Conversation

@steipete

@steipete steipete commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Bounded native directory cleanup repeats fstat on each already-opened descendant solely for its unchanged type, device and inode. Reuse those captured facts while retaining the fresh no-follow pathname check immediately before removal. This removes nine production code lines and one metadata syscall per successfully traversed descendant. The child remains owned throughout recursion; root descriptor rechecks, Linux mount fences, macOS mount checks and unlink handling remain intact. Removing the syscall also removes its distinct possible late operational-error observation.

Held as a draft: the fixed Linux installed-package comparison does not exclude a material regression for asynchronous depth-64 cleanup. Its 95% upper ratio bound is 1.1343, exceeding the predeclared 1.10 limit. This is uncertainty, not an established repeatable slowdown. The complete measurements are retained; there was no measurement retry, exclusion or threshold change.

Public cleanup workload Paired candidate/base ratio 95% interval Fixed gate
Async, 128 sibling directories 0.9860 0.9733–0.9969 Pass
Async, depth 64 1.0397 0.9523–1.1343 Hold
Sync, 128 sibling directories 0.9795 0.9748–0.9840 Pass
Sync, depth 64 0.9946 0.9120–1.0837 Pass

Each of two independently built and installed artifacts ran two warmup pairs and twenty measured pairs per workload, four cleanups per sample, with balanced A/B order. Setup and syscall tracing were outside timed regions. Results use the geometric mean of paired ratios and a fixed 10,000-draw paired bootstrap on Linux x64, Node 24.21.0, on a 16-vCPU AWS runner. There is no macOS timing claim.

Correctness and mechanism validation passed: thirteen related Rust tests on each implementation, including the new post-descent replacement regression; 175 focused TypeScript tests with zero skips; installed async/sync symlink and public-name replacement safety, descriptor cleanup, and real openat2 ENOSYS/EPERM refusal. Eight syscall traces show exactly 128 or 64 fewer descriptor stats with all other traced filesystem counts and mount flags unchanged. Both macOS native CI jobs ran and passed the new regression and quarantine-swap proof. Independent review passed through P2, and git diff --check passed.

CI run: the initial run had one Windows Node 22 package-smoke failure reporting only exit code 1. The single failed job passed one retry on the unchanged commit; CI is now green. The original failure is retained and its cause remains unclassified. The performance hold remains regardless of CI outcome.

@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 P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. 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. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 30, 2026, 8:24 PM ET / October 1, 2026, 00:24 UTC (Revision 6).

ClawSweeper review

What this changes

The branch reuses an open child directory’s captured identity during Linux and macOS bounded cleanup, adds a replacement-race regression test, and records the optimization in the changelog.

Merge readiness

⛔ Blocked before merge - 3 items remain

Current main still performs the extra descriptor metadata read, so this PR remains useful. The code review found no blocking defect, but the declared async depth-64 performance limit still needs a recorded disposition.

Priority: P2
Reviewed head: 68162309e1c34608582cafdff92f261eda03ccbc
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The narrow patch has strong safety and mechanism evidence, while its declared depth-64 performance limit remains unresolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR’s reported installed-package Linux async and sync cleanup runs exercise the changed native traversal and observe fewer descriptor stats, with replacement-safety observations; macOS native regression results are supplemental, and no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR’s reported installed-package Linux async and sync cleanup runs exercise the changed native traversal and observe fewer descriptor stats, with replacement-safety observations; macOS native regression results are supplemental, and no stored-data contract changes.
Evidence reviewed 8 items Introduced cleanup change: The child descriptor is statted and checked when opened; after descent, the patch reuses that captured identity and still performs a fresh no-follow name inspection before unlink.
Replacement regression coverage: The added test checks absent, directory, and symlink replacements after descent and verifies that replacement content is preserved.
Current-main necessity: The pinned main revision still calls a helper that repeats fstat on the child descriptor after descent.
Findings None None.
Security None None.

How this fits together

Temporary-workspace cleanup passes retained directory handles to native bounded cleanup. Native code traverses descendants through opened handles, checks each name before removal, and returns a removal result or error to the JavaScript caller.

flowchart LR
A[Temporary workspace cleanup] --> B[Retained directory handles]
B --> C[Native bounded traversal]
C --> D[Open child and capture identity]
D --> E[Traverse descendants]
E --> F{Child name still matches?}
F -- Yes --> G[Remove directory]
F -- No --> H[Report mismatch]
Loading

Decision needed

Question Recommendation
Should the optimization proceed when the recorded async depth-64 upper ratio is 1.1343, above its declared 1.10 limit? Measure prospectively: Predeclare an independent depth-64 sample and combine it with the retained original measurements against the same 1.10 criterion.

Why: The safety and syscall evidence supports the code change, but accepting or resolving the predeclared performance limit is a maintainer choice.

Before merge

  • Resolve merge risk (P1) - The Linux async depth-64 sample has a 95% upper candidate/base ratio of 1.1343, above the PR’s predeclared 1.10 limit. A material slowdown is not excluded, and no separately recorded maintainer acceptance or prospective combined analysis resolves that gate.
  • Complete next step (P2) - Record a maintainer disposition of the async depth-64 1.10 limit through prospective combined measurement or explicit acceptance of the observed uncertainty.
  • 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 delta production -9 lines, tests +56 lines The production reduction has a stated syscall rationale and focused replacement-race coverage.

Merge-risk options

Maintainer options:

  1. Resolve the depth-64 limit (recommended)
    Use a prospectively specified independent sample and combined analysis that retains the original measurements and 1.10 criterion.
  2. Accept the measured uncertainty
    A maintainer may explicitly accept the recorded upper bound and preserve that decision alongside the measurements.

Technical review

Best possible solution:

Keep the captured-descriptor identity and fresh no-follow name check, then land the optimization once the declared performance limit has an explicit, recorded disposition.

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

Not applicable as a bug reproduction. The PR provides installed-package cleanup measurements and syscall observations for its performance claim.

Is this the best way to solve the issue?

Yes for code scope: the open descriptor supplies stable identity while a fresh no-follow name check still gates removal. The declared performance limit needs a recorded disposition.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded performance improvement to existing temporary-workspace cleanup.
  • merge-risk: 🚨 other: The async depth-64 performance interval remains above the PR’s declared slowdown limit.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR’s reported installed-package Linux async and sync cleanup runs exercise the changed native traversal and observe fewer descriptor stats, with replacement-safety observations; macOS native regression results are supplemental, and no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR’s reported installed-package Linux async and sync cleanup runs exercise the changed native traversal and observe fewer descriptor stats, with replacement-safety observations; macOS native regression results are supplemental, and no stored-data contract changes.

Evidence

What I checked:

  • Introduced cleanup change: The child descriptor is statted and checked when opened; after descent, the patch reuses that captured identity and still performs a fresh no-follow name inspection before unlink. (native/src/unix.rs:709, 68162309e1c3)
  • Replacement regression coverage: The added test checks absent, directory, and symlink replacements after descent and verifies that replacement content is preserved. (native/src/unix.rs:1827, 68162309e1c3)
  • Current-main necessity: The pinned main revision still calls a helper that repeats fstat on the child descriptor after descent. (native/src/unix.rs:737, 678401b6f906)
  • Public cleanup boundary: The documented bounded path binds enumerated children to native identity, rejects mount crossings, traverses through opened handles, and treats links as leaves. (docs/temp.md:217, 68162309e1c3)
  • Production caller: The JavaScript temporary-workspace owner passes retained parent and workspace descriptors to the native async and sync removal entrypoints. (src/temp-workspace-owner.ts:345, 68162309e1c3)
  • Recorded real behavior and performance: The captured PR body reports installed-package Linux async and sync cleanup runs, replacement-safety observations, and eight syscall traces with 128 or 64 fewer descriptor stats. Its async depth-64 95% upper candidate/base ratio is 1.1343 against the declared 1.10 limit. (68162309e1c3)

Likely related people:

  • steipete: 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.

  • Resolve the depth-64 limit through prospective combined measurement or explicit maintainer risk acceptance.

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 (5 earlier review cycles)
  • reviewed 2026-09-29T01:30:41.572Z sha 1ea38bb :: blocked before merge. :: none
  • reviewed 2026-09-29T02:06:09.313Z sha 1ea38bb :: blocked before merge. :: none
  • reviewed 2026-09-29T02:16:41.054Z sha 1ea38bb :: blocked before merge. :: none
  • reviewed 2026-09-30T23:47:21.635Z sha aac046c :: blocked before merge. :: none
  • reviewed 2026-10-01T00:16:01.301Z sha aac046c :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

The coordinator has reviewed this diff and lifted the performance hold. opened is the child descriptor's fstat taken immediately after open and identity-checked against the name. The descriptor remains open through recursion, and its dev, ino and type cannot change, so the post-descent fstat was redundant. The fresh no-follow name check before unlinkat remains, with a new regression for post-descent replacement. Removing a syscall cannot cost time; the sole hold bound was the high-variance async depth-64 sample (point ratio 1.04, CI 0.95–1.13).

@steipete
steipete force-pushed the codex/owned-cleanup-identity branch from 1ea38bb to aac046c Compare September 30, 2026 23:42
@steipete
steipete marked this pull request as ready for review September 30, 2026 23:42
@steipete
steipete requested a review from a team as a code owner September 30, 2026 23:42
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. label Sep 30, 2026
@steipete
steipete marked this pull request as draft October 1, 2026 00:11
@steipete
steipete marked this pull request as ready for review October 1, 2026 00:11
@steipete
steipete force-pushed the codex/owned-cleanup-identity branch from aac046c to 6816230 Compare October 1, 2026 00:19
@steipete
steipete merged commit f1659db into main Oct 1, 2026
46 checks passed
@steipete
steipete deleted the codex/owned-cleanup-identity branch October 1, 2026 00:39
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. 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