Skip to content

fix(scripts): restore missing helpers in materialized PR anchors - #134366

Merged
steipete merged 2 commits into
mainfrom
steipete/vigorous-kalam-671221
Aug 31, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/vigorous-kalam-671221

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Related: #133913 (trusted PR-wrapper anchor materialization).

What Problem This Solves

Resolves a problem where maintainers running the native PR review or landing workflow from a stale or wrapper-changing worktree hit missing-module errors after the trusted origin/main wrapper was materialized. Review artifact initialization/validation could fail with ERR_MODULE_NOT_FOUND for scripts/lib/record-shared.mjs, leaving the normal operation lock retained for explicit recovery.

This is a separate tooling repair, not a change to the TLS work where the first failure was observed.

Why This Change Was Made

Complete the existing pr_wrapper_components source inventory rather than patching extracted copies or bypassing wrapper trust. The trace covers review artifacts, shell-resolved attribution tooling, TypeScript CLI shims, hosted gates, CI dispatch, and the publisher's canonical test-planner import closure. The same inventory continues to own dirty-file checks, revision comparisons, extraction, and per-blob verification.

The private extracted tree exposes only the four existing third-party tooling packages it requires (tsx, zod, minimatch, and yaml), not a whole node_modules link that could resolve unanchored workspace source. Hosted-gate normalization now imports the archived canonical implementation. Candidate build/test commands and candidate workflow inputs retain their existing ownership. There are no new packages, configuration options, runtime dependency resolvers, or fallback paths.

Native verification also exposed a nearby false-success path: a symlinked temporary/check-out path left helper arguments logical while Node canonicalized the module URL, so a direct-run guard could skip the helper and produce an empty artifact with exit 0. Resolve the wrapper's own path physically with pwd -P, preserving that canonical path through child execution. A real extracted-wrapper regression covers this path.

Wrapper, lock, and main-refresh fixtures now consume one inventory-driven source copier instead of maintaining incomplete parallel lists. Production LOC: +84/-3, net +81, principally 72 explicit source-closure entries plus physical wrapper-path normalization. Tests/support: +315/-172, net +143, including the shared fixture helper. Broad directory copies and a new runtime resolver would enlarge the trust surface or introduce another mechanism; restructuring the general test planner is not necessary for this repair.

User Impact

No bot/runtime product behavior changes. Maintainers using the repaired launcher can execute the real review and gate helpers from a materialized anchor while retaining blob verification, restrictive 0700 temporary-root permissions, protected GitHub routing, and existing lock supervision.

Adoption boundary: an old invoking launcher still contains its old extraction inventory. Use an updated launcher when adopting this fix; advancing the fetched ref does not rewrite already-running or stale launcher bytes. The relevant helper flows still require the existing installed third-party toolchain.

Evidence

Before the production repair, archiving the exact declared components into a fresh directory and dynamically importing the real review-artifact helper reproduced the missing record-shared.mjs error. The new extracted-anchor execution tests also failed against the original production code, exposing missing loader, attribution, and planner dependencies rather than being satisfied by marker stubs.

After repair, the real extracted review helper generates a correctly bound template and validates synthetic authored artifacts. Real CI/hosted-gate shims reach their argument guards, attribution tooling runs, the publisher emits its command, and the trusted planner discovers a non-sibling importing test from a synthetic candidate change. A tampered extracted dependency is refused before execution; the extracted root is asserted to be 0700. All execution proof uses disposable repositories, isolated HOME/Git/GitHub configuration, and fixture-owned or deny-all GitHub executables—no real GitHub writes or operator-state access.

Focused local proof (macOS; Node 24.20.0 and Node 26.8.1):

  • Initial owner/sibling run: 315 tests passed across wrapper, artifact validation, hosted verifier, watcher, CI dispatch, planner, and publisher suites.
  • Expanded lock proof caught four incomplete sibling fixture inventories. The existing native cleanup table failed 4/5 before fixture repair and passed 5/5 afterward; no lifecycle assertion or production check was weakened.
  • Final wrapper + operation-lock suites, including the physical-path regression: 137 passed, one Linux-only zombie case skipped on macOS.
  • Symlinked temporary-root regression: failed before physical-path normalization with exit 0 and empty output; passed afterward with a correctly PR/head-bound, nonempty template.
  • Main-refresh suite: 36 passed.
  • Hosted merge + hosted-gate verifier suites: 100 passed.
  • Explicit Node 24 extracted-anchor execution/tamper selection: 3 passed.
  • Changed-scope checks, formatting, scripts/root-test typechecks, scripts lint, erasability, shell syntax, and git diff --check: passed.
  • Codex autoreview: scoped-clean at the default P0 threshold.

Commands:

node scripts/run-vitest.mjs test/scripts/pr-wrappers.test.ts test/scripts/pr-review-artifact-validation.test.ts test/scripts/verify-pr-hosted-gates.test.ts test/scripts/watch-pr-ci.test.ts test/scripts/pr-ci-dispatch.test.ts test/scripts/pr-crabbox-gate-plan.test.ts test/scripts/pr-crabbox-gate-publisher.test.ts
node scripts/run-vitest.mjs test/scripts/pr-operation-lock.test.ts test/scripts/pr-wrappers.test.ts
node scripts/run-vitest.mjs test/scripts/pr-main-refresh.test.ts
node scripts/run-vitest.mjs test/scripts/pr-merge-hosted.test.ts test/scripts/verify-pr-hosted-gates.test.ts
node scripts/run-vitest.mjs test/scripts/pr-wrappers.test.ts -t 'extracted anchor'
node scripts/check-changed.mjs -- scripts/pr scripts/verify-pr-hosted-gates.mts test/scripts/pr-wrappers.test.ts test/scripts/pr-wrapper.test-support.ts test/scripts/pr-operation-lock.test.ts test/scripts/pr-main-refresh.test-support.ts

No full local product build/suite or authenticated end-to-end landing was used as proof of the candidate. Exact-head hosted CI and native landing verification remain required. Live open issue/PR searches for quoted record-shared.mjs plus anchor, and an additional anchor-closure PR search, found no matching open work before publication on 2026-08-31.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 31, 2026 18:18
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: L maintainer Maintainer-authored PR labels Aug 31, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 2:57 PM ET / 18:57 UTC.

ClawSweeper review

What this changes

The PR expands the trusted scripts/pr anchor’s extracted source closure, links only four existing tooling packages, and adds regression coverage for helper execution through a symlinked temporary path.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main still materializes an anchor without the helper closure needed by its own review and gate paths. The follow-up physical-path fix and closure tests address the observed failure without a discrete introduced defect; the maintainer label and trust-boundary change require explicit maintainer handling after exact-head CI completes.

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

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and backed by source-connected regression coverage; exact-head CI and protected maintainer review remain the merge gates.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository metadata identifies this as a maintainer-authored PR, so external-contributor proof is not a merge gate; the supplied disposable-repository tests nevertheless map the launcher, helper, tamper-refusal, and physical-path scenarios to the changed owner.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository metadata identifies this as a maintainer-authored PR, so external-contributor proof is not a merge gate; the supplied disposable-repository tests nevertheless map the launcher, helper, tamper-refusal, and physical-path scenarios to the changed owner.
Evidence reviewed 6 items Current main still lacks the required closure: Current main's materialized-anchor inventory includes the wrapper, its library directory, and selected shims, but not record-shared.mjs, the test planner, or the normalization source now reached by those helpers.
Caller and missing callee are directly connected: The review flow resolves and executes pr-lib/review-artifacts.mjs; that helper imports scripts/lib/record-shared.mjs, which current main's materialized inventory omits.
The proposed anchor remains source-verified before execution: The changed launcher verifies each archived entry against the trusted remote-tracking blob before creating its bounded package links and executing the extracted wrapper.
Findings None None.
Security None None.

How this fits together

The native scripts/pr launcher supervises review and landing actions in linked worktrees. If a local wrapper differs from the trusted main anchor, it extracts verified wrapper code and dispatches review, gate, and CI helpers against the target repository.

flowchart LR
  A[Linked PR worktree] --> B[Native PR launcher]
  B --> C{Wrapper differs from trusted main}
  C -->|yes| D[Verified anchor extraction]
  C -->|no| E[Local wrapper execution]
  D --> F[Anchored helper closure]
  F --> G[Review and gate operations]
  E --> G
Loading

Decision needed

Question Recommendation
Should the native landing workflow accept this bounded expansion of the materialized-anchor executable closure after exact-head CI is green? Accept the bounded closure: Keep the explicit verified inventory and four package links once exact-head checks validate the repaired paths.

Why: The repair restores a maintainer workflow by adding helper sources and package links inside a code-execution trust boundary, and the PR carries the protected maintainer label.

Before merge

  • Resolve merge risk (P1) - This enlarges the executable source closure of the native materialized-anchor trust boundary; maintainers should confirm the exact-head suite before relying on it for review or landing operations.
Agent review details

Security

None.

PR surface

Tests +143, Other +81. Total +224 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 4 315 172 +143
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 84 3 +81
Total 6 399 175 +224

Review metrics

Metric Value Why it matters
Production versus test delta production +81, tests/support +143 net The production growth is an explicit audited dependency closure rather than a new runtime resolver, but it expands a trust-sensitive launcher surface.

Merge-risk options

Maintainer options:

  1. Validate the anchored execution closure (recommended)
    Require exact-head CI and maintainer review of the bounded archive-plus-package execution boundary before merge.
  2. Pause the materialized route
    Do not merge if maintainers prefer the prior refusal over expanding the trusted helper closure.

Technical review

Best possible solution:

Retain one explicit, blob-verified source inventory and its inventory-derived fixtures, then accept the bounded four-package linkage only after exact-head checks and maintainer trust-boundary review pass.

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

Yes, by source: current main materializes a list that omits a helper imported by the anchored review-artifact path, and the PR supplies a disposable-worktree regression scenario for that route. This read-only review did not execute the scenario.

Is this the best way to solve the issue?

Yes. Extending the existing blob-verified inventory at the extraction owner is preferable to bypassing trust checks, copying broad directories, or adding a second resolver.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 security-boundary: The PR changes which verified source and installed tooling modules can execute from a materialized trust anchor.

Label justifications:

  • P2: This repairs maintainer-only review and landing workflow reliability without changing bot runtime behavior.
  • merge-risk: 🚨 security-boundary: The PR changes which verified source and installed tooling modules can execute from a materialized trust anchor.
  • 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 metadata identifies this as a maintainer-authored PR, so external-contributor proof is not a merge gate; the supplied disposable-repository tests nevertheless map the launcher, helper, tamper-refusal, and physical-path scenarios to the changed owner.

Evidence

What I checked:

  • Current main still lacks the required closure: Current main's materialized-anchor inventory includes the wrapper, its library directory, and selected shims, but not record-shared.mjs, the test planner, or the normalization source now reached by those helpers. (scripts/pr:47, 2d5f0f348a88)
  • Caller and missing callee are directly connected: The review flow resolves and executes pr-lib/review-artifacts.mjs; that helper imports scripts/lib/record-shared.mjs, which current main's materialized inventory omits. (scripts/pr-lib/review.sh:10, d8070a969ea8)
  • The proposed anchor remains source-verified before execution: The changed launcher verifies each archived entry against the trusted remote-tracking blob before creating its bounded package links and executing the extracted wrapper. (scripts/pr:224, d8070a969ea8)
  • Regression coverage exercises the real extracted path: The tests create a mismatched linked worktree, execute the extracted helper through a symlinked temporary root, exercise review artifacts and planner imports, and refuse a tampered extracted dependency. (test/scripts/pr-wrappers.test.ts:503, d8070a969ea8)
  • Feature history: Local history identifies the merged materialization implementation and this PR's two follow-up commits; the prior implementation is merged, but this repair is not on current main. (scripts/pr:47, 9b4c3d5f1b21)
  • Current-main comparison: The fetched main ref is 2d5f0f348a8876b9472d7f513d94f94543dfe409; all six PR paths still differ from it, so this is neither implemented nor obsolete. (scripts/pr:44, 2d5f0f348a88)

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.

  • Let the exact-head check suite complete, then obtain the maintainer decision on the expanded anchor execution boundary.

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-08-31T18:33:41.223Z sha d1c7588 :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Native verification exposed a nearby execution bug: a helper invoked through a symlinked temporary/checkout path could exit 0 with empty output because Node canonicalized the module URL while the wrapper passed a logical path. This PR now resolves the wrapper path physically with pwd -P and exercises the wrapper's actual extracted-helper dispatch through a symlinked temporary root.

The new regression failed before the change with exit 0 and empty output, then passed with a correctly PR/head-bound template. The full wrapper/lock suites pass 137 tests (one Linux-only case skipped on macOS); changed checks and a fresh full-candidate Codex autoreview passed. The original head's hosted CI and native preparation were green; this behavior-changing follow-up will get its own exact-head CI and refreshed native artifacts before merge.

The latest review had no discrete repair finding or rank-up beyond normal CI and maintainer review. Requesting a refresh because this follow-up changes behavior beyond the reviewed diff:

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Aug 31, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer decision: accept the bounded anchor-closure expansion and physical-path repair at d8070a969ea8ffd0d9f2d925228c250e8e98f308. This addresses the latest review's decision/rank-up request: retain one explicit, per-blob-verified source inventory and only the four existing installed tooling-package links. Dirty detection, trusted-ref selection, 0700 temporary-root permissions, protected GitHub routing, and operation locking remain intact. No broad source/module-tree copy, new resolver, or bypass is introduced.

Exact-head proof is green: CI 33427336100, attempt 1 and Workflow Sanity 33427336082. Native review artifacts were refreshed and validated after the final push. OPENCLAW_TESTBOX=1 scripts/pr prepare-run 134366 passed using that exact-head hosted evidence, with no rebase or head change. The verifier classified the dedicated Testbox workflows as not applicable; no separate Testbox lease is being claimed.

The real extracted-anchor tests failed against the incomplete inventory, then passed with the closure repair. Native verification additionally exposed the symlink-path exit-0/empty-artifact failure; its extracted-wrapper regression failed before pwd -P and passed afterward. Final wrapper/lock coverage is 137 passed, one Linux-only zombie case skipped on macOS. Main-refresh coverage is 36 passed; hosted merge/verifier coverage is 100 passed. The explicit Node 24 extracted-helper/tamper selection passed, as did changed checks and fresh full-candidate Codex autoreview at its default P0 threshold.

Key final local commands (the PR body records the complete owner/sibling command list):

node scripts/run-vitest.mjs test/scripts/pr-wrappers.test.ts -t 'symlinked temporary root'
node scripts/run-vitest.mjs test/scripts/pr-wrappers.test.ts test/scripts/pr-operation-lock.test.ts
node scripts/check-changed.mjs -- scripts/pr test/scripts/pr-wrappers.test.ts
bash -n scripts/pr

Production is +84/-3 (net +81), primarily the 72 explicit closure declarations; tests/support are +315/-172 (net +143) after removing parallel fixture inventories. No full local product build/suite is claimed. Final native merge admission must still resolve GitHub's mergeability projection and revalidate the pinned head before dispatch. Old invoking launcher bytes retain their old inventory; adoption requires using the updated launcher.

@steipete
steipete merged commit 0959561 into main Aug 31, 2026
157 of 158 checks passed
@steipete
steipete deleted the steipete/vigorous-kalam-671221 branch August 31, 2026 19:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L 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