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>
4 lines
6.3 KiB
JSON
4 lines
6.3 KiB
JSON
{
|
|
"topic_console.cpp": "#include \"topic.hpp\"\n#include <cstdint>\n#include <iostream>\n#include <limits>\n#include <string>\n#include <vector>\nnamespace {\nusing retained::Sample;\nstd::vector<std::string> words(const std::string &line)\n{\n std::vector<std::string> out;\n std::size_t at = 0;\n while (at < line.size()) {\n if (line[at] == ' ' || line[at] == '\\t' || line[at] == '\\r') {\n ++at;\n continue;\n }\n std::size_t start = at;\n while (at < line.size() && line[at] != ' ' && line[at] != '\\t' && line[at] != '\\r') {\n ++at;\n }\n out.push_back(line.substr(start, at - start));\n }\n return out;\n}\nbool integer(const std::string &token, int &out)\n{\n if (token.empty()) return false;\n std::size_t at = 0;\n bool negative = false;\n if (token[at] == '+' || token[at] == '-') {\n negative = token[at] == '-';\n ++at;\n }\n if (at == token.size()) return false;\n std::uint64_t value = 0;\n const std::uint64_t limit = negative ? 2147483648ULL : 2147483647ULL;\n for (; at < token.size(); ++at) {\n char ch = token[at];\n if (ch < '0' || ch > '9' || value > (limit - (ch - '0')) / 10) return false;\n value = value * 10 + ch - '0';\n }\n out = negative ? static_cast<int>(-static_cast<std::int64_t>(value)) : static_cast<int>(value);\n return true;\n}\nint nibble(char ch)\n{\n if (ch >= '0' && ch <= '9') return ch - '0';\n if (ch >= 'a' && ch <= 'f') return ch - 'a' + 10;\n if (ch >= 'A' && ch <= 'F') return ch - 'A' + 10;\n return -1;\n}\nbool decode(const std::string &token, std::string &out)\n{\n out.clear();\n if (token == \"-\") return true;\n if (token.size() % 2 != 0) return false;\n for (std::size_t at = 0; at < token.size(); at += 2) {\n int high = nibble(token[at]);\n int low = nibble(token[at + 1]);\n if (high < 0 || low < 0) return false;\n out.push_back(static_cast<char>(high * 16 + low));\n }\n return true;\n}\nvoid sample(const Sample &item)\n{\n std::cout << ' ' << item.writer << ' ' << item.generation << ' ' << item.sequence\n << ' ' << item.order << ' ' << item.value << ' ' << item.historical;\n}\nvoid samples(const std::vector<Sample> &items)\n{\n std::cout << ' ' << items.size();\n for (const Sample &item : items) sample(item);\n}\nbool run(retained::Broker &broker, const std::vector<std::string> &w)\n{\n const std::string &op = w[0];\n std::vector<int> a;\n std::string text;\n bool textual = op == \"D\" || op == \"L\";\n std::size_t stop = textual ? w.size() - 1 : w.size();\n for (std::size_t i = 1; i < stop; ++i) {\n int value = 0;\n if (!integer(w[i], value)) return false;\n a.push_back(value);\n }\n if (textual && (w.size() < 2 || !decode(w.back(), text))) return false;\n if (op == \"W\" && a.size() == 4) {\n std::cout << broker.open_writer(a[0], a[1], {a[2], a[3]});\n } else if (op == \"D\" && a.size() == 2) {\n std::cout << broker.open_profile(a[0], a[1], text);\n } else if (op == \"X\" && a.size() == 1) {\n std::cout << broker.close_writer(a[0]);\n } else if (op == \"P\" && a.size() == 2) {\n Sample item{91, 92, 93, 94, 95, 96};\n std::cout << broker.publish(a[0], a[1], item);\n sample(item);\n } else if (op == \"R\" && a.size() == 4) {\n std::cout << broker.open_reader(a[0], a[1], a[2], a[3]);\n } else if (op == \"C\" && a.size() == 1) {\n std::cout << broker.close_reader(a[0]);\n } else if (op == \"N\" && a.size() == 2) {\n std::cout << broker.resize_reader(a[0], a[1]);\n } else if (op == \"H\" && a.size() == 2) {\n std::cout << broker.set_history(a[0], a[1]);\n } else if ((op == \"T\" && a.size() == 2) || (op == \"E\" && a.size() == 1)) {\n std::vector<Sample> items{{91, 92, 93, 94, 95, 96}};\n int rc = op == \"T\" ? broker.take(a[0], a[1], items) : broker.peek(a[0], items);\n std::cout << rc;\n samples(items);\n } else if (op == \"Q\" && a.size() == 1) {\n retained::ReaderView v{91, 92, 93, 94, 95, 96};\n int rc = broker.reader_view(a[0], v);\n std::cout << rc << ' ' << v.topic << ' ' << v.durability << ' ' << v.capacity\n << ' ' << v.pending << ' ' << v.dropped << ' ' << v.delivered;\n } else if (op == \"V\" && a.size() == 1) {\n retained::WriterView v{91, 92, 93, 94, 95, 96};\n int rc = broker.writer_view(a[0], v);\n std::cout << rc << ' ' << v.topic << ' ' << v.durability << ' ' << v.depth\n << ' ' << v.generation << ' ' << v.published << ' ' << v.cached;\n } else if (op == \"F\" && a.size() == 1) {\n retained::TopicView v{91, 92, 93, 94};\n int rc = broker.topic_view(a[0], v);\n std::cout << rc << ' ' << v.writers << ' ' << v.readers << ' ' << v.cached << ' ' << v.pending;\n } else if (op == \"S\" && a.empty()) {\n retained::Summary v = broker.summary();\n std::cout << v.writers << ' ' << v.readers << ' ' << v.cached << ' ' << v.pending\n << ' ' << v.publications << ' ' << v.generations;\n } else if (op == \"Z\" && a.empty()) {\n broker.clear();\n std::cout << 0;\n } else if (op == \"L\" && a.empty()) {\n retained::Policy p{91, 92};\n int rc = retained::parse_policy(text, p);\n std::cout << rc << ' ' << p.durability << ' ' << p.depth;\n } else if (op == \"M\" && a.size() == 2) {\n std::string result = retained::format_policy({a[0], a[1]});\n std::cout << result.size();\n for (unsigned char ch : result) std::cout << ' ' << static_cast<unsigned>(ch);\n } else {\n return false;\n }\n std::cout << '\\n';\n return true;\n}\n}\nint main()\n{\n retained::Broker brokers[2];\n int selected = 0;\n std::string line;\n while (std::getline(std::cin, line)) {\n std::vector<std::string> w = words(line);\n if (w.empty()) continue;\n if (w[0] == \"U\") {\n int next = 0;\n if (w.size() != 2 || !integer(w[1], next) || next < 0 || next > 1) return 2;\n selected = next;\n std::cout << selected << '\\n';\n } else if (!run(brokers[selected], w)) {\n return 2;\n }\n }\n return std::cin.bad() ? 2 : 0;\n}\n"
|
|
}
|