code wiki / (root) / nx_ferment_process.nx

nx_ferment_process.nx

buildroot/runtime/nx_ferment_process.nx

7850 B191 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind librarytopic ferment
docsdependenciesstructsconstsfunctions

about

nx_ferment_process.nx -- R2 process rung: the ferment state machine. A fermentation recipe is a SEQUENCE OF PHASES, each with a target temperature (for the R1 thermal controller) and an exit condition (temperature reached, pH reached, or time elapsed). This is the yogurt-maker / cheesemaker LOGIC: pasteurize -> cool -> inoculate -> ferment-hold -> chill (yogurt); ripen -> rennet -> cut -> cook -> drain -> press -> age (cheese). One generic executor, data-driven per Rule 6/11 -- the phase table is data, not code. SAFETY COMPOSITION: every phase flagged is_ferment passes through the R0 never-poison law (nx_ferment_validate) BEFORE its exit is checked. Any refusal HALTS the whole process (status = HALTED_UNSAFE) and records the verdict. The never-poison law thus propagates up the ladder -- an unsafe batch can never run to "done". Non-ferment phases (e.g. the 82 C pasteurization, which is above culture-kill) are NOT validated by the ferment law -- no culture is present yet, so culture-kill does not apply. That separation is why nx_ferment_validate documents itself as the ferment-HOLD predicate. genealogy_id: nishi_ferment_safety_envelope_2026 (via nx_ferment_safety) + state_machine_recipe_executor_pattern

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_ferment_safety.nx nx_ferment_process.nx nx_ferment_process_test.nx

imports: nx_syscalls.nxnx_ferment_safety.nx

imported by: nx_ferment_process_test.nx

structs

57struct NxFermentPhase
68struct NxFermentProcess

consts

27const NX_MAGIC_82000: i64 = 82000
28const NX_MAGIC_43000: i64 = 43000
29const NX_MAGIC_4500: i64 = 4500
30const NX_MAGIC_5000: i64 = 5000
34const NX_FP_PASTEURIZE: nx_int = 0
35const NX_FP_COOL: nx_int = 1
36const NX_FP_INOCULATE: nx_int = 2
37const NX_FP_FERMENT: nx_int = 3
38const NX_FP_CHILL: nx_int = 4
39const NX_FP_PRESS: nx_int = 5
40const NX_FP_AGE: nx_int = 6
44const NX_FX_TEMP_AT_OR_ABOVE: nx_int = 0 // temp >= threshold (heating done)
45const NX_FX_TEMP_AT_OR_BELOW: nx_int = 1 // temp <= threshold (cooling done)
46const NX_FX_PH_AT_OR_BELOW: nx_int = 2 // pH <= threshold (acidified)
47const NX_FX_TIME_ELAPSED: nx_int = 3 // elapsed >= threshold
51const NX_PR_RUNNING: nx_int = 0
52const NX_PR_COMPLETE: nx_int = 1
53const NX_PR_HALTED_UNSAFE: nx_int = 2
66const NX_FP_PHASE_BYTES: nx_size = 48

functions

79func nx_ferment_phases_new(n: nx_size) -> *NxFermentPhase
called by 1: main calls 1: sys_mmap
84func _fp_phase_at(phases: *NxFermentPhase, idx: nx_size) -> *NxFermentPhase
88func nx_ferment_phase_set(phases: *NxFermentPhase, idx: nx_size,
102func nx_ferment_process_new(env: *NxFermentSafetyEnvelope,
called by 1: main calls 1: sys_mmap
118func nx_ferment_process_target(pr: *NxFermentProcess) -> i64
called by 1: main calls 1: _fp_phase_at
125func nx_ferment_process_current_is_ferment(pr: *NxFermentProcess) -> nx_int
called by 1: main calls 1: _fp_phase_at
134func nx_ferment_process_step(pr: *NxFermentProcess,
184func nx_ferment_build_yogurt(phases: *NxFermentPhase) -> i64
called by 1: main calls 1: nx_ferment_phase_set