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>
120 lines
2.9 KiB
C++
120 lines
2.9 KiB
C++
#include "link.hpp"
|
|
|
|
#include <limits>
|
|
|
|
namespace carrier {
|
|
|
|
Controller::Controller(Backend& backend) : backend_(backend) {}
|
|
|
|
bool Controller::valid(unsigned port) const
|
|
{
|
|
return port < ports_.size();
|
|
}
|
|
|
|
std::uint64_t Controller::now() const
|
|
{
|
|
return now_;
|
|
}
|
|
|
|
bool Controller::status(unsigned port, Status& result) const
|
|
{
|
|
if (!valid(port)) return false;
|
|
const Port& state = ports_[port];
|
|
result.enabled = state.enabled;
|
|
result.carrier = state.carrier;
|
|
result.phase = state.phase;
|
|
result.generation = state.generation;
|
|
result.failures = state.failures;
|
|
result.due = state.due;
|
|
return true;
|
|
}
|
|
|
|
void Controller::begin(unsigned port)
|
|
{
|
|
Port& state = ports_[port];
|
|
if (!state.enabled || !state.carrier) return;
|
|
if (state.phase == Phase::opening || state.phase == Phase::online) return;
|
|
if (state.generation == std::numeric_limits<std::uint64_t>::max()) return;
|
|
state.generation += 1;
|
|
state.phase = Phase::opening;
|
|
state.due = 0;
|
|
backend_.open(port, state.generation);
|
|
}
|
|
|
|
void Controller::stop(unsigned port)
|
|
{
|
|
Port& state = ports_[port];
|
|
if (state.phase == Phase::opening || state.phase == Phase::online) {
|
|
backend_.close(port, state.generation);
|
|
}
|
|
state.phase = Phase::idle;
|
|
state.due = 0;
|
|
state.failures = 0;
|
|
}
|
|
|
|
bool Controller::enable(unsigned port)
|
|
{
|
|
if (!valid(port)) return false;
|
|
Port& state = ports_[port];
|
|
if (state.enabled) return true;
|
|
state.enabled = true;
|
|
if (state.carrier) begin(port);
|
|
return true;
|
|
}
|
|
|
|
bool Controller::disable(unsigned port)
|
|
{
|
|
if (!valid(port)) return false;
|
|
Port& state = ports_[port];
|
|
if (!state.enabled) return true;
|
|
stop(port);
|
|
state.enabled = false;
|
|
return true;
|
|
}
|
|
|
|
bool Controller::carrier_up(unsigned port)
|
|
{
|
|
if (!valid(port)) return false;
|
|
Port& state = ports_[port];
|
|
if (state.carrier) return true;
|
|
state.carrier = true;
|
|
if (state.enabled) begin(port);
|
|
return true;
|
|
}
|
|
|
|
bool Controller::complete(unsigned port, std::uint64_t generation)
|
|
{
|
|
if (!valid(port)) return false;
|
|
Port& state = ports_[port];
|
|
if (!state.enabled || !state.carrier) return true;
|
|
if (state.phase != Phase::opening) return true;
|
|
// A completion is associated with the opening transaction on this port.
|
|
if (port == 1 || state.generation != generation) return true;
|
|
state.phase = Phase::online;
|
|
state.failures = 0;
|
|
state.due = 0;
|
|
return true;
|
|
}
|
|
|
|
bool Controller::fail(unsigned port, std::uint64_t generation)
|
|
{
|
|
if (!valid(port)) return false;
|
|
Port& state = ports_[port];
|
|
if (!state.enabled || !state.carrier) return true;
|
|
if (state.phase != Phase::opening) return true;
|
|
if (state.generation != generation) return true;
|
|
schedule(port);
|
|
return true;
|
|
}
|
|
|
|
bool Controller::advance(std::uint64_t delta)
|
|
{
|
|
if (delta > std::numeric_limits<std::uint64_t>::max() - now_) return false;
|
|
now_ += delta;
|
|
tick(0);
|
|
tick(1);
|
|
return true;
|
|
}
|
|
|
|
} // namespace carrier
|