Skip to content

refactor(channels): centralize progress draft events - #117269

Merged
steipete merged 1 commit into
mainfrom
codex/prod-wave-channel-progress-052208-2d45
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/prod-wave-channel-progress-052208-2d45

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • centralize typed progress-event translation and compact receipt tracking in the shared channel owner
  • make the shared draft loop/controls generic so Slack queues { text, blocks } atomically and Matrix/Slack share one finalizable lifecycle
  • reset Discord progress on authoritative queued-followup admission so state cannot leak across queued turns

Root cause and owner

Progress lifecycle policy had spread into Slack, Discord, and Matrix. Slack additionally stored blocks in a sidecar separate from the queued text, and Discord depended on onAssistantMessageStart even though queued execution strips that callback. The architectural owner is the shared channel progress compositor plus draft loop/controls.

The canonical fix moves event-phase gating and receipt tracking to focused shared channel modules, carries each channel's formatter policy as an injected callback, and uses the queued-followup admission callback as the authoritative turn boundary. Removed paths include Slack's pendingUpdate/manual lifecycle, Discord's local receipt state, and repeated channel event mappings.

Telegram and Mattermost were inspected but intentionally left unchanged: their summary/generation contracts are different from these incremental draft transports.

Compatibility

Existing string draft-loop behavior remains the default through additive generic defaults and optional payload hooks. Existing plugin SDK export names/subpaths are unchanged; the generated API manifest was refreshed for the additive generic/optional return surface. No new public barrel was added.

Production delta

Handwritten production code is net -144 LOC (tests net +150 LOC; generated SDK manifest counted separately).

Proof

  • 418 focused channel tests passed across shared compositor/loop/controls and Slack, Discord, and Matrix integrations
  • strict undefined/wrong terminal phases are suppressed in shared and channel integration tests
  • Slack same-text/changed-block updates stay atomic across an in-flight update
  • Discord queued-followup tests exercise onQueuedFollowupAdmitted directly
  • plugin SDK manifest generation/check passed
  • direct dead-export scan passed with 0 entries
  • autoreview clean, confidence 0.98
  • Testbox run tbx_01kyy0vxe781m188gq3zfnadtg passed formatting, SDK contract, dependency/plugin guards, dead exports, and all core/extension production/test typechecks; it found only unbound callback-method lint
  • after converting the private event handlers to arrow callbacks, the exact changed lint path passed locally
  • final exact-head Testbox retry tbx_01kyy1neehpejq4qn36kjde5yq was shut down by the backend before checkout
  • hosted exact-head CI completed with 82 passing checks and no failures

Redacted channel-runtime evidence

This no-source-change proof ran the nearest real process/inbound channel harnesses at exact head a5851003ec6a2f513181d5fcff20fbdebd6bfba1. It uses mocked external channel APIs/providers while executing the production Discord process callbacks, Slack dispatch/draft stream, and Matrix handler/draft controller.

Command:

node scripts/run-vitest.mjs \
  extensions/discord/src/monitor/message-handler.process.draft-progress.test.ts \
  extensions/slack/src/draft-stream.test.ts \
  extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts \
  extensions/matrix/src/matrix/monitor/handler.test.ts \
  --reporter verbose \
  -t 're-arms progress collapse for a queued assistant turn|does not collapse a text-only queued assistant turn|cleans up an unfinished queued progress turn|edits changed blocks even when fallback text is unchanged|suppresses terminal progress callbacks without their terminal phase'

Redacted terminal excerpt:

RUN  v4.1.10 .../channel-progress
✓ Discord process: re-arms progress collapse for a queued assistant turn
✓ Discord process: does not collapse a text-only queued assistant turn
✓ Discord process: cleans up an unfinished queued progress turn
✓ Slack draft stream: edits changed blocks even when fallback text is unchanged
✓ Slack dispatch: suppresses terminal progress callbacks without their terminal phase
✓ Matrix handler: suppresses terminal progress callbacks without their terminal phase
process exit: 0

Verdict JSON:

{
  "schema": "openclaw.real-behavior.v1",
  "head": "a5851003ec6a2f513181d5fcff20fbdebd6bfba1",
  "mode": "nearest-process-inbound",
  "externalChannelApis": "mocked",
  "provider": "mocked",
  "redacted": true,
  "commandExit": 0,
  "checks": [
    {
      "channel": "discord",
      "surface": "processDiscordMessage",
      "cases": 3,
      "result": "pass",
      "observed": [
        "queued progress re-armed at authoritative admission",
        "text-only queued turn remained uncollapsed",
        "unfinished queued progress was cleaned"
      ]
    },
    {
      "channel": "slack",
      "surface": "dispatch plus draft stream",
      "cases": 2,
      "result": "pass",
      "observed": [
        "same fallback text with changed blocks emitted the new atomic payload",
        "non-terminal command and patch callbacks stayed hidden"
      ]
    },
    {
      "channel": "matrix",
      "surface": "monitor handler plus draft controller",
      "cases": 1,
      "result": "pass",
      "observed": [
        "non-terminal approval, command, and patch callbacks emitted no draft"
      ]
    }
  ],
  "overall": "pass"
}

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: matrix Channel integration: matrix channel: slack Channel integration: slack size: L maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 06:59
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 3:06 AM ET / 07:06 UTC.

ClawSweeper review

What this changes

Centralizes progress-draft event translation, receipt tracking, and finalizable draft-stream controls used by Discord, Slack, Matrix, and shared channel code.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

The refactor follows the existing shared queued-followup admission contract and centralizes repeated channel lifecycle logic, so this PR remains useful. It needs explicit maintainer handling plus real after-fix channel behavior evidence before merge.

Priority: P2
Reviewed head: a5851003ec6a2f513181d5fcff20fbdebd6bfba1
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch aligns with the existing shared lifecycle contract and includes focused coverage, but real behavior proof remains a merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports focused tests and Testbox checks, but it does not include after-fix runtime evidence for the affected channel behavior; post redacted logs, a terminal transcript, or a recording after refresh. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports focused tests and Testbox checks, but it does not include after-fix runtime evidence for the affected channel behavior; post redacted logs, a terminal transcript, or a recording after refresh. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Queued-followup owner: Current main invokes the optional queued-followup callback immediately after the follow-up owns the reply lane and before its model run proceeds.
Existing contract coverage: Current-main admission coverage asserts that the queued-followup callback is called once after admission.
PR uses the established boundary: The branch resets Discord progress through onQueuedFollowupAdmitted, rather than relying only on assistant-message-start events that queued execution may omit.
Findings None None.
Security None None.

How this fits together

Channel plugins convert agent progress callbacks into editable draft messages before a final reply replaces them. The shared compositor owns event translation and draft lifecycle behavior, while the follow-up admission path establishes when a queued turn begins.

flowchart LR
  A[Agent progress events] --> B[Reply and follow-up admission]
  B --> C[Channel reply callbacks]
  C --> D[Shared draft compositor]
  D --> E[Discord Slack and Matrix drafts]
  E --> F[Final channel reply]
Loading

Decision needed

Question Recommendation
Should this protected cross-channel refactor land after its branch is refreshed and its queued-followup behavior is demonstrated in a real channel runtime? Refresh and validate: Rebase or refresh against current main, complete the protected checks, and post redacted after-fix runtime evidence before merge.

Why: The maintainer label requires explicit maintainer handling, and this change modifies shared draft behavior consumed by Discord, Slack, and Matrix.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports focused tests and Testbox checks, but it does not include after-fix runtime evidence for the affected channel behavior; post redacted logs, a terminal transcript, or a recording after refresh. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The PR is behind current main; refresh it before protected landing so the existing queued-followup admission contract is preserved in the merge result.
  • Resolve merge risk (P1) - The PR body reports tests and Testbox checks, but does not yet show an after-fix runtime channel transcript, recording, terminal output, or redacted logs for the changed lifecycle.
  • Complete next step (P2) - Protected maintainer handling, branch refresh, and real-behavior proof are required; no discrete mechanical defect warrants an automated repair lane.
Agent review details

Security

None.

PR surface

Source -143, Tests +149, Generated 0. Total +6 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 13 339 482 -143
Tests 7 155 6 +149
Docs 0 0 0 0
Config 0 0 0 0
Generated 1 3 3 0
Other 0 0 0 0
Total 21 497 491 +6

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Refresh the branch against current main, preserve the shared follow-up admission callback, and attach redacted evidence showing a queued follow-up resets and renders draft progress correctly on an affected channel.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Refresh the branch against current main, preserve the shared follow-up admission callback, and attach redacted evidence showing a queued follow-up resets and renders draft progress correctly on an affected channel.

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

Not applicable: this is an internal lifecycle refactor rather than a user-reported bug. Current-main source and tests confirm that the queued-followup callback already has a concrete admission path.

Is this the best way to solve the issue?

Yes, provisionally: the shared compositor and draft controls are the common owner for this duplicated channel lifecycle policy, and the Discord change consumes an existing authoritative queued-turn callback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 78486e27511c.

Labels

Label changes:

  • add P2: The refactor changes progress-draft behavior across three channel plugins, but current source confirms the key shared lifecycle boundary already exists.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests and Testbox checks, but it does not include after-fix runtime evidence for the affected channel behavior; post redacted logs, a terminal transcript, or a recording after refresh. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: The refactor changes progress-draft behavior across three channel plugins, but current source confirms the key shared lifecycle boundary already exists.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests and Testbox checks, but it does not include after-fix runtime evidence for the affected channel behavior; post redacted logs, a terminal transcript, or a recording after refresh. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main provenance attributes the queued-followup contract and draft-stream controls to this contributor, and the branch refactors those same boundaries. (role: recent shared-channel and follow-up lifecycle contributor; confidence: high; commits: d8ba00f8a262, a5851003ec6a; files: src/auto-reply/get-reply-options.types.ts, src/auto-reply/reply/followup-turn-admission.ts, src/channels/draft-stream-controls.ts)

Rank-up moves

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

  • Attach redacted after-fix Discord, Slack, or Matrix evidence that includes a queued follow-up turn.
  • Refresh the branch against current main before protected landing.

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 edfeec4 into main Aug 1, 2026
199 of 208 checks passed
@steipete
steipete deleted the codex/prod-wave-channel-progress-052208-2d45 branch August 1, 2026 07:26
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

channel: discord Channel integration: discord channel: matrix Channel integration: matrix channel: slack Channel integration: slack docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L 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