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>
73 lines
2.1 KiB
C++
73 lines
2.1 KiB
C++
#include "calibration.hpp"
|
|
#include <algorithm>
|
|
namespace quant {
|
|
static bool point_in_format(int format, std::int32_t point) {
|
|
switch (format) {
|
|
case 0:
|
|
return point >= 0 && point <= 255;
|
|
case 1:
|
|
return point >= -128 && point <= 127;
|
|
case 2:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
static bool valid_definition(const Definition& value) {
|
|
if (value.channels.empty() || value.channels.size() > 8) {
|
|
return false;
|
|
}
|
|
for (const Channel& channel : value.channels) {
|
|
if (!point_in_format(value.format, channel.zero_point)) {
|
|
return false;
|
|
}
|
|
if (channel.numerator < 1 || channel.numerator > 1000000) {
|
|
return false;
|
|
}
|
|
if (channel.denominator < 1 || channel.denominator > 1000000) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
Status Bank::replace(const std::vector<Definition>& proposal) {
|
|
if (proposal.size() > 16) {
|
|
return Status::Capacity;
|
|
}
|
|
std::vector<Definition> staged;
|
|
for (const Definition& value : proposal) {
|
|
if (!valid_definition(value)) {
|
|
return Status::Invalid;
|
|
}
|
|
auto duplicate = std::find_if(staged.begin(), staged.end(),
|
|
[&value](const Definition& item) { return item.id == value.id; });
|
|
if (duplicate != staged.end()) {
|
|
return Status::Invalid;
|
|
}
|
|
staged.push_back(value);
|
|
}
|
|
definitions_.swap(staged);
|
|
++revision_;
|
|
return Status::Ok;
|
|
}
|
|
const Definition* Bank::find(std::uint32_t id) const {
|
|
for (const Definition& value : definitions_) {
|
|
if (value.id == id) {
|
|
return &value;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
Snapshot Bank::snapshot() const {
|
|
Snapshot result;
|
|
result.revision = revision_;
|
|
result.definitions = definitions_;
|
|
std::sort(result.definitions.begin(), result.definitions.end(),
|
|
[](const Definition& left, const Definition& right) { return left.id < right.id; });
|
|
return result;
|
|
}
|
|
std::uint64_t Bank::revision() const {
|
|
return revision_;
|
|
}
|
|
}
|