Skip to content

Extend schema-drift test to all schema-paired types #16

Description

@AimTune

packages/core/src/domain/value-objects/__tests__/schema-drift.test.ts mechanically guards ThemeConfig and its sub-objects (colors, layout, avatar, end-of-conversation survey) against schemas/theme.schema.json. The same drift policy is documented in AGENTS.md → Schema Sync Rule for every other JSON-serialisable type — but only ThemeConfig has the test. We want the same protection for the rest.

Tasks

  • Connector option types — pair each Options interface with its schema:
    • WebSocketConnectorOptionsschemas/connectors/websocket.schema.json
    • SignalRConnectorOptionsschemas/connectors/signalr.schema.json
    • DirectLineConnectorOptionsschemas/connectors/directline.schema.json
    • SseConnectorOptionsschemas/connectors/sse.schema.json
    • HttpConnectorOptionsschemas/connectors/http.schema.json
    • DummyConnector constructor options ↔ schemas/connectors/dummy.schema.json
  • Domain entities and value objects:
    • IncomingMessageschemas/messages/incoming-message.schema.json
    • OutgoingMessageschemas/messages/outgoing-message.schema.json
    • MessageActionschemas/messages/message-action.schema.json
    • HistoryResultschemas/messages/history-result.schema.json
    • Conversationschemas/messages/conversation.schema.json
    • SurveyPayloadschemas/messages/survey-payload.schema.json
    • AIChunk (union) ↔ schemas/genui/ai-chunk.schema.json

Approach

Each new test follows the same pattern as the existing one:

const EXPECTED: { [K in keyof Required<T>]: true } = { /* ... */ };
expect(keys(schema.properties)).toEqual(keys(EXPECTED));

The mapped-type contract catches TS-only drift; the JSON read catches schema-only drift. For AIChunk's discriminated-union case, iterate schema.oneOf[*].properties and compare each variant.

Some connectors live outside @chativa/core — the test for them belongs in their own package's __tests__ folder, not in core, to avoid a cross-package import.

Acceptance criteria

  • One drift test per type listed above.
  • All tests pass on pnpm test.
  • Updating the type without the schema fails typecheck or the test.

Spun out of todos.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions