feat(schemas): custom schema authoring (#275)#306
Merged
Conversation
Adds a SchemaRegistry that loads built-in YAML bundles via include_str!
and discovers custom schemas under .lean-spec/schemas/, resolves
extends-based inheritance with cycle detection, and protects the
reserved leanspec: prefix from being shadowed by project files.
Surfaces it through a new `leanspec schema {list, show, validate}`
subcommand, an optional `schema_id` on AdapterConfig, a `--schema` flag
on `leanspec create`, and has `leanspec init` scaffold the
`.lean-spec/schemas/` directory.
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
Implements #275 — custom schema authoring for LeanSpec.
SchemaRegistryinleanspec-corethat:leanspec:base,leanspec:feature,leanspec:bug,leanspec:adr) viainclude_str!<project_root>/.lean-spec/schemas/*.yamlextends-based inheritance (child fields/link types override parent by key) with circular-inheritance detectionleanspec:prefix — custom files claiming a built-in id are skipped with a warningleanspec schemaCLI subcommand:schema list— built-in + custom, with field counts andextendsparentsschema show <id>— resolved field list, grouped inline / section, with link typesschema validate <path>— YAML parse, required id/name, identifier regex, parent existence, cycles, empty-enum check-o jsonflagAdapterConfiggains an optionalschema_id(parsed fromleanspec.adapter.yaml)leanspec create --schema <id>forwardsschema_idintoCreateRequestleanspec initscaffolds the.lean-spec/schemas/directoryTest plan
cargo test --workspace— 373 + 62 + ... all passing (no regressions)cargo clippy --workspace -- -D warningscleancargo fmt --checkcleanschema_registry: builtin load, extends flattening, field override, circular detection, unknown parent,leanspec:prefix protection, plus 5validate_schema_filecasesschema list,schema show leanspec:feature,schema show acme:sprint-story(inherited),schema validateon valid + missing-id + circular fixtures, JSON output, prefix-protection warningGenerated by Claude Code