Skip to content

feat(pr): release dependency cache holds left behind by dead wrappers - #194546

Merged
steipete merged 3 commits into
mainfrom
steipete/gifted-chatterjee-12102f
Nov 8, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/gifted-chatterjee-12102f

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 the wrapper that created their anchor dies without retiring it, because only the creator may release its holds.

User Impact

User impact: maintainers can review leaked dependency holds with a read-only dry run, then release exactly the reviewed anchors with an explicit confirmation, so the existing collector can evict those entries. No release happens automatically, and ordinary scripts/pr runs are unchanged.

This changes a documented rule, so it is worth reading on its own: docs/reference/scripts/pr-tooling.md previously said a creator crash never authorizes releasing holds. Nothing releases them automatically now either, and PID death, age, and path disappearance still never authorize release on their own. The one new exception is an operator confirming a reviewed plan.

Why This Change Was Made

Eviction already works, but it only considers settled, unheld entries. Holds from a dead creator can never release, so their entries are never considered. #194520 stopped one source of new leaks; this handles the holds that already exist and any future leak from a crash.

Holds exist because an inherited consumer can outlive its creator, so no signal alone proves an anchor finished. Authority follows lock-recover: an explicit operator confirmation, plus evidence checks that fail closed, plus exact identity rechecks by the owner.

scripts/pr dependency-hold-release --dry-run [--anchor <path>]... > plan.json
scripts/pr dependency-hold-release plan.json --plan-sha256 <SHA256> --confirmed-no-running-tools

Evidence is collected again immediately before each anchor and never trusted from the plan. Any of these blocks an anchor: a live same-uid creator, a live process in the creator's group, any process referencing the anchor or an entry it holds (by command line or open file), or a changed anchor or entry identity. A failed ps or lsof stops the command.

Decisions worth a reviewer's attention:

  • Present anchors are retired, not just released. On the host that prompted this, 196 of 204 anchors still exist, at about 29 MiB of wrapper source each. Release follows the creator's order: remove the anchor, then release its holds, so a crash leaves a state a rerun of the same plan finishes. Holds are the only authority to remove a path: with no ledger rows for an anchor, the command reports already-released and never touches that path.
  • Process scans run outside the metadata mutex. Other wrappers wait at most one second for it, and lsof alone takes about 0.3 s, so scanning under the lock would make live wrappers fail. The ledger recheck does run under the lock, inside the transaction. A hold a live wrapper takes during a batch is safe by accounting: its anchor is not in the sealed plan, and its row keeps the entry unsettled.
  • One settlement path. retireAnchorDependencies and the new release share their snapshot and settlement code rather than forking it.

Accepted edges, deliberately not coded around:

  • A PID reused by another uid cannot be the creator, so it is recorded but does not block. This happens today: one creator PID now belongs to a system service. A PID reused by the same uid delays release until that process exits.
  • There is no correlation with retained operation locks. Across this host's clones, 0 of 204 anchors match one. Resolving them first is part of what the operator attests.
  • The collector deletes evicted entries synchronously, so the next materializing wrapper run after a large release pays for those deletions before it continues. The docs say so.

Release-note context: new maintainer command scripts/pr dependency-hold-release.

Evidence

End to end on a real projection. The existing live package reader test drives the real embedded materializer, leaving a real node_modules projection, an exited creator, and a live reader, which is exactly a leaked hold. It now continues:

  1. while the reader lives, the anchor is blocked with process-references;
  2. once the reader exits, the anchor is releasable;
  3. a sealed release retires the anchor, leaves the entry's files readable (removal did not follow the symlinks), and settles the entry;
  4. rerunning the plan reports already-released;
  5. the next real materialization evicts the entry.

Refusals leave the ledger byte-identical: missing confirmation, wrong seal, a hold added after review, and an anchor replaced at the same path (the replacement survives).

Live holds are never released, even through a sealed, confirmed plan. Using real ps and lsof with no mocks, the cases are a live creator, an orphaned process group whose leader has exited, a process with its cwd in the anchor, and a process whose command line names the entry key. For the creator and group cases, the test deliberately promotes the blocked record into a sealed plan, because a dead PID cannot be made live; this proves evidence is recollected rather than read from the plan.

Negative controls, each failing for the intended reason: release blockers disabled (4 live-hold cases fail), reviewed-holds comparison removed (the added-hold case fails), anchor removal skipped (the end-to-end test fails). All were restored afterward.

Live dry run on one maintainer host, read-only:

Ledger 31 entries, 5 settled, 204 holds
Anchors 204 releasable, 0 blocked
Anchor state 196 present, 8 missing
Creators 203 gone, 1 PID reused by another uid
Entries that would settle 26

Ledger bytes were unchanged and no lock remained. Two runs produced the same seal. An independent raw ps and lsof check agreed: no references, and no same-uid process with a creator PID as its pid or pgid. No live hold has been released; that awaits the maintainer's decision on this output.

Test cost. Net test lines are -6 against the merge base (422 added, 428 removed), through consolidation that keeps every existing assertion. Measured with --maxWorkers=1: pr-dependency-cache.test.ts passes 62 tests in about 30 to 50 s depending on host load, of which the 10 new cases take about 11 s. The extended reader test takes about 8 s. CI seconds to follow.

Local suites run: pr-dependency-cache, the dependency-cache-recovery, closed-reader and live-reader cases of pr-wrappers, pr-materialized-anchor, check-deadcode-exports, and the wrapper inventory check. Autoreview reported no P0 to P2 findings, though one of its 9 chunks contained only file statistics, so it carries little weight there.

Known gaps:

  • The macOS end-to-end run used a local install 54 packages behind the manifest, so I aligned the manifests temporarily for that run. Nothing from that is committed. PR CI covers a current install on Linux, which also proves ps and lsof behavior there.
  • Production lint could not run locally against that borrowed install. It passed in a copied checkout before a small later change to the release loop, so CI's static gates are the proof for the final code.
  • The per-anchor rescan has no dedicated test. Making liveness appear between two anchors deterministically would need a test-only hook.
  • A real release against a real cache is unproven until the maintainer approves one.

A creator that dies before retiring its anchor leaves dependency holds that
nothing can release, because only the creator may retire an anchor. Those
entries never settle, so the collector never considers them.

Add `scripts/pr dependency-hold-release`. A read-only dry run lists each anchor,
its entries and the evidence, and emits a sealed plan. Release takes that exact
plan with --confirmed-no-running-tools, recollects evidence immediately before
each anchor, retires a present anchor in the creator's order, and settles under
the owner's metadata lock and transaction. Retirement and release now share one
settlement path.

PID death, age and path disappearance still never authorize release on their
own, and nothing sweeps automatically. Authority is the operator's confirmation
of a reviewed plan, plus fail-closed evidence, plus exact identity rechecks.
…erjee-12102f

# Conflicts:
#	docs/reference/scripts/pr-tooling.md
Extend the live package reader test: while the reader survives its exited
creator the anchor is blocked, and once it exits a sealed release retires the
anchor without following its symlinks, settles the entry, reruns safely, and lets
the next real materialization evict it.

Return the fixture-level eviction test to proving creator retirement, so each
contract has one owner at its strongest boundary.
@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-07T08:09:50.495576Z cfcce82 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: XL labels Nov 7, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature 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:feature 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 adds an operator-confirmed command to retire finished wrapper anchors and release their dependency-cache holds.

Example: A wrapper dies, leaving an anchor holding one dependency installation.

  • Before: The installation remains pinned indefinitely, even after its last reader exits.
  • After: The operator reviews a dry-run plan and confirms release; the anchor retires and the existing collector can reclaim the installation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, coherent recovery with no actionable finding; execution confidence rests chiefly on the production-owner harness and reported host dry run.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; real ps/lsof production-owner cases cover confirmed release and live or stale refusals, while the reported real-host execution covers dry-run discovery only.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Maintainers cannot reclaim dependency installations pinned by wrappers that died before retiring their anchors.
Reason: The maintainer-authored direction supplies the owner decision for explicit recovery, and the observed retained holds establish practical value.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR adds useful recovery for historical dependency holds that main cannot release, with no concrete introduced defect found.

Priority: P2
Reviewed head: cfcce829997e42bc195338382723f96a70af7909

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A confirmed release through the authenticated scripts/pr entry point is not supplied; release execution is demonstrated through the production-owner harness.
Agent review details

How this fits together

The scripts/pr wrapper projects cached dependencies into temporary anchors; the SQLite lifetime owner records holds and settlement, which determine whether the collector may evict installations.

flowchart TD
  A[Operator] --> B[Authenticated PR wrapper]
  B --> C[Plan and process inspection]
  C --> D[Cache lifetime owner]
  D --> E[Anchor retirement and hold settlement]
  E --> F[Existing dependency collector]
Loading

Technical review

Best possible solution:

Keep confirmed recovery in the existing cache lifetime owner, with exact reviewed holds, fresh process inspection, and unchanged automatic collection.

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

Main's creator-only retirement checks explain why a crashed creator leaves holds permanently pinned; the PR also reports a real host inventory of retained holds, but no target code was executed during this review.

Is this the best way to solve the issue?

The change uses the existing lifetime owner, preserves conservative automatic behavior, and adds the smallest coherent operator recovery path; the test helpers consolidate repeated setup while retaining distinct failure coverage.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Creator-only dependency retirement changes intended behavior with a stated reason (39b3d94: Prevent collection while an inherited reader survives its creator; PID death and path disappearance do not establish completed consumption.)
  • Authenticated dependency recovery keeps the original intent (cce57b2: Explicit recovery must authenticate official-main tooling and validate exact state without installing dependencies or trusting unlanded wrappers.)
  • Closed-reader cleanup keeps the original intent (e53d657: Run ordinary creator retirement after SIGPIPE while preserving status 141; historical leaked holds remain outside that repair.)
  • Wrapper test fixture consolidation keeps the original intent (39b3d94: Exercise real creator descriptors, durable holds, surviving readers, and identity-sensitive retirement across process handoffs.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 39b3d94 adds scripts/pr-lib/cache-lifetime.mjs:78 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-lib/cache-lifetime.mjs)
  • Peter Steinberger: Raw commit e53d657 adds scripts/pr:20 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e53d6574c0f7; files: scripts/pr)

PR surface

Tests -6, Docs +71, Other +408. Total +473 across 13 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 422 428 -6
Docs 2 76 5 +71
Config 0 0 0 0
Generated 0 0 0 0
Other 6 477 69 +408
Total 13 975 502 +473

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.

Review metrics

Metric Value Why it matters
Recovery command surface 1 new subcommand with 4 option names dependency-hold-release accepts --dry-run, repeatable --anchor, --plan-sha256, and --confirmed-no-running-tools; ordinary wrapper defaults remain unchanged.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Historical holds prevent dependency-cache reclamation in maintainer tooling, without evidence of an application-runtime outage.
  • 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.

Rank-up moves

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

  • A redacted terminal trace of confirmed scripts/pr release on an isolated retained cache would strengthen shipped-entry-point confidence.

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, 3:21 AM ET / 08:21 UTC.

@steipete
steipete merged commit a606a90 into main Nov 8, 2026
123 of 125 checks passed
@steipete
steipete deleted the steipete/gifted-chatterjee-12102f branch November 8, 2026 00:54
@steipete

steipete commented Nov 8, 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
…openclaw#194546)

* feat(pr): release finished dependency holds with operator confirmation

A creator that dies before retiring its anchor leaves dependency holds that
nothing can release, because only the creator may retire an anchor. Those
entries never settle, so the collector never considers them.

Add `scripts/pr dependency-hold-release`. A read-only dry run lists each anchor,
its entries and the evidence, and emits a sealed plan. Release takes that exact
plan with --confirmed-no-running-tools, recollects evidence immediately before
each anchor, retires a present anchor in the creator's order, and settles under
the owner's metadata lock and transaction. Retirement and release now share one
settlement path.

PID death, age and path disappearance still never authorize release on their
own, and nothing sweeps automatically. Authority is the operator's confirmation
of a reviewed plan, plus fail-closed evidence, plus exact identity rechecks.

* test(pr): prove hold release end to end on a real projection

Extend the live package reader test: while the reader survives its exited
creator the anchor is blocked, and once it exits a sealed release retires the
anchor without following its symlinks, settles the entry, reruns safely, and lets
the next real materialization evict it.

Return the fixture-level eviction test to proving creator retirement, so each
contract has one owner at its strongest boundary.
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: XL 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