Skip to main content

Module evidence

Module evidence 

Source
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) or Stopped (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 while attempt < max_retries; past the budget the loop reports a soft failure, which the engine settles as failed — never completed with a failed gate (constraint 7).
  • attempt is 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§

CheckOutcome
One evaluated check inside a verdict. detail is present exactly when the check failed (observable why, no noise on passes).
EvidenceGateConfig
Evidence-gate tuning. Default is disabled — built-in behavior is unchanged until a caller mounts a gate explicitly.
EvidenceGateCounters
Shared, lock-free verdict counters. Cloning the containing EvidenceGateConfig shares the same counters (an Arc).
GateVerdict
The gate’s verdict over one stream.
VerdictCounters
Verdict counters for the metrics surface (SPEC §3.1: evidence-gate verdicts). Mounted into GET /metrics by the assembly; cheap to read at any time.

Enums§

CheckSpec
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 checks against events. Pure: same inputs, same verdict.
verdict_payload
Renders a verdict into the frozen evidence/verdict payload: {"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).