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

141 lines
4.3 KiB
C++

#include "packet.hpp"
#include <iostream>
namespace {
using namespace packet;
void print_memory(const Memory& memory) {
MemoryView view = memory.view();
std::cout << ' ' << view.attempts;
std::cout << ' ' << view.allocated;
std::cout << ' ' << view.released;
std::cout << ' ' << view.failures;
std::cout << ' ' << view.invalid;
std::cout << ' ' << view.nodes;
std::cout << ' ' << view.payloads;
std::cout << ' ' << view.bytes;
}
void snapshot(unsigned step, const Queue& queue, const Memory& memory) {
Stats stats = queue.stats();
std::cout << "S " << step;
std::cout << ' ' << stats.accepted;
std::cout << ' ' << stats.popped;
std::cout << ' ' << stats.expired;
std::cout << ' ' << stats.cleared;
std::cout << ' ' << stats.moved;
std::cout << ' ' << stats.refused;
std::cout << ' ' << stats.oom;
for (unsigned index = 0; index != 3; ++index) {
LaneView lane = queue.lane(index);
std::cout << ' ' << lane.count;
std::cout << ' ' << lane.bytes;
std::cout << ' ' << lane.head;
std::cout << ' ' << lane.tail;
std::cout << ' ' << lane.checksum;
std::cout << ' ' << lane.capacity;
}
print_memory(memory);
std::cout << '\n';
}
int execute(const std::vector<std::string>& tokens, Queue& queue, Memory& memory, Packet& result) {
std::uint32_t first = 0;
std::uint32_t second = 0;
std::uint32_t third = 0;
if (tokens.empty()) {
return -1;
}
const std::string& command = tokens[0];
if (command == "P" && tokens.size() == 6) {
Packet packet;
if (!number(tokens[1], 2, first)) {
return -1;
}
if (!number(tokens[2], 999999, packet.id)) {
return -1;
}
if (!number(tokens[3], 3, second)) {
return -1;
}
if (!number(tokens[4], 1000000, packet.deadline)) {
return -1;
}
if (!decode(tokens[5], packet.data)) {
return -1;
}
packet.priority = second;
return queue.push(first, packet);
}
if ((command == "O" || command == "K" || command == "C") && tokens.size() == 2) {
if (!number(tokens[1], 2, first)) {
return -1;
}
if (command == "O") {
return queue.pop(first, result);
}
if (command == "K") {
return queue.peek(first, result);
}
return queue.clear(first);
}
if (command == "E" && tokens.size() == 3) {
if (!number(tokens[1], 2, first) || !number(tokens[2], 1000000, second)) {
return -1;
}
return queue.expire(first, second);
}
if (command == "M" && tokens.size() == 4) {
if (!number(tokens[1], 2, first) || !number(tokens[2], 2, second)) {
return -1;
}
if (!number(tokens[3], 32, third)) {
return -1;
}
return queue.move(first, second, third);
}
if (command == "L" && tokens.size() == 3) {
if (!number(tokens[1], 2, first) || !number(tokens[2], 32, second)) {
return -1;
}
return queue.limit(first, second);
}
if (command == "F" && tokens.size() == 2) {
if (!number(tokens[1], 1000, first)) {
return -1;
}
memory.fail_after(first);
return 0;
}
if (command == "X" && tokens.size() == 1) {
queue.shutdown();
return 0;
}
return -1;
}
}
int main() {
packet::Memory memory;
{
packet::Queue queue(memory);
std::string line;
unsigned step = 0;
while (std::getline(std::cin, line)) {
std::vector<std::string> tokens = packet::words(line);
if (tokens.empty()) {
continue;
}
++step;
packet::Packet result;
int code = execute(tokens, queue, memory, result);
std::cout << "R " << step << ' ' << code;
if (code == 0 && (tokens[0] == "O" || tokens[0] == "K")) {
std::cout << ' ' << result.id << ' ' << result.priority;
std::cout << ' ' << result.deadline << ' ' << packet::encode(result.data);
}
std::cout << '\n';
snapshot(step, queue, memory);
}
}
std::cout << "Z";
print_memory(memory);
std::cout << '\n';
return 0;
}