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>
127 lines
3.4 KiB
C++
127 lines
3.4 KiB
C++
#ifndef DURABLE_HPP
|
|
#define DURABLE_HPP
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
#include <deque>
|
|
#include <map>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
namespace durable {
|
|
using Number = std::int64_t;
|
|
struct Sample {
|
|
Number sequence;
|
|
Number writer;
|
|
Number generation;
|
|
Number topic;
|
|
Number payload;
|
|
Number replayed;
|
|
};
|
|
struct WriterInfo {
|
|
Number id;
|
|
Number generation;
|
|
Number topic;
|
|
Number durability;
|
|
Number depth;
|
|
Number published;
|
|
Number retained;
|
|
};
|
|
struct ReaderInfo {
|
|
Number id;
|
|
Number topic;
|
|
Number durability;
|
|
Number capacity;
|
|
Number received;
|
|
Number taken;
|
|
Number lost;
|
|
Number queued;
|
|
};
|
|
struct Totals {
|
|
Number writers;
|
|
Number readers;
|
|
Number retained;
|
|
Number queued;
|
|
Number next_sequence;
|
|
};
|
|
struct HistoryEntry {
|
|
int topic;
|
|
int durability;
|
|
int depth;
|
|
std::deque<Sample> samples;
|
|
};
|
|
class Histories {
|
|
public:
|
|
void attach(int id, Number generation, int topic, int durability, int depth);
|
|
void release(int id, Number generation);
|
|
void remember(const Sample &sample);
|
|
void resize(int id, Number generation, int depth);
|
|
std::vector<Sample> read(int id, Number generation) const;
|
|
std::vector<Sample> replay(int topic) const;
|
|
Number count() const;
|
|
void reset();
|
|
private:
|
|
using Key = std::pair<int, Number>;
|
|
std::map<Key, HistoryEntry> entries_;
|
|
};
|
|
class Domain {
|
|
public:
|
|
Domain();
|
|
int open_writer(int id, int topic, int durability, int depth);
|
|
int close_writer(int id);
|
|
int set_depth(int id, int depth);
|
|
int publish(int id, Number payload, Number &sequence);
|
|
int publish_many(int id, const std::vector<Number> &payloads, std::vector<Number> &sequences);
|
|
int history(int id, std::vector<Sample> &out) const;
|
|
int open_reader(int id, int topic, int durability, int capacity);
|
|
int close_reader(int id);
|
|
int set_capacity(int id, int capacity);
|
|
int peek(int id, std::vector<Sample> &out) const;
|
|
int take(int id, int count, std::vector<Sample> &out);
|
|
int clear(int id);
|
|
int writer_info(int id, WriterInfo &out) const;
|
|
int reader_info(int id, ReaderInfo &out) const;
|
|
void writer_ids(std::vector<int> &out) const;
|
|
void reader_ids(std::vector<int> &out) const;
|
|
Totals totals() const;
|
|
void reset();
|
|
private:
|
|
struct Writer {
|
|
int id;
|
|
Number generation;
|
|
int topic;
|
|
int durability;
|
|
int depth;
|
|
Number published;
|
|
};
|
|
struct Reader {
|
|
int id;
|
|
int topic;
|
|
int durability;
|
|
int capacity;
|
|
Number received;
|
|
Number taken;
|
|
Number lost;
|
|
std::deque<Sample> queue;
|
|
};
|
|
static bool valid_id(int id);
|
|
static bool valid_topic(int topic);
|
|
static bool valid_durability(int durability);
|
|
static bool valid_depth(int depth);
|
|
static bool valid_capacity(int capacity);
|
|
static bool valid_payload(Number payload);
|
|
int writer_arguments(int id, int topic, int durability, int depth) const;
|
|
int reader_arguments(int id, int topic, int durability, int capacity) const;
|
|
Sample make_sample(Writer &writer, Number payload);
|
|
Number commit(Writer &writer, Number payload);
|
|
void deliver(Reader &reader, const Sample &sample);
|
|
void broadcast(const Sample &sample);
|
|
void trim(Reader &reader);
|
|
std::map<int, Writer> writers_;
|
|
std::map<int, Reader> readers_;
|
|
std::map<int, Number> generations_;
|
|
Histories histories_;
|
|
Number next_sequence_;
|
|
};
|
|
}
|
|
#endif
|