nx_maint_asset.nx source
↩ module page · 102 lines · 4775 B
1// nx_maint_asset.nx -- the universal maintenance SPINE: a data-driven asset/
2// spec model + physics-kernel dispatch. PROVES the platform thesis -- ONE
3// verdict engine + per-asset spec DATA -> MANY assets -- by routing thermal
4// assets (HVAC, water heater, fridge, dryer, oven) through the SAME proven
5// thermal kernel (nx_hvac_efficiency) with different specs.
6//
7// Operator (2026-06-23): expand HVAC efficiency into a universal maintenance
8// platform (cars/house/plumbing/hvac/tools), monitor + fix + replace, DIYer ->
9// enterprise do-it-for-you. Confirmed direction: spine-first; first vertical
10// after the spine = appliances & water heater (which reuses THIS kernel).
11//
12// The asset's healthy ENVELOPE lives in AssetSpec = DATA (CLAUDE.md #6/#11),
13// not code. A new thermal asset = a new spec, ZERO new physics. Declared-but-
14// unbuilt kernels return NOT_IMPLEMENTED (honest -- never a fake verdict).
15//
16// NEVER-BRICK (#26): pure dispatch over read-only measurement; writes nothing
17// to any device. No firmware path exists here.
18//
19// genealogy_id: project-maintenance-platform-sclass-2026-06-23 (SPINE R1)
20// license_tier: ORIGINAL
21//
22// nx_capability_claims:
23// needs: [pointer_arithmetic]
24// provides: [data_driven_asset_spec, physics_kernel_dispatch,
25// thermal_kernel_reuse_multi_asset, honest_not_implemented]
26// safety: [no_floating_point, no_syscall, read_only_no_device_write,
27// no_firmware_write_by_construction, sealed_enum_kernel]
28// verdict: [sealed_enum, no_silent_failure]
29// license: ORIGINAL
30// kind: maintenance_runtime_primitive
31
32import "nx_hvac_efficiency.nx" // the thermal-response kernel (nx_hvac_analyze_core)
33
34// ---- Asset classes (extensible; data identifies the specifics) -----
35const NX_MAINT_CLASS_HVAC: i64 = 0
36const NX_MAINT_CLASS_WATER_HEATER: i64 = 1
37const NX_MAINT_CLASS_REFRIGERATOR: i64 = 2
38const NX_MAINT_CLASS_DRYER: i64 = 3
39const NX_MAINT_CLASS_TOOL: i64 = 4
40const NX_MAINT_CLASS_PUMP: i64 = 5
41const NX_MAINT_CLASS_N: i64 = 6
42
43// ---- Physics kernels (~4 cover the whole platform) -----------------
44const NX_MAINT_KERNEL_THERMAL_RESPONSE: i64 = 0 // BUILT (nx_hvac_efficiency)
45const NX_MAINT_KERNEL_ROTATING_MACHINE: i64 = 1 // declared, not built
46const NX_MAINT_KERNEL_CONSUMABLE: i64 = 2 // declared, not built (printer-toner seed)
47const NX_MAINT_KERNEL_FLUID_SEAL: i64 = 3 // declared, not built
48const NX_MAINT_KERNEL_N: i64 = 4
49
50// ---- Maintenance-layer verdicts (>=100 so they never collide with the
51// thermal kernel's 0..6 verdict enum) --------------------------
52const NX_MAINT_NOT_IMPLEMENTED: i64 = 100 // kernel declared but unbuilt (honest)
53const NX_MAINT_BAD_SPEC: i64 = 101
54
55func nx_maint_class_is_valid(c: i64) -> i64 {
56 if c < 0 { return 0 }
57 if c >= NX_MAINT_CLASS_N { return 0 }
58 return 1
59}
60
61func nx_maint_kernel_is_valid(k: i64) -> i64 {
62 if k < 0 { return 0 }
63 if k >= NX_MAINT_KERNEL_N { return 0 }
64 return 1
65}
66
67// ---- The asset spec = the healthy envelope, as DATA ----------------
68// Thermal assets use: target_mC (setpoint/target), mode (+1 heat / -1 cool),
69// and the three thermal thresholds. A water heater and a furnace differ ONLY
70// in these numbers -- same kernel, different data. Non-thermal kernels extend
71// this struct with their own fields as they are built.
72struct AssetSpec {
73 asset_class: i64,
74 kernel: i64,
75 target_mC: i64,
76 mode: i64,
77 max_cph_x10: i64,
78 min_resp_mC_per_min: i64,
79 max_overshoot_mC: i64,
80}
81
82// ---- Dispatch: spec + out-of-band samples -> verdict (into *out) ----
83// value_mC = the controlled quantity (room temp / tank temp / cabinet temp)
84// ambient_mC = the load context (outdoor / room temp)
85// on = the independent runtime flag (from the CT monitor / sensor)
86// Routes by spec.kernel; reuses the proven thermal kernel for THERMAL_RESPONSE.
87func nx_maint_analyze(spec: *AssetSpec, t_sec: *i64, value_mC: *i64, ambient_mC: *i64,
88 on: *i64, n: i64, out: *HvacEff) -> i64 {
89 if nx_maint_kernel_is_valid(spec.kernel) != 1 {
90 out.verdict = NX_MAINT_BAD_SPEC
91 return out.verdict
92 }
93 if spec.kernel == NX_MAINT_KERNEL_THERMAL_RESPONSE {
94 return nx_hvac_analyze_core(t_sec, value_mC, ambient_mC, on, n,
95 spec.target_mC, spec.mode,
96 spec.max_cph_x10, spec.min_resp_mC_per_min,
97 spec.max_overshoot_mC, out)
98 }
99 // Declared kernel, not yet built -> honest, never a fabricated verdict.
100 out.verdict = NX_MAINT_NOT_IMPLEMENTED
101 return out.verdict
102}