Skip to content

Commit 0d3eafa

Browse files
committed
Add prompt 26: THE entry point. All sessions start here. Four phases. Node/Plane/Mask as primary citizen.
1 parent 1838dc9 commit 0d3eafa

1 file changed

Lines changed: 352 additions & 0 deletions

File tree

.claude/prompts/26_entry_point.md

Lines changed: 352 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,352 @@
1+
# 26_ENTRY_POINT.md
2+
3+
## The Entry Point. Read This First. Do Everything From Here.
4+
5+
**Repo:** ladybug-rs
6+
**Date:** 2026-03-12
7+
**Status:** This is the orchestration root. All sessions start here.
8+
9+
---
10+
11+
## 0. WHERE YOU ARE
12+
13+
```
14+
ladybug-rs is a 164K LOC Rust cognitive substrate.
15+
It has 5 Cypher implementations where it should have 1.
16+
Its core architectural reference (spo.rs) is private.
17+
Its server endpoint for Cypher is a stub.
18+
Its CI is broken.
19+
It has 13 stale PRs.
20+
21+
But it also has a 10-layer qualia stack, NARS inference,
22+
a working SPO encoding, a working Cypher executor (cypher_bridge.rs),
23+
a working nom Cypher parser (lance_parser/), Blake3 Merkle integrity,
24+
SpineCache borrow/mut, and the complete awareness loop designed in prompts.
25+
26+
The job: wire what exists. Delete what's dead. Refactor what's tangled.
27+
Then implement prompt 25 (Node/Plane/Mask) as the production API.
28+
```
29+
30+
---
31+
32+
## 1. MANDATORY READS (in this order, no skipping)
33+
34+
```
35+
FIRST (understand what you're working with):
36+
CLAUDE.md Guardrails. Traps. Known issues. Read ALL of it.
37+
38+
THEN (understand the target architecture):
39+
.claude/prompts/25_node_plane_mask.md THE object model. Three structures.
40+
Node, Plane, Mask. i8 accumulator as
41+
sole ground truth. Seven words.
42+
This is what ladybug-rs BECOMES.
43+
44+
THEN (understand what's broken and what to harvest):
45+
.claude/prompts/17_five_path_teardown.md 5 Cypher paths. File-by-file verdicts.
46+
.claude/prompts/17a_spo_rosetta_stone_addendum.md spo.rs is private. 3 TruthValues.
47+
48+
THEN (understand the invariants):
49+
.claude/prompts/19_hot_cold_separation_constraint.md One-way mirror. Never violated.
50+
51+
CONTEXT (read as needed for specific tasks):
52+
.claude/prompts/15_RISC_brain_convergence_vision.md 6 RISC instructions
53+
.claude/prompts/22_sisyphus_then_forks.md Harvest table
54+
.claude/prompts/23_alpha_channel_risc_modifier.md Alpha = .α modifier
55+
.claude/prompts/24_blake3_int8_bundle_encoding.md BLAKE3 → i8 → (data, alpha)
56+
```
57+
58+
---
59+
60+
## 2. THE CURRENT NAMES (DO NOT RENAME)
61+
62+
```
63+
FILE/MODULE WHAT IT IS KEEP/REFACTOR/DELETE
64+
─────────────────────────────────────────────────────────────────────────────────
65+
src/spo/spo.rs Reference implementation (PRIVATE) KEEP as reference
66+
src/spo/mod.rs SPO module root REFACTOR: pub(crate) mod spo
67+
src/spo/gestalt.rs Bundling/tilt/calibration KEEP
68+
src/spo/spo_harvest.rs SPO distance (238x cheaper) KEEP
69+
src/spo/clam_path.rs CLAM + Merkle in word[0] KEEP
70+
src/spo/causal_trajectory.rs BNN instrumentation KEEP
71+
src/spo/shift_detector.rs Stripe migration KEEP
72+
src/spo/codebook_*.rs Codebook management KEEP
73+
src/spo/sentence_crystal.rs Text→SPO pipeline KEEP
74+
src/spo/deepnsm_integration.rs DeepNSM bridge KEEP
75+
src/spo/jina_api.rs Jina client KEEP (optional)
76+
src/spo/jina_cache.rs Jina cache KEEP (optional)
77+
78+
src/query/lance_parser/ Production Cypher parser (nom) KEEP — THIS IS THE PARSER
79+
src/query/cypher.rs Hand-rolled transpiler (P1) DELETE
80+
src/query/graph_provider.rs BindSpace → DataFusion table KEEP
81+
src/query/cognitive_udfs.rs 12 DataFusion UDFs KEEP
82+
src/query/datafusion.rs DataFusion session setup KEEP
83+
src/query/hybrid.rs Hybrid query REFACTOR (imports P1 types)
84+
85+
src/cypher_bridge.rs Cypher → BindSpace executor (P2) REFACTOR to take P3 AST
86+
src/bin/server.rs HTTP server (3681 lines) REFACTOR /cypher endpoint
87+
88+
src/graph/spo/store.rs SpoStore + TruthGate KEEP
89+
src/graph/spo/merkle.rs SpoMerkle + Epoch + Proof KEEP
90+
src/graph/spo/sparse.rs SparseContainer KEEP
91+
src/graph/spo/semiring.rs SPO semiring (extend with holograph) KEEP + EXTEND
92+
src/graph/spo/scent.rs NibbleScent KEEP
93+
94+
src/nars/ NARS inference (7 files) KEEP — canonical TruthValue
95+
src/qualia/ 10-layer qualia stack KEEP
96+
src/storage/ BindSpace + Substrate + etc KEEP
97+
src/orchestration/ crewAI integration (12 files) KEEP
98+
src/learning/cam_ops.rs Opcode dispatch (CypherOp) RENAME CypherOp→CypherInstruction
99+
src/cognitive/ 7-layer consciousness KEEP
100+
src/search/ HDR cascade, causal search KEEP
101+
src/core/fingerprint.rs 16384-bit Fingerprint KEEP + ADD project_out
102+
103+
src/learning/cam_ops.rs CypherOp Opcode enum (80 opcodes) RENAME only, keep all opcodes
104+
```
105+
106+
---
107+
108+
## 3. THE FOUR PHASES
109+
110+
### Phase A: Sisyphus Cleanup (Sessions 1-2)
111+
112+
**Goal:** Delete dead code. Fix the /cypher endpoint. Get things compiling.
113+
114+
```
115+
A1. Delete src/query/cypher.rs (P1, 1560 lines)
116+
- Save CTE generator (lines 1253-1361) → src/query/cte_builder.rs
117+
- Remove from query/mod.rs
118+
- Fix hybrid.rs imports (it imports CypherParser from P1)
119+
- Comment out server.rs /cypher temporarily
120+
121+
A2. Refactor cypher_bridge.rs to take lance_parser AST directly
122+
- Remove: CypherOp enum, NodeRef, WhereClause, CypherValue, parse_cypher()
123+
- Change: execute_cypher(&mut BindSpace, &CypherQuery) using P3 ast types
124+
- Keep: ALL execution logic (execute_merge_node, execute_create_edge, etc)
125+
- Keep: find_node_by_label_and_name, evaluate_where
126+
- Rewrite evaluate_where to take lance_parser::BooleanExpression
127+
- Rewrite execute_merge to take lance_parser::NodePattern
128+
- Rewrite execute_match to take lance_parser::MatchClause
129+
130+
A3. Wire server.rs /cypher:
131+
parse_cypher_query(&query) → execute_cypher(&mut bs, &ast) → JSON response
132+
133+
A4. Rename cam_ops CypherOp → CypherInstruction
134+
135+
A5. cargo check passes
136+
```
137+
138+
### Phase B: Unlock + Implement Node/Plane/Mask (Sessions 3-5)
139+
140+
**Goal:** Implement prompt 25 as the production API in src/spo/.
141+
142+
```
143+
B1. Unlock spo.rs: mod spo → pub(crate) mod spo
144+
145+
B2. Add to core/fingerprint.rs:
146+
project_out() — Gram-Schmidt (from spo.rs lines 116-140)
147+
dot_bipolar() — matching bits - non-matching bits
148+
149+
B3. Create src/spo/node.rs — THE Node struct (prompt 25 §1)
150+
Node { s: Plane, p: Plane, o: Plane }
151+
Plane { acc: [i8; 16384], encounter_count: u32 }
152+
Mask { s: bool, p: bool, o: bool }
153+
8 Mask constants: SPO, SP_, S_O, _PO, S__, _P_, __O, ___
154+
155+
B4. Create src/spo/plane_ops.rs — Plane implementation (prompt 25 §2)
156+
bits() → derived from sign(acc)
157+
alpha() → derived from |acc| > threshold
158+
encounter() → BLAKE3 → i8 ±1 saturating
159+
reinforce() → BNN from Seal
160+
truth() → NARS from accumulator state
161+
distance() → alpha-normalized Hamming with penalty
162+
density() → alpha density
163+
164+
B5. Create src/spo/mind.rs — Mind implementation (prompt 25 §4)
165+
Mind { bind_space: &BindSpace, crystal: &SPOCrystal }
166+
open() → Mind (immutable borrow, zero copy)
167+
at(s, p, o) → &Node (Hebbian side-effect)
168+
hold(node, Mask) → HeldNode (owned micro-copy)
169+
merge(HeldNode) → Changed { seal, diffs, alpha_shift }
170+
171+
B6. Create src/spo/seal.rs — Seal types (prompt 25 §3)
172+
Seal::Wisdom | Seal::Staunen
173+
blake3_masked(data AND alpha)
174+
Address { bits, alpha, merkle }
175+
176+
B7. Create src/spo/gestalt.rs extension — VSA projection (prompt 25 §5)
177+
GestaltNode { s: ContinuousPlane, p: ContinuousPlane, o: ContinuousPlane }
178+
project_to_continuous() — i8 acc → f16 for qualia operations
179+
qualia(Mask) → QualiaState
180+
This is the awareness passthrough. Not hot path. Computed once per cycle.
181+
182+
B8. Wire into cypher_bridge.rs:
183+
execute_match uses mind.at() + node.resonate() instead of nodes_iter
184+
execute_merge uses mind.hold() + encounter + merge
185+
186+
B9. Wire into server.rs:
187+
Mind created from BindSpace on request
188+
/cypher flows through Mind API
189+
Response includes Changed { seal } metadata
190+
```
191+
192+
### Phase C: Hardening (Sessions 6-7)
193+
194+
```
195+
C1. Fix CI — cargo check --all-features or closest
196+
C2. Close stale PRs #11-#33, #54
197+
C3. Evaluate #168, #169 against #170
198+
C4. .unwrap() audit on hot paths (storage/, spo/, server.rs)
199+
C5. Race condition P0 fixes from TECHNICAL_DEBT.md
200+
```
201+
202+
### Phase D: Integration (Sessions 8-10)
203+
204+
```
205+
D1. Harvest holograph semiring.rs (7 semirings) → src/graph/spo/semiring.rs
206+
D2. Harvest holograph epiphany.rs → src/search/epiphany.rs
207+
D3. Harvest lance-graph truth.rs → src/graph/spo/truth.rs
208+
D4. Harvest lance-graph walk_chain_forward → src/graph/spo/store.rs
209+
D5. Wire awareness loop (prompt 13) using Mind + Node + gestalt
210+
D6. Wire thinking style routing (prompt 12) using Mask as attention selector
211+
```
212+
213+
---
214+
215+
## 4. AGENT ROLES FOR A2A ORCHESTRATION
216+
217+
### Agent JANITOR [Phase A, sessions 1-2]
218+
219+
```
220+
READS: CLAUDE.md, prompt 17, src/query/cypher.rs, src/cypher_bridge.rs,
221+
src/query/lance_parser/ast.rs, src/bin/server.rs
222+
DOES: Delete P1. Refactor P2 to take P3 AST. Wire server. Rename P4.
223+
EXIT: cargo check passes. /cypher calls lance_parser → cypher_bridge.
224+
LINES: -1560 deleted, ~400 refactored in cypher_bridge.rs, ~50 in server.rs
225+
```
226+
227+
### Agent ARCHITECT [Phase B, sessions 3-5]
228+
229+
```
230+
READS: CLAUDE.md, prompt 25 (ENTIRE THING), src/spo/spo.rs (ENTIRE FILE),
231+
src/core/fingerprint.rs, src/storage/bind_space.rs
232+
DOES: Implement Node, Plane, Mask, Mind, Seal, HeldNode, GestaltNode.
233+
Create node.rs, plane_ops.rs, mind.rs, seal.rs, gestalt extension.
234+
Wire into cypher_bridge and server.
235+
EXIT: mind.at() → node.hold(SP_) → encounter → resonate → merge compiles + runs.
236+
LINES: ~1500 new across 5 files. Zero bridges. Zero adapters.
237+
```
238+
239+
### Agent MEDIC [Phase C, sessions 6-7]
240+
241+
```
242+
READS: CLAUDE.md §1 (CI), TECHNICAL_DEBT.md
243+
DOES: Fix CI. Close PRs. .unwrap() audit. Race condition fixes.
244+
EXIT: CI green. Open PRs < 5. Zero P0 race conditions.
245+
```
246+
247+
### Agent HARVESTER [Phase D, sessions 8-10]
248+
249+
```
250+
READS: CLAUDE.md, prompt 22 harvest table, holograph src/, lance-graph src/graph/spo/
251+
DOES: Import holograph semirings, epiphany. Import lance-graph truth, walk_chain.
252+
Wire awareness loop and thinking style routing through Mind API.
253+
EXIT: 7 semirings available. Epiphany detection available.
254+
/awareness/preamble returns qualia from gestalt projection.
255+
```
256+
257+
### Dependency Graph
258+
259+
```
260+
JANITOR ─────────► ARCHITECT ─────────► HARVESTER
261+
262+
MEDIC (parallel with ARCHITECT or after)
263+
```
264+
265+
JANITOR must complete first (clean workspace).
266+
ARCHITECT is the core work (prompt 25 implementation).
267+
MEDIC can run parallel or after.
268+
HARVESTER needs ARCHITECT complete (imports integrate via Mind API).
269+
270+
---
271+
272+
## 5. THE PROMPT 25 MIGRATION PATH
273+
274+
```
275+
EXISTING spo.rs BECOMES prompt 25 Node/Plane/Mask
276+
─────────────────────────────────────────────────────────────────────────
277+
SPOCrystal Mind (wraps BindSpace + crystal index)
278+
SPOCrystal.insert(Triple) mind.hold(Mask) → encounter → merge
279+
SPOCrystal.query_object(s, p) mind.at(s, p, _).resonate(SP_)
280+
SPOCrystal.query_subject(p, o) mind.at(_, p, o).resonate(_PO)
281+
SPOCrystal.resonate_spo(s?, p?, o?) node.resonate(&mind, Mask, threshold)
282+
Triple { s, p, o, qualia, truth } Node { s: Plane, p: Plane, o: Plane }
283+
Qualia { activation, valence, ... } node.gestalt().qualia(Mask)
284+
TruthValue { freq, conf } node.truth(Mask) — derived from acc
285+
OrthogonalCodebook Stays — used by crystal index for CAM
286+
Fingerprint (spo.rs private) core::Fingerprint + project_out()
287+
QuorumField (5×5×5 grid) SPOCrystal spatial index (internal)
288+
CubicDistance node.distance(other, Mask) — per-plane
289+
FieldCloseness resonate() return type
290+
bundle(), bundle_weighted() Plane.encounter() (i8 accumulation)
291+
cleanup() Built into resonate() iterations
292+
```
293+
294+
The spo.rs reference stays as `pub(crate) mod spo`. Every function in it
295+
maps to a prompt 25 method. The new code is not a rewrite — it's spo.rs
296+
concepts expressed as the Node/Plane/Mask type system where the compiler
297+
prevents the wrong operations.
298+
299+
---
300+
301+
## 6. WHAT SUCCESS LOOKS LIKE
302+
303+
```
304+
AFTER PHASE A:
305+
/cypher endpoint calls lance_parser → refactored cypher_bridge → BindSpace
306+
No dead Cypher parsers. One path.
307+
308+
AFTER PHASE B:
309+
let mind = bind.open();
310+
let known = mind.at("Ada", "loves", "Bob");
311+
let mut idea = mind.hold(&known, SP_);
312+
idea.encounter_p("deeply");
313+
let echoes = idea.resonate(&mind, SP_, 0.7);
314+
let changed = mind.merge(idea);
315+
// This compiles. This runs. This IS the API.
316+
317+
AFTER PHASE C:
318+
CI green. Stale PRs closed. Hot path .unwrap()-free.
319+
320+
AFTER PHASE D:
321+
7 semiring algebras. Epiphany detection. Awareness loop.
322+
The system reports its own felt state via gestalt projection.
323+
Neo4j shows the brain thinking in real time.
324+
```
325+
326+
---
327+
328+
## 7. SESSION BOOTSTRAP
329+
330+
Every Claude Code session on ladybug-rs starts with:
331+
332+
```bash
333+
cat CLAUDE.md # guardrails + traps
334+
cat .claude/prompts/26_entry_point.md # this file — the orchestration root
335+
cat .claude/TONIGHT_SESSION_STACK.md # current session tasks
336+
```
337+
338+
If session stack is empty or completed, check the blackboard:
339+
340+
```bash
341+
cat .claude/SURGERY_BLACKBOARD.md # which tasks are done
342+
```
343+
344+
Pick the next uncompleted phase (A → B → C → D) and execute.
345+
346+
---
347+
348+
*"Three structures. Seven words. One accumulator as ground truth."*
349+
350+
*"The system doesn't HAVE intelligence. The using IS the intelligence."*
351+
352+
*"Read first. All of it. Then build."*

0 commit comments

Comments
 (0)