Skip to content

feat(schema): reject prefix-overlapping field paths (#194)#195

Merged
zeevdr merged 1 commit into
mainfrom
prefix-overlap-lint
Apr 27, 2026
Merged

feat(schema): reject prefix-overlapping field paths (#194)#195
zeevdr merged 1 commit into
mainfrom
prefix-overlap-lint

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented Apr 27, 2026

Closes #194.

Summary

  • Adds a cross-field lint at `ImportSchema` time: no field path may be a strict prefix of another (e.g. `payments` alongside `payments.fee`).
  • Independent of CEL — driven by the schema-as-tree consumers (UI, code generators, doc generators, future `self` binding for CEL CEL expressions for advanced validation #76).
  • Algorithm: sort paths, scan adjacent pairs, fail if `A + "."` prefixes `B`. Sorted-pair adjacency is sufficient (proof in code comment).
  • ~40 µs at 1000 fields per the included bench.

Test plan

  • Unit tests cover: empty input, single field, no-overlap siblings, direct overlap, deep gap (`payments` → `payments.refunds.window` with no intermediate node), transitive cousins, substring-not-prefix (`payment` vs `payments` — must NOT trigger), siblings with common prefix (`payments.fee` vs `payments.fees` — must NOT trigger), unsorted input
  • Benchmarks at 10 / 100 / 1000 fields, plus an early-conflict case
  • `make test` passes (full suite)
  • `make lint` passes
  • Existing fixtures across the repo verified clean (Python scan walked all `.yaml` / `.yml`, zero violations)

Fixes #194.

Adds a cross-field lint at ImportSchema time: no field path may be a
strict prefix of another field path (e.g. "payments" alongside
"payments.fee"). Such schemas cannot be presented as a tree without
ambiguity — the same node would be both a typed leaf and a parent
containing other leaves. Tooling that consumes the schema as a tree
(UI, code generators, doc generators, future CEL `self` binding) all
hit the same conflict.

Independent of CEL, but required for the `self` tree shape per the
discovery brief in .agents/context/cel-validation.md.

Algorithm: sort paths, walk adjacent pairs, fail if A + "." prefixes B.
Sorted-pair adjacency is sufficient — if A is a strict prefix of any
path B, no other path C can sort between them without also being
prefixed by A. ~40us at 1000 fields (see bench).

Existing fixtures verified clean (no prefix-overlap violations).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zeevdr zeevdr added this to the Schema Spec v0.1.0 milestone Apr 27, 2026
@zeevdr zeevdr added server Server changes size: S Quick win — a few hours or less priority: P1 Current milestone work labels Apr 27, 2026
@zeevdr zeevdr merged commit 1d45d2e into main Apr 27, 2026
18 checks passed
@zeevdr zeevdr deleted the prefix-overlap-lint branch April 27, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P1 Current milestone work server Server changes size: S Quick win — a few hours or less

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint rule: reject schemas where one field path is a strict prefix of another

1 participant