ADR 0003 — TypeScript contracts with Zod 4, exported as JSON Schema and OpenAPI

Status: accepted. Date: 2026-12-03.

Decision

  • Input, output, entity and event schemas are Zod 4. @fellowframework/core re-exports z to guarantee a single instance.
  • Handler output is always validated by the output schema: undeclared fields never leave the server.
  • fellow intel and fellow openapi convert the schemas to JSON Schema and OpenAPI 3.1. There is no proprietary format.
  • The manifest stores only what cannot be derived (id, version, dependencies, permissions). Routes, entities, events and migrations are discovered from the files and checked by the validator.

Consequences

  • The public contract is coupled to Zod. Exit path: Standard Schema, which Zod 4 implements.
  • Discovery imports the module files; code with side effects at the top level of a module would run during fellow check.

Conditions for reassessment

There is demand for another schema library, or import-based discovery proves slow or unsafe (alternative: static analysis).