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>
9 lines
15 KiB
JSON
9 lines
15 KiB
JSON
{
|
|
"command.hpp": "#ifndef COMMAND_HPP\n#define COMMAND_HPP\n#include \"lifecycle.hpp\"\nnamespace replay {\nenum class Operation { Reset, Configure, Activate, Deactivate, Cleanup, Tick, Query };\nstruct Command {\n Operation operation=Operation::Query;\n int slot=0;\n int value=0;\n int capacity=8;\n Profile profile;\n};\nbool decode(const std::string& line,Command& command);\n}\n#endif\n",
|
|
"observer.cpp": "#include \"lifecycle.hpp\"\n#include <sstream>\nnamespace replay {\nnamespace {\nclass JsonWriter {\npublic:\n void begin() {\n separator();\n stream_<<'[';\n first_.push_back(true);\n }\n void end() {\n stream_<<']';\n first_.pop_back();\n }\n void number(std::int64_t value) {\n separator();\n stream_<<value;\n }\n void boolean(bool value) {\n separator();\n stream_<<(value?\"true\":\"false\");\n }\n std::string finish() const {\n return stream_.str();\n }\nprivate:\n void separator() {\n if (first_.empty()) return;\n if (!first_.back()) stream_<<',';\n first_.back()=false;\n }\n std::ostringstream stream_;\n std::vector<bool> first_;\n};\nvoid profile_json(JsonWriter& writer,const Profile& profile) {\n writer.begin();\n for (int field:profile.fields()) writer.number(field);\n writer.end();\n}\nvoid node_json(JsonWriter& writer,const NodeView& node) {\n writer.begin();\n writer.number(static_cast<int>(node.state));\n writer.boolean(node.ready);\n writer.number(static_cast<std::int64_t>(node.generation));\n writer.number(static_cast<std::int64_t>(node.configured));\n writer.number(static_cast<std::int64_t>(node.rejected));\n writer.begin();\n for (int handle:node.channels) writer.number(handle);\n writer.end();\n writer.number(node.recorder);\n profile_json(writer,node.profile);\n writer.number(static_cast<std::int64_t>(node.samples));\n writer.number(node.total);\n writer.number(node.checksum);\n writer.end();\n}\nvoid resource_json(JsonWriter& writer,const Resource& resource) {\n writer.begin();\n writer.number(resource.handle);\n writer.number(resource.owner);\n writer.number(resource.kind);\n writer.end();\n}\nvoid port_json(JsonWriter& writer,const PortView& port) {\n writer.begin();\n writer.number(port.capacity);\n writer.number(port.next_handle);\n writer.number(port.attempts);\n writer.number(port.opened);\n writer.number(port.closed);\n writer.number(port.primed);\n writer.number(port.reads);\n writer.number(port.writes);\n writer.number(port.record_total);\n writer.number(port.invalid);\n writer.begin();\n for (const Resource& resource:port.resources) resource_json(writer,resource);\n writer.end();\n writer.end();\n}\n}\nstd::string observe(Result rc,const System& system) {\n JsonWriter writer;\n writer.begin();\n writer.number(static_cast<int>(rc));\n writer.begin();\n for (int slot=0;slot<3;++slot) node_json(writer,system.node(slot));\n writer.end();\n port_json(writer,system.port());\n writer.end();\n return writer.finish();\n}\n}\n",
|
|
"lifecycle.hpp": "#ifndef LIFECYCLE_HPP\n#define LIFECYCLE_HPP\n#include <array>\n#include <cstdint>\n#include <map>\n#include <string>\n#include <vector>\nnamespace replay {\nenum class State { Unconfigured=0, Inactive=1, Active=2 };\nenum class Result { Ok=0, Rejected=1, InvalidProfile=2, BadState=3 };\nenum class Callback { Success=0, Failure=1 };\nstruct Profile {\n int channels=0;\n int recorder=0;\n int rate=0;\n int seed=0;\n int fail_at=0;\n bool valid() const;\n std::array<int,5> fields() const;\n};\nstruct Resource {\n int handle=0;\n int owner=0;\n int kind=0;\n};\nstruct PortView {\n int capacity=0;\n int next_handle=1;\n std::int64_t attempts=0;\n std::int64_t opened=0;\n std::int64_t closed=0;\n std::int64_t primed=0;\n std::int64_t reads=0;\n std::int64_t writes=0;\n std::int64_t record_total=0;\n std::int64_t invalid=0;\n std::vector<Resource> resources;\n};\nclass DevicePort {\npublic:\n explicit DevicePort(int capacity);\n void begin_attempt(int fail_at);\n int open(int owner,int kind);\n bool prime();\n void close(int owner,int handle);\n std::int64_t read(int owner,int handle,int channel,int value,const Profile& profile);\n void write(int owner,int handle,std::int64_t value);\n PortView view() const;\n bool contains(int owner,int handle,int kind) const;\n int available() const;\nprivate:\n bool step_failed();\n int capacity_;\n int next_handle_=1;\n int current_step_=0;\n int fail_at_=0;\n std::int64_t attempts_=0;\n std::int64_t opened_=0;\n std::int64_t closed_=0;\n std::int64_t primed_=0;\n std::int64_t reads_=0;\n std::int64_t writes_=0;\n std::int64_t record_total_=0;\n std::int64_t invalid_=0;\n std::map<int,Resource> resources_;\n};\nstruct NodeView {\n State state=State::Unconfigured;\n bool ready=false;\n std::uint64_t generation=0;\n std::uint64_t configured=0;\n std::uint64_t rejected=0;\n std::vector<int> channels;\n int recorder=-1;\n Profile profile;\n std::uint64_t samples=0;\n std::int64_t total=0;\n std::int64_t checksum=0;\n};\nclass Node {\npublic:\n explicit Node(int owner);\n Result configure(DevicePort& port,const Profile& profile);\n Result activate();\n Result deactivate();\n Result cleanup(DevicePort& port);\n Result tick(DevicePort& port,int value);\n NodeView view() const;\nprivate:\n Callback on_configure(DevicePort& port,const Profile& profile);\n void rollback(DevicePort& port,std::vector<int>& staged,int recorder);\n void clear_configuration();\n std::int64_t initial_checksum(const Profile& profile) const;\n int owner_;\n NodeView data_;\n};\nclass System {\npublic:\n explicit System(int capacity=8);\n Result configure(int slot,const Profile& profile);\n Result activate(int slot);\n Result deactivate(int slot);\n Result cleanup(int slot);\n Result tick(int slot,int value);\n NodeView node(int slot) const;\n PortView port() const;\nprivate:\n DevicePort port_;\n std::array<Node,3> nodes_;\n};\nstd::string observe(Result rc,const System& system);\n}\n#endif\n",
|
|
"command.cpp": "#include \"command.hpp\"\n#include <stdexcept>\nnamespace replay {\nnamespace {\nbool delimiter(char byte) {\n return byte==' ' || byte=='\\t' || byte=='\\r';\n}\nstd::vector<std::string> tokenize(const std::string& line) {\n std::vector<std::string> result;\n std::size_t index=0;\n while (index<line.size()) {\n while (index<line.size() && delimiter(line[index])) ++index;\n if (index==line.size()) break;\n std::size_t start=index;\n while (index<line.size() && !delimiter(line[index])) ++index;\n result.emplace_back(line.substr(start,index-start));\n }\n return result;\n}\nint number(const std::string& token,int lower,int upper) {\n std::size_t index=0;\n bool minus=false;\n if (!token.empty() && (token[0]=='+' || token[0]=='-')) {\n minus=token[0]=='-';\n index=1;\n }\n if (index==token.size()) throw std::invalid_argument(\"empty decimal\");\n int magnitude=0;\n for (;index<token.size();++index) {\n char byte=token[index];\n if (byte<'0' || byte>'9') throw std::invalid_argument(\"ASCII decimal required\");\n int digit=byte-'0';\n if (magnitude>(1000000-digit)/10) throw std::out_of_range(\"decimal magnitude\");\n magnitude=magnitude*10+digit;\n }\n int value=minus?-magnitude:magnitude;\n if (value<lower || value>upper) throw std::out_of_range(\"input domain\");\n return value;\n}\nvoid count(const std::vector<std::string>& tokens,std::size_t expected) {\n if (tokens.size()!=expected) throw std::invalid_argument(\"argument count\");\n}\nint slot(const std::vector<std::string>& tokens) {\n return number(tokens.at(1),0,2);\n}\nProfile profile(const std::vector<std::string>& tokens) {\n Profile value;\n value.channels=number(tokens.at(2),-1,6);\n value.recorder=number(tokens.at(3),-1,2);\n value.rate=number(tokens.at(4),-1,1001);\n value.seed=number(tokens.at(5),-1,65536);\n value.fail_at=number(tokens.at(6),-1,9);\n return value;\n}\nCommand reset(const std::vector<std::string>& tokens) {\n count(tokens,2);\n Command result;\n result.operation=Operation::Reset;\n result.capacity=number(tokens[1],1,16);\n return result;\n}\nCommand configure(const std::vector<std::string>& tokens) {\n count(tokens,7);\n Command result;\n result.operation=Operation::Configure;\n result.slot=slot(tokens);\n result.profile=profile(tokens);\n return result;\n}\nCommand unary(const std::vector<std::string>& tokens,Operation operation) {\n count(tokens,2);\n Command result;\n result.operation=operation;\n result.slot=slot(tokens);\n return result;\n}\nCommand tick(const std::vector<std::string>& tokens) {\n count(tokens,3);\n Command result;\n result.operation=Operation::Tick;\n result.slot=slot(tokens);\n result.value=number(tokens[2],-1000000,1000000);\n return result;\n}\n}\nbool decode(const std::string& line,Command& command) {\n std::vector<std::string> tokens=tokenize(line);\n if (tokens.empty()) return false;\n const std::string& name=tokens[0];\n if (name==\"R\") command=reset(tokens);\n else if (name==\"C\") command=configure(tokens);\n else if (name==\"A\") command=unary(tokens,Operation::Activate);\n else if (name==\"D\") command=unary(tokens,Operation::Deactivate);\n else if (name==\"X\") command=unary(tokens,Operation::Cleanup);\n else if (name==\"T\") command=tick(tokens);\n else if (name==\"Q\") {\n count(tokens,1);\n command=Command{};\n } else throw std::invalid_argument(\"unknown command\");\n return true;\n}\n}\n",
|
|
"console.cpp": "#include \"command.hpp\"\n#include <iostream>\n#include <memory>\nnamespace {\nclass Console {\npublic:\n Console():system_(new replay::System(8)) {}\n replay::Result execute(const replay::Command& command) {\n switch (command.operation) {\n case replay::Operation::Reset:\n system_.reset(new replay::System(command.capacity));\n return replay::Result::Ok;\n case replay::Operation::Configure:\n return system_->configure(command.slot,command.profile);\n case replay::Operation::Activate:\n return system_->activate(command.slot);\n case replay::Operation::Deactivate:\n return system_->deactivate(command.slot);\n case replay::Operation::Cleanup:\n return system_->cleanup(command.slot);\n case replay::Operation::Tick:\n return system_->tick(command.slot,command.value);\n case replay::Operation::Query:\n return replay::Result::Ok;\n }\n throw std::logic_error(\"operation\");\n }\n std::string observation(replay::Result rc) const {\n return replay::observe(rc,*system_);\n }\nprivate:\n std::unique_ptr<replay::System> system_;\n};\n}\nint main() {\n Console console;\n std::string line;\n try {\n while (std::getline(std::cin,line)) {\n replay::Command command;\n if (!replay::decode(line,command)) continue;\n replay::Result rc=console.execute(command);\n std::cout<<console.observation(rc)<<'\\n';\n }\n } catch (const std::exception& error) {\n std::cerr<<\"input error: \"<<error.what()<<'\\n';\n return 2;\n }\n return 0;\n}\n",
|
|
"port.cpp": "#include \"lifecycle.hpp\"\n#include <algorithm>\nnamespace replay {\nbool Profile::valid() const {\n if (channels<1 || channels>4) return false;\n if (recorder!=0 && recorder!=1) return false;\n if (rate<1 || rate>1000) return false;\n if (seed<0 || seed>65535) return false;\n if (fail_at<0 || fail_at>channels+recorder+1) return false;\n return true;\n}\nstd::array<int,5> Profile::fields() const {\n return {{channels,recorder,rate,seed,fail_at}};\n}\nDevicePort::DevicePort(int capacity):capacity_(capacity) {}\nvoid DevicePort::begin_attempt(int fail_at) {\n current_step_=0;\n fail_at_=fail_at;\n}\nbool DevicePort::step_failed() {\n ++attempts_;\n ++current_step_;\n return fail_at_!=0 && current_step_==fail_at_;\n}\nint DevicePort::open(int owner,int kind) {\n bool failed=step_failed();\n if (failed) return -1;\n if (available()==0) return -1;\n Resource resource;\n resource.handle=next_handle_;\n resource.owner=owner;\n resource.kind=kind;\n resources_.emplace(next_handle_,resource);\n ++next_handle_;\n ++opened_;\n return resource.handle;\n}\nbool DevicePort::prime() {\n ++primed_;\n return !step_failed();\n}\nvoid DevicePort::close(int owner,int handle) {\n auto entry=resources_.find(handle);\n if (entry==resources_.end()) {\n ++invalid_;\n return;\n }\n if (entry->second.owner!=owner) {\n ++invalid_;\n return;\n }\n resources_.erase(entry);\n ++closed_;\n}\nbool DevicePort::contains(int owner,int handle,int kind) const {\n auto entry=resources_.find(handle);\n if (entry==resources_.end()) return false;\n if (entry->second.owner!=owner) return false;\n return entry->second.kind==kind;\n}\nstd::int64_t DevicePort::read(int owner,int handle,int channel,int value,const Profile& profile) {\n if (!contains(owner,handle,channel)) {\n ++invalid_;\n return 0;\n }\n ++reads_;\n std::int64_t weighted=static_cast<std::int64_t>(value)*(channel+1);\n std::int64_t baseline=profile.seed;\n baseline+=profile.rate;\n baseline+=handle;\n return weighted+baseline;\n}\nvoid DevicePort::write(int owner,int handle,std::int64_t value) {\n if (!contains(owner,handle,10)) {\n ++invalid_;\n return;\n }\n ++writes_;\n record_total_+=value;\n}\nint DevicePort::available() const {\n return capacity_-static_cast<int>(resources_.size());\n}\nPortView DevicePort::view() const {\n PortView result;\n result.capacity=capacity_;\n result.next_handle=next_handle_;\n result.attempts=attempts_;\n result.opened=opened_;\n result.closed=closed_;\n result.primed=primed_;\n result.reads=reads_;\n result.writes=writes_;\n result.record_total=record_total_;\n result.invalid=invalid_;\n result.resources.reserve(resources_.size());\n for (const auto& entry:resources_) result.resources.push_back(entry.second);\n return result;\n}\nSystem::System(int capacity):port_(capacity),nodes_{{Node(0),Node(1),Node(2)}} {}\nResult System::configure(int slot,const Profile& profile) {\n return nodes_.at(static_cast<std::size_t>(slot)).configure(port_,profile);\n}\nResult System::activate(int slot) {\n return nodes_.at(static_cast<std::size_t>(slot)).activate();\n}\nResult System::deactivate(int slot) {\n return nodes_.at(static_cast<std::size_t>(slot)).deactivate();\n}\nResult System::cleanup(int slot) {\n return nodes_.at(static_cast<std::size_t>(slot)).cleanup(port_);\n}\nResult System::tick(int slot,int value) {\n return nodes_.at(static_cast<std::size_t>(slot)).tick(port_,value);\n}\nNodeView System::node(int slot) const {\n return nodes_.at(static_cast<std::size_t>(slot)).view();\n}\nPortView System::port() const {\n return port_.view();\n}\n}\n"
|
|
}
|