Skip to content

fix(channels): preserve ordinary thread session bindings - #190763

Merged
roboclaw-bot merged 3 commits into
mainfrom
feat/channel-fork-bindings
Nov 2, 2026
Merged

roboclaw-bot merged 3 commits into
mainfrom
feat/channel-fork-bindings

Conversation

@roboclaw-bot

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

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Ordinary thread-bound conversations were recorded as ACP sessions and could enter the wrong reconciliation lifecycle after restart. Landing review also exposed opaque plugin-owned targets being sent through ACP agent selection, including metadata-omitting refreshes.

User Impact

Ordinary session bindings remain ordinary through creation, persistence, reload and cleanup in Discord, Matrix and Telegram. Canonical ACP keys, supported main/global ACP aliases and explicit subagents retain their behavior. Plugin-owned opaque targets work with explicit multiple agents and no default agent. This is prerequisite A of the threaded /fork stack; it does not expose /fork itself.

Why This Change Was Made

Keep the existing public session/subagent contract in each plugin’s private record. The worker-backed ACP metadata reader classifies supported aliases; unreadable stores refuse classification before native creation. Legacy ACP-coerced ordinary rebinding preserves same-target metadata without bulk rewriting historical explicit tags.

The landing repair uses canonical plugin-ownership metadata, not target-key prefixes, arbitrary agent selection or broad exception swallowing. Discord creation/hydration/reply identity tolerate an absent agent owner. Matrix preserves plugin metadata through creation, projection, persistence and hydration.

For partial refreshes, only the same target and same public-kind family inherit ownership facts. Child placement, replacement targets and kind changes do not inherit them. Native/action hints remain incoming-only; Matrix introText is not replayed from stored metadata. Currentness callbacks and effect-boundary checks remain intact.

No database schema, configuration, dependency, retention or intentional permission-policy changes. The updater is unchanged and no migration step is added. The separate F refactor consolidates classification; this PR repairs lifecycle behavior in the existing owners.

Evidence

Current landing repairs: deff77c

  • Real interactive producer → approval → actual adapters, with alpha/beta agents and no default: opaque-target failures reproduced before repair. Tests retain real ACP-reader delegation and cover refresh, persisted reload, detach, incomplete ownership and replacement/kind isolation.
  • Initial opaque-target repair campaign: six adapter/sibling files, 117 passed (944.90s). Final standalone creation/reload suites: Discord 22 (40.97s), Matrix 27 (136.00s), Telegram 35 (61.90s).
  • Partial-refresh regression reproduced AgentSelectionRequiredError in all three adapters. Final original ordered five-file database shard: 103 passed (77.20s). Unchanged reply-delivery sibling: 14 passed in the preceding campaign. A test-owned kind-change row was explicitly unbound to repair the original ordered cleanup failure; no assertion was weakened.
  • Tests use node scripts/run-vitest.mjs <file> --maxWorkers=1 with task-specific compiler caches. Added repair test lines are explicitly allocated: 167 opaque-target lines and 148 partial-refresh lines. CI seconds are reported by the attached run, not inferred locally.
  • Focused production/test types, scoped lint, formatting, whitespace and the extension-test core-import guard passed. Fresh P0–P2 independent reviews of both repair deltas completed scoped-clean with zero findings; the final refresh review received 34 complete context files.
  • Committed final CLI-startup build completed successfully. Discord, Telegram and Matrix cold-import snapshots all qualified with no gaps; process/temporary-home cleanup was verified. Earlier dirty/stale-declaration screenings remain unqualified and are not reused as this result.
  • No new live-channel or live-Gateway run is claimed for these repairs. Current-head CI and native admission remain required before merge.

Original feature baseline: 26fa359

  • Ordinary-target regressions failed on all three original producers (acp instead of session).
  • Original per-file --maxWorkers=1 proof: Discord 21 passed, 45.11s; Telegram 31, 16.94s; Matrix 26, 11.14s. Discord authority/state/subagent siblings: 23 passed.
  • Original focused types/lint/format and diff checks passed. Original pnpm build: exit 0, 8m17.6s, with advisory UI asset-budget warnings. Subsequent landing findings are repaired and reviewed above.

Stack

A → B (shared command/core recording/Telegram) → C (Discord) / D (Slack) / E (Control UI), with separately published F–I refactor follow-ups. Retarget dependents after prerequisites land, preserving incremental review and exact-head qualification. Landing is authorized; operator Gateway deployment is outside this request.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: matrix Channel integration: matrix channel: telegram Channel integration: telegram size: M labels Nov 2, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR preserves ordinary session bindings through creation, persistence, reload, and cleanup in Discord, Matrix, and Telegram.

Example: Bind a Discord thread to agent:main:fork:ordinary, then restart.

  • Before: The binding is stored as ACP and can be removed because it lacks ACP metadata.
  • After: The binding retains the session kind and bypasses ACP startup cleanup.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused manager tests support the intended repair, but a reachable compatibility regression blocks merge.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An ordinary conversation bound to a native thread can acquire ACP lifecycle behavior and lose its binding after restart.
Reason: The maintainer-authored direction restores the existing public session/subagent contract without exposing the separate fork feature.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this maintainer-authored draft open: the central fix remains necessary on main, but an introduced plugin-binding regression blocks merge.

Priority: P2
Reviewed head: 26fa359d7ca57211e1c9fe6cfed9d88bb82befbe

Before merge

  • Exclude plugin-owned opaque targets from ACP owner resolution (P1) - With agents.ownership set to explicit, agents.entries containing alpha and beta, and no system-agent default, a normal Telegram plugin binding now throws before it can be stored. bindConversationNow generates a plugin-binding:<plugin>:<hash> target with targetKind session and no metadata.agentId. This new call passes that opaque key to resolveSessionStorePathForAcp, which throws AgentSelectionRequiredError because the target has no agent owner. Previously Telegram stored this supported plugin-owned binding without selecting an agent. Preserve that ownership boundary instead of classifying plugin targets through ACP storage, and cover the real plugin-binding producer under a multi-agent configuration.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Exclude plugin-owned opaque targets from ACP owner resolution — extensions/telegram/src/thread-bindings.ts:319-322

Tests

  • Missing end-to-end proof: No supplied run upgrades v2026.10.9 with existing bindings and settings intact, then exercises ordinary binding creation and restart through the shipped channel path.
Agent review details

How this fits together

The shared binding service passes session targets and conversation references to channel adapters, whose existing managers persist routing records and apply lifecycle cleanup.

flowchart TD
  A[Binding caller] --> B[Shared binding service]
  B --> C[Channel adapter]
  C --> D[ACP metadata reader]
  C --> E[Existing binding manager]
  E --> F[SQLite binding store]
  F --> G[Reload and lifecycle cleanup]
Loading

Technical review

Best possible solution:

Preserve ordinary binding kinds while keeping plugin-owned opaque targets outside ACP classification and retaining supported ACP alias handling.

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

Source inspection establishes the ordinary-session coercion and Discord cleanup path; the body reports failing original-producer regressions, but this read-only review ran no target code.

Is this the best way to solve the issue?

Extending the existing private records is a focused repair with no unnecessary manager or storage layer, but classification must respect plugin ownership rather than require every session target to resolve through ACP storage.

Full review comments:

  • [P1] Exclude plugin-owned opaque targets from ACP owner resolution — extensions/telegram/src/thread-bindings.ts:319-322
    With agents.ownership set to explicit, agents.entries containing alpha and beta, and no system-agent default, a normal Telegram plugin binding now throws before it can be stored. bindConversationNow generates a plugin-binding:<plugin>:<hash> target with targetKind session and no metadata.agentId. This new call passes that opaque key to resolveSessionStorePathForAcp, which throws AgentSelectionRequiredError because the target has no agent owner. Previously Telegram stored this supported plugin-owned binding without selecting an agent. Preserve that ownership boundary instead of classifying plugin targets through ACP storage, and cover the real plugin-binding producer under a multi-agent configuration.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 18e52ca69eae.

Provenance checked

  • Telegram binding representation and metadata inheritance changes intended behavior with a stated reason (71bb516: The worker migration retained existing record semantics, ordered mutation ownership, and strict binding publication; this commit carries the coercion but does not establish its original introduction.)
  • Discord session-kind conversion changes intended behavior with a stated reason (38c0f85: The cleanup inlined an existing conversion helper while preserving behavior; this PR explicitly explains why ordinary targets need a distinct private kind.)
  • Matrix adapter and stored binding normalization changes intended behavior with a stated reason (76a282c: The worker migration separated the adapter from persistence while retaining one binding owner and compatibility methods; this PR retains that architecture.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/telegram/src/thread-bindings.test.ts --maxWorkers=1
  • pnpm test extensions/discord/src/monitor/thread-bindings.creation.test.ts --maxWorkers=1
  • pnpm test extensions/matrix/src/matrix/thread-bindings.test.ts --maxWorkers=1
  • pnpm test src/plugins/conversation-binding.sqlite.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 71bb516 adds extensions/telegram/src/thread-bindings-session.ts:55 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 71bb516084f5; files: extensions/telegram/src/thread-bindings-session.ts)

PR surface

Source +90, Tests +223, Docs +3, Other +1. Total +317 across 18 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 11 107 17 +90
Tests 3 223 0 +223
Docs 3 4 1 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 18 335 18 +317

Labels

Label changes:

  • add P2: This is a focused binding-lifecycle repair across three channels, without evidence of a widespread current outage.
  • add merge-risk: 🚨 compatibility: The new ACP lookup rejects previously supported Telegram plugin bindings when no agent owner can be selected.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a focused binding-lifecycle repair across three channels, without evidence of a widespread current outage.
  • merge-risk: 🚨 compatibility: The new ACP lookup rejects previously supported Telegram plugin bindings when no agent owner can be selected.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed November 1, 2026, 8:35 PM ET / November 2, 2026, 01:35 UTC.

@roboclaw-bot
roboclaw-bot merged commit 9710c42 into main Nov 2, 2026
121 checks passed
@roboclaw-bot
roboclaw-bot deleted the feat/channel-fork-bindings branch November 2, 2026 16:07
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…0763)

* fix(channels): preserve ordinary thread session bindings

Co-authored-by: vincentkoc <[email protected]>

* fix(channels): preserve opaque plugin binding ownership

Co-authored-by: vincentkoc <[email protected]>

* fix(channels): retain plugin ownership on partial binding refresh

Co-authored-by: vincentkoc <[email protected]>

---------

Co-authored-by: vincentkoc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: matrix Channel integration: matrix channel: telegram Channel integration: telegram docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant