Schema Mechanism
"An agent learns by discovering reliable patterns: when I do X in context C, result R tends to follow."
Gary Drescher's Made-Up Minds (1991) provides a computational theory of how minds learn causal models of the world. Drescher was a student of Marvin Minsky at MIT, and his schema mechanism extends Piaget's developmental psychology into executable algorithms.
The Core Idea
A schema is a causal unit:
Context → Action → Result
The agent doesn't start with schemas. It discovers them through experience, noticing which actions reliably produce which results in which contexts.
schema:
action: push-button
context: [door-closed]
result: [door-open]
reliability: 0.95
Drescher schema vs interchange schema
Here schema means Drescher causal units (Context → Action → Result). That is not JSON Schema, OpenAPI, RELAX NG, XSD, or other interchange mechanisms. For the MOOLLM schemapedia (interchange, relational SQL/SQLite, frames, K-lines, SoM—same word, many senses), see schema (skills/schema/, schemas/registry.yml). For Minsky frames vs K-lines vs Drescher, see knowledge-frames.
Schema Components
| Component | Description | MOOLLM Equivalent |
|-----------|-------------|-------------------|
| Item | Atomic state element (ON/OFF/UNKNOWN) | YAML field, file existence |
| Action | Something the agent can do | Skill verb, procedure |
| Schema | Context → Action → Result | Documented procedure |
| Extended Context | Statistical tracking of context conditions | "Prerequisites" section |
| Extended Results | Statistical tracking of result conditions | "Side Effects" section |
| Synthetic Item | Discovered hidden state | Undocumented dependency |
| Composite Action | Chained sequence of actions | Multi-step procedure |
Extended Context: Marginal Attribution
A schema might fail unpredictably. Extended Context tracks which conditions correlate with success:
# The schema "start pyvision" sometimes fails
# Extended Context discovers: it fails when postgres isn't running
schema:
action: start-pyvision
context: [] # Initially empty
result: [pyvision-running]
extended_context:
postgres-running:
success_when_on: 47 # Succeeded 47 times when postgres was on
success_when_off: 0 # Never succeeded when postgres was off
failure_when_on: 2 # Failed 2 times even with postgres
failure_when_off: 15 # Failed 15 times without postgres
# Discovery: postgres-running is a prerequisite!
# Spin off new schema with explicit context:
schema:
action: start-pyvision
context: [postgres-running] # Now explicit
result: [pyvision-running]
This is marginal attribution -- discovering which items matter by tracking correlations.
Extended Results: Side Effect Discovery
Similarly, schemas track what else happens:
schema:
action: ingest-video
context: [video-exists]
result: [task-created]
extended_results:
disk-space-decreased:
on_after_success: 47
off_after_success: 0
# Discovery: ingesting uses disk space!
Side effects become explicit, documented, predictable.
Synthetic Items: Hidden State
Sometimes success depends on state the agent can't directly observe. Drescher's solution: invent a synthetic item as a hypothesis.
# The schema works sometimes, fails sometimes, no visible pattern
# Hypothesis: there's hidden state we can't see
synthetic_item:
name: "gpu-memory-available"
host_schema: start-pyvision
# If this schema succeeds, assume the item was ON
# If it fails, assume the item was OFF
The synthetic item becomes a probe -- its state is inferred from schema success/failure.
Composite Actions: Planning
Once the agent has reliable schemas, it can chain them:
# Goal: pyvision-running
# Current: postgres-not-running
plan:
- schema: start-postgres
context: []
result: [postgres-running]
- schema: start-pyvision
context: [postgres-running]
result: [pyvision-running]
Drescher uses Dijkstra's algorithm on the schema graph -- find shortest path from current state to goal state.
The Learning Loop
# Schema mechanism learning loop
learning_loop:
- step: 1. ACT
action: "Execute schema action"
- step: 2. OBSERVE
action: "Record which items changed (on-flips, off-flips)"
- step: 3. ATTRIBUTE
action: "Update extended context/results tables, track correlations"
- step: 4. SPIN OFF
action: "When patterns emerge, create child schemas with refined conditions"
This maps directly to PLAY-LEARN-LIFT:
- PLAY = ACT + OBSERVE
- LEARN = ATTRIBUTE
- LIFT = SPIN OFF
Implementation: pyleela.brain
Henry Minsky (Marvin's son) implemented Drescher's schema mechanism in Python:
| Class | Purpose |
|-------|---------|
| World | Central coordinator, tracks all items and schemas |
| Item | Atomic state element with ON/OFF/UNKNOWN values |
| Action | Primitive or composite action |
| Schema | The Context → Action → Result unit |
| ExtendedContext | Statistical tracking for context discovery |
| ExtendedResults | Statistical tracking for result discovery: P(item turns on \| taken) vs \| not taken |
| LocalConsistencyTracker | Streakiness of a schema's success; triggers synthetic items, including negative ones for reliable schemas that go locally unreliable |
| DijkstraPlanner, PlanSimulator | Goal-directed planning through the schema graph, plans checked by simulation |
The extended-context tables also yield overriding conditions: items that
make an otherwise reliable schema fail. Those are Minsky's anecdotal
censors, learned statistically. A comparison with the censor simulator, and
what it borrowed from this code, is in