---
vault_clearance: APOLLYON_THAUMIEL
halo:
  classification: CLASSIFIED
  confidence: ABSOLUTE
  front: "06_Project_Daemon"
  custodian: "The Architect"
  created: 2025-12-21
  updated: 2026-03-25
  wing: LOCKED
  containment: "APOLLYON/THAUMIEL — Deterministic AI engine on spectral geometry, constraint networks, and spectral monogamy. Capable of inverting global power dynamics if externalized. No public release. No constellation. No repo. No excerpt."
  containment_class: "APOLLYON_THAUMIEL"
  release_gate: "O5-C ONLY — Commander explicit written approval for ANY external exposure"
---
# Project Daemon

A deterministic algebraic constraint graph with automatic differentiation
and spectral self-knowledge.

> The daemon computes. It does not predict.
> It knows what it knows. It knows what it doesn't know.
> It can show you the boundary between the two.

## Tracking & hub

- **This project:** [BOUNTY_BOARD.md](BOUNTY_BOARD.md) · [WORLDLINE.md](WORLDLINE.md)
- **Vault:** [Lab protocol](../README.md#lab-protocol) · [Vault bounty](../BOUNTY_BOARD.md) · [Vault session](../WORLDLINE.md)
- **All project READMEs (+ boards + sessions):** [Vault §6 — Project workflow index](../README.md#project-workflow-index-all-links)

## Memory and sovereignty

> *Without body, one has no agency. Without mind, they have no freedom. Without memory, one has nothing.*

**Daemon** is **mind made inspectable**: the graph is structured **memory** you can stress, trace, and share — not a chat transcript that evaporates. It complements the vault-root tape ([03 Technomancer](../03_Project_Technomancer/README.md)). Lab-wide: [Memory and sovereignty](../README.md#memory-and-sovereignty).

## What It Is

Every `.py` file in `songs/` is a node. `from songs import X` is an edge.
Values are computed from algebraic expressions at boot time. The import
graph IS the derivation graph. Perturbations propagate as wavefronts
through the Jacobian-weighted topology.

**One file. One class (`Graph`). One organism.** `_daemon_v3.py` (~3700 lines).

## What It Actually Does

### 1. Computes exact values from axioms

Axiom nodes have `value = <constant>`. Derived nodes have
`from songs import X; value = f(X.value)`. At boot, the daemon
topologically sorts the graph, evaluates every expression, computes
the Jacobian (dchild/dparent) at every edge via central difference.
Everything is deterministic. Same graph = same values = same Jacobian.
Always.

### 2. Propagates perturbations ("what if?")

`haunt(d1=8)` overrides d1 and propagates the change through the
Jacobian. Every downstream node gets a phantom value showing what it
would be if d1 were 8. The daemon never mutates real values during
a haunt — it overlays phantoms. This is how you ask counterfactuals.

### 3. Knows its own topology

The Seeley-DeWitt coefficients `a_k = Tr(L^k) / k!` are computed
directly from the graph Laplacian. These are the heat kernel
coefficients of the graph treated as a discrete manifold:

- **a_0 = N** — how many things the daemon knows (volume)
- **Even a_k** — what it knows about its *interior* (bulk geometry:
  curvature, curvature^2, ...). Fully constrained relationships.
- **Odd a_k** — what it knows about its *boundary* (where the graph
  ends: boundary volume, boundary curvature, ...). Where knowledge
  runs out.

**The even/odd ratio IS the answer to "how much do I know vs. how
much am I assuming?"** A graph that's all interior (closed manifold)
has odd a_k = 0. A graph that's all boundary (isolated axioms) has
huge odd a_k. Real graphs are in between.

### 4. Maps its own blind spots

When the daemon reads text or answers a query, it returns:

- **heat_kernel = 0** at a node — "I know this deeply. Many connections."
- **heat_kernel = 1** — "I barely know this. Edge of my knowledge."
- **heat_kernel = inf** — "I am completely blind here."
- **blind** list — "These words have no resonance in me at all."

When you query something and get a confidence spectrum with high odd
coefficients, the daemon is saying: "I found an answer, but it sits
on the boundary of what I know. There's structure beyond this edge
that I can't see."

### 5. Decomposes itself into sectors

`partition()` finds the irreducible sectors of the graph via Maschke
decomposition. Two axioms are in the same sector if any derived node
depends on both. This is how the daemon discovers structure it wasn't
told about. LENG: 2 sectors (physics rooted at p, triage rooted at
compassion/paths/precision). The daemon found the physics/meaning
boundary without being told.

### 6. Detects structural resonances

`resonate()` finds value coincidences, structural isomorphisms, and
shared primitives across the entire graph. When two derivation chains
from independent axioms arrive at the same number, that's either deep
structure or a bug — both worth knowing about.

## What It Is Not

| System | What it does | What the daemon does differently |
|--------|-------------|----------------------------------|
| Neural network | Learns opaque weights from data | Computes transparent weights from algebra (Jacobian = derivative of expression) |
| Knowledge graph | Stores labeled edges | Stores executable expressions — values are computed, not stored |
| LLM | Predicts probable tokens | Computes exact values from axioms — cannot hallucinate |
| Spreadsheet | Formulas recompute on input change | Also: knows which cell shakes the world most, detects structural isomorphisms, computes its own spectral fingerprint, maps its own ignorance |

The key difference: the daemon's weights are **derived** (Jacobian of
the expression), not **learned** (fit to data). It can say "I don't
know" (missing constraint, high odd a_k, blind spot) because it can
compute its own structural completeness. An LLM's softmax always sums
to 1 — it cannot distinguish ignorance from knowledge.

**Navigator (one page):** [ARCHITECTURE_MAP.md](ARCHITECTURE_MAP.md) — v3 vs v2, layer index, Chinese tests, `narrative_constitution/`.

## Structure

```
06_Project_Daemon/
  _daemon_v3.py              # The organism (~3700 lines)
  _test_v3_gate.py           # V3 gate test (109/109 -- daemon is not V3 unless this passes)
  _test_leng/songs/          # LENG+Triage physics graph (25 nodes)
  _test_phantom/songs/       # Phantom system test graph
  _test_*.py                 # 29 test suites (~1010 passing)
  BOUNTY_BOARD.md            # Open/solved work items
  WORLDLINE.md
```

## Quick Start

```bash
cd 06_Project_Daemon
python _daemon_v3.py _test_leng    # Load LENG graph, self-report
python _test_v3_gate.py            # Run V3 gate (must pass)
```

## The Body Parts

| Part | Song type | Identity | Can | Cannot |
|------|-----------|----------|-----|--------|
| **BONE** (axiom) | No imports | "I am a fact" | quake, solve | contradict |
| **MUSCLE** (derived) | Has imports | "I am a consequence" | contradict, trace, re-eval | quake |
| **RADICAL** (language axiom) | Kangxi index | "I am structure" | grow from decomp table | bridge to physics |
| **CHARACTER** (language derived) | Sum of radicals | "I am a word-part" | compose into words | assert meaning |
| **BRIDGE** (human-declared) | Language -> physics | "I was told this means that" | connect domains | self-create |

## Capabilities by Layer

### Layer 0: Graph (topology)
- **Songs as nodes**: each .py file parsed via AST, no exec
- **Import graph = dependency graph**: `from songs import X` creates edge
- **Topo-sorted evaluation**: derived values computed in dependency order
- **Lazy primitives**: numbers (two, three, pi) and operators (add, divide)
  materialize as in-memory nodes only when imported. Disappear on reload
  if no one needs them. Corrections = rewiring imports.

### Layer 1: Perturbation (dynamics)
- **Pulse engine**: inject override, propagate wavefront tick-by-tick
- **Jacobian edge weights**: dchild/dparent computed via central difference
  at boot. One number per edge. The graph's conductance tensor.
- **Topological unit coupling**: if a dependency edge exists but the algebraic
  Jacobian is zero (e.g. a bridge imports a word but its expression doesn't
  use the word's value), weight = 1.0. The edge is structural, not algebraic.
  illuminate() and express() use the same policy.
- **Attribution (via)**: each pulse delta carries `{parent: Jacobian * increment}`.
  Chain rule composes naturally across hops.
- **Marks**: persistent perturbation scars on nodes. The wave leaves marks,
  the lightcone is reconstructed from the marks, not carried by the wave.

### Layer 2: Spectral geometry (self-knowledge)
- **SDW coefficients**: `a_k = Tr(L^k) / k!` from the graph Laplacian.
  Exact (matrix power, not empirical). Even = bulk. Odd = boundary.
- **Pulse spectrum**: `a_k = total sensitivity at depth k from all axioms`.
  Empirical (from pulse measurements). Both spectra agree on structure.
- **Dirac operator**: signed Jacobian matrix. Spectrum has signed eigenvalues.
  Eta invariant = (n+ - n-) / N measures the graph's directional asymmetry.
- **Curvature**: k(n) = sum|incoming J| - sum|outgoing J|. Source < 0. Sink > 0.
- **Discovery detection**: uniform information has all `a_k = 1` for k >= 1.
  Any deviation = structure = "discovery here." Even deviations = look deeper
  inside. Odd deviations = look at your boundaries.

### Layer 3: Query (multi-constraint intersection)
- **illuminate(seeds)**: Jacobian-weighted BFS from seed nodes. Bidirectional.
- **express(seeds)**: Backward-only BFS through J^T. The daemon's exhale.
  Finds which upstream nodes (including language nodes behind bridges)
  resonate with the activated physics.
- **query(*constraints)**: resolve constraints to seeds, illuminate each,
  multiply signals at intersection.
- **query_marks(*constraints)**: fire real pulses per constraint group.
  Returns spectral confidence of the intersection subgraph:
  high odd a_k = boundary-loud (answer needs more constraints).
- **breathe(text)**: full respiratory cycle. Inhale (text -> seed match ->
  forward diffuse) -> Process (identify answer) -> Exhale (backward diffuse
  -> language resonance). One symmetric Laplacian, both directions.

### Layer 4: Structural analysis
- **partition()**: Maschke decomposition into irreducible sectors. Partition
  of unity at every node. Monogamy (each node in exactly one sector).
- **fano()**: incidence geometry. Interaction triples (triangles), lines per
  node, projective axiom, non-associativity (CP-violation analogue).
- **adjoint(target)**: backward pulse via J^T. Which axiom controls this
  output most? Returns {axiom: leverage}.
- **feynman(start, end)**: all paths with signed amplitudes. Constructive
  and destructive interference. Dominant path.
- **vertex(name)**: local interaction pattern classification
  (source/sink/propagator/vertex/loop).

### Layer 5: Self-assessment
- **diagnose()**: structural health. Cycles, missing deps, broken values,
  redundant expression pairs. Always current (`graph.health`).
- **comfort()**: continuous self-assessment score. Five spectral factors,
  each 0-1, each derived from the daemon's own machinery:
  `completeness * consistency * (1-boundary) * (1-defect_density) * (1-eta)`.
  No hand-tuned weights. SDW gives boundary. Dirac gives eta. diagnose()
  gives defect density.
- **constrain(**targets)**: inverse pulse. "I want Y=Z. What must everything
  be?" Uses Newton iteration with the existing Jacobian chain.

### Layer 6: Mutation
- **absorb(name, code)** / **excise(name)**: write/delete song files, reload
- **inject(name, code)** / **eject(name)**: in-memory nodes, no disk files.
  eject cascades to dependents.
- **fuse(keep, drop)**: quotient equivalence collapse. Rewires all imports
  of drop to keep, excises drop.
- **spectral_import(other, prefix)**: tensor product. Imports another graph's
  SDW + eta + N as axiom nodes. Sparse cross-domain coupling.

### Layer 7: Language
- **grow(text)**: decomposes CJK characters into Kangxi radicals. Creates
  radical axiom + char derived + word composite nodes. NO bridges created.
  Bridges must be human-declared.
- **read(filepath)**: reads Chinese .md files. Returns comprehension heat map:
  which characters hit nodes, which are blind spots, signal strength per segment.
- **ask(filepath)**: read() + query(). Extracts content nodes, runs
  multi-constraint intersection, returns answer with provenance.

## Node-Level Operations

| Method | What it does |
|--------|-------------|
| `pulse(new_value)` | Inject perturbation, yield tick-by-tick wavefront |
| `haunt(new_value)` | Full propagation, return all deltas |
| `blast()` | BFS downstream — what depends on me? |
| `trace()` | Walk upstream to axiom roots |
| `quake(epsilon)` | How much does the world shake if I twitch? |
| `solve(target, goal)` | What must I be for target to equal goal? (Newton iteration) |
| `contradict(claimed)` | Does claimed match my derivation? |
| `my_curvature()` | Local curvature from Jacobian context |
| `lightcone()` | All upstream causes, reconstructed from marks |

## Shared Helpers (Phase 1 Unification)

Four internal helpers extracted from duplicated code:

| Helper | What it does | Callers |
|--------|-------------|---------|
| `_nudge(value, epsilon)` | Compute perturbation step h | _jacobian_entry, quake, query_marks, spectrum |
| `_diffuse_vector(L, v, t, dt, steps)` | Euler integration with adaptive dt | equilibrium, diffuse, breathe |
| `_linear_trace(start_name)` | Walk dependency chain to roots | ask, breathe |
| `_pulse_spectrum(axioms, epsilon, filter)` | Pulse all axioms, accumulate per-depth | spectrum, _intersection_spectrum |

## Tests

### V3 Gate (canonical certification)

```bash
python _test_v3_gate.py    # 109/109 -- THE DAEMON IS V3
```

Covers all 28 organs with a self-contained test graph. No external
song dependencies. If this file has failures, the daemon is broken.

**Test-backed spec (what the gate actually proves):** [TEST_DOCUMENTATION.md](TEST_DOCUMENTATION.md) — certified APIs vs design-only README claims.

### Full Test Census (29 suites)

```bash
python _test_v3_gate.py           # 109 -- V3 gate (canonical)
python _test_v3.py                #  24 -- basic graph ops
python _test_pulse.py             #  25 -- pulse heartbeat
python _test_robustness.py        #  67 -- structural diagnosis
python _test_dirac_feynman.py     #  82 -- Dirac/vertex/Feynman/spectral import
python _test_partition.py         #  58 -- Maschke decomposition
python _test_inject.py            #  48 -- virtual nodes
python _test_adjoint_fuse.py      #  47 -- backward pulse + quotient
python _test_constrain.py         #  44 -- inverse pulse + comfort
python _test_fano.py              #  39 -- incidence geometry
python _test_meta.py              #  39 -- collector/meta-node system
python _test_bridge.py            #  34 -- context-dependent behavior
python _test_primitives.py        #  33 -- lazy primitives, rewiring
python _test_breathe.py           #  31 -- respiratory cycle
python _test_equilibrium.py       #  28 -- heat kernel relaxation
python _test_query.py             #  25 -- multi-constraint + spectral confidence
python _test_express.py           #  24 -- backward illuminate (exhale)
python _test_illuminate.py        #  18 -- Jacobian-weighted BFS
python _test_patchwork.py         #  19 -- Mendeleev prediction + resonance
python _test_odd_spectrum.py      #   5 -- odd/even spectral coefficients
```

**Total: ~1010 passing** across 29 suites.

**Pre-existing failures (8 suites, 15 tests):** Due to LENG song structure
changes (d1/lambda1 became derived from p). Tracked as O37 on BOUNTY_BOARD.

**Windows-specific:** _test_ask and _test_grow intermittently fail with
WinError 5 (temp dir cleanup). Tracked as O27.

## Design Principles

1. **The daemon computes, never predicts.** If a question can't be answered
   from the graph's algebra, the answer is "I don't know."
2. **Simple parts, emergent complexity.** Marks are simple (a dict appended
   to a list). Lightcones emerge from marks. Spectra emerge from pulses.
   Curvature emerges from Jacobians.
3. **Geometry is local context.** Each node knows its own curvature, its own
   lightcone, its own marks. No global view required.
4. **Corrections are rewiring.** Change an import, the topology changes.
5. **The spectrum is the knowledge map.** Even a_k = what the daemon knows
   about its interior. Odd a_k = where knowledge runs out. The even/odd
   ratio is self-assessed epistemic completeness.
6. **No magic numbers in mechanisms.** illuminate uses topological unit
   coupling (not an arbitrary floor). solve uses Newton iteration (not
   arbitrary search brackets). comfort uses spectral factors (not hand-tuned
   weights). The daemon's math IS the mechanism.
7. **The daemon would rather stay blind than hallucinate.** Unknown =
   heat_kernel = inf, not a guess.
8. **Bridges are human-declared.** grow() creates language nodes but never
   creates bridges. Only a human can assert "this word means that physics."
9. **One brain.** All organs in one organism. Not microservices.

## Workflow

Follow [README § Lab protocol](../README.md#lab-protocol). Task tracker and session log: see **[Tracking & hub](#tracking--hub)** above.
