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>
87 lines
2.0 KiB
C++
87 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <map>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace probe {
|
|
|
|
enum class Fault { none, acquire, send, receive };
|
|
enum class Status { ok, unavailable, send_error, receive_error };
|
|
|
|
struct Request {
|
|
unsigned id;
|
|
Fault fault;
|
|
std::string token;
|
|
};
|
|
|
|
struct Result {
|
|
Status status;
|
|
std::string reply;
|
|
};
|
|
|
|
struct Observation {
|
|
unsigned id;
|
|
unsigned opened;
|
|
unsigned closed;
|
|
unsigned live;
|
|
std::string events;
|
|
std::string sent;
|
|
std::string received;
|
|
};
|
|
|
|
class EndpointError : public std::runtime_error {
|
|
public:
|
|
explicit EndpointError(const std::string& message);
|
|
};
|
|
|
|
class Port {
|
|
public:
|
|
explicit Port(Request request);
|
|
int acquire();
|
|
void send(int handle, const std::string& bytes);
|
|
std::string receive(int handle);
|
|
void close(int handle);
|
|
Observation observation() const;
|
|
bool owns(int handle) const;
|
|
|
|
private:
|
|
struct HandleState {
|
|
bool open = false;
|
|
bool sent = false;
|
|
bool received = false;
|
|
unsigned sequence = 0;
|
|
std::string outgoing;
|
|
std::string incoming;
|
|
};
|
|
|
|
Request request_;
|
|
unsigned opened_ = 0;
|
|
unsigned closed_ = 0;
|
|
unsigned sequence_ = 0;
|
|
std::string events_;
|
|
std::string sent_;
|
|
std::string received_;
|
|
std::map<int, HandleState> handles_;
|
|
|
|
HandleState& require_open(int handle);
|
|
const HandleState& require_open(int handle) const;
|
|
void record(char code);
|
|
int next_handle();
|
|
std::string make_reply(const std::string& payload) const;
|
|
};
|
|
|
|
Result run_probe(Port& port, const Request& request);
|
|
Fault parse_fault(char code);
|
|
char fault_code(Fault fault);
|
|
std::string status_name(Status status);
|
|
std::string hex_encode(const std::string& bytes);
|
|
std::string hex_decode(const std::string& text);
|
|
std::vector<Request> read_requests(const std::string& input);
|
|
std::string render_result(const Request& request, const Result& result,
|
|
const Observation& observation);
|
|
|
|
} // namespace probe
|