code wiki / _hdl_build / nx_site_deploy.nx

nx_site_deploy.nx source

↩ module page · 49 lines · 2398 B

1// nx_site_deploy.nx -- the team's BUILD -> DEPLOY -> UPDATE capability for nishifamily.com, with the safety 2// gates a live family site demands (operator: "build the teams ability to build this and deploy and update 3// on nishifamily.com"). NEVER mutate production without: a BACKUP, VERIFIED equivalence (what serves == what 4// we built), a post-deploy HEALTH check, and an AUTO-ROLLBACK path. Each successful update is a versioned 5// rollback point. license_tier: ORIGINAL Composes nx_ssh_put (transfer) + nx_deploy (practice score) + 6// nx_work_dashboard / nx_site_generator (build) + nx_site_command (update intent). 7 8import "nx_syscalls.nx" 9 10const SD_DEPLOYED: i64 = 1 11const SD_ROLLED_BACK: i64 = 2 // deployed but health failed -> auto-restored the backup (site never left broken) 12const SD_BLOCKED: i64 = 0 // not safe to deploy (missing a gate) -> do not touch production 13 14// a deploy is SAFE only with all four gates present. 15func sd_safe(backup: i64, verified_equiv: i64, health_pre: i64, rollback_ready: i64) -> i64 { 16 if backup == 1 { if verified_equiv == 1 { if health_pre == 1 { if rollback_ready == 1 { return 1 } } } } 17 return 0 18} 19 20// the deploy verdict: BLOCKED if unsafe; after deploying, DEPLOYED if the post-health passes, else AUTO-ROLLBACK. 21func sd_verdict(safe: i64, post_health: i64) -> i64 { 22 if safe != 1 { return SD_BLOCKED } 23 if post_health == 1 { return SD_DEPLOYED } 24 return SD_ROLLED_BACK 25} 26 27// versioned update: only a clean DEPLOYED bumps the live version (a new rollback point). 28func sd_version(current: i64, verdict: i64) -> i64 { 29 if verdict == SD_DEPLOYED { return current + 1 } 30 return current 31} 32func sd_can_rollback(current: i64, target: i64) -> i64 { 33 if target < 0 { return 0 } 34 if target < current { return 1 } 35 return 0 36} 37 38// the team must NOT rebuild the compiled daemon from a DRIFTED checkout (would regress the live site) -- 39// publish to a doc-root the daemon already serves, or via the wiki engine. flags the unsafe rebuild path. 40func sd_rebuild_safe(source_pinned: i64, drift_detected: i64) -> i64 { 41 if source_pinned == 1 { if drift_detected == 0 { return 1 } } 42 return 0 43} 44 45func sd_verdict_label(v: i64) -> *u8 { 46 if v == SD_DEPLOYED { return "DEPLOYED" as *u8 } 47 if v == SD_ROLLED_BACK { return "AUTO-ROLLED-BACK(site safe)" as *u8 } 48 return "BLOCKED(unsafe -- gate missing)" as *u8 49}