-
Notifications
You must be signed in to change notification settings - Fork 12.9k
fix(cli): wirings create silently skips the agent_destinations side effect — agent sends to the new chat are dropped#2743
Open
sturdy4days wants to merge 1 commit into
Conversation
... row ncl wirings create used the generic CRUD INSERT into messaging_group_agents, skipping the side effect createMessagingGroupAgent performs: the companion agent_destinations row that delivery's ACL checks. A CLI-created wiring therefore RECEIVES messages fine, but every send the agent addresses to the newly wired chat is silently dropped — no error at create time, none visible to the agent. The operator just sees a mute bot. Fix: add ResourceDef.customInsert (replace the generic INSERT with a domain helper when row creation has required side effects) and route wirings-create through createMessagingGroupAgent, filling the columns the CLI def leaves optional with the same defaults setup/register.ts uses. The guard test drives the real dispatch path and asserts both the wiring row and the destination row exist. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sturdy4days
sturdy4days
requested review from
gabi-simons and
gavrielc
as code owners
June 11, 2026 18:59
This was referenced Jun 12, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
ncl wirings creategoes through the generic CRUD layer — a plain INSERT intomessaging_group_agents. But creating a wiring has a required side effect that onlycreateMessagingGroupAgent(src/db/messaging-groups.ts) performs: the companionagent_destinationsrow thatdeliverSessionMessages' permission check consults.Result: a CLI-created wiring receives inbound messages normally, but every message the agent addresses to the newly wired chat is silently dropped by the delivery ACL — no error at create time, nothing visible to the agent, no operator-facing signal. Found live while wiring a multi-bot group (#2733 substrate): the bot looked mute for twenty minutes until we traced the missing destination row.
The setup paths (
setup/register.ts,scripts/init-first-agent.ts) don't have this bug because they call the helper; only the CLI path bypasses it.Fix
ResourceDef.customInsert: an optional hook letting a resource replace the generic INSERT with a domain helper when row creation has required side effects. (Generalizable: any future resource whose insert needs invariants gets the same escape hatch instead of a one-off handler.)wirings.tsroutes create throughcreateMessagingGroupAgent, filling the columns the CLI def leaves optional with the same defaultssetup/register.tsuses.Testing
src/cli/resources/wirings.test.ts) drives the realdispatch()path and asserts both the wiring row AND the destination row exist — it fails on the generic-INSERT behavior (it actually caught a second issue during development: the helper's named-parameter INSERT requires every column, hence the explicit defaults).pnpm run buildclean; full vitest suite green on the patched tree.🤖 Generated with Claude Code