Repository navigation
fix(clickclack): discussion rooms fail to open when plugin state runs on PostgreSQL - #188643
Conversation
The revoked discussion channel store keyed markers by the server URL and channel id joined with NUL. PostgreSQL plugin state rejects NUL in keys, so opening a discussion room failed with PLUGIN_STATE_INVALID_INPUT after the room was created, and close and cleanup failed the same way. Key markers by a sha256 prefix of the encoded pair, and adopt markers still stored under the NUL key (SQLite only) once per runtime by listing the namespace.
|
🦞👀 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 real behavior proof before merge. What this changesThis PR hashes ClickClack revoked-channel keys and migrates existing SQLite markers to the new keys. Example: Open a discussion for agent:main:dashboard:proof-room with PostgreSQL state.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 5 items remain This PR fixes a verified PostgreSQL failure, but its migration breaks routing when the existing marker store is full and needs further authority-boundary validation. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherClickClack discussion operations and message routing consult plugin-owned revocation markers before using a bound channel or granting access to its attached session. flowchart TD
A[Discussion panel or channel message] --> B[ClickClack discussion service]
B --> C[Revocation store]
C --> D[Plugin state worker]
D --> E[SQLite or PostgreSQL]
B --> F[Channel operations and session access]
Technical reviewBest possible solution: Keep portable hashed keys in the existing revocation owner, migrate markers without requiring spare capacity, and preserve revocation at every access boundary. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the NUL-key rejection, and inspected contributor captures demonstrate it through the Gateway; no target code was executed during this review. Is this the best way to solve the issue? Portable hashing fixes the producer and the added tests cover distinct storage boundaries, but adoption must preserve authority and work without temporary spare capacity. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f4c7eb489a1f. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: The persisted revocation-key cutover needs final-effect denial proof for revoked discussions. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +34, Tests +99, Other +1. Total +134 across 5 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 30, 2026, 3:48 PM ET / 19:48 UTC. |
Start legacy marker adoption during registration and keep synchronous authorization closed until it succeeds. Preserve async retry after failed adoption and cover the pending-to-complete transition.
|
Merged via squash.
|
… on PostgreSQL (openclaw#188643) * fix(clickclack): use a PostgreSQL-safe revoked-channel key The revoked discussion channel store keyed markers by the server URL and channel id joined with NUL. PostgreSQL plugin state rejects NUL in keys, so opening a discussion room failed with PLUGIN_STATE_INVALID_INPUT after the room was created, and close and cleanup failed the same way. Key markers by a sha256 prefix of the encoded pair, and adopt markers still stored under the NUL key (SQLite only) once per runtime by listing the namespace. * fix(clickclack): deny access until revocation adoption completes Start legacy marker adoption during registration and keep synchronous authorization closed until it succeeds. Preserve async retry after failed adoption and cover the pending-to-complete transition. * test(clickclack): allocate the full revocation regression coverage --------- Co-authored-by: Peter Steinberger <[email protected]>
Closes #188642
What Problem This Solves
Fixes: opening a ClickClack discussion room fails with "PostgreSQL plugin state keys cannot contain NUL characters" when the state database family runs on PostgreSQL, after the remote channel has already been created.
User Impact
User impact: on PostgreSQL state, ClickClack discussion rooms open, close and clean up as they do on SQLite. SQLite installs keep every revoked-channel marker they already hold; nothing needs to be done after the update.
Why This Change Was Made
The revoked discussion channel store keyed its markers by the server URL and channel id joined with a NUL character, which the PostgreSQL plugin state kernel refuses. Following #184919 (the same rule for the iMessage plugin), the key is now a hex sha256 prefix of the JSON-encoded pair, with the same trailing-slash normalization as before.
Markers written under the NUL key exist only on SQLite and are authority evidence (they keep released channels revoked), so they are re-keyed once per runtime: registration starts adoption immediately, and async store operations await the same adoption before proceeding. Adoption lists the namespace and moves each NUL-keyed marker with
registerIfAbsentanddelete. Synchronous authorization checks deny access until adoption succeeds; on failure they keep denying while the next async operation retries. PostgreSQL never held one, so the listing finds nothing there. The adoption can be removed once no supported stable release writes the NUL key. A Doctor migration was the alternative, but plugin state markers are plugin-owned, and the in-plugin adoption matches the merged iMessage fix.Accepted edge cases:
Evidence
Final-head CI run 41126484646 passed, including all three PostgreSQL conformance shards, changed tests, baseline ratchets, security-fast, and the effective CI gate. The initial maintainer run caught a missing allocation for the full test delta; the dedicated allocation now covers all 103 added regression lines.
Maintainer hardening at
7370123ad73ba18f3f814d21d9afdf17566fce41closes the synchronous startup authorization gap. The extended SQLite legacy-marker regression checks denial for both revoked and unrevoked channels before adoption completes, then verifies that the legacy-revoked channel stays revoked and the unrevoked channel is allowed. The full 103-line regression growth has a dedicated allocation.The maintainer edit passes static formatting and diff checks. Independent Codex reviews of the repair and the complete final branch at
0febd35184fad1d985a38551ee0c7b2399b11e58against merge-base83064b3ae1155f0c6c96081c863e7db4bd4451f4found no accepted P0/P1 findings. No contributor runtime code or tests were executed locally during maintainer landing; new-head runtime validation uses PR CI.Tested at
c980afaf3dc(baseupstream/main83064b3ae115).An isolated Gateway (own state directory and port) with
database.families.state.engine: "postgres"against a throwawaypostgres:17-alpinecontainer, the ClickClack plugin pointed at a local fake ClickClack server, and a synthetic bot token. Both sides ransessions.createforagent:main:dashboard:proof-room, then the Gateway method the Control UI's discussion panel calls:Before (base
83064b3ae115):After (this PR):
Observed result: on the base the channel is created and the open fails, again on retry; with the fix the room opens, and
session.discussion.inforeportsstate: open.Full captures: before, after.
Upgrade from the latest stable on SQLite state: openclaw v2026.10.9 with
@openclaw/[email protected]opened the session's room (chn_room1), and a bot token rotation in config made the binding stale, so the release revoked the channel andsession.discussion.inforeportedstate: available. On the same state directory,openclaw doctor --fixfrom this branch, then this branch's Gateway:The NUL-keyed row is gone and no Gateway log line mentions NUL characters. Full capture: upgrade.
Tests:
revoked-channel-store.postgres.test.ts(mark, read and clear a revoked channel on PostgreSQL state, run throughnode scripts/test-database-conformance.mjs --engine postgres) fails on the base with the same NUL error and passes with the fix.adopts a revocation stored under the NUL-joined SQLite key onceinservice-state-persistence.test.tsfails on the base and passes with the fix; the other 21 tests in that file pass on both.Checks: the touched tests (
pnpm test <file> --maxWorkers=1, wall time per file below; the PostgreSQL file skips without a connection there and took 31.0 s through the conformance lane, 0.5 s of it the test), the extension test typecheck (pnpm tsgo:extensions:test), oxlint and the formatter on the changed files, and the test-line ratchet; the broad suites run in this PR's CI.--maxWorkers=1wallextensions/clickclack/src/discussions/service-state-persistence.test.tsextensions/clickclack/src/discussions/revoked-channel-store.postgres.test.tsNot covered: the proof uses a fake ClickClack server rather than a real one, and drives the Gateway method directly rather than through the Control UI panel. On PostgreSQL, the conformance test covers identity marking, the async read and clear; room close (the binding-conditioned mark) and the inbound prepared read use the same key but were not run there. The upgrade run shows the marker re-keyed and kept, not a revoked channel refusing an inbound message: the fake server has no event stream, so inbound routing was not driven.