Skip to content

fix(twitch): prevent stopped accounts from reconnecting after delayed startup - #128909

Merged
steipete merged 1 commit into
mainfrom
codex/qa-twitch-startup-shutdown-fence
Aug 25, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-twitch-startup-shutdown-fence

Conversation

@steipete

@steipete steipete commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where operators stopping or restarting a Twitch account could leave an unregistered chat connection running after shutdown when the provider's initial account lookup was still in flight. A stopped account could reconnect after its manager had been removed, and an account restart could remain attached to the stale startup attempt.

Why This Change Was Made

The Twitch client manager previously awaited provider initialization before creating and registering its pending chat client, so account shutdown had no client to cancel during that window. Reuse the existing per-account connection promise as the exact startup ownership record, validate that identity before constructing a chat client, and retire pending account work and message handlers together during disconnect. This remains entirely within the private Twitch lifecycle owner and does not change provider credentials, authentication policy, configuration, or public plugin contracts.

User Impact

Stopping a Twitch account reliably prevents delayed connection startup and clears its pending message handler. Restarting the same account creates exactly one fresh connection, while other active Twitch accounts continue unaffected.

Evidence

  • Four new owner-level tests fail on current main and pass with the fix: account shutdown during deferred provider initialization, global shutdown during deferred initialization, same-account restart while an older initialization resolves, and cancellation without disturbing another account.
  • Independent review identified an additional pending-handler cleanup gap; the account-shutdown regression was extended, reproduced the failure, and now passes.
  • The actual production client manager and registry were exercised through account removal and replacement: the retired manager creates zero connections, the replacement creates exactly one, and no stopped-account handlers remain.
  • Full focused owner and sibling proof passed independently twice: node scripts/run-vitest.mjs extensions/twitch/src/twitch-client.test.ts extensions/twitch/src/client-manager-registry.test.ts extensions/twitch/src/monitor.test.ts extensions/twitch/src/plugin.lifecycle.test.ts extensions/twitch/src/twitch-ingress.test.ts extensions/twitch/src/outbound.test.ts — six suites, 90 tests passed per run.
  • Scoped formatting and lint passed; authenticated full committed-branch review reported no actionable findings.
  • Production delta: +12 lines, required for exact startup-attempt ownership and unified account-lifecycle cleanup.
  • Live Twitch account stop/restart is concretely infeasible for this change because no isolated, authenticated disposable Twitch account is available, and manipulating the operator's live channel or production credentials is not authorized. Instead, the actual production client manager, actual registry removal/replacement flow, and real Twurple chat-client construction were exercised with a controlled asynchronous provider boundary; the six owner/sibling suites also passed 90 tests independently twice.
  • Exact reviewed-head hosted CI run 32791495885 completed successfully, including the required openclaw/ci-gate. The repository-native landing workflow validates the exact current-main merge boundary and post-merge ancestry; an age-only rebase is unnecessary for this conflict-free change.
  • ClawSweeper's owner-test output separately shows all 47 Twitch client-manager tests passing twice. Its reported live-verification failure is an output-matching harness mismatch: it searched for a suite-title string that the successful Vitest reporter does not print.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: twitch Channel integration: twitch size: S maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 23:55
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 8:01 PM ET / August 25, 2026, 00:01 UTC.

ClawSweeper review

What this changes

The PR prevents a stopped or replaced Twitch account from completing delayed authentication and creating a stale chat client or retaining its message handler.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. Current main still constructs a Twitch chat client immediately after deferred authentication, while this PR adds an exact startup-ownership fence before construction; the repair is in the lifecycle owner and has focused regression coverage. A redacted live cancellation/restart trace or stated infeasibility remains desirable before landing.

Priority: P1
Reviewed head: 5a3ccd656a644928b44cdb776fa286a23c79d3b8

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The code and focused regression design are strong, but live provider-side cancellation evidence is not attached.
Proof confidence 🌊 off-meta tidepool Not applicable: Maintainer-authored PRs are exempt from the external-contributor proof gate; the body reports focused mocked owner tests but attaches no real Twitch trace.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Maintainer-authored PRs are exempt from the external-contributor proof gate; the body reports focused mocked owner tests but attaches no real Twitch trace.
Evidence reviewed 7 items Current-main failure boundary: Current main awaits authentication and then constructs ChatClient without confirming that the pending startup still belongs to the manager, so removal during that await cannot prevent later construction.
Owner-boundary repair: The branch records the exact connection promise, validates ownership after authentication, and deletes that record during disconnect, preserving a replacement startup's record.
Lifecycle caller and cleanup owner: The gateway stop path removes the registry entry, and the registry synchronously asks its manager to disconnect all pending work; this is the producer boundary the fix protects.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/twitch/src/twitch-client.test.ts

Result: FAIL (partial) — step 2 expect_output TwitchClientManager: expected terminal output was not visible within 30 seconds: "TwitchClientManager"

node scripts/run-vitest.mjs extensions/twitch/src/twitch-client.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128909-kvLzfc/target$ node scripts/run-vitest.mjs extensions/twitch/src/twitch-client.test.ts
node scripts/run-vitest.mjs extensions/twitch/src/twitch-client.test.ts
[test] starting test/vitest/vitest.extension-messaging.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128909-kvLzfc/target

 ✓  extension-messaging  extensions/twitch/src/twitch-client.test.ts (47 tests) 86ms

 Test Files  1 passed (1)
      Tests  47 passed (47)
   Start at  00:02:45
   Duration  8.98s (transform 6.88s, setup 969ms, import 7.55s, tests 86ms, environment 0ms)

[test] passed 1 Vitest shard in 15.08s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128909-kvLzfc/target$ node scripts/run-vitest.mjs extensions/twitch/src/twitch-client.test.ts
[test] starting test/vitest/vitest.extension-messaging.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128909-kvLzfc/target

 ✓  extension-messaging  extensions/twitch/src/twitch-client.test.ts (47 tests) 76ms

 Test Files  1 passed (1)
      Tests  47 passed (47)
   Start at  00:03:00
   Duration  4.24s (transform 2.23s, setup 434ms, import 3.49s, tests 76ms, environment 0ms)

[test] passed 1 Vitest shard in 10.21s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128909-kvLzfc/target$






















Assertions:

  • FAIL expect_output: TwitchClientManager

How this fits together

The Twitch plugin starts one chat client per configured account after resolving provider authentication. Its registry removes that manager during account shutdown, affecting incoming chat handlers and outbound replies.

flowchart LR
A[Gateway starts or stops account] --> B[Twitch manager registry]
B --> C[Twitch client manager]
C --> D[Provider authentication]
D --> E{Startup still owned?}
E -->|yes| F[Create chat client and handlers]
E -->|no| G[Cancel stale startup]
F --> H[Incoming and outgoing Twitch chat]
Loading

Before merge

  • Resolve merge risk (P1) - The PR changes the owner of an asynchronous chat connection; its focused tests mock Twurple and no redacted live Twitch stop/restart trace or concrete infeasibility is attached, so real provider-side cancellation remains unobserved before merge.
  • Resolve merge risk (P1) - The branch is behind current main; validate the actual merge result and rerun the focused lifecycle suites on the exact head before landing.
  • Complete next step (P2) - This maintainer-labeled PR has a coherent owner-boundary fix; it needs ordinary exact-head validation rather than an automated repair job.
Agent review details

Security

None.

PR surface

Source +12, Tests +89. Total +101 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 4 +12
Tests 1 89 0 +89
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 105 4 +101

Review metrics

Metric Value Why it matters
Production versus regression coverage production +12 net, tests +89 The production growth carries one startup-ownership invariant; the added tests cover cancellation, replacement, and account isolation.

Merge-risk options

Maintainer options:

  1. Prove cancellation on a real Twitch account (recommended)
    Before merge, add a redacted trace showing stop or replacement during delayed authentication leaves no stale connection or handler, then recheck the rebased exact head.
  2. Accept focused-owner-test evidence
    A maintainer may accept the focused mocked lifecycle coverage if real Twitch proof is concretely infeasible and that limitation is recorded in the PR.

Technical review

Best possible solution:

Keep the promise-identity fence in the Twitch client manager, then demonstrate that stopping a real account during authentication leaves no client or handler while a replacement account connects once.

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

Yes, from source: defer RefreshingAuthProvider authentication, remove the manager while it is pending, then resolve it; current main proceeds to ChatClient construction because no ownership check exists after the await.

Is this the best way to solve the issue?

Yes. The promise-identity check repairs the lifecycle owner before client construction; downstream cleanup cannot cancel work while no client exists yet.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4c8c22867ebb.

Labels

Label changes:

  • add P1: A stopped Twitch account can reconnect and resume an active channel workflow unexpectedly.
  • add merge-risk: 🚨 message-delivery: The same lifecycle owner registers clients and clears incoming-message handlers.
  • add merge-risk: 🚨 availability: The patch changes asynchronous account startup and shutdown behavior for the Twitch chat client.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Maintainer-authored PRs are exempt from the external-contributor proof gate; the body reports focused mocked owner tests but attaches no real Twitch trace.

Label justifications:

  • P1: A stopped Twitch account can reconnect and resume an active channel workflow unexpectedly.
  • merge-risk: 🚨 availability: The patch changes asynchronous account startup and shutdown behavior for the Twitch chat client.
  • merge-risk: 🚨 message-delivery: The same lifecycle owner registers clients and clears incoming-message handlers.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Maintainer-authored PRs are exempt from the external-contributor proof gate; the body reports focused mocked owner tests but attaches no real Twitch trace.

Evidence

What I checked:

Likely related people:

  • steipete: Auth-retry, lifecycle-status, durable-ingress, and this startup-fencing work all appear in the history of the affected manager and plugin entry point. (role: recent lifecycle and Twitch feature owner; confidence: high; commits: 5a3ccd656a64, 841cb121fb70, e04ea7916c5b; files: extensions/twitch/src/twitch-client.ts, extensions/twitch/src/plugin.ts)
  • alkor2000: Previously repaired preservation of a newer Twitch message handler during cleanup, directly adjacent to this PR's handler-retirement path. (role: adjacent lifecycle contributor; confidence: medium; commits: 71ddc016a804; files: extensions/twitch/src/twitch-client.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted real Twitch stop/restart trace, or record the concrete reason that live proof is infeasible.
  • Rebase or verify the merge result and rerun focused lifecycle tests on the exact head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 05a2a59 into main Aug 25, 2026
189 checks passed
@steipete
steipete deleted the codex/qa-twitch-startup-shutdown-fence branch August 25, 2026 00:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 25, 2026
steipete added a commit that referenced this pull request Oct 15, 2026
Use the existing account registry as Twitch's only account owner, fold the
private Teams store selector into its only caller, share QA message sending,
and remove redundant Feishu table/cache and mobile expiry work. Convert
replacement table-cell Markdown before deleting its existing content.

Best-effort tradeoffs accepted:
- Feishu optional bot-name failures use one 60-second account cooldown, not
  ten failures plus an hour-long circuit. #89783 documents feature proof,
  not a human incident needing that circuit. Names recover next minute.
- Unsupported runtimes without Intl.Segmenter now fail clearly; supported
  Node/current Bun preserve #96587's real grapheme/emoji repair.
- Malformed duplicate Feishu block IDs retain source/current-table order,
  not redundant map/sort or first-match order. Valid provider trees retain
  the tree reconstruction and table-width behavior from #40524.
- LINE cache eviction assumes ordinary wall-clock order. #132108's real
  account identity fix remains; backward clock jumps may evict another
  display-name entry, which is refetched normally.
- iMessage/Zalouser internal expiries trust Date.now plus constant TTLs.
  Direct commits 5269924/becd45325bc and 743d537 only test NaN,
  Infinity or year-275760 clocks, not human reports. Monkeypatched invalid
  clocks may keep cached verdicts/metadata until restart.
- Zalo's duplicate expiry preflight is gone; the shared hosted-media owner
  still rejects before download. f91ddef added only synthetic clock
  handling; an invalid clock now receives that owner's generic error.
- FaceTime cancels synchronous drain timers rather than fencing them with
  generations. #119291 cites no stale-timer incident; barge-in, carrier
  authority, playback timing and shutdown settlement remain.
- Private Twitch managers serve one registered account, not arbitrary
  additional username/channel pairs. #1612 introduced unused inner maps;
  production managers already belong to one account. Real startup
  cancellation and connection sharing from #128909 remain.

No config, protocol, dependency, schema, retention, permission or public SDK
changes. Phase E memory is untouched. The attempted vendor-type consolidation
was fully dropped because the pinned ZCA package cannot expose its public
types under NodeNext without an approval-gated dependency/configuration fix.

Reopened pass: 183 additional net production lines removed; branch total429
(176 added/605 deleted), excluding tests/support/generated/declarations.
Production/test extension types, runtime/Madge zero-cycle checks, formatting
and actual Tlon/long-sleep owner probes pass. Fresh P2 review has three
source-disproved findings and no accepted/actionable finding. Two mocked
constructor lint errors were mechanically fixed and their narrow guard passes.
Owner suites remained startup-bound and were stopped before assertions;
the docx regression/control remains unproved. Suppression suite retains only
the known base UI allowlist drift. Full package-aware lint/check-changed and
exact bundle-head CI remain for coordinator bundling. No structural PR.
steipete added a commit that referenced this pull request Oct 15, 2026
…173047)

* refactor(auto-reply): consolidate delivery preparation

Share aggregate collect/overflow adoption, transcript settlement and reply
sanitization. Reuse ACP account preparation, keep fixed export colors with
their CSS owner, and remove redundant runtime/cache checks. Preserve live
authorization, FIFO, consume-before-ack and ordinary write settlement.

Production: +307/-446, net 139 lines removed. Tests: +37/-83, net 46 removed.
The optional session rollover and session-event assertion cleanups were dropped
after unresolved memory-hook/background-permission proof. Their owners and the
standalone session-memory backend/tests are unchanged.

Best-effort tradeoffs accepted

- Intl constructor hot replacement after cache fill: #148648 added synthetic replacement/recovery coverage, not an incident fix; normal processes keep Intl stable. The measured formatter cache and native fallback stay; replacement takes effect after restart.
- Media application failure clearing a successful import: #154864 extracted this path, without a module-reload incident. ESM code is process-stable and the lazy loader already evicts rejected loads; raw-content fallback remains and successful imports are reused.
- Link application failure clearing a successful import: same #154864 provenance and canonical eviction owner. A successful ESM module is reused; raw-content fallback and AbortError propagation remain.
- Collect-source reinsertion after a preparation failure: #103695 predates #172080's consume-before-ack cutover. Unaccepted inputs remain queued and accepted inputs must not replay; unexplained internal queue mutation is no longer repaired here, while durable ingress retains pre-acceptance retry.
- A source abort between consecutive synchronous prepared checks: the earlier #100123 TUI fixes remain, including their real #89059/#90012 behavior. The canonical prepared assertion checks every source; Stop membership filtering and aggregate cancellation still protect actual awaits.
- Duplicate ACP post-resolution assertion: #159084 introduced async metadata ownership. Resolution still receives its owner assertion and the caller keeps the final post-await check; the private wrapper and its earlier duplicate check are gone.
- Mutation of constructor metadata bags: #121995 retained forwarding getters, but the sole production constructor call at reply-turn-admission.ts:524 supplies a fresh value literal. Those values are captured once; live session/agent/result accessors remain. The review's hypothetical retained/getter-valued constructor caller does not exist and is not a shipped SDK contract.

Evidence

Final format, changed lint, core production types, messaging test types,
line-cap and runtime cycles pass. Madge reports zero cycles; all follow-up
import specifiers are unchanged. All non-whitespace export CSS and all 40 fixed
declarations match the pinned generated stylesheet. Independent full-candidate
review completed with one source-disproved speculative P2; no accepted finding.
Completed focused selections: initial unit-fast 4 files/40 tests, HTML 3 files/29
tests, and final lint-suppressions 1 file/3 tests. ACP default-account and delivery
assertions, plus capture/hook/callback-settlement assertions, passed individually;
interrupted infra selections and remaining owner suites are incomplete.

Unresolved local failures: the retiring memory-window case timed out at 125461ms,
and the allowed background-permission completion case at 120332ms (both existing
120000ms limits). Related optional owner hunks were dropped, not claimed fixed.
An unchanged-session-owner replay was inconclusive; no main/load attribution.
No tests, timeouts, retries or skips were weakened.

Broad check-changed is incomplete. Its env inventory reported 455 against 454;
the same count was reproduced from original base 9e3e16c and recorded main
a065e6a, without patch-added env names or a budget edit. No hosted PR CI is
claimed: below-500 branch-only handoff for coordinator bundling.

* refactor(auto-reply): remove test-only runtime plumbing

Continue the same lane with direct owner resets instead of test-global
publications, inline the sole queue-wait scaffold, remove test-only delivery
getters, and share the immutable HTML tree and text extraction. Keep actual
login consent, interrupt authority, busy rechecks, dedupe, delivery recovery,
FIFO, transcript writes and ordinary shutdown settlement unchanged.

This follow-up removes 118 net production lines. Full branch: +341/-598,
257 net production lines removed; tests/support +84/-230, 146 net removed.
Largest-file, sole-caller, dead-export, option and compatibility sweeps found
no further sound cut without removing retained behavior or moving code.
Phase E session memory and its tests are untouched. No config, schema,
durability, retention, permission, protocol or dependency changes.

Best-effort tradeoffs accepted

- Command descriptors no longer manufacture absent optional own-undefined
  properties. The private typed builder dates to #117143, with later work
  in #163997; no production enumeration consumer exists. Property reads,
  supplied fields, defaults and JSON behavior remain unchanged.
- HTML entries are immutable for the lifetime of an export viewer. Build
  its tree/index once; external mutation of this private snapshot is not
  supported. Keep the iterative long-session fix from #151029.

Evidence

Fresh isolated full-branch review is scoped-clean through P2. Changed lint,
format, core types, messaging/root-tooling test types, line cap and runtime
cycles pass (0 runtime value cycles). The initial test-type invocation used
an invalid canonical graph selector; the corrected supported commands pass.
No new production runtime import edges; prior zero-cycle Madge proof applies.

Focused proof passes: 15 files/318 tests across four shards, 1629.71s total
including 382.56s worker preparation. Final-outcome/HTML: 4 files/45 tests;
ingress retry: 1 file/6 tests; required lint-suppressions: 1 file/3 tests;
auto-reply owners: 9 files/264 tests. Consent fixtures emitted host-broker
metadata-write warnings; all assertions passed. All proof used isolated
HOME/OpenClaw/XDG state, never real user state.

Earlier memory-window and background-permission timeouts remain unresolved;
their optional owner hunks were dropped, not claimed fixed. Broad changed
check remains incomplete, including the baseline-reproduced env inventory
455/454 finding. No tests, timeouts, retries, skips or budgets were weakened.
Below-500 branch-only handoff; no PR or hosted CI is claimed.

* refactor(channels): consolidate secondary transport plumbing

Use existing SDK setup and sleep owners, reuse parsed Tlon list items,
consolidate LINE callback validation and Teams sender selection, replace
iMessage's parallel cache indices, and remove redundant QA snapshots.
Preserve account, security, conversation, transport and settlement contracts.

Best-effort tradeoffs accepted:
- Feishu identity published before successor route registration during an old
  webhook drain may be cleared until refresh/restart. Available #48588 evidence
  only forces that identity interleaving in a test, with no cited human report;
  registered successors, signed ingress and response settlement remain protected.
- QA senders that mutate already-sanitized internal tool records no longer
  receive independent deep-snapshot comparison. Native records only append;
  the mutation tests from #114910 monkeypatch a sender. Duplicate final
  suppression and pre-await tool-array capture remain.
- Retired Bot Framework revoked proxies no longer trigger proactive resend.
  The historical #27189 defect belonged to the SDK replaced in #51808;
  current Teams ActivityContext is not a revocable proxy. Unexpected errors
  now follow the ordinary delivery-error path, without duplicate fallback.
- The bounded self-chat cache uses linear lookup instead of synchronized
  indices. #161967 establishes no measured lookup-performance requirement;
  existing TTL, cap, timestamp, scope and hash matching remain unchanged.

No config, protocol, dependency, schema, durability, retention, permission or
public SDK contract changes. Phase E memory backend is untouched.

Net production: 246 lines removed (83 added, 329 deleted), excluding tests,
support and inventories. Fresh review through P2 is clean; production/test
extension types and both cycle checks pass (zero cycles). X focused suites
pass 31 tests; native Buzz baseline/current protocol probes preserve signed
discovery, cancellation and notification-driven retry. Other direct owner
probes cover Tlon, self-chat caching, LINE limits and Mattermost setup.

Local proof gaps: SDK declaration preparation timed out before lint; the
remaining owner suites produced no assertions during loaded-host startup;
full check-changed was classified but not run. The suppression test has
unrelated UI-only allowlist drift inherited from the base. No new suppression,
timeout increase, retry, skip or baseline expansion.

* refactor(channels): simplify account-scoped transport owners

Use the existing account registry as Twitch's only account owner, fold the
private Teams store selector into its only caller, share QA message sending,
and remove redundant Feishu table/cache and mobile expiry work. Convert
replacement table-cell Markdown before deleting its existing content.

Best-effort tradeoffs accepted:
- Feishu optional bot-name failures use one 60-second account cooldown, not
  ten failures plus an hour-long circuit. #89783 documents feature proof,
  not a human incident needing that circuit. Names recover next minute.
- Unsupported runtimes without Intl.Segmenter now fail clearly; supported
  Node/current Bun preserve #96587's real grapheme/emoji repair.
- Malformed duplicate Feishu block IDs retain source/current-table order,
  not redundant map/sort or first-match order. Valid provider trees retain
  the tree reconstruction and table-width behavior from #40524.
- LINE cache eviction assumes ordinary wall-clock order. #132108's real
  account identity fix remains; backward clock jumps may evict another
  display-name entry, which is refetched normally.
- iMessage/Zalouser internal expiries trust Date.now plus constant TTLs.
  Direct commits 5269924/becd45325bc and 743d537 only test NaN,
  Infinity or year-275760 clocks, not human reports. Monkeypatched invalid
  clocks may keep cached verdicts/metadata until restart.
- Zalo's duplicate expiry preflight is gone; the shared hosted-media owner
  still rejects before download. f91ddef added only synthetic clock
  handling; an invalid clock now receives that owner's generic error.
- FaceTime cancels synchronous drain timers rather than fencing them with
  generations. #119291 cites no stale-timer incident; barge-in, carrier
  authority, playback timing and shutdown settlement remain.
- Private Twitch managers serve one registered account, not arbitrary
  additional username/channel pairs. #1612 introduced unused inner maps;
  production managers already belong to one account. Real startup
  cancellation and connection sharing from #128909 remain.

No config, protocol, dependency, schema, retention, permission or public SDK
changes. Phase E memory is untouched. The attempted vendor-type consolidation
was fully dropped because the pinned ZCA package cannot expose its public
types under NodeNext without an approval-gated dependency/configuration fix.

Reopened pass: 183 additional net production lines removed; branch total429
(176 added/605 deleted), excluding tests/support/generated/declarations.
Production/test extension types, runtime/Madge zero-cycle checks, formatting
and actual Tlon/long-sleep owner probes pass. Fresh P2 review has three
source-disproved findings and no accepted/actionable finding. Two mocked
constructor lint errors were mechanically fixed and their narrow guard passes.
Owner suites remained startup-bound and were stopped before assertions;
the docx regression/control remains unproved. Suppression suite retains only
the known base UI allowlist drift. Full package-aware lint/check-changed and
exact bundle-head CI remain for coordinator bundling. No structural PR.

* test: repair wave-5 bundle integration checks
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…penclaw#173047)

* refactor(auto-reply): consolidate delivery preparation

Share aggregate collect/overflow adoption, transcript settlement and reply
sanitization. Reuse ACP account preparation, keep fixed export colors with
their CSS owner, and remove redundant runtime/cache checks. Preserve live
authorization, FIFO, consume-before-ack and ordinary write settlement.

Production: +307/-446, net 139 lines removed. Tests: +37/-83, net 46 removed.
The optional session rollover and session-event assertion cleanups were dropped
after unresolved memory-hook/background-permission proof. Their owners and the
standalone session-memory backend/tests are unchanged.

Best-effort tradeoffs accepted

- Intl constructor hot replacement after cache fill: openclaw#148648 added synthetic replacement/recovery coverage, not an incident fix; normal processes keep Intl stable. The measured formatter cache and native fallback stay; replacement takes effect after restart.
- Media application failure clearing a successful import: openclaw#154864 extracted this path, without a module-reload incident. ESM code is process-stable and the lazy loader already evicts rejected loads; raw-content fallback remains and successful imports are reused.
- Link application failure clearing a successful import: same openclaw#154864 provenance and canonical eviction owner. A successful ESM module is reused; raw-content fallback and AbortError propagation remain.
- Collect-source reinsertion after a preparation failure: openclaw#103695 predates openclaw#172080's consume-before-ack cutover. Unaccepted inputs remain queued and accepted inputs must not replay; unexplained internal queue mutation is no longer repaired here, while durable ingress retains pre-acceptance retry.
- A source abort between consecutive synchronous prepared checks: the earlier openclaw#100123 TUI fixes remain, including their real openclaw#89059/openclaw#90012 behavior. The canonical prepared assertion checks every source; Stop membership filtering and aggregate cancellation still protect actual awaits.
- Duplicate ACP post-resolution assertion: openclaw#159084 introduced async metadata ownership. Resolution still receives its owner assertion and the caller keeps the final post-await check; the private wrapper and its earlier duplicate check are gone.
- Mutation of constructor metadata bags: openclaw#121995 retained forwarding getters, but the sole production constructor call at reply-turn-admission.ts:524 supplies a fresh value literal. Those values are captured once; live session/agent/result accessors remain. The review's hypothetical retained/getter-valued constructor caller does not exist and is not a shipped SDK contract.

Evidence

Final format, changed lint, core production types, messaging test types,
line-cap and runtime cycles pass. Madge reports zero cycles; all follow-up
import specifiers are unchanged. All non-whitespace export CSS and all 40 fixed
declarations match the pinned generated stylesheet. Independent full-candidate
review completed with one source-disproved speculative P2; no accepted finding.
Completed focused selections: initial unit-fast 4 files/40 tests, HTML 3 files/29
tests, and final lint-suppressions 1 file/3 tests. ACP default-account and delivery
assertions, plus capture/hook/callback-settlement assertions, passed individually;
interrupted infra selections and remaining owner suites are incomplete.

Unresolved local failures: the retiring memory-window case timed out at 125461ms,
and the allowed background-permission completion case at 120332ms (both existing
120000ms limits). Related optional owner hunks were dropped, not claimed fixed.
An unchanged-session-owner replay was inconclusive; no main/load attribution.
No tests, timeouts, retries or skips were weakened.

Broad check-changed is incomplete. Its env inventory reported 455 against 454;
the same count was reproduced from original base d6898f3 and recorded main
51164a1, without patch-added env names or a budget edit. No hosted PR CI is
claimed: below-500 branch-only handoff for coordinator bundling.

* refactor(auto-reply): remove test-only runtime plumbing

Continue the same lane with direct owner resets instead of test-global
publications, inline the sole queue-wait scaffold, remove test-only delivery
getters, and share the immutable HTML tree and text extraction. Keep actual
login consent, interrupt authority, busy rechecks, dedupe, delivery recovery,
FIFO, transcript writes and ordinary shutdown settlement unchanged.

This follow-up removes 118 net production lines. Full branch: +341/-598,
257 net production lines removed; tests/support +84/-230, 146 net removed.
Largest-file, sole-caller, dead-export, option and compatibility sweeps found
no further sound cut without removing retained behavior or moving code.
Phase E session memory and its tests are untouched. No config, schema,
durability, retention, permission, protocol or dependency changes.

Best-effort tradeoffs accepted

- Command descriptors no longer manufacture absent optional own-undefined
  properties. The private typed builder dates to openclaw#117143, with later work
  in openclaw#163997; no production enumeration consumer exists. Property reads,
  supplied fields, defaults and JSON behavior remain unchanged.
- HTML entries are immutable for the lifetime of an export viewer. Build
  its tree/index once; external mutation of this private snapshot is not
  supported. Keep the iterative long-session fix from openclaw#151029.

Evidence

Fresh isolated full-branch review is scoped-clean through P2. Changed lint,
format, core types, messaging/root-tooling test types, line cap and runtime
cycles pass (0 runtime value cycles). The initial test-type invocation used
an invalid canonical graph selector; the corrected supported commands pass.
No new production runtime import edges; prior zero-cycle Madge proof applies.

Focused proof passes: 15 files/318 tests across four shards, 1629.71s total
including 382.56s worker preparation. Final-outcome/HTML: 4 files/45 tests;
ingress retry: 1 file/6 tests; required lint-suppressions: 1 file/3 tests;
auto-reply owners: 9 files/264 tests. Consent fixtures emitted host-broker
metadata-write warnings; all assertions passed. All proof used isolated
HOME/OpenClaw/XDG state, never real user state.

Earlier memory-window and background-permission timeouts remain unresolved;
their optional owner hunks were dropped, not claimed fixed. Broad changed
check remains incomplete, including the baseline-reproduced env inventory
455/454 finding. No tests, timeouts, retries, skips or budgets were weakened.
Below-500 branch-only handoff; no PR or hosted CI is claimed.

* refactor(channels): consolidate secondary transport plumbing

Use existing SDK setup and sleep owners, reuse parsed Tlon list items,
consolidate LINE callback validation and Teams sender selection, replace
iMessage's parallel cache indices, and remove redundant QA snapshots.
Preserve account, security, conversation, transport and settlement contracts.

Best-effort tradeoffs accepted:
- Feishu identity published before successor route registration during an old
  webhook drain may be cleared until refresh/restart. Available openclaw#48588 evidence
  only forces that identity interleaving in a test, with no cited human report;
  registered successors, signed ingress and response settlement remain protected.
- QA senders that mutate already-sanitized internal tool records no longer
  receive independent deep-snapshot comparison. Native records only append;
  the mutation tests from openclaw#114910 monkeypatch a sender. Duplicate final
  suppression and pre-await tool-array capture remain.
- Retired Bot Framework revoked proxies no longer trigger proactive resend.
  The historical openclaw#27189 defect belonged to the SDK replaced in openclaw#51808;
  current Teams ActivityContext is not a revocable proxy. Unexpected errors
  now follow the ordinary delivery-error path, without duplicate fallback.
- The bounded self-chat cache uses linear lookup instead of synchronized
  indices. openclaw#161967 establishes no measured lookup-performance requirement;
  existing TTL, cap, timestamp, scope and hash matching remain unchanged.

No config, protocol, dependency, schema, durability, retention, permission or
public SDK contract changes. Phase E memory backend is untouched.

Net production: 246 lines removed (83 added, 329 deleted), excluding tests,
support and inventories. Fresh review through P2 is clean; production/test
extension types and both cycle checks pass (zero cycles). X focused suites
pass 31 tests; native Buzz baseline/current protocol probes preserve signed
discovery, cancellation and notification-driven retry. Other direct owner
probes cover Tlon, self-chat caching, LINE limits and Mattermost setup.

Local proof gaps: SDK declaration preparation timed out before lint; the
remaining owner suites produced no assertions during loaded-host startup;
full check-changed was classified but not run. The suppression test has
unrelated UI-only allowlist drift inherited from the base. No new suppression,
timeout increase, retry, skip or baseline expansion.

* refactor(channels): simplify account-scoped transport owners

Use the existing account registry as Twitch's only account owner, fold the
private Teams store selector into its only caller, share QA message sending,
and remove redundant Feishu table/cache and mobile expiry work. Convert
replacement table-cell Markdown before deleting its existing content.

Best-effort tradeoffs accepted:
- Feishu optional bot-name failures use one 60-second account cooldown, not
  ten failures plus an hour-long circuit. openclaw#89783 documents feature proof,
  not a human incident needing that circuit. Names recover next minute.
- Unsupported runtimes without Intl.Segmenter now fail clearly; supported
  Node/current Bun preserve openclaw#96587's real grapheme/emoji repair.
- Malformed duplicate Feishu block IDs retain source/current-table order,
  not redundant map/sort or first-match order. Valid provider trees retain
  the tree reconstruction and table-width behavior from openclaw#40524.
- LINE cache eviction assumes ordinary wall-clock order. openclaw#132108's real
  account identity fix remains; backward clock jumps may evict another
  display-name entry, which is refetched normally.
- iMessage/Zalouser internal expiries trust Date.now plus constant TTLs.
  Direct commits 3bcf53d/233d19aff94 and 2bf2afc only test NaN,
  Infinity or year-275760 clocks, not human reports. Monkeypatched invalid
  clocks may keep cached verdicts/metadata until restart.
- Zalo's duplicate expiry preflight is gone; the shared hosted-media owner
  still rejects before download. 2512ef2 added only synthetic clock
  handling; an invalid clock now receives that owner's generic error.
- FaceTime cancels synchronous drain timers rather than fencing them with
  generations. openclaw#119291 cites no stale-timer incident; barge-in, carrier
  authority, playback timing and shutdown settlement remain.
- Private Twitch managers serve one registered account, not arbitrary
  additional username/channel pairs. openclaw#1612 introduced unused inner maps;
  production managers already belong to one account. Real startup
  cancellation and connection sharing from openclaw#128909 remain.

No config, protocol, dependency, schema, retention, permission or public SDK
changes. Phase E memory is untouched. The attempted vendor-type consolidation
was fully dropped because the pinned ZCA package cannot expose its public
types under NodeNext without an approval-gated dependency/configuration fix.

Reopened pass: 183 additional net production lines removed; branch total429
(176 added/605 deleted), excluding tests/support/generated/declarations.
Production/test extension types, runtime/Madge zero-cycle checks, formatting
and actual Tlon/long-sleep owner probes pass. Fresh P2 review has three
source-disproved findings and no accepted/actionable finding. Two mocked
constructor lint errors were mechanically fixed and their narrow guard passes.
Owner suites remained startup-bound and were stopped before assertions;
the docx regression/control remains unproved. Suppression suite retains only
the known base UI allowlist drift. Full package-aware lint/check-changed and
exact bundle-head CI remain for coordinator bundling. No structural PR.

* test: repair wave-5 bundle integration checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: twitch Channel integration: twitch maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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.

1 participant