feat(pf): domain model structure/data split + data conformance (FT-145)#16
Merged
Conversation
…5 ✓) §3.1 adds the data side of the domain model. The structure side (entities, relations, invariants) was already captured; this adds the data side: - ReferenceSet — constitutive reference data, part of the What (reference_data_for a concept), versioned/governed like the rest. - DataShape — the structure made machine-checkable: a target entity, its required fields, and reference-set membership constraints (the SHACL- property side). - ProductionDataset — the oracle pointer: the shape it conforms_to_shape plus a JSON source of populated records (not specification). `product domain data <dataset>` runs §6.3 data conformance: it validates each record against the shape and reports the data-divergence rate, catching the two §3.1 defects (a field null/absent in rows, an enum value the schema never declared). The verdict reads both ways — fix the data, or (if the spec is stale) fix the shape — and exits 1 on any divergence. Pure engine in pf::data_check; data-side rules (presence + cross-reference) in pf::rules_data; model in pf::model_data; CLI is a thin adapter. Wired through ids/model/edit/validate/turtle/bundle/list. validate_node refactored to extract check_local_shape (function-length gate). Adds ADR-089, TC-1021..1024, and unit + integration coverage. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01NGoLrRZv23sg6quHJHEP54
Round out the §3.1 data side (FT-145): - DataShape gains a third constraint kind, `types` (field → datatype: string/integer/number/boolean/date), catching type drift the structure side cannot see. A wrong type is a per-record `not-of-type` finding; unknown datatypes are rejected at author time. - `domain data` now records each run's divergence rate to a per-product history and surfaces the trend (first / rising / falling / stable) against the previous run — the §3.1 "spec staleness becomes measurable" signal (§13.3), made visible as it happens. `--no-record` skips persistence. The data-check handler moves to a dedicated commands/domain_data.rs adapter (history I/O + report); the trend classifier is a pure fn in pf::data_check. Adds TC-1025/TC-1026 and unit + integration coverage; ADR-089 amended. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01NGoLrRZv23sg6quHJHEP54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Implements the §3.1 structure/data split of the Product Framework so you can validate production data against the domain model. The structure side (entities, relations, invariants) was already captured; this adds the data side and the data conformance verification (§6.3), plus the §13 Data Conformance Profile's standing divergence-rate signal.
The split (three new node kinds)
ReferenceSet— constitutive reference data, part of the What (reference_data_fora concept). E.g. the valid shipping methods. Versioned/governed like the rest of the model.DataShape— the structure made machine-checkable: atargetentity plus three field-constraint kinds (the SHACL-property side):required— present + non-nullenums— value must be a member of a declared reference settypes— value must be of a datatype (string/integer/number/boolean/date)ProductionDataset— the oracle pointer: theshapeitconforms_to_shape+ a JSONsourceof populated records. Not specification.Data conformance —
product domain data <dataset>Validates every record against the shape and reports the data-divergence rate, catching the §3.1 defects the structure side can't see — a field null/absent, an undeclared enum value, a wrong datatype:
--no-recordskips persistence.domain validatealso catches dangling data cross-references (a shape targeting an unknown entity, etc.).Architecture (slice + adapter, per CLAUDE.md)
pf::data_check; data-side rules:pf::rules_data; model:pf::model_data. Thin CLI adapter:commands::domain_data(history I/O + report).validate_noderefactored to keep the function-length gate green.Verification
cargo build✅ ·cargo clippy -- -D warnings -D clippy::unwrap_used✅ ·cargo xtask check✅ (0 errors)cargo t: lib 670, integration 711 (incl. 6 new data TCs), sessions 139, property 13, code_quality 16 — all green🤖 Generated with Claude Code
https://claude.ai/code/session_01NGoLrRZv23sg6quHJHEP54
Generated by Claude Code