Class: Ucode::Glyphs::UniversalSet::Validator
- Inherits:
-
Object
- Object
- Ucode::Glyphs::UniversalSet::Validator
- Includes:
- Idempotency
- Defined in:
- lib/ucode/glyphs/universal_set/validator.rb
Overview
Post-build validator for a universal-set build (TODO 31 §Post- build validation). Walks the manifest + glyphs directory and runs the four structural checks:
1. `manifest_loadable` — `manifest.json` parses via
`Ucode::Models::UniversalSetManifest.from_hash`.
2. `glyph_files_present` — every entry has a corresponding
`glyphs/<id>.svg` on disk.
3. `totals_reconcile` — manifest totals match the actual
entry counts (`built == entries.size`).
4. `provenance_complete` — every entry has non-empty `tier`
and `source`.
Tofu (pillar-3) investigation and per-tier / per-block breakdowns live in CoverageReport — those are coverage questions, not structural ones. The idempotency check (TODO 31 §5) is exercised by re-running the build, not by reading on-disk state.
The validator is stateless from the outside: one call to
#validate walks the manifest, builds a
Models::ValidationReport, and writes it atomically to
<output_root>/reports/validation.json. Safe to re-run.
Constant Summary collapse
- CHECK_MANIFEST =
"manifest_loadable"- CHECK_GLYPHS =
"glyph_files_present"- CHECK_TOTALS =
"totals_reconcile"- CHECK_PROVENANCE =
"provenance_complete"
Instance Method Summary collapse
-
#initialize(output_root, unicode_version: nil) ⇒ Validator
constructor
A new instance of Validator.
-
#validate ⇒ Hash
Walk the manifest + glyphs dir, run all checks, emit
reports/validation.json.
Methods included from Idempotency
#by_block_report_path, #by_tier_report_path, #gaps_report_path, #glyph_path, #manifest_path, #write_glyph
Methods included from Repo::AtomicWrites
#same_content?, #to_pretty_json, #write_atomic
Constructor Details
#initialize(output_root, unicode_version: nil) ⇒ Validator
Returns a new instance of Validator.
52 53 54 55 |
# File 'lib/ucode/glyphs/universal_set/validator.rb', line 52 def initialize(output_root, unicode_version: nil) @output_root = Pathname.new(output_root) @unicode_version = unicode_version end |
Instance Method Details
#validate ⇒ Hash
Walk the manifest + glyphs dir, run all checks, emit
reports/validation.json. Returns the structured outcome.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ucode/glyphs/universal_set/validator.rb', line 61 def validate manifest, manifest_failures = load_manifest entries = manifest ? manifest.entries : [] findings = manifest_failures.dup if manifest findings.concat(check_glyph_files(entries)) findings.concat(check_totals(manifest)) findings.concat(check_provenance(entries)) end report = build_report(entries, findings, manifest) report_path = write_report(report) { report: report, report_path: report_path, passed: report.totals.failures.zero?, manifest_loaded: !manifest.nil?, } end |