code wiki / _hdl_build / nx_site_snapshot.nx
nx_site_snapshot.nx source
↩ module page · 35 lines · 1863 B
1// nx_site_snapshot.nx -- the team's SITE SNAPSHOT capability (part of S-class hosting: you cannot host
2// at S-class without snapshot/backup/restore). It captures every live route's content to a file, so the
3// site's content is DECOUPLED from the serving binary -- source-preserved, redeployable, migratable.
4// This directly fixed the trap we hit: the live content was reachable ONLY inside a binary whose source
5// was lost; the snapshot makes the CONTENT the source of truth again. PROVEN by the real capture of
6// nishifamily.com + andelinwest.com (6 routes, 12462 bytes, into knowledge/captured_site/*.html).
7// license_tier: ORIGINAL Composes the sovereign fetch + ssh_exec; pairs with nx_host_deploy + the Genealogist.
8
9import "nx_syscalls.nx"
10
11// a route is captured iff it returned content.
12func snap_route_ok(bytes: i64) -> i64 { if bytes > 0 { return 1 } return 0 }
13
14// coverage: how many of the n routes were captured non-empty.
15func snap_coverage(route_bytes: *i64, n: i64) -> i64 {
16 var c: i64 = 0; var i: i64 = 0
17 while i < n { if snap_route_ok(route_bytes[i]) == 1 { c = c + 1 } i = i + 1 }
18 return c
19}
20
21// the snapshot is COMPLETE iff every listed route was captured.
22func snap_complete(route_bytes: *i64, n: i64) -> i64 { if snap_coverage(route_bytes, n) == n { return 1 } return 0 }
23
24// can the site be rebuilt/redeployed FROM the snapshot (no binary needed)?
25func snap_redeployable(complete: i64) -> i64 { return complete }
26
27// the key property: a complete snapshot DECOUPLES content from the binary -> source-of-truth restored.
28func snap_decouples_content(complete: i64) -> i64 { return complete }
29
30// total bytes preserved (the size of the source-preserved content).
31func snap_total_bytes(route_bytes: *i64, n: i64) -> i64 {
32 var s: i64 = 0; var i: i64 = 0
33 while i < n { s = s + route_bytes[i]; i = i + 1 }
34 return s
35}