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.3 KiB

Sequence record contract

Types

R01. sequence.hpp defines namespace sequence. ByteString is std::vectorstd::uint8_t. Status is an enum class with the values OK, BAD, MISSING, EXISTS and RANGE. Each status field has type Status. RecordResult has fields status, id, value and payload. ReadResult has fields status, bytes, position and eof. PositionResult has fields status and position. The id, value and position fields have type std::int64_t; eof has type bool. ByteString is used for payload and bytes.

R02. Engine is default constructible and owns independent state. Its record table and handle table are initially empty. Two live Engine objects may contain the same record and handle IDs with different values, payloads, snapshots and byte positions. Operations on one object do not change the other.

R03. Record IDs are integers from 0 through 31, values from 0 through 1000000 and handle IDs from 0 through 7. A payload contains from 0 through 96 bytes. All numeric API parameters have type std::int64_t. The API methods below are public; their helpers and the contents of sequence_internal.hpp are implementation details.

R04. A method returning an error leaves every record and open handle unchanged. An error RecordResult contains id=0, value=0 and an empty payload. An error ReadResult contains empty bytes, position=0 and eof=false. An error PositionResult contains position=0. Status-only methods return the status itself.

Records and handles

R05. Status Engine::put(id, value, const ByteString& payload) returns BAD if the ID, value or payload length is outside its domain. Otherwise it inserts or replaces that ID's value and payload and returns OK. The stored payload is a copy of the argument.

R06. Status Engine::erase(id) returns BAD for an ID outside its domain, MISSING for an absent ID, and otherwise removes the record and returns OK.

R07. RecordResult Engine::get(id) returns BAD for an ID outside its domain and MISSING for an absent ID. Otherwise it returns OK with that ID and copies of its value and payload. Changing the returned payload does not change the record table.

R08. Status Engine::open(handle) returns BAD for a handle outside its domain and EXISTS for an already open handle. Otherwise it captures the current records in increasing ID order, creates an independent stream over that snapshot at byte position zero, and returns OK. Changes to records after open are seen by a later open and do not change a snapshot already captured.

R09. Each snapshot record renders as its decimal ID, a vertical bar, its decimal value, a vertical bar, its decimal payload length, a vertical bar, two lowercase hexadecimal characters per payload byte, and one LF byte. Decimal zero is 0; other decimal fields have no leading zeros. The stream is the concatenation of these records without other bytes. An empty snapshot has an empty stream.

R10. Status Engine::close(handle) returns BAD for a handle outside its domain and MISSING for a handle that is not open. Otherwise it removes that handle and its snapshot and returns OK. The handle may subsequently be opened again using the then current records.

Reading and positioning

R11. ReadResult Engine::read(handle, count) returns BAD if the handle is outside its domain or count is outside 0 through 4096. Otherwise it returns MISSING if the handle is not open. On success it returns the next min(count, remaining stream bytes) bytes, advances the position by their length and returns OK with the resulting position. A read that finishes within a record leaves the remaining bytes of that record for the following read. count=0 leaves the position unchanged. eof reports whether the resulting position equals the stream length, including on an empty stream and a zero-count read. Reads at the end return empty bytes and do not move the position.

R12. PositionResult Engine::seek(handle, offset, whence) returns BAD if the handle is outside its domain or whence is not 0, 1 or 2. Otherwise it returns MISSING if the handle is not open. whence 0 uses base zero, whence 1 uses the current byte position and whence 2 uses the snapshot stream's byte length. The target is base+offset evaluated without signed overflow. A target less than zero or greater than the stream length returns RANGE. Otherwise the method sets the byte position to that target and returns OK with the target. Subsequent reading starts at that byte position, including when it lies inside a rendered field or its LF byte.

R13. PositionResult Engine::tell(handle) returns BAD for a handle outside its domain and MISSING for a handle that is not open. Otherwise it returns OK with the current byte position without changing it.

Command entry

R14. int run_cli(std::istream& input, std::ostream& output, std::ostream& diagnostics) creates two fresh Engine objects identified by slots 0 and 1, processes input and returns 0. Every invocation begins with fresh state, including several invocations in one process. main calls this entry with standard input, standard output and standard error. The entry and the executable write no diagnostics.

R15. Input is a sequence of lines terminated by LF; a final line without LF is also processed. Empty input produces no output. A line is at most 1024 bytes before LF. Leading and trailing ASCII spaces and tabs are allowed, and adjacent tokens are separated by one or more of those bytes. Other whitespace, NUL and bytes outside ASCII are not separators or token characters and make the line invalid. An empty or whitespace-only line is invalid.

R16. A numeric token contains decimal digits, optionally preceded by one minus sign. Leading zeros and -0 are accepted. It must fit std::int64_t. A payload token is either - for an empty payload or an even nonzero number of hexadecimal characters, using either case. Output hexadecimal always uses lowercase.

R17. The command forms are PUT slot id value payload, ERASE slot id, GET slot id, OPEN slot handle, CLOSE slot handle, READ slot handle count, SEEK slot handle offset whence and TELL slot handle. The verb is case sensitive. An unknown verb, wrong number of tokens, invalid numeric or payload token, or overlong line produces ERR SYNTAX followed by LF, including when another token is outside a numeric domain. For a syntactically valid line, a slot outside 0..1 produces ERR BAD followed by LF. A syntactically valid line with a valid slot returns the corresponding Engine method's result using the remaining arguments.

R18. A successful PUT, ERASE, OPEN or CLOSE produces OK followed by LF. A successful GET produces OK REC id value payload followed by LF. A successful READ produces OK DATA position eof bytes followed by LF. A successful SEEK or TELL produces OK POS position followed by LF. Fields are separated by one ASCII space. Decimal fields use the representation in R09, eof is 0 or 1, and an empty payload or byte string is represented by -. An API error produces ERR status followed by LF, where status is the API status name. There are no other stdout bytes.

R19. The entry processes at most 512 physical lines; empty, malformed and successful lines each count as one line, including a final unterminated line. If more input remains, it emits ERR LIMIT followed by LF once, consumes the remaining input without applying commands and returns 0. It continues processing within the limit after a malformed line or API error. Every rejected line leaves both Engine objects unchanged.