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

1 line
9.1 KiB
JSON

{"route.hpp": "#ifndef BUILD_RUN_ROUTE_HPP\n#define BUILD_RUN_ROUTE_HPP\n\n#include <cstdint>\n#include <string>\n#include <vector>\n\nnamespace route {\n\nstruct Config {\n bool cross = false;\n std::string host_machine;\n std::string target_machine;\n std::vector<std::string> exe_wrapper;\n std::string runtime_root;\n};\n\nstruct Artifact {\n std::string path;\n std::string machine;\n bool built = false;\n};\n\nstruct Test {\n std::string name;\n std::string input;\n std::vector<std::string> arguments;\n};\n\nstruct Observation {\n int exit_code = 0;\n std::string machine;\n std::string output;\n};\n\nclass RunPort {\npublic:\n virtual ~RunPort() = default;\n virtual Observation invoke(const std::vector<std::string>& argv,\n const std::string& input) = 0;\n};\n\nstruct TestResult {\n std::string name;\n bool attempted = false;\n bool passed = false;\n int exit_code = -1;\n std::string machine;\n std::string output;\n};\n\nstruct Report {\n bool build_ok = false;\n bool tests_ok = false;\n std::string reason;\n std::vector<TestResult> tests;\n};\n\n// Parse the public cross description. On failure, return false, leave output unchanged,\n// and provide a short human-readable error. Whitespace and quoting are specified in docs.\nbool parse_config(const std::string& text, Config& output, std::string& error);\n\n// Create one argv for a target test. No shell interpretation is involved.\nbool command_for(const Config& config, const Artifact& artifact,\n const Test& test, std::vector<std::string>& argv,\n std::string& error);\n\n// Build status and target execution are distinct observations. Never claim that\n// a target test passed unless RunPort was called and reported a matching target.\nReport execute(const Config& config, const Artifact& artifact,\n const std::vector<Test>& tests, RunPort& port);\n\n} // namespace route\n\n#endif\n", "observer.cpp": "#include \"route.hpp\"\n\n#include <charconv>\n#include <cstddef>\n#include <cstdint>\n#include <iostream>\n#include <iterator>\n#include <map>\n#include <sstream>\n#include <string>\n#include <utility>\n#include <vector>\n\nnamespace {\n\nint hex_value(char ch) {\n if (ch >= '0' && ch <= '9') return ch - '0';\n if (ch >= 'a' && ch <= 'f') return ch - 'a' + 10;\n return -1;\n}\n\nbool decode(const std::string& token, std::string& output) {\n if (token == \"-\") {\n output.clear();\n return true;\n }\n if (token.empty() || token.size() % 2 != 0) return false;\n std::string value;\n value.reserve(token.size() / 2);\n for (std::size_t i = 0; i < token.size(); i += 2) {\n const int hi = hex_value(token[i]);\n const int lo = hex_value(token[i + 1]);\n if (hi < 0 || lo < 0) return false;\n value.push_back(static_cast<char>((hi << 4) | lo));\n }\n output = std::move(value);\n return true;\n}\n\nstd::string encode(const std::string& input) {\n static constexpr char digits[] = \"0123456789abcdef\";\n if (input.empty()) return \"-\";\n std::string result;\n result.reserve(input.size() * 2);\n for (unsigned char byte : input) {\n result.push_back(digits[byte >> 4]);\n result.push_back(digits[byte & 15]);\n }\n return result;\n}\n\nbool number(const std::string& token, std::size_t& output) {\n if (token.empty()) return false;\n for (char ch : token) if (ch < '0' || ch > '9') return false;\n std::size_t parsed = 0;\n const auto result = std::from_chars(token.data(), token.data() + token.size(), parsed);\n if (result.ec != std::errc{} || result.ptr != token.data() + token.size()) {\n return false;\n }\n output = parsed;\n return true;\n}\n\nstd::vector<std::string> tokens(const std::string& line) {\n std::istringstream stream(line);\n std::vector<std::string> result;\n std::string token;\n while (stream >> token) result.push_back(token);\n return result;\n}\n\nstruct Case {\n std::string config;\n route::Artifact artifact;\n std::vector<route::Test> tests;\n std::map<std::string, route::Observation> responses;\n};\n\nbool case_header(const std::vector<std::string>& fields, Case& current,\n std::size_t& test_count) {\n if (fields.size() != 6 || fields[0] != \"CASE\") return false;\n if (!decode(fields[1], current.config) ||\n !decode(fields[2], current.artifact.path) ||\n !decode(fields[3], current.artifact.machine)) return false;\n if (fields[4] != \"0\" && fields[4] != \"1\") return false;\n current.artifact.built = fields[4] == \"1\";\n if (!number(fields[5], test_count)) return false;\n return true;\n}\n\nbool test_line(const std::vector<std::string>& fields, route::Test& test,\n route::Observation& response) {\n if (fields.size() < 7 || fields[0] != \"TEST\") return false;\n if (!decode(fields[1], test.name) || !decode(fields[2], test.input) ||\n !decode(fields[4], response.machine) ||\n !decode(fields[5], response.output)) return false;\n const auto status = std::from_chars(fields[3].data(),\n fields[3].data()+fields[3].size(),\n response.exit_code);\n if (status.ec != std::errc{} ||\n status.ptr != fields[3].data()+fields[3].size()) return false;\n std::size_t count = 0;\n if (!number(fields[6], count) || count != fields.size() - 7) return false;\n for (std::size_t i = 7; i < fields.size(); ++i) {\n std::string argument;\n if (!decode(fields[i], argument)) return false;\n test.arguments.push_back(std::move(argument));\n }\n return true;\n}\n\nclass RecordingPort : public route::RunPort {\npublic:\n explicit RecordingPort(std::map<std::string, route::Observation> responses)\n : responses_(std::move(responses)) {}\n\n route::Observation invoke(const std::vector<std::string>& argv,\n const std::string& input) override {\n calls_.push_back({argv, input});\n const auto found = responses_.find(input);\n if (found == responses_.end()) return {-1, \"\", \"\"};\n return found->second;\n }\n\n void print(std::size_t index) const {\n for (const Call& call : calls_) {\n std::cout << \"CALL \" << index << ' ' << call.argv.size();\n for (const std::string& arg : call.argv) std::cout << ' ' << encode(arg);\n std::cout << ' ' << encode(call.input) << '\\n';\n }\n }\n\nprivate:\n struct Call {\n std::vector<std::string> argv;\n std::string input;\n };\n std::map<std::string, route::Observation> responses_;\n std::vector<Call> calls_;\n};\n\nvoid print_report(std::size_t index, const route::Report& report) {\n std::cout << \"RESULT \" << index << ' ' << static_cast<int>(report.build_ok)\n << ' ' << static_cast<int>(report.tests_ok) << ' '\n << encode(report.reason) << ' ' << report.tests.size() << '\\n';\n for (const route::TestResult& test : report.tests) {\n std::cout << \"ITEM \" << index << ' ' << encode(test.name) << ' '\n << static_cast<int>(test.attempted) << ' '\n << static_cast<int>(test.passed) << ' ' << test.exit_code << ' '\n << encode(test.machine) << ' ' << encode(test.output) << '\\n';\n }\n}\n\nbool run_case(std::size_t index, const Case& current) {\n route::Config config;\n std::string error;\n const bool parsed = route::parse_config(current.config, config, error);\n std::cout << \"PARSE \" << index << ' ' << static_cast<int>(parsed) << ' '\n << encode(error) << '\\n';\n if (!parsed) return true;\n RecordingPort port(current.responses);\n const route::Report report = route::execute(config, current.artifact,\n current.tests, port);\n port.print(index);\n print_report(index, report);\n return true;\n}\n\n} // namespace\n\nint main() {\n const std::string raw_input(std::istreambuf_iterator<char>(std::cin), {});\n std::istringstream input(raw_input);\n std::string line;\n std::size_t index = 0;\n while (std::getline(input, line)) {\n Case current;\n std::size_t count = 0;\n if (!case_header(tokens(line), current, count)) {\n std::cerr << \"invalid CASE line\\n\";\n return 2;\n }\n for (std::size_t i = 0; i < count; ++i) {\n if (!std::getline(input, line)) {\n std::cerr << \"missing TEST line\\n\";\n return 2;\n }\n route::Test test;\n route::Observation response;\n if (!test_line(tokens(line), test, response)) {\n std::cerr << \"invalid TEST line\\n\";\n return 2;\n }\n current.responses[test.input] = std::move(response);\n current.tests.push_back(std::move(test));\n }\n if (!run_case(index++, current)) return 2;\n }\n std::cout << \"READ \" << encode(raw_input) << '\\n';\n return 0;\n}\n"}