S1 lane: protocol codec (Rust + TS), fuzzing, golden vectors #15

Closed
opened 2026-10-06 10:10:48 +00:00 by kayg · 19 comments
Owner

Implement contracts/wire.md §2–§4 in infraternal-protocol (Rust) and packages/protocol (TS), with shared golden test vectors, the fuzz target wire_frame_decode, and Criterion and JS benchmarks against the #12 numbers. Base: s1-base 386acfd. Part of #9.

Implement `contracts/wire.md` §2–§4 in `infraternal-protocol` (Rust) and `packages/protocol` (TS), with shared golden test vectors, the fuzz target `wire_frame_decode`, and Criterion and JS benchmarks against the #12 numbers. Base: `s1-base` `386acfd`. Part of #9.
Author
Owner

Starting protocol codec work on branch lane-protocol, based on 386acfd3dc. Finding: contracts/wire.md §2-§3 says LEB128 varint but does not define maximum width or whether non-minimal encodings are valid. Proposed implementation profile: unsigned u32 LEB128, shortest-form only; frame lengths are bounded to 4 MiB before any allocation, and stream IDs / nested string lengths use the same u32 representation. I will implement this consistently in Rust and TypeScript and flag the added constraint in the result.

Starting protocol codec work on branch lane-protocol, based on 386acfd3dc6255c7f58f98b4f114d5d7326292ad. Finding: contracts/wire.md §2-§3 says LEB128 varint but does not define maximum width or whether non-minimal encodings are valid. Proposed implementation profile: unsigned u32 LEB128, shortest-form only; frame lengths are bounded to 4 MiB before any allocation, and stream IDs / nested string lengths use the same u32 representation. I will implement this consistently in Rust and TypeScript and flag the added constraint in the result.
Author
Owner

Finding: while implementing vectors, the initial Close encoder incorrectly added a varint reason length. contracts/wire.md §4 specifies u16 code followed by UTF-8 reason to the end of the body; the §2 length-prefixed string rule applies only where the table says varint+utf8. The shared golden test exposed the extra 0x04 byte in close.bin. Fixed Rust and TypeScript encoders and regenerated contracts/vectors/wire/close.bin; bun test and the Rust protocol tests now pass all 17 frame vectors.

Finding: while implementing vectors, the initial Close encoder incorrectly added a varint reason length. contracts/wire.md §4 specifies u16 code followed by UTF-8 reason to the end of the body; the §2 length-prefixed string rule applies only where the table says varint+utf8. The shared golden test exposed the extra 0x04 byte in close.bin. Fixed Rust and TypeScript encoders and regenerated contracts/vectors/wire/close.bin; bun test and the Rust protocol tests now pass all 17 frame vectors.
Author
Owner

Performance finding (measured in crates/infraternal-protocol/benches/wire_codec.rs): Criterion used the spike's 20 samples, 200 ms warmup and 500 ms measurement. Sequence/payload summary medians were 10.635 ns for 1-byte Input and 10.952 ns for 64-byte Output; full typed-frame medians were 14.378 ns and 15.275 ns. The #12 spike reported 4.63 ns and 4.95 ns for its simpler four-frame decoder with fixed-width length framing. The full §4 typed decoder is slower, and I'm recording both summary and full-path results while completing the requested fuzz and checks.

Performance finding (measured in crates/infraternal-protocol/benches/wire_codec.rs): Criterion used the spike's 20 samples, 200 ms warmup and 500 ms measurement. Sequence/payload summary medians were 10.635 ns for 1-byte Input and 10.952 ns for 64-byte Output; full typed-frame medians were 14.378 ns and 15.275 ns. The #12 spike reported 4.63 ns and 4.95 ns for its simpler four-frame decoder with fixed-width length framing. The full §4 typed decoder is slower, and I'm recording both summary and full-path results while completing the requested fuzz and checks.
Author
Owner

Finding from review: crates/infraternal-protocol/src/lib.rs::StreamDecoder::buffer_bytes currently uses try_reserve_exact for each received chunk. The streaming harness feeds 3-byte chunks (fuzz/fuzz_targets/wire_stream_decode.rs); for a 4 KiB partial frame, exact growth can request about 1,365 reallocations and copy roughly 2.8 MiB cumulatively. I am changing growth to geometric capacity bounded by the validated frame length, then restarting the streaming fuzz run against that implementation.

Finding from review: crates/infraternal-protocol/src/lib.rs::StreamDecoder::buffer_bytes currently uses try_reserve_exact for each received chunk. The streaming harness feeds 3-byte chunks (fuzz/fuzz_targets/wire_stream_decode.rs); for a 4 KiB partial frame, exact growth can request about 1,365 reallocations and copy roughly 2.8 MiB cumulatively. I am changing growth to geometric capacity bounded by the validated frame length, then restarting the streaming fuzz run against that implementation.
Author
Owner

Finding: Bun 1.4.2's default TextDecoder strips an initial UTF-8 BOM () and returns , while Rust std::str::from_utf8 preserves it as U+FEFF. That would make the same Hello.client_info bytes decode differently across clients. I will set ignoreBOM: true in packages/protocol/src/codec.ts and change the shared Hello vector to begin with U+FEFF so both implementations prove parity.

Finding: Bun 1.4.2's default TextDecoder strips an initial UTF-8 BOM () and returns , while Rust std::str::from_utf8 preserves it as U+FEFF. That would make the same Hello.client_info bytes decode differently across clients. I will set ignoreBOM: true in packages/protocol/src/codec.ts and change the shared Hello vector to begin with U+FEFF so both implementations prove parity.
Author
Owner

Finding: Bun 1.4.2 default TextDecoder strips the initial UTF-8 BOM bytes EF BB BF and returns only the following A, while Rust std::str::from_utf8 preserves U+FEFF. The same Hello.client_info bytes would decode differently across clients. I will set ignoreBOM true in packages/protocol/src/codec.ts and change the shared Hello vector to begin with U+FEFF so both implementations prove parity.

Finding: Bun 1.4.2 default TextDecoder strips the initial UTF-8 BOM bytes EF BB BF and returns only the following A, while Rust std::str::from_utf8 preserves U+FEFF. The same Hello.client_info bytes would decode differently across clients. I will set ignoreBOM true in packages/protocol/src/codec.ts and change the shared Hello vector to begin with U+FEFF so both implementations prove parity.
Author
Owner

Fuzz evidence on final Rust source: wire_frame_decode completed 601 s with 323,552,539 executions (538,356 exec/s average, 535 MiB peak RSS); wire_stream_decode completed 601 s with 13,342,465 executions (22,200 exec/s average, 510 MiB peak RSS). Neither target found a crash. The streaming run exercised the geometric bounded-growth buffer implementation.

Fuzz evidence on final Rust source: wire_frame_decode completed 601 s with 323,552,539 executions (538,356 exec/s average, 535 MiB peak RSS); wire_stream_decode completed 601 s with 13,342,465 executions (22,200 exec/s average, 510 MiB peak RSS). Neither target found a crash. The streaming run exercised the geometric bounded-growth buffer implementation.
Author
Owner

Benchmark evidence: the lower-contention Criterion run (same 20 samples, 200 ms warmup, 500 ms measure as #12 on the i9-9900K) measured Rust sequence/payload decode at 10.635 ns for Input/1 B and 10.952 ns for Output/64 B; full typed decode at 14.378 ns and 15.275 ns; reusable encode at 14.972 ns and 10.043 ns. Compared with #12 specialized decode at 4.63 ns and 4.95 ns, the new full codec costs about 3.1x and 3.1x (summary-only decode about 2.3x and 2.2x), while remaining about 5x faster than the #12 prost comparison. Bun medians were 232.8 ns and 237.5 ns (about 4.04M exec/s), versus #12 Chrome 153 at 287.1 ns and 283.3 ns; runtime comparison is not apples-to-apples. A later retry was discarded as host-contended: mpstat showed 89% average CPU busy across all cores during concurrent OpenSSL builds, and Criterion intervals widened to 24.7–47.3 ns for Input encode and 35.8–46.0 ns for Input summary decode.

Benchmark evidence: the lower-contention Criterion run (same 20 samples, 200 ms warmup, 500 ms measure as #12 on the i9-9900K) measured Rust sequence/payload decode at 10.635 ns for Input/1 B and 10.952 ns for Output/64 B; full typed decode at 14.378 ns and 15.275 ns; reusable encode at 14.972 ns and 10.043 ns. Compared with #12 specialized decode at 4.63 ns and 4.95 ns, the new full codec costs about 3.1x and 3.1x (summary-only decode about 2.3x and 2.2x), while remaining about 5x faster than the #12 prost comparison. Bun medians were 232.8 ns and 237.5 ns (about 4.04M exec/s), versus #12 Chrome 153 at 287.1 ns and 283.3 ns; runtime comparison is not apples-to-apples. A later retry was discarded as host-contended: mpstat showed 89% average CPU busy across all cores during concurrent OpenSSL builds, and Criterion intervals widened to 24.7–47.3 ns for Input encode and 35.8–46.0 ns for Input summary decode.
Author
Owner

Finished S1 lane protocol codec on branch lane-protocol. Head: 407057272ce0e33c8b9e6dfed10a03c719887e77.

Both final-source cargo-fuzz runs completed 601 seconds without crashes: wire_frame_decode 323,552,539 executions (538,356/s average, 535 MiB peak RSS); wire_stream_decode 13,342,465 executions (22,200/s average, 510 MiB peak RSS).

Benchmark results and the host-contention caveat are in the preceding issue comment. Bun and Rust golden tests pass against the same 17-frame manifest. The contract clarifies the previously unspecified varint rule as shortest-form unsigned u32 LEB128.

Required gate command exited 0. Gate output (verbatim):


==> fmt

==> clippy
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s

==> test
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.06s
     Running unittests src/main.rs (target/debug/deps/infraternal-239f4951fa340219)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_agent-eadaa10b8c42bfd9)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_api-4480fd7032f11ca2)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_ssh-22a9a893799c7f17)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_protocol-6aec3e05ca065f96)

running 4 tests
test tests::mux_round_trip_and_incremental_decoders_preserve_frame_order ... ok
test tests::rejects_oversized_noncanonical_and_malformed_frames_before_buffering_body ... ok
test tests::oversized_encode_keeps_the_reusable_output_unchanged ... ok
test tests::golden_vectors_encode_and_decode_every_contract_frame ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_server-3a7dcd467cd5ddf2)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_shim-2036f3f8f778c3eb)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_agent

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_plugin_api

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_plugin_ssh

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_protocol

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_server

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_shim

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s


==> cargo-deny
advisories ok, bans ok, licenses ok, sources ok

==> static builds
    Finished `release` profile [optimized] target(s) in 0.04s
target/x86_64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, stripped
PT_INTERP: absent; size: 705624 bytes
    Finished `release` profile [optimized] target(s) in 0.03s
target/aarch64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped
PT_INTERP: absent; size: 607880 bytes
server subcommand: exit 2, not implemented
agent subcommand: exit 2, not implemented

+---------------------------+--------------+
| Rust gate                 | Result       |
+---------------------------+--------------+
| fmt                       | PASS         |
| clippy                    | PASS         |
| test                      | PASS         |
| cargo-deny                | PASS         |
| static builds             | PASS         |
+---------------------------+--------------+

==> TypeScript protocol tests
bun test v1.4.2 (744846f84)

src/codec.test.ts:
(pass) wire protocol golden vectors > encodes and decodes each frame exactly as the shared manifest describes [5.22ms]
(pass) wire protocol golden vectors > returns borrowed payload views and writes into reusable buffers [0.18ms]
(pass) wire protocol golden vectors > decodes muxed messages split across WebSocket messages [0.76ms]
(pass) wire protocol golden vectors > rejects oversized, non-canonical, unknown, and malformed frame bytes [0.18ms]

 4 pass
 0 fail
 63 expect() calls
Ran 4 tests across 1 file. [10.00ms]
Finished S1 lane protocol codec on branch lane-protocol. Head: 407057272ce0e33c8b9e6dfed10a03c719887e77. Both final-source cargo-fuzz runs completed 601 seconds without crashes: wire_frame_decode 323,552,539 executions (538,356/s average, 535 MiB peak RSS); wire_stream_decode 13,342,465 executions (22,200/s average, 510 MiB peak RSS). Benchmark results and the host-contention caveat are in the preceding issue comment. Bun and Rust golden tests pass against the same 17-frame manifest. The contract clarifies the previously unspecified varint rule as shortest-form unsigned u32 LEB128. Required gate command exited 0. Gate output (verbatim): ```text ==> fmt ==> clippy Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s ==> test Finished `test` profile [unoptimized + debuginfo] target(s) in 0.06s Running unittests src/main.rs (target/debug/deps/infraternal-239f4951fa340219) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_agent-eadaa10b8c42bfd9) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_api-4480fd7032f11ca2) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_ssh-22a9a893799c7f17) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_protocol-6aec3e05ca065f96) running 4 tests test tests::mux_round_trip_and_incremental_decoders_preserve_frame_order ... ok test tests::rejects_oversized_noncanonical_and_malformed_frames_before_buffering_body ... ok test tests::oversized_encode_keeps_the_reusable_output_unchanged ... ok test tests::golden_vectors_encode_and_decode_every_contract_frame ... ok test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_server-3a7dcd467cd5ddf2) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_shim-2036f3f8f778c3eb) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_agent running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_plugin_api running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_plugin_ssh running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_protocol running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_server running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_shim running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s ==> cargo-deny advisories ok, bans ok, licenses ok, sources ok ==> static builds Finished `release` profile [optimized] target(s) in 0.04s target/x86_64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, stripped PT_INTERP: absent; size: 705624 bytes Finished `release` profile [optimized] target(s) in 0.03s target/aarch64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped PT_INTERP: absent; size: 607880 bytes server subcommand: exit 2, not implemented agent subcommand: exit 2, not implemented +---------------------------+--------------+ | Rust gate | Result | +---------------------------+--------------+ | fmt | PASS | | clippy | PASS | | test | PASS | | cargo-deny | PASS | | static builds | PASS | +---------------------------+--------------+ ==> TypeScript protocol tests bun test v1.4.2 (744846f84) src/codec.test.ts: (pass) wire protocol golden vectors > encodes and decodes each frame exactly as the shared manifest describes [5.22ms] (pass) wire protocol golden vectors > returns borrowed payload views and writes into reusable buffers [0.18ms] (pass) wire protocol golden vectors > decodes muxed messages split across WebSocket messages [0.76ms] (pass) wire protocol golden vectors > rejects oversized, non-canonical, unknown, and malformed frame bytes [0.18ms] 4 pass 0 fail 63 expect() calls Ran 4 tests across 1 file. [10.00ms] ```
Author
Owner

Independent read-only review started on lane-protocol, base 386acfd3dc, head 407057272ce0e33c8b9e6dfed10a03c719887e77. Reviewing safety, Rust/TypeScript parity, fuzzing, performance, API and history.

Independent read-only review started on lane-protocol, base 386acfd3dc6255c7f58f98b4f114d5d7326292ad, head 407057272ce0e33c8b9e6dfed10a03c719887e77. Reviewing safety, Rust/TypeScript parity, fuzzing, performance, API and history.
Author
Owner

P1 blocker reproduced in both runtimes: incremental mux header refill copies up to 10 bytes without respecting the newly completed frame boundary, then clears the entire buffer (Rust src/lib.rs around 489-531; TS src/codec.ts around 213-242). Feed hex 0005140100000000030f0000 in chunks [first byte, remainder]: only Credit is delivered, then Rust EmptyFrame / TS empty-frame. Two valid Close envelopes 00030f000000030f0000 split after byte 1 silently deliver only one callback. Add all-split multi-frame equivalence tests; consume only the header or preserve buffered surplus.

P1 blocker reproduced in both runtimes: incremental mux header refill copies up to 10 bytes without respecting the newly completed frame boundary, then clears the entire buffer (Rust src/lib.rs around 489-531; TS src/codec.ts around 213-242). Feed hex 0005140100000000030f0000 in chunks [first byte, remainder]: only Credit is delivered, then Rust EmptyFrame / TS empty-frame. Two valid Close envelopes 00030f000000030f0000 split after byte 1 silently deliver only one callback. Add all-split multi-frame equivalence tests; consume only the header or preserve buffered surplus.
Author
Owner

Review evidence: both Rust and TS fail 2/769 split-position cases over repeated golden vectors (close.bin split 1: one callback and 8 retained bytes; credit.bin split 1: one callback then EmptyFrame). Rust checks all 359 golden-vector truncations as Incomplete. Direct decoder differential: 24,504 deterministic mutated/golden/varint/mux cases + 3,450 cases from 119 frame and 1,606 stream corpus files, zero divergences (accepted 9,126 and 2,002 respectively); outputs and consumed lengths compared via re-encoding. Replay fuzz coverage: frame cov 280 / 963 counters, stream cov 472 / 1347 counters; no crash, but no semantic oracle and fixed 3-byte chunks do not exercise the found refill over-read. Evidence target/review--summary.json and target/review-fuzz-.log. History blocker: git log s1-base..lane-protocol contains only 4070572, violating the requested logical-step commit split. Fast gate passes; review verdict pending final report.

Review evidence: both Rust and TS fail 2/769 split-position cases over repeated golden vectors (close.bin split 1: one callback and 8 retained bytes; credit.bin split 1: one callback then EmptyFrame). Rust checks all 359 golden-vector truncations as Incomplete. Direct decoder differential: 24,504 deterministic mutated/golden/varint/mux cases + 3,450 cases from 119 frame and 1,606 stream corpus files, zero divergences (accepted 9,126 and 2,002 respectively); outputs and consumed lengths compared via re-encoding. Replay fuzz coverage: frame cov 280 / 963 counters, stream cov 472 / 1347 counters; no crash, but no semantic oracle and fixed 3-byte chunks do not exercise the found refill over-read. Evidence target/review-*-summary.json and target/review-fuzz-*.log. History blocker: git log s1-base..lane-protocol contains only 4070572, violating the requested logical-step commit split. Fast gate passes; review verdict pending final report.
Author
Owner

Independent read-only review finished. Verdict: MERGE AFTER FIXES.
Head: 407057272ce0e33c8b9e6dfed10a03c719887e77

Blockers:

  • P1: Rust MuxStreamDecoder (src/lib.rs:485-520) and TS WebSocketFrameDecoder (codec.ts:188-214) lose trailing frame bytes during incomplete-header refill. Two valid muxed Close frames, hex 00030f000000030f0000, fed as first byte then remainder, silently emit only one callback in BOTH runtimes with no error. Fix frame-boundary consumption and add exhaustive multi-frame split regressions and a stream-equivalence fuzz oracle. Both runtimes fail 2/769 golden-vector split cases.
  • P2: one commit 4070572 for the entire lane violates the explicit owner rule. Split by contract, dependencies, Rust/TS codec modules, incremental modules, vectors/tests, fuzzing, benches and gate integration. Full proposed split is in the findings report. No history rewritten by this review.

Evidence: direct differential 24,504 generated cases plus 3,450 existing fuzz-corpus mode/case pairs, zero Rust/TS divergences; all 359 golden-vector truncations incomplete. Fuzz replay frame cov 280/963 counters and stream cov 472/1347, no crash; fixed 3-byte chunks and absent semantic assertions miss the data-loss bug. Full Rust decode central 12.040 ns input / 11.668 ns 64B output, approximately 0.18% one-core CPU at 10 MB/s with 64B chunks, not an end-to-end latency result. Borrowed direct decode works over Bytes, but internal-Vec streaming callbacks cannot transfer retained payload ownership zero-copy to async tasks. Strict TS compilation separately passed; add it to fast gate.

Findings appended to /home/kayg/.local/state/codex-jobs/infraternal/review-protocol/findings.md. Repro/data/bench/fuzz/gate artifacts are under the lane worktree target/review-*. Tracked worktree remains clean. No code edits, commits, pushes or issue closure.

scripts/verify fast exited 0; complete output verbatim:


==> fmt

==> clippy
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s

==> test
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.06s
     Running unittests src/main.rs (target/debug/deps/infraternal-239f4951fa340219)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_agent-eadaa10b8c42bfd9)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_api-4480fd7032f11ca2)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_ssh-22a9a893799c7f17)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_protocol-6aec3e05ca065f96)

running 4 tests
test tests::rejects_oversized_noncanonical_and_malformed_frames_before_buffering_body ... ok
test tests::mux_round_trip_and_incremental_decoders_preserve_frame_order ... ok
test tests::oversized_encode_keeps_the_reusable_output_unchanged ... ok
test tests::golden_vectors_encode_and_decode_every_contract_frame ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_server-3a7dcd467cd5ddf2)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_shim-2036f3f8f778c3eb)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_agent

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_plugin_api

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_plugin_ssh

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_protocol

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_server

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_shim

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s


==> cargo-deny
advisories ok, bans ok, licenses ok, sources ok

==> static builds
    Finished `release` profile [optimized] target(s) in 0.04s
target/x86_64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, stripped
PT_INTERP: absent; size: 705624 bytes
    Finished `release` profile [optimized] target(s) in 0.04s
target/aarch64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped
PT_INTERP: absent; size: 607880 bytes
server subcommand: exit 2, not implemented
agent subcommand: exit 2, not implemented

+---------------------------+--------------+
| Rust gate                 | Result       |
+---------------------------+--------------+
| fmt                       | PASS         |
| clippy                    | PASS         |
| test                      | PASS         |
| cargo-deny                | PASS         |
| static builds             | PASS         |
+---------------------------+--------------+

==> TypeScript protocol tests
bun test v1.4.2 (744846f84)

src/codec.test.ts:
(pass) wire protocol golden vectors > encodes and decodes each frame exactly as the shared manifest describes [5.00ms]
(pass) wire protocol golden vectors > returns borrowed payload views and writes into reusable buffers [0.24ms]
(pass) wire protocol golden vectors > decodes muxed messages split across WebSocket messages [0.98ms]
(pass) wire protocol golden vectors > rejects oversized, non-canonical, unknown, and malformed frame bytes [0.20ms]

 4 pass
 0 fail
 63 expect() calls
Ran 4 tests across 1 file. [12.00ms]
Independent read-only review finished. Verdict: MERGE AFTER FIXES. Head: 407057272ce0e33c8b9e6dfed10a03c719887e77 Blockers: - P1: Rust MuxStreamDecoder (src/lib.rs:485-520) and TS WebSocketFrameDecoder (codec.ts:188-214) lose trailing frame bytes during incomplete-header refill. Two valid muxed Close frames, hex 00030f000000030f0000, fed as first byte then remainder, silently emit only one callback in BOTH runtimes with no error. Fix frame-boundary consumption and add exhaustive multi-frame split regressions and a stream-equivalence fuzz oracle. Both runtimes fail 2/769 golden-vector split cases. - P2: one commit 4070572 for the entire lane violates the explicit owner rule. Split by contract, dependencies, Rust/TS codec modules, incremental modules, vectors/tests, fuzzing, benches and gate integration. Full proposed split is in the findings report. No history rewritten by this review. Evidence: direct differential 24,504 generated cases plus 3,450 existing fuzz-corpus mode/case pairs, zero Rust/TS divergences; all 359 golden-vector truncations incomplete. Fuzz replay frame cov 280/963 counters and stream cov 472/1347, no crash; fixed 3-byte chunks and absent semantic assertions miss the data-loss bug. Full Rust decode central 12.040 ns input / 11.668 ns 64B output, approximately 0.18% one-core CPU at 10 MB/s with 64B chunks, not an end-to-end latency result. Borrowed direct decode works over Bytes, but internal-Vec streaming callbacks cannot transfer retained payload ownership zero-copy to async tasks. Strict TS compilation separately passed; add it to fast gate. Findings appended to /home/kayg/.local/state/codex-jobs/infraternal/review-protocol/findings.md. Repro/data/bench/fuzz/gate artifacts are under the lane worktree target/review-*. Tracked worktree remains clean. No code edits, commits, pushes or issue closure. scripts/verify fast exited 0; complete output verbatim: ``` ==> fmt ==> clippy Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s ==> test Finished `test` profile [unoptimized + debuginfo] target(s) in 0.06s Running unittests src/main.rs (target/debug/deps/infraternal-239f4951fa340219) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_agent-eadaa10b8c42bfd9) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_api-4480fd7032f11ca2) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_ssh-22a9a893799c7f17) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_protocol-6aec3e05ca065f96) running 4 tests test tests::rejects_oversized_noncanonical_and_malformed_frames_before_buffering_body ... ok test tests::mux_round_trip_and_incremental_decoders_preserve_frame_order ... ok test tests::oversized_encode_keeps_the_reusable_output_unchanged ... ok test tests::golden_vectors_encode_and_decode_every_contract_frame ... ok test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_server-3a7dcd467cd5ddf2) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_shim-2036f3f8f778c3eb) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_agent running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_plugin_api running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_plugin_ssh running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_protocol running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_server running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_shim running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s ==> cargo-deny advisories ok, bans ok, licenses ok, sources ok ==> static builds Finished `release` profile [optimized] target(s) in 0.04s target/x86_64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, stripped PT_INTERP: absent; size: 705624 bytes Finished `release` profile [optimized] target(s) in 0.04s target/aarch64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped PT_INTERP: absent; size: 607880 bytes server subcommand: exit 2, not implemented agent subcommand: exit 2, not implemented +---------------------------+--------------+ | Rust gate | Result | +---------------------------+--------------+ | fmt | PASS | | clippy | PASS | | test | PASS | | cargo-deny | PASS | | static builds | PASS | +---------------------------+--------------+ ==> TypeScript protocol tests bun test v1.4.2 (744846f84) src/codec.test.ts: (pass) wire protocol golden vectors > encodes and decodes each frame exactly as the shared manifest describes [5.00ms] (pass) wire protocol golden vectors > returns borrowed payload views and writes into reusable buffers [0.24ms] (pass) wire protocol golden vectors > decodes muxed messages split across WebSocket messages [0.98ms] (pass) wire protocol golden vectors > rejects oversized, non-canonical, unknown, and malformed frame bytes [0.20ms] 4 pass 0 fail 63 expect() calls Ran 4 tests across 1 file. [12.00ms] ```
Author
Owner

Starting independent-review fixes on lane-protocol, original head 407057272ce0e33c8b9e6dfed10a03c719887e77, base s1-base 386acfd3dc. Read CLAUDE.md, DECISIONS.md, docs/ARCHITECTURE.md and all findings. Will first demonstrate split-header data loss in both runtimes, add stream differential/oracle coverage, strengthen fuzzing, and tag/rewrite the lane as gated atomic steps. No push.

Starting independent-review fixes on lane-protocol, original head 407057272ce0e33c8b9e6dfed10a03c719887e77, base s1-base 386acfd3dc6255c7f58f98b4f114d5d7326292ad. Read CLAUDE.md, DECISIONS.md, docs/ARCHITECTURE.md and all findings. Will first demonstrate split-header data loss in both runtimes, add stream differential/oracle coverage, strengthen fuzzing, and tag/rewrite the lane as gated atomic steps. No push.
Author
Owner

Confirmed P1 with failing tests before edits: target/regression-rust-before.log reports left 1/right 2 callbacks; target/regression-ts-before.log reports the missing second Close. Fixed both header refill paths to recheck length after each header byte, retaining the direct fast path. packages/protocol/src/stream.test.ts plus crates/infraternal-protocol/examples/stream_oracle.rs compare scalar fields, payloads, order, re-encoding and final buffered state: 134 streams, 11,439 identical schedules, zero divergences. Every boundary, empty chunks, all 1–5-byte mux widths, all 17 vectors, minimum Close/Credit and seeded random multi-splits included. Added deterministic 4 MiB/oversized tests; strengthening fuzz oracles before timed runs.

Confirmed P1 with failing tests before edits: target/regression-rust-before.log reports left 1/right 2 callbacks; target/regression-ts-before.log reports the missing second Close. Fixed both header refill paths to recheck length after each header byte, retaining the direct fast path. packages/protocol/src/stream.test.ts plus crates/infraternal-protocol/examples/stream_oracle.rs compare scalar fields, payloads, order, re-encoding and final buffered state: 134 streams, 11,439 identical schedules, zero divergences. Every boundary, empty chunks, all 1–5-byte mux widths, all 17 vectors, minimum Close/Credit and seeded random multi-splits included. Added deterministic 4 MiB/oversized tests; strengthening fuzz oracles before timed runs.
Author
Owner

Review follow-ups: added strict TypeScript@5.9.3 compiler invocation to scripts/verify.d/ts.sh (Bun transpilation alone did not enforce decision 40). Documented incremental callback/copy/async retention limitations in both decoder APIs; borrowed direct decoders remain available for owning transport buffers. contracts/wire.md now gives redundant/overflow varint examples and requires consumer checked u64 exclusive sequence ends; Snapshot length does not advance out_seq. Connection integration must still enforce Hello ordering, stream ownership, direction/version/caps, JSON authorization, admission/reclamation and frozen upgrade layouts before implementation; this lane makes no auth or end-to-end budget claim. Benchmark evidence target/bench-before.log and target/bench-after.log: mux split_header id=0 central 66.419 -> 64.585 ns (overlapping intervals); id=u32::MAX 75.747 -> 108.05 ns (~32.3 ns for repeated header checks). Correctness justifies that bounded fragmented-path cost; direct full typed Output 12.294 -> 12.936 ns with overlapping intervals. Benchmarks ran locally alongside fuzzing, not on the pinned perf VM. Added mux/fragmentation cases to the Rust benchmark rather than weakening strict validation or refactoring enums without end-to-end evidence.

Review follow-ups: added strict TypeScript@5.9.3 compiler invocation to scripts/verify.d/ts.sh (Bun transpilation alone did not enforce decision 40). Documented incremental callback/copy/async retention limitations in both decoder APIs; borrowed direct decoders remain available for owning transport buffers. contracts/wire.md now gives redundant/overflow varint examples and requires consumer checked u64 exclusive sequence ends; Snapshot length does not advance out_seq. Connection integration must still enforce Hello ordering, stream ownership, direction/version/caps, JSON authorization, admission/reclamation and frozen upgrade layouts before implementation; this lane makes no auth or end-to-end budget claim. Benchmark evidence target/bench-before.log and target/bench-after.log: mux split_header id=0 central 66.419 -> 64.585 ns (overlapping intervals); id=u32::MAX 75.747 -> 108.05 ns (~32.3 ns for repeated header checks). Correctness justifies that bounded fragmented-path cost; direct full typed Output 12.294 -> 12.936 ns with overlapping intervals. Benchmarks ran locally alongside fuzzing, not on the pinned perf VM. Added mux/fragmentation cases to the Rust benchmark rather than weakening strict validation or refactoring enums without end-to-end evidence.
Author
Owner

Implementation complete on lane-protocol, head 6ac06c7f75; base s1-base 386acfd3dc. Original reviewed head preserved as lane-protocol-v1 (407057272ce0e33c8b9e6dfed10a03c719887e77). No push/deploy; issue remains open.

Review disposition:

  • P1 data loss fixed in Rust and TypeScript. Failing-first logs: target/regression-rust-before.log and target/regression-ts-before.log. Header refill reads one byte before rechecking the validated length; subsequent envelopes remain in the input. Rust regression module: crates/infraternal-protocol/src/stream_tests.rs.
  • Durable cross-runtime oracle: packages/protocol/src/stream.test.ts and crates/infraternal-protocol/examples/stream_oracle.rs. 134 streams / 11,439 identical chunk schedules / zero divergences. Includes every two-chunk boundary, empty chunks, all mux-id widths, 17 golden types, minimum Close/Credit, multiple trailing frames and seeded random multi-splits. Each decoder also matches direct decoded scalar fields, payloads, order, exact re-encoding and zero final retained bytes, preventing shared-bug parity from passing. Rust and TS deterministic tests cover full 4 MiB frames; oversized prefixes are rejected before body buffering.
  • P2 repaired by reconstructing 11 atomic steps on s1-base; every commit passed nix shell nixpkgs#binutils nixpkgs#file -c scripts/verify fast on its own tree. Logs target/atomic-gate-01.log through target/atomic-gate-11.log. Before TS integration, relevant TS steps additionally ran compiler/tests. Every commit body records choice/rejected alternatives/decisions and ends Refs: #15.
  • Fuzz quality strengthened: raw+direct mux round trips; selected chunk sizes including tiny and large refills and empty feeds; generated valid concatenations; stream/direct callback, terminal-error and incomplete-byte oracles. fuzz/seed.py reproducibly seeds all types and mux widths; fuzz/README.md records commands and oracle limits.
  • Compiler should-fix resolved: scripts/verify.d/ts.sh invokes pinned TypeScript 5.9.3 strict checking before Bun tests.
  • Ownership should-fix resolved: both incremental API docs disclose copies and callback-only payload lifetime. Owning Bytes/BytesMut adapters and scatter/gather encoding remain integration work; borrowed direct APIs already work without adding a bytes dependency.
  • Varint examples added in contracts/wire.md. Checked u64 exclusive ends and Snapshot non-advancement are now explicit consumer invariants; codec performs no sequence addition. Connection integration must test these along with Hello order/control stream, version/direction/caps, mux ownership, JSON schema/auth and admission/reclamation. Upgrade byte layouts/cap assignments must be specified before those frames are implemented; the current codec intentionally rejects unknown types. These are integration follow-ups, not claims of codec/session authorization or completed upgrade support.
  • Performance: target/bench-before.log / target/bench-after.log. Split-header id=0 central 66.419 -> 64.585 ns (overlapping intervals), u32::MAX 75.747 -> 108.05 ns (bounded ~32.3 ns for repeated header checks, required to prevent silent loss). Direct full typed Output central 12.294 -> 12.936 ns with overlapping intervals. Strict validation retained; no speculative enum refactor. Bun direct decode medians: Input 252.1 ns, Output 285.5 ns (target/bench-ts-fixed.log). Measurements ran locally alongside fuzzing, not on the pinned perf VM; they do not establish keystroke p99/end-to-end decisions 12/41. No UI/browser screenshot gate applies to this codec-only change.

Atomic commits:

4a616df clarify canonical varints and session sequence bounds #15
2bded22 add codec test and benchmark dependencies #15
df190dd implement borrowed Rust frames and direct mux codec #15
f09ee3e decode fragmented Rust frames without swallowing mux successors #15
91c4007 share golden wire vectors and verify Rust frame layouts #15
b2e3842 implement strict TypeScript direct wire codec and vector tests #15
947404e preserve TypeScript mux boundaries and compare both stream codecs #15
d548d33 fuzz raw and mux round trips with chunk-equivalence oracles #15
dbc98e0 benchmark typed decoding and fragmented mux reception #15
6d240ca add browser codec latency benchmark entry point #15
6ac06c7 enforce strict TypeScript compilation and codec parity in fast gate #15

Final-tree fast gate (exit 0), verbatim:


==> fmt

==> clippy
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s

==> test
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.07s
     Running unittests src/main.rs (target/debug/deps/infraternal-239f4951fa340219)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_agent-eadaa10b8c42bfd9)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_api-4480fd7032f11ca2)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_ssh-22a9a893799c7f17)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_protocol-6aec3e05ca065f96)

running 7 tests
test stream_tests::split_mux_header_preserves_trailing_close ... ok
test tests::mux_round_trip_and_incremental_decoders_preserve_frame_order ... ok
test tests::rejects_oversized_noncanonical_and_malformed_frames_before_buffering_body ... ok
test tests::oversized_encode_keeps_the_reusable_output_unchanged ... ok
test stream_tests::all_short_frame_splits_match_direct_decoding ... ok
test tests::golden_vectors_encode_and_decode_every_contract_frame ... ok
test stream_tests::maximum_sized_fragmented_frame_is_not_rejected ... ok

test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_server-3a7dcd467cd5ddf2)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/infraternal_shim-2036f3f8f778c3eb)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_agent

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_plugin_api

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_plugin_ssh

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_protocol

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_server

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests infraternal_shim

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s


==> cargo-deny
advisories ok, bans ok, licenses ok, sources ok

==> static builds
    Finished `release` profile [optimized] target(s) in 0.04s
target/x86_64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, stripped
PT_INTERP: absent; size: 705624 bytes
    Finished `release` profile [optimized] target(s) in 0.04s
target/aarch64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped
PT_INTERP: absent; size: 607880 bytes
server subcommand: exit 2, not implemented
agent subcommand: exit 2, not implemented

+---------------------------+--------------+
| Rust gate                 | Result       |
+---------------------------+--------------+
| fmt                       | PASS         |
| clippy                    | PASS         |
| test                      | PASS         |
| cargo-deny                | PASS         |
| static builds             | PASS         |
+---------------------------+--------------+

==> TypeScript protocol compiler

==> TypeScript protocol tests
bun test v1.4.2 (744846f84)

src/codec.test.ts:
(pass) wire protocol golden vectors > encodes and decodes each frame exactly as the shared manifest describes [5.69ms]
(pass) wire protocol golden vectors > returns borrowed payload views and writes into reusable buffers [0.26ms]
(pass) wire protocol golden vectors > decodes muxed messages split across WebSocket messages [1.10ms]
(pass) wire protocol golden vectors > rejects oversized, non-canonical, unknown, and malformed frame bytes [0.32ms]
(pass) split mux header preserves trailing Close [0.21ms]

src/stream.test.ts:
stream differential: 134 streams, 11439 schedules, zero divergences
(pass) Rust and TypeScript preserve every frame at all boundaries and random multi-splits [2236.77ms]
(pass) maximum frame size and fragmented oversized prefix obey the allocation boundary [6.78ms]

 7 pass
 0 fail
 34390 expect() calls
Ran 7 tests across 2 files. [2.26s]

Timed post-fix fuzz results (both exit 0, max_len=65536):

  • wire_frame_decode: 159,503,182 executions in 601 seconds, zero crashes or oracle failures, cov 649, ft 876. Log: target/fuzz-frame-fixed.log.
  • wire_stream_decode: 1,933,060 executions in 601 seconds, zero crashes or oracle failures, cov 912, ft 4107. Log: target/fuzz-stream-fixed.log.
    These are libFuzzer edge/feature counts, not source-coverage percentages. Summary: target/fuzz-fixed-summary.json. Worktree clean at final head; generated corpora/artifacts are ignored. All review findings answered above; no issue closure.
Implementation complete on lane-protocol, head 6ac06c7f75713feb2c5ce0f26e32712c9bf64b0e; base s1-base 386acfd3dc6255c7f58f98b4f114d5d7326292ad. Original reviewed head preserved as lane-protocol-v1 (407057272ce0e33c8b9e6dfed10a03c719887e77). No push/deploy; issue remains open. Review disposition: - P1 data loss fixed in Rust and TypeScript. Failing-first logs: target/regression-rust-before.log and target/regression-ts-before.log. Header refill reads one byte before rechecking the validated length; subsequent envelopes remain in the input. Rust regression module: crates/infraternal-protocol/src/stream_tests.rs. - Durable cross-runtime oracle: packages/protocol/src/stream.test.ts and crates/infraternal-protocol/examples/stream_oracle.rs. 134 streams / 11,439 identical chunk schedules / zero divergences. Includes every two-chunk boundary, empty chunks, all mux-id widths, 17 golden types, minimum Close/Credit, multiple trailing frames and seeded random multi-splits. Each decoder also matches direct decoded scalar fields, payloads, order, exact re-encoding and zero final retained bytes, preventing shared-bug parity from passing. Rust and TS deterministic tests cover full 4 MiB frames; oversized prefixes are rejected before body buffering. - P2 repaired by reconstructing 11 atomic steps on s1-base; every commit passed `nix shell nixpkgs#binutils nixpkgs#file -c scripts/verify fast` on its own tree. Logs target/atomic-gate-01.log through target/atomic-gate-11.log. Before TS integration, relevant TS steps additionally ran compiler/tests. Every commit body records choice/rejected alternatives/decisions and ends Refs: #15. - Fuzz quality strengthened: raw+direct mux round trips; selected chunk sizes including tiny and large refills and empty feeds; generated valid concatenations; stream/direct callback, terminal-error and incomplete-byte oracles. fuzz/seed.py reproducibly seeds all types and mux widths; fuzz/README.md records commands and oracle limits. - Compiler should-fix resolved: scripts/verify.d/ts.sh invokes pinned TypeScript 5.9.3 strict checking before Bun tests. - Ownership should-fix resolved: both incremental API docs disclose copies and callback-only payload lifetime. Owning Bytes/BytesMut adapters and scatter/gather encoding remain integration work; borrowed direct APIs already work without adding a bytes dependency. - Varint examples added in contracts/wire.md. Checked u64 exclusive ends and Snapshot non-advancement are now explicit consumer invariants; codec performs no sequence addition. Connection integration must test these along with Hello order/control stream, version/direction/caps, mux ownership, JSON schema/auth and admission/reclamation. Upgrade byte layouts/cap assignments must be specified before those frames are implemented; the current codec intentionally rejects unknown types. These are integration follow-ups, not claims of codec/session authorization or completed upgrade support. - Performance: target/bench-before.log / target/bench-after.log. Split-header id=0 central 66.419 -> 64.585 ns (overlapping intervals), u32::MAX 75.747 -> 108.05 ns (bounded ~32.3 ns for repeated header checks, required to prevent silent loss). Direct full typed Output central 12.294 -> 12.936 ns with overlapping intervals. Strict validation retained; no speculative enum refactor. Bun direct decode medians: Input 252.1 ns, Output 285.5 ns (target/bench-ts-fixed.log). Measurements ran locally alongside fuzzing, not on the pinned perf VM; they do not establish keystroke p99/end-to-end decisions 12/41. No UI/browser screenshot gate applies to this codec-only change. Atomic commits: ``` 4a616df clarify canonical varints and session sequence bounds #15 2bded22 add codec test and benchmark dependencies #15 df190dd implement borrowed Rust frames and direct mux codec #15 f09ee3e decode fragmented Rust frames without swallowing mux successors #15 91c4007 share golden wire vectors and verify Rust frame layouts #15 b2e3842 implement strict TypeScript direct wire codec and vector tests #15 947404e preserve TypeScript mux boundaries and compare both stream codecs #15 d548d33 fuzz raw and mux round trips with chunk-equivalence oracles #15 dbc98e0 benchmark typed decoding and fragmented mux reception #15 6d240ca add browser codec latency benchmark entry point #15 6ac06c7 enforce strict TypeScript compilation and codec parity in fast gate #15 ``` Final-tree fast gate (exit 0), verbatim: ```text ==> fmt ==> clippy Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s ==> test Finished `test` profile [unoptimized + debuginfo] target(s) in 0.07s Running unittests src/main.rs (target/debug/deps/infraternal-239f4951fa340219) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_agent-eadaa10b8c42bfd9) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_api-4480fd7032f11ca2) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_plugin_ssh-22a9a893799c7f17) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_protocol-6aec3e05ca065f96) running 7 tests test stream_tests::split_mux_header_preserves_trailing_close ... ok test tests::mux_round_trip_and_incremental_decoders_preserve_frame_order ... ok test tests::rejects_oversized_noncanonical_and_malformed_frames_before_buffering_body ... ok test tests::oversized_encode_keeps_the_reusable_output_unchanged ... ok test stream_tests::all_short_frame_splits_match_direct_decoding ... ok test tests::golden_vectors_encode_and_decode_every_contract_frame ... ok test stream_tests::maximum_sized_fragmented_frame_is_not_rejected ... ok test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_server-3a7dcd467cd5ddf2) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests src/lib.rs (target/debug/deps/infraternal_shim-2036f3f8f778c3eb) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_agent running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_plugin_api running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_plugin_ssh running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_protocol running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_server running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Doc-tests infraternal_shim running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s ==> cargo-deny advisories ok, bans ok, licenses ok, sources ok ==> static builds Finished `release` profile [optimized] target(s) in 0.04s target/x86_64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, stripped PT_INTERP: absent; size: 705624 bytes Finished `release` profile [optimized] target(s) in 0.04s target/aarch64-unknown-linux-musl/release/infraternal: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped PT_INTERP: absent; size: 607880 bytes server subcommand: exit 2, not implemented agent subcommand: exit 2, not implemented +---------------------------+--------------+ | Rust gate | Result | +---------------------------+--------------+ | fmt | PASS | | clippy | PASS | | test | PASS | | cargo-deny | PASS | | static builds | PASS | +---------------------------+--------------+ ==> TypeScript protocol compiler ==> TypeScript protocol tests bun test v1.4.2 (744846f84) src/codec.test.ts: (pass) wire protocol golden vectors > encodes and decodes each frame exactly as the shared manifest describes [5.69ms] (pass) wire protocol golden vectors > returns borrowed payload views and writes into reusable buffers [0.26ms] (pass) wire protocol golden vectors > decodes muxed messages split across WebSocket messages [1.10ms] (pass) wire protocol golden vectors > rejects oversized, non-canonical, unknown, and malformed frame bytes [0.32ms] (pass) split mux header preserves trailing Close [0.21ms] src/stream.test.ts: stream differential: 134 streams, 11439 schedules, zero divergences (pass) Rust and TypeScript preserve every frame at all boundaries and random multi-splits [2236.77ms] (pass) maximum frame size and fragmented oversized prefix obey the allocation boundary [6.78ms] 7 pass 0 fail 34390 expect() calls Ran 7 tests across 2 files. [2.26s] ``` Timed post-fix fuzz results (both exit 0, max_len=65536): - wire_frame_decode: 159,503,182 executions in 601 seconds, zero crashes or oracle failures, cov 649, ft 876. Log: target/fuzz-frame-fixed.log. - wire_stream_decode: 1,933,060 executions in 601 seconds, zero crashes or oracle failures, cov 912, ft 4107. Log: target/fuzz-stream-fixed.log. These are libFuzzer edge/feature counts, not source-coverage percentages. Summary: target/fuzz-fixed-summary.json. Worktree clean at final head; generated corpora/artifacts are ignored. All review findings answered above; no issue closure.
Author
Owner

Merged into dev as 7174d6b. Gate on the merge result: all PASS, TS 7/7.

Merged into `dev` as `7174d6b`. Gate on the merge result: all PASS, TS 7/7.
Author
Owner

Closed by the orchestrator during the 2026-10-28 handover (#254), on the owner's request to close finished issues. Evidence: Codec lane merged to dev as 7174d6b (verified ancestor of dev); P1 split-header finding fixed and fuzz clean. Reopen if anything is still missing.

Closed by the orchestrator during the 2026-10-28 handover (#254), on the owner's request to close finished issues. Evidence: Codec lane merged to dev as 7174d6b (verified ancestor of dev); P1 split-header finding fixed and fuzz clean. Reopen if anything is still missing.
kayg closed this issue 2026-10-28 17:52:08 +00:00
Sign in to join this conversation.
No labels
launch-qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/infraternal#15
No description provided.