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>
164 lines
4.2 KiB
C++
164 lines
4.2 KiB
C++
#include "request.hpp"
|
|
|
|
#include <sstream>
|
|
|
|
namespace remaining {
|
|
|
|
namespace {
|
|
|
|
std::string response(const std::string &opcode, int result)
|
|
{
|
|
return opcode + " " + std::to_string(result);
|
|
}
|
|
|
|
bool command_id(const std::vector<std::string> &words, int &id)
|
|
{
|
|
return words.size() == 2 && parse_signed(words[1], id);
|
|
}
|
|
|
|
bool command_priority(const std::vector<std::string> &words, int &id, int &priority)
|
|
{
|
|
return words.size() == 3 && parse_signed(words[1], id) &&
|
|
parse_signed(words[2], priority);
|
|
}
|
|
|
|
bool command_duration(const std::vector<std::string> &words,
|
|
int &id, std::uint64_t &duration, int &priority)
|
|
{
|
|
return words.size() == 4 && parse_signed(words[1], id) &&
|
|
parse_duration(words[2], duration) && parse_signed(words[3], priority);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
Console::Console(Manager &manager) : manager_(manager)
|
|
{
|
|
}
|
|
|
|
bool Console::execute(const std::string &line, std::string &output)
|
|
{
|
|
const auto words = split_words(line);
|
|
if (words.empty() || words[0].front() == '#') {
|
|
output.clear();
|
|
return true;
|
|
}
|
|
return dispatch(words, output);
|
|
}
|
|
|
|
bool Console::dispatch(const std::vector<std::string> &words, std::string &output)
|
|
{
|
|
const std::string &op = words[0];
|
|
int id = 0;
|
|
int priority = 0;
|
|
std::uint64_t duration = 0;
|
|
if (op == "A") {
|
|
if (!command_duration(words, id, duration, priority)) {
|
|
return false;
|
|
}
|
|
output = response("A", manager_.add(id, duration, priority));
|
|
return true;
|
|
}
|
|
if (op == "M") {
|
|
if (!command_duration(words, id, duration, priority)) {
|
|
return false;
|
|
}
|
|
output = response("M", manager_.amend(id, duration, priority));
|
|
return true;
|
|
}
|
|
if (op == "D") {
|
|
int new_id = 0;
|
|
if (!command_priority(words, id, new_id)) {
|
|
return false;
|
|
}
|
|
output = response("D", manager_.duplicate(id, new_id));
|
|
return true;
|
|
}
|
|
if (op == "T") {
|
|
if (!command_priority(words, id, priority)) {
|
|
return false;
|
|
}
|
|
output = response("T", manager_.reprioritize(id, priority));
|
|
return true;
|
|
}
|
|
if (op == "C") {
|
|
if (!command_id(words, id)) {
|
|
return false;
|
|
}
|
|
output = response("C", manager_.cancel(id));
|
|
return true;
|
|
}
|
|
if (op == "R") {
|
|
if (!command_id(words, id)) {
|
|
return false;
|
|
}
|
|
output = response("R", manager_.run(id));
|
|
return true;
|
|
}
|
|
if (op == "Q") {
|
|
if (!command_id(words, id)) {
|
|
return false;
|
|
}
|
|
Request request{};
|
|
const int result = manager_.query(id, request);
|
|
output = result == 0 ? "Q 0 " + format_request(request) : response("Q", result);
|
|
return true;
|
|
}
|
|
if (op == "N") {
|
|
if (words.size() != 1) {
|
|
return false;
|
|
}
|
|
int selected = -1;
|
|
const int result = manager_.run_next(selected);
|
|
output = "N " + std::to_string(selected) + " " + std::to_string(result);
|
|
return true;
|
|
}
|
|
if (op == "B") {
|
|
if (words.size() != 1) {
|
|
return false;
|
|
}
|
|
unsigned count = 0;
|
|
const int result = manager_.run_batch(count);
|
|
output = "B " + std::to_string(count) + " " + std::to_string(result);
|
|
return true;
|
|
}
|
|
if (op == "L") {
|
|
if (words.size() != 1) {
|
|
return false;
|
|
}
|
|
output = "L " + format_list(manager_.list());
|
|
return true;
|
|
}
|
|
if (op == "O") {
|
|
if (words.size() != 1) {
|
|
return false;
|
|
}
|
|
output = "O " + format_order(manager_.pending_order());
|
|
return true;
|
|
}
|
|
if (op == "S") {
|
|
if (words.size() != 1) {
|
|
return false;
|
|
}
|
|
output = "S " + format_totals(manager_.totals());
|
|
return true;
|
|
}
|
|
if (op == "P") {
|
|
if (words.size() != 1) {
|
|
return false;
|
|
}
|
|
output = "P " + std::to_string(manager_.purge());
|
|
return true;
|
|
}
|
|
if (op == "Z") {
|
|
if (words.size() != 1) {
|
|
return false;
|
|
}
|
|
manager_.reset();
|
|
output = "Z 0";
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace remaining
|