solvi.core.knowledge.gates¶
Write gates: the WriteGate protocol, the source check and the consistency check.
Write gates: what lets a proposed item into the knowledge store, and what lets a behaviour-changing one become a fact.
class MyGate: # the WriteGate protocol
name = "mine"
def admit(self, store, item, shadow) -> Verdict: ...
KnowledgeStore(gates=[SourceGate(), ConsistencyGate(), MyGate()])
item is the proposal as a dict (KnowledgeStore.proposal: id, kind, body, scope, source, by, derived_from, key, ...);
shadow is whatever the writer passed to add(..., shadow=) — for a rule, skill or action, a shadow measurement.
Every verdict is recorded in the journal: a refusal as a "refused" entry, a held behaviour-changing item as "held", a
promotion with every gate's verdict.
Built in (stable):
SourceGate the source check: "person", "outcome", "spec", or "verified" — a System 2 answer that answered
alone under its guarantee, named by of= and checked in the store's TraceStorage. Never the system's
own unverified answer. It runs first in every store, whatever gates are given (by construction).
ConsistencyGate premises must exist and be present (not retracted or refuted), and a derived item may not hold
another value on its own premise's key (it would refute its support). Contradictions between items
are not a refusal: the store resolves them (outcome > person > spec > verified; else a dispute).
The shadow gate — measure a candidate on a shadow of the system (held-out gain, honesty, size of the change) before it changes System 1's behaviour — is experimental: solvi.experimental.learning.ShadowGate.
Verdict
dataclass
¶
A write gate's answer about one proposed item: admitted or not, why, and what it measured (recorded).
WriteGate ¶
Bases: Protocol
A write gate of the knowledge store.
You implement: admit(store, item, shadow) → Verdict(admit, reason, measured) — item is the proposal
(KnowledgeStore.proposal), shadow what the writer passed to add(..., shadow=).
You get for free: it runs after the built-in source check on every proposed item; its verdict is journaled; a refusal keeps a fact out, a hold keeps a rule, skill or action a hypothesis.
Stability: stable.
SourceGate ¶
The source check (see the module docstring).
ConsistencyGate ¶
Premises exist and are present; a derived item is not self-defeating (see the module docstring).
default_gates ¶
The gates a KnowledgeStore uses when none are given: [SourceGate(), ConsistencyGate()].
with_source_gate ¶
The gates with a SourceGate first (added when missing): the source check is never left out.