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>
105 lines
2.3 KiB
C++
105 lines
2.3 KiB
C++
#ifndef PROBE_HPP
|
|
#define PROBE_HPP
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
namespace probe {
|
|
constexpr int DeviceLimit = 32;
|
|
constexpr std::int64_t ClockLimit = 1000000;
|
|
constexpr int EvidenceLimit = 65535;
|
|
constexpr int LifetimeLimit = 1000;
|
|
|
|
enum Code {
|
|
Offline = 0,
|
|
Ready = 1,
|
|
Busy = 2,
|
|
Fault = 3
|
|
};
|
|
|
|
enum Verdict {
|
|
Missing = -1,
|
|
Unavailable = 0,
|
|
Accepted = 1,
|
|
Occupied = 2,
|
|
Broken = 3,
|
|
EvidenceMismatch = 4,
|
|
Expired = 5,
|
|
Invalid = 6
|
|
};
|
|
|
|
struct Query {
|
|
int id = 0;
|
|
int strict = 0;
|
|
int evidence = 0;
|
|
};
|
|
|
|
struct Record {
|
|
int id = 0;
|
|
int code = Offline;
|
|
int evidence = 0;
|
|
std::int64_t stamp = 0;
|
|
int lifetime = 0;
|
|
int revision = 0;
|
|
int checks = 0;
|
|
int accepted = 0;
|
|
int rejected = 0;
|
|
int last = Missing;
|
|
};
|
|
|
|
struct Snapshot {
|
|
bool exists = false;
|
|
Record record;
|
|
};
|
|
|
|
struct Totals {
|
|
int live = 0;
|
|
int offline = 0;
|
|
int ready = 0;
|
|
int busy = 0;
|
|
int fault = 0;
|
|
int fresh = 0;
|
|
int checks = 0;
|
|
int accepted = 0;
|
|
int rejected = 0;
|
|
int revisions = 0;
|
|
std::int64_t fingerprint = 0;
|
|
};
|
|
|
|
bool valid_id(int id);
|
|
bool valid_code(int code);
|
|
bool valid_evidence(int evidence);
|
|
bool valid_lifetime(int lifetime);
|
|
bool valid_query(const Query& query);
|
|
bool is_fresh(const Record& record, std::int64_t now);
|
|
int classify(Record& record);
|
|
bool evidence_matches(Query& query, const Record& record);
|
|
int decide(Record& record, Query& query, std::int64_t now);
|
|
std::vector<std::int64_t> snapshot_fields(const Snapshot& snapshot);
|
|
std::vector<std::int64_t> total_fields(const Totals& totals);
|
|
std::int64_t record_fingerprint(const Record& record);
|
|
|
|
class Registry {
|
|
public:
|
|
explicit Registry(std::int64_t initial = 0);
|
|
bool reset(std::int64_t initial);
|
|
bool set(int id, int code, int evidence, int lifetime);
|
|
bool advance(std::int64_t amount);
|
|
bool drop(int id);
|
|
int ask(Query& query);
|
|
Snapshot view(int id) const;
|
|
Totals totals() const;
|
|
std::int64_t now() const;
|
|
std::vector<int> ids() const;
|
|
std::vector<Snapshot> snapshots() const;
|
|
private:
|
|
std::array<Record, DeviceLimit> records_;
|
|
std::array<bool, DeviceLimit> present_;
|
|
std::int64_t now_;
|
|
Record* find(int id);
|
|
const Record* find(int id) const;
|
|
void account(Record& record, int verdict);
|
|
};
|
|
}
|
|
#endif
|