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>
153 lines
4.0 KiB
C++
153 lines
4.0 KiB
C++
#include "io.hpp"
|
|
namespace bio {
|
|
bool Session::valid_id(Number id) const {
|
|
return id >= 0 && id <= 3;
|
|
}
|
|
Session::Stream& Session::stream(Number id) {
|
|
return streams_[static_cast<std::size_t>(id)];
|
|
}
|
|
const Session::Stream& Session::stream(Number id) const {
|
|
return streams_[static_cast<std::size_t>(id)];
|
|
}
|
|
Code Session::open(Number id, Number capacity) {
|
|
if (!valid_id(id)) {
|
|
return Code::BadId;
|
|
}
|
|
if (capacity < 1 || capacity > 8) {
|
|
return Code::BadCapacity;
|
|
}
|
|
if (stream(id).live) {
|
|
return Code::Exists;
|
|
}
|
|
Stream fresh;
|
|
fresh.seen = true;
|
|
fresh.live = true;
|
|
fresh.capacity = capacity;
|
|
stream(id) = fresh;
|
|
++totals_.opened;
|
|
++totals_.live;
|
|
return Code::Ok;
|
|
}
|
|
Code Session::drain(Stream& value) {
|
|
while (!value.pending.empty()) {
|
|
const WriteResult result = backend_.write(value.device, value.pending);
|
|
++totals_.writes;
|
|
if (result.code != Code::Ok) {
|
|
return result.code;
|
|
}
|
|
value.pending.erase(0, result.consumed);
|
|
}
|
|
return Code::Ok;
|
|
}
|
|
Code Session::put(Number id, Number byte, Number count) {
|
|
if (valid_id(id) && byte >= 0 && byte <= 255 && count >= 0 && count <= 16 && stream(id).live) { return Code::Ok; }
|
|
if (!valid_id(id)) {
|
|
return Code::BadId;
|
|
}
|
|
if (byte < 0 || byte > 255) {
|
|
return Code::BadByte;
|
|
}
|
|
if (count < 0 || count > 16) {
|
|
return Code::BadCount;
|
|
}
|
|
Stream& value = stream(id);
|
|
if (!value.live) {
|
|
return Code::Missing;
|
|
}
|
|
for (Number index = 0; index < count; ++index) {
|
|
if (value.pending.size() == static_cast<std::size_t>(value.capacity)) {
|
|
const Code result = drain(value);
|
|
if (result != Code::Ok) {
|
|
value.last = result;
|
|
return result;
|
|
}
|
|
}
|
|
value.pending.push_back(static_cast<char>(byte));
|
|
}
|
|
value.last = Code::Ok;
|
|
return Code::Ok;
|
|
}
|
|
Code Session::arm(Number id, Number stage, Number enabled) {
|
|
if (!valid_id(id)) {
|
|
return Code::BadId;
|
|
}
|
|
if (stage < 1 || stage > 3) {
|
|
return Code::BadStage;
|
|
}
|
|
if (enabled < 0 || enabled > 1) {
|
|
return Code::BadEnabled;
|
|
}
|
|
Stream& value = stream(id);
|
|
if (!value.live) {
|
|
return Code::Missing;
|
|
}
|
|
value.device.faults[static_cast<std::size_t>(stage - 1)] = enabled != 0;
|
|
return Code::Ok;
|
|
}
|
|
Code Session::flush_stream(Stream& value) {
|
|
Code result = drain(value);
|
|
if (result == Code::Ok) {
|
|
result = backend_.flush(value.device);
|
|
++totals_.flushes;
|
|
}
|
|
value.last = result;
|
|
return result;
|
|
}
|
|
Code Session::flush(Number id) {
|
|
if (!valid_id(id)) {
|
|
return Code::BadId;
|
|
}
|
|
Stream& value = stream(id);
|
|
if (!value.live) {
|
|
return Code::Missing;
|
|
}
|
|
return flush_stream(value);
|
|
}
|
|
Code Session::close(Number id) {
|
|
if (!valid_id(id)) {
|
|
return Code::BadId;
|
|
}
|
|
Stream& value = stream(id);
|
|
if (!value.live) {
|
|
return Code::Missing;
|
|
}
|
|
const Code first = flush_stream(value);
|
|
const Code closing = backend_.close(value.device);
|
|
++totals_.closes;
|
|
value.pending.clear();
|
|
value.live = false;
|
|
--totals_.live;
|
|
++totals_.closed;
|
|
value.last = first != Code::Ok ? first : closing;
|
|
return value.last;
|
|
}
|
|
View Session::view(Number id) const {
|
|
View result;
|
|
result.id = id;
|
|
if (!valid_id(id)) {
|
|
result.code = Code::BadId;
|
|
return result;
|
|
}
|
|
const Stream& value = stream(id);
|
|
if (!value.seen) {
|
|
return result;
|
|
}
|
|
result.code = Code::Ok;
|
|
result.seen = value.seen;
|
|
result.live = value.live;
|
|
result.capacity = value.capacity;
|
|
result.pending = value.pending;
|
|
result.durable = value.device.data;
|
|
result.history = value.device.history;
|
|
result.last = value.last;
|
|
result.faults = value.device.faults;
|
|
result.writes = value.device.writes;
|
|
result.flushes = value.device.flushes;
|
|
result.closes = value.device.closes;
|
|
return result;
|
|
}
|
|
Stats Session::stats() const {
|
|
return totals_;
|
|
}
|
|
}
|