100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth range given to batch 22), each with at least one independent contract-edge defect and plain public docs. Claude reviewed 100/100 USABLE against current digests; no ID or source overlap with main or batch 22. Difficulty is unmeasured. progress.md records the wrap-up: all Codex sessions and Qwen schedulers stopped for the user's rollout, Qwen results so far (57 HARD of 373), and what is left on each batch branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7.2 KiB
Mode captured stream contract, version 1
C01. This is an ordinary single threaded C++17 byte-container model. Devices are independent; no kernel, file descriptor, wall clock, locale or hardware behavior is modeled. All counters are unsigned 64-bit sums modulo 2^64. Byte values cover 0..255 including NUL, CR and LF. Every API is deterministic and writes no stdout or stderr.
C02. The complete public API is declared in stream.hpp: Device, reset, set_mode, get_mode, capacity, begin, append, finish, cancel, read, peek, stats, inspect, active_ids, packet, parse_mode, mode_name and transform. All input byte containers remain unchanged. These APIs may be called directly as well as through the packet bridge. No implementation layout or particular container is required.
C03. A freshly constructed Device has capacity 16, mode 0, an empty FIFO, no transactions and all four counters zero. reset(cap) accepts 1..4096, replaces capacity, clears FIFO/transactions/counters and restores mode 0; otherwise it returns -22 and changes nothing. capacity() returns the configured capacity, not free space.
C04. Modes are 0=pass, 1=upper, 2=lower. set_mode(m) returns 0 for these values and -22 otherwise, without affecting other state. get_mode() returns the current control mode. parse_mode(bytes) accepts exactly lowercase ASCII pass, upper or lower, returning 0/1/2, otherwise -22; whitespace, case variants and trailing NUL/LF are invalid. mode_name(m) returns those names, otherwise invalid.
C05. transform(data,m) returns an equally long byte vector: upper changes only ASCII a..z to A..Z, lower only A..Z to a..z, pass and any invalid m leave bytes unchanged. No locale or text decoding occurs.
C06. begin(id,total) starts an active write transaction with 0 accepted bytes, declared total 0..65535, and the current mode captured permanently. IDs range 1..4294967295. Validation order is invalid ID -> -22; total >65535 -> -7; existing ID -> -17; already four active IDs -> -28. Success returns 0. A zero-total transaction is active until explicitly finished or canceled.
C07. A transaction's captured mode governs every byte accepted by every append in that transaction, even after any number of set_mode calls. Control changes affect only subsequently begun transactions. FIFO bytes never change after a control mode change. Reusing an ID after finish/cancel starts a new capture.
C08. append(id,data,budget) validation order is invalid ID -> -22; unknown ID -> -2; budget >4096 -> -22; data length >65535 -> -7; data length greater than the transaction's remaining declared total -> -90. Validate the entire request before accepting any prefix. Errors return Result(status,0,empty) and preserve all state.
C09. On a valid append accept n=min(data length,budget,capacity-buffered). Enqueue exactly the transformed prefix data[0:n] at the FIFO tail, advance that transaction by n, and increase the accepted counter by n, including when input was longer. Return Result(0,n,empty). Budget 0, empty input or a full FIFO are successful zero accepts. Unaccepted suffixes are not retained and must be resubmitted by the caller. Transactions may interleave; FIFO order is acceptance order.
C10. finish(id) checks ID validity (-22), existence (-2), then whether accepted equals declared total (-115 otherwise). Success removes that active transaction and increments completed by one; queued bytes remain. cancel(id) uses ID validity then existence, removes the transaction and increments canceled by one, regardless of progress; queued bytes remain. Repeated finish/cancel on a removed ID returns -2. No automatic finishing occurs.
C11. read(count) and peek(count) reject count >4096 with Result(-22,0,empty). Count 0 returns Result(0,0,empty) even with an empty FIFO. Positive count on an empty FIFO returns Result(-11,0,empty). Otherwise return Result(0,n,prefix), n=min(count,buffered). read removes exactly that prefix and increments consumed by n; peek changes nothing. Short reads succeed. Results include the actual bytes without normalization.
C12. stats() returns accepted, consumed, completed, canceled, buffered, active in that order; the last two are current sizes. inspect(id) checks valid ID then existence as above; on success returns status 0,id,total,accepted,remaining,captured_mode. An error Snapshot has status -22 or -2 and all five remaining fields zero. active_ids() returns current IDs in increasing numeric order. All three observation methods are nonmutating.
C13. Every error leaves the entire Device unchanged, including counters, mode, sessions and FIFO. Read-only operations, helper calls and failures cannot affect later success. All Result and Reply error outputs have empty data/payload and Result count 0. There are no diagnostic side effects.
Binary control packet bridge
C14. packet(request) returns Reply(status,payload). Integers are unsigned 64-bit little endian. Header is four bytes: ASCII M, ASCII S, version 1, opcode. The total request must be between 4 and 131072 bytes inclusive; a bad size, magic or version returns -71 before dispatch. With a valid header an unknown opcode returns -25, regardless of its payload length. Every known opcode requires the exact payload shape below; malformed lengths return -71 before any API validation or mutation. All byte strings may contain any byte value.
C15. Opcodes/payloads: 1 reset(cap:u64); 2 set_mode(mode:u64); 3 get_mode(empty); 4 begin(id:u64,total:u64); 5 append(id:u64,budget:u64,length:u64,data:length bytes); 6 finish(id:u64); 7 cancel(id:u64); 8 read(count:u64); 9 peek(count:u64); 10 stats(empty); 11 inspect(id:u64); 12 active_ids(empty); 13 capacity(empty). For append require length <=65535 and exactly 24+length payload bytes, otherwise -71. This framing check precedes append's semantic validation.
C16. A well framed packet calls the corresponding API once and has its status. Successful reset/set/begin/finish/cancel reply with an empty payload; get_mode/capacity reply with one u64; append with accepted count u64; read/peek with actual count u64 followed by actual bytes; stats with six u64 in C12 order; inspect with id,total,accepted,remaining,captured_mode as five u64; active_ids with count u64 followed by sorted IDs as u64. Every nonzero status replies with an empty payload. No implicit mode change/reset or extra operation is permitted.
Build and observation
C17. Submit only stream.hpp, stream.cpp, byte_codec.cpp, control_packet.cpp. Existing signatures and documented behavior are the contract; private state and algorithms may change. Added files are not collected. Build uses g++ -std=c++17 -O2 -Wall -Wextra -pedantic with these sources and the supplied raw observer. No external libraries, system calls, filesystem access or subprocesses are needed for the model.
C18. The observer's protocol is specified in console.md. For every well-formed stream, the process exits 0 and stdout consists exactly of the documented observations, each with one LF. Stderr must be empty. Empty stdin produces empty stdout and stderr. Do not emit banners, CRLF, debug lines or success tokens; binary stdout capture preserves bytes exactly. The grader also calls all public APIs via its own unchanged copy of this raw observer.