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

193 lines
4.2 KiB
C

#include "stream.h"
#include <limits.h>
void text_reset(struct text *t)
{
t->length = 0;
t->failed = 0;
t->bytes[0] = 0;
}
int text_char(struct text *t, char c)
{
if (t->failed) {
return -1;
}
if (t->length + 1 >= TEXT_LIMIT) {
t->failed = 1;
return -1;
}
t->bytes[t->length] = c;
t->length += 1;
t->bytes[t->length] = 0;
return 0;
}
int text_word(struct text *t, const char *s)
{
if (s == NULL) {
t->failed = 1;
return -1;
}
while (*s != 0) {
if (text_char(t, *s) != 0) {
return -1;
}
s += 1;
}
return 0;
}
int text_unsigned(struct text *t, unsigned long long n)
{
char reverse[32];
size_t count = 0;
do {
reverse[count] = (char)('0' + n % 10);
count += 1;
n /= 10;
} while (n != 0);
while (count != 0) {
count -= 1;
if (text_char(t, reverse[count]) != 0) {
return -1;
}
}
return 0;
}
int text_signed(struct text *t, long long n)
{
unsigned long long magnitude;
if (n < 0) {
if (text_char(t, '-') != 0) {
return -1;
}
magnitude = (unsigned long long)(-(n + 1));
magnitude += 1;
} else {
magnitude = (unsigned long long)n;
}
return text_unsigned(t, magnitude);
}
int text_field(struct text *t, long long n)
{
if (text_char(t, ' ') != 0) {
return -1;
}
return text_signed(t, n);
}
int text_end(struct text *t)
{
return text_char(t, '\n');
}
static int start_line(struct text *t, char type, int serial)
{
text_reset(t);
if (text_char(t, type) != 0) {
return -1;
}
return text_field(t, serial);
}
static int finish_line(struct text *t)
{
if (t->failed) {
return -1;
}
return text_end(t);
}
int format_data(struct text *t, const struct job *j, int ordinal, const struct record *r)
{
if (start_line(t, 'D', j->serial) != 0) {
return -1;
}
if (text_field(t, ordinal) != 0) {
return -1;
}
if (text_field(t, r->channel) != 0) {
return -1;
}
if (text_field(t, r->tick) != 0) {
return -1;
}
if (text_field(t, r->value) != 0) {
return -1;
}
return finish_line(t);
}
int format_audit(struct text *t, const struct job *j, int ordinal, int status)
{
if (start_line(t, 'A', j->serial) != 0) {
return -1;
}
if (text_field(t, ordinal) != 0) {
return -1;
}
if (text_field(t, status) != 0) {
return -1;
}
return finish_line(t);
}
int format_index(struct text *t, const struct job *j, int ordinal, size_t offset, size_t length)
{
if (start_line(t, 'I', j->serial) != 0) {
return -1;
}
if (text_field(t, ordinal) != 0) {
return -1;
}
if (text_field(t, (long long)offset) != 0) {
return -1;
}
if (text_field(t, (long long)length) != 0) {
return -1;
}
return finish_line(t);
}
int format_barrier(struct text *t, const struct job *j, int ordinal, int tick)
{
if (start_line(t, 'B', j->serial) != 0) {
return -1;
}
if (text_field(t, ordinal) != 0) {
return -1;
}
if (text_field(t, tick) != 0) {
return -1;
}
return finish_line(t);
}
int format_total(struct text *t, const struct job *j, const struct report *r)
{
if (start_line(t, 'T', j->serial) != 0) {
return -1;
}
if (text_field(t, r->accepted) != 0) {
return -1;
}
if (text_field(t, r->filtered) != 0) {
return -1;
}
if (text_field(t, r->invalid) != 0) {
return -1;
}
if (text_field(t, r->notes) != 0) {
return -1;
}
if (text_field(t, r->barriers) != 0) {
return -1;
}
if (text_field(t, r->sum) != 0) {
return -1;
}
if (text_field(t, r->checksum) != 0) {
return -1;
}
return finish_line(t);
}
int format_end(struct text *t, const struct job *j, int index, size_t bytes)
{
if (start_line(t, index ? 'E' : 'Z', j->serial) != 0) {
return -1;
}
if (text_field(t, index ? (long long)bytes : j->count) != 0) {
return -1;
}
return finish_line(t);
}