Skip to content

Repair trios-chat specs: skipped_message_key_gap_bound_guard and CR-CHAT-LAWS lib (Closes #9550) - #9551

Open
dmitrii-f-t27 wants to merge 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:chat-w1a-repair
Open

dmitrii-f-t27 wants to merge 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:chat-w1a-repair

Conversation

@dmitrii-f-t27

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

Copy link
Copy Markdown
Contributor

Closes #9550

Part of the Trinity Secure Chat rewrite (gHashTag/trios crates/trios-chat, epic gHashTag/trios#1812; stage-6 goal #4548).

Repairs two merged trios-chat specs so that they compile in Zig and their gen-rust output compiles under rustc:

  • specs/port/trios/crates/trios-chat/rings/CR-CHAT-02/src/skipped_message_key_gap_bound_guard.t27
  • specs/port/trios/crates/trios-chat/rings/CR-CHAT-LAWS/src/lib.t27

What changed

skipped_message_key_gap_bound_guard. A verdict struct (SkippedGapCode, Ok first, then the original variants in order, plus the u32 payload) replaces the payload enum variants and the ?SkippedGapError return. Duplicates are found by scanning earlier inputs, which is what the original's BTreeSet answers, instead of a [256]bool indexed by the key index (indices go up to 1,000,000). The order of checks is the original's; the IndexBelowMin check the original never makes is removed (the variant stays for the adapter). Tests: the 10 originals with exact verdicts, plus index 1,000,000, check order and helpers.

CR-CHAT-LAWS lib. The 12 laws are flat bytes, each followed by its zero byte: LAWS_PREIMAGE is exactly the byte string the original feeds to SHA-256; LAWS_OFFSETS gives each law's start. SHA-256 is not computed in .t27; it stays in the Rust adapter with sha2. The spec keeps the decision laws_hash_matches_reference(digest); no function returns the reference digest. Every test asserts at runtime; the prefix check includes the law number; a FNV-1a checksum test pins every byte of the table to a value computed from the original Rust strings.

Both specs get a full-path module line (the LAWS spec no longer collides with the trios-store src_lib seal), seals saved with t27c built from this tree, and the t27b ledger gets a row for the repaired smkg spec (the LAWS row already says pass).

Checks (local, macOS arm64, Zig 0.16.0, rustc 1.94.0, t27c and t27b built from this tree at 394732e)

Check skipped_message_key_gap_bound_guard CR-CHAT-LAWS lib
t27c test-report 17/17 pass, 0 vacuous 6/6 pass, 0 vacuous
t27b test --check 17/17, 34 runtime asserts 6/6, 131 runtime asserts
t27c gen-rust + rustc --crate-type lib 0 errors 0 errors
t27c coverage Untested 0 (3 functions) Untested 0 (8 functions)
t27c seal --verify all hashes MATCH all hashes MATCH
ASCII only yes yes

Swap readiness (scratch, not part of this PR):

  • smkg: the 10 original #[test]s, byte-identical, pass 10/10 against the generated Rust behind a 23-line adapter. Mutating gap > SMKG_MAX_GAP to >= in the generated file fails smkg_09; after restore the file is byte-identical to fresh gen-rust output and 10/10 pass again. The five new expectations (index 1,000,000; [5, 6, 5] duplicate before order; [5, 3, 5] not increasing; [4, 2000000] too large before gap; 257 indices) were also run against the original Rust and pass there.
  • LAWS: the 4 original tests pass with the adapter computing sha2::Sha256 over the generated LAWS_PREIMAGE; that digest equals d8c962d0cfe111bf72f9d59f2296baf015ff5c9f0390cf807b7cc08c706f3a98 and the generated preimage equals the joined original strings byte for byte.

Gates run locally on this tree: check_seal_coverage.py OK; check_seal_currency.py 0 stale; check_assertionless_spec_tests.py ok; tri types ratchet CLEAN (110/110). tools/dupe_scan.py reports 12 errors, the same set as on master d06eaed (none names a function of these specs).

CI on the head SHA 394732e

Required: validate SUCCESS, check-linked-issue SUCCESS, parse-ratchet SUCCESS, own-language SUCCESS. 28 of 31 checks green (Corpus ratchet, emit-bitexact, coverage and spec-guards included). Three reds; none names these specs, and each matches master d06eaed:

Red check On this PR 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 set; the same set is red on #9131
cli-tri cargo build -p tri --all-targets with rustc 1.99.0: errors in cli/dlc10/src/lib.rs, cli/tri/src/gates.rs and gen/rust/tri/network/payout.rs (this PR touches none of them) last master run https://github.com/gHashTag/t27/actions/runs/38297236431 fails at the same step with rustc 1.99.0
t27b-native-ratchet 155 UNLISTED/UNEXPECTED rows, all other specs; the rows of both specs here (pass) are not named the identical 155-row set is red on #9131 (head a5a960f, also merged with d06eaed)

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

Not claimed: no swap into gHashTag/trios happens here; the trios side is a later PR.

Dmitrii Fedorov (@dmitrii-f-t27)

skipped_message_key_gap_bound_guard: verdict struct instead of payload
enum variants and ?Enum (Zig BLOCKED, 12 rustc errors); duplicate check
scans earlier inputs instead of a [256]bool indexed by the key index (up
to 1,000,000); original order of checks; the IndexBelowMin check the
original never makes is gone (variant kept). 17 tests, 34 asserts.

CR-CHAT-LAWS lib: the 12 laws as flat bytes, each followed by its zero
byte (the original's exact SHA-256 input), plus offsets; SHA-256 stays
in the Rust adapter; laws_hash_matches_reference() keeps the decision and
no function returns the reference digest. 6 tests, 131 asserts, none
vacuous; prefix check includes the law number.

Full-path module lines; seals saved with t27c built from this tree
(d06eaed); t27b ledger row for the repaired smkg spec.

Refs gHashTag#9550
@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.

Repair trios-chat specs: skipped_message_key_gap_bound_guard (BLOCKED) and CR-CHAT-LAWS lib (vacuous, does not lower to Rust)

1 participant