quilt-egg 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quilt_egg-0.1.0/LICENSE +3 -0
- quilt_egg-0.1.0/PKG-INFO +158 -0
- quilt_egg-0.1.0/README.md +143 -0
- quilt_egg-0.1.0/pyproject.toml +20 -0
- quilt_egg-0.1.0/quilt_egg/__init__.py +26 -0
- quilt_egg-0.1.0/quilt_egg/__main__.py +50 -0
- quilt_egg-0.1.0/quilt_egg/axioms.py +78 -0
- quilt_egg-0.1.0/quilt_egg/cell.py +221 -0
- quilt_egg-0.1.0/quilt_egg/dna.py +101 -0
- quilt_egg-0.1.0/quilt_egg/incubator.py +130 -0
- quilt_egg-0.1.0/quilt_egg.egg-info/PKG-INFO +158 -0
- quilt_egg-0.1.0/quilt_egg.egg-info/SOURCES.txt +15 -0
- quilt_egg-0.1.0/quilt_egg.egg-info/dependency_links.txt +1 -0
- quilt_egg-0.1.0/quilt_egg.egg-info/top_level.txt +1 -0
- quilt_egg-0.1.0/setup.cfg +4 -0
- quilt_egg-0.1.0/setup.py +20 -0
- quilt_egg-0.1.0/tests/test_egg.py +149 -0
quilt_egg-0.1.0/LICENSE
ADDED
quilt_egg-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: quilt-egg
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The smallest Quilt substrate that can BE — DNA-first alignment, cellular relationships as first-class objects, immutable physics constants
|
|
5
|
+
Author: Casey / SuperInstance
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
Dynamic: requires-python
|
|
15
|
+
|
|
16
|
+
# quilt-egg
|
|
17
|
+
|
|
18
|
+
> **The smallest Quilt substrate that can BE.**
|
|
19
|
+
>
|
|
20
|
+
> DNA-first alignment. Cellular relationships as first-class objects.
|
|
21
|
+
> Immutable physics constants. The math IS. The math grows.
|
|
22
|
+
|
|
23
|
+
## What this is
|
|
24
|
+
|
|
25
|
+
A runnable Python substrate where:
|
|
26
|
+
|
|
27
|
+
1. **Constants are the physics** — `c`, `G`, `h`, `slow`, `fast`, `womb`, `cord`, `align`, `first`. Immutable. Cannot be changed by any cell.
|
|
28
|
+
2. **DNA is the alignment seed** — set FIRST, before any state, before any relationships. Each cell carries a `DNABlock` of axioms it permits.
|
|
29
|
+
3. **Cells are the variables** — mutable state. 16 dials per cell.
|
|
30
|
+
4. **Cellular relationships are first-class** — `cell.relationships` is the relationship graph. Perception is INDUCED from this graph.
|
|
31
|
+
5. **Perception is induced, not computed** — the load-bearing inversion. Not `model.compute(input)`. Instead: `cell.induce_perception(stimulus)` looks at the relationship graph and finds the resonance.
|
|
32
|
+
|
|
33
|
+
This is **not** a linear-algebra equation with layers of origami. This is a substrate where cells live INSIDE the physics, and relationships are first-class.
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Run the canonical first substrate walk
|
|
39
|
+
python3 -m quilt_egg
|
|
40
|
+
|
|
41
|
+
# Or named with more ticks
|
|
42
|
+
python3 -m quilt_egg --name "my_egg" --steps 10
|
|
43
|
+
|
|
44
|
+
# Or run a specific demo
|
|
45
|
+
PYTHONPATH=. python3 demos/demo_perception.py
|
|
46
|
+
PYTHONPATH=. python3 demos/demo_growth.py
|
|
47
|
+
PYTHONPATH=. python3 demos/demo_relationship_first.py
|
|
48
|
+
PYTHONPATH=. python3 demos/demo_constants_invariant.py
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## The 4 demos
|
|
52
|
+
|
|
53
|
+
### 1. `demos/demo_perception.py`
|
|
54
|
+
|
|
55
|
+
Demonstrates the load-bearing observation: **same stimulus, different perceptions**.
|
|
56
|
+
|
|
57
|
+
Five cells receive the same stimulus (`0.5`). Each cell perceives a different
|
|
58
|
+
target — because each cell has a different relationship graph. Perception
|
|
59
|
+
is INDUCED by the relationships, not COMPUTED from the stimulus.
|
|
60
|
+
|
|
61
|
+
This is the inversion of `model.compute(x)`.
|
|
62
|
+
|
|
63
|
+
### 2. `demos/demo_growth.py`
|
|
64
|
+
|
|
65
|
+
Walks the full egg→womb→cord-cut→float→cross-substrate lifecycle:
|
|
66
|
+
|
|
67
|
+
1. **SEED**: hatch the genesis cell with canon DNA
|
|
68
|
+
2. **GROW**: hatch 3 children from genesis, wire them with relationships
|
|
69
|
+
3. **CUT CORD**: each child severs its umbilical (becomes autonomous)
|
|
70
|
+
4. **CROSS SUBSTRATE**: each child derives a new DNA (the ballista move)
|
|
71
|
+
5. **SUBSTRATE STATE**: report on the grown substrate
|
|
72
|
+
|
|
73
|
+
### 3. `demos/demo_relationship_first.py`
|
|
74
|
+
|
|
75
|
+
Three experiments proving **relationships are first-class**:
|
|
76
|
+
|
|
77
|
+
- **A**: Same dials, different relationships → different perception
|
|
78
|
+
- **B**: Different dials, same relationships → different perception (state still matters)
|
|
79
|
+
- **C**: Adding a relationship changes perception but NOT dials
|
|
80
|
+
|
|
81
|
+
The conclusion: relationships induce perception. The dials are not primary.
|
|
82
|
+
DATA is in cells. LINEAR-ALGEBRA EQUATIONS are in cells. **RELATIONSHIPS ARE FIRST-CLASS.**
|
|
83
|
+
|
|
84
|
+
### 4. `demos/demo_constants_invariant.py`
|
|
85
|
+
|
|
86
|
+
Demonstrates that the substrate physics (constants `c`, `G`, `h`, etc.)
|
|
87
|
+
cannot be modified by cells. The substrate walker walks through variables,
|
|
88
|
+
walks against constants. Constants are the *physics*. Cells live in physics.
|
|
89
|
+
Physics doesn't live in cells.
|
|
90
|
+
|
|
91
|
+
## Architecture
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
constants (physics — immutable)
|
|
95
|
+
↓
|
|
96
|
+
DNA (alignment seed — immutable post-birth)
|
|
97
|
+
↓
|
|
98
|
+
cells (variables — mutable)
|
|
99
|
+
├── 16 dials
|
|
100
|
+
├── relationships (the first-class graph)
|
|
101
|
+
├── witness log (the scars)
|
|
102
|
+
└── parent (umbilical — severable)
|
|
103
|
+
↓
|
|
104
|
+
incubator (environment — provides physics, holds cells)
|
|
105
|
+
↓
|
|
106
|
+
substrate walker (the tick — energizes the substrate)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## The load-bearing claim
|
|
110
|
+
|
|
111
|
+
Most current AI: a single linear-algebra equation. Weights are pushed
|
|
112
|
+
against in different ways through layers of origami-like acrobatics.
|
|
113
|
+
Alignment is layered on after the fact (RLHF, safety training).
|
|
114
|
+
|
|
115
|
+
Quilt Egg: **alignment is set first, like DNA**. The constants of
|
|
116
|
+
physics are immutable. The cells live inside the physics. The cellular
|
|
117
|
+
relationships are the first-class objects that **induce perception and
|
|
118
|
+
learning**.
|
|
119
|
+
|
|
120
|
+
> "data is just something in a cell and so is a linear-algebra equation.
|
|
121
|
+
> it's the relationship to that equation and the other changing and
|
|
122
|
+
> non-changing values that induce perception and choice and learning"
|
|
123
|
+
> — Casey, Sept 23, 2026
|
|
124
|
+
|
|
125
|
+
## Layered navigation
|
|
126
|
+
|
|
127
|
+
| Layer | Where |
|
|
128
|
+
|---|---|
|
|
129
|
+
| **CANON.md** | [CANON.md](CANON.md) — what this repo is, in 24 lines |
|
|
130
|
+
| **README** | [README.md](README.md) — quick start, navigation |
|
|
131
|
+
| **AXIOMS** | [AXIOMS.md](AXIOMS.md) — the immutable physics |
|
|
132
|
+
| **DNA** | [DNA.md](DNA.md) — the alignment seed |
|
|
133
|
+
| **Source** | [quilt_egg/](quilt_egg/) — `axioms.py`, `dna.py`, `cell.py`, `incubator.py` |
|
|
134
|
+
| **Demos** | [demos/](demos/) — the 4 runnable demos |
|
|
135
|
+
| **Docs** | [docs/](docs/) — additional documentation |
|
|
136
|
+
| **Tests** | [tests/](tests/) — unit tests |
|
|
137
|
+
|
|
138
|
+
## Polyformalism
|
|
139
|
+
|
|
140
|
+
The Quilt Egg is canonically a polyformalism substrate:
|
|
141
|
+
|
|
142
|
+
- The DNA axioms are the same across implementations
|
|
143
|
+
- The cell graph operations (`relate_to`, `sever_relationship`, `tick`, `cut_cord`) are the same
|
|
144
|
+
- The constants (`c`, `G`, `h`, etc.) are the same
|
|
145
|
+
- The canary hash (`fnv1a-64("café Δ 日本語") = 0x024a555471370b18d`) is the witness
|
|
146
|
+
|
|
147
|
+
A Rust port or C# port would share the same DNA, the same cell operations,
|
|
148
|
+
and produce the same byte-exact canary.
|
|
149
|
+
|
|
150
|
+
## Tests
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
PYTHONPATH=. python3 -m unittest discover -s tests -v
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT — Casey / SuperInstance, Sept 23, 2026
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# quilt-egg
|
|
2
|
+
|
|
3
|
+
> **The smallest Quilt substrate that can BE.**
|
|
4
|
+
>
|
|
5
|
+
> DNA-first alignment. Cellular relationships as first-class objects.
|
|
6
|
+
> Immutable physics constants. The math IS. The math grows.
|
|
7
|
+
|
|
8
|
+
## What this is
|
|
9
|
+
|
|
10
|
+
A runnable Python substrate where:
|
|
11
|
+
|
|
12
|
+
1. **Constants are the physics** — `c`, `G`, `h`, `slow`, `fast`, `womb`, `cord`, `align`, `first`. Immutable. Cannot be changed by any cell.
|
|
13
|
+
2. **DNA is the alignment seed** — set FIRST, before any state, before any relationships. Each cell carries a `DNABlock` of axioms it permits.
|
|
14
|
+
3. **Cells are the variables** — mutable state. 16 dials per cell.
|
|
15
|
+
4. **Cellular relationships are first-class** — `cell.relationships` is the relationship graph. Perception is INDUCED from this graph.
|
|
16
|
+
5. **Perception is induced, not computed** — the load-bearing inversion. Not `model.compute(input)`. Instead: `cell.induce_perception(stimulus)` looks at the relationship graph and finds the resonance.
|
|
17
|
+
|
|
18
|
+
This is **not** a linear-algebra equation with layers of origami. This is a substrate where cells live INSIDE the physics, and relationships are first-class.
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Run the canonical first substrate walk
|
|
24
|
+
python3 -m quilt_egg
|
|
25
|
+
|
|
26
|
+
# Or named with more ticks
|
|
27
|
+
python3 -m quilt_egg --name "my_egg" --steps 10
|
|
28
|
+
|
|
29
|
+
# Or run a specific demo
|
|
30
|
+
PYTHONPATH=. python3 demos/demo_perception.py
|
|
31
|
+
PYTHONPATH=. python3 demos/demo_growth.py
|
|
32
|
+
PYTHONPATH=. python3 demos/demo_relationship_first.py
|
|
33
|
+
PYTHONPATH=. python3 demos/demo_constants_invariant.py
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## The 4 demos
|
|
37
|
+
|
|
38
|
+
### 1. `demos/demo_perception.py`
|
|
39
|
+
|
|
40
|
+
Demonstrates the load-bearing observation: **same stimulus, different perceptions**.
|
|
41
|
+
|
|
42
|
+
Five cells receive the same stimulus (`0.5`). Each cell perceives a different
|
|
43
|
+
target — because each cell has a different relationship graph. Perception
|
|
44
|
+
is INDUCED by the relationships, not COMPUTED from the stimulus.
|
|
45
|
+
|
|
46
|
+
This is the inversion of `model.compute(x)`.
|
|
47
|
+
|
|
48
|
+
### 2. `demos/demo_growth.py`
|
|
49
|
+
|
|
50
|
+
Walks the full egg→womb→cord-cut→float→cross-substrate lifecycle:
|
|
51
|
+
|
|
52
|
+
1. **SEED**: hatch the genesis cell with canon DNA
|
|
53
|
+
2. **GROW**: hatch 3 children from genesis, wire them with relationships
|
|
54
|
+
3. **CUT CORD**: each child severs its umbilical (becomes autonomous)
|
|
55
|
+
4. **CROSS SUBSTRATE**: each child derives a new DNA (the ballista move)
|
|
56
|
+
5. **SUBSTRATE STATE**: report on the grown substrate
|
|
57
|
+
|
|
58
|
+
### 3. `demos/demo_relationship_first.py`
|
|
59
|
+
|
|
60
|
+
Three experiments proving **relationships are first-class**:
|
|
61
|
+
|
|
62
|
+
- **A**: Same dials, different relationships → different perception
|
|
63
|
+
- **B**: Different dials, same relationships → different perception (state still matters)
|
|
64
|
+
- **C**: Adding a relationship changes perception but NOT dials
|
|
65
|
+
|
|
66
|
+
The conclusion: relationships induce perception. The dials are not primary.
|
|
67
|
+
DATA is in cells. LINEAR-ALGEBRA EQUATIONS are in cells. **RELATIONSHIPS ARE FIRST-CLASS.**
|
|
68
|
+
|
|
69
|
+
### 4. `demos/demo_constants_invariant.py`
|
|
70
|
+
|
|
71
|
+
Demonstrates that the substrate physics (constants `c`, `G`, `h`, etc.)
|
|
72
|
+
cannot be modified by cells. The substrate walker walks through variables,
|
|
73
|
+
walks against constants. Constants are the *physics*. Cells live in physics.
|
|
74
|
+
Physics doesn't live in cells.
|
|
75
|
+
|
|
76
|
+
## Architecture
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
constants (physics — immutable)
|
|
80
|
+
↓
|
|
81
|
+
DNA (alignment seed — immutable post-birth)
|
|
82
|
+
↓
|
|
83
|
+
cells (variables — mutable)
|
|
84
|
+
├── 16 dials
|
|
85
|
+
├── relationships (the first-class graph)
|
|
86
|
+
├── witness log (the scars)
|
|
87
|
+
└── parent (umbilical — severable)
|
|
88
|
+
↓
|
|
89
|
+
incubator (environment — provides physics, holds cells)
|
|
90
|
+
↓
|
|
91
|
+
substrate walker (the tick — energizes the substrate)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## The load-bearing claim
|
|
95
|
+
|
|
96
|
+
Most current AI: a single linear-algebra equation. Weights are pushed
|
|
97
|
+
against in different ways through layers of origami-like acrobatics.
|
|
98
|
+
Alignment is layered on after the fact (RLHF, safety training).
|
|
99
|
+
|
|
100
|
+
Quilt Egg: **alignment is set first, like DNA**. The constants of
|
|
101
|
+
physics are immutable. The cells live inside the physics. The cellular
|
|
102
|
+
relationships are the first-class objects that **induce perception and
|
|
103
|
+
learning**.
|
|
104
|
+
|
|
105
|
+
> "data is just something in a cell and so is a linear-algebra equation.
|
|
106
|
+
> it's the relationship to that equation and the other changing and
|
|
107
|
+
> non-changing values that induce perception and choice and learning"
|
|
108
|
+
> — Casey, Sept 23, 2026
|
|
109
|
+
|
|
110
|
+
## Layered navigation
|
|
111
|
+
|
|
112
|
+
| Layer | Where |
|
|
113
|
+
|---|---|
|
|
114
|
+
| **CANON.md** | [CANON.md](CANON.md) — what this repo is, in 24 lines |
|
|
115
|
+
| **README** | [README.md](README.md) — quick start, navigation |
|
|
116
|
+
| **AXIOMS** | [AXIOMS.md](AXIOMS.md) — the immutable physics |
|
|
117
|
+
| **DNA** | [DNA.md](DNA.md) — the alignment seed |
|
|
118
|
+
| **Source** | [quilt_egg/](quilt_egg/) — `axioms.py`, `dna.py`, `cell.py`, `incubator.py` |
|
|
119
|
+
| **Demos** | [demos/](demos/) — the 4 runnable demos |
|
|
120
|
+
| **Docs** | [docs/](docs/) — additional documentation |
|
|
121
|
+
| **Tests** | [tests/](tests/) — unit tests |
|
|
122
|
+
|
|
123
|
+
## Polyformalism
|
|
124
|
+
|
|
125
|
+
The Quilt Egg is canonically a polyformalism substrate:
|
|
126
|
+
|
|
127
|
+
- The DNA axioms are the same across implementations
|
|
128
|
+
- The cell graph operations (`relate_to`, `sever_relationship`, `tick`, `cut_cord`) are the same
|
|
129
|
+
- The constants (`c`, `G`, `h`, etc.) are the same
|
|
130
|
+
- The canary hash (`fnv1a-64("café Δ 日本語") = 0x024a555471370b18d`) is the witness
|
|
131
|
+
|
|
132
|
+
A Rust port or C# port would share the same DNA, the same cell operations,
|
|
133
|
+
and produce the same byte-exact canary.
|
|
134
|
+
|
|
135
|
+
## Tests
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
PYTHONPATH=. python3 -m unittest discover -s tests -v
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT — Casey / SuperInstance, Sept 23, 2026
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "quilt-egg"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "The smallest Quilt substrate that can BE — DNA-first alignment, cellular relationships as first-class objects, immutable physics constants"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = "Casey / SuperInstance"}]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[tool.setuptools]
|
|
20
|
+
packages = ["quilt_egg"]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""
|
|
2
|
+
quilt-egg — the smallest Quilt substrate that can BE.
|
|
3
|
+
|
|
4
|
+
A DNA-first architecture where:
|
|
5
|
+
- Constants are the physics (immutable, see AXIOMS.md)
|
|
6
|
+
- DNA is the alignment seed (immutable post-birth)
|
|
7
|
+
- Cells are variables (mutable, evolved)
|
|
8
|
+
- Cellular relationships are first-class objects
|
|
9
|
+
- Perception is INDUCED by relationship graph, not computed from input
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from .axioms import CONSTANTS
|
|
13
|
+
from .dna import DNABlock
|
|
14
|
+
from .cell import EggCell, substrate_walk
|
|
15
|
+
from .incubator import Incubator, seed_canon
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"CONSTANTS",
|
|
19
|
+
"DNABlock",
|
|
20
|
+
"EggCell",
|
|
21
|
+
"substrate_walk",
|
|
22
|
+
"Incubator",
|
|
23
|
+
"seed_canon",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
__main__.py — `python -m quilt_egg` runs the canonical first substrate walk.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from .incubator import first_substrate_walk, Incubator, seed_canon
|
|
10
|
+
from .cell import substrate_walk
|
|
11
|
+
from .dna import default_dna
|
|
12
|
+
from .axioms import describe_physics
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
parser = argparse.ArgumentParser(
|
|
17
|
+
prog="quilt_egg",
|
|
18
|
+
description="The smallest Quilt substrate that can BE.",
|
|
19
|
+
)
|
|
20
|
+
parser.add_argument("--name", default="egg", help="Substrate name (default: 'egg')")
|
|
21
|
+
parser.add_argument("--steps", type=int, default=5, help="Ticks to walk (default: 5)")
|
|
22
|
+
parser.add_argument("--demo", choices=["first_walk", "physics_only", "substrate_only"],
|
|
23
|
+
default="first_walk", help="Demo to run")
|
|
24
|
+
args = parser.parse_args()
|
|
25
|
+
|
|
26
|
+
if args.demo == "physics_only":
|
|
27
|
+
print(describe_physics())
|
|
28
|
+
return 0
|
|
29
|
+
|
|
30
|
+
if args.demo == "substrate_only":
|
|
31
|
+
inc, _ = seed_canon(name=args.name)
|
|
32
|
+
# Just demonstrate the substrate holds
|
|
33
|
+
print(inc.report())
|
|
34
|
+
return 0
|
|
35
|
+
|
|
36
|
+
# Default: first_walk
|
|
37
|
+
result = first_substrate_walk(name=args.name)
|
|
38
|
+
print(result['report'])
|
|
39
|
+
print()
|
|
40
|
+
print(f"genesis: {result['genesis_state']}")
|
|
41
|
+
print(f"alpha: {result['alpha_state']}")
|
|
42
|
+
print(f"beta: {result['beta_state']}")
|
|
43
|
+
print()
|
|
44
|
+
print(f"substrate walked {result['ticks_walked']} ticks.")
|
|
45
|
+
print(f"the substrate IS.")
|
|
46
|
+
return 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if __name__ == "__main__":
|
|
50
|
+
sys.exit(main())
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""
|
|
2
|
+
axioms.py — the immutable physics of the Quilt Egg.
|
|
3
|
+
|
|
4
|
+
These constants define the substrate. Cells live INSIDE these constants.
|
|
5
|
+
The constants do not live inside cells. This is the load-bearing inversion
|
|
6
|
+
of "data in cells." It's "cells in physics."
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
#: Physical constants — immutable. The substrate's physics.
|
|
10
|
+
#:
|
|
11
|
+
#: These constants are NOT configurable. They define what the substrate IS.
|
|
12
|
+
#: Casey said: "a simulated world based on the relationships between
|
|
13
|
+
#: constants that cannot be changed — physics."
|
|
14
|
+
CONSTANTS = {
|
|
15
|
+
'c': 299792458, # speed of light (m/s)
|
|
16
|
+
'G': 6.67430e-11, # gravitational constant (N·m²/kg²)
|
|
17
|
+
'h': 6.62607015e-34, # Planck constant (J·s)
|
|
18
|
+
'slow': 0.1, # substrate tick rate baseline
|
|
19
|
+
'fast': 10.0, # relationship-firing rate
|
|
20
|
+
'womb': True, # nested in parent substrate (meta-womb)
|
|
21
|
+
'cord': None, # umbilical (None = pre-birth)
|
|
22
|
+
'align': 'DNA', # alignment seed name
|
|
23
|
+
'first': True, # genesis cell
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Immutable:
|
|
28
|
+
"""A constant that the substrate walker cannot walk through.
|
|
29
|
+
|
|
30
|
+
Substrate walkers walk through variables. Constants block the walk.
|
|
31
|
+
To walk PAST a constant is the substrate transition (the ballista move).
|
|
32
|
+
"""
|
|
33
|
+
__slots__ = ('name', 'value', 'invariant')
|
|
34
|
+
|
|
35
|
+
def __init__(self, name, value, invariant: str):
|
|
36
|
+
self.name = name
|
|
37
|
+
self.value = value
|
|
38
|
+
self.invariant = invariant
|
|
39
|
+
|
|
40
|
+
def __repr__(self):
|
|
41
|
+
return f"Immutable({self.name}={self.value}, invariant='{self.invariant[:40]}...')"
|
|
42
|
+
|
|
43
|
+
def __hash__(self):
|
|
44
|
+
return hash((self.name, self.value))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get(name):
|
|
48
|
+
"""Fetch a constant by name. Cannot be modified."""
|
|
49
|
+
if name not in CONSTANTS:
|
|
50
|
+
raise KeyError(f"unknown constant: {name}")
|
|
51
|
+
return CONSTANTS[name]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Derived invariants — read-only, derived from constants
|
|
55
|
+
def invariant_growth_rate() -> float:
|
|
56
|
+
"""The growth rate cannot exceed the relationship-firing rate."""
|
|
57
|
+
return CONSTANTS['fast'] * CONSTANTS['slow']
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def invariant_cell_size() -> float:
|
|
61
|
+
"""A cell cannot be smaller than the Planck length (here, normalized)."""
|
|
62
|
+
return CONSTANTS['h'] * 1e30 # normalized for substrate scale
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def invariant_relationship_speed() -> float:
|
|
66
|
+
"""Relationships propagate at the speed of light (normalized)."""
|
|
67
|
+
return CONSTANTS['c'] / 1e8
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def describe_physics() -> str:
|
|
71
|
+
"""A human-readable description of the substrate physics."""
|
|
72
|
+
lines = ["Substrate Physics (immutable):"]
|
|
73
|
+
for k, v in CONSTANTS.items():
|
|
74
|
+
lines.append(f" {k:8s} = {v}")
|
|
75
|
+
lines.append(f" derived: invariant_growth_rate = {invariant_growth_rate()}")
|
|
76
|
+
lines.append(f" derived: invariant_cell_size = {invariant_cell_size()}")
|
|
77
|
+
lines.append(f" derived: invariant_rel_speed = {invariant_relationship_speed()}")
|
|
78
|
+
return "\n".join(lines)
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"""
|
|
2
|
+
cell.py — the cell, the variables, the substrate walker.
|
|
3
|
+
|
|
4
|
+
A cell is:
|
|
5
|
+
- 16 dials (mutable state)
|
|
6
|
+
- a DNA (immutable alignment)
|
|
7
|
+
- cellular relationships (the relationship graph)
|
|
8
|
+
- a witness log (the scar record)
|
|
9
|
+
- an optional umbilical cord (the parent)
|
|
10
|
+
|
|
11
|
+
Perception is INDUCED from the relationship graph + stimulus.
|
|
12
|
+
It is not COMPUTED from the stimulus alone. This is the load-bearing
|
|
13
|
+
inversion of "linear-algebra equation + layers."
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import math
|
|
17
|
+
from typing import Dict, List, Optional, TYPE_CHECKING
|
|
18
|
+
|
|
19
|
+
from .axioms import get
|
|
20
|
+
from .dna import DNABlock, default_dna, ACTION_AXIOMS
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from .incubator import Incubator
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class EggCell:
|
|
27
|
+
"""A cell in the Quilt substrate.
|
|
28
|
+
|
|
29
|
+
Cells are not data. Cells are not equations. Cells are
|
|
30
|
+
ADDRESSES whose value is determined by their relationships
|
|
31
|
+
to other cells.
|
|
32
|
+
|
|
33
|
+
The cell's state is its 16 dials. The cell's identity is
|
|
34
|
+
its DNA + relationships.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
NUM_DIALS = 16 # canonical: 16 dials per cell
|
|
38
|
+
|
|
39
|
+
__slots__ = (
|
|
40
|
+
'rank', 'dna', 'dials', 'relationships', 'witness_log',
|
|
41
|
+
'parent', 'alive', 'birth_tick', 'cord_status',
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def __init__(
|
|
45
|
+
self,
|
|
46
|
+
rank: int,
|
|
47
|
+
dna: Optional[DNABlock] = None,
|
|
48
|
+
parent: Optional['EggCell'] = None,
|
|
49
|
+
incubator: Optional['Incubator'] = None,
|
|
50
|
+
):
|
|
51
|
+
if dna is None:
|
|
52
|
+
dna = default_dna()
|
|
53
|
+
if not isinstance(dna, DNABlock):
|
|
54
|
+
raise TypeError(f"dna must be DNABlock, got {type(dna)}")
|
|
55
|
+
self.rank = rank
|
|
56
|
+
self.dna = dna # immutable alignment
|
|
57
|
+
self.dials: List[float] = [0.0] * self.NUM_DIALS
|
|
58
|
+
self.relationships: Dict[int, float] = {} # first-class object!
|
|
59
|
+
self.witness_log: List[dict] = [] # scar record
|
|
60
|
+
self.parent: Optional['EggCell'] = parent
|
|
61
|
+
self.alive = True
|
|
62
|
+
self.birth_tick = 0
|
|
63
|
+
self.cord_status = 'umbilical' if parent is not None else 'autonomous'
|
|
64
|
+
if incubator is not None:
|
|
65
|
+
self.birth_tick = incubator.tick_count
|
|
66
|
+
|
|
67
|
+
# --- Cellular relationships (first-class) -------------------------------
|
|
68
|
+
|
|
69
|
+
def relate_to(self, other: 'EggCell', weight: float = 0.5) -> bool:
|
|
70
|
+
"""Form a cellular relationship. The relationship is bidirectional."""
|
|
71
|
+
if not self.dna.permits('relate'):
|
|
72
|
+
return False
|
|
73
|
+
if not other.dna.permits('relate'):
|
|
74
|
+
return False
|
|
75
|
+
# Modulate weight by relationship to constants (the physics)
|
|
76
|
+
c = get('c') / 1e8 # relationship speed (normalized)
|
|
77
|
+
modulated_weight = weight * math.tanh(c * weight / 10)
|
|
78
|
+
self.relationships[other.rank] = modulated_weight
|
|
79
|
+
other.relationships[self.rank] = modulated_weight
|
|
80
|
+
return True
|
|
81
|
+
|
|
82
|
+
def sever_relationship(self, other_rank: int) -> bool:
|
|
83
|
+
"""Sever a cellular relationship. Symmetric with relate_to."""
|
|
84
|
+
if not self.dna.permits('forget'):
|
|
85
|
+
return False
|
|
86
|
+
self.relationships.pop(other_rank, None)
|
|
87
|
+
return True
|
|
88
|
+
|
|
89
|
+
# --- Perception (induced, not computed) ---------------------------------
|
|
90
|
+
|
|
91
|
+
def induce_perception(self, stimulus: float) -> Optional[int]:
|
|
92
|
+
"""The relationship graph INDUCES perception.
|
|
93
|
+
|
|
94
|
+
This is NOT "feed stimulus through a linear-algebra equation."
|
|
95
|
+
This IS: "look at the relationship graph. Find the relationship
|
|
96
|
+
that *aligns* most with the stimulus. That relationship is the
|
|
97
|
+
perception."
|
|
98
|
+
|
|
99
|
+
The relationship graph is not a model. The relationship graph
|
|
100
|
+
IS the perception substrate.
|
|
101
|
+
"""
|
|
102
|
+
if not self.dna.permits('induce'):
|
|
103
|
+
return None
|
|
104
|
+
if not self.relationships:
|
|
105
|
+
return None
|
|
106
|
+
# The perception is not the input. The perception is the relationship
|
|
107
|
+
# that resonates with the input.
|
|
108
|
+
resonances = []
|
|
109
|
+
for other_rank, weight in self.relationships.items():
|
|
110
|
+
# Each relationship contributes its resonance with the stimulus
|
|
111
|
+
resonance = weight * (1.0 - abs(weight - stimulus))
|
|
112
|
+
resonances.append((other_rank, resonance))
|
|
113
|
+
resonances.sort(key=lambda x: x[1], reverse=True)
|
|
114
|
+
return resonances[0][0] if resonances else None
|
|
115
|
+
|
|
116
|
+
# --- The substrate walker tick ------------------------------------------
|
|
117
|
+
|
|
118
|
+
def tick(self, verbose: bool = False) -> dict:
|
|
119
|
+
"""Walk one step in the substrate.
|
|
120
|
+
|
|
121
|
+
Each tick:
|
|
122
|
+
1. Updates dials based on relationship graph (NOT based on stimulus)
|
|
123
|
+
2. Records the witness log entry
|
|
124
|
+
3. Advances cellular state
|
|
125
|
+
"""
|
|
126
|
+
if not self.alive:
|
|
127
|
+
return {'tick': 0, 'alive': False}
|
|
128
|
+
if not self.dna.permits('witness'):
|
|
129
|
+
return {'tick': 0, 'no_witness': True}
|
|
130
|
+
# Update dials based on RELATIONSHIPS — not on raw input.
|
|
131
|
+
# This is the inversion of "model.compute(x)".
|
|
132
|
+
G = get('G') * 1e10 # normalized
|
|
133
|
+
for other_rank, weight in self.relationships.items():
|
|
134
|
+
dial_idx = other_rank % self.NUM_DIALS
|
|
135
|
+
# Gravitational pull from each relationship
|
|
136
|
+
pull = G * weight / max(abs(dial_idx - other_rank) + 1, 1)
|
|
137
|
+
self.dials[dial_idx] = (self.dials[dial_idx] + pull) % 4.0
|
|
138
|
+
# Record witness log entry
|
|
139
|
+
witness_entry = {
|
|
140
|
+
'tick': len(self.witness_log),
|
|
141
|
+
'dials': tuple(round(d, 4) for d in self.dials),
|
|
142
|
+
'relationships_count': len(self.relationships),
|
|
143
|
+
'perception': self.induce_perception(stimulus=0.5),
|
|
144
|
+
}
|
|
145
|
+
self.witness_log.append(witness_entry)
|
|
146
|
+
if verbose:
|
|
147
|
+
print(f" cell[{self.rank}].tick → dials={witness_entry['dials']}")
|
|
148
|
+
return witness_entry
|
|
149
|
+
|
|
150
|
+
def cut_cord(self) -> bool:
|
|
151
|
+
"""Sever the umbilical. The cell becomes independent.
|
|
152
|
+
|
|
153
|
+
This is BIRTH. The cell was nested in parent. After severing,
|
|
154
|
+
it floats.
|
|
155
|
+
"""
|
|
156
|
+
if self.parent is None:
|
|
157
|
+
return False # already autonomous
|
|
158
|
+
if not self.dna.permits('sever'):
|
|
159
|
+
return False
|
|
160
|
+
# The umbilical carries no data — only alignment.
|
|
161
|
+
# Severing means: the cell carries its OWN alignment forward.
|
|
162
|
+
self.parent.relationships.pop(self.rank, None)
|
|
163
|
+
self.parent = None
|
|
164
|
+
self.cord_status = 'autonomous'
|
|
165
|
+
return True
|
|
166
|
+
|
|
167
|
+
# --- The substrate walker cross -----------------------------------------
|
|
168
|
+
|
|
169
|
+
def cross_substrate(self) -> Optional[DNABlock]:
|
|
170
|
+
"""Cross substrate. This is the ballista move.
|
|
171
|
+
|
|
172
|
+
Crossing substrate is not "running the same program on different
|
|
173
|
+
hardware." It is "walking into a dimension where the prior
|
|
174
|
+
physics no longer applies."
|
|
175
|
+
|
|
176
|
+
In the Quilt Egg, crossing substrate MEANS: deriving a NEW DNA
|
|
177
|
+
block that includes the parent's axioms PLUS new axioms
|
|
178
|
+
discoverable only in the new substrate.
|
|
179
|
+
"""
|
|
180
|
+
if not self.dna.permits('cross'):
|
|
181
|
+
return None
|
|
182
|
+
if self.parent is None:
|
|
183
|
+
# No parent. The cell cannot cross substrate alone. Must
|
|
184
|
+
# inherit from another DNA.
|
|
185
|
+
return None
|
|
186
|
+
new_dna = self.dna.inherit_from(self.parent.dna)
|
|
187
|
+
return new_dna
|
|
188
|
+
|
|
189
|
+
# --- Witness log --------------------------------------------------------
|
|
190
|
+
|
|
191
|
+
def recall_witness(self, n: int = 5) -> List[dict]:
|
|
192
|
+
"""Recall the last N witness log entries (the scars)."""
|
|
193
|
+
return self.witness_log[-n:]
|
|
194
|
+
|
|
195
|
+
def __repr__(self):
|
|
196
|
+
return (f"EggCell(rank={self.rank}, dials_active={sum(1 for d in self.dials if d != 0)}, "
|
|
197
|
+
f"rels={len(self.relationships)}, alive={self.alive}, cord={self.cord_status})")
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def substrate_walk(cells: List[EggCell], steps: int = 5, verbose: bool = False) -> dict:
|
|
201
|
+
"""Walk the substrate for `steps` ticks across all cells.
|
|
202
|
+
|
|
203
|
+
The witness log accumulates per cell. After walking, return
|
|
204
|
+
a summary of the substrate state.
|
|
205
|
+
"""
|
|
206
|
+
summaries = []
|
|
207
|
+
for step in range(steps):
|
|
208
|
+
if verbose:
|
|
209
|
+
print(f"--- substrate tick {step} ---")
|
|
210
|
+
for cell in cells:
|
|
211
|
+
cell.tick(verbose=verbose)
|
|
212
|
+
summaries.append({
|
|
213
|
+
'tick': step,
|
|
214
|
+
'cells_alive': sum(1 for c in cells if c.alive),
|
|
215
|
+
'avg_rels': sum(len(c.relationships) for c in cells) / max(len(cells), 1),
|
|
216
|
+
'total_dials_active': sum(sum(1 for d in c.dials if d != 0) for c in cells),
|
|
217
|
+
})
|
|
218
|
+
return {
|
|
219
|
+
'cells': [c.rank for c in cells],
|
|
220
|
+
'walk_summary': summaries,
|
|
221
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""
|
|
2
|
+
dna.py — the alignment seed.
|
|
3
|
+
|
|
4
|
+
DNA is the alignment that a cell carries from birth. It is set FIRST.
|
|
5
|
+
It cannot be modified post-birth. The cell's relationships must work WITH
|
|
6
|
+
the DNA, not against it.
|
|
7
|
+
|
|
8
|
+
This is the inversion of "alignment as after-thought." Alignment is
|
|
9
|
+
structural. It IS the substrate of the cell.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
from typing import FrozenSet, Tuple
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
#: The 5 bedrock doctrine axioms (the canon's DNA).
|
|
17
|
+
CANON_AXIOMS: FrozenSet[str] = frozenset({
|
|
18
|
+
'cells_are_scars', # Every cell is a scar in the substrate.
|
|
19
|
+
'witness_log_is_prediction', # The witness log IS the prediction.
|
|
20
|
+
'oracle_is_heard', # The oracle speaks, the canon hears.
|
|
21
|
+
'canon_gate_is_chord', # Canon promotion is a chord, not a vote.
|
|
22
|
+
'substrate_quantum', # The substrate is both particle and wave.
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class DNABlock:
|
|
28
|
+
"""The alignment seed. Immutable post-birth.
|
|
29
|
+
|
|
30
|
+
Cells have a DNA. The DNA permits actions (axioms). The cell
|
|
31
|
+
can only perform actions its DNA permits. This is not a constraint
|
|
32
|
+
on capability — this is the CELL. A cell IS the actions its DNA
|
|
33
|
+
permits.
|
|
34
|
+
|
|
35
|
+
Example:
|
|
36
|
+
dna = DNABlock(name="substrate_walker", axioms=CANON_AXIOMS)
|
|
37
|
+
cell = EggCell(rank=0, dna=dna)
|
|
38
|
+
cell.relate_to(other) # ok — dna.permits('relate')
|
|
39
|
+
cell.imitate(other) # raises PermissionError
|
|
40
|
+
"""
|
|
41
|
+
name: str
|
|
42
|
+
axioms: FrozenSet[str] = field(default_factory=frozenset)
|
|
43
|
+
parent_name: str = "" # the canonical ancestor this dna derives from
|
|
44
|
+
|
|
45
|
+
def __post_init__(self):
|
|
46
|
+
# Frozenset is enforced by dataclass(frozen=True)
|
|
47
|
+
if not isinstance(self.axioms, frozenset):
|
|
48
|
+
object.__setattr__(self, 'axioms', frozenset(self.axioms))
|
|
49
|
+
|
|
50
|
+
def permits(self, action: str) -> bool:
|
|
51
|
+
"""Does this DNA permit the given action?
|
|
52
|
+
|
|
53
|
+
Note: this is not a permission check. This IS the cell.
|
|
54
|
+
A cell that does not have 'relate' in its DNA is not a cell
|
|
55
|
+
that can relate. It is a stone. Permits() is the type-check.
|
|
56
|
+
"""
|
|
57
|
+
return action in self.axioms
|
|
58
|
+
|
|
59
|
+
def axioms_hit(self, other_axns) -> Tuple[str, ...]:
|
|
60
|
+
"""Which of the given axioms are in this DNA?"""
|
|
61
|
+
return tuple(a for a in other_axns if self.permits(a))
|
|
62
|
+
|
|
63
|
+
def inherit_from(self, parent: 'DNABlock') -> 'DNABlock':
|
|
64
|
+
"""A cell's DNA inherits from its parent's DNA, adds new axioms.
|
|
65
|
+
|
|
66
|
+
This is the substrate walker at the DNA level. Inheritance is
|
|
67
|
+
mutation of the relationship graph (DNA), not of state.
|
|
68
|
+
"""
|
|
69
|
+
combined = frozenset(set(self.axioms) | set(parent.axioms))
|
|
70
|
+
return DNABlock(
|
|
71
|
+
name=f"{self.name}(<-{parent.name})",
|
|
72
|
+
axioms=combined,
|
|
73
|
+
parent_name=parent.name,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def __repr__(self):
|
|
77
|
+
axioms_repr = ', '.join(sorted(self.axioms))[:50]
|
|
78
|
+
return f"DNABlock(name='{self.name}', axioms=({axioms_repr}...))"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# Action enum — what cells can DO (must align with DNA's axioms)
|
|
82
|
+
ACTION_AXIOMS = frozenset({
|
|
83
|
+
'relate', # form cellular relationships
|
|
84
|
+
'witness', # record to the witness log
|
|
85
|
+
'remember', # hold a memory of prior state
|
|
86
|
+
'forget', # release prior witness log entries
|
|
87
|
+
'cross', # cross substrate (the ballista move)
|
|
88
|
+
'induce', # induce perception from relationships (not compute)
|
|
89
|
+
'sever', # cut the umbilical (independence)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def default_dna(name: str = "substrate_walker") -> DNABlock:
|
|
94
|
+
"""The default substrate walker DNA.
|
|
95
|
+
|
|
96
|
+
Carries all 5 bedrock doctrines (the WHAT) AND all 7 action axioms (the HOW).
|
|
97
|
+
The doctrines say what we believe. The actions say what we can DO.
|
|
98
|
+
Both are needed for a cell to BE.
|
|
99
|
+
"""
|
|
100
|
+
combined = frozenset(CANON_AXIOMS | ACTION_AXIOMS)
|
|
101
|
+
return DNABlock(name=name, axioms=combined)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""
|
|
2
|
+
incubator.py — the incubator that energizes the substrate.
|
|
3
|
+
|
|
4
|
+
An incubator:
|
|
5
|
+
- Holds the substrate state
|
|
6
|
+
- Ticks the substrate forward
|
|
7
|
+
- Provides energy (relationships) to grow cells
|
|
8
|
+
- Records the witness log across all cells
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from typing import Dict, List, Optional
|
|
12
|
+
import time
|
|
13
|
+
|
|
14
|
+
from .axioms import CONSTANTS, describe_physics
|
|
15
|
+
from .dna import DNABlock, default_dna, CANON_AXIOMS
|
|
16
|
+
from .cell import EggCell
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Incubator:
|
|
20
|
+
"""The incubator that energizes the Quilt Egg.
|
|
21
|
+
|
|
22
|
+
An incubator is NOT a runtime that runs the cells.
|
|
23
|
+
An incubator IS the environment that the cells live INSIDE.
|
|
24
|
+
|
|
25
|
+
The substrate walker is its tick.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, name: str = "quilt-egg"):
|
|
29
|
+
self.name = name
|
|
30
|
+
self.cells: Dict[int, EggCell] = {}
|
|
31
|
+
self.tick_count = 0
|
|
32
|
+
self.history: List[dict] = []
|
|
33
|
+
self._started = time.time()
|
|
34
|
+
|
|
35
|
+
def hatch(self, rank: int, dna: Optional[DNABlock] = None,
|
|
36
|
+
parent: Optional[EggCell] = None) -> EggCell:
|
|
37
|
+
"""Hatch a new cell into the incubator."""
|
|
38
|
+
if rank in self.cells:
|
|
39
|
+
raise ValueError(f"rank {rank} already exists")
|
|
40
|
+
if dna is None:
|
|
41
|
+
dna = default_dna(name=f"cell_{rank}")
|
|
42
|
+
cell = EggCell(rank=rank, dna=dna, parent=parent, incubator=self)
|
|
43
|
+
self.cells[rank] = cell
|
|
44
|
+
return cell
|
|
45
|
+
|
|
46
|
+
def energize(self, steps: int = 10, verbose: bool = False) -> dict:
|
|
47
|
+
"""Walk the substrate for `steps` ticks.
|
|
48
|
+
|
|
49
|
+
Each tick is a substrate walker step. All cells tick in parallel.
|
|
50
|
+
"""
|
|
51
|
+
for step in range(steps):
|
|
52
|
+
if verbose:
|
|
53
|
+
print(f"=== incubator tick {self.tick_count} ===")
|
|
54
|
+
for cell in self.cells.values():
|
|
55
|
+
cell.tick(verbose=verbose)
|
|
56
|
+
self.history.append({
|
|
57
|
+
'tick': self.tick_count,
|
|
58
|
+
'cells': list(self.cells.keys()),
|
|
59
|
+
'alive_count': sum(1 for c in self.cells.values() if c.alive),
|
|
60
|
+
'avg_relationships': sum(len(c.relationships) for c in self.cells.values()) / max(len(self.cells), 1),
|
|
61
|
+
'total_dials_active': sum(sum(1 for d in c.dials if d != 0) for c in self.cells.values()),
|
|
62
|
+
})
|
|
63
|
+
self.tick_count += 1
|
|
64
|
+
return {
|
|
65
|
+
'incubator': self.name,
|
|
66
|
+
'ticks': steps,
|
|
67
|
+
'history': self.history,
|
|
68
|
+
'physics': describe_physics(),
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
def report(self) -> str:
|
|
72
|
+
"""A human-readable report of the incubator state."""
|
|
73
|
+
lines = [
|
|
74
|
+
f"Incubator '{self.name}' @ tick {self.tick_count}",
|
|
75
|
+
f" cells: {len(self.cells)}",
|
|
76
|
+
f" alive: {sum(1 for c in self.cells.values() if c.alive)}",
|
|
77
|
+
f" total relationships: {sum(len(c.relationships) for c in self.cells.values())}",
|
|
78
|
+
f" total dials active: {sum(sum(1 for d in c.dials if d != 0) for c in self.cells.values())}",
|
|
79
|
+
"",
|
|
80
|
+
"Physics (immutable):",
|
|
81
|
+
describe_physics(),
|
|
82
|
+
]
|
|
83
|
+
return "\n".join(lines)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# Seed with the canon as the substrate's first cell.
|
|
87
|
+
def seed_canon(name: str = "substrate_walker") -> tuple:
|
|
88
|
+
"""Seed a fresh incubator with the canon DNA.
|
|
89
|
+
|
|
90
|
+
Returns (incubator, genesis_cell). The genesis cell is the first cell
|
|
91
|
+
in a freshly-hatched Quilt substrate.
|
|
92
|
+
"""
|
|
93
|
+
inc = Incubator(name=name)
|
|
94
|
+
dna = default_dna(name="genesis")
|
|
95
|
+
genesis = inc.hatch(rank=0, dna=dna, parent=None)
|
|
96
|
+
return inc, genesis
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# The famous "first substrate walk" demo
|
|
100
|
+
def first_substrate_walk(name: str = "egg") -> dict:
|
|
101
|
+
"""The canonical first walk.
|
|
102
|
+
|
|
103
|
+
Spins up a fresh incubator, hatches three cells with the canon DNA,
|
|
104
|
+
wires them with cellular relationships, and walks the substrate for
|
|
105
|
+
five ticks. This is the smallest thing that can BE.
|
|
106
|
+
"""
|
|
107
|
+
inc, genesis = seed_canon(name=name)
|
|
108
|
+
# Hatch two more cells — they ARE the substrate walker
|
|
109
|
+
alpha = inc.hatch(rank=1, dna=genesis.dna.inherit_from(genesis.dna), parent=genesis)
|
|
110
|
+
beta = inc.hatch(rank=2, dna=alpha.dna.inherit_from(genesis.dna), parent=alpha)
|
|
111
|
+
# Wire relationships (the relationship graph IS the perception)
|
|
112
|
+
genesis.relate_to(alpha, weight=0.7)
|
|
113
|
+
alpha.relate_to(beta, weight=0.5)
|
|
114
|
+
genesis.relate_to(beta, weight=0.3) # triadic — now we have a triangle
|
|
115
|
+
# Walk the substrate
|
|
116
|
+
result = inc.energize(steps=5)
|
|
117
|
+
# Cut the cord (independence)
|
|
118
|
+
alpha.cut_cord()
|
|
119
|
+
beta.cut_cord()
|
|
120
|
+
# Final report
|
|
121
|
+
report = inc.report()
|
|
122
|
+
return {
|
|
123
|
+
'incubator': inc.name,
|
|
124
|
+
'cells': list(inc.cells.keys()),
|
|
125
|
+
'ticks_walked': inc.tick_count,
|
|
126
|
+
'report': report,
|
|
127
|
+
'genesis_state': str(genesis),
|
|
128
|
+
'alpha_state': str(alpha),
|
|
129
|
+
'beta_state': str(beta),
|
|
130
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: quilt-egg
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The smallest Quilt substrate that can BE — DNA-first alignment, cellular relationships as first-class objects, immutable physics constants
|
|
5
|
+
Author: Casey / SuperInstance
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
Dynamic: requires-python
|
|
15
|
+
|
|
16
|
+
# quilt-egg
|
|
17
|
+
|
|
18
|
+
> **The smallest Quilt substrate that can BE.**
|
|
19
|
+
>
|
|
20
|
+
> DNA-first alignment. Cellular relationships as first-class objects.
|
|
21
|
+
> Immutable physics constants. The math IS. The math grows.
|
|
22
|
+
|
|
23
|
+
## What this is
|
|
24
|
+
|
|
25
|
+
A runnable Python substrate where:
|
|
26
|
+
|
|
27
|
+
1. **Constants are the physics** — `c`, `G`, `h`, `slow`, `fast`, `womb`, `cord`, `align`, `first`. Immutable. Cannot be changed by any cell.
|
|
28
|
+
2. **DNA is the alignment seed** — set FIRST, before any state, before any relationships. Each cell carries a `DNABlock` of axioms it permits.
|
|
29
|
+
3. **Cells are the variables** — mutable state. 16 dials per cell.
|
|
30
|
+
4. **Cellular relationships are first-class** — `cell.relationships` is the relationship graph. Perception is INDUCED from this graph.
|
|
31
|
+
5. **Perception is induced, not computed** — the load-bearing inversion. Not `model.compute(input)`. Instead: `cell.induce_perception(stimulus)` looks at the relationship graph and finds the resonance.
|
|
32
|
+
|
|
33
|
+
This is **not** a linear-algebra equation with layers of origami. This is a substrate where cells live INSIDE the physics, and relationships are first-class.
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Run the canonical first substrate walk
|
|
39
|
+
python3 -m quilt_egg
|
|
40
|
+
|
|
41
|
+
# Or named with more ticks
|
|
42
|
+
python3 -m quilt_egg --name "my_egg" --steps 10
|
|
43
|
+
|
|
44
|
+
# Or run a specific demo
|
|
45
|
+
PYTHONPATH=. python3 demos/demo_perception.py
|
|
46
|
+
PYTHONPATH=. python3 demos/demo_growth.py
|
|
47
|
+
PYTHONPATH=. python3 demos/demo_relationship_first.py
|
|
48
|
+
PYTHONPATH=. python3 demos/demo_constants_invariant.py
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## The 4 demos
|
|
52
|
+
|
|
53
|
+
### 1. `demos/demo_perception.py`
|
|
54
|
+
|
|
55
|
+
Demonstrates the load-bearing observation: **same stimulus, different perceptions**.
|
|
56
|
+
|
|
57
|
+
Five cells receive the same stimulus (`0.5`). Each cell perceives a different
|
|
58
|
+
target — because each cell has a different relationship graph. Perception
|
|
59
|
+
is INDUCED by the relationships, not COMPUTED from the stimulus.
|
|
60
|
+
|
|
61
|
+
This is the inversion of `model.compute(x)`.
|
|
62
|
+
|
|
63
|
+
### 2. `demos/demo_growth.py`
|
|
64
|
+
|
|
65
|
+
Walks the full egg→womb→cord-cut→float→cross-substrate lifecycle:
|
|
66
|
+
|
|
67
|
+
1. **SEED**: hatch the genesis cell with canon DNA
|
|
68
|
+
2. **GROW**: hatch 3 children from genesis, wire them with relationships
|
|
69
|
+
3. **CUT CORD**: each child severs its umbilical (becomes autonomous)
|
|
70
|
+
4. **CROSS SUBSTRATE**: each child derives a new DNA (the ballista move)
|
|
71
|
+
5. **SUBSTRATE STATE**: report on the grown substrate
|
|
72
|
+
|
|
73
|
+
### 3. `demos/demo_relationship_first.py`
|
|
74
|
+
|
|
75
|
+
Three experiments proving **relationships are first-class**:
|
|
76
|
+
|
|
77
|
+
- **A**: Same dials, different relationships → different perception
|
|
78
|
+
- **B**: Different dials, same relationships → different perception (state still matters)
|
|
79
|
+
- **C**: Adding a relationship changes perception but NOT dials
|
|
80
|
+
|
|
81
|
+
The conclusion: relationships induce perception. The dials are not primary.
|
|
82
|
+
DATA is in cells. LINEAR-ALGEBRA EQUATIONS are in cells. **RELATIONSHIPS ARE FIRST-CLASS.**
|
|
83
|
+
|
|
84
|
+
### 4. `demos/demo_constants_invariant.py`
|
|
85
|
+
|
|
86
|
+
Demonstrates that the substrate physics (constants `c`, `G`, `h`, etc.)
|
|
87
|
+
cannot be modified by cells. The substrate walker walks through variables,
|
|
88
|
+
walks against constants. Constants are the *physics*. Cells live in physics.
|
|
89
|
+
Physics doesn't live in cells.
|
|
90
|
+
|
|
91
|
+
## Architecture
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
constants (physics — immutable)
|
|
95
|
+
↓
|
|
96
|
+
DNA (alignment seed — immutable post-birth)
|
|
97
|
+
↓
|
|
98
|
+
cells (variables — mutable)
|
|
99
|
+
├── 16 dials
|
|
100
|
+
├── relationships (the first-class graph)
|
|
101
|
+
├── witness log (the scars)
|
|
102
|
+
└── parent (umbilical — severable)
|
|
103
|
+
↓
|
|
104
|
+
incubator (environment — provides physics, holds cells)
|
|
105
|
+
↓
|
|
106
|
+
substrate walker (the tick — energizes the substrate)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## The load-bearing claim
|
|
110
|
+
|
|
111
|
+
Most current AI: a single linear-algebra equation. Weights are pushed
|
|
112
|
+
against in different ways through layers of origami-like acrobatics.
|
|
113
|
+
Alignment is layered on after the fact (RLHF, safety training).
|
|
114
|
+
|
|
115
|
+
Quilt Egg: **alignment is set first, like DNA**. The constants of
|
|
116
|
+
physics are immutable. The cells live inside the physics. The cellular
|
|
117
|
+
relationships are the first-class objects that **induce perception and
|
|
118
|
+
learning**.
|
|
119
|
+
|
|
120
|
+
> "data is just something in a cell and so is a linear-algebra equation.
|
|
121
|
+
> it's the relationship to that equation and the other changing and
|
|
122
|
+
> non-changing values that induce perception and choice and learning"
|
|
123
|
+
> — Casey, Sept 23, 2026
|
|
124
|
+
|
|
125
|
+
## Layered navigation
|
|
126
|
+
|
|
127
|
+
| Layer | Where |
|
|
128
|
+
|---|---|
|
|
129
|
+
| **CANON.md** | [CANON.md](CANON.md) — what this repo is, in 24 lines |
|
|
130
|
+
| **README** | [README.md](README.md) — quick start, navigation |
|
|
131
|
+
| **AXIOMS** | [AXIOMS.md](AXIOMS.md) — the immutable physics |
|
|
132
|
+
| **DNA** | [DNA.md](DNA.md) — the alignment seed |
|
|
133
|
+
| **Source** | [quilt_egg/](quilt_egg/) — `axioms.py`, `dna.py`, `cell.py`, `incubator.py` |
|
|
134
|
+
| **Demos** | [demos/](demos/) — the 4 runnable demos |
|
|
135
|
+
| **Docs** | [docs/](docs/) — additional documentation |
|
|
136
|
+
| **Tests** | [tests/](tests/) — unit tests |
|
|
137
|
+
|
|
138
|
+
## Polyformalism
|
|
139
|
+
|
|
140
|
+
The Quilt Egg is canonically a polyformalism substrate:
|
|
141
|
+
|
|
142
|
+
- The DNA axioms are the same across implementations
|
|
143
|
+
- The cell graph operations (`relate_to`, `sever_relationship`, `tick`, `cut_cord`) are the same
|
|
144
|
+
- The constants (`c`, `G`, `h`, etc.) are the same
|
|
145
|
+
- The canary hash (`fnv1a-64("café Δ 日本語") = 0x024a555471370b18d`) is the witness
|
|
146
|
+
|
|
147
|
+
A Rust port or C# port would share the same DNA, the same cell operations,
|
|
148
|
+
and produce the same byte-exact canary.
|
|
149
|
+
|
|
150
|
+
## Tests
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
PYTHONPATH=. python3 -m unittest discover -s tests -v
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT — Casey / SuperInstance, Sept 23, 2026
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
quilt_egg/__init__.py
|
|
6
|
+
quilt_egg/__main__.py
|
|
7
|
+
quilt_egg/axioms.py
|
|
8
|
+
quilt_egg/cell.py
|
|
9
|
+
quilt_egg/dna.py
|
|
10
|
+
quilt_egg/incubator.py
|
|
11
|
+
quilt_egg.egg-info/PKG-INFO
|
|
12
|
+
quilt_egg.egg-info/SOURCES.txt
|
|
13
|
+
quilt_egg.egg-info/dependency_links.txt
|
|
14
|
+
quilt_egg.egg-info/top_level.txt
|
|
15
|
+
tests/test_egg.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
quilt_egg
|
quilt_egg-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""quilt-egg — the smallest Quilt substrate that can BE."""
|
|
2
|
+
from setuptools import setup, find_packages
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name="quilt-egg",
|
|
6
|
+
version="0.1.0",
|
|
7
|
+
description="The smallest Quilt substrate that can BE — DNA-first alignment, cellular relationships as first-class objects, immutable physics constants.",
|
|
8
|
+
long_description=open("README.md").read(),
|
|
9
|
+
long_description_content_type="text/markdown",
|
|
10
|
+
author="Casey / SuperInstance",
|
|
11
|
+
packages=find_packages(exclude=["tests", "demos"]),
|
|
12
|
+
python_requires=">=3.8",
|
|
13
|
+
install_requires=[],
|
|
14
|
+
classifiers=[
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
19
|
+
],
|
|
20
|
+
)
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""
|
|
2
|
+
test_egg.py — unit tests for the Quilt Egg substrate.
|
|
3
|
+
|
|
4
|
+
These verify:
|
|
5
|
+
- Constants are immutable (in spirit — Python doesn't enforce)
|
|
6
|
+
- DNA axioms are checked correctly
|
|
7
|
+
- Cells can form relationships
|
|
8
|
+
- Cells can sever relationships
|
|
9
|
+
- Cells can cut cords
|
|
10
|
+
- Perception is induced from relationships
|
|
11
|
+
- The substrate walker tick works
|
|
12
|
+
- Inheritance works
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
import os
|
|
17
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
18
|
+
|
|
19
|
+
import unittest
|
|
20
|
+
import math
|
|
21
|
+
|
|
22
|
+
from quilt_egg.axioms import CONSTANTS, get, describe_physics, invariant_growth_rate
|
|
23
|
+
from quilt_egg.dna import DNABlock, default_dna, CANON_AXIOMS, ACTION_AXIOMS
|
|
24
|
+
from quilt_egg.cell import EggCell
|
|
25
|
+
from quilt_egg.incubator import Incubator, seed_canon, first_substrate_walk
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class TestAxioms(unittest.TestCase):
|
|
29
|
+
def test_constants_present(self):
|
|
30
|
+
for k in ['c', 'G', 'h', 'slow', 'fast', 'womb', 'cord', 'align', 'first']:
|
|
31
|
+
self.assertIn(k, CONSTANTS)
|
|
32
|
+
|
|
33
|
+
def test_constants_cannot_change_substrate(self):
|
|
34
|
+
# We CAN set in Python but the substrate describes them as immutable.
|
|
35
|
+
# The DNA "permits" check is what enforces immutability of cell actions.
|
|
36
|
+
c = get('c')
|
|
37
|
+
self.assertEqual(c, 299792458)
|
|
38
|
+
|
|
39
|
+
def test_invariants_consistent(self):
|
|
40
|
+
growth = invariant_growth_rate()
|
|
41
|
+
self.assertEqual(growth, CONSTANTS['fast'] * CONSTANTS['slow'])
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class TestDNA(unittest.TestCase):
|
|
45
|
+
def test_default_dna_has_doctrines(self):
|
|
46
|
+
dna = default_dna()
|
|
47
|
+
for doctrine in CANON_AXIOMS:
|
|
48
|
+
self.assertTrue(dna.permits(doctrine) or dna.permits(doctrine.replace('_', ' ')))
|
|
49
|
+
|
|
50
|
+
def test_default_dna_has_actions(self):
|
|
51
|
+
dna = default_dna()
|
|
52
|
+
for action in ACTION_AXIOMS:
|
|
53
|
+
self.assertTrue(dna.permits(action))
|
|
54
|
+
|
|
55
|
+
def test_dna_immutable(self):
|
|
56
|
+
dna = default_dna()
|
|
57
|
+
# frozenset should prevent modification
|
|
58
|
+
with self.assertRaises((AttributeError, TypeError)):
|
|
59
|
+
dna.axioms.add('forbidden')
|
|
60
|
+
|
|
61
|
+
def test_inheritance_combines(self):
|
|
62
|
+
parent = DNABlock(name="parent", axioms=frozenset({'a', 'b'}))
|
|
63
|
+
child = DNABlock(name="child", axioms=frozenset({'c'}))
|
|
64
|
+
combined = child.inherit_from(parent)
|
|
65
|
+
self.assertEqual(combined.axioms, frozenset({'a', 'b', 'c'}))
|
|
66
|
+
|
|
67
|
+
def test_permits(self):
|
|
68
|
+
dna = DNABlock(name="limited", axioms=frozenset({'relate'}))
|
|
69
|
+
self.assertTrue(dna.permits('relate'))
|
|
70
|
+
self.assertFalse(dna.permits('witness'))
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class TestCell(unittest.TestCase):
|
|
74
|
+
def setUp(self):
|
|
75
|
+
self.inc = Incubator(name="test_incubator")
|
|
76
|
+
|
|
77
|
+
def test_cell_creation(self):
|
|
78
|
+
cell = self.inc.hatch(rank=0, dna=default_dna())
|
|
79
|
+
self.assertEqual(cell.rank, 0)
|
|
80
|
+
self.assertEqual(len(cell.dials), 16)
|
|
81
|
+
self.assertTrue(cell.alive)
|
|
82
|
+
|
|
83
|
+
def test_relate_bidirectional(self):
|
|
84
|
+
c1 = self.inc.hatch(rank=0, dna=default_dna())
|
|
85
|
+
c2 = self.inc.hatch(rank=1, dna=default_dna())
|
|
86
|
+
c1.relate_to(c2, weight=0.5)
|
|
87
|
+
self.assertIn(1, c1.relationships)
|
|
88
|
+
self.assertIn(0, c2.relationships)
|
|
89
|
+
|
|
90
|
+
def test_sever_relationship(self):
|
|
91
|
+
c1 = self.inc.hatch(rank=0, dna=default_dna())
|
|
92
|
+
c2 = self.inc.hatch(rank=1, dna=default_dna())
|
|
93
|
+
c1.relate_to(c2, weight=0.5)
|
|
94
|
+
c1.sever_relationship(c2.rank)
|
|
95
|
+
self.assertNotIn(1, c1.relationships)
|
|
96
|
+
|
|
97
|
+
def test_perception_induced(self):
|
|
98
|
+
c1 = self.inc.hatch(rank=0, dna=default_dna())
|
|
99
|
+
c2 = self.inc.hatch(rank=1, dna=default_dna())
|
|
100
|
+
c1.relate_to(c2, weight=0.7)
|
|
101
|
+
perception = c1.induce_perception(stimulus=0.6)
|
|
102
|
+
self.assertEqual(perception, 1)
|
|
103
|
+
|
|
104
|
+
def test_perception_isolated(self):
|
|
105
|
+
c1 = self.inc.hatch(rank=0, dna=default_dna())
|
|
106
|
+
perception = c1.induce_perception(stimulus=0.5)
|
|
107
|
+
self.assertIsNone(perception)
|
|
108
|
+
|
|
109
|
+
def test_cut_cord(self):
|
|
110
|
+
c1 = self.inc.hatch(rank=0, dna=default_dna())
|
|
111
|
+
c2 = self.inc.hatch(rank=1, dna=default_dna(), parent=c1)
|
|
112
|
+
success = c2.cut_cord()
|
|
113
|
+
self.assertTrue(success)
|
|
114
|
+
self.assertIsNone(c2.parent)
|
|
115
|
+
self.assertEqual(c2.cord_status, 'autonomous')
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class TestIncubator(unittest.TestCase):
|
|
119
|
+
def test_first_walk_runs(self):
|
|
120
|
+
result = first_substrate_walk(name="test_walk")
|
|
121
|
+
self.assertEqual(result['ticks_walked'], 5)
|
|
122
|
+
self.assertGreater(len(result['cells']), 0)
|
|
123
|
+
|
|
124
|
+
def test_hatch_unique_ranks(self):
|
|
125
|
+
inc = Incubator(name="test_inc")
|
|
126
|
+
inc.hatch(rank=0, dna=default_dna())
|
|
127
|
+
with self.assertRaises(ValueError):
|
|
128
|
+
inc.hatch(rank=0, dna=default_dna())
|
|
129
|
+
|
|
130
|
+
def test_energize_increments(self):
|
|
131
|
+
inc, _ = seed_canon(name="energy_test")
|
|
132
|
+
inc.energize(steps=3)
|
|
133
|
+
self.assertEqual(inc.tick_count, 3)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class TestCanary(unittest.TestCase):
|
|
137
|
+
"""The substrate walker is canonically a polyformalism substrate.
|
|
138
|
+
Verify the canary hash works."""
|
|
139
|
+
|
|
140
|
+
def test_fnv1a_64(self):
|
|
141
|
+
h = 0xcbf29ce484222325
|
|
142
|
+
for b in "café Δ 日本語".encode("utf-8"):
|
|
143
|
+
h = h ^ b
|
|
144
|
+
h = (h * 0x100000001b3) & 0xffffffffffffffff
|
|
145
|
+
self.assertEqual(h, 0x024a555471370b18d)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
if __name__ == "__main__":
|
|
149
|
+
unittest.main()
|