Skip to content

Commit 722fa4f

Browse files
feat!(types): resolve PolicyInfo / MCPPolicyInfo naming collision (v6.0.0)
The TS SDK had two unrelated types using overlapping names that predated the OpenAPI spec write-up: - `PolicyInfo` (proxy.ts): proxy-mode shape returned by /api/request - `MCPPolicyInfo` (connector.ts): MCP shape returned by /mcp/* — this is what the OpenAPI spec actually calls `PolicyInfo`. The wire-shape contract gate flagged this as drift on the spec PolicyInfo schema, since the SDK's PolicyInfo did not match the spec shape and there was no way for the gate to know the SDK uses MCPPolicyInfo for the spec's PolicyInfo. This PR swaps the names to align with the OpenAPI spec: v5.x → v6.0.0 PolicyInfo → ProxyPolicyInfo (proxy-mode shape) MCPPolicyInfo → PolicyInfo (MCP shape; matches OpenAPI) Both old names are kept as `type` aliases for one major-version migration window: type MCPPolicyInfo = PolicyInfo (in connector.ts) type PolicyInfoLegacyProxyShape = ProxyPolicyInfo (in proxy.ts) Removed in v7.0.0. Code that uses the proxy-mode shape via `response.policyInfo` on ExecuteQueryResponse continues to compile — the property type changed from `PolicyInfo` to `ProxyPolicyInfo`, but the field shape is identical. Code that explicitly imports `PolicyInfo` from the public API will see the new MCP shape (which is what the spec said it should be). Migration: - s/MCPPolicyInfo/PolicyInfo/ in MCP-handling code, OR keep the MCPPolicyInfo alias for now. - s/PolicyInfo/ProxyPolicyInfo/ in proxy-mode code, OR temporarily use PolicyInfoLegacyProxyShape. CHANGELOG marks this as BREAKING under [Unreleased]; the v6.0.0 header will land at release time. Tests: 859 pass. Lint clean.
1 parent d2274b7 commit 722fa4f

4 files changed

Lines changed: 71 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### BREAKING — `PolicyInfo` reassignment (v6.0.0)
11+
12+
`PolicyInfo` and `MCPPolicyInfo` referred to two different concepts in v5.x:
13+
14+
- `PolicyInfo` (in `src/types/proxy.ts`) was the proxy-mode shape returned by `/api/request` — fields like `policiesEvaluated`, `staticChecks`, `processingTime`, `tenantId`, `codeArtifact`.
15+
- `MCPPolicyInfo` (in `src/types/connector.ts`) was the MCP shape returned by `/api/v1/mcp/check-input` and friends — fields like `policies_evaluated`, `blocked`, `block_reason`, `processing_time_ms`, `matched_policies`. **This is what the OpenAPI spec calls `PolicyInfo`.**
16+
17+
The naming has been swapped to align with the OpenAPI spec:
18+
19+
| In v5.x | In v6.0.0 |
20+
|--|--|
21+
| `PolicyInfo` (proxy shape) | **`ProxyPolicyInfo`** (renamed) |
22+
| `MCPPolicyInfo` (MCP shape) | **`PolicyInfo`** (renamed; matches OpenAPI spec) |
23+
24+
Migration:
25+
26+
- If you imported `PolicyInfo` to read proxy-mode `/api/request` responses, change to `ProxyPolicyInfo` (or use the `PolicyInfoLegacyProxyShape` type alias as a one-major-version shim).
27+
- If you imported `MCPPolicyInfo` for MCP responses, change to `PolicyInfo`. The `MCPPolicyInfo` name is kept as a `type` alias for one major-version migration window and will be removed in v7.0.0.
28+
29+
This was previously hidden by the naming collision — code reading `response.policyInfo` on `ExecuteQueryResponse` continues to work because the property type is now `ProxyPolicyInfo` with the same fields. The break only affects code that imported the type names by hand.
30+
1031
### Fixed
1132

1233
- Telemetry path is bounded at `TELEMETRY_TIMEOUT_MS` (3s) total; the `/health` probe and checkpoint POST share a single monotonic deadline instead of stacking independent timeouts. Aligns with python/go/java SDKs.

src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ export type {
6363
DynamicPolicyInfo,
6464
DynamicPolicyMatch,
6565
ConnectorHealthStatus,
66+
// v6.0.0: `PolicyInfo` exported from connector.ts is the OpenAPI
67+
// `PolicyInfo` (MCP shape). The proxy-mode shape is `ProxyPolicyInfo`
68+
// (exported below). `MCPPolicyInfo` kept as a type alias for one
69+
// major-version migration window.
70+
PolicyInfo,
6671
MCPPolicyInfo,
6772
ExfiltrationCheckInfo,
6873
MCPCheckInputOptions,
@@ -121,7 +126,12 @@ export type {
121126
CircuitBreakerConfigUpdate,
122127
// Proxy Mode types
123128
RequestType,
124-
PolicyInfo,
129+
// v6.0.0: this is the proxy-mode shape, renamed from `PolicyInfo`.
130+
// The OpenAPI `PolicyInfo` (MCP shape) is now exported from the
131+
// connector group above; `PolicyInfoLegacyProxyShape` is a kept-
132+
// for-back-compat alias of `ProxyPolicyInfo` removed in v7.
133+
ProxyPolicyInfo,
134+
PolicyInfoLegacyProxyShape,
125135
CodeArtifact,
126136
HealthStatus,
127137
PlatformCapability,

src/types/connector.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@ export interface PolicyMatchInfo {
3838

3939
/**
4040
* Policy evaluation information included in MCP responses
41-
* Provides transparency into policy enforcement decisions
41+
* (canonical OpenAPI `PolicyInfo` schema). Provides transparency
42+
* into policy enforcement decisions returned by `/api/v1/mcp/*`
43+
* endpoints.
44+
*
45+
* Renamed from `MCPPolicyInfo` in v6.0.0 to match the OpenAPI
46+
* spec name. The previous proxy-mode `PolicyInfo` (in `proxy.ts`)
47+
* is now `ProxyPolicyInfo` so the names align with the spec.
4248
*/
43-
export interface MCPPolicyInfo {
49+
export interface PolicyInfo {
4450
policies_evaluated: number;
4551
blocked: boolean;
4652
block_reason?: string;
@@ -53,6 +59,14 @@ export interface MCPPolicyInfo {
5359
dynamic_policy_info?: DynamicPolicyInfo;
5460
}
5561

62+
/**
63+
* @deprecated Renamed to `PolicyInfo` in v6.0.0 to match the OpenAPI
64+
* spec. The previous SDK `PolicyInfo` (proxy-mode shape) is now
65+
* `ProxyPolicyInfo`. This alias keeps existing code compiling for
66+
* one major version. Removed in v7.0.0.
67+
*/
68+
export type MCPPolicyInfo = PolicyInfo;
69+
5670
/**
5771
* Information about exfiltration limit checks (Issue #966)
5872
* Helps prevent large-scale data extraction via MCP queries

src/types/proxy.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,16 @@ export interface CodeArtifact {
5555
}
5656

5757
/**
58-
* Policy evaluation information from the agent
58+
* Proxy-mode policy evaluation summary returned by `/api/request`.
59+
*
60+
* Renamed from `PolicyInfo` in v6.0.0 — the original name collided
61+
* with the OpenAPI `PolicyInfo` schema served by the MCP path
62+
* (`/api/v1/mcp/check-input` etc.), which the SDK exposes as
63+
* `MCPPolicyInfo`. This type is the proxy-mode shape; the v6
64+
* top-level `PolicyInfo` export now refers to the MCP shape (matching
65+
* the OpenAPI spec).
5966
*/
60-
export interface PolicyInfo {
67+
export interface ProxyPolicyInfo {
6168
/** List of policies that were evaluated */
6269
policiesEvaluated: string[];
6370
/** Static checks that were applied */
@@ -70,6 +77,18 @@ export interface PolicyInfo {
7077
codeArtifact?: CodeArtifact;
7178
}
7279

80+
/**
81+
* @deprecated Renamed to `ProxyPolicyInfo` in v6.0.0 to resolve a
82+
* name collision with the OpenAPI `PolicyInfo` schema (the MCP
83+
* shape). For new code, use `ProxyPolicyInfo` from `@axonflow/sdk`
84+
* for the proxy-mode shape, or `PolicyInfo` for the MCP shape (the
85+
* latter is what was previously exported as `MCPPolicyInfo`).
86+
*
87+
* This alias keeps existing code compiling for one major version.
88+
* Removed in v7.0.0.
89+
*/
90+
export type PolicyInfoLegacyProxyShape = ProxyPolicyInfo;
91+
7392
/**
7493
* Budget enforcement status information (Issue #1082).
7594
*
@@ -116,8 +135,8 @@ export interface ExecuteQueryResponse {
116135
blocked: boolean;
117136
/** Reason for blocking (if blocked) */
118137
blockReason?: string;
119-
/** Policy evaluation info */
120-
policyInfo?: PolicyInfo;
138+
/** Policy evaluation info (proxy-mode shape) */
139+
policyInfo?: ProxyPolicyInfo;
121140
/** Budget status (Issue #1082) */
122141
budgetInfo?: BudgetInfo;
123142
/** Media analysis results (present when media was submitted) */

0 commit comments

Comments
 (0)