code wiki / (root) / nx_circadian.nx

nx_circadian.nx

buildroot/runtime/nx_circadian.nx

5119 B132 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_circadian.nx -- distributed clock sync + scheduling (NTP/cron class). Biology: circadian rhythm is the ~24-hour cycle in metabolic + behavior regulated by cellular oscillators (suprachiasmatic nucleus in mammals, per/cry/clock genes). Sync drift: ~15-30 min/day without external cue. Reset by light, temperature, food timing. Substrate: distributed-clock-class primitive for substrate-internal rhythms (heartbeat, scheduled work, peer-clock-sync alignment). Per [[feedback-predictive-planning-allowed-exploitation-refused]]: substrate supports rhythm-detection for operator's own planning; REFUSES rhythm-exploitation (engagement loops, addiction architecture). lineage_id: substrate_circadian_v1

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_tier.nx nx_circadian.nx nx_circadian_test.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_circadian_test.nx

structs

45struct NxCircadianRhythm

consts

19const NX_MAGIC_30000: i64 = 30000
20const NX_MAGIC_60000: i64 = 60000
21const NX_MAGIC_3600000: i64 = 3600000
22const NX_MAGIC_86400000: i64 = 86400000
23const NX_MAGIC_604800000: i64 = 604800000
24const NX_MAGIC_7884000000: i64 = 7884000000
26const NX_CD_RHYTHM_SUBSTRATE_HEARTBEAT: nx_int = 0 // ~30s heartbeat
27const NX_CD_RHYTHM_SHORT_INTERVAL: nx_int = 1 // 1-15 min
28const NX_CD_RHYTHM_HOURLY: nx_int = 2
29const NX_CD_RHYTHM_DAILY: nx_int = 3 // canonical circadian
30const NX_CD_RHYTHM_WEEKLY: nx_int = 4
31const NX_CD_RHYTHM_SEASONAL: nx_int = 5
32const NX_CD_RHYTHM_N: nx_int = 6
34const NX_CD_DRIFT_OK: nx_int = 0
35const NX_CD_DRIFT_MINOR: nx_int = 1 // re-sync soon
36const NX_CD_DRIFT_MAJOR: nx_int = 2 // re-sync now
37const NX_CD_DRIFT_INVALID: nx_int = 99
38const NX_CD_DRIFT_N: nx_int = 3
40const NX_CD_V_OK: nx_int = 0
41const NX_CD_V_ERR_NULL_INPUT: nx_int = 1
42const NX_CD_V_ERR_INVALID_RHYTHM: nx_int = 2
43const NX_CD_V_N: nx_int = 3
53const NX_CD_BYTES: nx_int = 48

functions

55func nx_cd_rhythm_is_valid(r: nx_int) -> nx_int
61func nx_cd_drift_is_valid(d: nx_int) -> nx_int
called by 1: main
67func nx_cd_v_is_valid(v: nx_int) -> nx_int
called by 1: main
73func nx_cd_rhythm_canonical_period_ms(r: nx_int) -> nx_size
83func nx_cd_rhythm_new(rhythm: nx_int, now_us: nx_size) -> *NxCircadianRhythm
95func nx_cd_tick(c: *NxCircadianRhythm, now_us: nx_size) -> nx_int
called by 1: main
108func nx_cd_drift_classify(c: *NxCircadianRhythm) -> nx_int
called by 1: main
119func nx_cd_resync(c: *NxCircadianRhythm, now_us: nx_size) -> nx_int
called by 1: main
126func nx_cd_due_for_tick(c: *NxCircadianRhythm, now_us: nx_size) -> nx_int
called by 1: main