Repository navigation
refactor(auth-profiles): record personal model-account usage in workers - #164240
Conversation
Move personal run-success and failover-failure reductions to the existing authProfiles worker. Reread usage under the writer transaction, preserve credential and probe generations, and join accepted maintenance work. Keep shared reducers and released SDK updater compatibility.
|
🦞👀 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 maintainer review before merge. Reviewed October 3, 2026, 6:18 AM ET / 10:18 UTC (Revision 2). ClawSweeper reviewWhat this changesMoves personal model-account success and failure bookkeeping into OpenClaw’s existing database worker while sharing cooldown calculations and preserving credential ownership. Merge readiness✅ Ready for maintainer review This remains useful: current main still performs personal-account bookkeeping through the synchronous writer, and the related PRs address different behavior. No actionable introduced defect was found; maintainer-authored work also remains protected from automatic closure. Priority: P2 Review scores
Verification
How this fits togetherAgent runs report credential success or failure to auth-profile accounting. That accounting updates the selected personal account’s usage in shared SQLite storage and returns committed usage to the active turn. flowchart TD
A[Agent success or failure] --> B[Capture selected account and store]
B --> C[Existing database worker]
C --> D[Check authority and credential generation]
D --> E[Reduce current usage and commit]
E --> F[Publish acknowledged usage to turn]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +180, Tests +346, Docs +12. Total +538 across 11 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep personal usage reductions on the canonical worker with live commit admission, shared reducers, and unchanged released SDK callback behavior. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that the existing personal-account path enters synchronous SQLite work before its background promise yields. The PR reports a focused before/after SQL counter; this read-only review did not execute it. Is this the best way to solve the issue? Yes, the patch reuses the existing worker, transaction owner, and usage calculations while retaining the released callback path for its separate compatibility contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 260a31989937. 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 (1 earlier review cycle)
|
|
Merged via squash.
|
…rs (openclaw#164240) Move personal run-success and failover-failure reductions to the existing authProfiles worker. Reread usage under the writer transaction, preserve credential and probe generations, and join accepted maintenance work. Keep shared reducers and released SDK updater compatibility.
What Problem This Solves
Personal model-account success and failover-failure bookkeeping performed native SQLite work before its nominally background promise yielded, keeping per-run accounting on the Gateway thread.
Why This Change Was Made
Route typed success/failure reductions through the existing
authProfilesshared-state worker. Capture the physical store before yielding, reread authoritative usage in the same synchronous transaction, refuse changed credentials, recheck host authority at transaction and commit, and publish only acknowledged usage to the selected turn. Post-run success remains nonblocking; maintenance close joins accepted work.Host and worker share the existing usage reducers. Provider probing stays outside the transaction, with credential and block-generation checks preserved. The auth scope state moves to a small sibling module so the isolated-scope guard has one owner without growing the already oversized store module.
User Impact
Credential bytes, shared rotation, schema, retention, durability, and update behavior are unchanged. Connect/disconnect, OAuth refresh, selection, and private GitHub stores remain outside this change. The synchronous updater remains for the released v2026.9.8 SDK callback contract and excluded credential/selection flows; success/failure bookkeeping no longer reaches that path.
Coordination with #125573:
state.ts,types.ts, andusage-state.tsare untouched. Its probe-result type andapplyWhamCooldownResultchanges belong in the extractedusage-reduction.ts; parsing stays inusage.ts. A mechanical relocation conflict inusage.tsis expected when rebasing that older draft, but both host and worker will consume the same changed reducer without a second worker implementation. Current main already shares persisted normalization throughcoerceProfileUsageStats. Adjacent #107671 extracts the untouched owner-write helper; #143744 changes shared OAuth routing; #163350 extracts store-save code; #162398 changes retry selection. Those semantics are unchanged here.Evidence
--maxWorkers=1.updateUserModelAuthProfileis internal, the public success/failure signatures are unchanged, andprovider-auth-write-compat.tsplus its type/behavior tests remain byte-identical to the release. No new compatibility record is required.OPENCLAW_*names.f1c2314964b7504df8f2686e996559e71de4bf7a; Madge reported 0 cycles. The new modules are outside the compiled PR-wrapper dependency closure.node scripts/check-changed.mjs --base f1c2314964b7504df8f2686e996559e71de4bf7a: passed, 2,679.04 s wall. Core and test typechecks, lint, and policy guards passed; the untouched Doctor registry retains an existing max-lines warning.No live provider request was made; provider probe races use synthetic responses with real account storage and workers.