nx_circadian.nx
buildroot/runtime/nx_circadian.nx
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
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_circadian_test.nx
structs
| 45 | struct NxCircadianRhythm |
consts
| 19 | const NX_MAGIC_30000: i64 = 30000 |
| 20 | const NX_MAGIC_60000: i64 = 60000 |
| 21 | const NX_MAGIC_3600000: i64 = 3600000 |
| 22 | const NX_MAGIC_86400000: i64 = 86400000 |
| 23 | const NX_MAGIC_604800000: i64 = 604800000 |
| 24 | const NX_MAGIC_7884000000: i64 = 7884000000 |
| 26 | const NX_CD_RHYTHM_SUBSTRATE_HEARTBEAT: nx_int = 0 // ~30s heartbeat |
| 27 | const NX_CD_RHYTHM_SHORT_INTERVAL: nx_int = 1 // 1-15 min |
| 28 | const NX_CD_RHYTHM_HOURLY: nx_int = 2 |
| 29 | const NX_CD_RHYTHM_DAILY: nx_int = 3 // canonical circadian |
| 30 | const NX_CD_RHYTHM_WEEKLY: nx_int = 4 |
| 31 | const NX_CD_RHYTHM_SEASONAL: nx_int = 5 |
| 32 | const NX_CD_RHYTHM_N: nx_int = 6 |
| 34 | const NX_CD_DRIFT_OK: nx_int = 0 |
| 35 | const NX_CD_DRIFT_MINOR: nx_int = 1 // re-sync soon |
| 36 | const NX_CD_DRIFT_MAJOR: nx_int = 2 // re-sync now |
| 37 | const NX_CD_DRIFT_INVALID: nx_int = 99 |
| 38 | const NX_CD_DRIFT_N: nx_int = 3 |
| 40 | const NX_CD_V_OK: nx_int = 0 |
| 41 | const NX_CD_V_ERR_NULL_INPUT: nx_int = 1 |
| 42 | const NX_CD_V_ERR_INVALID_RHYTHM: nx_int = 2 |
| 43 | const NX_CD_V_N: nx_int = 3 |
| 53 | const NX_CD_BYTES: nx_int = 48 |
functions
| 55 | func nx_cd_rhythm_is_valid(r: nx_int) -> nx_int |
| 61 | func nx_cd_drift_is_valid(d: nx_int) -> nx_int called by 1: main |
| 67 | func nx_cd_v_is_valid(v: nx_int) -> nx_int called by 1: main |
| 73 | func nx_cd_rhythm_canonical_period_ms(r: nx_int) -> nx_size |
| 83 | func nx_cd_rhythm_new(rhythm: nx_int, now_us: nx_size) -> *NxCircadianRhythm |
| 95 | func nx_cd_tick(c: *NxCircadianRhythm, now_us: nx_size) -> nx_int called by 1: main |
| 108 | func nx_cd_drift_classify(c: *NxCircadianRhythm) -> nx_int called by 1: main |
| 119 | func nx_cd_resync(c: *NxCircadianRhythm, now_us: nx_size) -> nx_int called by 1: main |
| 126 | func nx_cd_due_for_tick(c: *NxCircadianRhythm, now_us: nx_size) -> nx_int called by 1: main |