code wiki / (root) / nx_stepsolve_lib.nx

nx_stepsolve_lib.nx

buildroot/runtime/nx_stepsolve_lib.nx

21668 B354 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_stepsolve_lib.nx -- ES26 (engineshift al_steps): THE ONE RULER for STEPS-TO-SOLVE PER COMMON TASK. The operator's 2026-09-06 order: if a task can be solved in ONE step within logic it should be, and when it cannot the estate explains why two, why three, and so on, from the most common tasks to the least, mining and evaluating this efficacy continuously. The MEASURED side is the action journal's recurring tool:verb n-grams (nx_actlog's indexed miner, exact support, adjacent only): a recurring bigram is a 2-step ritual, a trigram a 3-step one, and its support is how common it is. The DECLARED side is knowledge/stepsolve.conf, DATA rows steps|<signature>|<min_steps>|<reason>|<one_step_verb> verbclass|<verb>|<reason> where signature = tool:verb>tool:verb[>tool:verb] exactly as the journal spells it, min_steps is the LOGICAL minimum, reason is why it cannot be fewer (a true dependency: a promote must see the sha only a finished build produces) and one_step_verb names the composed verb on the CANONICAL organ that does it in one call (nx_organ_ship for the build-stage-judge-promote ritual). A verbclass row is a RULE: every signature whose EVERY step carries that verb is explained by the rule's reason -- the clock plane and the job lane write <elf>:run for each organ fork, and a fork is one whole organ run and therefore one step by construction, so two adjacent scheduled forks are two tasks and not a ritual. A steps row for a specific signature WINS over a rule, so a fork ritual that does have a composed verb stays declarable. This lib joins the two and classifies every recurring signature: ONE-STEP-AVAILABLE min_steps 1 and a composed verb is named: the ritual is an ADOPTION gap, its support should fall DEPENDENCY min_steps equals the observed steps: the count is explained, the reason travels with it REDUCIBLE 1 < min_steps < observed: fewer steps are possible by declared logic BY-RULE no steps row, every step's verb matches a verbclass row: explained by that rule's reason UNDECLARED no row and no rule: NEVER assumed one-step; it is the worklist, most common first The published figure is a PARTITION over signature support (sums to the total, printed); per-rule support is tallied beside it so a rule can never hide what it absorbed; the gauge stamp is the EXPLAINED permil (declared classes over all), written in the CE9 heartbeat shape so gauge_pass renders it and a stale one reads STALE never zero. A row that cannot be parsed is counted as malformed, never dropped in silence. license_tier: ORIGINAL No hw writes.

dependencies 3 imports · 1 importers

nx_sovjson_lib.nx nx_syscalls.nx nx_gauge_lib.nx nx_stepsolve_lib.nx nx_actlog.nx

imports: nx_sovjson_lib.nxnx_syscalls.nxnx_gauge_lib.nx

imported by: nx_actlog.nx

structs

none

consts

33const SS_CONF_PROD: *u8 = "knowledge/stepsolve.conf"
34const SS_SPINE_PROD: *u8 = "knowledge/status/stepsolve.spine"
35const SS_STAMP_PROD: *u8 = "knowledge/status/stepsolve.stamp"
36const SS_SPINE_SIDECAR: *u8 = ".stepsolve.spine"
37const SS_STAMP_SIDECAR: *u8 = ".stepsolve.stamp"
38const SS_QSTAMP_PROD: *u8 = "knowledge/status/stepsolve_quality.stamp" // ES27: the QUALITY gauge (1000 - failure permil) beside EXPLAINED
39const SS_QSTAMP_SIDECAR: *u8 = ".stepsolve.quality.stamp"
40const SS_CADENCE_S: i64 = 86400 // the daily beat that writes the stamp; max_age derives from it in the gauge lib
41const SS_AXES: i64 = 2 // the journal and the conf: an unreadable conf is an abstaining axis
42const SS_WORD: i64 = 8
43const SS_LINE: i64 = 512
44const SS_PATH: i64 = 1024
45const SS_MODE644: i64 = 420
46const SS_NL: i64 = 10
47const SS_PIPE: i64 = 124
48const SS_HASH: i64 = 35
49const SS_GT: i64 = 62
50const SS_COLON: i64 = 58
51const SS_PERMIL: i64 = 1000
52const SS_ROW_FIELDS: i64 = 5
53const SS_RULE_FIELDS: i64 = 3
55const SS_C_UNDECLARED: i64 = 0
56const SS_C_ONE_STEP: i64 = 1
57const SS_C_DEPENDENCY: i64 = 2
58const SS_C_REDUCIBLE: i64 = 3
59const SS_C_RULE: i64 = 4
60const SS_C_N: i64 = 5
62const SS_K_STEPS: i64 = 1
63const SS_K_RULE: i64 = 2
65const SS_R_SIG: i64 = 0
66const SS_R_SIGLEN: i64 = 1
67const SS_R_MIN: i64 = 2
68const SS_R_REASON: i64 = 3
69const SS_R_VERB: i64 = 4
70const SS_R_HASVERB: i64 = 5
71const SS_R_SLOTS: i64 = 8
73const SS_U_VERB: i64 = 0
74const SS_U_VERBLEN: i64 = 1
75const SS_U_REASON: i64 = 2
76const SS_U_SUP: i64 = 3
77const SS_U_CNT: i64 = 4
78const SS_U_SLOTS: i64 = 8
80const SS_T_SUP: i64 = 0
81const SS_T_CNT: i64 = 5
82const SS_T_TOTAL_SUP: i64 = 10
83const SS_T_TOTAL_CNT: i64 = 11
84const SS_T_CONF_ROWS: i64 = 12
85const SS_T_CONF_MALFORMED: i64 = 13
86const SS_T_CONF_READ: i64 = 14
87const SS_T_CONF_RULES: i64 = 15
88const SS_T_FAIL: i64 = 16 // per class FAILURE support [16..20]: frames of the ritual whose outcome was not ok (ES27)
89const SS_T_TOTAL_FAIL: i64 = 21
90const SS_T_SLOTS: i64 = 22

functions

92func ss_capacity(q: *u8, n: i64) -> i64
called by 1: al_steps
98func ss_vlen(s: *u8) -> i64 { return sj_vlen(s) }
calls 1: sj_vlen
105func ss_conf_load(q: *u8, n: i64, tab: *i64, rt: *i64, t: *i64) -> i64
called by 1: al_steps calls 3: sj_lesj_lit_eqsj_atoi_span
165func ss_conf_find(q: *u8, tab: *i64, rows: i64, sig: *u8, siglen: i64) -> i64
called by 1: al_steps
181func ss_rule_find(q: *u8, rt: *i64, rules: i64, sig: *u8, siglen: i64) -> i64
called by 1: al_steps
213func ss_classify(row: i64, min_steps: i64, has_verb: i64, steps: i64) -> i64
called by 1: ss_class_of
221func ss_class_of(row: i64, min_steps: i64, has_verb: i64, steps: i64, rule: i64) -> i64
called by 1: al_steps calls 1: ss_classify
226func ss_rule_add(rt: *i64, rule: i64, support: i64) -> i64
called by 1: al_steps
232func ss_class_name(c: i64) -> *u8
239func ss_totals_zero(t: *i64) -> i64 { var z: i64 = 0; while z < SS_T_SLOTS { t[z] = 0; z = z + 1 } return 0 }
called by 1: al_steps
240func ss_totals_add(t: *i64, c: i64, support: i64, fail: i64) -> i64
called by 1: al_steps
249func ss_permil(part: i64, whole: i64) -> i64 { if whole <= 0 { return 0 - 1 } return part * SS_PERMIL / whole }
252func ss_explained_permil(t: *i64) -> i64
259func ss_fail_permil(support: i64, fail: i64) -> i64 { return ss_permil(fail, support) }
260func ss_quality_permil(t: *i64) -> i64 { let fp: i64 = ss_permil(t[SS_T_TOTAL_FAIL], t[SS_T_TOTAL_SUP]); if fp < 0 { return 0 - 1 } return SS_PERMIL - fp }
261func ss_risk(support: i64, fail: i64) -> i64 { let fp: i64 = ss_fail_permil(support, fail); if fp < 0 { return 0 } return support * fp }
263func ss_emit_totals(d: *u8, p0: i64, t: *i64) -> i64
296func ss_is_prod(journal: *u8) -> i64
called by 1: ss_publish_json calls 2: sj_lit_eqsj_vlen
299func ss_side_path(journal: *u8, sfx: *u8, out: *u8) -> i64 { let o: i64 = sj_cat(out, 0, journal); return sj_cat(out, o, sfx) }
called by 1: ss_publish_json calls 1: sj_cat
301func ss_publish_json(d: *u8, p0: i64, journal: *u8, now: i64, t: *i64) -> i64