Skip to content

[AI-3809] Sensitive-connector rule holds across child agents - #2432

Merged
kanat merged 5 commits into
mainfrom
kanat/ai-3809-sensitive-across-children
Nov 25, 2026
Merged

kanat merged 5 commits into
mainfrom
kanat/ai-3809-sensitive-across-children

Conversation

@kanat

@kanat kanat commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Piece 1/2 of AI-3748. This PR moves the sensitive-connector rule into its own package and checks it over a parent and its child agents each time the parent hands work to a child. AI-3810 adds the same check to the write paths (create, update, patch, sync).

Why

The rule that a config binding a sensitive connector (one whose tools read private data) has nothing that sends data out with no person's approval was checked per config (SensitiveBindingsComplaint, internal/api/configs.go). A parent and the child agents it delegates to pass input and answers to each other, so two configs that each pass could together put private data in reach of an outbound tool. The runtime path could not reuse the rule: internal/api imports internal/session (api/authorizations.go:28).

How it works

childRunner.Run(call)                       internal/session/child_agents.go
├─ child config loaded, mode / agents checked     (as before)
├─ sensitive.GraphComplaint(set)
│    set = parent as it runs (spec bindings + sandbox)
│        + called child + every other offered child, read from the store now
│  ├─ any member binds a sensitive connector
│  │  and any member sends out ─> tool error "<tool> was not run: ..."
│  │                              the model reads it, the parent run goes on
│  └─ otherwise ─> the child runs                   (as before)

"Sends out" is the existing definition, unchanged: a binding to a source not marked outbound: false whose granted tools are not all read_only_tools or held by require_approval, a binding with sandbox set, or a sandbox that reaches the network.

Graph Before After
parent sensitive, a child sends out children run every delegation refused
a child sensitive, the parent sends out children run every delegation refused
one child sensitive, a sibling sends out, parent neither children run every delegation refused
parent sensitive, a child's sandbox reaches the network children run every delegation refused
sensitive + outbound tool held by require_approval children run children run
nothing sensitive children run children run

One runtime path refuses (childRunner.Run). Stored graphs are not rewritten. Every delegation of a graph that breaks the rule is refused with <tool> was not run: the agent "<name>"'s connector binding "<alias>" binds "<connector>", whose tools read private data, and <each outbound part, with its agent> can send data out with no person's approval, and a parent and its child agents pass on to each other what they read: take them out of these agents, plus the require_approval hint when a tool could be held.

Changes

  • New package internal/connectors/sensitive: ConfigComplaint (the moved per-config rule, same message), GraphComplaint (the same rule over a set of configs), and the moved bindingSendsOut and holdsPattern. Both share one exposureOf.
  • internal/api: the per-config call sites keep using Server.sensitiveBindingsComplaint, which now calls sensitive.ConfigComplaint.
  • internal/session/child_agents.go: childRunner.Run calls GraphComplaint before a child runs. The parent comes from the running session's spec (ConnectorBindings, Sandbox, SandboxOptions, spec.go:322-341), which is what the session uses, so a fork or a parent edited mid-session is checked as it runs.
  • Doc and comment references now point at the new package.

Validation

Test (ChildAgentsSuite, child_agents_sensitive_test.go) Base dca845c Head
TestADelegationIsRefusedWhenTheParentIsSensitiveAndAChildSendsOut fails passes
TestADelegationIsRefusedWhenAChildIsSensitiveAndTheParentSendsOut fails passes
TestADelegationIsRefusedWhenOneChildIsSensitiveAndASiblingSendsOut fails passes
TestADelegationIsRefusedWhenAChildsSandboxReachesTheNetworkBesideASensitiveParent fails passes
TestADelegationBesideASensitiveConnectorRunsWhenEachOutboundToolNeedsApproval (false-positive side, plus a deleted sibling is skipped) passes passes
TestADelegationRunsBesideASensitiveChildTheParentDoesNotOffer (a child whose tool name is taken is never run) passes passes
TestADelegationWithNoSensitiveConnectorRuns (control, its expected value taken from base) passes passes
  • The move is a pure move: ConfigsSuite (265 tests) and SyncSuite (89 tests) pass unchanged. One assertion was added: TestNessyBesideASandboxIsRefusedOnlyWhenItReachesTheNetwork now checks that a sandbox refusal offers no require_approval hint. The mutant that always adds the hint survived without it.
  • I ran 30 mutants over every guard in the diff (the moved rule, GraphComplaint, and the childRunner.Run call and its sibling loop). All 30 fail a test. Two are not tested: a store read error and a definitions read error, because no test may inject a Postgres failure on shared tables.
  • go vet passes with and without -tags integration, and gofmt is clean. The suites ran on a rebase onto main 0e5197a, which includes [AI-3749] A child agent keeps its parent's thread #2423 (AI-3749), the other change to child_agents.go.

🤖 Generated with Claude Code

kanat and others added 3 commits November 25, 2026 00:20
…ck it across child agents at delegation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… refusal names no tool to hold

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kanat kanat changed the title [AI-3809] Refuse a child-agent delegation that breaks the sensitive-connector rule [AI-3809] Sensitive-connector rule holds across child agents Nov 25, 2026

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[security R1] VERDICT: NO-GO (one Should fix, one Nit).

Checked and fine: the runtime check covers every way a session is opened, because every entry point goes through Manager.Create, which wires childAgents in one place. A grandchild is still refused before the check. A fork, a reopened chat and a scheduled turn are checked from the spec they run with. Implied connections only pick a connection for a binding that is already declared. No session field sets a sandbox. A child's held tools fail closed when nobody can approve them. The child that is checked is the same config value that runs.

A-D1 (check the parent from its running spec): I agree with the author. The dispatcher's tools are fixed when the session opens. Each call is checked again against the stored config, which can only narrow the tools, and require_approval is the union of both. So the spec is an upper bound on what the parent can do.

S1.1: one new input to the rule has no test that fails when it is removed.

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: NO-GO

Round-1 review of 4b15deb27 (main 0e5197a7a is its merge base). It is a draft, so CI's go and integration (router) jobs were skipped; they run at gh pr ready.

Ran on the head: ChildAgentsSuite 29/29, ConfigsSuite 265/265, SyncSuite 89/89, unit ./internal/connectors/... ./internal/session/, go vet with both tags, gofmt. All green.

Verdict: request changes, for R1.1. In the runtime graph, the parent's own sandbox is never tested: dropping its Provider or its Options passes every test.

Checked and sound:

  • The api side is a pure move. I compared the old SensitiveBindingsComplaint with ConfigComplaint + exposureOf line by line. The loop, the skip for a missing definition, the order of the outbound parts and the message text are the same. The only difference is that the sandbox part is now computed before the sensitive == nil return, which has no side effect.
  • The parent is read from the running spec, not reloaded from the store (A-D1), and this is the right choice. The spec is the upper bound of what the session can call. dispatcher.recheck refuses a binding or tool the current config dropped. A call is held when either the opened binding or the current one asks for approval (dispatcher.go:148). A binding added to the config mid-session is never opened. A fork rebinds to the config as it is now (api/sessions.go:171-176) and then runs that spec.
  • The star rule covers siblings, the refusal reaches the model as a tool error and the parent run continues, and require_approval exempts a tool exactly as in the single-config rule (one bindingSendsOut).
  • A graph with nothing sensitive in it runs as on base. The only change is on the error path: a failed read of a sibling or of a definition now fails the delegation.
  • No stale references to the old names are left in docs or skills.

kanat and others added 2 commits November 25, 2026 07:50
…tion tells the model no binding, connector or tool

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: GO

Delta round 2, reviewed 808ec69 merged onto main b86e02f (the base merge 6260bd6 had no conflicts).

Prior findings

  • R1.1 (the parent's own sandbox in the graph): fixed. With the new test TestADelegationIsRefusedWhenTheParentsSandboxReachesTheNetworkBesideASensitiveChild, the mutants that drop Provider: r.spec.Sandbox, drop Options: r.spec.SandboxOptions, or use Sandbox: store.AgentSandbox{} are all killed. The round-1 mutants that could not build on a full disk now run: parent bindings dropped, the call site checking the called child alone, and the parent name dropped are all killed. "Called child not pre-marked read" survives; it only adds a duplicate member of the same config, so it is equivalent.
  • S1.2 (refusal text names server-side config): fixed. The model and the tool_call frame get the fixed sentence, and refusedAll asserts that no binding, connector, tool or sandbox name appears. The complaint is only in the Warn log line at child_agents.go:137, and no other path carries it: sensitiveComplaint has one caller, and the router logger writes to stderr, not to a socket or stored item. Mutants that put the complaint back in the error, drop the log, or drop the complaint from the log are killed.
  • A-D1 (parent from the running spec): unchanged, still upheld.
  • R1.N1 and R1.Q stay as tickets; not part of this delta.

New findings

  • [Nit] child_agents.go:137: nothing pins the log level. Warn changed to Debug survives, because the test logger runs at Debug while the router default is Info, so the complaint would then be lost at the default level. Not blocking.

Checks on the merged tree: TestChildAgentsSuite, TestConfigsSuite and TestSyncSuite pass; ./internal/connectors/... and ./internal/session/ pass. CI is a draft here, so go and integration are skipped; the rest pass.

@kanat
kanat marked this pull request as ready for review November 25, 2026 14:08
@kanat
kanat merged commit adcd1d1 into main Nov 25, 2026
15 checks passed
@kanat
kanat deleted the kanat/ai-3809-sensitive-across-children branch November 25, 2026 15:06
kanat added a commit that referenced this pull request Nov 25, 2026
…69-http-connectors

Conflicts:
- internal/api/configs.go: main moved the sensitive-connector rule into
  internal/connectors/sensitive (#2432); the feature's digest-aware grant check
  (grantSendsOut, #2324) moves there as sensitive.GrantSendsOut, used by
  bindingSendsOut, so ConfigComplaint and GraphComplaint both judge an http tool
  at the digest its grant pins.
- internal/api/connection_tools.go: listConnectionTools calls
  sensitive.GrantSendsOut; comment names both.
- internal/connectors/core/manifest.go, .claude/skills/connectors/SKILL.md:
  comments/doc keep both sides.
- internal/store/datamove.go: applyChanges keeps the feature's importableRow
  pass before the transaction and main's lockNumbers / NumbersLeftOutError
  (#2412); ImportRow drops main's `var err error` that redeclared the feature's err.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat added a commit that referenced this pull request Nov 25, 2026
Piece 2/2 of [AI-3748](https://linear.app/stream/issue/AI-3748). Piece 1
was #2432 ([AI-3809](https://linear.app/stream/issue/AI-3809)). Ticket:
[AI-3810](https://linear.app/stream/issue/AI-3810).

## Why

The sensitive-connector rule says that a sensitive connector (one whose
tools read private data) and something that sends data out with no
person's approval cannot be in one agent config. #2432 extended the rule
to a parent plus its child agents, but checked it only when the parent
delegates at run time. Config writes still checked each config on its
own. So a create, update, patch or sync could store a parent and its
children that break the rule together, and the developer found out only
when a delegation was refused.

## How it works

```
create / update / patch / sync                configs.go, config_patch.go, sync.go
└─ childAgentsComplaint                        internal/api/child_agents.go
   ├─ existing checks (tools, one level deep, a child keeps its name and mode)
   ├─ parents = AgentConfigs.Calling(name)     every parent of the config, oldest first
   └─ sensitiveGraphComplaint
      ├─ the config has agents:  {config + each child as stored}
      ├─ for each parent:        {parent + each of its children}, with the
      │                          config as it is about to be stored, not its stored copy
      └─ sensitive.GraphComplaint fails on any set ─> 400 naming the agents,
                                                      bindings and connector
```

Every save runs the check, including one that changes only an unrelated
field. So a stored set that already breaks the rule refuses every save
of its members until it is fixed, the same way the single-config check
works. A save that removes the outbound binding is weighed without the
stored copy, so the fix goes through.

| Graph, written through each of create, update, patch, sync | Before |
After |
| --- | --- | --- |
| sensitive parent, a child that sends out | stored | 400 |
| parent that sends out, a sensitive child | stored | 400 |
| parent of a sensitive child and of a child that sends out | stored |
400 |
| a child gains an outbound tool under a sensitive parent | stored | 400
|
| the same, under the second of two parents (the newer one) | stored |
400 |
| a child gains an outbound tool beside a sensitive sibling | stored |
400 |
| a child gains a sensitive binding, the parent's sandbox reaches the
network | stored | 400 |
| a save of another field of a child in a set that already breaks the
rule | stored | 400 |
| a child gains agents of its own (grandchild) | 400 one level deep |
400 one level deep |
| sensitive + an outbound tool held by `require_approval` (both
directions) | stored | stored |
| a child removes its outbound tool under a sensitive parent (the fix) |
stored | stored |
| nothing sensitive (two rows) | stored | stored |
| a rename (update, patch) to the name a sensitive parent calls | stored
| 400 |

The refusal is `GraphComplaint`'s text, for example: `the agent
"<parent>"'s connector binding "<alias>" binds "<connector>", whose
tools read private data, and connector binding "<alias>" of the agent
"<child>" can send data out with no person's approval, and a parent and
its child agents pass on to each other what they read: take them out of
these agents`. When a `require_approval` could hold a tool, the
`require_approval` hint is added.

## Decisions

- A write checks every child a parent names. This is a little stricter
than the run-time check, which skips a child whose tool clashes with a
built-in tool. Accepted.
- A rename is checked by the new name, so a rename into a name some
parent calls gets the structural and graph checks as that parent's
child. This closes a gap beside the ticket's scope, and it stays in this
PR.
- The 400 names every config in the set. Config create, update, patch
and sync are server-side only (`withServerSide`, `server.go:1330`), so
the caller is a backend and is not limited by teams; no hidden config's
name reaches an end user.

## Changes

- `store.AgentConfigs.NameCalling` (one parent, `LIMIT 1`, no order) is
now `Calling`, which returns every live parent, oldest first. `parentOf`
(the delete 409 and the existing refusals) names the oldest one.
- `childAgentsComplaint` no longer returns early for a plain child save,
and it runs `sensitiveGraphComplaint` last. It also reads the parents by
the name the config is about to have, so a rename into a name some
parent calls is checked as that parent's child.
- The rule's text is updated in `connectors/providers/AGENTS.md` and
`connectors/sensitive/AGENTS.md`.

### Query

Every config save now runs one parents query. Before, only a save with
agents, a rename or a mode change ran it.

<table>
<tr><th>Before (<code>NameCalling</code>)</th><th>After
(<code>Calling</code>)</th></tr>
<tr><td>

```sql
SELECT name FROM agent_configs
WHERE customer_id = ? AND id <> ?
  AND agents @> ?::jsonb
  AND deleted_at IS NULL
LIMIT 1
```

</td><td>

```sql
SELECT * FROM agent_configs
WHERE customer_id = ? AND id <> ?
  AND agents @> ?::jsonb
  AND deleted_at IS NULL
ORDER BY created_at, id
```

</td></tr>
</table>

Both plans use the same path, a bitmap scan of `agent_configs_name_idx`
on `customer_id`. In the usual case no config calls the one being saved,
and then both queries read every live config of the app, because `LIMIT
1` stops early only when a row matches. I ran the plans on my local test
database, where the customer had 7 configs: before, 3 buffers and 0.11
ms; after, 3 buffers and 0.06 ms (the second ran on a warm cache). I did
not run them on production-sized data.

## Validation

- New tests, in `internal/api/child_agents_writes_test.go`:
- `TestAWriteIsHeldToTheSensitiveConnectorRuleOverTheAgentsItWorksWith`:
14 rows × 4 write paths, the table above.
  - `TestARenameIntoTheNameASensitiveParentCallsIsRefused`.
  - `TestAChildWithTwoParentsNamesTheOlderOne`.
- New test in `internal/store/agent_config_test.go`:
`TestCallingIsEveryLiveParentOfAChildOldestFirst`. It checks that the
excepted, deleted and other-customer configs are left out.
- On base 4a6dd11 the new table failed in 32 subtests, which are the 8
refusal rows on each path. The 20 rows that also pass on base still
passed: the grandchild refusal, the approval rows and the controls. The
rename test failed on base too. On head, all of them pass.
- 24 mutants, one script, all killed. The script covers every guard in
the diff, the `Calling` filters, order and limit, and one mutant per
write-path call site (create, update, patch, sync). Two error returns
are not tested: the store read failures in `Calling` and `GetByName`. No
test may inject a Postgres failure on shared tables.
- Suites, run on the branch merged with main 0430ce9:
`ChildAgentsSuite` (33 tests), `ConfigsSuite` (227) and `SyncSuite` (89)
all pass. In `StoreSuite`, 1587 tests pass.
`TestEveryHotTableIsReadByIndex` fails in 5 subtests (Requests,
Sandboxes, UserOrganizations, ExportCustomer). It fails in exactly the
same way on main 0430ce9 against the same database, and this PR does
not touch those tables. `go vet` passes with and without `-tags
integration`, and `gofmt` is clean.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant