Repository navigation
fix(pr): review-init fails with a client credential custody error on pre-cutover PR registries - #179173
Conversation
…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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible 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 Before merge
FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceTests +35, Docs 0, Other +16. Total +51 across 6 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 21, 2026, 3:16 AM ET / 07:16 UTC. |
There was a problem hiding this comment.
💡 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".
| [...readFileSync(file, "utf8").matchAll(/resolveRuntimeProcessEntrypointUrl\(([^)]*)\)/g)] | ||
| .flatMap(([, argument]) => Array.from(argument!.matchAll(/"(\w+)"/g))) |
There was a problem hiding this comment.
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 👍 / 👎.
|
Merged via squash.
|
…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
What Problem This Solves
Fixes:
scripts/pr review-init(and every other provisioningscripts/prcommand) 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/prexecutes wrapper code materialized from the trusted anchor. That tree contains onlyscripts/pr,scripts/pr-liband the files listed inwrapper-components.txt. The state preflight forkssrc/state/openclaw-agent-schema-inspection.worker.ts, which was not listed, so the child exited 1 and the preflight reported the registry asindeterminaterather than as a pending migration.preparePrStateSchemaonly looked atpendingMigrations, 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:
pgis not a pinned wrapper dependency.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.preparePrStateSchemano longer treats a store the preflight could not classify as current. Anindeterminatestate 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 recommendsopenclaw doctor --fixfor 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
GatewayStateOwnerContentionErrorwhile 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
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 asscripts/prdoes it.main(fbc99b8), the run logs[state/db] state database schema migration pending; verifying integrity firstand then the custody refusal, identical to the incident.review-initcompletes. The registry is atuser_version29 with the legacy credential tables dropped,client/credentials.sqlitehas phasecomplete, a.pre-startup-migration-*.scoped.bakexists, and the operation lock is released.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 casev28 from unclassified extractruns 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.pr-worktree-statefile passes (15 tests). Also passing: theeager-import-closureandpr-wrapper-source-closuresuites in full (22/22),pr-worktree-interruption(the other consumer of the owner fixture),pnpm tsgo:scriptsandpnpm 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.main. I mergedmaininto the branch, because one inventory entry (src/process/spawn-broker/resource-port.ts) had been deleted there andgit archivewould 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-statepasses 14/14 (the extracted-source case takes 21 s), andpnpm tsgo:scriptsandpnpm tsgo:test:rootpass.no-map-spreaderror in the new inventory check; it is fixed withArray.from. The same changed-file oxlint command now passes locally. Theui/**-only Solid plugin override was stripped from a temporary config because that worktree has noeslint-plugin-solid.