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

100 lines
2.8 KiB
C

#include "retained.h"
#include <string.h>
static int readable(const RsSampler *sampler)
{
if (sampler == NULL || !sampler->ready) {
return RS_INVALID;
}
return RS_OK;
}
int rs_view(const RsSampler *sampler, RsView *view)
{
const RsSaved *saved;
if (readable(sampler) != RS_OK || view == NULL) {
return RS_INVALID;
}
memset(view, 0, sizeof(*view));
saved = sampler->retained;
if (saved == NULL) {
return RS_OK;
}
view->present = 1;
view->id = saved->record.id;
view->channel = saved->record.channel;
view->value = saved->record.value;
view->age = saved->record.age;
view->flags = saved->record.flags;
view->length = saved->record.length;
view->score = saved->score;
view->batch = saved->batch;
view->digest = rs_payload_digest(saved->record.payload, saved->record.length);
return RS_OK;
}
int rs_copy_payload(const RsSampler *sampler, unsigned char *out,
size_t capacity, size_t *length)
{
size_t required;
if (readable(sampler) != RS_OK || length == NULL) {
return RS_INVALID;
}
required = sampler->retained == NULL ? 0u : sampler->retained->record.length;
*length = required;
if (capacity < required || (out == NULL && required != 0u)) {
return RS_INVALID;
}
if (required != 0u) {
memcpy(out, sampler->retained->record.payload, required);
}
return RS_OK;
}
int rs_counters(const RsSampler *sampler, RsCounters *counters)
{
if (readable(sampler) != RS_OK || counters == NULL) {
return RS_INVALID;
}
*counters = sampler->counters;
return RS_OK;
}
int rs_channel_total(const RsSampler *sampler, unsigned channel, uint64_t *total)
{
if (readable(sampler) != RS_OK || total == NULL || channel >= RS_CHANNELS) {
return RS_INVALID;
}
*total = sampler->counters.channels[channel];
return RS_OK;
}
int rs_mean(const RsSampler *sampler, int64_t *numerator, uint64_t *denominator)
{
if (readable(sampler) != RS_OK || numerator == NULL || denominator == NULL) {
return RS_INVALID;
}
*numerator = sampler->counters.value_sum;
*denominator = sampler->counters.records;
return RS_OK;
}
int rs_view_equal(const RsView *left, const RsView *right)
{
if (left == NULL || right == NULL) {
return 0;
}
if (left->present != right->present) {
return 0;
}
if (!left->present) {
return 1;
}
if (left->id != right->id || left->channel != right->channel) {
return 0;
}
if (left->value != right->value || left->age != right->age) {
return 0;
}
if (left->flags != right->flags || left->length != right->length) {
return 0;
}
if (left->score != right->score || left->batch != right->batch) {
return 0;
}
return left->digest == right->digest;
}