THE SUBSTRATE — doctrine → code
The implemented libraries, mapped to the doctrine documents they mechanize. Nothing here is aspirational: every library ships with a stdlib unittest suite, and the v1 audit's bugs are kept dead by adversarial reproduction. ↳ lib/ · gates/ · bin/ · tests/
6
libraries (lib/)
2
gate scripts (gates/)
209
tests
3
adversarial checks
1 · Library cards — which doctrine each implements
lib/ledgerlib.py 816 LOC
ledgerlib — the append-only ledger substrate (specs/LEDGER.md).
gates/gatelib.py 1296 LOC
gatelib.py — the shared gate library (GATES.md v2 contract, §1–§5).
lib/manifestlib.py 415 LOC
manifestlib — worker-manifest schema validation, commissioning pre-flight.
lib/valuesgate.py 218 LOC
valuesgate — the floor gate template carried by every worker (GATES.md §6).
lib/monitorlib.py 479 LOC
monitorlib — monitoring-layer primitives (corpus/LOOP-CLOSURE.md §3).
lib/sklib.py 886 LOC
sklib — self-knowledge layer primitives (BLUEPRINT.md self-knowledge table).
lib/funnellib.py 676 LOC
funnellib — executive funnel primitives (system/corpus/FUNNEL.md).
bin/podrun.py 266 LOC
podrun — the pod-runner harness.
gates/voice-pattern-gate.py 42 LOC
voice-pattern-gate.py — thin wrapper over gatelib (GATES.md §4).
workers/health_probe.py 39 LOC
health-probe worker — the first real script worker.
2 · VERIFIED DEAD — the four v1 bugs, killed by adversarial reproduction
tests/adversarial_check.py recreates each v1 failure scenario against the real API — exit 1 if any survives.
Adversarial check #2 — the canary discipline (tests/adversarial_check_sk.py, LOOP-CLOSURE.md §5): a planted fake-orphan canary must be CAUGHT by the real detector; a canary must NEVER leak into published findings; a detector deprived of its input must score MISSED, never silently fine — a blind detector is loud.
Adversarial check #3 — bad-news conservation (in tests/test_funnellib.py): a doctored condenser tier that drops a kill verdict's flag must be ruled DROPPED and named exactly; conservation_trace on a pass is an error — only bad news is traced.
- BUG 1 — day-collapse (audit R1): v1 counted unique DATES; 3 same-day runs could never pass threshold 3. v2 must pass on distinct run×provenance pairs. DEAD
- BUG 2 — repeat-firing (audit R2): a consumed key must not re-qualify from stale epochs — epoch ≤ consumed is blocked, fresh evidence re-qualifies. DEAD
- BUG 3 — unknown-bucket (audit R3): a proposal with no direction_key must never be counted — keyless proposals are excluded from counting, not defaulted into an "unknown" bucket. DEAD
- BUG 4 — AUTO_PASS (audit R4): the AUTO_PASS_SOURCES bypass is DELETED (GATES.md §5); self-declared provenance (attested_by == proposer) is stripped before counting. DEAD
Adversarial check #2 — the canary discipline (tests/adversarial_check_sk.py, LOOP-CLOSURE.md §5): a planted fake-orphan canary must be CAUGHT by the real detector; a canary must NEVER leak into published findings; a detector deprived of its input must score MISSED, never silently fine — a blind detector is loud.
Adversarial check #3 — bad-news conservation (in tests/test_funnellib.py): a doctored condenser tier that drops a kill verdict's flag must be ruled DROPPED and named exactly; conservation_trace on a pass is an error — only bad news is traced.
3 · Test inventory
| File | Tests | Covers |
|---|---|---|
tests/test_manifestlib.py | 44 | Tests for lib/manifestlib.py and lib/valuesgate.py — stdlib unittest only. |
tests/test_sklib.py | 44 | Tests for lib/sklib.py — the self-knowledge layer primitives. |
tests/test_gatelib.py | 35 | test_gatelib.py — stdlib unittest suite for gates/gatelib.py (GATES.md v2). |
tests/test_funnellib.py | 34 | Tests for lib/funnellib.py against system/corpus/FUNNEL.md. |
tests/test_ledgerlib.py | 30 | Tests for lib/ledgerlib.py against system/specs/LEDGER.md. |
tests/test_monitorlib.py | 22 | Tests for lib/monitorlib.py against corpus/LOOP-CLOSURE.md §3. |
tests/adversarial_check.py | — | Adversarial verification: the four v1 audit bugs must be DEAD in gatelib. |
tests/adversarial_check_sk.py | — | Adversarial check #2 — the canary discipline (LOOP-CLOSURE.md §5). |
| Total | 209 |
4 · The podrun flow — one scheduled tick, substrate enforced
manifest
manifests/<worker>.yaml — the commissioning record + the directive file
→
preflight
commissioning pre-flight via manifestlib — an unwired worker does not run. Exit 6: NOT COMMISSIONED = refused.
→
values guard
the floor gate (valuesgate) checked on every outbound action. Exit 7: values block.
→
tick
script workers run inline; llm workers get the run envelope (prompt assembled from directive + delta-brief) and hand off to the scheduler — podrun never calls a model
→
ledger + broadcast + mirror
heartbeat/verdicts/records mirrored to the ledger (ledgerlib); state + log written; broadcast-up to the captured endpoint; Discord mirror queue (display, never transport)
↳ bin/podrun.py · system/ops/DEPLOYMENT.md §3–§4