Skip to content

conformance: add runnable AKN4OLF conformance suite - #1

Open
Sipioteo wants to merge 1 commit into
mainfrom
conformance-suite
Open

conformance: add runnable AKN4OLF conformance suite#1
Sipioteo wants to merge 1 commit into
mainfrom
conformance-suite

Conversation

@Sipioteo

@Sipioteo Sipioteo commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

The spec README points to ./conformance and calls the conformance suite "the heart of the project … the only gate", but that directory did not exist (the link 404'd). This PR adds the real, runnable suite.

A new conformance/ package implements the six criteria from the README as a dependency-free Python library + CLI (standard library only — xml.etree.ElementTree), so any adapter author can run it.

What's included

  • conformance/akn4olf_conformance.py — library + CLI implementing criteria 1–6.
  • conformance/__init__.py — public API: check(), stability(), report types.
  • conformance/README.md — per-criterion definitions, what is mechanically enforced vs advisory, how to run.
  • conformance/samples/ — a real Normattiva conformant sample (single-version), a synthetic multi-version conformant sample, and a deliberately non-conformant sample.
  • conformance/selftest.py — self-test over the bundled samples.
  • Top-level README.md — the ./conformance link now resolves; added a short pointer with run commands.

The six criteria

  1. Schema-valid Akoma Ntoso in a recognized profile — well-formed XML; {akn}akomaNtoso root; one recognized document element (act/bill/doc/…) with {akn}meta; the OLF proprietary source="#openlawsfoundation" agent IDREF resolves to a declared TLCOrganization. Structural by default and labelled as such; validates against an offline AKN XSD if one is provided via AKN4OLF_XSD (with lxml). No official XSD is bundled.
  2. Required lifecycle events present and well-formed<olf:lifecycle> with a valid ISO inForceFrom; events drawn from the fixed vocabulary {enacted, published, commenced, amended, repealed} with valid dates. The README does not enumerate the mandatory set in prose, so the suite adopts a minimal, stated interpretation (require inForceFrom + a matching commenced) documented in code and the README.
  3. Every <ref> resolved-or-unresolved — each {akn}ref carries either a well-formed {olf}target OLF id or {olf}resolution="unresolved"; reports counts.
  4. Temporal validity monotonic — distinguishes the act-level OLF envelope (checked for internal consistency) from native <temporalGroup> version slices (which must be pairwise non-overlapping and contained in the envelope).
  5. As-enacted text reconstructible — only meaningful for multi-version documents; returns NOT-APPLICABLE (not a false PASS) for single-version monovigente inputs.
  6. OLF identifiers stable across regenerations — a two-input check comparing identity, ref-target ids, and structural eIds while ignoring volatile provenance; run via --compare or stability().

NOT-APPLICABLE criteria are surfaced but never make a document non-conformant.

How to run

python -m conformance.akn4olf_conformance path/to/document.akn.xml
python -m conformance.akn4olf_conformance run1.akn.xml --compare run2.akn.xml
python -m conformance.selftest

The CLI exits 0 on CONFORMANT (and stability PASS) and 1 otherwise, for direct CI use.

Validation

  • Real conformant sample → CONFORMANT (criterion 5 NOT-APPLICABLE, correct for a monovigente snapshot).
  • Synthetic multi-version sample → CONFORMANT (criteria 4 and 5 PASS).
  • Non-conformant sample → NON-CONFORMANT, naming criterion 3 as the cause.
  • Stability: two regenerations from the same source (different generation timestamps) → PASS; a copy with a changed id → FAIL.
  • python -m conformance.selftest → all assertions hold.

Honest limitations (documented in conformance/README.md)

  • No official AKN 3.0 XSD is redistributed here; criterion 1 is structural unless an XSD is supplied offline.
  • Criterion 5 needs a multi-version document; it is NOT-APPLICABLE for single-version inputs.
  • Criterion 6 needs two regenerations (--compare).

Implement the six conformance criteria from the spec README as a
dependency-free Python library and CLI under conformance/:

  1. schema-valid Akoma Ntoso in a recognized profile (structural;
     optional offline XSD via AKN4OLF_XSD)
  2. required AKN4OLF lifecycle events present and well-formed
  3. every <ref> resolves to an OLF id or is explicitly unresolved
  4. temporal validity monotonic (envelope vs non-overlapping version slices)
  5. as-enacted text reconstructible from a multi-version document
     (NOT-APPLICABLE for single-version/monovigente inputs)
  6. OLF identifiers stable across two regenerations (stability check)

Each criterion reports PASS/FAIL/NOT-APPLICABLE with a human-readable
reason; NOT-APPLICABLE never gates. CLI prints a per-criterion table and a
final CONFORMANT/NON-CONFORMANT verdict, exiting non-zero on failure.

Ship a conformant real Normattiva sample, a synthetic multi-version
conformant sample, a deliberately non-conformant sample, and a self-test.
Resolve the README ./conformance link (previously 404) and add a short
pointer on how to run the suite.

Signed-off-by: Sipioteo <matteo@sipio.it>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant