How eriktmueller/daydreamer works
1. Repository purpose
This repo implements DAYDREAMER, a Common Lisp goal-based agent that turns goals and input events into a narrated stream of inference, planning, emotion, and action. It is not a single monolith; it is split into a reusable reasoning kernel and the DAYDREAMER agent built on top of it.
2. Two main layers: GATE and DAYDREAMER
The gate_*.cl files are the generic reasoning/representation engine. The dd_*.cl files are the DAYDREAMER-specific agent logic that uses GATE for types, objects, unification, proof, and context management. This separation is the key architectural boundary in the repo.
3. Core runtime model: contexts and sprouting
The system operates over nested “contexts” (CX) rather than a flat global state. A new plan or subgoal typically “sprouts” a new context from the current one, carrying forward relevant facts while adding goal-specific structure. The trace in the README shows this as CX.4 -> CX.5 -> CX.6, which is central to how planning is isolated and reversible.
4. Knowledge representation and inference
GATE provides the symbolic backbone: types, objects, facts, rules, instantiation, and unification. The files gate_ty.cl, gate_obs.cl, gate_unify.cl, gate_instan.cl, gate_prove.cl, and gate_read_pr.cl indicate a rule/proof engine that can parse and execute logical forms, match them against current context, and assert/retract derived beliefs or goals.
5. DAYDREAMER agent behavior
The DAYDREAMER layer adds the agent’s “mind”: control loop, episodic memory, emotion handling, goal management, daydreaming modes, reversal/rationalization behavior, and domain-specific rules. Files like dd_cntrl.cl, dd_epis.cl, dd_night.cl, dd_reversal.cl, dd_mutation.cl, dd_rule1.cl, and dd_rule2.cl suggest distinct behavioral subsystems rather than one planner.
6. Goal lifecycle
The main flow is: infer unmet needs or triggers, activate a top-level concern, select a plan, decompose into subgoals, perform actions, then mark the goal succeeded or failed. The README’s trace shows explicit statuses like HALTED, RUNABLE, WAITING, SUCCEEDED-GOAL, and the control loop re-evaluates concerns based on motivation and emotional state.
7. Emotion as control signal
Emotions are not decorative output; they are part of the decision mechanism. Goals can create motivating emotions, and successful completion can generate positive emotions and remove prior motivation. This means the architecture couples belief/planning state to affect state, with emotion influencing which concern becomes the active focus.
8. Planning and action execution
Plans are rule-driven. A high-level goal can be rewritten into a lower-level subgoal, and then into an action goal with preconditions. The README examples show this chain clearly: ENTERTAINMENT -> M-MOVIE, or HACK -> FTP -> RTRUE. The architecture therefore has a hierarchical planner plus an action layer that only performs “real action” when in performance mode.
9. Episodic memory and learning
After goal completion, the agent stores episodes, links them to the rules that produced them, and indexes them by objects, emotions, and goals. dd_epis.cl is likely the memory store/retrieval subsystem, allowing future planning to reuse prior episodes or support analogical reasoning and serendipitous recall.
10. Language generation and narrated traces
dd_gen.cl is the English generator. It converts asserted facts, goal changes, and completed actions into human-readable narration, which is why the runtime output is a detailed prose trace rather than a silent state machine. This is a separate subsystem from reasoning: the agent reasons symbolically, then verbalizes the results.
11. Initialization and knowledge base
dd_kb.cl and the sample input files (inputlovers*.txt, inputemployment1.txt, inputrecovery3.txt, etc.) define the initial world model, personal goals, and scenario-specific facts. The README’s examples show that loading dd or dd_get starts from a prepared initial reality context with built-in needs and themes.
12. Build/load and test structure
The repo supports both interpreted loading and compiled operation. gate_compile.cl and dd_compile.cl are the compilation entry points, while gate_get.cl and dd_get.cl are the loadable runtime entry points. gate_test.cl is the test suite, and files like hello_world.cl demonstrate how to extend the system by defining new types, needs, rules, and generation templates.
13. External interaction boundary
The only “interface” is a Lisp REPL plus textual inputs/outputs. Inputs are either scripted scenario files or parser-entered concepts; outputs are the generated English trace and the console state log. There is no evidence of a web/UI layer, database, or network service in this repo.
14. How to draw the architecture
A useful diagram would show: REPL/load scripts on the left, GATE reasoning core in the middle, DAYDREAMER agent logic on top of it, and a loop connecting inference → goal activation → planning → action/performance → episodic memory → generation. The main boundary is between the generic symbolic engine (gate_*) and the agent-specific behavioral layer (dd_*).
Main entry points: gate_main.cl Kernel core · dd_cntrl.cl Control loop · dd.cl Agent core · gate_prove.cl Prove
Components 22
Interface
Load/compile entry points and REPL-facing scripts.
- DD load · Loadable entry point for the DAYDREAMER agent.
dd_get.cl - DD compile · Compilation entry point for the DAYDREAMER layer.
dd_compile.cl - GATE load · Loadable entry point for the generic GATE kernel.
gate_get.cl - GATE compile · Compilation entry point for the GATE kernel.
gate_compile.cl
GATE Core
Generic symbolic reasoning kernel for contexts, types, matching, proof, and parsing.
- Kernel core · Top-level orchestration for the symbolic reasoning engine.
gate_main.cl - Contexts · Nested context structure used for sprouting, scoping, and reversible reasoning.
gate_cx.cl - Types · Symbolic type hierarchy and representation backbone.
gate_ty.cl - Objects · Object and fact representation shared by rules and inference.
gate_obs.cl - Unify · Unification and symbolic matching for logical forms.
gate_unify.cl - Instantiate · Builds concrete instances from abstract logical structures.
gate_instan.cl - Prove · Rule execution and proof search over the current context.
gate_prove.cl - Parser · Reads and interprets logical forms for the proof engine.
gate_read_pr.cl
DAYDREAMER
Agent-specific control, knowledge, emotion, memory, and narration built on GATE.
- Agent core · DAYDREAMER-specific behavior built on the generic GATE kernel.
dd.cl - Knowledge base · Built-in scenario facts, goals, and starting state.
dd_kb.cl - Control loop · Chooses the active concern, evaluates status, and drives the goal lifecycle.
dd_cntrl.cl - Episodic memory · Stores and retrieves episodes, outcomes, and learned associations.
dd_epis.cl - Generator · Turns internal state changes into English narration.
dd_gen.cl - Rules 1 · Primary agent rules for goal rewrites and behavior selection.
dd_rule1.cl - Rules 2 · Additional rule set for planning, emotion, and action selection.
dd_rule2.cl - Night mode · Non-daytime or idle-mode behavior and transitions.
dd_night.cl - Reversal · Rationalization and reversal behavior when outcomes change or need reinterpretation.
dd_reversal.cl - Mutation · Transforms goals or plans when conditions require adjustment.
dd_mutation.cl
Connections 26
- DD load → Agent core: loads · Runtime entry loads the DAYDREAMER layer.
- DD compile → Agent core: builds · Compilation entry builds the DAYDREAMER layer.
- GATE load → Kernel core: loads · Runtime entry loads the GATE kernel.
- GATE compile → Kernel core: builds · Compilation entry builds the GATE kernel.
- Agent core → Kernel core: uses · DAYDREAMER delegates symbolic work to the generic kernel.
- Kernel core → Contexts: manages · The kernel organizes reasoning around nested contexts.
- Kernel core → Types: defines · Kernel core depends on the type system.
- Kernel core → Objects: stores · Kernel core works over objects and facts.
- Kernel core → Unify: matches · Unification supports inference and rule firing.
- Kernel core → Instantiate: instantiates · Abstract forms are turned into concrete instances.
- Kernel core → Prove: proves · Proof search drives symbolic inference.
- Kernel core → Parser: parses · Logical input is read into the reasoning engine.
- Agent core → Knowledge base: starts from · The agent boots from its built-in knowledge base.
- Agent core → Control loop: runs · The control loop is the agent's main runtime behavior.
- Agent core → Generator: narrates · The agent verbalizes internal state changes and outcomes.
- Agent core → Episodic memory: records · Episodes are stored for later reuse and recall.
- Control loop → Contexts: sprouts · Planning and subgoaling occur by creating new contexts.
- Control loop → Prove: queries · Control asks the proof engine what follows next.
- Control loop → Rules 1: applies · Primary behavioral rules shape goal activation and rewriting.
- Control loop → Rules 2: applies · Secondary rule set supports planning and action selection.
- Control loop → Night mode: switches · Control can move into a night/idle behavioral mode.
- Control loop → Reversal: revises · Control can rationalize or reverse prior conclusions.
- Control loop → Mutation: adapts · Control can mutate goals and plans to fit current conditions.
- Rules 1 → Unify: matches · Rules rely on unification to bind goal patterns.
- Rules 2 → Prove: derives · Rules feed the inference engine with goal rewrites.
- Episodic memory → Generator: reports · Memory can be surfaced through narration.