RFTSystems commited on
Commit
959c186
·
verified ·
1 Parent(s): 0333a47

Create registry_utils.py

Browse files
Files changed (1) hide show
  1. registry_utils.py +31 -0
registry_utils.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from datetime import datetime
3
+
4
+ REGISTRY_PATH = "Codex_Registry.json"
5
+
6
+ def append_to_registry(agent_id, collapse_torque, tier_drift, emotional_resonance, score, hash_val):
7
+ entry = {
8
+ "agent_id": agent_id,
9
+ "collapse_torque": collapse_torque,
10
+ "tier_drift": tier_drift,
11
+ "emotional_resonance": emotional_resonance,
12
+ "fitness_score": score,
13
+ "hash": hash_val,
14
+ "timestamp": datetime.utcnow().isoformat(),
15
+ "author": "Liam Grinstead"
16
+ }
17
+ try:
18
+ with open(REGISTRY_PATH, "r+") as f:
19
+ data = json.load(f)
20
+ data["registry"].append(entry)
21
+ f.seek(0)
22
+ json.dump(data, f, indent=2)
23
+ except Exception as e:
24
+ print("Registry append failed:", e)
25
+
26
+ def read_registry():
27
+ try:
28
+ with open(REGISTRY_PATH, "r") as f:
29
+ return json.load(f)["registry"]
30
+ except:
31
+ return []