amos 9d633e9e67 Batch 15 (20261023-C-hwe-scale-15): 320 HWE-derived repair tasks
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>
2026-10-27 01:55:56 +08:00
..

Repeated reader service

Build with make and run ./app. The default run opens four synthetic files with one virtual descriptor slot. The command below exercises a documented read-error scene:

./app 4 7 17 3 8 1 0 io

./app rounds seed max_length read_cap read_hint error_round error_offset error_kind accepts unsigned decimal arguments. The last argument is none, interrupt, or io. The default invocation uses 4 7 17 3 8 0 0 none. Valid ranges are rounds 0..64, max_length 0..256, read_cap 1..64, read_hint 1..64, error_round 0..64, and error_offset 0..256. The port's descriptor capacity is one. The observer prints exactly one JSON line containing the raw return, result fields and callback counters. It does not decide whether the result is correct. A nonzero candidate return is represented in the JSON; the observer itself exits zero after a valid invocation.

Public C interface

include/rr.h defines rr_run and the callback types. rr_plan.rounds is the number of independent files to process. read_hint is a permitted request size from 1 to 64; implementations may choose any positive read size up to 64. For every round, call open_round(context, round), then read that handle through EOF, then call close_round exactly once before opening the next round. At most one handle may be live. Round order starts at zero. Empty files are complete rounds. With zero rounds, make no port calls and return RR_OK.

read_bytes returns a positive byte count, zero at EOF, or -1 with errno set. Retry EINTR on the same handle. A different read error stops processing, closes the current handle and returns RR_READ_ERROR. An open error returns RR_OPEN_ERROR and does not attempt a close. A close error returns RR_CLOSE_ERROR; it takes precedence over a read error. Do not continue after any error. rr_run returns the same status as result.status. Invalid plan, callback table or result pointer returns RR_BAD_PLAN without port calls; if result is supplied, its counters are reset.

Only a round that reaches EOF and closes successfully contributes to the result. rounds_done counts those rounds. A failed round contributes none of its bytes or summary values. All unsigned 64-bit arithmetic wraps modulo 2^64. bytes, even_bytes and high_bytes sum across completed rounds. rising_pairs counts adjacent bytes for which the later byte is greater. longest is the largest completed round length; empty_rounds counts completed empty files. For a nonempty round, range is the absolute difference between its first and last byte; for an empty round it is zero. range_sum adds those ranges.

For each round, start its digest at 1469598103934665603. For each byte b, set digest to (digest XOR b) * 1099511628211 modulo 2^64. On commit of zero-based round r, add (r+1)*digest to checksum modulo 2^64, and XOR digest_xor with the digest rotated left by r mod 64 bits. Empty rounds still commit their seed digest.

Synthetic port and observer

The port source in src/sim_port.c is included to make behavior reproducible. Round r has length (seed + 17*r + r*r) mod (max_length+1). Its byte at offset p is ((seed XOR (r*37)) XOR (p*19+p*r)) mod 256. The port returns at most read_cap bytes per call, and never more than requested. The sole descriptor slot is freed by a successful close. open_attempts counts calls even if no slot is free; open_successes counts successful opens. The close counters follow the same rule. live, peak, read_calls, delivered_bytes, eof_reads, interrupts, io_errors, and invalid_calls are raw port observations.

If error_kind is interrupt or io, the port raises that error once on error_round when the read offset reaches error_offset. A read crossing that offset stops immediately before it, so the next read sees the error. The injection occurs before EOF when offset equals file length. A configured offset beyond file length or round beyond the plan causes no injection. interrupt then allows reading to continue; io is terminal.

The sim_config fields open_error_round and close_error_round let a direct API caller inject a failed open or close in that round; UINT_MAX disables each injection. An injected failed open creates no handle. The synthetic close releases its slot even when returning an injected error; close_attempts increases but close_successes does not. Both are observable in sim_print_observation. The command-line demo keeps these two injections disabled.

The app and port are fixed support material for local reproduction. Final submission is limited to the files listed in the task prompt. The scorer compiles a fresh copy with the public observer and checks behavior on further deterministic scenarios. The observer prints raw data only; test expectations are calculated separately.

make observer builds the batch form of the same raw observer from src/batch_observer.c. It reads a 64-character hexadecimal nonce and a case count (0..64) on its first stdin line, then one line per case with the eight demo numbers (error_kind encoded as 0/1/2) followed by open_error_round close_error_round; use 4294967295 to disable either added injection. It prints the nonce JSON line, then one observation JSON line per case, without calculating expected values.