amos 73a5240295 Batches 21 and 18: add 74 calibrated tasks (40 Bos redo, 34 HWE code-gen)
Batch 21 (20261027-A-bos-redo-21) rebuilt 40 of the 53 rejected Bos-qiao
environments: hidden assertions that ran inside the candidate's process
now run in a trusted parent that reads observations from a low-UID
worker; gold bytes are unchanged. 9 were excluded for scope (ROS2,
oversize, security core), 3 are blocked because the source requires an
exec bit the platform does not freeze, 1 lacks requests/bs4 in trace6.

Batch 18 (20261026-C-hwe-codegen-18) adds its last 34 of 134 tasks; the
first 100 landed in 2f32624d.

Claude reviewed 74/74 USABLE against current digests, canonical
families, no ID or source overlap with main, plain public docs. Only the
new task directories are taken; the stale pre-batch-20 copies of
concur-release-capsule and resource-temp-link on the batch 21 branch and
both branches' progress notes stay as main has them. Difficulty is
unmeasured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 10:23:12 +08:00

104 lines
2.5 KiB
C++

#ifndef BUFFER_IO_HPP
#define BUFFER_IO_HPP
#include <array>
#include <cstdint>
#include <istream>
#include <ostream>
#include <string>
#include <vector>
namespace bio {
using Number = std::int64_t;
enum class Code {
Ok = 0,
BadId = 1,
BadCapacity = 2,
BadByte = 3,
BadCount = 4,
BadStage = 5,
BadEnabled = 6,
Exists = 7,
Missing = 8,
WriteError = 9,
FlushError = 10,
CloseError = 11
};
struct View {
Code code = Code::Missing;
Number id = 0;
bool seen = false;
bool live = false;
Number capacity = 0;
std::string pending;
std::string durable;
std::string history;
Code last = Code::Ok;
std::array<bool, 3> faults{{false, false, false}};
Number writes = 0;
Number flushes = 0;
Number closes = 0;
};
struct Stats {
Number opened = 0;
Number live = 0;
Number closed = 0;
Number writes = 0;
Number flushes = 0;
Number closes = 0;
};
struct Device {
std::string data;
std::string history;
std::array<bool, 3> faults{{false, false, false}};
Number writes = 0;
Number flushes = 0;
Number closes = 0;
};
struct WriteResult {
Code code;
std::size_t consumed;
};
class Backend {
public:
WriteResult write(Device& device, const std::string& bytes);
Code flush(Device& device);
Code close(Device& device);
};
class Session {
public:
Session() = default;
Session(const Session&) = delete;
Session& operator=(const Session&) = delete;
Code open(Number id, Number capacity);
Code put(Number id, Number byte, Number count);
Code arm(Number id, Number stage, Number enabled);
Code flush(Number id);
Code close(Number id);
View view(Number id) const;
Stats stats() const;
private:
struct Stream {
bool seen = false;
bool live = false;
Number capacity = 0;
std::string pending;
Code last = Code::Ok;
Device device;
};
std::array<Stream, 4> streams_{};
Stats totals_{};
Backend backend_;
bool valid_id(Number id) const;
Stream& stream(Number id);
const Stream& stream(Number id) const;
Code drain(Stream& value);
Code flush_stream(Stream& value);
};
std::string code_name(Code code);
std::string decimal(Number value);
std::string hexadecimal(const std::string& bytes);
std::string format_view(const View& value);
std::string format_stats(const Stats& value);
int run_cli(Session& session, std::istream& input, std::ostream& output);
}
#endif