Skip to content

[AI-3675] HTTP connectors: call-time safety for http tools - #2324

Merged
kanat merged 17 commits into
feature/ai-3669-http-connectorsfrom
connectors/http-safety
Nov 24, 2026
Merged

kanat merged 17 commits into
feature/ai-3669-http-connectorsfrom
connectors/http-safety

Conversation

@kanat

@kanat kanat commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Leaf 3 of AI-3669 (router: run HTTP connectors). Targets feature/ai-3669-http-connectors, not main. No API change; that is leaf 4 (AI-3676).

Why

Values the model picks go into the URL and the body of an http tool's request (sources/http, #2316). Before leaf 4 lets anyone store an http connector, these cases must be impossible: a write through a read_only tool, a method override, a path that names another resource, a credential echoed into the conversation, and a write resent by a redirect. The checklist comes from the AI-3673 and AI-3674 reviews: Q1 stale pin, R1.6, S1.2, S1.3 and R2.1.

How it works

Toolset.Call(call)                                  sources/http/toolset.go
├─ an argument the tool does not declare  -> refused, nothing sent (AC-6)
├─ arguments vs input schema              -> refused, nothing sent
├─ path built segment by segment (builtPath)
│    a segment with a {name} that is "", "." or ".." -> refused (S1.3)
│    "../admin" -> "..%2Fadmin"   "..%2F" -> "..%252F"  (one segment)
├─ send through binding.HTTP (credential + egress)
│    redirect: GET/HEAD follow (same origin, egress policy)
│              POST/PUT/PATCH/DELETE -> the 3xx is the answer (R1.6)
├─ write's 301/302/303 -> result "The API answered 303 See Other; the request may have run."
├─ non-2xx -> ToolError "The API answered <status>: <body>"
│            body -> Exchange.Redact (credential, path, query) -> cut 32 KiB
└─ 2xx     -> body -> Exchange.RedactCredential (credential values only) -> cut 32 KiB
   <status> = code + http.StatusText, never the API's reason phrase

Source.Open                                         sources/http/source.go
└─ core.CheckHTTPSource(rule): Validate's http rules again
     (override names, read_only only on GET/HEAD, a description, ...) -> error, nothing offered

Stale pin (AI-3674 Q1). A session opens an http tool only at the digest its grant pins, and the digest covers method, path and read_only. So internal/api now judges an http tool read-only only when the grant pins the latest revision's read-only digest (grantSendsOut):

revision 1: x = POST /x       revision 2: x = GET /x, read_only
fixed connection stays on revision 1, lists x at digest D1

                              before                after
GET .../connections/{id}/tools x read_only: true    false
config beside nessy, x@D1      201 (POST runs)      400 "api" x
config beside nessy, x by name 201                  400
config beside nessy, x@D2      201                  201 (rev 1 never opens D2)

An MCP tool stays judged on the latest revision's read_only_tools. TestReadOnlyIsTheConnectorsLatestRevisionsAsAConfigSaveChecks pins that, and it is unchanged.

Changes

  • sources/http: refuse undeclared arguments; judge the built path; follow redirects only for GET and HEAD (with net/http's limit of 10 when a client has no policy); redact tool errors with the call's Exchange (core.Observed: the dispatcher's, or one of the call's own); recheck the source at Open.
  • core: CheckHTTPSource (the http rules of Validate, exported for Open) and Observed.
  • core: Exchange.RedactCredential, the credential's secret values alone, for a 2xx answer. A scheme whose secret also holds a name says which strings are values (core.SecretValuer; api_key: the key, not its header name). Redaction takes the longest string out first, so a key that holds its header name goes out whole.
  • core: an http tool with no description is refused by Validate and at Open: a session refuses such a tool (harness.Tools.Validate), so the sync says so first.
  • api: grantSendsOut in bindingSendsOut (config check) and in listConnectionTools (the same class).
  • fakeprovider: an HTTP API at /rest (api_key header, /bytes/<n>?then=<m>, /echo-credential with ?status=200, request log), for AC-6 and AC-9.
  • Docs: sources/http/AGENTS.md, core/AGENTS.md, fakeprovider/AGENTS.md, .claude/skills/connectors/SKILL.md.

Decisions:

Case Decision Reason
empty path value (DELETE /items/) refused it names the collection
{a}{b} = . + . refused it is judged as built, so it is ..
../admin sent as ..%2Fadmin AC-6 of AI-3669
..%2F sent as ..%252F the % is escaped, so it is no dot segment
307/308 on a POST, PUT or PATCH not followed, the 3xx is the answer net/http would resend the body to a path the manifest does not name
3xx on a DELETE not followed a write's path is the manifest's
301/302/303 on a POST, PUT, PATCH or DELETE a result: "The API answered ; the request may have run." only a 307 or 308 asks for the request again; after the others the write may have run, so the model must not read a failure and retry (R1.2)
status the model reads code + http.StatusText the API's reason phrase is its own text and may echo the credential (S1.1)
http tool with no description refused at validation a session refuses it anyway (Q0.3)
GET/HEAD redirect followed, same origin only the egress policy, unchanged
2xx body the credential's secret values redacted; path, query and api_key's header name kept an API that echoes the key in a 200 must not put it in the conversation; an answer names its resource by its path (Q1) and may name its own header (R1.1)
/ in a path value (../admin) stays escaped as one segment (..%2Fadmin) AC-6 of AI-3669; an API that decodes %2F before routing is out of the router's control, and the docs leaf says so (Q2)
stale pin an http tool reads only when the grant pins the latest revision's read-only digest side effect, accepted as fail-closed: an http read-only tool granted by name beside a sensitive connector is refused; the docs leaf says so (Q3)

Validation

Rule Test Mutations killed
undeclared argument refused TestSourceSuite/TestAnArgumentTheToolDoesNotDeclareIsRefusedBeforeSending (7 shapes x GET/POST), TestAcceptanceSuite/TestAnOverrideIsRefusedBeforeSendingAndAValidCallIsOneGET (AC-6) T1, T2
built path TestSourceSuite/TestAPathValueThatNamesAnotherResourceIsRefusedBeforeSending (18 rows) T3, T6-T12
Open recheck TestSourceSuite/TestOpenRefusesASourceThatBreaksARuleOfValidation S1, C1
redirects TestSourceSuite/TestOnlyAReadFollowsARedirect (a write's 301/302/303 is a result, a read's 302 with no Location stays an error), TestARedirectToAnotherOriginNeverCarriesTheCredential, TestAClientWithNoRedirectPolicyStopsAfterTenRedirects S2-S9; R1.2: rule off, rule for reads too, 307 added, 302 dropped
status text TestSourceSuite/TestAnEmpty2xxIsItsStatus (reason phrase echoing the token), TestAnAnswerThatIsNotA2xxIsAToolErrorNamingItsStatus (own phrase, unknown code) each response.Status put back
description required TestHTTPSourceSuite/TestAnHTTPSourceBreakingARuleIsRefused row "no description" check off
key holding its header name TestLoggedDescriptionSuite/TestASecretHoldingAnotherIsTakenOutWhole sort removed
header name kept in a 2xx TestAcceptanceSuite/TestA2xxKeepsTheKeysHeaderName (a 403 still redacts it) transport back to every string, api_key values with the header, api_key values nil, SecretValuer ignored
redaction TestSourceSuite/TestAToolErrorEchoingTheCredentialIsRedacted (also a token the 32 KiB cut falls in), TestAToolErrorIsRedactedWithNoExchangeOfTheCallers, TestAcceptanceSuite/TestA403EchoingTheKeyIsRedacted T4, T5, C2, C3
logs TestAcceptanceSuite/TestALogLineHoldsNoArgumentAndNoCredential (KeepHosts is the base's)
AC-9 TestAcceptanceSuite/TestAnAnswerIsReadUpTo4MiBAndReadAsAtMost32KiB F5
stale pin TestConfigsSuite/TestAnHTTPToolReadsOnlyAtTheDigestItsGrantPins. It fails with grantSendsOut reverted: listing true, config 201 A1-A7
stale pin, in a session TestSessionConnectorsSuite/TestAStalePinNeverRunsAWriteAsARead: a fixed connection on revision 1 (echo POST); beside nessy, echo at revision 1's digest is refused, at revision 2's (read-only GET) accepted and the session leaves crm out, nothing reaches the API; without nessy the session runs the POST grantSendsOut reverted (config 201), Source.Open digest pin reverted (crm offered)
2xx redaction TestSourceSuite/TestA2xxEchoingTheCredentialIsRedactedAndKeepsItsPath (bearer, Authorization), TestAcceptanceSuite/TestA200EchoingTheKeyIsRedacted (api_key header) no RedactCredential, Redact in its place (path lost), identity redaction, no secret
R2.1 TestLoggedMessageSuite/TestAnUnreachedErrorWithNoCauseIsItsMessage C4
fake API TestFakeProviderSuite/TestTheHTTPAPITakesItsKeyRecordsEachRequestAndAnswersByPath F1-F6

The mutation script applies, tests and restores each of 38 mutants. All 38 were killed. The author's notes keep the list.

Round 1 fixes (Q0.3, S1.1, S1.2, R1.1, R1.2) ran: go vet with and without the integration tag; unit ./internal/connectors/... ./internal/api ./internal/session ./internal/store ./internal/harness ./cmd/router; -race on sources/http, core, schemes; integration TestConfigsSuite|TestConnectionToolsSuite|TestSessionConnectorsSuite|TestSessionToolsSuite in ./internal/api (455 passed) and TestDataMoveSuite in ./internal/store.

The author ran:

  • go test ./internal/connectors/... ./cmd/router ./internal/api ./internal/session (unit)
  • go test -race ./internal/connectors/sources/http ./internal/connectors/fakeprovider
  • go test -tags integration -run 'TestConfigsSuite|TestConnectionToolsSuite|TestSyncSuite|TestSessionConnectorsSuite|TestSessionToolsSuite' ./internal/api on its own database (539 tests)
  • go vet with and without the integration tag

All passed. The full integration run is not done.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the docs label Nov 24, 2026
kanat and others added 3 commits November 24, 2026 01:50
An API that echoes the key or token in a 200 put it in the conversation.
Exchange.RedactCredential takes out the credential's strings and keeps the
path and query, which an answer names its resource by.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Revision 1 makes echo a POST, revision 2 a read-only GET, and a fixed
connection stays on revision 1. Beside nessy a grant at revision 1's digest
is refused; one at revision 2's is accepted and its session leaves crm out,
so nothing reaches the API. Without nessy the session runs revision 1's POST.

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

kanat commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-review fixes, head a1792f5:

  • Q0.1, the credential in a 2xx answer: fixed in 5e49b9b. A 2xx result now goes through core.Exchange.RedactCredential. It removes the connection's credential strings (bearer token, api_key header and key). It keeps the path and query. Tests: TestSourceSuite/TestA2xxEchoingTheCredentialIsRedactedAndKeepsItsPath (bearer, Authorization) and TestAcceptanceSuite/TestA200EchoingTheKeyIsRedacted (api_key header, fake /rest/echo-credential?status=200). Each of these mutations fails a test: no redaction, Redact in its place (the path is lost), an identity redaction, an empty secret.
  • Q0.2, the stale pin in a session: covered in a1792f5 by TestSessionConnectorsSuite/TestAStalePinNeverRunsAWriteAsARead. A fixed connection stays on revision 1, where echo is a POST. Revision 2 makes echo a read-only GET. Beside nessy, a grant at revision 1's digest is refused (400 "crm" echo). A grant at revision 2's digest is accepted, the session leaves crm out (tool_unavailable), and nothing reaches the API. In the control without nessy, the session runs revision 1's POST. Reverting grantSendsOut fails the test (config 201). Reverting the Source.Open digest pin also fails it (crm is offered).

The PR body now has the decisions on Q1-Q3.

@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

[security R1] head a1792f5 on feature/ai-3669-http-connectors (base unchanged).

Checked with attack tests at this head: undeclared arguments, ./../empty segments on the built path (including two placeholders in one segment and encoded forms), override names at Open, redirects for every method (same and other origin), credential redaction in non-2xx and 2xx answers, log lines, the nil-Err guard, the stale pin (config save and session), and leaf 2's earlier probes. All hold except the two gaps below. 16 mutants of the new guards, all killed.

  • [Should fix] S1.1 sources/http/toolset.go:163: the empty-2xx sentence quotes the status line's reason phrase, which is server text and skips the new credential redaction (inline).
  • [Should fix] S1.2 core/error_body.go:139/:151: the order credential strings are taken out in follows map order, so a secret string that contains another one comes out in pieces, and the rest stays in the text (inline).
  • [Nit] S1.3 core/error_body.go:156: a one-byte credential is never redacted, and api_key and bearer accept one. Ticket: set a minimum length when the key or token is supplied.
  • [Question] S1.4: when an API echoes one argument value in a 4xx, that value stays in the invocation row's error_message and the log line's provider_body. Only the whole path and the whole query are redacted. This is existing behaviour for every source. The orchestrator decides whether to accept it or to redact declared argument values from the stored body.

Each fix comes with a ready test row for SourceSuite, given to the fixer.

// An empty answer, such as a 204's or any HEAD's, is its status, so the model can tell a
// call that was done from one that said nothing.
if len(body) == 0 {
return core.Result{Parts: llm.TextParts(fmt.Sprintf("The API answered %s.", response.Status))}, nil

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.

[Should fix] S1.1 response.Status holds the server's reason phrase, and this 2xx sentence goes to the model without the credential redaction the other answers get. Fix: build the status from response.StatusCode and http.StatusText (here and at :152), or pass it through exchange.RedactCredential. Test row: an empty 2xx whose status line repeats the request's credential must not show it.

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.

Fixed in 0333fb1: the model reads StatusCode + http.StatusText (toolset.go status), here and in the non-2xx message. Tests: TestSourceSuite/TestAnEmpty2xxIsItsStatus (202 whose reason phrase echoes the token) and TestAnAnswerThatIsNotA2xxIsAToolErrorNamingItsStatus (own phrase, unknown 499). Putting response.Status back at either site fails its test.


// secretStrings is each string in the credential's secret (AccessCredential.Secret): bearer's
// token, api_key's header and key.
func secretStrings(credential AccessCredential) []string {

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.

[Should fix] S1.2 appendStrings ranges over a map, and redactionFrom keeps that order. So when one secret string contains another (an api_key whose key contains its header name), the shorter one can go first and split the longer one, and the rest of the key stays in the text. This happens to 2xx answers now and to the log redaction too. Fix: in redactionFrom, sort longest first with a stable sort before returning. Test row: a key that contains its header name, echoed in a 2xx and called 20 times, never shows any part of the key.

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.

Fixed in 7373407: redactionFrom sorts longest first (stable), so a string that holds another goes out whole. Test: TestLoggedDescriptionSuite/TestASecretHoldingAnotherIsTakenOutWhole (header X-Key, key X-Key-9f8e7d6c5b); with the sort removed it reads seen [redacted]-9f8e7d6c5b. The security probe rows pass on b99ddc9.

@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

Reviewed a1792f56c on the base feature/ai-3669-http-connectors at ba3949a31. The base has not moved, so the merge is a no-op. CI: go and integration are skipped on the draft; they run at gh pr ready.

The one finding that blocks the merge is the orchestrator's open Should fix Q0.3. I confirmed it. This round adds no Blocker and no Should fix.

[Should fix] Q0.3 acceleration/internal/connectors/core/http_tools.go:150: checkHTTPSource checks only that a description is not too long. An http tool with no description passes it. A probe of httpManifest(HTTPTool{Name: "echo", Method: GET, Path: "/echo"}) gives Validate() = nil and CheckHTTPSource = nil. A session with that tool is then refused at create by internal/harness/tools.go:266 ("tool ... has no description"). Fix: refuse an empty description in checkHTTPSource, so both Validate and Source.Open refuse it. Add a table row and a mutation. Open now runs CheckHTTPSource, so every test tool with no Description will fail at Open and needs one: acceptance_test.go (get_item, get_bytes, get, lookup), the rows of source_test.go, and x and y in TestAnHTTPToolReadsOnlyAtTheDigestItsGrantPins. Recompute those digests after the change.

Checked and sound:

  • MCP is unchanged. grantSendsOut only leaves the base SendsOutTool for a manifest that has http_tools. No built-in provider has one. A mutant that judges MCP by-name grants differently fails 30 MCP tests, TestReadOnlyIsTheConnectorsLatestRevisionsAsAConfigSaveChecks among them.
  • AC-6 and AC-9 hold as the epic words them, against the fake provider.
  • A tool_patterns binding on an http connector cannot use a stale pin. SourceRule.SendsOut is always true for an http source, so beside nessy the binding always needs require_approval.
  • Redaction covers the escaped forms. It catches the raw, URL-escaped and JSON-escaped forms, the PHP \/ form included. A 1-byte key is not redacted, so a key of "a" cannot wipe out the body.
  • Tests: unit, -race and the touched integration suites (455 tests) pass, and generated.sh is clean. 12 reviewer mutants: 11 killed, and 1 equivalent (a nil redactCredential happens only when no request left).

The Nit and the Question below go to tickets, not to this PR.

var redact, secret redaction
if exchange != nil {
redact = redactionOf(request, credential)
secret = redactionFrom(secretStrings(credential))

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.

[Nit] R1.1 RedactCredential takes every string of the secret out of a 2xx result. That includes the api_key header name, and any value of 2 bytes or more, wherever it appears. A probe with header Key and the answer {"Key":"public-id"} returns {"[redacted]":"public-id"}. A probe with key 12 and the answer {"count":12,"id":"a12b"} returns {"count":[redacted],"id":"a[redacted]b"}. The Q1 decision named only the credential's values. Fix (ticket): redact the secret's values without the api_key header name, and consider a minimum length for a 2xx.

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.

Fixed in 424b512: RedactCredential takes out secret values only. A scheme whose secret also holds a name implements core.SecretValuer; api_key returns its key alone. Redact (errors, logs) still takes out every string. Test: TestAcceptanceSuite/TestA2xxKeepsTheKeysHeaderName (2xx keeps X-Api-Key, a 403 still redacts it). Four mutants killed: transport back to every string, api_key values with the header, values nil, SecretValuer ignored. The 2-byte rule is unchanged; the 1-byte case is AI-3706.

}
policy := client.CheckRedirect
copied.CheckRedirect = func(request *http.Request, via []*http.Request) error {
if !slices.Contains(redirectMethods, via[0].Method) {

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.

[Question] R1.2 Not following 307 and 308 for a write is right. A 301, 302 or 303 to a write is different: the server has already run the write. The model still reads it as a tool error, "The API answered 303 See Other" (the POST /moved-303 row of TestOnlyAReadFollowsARedirect), so it may call the write again. Should a 3xx answer to a write be a result that names the status? Ticket, for the orchestrator or Kanat to decide.

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.

Fixed in 7864639 and b99ddc9 (ruling: return a result). A POST/PUT/PATCH/DELETE answered 301/302/303 is now a result: "The API answered 303 See Other; the request may have run." 307/308 stay tool errors, and GET/HEAD keep following. Test: TestSourceSuite/TestOnlyAReadFollowsARedirect, with rows for each write method and a GET 302 with no Location, which stays an error. Killed: rule off, rule applied to reads, 307 added, 302 dropped.

kanat and others added 6 commits November 24, 2026 02:31
…0.3)

A session refuses a tool with no description (harness.Tools.Validate), so an
http connector's sync now says so instead. Every test tool gains a description.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on phrase (S1.1)

An API's reason phrase is its own text and may echo the credential; an empty
2xx was read with it unredacted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
redactionFrom takes the longest string out first, so api_key's key holding its
header name no longer comes out in pieces in map order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(R1.1)

RedactCredential takes out a credential's secret values: a scheme whose secret
also holds a name says which strings are values (core.SecretValuer). Redact,
for errors and logs, still takes out every string of the secret.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ave run (R1.2)

Only a 307 or a 308 asks for the request again; after the others the write may
have run, so the model no longer reads a tool error it might retry.

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

kanat commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Q0.3 fixed in 7c3f328: checkHTTPSource refuses an http tool with no description (http_tools[i].description: is empty), so Manifest.Validate and Source.Open both refuse it, not session create (harness.Tools.Validate). Test: the no description row of TestHTTPSourceSuite/TestAnHTTPSourceBreakingARuleIsRefused, which fails with the check off. Every test tool now has a description; the configs test computes its digests from the tools.

@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

Delta review of round 1 (a1792f5 -> b99ddc9, base ba3949a, no merge needed). One Should fix is open; everything else is fixed.

Prior findings

  • Q0.3 fixed: an http tool with no description is refused at Validate and at Open. Mutant if false && killed (TestHTTPSourceSuite row "no description"). The digests in TestAnHTTPToolReadsOnlyAtTheDigestItsGrantPins come from ToolSchemaDigest, not literals.
  • S1.1 fixed: both status sites (non-2xx error, empty 2xx) use code + http.StatusText; mutants at each site and the TrimSpace one are killed. The security probe rows pass.
  • S1.2 fixed: longest first. A no-op comparator and a reversed one are both killed by TestASecretHoldingAnotherIsTakenOutWhole.
  • R1.1 fixed: only apikey implements SecretValuer; bearer, oauth2_code, oauth2_client_credentials and none still take every string of the secret out of a 2xx (bearer echo in plain, JSON and url forms re-probed). RedactCredential has one caller (sources/http toolset.go); MCP uses Redact, which still takes every string. The scheme comes from the schemes map, never wrapped. Probes P1-P4: header name Key and X-Api-Key kept, a 2-byte key redacted, a 1-byte key left (S1.3, AI-3706). The nil branch is equivalent: Wrap refuses an unreadable credential, so no request leaves; replacing the readable-key return with nil is killed.
  • R1.2 fixed as ruled: off, reads-too, +307, -301, -302, -303 and "as a ToolError" mutants all killed. The session never retries; a write 3xx now returns as a call that answered.
  • S1.3 is AI-3706, S1.4 accepted.

New findings

  • [Should fix] N2.1 source_test.go:289 — the new 301/302/303 result sentence is built from status(response), but the mutant that builds it from response.Status survives: with a server answering a write HTTP/1.1 303 seen <Authorization> the model would read "The API answered 303 seen Bearer token-1; the request may have run." (checked in a scratch copy: head gives "303 See Other", the mutant fails NotContains token-1). That is S1.1's class on the new path. Fix: provider case /moved-reason -> answerWithReason(w, "303 seen "+r.Header.Get("Authorization")) and a row in TestOnlyAReadFollowsARedirect: {http.MethodPost, "/moved-reason", "", "The API answered 303 See Other; the request may have run."}.
  • [Nit] N2.2 dispatcher.go record — a write answered 3xx is now a success row (no error_type, no provider_status), where it was external_server with status 303. A 2xx row is the same, so it is consistent; accept or ticket, no change needed here.

Runs on b99ddc9 (DB model_router_test_ai3675d_test): vet and vet -tags integration clean; unit connectors/..., session, harness, store ok; -race core, sources/http, schemes ok; integration -p 1 Configs|ConnectionTools|SessionConnectors|SessionTools 470 PASS 0 FAIL; TestDataMoveSuite ok. 21 mutants run, 1 survived (N2.1). CI: draft, only labeler ran (pass).

{http.MethodPut, "/moved-307", "The API answered 307 Temporary Redirect", ""},
{http.MethodPatch, "/moved-308", "The API answered 308 Permanent Redirect", ""},
{http.MethodDelete, "/moved-307", "The API answered 307 Temporary Redirect", ""},
{http.MethodPost, "/moved-303", "", "The API answered 303 See Other; the request may have run."},

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.

Should fix (N2.1): the POST/PUT/PATCH/DELETE 301/302/303 rows here do not pin that the result is built from status(response). Mutant: toolset.go result built from response.Status survives. Add provider case case "/moved-reason": answerWithReason(w, "303 seen "+r.Header.Get("Authorization")) (near the /moved-nowhere case) and the row {http.MethodPost, "/moved-reason", "", "The API answered 303 See Other; the request may have run."}. Checked in scratch: passes on head, fails under the mutant ("303 seen Bearer token-1; the request may have run.").

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.

Fixed in 8321b3a: TestSourceSuite/TestOnlyAReadFollowsARedirect row POST /moved-reason (provider answers reason phrase "303 seen "). Mutation: building the 3xx sentence from response.Status fails the row (actual "The API answered 303 seen Bearer token-1; ..."); restored it passes.

…hrase (R2.1)

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 review of round 2 (b99ddc9 -> 8321b3a, base ba3949a unchanged, no merge needed). The delta is one test file (source_test.go, +3 lines).

Prior findings

  • N2.1 fixed: the row POST /moved-reason pins the 3xx write sentence to net/http's status text. Mutant: toolset.go:156 built from response.Status fails TestSourceSuite/TestOnlyAReadFollowsARedirect (actual "The API answered 303 seen Bearer token-1; the request may have run."); restored, it passes.
  • N2.2 (Nit): accepted by the orchestrator, unchanged.
  • Earlier findings (Q0.1-Q0.3, S1.1-S1.2, R1.1-R1.2): not touched by this delta; round-2 evidence stands.
  • S1.3 is ticketed (AI-3706); S1.4 accepted.

Checks on the head

  • go test ./internal/connectors/sources/http/ -run TestSourceSuite: pass.
  • go test ./internal/connectors/...: all packages pass.
  • go vet ./internal/connectors/...: clean.
  • CI: go and integration are skipped on the draft; labeler and GitGuardian pass.

New findings: none. Mutations: 1 checked, 0 survived.

Details: /Users/kanat/.claude/features/Vision-Agents/AI-3669/AI-3675/reviewer-3.md

@kanat
kanat marked this pull request as ready for review November 24, 2026 07:50
@kanat
kanat merged commit 5a798ad into feature/ai-3669-http-connectors Nov 24, 2026
11 checks passed
@kanat
kanat deleted the connectors/http-safety branch November 24, 2026 07:50
kanat added a commit that referenced this pull request Nov 25, 2026
Targets the feature branch `feature/ai-3669-http-connectors`, not
`main`. Leaf 4 of 4 in the router for AI-3669 (the keystone): until it
merges, no API stores an http connector.

## Why

The CLI writes `connectors/http/<name>.yaml` (base_url + tools), and the
router can run such tools since leaves 1-3 (#2316 manifest, #2324
call-time safety). `POST /v1/agents/connectors` took only an MCP
`endpoint`, and AI-3674 made `POST /v1/data/import` refuse an http
connector until this leaf. The AI-3674 reviews asked for two things:
`base_url` is checked with `egress.ValidatePublicHTTPSURL` on create and
on every new revision (S1.5), and import and create open at the same
time with the same checks (R1.1).

## How it works

```
POST /v1/agents/connectors  (CustomConnectorRequest)
├─ endpoint set == http set (both, or neither) -> 400 "exactly one of them"
├─ scheme not on this deployment              -> 400 (as before)
├─ http set
│  ├─ core.CheckBaseURL(base_url) fails: over 2048, not https://,
│  │  a {name}, or egress.ValidatePublicHTTPSURL refuses
│  │     -> 400 "base_url must be a public https URL
│  │             without userinfo, query or fragment"   (AC-7, one answer)
│  ├─ core.CustomManifest(base_url, tools) refuses
│  │     -> 400 core's reason, naming the tool          (AC-5)
│  └─ ok -> store revision (the same path as MCP)
└─ endpoint set: exactly as before                     (control test)

POST /v1/data/import  (importableDefinition)
├─ http source -> core.CheckBaseURL before AsCustom, the same message
│                 (AI-3674's refusal is gone)
└─ a change set: every definition checked before applyChanges'
   transaction opens, so no DNS lookup runs inside it

GET /v1/agents/connectors[/{id}]  (connectorOf, unchanged)
└─ copies fields by name: no base_url, no tools          (AC-1)
```

The request shape:

```
CustomConnectorRequest
├─ endpoint   string, now optional      MCP server
└─ http       CustomHTTPAPI, new        HTTP API
   ├─ base_url   string <= 2048
   └─ tools[]    CustomHTTPTool, 1 to 128
      ├─ name ^[A-Za-z0-9_-]{1,63}$, description <= 1000, path <= 2048
      ├─ method      GET|HEAD|POST|PUT|PATCH|DELETE
      ├─ read_only   only with GET or HEAD
      └─ parameters  {name: CustomHTTPParameter}, up to 64
                       type  string|number|integer|boolean
                       description <= 1000, required
```

The base_url is checked before the manifest's rules, so `http://...`, a
`{name}` in it or one over 2048 gets the fixed message too (core would
answer it in its own words), on create and on import alike. The schema
carries core's caps and tool name pattern, and core holds them as well
(a parameter's description and the base_url included), so an import,
which has no request schema, stores nothing the API would refuse.
Egress's own error never reaches the caller on create or import: it
tells a name that does not resolve from a private one.

## Changes

- `internal/api/connectors.go`: `http` beside `endpoint` on
`CustomConnectorRequest` (new `CustomHTTPAPI`, `CustomHTTPTool`,
`CustomHTTPParameter`, each refusing unknown fields); `customManifest`
checks exactly-one and the base_url, then builds through
`core.CustomManifest`. `createConnector` is untouched, so #2302
(`ReviseSynced`) merges beside it.
- `internal/connectors/core`: `CheckBaseURL`, the one base_url check
create and import share; `Manifest.Validate` caps a parameter's
description (1000) and the http endpoint (2048).
- `internal/store/datamove.go`: `importableDefinition` takes `ctx` and
checks an http connector's base_url in place of AI-3674's refusal;
`importableRow` checks a definition before `importRow`, and
`applyChanges` runs it for the whole change set before its transaction.
- The new enums name their constants (`x-enum-varnames`), so the Go SDK
keeps `Array`, `Boolean`, `Null`, `Number`, `Object` and `String`;
`sdks/go/acceleration/enums_test.go` pins them.
- `api/openapi.yaml` and the Go, JS, Python, .NET, Ruby, Rust and PHP
clients regenerated; Kotlin, Swift and Dart generate nothing new
(`createConnector` is not client-accessible).
- SDK note `.claude/skills/sdk/notes/2026-11-24-ai-3676.md`;
`connectors` and `add-connector` skills name `http`;
`sources/http/AGENTS.md` says who stores an http connector now.

## Validation

| Rule | Test |
| --- | --- |
| AC-1: stored at revision 1 as the source's manifest; no answer shows
base_url or tools |
`ConnectorsSuite/TestACustomHTTPConnectorIsStoredAndItsAPIIsNeverShown`
|
| AC-2: a none connection validates connected; tools list says read_only
| `ConnectorsSuite/TestAConnectionToAnHTTPConnectorListsItsReadOnlyTool`
|
| AC-5: read_only POST / DELETE -> 400 naming the tool, nothing stored |
`ConnectorsSuite/TestAReadOnlyToolThatWritesIsRefusedNamingIt` |
| AC-7 + S1.5: 127.0.0.1, 10.0.0.1, 169.254.169.254, http://, ::1,
.invalid, query, userinfo, fragment -> one message, nothing stored |
`ConnectorsSuite/TestAnHTTPConnectorWhoseAPIIsNotPublicHTTPSIsRefused` |
| A new revision is checked again; a refused one leaves revision 1 |
`ConnectorsSuite/TestANewRevisionOfAnHTTPConnectorIsCheckedAgain` |
| Both / neither / empty endpoint -> 400 |
`ConnectorsSuite/TestAConnectorWithBothOrNeitherOfEndpointAndHTTPIsRefused`
|
| Schema edges (method/type enums, lowercase method, unknown fields,
base_url > 2048, null tools, no base_url, no type, no tool, 129 tools,
bad name, description / path / parameter description over cap, 65
parameters) -> `validation_failed` |
`ConnectorsSuite/TestAnHTTPToolTheSchemaRefusesIsAValidationFailure` |
| Core's reasons through the API (oauth2_code, `_method`) |
`ConnectorsSuite/TestAnHTTPConnectorTheManifestRefusesIsRefusedWithItsReason`
|
| Control: MCP create and its refusals answer as on 5a798ad (keys,
values, messages from a probe run there) |
`ConnectorsSuite/TestAnMCPConnectorIsAnsweredAsBefore` (passes on base
and head) |
| Core caps: a parameter description over 1000, a base_url over 2048 |
`HTTPSourceSuite/TestAnHTTPSourceBreakingARuleIsRefused`,
`ImportableDefinitionSuite/TestAnOversizedHTTPConnectorIsRefused` |
| A change set's definitions are checked before its transaction opens |
`store
DataMoveSuite/TestAChangesDefinitionsAreCheckedBeforeItsTransactionOpens`
|
| Go SDK constant names kept | `sdks/go/acceleration`
`TestInvocationArgumentTypeKeepsItsConstantNames`,
`TestCustomHTTPToolMethodNamesItsConstants` |
| Import: http kept, MCP kept; private / .invalid / http:// / {name}
base_url refused with the fixed message | `ImportableDefinitionSuite`,
`store DataMoveSuite/TestAnImportedHTTP*`, `api
DataMoveSuite/TestAnImportedHTTPConnectorIsCheckedAsTheAPIChecksIt` |

The AC tests fail on the base (run there with this branch's test file),
except the schema test, which the base also passes by refusing `http` as
an unknown field. Each changed condition, field copy and schema tag was
mutated; the list is in the author log.

## Open points

- An imported MCP definition's endpoint gets no public-address check (as
on the base); the MCP source's egress client still checks each address
it dials.
- Breaking for SDK callers (CHANGELOG Breaking Changes): Go
`CustomConnectorRequest.Endpoint` is `*string`, Rust's `endpoint` is
`Option<String>`, and PHP's and Python's constructors take `endpoint`
after `schemes`.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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 26, 2026
Feature branch for [AI-3669](https://linear.app/stream/issue/AI-3669):
the router gets an `http` tool source. A file
`connectors/http/<name>.yaml` names a public https base URL and
read-only tools. Once synced, an agent calls those tools with a user's
credential.

## What it does

```
connectors/http/<name>.yaml
  │  CLI sync
  v
POST /v1/agents/connectors   (http block)
  │
  v
manifest, sources/http
  │  agent session offers the tool
  v
session tool call -> base_url + path, with the connection's credential
```

Safety rules. Each is checked when the connector is saved, at each call,
or both:

| Rule | Effect | Checked |
|---|---|---|
| Public https only | `base_url` goes through the egress check; private
and plain-http hosts are refused | save (`CheckBaseURL`), and every
call, as the connection's client is the egress client |
| `read_only` GET and HEAD | other methods are refused on `read_only`
tools | save. A tool whose definition changed since its grant is not
offered (the grant pins a digest of method, path and `read_only`) |
| Override args refused | the model cannot change the method, host or
headers | save refuses a parameter or header named like a method
override; a call refuses an argument the tool does not declare, before
anything is sent |
| Path segments escaped | `..%2Fadmin` stays one segment | every call |
| Size caps | 4 MiB read from the provider, 32 KiB to the model (with a
marker) | every call |
| Egress limits | the same egress client and the same 4 MiB read cap as
the MCP source, and #2430's import limits | every call; import |

## Pieces

All merged into this branch, each reviewed on its own PR. Three commits
on the branch itself follow the last main sync: the feature's caps
become core's after #2430, a subtest split of #2480's test, and a test
that an http custom connector meets an MCP one's limits.

| Piece | Ticket | PR | Merge commit |
|---|---|---|---|
| Manifest model for http tools | AI-3673 |
[#2303](#2303) | 7d1d6b7 |
| `sources/http` tool source | AI-3674 |
[#2316](#2316) | 2a29dac |
| Call-time safety | AI-3675 |
[#2324](#2324) | 5a798ad |
| API accepts http connectors (keystone) | AI-3676 |
[#2344](#2344) | aed810a |
| A connector's answer names its source kind | AI-3871 |
[#2464](#2464) | c72f50f |
| Pin delegation's digest check; own SDK note | AI-3870 |
[#2480](#2480) | 73e80f2 |
| Fake provider's CodeQL alert; SDK skill names http connectors |
AI-3870 | [#2483](#2483) |
469960b |

Main was merged into the branch 9 times; the last is main `f58ff6eb3`.
An earlier one, main `c4119ba23`, carries
[#2430](#2430 import limits.
Imported http connectors are held to the same limits.

The merge of main `8232d25af` brings in two changes that touch http
connectors:
- [#2485](#2485) refuses
imported agent configs that break the sensitive-connector rule. An http
connector's tools are weighed by their own rule: a tool that is not
read-only, or a read-only tool granted without its digest, is refused. A
test covers this
(`TestAnImportedHTTPConnectorAnAgentBindsBesideASensitiveOneIsWeighedByItsTools`).
- [#2434](#2434) adds
`check_changes` to a custom connector create. An http connector takes
the same path as an MCP one, and a test covers the http case
(`TestACheckedSyncOfAnHTTPConnectorIsRefusedOnlyOverAnEditNoSyncWrote`).

## Acceptance

AC-1..AC-9 are frozen in the epic. The staging window was opened twice
on the branch build, then staging was restored.

| AC | Result | Checked |
|---|---|---|
| AC-1 | pass | staging windows 1 and 2 (router part). The CLI line
(first sync prints the connector id) is in
[GetStream/cli#128](GetStream/cli#128) |
| AC-2 | pass | staging window 1 and 2 |
| AC-3 | pass | staging window 1 and 2: one tool call, the agent
answered from it |
| AC-4 | pass | staging window 1 and 2 |
| AC-5 | pass | staging window 1 and 2 |
| AC-6 | pass | local router: override args refused, the fake provider
saw 0 requests |
| AC-7 | pass | staging, by API and by CLI |
| AC-8 | pass | staging window 1 and 2: a JSON body comes back as
`application/json` |
| AC-9 | pass | local router: 100 KiB cut to 32768 B with a marker, 5
MiB cut at the 4 MiB read cap |

Rulings by Kanat (2026-11-25):

- AC-4: the "no token" clause is read as a wrong token. A wrong token
gives a tool error 401. A connection with no token at all stays
`not_connected` and its tool is not offered, as before.
- AC-5: the CLI refuses a `read_only` POST or DELETE locally, before any
request. The router refuses the same with a 400 on a direct POST.

## Gates for the merge into main

| Gate | What |
|---|---|
| a | Done: [#2481](#2481)
merged into main (`96d535d9d`), which fixed main's integration build at
`scheduled_unpaid_test.go:814`. This branch builds and vets with the
integration tag merged onto main `aa4c2d4d9` |
| b | Full CI green once this PR leaves draft (a draft runs none of the
go or integration jobs) |
| c | [GetStream/cli#128](GetStream/cli#128)
merges after this is deployed, then the docs leaf AI-3678 |
| d | SDK releases that carry `Connector.sources` go out only after the
router deploy: the generated Python and Rust clients cannot parse a
connector from an older router |
| e | No migration, no flag. A rollback to the previous build fails
closed: an http binding is unavailable, and every http tool counts as
sending out |

## Breaking change

From `CHANGELOG.md` on the branch, under Unreleased, Breaking Changes:
**`CustomConnectorRequest`'s endpoint is optional in the Go, Rust, PHP
and Python SDKs**

- Go: `CustomConnectorRequest.Endpoint` is now `*string`. Set it with a
pointer (for example `Endpoint: &url`); a caller that set a plain string
no longer compiles.
- Rust: `CustomConnectorRequest.endpoint` is now `Option<String>`. Set
it with `Some(url)`; a struct literal with a plain `String`, or a read
of one, no longer compiles.
- PHP: the `CustomConnectorRequest` constructor takes `$endpoint` after
`$schemes`, not first. A positional call no longer matches; named
arguments work as before.
- Python (`plugins/stream`): the generated `CustomConnectorRequest`
takes `endpoint` after `schemes`, not first. A positional call no longer
matches; keyword arguments work as before.

## Rollout

```
merge this PR -> deploy to staging
  -> recheck AC-3 and AC-8 live -> merge cli#128 -> docs (AI-3678)
  -> SDK releases with Connector.sources
```

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

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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