code wiki / (root) / nx_image_access.nx

nx_image_access.nx source

↩ module page · 30 lines · 2076 B

1// nx_image_access.nx -- ACCESS POLICY for the search-by-image realm: OPERATOR-ONLY, deny-by-default. 2// 3// Operator directive (2026-06-18): "put the search by image for only my access, not internet or others." 4// Search-by-image runs reverse-image queries over the OWNER-only gallery (cam recordings + NSFW), so the 5// realm INHERITS the gallery's strictest level: OWNER. DENY-BY-DEFAULT + FAIL-CLOSED (NIST SP 800-207, 6// same posture as nx_access_wall): any viewer below OWNER -- anonymous internet (0), family (1), or a 7// negative/garbage level -- is DENIED and gets ZERO results. 8// 9// This is the search-by-image analog of nx_galx_authz (which defines the gallery's policy). OWNER==3 10// MIRRORS nx_galx_authz GALX_OWNER (its owner-only level for cam recordings + NSFW); that module lives in 11// runtime/_hdl_build/ which is off this compile's import path, so the value is PINNED here and asserted 12// ==3 by nx_image_access_gate (single vocabulary, gate-checked). The enforcement point (the future search 13// ENDPOINT/daemon) derives viewer_level from the OPAQUE-authenticated session exactly as the gallery 14// daemon does (nx_opaque_login -> nx_sa_validate_handle -> level), then calls nx_imgsearch_access BEFORE 15// running any query. Internal CLI callers are trusted (Cardinal 12: validate at the boundary). license_tier: ORIGINAL 16import "nx_syscalls.nx" 17 18const NX_IMGSEARCH_OWNER: i64 = 3 // == nx_galx_authz GALX_OWNER (operator-only); gate asserts ==3 19const NX_IMGSEARCH_DENY: i64 = 0 20const NX_IMGSEARCH_ALLOW: i64 = 1 21 22// the search-by-image realm requires OWNER (operator). Single source of truth for the required level. 23func nx_imgsearch_required_level() -> i64 { return NX_IMGSEARCH_OWNER } 24 25// THE decision. ALLOW iff the (session-derived) viewer level meets OWNER. Deny-by-default / fail-closed: 26// every level below OWNER -- 0 anonymous-internet, 1 family, 2, or any negative/garbage value -- DENIES. 27func nx_imgsearch_access(viewer_level: i64) -> i64 { 28 if viewer_level >= NX_IMGSEARCH_OWNER { return NX_IMGSEARCH_ALLOW } 29 return NX_IMGSEARCH_DENY 30}