docs/plans/2026-07-21-channel-delivery-review-fixes.md
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Close the actionable review findings on PR #7388 without adding durable delivery retries or allowing delivery diagnostics to affect Agent execution.
Architecture: Keep immediate delivery semantics. Add short-lived daemon-owned authorization for prompt and scheduled targets, preserve producer-specific execution, and keep logging as a best-effort observation side effect. Reuse the existing Channel worker IPC and public result event.
Tech Stack: TypeScript, ACP bridge, Express daemon routes, Channel worker IPC, Vitest.
delivery remain unchanged.Files:
integration-tests/cli/qwen-serve-routes.test.tsInterfaces:
Consumes: GET /capabilities feature list.
Produces: exact integration expectation including channel_delivery.
Add channel_delivery to the existing exact capability expectation.
Run the affected bundled-daemon integration file and verify all 35 cases pass.
Files:
packages/cli/src/serve/channel-delivery-authorization.tspackages/cli/src/serve/channel-delivery-authorization.test.tspackages/cli/src/serve/routes/session.tspackages/cli/src/serve/routes/scheduled-tasks.tspackages/cli/src/serve/scheduled-task-keepalive.tspackages/cli/src/serve/run-qwen-serve.tspackages/cli/src/serve/server.tsInterfaces:
Consumes: daemon-admitted Prompt {sessionId, promptId, target} and persisted scheduled task {id, sessionId, recurring, lastFiredAt, delivery.target}.
Produces: one-shot authorizePrompt, scheduled registerTask, revokeTask, and callback consume checks that deep-compare the target before worker IPC.
Write failing tests proving an unregistered callback, changed target, repeated Prompt callback, and invalid/replayed scheduled fire are rejected before worker IPC.
Run the focused tests and confirm the expected authorization failures.
Implement an in-memory authorization store with Prompt consume-once behavior and scheduled monotonic-fire/one-shot behavior.
Wire Prompt admission, scheduled CRUD/rehydration, and the bound delivery handler to the store.
Run the focused tests and verify authorized Prompt, recurring, and one-shot deliveries still pass.
Files:
packages/cli/src/acp-integration/session/Session.tspackages/cli/src/acp-integration/session/Session.test.tspackages/cli/src/serve/run-qwen-serve.tspackages/cli/src/serve/run-qwen-serve.test.tsInterfaces:
Consumes: Prompt and cron stream events plus resolved channel_delivery_result values.
Produces: retry-safe final text, no delivery for non-end_turn/aborted turns, and best-effort sanitized daemon warning logs for non-delivered results.
Add failing Prompt and cron tests for retry collector rollback and cancelled/error non-delivery.
Add tests where delivery resolves failed or daemon logger output throws while the Agent turn remains normal.
Run focused Session tests and confirm each regression test fails for the intended reason.
Trim the collector at retry boundaries without awaiting delivery from the Agent turn.
Route failure diagnostics through a non-throwing sanitized daemon helper.
Run focused Session and daemon-handler tests and verify all cases pass.
Files:
packages/cli/src/commands/channel/daemon-worker.tspackages/cli/src/commands/channel/daemon-worker.test.tspackages/cli/src/serve/channel-delivery-ipc.tspackages/cli/src/serve/routes/channel-notify.tsInterfaces:
Consumes: active webhook/delivery promises and Channel adapter failures.
Produces: one shared 10-second drain budget, typed unavailable errors, and a distinct provider-rejection code.
Add failing tests for concurrent drain, typed unavailable classification, and provider rejection not mapping to HTTP 400.
Run focused worker/route tests and confirm the expected failures.
Drain both active maps concurrently, throw/classify typed errors, and add channel_delivery_rejected across the wire contract.
Run focused worker, route, bridge, and SDK tests.
Files:
packages/cli/src/serve/channel-delivery.tspackages/cli/src/serve/channel-delivery.test.tspackages/cli/src/acp-integration/session/Session.tsInterfaces:
Consumes: arbitrary delivery text.
Produces: one CLI truncation helper with surrogate-safe 100,000-code-unit output.
Correct the surrogate-boundary test so deleting the protection makes it fail.
Export and reuse the CLI text normalizer from Session.
Run both focused test files.
Files:
Interfaces:
Consumes: completed implementation.
Produces: verified branch suitable for maintainer rereview.
Run focused tests for every touched package.
Run npm run build, npm run typecheck, and npm run lint.
Run the bundled-daemon route integration test that failed in CI.
Run real IM E2E for notify, Prompt final, scheduled final, and provider rejection using redacted credentials.
Perform two clean diff self-audit passes.
Commit and deliver the fixes to the maintainer-selected branch without resolving or replying to review threads.