Expand description
Evidence gate v1 (SPEC P4/A6): a declarative, bounded, no-model-call gate over the worker’s own event stream.
The gate is a pure predicate evaluation: it never calls the provider, never mutates context (verdicts are non-context-bearing ), and only reports — recovery disposition stays owned by the engine (a failed gate surfaces as a soft failure; the engine settles it).
Semantics (wired into the built-in loop’s stop path by
crate::react::ReActLoop::with_evidence_gate):
- On the loop’s terminal stop —
Settled(final answer, empty inbox: the loop’s “done” claim) orStopped(intentional stop, e.g. The iteration budget) — the gate evaluates every check as a pure predicate over the session’s event stream. - Pass: append
evidence/verdict{passed:true}and let the stop proceed — the verdict is the last event before the end write. - Fail: append
evidence/verdict{passed:false, attempt}and send the loop back for another provider turn whileattempt < max_retries; past the budget the loop reports a soft failure, which the engine settles asfailed— nevercompletedwith a failed gate (constraint 7). attemptis derived from the stream (the number of prior failed verdicts of the same gate), so the retry budget survives episodes, crashes and takeover (constraint 1 in spirit).- Retry turns reuse the identical context prefix: verdict events are non-context-bearing, so a gate retry never invalidates the provider prefix cache (constraint 3).
Default-off: EvidenceGateConfig::default is disabled; built-in
behavior is unchanged until a caller explicitly mounts a gate.
Structs§
- Check
Outcome - One evaluated check inside a verdict.
detailis present exactly when the check failed (observable why, no noise on passes). - Evidence
Gate Config - Evidence-gate tuning. Default is disabled — built-in behavior is unchanged until a caller mounts a gate explicitly.
- Evidence
Gate Counters - Shared, lock-free verdict counters. Cloning the containing
EvidenceGateConfigshares the same counters (anArc). - Gate
Verdict - The gate’s verdict over one stream.
- Verdict
Counters - Verdict counters for the metrics surface (SPEC §3.1: evidence-gate
verdicts). Mounted into
GET /metricsby the assembly; cheap to read at any time.
Enums§
- Check
Spec - One declarative evidence check. Each variant is a pure predicate over
&[Event]— no provider call, no context mutation, no clock.
Constants§
- BUILTIN_
GATE_ NAME - Gate name the built-in loop stamps on its verdicts. Custom wrappers (’s worker driver) pass their own name so multiple gates can coexist on one stream.
Functions§
- evaluate_
evidence_ gate - Evaluates
checksagainstevents. Pure: same inputs, same verdict. - verdict_
payload - Renders a verdict into the frozen
evidence/verdictpayload:{"gate": str, "passed": bool, "checks": [{"name": str, "passed": bool, "detail"?: str}], "attempt": u64}. Field order in serialized form is lexicographic (frozen serialization discipline, constraint 3).