Repository navigation
perf(auth): scrub catalog credentials once per owner store on profile removal - #163451
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, 7:54 AM ET / 11:54 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR speeds up auth-profile removal by inspecting model catalogs together, scrubbing only affected stores once, and coordinating cleanup with catalog publication. Merge readiness⛔ Blocked before merge - 1 item remains The optimization remains useful: current main still performs both catalog-cleanup passes. No introduced correctness or security defect was found. The earlier migration-proof blocker does not apply because this patch preserves the stored-data contract. Priority: P2 Review scores
Verification
How this fits togetherProvider discovery stores model catalogs in each agent’s SQLite database. Auth-profile removal clears copied credentials from those catalogs while preserving model inventory and unrelated accounts. flowchart TD
A[Logout request] --> B[Remove saved auth profile]
B --> C[Lock candidate catalogs]
D[Provider catalog publication] --> C
C --> E[Inspect current catalog rows]
E --> F{Cleanup needed?}
F -->|Yes| G[Canonical database writer]
F -->|No| H[Complete logout]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +150, Tests +201, Docs 0. Total +351 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep credential cleanup in the existing database owners, with fresh batched inspection, coordinated publication, and retryable failure compensation. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the repeated worker-entry path on current main, and the PR reports a six-store timing comparison; this review did not execute the benchmark. Is this the best way to solve the issue? Yes, the patch reduces unnecessary worker entry through the existing storage owners while retaining the credential matcher, publication auth check, and compensation path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cae2f937ce97. 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 (4 earlier review cycles)
|
37d99ad to
49fd717
Compare
|
1b5fe4a to
3615ac6
Compare
… removal Run one post-removal catalog cleanup, preserving partial-exit cleanup and compensation. Batch candidate inspection through the shared-state worker and retain canonical agent mutation workers only for catalogs needing changes. Serialize catalog publication and cleanup by canonical database path so an uncommitted replacement cannot escape a no-op inspection. Preserve OAuth generation ownership, exact credential matching, surviving accounts, and retry recovery. Move catalog removal tests and its facade into focused modules without retaining the old export. Blacksmith Testbox proof: five-run first-test median 5024ms to 702ms; six-store removal 5171ms to 395ms, mutation-worker calls 12 to 0. Auth profile selection: 788 tests / 66 files; focused suites: 103 tests. Build, changed guards, core and all 27 test type graphs, and corrected lint passed. Independent review is clean through P2.
3615ac6 to
afa5247
Compare
… removal (openclaw#163451) Run one post-removal catalog cleanup, preserving partial-exit cleanup and compensation. Batch candidate inspection through the shared-state worker and retain canonical agent mutation workers only for catalogs needing changes. Serialize catalog publication and cleanup by canonical database path so an uncommitted replacement cannot escape a no-op inspection. Preserve OAuth generation ownership, exact credential matching, surviving accounts, and retry recovery. Move catalog removal tests and its facade into focused modules without retaining the old export. Blacksmith Testbox proof: five-run first-test median 5024ms to 702ms; six-store removal 5171ms to 395ms, mutation-worker calls 12 to 0. Auth profile selection: 788 tests / 66 files; focused suites: 103 tests. Build, changed guards, core and all 27 test type graphs, and corrected lint passed. Independent review is clean through P2.
What Problem This Solves
Auth-profile removal scrubbed every candidate catalog before and after deleting auth state. Six stores therefore entered twelve canonical agent mutation workers, even when their catalogs contained nothing to remove. The executor retains one idle native generation, so serial traversal repeatedly paid worker startup and retirement costs.
The earlier hosted-shard investigation measured 12 calls at 422–656 ms each: 6,891 ms initially and 6,221 ms on a warm repeat. This production logout cost also consumed the concurrent-agent test's deadline.
User Impact
Logout avoids repeated mutation-worker startup for empty and unrelated catalogs while retaining credential removal and retry recovery. The concurrent-agent test's assertions and deadline are unchanged.
Why This Change Was Made
Run one post-removal cleanup, including contention, stale retries, and mutation errors. Inspect candidate catalogs together through the existing shared-state worker; only catalogs containing matching credentials or unusable rows enter their canonical agent writer. Every operation reads current rows; there is no retained result cache.
Cleanup and publication share locks keyed by canonical database path. Cleanup takes candidate locks in stable order after auth deletion and holds them through inspection and scrub settlement. This preserves ordering behind an already-authorized, uncommitted catalog replacement. Later publications still revalidate their captured auth snapshot. Discovery and OAuth refresh remain outside these catalog locks.
Keep OAuth generation ownership, exact credential matching, surviving accounts, and failed-cleanup compensation. Extract the cleanup facade and its tests into focused modules, removing the old facade export. No schema, configuration, or migration changes.
Evidence
All heavy proof used
blacksmith-testbox, profileopenclaw-check:tbx_01m3xxfztjens6nm3h22dfg0j7: run 36987294604, base2516be90f16a.tbx_01m3xzkybpfpv5qapdp4hxsvjt: run 36990868110, base0d530ea5b0a9plus the reviewed patch. Both leases are stopped.tbx_01m3y3bgz6gft30qx4zxaeswng: run 36997001854, head49fd717252c208bf81fedc22f2c7b7abf9218be1: 103 focused tests and all five timing runs passed. The table uses these latest first-test and removal-only timings. This lease is stopped.Warm-run peak RSS medians were 619 MiB before and 683 MiB after; the removal benchmark sampled 488 MiB and 546 MiB. These are different leases/bases; this change claims a latency improvement, not a memory reduction.
Validation:
node scripts/run-vitest.mjs run src/agents/auth-profiles/oauth.concurrent-agents.test.ts --reporter=verbose: 5/5 before and 5/5 final, 11 tests per run; all final first-test durations below 1.5 seconds.node scripts/run-vitest.mjs run src/agents/auth-profiles --reporter=verbose: 788 tests across 66 files passed.pnpm test <files> --maxWorkers=1 --reporter=verbose, project wall times were 9.42 s for catalog, 6.90 s for logout, and 20.71 s for the two profile files together. Coverage includes uncommitted publication, partial-removal exits, rollback/retry, malformed migration rows, and surviving credentials. The no-op regression failed on original code (one mutation worker instead of zero).node scripts/check-changed.mjs --base HEAD: structural guards, core types, all 27 core test type graphs, and dead-export checks passed. Two lint findings were corrected; the exact changed-file lint command, line-cap guard, and core typecheck were rerun and passed. Other passing components were reused.--base HEADselects the synced uncommitted patch because the Testbox's shalloworigin/mainhas no merge base with its materialized source.pnpm build: passed, including declaration generation, plugin SDK checks, UI build, and 96 local plugin assets.pnpm docs:listandgit diff --check: passed.A subsequent main catalog-read refactor required retaining both import sets during rebase; the cleanup logic is unchanged. The branch contains one lane commit and only the 11 intended files. Focused integration proof passed on the rebased head. Exact-head CI is pending.