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>
10 lines
16 KiB
JSON
10 lines
16 KiB
JSON
{
|
|
"readonly": {
|
|
"line_port.h": "#ifndef LINE_PORT_H\n#define LINE_PORT_H\n#include <stddef.h>\n#include <stdint.h>\n#define LP_CACHE 37\n#define LP_OK 1\n#define LP_END 0\n#define LP_IO -1\n#define LP_MEMORY -2\n#define LP_LIMIT -3\n#define LP_ARGUMENT -4\nstruct lp_allocator {\n void *context;\n void *(*resize)(void *, void *, size_t);\n void (*release)(void *, void *);\n};\nstruct lp_source {\n void *context;\n int (*read)(void *, unsigned char *, size_t, size_t *);\n};\nstruct lp_cursor {\n struct lp_source source;\n unsigned char cache[LP_CACHE];\n size_t begin;\n size_t end;\n size_t delivered;\n int terminal;\n};\nstruct lp_line {\n unsigned char *data;\n size_t length;\n size_t capacity;\n size_t maximum;\n struct lp_allocator allocator;\n};\nstruct lp_summary {\n uint64_t lines;\n uint64_t bytes;\n uint64_t selected;\n uint64_t selected_bytes;\n uint64_t digest;\n uint64_t longest;\n};\nstruct lp_options {\n size_t maximum;\n size_t stop_after;\n unsigned int divisor;\n unsigned int remainder;\n uint64_t seed;\n};\nstruct lp_result {\n int status;\n struct lp_summary summary;\n size_t delivered;\n};\nint lp_cursor_init(struct lp_cursor *, struct lp_source);\nint lp_cursor_next(struct lp_cursor *, unsigned char *);\nsize_t lp_cursor_delivered(const struct lp_cursor *);\nint lp_cursor_terminal(const struct lp_cursor *);\nint lp_line_init(struct lp_line *, size_t, struct lp_allocator);\nint lp_line_reserve(struct lp_line *, size_t);\nint lp_line_append(struct lp_line *, unsigned char);\nint lp_line_read(struct lp_line *, struct lp_cursor *);\nvoid lp_line_clear(struct lp_line *);\nvoid lp_line_destroy(struct lp_line *);\nvoid lp_summary_init(struct lp_summary *, uint64_t);\nint lp_summary_accept(struct lp_summary *, const unsigned char *, size_t,\n unsigned int, unsigned int);\nint lp_options_valid(const struct lp_options *);\nint lp_run(struct lp_source, struct lp_allocator, const struct lp_options *,\n struct lp_result *);\n#endif\n",
|
|
"observe.c": "#include \"line_port.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <inttypes.h>\n\nstruct slot {\n void *pointer;\n size_t size;\n};\nstruct heap {\n struct slot slots[64];\n size_t live;\n size_t bytes;\n size_t peak;\n size_t attempts;\n size_t successes;\n size_t releases;\n size_t invalid;\n int reject_all;\n};\nstruct bytes {\n unsigned char data[131072];\n size_t size;\n size_t position;\n size_t error_at;\n size_t chunk;\n size_t reads;\n};\n\nstatic struct slot *find_slot(struct heap *heap, void *pointer)\n{\n size_t index;\n for (index = 0; index < 64; index += 1) {\n if (heap->slots[index].pointer == pointer) {\n return &heap->slots[index];\n }\n }\n return NULL;\n}\n\nstatic void *resize_block(void *context, void *pointer, size_t size)\n{\n struct heap *heap = context;\n struct slot *slot;\n void *replacement;\n size_t previous = 0;\n heap->attempts += 1;\n if (pointer == NULL) {\n slot = find_slot(heap, NULL);\n } else {\n slot = find_slot(heap, pointer);\n if (slot != NULL) {\n previous = slot->size;\n }\n }\n if (slot == NULL || size == 0) {\n heap->invalid += 1;\n return NULL;\n }\n if (heap->reject_all) {\n return NULL;\n }\n replacement = realloc(pointer, size);\n if (replacement == NULL) {\n return NULL;\n }\n if (pointer == NULL) {\n heap->live += 1;\n }\n slot->pointer = replacement;\n slot->size = size;\n heap->bytes = heap->bytes - previous + size;\n if (heap->bytes > heap->peak) {\n heap->peak = heap->bytes;\n }\n heap->successes += 1;\n return replacement;\n}\n\nstatic void release_block(void *context, void *pointer)\n{\n struct heap *heap = context;\n struct slot *slot;\n if (pointer == NULL) {\n return;\n }\n slot = find_slot(heap, pointer);\n if (slot == NULL) {\n heap->invalid += 1;\n return;\n }\n free(slot->pointer);\n heap->bytes -= slot->size;\n heap->live -= 1;\n heap->releases += 1;\n slot->pointer = NULL;\n slot->size = 0;\n}\n\nstatic int read_bytes(void *context, unsigned char *out, size_t capacity,\n size_t *amount)\n{\n struct bytes *source = context;\n size_t count = 0;\n source->reads += 1;\n *amount = 0;\n if (source->position == source->error_at) {\n return -1;\n }\n if (source->position == source->size) {\n return 0;\n }\n while (count < capacity && count < source->chunk &&\n source->position < source->size &&\n source->position != source->error_at) {\n out[count] = source->data[source->position];\n source->position += 1;\n count += 1;\n }\n *amount = count;\n return 1;\n}\n\nstatic int nibble(int value)\n{\n if (value >= '0' && value <= '9') {\n return value - '0';\n }\n if (value >= 'a' && value <= 'f') {\n return value - 'a' + 10;\n }\n if (value >= 'A' && value <= 'F') {\n return value - 'A' + 10;\n }\n return -1;\n}\n\nstatic int decode_hex(struct bytes *source, const char *text)\n{\n size_t length = strlen(text);\n size_t index;\n if (strcmp(text, \"-\") == 0) {\n source->size = 0;\n return 1;\n }\n if (length % 2 != 0 || length / 2 > sizeof(source->data)) {\n return 0;\n }\n for (index = 0; index < length; index += 2) {\n int high = nibble(text[index]);\n int low = nibble(text[index + 1]);\n if (high < 0 || low < 0) {\n return 0;\n }\n source->data[index / 2] = (unsigned char)(high * 16 + low);\n }\n source->size = length / 2;\n return 1;\n}\n\nstatic void clear_heap(struct heap *heap)\n{\n size_t index;\n for (index = 0; index < 64; index += 1) {\n free(heap->slots[index].pointer);\n }\n}\n\nstatic void observe_buffer_api(void)\n{\n struct heap heap;\n struct lp_line line;\n struct lp_allocator allocator;\n unsigned char *saved;\n size_t capacity;\n int initialized;\n int first;\n int second;\n int third;\n int preserved;\n int content;\n int cleared;\n int reused;\n int destroyed;\n int repeated;\n int invalid;\n memset(&heap, 0, sizeof(heap));\n allocator.context = &heap;\n allocator.resize = resize_block;\n allocator.release = release_block;\n initialized = lp_line_init(&line, 8, allocator);\n first = lp_line_append(&line, 'a');\n second = lp_line_append(&line, 0);\n third = lp_line_append(&line, 'b');\n content = line.length == 3 && line.data != NULL &&\n line.data[0] == 'a' && line.data[1] == 0 &&\n line.data[2] == 'b' && line.data[3] == 0;\n saved = line.data;\n capacity = line.capacity;\n lp_line_clear(&line);\n preserved = line.data == saved && line.capacity == capacity;\n cleared = line.length == 0 && line.data != NULL && line.data[0] == 0;\n first += lp_line_append(&line, 255);\n reused = line.length == 1 && line.data != NULL &&\n line.data[0] == 255 && line.data[1] == 0;\n lp_line_destroy(&line);\n destroyed = line.data == NULL && line.length == 0 && line.capacity == 0;\n lp_line_destroy(&line);\n repeated = heap.live == 0 && heap.bytes == 0 && heap.invalid == 0;\n invalid = lp_line_init(&line, 0, allocator);\n lp_line_destroy(&line);\n printf(\"P %d %d %d %d %d %d %d %d %d %d %d %zu %zu %zu\\n\",\n initialized, first, second, third, content, preserved, cleared,\n reused, destroyed, repeated, invalid, heap.live, heap.bytes, heap.invalid);\n clear_heap(&heap);\n}\n\nint main(void)\n{\n static char encoded[262145];\n unsigned int id;\n unsigned int reject;\n struct lp_options options;\n struct heap heap;\n struct bytes source;\n struct lp_result result;\n int status;\n int fields;\n observe_buffer_api();\n while ((fields = scanf(\"%u %zu %zu %u %u %\" SCNu64 \" %u %zu %zu %262144s\",\n &id, &options.maximum, &options.stop_after,\n &options.divisor, &options.remainder, &options.seed,\n &reject, &source.error_at, &source.chunk, encoded)) != EOF) {\n if (fields != 10 || source.chunk < 1 || source.chunk > 4096 || reject > 1) {\n return 2;\n }\n source.position = 0;\n source.reads = 0;\n if (!decode_hex(&source, encoded)) {\n return 2;\n }\n memset(&heap, 0, sizeof(heap));\n memset(&result, 0, sizeof(result));\n heap.reject_all = reject;\n status = lp_run((struct lp_source){&source, read_bytes},\n (struct lp_allocator){&heap, resize_block, release_block},\n &options, &result);\n printf(\"J %u %d %d %\" PRIu64 \" %\" PRIu64 \" %\" PRIu64 \" %\" PRIu64\n \" %\" PRIu64 \" %\" PRIu64 \" %zu %zu %zu %zu %zu %zu %zu %zu %zu\\n\",\n id, status, result.status, result.summary.lines, result.summary.bytes,\n result.summary.selected, result.summary.selected_bytes,\n result.summary.digest, result.summary.longest, heap.live, heap.bytes,\n heap.invalid, heap.peak, heap.attempts, heap.successes, heap.releases,\n source.reads, result.delivered);\n clear_heap(&heap);\n }\n return 0;\n}\n",
|
|
"Makefile": "CC = gcc\nCFLAGS = -std=c11 -O2 -Wall -Wextra -Werror -pedantic\nSOURCES = source.c line.c summary.c job.c observe.c\nHEADERS = line_port.h\n.PHONY: all clean demo\nall: observe\nobserve: $(SOURCES) $(HEADERS)\n\t$(CC) $(CFLAGS) $(SOURCES) -o $@\ndemo: observe\n\tprintf '1 128 0 1 0 17 0 999999 7 616c7068610a626574610a\\n' | ./observe\nclean:\n\trm -f observe\n",
|
|
"docs/contract.md": "# Line port contract v1\n\nC01. 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.\n\nC02. 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.\n\nC03. 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.\n\nC04. 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.\n\nC05. 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.\n\nC06. 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.\n\nC07. 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.\n\nC08. 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 digest*257+b+1 modulo 2^64; after the line, append the boundary value 256 by digest=digest*257+256 modulo 2^64. Only complete lines affect digest.\n\nC09. 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.\n\nC10. 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.\n\nC11. 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.\n\nC12. 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.\n\nC13. 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.\n"
|
|
},
|
|
"seed": 97052026
|
|
}
|