All 161 task packages, including the 21 batch 6 C++17 tasks that passed
gates 1/2, are now in Git. rollout.catalog builds docs/task-catalog.{json,md}
from the task packages, a fresh trace5 calibration (128/128 PASS), every
verified controller receipt on the current task digest, documented holds
and digest-bound difficulty reviews. 123 tasks are usable (6 HARD),
5 are on hold and 33 still need a subprocess-only grader.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 lines
8.4 KiB
JSON
5 lines
8.4 KiB
JSON
{
|
|
"overlay.hpp": "#ifndef OVERLAY_HPP\n#define OVERLAY_HPP\n\n#include <cstdint>\n#include <string>\n#include <vector>\n\nnamespace overlay_relocation {\n\nusing Bytes = std::vector<std::uint8_t>;\nconstexpr int ok = 0;\nconstexpr int invalid = -22;\n\nstruct Property {\n std::string name;\n Bytes value;\n};\n\nstruct Node {\n std::string path;\n std::vector<Property> properties;\n};\n\nstruct Tree {\n std::vector<Node> nodes;\n};\n\nint apply_overlay(const Tree& base, const Tree& overlay, Tree& output);\n\n} // namespace overlay_relocation\n\n#endif\n",
|
|
"overlay_observe.cpp": "#include \"overlay.hpp\"\n\n#include <cstdint>\n#include <iostream>\n#include <sstream>\n#include <stdexcept>\n#include <string>\n#include <utility>\n#include <vector>\n\nnamespace {\nusing namespace overlay_relocation;\n\nclass Words {\npublic:\n explicit Words(const std::string& line) : stream_(line) {}\n std::string next() {\n std::string word;\n if (!(stream_ >> word)) throw std::runtime_error(\"missing token\");\n return word;\n }\n std::uint64_t number(std::uint64_t limit) {\n const std::string word = next();\n std::uint64_t result = 0;\n for (unsigned char byte : word) {\n if (byte < '0' || byte > '9') throw std::runtime_error(\"decimal token\");\n const unsigned digit = byte - '0';\n if (digit > limit || result > (limit - digit) / 10) {\n throw std::runtime_error(\"number wire limit\");\n }\n result = result * 10 + digit;\n }\n return result;\n }\n void end() {\n std::string word;\n if (stream_ >> word) throw std::runtime_error(\"extra token\");\n }\nprivate:\n std::istringstream stream_;\n};\n\nunsigned nibble(unsigned char byte) {\n if (byte >= '0' && byte <= '9') return byte - '0';\n if (byte >= 'a' && byte <= 'f') return byte - 'a' + 10;\n if (byte >= 'A' && byte <= 'F') return byte - 'A' + 10;\n throw std::runtime_error(\"hex token\");\n}\n\nstd::string read_bytes(Words& words, std::size_t limit) {\n const std::string word = words.next();\n if (word == \"-\") return {};\n if (word.size() % 2 != 0 || word.size() / 2 > limit) {\n throw std::runtime_error(\"byte wire limit\");\n }\n std::string result;\n result.reserve(word.size() / 2);\n for (std::size_t i = 0; i < word.size(); i += 2) {\n result.push_back(static_cast<char>((nibble(word[i]) << 4) | nibble(word[i + 1])));\n }\n return result;\n}\n\ntemplate<class Range>\nvoid hex(std::ostream& out, const Range& bytes) {\n static const char digits[] = \"0123456789abcdef\";\n out << '\"';\n for (unsigned char byte : bytes) out << digits[byte >> 4] << digits[byte & 15];\n out << '\"';\n}\n\nvoid tree(std::ostream& out, const Tree& value) {\n out << '[';\n for (std::size_t i = 0; i < value.nodes.size(); ++i) {\n if (i != 0) out << ',';\n const Node& node = value.nodes[i];\n out << '[';\n hex(out, node.path);\n out << \", [\";\n for (std::size_t j = 0; j < node.properties.size(); ++j) {\n if (j != 0) out << ',';\n const Property& property = node.properties[j];\n out << '[';\n hex(out, property.name);\n out << ',';\n hex(out, property.value);\n out << ']';\n }\n out << \"]]\";\n }\n out << ']';\n}\n\nstruct Bank {\n Tree inputs[2];\n Tree last;\n bool has_last = false;\n std::size_t names = 0;\n std::size_t data = 0;\n std::size_t properties = 0;\n};\n\nstd::string input_value(const Bank& bank) {\n std::ostringstream out;\n tree(out, bank.inputs[0]);\n out << ',';\n tree(out, bank.inputs[1]);\n return out.str();\n}\n\nTree dirty() {\n return Tree{{Node{\"/old\", {Property{\"OLD\", Bytes{0, 255}}}}}};\n}\n\nstruct Observer {\n Bank banks[2];\n Tree held[4];\n bool has_held[4] = {false, false, false, false};\n unsigned active = 0;\n unsigned calls = 0;\n\n void command(const std::string& line) {\n std::istringstream probe(line);\n std::string first;\n if (!(probe >> first) || first[0] == '#') return;\n Words words(line);\n const std::string op = words.next();\n Bank& bank = banks[active];\n if (op == \"A\") {\n active = static_cast<unsigned>(words.number(1));\n } else if (op == \"N\") {\n bank = Bank{};\n } else if (op == \"F\") {\n Tree& value = bank.inputs[words.number(1)];\n std::string path = read_bytes(words, 131073);\n if (value.nodes.size() >= 513 || path.size() > 262144 - bank.names) {\n throw std::runtime_error(\"node wire limit\");\n }\n bank.names += path.size();\n value.nodes.push_back({std::move(path), {}});\n } else if (op == \"P\") {\n Tree& value = bank.inputs[words.number(1)];\n const auto index = words.number(512);\n if (index >= value.nodes.size()) throw std::runtime_error(\"missing node\");\n std::string name = read_bytes(words, 131073);\n const std::string bytes = read_bytes(words, 65537);\n if (bank.properties >= 4097 || name.size() > 262144 - bank.names ||\n bytes.size() > 2097152 - bank.data) {\n throw std::runtime_error(\"property wire limit\");\n }\n bank.names += name.size();\n bank.data += bytes.size();\n ++bank.properties;\n value.nodes[static_cast<std::size_t>(index)].properties.push_back(\n {std::move(name), Bytes(bytes.begin(), bytes.end())});\n } else if (op == \"R\" || op == \"Y\") {\n const bool alias = op == \"Y\";\n const unsigned which = alias ? static_cast<unsigned>(words.number(1)) : 0;\n words.end();\n if (++calls > 256) throw std::runtime_error(\"call wire limit\");\n const std::string before = input_value(bank);\n Tree output = dirty();\n const int status = apply_overlay(bank.inputs[which], bank.inputs[alias ? which : 1], output);\n const bool unchanged = before == input_value(bank);\n bank.last = output;\n bank.has_last = true;\n std::cout << \"[\\\"\" << op << \"\\\",\" << status << ',';\n tree(std::cout, output);\n std::cout << ',' << (unchanged ? \"true\" : \"false\") << \"]\\n\";\n return;\n } else if (op == \"H\" || op == \"J\" || op == \"M\") {\n const unsigned slot = static_cast<unsigned>(words.number(3));\n words.end();\n if (op == \"H\") {\n if (!bank.has_last) throw std::runtime_error(\"no last output\");\n held[slot] = bank.last;\n has_held[slot] = true;\n } else {\n if (!has_held[slot]) throw std::runtime_error(\"no held output\");\n std::cout << \"[\\\"\" << op << \"\\\",\";\n tree(std::cout, held[slot]);\n if (op == \"M\") {\n Tree copy = held[slot];\n if (!copy.nodes.empty()) {\n copy.nodes[0].path = \"/copy\";\n if (!copy.nodes[0].properties.empty()) {\n copy.nodes[0].properties[0].value = Bytes{0, 255};\n }\n copy.nodes[0].properties.push_back({\"COPY\", Bytes{1, 2}});\n }\n copy.nodes.push_back({\"/new\", {Property{\"NEW\", Bytes{255, 0}}}});\n std::cout << ',';\n tree(std::cout, copy);\n std::cout << ',';\n tree(std::cout, held[slot]);\n }\n std::cout << \"]\\n\";\n }\n return;\n } else {\n throw std::runtime_error(\"unknown command\");\n }\n words.end();\n }\n};\n} // namespace\n\nint main() {\n try {\n Observer observer;\n std::string line;\n while (std::getline(std::cin, line)) {\n if (line.size() > 8388608) throw std::runtime_error(\"line wire limit\");\n observer.command(line);\n }\n if (!std::cin.eof()) throw std::runtime_error(\"input read error\");\n return 0;\n } catch (const std::exception& error) {\n std::cerr << error.what() << '\\n';\n return 2;\n }\n}\n"
|
|
}
|