Conformance
This page defines the conformance requirements for SDIF 1.0 implementations and the layout of the conformance test fixture suite.
Conformance Levels
An implementation MAY claim conformance to one or more of the following levels:
| Level | Description |
|---|---|
| Parser | Correctly parses valid SDIF source documents and rejects invalid ones |
| Canonicalizer | Produces canonical bytes matching golden fixtures for all valid inputs |
| Hasher | Computes SHA-256 document hashes matching .sha256 golden files |
| AI projection | Produces and ingests .sdif.ai documents with correct round-trip behavior |
An implementation that claims full SDIF 1.0 conformance MUST satisfy all four levels.
Fixture Layout
Conformance test fixtures are located in the SDIF repository under the conformance/ directory. The directory is organized as follows:
conformance/
manifest.sdif # Portable fixture index (SDIF document, kind ConformanceManifest)
cases/ # Named valid-case fixtures
<case-id>/
source.sdif # Source input (may use non-canonical form)
canonical.sdif # Expected canonical bytes (golden)
expected.tree # Expected parse tree (implementation-defined text format)
invalid/ # Documents that parsers MUST reject
<fixture>.sdif # One file per error condition
The manifest
conformance/manifest.sdif is the authoritative index of the conformance suite. It is itself a valid SDIF document and can be parsed by any conforming implementation without a JSON adapter.
@sdif 1.0
kind ConformanceManifest
version 1.0.0
cases[id,profile,source,canonical,tree,sha256]:
core-agent v1 conformance/cases/core-agent/source.sdif ...
ai-alias-header ai conformance/cases/ai-alias-header/source.sdif ...
invalid_cases[id,source,expected_code]:
version-missing conformance/invalid/version_missing.sdif SDIF_VERSION_MISSING
table-too-few-cells conformance/invalid/table_too_few_cells.sdif SDIF_TABLE_ARITY
scalar-unclosed-quote conformance/invalid/scalar_unclosed_quote.sdif SDIF_STRING_UNCLOSED
...
The cases table covers valid round-trip cases. Each row declares:
id— unique case identifierprofile—v1(source-profile) orai(AI-profile)source— repo-relative path to source filecanonical— repo-relative path to canonical goldentree— repo-relative path to expected parse treesha256— 64-char lowercase hex ofSHA-256(canonical UTF-8 bytes)
The invalid_cases table covers rejection cases. Each row declares:
id— unique case identifiersource— repo-relative path to the invalid fixtureexpected_code— the error code the parser MUST raise (e.g.SDIF_VERSION_MISSING)
Parser Conformance
An implementation claiming Parser conformance MUST:
- Accept all cases listed in the
casestable ofconformance/manifest.sdif. For each case, the parser MUST successfully produce an AST without errors or warnings that would cause the parse to fail. - Reject all fixtures listed in the
invalid_casestable ofconformance/manifest.sdif. For each fixture, the parser MUST report a parse error whose code matches theexpected_codecolumn. The error MUST be reported with enough information to identify the location (line number SHOULD be included). - Normalize CRLF to LF on parse, as required by Lexical Structure. A document that is otherwise valid but uses CRLF line endings MUST be accepted and parsed identically to its LF-normalized form.
- Reject invalid UTF-8 byte sequences with a parse error.
Canonicalizer Conformance
An implementation claiming Canonicalizer conformance MUST:
- Produce matching canonical bytes for every case in the
casestable ofconformance/manifest.sdif. For eachsourcefile, the implementation MUST produce canonical output that is byte-for-byte identical to the correspondingcanonicalgolden file. - Be idempotent:
canon(canon(x))MUST equalcanon(x)for all valid fixtures. Implementations SHOULD verify this property by running the canonicalizer twice on each fixture. - Report canonicalization errors for fixtures that include
ordered: falsetables with noprimary_key, as described in Canonicalization Rule 11. The implementation MUST report an error and MUST NOT emit partial canonical output for such documents. - Respect all 13 normative rules defined in Canonicalization.
Hash Conformance
An implementation claiming Hasher conformance MUST:
- Produce matching hashes for every case in the
casestable ofconformance/manifest.sdif. The computed SHA-256 hash, expressed as a 64-character lowercase hexadecimal string, MUST be identical to thesha256column value for that case. - Hashes MUST be computed over the canonical UTF-8 bytes as produced by the canonicalizer, not over source bytes.
AI Projection Conformance
An implementation claiming AI projection conformance MUST:
-
Produce matching canonical output for every case with profile
aiin thecasestable ofconformance/manifest.sdif. The AI projection round-tripped back to canonical SDIF MUST match thecanonicalgolden file for that case. -
Satisfy the round-trip requirement: For every AI-profile case in the manifest, the following MUST hold:
hash(canon(sdif_from_ai(ai_view(source)))) == hash(canon(source))That is, applying the AI projection and then reversing it back to canonical SDIF MUST yield a document with the same canonical hash as the original source. Implementations MUST verify this equality against the
*.sha256file. -
Reject
rel[subject]:syntax in source-profile documents. Grouped relation syntax is valid only in@sdif.aidocuments and MUST be treated as a parse error in@sdifdocuments.
Fixture Authoring Guidelines
New fixtures added to the conformance suite SHOULD follow these guidelines:
- Valid case fixtures (
conformance/cases/<id>/) MUST includesource.sdif,canonical.sdif, andexpected.tree. The canonical file MUST be generated by the reference Python implementation. The case MUST be registered in thecasestable ofconformance/manifest.sdifwith a correctsha256value. - Invalid fixtures (
conformance/invalid/<name>.sdif) MUST be registered in theinvalid_casestable ofconformance/manifest.sdifwith theexpected_codethat the parser MUST raise. No sidecar files are required. - Canonical golden files MUST be generated by the reference implementation and verified by
scripts/check_conformance_fixtures.pybefore being merged. - All fixture files MUST use LF line endings and UTF-8 encoding in the repository.
Reporting Non-Conformance
Implementations that discover divergence from these conformance requirements SHOULD:
- File an issue in the SDIF repository with the fixture name, the actual output, and the expected output.
- Include the implementation name, version, and platform in the report.
- Attach the minimal reproducing fixture if it is not already in the conformance suite.