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).
WriterGate (opt-in: KnowledgeStore(writers={writer: source})) a source is a rank bound to its writer: a
writer not registered, or declaring a source it is not registered with, is refused.
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).
A shadow measurement — what a candidate does on a shadow of the system (held-out gain, honesty, size of the change)
before it changes System 1's behaviour — is a gate you write (add(..., shadow=...) passes the measurement to every
gate); the experimental change pipeline (solvi.experimental.changes) measures candidates in its stages and passes their
numbers on that way.
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).
TrustGate ¶
Opt-in descriptive source reliability check, never a truth certificate.
Identity comes exclusively from item.by (or an explicit writer_sources map), never from the item's source rank/category. The caller authenticates writers. SourceGate and WriterGate still govern permission independently. This gate reads a fixed registry; it neither records assertions nor invents labels. An adverse verdict refuses every item kind, including behaviour-changing items.
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.