RFTSystems commited on
Commit
81ead93
·
verified ·
1 Parent(s): 9c9e96e

Update lineage_tracker.py

Browse files
Files changed (1) hide show
  1. lineage_tracker.py +17 -23
lineage_tracker.py CHANGED
@@ -1,27 +1,22 @@
1
- # lineage_tracker.py
2
  # Author: Liam Grinstead
3
- # Tracks symbolic agent lineage, mutation history, and parent mapping
4
 
5
  from typing import Dict, List
6
 
7
  LINEAGE: Dict[str, List[dict]] = {}
8
- PARENT_OF: Dict[str, str] = {} # child_id -> parent_id
9
 
10
  def register_lineage(parent_id: str, child_id: str, mutation_profile: dict):
11
- if parent_id not in LINEAGE:
12
- LINEAGE[parent_id] = []
13
- LINEAGE[parent_id].append({
14
  "child_id": child_id,
15
- "mutation": mutation_profile
16
- })
 
 
 
17
  PARENT_OF[child_id] = parent_id
18
 
19
- def get_lineage(agent_id: str) -> List[dict]:
20
- return LINEAGE.get(agent_id, [])
21
-
22
- def get_parent(child_id: str) -> str:
23
- return PARENT_OF.get(child_id, "")
24
-
25
  def get_ancestors(agent_id: str) -> List[str]:
26
  chain = []
27
  cur = agent_id
@@ -29,20 +24,19 @@ def get_ancestors(agent_id: str) -> List[str]:
29
  p = PARENT_OF[cur]
30
  chain.append(p)
31
  cur = p
32
- return chain[::-1] # oldest → newest
33
 
34
- def get_descendants(agent_id: str, depth: int = 5) -> Dict[str, List[str]]:
35
- # returns a dict level -> list of child ids
36
- levels: Dict[int, List[str]] = {}
37
  frontier = [agent_id]
38
  for d in range(1, depth + 1):
39
- next_frontier = []
40
  for node in frontier:
41
- children = [c["child_id"] for c in LINEAGE.get(node, [])]
42
  if children:
43
  levels.setdefault(d, []).extend(children)
44
- next_frontier.extend(children)
45
- frontier = next_frontier
46
  if not frontier:
47
  break
48
- return {f"level_{k}": v for k, v in levels.items()}
 
1
+ # lineage_tracker_rft.py
2
  # Author: Liam Grinstead
3
+ # Multi-gen lineage tracking with mutation provenance (operators & overlays)
4
 
5
  from typing import Dict, List
6
 
7
  LINEAGE: Dict[str, List[dict]] = {}
8
+ PARENT_OF: Dict[str, str] = {}
9
 
10
  def register_lineage(parent_id: str, child_id: str, mutation_profile: dict):
11
+ entry = {
 
 
12
  "child_id": child_id,
13
+ "tier": mutation_profile.get("tier_drift"),
14
+ "overlay": mutation_profile.get("collapse_torque"),
15
+ "operators": mutation_profile.get("symbolic_operators", []),
16
+ }
17
+ LINEAGE.setdefault(parent_id, []).append(entry)
18
  PARENT_OF[child_id] = parent_id
19
 
 
 
 
 
 
 
20
  def get_ancestors(agent_id: str) -> List[str]:
21
  chain = []
22
  cur = agent_id
 
24
  p = PARENT_OF[cur]
25
  chain.append(p)
26
  cur = p
27
+ return chain[::-1]
28
 
29
+ def get_descendants(agent_id: str, depth: int = 6) -> Dict[int, List[dict]]:
30
+ levels: Dict[int, List[dict]] = {}
 
31
  frontier = [agent_id]
32
  for d in range(1, depth + 1):
33
+ nxt = []
34
  for node in frontier:
35
+ children = LINEAGE.get(node, [])
36
  if children:
37
  levels.setdefault(d, []).extend(children)
38
+ nxt.extend([c["child_id"] for c in children])
39
+ frontier = nxt
40
  if not frontier:
41
  break
42
+ return levels