Class: Ucode::Repo::BuildValidator
- Inherits:
-
Object
- Object
- Ucode::Repo::BuildValidator
- Includes:
- AtomicWrites
- Defined in:
- lib/ucode/repo/build_validator.rb
Overview
Walks an output tree produced by CanonicalBuildCommand and runs the four automated validation checks from TODO 21 §Validation:
1. `completeness` — every codepoint folder has both
`index.json` and `glyph.svg`.
2. `schema` — every `index.json` deserializes via
`Ucode::Models::CodePoint.from_hash`.
3. `provenance_sanity` — every deserialized CodePoint carries
a non-nil `glyph.source.tier`.
4. `block_coverage` — per-block built count matches the
supplied baseline (status is `skipped` when no baseline).
Sample inspection (check 5 in TODO 21) is manual and out of scope.
The validator is stateless from the outside: one call to
#validate walks the tree, builds a ValidationReport, and
writes it atomically to output/validation-report.json. Safe
to re-run on the same tree — idempotent via AtomicWrites.
Baseline shape
baseline: is a Hash{String block_name => Integer expected}
— the per-block built count expected from TODO 05's audit.
Missing blocks in the baseline are ignored; blocks present in
the output but absent from the baseline are not flagged (the
baseline is authoritative only for what it covers).
Constant Summary collapse
- CHECK_COMPLETENESS =
"completeness"- CHECK_SCHEMA =
"schema"- CHECK_PROVENANCE =
"provenance_sanity"- CHECK_BLOCK_COVERAGE =
"block_coverage"
Instance Method Summary collapse
-
#initialize(output_root, unicode_version: nil, baseline: nil) ⇒ BuildValidator
constructor
A new instance of BuildValidator.
-
#validate ⇒ Hash
Walk the tree, run all checks, emit validation-report.json.
Methods included from AtomicWrites
#same_content?, #to_pretty_json, #write_atomic
Constructor Details
#initialize(output_root, unicode_version: nil, baseline: nil) ⇒ BuildValidator
Returns a new instance of BuildValidator.
57 58 59 60 61 |
# File 'lib/ucode/repo/build_validator.rb', line 57 def initialize(output_root, unicode_version: nil, baseline: nil) @output_root = Pathname.new(output_root) @unicode_version = unicode_version @baseline = baseline end |
Instance Method Details
#validate ⇒ Hash
Walk the tree, run all checks, emit validation-report.json.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ucode/repo/build_validator.rb', line 65 def validate failures = [] per_block_counts = Hash.new(0) each_codepoint_dir do |block_name, cp_id, cp_dir| per_block_counts[block_name] += 1 validate_codepoint(block_name, cp_id, cp_dir, failures) end validate_block_coverage(per_block_counts, failures) report = build_report(failures, per_block_counts) report_path = write_report(report) { report: report, report_path: report_path, passed: report.totals.failures.zero?, } end |