One user-space repair task per eligible HWE debug-diag / compile-deploy base ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content filter. Each ships a public spec with a check-to-basis table, at least two defects with single-fix fixtures, a symptom-masking fixture and an alternative correct implementation. Claude re-checked all 320: structure, the HWE quality items and trace6 Docker calibration receipts against current digests (320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120 ad-hoc family names; the next batch maps them to the canonical list. The batch's 1,256-line progress log stays in its factory report and the 36-local branch batch15-hwe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6.2 KiB
Dispatch contract, revision 1
C1. Storage and startup
Four lanes are numbered 0..3. Each owns a FIFO with capacity 8. A message stores positive id (1..1000000), signed value (-100000..100000), and lease (1..255). Startup and R clear every queue, counter, cursor and receiver history; each lane is enabled with one credit and reject period zero. Dispatch mode starts at 0. All counters fit unsigned 64 bits for the supported stream bound of 10000 commands. No heap allocation is required. Queue entries outside the live range have no specified content.
C2. Input and rejection
One line is one command, with whitespace-separated decimal integers; leading/trailing spaces, signs, blank lines and # comments (from # to line end) are supported. Blank/comment lines emit no observation. Commands are case sensitive. An invalid operation, integer overflow, trailing token, unknown command or overlong nonempty line is rejected with rc=-1. A rejected line increments only the service's invalid counter. Numeric fields must be entirely decimal digits after an optional sign. Inputs use no embedded NUL and lines are at most 4096 bytes, including newline. EOF needs no newline.
C3. Commands
R resets as C1 and returns 0. M mode sets mode 0 or 1 and returns 0. L lane enabled credit period sets the lane's enabled bit (0/1), credit (0..8) and receiver rejection period (0..8); it preserves all queue state and counters. G lane amount adds 0..8 credits; a sum over 8 returns -3 without mutation. D lane clears that lane's queue, increments its cancelled counter by its previous queue length, and returns 0. P id value lease mask publishes a message to each lane selected by bits 0..3 of mask (mask 1..15); if any selected queue is full it returns -2 and increments blocked once, with no queue mutation. Otherwise it appends one copy per selected lane, increments published once and returns 0. Repeated ids are allowed and FIFO order is publication order. C id mask removes every matching id from the selected lanes, increments their cancelled counters by the number removed, and preserves other messages in FIFO order. X source target count moves the first 0..8 messages from one distinct lane to another, preserving their values and leases; lanes must be valid and distinct. If source length is less than count it returns -4 without mutation; otherwise insufficient destination space returns -2 and increments blocked once without queue mutation. Success appends to the destination FIFO, increments source moved_out and destination moved_in by count, and returns 0. T performs one tick as C4/C5. S is read-only. Both return 0. Every syntactically valid command with out-of-range arguments is invalid per C2; business refusals -2/-3/-4 do not increment invalid.
C4. Tick maintenance
A tick increments ticks once. Before attempting deliveries, it visits every lane, including disabled lanes and lanes with no credit. Every lane's pulses increases once; every live message lease decreases once. Messages whose lease becomes zero are removed, expired increases by their number, and surviving messages retain FIFO order. Maintenance is required for every lane on every tick, independently of delivery eligibility. A message published with lease 1 expires on the next tick before it can be delivered.
C5. Tick delivery and receiver
After all maintenance, lanes are considered in cyclic order starting at cursor. Each lane is considered at most once. An eligible lane is enabled, has positive credit, and has a nonempty queue. Its oldest message is offered exactly once to port_offer. Mode 0 stops after the first accepted offer; rejected offers allow scanning to continue. Mode 1 considers all four lanes even after accepted offers. An accepted offer pops that message, decreases credit once and increases lane delivered once. A rejected offer retains the message/credit and increases lane refused once. At the end of every tick cursor becomes (old cursor+1)%4 regardless of mode, eligibility or outcome.
The deterministic receiver increments lane attempts on each offer and records the offered id and value. A nonzero period rejects every period-th attempt; period zero accepts all offers. Receiver accepted and rejected count outcomes. On acceptance it adds the message's signed value to sum and updates digest=(digest*33 + id*17 + value+100000) modulo 1000000007. Last id/value record every offer, including rejected ones. Receiver state can only change via offers, reset, or the period field in L. These observations are part of the contract.
C6. API and state observations
dispatch.h defines all public structures and signatures. service_command(Service*, const Command*) applies C1..C5; Command uses op plus its exact arity in argc and integer operands in arg. It validates arguments before any mutation. command_parse(const char*, Command*) returns 1 for a command (including unknown op for subsequent rejection), 0 for empty/comment-only input, and -1 for malformed/overflowing input. queue_push, queue_front, queue_at, queue_pop, queue_age, queue_clear, queue_remove_id, queue_transfer implement a FIFO, with push returning 0/full=-2, front returning NULL when empty, at returning the live ordinal message or NULL when out of range, pop returning 0/empty=-2, age returning number expired, clear returning number removed, remove_id returning number removed, and transfer returning the C3 refusal/success codes (a source identical to target returns -4). Indexes and unused storage are implementation choices. service_init implements C1. port_reset, port_offer and port_configure are supplied in port.c. Code is C11 and must build using the supplied make command.
After each nonempty line the driver prints raw state: S rc mode cursor ticks published blocked invalid; four L lane enabled credit count pulses expired delivered refused cancelled moved_in moved_out; every live Q lane ordinal id value lease in FIFO order; and four V lane period attempts accepted rejected sum digest last_id last_value. Integers are decimal and compared by value; whitespace between tokens is flexible. No stdout records other than this protocol are emitted. Stderr diagnostics are allowed. Reset observations reflect the freshly reset state.