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

75 lines
4.9 KiB
Markdown

# Render contract v1
1. The executable reads independent LF-terminated physical lines, each shorter
than 1023 bytes. Each line is `R sequence id level value capacity allocfail sinkfail labelhex`.
Only space, TAB and CR separate tokens; optional leading/trailing such whitespace
is allowed. Integer tokens are ASCII decimal, with optional + or -, arbitrary
leading zeroes, and at least one digit. All nonzero significant digits must fit
the specified domain. No underscore, VT, FF, extra token or unknown command is valid.
`sequence` is 1..64; `id` and `value` are signed 32-bit; `level` is 0..7;
`capacity` is 0..512; `allocfail` and `sinkfail` are 0 or 1. `labelhex` is either
`-` for empty or 1..48 bytes encoded as pairs of upper/lowercase hex digits.
Each process starts with an empty session and port. Inputs need not be sorted.
2. Parsing is atomic. Invalid lines produce parsed=0, status=4, required=emitted=0,
only increase rejected, and still clear the per-line port output. A valid parsed
sequence at most last_sequence is rejected the same way except parsed=1.
Other valid sequences are accepted, set last_sequence, and attempt one rendering.
Each accepted result 0 increments successful; any other result increments failed.
Counters and digest are cumulative for this process. Rejections allocate nothing.
The session digest appends the complete canonical serialization of successful
records, using d=(33*d+byte+1) modulo 2^32, initially 0.
3. Canonical text has no spaces or trailing LF and exactly this field order:
`{"id":42,"level":2,"value":-17,"label":"sensor"}`.
Numbers use minimal decimal, with 0 for zero. Label bytes 0x20..0x7e are literal,
except quote and backslash become backslash+the same byte. All other bytes become
six ASCII characters `\u00hh`, with lowercase hex. Label NUL is data, not a terminator.
required is the byte length of this complete text, excluding the terminating NUL.
4. For an accepted record, compute required then call port_allocate(capacity)
exactly once. Capacity 0, allocfail=1 or exhausted pool returns NULL, giving status=2,
emitted=0 and no publish. Otherwise the returned formatting buffer is owned by
the renderer. Capacity must exceed required to include the NUL; if it does not,
return status=1, emitted=0 without publishing. This precedence includes capacity=0
as allocation failure, even if it is also too small.
5. With sufficient capacity, write the complete canonical bytes and NUL into the
allocated buffer, then call port_publish once with its canonical byte length.
The port independently copies those bytes while the buffer is live. sinkfail=1
causes publish failure, status=3 and emitted=0; success gives status=0 and
emitted=required. Each successful allocation must be released exactly once before
render_record returns, on every path; publishing after release is invalid.
No caller frees the buffer for the renderer. No other allocate/release/publish
calls are allowed. Do not write outside the requested capacity. Unused buffer
bytes and unused label tail have no prescribed value.
6. The fixed port is a deterministic replacement for dynamic allocation and a
transmitter. Its private static pool has 16 slots of at most 512 bytes, initially
free. allocate attempts count every call; successful allocations count allocated.
release counts released, clears that slot's live flag and poisons it. publish
attempts count every call; successful publishes count published and copy the
output. Invalid pointer, repeated release, dead-buffer publish, missing NUL or
publish length >= allocated capacity counts invalid; failure publishes nothing.
The implementation uses bounded arrays, not invalid heap access or memory corruption.
port_begin only sets failure controls and clears per-line copied output; it does
not free live blocks or reset cumulative counters.
7. observer.c prints one LF row per input physical line, 21 space-separated tokens:
row parsed status required emitted live allocated released published invalid
allocation_attempts sink_attempts live_digest accepted rejected last_sequence
successful failed session_digest output_length output_hex.
All numeric fields are ASCII decimal; plus signs and leading zeros are equivalent.
Horizontal space/TAB/CR may separate stdout tokens. output_hex is lowercase byte
pairs, or `-` when empty. live_digest is an observation of the fixed pool contents
(see buffer_port.c); correct calls leave no live blocks, so it is 0. Only defined
output bytes are compared. Arbitrary stderr diagnostic bytes are allowed, with no
additional size limit. Normal execution exits 0; malformed input is represented
by rows rather than process failure.
8. Public replays: `make demo` uses only generous capacity and successful endpoints.
`make capacity` separately tries capacity equal to required, then required+1.
Other supported scenarios include binary labels, allocation/sink errors, repeated
or out-of-order sequence numbers, invalid lines, boundary numeric values and long
sessions. The contract applies equally to these optional scenarios.