code wiki / _hdl_build / nx_spec_ingest.nx
nx_spec_ingest.nx source
↩ module page · 49 lines · 2690 B
1// nx_spec_ingest.nx -- the SPEC -> BUILDER -> INGEST bridge that was MISSING (operator: "is it being
2// pushed into spec work for the builder and being ingested?" -- it wasn't). When the Monitor/opportunity
3// loop selects a move, this turns it into a SPEC (in-type -> out-type, must verify), hands it to the
4// BUILDER (bc_compose finds the chain), and on success BANKS a capability record by APPENDING it to a
5// sovereign registry file -- automatic ingestion, written by the TEAM via sys_write, not hand-edited by
6// Claude. The self-model is regenerated FROM this registry. license_tier: ORIGINAL Composes
7// nx_builder_compose (the Builder) + nx_loop_monitor (productive -> emit spec).
8
9import "nx_builder_compose.nx"
10import "nx_ingest_governed.nx"
11import "nx_syscalls.nx"
12
13const SI_OK: i64 = 1
14const SI_REJECT: i64 = 0
15
16// can the Builder satisfy this spec? delegate to the Builder's composer (it INGESTS the spec).
17func si_buildable(in_type: i64, out_type: i64, seq: *i64, maxlen: i64) -> i64 {
18 let len: i64 = bc_compose(in_type, out_type, seq, maxlen)
19 return len // >0 = a chain was found; <=0 = the Builder can't build it (honest reject)
20}
21
22// ingest only when the Builder composed a chain AND it verified -- never bank an unbuilt/unverified claim.
23func si_ingest_verdict(chain_len: i64, verified: i64) -> i64 {
24 if chain_len <= 0 { return SI_REJECT }
25 if verified != 1 { return SI_REJECT }
26 return SI_OK
27}
28
29// GOVERNED BANK: the registry is only written when the governance pipeline returned IG_INGEST (Engineer
30// PASS + Council ADMIT + documented). A raw verified=1 flag is NOT enough -- the bridge proposes, the
31// Council disposes. This is the gate the operator required: no automatic insertion into the ecosystem.
32func si_bank_if_governed(fd: i64, name: *u8, namelen: i64, chain_len: i64, ingest_decision: i64) -> i64 {
33 if ingest_decision != IG_INGEST { return 0 } // HELD -> route to Doctor/Scribe; nothing banked
34 return si_bank(fd, name, namelen, chain_len)
35}
36
37// BANK: append a capability record to the sovereign registry file (the final write -- ONLY the governed
38// path above calls this; never call it directly on a loop result).
39func si_bank(fd: i64, name: *u8, namelen: i64, chain_len: i64) -> i64 {
40 sys_write(fd, "CAP name=" as *u8, 9)
41 sys_write(fd, name, namelen)
42 sys_write(fd, " status=PROVEN chain_len=" as *u8, 25)
43 let d: *u8 = sys_mmap(8); var m: i64 = chain_len; var k: i64 = 0; if m==0 {d[0]=48;k=1}
44 let t: *u8 = sys_mmap(8); while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}
45 var i: i64 = 0; while i<k {d[i]=t[k-1-i]; i=i+1}
46 sys_write(fd, d, k)
47 sys_write(fd, " src=loop\n" as *u8, 9)
48 return 1
49}