Stable Queue/Vec collection windows

Candidate based on 56e23fba, isolated on stable-round3/queue, frozen at 4e3cf6ec9664dd8f11b8dede7f41bbaa0e1d3e74. The qualified combined control costs 1,132,909,046,630 instructions / 179 Heavy16 rounds; retained costs 105,261,812,195 / 49. This candidate passes native tests and the canonical complete Heavy16 audit at 1,127,003,694,396 instructions / 179 rounds: 0.5213% fewer instructions, with the tradeoffs recorded below.

Collection-owned access

Queue::for_each_prefix(max_items, visitor) visits the logical prefix with Storage::read_with. A window is limited by the requested live prefix, ring wrap, 64 items and 4,080 encoded bytes. One wider fixed item is indivisible. Decoding stops at the first rejected item, without decoding the remainder of the already-read window. The provider's shared loan spans the traversal; callbacks can read stable children but cannot write, resize or retire storage. No workspace or validated allocation capability survives the provider loan.

Reactor outgoing batches use this traversal with their remaining item limit. The original byte-bound rule, first-item handling, lane order, snapshots and exact retry bytes are preserved. A byte-bound rejection can leave unread rows in the current bounded window; no later window is fetched.

Queue::retire_front_while reads one bounded window, collects accepted decoded rows in reusable transient scratch, ends the shared loan, removes those actual owning edges from the logical queue, then retires them in prefix order under an exclusive provider loan. The next window binds and validates afresh after child retirement. Reactor acknowledgements bound this operation by the original sent segment length, with the existing priority/cursor/last-sequence checks intact. An acknowledgement no longer reads every removed frame through both front and pop_front. Appended frames have greater sequences and remain untouched.

Clear and container retirement use the same bounded decode/retire principle. Scalar get/pop and ordinary iteration use scoped fixed-value reads, eliminating their per-element output Vec. Ordinary iter().next() remains a fresh scalar read: buffering across calls could change observations through trusted mutable snapshot aliases. There is no per-item header-validation cache or iterator capability whose lifetime exceeds a provider loan.

Vec::reserve_exact permits logical capacity one without Queue's default minimum-eight growth policy. Indexed insert and remove move encoded bytes with at most 4,080 bytes of collection-local scratch, backward for right shifts and forward for left shifts. These byte moves create no owning edges. Growth also copies only the two initialized ring spans with bounded scratch; it frees the superseded container without retiring transferred children. into_transient decodes directly into its necessary output, transfers every existing child edge and frees only the encoded container. Carrier layout remains 40 encoded bytes; the source-qualified Collections policy deliberately changes with this code. No old-policy upgrade or compatibility adapter is introduced.

Focused evidence

The new native trace fixture compares a head-zero queue containing 128 twenty-byte rows through ordinary iteration and the scoped prefix operation:

Native provider trace Scalar iteration Scoped prefix
Logical / raw read calls 128 / 128 2 / 2
Requested logical bytes 2,560 2,560
Actual raw read bytes 167,168 3,872

These are measured VecMemory/Arena traces and checked assertions, not IC instruction attribution or a Heavy16 forecast. The two windows still cause Arena prefix copies within its fused path. The pinned IC's stable API charges 20+n per nonempty call; stable source mapping and heap scratch fees remain separate. First-read bypass means fewer API reads do not universally mean fewer instructions. The IC review found no new lifetime, bounds, ownership or acknowledgement-ordering blocker; whole-workload selection remains required.

All six new tests pass. They cover wrap and initialized-span bounds, byte/item limits, rejection/zero prefixes, wide and zero-size items, nested read-only callbacks, blocked callback mutations, stale generation rejection after reuse, partial retirement/refill/order, exact once nested ownership, bounded overlapping Vec shifts, randomized native Vec parity, exact one-slot reserve, reopen and owning into_transient transfer. The existing Queue randomized wrap/growth test and shared ownership/conversion/forgotten-owner suites also pass.

The full Collections package passes 44 native tests and 13 doctests. The Reactor package passes 34 native tests and two compile-fail doctests, including partial/lost acknowledgements, exact retries, live prepared frames through queue growth, large batches, admission and callback reentrancy. An initial Reactor compile found the new usize removal count being subtracted from its u64 metric; the explicit widening cast fixed it before this freeze.

Complete Heavy16

Canonical uninstrumented Wasm 17c37256cc1e2f58f68a4f0ca016cb2f416f2cc835e658f66703725ad3c439a5 is built from the frozen source above. Public Wire equality, all 586 build source inputs, seven unchanged graph byte sequences and the final source guard pass. The full audit checks 55,172 trace rows. All 19,200 workflows, 594,000 visits, 202,800 attempts, 180,000 endpoint deliveries, 360,000 accepted frames and 27,600 blocks complete; 1,024 canonical block samples verify. There are zero traps, rejected admissions and reoffered frames. Original turn budgets, topology, arrival rounds, concurrency, batching, retry bytes and maintenance remain fixed. An independent IC reviewer reproduces every function total from all 55,172 raw rows, verifies raw/gzip hashes and rehashes all 604 manifest pins (586 sources and 18 outputs). The exact-work vector equals the qualified control.

Complete observation Qualified stable control Queue/Vec candidate
Instructions 1,132,909,046,630 1,127,003,694,396
Rounds 179 179
Physical peer calls 5,616 5,630
Heap page instructions, already included 48,927,760,000 49,504,000,000
Admission-to-completion p50 / p95 / max 78.6 / 99.6 / 103.2s 82.8 / 99.6 / 103.8s
Grown fleet Wasm capacity 269,484,032 B 269,484,032 B
Grown fleet stable capacity 324,927,488 B 325,386,240 B

The net saving is 5,905,352,234 instructions. Heap page fees rise 576,240,000 instructions and grown stable capacity rises seven 64-KiB pages fleet-wide; these are tradeoffs, not omitted charges. Median latency rises while p95 and complete rounds are unchanged. Capacity is not live payload or resident memory. The candidate still costs 10.71 times current retained instructions.

Controller-turn instructions are essentially unchanged: 896,511,724,668 versus 896,505,471,832. The large business callback cohort falls from 60,034,090,942 to 57,015,628,117 and the timer executor from 13,059,272,868 to 10,558,024,877. These are complete trace observations with changed callback/turn counts; they do not isolate an individual Queue operation or establish a stable-read/page cost decomposition. The much larger native trace byte reduction is not the global workload instruction reduction. Removing the separately reported heap page-fee field leaves a 6,481,592,234-instruction reduction in the remainder; that remainder still includes stable API/mapping costs and ordinary Wasm work.

This is a small complete-workload instruction win and a useful bounded collection API for the separate sorted NodeTable candidate. Integration and final combined ownership/rollback/KEEP qualification remain the root lane's work. The canonical build takes 129.1 seconds; the workload's observed 197.9 host seconds overlaps other jobs and is not a comparative performance metric.

Reproduction and outputs

All outputs are outside the worktree at rrt/tmp/stable-round3/queue/. Both complete workspace metadata resolutions pass locked/offline. The exclusive build target is rrt/tmp/perf-round12/const-sha; these variables are exported before sourcing ver1/tools/env.sh, which enables checksum/content freshness:

export CARGO_TARGET_DIR=/srv/shared/code/icrustmem/rrt/tmp/perf-round12/const-sha
export TMPDIR=/srv/shared/code/icrustmem/rrt/tmp/stable-round3/queue/tmp
source ver1/tools/env.sh
cargo metadata --manifest-path ver1/Cargo.toml --locked --offline --format-version=1
cargo metadata --manifest-path rrts/Cargo.toml --locked --offline --format-version=1
cargo test --manifest-path ver1/Cargo.toml --locked --offline -p cdk-rsx-collections --test stable_sequence
cargo test --manifest-path ver1/Cargo.toml --locked --offline -p cdk-rsx-collections
cargo test --manifest-path rrts/Cargo.toml --locked --offline -p cdk-rsx-rrts-reactor

Raw logs: sequence-native.log, collections-native.log, reactor-native.log (preserved compile failure), reactor-native-final.log. The canonical artifact is in build/; full guarded run/audit output is in heavy16/. receipt.json pins source, Wasm, control, commands, raw logs and their hashes without duplicating the full trace packet. The exact launch uses:

python3 rrts/tools/build.py --app fourcans \
  --output /srv/shared/code/icrustmem/rrt/tmp/stable-round3/queue/build \
  --target-dir "$CARGO_TARGET_DIR" \
  --pocket-ic /srv/shared/code/icrustmem/rrt/tmp/perf-round9/servers/1fc9e6f58f7b329a0deb0c1944306a74625293fa56decf9df653ba8ec41fa45c/pocket-ic \
  --reference-interface /srv/shared/code/icrustmem/rrt/tmp/store-round2/final/rrts-build/reactor_cell.wire.json
RRT_PIC_SERVER_URL=http://127.0.0.1:42653 python3 rrt/tools/run-heavy.py \
  --artifact /srv/shared/code/icrustmem/rrt/tmp/stable-round3/queue/build \
  --output /srv/shared/code/icrustmem/rrt/tmp/stable-round3/queue/heavy16 \
  --source-root /srv/shared/code/icrustmem/rrt/tmp/stable-round3/worktrees/queue

No allocator cache, authoritative heap replacement, journal, dropped work or relaxed workload limit is part of this candidate. The root integration owns the canonical whitepaper reconciliation and combined lifecycle qualification.