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>
104 lines
2.5 KiB
C++
104 lines
2.5 KiB
C++
#ifndef LINE_PROTOCOL_HPP
|
|
#define LINE_PROTOCOL_HPP
|
|
|
|
#include "level_port.hpp"
|
|
|
|
#include <cstddef>
|
|
#include <istream>
|
|
#include <ostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace levels {
|
|
|
|
enum class Verb { take, drop, chain, release_all, view, port, count, snapshot, inspect, feasibility, release_preview, gate, journal, reset, invalid };
|
|
|
|
struct Command {
|
|
Verb verb = Verb::invalid;
|
|
int first = 0;
|
|
int second = 0;
|
|
std::vector<int> chain;
|
|
std::size_t line = 0;
|
|
};
|
|
|
|
struct ParseError {
|
|
std::size_t line = 0;
|
|
std::string reason;
|
|
};
|
|
|
|
class ScriptReader {
|
|
public:
|
|
explicit ScriptReader(std::istream &source);
|
|
bool next(Command &command, ParseError &error);
|
|
bool done() const;
|
|
|
|
private:
|
|
bool parse(const std::string &line, Command &command, ParseError &error) const;
|
|
std::istream &source_;
|
|
std::size_t line_ = 0;
|
|
bool done_ = false;
|
|
};
|
|
|
|
class TraceWriter {
|
|
public:
|
|
explicit TraceWriter(std::ostream &sink);
|
|
void status(int value);
|
|
void owner(const OwnerView &view);
|
|
void port(int lock, int owner);
|
|
void count(int value);
|
|
void snapshot(const Manager &manager);
|
|
void inspect(const Manager &manager);
|
|
void feasibility(int owner, const Manager &manager);
|
|
void release_preview(int owner, const Manager &manager);
|
|
void gate(int owner, const Manager &manager);
|
|
void journal(std::size_t attempts, std::size_t successes,
|
|
std::size_t failures, std::size_t reads, std::size_t resets);
|
|
void reset();
|
|
|
|
private:
|
|
std::ostream &sink_;
|
|
};
|
|
|
|
class Dispatcher {
|
|
public:
|
|
explicit Dispatcher(std::ostream &sink);
|
|
void execute(const Command &command);
|
|
const Manager &manager() const;
|
|
|
|
private:
|
|
void record_action(int status);
|
|
void record_read();
|
|
Manager manager_;
|
|
TraceWriter trace_;
|
|
std::size_t attempts_ = 0;
|
|
std::size_t successes_ = 0;
|
|
std::size_t failures_ = 0;
|
|
std::size_t reads_ = 0;
|
|
std::size_t resets_ = 0;
|
|
};
|
|
|
|
struct Inspection {
|
|
int occupied = 0;
|
|
int mismatches = 0;
|
|
int inversions = 0;
|
|
int duplicates = 0;
|
|
std::array<unsigned, kOwners> masks{};
|
|
};
|
|
|
|
Inspection inspect_state(const Manager &manager);
|
|
|
|
struct Feasibility {
|
|
int owner = 0;
|
|
std::array<int, kLocks> results{};
|
|
int eligible_count = 0;
|
|
int first_eligible = -1;
|
|
};
|
|
|
|
Feasibility inspect_feasibility(int owner, const Manager &manager);
|
|
std::array<int, kLocks> inspect_release(int owner, const Manager &manager);
|
|
|
|
int run_script(std::istream &source, std::ostream &sink, std::ostream &errors);
|
|
|
|
} // namespace levels
|
|
#endif
|