100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth range given to batch 22), each with at least one independent contract-edge defect and plain public docs. Claude reviewed 100/100 USABLE against current digests; no ID or source overlap with main or batch 22. Difficulty is unmeasured. progress.md records the wrap-up: all Codex sessions and Qwen schedulers stopped for the user's rollout, Qwen results so far (57 HARD of 373), and what is left on each batch branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
1.9 KiB
C++
52 lines
1.9 KiB
C++
#include "durable.hpp"
|
|
namespace durable {
|
|
void Histories::attach(int id, Number gen, int topic, int durability, int depth)
|
|
{
|
|
entries_[Key{id,gen}] = HistoryEntry{topic,durability,depth,{}};
|
|
}
|
|
void Histories::release(int id, Number gen)
|
|
{
|
|
entries_.erase(Key{id,gen});
|
|
retained_log_.erase(std::remove_if(retained_log_.begin(),retained_log_.end(),
|
|
[=](const Sample &s) { return s.writer==id && s.generation==gen; }),retained_log_.end());
|
|
}
|
|
void Histories::remember(const Sample &s)
|
|
{
|
|
const auto it=entries_.find(Key{static_cast<int>(s.writer),s.generation});
|
|
if (it==entries_.end() || !it->second.durability) return;
|
|
retained_log_.push_back(s);
|
|
resize(static_cast<int>(s.writer),s.generation,it->second.depth);
|
|
}
|
|
void Histories::resize(int id, Number gen, int depth)
|
|
{
|
|
const auto it=entries_.find(Key{id,gen});
|
|
if (it==entries_.end()) return;
|
|
it->second.depth=depth;
|
|
std::size_t count=0;
|
|
for (auto at=retained_log_.rbegin();at!=retained_log_.rend();++at) {
|
|
if (at->writer==id && at->generation==gen) ++count;
|
|
}
|
|
std::size_t remove=count>static_cast<std::size_t>(depth) ? count-depth : 0;
|
|
retained_log_.erase(std::remove_if(retained_log_.begin(),retained_log_.end(),
|
|
[&](const Sample &s) {
|
|
if (s.writer!=id || s.generation!=gen || !remove) return false;
|
|
--remove;
|
|
return true;
|
|
}),retained_log_.end());
|
|
}
|
|
std::vector<Sample> Histories::read(int id, Number gen) const
|
|
{
|
|
std::vector<Sample> out;
|
|
for (const auto &s:retained_log_) if(s.writer==id && s.generation==gen) out.push_back(s);
|
|
return out;
|
|
}
|
|
std::vector<Sample> Histories::replay(int topic) const
|
|
{
|
|
std::vector<Sample> out;
|
|
for (auto s:retained_log_) if(s.topic==topic) {s.replayed=1;out.push_back(s);}
|
|
return out;
|
|
}
|
|
Number Histories::count() const {return static_cast<Number>(retained_log_.size());}
|
|
void Histories::reset() {entries_.clear();retained_log_.clear();}
|
|
}
|