Skip to content

fix(schema): document strict Ajv use and test the schema compiles strictly - #201

Open
ara-stock wants to merge 2 commits into
flop-labs:mainfrom
ara-stock:fix/199-strict-ajv
Open

ara-stock wants to merge 2 commits into
flop-labs:mainfrom
ara-stock:fix/199-strict-ajv

Conversation

@ara-stock

Copy link
Copy Markdown
Contributor

What

The README now shows how to compile schema/tclk1-frames.schema.json under Ajv's default strict mode: collect every x-tclk-* key the schema uses and register it with ajv.addKeyword before compile. A new test compiles the whole schema that way with a default Ajv2020, and also checks that an unregistered default instance still rejects it. ajv@8.20.0 (already the locked version) is added as a root dev dependency for the test.

Why

Fixes #199 with option (b). A default new Ajv2020().compile(schema) throws on x-tclk-canonicalPattern, and nothing compiled the whole document, so integrators found out at runtime. Following @maho0638's note, the keyword list is derived from the schema instead of hard-coding three names, so #177 / #185 (x-tclk-runtimeConstraint) keep working once merged. Thanks to @vanilla3 and @bdunn77 for confirming the reproduction. The schema and SPEC.md are unchanged.

Checks

  • pnpm install --frozen-lockfile && pnpm -r --include-workspace-root build
  • pnpm -r --include-workspace-root test
  • Golden vectors untouched
  • CHANGELOG.md has an [Unreleased] entry
  • Docs that would now be wrong are updated: README.md
  • New surface on the money path: nothing new

I used an AI assistant (Claude) while preparing this. I reproduced the issue and checked the change and tests myself.

…ictly

Register every x-tclk-* annotation keyword found in the schema, so the
README recipe and the test keep working when a new annotation is added.

Fixes flop-labs#199

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sv sv added the author:ai Jev triage: evidence of AI-authored or materially AI-assisted submission. label Oct 10, 2026
@vanilla3

Copy link
Copy Markdown

Thanks for picking this up. Deriving the keyword set from the schema, as @maho0638 suggested, is better than the hard-coded three names in the patch I'd prepared.

One small thing in the README snippet: import Ajv2020 from "ajv/dist/2020.js" followed by new Ajv2020() runs fine in Node. Under TypeScript with module: "Node16", the same setting as this repo's tsconfig.base.json, it fails with TS2351: This expression is not constructable. CI doesn't catch it because tsconfig.json only includes src, and vitest doesn't type-check. The named export type-checks and runs:

import { Ajv2020 } from "ajv/dist/2020.js";

Checked on 5cc4ab9 with ajv 8.20.0 by copying the snippet verbatim into a .ts file. tsc --module node16 --moduleResolution node16 --strict exits 1 with the default import and 0 with the named one, and both forms run under Node. The same change would apply to the import in tests/schema-strict.test.ts, for consistency.

… under Node16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ara-stock

Copy link
Copy Markdown
Contributor Author

Thanks, reproduced: with --module node16 the default import gives TS2351 and the named export type-checks. Switched both the README snippet and tests/schema-strict.test.ts to import { Ajv2020 } from "ajv/dist/2020.js" in 73b582a; the test still passes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:ai Jev triage: evidence of AI-authored or materially AI-assisted submission.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

schema: tclk1-frames.schema.json doesn't compile under ajv's default strict mode (x-tclk-* registry keywords)

3 participants