diff --git a/apps/daemon/tests/chat-run-inactivity-timeout.test.ts b/apps/daemon/tests/chat-run-inactivity-timeout.test.ts index 831fd584c..77bdd4b47 100644 --- a/apps/daemon/tests/chat-run-inactivity-timeout.test.ts +++ b/apps/daemon/tests/chat-run-inactivity-timeout.test.ts @@ -16,7 +16,6 @@ */ import { afterEach, describe, expect, it } from 'vitest'; -import { API_ERROR_CODES, type ApiErrorCode } from '@open-design/contracts'; import { assertValidRuntimeDefInactivityTimeoutMs, resolveChatRunInactivityTimeoutMs, @@ -217,25 +216,3 @@ describe('assertValidRuntimeDefInactivityTimeoutMs (#2579 fast-fail at def-selec } }); }); - -describe('AGENT_RUNTIME_DEF_INVALID contract surface (#2579 review follow-up)', () => { - // The chat-run startup path emits this code through `design.runs.fail`, - // which feeds the shared SSE/status error envelopes — i.e. the - // daemon/web/CLI wire contract. The previous follow-up introduced the - // string at the daemon emit site only, so downstream consumers reading - // `ApiErrorCode` saw a value not in the union. Land it in - // `packages/contracts/src/errors.ts#API_ERROR_CODES` so the contract - // catches up and any future web/CLI consumer can switch on it. - - it('AGENT_RUNTIME_DEF_INVALID is exposed by the shared contracts package so daemon/web/CLI agree on the union', () => { - expect((API_ERROR_CODES as readonly string[])).toContain('AGENT_RUNTIME_DEF_INVALID'); - }); - - it('the literal is assignable to ApiErrorCode (compile-time wire-contract check)', () => { - // If the union ever loses this member again, the assignment below - // becomes a type error; the runtime expect just keeps the spec - // executable so the regression surfaces in CI. - const code: ApiErrorCode = 'AGENT_RUNTIME_DEF_INVALID'; - expect(code).toBe('AGENT_RUNTIME_DEF_INVALID'); - }); -}); diff --git a/packages/contracts/tests/error-codes.test.ts b/packages/contracts/tests/error-codes.test.ts new file mode 100644 index 000000000..e67c64858 --- /dev/null +++ b/packages/contracts/tests/error-codes.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, it } from 'vitest'; + +import { API_ERROR_CODES, type ApiErrorCode } from '../src/errors'; + +describe('shared API error codes', () => { + it('exposes AGENT_RUNTIME_DEF_INVALID for runtime-def validation failures', () => { + // Chat-run startup emits this code through the shared SSE/status error + // envelopes when a checked-in runtime def is invalid. Keeping the + // assertion in the contracts package ensures contract-only refactors + // cannot drop the literal without this package's own test lane failing. + expect(API_ERROR_CODES).toContain('AGENT_RUNTIME_DEF_INVALID'); + }); + + it('keeps AGENT_RUNTIME_DEF_INVALID assignable to ApiErrorCode', () => { + const code: ApiErrorCode = 'AGENT_RUNTIME_DEF_INVALID'; + expect(code).toBe('AGENT_RUNTIME_DEF_INVALID'); + }); +});