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

9 lines
13 KiB
JSON

{
"driver.c": "#include \"pathvisit.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <errno.h>\n#include <limits.h>\n\nstatic char *tokens[8];\n\nstatic int split(char *line)\n{\n int n = 0;\n char *p = line;\n while (*p != '\\0') {\n while (*p == ' ' || *p == '\\t' || *p == '\\r' || *p == '\\n') {\n p += 1;\n }\n if (*p == '\\0') {\n break;\n }\n if (n == 8) {\n return -1;\n }\n tokens[n++] = p;\n while (*p != '\\0' && *p != ' ' && *p != '\\t' && *p != '\\r' && *p != '\\n') {\n p += 1;\n }\n if (*p != '\\0') {\n *p++ = '\\0';\n }\n }\n return n;\n}\n\nstatic int number(const char *text, long *value)\n{\n char *end;\n const char *p = text;\n long parsed;\n if (*p == '+' || *p == '-') {\n p += 1;\n }\n if (*p == '\\0') {\n return 0;\n }\n while (*p != '\\0') {\n if (*p < '0' || *p > '9') {\n return 0;\n }\n p += 1;\n }\n errno = 0;\n parsed = strtol(text, &end, 10);\n if (errno != 0 || *end != '\\0') {\n return 0;\n }\n *value = parsed;\n return 1;\n}\n\nstatic int add_command(struct pv_catalog *catalog, int n)\n{\n long id;\n long kind;\n long weight;\n if (n != 5 || !number(tokens[1], &id) || !number(tokens[2], &kind) ||\n !number(tokens[3], &weight) || id < 1 || id > 10000 ||\n kind < 0 || kind > 2 || weight < 0 || weight > 10000) {\n return -1;\n }\n return pv_catalog_put(catalog, (int)id, (int)kind, (unsigned)weight, tokens[4]);\n}\n\nstatic int delete_command(struct pv_catalog *catalog, int n)\n{\n long id;\n if (n != 2 || !number(tokens[1], &id) || id < 1 || id > 10000) {\n return -1;\n }\n return pv_catalog_remove(catalog, (int)id);\n}\n\nstatic int visit_command(struct pv_catalog *catalog, struct pv_pool *pool,\n int n, struct pv_result *last)\n{\n struct pv_request request;\n long kind;\n long limit;\n long fail;\n if (n != 5 || !number(tokens[2], &kind) || !number(tokens[3], &limit) ||\n !number(tokens[4], &fail) || kind < -1 || kind > 2 ||\n limit < 0 || limit > PV_ENTRIES || fail < 0 || fail > PV_ENTRIES + 2) {\n return -1;\n }\n request.root = tokens[1];\n request.kind = (int)kind;\n request.limit = (unsigned)limit;\n request.fail_at = (unsigned)fail;\n *last = pv_visit(catalog, pool, &request);\n return last->status;\n}\n\nstatic void observation(unsigned step, int status, const struct pv_catalog *catalog,\n const struct pv_pool *pool, const struct pv_result *last)\n{\n printf(\"%u %d %u %llu %llu %llu %llu %llu %llu %llu %llu %llu %d %d %d %u %u %llu %llu %llu\\n\",\n step, status, catalog->count,\n (unsigned long long)catalog->revision,\n (unsigned long long)pool->attempts,\n (unsigned long long)pool->allocations,\n (unsigned long long)pool->releases,\n (unsigned long long)pool->live,\n (unsigned long long)pool->bytes,\n (unsigned long long)pool->peak,\n (unsigned long long)pool->failures,\n (unsigned long long)pool->bad_releases,\n pv_pool_consistent(pool), pv_catalog_consistent(catalog), last->status, last->visited, last->accepted,\n (unsigned long long)last->characters,\n (unsigned long long)last->weight,\n (unsigned long long)last->digest);\n}\n\nint main(void)\n{\n struct pv_catalog catalog;\n struct pv_pool pool;\n struct pv_result last = {0, 0, 0, 0, 0, 0};\n char line[1024];\n unsigned step = 0;\n pv_catalog_init(&catalog);\n pv_pool_init(&pool);\n while (fgets(line, sizeof(line), stdin) != NULL) {\n int n = split(line);\n int status = -1;\n if (n == 0) {\n continue;\n }\n step += 1;\n if (n > 0 && strcmp(tokens[0], \"A\") == 0) {\n status = add_command(&catalog, n);\n } else if (n > 0 && strcmp(tokens[0], \"D\") == 0) {\n status = delete_command(&catalog, n);\n } else if (n == 1 && strcmp(tokens[0], \"C\") == 0) {\n pv_catalog_clear(&catalog);\n status = 0;\n } else if (n == 1 && strcmp(tokens[0], \"Q\") == 0) {\n status = 0;\n } else if (n > 0 && strcmp(tokens[0], \"V\") == 0) {\n status = visit_command(&catalog, &pool, n, &last);\n }\n observation(step, status, &catalog, &pool, &last);\n }\n pv_pool_dispose(&pool);\n return ferror(stdin) ? 2 : 0;\n}\n",
"Makefile": "CC = gcc\nCFLAGS = -std=c11 -O2 -Wall -Wextra -Wpedantic\nSOURCES = driver.c pool.c catalog.c visitor.c\npath-visitor: $(SOURCES) pathvisit.h\n\t$(CC) $(CFLAGS) $(SOURCES) -o $@\n.PHONY: clean demo\nclean:\n\trm -f path-visitor\ndemo: path-visitor\n\t./path-visitor < demo.txt\n",
"demo.txt": "A 1 0 20 /assets/a\nA 2 1 40 /assets/b\nV /assets -1 0 0\nV /assets -1 0 0\nQ\n",
"pathvisit.h": "#ifndef PATHVISIT_H\n#define PATHVISIT_H\n#include <stddef.h>\n#include <stdint.h>\n#define PV_ENTRIES 48\n#define PV_PATH 97\n#define PV_BLOCKS 256\n#define PV_MOD 1000000007ULL\nstruct pv_block {\n char *address;\n size_t length;\n};\nstruct pv_pool {\n struct pv_block blocks[PV_BLOCKS];\n uint64_t attempts;\n uint64_t allocations;\n uint64_t releases;\n uint64_t live;\n uint64_t bytes;\n uint64_t peak;\n uint64_t failures;\n uint64_t bad_releases;\n unsigned fail_at;\n unsigned round_attempts;\n};\nstruct pv_entry {\n int used;\n int id;\n int kind;\n unsigned weight;\n char path[PV_PATH];\n};\nstruct pv_catalog {\n struct pv_entry entries[PV_ENTRIES];\n unsigned count;\n uint64_t revision;\n};\nstruct pv_result {\n int status;\n unsigned visited;\n unsigned accepted;\n uint64_t characters;\n uint64_t weight;\n uint64_t digest;\n};\nstruct pv_request {\n const char *root;\n int kind;\n unsigned limit;\n unsigned fail_at;\n};\nvoid pv_pool_init(struct pv_pool *pool);\nvoid pv_pool_begin(struct pv_pool *pool, unsigned fail_at);\nchar *pv_pool_copy(struct pv_pool *pool, const char *text);\nvoid pv_pool_release(struct pv_pool *pool, char *address);\nvoid pv_pool_dispose(struct pv_pool *pool);\nint pv_pool_consistent(const struct pv_pool *pool);\nvoid pv_catalog_init(struct pv_catalog *catalog);\nint pv_path_valid(const char *path);\nint pv_is_below(const char *path, const char *root);\nint pv_catalog_put(struct pv_catalog *catalog, int id, int kind,\n unsigned weight, const char *path);\nint pv_catalog_remove(struct pv_catalog *catalog, int id);\nvoid pv_catalog_clear(struct pv_catalog *catalog);\nint pv_catalog_consistent(const struct pv_catalog *catalog);\nsize_t pv_catalog_order(const struct pv_catalog *catalog,\n const struct pv_entry **ordered);\nint pv_request_valid(const struct pv_request *request);\nuint64_t pv_digest_path(uint64_t digest, const struct pv_entry *entry,\n const char *path);\nstruct pv_result pv_visit(struct pv_catalog *catalog, struct pv_pool *pool,\n const struct pv_request *request);\n#endif\n",
"README.md": "# Virtual resource path visitor\nBuild with `make`; reproduce the default report using `make demo`.\nThe program reads a bounded virtual catalog from stdin; it never scans host paths.\nThe complete normative contract is in `docs/visitor-contract.md`.\n`driver.c` is a public raw-observation harness, without assertions or expected values.\nOnly `visitor.c`, `pool.c`, and `catalog.c` are submitted.\n",
"docs/visitor-contract.md": "# Visitor contract, revision 1\n1. Scope and construction\nThis C11 library visits a virtual catalog, not a real directory. Build with `make` (gcc).\n`pathvisit.h` declares the public structs and functions. Candidates may change the three\nsubmitted C files but must preserve these interfaces. Use the documented accounting pool\nfor all temporary root/path copies; observations must represent the actual pool resources.\nCatalog storage is fixed capacity and does not allocate from the pool.\n\n2. Catalog\nAt most 48 entries exist. An ID is 1..10000, kind is 0..2, weight is 0..10000.\nA valid path is ASCII, 1..96 bytes, starts with `/`, and consists of nonempty slash-separated\nsegments using letters, digits, `_`, `-`, `.`. `.` and `..` segments and trailing slash\nare invalid, except `/` alone is valid. Duplicate paths with different IDs are allowed.\nPut replaces an existing ID in place or inserts an ID; it returns 0 and increments revision\nonce. Full insertion returns -2. Invalid arguments return -1 with no catalog changes.\nRemove returns 0 and increments revision once when found, -2 when absent, -1 for invalid ID.\nClear removes every entry and increments revision once, including when already empty.\nEntry order for a visit is ascending ASCII path, then ascending ID for equal paths.\nCatalog consistency is 1 exactly when count agrees with used slots, every used entry is valid,\nand all used IDs are unique; it is 0 otherwise.\nOnly used entries matter; unused struct bytes are unspecified.\n\n3. Round and callback lifecycle\nA request has a valid root path, kind -1 (all) or 0..2, limit 0..48, fail_at 0..50.\nInvalid request returns a zero-valued result except status -1; pool state is unchanged.\nEach valid round starts pool failure indexing anew, then allocates exactly one root copy.\nIt visits only entries equal to root or below root plus `/`; root `/` includes all entries.\nBefore filtering each such entry, increment visited and attempt one path copy.\nFailure of the root or a path copy immediately terminates the round with status -3;\nfailed paths count as visited but are not accepted. Earlier contributions remain.\nKind mismatch rejects the entry after copying it. Matching kind increments accepted,\nadds path byte length and weight, and updates digest in visit order.\nDigest starts at 0. For each accepted path byte b, digest=(digest*131+b)%1000000007;\nthen apply the same recurrence to ID, kind and weight in that order.\nAfter accepting an entry, positive limit reached terminates with status 1, even if it was\nlast in the catalog. Otherwise completion has status 0. Filtering does not consume limit.\nEvery successfully allocated callback copy must be released before the next path attempt\nor returning, and the root copy must be released on every completion, stop or failure.\nRounds cannot retain temporary resources; repeat visits must work independently.\n\n4. Pool accounting\nInitialization zeroes counters and empties slots. Begin changes only fail_at/round_attempts.\nEvery copy increments attempts and round_attempts; fail_at=0 disables injection, otherwise\nthat ordinal attempt in the round fails. A failure increments failures without allocation.\nSuccessful copy stores the NUL-terminated text, charges strlen+1 bytes, increments allocations\nand live, and updates peak=max(previous peak,current bytes). Pool has 256 live slots.\nA release of a currently owned nonnull address frees it exactly once, increments releases,\nand decrements live and bytes. NULL release is harmless; an unknown address increments\nbad_releases. Dispose releases all still-owned blocks. Consistency returns 1 exactly when\nactual occupied slot lengths agree with live/bytes, allocations=releases+live,\nattempts=allocations+failures, and peak>=bytes. No fabricated accounting is permitted.\nSuccessful test-sized copies with failure injection disabled are expected to allocate.\nCounters are cumulative across visits; no clearing except initialization. Public observations\ninclude resource statistics so leaks, stale failure indexing, and counter masking are observable.\n\n5. Public stdin harness\nEach input line is at most 1023 bytes and uses space, TAB or CR between tokens; LF ends it.\nEmpty lines are ignored. Decimal tokens allow a leading + or -, and leading zeroes.\nA id kind weight path : insert/replace. D id : remove. C : clear. Q : query only.\nV root kind limit fail_at : execute one round. Invalid command or wrong arity returns -1.\nInvalid scalar range returns -1 before a visit and leaves last result unchanged. A valid-scalar\nV with invalid root stores the request-error result in last. Catalog operations leave last.\nThe public driver prints one raw observation per nonempty input line, as 20 decimal integers:\nstep command_rc count revision attempts allocations releases live bytes peak failures\nbad_releases consistent catalog_consistent last.status last.visited last.accepted last.characters last.weight\nlast.digest. Step starts at 1. All observed values are within signed 64-bit range in bounded\nsessions (at most 4096 commands); digest is below 1000000007. Numeric stdout permits arbitrary\nleading zeroes and signs, space/TAB/CR separators and LF row endings; no extra stdout records.\nStderr may contain arbitrary diagnostic bytes and has no content or size restriction.\nThe process returns 0 on normal EOF. Extra unused struct bytes have no specified value.\n"
}