code wiki / _hdl_build / nx_spec_layers.nx

nx_spec_layers.nx source

↩ module page · 71 lines · 4021 B

1// nx_spec_layers.nx -- the team's LAYERED-SPEC synthesis capability (operator 2026-06-05: "we really really 2// need a true s class exceed spec synthesized so that we can build our own s class exceed specs from our 3// process with claudes role reducing to zero"). COMPLEMENTS nx_spec_author (objective WEIGHTS from findings); 4// this structures a MULTI-LAYER architectural spec. This is the MECHANIZED core of spec synthesis -- team-owned 5// without an LLM: given cataloged Library facts grouped into LAYERS (each with a corroboration count from the 6// 3-vote gate), it (1) detects GAPS (a layer with 0 corroborated facts = a RAISED HAND, never spec'd from thin 7// air), (2) orders the build by the charter ladder + dependency depth (foundational/early-ladder first), (3) 8// attaches a benchmark target, and (4) emits the ordered spec. The SYNTHESIS-INSIGHT (novel architecture 9// choices) is where Claude still tutors -- until the team has a local LLM (operator: "future local llm 10// augmenting it"). As the Library + this machinery grow, Claude's role shrinks toward zero. license_tier: ORIGINAL 11import "nx_syscalls.nx" 12 13// charter-ladder stage of a layer's output (the team's charter: unstructured->structured->meaningful-> 14// actionable->reproducible). Lower stage = earlier in the pipeline = built first. 15const SS_INGEST: i64 = 1 // unstructured -> structured (harvest) 16const SS_STRUCTURED: i64 = 2 // structured artifact (format, storage) 17const SS_MEANINGFUL: i64 = 3 // meaningful retrieval (search) 18const SS_ACTIONABLE: i64 = 4 // actionable answer (query API) 19 20const SS_GAP: i64 = 0 // 0 corroborated facts -> raised hand, cannot spec yet 21const SS_READY: i64 = 1 // has corroborated evidence -> spec it 22 23// a layer is a GAP (raised hand) iff nothing in the Library corroborates it -- we NEVER spec from thin air. 24func ss_status(corroborated_count: i64) -> i64 { 25 if corroborated_count <= 0 { return SS_GAP } 26 return SS_READY 27} 28 29// build rank: charter stage dominates (earlier ladder first), dependency depth breaks ties. LOWER builds first. 30func ss_build_rank(charter_stage: i64, dep_depth: i64) -> i64 { 31 return charter_stage * 10 + dep_depth 32} 33 34// the spec EXCEEDS the field iff one sovereign stack covers MULTIPLE competitor categories (format AND storage 35// AND search) that the incumbents split across separate products (Lucene + Pinecone + IPFS + EPUB tooling). 36func ss_exceed_by_unification(covers_format: i64, covers_storage: i64, covers_search: i64) -> i64 { 37 if covers_format == 1 { if covers_storage == 1 { if covers_search == 1 { return 1 } } } 38 return 0 39} 40 41// count raised hands (gap layers) -- these become the team's next research assignments, surfaced not hidden. 42func ss_count_gaps(corroborated: *i64, n: i64) -> i64 { 43 var g: i64 = 0; var i: i64 = 0 44 while i < n { if ss_status(corroborated[i]) == SS_GAP { g = g + 1 } i = i + 1 } 45 return g 46} 47 48// order n layers by build_rank (selection sort into out_order index array). Stable enough for a small spec. 49func ss_order_build(rank: *i64, n: i64, out_order: *i64) -> i64 { 50 let used: *i64 = sys_mmap(8 * n) as *i64 51 var i: i64 = 0; while i < n { used[i] = 0; i = i + 1 } 52 var k: i64 = 0 53 while k < n { 54 var best: i64 = 0 - 1; var bestrank: i64 = 0 55 var j: i64 = 0 56 while j < n { 57 if used[j] == 0 { if best < 0 { best = j; bestrank = rank[j] } else { if rank[j] < bestrank { best = j; bestrank = rank[j] } } } 58 j = j + 1 59 } 60 used[best] = 1; out_order[k] = best; k = k + 1 61 } 62 return n 63} 64 65// a spec is ADMISSIBLE iff every NON-gap layer it commits to build has corroborated evidence AND the gaps are 66// surfaced as raised hands (not silently dropped). This is the synthesis integrity gate. 67func ss_spec_admissible(corroborated: *i64, n: i64, gaps_surfaced: i64) -> i64 { 68 let actual_gaps: i64 = ss_count_gaps(corroborated, n) 69 if gaps_surfaced != actual_gaps { return 0 } // every gap must be surfaced 70 return 1 71}