Repository navigation
perf(secrets): route GitHub and setup credentials through workers - #169633
Conversation
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # docs/reference/database-schemas/worker-access.md # scripts/database-worker-inventory.mjs # src/state/openclaw-state-db-read-admission.test.ts
|
🦞👀 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: needs real behavior proof before merge. What this changesThis PR moves GitHub credential maintenance and Model Setup credential activation and rollback into existing database workers. Example: Model Setup activates fixture:setup while another operation updates a neighboring credential.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 6 items remain Keep open: this maintainer-directed worker migration has clear value, but the previously reported refresh regression remains unresolved. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway OAuth, publication, and Model Setup owners consume worker-read credentials and committed receipts, then authorize credential-file writes or authenticated provider operations. flowchart LR
A[Gateway requests] --> B[OAuth and setup owners]
B --> C[Database workers]
C --> D[SQLite credential stores]
C --> E[Committed authority receipts]
E --> B
B --> F[Credential files and GitHub operations]
Technical reviewBest possible solution: Retain worker ownership and credential-local rollback while making publication authority survive legitimate token renewal without reviving disconnected or reassigned authority. Do we have a high-confidence way to reproduce the issue? Source tracing establishes the refresh failure: publication captures a guard, refresh commits revoke it, and the subsequent assertion rejects the unchanged selection; no target code was executed. Is this the best way to solve the issue? The existing workers and targeted credential compensation are appropriate owners, but publication must distinguish legitimate refresh settlement from connection revocation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6ae32d46e750. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No concrete authorization bypass was established, but the replacement credential guards require final-effect revocation evidence. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +378, Tests +151, Docs +16, Other +26. Total +571 across 51 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label 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 HistoryReview history (7 earlier review cycles)
Reviewed October 12, 2026, 6:36 AM ET / 10:36 UTC (Revision 8). |
…orage # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # src/config/sessions/session-accessor.sqlite-projection.ts # src/config/sessions/session-lifecycle-projection.worker.ts
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
…orage # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # src/agents/subagents/registry/subagent-registry-read-snapshot.ts # src/cron/isolated-agent/run-subagent-registry.runtime.ts # src/cron/run-continuation-cleanup.ts # src/cron/session-reaper.ts
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
…orage # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
…t1cut-misc # Conflicts: # docs/plugins/sdk-migration/how-to-migrate.md # docs/reference/database-schemas/worker-access-inventory.md # src/gateway/github-personal-publication.test-support.ts # src/gateway/github-personal-publication.ts # src/gateway/github-publication-personal-pending.test.ts # src/gateway/github-publication.ts # src/gateway/github-repository-publication.ts
|
…enclaw#169633) Move hidden GitHub record access to the existing shared-state worker and batch enumeration. Migrate bundled OAuth, status, and cleanup callers to async operations while deprecating the released synchronous SDK methods. Use the auth worker for focused Model Setup activation and compensation, preserving unrelated writes and current credential authority. Keep one check at each credential or publication effect. Validated with owner regressions, scoped formatting and lint, CI static and security gates, SDK API and surface reports, and isolated live SQL evidence. The inherited X hook allowlist failure is documented in the PR body.
What Problem This Solves
GitHub OAuth maintenance still opened SQLite on the Gateway thread. Enumeration listed names and then reread every value, and personal publication preparation repeatedly reread the same connection. Model Setup also activated and rolled back credentials by saving whole-store snapshots.
Hidden GitHub records now use the existing shared-state worker for reads, writes, deletes, and listing. Enumeration returns each name and value in one query. Bundled OAuth, RPC, and cleanup callers await these operations. Pure record naming is separate from the mixed SQL kernel. Released synchronous methods on
githubOAuthServiceretain their contract and emit deprecation warnings; bundled callers use the async replacements. The publication coordinator's separate V2 API cutover comes from the storage base and is preserved here.Personal publication preparation reads the connection in the worker and retains live authority through the existing in-process write receipts. Disconnecting, changing, or restoring the connection invalidates older preparations. Status presentation awaits the connection and lifecycle owners; its private formatter accepts prepared inputs and cannot fall back to synchronous SQLite. Credential-revocation errors retain the existing
identity_changedclassification, including before request insertion and when settling an already-observed push. Unrelated errors propagate unchanged.Model Setup activates and compensates only the selected credential through the existing auth worker. Rollback is awaited before runtime recovery and preserves neighboring credential and usage writes. Schemas, secret formats, retention, configuration, and update behavior are unchanged. This slice does not change updater, Doctor, migrations, plugin loading, or service lifecycle, so no new published-driver update cell applies.
Removed work and retained authority
Credential use, identity selection, token installation, and publication keep current-owner checks after awaited work and immediately before effects. Deprecated synchronous compatibility calls remain explicit inventory debt; the mixed kernel is not relabeled worker-only.
Scope and inventory
Final head:
aa7820a424049c075d87420350dfbc98bd8b08cc. Main742b62c61b43478efce98d4405862d5f2f973e0dis integrated; its only conflict was the generated worker inventory. Compared with that base, this PR changes 51 files, +1600 / -1029 lines (net +571). Added code separates worker operations from the retained SDK adapters and keeps status presentation with one owner.742b62c→aa7820a)The final group is five expressions in the mixed hidden-record kernel and one in the deprecated managed OAuth native adapter. The ordinary bundled path uses the shared-state worker. Static call-site counts are not executed statement counts. The final canonical inventory was regenerated on the merged tree and reports 628 files, 2391 expressions, 539 live T1 calls, and two compatibility calls. Final-head CI independently confirms the one-call reduction against integrated main; incoming main changes are not credited to this slice.
Evidence
Basic
oxfmt, scopedoxlint, andgit diff --checkpass. Two completed Codex reviews covered the repair and storage/credential integration. The integration review identified two confirmation calls missing awaits and an async return type needingAwaited; both were corrected. No new bookkeeping guards, fallback paths, or handshakes were added.CI found and drove repairs for typed connection-revocation classification, stale synchronous spies, missing list awaits, host-broker routing in tests, and unused synchronous readers. The activation fixture now waits for the actual credential-update owner to finish compensation, instead of the removed whole-store restore; its config, credential, and runtime assertions remain. Existing lifecycle tests await real provider entry using the existing deterministic gate, with no sleeps or retries. The removed synchronous reader's assertion-only callers now await the worker reader; compatibility tests still assert synchronous return values and receipt publication before awaiting their reads.
A local three-file publication test attempt was stopped before valid execution after mixed-version compilation overlapped the storage/main integration. It is not a pass or a proven product failure. Prior-head PR CI 38227677948 passed at
d3a1ba911803811d0640a858a3a8de6175b4b52f, including the repaired activation flow; prior-head results are not presented as final-head proof.All 44 source/test paths changed by this PR remain byte-for-byte identical to reviewed head
aaa973b9c4d8b166a67d8b9448c0fc29b1177ab1after integrating main742b62c61b43478efce98d4405862d5f2f973e0d. The only merge conflict was the generated worker inventory, resolved with its canonical generator;git diff --cached --checkpassed before the merge commit. The static and security results below target final headaa7820a424049c075d87420350dfbc98bd8b08cc. No broad local rerun is claimed for the conflict-only integration.aaa973b9: all jobs passed or skipped except the untouched Doctor timeout and its aggregateopenclaw/ci-gate, described below.742b62c→aa7820a: 192 affected exports, acknowledgement digest5be8be8c, and[ok] plugin-sdk:api:diff. Its artifact was uploaded successfully. The enclosing job concluded cancelled; that status is not reported as a job pass.openclaw/security-sensitive-reviewalso passed in run 38235285037. Main-tier security-fast passed; CodeQL concluded neutral.The plugin contract suite's sole failure is
boundary-invariants.test.ts > keeps bundled plugin typed hook registrations on an explicit allowlist: current main addedextensions/x/src/work-origin.tsineb0fc57d6ed55b65be3a10c644375bf8b4d23968without updating the allowlist. Both the fixture and the X module are byte-identical to merged main and untouched by this PR. The identical assertion and missing X path fail on main run 38226928416, job 114736774242 at292a9887dbbf0cd1e1439b07a1c6a608abadc690(831 passed, one failed). This is an inherited exception; no unrelated fixture allowance was added here.The final-head dependency job passed Knip with zero entries in every file/export scan. The architecture job passed both import-cycle checks (zero cycles), including Madge, and the database guardrails. Earlier Knip findings for
gateway-prewarm.mjsandrenderPublicSessionCardSvgalso occurred on main, but no Knip exception is needed. This slice adds no budget increases or blanket exclusions.The automatic PR run timed out after 30 seconds in the untouched
doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts > runs legacy state migrations in yes mode without prompting; its four sibling tests passed. The same timeout was observed on the earlier credential head. This is recorded as an unresolved test timeout, not a proven inherited failure or product regression. No timeout was raised and no test was weakened.SQL measurement
One isolated live pair compares baseline
70bfdc2b58e42f02af5bdc4d345875a9e6ad3928with measured candidatec46015ecfe18b63b95008b602f1d3f7349c1eda0. This is combined campaign evidence, not an isolated measurement of either stacked slice. Later CLI cold-loading, unused-reader, fixture/type, and merge-metadata changes are outside the measured pin; reuse depends on the lead's source comparison showing that the exercised Gateway SQL paths are unchanged. The workload does not prove those unexercised CLI paths.Warm values cover ten turns within each run; ranges are turn ranges, not confidence intervals across repeated runs. The loaded host supports no latency claim.
The raw whole-workload decrease of 572 statements and 388 requests is not attributed wholesale to this PR. Per-operation evidence separates the changed owners from scheduling and background work:
ACP is not uniformly flat. Every observed cache miss executes the same single data SELECT,
select * from "acp_sessions" where "session_key" in (SELECT value FROM json_each(?)); there are no added schema/admission statements and no request executes more than one such SELECT. Both versions issue ten chat-admission and ten session-entry-resolver metadata requests. Baseline sends all twenty to worker 5: admission executes five SELECTs and the resolver zero. Candidate admission stays on worker 5 and executes three; nine resolver requests run on worker 8 and execute eight SELECTs. The other resolver request hits worker 5's cache. Thus metadata increases by six SELECTs, and shared-facts adds seven more ACP SELECTs, for combined warm ACP 32 → 45. Shared-facts requests on worker 5 rise 65 → 67 while worker 8 remains at two; their ACP SELECTs are 26 → 32 and 1 → 2 respectively.selectAcpSessionRowsByKeysretains rows in aWeakMap<DatabaseSync, ...>keyed by schema/write/mutation revision. Each worker connection owns a separate cache. Its code, the read dispatcher, and both calling functions are unchanged between the measured pins;WorkerTaskPoolCore.dispatchstill selects the first eligible idle worker without ACP affinity. The ACP worker change filters returned rows by lifecycle after reading. The trace establishes different worker placement and cache hits, not new request sites or a larger query per miss. Other async work can affect task overlap; this pair does not prove that every touched operation has flat total SQL.All 13 conversation turns, the child, cron, compaction, and clean shutdown completed in both runs. Both record retryable
mentions.dismissUNAVAILABLE, which fails the strict outer driver's all-RPC assertion after the workload. Candidate also records one shutdown-onlyBEGIN IMMEDIATE: database is lockedatreleaseOpenClawAgentDatabaseLease→closeCachedOpenClawAgentDatabase→closeIdle; it still exits with code 0. Baseline has no SQL error. Neither driver run is described as all-green. The earlier candidate37dffcfailed its build before producing workload evidence.Native statement counts reconcile exactly with the request census in every phase/thread, with zero missing contexts or duplicate sends. Both runs retain the same two unresolved bootstrap transport targets (
gatewayOwnerLease.read,userProfiles.catalog), reported as two unmatched sends/receives. Calibration covers eight native calls, two prepares, and seven successful statements on MAIN and on a worker. No fixture process remains. Compact evidence is preserved underv6-final/comparison-c460/:report.md,operations.csv,comparison.json,acp-attribution.json, andsource-equivalence.json.