Skip to content

feat: optional per-kind schema validation#30

Merged
DarlingtonDeveloper merged 1 commit into
mainfrom
feat/schema-validation
Mar 14, 2026
Merged

feat: optional per-kind schema validation#30
DarlingtonDeveloper merged 1 commit into
mainfrom
feat/schema-validation

Conversation

@DarlingtonDeveloper
Copy link
Copy Markdown
Contributor

Summary

  • Per-kind metadata schema definitions in cortex.toml for write-time validation
  • Backward compatible — kinds without schemas pass freely
  • Supports required fields, type checking, numeric ranges, and allowed values (enum-like)

Config example

[schemas.decision]
required_fields = ["rationale"]

[schemas.decision.fields.rationale]
type = "string"

[schemas.decision.fields.priority]
type = "number"
min = 1
max = 5

Changes

  • crates/cortex-core/src/gate/schema.rs (NEW) — SchemaValidator, field types, violations
  • crates/cortex-core/src/gate/mod.rs — Schema variant in GateCheck, check_schema() method
  • crates/cortex-core/src/lib.rs — re-exports
  • crates/cortex-server/src/config.rs — schemas config parsing
  • crates/cortex-server/src/cli/init.rs — schemas field in init config

Test plan

  • 10 unit tests (no-schema passthrough, required fields, type mismatch, ranges, allowed values)
  • cargo test --workspace passes
  • cargo clippy --workspace clean

🤖 Generated with Claude Code

Introduces SchemaValidator that validates node metadata against per-kind
schema definitions in cortex.toml. Kinds without schemas pass freely
(backward compatible). Supports required fields, type checking (string,
number, boolean, array), numeric range constraints (min/max), and
allowed values (enum-like).

- New schema module in cortex-core gate with validator logic
- Schema GateCheck variant integrates with WriteGate
- Config parsing for [schemas.*] sections in cortex.toml
- 10 unit tests covering all validation paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DarlingtonDeveloper DarlingtonDeveloper merged commit 824e956 into main Mar 14, 2026
2 of 3 checks passed
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.

1 participant