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>
97 lines
2.2 KiB
C
97 lines
2.2 KiB
C
#include "window.h"
|
|
#include <string.h>
|
|
|
|
static int slot_index(unsigned slot)
|
|
{
|
|
return slot < CW_SLOTS;
|
|
}
|
|
|
|
static int span_valid(unsigned first, unsigned count)
|
|
{
|
|
if (first > CW_CAPACITY) {
|
|
return 0;
|
|
}
|
|
if (count > CW_CAPACITY - first) {
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
void store_reset(CodeWorkbench *work)
|
|
{
|
|
memset(work, 0, sizeof(*work));
|
|
}
|
|
|
|
int store_write(CodeWorkbench *work, unsigned slot, unsigned first,
|
|
const uint16_t *words, unsigned count)
|
|
{
|
|
if (!slot_index(slot)) {
|
|
return CW_ADAPTER;
|
|
}
|
|
if (words == NULL || count == 0 || !span_valid(first, count)) {
|
|
return CW_ADAPTER;
|
|
}
|
|
CodeSlot *target = &work->slots[slot];
|
|
for (unsigned index = 0; index < count; ++index) {
|
|
target->data[first + index] = words[index];
|
|
}
|
|
work->counts.writes += count;
|
|
return CW_OK;
|
|
}
|
|
|
|
int store_sync(CodeWorkbench *work, unsigned slot, unsigned first,
|
|
unsigned end)
|
|
{
|
|
if (!slot_index(slot)) {
|
|
return CW_ADAPTER;
|
|
}
|
|
if (end <= first || end > CW_CAPACITY) {
|
|
return CW_ADAPTER;
|
|
}
|
|
CodeSlot *target = &work->slots[slot];
|
|
for (unsigned index = first; index < end; ++index) {
|
|
target->execution[index] = target->data[index];
|
|
}
|
|
work->counts.sync_calls += 1;
|
|
work->counts.sync_words += end - first;
|
|
return CW_OK;
|
|
}
|
|
|
|
static int publication_valid(Publication kind, unsigned length)
|
|
{
|
|
if (kind == CW_DROP) {
|
|
return length == 0;
|
|
}
|
|
if (kind != CW_INSTALL && kind != CW_PATCH) {
|
|
return 0;
|
|
}
|
|
return length > 0 && length <= CW_CAPACITY;
|
|
}
|
|
|
|
int store_publish(CodeWorkbench *work, unsigned slot, unsigned length,
|
|
Publication kind)
|
|
{
|
|
if (!slot_index(slot) || !publication_valid(kind, length)) {
|
|
return CW_ADAPTER;
|
|
}
|
|
CodeSlot *target = &work->slots[slot];
|
|
target->active = kind != CW_DROP;
|
|
target->length = length;
|
|
target->generation += 1;
|
|
work->counts.serial += 1;
|
|
switch (kind) {
|
|
case CW_INSTALL:
|
|
work->counts.installs += 1;
|
|
break;
|
|
case CW_PATCH:
|
|
work->counts.patches += 1;
|
|
break;
|
|
case CW_DROP:
|
|
work->counts.drops += 1;
|
|
break;
|
|
default:
|
|
return CW_ADAPTER;
|
|
}
|
|
return CW_OK;
|
|
}
|