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>
5.6 KiB
5.6 KiB
Inline record contract
This is a deterministic software allocation model. It does not allocate kernel memory or test physical addresses. Implement all clauses in this document. Only record.hpp, internal.hpp, layout.cpp, store.cpp and cli.cpp are collected for grading; additional files are not collected. Build with g++ -std=c++17 layout.cpp store.cpp cli.cpp -o records. The Store API in record.hpp is also built with a raw observer using -DINLINE_LIBRARY.
- A Store begins empty with allocations=0, frees=0, live=0, bytes=0 and next=1. Simultaneously live Store objects have independent records and counters, including when they use the same ID. Copying a Store is unsupported. Every Result begins with empty error and all six numeric fields zero. A failed call returns its error and leaves all numeric Result fields zero. A successful mutation returns that default Result. Reads and totals never change state.
- All API arguments are signed 64-bit integers. IDs are 0..7. Counts and positions used by replace, fill and copy are 0..64; get indices are 0..63; byte offsets are 0..271. Tags are 0..65535, fill values are -1000000..1000000 and budgets are 16..272. Bounds are inclusive. There is no arithmetic overflow behavior outside these domains: calls reject such arguments before doing arithmetic on them.
- replace(id,n,tag,budget) checks id, n, tag and budget in that order, returning BAD_ID, BAD_SIZE, BAD_TAG or BAD_BUDGET. It then returns NOMEM when budget is less than 16+4n. Otherwise it creates a record with n zero elements, the supplied tag and token=next, increments allocations and next, and releases an existing record at that ID once, incrementing frees. Each record contributes one to live and 16+4n to bytes. A record with n=0 has its header, token and tag, and participates in these counters. Budget applies to the new record alone and does not include an old record or other IDs.
- fill(id,start,count,value) checks id, start, count and value in that order, returning BAD_ID, BAD_START, BAD_COUNT or BAD_VALUE. It then returns ABSENT if the ID has no record, then RANGE if start exceeds the record count or count exceeds the remaining elements. Success writes value into count consecutive elements beginning at start. count=0 succeeds at any start through the record count and changes no fields.
- copy(dst,src,from,to,count) checks dst, src, from, to and count in that order, returning BAD_ID, BAD_SOURCE, BAD_FROM, BAD_TO or BAD_COUNT. It then checks destination presence (ABSENT), source presence (NO_SOURCE), source range and destination range (RANGE). Each range permits a position through that record's count and requires count to fit the remaining elements. Success copies the source elements as they were before the call into the destination. This also applies when source and destination overlap in the same record. Tokens, tags, capacities and allocation counters are unchanged by fill and copy.
- drop(id) checks ID (BAD_ID), then presence (ABSENT). Success removes the record and increases frees once. Repeating a drop is an ABSENT error. info(id) checks ID (BAD_ID) then presence (ABSENT), and returns token, count, tag, bytes and checksum in those Result fields; value remains zero. get(id,index) checks ID (BAD_ID), index domain (BAD_INDEX), presence (ABSENT), then index less than record count (RANGE). It returns the element in value and leaves other numeric fields zero. byte(id,offset) checks ID (BAD_ID), offset domain (BAD_OFFSET), presence (ABSENT), then offset less than record bytes (RANGE). It returns the unsigned byte in value and leaves other numeric fields zero. totals() returns allocations, frees, live, bytes and next. Every failure preserves all records, elements, exported bytes and counters.
- The exported record is a 16-byte header followed by n signed 32-bit elements. Bytes 0..3 are decimal 82,69,67,49; bytes 4..7 hold token; 8..9 hold tag; 10..11 hold count; 12..15 hold the checksum. All multibyte fields and elements use little endian. Negative elements use their unsigned value modulo 2^32. The checksum is the sum of those unsigned element values modulo 2^32. The software model's record identity represents one allocation containing header and elements. Implementations may choose a different internal representation while preserving every observation.
- The CLI reads lines from stdin, including a final line without LF. Tokens are separated by spaces or tabs; leading and trailing separators are accepted. Integers consist of an optional minus sign followed by one or more decimal digits and must fit signed 64-bit; leading zeroes and -0 are accepted. A plus sign, embedded or trailing non-digits, carriage return, missing argument, extra argument, unknown verb, empty line or line longer than 256 bytes produces ERR SYNTAX and does not call the Store. Each line counts toward the 4096-command limit; later lines produce ERR LIMIT without changing state. Empty stdin produces no output. A new CLI invocation starts a fresh Store.
- CLI verbs and argument order are REPLACE id n tag budget, FILL id start count value, COPY dst src from to count, DROP id, INFO id, GET id index, BYTE id offset, and TOTAL. Mutation success prints OK. API errors print ERR followed by the error. INFO success prints INFO token count tag bytes checksum. GET prints ITEM value. BYTE prints BYTE value. TOTAL prints TOTAL allocations frees live bytes next. Fields use one ASCII space, canonical decimal integers and one LF per output line, with no additional bytes. All CLI inputs, including syntax and limit errors, finish with exit status 0 and empty stderr. API methods emit no stdout or stderr. The observer reports the raw Result fields as well as Totals so it can distinguish each API's own result.