Repository navigation
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
Open
dmitrii-f-t27 wants to merge 4 commits into
dmitrii-f-t27 wants to merge 4 commits into
Conversation
…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.
9 tasks
…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
Contributor
Author
|
@gHashTag, please merge this PR (squash) into master;
Dmitrii Fedorov (@dmitrii-f-t27) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #8880
Ports
crates/trios-chat/rings/CR-CHAT-00/src/lib.rsof gHashTag/trios (at8b229e9489ee) 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
specs/port/trios/crates/trios-chat/rings/CR-CHAT-00/src/lib.t27const fn) +chat_laws()CounterNext { code: CounterCode, value }Function mapping (original -> spec):
SessionId::new(const fn)session_id_newSessionId { bytes: [32]u8 }SessionId::as_bytessession_id_as_bytesSessionId::to_hexsession_id_to_hex+ helperhex_digit[64]u8Counter::ZEROcounter_zeroChatCounter { value: u64 }: the type nameCounteris already defined byspecs/port/trinity/fpga/openxc7-synth/d_e21_test.t27, and the types ratchet refuses a second definition; the adapter maps it to the tuple structCounterCounter::nextcounter_next0xFFFFFFFFFFFFFFFF; the adapter keeps the panic text "counter overflow"Counter::get(const fn)counter_getDestHash::new(const fn)dest_hash_newchat_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[N][]const u8)enum Error(8 variants)enum ErrorKind+error_kind_codeEnvelopeMetastruct EnvelopeMetaErrorwith&'static str/Stringpayloads and Display strings,Result<T>, serde derives, tuple newtypes with.0, theconst fn chat_laws() -> &'static [ChatLaw]facadeTest mapping (9 original tests):
session_id_hex_roundtripcr00_01_session_id_hex_roundtripcounter_zero_and_nextcr00_02_counter_zero_and_nextcounter_overflow_panics(should_panic)cr00_03_counter_overflow_verdict; the panic message stays a Rust oracledest_hash_size_is_16cr00_05_dest_hash_size_is_16envelope_meta_serde_roundtripcr00_09_envelope_meta_fieldserror_invariant_renderserror_aead_renderslaw_table_has_exactly_twelve_rowscr00_11_law_table_has_exactly_twelve_rowslaw_ids_are_canonical_and_uniquecr00_12_law_ids_are_canonical_and_uniqueMapped 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)
[32]u8/[64]u8literals are test fixtures and the hex buffer)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_OFFSETSequal the originalchat_laws()strings;session_id_to_hexequalsformat!("{:02x}")on 10,000 pseudo-random ids;counter_nextmatcheschecked_add(1)at 0, 1, 7,u64::MAX - 1and returns Overflow atu64::MAX. 10,041 checks passed.Seal:
.trinity/seals/src_port::trios::crates::trios-chat::rings::CR-CHAT-00::src::lib.json,built_byt27c-bootstrap@0.5.2+5e5493cab,gen_hash_rustsha256: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; localt27b test(built from this tree): 16 passed, 0 failed. The first version was blocked on@truncate;chat_law_id_matchesnow compares digits as usize with widening@asonly.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:
python3 tools/dupe_scan.pyon a clean master d06eaed checkout prints the identical 12-error setcargo build -p tri --all-targets: rustc 1.99.0 E0282 in cli/tri/src/gates.rs:9019 (this PR touches no cli/ file)tri census pin --gatealso fails on clean master d06eaed (workflow files read 65 -> 66)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)