Commit Graph

18 Commits

Author SHA1 Message Date
fc1a6db1dc refactor(validation): fold the tagged validator onto one framework
The tagged-node validator carried its own copy of the validation machinery:
a Tagged.Rule cloning Validation's check type and a Tagged.Context cloning
its context, differing only in subject type. That is the per-layer
duplication the validation idiom exists to prevent (principle 10).

Generalise the type-directed framework over both the subject and the
document: SubjectContext, Check, and AnyCheck now take a Document type
parameter for the validated tree's root. The model layer validates with a
Model.Value document, the tagged layer with a Tagged.Node document, each
truthful rather than forcing one root type to stand in for the other.

The tagged layer keeps only what is genuinely its own: the Node document
type, its built-in check (now Tagged.BuiltinCheck, a Check<Node, Node>), and
its traversal. Tagged.Rule and the tagged Context are removed. The validator
surface is unchanged but validating now takes a Check<Node, Node>.

All 399 tests pass; the coverage gate reconciles to 62 public types.
2026-06-28 10:41:10 +02:00
2e45ecaffe feat(validation): add type-directed Check dispatch
Introduce the core of the validation-rules idiom: a Check<Subject> with a
positive description, a when predicate, and a Bool or multi-error check
that fires only on values of its Subject type wherever they occur. AnyCheck
erases the subject and dispatches by runtime type, guarding an optional or
a wrong type from matching. The validator gains a checks list, a
validating(_:) overload, and a traversal that offers each node the values
it may specialise on. BuiltinCheck.mappingKeysAreUnique is the
type-directed counterpart of the legacy rule.

The machinery has its own negative tests (wrong type, optional, false
predicate yield nothing; same type twice yields two errors) and the builtin
ships a failing and a near-miss test. The coverage gate catches the five
new public types, which are classified as validation machinery. The default
validator is unchanged, so this is additive; retiring the legacy Rule,
moving the default onto the check, the combinator algebra, the error
rendering, and de-duplicating the Tagged validator are the remaining steps.
2026-06-28 07:23:23 +02:00
85663682a2 build: enforce validation coverage over every public type
Adopt the validation-rules discipline that every public type is either
validated or excluded, enforced mechanically rather than by review. A new
gate enumerates the public surface from the compiler symbol graph and
fails the build, naming the type, if any public type is missing from the
coverage manifest or any manifest entry is no longer public.

scripts/validation-coverage.tsv classifies all 58 public types: the value
models with the mapping-key-uniqueness runtime invariant are validated,
and the namespaces, closed sum types, data-transfer values, error types,
and engine machinery are excluded with a one-line reason each. The gate
runs in check-all.sh and CI; a planted unclassified type was confirmed to
fail it.

This is the coverage-first phase of moving the validation layer to the
type-directed Validation idiom; the framework backing the validated
entries, the de-duplication of the Tagged validator machinery, and the
exhaustive tests follow.
2026-06-28 05:00:54 +02:00
9298536e52 test: measure conformance against the official YAML test-suite
Adds an opt-in harness that runs PureYAML over the canonical YAML 1.2
corpus (github.com/yaml/yaml-test-suite) and reports a parse-level pass
rate: a should-parse case must parse, a should-error case must be
rejected. The data is fetched into a gitignored location by
scripts/fetch-yaml-test-suite.sh, never vendored, and the run is gated
behind PUREYAML_RUN_YAML_TEST_SUITE=1 so the default suite is unaffected.

This turns 'best YAML library' from an assertion into a tracked number.
Baseline: 211/333 (63.4%) parse-level: 177/255 valid documents parse,
34/78 invalid documents are rejected. So 78 valid docs are not yet parsed
and 44 invalid docs are wrongly accepted. The stricter value-level check
against each case's in.json is the next step.
2026-06-26 17:43:19 +02:00
c4f7f9dccc refactor(code-style): one top-level type per source file
Split the six files that declared multiple sibling types under one
namespace extension so each file declares exactly one top-level type:
the Tagged node component types (Node, NodeKind, Scalar, Sequence,
Mapping, Pair), the validation report types (Report, Source,
SourceReport, BatchReport), DiagnosticKind, TokenKind, ScannerFlowContext
kind, and the event-stream composer helpers. Public type names are
unchanged; the shared report-rendering helpers move from file-private to
internal so the split report types still reach them.

Make check-namespacing.sh namespace-aware: the previous column-anchored
scan was blind to types declared inside indented extension blocks, so it
passed while the rule was violated. It now counts direct members of a
PureYAML namespace extension and ignores nested types and private helpers.
2026-06-26 06:14:21 +02:00
5f3892f2c1 chore(rules): vendor the rules-swift canon into docs/rules-swift
Mirror the shared Swift rules canon (rules-swift, commit 4ebb892) into
docs/rules-swift/ as a read-only reference alongside the repo's tailored
docs/rules/. PROVENANCE.md records the source, commit, and what was
included or excluded; the upstream repo's own VCS, CI, and lint tooling
is omitted as machinery rather than rule content.

Exclude the vendored tree from the style gate (scripts/check-style.sh)
and the pre-commit hook: the canon's enforcement docs quote the
forbidden attribution phrases to define them, the same reason the
repo's own enforcement files are already excluded.
2026-06-26 05:36:12 +02:00
7006d1eb52 chore(style): skip vendored yaml fixture corpora
Keep repo prose checks focused on authored files while preserving upstream fixture contents verbatim.
2026-06-06 08:25:03 +02:00
208b892019 feat(parser): harden diagnostics and streaming
Add structured validation diagnostics, JSON and Yams comparison gates, and lazy token/event parsing so production behavior is measured without retaining full intermediate parser arrays.
2026-06-06 07:57:48 +02:00
b47ca4fc31 ci: run optimized build gates 2026-06-05 22:36:28 +02:00
3a90df095d fix(ci): prepare 0.1.0 release 2026-06-05 21:20:20 +02:00
bc54528353 Harden parser against real YAML fixtures 2026-06-05 19:34:30 +02:00
611c079255 test(coding): add sequence fixtures and contract gate 2026-06-05 12:33:09 +02:00
b61ed10fb2 docs(roadmap): collapse completed epic diagrams 2026-06-05 10:50:13 +02:00
c25c35f82c ci(gates): add full local verification script 2026-06-05 10:24:04 +02:00
788126e3a0 docs(roadmap): follow tiledown mermaid palette 2026-06-05 07:04:46 +02:00
03779526b2 docs(roadmap): use apple web colors 2026-06-05 06:59:32 +02:00
18adb7db5b docs(roadmap): add parser roadmap epic tracking 2026-06-05 06:46:20 +02:00
9c718e3303 feat(package): bootstrap pure swift yaml package 2026-06-05 06:34:20 +02:00