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>
134 lines
3.3 KiB
C
134 lines
3.3 KiB
C
#include "parser.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
struct rp_stream {
|
|
int active;
|
|
size_t position;
|
|
int failed;
|
|
};
|
|
static struct rp_stream slots[4];
|
|
static unsigned char bytes[RP_DOCUMENT + 512];
|
|
static size_t byte_count;
|
|
static long error_at;
|
|
static int deny_open;
|
|
static int deny_close;
|
|
static int opens;
|
|
static int closes;
|
|
|
|
struct rp_stream *rp_open(const char *name)
|
|
{
|
|
size_t i;
|
|
if (strcmp(name, "ledger") != 0 || deny_open) {
|
|
return NULL;
|
|
}
|
|
for (i = 0; i < 4; ++i) {
|
|
if (!slots[i].active) {
|
|
slots[i].active = 1;
|
|
slots[i].position = 0;
|
|
slots[i].failed = 0;
|
|
++opens;
|
|
return &slots[i];
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
int rp_get(struct rp_stream *stream)
|
|
{
|
|
if (error_at >= 0 && stream->position >= (size_t)error_at) {
|
|
stream->failed = 1;
|
|
return -1;
|
|
}
|
|
if (stream->position == byte_count) {
|
|
return -1;
|
|
}
|
|
return bytes[stream->position++];
|
|
}
|
|
|
|
int rp_error(struct rp_stream *stream)
|
|
{
|
|
return stream->failed;
|
|
}
|
|
|
|
int rp_close(struct rp_stream *stream)
|
|
{
|
|
stream->active = 0;
|
|
++closes;
|
|
return deny_close ? -1 : 0;
|
|
}
|
|
|
|
static int nibble(int c)
|
|
{
|
|
if (c >= '0' && c <= '9') return c - '0';
|
|
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
|
return -1;
|
|
}
|
|
|
|
static int read_case(void)
|
|
{
|
|
char hex[(RP_DOCUMENT + 512) * 2 + 1];
|
|
size_t i;
|
|
size_t length;
|
|
if (scanf("%ld %d %d %17408s", &error_at, &deny_open, &deny_close, hex) != 4) {
|
|
return 0;
|
|
}
|
|
if (strcmp(hex, "-") == 0) {
|
|
byte_count = 0;
|
|
return 1;
|
|
}
|
|
length = strlen(hex);
|
|
if (length % 2 != 0) return 0;
|
|
byte_count = length / 2;
|
|
for (i = 0; i < byte_count; ++i) {
|
|
int a = nibble(hex[i * 2]);
|
|
int b = nibble(hex[i * 2 + 1]);
|
|
if (a < 0 || b < 0) return 0;
|
|
bytes[i] = (unsigned char)(a * 16 + b);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static void print_row(int status, const struct rp_model *model, int unchanged)
|
|
{
|
|
size_t i;
|
|
int live = 0;
|
|
for (i = 0; i < 4; ++i) live += slots[i].active;
|
|
printf("{\"rc\":%d,\"live\":%d,\"opens\":%d,\"closes\":%d,\"unchanged\":%d",
|
|
status, live, opens, closes, unchanged);
|
|
if (status == RP_OK) {
|
|
printf(",\"site\":\"%s\",\"rate\":%d,\"sensors\":[", model->site, model->rate);
|
|
for (i = 0; i < model->count && i < RP_SENSORS; ++i) {
|
|
const struct rp_sensor *s = &model->sensors[i];
|
|
if (i) printf(",");
|
|
printf("[%d,%d,%d,%d,%d", s->id, (unsigned char)s->kind,
|
|
s->gain, s->bias, s->has_limit);
|
|
if (s->has_limit) printf(",%d,%d", s->low, s->high);
|
|
printf("]");
|
|
}
|
|
printf("]");
|
|
}
|
|
printf("}");
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
unsigned int count;
|
|
unsigned int i;
|
|
struct rp_model model;
|
|
memset(&model, 0x5a, sizeof(model));
|
|
if (scanf("%u", &count) != 1) return 70;
|
|
printf("{\"rows\":[");
|
|
for (i = 0; i < count; ++i) {
|
|
struct rp_model before;
|
|
int status;
|
|
if (!read_case()) return 70;
|
|
before = model;
|
|
status = rp_load("ledger", &model);
|
|
if (i) printf(",");
|
|
print_row(status, &model, memcmp(&before, &model, sizeof(model)) == 0);
|
|
}
|
|
printf("]}\n");
|
|
return 0;
|
|
}
|