code wiki / _hdl_build / nx_researcher_spec.nx
nx_researcher_spec.nx source
↩ module page · 53 lines · 3019 B
1// nx_researcher_spec.nx -- the RESEARCHER turns a NEED into a buildable SPEC, decomposed to Layer-8
2// primitives (operator: "if we need 3 we need the researcher to find what we need, build the spec, and
3// get it going... build from layer 8 up"). A spec is the deterministic bridge from "we need X" to the
4// Builder building X. It is ACTIONABLE only if it is COMPLETE and every primitive it requires is
5// already available at L8 (integer ALU ops the team has proven gate-level); a required primitive that
6// is NOT available pushes the build DOWN a layer (build that first) -- and if the missing primitive is
7// a learned/LLM thing, the Researcher flags it as an LLM-gap rather than pretending the team can build
8// it. RACI: Researcher emits + grades the spec; Builder builds to it; Engineer's gate is the acceptance
9// test. license_tier: ORIGINAL
10
11import "nx_syscalls.nx"
12
13// layers (L8 = bits/machine-code up to L0 = frontier output) -- where the spec's work sits.
14const RS_L8: i64 = 8
15
16// primitives a spec may require. The L8 integer-ALU ops are AVAILABLE (team proved them gate-level);
17// a LEARNED-embedding trainer is NOT (that is the LLM rung).
18const RS_PRIM_IMUL: i64 = 1 // integer multiply (L8 ALU -- available)
19const RS_PRIM_IADD: i64 = 2 // integer add (L8 ALU -- available)
20const RS_PRIM_ISQRT: i64 = 3 // integer sqrt (for cosine magnitude; used in nx_qlayer -- available)
21const RS_PRIM_COUNT: i64 = 4 // substring/term count (nx_research_extract -- available)
22const RS_PRIM_EMBED_TRAIN: i64 = 5 // learned embedding training -- NOT available (LLM-gap rung)
23
24// which primitives does the team already have? everything except a learned-embedding trainer.
25func rs_prim_available(prim: i64) -> i64 { if prim == RS_PRIM_EMBED_TRAIN { return 0 } return 1 }
26
27// a spec is COMPLETE only if fully specified -- no half-specs reach the Builder.
28func rs_spec_complete(named: i64, layer: i64, n_in: i64, n_out: i64, n_prim: i64, has_gate: i64) -> i64 {
29 if named == 0 { return 0 }
30 if layer < 0 { return 0 }
31 if n_in <= 0 { return 0 }
32 if n_out <= 0 { return 0 }
33 if n_prim <= 0 { return 0 }
34 if has_gate == 0 { return 0 }
35 return 1
36}
37
38// the first required primitive the team CANNOT build yet (-1 if all available) -- the build to do first.
39func rs_first_missing(prims: *i64, n_prim: i64) -> i64 {
40 var i: i64 = 0
41 while i < n_prim { if rs_prim_available(prims[i]) == 0 { return prims[i] } i = i + 1 }
42 return 0 - 1
43}
44
45// ACTIONABLE iff complete AND every required primitive is available at its layer (else build down first).
46func rs_spec_actionable(complete: i64, prims: *i64, n_prim: i64) -> i64 {
47 if complete == 0 { return 0 }
48 if rs_first_missing(prims, n_prim) >= 0 { return 0 }
49 return 1
50}
51
52// is the missing primitive an LLM-gap (learned embedding) vs a buildable lower layer? -> route honestly.
53func rs_missing_is_llm_gap(missing_prim: i64) -> i64 { if missing_prim == RS_PRIM_EMBED_TRAIN { return 1 } return 0 }