Repository navigation
fix(exec): migrate legacy approval policy before runtime reads - #162687
Conversation
|
🦞👀 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: blocked before merge. Reviewed October 2, 2026, 5:51 AM ET / 09:51 UTC (Revision 11). ClawSweeper reviewWhat this changesThis PR moves legacy execution-approval normalization into a backed-up Doctor migration, requires canonical policy at runtime, and preserves malformed writes for fail-closed handling. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain The durable migration remains useful, but the previously reported backup regression is still present on the latest head. Ordinary backups can silently discard supported legacy execution policy. Priority: P2 Review scores
Verification
How this fits togetherExecution approvals store command permissions, MCP tool grants, and socket credentials in SQLite. Doctor repairs older policy before runtime reads, while backup and snapshot exporters sanitize copies for restoration or sharing. flowchart TD
A[Legacy approval policy] --> B[Doctor migration]
B --> C[Verified original backup]
B --> D[Canonical SQLite policy]
D --> E[Runtime execution checks]
A --> F[Backup sanitization]
D --> F
F --> G[Restorable or shared snapshot]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +176, Tests +203, Docs +17. Total +396 across 14 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep strict runtime reads and the durable Doctor migration, while letting offline snapshot sanitization use the shared validated legacy converter before redacting socket credentials. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the introduced failure: export a SQLite policy containing a legacy string allowlist before Doctor runs; the sanitizer receives null from the strict parser and writes deny-all instead. No target code was executed in this read-only review. Is this the best way to solve the issue? The Doctor-owned migration is the right direction, but the cutover is incomplete because offline backup consumers still depend on the runtime parser's former legacy acceptance. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aa31aeefb745. LabelsLabel changes: No label changes. Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
81390aa to
7e495df
Compare
7e495df to
b34aed8
Compare
61e2d44 to
cc0242a
Compare
|
…law#162687) Move supported persisted exec-approval normalization into the existing Doctor migration owner, with a verified backup and canonical runtime reads. Preserve malformed policy bytes so the reader continues to fail closed, and return the actual persisted rule IDs and CAS hash from writes. The published 2026.9.7 update cell and full changed checks passed on the migration head. The subsequent writer repair has independent P2 review and exact-head hosted CI. No schema version or public configuration option changes. Exact-head CI passed 58 jobs; its only root failure is inherited Windows source/compiled TUI error-copy fixture drift from openclaw#163381. The failing child reaches no approval-policy or migration code. Landed under the explicit pre-existing-failure exception.
What Problem This Solves
Exec approval reads still normalized historical policy in memory, leaving SQLite rows with legacy agent names, string allowlists, or missing rule IDs. Removing that runtime conversion needs a durable migration for supported installations.
User Impact
Doctor and update-time repair back up and normalize legacy SQLite policy before runtime access. Explicit
mainsettings win over the olddefaultagent, while allowlists and MCP grants merge. Socket credentials, current command-use metadata, and the original update timestamp survive. String entries become canonical objects with stable IDs. ObsoletecommandTextand unknown source labels remain recoverable in the original backup.Runtime reports
openclaw doctor --fixguidance for a convertible legacy row and leaves it untouched. Repeating Doctor preserves the canonical bytes and IDs. Published SDK/operator input normalization stays at the write boundary. No new config option or SQL schema version is introduced.Why This Change Was Made
The existing exec-policy Doctor owner now handles persisted policy as well as JSON import, using its exclusive maintenance scope and the shared verified snapshot helper. It validates the physical database identity and exact planned row before backup publication and commit. JSON conflict decisions run before SQLite normalization, preserving the existing imported-source receipt semantics.
Production
src/**andextensions/**, excluding tests/support/helpers/e2e/fixtures: +229/-54/net +175. The runtime conversion is deleted; the added code supplies the missing durable repair. Hunk overlaps with #153405, #161513, and #123867 were inspected and are separate from this codec/Doctor cut.The July 1 retention audit keeps the JSON importer:
v2026.7.1still writesexec-approvals.jsonthroughsaveExecApprovalsandwriteExecApprovalsRaw(src/infra/exec-approvals.ts:862–874). No safe pre-July retirement offset was established in this owner. Approval policy and its socket credentials use the approved durable-policy exception to the production cap.Evidence
Current head
fe9809682823f44a8351ee66537b8b32cd9df398, tree731fa80f4fe43ad3227319cd64902443f1545a27, base18689ff071b69dc41e35eb403ffe56433ad74a66. The integrated migration and the subsequent CI repair each have clean Codex review through P2. The conflict-driven rebase preserves main's July retention and cron sections. Formatting andgit diff --checkpassed. Exact-head hosted CI completed at the repaired head: all Linux Node groups and ordinary checks passed; the Windows exception below is inherited from main. The earlier full gate and migration update cell remain attributed to their original head.CI run 36983002142 exposed four deterministic PR-caused failures. Three exact receipt expectations omitted the canonical SQLite source now declared by the migration owner. The fourth exposed a writer defect: normalization stripped malformed
agents.runner.askbefore the existing fail-closed reader could reject it, allowing partial defaults to survive. The repair canonicalizes only positively identified, structurally valid legacy input, preserves malformed authored bytes, and returns the actual persisted bytes and hash. The existing Doctor security assertion remains unchanged. Two writer regressions cover direct and worker-backed updates and passed in exact-head hosted CI; the previous single-worker store suite measured 16.90s wall. Receipt assertions now require both exact sources. No failure is classified as a flake or pre-existing.At prior head
cc0242aa678802e72c6c6ceca1fa4482f1447801(tree41a254bab876523426626571f85df6cc6313e75c), Blacksmith Testboxtbx_01m3xqjp9k9g0r63gxhrp8dfmm, run 36977761177, after frozen dependency installation:pnpm test <file> --maxWorkers=1.node scripts/check-changed.mjs --base 18689ff071b69dc41e35eb403ffe56433ad74a66 --head HEAD --timedpassed in 1436.24s, including production/test types, lint, ratchets, and applicable source/boundary guards.d47be8b76178fe10def3c8e75a50b7dfdfde5baaceefc9b3651dd535d050fd07.openclaw update --tag file:<candidate> --yes --json --no-restart. Before manual candidate Doctor, assertions verified canonical policy, stable rule IDs, original verified backup, source timestamps, socket credentials, and exact installed candidate identity. The update took 146s. Repeated Doctor took 8s and retained the same canonical bytes, IDs, and backup. No package version rewriting or state reseeding occurred during update.The approvals phase completed before this lease later exceeded the workflow's one-hour limit during an independent Voice Call proof. The lease is completed. Recorded step exits and artifacts establish the approvals results above; no complete passing workflow is claimed. The repair does not change migration discovery, backup, valid legacy normalization, or update callbacks, so the published-driver cell remains applicable to that unchanged migration contract. Hosted CI now passes the affected Linux groups, including the exact-receipt and writer/security owners; no separate full-gate replay was needed. No local tests, builds, or type checks ran.
Earlier focused proof remains attributed to its original heads. On
81390aa608dd22d5381574cbd56dd87d59a5b22a, leasetbx_01m3vgatt77q1bjva836mm6c3spassed 179 tests in six files, core types, typed lint, and ratchets. Per-file wall times: canonical migration 17.02s (3 tests), JSON migration 16.97s (23), config 17.81s (35), store 16.90s (28), read worker 21.88s (16), policy 15.84s (74). The regression proves the original backup row, intended normalized row, runtime refusal, repeat stability, and refusal when a backup changes even if source is restored before commit. The final update cell above proves the actual registered repair path.Two earlier validation stops are retained as failures, not flakes or passing replays. Preview code added three lines to an over-cap Doctor module; moving preview ownership into the existing migration detector fixed it. A subsequent native check found 11 unchanged compatibility records expiring October 2 UTC; main fixes #163127 and #163158 are included in this candidate's base, and the current full gate passed without date spoofing or a disabled guard. No retries, timeout increases, or weakened assertions were added.
Exact-head CI and inherited Windows failure
CI 36991648805 completed on
fe9809682823f44a8351ee66537b8b32cd9df398: 58 jobs passed. The sole root failure ischecks-windows-node-test-3(job110789358773), followed by the aggregate CI gate. Both failing cases are source/compiled TUI subprocess expectations intest/scripts/vitest-worker-artifacts.test.ts. This is deterministic fixture drift from main’s error-copy change in #163381 (d0b48d63efb88ac4f9f5eb447a39ea95cb2b0542), not an approvals failure or a flake.The checkout log identifies tested merge
3565a1cccfefa29363390c74484ef79e2fd3da6d, with candidatefe980968and mainaa31aeef. The fixture blob is identical in both parents (2d7e03e0c7df2eb84ccbd9774f1d2b5811caa47d). Its generated child callsbuildEmbeddedRunPayloadsat line 672, which reaches the shared assistant-error formatter and fails the old wording assertion at line 673 before plugin activation. Main now returns the exact observed “Couldn’t sign in” guidance. No approval-policy read or migration is reached. The failing test and formatter owners are untouched by this PR. Landing uses the maintainer-authorized exception for proven inherited failures; the Windows fixture follow-up remains separate.