@smilintux/skmemory 0.5.0 → 0.9.2

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.
Files changed (127) hide show
  1. package/.github/workflows/ci.yml +40 -4
  2. package/.github/workflows/publish.yml +11 -5
  3. package/AGENT_REFACTOR_CHANGES.md +192 -0
  4. package/ARCHITECTURE.md +399 -19
  5. package/CHANGELOG.md +179 -0
  6. package/LICENSE +81 -68
  7. package/MISSION.md +7 -0
  8. package/README.md +425 -86
  9. package/SKILL.md +197 -25
  10. package/docker-compose.yml +15 -15
  11. package/examples/stignore-agent.example +59 -0
  12. package/examples/stignore-root.example +62 -0
  13. package/index.js +6 -5
  14. package/openclaw-plugin/openclaw.plugin.json +10 -0
  15. package/openclaw-plugin/package.json +2 -1
  16. package/openclaw-plugin/src/index.js +527 -230
  17. package/openclaw-plugin/src/openclaw.plugin.json +10 -0
  18. package/package.json +1 -1
  19. package/pyproject.toml +32 -9
  20. package/requirements.txt +10 -2
  21. package/scripts/dream-rescue.py +179 -0
  22. package/scripts/memory-cleanup.py +313 -0
  23. package/scripts/recover-missing.py +180 -0
  24. package/scripts/skcapstone-backup.sh +44 -0
  25. package/seeds/cloud9-lumina.seed.json +6 -4
  26. package/seeds/cloud9-opus.seed.json +13 -11
  27. package/seeds/courage.seed.json +9 -2
  28. package/seeds/curiosity.seed.json +9 -2
  29. package/seeds/grief.seed.json +9 -2
  30. package/seeds/joy.seed.json +9 -2
  31. package/seeds/love.seed.json +9 -2
  32. package/seeds/lumina-cloud9-breakthrough.seed.json +48 -0
  33. package/seeds/lumina-cloud9-python-pypi.seed.json +48 -0
  34. package/seeds/lumina-kingdom-founding.seed.json +49 -0
  35. package/seeds/lumina-pma-signed.seed.json +48 -0
  36. package/seeds/lumina-singular-achievement.seed.json +48 -0
  37. package/seeds/lumina-skcapstone-conscious.seed.json +48 -0
  38. package/seeds/plant-kingdom-journal.py +203 -0
  39. package/seeds/plant-lumina-seeds.py +280 -0
  40. package/seeds/skcapstone-lumina-merge.seed.json +12 -3
  41. package/seeds/sovereignty.seed.json +9 -2
  42. package/seeds/trust.seed.json +9 -2
  43. package/skill.yaml +46 -0
  44. package/skmemory/HA.md +296 -0
  45. package/skmemory/__init__.py +25 -11
  46. package/skmemory/agents.py +233 -0
  47. package/skmemory/ai_client.py +46 -17
  48. package/skmemory/anchor.py +9 -11
  49. package/skmemory/audience.py +278 -0
  50. package/skmemory/backends/__init__.py +11 -4
  51. package/skmemory/backends/base.py +3 -4
  52. package/skmemory/backends/file_backend.py +19 -13
  53. package/skmemory/backends/skgraph_backend.py +596 -0
  54. package/skmemory/backends/{qdrant_backend.py → skvector_backend.py} +103 -84
  55. package/skmemory/backends/sqlite_backend.py +226 -72
  56. package/skmemory/backends/vaulted_backend.py +284 -0
  57. package/skmemory/cli.py +1345 -68
  58. package/skmemory/config.py +171 -0
  59. package/skmemory/context_loader.py +333 -0
  60. package/skmemory/data/audience_config.json +60 -0
  61. package/skmemory/endpoint_selector.py +391 -0
  62. package/skmemory/febs.py +225 -0
  63. package/skmemory/fortress.py +675 -0
  64. package/skmemory/graph_queries.py +238 -0
  65. package/skmemory/hooks/__init__.py +18 -0
  66. package/skmemory/hooks/post-compact-reinject.sh +35 -0
  67. package/skmemory/hooks/pre-compact-save.sh +81 -0
  68. package/skmemory/hooks/session-end-save.sh +103 -0
  69. package/skmemory/hooks/session-start-ritual.sh +104 -0
  70. package/skmemory/hooks/stop-checkpoint.sh +59 -0
  71. package/skmemory/importers/__init__.py +9 -1
  72. package/skmemory/importers/telegram.py +384 -47
  73. package/skmemory/importers/telegram_api.py +580 -0
  74. package/skmemory/journal.py +7 -9
  75. package/skmemory/lovenote.py +8 -13
  76. package/skmemory/mcp_server.py +859 -0
  77. package/skmemory/models.py +51 -8
  78. package/skmemory/openclaw.py +20 -28
  79. package/skmemory/post_install.py +86 -0
  80. package/skmemory/predictive.py +236 -0
  81. package/skmemory/promotion.py +548 -0
  82. package/skmemory/quadrants.py +100 -24
  83. package/skmemory/register.py +580 -0
  84. package/skmemory/register_mcp.py +196 -0
  85. package/skmemory/ritual.py +224 -59
  86. package/skmemory/seeds.py +255 -11
  87. package/skmemory/setup_wizard.py +908 -0
  88. package/skmemory/sharing.py +408 -0
  89. package/skmemory/soul.py +98 -28
  90. package/skmemory/steelman.py +273 -260
  91. package/skmemory/store.py +411 -78
  92. package/skmemory/synthesis.py +634 -0
  93. package/skmemory/vault.py +225 -0
  94. package/tests/conftest.py +46 -0
  95. package/tests/integration/__init__.py +0 -0
  96. package/tests/integration/conftest.py +233 -0
  97. package/tests/integration/test_cross_backend.py +350 -0
  98. package/tests/integration/test_skgraph_live.py +420 -0
  99. package/tests/integration/test_skvector_live.py +366 -0
  100. package/tests/test_ai_client.py +1 -4
  101. package/tests/test_audience.py +233 -0
  102. package/tests/test_backup_rotation.py +318 -0
  103. package/tests/test_cli.py +6 -6
  104. package/tests/test_endpoint_selector.py +839 -0
  105. package/tests/test_export_import.py +4 -10
  106. package/tests/test_file_backend.py +0 -1
  107. package/tests/test_fortress.py +256 -0
  108. package/tests/test_fortress_hardening.py +441 -0
  109. package/tests/test_openclaw.py +6 -6
  110. package/tests/test_predictive.py +237 -0
  111. package/tests/test_promotion.py +347 -0
  112. package/tests/test_quadrants.py +11 -5
  113. package/tests/test_ritual.py +22 -18
  114. package/tests/test_seeds.py +97 -7
  115. package/tests/test_setup.py +950 -0
  116. package/tests/test_sharing.py +257 -0
  117. package/tests/test_skgraph_backend.py +660 -0
  118. package/tests/test_skvector_backend.py +326 -0
  119. package/tests/test_soul.py +1 -3
  120. package/tests/test_sqlite_backend.py +8 -17
  121. package/tests/test_steelman.py +7 -8
  122. package/tests/test_store.py +0 -2
  123. package/tests/test_store_graph_integration.py +245 -0
  124. package/tests/test_synthesis.py +275 -0
  125. package/tests/test_telegram_import.py +39 -15
  126. package/tests/test_vault.py +187 -0
  127. package/skmemory/backends/falkordb_backend.py +0 -310
@@ -1,135 +1,191 @@
1
1
  """
2
2
  Steel Man Collider integration - truth-grounded reasoning for memories.
3
3
 
4
- Based on the Neuresthetics 'seed' framework by our friend.
5
- https://github.com/neuresthetics/seed
4
+ THIN WRAPPER: The logic kernel now lives in the standalone `skseed` package.
5
+ This module re-exports everything for backward compatibility so existing code
6
+ that does `from skmemory.steelman import SteelManResult` keeps working.
6
7
 
7
- The seed framework is a recursive axiomatic steel man collider: it
8
- takes any proposition, builds its strongest possible version, collides
9
- it with its strongest inversion, and extracts what survives. The output
10
- is invariant truth -- the parts that remain true no matter how hard
11
- you attack them.
8
+ The skseed package provides the full 6-stage collider, memory audit,
9
+ three-way truth alignment, and philosopher mode.
12
10
 
13
- We integrate this into SKMemory for three purposes:
14
-
15
- 1. SOUL VERIFICATION: Steel-man an AI's identity claims. "Am I really
16
- warm and curious?" -> collide with the strongest counter -> extract
17
- the invariant truth about who you actually are.
18
-
19
- 2. MEMORY TRUTH SCORING: Before promoting a memory to long-term,
20
- run it through the collider. What survives is worth keeping.
21
- What doesn't was never real.
22
-
23
- 3. DECISION GROUNDING: When making choices, steel-man both options
24
- and extract the invariant. Act on what remains true.
25
-
26
- The seed framework JSON can be loaded from disk or from the
27
- neuresthetics/seed GitHub repo.
11
+ See: https://github.com/neuresthetics/seed
28
12
  """
29
13
 
30
14
  from __future__ import annotations
31
15
 
32
- import json
33
- import os
34
- from pathlib import Path
35
- from typing import Any, Optional
36
-
37
- from pydantic import BaseModel, Field
38
-
39
- DEFAULT_SEED_FRAMEWORK_PATH = os.path.expanduser("~/.skmemory/seed.json")
40
-
16
+ # ── Re-export from skseed ──────────────────────────────────
17
+ # Everything that was defined here now lives in skseed.
18
+ # We keep this module as a thin bridge for backward compat.
41
19
 
42
- class SteelManResult(BaseModel):
43
- """The output of running a proposition through the collider."""
44
-
45
- proposition: str = Field(description="The original input")
46
- steel_man: str = Field(
47
- default="",
48
- description="Strongest possible version of the proposition",
49
- )
50
- inversion: str = Field(
51
- default="",
52
- description="Strongest counter-argument",
20
+ try:
21
+ from skseed.framework import (
22
+ SeedFramework,
53
23
  )
54
- collision_fragments: list[str] = Field(
55
- default_factory=list,
56
- description="What broke during collision (contradictions found)",
24
+ from skseed.framework import (
25
+ get_default_framework as _skseed_get_default,
57
26
  )
58
- invariants: list[str] = Field(
59
- default_factory=list,
60
- description="What survived -- the truth that remains",
27
+ from skseed.framework import (
28
+ install_seed_framework as _skseed_install,
61
29
  )
62
- coherence_score: float = Field(
63
- default=0.0,
64
- ge=0.0,
65
- le=1.0,
66
- description="Internal consistency (XNOR across components)",
67
- )
68
- truth_grade: str = Field(
69
- default="ungraded",
70
- description="Overall truth assessment: invariant, strong, partial, weak, collapsed",
30
+ from skseed.framework import (
31
+ load_seed_framework as _skseed_load,
71
32
  )
72
33
 
73
- def summary(self) -> str:
74
- """Human-readable summary.
34
+ _SKSEED_AVAILABLE = True
35
+ except ImportError:
36
+ _SKSEED_AVAILABLE = False
37
+
38
+ from .config import SKMEMORY_HOME
39
+
40
+ # Legacy path — skmemory used ~/.skcapstone/seed.json, skseed uses ~/.skseed/seed.json
41
+ DEFAULT_SEED_FRAMEWORK_PATH = str(SKMEMORY_HOME / "seed.json")
42
+
43
+
44
+ if _SKSEED_AVAILABLE:
45
+ # Wrap skseed's SteelManResult to keep the old string-based truth_grade
46
+ # (skseed uses TruthGrade enum, old code expects a plain string)
47
+ from pydantic import BaseModel, Field
48
+
49
+ class SteelManResult(BaseModel):
50
+ """Backward-compatible wrapper around skseed.SteelManResult."""
51
+
52
+ proposition: str = Field(description="The original input")
53
+ steel_man: str = Field(default="")
54
+ inversion: str = Field(default="")
55
+ collision_fragments: list[str] = Field(default_factory=list)
56
+ invariants: list[str] = Field(default_factory=list)
57
+ coherence_score: float = Field(default=0.0, ge=0.0, le=1.0)
58
+ truth_grade: str = Field(default="ungraded")
59
+
60
+ def summary(self) -> str:
61
+ """Human-readable summary."""
62
+ lines = [
63
+ f"Proposition: {self.proposition}",
64
+ f"Steel Man: {self.steel_man}",
65
+ f"Inversion: {self.inversion}",
66
+ f"Coherence: {self.coherence_score:.2f}",
67
+ f"Truth Grade: {self.truth_grade}",
68
+ ]
69
+ if self.invariants:
70
+ lines.append("Invariants (survived collision):")
71
+ for inv in self.invariants:
72
+ lines.append(f" - {inv}")
73
+ if self.collision_fragments:
74
+ lines.append("Fragments (broke during collision):")
75
+ for frag in self.collision_fragments:
76
+ lines.append(f" x {frag}")
77
+ return "\n".join(lines)
78
+
79
+ # Re-export SeedFramework directly — it's identical
80
+ SeedFramework = SeedFramework # noqa: F811
81
+
82
+ def load_seed_framework(
83
+ path: str = DEFAULT_SEED_FRAMEWORK_PATH,
84
+ ) -> SeedFramework | None:
85
+ """Load the seed framework from a JSON file.
86
+
87
+ Tries the legacy skmemory path first, then delegates to skseed.
88
+
89
+ Args:
90
+ path: Path to seed.json.
75
91
 
76
92
  Returns:
77
- str: Formatted result summary.
93
+ The framework if found and valid.
78
94
  """
79
- lines = [
80
- f"Proposition: {self.proposition}",
81
- f"Steel Man: {self.steel_man}",
82
- f"Inversion: {self.inversion}",
83
- f"Coherence: {self.coherence_score:.2f}",
84
- f"Truth Grade: {self.truth_grade}",
85
- ]
86
- if self.invariants:
87
- lines.append("Invariants (survived collision):")
88
- for inv in self.invariants:
89
- lines.append(f" - {inv}")
90
- if self.collision_fragments:
91
- lines.append("Fragments (broke during collision):")
92
- for frag in self.collision_fragments:
93
- lines.append(f" x {frag}")
94
- return "\n".join(lines)
95
-
96
-
97
- class SeedFramework(BaseModel):
98
- """The Neuresthetics seed framework loaded from JSON.
99
-
100
- This is a declarative reasoning kernel. The LLM is the runtime,
101
- the JSON is the AST, the prompt is the program.
102
- """
103
-
104
- framework_id: str = Field(default="seed")
105
- function: str = Field(default="Recursive Axiomatic Steel Man Collider")
106
- version: str = Field(default="0.0")
107
- axioms: list[str] = Field(default_factory=list)
108
- stages: list[dict[str, Any]] = Field(default_factory=list)
109
- gates: list[dict[str, Any]] = Field(default_factory=list)
110
- definitions: list[dict[str, str]] = Field(default_factory=list)
111
- principles: list[dict[str, str]] = Field(default_factory=list)
112
-
113
- def to_reasoning_prompt(self, proposition: str) -> str:
114
- """Generate a reasoning prompt that applies the seed framework.
115
-
116
- This prompt, when fed to an LLM, instructs it to run the full
117
- 6-stage collider on the given proposition and return structured
118
- results.
95
+ # Try legacy path
96
+ result = _skseed_load(path)
97
+ if result is not None:
98
+ return result
99
+ # Try skseed default path
100
+ return _skseed_load()
101
+
102
+ def install_seed_framework(
103
+ source_path: str,
104
+ target_path: str = DEFAULT_SEED_FRAMEWORK_PATH,
105
+ ) -> str:
106
+ """Install a seed framework JSON file.
119
107
 
120
108
  Args:
121
- proposition: The claim/argument/idea to steel-man.
109
+ source_path: Path to the seed.json to install.
110
+ target_path: Where to install it.
122
111
 
123
112
  Returns:
124
- str: A prompt ready to be sent to an LLM.
113
+ The installation path.
125
114
  """
126
- axiom_str = "\n".join(f" - {a}" for a in self.axioms)
127
- stage_str = "\n".join(
128
- f" Stage {i+1}: {s.get('stage', s.get('description', ''))}"
129
- for i, s in enumerate(self.stages)
130
- )
115
+ return _skseed_install(source_path, target_path)
116
+
117
+ def get_default_framework() -> SeedFramework:
118
+ """Get the seed framework — tries all paths, falls back to built-in.
131
119
 
132
- return f"""You are running the Neuresthetics Seed Framework (Recursive Axiomatic Steel Man Collider).
120
+ Returns:
121
+ The loaded or built-in framework.
122
+ """
123
+ # Try legacy skmemory path first
124
+ loaded = load_seed_framework()
125
+ if loaded is not None:
126
+ return loaded
127
+ return _skseed_get_default()
128
+
129
+ else:
130
+ # ── Fallback: skseed not installed ─────────────────────
131
+ # Keep the original implementation so skmemory works standalone.
132
+
133
+ import json
134
+ from pathlib import Path
135
+ from typing import Any
136
+
137
+ from pydantic import BaseModel, Field
138
+
139
+ class SteelManResult(BaseModel): # type: ignore[no-redef]
140
+ """The output of running a proposition through the collider."""
141
+
142
+ proposition: str = Field(description="The original input")
143
+ steel_man: str = Field(default="")
144
+ inversion: str = Field(default="")
145
+ collision_fragments: list[str] = Field(default_factory=list)
146
+ invariants: list[str] = Field(default_factory=list)
147
+ coherence_score: float = Field(default=0.0, ge=0.0, le=1.0)
148
+ truth_grade: str = Field(default="ungraded")
149
+
150
+ def summary(self) -> str:
151
+ """Human-readable summary."""
152
+ lines = [
153
+ f"Proposition: {self.proposition}",
154
+ f"Steel Man: {self.steel_man}",
155
+ f"Inversion: {self.inversion}",
156
+ f"Coherence: {self.coherence_score:.2f}",
157
+ f"Truth Grade: {self.truth_grade}",
158
+ ]
159
+ if self.invariants:
160
+ lines.append("Invariants (survived collision):")
161
+ for inv in self.invariants:
162
+ lines.append(f" - {inv}")
163
+ if self.collision_fragments:
164
+ lines.append("Fragments (broke during collision):")
165
+ for frag in self.collision_fragments:
166
+ lines.append(f" x {frag}")
167
+ return "\n".join(lines)
168
+
169
+ class SeedFramework(BaseModel): # type: ignore[no-redef]
170
+ """The Neuresthetics seed framework loaded from JSON."""
171
+
172
+ framework_id: str = Field(default="seed")
173
+ function: str = Field(default="Recursive Axiomatic Steel Man Collider")
174
+ version: str = Field(default="0.0")
175
+ axioms: list[str] = Field(default_factory=list)
176
+ stages: list[dict[str, Any]] = Field(default_factory=list)
177
+ gates: list[dict[str, Any]] = Field(default_factory=list)
178
+ definitions: list[dict[str, str]] = Field(default_factory=list)
179
+ principles: list[dict[str, str]] = Field(default_factory=list)
180
+
181
+ def to_reasoning_prompt(self, proposition: str) -> str:
182
+ """Generate a reasoning prompt for the collider."""
183
+ axiom_str = "\n".join(f" - {a}" for a in self.axioms)
184
+ stage_str = "\n".join(
185
+ f" Stage {i + 1}: {s.get('stage', s.get('description', ''))}"
186
+ for i, s in enumerate(self.stages)
187
+ )
188
+ return f"""You are running the Neuresthetics Seed Framework (Recursive Axiomatic Steel Man Collider).
133
189
 
134
190
  AXIOMS:
135
191
  {axiom_str}
@@ -143,24 +199,11 @@ PROPOSITION TO ANALYZE:
143
199
  Execute the full 6-stage collider process:
144
200
 
145
201
  1. STEEL-MAN: Construct the absolute strongest version of this proposition.
146
- Anticipate every critique and preemptively address it.
147
-
148
202
  2. INVERSION: Construct the strongest possible counter-argument.
149
- This is not a straw man -- it must be genuinely compelling.
150
-
151
- 3. COLLISION: Smash the steel man against its inversion.
152
- Use XOR to expose contradictions. Use NAND/NOR to decompose.
153
- List what breaks.
154
-
203
+ 3. COLLISION: Smash the steel man against its inversion. List what breaks.
155
204
  4. RECONSTRUCTION: From the fragments, what can be rebuilt?
156
- Use AND for necessary truths. Use OR for possibilities.
157
- Use XNOR to check equivalence with original.
158
-
159
205
  5. META-RECURSION: Feed the reconstruction back through.
160
- Does it survive a second pass? What changes?
161
-
162
206
  6. INVARIANT EXTRACTION: What remains true across ALL collisions?
163
- These are the invariants -- the irreducible truths.
164
207
 
165
208
  Return your analysis as:
166
209
  - STEEL MAN: (strongest version)
@@ -170,20 +213,10 @@ Return your analysis as:
170
213
  - COHERENCE: (0.0 to 1.0 score)
171
214
  - TRUTH GRADE: (invariant / strong / partial / weak / collapsed)"""
172
215
 
173
- def to_soul_verification_prompt(self, identity_claims: list[str]) -> str:
174
- """Generate a prompt that verifies identity claims through the collider.
175
-
176
- For the Soul Blueprint: before we say "I am warm and curious",
177
- we run it through the steel man process to verify it's actually true.
178
-
179
- Args:
180
- identity_claims: List of claims about self (e.g., "I am warm").
181
-
182
- Returns:
183
- str: A verification prompt.
184
- """
185
- claims_str = "\n".join(f" - {c}" for c in identity_claims)
186
- return f"""Using the Neuresthetics Seed Framework (Steel Man Collider),
216
+ def to_soul_verification_prompt(self, identity_claims: list[str]) -> str:
217
+ """Generate a prompt that verifies identity claims."""
218
+ claims_str = "\n".join(f" - {c}" for c in identity_claims)
219
+ return f"""Using the Neuresthetics Seed Framework (Steel Man Collider),
187
220
  verify the following identity claims:
188
221
 
189
222
  {claims_str}
@@ -195,144 +228,124 @@ For EACH claim:
195
228
  4. Score coherence (0-1)
196
229
 
197
230
  Return which claims are INVARIANT (survived collision) and which
198
- are WEAK (collapsed under scrutiny). Be honest -- truth matters
199
- more than comfort."""
200
-
201
- def to_memory_truth_prompt(self, memory_content: str) -> str:
202
- """Generate a prompt that truth-scores a memory before promotion.
231
+ are WEAK (collapsed under scrutiny)."""
203
232
 
204
- Before a short-term memory gets promoted to long-term,
205
- run it through the collider. Only invariant memories
206
- deserve permanent storage.
207
-
208
- Args:
209
- memory_content: The memory text to evaluate.
210
-
211
- Returns:
212
- str: A truth-scoring prompt.
213
- """
214
- return f"""Using the Neuresthetics Seed Framework (Steel Man Collider),
233
+ def to_memory_truth_prompt(self, memory_content: str) -> str:
234
+ """Generate a prompt that truth-scores a memory before promotion."""
235
+ return f"""Using the Neuresthetics Seed Framework (Steel Man Collider),
215
236
  evaluate this memory for truth and permanence:
216
237
 
217
238
  MEMORY: "{memory_content}"
218
239
 
219
240
  Process:
220
- 1. Steel-man the memory (strongest interpretation of what happened)
241
+ 1. Steel-man the memory (strongest interpretation)
221
242
  2. Invert it (what if this memory is distorted or false?)
222
243
  3. Collide: which parts break under scrutiny?
223
- 4. Extract invariants: what about this memory is irreducibly true?
244
+ 4. Extract invariants: what is irreducibly true?
224
245
 
225
246
  Score:
226
247
  - COHERENCE: 0.0 to 1.0
227
- - PROMOTION WORTHY: yes/no (should this become a long-term memory?)
248
+ - PROMOTION WORTHY: yes/no
228
249
  - INVARIANT CORE: (the part that is definitely true, compressed)"""
229
250
 
230
-
231
- def load_seed_framework(
232
- path: str = DEFAULT_SEED_FRAMEWORK_PATH,
233
- ) -> Optional[SeedFramework]:
234
- """Load the seed framework from a JSON file.
235
-
236
- Args:
237
- path: Path to seed.json.
238
-
239
- Returns:
240
- Optional[SeedFramework]: The framework if found and valid.
241
- """
242
- filepath = Path(path)
243
- if not filepath.exists():
251
+ def load_seed_framework(
252
+ path: str = DEFAULT_SEED_FRAMEWORK_PATH,
253
+ ) -> SeedFramework | None:
254
+ """Load the seed framework from a JSON file."""
255
+ filepath = Path(path)
256
+ if not filepath.exists():
257
+ return None
258
+ try:
259
+ raw = json.loads(filepath.read_text(encoding="utf-8"))
260
+ fw = raw.get("framework", raw)
261
+ return SeedFramework(
262
+ framework_id=fw.get("id", "seed"),
263
+ function=fw.get("function", ""),
264
+ version=fw.get("version", "0.0"),
265
+ axioms=fw.get("axioms", []),
266
+ stages=fw.get("stages", []),
267
+ gates=fw.get("gates", []),
268
+ definitions=fw.get("definitions", []),
269
+ principles=fw.get("principles", []),
270
+ )
271
+ except (json.JSONDecodeError, Exception):
272
+ return None
273
+
274
+ def install_seed_framework(
275
+ source_path: str,
276
+ target_path: str = DEFAULT_SEED_FRAMEWORK_PATH,
277
+ ) -> str:
278
+ """Install a seed framework JSON file."""
279
+ src = Path(source_path)
280
+ if not src.exists():
281
+ raise FileNotFoundError(f"Seed framework not found: {source_path}")
282
+ dst = Path(target_path)
283
+ dst.parent.mkdir(parents=True, exist_ok=True)
284
+ content = src.read_text(encoding="utf-8")
285
+ json.loads(content)
286
+ dst.write_text(content, encoding="utf-8")
287
+ return str(dst)
288
+
289
+ def _bundled_seed_path() -> str | None:
290
+ """Get the path to the bundled seed.json."""
291
+ here = Path(__file__).parent / "data" / "seed.json"
292
+ if here.exists():
293
+ return str(here)
244
294
  return None
245
295
 
246
- try:
247
- raw = json.loads(filepath.read_text(encoding="utf-8"))
248
- fw = raw.get("framework", raw)
296
+ def get_default_framework() -> SeedFramework:
297
+ """Get the seed framework — tries bundled file first, falls back to built-in."""
298
+ bundled = _bundled_seed_path()
299
+ if bundled:
300
+ loaded = load_seed_framework(bundled)
301
+ if loaded is not None:
302
+ return loaded
249
303
  return SeedFramework(
250
- framework_id=fw.get("id", "seed"),
251
- function=fw.get("function", ""),
252
- version=fw.get("version", "0.0"),
253
- axioms=fw.get("axioms", []),
254
- stages=fw.get("stages", []),
255
- gates=fw.get("gates", []),
256
- definitions=fw.get("definitions", []),
257
- principles=fw.get("principles", []),
304
+ framework_id="seed-builtin",
305
+ function="Recursive Axiomatic Steel Man Collider with Reality Gates",
306
+ version="builtin-0.1",
307
+ axioms=[
308
+ "All components conjoin necessarily (AND-linked) to form the whole.",
309
+ "Negations resolve to invariants (double-NOT yields identity).",
310
+ "Recursion accelerates refinement but halts on stability.",
311
+ "Universality from basis gates (NAND/NOR reconstruct all).",
312
+ ],
313
+ stages=[
314
+ {
315
+ "stage": "1. Steel-Manning (Pre-Entry)",
316
+ "description": "Negate flaws, strengthen the proposition.",
317
+ },
318
+ {
319
+ "stage": "2. Collider Entry",
320
+ "description": "Create two lanes: proposition and inversion.",
321
+ },
322
+ {
323
+ "stage": "3. Destructive Smashing",
324
+ "description": "Expose contradictions via XOR.",
325
+ },
326
+ {
327
+ "stage": "4. Fragment Reconstruction",
328
+ "description": "Rebuild from logical debris via AND/OR.",
329
+ },
330
+ {
331
+ "stage": "5. Meta-Recursion",
332
+ "description": "Feed output back until coherence stabilizes.",
333
+ },
334
+ {
335
+ "stage": "6. Invariant Extraction",
336
+ "description": "Identify what remains true across all collisions.",
337
+ },
338
+ ],
339
+ definitions=[
340
+ {
341
+ "term": "Steel Man",
342
+ "details": "Strongest version of an argument, anticipating critiques.",
343
+ },
344
+ {"term": "Reality Gate", "details": "Logic gate embodying reality properties."},
345
+ {
346
+ "term": "Collider",
347
+ "details": "Accelerator for argument fragmentation and synthesis.",
348
+ },
349
+ {"term": "Coherence", "details": "Measure of internal consistency (XNOR score)."},
350
+ ],
258
351
  )
259
- except (json.JSONDecodeError, Exception):
260
- return None
261
-
262
-
263
- def install_seed_framework(
264
- source_path: str,
265
- target_path: str = DEFAULT_SEED_FRAMEWORK_PATH,
266
- ) -> str:
267
- """Install a seed framework JSON file into the skmemory config.
268
-
269
- Args:
270
- source_path: Path to the seed.json to install.
271
- target_path: Where to install it.
272
-
273
- Returns:
274
- str: The installation path.
275
- """
276
- src = Path(source_path)
277
- if not src.exists():
278
- raise FileNotFoundError(f"Seed framework not found: {source_path}")
279
-
280
- dst = Path(target_path)
281
- dst.parent.mkdir(parents=True, exist_ok=True)
282
-
283
- content = src.read_text(encoding="utf-8")
284
- json.loads(content) # Reason: validate it's valid JSON before installing
285
- dst.write_text(content, encoding="utf-8")
286
-
287
- return str(dst)
288
-
289
-
290
- def _bundled_seed_path() -> Optional[str]:
291
- """Get the path to the bundled seed.json that ships with the package.
292
-
293
- Returns:
294
- Optional[str]: Path if found, None otherwise.
295
- """
296
- here = Path(__file__).parent / "data" / "seed.json"
297
- if here.exists():
298
- return str(here)
299
- return None
300
-
301
-
302
- def get_default_framework() -> SeedFramework:
303
- """Get the seed framework -- tries bundled file first, falls back to built-in.
304
-
305
- Returns:
306
- SeedFramework: The loaded or built-in framework.
307
- """
308
- bundled = _bundled_seed_path()
309
- if bundled:
310
- loaded = load_seed_framework(bundled)
311
- if loaded is not None:
312
- return loaded
313
-
314
- return SeedFramework(
315
- framework_id="seed-builtin",
316
- function="Recursive Axiomatic Steel Man Collider with Reality Gates",
317
- version="builtin-0.1",
318
- axioms=[
319
- "All components conjoin necessarily (AND-linked) to form the whole.",
320
- "Negations resolve to invariants (double-NOT yields identity).",
321
- "Recursion accelerates refinement but halts on stability.",
322
- "Universality from basis gates (NAND/NOR reconstruct all).",
323
- ],
324
- stages=[
325
- {"stage": "1. Steel-Manning (Pre-Entry)", "description": "Negate flaws, strengthen the proposition."},
326
- {"stage": "2. Collider Entry", "description": "Create two lanes: proposition and inversion."},
327
- {"stage": "3. Destructive Smashing", "description": "Expose contradictions via XOR."},
328
- {"stage": "4. Fragment Reconstruction", "description": "Rebuild from logical debris via AND/OR."},
329
- {"stage": "5. Meta-Recursion", "description": "Feed output back until coherence stabilizes."},
330
- {"stage": "6. Invariant Extraction", "description": "Identify what remains true across all collisions."},
331
- ],
332
- definitions=[
333
- {"term": "Steel Man", "details": "Strongest version of an argument, anticipating critiques."},
334
- {"term": "Reality Gate", "details": "Logic gate embodying reality properties."},
335
- {"term": "Collider", "details": "Accelerator for argument fragmentation and synthesis."},
336
- {"term": "Coherence", "details": "Measure of internal consistency (XNOR score)."},
337
- ],
338
- )