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
..

FlushStore publication contract

This C11 library stages byte records in four banks, each with a 256-byte capacity. store.h is the public API. store.c is the current implementation. make builds a native diagnostic executable with the installed GCC; no cross compiler or device is needed. The exercise checks the software ordering contract below, not an ARM instruction, DMA cache management, or real thread synchronization.

State and return values

A bank begins closed. fs_open(store, bank, revision) opens an empty bank; fs_close closes and clears it; fs_clear empties an open bank. A successful fs_clone copies an open source to a closed, distinct target and opens the target with the supplied revision. Reopening an open bank, closing/operating on a closed bank, or cloning onto an open/same bank returns FS_STATE. An out-of-range bank, offset, count, capacity, null data pointer with positive count, or invalid empty rotation returns FS_RANGE. A publish request without all three port callbacks returns FS_PORT. Rejected operations leave bank state and port events unchanged. Operations returning FS_OK may leave state unchanged when their count is zero.

All offsets and lengths are byte counts. Valid bank indices are 0..3. Values and revision are unsigned; revision may be zero. fs_length returns the current length (zero for a closed or invalid bank). fs_read returns one staged byte at a valid offset. fs_checksum is 32-bit FNV-1a: start 2166136261, XOR each byte, multiply by 16777619 modulo 2^32. The checksum covers only bytes below the effective length. Storage above that length is unspecified.

Staging operations

fs_append adds bytes at the end; fs_insert inserts at an offset including the end; fs_erase removes an in-range span; fs_patch overwrites an in-range span. fs_fill and fs_xor alter an in-range span. fs_reverse reverses an in-range span. fs_rotate rotates an in-range span to the right by shift % count; for zero count, only shift zero is valid. fs_truncate may shorten but cannot extend. fs_copy copies an in-range span from one open bank into an existing in-range span of another open bank, including overlapping self-copy as if through a temporary buffer. Zero-length in-range calls succeed and change nothing.

Publication port

FsPort.write stages bytes at an offset in the selected bank. Staged writes do not change the observer's visible image yet. FsPort.barrier makes all earlier staged writes visible. FsPort.announce synchronously snapshots the currently visible image, together with the announced bank, revision, effective length, and checksum. The port may keep prior visible bytes at unused offsets. The caller must never rely on those unused bytes being zero.

fs_publish on an open bank stages the current effective bytes, completes a barrier, then announces exactly once with that bank's revision, effective length and checksum. Empty records still require the barrier before their announcement. It returns FS_OK; repeating publication is allowed. fs_replace_publish on an open bank atomically replaces its staged record with the supplied bytes and revision, then follows the same write, barrier, announce rule. It supports a shorter replacement (including empty). A successful publication's observer must see exactly the staged effective bytes at the instant of announce. Each successful publication announces once; rejected calls never announce. Implementations may choose any write chunk sizes or order that respect the effective range and final image.

The diagnostic program prints raw port snapshots. Its E line has bank, announced revision, effective length, announced checksum, and the visible effective bytes in lowercase hex. Its S line has each operation's return code and each bank's staged effective bytes. Diagnostic stderr is unrestricted. The grader independently computes expected snapshots and state from this contract, using inputs unknown to candidate code before grading. Build products and native executable output are software evidence only.