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

97 lines
2.5 KiB
C

#include "rr.h"
static int arguments_valid(const rr_plan *plan, const rr_io *io,
size_t limit, size_t block)
{
if (!rr_plan_validate(plan)) {
return 0;
}
if (io == NULL || io->open == NULL || io->read == NULL || io->close == NULL) {
return 0;
}
if (limit > RR_DATA_SIZE || block == 0 || block > RR_BLOCK_SIZE) {
return 0;
}
return 1;
}
static int release(const rr_io *io, int handle, rr_result *result)
{
int status = io->close(io->context, handle);
++result->closed;
return status;
}
static void finish_empty(rr_result *result, rr_status status)
{
result->selected = -1;
result->status = status;
rr_buffer_reset(&result->content);
}
static int collect(const rr_io *io, int handle, size_t block,
rr_result *result)
{
unsigned char bytes[RR_BLOCK_SIZE];
for (;;) {
ssize_t count = io->read(io->context, handle, bytes, block);
++result->reads;
if (count < 0) {
return -1;
}
if (count == 0) {
return 0;
}
if ((size_t)count > block) {
return -1;
}
if (rr_buffer_append(&result->content, bytes, (size_t)count) != 0) {
return 1;
}
}
}
int rr_read_plan(const rr_plan *plan, const rr_io *io, size_t limit,
size_t block, rr_result *result)
{
size_t index;
if (result == NULL) {
return -1;
}
rr_result_init(result, limit);
if (!arguments_valid(plan, io, limit, block)) {
result->status = RR_BAD_PLAN;
return 0;
}
for (index = 0; index < plan->count; ++index) {
const char *name = rr_plan_name(plan, index);
int handle;
int outcome;
int close_status;
++result->attempts;
handle = io->open(io->context, name);
if (handle < 0) {
++result->failures;
continue;
}
++result->opened;
rr_buffer_reset(&result->content);
outcome = collect(io, handle, block, result);
if (result->content.size) result->content.data[0] = 0;
close_status = release(io, handle, result);
if (outcome < 0 || close_status != 0) {
++result->failures;
continue;
}
if (outcome > 0) {
finish_empty(result, RR_TOO_LARGE);
return 0;
}
result->selected = (int)index;
result->status = RR_OK;
return 0;
}
finish_empty(result, RR_UNAVAILABLE);
return 0;
}