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>
149 lines
4.3 KiB
C++
149 lines
4.3 KiB
C++
#ifndef DEVICE_PROGRESS_HPP
|
|
#define DEVICE_PROGRESS_HPP
|
|
#include <array>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <iosfwd>
|
|
#include <vector>
|
|
namespace progress {
|
|
constexpr std::uint32_t digest_mod = 1000000007;
|
|
constexpr std::size_t maximum_lanes = 4;
|
|
struct Job {
|
|
std::uint32_t lane;
|
|
std::uint32_t units;
|
|
std::uint32_t stride;
|
|
std::uint32_t seed;
|
|
std::uint32_t operation;
|
|
};
|
|
struct Plan {
|
|
std::uint32_t lanes;
|
|
std::uint32_t modulus;
|
|
std::array<std::uint32_t, maximum_lanes> initial{};
|
|
std::vector<Job> jobs;
|
|
};
|
|
struct WordMetrics {
|
|
std::uint32_t population = 0;
|
|
std::uint32_t runs = 0;
|
|
std::uint32_t leading = 0;
|
|
std::uint32_t trailing = 0;
|
|
std::uint32_t byte_sum = 0;
|
|
};
|
|
WordMetrics measure_word(std::uint32_t word);
|
|
std::uint32_t crc_word(std::uint32_t crc, std::uint32_t word);
|
|
struct Statistics {
|
|
std::uint32_t units = 0;
|
|
std::uint32_t digest = 0;
|
|
std::uint32_t minimum = 0;
|
|
std::uint32_t maximum = 0;
|
|
std::uint32_t parity = 0;
|
|
std::uint32_t population = 0;
|
|
std::uint32_t runs = 0;
|
|
std::uint32_t leading = 0;
|
|
std::uint32_t trailing = 0;
|
|
std::uint32_t byte_sum = 0;
|
|
std::uint32_t crc = 65535;
|
|
std::uint32_t changes = 0;
|
|
std::uint32_t rises = 0;
|
|
std::uint32_t falls = 0;
|
|
std::uint32_t repeats = 0;
|
|
std::uint32_t first = 0;
|
|
std::uint32_t last = 0;
|
|
std::uint32_t weighted = 0;
|
|
std::uint32_t even = 0;
|
|
std::uint32_t odd = 0;
|
|
std::array<std::uint32_t, 4> quartiles{};
|
|
};
|
|
struct JobResult {
|
|
std::uint32_t lane = 0;
|
|
Statistics statistics;
|
|
};
|
|
struct Report {
|
|
int status = 0;
|
|
std::array<Statistics, maximum_lanes> lanes{};
|
|
std::vector<JobResult> jobs;
|
|
std::uint32_t units = 0;
|
|
std::uint32_t digest = 0;
|
|
};
|
|
void accumulate(Statistics& target, std::uint32_t word);
|
|
std::uint32_t span(const Statistics& value);
|
|
std::uint32_t dominant_quartile(const Statistics& value);
|
|
struct Certificate {
|
|
std::uint32_t job = 0;
|
|
std::uint32_t unit = 0;
|
|
std::uint32_t lane = 0;
|
|
std::uint32_t word = 0;
|
|
std::uint32_t digest = 0;
|
|
};
|
|
std::vector<std::uint8_t> encode_certificate(const Certificate& certificate);
|
|
class CertificateReceiver {
|
|
public:
|
|
void consume(std::uint8_t byte);
|
|
const Certificate& last() const;
|
|
std::uint32_t bytes() const;
|
|
std::uint32_t accepted() const;
|
|
std::uint32_t rejected() const;
|
|
std::uint32_t audit() const;
|
|
private:
|
|
void close_frame();
|
|
void append(std::uint8_t byte);
|
|
bool active_ = false;
|
|
bool escaped_ = false;
|
|
bool overflow_ = false;
|
|
std::vector<std::uint8_t> payload_;
|
|
Certificate last_;
|
|
std::uint32_t bytes_ = 0;
|
|
std::uint32_t accepted_ = 0;
|
|
std::uint32_t rejected_ = 0;
|
|
std::uint32_t audit_ = 0;
|
|
};
|
|
class Device;
|
|
class ProgressRegister {
|
|
public:
|
|
std::uint32_t read() const volatile;
|
|
void write(std::uint32_t value) volatile;
|
|
private:
|
|
friend class Device;
|
|
Device* device_ = nullptr;
|
|
std::uint32_t lane_ = 0;
|
|
};
|
|
struct BusState {
|
|
std::uint32_t value = 0;
|
|
std::uint32_t reads = 0;
|
|
std::uint32_t writes = 0;
|
|
std::uint32_t latches = 0;
|
|
std::uint32_t audit = 0;
|
|
};
|
|
class Device {
|
|
public:
|
|
Device(const Plan& plan, std::ostream& output);
|
|
volatile ProgressRegister& port(std::uint32_t lane);
|
|
void begin(std::uint32_t job, const Job& descriptor);
|
|
void checkpoint(std::uint32_t job, std::uint32_t unit,
|
|
std::uint32_t lane, std::uint32_t word, std::uint32_t digest);
|
|
void end(std::uint32_t job, std::uint32_t lane, const Statistics& statistics);
|
|
void certificate(const std::vector<std::uint8_t>& bytes);
|
|
void dump();
|
|
private:
|
|
friend class ProgressRegister;
|
|
std::uint32_t read(std::uint32_t lane);
|
|
void write(std::uint32_t lane, std::uint32_t value);
|
|
void event_prefix(const char* kind);
|
|
void field(std::uint32_t value);
|
|
void finish_event();
|
|
std::array<ProgressRegister, maximum_lanes> ports_{};
|
|
std::array<BusState, maximum_lanes> bus_{};
|
|
std::ostream& output_;
|
|
std::uint32_t lanes_;
|
|
std::uint32_t modulus_;
|
|
std::uint32_t sequence_ = 0;
|
|
std::uint32_t active_job_ = 0;
|
|
std::uint32_t active_lane_ = 0;
|
|
bool active_ = false;
|
|
CertificateReceiver receiver_;
|
|
};
|
|
std::uint32_t sample_word(const Job& job, std::uint32_t unit);
|
|
int validate(const Plan& plan);
|
|
Report execute(const Plan& plan, Device& device);
|
|
}
|
|
#endif
|