Skip to content

fix(discord): codex detach and rebind are lost after a Gateway restart - #177691

Closed
MarMarLabs wants to merge 14 commits into
openclaw:mainfrom
MarMarLabs:fix/discord-thread-binding-owner-runtime
Closed

MarMarLabs wants to merge 14 commits into
openclaw:mainfrom
MarMarLabs:fix/discord-thread-binding-owner-runtime

Conversation

@MarMarLabs

@MarMarLabs MarMarLabs commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #178330. Related to #175379.

What Problem This Solves

A Discord thread detached with a typed /codex detach can become bound again after the Gateway restarts. A typed /codex bind that moves a bound thread to a new workspace can also be undone by a restart.

User impact

Detached threads stay detached, rebinds keep their new workspace, and later binding changes remain durable. A write refused by a retired runtime or a closing Gateway no longer disables persistence, and a refused binding change reports a failure, not success. A replacement Discord provider that starts after its predecessor retires gets its own thread binding manager, so its bind, idle timeout and detach writes persist. No config change or migration is needed.

A row left behind by an earlier detach is still loaded at startup. That thread needs one more /codex detach on this build.

The repair reaches core runtime-owned state stores, so the Telegram, ClickClack and /codex caller suites are included below. Matrix's separate no-instance repair is #177372.

Cause and repair

Discord looked up its plugin runtime in the slot of the plugin instance currently running, and a typed detach starts in the /codex instance, where the Discord slot is empty. The write threw Discord runtime not initialized, the manager changed memory and disabled persistence for the process, and the command appeared to succeed until restart.

Each Discord manager now retains its creating runtime and passes it into async and synchronous store opens, and session-wide idle timeout, max age and unbind helpers read the same runtime from a private WeakMap through the account registry. Core now checks a runtime-owned synchronous store at open and before all seven mutators, update and deleteIf also after their callback. Already-open handle reads are unchanged.

The state runtime marks its authority refusal with PLUGIN_STATE_RUNTIME_INACTIVE, and the worker client preserves it. Discord tells it from a storage failure through the SDK facade it already imports, drops the uncommitted write and leaves persistence on. For a retired runtime, async unbind, bind, detach and the session-wide idle timeout, max age and unbind updates reject with it, send no unbound notification and publish no record. The check runs before every shared-memory publication, including a touch inside the 15 s persist interval and a manager with persistence off or latched off. It opens a data-only V2 handle with no store operation before the operation module source is captured. Synchronous compatibility calls still return null or an empty array, a retired owner's touches resolve null, and a deleted thread still closes its sessions after a refused unbind. Real storage failures still disable persistence and apply the change in memory.

createThreadBindingManager used to return the account's cached manager even after its owner retired, so a replacement provider's own bind, idle timeout and detach were refused, and after the old stop removed the adapter nothing recovered until a later acquisition. Now, when the cached manager's runtime is inactive, acquisition checks that the caller's runtime is active, starts the old stop without waiting for it, and registers a new manager that retains the caller's runtime. The old manager's runtime is never reassigned, and its late stop clears the slot and adapter only while it owns them. A live owner's manager is still reused, an inactive caller still gets the typed refusal, and a reference taken while its owner was live stays refused after retirement.

Reviewed through 5388ada4c289, manager method signatures, account queues and the runtime lookup for managers without a retained runtime are unchanged.

Public SDK semantics change for retired runtimes. Typed and plain runtime refusals now count as closed admission for SDK retries and tool outcomes. New synchronous opens and writes through retained synchronous handles now refuse work, and async binding changes through a retired Discord manager now reject. An October 19 usage query found no resolved references to this member but covered only 2,047 of 2,432 eligible artifacts, so third-party impact is unknown. createThreadBindingManager, exported from the Discord runtime API, now also replaces the cached manager of a retired owner, and in that case it throws the typed refusal if the caller's runtime is inactive or missing.

Evidence

At 857edb7316cf, six PR test files passed 218 tests, 15 plugin-state files passed 193 with one skipped, and ten baseline checks passed. My real Discord/model checks at d1e4495644c5 are in #177691 (comment). The checks passed, but the full runbook evidence remains inconclusive. Typed detach and rebind persisted across restart. These runs cover only the first half of the authority-chain item. Retirement and replacement writes ran in #177691 (comment), a scripted driver over the built production modules at d1e4495644c5 and not a Gateway reload. A checker's revoke run there covers revocation. Other results below ran at earlier heads.

Tests at 22ea62d

Head 857edb7316cf merges 5388ada4c289, uses upstream's publicationEffect helper and adds six cases. Commit 22ea62d adds src/plugins/conversation-binding.discord-handoff.test.ts with three cases. A live owner's retained manager refuses a candidate's writes after retirement until an explicit acquisition hands off. A replacement started after retirement gets a distinct manager whose bind, idle timeout, touch and detach persist, and the old manager's late stop leaves it registered. An inactive candidate cannot replace a retired owner. All three fail with the two production files from 56cd59f and pass at 22ea62d. Wrong versions that borrow the caller's runtime at call time, fall back to memory on the typed refusal, hand off over a live owner, or skip the candidate's activity check each fail one of them.

On a mocked clock, an uncommitted diagnostic found that at 56cd59f, after the owner retired, the candidate's idle timeout write was refused at five points from +1 s to +1 h. At main e2da41f the idle writes, bind, touch and detach all succeeded before the old stop. A probe then stopped the old instance from accepting calls, started the replacement with the old manager unstopped, and ran each operation in the replacement.

Operation 56cd59f production files 22ea62d
Bind Refused Persisted
/session idle Refused Persisted
Touch Null, no write Row updated
/codex detach Refused Removed
After the late old stop BINDING_ADAPTER_UNAVAILABLE Bind persisted

At 22ea62d the 14 Discord binding, listener and manager caller files passed 206 tests and the 7 conversation binding and contract files passed 128. The extensions type check, the core plugin-platform test type check, formatting and typed lint on the three files it changes, and the mock-exports and line-cap ratchets also passed. At 22ea62d, max-lines, the other ratchets, the SDK exports check, plugin inventory and config documentation were not rerun. At the 56cd59f production code they passed except max-lines, which flagged three unchanged UI files, and 17 Telegram, ClickClack and /codex caller files passed 310 tests.

The 19 retired Discord cases fail at d5f8321, and the bound-source and core open cases fail at ed59bdf. Real SQLite trigger failures verify the memory fallback. The /codex detach command file checks the failure reply and the restored native binding. A 30-cell guard matrix from 95d9afe through ed59bdf, a 45-cell probe and an uncommitted 153-cell probe of earlier heads found no durable difference and were not rerun.

Prior-head Gateway evidence, not rerun

The earlier local Gateway record used a Discord stand-in and mock model. It compares main 89e77376ccb with local merge 3a4095bc93d, the earlier de7639b repair. It was not rerun on a later head, and its typed detach reply predates the refusal path above. After detach, stop and a fresh start, main held 1, 1, 1 rows and the old binding returned after restart, while the merge held 0, 0, 0. A typed rebind run kept the new workspace through restart on the merge, not on main.

Remaining limits

The live runs did not cover a base build, a DM, Always allow or registry retirement, which the scripted driver ran. The full Discord extension project passed at 67b59f2ef60e and was not rerun after main changed 96 Discord extension files through 5388ada4c289. #178330 holds its author's pre-fix reproduction on a real Discord bot, which was not rerun on this branch.

The typed detach failure reply and the real store's refusal were measured separately, not together in a Gateway. The reload ordering, with the old instance's calls stopped before the replacement provider starts, was read from source and modeled with an instance that no longer accepts calls. The time from retirement to the replacement's acquisition was not measured, and writes in it are still refused. The handoff for a caller with no runtime has no test. A channel restart inside the same plugin instance after a timed-out stop still shares one manager, so the old task's late stop removes its adapter until the next provider start, as on main. A session-wide call while no manager is registered still uses the ambient runtime lookup, whose failure still turns persistence off, as on main. A session-wide update across two accounts stops at the first refused row without rolling back earlier rows, startup reconciliation does not catch a refused stale unbind, and a refused thread-delete unbind leaves its row for the replacement owner's sweeper.

@MarMarLabs
MarMarLabs marked this pull request as ready for review October 19, 2026 20:04
@clawsweeper

clawsweeper Bot commented Oct 19, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-31T07:50:20.689540Z
We couldn’t complete this review. Comment @codex review to try again.
857edb7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: M labels Oct 19, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de7639b875

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Discord binding managers retain their creating runtime, refuse retired-owner mutations, and hand persistence to active replacement managers.

Example: Send /codex detach in a bound Discord conversation, then restart the Gateway.

  • Before: The command reports success, but the stored binding returns after restart.
  • After: The binding row is deleted and the conversation remains detached after restart.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair has strong exact-head behavior evidence and no actionable code findings; unresolved public SDK direction limits readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): At the reviewed head, real Discord commands through a built Gateway preserve detach and workspace rebind across full process restarts; a separate production-module driver exercises registry retirement and revocation through real managers, the worker and SQLite, verifies unchanged rows and routing state after refusal, and verifies replacement writes and late-stop survival.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Detached Discord conversations become bound again after restart, and workspace rebinds revert despite successful command replies.
Reason: The persistence repair has clear value, but its public SDK lifetime semantics require an owner decision.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR fixes a current Discord persistence bug and has sufficient behavior proof; the public SDK behavior change still needs owner approval.

Priority: P1
Reviewed head: d1e4495644c500960a93a72baf9af6742825a025
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should runtime-bound synchronous stores refuse opens and retained-handle writes after retirement during the existing compatibility window, with Discord async mutations rejecting the same refusal?
  • Recommendation: Approve the guarded behavior: Accept retired-runtime refusal as the intended lifetime contract, including the typed error and replacement-manager behavior documented in this PR.
  • Why: This changes public behavior beyond retaining Discord's runtime, and no owner approval is recorded; the reported usage query has incomplete coverage.

Before merge

  • Await maintainer action - The SDK owner must approve the public retired-runtime refusal semantics or define the compatibility transition before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

Discord binding managers translate conversation commands and lifecycle updates into plugin-state writes; SQLite stores the records that startup restores into routing state.

flowchart LR
  A[Discord conversation command] --> B[Conversation binding service]
  B --> C[Discord binding manager]
  C --> D[Captured runtime authority]
  D --> E[Plugin state worker]
  E --> F[SQLite binding records]
  F --> G[Startup routing state]
Loading

Technical review

Best possible solution:

Keep the runtime-bound persistence repair and obtain SDK-owner acceptance of retired-runtime refusal during the synchronous compatibility window.

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

Current-main store lookup and fallback code explain the reporter's real Discord reproduction; no target code was executed during this review.

Is this the best way to solve the issue?

Retaining the creating runtime fixes the ownership error at the existing manager and store boundaries, while typed refusal preserves the distinction between lost authority and unavailable storage.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2bc19eb1e725.

Provenance checked

  • Discord worker-backed persistence and account ordering keeps the original intent (b310493: Move binding storage off the Gateway thread while retaining acknowledged writes, ordering, stored records and synchronous compatibility.)
  • Runtime-bound synchronous store authority changes intended behavior with a stated reason (6b5284f: Add worker-owned V2 state while preserving existing synchronous completion semantics.)
  • Legacy synchronous receiver keeps the original intent (a157713: Separate asynchronous receivers from deprecated native adapters without removing released callback or commit-before-return contracts.)
  • Historical singleton-shape repair keeps the original intent (ace1908: Historical source replacement across thread-registry shapes requires restart rather than speculative shape repair.)
  • Deleted-thread session cleanup keeps the original intent (13a5104: Remove deleted-thread bindings and close associated sessions through the canonical session owner.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit b310493 adds extensions/discord/src/monitor/thread-bindings.manager.ts:525 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b310493c0928; files: extensions/discord/src/monitor/thread-bindings.manager.ts)

PR surface

Source +171, Tests +1097, Docs +2. Total +1270 across 19 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 12 221 50 +171
Tests 6 1099 2 +1097
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 1322 52 +1270

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Discord detach and rebind report success while losing the requested binding state across Gateway restart.
  • merge-risk: 🚨 compatibility: Retained synchronous SDK handles gain runtime-lifetime refusal semantics before their documented compatibility window ends.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • 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-10-19T20:24:39.548Z sha de7639b :: needs real behavior proof before merge. :: [P2] Reject synchronous writes from a retired Discord runtime
  • reviewed 2026-10-29T18:47:23.418Z sha d1e4495 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-29T20:57:49.299Z sha d1e4495 :: blocked before merge. :: none

Reviewed October 29, 2026, 5:07 PM ET / 21:07 UTC (Revision 4).

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation plugin: file-transfer labels Oct 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d1980ede38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5f8321b44

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MarMarLabs

Copy link
Copy Markdown
Contributor Author

Live Discord persistence at d1e4495644c5

The observed persistence checks passed. The full runbook evidence remains inconclusive. These head-only runs cover only the first half of the review's authority-chain item, persistence through the Discord owner by an active foreign caller. They do not show retirement blocking synchronous touch, lifecycle update or unbind.

Setup and isolation

I ran a built Gateway at this head with a real Discord server and bot, the bundled /codex plugin and a real gpt-5.6-luna model through a counting relay. Each case used fresh state and a fresh guild thread. Between phases I fully stopped the Gateway and its children, verified captured groups were empty and the case listener was gone, then started a fresh process on the same state, config, native home and workspaces.

Before these paid runs, credential-free controls passed a synthetic marker read, ten protected-file read denials and three out-of-run write denials. An earlier attempt had stopped before detach because the native read-only sandbox failed under the outer profile. These runs used appServer.sandbox set to danger-full-access inside that unchanged outer sandbox. Native read-only execution and its shell network protection were absent. The outer profile still allowed network access and writes within the run.

Detach, rebind and binding queries below were ordinary Discord type-0 messages, without interaction metadata.

B1, detach

An approved initial bind committed one plugin-owned workspace A row with a verified real webhook. A genuine file read returned WORKSPACE-A-OK. I then sent /codex detach and got Detached this conversation from Codex.

Snapshot Rows
Before detach 1
After detach 0
After full stop 0
After fresh start, before traffic 0
After final query 0

/codex binding returned No Codex conversation binding is attached. before the stop and again after restart.

B2, rebind

In a fresh case an approved A bind and real file read returned WORKSPACE-A-OK. I sent /codex bind naming workspace B. No new approval prompt appeared. Exactly one row remained, with the same Discord conversation, webhook, target key and binding ID, now naming B. /codex binding named B and a real file read returned WORKSPACE-B-OK.

The retained binding record was equal before and after the full stop, and after a fresh start before traffic. The query then named B again, and a final real file read returned WORKSPACE-B-OK.

The native Thread value in the two binding queries changed across restart. The Discord conversation, binding ID and workspace persisted. I do not claim the native thread survived or infer a recovery mechanism from that changed value alone.

Requests and limits

These completed B1 and B2 runs used 2 and 6 model requests respectively, two per file read. Detach, rebind and binding queries added none. The earlier blocked attempt is separate.

  • Head only, with no real Discord base run. The failing side remains the earlier local evidence in the body.
  • Initial approval cards stayed visible after commit. Retained projections establish approved binds, not the exact initial native interaction or which approval button was clicked.
  • Callback HTTP statuses, approval click IDs, direct MESSAGE_CREATE frames and internal caller-instance traces were unavailable. Typed messages, replies and durable outcomes were measured, not the writer's internal instance identity.
  • No artifacts are attached. Screenshots remain private pending export review. This comment is text only.

Retirement coverage

Retirement and late-stop handover retain test-only evidence. I read these tests at the tested head and did not rerun them.

  • src/plugins/conversation-binding.discord.test.ts covers sync and async touch, idle timeout, max age and unbind, plus async rebind and detach. All run through a foreign caller against active, retired-before-stop and stopped owners. Non-active cases require unchanged durable rows.
  • src/plugin-state/plugin-state-store.runtime.test.ts checks all seven sync mutators after revocation, plus update and deleteIf when their own callback revokes the owner.
  • src/plugins/conversation-binding.discord-handoff.test.ts checks explicit retirement handoff and that the old manager's late stop leaves its replacement registered.

@MarMarLabs

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 29, 2026
@MarMarLabs

Copy link
Copy Markdown
Contributor Author

Retirement and replacement proof at d1e4495644c5

This is the proof the first Before merge item in the latest review asks for. After the owner retires or is revoked, synchronous touch, lifecycle update and unbind must not change durable rows, and the replacement owner's writes must then succeed. It supersedes the test-only retirement note in my earlier live Discord comment.

What ran

A scripted driver over the built production modules at d1e4495644c5. It loads the plugin registry and lifecycle, the Discord thread-binding manager, the plugin-state worker and SQLite. It is not a Gateway reload and not live Discord. There were no credentials and no network. Retirement goes through markPluginRegistryRetired, the function src/plugins/runtime.ts:143 and :200 call.

The retired state is an old Discord provider whose stop has not stopped its thread-binding manager when the registry retires, for example a stop that runs past the 5 s channel stop timeout. In an ordinary reload, by my reading of the source, the old provider reaches threadBindings.stop() first, which marks the manager stopping and unregisters it.

Results

In my head run the active bind wrote 1 row, row-set SHA-256 starting 304b6713. I waited out the 15 s touch persist interval in real time, then retired the registry. The original manager stayed registered and not stopping. Ten calls then ran inside the replacement instance, through the retired owner's retained manager, its retained store handles or the session-wide helpers.

Call after retirement Result
sync touch null
sync idle timeout, max age, unbind [] each
async touch null
async idle timeout, max age, unbind PLUGIN_STATE_RUNTIME_INACTIVE each
retained sync store update, V2 store register PLUGIN_STATE_RUNTIME_INACTIVE each

After every call the whole plugin_state_entries table had the same SHA-256 as before retirement, and the in-memory routing projection was unchanged.

The replacement then acquired a distinct manager. A separate read-only SQLite connection read back each write. Bind set proofPhase to replacement, idle timeout became 90000 ms and max age 180000 ms. Awaiting the old manager's stop at that point left the replacement registered. After another real 15 s wait, touch set lastActivityAt to the requested value. Unbind left 0 rows.

Wrong-version control

The wrong version points one built Discord file at a copy where the two store-open helpers call getDiscordRuntime() instead of (runtime ?? getDiscordRuntime()). That is main's lookup. It borrows the calling instance's runtime, and no other module changes.

  • My control covers the four synchronous operations. After retirement each changed the rows. Touch advanced lastActivityAt, idle timeout became 60000, max age 120000 and unbind deleted the row. Later operations in that run found no row and prove nothing more. Acquisition then reused the retired manager, which fails the driver's own distinct-manager check.
  • An independent checker reran the control with the four asynchronous operations first, which covers them as separate evidence. Touch advanced lastActivityAt, idle timeout became 65000, max age 130000 and unbind deleted the row. The paired head run in that order passed.
  • The checker's revoke run used revokePluginRecord at head. The ten refusals, unchanged rows and replacement writes were the same, with the registry not retired and the old instance still accepting calls. That mode has no wrong-version run.
  • The two store-handle refusals have no wrong-version control.

The checker also reran the head and the control in fresh roots. With timestamps set aside, all 22 head snapshots and 16 operation results matched my run, and all 16 control snapshots and 11 operation results matched.

Terminal output

Selected driver stdout lines from my head run.

{"utc":"2026-10-29T19:16:40.381Z","attempt":"attempt5","event":"owner_deactivated","method":"markPluginRegistryRetired","ownerActive":false,"registryRetired":true,"ownerAcceptingCalls":false,"managerStillRegistered":true,"managerStopping":false,"candidateActive":true}
{"utc":"2026-10-29T19:16:40.383Z","attempt":"attempt5","event":"operation","label":"retained.sync_touch","returned":null}
{"utc":"2026-10-29T19:16:40.386Z","attempt":"attempt5","event":"refusal_check","label":"retained.sync_touch","byteIdenticalRows":true,"unchangedRoutingProjection":true,"isRefusal":true}
{"utc":"2026-10-29T19:16:40.396Z","attempt":"attempt5","event":"operation","label":"retained.async_unbind","error":{"name":"PluginStateRuntimeInactiveError","code":"PLUGIN_STATE_RUNTIME_INACTIVE","message":"Plugin \"discord\" runtime is no longer active."}}
{"utc":"2026-10-29T19:16:40.397Z","attempt":"attempt5","event":"refusal_check","label":"retained.async_unbind","byteIdenticalRows":true,"unchangedRoutingProjection":true,"isRefusal":true}

Limits

  • All ten refusals came within about 20 ms of retirement, in one process.
  • I set up the retired state directly and did not reach it through a real reload. The plugin record is synthetic and the driver activates each registry itself.
  • The driver activates the replacement registry while the original is still live and no old-provider stop has started. A reload stops the old provider, or times out on it, and disposes its instances before loading the replacement. Both then mark the new registry active before retiring the old one.
  • No sweeper, webhook, REST, farewell, plugin loader or command handler path ran. The conversation is a direct user: one and only plugin_state_entries was snapshotted.
  • The old manager was not stopping during the refusals, so a stop held part-way is not modeled. Only the calls listed above ran, not every synchronous mutator.

No artifacts are attached. This comment is text only.

@MarMarLabs

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 29, 2026
@MarMarLabs

Copy link
Copy Markdown
Contributor Author

Closing this to keep my open queue small. Happy to reopen or redo it if it's still useful.

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

Labels

channel: discord Channel integration: discord docs Improvements or additions to documentation extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. plugin: file-transfer proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Discord: /codex detach and rebind are not saved, so the binding returns after a Gateway restart

2 participants