Skip to content

Add a second implementation, and fix what it found - #16

Merged
rokoss21 merged 1 commit into
masterfrom
feat/second-implementation
Aug 21, 2026
Merged

Add a second implementation, and fix what it found#16
rokoss21 merged 1 commit into
masterfrom
feat/second-implementation

Conversation

@rokoss21

Copy link
Copy Markdown
Owner

ROADMAP item 4.

A standard with one implementation is a design. Nothing had tested whether a second implementer, reading only the specification, arrives at the same bytes.

What this is

conformance/second_impl — the Core profile (§2.1.1) in Python, written from the specification text rather than from this source tree. cross_check.py runs both implementations over the example corpus and compares document_hash and messages, excluding profile and mode (properties of the implementation, not the document). Gated in CI; a new divergence fails, a documented one does not.

What it found

An implementation cannot notice the questions it silently answered. This one asked four.

Fixed here: §7.2 left a contract's identity undefined

§7.2 said imported content is "expanded in-place" and no more. document_hash is the SHA-256 of the Resolved Source Form (§18.3) — so the two implementations produced different identities for the same contract:

reference:  sha256:3bd041eeca7734ded988b83da42d49ef08d405241a2923ec0ab79e6ed3b91a00
second:     sha256:4eb3df04d754e46cb373654b50278c99aa4ead5a56f3aee10865e32798ce02c1

Both readings of "expanded in-place" are defensible; that is the problem. §7.2 now states the splice exactly: the @import line is replaced by the imported document's Resolved Source Form with exactly one trailing newline and no other separator. The trailing-newline clause is not decoration — without it, an imported file that does not end in a newline joins its last line to whatever follows.

Open, and written down in DIVERGENCES.md

  • Core meets $prompt in a message with no phase able to resolve it. Refuse (F801), pass through as text, or resolve when the variable is a literal? All three are defensible and produce different canonical output.
  • Core reports budget_units while having no Token Box Model to enforce it, so its payload can exceed the budget it declares.
  • Multi-line inline literals are used by the spec's own 09_multimodal_content.facet but cannot be derived from Appendix B's grammar, where SP is a space, not a newline. Informative annex, so not a violation — but an implementer working from the grammar writes a parser that rejects the specification's examples. This one did.

What agreed

Everything else: normalization, concrete syntax, facet cardinality and merge order, @meta restrictions, canonical message ordering, policy_hash over the effective policy object, and document_hash byte for byte including across imports once §7.2 was pinned.

Honest limit

This second implementation shares an author with the reference. It tests whether the text is sufficient, not whether it is unambiguous to a stranger — that item stays open in ROADMAP.md.

498 tests, coverage 60 → 62, all gates green.

🤖 Generated with Claude Code

A standard with one implementation is a design. Nothing had tested
whether a second implementer, reading only the specification, arrives at
the same bytes.

conformance/second_impl is the Core profile (§2.1.1) in Python, written
from the specification text rather than from this source tree:
normalization, the concrete syntax, import resolution and merge,
profile enforcement, and canonical rendering with policy hashing.
cross_check.py runs both implementations over the example corpus and
compares document_hash and messages, excluding `profile` and `mode`,
which are properties of the implementation rather than of the document.
A new divergence fails; a documented one does not.

It found four things, none of which were visible from inside the
reference — an implementation cannot notice the questions it silently
answered.

The serious one is fixed here. §7.2 said imported content is "expanded
in-place" and no more, which leaves the byte-level result open. Since
`document_hash` is the SHA-256 of the Resolved Source Form (§18.3), the
two implementations produced *different identities for the same
contract*: sha256:3bd041ee… against sha256:4eb3df04…. §7.2 now states
the splice exactly — the `@import` line is replaced by the imported
document's Resolved Source Form with exactly one trailing newline and no
other separator. The trailing-newline clause is not decoration: without
it an imported file that does not end in a newline joins its last line
to what follows.

Three remain open, recorded in DIVERGENCES.md rather than papered over:
Core meets a `$` reference in a message with no phase able to resolve it
and the spec does not say whether to refuse, pass through, or resolve;
Core reports `budget_units` while having no Token Box Model to enforce
it; and Appendix B's grammar cannot derive the multi-line inline
literals that the specification's own example 09 uses.

Everything else agreed, including document_hash across imports once §7.2
was pinned. That is the useful half of the result: the parts written
tightly enough produced identical bytes from two implementations sharing
no code.

This second implementation shares an author with the reference, so it
tests whether the text is sufficient, not whether it is unambiguous to a
stranger. ROADMAP.md keeps that distinction open.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rokoss21
rokoss21 merged commit 9b61d06 into master Aug 21, 2026
15 checks passed
@rokoss21
rokoss21 deleted the feat/second-implementation branch August 21, 2026 23:04
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