Skip to content

fix: tighten a channel send permission check - #33353

Merged
bolichen97 merged 1 commit into
mainfrom
fix/26339-per-part-dm-and-target
Nov 9, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/26339-per-part-dm-and-target

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A long proactive channel message stops going out as soon as the permission behind it is withdrawn, on every proactive channel send path.

A long proactive message reaches a channel as several parts. Two of the three proactive channel paths, the channel owner's direct message and a configured channel destination, decide permission once before the first part. If the operator narrows the channel policy or removes the recipient while the message is going out, the remaining parts are still sent.

Why it matters

An operator who withdraws a channel or a recipient expects messages there to stop. Today the rest of a long agent message, such as a cron report or a subagent result, can still reach a destination that no longer has permission to receive it.

Not a goal

  • Recalling parts delivered before the withdrawal: a channel cannot take back a message it already accepted.
  • Changing what any path permits: every question asked before a part is one that path already asks before the first.
  • The session's own conversation path, which already asks again before each part.

What changed (motivation → approach → change)

The two proactive paths in src/kiro_crew/dashboard ask their own permission questions again before every part of a message, the way the session-conversation path already does: is the channel still allowed by policy, and is the recipient or destination still allowed. The destination is checked once more after it has been looked up, so a destination removed during that lookup is refused as well. When an answer turns to no, the remaining parts are not sent, and the caller gets the permission refusal that path already uses, saying how many parts went out first. When the policy is changing at that very moment, the path asks once more and otherwise stops with a retryable failure. All three paths share one way of asking.

The messaging spec under docs/ records both paths as re-checking before every part, where it used to list them as a deferred gap.

Backwards compatibility

Compatible: a send whose permissions hold delivers every part as before, and a refused part answers with the status and code its path already returns for that refusal.

Removes nothing: no field, key, route, code or command is removed or renamed.

Tests

  • For each of the two paths, under test/: a multi-part send with nothing withdrawn still delivers every part; a policy withdrawn after the first part stops the rest with that path's policy refusal; a recipient or destination withdrawn after the first part stops the rest with that path's recipient refusal; a body that renders to no part at all is still refused where it is not permitted.
  • For the configured destination: a destination removed while a later part is looking it up stops that part with the recipient refusal.
  • The configured-destination tests' stand-in channel lists its destinations, as every real channel does.
  • The session-conversation path's existing per-part tests run unchanged against the shared helpers.

Proof: not provable -- other: prove.py could not check out its throwaway worktree on this disk-bound host before the push

Manual verification

N/A — unit coverage sufficient: each check runs in the send loop itself, and the tests withdraw each permission between real parts of a chunked message.

Related Issues

Closes #26339

Sibling sweep

Siblings: none -- of the three send_message channel paths, the session-conversation one already asks before each part, and these are the other two.

Pattern harvest

Not generalizable: a decision taken once for a message sent in parts; no text rule can tell which loop sends parts of one authorization.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 8, 2026 19:15
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 8769771e0ab6f99e5aab722c5b9d536dd35edc54 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 8769771e0ab6f99e5aab722c5b9d536dd35edc54 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: each part is now authorized by the same questions its path already asked before the first part, through one shared helper, and nothing is taken away.

Notes

  • On Discord, a user: target now calls create_dm_channel once per part. That multiplies Discord API calls by the number of parts in a long cron report. If Discord starts rate-limiting it, those parts fail as channel_delivery_failed. Caching the DM channel for the length of one send would remove those repeated calls and still check membership through the configured_targets() reads before and after each resolve.
  • On _send_to_channel_target, three failures go out as the generic 502 "delivery failed": a target that resolves to a different conversation, a replaced transport, and governance that would not settle. The aborted text saying how many parts were already delivered is logged but never reaches the caller. Only the permission refusals tell the caller how many parts went out.

[DESIGN-REVIEWED] 8769771

Description read

[DESCRIPTION-READ] b5e4452bf395d2e8836fcccb8dad50e20cbe0cf0e6806ec3a538ec3cb444a0e5

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 8769771e0ab6f99e5aab722c5b9d536dd35edc54 — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. The base spec already listed both legs as a deferred gap, and #26339 is linked. The new helper is moved out of _deliver_to_channel and has three call sites.

What this change ships

Inventory (6 items) — 6 justified

Intent: when an operator withdraws a channel or recipient, a long proactive message stops going out partway through. FIX.

  1. On the owner-DM leg, a long message stops after a part once the policy or the owner is withdrawn — justified
  2. On the configured-target leg, a long message stops after a part once the policy or the target is withdrawn — justified
  3. A configured target removed while it is being resolved (the Discord DM-open await) is refused — justified
  4. A refusal says how many parts were delivered before the abort; a replaced transport, or governance that will not settle, fails as retryable — justified
  5. _generation_now/_fresh_governance move out of _deliver_to_channel into one shared helper for all three legs — justified
  6. The messaging spec now records the two legs as re-checking before every part instead of as a deferred gap — justified

[FIRST-PRINCIPLES-REVIEWED] 8769771

Description read

[DESCRIPTION-READ] 7fe010c85571f95e06a19fff65548b29a2ba00ec565421805f8577e27997bfeb

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 8769771e0ab6f99e5aab722c5b9d536dd35edc54 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 8769771

Verdict parsed from the review's SHA-scoped output markers for commit 8769771e0ab6f99e5aab722c5b9d536dd35edc54.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 8769771e0ab6f99e5aab722c5b9d536dd35edc54 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 8769771e0ab6f99e5aab722c5b9d536dd35edc54 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8769771

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 8769771e0ab6f99e5aab722c5b9d536dd35edc54 false-positive: <reason, 20 to 500 characters>

@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 Nov 8, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 8, 2026 19:44
The channel owner's direct message and a configured channel destination
now re-check their permission before every part of a long proactive
message, as the session's own conversation already does, so a policy
narrowed or a recipient removed mid-send stops the remaining parts.

Closes #26339
@bolichen97
bolichen97 force-pushed the fix/26339-per-part-dm-and-target branch from cd559aa to 8769771 Compare November 9, 2026 14:31
@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: re-check the configured target's listing right after its resolve, before the send

  • fixed span=9225d91670db

fixed in 8769771: the configured-target leg reads the transport's configured_targets() just before and just after resolve_configured_target, and a target listed before and gone after is refused as target_not_allowed, synchronously, with nothing awaited before the send.
_authorize_recipient was not reused: WhatsApp's and Weixin's may_send_to refuse targets those transports list and resolve, so it would refuse sends this leg delivers today.
covered by test_send_message_per_part.py::TestPerPartOnTheConfiguredTargetLeg::test_a_target_dropped_during_its_resolve_stops_the_remainder.
[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/dashboard/handlers/messaging.py and test/test_dashboard_server_composition_contract.py since this head's CI ran (c953b74 -> 445dd36); the Backend Tests shard 6 red was main's lazy-import count, re-pinned on main in #33377. CI re-running.
[operator: bolichen97]

@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 labels Nov 9, 2026

@buluoray buluoray 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.

Approved at 8769771. The earlier security block is fixed. The configured-target leg reads configured_targets() synchronously before and after the awaited resolve, and refuses target_not_allowed if the target disappeared, with no await between that check and send (src/kiro_crew/dashboard/messaging_api/channel_delivery.py:805, :832, :836, :869; src/kiro_crew/discord/transport.py:350). A new test pins it and turns red under mutation.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 9, 2026
@bolichen97
bolichen97 merged commit 2329220 into main Nov 9, 2026
99 checks passed
@bolichen97
bolichen97 deleted the fix/26339-per-part-dm-and-target branch November 9, 2026 15:22
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 9, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Red/green for the test added on 8769771, run in place because the throwaway-worktree prover could not finish its checkout on this host:

fix hunk reverted:  FAILED test/test_send_message_per_part.py::TestPerPartOnTheConfiguredTargetLeg::test_a_target_dropped_during_its_resolve_stops_the_remainder - AssertionError: assert 2 == 1
fix restored:       that test + test/test_channel_send_target.py + test/test_send_message_per_part.py: 37 passed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Re-check channel authorization before every part on the owner-DM and configured-target send legs

2 participants