Skip to content

refactor(qqbot): adopt core typing keepalive loop with budget accounting intact - #104438

Merged
steipete merged 2 commits into
mainfrom
claude/chanref-p1-typing-sweep
Jul 11, 2026
Merged

steipete merged 2 commits into
mainfrom
claude/chanref-p1-typing-sweep

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #104318

What Problem This Solves

qqbot ran its own setInterval typing-keepalive class instead of the core keepalive loop — risky on QQ specifically, because typing renewals spend the same ≤5-replies-per-msg_id budget as real sends and must reserve capacity for the final reply.

Why This Change Was Made

TypingKeepAlive now delegates interval/stop/in-flight-suppression orchestration to core createTypingKeepaliveLoop (exposed via the same channel-outbound SDK seam discord already uses), while all budget accounting stays channel-side and unchanged: 3 attempt-counted renewals including token-refresh retries, final-reply reserve, permanent stop latch, 5s cadence. createTypingCallbacks was deliberately not used — its automatic initial fire would spend the budget slot that fetches the reply refIdx. imessage needed no change (already on the core controller via its reply pipeline). Two intentional deltas, both test-pinned: stalled RPC ticks are suppressed instead of overlapping (strictly budget-safer), and the timer is unref'd.

User Impact

No behavior change beyond the budget-safer stalled-tick suppression.

Evidence

  • Blacksmith Testbox tbx_01kx8dnzq3cg4ket6jnebvhcw5 (Actions 29150408619): qqbot 740 + imessage 692 tests green, full pnpm check:changed green.
  • New tests: token-retry budget accounting; stalled-send suppression (no double-send/budget burn); existing cadence + budget-cap tests kept.
  • Autoreview (codex gpt-5.6-sol, xhigh): clean.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 8:40 AM ET / 12:40 UTC.

Summary
The PR moves QQBot typing keepalive scheduling to the shared core loop, retains QQ-specific passive-reply budget accounting, adds retry and overlap tests, and publicly re-exports the low-level loop with updated SDK surface budgets.

PR surface: Source -1, Tests +61, Other 0. Total +60 across 4 files.

Reproducibility: not applicable. This PR addresses internal duplication rather than a reproducible current-main bug, and focused tests define the intended budget and scheduling invariants.

Review metrics: 1 noteworthy metric.

  • Public SDK expansion: 1 helper; aggregate budgets +3 exports, +3 functions, +2 deprecated exports. Compatibility barrels multiply one low-level implementation helper into several durable public surfaces.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #104318
Summary: This PR is an incremental implementation candidate for the QQ shared-helper adoption slice of the canonical channel-refactor program.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Remove or explicitly sponsor the public SDK export with contract coverage.
  • Replace the invalid run citation with successful exact-head validation.
  • Post redacted live QQ proof of renewals and final reply behavior.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Focused tests are present, but the cited Testbox run is unrelated and cancelled and no live QQ after-fix output is supplied; add redacted logs, terminal/live output, or a recording, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] Merging would establish a low-level timer controller as supported third-party plugin API during a phase described as making no API change.
  • [P1] The PR body overstates validation by citing an unrelated cancelled Testbox run.
  • [P1] The exact current head lacks completed validation and after-fix live QQ evidence showing renewals and successful final reply delivery.

Maintainer options:

  1. Keep Phase 1 API-neutral (recommended)
    Remove the public re-export and preserve the QQ refactor through a narrow approved runtime boundary.
  2. Approve and lock the API
    Accept the compatibility commitment with owner approval, lifecycle documentation, direct contract tests, and final exact-head proof.
  3. Wait for the contract phase
    Pause this adoption until the broader channel program reaches its explicitly API-changing phase.

Next step before merge

  • [P1] A channel/plugin SDK owner must choose the permanent API boundary; afterward the contributor must provide valid exact-head validation and real QQ behavior proof.

Maintainer decision needed

  • Question: Should createTypingKeepaliveLoop become a supported public plugin SDK contract during the channel program's API-neutral mechanical-adoption phase?
  • Rationale: The implementation is reusable, but its permanent third-party lifecycle contract cannot be selected from code correctness alone.
  • Likely owner: steipete — The linked phased program and relevant feature history make Peter Steinberger the strongest available owner for this API-direction choice.
  • Options:
    • Keep Phase 1 API-neutral (recommended): Remove the public export and route QQBot through a narrow bundled or injected runtime seam.
    • Sponsor the public API: Approve the export with documented lifecycle semantics, direct SDK contract tests, and explicit compatibility ownership.
    • Defer the refactor: Retain QQBot's local scheduler until the planned channel contract phase defines the permanent seam.

Security
Cleared: The patch adds no dependency, workflow, permission, secret, download, package-resolution, or other supply-chain execution change.

Review findings

  • [P1] Keep this phase from adding a public SDK contract — src/plugin-sdk/channel-outbound.ts:36
Review details

Best possible solution:

Keep the QQ scheduling refactor behind the narrowest approved bundled or injected runtime seam; promote the loop publicly only with explicit SDK-owner sponsorship, lifecycle documentation, direct contract coverage, completed exact-head validation, and redacted live QQ proof.

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

Not applicable; this PR addresses internal duplication rather than a reproducible current-main bug, and focused tests define the intended budget and scheduling invariants.

Is this the best way to solve the issue?

No, not at the proposed boundary: sharing the scheduler is maintainable, but public SDK promotion is broader than necessary for mechanical adoption and lacks owner-approved contract proof.

Full review comments:

  • [P1] Keep this phase from adding a public SDK contract — src/plugin-sdk/channel-outbound.ts:36
    This export still turns an internal timer controller into supported third-party API during the linked program's no-API-change phase. Remove the re-export and use an approved bundled/runtime seam, or obtain explicit owner sponsorship with lifecycle docs and direct contract tests.
    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 high; reviewed against 0ca6880f3d92.

Label changes

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused tests are present, but the cited Testbox run is unrelated and cancelled and no live QQ after-fix output is supplied; add redacted logs, terminal/live output, or a recording, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P3: This is low-urgency internal channel cleanup without a reported broken current user workflow.
  • merge-risk: 🚨 compatibility: The branch promotes a low-level lifecycle controller into the supported third-party plugin SDK.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused tests are present, but the cited Testbox run is unrelated and cancelled and no live QQ after-fix output is supplied; add redacted logs, terminal/live output, or a recording, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source -1, Tests +61, Other 0. Total +60 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 21 22 -1
Tests 1 61 0 +61
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 5 5 0
Total 4 87 27 +60

What I checked:

  • Public SDK boundary: The head re-exports createTypingKeepaliveLoop from the public channel-outbound SDK entrypoint, while scoped SDK policy says internal channel helpers should be exposed only when intentionally promoted as supported contracts. (src/plugin-sdk/channel-outbound.ts:36, 8b237678d836)
  • QQ budget preservation: The refactored implementation retains attempt accounting, counts token-refresh retries, reserves the final reply slot, and permanently stops when the renewal budget is exhausted. (extensions/qqbot/src/engine/gateway/typing-keepalive.ts:79, 8b237678d836)
  • Shared loop semantics: Current main's core loop starts without an immediate tick, suppresses overlapping asynchronous ticks, unreferences the timer, and supports explicit stop. (src/channels/typing-lifecycle.ts:19, 0ca6880f3d92)
  • Invalid cited validation: The PR body cites Actions run 29150408619, but GitHub reports unrelated head SHA f8aa995856ecec703e7391e0f3818a16ac844847; its Testbox execution was cancelled before the claimed results completed. (f8aa995856ec)
  • Exact-head CI state: The active CI run targets the current PR head, but it remained in progress during review and therefore does not provide completed exact-head proof. (8b237678d836)
  • Feature provenance: Blame attributes the shared typing-loop implementation to Vincent Koc, while QQ typing history and the linked channel-refactor program connect Peter Steinberger to the surrounding behavior and product direction. (src/channels/typing-lifecycle.ts:1, a8ce8929096f)

Likely related people:

  • steipete: The linked channel-refactor program and merged history connect Peter Steinberger to the channel contract and QQ typing behavior, making him the strongest product-boundary decision owner. (role: feature owner and program proposer; confidence: high; commits: 7875dd97a11a, ab96520bbad5, 2766c27b2aa6; files: extensions/qqbot/src/engine/gateway/typing-keepalive.ts, src/channels/plugins/types.plugin.ts, src/channels/message/reply-pipeline.ts)
  • vincentkoc: Current blame attributes the shared typing loop to Vincent Koc, with adjacent merged work on channel runtime imports and plugin SDK boundaries. (role: shared-loop and SDK-boundary contributor; confidence: high; commits: a8ce8929096f, 61f93540b262, 9bfaf7b681c6; files: src/channels/typing-lifecycle.ts, src/plugins/runtime/runtime-channel.ts, extensions/discord/src)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (4 earlier review cycles)
  • reviewed 2026-07-11T11:34:25.129Z sha 4b29da5976a5aa2a1355790c65005893515c637c :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T11:43:45.406Z sha 4b29da5976a5aa2a1355790c65005893515c637c :: needs real behavior proof before merge. :: [P1] Update the SDK surface contract for the new export
  • reviewed 2026-07-11T12:09:24.966Z sha 2aeb190f106efa716d5099bcac76683bdccd3002 :: needs real behavior proof before merge. :: [P1] Keep this phase from adding a public SDK contract
  • reviewed 2026-07-11T12:16:32.397Z sha 2aeb190f106efa716d5099bcac76683bdccd3002 :: needs real behavior proof before merge. :: [P1] Keep this phase from adding a public SDK contract

@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: 4b29da5976

ℹ️ 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".

@@ -31,6 +31,9 @@ export {
createChannelReplyPipeline as createChannelMessageReplyPipeline,
resolveChannelSourceReplyDeliveryMode as resolveChannelMessageSourceReplyDeliveryMode,
} from "../channels/message/index.js";
// Bare interval/stop orchestration for channels that own their typing renewal
// policy (e.g. per-message reply budgets) instead of the createTypingCallbacks lifecycle.
export { createTypingKeepaliveLoop } from "../channels/typing-lifecycle.js";

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.

P1 Badge Update the SDK surface budget for this export

This adds a new public function export to openclaw/plugin-sdk/channel-outbound (a public SDK subpath listed in scripts/lib/plugin-sdk-entrypoints.json). The workflow sanity job runs pnpm plugin-sdk:surface:check (.github/workflows/workflow-sanity.yml:215-216), and that check compares public export/function counts against the checked-in defaults in scripts/plugin-sdk-surface-report.mjs; this diff increases both counts but does not update the budget/contract artifacts, so the SDK surface check will fail when this commit is validated. Please either keep the helper out of the public SDK or update the SDK surface budget intentionally with this new export.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jul 11, 2026
@steipete
steipete force-pushed the claude/chanref-p1-typing-sweep branch from 2aeb190 to 8b23767 Compare July 11, 2026 12:33

@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: 8b237678d8

ℹ️ 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".

} from "../channels/message/index.js";
// Bare interval/stop orchestration for channels that own their typing renewal
// policy (e.g. per-message reply budgets) instead of the createTypingCallbacks lifecycle.
export { createTypingKeepaliveLoop } from "../channels/typing-lifecycle.js";

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.

P1 Badge Regenerate the SDK API baseline for this export

This adds a public openclaw/plugin-sdk/channel-outbound export, but only the surface-budget script was updated. The workflow sanity job also runs pnpm plugin-sdk:api:check (.github/workflows/workflow-sanity.yml:212-216), and that check hashes every public SDK export from the TypeScript module surface (src/plugin-sdk/api-baseline.ts:452-464) against docs/.generated/plugin-sdk-api-baseline.sha256; because this commit does not update that hash, the API baseline check will still report drift. Please run pnpm plugin-sdk:api:gen and commit the updated hash, or keep the helper out of the public SDK.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 11, 2026
@steipete
steipete merged commit 3f33f0b into main Jul 11, 2026
120 of 126 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the claude/chanref-p1-typing-sweep branch July 11, 2026 12:48
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
…ing intact (openclaw#104438)

* refactor(channels): adopt core typing keepalive loop

* chore(plugin-sdk): pin surface budget for typing keepalive re-export
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: qqbot maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant