pub struct GoalGate { /* private fields */ }Expand description
The core hook for the --goal goal-driven loop, subscribing to two events
(dispatched via the hook_event envelope):
after_session_enter: Injects the goal description +goal_doneusage contract asadditional_contextinto the system prompt suffix — effective from turn 1. This lets the model know the goal and that it must actively callgoal_doneupon completion from the start, avoiding an extra wasted turn waiting for the first voluntary stop.before_turn_end: On voluntary turn stop, readsGoalState::is_reached: if reached (model calledgoal_done) →proceedto end; otherwise →continueto extend the turn + inject an English prompt reminder.
The hard cap on extensions is enforced by the turn loop’s
crate::session::TurnConfig::max_hook_continues (mapped from --max-turns) — this
hook only checks “is it done?”, it does not count extensions itself.
Like SkillManifestHook, this is a stateful builtin (holds Arc<GoalState>) and
cannot be constructed via BuiltinRegistry::defaults’s parameterless factory —
during CLI assembly, a closure capturing the state is registered for both events under
--goal (see defect_cli::hooks).
Implementations§
Trait Implementations§
Source§impl StepHandler for GoalGate
impl StepHandler for GoalGate
Source§fn handle_step<'a>(
&'a self,
envelope: &'a Value,
_ctx: HookCtx<'a>,
) -> BoxFuture<'a, Result<Option<Value>, HookError>>
fn handle_step<'a>( &'a self, envelope: &'a Value, _ctx: HookCtx<'a>, ) -> BoxFuture<'a, Result<Option<Value>, HookError>>
Dispatches on the envelope’s hook_event:
after_session_enter→ injects goal description and contract (additional_context)before_turn_end→ if reached, proceed; otherwise continue with a prompt
Auto Trait Implementations§
impl Freeze for GoalGate
impl RefUnwindSafe for GoalGate
impl Send for GoalGate
impl Sync for GoalGate
impl Unpin for GoalGate
impl UnsafeUnpin for GoalGate
impl UnwindSafe for GoalGate
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
Mutably borrows from an owned value. Read more