Batch 24 (20261102-C-bos-seed-24) screened all 3078 Bos seed queries. Only 23 themes were in scope (pure user-space reliability, at most one task per theme); the rest were single operations or explanations, installs and networking, system administration, ROS2, board-only or GUI requests. Two finished drafts were withdrawn as too close to existing tasks. Seeds supply direction only: all sources, contracts and tests are new, and no task shares more than 14 characters with its seed text. Each task passed the local gate and the trace6 Docker gate (5 runs per sample class). Claude rebuilt the catalog from the calibration receipts: 23/23 USABLE. 16 of 23 are C/C++. Only the task directories are taken; the batch worktree's lowered disk floor in rollout/core.py stays out of main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
106 lines
2.6 KiB
C++
106 lines
2.6 KiB
C++
#include "link.hpp"
|
|
#include <limits>
|
|
|
|
namespace carrier {
|
|
Controller::Controller(Backend& backend) : backend_(backend) {}
|
|
|
|
bool Controller::valid(unsigned port) const
|
|
{
|
|
return port < ledger_.size();
|
|
}
|
|
|
|
std::uint64_t Controller::now() const
|
|
{
|
|
return now_;
|
|
}
|
|
|
|
bool Controller::status(unsigned port, Status& result) const
|
|
{
|
|
if (!valid(port)) return false;
|
|
result = fold(port);
|
|
return true;
|
|
}
|
|
|
|
bool Controller::enable(unsigned port)
|
|
{
|
|
if (!valid(port)) return false;
|
|
const Status before = fold(port);
|
|
if (!before.enabled) {
|
|
record(port, Event::enable);
|
|
if (before.carrier) start(port);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool Controller::disable(unsigned port)
|
|
{
|
|
if (!valid(port)) return false;
|
|
if (fold(port).enabled) stop(port, Event::disable);
|
|
return true;
|
|
}
|
|
|
|
bool Controller::carrier_up(unsigned port)
|
|
{
|
|
if (!valid(port)) return false;
|
|
const Status before = fold(port);
|
|
if (!before.carrier) {
|
|
record(port, Event::up);
|
|
if (before.enabled) start(port);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool Controller::carrier_down(unsigned port)
|
|
{
|
|
if (!valid(port)) return false;
|
|
if (fold(port).carrier) stop(port, Event::down);
|
|
return true;
|
|
}
|
|
|
|
bool Controller::complete(unsigned port, std::uint64_t generation)
|
|
{
|
|
if (!valid(port)) return false;
|
|
const Status before = fold(port);
|
|
if (before.enabled && before.carrier &&
|
|
before.phase == Phase::opening && before.generation == generation) {
|
|
record(port, Event::done);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool Controller::fail(unsigned port, std::uint64_t generation)
|
|
{
|
|
if (!valid(port)) return false;
|
|
const Status before = fold(port);
|
|
if (!before.enabled || !before.carrier ||
|
|
before.phase != Phase::opening || before.generation != generation) {
|
|
return true;
|
|
}
|
|
backend_.close(port, generation);
|
|
const unsigned failures = before.failures + 1;
|
|
std::uint64_t due = 0;
|
|
if (failures < 3) {
|
|
const std::uint64_t delay = std::uint64_t(1) << failures;
|
|
if (now_ <= std::numeric_limits<std::uint64_t>::max() - delay) {
|
|
due = now_ + delay;
|
|
}
|
|
}
|
|
record(port, Event::failed, due);
|
|
return true;
|
|
}
|
|
|
|
bool Controller::advance(std::uint64_t delta)
|
|
{
|
|
if (delta > std::numeric_limits<std::uint64_t>::max() - now_) return false;
|
|
now_ += delta;
|
|
for (unsigned port = 0; port < ledger_.size(); ++port) {
|
|
const Status before = fold(port);
|
|
if (before.enabled && before.carrier &&
|
|
before.phase == Phase::waiting && before.due <= now_) {
|
|
start(port);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
} // namespace carrier
|