Skip to content

fix(clickclack): discussion rooms fail with PostgreSQL agents - #189977

Merged
VACInc merged 3 commits into
mainfrom
openclaw/pg-plugin-compat-audit
Nov 18, 2026
Merged

VACInc merged 3 commits into
mainfrom
openclaw/pg-plugin-compat-audit

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

High Level TLDR

Panels → Discussion can open a ClickClack room when the Gateway stores agent sessions in PostgreSQL. File-backed ClickClack credentials continue to work after the async session change.

Root Cause

The discussion open path used the synchronous latest-session reader to check authority before channel operations and when persisting a binding. On a Gateway with PostgreSQL agent storage, the store rejects synchronous access on the Gateway thread. The original built Gateway reproduction returned UNAVAILABLE: PostgreSQL connections must run in a worker before the loopback fixture received a channel create request.

The open path now uses the existing async prepared-session helper. It refreshes the session at each effect and at binding commit, and releases the preparation in finally. A reset during HTTP can still bind the current session. The recheck uses isDiscussionAccountCurrent, which compares the token-file path for file-backed credentials. Comparing the metadata token against a prepared token rejects an otherwise current account because metadata deliberately leaves the token empty. The existing file-backed test failed with ClickClack discussion authority changed while opening the channel before this correction.

Verification

Real behavior proof

  • The earlier built Gateway proof used a PostgreSQL agent store and a loopback ClickClack endpoint. sessions.create → session.discussion.open → session.discussion.info produced one remote channel and an independently verified persisted binding. A reset during the held channel-create response still bound the current session. Archiving during the response refused the attachment and left no binding. This proof predates the branch refresh.
  • On the refreshed code, node scripts/run-vitest.mjs extensions/clickclack/src/discussions/{service-contract,service,service-state-persistence,service-open.agent-storage}.test.ts test/scripts/{postgres-conformance-shards,database-conformance}.test.ts --maxWorkers=1 --reporter=dot passed 128 tests in six files. The existing file-backed test goes through discussion open before checking grant rotation. The real-storage regression ran locally with SQLite. PostgreSQL CI discovers the same test via the conformance planner.
  • The test-line ratchet passed with +234 lines and 234 lines of allocation credit. The shared ceiling is unchanged.

What was not tested

The refreshed branch's local run used SQLite and a synthetic ClickClack transport. It did not run the complete Gateway/PostgreSQL exercise, measure latency, or use a live ClickClack account. Hosted checks are tracked on this PR.

Contributor credit

Co-authored with @etzelm.

@clawsweeper

clawsweeper Bot commented Nov 1, 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.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 1, 2026 02:25
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Use worker-prepared session authority when creating, recovering, and binding ClickClack discussion rooms.

Example: Open a discussion for agent:main:dashboard:proof-room with PostgreSQL-backed agent storage.

  • Before: Opening fails with “PostgreSQL connections must run in a worker” before channel creation.
  • After: The room opens and its persisted binding matches the current PostgreSQL session.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with shipped Gateway evidence, meaningful authority controls, unchanged persisted formats, and no open findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Built CLI/Gateway proof exercises PostgreSQL open, reset during HTTP, independent discussion info and persisted binding checks, plus archive during POST with attachment refused and no follow-up request. Real-client/real-storage controls additionally reject credential and destination retirement before creation and recovery. The proof source tree matches the reviewed head; the external endpoint is synthetic and no model inference is claimed.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Panels → Discussion cannot open a room when agent storage uses PostgreSQL.
Reason: Restores an existing supported workflow without new configuration or public APIs; maintainer-authored direction is already established.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current PostgreSQL discussion-opening failure while preserving session resets and live authority checks; no actionable findings remain, and exact-head CI is still pending.

Priority: P2
Reviewed head: a0fd38358dc454a223dc872e17177e6f26ba3719

Before merge

None.

Findings

None.

Agent review details

How this fits together

The ClickClack discussion service receives session discussion RPCs, reads session authority through the Plugin SDK, creates or adopts remote channels, and commits local bindings through the existing guarded state store.

flowchart LR
  A[Discussion RPC] --> B[ClickClack discussion service]
  B --> C[Prepared session authority]
  C --> D[Agent database worker]
  B --> E[ClickClack HTTP client]
  E --> F[Remote discussion channel]
  B --> G[Guarded binding store]
Loading

Technical review

Best possible solution:

Merge the focused repair once the existing exact-head CI gates pass.

Do we have a high-confidence way to reproduce the issue?

Current-main source reaches the forbidden synchronous PostgreSQL read, and the supplied baseline Gateway trace records the matching failure; this review executed no target code.

Is this the best way to solve the issue?

The smallest complete fix is to replace opening-path synchronous reads with the existing prepared authority owner, retain preparation through each effect, and reacquire after HTTP so resets remain supported.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 31866655fd60.

Provenance checked

  • Opening authority and shutdown settlement keeps the original intent (af78348: Keep live account and session checks around durable channel creation while draining accepted operations during shutdown.)
  • Reset-following durable room attachment keeps the original intent (5cd2c5b: Keep the ClickClack room durable while allowing its concrete OpenClaw session attachment to change.)
  • Worker-prepared session authority keeps the original intent (1a2494e: Replace synchronous storage readers with receipt-backed authority; opening was deferred because it must follow resets during HTTP.)
  • Reset regression fixture keeps the original intent (83ce140: Protect session replacement during asynchronous reads; the revised fixture selects observable phases instead of read ordinals and preserves binding assertions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +22, Tests +235, Other +2. Total +259 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 61 39 +22
Tests 4 239 4 +235
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 0 +2
Total 7 302 43 +259

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Discussion opening is broken for PostgreSQL-backed agents, with impact limited to this optional channel workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-01T02:58:33.230Z sha ea0008a :: needs real behavior proof before merge. :: [P2] Keep authority refusals out of HTTP recovery
  • reviewed 2026-11-01T03:32:57.160Z sha a0fd383 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-01T03:38:46.426Z sha a0fd383 :: needs maintainer review before merge. :: none

Reviewed October 31, 2026, 11:44 PM ET / November 1, 2026, 03:44 UTC (Revision 4).

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Nov 1, 2026
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Nov 4, 2026
roboclaw-bot and others added 3 commits November 18, 2026 15:48
Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 94c395aa-646c-4c16-8d2c-49b9001aa862
Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 4c630fa6-e324-4347-b04c-bd392c4e4cc0
Worked on by:
- @etzelm

Co-authored-by: etzelm <[email protected]>
OpenClaw-Publication: 6a487761-d0b7-409a-97bf-8e56347f5850
@VACInc

VACInc commented Nov 18, 2026

Copy link
Copy Markdown
Member

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor extensions: clickclack P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: M 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.

2 participants