Repository navigation
fix(zalouser): avoid Gateway stalls during credential persistence - #156003
Conversation
Move QR credential saves and logout revocation onto the shared SQLite worker, await their durable completion, and keep restoration behind pending revocation on its originally selected state directory. Preserve the credential format, revocation markers, refresh CAS, and named older-host capability fallback. Carry a live hosted-wizard assertion through setup and into the final write grant so a detached QR login cannot persist after its owner is retired. Validation: 172 focused tests across worker storage, registered setup, synthetic SDK transport, and core wizard lifecycle; complete independent P2 review clean. Repository gates: 34 passed, 3 unchanged core gates reused. The inherited unused TSGO_CORE_TEST_MAX_ROOTS export is the sole remaining gate failure on this base; canonical fix 1619aff supplies its repair. Regression controls prove the former host-SQL logout path, a missing final wizard-lifetime guard, and state-root drift across a pending logout. No live provider account, operator Gateway restart, schema change, or protocol bump.
|
🦞👀 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 changes before merge. Reviewed September 23, 2026, 11:18 AM ET / 15:18 UTC (Revision 4). ClawSweeper reviewWhat this changesMoves Zalo Personal credential persistence onto SQLite workers, prevents retired setup wizards from saving credentials, and updates related regression fixtures. Merge readiness⛔ Needs changes before merge - 1 item remains This remains a useful fix: current main still performs synchronous QR credential saves and logout. No introduced correctness defect was found; the previous test-cost follow-up is partially satisfied. Priority: P2 Review scores
Verification
How this fits togetherZalo Personal setup supplies login credentials to OpenClaw’s plugin-state storage. Credential persistence connects QR login, session restoration, and logout to the shared SQLite worker while the Gateway continues handling other work. flowchart TD
A[QR login or logout] --> B[Zalo credential owner]
C[Hosted setup lifetime] --> D[Current authority check]
B --> D
D --> E[SQLite worker]
E --> F[Credentials or revocation marker]
F --> G[Session restoration]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +135, Tests +254, Docs +9, Other 0. Total +398 across 24 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep credential persistence on the existing worker-backed storage owner while preserving durable logout, stored credentials, and setup-lifetime enforcement. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that current-main QR saves and logout enter synchronous SQLite storage on the calling thread. The reported negative control detects that path; this review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes, reusing the existing asynchronous store and carrying live setup authority to its final write grant addresses the blocking operations without changing credential representation or introducing a competing storage path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 645f1bc4ef49. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Compose current main while preserving the asynchronous channel-account resolver and the Zalo setup-lifetime assertion. Strengthen the existing QR regression to calibrate all eight native SQLite counters, then cover cold login, credential readback, durable logout, and awaited worker teardown without parent SQL. Validation: 207 cases across seven lifecycle and channel files; fresh P2 review clean; 37 of 38 selected repository gates pass. Restoring the original synchronous logout fails the regression with seven parent database constructors, including in-memory databases. Candidate source was restored and the full selection passed. The remaining gate is an unchanged main-branch chat-scroll fixture type error at chat-transcript-scroll-ownership.test.ts:210-211. Its canonical repair and a fresh ui-chat typecheck remain required before landing. No full local build was run.
Preserve all 22 reviewed feature postimages while incorporating current main, including the canonical chat-scroll pane identity correction. The previously failing UI chat type graph now passes. The 207 focused lifecycle cases, clean P2 review, and 37 unaffected selected checks remain valid for unchanged source. No dependency reconciliation or full local build was needed for this carry. Exact-head hosted CI remains required before landing.
Wait for the existing owner's next publication after releasing the model result, assert its captured state without filtering successful outcomes, and check one direct describe response. Preserve the durable watermark and model-call assertions. No production logic or test deadline changes. Validation: 22 cases on the exact tested CI merge with Node 24.21; real writer queue probe preserves the old updating recap until write settlement, then exposes the published current recap. Owning type graph, typed lint, formatting, and P2 review pass. The initial CI log redacts the returned summary, so the change does not claim that its historical failure was proved timing-only.
Limit the synthetic policy fixture to its Discord plugin so real reloads do not cold-load unrelated runtime plugins. Require the reload to report applied while preserving the active-turn, held lookup and revocation flow. Exact CI merge-source proof passed locally in 15.3s. Root fixture types, typed lint, formatting and independent review passed. No production code or test timeout changed.
|
Merged via squash.
|
…enclaw#156003) * fix(zalouser): avoid Gateway stalls during credential persistence Move QR credential saves and logout revocation onto the shared SQLite worker, await their durable completion, and keep restoration behind pending revocation on its originally selected state directory. Preserve the credential format, revocation markers, refresh CAS, and named older-host capability fallback. Carry a live hosted-wizard assertion through setup and into the final write grant so a detached QR login cannot persist after its owner is retired. Validation: 172 focused tests across worker storage, registered setup, synthetic SDK transport, and core wizard lifecycle; complete independent P2 review clean. Repository gates: 34 passed, 3 unchanged core gates reused. The inherited unused TSGO_CORE_TEST_MAX_ROOTS export is the sole remaining gate failure on this base; canonical fix 802e512 supplies its repair. Regression controls prove the former host-SQL logout path, a missing final wizard-lifetime guard, and state-root drift across a pending logout. No live provider account, operator Gateway restart, schema change, or protocol bump. * test(gateway): await recap publication before projection assertion Wait for the existing owner's next publication after releasing the model result, assert its captured state without filtering successful outcomes, and check one direct describe response. Preserve the durable watermark and model-call assertions. No production logic or test deadline changes. Validation: 22 cases on the exact tested CI merge with Node 24.21; real writer queue probe preserves the old updating recap until write settlement, then exposes the published current recap. Owning type graph, typed lint, formatting, and P2 review pass. The initial CI log redacts the returned summary, so the change does not claim that its historical failure was proved timing-only. * test(discord): scope policy reload fixture activation Limit the synthetic policy fixture to its Discord plugin so real reloads do not cold-load unrelated runtime plugins. Require the reload to report applied while preserving the active-turn, held lookup and revocation flow. Exact CI merge-source proof passed locally in 15.3s. Root fixture types, typed lint, formatting and independent review passed. No production code or test timeout changed.
What Problem This Solves
Zalo QR login and logout can block other Gateway work while reading or writing credentials.
User Impact
Credential persistence runs on SQLite workers while preserving the existing credential format and logout markers. Delayed QR writes stop when their hosted setup wizard closes, and a waiting restore keeps the state directory it originally selected.
Why This Change Was Made
The registered login/logout callers now await the asynchronous keyed-store owner. The old synchronous logout already completed persistence before returning; this change preserves that durability while moving SQL off the Gateway thread. Logout keeps atomic revocation and presence reporting, and replacement login and restore wait for pending revocation. A focused credential persistence owner retains the existing refresh currentness checks. Hosted setup supplies a pure session-lifetime assertion through the existing preparation flow and into the final worker write grant.
No configuration, schema, protocol, or credential migration is required. Existing external setup preparation callbacks and the published older-host capability fallback remain supported. Current hosts use the worker path; runtime errors do not trigger a synchronous fallback.
Evidence
On the combined current-main source, 207 focused tests passed across seven credential, Doctor, registered setup, hosted wizard, session lifecycle, and channel-add files. The strengthened real-worker QR test calibrates all eight native SQLite observers, then verifies zero parent-thread constructors, closes, prepares, executions, or statement reads/writes through cold QR login, credential readback, durable logout, and worker teardown. Restoring the original synchronous logout makes that test fail with seven parent-thread database constructors, including in-memory databases. The candidate bytes were restored and the full focused selection passed.
Earlier regression controls also detect missing final setup-lifetime enforcement and state-root drift while waiting for logout. Prior send/listener sibling proof is reused only where the source is unchanged. Current main's asynchronous account resolver and assertion-baseline reductions are preserved.
Fresh independent P2 review is clean. Thirty-seven selected repository checks passed before the latest main composition, including core and extension types, typed lint, formatting, three ratchets, and all unused-export scans. The remaining UI chat typecheck initially failed on an unchanged main-branch fixture. After incorporating its canonical repair, that typecheck passed. All 22 feature files retained their reviewed bytes across this composition; the unaffected runtime and static proof was reused. The proof uses real SQLite workers and synthetic SDK transport without an authenticated Zalo account or operator Gateway state. No full local build was run; exact-head hosted CI and both required gates passed before the native merge.
The first refreshed CI run exposed an activity-recap fixture that polled
sessions.describeafter the model result, before the owning write and publication necessarily settled. That fixture now waits for the next existing publication without filtering successful states, checks the captured state, and then asserts a single direct describe result. Its original durable-watermark and model-call assertions remain. All 22 cases passed with this correction on the exact CI merge source using local Node 24.21; hosted CI uses Linux/Node 24.19. A real writer-queue probe also verified that model completion leaves the old durable recap updating until the write is released. The fixture change passed its own P2 review, owning typecheck, typed lint, and formatting. No production recap code or test timeout changed. The final exact-head required CI passed before landing.The next hosted run passed the recap shard and exposed a Discord policy fixture that activated unrelated plugins during each real reload. Its synthetic configuration now allows the Discord plugin, and the reload result must explicitly be
applied. The original admission, held lookup, revocation, and active-turn assertions and the 120-second timeout are unchanged. This fixture passed on the exact failing CI merge source in 15.3 seconds locally, with 24 KiB of temporary growth; its owning root typecheck, typed lint, formatting, and independent P2 review passed. No production Discord code changed. The same hosted run also found three Session Share fixture failures from an omitted registered-service startup; that fixture lifecycle was repaired separately on main in #156464 (d7b45d7e76c6).Recorded test cost
The three previously missing standalone process-wall measurements are now captured on the exact, unchanged reviewed head
6c2a541265b9. These three measurements were captured after the PR merged, against the retained reviewed commit; they supplement the original pre-merge evidence. Each file ran separately and sequentially with/usr/bin/time -p pnpm test <file> --maxWorkers=1, on macOS/Node 24.21 after a frozen dependency restore. Filesystem module caching was disabled. All three commands exited successfully; no test source, timeout, or assertion changed.timereal)extensions/zalouser/src/zalo-js.credentials.test.tssrc/system-agent/hosted-setup.runtime.test.tssrc/wizard/session.test.tsProcess wall includes the repository wrapper, worker preparation/verification, imports, execution, and teardown. It excludes the outer resource-accounting observer. The credential run had a cold worker-artifact cache and reported 40.873 s of worker preparation; the hosted-setup run reused worker outputs but reported 45.45 s of Vitest transformation work. Those phases are included in the totals, not added to them. These are single-run cost observations, not a performance-regression comparison.
The credential suite retains the actual worker-store path, durable logout, final setup-owner enforcement, and calibrated zero-parent-SQL observation. The hosted suite retains config publication and wizard/session lifecycle behavior. Mocking away those owners would remove the boundaries these regressions protect; much of the measured wall cost belongs to preparation and transforms rather than additional waits in the cases. Wizard-session remains the smaller direct owner suite. No other already-qualified proof was rerun for this timing follow-up.
Earlier successful measurements remain separate: the 207-case credential/setup/wizard batch took 133.596 s end to end. Its credential and Doctor files shared a 31.76 s Vitest invocation; that combined duration was never claimed as either file's independent wall time. Earlier single-file Vitest durations were 33.86 s for chat-wizard-host, 20.24 s for channels.add, and 12.67 s for Zalo setup-surface. The activity-summary command took 63.529 s end to end (55.36 s Vitest); Discord took 48.398 s end to end (41.39 s Vitest; 15.313 s test body). Those two fixture proofs ran on their exact failing CI merge source plus the reviewed correction, using macOS/Node 24.21; hosted CI uses Linux/Node 24.19.
On published head
6c2a541265b9, CI run 35869185534 passed 149 jobs (16 skipped). Available GitHub timestamps give 538 s for the activity-summary shard, 365 s for the Discord policy shard, and 416 s for the Session Share shard. These are complete multi-file job durations, including setup and other tests, not per-file times or billed CPU seconds. Both required CI gates passed before the native merge.