pub enum HookDecision {
Allow,
Modify(ModifyPayload),
Deny {
reason: String,
code: i32,
},
AskUser {
prompt: String,
options: Vec<String>,
default: Option<String>,
},
}Expand description
The four decision shapes a hook subprocess may return.
See the module-level documentation for the JSON wire contract and the runtime validation rules.
#969 — PartialEq is now derived. Pre-#969 it was hand-rolled
on the (mistaken) premise that serde_json::Value was not
PartialEq; it IS (serde_json 1.0 derives Eq + PartialEq + Hash
on Value). The real blocker for derive(Eq) is Option<f64>
inside MemoryDelta, which is PartialEq but not Eq.
Variants§
Allow
Continue the memory operation unchanged. Wire shape:
{"action":"allow"} (or empty {} / empty stdout).
Modify(ModifyPayload)
Rewrite the in-flight payload before the memory operation
runs. Only valid on pre- events; on post- events the
dispatcher logs a warning and degrades to Allow.
Deny
Halt the memory operation. reason surfaces in the
operator log and (when G7+ wires the executor into the
request path) the API response. code is an HTTP-style
integer the API surface translates to a status code.
AskUser
Pause the chain and surface prompt to the operator
alongside options. The chain runner (G5) resumes once
the human picks one. default (if present) names the
option the runner falls back to on operator timeout.
Implementations§
Source§impl HookDecision
impl HookDecision
pub fn parse(line: &str) -> Result<Self, DecisionParseError>
Sourcepub fn degrade_modify_for_post_event(self, event: HookEvent) -> Self
pub fn degrade_modify_for_post_event(self, event: HookEvent) -> Self
Runtime guard for the pre-event-only constraint on
Modify. If self is Modify and event is a post-
event, log a warning and return Allow. Otherwise return
self unchanged.
The dispatcher (G5) calls this after parsing the child’s
decision but before applying the delta, so a misbehaving
hook can’t sneak a Modify past a post- event.
Trait Implementations§
Source§impl Clone for HookDecision
impl Clone for HookDecision
Source§fn clone(&self) -> HookDecision
fn clone(&self) -> HookDecision
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HookDecision
impl Debug for HookDecision
Source§impl<'de> Deserialize<'de> for HookDecision
impl<'de> Deserialize<'de> for HookDecision
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl PartialEq for HookDecision
impl PartialEq for HookDecision
Source§fn eq(&self, other: &HookDecision) -> bool
fn eq(&self, other: &HookDecision) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for HookDecision
impl Serialize for HookDecision
impl StructuralPartialEq for HookDecision
Auto Trait Implementations§
impl Freeze for HookDecision
impl RefUnwindSafe for HookDecision
impl Send for HookDecision
impl Sync for HookDecision
impl Unpin for HookDecision
impl UnsafeUnpin for HookDecision
impl UnwindSafe for HookDecision
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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