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>
6.3 KiB
Line port contract v1
C01. Build offline using make, then run ./observe with stdin; make demo is a text-only demonstration. C11, gcc and make suffice. No GNU getline or real external file is required.
C02. The API in line_port.h is public. Candidate files are source.c, line.c, summary.c, job.c. The header, observation program and this contract are fixed support. lp_run returns its status and writes the same status in result.status. A valid run starts with the requested seed and zero summary counters.
C03. A byte source returns 1 with 1..capacity bytes, 0 with no bytes at EOF, or a negative value with no bytes for an I/O error. Cursor delivery preserves every byte in order. LP_CACHE is only a cache size, not a record limit. Cursor delivered counts bytes returned to the line reader, including a byte which exposes overlength. Callback read counts and prefetch position may vary by implementation.
C04. A line includes its terminating LF byte, if present. Empty input has zero lines; LF alone is one line of length 1; consecutive LF bytes make separate lines; a final nonempty suffix at EOF is one complete line. CR, NUL, bytes 128..255 and all other bytes are ordinary content. The public length, never C-string termination, defines the content.
C05. maximum is 1..65536 inclusive and bounds content bytes including LF, excluding a convenience NUL sentinel. A completed line of exactly maximum bytes is valid. A further content byte returns LP_LIMIT (-3); that unfinished line contributes no summary. Earlier completed lines remain published. The byte exposing overlength has been delivered.
C06. Cursor error discards any incomplete current line and returns LP_IO (-1), even if a partial suffix exists. An error exactly after a completed LF preserves that line. EOF may be discovered after a final suffix. Error and EOF at the same source position resolve as error. Already-prefetched bytes preceding the error are still delivered first.
C07. Nonempty line storage is obtained only through allocator.resize(context, old, size), with ordinary realloc semantics and strictly positive size. A NULL result preserves old ownership and returns LP_MEMORY (-2), discarding the unfinished line. allocator.release returns any live allocation exactly once. No allocation may remain on any return, including EOF, early stop, limit, error, or allocation failure; invalid release is forbidden. Empty input need not allocate. Capacity policy, allocation count and peak capacity are implementation choices. One line buffer is reusable across successive lines, and lp_line_clear keeps its allocation; lp_line_destroy resets pointer, length and capacity to zero and tolerates repeated destroy.
C08. Each complete line increases lines by 1, bytes by its full content length, and longest by the maximum completed content length. Let S be the unsigned sum of every byte of the line. If S modulo divisor equals remainder, increment selected and add the length to selected_bytes. For every completed line byte b, digest becomes digest257+b+1 modulo 2^64; after the line, append the boundary value 256 by digest=digest257+256 modulo 2^64. Only complete lines affect digest.
C09. stop_after is 0 (unlimited) or 1..1000000. After that many complete lines, return success (0) immediately without delivering any byte from the following line. divisor is 1..256 and remainder is 0..divisor-1. Invalid options return LP_ARGUMENT (-4), zero counters and the requested seed, without reading or allocating. NULL result returns LP_ARGUMENT; other NULL required callbacks are invalid. Direct line/cursor functions use their declared status constants and argument checks.
C10. Observation stdin has one job per line: id maximum stop_after divisor remainder seed reject_all error_at chunk hex. id is a nonnegative 32-bit tag; seed is uint64; other numbers are size_t-range nonnegative decimal. hex is even-length hexadecimal byte content, or - for empty. chunk 1..4096 caps each successful callback read. error_at is the source byte offset where reads fail, or a value beyond input length for no error. reject_all 1 makes every allocation return NULL, 0 permits allocations. Formal inputs use at most 131072 content bytes. Horizontal input whitespace is space or TAB, each job ends LF. The harness also accepts its C scanf whitespace.
C11. Each job prints one ASCII row beginning J, then 18 decimal fields in this order: id, API return, result.status, lines, bytes, selected, selected_bytes, digest, longest, live allocation count, live allocated bytes, invalid allocator operations, peak allocated bytes, resize attempts, successful resizes, releases, source callback calls, cursor delivered. Decimal tokens may have leading + or -, arbitrary leading zeroes and be separated by space/TAB/CR; rows end LF. Negative signs are meaningful for status. No extra stdout rows or tokens are allowed. stderr may contain arbitrary diagnostic bytes without a size restriction. Normal observation process exits 0, malformed observation input exits 2.
C12. Formal verification rebuilds the submitted files with the fixed public header/observer, executes independent generated jobs and checks all semantic fields, zero live/invalid resources, delivery count, valid nonnegative resource observations, and conservation successes>=releases with releases zero iff successes zero for this single reused allocation. It does not require unused struct padding, unused cache bytes, exact allocation policy, callback count, peak value, capacity, stderr wording or stderr size. Real allocation exhaustion is outside the small public input bound; explicit reject_all failure is required.
C13. Before J rows, the observer prints one P row containing 14 decimal fields: initialization status, combined first/fourth append statuses, second append status, third append status, exact content/sentinel boolean, clear preserves pointer/capacity boolean, cleared content boolean, reused content boolean, destroyed fields boolean, repeated destroy resource boolean, invalid-maximum initialization status, final live count, final live bytes and invalid allocator operations. It initializes maximum 8, appends bytes 97/0/98, clears, appends 255, destroys twice, initializes maximum 0 and destroys again. Expected statuses are 0/0/0/0 and -4 for invalid initialization; all six content/lifetime booleans are 1, and all three resource counts are 0. Only these defined values are compared.