Skip to content

iter-126: canonical network JSON shape for navigate --with-network and network - #166

Merged
ractive merged 2 commits into
mainfrom
iter-126/network-json-shape-consistency
Jul 19, 2026
Merged

iter-126: canonical network JSON shape for navigate --with-network and network#166
ractive merged 2 commits into
mainfrom
iter-126/network-json-shape-consistency

Conversation

@ractive

@ractive ractive commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes the network JSON shape flip. navigate --with-network (and the standalone network command) returned an inconsistent JSON shape: a {entries, …} object on busy pages but a bare array on quiet ones. .results.network.entries / .results.network.total_requests threw cannot index array half the time, and the documented summary fields were unreachable via --jq (which forces detail mode).
  • One canonical object on every path. New shared pub(crate) build_canonical_network + merge_summary_fields builders in network.rs. apply_network_controls now returns a single object — {entries, shown, total, truncated, total_requests, total_transfer_bytes, by_cause_type, slowest, timeout_reached, …} — on busy/quiet, detail/summary, --all/default. Summary counts always reflect the full capture, never the truncated/field-projected view.
  • Standalone network detail carries summary fields. The detail-mode envelope now merges the summary fields alongside results, so --jq users are no longer cut off from total_requests/total_transfer_bytes/slowest.
  • Docs. args.rs help text documents the canonical shape with a bare-array backward-compat note (both the network output line and the navigate --with-network long_about section).

Test plan

  • cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace -q — all clean (718 + 279 + … passing, 0 failures).
  • cargo run -p xtask -- check-iteration-ready --plan kb/iterations/iteration-126-network-json-shape-consistency.md --base origin/main10/10 PASS (with FF_RDP_LIVE_TESTS=1).
  • 6 new unit tests incl. a navigate/network parity assertion (network_and_navigate_summary_fields_agree_field_for_field), truncation-math, and empty-page key-presence.
  • 3 new mock e2e tests (navigate_with_network_detail_mode_is_object_not_array, ..._all_keeps_object_shape, summary fields in network_detail_shows_requests).
  • 3 new live tests in live_126_network_shape.rs covering the quiet/busy shape parity, --all, and standalone network --jq summary carry.
  • Dogfooded against live Firefox: example.com (quiet) → {"t":"array","n":1,"truncated":false}; wikipedia (busy, 118 req) → {"t":"array","n":118,"shown":20,"truncated":true}identical key sets, no shape flip; standalone network --jq returns total_requests: 118, total_transfer_bytes: 2025146.0.

🤖 Generated with Claude Code## Claims vs code
<generated 2026-07-19T15:54:57Z by ralph-loop>

No claims extracted from commit messages.

ractive and others added 2 commits July 19, 2026 17:51
…twork

`navigate --with-network` (and the standalone `network` command) returned an
inconsistent JSON shape: a `{entries, …}` object on busy pages but a bare array
on quiet ones, so `.results.network.entries` / `.total_requests` threw
`cannot index array` half the time, and the documented summary fields were
unreachable via `--jq` (which forces detail mode).

Introduce a shared `pub(crate) build_canonical_network` builder plus
`merge_summary_fields` in network.rs. `apply_network_controls` now returns ONE
canonical object on every path (busy/quiet, detail/summary, --all/default):
`{entries, shown, total, truncated, total_requests, total_transfer_bytes,
by_cause_type, slowest, timeout_reached, …}`. Summary counts always reflect the
full capture, never the truncated/field-projected view. The standalone
`network` detail envelope now carries the same summary fields alongside
`results` so `--jq` users can reach them.

Docs: args.rs help text documents the canonical shape with a bare-array
backward-compat note. Tests: 6 unit tests incl. a navigate/network parity
assertion, 3 new mock e2e tests, and 3 live tests in live_126_network_shape.rs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t note

iter-126 inserted 6 lines earlier in args.rs (navigate/network help text),
shifting the a11y-contrast `total` help-text line reference from 654 to 660.
Also note the iter-126 parity-test / dogfood-compact-jq precedent as a design
note so iter-127's fix pins exact field values, not just presence.
@ractive
ractive merged commit 29c0836 into main Jul 19, 2026
10 checks passed
@ractive
ractive deleted the iter-126/network-json-shape-consistency branch July 19, 2026 16:05
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