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>
117 lines
5.0 KiB
C++
117 lines
5.0 KiB
C++
#include "durable.hpp"
|
|
#include <iostream>
|
|
#include <sstream>
|
|
#include <string>
|
|
using namespace durable;
|
|
namespace {
|
|
std::vector<Sample> initial(Number nonce)
|
|
{
|
|
return {{nonce, nonce, nonce, nonce, nonce, nonce}};
|
|
}
|
|
void samples(char label, int result, const std::vector<Sample> &values)
|
|
{
|
|
std::cout << label << ' ' << result << ' ' << values.size();
|
|
for (const auto &s : values) {
|
|
std::cout << ' ' << s.sequence << ' ' << s.writer << ' ' << s.generation
|
|
<< ' ' << s.topic << ' ' << s.payload << ' ' << s.replayed;
|
|
}
|
|
std::cout << '\n';
|
|
}
|
|
bool execute(Domain &d, char command, std::istringstream &in)
|
|
{
|
|
int id=0, topic=0, durability=0, size=0;
|
|
Number nonce=0, payload=0;
|
|
if (command == 'W' || command == 'O') {
|
|
if (!(in >> id >> topic >> durability >> size)) return false;
|
|
const int result = command == 'W' ? d.open_writer(id, topic, durability, size)
|
|
: d.open_reader(id, topic, durability, size);
|
|
std::cout << "R " << result << '\n';
|
|
} else if (command == 'X' || command == 'C' || command == 'Z') {
|
|
if (!(in >> id)) return false;
|
|
const int result = command == 'X' ? d.close_writer(id) :
|
|
command == 'C' ? d.close_reader(id) : d.clear(id);
|
|
std::cout << "R " << result << '\n';
|
|
} else if (command == 'D' || command == 'L') {
|
|
if (!(in >> id >> size)) return false;
|
|
const int result = command == 'D' ? d.set_depth(id, size) : d.set_capacity(id, size);
|
|
std::cout << "R " << result << '\n';
|
|
} else if (command == 'P') {
|
|
if (!(in >> id >> payload >> nonce)) return false;
|
|
const int result = d.publish(id, payload, nonce);
|
|
std::cout << "P " << result << ' ' << nonce << '\n';
|
|
} else if (command == 'B') {
|
|
if (!(in >> id >> nonce >> size) || size < 0) return false;
|
|
std::vector<Number> values;
|
|
for (int i=0; i<size; ++i) {
|
|
if (!(in >> payload)) return false;
|
|
values.push_back(payload);
|
|
}
|
|
std::vector<Number> output{nonce, nonce};
|
|
const int result = d.publish_many(id, values, output);
|
|
std::cout << "B " << result << ' ' << output.size();
|
|
for (Number value : output) std::cout << ' ' << value;
|
|
std::cout << ' ' << values.size();
|
|
for (Number value : values) std::cout << ' ' << value;
|
|
std::cout << '\n';
|
|
} else if (command == 'H' || command == 'K' || command == 'T') {
|
|
if (!(in >> id)) return false;
|
|
if (command == 'T' && !(in >> size)) return false;
|
|
if (!(in >> nonce)) return false;
|
|
auto output = initial(nonce);
|
|
const int result = command == 'H' ? d.history(id, output) :
|
|
command == 'K' ? d.peek(id, output) : d.take(id, size, output);
|
|
samples(command, result, output);
|
|
} else if (command == 'I') {
|
|
if (!(in >> id >> nonce)) return false;
|
|
WriterInfo info{nonce,nonce,nonce,nonce,nonce,nonce,nonce};
|
|
const int result = d.writer_info(id, info);
|
|
std::cout << "I " << result << ' ' << info.id << ' ' << info.generation << ' '
|
|
<< info.topic << ' ' << info.durability << ' ' << info.depth << ' '
|
|
<< info.published << ' ' << info.retained << '\n';
|
|
} else if (command == 'J') {
|
|
if (!(in >> id >> nonce)) return false;
|
|
ReaderInfo info{nonce,nonce,nonce,nonce,nonce,nonce,nonce,nonce};
|
|
const int result = d.reader_info(id, info);
|
|
std::cout << "J " << result << ' ' << info.id << ' ' << info.topic << ' '
|
|
<< info.durability << ' ' << info.capacity << ' ' << info.received << ' '
|
|
<< info.taken << ' ' << info.lost << ' ' << info.queued << '\n';
|
|
} else if (command == 'A' || command == 'E') {
|
|
std::vector<int> output{91,92};
|
|
if (command == 'A') d.writer_ids(output); else d.reader_ids(output);
|
|
std::cout << command << ' ' << output.size();
|
|
for (int value : output) std::cout << ' ' << value;
|
|
std::cout << '\n';
|
|
} else if (command == 'Q') {
|
|
const auto info = d.totals();
|
|
std::cout << "Q " << info.writers << ' ' << info.readers << ' ' << info.retained
|
|
<< ' ' << info.queued << ' ' << info.next_sequence << '\n';
|
|
} else if (command == 'N') {
|
|
d.reset();
|
|
std::cout << "R 0\n";
|
|
} else {
|
|
return false;
|
|
}
|
|
std::string remaining;
|
|
return !(in >> remaining);
|
|
}
|
|
}
|
|
int main()
|
|
{
|
|
Domain domains[2];
|
|
int selected=0;
|
|
std::string line;
|
|
while (std::getline(std::cin,line)) {
|
|
std::istringstream in(line);
|
|
char command=0;
|
|
if (!(in >> command)) continue;
|
|
if (command == 'U') {
|
|
std::string remaining;
|
|
if (!(in >> selected) || selected < 0 || selected > 1 || (in >> remaining)) return 2;
|
|
std::cout << "U " << selected << '\n';
|
|
} else if (!execute(domains[selected], command, in)) {
|
|
return 2;
|
|
}
|
|
}
|
|
return std::cin.bad() ? 2 : 0;
|
|
}
|