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

84 lines
2.3 KiB
C

#include "two_streams.h"
#include <string.h>
static int next_record(const ts_port *port, int handle, ts_record *record)
{
char line[TS_LINE_BYTES];
for (;;) {
int read_status = port->read(port->context, handle, line, sizeof(line));
int parsed;
if (read_status < 0) {
return -2;
}
if (read_status == 0) {
return 0;
}
parsed = ts_parse(line, record);
if (parsed < 0) {
return -1;
}
if (parsed > 0) {
return 1;
}
}
}
static ts_status classify_read(int state, int right)
{
if (state == -2) {
return right ? TS_READ_RIGHT : TS_READ_LEFT;
}
return right ? TS_BAD_RIGHT : TS_BAD_LEFT;
}
static ts_status accumulate(ts_ledger *target, const ts_record *left,
const ts_record *right, int scale)
{
int64_t difference = left->value - right->value;
int64_t delta;
int64_t value;
size_t position;
int found;
if (strcmp(left->key, right->key) != 0) {
return TS_KEY_MISMATCH;
}
if (!ts_checked_scale(difference, scale, &delta)) {
return TS_RANGE;
}
found = ts_ledger_find(target, left->key, &position);
if (!found && target->count == TS_KEYS) {
return TS_CAPACITY;
}
value = found ? target->items[position].value : 0;
if (!ts_checked_add(value, delta, &value)) {
return TS_RANGE;
}
if (!ts_ledger_set(target, left->key, value)) {
return TS_CAPACITY;
}
return TS_OK;
}
const char *ts_status_name(ts_status status)
{
switch (status) {
case TS_OK: return "ok";
case TS_OPEN_LEFT: return "open_left";
case TS_OPEN_RIGHT: return "open_right";
case TS_READ_LEFT: return "read_left";
case TS_READ_RIGHT: return "read_right";
case TS_BAD_LEFT: return "bad_left";
case TS_BAD_RIGHT: return "bad_right";
case TS_LENGTH: return "length";
case TS_KEY_MISMATCH: return "key_mismatch";
case TS_RANGE: return "range";
case TS_CAPACITY: return "capacity";
case TS_ROW_LIMIT: return "row_limit";
case TS_BAD_CONFIG: return "bad_config";
}
return "unknown";
}
ts_result ts_run(ts_ledger *d, const ts_port *p, ts_config c)
{ (void)d; (void)p; (void)c; ts_result r = { TS_OPEN_RIGHT, 0 }; return r; }