Skip to content

Add specs/vsa/trinity_compat: the VSA contract the Trinity facade runs (S04 of trinity#988) - #3580

Merged
gHashTag merged 4 commits into
gHashTag:masterfrom
dmitrii-f-t27:spec/trinity-s04-vsa-compat
Sep 12, 2026
Merged

gHashTag merged 4 commits into
gHashTag:masterfrom
dmitrii-f-t27:spec/trinity-s04-vsa-compat

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Collaborator

Closes #3566 -- work package S04 of gHashTag/trinity#988: the VSA and numeric contract the Trinity facade actually runs. Stacked on #3579 (S03), #3578 (S02) and #3577 (S01): the diff shows all four until the earlier ones merge; S04 itself touches only specs/vsa/, conformance/, tools/, docs/now/, the S01 README and OWNERS.

What

specs/vsa/trinity_compat.t27 (module vsa_trinity_compat, KIND = "vsa-compat"). trinity:src/trinity.zig re-exports sixteen VSA operations from the package the consumer pins -- gHashTag/zig-golden-float e7ce3288, src/vsa/core.zig, passed through gHashTag/zig-hdc b73b2fa2 name by name -- while specs/vsa/vsa_core.t27 describes the same names with other semantics. The spec names the facade and the owner and records, per export, the owner function (file:line), the canonical function (name:line), a finding and a verdict:

  • 4 agree on every input: permute, inversePermute, countNonZero, vectorNorm.
  • 6 agree on equal lengths only (the length policies differ: the owner pads to max(len) with a zero trit and divides dot similarity by max(len), the canonical spec cuts to min(len) and divides by min(len); cosine norms run over the whole vector in the owner and over the shared prefix in the spec): bundle2, bundle3, cosineSimilarity, hammingDistance, hammingSimilarity, dotSimilarity.
  • 6 differ in kind: bind and unbind (the owner multiplies, so a zero trit annihilates; vsa_core.t27, ops.t27 and coptic_bind keep the zero trit as an identity), encodeSequence (the owner adds permuted vectors with a carrying balanced-ternary add, not a bundle), probeSequence, randomVector (two different generators), bundleN (the owner takes the sign of the sum of all vectors; the canonical spec folds bundle3(result, result, next) and reads vectors[2] for a count of two).

The semantics the pinned consumer executes are selected as the reference of the Trinity profile and stated as elementwise functions the C backend runs, because the compiler does not lower array parameters (S02): trit_bind, trit_bind_zero_identity, trit_sign, trit_bundle2, trit_bundle3, trit_differs, trit_nonzero, len_max, len_min, rotate_right, rotate_left, packed_bytes, pack_index, pack_slot, cosine_defined, tri27_bind. The zero-identity bind of the canonical specs and the additive TRI27 register bind of src/tri27/emu/executor.zig (mod 19683, zero register as identity) are classified separately, each with its own function and tests. The numeric representation is declared: i8 trits, five to a byte, two capacities in one package (12000 packed in packed_trit.zig, 59049 hybrid in ternary/hybrid.zig, the type the sixteen operations take), SIMD width 32, an i32 dot accumulator in the owner (i64 in the canonical spec; both hold, |dot| <= 59049), f64 similarities, no GoldenFloat format on the facade (0 references to gf16 in trinity.zig, sdk.zig, science.zig, vm.zig, jit.zig), no allocation and no error in the sixteen operations. Ten test blocks (the nine bind pairs, the four pairs where the variant differs, self-inverse on nonzero trits only, bundle ties, the length rules, the rotation law, packing arithmetic, the cosine precondition, the TRI27 cases) and five invariants.

tools/trinity_vsa_compat.py

  • vectors writes conformance/vsa_trinity_compat.json from a Python statement of the owner's semantics as read at e7ce3288: 149 vectors over 15 operations -- equal lengths, one SIMD chunk, a chunk plus a remainder, unequal lengths, all-zero and empty vectors, ties, every pair of trits once, the rotation identities (k = 0, k = len, k > len) and the inverse law, packing, the TRI27 fix-up. The pseudo-random trits come from the tool's own LCG, never from the owner's PRNG.
  • run generates the spec to C with t27c gen-c, composes the elementwise functions into whole-vector operations in a C driver whose length rules are the spec's own len_max, len_min and rotate_*, replays every vector and records the verdict with the compiler, the C compiler, the host and the spec hash. Model and spec are two independent statements of one reading of the owner; a failing vector names a wrong reading, a wrong function or a wrong composition.
  • check holds the committed record to the spec and the model: drifted vectors, constants or operations, a missing operation, a replay of another spec text, a changed vector count and a recorded failure are findings; the facade tables must have one entry per export, every verdict must be one of VERDICTS and open its finding, and the three counts must equal the verdicts.
  • --self-check plants a wrong expected trit (fails exactly its vector), a zero-identity bind in the spec (fails only bind-shaped vectors: 28 of 149, all bind, unbind, cosine_similarity, dot_similarity), drifted vectors, a stale replay and a recorded failure.

Also: docs/now entry; specs/trinity/README.md gains the S04 section and two rows; specs/OWNERS.md names the file under vsa/; seal .trinity/seals/vsa_vsa_trinity_compat.json; tools/published_figures.py test-blocks pin 12663 -> 12673.

Measured (2026-09-12)

  • t27c typecheck: 0 errors, 0 warnings; gen-c + cc -DT27_TEST_MAIN: All 10 tests passed.; gen, gen-rust, gen-verilog exit 0.
  • Replay: 149 of 149 vectors pass with t27c 0.2.0 and Apple clang 21 (the record carries them).
  • Not measured: the owner's Zig itself. The package does not build with the Zig available on this host (0.15.2 cannot link against the host SDK; the 0.17 nightly rejects the package), so the reference is read from the owner's source and executed through the spec's functions; the spec records this in NOT_MEASURED. A differential run against the owner remains the owner's own test suite.

Verification

python3 tools/trinity_vsa_compat.py --self-check                        ok (12 checks)
python3 tools/trinity_vsa_compat.py vectors / run / check               149/149, 0 findings
t27c seal --verify specs/vsa/trinity_compat.t27                         all hashes MATCH
check_seal_currency/coverage, specs_generate, duplicate_declarations, duplicate_agreement, assertionless,
json_parses, devhome, documented_commands, conflict_markers, catalog count/integrity, damage_negatives --require,
ring_spec_drift, published_figures, status tables, untrusted interp, now-entry shape (as PR)   exit 0
t27c ci --repo-root .                                                   115 issues, all pre-existing on master

The red test-ratchet on #3578/#3579 is pre-existing: the same 23 Rust tests (icarus_lowerable, lex_conform, parse_conform, tests_w458) fail on every Bootstrap Test Ratchet run of master since 2026-09-08 (e.g. run 34237060544 at f6a4a0fa, same "113 targets ran; 23 failing" summary); the S02 fixtures do not change the set.

What this does not claim

  • That vsa_core.t27 is wrong: it is a different contract, and this spec records which one the consumer runs. Reconciling the two, or moving the consumer to the canonical semantics, is a decision for the owners, not a side effect of S04.
  • That whole-vector operations are lowered by the compiler: the composition lives in the tool's C driver and is stated in the record (operations), the elementwise functions live in the spec.
  • Anything about bundleN for more than three vectors beyond what src/vsa/core.zig:324 says, or about the sequence helpers' numeric behaviour: they are recorded as differing in kind and carry no vectors.

Do not merge without the owner's approval.

🤖 Generated with Claude Code

dmitrii-f-t27 and others added 4 commits September 12, 2026 16:43
Closes gHashTag#3563 -- S01 of gHashTag/trinity#988.

specs/trinity/project.t27 (module trinity_project) pins the consumer
gHashTag/trinity at 976df517 and declares the seven profiles with headless
as the initial one, the eight dispositions, the five evidence tags of
docs/system/project.md, the dialect and build counts the inventory
measured, the four dependency pins and the twelve work packages S01..S12.
Fifty capability cards specs/trinity/capabilities/<id>.t27 give every
shipped build target and every requested capability an owner, a
disposition, a canonical spec and dialect, implementation and generated
paths, a backend, the build.zig targets it owns, an acceptance command,
an evidence status with its source and a work package.

tools/trinity_manifest.py derives the inventory from a clean pinned
checkout (inventory --trinity-root; a modified tracked file is refused)
and holds the cards to it (check): 51 executables, 6 libraries, 73 tests
and 68 steps are each owned by exactly one card, default-installed
targets are headless and !ci_mode-guarded ones are not, every trinity:
path is tracked, the website mirror is never canonical, DIALECT follows
the extension of CANONICAL_SPEC, only executable/adapter/research cards
claim a backend, no spec has two owners, measured names its command and
source, every work package has a card. --self-check plants thirteen
defects and requires each to be reported. The inventory and the derived
report are committed under conformance/trinity/.

specs/catalog/discovery.t27 is the canonical copy of the world-scan
contract gHashTag/trinity#990 vendored under the site's mirror path;
specs/OWNERS.md registers catalog/ and trinity/.

Evidence is what a public CI log measured: zig build -Dci=true succeeded
on ubuntu-latest at 79ffb034 (one data commit before the pin); the test
step is piped through tee there and its exit code is not measured
(gHashTag/trinity#616), so no card claims a passing test.

Seals for the 52 files by t27c seal --save at 03f0faf; t27c typecheck
reports 0 errors on each; published_figures test-blocks pin 12593 ->
12653 with the movement recorded next to the pin.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…d (S02)

Closes gHashTag#3564 -- S02 of gHashTag/trinity#988. Stacked on gHashTag#3577 (S01).

specs/trinity/compiler_matrix.t27 (module trinity_compiler_matrix) names
the native compiler (t27c 0.2.0; NATIVE_REVISION is the last commit that
changed bootstrap/, bff21b8), the WASM the site vendors (1cd2877, its
own column, no runtime), the four backends with the command that emits
each and what proves a runtime result on each, the four stages kept apart
in every record, fourteen features of the Trinity headless profile with
one fixture each under bootstrap/tests/fixtures/trinity_matrix/, five
negatives with the latest stage at which each must be rejected, and an
absent backend that must yield blocked.

tools/trinity_compiler_matrix.py run carries every fixture through t27c
typecheck and parse --json (annotation agreement, import resolution,
declaration count), gen-c / gen / gen-rust / gen-verilog, cc, zig test,
rustc --test, iverilog and t27c icarus-simulate, and writes
conformance/trinity/compiler_matrix.json; check holds the record to the
spec and the fixture hashes; --self-check proves the negatives are
negatives and that a stale status, an accepted negative, a late rejection
and a listed absent backend are each reported.

Measured: 12 of 14 features execute on their backend; enums is blocked on
C (the enum declares EVIDENCE_EMULATOR, the switch compares against
EMULATOR) while it executes on Zig; ffi_boundary is blocked at declaration
(a bodyless signature is a parse error, gHashTag#3472). The Rust backend emits
declarations only for every fixture. The Zig backend (0.17.0-dev nightly,
because 0.15.2 cannot link on the host) does not lower string equality,
array constants, invariant blocks or the clocked form. All five negatives
are rejected: the invalid annotation and the unresolved import by the
tool at declaration (both compilers report typecheck.ok for them), the
false assertion at runtime, the bodyless function and the dropped module
by the parser.

check_specs_generate registers the fixture directory as control fixtures;
published_figures test-blocks pin 12653 -> 12659.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Closes gHashTag#3565 -- S03 of gHashTag/trinity#988. Stacked on gHashTag#3578 (S02).

specs/trinity/build_graph.t27 (module trinity_build_graph) declares what
the consumer's build is made of at 976df517: the Zig it requires and the
one its CI measures with, the CI build and test commands (the test exit
code does not reach the job, gHashTag/trinity#616), the build.zig
options, the four build.zig.zon pins with how build.zig uses each, the
submodule, the seven profiles with what is measured for each, the
untracked outputs, fourteen tracked files a generator writes with their
generators and inputs, the seven generator output locations, and the
receipt policy of the bootstrap/fixture profile.

tools/trinity_build_receipt.py graph derives conformance/trinity/
build_graph.json from the pinned tree: 44 named modules, 252 import
edges resolved to 84 named modules, 152 package modules (149 to
zig-hdc-vsa, 3 to golden-float) and 16 inline modules, 0 unresolved,
the generated files and their inputs hashed at the pin. receipt --runs 2
writes bootstrap_receipt.json: compiler-source revision bff21b8, the
t27c hash, the host, and every generated output of the 18 matrix
fixtures x 4 backends hashed in two runs: 72 outputs, 0 differing. check
recomputes offline that the compiler sources, Cargo.lock, the fixtures
and a fresh generation match the receipt, and with --trinity-root judges
drift in the consumer (hand edit, stale, unregistered): none at the pin.
--self-check plants each defect.

trinity_compiler_matrix.py names the compiler-source revision by
bootstrap/src (the fixtures live under bootstrap/tests/); same revision,
record and seal refreshed. published_figures test-blocks pin 12659 ->
12663.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…s (S04)

specs/vsa/trinity_compat.t27 (module vsa_trinity_compat, KIND "vsa-compat") names
the facade trinity:src/trinity.zig, the implementation owner it resolves to
(gHashTag/zig-golden-float e7ce3288 src/vsa/core.zig through gHashTag/zig-hdc
b73b2fa2) and, for each of the sixteen re-exported operations, the owner function,
the canonical function of specs/vsa/vsa_core.t27, a finding and a verdict: 4 agree
on every input, 6 agree on equal lengths only, 6 differ in kind (bind and unbind
annihilate on a zero trit in the owner and keep it as an identity in the canonical
spec; encodeSequence, probeSequence, randomVector, bundleN). The semantics the pinned
consumer executes are the reference of the Trinity profile, stated as elementwise
functions the C backend runs; the zero-identity bind and the additive TRI27 register
bind are classified separately. Numeric representation declared: i8 trits, five per
byte, 12000 packed / 59049 hybrid capacity, SIMD width 32, i32 dot accumulator, f64
similarities, no GoldenFloat on the facade, no allocation, no error. 10 tests, 5
invariants; All 10 tests passed on C.

tools/trinity_vsa_compat.py: vectors writes conformance/vsa_trinity_compat.json from
a Python statement of the owner semantics (149 vectors over 15 operations); run
generates the spec to C and replays every vector through a driver composed of the
spec's own functions (149 of 149 pass); check holds the record to the spec and the
model; --self-check plants a wrong expectation, a zero-identity bind in the spec,
drifted vectors, a stale replay and a recorded failure.

Not measured: the owner's Zig itself (the package does not build with the Zig on
this host); the spec records this in NOT_MEASURED.

docs/now entry, specs/trinity/README.md section and rows, specs/OWNERS.md vsa/ row,
seal .trinity/seals/vsa_vsa_trinity_compat.json, published_figures test-block pin
12663 -> 12673.

Closes gHashTag#3566

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@gHashTag
gHashTag merged commit 6bc4707 into gHashTag:master Sep 12, 2026
37 of 38 checks passed
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.

[spec][Trinity S04] Define executable numeric, VSA and SDK compatibility contracts

2 participants