Skip to content

perf(staging): bound residual chunk decoding - #606

Closed
forhappy wants to merge 1 commit into
codex/indexed-staging-final-integrationfrom
codex/bounded-residual-staging
Closed

forhappy wants to merge 1 commit into
codex/indexed-staging-final-integrationfrom
codex/bounded-residual-staging

Conversation

@forhappy

Copy link
Copy Markdown
Contributor

Residual reads could decode an entire prepared xorb even when the caller requested a small chunk batch. Add a bounded decoded-batch cursor that verifies and opens each serialized source once, pins its descriptor before worker admission, and retains cancellation results for the next call. Native residual packing uses this API. Selected recipe leases or the push snapshot remain the lifetime owner.

Stacked on #598. The complete-source read_next API is present in published v1.2.4 (b4d5fd361f9a); retain that public contract and reject mixing it with a partially drained bounded read. The new module owns the cursor and pending worker; common source verification stays shared. One serialized source remains bounded by the xorb format; decoded results obey count/byte targets, allowing one oversized chunk to make progress.

Validation on the combined candidate: four focused staging tests pass, covering exact source-open counts, detached bounded batches, corruption before return, and cancelled-call resumption. Strict staging all-target Clippy and formatting pass. Nineteen CLI publication/packing tests pass on the dependent publication change. CLI build is recorded separately. These are focused component checks; fresh combined 10 GiB and lifecycle qualification remain required.

Evidence map: native pack_xorbs enters CoalescedChunkReadPlan::read_next_bounded; SQLite selects source groups, source handles are pinned, and shared xorb verification/decode provides payloads. Prepared and segment sources keep the same owner boundary. The capsule caller switches in the dependent publication PR. Current main uses complete-source decoded reads; published v1.2.4 confirms why its API remains. No staging schema or wire format changes.

Is this the best fix? The existing residual planner owns batching and cancellation, so one cursor prevents repeat opens and oversized decoded allocations without adding another payload store. The implementation grows to hold bounded cursor/worker state and exercise real cancellation/lifetime behavior; the old public method remains for the cited release contract.

Draft only. The advisor plan and both excluded large-file audit reports are absent. No inventory, baseline, ignore, or product assertion is relaxed.

@forhappy forhappy closed this Oct 15, 2026
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