Batch 24 (20261102-C-bos-seed-24) screened all 3078 Bos seed queries. Only 23 themes were in scope (pure user-space reliability, at most one task per theme); the rest were single operations or explanations, installs and networking, system administration, ROS2, board-only or GUI requests. Two finished drafts were withdrawn as too close to existing tasks. Seeds supply direction only: all sources, contracts and tests are new, and no task shares more than 14 characters with its seed text. Each task passed the local gate and the trace6 Docker gate (5 runs per sample class). Claude rebuilt the catalog from the calibration receipts: 23/23 USABLE. 16 of 23 are C/C++. Only the task directories are taken; the batch worktree's lowered disk floor in rollout/core.py stays out of main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
150 lines
3.8 KiB
C++
150 lines
3.8 KiB
C++
#include "command.hpp"
|
|
#include "link.hpp"
|
|
|
|
#include <iostream>
|
|
#include <limits>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace carrier {
|
|
|
|
class Console {
|
|
public:
|
|
Console(std::istream& input, std::ostream& output)
|
|
: input_(input), output_(output), controller_(backend_) {}
|
|
|
|
int run()
|
|
{
|
|
std::string line;
|
|
while (std::getline(input_, line)) {
|
|
process(line);
|
|
}
|
|
return input_.bad() ? 1 : 0;
|
|
}
|
|
|
|
private:
|
|
std::istream& input_;
|
|
std::ostream& output_;
|
|
Backend backend_;
|
|
Controller controller_;
|
|
CommandReader reader_;
|
|
std::size_t next_request_ = 0;
|
|
|
|
void process(const std::string& line)
|
|
{
|
|
const Command command = reader_.parse(line);
|
|
const bool accepted = dispatch(command);
|
|
emit_result(accepted);
|
|
emit_clock();
|
|
emit_ports();
|
|
emit_requests();
|
|
if (command.kind == CommandKind::history && accepted) emit_history();
|
|
output_ << "END\n";
|
|
}
|
|
|
|
bool dispatch(const Command& command)
|
|
{
|
|
switch (command.kind) {
|
|
case CommandKind::enable:
|
|
return controller_.enable(command.port);
|
|
case CommandKind::disable:
|
|
return controller_.disable(command.port);
|
|
case CommandKind::up:
|
|
return controller_.carrier_up(command.port);
|
|
case CommandKind::down:
|
|
return controller_.carrier_down(command.port);
|
|
case CommandKind::complete:
|
|
return controller_.complete(command.port, command.value);
|
|
case CommandKind::fail:
|
|
return controller_.fail(command.port, command.value);
|
|
case CommandKind::advance:
|
|
return controller_.advance(command.value);
|
|
case CommandKind::query:
|
|
return query(command.port);
|
|
case CommandKind::history:
|
|
return true;
|
|
case CommandKind::reset_log:
|
|
return reset_log();
|
|
case CommandKind::invalid:
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool query(unsigned port) const
|
|
{
|
|
Status status{};
|
|
return controller_.status(port, status);
|
|
}
|
|
|
|
bool reset_log()
|
|
{
|
|
backend_.clear();
|
|
next_request_ = 0;
|
|
return true;
|
|
}
|
|
|
|
void emit_result(bool accepted)
|
|
{
|
|
output_ << "RESULT " << (accepted ? 1 : 0) << '\n';
|
|
}
|
|
|
|
void emit_clock()
|
|
{
|
|
output_ << "CLOCK " << controller_.now() << '\n';
|
|
}
|
|
|
|
void emit_port(unsigned port)
|
|
{
|
|
Status status{};
|
|
if (!controller_.status(port, status)) return;
|
|
output_ << "PORT " << port << ' ';
|
|
output_ << (status.enabled ? 1 : 0) << ' ';
|
|
output_ << (status.carrier ? 1 : 0) << ' ';
|
|
output_ << phase_name(status.phase) << ' ';
|
|
output_ << status.generation << ' ';
|
|
output_ << status.failures << ' ';
|
|
output_ << status.due << '\n';
|
|
}
|
|
|
|
void emit_ports()
|
|
{
|
|
for (unsigned port = 0; port < 2; ++port) {
|
|
emit_port(port);
|
|
}
|
|
}
|
|
|
|
void emit_request(const Request& request)
|
|
{
|
|
output_ << "REQUEST " << request.verb << ' ';
|
|
output_ << request.port << ' ';
|
|
output_ << request.generation << '\n';
|
|
}
|
|
|
|
void emit_requests()
|
|
{
|
|
const auto& requests = backend_.requests();
|
|
while (next_request_ < requests.size()) {
|
|
emit_request(requests[next_request_]);
|
|
++next_request_;
|
|
}
|
|
}
|
|
|
|
void emit_history()
|
|
{
|
|
for (const auto& request : backend_.requests()) {
|
|
output_ << "STORED " << request.verb << ' ';
|
|
output_ << request.port << ' ';
|
|
output_ << request.generation << '\n';
|
|
}
|
|
}
|
|
};
|
|
|
|
} // namespace carrier
|
|
|
|
int main()
|
|
{
|
|
carrier::Console console(std::cin, std::cout);
|
|
return console.run();
|
|
}
|