code wiki / _hdl_build / nx_spec_author.nx
nx_spec_author.nx source
↩ module page · 35 lines · 2333 B
1// nx_spec_author.nx -- the team BUILDS ITS OWN SPECS from research (operator: "the ability to turn
2// research into specs is key"). A spec is the OBJECTIVE the Builder's search optimizes. Instead of
3// Claude deciding what to optimize, the team COMPOSES the objective from CONFIRMED research findings:
4// each finding that survived the Researcher+Critic gates about "what matters" sets a weight on an
5// objective component. So the Blau-Michaeli finding (perception != distortion, Critic-blessed) RAISES
6// the perception weight; the imatrix finding raises the importance/distortion weight. The composed
7// objective is then handed to the WIDENED search (nx_builder_synth's hill-climb works on ANY composed
8// importance -- that is the widening: specs are now arbitrary weighted objectives, not one hardcoded
9// error). research -> spec -> search -> verified solution, all team-owned. license_tier: ORIGINAL
10
11import "nx_imatrix.nx" // imat_err2 / weighted_error: the search objective is a composed importance
12
13// objective-component weights the team sets from research (one per objective kind).
14// the team AUTHORS a spec by choosing these from what research CONFIRMED matters.
15func spec_weight_from_findings(target_obj: i64, n: i64, finding_obj: *i64, finding_confirmed: *i64, finding_strength: *i64) -> i64 {
16 var w: i64 = 0; var i: i64 = 0
17 while i < n {
18 if finding_obj[i] == target_obj { if finding_confirmed[i] == 1 { w = w + finding_strength[i] } }
19 i = i + 1
20 }
21 return w
22}
23
24// compose the per-group importance the search will optimize: for each weight-group, combine its
25// distortion-sensitivity and perception-sensitivity by the spec weights the team authored.
26// composed_imp[i] = w_dist*dist_sens[i] + w_perc*perc_sens[i]. (energy etc. extend the same way.)
27func spec_compose_importance(n: i64, w_dist: i64, w_perc: i64, dist_sens: *i64, perc_sens: *i64, out: *i64) -> i64 {
28 var i: i64 = 0
29 while i < n { out[i] = w_dist * dist_sens[i] + w_perc * perc_sens[i]; i = i + 1 }
30 return 0
31}
32
33// the objective value of an allocation under a composed spec (what the search minimizes + the
34// Engineer verifies). reuses imat_err2; the importance is the COMPOSED one.
35func spec_objective(n: i64, composed_imp: *i64, bits: *i64) -> i64 { return imat_weighted_error(n, composed_imp, bits) }