Skip to content

feat(meta): add spec-validator tool#336

Merged
potiuk merged 3 commits into
apache:mainfrom
justinmclean:spec-validator
May 27, 2026
Merged

feat(meta): add spec-validator tool#336
potiuk merged 3 commits into
apache:mainfrom
justinmclean:spec-validator

Conversation

@justinmclean

@justinmclean justinmclean commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

validate spec frontmatter and b…ody sections

Adds tools/spec-validator/, a stdlib-only uv tool analogous to tools/skill-validator/ that validates every .md file carrying a YAML frontmatter block in tools/spec-loop/specs/:

  1. Required frontmatter keys (title, status, kind, mode, source, acceptance)
  2. Valid status / kind / mode values
  3. Non-empty acceptance list
  4. Required body sections (What it does, Where it lives, Behaviour & contract, Out of scope, Acceptance criteria, Validation)
  5. Validation section contains at least one fenced code block

Files without frontmatter (README.md, overview.md) are silently skipped. 56 tests pass; 11 live specs from the control branch validate clean.

Note: all 7 IMPLEMENTATION_PLAN.md items were found to be merged or in-flight before this iteration; this item was derived from the Known gap in specs/meta-and-quality-tooling.md ("a spec validator analogous to the skill validator"). A plan/update beat should reconcile.

Generated-by: Claude (Opus 4.7)

Summary

Type of change

  • Skill change (.claude/skills/<name>/) — eval fixtures updated below
  • Tool / bridge contract (tools/<system>/*.md)
  • Python package (tools/*/ with pyproject.toml)
  • Groovy reference impl
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation (docs/, README.md, CONTRIBUTING.md)
  • Project template (projects/_template/)
  • CI / dev loop (prek, workflows, validators)
  • Other:

Test plan

  • prek run --all-files passes
  • For Python packages touched: uv run pytest / ruff check / mypy passes
  • For Groovy bridges touched: command-line invocation tested end-to-end
  • For skill changes: eval suite passes for the affected skill
    (PYTHONPATH=tools/skill-evals/src python3 -m skill_evals.runner tools/skill-evals/evals/<skill>/)
  • For skill behaviour changes: a new or updated eval fixture is included in this PR
    (a regression test for the bug fixed / the behaviour added — see CONTRIBUTING.md)
  • Other: also run teh tool - no issues

@justinmclean justinmclean self-assigned this May 27, 2026
Comment thread tools/spec-validator/tests/test_spec_validator.py Fixed
Comment thread tools/spec-validator/tests/test_spec_validator.py Fixed
justinmclean and others added 2 commits May 28, 2026 01:25
…ody sections

Adds tools/spec-validator/, a stdlib-only uv tool analogous to
tools/skill-validator/ that validates every .md file carrying a YAML
frontmatter block in tools/spec-loop/specs/:

  1. Required frontmatter keys (title, status, kind, mode, source, acceptance)
  2. Valid status / kind / mode values
  3. Non-empty acceptance list
  4. Required body sections (What it does, Where it lives,
     Behaviour & contract, Out of scope, Acceptance criteria, Validation)
  5. Validation section contains at least one fenced code block

Files without frontmatter (README.md, overview.md) are silently skipped.
56 tests pass; 11 live specs from the control branch validate clean.

Note: all 7 IMPLEMENTATION_PLAN.md items were found to be merged or
in-flight before this iteration; this item was derived from the Known
gap in specs/meta-and-quality-tooling.md ("a spec validator analogous
to the skill validator"). A plan/update beat should reconcile.

Generated-by: Claude (Opus 4.7)
The capability-sync check from apache#340 requires every tool with a
`**Capability:**` declaration to carry a row in
`docs/labels-and-capabilities.md`, and every tool README to declare
its capability. `tools/spec-validator/README.md` predates the rule;
add the line (matches sibling meta tools — `skill-and-tool-validator`,
`spec-loop` — at `capability:setup`) and the corresponding table row.

Also fix a stale ref in the README: `tools/skill-validator/` →
`tools/skill-and-tool-validator/` (renamed in apache#340).

Generated-by: Claude Code (Opus 4.7)

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean stdlib-only validator analogous to skill-and-tool-validator on
the spec side. 7 validation rules (required frontmatter keys, enum values
for status/kind/mode, non-empty acceptance, required body sections,
fenced code block in Validation), and a hand-rolled YAML-lite parser
that correctly skips files lacking frontmatter (README.md, overview.md)
and tolerates the SPDX HTML-comment header that prefixes every spec.

Verified locally

  • 57 tests pass (uv run --project tools/spec-validator --group dev pytest).
  • Tool runs cleanly against the live specs (spec-validator: OK (no violations))
    via uv run --project tools/spec-validator spec-validate.
  • skill-and-tool-validate exits 0 across the repo after the fixup commit
    (no hard violations).

Fixup landed on top of your commit

Added a small chore: commit to satisfy the capability-sync check from
#340 that the PR predated:

  • tools/spec-validator/README.md — added **Capability:** capability:setup
    (matches sibling meta tools — skill-and-tool-validator, spec-loop).
  • docs/labels-and-capabilities.md — added the corresponding tool-table
    row.
  • Also fixed a stale ref in the README: tools/skill-validator/
    tools/skill-and-tool-validator/ (renamed in #340).

This review was drafted by an AI-assisted tool and confirmed by an Apache Steward
maintainer. The maintainer approving this PR has read the findings and signed off.
If something feels off, please reply on the PR and a maintainer will follow up.

More on how Apache Steward handles maintainer review:
CONTRIBUTING.md.

CodeQL flagged two unused names in `tests/test_spec_validator.py`:
- unused imports `REQUIRED_FRONTMATTER_KEYS` and `validate_file`
- unused local variable `text` in `test_missing_code_block` (left over
  from an earlier draft; the test already uses `spec_no_code` for the
  actual assertion)

Remove all three. Ruff clean; 57 tests still pass.

Generated-by: Claude Code (Opus 4.7)
@potiuk potiuk merged commit 8e474a7 into apache:main May 27, 2026
15 of 16 checks passed
@justinmclean justinmclean deleted the spec-validator branch May 28, 2026 00:34
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.

3 participants