Skip to content

feat(schemas): custom schema authoring (#275)#306

Merged
tikazyq merged 1 commit into
mainfrom
claude/implement-issue-275-eeijy
May 20, 2026
Merged

feat(schemas): custom schema authoring (#275)#306
tikazyq merged 1 commit into
mainfrom
claude/implement-issue-275-eeijy

Conversation

@tikazyq
Copy link
Copy Markdown
Contributor

@tikazyq tikazyq commented May 20, 2026

Summary

Implements #275 — custom schema authoring for LeanSpec.

  • New SchemaRegistry in leanspec-core that:
    • Embeds the four built-in YAML bundles (leanspec:base, leanspec:feature, leanspec:bug, leanspec:adr) via include_str!
    • Auto-discovers custom schemas under <project_root>/.lean-spec/schemas/*.yaml
    • Resolves extends-based inheritance (child fields/link types override parent by key) with circular-inheritance detection
    • Protects the reserved leanspec: prefix — custom files claiming a built-in id are skipped with a warning
  • New leanspec schema CLI subcommand:
    • schema list — built-in + custom, with field counts and extends parents
    • schema show <id> — resolved field list, grouped inline / section, with link types
    • schema validate <path> — YAML parse, required id/name, identifier regex, parent existence, cycles, empty-enum check
    • JSON output supported via the global -o json flag
  • AdapterConfig gains an optional schema_id (parsed from leanspec.adapter.yaml)
  • leanspec create --schema <id> forwards schema_id into CreateRequest
  • leanspec init scaffolds the .lean-spec/schemas/ directory

Test plan

  • cargo test --workspace — 373 + 62 + ... all passing (no regressions)
  • cargo clippy --workspace -- -D warnings clean
  • cargo fmt --check clean
  • 11 new unit tests in schema_registry: builtin load, extends flattening, field override, circular detection, unknown parent, leanspec: prefix protection, plus 5 validate_schema_file cases
  • Manual smoke: schema list, schema show leanspec:feature, schema show acme:sprint-story (inherited), schema validate on valid + missing-id + circular fixtures, JSON output, prefix-protection warning

Generated by Claude Code

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.
Copilot AI review requested due to automatic review settings May 20, 2026 03:25
@tikazyq tikazyq merged commit 964feb4 into main May 20, 2026
1 check failed
@tikazyq tikazyq deleted the claude/implement-issue-275-eeijy branch May 20, 2026 03:28
@tikazyq tikazyq review requested due to automatic review settings May 20, 2026 03:45
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