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.4 KiB
C++
104 lines
2.4 KiB
C++
#ifndef EXCEPTION_READER_HPP
|
|
#define EXCEPTION_READER_HPP
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace exception_reader {
|
|
|
|
struct Missing : std::runtime_error {
|
|
Missing() : std::runtime_error("missing file") {}
|
|
};
|
|
struct Exhausted : std::runtime_error {
|
|
Exhausted() : std::runtime_error("handle table full") {}
|
|
};
|
|
struct ReadFault : std::runtime_error {
|
|
ReadFault() : std::runtime_error("injected read fault") {}
|
|
};
|
|
struct BadHandle : std::runtime_error {
|
|
BadHandle() : std::runtime_error("bad handle") {}
|
|
};
|
|
|
|
struct Event {
|
|
char kind;
|
|
int handle;
|
|
std::size_t amount;
|
|
};
|
|
|
|
class Store {
|
|
public:
|
|
explicit Store(std::size_t capacity);
|
|
void put(const std::string &name, const std::string &bytes);
|
|
void append(const std::string &name, const std::string &bytes);
|
|
bool contains(const std::string &name) const;
|
|
std::size_t file_size(const std::string &name) const;
|
|
int open(const std::string &name);
|
|
int clone(int handle);
|
|
std::string read(int handle, std::size_t limit, long long fault_after);
|
|
void close(int handle);
|
|
void seek(int handle, std::size_t offset);
|
|
std::size_t position(int handle) const;
|
|
std::size_t remaining(int handle) const;
|
|
std::size_t live() const;
|
|
std::vector<Event> events() const;
|
|
std::size_t event_count() const;
|
|
|
|
private:
|
|
struct Cursor {
|
|
std::string name;
|
|
std::size_t offset;
|
|
};
|
|
std::size_t capacity_;
|
|
std::map<std::string, std::string> files_;
|
|
std::map<int, Cursor> cursors_;
|
|
std::vector<Event> events_;
|
|
};
|
|
|
|
struct Request {
|
|
std::string primary_path;
|
|
std::string index_path;
|
|
bool with_index;
|
|
std::size_t chunk;
|
|
long long fault_after;
|
|
};
|
|
|
|
enum class Status {
|
|
OK,
|
|
BAD_REQUEST,
|
|
READ_ERROR,
|
|
INDEX_ERROR,
|
|
MISSING,
|
|
EXHAUSTED
|
|
};
|
|
|
|
const char *status_name(Status value);
|
|
|
|
struct Result {
|
|
Status status = Status::OK;
|
|
std::size_t lines = 0;
|
|
std::size_t bytes = 0;
|
|
std::size_t longest = 0;
|
|
std::uint32_t digest = 2166136261u;
|
|
long long index_value = -1;
|
|
std::size_t opened = 0;
|
|
std::size_t closed = 0;
|
|
std::size_t live = 0;
|
|
};
|
|
|
|
class Reader {
|
|
public:
|
|
explicit Reader(Store &store);
|
|
Result run(const Request &request);
|
|
Result run_unchecked(const Request &request);
|
|
|
|
private:
|
|
Store &store_;
|
|
};
|
|
|
|
}
|
|
#endif
|