Skip to content

perf(auth): scrub catalog credentials once per owner store on profile removal - #163451

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-auth-removal-catalog-scrub-20260919
Oct 2, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-auth-removal-catalog-scrub-20260919

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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, profile openclaw-check:

  • Baseline lease tbx_01m3xxfztjens6nm3h22dfg0j7: run 36987294604, base 2516be90f16a.
  • Full proof lease tbx_01m3xzkybpfpv5qapdp4hxsvjt: run 36990868110, base 0d530ea5b0a9 plus the reviewed patch. Both leases are stopped.
  • Rebased-head integration lease tbx_01m3y3bgz6gft30qx4zxaeswng: run 36997001854, head 49fd717252c208bf81fedc22f2c7b7abf9218be1: 103 focused tests and all five timing runs passed. The table uses these latest first-test and removal-only timings. This lease is stopped.
First concurrent-agent test Before Final
Run 1 5,024 ms 746 ms
Run 2 6,116 ms 697 ms
Run 3 4,912 ms 773 ms
Run 4 4,763 ms 879 ms
Run 5 5,030 ms 836 ms
Median 5,024 ms 773 ms (85% faster)
Six-store removal, empty catalogs 5,171 ms; 12 mutation-worker calls 387 ms; 0 mutation-worker calls (93% faster)

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.
  • Focused catalog, logout, profile, and catalog-removal suites: 103 tests passed. With 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 HEAD selects the synced uncommitted patch because the Testbox's shallow origin/main has 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:list and git diff --check: passed.
  • Final independent review: clean through P2.

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.

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations agents Agent runtime and tooling size: L labels Oct 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 2, 2026, 7:54 AM ET / 11:54 UTC (Revision 5).

ClawSweeper review

What this changes

The 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
Reviewed head: 3615ac6a768b90a7a60561a608ef402037e6f9fc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused performance improvement with useful validation and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this verified maintainer-authored PR. Reported Testbox benchmarks exercise auth removal and catalog workers, with focused regressions supplementing them; they are earlier-head evidence. No stored-data contract changes require migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this verified maintainer-authored PR. Reported Testbox benchmarks exercise auth removal and catalog workers, with focused regressions supplementing them; they are earlier-head evidence. No stored-data contract changes require migration proof.
Evidence reviewed 9 items Pinned introduced changes: Reviewed the production and test hunks between the verified merge base and original PR head. Cleanup moves after auth removal, runs on partial exits, and retains guarded restoration when cleanup fails.
Optimization still absent from current main: Fetched main retains the pre-removal and post-removal traversal through catalog mutation workers. Its catalog executor lacks the introduced publication-lock barrier, so the central performance improvement remains distinct.
Publication and revocation ordering: Cleanup holds canonical-path locks through fresh inspection and writer settlement; runtime catalog replacement uses the same locks. The unchanged publication worker rereads current auth before writing, and models-config supplies the captured auth snapshot. No new principal grant or authorization bypass was identified.
Findings None None.
Security None None.

How this fits together

Provider 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
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +150, Tests +201, Docs 0. Total +351 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 230 80 +150
Tests 4 336 135 +201
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 567 216 +351

Review metrics

Metric Value Why it matters
Production and test growth production net +150 lines; tests net +201 lines Production growth has a concrete purpose: batched worker inspection and publication coordination; test growth covers ordering and partial-removal recovery.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/agents/plugin-model-catalog-read.worker.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded logout-performance improvement with preserved credential-removal semantics.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this verified maintainer-authored PR. Reported Testbox benchmarks exercise auth removal and catalog workers, with focused regressions supplementing them; they are earlier-head evidence. No stored-data contract changes require migration proof.

Evidence

What I checked:

  • Pinned introduced changes: Reviewed the production and test hunks between the verified merge base and original PR head. Cleanup moves after auth removal, runs on partial exits, and retains guarded restoration when cleanup fails. (src/agents/auth-profiles/profiles.ts:435, 3615ac6a768b)
  • Optimization still absent from current main: Fetched main retains the pre-removal and post-removal traversal through catalog mutation workers. Its catalog executor lacks the introduced publication-lock barrier, so the central performance improvement remains distinct. (src/agents/auth-profiles/profiles.ts:435, cae2f937ce97)
  • Publication and revocation ordering: Cleanup holds canonical-path locks through fresh inspection and writer settlement; runtime catalog replacement uses the same locks. The unchanged publication worker rereads current auth before writing, and models-config supplies the captured auth snapshot. No new principal grant or authorization bypass was identified. (src/agents/plugin-model-catalog-credentials.ts:44, 3615ac6a768b)
  • Stored-data compatibility and prior review: The new reader queries the existing cache table and both existing catalog scopes using the unchanged credential-stripping owner. Schema definitions, serialized formats, migration kernels, and public SDK contracts are unchanged. The prior review’s migration-proof request is therefore not retained as a blocker. (src/agents/plugin-model-catalog-read.worker.ts:30, 3615ac6a768b)
  • Focused regression coverage: Inspected coverage for no-op inspection followed by matching publication, an uncommitted publication, held refreshes across deletion, surviving credentials, partial-removal failures, malformed recovery rows, and cleanup compensation followed by retry. These tests were read, not executed during this review. (src/agents/plugin-model-catalog.test.ts:120, 3615ac6a768b)
  • Reported performance validation: The captured PR body reports Testbox integration on head 49fd717252c208bf81fedc22f2c7b7abf9218be1: first concurrent-agent test median 5,024 to 773 ms, and six-store empty-catalog removal 5,171 to 387 ms with mutation-worker calls reduced from twelve to zero. This is author-reported earlier-head evidence, not reviewer execution or exact-current-head proof; RSS increased in the reported comparisons. (49fd717252c2)

Likely related people:

  • Jason O'Neal: Raw commit e0d16ec adds src/agents/plugin-model-catalog.worker.ts:37 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e0d16ecdd581; files: src/agents/plugin-model-catalog.worker.ts)
  • Peter Steinberger: Raw commit 93625aa adds src/agents/plugin-model-catalog-execution.ts:99 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 93625aa3d10d; files: src/agents/plugin-model-catalog-execution.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-02T10:38:21.545Z sha 37d99ad7d295449cb2ca227bd54f1afeaf6210fa :: blocked before merge. :: none
  • reviewed 2026-10-02T10:46:03.481Z sha 49fd717252c208bf81fedc22f2c7b7abf9218be1 :: blocked before merge. :: none
  • reviewed 2026-10-02T10:58:06.754Z sha 49fd717252c208bf81fedc22f2c7b7abf9218be1 :: blocked before merge. :: none
  • reviewed 2026-10-02T11:31:32.126Z sha 1b5fe4a80672fcb2ef8ea6bfb6309eb27eba9673 :: blocked before merge. :: none

@steipete
steipete force-pushed the steipete/perf-micro-auth-removal-catalog-scrub-20260919 branch from 37d99ad to 49fd717 Compare October 2, 2026 10:40
@steipete
steipete marked this pull request as ready for review October 2, 2026 10:48
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: afa52476f033b9836b2e50ff54e7795e0576c815
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/profiles.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/plugin-model-catalog-credentials.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@steipete
steipete enabled auto-merge (squash) October 2, 2026 10:49
@steipete
steipete force-pushed the steipete/perf-micro-auth-removal-catalog-scrub-20260919 branch 2 times, most recently from 1b5fe4a to 3615ac6 Compare October 2, 2026 11:49
… 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.
@steipete
steipete force-pushed the steipete/perf-micro-auth-removal-catalog-scrub-20260919 branch from 3615ac6 to afa5247 Compare October 2, 2026 13:01
@steipete
steipete merged commit fc17c21 into main Oct 2, 2026
121 checks passed
@steipete
steipete deleted the steipete/perf-micro-auth-removal-catalog-scrub-20260919 branch October 2, 2026 13:12
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant