Repository navigation
feat(core): emit JSON Schema artifacts for the on-disk .basou/ formats - #42
Merged
Merged
Conversation
`@basou/core` now ships JSON Schema artifacts for every on-disk `.basou/` document, generated from the canonical Zod schemas (zod v4's built-in `z.toJSONSchema`) so they cannot drift from validation. Non-JavaScript / cross-language tooling and editors can now validate `.basou/` files directly, without reimplementing the format. One schema per document: manifest, session, event (a `oneOf` over the event type), task, approval, status, task-index, and session-import. Each is a draft 2020-12 document with a stable `$id` (`https://basou.dev/schemas/0.1.0/<name>.schema.json`), published under the package's `./schemas/*` export (e.g. `@basou/core/schemas/session.schema.json`) and listed in `files`. The artifacts describe what a consumer AUTHORS on disk: generated in `io: "input"` mode so a field with a `.default()` (e.g. `events_log`) stays optional rather than required, and a non-strict object allows additive fields; only the `.strict()` event variants (e.g. `adapter_output`) keep `additionalProperties: false`. Prefixed-id fields carry a faithful ULID `pattern` via schema metadata on the shared id factory (validation behavior is unchanged; the existing `.refine` still gates acceptance). Other refinement-only constraints are not expressible in JSON Schema and are omitted. Generation and guards: - `pnpm --filter @basou/core gen:schemas` builds, then regenerates the committed `packages/core/schemas/*.json` from `buildJsonSchemas()`. - A drift-guard test asserts every committed file still matches the Zod source byte-for-byte, so a schema change without regeneration fails CI. - An ajv (draft 2020-12) round-trip test validates a representative document per schema, plus the input-mode cases (defaulted fields may be omitted; a non-strict event accepts an additive field) and that the ULID pattern rejects a malformed id. - The generated `schemas/` dir is excluded from biome (a generated artifact, like `dist`), so the formatter does not fight the generator's output. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
takashi-matsuyama
added a commit
that referenced
this pull request
Jun 4, 2026
…s) (#43) Promote the Unreleased section to 0.6.0 and bump all four package manifests (core / cli / sdk / basou) to 0.6.0 in lockstep. Highlights since 0.5.0: - billing-grade work-measurement v2: Codex active time from real per-turn intervals, plus a machine_active_time_ms model-compute measure (#40). - @basou/sdk v0.2: a runtime, read-only programmatic API over @basou/core's readers for reading .basou/ provenance (#41). - @basou/core JSON Schema artifacts for the on-disk formats, generated from the Zod schemas and shipped under ./schemas/* (#42). Also: document the four-package lockstep bump in CONTRIBUTING, and record the 0.6.0 pre-publish dry-run tarball contents in the release checklist (core now ships its schemas/, cli ships two entry points). This commit only prepares the release; tagging v0.6.0 and the OIDC publish remain maintainer actions. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@basou/corenow ships JSON Schema artifacts for every on-disk.basou/document, generated from the canonical Zod schemas (zod v4's built-inz.toJSONSchema) so they cannot drift from validation. Non-JavaScript / cross-language tooling and editors can now validate.basou/files directly. This is the schema-reference artifact unblocked by the@basou/sdkv0.2 keystone (per the operator's own plan: deferred until a programmatic consumer existed).One schema per document —
manifest,session,event(aoneOfover the event type),task,approval,status,task-index,session-import— each a draft 2020-12 document with a stable$id(https://basou.dev/schemas/0.1.0/<name>.schema.json), published under the package's./schemas/*export (e.g.@basou/core/schemas/session.schema.json) and listed infiles.Design (operator-confirmed)
patternvia.meta()on the shared id factory — metadata only, validation behavior unchanged (the.refinestill gates acceptance). Verified to accept all 79 real local session ids and reject malformed ones.$iduses basou.dev (a stable identifier; need not resolve).Correctness (from adversarial review)
Artifacts are generated in
io: "input"mode, so they describe what a consumer authors on disk, not Zod's parsed output:.default()(e.g.events_log) stays optional, notrequired;additionalProperties: false), while the.strict()event variants (e.g.adapter_output) keepadditionalProperties: false.Without this, the artifacts would falsely reject valid on-disk files — the opposite of their purpose.
Generation & guards
pnpm --filter @basou/core gen:schemasbuilds, then regenerates the committedpackages/core/schemas/*.jsonfrombuildJsonSchemas().schemas/dir is excluded from biome (a generated artifact, likedist).Compatibility
Additive: new
./schemas/*export,gen:schemasscript, andajv/ajv-formatsdevDependencies. No@basou/coreruntime-API or on-disk-format change. Branches frommain(which now carries #40 + #41).Test plan
pnpm -r build && pnpm typecheck && pnpm test && pnpm lintall green (core 732 + sdk 17 + cli 417; lint clean apart from pre-existing unrelated warnings).gen:schemasyields no diff).🤖 Generated with Claude Code