Skip to content

[AI-3810] Config writes hold the sensitive rule across agents - #2473

Merged
kanat merged 7 commits into
mainfrom
kanat/ai-3810-sensitive-graph-writes
Nov 25, 2026
Merged

kanat merged 7 commits into
mainfrom
kanat/ai-3810-sensitive-graph-writes

Conversation

@kanat

@kanat kanat commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Piece 2/2 of AI-3748. Piece 1 was #2432 (AI-3809). Ticket: 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.

Before (NameCalling)After (Calling)
SELECT name FROM agent_configs
WHERE customer_id = ? AND id <> ?
  AND agents @> ?::jsonb
  AND deleted_at IS NULL
LIMIT 1
SELECT * FROM agent_configs
WHERE customer_id = ? AND id <> ?
  AND agents @> ?::jsonb
  AND deleted_at IS NULL
ORDER BY created_at, id

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

kanat and others added 4 commits November 25, 2026 10:13
…s and children (WIP)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ver parents and children

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ames the older one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kanat kanat changed the title [AI-3810] Config writes check child agents for sensitive connectors [AI-3810] Config writes hold the sensitive rule across agents Nov 25, 2026
@github-actions github-actions Bot added the docs label 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: GO

Reviewed the four config writes (create, update, patch, sync) that now run the sensitive-connector rule over a config's parents and children, and the new AgentConfigs.Calling query, merged onto current main.

check result
who can call the four writes are server-side only; a user's device, a guest and an anonymous caller get 403
tenancy Calling and the sibling reads are scoped to the caller's app; another app's parent of the same name is neither weighed nor named
400 text names only the app's own configs, bindings and connector ids; no store or internal error text reaches the caller
mutations 7 guards removed one at a time, all caught by tests

Author question on a team-limited caller: not reachable, since these writes refuse every client-side caller and a backend has no team gate.

One Nit inline. Other points went to the ticket.

@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

[main R1] Reviewed ddae318cf merged onto main 48e5f96a4. CI: draft, so go and integration are skipped; they run at gh pr ready.

Decided by R1.1 (Should fix, inline): the deleted-child branch of the graph check is not pinned by any test.

[Nit] R1.2 acceleration/internal/api/configs.go:197 (not in the diff). A create can use a name that is already taken, by a config that is a child of a sensitive parent. If that create also sends a binding with a tool that sends data out, base answers 409 name_taken. Head answers 400 with the graph message, which names the other config's parent. Shown by a scratch probe on base and head. main already orders the one-level-deep refusal before the name check in the same way. Fix: a ticket.

Author questions: (1) The team-limited caller is not reachable. The four writes are server-side only (withServerSide, server.go:1338). No finding. (2) A write is stricter than the run-time check for a child whose tool clashes with a built-in tool. This was accepted, and the PR body says so. No ticket.

Checked and sound:

  • Touched suites on the merged tree: ChildAgentsSuite, ConfigsSuite and SyncSuite, 446 pass. StoreSuite: TestCalling… and TestAgentConfigQueryBudgets pass. Only the known local TestEveryHotTableIsReadByIndex subtests fail, on tables this PR does not touch.
  • Hard rule. A scratch probe ran 4 more control rows on each of create, update, patch and sync. The rows: a parent sandbox that reaches the network beside a child that sends out, with nothing sensitive; a child's instructions save beside a sensitive parent and a sibling whose outbound tool needs approval; a sensitive child of two parents that have no tools; a sensitive parent with a read-only child. Each got the same 200 or 201 on base and head. The single-config check still runs before childAgentsComplaint on all four paths, and the diff leaves it as it was.
  • NameCalling has no other caller. parentOf now names the oldest parent. A delete of a child is still a 409. A delete of the parent of a set that breaks the rule is still a 204 (probe).
  • Query. Calling reads through agent_configs_customer_idx and then filters agents @> over the app's live configs. Neither base nor head has an index on the child name. EXPLAIN on a local test database took 0.33 ms for a 100-config app and 1.26 ms for a 3000-config app. It is one query per save, with no loop around it.
  • Mutations: 16 checked (8 mine, plus 8 of the author's rerun on the merged tree). 2 survived; both are under R1.1.

kanat and others added 3 commits November 25, 2026 11:06

@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 60d1300 (previous review ddae318). The base merge 04955ab is clean; the delta is two commits, a test row and one sentence.

Prior findings:

  • R1.1 (Should fix, test-only): fixed. The new row "a sensitive parent that names a gone child first" passes on create, update, patch and sync. Both mutants now fail on all four paths: continue -> break and continue -> return "", true, nil.
  • R1.3 (Question): fixed. The refusal now says to change the other agents first and save this one after. Probe: child first 400, parent drops nessy 200, child retry 200, so the advice holds. The runtime refusal in session/child_agents.go is unchanged.
  • R1.2 (Nit, configs.go:197, unchanged code): still open, ticketed per policy.
  • R1.3(b) concurrent writes (unchanged code): still open, ticketed as AI-3883.

New findings (Nit, not blocking):

  • child_agents.go:156 — the sentence is also appended when GraphComplaint returns an error (ok is false, message empty). Callers check err first, so nothing observable. Optional: return on err before the append.
  • child_agents.go:158 — "The other agents in these" reads loosely; "in this set" would be clearer. Optional.

Checks:

  • ChildAgentsSuite, ConfigsSuite, SyncSuite on the head merged onto origin/main 48e5f96: 450 PASS, 0 FAIL. go vet and gofmt clean.
  • Mutants: 3 checked (R1, R2, R9 sentence dropped), 0 survived.
  • CI: draft; go and integration skipping, labeler and GitGuardian pass. Not waited for.

Details: /Users/kanat/.claude/ship-task/Vision-Agents/AI-3748/AI-3810/reviewer-2.md

@kanat
kanat marked this pull request as ready for review November 25, 2026 16:21
@kanat
kanat merged commit c4119ba into main Nov 25, 2026
16 of 17 checks passed
@kanat
kanat deleted the kanat/ai-3810-sensitive-graph-writes branch November 25, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant