@hawkeyexl/manni 4.26.1 → 4.27.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 (280) hide show
  1. package/README.md +1 -1
  2. package/dist/{batch-NEN7H55G.js → batch-TFGOULLM.js} +14 -14
  3. package/dist/build-TOTJTK5K.js +37 -0
  4. package/dist/{calibrate-3ABLKPCL.js → calibrate-7O4RKGZS.js} +15 -15
  5. package/dist/{capture-EOC6VNIP.js → capture-K6ZKOSIK.js} +14 -14
  6. package/dist/check-4LK34QVH.js +34 -0
  7. package/dist/check-6XN46NLH.js +31 -0
  8. package/dist/check-JBSRU724.js +58 -0
  9. package/dist/check-LZQ3PW6G.js +58 -0
  10. package/dist/{check-5QIOVMIM.js → check-WFJMMSD7.js} +15 -15
  11. package/dist/{chunk-DMTREFXP.js → chunk-2E5OBVLC.js} +4 -4
  12. package/dist/{chunk-MM5HXSYQ.js → chunk-2LLCV66Q.js} +9 -9
  13. package/dist/{chunk-ERBT4WDL.js → chunk-43KMLS4Y.js} +3 -3
  14. package/dist/{chunk-BREAC43H.js → chunk-43VLZO4W.js} +2 -2
  15. package/dist/{chunk-K4ZXCV26.js → chunk-46EEHYA4.js} +65 -12
  16. package/dist/chunk-46EEHYA4.js.map +1 -0
  17. package/dist/{chunk-TVXA4IYY.js → chunk-4KK6TVFD.js} +7 -7
  18. package/dist/{chunk-MMYFT7FI.js → chunk-4NCNVKZS.js} +5 -5
  19. package/dist/{chunk-PMX67E4G.js → chunk-4QOXP5K4.js} +6 -6
  20. package/dist/{chunk-6I7DQ4RL.js → chunk-5QPLKYLM.js} +4 -4
  21. package/dist/{chunk-IJFTUE6Y.js → chunk-5XEZ7FQT.js} +2 -2
  22. package/dist/{chunk-QZOJ2UXP.js → chunk-7BPOYION.js} +2 -2
  23. package/dist/{chunk-ZACMNF3K.js → chunk-7MKAJCU2.js} +2 -2
  24. package/dist/{chunk-ZACMNF3K.js.map → chunk-7MKAJCU2.js.map} +1 -1
  25. package/dist/{chunk-CP6QSXA7.js → chunk-A4DPDPKJ.js} +2 -2
  26. package/dist/{chunk-QJJI6LKA.js → chunk-ACTUV3CQ.js} +52 -4
  27. package/dist/chunk-ACTUV3CQ.js.map +1 -0
  28. package/dist/{chunk-Y23L2GNH.js → chunk-AONT5QCO.js} +10 -10
  29. package/dist/{chunk-7EFXQOTZ.js → chunk-AXMVISW7.js} +3 -3
  30. package/dist/{chunk-MC7U5IH4.js → chunk-BCRMMIY5.js} +1 -1
  31. package/dist/chunk-BCRMMIY5.js.map +1 -0
  32. package/dist/{chunk-LJDIRJLG.js → chunk-BMPQLKQS.js} +10 -8
  33. package/dist/chunk-BMPQLKQS.js.map +1 -0
  34. package/dist/{chunk-K352TYME.js → chunk-BN3SQUXK.js} +14 -14
  35. package/dist/{chunk-3ZVRGBK6.js → chunk-BTFXOKCP.js} +2 -2
  36. package/dist/{chunk-JF4BC7ZD.js → chunk-CDX4QK6O.js} +29 -2
  37. package/dist/chunk-CDX4QK6O.js.map +1 -0
  38. package/dist/{chunk-R4BRS4AE.js → chunk-CJWFDJEX.js} +9 -9
  39. package/dist/{chunk-3YF2DCKQ.js → chunk-D3FJVKE2.js} +3 -3
  40. package/dist/{chunk-ZV3VLKG4.js → chunk-DRMCY64Q.js} +15 -7
  41. package/dist/chunk-DRMCY64Q.js.map +1 -0
  42. package/dist/{chunk-Q56IULOH.js → chunk-DSTEX7SK.js} +3 -3
  43. package/dist/{chunk-466GMD3F.js → chunk-DZC2OALR.js} +4 -4
  44. package/dist/{chunk-PSXEBABJ.js → chunk-FK2FAE3J.js} +4 -4
  45. package/dist/{chunk-XXMPPQMJ.js → chunk-FRAEUYJE.js} +56 -27
  46. package/dist/chunk-FRAEUYJE.js.map +1 -0
  47. package/dist/{chunk-BRUD25F4.js → chunk-H7SFSZ3I.js} +300 -58
  48. package/dist/chunk-H7SFSZ3I.js.map +1 -0
  49. package/dist/chunk-HMJZHUCJ.js +337 -0
  50. package/dist/chunk-HMJZHUCJ.js.map +1 -0
  51. package/dist/{chunk-3D7VBQXN.js → chunk-HQRXE6QY.js} +354 -51
  52. package/dist/chunk-HQRXE6QY.js.map +1 -0
  53. package/dist/{chunk-OQK7J4VE.js → chunk-IFAOEGSU.js} +32 -22
  54. package/dist/chunk-IFAOEGSU.js.map +1 -0
  55. package/dist/{chunk-KP44XIY4.js → chunk-IQJ4WBJZ.js} +173 -83
  56. package/dist/chunk-IQJ4WBJZ.js.map +1 -0
  57. package/dist/{chunk-WPIBGNKM.js → chunk-JWS4OKOZ.js} +4 -4
  58. package/dist/{chunk-MNUGG3B4.js → chunk-K5DKRGUV.js} +6 -6
  59. package/dist/{chunk-KDV7GPCU.js → chunk-LESYV3TT.js} +3 -3
  60. package/dist/{chunk-UZ7BMGDD.js → chunk-LWWO4C6P.js} +3 -3
  61. package/dist/{chunk-63FAVBEK.js → chunk-MABRQ46L.js} +14 -7
  62. package/dist/chunk-MABRQ46L.js.map +1 -0
  63. package/dist/{chunk-O4MKNFMM.js → chunk-MMS3I5ZH.js} +7 -7
  64. package/dist/{chunk-KKCOXRSU.js → chunk-NXJMRIKW.js} +5 -5
  65. package/dist/{chunk-MJBGGFSN.js → chunk-OBFIWPEB.js} +3 -3
  66. package/dist/{chunk-TI4DA6DF.js → chunk-OPF3NOKF.js} +1 -1
  67. package/dist/chunk-OPF3NOKF.js.map +1 -0
  68. package/dist/{chunk-CLH4ZYNG.js → chunk-OZH46DBT.js} +1 -1
  69. package/dist/{chunk-CLH4ZYNG.js.map → chunk-OZH46DBT.js.map} +1 -1
  70. package/dist/{chunk-IUSVWJOF.js → chunk-PBR4TVEL.js} +7 -7
  71. package/dist/{chunk-LZCBMMSG.js → chunk-PHZ7VWSL.js} +31 -13
  72. package/dist/chunk-PHZ7VWSL.js.map +1 -0
  73. package/dist/{chunk-JDV6UC34.js → chunk-Q34NWLGY.js} +2 -2
  74. package/dist/{chunk-ZFLGCCOO.js → chunk-QFVBBRHW.js} +2 -2
  75. package/dist/{chunk-TDQ445D5.js → chunk-QLK6LXSS.js} +3 -3
  76. package/dist/{chunk-XU24F36U.js → chunk-QSABWNXP.js} +4 -4
  77. package/dist/{chunk-T6ZSLK7G.js → chunk-R3FCSRTX.js} +6 -6
  78. package/dist/{chunk-JR4CHN6I.js → chunk-RA3QM7X6.js} +8 -8
  79. package/dist/{chunk-OCJR7ZML.js → chunk-RCGR4NKY.js} +2 -2
  80. package/dist/{chunk-LFA2AMF5.js → chunk-S2ZOXAFY.js} +2 -2
  81. package/dist/{chunk-PAKXJGQF.js → chunk-SYZ75Q5F.js} +65 -47
  82. package/dist/chunk-SYZ75Q5F.js.map +1 -0
  83. package/dist/{chunk-NMYN46MG.js → chunk-TF4VEEDJ.js} +3 -3
  84. package/dist/{chunk-4I3K7QHO.js → chunk-TNOML4XE.js} +3 -3
  85. package/dist/{chunk-GW45SXGE.js → chunk-UVI6JXRM.js} +8 -8
  86. package/dist/{chunk-ZTH67IDP.js → chunk-VHAQJ6KU.js} +34 -28
  87. package/dist/chunk-VHAQJ6KU.js.map +1 -0
  88. package/dist/{chunk-SMDE7RY3.js → chunk-VLPUC4MH.js} +3 -3
  89. package/dist/{chunk-N2AZOLIA.js → chunk-WJ7IGOBI.js} +21 -12
  90. package/dist/chunk-WJ7IGOBI.js.map +1 -0
  91. package/dist/{chunk-3MYJ6BI6.js → chunk-WLN4A2OJ.js} +4 -4
  92. package/dist/{chunk-RGOULVBF.js → chunk-WNL2T7LK.js} +4 -4
  93. package/dist/{chunk-PLUIVONN.js → chunk-WOPKA4ZB.js} +3 -3
  94. package/dist/{chunk-VK34UKBY.js → chunk-X3FSKK53.js} +13 -7
  95. package/dist/chunk-X3FSKK53.js.map +1 -0
  96. package/dist/{chunk-XX7GNK4F.js → chunk-XZFJAVX7.js} +3 -3
  97. package/dist/{chunk-WSRK3PN4.js → chunk-Y72JZVMX.js} +3 -3
  98. package/dist/{chunk-KBZM4HI2.js → chunk-YQ4XWJTB.js} +26 -16
  99. package/dist/chunk-YQ4XWJTB.js.map +1 -0
  100. package/dist/{chunk-K7UK72VN.js → chunk-YUTRYEDG.js} +3 -3
  101. package/dist/{chunk-H7UPMVBK.js → chunk-Z3YNYZR2.js} +2 -2
  102. package/dist/{chunk-XDARBEJA.js → chunk-Z66LHZRV.js} +2 -2
  103. package/dist/{chunk-G5I2JTDK.js → chunk-ZWVYT2G6.js} +2 -2
  104. package/dist/{chunk-D4BGNAN5.js → chunk-ZZGHTXZ2.js} +159 -23
  105. package/dist/chunk-ZZGHTXZ2.js.map +1 -0
  106. package/dist/{cli-BIRTWKQ5.js → cli-4Q22IFXX.js} +16 -15
  107. package/dist/{cli-BIRTWKQ5.js.map → cli-4Q22IFXX.js.map} +1 -1
  108. package/dist/{cli-EYDOJUG7.js → cli-6Y2V6OI6.js} +29 -28
  109. package/dist/{cli-EYDOJUG7.js.map → cli-6Y2V6OI6.js.map} +1 -1
  110. package/dist/{cli-HBVAUPIC.js → cli-A3E4KJ5U.js} +21 -21
  111. package/dist/{cli-XGY7JUEI.js → cli-H4SH5A6M.js} +37 -36
  112. package/dist/{cli-XGY7JUEI.js.map → cli-H4SH5A6M.js.map} +1 -1
  113. package/dist/{cli-RJTB3BWZ.js → cli-ODMYZEFY.js} +68 -58
  114. package/dist/{cli-RJTB3BWZ.js.map → cli-ODMYZEFY.js.map} +1 -1
  115. package/dist/{cli-V3UM6B6F.js → cli-PKCV3N4H.js} +8 -8
  116. package/dist/{cli-HRQCVZQY.js → cli-QQIIFRKE.js} +20 -19
  117. package/dist/{cli-HRQCVZQY.js.map → cli-QQIIFRKE.js.map} +1 -1
  118. package/dist/{cli-XDPMDMZU.js → cli-SN7N4WCV.js} +29 -28
  119. package/dist/{cli-XDPMDMZU.js.map → cli-SN7N4WCV.js.map} +1 -1
  120. package/dist/{cli-VI76NFWN.js → cli-WFC3CJOJ.js} +3 -3
  121. package/dist/{cli-KOATS2ZY.js → cli-YP5KKGZP.js} +30 -29
  122. package/dist/{cli-KOATS2ZY.js.map → cli-YP5KKGZP.js.map} +1 -1
  123. package/dist/{cli-S36TXD3Z.js → cli-Z6IVPISQ.js} +24 -42
  124. package/dist/cli-Z6IVPISQ.js.map +1 -0
  125. package/dist/cli.js +15 -15
  126. package/dist/{config-2YJPJ36T.js → config-Z3FYLJ6X.js} +3 -3
  127. package/dist/docmeta.js +7 -7
  128. package/dist/github-7MZOPO6F.js +49 -0
  129. package/dist/github-MERFCTC7.js +29 -0
  130. package/dist/{github-KGQPHQQJ.js → github-MQPACOAB.js} +15 -14
  131. package/dist/index.d.ts +169 -8
  132. package/dist/index.js +58 -57
  133. package/dist/index.js.map +1 -1
  134. package/dist/{json-5GDD64P6.js → json-7RZPISH3.js} +13 -12
  135. package/dist/{json-BO5XIJWF.js → json-GOM7GQ6C.js} +16 -15
  136. package/dist/{labels-N7GKDSDM.js → labels-3ZOCWOT6.js} +12 -11
  137. package/dist/{labels-N7GKDSDM.js.map → labels-3ZOCWOT6.js.map} +1 -1
  138. package/dist/lint-XQMOP6UX.js +33 -0
  139. package/dist/{list-ZQJOVVUU.js → list-5PR56LNP.js} +15 -14
  140. package/dist/list-AV4DCGP3.js +31 -0
  141. package/dist/list-PLVWVFAV.js +49 -0
  142. package/dist/{page-WXPSHZJY.js → page-7EML6WFG.js} +10 -10
  143. package/dist/{prepare-V76CXWW4.js → prepare-A7NZ5BPZ.js} +13 -13
  144. package/dist/{pretty-RTIATRSO.js → pretty-5QHFDOSO.js} +15 -14
  145. package/dist/{pretty-AR6FVUJO.js → pretty-E4FJRLZZ.js} +25 -24
  146. package/dist/{pretty-VOC2SKHD.js → pretty-Y4UZL35B.js} +13 -12
  147. package/dist/{reporters-LJZLZDFQ.js → reporters-A63SJIY7.js} +12 -12
  148. package/dist/{reporters-A4VULNIK.js → reporters-BFST46C2.js} +5 -5
  149. package/dist/{reporters-6CNOPRDA.js → reporters-MK62LRGW.js} +4 -4
  150. package/dist/run-2MWSIAGL.js +52 -0
  151. package/dist/{sarif-TMQEXFHP.js → sarif-BBNFOFUZ.js} +9 -9
  152. package/dist/sarif-MDBTPWQN.js +50 -0
  153. package/dist/{sarif-UHITXNLM.js → sarif-MTFYXIRJ.js} +11 -11
  154. package/dist/{strategy-TGJGFZHD.js → strategy-3EJODC6O.js} +22 -21
  155. package/dist/{term-GJURJ3FM.js → term-UYCZLVVA.js} +19 -18
  156. package/dist/{term-GJURJ3FM.js.map → term-UYCZLVVA.js.map} +1 -1
  157. package/dist/{types-VWL35P4F.js → types-GV2THIRC.js} +2 -2
  158. package/dist/{validate-YTMGOZAP.js → validate-3C3RWYMR.js} +5 -5
  159. package/package.json +1 -1
  160. package/plugin/manni/.claude-plugin/plugin.json +1 -1
  161. package/plugin/manni/hooks/page-metadata.mjs +1 -1
  162. package/dist/build-UYQEHJ2O.js +0 -36
  163. package/dist/check-34N4PI6C.js +0 -57
  164. package/dist/check-7SUZMJDK.js +0 -33
  165. package/dist/check-D7W7CUPQ.js +0 -30
  166. package/dist/check-RFLS3OB4.js +0 -57
  167. package/dist/chunk-3D7VBQXN.js.map +0 -1
  168. package/dist/chunk-63FAVBEK.js.map +0 -1
  169. package/dist/chunk-BRUD25F4.js.map +0 -1
  170. package/dist/chunk-D4BGNAN5.js.map +0 -1
  171. package/dist/chunk-JF4BC7ZD.js.map +0 -1
  172. package/dist/chunk-K4ZXCV26.js.map +0 -1
  173. package/dist/chunk-KBZM4HI2.js.map +0 -1
  174. package/dist/chunk-KP44XIY4.js.map +0 -1
  175. package/dist/chunk-LJDIRJLG.js.map +0 -1
  176. package/dist/chunk-LZCBMMSG.js.map +0 -1
  177. package/dist/chunk-MC7U5IH4.js.map +0 -1
  178. package/dist/chunk-N2AZOLIA.js.map +0 -1
  179. package/dist/chunk-OQK7J4VE.js.map +0 -1
  180. package/dist/chunk-PAKXJGQF.js.map +0 -1
  181. package/dist/chunk-QJJI6LKA.js.map +0 -1
  182. package/dist/chunk-TI4DA6DF.js.map +0 -1
  183. package/dist/chunk-VK34UKBY.js.map +0 -1
  184. package/dist/chunk-XXMPPQMJ.js.map +0 -1
  185. package/dist/chunk-ZTH67IDP.js.map +0 -1
  186. package/dist/chunk-ZV3VLKG4.js.map +0 -1
  187. package/dist/cli-S36TXD3Z.js.map +0 -1
  188. package/dist/github-EKVVPQPD.js +0 -48
  189. package/dist/github-FQ5MCP3E.js +0 -28
  190. package/dist/lint-U6VEL4ZA.js +0 -32
  191. package/dist/list-5LRPJRJJ.js +0 -48
  192. package/dist/list-GWP3Y2SR.js +0 -30
  193. package/dist/run-4B25K2SV.js +0 -51
  194. package/dist/sarif-Z34PKKFQ.js +0 -49
  195. /package/dist/{batch-NEN7H55G.js.map → batch-TFGOULLM.js.map} +0 -0
  196. /package/dist/{build-UYQEHJ2O.js.map → build-TOTJTK5K.js.map} +0 -0
  197. /package/dist/{calibrate-3ABLKPCL.js.map → calibrate-7O4RKGZS.js.map} +0 -0
  198. /package/dist/{capture-EOC6VNIP.js.map → capture-K6ZKOSIK.js.map} +0 -0
  199. /package/dist/{check-34N4PI6C.js.map → check-4LK34QVH.js.map} +0 -0
  200. /package/dist/{check-7SUZMJDK.js.map → check-6XN46NLH.js.map} +0 -0
  201. /package/dist/{check-D7W7CUPQ.js.map → check-JBSRU724.js.map} +0 -0
  202. /package/dist/{check-RFLS3OB4.js.map → check-LZQ3PW6G.js.map} +0 -0
  203. /package/dist/{check-5QIOVMIM.js.map → check-WFJMMSD7.js.map} +0 -0
  204. /package/dist/{chunk-DMTREFXP.js.map → chunk-2E5OBVLC.js.map} +0 -0
  205. /package/dist/{chunk-MM5HXSYQ.js.map → chunk-2LLCV66Q.js.map} +0 -0
  206. /package/dist/{chunk-ERBT4WDL.js.map → chunk-43KMLS4Y.js.map} +0 -0
  207. /package/dist/{chunk-BREAC43H.js.map → chunk-43VLZO4W.js.map} +0 -0
  208. /package/dist/{chunk-TVXA4IYY.js.map → chunk-4KK6TVFD.js.map} +0 -0
  209. /package/dist/{chunk-MMYFT7FI.js.map → chunk-4NCNVKZS.js.map} +0 -0
  210. /package/dist/{chunk-PMX67E4G.js.map → chunk-4QOXP5K4.js.map} +0 -0
  211. /package/dist/{chunk-6I7DQ4RL.js.map → chunk-5QPLKYLM.js.map} +0 -0
  212. /package/dist/{chunk-IJFTUE6Y.js.map → chunk-5XEZ7FQT.js.map} +0 -0
  213. /package/dist/{chunk-QZOJ2UXP.js.map → chunk-7BPOYION.js.map} +0 -0
  214. /package/dist/{chunk-CP6QSXA7.js.map → chunk-A4DPDPKJ.js.map} +0 -0
  215. /package/dist/{chunk-Y23L2GNH.js.map → chunk-AONT5QCO.js.map} +0 -0
  216. /package/dist/{chunk-7EFXQOTZ.js.map → chunk-AXMVISW7.js.map} +0 -0
  217. /package/dist/{chunk-K352TYME.js.map → chunk-BN3SQUXK.js.map} +0 -0
  218. /package/dist/{chunk-3ZVRGBK6.js.map → chunk-BTFXOKCP.js.map} +0 -0
  219. /package/dist/{chunk-R4BRS4AE.js.map → chunk-CJWFDJEX.js.map} +0 -0
  220. /package/dist/{chunk-3YF2DCKQ.js.map → chunk-D3FJVKE2.js.map} +0 -0
  221. /package/dist/{chunk-Q56IULOH.js.map → chunk-DSTEX7SK.js.map} +0 -0
  222. /package/dist/{chunk-466GMD3F.js.map → chunk-DZC2OALR.js.map} +0 -0
  223. /package/dist/{chunk-PSXEBABJ.js.map → chunk-FK2FAE3J.js.map} +0 -0
  224. /package/dist/{chunk-WPIBGNKM.js.map → chunk-JWS4OKOZ.js.map} +0 -0
  225. /package/dist/{chunk-MNUGG3B4.js.map → chunk-K5DKRGUV.js.map} +0 -0
  226. /package/dist/{chunk-KDV7GPCU.js.map → chunk-LESYV3TT.js.map} +0 -0
  227. /package/dist/{chunk-UZ7BMGDD.js.map → chunk-LWWO4C6P.js.map} +0 -0
  228. /package/dist/{chunk-O4MKNFMM.js.map → chunk-MMS3I5ZH.js.map} +0 -0
  229. /package/dist/{chunk-KKCOXRSU.js.map → chunk-NXJMRIKW.js.map} +0 -0
  230. /package/dist/{chunk-MJBGGFSN.js.map → chunk-OBFIWPEB.js.map} +0 -0
  231. /package/dist/{chunk-IUSVWJOF.js.map → chunk-PBR4TVEL.js.map} +0 -0
  232. /package/dist/{chunk-JDV6UC34.js.map → chunk-Q34NWLGY.js.map} +0 -0
  233. /package/dist/{chunk-ZFLGCCOO.js.map → chunk-QFVBBRHW.js.map} +0 -0
  234. /package/dist/{chunk-TDQ445D5.js.map → chunk-QLK6LXSS.js.map} +0 -0
  235. /package/dist/{chunk-XU24F36U.js.map → chunk-QSABWNXP.js.map} +0 -0
  236. /package/dist/{chunk-T6ZSLK7G.js.map → chunk-R3FCSRTX.js.map} +0 -0
  237. /package/dist/{chunk-JR4CHN6I.js.map → chunk-RA3QM7X6.js.map} +0 -0
  238. /package/dist/{chunk-OCJR7ZML.js.map → chunk-RCGR4NKY.js.map} +0 -0
  239. /package/dist/{chunk-LFA2AMF5.js.map → chunk-S2ZOXAFY.js.map} +0 -0
  240. /package/dist/{chunk-NMYN46MG.js.map → chunk-TF4VEEDJ.js.map} +0 -0
  241. /package/dist/{chunk-4I3K7QHO.js.map → chunk-TNOML4XE.js.map} +0 -0
  242. /package/dist/{chunk-GW45SXGE.js.map → chunk-UVI6JXRM.js.map} +0 -0
  243. /package/dist/{chunk-SMDE7RY3.js.map → chunk-VLPUC4MH.js.map} +0 -0
  244. /package/dist/{chunk-3MYJ6BI6.js.map → chunk-WLN4A2OJ.js.map} +0 -0
  245. /package/dist/{chunk-RGOULVBF.js.map → chunk-WNL2T7LK.js.map} +0 -0
  246. /package/dist/{chunk-PLUIVONN.js.map → chunk-WOPKA4ZB.js.map} +0 -0
  247. /package/dist/{chunk-XX7GNK4F.js.map → chunk-XZFJAVX7.js.map} +0 -0
  248. /package/dist/{chunk-WSRK3PN4.js.map → chunk-Y72JZVMX.js.map} +0 -0
  249. /package/dist/{chunk-K7UK72VN.js.map → chunk-YUTRYEDG.js.map} +0 -0
  250. /package/dist/{chunk-H7UPMVBK.js.map → chunk-Z3YNYZR2.js.map} +0 -0
  251. /package/dist/{chunk-XDARBEJA.js.map → chunk-Z66LHZRV.js.map} +0 -0
  252. /package/dist/{chunk-G5I2JTDK.js.map → chunk-ZWVYT2G6.js.map} +0 -0
  253. /package/dist/{cli-HBVAUPIC.js.map → cli-A3E4KJ5U.js.map} +0 -0
  254. /package/dist/{cli-V3UM6B6F.js.map → cli-PKCV3N4H.js.map} +0 -0
  255. /package/dist/{cli-VI76NFWN.js.map → cli-WFC3CJOJ.js.map} +0 -0
  256. /package/dist/{config-2YJPJ36T.js.map → config-Z3FYLJ6X.js.map} +0 -0
  257. /package/dist/{github-EKVVPQPD.js.map → github-7MZOPO6F.js.map} +0 -0
  258. /package/dist/{github-FQ5MCP3E.js.map → github-MERFCTC7.js.map} +0 -0
  259. /package/dist/{github-KGQPHQQJ.js.map → github-MQPACOAB.js.map} +0 -0
  260. /package/dist/{json-5GDD64P6.js.map → json-7RZPISH3.js.map} +0 -0
  261. /package/dist/{json-BO5XIJWF.js.map → json-GOM7GQ6C.js.map} +0 -0
  262. /package/dist/{lint-U6VEL4ZA.js.map → lint-XQMOP6UX.js.map} +0 -0
  263. /package/dist/{list-5LRPJRJJ.js.map → list-5PR56LNP.js.map} +0 -0
  264. /package/dist/{list-GWP3Y2SR.js.map → list-AV4DCGP3.js.map} +0 -0
  265. /package/dist/{list-ZQJOVVUU.js.map → list-PLVWVFAV.js.map} +0 -0
  266. /package/dist/{page-WXPSHZJY.js.map → page-7EML6WFG.js.map} +0 -0
  267. /package/dist/{prepare-V76CXWW4.js.map → prepare-A7NZ5BPZ.js.map} +0 -0
  268. /package/dist/{pretty-AR6FVUJO.js.map → pretty-5QHFDOSO.js.map} +0 -0
  269. /package/dist/{pretty-RTIATRSO.js.map → pretty-E4FJRLZZ.js.map} +0 -0
  270. /package/dist/{pretty-VOC2SKHD.js.map → pretty-Y4UZL35B.js.map} +0 -0
  271. /package/dist/{reporters-6CNOPRDA.js.map → reporters-A63SJIY7.js.map} +0 -0
  272. /package/dist/{reporters-A4VULNIK.js.map → reporters-BFST46C2.js.map} +0 -0
  273. /package/dist/{reporters-LJZLZDFQ.js.map → reporters-MK62LRGW.js.map} +0 -0
  274. /package/dist/{run-4B25K2SV.js.map → run-2MWSIAGL.js.map} +0 -0
  275. /package/dist/{sarif-TMQEXFHP.js.map → sarif-BBNFOFUZ.js.map} +0 -0
  276. /package/dist/{sarif-UHITXNLM.js.map → sarif-MDBTPWQN.js.map} +0 -0
  277. /package/dist/{sarif-Z34PKKFQ.js.map → sarif-MTFYXIRJ.js.map} +0 -0
  278. /package/dist/{strategy-TGJGFZHD.js.map → strategy-3EJODC6O.js.map} +0 -0
  279. /package/dist/{types-VWL35P4F.js.map → types-GV2THIRC.js.map} +0 -0
  280. /package/dist/{validate-YTMGOZAP.js.map → validate-3C3RWYMR.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/graph/core/load.ts","../src/graph/commands/search.ts","../src/graph/embed/local.ts","../src/graph/embed/mock.ts","../src/graph/commands/questions.ts","../src/graph/core/search-index.ts","../src/graph/runtime/resolve.ts","../src/graph/commands/chunks.ts","../src/graph/core/emit-jsonld.ts","../src/graph/commands/traverse.ts","../src/graph/core/pkg.ts","../src/graph/core/shacl.ts"],"sourcesContent":["/** Load a built .ttl into an in-memory N3 store for query/stats. */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { Parser, Store } from \"n3\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport { GraphError } from \"../types.js\";\nimport type { Quad, Term } from \"./derive.js\";\nimport { NS, PREFIXES } from \"./vocab.js\";\n\nconst XSD_STRING = `${NS.xsd}string`;\n\nexport function loadGraph(ttlPath: string): Store {\n if (!existsSync(ttlPath)) {\n throw new GraphError(\n `Graph not found: ${ttlPath} — run \\`manni graph build\\` first.`,\n );\n }\n return parseGraph(readFileSync(ttlPath, \"utf8\"), ttlPath);\n}\n\n/** Turtle already in memory into a store; `label` names it in an error. */\nexport function parseGraph(turtle: string, label: string): Store {\n const parser = new Parser({ format: \"text/turtle\" });\n let quads;\n try {\n quads = parser.parse(turtle);\n } catch (e) {\n throw new GraphError(\n `Failed to parse ${label}: ${errorMessage(e)}`,\n );\n }\n return new Store(quads);\n}\n\n/**\n * Convert an in-memory N3 store back to dockg's internal quad shape — the\n * bridge from the Turtle-reading Node side to the platform-neutral emitters and\n * runtime. A redundant `xsd:string` datatype is dropped so the result matches\n * what the JSON-LD path produces.\n */\nexport function storeToQuads(store: Store): Quad[] {\n return store.getQuads(null, null, null, null).map((q) => {\n const o = q.object;\n let term: Term;\n if (o.termType === \"Literal\" && o.language !== \"\") {\n term = { kind: \"literal\", value: o.value, language: o.language };\n } else if (o.termType === \"Literal\") {\n const dt = o.datatype.value;\n term =\n dt && dt !== XSD_STRING\n ? { kind: \"literal\", value: o.value, datatype: dt }\n : { kind: \"literal\", value: o.value };\n } else {\n term = { kind: \"iri\", value: o.value };\n }\n return { s: q.subject.value, p: q.predicate.value, o: term };\n });\n}\n\n/** Expand `dcterms:references`-style prefixed names to full IRIs; pass through the rest. */\nexport function expandTerm(input: string): string {\n const colon = input.indexOf(\":\");\n if (colon > 0) {\n const prefix = input.slice(0, colon);\n const ns = (NS as Record<string, string>)[prefix];\n if (ns) return `${ns}${input.slice(colon + 1)}`;\n }\n return input;\n}\n\n/** Compact a full IRI back to a prefixed name when a known namespace matches. */\nexport function compactIri(iri: string): string {\n for (const [prefix, ns] of PREFIXES) {\n if (iri.startsWith(ns) && iri.length > ns.length) {\n return `${prefix}:${iri.slice(ns.length)}`;\n }\n }\n return iri;\n}\n","/**\n * `manni graph search` — text query → ranked seed nodes (ADR 01019).\n *\n * A thin Node wrapper over the browser-native lexical entry stage: it loads the\n * `search.json` artifact and runs the same `findEntry` a browser would. This is\n * the stage before `traverse`; Phase 9's `retrieve` chains the two.\n *\n * The trace is always in the JSON output — retrieval provenance is part of the\n * contract, not an opt-in (ADR 01018).\n */\nimport { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { loadRunConfig } from \"../core/config.js\";\nimport { compactIri } from \"../core/load.js\";\nimport { type SearchIndexDoc } from \"../core/search-index.js\";\nimport {\n canonicalLanguageTag,\n LOCALIZATIONS_FILENAME,\n parseLocalizations,\n type LocalizationEntry,\n} from \"../core/localizations.js\";\nimport { VectorIndexError } from \"../core/vector-index.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport { GraphError } from \"../types.js\";\nimport { warn } from \"../../shared/warn.js\";\nimport { findEntry } from \"../runtime/entry.js\";\nimport { createLexicalIndex } from \"../runtime/lexical.js\";\nimport {\n createVectorIndex,\n VectorMismatchError,\n type VectorIndex,\n} from \"../runtime/vector.js\";\nimport {\n createLocalEmbedder,\n EmbedderUnavailableError,\n} from \"../embed/local.js\";\nimport { createMockEmbedder } from \"../embed/mock.js\";\nimport type { Embedder } from \"../embed/types.js\";\nimport type { QueryTrace } from \"../runtime/trace.js\";\n\n/**\n * Which legs `--mode` can ask for, in the order messages list them. Stated\n * once so the union, the help text and the refusal sentence cannot drift.\n */\nexport const SEARCH_MODES = [\"lexical\", \"hybrid\", \"vector\"] as const;\nexport type SearchMode = (typeof SEARCH_MODES)[number];\n\nexport interface SearchOptions {\n config?: string;\n /** `--no-config`: skip discovery and run on the built-in defaults. */\n noConfig?: boolean;\n /** Graph .ttl path (default: config `out`) — locates the sibling index. */\n graph?: string;\n /** Directory holding the indexes and manifest (default: beside the graph). */\n index?: string;\n /**\n * Which localization to search (ADR 01038). Optional when the corpus has one;\n * required when it has more, because picking for the user is how a query gets\n * answered out of the wrong language.\n */\n lang?: string;\n query: string;\n limit?: number;\n /** Vector sidecar path (default: the sidecar the manifest records). */\n vectors?: string;\n /**\n * Which legs to run. \"lexical\" is always available; \"vector\"/\"hybrid\" need an\n * embedder and a sidecar. Default \"hybrid\" when both are present, else\n * \"lexical\" — additive, never a new failure mode.\n */\n mode?: SearchMode;\n /** Injection seam for tests: bypasses the embedder factory. */\n embedder?: Embedder;\n cwd?: string;\n}\n\nexport interface SearchHit {\n iri: string;\n score: number;\n via: string;\n type?: string;\n title?: string;\n}\n\nexport interface SearchReport {\n query: string;\n /** Which legs actually ran. */\n mode: SearchMode;\n /** The fused ranking (or the single leg's, when only one ran). */\n results: SearchHit[];\n /** The lexical leg's own ranking. */\n lexical: SearchHit[];\n /** The vector leg's own ranking; empty when it did not run. */\n vector: SearchHit[];\n trace: QueryTrace;\n}\n\n/**\n * Read and shape-check the artifact. A truncated write, or `-i` pointed at the\n * wrong file, is an operational error (exit 2) like an unparseable graph — not\n * a raw stack trace, and not a confident \"0 results\".\n *\n * The digest travels with the document: it is what the vector sidecar records\n * as its `source`, and comparing them is how a stale sidecar is refused rather\n * than ranked against (ADR 01020).\n */\nfunction loadSearchIndex(indexPath: string): {\n doc: SearchIndexDoc;\n source: string;\n} {\n const raw = readFileSync(indexPath, \"utf8\");\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (e) {\n throw new GraphError(\n `Failed to parse ${indexPath}: ${errorMessage(e)} — re-run \\`manni graph export search\\`.`,\n );\n }\n const entries = (parsed as SearchIndexDoc | null)?.entries;\n if (!Array.isArray(entries)) {\n throw new GraphError(\n `Not a manni graph search index: ${indexPath} — expected an \\`entries\\` array; re-run \\`manni graph export search\\`.`,\n );\n }\n return {\n doc: parsed as SearchIndexDoc,\n // Same recipe `manni graph embed` uses, so the two digests are comparable.\n source: `sha256:${createHash(\"sha256\").update(raw, \"utf8\").digest(\"hex\")}`,\n };\n}\n\n/** A `--lang` the corpus has no index for. `graph retrieve` refuses in the same words. */\nexport function noIndexFor(lang: string, available: readonly string[]): string {\n return `No index for language \"${lang}\" — this corpus has ${available.join(\", \") || \"none\"}.`;\n}\n\n/** Several localizations and no `--lang`. `graph retrieve` refuses in the same words. */\nexport function langRequired(available: readonly string[]): string {\n return `This corpus has more than one localization (${available.join(\", \")}) — pass --lang to choose one.`;\n}\n\n/**\n * Pick the localization to search from the manifest (ADR 01038).\n *\n * With one language the choice is unambiguous and made silently. With more, an\n * unspecified `--lang` is a **refusal**, not a default: answering a German\n * question out of the English index is the failure the fan-out exists to\n * prevent, and guessing would hide it behind a confident result.\n */\nfunction resolveLocalization(\n indexDir: string,\n lang: string | undefined,\n): LocalizationEntry {\n const manifestPath = join(indexDir, LOCALIZATIONS_FILENAME);\n if (!existsSync(manifestPath)) {\n throw new GraphError(\n `Localization manifest not found: ${manifestPath} — run \\`manni graph export search\\` first.`,\n );\n }\n const manifest = parseLocalizations(readFileSync(manifestPath, \"utf8\"));\n if (!manifest) {\n throw new GraphError(\n `Not a manni graph localization manifest: ${manifestPath} — re-run \\`manni graph export search\\`.`,\n );\n }\n const available = manifest.languages.map((l) => l.language);\n if (lang !== undefined) {\n // Tags are case-insensitive: `--lang en-us` names the `en-US` index.\n const wanted = canonicalLanguageTag(lang);\n const hit = manifest.languages.find(\n (l) => canonicalLanguageTag(l.language) === wanted,\n );\n if (!hit) {\n throw new GraphError(noIndexFor(lang, available));\n }\n return hit;\n }\n const only = manifest.languages[0];\n if (!only) {\n throw new GraphError(\n `The localization manifest lists no languages: ${manifestPath} — re-run \\`manni graph export search\\`.`,\n );\n }\n if (manifest.languages.length > 1) {\n throw new GraphError(langRequired(available));\n }\n return only;\n}\n\nexport async function runSearch(opts: SearchOptions): Promise<SearchReport> {\n const cwd = opts.cwd ?? process.cwd();\n const config = loadRunConfig(\n {\n ...(opts.config === undefined ? {} : { configPath: opts.config }),\n ...(opts.noConfig === undefined ? {} : { noConfig: opts.noConfig }),\n },\n cwd,\n );\n const graphPath = resolve(cwd, opts.graph ?? config.out);\n const indexDir = opts.index ? resolve(cwd, opts.index) : dirname(graphPath);\n const localization = resolveLocalization(indexDir, opts.lang);\n const indexPath = join(indexDir, localization.search.path);\n\n if (!existsSync(indexPath)) {\n throw new GraphError(\n `Search index not found: ${indexPath} — the manifest names it; re-run \\`manni graph export search\\`.`,\n );\n }\n\n const { doc, source } = loadSearchIndex(indexPath);\n // The manifest records the digest of the index it wrote, and embed refuses a\n // pair that has drifted. Searching one anyway answers from bytes the\n // manifest does not describe, with a confident ranking.\n if (localization.search.digest !== source) {\n throw new GraphError(\n `Stale manifest: ${localization.search.path} does not match the digest recorded for \"${localization.language}\". Re-run \\`manni graph export search\\`.`,\n );\n }\n const lexical = createLexicalIndex(doc);\n\n // The vector leg is opt-in by availability: a sidecar plus an embedder. Asked\n // for explicitly (`--mode vector|hybrid`) a missing piece is an error, since\n // silently answering lexically would look like the semantic leg ran.\n // \"Asked for\" means an explicit `--mode vector|hybrid` *or* an explicit\n // `--vectors <path>`. A typo'd path would otherwise fall through to the\n // default-path branch, find nothing, and return lexical results with exit 0 —\n // a confident answer to a question the user did not ask.\n //\n // One predicate for both decisions. Testing `!== undefined` here while the\n // path below tested truthiness meant `--vectors \"\"` demanded the vector leg\n // and then resolved the *default* sidecar — failing, or answering, about a\n // file the user never named.\n const explicitVectors =\n opts.vectors !== undefined && opts.vectors !== \"\"\n ? opts.vectors\n : undefined;\n const wantsVector =\n opts.mode === \"vector\" ||\n opts.mode === \"hybrid\" ||\n (explicitVectors !== undefined && opts.mode !== \"lexical\");\n // Default to the sidecar the manifest records for *this* language, so the\n // pair can never be crossed. An entry with no `vectors` block simply has no\n // sidecar yet, and the leg stays unavailable.\n //\n // Resolved against the manifest's own directory, because that is what\n // `vectors.path` is relative to. Resolving it against `config.embed.out`\n // instead made the vector leg silently vanish for any layout where the two\n // differ — a lexical answer to a question that asked for both.\n const vectorsPath = explicitVectors\n ? resolve(cwd, explicitVectors)\n : localization.vectors\n ? resolve(indexDir, localization.vectors.path)\n : undefined;\n let vectors: VectorIndex | undefined;\n if (\n opts.mode !== \"lexical\" &&\n vectorsPath !== undefined &&\n existsSync(vectorsPath)\n ) {\n try {\n vectors = createVectorIndex(readFileSync(vectorsPath));\n } catch (e) {\n // A truncated write or `--vectors` pointed at the wrong file is an\n // operational error (exit 2), exactly as for the search index above —\n // not a raw VectorIndexError stack trace out of an async action.\n if (e instanceof VectorIndexError) {\n throw new GraphError(\n `${e.message} (${vectorsPath}) — re-run \\`manni graph embed\\`, or use \\`--mode lexical\\`.`,\n );\n }\n throw e;\n }\n // Refuse rather than rank: vectors built from a different corpus point at\n // IRIs that may no longer exist and miss everything added since\n // (ADR 01020, \"Mismatch is refused, not ranked\").\n //\n // But only refuse when the vector leg was *asked for*. A plain `dockg\n // search` that merely happens to find a stale sidecar beside the graph\n // should degrade to lexical, not fail — the leg is additive, and turning a\n // working lexical search into exit 2 is the new failure mode ADR 01009\n // forbids. Warned about rather than silently dropped, so a user who\n // expected semantic results learns why they did not get them.\n const stale = vectors.check({ source });\n if (stale && wantsVector) throw new GraphError(stale.detail);\n if (stale) {\n warn(`${stale.detail} Falling back to lexical.`);\n vectors = undefined;\n }\n } else if (wantsVector) {\n // Named by the manifest when there is one to name, and by the language\n // otherwise: \"no sidecar for de\" is actionable, an undefined path is not.\n const named =\n vectorsPath ?? `no sidecar recorded for \"${localization.language}\"`;\n throw new GraphError(\n `Vector index not found: ${named} — run \\`manni graph embed\\` first, or use \\`--mode lexical\\`.`,\n );\n }\n\n let embedder: Embedder | undefined;\n if (vectors) {\n // Only an explicit `--mode vector|hybrid` makes a missing embedder fatal.\n // Naming a sidecar says which file to use, not that the optional\n // transformers peer must be installed — threading `wantsVector` here turned\n // `--vectors ./v.bin` on a machine without the peer from \"degrade to\n // lexical, exit 0\" into exit 2.\n const requireEmbedder = opts.mode === \"vector\" || opts.mode === \"hybrid\";\n embedder = await resolveEmbedder(opts.embedder, vectors, requireEmbedder);\n }\n\n const entry = await findEntry(opts.query, {\n lexical,\n // Pass the embedder, not a bare function: findEntry then verifies it\n // against the index itself rather than trusting the CLI to have done so.\n ...(embedder && vectors ? { vectors, embedder } : {}),\n limit: opts.limit,\n }).catch((e: unknown) => {\n // `resolveEmbedder` has already checked model and dtype, so reaching here\n // means a dimension disagreement the header did not predict — a real\n // operational error (exit 2), not a stack trace out of an async action.\n if (e instanceof VectorMismatchError) {\n throw new GraphError(`${e.message} Re-run \\`manni graph embed\\`.`);\n }\n throw e;\n });\n\n const decorate = (c: {\n iri: string;\n score: number;\n via: string;\n }): SearchHit => {\n const found = lexical.entry(c.iri);\n return {\n iri: c.iri,\n score: c.score,\n via: c.via,\n ...(found?.type === undefined ? {} : { type: found.type }),\n ...(found?.title === undefined ? {} : { title: found.title }),\n };\n };\n\n // Which legs *ran*, not which produced hits: a vector leg that matched\n // nothing (blank query, everything below `minScore`) still ran, and reporting\n // \"lexical\" for an explicit `--mode vector` would deny it ever happened. An\n // explicit mode is authoritative — the guards above already errored if it\n // could not be honored.\n const mode = opts.mode ?? (embedder && vectors ? \"hybrid\" : \"lexical\");\n\n // `--mode vector` reports the vector leg alone rather than the fusion.\n const results = opts.mode === \"vector\" ? entry.vector : entry.candidates;\n if (opts.mode === \"vector\") {\n // The trace is the answer to \"why did these come back\" (ADR 01018), so it\n // must describe the ranking actually returned, not the fusion that seeded\n // nothing in this mode.\n entry.trace.entry.length = 0;\n entry.trace.entry.push(...entry.vector);\n }\n\n return {\n query: opts.query,\n mode,\n results: results.map(decorate),\n lexical: entry.lexical.map(decorate),\n vector: entry.vector.map(decorate),\n trace: entry.trace,\n };\n}\n\n/**\n * Build an embedder for the query side, matching the sidecar. A mismatch is\n * refused rather than ranked against: comparing vectors from two different\n * models compares outputs of two different functions (ADR 01020).\n *\n * Both the model *and* the dtype come from the sidecar header rather than from\n * config: `embed.*` is a build-time knob, and q8 weights are a different\n * function from fp32 ones, so following config here would silently compare\n * query vectors against corpus vectors produced by different weights.\n *\n * `graph check` asks sample questions through it too, so both rank alike.\n */\nexport async function resolveEmbedder(\n override: Embedder | undefined,\n vectors: VectorIndex,\n required: boolean,\n): Promise<Embedder | undefined> {\n const { model, dtype } = vectors;\n try {\n const embedder =\n override ??\n (model === \"mock\"\n ? createMockEmbedder({ dtype })\n : await createLocalEmbedder({ model, dtype, role: \"query\" }));\n const mismatch = vectors.check({\n model: embedder.model,\n dtype: embedder.dtype,\n // Defense in depth: a future model that changes output size without\n // changing its id would otherwise only surface deep inside search().\n ...(embedder.dims > 0 ? { dims: embedder.dims } : {}),\n });\n if (mismatch) throw new GraphError(mismatch.detail);\n return embedder;\n } catch (e) {\n if (e instanceof GraphError) throw e;\n if (e instanceof EmbedderUnavailableError) {\n // Only fatal when the vector leg was asked for; otherwise degrade to\n // lexical rather than failing a search that can still be answered.\n if (required) throw new GraphError(e.message);\n return undefined;\n }\n // A model that will not load (bad id, 404, corrupt weights) is fatal either\n // way — but as an operational error with a message, not a stack trace.\n throw new GraphError(\n `Failed to load embedding model ${model}: ${errorMessage(e)}`,\n );\n }\n}\n\nexport function renderSearch(\n report: SearchReport,\n format: \"pretty\" | \"json\",\n): string {\n if (format === \"json\") return JSON.stringify(report, null, 2);\n\n const lines: string[] = [];\n for (const r of report.results) {\n const label = r.title ? ` — ${r.title}` : \"\";\n const type = r.type ? ` [${r.type}]` : \"\";\n lines.push(`${r.score.toFixed(4)} ${compactIri(r.iri)}${type}${label}`);\n }\n if (report.results.length === 0) {\n lines.push(\"(no matches)\");\n }\n lines.push(\"\");\n lines.push(\n `${report.results.length} result${report.results.length === 1 ? \"\" : \"s\"} (${report.mode})`,\n );\n return lines.join(\"\\n\");\n}\n","/**\n * The local embedder ([ADR 01020](../../adrs/01020-local-embeddings.md), corrected\n * by [ADR 01025](../../adrs/01025-embedder-cross-platform-reality.md)).\n *\n * Node and the browser **do not** run the same implementation, and cannot be made\n * to. transformers.js v4 takes disjoint `device` vocabularies per platform — Node\n * accepts `dml | webgpu | cpu`, the browser accepts `webgpu | wasm` — so no single\n * value selects one backend everywhere. An earlier version of this file forced\n * `device: \"wasm\"`, which threw on every real Node run; see ADR 01025 for the\n * measurements.\n *\n * What that costs, measured on granite q8: Node native vs browser WASM agree to\n * cosine 0.999914 (max component diff 2.2e-3). dockg's guarantee is therefore\n * **ranking agreement**, gated by `test/real/cross-platform.mjs`, not float\n * equality.\n *\n * Three disciplines are real and pinned here:\n *\n * 1. `numThreads = 1` — binds on the WASM side, where the default follows\n * `hardwareConcurrency` and would vary reduction splits per machine. Inert\n * on the Node side, whose env object does not carry it.\n * 2. `dtype: \"q8\"` — int8 GEMM accumulates in int32, and integer addition is\n * associative.\n * 3. One text per call — a batched vector depends on what it was batched with,\n * so adding a document would perturb its neighbours.\n *\n * `device` is deliberately **not** passed: transformers.js then picks its platform\n * default, which in Node is bit-identical to an explicit `cpu` (measured) and in\n * the browser is WASM. A caller wanting `webgpu` can pass it.\n *\n * `@huggingface/transformers` is an **optional peer dependency**, imported\n * dynamically: it hard-depends on both ONNX runtimes plus native `sharp`, and\n * most dockg users never enable embeddings. Behind this subpath, a consumer who\n * never imports `@hawkeyexl/manni/graph/embed` never resolves it.\n */\nimport { errorMessage } from \"../../shared/errors.js\";\nimport {\n profileFor,\n withPrefix,\n type EmbedRole,\n type Embedder,\n type ModelProfile,\n} from \"./types.js\";\nimport { DEFAULT_MODEL } from \"./types.js\";\n\n/**\n * A built feature-extraction pipeline, as this module calls it.\n *\n * One text, mean-pooled and normalized (disciplines 2 and 3 above), returning\n * something array-like of numbers. `Tensor` carries far more than that; naming\n * only what is read keeps the peer's real type out of the build.\n */\nexport type FeatureExtractionPipeline = (\n text: string,\n options: { pooling: \"mean\"; normalize: boolean },\n) => Promise<{ data: ArrayLike<number> }>;\n\n/**\n * The slice of `@huggingface/transformers` this module touches.\n *\n * The package is an **optional peer**, so importing its types would make it a\n * hard dependency for everyone — the thing the dynamic import exists to avoid.\n * Declaring the used surface here instead keeps the boundary narrow rather\n * than untyped: three members, each one a line the code below actually runs.\n * `env` is optional all the way down because the Node build's\n * `backends.onnx.wasm` may be absent or a stub, which is the mistake ADR 01025\n * documents.\n */\nexport interface TransformersModule {\n env?: {\n backends?: {\n onnx?: { wasm?: { numThreads?: number } };\n };\n };\n pipeline: (\n task: \"feature-extraction\",\n model: string,\n options: { device?: string; dtype: string },\n ) => Promise<FeatureExtractionPipeline>;\n}\n\nexport interface LocalEmbedderOptions {\n /** Hugging Face model id. Any id is accepted; the tested set is documented. */\n model?: string;\n /** Weight quantization. Default `q8` — see discipline 2 above. */\n dtype?: string;\n /**\n * ONNX execution provider. **Omitted by default on purpose** — the accepted\n * values differ by platform (Node: `dml | webgpu | cpu`; browser: `webgpu |\n * wasm`), so any hardcoded value throws somewhere. Pass one only if you know\n * which platform this embedder runs on.\n */\n device?: string;\n /**\n * What these embeddings are for. Decides which prefix convention applies for\n * models that need one. Default \"passage\" (indexing); the query side passes\n * \"query\".\n */\n role?: EmbedRole;\n /**\n * Inject the transformers.js module (tests, or a host that already imported\n * it). Absent, it is imported dynamically.\n */\n transformers?: TransformersModule;\n}\n\n/** Thrown when the optional peer is not installed, with the fix in the message. */\nexport class EmbedderUnavailableError extends Error {\n constructor(detail: string) {\n super(\n `Local embeddings need @huggingface/transformers, which is an optional peer dependency.\\n` +\n ` Install it: npm install @huggingface/transformers\\n` +\n ` (${detail})`,\n );\n this.name = \"EmbedderUnavailableError\";\n }\n}\n\nasync function loadTransformers(\n injected?: TransformersModule,\n): Promise<TransformersModule> {\n if (injected) return injected;\n try {\n // A literal specifier, so a consumer's bundler can resolve and chunk it\n // normally when they *have* opted in. Nothing is lost by leaving it\n // untyped: this boundary is untyped by design (see the note above), and\n // the missing-package path is what the catch handles.\n //\n // `@ts-ignore`, not `@ts-expect-error`, precisely because whether this\n // line errors depends on whether the optional peer happens to be\n // installed. `@ts-expect-error` fails with TS2578 (\"unused directive\") the\n // moment someone follows the README and installs it — which is exactly\n // what the `embed-real` CI job does, and how this was caught.\n // @ts-ignore optional peer dependency, may or may not be installed\n return (await import(\"@huggingface/transformers\")) as TransformersModule;\n } catch (e) {\n throw new EmbedderUnavailableError(\n errorMessage(e),\n );\n }\n}\n\n/**\n * Create an embedder backed by a local model.\n *\n * **Constructing it is the expensive step**: `pipeline()` fetches the model's\n * config and weights (tens of megabytes on a cold cache) and builds the ONNX\n * session before returning, so callers that may not need to embed anything —\n * `manni graph embed` on an all-cache-hit run — should construct it lazily.\n */\nexport async function createLocalEmbedder(\n options: LocalEmbedderOptions = {},\n): Promise<Embedder> {\n const model = options.model ?? DEFAULT_MODEL;\n const dtype = options.dtype ?? \"q8\";\n const role: EmbedRole = options.role ?? \"passage\";\n const profile: ModelProfile = profileFor(model);\n\n const transformers = await loadTransformers(options.transformers);\n\n // Discipline 1, set before the pipeline is built. Optional-chained because\n // the Node build's `env.backends.onnx.wasm` may be absent or a stub — this\n // pins the browser side, and asserting it pinned both is the mistake ADR\n // 01025 documents.\n if (transformers.env?.backends?.onnx?.wasm) {\n transformers.env.backends.onnx.wasm.numThreads = 1;\n }\n\n const extractor = await transformers.pipeline(\"feature-extraction\", model, {\n // No `device`: its accepted values are disjoint across platforms, so any\n // hardcoded choice throws on one of them (ADR 01025).\n ...(options.device === undefined ? {} : { device: options.device }),\n dtype,\n });\n\n let dims = 0;\n\n return {\n model,\n dtype,\n get dims() {\n return dims;\n },\n async embed(text: string): Promise<Float32Array> {\n // Discipline 3: one text per call, never a batch.\n const output = await extractor(withPrefix(profile, role, text), {\n pooling: \"mean\",\n normalize: true,\n });\n const data = Float32Array.from(output.data);\n dims = data.length;\n return data;\n },\n };\n}\n","/**\n * A deterministic offline embedder (ADR 01020) — the counterpart to\n * `MockProvider` for the LLM seam.\n *\n * CI must stay hermetic: real embedding downloads tens of megabytes of model\n * weights, which the no-network rule forbids. This produces vectors from a hash\n * of the text, so they are stable across runs, machines, and platforms — which\n * makes the `vectors.bin` golden and the double-build determinism gate possible\n * without a model.\n *\n * The vectors carry no semantics. They are useful for testing plumbing,\n * ordering, and refusal paths — never for judging retrieval quality.\n *\n * Platform-neutral: no `node:` imports, no dependencies.\n */\nimport type { Embedder } from \"./types.js\";\n\n/** FNV-1a, 32-bit. Small, fast, and identical everywhere. */\nfunction fnv1a(text: string, seed: number): number {\n let hash = (0x81_1c_9d_c5 ^ seed) >>> 0;\n for (let i = 0; i < text.length; i++) {\n hash = (hash ^ text.charCodeAt(i)) >>> 0;\n // hash *= 16777619, via shifts to stay in 32-bit integer range.\n hash =\n (hash +\n ((hash << 1) +\n (hash << 4) +\n (hash << 7) +\n (hash << 8) +\n (hash << 24))) >>>\n 0;\n }\n return hash >>> 0;\n}\n\nexport interface MockEmbedderOptions {\n /** Output dimensions. Default 8 — small keeps fixtures readable. */\n dims?: number;\n /** Reported model id. Default \"mock\". */\n model?: string;\n /** Reported dtype. Default \"mock\". */\n dtype?: string;\n}\n\n/**\n * Build a deterministic embedder. The same text always yields the same vector;\n * different texts yield different ones with high probability.\n */\nexport function createMockEmbedder(\n options: MockEmbedderOptions = {},\n): Embedder {\n const dims = options.dims ?? 8;\n const model = options.model ?? \"mock\";\n const dtype = options.dtype ?? \"mock\";\n\n return {\n model,\n dtype,\n dims,\n embed(text: string): Promise<Float32Array> {\n const vector = new Float32Array(dims);\n for (let i = 0; i < dims; i++) {\n // Map each hash into [-1, 1) so vectors spread over the sphere rather\n // than crowding one orthant.\n vector[i] = (fnv1a(text, i) / 0x1_00_00_00_00) * 2 - 1;\n }\n return Promise.resolve(vector);\n },\n };\n}\n","/**\n * Sample questions as findability checks (proposals 0086 §7 and 0087), the\n * half of `manni graph check` no shape can express.\n *\n * Questions are read from each page's source, not from the graph: an item's\n * answer pins and review state are test data, and never reach the graph. A\n * question is asked through the retrieval `graph search` uses by default:\n * `findEntry` over the lexical index, fused with the vector leg when a sidecar\n * and an embedder are present beside the graph. The lexical index is built in\n * memory from the graph, so no `export search` run is needed, and a question\n * is asked in its page's language's index.\n *\n * An unpinned question must find its page, or a section of it. A pinned\n * answer must find the node whose own text holds its lines. Each pin is first\n * compared with the page as it is now, under cite's hashing rule: an answer\n * that moved is checked at its new lines, and one that changed is not asked.\n *\n * A golden-set file (`graph.questionFiles`) holds questions that span pages\n * or that the docs don't answer. Each of its answers names its page, and is\n * asked as a page's pin is. Across both homes, a question asked twice and a\n * question that repeats its answer's words are reported, and the whole set's\n * health is summed up for `check` to print and gate on.\n *\n * It measures finding, not answering. Nothing here reaches a model beyond the\n * embedder `search` would use, and the same inputs give the same findings.\n */\nimport { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport GithubSlugger from \"github-slugger\";\nimport type { Store } from \"n3\";\nimport { locateFrontmatter } from \"../../meta/index.js\";\nimport {\n bodyLineOf,\n findWindows,\n pinOfLines,\n spellLines,\n splitLines,\n toFileLines,\n type PageLines,\n} from \"../../shared/pin.js\";\nimport type { Severity } from \"../../shared/severity.js\";\nimport { warn } from \"../../shared/warn.js\";\nimport {\n formatOf,\n type DocFormat,\n isTreeFormat,\n metadataOf,\n mintTreeSections,\n parseTree,\n} from \"../core/analyze.js\";\nimport type { GraphConfig } from \"../core/config.js\";\nimport { mergePage, openMetaView, type MetaViewSource } from \"../core/external.js\";\nimport { STDIN_PATH } from \"../core/iri.js\";\nimport { compactIri, storeToQuads } from \"../core/load.js\";\nimport {\n canonicalLanguageTag,\n LOCALIZATIONS_FILENAME,\n parseLocalizations,\n UNDETERMINED,\n type LocalizationEntry,\n} from \"../core/localizations.js\";\nimport {\n COPIED_SHARE,\n copiedPairs,\n questionKey,\n readQuestionFile,\n readSampleQuestions,\n type AnswerPin,\n type SampleQuestion,\n} from \"../core/questions.js\";\nimport {\n buildSearchIndex,\n emitSearchIndex,\n partitionByLanguage,\n type SearchIndexDoc,\n} from \"../core/search-index.js\";\nimport type { CheckFinding } from \"../core/shacl.js\";\nimport { byCodeUnit } from \"../core/sort.js\";\nimport { VectorIndexError } from \"../core/vector-index.js\";\nimport { NS, PREFIXES } from \"../core/vocab.js\";\nimport type { Embedder } from \"../embed/types.js\";\nimport type { WithholdReason } from \"../runtime/chunks.js\";\nimport { findEntry } from \"../runtime/entry.js\";\nimport { GraphIndex } from \"../runtime/graph.js\";\nimport { createLexicalIndex, type LexicalIndex } from \"../runtime/lexical.js\";\nimport { sectionOccurrences, sectionOwnLines } from \"../runtime/resolve.js\";\nimport {\n createVectorIndex,\n VectorMismatchError,\n type VectorIndex,\n} from \"../runtime/vector.js\";\nimport type { Position } from \"../../lint/types.js\";\nimport type { PassageBundle } from \"../runtime/retrieve.js\";\nimport { GraphError } from \"../types.js\";\nimport { resolveEmbedder } from \"./search.js\";\n\nconst DOCUMENT = `${NS.graph}Document`;\nconst SECTION = `${NS.graph}Section`;\nconst PATH = `${NS.graph}path`;\nconst LEVEL = `${NS.graph}level`;\nconst TITLE = `${NS.dcterms}title`;\nconst LANGUAGE = `${NS.dcterms}language`;\nexport const SAMPLE_QUESTION = `${NS.graph}sampleQuestion`;\nconst DOCUMENT_TYPE = compactIri(DOCUMENT);\nconst SECTION_TYPE = compactIri(SECTION);\n\n/** One language's retrieval: the lexical leg, and the vector leg when present. */\ninterface Retriever {\n lexical: LexicalIndex;\n vectors?: VectorIndex;\n embedder?: Embedder;\n}\n\n/** A page whose source is on disk, with the questions it declares. */\ninterface Page {\n doc: string;\n path: string;\n language: string;\n /** File line of body line 1, as cite counts it. */\n bodyLine: number;\n /** The body's lines, normalized as cite hashes them. */\n body: string[];\n /** Each section node in the graph, with the file lines its own text spans. */\n sections: { iri: string; span: PageLines }[];\n questions: SampleQuestion[];\n}\n\n/** The manifest `export search` and `embed` write beside the graph, if any. */\nfunction readManifest(indexDir: string): LocalizationEntry[] {\n const path = join(indexDir, LOCALIZATIONS_FILENAME);\n if (!existsSync(path)) return [];\n const manifest = parseLocalizations(readFileSync(path, \"utf8\"));\n if (!manifest) {\n throw new GraphError(\n `Not a manni graph localization manifest: ${path} — re-run \\`manni graph export search\\`.`,\n );\n }\n return manifest.languages;\n}\n\n/**\n * The lexical index, plus the vector leg when the manifest records a sidecar\n * for this language and an embedder loads. Every missing piece degrades to\n * lexical, as a plain `graph search` does. A sidecar built from another index\n * is refused with a warning, because its IRIs describe a different corpus.\n */\nasync function openRetriever(\n doc: SearchIndexDoc,\n entry: LocalizationEntry | undefined,\n indexDir: string,\n): Promise<Retriever> {\n const lexical = createLexicalIndex(doc);\n if (!entry?.vectors) return { lexical };\n const path = resolve(indexDir, entry.vectors.path);\n if (!existsSync(path)) return { lexical };\n let vectors: VectorIndex;\n try {\n vectors = createVectorIndex(readFileSync(path));\n } catch (e) {\n if (e instanceof VectorIndexError) {\n throw new GraphError(`${e.message} (${path}) — re-run \\`manni graph embed\\`.`);\n }\n throw e;\n }\n // The digest `export search` would record for this index, so a sidecar\n // embedded from the bytes it wrote is recognized as current.\n const source = `sha256:${createHash(\"sha256\").update(emitSearchIndex(doc), \"utf8\").digest(\"hex\")}`;\n const stale = vectors.check({ source });\n if (stale) {\n warn(`${stale.detail} Falling back to lexical.`);\n return { lexical };\n }\n const embedder = await resolveEmbedder(undefined, vectors, false);\n return embedder ? { lexical, vectors, embedder } : { lexical };\n}\n\n/** The documents and sections a question finds, best first. Concepts belong to no page. */\nasync function rankNodes(question: string, r: Retriever): Promise<string[]> {\n const entry = await findEntry(question, {\n lexical: r.lexical,\n ...(r.vectors && r.embedder ? { vectors: r.vectors, embedder: r.embedder } : {}),\n limit: r.lexical.size(),\n }).catch((e: unknown) => {\n if (e instanceof VectorMismatchError) {\n throw new GraphError(`${e.message} Re-run \\`manni graph embed\\`.`);\n }\n throw e;\n });\n return entry.candidates.flatMap((c) => {\n const type = r.lexical.entry(c.iri)?.type;\n return type === DOCUMENT_TYPE || type === SECTION_TYPE ? [c.iri] : [];\n });\n}\n\n/** The page a document or section node belongs to. */\nfunction pageOf(iri: string): string {\n const hash = iri.indexOf(\"#\");\n return hash < 0 ? iri : iri.slice(0, hash);\n}\n\n/** A node's last line: a half-open span that ends at column 1 ends on the line before. */\nfunction lastLine(position: Position): number {\n const { start, end } = position;\n return end.column <= 1 && end.line > start.line ? end.line - 1 : end.line;\n}\n\n/**\n * Each graph section of a page, with the file lines its own text spans: its\n * heading down to the next heading of any rank, as the search index slices it.\n */\nexport async function sectionSpans(\n graph: GraphIndex,\n doc: string,\n path: string,\n content: string,\n sections: readonly string[],\n): Promise<{ iri: string; span: PageLines }[]> {\n const format = formatOf(path);\n const out: { iri: string; span: PageLines }[] = [];\n if (isTreeFormat(format)) {\n const known = new Set(sections);\n const minted = mintTreeSections((await parseTree(content, path, format)).sections);\n for (const [n, section] of minted.sections.entries()) {\n const iri = `${doc}#${section.slug}`;\n const node = minted.nodes[n];\n if (!known.has(iri) || node === undefined) continue;\n const head = node.titlePosition ?? node.position;\n const end = Math.max(\n lastLine(head),\n ...(minted.owned[n] ?? []).map((c) => lastLine(c.position)),\n );\n out.push({ iri, span: { start: head.start.line, end } });\n }\n return out;\n }\n const occurrences = sectionOccurrences(graph, doc);\n for (const iri of sections) {\n const title = graph.literal(iri, TITLE);\n if (title === undefined) continue;\n const level = Number.parseInt(graph.literal(iri, LEVEL) ?? \"\", 10);\n const span = sectionOwnLines(\n content,\n title,\n Number.isNaN(level) ? undefined : level,\n occurrences.get(iri) ?? 0,\n );\n if (span) out.push({ iri, span });\n }\n return out;\n}\n\n/**\n * A page's body as answer pins count it: the file line of body line 1, and\n * the body's lines, normalized as cite hashes them. HTML and XML carry their\n * metadata inside the body, so body line 1 is file line 1, as cite counts it.\n */\nexport function bodyOf(content: string, format: DocFormat): { bodyLine: number; body: string[] } {\n const bodyLine =\n format === \"html\" || format === \"xml\"\n ? 1\n : bodyLineOf(content, locateFrontmatter(content)?.closeEnd ?? 0);\n return { bodyLine, body: splitLines(content).slice(bodyLine - 1) };\n}\n\n/** Where a pin's lines are now, judged against the page as it reads today. */\nexport type Freshness =\n | { state: \"current\" | \"moved\" | \"ambiguous\"; ranges: PageLines[] }\n | { state: \"changed\" };\n\nexport function freshness(body: readonly string[], pin: AnswerPin): Freshness {\n const { lines, integrity } = pin;\n if (integrity === undefined) {\n return lines.end <= body.length ? { state: \"current\", ranges: [lines] } : { state: \"changed\" };\n }\n if (pinOfLines(body, lines) === integrity) return { state: \"current\", ranges: [lines] };\n const length = lines.end - lines.start + 1;\n const { starts } = findWindows(body, length, integrity, undefined, { around: lines.start });\n const ranges = starts.map((start) => ({ start, end: start + length - 1 }));\n if (ranges.length === 0) return { state: \"changed\" };\n return { state: ranges.length === 1 ? \"moved\" : \"ambiguous\", ranges };\n}\n\n/** `lines 4 and 8 both match`, or `lines 4, 8 and 12 all match`. */\nexport function matchList(ranges: readonly PageLines[]): string {\n const spelled = ranges.map(spellLines);\n const head = spelled.slice(0, -1);\n const last = spelled[spelled.length - 1] ?? \"\";\n // An ambiguous pin always has two or more; one range still reads right.\n if (head.length === 0) return `lines ${last} match`;\n const both = head.length === 1 ? \"both\" : \"all\";\n return `lines ${head.join(\", \")} and ${last} ${both} match`;\n}\n\n/**\n * The pages of the graph that are on disk. `pages` holds each one that\n * declares a question; `pageAt` builds the record of any other, by its\n * absolute path, for a golden-set answer that points at it.\n */\nasync function readPages(\n graph: GraphIndex,\n sources: string,\n view: { source: MetaViewSource; cwd: string },\n verb: \"checked\" | \"exported\",\n): Promise<{\n pages: Page[];\n contents: Map<string, string>;\n pageAt: (abs: string) => Promise<Page | undefined>;\n}> {\n const contents = new Map<string, string>();\n const onDisk: { doc: string; path: string }[] = [];\n const byAbs = new Map<string, { doc: string; path: string }>();\n let missing = 0;\n for (const doc of graph.instancesOf(DOCUMENT)) {\n const path = graph.literal(doc, PATH);\n if (path === undefined || path === STDIN_PATH) continue;\n const abs = resolve(sources, path);\n if (!existsSync(abs)) {\n missing += 1;\n continue;\n }\n contents.set(path, readFileSync(abs, \"utf8\"));\n onDisk.push({ doc, path });\n byAbs.set(abs, { doc, path });\n }\n if (missing > 0) {\n warn(\n missing === 1\n ? `1 page in the graph is not on disk, so its questions were not ${verb}; run manni graph build.`\n : `${String(missing)} pages in the graph are not on disk, so their questions were not ${verb}; run manni graph build.`,\n );\n }\n\n const sectionsOf = new Map<string, string[]>();\n for (const section of graph.instancesOf(SECTION)) {\n const doc = pageOf(section);\n const siblings = sectionsOf.get(doc);\n if (siblings) siblings.push(section);\n else sectionsOf.set(doc, [section]);\n }\n\n const readRecord = async (doc: string, path: string, questions: SampleQuestion[]): Promise<Page> => {\n const content = contents.get(path) ?? \"\";\n const { bodyLine, body } = bodyOf(content, formatOf(path));\n const tag = graph.literal(doc, LANGUAGE);\n return {\n doc,\n path,\n language: tag === undefined ? UNDETERMINED : canonicalLanguageTag(tag),\n bodyLine,\n body,\n sections: await sectionSpans(graph, doc, path, content, sectionsOf.get(doc) ?? []),\n questions,\n };\n };\n // The promise is kept, so concurrent asks for one page share one record.\n const records = new Map<string, Promise<Page>>();\n const record = (doc: string, path: string, questions: SampleQuestion[]): Promise<Page> => {\n const known = records.get(doc);\n if (known) return known;\n const page = readRecord(doc, path, questions);\n records.set(doc, page);\n return page;\n };\n\n // The metadata `build` derives from: the page's own, merged with every key\n // a manifest of its collections owns.\n const meta = await openMetaView(view.source, view.cwd, onDisk.map((p) => p.path), sources);\n const pages: Page[] = [];\n for (const { doc, path } of onDisk) {\n const content = contents.get(path) ?? \"\";\n const format = formatOf(path);\n const own = metadataOf(content, path, format);\n const { data } = await mergePage(meta, path, own.data, own.present, format);\n const questions = readSampleQuestions(data[\"sample-questions\"]);\n if (questions.length > 0) pages.push(await record(doc, path, questions));\n }\n pages.sort((a, b) => byCodeUnit(a.path, b.path));\n return {\n pages,\n contents,\n pageAt: async (abs) => {\n const hit = byAbs.get(abs);\n return hit && (await record(hit.doc, hit.path, []));\n },\n };\n}\n\n/** The nodes of `page` whose own text holds any of `lines`, in file lines. */\nfunction holdersOf(page: Page, lines: PageLines): string[] {\n const out = page.sections\n .filter(({ span }) => span.start <= lines.end && lines.start <= span.end)\n .map(({ iri }) => iri);\n for (let line = lines.start; line <= lines.end; line++) {\n if (!page.sections.some(({ span }) => span.start <= line && line <= span.end)) {\n return [page.doc, ...out];\n }\n }\n return out;\n}\n\n/** How many of a kind of question are found, and how many first. */\nexport interface FoundCount {\n inTop: number;\n first: number;\n /** The questions with a test: a page, or at least one pin. */\n of: number;\n}\n\n/**\n * The health of the whole question set (proposal 0087 § 7b): what `check`\n * prints after its findings, and the `questions` key of its JSON report.\n */\nexport interface QuestionSummary {\n /** Every question, on pages and in golden-set files. */\n total: number;\n reviewed: number;\n drafted: number;\n /** Pages that declare at least one question. */\n pages: number;\n /** The golden-set files, as `graph.questionFiles` names them. */\n files: string[];\n top: number;\n found: { reviewed: FoundCount; drafted: FoundCount };\n answers: {\n /**\n * Every pin. It can exceed current + moved + changed by the golden-set\n * answers whose page is on disk but in no collection: their freshness\n * cannot be read, and their own findings say why.\n */\n pinned: number;\n /** Pins on a drafted question, or marked `reviewed: false` themselves. */\n unreviewed: number;\n current: number;\n /** Moved to one place or, ambiguously, to several. */\n moved: number;\n /** Changed, or on a page that does not exist. */\n changed: number;\n /** Page questions with no pin, which must find the page itself. */\n unpinned: number;\n };\n /** Golden-set questions with no answers: questions the docs don't answer. */\n gaps: number;\n /**\n * Reviewed questions `graph retrieve` cites an answer for, of\n * `found.reviewed.of` (proposal 0090). Absent when the row did not run.\n */\n cited?: number;\n /** Reviewed questions not cited because `graph.retrieve.withhold` left their answer out. */\n withheld?: number;\n}\n\n/**\n * What the cited row asks through: `graph retrieve` over the chunk artifact\n * beside the graph, and the passages its export withheld.\n */\nexport interface CiteSeam {\n /** The bundle for a question in a language, or `undefined` when the artifact holds no such language. */\n retrieve(question: string, language: string): Promise<PassageBundle | undefined>;\n withheld: ReadonlyMap<string, WithholdReason[]>;\n}\n\n/**\n * A percentage, rounded down so a rate under a threshold never prints as it.\n * None of none is 0%: the summary reads as health, and nothing found is not\n * full marks. The rate gate guards an empty set on its own.\n */\nfunction percent(part: number, of: number): number {\n return of === 0 ? 0 : Math.floor((part / of) * 100);\n}\n\nfunction plural(n: number, word: string): string {\n return `${String(n)} ${word}${n === 1 ? \"\" : \"s\"}`;\n}\n\n/** `a`, `a and b`, or `a, b and c`. */\nfunction listOf(items: readonly string[]): string {\n const head = items.slice(0, -1);\n const last = items[items.length - 1] ?? \"\";\n return head.length === 0 ? last : `${head.join(\", \")} and ${last}`;\n}\n\n/** The health summary as `check` prints it, one line per row. */\nexport function renderQuestionSummary(s: QuestionSummary): string[] {\n const homes = [\n ...(s.pages > 0 ? [`on ${plural(s.pages, \"page\")}`] : []),\n ...(s.files.length > 0 ? [`in ${listOf(s.files)}`] : []),\n ];\n const { reviewed, drafted } = s.found;\n const a = s.answers;\n return [\n `questions ${String(s.total)}: ${String(s.reviewed)} reviewed, ${String(s.drafted)} drafted${homes.length > 0 ? `, ${homes.join(\" and \")}` : \"\"}`,\n ` found ${String(reviewed.inTop)} of ${String(reviewed.of)} reviewed in the top ${String(s.top)} (${String(percent(reviewed.inTop, reviewed.of))}%), ${String(reviewed.first)} first (${String(percent(reviewed.first, reviewed.of))}%)`,\n ...(s.cited === undefined\n ? []\n : [\n ` cited ${String(s.cited)} of ${String(reviewed.of)} reviewed by graph retrieve (${String(percent(s.cited, reviewed.of))}%)${s.withheld ? `, ${String(s.withheld)} withheld` : \"\"}`,\n ]),\n ...(drafted.of > 0\n ? [` drafted ${String(drafted.inTop)} of ${String(drafted.of)} in the top ${String(s.top)}, not counted until reviewed`]\n : []),\n ` answers ${String(a.pinned)} pinned, ${String(a.unreviewed)} not reviewed: ${String(a.current)} current, ${String(a.moved)} moved, ${String(a.changed)} changed; ${String(a.unpinned)} not pinned`,\n ...(s.gaps > 0 ? [` gaps ${plural(s.gaps, \"question\")} the docs don't answer`] : []),\n ];\n}\n\n/** Where a question's findings go. */\ninterface Target {\n focusNode: string;\n path?: string;\n docs: string[];\n}\n\n/** A finding on one question: `knob` takes `questions.severity`, and a draft reports at notice. */\ntype Report = (kind: \"knob\" | Severity, message: string, draft?: \"question\" | \"pin\") => void;\n\n/**\n * The findings for every page's sample questions and every golden-set file's\n * questions, with the health summary of the whole set. `sources` is where\n * each page's `graph:path` resolves from, `indexDir` is where a vector\n * sidecar's manifest sits, and `view` is the config meta's merge reads.\n * `questionFiles` are the golden-set files, and they and their answers'\n * `file`s resolve from `configDir`. The summary is absent when no question\n * exists. `cite` opens the cited row's seam on first use, and a `GraphError`\n * from it skips the row with a notice.\n */\nexport async function askSampleQuestions(\n store: Store,\n settings: GraphConfig[\"check\"][\"questions\"],\n sources: string,\n indexDir: string,\n view: { source: MetaViewSource; cwd: string },\n questionFiles: readonly string[],\n configDir: string,\n cite?: () => CiteSeam | Promise<CiteSeam>,\n): Promise<{ findings: CheckFinding[]; summary?: QuestionSummary }> {\n const knob = settings.severity;\n const top = settings.top;\n // A golden-set file that cannot be read is an operational error, said\n // before any page is read.\n const sets = questionFiles.map((label) => ({\n label,\n questions: readQuestionFile(resolve(configDir, label), label),\n }));\n const graph = GraphIndex.fromQuads(storeToQuads(store), Object.fromEntries(PREFIXES));\n const { pages, contents, pageAt } = await readPages(graph, sources, view, \"checked\");\n const total =\n pages.reduce((n, p) => n + p.questions.length, 0) +\n sets.reduce((n, f) => n + f.questions.length, 0);\n if (total === 0) return { findings: [] };\n\n // Built on first use: a set of nothing but gaps asks nothing.\n let byLanguage: Map<string, SearchIndexDoc> | undefined;\n let manifest: LocalizationEntry[] = [];\n const retrievers = new Map<string, Retriever>();\n const ranked = new Map<string, string[]>();\n const rank = async (language: string, question: string): Promise<string[]> => {\n const key = JSON.stringify([language, question]);\n const cached = ranked.get(key);\n if (cached) return cached;\n if (byLanguage === undefined) {\n // Missing pages were said once already, so the index's own warnings go.\n byLanguage = partitionByLanguage(\n graph,\n await buildSearchIndex(graph, sources, { readDoc: (p) => contents.get(p) }),\n );\n manifest = readManifest(indexDir);\n }\n let retriever = retrievers.get(language);\n if (!retriever) {\n retriever = await openRetriever(\n byLanguage.get(language) ?? { version: 1, entries: [] },\n manifest.find((l) => canonicalLanguageTag(l.language) === language),\n indexDir,\n );\n retrievers.set(language, retriever);\n }\n const nodes = await rankNodes(question, retriever);\n ranked.set(key, nodes);\n return nodes;\n };\n\n const describe = (iri: string): string => {\n const path = graph.literal(pageOf(iri), PATH) ?? pageOf(iri);\n const title = iri.includes(\"#\") ? graph.literal(iri, TITLE) : undefined;\n return title === undefined ? path : `${path} § ${title}`;\n };\n const where = (position: number, first: string | undefined): string =>\n [\n position === 0 ? \"it is not found\" : `it ranks ${String(position)}`,\n ...(first === undefined ? [] : [`first is ${describe(first)}`]),\n ].join(\"; \");\n\n const findings: CheckFinding[] = [];\n const reporter =\n (target: Target): Report =>\n (kind, message, draft) => {\n const level = kind === \"knob\" ? knob : kind;\n if (level === \"off\") return;\n const suffix =\n draft === \"question\" ? \" (drafted, not reviewed)\" : draft === \"pin\" ? \" (answer not reviewed)\" : \"\";\n findings.push({\n severity: draft ? \"notice\" : level,\n message: `${message}${suffix}`,\n focusNode: target.focusNode,\n ...(target.path === undefined ? {} : { path: target.path }),\n docs: target.docs,\n // A retrieval check judges a question, not a shape.\n guidance: null,\n });\n };\n\n const empty = (): FoundCount => ({ inTop: 0, first: 0, of: 0 });\n const summary: QuestionSummary = {\n total,\n reviewed: 0,\n drafted: 0,\n pages: pages.length,\n files: [...questionFiles],\n top,\n found: { reviewed: empty(), drafted: empty() },\n answers: { pinned: 0, unreviewed: 0, current: 0, moved: 0, changed: 0, unpinned: 0 },\n gaps: 0,\n };\n /** Counts one question's outcome: `tests` holds each counted test's position, 0 when missed. */\n const tally = (reviewed: boolean, tests: readonly number[]): void => {\n if (tests.length === 0) return;\n const count = reviewed ? summary.found.reviewed : summary.found.drafted;\n count.of += 1;\n if (tests.every((p) => p >= 1 && p <= top)) count.inTop += 1;\n if (tests.every((p) => p === 1)) count.first += 1;\n };\n\n /**\n * One pin on `page`: its freshness first, then whether the top `top` holds\n * a node whose own text holds its lines. `file` is the page as a golden-set\n * item names it, absent for a page's own question. Returns the best\n * position, 0 when the answer changed or is not found, and the answer's\n * text as it reads now.\n */\n const askPin = async (\n page: Page,\n pin: AnswerPin,\n question: string,\n language: string,\n report: Report,\n draft: \"question\" | \"pin\" | undefined,\n file?: string,\n ): Promise<{ position: number; text?: string; answering: string[] }> => {\n const fresh = freshness(page.body, pin);\n if (fresh.state === \"changed\") {\n summary.answers.changed += 1;\n // `fill` re-pairs a page's own question. A golden-set file's is a\n // person's to re-pin, because fill only moves its lines.\n const of = file === undefined ? \"\" : ` of ${file}`;\n const fix =\n file === undefined\n ? \"re-pair it with manni graph fill --fields sample-questions and review it\"\n : \"re-pin it and review it\";\n report(\n \"knob\",\n `lines ${spellLines(pin.lines)}${of} no longer hold the answer to \"${question}\" as pinned, so ${fix}.`,\n draft,\n );\n return { position: 0, answering: [] };\n }\n const [range] = fresh.ranges;\n const inFile = file === undefined ? \"\" : ` in ${file}`;\n if (fresh.state === \"current\") summary.answers.current += 1;\n else summary.answers.moved += 1;\n if (fresh.state === \"moved\" && range) {\n report(\n \"notice\",\n `the answer to \"${question}\"${inFile} moved from lines ${spellLines(pin.lines)} to ${spellLines(range)}, so manni graph fill --fields sample-questions re-pins it.`,\n draft,\n );\n } else if (fresh.state === \"ambiguous\") {\n report(\n \"warning\",\n `the answer to \"${question}\"${inFile} moved, and ${matchList(fresh.ranges)}, so pin one of them by hand.`,\n draft,\n );\n }\n const text = range ? page.body.slice(range.start - 1, range.end).join(\"\\n\") : undefined;\n const nodes = await rank(language, question);\n const answering = fresh.ranges.flatMap((r) => holdersOf(page, toFileLines(r, page.bodyLine)));\n const positions = answering.map((iri) => nodes.indexOf(iri) + 1);\n // The best-ranked node that holds the answer, else the one holding its\n // first line.\n const best = positions.reduce(\n (b, p, i) => (p >= 1 && (b.p === 0 || p < b.p) ? { p, i } : b),\n { p: 0, i: 0 },\n );\n const found = { position: best.p, answering, ...(text === undefined ? {} : { text }) };\n if (best.p >= 1 && best.p <= top) return found;\n const holder = answering[best.i];\n if (holder !== undefined) {\n const title = holder.includes(\"#\") ? graph.literal(holder, TITLE) : undefined;\n const target =\n file !== undefined\n ? `does not find ${describe(holder)}`\n : title === undefined\n ? \"does not find this page, whose own text answers it,\"\n : `does not find the section that answers it, § ${title},`;\n report(\"knob\", `\"${question}\" ${target} in the top ${String(top)} (${where(best.p, nodes[0])})`, draft);\n }\n return found;\n };\n\n // The cited row (proposal 0090): each reviewed question asked through\n // `graph retrieve`, in its own language. `targets` holds, per counted test,\n // the nodes that answer it, and a question is cited when every test has\n // one among the bundle's citations. An empty test, an answer that changed\n // or a page that is gone, is not cited, and its own finding says why.\n // An object, since the seam opens inside `askCited` and flow analysis reads only this scope.\n const row: { seam: CiteSeam | null | undefined } = { seam: cite ? undefined : null };\n let citedCount = 0;\n let withheldCount = 0;\n const languageOf = (iri: string): string | undefined => {\n const tag = graph.literal(pageOf(iri), LANGUAGE);\n return tag === undefined ? undefined : canonicalLanguageTag(tag);\n };\n const askCited = async (question: string, language: string, targets: string[][], report: Report): Promise<void> => {\n if (row.seam === undefined && cite) {\n try {\n row.seam = await cite();\n } catch (e) {\n if (!(e instanceof GraphError)) throw e;\n row.seam = null;\n findings.push({\n severity: \"notice\",\n message: `the cited row did not run: ${e.message}`,\n focusNode: \"questions\",\n docs: [],\n guidance: null,\n });\n }\n }\n const seam = row.seam;\n if (!seam) return;\n const bundle = await seam.retrieve(question, language);\n const cites = bundle?.citations.map((c) => c.iri) ?? [];\n const leak = cites.find((iri) => {\n const l = languageOf(iri);\n return l !== undefined && l !== UNDETERMINED && l !== language;\n });\n if (leak !== undefined) {\n const page = graph.literal(pageOf(leak), PATH) ?? pageOf(leak);\n report(\"error\", `\"${question}\" asks in ${language}, and graph retrieve cites ${page}, which is ${languageOf(leak) ?? \"\"}.`);\n return;\n }\n if (targets.every((t) => t.some((iri) => cites.includes(iri)))) {\n citedCount += 1;\n return;\n }\n // Deliberate: any empty test (a changed answer pin) leaves the question unclassified, even when\n // another test is withheld. That pin's own finding is the one to fix first, and the withheld\n // count would only describe a question whose answers are not yet settled.\n if (targets.some((t) => t.length === 0)) return;\n const held = targets.flat().find((iri) => seam.withheld.has(iri));\n if (held !== undefined) {\n withheldCount += 1;\n const title = held.includes(\"#\") ? graph.literal(held, TITLE) : undefined;\n const what = title === undefined ? (graph.literal(pageOf(held), PATH) ?? pageOf(held)) : `§ ${title}`;\n const because = listOf(seam.withheld.get(held) ?? []);\n report(\"knob\", `\"${question}\" is not cited by graph retrieve, because graph.retrieve.withhold left out ${what} as ${because}.`);\n return;\n }\n const first = cites[0];\n report(\n \"knob\",\n first === undefined\n ? `\"${question}\" is not cited by graph retrieve, which cites nothing for it.`\n : `\"${question}\" is not cited by graph retrieve, which cites ${describe(first)} first.`,\n );\n };\n\n /** A question that repeats over half its answer's word pairs tests matching more than finding. */\n const copies = (question: string, said: string[], report: Report, draft: \"question\" | undefined): void => {\n const m = said.length === 0 ? undefined : copiedPairs(question, ...said);\n if (m && m.copied / m.of > COPIED_SHARE) {\n report(\n \"notice\",\n `\"${question}\" repeats ${String(m.copied)} of its ${String(m.of)} word pairs from its answer, so it tests matching words more than finding.`,\n draft,\n );\n }\n };\n\n /** Every copy of every question, for duplicates: where it is asked, and its finding's home. */\n const asked: { key: string; where: string; order: number; text: string; report: Report; draft?: \"question\" }[] = [];\n\n for (const page of pages) {\n const report = reporter({ focusNode: page.doc, path: SAMPLE_QUESTION, docs: [page.path] });\n for (const [n, q] of page.questions.entries()) {\n const drafted = q.reviewed ? undefined : (\"question\" as const);\n if (q.reviewed) summary.reviewed += 1;\n else summary.drafted += 1;\n asked.push({ key: questionKey(q.question), where: page.path, order: n, text: q.question, report, ...(drafted ? { draft: drafted } : {}) });\n if (q.answers.length === 0) summary.answers.unpinned += 1;\n const tests: number[] = [];\n const targets: string[][] = [];\n // 0086's test: an unpinned question, or a confirmed one whose every\n // pin is still a draft, must find the page itself. A drafted question\n // with any pin skips it and goes straight to the pin checks, which\n // report at notice through `drafted`.\n if (q.answers.length === 0 || (q.reviewed && q.answers.every((a) => !a.reviewed))) {\n targets.push([page.doc, ...page.sections.map((s) => s.iri)]);\n const nodes = await rank(page.language, q.question);\n const pagesFound = [...new Set(nodes.map(pageOf))];\n const position = pagesFound.indexOf(page.doc) + 1;\n tests.push(position);\n if (position < 1 || position > top) {\n report(\n \"knob\",\n `\"${q.question}\" does not find this page in the top ${String(top)} (${where(position, pagesFound[0])})`,\n drafted,\n );\n }\n }\n const said: string[] = [];\n for (const pin of q.answers) {\n const draft = drafted ?? (pin.reviewed ? undefined : \"pin\");\n summary.answers.pinned += 1;\n if (draft) summary.answers.unreviewed += 1;\n const { position, text, answering } = await askPin(page, pin, q.question, page.language, report, draft);\n if (text !== undefined) said.push(text);\n // A drafted pin on a confirmed question is reported, not counted.\n if (draft !== \"pin\") {\n tests.push(position);\n targets.push(answering);\n }\n }\n copies(q.question, said, report, drafted);\n tally(q.reviewed, tests);\n if (q.reviewed && tests.length > 0) await askCited(q.question, page.language, targets, report);\n }\n }\n\n for (const set of sets) {\n for (const [n, q] of set.questions.entries()) {\n const report = reporter({ focusNode: `${set.label}:${String(q.line)}`, docs: [set.label] });\n const drafted = q.reviewed ? undefined : (\"question\" as const);\n if (q.reviewed) summary.reviewed += 1;\n else summary.drafted += 1;\n asked.push({ key: questionKey(q.question), where: set.label, order: n, text: q.question, report, ...(drafted ? { draft: drafted } : {}) });\n // A known gap: search has no score floor, so \"finds nothing\" is no test.\n if (q.answers.length === 0) {\n summary.gaps += 1;\n continue;\n }\n const [firstAnswer] = q.answers;\n const firstPage = firstAnswer && (await pageAt(resolve(configDir, firstAnswer.file)));\n const language =\n q.language !== undefined ? canonicalLanguageTag(q.language) : (firstPage?.language ?? UNDETERMINED);\n const tests: number[] = [];\n const targets: string[][] = [];\n const said: string[] = [];\n for (const pin of q.answers) {\n const draft = drafted ?? (pin.reviewed ? undefined : \"pin\");\n summary.answers.pinned += 1;\n if (draft) summary.answers.unreviewed += 1;\n const abs = resolve(configDir, pin.file);\n const page = await pageAt(abs);\n if (page === undefined) {\n if (existsSync(abs)) {\n // On disk, but in no collection the graph was built from. Its\n // freshness cannot be read without the page's graph record, so the\n // pin counts in no freshness bucket, and pinned can exceed\n // current + moved + changed by these. Its finding says why.\n const nodes = await rank(language, q.question);\n report(\"knob\", `\"${q.question}\" does not find ${pin.file} in the top ${String(top)} (${where(0, nodes[0])})`, draft);\n } else {\n summary.answers.changed += 1;\n report(\n \"knob\",\n `${pin.file}, which holds the answer to \"${q.question}\", does not exist, so re-pin or remove the question.`,\n draft,\n );\n }\n if (draft !== \"pin\") {\n tests.push(0);\n targets.push([]);\n }\n continue;\n }\n const { position, text, answering } = await askPin(page, pin, q.question, language, report, draft, pin.file);\n if (text !== undefined) said.push(text);\n if (draft !== \"pin\") {\n tests.push(position);\n targets.push(answering);\n }\n }\n copies(q.question, said, report, drafted);\n tally(q.reviewed, tests);\n if (q.reviewed && tests.length > 0) await askCited(q.question, language, targets, report);\n }\n }\n\n // Duplicates: each copy after the first, in path order, names the first.\n asked.sort((a, b) => byCodeUnit(a.where, b.where) || a.order - b.order);\n const firstAt = new Map<string, string>();\n for (const copy of asked) {\n if (copy.key === \"\") continue;\n const first = firstAt.get(copy.key);\n if (first === undefined) firstAt.set(copy.key, copy.where);\n else copy.report(\"knob\", `\"${copy.text}\" is also asked on ${first}, so keep it where it is answered.`, copy.draft);\n }\n\n // The rate gate. questions.severity does not touch it.\n const threshold = settings.foundThreshold;\n const { inTop, of } = summary.found.reviewed;\n if (threshold !== null && of > 0 && (inTop / of) * 100 < threshold) {\n findings.push({\n severity: \"error\",\n message: `${String(inTop)} of ${String(of)} reviewed questions are found in the top ${String(top)} (${String(percent(inTop, of))}%), under the ${String(threshold)}% that graph.check.questions.foundThreshold asks for.`,\n focusNode: \"questions\",\n docs: [],\n guidance: null,\n });\n }\n\n // The cited row and its gate, only when the row ran.\n if (row.seam) {\n summary.cited = citedCount;\n summary.withheld = withheldCount;\n const cited = settings.citedThreshold;\n if (cited !== null && of > 0 && (citedCount / of) * 100 < cited) {\n findings.push({\n severity: \"error\",\n message: `${String(citedCount)} of ${String(of)} reviewed questions are cited by graph retrieve (${String(percent(citedCount, of))}%), under the ${String(cited)}% that graph.check.questions.citedThreshold asks for.`,\n focusNode: \"questions\",\n docs: [],\n guidance: null,\n });\n }\n }\n return { findings, summary };\n}\n\n/** One answer of an exported question: the node that holds it, and its text as it reads now. */\ninterface ExportedAnswer {\n id?: string;\n file: string;\n lines?: string;\n reviewed: boolean;\n stale?: true;\n text?: string;\n}\n\n/**\n * The golden set as `graph export questions` writes it (proposal 0087 § 7d):\n * one JSON line per question, each page's in path order, then each golden-set\n * file's. An answer's `id` is the node `export search` indexes its first line\n * under, so an index built from that export returns comparable ids. Its text\n * is rendered from the pin, as the page reads now. A changed answer, or one\n * whose page is gone, is marked stale and counted.\n */\nexport async function exportSampleQuestions(\n store: Store,\n sources: string,\n view: { source: MetaViewSource; cwd: string },\n questionFiles: readonly string[],\n configDir: string,\n): Promise<{ lines: string[]; stale: number }> {\n const sets = questionFiles.map((label) => ({\n label,\n questions: readQuestionFile(resolve(configDir, label), label),\n }));\n const graph = GraphIndex.fromQuads(storeToQuads(store), Object.fromEntries(PREFIXES));\n const { pages, pageAt } = await readPages(graph, sources, view, \"exported\");\n let stale = 0;\n\n const pinned = (page: Page, file: string, pin: AnswerPin, reviewed: boolean): ExportedAnswer => {\n const fresh = freshness(page.body, pin);\n const range = fresh.state === \"changed\" ? pin.lines : (fresh.ranges[0] ?? pin.lines);\n if (fresh.state === \"changed\") stale += 1;\n const first = toFileLines({ start: range.start, end: range.start }, page.bodyLine);\n const text = page.body.slice(range.start - 1, range.end).join(\"\\n\");\n return {\n id: holdersOf(page, first)[0] ?? page.doc,\n file,\n lines: spellLines(range),\n reviewed,\n ...(fresh.state === \"changed\" ? { stale: true as const } : {}),\n ...(text === \"\" ? {} : { text }),\n };\n };\n\n const lines: string[] = [];\n const write = (\n id: string,\n question: string,\n language: string,\n reviewed: boolean,\n expected: ExportedAnswer[],\n ): void => {\n lines.push(\n JSON.stringify({ id, question, language, reviewed, answerable: expected.length > 0, expected }),\n );\n };\n\n for (const page of pages) {\n // A question asked twice on one page still gets an id of its own.\n const slugger = new GithubSlugger();\n for (const q of page.questions) {\n const expected =\n q.answers.length === 0\n ? [{ id: page.doc, file: page.path, reviewed: q.reviewed }]\n : q.answers.map((pin) => pinned(page, page.path, pin, q.reviewed && pin.reviewed));\n write(`${page.path}#${slugger.slug(q.question)}`, q.question, page.language, q.reviewed, expected);\n }\n }\n\n for (const set of sets) {\n const slugger = new GithubSlugger();\n for (const q of set.questions) {\n const expected = await Promise.all(q.answers.map(async (pin): Promise<ExportedAnswer> => {\n const reviewed = q.reviewed && pin.reviewed;\n const abs = resolve(configDir, pin.file);\n const page = await pageAt(abs);\n if (page) return pinned(page, pin.file, pin, reviewed);\n // A page outside the graph has no node to name, and its freshness is\n // not checked, since that needs the page's graph record. A page that\n // is gone is stale.\n const gone = !existsSync(abs);\n if (gone) stale += 1;\n return { file: pin.file, lines: spellLines(pin.lines), reviewed, ...(gone ? { stale: true as const } : {}) };\n }));\n const [firstAnswer] = q.answers;\n const firstPage = firstAnswer && (await pageAt(resolve(configDir, firstAnswer.file)));\n const language =\n q.language !== undefined ? canonicalLanguageTag(q.language) : (firstPage?.language ?? UNDETERMINED);\n write(`${set.label}#${slugger.slug(q.question)}`, q.question, language, q.reviewed, expected);\n }\n }\n return { lines, stale };\n}\n","/**\n * The lexical search artifact (ADR 01019) — `graph/search.<lang>.json`, a sibling\n * of the graph rather than prose inside it. One file per language since\n * ADR 01038; this module builds the whole index and partitions it.\n *\n * The graph is an index, not a corpus (ADR 01008): sections carry only titles,\n * so a lexical index built from the graph alone cannot find anything a document\n * actually *says*. This module walks the built graph, reads each document's\n * markdown from disk (the same pattern the iiRDS projection uses for\n * renditions), and emits a deterministic JSON index the browser runtime loads in\n * one fetch.\n *\n * Granularity golden rule: **every node indexes exactly the text it owns.** A\n * Section carries its own text down to the next heading of any rank; a Document\n * carries title + description plus the prose no section covers (its preamble,\n * or its whole body when it has no sections). Duplicating would let a node\n * shadow the nodes beneath it in the rankings; carrying nothing would leave\n * that prose findable nowhere.\n *\n * Slicing reuses the runtime's own functions, so index-time and retrieval-time\n * text cannot drift — with one deliberate difference: retrieval uses\n * `sliceSection` (subtree included, because asking for a section should give\n * you its subsections), indexing uses `sectionOwnText`.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { compactIri } from \"./load.js\";\nimport { byCodeUnit } from \"./sort.js\";\nimport { NS } from \"./vocab.js\";\nimport { canonicalLanguageTag, UNDETERMINED } from \"./localizations.js\";\nimport type { GraphIndex } from \"../runtime/graph.js\";\nimport type { ContentNode } from \"../../lint/types.js\";\nimport { formatOf, mintTreeSections, parseTree } from \"./analyze.js\";\nimport {\n documentPreamble,\n sectionOccurrences,\n sectionOwnText,\n} from \"../runtime/resolve.js\";\n\nconst GRAPH_DOCUMENT = `${NS.graph}Document`;\nconst GRAPH_SECTION = `${NS.graph}Section`;\nconst SKOS_CONCEPT = `${NS.skos}Concept`;\nconst GRAPH_PATH = `${NS.graph}path`;\nconst GRAPH_LEVEL = `${NS.graph}level`;\nconst DCTERMS_TITLE = `${NS.dcterms}title`;\nconst DCTERMS_DESCRIPTION = `${NS.dcterms}description`;\nconst SKOS_PREF_LABEL = `${NS.skos}prefLabel`;\nconst SKOS_ALT_LABEL = `${NS.skos}altLabel`;\nconst DCTERMS_LANGUAGE = `${NS.dcterms}language`;\n\n/** One indexable node. Empty fields are omitted so the artifact stays tight. */\nexport interface SearchEntry {\n /** Node IRI. */\n id: string;\n /** Compacted class IRI, e.g. `graph:Section`. */\n type: string;\n title?: string;\n /** Space-joined alternative labels, deduped case-insensitively. */\n labels?: string;\n description?: string;\n /** Body text, per the granularity rule. */\n text?: string;\n}\n\nexport interface SearchIndexDoc {\n version: 1;\n entries: SearchEntry[];\n}\n\nexport interface SearchIndexOptions {\n /** Read a document's source. Defaults to reading `cwd`-relative from disk. */\n readDoc?: (path: string) => string | undefined;\n /** Warnings channel (missing sources are non-fatal — the entry loses text). */\n warnings?: string[];\n}\n\n/** Space-join labels, dropping case-insensitive duplicates, sorted. */\nfunction joinLabels(values: string[]): string | undefined {\n const seen = new Map<string, string>();\n for (const v of values) {\n const key = v.trim().toLowerCase();\n if (key && !seen.has(key)) seen.set(key, v.trim());\n }\n const out = [...seen.values()].sort(byCodeUnit);\n return out.length > 0 ? out.join(\" \") : undefined;\n}\n\n/**\n * A leading YAML frontmatter block, and the blank lines after it.\n *\n * Only a document with *no* sections gets body text, and its body is the whole\n * file — frontmatter included, unless it is stripped here. That block is\n * machinery, not prose: left in, a query for `label` or `alt-labels` matches\n * every sectionless document, and the artifact carries YAML nobody can read.\n * Section slices start at their heading, so they never see it.\n */\nconst FRONTMATTER =\n /^---[ \\t]*\\r?\\n(?:[\\s\\S]*?\\r?\\n)?(?:---|\\.\\.\\.)[ \\t]*(?:\\r?\\n|$)(?:\\r?\\n)*/;\n\nfunction stripFrontmatter(markdown: string): string {\n return markdown.replace(FRONTMATTER, \"\");\n}\n\n/** A non-Markdown document's text, per node, read from lint's tree. */\ninterface TreeText {\n /** The prose no section owns: the lead's, or the whole body when sectionless. */\n doc: string | undefined;\n /** Each section's own prose, by its anchor. */\n sections: Map<string, string>;\n}\n\n/** Content nodes' plain text, one block each, LF only. */\nfunction plainText(nodes: readonly ContentNode[]): string[] {\n return nodes\n .map((n) => n.text.replace(/\\r\\n/g, \"\\n\").trim())\n .filter((t) => t !== \"\");\n}\n\n/**\n * The text a non-Markdown document's nodes own, or undefined for Markdown and\n * MDX, which keep the line slicers their goldens pin. Sections are minted by\n * the analyzer's own function, so each text lands on the anchor `build` gave\n * that section. A section's text starts with its title, as a Markdown slice\n * starts at its heading line.\n */\nasync function treeText(source: string, path: string): Promise<TreeText | undefined> {\n const format = formatOf(path);\n if (format === \"markdown\" || format === \"mdx\") return undefined;\n const minted = mintTreeSections((await parseTree(source, path, format)).sections);\n const sections = new Map<string, string>();\n for (const [n, section] of minted.sections.entries()) {\n const own = plainText(minted.owned[n] ?? []);\n sections.set(section.slug, [section.title, ...own].join(\"\\n\\n\"));\n }\n const lead = plainText(minted.unowned);\n return { doc: lead.length > 0 ? lead.join(\"\\n\\n\") : undefined, sections };\n}\n\n/** Drop undefined fields so entries serialize identically for equal inputs. */\nfunction entry(\n id: string,\n type: string,\n fields: Omit<SearchEntry, \"id\" | \"type\">,\n): SearchEntry {\n const out: SearchEntry = { id, type };\n if (fields.title !== undefined) out.title = fields.title;\n if (fields.labels !== undefined) out.labels = fields.labels;\n if (fields.description !== undefined) out.description = fields.description;\n if (fields.text !== undefined) out.text = fields.text;\n return out;\n}\n\nexport async function buildSearchIndex(\n graph: GraphIndex,\n cwd: string,\n options: SearchIndexOptions = {},\n): Promise<SearchIndexDoc> {\n const warnings = options.warnings ?? [];\n const readDoc =\n options.readDoc ??\n ((path: string): string | undefined => {\n const abs = resolve(cwd, path);\n return existsSync(abs) ? readFileSync(abs, \"utf8\") : undefined;\n });\n\n const entries: SearchEntry[] = [];\n const sourceOf = new Map<string, string | undefined>();\n const treeTextOf = new Map<string, TreeText>();\n\n // Group sections by their parent document once. Re-scanning every section per\n // document is quadratic across the corpus, and the section loop below needs\n // the same grouping anyway.\n const allSections = graph.instancesOf(GRAPH_SECTION);\n const sectionsOf = new Map<string, string[]>();\n for (const section of allSections) {\n const hash = section.indexOf(\"#\");\n if (hash < 0) continue;\n const doc = section.slice(0, hash);\n const siblings = sectionsOf.get(doc);\n if (siblings) siblings.push(section);\n else sectionsOf.set(doc, [section]);\n }\n\n // Documents. Sections resolve their slice from the parent's source, so read\n // each document once and remember it.\n for (const doc of graph.instancesOf(GRAPH_DOCUMENT)) {\n const path = graph.literal(doc, GRAPH_PATH);\n const source = path === undefined ? undefined : readDoc(path);\n sourceOf.set(doc, source);\n if (path !== undefined && source === undefined) {\n warnings.push(\n `Source not found for ${path} — indexed without body text.`,\n );\n }\n\n // Granularity rule: a section owns its slice, so a document with sections\n // keeps only the prose that belongs to no section — the preamble before the\n // first heading. Without this, that text is indexed nowhere and is\n // unfindable. A document with no sections owns its whole body.\n // Newlines normalized to LF: section slices and `documentPreamble` already\n // re-join on \"\\n\", so without this a sectionless CRLF document is the one\n // entry in the artifact carrying \"\\r\\n\".\n const tree =\n source === undefined || path === undefined\n ? undefined\n : await treeText(source, path);\n if (tree) treeTextOf.set(doc, tree);\n const body =\n source === undefined\n ? undefined\n : stripFrontmatter(source).replace(/\\r\\n/g, \"\\n\");\n const text = tree\n ? tree.doc\n : body === undefined\n ? undefined\n : (sectionsOf.get(doc)?.length ?? 0) > 0\n ? documentPreamble(body)\n : body;\n\n entries.push(\n entry(doc, compactIri(GRAPH_DOCUMENT), {\n title: graph.literal(doc, DCTERMS_TITLE),\n description: graph.literal(doc, DCTERMS_DESCRIPTION),\n text,\n }),\n );\n }\n\n // Sections: title plus the slice of the parent document they own. Occurrences\n // are per-document, so compute each document's map once.\n const occurrencesOf = new Map<string, Map<string, number>>();\n for (const section of allSections) {\n const hash = section.indexOf(\"#\");\n const doc = hash < 0 ? section : section.slice(0, hash);\n const title = graph.literal(section, DCTERMS_TITLE);\n const source = sourceOf.get(doc);\n const levelText = graph.literal(section, GRAPH_LEVEL);\n const parsed =\n levelText === undefined ? NaN : Number.parseInt(levelText, 10);\n const level = Number.isNaN(parsed) ? undefined : parsed;\n\n let occurrences = occurrencesOf.get(doc);\n if (!occurrences) {\n occurrences = sectionOccurrences(graph, doc);\n occurrencesOf.set(doc, occurrences);\n }\n\n // Heading text repeats (the corpus has two `## Install`), so the section's\n // occurrence disambiguates which slice is actually its own.\n const tree = treeTextOf.get(doc);\n const text = tree\n ? tree.sections.get(section.slice(hash + 1))\n : source !== undefined && title !== undefined\n ? sectionOwnText(source, title, level, occurrences.get(section) ?? 0)\n : undefined;\n\n entries.push(entry(section, compactIri(GRAPH_SECTION), { title, text }));\n }\n\n // Concepts: label surface only — they are index nodes with no body of their\n // own, but they are worth seeding from (concept → the documents about it).\n for (const concept of graph.instancesOf(SKOS_CONCEPT)) {\n const pref = graph.literals(concept, SKOS_PREF_LABEL);\n const alt = graph.literals(concept, SKOS_ALT_LABEL);\n entries.push(\n entry(concept, compactIri(SKOS_CONCEPT), {\n title: pref[0],\n labels: joinLabels([...pref, ...alt]),\n }),\n );\n }\n\n entries.sort((a, b) => byCodeUnit(a.id, b.id));\n return { version: 1, entries };\n}\n\n/** Serialize deterministically, with the trailing newline the other emitters use. */\nexport function emitSearchIndex(doc: SearchIndexDoc): string {\n return `${JSON.stringify(doc, null, 2)}\\n`;\n}\n\n/**\n * Split one index into per-language indexes (ADR 01038).\n *\n * A document's language is the `dcterms:language` it carries; a **section takes\n * its document's**, which is containment rather than inference — a section is\n * part of exactly one document and has no language of its own. A document\n * declaring none lands in the `und` bucket.\n *\n * **Concepts belong to every locale.** A `skos:Concept` is shared vocabulary\n * minted from labels across the corpus, not a document in some language, so it\n * is replicated into each language's index rather than filed under `und`. Doing\n * otherwise had two visible costs: `--lang de` could never return a concept,\n * and a corpus whose every document declared a language still grew a phantom\n * `und` localization holding only concepts — which then made `manni graph search`\n * demand `--lang` on what is, to its author, a single-language corpus.\n *\n * Entry order inside each index is preserved, so each one is sorted for the\n * same reason the whole index was.\n */\nexport function partitionByLanguage(\n graph: GraphIndex,\n index: SearchIndexDoc,\n): Map<string, SearchIndexDoc> {\n const documentType = compactIri(GRAPH_DOCUMENT);\n const sectionType = compactIri(GRAPH_SECTION);\n\n /** The language of an entry, or undefined when it belongs to every locale. */\n const languageOf = (entry: SearchEntry): string | undefined => {\n if (entry.type !== documentType && entry.type !== sectionType) {\n return undefined;\n }\n const hash = entry.id.indexOf(\"#\");\n const doc = hash === -1 ? entry.id : entry.id.slice(0, hash);\n return languageOfDocument(graph, doc);\n };\n\n const out = new Map<string, SearchIndexDoc>();\n const shared: SearchEntry[] = [];\n for (const entry of index.entries) {\n const language = languageOf(entry);\n if (language === undefined) {\n shared.push(entry);\n continue;\n }\n const bucket = out.get(language);\n if (bucket) bucket.entries.push(entry);\n else out.set(language, { version: 1, entries: [entry] });\n }\n\n // A corpus of nothing but concepts still needs somewhere to put them.\n if (out.size === 0 && shared.length > 0) {\n out.set(UNDETERMINED, { version: 1, entries: [] });\n }\n for (const bucket of out.values()) {\n bucket.entries.push(...shared);\n bucket.entries.sort((a, b) => byCodeUnit(a.id, b.id));\n }\n return out;\n}\n\n/**\n * A document's language, canonically spelled, or `und`. `derive` already\n * writes the canonical tag, so this matters for a graph written by hand: one\n * locale in two spellings would otherwise become two indexes.\n */\nfunction languageOfDocument(graph: GraphIndex, doc: string): string {\n const tag = graph.literal(doc, DCTERMS_LANGUAGE);\n return tag === undefined ? UNDETERMINED : canonicalLanguageTag(tag);\n}\n\n/** Documents (not sections) per language, for the manifest's counts. */\nexport function documentsByLanguage(graph: GraphIndex): Map<string, number> {\n const out = new Map<string, number>();\n for (const doc of graph.instancesOf(GRAPH_DOCUMENT)) {\n const language = languageOfDocument(graph, doc);\n out.set(language, (out.get(language) ?? 0) + 1);\n }\n return out;\n}\n","/**\n * Content resolution (ADR 01018): graph node → the text it stands for.\n *\n * The graph is an index over documents ([ADR 01008](../../adrs/01008-graph-as-index-not-corpus.md)),\n * so retrieval must go back to the source to get text. The seam is a\n * `ContentResolver`; the shipped implementation uses `fetch`, which works\n * unchanged in browsers and in Node ≥18, and is injectable for tests.\n *\n * Section nodes (`doc.md#slug`) resolve by fetching the parent document and\n * slicing it at the heading whose text matches the section's `dcterms:title`\n * — so no line-span predicates need to be added to the graph.\n *\n * Platform-neutral: no `node:` imports, no npm dependencies.\n */\nimport { NS } from \"../core/vocab.js\";\nimport type { GraphIndex } from \"./graph.js\";\nimport type { QueryTrace } from \"./trace.js\";\n\nconst GRAPH_PATH = `${NS.graph}path`;\nconst DCTERMS_TITLE = `${NS.dcterms}title`;\nconst DCTERMS_HAS_PART = `${NS.dcterms}hasPart`;\nconst GRAPH_LEVEL = `${NS.graph}level`;\nconst GRAPH_ORDER = `${NS.graph}order`;\nconst GRAPH_BLOCK = `${NS.graph}Block`;\n\nexport interface ResolvedContent {\n iri: string;\n text: string;\n sourceUrl: string;\n title?: string;\n}\n\nexport interface ContentResolver {\n /** Text for a node, or undefined when the node has no content. */\n resolve(iri: string): Promise<ResolvedContent | undefined>;\n}\n\ntype FetchLike = (\n url: string,\n) => Promise<{ ok: boolean; status: number; text(): Promise<string> }>;\n\nexport interface FetchResolverOptions {\n /** Prefix joined to each `graph:path`, e.g. \"https://site/raw/\". */\n baseUrl?: string;\n /** Full control over path → URL. Overrides `baseUrl`. */\n pathToUrl?: (path: string) => string;\n /** Injectable fetch (defaults to the global). */\n fetch?: FetchLike;\n /** Record resolutions here. */\n trace?: QueryTrace;\n}\n\n/** Split a section IRI into its document IRI and fragment. */\nexport function splitFragment(iri: string): { doc: string; fragment?: string } {\n const hash = iri.indexOf(\"#\");\n return hash < 0\n ? { doc: iri }\n : { doc: iri.slice(0, hash), fragment: iri.slice(hash + 1) };\n}\n\n/**\n * Mark every line that sits inside a fenced code block (including the fence\n * delimiters themselves). Without this, a shell comment in a code sample —\n * `# Set the API key` — reads as an h1 and truncates the surrounding section,\n * which silently drops most of the retrieved content.\n *\n * CommonMark rules, minus the ones a heading scan cannot observe: a fence opens\n * on 3+ backticks or tildes indented at most 3 spaces, a backtick fence's info\n * string may not contain a backtick, and it closes on a delimiter of the same\n * character that is at least as long and carries no info string. An unclosed\n * fence runs to end of document.\n */\nfunction fencedLines(lines: string[]): boolean[] {\n const mask = new Array<boolean>(lines.length).fill(false);\n let open: string | undefined;\n for (const [i, line] of lines.entries()) {\n const m = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);\n // Both groups are mandatory in the pattern, so a match carries both.\n // Requiring them is the check that proves it, and it replaces the bare\n // `m &&` the branches already tested — no condition is added, only\n // sharpened.\n const delimiter = m?.[1];\n const info = m?.[2];\n const isFence = delimiter !== undefined && info !== undefined;\n if (open === undefined) {\n if (isFence && !(delimiter.startsWith(\"`\") && info.includes(\"`\"))) {\n open = delimiter;\n mask[i] = true;\n }\n continue;\n }\n mask[i] = true;\n if (\n isFence &&\n delimiter[0] === open[0] &&\n delimiter.length >= open.length &&\n info.trim() === \"\"\n ) {\n open = undefined;\n }\n }\n return mask;\n}\n\n/** One heading as the source spells it, located by the line it starts on. */\ninterface SourceHeading {\n /** First line: the `#` line, or a setext heading's first line of text. */\n start: number;\n level: number;\n /** The heading's raw inline text, markdown and all. */\n text: string;\n}\n\nconst ATX = /^ {0,3}(#{1,6})(?:[ \\t]+(.*?))?[ \\t]*$/;\nconst SETEXT_UNDERLINE = /^ {0,3}(=+|-+)[ \\t]*$/;\n\n/**\n * Whether a line can be paragraph text, which a setext underline turns into a\n * heading. A blank line, an ATX heading, a list item, a block quote, a\n * thematic break and indented code cannot.\n */\nfunction isParagraphLine(line: string): boolean {\n if (line.trim() === \"\") return false;\n if (ATX.test(line)) return false;\n if (/^ {0,3}([-+*]|\\d{1,9}[.)])([ \\t]|$)/.test(line)) return false;\n if (/^ {0,3}>/.test(line)) return false;\n if (/^ {0,3}([-*_])([ \\t]*\\1){2,}[ \\t]*$/.test(line)) return false;\n return !/^ {4}/.test(line);\n}\n\n/**\n * How many leading lines a YAML frontmatter block takes, delimiters included.\n * Its closing `---` follows a line of text, so without this the scan would\n * read the last frontmatter key as a setext heading.\n */\nfunction frontmatterLength(lines: string[]): number {\n if (lines[0]?.trim() !== \"---\") return 0;\n for (let i = 1; i < lines.length; i++) {\n const line = lines[i]?.trim();\n if (line === \"---\" || line === \"...\") return i + 1;\n }\n return 0;\n}\n\n/**\n * Every heading in a markdown source, in order. ATX headings may sit up to\n * three spaces in and lose any closing `#` run. Setext headings are\n * underlined with `=` or `-`. Fenced code and frontmatter hold none.\n *\n * Line-based, so a shape remark reads and this does not is possible. The\n * common ones are covered, and a miss leaves one section unindexed.\n */\nfunction sourceHeadings(lines: string[]): SourceHeading[] {\n const fenced = fencedLines(lines);\n const skip = frontmatterLength(lines);\n const headings: SourceHeading[] = [];\n /** First line of the paragraph the scan is inside, or -1. */\n let paragraph = -1;\n for (const [i, line] of lines.entries()) {\n if (i < skip || fenced[i]) {\n paragraph = -1;\n continue;\n }\n const atx = ATX.exec(line);\n const hashes = atx?.[1];\n if (hashes !== undefined) {\n // A closing run is `#`s after whitespace, or the whole content.\n const text = (atx?.[2] ?? \"\").replace(/(^|[ \\t]+)#+$/, \"\");\n headings.push({ start: i, level: hashes.length, text });\n paragraph = -1;\n continue;\n }\n const underline = SETEXT_UNDERLINE.exec(line)?.[1];\n if (underline !== undefined && paragraph >= 0) {\n headings.push({\n start: paragraph,\n level: underline.startsWith(\"=\") ? 1 : 2,\n text: lines.slice(paragraph, i).join(\"\\n\"),\n });\n paragraph = -1;\n continue;\n }\n if (isParagraphLine(line)) {\n if (paragraph < 0) paragraph = i;\n } else {\n paragraph = -1;\n }\n }\n return headings;\n}\n\nconst ENTITIES: Record<string, string> = {\n amp: \"&\",\n lt: \"<\",\n gt: \">\",\n quot: '\"',\n apos: \"'\",\n nbsp: \" \",\n};\n\n/** Decode the character references a heading is likely to carry. */\nfunction decodeEntities(text: string): string {\n return text.replace(\n /&(#x[0-9a-f]+|#[0-9]+|[a-z]+);/gi,\n (whole, name: string) => {\n if (name.startsWith(\"#\")) {\n const hex = name[1] === \"x\" || name[1] === \"X\";\n const code = Number.parseInt(name.slice(hex ? 2 : 1), hex ? 16 : 10);\n return Number.isNaN(code) || code > 0x10ffff\n ? whole\n : String.fromCodePoint(code);\n }\n return ENTITIES[name.toLowerCase()] ?? whole;\n },\n );\n}\n\n/**\n * The key a heading is matched by, from either side. One side is the\n * plain-text title the build recorded, the other the source text after\n * `stripInline`. Markup characters go, whitespace collapses, and case folds.\n * Both sides pass through it, so a character it drops cannot make them differ.\n */\nexport function headingKey(text: string): string {\n return text\n .replace(/[`*_~\\\\[\\]]/g, \"\")\n .replace(/\\s+/g, \" \")\n .trim()\n .toLowerCase();\n}\n\n/**\n * Raw heading source to the text remark reads from it. Links and images keep\n * their text, autolinks their target, and character references decode.\n */\nfunction stripInline(raw: string): string {\n return decodeEntities(\n raw\n .replace(/!?\\[([^\\]]*)\\]\\((?:[^()]|\\([^()]*\\))*\\)/g, \"$1\")\n .replace(/!?\\[([^\\]]*)\\]\\[[^\\]]*\\]/g, \"$1\")\n .replace(/<((?:https?|mailto):[^>\\s]+)>/gi, \"$1\"),\n );\n}\n\n/**\n * Sections of a document in true document order, reconstructed from the\n * `dcterms:hasPart` tree ordered by `graph:order` within each parent.\n *\n * Needed because heading text is not unique: a document with two `## Install`\n * headings produces two section nodes, and matching by title alone would give\n * both the *first* heading's text — wrong content under a confident citation.\n */\nexport function documentSectionOrder(\n graph: GraphIndex,\n docIri: string,\n): string[] {\n const ordered: string[] = [];\n const seen = new Set<string>();\n\n const childrenOf = (iri: string): string[] =>\n graph\n .out(iri, DCTERMS_HAS_PART)\n .map((e) => e.target)\n // A statement's graph:Block is a part too (proposal 0099), not a section.\n .filter((target) => !graph.types(target).includes(GRAPH_BLOCK))\n .sort((a, b) => {\n const oa = Number.parseInt(graph.literal(a, GRAPH_ORDER) ?? \"\", 10);\n const ob = Number.parseInt(graph.literal(b, GRAPH_ORDER) ?? \"\", 10);\n if (Number.isNaN(oa) || Number.isNaN(ob) || oa === ob) {\n return a < b ? -1 : a > b ? 1 : 0;\n }\n return oa - ob;\n });\n\n const walk = (iri: string): void => {\n for (const child of childrenOf(iri)) {\n if (seen.has(child)) continue;\n seen.add(child);\n ordered.push(child);\n walk(child);\n }\n };\n walk(docIri);\n return ordered;\n}\n\n/**\n * Occurrence number of every section of a document, in one walk: section IRI →\n * how many earlier sections share its heading text and level.\n *\n * Batched because the per-section form is quadratic — a document with N\n * sections would otherwise rebuild the whole `hasPart` order N times, once per\n * section indexed or resolved.\n */\nexport function sectionOccurrences(\n graph: GraphIndex,\n docIri: string,\n): Map<string, number> {\n const occurrences = new Map<string, number>();\n // title → level → how many carrying that pair have been seen so far. Nested\n // rather than a joined key, so no separator has to be safe in either field.\n const counts = new Map<string, Map<string, number>>();\n\n for (const section of documentSectionOrder(graph, docIri)) {\n const rawTitle = graph.literal(section, DCTERMS_TITLE);\n if (rawTitle === undefined) {\n occurrences.set(section, 0);\n continue;\n }\n // Keyed exactly the way `sliceSection` matches headings, by `headingKey`.\n // Keyed by the raw title instead, a document with `## Install`\n // and `## install` gives both sections occurrence 0, and the second one\n // then slices the first heading: wrong content under a confident citation.\n const title = headingKey(rawTitle);\n const level = graph.literal(section, GRAPH_LEVEL) ?? \"\";\n let byLevel = counts.get(title);\n if (!byLevel) {\n byLevel = new Map();\n counts.set(title, byLevel);\n }\n const seen = byLevel.get(level) ?? 0;\n occurrences.set(section, seen);\n byLevel.set(level, seen + 1);\n }\n return occurrences;\n}\n\n/**\n * Which occurrence of its heading text a section is (0-based) — the number of\n * earlier same-title, same-level sections in the same document. A section the\n * `hasPart` tree does not reach counts as the first (0).\n */\nexport function sectionOccurrence(\n graph: GraphIndex,\n sectionIri: string,\n): number {\n const { doc } = splitFragment(sectionIri);\n return sectionOccurrences(graph, doc).get(sectionIri) ?? 0;\n}\n\n/**\n * The prose before a document's first heading — the text that belongs to no\n * section, and so would otherwise be indexed nowhere in a document that has\n * sections.\n *\n * Fence-aware for the same reason `sliceSection` is: a `#` comment inside a\n * leading code block is not a heading, and treating it as one would cut the\n * preamble short. Frontmatter is *not* stripped here — the caller decides,\n * since only the search index cares about that.\n */\nexport function documentPreamble(markdown: string): string | undefined {\n const lines = markdown.split(/\\r?\\n/);\n const end = sourceHeadings(lines)[0]?.start ?? lines.length;\n const text = lines.slice(0, end).join(\"\\n\").trim();\n return text === \"\" ? undefined : text;\n}\n\n/**\n * Slice a markdown document at the heading whose text matches `title`,\n * returning that heading through to the next heading of the same or higher\n * rank. Returns undefined when no such heading exists. Handles CRLF, and\n * ignores `#` lines inside fenced code blocks.\n *\n * `occurrence` selects among repeated headings (0 = the first). Heading text is\n * not unique, so callers with a specific section node in hand should pass\n * `sectionOccurrence(graph, iri)` rather than defaulting to the first match.\n */\nexport function sliceSection(\n markdown: string,\n title: string,\n level?: number,\n occurrence = 0,\n): string | undefined {\n return slice(markdown, title, level, occurrence, false);\n}\n\n/**\n * The text a section *owns*: its heading down to the next heading of **any**\n * rank, so nested subsections are excluded.\n *\n * `sliceSection` keeps the subtree because that is what retrieval wants — ask\n * for \"Configuration\" and you should get its subsections too. Indexing wants\n * the opposite: with the subtree, a parent section matches everything its\n * children match and outranks them, so an H1 section shadows every heading\n * beneath it. Same granularity rule as Document vs Section, one level down.\n */\nexport function sectionOwnText(\n markdown: string,\n title: string,\n level?: number,\n occurrence = 0,\n): string | undefined {\n return slice(markdown, title, level, occurrence, true);\n}\n\n/**\n * The file lines `sectionOwnText` slices, 1-based and inclusive: the heading\n * down to the line before the next heading of any rank. `graph check` maps a\n * sample question's pinned answer onto the section that owns it with this.\n */\nexport function sectionOwnLines(\n markdown: string,\n title: string,\n level?: number,\n occurrence = 0,\n): { start: number; end: number } | undefined {\n const span = locate(markdown.split(/\\r?\\n/), title, level, occurrence, true);\n return span === undefined ? undefined : { start: span.start + 1, end: span.end };\n}\n\n/**\n * The file lines `sliceSection` returns, 1-based and inclusive: the heading\n * through its subsections, less the trailing blank lines `sliceSection`\n * trims. A chunk's `lines` come from here, so they cover its text exactly.\n */\nexport function sectionLines(\n markdown: string,\n title: string,\n level?: number,\n occurrence = 0,\n): { start: number; end: number } | undefined {\n const text = sliceSection(markdown, title, level, occurrence);\n if (text === undefined) return undefined;\n const span = locate(markdown.split(/\\r?\\n/), title, level, occurrence, false);\n if (span === undefined) return undefined;\n return { start: span.start + 1, end: span.start + text.split(\"\\n\").length };\n}\n\nfunction slice(\n markdown: string,\n title: string,\n level: number | undefined,\n occurrence: number,\n ownTextOnly: boolean,\n): string | undefined {\n const lines = markdown.split(/\\r?\\n/);\n const span = locate(lines, title, level, occurrence, ownTextOnly);\n if (span === undefined) return undefined;\n return lines.slice(span.start, span.end).join(\"\\n\").trimEnd();\n}\n\n/** The 0-based, end-exclusive line span of a section's slice. */\nfunction locate(\n lines: string[],\n title: string,\n level: number | undefined,\n occurrence: number,\n ownTextOnly: boolean,\n): { start: number; end: number } | undefined {\n const headings = sourceHeadings(lines);\n const wanted = headingKey(title);\n let remaining = occurrence;\n let found = -1;\n\n for (const [n, heading] of headings.entries()) {\n if (level !== undefined && heading.level !== level) continue;\n if (headingKey(stripInline(heading.text)) !== wanted) continue;\n if (remaining > 0) {\n remaining -= 1;\n continue;\n }\n found = n;\n break;\n }\n const match = headings[found];\n if (match === undefined) return undefined;\n\n const next = headings\n .slice(found + 1)\n .find((h) => ownTextOnly || h.level <= match.level);\n return { start: match.start, end: next?.start ?? lines.length };\n}\n\n/**\n * A resolver that fetches document sources over HTTP. Documents map through\n * `graph:path`; sections slice their parent document by heading.\n */\nexport function createFetchResolver(\n graph: GraphIndex,\n options: FetchResolverOptions = {},\n): ContentResolver {\n const doFetch: FetchLike =\n options.fetch ?? ((url: string) => globalThis.fetch(url));\n const toUrl =\n options.pathToUrl ?? ((path: string) => `${options.baseUrl ?? \"\"}${path}`);\n const cache = new Map<string, Promise<string | undefined>>();\n // `assemble` resolves many sections of the same document; the occurrence walk\n // is per-document, so compute it once and reuse it.\n const occurrenceCache = new Map<string, Map<string, number>>();\n\n const occurrenceOf = (docIri: string, sectionIri: string): number => {\n let map = occurrenceCache.get(docIri);\n if (!map) {\n map = sectionOccurrences(graph, docIri);\n occurrenceCache.set(docIri, map);\n }\n return map.get(sectionIri) ?? 0;\n };\n\n const fetchDoc = (url: string): Promise<string | undefined> => {\n let pending = cache.get(url);\n if (!pending) {\n pending = doFetch(url)\n .then((r) => (r.ok ? r.text() : undefined))\n .catch(() => undefined);\n cache.set(url, pending);\n }\n return pending;\n };\n\n return {\n async resolve(iri: string): Promise<ResolvedContent | undefined> {\n const { doc, fragment } = splitFragment(iri);\n const path = graph.literal(doc, GRAPH_PATH);\n if (!path) return undefined;\n\n const sourceUrl = toUrl(path);\n const body = await fetchDoc(sourceUrl);\n const title = graph.literal(iri, DCTERMS_TITLE);\n\n if (body === undefined) {\n options.trace?.resolutions.push({\n iri,\n sourceUrl,\n ok: false,\n error: \"fetch failed\",\n });\n return undefined;\n }\n\n let text = body;\n if (fragment) {\n const levelText = graph.literal(iri, GRAPH_LEVEL);\n const level = levelText ? Number.parseInt(levelText, 10) : undefined;\n const slice =\n title === undefined\n ? undefined\n : sliceSection(\n body,\n title,\n Number.isNaN(level) ? undefined : level,\n occurrenceOf(doc, iri),\n );\n if (slice === undefined) {\n options.trace?.resolutions.push({\n iri,\n sourceUrl,\n ok: false,\n error: \"section heading not found\",\n });\n return undefined;\n }\n text = slice;\n }\n\n options.trace?.resolutions.push({ iri, sourceUrl, ok: true });\n return { iri, text, sourceUrl, title };\n },\n };\n}\n","/**\n * `manni graph export chunks` (proposal 0090): every servable passage of the\n * built graph, keyed by its node IRI, with its text, its vector when a\n * sidecar holds one, its delivered metadata and its provenance record.\n *\n * A passage is a section's `sliceSection`, its heading through the next\n * heading of the same or higher rank, or a document's whole body. Provenance\n * needs git, cite and meta, none of which the runtime can run, so the record\n * is built here, on the Node side, as the search index is, and every host\n * reads the rows.\n *\n * Byte-stable: keys are sorted, rows are in id order, and nothing reads the\n * wall clock. A page with an uncommitted body change has no day git can\n * attest, so its `lastUpdated.day` is `null` rather than today's date.\n */\nimport { execFile } from \"node:child_process\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, join, resolve } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { runCheck } from \"../../cite/index.js\";\nimport type { CitationResult, PageCitationReport } from \"../../cite/types.js\";\nimport { integrityOf, runDerive } from \"../../meta/index.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport { analyzeDoc, formatOf, isTreeFormat } from \"../core/analyze.js\";\nimport type { GraphConfig } from \"../core/config.js\";\nimport { documentBase, routesFrom } from \"../core/discover.js\";\nimport { emitJsonLd } from \"../core/emit-jsonld.js\";\nimport { openMetaView, withExternalMetadata, type MetaViewSource } from \"../core/external.js\";\nimport { CONFIGURED_EVALS_LEFT_OUT, deliveredFields, userFacing } from \"../core/graph-output.js\";\nimport { readRecord } from \"../../shared/reference-fields.js\";\nimport { STDIN_PATH } from \"../core/iri.js\";\nimport { loadGraph, storeToQuads } from \"../core/load.js\";\nimport {\n canonicalLanguageTag,\n isLanguageTag,\n LOCALIZATIONS_FILENAME,\n parseLocalizations,\n UNDETERMINED,\n} from \"../core/localizations.js\";\nimport { byCodeUnit } from \"../core/sort.js\";\nimport { decodeVectorIndex } from \"../core/vector-index.js\";\nimport { NS, PREFIXES } from \"../core/vocab.js\";\nimport {\n range,\n type ChunkRow,\n type ChunksManifest,\n type DerivedDate,\n type EvalItem,\n type PassageStatement,\n type PinItem,\n type PinSummary,\n type ProvenanceEvals,\n type ProvenanceRecord,\n} from \"../runtime/chunks.js\";\nimport { GraphIndex } from \"../runtime/graph.js\";\n// The floor is applied at export here and again at query in the runtime: one rule.\nimport { withholds } from \"../runtime/retrieve.js\";\nimport { documentSectionOrder, sectionLines, sectionOccurrences } from \"../runtime/resolve.js\";\nimport { GraphError, type DocModel } from \"../types.js\";\nimport { bodyOf, sectionSpans } from \"./questions.js\";\n\nconst run = promisify(execFile);\n\nconst DOCUMENT = `${NS.graph}Document`;\nconst PATH = `${NS.graph}path`;\nconst LEVEL = `${NS.graph}level`;\nconst TITLE = `${NS.dcterms}title`;\nconst LANGUAGE = `${NS.dcterms}language`;\n\n/** The manifest's file name, beside its rows. */\nexport const CHUNKS_MANIFEST = \"chunks.json\";\n\n/** `chunks.de.jsonl`: one language's rows. */\nexport function chunksFilename(language: string): string {\n return `chunks.${language}.jsonl`;\n}\n\nexport interface ChunksOptions {\n cwd: string;\n config: GraphConfig;\n source: MetaViewSource;\n graphPath: string;\n /** The directory the manifest and rows go to, which also holds the search manifest and sidecars. */\n outDir: string;\n /** The docevals report: `--evals` as typed (from `cwd`), else the config's (from its directory). */\n evals?: { label: string; path: string };\n /**\n * `false` reads the pages as a `--no-authoring` build does (proposal 0110):\n * no strategy record, no external value, no pin and no eval verdict.\n * Default `true`.\n */\n authoring?: boolean;\n}\n\nexport interface ChunksResult {\n manifestPath: string;\n rows: number;\n withheld: number;\n warnings: string[];\n notices: string[];\n /** The manifest and each language's rows, absolute. */\n files: string[];\n}\n\n/** One passage before it becomes a row. */\ninterface Passage {\n id: string;\n page: string;\n /** Body lines. */\n start: number;\n end: number;\n title: string;\n text: string;\n language: string;\n metadata: Record<string, unknown>;\n}\n\nexport async function exportChunks(opts: ChunksOptions): Promise<ChunksResult> {\n const { cwd, config } = opts;\n const warnings: string[] = [];\n const notices: string[] = [];\n\n const quads = storeToQuads(loadGraph(opts.graphPath));\n const graph = GraphIndex.fromQuads(quads, Object.fromEntries(PREFIXES));\n const graphDigest = integrityOf(Buffer.from(emitJsonLd(quads), \"utf8\"));\n const sources = documentBase(config, {}, cwd);\n\n // The pages the graph holds that are on disk, as the build labelled them.\n let pages: { doc: string; path: string; content: string }[] = [];\n for (const doc of graph.instancesOf(DOCUMENT)) {\n const path = graph.literal(doc, PATH);\n if (path === undefined || path === STDIN_PATH) continue;\n const abs = resolve(sources, path);\n if (!existsSync(abs)) continue;\n pages.push({ doc, path, content: readFileSync(abs, \"utf8\") });\n }\n pages.sort((a, b) => byCodeUnit(a.path, b.path));\n\n // What `build` reads: each page's own model, its manifests merged in.\n const allPaths = new Set(pages.map((p) => p.path));\n const routes = routesFrom(config, sources);\n const view = await openMetaView(opts.source, cwd, [...allPaths], sources);\n let models = await withExternalMetadata(\n await Promise.all(pages.map((p) => analyzeDoc(p.content, p.path, allPaths, { routes }))),\n view,\n );\n // Without author-facing content (proposal 0110), a strategy record is no\n // passage, and a page keeps only what it carries for its readers.\n // Unset means the default, which is on.\n const authoring = opts.authoring !== false;\n if (!authoring) {\n const kept = models.flatMap((m, i) => {\n const page = pages[i];\n return page === undefined || readRecord(m.frontmatter, m.path) !== undefined ? [] : [{ page, model: m }];\n });\n pages = kept.map((k) => k.page);\n models = await userFacing(\n kept.map((k) => k.model),\n view,\n );\n }\n const paths = pages.map((p) => p.path);\n\n const git = await gitState(sources, paths);\n if (git.reason !== undefined) {\n notices.push(`git cannot read this directory (${git.reason}), so records carry no commit and no derived dates.`);\n } else if (git.dirty.size > 0 && git.commit !== null) {\n const n = git.dirty.size;\n warnings.push(\n `${String(n)} ${n === 1 ? \"page differs\" : \"pages differ\"} from ${git.commit.slice(0, 8)}, so their records describe uncommitted text.`,\n );\n }\n const worktree = git.commit === null ? null : git.dirty.size > 0 ? \"modified\" : \"clean\";\n\n const metadataByPage = new Map(models.map((m) => [m.path, m.frontmatter]));\n // Pins and eval verdicts are author-facing: a run without them reads neither.\n const pins = authoring ? await pinsByPage(opts, sources, paths, metadataByPage) : new Map<string, Pin[]>();\n const dates = await datesByPage(opts, sources, paths, git.commit !== null, authoring ? undefined : metadataByPage);\n const evals = authoring ? readEvals(opts, sources, pages, warnings) : undefined;\n if (opts.evals === undefined) warnings.push(\"no docevals report is configured, so records carry no eval verdicts.\");\n else if (!authoring) warnings.push(CONFIGURED_EVALS_LEFT_OUT);\n\n const vectors = readVectors(opts.outDir);\n if (vectors === undefined) {\n warnings.push(\n \"no vector sidecar, so chunks carry no vectors and retrieval is lexical only; configure graph.embed to add them.\",\n );\n }\n\n const rows: ChunkRow[] = [];\n const pageMetadata: Record<string, { metadata: Record<string, unknown> }> = {};\n for (const [n, page] of pages.entries()) {\n const model = models[n];\n if (model === undefined) continue;\n const refs = view.refsFor(page.path, model.frontmatter);\n const { $schema: _schema, ...own } = model.frontmatter;\n const metadata = plain(await deliveredFields(own, refs, view.validator)) as Record<string, unknown>;\n pageMetadata[page.path] = { metadata };\n const { bodyLine } = bodyOf(page.content, model.format);\n const blocks: { start: number; end: number; status: PassageStatement[\"status\"]; data: Record<string, unknown> }[] = [];\n const bySection = new Map<string, Record<string, unknown>[]>();\n for (const s of model.statements ?? []) {\n const data = plain(await deliveredFields(s.data, refs, view.validator)) as Record<string, unknown>;\n if (s.scope === \"block\") {\n blocks.push({ start: s.anchor.start - bodyLine + 1, end: s.anchor.end - bodyLine + 1, status: s.status, data });\n continue;\n }\n const section = model.sections.find(\n (x) => x.line !== null && x.line >= s.anchor.start && x.line <= s.anchor.end,\n );\n if (section === undefined) continue;\n // The record carries it too, at its heading's lines, so a host can\n // place it on the heading (proposal 0095).\n blocks.push({ start: s.anchor.start - bodyLine + 1, end: s.anchor.end - bodyLine + 1, status: s.status, data });\n const list = bySection.get(section.slug) ?? [];\n list.push(data);\n bySection.set(section.slug, list);\n }\n\n const language = languageOf(graph, page.doc);\n const record = (start: number, end: number): Omit<ProvenanceRecord, \"node\"> => ({\n page: page.path,\n lines: `${String(start)}-${String(end)}`,\n commit: git.commit,\n worktree,\n pins: summarize(pins.get(page.path) ?? [], start, end),\n dates: dates.get(page.path) ?? noDates(model.frontmatter),\n evals: evals?.get(page.path) ?? null,\n statements: blocks\n .filter((b) => b.start >= start && b.end <= end)\n .map((b) => ({ lines: `${String(b.start)}-${String(b.end)}`, status: b.status, data: b.data })),\n });\n\n for (const passage of await passagesOf(graph, page, model, bodyLine, language, metadata, bySection)) {\n const vector = vectors?.byId.get(passage.id);\n rows.push({\n id: passage.id,\n graph: graphDigest,\n page: passage.page,\n lines: `${String(passage.start)}-${String(passage.end)}`,\n language: passage.language,\n title: passage.title,\n text: passage.text,\n ...(vector === undefined ? {} : { vector }),\n metadata: passage.metadata,\n provenance: { node: passage.id, ...record(passage.start, passage.end) },\n });\n }\n }\n rows.sort((a, b) => byCodeUnit(a.id, b.id));\n\n // The trust floor, at export (decision 8): what it names leaves the rows.\n const withhold = config.retrieve.withhold;\n const withheld: ChunksManifest[\"withheld\"] = [];\n const kept: ChunkRow[] = [];\n for (const row of rows) {\n const because = withhold.filter((reason) => withholds(row.provenance, reason));\n if (because.length === 0) kept.push(row);\n else withheld.push({ id: row.id, page: row.page, because });\n }\n if (withheld.length > 0) {\n const reasons = withhold.filter((r) => withheld.some((w) => w.because.includes(r)));\n const n = withheld.length;\n notices.push(\n `${String(n)} ${n === 1 ? \"chunk\" : \"chunks\"} withheld by graph.retrieve.withhold (${reasons.join(\", \")}); ${CHUNKS_MANIFEST} lists them.`,\n );\n }\n\n mkdirSync(opts.outDir, { recursive: true });\n const languages: ChunksManifest[\"languages\"] = {};\n const byLanguage = new Map<string, ChunkRow[]>();\n for (const row of kept) {\n const list = byLanguage.get(row.language) ?? [];\n list.push(row);\n byLanguage.set(row.language, list);\n }\n for (const [language, list] of byLanguage) {\n // The tag becomes a filename, as it does for the search index.\n if (!isLanguageTag(language)) {\n throw new GraphError(\n `Cannot write an index for language \"${language}\": not a BCP-47 tag. ` +\n `Fix the \\`lang\\`/\\`language\\` frontmatter, or the route's \\`language\\`, ` +\n `and rebuild — \\`manni graph check\\` reports which document carries it.`,\n );\n }\n const file = chunksFilename(language);\n writeFileSync(join(opts.outDir, file), list.map((row) => `${canonicalJson(row)}\\n`).join(\"\"), \"utf8\");\n languages[language] = { file, rows: list.length, model: vectors?.models.get(language) ?? null };\n }\n\n const manifest: ChunksManifest = {\n format: \"manni-graph-chunks\",\n version: 1,\n graph: graphDigest,\n graphFile: basename(opts.graphPath).replace(/\\.[^.]*$/, \"\") + \".jsonld\",\n searchIndex: LOCALIZATIONS_FILENAME,\n commit: git.commit,\n worktree,\n retrieve: { ...config.retrieve },\n evals: opts.evals === undefined || evals === undefined ? null : { report: opts.evals.label, digest: evals.digest },\n languages,\n pages: pageMetadata,\n withheld,\n };\n const manifestPath = join(opts.outDir, CHUNKS_MANIFEST);\n writeFileSync(manifestPath, `${canonicalJson(manifest, 2)}\\n`, \"utf8\");\n const files = [manifestPath, ...Object.values(languages).map((l) => join(opts.outDir, l.file))];\n return { manifestPath, rows: kept.length, withheld: withheld.length, warnings, notices, files };\n}\n\nfunction languageOf(graph: GraphIndex, doc: string): string {\n const tag = graph.literal(doc, LANGUAGE);\n return tag === undefined ? UNDETERMINED : canonicalLanguageTag(tag);\n}\n\n/** A document's passage, then each section's, in document order. */\nasync function passagesOf(\n graph: GraphIndex,\n page: { doc: string; path: string; content: string },\n model: DocModel,\n bodyLine: number,\n language: string,\n metadata: Record<string, unknown>,\n bySection: ReadonlyMap<string, Record<string, unknown>[]>,\n): Promise<Passage[]> {\n const out: Passage[] = [];\n const fileLines = page.content.split(/\\r?\\n/);\n const body = fileLines.slice(bodyLine - 1).join(\"\\n\").trimEnd();\n if (body.trim() !== \"\") {\n out.push({\n id: page.doc,\n page: page.path,\n start: 1,\n end: body.split(\"\\n\").length,\n title: graph.literal(page.doc, TITLE) ?? page.path,\n text: body,\n language,\n metadata,\n });\n }\n\n const sections = documentSectionOrder(graph, page.doc);\n const spans = new Map<string, { start: number; end: number }>();\n const format = formatOf(page.path, model.format);\n if (isTreeFormat(format)) {\n // A tree section's own span, widened over the sections nested in it: the\n // ones after it of a deeper level, up to the next of its own or higher.\n const own = new Map((await sectionSpans(graph, page.doc, page.path, page.content, sections)).map((s) => [s.iri, s.span]));\n const levels = sections.map((iri) => Number.parseInt(graph.literal(iri, LEVEL) ?? \"\", 10));\n for (const [i, iri] of sections.entries()) {\n const span = own.get(iri);\n if (span === undefined) continue;\n let end = span.end;\n for (let j = i + 1; j < sections.length; j++) {\n const level = levels[j] ?? Number.NaN;\n if (!(level > (levels[i] ?? Number.NaN))) break;\n end = Math.max(end, own.get(sections[j] ?? \"\")?.end ?? end);\n }\n spans.set(iri, { start: span.start, end });\n }\n } else {\n const occurrences = sectionOccurrences(graph, page.doc);\n for (const iri of sections) {\n const title = graph.literal(iri, TITLE);\n if (title === undefined) continue;\n const level = Number.parseInt(graph.literal(iri, LEVEL) ?? \"\", 10);\n const span = sectionLines(page.content, title, Number.isNaN(level) ? undefined : level, occurrences.get(iri) ?? 0);\n if (span !== undefined) spans.set(iri, span);\n }\n }\n\n const slugs = new Map(model.sections.map((s) => [s.slug, s]));\n for (const iri of sections) {\n const span = spans.get(iri);\n if (span === undefined || span.start < bodyLine) continue;\n const text = fileLines.slice(span.start - 1, span.end).join(\"\\n\").trimEnd();\n if (text === \"\") continue;\n // The page's fields, then each heading statement from the outermost\n // section down to this one: the nearest wins, field by field.\n const chain: Record<string, unknown>[] = [];\n let slug: string | null = iri.slice(iri.indexOf(\"#\") + 1);\n const seen = new Set<string>();\n while (slug !== null && !seen.has(slug)) {\n seen.add(slug);\n chain.unshift(...(bySection.get(slug) ?? []));\n slug = slugs.get(slug)?.parentSlug ?? null;\n }\n out.push({\n id: iri,\n page: page.path,\n start: span.start - bodyLine + 1,\n end: span.start - bodyLine + text.split(\"\\n\").length,\n title: graph.literal(iri, TITLE) ?? iri,\n text,\n language,\n metadata: Object.assign({}, metadata, ...chain) as Record<string, unknown>,\n });\n }\n return out;\n}\n\n// ---- git ---------------------------------------------------------------------\n\n/** HEAD, the pages that differ from it, or why git could not answer. */\nasync function gitState(\n dir: string,\n paths: readonly string[],\n): Promise<{ commit: string | null; dirty: Set<string>; reason?: string }> {\n let commit: string;\n let prefix: string;\n try {\n commit = (await run(\"git\", [\"rev-parse\", \"HEAD\"], { cwd: dir })).stdout.trim();\n prefix = (await run(\"git\", [\"rev-parse\", \"--show-prefix\"], { cwd: dir })).stdout.trim();\n } catch (e) {\n const stderr = (e as { stderr?: unknown }).stderr;\n const said = typeof stderr === \"string\" && stderr.trim() !== \"\" ? stderr.trim().split(/\\r?\\n/)[0] ?? \"\" : errorMessage(e);\n return { commit: null, dirty: new Set(), reason: said.replace(/^fatal:\\s*/, \"\") };\n }\n const wanted = new Set(paths);\n const dirty = new Set<string>();\n const { stdout } = await run(\"git\", [\"status\", \"--porcelain=v1\", \"-z\", \"--untracked-files=all\", \"--\", \".\"], {\n cwd: dir,\n maxBuffer: 64 * 1024 * 1024,\n });\n const entries = stdout.split(\"\\0\");\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i] ?? \"\";\n if (entry.length < 4) continue;\n // A rename names its source in the next field, which is not a page now.\n if (entry[0] === \"R\" || entry[0] === \"C\") i++;\n const fromRoot = entry.slice(3);\n if (!fromRoot.startsWith(prefix)) continue;\n const path = fromRoot.slice(prefix.length);\n if (wanted.has(path)) dirty.add(path);\n }\n return { commit, dirty };\n}\n\n// ---- pins --------------------------------------------------------------------\n\ninterface Pin {\n start: number;\n end: number;\n item: PinItem;\n}\n\n/** cite's own check over the pages, read into pins with their current claim lines. */\nasync function pinsByPage(\n opts: ChunksOptions,\n sources: string,\n paths: readonly string[],\n metadata: ReadonlyMap<string, Record<string, unknown>>,\n): Promise<Map<string, Pin[]>> {\n const out = new Map<string, Pin[]>();\n if (paths.length === 0) return out;\n let reports: PageCitationReport[];\n try {\n reports = (\n await runCheck({\n inputs: [...paths],\n cwd: sources,\n ...(opts.source.configPath === undefined ? {} : { configPath: resolve(opts.cwd, opts.source.configPath) }),\n ...(opts.source.noConfig === undefined ? {} : { noConfig: opts.source.noConfig }),\n })\n ).pages;\n } catch (e) {\n throw new GraphError(errorMessage(e));\n }\n for (const report of reports) {\n const content = readFileSync(resolve(sources, report.file), \"utf8\");\n const { bodyLine } = bodyOf(content, formatOf(report.file));\n const list: Pin[] = [];\n for (const result of report.citations) {\n const claim = claimLines(result, bodyLine);\n if (claim === undefined) continue;\n // cite reads the entry's pin fields; its verification fields are read\n // from the merged page, where the entry sits at the same index.\n const entries = metadata.get(report.file)?.[\"citations\"];\n const raw: unknown = Array.isArray(entries) ? entries[result.origin.index] : undefined;\n const entry = typeof raw === \"object\" && raw !== null ? (raw as Record<string, unknown>) : {};\n const findings = report.findings\n .filter((f) => f.index === result.origin.index)\n .map((f) => ({ rule: f.rule, severity: f.severity }));\n list.push({\n ...claim,\n item: {\n id: result.citation.id ?? null,\n claim: claim.start === claim.end ? String(claim.start) : `${String(claim.start)}-${String(claim.end)}`,\n source: result.source.src,\n commit: result.citation.source[\"commit-sha\"] ?? null,\n findings,\n lastVerified: asWritten(entry[\"last-verified\"]),\n verifiedBy: entriesOf(entry[\"verified-by\"]),\n },\n });\n }\n out.set(report.file, list);\n }\n return out;\n}\n\n/** The body lines a claim occupies now: where it moved to, else where it is recorded. */\nfunction claimLines(result: CitationResult, bodyLine: number): { start: number; end: number } | undefined {\n const claim = result.claim;\n if (claim === null) return undefined;\n const body = claim.status === \"moved\" && claim.newLines !== undefined ? claim.newLines : claim.lines;\n if (body !== undefined) return range(body);\n if (claim.fileLines === undefined) return undefined;\n const file = range(claim.fileLines);\n return file && { start: file.start - bodyLine + 1, end: file.end - bodyLine + 1 };\n}\n\nconst RANK = { notice: 1, warning: 2, error: 3 } as const;\n\n/** The pins whose claim overlaps `start`-`end`, each counted once at its worst finding. */\nfunction summarize(pins: readonly Pin[], start: number, end: number): PinSummary {\n const summary: PinSummary = { total: 0, current: 0, notice: 0, warning: 0, error: 0, items: [] };\n for (const pin of pins) {\n if (pin.end < start || pin.start > end) continue;\n summary.total += 1;\n summary.items.push(pin.item);\n const worst = pin.item.findings.reduce<PinItem[\"findings\"][number][\"severity\"] | undefined>(\n (w, f) => (w === undefined || RANK[f.severity] > RANK[w] ? f.severity : w),\n undefined,\n );\n if (worst === undefined) summary.current += 1;\n else summary[worst] += 1;\n }\n return summary;\n}\n\n// ---- dates -------------------------------------------------------------------\n\n/**\n * What `manni meta derive` would stamp for `created` and `last-updated`, compared with each page.\n * `pages`, when given, is what each page asserts, in place of what its file and manifests hold.\n */\nasync function datesByPage(\n opts: ChunksOptions,\n sources: string,\n paths: readonly string[],\n inGit: boolean,\n pages?: ReadonlyMap<string, Record<string, unknown>>,\n): Promise<Map<string, ProvenanceRecord[\"dates\"]>> {\n const out = new Map<string, ProvenanceRecord[\"dates\"]>();\n if (paths.length === 0 || !inGit) return out;\n let derived;\n try {\n derived = await runDerive({\n inputs: [...paths],\n cwd: sources,\n fields: [\"created\", \"last-updated\"],\n sources: [\"git\"],\n // `check` judges and writes nothing, and offers no relocation.\n check: true,\n // Never read: an uncommitted change's day is dropped below.\n now: () => new Date(0),\n ...(opts.source.configPath === undefined ? {} : { configPath: resolve(opts.cwd, opts.source.configPath) }),\n ...(opts.source.noConfig === undefined ? {} : { noConfig: opts.source.noConfig }),\n });\n } catch (e) {\n throw new GraphError(errorMessage(e));\n }\n for (const result of derived.results) {\n const content = readFileSync(resolve(sources, result.file), \"utf8\");\n const page = pages?.get(result.file) ?? (await analyzeDoc(content, result.file, new Set([result.file]))).frontmatter;\n const date = (field: \"created\" | \"last-updated\"): DerivedDate => {\n const f = result.fields.find((x) => x.field === field);\n const asserted = pages === undefined ? (f?.asserted ?? page[field]) : page[field];\n // Without author-facing content, a `created` the field stamped is the\n // field's value, so it goes with the field (proposal 0110).\n const fromField = pages !== undefined && field === \"created\" && f?.evidence?.startsWith(\"stamped\") === true;\n const day = f === undefined || f.evidence === \"uncommitted body change\" || fromField ? null : asWritten(f.derived);\n // No derived day, nothing to compare the page against: no stamp either.\n if (day === null) return { day, stamp: null };\n const stamp: DerivedDate[\"stamp\"] =\n asserted === undefined || asserted === null ? \"absent\" : f?.status === \"current\" ? \"current\" : \"stale\";\n return { day, stamp };\n };\n out.set(result.file, {\n created: date(\"created\"),\n lastUpdated: date(\"last-updated\"),\n lastVerified: asWritten(page[\"last-verified\"]),\n verifiedBy: entriesOf(page[\"verified-by\"]),\n });\n }\n return out;\n}\n\n/** Outside git, or for a page derive did not read: no days, so no stamps, and the page's own verification. */\nfunction noDates(page: Record<string, unknown>): ProvenanceRecord[\"dates\"] {\n return {\n created: { day: null, stamp: null },\n lastUpdated: { day: null, stamp: null },\n lastVerified: asWritten(page[\"last-verified\"]),\n verifiedBy: entriesOf(page[\"verified-by\"]),\n };\n}\n\n// ---- evals -------------------------------------------------------------------\n\ninterface ReportResult {\n evalName: string;\n suite?: string;\n grader: string;\n file: string;\n outcome: EvalItem[\"outcome\"];\n integrity?: string;\n consensus?: { meanConfidence?: number };\n}\n\n/** Each page's verdicts from the report, keyed by page, plus the report's digest. */\nfunction readEvals(\n opts: ChunksOptions,\n sources: string,\n pages: readonly { path: string; content: string }[],\n warnings: string[],\n): (Map<string, ProvenanceEvals> & { digest: string }) | undefined {\n if (opts.evals === undefined) return undefined;\n const { label, path } = opts.evals;\n if (!existsSync(path)) throw new GraphError(`graph.export.chunks.evals names ${label}, which does not exist.`);\n const bytes = readFileSync(path);\n const notReport = new GraphError(`${label} is not a docevals JSON report; write one with manni docevals run -f json.`);\n let parsed: unknown;\n try {\n parsed = JSON.parse(bytes.toString(\"utf8\"));\n } catch {\n throw notReport;\n }\n const results = (parsed as { evalResults?: unknown } | null)?.evalResults;\n if (typeof parsed !== \"object\" || parsed === null || !Array.isArray(results) || typeof (parsed as { pages?: unknown }).pages !== \"number\") {\n throw notReport;\n }\n const digest = integrityOf(bytes);\n // A result's `file` is relative to where docevals ran: the config's\n // directory, where a bare run starts, and the graph's labels resolve too.\n const reportBase = opts.config.configSource === null ? opts.cwd : opts.config.configDir;\n const byPage = new Map<string, ReportResult[]>();\n const known = new Map(pages.map((p) => [resolve(sources, p.path), p.path]));\n const strangers = new Set<string>();\n let anyIntegrity = false;\n for (const raw of results) {\n if (typeof raw !== \"object\" || raw === null) throw notReport;\n const r = raw as ReportResult;\n if (typeof r.file !== \"string\" || typeof r.evalName !== \"string\" || typeof r.outcome !== \"string\") throw notReport;\n if (r.integrity !== undefined) anyIntegrity = true;\n const page = known.get(resolve(reportBase, r.file));\n if (page === undefined) {\n strangers.add(r.file);\n continue;\n }\n const list = byPage.get(page) ?? [];\n list.push(r);\n byPage.set(page, list);\n }\n if (results.length > 0 && !anyIntegrity) {\n warnings.push(`${label} records no page integrity, so every verdict reads stale; write it again with manni docevals run -f json.`);\n }\n const out = new Map<string, ProvenanceEvals>() as Map<string, ProvenanceEvals> & { digest: string };\n out.digest = digest;\n let changed = 0;\n for (const page of pages) {\n // A page the report never judged has no verdicts: its record's evals stay null.\n const list = byPage.get(page.path);\n if (list === undefined) continue;\n const now = integrityOf(Buffer.from(page.content, \"utf8\"));\n const current = list.every((r) => r.integrity === now);\n if (!current && list.some((r) => r.integrity !== undefined)) changed += 1;\n const count = (outcome: EvalItem[\"outcome\"]): number => list.filter((r) => r.outcome === outcome).length;\n out.set(page.path, {\n report: digest,\n current,\n pass: count(\"pass\"),\n fail: count(\"fail\"),\n needsReview: count(\"needs-review\"),\n skipped: count(\"skipped\"),\n error: count(\"error\"),\n items: list\n .map((r): EvalItem => ({\n name: r.evalName,\n suite: r.suite ?? \"\",\n grader: r.grader,\n outcome: r.outcome,\n ...(typeof r.consensus?.meanConfidence === \"number\" ? { confidence: r.consensus.meanConfidence } : {}),\n }))\n .sort((a, b) => byCodeUnit(a.suite, b.suite) || byCodeUnit(a.name, b.name)),\n });\n }\n if (changed > 0) {\n warnings.push(\n `${String(changed)} ${changed === 1 ? \"page\" : \"pages\"} changed since ${label} was written, so their verdicts read stale.`,\n );\n }\n if (strangers.size > 0) {\n const n = strangers.size;\n warnings.push(\n `${String(n)} ${n === 1 ? \"page\" : \"pages\"} in ${label} ${n === 1 ? \"is\" : \"are\"} not in the graph, so their verdicts are left out.`,\n );\n }\n return out;\n}\n\n// ---- vectors -----------------------------------------------------------------\n\n/**\n * Every node's vector from the sidecars the search manifest names, and each\n * language's model from its own sidecar header, since `graph.embed.byLanguage`\n * can embed each language with a different one. `undefined` when there are none.\n */\nfunction readVectors(\n dir: string,\n): { models: Map<string, { id: string; dimensions: number }>; byId: Map<string, number[]> } | undefined {\n const manifestPath = join(dir, LOCALIZATIONS_FILENAME);\n if (!existsSync(manifestPath)) return undefined;\n const doc = parseLocalizations(readFileSync(manifestPath, \"utf8\"));\n if (doc === undefined) return undefined;\n const byId = new Map<string, number[]>();\n const models = new Map<string, { id: string; dimensions: number }>();\n for (const entry of doc.languages) {\n if (entry.vectors === undefined) continue;\n const file = resolve(dir, entry.vectors.path);\n if (!existsSync(file)) continue;\n const { header, vectors } = decodeVectorIndex(readFileSync(file));\n models.set(canonicalLanguageTag(entry.language), { id: header.model, dimensions: header.dims });\n for (const [i, id] of header.ids.entries()) {\n byId.set(id, Array.from(vectors.subarray(i * header.dims, (i + 1) * header.dims)));\n }\n }\n return models.size === 0 ? undefined : { models, byId };\n}\n\n// ---- values ------------------------------------------------------------------\n\n/** A value as the page wrote it: a parsed date back to its text, else a string, else `null`. */\nfunction asWritten(value: unknown): string | null {\n if (value instanceof Date) return dateText(value);\n if (typeof value === \"string\") return value;\n return null;\n}\n\nfunction dateText(d: Date): string {\n const iso = d.toISOString();\n return iso.endsWith(\"T00:00:00.000Z\") ? iso.slice(0, 10) : iso;\n}\n\n/** A list field's entries, or `[]`. */\nfunction entriesOf(value: unknown): unknown[] {\n if (value === undefined || value === null) return [];\n return (Array.isArray(value) ? value : [value]).map(plain);\n}\n\n/** JSON-ready: dates as written, everything else as it is. */\nfunction plain(value: unknown): unknown {\n if (value instanceof Date) return dateText(value);\n if (Array.isArray(value)) return value.map(plain);\n if (typeof value === \"object\" && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, plain(v)]));\n }\n return value;\n}\n\n/** JSON with every object's keys sorted, so equal values give equal bytes. */\nexport function canonicalJson(value: unknown, indent?: number): string {\n const sort = (v: unknown): unknown => {\n if (Array.isArray(v)) return v.map(sort);\n if (typeof v === \"object\" && v !== null) {\n return Object.fromEntries(\n Object.keys(v)\n .sort(byCodeUnit)\n .map((k) => [k, sort((v as Record<string, unknown>)[k])]),\n );\n }\n return v;\n };\n return JSON.stringify(sort(value), null, indent);\n}\n","/**\n * Deterministic JSON-LD serialization — the web-native rendering of the same\n * graph the Turtle emitter produces. Canonical form: an `@context` carrying the\n * fixed prefix table, then `@graph` as one node object per subject sorted by\n * `@id`. Within a node: `@id`, then `@type` (compacted class IRIs, sorted),\n * then predicate CURIE keys sorted, each value array sorted. Objects are built\n * in that sorted key order so `JSON.stringify(_, null, 2)` is byte-stable.\n * Byte-identical output for any input quad order.\n *\n * Deliberately hand-rolled rather than the `jsonld` library, for the same\n * reason the Turtle emitter avoids N3.Writer: library formatting and ordering\n * are incidental, not a stability contract. dockg emits no blank nodes, so\n * none is handled here. A language-tagged literal is `{@value, @language}`.\n */\nimport { compactIri } from \"./load.js\";\nimport type { Quad, Term } from \"./derive.js\";\nimport { byCodeUnit } from \"./sort.js\";\nimport { NS, PREFIXES, RDF_TYPE } from \"./vocab.js\";\n\nconst XSD_STRING = `${NS.xsd}string`;\n\n/**\n * A rendered JSON-LD object value plus the fields it sorts by. Sorting compares\n * field by field (never a joined string with a separator — that would need a\n * delimiter byte, and NUL/control bytes in source are forbidden): IRIs before\n * literals (mirroring the Turtle emitter), then lexical value, then datatype.\n */\ninterface RenderedValue {\n value: unknown;\n /** 0 = IRI, 1 = literal — IRIs sort first. */\n kind: 0 | 1;\n /** IRI value or literal lexical form. */\n primary: string;\n /** Datatype IRI for typed literals; \"\" for IRIs and plain literals. */\n datatype: string;\n /** Language tag for tagged literals; \"\" otherwise. */\n language: string;\n}\n\nfunction renderValue(term: Term): RenderedValue {\n if (term.kind === \"iri\") {\n return {\n value: { \"@id\": term.value },\n kind: 0,\n primary: term.value,\n datatype: \"\",\n language: \"\",\n };\n }\n if (term.language) {\n return {\n value: { \"@value\": term.value, \"@language\": term.language },\n kind: 1,\n primary: term.value,\n datatype: \"\",\n language: term.language,\n };\n }\n if (term.datatype && term.datatype !== XSD_STRING) {\n return {\n value: { \"@value\": term.value, \"@type\": compactIri(term.datatype) },\n kind: 1,\n primary: term.value,\n datatype: term.datatype,\n language: \"\",\n };\n }\n return { value: term.value, kind: 1, primary: term.value, datatype: \"\", language: \"\" };\n}\n\nfunction compareRendered(a: RenderedValue, b: RenderedValue): number {\n if (a.kind !== b.kind) return a.kind - b.kind;\n const p = byCodeUnit(a.primary, b.primary);\n if (p !== 0) return p;\n return byCodeUnit(a.datatype, b.datatype) || byCodeUnit(a.language, b.language);\n}\n\n/** Collapse a sorted value list to a scalar (n=1) or array (n>1). */\nfunction collapse(values: RenderedValue[]): unknown {\n const rendered = [...values].sort(compareRendered).map((v) => v.value);\n return rendered.length === 1 ? rendered[0] : rendered;\n}\n\nexport function emitJsonLd(quads: Quad[]): string {\n const context: Record<string, string> = {};\n for (const [prefix, ns] of PREFIXES) context[prefix] = ns;\n\n // subject → predicate → terms\n const subjects = new Map<string, Map<string, Term[]>>();\n for (const quad of quads) {\n let preds = subjects.get(quad.s);\n if (!preds) {\n preds = new Map();\n subjects.set(quad.s, preds);\n }\n let terms = preds.get(quad.p);\n if (!terms) {\n terms = [];\n preds.set(quad.p, terms);\n }\n terms.push(quad.o);\n }\n\n // Sorting the entries rather than the keys: each predicate map arrives with\n // the subject it belongs to, so there is no second lookup to assert on.\n const graph = [...subjects.entries()]\n .sort(([a], [b]) => byCodeUnit(a, b))\n .map(([subject, preds]) => {\n const node: Record<string, unknown> = { \"@id\": subject };\n\n const types = preds.get(RDF_TYPE);\n if (types) {\n const compacted = types\n .map((t) => compactIri(t.value))\n .sort(byCodeUnit);\n node[\"@type\"] = compacted.length === 1 ? compacted[0] : compacted;\n }\n\n const predEntries = [...preds.entries()]\n .filter(([p]) => p !== RDF_TYPE)\n .sort(([a], [b]) => byCodeUnit(a, b));\n for (const [p, terms] of predEntries) {\n node[compactIri(p)] = collapse(terms.map(renderValue));\n }\n return node;\n });\n\n return `${JSON.stringify({ \"@context\": context, \"@graph\": graph }, null, 2)}\\n`;\n}\n","/**\n * `manni graph traverse` — node-centric graph walking from the CLI (ADR 01018).\n *\n * A thin Node wrapper over the browser-native runtime: it reads the built\n * Turtle, hands the quads to the same `GraphIndex` a browser would build from\n * `graph.jsonld`, and runs the same walker. `query` stays triple-pattern;\n * `traverse` answers \"what is connected to this node, and why\".\n *\n * The trace is always in the JSON output — retrieval provenance is part of the\n * contract, not an opt-in (ADR 01018).\n */\nimport { resolve } from \"node:path\";\nimport { loadRunConfig } from \"../core/config.js\";\nimport {\n compactIri,\n expandTerm,\n loadGraph,\n storeToQuads,\n} from \"../core/load.js\";\nimport { SOFTWARE_SUBJECT_IRIS } from \"../core/iirds.js\";\nimport { NS, PREFIXES } from \"../core/vocab.js\";\nimport { GraphError } from \"../types.js\";\nimport { GraphIndex } from \"../runtime/graph.js\";\nimport {\n impact,\n resolveSubject,\n resolveVariant,\n traverse,\n type Direction,\n type TraverseResult,\n} from \"../runtime/traverse.js\";\n\nexport interface TraverseOptions {\n config?: string;\n /** `--no-config`: skip discovery and run on the built-in defaults. */\n noConfig?: boolean;\n /** Graph .ttl path (default: config `out`). */\n graph?: string;\n /** Starting node: full IRI or a `prefix:local` CURIE. */\n node: string;\n depth?: number;\n predicates?: string[];\n /** Walk inbound edges instead of outbound. */\n reverse?: boolean;\n /** Transitive inbound reach — what is affected if this node changes. */\n impact?: boolean;\n /** Scope filter: a product variant IRI, title, or slug. */\n variant?: string;\n /** Scope filter: a software subject. */\n subject?: string;\n /** Scope filter: a BCP-47 language tag, matched in any case (ADR 01037). */\n lang?: string;\n limit?: number;\n cwd?: string;\n}\n\nexport interface TraverseReport {\n /** The resolved starting IRI. */\n node: string;\n nodes: Array<{ iri: string; depth: number; title?: string }>;\n trace: TraverseResult[\"trace\"];\n}\n\nexport function runTraverse(opts: TraverseOptions): TraverseReport {\n const cwd = opts.cwd ?? process.cwd();\n const config = loadRunConfig(\n {\n ...(opts.config === undefined ? {} : { configPath: opts.config }),\n ...(opts.noConfig === undefined ? {} : { noConfig: opts.noConfig }),\n },\n cwd,\n );\n const store = loadGraph(resolve(cwd, opts.graph ?? config.out));\n const quads = storeToQuads(store);\n const graph = GraphIndex.fromQuads(quads, Object.fromEntries(PREFIXES));\n const { node, predicates } = checkTraverseInputs(graph, quads, opts);\n const direction: Direction = opts.reverse ? \"in\" : \"out\";\n const result = opts.impact\n ? impact(graph, node, {\n depth: opts.depth,\n predicates,\n variant: opts.variant,\n subject: opts.subject,\n language: opts.lang,\n limit: opts.limit,\n })\n : traverse(graph, {\n seeds: [node],\n depth: opts.depth,\n predicates,\n direction,\n variant: opts.variant,\n subject: opts.subject,\n language: opts.lang,\n limit: opts.limit,\n });\n\n return {\n node,\n nodes: result.nodes.map((n) => {\n const title = graph.literal(n.iri, `${NS.dcterms}title`);\n return title === undefined\n ? { iri: n.iri, depth: n.depth }\n : { iri: n.iri, depth: n.depth, title };\n }),\n trace: result.trace,\n };\n}\n\n/**\n * The start node and predicates, expanded, with every input the walker would\n * silently ignore refused first. `traverse --context` checks through it too,\n * so both forms of the verb refuse alike.\n */\nexport function checkTraverseInputs(\n graph: GraphIndex,\n quads: ReturnType<typeof storeToQuads>,\n opts: Pick<TraverseOptions, \"node\" | \"variant\" | \"subject\" | \"predicates\">,\n): { node: string; predicates: string[] | undefined } {\n const node = expandTerm(opts.node);\n if (!graph.has(node)) {\n throw new GraphError(\n `Node not found in the graph: ${opts.node} — check the IRI, or run \\`manni graph build\\` first.`,\n \"unknown-node\",\n );\n }\n checkScope(graph, opts);\n\n const predicates = opts.predicates?.map(expandTerm);\n // A misspelt predicate matches no edge, so the walk returns the seed alone\n // and looks like an answer. Same contract as --variant: fail loudly.\n if (predicates && predicates.length > 0) {\n const used = new Set<string>();\n for (const quad of quads) {\n if (quad.o.kind === \"iri\") used.add(quad.p);\n }\n predicates.forEach((predicate, i) => {\n if (!used.has(predicate)) {\n throw new GraphError(\n `Unknown predicate: ${opts.predicates?.[i] ?? predicate}. No edge in the graph uses it.`,\n \"unknown-scope\",\n );\n }\n });\n }\n return { node, predicates };\n}\n\n/** Refuse a variant or software subject the graph cannot resolve. `retrieve` refuses through it too. */\nexport function checkScope(\n graph: GraphIndex,\n opts: Pick<TraverseOptions, \"variant\" | \"subject\">,\n): void {\n if (opts.variant && !resolveVariant(graph, opts.variant)) {\n throw new GraphError(\n `Unknown product variant: ${opts.variant} — no iirds:ProductVariant matches that IRI, title, or slug.`,\n \"unknown-scope\",\n );\n }\n // An unresolvable scope filter silently disables itself in the walker, which\n // would hand back exactly the nodes the filter was meant to exclude. Fail\n // loudly instead — same contract as --variant above.\n if (opts.subject && !resolveSubject(graph, opts.subject)) {\n throw new GraphError(\n `Unknown software subject: ${opts.subject} — expected one of ` +\n `${Object.keys(SOFTWARE_SUBJECT_IRIS).sort().join(\", \")}, or a full IRI.`,\n \"unknown-scope\",\n );\n }\n}\n\nexport function renderTraverse(\n report: TraverseReport,\n format: \"pretty\" | \"json\",\n): string {\n if (format === \"json\") return JSON.stringify(report, null, 2);\n\n const lines: string[] = [];\n for (const n of report.nodes) {\n const indent = \" \".repeat(n.depth);\n const title = n.title ? ` — ${n.title}` : \"\";\n lines.push(`${indent}${compactIri(n.iri)}${title}`);\n }\n if (report.nodes.length === 0) lines.push(\"(no nodes)\");\n\n if (report.trace.exclusions.length > 0) {\n lines.push(\"\");\n lines.push(\"excluded by scope:\");\n for (const e of report.trace.exclusions) {\n lines.push(\n ` ${compactIri(e.node)} — ${compactIri(e.rule)} ${compactIri(e.value)}`,\n );\n }\n }\n\n lines.push(\"\");\n lines.push(\n `${report.nodes.length} node${report.nodes.length === 1 ? \"\" : \"s\"}, ` +\n `${report.trace.hops.length} hop${report.trace.hops.length === 1 ? \"\" : \"s\"}, ` +\n `${report.trace.exclusions.length} excluded`,\n );\n return lines.join(\"\\n\");\n}\n","/**\n * The one asset that ships with the package and is read by path at runtime: the\n * SHACL shapes. They live under `shapes/graph/` at the package root, listed in\n * `files`, and are reached through the shared package-root walk, which holds\n * both in the source tree (`src/graph/core/`) and in the bundle (`dist/`).\n *\n * The frontmatter schema is no longer one of them. The `graph` page vocabulary\n * is proposal 0023's draft, imported by `src/graph/schema.ts` and inlined by the\n * build, so nothing under `schemas/` is read at run time and nothing under it\n * is published (proposal 0051 §4).\n */\nimport { join } from \"node:path\";\nimport { packageRoot } from \"../../shared/package-root.js\";\n\n/** Absolute path of the bundled SHACL shapes `manni graph check` defaults to. */\nexport function bundledShapesPath(moduleUrl: string): string {\n return join(packageRoot(moduleUrl), \"shapes\", \"graph\", \"shapes-1.4.0.ttl\");\n}\n","/**\n * Graph-level validation: run the published SHACL shapes over a built graph,\n * plus the SKOS integrity checks core SHACL cannot express (broader cycles,\n * related⨯broaderTransitive disjointness, two untagged prefLabels on one\n * concept, a mapping into the scheme itself). Every finding carries the\n * doc paths responsible, so writers get file names instead of bare IRIs, and\n * the shape that judged it, so they learn what the rule is for (proposal 0089).\n */\nimport { readFileSync } from \"node:fs\";\nimport { DataFactory, Parser, Store, type Quad as N3Quad } from \"n3\";\nimport SHACLValidator from \"rdf-validate-shacl\";\nimport type { Term } from \"@rdfjs/types\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport type { Guidance } from \"../../shared/guidance.js\";\nimport type { Severity } from \"../../shared/severity.js\";\nimport { GraphError } from \"../types.js\";\nimport { compactIri } from \"./load.js\";\nimport { bundledShapesPath } from \"./pkg.js\";\nimport { byCodeUnit } from \"./sort.js\";\nimport { NS } from \"./vocab.js\";\n\nconst SH = \"http://www.w3.org/ns/shacl#\";\nconst OWL_ONTOLOGY = \"http://www.w3.org/2002/07/owl#Ontology\";\nconst RDFS_SEE_ALSO = \"http://www.w3.org/2000/01/rdf-schema#seeAlso\";\n\n/** SHACL's own scale, as `sh:severity` spells it. */\nexport type ShaclSeverity = \"violation\" | \"warning\" | \"info\";\n\nexport interface CheckFinding {\n /**\n * The family's scale (`src/shared/severity.ts`). SHACL's three levels map\n * onto it one for one — violation to error, warning to warning, info to\n * notice — and the source value stays in {@link shaclSeverity}, the way\n * a11y keeps axe's `impact` (proposal 0035, stress test 10).\n */\n severity: Severity;\n /**\n * SHACL's own word for the same finding, kept for lookup. Absent on a\n * finding no shape reported, such as a sample question that missed.\n */\n shaclSeverity?: ShaclSeverity;\n /** Human-readable description (IRIs compacted to prefixed names). */\n message: string;\n /** IRI of the node the finding is about. */\n focusNode: string;\n /** Predicate IRI involved, when the finding concerns one. */\n path?: string;\n /** graph:path of the docs responsible, sorted (empty when untraceable). */\n docs: string[];\n /**\n * The shape that judged the finding (proposal 0089): the shapes file's id,\n * the shape's local name, its `sh:description` and the file's guide. `null`\n * when no shape stands behind it, as for a sample question that missed.\n */\n guidance: Guidance | null;\n}\n\n/**\n * SHACL's scale onto the family's. The one place the translation happens, so\n * no caller re-derives it: a finding is built through {@link finding} and\n * carries both words from there on.\n */\nconst FAMILY_SEVERITY: Record<ShaclSeverity, Severity> = {\n violation: \"error\",\n warning: \"warning\",\n info: \"notice\",\n};\n\n/** A finding at `shaclSeverity`, carrying the family severity it maps to. */\nfunction finding(\n shaclSeverity: ShaclSeverity,\n rest: Omit<CheckFinding, \"severity\" | \"shaclSeverity\">,\n): CheckFinding {\n return { severity: FAMILY_SEVERITY[shaclSeverity], shaclSeverity, ...rest };\n}\n\n/** Most severe first: error, warning, notice. */\nconst SEVERITY_RANK: Record<Severity, number> = {\n error: 0,\n warning: 1,\n notice: 2,\n};\n\n/**\n * The one order every check finding is reported in: severity, then focus\n * node, path and message. Exported so findings from outside the shapes sort\n * among them the same way.\n */\nexport function compareFindings(a: CheckFinding, b: CheckFinding): number {\n return (\n SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity] ||\n byCodeUnit(a.focusNode, b.focusNode) ||\n byCodeUnit(a.path ?? \"\", b.path ?? \"\") ||\n byCodeUnit(a.message, b.message)\n );\n}\n\n/**\n * A shapes file to read: where it is, and how a finding names it when the file\n * carries no header. A bare string is both.\n */\nexport type ShapesSource = string | { path: string; label: string };\n\n/** One parsed shapes file, and what names it. */\nexport interface ShapesFile {\n /** The path as given. */\n label: string;\n /**\n * The `dcterms:identifier` of the file's `owl:Ontology` node, such as\n * `manni:graph-shapes:1.1.1`, or the path as given when it has none.\n */\n id: string;\n /** The ontology node's `rdfs:seeAlso`, when it is an http(s) URL. */\n guide: string | null;\n quads: N3Quad[];\n}\n\n/** The shapes in effect: one store, and the file each shape came from. */\nexport interface LoadedShapes {\n store: Store;\n files: ShapesFile[];\n /** A shape's term value (named or blank) to the file that defines it. */\n fileOf: Map<string, ShapesFile>;\n}\n\n/** Read and parse one shapes file. */\nexport function readShapesFile(source: ShapesSource): ShapesFile {\n const { path, label } = typeof source === \"string\" ? { path: source, label: source } : source;\n let text: string;\n try {\n text = readFileSync(path, \"utf8\");\n } catch (e) {\n // Only a missing file gets the recovery advice. Any other read error is\n // the OS's to explain.\n if ((e as NodeJS.ErrnoException).code === \"ENOENT\") {\n throw new GraphError(\n `Shapes file not found: ${path}. Fix the path in --shapes or graph.check.shapes. Leave both unset to use the bundled shapes.`,\n );\n }\n throw new GraphError(`Failed to read shapes ${path}: ${errorMessage(e)}`);\n }\n let quads: N3Quad[];\n try {\n quads = new Parser({ format: \"text/turtle\" }).parse(text);\n } catch (e) {\n throw new GraphError(`Failed to parse shapes ${path}: ${errorMessage(e)}`);\n }\n const header = new Store(quads);\n const ontology = header\n .getSubjects(DataFactory.namedNode(`${NS.rdf}type`), DataFactory.namedNode(OWL_ONTOLOGY), null)\n .map((s) => s.value)\n .sort(byCodeUnit)[0];\n const first = (predicate: string): string | undefined =>\n ontology === undefined\n ? undefined\n : header\n .getObjects(DataFactory.namedNode(ontology), DataFactory.namedNode(predicate), null)\n .map((o) => o.value)\n .sort(byCodeUnit)[0];\n const seeAlso = first(RDFS_SEE_ALSO);\n return {\n label,\n id: first(`${NS.dcterms}identifier`) ?? label,\n guide: seeAlso !== undefined && /^https?:\\/\\//.test(seeAlso) ? seeAlso : null,\n quads,\n };\n}\n\n/** Parse one or more shapes .ttl files into a single store. */\nexport function loadShapes(sources: ShapesSource[]): LoadedShapes {\n const store = new Store();\n const files: ShapesFile[] = [];\n const fileOf = new Map<string, ShapesFile>();\n for (const source of sources) {\n const file = readShapesFile(source);\n files.push(file);\n store.addQuads(file.quads);\n // The first file to say anything about a shape owns it. n3 gives each\n // parse its own blank-node prefix, so a blank shape cannot collide.\n for (const q of file.quads) {\n if (!fileOf.has(q.subject.value)) fileOf.set(q.subject.value, file);\n }\n }\n return { store, files, fileOf };\n}\n\n/** `…/shapes/1.1.1#Document-language` → `Document-language`. */\nexport function localName(iri: string): string {\n const hash = iri.lastIndexOf(\"#\");\n return iri.slice((hash === -1 ? iri.lastIndexOf(\"/\") : hash) + 1);\n}\n\n/**\n * A literal of `shape` under `predicate`, untagged or English first, then by\n * language. `null` when the shape has none.\n */\nexport function shapeText(store: Store, shape: Term, predicate: string): string | null {\n const subject =\n shape.termType === \"BlankNode\"\n ? DataFactory.blankNode(shape.value)\n : DataFactory.namedNode(shape.value);\n return preferredLiteral(store.getObjects(subject, DataFactory.namedNode(predicate), null));\n}\n\n/** The untagged literal first, then English, then by language and value. */\nfunction preferredLiteral(terms: Term[]): string | null {\n const literals = terms.flatMap((t) =>\n t.termType === \"Literal\" ? [{ value: t.value, language: t.language }] : [],\n );\n const rank = (lang: string): number => (lang === \"\" ? 0 : lang.startsWith(\"en\") ? 1 : 2);\n literals.sort(\n (a, b) =>\n rank(a.language) - rank(b.language) ||\n byCodeUnit(a.language, b.language) ||\n byCodeUnit(a.value, b.value),\n );\n return literals[0]?.value ?? null;\n}\n\n/** How a message names a concept: its prefLabel, else its compact IRI. */\nfunction labelOf(store: Store, iri: string): string {\n return (\n preferredLiteral(\n store.getObjects(DataFactory.namedNode(iri), DataFactory.namedNode(`${NS.skos}prefLabel`), null),\n ) ?? compactIri(iri)\n );\n}\n\n/** `\"A\"`, `\"A\" and \"B\"`, `\"A\", \"B\" and \"C\"`. */\nfunction quotedList(values: string[]): string {\n const quoted = values.map((v) => `\"${v}\"`);\n const last = quoted.pop();\n if (last === undefined) return \"\";\n return quoted.length === 0 ? last : `${quoted.join(\", \")} and ${last}`;\n}\n\n/** What a finding a shape reported says about that shape. */\nfunction shapeGuidance(loaded: LoadedShapes, shape: Term | null): Guidance | null {\n if (shape === null) return null;\n // Unreachable miss: a shape that reports has constraint triples, and every triple came from a file.\n const file = loaded.fileOf.get(shape.value);\n if (file === undefined) return null;\n const named = shape.termType === \"NamedNode\";\n return {\n id: file.id,\n rule: named ? localName(shape.value) : null,\n description: named ? shapeText(loaded.store, shape, `${SH}description`) : null,\n guide: file.guide,\n };\n}\n\nlet bundled: LoadedShapes | undefined;\n\n/**\n * The guidance for a check-core finding: the bundled shape for its path,\n * whatever shapes the run validated against. These checks are manni's own\n * code, so the bundled contract is what speaks for them.\n */\nfunction coreGuidance(rule: string): Guidance | null {\n bundled ??= loadShapes([bundledShapesPath(import.meta.url)]);\n const shape = bundled.store\n .getSubjects(DataFactory.namedNode(`${NS.rdf}type`), DataFactory.namedNode(`${SH}PropertyShape`), null)\n .find((s) => localName(s.value) === rule);\n return shape === undefined ? null : shapeGuidance(bundled, shape);\n}\n\n/**\n * Trace a focus node back to the doc(s) responsible: its own graph:path,\n * the path of its fragment-stripped base (sections, provenance fragments),\n * or — for shared nodes like concepts and agents — the paths of docs that\n * point at it, up to two hops back. Sorted and deduplicated.\n */\nexport function blameDocs(store: Store, focus: string): string[] {\n const pathPred = DataFactory.namedNode(`${NS.graph}path`);\n const pathOf = (iri: string): string | undefined =>\n store.getQuads(DataFactory.namedNode(iri), pathPred, null, null)[0]?.object.value;\n\n const found = new Set<string>();\n const visited = new Set<string>();\n\n const walk = (iri: string, depth: number): void => {\n if (visited.has(iri)) return;\n visited.add(iri);\n\n const own = pathOf(iri);\n if (own !== undefined) {\n found.add(own);\n return;\n }\n const hash = iri.indexOf(\"#\");\n if (hash !== -1) {\n const base = pathOf(iri.slice(0, hash));\n if (base !== undefined) {\n found.add(base);\n return;\n }\n }\n if (depth === 0) return;\n for (const quad of store.getQuads(null, null, DataFactory.namedNode(iri), null)) {\n if (quad.subject.termType === \"NamedNode\") {\n walk(quad.subject.value, depth - 1);\n }\n }\n };\n\n walk(focus, 2);\n return [...found].sort();\n}\n\ninterface Edge {\n s: string;\n o: string;\n}\n\n/** skos:broader edges, folding narrower in as its inverse. */\nfunction broaderEdges(store: Store): Edge[] {\n const edges: Edge[] = [];\n for (const q of store.getQuads(\n null,\n DataFactory.namedNode(`${NS.skos}broader`),\n null,\n null,\n )) {\n if (q.object.termType === \"NamedNode\") {\n edges.push({ s: q.subject.value, o: q.object.value });\n }\n }\n for (const q of store.getQuads(\n null,\n DataFactory.namedNode(`${NS.skos}narrower`),\n null,\n null,\n )) {\n if (q.object.termType === \"NamedNode\") {\n edges.push({ s: q.object.value, o: q.subject.value });\n }\n }\n return edges;\n}\n\n/**\n * Strongly connected components of the broader graph (iterative Tarjan —\n * no recursion, taxonomy depth can't blow the stack). Returns only real\n * cycles: components of 2+ nodes, or single nodes with a self-loop.\n */\nexport function broaderCycles(store: Store): string[][] {\n const adjacency = new Map<string, string[]>();\n const selfLoops = new Set<string>();\n for (const { s, o } of broaderEdges(store)) {\n if (s === o) selfLoops.add(s);\n const list = adjacency.get(s);\n if (list) list.push(o);\n else adjacency.set(s, [o]);\n if (!adjacency.has(o)) adjacency.set(o, []);\n }\n for (const list of adjacency.values()) list.sort();\n\n const index = new Map<string, number>();\n const lowlink = new Map<string, number>();\n const onStack = new Set<string>();\n const stack: string[] = [];\n const components: string[][] = [];\n let counter = 0;\n\n /**\n * A node's Tarjan number. Every node is stamped into both maps on the frame\n * where `childIdx === 0`, before any edge out of it is followed, so a miss\n * here is not a missing value but a broken traversal — which is worth\n * saying rather than reading as `NaN` three lines later.\n */\n const numberOf = (map: Map<string, number>, node: string): number => {\n const value = map.get(node);\n if (value === undefined) {\n throw new GraphError(\n `internal: ${node} was visited before it was numbered`,\n );\n }\n return value;\n };\n\n const nodes = [...adjacency.keys()].sort();\n for (const root of nodes) {\n if (index.has(root)) continue;\n // Explicit work stack of [node, next-child-index] frames. The loop reads\n // the top frame as its condition, so the frame is proven present by the\n // same test that keeps the loop running.\n const frames: Array<[string, number]> = [[root, 0]];\n for (let frame = frames.at(-1); frame !== undefined; frame = frames.at(-1)) {\n const [node, childIdx] = frame;\n if (childIdx === 0) {\n index.set(node, counter);\n lowlink.set(node, counter);\n counter += 1;\n stack.push(node);\n onStack.add(node);\n }\n const children = adjacency.get(node) ?? [];\n // Reading the child *is* the bounds check: `adjacency` holds dense\n // arrays of strings, so a hit is a child and a miss is the end of them.\n const child = children[childIdx];\n if (child !== undefined) {\n frame[1] += 1;\n if (!index.has(child)) {\n frames.push([child, 0]);\n } else if (onStack.has(child)) {\n lowlink.set(\n node,\n Math.min(numberOf(lowlink, node), numberOf(index, child)),\n );\n }\n } else {\n if (lowlink.get(node) === index.get(node)) {\n const component: string[] = [];\n let member: string | undefined;\n do {\n member = stack.pop();\n if (member === undefined) break;\n onStack.delete(member);\n component.push(member);\n } while (member !== node);\n if (component.length > 1 || selfLoops.has(node)) {\n components.push(component.sort());\n }\n }\n frames.pop();\n const parent = frames.at(-1);\n if (parent) {\n lowlink.set(\n parent[0],\n Math.min(numberOf(lowlink, parent[0]), numberOf(lowlink, node)),\n );\n }\n }\n }\n }\n // A component always has a member — it is built by popping at least one —\n // so `?? \"\"` is a spelling of that, not a fallback anyone can reach.\n return components.sort((a, b) => ((a[0] ?? \"\") < (b[0] ?? \"\") ? -1 : 1));\n}\n\n/** Forward reachability over broader edges from each given start node. */\nfunction broaderClosure(edges: Edge[], start: string): Set<string> {\n const adjacency = new Map<string, string[]>();\n for (const { s, o } of edges) {\n const list = adjacency.get(s);\n if (list) list.push(o);\n else adjacency.set(s, [o]);\n }\n const seen = new Set<string>();\n const queue = [...(adjacency.get(start) ?? [])];\n // Shifting *is* the emptiness test, so the queue is never read past its end.\n for (let node = queue.shift(); node !== undefined; node = queue.shift()) {\n if (seen.has(node)) continue;\n seen.add(node);\n queue.push(...(adjacency.get(node) ?? []));\n }\n return seen;\n}\n\n/**\n * SKOS S27: skos:related is disjoint with skos:broaderTransitive. Reported\n * once per unordered pair, because derive writes skos:related both ways\n * round, and on the descendant. A pair where SHACL's one-hop sh:disjoint\n * already fires is skipped, so one mistake doesn't produce two findings.\n */\nfunction relatedConflicts(store: Store): CheckFinding[] {\n const edges = broaderEdges(store);\n const related = `${NS.skos}related`;\n // Pairs as nested maps rather than joined keys: a joined key would need a\n // separator character, and IRIs make any choice fragile.\n const has = (index: Map<string, Set<string>>, a: string, b: string): boolean =>\n index.get(a)?.has(b) ?? false;\n const put = (index: Map<string, Set<string>>, a: string, b: string): void => {\n const targets = index.get(a);\n if (targets) targets.add(b);\n else index.set(a, new Set([b]));\n };\n const index = (predicate: string): Map<string, Set<string>> => {\n const out = new Map<string, Set<string>>();\n for (const q of store.getQuads(null, DataFactory.namedNode(predicate), null, null)) {\n if (q.object.termType === \"NamedNode\") put(out, q.subject.value, q.object.value);\n }\n return out;\n };\n const relatedIndex = index(related);\n const broaderIndex = index(`${NS.skos}broader`);\n // Where Concept-related's sh:disjoint fires: one node holds both links.\n const disjointFires = (a: string, b: string): boolean =>\n (has(relatedIndex, a, b) && has(broaderIndex, a, b)) ||\n (has(relatedIndex, b, a) && has(broaderIndex, b, a));\n\n const closures = new Map<string, Set<string>>();\n const ancestors = (node: string): Set<string> => {\n let found = closures.get(node);\n if (found === undefined) {\n found = broaderClosure(edges, node);\n closures.set(node, found);\n }\n return found;\n };\n\n const seen = new Map<string, Set<string>>();\n const findings: CheckFinding[] = [];\n for (const [s, targets] of [...relatedIndex].sort(([a], [b]) => byCodeUnit(a, b))) {\n for (const o of [...targets].sort(byCodeUnit)) {\n const [a, b] = byCodeUnit(s, o) <= 0 ? [s, o] : [o, s];\n if (has(seen, a, b)) continue;\n put(seen, a, b);\n if (disjointFires(a, b)) continue;\n const bAboveA = ancestors(a).has(b);\n if (!bAboveA && !ancestors(b).has(a)) continue;\n const [descendant, ancestor] = bAboveA ? [a, b] : [b, a];\n findings.push(\n finding(\"violation\", {\n message: `\"${labelOf(store, ancestor)}\" is both related to \"${labelOf(store, descendant)}\" and one of its ancestors. Remove one link: from \\`related-concepts\\` or \\`related-terms\\`, or from the \\`broader\\` chain between them.`,\n focusNode: descendant,\n path: related,\n docs: [\n ...new Set([...blameDocs(store, descendant), ...blameDocs(store, ancestor)]),\n ].sort(byCodeUnit),\n guidance: coreGuidance(\"Concept-related\"),\n }),\n );\n }\n }\n return findings;\n}\n\nfunction cycleFindings(store: Store): CheckFinding[] {\n return broaderCycles(store).map((members) => {\n const labels = members.map((m) => labelOf(store, m));\n return finding(\"violation\", {\n message:\n labels.length === 1\n ? `${quotedList(labels)} forms a broader cycle with itself, so it is its own ancestor. Remove the \\`broader\\` or \\`narrower\\` value that names it.`\n : `${quotedList(labels)} form a broader cycle, so each is its own ancestor. Remove one \\`broader\\` or \\`narrower\\` value on the cycle.`,\n // `broaderCycles` returns only components of at least one member, so\n // the first is there; `?? \"\"` says that without asserting it.\n focusNode: members[0] ?? \"\",\n path: `${NS.skos}broader`,\n docs: [...new Set(members.flatMap((m) => blameDocs(store, m)))].sort(),\n guidance: coreGuidance(\"Concept-broader\"),\n });\n });\n}\n\n/**\n * Shapes 1.0.0 reported the untagged collision itself, with this message. A\n * run that pins 1.0.0 still carries it, and the check core's copy would only\n * repeat it.\n */\nconst SHAPES_1_0_0_COLLISION =\n \"concept carries multiple prefLabels (same slug, different spellings) — settle on one spelling\";\n\n/**\n * The prefLabel collision SHACL Core cannot express. Concept IRIs converge on\n * slugified labels, so \"Configuration\" and \"configuration\" land on one concept\n * with two untagged spellings. `sh:uniqueLang` catches two labels in one\n * language and ignores untagged ones, so this catches those.\n */\nfunction untaggedPrefLabelFindings(store: Store): CheckFinding[] {\n const prefLabel = `${NS.skos}prefLabel`;\n const untagged = new Map<string, Set<string>>();\n for (const q of store.getQuads(null, DataFactory.namedNode(prefLabel), null, null)) {\n if (q.object.termType !== \"Literal\" || q.object.language !== \"\") continue;\n const spellings = untagged.get(q.subject.value);\n if (spellings) spellings.add(q.object.value);\n else untagged.set(q.subject.value, new Set([q.object.value]));\n }\n return [...untagged]\n .filter(([, spellings]) => spellings.size > 1)\n .map(([focusNode, spellings]) =>\n finding(\"warning\", {\n message: `Pages spell this concept ${spellings.size === 2 ? \"two\" : String(spellings.size)} ways: ${quotedList([...spellings].sort(byCodeUnit))}. Use one spelling on every page that names it.`,\n focusNode,\n path: prefLabel,\n docs: blameDocs(store, focusNode),\n guidance: coreGuidance(\"Concept-prefLabel-collision\"),\n }),\n );\n}\n\n/**\n * The SKOS mapping properties, each beside the term-page key that writes it.\n * Each links a concept to one in another scheme.\n */\nconst MAPPINGS = [\n [\"exactMatch\", \"exact-matches\"],\n [\"closeMatch\", \"close-matches\"],\n [\"broadMatch\", \"broad-matches\"],\n [\"narrowMatch\", \"narrow-matches\"],\n [\"relatedMatch\", \"related-matches\"],\n] as const;\n\n/**\n * A mapping whose object is a concept in this graph's scheme. SKOS keeps the\n * mapping properties for links between schemes, so inside one the relation is\n * broader, narrower or related.\n */\nfunction inSchemeMappingFindings(store: Store): CheckFinding[] {\n const inScheme = DataFactory.namedNode(`${NS.skos}inScheme`);\n const findings: CheckFinding[] = [];\n for (const [mapping, key] of MAPPINGS) {\n const path = `${NS.skos}${mapping}`;\n for (const q of store.getQuads(null, DataFactory.namedNode(path), null, null)) {\n if (q.object.termType !== \"NamedNode\") continue;\n // Into *this* scheme: the target shares a scheme with the concept that\n // maps to it. A concept of an outside scheme carried in the graph keeps\n // its own `skos:inScheme`, and mapping to it is the point of a match.\n const schemes = new Set(store.getObjects(q.subject, inScheme, null).map((o) => o.value));\n const shared = store.getObjects(q.object, inScheme, null).some((o) => schemes.has(o.value));\n if (!shared) continue;\n findings.push(\n finding(\"violation\", {\n message: `\\`${key}\\` names \"${labelOf(store, q.object.value)}\", a concept in this glossary. Use \\`broader\\`, \\`narrower\\` or \\`related-terms\\` for it instead.`,\n focusNode: q.subject.value,\n path,\n docs: blameDocs(store, q.subject.value),\n guidance: coreGuidance(`Concept-${mapping}`),\n }),\n );\n }\n }\n return findings;\n}\n\n/**\n * The three `graph` fields a machine may never be attributed for. The old\n * `kg.provenance` schema enumerated the twelve *fillable* fields, which kept\n * these out; a free JSON Pointer cannot express that, so proposal 0046 stress\n * test 13 moved the guard into graph's harvest and, from there, to here.\n */\nconst CURATED_FIELDS = new Set([\"sections\", \"revision-of\", \"derived-from\"]);\n\n/** The fragment a `graph fill` activity's IRI carries, before its model slug. */\nconst GRAPH_FILL_FRAGMENT = \"#prov.graph-fill.\";\n\n/**\n * A machine attribution on a hand-curated field. `check` reads only the built\n * graph and `build` has no findings channel, so the store is where the fact is\n * read: the harvest has already put `graph:filledField \"sections\"` on a field\n * node under a `#prov.graph-fill.` activity.\n */\nfunction curatedFieldFindings(store: Store): CheckFinding[] {\n const filledField = `${NS.graph}filledField`;\n const pathPred = DataFactory.namedNode(`${NS.graph}path`);\n const findings: CheckFinding[] = [];\n for (const q of store.getQuads(null, DataFactory.namedNode(filledField), null, null)) {\n if (q.object.termType !== \"Literal\") continue;\n const field = q.object.value;\n if (!CURATED_FIELDS.has(field)) continue;\n const node = q.subject.value;\n const at = node.indexOf(GRAPH_FILL_FRAGMENT);\n const fieldAt = node.lastIndexOf(\".field.\");\n if (at === -1 || fieldAt <= at) continue;\n const activity = node.slice(0, fieldAt);\n // The model the activity is for, from its own fragment. Naming it beats\n // repeating the activity IRI, which the reporter already prints as the\n // focus node ahead of this message.\n const model = node.slice(at + GRAPH_FILL_FRAGMENT.length, fieldAt);\n // These activities hang off no document edge, so `blameDocs` cannot walk\n // back to one. The doc IRI is the activity's own, minus its fragment.\n const docIri = activity.slice(0, activity.indexOf(\"#\"));\n const path = store.getQuads(DataFactory.namedNode(docIri), pathPred, null, null)[0]\n ?.object.value;\n findings.push(\n finding(\"violation\", {\n message: `\\`meta-provenance\\` credits ${model} with /graph/${field}, a field only a person writes. Check the value, then delete that entry.`,\n focusNode: activity,\n path: filledField,\n docs: path === undefined ? blameDocs(store, activity) : [path],\n guidance: coreGuidance(\"FilledFieldEntry-name\"),\n }),\n );\n }\n return findings;\n}\n\n/**\n * One validation result, with the nullability its library documents in code\n * rather than in its `.d.ts`.\n *\n * `rdf-validate-shacl` declares `path`, `focusNode` and `severity` as `Term`,\n * and every one of them is `…out(ns.sh.resultPath).term || null` at runtime. A\n * result with no path is ordinary — a node-shape constraint has none — so the\n * guards at the read site are the real contract and the declaration is the\n * optimistic one. Saying so once here is what keeps them from reading as\n * checks that cannot fail.\n */\ninterface ShaclResult {\n message: Term[];\n path: Term | null;\n focusNode: Term | null;\n severity: Term | null;\n sourceShape: Term | null;\n}\n\nfunction severityOf(iri: string | undefined): ShaclSeverity {\n if (iri === \"http://www.w3.org/ns/shacl#Warning\") return \"warning\";\n if (iri === \"http://www.w3.org/ns/shacl#Info\") return \"info\";\n return \"violation\";\n}\n\n/**\n * Validate a built graph against SHACL shapes files, merge in the TS-side\n * SKOS checks, and return deterministic, doc-blamed findings.\n */\nexport async function validateGraph(\n store: Store,\n shapesPaths: ShapesSource[],\n): Promise<CheckFinding[]> {\n const shapes = loadShapes(shapesPaths);\n const validator = new SHACLValidator(shapes.store);\n let report;\n try {\n report = await validator.validate(store);\n } catch (e) {\n throw new GraphError(\n `SHACL validation failed: ${errorMessage(e)}`,\n );\n }\n\n // One finding per (shape, focus node, path): a shape that fails on two\n // values of one property is one mistake, so it reports once. Nested maps\n // rather than a joined key, for the reason `relatedConflicts` gives. Each\n // keeps its distinct messages, joined once the results are all read.\n type Merged = { found: CheckFinding; messages: string[] };\n const merged = new Map<string, Map<string, Map<string, Merged>>>();\n const groups: Merged[] = [];\n for (const result of report.results as ShaclResult[]) {\n const focus = result.focusNode?.value ?? \"\";\n const path = result.path?.value;\n const messages = result.message\n .map((m) => m.value)\n .filter((m) => m.length > 0);\n // The shape's own sh:message wins, as SHACL says it does. The library\n // lets a validator's text override it (sh:uniqueLang's does), so it is\n // read back here. One with a {$this} or {?var} placeholder is left to\n // the library, which substitutes it.\n const declared =\n result.sourceShape === null ? null : shapeText(shapes.store, result.sourceShape, `${SH}message`);\n const message =\n declared !== null && !/\\{[$?]/.test(declared)\n ? declared\n : messages.length > 0\n ? messages.join(\"; \")\n : `constraint violated${path ? ` on ${compactIri(path)}` : \"\"}`;\n const byFocus = merged.get(result.sourceShape?.value ?? \"\") ?? new Map<string, Map<string, Merged>>();\n merged.set(result.sourceShape?.value ?? \"\", byFocus);\n const byPath = byFocus.get(focus) ?? new Map<string, Merged>();\n byFocus.set(focus, byPath);\n const earlier = byPath.get(path ?? \"\");\n if (earlier !== undefined) {\n if (!earlier.messages.includes(message)) earlier.messages.push(message);\n continue;\n }\n const found = finding(severityOf(result.severity?.value), {\n message,\n focusNode: focus,\n ...(path !== undefined ? { path } : {}),\n docs: blameDocs(store, focus),\n guidance: shapeGuidance(shapes, result.sourceShape),\n });\n const group = { found, messages: [message] };\n byPath.set(path ?? \"\", group);\n groups.push(group);\n }\n const findings = groups.map(({ found, messages }) => ({ ...found, message: messages.join(\"; \") }));\n\n // Shapes 1.0.0 still says the untagged collision itself, with this message.\n // The check core's copy adds nothing beside it.\n const said = new Set(\n findings\n .filter((f) => f.message === SHAPES_1_0_0_COLLISION)\n .map((f) => f.focusNode),\n );\n findings.push(\n ...cycleFindings(store),\n ...relatedConflicts(store),\n ...curatedFieldFindings(store),\n ...inSchemeMappingFindings(store),\n ...untaggedPrefLabelFindings(store).filter((f) => !said.has(f.focusNode)),\n );\n\n findings.sort(compareFindings);\n return findings;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,YAAY,oBAAoB;AACzC,SAAS,QAAQ,aAAa;AAM9B,IAAM,aAAa,GAAG,GAAG,GAAG;AAErB,SAAS,UAAU,SAAwB;AAChD,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,UAAM,IAAI;AAAA,MACR,oBAAoB,OAAO;AAAA,IAC7B;AAAA,EACF;AACA,SAAO,WAAW,aAAa,SAAS,MAAM,GAAG,OAAO;AAC1D;AAGO,SAAS,WAAW,QAAgB,OAAsB;AAC/D,QAAM,SAAS,IAAI,OAAO,EAAE,QAAQ,cAAc,CAAC;AACnD,MAAI;AACJ,MAAI;AACF,YAAQ,OAAO,MAAM,MAAM;AAAA,EAC7B,SAAS,GAAG;AACV,UAAM,IAAI;AAAA,MACR,mBAAmB,KAAK,KAAK,aAAa,CAAC,CAAC;AAAA,IAC9C;AAAA,EACF;AACA,SAAO,IAAI,MAAM,KAAK;AACxB;AAQO,SAAS,aAAa,OAAsB;AACjD,SAAO,MAAM,SAAS,MAAM,MAAM,MAAM,IAAI,EAAE,IAAI,CAAC,MAAM;AACvD,UAAM,IAAI,EAAE;AACZ,QAAI;AACJ,QAAI,EAAE,aAAa,aAAa,EAAE,aAAa,IAAI;AACjD,aAAO,EAAE,MAAM,WAAW,OAAO,EAAE,OAAO,UAAU,EAAE,SAAS;AAAA,IACjE,WAAW,EAAE,aAAa,WAAW;AACnC,YAAM,KAAK,EAAE,SAAS;AACtB,aACE,MAAM,OAAO,aACT,EAAE,MAAM,WAAW,OAAO,EAAE,OAAO,UAAU,GAAG,IAChD,EAAE,MAAM,WAAW,OAAO,EAAE,MAAM;AAAA,IAC1C,OAAO;AACL,aAAO,EAAE,MAA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AK;AAC5B,WAAO,KAAK,KAAK;AAAA,EACnB;AACA,QAAM,WAAW,OAAO,IAAI,CAAC,EAAE,OAAO,SAAS,OAAO,EAAE,GAAG,OAAO,SAAS,SAAS,KAAK,IAAI,EAAE,EAAE;AAIjG,QAAM,OAAO,IAAI;AAAA,IACf,SACG,OAAO,CAAC,MAAM,EAAE,YAAY,sBAAsB,EAClD,IAAI,CAAC,MAAM,EAAE,SAAS;AAAA,EAC3B;AACA,WAAS;AAAA,IACP,GAAG,cAAc,KAAK;AAAA,IACtB,GAAG,iBAAiB,KAAK;AAAA,IACzB,GAAG,qBAAqB,KAAK;AAAA,IAC7B,GAAG,wBAAwB,KAAK;AAAA,IAChC,GAAG,0BAA0B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,SAAS,CAAC;AAAA,EAC1E;AAEA,WAAS,KAAK,eAAe;AAC7B,SAAO;AACT;","names":["existsSync","readFileSync","readFileSync","existsSync","entry","createHash","existsSync","readFileSync","join","resolve","existsSync","readFileSync","resolve","slice","GRAPH_PATH","GRAPH_LEVEL","DCTERMS_TITLE","resolve","existsSync","readFileSync","languageOf","entry","join","existsSync","readFileSync","entry","resolve","createHash","readRecord","of","range","languageOf","existsSync","readFileSync","join","resolve","XSD_STRING","DOCUMENT","PATH","LEVEL","TITLE","LANGUAGE","resolve","existsSync","readFileSync","kept","join","entry","resolve","resolve","join","join","readFileSync","Parser","Store","readFileSync","Parser","Store","index"]}