|
1 | 1 | """ |
2 | | -Founding Network Bootstrap — Direct DB insertion for founding bonds. |
| 2 | +Founding Network Bootstrap — Direct DB insertion for founding links. |
3 | 3 | Bypasses cooldown because these are pre-existing paid members |
4 | 4 | being loaded into the system retroactively. |
5 | 5 | """ |
|
10 | 10 | from datetime import datetime, timezone, timedelta |
11 | 11 | from app import create_app |
12 | 12 | from models.member import Member |
13 | | -from models.bond import Bond |
| 13 | +from models.link import Link |
14 | 14 | from config import HeliosConfig |
15 | 15 |
|
16 | 16 | app = create_app() |
|
31 | 31 | 'nakia-r.helios', # 12 |
32 | 32 | ] |
33 | 33 |
|
34 | | -# Bond pairs — building a connected mesh |
35 | | -# Chain bonds connect everyone in sequence |
36 | | -# Cross bonds strengthen the topology |
37 | | -bond_pairs = [ |
| 34 | +# Link pairs — building a connected mesh |
| 35 | +# Chain links connect everyone in sequence |
| 36 | +# Cross links strengthen the topology |
| 37 | +link_pairs = [ |
38 | 38 | # Chain — connects everyone in sequence |
39 | 39 | (0, 1), # elliot ↔ aaron |
40 | 40 | (1, 2), # aaron ↔ ryan |
|
48 | 48 | (9, 10), # joseph ↔ brian |
49 | 49 | (10, 11), # brian ↔ blyss |
50 | 50 | (11, 12), # blyss ↔ nakia |
51 | | - # Cross bonds — strengthen the mesh (respecting max 5 per node) |
| 51 | + # Cross links — strengthen the mesh (respecting max 5 per node) |
52 | 52 | (0, 6), # elliot ↔ eddie |
53 | 53 | (0, 12), # elliot ↔ nakia |
54 | 54 | (1, 7), # aaron ↔ dan |
|
78 | 78 | print("FOUNDING NETWORK BOOTSTRAP") |
79 | 79 | print("=" * 60) |
80 | 80 |
|
81 | | - # First, clean up any bonds from the earlier partial attempt |
82 | | - existing_bonds = db.query(Bond).all() |
83 | | - if existing_bonds: |
84 | | - print(f"\nClearing {len(existing_bonds)} existing bonds from partial attempt...") |
85 | | - for b in existing_bonds: |
| 81 | + # First, clean up any links from the earlier partial attempt |
| 82 | + existing_links = db.query(Link).all() |
| 83 | + if existing_links: |
| 84 | + print(f"\nClearing {len(existing_links)} existing links from partial attempt...") |
| 85 | + for b in existing_links: |
86 | 86 | db.delete(b) |
87 | | - # Reset all founder bond counts |
| 87 | + # Reset all founder link counts |
88 | 88 | for hid in founders: |
89 | 89 | m = db.query(Member).filter_by(helios_id=hid).first() |
90 | 90 | if m: |
91 | | - m.bond_count = 0 |
| 91 | + m.link_count = 0 |
92 | 92 | m.node_state = "instantiated" |
93 | 93 | db.commit() |
94 | 94 | print(" Cleared.") |
|
98 | 98 |
|
99 | 99 | formed = 0 |
100 | 100 | skipped = 0 |
101 | | - bond_counts = {hid: 0 for hid in founders} |
| 101 | + link_counts = {hid: 0 for hid in founders} |
102 | 102 |
|
103 | | - print("\nForming bonds:\n") |
| 103 | + print("\nForming links:\n") |
104 | 104 |
|
105 | | - for idx, (i, j) in enumerate(bond_pairs): |
| 105 | + for idx, (i, j) in enumerate(link_pairs): |
106 | 106 | a_id = founders[i] |
107 | 107 | b_id = founders[j] |
108 | 108 |
|
109 | | - # Respect max 5 bonds per node |
110 | | - if bond_counts[a_id] >= 5: |
| 109 | + # Respect max 5 links per node |
| 110 | + if link_counts[a_id] >= 5: |
111 | 111 | print(f" FULL {a_id:<24} (5/5, skipping)") |
112 | 112 | skipped += 1 |
113 | 113 | continue |
114 | | - if bond_counts[b_id] >= 5: |
| 114 | + if link_counts[b_id] >= 5: |
115 | 115 | print(f" FULL {b_id:<24} (5/5, skipping)") |
116 | 116 | skipped += 1 |
117 | 117 | continue |
118 | 118 |
|
119 | | - node_a, node_b = Bond.ordered_pair(a_id, b_id) |
| 119 | + node_a, node_b = Link.ordered_pair(a_id, b_id) |
120 | 120 |
|
121 | 121 | # Check no duplicate |
122 | | - existing = db.query(Bond).filter_by(node_a=node_a, node_b=node_b).first() |
| 122 | + existing = db.query(Link).filter_by(node_a=node_a, node_b=node_b).first() |
123 | 123 | if existing: |
124 | 124 | print(f" EXISTS {a_id:<24} ↔ {b_id}") |
125 | 125 | skipped += 1 |
126 | 126 | continue |
127 | 127 |
|
128 | 128 | # Stagger timestamps so cooldown logic is satisfied |
129 | | - bond_time = base_time + timedelta(minutes=idx * 5) |
| 129 | + link_time = base_time + timedelta(minutes=idx * 5) |
130 | 130 |
|
131 | | - bond = Bond( |
| 131 | + link = Link( |
132 | 132 | node_a=node_a, |
133 | 133 | node_b=node_b, |
134 | | - state=HeliosConfig.BOND_STATE_ACTIVE, |
| 134 | + state=HeliosConfig.LINK_STATE_ACTIVE, |
135 | 135 | initiated_by=a_id, |
136 | | - created_at=bond_time, |
137 | | - activated_at=bond_time, |
| 136 | + created_at=link_time, |
| 137 | + activated_at=link_time, |
138 | 138 | ) |
139 | | - db.add(bond) |
140 | | - bond_counts[a_id] += 1 |
141 | | - bond_counts[b_id] += 1 |
| 139 | + db.add(link) |
| 140 | + link_counts[a_id] += 1 |
| 141 | + link_counts[b_id] += 1 |
142 | 142 | formed += 1 |
143 | | - print(f" BONDED {a_id:<24} ↔ {b_id:<24} [{bond_counts[a_id]}/{bond_counts[b_id]}]") |
| 143 | + print(f" LINKED {a_id:<24} ↔ {b_id:<24} [{link_counts[a_id]}/{link_counts[b_id]}]") |
144 | 144 |
|
145 | 145 | # Update member records |
146 | | - print("\nUpdating member bond counts and node states:\n") |
| 146 | + print("\nUpdating member link counts and node states:\n") |
147 | 147 | for hid in founders: |
148 | 148 | m = db.query(Member).filter_by(helios_id=hid).first() |
149 | 149 | if m: |
150 | | - m.bond_count = bond_counts[hid] |
| 150 | + m.link_count = link_counts[hid] |
151 | 151 | m.update_node_state() |
152 | | - print(f" {hid:<28} bonds={m.bond_count} state={m.node_state}") |
| 152 | + print(f" {hid:<28} links={m.link_count} state={m.node_state}") |
153 | 153 |
|
154 | 154 | db.commit() |
155 | 155 |
|
156 | | - print(f"\nBonds formed: {formed}") |
| 156 | + print(f"\nLinks formed: {formed}") |
157 | 157 | print(f"Skipped (full/duplicate): {skipped}") |
158 | 158 |
|
159 | 159 | # Summary |
|
166 | 166 | print(f"\nNetwork topology:") |
167 | 167 | for state, count in sorted(states.items()): |
168 | 168 | print(f" {state}: {count} nodes") |
169 | | - print(f" Total bonds: {formed}") |
| 169 | + print(f" Total links: {formed}") |
170 | 170 |
|
171 | 171 | db.close() |
0 commit comments