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>
120 lines
3.1 KiB
C
120 lines
3.1 KiB
C
#include "service.h"
|
|
#include <ctype.h>
|
|
#include <errno.h>
|
|
#include <inttypes.h>
|
|
#include <limits.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
static void observe(const queue_service *service, int rc)
|
|
{
|
|
int64_t values[SERVICE_OBSERVATIONS];
|
|
service_snapshot(service, rc, values);
|
|
for (unsigned index = 0; index < SERVICE_OBSERVATIONS; ++index) {
|
|
if (index != 0) {
|
|
putchar(' ');
|
|
}
|
|
printf("%" PRId64, values[index]);
|
|
}
|
|
putchar('\n');
|
|
}
|
|
|
|
static int parse_integer(const char *text, int *result)
|
|
{
|
|
if (text == NULL || *text == '\0') {
|
|
return 0;
|
|
}
|
|
const char *cursor = text;
|
|
if (*cursor == '+' || *cursor == '-') {
|
|
cursor += 1;
|
|
}
|
|
if (*cursor == '\0') {
|
|
return 0;
|
|
}
|
|
while (*cursor != '\0') {
|
|
if (!isdigit((unsigned char)*cursor)) {
|
|
return 0;
|
|
}
|
|
cursor += 1;
|
|
}
|
|
errno = 0;
|
|
char *end = NULL;
|
|
long long value = strtoll(text, &end, 10);
|
|
if (errno == ERANGE || *end != '\0' || value < INT_MIN || value > INT_MAX) {
|
|
return 0;
|
|
}
|
|
*result = (int)value;
|
|
return 1;
|
|
}
|
|
|
|
static int dispatch(queue_service *service, char *line)
|
|
{
|
|
char *words[6];
|
|
unsigned count = 0;
|
|
char *word = strtok(line, " \t\r\n");
|
|
while (word != NULL && count < 6) {
|
|
words[count++] = word;
|
|
word = strtok(NULL, " \t\r\n");
|
|
}
|
|
if (count == 0) {
|
|
return SERVICE_OK;
|
|
}
|
|
if (word != NULL || strlen(words[0]) != 1) {
|
|
return service_reject(service);
|
|
}
|
|
int values[5];
|
|
for (unsigned index = 1; index < count; ++index) {
|
|
if (!parse_integer(words[index], &values[index - 1])) {
|
|
return service_reject(service);
|
|
}
|
|
}
|
|
char command = words[0][0];
|
|
if (command == 'I' && count == 3) {
|
|
return service_init(service, values[0], values[1]);
|
|
}
|
|
if (command == 'S' && count == 4) {
|
|
return service_submit(service, values[0], values[1], values[2]);
|
|
}
|
|
if (command == 'T' && count == 2) {
|
|
return service_turn(service, values[0]);
|
|
}
|
|
if (command == 'A' && count == 2) {
|
|
return service_advance(service, values[0]);
|
|
}
|
|
if (command == 'C' && count == 2) {
|
|
return service_cancel(service, values[0]);
|
|
}
|
|
if (command == 'X' && count == 2) {
|
|
return service_close(service, values[0]);
|
|
}
|
|
if (command == 'N' && count == 2) {
|
|
return service_spurious(service, values[0]);
|
|
}
|
|
if (command == 'Q' && count == 1) {
|
|
return SERVICE_OK;
|
|
}
|
|
return service_reject(service);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
queue_service service = {0};
|
|
service_init(&service, 1, 4);
|
|
char line[512];
|
|
while (fgets(line, sizeof(line), stdin) != NULL) {
|
|
int nonblank = 0;
|
|
for (size_t index = 0; line[index] != '\0'; ++index) {
|
|
if (!isspace((unsigned char)line[index])) {
|
|
nonblank = 1;
|
|
}
|
|
}
|
|
if (!nonblank) {
|
|
continue;
|
|
}
|
|
int rc = dispatch(&service, line);
|
|
observe(&service, rc);
|
|
}
|
|
return ferror(stdin) ? 1 : 0;
|
|
}
|