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

7.1 KiB

Hot row layout port

This C11 project models a small bank of hot records in process memory. Its “row” is a configured software boundary of 64 or 128 bytes. It is a storage contract, not a statement about the host CPU cache. No DMA or timing behavior is part of this port.

Build and local reproduction

make builds row-console using GCC. No downloaded packages or generated code are required. The console starts with four 64-byte rows. Run printf 'P 0 aabbcc\nB\nV\n' | ./row-console for a short observation; use I 128 4 before writing to try the other supported row width. make clean removes the local binary. The grader builds a fresh copy of submitted sources and invokes the public C API directly; a prebuilt binary is not submitted.

Public API and storage contract

layout.h and journal.h are the public API. A LayoutBank has 1 through 8 independent slots and is initialized with width 64 or 128 using layout_init. Any other width or count returns LAYOUT_EINVAL (-22). Initialization clears all effective lengths and sets the revision to zero. Each slot stores 0 through width bytes. The bytes returned by layout_view are the actual hot data bytes of the slot, not a printed or rounded address. Their starting address must be divisible by width; for a nonempty slot, every byte in [data, data + length) must lie inside that one width-byte row. For an empty slot, the returned data pointer still denotes its aligned row start. Each slot is independent; writing one never changes another slot's effective bytes or length.

The implementation may use more memory than the effective row and may organize its storage differently. Only the effective range is defined; unused tail bytes have no required value. This contract checks the process's actual pointer and effective range, without assuming sizeof(long) or a physical cache line size.

layout_store copies length bytes into a slot; zero length is allowed with a null source. layout_fill writes one byte value repeatedly. layout_clear makes the effective length zero. layout_copy replaces the destination's effective bytes and length with those of the source, including when source equals destination. layout_swap exchanges two slots' effective bytes and lengths, including when indices match. Successful changes increase the bank revision; one successful store, fill, clear, or copy adds one, while a swap of distinct slots adds two. A same-slot swap adds one. The slot generation fields are implementation metadata and are not part of the observable contract.

layout_patch replaces length effective bytes beginning at offset without changing the effective length. layout_insert inserts bytes before offset, shifting the old suffix and increasing the effective length. layout_erase removes length bytes beginning at offset, shifting the suffix left. An offset equal to the effective length is valid for an empty patch, an append insertion, or an empty erase. Each successful edit, including an empty edit, adds one revision. Patch and insert copy the caller bytes as they were at call entry.

layout_view returns the actual slot data pointer and effective length. layout_fetch copies only effective bytes into a caller buffer, returns the length through its output pointer, and accepts a null destination only for an empty slot. layout_stats reports nonempty slot count, total effective bytes, longest effective length, and revision. layout_hash is 32-bit FNV-1a (initial value 2166136261, multiply 16777619 after xor for each byte, unsigned wrap); layout_slot_hash applies it to the effective bytes, including the standard initial value for an empty slot.

For any API taking an index, an index outside 0..count-1 returns LAYOUT_EINVAL. A valid slot with requested length above its configured width returns LAYOUT_ERANGE (-34). layout_fetch with too-small capacity also returns LAYOUT_ERANGE. Null required pointers return LAYOUT_EINVAL. Rejected operations leave the bank's effective bytes, lengths, and revision unchanged. layout_fetch rejection leaves its caller output buffer and output length untouched. The shown API signatures in the headers define the pointer parameters.

For edits, an offset beyond the current effective length or a patch/erase span past its end returns LAYOUT_ERANGE. An insertion that would make the effective length exceed the configured width also returns LAYOUT_ERANGE. A nonempty patch or insertion requires a nonnull source. These checks precede modification, so a failed edit keeps the existing row and revision.

Journal batch contract

A Journal queues up to 16 operations, in order. journal_put, journal_fill, journal_copy, journal_swap, and journal_clear enqueue the corresponding layout action. journal_put copies caller bytes into the queue at enqueue time. A requested length above the maximum supported 128 bytes returns LAYOUT_ERANGE without enqueuing. Queue overflow returns LAYOUT_ERANGE without enqueuing. journal_reset discards queued operations and journal_count reports their number.

journal_patch, journal_insert, and journal_erase queue the matching edits. Patch and insert copy source bytes when enqueued; erase stores only its span. Enqueue rejects a payload length above 128 or a required null source without changing the queue. Edit bounds against a particular row are checked during commit, when earlier queued operations have taken effect.

journal_commit replays the queued operations in order on a private temporary bank and publishes all changes only when every operation succeeds. On the first invalid operation it returns that operation's status and leaves the bank unchanged. It clears the queue after success or failure. A valid 128-byte row must preserve bytes 65 through 128 just as a 64-byte row preserves its last bytes. Empty commits succeed without changing the bank.

Console commands and observation

Each input line has fields separated by space, tab, carriage return, or newline. I width count initializes; P index hex queues a put (- means empty); F index byte length queues a fill; C source destination, S left right, and D index queue copy, swap, and clear; B commits; R resets the queue; V prints a snapshot. A valid hexadecimal payload has two ASCII digits per byte. The console prints RESULT status after a command. V additionally prints STATS occupied total longest revision and one ROW index offset length hash hex line per slot. offset is the actual uintptr_t(data) % width, and hex contains only effective bytes (or - for empty). Stderr may contain diagnostics and has no output format requirement.

A index offset hex, E index offset hex, and Q index offset length queue patch, insert, and erase. The empty hexadecimal payload is -. For example, P 0 aabb, A 0 1 cc, E 0 2 dd, Q 0 0 1, B, V produces effective row bytes ccdd if all commands succeed.

The grader's independent observer uses the same public API and prints raw status, pointer remainder, effective length, effective bytes, hash, and stats. It does not supply expected values to the candidate process. The checker computes expected values independently from the rules above.