Repository navigation
refactor(secrets): run secret settings metadata writes in workers - #164020
Conversation
…ity overlap in configureGatewayForSetup; store-bound question callbacks need async authority)
Move ordinary settings metadata reads and set/delete/rollback through the shared-state workers. Await acknowledged persistence before settings and credential-question success, retain private question settlement across reset, and preserve exact-writer compensation and released synchronous SDK methods.
|
🦞👀 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. |
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. Reviewed October 3, 2026, 3:21 AM ET / 07:21 UTC (Revision 6). ClawSweeper reviewWhat this changesMoves secret-settings metadata reads and mutations into database workers and awaits persistence before credential answers, token configuration, and provider-auth publication. Merge readiness⛔ Blocked before merge - 1 item remains The worker cutover remains useful and is absent from current main. No actionable introduced defect was found; the previous migration-proof blocker does not apply because stored contracts are unchanged. Priority: P2 Review scores
Verification
How this fits togetherThe secret store holds credentials and environment settings used by Gateway configuration and providers. Settings requests now use the existing database workers before publishing acknowledgments or refreshing runtime credentials. flowchart TD
A[Settings and credential requests] --> B[Capture store and caller authority]
B --> C[Database worker]
C --> D[Check authority before commit]
D --> E[Existing secret store]
E --> F[Acknowledged result]
F --> G[Safe answer and runtime refresh]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +479, Tests +301, Docs +8, Other +17. Total +805 across 63 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use the existing database workers while preserving committed outcomes, current caller authority, and released synchronous question contracts. Do we have a high-confidence way to reproduce the issue? Not applicable to a reported bug: source confirms synchronous metadata access on current main, and the PR records worker-boundary validation. This read-only review ran no target tests. Is this the best way to solve the issue? Yes. Reusing the existing reader and writer owners, with awaited acknowledgments and unchanged stored contracts, is a focused solution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e17e653e8dea. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
Await protected credential seeding before Gateway startup closes parent-side database admissions. Keep the Gateway worker inventory sorted for canonical CI and CLI selection. The original routing failures reproduced in five runs per file and passed five times per file on the merge base. The corrected tooling tests pass all 533 cases; changed-file checks and P2 review are clean.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Merge current main to resolve the structuredClone dispatch conflict. Retain main consolidation and include secrets.metadata in the captured command group. Affected worker and routing proof passes 544 tests. Full P2 review completed; the suggested post-revocation refresh change was not accepted because refresh includes retention and runtime activation, while committed-answer recovery explicitly requires a later authorized secrets.reload.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Resolve the concurrent ErrorIdentity union additions by retaining both secret-store-validation and session-goal-operation. Focused worker/error tests pass all 61 cases; core and state types, formatting, lint, and fresh full P2 review pass.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Retain the shared mutation response helper from main, await the worker mutation before recording a committed outcome, and preserve current authority before runtime refresh. Existing set/delete response and recovery semantics remain unchanged. Affected secrets handler/lifecycle tests pass all 20 cases. Core and Gateway-method types, targeted lint/formatting, and fresh full P2 review pass.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…enclaw#164020) * wip(secrets): settings metadata worker cutover (parked: openclaw#150992 security overlap in configureGatewayForSetup; store-bound question callbacks need async authority) * refactor(secrets): finish worker metadata cutover Move ordinary settings metadata reads and set/delete/rollback through the shared-state workers. Await acknowledged persistence before settings and credential-question success, retain private question settlement across reset, and preserve exact-writer compensation and released synchronous SDK methods. * test(secrets): await fixture writes and preserve worker routing order Await protected credential seeding before Gateway startup closes parent-side database admissions. Keep the Gateway worker inventory sorted for canonical CI and CLI selection. The original routing failures reproduced in five runs per file and passed five times per file on the merge base. The corrected tooling tests pass all 533 cases; changed-file checks and P2 review are clean.
What Problem This Solves
Ordinary secret settings metadata reads and set/delete/rollback operations still execute SQLite on the Gateway thread. Moving them into workers also requires preserving save-before-answer ordering for store-bound credential questions and save-before-config ordering during token provisioning.
Why This Change Was Made
Use the existing shared-state writer and lazy reader registry. Capture the physical store and inputs before yielding, recheck host authority at transaction and commit, retain exact-writer rollback, and register transferred secret values with the host redaction owner. Prepare the existing lazy secret schema once per admitted database backend before its first ordinary write.
Await persistence through settings RPCs, provider persistence, CLI/Doctor callers, and token provisioning. Store-bound questions publish their safe
storedmarker only after acknowledgment. Reset immediately hides in-flight entries while their private settlement remains owned, so completion cannot affect a replacement using the same ID.User Impact
No schema version, stored format, retention, configuration, or update-contract change. Runtime value/exec reads, hidden GitHub credential operations, and the CLI-only allowed-host setter retain their existing owners. The merged onboarding trusted-proxy/Funnel protections remain intact.
Production: 31 files, +856 / -377, net +479; 1,233 changed lines. Original-base static main-thread SQL measurement: T1 1,339 → 1,331 (-8). This is a placement count, not a latency benchmark.
Released SDK surface check: compared with
v2026.9.7and rechecked against the newerv2026.9.8tag during landing. The transitively exportedQuestionManager.resolve()andreset()remain synchronous with their released signatures; the internal async path is additive. Other changed synchronous helpers are not exported through released SDK/runtime surfaces. No compatibility adapter or deprecation record is needed for an unchanged released signature.Coordinator-approved incidental overlap with #163945 in shared-state read-command plumbing. The validator change only adds the new command case in the existing style; it does not restructure the validator.
Evidence
pnpm test <changed test files> --maxWorkers=1; 839.18 seconds wall time on the loaded host.6aa12006ff81ee0ba2c72eaafc41ea196c8600e7. Original validation recorded the environment-name budget at 477/477; this PR introduces zero new names.pnpm buildpassed, including SDK exports and runtime-load verification: 1,456.49 seconds wall time. It emitted a nonfatal UI startup gzip diagnostic of 373,475 B versus 373,454 B (+21 B); this PR does not modify UI sources.node scripts/check-changed.mjs --base 6aa12006ff81ee0ba2c72eaafc41ea196c8600e7passed: 1,130.90 seconds wall time. Full core lint reported only three pre-existing max-lines warnings in untouched files; runtime import cycles were also zero.Initial validation exposed and repaired WIP import/schema omissions, test routing for the host-owned broker, and a provider assertion that needed to check the preserved revocation cause.
Landing validation
Initial CI run 37095271879 exposed two PR-caused test integration omissions. The new Gateway database-worker inventory entry was not alphabetically ordered, breaking the CI planner and CLI ownership assertions. The managed-auth real-Gateway fixture also needed to await the now-asynchronous credential write before startup closes parent-side database admissions. The landing correction
94dc8bd33662a04eb15ccdad5121de4d810f11a1changes only those two test files and preserves all assertions.Both tooling files failed consistently in five single-worker runs on the approved head, while each passed five times on merge base
6aa12006ff81ee0ba2c72eaafc41ea196c8600e7. After the ordering correction, the two files passed together: 533 tests, 147.99 seconds wall time, usingnode scripts/run-vitest.mjs test/scripts/ci-node-test-plan.test.ts test/vitest-cli-ownership.test.ts --maxWorkers=1. The two-file correction received a fresh P2 Codex autoreview with no accepted/actionable findings.ClawSweeper completed the approved-head review without a correctness or security finding. Its data-model compatibility checklist was triggered by Doctor path changes. Those hunks only await the existing metadata reads; no schema or migration file, stored representation, retention, or update contract changes. The existing Doctor/token-repair regression proof and full build are recorded above.
Changed-file validation for the two-file correction passed in 302.50 seconds: formatting, all root test typecheck shards, lint, common guards, and dead-export scans. No new test cases or production changes were added.
The real-Gateway comparison completed on Blacksmith Testbox; detailed results are recorded below.
Main integration
The corrected head
94dc8bd33662a04eb15ccdad5121de4d810f11a1passed CI run 37096767018, including all three previously failing Node jobs. Main then introduced a real conflict through the state cleanup in0146d9b7ac1b7. Merge commit76c039e613931905e2022d579636660c5df99b2dincorporates main8bb7fb2f0fb33fbb74ede9243f4488a9b10a354fwithout rebasing. The resolution addssecrets.metadatato main's consolidated structured-clone command group; the managed-auth fixture and secret mutation implementation remain unchanged.Affected integration proof passed: 544 tests across the secret metadata worker, shared-state read worker, CI planner, and CLI ownership suites, in 204.66 seconds wall time. The earlier successful CI run remains prior-head evidence; that merge head subsequently passed CI run 37098061123.
Full P2 review of the merged candidate raised one suggestion: refresh runtime secrets after an acknowledged write even if caller authority has expired. This was not accepted:
reloadReferencealso performs retention writes and runtime activation, so these follow-up effects retain the existing current-authority boundary. The documented committed-answer recovery contract preserves a successful save as terminal and reports an unavailable refresh with instructions to retrysecrets.reload, rather than resubmit the answer. The guards and that recovery behavior remain intact.Blacksmith Testbox baseline managed-auth E2E comparison passed five times at the pinned original merge base. The original head failed five times with the same missing-secret and read-admission-closed errors; the single-await repair then passed.
Final validation and review
Blacksmith Testbox run 37097133490 reproduced the managed-auth flow using
node scripts/run-vitest.mjs test/system-agent-managed-auth.e2e.test.ts --maxWorkers=1: baseline 5/5 passed, original PR head 5/5 failed, and only the missing await added: passed. The returned fixture bytes match this PR's repaired fixture. Warm baseline runs took 33.902–34.641 seconds, warm original-head runs 32.221–32.521 seconds, and the repaired run 34.550 seconds (7.438 seconds test-body time). The first baseline and original-head invocations included fresh runtime builds, taking 605.160 and 561.403 seconds respectively. The remote command exited successfully, and both task-owned leases are stopped.Head
76c039e613931905e2022d579636660c5df99b2dpassed complete changed-file validation in 1,621.04 seconds, including all core test type graphs, storage/schema guards, lint, and zero runtime import cycles. Main advanced again during validation, producing one concurrent type-union conflict. Merge commit3336b68e006cce24e1455ba41636d4ec6d14e04eincorporates9d5c37cf80a9bf6c50833c405f0ae5a5b31298a1without rebasing and retains both the secret-store validation and session-goal error variants.Second-merge affected proof: 61 tests across three worker/error files passed in 317.81 seconds; core and state test types passed in 58.99 seconds, with formatting, targeted lint, and diff checks passing. Fresh full P2 Codex autoreview of this candidate is scoped-clean, with no accepted/actionable findings. Earlier valid proof is retained for unchanged inputs; the published merge head receives fresh required GitHub CI.
Gateway cleanup integration
Head
3336b68e006cce24e1455ba41636d4ec6d14e04epassed CI run 37100621968 with a successful overall check rollup. Main advanced during native preparation and introduced an incidental overlap with the merged gateway cleanup #163919 (cd09e8848e785). Merge commit795a76bf2c1ed52b9aa2d4647b3b5c2bb87c6581incorporates main1fa3920cb54f12798948da2f3684c8c293fc07e8without rebasing.The resolution retains main's shared mutation-response helper. Its private callback now awaits the worker mutation, records a committed result only after acknowledgment, and applies the existing current-authority check before refresh. Set/delete keep their existing error messages and distinguish failed persistence from a committed write whose refresh cannot proceed. Public handler and released SDK signatures are unchanged.
Affected proof: 20 secrets handler/lifecycle tests passed in 380.67 seconds (cold compiled-worker preparation included); core and Gateway-method types passed in 46.37 seconds. Targeted lint, formatting, and diff checks passed. Fresh full P2 Codex autoreview is scoped-clean, with no accepted/actionable findings. Previous proof remains valid for unchanged inputs; current-head required CI is enforced by native landing.
Independently inherited CI failure
Final-head CI run 37103925805, attempt 1 has one failed test job (
checks-node-changed-compact-small-5, job 111148878370) and its downstream CI aggregate. All other jobs passed or were intentionally skipped, includingsecurity-fast; no jobs were cancelled. CI remains recorded as failed.The sole root is 21 failures in the unchanged
src/flows/doctor-health-contributions.test.tsfixture. Its mocked config snapshots omit requiredsourceConfig; main's webhook migration changec7c937abfea22(#162759) dereferences that field before the Gateway-auth contribution this PR changes. The exact 21-case set reproduced in 5/5 PR-head runs, 5/5 merge-base runs, and an actual current-main run at843c05384d66d16f237786e51a95ff46c233f873. The test, snapshot-projection owners, ordering/support files, package manifest, and lockfile are byte-identical between CI's main parent and tested merge; the primary failing sources remained unchanged through checked maine52c9a89197f4ce00507386e6c6443bec6eb2a1d.CI checked out
e1b8868e805921bd90919bcae1137e9f4d069f9b, whose ordered parents are main7d2e0fded0ad4ae04770c8d1b587e39f0fa18fd6and PR head795a76bf2c1ed52b9aa2d4647b3b5c2bb87c6581. Its tree was independently verified against Git's merge of those parents. Native landing will use the explicitly authorized pre-existing-failure admin route with hashed logs, exact cases, source identities, checkout binding, and scoped passing proof. This is an inherited-fixture exception, not a claim of green CI.