From the 101 lk/man/pth code-gen sources: 63 tasks (C11 36, C++17 27, 11 canonical families), 38 skipped for scope or duplication. Each task has at least one independent contract-edge defect, boundary types rotate, and public docs state trap clauses as plain contract prose. Claude reviewed 63/63 USABLE against current digests. Difficulty is unmeasured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
15 lines
12 KiB
JSON
15 lines
12 KiB
JSON
{
|
|
"seed": 220027,
|
|
"candidate_files": [
|
|
"input.hpp",
|
|
"state.cpp",
|
|
"registry.cpp",
|
|
"reports.cpp",
|
|
"frames.cpp"
|
|
],
|
|
"context": {
|
|
"input_console.cpp": "#include \"input.hpp\"\n#include <climits>\n#include <iostream>\n#include <sstream>\n#include <string>\n#include <vector>\nusing panel::Capability;\nusing panel::Service;\nstatic bool number(const std::string& word, int& value)\n{\n if (word.empty()) {\n return false;\n }\n std::size_t offset = 0;\n bool negative = false;\n if (word[offset] == '+' || word[offset] == '-') {\n negative = word[offset] == '-';\n offset += 1;\n }\n if (offset == word.size()) {\n return false;\n }\n unsigned long long total = 0;\n unsigned long long limit = negative ? 2147483648ULL : 2147483647ULL;\n for (; offset < word.size(); ++offset) {\n unsigned char ch = word[offset];\n if (ch < '0' || ch > '9') {\n return false;\n }\n unsigned digit = ch - '0';\n if (total > (limit - digit) / 10) {\n return false;\n }\n total = total * 10 + digit;\n }\n long long signed_value = negative ? -static_cast<long long>(total) : static_cast<long long>(total);\n value = static_cast<int>(signed_value);\n return true;\n}\nstatic std::vector<std::string> words(const std::string& line)\n{\n std::vector<std::string> output;\n std::size_t pos = 0;\n while (pos < line.size()) {\n if (line[pos] == ' ' || line[pos] == '\\t') {\n ++pos;\n continue;\n }\n std::size_t start = pos;\n while (pos < line.size() && line[pos] != ' ' && line[pos] != '\\t') {\n ++pos;\n }\n output.push_back(line.substr(start, pos - start));\n }\n return output;\n}\nstatic void string_json(const std::string& text)\n{\n std::cout << '\"';\n for (unsigned char ch : text) {\n if (ch == '\"' || ch == '\\\\') {\n std::cout << '\\\\' << ch;\n } else if (ch < 32 || ch >= 127) {\n static const char* hex = \"0123456789abcdef\";\n std::cout << \"\\\\u00\" << hex[ch >> 4] << hex[ch & 15];\n } else {\n std::cout << ch;\n }\n }\n std::cout << '\"';\n}\nstatic void capabilities(const std::vector<Capability>& caps)\n{\n std::cout << '[';\n bool comma = false;\n for (const auto& cap : caps) {\n if (comma) std::cout << ',';\n comma = true;\n std::cout << '[' << cap.type << ',' << cap.code << ',' << cap.lower << ',' << cap.upper << ']';\n }\n std::cout << ']';\n}\nstatic void events(const std::vector<panel::Event>& list)\n{\n std::cout << '[';\n bool comma = false;\n for (const auto& event : list) {\n if (comma) std::cout << ',';\n comma = true;\n std::cout << '[' << event.type << ',' << event.code << ',' << event.value << ']';\n }\n std::cout << ']';\n}\nstatic void observe(const Service& service, int rc, bool reading, int value,\n bool norm, const std::vector<Capability>& normalized,\n const std::vector<int>& help)\n{\n std::cout << \"{\\\"rc\\\":\" << rc << \",\\\"read\\\":\";\n if (reading) std::cout << value; else std::cout << \"null\";\n std::cout << \",\\\"normalized\\\":\";\n if (norm) capabilities(normalized); else std::cout << \"null\";\n std::cout << \",\\\"help\\\":\";\n if (help.empty()) {\n std::cout << \"null\";\n } else {\n std::cout << '[';\n for (std::size_t i = 0; i < help.size(); ++i) {\n if (i) std::cout << ',';\n std::cout << help[i];\n }\n std::cout << ']';\n }\n std::cout << \",\\\"slots\\\":[\";\n for (std::size_t i = 0; i < service.slots().size(); ++i) {\n if (i) std::cout << ',';\n const auto& slot = service.slots()[i];\n std::cout << '[' << static_cast<int>(slot.phase) << ',' << slot.generation << ',';\n string_json(slot.name);\n std::cout << ',';\n capabilities(slot.capabilities);\n std::cout << \",[\";\n for (std::size_t j = 0; j < slot.values.size(); ++j) {\n if (j) std::cout << ',';\n std::cout << slot.values[j];\n }\n std::cout << \"],\";\n events(slot.pending);\n std::cout << ']';\n }\n const auto& c = service.counters();\n std::cout << \"],\\\"totals\\\":[\" << c.allocations << ',' << c.releases << ','\n << c.configurations << ',' << c.registrations << ',' << c.unregistrations\n << ',' << c.reports << ',' << c.frames << ',' << c.committed_events;\n std::cout << \"],\\\"ledger\\\":[\";\n bool comma = false;\n for (const auto& frame : service.ledger()) {\n if (comma) std::cout << ',';\n comma = true;\n std::cout << '[' << frame.serial << ',' << frame.slot << ',' << frame.generation << ',';\n events(frame.events);\n std::cout << ']';\n }\n std::cout << \"]}\\n\";\n}\nstatic bool parse_caps(const std::vector<int>& args, std::size_t begin,\n std::vector<Capability>& caps)\n{\n if (args.size() <= begin || args[begin] < 0 || args[begin] > 40) {\n return false;\n }\n std::size_t count = static_cast<std::size_t>(args[begin]);\n if (args.size() != begin + 1 + count * 4) {\n return false;\n }\n for (std::size_t i = 0; i < count; ++i) {\n std::size_t at = begin + 1 + i * 4;\n caps.push_back({args[at], args[at + 1], args[at + 2], args[at + 3]});\n }\n return true;\n}\nint main()\n{\n Service service;\n std::string line;\n while (std::getline(std::cin, line)) {\n auto tokens = words(line);\n int rc = -9;\n bool reading = false;\n bool norm = false;\n int value = 0;\n std::vector<Capability> normalized;\n std::vector<int> help;\n std::vector<int> args;\n bool parsed = line.size() <= 65536 && !tokens.empty();\n std::string command = tokens.empty() ? \"\" : tokens[0];\n if (parsed && command == \"A\") {\n int slot = 0;\n if (tokens.size() == 3 && number(tokens[1], slot)) {\n rc = service.allocate(slot, tokens[2]);\n }\n } else if (parsed && command == \"H\") {\n int slot = 0;\n if (tokens.size() == 7 && number(tokens[1], slot)) {\n parsed = true;\n for (std::size_t i = 3; i < tokens.size(); ++i) {\n int item;\n if (!number(tokens[i], item)) parsed = false;\n else args.push_back(item);\n }\n if (parsed) {\n Capability cap{args[0], args[1], args[2], args[3]};\n help = {panel::valid_slot(slot), panel::valid_name(tokens[2]),\n panel::capability_valid(cap), service.inspect(slot) != nullptr,\n service.capability(slot, cap.type, cap.code) != nullptr};\n rc = 0;\n }\n }\n } else if (parsed) {\n for (std::size_t i = 1; i < tokens.size(); ++i) {\n int item;\n if (!number(tokens[i], item)) parsed = false;\n else args.push_back(item);\n }\n if (parsed) {\n std::vector<Capability> caps;\n if (command == \"Z\" && args.empty()) {\n service.reset(); rc = 0;\n } else if (command == \"C\" && args.size() >= 2 && parse_caps(args, 1, caps)) {\n rc = service.replace_capabilities(args[0], caps);\n } else if (command == \"N\" && parse_caps(args, 0, caps)) {\n normalized.push_back({1,31,0,1});\n norm = true;\n rc = panel::normalize_capabilities(caps, normalized);\n } else if (command == \"B\" && args.size() == 2) {\n rc = service.attach(args[0], args[1]);\n } else if (command == \"D\" && args.size() == 1) {\n rc = service.detach(args[0]);\n } else if (command == \"X\" && args.size() == 1) {\n rc = service.release(args[0]);\n } else if (command == \"E\" && args.size() == 4) {\n rc = service.report(args[0], args[1], args[2], args[3]);\n } else if (command == \"S\" && args.size() == 1) {\n rc = service.sync(args[0]);\n } else if (command == \"R\" && args.size() == 3) {\n auto result = service.read(args[0], args[1], args[2]);\n rc = result.rc; value = result.value; reading = true;\n }\n }\n }\n observe(service, rc, reading, value, norm, normalized, help);\n }\n return 0;\n}\n"
|
|
},
|
|
"probe.cpp": "#define main panel_console_main\n#include \"input_console.cpp\"\n#undef main\nstatic void pointer_slot(int index, const panel::Slot* slot)\n{\n std::cout << \"{\\\"inspect\\\":\" << index << \",\\\"value\\\":\";\n if (!slot) {\n std::cout << \"null}\\n\";\n return;\n }\n std::cout << '[' << static_cast<int>(slot->phase) << ',' << slot->generation << ',';\n string_json(slot->name);\n std::cout << ',';\n capabilities(slot->capabilities);\n std::cout << \",[\";\n for (std::size_t i=0;i<slot->values.size();++i) {\n if (i) std::cout << ',';\n std::cout << slot->values[i];\n }\n std::cout << \"],\";\n events(slot->pending);\n std::cout << \"]}\\n\";\n}\nstatic void pointer_cap(int slot, int type, int code, const Capability* cap)\n{\n std::cout << \"{\\\"capability\\\":[\" << slot << ',' << type << ',' << code << \"],\\\"value\\\":\";\n if (cap) {\n std::cout << '[' << cap->type << ',' << cap->code << ',' << cap->lower << ',' << cap->upper << ']';\n } else {\n std::cout << \"null\";\n }\n std::cout << \"}\\n\";\n}\nint main()\n{\n Service s;\n std::vector<Capability> none;\n std::vector<int> help;\n auto out = [&](int rc) { observe(s, rc, false, 0, false, none, help); };\n out(s.allocate(0, \"\"));\n out(s.allocate(0, std::string(33, 'a')));\n out(s.allocate(0, std::string(1, char(255))));\n out(s.allocate(0, \"Direct_1\"));\n std::vector<Capability> caps{{3,7,-32768,32767},{1,31,0,1},{1,0,0,1}};\n int rc = panel::normalize_capabilities(caps, caps);\n observe(s, rc, false, 0, true, caps, help);\n caps.push_back({1,31,0,1});\n rc = panel::normalize_capabilities(caps, caps);\n observe(s, rc, false, 0, true, caps, help);\n out(s.replace_capabilities(0, {{1,31,0,1}}));\n out(s.attach(0,0));\n out(s.report(0,1,31,2));\n out(s.sync(0));\n out(s.release(0));\n out(s.allocate(0,\"Direct_2\"));\n out(s.replace_capabilities(0, {}));\n out(s.attach(0,0));\n out(s.sync(0));\n out(s.release(0));\n help = {panel::valid_name(\"\"), panel::valid_name(std::string(32,'a')),\n panel::valid_name(std::string(33,'a')), panel::valid_name(std::string(1,char(255))),\n panel::valid_name(\"-\")};\n observe(s, 0, false, 0, false, none, help);\n help.clear();\n out(s.allocate(3,\"Pointer\"));\n out(s.replace_capabilities(3, {{3,2,-9,9},{1,7,0,1}}));\n out(s.attach(3,0));\n out(s.report(3,1,7,1));\n for (int index=0;index<4;++index) pointer_slot(index,s.inspect(index));\n pointer_slot(-1,s.inspect(-1));\n pointer_slot(4,s.inspect(4));\n pointer_cap(3,3,2,s.capability(3,3,2));\n pointer_cap(3,1,7,s.capability(3,1,7));\n pointer_cap(3,1,31,s.capability(3,1,31));\n pointer_cap(0,3,2,s.capability(0,3,2));\n out(0);\n out(s.allocate(0,\"Other\"));\n out(s.replace_capabilities(0, {{3,1,5,5},{1,31,0,1}}));\n pointer_slot(0,s.inspect(0));\n pointer_cap(0,3,1,s.capability(0,3,1));\n pointer_cap(0,1,31,s.capability(0,1,31));\n out(s.attach(0,0));\n out(s.report(0,1,31,2));\n for (int index=0;index<4;++index) pointer_slot(index,s.inspect(index));\n pointer_cap(0,3,1,s.capability(0,3,1));\n pointer_cap(0,1,31,s.capability(0,1,31));\n pointer_cap(3,3,2,s.capability(3,3,2));\n pointer_cap(3,1,7,s.capability(3,1,7));\n pointer_cap(-1,1,31,s.capability(-1,1,31));\n out(0);\n out(s.release(3));\n pointer_slot(3,s.inspect(3));\n pointer_cap(3,3,2,s.capability(3,3,2));\n out(0);\n return 0;\n}\n"
|
|
}
|