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>
5.0 KiB
5.0 KiB
Batch ledger contract
- Scope and build. C11, eight channels numbered 0..7, a single ledger in process memory. Build with
makeusing gcc. The executable accepts zero arguments or-for stdin, or one script path. Success is exit 0. Syntax/read/open/output failures are exit 2. Stderr may contain arbitrary diagnostic bytes and is not part of the result protocol. The observer in src/main.c, src/text.c and src/report.c is public; formal grading rebuilds those same sources with the submitted ledger implementation. Only src/ledger.c is submitted. - Limits and storage. At most 64 staged rows. Batch IDs allowed for BEGIN are 1..1000000 and must exceed the last committed ID. A row holds channel, signed value -1000000..1000000, weight 1..1000, and filtered flag 0 or 1. A successfully staged filtered row consumes capacity just like any other row. Runs contain at most 100000 operations, so all documented counts and signed weighted totals fit the declared integer fields. Internal unused staging slots are not observable and have no required contents.
- Initialization and BEGIN. Initialization has zero totals, all eight buckets with zero rows/units/total/min/max, zero completed batches and last committed ID, and no active batch. BEGIN while active returns BF_STATE=1 before testing its ID. Otherwise invalid/non-increasing IDs return BF_RANGE=2; success opens an empty active batch and returns BF_OK=0. Canceled IDs may be reused because only committed IDs constrain ordering.
- ADD. With no active batch return BF_STATE=1. Otherwise invalid row fields return BF_RANGE=2, even when full. A valid row on a full batch returns BF_FULL=3; otherwise append it in input order and return BF_OK=0. Each error preserves the complete public state. ADD never changes committed totals. No row may replace an earlier staged row.
- COMMIT. With no active batch return BF_STATE=1 without change. Otherwise consume every staged row exactly once. Each filtered=1 row increments global ignored only. Each filtered=0 row increments global accepted and its channel rows by one, adds weight to channel units and value*weight to signed weighted_total, and extends channel min/max across all accepted values (including earlier batches). Empty buckets keep min=max=0; first accepted value sets both endpoints. Empty batches are valid. After folding, increment completed batches by one and set last committed ID to the active ID; close the batch and expose active=0, active_batch=0, staged_count=0. Return BF_OK=0. Previous committed measurements remain accumulated.
- CANCEL. With no active batch return BF_STATE=1 without change. Otherwise discard all staged rows and close the batch with active=0, active_batch=0, staged_count=0. Preserve every committed total, completed batch count and last committed ID exactly; return BF_OK=0. This applies also to empty or full canceled batches. See optional examples/cancel.batch; the default demo never calls CANCEL.
- SNAPSHOT. Copy the committed totals and current active flag, active ID and staged count into bf_view, without changing the ledger; no staged values enter committed totals. Snapshots may occur before any command, between ADD calls, after errors and after closing a batch. The C structs and functions are declared in include/batch.h. Callers supply valid non-NULL objects; objects are independent and no dynamic allocation is required. Direct mutation of private struct storage by callers is outside this contract.
- Script syntax. One command per line, blank lines ignored. Tokens use only ASCII space, TAB or CR separators; LF separates lines. Commands are case-sensitive BEGIN id, ADD channel value weight filtered, COMMIT, CANCEL, SNAPSHOT, with exactly these arities. Decimal integers allow an optional + or -, arbitrary leading zeros within the line limit, and ASCII digits only. BEGIN/channel/weight/filtered syntax values must fit uint32_t; value syntax must fit int32_t. A syntactically representable value can still receive BF_RANGE under clauses 2..4. NUL, VT, FF, unknown commands, wrong arity, out-of-storage-range numbers and lines of 1024 bytes or more (excluding LF) are syntax errors. The final line need not end in LF. Script errors may leave already printed prefix output; no particular stdout on exit 2 is required.
- Raw stdout. Every nonblank syntactically valid operation increments ordinal from 1 and prints
R ordinal OPCODE return_codefollowed by LF. SNAPSHOT has return_code 0 and additionally printsH ordinal accepted ignored batches last_batch active active_batch staged_count, then eight linesB ordinal channel rows units weighted_total minimum maximumin channel order. Fields are decimal ASCII tokens separated by horizontal whitespace; optional sign and leading zeros are equivalent displays for integer fields. OPCODE and R/H/B remain exact uppercase tokens. Extra or missing protocol records are errors. No diagnostic text goes to stdout. The grader accepts equivalent integer presentation and ignores horizontal leading/trailing whitespace and blank lines; it checks all defined fields only.