# Owned buffer view contract The program is a software model of an owned allocation and an aligned child view. Its observer reports pointer residue and view metadata; it never dereferences a view whose range is invalid, nor passes an interior pointer to `free`. `OPEN id capacity` accepts ids 0..7 and capacities 1..4096. A live id is replaced only after its old original allocation has been released. A successful OPEN prints `O id capacity generation`; generation starts at 1 and increments on each OPEN. An invalid command prints `E` and leaves all owners unchanged. `PLAN id alignment requested` accepts alignment 1..256 and requested 0..4096. The owner must be live. The view offset is the **smallest nonnegative** integer such that `(uintptr_t)original + offset` is divisible by alignment. In particular, an already aligned original has offset zero. Alignment need not be a power of two. Compute without overflowing the original capacity. PLAN succeeds exactly when offset is at most capacity and requested is at most capacity minus offset. On success, the view's effective span is **all remaining bytes** from offset to the end of that original allocation, including bytes after the requested subrange. A zero length request follows the same rule. The successful view carries the original owner's identity, original pointer, original capacity, and current generation. It must not substitute its interior address for the owner pointer. Failed PLAN leaves no usable view and reports `-1`. `DROP id` releases the original allocation at most once and reports `D id 1` when a live owner was released, or `D id 0` otherwise. A view becomes stale after DROP or replacement OPEN; `CHECK id` reports it unusable. Only the original pointer is passed to the actual allocator release operation. `FILL id seed` accepts seed 0..255 and writes byte `(seed + 17 * index) % 256` at each index of a live original allocation. It prints `F id 1`, or `F id 0` when the id is not live. `PROBE id count` accepts count 0..4096 and prints `T id status checksum`. It succeeds only when a current usable view exists and count is at most its effective span. Its checksum starts at zero and, for each byte in the view prefix, applies `(checksum * 33 + byte) % 65521`; on failure it prints `T id -1 0`. No invalid view is dereferenced. `COPY source_id destination_id count` accepts ids 0..7 and count 0..4096. It copies exactly count bytes from a current usable view to the beginning of a live destination original allocation, using overlap safe copying. The count must fit both source effective span and destination original capacity. It prints `X source_id destination_id 1` on success or the same fields with `0` on failure. A failed copy changes neither allocation. `RESET` releases every live original allocation, prints `Z released_count`, and leaves every prior view stale. It preserves generation counters so the next OPEN can be distinguished from the old owner lifetime. The observer prints one response per input line. PLAN response is: `P id residue status offset span owner_ok aligned in_bounds usable` `residue` is the original pointer modulo the requested alignment. On failure, status is -1 and the six metadata fields after it are zero. On success status is 0, offset/span are decimal integers, and each final flag is 0 or 1. `owner_ok` checks original owner/pointer/capacity/generation; `aligned` and `in_bounds` inspect the returned view without dereferencing it; `usable` checks all invariants. `CHECK id` prints `C id usable`, with 0 when no current live view exists. Input fields use ASCII decimal digits with optional leading plus, separated by space or TAB; each command occupies one LF terminated line. Output fields use ASCII decimal tokens separated by space or TAB and terminated by LF. Diagnostics may be written to stderr. The program reads until EOF. At exit it releases all remaining **original** allocations. A maximum of 512 commands is supported. After the last command, the observer prints `I bytes digest`, where `bytes` is the number of stdin bytes actually read and `digest` is FNV-1a over those bytes with 32-bit offset basis 2166136261 and multiplier 16777619. This line is part of the public output protocol.