Skip to content

[M2/P0] Close the Core semantic reference graph #184

Description

@samovers

Parent: #167
Design dependency: #168
Implementation dependencies: #170, #171, #173, #174
Database carrier prerequisite: #174

Problem

M2 has the right domain nouns, but the executable reference graph does not yet prove that an accepted operation is one coherent semantic statement.

At the review baseline:

  • the submission/assertion subject and time can disagree with the ExecutionRecordPayload subject, interval, and extent;
  • the real product-authorisation resolver emits a REGULATORY_AUTHORISATION binding while the active operation path requires a CROP_PROTECTION_PRODUCT binding, so resolver-produced data cannot satisfy the same path demonstrated by direct fixtures;
  • operation materialRef, AppliedResource identity, material quantity, product binding, crop/cycle, equipment, and target extent are not closed into one exact graph;
  • binding selection can degrade to first-match behavior and does not consistently prove exact role, local subject, lifecycle/currentness, profile/bundle, or promotion lineage;
  • external identity is represented through three different mechanisms: embedded identifiers, AgronomicIdentityBinding, and bare scheme-prefixed values;
  • interval ordering, event-time coherence, extent containment, and ambiguous reference aliases are not completely enforced.

A schema-valid payload is therefore not yet enough to prove a semantically valid operation.

Required decision record

Before implementation, write one reviewable M2 semantic map covering:

  1. the authoritative local identity for Farm, Field, CropCycle, AppliedResource, Equipment, and any other accepted operation subject;
  2. which external identifiers are embedded attributes versus governed bindings, with one rule per identity family;
  3. exact reference roles and cardinalities for every accepted operation class;
  4. the relationship among top-level subject/time/scope, carrier subject/effective interval/extent, and materialized state;
  5. lifecycle/current-binding and ambiguity rules;
  6. the role distinction between product identity and regulatory authorisation;
  7. the supported extent-containment and temporal-applicability model.

Do not silently edit frozen v0.1 law or extracted contracts. If the accepted contract cannot express the required invariant, stop and open an explicit ERRATA/RFC or versioned-candidate ticket with migration and compatibility consequences.

Acceptance criteria

  • Top-level subject, farm/field scope, and event time equal or are deterministically derived from the carrier; any mismatch refuses with a stable problem code.
  • Operation references resolve to exact tenant-local identities. An external binding attaches to a local identity and never substitutes for AppliedResource, Equipment, Field, or CropCycle.
  • Each operation class has one executable role/cardinality matrix. Missing, duplicate, extra, or wrong-role references refuse.
  • Product resolution distinguishes product identity from regulatory authorisation and requires the exact roles the operation policy needs; no first-match semantics remain.
  • Every binding proves exact tenant, local subject, identity family, scheme role, accepted lifecycle state, profile/RuntimeBundle, validity/knowledge cut, and promotion/supersession lineage.
  • The crop binding matches the referenced CropCycle; material quantities match the referenced AppliedResource and its accepted product bindings; equipment matches the farm, type, and lifecycle required by the operation.
  • Referenced extents prove the required anchor/parent relationship, temporal applicability, and containment in the target scope. Unsupported partial-overlap semantics refuse rather than approximate.
  • Effective interval start is not after end, and event-time/effective-time coherence follows the rule accepted in [M1/ADR] Specify valid-time and knowledge-time semantics #170.
  • Canonical reference fields are unambiguous. Compatibility aliases, if retained, normalize to one representation and contradictory aliases refuse.
  • Consume [M1/Security] Enforce tenant isolation and record-graph integrity in PostgreSQL #174's neutral tenant/batch/lane reference carrier and add the accepted extraction/path/kind/cardinality enforcement through an immutable forward migration. [M1/Security] Enforce tenant isolation and record-graph integrity in PostgreSQL #174 does not implement or claim this semantic matrix.
  • Hostile substitution tests cover same-farm wrong subject, cross-farm, cross-tenant, wrong role, stale/revoked/superseded binding, multiple-current bindings, crop mismatch, resource mismatch, equipment mismatch, extent escape, and temporal mismatch.
  • Existing valid SI scenarios remain assertion-equivalent except where a fixture was proving an invalid graph; every changed fixture is documented as a corrected invariant, not a policy expansion.

Validation

Add focused unit, property, and end-to-end tests through the public submission path. Include at least one fixture produced by the real resolver/verification path rather than raw direct inserts.

Run and report:

.venv/bin/python -m pytest kernel/tests/ -q
python3 conformance/ofarm_pkg_contract_check.py
git diff --check

Use the repository-supported equivalent if the documented virtualenv is unavailable and report the exact command.

Boundaries

Codex stop conditions

Stop and report if closing the graph requires changing law, inventing a country rule, guessing an ambiguous contract meaning, accepting multiple-current bindings, or widening a runtime capability.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tracking-epicProgramme containing multiple independently reviewable capabilities; owns no implementation PR.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions