nx_select.nx
buildroot/runtime/nx_select.nx
about
nx_select.nx -- single-class variant selector engine.
SA-4 milestone of NISHI_SELF_ASSEMBLY_ROADMAP.md. Consumes
(candidates, probe, calibration, policy) and returns the index of
the best-match variant under the policy vector subject to the
candidate's requires_* constraints intersecting the device's probe.
Selection function (single-class, MVP):
S(C, P, K, π) = argmin_{v ∈ candidates}
Σ_axis π[axis] · cost_axis(v) · K[axis_norm]
s.t. requires_isa(v) ⊆ P.actual_isa_family
requires_isa_ext(v) ⊆ P.actual_isa_ext
requires_ram_min(v) ≤ P.ram_proxy
tier_floor(v) ≤ K.inferred_tier
tier_ceiling(v) ≥ K.inferred_tier
Joint-DAG cross-primitive selection deferred to SA-5
(nx_select_joint). Per-primitive smoke gating deferred to SA-6
(nx_verify). Byzantine N-of-M deferred to SA-7.
V1 manifest schema is INTEGER-ENCODED (sealed-enum bitmasks for
requires_isa, Q10 fixed-point for cost coefficients) so the
selector runs without a manifest-header parser. SA-5 lands the
parser that lifts authored headers in `runtime/*.nx` into these
integer-encoded records.
genealogy_id: petabricks_2009 + halide_schedule_search_2019 +
cardinal_2026-05-19_self_assembly
lineage_id: substrate_select_v1
nx_capability_manifest:
variant_class: capability_select
variant_id: capability_select_v1_single_class
requires_isa: [rv64imac, x86_64]
requires_syscalls: [mmap]
requires_ram_min_b: 4096
tier_floor: NX_TIER_MOBILE
tier_ceiling: NX_TIER_HPC
cost_model:
dependencies 3 imports · 14 importers
diagram shows first 10 each side; +0 more imports, +4 more importers in the complete lists below.
imports: nx_syscalls.nxnx_probe.nxnx_calibrate.nx
imported by: nx_install_attest_signed_test.nxnx_install_attest_test.nxnx_install_hash_test.nxnx_install_pipeline.nxnx_install_pipeline_test.nxnx_install_plan.nxnx_install_plan_test.nxnx_select_joint.nxnx_select_joint_chain_test.nxnx_select_joint_test.nxnx_select_test.nxnx_spore_up_lifecycle_test.nxnx_spore_up_network_test.nxnx_spore_up_test.nx
structs
| 116 | struct NxManifest |
| 137 | struct NxPolicy |
consts
| 57 | const NX_MAGIC_1024: i64 = 1024 |
| 58 | const NX_MAGIC_9223372036854775000: i64 = 9223372036854775000 |
| 78 | const NX_LAYOUT_OPAQUE_PASS: i64 = 0 |
| 79 | const NX_LAYOUT_ROW_MAJOR: i64 = 1 |
| 80 | const NX_LAYOUT_COL_MAJOR: i64 = 2 |
| 81 | const NX_LAYOUT_I64_PACKED: i64 = 3 |
| 82 | const NX_LAYOUT_I32_PACKED: i64 = 4 |
| 83 | const NX_LAYOUT_I8_PACKED: i64 = 5 |
| 84 | const NX_LAYOUT_Q10_FIXED: i64 = 6 |
| 85 | const NX_LAYOUT_F16: i64 = 7 |
| 86 | const NX_LAYOUT_F32: i64 = 8 |
| 87 | const NX_LAYOUT_N: i64 = 9 |
| 100 | const NX_ISA_EXT_AVX2: i64 = 0 |
| 101 | const NX_ISA_EXT_AVX512: i64 = 1 |
| 102 | const NX_ISA_EXT_BMI2: i64 = 2 |
| 103 | const NX_ISA_EXT_SHA_NI: i64 = 3 |
| 104 | const NX_ISA_EXT_AES_NI: i64 = 4 |
| 105 | const NX_ISA_EXT_NEON: i64 = 5 |
| 106 | const NX_ISA_EXT_SVE: i64 = 6 |
| 107 | const NX_ISA_EXT_RVV: i64 = 7 |
| 108 | const NX_ISA_EXT_N: i64 = 8 |
| 205 | const NX_SEL_NONE_MATCH: i64 = -1 |
| 206 | const NX_SEL_BAD_INPUT: i64 = -2 |
| 207 | const NX_SEL_OVER_CAPACITY: i64 = -3 |
functions
| 64 | func nx_isa_bit(isa: i64) -> i64 |
| 92 | func nx_layout_compatible(out_layout: i64, in_layout: i64) -> i64 |
| 146 | func nx_policy_throughput_default() -> *NxPolicy |
| 156 | func nx_policy_energy_default() -> *NxPolicy |
| 166 | func nx_manifest_new( |
| 198 | func nx_manifest_set_layout(m: *NxManifest, in_layout: i64, out_layout: i64) -> i64 |
| 212 | func nx_select_variant_fits( |
| 239 | func nx_select_score(v: *NxManifest, policy: *NxPolicy) -> i64 |
| 258 | func nx_select( |