Repository navigation
perf(auth-profiles): detect auth sources through the auth readers - #164992
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. |
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. Reviewed October 4, 2026, 2:30 PM ET / 18:30 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR moves credential-source detection through existing asynchronous auth readers and prepares source-presence facts for model selection and tool discovery. Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this remains a distinct, useful optimization absent from current main. The prior correctness findings are repaired, and the earlier migration-proof blocker does not apply to the read-only execution change. No actionable patch defect remains. Priority: P2 Review scores
Verification
How this fits togetherAuth profiles supply credentials and account state to OpenClaw’s model and tool selection. Source detection determines whether those callers should use the canonical credential loader or continue without a stored profile source. flowchart TD
A[Model and tool preparation] --> B[Capture auth store locations]
B --> C[Existing asynchronous readers]
C --> D[Classify source presence]
D --> E[Canonical credential loader]
D --> F[No stored source]
E --> G[Model and tool selection]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +362, Tests +294, Docs +14, Other -8. Total +662 across 64 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use the existing async readers for runtime discovery while preserving canonical credential loading, current admission checks, and the released synchronous factory contract. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the current-main synchronous SQLite path, and the supplied before/after production workload measures its caller-thread cost. This read-only review did not execute it. Is this the best way to solve the issue? Yes: reusing existing readers and carrying prepared facts is a focused execution change, and the repaired head preserves error classification and deferred credential discovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 88934753a492. 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 (3 earlier review cycles)
|
Propagate shared-state read errors to the existing corruption-eviction owner and keep the storage-free ACP fallback fixture outside auth admission. Refresh negative source facts when deferred media actions need them, and honor a prepared absence before invoking the canonical credential loader. Preserve supplied auth-store snapshots and synchronous SDK/CLI compatibility.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Route the fallback-runner and cron conversation delivery suites through isolated infra forks after async auth source detection began using the shared-state owner. Both reproduced broker admission errors in their old thread projects. Normal Node hosts initialize the broker locally; no production behavior or assertions change. The unchanged fallback test now preserves the exact provider failure after committed delivery. Both cron retry cases and the async auth-source sibling suite pass: 8 tests, 519.70s wrapper wall time with cold preparation. Changed-file checks pass (763.39s), as does independent P2 review. Refs #164992; main CI run 37228653021, jobs 111513599521 and 111513599698.
…enclaw#164992) * perf(auth-profiles): detect auth sources through the auth readers * test(auth-profiles): await progress-card inventory preparation * fix(auth-profiles): preserve source semantics in deferred tools Propagate shared-state read errors to the existing corruption-eviction owner and keep the storage-free ACP fallback fixture outside auth admission. Refresh negative source facts when deferred media actions need them, and honor a prepared absence before invoking the canonical credential loader. Preserve supplied auth-store snapshots and synchronous SDK/CLI compatibility.
Route the fallback-runner and cron conversation delivery suites through isolated infra forks after async auth source detection began using the shared-state owner. Both reproduced broker admission errors in their old thread projects. Normal Node hosts initialize the broker locally; no production behavior or assertions change. The unchanged fallback test now preserves the exact provider failure after committed delivery. Both cron retry cases and the async auth-source sibling suite pass: 8 tests, 519.70s wrapper wall time with cold preparation. Changed-file checks pass (763.39s), as does independent P2 review. Refs openclaw#164992; main CI run 37228653021, jobs 111513599521 and 111513599698.
…170770) ## What Problem This Solves Scheduled main CI fails `image-generate-tool.auth.test.ts` when the retained image tool test saves real credentials. It runs in the `agents-tools` thread pool, where the credential owner correctly rejects an unadmitted writer before the test can verify refreshed availability. Commit `90c4d9a6edebdb2b256fd2129d461227b9d1df42` (#164992) added this real-write regression. Commit `50414196f1912053abee1ddcab595fca3c7e7889` (#170632) later introduced credential custody and moved other native credential fixtures into the forked database-worker owner, but missed this file. Add the image-auth file to that existing owner and extend the existing routing contract to require inclusion in infra and exclusion from agents-tools. All six behavioral cases, the fixture helper, and the production credential guard remain unchanged. No checks are removed; no schema, SDK, runtime SQL, T1, or update behavior changes. Two test-routing files: +4/-0; production: +0/-0. ## Evidence The actual scheduled-main baseline is run [38359584345](https://github.com/openclaw/openclaw/actions/runs/38359584345), job [115170479640](https://github.com/openclaw/openclaw/actions/runs/38359584345/job/115170479640), head `0348a2526c561d8ccce61bfd23931024a6b8f13e`. The failure is `Auth profile credential writes require an admitted worker` at `credential-write-custody.ts:72`, through `writeAuthProfiles` to `image-generate-tool.auth.test.ts:57`. The containing agents-tools shard reports 1 failed / 1933 passed / 1 skipped tests (47.73 seconds Vitest; 49.77 seconds wrapper). This is observed main execution, not a source-parity inference. Changed-file formatting, direct changed-file oxlint, and `git diff --check` passed. One isolated Codex review completed with no actionable findings; native commit hooks passed. No local tests or type scans ran under compute conservation. Candidate proof: ```sh pnpm test src/agents/tools/image-generate-tool.auth.test.ts --maxWorkers=1 pnpm test test/vitest-scoped-config.test.ts --maxWorkers=1 -t "keeps infra and database worker consumers rooted at the repository" ``` The exact original file passed all six cases on candidate `30edf5f4bed3e34b3aab06d39c8a914b976ff76d` in [focused CI 38362624127/job115180185169](https://github.com/openclaw/openclaw/actions/runs/38362624127/job/115180185169): 26.08 seconds Vitest, 64.20 seconds wrapper; unchanged-source verification passed. The routing contract passed in ordinary CI 38361217277/job115176092361 (2.501-second case, 24/24 file cases). Ordinary CI omitted the original file, so the supplement ran only its six cases. No duplicate baseline was run. Final ordinary CI: 49 successful checks, 39 skipped, no failures or pending checks. Static, type, architecture, security, and required CI gates passed. Database ratchets remained T1 454 to 454, compatibility calls 9 to 9, and all dialect groups 0 to 0. This is a test-only owner-routing correction; no SQL savings are claimed.
…penclaw#170770) ## What Problem This Solves Scheduled main CI fails `image-generate-tool.auth.test.ts` when the retained image tool test saves real credentials. It runs in the `agents-tools` thread pool, where the credential owner correctly rejects an unadmitted writer before the test can verify refreshed availability. Commit `24fc8a49a8c1c4f106d92c833b440cec6e6d55f6` (openclaw#164992) added this real-write regression. Commit `c3b5d0c7bc15f2f497247c3127cfa844d34c6e74` (openclaw#170632) later introduced credential custody and moved other native credential fixtures into the forked database-worker owner, but missed this file. Add the image-auth file to that existing owner and extend the existing routing contract to require inclusion in infra and exclusion from agents-tools. All six behavioral cases, the fixture helper, and the production credential guard remain unchanged. No checks are removed; no schema, SDK, runtime SQL, T1, or update behavior changes. Two test-routing files: +4/-0; production: +0/-0. ## Evidence The actual scheduled-main baseline is run [38359584345](https://github.com/openclaw/openclaw/actions/runs/38359584345), job [115170479640](https://github.com/openclaw/openclaw/actions/runs/38359584345/job/115170479640), head `116f0502239e7f1cd4a85f57331f986f616e8939`. The failure is `Auth profile credential writes require an admitted worker` at `credential-write-custody.ts:72`, through `writeAuthProfiles` to `image-generate-tool.auth.test.ts:57`. The containing agents-tools shard reports 1 failed / 1933 passed / 1 skipped tests (47.73 seconds Vitest; 49.77 seconds wrapper). This is observed main execution, not a source-parity inference. Changed-file formatting, direct changed-file oxlint, and `git diff --check` passed. One isolated Codex review completed with no actionable findings; native commit hooks passed. No local tests or type scans ran under compute conservation. Candidate proof: ```sh pnpm test src/agents/tools/image-generate-tool.auth.test.ts --maxWorkers=1 pnpm test test/vitest-scoped-config.test.ts --maxWorkers=1 -t "keeps infra and database worker consumers rooted at the repository" ``` The exact original file passed all six cases on candidate `30edf5f4bed3e34b3aab06d39c8a914b976ff76d` in [focused CI 38362624127/job115180185169](https://github.com/openclaw/openclaw/actions/runs/38362624127/job/115180185169): 26.08 seconds Vitest, 64.20 seconds wrapper; unchanged-source verification passed. The routing contract passed in ordinary CI 38361217277/job115176092361 (2.501-second case, 24/24 file cases). Ordinary CI omitted the original file, so the supplement ran only its six cases. No duplicate baseline was run. Final ordinary CI: 49 successful checks, 39 skipped, no failures or pending checks. Static, type, architecture, security, and required CI gates passed. Database ratchets remained T1 454 to 454, compatibility calls 9 to 9, and all dialect groups 0 to 0. This is a test-only owner-routing correction; no SQL savings are claimed.
What Problem This Solves
Runtime auth-source detection performs native SQLite source/read-pool/table checks before loading credentials. In the unchanged sqlmeasure3 workload, this lane accounts for six MAIN-thread SQL calls per warmed turn. Tool discovery and several indirect callers also reach the synchronous probe.
Why This Change Was Made
Use the existing shared and agent auth readers for runtime source detection, capturing physical targets before yielding and retaining readers through classification and cleanup. Preserve missing database/table/row routing, state-only sources, and present-unreadable refusal. Classify store and state cells independently so a broken state table cannot make an absent credential row appear present.
Migrate model/session fallback, provider usage, cron preparation, inline skills, compaction, tool inventory and worker-turn preparation. Carry the resulting presence fact through synchronous image/media/PDF factories; retain lazy web-search probing through the existing selection owner. Inventory callers await preparation before releasing their runtime lease. Public synchronous coding-tool construction remains compatible and does not expose the internal preparation option.
User Impact
Auth-source checks move off the caller thread without changing credential precedence or fallback behavior. Existing auth readers, admission, transports and lifecycle remain the owners; no new service, cache, schema, retention, durability or environment-variable names. Update behavior is unchanged, so the conditional update cell does not apply.
Production diff: +420 / −59 / net +361 across 36 production files (479 changed production lines). The broader file count is the complete caller cutover plus fixture updates and worker-access documentation. Native kernels remain for documented Doctor/CLI and released synchronous SDK compatibility; static T1 is 895 → 895.
Known overlaps: #162433 (umbrella design) and #155584 (shared auth selection). The concurrent delegate-exec lane also touches worker-tool-authority.ts; this PR changes only source preparation. Usage bookkeeping from #164240 and #164588 is outside this lane. The existing other-owner session authority read at
src/gateway/worker-environments/worker-turn-transcript-target.ts:29remains follow-up debt; moved-operation boundary tests do not claim zero SQL for the entire worker flow.Evidence
Base:
82adb7a49d36e844e4ea1989bc5d865abac916f0, the fresh origin/main at task start. Measured candidate:451b5bb3aa99b29bfa8482ecee392a9ee3b6540f. Landing candidate:77d2e0c9bdf123b2484dd9b7d15ea857fc51dff0.The unchanged local sqlmeasure3 harness/observer ran on Node 24.21.0 / SQLite 3.53.4 with source maps. Both revisions completed 13/13 turns, the native child, cron, all RPCs, committed compaction and graceful shutdown. All disk stores were inside synthetic fixtures; owned processes and harness staging were cleaned up.
Target sites, using baseline line numbers:
auth-profiles/sqlite-read-pool.ts:161busy-timeout checks 10 → 0;:162user-version checks 10 → 0;auth-profiles/sqlite-json.ts:68table checks 20 → 0;:91store reads 10 → 0;:98state reads 10 → 0, across ten warmed turns. No after MAIN stack contains either source module anywhere in the workload.This proves the moved operations leave MAIN; it does not show fewer total statements or an overall warmed reduction. Outside authsource, the warmed difference is +82: +80 scheduled/reconciliation statements (cron 34, GitHub OAuth/publication 30, placement 16), +9 existing pending-input current-custody statements, −5 foreground/freshness statements and −2 plugin startup-cleanup statements. The nine custody statements are foreground authority work, not background; one run does not establish their trigger or deterministic overhead from this change. Those producers are unchanged.
Runtime wall time was 83.24 → 198.31 s and maximum RSS 2,983,608,320 → 2,642,509,824 bytes; host contention and instrumentation make these diagnostic only. Failed SQL is excluded from successful counts: one before and two after worker-only
BEGIN IMMEDIATEbusy failures during audit shutdown; no MAIN errors. Build-stamp and stale-lock guards were respected during test-fixture repair; the final clean-source build passed before measurement.The source-boundary regressions cover zero caller-thread SQL, missing/table-missing/state-only/unreadable routing, physical shared-root capture across environment mutation, and primary-error classification when cleanup also fails. Negative controls failed against the original native probe, the original undefined-hint fallback, and the pre-fix cleanup path.
All focused runs use
pnpm test <files> --maxWorkers=1. Local wall times include transform/build costs and contention; these are not measured CI seconds. Hosted CI seconds are not yet available.Initial inventory fixture failures exposed an unintended real host-broker call from storage-free metadata tests; explicit source mocks fixed those fixtures. Mock-baseline maintenance removes exactly eight obsolete entries with no additions. The complete typecheck also caught a missed progress-card test caller; it now awaits inventory preparation, with all five focused cases passing. Final Madge: zero cycles (141.21 s). The database-worker ratchet passes with no T1 growth and zero new OPENCLAW_* names.
Authoring P2 Codex autoreview against the pinned base in private TMPDIR is scoped-clean, including the final test-only correction. An earlier static concern was independently checked against source: optional-media availability planning never calls
hasAuthProfileForProvideror a source probe.openclaw-tools.media-factory-plan.ts:198consumes the supplied store viatools/manifest-capability-availability.ts:122–127andauth-profiles/profile-list.ts:14–18; actual media/PDF constructors receive the prepared fact through the existing options spread inopenclaw-tools.ts:172–196.Local SDK API diff completed in realpath private TMPDIR against the pinned base and production commit
8ba553d1ef4e7699f49fa84b2c98955162b14663(digestab62668d). Measured commit451b5bb3aa99b29bfa8482ecee392a9ee3b6540fchanges only the progress-card test; production inputs are identical. No entrypoints added or removed. The report marks 127 exports affected through seven unique reachable-declaration changes: the async helper, optional environment/prepared-presence inputs, and the existing public factory’sOmitlist. The public factory remains synchronous and excludes the new internal hint, preserving its accepted option shape; no Gateway-context service method signature changes.node scripts/check-changed.mjs --base 82adb7a49d36e844e4ea1989bc5d865abac916f0completed with exit 0 (1,960.39 s), including all core/test type graphs, ratchets, format/lint, unused-export scans and runtime architecture guards. Runtime import cycles: zero.git diff --checkpassed. SDK comparison including checkout cleanup completed with exit 0 (1,360.78 s).Released SDK check: inspected
v2026.9.8(latest release tag), includingsrc/plugin-sdk/agent-harness.ts,src/agents/agent-tools.ts, SDK exports,src/plugins/runtime, and documented plugin contracts. The async conversions (resolveEffectiveToolInventory,resolveWorkerToolAuthority,hasUsableWebSearchProvider) are internal. The releasedcreateOpenClawCodingToolsremains synchronous with its accepted input shape unchanged; the new preparation hint is omitted at that boundary and covered by the existing SDK type test. No released contract is retired, so no new deprecation record is required.Landing corrections and verification
The original CI attempt 37213979573 exposed two PR-caused failures: shared auth-row corruption no longer evicted its cached handle, and the storage-free ACP fallback fixture entered host-broker admission. Each failing file was run five times at the original head and five times at the merge base in isolated Linux worktrees: all ten head invocations failed the expected cases, and all ten baseline invocations passed. The correction restores native shared-state error propagation to the existing eviction owner and uses the existing auth-runtime opt-out in the ACP policy fixture. No inherited-failure exception is claimed for either original failure.
Further review found that a retained media tool could keep a construction-time negative source fact after the first credential was published. Deferred media selection and listing now refresh that negative through the existing async reader. Supplied auth-store snapshots keep their existing lifetime, explicit model paths stay lazy, and undefined SDK/CLI compatibility inputs retain their prior behavior. Provider checks also honor an absent source before loading the canonical credential store. Negative controls reproduced both stale provider readiness on the same retained tool and the unwanted synchronous store load.
The landing corrections do not change released SDK signatures, reader transports, schemas, stored formats, retention, or admission policy. The new helper is internal; the released SDK comparison above remains applicable to the public declarations. The original SQL measurement remains bound to its measured candidate rather than being presented as a rerun of the landing head.
Validation: the two initial CI repairs passed 122 focused tests locally (938.32 s). An isolated Linux checkout verified the correction file hashes, passed ten focused media/auth test files (139 s), all ten required import/build-graph files (61 s), and
node scripts/check-changed.mjs --base 451b5bb3aa99b29bfa8482ecee392a9ee3b6540f(831 s). After the final small absence guard, the two affected helper/auth files passed all 26 tests locally (385.20 s), with targeted lint, format, and diff checks passing. The retained-tool negative control took 174.20 s locally; the store-load negative control took 352.82 s. These wall times include local transformation/build costs; the hosted numbers are batch seconds, not isolated per-case CI costs. Fresh P2 Codex autoreview of the complete landing-repair delta is scoped-clean. Required GitHub CI is bound to the final PR head; the independently qualified pre-existing UI failure below uses the explicitly authorized native admin exception.Inherited CI failure qualification
At landing head
77d2e0c9bdf123b2484dd9b7d15ea857fc51dff0, CI run 37220273651, attempt 1 has one root failure:checks-ui-e2e-real-gateway (2/2), job111489294517. The worker initial-setup test accepts two queued inputs but observes one launch. Immediately beforehand, the second input reportsSession setup-proof-session placement authority changed. The aggregate gate fails solely from that UI shard; all other selected CI execution jobs succeeded. A cancelled non-required auto-response check belongs to a separate workflow.Independent clean Linux/Chromium repetitions used the canonical prebuilt UI entrypoint and
--maxWorkers=1: this PR head passed 5/5 (125, 72, 73, 74, 73 seconds); main merge base82adb7a49d36e844e4ea1989bc5d865abac916f0failed twice with the same error and assertion, then passed three times (146, 99, 71, 70, 70 seconds). A separately built current-main checkout atc9bff77155b0d6fde8214b5e9cbfbc32178eff09passed twice and reproduced the same failure on its third run (103, 62, 91 seconds). These are single-file command wall times, including transform and fixture costs. Each head/base build took 117 seconds; current main took 105 seconds. No assertions, timeouts, fixture synchronization, or retries were added, and no CI rerun was used to obtain green.The unchanged placement observer rejects an awaited read when another turn publishes same-session claim/ACK/workspace facts. Runtime selection begins before the per-session execution lane, so normal first-turn settlement can invalidate the second input's observation. This path predates the PR. The CI log does not isolate which of the existing runtime-selection or initial-execution observers threw; the independent main reproduction establishes inheritance without claiming a speculative repair. The test, placement observation/store/launcher/admission/ACK owners, runtime entry, and session queue are byte-identical between CI's main parent
15f60faa8e09a791b8d4c28d0f6bb94de7bd2594and tested merge98c1c9e11362c23c3c6efdb45dca614689e6277b, and remain unchanged at the tested current-main revision. Added auth awaits may alter timing; they introduce no placement publication or writer. Recent scheduled main UI shards also passed, consistent with the observed intermittency.The native review retains
tests.result: failand exact run/head attribution for the approved pre-existing-failure admin route. This race remains follow-up work in placement admission; the passing repetitions are not presented as a fix. The completed ClawSweeper review of this head (2026-10-04 17:28 UTC) reports no actionable correctness or security findings, and the final P2 review is scoped-clean.