Conformance vectors: Java writes, others compare
Status
Section titled “Status”Accepted.
2026-10-12.
Context
Section titled “Context”Two implementations of one contract drift unless something forces them together. Prose contracts are read differently by each author. What matters is that a Go service takes over a Java service’s database and the platform sees the same rows, ids, configuration results and bytes. Some of that is exact bytes (a SQL statement, a Lua script, an OpenAPI document), some is parsed values, and some is a generated value that has to be pinned.
If both languages could write the expected output, a fix on one side could quietly redefine the contract, and the other side would then be tested against itself.
Decision
Section titled “Decision”- Conformance vectors are files under
conformance/: inputs and expected outputs read by both languages. - Java writes them. Each Java module has a vector test that runs the code on every input and compares to the committed output. Run in update mode it rewrites the file; a reviewer reads the diff and commits it.
- Other languages only compare. A Go mismatch means Go is wrong, or the vector exposes a Java bug, which is fixed in Java first.
- Comparison rules are fixed. JSON values compare as parsed values, including JSON carried inside a string. SQL and Lua text files and OpenAPI documents compare as exact bytes. Clocks and ids are pinned in the vector, or the vector says how to check an unpinnable value.
- An allowed difference is recorded in the vector with a reason, so it is deliberate and visible.
- Vectors written since 2026-10-18 open with a
descriptionandhowToRun, so a runner in another language can be written from the file alone. - Statements Go sends are copied into the Go package and compared byte for byte with the shared file, because
go:embedcannot reach outside its module. A sync target refreshes the copies. - Exceptions: a few vectors come from elsewhere, such as the field-token vectors copied from the platform and hand-written push vectors, and are compared by both sides. The Datastar adapter and the component goldens do not apply to the Go core.
Consequences
Section titled “Consequences”Good:
- “The same rows, ids and bytes” is a failing test, not an opinion.
- New behaviour is specified by adding a Java case first, then making the other side pass.
- The vectors double as documentation of edge cases.
Bad:
- The reference language gates every change, and a Java bug is copied into the vector until it is fixed.
- Some capabilities exist in only one language, so they have no cross-check yet.
- The repository’s conformance README still describes Rust as the comparing language; Go is the one that compares today.
Alternatives considered
Section titled “Alternatives considered”| Alternative | Why not |
|---|---|
| Prose contracts only | Each reading differs; drift is found late. |
| Either language writes vectors | The contract can be silently redefined. |
| A neutral generator program | Another implementation to maintain with no reference semantics. |