code wiki / _hdl_build / nx_lineage_archive.nx
nx_lineage_archive.nx source
↩ module page · 42 lines · 2397 B
1// nx_lineage_archive.nx -- the BRANCHING lineage archive for the hub-spoke Naruto loop (Darwin Gödel
2// Machine evidence, /deep-research wfb7jkc6h): keep a branching ARCHIVE of ALL clones -- even low-scoring
3// or rejected ones -- because open-ended branching beat single-track hill-climbing (50% vs 23% on SWE-bench)
4// and LOW-performing ancestors later seeded breakthroughs. So a clone is never deleted; a future clone may
5// branch from ANY archived ancestor, not just the current best. Additive-only -> the Librarian/Archivist
6// owns it. license_tier: ORIGINAL Upgrades nx_hub_spoke (integrate-or-discard -> integrate-and-archive).
7
8import "nx_syscalls.nx"
9
10// append a clone to the archive (ALWAYS kept). stores parent + score in parallel arrays; returns its index.
11func la_archive(parents: *i64, scores: *i64, n: i64, parent: i64, score: i64) -> i64 {
12 parents[n] = parent
13 scores[n] = score
14 return n // the new clone's id = its index; caller increments count
15}
16
17// hill-climbing would only ever branch from the best:
18func la_best(scores: *i64, n: i64) -> i64 {
19 var bi: i64 = 0; var bs: i64 = 0 - 1; var i: i64 = 0
20 while i < n { if scores[i] > bs { bs = scores[i]; bi = i } i = i + 1 }
21 return bi
22}
23// ...but BRANCHING lets a future clone descend from ANY archived ancestor (the DGM advantage).
24func la_can_branch_from(idx: i64, n: i64) -> i64 { if idx < 0 { return 0 } if idx >= n { return 0 } return 1 }
25
26// the frontier (best score) the archive has reached -- never regresses even though everything is kept.
27func la_frontier(scores: *i64, n: i64) -> i64 {
28 var f: i64 = 0; var i: i64 = 0
29 while i < n { if scores[i] > f { f = scores[i] } i = i + 1 }
30 return f
31}
32
33// did a LOW-scoring ancestor seed a breakthrough? child branched from a below-frontier parent yet beat the
34// prior frontier -> the exact reason to archive (not discard) low clones.
35func la_seeded_breakthrough(parent_score: i64, child_score: i64, prior_frontier: i64) -> i64 {
36 if parent_score >= prior_frontier { return 0 } // parent wasn't low -> not the interesting case
37 if child_score > prior_frontier { return 1 } // a low parent yielded a new best
38 return 0
39}
40
41// nothing is ever deleted (additive-only archive): the count only grows.
42func la_no_deletion(count_before: i64, count_after: i64) -> i64 { if count_after >= count_before { return 1 } return 0 }