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

136 lines
2.9 KiB
C

#include "array_report.h"
#include <limits.h>
#include <string.h>
static int in_range(int value, int lower, int upper)
{
return value >= lower && value <= upper;
}
int ra_valid(const ra_request *request)
{
if (request == NULL) {
return 0;
}
if (!in_range(request->count, 0, RA_LIMIT)) {
return 0;
}
if (request->seed > 65535U) {
return 0;
}
if (!in_range(request->base, -100, 100)) {
return 0;
}
if (!in_range(request->step, -7, 7)) {
return 0;
}
if (!in_range(request->mode, 0, 3)) {
return 0;
}
if (!in_range(request->cutoff, 0, 100)) {
return 0;
}
if (!in_range(request->window, 1, 16)) {
return 0;
}
if (!in_range(request->bins, 1, 8)) {
return 0;
}
if (!in_range(request->fail_at, 0, 2)) {
return 0;
}
return 1;
}
int ra_transform(int value, int mode)
{
if (mode == 1) {
return value < 0 ? -value : value;
}
if (mode == 2) {
if (value < -25) {
return -25;
}
if (value > 25) {
return 25;
}
return value;
}
if (mode == 3) {
int square = value * value;
return value < 0 ? -square : square;
}
return value;
}
static uint32_t next_word(uint32_t current)
{
return current * UINT32_C(1664525) + UINT32_C(1013904223);
}
static int admitted(int value, int cutoff)
{
int magnitude = value < 0 ? -value : value;
return magnitude >= cutoff;
}
size_t ra_generate(const ra_request *request, ra_cell *cells)
{
uint32_t word = request->seed;
size_t used = 0;
for (int index = 0; index < request->count; ++index) {
word = next_word(word);
int noise = (int)((word >> 16) % 101U) - 50;
int raw = request->base + (index % 11) * request->step + noise;
int value = ra_transform(raw, request->mode);
if (admitted(value, request->cutoff)) {
cells[used].value = value;
cells[used].position = (unsigned)index;
used += 1;
}
}
return used;
}
static int port_valid(const ra_port *port)
{
if (port == NULL) {
return 0;
}
if (port->allocate == NULL) {
return 0;
}
if (port->release == NULL) {
return 0;
}
if (port->publish == NULL) {
return 0;
}
return 1;
}
static void report_header(const ra_request *request, size_t used, ra_report *report)
{
memset(report, 0, sizeof(*report));
report->v[0] = request->count;
report->v[1] = (long long)used;
report->v[2] = request->count - (long long)used;
}
static void release_pair(const ra_port *port, ra_cell *cells, unsigned *order)
{
if (order != NULL) {
port->release(port->context, order);
}
if (cells != NULL) {
port->release(port->context, cells);
}
}
int ra_process(const ra_request *request, const ra_port *port)
{
(void)request;
(void)port;
return 0;
}