From the 101 lk/man/pth code-gen sources: 63 tasks (C11 36, C++17 27, 11 canonical families), 38 skipped for scope or duplication. Each task has at least one independent contract-edge defect, boundary types rotate, and public docs state trap clauses as plain contract prose. Claude reviewed 63/63 USABLE against current digests. Difficulty is unmeasured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
#include "group.hpp"
|
|
|
|
namespace group {
|
|
int Journal::fail_next(Word count)
|
|
{
|
|
if (count > 8) {
|
|
return range;
|
|
}
|
|
failures_ = count;
|
|
return 0;
|
|
}
|
|
|
|
int Journal::commit(Word ticket, const std::vector<Item> &items, Receipt &out)
|
|
{
|
|
const int validation = validate_items(ticket, items);
|
|
if (validation != 0) {
|
|
return validation;
|
|
}
|
|
std::size_t match = entries_.size();
|
|
for (std::size_t i = 0; i < entries_.size(); ++i) {
|
|
if (entries_[i].receipt.ticket == ticket) match = i;
|
|
}
|
|
if (match != entries_.size()) {
|
|
if (same_items(items, entries_[match].items)) {
|
|
out = entries_[match].receipt;
|
|
return 0;
|
|
}
|
|
return exists;
|
|
}
|
|
std::vector<Entry> next = entries_;
|
|
next.push_back(Entry{summarize(ticket, items), items});
|
|
++attempts_;
|
|
if (failures_ == 0) {
|
|
entries_.swap(next);
|
|
out = entries_.back().receipt;
|
|
return 0;
|
|
}
|
|
--failures_;
|
|
return again;
|
|
}
|
|
|
|
int Journal::read(Word index, Receipt &out) const
|
|
{
|
|
if (index >= entries_.size()) {
|
|
return missing;
|
|
}
|
|
out = entries_[static_cast<std::size_t>(index)].receipt;
|
|
return 0;
|
|
}
|
|
|
|
JournalInfo Journal::info() const
|
|
{
|
|
JournalInfo result;
|
|
result.batches = entries_.size();
|
|
result.attempts = attempts_;
|
|
result.failures = failures_;
|
|
for (const Entry &entry : entries_) {
|
|
result.items += entry.receipt.count;
|
|
result.total += entry.receipt.total;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
void Journal::reset()
|
|
{
|
|
entries_.clear();
|
|
attempts_ = 0;
|
|
failures_ = 0;
|
|
}
|
|
}
|