Skip to content

fix(pr): review-init fails with a client credential custody error on pre-cutover PR registries - #179173

Merged
steipete merged 4 commits into
mainfrom
claude/magical-hawking-a50ae7
Oct 23, 2026
Merged

steipete merged 4 commits into
mainfrom
claude/magical-hawking-a50ae7

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: scripts/pr review-init (and every other provisioning scripts/pr command) fails in [pr-worktree-provision] with "Client credentials require backed-up migration custody; stop the app and run openclaw doctor --fix." when the wrapper's private PR registry (<canonical>/.local/pr-state) predates the client-credential cutover.

User Impact

Maintainers can provision PR worktrees again from a pre-cutover PR registry. The first run migrates the private registry under Doctor-style custody, with a scoped pre-migration backup. The operator's own Gateway database is never involved, and no action is required.

Why This Change Was Made

The migration custody contract was fine. The guarded migration simply never ran when scripts/pr executes wrapper code materialized from the trusted anchor. That tree contains only scripts/pr, scripts/pr-lib and the files listed in wrapper-components.txt. The state preflight forks src/state/openclaw-agent-schema-inspection.worker.ts, which was not listed, so the child exited 1 and the preflight reported the registry as indeterminate rather than as a pending migration. preparePrStateSchema only looked at pendingMigrations, treated the store as current and returned. The allocation lease's ordinary open then hit the v28→v29 cutover with no maintenance scope or backup capture, and the custody check refused it.

This change makes three adjustments:

  • Inventory: lists the forked runtime children that wrapper code can launch (11 files). The PostgreSQL bridge is deliberately left out: wrapper processes never install a PostgreSQL engine selection, and pg is not a pinned wrapper dependency.
  • Inventory check: the "PR wrapper inventory" check now follows resolveRuntimeProcessEntrypointUrl("…") references, so a forked child missing from the extracted closure fails CI instead of failing at runtime. This gap dates from fix(state): avoid payload copies during online schema preflight #171984 (online preflight in a forked child) and became fatal with feat(state): local client credential cutover (R0 PR1b) #174599, which added the preflight-gated migration.
  • Routing: preparePrStateSchema no longer treats a store the preflight could not classify as current. An indeterminate state store goes through the same guarded doctor-preparation as a pending migration, and that path re-inspects the store under custody (a current store passes its integrity check and needs no repair). Without this, any future gap of this kind degrades into a misleading custody error that recommends openclaw doctor --fix for a private wrapper registry.

Accepted edge case: if two provisioners race the one-time migration of the same registry, the second one fails fast with a visible, retryable GatewayStateOwnerContentionError while the first holds the migration owner. Pending migrations already behaved this way. Live lease holders do not make the preflight indeterminate (its inspection is a plain WAL read), so ordinary concurrent provisioning is unchanged.

Evidence

  • Real reproduction and fix through scripts/pr review-init 178648. I used a disposable canonical clone holding a copy of the real pre-cutover registry (v28, clean-close seal re-bound to the copy), with the anchor materialized exactly as scripts/pr does it.
    • With the anchor at unfixed main (fbc99b8), the run logs [state/db] state database schema migration pending; verifying integrity first and then the custody refusal, identical to the incident.
    • With the anchor at this change, review-init completes. The registry is at user_version 29 with the legacy credential tables dropped, client/credentials.sqlite has phase complete, a .pre-startup-migration-*.scoped.bak exists, and the operation lock is released.
    • The live shared registry was never touched; all runs used copies.
  • Controls. The same copied registry migrates cleanly when the provisioner runs from a full checkout, with or without the seal. So the store bytes and seal are not causal; only the extracted-tree composition is.
  • test/scripts/eager-import-closure.test.ts -t "PR wrapper inventory". Red on base, naming 7 unlisted forked children. Green with this change.
  • test/scripts/pr-worktree-state.test.ts. New case v28 from unclassified extract runs the real provisioner from extracted wrapper sources with the inspection child removed. On base it fails with the custody refusal (~17 s); with the fix it passes and keeps the existing assertions: migration, preserved rows, credential move and backup restore. The existing checkout cases still pass.
  • Other checks. The full pr-worktree-state file passes (15 tests). Also passing: the eager-import-closure and pr-wrapper-source-closure suites in full (22/22), pr-worktree-interruption (the other consumer of the owner fixture), pnpm tsgo:scripts and pnpm tsgo:test:root.
  • pr-worktree-provision. 14 of its cases pass. Three cold-provisioning cases hit the 120 s timeout on this host (load average around 90), and they time out identically with this PR's production files reverted to base, so PR CI is the judge for those.
  • Review. Codex autoreview (P0–P1) found nothing actionable.
  • Cost. The new state case copies the wrapper inventory and runs a real provisioner. Locally it took 73 s, but under a load average around 90; CI records about 40 s for the whole file. No cheaper layer exercises the extracted-tree route that failed.
  • Current head on current main. I merged main into the branch, because one inventory entry (src/process/spawn-broker/resource-port.ts) had been deleted there and git archive would refuse it, so that entry is dropped. On the merged tree (Node 26.12.1) the inventory check reports nothing missing or stale. The closure suites pass 22/22, pr-worktree-state passes 14/14 (the extracted-source case takes 21 s), and pnpm tsgo:scripts and pnpm tsgo:test:root pass.
  • Lint. CI's first run caught a no-map-spread error in the new inventory check; it is fixed with Array.from. The same changed-file oxlint command now passes locally. The ui/**-only Solid plugin override was stripped from a temporary config because that worktree has no eslint-plugin-solid.

…rces

scripts/pr review-init failed in [pr-worktree-provision] with "Client
credentials require backed-up migration custody" when the private PR
registry (<canonical>/.local/pr-state) predated the client-credential
cutover.

The trusted-anchor wrapper extracts only scripts/pr, scripts/pr-lib and
wrapper-components.txt. The state preflight forks
src/state/openclaw-agent-schema-inspection.worker.ts, which was not
listed, so the child exited 1 and the preflight reported the registry as
indeterminate. preparePrStateSchema only consulted pendingMigrations,
returned early, and the allocation lease's ordinary open then ran the
v28->v29 cutover without maintenance custody or a backup capture.

- List the forked runtime children wrapper code can launch. The
  PostgreSQL bridge stays out: wrapper processes never install a
  PostgreSQL engine selection and pg is not a pinned wrapper dependency.
- Make the PR wrapper inventory check follow
  resolveRuntimeProcessEntrypointUrl references.
- Send an indeterminate state preflight through the existing guarded
  doctor-preparation instead of treating the store as current.
- Regression: run the real provisioner from extracted wrapper sources
  with the inspection child removed; the v28 registry must migrate.
@clawsweeper

clawsweeper Bot commented Oct 21, 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 Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T01:03:14.620789Z 4c9de21 New commits
ℹ️ 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: S labels Oct 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR restores guarded migration of older private PR registries by including missing worker sources and handling indeterminate schema inspections.

Example: Run scripts/pr review-init 178648 with a private registry at schema version 28.

  • Before: The extracted wrapper cannot launch schema inspection and subsequently fails with a client credential custody error.
  • After: The wrapper captures a scoped backup, migrates the registry to version 29 under existing custody, and completes provisioning.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful migration coverage; the reported CLI reproduction supports it, while the failed lint gate still needs classification.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body records scripts/pr review-init against an isolated copy of a real version-28 registry, successful version-29 cutover, a scoped backup, and lock release.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Maintainers with pre-cutover private PR registries cannot provision PR worktrees and receive a Doctor instruction aimed at the wrong state location.
Reason: This maintainer-authored repair restores the intended provisioning contract while preserving the approved credential custody design.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this PR repairs a concrete provisioning failure still present on current main, and the focused implementation has no identified correctness defect.

Priority: P2
Reviewed head: c5ed52da84e5ba5753cd56ed2ee89b1ba16c6b67

Before merge

  • Complete next step - Inspect the failed changed-lint output and establish whether it requires a repair in this PR or has a verified outside cause.

Findings

None.

Agent review details

How this fits together

The trusted PR wrapper extracts an approved source inventory and provisions worktrees using a repository-private SQLite registry; schema preparation must finish before allocation opens that registry.

flowchart TD
A[PR command] --> B[Trusted wrapper extraction]
B --> C[Schema preflight worker]
C --> D[Guarded Doctor preparation]
D --> E[Private PR registry]
E --> F[Allocation lease]
F --> G[PR worktree]
Loading

Technical review

Best possible solution:

Retain this focused repair using the existing migration and backup owners, with the extracted-wrapper regression coverage.

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

Source inspection establishes the missing-child → indeterminate preflight → uncaptured allocation-open path, and the body records an isolated scripts/pr reproduction; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The change repairs extraction at its producer and reuses guarded preparation for unclassified stores; the inventory check and extracted-source regression protect distinct failure boundaries without introducing another owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Private registry migration preparation keeps the original intent (8f62210: The local credential cutover requires captured, exclusive migration custody before retiring shared credentials.)
  • Online schema inspection keeps the original intent (fix(state): avoid payload copies during online schema preflight #171984: Inspect schema metadata in an isolated child without copying database payloads or disturbing parent-process writer locks.)
  • Wrapper inventory and extracted sources keeps the original intent (68663e6: Maintain one source-closure check so copied wrapper sources contain their runtime dependencies.)
  • Provisioning fixture isolation keeps the original intent (d88a97a: Keep fresh provisioner processes bound to private test stores independently of NODE_OPTIONS.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Tests +35, Docs 0, Other +16. Total +51 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 40 5 +35
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 17 1 +16
Total 6 58 7 +51

Labels

Label changes:

  • add P2: The failure blocks maintainer worktree provisioning for older private registries, with limited impact outside repository tooling.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The failure blocks maintainer worktree provisioning for older private registries, with limited impact outside repository tooling.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 October 21, 2026, 3:16 AM ET / 07:16 UTC.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c9de21cbe

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +114 to +115
[...readFileSync(file, "utf8").matchAll(/resolveRuntimeProcessEntrypointUrl\(([^)]*)\)/g)]
.flatMap(([, argument]) => Array.from(argument!.matchAll(/"(\w+)"/g)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse entrypoint calls instead of grepping source

This inventory guard only recognizes the exact identifier resolveRuntimeProcessEntrypointUrl followed by double-quoted word literals before the first ). If a wrapper caller validly aliases the imported resolver or passes a typed variable holding a new entrypoint name, the test reports no missing worker, allowing the materialized wrapper to omit that child and recreate the runtime failure this test is intended to prevent. Derive these edges from parsed call expressions or a centralized launch inventory rather than a source regex.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 9c29902 into main Oct 23, 2026
111 of 112 checks passed
@steipete
steipete deleted the claude/magical-hawking-a50ae7 branch October 23, 2026 01:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…pre-cutover PR registries (openclaw#179173)

* fix(pr): migrate pre-cutover PR registries from extracted wrapper sources

scripts/pr review-init failed in [pr-worktree-provision] with "Client
credentials require backed-up migration custody" when the private PR
registry (<canonical>/.local/pr-state) predated the client-credential
cutover.

The trusted-anchor wrapper extracts only scripts/pr, scripts/pr-lib and
wrapper-components.txt. The state preflight forks
src/state/openclaw-agent-schema-inspection.worker.ts, which was not
listed, so the child exited 1 and the preflight reported the registry as
indeterminate. preparePrStateSchema only consulted pendingMigrations,
returned early, and the allocation lease's ordinary open then ran the
v28->v29 cutover without maintenance custody or a backup capture.

- List the forked runtime children wrapper code can launch. The
  PostgreSQL bridge stays out: wrapper processes never install a
  PostgreSQL engine selection and pg is not a pinned wrapper dependency.
- Make the PR wrapper inventory check follow
  resolveRuntimeProcessEntrypointUrl references.
- Send an indeterminate state preflight through the existing guarded
  doctor-preparation instead of treating the store as current.
- Regression: run the real provisioner from extracted wrapper sources
  with the inspection child removed; the v28 registry must migrate.

* test: collect forked entrypoint names without map spread

* fix(pr): drop wrapper inventory entry deleted on main
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: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant