Skip to content

Port trios-chat CR-CHAT-00: lib.rs data and decisions as lib.t27 (Refs #8880) - #9131

Open
dmitrii-f-t27 wants to merge 4 commits into
gHashTag:masterfrom
dmitrii-f-t27:chat-cr00-lib
Open

dmitrii-f-t27 wants to merge 4 commits into
gHashTag:masterfrom
dmitrii-f-t27:chat-cr00-lib

Conversation

@dmitrii-f-t27

@dmitrii-f-t27 dmitrii-f-t27 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Refs #8880

Ports crates/trios-chat/rings/CR-CHAT-00/src/lib.rs of gHashTag/trios (at 8b229e9489ee) to .t27, as part of the Trinity Secure Chat rewrite (parent epic gHashTag/trios#1812; roadmap goal #4548). This is the only target of tracker 8880, so the ring CR-CHAT-00 is complete with this PR. The original is not edited; the swap into gHashTag/trios is a separate PR there.

Spec in this PR

Target Original fns Original tests Spec tests Verdict Notes
specs/port/trios/crates/trios-chat/rings/CR-CHAT-00/src/lib.t27 7 (incl. 3 const fn) + chat_laws() 9 16 CounterNext { code: CounterCode, value } T-SPLIT: main chunk at the parent target (feeder-eligible file). The doc-comment glyphs of the original are dropped; the spec is ASCII only.

Function mapping (original -> spec):

Original Spec Note
SessionId::new (const fn) session_id_new record SessionId { bytes: [32]u8 }
SessionId::as_bytes session_id_as_bytes
SessionId::to_hex session_id_to_hex + helper hex_digit lowercase, [64]u8
Counter::ZERO counter_zero record ChatCounter { value: u64 }: the type name Counter is already defined by specs/port/trinity/fpga/openxc7-synth/d_e21_test.t27, and the types ratchet refuses a second definition; the adapter maps it to the tuple struct Counter
Counter::next counter_next Overflow verdict at 0xFFFFFFFFFFFFFFFF; the adapter keeps the panic text "counter overflow"
Counter::get (const fn) counter_get
DestHash::new (const fn) dest_hash_new
chat_laws() (const fn) CHAT_LAWS_TEXT (1088 bytes) + CHAT_LAWS_OFFSETS (37 u32), chat_law_count, chat_law_field_start, chat_law_field_len, chat_law_byte, chat_law_id_matches, chat_law_fields_equal string table as flat bytes + offsets (no [N][]const u8)
enum Error (8 variants) enum ErrorKind + error_kind_code payload-free, declaration order
EnvelopeMeta struct EnvelopeMeta fields as the original
stays Rust - thiserror Error with &'static str / String payloads and Display strings, Result<T>, serde derives, tuple newtypes with .0, the const fn chat_laws() -> &'static [ChatLaw] facade

Test mapping (9 original tests):

Original test Spec test or Rust oracle
session_id_hex_roundtrip cr00_01_session_id_hex_roundtrip
counter_zero_and_next cr00_02_counter_zero_and_next
counter_overflow_panics (should_panic) decision: cr00_03_counter_overflow_verdict; the panic message stays a Rust oracle
dest_hash_size_is_16 cr00_05_dest_hash_size_is_16
envelope_meta_serde_roundtrip stays Rust oracle (serde); field layout in cr00_09_envelope_meta_fields
error_invariant_renders stays Rust oracle (Display)
error_aead_renders stays Rust oracle (Display)
law_table_has_exactly_twelve_rows cr00_11_law_table_has_exactly_twelve_rows
law_ids_are_canonical_and_unique cr00_12_law_ids_are_canonical_and_unique

Mapped to a spec: 6 of 9. Extra spec tests cover every helper (Untested: 0).

Not reconciled on purpose (changes only by ADR): the law titles here differ from CR-CHAT-LAWS, and the original Error docs map Capability to R-CHAT-7 and Injection to R-CHAT-8, swapped versus the law table.

Checks (t27c built from this tree at 5e5493c, Zig 0.16.0)

1 present 2 fns 3 gen 4 status 5 tests 6 test-report 7 parse 8 gen-rust + rustc 8b signatures 9 module 10 ASCII 11 banned 12 seal 14 coverage
present mapping table above 0 IMPLEMENTED mapping table exit 0, 16/16, 0 vacuous parses exit 0, 0 errors 0 / 0 1 0 0 (the 5 [32]u8/[64]u8 literals are test fixtures and the hex buffer) MATCH, tests 16/16 Functions 15, Untested 0

Check 0 (dedup) was run right before the file: only tracker 8880 names the target, no spec on master, no foreign PR, no queen-N branch.

Parity of the generated Rust against the original (local, rustc 1.94.0, not CI): the 36 law fields rebuilt from CHAT_LAWS_TEXT/CHAT_LAWS_OFFSETS equal the original chat_laws() strings; session_id_to_hex equals format!("{:02x}") on 10,000 pseudo-random ids; counter_next matches checked_add(1) at 0, 1, 7, u64::MAX - 1 and returns Overflow at u64::MAX. 10,041 checks passed.

Seal: .trinity/seals/src_port::trios::crates::trios-chat::rings::CR-CHAT-00::src::lib.json, built_by t27c-bootstrap@0.5.2+5e5493cab, gen_hash_rust sha256:a354e0c9b62120c44927f4d3670a8601ac1eec6ec4091075d25871fe1e346df7 (head b48e46b); seal --verify: all hashes MATCH.

t27b expectations: one row, specs/port/trios/crates/trios-chat/rings/CR-CHAT-00/src/lib.t27 = pass, in path order. The ratchet printed the spec as UNLISTED; local t27b test (built from this tree): 16 passed, 0 failed. The first version was blocked on @truncate; chat_law_id_matches now compares digits as usize with widening @as only.

CI on the head SHA a5a960f (2026-10-14)

a5a960f merges master d06eaed into this branch (no rebase, no change to the spec). With t27c built from that tree the seal still holds (t27c seal --verify: all hashes MATCH); test-report 16/16, 0 vacuous; gen-rust compiles; coverage Untested 0.

Required: validate SUCCESS, check-linked-issue SUCCESS, parse-ratchet SUCCESS, own-language SUCCESS. 28 of 31 checks green. The merge cleared three of the five earlier reds (Corpus ratchet types step, spec-guards, coverage: fixed on master). Three reds remain; none names this spec, and each is reproduced on master d06eaed:

Red check On this PR (CI merge ref c4ac6cb = a5a960f into d06eaed) Same on master
duplicate-bodies 12 errors (bit_at, build_level, indent, flat_index, is_ascii, on_comb, ...) python3 tools/dupe_scan.py on a clean master d06eaed checkout prints the identical 12-error set
cli-tri cargo build -p tri --all-targets: rustc 1.99.0 E0282 in cli/tri/src/gates.rs:9019 (this PR touches no cli/ file) last master run of cli-tri, https://github.com/gHashTag/t27/actions/runs/38297236431 (177eef9), fails at the same step with rustc 1.99.0 (gates.rs and cli/dlc10); local rustc 1.94.0 builds it, and tri census pin --gate also fails on clean master d06eaed (workflow files read 65 -> 66)
t27b-native-ratchet 155 UNLISTED/UNEXPECTED rows, e.g. UNEXPECTED FAILURE specs/tools/t27o/rust_convert.t27; this spec's row (pass) is in the ledger and is not named rows belong to specs merged on master since its last ledger update

Earlier run on b48e46b (2026-10-11): 5 reds, each matched on master at 5e5493c (runs 38146939229, 38146939153, 38146939200, 38145387223, 38146939191).

A red check with an external cause is still red; these need fixes on master, not here.

Not claimed

The spec carries the data and decisions of the original. No constant-time, post-quantum or Coq claim. Equivalence with the Rust original is proven only by the swap PR in gHashTag/trios, where the original tests run against the generated code.

Dmitrii Fedorov (@dmitrii-f-t27)

…gHashTag#8880)

Refs gHashTag#8880

T-SPLIT port of gHashTag/trios crates/trios-chat/rings/CR-CHAT-00/src/lib.rs
at 8b229e9489ee: the eight error kinds in declaration order, SessionId,
Counter, DestHash and EnvelopeMeta records, the counter successor with an
Overflow verdict (the original panics), lowercase hex of a session id into
[64]u8, and the 12-row R-CHAT law table as flat bytes plus offsets.

The thiserror Error facade, Result, serde derives, tuple newtypes and the
const fn chat_laws() stay Rust. test-report 16/16, vacuous 0; gen-rust
compiles; coverage Untested 0; sealed with t27c built from this tree
(t27c-bootstrap@0.5.2+5e5493cab), seal --verify all hashes MATCH.
…HashTag#8880)

Refs gHashTag#8880

The types ratchet (Corpus ratchet, 'A type name may not gain a second
definition') reported Counter as a NEW conflict: specs/port/trinity/fpga/
openxc7-synth/d_e21_test.t27 already defines a type Counter. The record is
renamed ChatCounter; the swap adapter maps it to the original tuple struct
Counter. Resealed with t27c-bootstrap@0.5.2+5e5493cab: tests 16/16,
vacuous 0, all hashes MATCH.
…ow (Refs gHashTag#8880)

Refs gHashTag#8880

t27b-native-ratchet listed the spec as UNLISTED, blocked on
ExprCall(@truncate) in chat_law_id_matches. The check now compares the
id digits as usize (@as widening only) and rejects n outside 1..99; two
more asserts cover that. Local t27b (built from this tree): 16 passed,
0 failed, so the ledger gets the row t27b=pass, in path order.
Resealed: tests 16/16, vacuous 0, all hashes MATCH.
This was referenced Oct 11, 2026
This was referenced Oct 13, 2026
Brings the CR-CHAT-00 port up to the current master before re-checking
its seal and the five red checks of b48e46b.

Refs gHashTag#8880
@dmitrii-f-t27

Copy link
Copy Markdown
Contributor Author

@gHashTag, please merge this PR (squash) into master; dmitrii-f-t27 has read access only in gHashTag/t27, so I cannot merge it.

Dmitrii Fedorov (@dmitrii-f-t27)

This branch has not been deployed

No deployments
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