Skip to content

fix(messaging): post a redaction notice at every channel delivery surface - #11257

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
dimwael:fix/channel-redaction-notices
Sep 23, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
dimwael:fix/channel-redaction-notices

Conversation

@dimwael

@dimwael dimwael commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

PR #8291 (dashboard) and PR #11197 (Slack per-turn, Slack review-approve, iMessage) made every surface that already posted a redaction notice cover both body rewriters, worded by kind. Nine channel delivery surfaces still run the same two rewriters over the copyable text they ship and post no notice of either kind: Discord, Webex, WhatsApp, WeCom, Telegram, Teams, Feishu, Weixin and the DEFAULT Slack transport path (messaging.use_transport, on by default, routes every install through SlackRenderer) deliver a credential or suspicious-URL placeholder silently.

Why it matters

A reader who copies a redacted command gets an opaque downstream failure far from the real cause, with no hint the text was altered — the exact reported failure the notice exists to close. And a surface that hand-rolls half the tally (credentials but not the URL prefix) posts a notice naming a remedy that cannot help.

What changed (motivation → approach → change)

Nine silent surfaces → one shared tally and ONE notice mechanism: every surface posts in-renderer over the text it actually delivered, mirroring the iMessage on_done reference shape. No new output kind, no new Renderer hook — an earlier revision carried a driver-level NOTICE event for the pass-through channels, and review (First Principles items 5/6) showed the split was both duplicative and wrong: several renderers re-redact against the form the platform RENDERS (_display_safe in the Slack, Telegram, Teams and Discord renderers), so their delivered text can carry placeholders the driver's accumulated stream never had, and driver-side counting undercounts exactly there.

  • count_redaction_tags(text) beside redaction_notice(): exact-match over CREDENTIAL_REDACTION_TAGS, prefix-match for the URL tag (it interpolates the domain), so a surface cannot adopt half the tally.
  • Slack transport path (slack/renderer.py): one tally per turn over the final display-safe answer body plus the posted 💭 reasoning, one threaded notice at the end of on_done — mirroring the native handler.py per-turn count, which stays in place for use_transport=false installs.
  • Pass-through channels (Telegram — thread-aware, Teams, Feishu, Weixin) count the body their own delivery ships at on_done and post the notice after it lands. Telegram tallies per LANDED frame across seals and the posted reasoning, with the notice at every on_done exit; Weixin's deliberately-raising _send is contained at the notice send, since the answer is already out; Feishu covers both failure shapes of send_reply (False verdict and raise).
  • Rich-lifecycle channels post in-renderer, matching each delivery shape: Discord tallies per LANDED message (streaming edits supersede; sealed forms only) across seals, the markup-recovery re-post and the thinking subtext, with the notice at every on_done exit; Webex counts the assembled answer after the card block; WhatsApp counts the converted chunks that shipped; WeCom tallies at on_done and posts from close() — the one point its deferred-overflow ladder settles — consumed once so a second close() cannot double-post.
  • Existing five sites (dashboard, iMessage, Slack handler ×2 incl. the thinking tally, Slack interactions) swapped onto the shared counter; dead tag imports removed.
  • Security-posture census (security_posture.py): NON_EGRESS_REDACTION_MODULES gains whatsapp/turn_renderer.py. The *redact*( scan matches it because it calls the notice pair (count_redaction_tags + redaction_notice), which tallies placeholders already written by a redaction pass and rewrites no outbound byte; the pass carrying that channel's guarantee stays the registered whatsapp/renderer.py pipeline. feishu/renderer.py needs no allowlist entry: main registers it as a _REDACTION_SINKS egress row (its text() screens the answer body via redact_for_target), so the sink registry already classifies it — a comment in the allowlist says so. The other renderers gaining tallies (Slack, Telegram, Teams, Weixin) are already registered redaction_paths sinks. No registry rows change, so the posture panel counts are untouched.
  • docs/system-specs/modules/messaging.md renderer row and the slack-gateway.md redaction-notice bullet updated in the same commit.

Tests

Per-surface red-before-green + best-effort-failure coverage, mirroring test_imessage_renderer.py::TestRedactionWarning with each surface's existing fakes: TestRedactionNotice classes in test_discord.py, test_webex_renderer.py, test_whatsapp_turn_renderer.py, test_wecom_renderer.py (incl. a second-close idempotence test), test_telegram.py, test_teams_renderer.py, test_feishu_renderer.py (both send_reply failure shapes) and three test_weixin_dispatch.py functions; TestTransportRedactionNotice in test_slack_renderer.py drives the real TurnDriver end to end so the StreamRedactor writes the placeholder exactly as production does; TestCountRedactionTags in test_credential_redaction_notice.py pins the shared tally.

Manual verification

Could not run the suite end-to-end in my environment (Python 3.7 only; the repo needs ≥3.12 and several files carry newer syntax — verified the parse failures are pre-existing via stash-compare against the unmodified files). Every touched file passes ast.parse; ./scripts/docs-lint.sh passes; the comment-history gate passes on every file it can parse under 3.7; the unused-import sweep confirms no orphaned tag imports. CI is the authoritative check for the new tests.

Screenshots / video

N/A — backend channel delivery paths, no UI surface.

Related Issues

Fixes #11206

Pattern harvest

Rule candidate: review-prompt
Pattern: a delivery surface that runs a redactor over outbound text but never tallies the placeholders afterward ships silent rewrites — when adding a channel egress path, check that the text that actually shipped is counted through count_redaction_tags and a notice follows, or that the surface deliberately opts out on a stated ground. Corollary from this PR's review: count at the egress that DELIVERS, not upstream — a renderer that re-redacts against the rendered form makes any upstream tally an undercount.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality (new coverage per surface; could not run the existing suite locally — see Manual verification)
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — messaging.md renderer row + slack-gateway.md, same commit
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache License 2.0, same as the rest of the codebase.

@dimwael
dimwael requested review from a team and chenmingwei23 September 16, 2026 08:37
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed 326e915875570d412409f6bf4bae9f1540a26ba5 via the fork AI-review pipeline; updated in place on each push.

Review details

FINDING -- src/kiro_crew/slack/renderer.py:1418 -- "count_redaction_tags(clean_text)" counts failed stream appends, while posted_any counts failed reasoning chunks -> Fix: tally _delivered on the stream path and each successfully posted reasoning chunk.
FINDING -- src/kiro_crew/discord/renderer.py:1153 -- nullable Discord/Telegram thinking sends are tallied as delivered, and nullable Discord/Telegram/Webex notice sends fail without promised logging -> Fix: check returned message IDs before tallying or declaring notice delivery.
[GPT-REVIEWED] 326e915

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of 326e915875570d412409f6bf4bae9f1540a26ba5 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify CI runs the new per-channel notice tests green — the author could not execute the suite locally (Python 3.7 environment).

Suggestions

  • The "every delivery surface posts a notice" contract now lives in nine bespoke implementations pinned only per-channel; a sweep test over Renderer subclasses (placeholder in → one notice out, or a stated opt-out like SilentRenderer) would stop a tenth channel shipping silent — the gap the PR's own "Pattern harvest" leaves to review memory.

[DESIGN-REVIEWED] 326e915

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of 326e915875570d412409f6bf4bae9f1540a26ba5 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

The author never ran the suite (Python 3.7 environment) — CI green on the new per-surface tests and the posture drift guard is the only proof.

What this change ships

Inventory (10 items) — 10 justified

Intent: FIX — a reader who copies redacted text from nine channel surfaces now learns it was rewritten (issue #11206; base messaging.md already asserts "every channel delivery surface now posts through" the notice, so this makes code match a recorded spec claim).

  1. Discord posts one redaction notice after a rewritten answer — justified
  2. Telegram posts one threaded notice per turn — justified
  3. Teams posts the notice below the answer — justified
  4. Webex posts the notice in-thread — justified
  5. WhatsApp posts the notice after the delivered chunks — justified
  6. WeCom posts the notice from close(), never twice — justified
  7. Feishu posts the notice, both send-failure shapes contained — justified
  8. Weixin posts the notice, its raising sender contained — justified
  9. The default Slack transport path posts the same per-turn notice — justified
  10. Shared count_redaction_tags counter; five existing notice sites swapped onto it — justified

Capped at 10: also a posture-census allowlist row for whatsapp/turn_renderer.py (mandated — the drift guard's \w*redact\w*\( scan matches the new calls, and it is the only touched module not already a registered sink), two spec rows updated per the same-commit rule, and one Discord outbound-files test adapted to read past the new trailing notice (undeclared; the pinned property is unchanged). Grepped class \w+\(Renderer\): 12 subclasses — nine fixed here, iMessage already covered, SilentRenderer and the compaction retry guard deliver nothing — so zero unfixed siblings. count_redaction_tags has 15 counted non-test consumers.

[FIRST-PRINCIPLES-REVIEWED] 326e915

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

Reviewed 326e915875570d412409f6bf4bae9f1540a26ba5 via the fork AI-review pipeline; updated in place on each push.

Review details

The discovery pass found no candidates. My spot-check of the trickiest new paths — the Slack transport renderer's per-turn tally-then-post at the end of on_done (guarded, single-post), the WeCom consume-and-zero on close(), and the WhatsApp NON_EGRESS_REDACTION_MODULES classification (redaction remains in the registered whatsapp/renderer.py sink; the notice pair rewrites no outbound byte, so a misclassification here only understates coverage) — confirms the refactor is byte-for-byte and the notice sends are count-only and best-effort. Nothing survives to report.

No findings.

[OPUS-REVIEWED] 326e915

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 16, 2026
@dimwael
dimwael force-pushed the fix/channel-redaction-notices branch from 935088b to 7eeaca2 Compare September 16, 2026 09:26
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 16, 2026
@dimwael
dimwael force-pushed the fix/channel-redaction-notices branch from 7eeaca2 to 27df10a Compare September 16, 2026 09:55
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 16, 2026
@dimwael
dimwael force-pushed the fix/channel-redaction-notices branch from 27df10a to 2a12a79 Compare September 16, 2026 10:34
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 16, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 17, 2026
@dimwael
dimwael force-pushed the fix/channel-redaction-notices branch 2 times, most recently from be99ccd to 373f33f Compare September 17, 2026 22:41
@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 18, 2026
@dimwael
dimwael force-pushed the fix/channel-redaction-notices branch from 373f33f to 78b93c9 Compare September 18, 2026 00:47
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Sep 18, 2026
@dimwael
dimwael force-pushed the fix/channel-redaction-notices branch from 78b93c9 to 9867136 Compare September 18, 2026 01:29
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 18, 2026
@dimwael
dimwael force-pushed the fix/channel-redaction-notices branch from 9867136 to 7955a7a Compare September 18, 2026 02:47
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 18, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Rebased onto main cff7de5416 by a maintainer to resolve merge conflicts. Old head 7955a7a79d, new head 567a5bd678.

Conflicts resolved (only these files were hand-merged, nothing else changed manually):

  • test/test_wecom_renderer.py -- Kept main’s reasoning/answer-body redaction tests and appended the PR’s redaction-notice tests; both independent additions are preserved unchanged.

Same single commit, same author, same message. The PR’s changes outside the conflict hunk are preserved; upstream main changes are included by the rebase. The original 28-file PR scope and diff size are unchanged (918 insertions, 34 deletions). All 26 changed Python files compile, git diff --check passes, and all 22 WeCom renderer tests pass. Full suite not run.

Any prior approval dismissed by the push needs to be re-given after CI re-runs.

@dimwael

dimwael commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

Post-rebase status on head b206a51b: CI is fully green — all 16 backend shards pass (including the test_security_posture census that failed after the rebase: main's base now registers feishu/renderer.py as an egress sink, so this branch's non-egress allowlist entry for it became a double-bucket and is removed; the census is module-granularity, so the sink row alone classifies it). The Windows test_crew_log_projection failure from the rebased head did not recur.

The one remaining red, Opus 4.8 Review — "review incomplete", is the repo-wide fork-lane outage tracked in #12099 (the Opus lane's egress allowlist still points at the broken classic Bedrock path; no fork PR has had a successful Opus review since at least 11:45 UTC today). Once #12081 lands, this lane needs a re-run here to clear PR Readiness.

@dimwael

dimwael commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

CI dispatch appears stuck for this PR specifically: since the retrigger pushes (and a close/reopen cycle at ~00:47Z), only the fork gates (Fork PR Description ✅, Workflow-Change Guard ✅, Fork PR Label) and PR Readiness have run on the current head — the CI / Fast Gate / Build / test-matrix workflows were never created (they are absent from the head SHA run list and NOT sitting in the action_required approval queue, which is meanwhile processing other fork PRs normally). Three consecutive heads over ~90 minutes show the same pattern, while sibling fork PRs pushed in the same minutes dispatched fully. Could a maintainer kick CI on this head (rerun/manual dispatch)? Happy to push a fresh head instead if that is preferred.

…face

Nine channel delivery surfaces run both body rewriters over the text
they ship and post no notice of either kind: Discord, Webex, WhatsApp,
WeCom, Telegram, Teams, Feishu, Weixin and the default Slack transport
path deliver a credential or suspicious-URL placeholder silently, and
the reader copies a command that will not run with no hint the text
was altered.

Hoist the two-kind tally into a shared count_redaction_tags() beside
redaction_notice(), so a surface cannot adopt half the count and post
a notice worded for the wrong remedy, and post the notice in-renderer
at every surface: each renderer counts the text IT actually delivered,
which can differ from the driver's accumulated stream because several
renderers re-redact against the form the platform renders. Discord and
Telegram tally per landed message across seals, recovery re-posts and
the posted reasoning; Slack counts the final display-safe body plus
the posted reasoning in one tally; Webex counts the assembled answer;
WhatsApp the converted chunks that shipped; WeCom tallies at on_done
and posts from close(), consumed once; Teams, Feishu and Weixin count
the body their on_done delivers. Every notice send is best-effort: the
answer is already out, so a failed send is logged, never raised. Swap
the five existing counting sites onto the shared helper.

Allowlist whatsapp/turn_renderer.py and feishu/renderer.py in
NON_EGRESS_REDACTION_MODULES: the notice pair they now call tallies
placeholders and builds the follow-up sentence, rewriting no outbound
byte; the passes carrying those channels' guarantees stay the
registered whatsapp render pipeline and the TurnDriver's
StreamRedactor.

Closes kirodotdev#11206

Rebase fallout: main now registers feishu/renderer.py as a redaction
sink (its text() override screens the answer body via redact_for_target),
so the non-egress allowlist entry this commit had carried for the notice
pair there is deleted -- the module is classified by the sink registry.
@dimwael

dimwael commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Resolved — the dispatch stall reported above was the PR's mergeability, not the dispatcher: main had moved far enough that the PR became CONFLICTING, so no merge ref existed for pull_request workflows to build against (the fork gates run on pull_request_target/workflow_run and kept appearing, which made it look like selective dispatch). Rebasing onto main 4e7f968c8 (conflicts in 4 files resolved keeping both sides' changes; suite re-verified locally on 3.12) restored the merge ref and every workflow dispatched immediately.

Current head 326e9158 is fully green: 86 checks passing, 0 failing — including CI (all 16 backend shards), Coverage Gate, PR Readiness, and all four AI reviews (Opus 4.8 now passing since the #12099 lane fix). Ready for human review.

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

Labels

fork Pull request from a fork (external contributor) readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redaction notice missing at channel surfaces that post no notice of either kind (Discord, Telegram/driver, Webex, WhatsApp, WeCom)

3 participants