mechanism/until.hpp — WHEN A STEP IS DONE: a power step's done-conditions.
This header declares 4 types (29 members), 1 free function, 3 constants, and 3 type aliass.
Extracted from include/shulib/mechanism/until.hpp — this page is that header's documentation, reformatted, so it cannot disagree with the code. Prose about how to think about the API lives in How it works; worked recipes live in Recipes; this page is the complete, mechanical list of what exists.
enum class DoneBydoneByWord— free functionclass Untilstruct SeesPiecestruct StopsSeeingPieceseesPiece— constantstopsSeeingPiece— constantstalls— constantseesPiece (overload 2)— type aliasstopsSeeingPiece (overload 2)— type aliasstalls (overload 2)— type alias
enum class DoneBy : std::uint8_tWhich done-condition ended a step — the word the step's log line names (doneByWord).
enum class, declared at include/shulib/mechanism/until.hpp:56.
None = 0no condition: the bound, a refusal, a cancel
enumerator, declared at include/shulib/mechanism/until.hpp:57.
Timeits time condition (a duration, or orAfter's)
enumerator, declared at include/shulib/mechanism/until.hpp:58.
Reacheda position or speed step reached its target (MECH-A3)
enumerator, declared at include/shulib/mechanism/until.hpp:59.
Stalledit stalled (stalls: SUCCEEDED; a stall signature otherwise: STALLED)
enumerator, declared at include/shulib/mechanism/until.hpp:60.
Seesa piece sensor saw a piece
enumerator, declared at include/shulib/mechanism/until.hpp:61.
StopsSeeinga piece sensor stopped seeing a piece
enumerator, declared at include/shulib/mechanism/until.hpp:62.
[[nodiscard]] constexpr const char* doneByWord(DoneBy d) noexceptThe words of a DoneBy, as the step's log line prints them. Never null; an out-of-range value reads "?".
free function, declared at include/shulib/mechanism/until.hpp:67.
class UntilA step's done-conditions (header): any combination of a time, a stall and a piece sensor's seeing or not seeing, ALWAYS beside the step's bound. Combined with | (either ends the step) or orAfter (a sensor condition, or after a time).
class, declared at include/shulib/mechanism/until.hpp:82.
static constexpr const char* kSelf = nullptr"This mechanism": no other mechanism named — the condition reads the step's OWN sensor.
field, declared at include/shulib/mechanism/until.hpp:85.
[[nodiscard]] static constexpr Until time(units::Time t) noexceptDone when t has passed since the step started (a desired duration: SUCCEEDED, by time).
function, declared at include/shulib/mechanism/until.hpp:88.
[[nodiscard]] static constexpr Until stalled() noexceptDone when the mechanism STALLS — a squeeze that closes until it is tight: SUCCEEDED, not a fault. Without it, a stated stall signature that trips is the STALLED verdict and a MECHANISM_STALLED fault. Needs the mechanism's stall signature (refused at the step without).
function, declared at include/shulib/mechanism/until.hpp:94.
[[nodiscard]] static constexpr Until sees() noexceptDone when THIS mechanism's piece sensor sees a piece.
function, declared at include/shulib/mechanism/until.hpp:96.
[[nodiscard]] static constexpr Until stopsSeeing() noexceptDone when THIS mechanism's piece sensor stops seeing a piece.
function, declared at include/shulib/mechanism/until.hpp:98.
template <class Declared> [[nodiscard]] static constexpr Until sees(const Declared& other) noexceptDone when ANOTHER mechanism's piece sensor sees a piece (the roller runs until the GRIP sees one), named by that mechanism's declaration of any kind and found by its NAME at run time. The words (seesPiece(grip)) also refuse, at build, a mechanism that declares no sensor and a declaration with no .name. Here, a declaration with no .name stores an EMPTY name — never kSelf, which would read the step's own sensor in its place — and the step refuses it.
function, declared at include/shulib/mechanism/until.hpp:105.
template <class Declared> [[nodiscard]] static constexpr Until stopsSeeing(const Declared& other) noexceptDone when ANOTHER mechanism's piece sensor stops seeing a piece (sees(other)'s rules).
function, declared at include/shulib/mechanism/until.hpp:110.
[[nodiscard]] static constexpr Until bound() noexceptNever done by a condition: only the bound ends the step (TIMED_OUT) — a run that is meant to last its whole time limit while the robot does something else.
function, declared at include/shulib/mechanism/until.hpp:115.
[[nodiscard]] constexpr Until operator|(const Until& o) const noexceptEither condition ends the step. Two TIME conditions keep the EARLIER. The sensor conditions must read ONE mechanism's sensor (header): two different NAMES (seesPiece(grip) | stopsSeeingPiece(claw)) are conflicting() and the step refuses them; the step's OWN sensor beside a name keeps the name and sets readsOwnSensorToo(), which the step resolves (one sensor when it runs on that mechanism, refused otherwise).
function, declared at include/shulib/mechanism/until.hpp:122.
[[nodiscard]] constexpr Until orAfter(units::Time t) const noexcept"... or after t, whichever comes first" — the time ends it SUCCEEDED, by time (seesPiece.orAfter(2.5_s): a missed piece does not end the auton). t must be shorter than the step's time limit (refused at the step otherwise: the bound would always win).
function, declared at include/shulib/mechanism/until.hpp:157.
[[nodiscard]] constexpr bool has(std::uint8_t bit) const noexceptWhether the condition bit (kTime, kStalled, kSees, kStops) is part of it.
function, declared at include/shulib/mechanism/until.hpp:160.
[[nodiscard]] constexpr double seconds() const noexceptThe time condition's duration, seconds (0 when there is none).
function, declared at include/shulib/mechanism/until.hpp:162.
[[nodiscard]] constexpr const char* sensor() const noexceptThe NAME of the mechanism whose piece sensor the condition reads (kSelf = the step's own; "" = a declaration with no .name, which no robot's list has).
function, declared at include/shulib/mechanism/until.hpp:165.
[[nodiscard]] constexpr bool readsOwnSensorToo() const noexceptTrue when the condition ALSO reads the step's own sensor beside the one sensor() names (seesPiece | stopsSeeingPiece(intake)): one sensor if the step runs on that mechanism, two otherwise — the step resolves it (operator|). Always false when sensor() is kSelf.
function, declared at include/shulib/mechanism/until.hpp:169.
[[nodiscard]] constexpr bool conflicting() const noexceptTrue when | joined sensor conditions NAMING two different mechanisms (operator|): the step refuses it rather than silently read one of them.
function, declared at include/shulib/mechanism/until.hpp:172.
static constexpr std::uint8_t kTime = 1The time condition's bit.
field, declared at include/shulib/mechanism/until.hpp:175.
static constexpr std::uint8_t kStalled = 4The stall condition's bit (2 is left free: "reached" is a position step's own, not a condition).
field, declared at include/shulib/mechanism/until.hpp:177.
static constexpr std::uint8_t kSees = 8The "sees a piece" condition's bit.
field, declared at include/shulib/mechanism/until.hpp:179.
static constexpr std::uint8_t kStops = 16The "stops seeing a piece" condition's bit.
field, declared at include/shulib/mechanism/until.hpp:181.
struct SeesPiece : UntilTHE WORD seesPiece: as itself, the step's OWN piece sensor; called with another mechanism's declaration, THAT one's (seesPiece(grip)) — refused AT BUILD when that one declares none.
struct, declared at include/shulib/mechanism/until.hpp:231.
constexpr SeesPiece() noexceptThe step's own sensor.
function, declared at include/shulib/mechanism/until.hpp:233.
template <class Declared> [[nodiscard]] consteval Until operator()(const Declared& other) constAnother mechanism's piece sensor; a declaration with none fails the build, named.
function, declared at include/shulib/mechanism/until.hpp:236.
struct StopsSeeingPiece : UntilTHE WORD stopsSeeingPiece: as seesPiece, for "no longer sees a piece".
struct, declared at include/shulib/mechanism/until.hpp:242.
constexpr StopsSeeingPiece() noexceptThe step's own sensor.
function, declared at include/shulib/mechanism/until.hpp:244.
template <class Declared> [[nodiscard]] consteval Until operator()(const Declared& other) constAnother mechanism's piece sensor; a declaration with none fails the build, named.
function, declared at include/shulib/mechanism/until.hpp:247.
inline constexpr SeesPiece seesPiece{}Until the step's piece sensor (or another's, seesPiece(grip)) sees a piece.
constant, declared at include/shulib/mechanism/until.hpp:253.
inline constexpr StopsSeeingPiece stopsSeeingPiece{}Until it stops seeing one.
constant, declared at include/shulib/mechanism/until.hpp:255.
inline constexpr Until stalls = Until::stalled()Until the mechanism stalls (a squeeze: SUCCEEDED).
constant, declared at include/shulib/mechanism/until.hpp:257.
using mechanism::seesPieceUntil a piece sensor sees a piece.
type alias, declared at include/shulib/mechanism/until.hpp:263.
using mechanism::stopsSeeingPieceUntil a piece sensor stops seeing one.
type alias, declared at include/shulib/mechanism/until.hpp:265.
using mechanism::stallsUntil the mechanism stalls.
type alias, declared at include/shulib/mechanism/until.hpp:267.
The header opens with the reasoning behind these shapes. It is reproduced here in full because a reference that only lists signatures teaches nobody why.
The header’s own reasoning — 44 lines
mechanism/until.hpp — WHEN A STEP IS DONE: a power step's done-conditions (the mechanism core,
chunk MECH-A2, 2026-10-15).
A step that runs a mechanism ends when ANY of its conditions holds — "this much time has passed",
"it stalled", "a piece sensor sees a piece", "a piece sensor stops seeing one" — and ALWAYS also at
its BOUND, the time limit every step states. `Until` never replaces the bound (requirements P4:
every action is bounded and says how it ended); it only lets a step end sooner, and says which
condition ended it (`DoneBy`, the word the step's log line names).
r.run(intake, 12_volt, seesPiece, 3_s) // until ITS piece sensor sees a piece
r.run(intake, 12_volt, seesPiece.orAfter(2.5_s), 3_s) // ... or after 2.5 s: SUCCEEDED by time
r.run(intake, -6_volt, stopsSeeingPiece, 1_s) // until it no longer sees one (an eject)
r.run(roller, 12_volt, seesPiece(grip), 2_s) // until ANOTHER mechanism's sensor sees one
r.run(catapult, 6_volt, stalls, 1_s) // until it stalls: a squeeze, SUCCEEDED
(`r.run(...)` is the auton's step, MECH-A4; the mechanism service runs the condition,
mechanism/service.hpp.)
── A condition that can never be met is a mistake, said where it is made ────────────
`seesPiece(arm)` — another mechanism's sensor, on a mechanism that declares none — FAILS THE BUILD
at the auton's line (detail::that_mechanism_has_no_piece_sensor). The forms the build cannot see
(`seesPiece` / `stopsSeeingPiece` on the step's OWN mechanism, `stalls` on one with no stall
signature) are refused at the STEP, before anything is commanded (the service's preconditions):
the condition and the declaration are two arguments of one run-time call, and the host test of
every registered auton runs each step against its robot's real list (MECH-A5), so the refusal
fails the suite before any upload.
── What a condition reads ───────────────────────────────────────────────────────────
A piece sensor is read as POSITIVE evidence (the service's Slot::seen()): YES, NO or UNKNOWN, and
UNKNOWN — a sensor declared but missing this boot, a distance held near with no confidence, a
sample taken while its read-fault count moved — satisfies NEITHER `seesPiece` nor
`stopsSeeingPiece`. A condition that names ANOTHER mechanism stores that mechanism's NAME, not
its address: the service finds it by name at run time (a declaration copied without `inline` has
one address per translation unit — the brief's P12). A declaration written without `.name` is
on no robot's list: the words refuse it at build (A1's `a_mechanism_has_no_name`), and the plain
`Until::sees(decl)` stores an EMPTY name — never "this mechanism" — which the step refuses.
ONE mechanism's sensor per condition. Two different NAMES joined by `|` are `conflicting()` at
once. The step's OWN sensor beside a NAME (`seesPiece | stopsSeeingPiece(intake)`) is one sensor
when the step runs on that very mechanism and two otherwise — only the step knows which, so the
condition keeps both facts (`sensor()` and `readsOwnSensorToo()`) and the step decides.
Plain constexpr data: a bit set, a time, which mechanism's sensor. PROS-free, allocation-free.