nx_compost.nx
buildroot/runtime/nx_compost.nx
about
nx_compost.nx -- graceful retirement + nutrient harvest from retired primitives.
Biology: when an organism dies, its constituent atoms are decomposed by
fungi+bacteria and returned to the soil pool, where they're available
for re-uptake by living plants. Forests recycle ~90% of their nutrients
through this loop. Without compost, ecosystems collapse from depletion.
In Nishi: extends [[nx_prune]] (which only REMOVES dead/orphan code) by
adding nutrient-harvest -- when a primitive retires, identify its
reusable parts (constants, types, helper functions, schemas) and route
them back to the substrate pool for adoption by living primitives. This
is the difference between "delete file" (current prune) and "compost"
(extract value before disposing).
Composes [[feedback-forest-meta-vision-drift-lifecycle]] +
[[feedback-thymus-sovereignty-audit-soma-germline]] (composted nutrients
retain soma/germline class) + [[feedback-regenerative-stewardship-
doctrine-captain-moroni]] (recycling is regeneration not extraction) +
Cardinal 13 (history is sacred -- compost record is permanent additive
log, not destructive delete).
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_compost_test.nx
structs
| 58 | struct NxNutrient |
| 68 | struct NxCompostPile |
consts
| 29 | const NX_CP_NUT_CONST_DEFINITION: nx_int = 0 // sealed enum / const block |
| 30 | const NX_CP_NUT_TYPE_DEFINITION: nx_int = 1 // struct / type alias |
| 31 | const NX_CP_NUT_HELPER_FUNCTION: nx_int = 2 // pure utility function |
| 32 | const NX_CP_NUT_SCHEMA: nx_int = 3 // serialization layout |
| 33 | const NX_CP_NUT_TEST_SCAFFOLD: nx_int = 4 // assertion patterns / fixtures |
| 34 | const NX_CP_NUT_DOCUMENTATION: nx_int = 5 // header comment / spec |
| 35 | const NX_CP_NUT_BENCHMARK: nx_int = 6 // perf harness |
| 36 | const NX_CP_NUT_N: nx_int = 7 |
| 40 | const NX_CP_STAGE_FRESH: nx_int = 0 // just retired |
| 41 | const NX_CP_STAGE_DECOMPOSING: nx_int = 1 // nutrients being extracted |
| 42 | const NX_CP_STAGE_HARVESTED: nx_int = 2 // nutrients reabsorbed |
| 43 | const NX_CP_STAGE_REFUSED: nx_int = 3 // unsafe to recycle (soma) |
| 44 | const NX_CP_STAGE_N: nx_int = 4 |
| 48 | const NX_CP_V_OK: nx_int = 0 |
| 49 | const NX_CP_V_REFUSED_GERMLINE: nx_int = 1 // germline never composts |
| 50 | const NX_CP_V_REFUSED_ACTIVE: nx_int = 2 // not yet retired |
| 51 | const NX_CP_V_REFUSED_CLIMAX: nx_int = 3 // climax-stage never composts |
| 52 | const NX_CP_V_INVALID: nx_int = 4 |
| 53 | const NX_CP_V_NULL: nx_int = 5 |
| 54 | const NX_CP_V_N: nx_int = 6 |
| 66 | const NX_CP_N_BYTES: nx_int = 40 |
| 79 | const NX_CP_BYTES: nx_int = 56 |
functions
| 83 | func nx_cp_nut_is_valid(k: nx_int) -> nx_int |
| 89 | func nx_cp_stage_is_valid(s: nx_int) -> nx_int called by 1: main |
| 95 | func nx_cp_v_is_valid(v: nx_int) -> nx_int called by 1: main |
| 103 | func nx_cp_new(primitive_id: nx_int, |
| 128 | func _cp_nutrient_at(p: *NxCompostPile, idx: nx_int) -> *NxNutrient |
| 137 | func nx_cp_begin_decompose(p: *NxCompostPile) -> nx_int called by 1: main |
| 148 | func nx_cp_extract_nutrient(p: *NxCompostPile, |
| 171 | func nx_cp_reabsorb(p: *NxCompostPile, |
| 190 | func nx_cp_mark_harvested(p: *NxCompostPile) -> nx_int called by 1: main |
| 199 | func nx_cp_count_by_kind(p: *NxCompostPile, kind: nx_int) -> nx_int |
| 211 | func nx_cp_reused_count(p: *NxCompostPile) -> nx_int |
| 223 | func nx_cp_unclaimed_count(p: *NxCompostPile) -> nx_int |
| 235 | func nx_cp_stage(p: *NxCompostPile) -> nx_int called by 1: main |