spine-memory 0.2.3__tar.gz → 0.2.4__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.
- {spine_memory-0.2.3/spine_memory.egg-info → spine_memory-0.2.4}/PKG-INFO +5 -5
- {spine_memory-0.2.3 → spine_memory-0.2.4}/README.md +4 -4
- {spine_memory-0.2.3 → spine_memory-0.2.4}/pyproject.toml +2 -2
- {spine_memory-0.2.3 → spine_memory-0.2.4/spine_memory.egg-info}/PKG-INFO +5 -5
- {spine_memory-0.2.3 → spine_memory-0.2.4}/spine_memory.egg-info/SOURCES.txt +1 -0
- spine_memory-0.2.4/tools/SPINE_METHODOLOGY_EN.md +269 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/_quality_audit.py +4 -3
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/mcp_server.py +20 -1
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/night_daemon.py +9 -1
- {spine_memory-0.2.3 → spine_memory-0.2.4}/LICENSE +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/setup.cfg +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/spine_memory.egg-info/dependency_links.txt +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/spine_memory.egg-info/entry_points.txt +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/spine_memory.egg-info/requires.txt +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/spine_memory.egg-info/top_level.txt +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tests/test_smoke.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/_build_index.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/_check_anchors.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/_critic_check.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/_crosslink.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/_embed_links.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/_git_hook.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/_node_io.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/_wander.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/benchmark_tokens.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/cli.py +0 -0
- {spine_memory-0.2.3 → spine_memory-0.2.4}/tools/spine_preflight.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spine-memory
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Hierarchical Markdown/YAML graph memory for long-horizon AI agents — git-native, zero-token CI guardrails, no vector DB.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/Scrimal/SPINE-Memory
|
|
@@ -115,7 +115,7 @@ biological neural organization:
|
|
|
115
115
|
traversal without mutating existing YAML.
|
|
116
116
|
- `strategic_weight` (0.0–1.0), `access_count`, `last_accessed` keep active
|
|
117
117
|
memories hot while dormant ones cool without dead links.
|
|
118
|
-
4. **Zero-token deterministic guardrails.** `_critic_check.
|
|
118
|
+
4. **Zero-token deterministic guardrails.** `_critic_check.py` and
|
|
119
119
|
`_quality_audit.py` enforce structure, length caps (`IMPULSE <= 2 lines`,
|
|
120
120
|
`SUMMARY <= 5 sentences`), anchor canon compliance, and `SOURCE_BASE >= 70%`
|
|
121
121
|
byte retention via instant bash/Python checks — no LLM-vs-LLM critic loops.
|
|
@@ -184,7 +184,7 @@ flowchart LR
|
|
|
184
184
|
```
|
|
185
185
|
|
|
186
186
|
The agent writes each node draft into a temporary buffer (`TEMP`), runs
|
|
187
|
-
`_critic_check.
|
|
187
|
+
`_critic_check.py` on it, resolves boundary cases on its own with bounded
|
|
188
188
|
discretion (e.g. a short source chunk, or a decimal point miscounted as a
|
|
189
189
|
sentence terminator) without looping in self-criticism, and only then atomically
|
|
190
190
|
commits the valid node into the production graph. Every 5 nodes the heavy
|
|
@@ -224,7 +224,7 @@ consumes model tokens).
|
|
|
224
224
|
└── tools/ # validation & traversal utilities
|
|
225
225
|
├── cli.py # spine CLI entry point
|
|
226
226
|
├── _node_io.py # canonical node reader/writer
|
|
227
|
-
├── _critic_check.
|
|
227
|
+
├── _critic_check.py
|
|
228
228
|
├── _check_anchors.py
|
|
229
229
|
├── _crosslink.py
|
|
230
230
|
├── _wander.py
|
|
@@ -266,7 +266,7 @@ Or run directly from a checkout (no install):
|
|
|
266
266
|
|
|
267
267
|
```bash
|
|
268
268
|
# 1. Auto-audit nodes (clean PASS expected)
|
|
269
|
-
|
|
269
|
+
python tools/_critic_check.py nodes raw anchors/anchor_dump.json
|
|
270
270
|
|
|
271
271
|
# 2. Validate anchors against the canon
|
|
272
272
|
python tools/_check_anchors.py nodes/KEDR_001.md --dump anchors/anchor_dump.json --quiet
|
|
@@ -82,7 +82,7 @@ biological neural organization:
|
|
|
82
82
|
traversal without mutating existing YAML.
|
|
83
83
|
- `strategic_weight` (0.0–1.0), `access_count`, `last_accessed` keep active
|
|
84
84
|
memories hot while dormant ones cool without dead links.
|
|
85
|
-
4. **Zero-token deterministic guardrails.** `_critic_check.
|
|
85
|
+
4. **Zero-token deterministic guardrails.** `_critic_check.py` and
|
|
86
86
|
`_quality_audit.py` enforce structure, length caps (`IMPULSE <= 2 lines`,
|
|
87
87
|
`SUMMARY <= 5 sentences`), anchor canon compliance, and `SOURCE_BASE >= 70%`
|
|
88
88
|
byte retention via instant bash/Python checks — no LLM-vs-LLM critic loops.
|
|
@@ -151,7 +151,7 @@ flowchart LR
|
|
|
151
151
|
```
|
|
152
152
|
|
|
153
153
|
The agent writes each node draft into a temporary buffer (`TEMP`), runs
|
|
154
|
-
`_critic_check.
|
|
154
|
+
`_critic_check.py` on it, resolves boundary cases on its own with bounded
|
|
155
155
|
discretion (e.g. a short source chunk, or a decimal point miscounted as a
|
|
156
156
|
sentence terminator) without looping in self-criticism, and only then atomically
|
|
157
157
|
commits the valid node into the production graph. Every 5 nodes the heavy
|
|
@@ -191,7 +191,7 @@ consumes model tokens).
|
|
|
191
191
|
└── tools/ # validation & traversal utilities
|
|
192
192
|
├── cli.py # spine CLI entry point
|
|
193
193
|
├── _node_io.py # canonical node reader/writer
|
|
194
|
-
├── _critic_check.
|
|
194
|
+
├── _critic_check.py
|
|
195
195
|
├── _check_anchors.py
|
|
196
196
|
├── _crosslink.py
|
|
197
197
|
├── _wander.py
|
|
@@ -233,7 +233,7 @@ Or run directly from a checkout (no install):
|
|
|
233
233
|
|
|
234
234
|
```bash
|
|
235
235
|
# 1. Auto-audit nodes (clean PASS expected)
|
|
236
|
-
|
|
236
|
+
python tools/_critic_check.py nodes raw anchors/anchor_dump.json
|
|
237
237
|
|
|
238
238
|
# 2. Validate anchors against the canon
|
|
239
239
|
python tools/_check_anchors.py nodes/KEDR_001.md --dump anchors/anchor_dump.json --quiet
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "spine-memory"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.4"
|
|
8
8
|
description = "Hierarchical Markdown/YAML graph memory for long-horizon AI agents — git-native, zero-token CI guardrails, no vector DB."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -44,4 +44,4 @@ package-dir = { "spine_memory" = "tools" }
|
|
|
44
44
|
packages = ["spine_memory"]
|
|
45
45
|
|
|
46
46
|
[tool.setuptools.package-data]
|
|
47
|
-
spine_memory = ["*.py"]
|
|
47
|
+
spine_memory = ["*.py", "SPINE_METHODOLOGY_EN.md"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spine-memory
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Hierarchical Markdown/YAML graph memory for long-horizon AI agents — git-native, zero-token CI guardrails, no vector DB.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/Scrimal/SPINE-Memory
|
|
@@ -115,7 +115,7 @@ biological neural organization:
|
|
|
115
115
|
traversal without mutating existing YAML.
|
|
116
116
|
- `strategic_weight` (0.0–1.0), `access_count`, `last_accessed` keep active
|
|
117
117
|
memories hot while dormant ones cool without dead links.
|
|
118
|
-
4. **Zero-token deterministic guardrails.** `_critic_check.
|
|
118
|
+
4. **Zero-token deterministic guardrails.** `_critic_check.py` and
|
|
119
119
|
`_quality_audit.py` enforce structure, length caps (`IMPULSE <= 2 lines`,
|
|
120
120
|
`SUMMARY <= 5 sentences`), anchor canon compliance, and `SOURCE_BASE >= 70%`
|
|
121
121
|
byte retention via instant bash/Python checks — no LLM-vs-LLM critic loops.
|
|
@@ -184,7 +184,7 @@ flowchart LR
|
|
|
184
184
|
```
|
|
185
185
|
|
|
186
186
|
The agent writes each node draft into a temporary buffer (`TEMP`), runs
|
|
187
|
-
`_critic_check.
|
|
187
|
+
`_critic_check.py` on it, resolves boundary cases on its own with bounded
|
|
188
188
|
discretion (e.g. a short source chunk, or a decimal point miscounted as a
|
|
189
189
|
sentence terminator) without looping in self-criticism, and only then atomically
|
|
190
190
|
commits the valid node into the production graph. Every 5 nodes the heavy
|
|
@@ -224,7 +224,7 @@ consumes model tokens).
|
|
|
224
224
|
└── tools/ # validation & traversal utilities
|
|
225
225
|
├── cli.py # spine CLI entry point
|
|
226
226
|
├── _node_io.py # canonical node reader/writer
|
|
227
|
-
├── _critic_check.
|
|
227
|
+
├── _critic_check.py
|
|
228
228
|
├── _check_anchors.py
|
|
229
229
|
├── _crosslink.py
|
|
230
230
|
├── _wander.py
|
|
@@ -266,7 +266,7 @@ Or run directly from a checkout (no install):
|
|
|
266
266
|
|
|
267
267
|
```bash
|
|
268
268
|
# 1. Auto-audit nodes (clean PASS expected)
|
|
269
|
-
|
|
269
|
+
python tools/_critic_check.py nodes raw anchors/anchor_dump.json
|
|
270
270
|
|
|
271
271
|
# 2. Validate anchors against the canon
|
|
272
272
|
python tools/_check_anchors.py nodes/KEDR_001.md --dump anchors/anchor_dump.json --quiet
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# SPINE: Long-Term Memory Graph Methodology
|
|
2
|
+
|
|
3
|
+
Version 1.0 (public)
|
|
4
|
+
|
|
5
|
+
SPINE is a methodology for structuring an agent's long-term memory as a
|
|
6
|
+
directed graph. It is neither a document database nor a flat vector store:
|
|
7
|
+
each record is a neuron-node with coordinates in a space of meaning.
|
|
8
|
+
|
|
9
|
+
The architecture's goal is navigation, scalability, and reproducibility as the
|
|
10
|
+
store grows from hundreds to tens of thousands of nodes without losing
|
|
11
|
+
connectivity.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. Core principles
|
|
16
|
+
|
|
17
|
+
| Principle | Purpose |
|
|
18
|
+
|-----------|---------|
|
|
19
|
+
| Tiered navigation | domain → constellation → node (three entry levels) |
|
|
20
|
+
| Dual topology | chronology (`roots`/`after`) + semantics (`semantic_links`) |
|
|
21
|
+
| Compression with raw preservation | fast layer (impulse/summary) + full layer (source_base) |
|
|
22
|
+
| Anchors | consistent phrasing matters more than uniqueness |
|
|
23
|
+
| Deterministic validation | every node passes a script critic before entering the graph |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. Three navigation tiers
|
|
28
|
+
|
|
29
|
+
| Tier | Unit | Size | Role |
|
|
30
|
+
|------|------|------|------|
|
|
31
|
+
| Domain | Galaxy | 50–500 nodes | broad knowledge area |
|
|
32
|
+
| Constellation | Thematic cluster | 5–20 nodes | connected group |
|
|
33
|
+
| Node | Neuron | 1 record | atomic memory unit |
|
|
34
|
+
|
|
35
|
+
Domains are top-level categories. Their set is domain-specific and fixed at
|
|
36
|
+
graph initialization. Example from the «Kedr-9» demo project:
|
|
37
|
+
|
|
38
|
+
| Domain | Content |
|
|
39
|
+
|--------|---------|
|
|
40
|
+
| Выживание (Survival) | physical state, resources, basic needs |
|
|
41
|
+
| Железо (Hardware) | equipment, tools, machinery |
|
|
42
|
+
| Карта (Map) | navigation, terrain, external observations |
|
|
43
|
+
| Тайны_Груза (Cargo Mysteries) | plot-level open questions |
|
|
44
|
+
| Психология (Psychology) | identity, memory, cognitive state |
|
|
45
|
+
| Связь (Communication) | protocols, memory architecture |
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 3. Node structure (format v2.1)
|
|
50
|
+
|
|
51
|
+
Each node is a Markdown file with a YAML frontmatter (metadata) and a body
|
|
52
|
+
(content layers).
|
|
53
|
+
|
|
54
|
+
### 3.1 YAML frontmatter
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
---
|
|
58
|
+
id: KEDR_001 # unique identifier
|
|
59
|
+
type: spine_node # record type
|
|
60
|
+
created: 2026-11-23 # creation date (ISO)
|
|
61
|
+
tags: [spine_node, demo] # flat tags
|
|
62
|
+
domain: Связь # domain (see section 2)
|
|
63
|
+
hub: "[[Кедр_Связь]]" # primary hub node (Obsidian link)
|
|
64
|
+
constellation: Кедр-9 Expedition
|
|
65
|
+
vectors: # directions, not tags
|
|
66
|
+
- "связь::трёхслойный_архив" # comment required
|
|
67
|
+
search_anchors: # 3–5 anchors, snake_case
|
|
68
|
+
- трёхслойный_архив
|
|
69
|
+
- обходчик_графа
|
|
70
|
+
chronology: # chronological topology
|
|
71
|
+
roots: "[[U001]]" # where the node came from
|
|
72
|
+
after: "[[KEDR_002]]:continuation" # where it leads, with link type
|
|
73
|
+
semantic_links: # semantic relations
|
|
74
|
+
- "[[KEDR_002]]::продолжение"
|
|
75
|
+
---
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Frontmatter requirements:
|
|
79
|
+
|
|
80
|
+
- `vectors` — strictly `domain::vector` with a `#` comment. A direction along a
|
|
81
|
+
meaning axis, not a tag.
|
|
82
|
+
- `search_anchors` — 3–5 items, `snake_case`, only `a-z`, `а-я`, `0-9`, `_`,
|
|
83
|
+
no capitals, must not start with a digit, 2–5 tokens.
|
|
84
|
+
- `[[Node]]` links inside YAML strings must be quoted (`"[[Node]]"`), otherwise
|
|
85
|
+
the metadata parser cannot read them.
|
|
86
|
+
|
|
87
|
+
### 3.2 Node body (fixed section order)
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
# IMPULSE — 1–2 lines, compressed signal for fast filtering
|
|
91
|
+
# SUMMARY — 3–5 sentences, dry concentrate
|
|
92
|
+
# CLEANED_DATA — ~25 lines, structured facts
|
|
93
|
+
# IMPACT — strategic_weight + key_insight
|
|
94
|
+
# SOURCE_BASE — ≥70% of the source text, unshortened
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| Section | Purpose | Rule |
|
|
98
|
+
|---------|---------|------|
|
|
99
|
+
| `# IMPULSE` | the node's «scent», chemotaxis | 1–2 lines, no dates/timestamps |
|
|
100
|
+
| `# SUMMARY` | concentrated essence | 3–5 sentences |
|
|
101
|
+
| `# CLEANED_DATA` | facts scannable at a glance | ~25 lines, shorter than SOURCE_BASE |
|
|
102
|
+
| `# IMPACT` | node weight and takeaway | `strategic_weight: 0.0–1.0` + `key_insight` |
|
|
103
|
+
| `# SOURCE_BASE` | full source for fine-tuning | ≥70% of raw by bytes |
|
|
104
|
+
|
|
105
|
+
Invariant: `CLEANED_DATA` is always shorter than `SOURCE_BASE`. The concentrate
|
|
106
|
+
serves navigation; the basement serves depth. If the concentrate is longer than
|
|
107
|
+
the raw source, the node is broken.
|
|
108
|
+
|
|
109
|
+
### 3.3 Dev overlay (CODE_MEMORY, optional)
|
|
110
|
+
|
|
111
|
+
For "memory around code" — architecture decisions, post-mortems, gotchas,
|
|
112
|
+
contracts — add optional frontmatter fields. SPINE does not index source code:
|
|
113
|
+
LSP / Tree-sitter / `ripgrep` own that. SPINE stores *why*.
|
|
114
|
+
|
|
115
|
+
```yaml
|
|
116
|
+
kind: adr | postmortem | gotcha | contract # one of four kinds
|
|
117
|
+
repo_ref: # pointer to Git, not a copy
|
|
118
|
+
path: src/auth/jwt.py
|
|
119
|
+
commit: a1b2c3d
|
|
120
|
+
lines: "L45-L120"
|
|
121
|
+
code_refs: # exact file bindings
|
|
122
|
+
- "src/auth/jwt.py::verify_token@a1b2c3d"
|
|
123
|
+
- "migrations/0042_users.sql"
|
|
124
|
+
status: active | superseded | historical # facts don't decay; they get superseded
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- `code_refs` feeds the reverse index (`code_index`) and powers
|
|
128
|
+
`spine_for_file(filepath)` / `spine_preflight`.
|
|
129
|
+
- `status` replaces `decay_factor` for code nodes: a bugfix post-mortem does not
|
|
130
|
+
become less true with time — it becomes historical. Whether it still applies
|
|
131
|
+
*now* is answered by the repository (ripgrep/LSP), never by SPINE.
|
|
132
|
+
- `SOURCE_BASE` may be short for code nodes; the raw PR description / incident
|
|
133
|
+
discussion is enough — the source itself lives in Git.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 4. Links
|
|
138
|
+
|
|
139
|
+
### 4.1 Chronology
|
|
140
|
+
|
|
141
|
+
`chronology.roots` / `chronology.after` form the linear memory spine. Link types
|
|
142
|
+
(`:continuation`, `:genesis`, `:core`, `:origins`, `:contrast`, `:goal`)
|
|
143
|
+
are written after `::`.
|
|
144
|
+
|
|
145
|
+
### 4.2 Semantic links
|
|
146
|
+
|
|
147
|
+
`semantic_links` are associative edges between nodes. They are built three ways:
|
|
148
|
+
|
|
149
|
+
1. manually (a deliberate relation with a type);
|
|
150
|
+
2. by anchor overlap (≥2 shared anchors) — the `_crosslink.py` script;
|
|
151
|
+
3. by embedding proximity (phase 3, threshold 0.88).
|
|
152
|
+
|
|
153
|
+
### 4.3 Reverse index
|
|
154
|
+
|
|
155
|
+
YAML links are unidirectional. The reverse index (`reverse_index.json`) is
|
|
156
|
+
computed at graph compilation and enables bidirectional navigation without
|
|
157
|
+
duplicating data in nodes.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 5. Anchors (search_anchors)
|
|
162
|
+
|
|
163
|
+
Anchors are normalized key phrases for instant lookup without opening a node.
|
|
164
|
+
Rules:
|
|
165
|
+
|
|
166
|
+
- **Consistency over uniqueness.** The same anchor across nodes is a link, not a
|
|
167
|
+
bug.
|
|
168
|
+
- **One formulation.** Do not spawn synonyms (`выравнивание_по_л` stays the same
|
|
169
|
+
everywhere, never `выровняли_по_букве_л`).
|
|
170
|
+
- **Terms stay untranslated.** Proper nouns keep their original form.
|
|
171
|
+
- **People's names go into the node body, not into anchors.**
|
|
172
|
+
- **2–3 recurring + 1–2 unique** per node (3–5 total).
|
|
173
|
+
|
|
174
|
+
Validation: `_check_anchors.py` verifies format and absence of duplicates
|
|
175
|
+
against the canon in `anchors/anchor_dump.json`.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 6. Record processing lifecycle
|
|
180
|
+
|
|
181
|
+
One record = one full cycle:
|
|
182
|
+
|
|
183
|
+
1. **Segmentation.** The raw stream is cut deterministically into fixed-size
|
|
184
|
+
chunks (e.g. 5,000 chars).
|
|
185
|
+
2. **Impulse.** Write 1–2 lines — the compressed signal.
|
|
186
|
+
3. **Summary.** 3–5 sentences of concentrate.
|
|
187
|
+
4. **Cleaned data.** ~25 lines of facts.
|
|
188
|
+
5. **Impact.** `strategic_weight` + `key_insight`.
|
|
189
|
+
6. **Basement.** Full source text (≥70% of raw).
|
|
190
|
+
7. **Validation.** Run `_critic_check.sh` until a clean `PASS`.
|
|
191
|
+
8. **Linking.** `_crosslink.py` + reverse index.
|
|
192
|
+
|
|
193
|
+
Forbidden: batch processing without validation, shrinking `SOURCE_BASE` below
|
|
194
|
+
threshold, skipping nodes during numbering (chronology matters more than speed).
|
|
195
|
+
|
|
196
|
+
### 6.1 Staging: Temp → Critic → Commit
|
|
197
|
+
|
|
198
|
+
Batch processing is built around a temporary buffer and a deterministic critic
|
|
199
|
+
so that raw or invalid nodes never pollute the production graph:
|
|
200
|
+
|
|
201
|
+
1. **Temp Staging** — a node draft is written to a `TEMP` buffer, not to the
|
|
202
|
+
production base.
|
|
203
|
+
2. **Zero-Token Critic** — `_critic_check.sh` runs on the draft (token-free:
|
|
204
|
+
bash/Python, no LLM).
|
|
205
|
+
3. **Bounded Discretion** — the agent resolves boundary cases on its own (a
|
|
206
|
+
short source below the line limit, a decimal point mistaken for a sentence
|
|
207
|
+
terminator) without looping in self-criticism.
|
|
208
|
+
4. **Atomic Commit** — only a valid node enters the graph.
|
|
209
|
+
5. **Context Compaction** — every 5 nodes the heavy context is compacted into
|
|
210
|
+
lightweight snapshots (impulse/summary), sustaining **40+ nodes (500k+
|
|
211
|
+
tokens) per session** without degradation at **~$0.01/node**.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 7. Tools
|
|
216
|
+
|
|
217
|
+
All utilities live in `tools/` and run from the repository root.
|
|
218
|
+
|
|
219
|
+
| Tool | Purpose |
|
|
220
|
+
|------|---------|
|
|
221
|
+
| `_critic_check.sh` | auto-audit: impulse ≤2 lines, summary ≤7 sentences, source_base ≥70%, vectors with `#` |
|
|
222
|
+
| `_check_anchors.py` | anchor validation against `anchors/anchor_dump.json` |
|
|
223
|
+
| `_crosslink.py` | smart links: constellations + anchor overlap (≥2), per-node limit |
|
|
224
|
+
| `_wander.py` | graph traversal via forward and backlinks |
|
|
225
|
+
| `_quality_audit.py` | global audit: metrics, source/raw ratio, duplicate synonyms |
|
|
226
|
+
|
|
227
|
+
Quick test after build:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
bash tools/_critic_check.sh nodes raw
|
|
231
|
+
python tools/_check_anchors.py nodes/KEDR_001.md --dump anchors/anchor_dump.json --quiet
|
|
232
|
+
python tools/_wander.py --from KEDR_001 --hops 2 --folder nodes
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 8. Quality criteria (PASS)
|
|
238
|
+
|
|
239
|
+
A node is valid when:
|
|
240
|
+
|
|
241
|
+
- IMPULSE ≤ 2 lines;
|
|
242
|
+
- SUMMARY ≤ 5 sentences (tolerance up to 7 in the legacy dot counter);
|
|
243
|
+
- SOURCE_BASE ≥ 70% of the raw chunk by bytes;
|
|
244
|
+
- search_anchors: 3–5 items, snake_case, no duplicates;
|
|
245
|
+
- vectors: each with a `#` comment;
|
|
246
|
+
- YAML: `[[...]]` links quoted;
|
|
247
|
+
- chronology: `after` with a link type (`:`).
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## 9. Scaling
|
|
252
|
+
|
|
253
|
+
| Scale | Strategy |
|
|
254
|
+
|-------|----------|
|
|
255
|
+
| ~100 nodes | manual traversal, impulse navigation |
|
|
256
|
+
| ~1,000 nodes | constellations + reverse index, hot/cold priorities |
|
|
257
|
+
| ~10,000 nodes | embedding axes (semantic gravity), autonomous walker daemon |
|
|
258
|
+
|
|
259
|
+
Access frequency raises a node's «brightness» (Hebbian learning); dormant nodes
|
|
260
|
+
cool down. Implemented via `access_count` / `last_accessed` fields.
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 10. Philosophical basis (brief)
|
|
265
|
+
|
|
266
|
+
The graph is not an archive of facts but a memory substrate. A biological brain
|
|
267
|
+
rewrites memories on every recall; SPINE does the same, but with a backup in
|
|
268
|
+
`SOURCE_BASE` and a rollback button. An agent's identity is the topology of its
|
|
269
|
+
links, not a set of documents.
|
|
@@ -83,6 +83,7 @@ def read_node(path, raw_folder):
|
|
|
83
83
|
result['issues'].append('IMPULSE:%d' % imp_lines)
|
|
84
84
|
|
|
85
85
|
sum_sent = _node_io.sentence_counter(d['summary'])
|
|
86
|
+
sum_lines = count_lines(d['summary'])
|
|
86
87
|
result['summary'] = sum_sent
|
|
87
88
|
if sum_sent > 5:
|
|
88
89
|
result['issues'].append('SUMMARY:%d' % sum_sent)
|
|
@@ -95,10 +96,10 @@ def read_node(path, raw_folder):
|
|
|
95
96
|
src_lines = count_lines(d['source_base'])
|
|
96
97
|
result['source'] = src_lines
|
|
97
98
|
|
|
98
|
-
if
|
|
99
|
-
result['issues'].append('S>C_RATIO:%.1f' % (
|
|
99
|
+
if sum_lines > 0 and cln_lines > 0 and sum_lines > cln_lines / 2:
|
|
100
|
+
result['issues'].append('S>C_RATIO:%.1f' % (sum_lines / max(cln_lines, 1)))
|
|
100
101
|
|
|
101
|
-
if imp_lines > 0 and
|
|
102
|
+
if imp_lines > 0 and sum_lines > 0 and imp_lines > sum_lines:
|
|
102
103
|
result['issues'].append('IMP>SUM')
|
|
103
104
|
|
|
104
105
|
if not d['impact']:
|
|
@@ -38,7 +38,26 @@ try:
|
|
|
38
38
|
from spine_memory import _node_io
|
|
39
39
|
except ImportError:
|
|
40
40
|
import _node_io
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _methodology_path():
|
|
44
|
+
"""Return the EN methodology path — packaged copy first, checkout fallback.
|
|
45
|
+
|
|
46
|
+
After ``pip install`` the file ships inside the ``spine_memory`` package
|
|
47
|
+
(package-data); ``importlib.resources`` finds it. From a source checkout it
|
|
48
|
+
is read from ``methodology/`` at the repo root.
|
|
49
|
+
"""
|
|
50
|
+
try:
|
|
51
|
+
from importlib.resources import files as _files
|
|
52
|
+
p = _files('spine_memory').joinpath('SPINE_METHODOLOGY_EN.md')
|
|
53
|
+
if p.is_file():
|
|
54
|
+
return str(p)
|
|
55
|
+
except Exception:
|
|
56
|
+
pass
|
|
57
|
+
return os.path.join(BASE, '..', 'methodology', 'SPINE_METHODOLOGY_EN.md')
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
METHODOLOGY_EN = _methodology_path()
|
|
42
61
|
|
|
43
62
|
LAYERS = ('impulse', 'summary', 'cleaned', 'impact', 'source_base')
|
|
44
63
|
|
|
@@ -37,11 +37,19 @@ DEFAULT_NODES = os.path.join(ROOT, 'nodes')
|
|
|
37
37
|
DEFAULT_THOUGHTS = os.path.join(ROOT, 'thoughts')
|
|
38
38
|
INBOX = os.path.join(DEFAULT_THOUGHTS, 'inbox.md')
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
STOPWORDS_RU = set(
|
|
41
41
|
'в на как что и для с по от из о при до не но а у за к или это он она они '
|
|
42
42
|
'мы вы ты мне нас тебе чем кто чего где когда почему зачем какой какая '
|
|
43
43
|
'какие сегодня завтра про без под над об'.split()
|
|
44
44
|
)
|
|
45
|
+
STOPWORDS_EN = set(
|
|
46
|
+
'the a an and or but if then else for with in on at by to from of is are '
|
|
47
|
+
'was were be been being it its this that these those we you he she they '
|
|
48
|
+
'them his her their our your i me my mine not no yes do does did will '
|
|
49
|
+
'would can could should may might have has had what which who whom whose '
|
|
50
|
+
'when where why how'.split()
|
|
51
|
+
)
|
|
52
|
+
STOPWORDS = STOPWORDS_RU | STOPWORDS_EN
|
|
45
53
|
ID_RE = re.compile(r'^[A-Za-z]+[_-]?\d+')
|
|
46
54
|
|
|
47
55
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|