Skip to content

Slice 142: N6 codec and code registry aligned to draft v0.1-r7 - #140

Merged
HackTuah merged 1 commit into
mainfrom
slice/142-n6-v01-alignment
Oct 21, 2026
Merged

HackTuah merged 1 commit into
mainfrom
slice/142-n6-v01-alignment

Conversation

@HackTuah

Copy link
Copy Markdown
Member

Slice 142: Trinity's N6 codec and code registry follow the profile's draft v0.1-r7, and agree with every vector the publisher has cut.

What changes

  • Text rule (r7 section 2.4). Text is judged by four tables generated from the Unicode 15.0.0 data files, each checked by SHA-256 (scripts/unicode15_tables.exs, lib/trinity/n6/unicode15.ex). Unassigned code points, format controls (Cf), out-of-order combining marks and NFC quick check No or Maybe are refused. No Unicode normaliser runs anywhere in lib/trinity/n6/; the runtime's Unicode data is never read.
  • Decoder order (D0 to D18). A map key's head is checked before its type, an argument's missing bytes before a tag or float refusal, and a container's declared contents against the item limit at its head.
  • Body (B1 to B8). One ascending scan over present and required keys. Field types gain ranges, enums, byte bounds, grammars, unions, fixed-shape arrays and nullable fields.
  • Header (H1 to H4) and keys (K1 to K3). typ is checked first and selects the label set. New codes header_missing and header_value_invalid; the hash-envelope label set is checked. An Ed25519 key must decode strictly (RFC 8032 section 5.1.3).
  • Registry. r7's code names (field_missing, field_type_mismatch, value_out_of_range, text_grammar_mismatch, ...). Each code records the steps that emit it. Only alg_unavailable and the encoder's value_not_n6 are Trinity's own.
  • Licence. LICENSES/Unicode-3.0.txt for the embedded tables.

Evidence

  • TRINITY_N6_PUBLISHER_VECTORS=<Requisition vectors/n6 at 173487c9> mix test test/trinity/n6/publisher_vectors_test.exs: encoding 347/347, body 124/124, header 85/85, thumbprint 18/18, digest 19/19. The set's SHA384SUMS is checked first. A planted wrong expectation was reported by name.
  • On main the same encoding vectors gave 245 of 295 negatives (the text rule and the key-head order).
  • TRINITY_UCD_DIR=<UCD 15.0.0> mix test test/trinity/n6/r7_alignment_test.exs: the generator rewrites the module byte for byte. The counts match r7 (Cf 170, NFC_QC No 1,120, Maybe 111, Cn 825,345).
  • Trinity's own fixtures are regenerated where a code name changed (scripts/n6_vectors.exs).

Not in this PR: exit 7 for a defect after a verified signature, the small-order Ed25519 rule, and the v3-to-v4 crossing (slice 144).

… draft v0.1-r7: the text rule on pinned Unicode 15.0.0 tables, the profile's step order, r7's codes, agreement with the publisher's cut vectors)

Signed-off-by: Ayla Croft <aylacroft@proton.me>
@HackTuah
HackTuah merged commit 54498d5 into main Oct 21, 2026
12 checks passed
@HackTuah
HackTuah deleted the slice/142-n6-v01-alignment branch October 21, 2026 18:51
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