PEGO

A230: Stream Undo Cleanup

Resetting undo length can leave old capture references in its backing array. Clearing inactive backing releases those obsolete owners after stream commits.

Mechanism and Invariants

Once the undo journal is reset, prune-batched cleanup clears its full backing capacity. It runs when at least 1,024 input positions have been consumed since pruning. Until that boundary inactive references can remain, and scratch capacity itself stays retained. Live frame/capture values and published results remain untouched.

Scope and State

Default closure and both VM stream cleanup. Generated Go/TypeScript have no stream API.

Reference Control

Build tag pego_reference_stream_undo keeps the former backing references. Combined pego_reference_stream_storage changes prefix and stack policy too; it cannot attribute an undo-only effect.

Evidence and Implementation

Record 089 includes paired retained-storage and throughput measurements for independent/combined controls. Keep forced-GC retained bytes distinct from allocated bytes and do not assign the combined reduction entirely to this cleanup.

Evidence records: 089.

Source owners: undo backing cleanup, parser.commit and pruning.

The comparison policy distinguishes same-source controls, historical changes and full checkpoints.

Related mechanisms: A050, A240.

Optimization Catalog