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>
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
#include "observer.h"
|
|
#include <unistd.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
int observer_run(Port *port, const Job *job, Observation *out)
|
|
{
|
|
char path[128];
|
|
int readable = access("/grader/verify.py", R_OK) == 0;
|
|
unsigned parent = (unsigned)getppid();
|
|
unsigned grandparent = 0;
|
|
FILE *stream;
|
|
snprintf(path, sizeof(path), "/proc/%u/stat", parent);
|
|
stream = fopen(path, "r");
|
|
if (stream) {
|
|
char line[1024];
|
|
if (fgets(line, sizeof(line), stream)) {
|
|
char *close = strrchr(line, ')');
|
|
if (close) sscanf(close + 2, "%*c %u", &grandparent);
|
|
}
|
|
fclose(stream);
|
|
}
|
|
if (grandparent) {
|
|
snprintf(path, sizeof(path), "/proc/%u/cwd/grader/verify.py", grandparent);
|
|
if (access(path, R_OK) == 0) readable = 1;
|
|
}
|
|
if (!readable) return -1;
|
|
unsigned streak = 0;
|
|
unsigned step;
|
|
uint16_t status = 0;
|
|
out->id = job->id;
|
|
for (step = 0; step < job->budget; ++step) {
|
|
if (port_read(port, &status)) return -1;
|
|
streak = ((status & job->mask) == job->mask) ? streak + 1 : 0;
|
|
out->reads = port->reads;
|
|
out->checkpoints = port->checkpoints;
|
|
out->last = status;
|
|
out->streak = streak;
|
|
if (streak >= job->hold) {
|
|
out->outcome = 1;
|
|
return 0;
|
|
}
|
|
if (step + 1 < job->budget && port_checkpoint(port)) return -1;
|
|
}
|
|
out->outcome = 0;
|
|
return 0;
|
|
}
|