Provable decisions #
What is new: when a TensorChain machine chooses among several programs, the choice is a record, not a side effect. Exact selection (E1) picks only a program whose output provably matches the expected output, and otherwise abstains. Every decision record lists each candidate as selected, not_taken or denied: the roads not taken are kept, with no invented output. A learned re-ranker (the promoted E2S) may reorder E1's survivors, never add to them, and it is pinned to an owner-approved receipt: if its weights change by one bit, it refuses to load.
Why it matters: this is how learning gets into a system without giving up proof. The exact rule is the floor, the learned part can only narrow it, and every decision can be replayed and audited, including what was not chosen and why. The off switch is the plain exact machine on the same state.
Three programs, one goal #
import tempfile
from ouroboros_v2 import MemoryStore, Refused
from ouroboros_v2.transforms import ByteProgram, Step
from adderall_protocol.scaffolding import ScaffoldMachine
from adderall_protocol.tensors import read_reference
payload = bytes(range(0, 250, 7))
plus = lambda n: bytes((x + n) % 256 for x in payload)
programs = [ByteProgram((Step("add", a),)) for a in (5, 3, 7)] # three candidate transforms
machine = ScaffoldMachine(MemoryStore(), programs, selection="e1").lock()
with tempfile.TemporaryDirectory() as work:
result = machine.pop(work, payload, expected=plus(3))
record = read_reference(machine.store, machine._last_e1, "adderall.e1-selection.v1")
print("chosen slot:", result.slot, "| reason:", record["reason"])
for row in record["rows"]:
print(" slot", row["slot"], row["status"], "| consistent with the goal:", row["consistent"])
assert result.slot == 1 # only "add 3" maps payload to plus(3)
assert [r["status"] for r in record["rows"]].count("selected") == 1
assert all(r["status"] == "not_taken" for r in record["rows"] if r["slot"] != 1)
chosen slot: 1 | reason: selected slot 0 not_taken | consistent with the goal: False slot 1 selected | consistent with the goal: True slot 2 not_taken | consistent with the goal: False
The record keeps all three candidates: one selected, two not taken, each with whether it agreed with the goal.
When nothing fits, it abstains #
before = machine.reflect()
with tempfile.TemporaryDirectory() as work:
try:
machine.pop(work, payload, expected=plus(4)); outcome = "chose something (wrong)"
except Refused as e:
outcome = "refused: " + str(e)
after = machine.reflect()
abstained = read_reference(machine.store, machine._last_e1, "adderall.e1-selection.v1")
print(outcome)
print("selected:", abstained["selected"], "| reason:", abstained["reason"])
print("state moved:", (before["history"], before["state_bits"]) != (after["history"], after["state_bits"]))
assert outcome.startswith("refused")
assert abstained["selected"] is None and abstained["reason"] == "no_consistent_ready_program"
assert (before["history"], before["state_bits"]) == (after["history"], after["state_bits"])
refused: E1 abstains: no ready program is consistent with the expected output selected: None | reason: no_consistent_ready_program state moved: False
No program adds 4, so the machine refuses instead of guessing, records why, and moves nothing.
The learned re-ranker, behind the exact gate #
from adderall_protocol.promoted import PromotedMachine, PROMOTION
promoted = PromotedMachine(MemoryStore(), programs, budget=2).lock()
with tempfile.TemporaryDirectory() as work:
r = promoted.pop(work, payload, expected=plus(3))
rec = read_reference(promoted.store, promoted._last_e1, "adderall.e1-selection.v1")
print("model:", rec["rerank"]["model"], "| bank:", rec["rerank"]["bank"][:16], "...")
print("E1 chose:", rec["rerank"]["e1_selected"], "| E2S chose:", rec["rerank"]["e2_selected"], "| final:", rec["selected"])
print("approved by:", PROMOTION["approved_by"], "on", PROMOTION["approved"])
print("off switch:", PROMOTION["off_switch"])
snap = promoted.snapshot()
plain = ScaffoldMachine.from_state(promoted.store, snap) # the same state, exact only
print("off switch restores a plain exact machine:", type(plain).__name__)
assert rec["rerank"]["bank"] == PROMOTION["bank_digest"] and rec["promotion"] == promoted.promotion.root
assert rec["selected"] == r.slot == 1 # the only consistent survivor
assert type(plain) is ScaffoldMachine
model: E2S | bank: c22081af99dd149c ... E1 chose: 1 | E2S chose: 1 | final: 1 approved by: Tom (owner) on 2026-11-23 off switch: ScaffoldMachine(selection="e1") off switch restores a plain exact machine: ScaffoldMachine
The promoted model's choice is written into the same decision record as E1's, bound to the approval record. With a single consistent survivor it can only confirm E1; with several, it orders them, and E1 still decides what is allowed.