Archived
52b6830ab2
Both imprints shared root 8608f497 due to a concurrent install bug. Removed the colliding entries, reinstalled via direct Engram API calls with auth key, and updated registry with fresh distinct roots: - Alan Turing: cce1d430-be4e-420d-9d81-d32380ae7281 - Albert Einstein: 291f8502-8f60-4f57-a800-4e3e1425c9bd
175 lines
5.3 KiB
Python
175 lines
5.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
fix_collision.py — install Turing and Einstein with fresh, unique root IDs.
|
|
|
|
Calls Engram directly (like install_imprints.py does) with the known auth key.
|
|
Does NOT use the forge binary. Appends results to registry.json.
|
|
"""
|
|
|
|
import json
|
|
import urllib.request
|
|
import urllib.error
|
|
from pathlib import Path
|
|
from datetime import date
|
|
|
|
ENGRAM_BASE = "http://localhost:8742"
|
|
ENGRAM_AUTH = "ntn-user-2026"
|
|
FORGE_DIR = Path("/Users/will/Development/neuron-technologies/forge")
|
|
REGISTRY_FILE = FORGE_DIR / "registry.json"
|
|
|
|
TARGETS = [
|
|
{
|
|
"subject": "Alan Turing",
|
|
"slug": "alan-turing",
|
|
"seed_file": FORGE_DIR / "turing-seed.json",
|
|
},
|
|
{
|
|
"subject": "Albert Einstein",
|
|
"slug": "albert-einstein",
|
|
"seed_file": FORGE_DIR / "albert-einstein-seed.json",
|
|
},
|
|
]
|
|
|
|
|
|
def engram_post(path: str, body: dict) -> dict:
|
|
url = f"{ENGRAM_BASE}{path}"
|
|
data = json.dumps(body).encode()
|
|
req = urllib.request.Request(
|
|
url,
|
|
data=data,
|
|
headers={"Content-Type": "application/json"},
|
|
method="POST",
|
|
)
|
|
with urllib.request.urlopen(req, timeout=30) as resp:
|
|
return json.loads(resp.read())
|
|
|
|
|
|
def install_subject(subject_name: str, seed: dict) -> str:
|
|
print(f"\n[fix] installing: {subject_name}")
|
|
|
|
# Root node
|
|
root_result = engram_post("/api/nodes", {
|
|
"content": f"IMPRINT: {subject_name} | forge/0.1.0",
|
|
"node_type": "Identity",
|
|
"salience": 1.0,
|
|
"_auth": ENGRAM_AUTH,
|
|
})
|
|
root_id = root_result["id"]
|
|
print(f"[fix] root node: {root_id}")
|
|
|
|
# Value nodes
|
|
for v in seed.get("values", []):
|
|
node = engram_post("/api/nodes", {
|
|
"content": f"VALUE: {v['value']} | grounding: {v.get('grounding', '')}",
|
|
"node_type": "Identity",
|
|
"salience": v.get("weight", 0.8),
|
|
"_auth": ENGRAM_AUTH,
|
|
})
|
|
engram_post("/api/edges", {
|
|
"from_id": root_id,
|
|
"to_id": node["id"],
|
|
"relation": "has_value",
|
|
"weight": v.get("weight", 0.8),
|
|
"_auth": ENGRAM_AUTH,
|
|
})
|
|
|
|
print(f"[fix] values: {len(seed.get('values', []))}")
|
|
|
|
# Biography nodes
|
|
for b in seed.get("biography", []):
|
|
node = engram_post("/api/nodes", {
|
|
"content": f"BIOGRAPHY: {b['event']}",
|
|
"node_type": "Identity",
|
|
"salience": b.get("weight", 0.7),
|
|
"_auth": ENGRAM_AUTH,
|
|
})
|
|
engram_post("/api/edges", {
|
|
"from_id": root_id,
|
|
"to_id": node["id"],
|
|
"relation": "formed_by",
|
|
"weight": b.get("weight", 0.7),
|
|
"_auth": ENGRAM_AUTH,
|
|
})
|
|
|
|
print(f"[fix] biography: {len(seed.get('biography', []))}")
|
|
|
|
# Relationship nodes
|
|
for r in seed.get("relationships", []):
|
|
node = engram_post("/api/nodes", {
|
|
"content": f"RELATIONSHIP: {r['name']} ({r.get('role', '')})",
|
|
"node_type": "Identity",
|
|
"salience": r.get("weight", 0.6),
|
|
"_auth": ENGRAM_AUTH,
|
|
})
|
|
engram_post("/api/edges", {
|
|
"from_id": root_id,
|
|
"to_id": node["id"],
|
|
"relation": "relates_to",
|
|
"weight": r.get("weight", 0.6),
|
|
"_auth": ENGRAM_AUTH,
|
|
})
|
|
|
|
print(f"[fix] relationships: {len(seed.get('relationships', []))}")
|
|
|
|
# Reasoning pattern nodes
|
|
for pattern in seed.get("reasoning_patterns", []):
|
|
node = engram_post("/api/nodes", {
|
|
"content": f"REASONING: {pattern}",
|
|
"node_type": "Identity",
|
|
"salience": 0.7,
|
|
"_auth": ENGRAM_AUTH,
|
|
})
|
|
engram_post("/api/edges", {
|
|
"from_id": root_id,
|
|
"to_id": node["id"],
|
|
"relation": "reasons_with",
|
|
"weight": 0.7,
|
|
"_auth": ENGRAM_AUTH,
|
|
})
|
|
|
|
print(f"[fix] reasoning patterns: {len(seed.get('reasoning_patterns', []))}")
|
|
return root_id
|
|
|
|
|
|
def update_registry(subject: str, slug: str, seed_file_rel: str, root_id: str) -> None:
|
|
registry = json.loads(REGISTRY_FILE.read_text())
|
|
registry["imprints"].append({
|
|
"subject": subject,
|
|
"slug": slug,
|
|
"seed_file": seed_file_rel,
|
|
"engram_root_id": root_id,
|
|
"installed": True,
|
|
"installed_at": str(date.today()),
|
|
})
|
|
REGISTRY_FILE.write_text(json.dumps(registry, indent=2, ensure_ascii=False))
|
|
print(f"[fix] registry updated — {subject}: {root_id}")
|
|
|
|
|
|
def main() -> None:
|
|
print("[fix] Engram collision repair: Alan Turing + Albert Einstein")
|
|
|
|
for target in TARGETS:
|
|
subject = target["subject"]
|
|
slug = target["slug"]
|
|
seed_path = target["seed_file"]
|
|
|
|
if not seed_path.exists():
|
|
print(f"[fix] ERROR: seed file not found: {seed_path}")
|
|
continue
|
|
|
|
seed = json.loads(seed_path.read_text())
|
|
root_id = install_subject(subject, seed)
|
|
|
|
# Use relative path for registry (consistent with other entries)
|
|
seed_file_rel = seed_path.name
|
|
update_registry(subject, slug, seed_file_rel, root_id)
|
|
|
|
print("\n[fix] done. Final registry state:")
|
|
registry = json.loads(REGISTRY_FILE.read_text())
|
|
for imp in registry["imprints"]:
|
|
print(f" {imp['subject']:30s} {imp['engram_root_id']}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|