code wiki / _hdl_build / nx_web_builder_test.nx
nx_web_builder_test.nx source
↩ module page · 98 lines · 6454 B
1// nx_web_builder_test.nx -- the TEAM uses its web-builder CAPABILITY to build andelinwest.com v1 (and a
2// second site, proving the capability is general, not a one-off). The generator enforces the cited UX
3// rules and emits responsive HTML bits-up. Content strings are the caller's (the legal prose = the
4// flagged LLM-gap); structure/UX/responsiveness are the capability's. Exit 0 on 6/6; the runner then
5// checks the emitted HTML contains the UX elements. license_tier: ORIGINAL
6
7import "nx_web_builder.nx"
8import "nx_syscalls.nx"
9
10func tt_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
11func tt_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(1,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 }
12
13// build the andelinwest site to fd using the capability; return the number of resolution steps emitted.
14func build_andelinwest(fd: i64) -> i64 {
15 wb_doc_open(fd, "Andelin West -- Utah Attorneys" as *u8)
16 wb_header(fd, "Andelin West" as *u8, "Free consultation" as *u8, "#consult" as *u8)
17 wb_hero(fd, "Straightforward legal help for Utah families and businesses." as *u8,
18 "Talk to a licensed Utah attorney. Most matters start with one short call." as *u8,
19 "Start your free consultation" as *u8, "#consult" as *u8)
20 wb_search(fd, "/search" as *u8, "Search: divorce, will, injury, contract..." as *u8)
21 wb_cards_open(fd, "How we help" as *u8)
22 wb_card(fd, "Family Law" as *u8, "Divorce, custody, and support, handled with care." as *u8)
23 wb_card(fd, "Estate Planning" as *u8, "Wills, trusts, and probate done right the first time." as *u8)
24 wb_card(fd, "Business Law" as *u8, "Formation, contracts, and disputes for Utah businesses." as *u8)
25 wb_card(fd, "Personal Injury" as *u8, "Injured? We deal with the insurers so you can heal." as *u8)
26 wb_cards_close(fd)
27 let steps: *i64 = sys_mmap(8*8) as *i64
28 steps[0]="Tell us what happened -- 2 minutes, no jargon." as *u8 as i64
29 steps[1]="We review and call you back, usually the same day." as *u8 as i64
30 steps[2]="We handle it -- clear updates at every stage." as *u8 as i64
31 let ns: i64 = wb_steps(fd, "Resolve it in 3 steps" as *u8, steps, 3)
32 let trust: *i64 = sys_mmap(8*8) as *i64
33 trust[0]="Licensed by the Utah State Bar" as *u8 as i64
34 trust[1]="Free initial consultation" as *u8 as i64
35 trust[2]="Serving Utah families since 2008" as *u8 as i64
36 wb_trust(fd, trust, 3)
37 wb_footer(fd, "Andelin West, PLLC -- Utah -- (801) 555-0100" as *u8)
38 wb_doc_close(fd)
39 return ns
40}
41
42// a SECOND, different site from the same capability -> proves it generalizes (the shadow-clone reuse).
43func build_clinic(fd: i64) -> i64 {
44 wb_doc_open(fd, "Wasatch Family Clinic" as *u8)
45 wb_header(fd, "Wasatch Family Clinic" as *u8, "Book a visit" as *u8, "#book" as *u8)
46 wb_hero(fd, "Friendly family healthcare in the Wasatch Front." as *u8, "Same-week appointments." as *u8, "Book a visit" as *u8, "#book" as *u8)
47 wb_search(fd, "/search" as *u8, "Search: pediatrics, physical, vaccine..." as *u8)
48 wb_cards_open(fd, "Services" as *u8)
49 wb_card(fd, "Primary Care" as *u8, "Checkups and ongoing care for the whole family." as *u8)
50 wb_card(fd, "Pediatrics" as *u8, "Gentle care from newborns to teens." as *u8)
51 wb_cards_close(fd)
52 let steps: *i64 = sys_mmap(8*8) as *i64
53 steps[0]="Book online in about a minute." as *u8 as i64
54 steps[1]="We confirm your time by text." as *u8 as i64
55 steps[2]="See the doctor." as *u8 as i64
56 let ns: i64 = wb_steps(fd, "Get seen in 3 steps" as *u8, steps, 3)
57 let trust: *i64 = sys_mmap(8*8) as *i64
58 trust[0]="Board-certified physicians" as *u8 as i64
59 trust[1]="Most insurance accepted" as *u8 as i64
60 wb_trust(fd, trust, 2)
61 wb_footer(fd, "Wasatch Family Clinic" as *u8)
62 wb_doc_close(fd)
63 return ns
64}
65
66func main() -> i64 {
67 tt_puts("=== WEB-BUILDER capability: the team builds andelinwest (+ a 2nd site), UX enforced ===\n" as *u8)
68
69 // capability self-checks (the research, enforced)
70 let comp_ok: i64 = wb_ux_compliant(3, 1, 1, 2)
71 let comp_bad: i64 = wb_ux_compliant(5, 1, 1, 2) // 5 steps violates the <=3 rule
72 let grade: i64 = wb_ux_grade(3, 1, 1, 2, 1)
73
74 // the team BUILDS andelinwest with the capability
75 let fd: i64 = sys_openat_wr("knowledge/projects/andelinwest_v1.html" as *u8, 0x1a4)
76 var aw_steps: i64 = 0 - 1; var aw_ok: i64 = 0
77 if fd >= 0 { aw_steps = build_andelinwest(fd); sys_close(fd); aw_ok = 1 }
78 // ...and a different site, proving generality
79 let fd2: i64 = sys_openat_wr("knowledge/projects/clinic_v1.html" as *u8, 0x1a4)
80 var cl_ok: i64 = 0
81 if fd2 >= 0 { build_clinic(fd2); sys_close(fd2); cl_ok = 1 }
82
83 tt_puts(" UX gate: compliant(3-step)=" as *u8); tt_num(comp_ok); tt_puts(" compliant(5-step)=" as *u8); tt_num(comp_bad); tt_puts(" grade=" as *u8); tt_num(grade); tt_puts("/100\n" as *u8)
84 tt_puts(" built andelinwest_v1.html (steps=" as *u8); tt_num(aw_steps); tt_puts(", ok=" as *u8); tt_num(aw_ok); tt_puts(") built clinic_v1.html (ok=" as *u8); tt_num(cl_ok); tt_puts(") -- same capability, 2 sites\n" as *u8)
85
86 let r: *i64 = sys_mmap(8*8) as *i64
87 r[0] = 0; if comp_ok == 1 { r[0] = 1 } // compliant spec accepted
88 r[1] = 0; if comp_bad == 0 { r[1] = 1 } // >3 steps rejected (rule enforced)
89 r[2] = 0; if grade == 100 { r[2] = 1 } // full UX grade
90 r[3] = 0; if aw_steps == 3 { r[3] = 1 } // andelinwest built with exactly 3 steps
91 r[4] = 0; if aw_ok == 1 { r[4] = 1 } // andelinwest emitted
92 r[5] = 0; if cl_ok == 1 { r[5] = 1 } // a 2nd site from the same capability (general)
93 var pass: i64 = 0; var i: i64 = 0
94 while i < 6 { pass = pass + r[i]; i = i + 1 }
95 tt_puts("----\n passed " as *u8); tt_num(pass); tt_puts("/6\n" as *u8)
96 if pass == 6 { tt_puts(" CAPABILITY BUILT: the team can build UX-compliant responsive sites from a spec -- it built andelinwest AND a clinic. Reusable for the next lawyer/doctor/ecommerce (shadow-clone).\n" as *u8); sys_exit(0); return 0 }
97 tt_puts(" FAIL\n" as *u8); sys_exit(1); return 1
98}