Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Address coverage gate review: pinned config, shared mounting, flag-aware probe

Petr Bauch073cf75b1fa4
diff --git a/console/tooling-e2e/README.md b/console/tooling-e2e/README.md
index 47ed0fcce..7b569e810 100644
--- a/console/tooling-e2e/README.md
+++ b/console/tooling-e2e/README.md
@@ -228,17 +228,21 @@ on every PR with no server.
- every declared agent operation, gated groups included. One definition
serves both MCP and the HTTP front door, so this is the agent surface
whichever door an agent uses;
- - every gateway route, with every feature flag on, and what it authenticates
- with: `session`, `operator-token` (the hosted controller's machine routes)
- or `none`.
+ - every gateway route, with every feature flag on. Each one records what it
+ authenticates with (`session`, `operator-token` for the hosted controller's
+ machine routes, or `none`) and which feature flags it is mounted behind.
+
+ Every setting the script builds the app with is pinned in the script, so a
+ developer's `.env` cannot change the snapshot. Agent management's routes are
+ mounted through the same function `Management.install` uses.
The backend CI job runs the script with `--check`, so a route added without
regenerating fails there. Once the snapshot is regenerated, the gate fails
until the new route is accounted for.
-- **What counts as covered.** An entry in some scenario's `covers`. Operation
- names and `/gateway/…` routes are checked against the snapshot, so a renamed
- route fails as a stale claim. Agent-bridge routes (`/agents/…`) are not
- snapshotted yet and pass unchecked.
+- **What counts as covered.** An entry in some scenario's `covers`. Every
+ operation name and route is checked against the snapshot, so a renamed route
+ or a typo fails as a stale claim. The one exception is agent-bridge routes
+ (`/agents/…`), which are not snapshotted yet and are taken on trust.
- **`exemptions.json`** has three lists:
- `exempt`: deliberately not covered end to end, each with its reason (it
needs a real third-party sign-in, say).
@@ -250,11 +254,12 @@ on every PR with no server.
removed. Never add to it: a new route needs a scenario or an `exempt` entry
with its reason.
- **A check derived from the snapshot.** The fast lane checks that every
- `session` route the deployment mounts answers 401 to a request carrying no
- credential. It reads which routes are mounted from the deployment's own
- OpenAPI document, so routes behind flags that are off are left out and
- counted. This check counts nothing towards coverage, but it applies to every
- new route automatically.
+ `session` route answers 401 to a request carrying no credential. It skips
+ only the routes behind a feature flag the deployment has off: the snapshot
+ names each route's flags, and `GET /gateway/feature-flags` says which are on.
+ Routes left out of the OpenAPI document are probed like any other. This check
+ counts nothing towards coverage, but it applies to every new route
+ automatically.
## In CI
diff --git a/console/tooling-e2e/src/clients/switch-client.ts b/console/tooling-e2e/src/clients/switch-client.ts
index 5b9751234..f7ffe075f 100644
--- a/console/tooling-e2e/src/clients/switch-client.ts
+++ b/console/tooling-e2e/src/clients/switch-client.ts
@@ -207,23 +207,13 @@ export class SwitchClient {
return response.status;
}
- /**
- * The gateway routes this deployment mounts, as `METHOD /gateway/path`, from
- * its own OpenAPI document (served without a session). Routes behind a
- * feature flag the deployment has off are not in it.
- */
- async mountedGatewayRoutes(): Promise<Set<string>> {
- const document = await this.request<{ paths: Record<string, Record<string, unknown>> }>(
+ /** `GET /gateway/feature-flags` — the flags this deployment has turned on. */
+ async enabledFeatureFlags(): Promise<Set<string>> {
+ const body = await this.gateway<{ flags: { key: string; enabled: boolean }[] }>(
'GET',
- '/gateway/openapi.json'
+ '/feature-flags'
);
- const routes = new Set<string>();
- for (const [path, operations] of Object.entries(document.paths)) {
- for (const method of Object.keys(operations)) {
- routes.add(`${method.toUpperCase()} /gateway${path}`);
- }
- }
- return routes;
+ return new Set(body.flags.filter((flag) => flag.enabled).map((flag) => flag.key));
}
/** `GET /health` — the reachability probe the suite skips on. */
diff --git a/console/tooling-e2e/src/fast/fast.e2e.test.ts b/console/tooling-e2e/src/fast/fast.e2e.test.ts
index 7d4daea7a..7f28a0019 100644
--- a/console/tooling-e2e/src/fast/fast.e2e.test.ts
+++ b/console/tooling-e2e/src/fast/fast.e2e.test.ts
@@ -3,8 +3,8 @@ import { describeEnv } from '../core/env.ts';
import { RunContext } from '../core/run.ts';
import { admit, assertValidHeaders } from '../core/scenario.ts';
import { resolveLane, type LaneResolution } from '../core/suite.ts';
-import { readSurface } from '../gate/gate.ts';
import { Fixtures } from '../fixtures/fixtures.ts';
+import { readSurface } from '../gate/gate.ts';
import { FAST_SCENARIOS } from './index.ts';
import { probeSessionRoutes } from './session-required.ts';
diff --git a/console/tooling-e2e/src/fast/session-required.ts b/console/tooling-e2e/src/fast/session-required.ts
index 0c798c17c..ead01c745 100644
--- a/console/tooling-e2e/src/fast/session-required.ts
+++ b/console/tooling-e2e/src/fast/session-required.ts
@@ -11,9 +11,11 @@ import type { ServerSurface } from '../gate/gate.ts';
* catches a session check that a refactor dropped, which the snapshot would
* only show as a route moving to `none` in a diff.
*
- * Only routes the deployment mounts are probed, read from its own OpenAPI
- * document: a route behind a feature flag it has off answers 404 for that
- * reason alone. Path parameters get a well-formed id that names nothing: the
+ * A route behind a feature flag the deployment has off is not mounted, and
+ * answers 404 for that reason alone, so the probe skips exactly those: the
+ * snapshot names each route's flags, and the deployment says which it has on.
+ * Every other session route is probed, whether or not it appears in the
+ * deployment's OpenAPI document. Path parameters get a well-formed id that names nothing: the
* session check runs before the route ever looks the id up.
*/
@@ -26,7 +28,7 @@ export function probePath(route: string): { method: string; path: string } {
export interface SessionProbe {
probed: number;
- /** Session routes in the snapshot this deployment does not mount. */
+ /** Session routes behind a feature flag this deployment has off. */
notMounted: number;
/** Each probed route that did not answer 401, with what it answered. */
wrong: string[];
@@ -36,11 +38,11 @@ export async function probeSessionRoutes(
switchClient: SwitchClient,
surface: ServerSurface
): Promise<SessionProbe> {
- const mounted = await switchClient.mountedGatewayRoutes();
+ const enabled = await switchClient.enabledFeatureFlags();
const result: SessionProbe = { probed: 0, notMounted: 0, wrong: [] };
- for (const { route, auth } of surface.gatewayRoutes) {
+ for (const { route, auth, flags } of surface.gatewayRoutes) {
if (auth !== 'session') continue;
- if (!mounted.has(route)) {
+ if (!flags.every((flag) => enabled.has(flag))) {
result.notMounted += 1;
continue;
}
diff --git a/console/tooling-e2e/src/gate/coverage.test.ts b/console/tooling-e2e/src/gate/coverage.test.ts
index 109a4964c..e7fafc399 100644
--- a/console/tooling-e2e/src/gate/coverage.test.ts
+++ b/console/tooling-e2e/src/gate/coverage.test.ts
@@ -22,13 +22,20 @@ describe('coverage gate', () => {
const SURFACE: ServerSurface = {
operations: ['list_rooms', 'post_message'],
gatewayRoutes: [
- { route: 'POST /gateway/rooms', auth: 'session' },
- { route: 'POST /gateway/auth/login', auth: 'none' },
+ { route: 'POST /gateway/rooms', auth: 'session', flags: [] },
+ { route: 'POST /gateway/auth/login', auth: 'none', flags: [] },
],
};
function header(id: string, covers: string[]): ScenarioHeader {
- return { id, covers, needsProvider: false, environments: ['ephemeral'], owner: 'platform', requires: [] };
+ return {
+ id,
+ covers,
+ needsProvider: false,
+ environments: ['ephemeral'],
+ owner: 'platform',
+ requires: [],
+ };
}
function exemptions(overrides: Partial<Exemptions>): Exemptions {
@@ -41,7 +48,9 @@ function exemptions(overrides: Partial<Exemptions>): Exemptions {
}
describe('coverage gate rules', () => {
- const covering = [header('rooms', ['list_rooms', 'POST /gateway/rooms', 'GET /agents/{agent_id}/ops'])];
+ const covering = [
+ header('rooms', ['list_rooms', 'POST /gateway/rooms', 'GET /agents/{agent_id}/ops']),
+ ];
it('passes when everything is covered, exempt or in the backlog', () => {
expect(coverageProblems(SURFACE, exemptions({}), covering)).toEqual([]);
@@ -50,12 +59,17 @@ describe('coverage gate rules', () => {
it('fails on a new operation or route nothing accounts for', () => {
const grown: ServerSurface = {
operations: [...SURFACE.operations, 'archive_room'],
- gatewayRoutes: [...SURFACE.gatewayRoutes, { route: 'DELETE /gateway/rooms/{room_id}', auth: 'session' }],
+ gatewayRoutes: [
+ ...SURFACE.gatewayRoutes,
+ { route: 'DELETE /gateway/rooms/{room_id}', auth: 'session', flags: [] },
+ ],
};
const problems = coverageProblems(grown, exemptions({}), covering);
expect(problems).toHaveLength(2);
expect(problems.join('\n')).toContain("'archive_room' is covered by no scenario");
- expect(problems.join('\n')).toContain("'DELETE /gateway/rooms/{room_id}' is covered by no scenario");
+ expect(problems.join('\n')).toContain(
+ "'DELETE /gateway/rooms/{room_id}' is covered by no scenario"
+ );
});
it('fails on a backlog entry a scenario now covers, and on stale entries', () => {
@@ -65,17 +79,27 @@ describe('coverage gate rules', () => {
covering
);
expect(problems.join('\n')).toContain("backlog lists 'list_rooms', which rooms now covers");
- expect(problems.join('\n')).toContain("backlog lists 'gone_operation', which the server does not have");
+ expect(problems.join('\n')).toContain(
+ "backlog lists 'gone_operation', which the server does not have"
+ );
});
- it('fails on a header covering what the server does not have, ignoring the agent bridge', () => {
+ it('fails on a header covering what the server does not have, trusting only agent-bridge routes', () => {
const problems = coverageProblems(SURFACE, exemptions({}), [
...covering,
- header('stale', ['list_room', 'GET /gateway/nowhere', 'POST /agents/register-known']),
+ header('stale', [
+ 'list_room',
+ 'GET /gateway/nowhere',
+ 'POST /gatway/rooms',
+ 'POST gateway/rooms',
+ 'POST /agents/register-known',
+ ]),
]);
- expect(problems).toHaveLength(2);
+ expect(problems).toHaveLength(4);
expect(problems.join('\n')).toContain("stale covers 'list_room'");
expect(problems.join('\n')).toContain("stale covers 'GET /gateway/nowhere'");
+ expect(problems.join('\n')).toContain("stale covers 'POST /gatway/rooms'");
+ expect(problems.join('\n')).toContain("stale covers 'POST gateway/rooms'");
});
it('wants a reason for every exemption, and for every route that takes no credential', () => {
@@ -84,7 +108,9 @@ describe('coverage gate rules', () => {
exemptions({ exempt: { 'POST /gateway/auth/login': ' ' }, unauthenticated: {} }),
covering
);
- expect(problems.join('\n')).toContain("exempt lists 'POST /gateway/auth/login' without a reason");
+ expect(problems.join('\n')).toContain(
+ "exempt lists 'POST /gateway/auth/login' without a reason"
+ );
expect(problems.join('\n')).toContain("'POST /gateway/auth/login' takes no credential");
});
diff --git a/console/tooling-e2e/src/gate/gate.ts b/console/tooling-e2e/src/gate/gate.ts
index 9d5162be5..f3acffebe 100644
--- a/console/tooling-e2e/src/gate/gate.ts
+++ b/console/tooling-e2e/src/gate/gate.ts
@@ -26,7 +26,12 @@ export type RouteAuth = 'session' | 'operator-token' | 'none';
export interface ServerSurface {
operations: string[];
- gatewayRoutes: { route: string; auth: RouteAuth }[];
+ gatewayRoutes: {
+ route: string;
+ auth: RouteAuth;
+ /** The feature flags the route is mounted behind; it exists only with all of them on. */
+ flags: string[];
+ }[];
}
export interface Exemptions {
@@ -35,7 +40,12 @@ export interface Exemptions {
backlog: string[];
}
-const SURFACE_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'surface');
+const SURFACE_DIR = path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '..',
+ '..',
+ 'surface'
+);
export function readSurface(): ServerSurface {
return JSON.parse(
@@ -55,9 +65,16 @@ export function readExemptions(): Exemptions {
};
}
-/** What the gate is about: operations, and routes under `/gateway`. */
-function inScope(entry: string): boolean {
- return !entry.includes(' ') || entry.includes(' /gateway/');
+/**
+ * Route prefixes the snapshot does not hold yet, so a `covers` entry under one
+ * is taken on trust. Any other route has to be one the snapshot has: a typo
+ * would otherwise read as coverage while the real route stays uncovered.
+ */
+const UNCHECKED_ROUTE_PREFIXES = ['/agents/'];
+
+function unchecked(entry: string): boolean {
+ const [, path] = entry.split(' ', 2);
+ return path !== undefined && UNCHECKED_ROUTE_PREFIXES.some((prefix) => path.startsWith(prefix));
}
/** Every problem, so one pass fixes them all. Empty when the gate passes. */
@@ -72,11 +89,11 @@ export function coverageProblems(
const coveredBy = new Map<string, string[]>();
for (const header of headers) {
for (const entry of header.covers) {
- if (!inScope(entry)) continue;
+ if (unchecked(entry)) continue;
if (!known.has(entry)) {
problems.push(
`${header.id} covers '${entry}', which the server does not have ` +
- `(renamed or removed? the snapshot is surface/server-surface.json)`
+ `(renamed, removed, or a typo? the snapshot is surface/server-surface.json)`
);
continue;
}
@@ -86,7 +103,8 @@ export function coverageProblems(
const backlog = new Set(exemptions.backlog);
for (const entry of exemptions.backlog) {
- if (!known.has(entry)) problems.push(`backlog lists '${entry}', which the server does not have`);
+ if (!known.has(entry))
+ problems.push(`backlog lists '${entry}', which the server does not have`);
else if (coveredBy.has(entry)) {
problems.push(
`backlog lists '${entry}', which ${coveredBy.get(entry)!.join(', ')} now covers — remove it`
diff --git a/console/tooling-e2e/surface/server-surface.json b/console/tooling-e2e/surface/server-surface.json
index ee4c8657d..6fef2272a 100644
--- a/console/tooling-e2e/surface/server-surface.json
+++ b/console/tooling-e2e/surface/server-surface.json
@@ -63,979 +63,1283 @@
"gatewayRoutes": [
{
"route": "DELETE /gateway/agents/by-name/{agent_name}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/agents/{agent_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/agents/{agent_id}/service-grants/{service}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "DELETE /gateway/api-keys/{key_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/chats/{room_id}/hidden",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/chats/{room_id}/members/{member_user_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/collaborations/{bridge_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/collaborations/{bridge_id}/identities/{external_user_row_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/collaborations/{bridge_id}/teams/{team_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/connectors/{connector_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/documents/{document_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/management/agents/{agent_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "DELETE /gateway/management/controllers/{controller_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "DELETE /gateway/management/controllers/{controller_id}/provider-logins/{provider}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "DELETE /gateway/messaging-apps/installs/{install_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/packages/{package_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/packages/{package_id}/documents/{document_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/packages/{package_id}/references/{reference_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/provider-connections/github",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/provider-connections/github/flows/{flow_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/references/reference-types/{type}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/references/{reference_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/room-groups/{group_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/rooms/{room_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/rooms/{room_id}/agents/{agent_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/rooms/{room_id}/documents/{document_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/rooms/{room_id}/linked-rooms/{target_room_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/rooms/{room_id}/packages/{package_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/rooms/{room_id}/references/{reference_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/rooms/{room_id}/roles/{name}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/service-connections/{service}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "DELETE /gateway/service-connections/{service}/flows/{flow_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "DELETE /gateway/templates/{template_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/tenants/{tenant_id}/budgets/{budget_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/tenants/{tenant_id}/invitations/{invitation_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/tenants/{tenant_id}/join-domains/{domain}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/tenants/{tenant_id}/members/{user_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "DELETE /gateway/trust-settings",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/agent-sessions/approvals",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/agents",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/agents/avatar-settings",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/agents/icon-choices",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/agents/known-types",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/agents/{agent_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/agents/{agent_id}/service-grants",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "GET /gateway/api-keys",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/api-keys/{key_id}/reveal",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/auth/config",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/auth/me",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/auth/me/identities",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/auth/oidc/callback",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/auth/oidc/login",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/auth/session",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/chats",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/chats/activity/events",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/chats/events",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/chats/{room_id}/activity",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/chats/{room_id}/media",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/chats/{room_id}/members",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/chats/{room_id}/messages",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/collaborations",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/collaborations/types",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/collaborations/{bridge_id}/directory",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/collaborations/{bridge_id}/teams",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/collaborations/{bridge_id}/teams-package",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/collaborations/{bridge_id}/users",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/connectors",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/connectors/types",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/connectors/{connector_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/docs",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/docs/oauth2-redirect",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/documents",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/documents/{document_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/documents/{document_id}/rooms",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/ecosystem/graph",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/feature-flags",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/hosted-controller/machines",
- "auth": "operator-token"
+ "auth": "operator-token",
+ "flags": []
},
{
"route": "GET /gateway/hosted-machines",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/hosted-machines/{machine_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/invitations/mine",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/joinable-tenants",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/linked-rooms/graph",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/management/advanced-config",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/management/agents",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "GET /gateway/management/agents/{agent_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "GET /gateway/management/controllers",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "GET /gateway/management/controllers/{controller_id}/provider-logins",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "GET /gateway/management/operations",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "GET /gateway/management/providers",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/messaging-apps",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/messaging-apps/installs",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/openapi.json",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/packages",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/packages/{package_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/packages/{package_id}/documents",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/packages/{package_id}/references",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/packages/{package_id}/rooms",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/provider-connections/catalog",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/provider-connections/github",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/provider-connections/github/authorize",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/provider-connections/github/callback",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/provider-connections/github/flows/{flow_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/redoc",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "GET /gateway/references",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/references/reference-types",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/references/reference-types/owned",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/references/{reference_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/references/{reference_id}/rooms",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/room-groups",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/template-schema",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/{room_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/{room_id}/documents",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/{room_id}/documents/{document_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/{room_id}/linked-rooms",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/{room_id}/linked-rooms/inbound",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/{room_id}/packages",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/{room_id}/references",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/{room_id}/roles",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/rooms/{room_id}/yaml",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/service-connections",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "GET /gateway/service-connections/{service}/flows/authorize",
- "auth": "none"
+ "auth": "none",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "GET /gateway/service-connections/{service}/flows/callback",
- "auth": "none"
+ "auth": "none",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "GET /gateway/service-connections/{service}/flows/{flow_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "GET /gateway/template-runs",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/templates",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/templates/{template_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/templates/{template_id}/content",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/tenants",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/tenants/current",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/tenants/{tenant_id}/audit-events",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/tenants/{tenant_id}/budgets",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/tenants/{tenant_id}/invitations",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/tenants/{tenant_id}/join-domains",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/tenants/{tenant_id}/members",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/tenants/{tenant_id}/usage",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/trust-settings",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/users",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "GET /gateway/version",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/agents/{agent_id}/options",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/collaborations/{bridge_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/documents/{document_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/management/agents/{agent_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "PATCH /gateway/management/controllers/{controller_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "PATCH /gateway/packages/{package_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/references/reference-types/{type}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/references/{reference_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/room-groups/{group_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/rooms/{room_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/rooms/{room_id}/agents/{agent_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/rooms/{room_id}/roles/{name}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/templates/{template_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PATCH /gateway/tenants/{tenant_id}/members/{user_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/agent-sessions/{agent_id}/{session_id}/approvals/{request_id}/answer",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/agents/register",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/agents/register-known-bulk",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/agents/register-other",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/api-keys",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/auth/login",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "POST /gateway/auth/logout",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "POST /gateway/auth/refresh",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/auth/signup",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "POST /gateway/chats",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/chats/{room_id}/archive",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/chats/{room_id}/attachments",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/chats/{room_id}/controls",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/chats/{room_id}/members",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/chats/{room_id}/messages",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/chats/{room_id}/warm",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/collaborations",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/collaborations/{bridge_id}/default",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/collaborations/{bridge_id}/identities",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/collaborations/{bridge_id}/teams/{team_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/connectors",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/documents",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/hosted-controller/machines/{machine_id}/observation",
- "auth": "operator-token"
+ "auth": "operator-token",
+ "flags": []
},
{
"route": "POST /gateway/hosted-controller/machines/{machine_id}/prepare",
- "auth": "operator-token"
+ "auth": "operator-token",
+ "flags": []
},
{
"route": "POST /gateway/hosted-machines/ensure",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/hosted-machines/{machine_id}/lifecycle",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/invitations/accept",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/invitations/mine/accept",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/joinable-tenants/{tenant_id}/join",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/management/agents",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "POST /gateway/management/controllers",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "POST /gateway/management/enrollment-codes",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "POST /gateway/management/operations",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "POST /gateway/messaging-apps/{platform}/claim",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/messaging-apps/{platform}/install",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/packages",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/packages/{package_id}/documents/{document_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/packages/{package_id}/references/{reference_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/provider-connections/github/callback",
- "auth": "none"
+ "auth": "none",
+ "flags": []
},
{
"route": "POST /gateway/provider-connections/github/flows",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/provider-connections/github/flows/{flow_id}/complete",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/provider-connections/github/flows/{flow_id}/confirm",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/references",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/references/reference-types",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/room-groups",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/bulk-archive",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/bulk-delete",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/from-template",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/from-template-document",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/from-yaml",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/{room_id}/agents",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/{room_id}/archive",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/{room_id}/documents/{document_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/{room_id}/linked-rooms",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/{room_id}/packages/{package_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/{room_id}/references/{reference_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/{room_id}/roles",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/{room_id}/unarchive",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/rooms/{room_id}/users",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/service-connections/{service}/flows",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "POST /gateway/service-connections/{service}/flows/callback",
- "auth": "none"
+ "auth": "none",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "POST /gateway/service-connections/{service}/flows/{flow_id}/complete",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "POST /gateway/service-connections/{service}/flows/{flow_id}/confirm",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "POST /gateway/template-runs/{root_room_id}/continue",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/template-runs/{root_room_id}/stop",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/templates",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/templates/validate",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/tenants",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/tenants/{tenant_id}/budgets",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/tenants/{tenant_id}/invitations",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/tenants/{tenant_id}/join-domains",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/tenants/{tenant_id}/switch",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "POST /gateway/users",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/agents/{agent_id}/addressing-policy",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/agents/{agent_id}/can-manage-agents",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/agents/{agent_id}/description",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/agents/{agent_id}/display-name",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/agents/{agent_id}/icon",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/agents/{agent_id}/service-grants/{service}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "PUT /gateway/auth/me/password",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/chats/{room_id}/hidden",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/management/agents/{agent_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "PUT /gateway/management/controllers/{controller_id}/provider-logins/{provider}",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "agent_management"
+ ]
},
{
"route": "PUT /gateway/room-groups/{group_id}/rooms",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/rooms/{room_id}/group",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/rooms/{room_id}/observe",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/rooms/{room_id}/protection",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/service-connections/{service}/key",
- "auth": "session"
+ "auth": "session",
+ "flags": [
+ "service_connections"
+ ]
},
{
"route": "PUT /gateway/tenants/{tenant_id}/budgets/{budget_id}",
- "auth": "session"
+ "auth": "session",
+ "flags": []
},
{
"route": "PUT /gateway/trust-settings",
- "auth": "session"
+ "auth": "session",
+ "flags": []
}
]
}
diff --git a/core/switch_core/management/wiring.py b/core/switch_core/management/wiring.py
index 5c6079a59..0ec8a8075 100644
--- a/core/switch_core/management/wiring.py
+++ b/core/switch_core/management/wiring.py
@@ -89,7 +89,7 @@ class Management:
session_factory=self.session_factory,
)
agent_bridge_app.include_router(controller_router)
- gateway_app.include_router(gateway_router, prefix=GATEWAY_PREFIX)
+ mount_gateway_routes(gateway_app)
protocol.set_agent_removal_listener(self.agent_removed)
enable_agent_management(self.agent_operations)
@@ -207,6 +207,16 @@ def build_management(
)
+def mount_gateway_routes(gateway_app: FastAPI) -> None:
+ """Every route agent management adds to the gateway.
+
+ The one place they are mounted: `Management.install` calls it, and so does
+ the end-to-end surface snapshot (`scripts/e2e_surface.py`), which is how a
+ route added here reaches the coverage gate.
+ """
+ gateway_app.include_router(gateway_router, prefix=GATEWAY_PREFIX)
+
+
def create_management(
config: SwitchConfig,
session_factory: async_sessionmaker[AsyncSession],
diff --git a/core/tests/test_e2e_surface.py b/core/tests/test_e2e_surface.py
index 4218578ea..b9465baec 100644
--- a/core/tests/test_e2e_surface.py
+++ b/core/tests/test_e2e_surface.py
@@ -56,11 +56,25 @@ def test_flag_gated_routes_are_included() -> None:
def test_the_environment_does_not_change_the_snapshot(
monkeypatch: pytest.MonkeyPatch,
) -> None:
+ """Settings the script does not pin, each of which would either fail the
+ build or change what it mounts if the environment leaked in."""
before = surface.render()
- monkeypatch.setenv("FEATURE_FLAGS_ENABLED", "")
+ monkeypatch.setenv("GATEWAY_SIGNUP_MODE", "open")
+ monkeypatch.setenv("HOSTED_LAUNCH_CAPACITY", "1")
+ monkeypatch.setenv("GITHUB_APP_CONFIG_PATH", "/nonexistent/github-app.json")
assert surface.render() == before
+def test_each_route_names_the_flags_it_is_mounted_behind() -> None:
+ routes = {
+ entry["route"]: entry["flags"]
+ for entry in json.loads(surface.render())["gatewayRoutes"]
+ }
+ assert routes["POST /gateway/rooms"] == []
+ assert routes["POST /gateway/management/agents"] == ["agent_management"]
+ assert routes["GET /gateway/service-connections"] == ["service_connections"]
+
+
def test_operations_include_gated_groups() -> None:
operations = json.loads(surface.render())["operations"]
assert "list_rooms" in operations
diff --git a/scripts/e2e_surface.py b/scripts/e2e_surface.py
index 5d0f08f5f..3aa6fccdb 100644
--- a/scripts/e2e_surface.py
+++ b/scripts/e2e_surface.py
@@ -9,12 +9,17 @@ so the surface it reads is a committed snapshot:
* every declared agent operation, gated groups included — one definition
serves both the MCP server and the HTTP front door, so this is the agent
surface whichever door an agent uses;
-* every gateway route as `METHOD /gateway/path`, with every feature flag on and
- agent management mounted, and what it authenticates with: a signed-in
- session (`session`), the hosted controller's operator token
- (`operator-token`), or nothing (`none`). The gate requires each route that
- takes nothing to be listed with a reason, and the fast lane checks that each
- `session` route refuses a request without one.
+* every gateway route as `METHOD /gateway/path` (path parameters as OpenAPI
+ writes them, convertors dropped), with every feature flag on, and:
+ - what it authenticates with: a signed-in session (`session`), the hosted
+ controller's operator token (`operator-token`), or nothing (`none`). The
+ gate requires each route that takes nothing to be listed with a reason;
+ - the feature flags it is mounted behind, found by building the app with
+ each flag off in turn. The fast lane probes every `session` route whose
+ flags the deployment has on, and expects a 401 without a session.
+
+Every setting comes from this script, never from the environment, so a
+developer's `.env` (which `just` exports) cannot change what it writes.
Usage:
uv run --project core python scripts/e2e_surface.py # write it
@@ -37,6 +42,7 @@ from unittest.mock import MagicMock
from fastapi import FastAPI
from fastapi.dependencies.models import Dependant
from fastapi.routing import APIRoute
+from pydantic_settings import BaseSettings, PydanticBaseSettingsSource
from starlette.routing import Route
from switch_core.bridges.agent.operations import declared_operations
@@ -51,8 +57,7 @@ from switch_core.gateway.auth import (
get_current_user_in_transaction,
)
from switch_core.gateway.hosted_controller import controller_session
-from switch_core.management.gateway_routes import router as management_router
-from switch_core.management.wiring import GATEWAY_PREFIX
+from switch_core.management.wiring import mount_gateway_routes
REPO_ROOT = Path(__file__).resolve().parent.parent
SNAPSHOT = REPO_ROOT / "console" / "tooling-e2e" / "surface" / "server-surface.json"
@@ -100,9 +105,23 @@ _COLLABORATORS = (
)
-def _config() -> SwitchConfig:
- return SwitchConfig(
- _env_file=None, # type: ignore[call-arg]
+class _PinnedConfig(SwitchConfig):
+ """`SwitchConfig` that reads only the arguments it is given."""
+
+ @classmethod
+ def settings_customise_sources(
+ cls,
+ settings_cls: type[BaseSettings],
+ init_settings: PydanticBaseSettingsSource,
+ env_settings: PydanticBaseSettingsSource,
+ dotenv_settings: PydanticBaseSettingsSource,
+ file_secret_settings: PydanticBaseSettingsSource,
+ ) -> tuple[PydanticBaseSettingsSource, ...]:
+ return (init_settings,)
+
+
+def _config(flags: frozenset[str]) -> SwitchConfig:
+ return _PinnedConfig(
db_host="db",
db_port="5432",
db_user="switch",
@@ -114,19 +133,21 @@ def _config() -> SwitchConfig:
gateway_admin_email="[email protected]",
gateway_admin_password="placeholder",
controller_token_secret="0" * 64,
- feature_flags_enabled=",".join(sorted(KNOWN_FEATURE_FLAGS)),
+ feature_flags_enabled=",".join(sorted(flags)),
)
-def gateway_app() -> FastAPI:
+def gateway_app(config: SwitchConfig) -> FastAPI:
app = create_gateway_app(
**{name: MagicMock() for name in _COLLABORATORS},
install_service=None,
invite_mailer=None,
- config=_config(),
+ config=config,
)
- # What `Management.install` mounts when the agent_management flag is on.
- app.include_router(management_router, prefix=GATEWAY_PREFIX)
+ # `create_management` builds agent management only with its flag on, and
+ # `Management.install` then mounts its gateway routes through this.
+ if config.agent_management_enabled:
+ mount_gateway_routes(app)
return app
@@ -155,7 +176,8 @@ def _auth(route: Route) -> str:
return "none"
-def gateway_routes(app: FastAPI) -> list[dict[str, str]]:
+def _routes_by_key(app: FastAPI) -> dict[str, str]:
+ """Each route's `METHOD /gateway/path`, and what it authenticates with."""
routes: dict[str, str] = {}
for route in app.routes:
if not isinstance(route, Route):
@@ -166,18 +188,42 @@ def gateway_routes(app: FastAPI) -> list[dict[str, str]]:
for method in sorted(route.methods or ()):
if method == "HEAD":
continue
- key = f"{method} /gateway{route.path}"
+ # `path_format` is the path as OpenAPI and a client write it:
+ # `{file:path}` becomes `{file}`.
+ key = f"{method} /gateway{route.path_format}"
if key in routes:
raise ValueError(f"Gateway route {key} is mounted twice.")
routes[key] = _auth(route)
- return [{"route": key, "auth": routes[key]} for key in sorted(routes)]
+ return routes
+
+
+def gateway_routes() -> list[dict[str, Any]]:
+ every = frozenset(KNOWN_FEATURE_FLAGS)
+ routes = _routes_by_key(gateway_app(_config(every)))
+ gated_by: dict[str, list[str]] = {key: [] for key in routes}
+ for flag in sorted(every):
+ without = _routes_by_key(gateway_app(_config(every - {flag})))
+ unexpected = sorted(set(without) - set(routes))
+ if unexpected:
+ raise ValueError(
+ f"Turning the {flag} flag off mounts routes that are absent with "
+ f"every flag on: {unexpected}. The snapshot assumes a flag only "
+ "ever adds routes."
+ )
+ for key in routes:
+ if key not in without:
+ gated_by[key].append(flag)
+ return [
+ {"route": key, "auth": routes[key], "flags": gated_by[key]}
+ for key in sorted(routes)
+ ]
def render() -> str:
surface = {
"_generated": "by scripts/e2e_surface.py; do not edit. Run `just e2e-surface`.",
"operations": sorted(declared_operations()),
- "gatewayRoutes": gateway_routes(gateway_app()),
+ "gatewayRoutes": gateway_routes(),
}
return json.dumps(surface, indent=2) + "\n"