nx_v7_bundle.nx source
↩ module page · 177 lines · 6401 B
1// nx_v7_bundle.nx -- typed measurement bundle for the V7 detection pipeline.
2//
3// The 16 detector primitives shipped in the S-class substrate consume a
4// shared MEASUREMENT BUNDLE — a single flat-array of typed slots that
5// caller fills from real image data once per render. Avoids the
6// nxc2 codegen bug with high-arity functions: each detector takes only
7// the bundle pointer plus its own result array.
8//
9// Layout: each slot is one i64 at a fixed offset. Caller pre-allocs
10// NX_V7_BUNDLE_FIELDS * 8 bytes and zero-fills.
11//
12// Producers:
13// nx_region (face/torso/limb bbox) -> face_*, torso_*, body_*
14// nx_cheek_localize -> cheek_l_*, cheek_r_*
15// nx_breast_localize -> breast_l_*, breast_r_*
16// nx_areola_localize -> areola_l_*, areola_r_*
17// nx_pose_classify -> pose_kind, pose_confidence
18// nx_eye_detect -> eye_width_px, iris_radius_px
19//
20// Consumers:
21// nx_anatomy_measure(bundle, mask, meas) -> writes meas[] for nx_beauty_score
22// nx_breast_drape_pose(...) -> reads breast_l_*, pose_kind
23// nx_areola_pigment(rgb, areola_mask, ...) -> uses areola_l_ as mask
24// nx_subsurface_warmth(rgb, skin_mask, ...) -> uses skin_mask globally
25// nx_specular_falloff(rgb, skin_mask, ...)
26// nx_eroticism_ladder(...) -> takes typed nudity+pose+penetration
27// nx_response_signal(rgb, skin_mask, bbox_pack) -> reads bbox_pack from bundle accessors
28
29// nx_safety_envelope:
30// intended_use: AUTO_APPLIED -- primitive-specific tuning queued
31// sil_target: SIL1
32// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail]
33// verdict: NOT_YET_EVALUATED
34
35import "nx_syscalls.nx"
36
37// Bundle slot offsets.
38const NX_V7_FACE_X0: i64 = 0
39const NX_V7_FACE_Y0: i64 = 1
40const NX_V7_FACE_X1: i64 = 2
41const NX_V7_FACE_Y1: i64 = 3
42const NX_V7_TORSO_X0: i64 = 4
43const NX_V7_TORSO_Y0: i64 = 5
44const NX_V7_TORSO_X1: i64 = 6
45const NX_V7_TORSO_Y1: i64 = 7
46const NX_V7_BODY_X0: i64 = 8
47const NX_V7_BODY_Y0: i64 = 9
48const NX_V7_BODY_X1: i64 = 10
49const NX_V7_BODY_Y1: i64 = 11
50
51const NX_V7_EYE_WIDTH_PX: i64 = 12
52const NX_V7_IRIS_RADIUS_PX: i64 = 13
53
54const NX_V7_CHEEK_L_X0: i64 = 14
55const NX_V7_CHEEK_L_Y0: i64 = 15
56const NX_V7_CHEEK_L_X1: i64 = 16
57const NX_V7_CHEEK_L_Y1: i64 = 17
58const NX_V7_CHEEK_R_X0: i64 = 18
59const NX_V7_CHEEK_R_Y0: i64 = 19
60const NX_V7_CHEEK_R_X1: i64 = 20
61const NX_V7_CHEEK_R_Y1: i64 = 21
62
63const NX_V7_BREAST_L_X0: i64 = 22
64const NX_V7_BREAST_L_Y0: i64 = 23
65const NX_V7_BREAST_L_X1: i64 = 24
66const NX_V7_BREAST_L_Y1: i64 = 25
67const NX_V7_BREAST_L_AREA: i64 = 26
68const NX_V7_BREAST_L_CY: i64 = 27
69const NX_V7_BREAST_R_X0: i64 = 28
70const NX_V7_BREAST_R_Y0: i64 = 29
71const NX_V7_BREAST_R_X1: i64 = 30
72const NX_V7_BREAST_R_Y1: i64 = 31
73const NX_V7_BREAST_R_AREA: i64 = 32
74const NX_V7_BREAST_R_CY: i64 = 33
75
76const NX_V7_AREOLA_L_X0: i64 = 34
77const NX_V7_AREOLA_L_Y0: i64 = 35
78const NX_V7_AREOLA_L_X1: i64 = 36
79const NX_V7_AREOLA_L_Y1: i64 = 37
80const NX_V7_AREOLA_R_X0: i64 = 38
81const NX_V7_AREOLA_R_Y0: i64 = 39
82const NX_V7_AREOLA_R_X1: i64 = 40
83const NX_V7_AREOLA_R_Y1: i64 = 41
84
85const NX_V7_POSE_KIND: i64 = 42
86const NX_V7_POSE_CONFIDENCE: i64 = 43
87
88// Reproductive state hint (set by identity registry).
89const NX_V7_REPRODUCTIVE_STATE: i64 = 44
90// Declared arousal Q10 (set by character state at render time).
91const NX_V7_AROUSAL_Q10: i64 = 45
92
93const NX_V7_BUNDLE_FIELDS: i64 = 46
94
95// Zero-init a freshly mmapped bundle.
96func nx_v7_bundle_init(bundle: *i64) -> i64 {
97 var i: i64 = 0
98 while i < NX_V7_BUNDLE_FIELDS { bundle[i] = 0; i = i + 1 }
99 return 0
100}
101
102// Set face bbox into bundle.
103func nx_v7_bundle_set_face(bundle: *i64, x0: i64, y0: i64, x1: i64, y1: i64) -> i64 {
104 bundle[NX_V7_FACE_X0] = x0
105 bundle[NX_V7_FACE_Y0] = y0
106 bundle[NX_V7_FACE_X1] = x1
107 bundle[NX_V7_FACE_Y1] = y1
108 return 0
109}
110
111// Set torso bbox into bundle.
112func nx_v7_bundle_set_torso(bundle: *i64, x0: i64, y0: i64, x1: i64, y1: i64) -> i64 {
113 bundle[NX_V7_TORSO_X0] = x0
114 bundle[NX_V7_TORSO_Y0] = y0
115 bundle[NX_V7_TORSO_X1] = x1
116 bundle[NX_V7_TORSO_Y1] = y1
117 return 0
118}
119
120// Set the keystone eye-width measurement.
121func nx_v7_bundle_set_eye(bundle: *i64, eye_width_px: i64, iris_radius_px: i64) -> i64 {
122 bundle[NX_V7_EYE_WIDTH_PX] = eye_width_px
123 bundle[NX_V7_IRIS_RADIUS_PX] = iris_radius_px
124 return 0
125}
126
127// Get face bbox into a 4-i64 array (for passing to functions that expect packed bbox).
128func nx_v7_bundle_get_face_bbox(bundle: *i64, out: *i64) -> i64 {
129 out[0] = bundle[NX_V7_FACE_X0]
130 out[1] = bundle[NX_V7_FACE_Y0]
131 out[2] = bundle[NX_V7_FACE_X1]
132 out[3] = bundle[NX_V7_FACE_Y1]
133 return 0
134}
135
136func nx_v7_bundle_get_torso_bbox(bundle: *i64, out: *i64) -> i64 {
137 out[0] = bundle[NX_V7_TORSO_X0]
138 out[1] = bundle[NX_V7_TORSO_Y0]
139 out[2] = bundle[NX_V7_TORSO_X1]
140 out[3] = bundle[NX_V7_TORSO_Y1]
141 return 0
142}
143
144// Build a face+torso bbox pack for nx_pose_classify (8 entries).
145func nx_v7_bundle_pose_pack(bundle: *i64, out: *i64) -> i64 {
146 out[0] = bundle[NX_V7_FACE_X0]
147 out[1] = bundle[NX_V7_FACE_Y0]
148 out[2] = bundle[NX_V7_FACE_X1]
149 out[3] = bundle[NX_V7_FACE_Y1]
150 out[4] = bundle[NX_V7_TORSO_X0]
151 out[5] = bundle[NX_V7_TORSO_Y0]
152 out[6] = bundle[NX_V7_TORSO_X1]
153 out[7] = bundle[NX_V7_TORSO_Y1]
154 return 0
155}
156
157// Build face/cheek/torso bbox pack for nx_response_signal (12 entries).
158func nx_v7_bundle_response_pack(bundle: *i64, out: *i64) -> i64 {
159 out[0] = bundle[NX_V7_FACE_X0]
160 out[1] = bundle[NX_V7_FACE_Y0]
161 out[2] = bundle[NX_V7_FACE_X1]
162 out[3] = bundle[NX_V7_FACE_Y1]
163 // Average of left + right cheek into a single rep cheek bbox.
164 let l_x0: i64 = bundle[NX_V7_CHEEK_L_X0]
165 let l_y0: i64 = bundle[NX_V7_CHEEK_L_Y0]
166 let r_x1: i64 = bundle[NX_V7_CHEEK_R_X1]
167 let r_y1: i64 = bundle[NX_V7_CHEEK_R_Y1]
168 out[4] = l_x0
169 out[5] = l_y0
170 out[6] = r_x1
171 out[7] = r_y1
172 out[8] = bundle[NX_V7_TORSO_X0]
173 out[9] = bundle[NX_V7_TORSO_Y0]
174 out[10] = bundle[NX_V7_TORSO_X1]
175 out[11] = bundle[NX_V7_TORSO_Y1]
176 return 0
177}