nx_fetch_rights_gate.nx source
↩ module page · 51 lines · 2626 B
1// nx_fetch_rights_gate.nx -- liar-kill gate for the acquisition rights policy.
2//
3// Proves the four-status, search-engine-style model and its two key invariants:
4// BLOCKED (Getty/DMCA) is NEVER indexable; only OWNED is product-usable.
5// Plus: unknown defaults to CRAWLABLE, host match is case-insensitive,
6// TO_ACQUIRE is flagged-not-usable, override (sign a target -> OWNED) works,
7// bad status refused.
8
9import "nx_syscalls.nx"
10import "nx_fetch_rights.nx"
11
12func main() -> i64 {
13 let p: *NxFrPolicy = nx_fr_new(16)
14 if nx_fr_set(p, "getty.com" as *u8, NX_FR_BLOCKED) != 0 { return 1 }
15 if nx_fr_set(p, "dmca-flagged.example" as *u8, NX_FR_BLOCKED) != 0 { return 2 }
16 if nx_fr_set(p, "licensed-partner.example" as *u8, NX_FR_OWNED) != 0 { return 3 }
17 if nx_fr_set(p, "wewanttowork.example" as *u8, NX_FR_TO_ACQUIRE) != 0 { return 4 }
18
19 // unknown host -> CRAWLABLE: indexable like a search engine, NOT product-usable
20 if nx_fr_classify(p, "random-public.example" as *u8) != NX_FR_CRAWLABLE { return 5 }
21 if nx_fr_may_index(NX_FR_CRAWLABLE) != 1 { return 6 }
22 if nx_fr_may_use_in_product(NX_FR_CRAWLABLE) != 0 { return 7 }
23
24 // BLOCKED (Getty/DMCA): NEVER indexable, NEVER usable -- the avoid invariant
25 if nx_fr_classify(p, "getty.com" as *u8) != NX_FR_BLOCKED { return 8 }
26 if nx_fr_may_index(NX_FR_BLOCKED) != 0 { return 9 }
27 if nx_fr_may_use_in_product(NX_FR_BLOCKED) != 0 { return 10 }
28 // case-insensitive host match
29 if nx_fr_classify(p, "GETTY.COM" as *u8) != NX_FR_BLOCKED { return 11 }
30
31 // OWNED (licensed): indexable + product-usable
32 if nx_fr_classify(p, "licensed-partner.example" as *u8) != NX_FR_OWNED { return 12 }
33 if nx_fr_may_index(NX_FR_OWNED) != 1 { return 13 }
34 if nx_fr_may_use_in_product(NX_FR_OWNED) != 1 { return 14 }
35
36 // TO_ACQUIRE: indexable, NOT product-usable yet, flagged for outreach
37 if nx_fr_classify(p, "wewanttowork.example" as *u8) != NX_FR_TO_ACQUIRE { return 15 }
38 if nx_fr_may_index(NX_FR_TO_ACQUIRE) != 1 { return 16 }
39 if nx_fr_may_use_in_product(NX_FR_TO_ACQUIRE) != 0 { return 17 }
40 if nx_fr_is_to_acquire(NX_FR_TO_ACQUIRE) != 1 { return 18 }
41
42 // override: we signed the target -> reclassify OWNED (last write wins)
43 if nx_fr_set(p, "wewanttowork.example" as *u8, NX_FR_OWNED) != 0 { return 19 }
44 if nx_fr_classify(p, "wewanttowork.example" as *u8) != NX_FR_OWNED { return 20 }
45 if nx_fr_may_use_in_product(nx_fr_classify(p, "wewanttowork.example" as *u8)) != 1 { return 21 }
46
47 // bad status refused
48 if nx_fr_set(p, "x.example" as *u8, 99) != (0 - 1) { return 22 }
49
50 return 0
51}