Repository navigation
refactor(secrets): move providerless refs to Doctor - #163350
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 3, 2026, 10:50 AM ET / 14:50 UTC (Revision 15). ClawSweeper reviewWhat this changesThe branch moves normalization of secret references missing a provider into Doctor, makes core readers require canonical references, and preserves published plugin SDK input adapters. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 5 items remain This PR remains useful, but the previously reported Talk credential-preservation defect is still present. The recorded update, Gateway, and SDK evidence is valuable; it does not resolve that migration-order bug. Priority: P2 Review scores
Verification
How this fits togetherSecret references connect configured credentials and stored auth profiles to OpenClaw's secret providers. Doctor prepares older persisted inputs before Gateway and agent runtime readers consume them. flowchart TD
A[Existing configuration] --> C[Doctor repair]
B[Stored auth profiles] --> C
C --> D[Backed-up canonical state]
E[Plugin SDK writes] --> F[Input normalization]
F --> D
D --> G[Runtime secret resolution]
G --> H[Gateway and agent credentials]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +151, Tests +233, Docs +22, Other -2. Total +404 across 76 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: Doctor should preserve legacy Talk credentials through every earlier normalization step and persist their canonical references using the existing backup owner. Do we have a high-confidence way to reproduce the issue? Yes, from source: pass a providerless apiKey object in either Talk provider map through normalizeCompatibilityConfigValues; Talk normalization omits it before SecretRef migration. This read-only review did not execute that path. Is this the best way to solve the issue? The ownership direction is sound, but the current patch is incomplete: keep runtime parsing strict and repair preservation in Doctor's complete migration pipeline. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against df346f5729d0. LabelsLabel 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 (14 earlier review cycles; latest 8 shown)
|
b8a8edb to
042de6a
Compare
64b687b to
8660640
Compare
|
* refactor(secrets): move providerless refs to Doctor * fix(secrets): preserve public input adapters during canonical cutover * fix(secrets): guard extended refs before auth writes * test(doctor): use real SecretRef target discovery * test(doctor): inspect grouped SecretRef repair notes * test(secrets): split focused SecretRef migration coverage * refactor(secrets): separate credential decoding and save preparation * chore(config): drop stale persisted-auth line exemption * fix(secrets): canonicalize migrated credential variants * chore(config): prune retired SecretRef assertion allowance * refactor(secrets): distinguish canonical core resolvers * refactor(auth): bind normalized credential locally
What Problem This Solves
Runtime readers still supplied missing providers for legacy SecretRef config and auth rows. The published 2026.9.7 SDK can write providerless auth refs, so deleting those readers requires a durable migration. A providerless ref with extra fields also exposed a repair bug: adding
providerwhile retaining the extra fields produced an object rejected by the canonical three-field parser.User Impact
Doctor now owns normalization of registered legacy credential inputs. Config credentials receive their source-specific configured provider; stored auth refs retain their historical
defaultprovider independently of config defaults. Core runtime consumes canonical refs and supported environment shorthand. Active providerless core inputs require Doctor; opaque plugin data and inactive missing-plugin inputs stay intact. The generatedmodels.jsonenvironment-marker contract remains unchanged.Registered providerless refs containing extra fields normalize to exactly
source,provider, andid. Doctor reports the normalization without logging removed values, and existing config/database backup or source-archive owners preserve the original bytes before writing. Opaque neighbors, other auth-profile fields, and rotation state remain intact. Repeated repair is idempotent.Public SDK input coercion and string-read contracts remain compatible, including configured-input resolvers, channel collectors/builders, and unknown-valued web-provider credential callbacks. Public auth save/updater/upsert boundaries canonicalize supported providerless refs before persistence and runtime snapshot publication. New SDK writes of extended refs fail before mutating caller input, persisted rows, or published snapshots; the error tells callers to preserve metadata separately and explicitly invoke the unchanged public coercer. No public entrypoint or export is retired, and no schema is widened.
Manifest config signals use their documented presence contract for opaque nonempty objects instead of guessing that undeclared
source/idmetadata is a SecretRef. Canonical refs still require provider/environment availability. The main-only storage callback also consumes canonical refs; storage locations postdate 2026.9.7.Why This Change Was Made
Providers were introduced by
4e7a833a24eon 2026-02-25, but a supported published SDK writer still emits providerless refs. Their migration therefore remains supported under the retention policy. Node-host Cloudflare Access has canonical write ingress since its 2026-08-17 introduction (2d3aaaa0d59) and in 2026.9.7; removing provider filling there changes no supported stored bytes.Auth repair reuses #162958 (
9b0a90e3b9e): ordinary field repair runs with an empty alias map, verifies its SQLite backup, and revalidates database generation/raw preimages before writing. Config marker normalization moves intosrc/commands/doctor/shared; the lg-doctor owner remains responsible for persistence and backup. There is no parallel migration scaffold.The rebase preserves main's overlapping owner changes: #163974 keeps existing named channel accounts and shared root policy/token, while #164019 retains cast-free persisted-store construction and the simplified external-profile save condition. Parsing, local-save shaping, and Doctor config metadata have focused owners; lazy external lookup and backup/report ordering remain intact.
Production against rebased base
5f6ee754f6f17978651e5c19d6001c5d8901de91: +648/-497/net +151 across 55 production files undersrc/**andextensions/**, excluding tests, test support/helpers/utils, e2e, and fixtures. Retained public SDK adapters and durable normalization safeguards account for growth. Commitd39c08bdb7da364546879bacb5fd9113afaf8c6eremoves only the obsolete assertion-baseline row for the deletedsrc/secrets/legacy-secretref-env-marker.ts. Follow-upe1e2bd8ad9c05c2b6889c2532584a26a54abfeccgives internal canonical resolvers distinct names and cuts over all five internal callers, SDK imports, and the core test. Public SDK names and behavior remain unchanged; no internal compatibility aliases or guard exceptions are added. Final64b687b838b1bb67b705b618014dd321948b2f58replaces credential parameter reassignment with an equivalent local const; no behavior or assertions change.The branch was rebased onto
5f6ee754f6f17978651e5c19d6001c5d8901de91because GitHub reported a real conflict. Current head is8660640dccf68196065e3e3f70fa23de3f6588f1. Eleven of twelve patches are identical; the remaining range-diff changes only extraction context. Main's #164240 moved the auth runtime AsyncLocalStorage intoruntime-scope.ts, so the resolution preserves that shared singleton and personal-account guard while retaining this PR'sstore-save.tsoptions owner. Main's snapshot-clone ownership, protected-store worker reads, and Doctor retired-sidecar preflight remain intact. The resolution passed a fresh independent P2 review.The successful package/update/Gateway cells below retain their exact
64b687b…source identity. They are not executions on the rebased head. Source comparison shows no main changes in the strict SecretRef type parser, profile credential resolver, runtime preparation, or auth-ref collector owners. The original update cell used env refs and no authored includes, webhook migrations, or retired OAuth sidecars. Focused new-head proof checks the shared-owner integration instead of repeating the full install/update campaign.Evidence
Rebased-head focused proof passed at
8660640dccf68196065e3e3f70fa23de3f6588f1against base5f6ee754f6f17978651e5c19d6001c5d8901de91: 188 tests across seven suites, core typecheck, full SDK API report, and SDK surface budget. Producer: Hetzner leasecbx_53d53730992c, native runrun_97f32c587de948cb03caf1af6552e1bb. The fresh-clone/frozen-install phase took 510.10s; native command wall was 517.021s. All 14 recorded commands, including preparation, exited zero. Downloaded artifact SHA256eecc14833592e066bd5edf41e4045b1a400c7ab1d17fa19480285c71d9eaea81and exact SDK evidence SHA256a91b68e232cd1d6871f32cd6111800949b63b730ef8d5140d4105b379e56a13ewere independently checked.src/agents/auth-profiles/persisted-boundary.test.tssrc/agents/auth-profiles/store.async-read.test.tssrc/plugin-sdk/provider-auth-write-compat.test.tssrc/agents/embedded-agent-runner/run/auth-profile-personal-usage.worker.test.tssrc/secrets/runtime-state.test.tssrc/secrets/runtime-state.store-refs.test.tssrc/commands/doctor-auth-flat-profiles.test.tsPer-file commands were
pnpm test <file> --maxWorkers=1, totaling 231.94s wall.pnpm tsgo:corepassed in 14.35s, SDK report generation in 214.98s, and SDK surface check in 5.68s. The full new report retains the same 194 affected export identities: 190 reachable-declaration effects and four signature-text changes, with no entrypoint/export additions or removals. The four wrappers retain the same parameter/result contracts. Compared with the approved prior-64 report, main's internalresolveRuntimePluginRegistryconst-to-function declaration is the only new unique internal pair difference; the webhook handler type andmemoryFlushToolsdeclarations changed identically on both sides of the report, so they are not changes introduced by this PR.The maintainer personally inspected the full report and approved digest
98cf306eec6c049352635a135212ec840046982d55a81192d0e24bc60db15e05, bound to the exact evidence-file hash above. Native canonical SDK acknowledgement passed with prefix98cf306ein Hetzner runrun_b9e4892fc7d4deb2ce3a53f197356a7eon leasecbx_53d53730992c. The existing release-evidence owner checked the immutable report in 0.22s (5.899s native command), preserving its original producer and exact bytes; no report regeneration was needed.Canonical check coverage is complete for the reviewed scope: 11 remaining commands passed on final
64b687b838b1bb67b705b618014dd321948b2f58, retaining 28 earlier passing gates with their original e1e provenance. Final producer: Hetzner leasecbx_2bd50ab12012, native runrun_35a48d22cc2790f899661ca651dbe0e2. The final checks phase took 1,073.39 seconds, including preparation; the remaining-command runner took 1,025.34 seconds. All 11 native exit codes were zero.The continuation verified the exact two-line e1e-to-64 source diff, original native plan/log/source hashes, all 28 prior successes, and equality of the fresh plan except for its head. It used the repository's plan builder, command environments, package-manager wrapper, and managed-child lifecycle for core/extension/script lint and the remaining schema/storage/media/sidecar/import-cycle/webhook/auth guards. The original e1e check phase still records its
no-param-reassignfailure; that was repaired with a local const. Neither the retained gates nor their original failure status were restamped as a new full-check run.The prior-64 SDK API report and surface check passed in 276.00 and 7.70 seconds in the same native run. The full diff JSON is identical to the reviewed e1e diff: 194 affected exports, comprising 190 reachable-declaration effects and four signature-text changes, with no entrypoint/export additions or removals. The prior-64 digest was explicitly approved:
3afc44a22d6c5d93386365cab45c8ac3e3041a9c2bf6515362620ed1d4d17898. The exact prior-64 evidence-file SHA256 is18a1a7c4870e2a33c8679bf52e9a26853849edc99242ec0dd1d1264945445ffd, binding that report to its recorded 64 head/base/workflow. The rebased head receives a separate fresh report and acknowledgement.Behavior proof and measured cost
At
e1e2bd8ad9c05c2b6889c2532584a26a54abfecc, the two affected resolver suites passed 26 cases: 23 core configured-resolver cases and 3 public SDK SecretInput cases. Producer: Hetzner leasecbx_2bd50ab12012, runrun_ded4cd3f6841d5f5a8dfe4043518fd01. Command walls were 28.71 and 29.80 seconds (Vitest 25.00 and 26.69 seconds), for 58.51 seconds summed command wall and 123.23 seconds including preparation. The final local-binding correction preserves those results under their original source identity; neither suite is replayed.Native proof at
042de6ac731b78c6a94e5e97121a95f589892465: 178 passing tests in seven affected files. Producer: Hetzner leasecbx_2bd50ab12012, runrun_bdd8354e16a73eada1d2bcedb2f9ff67. Per-file commands werepnpm test <file> --maxWorkers=1; their wall times sum to 269.40 seconds. The complete test phase, including fresh fetch and frozen install, took 314.11 seconds.src/agents/auth-profiles/persisted-boundary.test.tssrc/plugin-sdk/provider-auth-write-compat.test.tssrc/commands/doctor-legacy-config.migrations.test.tssrc/commands/doctor-legacy-config.secret-inputs.test.tssrc/agents/auth-profiles/store.async-read.test.tssrc/agents/auth-profiles.sqlite-store.test.tssrc/agents/auth-profiles/profiles.test.tsAnother 131 cases retain their original c45 source attribution (
c45fd8a12a0c3080df941806c2172b653add0a2a): runtime-state 62, store refs 1, Doctor flat profiles 68. Their producer was Hetzner leasecbx_82ecc3069e04, runrun_c4ffafdd3284ab92c1089fcad2aee6b2; command walls were respectively 34.37, 22.38, and 74.36 seconds. These results cover retained contracts and are not claimed as executions on the final head. No passing suite was rerun after a baseline-only change. These are remote command costs, not hosted CI seconds; CI cost is not yet recorded.The extended-ref regression ran against old production
b8a8edbe1b759627f99f8a2edf74125f2636dd47, with only the final SecretRef test file applied after a frozen install. Its four source cases all failed with the intended four-field-versus-three-field mismatch; the two marker cases were excluded by name selection. Command wall was 30.41 seconds. The repository's credential reporter redacted stack coordinates after thesecret-inputsfilename, so the original validator could not match the literal line. A reviewed read-only reconciler bound the exact saved artifacts, source, native IDs, messages, and zero infrastructure errors, and passed in native runrun_d76ee7dd7fe534118da20a17cc3a1500(19.377 seconds). It preserved the original test/validator exit codes and failed phase status. No test rerun or assertion weakening was used.Earlier deterministic fixture defects were repaired at their owners: a replacement registry enumerated only Discord tokens and hid model-provider targets, so the obsolete 55-line mock was removed; an auth migration assertion now splits grouped note blocks before applying its original exact-count/message checks. No retries, longer timeouts, or broader mocks were added.
Update Behavior
The genuine published-driver npm update succeeded. Native run
run_ff152ebc77f76ff720f7506190e84100on Hetzner leasecbx_2bd50ab12012installed published OpenClaw 2026.9.7 with npm 11.17.0, created the agent through the published CLI, wrote two legacy config markers and an extended registered config ref through that CLI, and wrote two extended providerless auth refs through the published SDK. The installed driver then ranopenclaw update --yes --no-restart --tag file:<sealed-candidate.tgz> --jsonto prior candidate64b687b838b1bb67b705b618014dd321948b2f58. The application update26fc6a21-b9c9-40b9-a165-0dc17c05584creportsstatus: ok, npm mode, and a succeeded application update record. Package installation/swap and candidate state, Doctor, config, plugin, recovery, and startup checks passed with the unchanged 50,000-entry integrity limit. Update command wall was 452.04 seconds; its internal JSON duration was 357.339 seconds. The original cell phase took 541.26 seconds (native command 550.333 seconds).The prior-64 package was built and sealed in native run
run_b659421ecbc4472162e75c9eb30931a3on the same lease. Build wall was 706.30 seconds, package wall 90.04 seconds, and complete package phase 843.97 seconds. Tarball SHA256:eb07d83dfd944ad1db1c2f040d5c454270ecd1e251cc2f5ad4346779689d383d; sealed build-info SHA256:bdcfea6f6cd51bd022697ee83e25a1f8da0e80b63b00d55b533a5d4eeed965ff. The continuation also uses the repository's existing upgrade-survivor package-identity owner to compare installedpackage.json,openclaw.mjs, and the completedistinventory against this sealed artifact. npm retains ownership of dependency reification.After the successful update, the original proof cell failed because its expected config omitted Doctor's documented wizard provenance. A reviewed continuation,
run_07f71328950cfbe125e909d3fb42d4c5, passed complete config/raw-row/backup verification and public SDK compatibility checks in 0.34 and 0.82 seconds. The expected wizard object has exactly the four observed fields: canonical ISO timestamp within the original update interval, sealed candidate version, commanddoctor, and modelocal. Whole-config equality remains exact elsewhere. It verified source-specific config provider defaults, auth refs' historicaldefaultprovider, exact original config and auth-row backups, untouched opaque neighbors and health/rotation rows, all three public configured resolvers, and the public channel collector.The continuation then exposed a second fixture gap: it called the runtime credential reader without activating Secrets. Both base and candidate correctly reject an unpublished SecretRef; the runtime contract requires eager materialization. A subsequent real-Gateway attempt,
run_a26ca8604433c9d35245b96937a142b4, reached health and shut down cleanly but its service-only probe never ran because its manifest omitted the documentedactivation.onStartup: true. Its failed runtime wall was 315.02 seconds, with no assertion timeout increase. The reviewed correction adds that one manifest field. Runtime uses a separate copied config enabling the synthetic service, the same migrated persisted auth store, and public SDK credential APIs after actual Gateway activation. No inline credentials or fabricated snapshots are substituted. It preserves caller input, raw rows and the actual published snapshot when rejecting an extended write, then joins graceful shutdown before full Doctor and exact original-config/backup idempotence checks.The corrected runtime and remaining update proof passed in native run
run_cdf9abc8ec5c1ed142ad122a1b0d1e6fon the same lease. All six phases exited zero. Admission verified 11,446 installed application files against the sealed package. The real Gateway reached health, its normally activated synthetic service resolved all three persisted credentials and proved extended-write rejection left caller input, durable rows and the Gateway-published snapshot unchanged. Every owned command joined, SIGTERM required no escalation, and the native port claim was released. The original config, raw credential/health rows, backup list and every original backup hash matched the retained checkpoint both after Gateway shutdown and after fullopenclaw doctor --fix --non-interactive, including the exact previous wizard timestamp. Doctor completed with nonblocking isolated-fixture diagnostics; these were not converted into a claim of warning-free operation.Command walls: admission 3.03s, Gateway runtime 15.72s, preservation 0.32s, full Doctor 15.96s, final idempotence 0.32s, and original-evidence preservation 0.04s. Inner continuation wall was 35.55s; native command wall was 42.041s. Downloaded result archive SHA256 is
ec1de3a9d179ddc2d832cb876d5fed156dc83c96a9fe54b47c5c4d6c1c59e11c, independently checked before artifact inspection. The failed manifest-omission run remains failed and is not claimed as this successful execution.All prior failed statuses, original successful update receipts, and completed verification/SDK results remain hash-bound and attributed to their original native producers; install/update and passing tests are not repeated or restamped. The earlier stderr admission failure is preserved separately: the completed original stderr differed from its early progress capture only by
/usr/bin/time's final 35-byte timing suffix, and admission now pins the exact final hash.The separate pnpm attempt remains a limitation: native run
run_3ab8ed6dac8e91dda6b86b5af5127396failed after candidate checks passed. A confirmed secondary rollback defect in published 2026.9.7 resolves its database-generation worker against the old physical pnpm installation path after replacement, becauserestoreUpdateDatabaseBackupomits the active root when callingreadUpdateDatabaseGenerationsIsolated. The initiating failure was not retained in the original run ledger and remains unknown; the missing rollback worker is not claimed as its primary trigger. No product workaround or package-integrity limit change was added to this PR. The genuine npm route above supplies the successful published-driver update cell.Product changes and each corrected proof capsule passed independent Codex P2 review. The payload-attribution finding was addressed through the existing package-identity owner; broader dependency re-auditing was rejected in favor of npm's established ownership. Original findings and failed proof statuses remain preserved. No local test, build, or typecheck result is claimed.
Native proof and review gates are complete. Rebased-head integration tests/types/API/surface and canonical SDK acknowledgement passed; exact-head hosted CI and merge remain pending. Package/update/runtime evidence retains its proven prior-64 producer and source attribution; earlier tests and checks retain e1e/042/c45/64 identities. The pnpm initiating failure remains the explicit limitation above; no pnpm success or local test/build/type result is claimed.
Exact-head CI and inherited UI timeout
CI run 37130698716 executed merge
89db55238d766e1b420ded69527f32b7bdfca5dd, whose verified parents are mainb94391aa2c5a6e248ea60848cee6394759187f94and this exact head8660640dccf68196065e3e3f70fa23de3f6588f1. Full job pagination records 81 successful jobs, 19 skipped jobs, and two failures: UI E2E 2/9 and its aggregateopenclaw/ci-gate. No jobs were cancelled.security-fastpassed; the separate Security Review publisher completed successfully and projected the CI failure.The UI job took 424 seconds and reported 82 passing files/392 passing cases, with one 120-second timeout:
github-link-hovercard.e2e.test.ts, “waits silently while pending, then shows the result (dark, reduce, 390, fails=true).” The stalled await is not identified; a passing replay is not claimed as a fix.This is a source-excluded failure, not a SecretRef regression. The entire UI tree,
test/helpers/qa-gateway-cleanup.ts,src/gateway/control-ui-contract.ts, andsrc/shared/control-ui-link-reader.tsare byte-identical between the tested merge and its main parent. The test suppliesTEST_LINK_READERand deferred syntheticforge.preview(github-link-hovercard.e2e.test.ts:95–116);control-ui-e2e.tsdefaults passthrough prefixes to empty and replaces WebSocket, whilecontrol-ui-e2e-controls.ts:108–117rejects the deferred result throughpage.evaluate. No actual Gateway, auth store, plugin-manifest credential reader, or changed SecretRef parser runs in this flow. The only UI consumers of the changedtypes.secrets.tsimport the unchangedENV_SECRET_REF_ID_REfrom the untouchedsecrets/ref-contract.ts.Landing uses the maintainer-authorized pre-existing-failure exception at the pinned head. The timeout remains an explicit follow-up: no matching fix was verified. Exact reproduction inputs are retained as 688 ordered includes, Vitest shard 2/8, three workers,
--configLoader runner, and real-Gateway tests disabled; the job's 2/9 label is not the executable shard count. No CI rerun, retry, longer timeout, or weakened assertion was used.A separate bounded native comparison ran the original 688-entry selection through Vitest shard 2/8, with 3 workers and the original config loader, assertions, and timeouts, once on clean main
6d05367678fbd3b8f01040eb565184d77b257aafand once on the exact CI merge89db55238d766e1b420ded69527f32b7bdfca5dd. Both passed 393/393 cases across the original 83 files, with no selection drift. The formerly timed-out hover-card case passed in 1.095 s and 1.107 s, respectively. Shard process wall times were 369.35 s / 367.97 s; the complete native command took 858.780 s. Producer: Hetzner leasecbx_53d53730992c, runrun_fc294ff338225957045ca26ad6325da2; retrieved evidence SHA25604658f802fdb5ac2efd340fa5c9991a1c7ec53b12f8b41919cbf1dc0c6123aafwas verified. These are single diagnostic runs on unchanged sources, not a repair or repeated-run campaign. The original CI timeout remains recorded, and its stalled await and root cause remain unresolved.