Skip to content

fix(pr): dependency cache holds leak when a reader closes scripts/pr output early - #194520

Merged
steipete merged 1 commit into
mainfrom
steipete/goofy-nash-57e517
Nov 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/goofy-nash-57e517

Conversation

@steipete

@steipete steipete commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: scripts/pr dependency cache entries stay pinned forever when a run's output reader closes early, as in scripts/pr --help 2>&1 | head -40.

User Impact

User impact: maintainers and agents can pipe scripts/pr through head without permanently pinning a cache installation. The exit status stays 141. Holds that already leaked are not released by this change.

Why This Change Was Made

Eviction already works: each materialization keeps the current entry and the four most recently used settled, unheld entries. It never reached these entries because their holds never released.

The creator process trapped HUP, INT, QUIT, and TERM so that anchor retirement runs, but not PIPE. Installs are the case that hits this, because pnpm install output overruns a head -N reader before the wrapper's next write. Bash 5 then dies without running its EXIT trap. Bash 3.2 does run it, from the fatal-signal handler, but bootstrap verification fails there and takes the fail-closed retain branch, with its warning lost to the closed pipe.

Handling PIPE like the other signals makes retirement run from an ordinary exit. The collector and its retain-on-uncertainty rules are unchanged.

Evidence

  • Regression test: drives the real wrapper with a closed reader and asserts exit 141 plus settled holds. Red on main with the hold retained and settled: false, green with this change. Run locally on Bash 3.2; Linux CI covers Bash 5.
  • Trap semantics, run directly on both shells:
Bash without PIPE trap with PIPE trap
3.2.57 status 141, EXIT trap runs from the signal handler status 141, retirement completes
5.3.20 status 141, EXIT trap never runs status 141, retirement completes
  • Synthetic fixture, 8 successive dependency keys, each first used through a closed reader:
entries held settled KiB
main 8 8 0 17,568
this change 5 0 5 10,980
  • Reader closed at depths 1 through 40, for both unknown-command and --help: 0 holds and 0 anchors retained.
  • Touched suites (pr-dependency-cache, pr-materialized-anchor, pr-wrappers): 169 passed, 6 skipped. Test lines net 0, by moving repeated hold setup into one helper.
  • Field data from one maintainer host: 26 of 31 entries were unsettled. 21 of those were pinned by a single hold from an install, and 20 of the 21 trace to scripts/pr ... | head -N-style commands; the other was not found in logs.

Known gaps, not addressed here:

  • Existing leaked holds stay. Releasing them would change the documented rule that PID death and age never authorize release, so it needs a separate decision.
  • A selected revision older than the lifetime owner (before fix(scripts): preserve PR tooling across process handoffs #185964) still cannot release the hold its parent took. The docs now say so.
  • A stale worktree's parent wrapper picks up its trap on rebase. Anchored children have it as soon as this lands.

`scripts/pr --help | head -40` closes stderr while a frozen install is still
printing. The creator trapped HUP, INT, QUIT, and TERM but not PIPE. Bash 5
died without its EXIT trap; Bash 3.2 ran it from the fatal-signal handler,
where bootstrap verification failed and retained the anchor, with the warning
lost to the closed pipe. The hold never released, so the installation could
never settle or be collected.

Handle PIPE like the other signals so retirement runs from an ordinary exit.
The exit status stays 141.

Repeated hold setup in the cache tests moves to one helper, keeping net test
lines at zero.
@clawsweeper

clawsweeper Bot commented Nov 7, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T06:43:43.191946Z 48b73c6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: XS labels Nov 7, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 7, 2026
@clawsweeper

clawsweeper Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR handles SIGPIPE during wrapper creation so authenticated cleanup releases dependency-cache holds while preserving exit status 141.

Example: Run scripts/pr --help 2>&1 | head -40 while frozen dependencies are being installed.

  • Before: The creator can exit with status 141 without settling its dependency hold, permanently preventing collection.
  • After: The creator runs authenticated retirement, releases its hold, and still exits with status 141.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and correct; execution confidence rests on the wrapper regression, reported shell results, and successful exact-head CI.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body reports wrapper and Bash results, while the inspectable regression uses a fixture installer rather than providing a standalone installation trace.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Piping maintainer tooling through a short-lived reader can leave dependency installations permanently pinned.
Reason: The maintainer-authored change restores intended cleanup using existing owners and leaves recovery of historical leaks outside its narrow scope.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes an evidenced resource leak that remains on main, with a minimal lifecycle repair and no actionable findings.

Priority: P2
Reviewed head: 48b73c6007b1b85463018a0db72fd0ece520970a

Before merge

None.

Findings

None.

Agent review details

How this fits together

The scripts/pr shell wrapper selects trusted tooling and projects dependencies; creator retirement removes its temporary anchor and settles holds in the existing SQLite lifetime ledger.

flowchart TD
  A[PR command] --> B[Trusted wrapper selection]
  B --> C[Creator holds anchor descriptor]
  C --> D[Dependency installation and ledger hold]
  D --> E[Output reader closes]
  E --> F[PIPE trap exits 141]
  F --> G[Authenticated anchor retirement]
  G --> H[Release hold and settle installation]
Loading

Technical review

Best possible solution:

Use the existing creator retirement owner for SIGPIPE, preserving authenticated settlement and status 141.

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

The base lacks PIPE handling on the creator cleanup paths, and the PR reports matching red/green wrapper results on Bash; no target code was executed during this read-only review.

Is this the best way to solve the issue?

This is the smallest complete repair: extend both existing signal-trap sets, clear the added trap with its siblings, and retain one regression without changing settlement policy.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Creator signal handling keeps the original intent (3a4c80c: Creator-owned traps were introduced to retire materialized anchors after failures, signals, bootstrap exits, and failed handoffs.)
  • Durable dependency holds and retirement keeps the original intent (39b3d94: Keep dependencies protected until authenticated creator retirement confirms removal and revalidates identities; uncertainty retains holds.)
  • Repeated hold setup in tests keeps the original intent (39b3d94: The existing cases protect distinct metadata-transition and settlement failures; helper extraction preserves their setup and assertions.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced diff adds PIPE handlers to both creator trap sets and clears PIPE with the other traps after explicit retirement; it changes neither collection policy nor cleanup authorization. (scripts/pr:20, 48b73c6007b1)
  • Current-main necessity: Fetched main retains creator handlers for HUP, INT, QUIT, and TERM without PIPE; its wrapper, lifetime owner, and tooling guide match the corresponding merge-base files. (scripts/pr:16, cba7c0ec2ecc)
  • Existing retirement safeguards remain: Cleanup reauthenticates bootstrap helpers, validates the creator's held directory identity, removes the anchor, and revalidates ledger and installation identities before releasing matching holds. (scripts/pr-lib/cache-lifetime.mjs:832, 48b73c6007b1)
  • Focused regression: The added regression invokes the wrapper through Bash with a closed output reader and independently asserts status 141, no anchor holds, and settled ledger state; the existing fixture substitutes package installation. (test/scripts/pr-wrappers.test.ts:2321, 48b73c6007b1)
  • Discussion and reported execution evidence: The complete PR body reports red/green wrapper results, Bash 3.2 and 5 signal behavior, and an eight-install fixture ending with zero held entries after the fix; the body and comments were read through REST, and no additional execution evidence was attached. (48b73c6007b1)
  • Exact-head CI: The reviewed head has successful openclaw/ci-gate and Darwin checks, successful aggregate statuses, and no failed check runs; the two cancelled runs are auto-response jobs. (48b73c6007b1)

Likely related people:

  • Peter Steinberger: Raw commit 3a4c80c adds scripts/pr:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3a4c80c4c569; files: scripts/pr)
  • Vincent Koc: Raw commit 39b3d94 adds scripts/pr:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 39b3d94413ba; files: scripts/pr)

PR surface

Tests 0, Docs +3, Other +3. Total +6 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 21 21 0
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 1 +3
Total 4 28 22 +6

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: Repeated piped maintainer commands can permanently pin dependency installations, but no application-runtime outage is established.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Repeated piped maintainer commands can permanently pin dependency installations, but no application-runtime outage is established.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 7, 2026, 1:56 AM ET / 06:56 UTC.

@steipete
steipete merged commit e53d657 into main Nov 7, 2026
113 of 115 checks passed
@steipete
steipete deleted the steipete/goofy-nash-57e517 branch November 7, 2026 07:26
@steipete

steipete commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 8, 2026
…er (openclaw#194520)

`scripts/pr --help | head -40` closes stderr while a frozen install is still
printing. The creator trapped HUP, INT, QUIT, and TERM but not PIPE. Bash 5
died without its EXIT trap; Bash 3.2 ran it from the fatal-signal handler,
where bootstrap verification failed and retained the anchor, with the warning
lost to the closed pipe. The hold never released, so the installation could
never settle or be collected.

Handle PIPE like the other signals so retirement runs from an ordinary exit.
The exit status stays 141.

Repeated hold setup in the cache tests moves to one helper, keeping net test
lines at zero.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XS 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