amos 73a5240295 Batches 21 and 18: add 74 calibrated tasks (40 Bos redo, 34 HWE code-gen)
Batch 21 (20261027-A-bos-redo-21) rebuilt 40 of the 53 rejected Bos-qiao
environments: hidden assertions that ran inside the candidate's process
now run in a trusted parent that reads observations from a low-UID
worker; gold bytes are unchanged. 9 were excluded for scope (ROS2,
oversize, security core), 3 are blocked because the source requires an
exec bit the platform does not freeze, 1 lacks requests/bs4 in trace6.

Batch 18 (20261026-C-hwe-codegen-18) adds its last 34 of 134 tasks; the
first 100 landed in 2f32624d.

Claude reviewed 74/74 USABLE against current digests, canonical
families, no ID or source overlap with main, plain public docs. Only the
new task directories are taken; the stale pre-batch-20 copies of
concur-release-capsule and resource-temp-link on the batch 21 branch and
both branches' progress notes stay as main has them. Difficulty is
unmeasured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 10:23:12 +08:00

7.2 KiB

Buffered memory stream contract

The supported C++17 API is bio::Session, its seven methods below, the bio::View and bio::Stats value records, and bio::run_cli(Session&, std::istream&, std::ostream&). Other declarations in io.hpp are implementation support. bio::Number is signed 64 bit. A Session owns its state, starts empty, need not be copyable, movable or assignable, and has no external side effects. Multiple sessions can be live with independent state, including the same stream IDs.

Code numeric values and command spellings are: 0 OK, 1 BAD_ID, 2 BAD_CAPACITY, 3 BAD_BYTE, 4 BAD_COUNT, 5 BAD_STAGE, 6 BAD_ENABLED, 7 EXISTS, 8 MISSING, 9 WRITE_ERROR, 10 FLUSH_ERROR, 11 CLOSE_ERROR. Methods return Code, except view, stats and run_cli.

open(Number id, Number capacity) accepts IDs 0..3 and capacities 1..8. It validates ID, capacity, then whether the ID is live. It returns BAD_ID, BAD_CAPACITY or EXISTS for those failures. Success creates a live stream with empty pending, durable and history bytes, clear fault policies, last=OK and zero per-stream attempts. A previously closed ID can be reopened, replacing its retained record. Each success increments opened and live totals.

put(Number id, Number byte, Number count) accepts bytes 0..255 and counts 0..16. It validates ID, byte, count, then whether the stream is live, returning BAD_ID, BAD_BYTE, BAD_COUNT or MISSING. Success appends count copies of the byte in order. Before appending a byte when the pending buffer has reached capacity, it drains the pending bytes to the memory backend. An append that reaches capacity leaves that full buffer pending. Count zero appends nothing and makes no backend calls. The operation sets last to its result. If draining fails, the operation returns WRITE_ERROR immediately; the prefix already appended or committed stays, the uncommitted pending tail stays, and the remainder of this put is not appended.

The backend write accepts at most two bytes per call and appends that accepted prefix to durable bytes. A successful write with nonempty input always makes progress; draining continues until pending is empty. An enabled write fault makes the call return WRITE_ERROR with zero bytes accepted. Each backend write attempt increments both per-stream writes and total writes, including a failed attempt. Pending bytes are removed only after acceptance. No real I/O is used.

arm(Number id, Number stage, Number enabled) accepts stages 1..3 (write, flush, close) and enabled 0..1. It validates ID, stage, enabled, then live state, returning BAD_ID, BAD_STAGE, BAD_ENABLED or MISSING. Success replaces the selected fault policy with enabled, returns OK and leaves other state, counters and last unchanged. Fault policies persist until replaced or the ID is reopened.

flush(Number id) validates ID then live state, returning BAD_ID or MISSING. It drains pending, then calls backend flush only if draining succeeded. Backend flush returns FLUSH_ERROR when its policy is enabled, otherwise OK. It increments the per-stream and total flush attempts even when it fails and when there were no pending bytes. The operation sets last to the returned result; durable bytes already committed remain after failure.

close(Number id) validates ID then live state, returning BAD_ID or MISSING. It performs the flush operation and then calls backend close, including when flush failed. Backend close increments the per-stream and total close attempts and returns CLOSE_ERROR when its policy is enabled, otherwise OK. The stream becomes closed, pending bytes are discarded, live total decreases and closed total increases. The result and last are the flush result if it failed, otherwise the backend close result. The retained record remains readable. A later close of this ID returns MISSING and makes no backend calls. Each successful open has at most one backend close attempt.

A validation or live-state rejection leaves all streams, bytes, fault policies, last results and counters unchanged. Accepted put, flush and close operations that encounter backend failures have the transitions specified above. Open, arm and successful queries do not reset an existing last error, except that open creates a new record.

view(Number id) const directly returns all fields of View. An invalid ID returns code=BAD_ID, id equal to the supplied ID and all other fields at their defaults. A valid ID never opened returns code=MISSING, id equal to the supplied ID and other fields at defaults. Defaults are seen=false, live=false, capacity=0, empty pending/durable/history, last=OK, all faults=false and writes=flushes=closes=0. An opened ID returns code=OK, its ID, seen=true, live status, capacity, pending bytes, durable bytes, last Code, three fault flags in write/flush/close order and per-stream attempt counters and backend call history bytes. Each backend attempt appends W, F or C for write, flush or close, in call order, including failed attempts. Queries do not alter state.

stats() const returns opened, live, closed, writes, flushes and closes lifetime totals as signed 64 bit counts, initially zero. Closed records can be replaced on reopen without reducing any lifetime counter. live equals opened minus closed.

run_cli uses the supplied Session by reference, preserves its state across invocations, starts its physical line counter afresh on every invocation, and returns the number of processed physical input lines, at most 64. It accepts an unterminated final line. Each of the first 64 lines is processed, including empty, syntax-error and API-error lines. If another line exists it emits one LIMIT line and returns without processing that line or later lines. The standalone program creates a fresh Session and invokes run_cli once, exits zero, and emits no stderr; the API and command runner emit no stderr either. Empty stdin emits no output.

Commands are case-sensitive OPEN id capacity, PUT id byte count, ARM id stage enabled, FLUSH id, CLOSE id, VIEW id and STATS. Tokens are separated only by ASCII space or tab, which may surround the command. Each verb requires exactly the shown number of arguments. Numeric tokens consist of an optional minus sign followed by one or more ASCII decimal digits, must fit Number, and may contain leading zeroes. A plus sign, sign without digits, overflow, embedded NUL, carriage return and other trailing characters are invalid. An unknown verb, wrong arity, empty line or invalid numeric token emits SYNTAX and leaves the session unchanged. Parsing completes before any API call. A syntactically valid command delegates to the named method, including values outside the method's domain.

Mutating commands emit the Code spelling followed by LF. VIEW emits its error Code spelling on an unsuccessful query; otherwise it emits VIEW id seen live capacity pending durable history last write_fault flush_fault close_fault writes flushes closes. STATS emits STATS opened live closed writes flushes closes. Fields are separated by one ASCII space. Boolean fields use 0 or 1, numbers use canonical decimal without leading zeroes, bytes use lowercase hexadecimal with two digits per byte, and an empty byte sequence uses -. Every emitted line ends with LF. Output bytes follow this format even if the caller supplied output flags, width, fill or locale; restoring those settings is not required. No other stdout bytes are permitted.