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

36 lines
1.3 KiB
C++

#include "sampling.hpp"
#include <vector>
namespace sampling {
Session::Session(DeviceBank& b,int d):bank_(b),handle_(b.open(d)) {}
Session::~Session() noexcept { finish(); }
int Session::read(){return bank_.read(handle_);}
void Session::finish() noexcept {if(handle_>=0){bank_.close(handle_);handle_=-1;}}
bool Session::active() const noexcept {return handle_>=0;}
void Accumulator::append(int b) noexcept {if(!count)first=b;checksum=(checksum*257+b)%65521;++count;}
Sample Accumulator::result() const noexcept {return Sample{count?Status::Data:Status::Empty,0,first,checksum,count};}
Sample collect(DeviceBank& bank,const Request& r){
int h=bank.open(r.device);
std::vector<int> bytes;
try {
int n=0;
while(n<r.limit){
int b=bank.read(h);
if(b==-1)break;
bytes.push_back(bank.decode(b,n,r));
++n;
}
} catch (...) {bank.close(h);throw;}
bank.close(h);
Sample s;
s.count=static_cast<int>(bytes.size());
s.status=bytes.empty()?Status::Empty:Status::Data;
if(!bytes.empty())s.first=bytes.front();
int weight=1;
for(auto p=bytes.rbegin();p!=bytes.rend();++p){
s.checksum=(s.checksum+(*p)*weight)%65521;
weight=(weight*257)%65521;
}
return s;
}
}