Skip to content

Agents: people on an agent's allowed list can DM it, and a refusal always reaches the sender - #160

Merged
QuicksilverSlick merged 2 commits into
mainfrom
fix/agent-dm-allowlist
Nov 20, 2026
Merged

QuicksilverSlick merged 2 commits into
mainfrom
fix/agent-dm-allowlist

Conversation

@QuicksilverSlick

@QuicksilverSlick QuicksilverSlick commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Factory-Task: partner-fixes-15nov/1-chris-dm
Built-by: claude-code/claude-opus-5-5
Claude-Account: russelledeming@gmail.com
Undo: revert this PR's merge commit. Allowlisted people are then dropped in DMs again, as upstream does. A refusal notice that fails is again silent, with no retry, card or text. The relay's reason drops out of the log again. Nothing is stored, so nothing needs cleaning up.

Was stacked on #155, which merged in train #172 on 18 Nov; now based on main. #160 and #161 should still ship together.

Ship together with fix/guest-words-fresh-session (slice 2), in the same train. Please tap both, or neither. The reason is under "Why the two ride together".

In plain words

On 13 Nov Chris, who is on Chris Orchestrator's allowed list, DMed it three times and got nothing back.

  • The gate: inside a DM the agent checked only "owner or sibling agent" and never read its allowed list.
  • The reply failed: the "not set up to take requests from you" reply failed (HTTP 400), and the harness threw away the relay's reason.
  • The memo: that failed reply still used up his one notice, so his next two DMs got silence.

After this PR:

  1. People on an agent's allowed list can DM it when the agent is set to "Selected people". The check is on who wrote the message. A stranger in the same DM still gets nothing. An agent set to "Anyone" still answers only you and its siblings in DMs.
  2. The relay's reason is kept. A refused post now logs the relay's own words, for example restricted: not a channel member, so the next failure names the real rule.
  3. Turned-away people are told. The "not set up to take requests" reply is posted. If the relay refuses it, the agent waits 11 s (the relay's membership cache) and tries once more.
  4. If both tries fail, you hear about it once per person per conversation. You get one Critical Bench card, " turned away a message without telling the sender", with an Open message link, and one text (your D1 pick). The person's next message gets one more try. After that a relay that keeps refusing costs no more posts, cards or texts.
  5. People who wrote while the agent was down are told too. Before, a refused @mention sent while the agent was down got no reply, ever. Plain messages that weren't mentions still get none, because they would repeat on every restart.

Chris must resend his three 13 Nov DMs after this is released. The catch-up ledger already marked them done, so they will not replay. Until then he can use a shared channel and tag the agent.

Deliberately different from Block's upstream (block#2591)

Block's block#2591 (cb42c8d) made DMs owner-and-siblings only in every mode, because an agent can be asked to open a DM with anyone. This fork lets allowlisted people through in DMs on purpose: you chose that on Sun 15 Nov 2026. The narrower risk Block guarded against still holds:

  • the check is on the author, never on DM membership, so a stranger added to a DM gets nothing;
  • anyone mode stays owner-only in DMs.

The code comment on the new arm and the flipped test, test_dm_admits_allowlisted_person_under_allowlist (it replaces upstream's test_dm_rejects_allowlisted_external_pubkey), both say this. On the next upstream sync, keep our arm. A later Block edit to author_allowed arrives as a held commit.

Why the two ride together

DMs always get one session per conversation. Once this PR lets an allowlisted person into a DM, that person and you can share one agent session in a group DM. Until slice 2 lands, their words would then sit in that session carrying your trust. Slice 2 starts a fresh session when you speak after a guest. The two merge cleanly (git merge-tree), and the merged tree passes clippy with -D warnings.

What changes

  • lib.rs, author_allowed: in a DM, RespondTo::Allowlist with the author on the list returns allowed. The setup-mode comment in setup_mode.rs is updated, because setup mode reuses this gate: an allowlisted person DMing a not-yet-ready agent now gets its setup nudge.
  • relay.rs, request_with_retry: a non-retriable status reads the first 200 characters of the body into the warn log and the error. The client's 10 s timeout bounds the read. Nothing matches on this string.
  • pool.rs, post_notice: now returns whether the relay accepted the notice. The other four callers ignore the result.
  • lib.rs, refusal notice:
    • post_refusal_notice posts with waits [0, 11 s].
    • settle_refusal_notice then decides. A landed notice keeps its (channel, sender) claim. A pair's first failure releases the claim once, raises the card and returns the text. Any later failure keeps the claim and raises nothing.
    • The text is sent from the notice task itself. The beat that sends queued texts runs only while the agent's pool is awake, and refusals mostly arrive while it sleeps.
  • lib.rs, gate_notice_due: a refused mention replayed on catch-up now gets the notice. It is ledgered when refused, so it never replays twice.
  • factory.rs, refusal_unseen:
    • the card id is <agent>-refused-<channel>-<sender key, 12 chars>, so a restart overwrites the same card instead of adding one;
    • the body is neutral: "If they should have access, change who can send it instructions…";
    • the text goes through alert_aside, not alert_critical. A refusal isn't an incident, so it must not mute the next real Critical's text or owe you an "all clear" text.

Tests

  • New or changed tests:
    • lib.rs gate:
      • test_dm_admits_allowlisted_person_under_allowlist
      • test_dm_rejects_stranger_under_allowlist
      • test_dm_ignores_the_list_outside_allowlist_mode
      • test_dm_from_allowlisted_person_passes_the_listener_gate, the 13 Nov incident replayed through the listener gate, with no relay lookup needed
    • lib.rs refusal notice:
      • backlog_refusal_notices_only_a_ledgered_mention (table)
      • refused_post_names_the_relay_rule (loopback relay returning 400)
      • refusal_notice_retries_until_the_relay_accepts_it: 400 then 200 lands in 2 posts; always 400 stops after exactly 2
      • refusal_memo_releases_a_failed_claim_once: success keeps the claim with no card; the first failure releases the claim and gives 1 card and 1 text; a second failure keeps the claim with no new card or text
    • factory.rs: refusal_unseen_card_links_the_message_and_never_shows_unsafe_text checks the title, severity, link, wait line, the pair-keyed id and card_safe body, one text, and no incident opened.
    • Upstream-rule tests, updated: production_listener_boundaries_enforce_dm_author_policy now expects an allowlisted DM author through both listeners. test_discovery_without_metadata_stays_fail_closed_at_author_gate proves DM hardening with anyone plus a stranger.
  • Targeted run (head afdafdcc8): 27 passed, 0 failed.
  • Mutation checks:
    • With the allowlist arm, the relay-reason suffix and the memo release removed: 4 tests failed.
    • With the release made unconditional, or the text switched back to alert_critical: the memo test and the factory test failed.
    • Everything was restored, and the tests then passed again.
  • Lint: cargo fmt --check and cargo clippy -p buzz-acp --all-targets -- -D warnings are clean.
  • Full cargo test -p buzz-acp --no-fail-fast on this Windows PC (vcvars64, private target dir):
    • head afdafdcc8: lib 1321 passed / 42 failed;
    • base e0d86b1fa: 1314 passed / 42 failed.
    • The failing test names, taken from the second failures: block, are identical, with nothing new and nothing gone. All 42 are the known Windows process-spawn and wall-clock set.
    • Integration tests pass (pool_lifecycle_state 9, stdio_contract 1).

Not verified

  • No live or full-stack check. It was not run against a local relay and agent, and not in the app. The after-release check: Chris DMs Chris Orchestrator, its log shows turn starting for that DM, and there is no "inbound author gate — dropping" line.
  • Why the 400 happened is a strong guess, not proven: the relay's 10 s membership cache on a seconds-old DM. The 11 s retry covers that window, and this PR makes the next failure name the real rule.
  • The text depends on the alert command. It goes through the existing deliver_factory_state, and nothing here exercises that send end to end. With BUZZ_FACTORY_ALERT_CMD unset it is only logged, as for every other alert.
  • A slow notice can be counted as failed even though it landed. post_notice gives up after 5 s, and the relay can still accept it after that. The person may then get the notice twice, and you may get a card saying they weren't told. This is accepted: it happens at most once per person per conversation.
  • A retry waiting out its 11 s is lost if the agent shuts down. Its error log goes with it.
  • Two kinds of refusal still get no notice: a refusal after a failed lookup (Unverified), and a non-mention sent while the agent was down. Allowlisted people never hit either one.
  • You can't see partners' DMs with your agent. The agent's turns still show in its own log.

Labels: lane:ready + lane:hold (auth: who may instruct the agent). Open it as a draft, and label it only once CI is green on its head.

Size: 5 files, 513 changed lines (467 insertions, 46 deletions).

🤖 Generated with Claude Code

QuicksilverSlick and others added 2 commits November 15, 2026 15:18
… sender

On 13 Nov Chris, on Chris Orchestrator's allowlist, DMed it and got nothing:
- The DM branch of the author gate checked only owner-or-sibling and never
  read the allowlist (upstream block#2591). In allowlist mode an allowlisted author
  now passes in a DM. The check stays on the author, so a stranger in the
  same DM gets nothing, and `anyone` stays owner-only in DMs. This diverges
  from upstream on purpose: keep our arm on the next sync.
- The "not set up to take requests" reply failed with HTTP 400 and the
  relay's reason was thrown away. A non-retriable status now logs and
  returns the first 200 characters of the body.
- The one-notice memo was used up by that failed post, so his next two DMs
  met silence. The notice now posts, waits 11 s (the relay's membership
  cache) and tries once more. The memo keeps a (channel, author) claim only
  once the relay accepted the notice; a failed one releases it so the next
  message tries again, logs an error and gives the owner a Critical Bench
  card plus a text (D1).
- A mention refused on catch-up (sent while the agent was down) now gets the
  notice too: it is ledgered when refused, so it never replays twice.
  Non-mentions still get none.

post_notice now returns whether the relay accepted it; the other four
callers ignore it. Two older tests that pinned the upstream DM rule are
updated: the listener-boundary test now expects an allowlisted DM author
through both listeners, and the discovery fail-closed test proves DM
hardening with `anyone` + a stranger.

Chris's three 13 Nov DMs will not replay (the ledger marked them done); he
must send again once this is live.

Factory-Task: partner-fixes-15nov/1-chris-dm
Claude-Account: russelledeming@gmail.com
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nder

Review fixes for the allowlisted-DM slice:
- A pair's first failed notice releases its claim once, so the sender's
  next message tries again, and tells the owner once. Any later failure
  keeps the claim: a relay that keeps refusing costs no more posts, cards
  or texts. The card id is keyed on (channel, sender), not the event.
- The owner's text goes out from the notice task itself. The beat that
  sends queued texts runs only while the pool is up, and a refusal arrives
  while it sleeps.
- The text uses alert_aside, not alert_critical: a refusal is not an
  incident, so it must not mute the next real Critical's text or owe an
  all-clear nobody expects.
- The card's advice no longer assumes allowlist mode: "change who can send
  it instructions".

Factory-Task: partner-fixes-15nov/1-chris-dm
Claude-Account: russelledeming@gmail.com
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@QuicksilverSlick QuicksilverSlick added lane:ready Builder is done: green, agent-reviewed, exercised. The steward puts it in the next train. lane:hold Needs the owner's read before any train (paid path, auth, migrations, or asked for). labels Nov 15, 2026
@QuicksilverSlick
QuicksilverSlick changed the base branch from upstream-manual/44c8206beacb to main November 18, 2026 23:11
@QuicksilverSlick

Copy link
Copy Markdown
Owner Author

Retargeting to main: its base (#155's branch) merged in train #172, and the steward does not retarget a child whose parent left in a train. Closing and reopening only to start CI against main.

@QuicksilverSlick
QuicksilverSlick merged commit 8428950 into main Nov 20, 2026
213 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lane:hold Needs the owner's read before any train (paid path, auth, migrations, or asked for). lane:ready Builder is done: green, agent-reviewed, exercised. The steward puts it in the next train.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant