Skip to content

A desktop coding agent with free access to frontier models.

TypeScript
13.7 KB
Raw Blame
import { faultDefinitionSchema, type FaultDefinition } from "../contracts/fault.js"
import type { ProviderProfileId } from "../contracts/profile.js"
import { deepFreeze } from "../immutability.js"

const allProfiles: ProviderProfileId[] = [
  "synthetic-enterprise-oauth-mcp",
  "servicenow-inbound-quickstart",
  "microsoft-work-iq",
  "microsoft-enterprise",
  "agent-365-mail-v1-2026-07",
]

const faults = deepFreeze(faultDefinitionSchema.array().parse([
  {
    id: "oauth-missing-auth-challenge",
    displayName: "Missing OAuth challenge",
    description: "Returns HTTP 401 without a usable WWW-Authenticate resource metadata reference.",
    phase: "AUTH_RESOURCE_DISCOVERY",
    category: "oauth_discovery_resource",
    retryable: false,
    operatorAction: "check_provider_metadata",
    applicableProfiles: allProfiles,
    effect: "omit-auth-challenge",
  },
  {
    id: "oauth-malformed-resource-metadata",
    displayName: "Malformed protected-resource metadata",
    description: "Returns a protected-resource document whose resource does not match the MCP endpoint.",
    phase: "AUTH_RESOURCE_DISCOVERY",
    category: "oauth_discovery_resource",
    retryable: false,
    operatorAction: "check_provider_metadata",
    applicableProfiles: allProfiles,
    effect: "malformed-resource-metadata",
  },
  {
    id: "oauth-issuer-mismatch",
    displayName: "Authorization issuer mismatch",
    description: "Publishes authorization-server metadata with a mismatched issuer.",
    phase: "AUTH_ISSUER_DISCOVERY",
    category: "oauth_discovery_issuer",
    retryable: false,
    operatorAction: "check_provider_metadata",
    applicableProfiles: allProfiles,
    effect: "issuer-mismatch",
  },
  {
    id: "oauth-pkce-s256-unsupported",
    displayName: "PKCE S256 unavailable",
    description: "Omits S256 from authorization-server metadata.",
    phase: "AUTH_ISSUER_DISCOVERY",
    category: "oauth_pkce_unsupported",
    retryable: false,
    operatorAction: "contact_provider",
    applicableProfiles: allProfiles,
    effect: "omit-pkce-s256",
  },
  {
    id: "oauth-dynamic-registration-unsupported",
    displayName: "Dynamic registration unsupported",
    description: "Rejects RFC 7591 registration so the client must use a manual client registration.",
    phase: "AUTH_CLIENT_REGISTRATION",
    category: "oauth_client_registration",
    retryable: false,
    operatorAction: "register_client",
    applicableProfiles: ["synthetic-enterprise-oauth-mcp"],
    effect: "reject-registration",
  },
  {
    id: "oauth-invalid-client",
    displayName: "OAuth client rejected",
    description: "Token exchange returns a provider-shaped invalid_client response for a syntactically valid request: Microsoft profiles include safe AADSTS7000215 correlation evidence, while ServiceNow retains its own remediation wording.",
    phase: "AUTH_TOKEN_ACQUISITION",
    category: "oauth_client_registration",
    retryable: false,
    operatorAction: "register_client",
    applicableProfiles: allProfiles,
    effect: "reject-client",
  },
  {
    id: "oauth-invalid-grant",
    displayName: "Authorization grant rejected",
    description: "Token exchange returns invalid_grant after synthetic authorization.",
    phase: "AUTH_TOKEN_ACQUISITION",
    category: "oauth_token",
    retryable: false,
    operatorAction: "reauthorize",
    applicableProfiles: allProfiles,
    effect: "reject-grant",
  },
  {
    id: "oauth-wrong-resource-audience",
    displayName: "Wrong token resource",
    description: "Rejects the synthetic access token because its MCP resource audience is wrong.",
    phase: "AUTH_RESOURCE_VALIDATION",
    category: "oauth_wrong_audience",
    retryable: false,
    operatorAction: "reauthorize",
    applicableProfiles: allProfiles,
    effect: "reject-audience",
  },
  {
    id: "oauth-insufficient-scope",
    displayName: "MCP resource scope missing",
    description: "Returns HTTP 403 at the MCP resource before any provider operation runs.",
    phase: "AUTH_RESOURCE_VALIDATION",
    category: "oauth_insufficient_scope",
    retryable: false,
    operatorAction: "reauthorize",
    applicableProfiles: allProfiles,
    effect: "reject-scope",
  },
  {
    id: "mcp-version-unsupported",
    displayName: "MCP protocol version unsupported",
    description: "Rejects initialize because no offered version is accepted.",
    phase: "MCP_VERSION",
    category: "mcp_version",
    retryable: false,
    operatorAction: "check_configuration",
    applicableProfiles: allProfiles,
    effect: "reject-version",
  },
  {
    id: "mcp-initialize-malformed",
    displayName: "Malformed initialize response",
    description: "Returns an initialize result with a mismatched JSON-RPC identifier.",
    phase: "MCP_INITIALIZE",
    category: "mcp_initialize",
    retryable: false,
    operatorAction: "contact_provider",
    applicableProfiles: allProfiles,
    effect: "malform-initialize",
  },
  {
    id: "mcp-session-expired",
    displayName: "MCP session expired",
    description: "Expires the session on its first post-initialize request and returns HTTP 404.",
    phase: "CONTINUITY_SESSION",
    category: "mcp_session_expired",
    retryable: true,
    operatorAction: "reinitialize",
    applicableProfiles: allProfiles,
    effect: "expire-session",
  },
  {
    id: "mcp-initialized-rejected",
    displayName: "Initialized notification rejected",
    description: "Rejects notifications/initialized instead of returning HTTP 202.",
    phase: "MCP_INITIALIZED",
    category: "mcp_lifecycle",
    retryable: false,
    operatorAction: "contact_provider",
    applicableProfiles: allProfiles,
    effect: "reject-initialized",
  },
  {
    id: "mcp-wrong-content-type",
    displayName: "Wrong MCP content type",
    description: "Returns text/html for a successful-looking MCP request.",
    phase: "MCP_TRANSPORT",
    category: "mcp_transport",
    retryable: false,
    operatorAction: "check_provider_metadata",
    applicableProfiles: allProfiles,
    effect: "wrong-content-type",
  },
  {
    id: "mcp-broken-sse",
    displayName: "Malformed SSE response",
    description: "Returns an incomplete SSE data frame when the scenario uses SSE.",
    phase: "MCP_TRANSPORT",
    category: "mcp_transport",
    retryable: true,
    operatorAction: "retry_after",
    applicableProfiles: allProfiles,
    effect: "broken-sse",
  },
  {
    id: "mcp-empty-tool-catalog",
    displayName: "Empty tool catalog",
    description: "Returns a protocol-valid empty tools/list result that fails this lab's enterprise readiness policy; it is not classified as an MCP connection failure.",
    phase: "MCP_TOOL_DISCOVERY",
    category: "catalog_empty",
    retryable: false,
    operatorAction: "inspect_provider",
    applicableProfiles: allProfiles,
    effect: "empty-catalog",
  },
  {
    id: "mcp-catalog-cursor-loop",
    displayName: "Tool catalog cursor loop",
    description: "Repeats the same nextCursor so bounded clients must stop and classify the catalog as incomplete.",
    phase: "MCP_TOOL_DISCOVERY",
    category: "mcp_pagination_loop",
    retryable: false,
    operatorAction: "contact_provider",
    applicableProfiles: allProfiles,
    effect: "repeat-cursor",
  },
  {
    id: "mcp-duplicate-tool",
    displayName: "Duplicate tool across pages",
    description: "Repeats a tool name on a later catalog page.",
    phase: "MCP_TOOL_DISCOVERY",
    category: "mcp_duplicate_tool",
    retryable: false,
    operatorAction: "contact_provider",
    applicableProfiles: allProfiles,
    effect: "duplicate-tool",
  },
  {
    id: "mcp-invalid-tool-schema",
    displayName: "Invalid tool input schema",
    description: "Returns one tool whose JSON Schema required keyword has the invalid string shape instead of an array.",
    phase: "MCP_TOOL_DISCOVERY",
    category: "mcp_invalid_tool_schema",
    retryable: false,
    operatorAction: "contact_provider",
    applicableProfiles: allProfiles,
    effect: "invalid-tool-schema",
  },
  {
    id: "provider-authorization-denied",
    displayName: "Provider ACL denied",
    description: "Returns an MCP tool result with isError true and ServiceNow/Microsoft-style authorization evidence.",
    phase: "PROVIDER_AUTHORIZATION",
    category: "provider_authorization_denied",
    retryable: false,
    operatorAction: "request_provider_access",
    applicableProfiles: allProfiles,
    effect: "provider-authorization-denial",
  },
  {
    id: "provider-policy-denied",
    displayName: "Provider governance policy denied",
    description: "Returns an MCP tool result with isError true for a tenant policy or guardian decision, distinct from ACLs.",
    phase: "PROVIDER_AUTHORIZATION",
    category: "provider_policy_denied",
    retryable: false,
    operatorAction: "request_provider_access",
    applicableProfiles: allProfiles,
    effect: "provider-policy-denial",
  },
  {
    id: "provider-throttled",
    displayName: "Provider throttled",
    description: "Returns an MCP tool error carrying retry-after and a synthetic provider request identifier.",
    phase: "PROVIDER_EXECUTION",
    category: "provider_throttled",
    retryable: true,
    operatorAction: "retry_after",
    applicableProfiles: allProfiles,
    effect: "provider-throttle",
  },
  {
    id: "provider-unavailable",
    displayName: "Provider temporarily unavailable",
    description: "Returns an MCP tool error representing a transient provider 503.",
    phase: "PROVIDER_EXECUTION",
    category: "provider_unavailable",
    retryable: true,
    operatorAction: "retry_after",
    applicableProfiles: allProfiles,
    effect: "provider-unavailable",
  },
  {
    id: "mutation-timeout-after-commit",
    displayName: "Mutation committed before disconnect",
    description: "Commits the synthetic mutation ledger entry and closes the connection before returning a result.",
    phase: "PROVIDER_EXECUTION",
    category: "mutation_indeterminate",
    retryable: false,
    operatorAction: "reconcile_before_retry",
    applicableProfiles: [
      "synthetic-enterprise-oauth-mcp",
      "servicenow-inbound-quickstart",
      "microsoft-work-iq",
      "agent-365-mail-v1-2026-07",
    ],
    effect: "commit-then-disconnect",
  },
  {
    id: "redirect-uri-whitelist",
    displayName: "Redirect URI whitelist rejection",
    description: "Rejects an otherwise valid OAuth authorization request because the provider has not allowlisted the exact OmniRush.ai callback URI.",
    phase: "AUTH_USER_OR_WORKLOAD",
    category: "oauth_redirect_uri_whitelist",
    retryable: false,
    operatorAction: "register_client",
    applicableProfiles: allProfiles,
    effect: "redirect-uri-whitelist",
  },
  {
    id: "per-connector-redirect",
    displayName: "Per-connector redirect required",
    description: "Rejects the authorization-code token exchange with the same safe evidence OmniRush.ai surfaces when a provider expects a per-connector callback instead of the shared callback.",
    phase: "AUTH_TOKEN_ACQUISITION",
    category: "oauth_token",
    retryable: false,
    operatorAction: "register_client",
    applicableProfiles: allProfiles,
    effect: "per-connector-redirect",
  },
  {
    id: "dcr-required",
    displayName: "Dynamic client registration required",
    description: "Rejects manual OAuth authorization so OmniRush.ai can prove the gateway requires DCR before a connection can proceed.",
    phase: "AUTH_USER_OR_WORKLOAD",
    category: "oauth_dynamic_registration_required",
    retryable: false,
    operatorAction: "register_client",
    applicableProfiles: allProfiles,
    effect: "dcr-required",
  },
  {
    id: "method-405",
    displayName: "GET method returns HTTP 405",
    description: "Returns HTTP 405 to a GET request at the MCP endpoint instead of starting OAuth discovery.",
    phase: "HTTP_ROUTING",
    category: "mcp_method_405",
    retryable: false,
    operatorAction: "check_provider_metadata",
    applicableProfiles: allProfiles,
    effect: "method-405",
  },
  {
    id: "duplicate-amplification",
    displayName: "Duplicate upstream request amplification",
    description: "Models a hostile gateway that turns one MCP tool call into duplicate upstream provider requests.",
    phase: "PROVIDER_EXECUTION",
    category: "provider_duplicate_request",
    retryable: false,
    operatorAction: "reconcile_before_retry",
    applicableProfiles: allProfiles,
    effect: "duplicate-amplification",
  },
  {
    id: "refresh-expired",
    displayName: "Expired refresh credential",
    description: "Rejects refresh-token continuity with an expired-credential response that requires member reauthorization.",
    phase: "CONTINUITY_REFRESH",
    category: "oauth_credential_expired",
    retryable: true,
    operatorAction: "reauthorize",
    applicableProfiles: allProfiles,
    effect: "refresh-expired",
  },
  {
    id: "trailing-dot-url",
    displayName: "Trailing-dot OAuth URL",
    description: "Publishes an authorization-server URL whose host contains a stray trailing dot.",
    phase: "AUTH_ISSUER_DISCOVERY",
    category: "oauth_trailing_dot_url",
    retryable: false,
    operatorAction: "check_provider_metadata",
    applicableProfiles: allProfiles,
    effect: "trailing-dot-url",
  },
  {
    id: "per-user-403",
    displayName: "Per-user provider authorization 403",
    description: "Returns HTTP 403 during tool discovery with the safe authorization wording shown for user-scoped provider permission failures.",
    phase: "PROVIDER_AUTHORIZATION",
    category: "provider_per_user_403",
    retryable: false,
    operatorAction: "request_provider_access",
    applicableProfiles: allProfiles,
    effect: "per-user-403",
  },
]))

export function listFaultDefinitions(profileId?: ProviderProfileId): readonly FaultDefinition[] {
  return profileId ? deepFreeze(faults.filter((fault) => fault.applicableProfiles.includes(profileId))) : faults
}

export function getFaultDefinition(faultId: string): FaultDefinition | undefined {
  return faults.find((fault) => fault.id === faultId)
}