Repository navigation
Description
Parent
#1269 — bound detail subprocess streams and the complete packet budget.
Roadmap parent: #1268.
Dependencies and order
Land after Horizon A authority integration #962 so the process/receipt semantics it observes are stable. This is the first #1269 implementation slice.
Objective
Add one reusable byte-oriented stream capture contract that can drain arbitrarily large stdout/stderr while retaining bounded diagnostic evidence and exact truncation metadata.
This PR defines and proves the primitive. It does not yet migrate production sensor, proof or worker runners.
Contract
byte stream
→ bounded head/tail or equivalent deterministic retention
→ rolling byte count and digest
→ terminal capture result
A terminal result should carry at least:
- configured byte limit and retention policy/version;
- total bytes observed;
- retained bytes and excerpt location/shape;
truncatedplus stable reason;- full-stream digest computed while draining, when enabled;
- decode status without requiring valid UTF-8;
- read/write/internal failure state;
- source/task/revision fields supplied by the caller rather than inferred.
The capture layer does not decide whether missing bytes affect Required evidence. Its callers own that semantic classification.
Scope
- Introduce one internal module/type shared by later sensor/proof/worker adapters.
- Read and write in fixed-size chunks; never buffer the complete stream before applying the limit.
- Keep stdout/stderr independently configurable and independently receipted.
- Preserve raw bytes at the capture boundary. A human-readable excerpt may replace invalid sequences explicitly, but byte counts/digests operate on original bytes.
- Define deterministic head/tail allocation, elision marker, file naming, atomic final publication and temporary-file cleanup.
- Bound both process memory and retained disk use to a declared function of the configured limits.
- Support an injected reader/writer or equivalent deterministic test seam without shelling out in unit tests.
- Keep stable serialization/versioning and
BTreeMap/stable ordering where maps are used. - Register the module through the narrowest internal seam without changing any production runner.
Acceptance
- A stream many times larger than the configured limit is fully drained while retained bytes remain within the exact bound.
- Peak process memory and temporary/final disk growth remain bounded independently of source-stream size.
- Head/tail retention is deterministic across chunk boundaries and repeated runs.
- Empty, exact-limit, one-byte-over, no-newline, one-very-long-line and alternating small/large chunk cases are correct.
- Invalid UTF-8 cannot corrupt byte counts, digest or terminal state.
- Stdout and stderr limits/results remain independent.
- Read failure, destination write failure, atomic-rename failure and interrupted cleanup are explicit and do not publish a false complete receipt.
- Digest/count/truncation metadata is independently recomputable from the generated fixture stream.
- Caller-supplied source/task/revision identity is preserved and malformed mandatory identity is rejected at the typed boundary.
- No process runner, sensor, proof, worker, gate, review or packet behavior changes.
Proof
- Deterministic generated readers for empty, exact, oversized, no-newline, invalid UTF-8 and adversarial chunking.
- Temporary-file and atomic-publication failure injection.
- Bounded-memory/bounded-disk assertion using a source substantially larger than the limit.
- Serialization/version/unknown-field/digest-forgery negatives.
- Repeated-run byte identity and stable ordering.
- Full focused tests, workspace check/tests, strict Clippy, fmt, policy and diff hygiene.
Non-goals
- No child process spawning or kill-tree behavior.
- No production sensor/detail/proof/worker migration.
- No structured analyzer artifact parsing.
- No whole-packet budget.
- No outcome, TaskLedger or gate classification.
- No compression/archive policy.
Completion
Close when later adapters can consume one proven bounded-capture primitive without inventing source-specific stream semantics.
Rollback
Remove the unused module and retain the generated stream fixtures. Do not land a caller-specific bounded implementation instead.
Activity