Skip to content

Add hermetic config-schema validation for JSON and YAML files - #54

Open
CallumHoward wants to merge 1 commit into
mainfrom
claude/great-meitner-510jzd
Open

CallumHoward wants to merge 1 commit into
mainfrom
claude/great-meitner-510jzd

Conversation

@CallumHoward

@CallumHoward CallumHoward commented Jun 21, 2026 •

Copy link
Copy Markdown
Owner

Adds a hermetic gate that validates every tracked config file referencing a schema, in CI and pre-commit. Schemas are vendored, so checks run offline and don't flake when upstream changes.

How it works

  • A file is checked if it has a top-level "$schema" (JSON/JSONC), a # yaml-language-server: $schema= modeline, or a $schema: key (YAML).
  • schemas/manifest.json maps each schema URL to a vendored copy under schemas/. Nothing is fetched at check time.
  • Files are parsed (JSONC tolerates comments; YAML via yaml) and validated with Ajv, draft-04 through 2020-12, picked from the schema.
  • pnpm schemas:update is the only networked step. It refreshes the vendored copies as a reviewable diff.

Files validated (9, all pass)

File Schema
.fallowrc.json fallow
tsconfig.json schemastore tsconfig
public/manifest.json schemastore web-manifest (+3 vendored siblings)
.claude/settings.json schemastore claude-code-settings
.github/workflows/ci.yml, update-pnpm.yml schemastore github-workflow
lefthook.yml lefthook
.github/dependabot.yml schemastore dependabot-2.0
pnpm-workspace.yaml schemastore pnpm-workspace

pnpm-lock.yaml and files without a schema reference are skipped. .mcp.json, .cta.json and .vscode/settings.json have no stable published schema, so they're left alone.

Key files

  • scripts/validate-schemas.ts (pnpm validate:schemas) and scripts/update-schemas.ts (pnpm schemas:update)
  • schemas/: manifest plus vendored copies
  • ci.yml "Validate config schemas" step; lefthook.yml pre-commit job over staged *.{json,jsonc,yml,yaml}
  • .fallowrc.json: excludes scripts/** and ignores ajv*, jsonc-parser, yaml

Rebased onto main after #78/#82/#85; full suite and validate:schemas pass.

🤖 Generated with Claude Code

@CallumHoward CallumHoward changed the title Add JSON Schema validation for $schema-bearing files Add hermetic config-schema validation for JSON and YAML files Jun 24, 2026
@CallumHoward
CallumHoward force-pushed the claude/great-meitner-510jzd branch from 302a2a8 to 929d6b9 Compare June 24, 2026 10:07
Comment thread schemas/fallow.schema.json Resolved
A static gate validates every tracked config file that references a
schema, wired into CI and the pre-commit hook. Validation is hermetic:
schemas are vendored in-repo and resolved offline, so it never hits the
network at check time and stays deterministic.

- scripts/validate-schemas.ts (`pnpm validate:schemas`): Ajv-based
  validator (draft-04 .. 2020-12). JSON/JSONC use a top-level "$schema";
  YAML uses a `# yaml-language-server: $schema=` modeline or top-level
  key. Resolves refs to vendored copies under schemas/ via manifest.json.
- Vendored schemas under schemas/ are themselves meta-validated against
  their declared dialect (Ajv ships the meta-schemas, so still hermetic),
  catching a corrupted or mis-edited vendored copy.
- scripts/update-schemas.ts (`pnpm schemas:update`): the only networked
  step; refreshes vendored copies for review.
- $schema/modelines added to tsconfig, public/manifest.json,
  .claude/settings.json, GitHub workflows, lefthook, dependabot,
  pnpm-workspace.
- deps: ajv*, jsonc-parser, yaml (added to fallow ignoreDependencies);
  scripts/** excluded from fallow; schemas/** excluded from oxfmt.
- CI step "Validate config schemas"; pre-commit job over staged
  *.{json,jsonc,yml,yaml}.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B8LKH5sijopQWNJtzqBTN4
@CallumHoward
CallumHoward force-pushed the claude/great-meitner-510jzd branch from 929d6b9 to 66fef06 Compare September 27, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants