zorya-classifier 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/NOTICE.md +2 -0
  2. package/README.md +18 -6
  3. package/dist/app/cli-arguments.d.ts +40 -0
  4. package/dist/app/cli-arguments.js +67 -0
  5. package/dist/app/create-classifier.d.ts +19 -0
  6. package/dist/app/create-classifier.js +226 -14
  7. package/dist/app/extraction-files.d.ts +9 -0
  8. package/dist/app/extraction-files.js +28 -0
  9. package/dist/cli.js +58 -14
  10. package/dist/entities/boundary-view.d.ts +29 -0
  11. package/dist/entities/boundary-view.js +1 -0
  12. package/dist/entities/contracts.d.ts +77 -1
  13. package/dist/entities/contracts.js +7 -0
  14. package/dist/entities/cutout-raster.d.ts +7 -0
  15. package/dist/entities/cutout-raster.js +1 -0
  16. package/dist/entities/object-proposals.d.ts +53 -0
  17. package/dist/entities/object-proposals.js +8 -0
  18. package/dist/entities/representation.d.ts +225 -0
  19. package/dist/entities/representation.js +33 -0
  20. package/dist/entities/segmentation-metadata.d.ts +11 -0
  21. package/dist/entities/segmentation-metadata.js +1 -0
  22. package/dist/entities/segmentation-verification.d.ts +30 -0
  23. package/dist/entities/segmentation-verification.js +1 -0
  24. package/dist/entities/segmentation.d.ts +159 -0
  25. package/dist/entities/segmentation.js +5 -0
  26. package/dist/entities/whole-object.d.ts +128 -0
  27. package/dist/entities/whole-object.js +7 -0
  28. package/dist/features/choice.d.ts +1 -1
  29. package/dist/features/choice.js +2 -2
  30. package/dist/features/segmentation/box-check.d.ts +10 -0
  31. package/dist/features/segmentation/box-check.js +299 -0
  32. package/dist/features/segmentation/mask.d.ts +6 -0
  33. package/dist/features/segmentation/mask.js +89 -0
  34. package/dist/features/segmentation/packed-mask.d.ts +5 -0
  35. package/dist/features/segmentation/packed-mask.js +53 -0
  36. package/dist/index.d.ts +6 -1
  37. package/dist/infrastructure/boundary-view.d.ts +2 -0
  38. package/dist/infrastructure/boundary-view.js +263 -0
  39. package/dist/infrastructure/openrouter-common.d.ts +8 -8
  40. package/dist/infrastructure/openrouter-vision.d.ts +3 -0
  41. package/dist/infrastructure/openrouter-vision.js +5 -0
  42. package/dist/infrastructure/raster.d.ts +10 -1
  43. package/dist/infrastructure/raster.js +99 -4
  44. package/dist/infrastructure/segmentation/box-presentation.d.ts +2 -0
  45. package/dist/infrastructure/segmentation/box-presentation.js +136 -0
  46. package/dist/infrastructure/segmentation/cutout-raster.d.ts +3 -0
  47. package/dist/infrastructure/segmentation/cutout-raster.js +79 -0
  48. package/dist/infrastructure/segmentation/grabcut/index.d.ts +13 -0
  49. package/dist/infrastructure/segmentation/grabcut/index.js +118 -0
  50. package/dist/infrastructure/segmentation/grabcut/worker-inference.d.ts +47 -0
  51. package/dist/infrastructure/segmentation/grabcut/worker-inference.js +260 -0
  52. package/dist/infrastructure/segmentation/index.d.ts +2 -0
  53. package/dist/infrastructure/segmentation/index.js +2 -0
  54. package/dist/infrastructure/segmentation/mobile-sam/index.d.ts +58 -0
  55. package/dist/infrastructure/segmentation/mobile-sam/index.js +472 -0
  56. package/dist/infrastructure/segmentation/mobile-sam/worker-inference.d.ts +149 -0
  57. package/dist/infrastructure/segmentation/mobile-sam/worker-inference.js +845 -0
  58. package/dist/infrastructure/segmentation/native-child.d.ts +23 -0
  59. package/dist/infrastructure/segmentation/native-child.js +297 -0
  60. package/dist/infrastructure/segmentation/native-protocol.d.ts +923 -0
  61. package/dist/infrastructure/segmentation/native-protocol.js +242 -0
  62. package/dist/infrastructure/segmentation/native-worker.d.ts +1 -0
  63. package/dist/infrastructure/segmentation/native-worker.js +93 -0
  64. package/dist/infrastructure/segmentation/probe-backend.d.ts +1 -0
  65. package/dist/infrastructure/segmentation/probe-backend.js +31 -0
  66. package/dist/infrastructure/segmentation/proposal-presentation.d.ts +3 -0
  67. package/dist/infrastructure/segmentation/proposal-presentation.js +371 -0
  68. package/dist/infrastructure/segmentation/verify-asset.d.ts +4 -0
  69. package/dist/infrastructure/segmentation/verify-asset.js +32 -0
  70. package/dist/infrastructure/text-representation.d.ts +23 -0
  71. package/dist/infrastructure/text-representation.js +226 -0
  72. package/dist/infrastructure/vision-chat.d.ts +1 -1
  73. package/dist/infrastructure/vision-chat.js +13 -4
  74. package/dist/openai-compatible.d.ts +3 -0
  75. package/dist/openai-compatible.js +4 -0
  76. package/dist/openrouter.d.ts +2 -2
  77. package/dist/openrouter.js +1 -1
  78. package/dist/processes/boundary-state.d.ts +12 -0
  79. package/dist/processes/boundary-state.js +196 -0
  80. package/dist/processes/classify.d.ts +2 -1
  81. package/dist/processes/classify.js +21 -3
  82. package/dist/processes/extract-from-region.d.ts +19 -0
  83. package/dist/processes/extract-from-region.js +415 -0
  84. package/dist/processes/extract.d.ts +25 -0
  85. package/dist/processes/extract.js +223 -0
  86. package/dist/processes/locate.d.ts +2 -1
  87. package/dist/processes/locate.js +84 -11
  88. package/dist/processes/proposal-location.d.ts +19 -0
  89. package/dist/processes/proposal-location.js +396 -0
  90. package/dist/processes/whole-object.d.ts +7 -0
  91. package/dist/processes/whole-object.js +272 -0
  92. package/dist/segmentation.d.ts +10 -0
  93. package/dist/segmentation.js +4 -0
  94. package/dist/shared/input-budget.d.ts +7 -0
  95. package/dist/shared/input-budget.js +21 -0
  96. package/docs/0.2.0-plan.md +190 -0
  97. package/docs/README.ru.md +18 -5
  98. package/docs/acceptance.md +116 -3
  99. package/docs/api.md +8 -4
  100. package/docs/architecture.md +20 -7
  101. package/docs/benchmarks.md +10 -0
  102. package/docs/categorical-presence-port.md +26 -0
  103. package/docs/evidence/v02/baseline.json +1043 -0
  104. package/docs/evidence/v02/boundary-variants.md +17 -0
  105. package/docs/evidence/v02/box-confirmation-dev40/README.md +15 -0
  106. package/docs/evidence/v02/box-confirmation-dev40/component-refinement.json +246 -0
  107. package/docs/evidence/v02/box-confirmation-dev40/evaluation.json +1663 -0
  108. package/docs/evidence/v02/box-confirmation-dev40/provenance.json +130 -0
  109. package/docs/evidence/v02/box-confirmation-dev40/report.json +127 -0
  110. package/docs/evidence/v02/box-confirmation-dev40-freeze-20261020-v1.json +230 -0
  111. package/docs/evidence/v02/box-confirmation-method-selection-20261020-v1.json +85 -0
  112. package/docs/evidence/v02/box-heldout-cancelled-before-dispatch-20261021-v1.json +32 -0
  113. package/docs/evidence/v02/box-heldout-combined-seal-20261021-v1.json +89 -0
  114. package/docs/evidence/v02/box-heldout-evaluator-truth-seal-20261021-v1.json +61 -0
  115. package/docs/evidence/v02/box-heldout-exclusion-audit-20261020-v1.json +81 -0
  116. package/docs/evidence/v02/box-heldout-map-seal-20261021-v1.json +48 -0
  117. package/docs/evidence/v02/box-heldout-photo-seal-20261020-v1.json +62 -0
  118. package/docs/evidence/v02/box-heldout-run-freeze-20261021-v1.json +61 -0
  119. package/docs/evidence/v02/box-heldout-source-review-20261020-v1.json +134 -0
  120. package/docs/evidence/v02/box-heldout-ui-seal-20261020-v1.json +44 -0
  121. package/docs/evidence/v02/calculator-proof-root-review-20261020-v1.json +63 -0
  122. package/docs/evidence/v02/categorical-dev40-freeze.json +94 -0
  123. package/docs/evidence/v02/categorical-dev40-preserve.json +460 -0
  124. package/docs/evidence/v02/categorical-dev40-target-only.json +460 -0
  125. package/docs/evidence/v02/categorical-heldout-admission-20261020-v3.json +215 -0
  126. package/docs/evidence/v02/categorical-heldout-admission-20261020-v4.json +270 -0
  127. package/docs/evidence/v02/categorical-heldout-dispatch-authorization-20261020-v4.json +79 -0
  128. package/docs/evidence/v02/categorical-heldout-predispatch-20261020-v3.json +57 -0
  129. package/docs/evidence/v02/categorical-heldout-producer-source-map-v4.json +262 -0
  130. package/docs/evidence/v02/categorical-heldout-producer-source-map.json +263 -0
  131. package/docs/evidence/v02/categorical-heldout-run-freeze-20261020-v3.json +35 -0
  132. package/docs/evidence/v02/categorical-heldout-run-freeze-20261020-v4.json +35 -0
  133. package/docs/evidence/v02/categorical-heldout-v4/README.md +35 -0
  134. package/docs/evidence/v02/categorical-heldout-v4/candidate-evaluation.json +2812 -0
  135. package/docs/evidence/v02/categorical-heldout-v4/candidate-physical-receipts.json +15261 -0
  136. package/docs/evidence/v02/categorical-heldout-v4/candidate-provenance.json +131 -0
  137. package/docs/evidence/v02/categorical-heldout-v4/control-evaluation.json +855 -0
  138. package/docs/evidence/v02/categorical-heldout-v4/control-physical-receipts.json +4402 -0
  139. package/docs/evidence/v02/categorical-heldout-v4/control-provenance.json +31 -0
  140. package/docs/evidence/v02/categorical-heldout-v4/mask-normalized-exploratory.json +682 -0
  141. package/docs/evidence/v02/categorical-heldout-v4/paired-qualification.json +21 -0
  142. package/docs/evidence/v02/categorical-heldout-v4/report.json +258 -0
  143. package/docs/evidence/v02/categorical-presence-dev6.json +144 -0
  144. package/docs/evidence/v02/categorical-presence-dev6.md +18 -0
  145. package/docs/evidence/v02/categorical-vision-method-selection.json +90 -0
  146. package/docs/evidence/v02/checked-region-component-v1/README.md +7 -0
  147. package/docs/evidence/v02/checked-region-component-v1/evidence.json +311 -0
  148. package/docs/evidence/v02/checked-region-resource-interrupted-2b0d09f.json +102 -0
  149. package/docs/evidence/v02/checked-region-segmentation-resource-4df544c-receipt.json +167 -0
  150. package/docs/evidence/v02/checked-region-segmentation-resource-4df544c-root-review.json +58 -0
  151. package/docs/evidence/v02/checked-region-segmentation-resource-987ac32-receipt.json +158 -0
  152. package/docs/evidence/v02/ci-012b935.json +17 -0
  153. package/docs/evidence/v02/ci-0c365cb.json +372 -0
  154. package/docs/evidence/v02/ci-185bde8.json +32 -0
  155. package/docs/evidence/v02/ci-24f849f.json +95 -0
  156. package/docs/evidence/v02/ci-25c19cd.json +375 -0
  157. package/docs/evidence/v02/ci-2922caf.json +375 -0
  158. package/docs/evidence/v02/ci-29357d7.json +29 -0
  159. package/docs/evidence/v02/ci-32aa90d.json +24 -0
  160. package/docs/evidence/v02/ci-35e3064.json +376 -0
  161. package/docs/evidence/v02/ci-4331b1b.json +384 -0
  162. package/docs/evidence/v02/ci-43b7426.json +376 -0
  163. package/docs/evidence/v02/ci-450439c.json +373 -0
  164. package/docs/evidence/v02/ci-46283fe.json +29 -0
  165. package/docs/evidence/v02/ci-4c9c09f.json +34 -0
  166. package/docs/evidence/v02/ci-5579646.json +27 -0
  167. package/docs/evidence/v02/ci-6f9cc15.json +127 -0
  168. package/docs/evidence/v02/ci-7c1051f.json +27 -0
  169. package/docs/evidence/v02/ci-9837888.json +34 -0
  170. package/docs/evidence/v02/ci-987ac32.json +29 -0
  171. package/docs/evidence/v02/ci-9d00fe5.json +25 -0
  172. package/docs/evidence/v02/ci-9f85acc.json +127 -0
  173. package/docs/evidence/v02/ci-be275a6.json +201 -0
  174. package/docs/evidence/v02/ci-c107ddf.json +372 -0
  175. package/docs/evidence/v02/ci-c35f67d.json +127 -0
  176. package/docs/evidence/v02/ci-c5eddd8.json +32 -0
  177. package/docs/evidence/v02/ci-d2042e0.json +372 -0
  178. package/docs/evidence/v02/ci-d684259.json +375 -0
  179. package/docs/evidence/v02/ci-e0c190b.json +127 -0
  180. package/docs/evidence/v02/ci-e551253.json +372 -0
  181. package/docs/evidence/v02/ci-f9d4633.json +29 -0
  182. package/docs/evidence/v02/dev1-proposal-evaluation.md +13 -0
  183. package/docs/evidence/v02/dev2-mobile-sam-proposal-oracle.md +21 -0
  184. package/docs/evidence/v02/dev2-proposal-evaluation.md +21 -0
  185. package/docs/evidence/v02/fresh-development.md +16 -0
  186. package/docs/evidence/v02/fresh-native-numeric/artifact-hashes.json +9 -0
  187. package/docs/evidence/v02/fresh-native-numeric/evaluation-root-v1.json +568 -0
  188. package/docs/evidence/v02/fresh-native-numeric/run-manifest.json +342 -0
  189. package/docs/evidence/v02/fresh-native-numeric/summary.json +5654 -0
  190. package/docs/evidence/v02/fresh-native-outline-axis/artifact-hashes.json +9 -0
  191. package/docs/evidence/v02/fresh-native-outline-axis/evaluation-root-v1.json +568 -0
  192. package/docs/evidence/v02/fresh-native-outline-axis/run-manifest.json +378 -0
  193. package/docs/evidence/v02/fresh-native-outline-axis/summary.json +5605 -0
  194. package/docs/evidence/v02/fresh-text/README.md +23 -0
  195. package/docs/evidence/v02/fresh-text/ascii-contours-v1/classify-followup-run-manifest.json +405 -0
  196. package/docs/evidence/v02/fresh-text/ascii-contours-v1/classify-followup-summary.json +1646 -0
  197. package/docs/evidence/v02/fresh-text/ascii-contours-v1/evaluation.json +568 -0
  198. package/docs/evidence/v02/fresh-text/ascii-contours-v1/original-run-manifest.json +404 -0
  199. package/docs/evidence/v02/fresh-text/ascii-contours-v1/original-summary.json +4416 -0
  200. package/docs/evidence/v02/fresh-text/ascii-luma-v1/classify-followup-run-manifest.json +405 -0
  201. package/docs/evidence/v02/fresh-text/ascii-luma-v1/classify-followup-summary.json +1646 -0
  202. package/docs/evidence/v02/fresh-text/ascii-luma-v1/evaluation.json +568 -0
  203. package/docs/evidence/v02/fresh-text/ascii-luma-v1/original-run-manifest.json +404 -0
  204. package/docs/evidence/v02/fresh-text/ascii-luma-v1/original-summary.json +4647 -0
  205. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/classify-followup-run-manifest.json +405 -0
  206. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/classify-followup-summary.json +846 -0
  207. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/evaluation.json +568 -0
  208. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/original-run-manifest.json +404 -0
  209. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/original-summary.json +1789 -0
  210. package/docs/evidence/v02/fresh-text/no-image-control/evaluation.json +568 -0
  211. package/docs/evidence/v02/fresh-text/no-image-control/original-run-manifest.json +404 -0
  212. package/docs/evidence/v02/fresh-text/no-image-control/original-summary.json +3953 -0
  213. package/docs/evidence/v02/fresh-text/palette-grid-v1/classify-followup-run-manifest.json +405 -0
  214. package/docs/evidence/v02/fresh-text/palette-grid-v1/classify-followup-summary.json +1646 -0
  215. package/docs/evidence/v02/fresh-text/palette-grid-v1/evaluation.json +568 -0
  216. package/docs/evidence/v02/fresh-text/palette-grid-v1/original-run-manifest.json +404 -0
  217. package/docs/evidence/v02/fresh-text/palette-grid-v1/original-summary.json +3974 -0
  218. package/docs/evidence/v02/fresh-text/pixel-rle-v1/classify-followup-run-manifest.json +405 -0
  219. package/docs/evidence/v02/fresh-text/pixel-rle-v1/classify-followup-summary.json +1646 -0
  220. package/docs/evidence/v02/fresh-text/pixel-rle-v1/evaluation.json +568 -0
  221. package/docs/evidence/v02/fresh-text/pixel-rle-v1/original-run-manifest.json +404 -0
  222. package/docs/evidence/v02/fresh-text/pixel-rle-v1/original-summary.json +4945 -0
  223. package/docs/evidence/v02/fresh-text/report.json +284 -0
  224. package/docs/evidence/v02/fresh-text/svg-contours-v1/classify-followup-run-manifest.json +405 -0
  225. package/docs/evidence/v02/fresh-text/svg-contours-v1/classify-followup-summary.json +846 -0
  226. package/docs/evidence/v02/fresh-text/svg-contours-v1/evaluation.json +568 -0
  227. package/docs/evidence/v02/fresh-text/svg-contours-v1/original-run-manifest.json +404 -0
  228. package/docs/evidence/v02/fresh-text/svg-contours-v1/original-summary.json +2189 -0
  229. package/docs/evidence/v02/heldout-evaluation-20261020.md +37 -0
  230. package/docs/evidence/v02/heldout-input-derivation.md +18 -0
  231. package/docs/evidence/v02/integration-0c365cb.json +90 -0
  232. package/docs/evidence/v02/integration-25c19cd.json +52 -0
  233. package/docs/evidence/v02/integration-35e3064.json +41 -0
  234. package/docs/evidence/v02/integration-4331b1b.json +42 -0
  235. package/docs/evidence/v02/integration-4c9c09f.json +46 -0
  236. package/docs/evidence/v02/integration-8010aad.json +48 -0
  237. package/docs/evidence/v02/integration-c1aa640.json +41 -0
  238. package/docs/evidence/v02/integration-eea1790.json +46 -0
  239. package/docs/evidence/v02/integration-fa82e65.json +42 -0
  240. package/docs/evidence/v02/jpeg-transport-offline.json +268 -0
  241. package/docs/evidence/v02/jpeg-transport-offline.md +7 -0
  242. package/docs/evidence/v02/local-archive-cleanup.json +59 -0
  243. package/docs/evidence/v02/native-base64-after.json +30 -0
  244. package/docs/evidence/v02/native-base64-before.json +32 -0
  245. package/docs/evidence/v02/native-checked-region-windows-46283fe.json +248 -0
  246. package/docs/evidence/v02/native-checked-region-windows-987ac32.json +141 -0
  247. package/docs/evidence/v02/native-grabcut-windows-4c494a3-run2.json +148 -0
  248. package/docs/evidence/v02/native-grabcut-windows-4c494a3-run3.json +148 -0
  249. package/docs/evidence/v02/native-grabcut-windows-4c494a3.json +56 -0
  250. package/docs/evidence/v02/native-proposal-windows-0c365cb.json +148 -0
  251. package/docs/evidence/v02/native-proposal-windows-450439c.json +156 -0
  252. package/docs/evidence/v02/native-proposal-windows-4c9c09f-retry1.json +147 -0
  253. package/docs/evidence/v02/native-proposal-windows-4c9c09f.json +52 -0
  254. package/docs/evidence/v02/native-region-windows-efc9318.json +163 -0
  255. package/docs/evidence/v02/native-windows-eea1790-baseline.json +198 -0
  256. package/docs/evidence/v02/native-windows-eea1790.json +228 -0
  257. package/docs/evidence/v02/ordinary-luna-axis/run-manifest.json +99 -0
  258. package/docs/evidence/v02/ordinary-luna-axis/summary.json +811 -0
  259. package/docs/evidence/v02/owned-temp-cleanup-20261020-v1.json +28 -0
  260. package/docs/evidence/v02/presentation-paired-20261020.json +1438 -0
  261. package/docs/evidence/v02/proposal-resource-soak-261dc23.json +201 -0
  262. package/docs/evidence/v02/proposal-resource-soak-261dc23.md +15 -0
  263. package/docs/evidence/v02/proposal-resource-soak-450439c-receipt.md +13 -0
  264. package/docs/evidence/v02/reconstructed-c03-box.json +41 -0
  265. package/docs/evidence/v02/region-seeded-dev-v1/README.md +17 -0
  266. package/docs/evidence/v02/region-seeded-dev-v1/evaluation.json +260 -0
  267. package/docs/evidence/v02/region-seeded-dev-v2/README.md +15 -0
  268. package/docs/evidence/v02/region-seeded-dev-v2/evaluation.json +232 -0
  269. package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/README.md +9 -0
  270. package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/control-identity-failure.json +22 -0
  271. package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/evaluation.json +160 -0
  272. package/docs/evidence/v02/region-seeded-dev-v3-control-r2/README.md +9 -0
  273. package/docs/evidence/v02/region-seeded-dev-v3-control-r2/attempt-accounting.json +55 -0
  274. package/docs/evidence/v02/region-seeded-dev-v3-control-r2/evaluation.json +136 -0
  275. package/docs/evidence/v02/region-seeded-development-control-r2-freeze-20261021.json +132 -0
  276. package/docs/evidence/v02/region-seeded-development-freeze-20261021-v1.json +167 -0
  277. package/docs/evidence/v02/region-seeded-development-freeze-20261021-v2.json +186 -0
  278. package/docs/evidence/v02/region-seeded-development-freeze-20261021-v3.json +205 -0
  279. package/docs/evidence/v02/region-seeded-heldout-cancelled-before-dispatch-20261021-v2.json +20 -0
  280. package/docs/evidence/v02/region-seeded-heldout-dispatch-authorization-20261021-v3.json +47 -0
  281. package/docs/evidence/v02/region-seeded-heldout-readiness-audit-20261021-v3.json +125 -0
  282. package/docs/evidence/v02/region-seeded-heldout-run-freeze-20261021-v2.json +234 -0
  283. package/docs/evidence/v02/region-seeded-heldout-run-freeze-20261021-v3.json +357 -0
  284. package/docs/evidence/v02/region-seeded-heldout-v3/README.md +19 -0
  285. package/docs/evidence/v02/region-seeded-heldout-v3/evaluation-summary.json +445 -0
  286. package/docs/evidence/v02/region-seeded-method-selection-20261021-v2.json +66 -0
  287. package/docs/evidence/v02/region-seeded-method-selection-20261021-v3.json +120 -0
  288. package/docs/evidence/v02/region-segmentation-resource-0ba4c87-receipt.json +156 -0
  289. package/docs/evidence/v02/resource-soak-linux-8010aad.json +125 -0
  290. package/docs/evidence/v02/screen-v2-terminal-evaluation.md +22 -0
  291. package/docs/evidence/v02/seed-outline/run-manifest.json +59 -0
  292. package/docs/evidence/v02/seed-outline/summary.json +487 -0
  293. package/docs/evidence/v02/seed-unbounded/run-manifest.json +80 -0
  294. package/docs/evidence/v02/seed-unbounded/summary.json +730 -0
  295. package/docs/evidence/v02/segmentation/README.md +21 -0
  296. package/docs/evidence/v02/segmentation/component-comparison-summary.json +240 -0
  297. package/docs/evidence/v02/segmentation/provenance/MOBILE-SAM-LICENSE.txt +201 -0
  298. package/docs/evidence/v02/segmentation/provenance/OPENCV-LICENSE.txt +202 -0
  299. package/docs/evidence/v02/segmentation/provenance/mobile-sam-download-receipt.json +29 -0
  300. package/docs/evidence/v02/segmentation/provenance/mobile-sam-graph-audit.json +214 -0
  301. package/docs/evidence/v02/segmentation/provenance/mobile-sam-model-metadata.json +166 -0
  302. package/docs/evidence/v02/split-choice-noul-dev6.json +72 -0
  303. package/docs/evidence/v02/split-choice-noul-dev6.md +11 -0
  304. package/docs/evidence/v02/supported-vision-screen-20261020.md +65 -0
  305. package/docs/evidence/v02/wesnoth-1.16.11-minimap-projection-source-audit.md +56 -0
  306. package/docs/evidence/v02/wesnoth-proof-root-review-20261020-v1.json +76 -0
  307. package/docs/operations.md +6 -0
  308. package/docs/plan.md +2 -0
  309. package/docs/publishing.md +10 -1
  310. package/docs/research/text-transport-audit.md +66 -0
  311. package/docs/v02-usage.md +162 -0
  312. package/docs/vision-results.md +29 -2
  313. package/package.json +30 -5
@@ -0,0 +1,23 @@
1
+ interface NativeChildPoolOptions<T> {
2
+ workerUrl: URL;
3
+ maxActive?: number;
4
+ maxWaiting?: number;
5
+ jobTimeoutMs?: number;
6
+ abortGraceMs?: number;
7
+ encode(job: {
8
+ id: string;
9
+ payload: T;
10
+ }): Uint8Array;
11
+ decode(value: unknown, id: string): unknown;
12
+ }
13
+ /** Owns every spawned child until its exit event confirms physical settlement. */
14
+ export declare class NativeChildPool<T> {
15
+ #private;
16
+ constructor(options: NativeChildPoolOptions<T>);
17
+ run(payload: T, signal: AbortSignal): Promise<unknown>;
18
+ /** Admission is reserved before buildPayload can snapshot or serialize caller-owned data. */
19
+ runLazy(signal: AbortSignal, buildPayload: () => T): Promise<unknown>;
20
+ settle(): Promise<void>;
21
+ dispose(): Promise<void>;
22
+ }
23
+ export {};
@@ -0,0 +1,297 @@
1
+ import { fork } from 'node:child_process';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { ClassifierError } from '../../entities/errors.js';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { channel } from 'node:diagnostics_channel';
6
+ const resourceChannel = channel('zorya.segmentation.child-resource');
7
+ /** Owns every spawned child until its exit event confirms physical settlement. */
8
+ export class NativeChildPool {
9
+ #workerUrl;
10
+ #maxActive;
11
+ #maxWaiting;
12
+ #jobTimeoutMs;
13
+ #abortGraceMs;
14
+ #encode;
15
+ #decode;
16
+ #queue = [];
17
+ #physical = new Set();
18
+ #lifetime = new AbortController();
19
+ #active = 0;
20
+ #closing;
21
+ #poisoned;
22
+ constructor(options) {
23
+ this.#workerUrl = options.workerUrl;
24
+ this.#maxActive = options.maxActive ?? 1;
25
+ this.#maxWaiting = options.maxWaiting ?? 2;
26
+ this.#jobTimeoutMs = options.jobTimeoutMs ?? 10_000;
27
+ this.#abortGraceMs = options.abortGraceMs ?? 250;
28
+ this.#encode = options.encode;
29
+ this.#decode = options.decode;
30
+ }
31
+ run(payload, signal) {
32
+ return this.runLazy(signal, () => payload);
33
+ }
34
+ /** Admission is reserved before buildPayload can snapshot or serialize caller-owned data. */
35
+ runLazy(signal, buildPayload) {
36
+ if (signal.aborted)
37
+ return Promise.reject(cancelledError(signal.reason));
38
+ if (this.#closing)
39
+ return Promise.reject(new ClassifierError('DISPOSED', 'Native child pool is disposed'));
40
+ if (this.#poisoned)
41
+ return Promise.reject(nativeFailure(this.#poisoned));
42
+ if (this.#queue.length >= this.#maxWaiting && this.#active >= this.#maxActive)
43
+ return Promise.reject(new ClassifierError('CAPACITY', 'Native child queue is full'));
44
+ let resolve;
45
+ let reject;
46
+ const promise = new Promise((yes, no) => {
47
+ resolve = yes;
48
+ reject = no;
49
+ });
50
+ const job = {
51
+ id: randomUUID(),
52
+ payload: undefined,
53
+ buildPayload,
54
+ payloadReady: false,
55
+ signal: AbortSignal.any([signal, this.#lifetime.signal]),
56
+ resolve,
57
+ reject,
58
+ promise,
59
+ started: false,
60
+ done: false,
61
+ };
62
+ job.abortListener = () => this.#abort(job, cancelledError(job.signal.reason));
63
+ job.signal.addEventListener('abort', job.abortListener, { once: true });
64
+ this.#queue.push(job);
65
+ try {
66
+ job.payload = job.buildPayload();
67
+ job.payloadReady = true;
68
+ }
69
+ catch (error) {
70
+ this.#finishQueued(job, error instanceof ClassifierError
71
+ ? error
72
+ : new ClassifierError('INVALID_INPUT', 'Unable to snapshot native task input'));
73
+ this.#pump();
74
+ return promise;
75
+ }
76
+ if (job.signal.aborted)
77
+ job.abortListener();
78
+ else
79
+ this.#pump();
80
+ return promise;
81
+ }
82
+ #pump() {
83
+ while (!this.#closing && !this.#poisoned && this.#active < this.#maxActive) {
84
+ const job = this.#queue.shift();
85
+ if (!job)
86
+ return;
87
+ if (job.done || job.signal.aborted) {
88
+ this.#finishQueued(job, job.signal.reason ?? new Error('Native task cancelled'));
89
+ continue;
90
+ }
91
+ this.#start(job);
92
+ }
93
+ }
94
+ #start(job) {
95
+ if (!job.payloadReady) {
96
+ this.#finishQueued(job, new ClassifierError('INVALID_INPUT', 'Native task payload was not prepared'));
97
+ return;
98
+ }
99
+ job.started = true;
100
+ this.#active++;
101
+ this.#physical.add(job);
102
+ const workerPath = fileURLToPath(this.#workerUrl);
103
+ let child;
104
+ try {
105
+ child = fork(workerPath, [], {
106
+ execArgv: workerPath.endsWith('.ts') ? ['--import', 'tsx'] : [],
107
+ stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
108
+ });
109
+ }
110
+ catch (error) {
111
+ job.failure = nativeFailure(error);
112
+ this.#poison(job.failure);
113
+ this.#endPhysical(job);
114
+ return;
115
+ }
116
+ job.child = child;
117
+ if (child.pid !== undefined)
118
+ resourceChannel.publish({ type: 'start', jobId: job.id, pid: child.pid });
119
+ let output = '';
120
+ let outputBytes = 0;
121
+ child.stdout?.setEncoding('utf8');
122
+ child.stdout?.on('data', (chunk) => {
123
+ outputBytes += Buffer.byteLength(chunk);
124
+ if (outputBytes > 24 * 1024 * 1024) {
125
+ job.failure = new ClassifierError('RESOURCE_LIMIT', 'Native child output exceeded its limit');
126
+ child.kill();
127
+ return;
128
+ }
129
+ output += chunk;
130
+ });
131
+ child.stderr?.resume();
132
+ child.stdin?.on('error', (error) => {
133
+ job.failure ??= nativeFailure(error);
134
+ });
135
+ let telemetryConfigured = false;
136
+ child.on('message', (message) => {
137
+ if (typeof message !== 'object' || message === null || !('type' in message)) {
138
+ job.failure ??= new ClassifierError('INVALID_RESPONSE', 'Native child sent an invalid control message');
139
+ child.kill();
140
+ return;
141
+ }
142
+ if (message.type === 'ready' && !telemetryConfigured) {
143
+ telemetryConfigured = true;
144
+ child.send({ type: 'telemetry', enabled: resourceChannel.hasSubscribers });
145
+ return;
146
+ }
147
+ if (message.type === 'memory' && 'memory' in message) {
148
+ const memory = message.memory;
149
+ if (typeof memory === 'object' && memory !== null && isMemoryUsage(memory))
150
+ resourceChannel.publish({ type: 'memory', jobId: job.id, pid: child.pid, ...memory });
151
+ return;
152
+ }
153
+ job.failure ??= new ClassifierError('INVALID_RESPONSE', 'Native child sent an invalid control message');
154
+ child.kill();
155
+ });
156
+ child.on('error', (error) => {
157
+ job.failure ??= nativeFailure(error);
158
+ });
159
+ child.on('close', (code, signal) => {
160
+ if (!job.failure && code !== 0)
161
+ job.failure = new ClassifierError('PROVIDER', `Native child exited with code ${String(code)} (${String(signal)})`);
162
+ if (!job.failure) {
163
+ try {
164
+ const raw = JSON.parse(output);
165
+ job.reply = this.#decode(raw, job.id);
166
+ }
167
+ catch (error) {
168
+ job.failure =
169
+ error instanceof ClassifierError
170
+ ? error
171
+ : new ClassifierError('INVALID_RESPONSE', 'Native child returned an invalid reply');
172
+ }
173
+ }
174
+ child.stdin?.removeAllListeners();
175
+ child.stdout?.removeAllListeners();
176
+ child.stderr?.removeAllListeners();
177
+ child.stdin?.destroy();
178
+ child.stdout?.destroy();
179
+ child.stderr?.destroy();
180
+ this.#endPhysical(job);
181
+ });
182
+ job.timer = setTimeout(() => this.#abort(job, new ClassifierError('TIMEOUT', 'Native segmentation exceeded its job limit')), this.#jobTimeoutMs);
183
+ try {
184
+ const bytes = this.#encode({ id: job.id, payload: job.payload });
185
+ if (bytes.byteLength > 96 * 1024 * 1024)
186
+ throw new ClassifierError('RESOURCE_LIMIT', 'Native child input exceeded its size limit');
187
+ child.stdin?.end(bytes);
188
+ }
189
+ catch (error) {
190
+ job.failure = nativeFailure(error);
191
+ child.kill();
192
+ }
193
+ if (job.signal.aborted)
194
+ this.#abort(job, cancelledError(job.signal.reason));
195
+ }
196
+ #abort(job, reason) {
197
+ if (job.done)
198
+ return;
199
+ if (!job.started) {
200
+ const queued = this.#queue.indexOf(job);
201
+ if (queued >= 0)
202
+ this.#queue.splice(queued, 1);
203
+ this.#finishQueued(job, reason);
204
+ return;
205
+ }
206
+ job.failure ??= reason;
207
+ if (job.abortTimer)
208
+ return;
209
+ job.abortTimer = setTimeout(() => {
210
+ if (!job.child || !this.#physical.has(job))
211
+ return;
212
+ job.child.kill('SIGKILL');
213
+ job.exitTimer = setTimeout(() => {
214
+ if (this.#physical.has(job))
215
+ this.#poison(reason);
216
+ }, 2000);
217
+ }, this.#abortGraceMs);
218
+ }
219
+ #poison(reason) {
220
+ this.#poisoned ??= nativeFailure(reason);
221
+ while (this.#queue.length) {
222
+ const job = this.#queue.shift();
223
+ if (job)
224
+ this.#finishQueued(job, this.#poisoned);
225
+ }
226
+ }
227
+ #finishQueued(job, error) {
228
+ if (job.done)
229
+ return;
230
+ job.done = true;
231
+ const queued = this.#queue.indexOf(job);
232
+ if (queued >= 0)
233
+ this.#queue.splice(queued, 1);
234
+ job.signal.removeEventListener('abort', job.abortListener);
235
+ job.reject(error);
236
+ }
237
+ #endPhysical(job) {
238
+ if (!this.#physical.delete(job))
239
+ return;
240
+ if (job.child?.pid !== undefined)
241
+ resourceChannel.publish({ type: 'close', jobId: job.id, pid: job.child.pid });
242
+ this.#active--;
243
+ clearTimeout(job.timer);
244
+ clearTimeout(job.abortTimer);
245
+ clearTimeout(job.exitTimer);
246
+ job.signal.removeEventListener('abort', job.abortListener);
247
+ if (!job.done) {
248
+ job.done = true;
249
+ if (job.failure !== undefined)
250
+ job.reject(job.failure);
251
+ else
252
+ job.resolve(job.reply);
253
+ }
254
+ this.#pump();
255
+ }
256
+ async settle() {
257
+ while (this.#queue.length || this.#physical.size) {
258
+ await Promise.allSettled([...[...this.#physical].map((job) => job.promise)]);
259
+ if (this.#queue.length && this.#active === 0)
260
+ this.#pump();
261
+ if (this.#physical.size)
262
+ await new Promise((resolve) => setTimeout(resolve, 5));
263
+ }
264
+ }
265
+ dispose() {
266
+ if (!this.#closing) {
267
+ this.#closing = this.#dispose();
268
+ this.#lifetime.abort(new Error('Native child pool disposed'));
269
+ }
270
+ return this.#closing;
271
+ }
272
+ async #dispose() {
273
+ this.#lifetime.abort(new Error('Native child pool disposed'));
274
+ for (const job of [...this.#queue])
275
+ this.#abort(job, this.#lifetime.signal.reason);
276
+ for (const job of this.#physical)
277
+ this.#abort(job, this.#lifetime.signal.reason);
278
+ await this.settle();
279
+ }
280
+ }
281
+ function cancelledError(reason) {
282
+ if (reason instanceof ClassifierError)
283
+ return reason;
284
+ const message = reason instanceof Error && reason.message ? reason.message : 'Native task cancelled';
285
+ return new ClassifierError('ABORTED', message);
286
+ }
287
+ function nativeFailure(error) {
288
+ if (error instanceof ClassifierError)
289
+ return error;
290
+ const code = typeof error === 'object' && error !== null && 'code' in error ? error.code : undefined;
291
+ if (code === 'ENOENT')
292
+ return new ClassifierError('UNSUPPORTED', 'Native worker executable is unavailable');
293
+ return new ClassifierError('PROVIDER', 'Native child process failed');
294
+ }
295
+ function isMemoryUsage(value) {
296
+ return ['rss', 'heapTotal', 'heapUsed', 'external', 'arrayBuffers'].every((key) => key in value && typeof Reflect.get(value, key) === 'number');
297
+ }