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

107 lines
2.9 KiB
C

#ifndef RETAINED_H
#define RETAINED_H
#include <stddef.h>
#include <stdint.h>
#define RS_CHANNELS 8
#define RS_PAYLOAD 32
#define RS_BATCH_LIMIT 64
#define RS_OK 0
#define RS_INVALID -1
#define RS_NOMEM -2
#define RS_CLOSED -3
#define RS_FLAG_BAD 1u
#define RS_FLAG_CALIBRATION 2u
typedef struct {
int id;
int channel;
int value;
int age;
unsigned flags;
size_t length;
unsigned char payload[RS_PAYLOAD];
} RsRecord;
typedef struct {
unsigned channels;
int minimum;
int maximum;
int max_age;
unsigned forbidden;
int value_weight;
int age_weight;
int channel_bias[RS_CHANNELS];
} RsPolicy;
typedef struct {
RsRecord record;
int64_t score;
uint64_t batch;
} RsSaved;
typedef struct {
void *context;
void *(*allocate)(void *, size_t);
void (*release)(void *, void *);
} RsAllocator;
typedef struct {
uint64_t batches;
uint64_t records;
uint64_t matches;
uint64_t rejected;
uint64_t changes;
uint64_t clears;
uint64_t invalid;
int64_t value_sum;
uint64_t channels[RS_CHANNELS];
} RsCounters;
typedef struct {
RsAllocator allocator;
RsPolicy policy;
RsSaved *retained;
RsCounters counters;
unsigned ready;
unsigned closed;
} RsSampler;
typedef struct {
int present;
int id;
int channel;
int value;
int age;
unsigned flags;
size_t length;
int64_t score;
uint64_t batch;
uint32_t digest;
} RsView;
typedef struct {
size_t count;
size_t matches;
size_t rejected;
int minimum;
int maximum;
int64_t sum;
uint64_t channel_mask;
uint32_t digest;
} RsBatchInfo;
void rs_policy_default(RsPolicy *policy);
int rs_policy_valid(const RsPolicy *policy);
int rs_record_valid(const RsRecord *record);
int rs_matches(const RsPolicy *policy, const RsRecord *record);
int64_t rs_score(const RsPolicy *policy, const RsRecord *record);
int rs_preferred(const RsSaved *left, const RsSaved *right);
uint32_t rs_payload_digest(const unsigned char *data, size_t length);
int rs_batch_info(const RsPolicy *policy, const RsRecord *records,
size_t count, RsBatchInfo *info);
int rs_init(RsSampler *sampler, RsAllocator allocator, const RsPolicy *policy);
int rs_configure(RsSampler *sampler, const RsPolicy *policy);
int rs_batch(RsSampler *sampler, const RsRecord *records, size_t count);
int rs_clear(RsSampler *sampler);
int rs_close(RsSampler *sampler);
int rs_view(const RsSampler *sampler, RsView *view);
int rs_copy_payload(const RsSampler *sampler, unsigned char *out,
size_t capacity, size_t *length);
int rs_counters(const RsSampler *sampler, RsCounters *counters);
int rs_channel_total(const RsSampler *sampler, unsigned channel,
uint64_t *total);
int rs_mean(const RsSampler *sampler, int64_t *numerator, uint64_t *denominator);
int rs_view_equal(const RsView *left, const RsView *right);
#endif