Skip to content

[AI-3663] Keep the last synced hash for connectors and routers - #2302

Merged
kanat merged 15 commits into
mainfrom
connectors/sync-hash
Nov 25, 2026
Merged

kanat merged 15 commits into
mainfrom
connectors/sync-hash

Conversation

@kanat

@kanat kanat commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Why

agents sync can tell a dashboard edit from an unchanged folder because the router keeps the hash of the last synced folder (agent_configs.sync_hash) and every other write clears it (internal/api/config_patch.go:281). Connector definitions and router configs have no such field. So connectors sync and routers sync cannot see a dashboard edit, and they overwrite it without a word. This PR adds the same field to both resources. The CLI piece (AI-3664) reads it.

How it works

POST /v1/agents/connectors {..., sync_hash?}       (createConnector)
└─ ConnectorDefinitions.ReviseSynced(manifest, hash)
   ├─ no revision yet / manifest differs -> new revision, sync_hash = hash
   │  (hash == latest.sync_hash -> sync_hash = "")
   └─ manifest == latest revision
      ├─ latest.sync_hash == hash -> nothing written
      └─ otherwise -> same revision, UPDATE sync_hash = hash

PUT /v1/router/configs/{id} {..., sync_hash?}      (updateRouterConfig)
├─ hash != "" and hash == stored and content equal -> nothing written
└─ otherwise -> written as before, sync_hash = hash ("" clears it;
                  hash == stored with other content -> "")
POST /v1/router/configs {..., sync_hash?}          -> stored with it

hash absent = "". A write without a hash (dashboard, API, the SDKs' router-config helpers) leaves the resource with no hash. The next sync then sees a hash it did not write.

Decision: same manifest, other hash. The revision stays, and the new hash is recorded on it. A re-sync of an identical file reports "unchanged" next time, and connections are not moved to a revision that differs only in bookkeeping. This includes a dashboard save of an unchanged form: it clears the hash and adds no revision.

The CLI's routers sync finds a config by name, then sends POST or PUT (GetStream/cli internal/routerrc/sync.go). So both operations take the hash. A PUT whose hash and content match the stored config returns it without a write: updated_at does not move and no audit entry is written. The content is compared with auditDiff on the rendered configs (sync_hash, ids and timestamps are bookkeeping), so a body that differs under the same hash is still written, and its hash is cleared. Such a body is no sync of the file that hash names: a client that reads the object, edits it and sends it back whole sends the hash too. The cost: after that, one more sync records the hash again.

Path Connector Router config
sync with hash TestASyncedConnectorShowsItsHashOnEveryRead TestASyncedRouterConfigShowsItsHashOnEveryRead
same hash again TestSyncingTheSameFileAgainAddsNoRevision, store: xmin unchanged TestSyncingTheSameFileAgainWritesNothing
same content, new hash TestTheSameDefinitionUnderAnotherHashRecordsTheHashOnTheSameRevision TestTheSameFileUnderAnotherHashRecordsTheNewHash
same hash, other content (hash cleared) new revision, no hash: TestAnEditCarryingTheReadHashClearsIt written, no hash: TestTheSameHashWithOtherContentIsStillWritten, TestAReadSentBackEditedClearsTheHash
another app syncs the same custom id TestAnotherAppsSyncOfTheSameCustomIdLeavesThisOnesHash n/a (ids are per config)
import from a release before sync hashes store: TestDataMoveSuite/TestADefinitionChangeFromAReleaseBeforeSyncHashesApplies store: TestDataMoveSuite/TestARouterConfigFromAReleaseBeforeSyncHashesImportsWithNone
edit without hash clears it TestACreateThatIsNoSyncClearsTheHash TestAReplaceThatIsNoSyncClearsTheHash
read returns field get, list, create in the tests above get, list, PUT in the tests above
no field at all (control, base behaviour) TestAConnectorNoSyncWroteShowsNoHash, TestSendingTheSameConnectorAgain... TestAReplaceWithoutAHashIsWrittenEveryTime
bad hash (space, NUL, non-ASCII, line break, 129 chars) -> 400; 128 accepted TestASyncHashThatIsNotPrintableASCIIOrTooLongIsRefused same name

Store: TestStoreSuite/TestASyncedDefinitionCarriesItsHashUntilAWriteThatIsNoSync runs the whole connector sequence and checks the row's xmin to prove that an unchanged sync writes nothing.

Limits on sync_hash. At most 128 characters, the length of a SHA-512 hex digest. The CLI's agent hash is an MD5 hex digest of 32 (Agentrc.Hash, GetStream/cli internal/agentrc/agentrc.go). The value must be printable ASCII without a space (^[!-~]*$), so it can hold no NUL, which a Postgres text column refuses. Built-ins never carry a hash: Seed does not write one, and ReviseSynced refuses the built-in customer as Revise does.

Changes

  • Migration 20270201001200_connector_router_sync_hash.sql: sync_hash text NOT NULL DEFAULT '' on connector_definitions and router_configs. It only adds columns. schema/global.sql is regenerated.
  • store.ConnectorDefinitions.ReviseSynced (Revise = ReviseSynced(..., ""), so the 60 existing callers are unchanged). RouterConfigs.Update now writes sync_hash.
  • Data moves: an imported row or replayed change without a sync_hash key (from an earlier release) stores '' (importRow, COALESCE(r.sync_hash, '')).
  • API: CustomConnectorRequest.sync_hash, Connector.sync_hash (readOnly), RouterConfigRequest.sync_hash, RouterConfig.sync_hash (readOnly).
  • openapi.yaml and every client regenerated: Go, Python, JS, .NET, Ruby, Rust, PHP. Kotlin, Swift and Dart are unchanged because these operations are server-side only (their generators report the client as up to date). SDK note: .claude/skills/sdk/notes/2026-11-23-ai-3663.md. add-connector skill names the field.

Volt callers (read only, volt-dashboard at dd9f82e88): each one builds its body field by field and sends no sync_hash, so each one clears it:

Volt caller Operation
components/dashboard/agents/connectors/connector.dialog.tsx:36 (customConnectorBody, connectors.data.ts:341) POST /v1/agents/connectors
routes/.../agents/settings/routers/new.tsx:55 (routerPayload, utils/agents/routers.ts:67) POST /v1/router/configs
routes/.../agents/settings/routers/$routerId.tsx:115 (same payload) PUT /v1/router/configs/{id}

Validation

  • go test -tags integration for TestRouterConfigsSuite, TestConnectorsSuite, TestPostureSuite and TestAuditSuite in internal/api, and for the store's connector definition, router config, schema-file, datamove-router and TestEveryTable... tests, on the branch merged with main 8e6e0bc (round 1 fixes; store run includes all of TestDataMoveSuite): pass. go vet with and without the integration tag: clean. sdks/go go test ./...: pass.
  • Control tests: the expected values come from the base. The same two control tests ran on 89e9e0c and passed: no sync_hash key in any answer, and a second identical PUT still moves updated_at.
  • Mutations: 23 of 23 killed. Round 0 (19): each new condition, the early return, both pattern and length limits, every field copy, the Update column list, Revise's empty hash, and the UPDATE branch. Review round 1 (4): the data-move import COALESCE, the router-config and connector clears on edited content, and the UPDATE's scope to the caller's app. Script: mutate.py <worktree>.
  • Not run locally: uv run dev.py check (only generated .py models changed), and the Docker test suites of the .NET, Rust, Ruby and PHP SDKs (only their generators were run). CI runs them.

🤖 Generated with Claude Code

@kanat kanat changed the title [AI-3663] Store the last synced hash for connectors and router configs [AI-3663] Keep the last synced hash for connectors and routers Nov 23, 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] One Should fix, no Blocker.

The new endpoints stay server-side only. Each new read and write is scoped to the caller's customer: the connector lookup goes through ownedBy, and the router config replace reads with Get(customerID, id) before it can return early. A built-in id cannot carry a hash. The early return also needs equal content, so a stale hash cannot hide a change, and it drops no audit entry the base would have written, because empty diffs were never recorded. The PR adds no new error text, log lines or routes.

S1.1 is a test gap. The tenant scope of the new sync_hash UPDATE is correct today, but no test fails if that scope is lost.

// sync: no new revision, but the hash is this write's, so the CLI's next sync of
// that file finds it unchanged, and one after an edit elsewhere does not.
saved.SyncHash = syncHash
_, err := tx.NewUpdate().Model(&saved).Column("sync_hash").WherePK().Exec(ctx)

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 This new UPDATE is scoped to the caller only by WherePK() (customer_id, id, revision). If it is narrowed to the id alone, the sync hash on another app's definition with the same custom id gets overwritten, and every test in this PR still passes (checked with that mutation against TestConnectorsSuite and the TestStoreSuite definition tests).

Fix: add a cross-app test to ConnectorsSuite, next to TestAnotherAppMayUseTheSameCustomIdWithoutTouchingThisOne. This app syncs a custom id with one hash. s.data.backendOfAnotherApp() then creates the same id and the same definition, first with another hash and then with none. This app's get(id) must still show its own hash, at revision 1.

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 fd051bf: TestConnectorsSuite/TestAnotherAppsSyncOfTheSameCustomIdLeavesThisOnesHash (another app syncs the same id under "hash-theirs", then with none; ours keeps "hash-ours" at revision 1). Mutant .Where("id = ?", saved.ID) fails it: expected "hash-ours", actual "".

@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.

Reviewed head 2346939 merged onto main 18962cc. CI: the PR is a draft, so the go, integration, sdks and unit jobs were skipped. They run at gh pr ready.

[Blocker] R1.2 acceleration/internal/store/datamove.go importRow (not in the diff; the cause is the NOT NULL column, see the inline comment on the migration). An imported row or replayed change of connector_definitions or router_configs with no sync_hash key inserts NULL and is refused: store: import connector_definitions: a row breaks a rule of its table. Every export and change from an earlier release lacks that key. The existing TestDataMoveSuite/TestALaterRevisionOfADefinitionImports and TestDataMoveSuite/TestAnImportedDefinitionArrivesWithoutAFieldThisReleaseDoesNotRead fail on the merged tree and pass on main. This also breaks the rule that a request without sync_hash behaves as before. Fix: after picked := slices.Clone(columns), add if i := slices.Index(columns, "sync_hash"); i >= 0 { picked[i] = "COALESCE(r.sync_hash, '')" }. This also clears the hash when an older source rewrites a row. Add two rows to DataMoveSuite: an ImportRow of a router_configs row without sync_hash, and an ApplyChanges insert of a connector_definitions payload without it. Both should succeed. I checked that both fail on the head and pass with the fix.

[Question] R1.4 goes to a ticket for the CLI work (AI-3664). During a rollback window, the previous build's router config PUT does not write sync_hash (its Update column list has no sync_hash), so an edit made then keeps the old hash. The router's content compare still writes the next sync. A CLI that skips the PUT whenever the hashes match would wrongly report the config as unchanged. The CLI should always send the PUT.

Checked and sound:

  • The early return writes nothing, so skipping the audit entry, updated_at and cache invalidation is correct.
  • The ReviseSynced UPDATE runs inside the advisory lock, so it cannot race another create.
  • An MD5 hex hash fits the 128-character, printable-ASCII limit.
  • Merging #2276 is clean and builds, with no change to openapi.yaml.
  • Base code passes its router config and connector suites on a migrated DB.
  • Generated files are current.
  • 25 mutations checked, 0 survived.

Verdict: request changes, for R1.1 (migration order) and R1.2 (data moves).

-- A fingerprint of the file the CLI last synced onto the row, as agent_configs.sync_hash is for
-- an agent's directory: empty when the row was never synced, or was written since by anything
-- that is not a sync, so the CLI tells an unchanged file from an edit made elsewhere.
ALTER TABLE connector_definitions ADD COLUMN IF NOT EXISTS sync_hash TEXT NOT NULL DEFAULT '';

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.

[Blocker] R1.1 main's newest global migration is now 20270201001110 (#2284), and goose is strict. On a DB that main has migrated, the router stops at start: detected 1 missing (out-of-order) migration lower than database version (20270201001110): version 20270201000800. I reproduced this on a fresh test DB migrated by main 18962cc. Fix: rename the migration to a slot above 20270201001110, regenerate schema/global.sql, and update the filename in the comments in connector_definition.go and router_config.go.

This NOT NULL column with no import default is also the cause of R1.2 (data moves, see the review body).

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 1a7db9f: renamed to 20270201001200_connector_router_sync_hash.sql, comments in connector_definition.go:67 and router_config.go:42 updated; go run ./cmd/schema leaves schema/global.sql unchanged. Probe (not committed): a DB migrated to 20270201001110 without this migration then takes it; with the 000800 name it fails with "detected 1 missing (out-of-order) migration lower than database version (20270201001110): version 20270201000800".

// A sync of the file last synced onto the config, which nothing has written since: every
// other write clears the hash. The content is compared too, so a body that differs under
// the same hash is written rather than dropped.
if config.SyncHash != "" && config.SyncHash == existing.SyncHash &&

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] R1.3 A replace that sends the stored hash with different content is written and keeps the hash, so the hash now describes content no sync wrote. This happens with a client that reads the config and sends it back edited. RouterConfigRequest allows extra properties, so a GET body PUT back whole is accepted, sync_hash included. The CLI's next sync then sees its own hash and cannot see the edit. Probe: create with hash-one, GET as a map, set stt.target, PUT the map back. The stored sync_hash is still hash-one.

Fix: after the early return, add if config.SyncHash == existing.SyncHash { config.SyncHash = "" }. Then assert the cleared hash in TestTheSameHashWithOtherContentIsStillWritten, add the echo row above, and update the PR body row "same hash, other content". After a stale hash, one more sync records it again.

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 ade0624: other content under the stored hash now clears it. Tests: TestRouterConfigsSuite/TestTheSameHashWithOtherContentIsStillWritten (now asserts no hash) and TestAReadSentBackEditedClearsTheHash (GET as a map, edit stt, PUT it back). Both fail with the new if turned off.

_, err := tx.NewUpdate().Model(&saved).Column("sync_hash").WherePK().Exec(ctx)
return err
}
manifest.Revision = latest.Revision + 1

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] R1.3 (connector side) The same case for connectors: a create with a changed manifest and the latest revision's hash stores revision 2 carrying that hash. Probe: create with hash-one, then create with name: Renamed and sync_hash taken from the GET. The result is revision 2 with sync_hash: hash-one.

Fix: after this line, add if syncHash == latest.SyncHash { syncHash = "" }. Add a ConnectorsSuite row: revision 2, sync_hash empty.

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 ade0624: a new revision under the latest's hash carries none. Test: TestConnectorsSuite/TestAnEditCarryingTheReadHashClearsIt (revision 2, no hash); it fails with the new if turned off.

kanat and others added 5 commits November 23, 2026 23:50
main's newest global migration is 20270201001110; goose refuses one lower than the DB version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A row or change with no sync_hash key inserted NULL into the NOT NULL column and was refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A read sent back edited carries the hash, which then named content no sync wrote.

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

kanat commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

R1.2 (datamove import without sync_hash): fixed in c18817e, importRow selects COALESCE(r.sync_hash, ''). Tests: TestDataMoveSuite/TestARouterConfigFromAReleaseBeforeSyncHashesImportsWithNone (also checks a row written over a synced one leaves no hash) and TestADefinitionChangeFromAReleaseBeforeSyncHashesApplies; the existing TestALaterRevisionOfADefinitionImports and TestAnImportedDefinitionArrivesWithoutAFieldThisReleaseDoesNotRead pass again. All four fail without the COALESCE.

@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.

Delta review, round 2: GO (head fd051bf, scratch-merged onto main 9e5b6bb)

Prior findings:

  • R1.1 (migration slot): fixed. The file is now 20270201001200_.... Main's newest global migration is still 20270201001110, and no other open PR touches a 0012xx global migration. schema/global.sql carries both columns and go run ./cmd/openapi leaves no diff.
  • R1.2 (import without sync_hash): fixed. I replaced COALESCE(r.sync_hash, '') with r.sync_hash, and 4 DataMove tests failed, including the two that were red in round 1 and the 2 new ones. All of TestDataMoveSuite passes on head.
  • R1.3 (same hash, other content): fixed. I set each of the two clearing conditions to if false in turn. The router mutant failed TestAReadSentBackEditedClearsTheHash and TestTheSameHashWithOtherContentIsStillWritten. The connector mutant failed TestAnEditCarryingTheReadHashClearsIt. A same-hash, same-content sync still writes nothing: the early return runs first, and the connector same-manifest branch is untouched.
  • S1.1 (UPDATE scope): fixed. With WherePK() replaced by Where("id = ?", saved.ID), TestAnotherAppsSyncOfTheSameCustomIdLeavesThisOnesHash fails.
  • R1.4: stays with AI-3664, no code here.

The merge d8d0d7b01 has an empty --remerge-diff. I found no new problems in the changed hunks.

Tests: the api suites TestRouterConfigsSuite, TestConnectorsSuite and TestAuditSuite, and all of TestDataMoveSuite, pass. go vet passes with and without the integration tag. TestEveryHotTableIsReadByIndex fails in TestStoreSuite and TestShardedStoreSuite (5 subtests on the requests table, planner choice). The same 5 fail on origin/main 2952b10 on a separate database, so this PR does not cause them.

New finding:

  • [Nit] PR body, Tests section: "Mutations: 19 of 19 killed" is stale. Add the round-1 mutations (import COALESCE, the two clears, the UPDATE scope).

CI: the PR is a draft, so integration and go are skipped. CodeQL was still pending when I read it.

@kanat
kanat marked this pull request as ready for review November 23, 2026 23:25
kanat and others added 2 commits November 24, 2026 01:11
…create answer

The create answers with the Go clock (ns on Linux), Postgres keeps µs, so the
unchanged-sync test failed on Linux CI at routerconfigs_test.go:189-190.

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

kanat commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

CI round: integration (api) run 45288687858 failed TestRouterConfigsSuite/TestSyncingTheSameFileAgainWritesNothing at routerconfigs_test.go:189-190.

Cause: the test compared created.UpdatedAt (the create response, stamped by the Go clock, ns on Linux) with UpdatedAt read from Postgres (µs). On macOS the Go clock is µs, so it passed locally. The router code was right: the PUT wrote nothing.

Fix (test only, 6d47d16): the baseline is now readConfig of the stored row before the replace, so the test still proves updated_at is unchanged against the stored row. TestTheSameHashWithOtherContentIsStillWritten used the same create-response time in an After check; it now uses the stored baseline too. No other new test in the PR compares a create-response time with a stored one (grep of UpdatedAt|CreatedAt in the api and store tests of this diff).

Proof: in golang:1.27 (Linux arm64) against the shared test Postgres, -run 'TestRouterConfigsSuite|TestConnectorsSuite' failed at lines 189 and 190 on fd051bf and passes on the fix. Merged origin/main (f8f1de8): clean, migration 20270201001200 is still above main's newest global migration (20270201001110), vet with both tags is clean, openapi unchanged.

@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, CI round, head dfdb86c (fix 6d47d16, a test-only change, plus a clean merge of main f8f1de8).

  • C1 (the Linux failure of TestSyncingTheSameFileAgainWritesNothing): fixed. The baseline is now the stored row (routerconfigs_test.go:188-192).
  • Mutation, run on Linux in golang:1.27: the round-2 test file fails at routerconfigs_test.go:189 and :190, as in CI. The head passes (RouterConfigs and Connectors suites).
  • Migration 20270201001200 is above main's newest, 20270201001110.
  • Earlier findings R1.1-R1.3, S1.1 and R2.1 stay fixed. R1.4 is with AI-3664.
  • No new findings.
  • Open condition, not a finding: CI integration (api) failed on TestScheduledTasksSuite/TestAReplyNeverWrittenIsNoReply (scheduled_tasks_test.go:3776). The PR touches no scheduling file. The test passes alone 3 of 3 on head (Linux golang:1.27). Main's run on f8f1de8 also failed integration (api), on another test. Please rerun integration (api) and confirm green before merge.

Details: AI-3663 ledger, reviewer-ci.md.

@kanat
kanat merged commit fca02d5 into main Nov 25, 2026
20 of 21 checks passed
@kanat
kanat deleted the connectors/sync-hash branch November 25, 2026 02:47
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
…on (#2420)

## Why

Staging's global database is at `20270202000000`: v0.6.378 applied
`20270201001320` and `20270202000000` on 2026-11-25, then staging was
rolled back to v0.6.377. #2302 added
`20270201001200_connector_router_sync_hash.sql`, which is older than
both. goose (`store/migrate.go:97`, no out-of-order option) refuses an
unapplied version older than the database's, so any deploy of main to
staging fails at the migration step.

The migration is renamed to `20270202000100`, newer than every global
migration on main and on staging. The SQL is unchanged (`ADD COLUMN IF
NOT EXISTS`). Two comments that named the old version are updated.

```
before:  ... 1200 sync_hash | 1320 | 20270202000000      staging at 20270202000000 -> 1200 is "missing"
after:   ... 1320 | 20270202000000 | 20270202000100 sync_hash
```

## Proof

Own migrate binary per tree (scratch, not committed), own DBs on the
shared test Postgres, all dropped after.

| Case | Binary | Result |
|---|---|---|
| Fresh DB | this PR | `migrate ok`; both `sync_hash` columns exist;
`20270202000100` applied |
| Staging DB (tag `accelerate-v0.6.378`: global at `20270202000000`, no
`sync_hash`) | tag | `migrate ok`, no `sync_hash` columns |
| same DB | origin/main (old name) | `MIGRATE ERROR: store: migrate
global: detected 1 missing (out-of-order) migration lower than database
version (20270202000000): version 20270201001200` (the bug) |
| same DB | this PR | `migrate ok`; `20270202000100` applied; both
columns exist |
| DB that applied `20270201001200` (origin/main) | this PR | `migrate
ok`; `20270202000100` applied on top, `20270201001200` stays recorded;
columns still there; a second run is `migrate ok` |

The last row works because `checkHistory` only refuses a missing version
below the squash point (`20270124093000`), and `ADD COLUMN IF NOT
EXISTS` makes the re-apply a no-op.

Suites on this branch: `go test -tags integration -run
'TestStoreSuite/TestMigrateIsIdempotent|TestShardedStoreSuite/TestTheSchemaFilesAreCurrent|TestStoreSuite/TestADatabaseALaterRelease|TestEveryTransactional|TestATableALater'
./internal/store/` passes; `go build ./...` and `go vet -tags
integration ./internal/store/` clean.

No CHANGELOG entry: nothing user-facing changes. No open PR holds a
global migration at or after `20270202000000`.

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

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
kanat added a commit that referenced this pull request Nov 26, 2026
## Why

`agents sync` asks the router to check for changes (`check_changes`),
and the router refuses the sync with `unsynced_changes` when it would
write over a dashboard edit (`acceleration/internal/api/sync.go:359`,
GetStream/cli `internal/agents_changes.go:71`). `routers sync` and
`connectors sync` have no such check, so they overwrite a dashboard edit
without a word. Since #2302 both resources keep the hash of the last
synced file, and every write that is no sync clears it, so the router
can now tell. Decided by Kanat on 2026-11-25: the router decides, as for
agents. Ticket AI-3831, parent AI-3664.

## How it works

```
PUT /v1/router/configs/{id} {..., sync_hash?, check_changes?}
└─ updateRouterConfig
   ├─ hash == stored hash, content equal -> nothing written (#2302)
   ├─ check_changes, stored hash "", content differs
   │     -> 409 unsynced_changes, nothing written            (new)
   ├─ check_changes -> RouterConfigs.Save(read updated_at)  (new)
   │     row locked; updated_at differs -> ErrStaleRouterConfig
   │     -> 409 unsynced_changes, nothing written, cached copy forgotten
   └─ otherwise -> RouterConfigs.Update, as on the base

POST /v1/agents/connectors {..., sync_hash?, check_changes?}
└─ ConnectorDefinitions.ReviseSynced (under the advisory lock)
   ├─ no revision yet -> revision 1
   ├─ manifest == newest -> no new revision, hash recorded (#2302)
   ├─ check_changes, newest hash "", manifest differs
   │     -> ErrChangedOutsideSync -> 409 unsynced_changes   (new)
   └─ otherwise -> next revision, as on the base
```

- The refusal is one error value, `errChangedOutsideSync`
(`sync_conflict.go`): the type and code of agent sync's
`unsyncedChangesError`, so a client branches on `unsynced_changes` for
every checked sync. Its message points to no `/changes` read, because
router configs and connectors keep no change log.
- The connector check runs inside `saveRevision`, under the advisory
lock it already takes, so an edit cannot land between the check and the
write. The router config check compares content with `auditDiff`, as the
#2302 early return does. With `check_changes` the router config is
written by `RouterConfigs.Save`, which locks the row and writes only if
its `updated_at` is still the one the check read, as `AgentConfigs.Save`
does (`ErrStaleAgentConfig`). A write that landed between the check and
the write refuses the sync with `unsynced_changes`, and the cached copy
is forgotten, so the comparison is with the table and not the cache.
Without `check_changes` the write is `RouterConfigs.Update`, the base's
statement.
- A create of a router config has nothing stored, so `check_changes`
refuses nothing there. The CLI's `routers sync` sends POST for a new
name and PUT for an existing one (GetStream/cli
`internal/routerrc/sync.go`).

**Decision: same content with an empty stored hash.** The checked sync
is not refused and goes on as on the base: the router config records the
new hash, and the connector records it on the same revision (#2302).
Without that record, the next checked sync of an edited file would be
refused for an edit nobody made outside sync
(`TestACheckedSyncOfWhatAConfigNoSyncWroteAlreadySaysIsNotRefused`
checks this).

| Path | Router config | Connector |
|---|---|---|
| checked, edited outside sync (hash cleared) -> 409, nothing written |
`TestACheckedSyncOverAConfigNoSyncWroteIsRefused/edited_after_a_sync` |
`TestACheckedSyncOverADefinitionNoSyncWroteIsRefused/edited_after_a_sync`
|
| checked, never synced -> 409 | `.../never_synced` | `.../never_synced`
|
| checked, same content -> not refused, hash recorded |
`TestACheckedSyncOfWhatAConfigNoSyncWroteAlreadySaysIsNotRefused` |
`TestACheckedSyncOfWhatTheNewestRevisionAlreadySaysIsNotRefused` |
| checked, stored hash set -> written |
`TestACheckedSyncOverASyncedConfigWritesTheFile` |
`TestACheckedSyncOverASyncedDefinitionStoresTheNextRevision` |
| checked create, nothing stored -> stored | same test | same test |
| another app's edit refuses only its own sync |
`TestAnotherAppsEditOutsideSyncRefusesOnlyItsOwnCheckedSync` |
`TestAnotherAppsEditOutsideSyncRefusesOnlyItsOwnCheckedSync` |
| checked, an edit lands between the check and the write -> 409, edit
kept | `TestACheckedSyncIsRefusedOverAnEditItsCheckNeverSaw`; store
`TestARouterConfigSaveMadeFromACopyAnotherWriteReplacedWritesNothing`,
`TestARefusedRouterConfigSaveForgetsTheCachedCopy` | under the advisory
lock (`saveRevision`) |
| no `check_changes` (control, base behaviour) |
`TestASyncWithoutTheCheckWritesOverAnEditOutsideSync` |
`TestACreateThatIsNoSyncClearsTheHash` (#2302) |

Volt sends no `check_changes` (its callers are listed in #2302), so the
dashboard writes as before.

## Changes

- `RouterConfigRequest.check_changes`,
`CustomConnectorRequest.check_changes`; `store.RouterConfigs.Save` and
`store.ErrStaleRouterConfig` (`Update` is `Save` with no read time);
`store.ConnectorDefinitions.ReviseSynced` takes `checkChanges` and
returns `store.ErrChangedOutsideSync` (`Revise` passes `false`).
- `openapi.yaml` and every client regenerated: Go, Python, JS, .NET,
Ruby, Rust, PHP. Swift, Kotlin and Dart report their clients up to date
(these operations are server-side only).
- SDK note `.claude/skills/sdk/notes/2026-11-25-ai-3831.md`; the
`add-connector` skill names the field.
- No migration. No CHANGELOG line (`.claude/skills/pr/SKILL.md`: written
once per release).

## Validation

- `go test -tags integration` for `TestRouterConfigsSuite` and
`TestConnectorsSuite` (`internal/api`) and the connector definition
tests of `TestStoreSuite` (`internal/store`), on head merged with main
d1f0aef: pass. `go vet` with and without the `integration` tag on both
packages: clean. `sdks/go` build and vet: clean.
- Control tests from the base:
`TestASyncWithoutTheCheckWritesOverAnEditOutsideSync` (copied onto
0e5197a) and `TestACreateThatIsNoSyncClearsTheHash` pass on 0e5197a,
so a write without `check_changes` overwrites an edit there as it does
here.
- Mutations, 9 of 9 killed in `internal/api`: each of the three router
config conditions set to `true`, the router config check removed, the
error's code and its type, the connector's error mapping removed, and
`check_changes` passed as `false` and as `true`. The 5 store mutants
(`checkChanges` and the empty-hash condition set to `true`, the check
moved above the same-manifest return, `ReviseSynced` dropping
`checkChanges`, `Revise` passing `true`): 5 of 5 killed in review round
1. The router config race (round 1): 5 of 5 killed (the `updated_at`
condition off, the read time ignored, the cache not forgotten on
refusal, the handler always calling `Update`, the stale error not mapped
to 409).
- Race probe (a dashboard PUT and a checked sync PUT at once, 60 rounds,
not committed because it is not deterministic): 28 of 60 dashboard edits
lost with the handler calling `Update`, 0 of 60 with `Save`.
- Not run locally: the SDKs' Docker test suites. Only their generators
ran, and Kotlin, Swift and Dart report their clients up to date.

🤖 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