amos 2f32624d3b Batch 18 (20261026-C-hwe-codegen-18): add 100 calibrated HWE code-gen tasks; pause production for rollout
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>
2026-10-27 17:52:13 +08:00

6.7 KiB

Mask write interlock contract

R01. This C++17 library is a deterministic model of four shared 32 bit configuration registers. It has no threads, hardware, clock, or external resources. Each Interlock instance starts with four zero words, no owner, IDLE phase, zero queued operations and generation zero. Instances have separate state.

R02. The public declarations are in interlock.hpp in namespace maskwrite. Number is int64_t. Status values are OK=0, RANGE=1, BUSY=2, OWNER=3, PHASE=4, FULL=5, EMPTY=6. Phase values are IDLE=0, BUILD=1, CAPTURED=2; Kind values are SET=0, CLEAR=1, REPLACE=2. All methods complete synchronously and are silent on stdout and stderr.

R03. Actor arguments range from 0 through 7, register arguments from 0 through 3, kind arguments from 0 through 2, mask and value arguments from 0 through 4294967295, and operation index arguments from 0 through 7. These domains apply to every method accepting that argument, including values ignored by SET and CLEAR. Number arguments outside their domains return RANGE before testing transaction state.

R04. A failed method leaves the instance and any output reference unchanged. Read methods do not change instance state. Status checks occur in this order: argument domains, required ownership, required phase, queue capacity or emptiness. A method that does not require ownership uses its stated busy condition after checking arguments.

R05. reset() returns OK, sets all words and generation to zero, and removes any transaction. load(reg,value) writes the selected word and returns OK when there is no owner; it returns BUSY while a transaction exists. load does not advance generation.

R06. begin(actor) returns BUSY if any actor owns a transaction. Otherwise it creates an empty BUILD transaction owned by actor and returns OK. Ownership continues through BUILD and CAPTURED until commit, abort or reset. A repeated begin by the current owner also returns BUSY.

R07. stage(actor,reg,kind,mask,value) requires actor to be the owner, then requires BUILD. It appends one operation to the queue in call order and returns OK, or returns FULL if eight operations are already queued. It does not change register words. A zero mask still occupies one queue entry. A valid actor who is not the owner receives OWNER, including when there is no transaction.

R08. SET computes old | mask and CLEAR computes old & ~mask within 32 bits. Their value arguments do not affect the result. REPLACE computes (old & ~mask) | (value & mask). Operations on the same register compose in queue order; operations on different registers affect their respective words.

R09. capture(actor) requires ownership, then BUILD, then a nonempty queue. It returns EMPTY for an empty BUILD queue. On success it samples all four current words, applies the queued operations to those samples, retains the queue and owner, enters CAPTURED and returns OK. The committed words remain unchanged. Calling capture again returns PHASE.

R10. commit(actor) requires ownership and CAPTURED. It publishes all queued changes as one transition, increments generation once, discards the queue, releases ownership, enters IDLE and returns OK. Even a publication whose words do not change increments generation. It returns PHASE when called in BUILD. No intermediate publication is observable.

R11. abort(actor) requires ownership. It discards a BUILD or CAPTURED transaction without changing words or generation, releases ownership, enters IDLE and returns OK. A subsequent transaction starts with an empty queue.

R12. word(reg,result) returns the committed word and OK. prepared(actor,reg,result) requires ownership and CAPTURED, then returns the prospective word for that register and OK, whether or not the register was selected by an operation. changed(actor,reg,result) has the same requirements and returns sampled_word XOR prospective_word and OK.

R13. operation(index,result) returns the indexed queued Operation and OK, in BUILD or CAPTURED, without requiring an actor. An in-domain index at or beyond queue count returns EMPTY. Operation has reg, kind, mask and value fields, preserving the supplied arguments, including ignored values and zero masks. State state() returns owner (-1 when idle), phase, count and generation. count is zero when idle. These observations remain available after failed calls.

R14. Build the program using g++ -std=c++17 -O2 interlock.cpp console.cpp main.cpp -o interlock. The library also builds with an independent main that includes interlock.hpp and links interlock.cpp and console.cpp. The implementation may use a different internal representation while retaining the declared public types and methods.

R15. The executable reads stdin as lines of bytes separated by LF. Each line has at most 256 bytes excluding LF. Tokens are separated by space, tab or CR; leading and trailing separators are accepted. A numeric token matches -?[0-9]+ and must fit int64_t; leading zeroes and -0 are accepted. The first token is an instance number, 0 or 1, and the second is a case sensitive verb. Both instances live for the duration of one process.

R16. Verbs and their arguments are reset; state; load reg value; begin actor; stage actor reg kind mask value; capture actor; commit actor; abort actor; word reg; prepared actor reg; changed actor reg; operation index. Each verb accepts only the listed number of arguments. Arguments are parsed before any method is called. An unknown verb, invalid instance, malformed number, wrong number of tokens, empty line or overlong line prints ERR followed by LF and leaves both instances unchanged. A syntactically valid number outside a library domain is passed to that method.

R17. reset, load, begin, stage, capture, commit and abort print S status. state prints T owner phase count generation. word prints W status value, prepared prints P status value, and changed prints D status value. These three output references start at 2779096485 before each call. operation prints O status reg kind mask value, starting its reg and kind at -9 and its mask and value at 2779096485. Every field uses ordinary decimal notation without leading zeroes, with one ASCII space between fields, and one LF after the last field. No other stdout or stderr bytes are written.

R18. The executable processes at most 4096 lines. If another line is present it prints LIMIT followed by LF and stops without processing that line or any later input. Empty stdin produces empty stdout. EOF may terminate the last line without LF. The process returns zero on normal completion, including malformed commands and the line limit.

R19. Submit interlock.hpp, interlock.cpp, console.cpp and main.cpp. Only these files are collected and scored; added files are not collected. The implementation must satisfy all clauses of this document. The public smoke is a reproduction aid and does not define the complete behavior.