Repository navigation
04 Final Submission — Slice E: Tunnel byte counters (Issue #6) - #8
Conversation
Slice E of blitzcrieg1#6. Record bytes_tx and bytes_rx on network_egress evidence so an investigation can tell a DNS-sized connection from a bulk transfer. The counters are sizes only, never content: the tunnel sums the bytes it relays in each direction and no relayed byte is inspected or stored, so the destination-only evidence policy (method, host, port, connection_established) is unchanged. denied and error attempts relay nothing and carry 0/0. Totals are known only at connection close, so the success event is now emitted when the tunnel closes instead of when it opens. denied/error emission timing is unchanged (reply first, emit second). Unit tests cover rendering and both tunnel directions; scripts/smoke.sh asserts positive counters on the two success events and 0/0 on the refused and failed attempts. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Reviewed against the slice E acceptance criteria. I ran the full gates locally at this head: Two process items before this can merge:
After both, I will approve the CI workflows and re-check at the updated head. |
|
Merged with credit. Slice E lands as-is: Slices A, B, C, D, F and G remain open on #6 for anyone else reading. |
Ships slice E from #6, contributed by @karuka744 in #8: bytes_tx and bytes_rx on network_egress evidence, sizes only, zeros on denied and errored attempts. Destination-only evidence policy unchanged. Generated by Mistral Vibe. Co-authored-by: Mistral Vibe <[email protected]>
Implements Slice E of #6.
What changed
Adds
bytes_txandbytes_rxtonetwork_egressevidence so an investigationcan tell a DNS-sized connection from a bulk transfer.
src/json.rs—EgressEventgainsbytes_tx: u64/bytes_rx: u64;to_json()emits them as bare integers insidetool.arguments.src/proxy.rs—tunnel()now returns(tx, rx); the client→upstream threadreports its byte count back through its
JoinHandle.bytes_txalso includesthe request bytes already written to the upstream before the relay loop
(
initial_bytes). The success event is emitted at connection close withthe final totals.
src/emit.rs— tests updated; the ingest-delivery test asserts the countersreach the POST body.
scripts/smoke.sh— asserts counters are non-negative ints on every event,positive on both success events, and
0/0on the refused and failed attempts.README.md— Events section documents the counters and the close-time emission.Why it keeps the evidence policy destination-only
The counters are sizes, not content. The tunnel sums the bytes it relays in
each direction; no relayed byte is inspected, buffered for inspection, or
recorded. The declared fields are still
scheme, method, host, port, policy, connection_establishedplus the two integer counts.deniedanderrorattempts relay nothing and carry
0/0. Direction:bytes_txisclient → destination (egress payload),
bytes_rxis destination → client.Behavior change (before/after)
Totals are known only once a connection closes, so the
successevent nowfires at close instead of at open.
denied/errortiming is unchanged(reply first, emit second). A never-closing tunnel therefore records its
observation when it finally ends rather than when it starts — the counts are
the point of the slice, and they do not exist until close.
Before (
main): success event, no byte fields.After (this branch — real line from
target/release, synthetic loopbackorigin, requested path
/secret-path?token=abc):{"source_app":"agentmetry","adapter":"guard","event_type":"network_egress","correlation_id":"","session_id":"","timestamp_utc":"2026-11-29T17:24:15.166281Z","outcome":"success","tool":{"qualified":"guard.egress","server":"guard","command":"GET 127.0.0.1:49264","arguments":{"scheme":"http","method":"GET","host":"127.0.0.1","port":49264,"policy":null,"connection_established":true,"bytes_tx":130,"bytes_rx":114}}}The path and query (
secret-path,token=abc) appear nowhere in the event —only the destination and the byte volumes.
Tests
cargo test --locked— 47 passed; 0 failed.cargo clippy --all-targets -- -D warnings— clean.scripts/smoke.sh— passing.No new third-party crates. Synthetic traces and markers only.
Terminal output proving the gate (local)
Toolchain used locally:
stable-x86_64-pc-windows-gnu(self-contained linking;no MSVC/mingw linker was present on the host, so rustup + the gnu target were
installed to verify). The GNU override is local rustup state, not committed.
Files changed
Fixes #6
Bounty payout (no bank/Stripe):
[email protected]0xA5562760194Aa3399e260E6eE3d8D2D987514CeD5XXbb5HWXRyrSMptThXeR2Wk4B6syaJGBt8mdfn6QKyq