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

6.4 KiB

Frame recorder contract v1

Frame values

C1. Frame represents one rectangular sensor capture. revision, tag are arbitrary uint32; tick is arbitrary uint64; samples are arbitrary int32. Empty captures use rows=columns=0. Otherwise rows and columns are each 1..4. The active sample count is rows*columns, at most 16. Only active samples are defined; unused array tail is never part of a result. C2. scale is an integer in [-4096,4096]. validate returns BadShape for an invalid shape before considering scale, then BadScale for an out-of-range scale, otherwise Ok. Validation is pure and never accesses the port. C3. summarize reports count, signed 64-bit sum of active samples, minimum and maximum (both zero for empty capture), and a uint64 checksum. Start h=1469598103934665603; for each word w, h=(h xor uint32(w))*1099511628211 modulo 2^64. Words in order: revision, tick low32, tick high32, rows, columns, scale, tag, then active samples. same_frame compares these fields and active samples, ignoring unused tail.

Store behavior

C4. A newly zero-initialized port is unpopulated. snapshot(out) returns Empty and leaves every field of out unchanged until a valid publish. publish returns validate(frame); a rejection changes no port word. A successful publish makes precisely that frame the most recent committed capture, including shrinking, growing, zero dimensions and repeated/wrapping revisions. No assumptions about monotonic revision, tick, tag or sample values are permitted. C5. Once populated, snapshot returns Ok and a complete committed frame. For a snapshot overlapping one valid publish it may return either the complete previous frame or the complete new frame, never a combination. The final snapshot after both operations complete must return the new frame. Returning Empty, a partial frame, a modified frame or a transient error to hide overlap is invalid. Writers are serialized. Readers need not use any particular algorithm; a correct multiword publication protocol is also allowed. C6. The port consists of atomic uint32 words, so individual accesses are defined even when unsynchronized. A word is not an atomic capture. Sequence is an internal publication word, initially 0; Present is initially 0. Public register locations are in frame.hpp. Successful publication stores each field at its declared register, sets Present to 1, and stores each active sample at Payload+i; snapshots read this persistent port state, shared by FrameStore instances. Blocking exclusion must use Port::lock/unlock, owned by the device adapter, so replay can observe contention; private blocking primitives are outside this port API. Nonblocking publication-sequence retry is permitted. Only the active payload has meaning. The port exposes Frame and Layout mutex domains; distinct domains do not exclude one another. Lock/unlock must be balanced. Port accesses, locks and event callbacks are synchronous. Correct store operations must terminate under finite input and one overlapping writer; no unbounded polling for an event that requires the caller to finish.

Deterministic replay

C7. MemoryPort uses sequentially consistent atomic words and two real mutexes. An optional access callback sees the word index, direction and value after each operation. An optional lock callback sees the selected domain and whether its initial try_lock was blocked, before a blocking acquisition waits. Callbacks do not change register values. Both callbacks may be invoked from either thread. Callbacks are copied under a separate instrumentation mutex and invoked after that mutex is released. C8. ReadInterleave launches one pending publish in a worker after the Nth word load by the calling thread, with N>=1. It waits until the worker's first lock attempt is known. If that attempt blocks, the reader continues and the worker finishes after the reader releases its domain. If it does not block, the worker finishes before the triggering load returns. If no load reaches N, finish still publishes the pending frame. finish joins and removes callbacks. Callback instrumentation must not be required for ordinary store correctness. This replay supplies ordering, not hardware timing or TSan certification.

Public console

C9. Build with make (g++ -std=c++17 -pthread). ./frame-demo --demo stable uses two 2x2 frames; --demo resize switches 2x2 to 1x3. The program prints raw API observations and does not judge them. ./frame-demo consumes newline-separated serial/race commands until EOF, ignores blank lines and lines beginning #. Commands and numbers are whitespace-separated decimal. Each line contains at most 8192 bytes. Normal requests exit 0; malformed requests print input error to stderr and exit 2. Additional stderr diagnostics are allowed. C10. A frame input is revision tick rows columns scale tag, followed by max(0,rows*columns) samples when rows,columns are each <=4 (invalid larger shapes carry no samples). serial N then N frames runs on a fresh store, prints initial status plus untouched marker, then one publish status, one bank observation and one snapshot per frame. N=0..128. race CUT then two valid frames runs a fresh store, publishes the first, snapshots with the second pending at CUT=1..128, joins, and snapshots again. No background operation remains after a request. C11. Output is one line per raw observation. P <status> is publish; F <status> is a snapshot. Ok snapshots append all frame fields, active samples, then | count sum min max checksum. Initial observation is E <status> <unchanged> revision tick rows columns scale tag [all 16 samples]; unchanged is the public comparator result, and every seeded destination field is also printed directly for independent comparison. The seed is defined by marker() in src/cli.cpp. A bank observation is B present revision tick_low tick_high rows columns scale_bits tag [active_sample_bits...], all uint32 words read directly from the port after each completed publish. It ignores Sequence and inactive payload. Race prints P, B, F, P, B, F. No hidden assertions are compiled into this console. C12. Status numeric values are Ok=0, Empty=1, BadShape=2, BadScale=3. Frozen public frame.hpp, memory_port, replay and CLI are part of the interface; only src/frame.cpp is submitted. Any conforming implementation is acceptable, including different serialization or retry strategies. Only the public API's defined results matter; no requirement exists for zeroing inactive payload or silence on stderr.