code wiki / _hdl_build / nx_host_deploy.nx
nx_host_deploy.nx source
↩ module page · 51 lines · 2905 B
1// nx_host_deploy.nx -- the team's UNIFIED S-class hosting + deploy capability (operator: "s class site
2// hosting and deployment with ease and speed"). It composes every piece the team built -- provenance
3// stamp, backup, sovereign ssh_put_file, differential-equivalence verify, health-check, auto-rollback --
4// into ONE orchestrated deploy with a single verdict, for TWO hosting models:
5// FILE_BASED -- the daemon serves from a web/ DOC ROOT. Deploy = sovereign file-put to the doc root ->
6// INSTANTLY live, NO rebuild, NO source needed. Fast + easy + source-loss-proof. S-CLASS.
7// COMPILED -- routes hoisted into the binary (the current live sites.elf). Deploy = rebuild ->
8// verify-equivalence -> swap. Slower, and BLOCKED if the source is not pinned (which is
9// exactly the trap the live site fell into).
10// The lesson encoded: the team should HOST file-based for ease+speed, and never let a deploy be
11// un-provenanced again. license_tier: ORIGINAL Composes nx_deploy + nx_deploy_verify + nx_deploy_provenance.
12
13import "nx_syscalls.nx"
14
15const HD_FILE_BASED: i64 = 1
16const HD_COMPILED: i64 = 2
17
18const HD_BLOCKED: i64 = 0 // cannot deploy safely (no source for compiled / transfer failed)
19const HD_STAGED: i64 = 1 // transferred but unhealthy -> rolled back, not live
20const HD_LIVE: i64 = 2 // deployed + healthy + serving
21
22// ease+speed score (0-100): file-based (drop a file -> live) >> compiled (rebuild + needs the source).
23func hd_ease_speed(mode: i64) -> i64 { if mode == HD_FILE_BASED { return 95 } return 40 }
24
25// can this model deploy WITHOUT the (possibly lost) source? file-based yes; compiled no.
26func hd_source_independent(mode: i64) -> i64 { if mode == HD_FILE_BASED { return 1 } return 0 }
27
28// the unified deploy verdict, composing all the safety gates.
29func hd_verdict(mode: i64, transferred: i64, healthy: i64, source_pinned: i64, verified_equivalent: i64) -> i64 {
30 if mode == HD_FILE_BASED {
31 if transferred != 1 { return HD_BLOCKED }
32 if healthy == 1 { return HD_LIVE }
33 return HD_STAGED // unhealthy -> auto-rollback (live protected)
34 }
35 // COMPILED model
36 if source_pinned != 1 { return HD_BLOCKED } // cannot build -> never swap (the live trap)
37 if verified_equivalent != 1 { return HD_BLOCKED } // would regress -> never swap
38 if transferred != 1 { return HD_BLOCKED }
39 if healthy == 1 { return HD_LIVE }
40 return HD_STAGED
41}
42
43// the S-class hosting recommendation: source-independent, fast, file-based.
44func hd_recommend() -> i64 { return HD_FILE_BASED }
45
46// is a deploy SLA-S-class (one-shot, source-independent, fast)? only the file-based model on a clean run.
47func hd_is_sclass(mode: i64, verdict: i64) -> i64 {
48 if mode != HD_FILE_BASED { return 0 }
49 if verdict == HD_LIVE { return 1 }
50 return 0
51}