Skip to content

refactor: trim unused internal switches and reuse error helpers - #794

Merged
steipete merged 2 commits into
mainfrom
steipete/deslop-r2-leftovers
Oct 1, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/deslop-r2-leftovers

Conversation

@steipete

@steipete steipete commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

A few internal switches, an injected filesystem parameter, and a type re-export lost their last real use when #772 consolidated the atomic writers; two modules still hand-wrote error checks that existing helpers implement; and two comments described the code inaccurately.

User Impact

No user-visible change. Branch selection, sync/async boundaries, rm options, error codes, messages and causes are unchanged.

Why This Change Was Made

Net -12 production lines:

  • atomic-io.ts: lstat, stat, and statExact drop a synchronousBuiltin = true parameter no caller passes (so true && x becomes x); remove drops a force = true option whose only caller passed true; SyncFchmod is no longer re-exported through a shim nobody imports.
  • file-cleanup.ts: removeOwnedPath becomes module-private and loses the injected filesystem whose only caller passed fs/promises; it keeps the synchronous lstat and awaited unlink it already used.
  • private-producer-handoff.ts uses errorCauseOptions; secret-file.ts uses hasNodeErrorCode for two exactly equivalent ENOENT guards.
  • Comments: publish-copy-stage.ts no longer claims readers can never observe two names (a synchronous callback and other processes can); archive-staging.ts no longer claims staging is left for OS cleanup or that identity change is the only failure.

Evidence

  • Per method, the omitted-argument default was verified to select the same branch as the simplified condition.

  • tsc, lint:file-size, lint:fs-boundary, docs:check, check-pack (public API snapshot unchanged): pass.

  • 55 focused files (atomic, copy fallback, cleanup authority, producer handoff, secret files, archive staging): 1,448 passed, 0 failed.

  • Codex autoreview (P0-P2): scoped-clean.

  • Tests added or updated when behavior changed

  • Security and compatibility impact considered

  • CHANGELOG.md updated when release-relevant

  • No credentials, private paths, private hosts, or sensitive contents included

@steipete
steipete requested a review from a team as a code owner October 1, 2026 04:30
@clawsweeper

clawsweeper Bot commented Oct 1, 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. 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 Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 3:27 AM ET / 07:27 UTC (Revision 2).

ClawSweeper review

What this changes

The PR removes unused internal filesystem options and type exports, reuses equivalent error helpers, and corrects archive staging and file publication comments.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded cleanup that current main has not adopted. No introduced correctness or security defect was found, and the prior review contained no findings to carry forward.

Priority: P3
Reviewed head: 60b2e4abc8103128d6822fe0252cac8da0d820bb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving cleanup with no actionable findings and relevant reported validation.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies a MEMBER-authored internal refactor, so external-contributor runtime proof is exempt. Source inspection shows unchanged atomic dispatch, guarded cleanup, and secret error classification; no authority or stored-data contract changes trigger additional proof requirements.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies a MEMBER-authored internal refactor, so external-contributor runtime proof is exempt. Source inspection shows unchanged atomic dispatch, guarded cleanup, and secret error classification; no authority or stored-data contract changes trigger additional proof requirements.
Evidence reviewed 9 items Policy and repository boundary: Read the complete root AGENTS.md and verified repository ownership through origin and package metadata. No nested AGENTS.md or maintainer notes were found. Its filesystem-boundary and public-contract guidance informed the review; maintenance-only refactors do not require a changelog entry.
Pinned introduction and merge result: Read all eight introduced file patches from the pinned main SHA to the exact PR head. The verified test merge has main followed by the exact head as its raw parents; its result contains the same eight-file change, with 23 additions and 35 deletions.
Existing callers preserve defaults: Main's callers omit the removed synchronous-selection arguments, its only adapter removal caller passes true, and cleanupPinnedFilePath is the sole removeOwnedPath caller and supplies fs/promises. The simplified branches therefore retain synchronous metadata admission, awaited unlink, and forced removal. Package exports do not expose the removed internal type or cleanup helper.
Findings None None.
Security None None.

How this fits together

fs-safe guards filesystem operations for applications handling untrusted paths. These internal adapters support atomic replacement, secret creation, producer handoff, and cleanup while retaining file and directory identity checks.

flowchart TD
  A[Requested file operation] --> B[Path and identity guards]
  B --> C[Internal filesystem adapter]
  C --> D[Stage and publish file]
  D --> E[Guarded cleanup]
  C --> F[Shared error handling]
  E --> G[Result or preserved failure]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC production +23/-35 (net -12), tests +0/-0 The branch reduces internal code through unused-option removal and helper reuse without changing behavior.

Technical review

Best possible solution:

Keep the smaller internal implementation while preserving guarded mutation, existing scheduling boundaries, and the public package contract.

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

Not applicable: this PR proposes behavior-preserving cleanup rather than fixing a reported runtime failure.

Is this the best way to solve the issue?

Yes: removing unused internal parameters and reusing exactly equivalent helpers is a narrow solution; inspected callers and package exports support the stated compatibility boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 74cf375d1807.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is bounded internal cleanup with no identified user-facing behavior change.
  • 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: Repository State identifies a MEMBER-authored internal refactor, so external-contributor runtime proof is exempt. Source inspection shows unchanged atomic dispatch, guarded cleanup, and secret error classification; no authority or stored-data contract changes trigger additional proof requirements.

Evidence

What I checked:

  • Policy and repository boundary: Read the complete root AGENTS.md and verified repository ownership through origin and package metadata. No nested AGENTS.md or maintainer notes were found. Its filesystem-boundary and public-contract guidance informed the review; maintenance-only refactors do not require a changelog entry. (AGENTS.md:1, 60b2e4abc810)
  • Pinned introduction and merge result: Read all eight introduced file patches from the pinned main SHA to the exact PR head. The verified test merge has main followed by the exact head as its raw parents; its result contains the same eight-file change, with 23 additions and 35 deletions. (60b2e4abc810)
  • Existing callers preserve defaults: Main's callers omit the removed synchronous-selection arguments, its only adapter removal caller passes true, and cleanupPinnedFilePath is the sole removeOwnedPath caller and supplies fs/promises. The simplified branches therefore retain synchronous metadata admission, awaited unlink, and forced removal. Package exports do not expose the removed internal type or cleanup helper. (src/atomic-io.ts:108, 74cf375d1807)
  • Equivalent error helpers: errorCauseOptions returns exactly the prior cause object, including an undefined cause for non-Error values. hasNodeErrorCode performs the same object, code-presence, and equality checks as both replaced ENOENT guards. Secret creation retains its directory assertions before creation and pinned writing. (src/root-errors.ts:132, 60b2e4abc810)
  • Retained regression coverage: Read the atomic metadata regression and pinned cleanup authority tests. They cover ordinary synchronous metadata values, adapter receivers, owned-file removal, replacement preservation, stale parents, and missing identity. These tests were inspected, not executed during this read-only review. (test/pinned-write-cleanup-authority.test.ts:20, 60b2e4abc810)
  • Merged predecessor and area routing: GitHub confirms refactor(atomic): share sync and async resource ownership #772 merged as 5d96c7e. Main history connects steipete to that atomic consolidation and earlier filesystem ownership work. This cleanup follows that work rather than duplicating its implementation. (src/atomic-io.ts, 5d96c7ee653a)

Likely related people:

  • steipete: 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-10-01T04:32:32.269Z sha 5d0b0ff :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 4856fd5 into main Oct 1, 2026
43 checks passed
@steipete
steipete deleted the steipete/deslop-r2-leftovers branch October 1, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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