Repository navigation
refactor(channels): read pairing allowlists through the shared-state reader - #164476
Conversation
Move the existing async allowlist API to the shared-state read owner, capture its physical source before yielding, and preserve current reads, account normalization, ordering, and ingress authority. Retain the released synchronous SDK contract as deprecated compatibility. Missing async reads grant no permission without initializing storage; boot and Doctor keep initialization. Boundary proof observes two caller-thread pairing queries before the cutover and zero afterward. Shared kernels remain T1 for SDK compatibility and pairing mutations; no schema, cache, retention, or durability changes.
Reserve one deprecated channel-pairing export for the required released synchronous allowlist compatibility window. Total public exports remain unchanged.
Apply the native array selection before worker serialization so inherited account keys retain TypeError instead of returning an object or causing a transport failure. Add real-worker regressions for both inherited keys.
|
🦞👀 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 3, 2026, 11:27 PM ET / October 4, 2026, 03:27 UTC (Revision 16). ClawSweeper reviewWhat this changesMoves asynchronous channel pairing allowlist reads into the shared-state worker while preserving the released synchronous plugin API. Merge readiness⛔ Blocked before merge - 1 item remains The refactor remains useful and has no actionable correctness or security findings. The previous migration-proof blocker does not apply: the compatibility record is SDK metadata, and no stored-data contract changes. Exact-head CI succeeded. Priority: P2 Review scores
Verification
How this fits togetherChannel ingress and plugins read approved senders from OpenClaw’s shared SQLite state. The reader prepares account-scoped allowlist entries, which channel policy then uses to decide whether a message may proceed. flowchart TD
A[Incoming channel message] --> B[Channel policy preparation]
B --> C[Shared-state reader worker]
D[Approved sender rows] --> C
C --> E[Account-scoped allowlist]
E --> F[Channel admission decision]
F --> G[Dispatch or denial]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +80, Tests +339, Docs +27, Other +2. Total +448 across 21 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use the existing worker for async preparation, keep channel policy authoritative, and retain the shipped synchronous SDK contract through its documented compatibility window. Do we have a high-confidence way to reproduce the issue? Not applicable to this refactor as a correctness bug report; current-main source directly confirms that the existing async API performs synchronous SQLite reads. Is this the best way to solve the issue? Yes. Reusing the shared-state reader and ordered query is a focused cutover, and preserving the released synchronous SDK API avoids an unnecessary breaking change. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 47206579b8e2. 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 (15 earlier review cycles; latest 8 shown)
|
Merge main to resolve additive compatibility registry and compiled-wrapper inventory conflicts, preserving both records. Keep inherited account-key TypeErrors when the async pairing reader encounters an absent store, without initializing storage. Extend the existing regression table to cover both present and absent databases. Release-note context: channel ingress prepares pairing allowlists in the shared read worker; released synchronous SDK behavior and fail-closed ingress remain.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Resolve the additive Gateway test inventory conflict by retaining both pairing and ACP diagnostics shutdown tests. The introduced pairing patch is unchanged and fresh P2 review is clean.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…tion Merge main to include the repaired Plugin SDK API comparison tool and the pre-existing fullscreen board frame fix. Preserve the pairing implementation and released synchronous SDK contract. Extend the real-worker inherited-account tests to require that ingress grants no permission and does not dispatch after a worker error. Keep absent-store refusal coverage. Focused worker, SDK, import-closure and wrapper checks pass; the formerly failing board test now passes, and fresh P2 review is clean.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Cold isolated Gateway tests can spend most of their behavior deadline transforming the mandatory managed-reloader module after readiness. Load that real dependency when the shared metadata fixture is collected, as the testing guide requires for mandatory import preparation. Production lazy loading, the 120-second timeout, startup, last-known-good promotion, audit readiness, and all assertions remain unchanged. Plain-main control timed out before the pairing assertions; a fresh-cache control with this preparation reached its expected synchronous-pairing baseline failure in 49.5 seconds. The existing port-reservation test passes in 35.4 seconds (470.4 seconds wrapper wall), the Gateway-server typecheck passes, and independent P2 review is clean. Unblocks shutdown-regression validation for #164476.
Merge current main without rebasing, retaining both generated-HTML provenance and pairing read registrations. Follow the retained-operation helper into worker-runtime and exercise the existing public pairing reader in the shutdown regression. Main contains the separately reviewed fixture-preparation repair c4813d6. The full pairing shutdown regression now passes with its unchanged timeout and assertions (37.8 seconds test time). Gateway-server typechecking and independent P2 review pass.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Integrate main's unused-import and retired Doctor test-inventory fixes without rebasing the reviewed pairing allowlist worker change.
|
@clawsweeper re-review Head 0053c28 integrates main's independently fixed unused import and obsolete Doctor test inventory. Pairing production changes are unchanged; fresh P2 review and all 21 security/lifecycle/import/signature tests passed. The compatibility record is SDK deprecation metadata, with no stored-data migration or schema change. Exact-head SDK comparison and CI are in progress. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
Restore the dynamic import at the default ingress allowlist reader. The static import introduced in f02d516 (#164476) made memory-wiki's Doctor contract reach Kysely through security-runtime and the shared-state reader. Keep the worker-backed pairing reader and its refusal behavior; defer its database graph until an actual store read. Leave the closure guard unchanged. Validation: 69 focused Doctor, ingress, and pairing tests; both import-cycle checks; core typecheck; targeted formatting and lint. Full build attempted but stopped during package declarations after 11 minutes in that stage under host contention; this is not passing full-build evidence.
Cold isolated Gateway tests can spend most of their behavior deadline transforming the mandatory managed-reloader module after readiness. Load that real dependency when the shared metadata fixture is collected, as the testing guide requires for mandatory import preparation. Production lazy loading, the 120-second timeout, startup, last-known-good promotion, audit readiness, and all assertions remain unchanged. Plain-main control timed out before the pairing assertions; a fresh-cache control with this preparation reached its expected synchronous-pairing baseline failure in 49.5 seconds. The existing port-reservation test passes in 35.4 seconds (470.4 seconds wrapper wall), the Gateway-server typecheck passes, and independent P2 review is clean. Unblocks shutdown-regression validation for openclaw#164476.
…reader (openclaw#164476) * refactor(channels): read pairing allowlists through shared-state reader Move the existing async allowlist API to the shared-state read owner, capture its physical source before yielding, and preserve current reads, account normalization, ordering, and ingress authority. Retain the released synchronous SDK contract as deprecated compatibility. Missing async reads grant no permission without initializing storage; boot and Doctor keep initialization. Boundary proof observes two caller-thread pairing queries before the cutover and zero afterward. Shared kernels remain T1 for SDK compatibility and pairing mutations; no schema, cache, retention, or durability changes. * chore(plugins): record deprecated pairing reader allowance Reserve one deprecated channel-pairing export for the required released synchronous allowlist compatibility window. Total public exports remain unchanged. * fix(channels): preserve pairing reader refusal errors Apply the native array selection before worker serialization so inherited account keys retain TypeError instead of returning an object or causing a transport failure. Add real-worker regressions for both inherited keys.
Restore the dynamic import at the default ingress allowlist reader. The static import introduced in 837ad2f (openclaw#164476) made memory-wiki's Doctor contract reach Kysely through security-runtime and the shared-state reader. Keep the worker-backed pairing reader and its refusal behavior; defer its database graph until an actual store read. Leave the closure guard unchanged. Validation: 69 focused Doctor, ingress, and pairing tests; both import-cycle checks; core typecheck; targeted formatting and lint. Full build attempted but stopped during package declarations after 11 minutes in that stage under host contention; this is not passing full-build evidence.
What Problem This Solves
Per-message channel ingress awaited
readChannelAllowFromStore, but that Promise ran synchronous SQLite reads on the Gateway thread, including unrelated pending pairing requests.User Impact
Pairing allowlists are prepared in the existing shared-state reader worker. Account normalization, persisted-row ordering, DM policy gates, and fail-closed ingress remain unchanged. Missing async reads grant no permission and do not initialize storage; boot and Doctor retain initialization ownership. Inherited account keys retain their native
TypeError, including when the store is absent.The synchronous
readChannelAllowFromStoreSyncSDK export retains its released signature and behavior until the next Plugin SDK major. No schema, stored-data format, retention, durability, permission policy, or update migration changes.Why This Change Was Made
Register
pairing.allowFromwith the existing read worker and reuse the ordered allow-entry query. Capture the physical store and canonical channel/account before yielding, request current rows outside discovery snapshots, and retain the reader's admission, typed-error, and cleanup ownership. Channel policy remains the authorization owner. Worker errors propagate without replay or host-SQL fallback; real ingress grants no permission and does not dispatch when the worker refuses.The released synchronous path has a compatibility record, signature test, migration note, and deprecated-export allowance. Its record is in the compiled-wrapper inventory. Both reader signatures and the runtime adapter were inspected directly in
v2026.9.8; no public export was removed or added. The record is deprecation metadata, not a database migration. Request/approval mutations, device pairing, and standing grants remain outside this read-only cutover. No host callback or SQL was added inside a worker grant. The diff adds zero newOPENCLAW_*names.Evidence
Head
0053c28a3ab0dd0b0cc1032cc3e1cbed720f7185integrates main1836ae2146443e952337bce1bccb41c524ea0639without rebasing or conflicts. The pairing production delta is unchanged. The earlier additive registry conflict retains both main's generated-HTML provenance reader and this PR's pairing reader.v2026.9.8completed exit 0, including cleanup, with checked evidence digest27154595960979a119ea6dd9ec553bd2470db9ff28160d1be51c471ae75d1d4e: neither reader export changed, and the pairing entrypoint remains. The exact-head CI run completed successfully: all 103 jobs succeeded or were intentionally skipped; none failed or was cancelled.Shutdown Timeout Investigation
The aa5 CI run had two root jobs reporting one stale test import after main moved the helper to
@openclaw/worker-runtime/lifecycle. The corrected test now uses that canonical helper and the existing public pairing reader.The subsequent startup timeout was reproduced with the identical test over plain main
ca267fa035f8e, without PR production code. Owner tracing showed cold Vitest transformation of the mandatory reloader graph after Gateway readiness, inside the 120s behavior deadline. The import eventually completed; config-health reads/writes, last-known-good promotion, audit readiness, and server-handle publication all settled. This was fixture preparation cost, not a demonstrated pairing or SQLite deadlock. The deferred import predates this work (cbaa21e6e32ba, September 4), as does the shared fixture (b5134de70af88, September 11).Main repair
c4813d6897ecprepares that real module during shared-fixture collection, following the testing guide. Production retains its lazy import; no timeout, sleep, retry, startup operation, or assertion was weakened. A fresh-cache main control completed startup and reached the expected synchronous-pairing baseline failure in 49.5s. The existing port-reservation test passed in 35.4s (470.39s wrapper wall); typechecking and P2 review passed. The complete PR regression now passes after integrating the repair. Temporary diagnostics were removed.Earlier CI Attribution
The C5 UI failure,
board-mcp-app.e2e.test.ts:527, reproduced identically in 5/5 PR-head and 5/5 main merge-base runs with 602px iframe gaps. All eight relevant UI inputs match across the reproduced baseline, CI base, PR head, and tested merge. This PR does not change those inputs or participate in that mocked UI flow. Main frame fix11515ce5b3dais integrated, and all five UI tests passed locally afterward.Main Linux test-inventory repair
53eb4193d0ed, the subsequent Knip entry correctionbf4fe3ace5702, and orphaned internal-type cleanupc13c48696949are also integrated. Full dead-code validation, isolated core typechecking, and P2 review passed for those repairs. No admin exception or unexplained rerun-for-green has been used.Additional CI Repairs
The ddf57da1 CI run exposed two inherited main defects: the unused
normalizeProviderIdimport in model discovery and a deleted Doctor test still registered in the database-worker inventory. The latter test was intentionally removed by02aa58710dce(#164669). Main fix1836ae214644(#164675) removes the import and stale inventory row; this integration incorporates that fix. The repeated production/test-type and lint failures share the same unused-import root. Neither failing source is changed by this PR.ClawSweeper completed review of
ddf57da1with no introduced correctness or security finding. Its automated stored-data prompt nameschannel-pairing-record.ts, which only declares SDK deprecation metadata. It performs no migration, backfill, repair, or storage operation. Released behavior is covered by the signature test, sync/async result comparison, and release-tag API comparison. ClawSweeper completed the integrated head0053c28a3ab0dat 2026-10-04T02:42:08.614Z with no actionable or security findings and explicitly confirmed the prior data-compatibility blocker does not apply. The report still contains an automatic migration checklist for the metadata filename; that checklist is rejected on the inspected source and the review's own compatibility finding.Main drift inspected through
cc740dfaf528f: overlapping shared request/validation edits only remove ACP legacy-metadata fields; wrapper inventory adds an unrelated worktree-template worker. Those hunks do not change pairing capture, validation, or permission policy. No additional integration is required for those disjoint changes.