pub struct RedelegationCapSignal(/* private fields */);Expand description
Shared signal tracking total re-delegation attempts across one run (#2265).
Why: [RedelegatingRunner] and run_task::assemble_report are different
call sites that both need to observe the SAME attempt count / cap state —
the runner to enforce the cap, the report assembler to recognise a
cap-triggered terminal state even when the PM’s own loop error doesn’t
literally say so (e.g. the PM’s NEXT turn separately exhausts its own
budget after seeing the cap-reached tool error). An Arc-wrapped group of
atomics is the simplest thing that is Send + Sync and cheap to clone into
both places.
What: new() starts at zero attempts with both flags clear.
is_cap_reached(), is_retry_budget_exhausted() and attempts() are
read-only accessors for assemble_report; record_attempt,
mark_retry_budget_exhausted and mark_cap_reached are private, called
only by [RedelegatingRunner]. The two flags are deliberately distinct:
only cap_reached is terminal (#2852).
Test: redelegating_runner_stops_at_per_call_cap_without_latching_stop_signal,
failure_ceiling_latches_cap_reached,
successful_delegations_never_consume_a_later_delegations_budget.
Implementations§
Source§impl RedelegationCapSignal
impl RedelegationCapSignal
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a fresh signal with zero recorded attempts.
Why: Each execute_run_task call needs its OWN signal — attempts must
never leak across independent runs.
What: Self::default().
Test: redelegating_runner_retries_on_llm_error_then_succeeds.
Sourcepub fn is_cap_reached(&self) -> bool
pub fn is_cap_reached(&self) -> bool
Whether the run-wide FAILED-invocation ceiling was hit (#2852).
Why: Drives run_task::mod’s with_stop_signal, so it must be true
ONLY for conditions a fresh delegation genuinely cannot clear. Neither
per-call retry exhaustion (see Self::is_retry_budget_exhausted) nor
sheer invocation COUNT is one of those — a run of successful recon
delegations must never land here.
What: Reads the latched flag.
Test: failure_ceiling_latches_cap_reached,
many_successful_delegations_never_latch_the_failure_ceiling.
Sourcepub fn failed_invocations(&self) -> u32
pub fn failed_invocations(&self) -> u32
Total FAILED engineer invocations recorded so far, run-wide.
Why: The number the terminal report must quote — it is the ceiling’s
actual input, and unlike a pre-incremented dispatch counter it is
exactly the count of invocations that really failed, so an operator is
never told “13” when 12 occurred.
What: Reads the atomic counter.
Test: failure_ceiling_latches_cap_reached.
Sourcepub fn is_retry_budget_exhausted(&self) -> bool
pub fn is_retry_budget_exhausted(&self) -> bool
Whether any single delegation exhausted its MAX_REDELEGATIONS
retry budget during this run (#2852).
Why: Lets assemble_report distinguish “the engineer really was
retried to exhaustion” from an unrelated PM-loop error, WITHOUT that
observation stopping the loop. Read-only for report assembly.
What: Reads the latched flag.
Test: redelegating_runner_stops_at_per_call_cap_without_latching_stop_signal.
Sourcepub fn attempts(&self) -> u32
pub fn attempts(&self) -> u32
Total engineer invocations (successes AND failures) recorded so far, run-wide.
Why: A truthful total-cost measure for callers that want it (e.g.
future observability/metrics) — but it is reporting-only and governs
nothing (#2852): the terminal report’s message quotes
Self::failed_invocations instead, precisely so a run of successful
delegations is never described as having “failed” anything.
What: Reads the atomic counter.
Test: many_successful_delegations_never_latch_the_failure_ceiling,
redelegating_runner_retries_on_llm_error_then_succeeds.
Trait Implementations§
Source§impl Clone for RedelegationCapSignal
impl Clone for RedelegationCapSignal
Source§impl Debug for RedelegationCapSignal
impl Debug for RedelegationCapSignal
Auto Trait Implementations§
impl Freeze for RedelegationCapSignal
impl RefUnwindSafe for RedelegationCapSignal
impl Send for RedelegationCapSignal
impl Sync for RedelegationCapSignal
impl Unpin for RedelegationCapSignal
impl UnsafeUnpin for RedelegationCapSignal
impl UnwindSafe for RedelegationCapSignal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more