@hawkeyexl/manni 4.12.4 → 4.14.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.
- package/README.md +1 -1
- package/dist/batch-TKNIUBLK.js +48 -0
- package/dist/build-6G7PEAG4.js +37 -0
- package/dist/calibrate-BDCXDZV5.js +43 -0
- package/dist/capture-NQJLZD66.js +39 -0
- package/dist/check-552X5I2J.js +36 -0
- package/dist/{check-3O2PZ7TZ.js → check-5HMDJOFP.js} +15 -14
- package/dist/check-BSB4FF4L.js +33 -0
- package/dist/{check-V7JUDAPS.js → check-QIZCTAIR.js} +33 -32
- package/dist/{check-V7JUDAPS.js.map → check-QIZCTAIR.js.map} +1 -1
- package/dist/{chunk-Z42MO7SO.js → chunk-2A6XYSXO.js} +58 -10
- package/dist/chunk-2A6XYSXO.js.map +1 -0
- package/dist/{chunk-HP43LH7E.js → chunk-2HQSMZ4N.js} +11 -5
- package/dist/chunk-2HQSMZ4N.js.map +1 -0
- package/dist/{chunk-EBZ4QKKX.js → chunk-36FJWJSK.js} +132 -27
- package/dist/chunk-36FJWJSK.js.map +1 -0
- package/dist/{chunk-WWKXPPN5.js → chunk-3BMTCS4H.js} +33 -18
- package/dist/chunk-3BMTCS4H.js.map +1 -0
- package/dist/{chunk-7QH2ZI4F.js → chunk-3CCY7M3R.js} +56 -29
- package/dist/chunk-3CCY7M3R.js.map +1 -0
- package/dist/{chunk-PNUM6RHR.js → chunk-3MTZZJKH.js} +3 -3
- package/dist/chunk-4U3X7LYV.js +236 -0
- package/dist/chunk-4U3X7LYV.js.map +1 -0
- package/dist/{chunk-ZCJUSQM7.js → chunk-56URKBXQ.js} +17 -17
- package/dist/chunk-56URKBXQ.js.map +1 -0
- package/dist/{chunk-PP22XDW2.js → chunk-66MKBRTA.js} +88 -12
- package/dist/chunk-66MKBRTA.js.map +1 -0
- package/dist/{chunk-7JUIJ7Q5.js → chunk-6VT3Z352.js} +24 -7
- package/dist/chunk-6VT3Z352.js.map +1 -0
- package/dist/{chunk-CU57HT2E.js → chunk-6WJUZQQX.js} +2 -2
- package/dist/{chunk-KRKNZ3IV.js → chunk-6XFSZCLT.js} +31 -13
- package/dist/chunk-6XFSZCLT.js.map +1 -0
- package/dist/{chunk-VFL3ERMI.js → chunk-742G2QCV.js} +4 -3
- package/dist/{chunk-VFL3ERMI.js.map → chunk-742G2QCV.js.map} +1 -1
- package/dist/chunk-7AXJY4FX.js +83 -0
- package/dist/chunk-7AXJY4FX.js.map +1 -0
- package/dist/{chunk-PSPNIAOP.js → chunk-7KOWE4F4.js} +14 -16
- package/dist/chunk-7KOWE4F4.js.map +1 -0
- package/dist/{chunk-J4ZOTZII.js → chunk-7PENJOI6.js} +14 -8
- package/dist/{chunk-J4ZOTZII.js.map → chunk-7PENJOI6.js.map} +1 -1
- package/dist/chunk-7WVWGULD.js +81 -0
- package/dist/chunk-7WVWGULD.js.map +1 -0
- package/dist/{chunk-4IW6FAUN.js → chunk-A7MNH4YI.js} +88 -7
- package/dist/chunk-A7MNH4YI.js.map +1 -0
- package/dist/{chunk-4TGIGVFO.js → chunk-AJYUJ37M.js} +65 -8
- package/dist/chunk-AJYUJ37M.js.map +1 -0
- package/dist/{chunk-OTJOBZJ5.js → chunk-B2242FYO.js} +2 -1
- package/dist/chunk-B2242FYO.js.map +1 -0
- package/dist/{chunk-U4SY2TJS.js → chunk-B6GUSA53.js} +15 -10
- package/dist/chunk-B6GUSA53.js.map +1 -0
- package/dist/{chunk-5NNPEPVM.js → chunk-BA4TCCOO.js} +5 -5
- package/dist/{chunk-X4GQ4HPY.js → chunk-BAWKNF6U.js} +3 -3
- package/dist/{chunk-Y4TDIUG6.js → chunk-BIRGZEWO.js} +86 -10
- package/dist/chunk-BIRGZEWO.js.map +1 -0
- package/dist/chunk-BREAC43H.js +85 -0
- package/dist/chunk-BREAC43H.js.map +1 -0
- package/dist/{chunk-YQV75FIL.js → chunk-CFMI74TP.js} +3 -3
- package/dist/{chunk-DTXLFSAB.js → chunk-CZJNYHK7.js} +2 -2
- package/dist/{chunk-AATCO43N.js → chunk-D2TIZOMN.js} +6 -5
- package/dist/chunk-D2TIZOMN.js.map +1 -0
- package/dist/{chunk-3FXPIZXL.js → chunk-EXAZ7K25.js} +5 -5
- package/dist/{chunk-BGRP44SX.js → chunk-GHZAOPGK.js} +148 -92
- package/dist/chunk-GHZAOPGK.js.map +1 -0
- package/dist/{chunk-XP4RNQZL.js → chunk-HGU4FDRY.js} +242 -15
- package/dist/chunk-HGU4FDRY.js.map +1 -0
- package/dist/{chunk-ZXRAE55H.js → chunk-IGRXQC3H.js} +2 -2
- package/dist/{chunk-6KONPVHQ.js → chunk-IOYEPB27.js} +5 -5
- package/dist/{chunk-U6IHLEWT.js → chunk-JCTHXG33.js} +2 -2
- package/dist/{chunk-TBAMBLF3.js → chunk-JNMY7KZG.js} +132 -15
- package/dist/chunk-JNMY7KZG.js.map +1 -0
- package/dist/{chunk-QWE3WLV4.js → chunk-JTEWU4C6.js} +26 -16
- package/dist/chunk-JTEWU4C6.js.map +1 -0
- package/dist/{chunk-KQRYW4DN.js → chunk-JWBS7YDI.js} +8 -8
- package/dist/chunk-JWBS7YDI.js.map +1 -0
- package/dist/{chunk-EX6E2P6Z.js → chunk-LCRBR7KW.js} +10 -4
- package/dist/chunk-LCRBR7KW.js.map +1 -0
- package/dist/{chunk-JAPSZ44X.js → chunk-M43NTWVH.js} +10 -7
- package/dist/chunk-M43NTWVH.js.map +1 -0
- package/dist/chunk-M534DYAJ.js +76 -0
- package/dist/chunk-M534DYAJ.js.map +1 -0
- package/dist/chunk-MC7U5IH4.js +126 -0
- package/dist/chunk-MC7U5IH4.js.map +1 -0
- package/dist/{chunk-7TVIFCGT.js → chunk-MIGFQP5N.js} +2 -2
- package/dist/{chunk-TZOYZK2E.js → chunk-OZUPJB4J.js} +2 -2
- package/dist/{chunk-J67EOBN3.js → chunk-QEZQ7MGH.js} +53 -13
- package/dist/chunk-QEZQ7MGH.js.map +1 -0
- package/dist/{chunk-5OKSFNUV.js → chunk-QF7EIRMU.js} +29 -23
- package/dist/chunk-QF7EIRMU.js.map +1 -0
- package/dist/chunk-QK6VYJHV.js +26 -0
- package/dist/chunk-QK6VYJHV.js.map +1 -0
- package/dist/chunk-QS2Z3SWL.js +21 -0
- package/dist/chunk-QS2Z3SWL.js.map +1 -0
- package/dist/{chunk-OKMTUAWO.js → chunk-QSPH4F56.js} +5 -5
- package/dist/{chunk-XEYS3KAZ.js → chunk-STM3G7WJ.js} +207 -79
- package/dist/chunk-STM3G7WJ.js.map +1 -0
- package/dist/{chunk-GNUZ37L2.js → chunk-T3BBNLAT.js} +2 -2
- package/dist/{chunk-GNUZ37L2.js.map → chunk-T3BBNLAT.js.map} +1 -1
- package/dist/{chunk-YGFIQ6Y5.js → chunk-TKINOTVS.js} +1 -1
- package/dist/chunk-TKINOTVS.js.map +1 -0
- package/dist/{chunk-QUG53QGZ.js → chunk-USKTLEPZ.js} +4 -4
- package/dist/{chunk-EU4HDGG4.js → chunk-V6OCE4ND.js} +129 -59
- package/dist/chunk-V6OCE4ND.js.map +1 -0
- package/dist/{chunk-SSDSV52B.js → chunk-VBBJGFME.js} +6 -7
- package/dist/chunk-VBBJGFME.js.map +1 -0
- package/dist/{chunk-CWXZ2MRT.js → chunk-VHJ72YCD.js} +4 -3
- package/dist/chunk-VHJ72YCD.js.map +1 -0
- package/dist/{chunk-PAU352SV.js → chunk-W4GTMOJW.js} +2 -2
- package/dist/{chunk-JEUFYSFQ.js → chunk-W5DO426O.js} +114 -70
- package/dist/chunk-W5DO426O.js.map +1 -0
- package/dist/{chunk-LWMB7JRE.js → chunk-W6B24IMO.js} +3 -3
- package/dist/{chunk-SE4JN5XN.js → chunk-WDENIUC7.js} +3 -1
- package/dist/chunk-WDENIUC7.js.map +1 -0
- package/dist/{chunk-NLELGEKL.js → chunk-WIPTWZVH.js} +6 -6
- package/dist/{chunk-RLPWXF5R.js → chunk-Y36PNW6J.js} +9 -9
- package/dist/{chunk-TR2XFZPR.js → chunk-Y37VJFX2.js} +9 -9
- package/dist/{chunk-3QUCVYNX.js → chunk-YJ3EG2D5.js} +12 -124
- package/dist/chunk-YJ3EG2D5.js.map +1 -0
- package/dist/{chunk-UKZNLVJW.js → chunk-ZINZTHWO.js} +4 -2
- package/dist/chunk-ZINZTHWO.js.map +1 -0
- package/dist/{chunk-N5JSOJY6.js → chunk-ZPLIXZZ6.js} +7 -5
- package/dist/chunk-ZPLIXZZ6.js.map +1 -0
- package/dist/{chunk-VXU75N5R.js → chunk-ZRQUQS7P.js} +5 -79
- package/dist/chunk-ZRQUQS7P.js.map +1 -0
- package/dist/{cli-RQRMZKKM.js → cli-5XKHMRZ5.js} +317 -28
- package/dist/cli-5XKHMRZ5.js.map +1 -0
- package/dist/{cli-5QGP6R63.js → cli-7QHJW5GH.js} +69 -26
- package/dist/cli-7QHJW5GH.js.map +1 -0
- package/dist/{cli-UL2IFH3R.js → cli-BUV3DRUH.js} +29 -83
- package/dist/cli-BUV3DRUH.js.map +1 -0
- package/dist/{cli-RQSCBJJY.js → cli-IKDX2I5X.js} +20 -18
- package/dist/{cli-RQSCBJJY.js.map → cli-IKDX2I5X.js.map} +1 -1
- package/dist/{cli-2Q5FODAX.js → cli-LOND37OA.js} +383 -247
- package/dist/cli-LOND37OA.js.map +1 -0
- package/dist/{cli-4ANSKDPD.js → cli-O6Y2KVWD.js} +11 -11
- package/dist/{cli-2OQKCKRD.js → cli-QTLOAVOY.js} +11 -10
- package/dist/{cli-2OQKCKRD.js.map → cli-QTLOAVOY.js.map} +1 -1
- package/dist/{cli-IE3CYYHA.js → cli-SOA2E26G.js} +62 -22
- package/dist/cli-SOA2E26G.js.map +1 -0
- package/dist/{cli-SDTXHLCA.js → cli-VQYB3663.js} +19 -18
- package/dist/{cli-SDTXHLCA.js.map → cli-VQYB3663.js.map} +1 -1
- package/dist/{cli-SGSS6FXE.js → cli-X6IWTDFK.js} +31 -29
- package/dist/{cli-SGSS6FXE.js.map → cli-X6IWTDFK.js.map} +1 -1
- package/dist/{cli-USPQURPP.js → cli-XAT673VB.js} +3 -3
- package/dist/cli.js +14 -14
- package/dist/{config-JJW75SBX.js → config-7I5CHHRZ.js} +6 -6
- package/dist/docmeta.js +10 -10
- package/dist/github-IPBOTQBN.js +36 -0
- package/dist/github-XM36D7ZH.js +32 -0
- package/dist/graph/runtime.js.map +1 -1
- package/dist/index.d.ts +157 -13
- package/dist/index.js +147 -131
- package/dist/index.js.map +1 -1
- package/dist/{json-PQURAHQ5.js → json-225TND7K.js} +15 -13
- package/dist/{labels-FMLO2URZ.js → labels-CTLHIRC4.js} +14 -12
- package/dist/{labels-FMLO2URZ.js.map → labels-CTLHIRC4.js.map} +1 -1
- package/dist/lint-NP3PC3SO.js +35 -0
- package/dist/list-JJGNKO6S.js +36 -0
- package/dist/list-Q457TIMA.js +34 -0
- package/dist/{page-X3HYSH6D.js → page-FJW7J2EU.js} +13 -12
- package/dist/{picker-3XF36MJF.js → picker-FPUC5UGM.js} +3 -3
- package/dist/{prepare-IQMB262G.js → prepare-RKJEKHAG.js} +21 -20
- package/dist/{prepare-IQMB262G.js.map → prepare-RKJEKHAG.js.map} +1 -1
- package/dist/{pretty-22PXIEOV.js → pretty-ECBO3EVT.js} +15 -14
- package/dist/{pretty-K5BOCKBB.js → pretty-QFEN2SIA.js} +15 -13
- package/dist/{provider-LBX4IXGX.js → provider-JY2I3VLF.js} +3 -3
- package/dist/{release-VV3UTKE5.js → release-Z3ASYZ3S.js} +3 -3
- package/dist/{reporters-5LIYYE6M.js → reporters-IKKL5RHS.js} +15 -14
- package/dist/{reporters-26H3N2KW.js → reporters-TDQDQHKE.js} +6 -5
- package/dist/{reporters-324OWH36.js → reporters-WGLQKW2Y.js} +6 -6
- package/dist/run-BTETGGLW.js +39 -0
- package/dist/sarif-K4SMB563.js +31 -0
- package/dist/sarif-ZHFK6PZY.js +37 -0
- package/dist/{term-2ADSKGZW.js → term-2M7APX2A.js} +58 -109
- package/dist/term-2M7APX2A.js.map +1 -0
- package/dist/types-VMOT7RAL.js +12 -0
- package/dist/types-VMOT7RAL.js.map +1 -0
- package/dist/{validate-LRYUEZLJ.js → validate-GBM5STKS.js} +6 -6
- package/dist/validate-GBM5STKS.js.map +1 -0
- package/package.json +1 -1
- package/plugin/manni/.claude-plugin/plugin.json +1 -1
- package/plugin/manni/skills/check/SKILL.md +2 -2
- package/plugin/manni/skills/evals/SKILL.md +1 -1
- package/plugin/manni/skills/fix/SKILL.md +99 -18
- package/plugin/manni/skills/setup/SKILL.md +1 -1
- package/schemas/lint/template.json +6 -1
- package/shapes/graph/shapes-1.1.1.ttl +953 -0
- package/templates/lint/tgdp/concept.yaml +27 -13
- package/templates/lint/tgdp/how-to.yaml +35 -21
- package/templates/lint/tgdp/readme.yaml +69 -25
- package/templates/lint/tgdp/reference.yaml +44 -31
- package/templates/lint/tgdp/release-notes.yaml +48 -19
- package/templates/lint/tgdp/troubleshooting.yaml +45 -31
- package/templates/lint/tgdp/tutorial.yaml +35 -19
- package/dist/batch-UHLVBMYM.js +0 -46
- package/dist/build-4RPXBSAO.js +0 -36
- package/dist/calibrate-POL5DCJ6.js +0 -41
- package/dist/capture-I7ZYG7NZ.js +0 -38
- package/dist/check-6TEG5TM6.js +0 -34
- package/dist/check-DGOUTC3V.js +0 -30
- package/dist/chunk-3QUCVYNX.js.map +0 -1
- package/dist/chunk-4IW6FAUN.js.map +0 -1
- package/dist/chunk-4TGIGVFO.js.map +0 -1
- package/dist/chunk-5OKSFNUV.js.map +0 -1
- package/dist/chunk-7JUIJ7Q5.js.map +0 -1
- package/dist/chunk-7QH2ZI4F.js.map +0 -1
- package/dist/chunk-AATCO43N.js.map +0 -1
- package/dist/chunk-BGRP44SX.js.map +0 -1
- package/dist/chunk-CWXZ2MRT.js.map +0 -1
- package/dist/chunk-EBZ4QKKX.js.map +0 -1
- package/dist/chunk-EU4HDGG4.js.map +0 -1
- package/dist/chunk-EX6E2P6Z.js.map +0 -1
- package/dist/chunk-HP43LH7E.js.map +0 -1
- package/dist/chunk-J67EOBN3.js.map +0 -1
- package/dist/chunk-JAPSZ44X.js.map +0 -1
- package/dist/chunk-JEUFYSFQ.js.map +0 -1
- package/dist/chunk-KQRYW4DN.js.map +0 -1
- package/dist/chunk-KRKNZ3IV.js.map +0 -1
- package/dist/chunk-MNH7QO4Z.js +0 -15
- package/dist/chunk-MNH7QO4Z.js.map +0 -1
- package/dist/chunk-N5JSOJY6.js.map +0 -1
- package/dist/chunk-OTJOBZJ5.js.map +0 -1
- package/dist/chunk-PP22XDW2.js.map +0 -1
- package/dist/chunk-PSPNIAOP.js.map +0 -1
- package/dist/chunk-QWE3WLV4.js.map +0 -1
- package/dist/chunk-SE4JN5XN.js.map +0 -1
- package/dist/chunk-SSDSV52B.js.map +0 -1
- package/dist/chunk-TBAMBLF3.js.map +0 -1
- package/dist/chunk-U4SY2TJS.js.map +0 -1
- package/dist/chunk-UKZNLVJW.js.map +0 -1
- package/dist/chunk-VXU75N5R.js.map +0 -1
- package/dist/chunk-W7EZJPRX.js +0 -117
- package/dist/chunk-W7EZJPRX.js.map +0 -1
- package/dist/chunk-WWKXPPN5.js.map +0 -1
- package/dist/chunk-XEYS3KAZ.js.map +0 -1
- package/dist/chunk-XP4RNQZL.js.map +0 -1
- package/dist/chunk-Y4TDIUG6.js.map +0 -1
- package/dist/chunk-YGFIQ6Y5.js.map +0 -1
- package/dist/chunk-Z42MO7SO.js.map +0 -1
- package/dist/chunk-ZCJUSQM7.js.map +0 -1
- package/dist/cli-2Q5FODAX.js.map +0 -1
- package/dist/cli-5QGP6R63.js.map +0 -1
- package/dist/cli-IE3CYYHA.js.map +0 -1
- package/dist/cli-RQRMZKKM.js.map +0 -1
- package/dist/cli-UL2IFH3R.js.map +0 -1
- package/dist/github-PBIYRH5S.js +0 -35
- package/dist/github-RJG2MAWB.js +0 -30
- package/dist/lint-N2CY66JX.js +0 -34
- package/dist/list-OMHTVFDY.js +0 -32
- package/dist/list-VBFNFEXV.js +0 -35
- package/dist/run-4EKG6EMI.js +0 -37
- package/dist/term-2ADSKGZW.js.map +0 -1
- package/dist/types-Y6TXHM7M.js +0 -10
- /package/dist/{batch-UHLVBMYM.js.map → batch-TKNIUBLK.js.map} +0 -0
- /package/dist/{build-4RPXBSAO.js.map → build-6G7PEAG4.js.map} +0 -0
- /package/dist/{calibrate-POL5DCJ6.js.map → calibrate-BDCXDZV5.js.map} +0 -0
- /package/dist/{capture-I7ZYG7NZ.js.map → capture-NQJLZD66.js.map} +0 -0
- /package/dist/{check-3O2PZ7TZ.js.map → check-552X5I2J.js.map} +0 -0
- /package/dist/{check-6TEG5TM6.js.map → check-5HMDJOFP.js.map} +0 -0
- /package/dist/{check-DGOUTC3V.js.map → check-BSB4FF4L.js.map} +0 -0
- /package/dist/{chunk-PNUM6RHR.js.map → chunk-3MTZZJKH.js.map} +0 -0
- /package/dist/{chunk-CU57HT2E.js.map → chunk-6WJUZQQX.js.map} +0 -0
- /package/dist/{chunk-5NNPEPVM.js.map → chunk-BA4TCCOO.js.map} +0 -0
- /package/dist/{chunk-X4GQ4HPY.js.map → chunk-BAWKNF6U.js.map} +0 -0
- /package/dist/{chunk-YQV75FIL.js.map → chunk-CFMI74TP.js.map} +0 -0
- /package/dist/{chunk-DTXLFSAB.js.map → chunk-CZJNYHK7.js.map} +0 -0
- /package/dist/{chunk-3FXPIZXL.js.map → chunk-EXAZ7K25.js.map} +0 -0
- /package/dist/{chunk-ZXRAE55H.js.map → chunk-IGRXQC3H.js.map} +0 -0
- /package/dist/{chunk-6KONPVHQ.js.map → chunk-IOYEPB27.js.map} +0 -0
- /package/dist/{chunk-U6IHLEWT.js.map → chunk-JCTHXG33.js.map} +0 -0
- /package/dist/{chunk-7TVIFCGT.js.map → chunk-MIGFQP5N.js.map} +0 -0
- /package/dist/{chunk-TZOYZK2E.js.map → chunk-OZUPJB4J.js.map} +0 -0
- /package/dist/{chunk-OKMTUAWO.js.map → chunk-QSPH4F56.js.map} +0 -0
- /package/dist/{chunk-QUG53QGZ.js.map → chunk-USKTLEPZ.js.map} +0 -0
- /package/dist/{chunk-PAU352SV.js.map → chunk-W4GTMOJW.js.map} +0 -0
- /package/dist/{chunk-LWMB7JRE.js.map → chunk-W6B24IMO.js.map} +0 -0
- /package/dist/{chunk-NLELGEKL.js.map → chunk-WIPTWZVH.js.map} +0 -0
- /package/dist/{chunk-RLPWXF5R.js.map → chunk-Y36PNW6J.js.map} +0 -0
- /package/dist/{chunk-TR2XFZPR.js.map → chunk-Y37VJFX2.js.map} +0 -0
- /package/dist/{cli-4ANSKDPD.js.map → cli-O6Y2KVWD.js.map} +0 -0
- /package/dist/{cli-USPQURPP.js.map → cli-XAT673VB.js.map} +0 -0
- /package/dist/{config-JJW75SBX.js.map → config-7I5CHHRZ.js.map} +0 -0
- /package/dist/{github-PBIYRH5S.js.map → github-IPBOTQBN.js.map} +0 -0
- /package/dist/{github-RJG2MAWB.js.map → github-XM36D7ZH.js.map} +0 -0
- /package/dist/{json-PQURAHQ5.js.map → json-225TND7K.js.map} +0 -0
- /package/dist/{lint-N2CY66JX.js.map → lint-NP3PC3SO.js.map} +0 -0
- /package/dist/{list-OMHTVFDY.js.map → list-JJGNKO6S.js.map} +0 -0
- /package/dist/{list-VBFNFEXV.js.map → list-Q457TIMA.js.map} +0 -0
- /package/dist/{page-X3HYSH6D.js.map → page-FJW7J2EU.js.map} +0 -0
- /package/dist/{picker-3XF36MJF.js.map → picker-FPUC5UGM.js.map} +0 -0
- /package/dist/{pretty-22PXIEOV.js.map → pretty-ECBO3EVT.js.map} +0 -0
- /package/dist/{pretty-K5BOCKBB.js.map → pretty-QFEN2SIA.js.map} +0 -0
- /package/dist/{provider-LBX4IXGX.js.map → provider-JY2I3VLF.js.map} +0 -0
- /package/dist/{release-VV3UTKE5.js.map → release-Z3ASYZ3S.js.map} +0 -0
- /package/dist/{reporters-26H3N2KW.js.map → reporters-IKKL5RHS.js.map} +0 -0
- /package/dist/{reporters-324OWH36.js.map → reporters-TDQDQHKE.js.map} +0 -0
- /package/dist/{reporters-5LIYYE6M.js.map → reporters-WGLQKW2Y.js.map} +0 -0
- /package/dist/{run-4EKG6EMI.js.map → run-BTETGGLW.js.map} +0 -0
- /package/dist/{types-Y6TXHM7M.js.map → sarif-K4SMB563.js.map} +0 -0
- /package/dist/{validate-LRYUEZLJ.js.map → sarif-ZHFK6PZY.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/docevals/types.ts"],"sourcesContent":["/**\n * Shared result model for manni docevals.\n *\n * Vocabulary follows the \"Docs as Evals\" methodology (Docs as Tests with AI):\n * every check is an *eval*; what differs is its *grader* (code-based, LLM-as-\n * judge, or human). Verdicts are binary pass/fail — aggregate rates emerge from\n * binary judgments, they are never assigned per item.\n */\nimport { ToolError } from \"../shared/errors.js\";\nimport type { Severity } from \"../shared/severity.js\";\n\n// The judge vocabulary is shared with the inference layer and is re-exported\n// here so manni docevals code and its consumers keep one import site. A second local\n// definition would be a second thing to keep in sync.\n//\n// Match — a single run's verdict; `partial` counts as fail\n// Zone — confidence-zone routing for AI-judged evals\n// JudgeVerdict — the structured verdict of one run (the book's shape)\n// JudgeRun — one run within an ensemble\n// ConsensusResult — the aggregated outcome for one (page, eval) pair\nimport type { ConsensusResult } from \"@hawkeyexl/inference\";\n\nexport type {\n ConsensusResult,\n JudgeRun,\n JudgeVerdict,\n Match,\n Zone,\n} from \"@hawkeyexl/inference\";\n\n/**\n * Regression evals guard behavior that must keep working (~100% target pass\n * rate). Capability evals probe what the docs/system can do (~70% target).\n */\nexport type EvalType = \"capability\" | \"regression\";\n\n/**\n * Finding severity for deterministically graded evals: the family scale,\n * `notice | warning | error`, from `src/shared/severity.ts`. Only `error`\n * affects exit codes.\n */\nexport type { Severity };\n\n/** How an eval is graded. `tool:regex` is the built-in `tool:*` kind; `registerGrader` adds others. */\nexport type GraderKind = \"ai\" | \"command\" | \"human\" | `tool:${string}`;\n\n/** A normalized finding from a deterministically graded eval (command or tool). */\nexport interface Finding {\n /** Name of the eval that produced this finding. */\n evalName: string;\n /** Repo-relative path of the page the finding applies to. */\n file: string;\n /** Grader-specific rule id (e.g. \"regex/found\"), when available. */\n ruleId?: string;\n message: string;\n severity: Severity;\n /**\n * This finding is about the *grader*, not the page: the tool could not be\n * run, or its output could not be read. It fails the eval whatever severity\n * the eval is configured at, because an eval configured `severity: warning`\n * would otherwise pass while its check never executed (ADR 01022).\n *\n * A finding about the page carries the eval's severity as usual.\n */\n diagnostic?: boolean;\n line?: number;\n col?: number;\n}\n\n/** Result of one eval applied to one page. */\nexport interface EvalResult {\n evalName: string;\n /**\n * Suite this result reports under. Stamped centrally by the engine, which\n * already computes the mapping for the suite summaries — the alternative is\n * threading it through every one of the ~30 places a result is constructed.\n */\n suite?: string;\n type: EvalType;\n grader: GraderKind;\n file: string;\n /**\n * Where the page declares the eval: the item of its `evals` key that names\n * it, in the page or in the manifest that supplied the key (proposal 0037).\n * A suite eval the page never names points at its `eval-suite` key, or at\n * the page alone when the suite is the config's default. `file` is spelled\n * like `file`, and `line` is 1-based and absent when nothing records one.\n *\n * Stamped centrally by the engine, like `suite`, on every result it\n * reports.\n */\n location?: { file: string; line?: number };\n outcome: \"pass\" | \"fail\" | \"needs-review\" | \"skipped\" | \"error\";\n /** Present for ai-graded evals. */\n consensus?: ConsensusResult;\n /** Present for command/tool-graded evals that produced findings. */\n findings?: Finding[];\n /** True when this run generated the eval's check script. */\n generated?: boolean;\n /** Set when a persisted human review resolved a needs-review outcome. */\n via?: \"human-review\";\n /**\n * Findings the baseline already recorded and this run therefore suppressed\n * (ADR 01017). Present only on a run with a baseline in effect, so its\n * absence means \"no baseline\", not \"nothing was forgiven\".\n */\n baselined?: number;\n skipReason?: string;\n /**\n * The eval's weight in its suite's pass rate. Stamped centrally by the\n * engine alongside `suite`, and for the same reason: threading it through\n * the ~30 sites that construct a result would be thirty chances to forget.\n */\n weight?: number;\n /**\n * Set when the model that judged this eval also produced what it graded.\n *\n * `content` — the machines attributed for what the eval's `target` reads\n * name this model (`provenance` for the body, the `fields` of\n * `meta-provenance` for the frontmatter, both for `raw`): the judge wrote\n * what it grades. `criterion` — a `meta-provenance` entry for this model\n * lists this eval under `evals`: the judge wrote the question. Both bias a\n * verdict without invalidating it, so this rides along with a real outcome\n * rather than replacing it, and reaches every reporter instead of stderr.\n */\n selfPreference?: { axis: \"content\" | \"criterion\"; model: string };\n durationMs: number;\n}\n\n/** Per-suite aggregate. Pass rates emerge from binary outcomes. */\nexport interface SuiteSummary {\n suite: string;\n total: number;\n passed: number;\n failed: number;\n needsReview: number;\n skipped: number;\n errored: number;\n /**\n * Weighted share of the graded set that passed, 1 when nothing ran.\n *\n * The graded set is pass + fail + error, as it has always been —\n * `needs-review` and `skipped` are in neither half, so a page awaiting review\n * neither helps nor hurts. Each eval contributes its `weight` (1 unless it\n * says otherwise), and an eval that belongs to a criterion contributes\n * nothing on its own: the criterion contributes once, for the group.\n */\n passRate: number;\n /** From config: ~1.0 for regression suites, ~0.7 for capability suites. */\n targetPassRate: number;\n meetsTarget: boolean;\n /**\n * Set when a selection filter (`--eval` / `--suite`) was active, meaning the\n * run measured part of this suite. `meetsTarget` is then always false and the\n * suite cannot fail the run either: it has numbers, but no verdict.\n */\n partial?: boolean;\n /**\n * Criteria scored in this suite. Present only when the suite declares any,\n * so its absence means \"none\", never \"none passed\".\n *\n * `suspended` counts criteria whose members were not all graded in this run.\n * They are out of the rate entirely rather than counted as failures — the\n * same reasoning as `partial` one level down (ADR 01018): a group measured\n * in part has numbers but no verdict.\n */\n criteria?: {\n total: number;\n passed: number;\n failed: number;\n suspended: number;\n };\n}\n\n/** Full run output consumed by reporters. */\nexport interface RunReport {\n pages: number;\n evalResults: EvalResult[];\n suites: SuiteSummary[];\n /**\n * Judge telemetry. Counts, not money: the dollar figure this block used to\n * carry was only as good as a price table this repo does not own, and was\n * absent entirely for `claude-cli` and self-hosted endpoints (ADR 01019).\n */\n usage: {\n totalTokens: number;\n cachedEvals: number;\n judgedEvals: number;\n };\n /** Script generations performed during this run (paths written). */\n generated: string[];\n exitCode: 0 | 1;\n}\n\n/** Operational/usage error → exit code 2. */\nexport class DocevalsError extends ToolError {\n constructor(\n message: string,\n /**\n * Set where a caller acts on the kind of error rather than reporting it.\n * `nothing-resolved`: no page this run would check resolves an eval.\n */\n readonly code?: \"nothing-resolved\",\n ) {\n super(message);\n this.name = \"DocevalsError\";\n }\n}\n"],"mappings":";;;;;;AAmMO,IAAM,gBAAN,cAA4B,UAAU;AAAA,EAC3C,YACE,SAKS,MACT;AACA,UAAM,OAAO;AAFJ;AAGT,SAAK,OAAO;AAAA,EACd;AAAA,EAJW;AAKb;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/commands/build.ts","../src/graph/core/analyze-cache.ts","../src/graph/core/concepts.ts","../src/graph/core/derive.ts","../src/graph/core/emit.ts","../src/graph/core/harvest.ts","../src/graph/core/git.ts","../src/graph/core/graph-output.ts"],"sourcesContent":["/**\n * `manni graph build` — derive the knowledge graph from discovered docs and write\n * deterministic Turtle. Running twice over unchanged inputs produces\n * byte-identical output.\n */\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { GraphError } from \"../types.js\";\nimport { analyzeDoc } from \"../core/analyze.js\";\nimport { ANALYZE_CACHE_DIR, AnalyzeCache } from \"../core/analyze-cache.js\";\nimport { loadRunConfig } from \"../core/config.js\";\nimport { deriveGraph, termConceptCount } from \"../core/derive.js\";\nimport {\n assertInputFormat,\n documentBase,\n documentSetPatterns,\n resolveDocumentSet,\n routesFrom,\n STDIN,\n type DocumentInputOptions,\n} from \"../core/discover.js\";\nimport { STDIN_PATH } from \"../core/iri.js\";\nimport { emitTurtle } from \"../core/emit.js\";\nimport { harvestWarnings } from \"../core/harvest.js\";\nimport { collectGitHistory } from \"../core/git.js\";\nimport { suppressGraphOutput } from \"../core/graph-output.js\";\nimport { openMetaView, withExternalMetadata } from \"../core/external.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport { termLabelSource, type TermLabel } from \"../../shared/term-labels.js\";\nimport { NS, RDF_TYPE } from \"../core/vocab.js\";\nimport pkg from \"../../../package.json\" with { type: \"json\" };\n\nexport interface BuildOptions extends DocumentInputOptions {\n /** Output path override (default: config `out`). */\n out?: string;\n cwd?: string;\n /**\n * What `-` reads: the document from stdin, read by the caller. Required\n * when `paths` holds `-`. Its display path is `<stdin>`, its node is\n * `{baseIri}stdin`, and its links resolve from `cwd`.\n */\n stdinContent?: string;\n /** `--allow-empty`: zero matched files writes an empty graph, not an error. */\n allowEmpty?: boolean;\n}\n\n/**\n * What a run that wanted git history and could not have it is told. Said once,\n * through `warn()` at the CLI edge: git is detected now rather than switched\n * (proposal 0051 §6), so the degradation graph ADR 01010 built the warnings\n * channel for is all that is left of the tri-state.\n *\n * The reason travels with the sentence. Detection removed the user's way of\n * saying \"I require this\", so the warning is the only thing standing between a\n * CI runner that lost git and a quietly thinner graph — and \"not a repository\"\n * wants a different fix from \"git is not on PATH\" or \"`git log` timed out\".\n */\nexport const GIT_ABSENT_WARNING =\n \"the graph has no revision history or commit agents\";\n\nexport function gitAbsentWarning(reason: string): string {\n return `${GIT_ABSENT_WARNING}: ${reason}`;\n}\n\nexport interface BuildResult {\n outPath: string;\n docs: number;\n quads: number;\n /**\n * The concepts the graph holds, and how many of them the termbase defines\n * (proposal 0086 §1). `fromTermbase` is 0 when the `terms` derive source\n * is off or no termbase is set up.\n */\n concepts: { total: number; fromTermbase: number };\n /**\n * Non-fatal diagnostics: the build succeeded, but something it would have\n * done by default could not run (see ADR 01010). Rendered to stderr by the\n * CLI; never affects the exit code.\n */\n warnings: string[];\n}\n\n/** The build with its Turtle in hand, before anything is written. */\nexport interface BuiltGraph extends BuildResult {\n turtle: string;\n}\n\nexport async function runBuild(opts: BuildOptions = {}): Promise<BuildResult> {\n const { turtle, ...result } = await buildGraph(opts);\n mkdirSync(dirname(result.outPath), { recursive: true });\n writeFileSync(result.outPath, turtle, \"utf8\");\n return result;\n}\n\n/**\n * `runBuild` without the write: the graph as Turtle, in memory. `manni check`\n * builds the graph this way and checks it, writing no file.\n */\nexport async function buildGraph(opts: BuildOptions = {}): Promise<BuiltGraph> {\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 ...(opts.paths === undefined ? {} : { paths: opts.paths }),\n ...(opts.collection === undefined ? {} : { collection: opts.collection }),\n },\n cwd,\n );\n\n const format = assertInputFormat(opts.paths ?? [], opts.as);\n // Collection pages are labelled from the config's directory and typed paths\n // from cwd, as meta labels them. Every read below resolves from `base`.\n const base = documentBase(config, opts, cwd);\n const files = resolveDocumentSet(config, opts, \"build\", cwd, base);\n const usingStdin = (opts.paths ?? []).includes(STDIN);\n const outPath = resolve(cwd, opts.out ?? config.out);\n if (files.length === 0 && !usingStdin) {\n if (opts.allowEmpty) {\n // Zero documents is an empty graph, written where the graph goes, so a\n // later step that reads it finds a file rather than a stale one.\n return {\n outPath,\n docs: 0,\n quads: 0,\n concepts: { total: 0, fromTermbase: 0 },\n warnings: [],\n turtle: emitTurtle([]),\n };\n }\n throw new GraphError(\n `No input files matched: ${documentSetPatterns(config, opts).join(\", \")} (cwd: ${cwd})`,\n );\n }\n if (usingStdin && opts.stdinContent === undefined) {\n throw new GraphError(\"graph build was given `-` but no stdin content.\");\n }\n\n const allPaths = new Set(usingStdin ? [...files, STDIN_PATH] : files);\n // Each page's body parse is cached across runs (`analyze-cache.ts`). Link\n // resolution against `allPaths` and `routes` still runs on every build.\n const cache = new AnalyzeCache(resolve(cwd, ANALYZE_CACHE_DIR));\n const analyzeOptions = {\n routes: routesFrom(config, base),\n ...(format === undefined ? {} : { format }),\n parse: cache.parse,\n };\n const read = files.map((path) =>\n analyzeDoc(readFileSync(resolve(base, path), \"utf8\"), path, allPaths, analyzeOptions),\n );\n if (usingStdin && opts.stdinContent !== undefined) {\n read.push(analyzeDoc(opts.stdinContent, STDIN_PATH, allPaths, analyzeOptions));\n }\n\n // A page's metadata is what `manni meta validate` reads: its frontmatter\n // plus every key a manifest of its collections owns (proposal 0047), merged\n // through meta's own merge. Read from meta's section of the same config the\n // output marks come from, so one file answers both.\n const view = await openMetaView(\n {\n ...(opts.config === undefined ? {} : { configPath: opts.config }),\n ...(opts.noConfig === undefined ? {} : { noConfig: opts.noConfig }),\n },\n cwd,\n files,\n base,\n );\n const merged = await withExternalMetadata(read, view);\n\n // What the graph carries is the schema's call (proposal 0051 §5): a top-level\n // field marked `x-manni-graph-output: false` is dropped here, before derivation,\n // and the schemas are the set `manni meta validate` resolves (proposal 0074),\n // so it reaches none of Turtle, JSON-LD, iiRDS or the search index. All four\n // read what `deriveGraph` produces, so one filter at the fan-in is the whole\n // mechanism; suppressing a field downstream would be triple surgery in four\n // places. It runs after the merge, so a field kept in a manifest is filtered\n // by the same mark as one kept on the page.\n const docs = await suppressGraphOutput(merged, view);\n\n // Page-level keys that look like harvest inputs but are not. The graph block\n // is schema-strict, so a typo there is a hard error; at the page level\n // nothing validates, and a near miss derives silently nothing (ADR 01028).\n const warnings: string[] = harvestWarnings(docs);\n // The git pass only feeds the provenance derive source, so the subprocess is\n // skipped entirely when that source is off. Otherwise git is *detected*\n // (proposal 0051 §6): history is used wherever git can run over a\n // repository, and a run that would have used it and cannot says so once and\n // builds the rest — graph ADR 01010's degradation, without its switch.\n let gitHistory: Awaited<ReturnType<typeof collectGitHistory>> | undefined;\n if (config.build.derive.includes(\"provenance\")) {\n try {\n gitHistory = await collectGitHistory(base);\n } catch (e) {\n warnings.push(gitAbsentWarning(errorMessage(e)));\n }\n }\n\n // The termbase `manni term check` reads, from the same config, under the\n // `terms` derive source (proposal 0086 §1). Nothing registers a source\n // under a library call, and then the graph builds as it always did. A\n // termbase that cannot be read is `term check`'s failure to report, so the\n // graph warns once and builds the rest, as it does without git.\n const source = termLabelSource();\n let termbase: readonly TermLabel[] = [];\n if (config.build.derive.includes(\"terms\") && source !== undefined) {\n try {\n termbase = await source({\n cwd,\n ...(opts.config === undefined ? {} : { configPath: opts.config }),\n ...(opts.noConfig === true ? { noConfig: true } : {}),\n });\n } catch (e) {\n warnings.push(\n `the graph holds no termbase concepts: the termbase could not be read — ${errorMessage(e)}`,\n );\n }\n }\n\n const quads = deriveGraph(docs, {\n baseIri: config.baseIri,\n derive: config.build.derive,\n // The package version, stamped on the build agent (graph:version). One\n // package, one version: the tool no longer has one of its own.\n toolVersion: pkg.version,\n gitHistory,\n qualified: config.provenance.qualified,\n termbase,\n });\n const concept = `${NS.skos}Concept`;\n const concepts = {\n total: quads.filter((q) => q.p === RDF_TYPE && q.o.value === concept).length,\n fromTermbase: termConceptCount(termbase),\n };\n const turtle = emitTurtle(quads);\n await cache.flush();\n\n return { outPath, docs: docs.length, quads: quads.length, concepts, warnings, turtle };\n}\n","/**\n * The cross-run cache for page parses.\n *\n * Parsing the body is most of what `graph build` spends on a page, and most\n * pages do not change between runs. `manni check` builds the graph on every\n * agent stop, so the parse is cached: one JSON file per page label under\n * `.manni/graph/analyze-cache/`, overwritten when the page changes. The\n * cache therefore holds about one entry per page ever built here.\n *\n * Only `parseBody`'s output is stored, which is a pure function of the bytes\n * and the format. Frontmatter, link resolution against the corpus, routes,\n * the meta view and git history all run on every build, so nothing a cache\n * entry holds depends on another page or on the clock.\n *\n * A cache is an optimization: an unreadable, unparseable or malformed entry\n * is a miss, and a write that fails is dropped. Neither can fail a run.\n * Node-only: the runtime and embed bundles never import it.\n */\nimport { createHash } from \"node:crypto\";\nimport { mkdir } from \"node:fs/promises\";\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { writeTextAtomic } from \"../../shared/write-file.js\";\nimport pkg from \"../../../package.json\" with { type: \"json\" };\nimport { parseBody, type DocBody, type DocFormat } from \"./analyze.js\";\n\n/**\n * Where the cache lives, relative to the working directory, beside the\n * `fill` proposal cache (`.manni/graph/cache`) and the `embed` vector cache.\n */\nexport const ANALYZE_CACHE_DIR = \".manni/graph/analyze-cache\";\n\n/**\n * The entry format. Bump it when `parseBody` changes what it returns, so a\n * development build does not read entries an older parse wrote under the\n * same package version.\n */\nconst ENTRY_VERSION = 1;\n\nfunction sha256(text: string): string {\n return createHash(\"sha256\").update(text, \"utf8\").digest(\"hex\");\n}\n\nconst isStrings = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every((v) => typeof v === \"string\");\n\nfunction isSection(value: unknown): boolean {\n if (typeof value !== \"object\" || value === null) return false;\n const s = value as Record<string, unknown>;\n return (\n typeof s.slug === \"string\" &&\n typeof s.title === \"string\" &&\n typeof s.level === \"number\" &&\n typeof s.order === \"number\" &&\n (s.parentSlug === null || typeof s.parentSlug === \"string\")\n );\n}\n\nfunction isDocBody(value: unknown): value is DocBody {\n if (typeof value !== \"object\" || value === null) return false;\n const b = value as Record<string, unknown>;\n return (\n (b.firstH1 === undefined || typeof b.firstH1 === \"string\") &&\n Array.isArray(b.sections) &&\n b.sections.every(isSection) &&\n isStrings(b.linkTargets) &&\n isStrings(b.imageTargets) &&\n isStrings(b.codeLanguages)\n );\n}\n\nexport class AnalyzeCache {\n /** Pages this run served from the cache. */\n hits = 0;\n /** Pages this run parsed. */\n misses = 0;\n private readonly writes: Promise<void>[] = [];\n\n constructor(\n private readonly dir: string,\n private readonly version: string = pkg.version,\n ) {}\n\n /** `parseBody`, served from the entry for `path` when its key matches. */\n readonly parse = (content: string, path: string, format: DocFormat): DocBody => {\n const key = sha256(JSON.stringify([ENTRY_VERSION, this.version, format, path, content]));\n // Named by a digest, so a label's `..` or `:` cannot choose where it lands.\n const file = join(this.dir, `${sha256(path)}.json`);\n const cached = readEntry(file, key);\n if (cached !== undefined) {\n this.hits++;\n return cached;\n }\n const body = parseBody(content, path, format);\n this.misses++;\n this.writes.push(this.write(file, JSON.stringify({ key, body })));\n return body;\n };\n\n /** Wait for this run's writes. Never rejects. */\n async flush(): Promise<void> {\n await Promise.all(this.writes);\n }\n\n private async write(file: string, text: string): Promise<void> {\n try {\n await mkdir(this.dir, { recursive: true });\n await writeTextAtomic(file, text);\n } catch {\n // Best-effort: the next run parses this page again.\n }\n }\n}\n\nfunction readEntry(file: string, key: string): DocBody | undefined {\n try {\n const entry = JSON.parse(readFileSync(file, \"utf8\")) as unknown;\n if (typeof entry !== \"object\" || entry === null) return undefined;\n const { key: stored, body } = entry as Record<string, unknown>;\n return stored === key && isDocBody(body) ? body : undefined;\n } catch {\n return undefined;\n }\n}\n","/**\n * The termbase as the graph reads it (proposal 0086 §1): one concept per term\n * id, and one resolver every concept label in derivation goes through.\n *\n * A label resolves to a term by its label, then its id, then an alt-label,\n * ignoring case. The page's own language is tried first, then the same\n * primary language (`en` for `en-US`), then any. A `see:` entry is a\n * redirect, not a concept: it resolves to its target.\n */\nimport type { TermLabel } from \"../../shared/term-labels.js\";\nimport { canonicalLanguageTag } from \"./localizations.js\";\nimport { byCodeUnit } from \"./sort.js\";\n\n/** What a key names: a term id, or a redirect to resolve in turn. */\ntype Target = { id: string } | { see: string; language: string | undefined };\n\ninterface Key {\n language: string | undefined;\n target: Target;\n}\n\nexport interface TermIndex {\n /** Each concept's entries, one per language, keyed by id in code-unit order. */\n groups: ReadonlyMap<string, readonly TermLabel[]>;\n /** The `see:` entries, in a stable order. */\n redirects: readonly TermLabel[];\n /** The term id a label names, or `undefined` for a freeform label. */\n resolve(label: string, language?: string): string | undefined;\n}\n\n/** A term's or a page's language, canonical, or `undefined` when it has none. */\nexport function canonicalLanguage(tag: string | undefined): string | undefined {\n return tag === undefined || tag === \"\" ? undefined : canonicalLanguageTag(tag);\n}\n\n// `split` always yields at least one element; the `?? \"\"` only satisfies the\n// index type.\nconst primary = (tag: string): string => (tag.split(\"-\")[0] ?? \"\").toLowerCase();\n\n/** A redirect chain longer than this is a loop, and names nothing. */\nconst MAX_REDIRECTS = 8;\n\n/**\n * Each termbase's index, by the array it was built from: one `graph build`\n * asks for it twice (the concept count and the derivation), and builds it once.\n */\nconst built = new WeakMap<readonly TermLabel[], TermIndex>();\n\nexport function termIndex(terms: readonly TermLabel[]): TermIndex {\n const cached = built.get(terms);\n if (cached !== undefined) return cached;\n const index = buildTermIndex(terms);\n built.set(terms, index);\n return index;\n}\n\nfunction buildTermIndex(terms: readonly TermLabel[]): TermIndex {\n const sorted = [...terms]\n .map((t) => ({ term: t, language: canonicalLanguage(t.language) }))\n .sort(\n (a, b) =>\n byCodeUnit(a.term.id, b.term.id) ||\n byCodeUnit(a.language ?? \"\", b.language ?? \"\") ||\n byCodeUnit(a.term.label, b.term.label),\n );\n\n const groups = new Map<string, TermLabel[]>();\n const redirects: TermLabel[] = [];\n const byLabel = new Map<string, Key[]>();\n const byId = new Map<string, Key[]>();\n const byAlt = new Map<string, Key[]>();\n const put = (map: Map<string, Key[]>, value: string, key: Key) => {\n const k = value.toLowerCase();\n const list = map.get(k);\n if (list) list.push(key);\n else map.set(k, [key]);\n };\n\n for (const { term, language } of sorted) {\n const target: Target =\n term.see === undefined ? { id: term.id } : { see: term.see, language };\n if (term.see === undefined) {\n const group = groups.get(term.id);\n if (group) group.push(term);\n else groups.set(term.id, [term]);\n } else {\n redirects.push(term);\n }\n put(byLabel, term.label, { language, target });\n put(byId, term.id, { language, target });\n for (const alt of term.altLabels ?? []) put(byAlt, alt, { language, target });\n }\n\n const tiers = [byLabel, byId, byAlt];\n\n const resolve = (label: string, language: string | undefined, depth: number): string | undefined => {\n const wanted = canonicalLanguage(language);\n const passes: Array<(k: Key) => boolean> =\n wanted === undefined\n ? [() => true]\n : [\n (k) => k.language === wanted,\n (k) => k.language !== undefined && primary(k.language) === primary(wanted),\n () => true,\n ];\n const needle = label.toLowerCase();\n for (const pass of passes) {\n for (const tier of tiers) {\n const hit = tier.get(needle)?.find(pass);\n if (hit === undefined) continue;\n if (\"id\" in hit.target) return hit.target.id;\n if (depth >= MAX_REDIRECTS) return undefined;\n return resolve(hit.target.see, hit.target.language ?? wanted, depth + 1);\n }\n }\n return undefined;\n };\n\n return {\n groups,\n redirects,\n resolve: (label, language) => (groups.size === 0 ? undefined : resolve(label, language, 0)),\n };\n}\n","/**\n * Graph derivation: DocModel[] → deduplicated Quad[]. This file is the\n * vocabulary mapping — the deterministic rules for what documentation\n * structure becomes which triples.\n */\nimport type { DocModel } from \"../types.js\";\nimport type { TermLabel } from \"../../shared/term-labels.js\";\nimport { canonicalLanguage, termIndex } from \"./concepts.js\";\nimport type { DeriveSource } from \"./config.js\";\nimport type { GitHistory } from \"./git.js\";\nimport { hasScheme, resolveRelative } from \"./analyze.js\";\nimport type { AgentKind } from \"./iri.js\";\nimport {\n conceptSlug,\n encodeSegment,\n mintAgentIri,\n mintBuildActivityIri,\n mintConceptIri,\n mintDocIri,\n mintGraphIri,\n mintProductIri,\n mintSchemeIri,\n mintSectionIri,\n mintTermConceptIri,\n normalizeDocPath,\n} from \"./iri.js\";\nimport { readSampleQuestions } from \"./questions.js\";\nimport { byCodeUnit } from \"./sort.js\";\nimport { NS, RDF_TYPE, ROLE } from \"./vocab.js\";\nimport {\n GRAPH_NOT_APPLICABLE_TO_VARIANT,\n GRAPH_NOT_SOFTWARE_SUBJECT,\n IIRDS_HAS_SUBJECT,\n IIRDS_HAS_TOPIC_TYPE,\n IIRDS_PRODUCT_VARIANT,\n IIRDS_RELATES_TO_LIFECYCLE_PHASE,\n IIRDS_RELATES_TO_PRODUCT_VARIANT,\n PAGE_TYPE_TO_TOPIC_TYPE,\n SOFTWARE_LIFECYCLE_IRIS,\n SOFTWARE_SUBJECT_IRIS,\n TOPIC_TYPE_IRIS,\n} from \"./iirds.js\";\n\n/**\n * Resolve a provenance target (a `graph.derived-from` / `graph.revision-of`\n * entry) to a corpus doc path: doc-relative first, then repo-relative; null\n * when neither names a discovered doc.\n */\nfunction resolveProvDocPath(\n docPath: string,\n raw: string,\n docByPath: ReadonlyMap<string, DocModel>,\n): string | null {\n const docRelative = resolveRelative(docPath, raw);\n if (docRelative !== null && docByPath.has(docRelative)) return docRelative;\n const repoRelative = normalizeDocPath(raw);\n return docByPath.has(repoRelative) ? repoRelative : null;\n}\n\nexport type Term =\n | { kind: \"iri\"; value: string }\n | {\n kind: \"literal\";\n value: string;\n datatype?: string;\n /** A language tag, for a literal that carries one. Never set with `datatype`. */\n language?: string;\n };\n\nexport interface Quad {\n s: string;\n p: string;\n o: Term;\n}\n\nexport interface DeriveOptions {\n baseIri: string;\n derive: DeriveSource[];\n /** dockg's own version, stamped on the build agent (provenance source). */\n toolVersion?: string;\n /** Per-file git history; set only under `provenance.git`. */\n gitHistory?: GitHistory;\n /** Emit qualified attribution/association nodes (`provenance.qualified`). */\n qualified?: boolean;\n /**\n * The termbase, as the family term source reads it (proposal 0086 §1).\n * Read only under the `terms` derive source.\n */\n termbase?: readonly TermLabel[];\n}\n\n/**\n * How many concepts the termbase contributes: one per term id. A `see:`\n * entry is a redirect, not a concept.\n */\nexport function termConceptCount(termbase: readonly TermLabel[]): number {\n return termIndex(termbase).groups.size;\n}\n\n/** A SKOS hierarchy predicate and the one emitted back from its object. */\nconst INVERSE = {\n broader: \"narrower\",\n narrower: \"broader\",\n related: \"related\",\n} as const;\n\n/** The one concept scheme's title (proposal 0086). */\nexport const CONCEPT_SCHEME_TITLE = \"manni graph concepts\";\n\nconst iri = (value: string): Term => ({ kind: \"iri\", value });\nconst lit = (value: string): Term => ({ kind: \"literal\", value });\nconst typedLit = (value: string, datatype: string): Term => ({\n kind: \"literal\",\n value,\n datatype,\n});\n\nconst DATE_RE = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst DATETIME_RE = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}/;\n\n/** Type a frontmatter date value; plain literal when unrecognized. */\nfunction dateTerm(value: string): Term {\n if (DATE_RE.test(value)) return typedLit(value, `${NS.xsd}date`);\n if (DATETIME_RE.test(value)) return typedLit(value, `${NS.xsd}dateTime`);\n return lit(value);\n}\n\nfunction asString(v: unknown): string | undefined {\n if (typeof v === \"string\" && v.length > 0) return v;\n if (typeof v === \"number\") return String(v);\n // TOML frontmatter yields Date instances (smol-toml TomlDate). String(date)\n // is locale/timezone-dependent and would break byte-identical output;\n // ISO 8601 is stable everywhere.\n if (v instanceof Date) {\n return Number.isNaN(v.getTime()) ? undefined : v.toISOString();\n }\n return undefined;\n}\n\nfunction asStringArray(v: unknown): string[] {\n if (typeof v === \"string\") return v.length > 0 ? [v] : [];\n if (Array.isArray(v)) {\n return v.flatMap((item) => {\n const s = asString(item);\n return s === undefined ? [] : [s];\n });\n }\n return [];\n}\n\n/**\n * The names in an `author`/`authors` value. Stewardship allows a name, a\n * person object with a `name` (the MyST and Docusaurus shape), or a list of\n * either. A person object with no name names no one.\n */\nfunction asPersonNames(v: unknown): string[] {\n const one = (item: unknown): string[] => {\n const name =\n item != null && typeof item === \"object\" && !Array.isArray(item)\n ? asString(asRecord(item).name)\n : asString(item);\n return name === undefined ? [] : [name];\n };\n return Array.isArray(v) ? v.flatMap(one) : one(v);\n}\n\n/** A plain object as a string-keyed record; anything else becomes `{}`. */\nfunction asRecord(v: unknown): Record<string, unknown> {\n return v != null && typeof v === \"object\" && !Array.isArray(v)\n ? (v as Record<string, unknown>)\n : {};\n}\n\n/** First defined frontmatter value among aliases. */\nfunction fmValue(fm: Record<string, unknown>, keys: string[]): unknown {\n for (const key of keys) {\n if (fm[key] !== undefined && fm[key] !== null) return fm[key];\n }\n return undefined;\n}\n\n/** PROV-O's three prov:Agent subclasses, and their IRI path segments. */\ntype ProvAgentClass = \"Person\" | \"Organization\" | \"SoftwareAgent\";\n\nconst AGENT_KIND: Record<ProvAgentClass, AgentKind> = {\n Person: \"person\",\n Organization: \"org\",\n SoftwareAgent: \"software\",\n};\n\n/** The `graph` block of frontmatter, or undefined. */\nfunction graphBlock(\n fm: Record<string, unknown>,\n): Record<string, unknown> | undefined {\n const block = fm[\"graph\"];\n return block && typeof block === \"object\" && !Array.isArray(block)\n ? (block as Record<string, unknown>)\n : undefined;\n}\n\n/**\n * The harvest rule (ADR 01024): **deeper wins; the page level is the fallback**\n * — per fact, not per page. A `graph` block that speaks to a fact owns it\n * outright; where the block is silent, the page-level twin feeds the graph.\n *\n * Only the facts the `graph` block has a twin for are resolved here. Page-level\n * `prerequisites` / `next-steps` / `related-pages` belong to `docmeta:structure`\n * and are deliberately not harvested — that is a separate vocabulary, not this\n * one's fallback.\n *\n * Returns a graph-shaped object even when the page carries no `graph` block at\n * all, so a page typed only at the top level still derives its iiRDS typing.\n */\nfunction resolveGraph(\n block: Record<string, unknown> | undefined,\n fm: Record<string, unknown>,\n): Record<string, unknown> {\n const k: Record<string, unknown> = { ...(block ?? {}) };\n\n const fallback = (key: string, pageKeys: string[]) => {\n if (k[key] !== undefined && k[key] !== null) return;\n const pageValue = fmValue(fm, pageKeys);\n if (pageValue !== undefined) k[key] = pageValue;\n };\n\n fallback(\"concepts\", [\"concepts\"]);\n fallback(\"applies-to\", [\"applies-to\"]);\n fallback(\"not-applicable-to\", [\"not-applicable-to\"]);\n fallback(\"revision-of\", [\"supersedes\"]);\n\n // `type` is the one fact whose two altitudes speak different vocabularies:\n // the page's is open (docmeta:core), `graph.type` is the closed iiRDS enum. A\n // page type with no iiRDS counterpart derives nothing rather than inventing\n // one.\n if (k[\"type\"] === undefined || k[\"type\"] === null) {\n const pageType = asString(fmValue(fm, [\"type\"]));\n // hasOwn guards the prototype chain: `type: constructor` would otherwise\n // resolve to Object and pass the truthiness check below, writing a\n // function into graph.type.\n const derived =\n pageType && Object.hasOwn(PAGE_TYPE_TO_TOPIC_TYPE, pageType)\n ? PAGE_TYPE_TO_TOPIC_TYPE[pageType]\n : undefined;\n if (derived) k[\"type\"] = derived;\n }\n\n return k;\n}\n\n/**\n * The mapping entries of a `provenance` / `meta-provenance` list. Both are\n * lists of entries keyed by `generated-by` (proposal 0046), and a list is all\n * either of them may be — anything else names no machine, so it derives\n * nothing rather than being guessed at.\n *\n * Not `metaProvenanceEntries` from meta's barrel: that reader narrows an entry\n * to its model, `fields` and `evals`, and the harvest also needs `confidence`,\n * which it drops.\n */\nfunction recordEntries(value: unknown): Array<Record<string, unknown>> {\n if (!Array.isArray(value)) return [];\n return value.filter(\n (e): e is Record<string, unknown> =>\n !!e && typeof e === \"object\" && !Array.isArray(e),\n );\n}\n\n/** A JSON Pointer's reference tokens, each unescaped per RFC 6901. */\nfunction pointerSegments(pointer: string): string[] {\n return pointer\n .split(\"/\")\n .slice(1)\n .map((s) => s.replace(/~1/g, \"/\").replace(/~0/g, \"~\"));\n}\n\nexport function deriveGraph(docs: DocModel[], options: DeriveOptions): Quad[] {\n const { baseIri } = options;\n const sources = new Set(options.derive);\n const quads: Quad[] = [];\n const add = (s: string, p: string, o: Term) => quads.push({ s, p, o });\n /**\n * Concept IRIs minted while deriving. A set rather than a flag because\n * `concept()` is a closure: a captured `let` assigned only inside one stays\n * narrowed to its initializer at the read below, which would make the\n * scheme node unreachable as far as the compiler is concerned.\n */\n const mintedConcepts = new Set<string>();\n const terms = termIndex(sources.has(\"terms\") ? (options.termbase ?? []) : []);\n\n /**\n * The concept a label names (proposal 0086 §1). A label the termbase\n * defines names that term's concept, which the termbase pass below emits,\n * so the reference adds no label of its own. Any other label is a freeform\n * concept, minted from its slug with the label as its prefLabel.\n */\n const concept = (label: string, language?: string): string => {\n const id = terms.resolve(label, language);\n if (id !== undefined) return mintTermConceptIri(baseIri, id);\n const c = mintConceptIri(baseIri, label);\n add(c, RDF_TYPE, iri(`${NS.skos}Concept`));\n add(c, `${NS.skos}prefLabel`, lit(label));\n add(c, `${NS.skos}inScheme`, iri(mintSchemeIri(baseIri)));\n mintedConcepts.add(c);\n return c;\n };\n\n /** One hierarchy edge, emitted both ways round. */\n const hierarchy = (s: string, relation: keyof typeof INVERSE, o: string) => {\n add(s, `${NS.skos}${relation}`, iri(o));\n add(o, `${NS.skos}${INVERSE[relation]}`, iri(s));\n };\n\n /** ProductVariant node (type + label); returns its IRI. Positive and\n * negative applicability converge on one node per label. */\n const variantNode = (label: string): string => {\n const variant = mintProductIri(baseIri, label);\n add(variant, RDF_TYPE, iri(IIRDS_PRODUCT_VARIANT));\n add(variant, `${NS.dcterms}title`, lit(label));\n return variant;\n };\n\n /**\n * Emit the iiRDS typing fields (type, applies-to, about-product-lifecycle,\n * about-product-aspect) plus the negative-scope fields (not-applicable-to,\n * not-about-product-aspect) for `subjectIri` from a graph-like object. Shared\n * by the document `graph` block and the per-section `graph.sections` block so\n * the mapping cannot drift between them (ADR 01012/01013/01014).\n */\n const emitIirdsTyping = (subjectIri: string, k: Record<string, unknown>) => {\n const topicType = asString(k[\"type\"]);\n const topicTypeIri = topicType && TOPIC_TYPE_IRIS[topicType];\n if (topicTypeIri) add(subjectIri, IIRDS_HAS_TOPIC_TYPE, iri(topicTypeIri));\n\n for (const label of asStringArray(k[\"applies-to\"])) {\n add(\n subjectIri,\n IIRDS_RELATES_TO_PRODUCT_VARIANT,\n iri(variantNode(label)),\n );\n }\n for (const label of asStringArray(k[\"not-applicable-to\"])) {\n add(subjectIri, GRAPH_NOT_APPLICABLE_TO_VARIANT, iri(variantNode(label)));\n }\n\n for (const value of asStringArray(k[\"about-product-lifecycle\"])) {\n const phase = SOFTWARE_LIFECYCLE_IRIS[value];\n if (phase) add(subjectIri, IIRDS_RELATES_TO_LIFECYCLE_PHASE, iri(phase));\n }\n for (const value of asStringArray(k[\"about-product-aspect\"])) {\n const subject = SOFTWARE_SUBJECT_IRIS[value];\n if (subject) add(subjectIri, IIRDS_HAS_SUBJECT, iri(subject));\n }\n for (const value of asStringArray(k[\"not-about-product-aspect\"])) {\n const subject = SOFTWARE_SUBJECT_IRIS[value];\n if (subject) add(subjectIri, GRAPH_NOT_SOFTWARE_SUBJECT, iri(subject));\n }\n };\n\n const docByPath = new Map(docs.map((d) => [normalizeDocPath(d.path), d]));\n const prov = sources.has(\"provenance\");\n\n /**\n * Agent node; dedupe converges repeats of the same name AND kind. The IRI\n * is segmented by kind (`agent/person/…`, `agent/software/…`) so a human\n * and a model whose names slug alike stay distinct nodes.\n */\n const agentNode = (name: string, type: ProvAgentClass): string => {\n const a = mintAgentIri(baseIri, AGENT_KIND[type], name);\n add(a, RDF_TYPE, iri(`${NS.prov}${type}`));\n add(a, `${NS.foaf}name`, lit(name));\n return a;\n };\n\n const qualified = options.qualified === true;\n\n // Qualification node IRIs use \".\" separators (github-slugger can never emit\n // a dot, so heading slugs cannot collide) and carry the agent slug, so two\n // agents on one activity/doc never merge into a single node.\n\n /** doc ↔ author qualification: {docIri}#prov.attribution.{agentSlug}. */\n const qualifyAttribution = (\n docIri: string,\n agentIri: string,\n name: string,\n ): void => {\n if (!qualified) return;\n const node = `${docIri}#prov.attribution.${conceptSlug(name)}`;\n add(docIri, `${NS.prov}qualifiedAttribution`, iri(node));\n add(node, RDF_TYPE, iri(`${NS.prov}Attribution`));\n add(node, `${NS.prov}agent`, iri(agentIri));\n add(node, `${NS.prov}hadRole`, iri(ROLE.author));\n };\n\n /** activity ↔ agent qualification: {activityIri}.assoc.{agentSlug}. */\n const qualifyAssociation = (\n activityIri: string,\n agentIri: string,\n role: string,\n ): void => {\n if (!qualified) return;\n const agentSlug = agentIri.slice(agentIri.lastIndexOf(\"/\") + 1);\n const node = `${activityIri}.assoc.${agentSlug}`;\n add(activityIri, `${NS.prov}qualifiedAssociation`, iri(node));\n add(node, RDF_TYPE, iri(`${NS.prov}Association`));\n add(node, `${NS.prov}agent`, iri(agentIri));\n add(node, `${NS.prov}hadRole`, iri(role));\n };\n\n /** Author agent + creator/attribution edges (+ qualification when on). */\n const attributeAuthor = (docIri: string, name: string): void => {\n const a = agentNode(name, \"Person\");\n add(docIri, `${NS.dcterms}creator`, iri(a));\n add(docIri, `${NS.prov}wasAttributedTo`, iri(a));\n qualifyAttribution(docIri, a, name);\n };\n\n /**\n * Shared mapping for graph.derived-from / graph.revision-of / page\n * `translation-of` entries.\n *\n * `inverse`, when given, is also emitted back from the resolved target — but\n * only for a target inside the corpus. A URL names a resource dockg has not\n * analyzed and does not speak for, so it gains an inbound edge and never an\n * outbound claim (ADR 01037).\n */\n const provTargetEdge = (\n doc: DocModel,\n docIri: string,\n raw: string,\n predicate: string,\n inverse?: string,\n ): void => {\n if (hasScheme(raw)) {\n add(docIri, predicate, iri(raw));\n return;\n }\n const target = resolveProvDocPath(\n normalizeDocPath(doc.path),\n raw,\n docByPath,\n );\n if (target) {\n const targetIri = mintDocIri(baseIri, target);\n add(docIri, predicate, iri(targetIri));\n if (inverse) add(targetIri, inverse, iri(docIri));\n } else {\n add(docIri, `${NS.graph}brokenLink`, lit(raw));\n }\n };\n\n for (const doc of docs) {\n const docIri = mintDocIri(baseIri, doc.path);\n const fm = doc.frontmatter;\n const block = graphBlock(fm);\n // `block` is the `graph` block as written (block-only facts: sections,\n // provenance, the SKOS hierarchy); `harvested` folds in the page-level\n // fallbacks.\n const harvested = resolveGraph(block, fm);\n // The page's own key outranks the route it sits under (ADR 01037): a\n // single English page inside a translated tree can correct its label,\n // and a corpus that declares nothing keeps deriving nothing.\n const pageLanguage = canonicalLanguage(\n asString(fmValue(fm, [\"lang\", \"language\"])) ?? doc.routeLanguage,\n );\n let createdEmitted = false;\n let modifiedEmitted = false;\n\n add(docIri, RDF_TYPE, iri(`${NS.graph}Document`));\n if (prov) add(docIri, RDF_TYPE, iri(`${NS.prov}Entity`));\n add(docIri, `${NS.graph}path`, lit(normalizeDocPath(doc.path)));\n // Intrinsic like path, not gated behind a derive source (ADR 01036): a hash\n // present only sometimes cannot tell \"unchanged\" from \"not stamped\", which\n // is the whole question it exists to answer.\n add(docIri, `${NS.graph}contentHash`, lit(doc.contentHash));\n\n if (sources.has(\"frontmatter\")) {\n const title = asString(fmValue(fm, [\"title\"])) ?? doc.firstH1;\n if (title) add(docIri, `${NS.dcterms}title`, lit(title));\n\n const description = asString(fmValue(fm, [\"description\"]));\n if (description)\n add(docIri, `${NS.dcterms}description`, lit(description));\n\n for (const author of asPersonNames(fmValue(fm, [\"author\", \"authors\"]))) {\n if (prov) {\n attributeAuthor(docIri, author);\n } else {\n add(docIri, `${NS.dcterms}creator`, lit(author));\n }\n }\n\n // Stewardship's spelling first (`created`, `last-updated`), then the\n // aliases other generators write. One value per predicate: the first\n // key present wins and the rest are ignored.\n const created = asString(fmValue(fm, [\"created\", \"date\"]));\n if (created) {\n add(docIri, `${NS.dcterms}created`, dateTerm(created));\n if (prov) add(docIri, `${NS.prov}generatedAtTime`, dateTerm(created));\n createdEmitted = true;\n }\n\n const modified = asString(\n fmValue(fm, [\"last-updated\", \"updated\", \"lastmod\", \"modified\"]),\n );\n if (modified) {\n add(docIri, `${NS.dcterms}modified`, dateTerm(modified));\n modifiedEmitted = true;\n }\n\n // Written in its canonical spelling: tags are case-insensitive, and\n // `en-us` beside `en-US` would otherwise split one locale into two\n // indexes and miss a `--lang` filter typed the other way.\n if (pageLanguage) add(docIri, `${NS.dcterms}language`, lit(pageLanguage));\n\n // ai-context's questions this page should be found for (proposal 0086\n // §7), in the page's language. Only the text: an item's answer pins and\n // review state are test data `check` reads from the source (0087).\n for (const { question } of readSampleQuestions(fmValue(fm, [\"sample-questions\"]))) {\n add(\n docIri,\n `${NS.graph}sampleQuestion`,\n pageLanguage\n ? { kind: \"literal\", value: question, language: pageLanguage }\n : lit(question),\n );\n }\n\n // Page-level only: the `graph` block is closed and carries no\n // translation key, so this fact lives at the altitude `lang` already\n // does (ADR 01023, ADR 01037). Both directions are materialized, so\n // \"every localization of this page\" is one lookup for a consumer with no\n // inbound index of its own.\n for (const raw of asStringArray(fmValue(fm, [\"translation-of\"]))) {\n provTargetEdge(\n doc,\n docIri,\n raw,\n `${NS.schema}translationOfWork`,\n `${NS.schema}workTranslation`,\n );\n }\n\n // The graph block: the SKOS hierarchy has no page-level twin, so it reads\n // the block as written (frontmatter key `graph`, RDF prefix `graph:`).\n const blockLabel = block ? asString(block[\"label\"]) : undefined;\n if (block) {\n if (blockLabel) {\n const topic = concept(blockLabel, pageLanguage);\n add(docIri, `${NS.foaf}primaryTopic`, iri(topic));\n for (const alt of asStringArray(block[\"alt-labels\"])) {\n add(topic, `${NS.skos}altLabel`, lit(alt));\n }\n // Frontmatter key → SKOS predicate. `related-concepts` is spelled for\n // what it points at (in step with the page-level `related-pages`);\n // the predicate it emits is still plain skos:related.\n for (const [key, predicate] of [\n [\"broader\", \"broader\"],\n [\"narrower\", \"narrower\"],\n [\"related-concepts\", \"related\"],\n ] as const) {\n for (const value of asStringArray(block[key])) {\n hierarchy(topic, predicate, concept(value, pageLanguage));\n }\n }\n }\n }\n\n // A term page is about its term (proposal 0086 §1), unless its `graph`\n // block names a topic of its own. Its id names the term, and its label\n // does when the id is absent or names no term.\n if (!blockLabel && asString(fm[\"type\"]) === \"term\") {\n const id = asString(fm[\"id\"]);\n const label = asString(fm[\"label\"]);\n const termId =\n (id !== undefined && terms.groups.has(id) ? id : undefined) ??\n (label === undefined ? undefined : terms.resolve(label, pageLanguage));\n if (termId !== undefined) {\n add(docIri, `${NS.foaf}primaryTopic`, iri(mintTermConceptIri(baseIri, termId)));\n }\n }\n\n // iiRDS Core + Software typing (ADR 01012), over the harvested block so a\n // page typed only at the top level still types its document (ADR 01024).\n emitIirdsTyping(docIri, harvested);\n }\n\n if (sources.has(\"tags\")) {\n // Two distinct facts, both landing on dcterms:subject: dockg's own\n // tag harvest (`tags`/`keywords`), and the concepts fact — where\n // `graph.concepts` beats the page-level `concepts` outright rather than\n // adding to it (ADR 01024).\n const labels = [\n ...asStringArray(fmValue(fm, [\"tags\", \"keywords\"])),\n ...asStringArray(harvested[\"concepts\"]),\n ];\n for (const label of labels) {\n add(docIri, `${NS.dcterms}subject`, iri(concept(label, pageLanguage)));\n }\n }\n\n if (sources.has(\"sections\")) {\n // graph.sections: slug-keyed iiRDS typing attached to section nodes\n // (ADR 01013). Explicit-only — a section gets nothing from the doc.\n const sectionMeta = asRecord(block?.[\"sections\"]);\n const sectionSlugs = new Set(doc.sections.map((s) => s.slug));\n\n for (const section of doc.sections) {\n const secIri = mintSectionIri(docIri, section.slug);\n const parentIri = section.parentSlug\n ? mintSectionIri(docIri, section.parentSlug)\n : docIri;\n add(secIri, RDF_TYPE, iri(`${NS.graph}Section`));\n add(secIri, `${NS.dcterms}title`, lit(section.title));\n add(\n secIri,\n `${NS.graph}level`,\n typedLit(String(section.level), `${NS.xsd}integer`),\n );\n add(\n secIri,\n `${NS.graph}order`,\n typedLit(String(section.order), `${NS.xsd}integer`),\n );\n add(parentIri, `${NS.dcterms}hasPart`, iri(secIri));\n\n const meta = asRecord(sectionMeta[section.slug]);\n emitIirdsTyping(secIri, meta);\n for (const label of asStringArray(meta[\"concepts\"])) {\n add(secIri, `${NS.dcterms}subject`, iri(concept(label, pageLanguage)));\n }\n }\n\n // A graph.sections key naming no heading is a broken reference (surfaced\n // by stats, gated by stats --check) — never a silent drop.\n for (const slug of Object.keys(sectionMeta)) {\n if (!sectionSlugs.has(slug)) {\n add(docIri, `${NS.graph}brokenSectionRef`, lit(slug));\n }\n }\n }\n\n if (sources.has(\"links\")) {\n for (const link of doc.links) {\n if (link.kind === \"external\" && link.url) {\n add(docIri, `${NS.dcterms}references`, iri(link.url));\n } else if (link.kind === \"internal\" && link.resolvedPath) {\n const targetIri = mintDocIri(baseIri, link.resolvedPath);\n const target = docByPath.get(link.resolvedPath);\n // Bound first, so the anchor the test found is the anchor the IRI is\n // minted from rather than a second read the type cannot connect to\n // the first.\n const anchor = link.anchor;\n const anchorResolves =\n anchor !== undefined &&\n target !== undefined &&\n target.sections.some((s) => s.slug === anchor);\n add(\n docIri,\n `${NS.dcterms}references`,\n iri(\n anchorResolves ? mintSectionIri(targetIri, anchor) : targetIri,\n ),\n );\n } else if (link.kind === \"broken\") {\n add(docIri, `${NS.graph}brokenLink`, lit(link.raw));\n }\n }\n }\n\n if (sources.has(\"images\")) {\n for (const image of doc.images) {\n const target = image.external\n ? image.target\n : `${baseIri}file/${normalizeDocPath(image.target)\n .split(\"/\")\n .map(encodeSegment)\n .join(\"/\")}`;\n add(docIri, `${NS.schema}image`, iri(target));\n }\n }\n\n if (sources.has(\"code\")) {\n for (const language of doc.codeLanguages) {\n add(docIri, `${NS.graph}codeLanguage`, lit(language));\n }\n }\n\n if (prov) {\n // graph.derived-from / graph.revision-of: doc-relative path,\n // repo-relative path, or URL — one shared resolution. `derived-from` is block-only\n // (document lineage is curated by hand); `revision-of` harvests the\n // page-level `supersedes` when the block is silent (ADR 01024).\n for (const raw of block ? asStringArray(block[\"derived-from\"]) : []) {\n provTargetEdge(doc, docIri, raw, `${NS.prov}wasDerivedFrom`);\n }\n for (const raw of asStringArray(harvested[\"revision-of\"])) {\n provTargetEdge(doc, docIri, raw, `${NS.prov}wasRevisionOf`);\n }\n\n // Per-file git history (provenance.git): frontmatter always wins on\n // dates; authors merge; renames become revision edges to the\n // historical-path entities.\n const gitFile = options.gitHistory?.files.get(normalizeDocPath(doc.path));\n if (gitFile) {\n if (!createdEmitted && gitFile.created) {\n add(docIri, `${NS.dcterms}created`, dateTerm(gitFile.created));\n add(docIri, `${NS.prov}generatedAtTime`, dateTerm(gitFile.created));\n }\n if (!modifiedEmitted && gitFile.modified) {\n add(docIri, `${NS.dcterms}modified`, dateTerm(gitFile.modified));\n }\n for (const author of gitFile.authors) {\n attributeAuthor(docIri, author);\n }\n for (const oldPath of gitFile.renamedFrom) {\n const oldIri = mintDocIri(baseIri, oldPath);\n add(docIri, `${NS.prov}wasRevisionOf`, iri(oldIri));\n add(oldIri, RDF_TYPE, iri(`${NS.prov}Entity`));\n }\n }\n\n // Whole-page generation. There is no page-level `generated-by` any more\n // (proposal 0046): the machines that wrote a page are the DISTINCT\n // `generated-by` values across its page-level `provenance` entries, each\n // of which pins a line range. The activity stays one per page, so a\n // single-model page emits exactly what it always did. Its fragment uses\n // a \".\" separator, which github-slugger can never produce — heading\n // slugs cannot collide with provenance fragments.\n const machines = [\n ...new Set(\n recordEntries(fmValue(fm, [\"provenance\"])).flatMap((e) => {\n const m = asString(e[\"generated-by\"]);\n return m === undefined ? [] : [m];\n }),\n ),\n ].sort(byCodeUnit);\n if (machines.length > 0) {\n const activity = `${docIri}#prov.generation`;\n add(docIri, `${NS.prov}wasGeneratedBy`, iri(activity));\n add(activity, RDF_TYPE, iri(`${NS.prov}Activity`));\n for (const machine of machines) {\n const model = agentNode(machine, \"SoftwareAgent\");\n add(activity, `${NS.prov}wasAssociatedWith`, iri(model));\n qualifyAssociation(activity, model, ROLE.generator);\n }\n }\n\n // Page-level `meta-provenance` (written by `manni graph fill`): one\n // activity PER MODEL so multiple fills by different models keep truthful\n // attribution. Only the doc's own topic concept is prov:generated —\n // shared subject/tag concepts are never attributed, or one doc's LLM\n // would taint every doc using the same tag.\n for (const entry of recordEntries(fmValue(fm, [\"meta-provenance\"]))) {\n const model = asString(entry[\"generated-by\"]);\n if (!model) continue;\n // A pointer names a value anywhere on the page, so only the ones under\n // `/graph/` are graph's business. The filled field is the first segment\n // after it: `/graph/sections/install/type` attributes `sections`, the\n // field a reviewer would look at. First pointer wins on confidence,\n // which 0046 keys by the whole pointer rather than by the field.\n const pointers = asStringArray(entry[\"fields\"]);\n const confidence = asRecord(entry[\"confidence\"]);\n const filled = new Map<string, string>();\n for (const pointer of pointers) {\n if (!pointer.startsWith(\"/graph/\")) continue;\n const field = pointerSegments(pointer)[1];\n if (field === undefined || field === \"\") continue;\n if (!filled.has(field)) filled.set(field, pointer);\n }\n if (filled.size === 0) continue;\n const activity = `${docIri}#prov.graph-fill.${conceptSlug(model)}`;\n const modelAgent = agentNode(model, \"SoftwareAgent\");\n add(activity, RDF_TYPE, iri(`${NS.prov}Activity`));\n add(activity, `${NS.prov}wasAssociatedWith`, iri(modelAgent));\n qualifyAssociation(activity, modelAgent, ROLE.generator);\n // Each filled field is reified as an entry node carrying its name and\n // (when fill recorded one) the model's confidence — a plain,\n // blank-node-free per-field audit edge (ADR 01015).\n for (const [field, pointer] of filled) {\n const fieldNode = `${activity}.field.${field}`;\n add(activity, `${NS.graph}filledFieldEntry`, iri(fieldNode));\n add(fieldNode, `${NS.graph}filledField`, lit(field));\n const c = confidence[pointer];\n if (typeof c === \"number\") {\n add(\n fieldNode,\n `${NS.graph}confidence`,\n typedLit(String(Math.round(c * 100) / 100), `${NS.xsd}decimal`),\n );\n }\n }\n const label = block ? asString(block[\"label\"]) : undefined;\n if (label && filled.has(\"label\")) {\n const id = terms.resolve(label, pageLanguage);\n add(\n activity,\n `${NS.prov}generated`,\n iri(\n id === undefined\n ? mintConceptIri(baseIri, label)\n : mintTermConceptIri(baseIri, id),\n ),\n );\n }\n }\n }\n }\n\n if (prov) {\n const graphIri = mintGraphIri(baseIri);\n const activity = mintBuildActivityIri(baseIri);\n const tool = agentNode(\"manni\", \"SoftwareAgent\");\n add(graphIri, RDF_TYPE, iri(`${NS.prov}Entity`));\n add(graphIri, `${NS.prov}wasGeneratedBy`, iri(activity));\n add(activity, RDF_TYPE, iri(`${NS.prov}Activity`));\n add(activity, `${NS.prov}wasAssociatedWith`, iri(tool));\n qualifyAssociation(activity, tool, ROLE.tool);\n if (options.toolVersion) {\n add(tool, `${NS.graph}version`, lit(options.toolVersion));\n }\n for (const doc of docs) {\n add(activity, `${NS.prov}used`, iri(mintDocIri(baseIri, doc.path)));\n }\n const headTime = options.gitHistory?.headTime;\n if (headTime) {\n add(\n activity,\n `${NS.prov}endedAtTime`,\n typedLit(headTime, `${NS.xsd}dateTime`),\n );\n }\n }\n\n // The termbase's concepts (proposal 0086 §1): one per id, each language of a\n // term joining it, and every label tagged with the term's language.\n const tagged = (value: string, language: string | undefined): Term =>\n language === undefined ? lit(value) : { kind: \"literal\", value, language };\n for (const [id, entries] of terms.groups) {\n const c = mintTermConceptIri(baseIri, id);\n add(c, RDF_TYPE, iri(`${NS.skos}Concept`));\n add(c, `${NS.skos}inScheme`, iri(mintSchemeIri(baseIri)));\n mintedConcepts.add(c);\n for (const entry of entries) {\n const language = canonicalLanguage(entry.language);\n add(c, `${NS.skos}prefLabel`, tagged(entry.label, language));\n for (const [values, predicate] of [\n [entry.altLabels, \"altLabel\"],\n [entry.hiddenLabels, \"hiddenLabel\"],\n [entry.definition, \"definition\"],\n [entry.scopeNote, \"scopeNote\"],\n ] as const) {\n for (const value of asStringArray(values)) {\n add(c, `${NS.skos}${predicate}`, tagged(value, language));\n }\n }\n for (const relation of [\"broader\", \"narrower\", \"related\"] as const) {\n for (const value of entry[relation] ?? []) {\n hierarchy(c, relation, concept(value, language));\n }\n }\n // A code and the mappings out of the scheme belong to no language.\n if (entry.notation !== undefined) add(c, `${NS.skos}notation`, lit(entry.notation));\n for (const [values, predicate] of [\n [entry.exactMatches, \"exactMatch\"],\n [entry.closeMatches, \"closeMatch\"],\n [entry.broadMatches, \"broadMatch\"],\n [entry.narrowMatches, \"narrowMatch\"],\n [entry.relatedMatches, \"relatedMatch\"],\n ] as const) {\n for (const value of values ?? []) add(c, `${NS.skos}${predicate}`, iri(value));\n }\n }\n }\n // A `see:` entry is no concept of its own. Its label is another way to say\n // its target, so it becomes an altLabel there.\n for (const entry of terms.redirects) {\n const language = canonicalLanguage(entry.language);\n const target =\n entry.see === undefined ? undefined : terms.resolve(entry.see, language);\n if (target === undefined) continue;\n add(\n mintTermConceptIri(baseIri, target),\n `${NS.skos}altLabel`,\n tagged(entry.label, language),\n );\n }\n\n if (mintedConcepts.size > 0) {\n const scheme = mintSchemeIri(baseIri);\n add(scheme, RDF_TYPE, iri(`${NS.skos}ConceptScheme`));\n add(scheme, `${NS.dcterms}title`, lit(CONCEPT_SCHEME_TITLE));\n // A concept with no broader concept is a top concept of the scheme, both\n // ways round. Read off the quads, so every source of hierarchy counts.\n const broader = `${NS.skos}broader`;\n const hasBroader = new Set(\n quads.filter((q) => q.p === broader).map((q) => q.s),\n );\n for (const c of mintedConcepts) {\n if (hasBroader.has(c)) continue;\n add(c, `${NS.skos}topConceptOf`, iri(scheme));\n add(scheme, `${NS.skos}hasTopConcept`, iri(c));\n }\n }\n\n return dedupe(quads);\n}\n\nfunction quadKey(q: Quad): string {\n const o =\n q.o.kind === \"iri\"\n ? `i:${q.o.value}`\n : `l:${q.o.value}|${q.o.datatype ?? \"\"}|${q.o.language ?? \"\"}`;\n return `${q.s}|${q.p}|${o}`;\n}\n\nfunction dedupe(quads: Quad[]): Quad[] {\n const seen = new Set<string>();\n const out: Quad[] = [];\n for (const q of quads) {\n const key = quadKey(q);\n if (seen.has(key)) continue;\n seen.add(key);\n out.push(q);\n }\n return out;\n}\n","/**\n * Deterministic Turtle serialization — the git-diff contract. Canonical form:\n * fixed sorted prefix header; subjects sorted by full IRI; within a subject,\n * rdf:type first (as `a`), then predicates sorted by full IRI; objects sorted\n * (IRIs before literals, each lexicographic); LF line endings, UTF-8, exactly\n * one trailing newline. Byte-identical output for any input quad order.\n *\n * Deliberately not N3.Writer: its formatting is incidental library behavior.\n * Correctness of escaping is guarded by a round-trip test through n3's parser.\n */\nimport type { Quad, Term } from \"./derive.js\";\nimport { byCodeUnit } from \"./sort.js\";\nimport { NS, PREFIXES, RDF_TYPE } from \"./vocab.js\";\n\n/** Conservative PN_LOCAL: shorten only when the local name is trivially safe. */\nconst SAFE_LOCAL = /^[A-Za-z_][A-Za-z0-9_-]*$/;\n\n/**\n * Percent-encode characters the Turtle IRIREF production forbids\n * (controls, space, <>\"{}|^` and backslash) so output always parses,\n * whatever made it into a node value.\n */\n// Forbidden by IRIREF: <>\"{}|^ plus backtick and backslash.\nconst ILLEGAL_IRI_CHARS = '<>\"{}|^\\x60\\x5c';\n\nfunction sanitizeIri(iriValue: string): string {\n let out = \"\";\n for (const ch of iriValue) {\n const code = ch.codePointAt(0) as number;\n const illegal = code <= 0x20 || ILLEGAL_IRI_CHARS.includes(ch);\n out += illegal\n ? \"%\" + code.toString(16).toUpperCase().padStart(2, \"0\")\n : ch;\n }\n return out;\n}\n\n/**\n * Memo: the same predicates/objects recur once per quad; shorten each once.\n * Cleared at the start of every emit so long-lived embedders don't accumulate\n * every IRI ever serialized.\n */\nconst shortenMemo = new Map<string, string>();\n\nfunction shorten(iriValue: string): string {\n const memoized = shortenMemo.get(iriValue);\n if (memoized !== undefined) return memoized;\n let result: string | undefined;\n for (const [prefix, ns] of PREFIXES) {\n if (iriValue.startsWith(ns)) {\n const local = iriValue.slice(ns.length);\n if (SAFE_LOCAL.test(local)) {\n result = `${prefix}:${local}`;\n break;\n }\n }\n }\n result ??= `<${sanitizeIri(iriValue)}>`;\n shortenMemo.set(iriValue, result);\n return result;\n}\n\nfunction escapeLiteral(value: string): string {\n return value\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/\\t/g, \"\\\\t\");\n}\n\nconst INTEGER = `${NS.xsd}integer`;\nconst INTEGER_RE = /^-?\\d+$/;\n\nfunction renderTerm(term: Term): string {\n if (term.kind === \"iri\") return shorten(term.value);\n if (term.datatype === INTEGER && INTEGER_RE.test(term.value))\n return term.value;\n const quoted = `\"${escapeLiteral(term.value)}\"`;\n if (term.language) return `${quoted}@${term.language}`;\n return term.datatype ? `${quoted}^^${shorten(term.datatype)}` : quoted;\n}\n\n/** Sort objects: IRIs before literals, each lexicographically. */\nfunction compareTerms(a: Term, b: Term): number {\n if (a.kind !== b.kind) return a.kind === \"iri\" ? -1 : 1;\n const byValue = byCodeUnit(a.value, b.value);\n if (byValue !== 0) return byValue;\n const da = a.kind === \"literal\" ? (a.datatype ?? \"\") : \"\";\n const db = b.kind === \"literal\" ? (b.datatype ?? \"\") : \"\";\n const la = a.kind === \"literal\" ? (a.language ?? \"\") : \"\";\n const lb = b.kind === \"literal\" ? (b.language ?? \"\") : \"\";\n return byCodeUnit(da, db) || byCodeUnit(la, lb);\n}\n\nexport function emitTurtle(quads: Quad[]): string {\n shortenMemo.clear();\n const lines: string[] = [];\n for (const [prefix, ns] of PREFIXES) {\n lines.push(`@prefix ${prefix}: <${ns}> .`);\n }\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 comes out\n // of the map with the subject it belongs to, and each term list with its\n // predicate, so nothing is looked up again and nothing has to be asserted.\n const sortedSubjects = [...subjects.entries()].sort(([a], [b]) =>\n byCodeUnit(a, b),\n );\n for (const [subject, preds] of sortedSubjects) {\n const sortedPreds = [...preds.entries()].sort(([a], [b]) => {\n if (a === RDF_TYPE) return b === RDF_TYPE ? 0 : -1;\n if (b === RDF_TYPE) return 1;\n return byCodeUnit(a, b);\n });\n\n const entries = sortedPreds.map(([p, terms], i) => {\n const objects = [...terms].sort(compareTerms).map(renderTerm).join(\", \");\n const pred = p === RDF_TYPE ? \"a\" : shorten(p);\n const terminator = i === sortedPreds.length - 1 ? \" .\" : \" ;\";\n return { pred, objects, terminator };\n });\n\n // A subject is in the map only because a quad put a predicate under it, so\n // `entries` is never empty; the destructuring says so and leaves the rest\n // of the block unreachable if it ever were.\n const [first, ...rest] = entries;\n if (first === undefined) continue;\n lines.push(\"\");\n lines.push(\n `${shorten(subject)} ${first.pred} ${first.objects}${first.terminator}`,\n );\n for (const entry of rest) {\n lines.push(` ${entry.pred} ${entry.objects}${entry.terminator}`);\n }\n }\n\n return `${lines.join(\"\\n\")}\\n`;\n}\n","/**\n * Near-miss detection for the page-level keys the harvest rule reads\n * (ADR 01024, ADR 01028).\n *\n * Five page-level keys are graph inputs — `type`, `concepts`, `applies-to`,\n * `not-applicable-to`, `supersedes` — and unlike the `graph` block, nothing\n * validates them. The `graph` block is `additionalProperties: false`, so a typo\n * inside it is a hard schema error; the same typo at the page level derives\n * silently nothing, because a page may legitimately carry any other key it\n * likes (a site generator's, a linter's, an author's).\n *\n * A schema is therefore the wrong instrument: rejecting unknown page keys would\n * reject every page. What is wrong with `applies_to` is not that dockg does not\n * know it — it is that it is one character from a key dockg *does* know, on a\n * page that declares nothing else of the kind. That is what this detects, and\n * it is the whole scope: dockg does not implement the vocabularies these keys\n * belong to and must not start claiming their facts (ADR 01024).\n *\n * Warnings only. A near miss is a suspicion, not a finding, and a suspicion\n * must never fail a build.\n */\nimport { PAGE_TYPE_TO_TOPIC_TYPE } from \"./iirds.js\";\nimport { byCodeUnit } from \"./sort.js\";\nimport type { DocModel } from \"../types.js\";\n\n/**\n * The page-level keys dockg reads, in the spelling it expects.\n *\n * Five are `resolveGraph`'s harvest inputs (ADR 01024). The localization three\n * are read straight by the emitter — `lang`/`language` into `dcterms:language`,\n * `translation-of` into the schema.org translation pair (ADR 01037) — and are\n * listed here for the same reason: a typo in any of them derives nothing while\n * looking exactly like a declared fact.\n */\nexport const HARVESTED_KEYS: readonly string[] = [\n \"applies-to\",\n \"concepts\",\n \"lang\",\n \"language\",\n \"not-applicable-to\",\n \"supersedes\",\n \"translation-of\",\n \"type\",\n];\n\n/**\n * Levenshtein distance, capped: anything past `max` returns `max + 1`, since\n * the caller only cares whether a candidate is *close*.\n */\nfunction distance(a: string, b: string, max: number): number {\n if (a === b) return 0;\n if (Math.abs(a.length - b.length) > max) return max + 1;\n let prev = Array.from({ length: b.length + 1 }, (_, i) => i);\n for (let i = 1; i <= a.length; i++) {\n const row = [i];\n for (let j = 1; j <= b.length; j++) {\n row[j] = Math.min(\n (prev[j] ?? 0) + 1,\n (row[j - 1] ?? 0) + 1,\n (prev[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1),\n );\n }\n prev = row;\n }\n return prev[b.length] ?? max + 1;\n}\n\n/**\n * The known name a candidate was probably meant to be, or undefined.\n *\n * Distance 1 for short names, 2 for longer ones: `type` and `types` differ by\n * one and mean different things, while `not-applicable-to` can absorb two typos\n * and still be unmistakable. Separator-only differences (`applies_to`,\n * `appliesTo`) normalize to an exact match and are always caught.\n */\nfunction nearestKnown(\n candidate: string,\n known: readonly string[],\n): string | undefined {\n // Split camelCase BEFORE lowercasing — doing it after is a no-op, because\n // there is no uppercase left to match. `appliesTo` then reaches `applies-to`\n // exactly, instead of relying on the distance fallback to rescue it, and\n // `notApplicabelTo` (two typos plus a case boundary) becomes reachable at\n // all.\n const normalize = (s: string): string =>\n s\n .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n .toLowerCase()\n .replace(/[_\\s]+/g, \"-\");\n const c = normalize(candidate);\n for (const k of known) {\n if (c === normalize(k) && candidate !== k) return k;\n }\n let best: { key: string; d: number } | undefined;\n for (const k of known) {\n const max = k.length > 8 ? 2 : 1;\n const d = distance(c, normalize(k), max);\n if (d > max) continue;\n if (!best || d < best.d) best = { key: k, d };\n }\n return best?.key;\n}\n\n/**\n * Warnings for page-level keys and page `type` values that look like harvest\n * inputs but are not. Sorted, so the output is deterministic like everything\n * else dockg emits.\n */\nexport function harvestWarnings(docs: readonly DocModel[]): string[] {\n const out: string[] = [];\n const mappedTypes = Object.keys(PAGE_TYPE_TO_TOPIC_TYPE);\n\n for (const doc of docs) {\n const fm = doc.frontmatter;\n const present = new Set(Object.keys(fm));\n\n for (const key of present) {\n if (HARVESTED_KEYS.includes(key)) continue;\n const meant = nearestKnown(key, HARVESTED_KEYS);\n // Only suspicious if the page does not already declare the real key: a\n // page carrying both `applies-to` and `applies_to` has made its choice.\n if (meant === undefined || present.has(meant)) continue;\n out.push(\n `${doc.path}: page key \"${key}\" is not read by manni graph and looks like \"${meant}\" — nothing was derived from it`,\n );\n }\n\n // A page `type` outside the map derives nothing, by design: dockg\n // references iiRDS terms and never mints them. That is correct for\n // `blog-post`, and almost never what the author meant for `how to`.\n const type = fm[\"type\"];\n // Object.hasOwn, not `in`: `type: constructor` and `type: toString` walk\n // the prototype chain and would be read as mapped types, silently skipping\n // the check.\n if (\n typeof type === \"string\" &&\n !Object.hasOwn(PAGE_TYPE_TO_TOPIC_TYPE, type)\n ) {\n const meant = nearestKnown(type, mappedTypes);\n if (meant !== undefined) {\n out.push(\n `${doc.path}: page type \"${type}\" maps to no iiRDS topic type and looks like \"${meant}\" — no graph.type was derived`,\n );\n }\n }\n }\n\n return out.sort(byCodeUnit);\n}\n","/**\n * One-pass git history collection for provenance derivation. A single\n * `git log` subprocess covers the whole corpus: per-file creation and\n * last-modification committer dates, author names, and rename chains\n * (followed backward so history accrues to the file's current path).\n * Deterministic per commit — the wall clock never enters the result.\n *\n * Author emails are deliberately not collected into the result (privacy):\n * names only, matching frontmatter author handling.\n */\nimport { GraphError } from \"../types.js\";\nimport { realExec, type ExecFn } from \"@hawkeyexl/inference\";\nimport { posix } from \"node:path\";\nimport { normalizeDocPath } from \"./iri.js\";\n\nexport interface GitFileHistory {\n /** Committer ISO date of the oldest commit touching the file (or its earlier names). */\n created?: string;\n /** Committer ISO date of the newest commit touching it. */\n modified?: string;\n /** Unique author names, newest contribution first. */\n authors: string[];\n /** Earlier paths of this file, nearest rename first (git -M heuristic; best-effort). */\n renamedFrom: string[];\n}\n\nexport interface GitHistory {\n /** HEAD committer ISO date — stamps the build activity's prov:endedAtTime. */\n headTime?: string;\n files: Map<string, GitFileHistory>;\n}\n\n/**\n * Git versions print a UTC committer date from `%cI` as either `+00:00` or\n * `Z`. Both name the same instant, so one spelling keeps the graph identical\n * whichever git wrote it. Other offsets pass through unchanged.\n */\nexport function canonicalGitTime(time: string): string {\n return time.replace(/[+-]00:00$/, \"Z\");\n}\n\n/** Record line marker: %x01 keeps commit headers unambiguous in the stream. */\nconst RECORD = \"\\u0001\";\nconst STATUS_LINE = /^([AMDRC])\\d*\\t(.+)$/;\n\n/**\n * Undo git's C-style path quoting. Even with core.quotepath=off, paths\n * containing double quotes, backslashes, or control characters arrive as\n * `\"docs/a\\\"b.md\"` — quotepath only disables quoting of non-ASCII bytes.\n * Octal escapes are raw UTF-8 bytes, decoded together at the end.\n */\nexport function unquoteGitPath(path: string): string {\n if (path.length < 2 || !path.startsWith('\"') || !path.endsWith('\"')) {\n return path;\n }\n const inner = path.slice(1, -1);\n const bytes: number[] = [];\n for (let i = 0; i < inner.length; i++) {\n // `?? \"\"` cannot fire under the loop's own bound; it is how that is said\n // without an assertion, and an empty chunk contributes no bytes anyway.\n const ch = inner[i] ?? \"\";\n if (ch !== \"\\\\\") {\n for (const byte of Buffer.from(ch, \"utf8\")) bytes.push(byte);\n continue;\n }\n const next = inner[++i];\n if (next === undefined) break;\n if (next >= \"0\" && next <= \"7\") {\n let octal = next;\n while (octal.length < 3) {\n const digit = inner[i + 1];\n if (digit === undefined || digit < \"0\" || digit > \"7\") break;\n octal += digit;\n i++;\n }\n bytes.push(Number.parseInt(octal, 8));\n } else {\n const map: Record<string, string> = { n: \"\\n\", t: \"\\t\", r: \"\\r\" };\n for (const byte of Buffer.from(map[next] ?? next, \"utf8\"))\n bytes.push(byte);\n }\n }\n return Buffer.from(bytes).toString(\"utf8\");\n}\n\n/**\n * Unset every inherited `GIT_*` variable for the child process.\n *\n * git exports GIT_DIR, GIT_INDEX_FILE, GIT_WORK_TREE and friends to the\n * subprocesses it runs — every hook, and anything spawned from one. Inheriting\n * them makes `git log` read *that* repository instead of `cwd`, so the same\n * inputs would yield a different graph depending on who invoked dockg, and a\n * build outside a repo would silently succeed against an unrelated one. Both\n * break the determinism contract, so the ambient state is dropped wholesale\n * rather than enumerated: git keeps adding variables to this namespace.\n */\nfunction clearedGitEnv(): Record<string, string | undefined> {\n const cleared: Record<string, string | undefined> = {};\n for (const key of Object.keys(process.env)) {\n if (key.startsWith(\"GIT_\")) cleared[key] = undefined;\n }\n return cleared;\n}\n\nexport async function collectGitHistory(\n cwd: string,\n exec: ExecFn = realExec,\n): Promise<GitHistory> {\n const git = async (args: string[]): Promise<string> => {\n const result = await exec([\"git\", ...args], {\n cwd,\n timeoutMs: 60000,\n env: clearedGitEnv(),\n });\n // Messages stay neutral about *why* git provenance was requested; the\n // caller frames the failure as an error or a warning.\n if (result.spawnError) {\n throw new GraphError(\n `git could not be run: ${result.spawnError} (is git installed and on PATH?)`,\n );\n }\n if (result.timedOut) {\n throw new GraphError(\n \"`git log` timed out after 60s — the repo history may be too large for whole-history provenance\",\n );\n }\n if (result.code !== 0) {\n const detail = result.stderr.trim().slice(-300);\n throw new GraphError(\n `git history could not be read (is ${cwd} a git repo with at least one commit?)${detail ? ` — git said: ${detail}` : \"\"}`,\n );\n }\n return result.stdout;\n };\n // Keys are relative to `cwd`, the directory the caller's labels count from\n // (`documentBase`). git reports paths from the repository root, so each is\n // rebased by `cwd`'s own place in the repository. `--relative` would do that\n // too, but it drops every path outside `cwd`: a page labelled `../x.md`, and\n // a rename from outside, whose fold into the current name is the point.\n const prefix = `/${(await git([\"rev-parse\", \"--show-prefix\"])).trim()}`;\n const label = (raw: string): string =>\n posix.relative(prefix, `/${normalizeDocPath(unquoteGitPath(raw))}`);\n const stdout = await git([\n \"-c\",\n \"core.quotepath=off\",\n \"log\",\n `--format=${RECORD}%H%x09%an%x09%cI`,\n \"--name-status\",\n \"-M\",\n ]);\n if (stdout.trim() === \"\") {\n throw new GraphError(\n `git history could not be read (is ${cwd} a git repo with at least one commit?)`,\n );\n }\n\n const files = new Map<string, GitFileHistory>();\n /** Maps a historical path to the file's current (newest) path. */\n const currentName = new Map<string, string>();\n let headTime: string | undefined;\n let commitAuthor = \"\";\n let commitTime = \"\";\n\n const entry = (path: string): GitFileHistory => {\n let file = files.get(path);\n if (!file) {\n file = { authors: [], renamedFrom: [] };\n files.set(path, file);\n }\n return file;\n };\n\n /** Register that the commit being parsed touched `path` (as known at that time). */\n const touch = (pathThen: string): GitFileHistory => {\n const path = label(pathThen);\n const current = currentName.get(path) ?? path;\n const file = entry(current);\n // Walking newest→oldest: first touch wins `modified`, every touch pushes\n // `created` older, authors keep first-appearance (newest) order.\n file.modified ??= commitTime;\n file.created = commitTime;\n if (!file.authors.includes(commitAuthor)) file.authors.push(commitAuthor);\n return file;\n };\n\n for (const line of stdout.split(\"\\n\")) {\n if (line.startsWith(RECORD)) {\n const [, author = \"\", rawTime = \"\"] = line.slice(1).split(\"\\t\");\n const time = canonicalGitTime(rawTime);\n commitAuthor = author;\n commitTime = time;\n headTime ??= time;\n continue;\n }\n const match = STATUS_LINE.exec(line);\n // Both groups are mandatory in the pattern, so a match carries both;\n // requiring them subsumes the bare `if (!match) continue` this replaces.\n const status = match?.[1];\n const rest = match?.[2];\n if (status === undefined || rest === undefined) continue;\n if (status === \"R\" || status === \"C\") {\n const [oldPath, newPath] = rest.split(\"\\t\");\n if (!oldPath || !newPath) continue;\n if (status === \"C\") {\n // Copies create a new file from an old one; the old file's own history\n // is separate. Record the touch on the copy only.\n touch(newPath);\n continue;\n }\n const file = touch(newPath);\n const normalizedOld = label(oldPath);\n file.renamedFrom.push(normalizedOld);\n // Older commits refer to the pre-rename path; fold them into this file.\n const normalizedNew = label(newPath);\n currentName.set(\n normalizedOld,\n currentName.get(normalizedNew) ?? normalizedNew,\n );\n } else {\n touch(rest);\n }\n }\n\n return { headTime, files };\n}\n","/**\n * `x-manni-graph-output` (proposal 0051 §5), on graph's side of the seam.\n *\n * Which fields belong in a published graph is a property of the field, not of\n * this tool, so it is recorded where the field is defined. The keyword is a\n * boolean beside a top-level property, registered on every Ajv `manni meta`\n * builds and read back through `Validator.graphOutputPreferences`. Absent means\n * `true`: every field is harvested. A mark nested inside `graph` is ignored, as\n * 0047 rule 2 ignores an `x-manni-location` there — the mark governs a\n * top-level key, and `graph` is the top-level key.\n *\n * The filter runs once, before `deriveGraph`, because all four published\n * outputs descend from what derivation produces: `emitTurtle` writes the graph,\n * and JSON-LD, the iiRDS package and the search index are all built by reading\n * that graph back. Dropping the field here keeps it out of every one of them.\n *\n * Encrypted values (proposal 0045) are harvested like any other value. graph\n * never decrypts, so what lands in the graph is the `~…` token, which says a\n * value exists and nothing about what it is. A field that should not reach a\n * published graph at all is marked `false` — one mechanism for \"keep this out\n * of the output\", rather than one rule for encryption and another for\n * everything else (0051 stress test 4).\n */\nimport type { MetaPageView } from \"../../meta/internal.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport { GraphError } from \"../types.js\";\nimport type { DocModel } from \"../types.js\";\n\n/**\n * `docs`, with every top-level frontmatter key its schemas mark\n * `x-manni-graph-output: false` removed.\n *\n * A page's schemas are the set `manni meta validate` resolves for it (proposal\n * 0074): its own `$schema`, then meta's overrides, `schemas:`, `strict` and\n * the default set, read from meta's section of the same config. graph keeps\n * no schema set of its own, so one config answers both what a page is checked\n * against and what its published graph may carry.\n *\n * The docs arrive with their manifests' values already merged\n * (`withExternalMetadata`), so a field kept beside the page is filtered by\n * the same mark as one kept on it.\n *\n * A document whose schemas mark nothing is returned as it came in, so the\n * common case allocates nothing.\n */\nexport async function suppressGraphOutput(\n docs: readonly DocModel[],\n sets: Pick<MetaPageView, \"validator\" | \"refsFor\">,\n): Promise<DocModel[]> {\n const out: DocModel[] = [];\n for (const doc of docs) {\n let preferences: Map<string, boolean>;\n try {\n const refs = sets.refsFor(doc.path, doc.frontmatter);\n preferences = await sets.validator.graphOutputPreferences(doc.frontmatter, refs);\n } catch (e) {\n // Loudly, and for the whole run. The schema is what decides which fields\n // a published graph may carry; a graph built while it could not be read\n // is a graph nobody checked, and quietly building one is the failure\n // this keyword exists to prevent.\n throw new GraphError(\n `${doc.path}: cannot read which fields the graph may carry: ${errorMessage(e)}`,\n );\n }\n\n const suppressed = [...preferences]\n .filter(([, allowed]) => !allowed)\n .map(([key]) => key);\n if (suppressed.length === 0) {\n out.push(doc);\n continue;\n }\n\n const frontmatter: Record<string, unknown> = { ...doc.frontmatter };\n for (const key of suppressed) Reflect.deleteProperty(frontmatter, key);\n out.push({ ...doc, frontmatter });\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,WAAW,gBAAAA,eAAc,qBAAqB;AACvD,SAAS,SAAS,eAAe;;;ACYjC,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AASd,IAAM,oBAAoB;AAOjC,IAAM,gBAAgB;AAEtB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ACtB;AAAA,QACA,GAAI,KAAK,WAAW,SAAY,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO;AAAA,QAC/D,GAAI,KAAK,aAAa,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;AAAA,MACrD,CAAC;AAAA,IACH,SAAS,GAAG;AACV,eAAS;AAAA,QACP,+EAA0E,aAAa,CAAC,CAAC;AAAA,MAC3F;AAAA,IACF;AAAA,EACF;AAEA,QAAM,QAAQ,YAAY,MAAM;AAAA,IAC9B,SAAS,OAAO;AAAA,IAChB,QAAQ,OAAO,MAAM;AAAA;AAAA;AAAA,IAGrB,aAAa,gBAAI;AAAA,IACjB;AAAA,IACA,WAAW,OAAO,WAAW;AAAA,IAC7B;AAAA,EACF,CAAC;AACD,QAAM,UAAU,GAAG,GAAG,IAAI;AAC1B,QAAM,WAAW;AAAA,IACf,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,MAAM,YAAY,EAAE,EAAE,UAAU,OAAO,EAAE;AAAA,IACtE,cAAc,iBAAiB,QAAQ;AAAA,EACzC;AACA,QAAM,SAAS,WAAW,KAAK;AAC/B,QAAM,MAAM,MAAM;AAElB,SAAO,EAAE,SAAS,MAAM,KAAK,QAAQ,OAAO,MAAM,QAAQ,UAAU,UAAU,OAAO;AACvF;","names":["readFileSync","resolve","readFileSync"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lint/rules/paragraphs.ts","../src/lint/rules/code-blocks.ts","../src/lint/rules/tables.ts","../src/lint/rules/admonitions.ts","../src/lint/rules/images.ts","../src/lint/rules/blockquotes.ts","../src/lint/rules/definition-lists.ts","../src/lint/rules/sequence.ts","../src/lint/rules/elements.ts","../src/lint/rules/contains.ts","../src/lint/rules/lists.ts","../src/lint/rules/index.ts","../src/lint/rules/heading.ts","../src/lint/core/template.ts","../src/lint/core/match.ts"],"sourcesContent":["/**\n * `paragraphs:` - paragraph counts and a per-paragraph pattern.\n *\n * v1 took a cycling `patterns: string[]`; v2 simplifies to one `pattern`\n * every paragraph in the run must match, per proposal 0061's block-rule\n * vocabulary.\n */\n\nimport type { ContentNode, Finding, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n compilePattern,\n paragraphsOf,\n sectionContext,\n type ParagraphsRule,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the paragraphs a section holds directly. */\nexport function checkParagraphs(\n section: SectionNode,\n rule: ParagraphsRule | undefined,\n): Finding[] {\n return checkParagraphsIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks the paragraphs in any ordered content list.\n *\n * Used for a section's own content, for a list item's `children`, and for one\n * run of a `sequence`. `ctx` says where count findings land and what heading\n * they carry.\n */\nexport function checkParagraphsIn(\n content: ContentNode[],\n rule: ParagraphsRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const paragraphs = paragraphsOf(content);\n const findings = checkCount(\n paragraphs.length,\n rule,\n \"paragraph\",\n \"paragraphs_count_error\",\n ctx,\n );\n\n const pattern = rule.pattern;\n if (pattern) {\n const regex = compilePattern(pattern);\n paragraphs.forEach((paragraph, index) => {\n if (!regex.test(paragraph.text)) {\n findings.push({\n type: \"paragraphs_pattern_error\",\n heading: ctx.heading,\n message: `Paragraph ${index + 1} does not match /${pattern}/`,\n position: paragraph.position,\n severity: \"error\",\n });\n }\n });\n }\n\n return findings;\n}\n","/**\n * `codeBlocks:` - code block counts, the language(s) every block must\n * declare, and a `fenceInfo` filter over the info-string tail.\n *\n * `language` reports per offending block (every code block must declare one\n * of the accepted languages), the same way v1 reported nothing about\n * language at all - this is new in v2. `fenceInfo` has no message form of its\n * own in proposal 0061's table, so it narrows which blocks count toward\n * `min`/`max` instead, the way `elements.tag` does.\n */\n\nimport type { CodeNode, ContentNode, Finding, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n codeBlocksOf,\n compilePattern,\n sectionContext,\n type CodeBlocksRule,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the code blocks a section holds directly. */\nexport function checkCodeBlocks(\n section: SectionNode,\n rule: CodeBlocksRule | undefined,\n): Finding[] {\n return checkCodeBlocksIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks the code blocks in any ordered content list -\n * a section's content, a list item's `children`, or one run of a `sequence`.\n */\nexport function checkCodeBlocksIn(\n content: ContentNode[],\n rule: CodeBlocksRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const codeBlocks = codeBlocksOf(content);\n const counted = rule.fenceInfo\n ? codeBlocks.filter((block) => matchesFenceInfo(block, rule.fenceInfo as string))\n : codeBlocks;\n\n const findings = checkCount(\n counted.length,\n rule,\n \"code block\",\n \"code_blocks_count_error\",\n ctx,\n );\n\n if (rule.language) {\n findings.push(...checkLanguages(codeBlocks, rule.language, ctx));\n }\n\n return findings;\n}\n\nfunction matchesFenceInfo(block: CodeNode, pattern: string): boolean {\n return compilePattern(pattern).test(block.fenceInfo ?? \"\");\n}\n\n/** Every code block in the run must declare one of the accepted languages. */\nfunction checkLanguages(\n codeBlocks: CodeNode[],\n language: string | string[],\n ctx: RuleContext,\n): Finding[] {\n const languages = Array.isArray(language) ? language : [language];\n const only = languages[0];\n if (languages.length === 0 || only === undefined) return [];\n\n const label =\n languages.length === 1\n ? `\"${only}\"`\n : `one of ${languages.map((lang) => `\"${lang}\"`).join(\", \")}`;\n\n const findings: Finding[] = [];\n codeBlocks.forEach((block, index) => {\n if (block.language !== undefined && languages.includes(block.language)) return;\n\n const found = block.language ? `but found \"${block.language}\"` : \"but found no language\";\n findings.push({\n type: \"code_blocks_language_error\",\n heading: ctx.heading,\n message: `Expected code block ${index + 1} to declare ${label}, ${found}`,\n position: block.position,\n severity: \"error\",\n });\n });\n\n return findings;\n}\n","/**\n * `tables:` - table counts and the header cells every table must carry.\n *\n * `columns` is diagnostic, not a count filter: every table in the run counts\n * toward `min`/`max` whether or not its columns match, and a mismatch is\n * reported once per offending table (the same treatment `codeBlocks.language`\n * and `admonitions.variant` get, and unlike `codeBlocks.fenceInfo`, which has\n * no message form and narrows the count instead).\n */\n\nimport type { ContentNode, Finding, SectionNode, TableNode } from \"../types.js\";\nimport {\n checkCount,\n quoteList,\n sectionContext,\n tablesOf,\n type RuleContext,\n type TablesRule,\n} from \"./index.js\";\n\n/** Checks the tables a section holds directly. */\nexport function checkTables(\n section: SectionNode,\n rule: TablesRule | undefined,\n): Finding[] {\n return checkTablesIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the tables in any ordered content list. */\nexport function checkTablesIn(\n content: ContentNode[],\n rule: TablesRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const tables = tablesOf(content);\n const findings = checkCount(tables.length, rule, \"table\", \"tables_count_error\", ctx);\n\n if (rule.columns) {\n for (const table of tables) {\n const actual = headerCells(table);\n if (!sameColumns(actual, rule.columns)) {\n findings.push({\n type: \"tables_columns_error\",\n heading: ctx.heading,\n message: `Expected table columns ${quoteList(rule.columns)}, but found ${quoteList(actual)}`,\n position: table.position,\n severity: \"error\",\n });\n }\n }\n }\n\n return findings;\n}\n\nfunction headerCells(table: TableNode): string[] {\n const header = table.children.find((row) => row.header);\n return header ? header.children.map((cell) => cell.text) : [];\n}\n\nfunction sameColumns(actual: string[], expected: string[]): boolean {\n return actual.length === expected.length && actual.every((cell, index) => cell === expected[index]);\n}\n","/**\n * `admonitions:` - admonition counts and the variant every admonition must\n * carry.\n *\n * `variant` is diagnostic, not a count filter, for the same reason\n * `tables.columns` is: every admonition counts toward `min`/`max` regardless,\n * and a mismatch is reported once per offending admonition.\n */\n\nimport type { AdmonitionNode, ContentNode, Finding, SectionNode } from \"../types.js\";\nimport {\n admonitionsOf,\n checkCount,\n sectionContext,\n type AdmonitionsRule,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the admonitions a section holds directly. */\nexport function checkAdmonitions(\n section: SectionNode,\n rule: AdmonitionsRule | undefined,\n): Finding[] {\n return checkAdmonitionsIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the admonitions in any ordered content list. */\nexport function checkAdmonitionsIn(\n content: ContentNode[],\n rule: AdmonitionsRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const admonitions = admonitionsOf(content);\n const findings = checkCount(\n admonitions.length,\n rule,\n \"admonition\",\n \"admonitions_count_error\",\n ctx,\n );\n\n if (rule.variant) {\n findings.push(...checkVariant(admonitions, rule.variant, ctx));\n }\n\n return findings;\n}\n\nfunction checkVariant(\n admonitions: AdmonitionNode[],\n variant: NonNullable<AdmonitionsRule[\"variant\"]>,\n ctx: RuleContext,\n): Finding[] {\n const findings: Finding[] = [];\n for (const admonition of admonitions) {\n if (admonition.variant !== variant) {\n // A format may name a flavor this vocabulary does not have, or none at\n // all: reStructuredText's `hint`, a bare HTML `<aside>`. The node then\n // carries no variant, and saying \"found a undefined\" would be worse\n // than saying what is true.\n const found = admonition.variant\n ? `but found a ${admonition.variant}`\n : \"but found one with no type\";\n findings.push({\n type: \"admonitions_variant_error\",\n heading: ctx.heading,\n message: `Expected a ${variant} admonition, ${found}`,\n position: admonition.position,\n severity: \"error\",\n });\n }\n }\n return findings;\n}\n","/**\n * `images:` - how many images, filtered by `url`, `alt`, and `attributes`.\n *\n * All three narrow the counted set rather than reporting their own finding -\n * proposal 0061's message table gives `images` only `images_count_error`, no\n * per-field diagnostic the way `elements.attributes` gets one. `attributes`\n * in particular can never match: `ImageNode` carries no `attributes` of its\n * own (the node model gave that field to `element` only), so any non-empty\n * `attributes` requirement here excludes every image, same as an image whose\n * `url` or `alt` does not match.\n */\n\nimport type { ContentNode, Finding, ImageNode, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n imagesOf,\n sectionContext,\n type ImagesRule,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the images a section holds directly. */\nexport function checkImages(\n section: SectionNode,\n rule: ImagesRule | undefined,\n): Finding[] {\n return checkImagesIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the images in any ordered content list. */\nexport function checkImagesIn(\n content: ContentNode[],\n rule: ImagesRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const matching = imagesOf(content).filter((image) => matches(image, rule));\n return checkCount(matching.length, rule, \"image\", \"images_count_error\", ctx);\n}\n\nfunction matches(image: ImageNode, rule: ImagesRule): boolean {\n if (rule.url !== undefined && image.url !== rule.url) return false;\n if (rule.alt !== undefined && image.alt !== rule.alt) return false;\n if (rule.attributes && Object.keys(rule.attributes).length > 0) return false;\n return true;\n}\n","/** `blockquotes:` - a plain count, the schema's `counted` shape. */\n\nimport type { ContentNode, Finding, SectionNode } from \"../types.js\";\nimport { blockquotesOf, checkCount, sectionContext, type Occurrences, type RuleContext } from \"./index.js\";\n\n/** Checks the blockquotes a section holds directly. */\nexport function checkBlockquotes(\n section: SectionNode,\n rule: Occurrences | undefined,\n): Finding[] {\n return checkBlockquotesIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the blockquotes in any ordered content list. */\nexport function checkBlockquotesIn(\n content: ContentNode[],\n rule: Occurrences | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n return checkCount(blockquotesOf(content).length, rule, \"blockquote\", \"blockquotes_count_error\", ctx);\n}\n","/** `definitionLists:` - a plain count, the schema's `counted` shape. */\n\nimport type { ContentNode, Finding, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n definitionListsOf,\n sectionContext,\n type Occurrences,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the definition lists a section holds directly. */\nexport function checkDefinitionLists(\n section: SectionNode,\n rule: Occurrences | undefined,\n): Finding[] {\n return checkDefinitionListsIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the definition lists in any ordered content list. */\nexport function checkDefinitionListsIn(\n content: ContentNode[],\n rule: Occurrences | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n return checkCount(\n definitionListsOf(content).length,\n rule,\n \"definition list\",\n \"definition_lists_count_error\",\n ctx,\n );\n}\n","/**\n * `sequence:` - the ordered runs of content a section (or an element's or\n * list item's own content) must hold.\n *\n * Content arrives flat and in document order, so consecutive nodes of the\n * same kind are first grouped into runs: `[p, p, code, table]` becomes three\n * runs (paragraph, codeBlock, table). Those runs are then matched\n * positionally against the template's sequence, and each run is handed to\n * `checkContainsIn` for its one set key.\n *\n * v1 reported a length mismatch and an order mismatch as two finding types,\n * `sequence_length_error` and `sequence_order_error`. v2 collapses both into\n * one `content_order_error`: the message states the full expected and actual\n * kind lists, which communicates a length difference as plainly as an order\n * one, and a template widening from three kinds to nine does not need a\n * matching widening of finding types. The bail-on-mismatch behavior stays -\n * once the runs are the wrong shape, per-run findings are noise about\n * content the author has not arranged yet.\n */\n\nimport type { ContentKind, ContentNode, Finding, Position, SectionNode } from \"../types.js\";\nimport { BLOCK_KINDS, sectionContext, type BlockKind, type BlockRule, type RuleContext } from \"./index.js\";\nimport { checkContainsIn } from \"./contains.js\";\n\n/** A maximal stretch of consecutive content nodes sharing one kind. */\nexport interface ContentRun {\n kind: ContentKind;\n nodes: ContentNode[];\n /** First node's start through last node's end. */\n position: Position;\n}\n\n/** Groups consecutive same-kind nodes into runs, preserving document order. */\nexport function groupRuns(content: ContentNode[]): ContentRun[] {\n const runs: ContentRun[] = [];\n\n for (const node of content) {\n const current = runs[runs.length - 1];\n if (current && current.kind === node.kind) {\n current.nodes.push(node);\n current.position = {\n start: current.position.start,\n end: node.position.end,\n };\n } else {\n runs.push({\n kind: node.kind,\n nodes: [node],\n position: { start: node.position.start, end: node.position.end },\n });\n }\n }\n\n return runs;\n}\n\n/** The content kind a block-rule key names, e.g. `codeBlocks` -> `codeBlock`. */\nconst KIND_OF_BLOCK: Record<BlockKind, ContentKind> = {\n paragraphs: \"paragraph\",\n codeBlocks: \"codeBlock\",\n lists: \"list\",\n tables: \"table\",\n admonitions: \"admonition\",\n images: \"image\",\n blockquotes: \"blockquote\",\n definitionLists: \"definitionList\",\n elements: \"element\",\n};\n\n/** The short noun a `content_order_error` message uses for one kind. */\nfunction sequenceLabel(kind: ContentKind): string {\n switch (kind) {\n case \"paragraph\":\n return \"paragraph\";\n case \"codeBlock\":\n return \"code\";\n case \"list\":\n return \"list\";\n case \"table\":\n return \"table\";\n case \"admonition\":\n return \"admonition\";\n case \"image\":\n return \"image\";\n case \"blockquote\":\n return \"blockquote\";\n case \"definitionList\":\n return \"definition list\";\n case \"element\":\n return \"element\";\n default:\n // tableRow/tableCell/definitionItem/listItem never appear as a top-level\n // ContentNode.kind; groupRuns only ever sees the nine kinds above.\n return kind;\n }\n}\n\n/** The one key set on a `sequence:` entry, or `null` for a malformed one. */\nfunction keyOf(entry: BlockRule): BlockKind | null {\n for (const kind of BLOCK_KINDS) {\n if (entry[kind] !== undefined) return kind;\n }\n return null;\n}\n\n/** Checks a section's own content against a `sequence:` rule. */\nexport function checkSequence(\n section: SectionNode,\n rule: BlockRule[] | undefined,\n): Finding[] {\n return checkSequenceIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks any ordered content list against a `sequence:`\n * rule - a section's content, a list item's `children`, or an element's own\n * `children`.\n */\nexport function checkSequenceIn(\n content: ContentNode[],\n rule: BlockRule[] | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const runs = groupRuns(content);\n const expectedKinds = rule.map((entry) => {\n const key = keyOf(entry);\n return key ? KIND_OF_BLOCK[key] : null;\n });\n const actualKinds = runs.map((run) => run.kind);\n\n const matches =\n expectedKinds.length === actualKinds.length &&\n expectedKinds.every((kind, index) => kind === actualKinds[index]);\n\n if (!matches) {\n const expected = expectedKinds.map((kind) => (kind ? sequenceLabel(kind) : \"?\"));\n const found = actualKinds.length > 0 ? actualKinds.map(sequenceLabel) : [\"nothing\"];\n return [\n {\n type: \"content_order_error\",\n heading: ctx.heading,\n message: `Expected ${expected.join(\" then \")}, but found ${found.join(\" then \")}`,\n position: ctx.position,\n severity: \"error\",\n },\n ];\n }\n\n const findings: Finding[] = [];\n runs.forEach((run, index) => {\n const entry = rule[index];\n if (!entry) return;\n const runCtx: RuleContext = { heading: ctx.heading, position: run.position };\n // A run holds one kind, so `checkContainsIn` sees exactly the nodes in\n // this stretch, not the section's other content of the same kind - the\n // entry has only that one key set, so every other dispatch is a no-op.\n findings.push(...checkContainsIn(run.nodes, entry, runCtx));\n });\n\n return findings;\n}\n","/**\n * `elements:` - named-wrapper counts, filtered and labeled by `tag`, the\n * literal `attributes` a matched element must carry, and what it holds via\n * `sequence` | `contains` recursing into the element's own `children` -\n * never the enclosing section's, per proposal 0065 stress test 4.\n *\n * `tag` narrows the counted set the way `codeBlocks.fenceInfo` and\n * `images.url`/`alt` do, and also names the noun in count messages: `elements:\n * { tag: \"Steps\", min: 1 }` reports `Expected at least 1 \"Steps\" element, but\n * found 0`, not the generic `\"element\"`. `attributes` is diagnostic instead,\n * checked per matched element and reported once per offending attribute.\n */\n\nimport type { ContentNode, ElementNode, Finding, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n elementsOf,\n sectionContext,\n type AttributesRule,\n type ElementsRule,\n type RuleContext,\n} from \"./index.js\";\nimport { checkContainsIn } from \"./contains.js\";\nimport { checkSequenceIn } from \"./sequence.js\";\n\n/** Checks the elements a section holds directly. */\nexport function checkElements(\n section: SectionNode,\n rule: ElementsRule | undefined,\n): Finding[] {\n return checkElementsIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the elements in any ordered content list. */\nexport function checkElementsIn(\n content: ContentNode[],\n rule: ElementsRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const tags = rule.tag === undefined ? undefined : Array.isArray(rule.tag) ? rule.tag : [rule.tag];\n const matching = tags ? elementsOf(content).filter((element) => tags.includes(element.name)) : elementsOf(content);\n\n // \"or\", not a comma list: the count applies to one combined label, so\n // `\"Note\", \"Tip\" element` reads as two nouns with a singular verb where\n // `\"Note\" or \"Tip\" element` reads as the one thing being counted.\n const noun = tags\n ? `${tags.map((tag) => `\"${tag}\"`).join(\" or \")} element`\n : \"element\";\n const findings = checkCount(matching.length, rule, noun, \"elements_count_error\", ctx);\n\n if (rule.attributes) {\n for (const element of matching) {\n findings.push(...checkAttributes(element, rule.attributes, ctx));\n }\n }\n\n // Both, unconditionally, as `validator.ts` runs them against a section. Each\n // no-ops on an absent rule, and the schema refuses a rule that writes both\n // (`oneOfSequenceOrContains`), so only one can ever fire. Writing it as a\n // choice made this file's behaviour depend on a constraint declared in\n // another, which reads like a silent drop whether or not it is one.\n if (rule.sequence || rule.contains) {\n for (const element of matching) {\n const elementCtx: RuleContext = { heading: ctx.heading, position: element.position };\n findings.push(...checkSequenceIn(element.children, rule.sequence, elementCtx));\n findings.push(...checkContainsIn(element.children, rule.contains, elementCtx));\n }\n }\n\n return findings;\n}\n\n/**\n * `true` requires presence (any value); `false` requires absence; a string\n * is the required literal value. An element's own `attributes` map values a\n * dynamic (JSX-expression) attribute as `true` too, since its literal value\n * cannot be known statically - `checkOne` tells that apart from \"absent\" by\n * checking membership before comparing values.\n */\nfunction checkAttributes(\n element: ElementNode,\n rule: AttributesRule,\n ctx: RuleContext,\n): Finding[] {\n const findings: Finding[] = [];\n for (const [key, expected] of Object.entries(rule)) {\n const finding = checkOne(element, key, expected, ctx);\n if (finding) findings.push(finding);\n }\n return findings;\n}\n\nfunction checkOne(\n element: ElementNode,\n key: string,\n expected: string | boolean,\n ctx: RuleContext,\n): Finding | null {\n const attributes = element.attributes ?? {};\n const present = key in attributes;\n const actual = attributes[key];\n\n const fail = (want: string, detail: string): Finding => ({\n type: \"elements_attribute_error\",\n heading: ctx.heading,\n message: `Expected the \"${element.name}\" element ${want}, but ${detail}`,\n position: element.position,\n severity: \"error\",\n });\n\n if (expected === false) {\n if (!present) return null;\n const found = actual === true ? `an expression` : `${key}=\"${String(actual)}\"`;\n return fail(`not to carry ${key}`, `found ${found}`);\n }\n\n if (!present) return fail(attributeWant(key, expected), `it carries no ${key}`);\n if (expected === true) return null;\n if (actual === true) return fail(attributeWant(key, expected), `its ${key} is an expression`);\n if (actual !== expected) return fail(attributeWant(key, expected), `found ${key}=\"${String(actual)}\"`);\n return null;\n}\n\nfunction attributeWant(key: string, expected: string | true): string {\n return expected === true ? `to carry ${key}` : `to carry ${key}=\"${expected}\"`;\n}\n","/**\n * `contains:` - what a section (or an element's or list item's own content)\n * holds, in any order. Each listed kind dispatches to that kind's own check.\n */\n\nimport type { ContentNode, Finding, SectionNode } from \"../types.js\";\nimport { BLOCK_KINDS, sectionContext, type BlockRule, type RuleContext } from \"./index.js\";\nimport { checkParagraphsIn } from \"./paragraphs.js\";\nimport { checkCodeBlocksIn } from \"./code-blocks.js\";\nimport { checkListsIn } from \"./lists.js\";\nimport { checkTablesIn } from \"./tables.js\";\nimport { checkAdmonitionsIn } from \"./admonitions.js\";\nimport { checkImagesIn } from \"./images.js\";\nimport { checkBlockquotesIn } from \"./blockquotes.js\";\nimport { checkDefinitionListsIn } from \"./definition-lists.js\";\nimport { checkElementsIn } from \"./elements.js\";\n\n/** Checks a section's own content against a `contains:` rule. */\nexport function checkContains(\n section: SectionNode,\n rule: BlockRule | undefined,\n): Finding[] {\n return checkContainsIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks any ordered content list against a `contains:`\n * rule - a section's content, a list item's `children`, an element's own\n * `children`, or one run of a `sequence` (which carries exactly one key).\n *\n * `BLOCK_KINDS` drives the dispatch so a ninth kind is one line here, not a\n * rewritten `if` chain.\n */\nexport function checkContainsIn(\n content: ContentNode[],\n rule: BlockRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const findings: Finding[] = [];\n for (const kind of BLOCK_KINDS) {\n switch (kind) {\n case \"paragraphs\":\n findings.push(...checkParagraphsIn(content, rule.paragraphs, ctx));\n break;\n case \"codeBlocks\":\n findings.push(...checkCodeBlocksIn(content, rule.codeBlocks, ctx));\n break;\n case \"lists\":\n findings.push(...checkListsIn(content, rule.lists, ctx));\n break;\n case \"tables\":\n findings.push(...checkTablesIn(content, rule.tables, ctx));\n break;\n case \"admonitions\":\n findings.push(...checkAdmonitionsIn(content, rule.admonitions, ctx));\n break;\n case \"images\":\n findings.push(...checkImagesIn(content, rule.images, ctx));\n break;\n case \"blockquotes\":\n findings.push(...checkBlockquotesIn(content, rule.blockquotes, ctx));\n break;\n case \"definitionLists\":\n findings.push(...checkDefinitionListsIn(content, rule.definitionLists, ctx));\n break;\n case \"elements\":\n findings.push(...checkElementsIn(content, rule.elements, ctx));\n break;\n }\n }\n return findings;\n}\n","/**\n * `lists:` - list counts, whether they are ordered, item counts, and what\n * each item holds.\n *\n * v1's `items` took its own flat `paragraphs`/`code_blocks`/`lists` keys. v2\n * replaces that split with the same `sequence` | `contains` every other\n * container uses (proposal 0061), so item-level rules recurse through the\n * same two functions as everything else instead of a third, list-shaped one.\n */\n\nimport type { ContentNode, Finding, ListNode, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n listsOf,\n sectionContext,\n type ListsRule,\n type RuleContext,\n} from \"./index.js\";\nimport { checkContainsIn } from \"./contains.js\";\nimport { checkSequenceIn } from \"./sequence.js\";\n\n/** Checks the lists a section holds directly. */\nexport function checkLists(\n section: SectionNode,\n rule: ListsRule | undefined,\n): Finding[] {\n return checkListsIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks the lists in any ordered content list.\n *\n * `rule.items` recurses - a list item's children are a `ContentNode[]` like\n * any other, so item-level `sequence`/`contains` rules run through the same\n * functions, arbitrarily deep.\n */\nexport function checkListsIn(\n content: ContentNode[],\n rule: ListsRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const lists = listsOf(content);\n const findings = checkCount(lists.length, rule, \"list\", \"lists_count_error\", ctx);\n\n if (rule.ordered !== undefined) {\n findings.push(...checkOrdered(lists, rule.ordered, ctx));\n }\n\n const items = rule.items;\n if (!items) return findings;\n\n findings.push(...checkItemCounts(lists, items, ctx));\n\n if (!items.sequence && !items.contains) return findings;\n\n for (const list of lists) {\n for (const item of list.items) {\n const itemCtx: RuleContext = { heading: ctx.heading, position: item.position };\n if (items.sequence) {\n findings.push(...checkSequenceIn(item.children, items.sequence, itemCtx));\n } else if (items.contains) {\n findings.push(...checkContainsIn(item.children, items.contains, itemCtx));\n }\n }\n }\n\n return findings;\n}\n\nfunction checkOrdered(lists: ListNode[], ordered: boolean, ctx: RuleContext): Finding[] {\n const findings: Finding[] = [];\n for (const list of lists) {\n if (list.ordered !== ordered) {\n findings.push({\n type: \"lists_ordered_error\",\n heading: ctx.heading,\n message: ordered\n ? \"Expected a numbered list, but found a bulleted list\"\n : \"Expected a bulleted list, but found a numbered list\",\n position: list.position,\n severity: \"error\",\n });\n }\n }\n return findings;\n}\n\n/**\n * Item counts report once per bound, anchored at the first list that breaks\n * it. `min` defaults to 1 like every other count, which is a harmless no-op\n * here: a list always has at least one item structurally, so only an\n * explicit `min` above 1 (or a rule that also forbids via `max`) ever fires.\n */\nfunction checkItemCounts(\n lists: ListNode[],\n items: { min?: number; max?: number },\n ctx: RuleContext,\n): Finding[] {\n const findings: Finding[] = [];\n const min = items.min ?? (items.max === 0 ? 0 : 1);\n const max = items.max ?? null;\n\n if (max !== null) {\n const offender = lists.find((list) => list.items.length > max);\n if (offender) {\n findings.push({\n type: \"lists_items_count_error\",\n heading: ctx.heading,\n message: `Expected at most ${max} items in a list, but found ${offender.items.length}`,\n position: offender.position,\n severity: \"error\",\n });\n }\n }\n\n if (min > 0) {\n const offender = lists.find((list) => list.items.length < min);\n if (offender) {\n findings.push({\n type: \"lists_items_count_error\",\n heading: ctx.heading,\n message: `Expected at least ${min} items in a list, but found ${offender.items.length}`,\n position: offender.position,\n severity: \"error\",\n });\n }\n }\n\n return findings;\n}\n","/**\n * Content rules: the checks that run against a single section's own content.\n *\n * A rule is a pure, synchronous function of one `SectionNode` (or one ordered\n * `ContentNode[]` slice of it) and its slice of a template, returning\n * `Finding[]`. Rules never touch a parser AST and never await anything.\n *\n * The content model is format-neutral and flat: a section carries one ordered\n * `children: ContentNode[]`, and the per-kind \"buckets\" every rule needs are\n * queries over it (`paragraphsOf`, `codeBlocksOf`, ...) rather than separately\n * maintained arrays. The same queries work unchanged on a list item's\n * `children` or an element's own `children`, which is why `lists.items` and\n * `elements` can recurse.\n *\n * This module is deliberately independent of `../core/template.ts`. That file\n * is the DSL the v2 loader and schema agree on; this one is the DSL the rules\n * are written against. Where the two diverge - see `CodeBlocksRule.language`\n * and `ElementsRule.tag` below, which this chunk's task widened to `string |\n * string[]` while `core/template.ts` still types them as a bare `string` -\n * the validator chunk that wires the two together needs to reconcile it. That\n * mirrors the v1 shape of this file, whose own rule interfaces mirrored\n * `template-v1.ts` rather than importing it.\n */\n\nimport { LintError } from \"../types.js\";\nimport type {\n AdmonitionNode,\n BlockquoteNode,\n CodeNode,\n ContentNode,\n DefinitionListNode,\n ElementNode,\n Finding,\n ImageNode,\n ListNode,\n ParagraphNode,\n Position,\n SectionNode,\n TableNode,\n} from \"../types.js\";\n\n/* -------------------------------------------------------------------------- *\n * Template rule shapes\n *\n * These mirror the v2 template DSL's block-rule vocabulary (proposal 0065 /\n * 0061): a block rule is keyed by a plural content kind and carries `min`\n * (default 1), `max` (absent unbounded, `0` forbids), plus per-kind keys.\n * -------------------------------------------------------------------------- */\n\n/** Shared by every counted rule: how many of the thing there must be. */\nexport interface Occurrences {\n /** Fewest occurrences. Absent means one - see `checkCount` for the one\n * exception, where an explicit `max: 0` with no `min` defaults `min` to 0\n * too, so \"forbid this kind\" is satisfiable by finding none of it. */\n min?: number;\n /** Most occurrences. Absent is unbounded; `0` forbids. */\n max?: number;\n}\n\n/**\n * What a rule's `heading` may say.\n *\n * `undefined` (the key absent) matches any heading or none. A string is exact\n * text, a list is one-of, `{ pattern }` is an unanchored regular expression,\n * and `false` means the section has no heading of its own.\n */\nexport type HeadingRule = string | string[] | { pattern: string } | false;\n\n/** Attributes a node must carry. `true` requires presence; `false` requires absence. */\nexport type AttributesRule = Record<string, string | boolean>;\n\n/** `paragraphs:` - how many paragraphs, and what they must look like. */\nexport interface ParagraphsRule extends Occurrences {\n /** Unanchored regular expression every paragraph in the run must match. */\n pattern?: string;\n}\n\n/** `codeBlocks:` - how many code blocks, and how they are tagged. */\nexport interface CodeBlocksRule extends Occurrences {\n /** Language(s) every code block must declare one of. */\n language?: string | string[];\n /** Info-string tail after the language; narrows which blocks count. */\n fenceInfo?: string;\n}\n\n/** `lists.items:` - how many items per list, and what each item holds. */\nexport interface ListItemsRule extends Occurrences {\n sequence?: BlockRule[];\n contains?: BlockRule;\n}\n\n/** `lists:` - how many lists, whether they are ordered, and item rules. */\nexport interface ListsRule extends Occurrences {\n ordered?: boolean;\n items?: ListItemsRule;\n}\n\n/** `tables:` - how many tables, and the header cells in order. */\nexport interface TablesRule extends Occurrences {\n columns?: string[];\n}\n\n/** `admonitions:` - how many, and of which variant. */\nexport interface AdmonitionsRule extends Occurrences {\n variant?: \"note\" | \"tip\" | \"important\" | \"caution\" | \"warning\" | \"danger\";\n}\n\n/** `images:` - how many, and what they point at. */\nexport interface ImagesRule extends Occurrences {\n /** Narrows which images count: only images at this url are counted. */\n url?: string;\n /** Narrows which images count: only images with this alt text are counted. */\n alt?: string;\n /**\n * Narrows which images count. `ImageNode` carries no `attributes` of its\n * own (the node model gave that field to `element` only), so any non-empty\n * requirement here matches no image - see `images.ts`.\n */\n attributes?: AttributesRule;\n}\n\n/** `elements:` - how many named wrappers, and what they hold. */\nexport interface ElementsRule extends Occurrences {\n /** Narrows which elements count, and names the noun in count messages. */\n tag?: string | string[];\n attributes?: AttributesRule;\n sequence?: BlockRule[];\n contains?: BlockRule;\n}\n\n/**\n * What a section (or an element's or list item's own content) holds, keyed by\n * content kind.\n *\n * One of these is a whole `contains:`. As an entry of `sequence:` exactly one\n * key is set, and it names the kind expected at that position.\n */\nexport interface BlockRule {\n paragraphs?: ParagraphsRule;\n codeBlocks?: CodeBlocksRule;\n lists?: ListsRule;\n tables?: TablesRule;\n admonitions?: AdmonitionsRule;\n images?: ImagesRule;\n blockquotes?: Occurrences;\n definitionLists?: Occurrences;\n elements?: ElementsRule;\n}\n\n/** `sequence:` - the ordered runs of content a section must contain. */\nexport type SequenceRule = BlockRule[];\n\n/** One block-rule key: a content kind, spelled plural. */\nexport type BlockKind = keyof BlockRule;\n\n/** Every block-rule key, in the order the schema declares them. */\nexport const BLOCK_KINDS: readonly BlockKind[] = [\n \"paragraphs\",\n \"codeBlocks\",\n \"lists\",\n \"tables\",\n \"admonitions\",\n \"images\",\n \"blockquotes\",\n \"definitionLists\",\n \"elements\",\n];\n\n/* -------------------------------------------------------------------------- *\n * Finding anchoring\n * -------------------------------------------------------------------------- */\n\n/**\n * Where findings land when a rule runs over content that is not a whole\n * section - a list item's `children`, an element's `children`, or one run\n * inside a `sequence`.\n */\nexport interface RuleContext {\n /** Stamped onto every finding as `Finding.heading`. */\n heading: string | null;\n /** Used when the offending thing is a count rather than a single node. */\n position: Position;\n}\n\n/**\n * The context for rules run against a section's own content.\n *\n * The heading is normalised to `null` when there is none, as `match.ts` and\n * `validator.ts` both do. A headless section carries `title: \"\"`, and the JSON\n * reporter's `heading` is a wire key `manni docevals` parses rather than\n * validates, so `\"\"` and `null` would reach it as two spellings of one fact.\n */\nexport function sectionContext(section: SectionNode): RuleContext {\n return { heading: section.title || null, position: section.position };\n}\n\n/* -------------------------------------------------------------------------- *\n * Content queries\n *\n * The single place the flat content array is bucketed by kind. Rules call\n * these; they never filter inline.\n * -------------------------------------------------------------------------- */\n\nexport function paragraphsOf(content: ContentNode[]): ParagraphNode[] {\n return content.filter((node): node is ParagraphNode => node.kind === \"paragraph\");\n}\n\nexport function codeBlocksOf(content: ContentNode[]): CodeNode[] {\n return content.filter((node): node is CodeNode => node.kind === \"codeBlock\");\n}\n\nexport function listsOf(content: ContentNode[]): ListNode[] {\n return content.filter((node): node is ListNode => node.kind === \"list\");\n}\n\nexport function tablesOf(content: ContentNode[]): TableNode[] {\n return content.filter((node): node is TableNode => node.kind === \"table\");\n}\n\nexport function admonitionsOf(content: ContentNode[]): AdmonitionNode[] {\n return content.filter((node): node is AdmonitionNode => node.kind === \"admonition\");\n}\n\nexport function imagesOf(content: ContentNode[]): ImageNode[] {\n return content.filter((node): node is ImageNode => node.kind === \"image\");\n}\n\nexport function blockquotesOf(content: ContentNode[]): BlockquoteNode[] {\n return content.filter((node): node is BlockquoteNode => node.kind === \"blockquote\");\n}\n\nexport function definitionListsOf(content: ContentNode[]): DefinitionListNode[] {\n return content.filter((node): node is DefinitionListNode => node.kind === \"definitionList\");\n}\n\nexport function elementsOf(content: ContentNode[]): ElementNode[] {\n return content.filter((node): node is ElementNode => node.kind === \"element\");\n}\n\n/* -------------------------------------------------------------------------- *\n * Shared message helpers\n * -------------------------------------------------------------------------- */\n\n/** `\"paragraph\"`/1 -> `\"paragraph\"`; `\"paragraph\"`/2 -> `\"paragraphs\"`. */\nfunction plural(noun: string, count: number): string {\n return count === 1 ? noun : `${noun}s`;\n}\n\n/** `[\"Field\", \"Type\"]` -> `\"Field\", \"Type\"`. */\nexport function quoteList(items: string[]): string {\n return items.map((item) => `\"${item}\"`).join(\", \");\n}\n\n/**\n * The count half of every block rule: `min` (default 1) and `max` (default\n * unbounded), against one already-computed count.\n *\n * One default is not the naive `rule.min ?? 1`. The schema documents `max: 0`\n * as how a template forbids a kind outright, and that has to be satisfiable\n * by a section that truly has none of it. A blanket \"min defaults to 1\" would\n * make `{ max: 0 }` alone unsatisfiable - it would demand at least one and\n * permit at most zero. So `min` defaults to 0 exactly when `max` is written\n * as `0` and `min` itself is not, and to 1 otherwise. `min: 0` and `max: 0`\n * are each still tested explicitly; this is what makes both mean something\n * at once.\n */\nexport function checkCount(\n count: number,\n rule: Occurrences,\n noun: string,\n type: string,\n ctx: RuleContext,\n): Finding[] {\n const findings: Finding[] = [];\n const min = rule.min ?? (rule.max === 0 ? 0 : 1);\n const max = rule.max ?? null;\n\n if (count < min) {\n findings.push({\n type,\n heading: ctx.heading,\n message: `Expected at least ${min} ${plural(noun, min)}, but found ${count}`,\n position: ctx.position,\n severity: \"error\",\n });\n }\n\n if (max !== null && count > max) {\n findings.push({\n type,\n heading: ctx.heading,\n message: `Expected at most ${max} ${plural(noun, max)}, but found ${count}`,\n position: ctx.position,\n severity: \"error\",\n });\n }\n\n return findings;\n}\n\n/* -------------------------------------------------------------------------- *\n * The rules\n * -------------------------------------------------------------------------- */\n\nexport { checkHeading } from \"./heading.js\";\nexport { checkParagraphs, checkParagraphsIn } from \"./paragraphs.js\";\nexport { checkCodeBlocks, checkCodeBlocksIn } from \"./code-blocks.js\";\nexport { checkLists, checkListsIn } from \"./lists.js\";\nexport { checkTables, checkTablesIn } from \"./tables.js\";\nexport { checkAdmonitions, checkAdmonitionsIn } from \"./admonitions.js\";\nexport { checkImages, checkImagesIn } from \"./images.js\";\nexport { checkBlockquotes, checkBlockquotesIn } from \"./blockquotes.js\";\nexport { checkDefinitionLists, checkDefinitionListsIn } from \"./definition-lists.js\";\nexport { checkElements, checkElementsIn } from \"./elements.js\";\nexport { checkContains, checkContainsIn } from \"./contains.js\";\nexport { checkSequence, checkSequenceIn, groupRuns } from \"./sequence.js\";\nexport type { ContentRun } from \"./sequence.js\";\n\n/**\n * Compile an author-supplied pattern, or say which one is broken.\n *\n * A pattern comes from a template, so a bad one is a broken template rather\n * than a lint finding - and the raw `SyntaxError` names the regex but not the\n * template, the section, or the file. Every caller must route the result\n * through the same containment a template load failure gets, or one bad\n * pattern takes the whole run down with it.\n *\n * ## A pattern that compiles can still hang\n *\n * This checks syntax, and syntax is all it checks. `(a+)+b$` is a valid regex\n * that backtracks catastrophically against a heading it cannot match, and\n * `loadTemplateFile` will fetch a template over HTTP, so an untrusted template\n * can supply one.\n *\n * Capping the input length is not the answer, however cheap it looks. The\n * blow-up is exponential in the length of the input, so a cap generous enough\n * for a real heading is already far past the point of hanging: `(a+)+b$` needs\n * on the order of 2^n steps, and n of 64 is out of reach. Any cap that\n * actually bounded the work would reject headings people legitimately write.\n *\n * The boundary that does hold is the one proposal 0015 drew for schemas: a\n * template from a URL is a trust decision made when the URL is configured, not\n * something this function can take back. Validating patterns for backtracking\n * safety at load time is the fix if that decision is ever delegated, and it is\n * a dependency and a proposal rather than a line here.\n */\nconst compiled = new Map<string, RegExp>();\n\nexport function compilePattern(pattern: string): RegExp {\n // Memoized because heading matching is quadratic by nature: the matcher asks\n // every rule about every section, so a template with ten pattern rules against\n // a twenty-section page compiled the same ten regexes two hundred times.\n //\n // Safe to share one instance: these are built with no flags, and `lastIndex`\n // is only carried between calls by `g` and `y`. Adding either to this\n // construction would make the cached regex stateful across sections.\n const hit = compiled.get(pattern);\n if (hit) return hit;\n try {\n const regex = new RegExp(pattern);\n compiled.set(pattern, regex);\n return regex;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new LintError(`Invalid pattern \"${pattern}\": ${reason}`);\n }\n}\n\n/** Drop the compiled-pattern memo. See `clearCaches` in the package root. */\nexport function clearPatternCache(): void {\n compiled.clear();\n}\n","/**\n * `heading:` - the section's title against a string, a one-of list, a\n * `{ pattern }`, or `false` for \"no heading of its own\".\n *\n * One finding type, `heading_error`, covers all four forms; the message\n * names which form failed. v1 split this into `heading_const_error` and\n * `heading_pattern_error`, each of which could fire independently for the\n * same section. v2's `heading:` is one value, so it fires at most once.\n */\n\nimport type { Finding, SectionNode } from \"../types.js\";\nimport { compilePattern, type HeadingRule } from \"./index.js\";\n\n/**\n * A section's own title, in the vocabulary `heading:` speaks: `null` when the\n * section has no heading of its own (the implicit lead section), the title\n * text otherwise.\n *\n * `SectionNode.title` is `\"\"` rather than `null` for that section - `null` is\n * reserved for \"no heading\" so `headingMatches`-style checks elsewhere don't\n * have to special-case the empty string. This bridges the two.\n */\nfunction ownTitle(section: SectionNode): string | null {\n return section.titlePosition === null ? null : section.title;\n}\n\n/** Checks a section's title against the template's `heading:` rule. */\nexport function checkHeading(\n section: SectionNode,\n rule: HeadingRule | undefined,\n): Finding[] {\n if (rule === undefined) return [];\n\n // The heading itself is the offending node when it has a span of its own;\n // the implicit lead section has none, so fall back to the section.\n const position = section.titlePosition ?? section.position;\n const title = ownTitle(section);\n const found = title === null ? \"no heading\" : `\"${title}\"`;\n\n const fail = (message: string): Finding[] => [\n {\n type: \"heading_error\",\n // `|| null`, as `sectionContext` and `match.ts`'s `anchor` both do. A\n // headless section's title is `\"\"`, and the JSON reporter's `heading` is\n // a wire key `manni docevals` parses rather than validates, so two\n // spellings of \"no heading\" would reach it as two different facts.\n heading: section.title || null,\n message,\n position,\n severity: \"error\",\n },\n ];\n\n if (rule === false) {\n return title === null ? [] : fail(`Expected no heading of its own, but found ${found}`);\n }\n\n if (typeof rule === \"string\") {\n return title === rule ? [] : fail(`Expected title \"${rule}\", but found ${found}`);\n }\n\n if (Array.isArray(rule)) {\n if (title !== null && rule.includes(title)) return [];\n return fail(`Expected one of ${rule.map((option) => `\"${option}\"`).join(\", \")}, but found ${found}`);\n }\n\n // { pattern }\n if (title !== null && compilePattern(rule.pattern).test(title)) return [];\n return fail(`Expected title matching /${rule.pattern}/, but found ${found}`);\n}\n","/**\n * The template DSL, as TypeScript. `schemas/lint/template.json` is the\n * authority that user input is validated against; this is the shape the rest of\n * the code reads once that validation has passed.\n *\n * Two things are worth knowing before reading it.\n *\n * A template *is* a rule. It describes the page, so it takes every rule key,\n * plus `title`, `types` and `extends`. It may not take `min` or `max`, because\n * a page is one page, and the loader refuses those two by hand.\n *\n * A rule's children are a **list**, not a map. The v1 format keyed section\n * rules by name and let YAML key order carry the grammar, which made the order\n * invisible to the schema and unspeakable in `extends`. A rule names itself\n * with `id` instead, and that is what `extends` targets.\n *\n * The block-rule keys are plural where the node model is singular. That is\n * deliberate: the node model names one node (`codeBlock`), while a template key\n * carries a count (`codeBlocks: { min: 1 }`).\n */\nimport type { ContentKind } from \"../types.js\";\nimport { compilePattern } from \"../rules/index.js\";\n\n/** Shared by every counted rule: how many of the thing there must be. */\nexport interface Occurrences {\n /** Fewest occurrences. Absent means one. */\n min?: number;\n /** Most occurrences. Absent is unbounded; `0` forbids. */\n max?: number;\n}\n\n/**\n * What a rule's `heading` may say.\n *\n * `undefined` (the key absent) matches any heading or none. A string is exact\n * text, a list is one-of, `{ pattern }` is an unanchored regular expression,\n * and `false` means the section has no heading of its own.\n */\nexport type HeadingRule = string | string[] | { pattern: string } | false;\n\n/**\n * Attributes a node must carry. A string is the required value, `true`\n * requires the attribute's presence, and `false` requires its absence.\n */\nexport type AttributesRule = Record<string, string | boolean>;\n\n/** `paragraphs:` - how many paragraphs, and what each must look like. */\nexport interface ParagraphsRule extends Occurrences {\n /** Unanchored regular expression every paragraph in the run must match. */\n pattern?: string;\n}\n\n/** `codeBlocks:` - how many code blocks, and how they are tagged. */\nexport interface CodeBlocksRule extends Occurrences {\n /** Language, or languages, every code block must declare one of. */\n language?: string | string[];\n /** Info-string tail after the language; narrows which blocks count. */\n fenceInfo?: string;\n}\n\n/** `lists.items:` - how many items per list, and what each item holds. */\nexport interface ListItemsRule extends Occurrences {\n sequence?: BlockRule[];\n contains?: BlockRule;\n}\n\n/** `lists:` - how many lists, whether they are ordered, and item rules. */\nexport interface ListsRule extends Occurrences {\n ordered?: boolean;\n items?: ListItemsRule;\n}\n\n/** `tables:` - how many tables, and the header cells in order. */\nexport interface TablesRule extends Occurrences {\n columns?: string[];\n}\n\n/** `admonitions:` - how many, and of which variant. */\nexport interface AdmonitionsRule extends Occurrences {\n variant?: \"note\" | \"tip\" | \"important\" | \"caution\" | \"warning\" | \"danger\";\n}\n\n/** `images:` - how many, and what they point at. */\nexport interface ImagesRule extends Occurrences {\n url?: string;\n alt?: string;\n attributes?: AttributesRule;\n}\n\n/** `elements:` - how many named wrappers, and what they hold. */\nexport interface ElementsRule extends Occurrences {\n /** Name, or names, an element must carry to be counted by this rule. */\n tag?: string | string[];\n attributes?: AttributesRule;\n sequence?: BlockRule[];\n contains?: BlockRule;\n}\n\n/**\n * What a section holds, keyed by content kind.\n *\n * One of these is a whole `contains:`. As an entry of `sequence:` exactly one\n * key is set, and it names the kind expected at that position.\n */\nexport interface BlockRule {\n paragraphs?: ParagraphsRule;\n codeBlocks?: CodeBlocksRule;\n lists?: ListsRule;\n tables?: TablesRule;\n admonitions?: AdmonitionsRule;\n images?: ImagesRule;\n blockquotes?: Occurrences;\n definitionLists?: Occurrences;\n elements?: ElementsRule;\n}\n\n/** One block-rule key: a content kind, spelled plural. */\nexport type BlockKind = keyof BlockRule;\n\n/** Every block-rule key, in the order the schema declares them. */\nexport const BLOCK_KINDS: readonly BlockKind[] = [\n \"paragraphs\",\n \"codeBlocks\",\n \"lists\",\n \"tables\",\n \"admonitions\",\n \"images\",\n \"blockquotes\",\n \"definitionLists\",\n \"elements\",\n];\n\n/**\n * The node a block-rule key counts: `codeBlocks` counts `codeBlock` nodes.\n *\n * It is what lets the validator ask a parser whether a rule can run at all -\n * a parser declares the kinds it emits, and a rule about a kind absent from\n * that list is reported rather than silently passing.\n *\n * `rules/sequence.ts` holds the same map, written against the rules' own copy\n * of the DSL. The duplication is the one this file's header describes: the two\n * vocabularies are kept apart deliberately, and this is the copy the loader and\n * the validator read.\n */\nexport const BLOCK_KIND_NODE: Record<BlockKind, ContentKind> = {\n paragraphs: \"paragraph\",\n codeBlocks: \"codeBlock\",\n lists: \"list\",\n tables: \"table\",\n admonitions: \"admonition\",\n images: \"image\",\n blockquotes: \"blockquote\",\n definitionLists: \"definitionList\",\n elements: \"element\",\n};\n\n/** One rule: a section of the page, or a repeated run of sections. */\nexport interface Rule extends Occurrences {\n /** Handle, unique among siblings. `extends` targets it. */\n id?: string;\n /** Prose description of what the rule is for. Never checked. */\n description?: string;\n heading?: HeadingRule;\n /** Rules matched in order as one unit, repeated by this rule's `min`/`max`. */\n repeat?: Rule[];\n /** What the section holds, in order. Not combinable with `contains`. */\n sequence?: BlockRule[];\n /** What the section holds, in any order. Not combinable with `sequence`. */\n contains?: BlockRule;\n /** Rules for the subsections, in document order. */\n sections?: Rule[];\n}\n\n/** One doctype template: the rule that describes a whole page. */\nexport interface Template extends Rule {\n /** Human-readable name, shown by `manni lint templates`. */\n title?: string;\n /** Doctypes this template serves, matched against a page's `type`. */\n types?: string[];\n /** Built-in id, path, or URL to inherit from. */\n extends?: string;\n}\n\n/** A template file: named templates plus reusable `$ref` targets. */\nexport interface TemplateFile {\n /** Published schema URL, for editors. Ignored by the linter. */\n $schema?: string;\n templates?: Record<string, Template>;\n components?: Record<string, unknown>;\n info?: Record<string, unknown>;\n}\n\n/**\n * A rule is a wildcard when it says nothing about its heading.\n *\n * It then matches any heading, and matches a section with none. `heading:\n * false` is not a wildcard: it states that the section has no heading of its\n * own, which is as specific as naming one.\n */\nexport function isWildcard(rule: Rule): boolean {\n return rule.heading === undefined;\n}\n\n/**\n * How many sections a rule claims: `min` defaulting to one, and `max` as\n * written, with `null` for unbounded.\n *\n * The defaults live here rather than in the schema. A default written into the\n * data by Ajv is indistinguishable from a value the author typed, so it wins\n * the `extends` merge against the parent's real value.\n *\n * One default is not the naive `min ?? 1`. `max: 0` is how the format forbids\n * a thing outright, and a bare `max: 0` has to be satisfiable by a page that\n * truly has none of it. A blanket \"min defaults to 1\" makes it unsatisfiable -\n * at least one demanded, at most zero permitted - so `min` defaults to 0\n * exactly when `max` is written as `0` and `min` itself is not, and to 1\n * otherwise. `checkCount` in `rules/index.ts` states the same rule for the\n * content counts; the two agree deliberately.\n */\nexport function occurrenceRange(rule: Occurrences): {\n min: number;\n max: number | null;\n} {\n return { min: rule.min ?? (rule.max === 0 ? 0 : 1), max: rule.max ?? null };\n}\n\n/** Whether a section's title satisfies a rule's `heading`. */\nexport function headingMatches(\n heading: HeadingRule | undefined,\n title: string | null,\n): boolean {\n if (heading === undefined) return true;\n if (heading === false) return title === null;\n if (title === null) return false;\n if (typeof heading === \"string\") return title === heading;\n if (Array.isArray(heading)) return heading.includes(title);\n return compilePattern(heading.pattern).test(title);\n}\n","/**\n * Decide which rule describes which section, by alignment.\n *\n * A rule list is a regular expression over section predicates, and a document's\n * sibling sections are the string. The matcher compiles the first and aligns\n * the second against it at minimum cost:\n *\n * 1. Each rule contributes one predicate on a heading. `min`/`max` is counted\n * repetition, and `repeat:` is a parenthesised subexpression.\n * 2. Bounded counts expand into copies; an absent `max` becomes a self-loop.\n * 3. Four edits close the gap between rules and sections: a *match* (the\n * predicate holds), a *coercion* (a rule claiming one section takes a\n * section its heading rejects), a *skipped rule* (a required occurrence\n * consumes nothing) and a *skipped section* (no rule consumes it).\n * 4. Viterbi over a (sections + 1) x states lattice finds the cheapest edit\n * sequence. Deletions can form zero-consuming cycles, so each column is\n * closed with Dijkstra rather than a topological sweep; all weights are\n * non-negative.\n * 5. Skipped rules become `missing_section` (or one `missing_group` for a\n * `repeat` copy that is absent whole), skipped sections become\n * `unexpected_section`, and every match is handed to the content rules.\n *\n * The predecessor of this file walked the rules left to right with no\n * backtracking, and each of its eight hand-written behaviours is now a\n * consequence of a weight or a tie-break instead of a special case. The two it\n * could not express are what forced the change: a rule list with counted\n * repetition is not a sequence of one-shot decisions, and a greedy walk has to\n * guess which of two rules wants a section before it has seen the rest.\n *\n * Heading mismatches are deliberately not reported here. This module pairs; the\n * content rules report `heading_error` on the pair it produced. `validator.ts`\n * explains why the two are separate.\n */\nimport { LintError } from \"../types.js\";\nimport type { Finding, Position, SectionNode } from \"../types.js\";\nimport { headingMatches, isWildcard, occurrenceRange } from \"./template.js\";\nimport type { Rule } from \"./template.js\";\n\n/* -------------------------------------------------------------------------- *\n * The cost model, which is interface\n * -------------------------------------------------------------------------- */\n\n/**\n * What each edit costs, in the units the alignment minimises.\n *\n * These weights are **interface, not implementation**. They decide which\n * findings a document produces, so changing one changes the report for\n * documents nobody edited - the same class of change as renaming a flag.\n * `test/lint/unit/match.test.ts` pins them, and the templates reference prints\n * them.\n *\n * Skipping an occurrence at or above its rule's `min` is free; only a required\n * occurrence pays `skipRule`.\n *\n * Coercion is open only to a *required* occurrence of a rule whose `max` is 1.\n * Both halves of that earn their place. Without the `max: 1` half a repeating\n * rule adopts any stray section for 1 rather than letting it report as\n * unexpected for 2. Without the \"required\" half an optional rule does the same\n * thing for the same reason, and there it is plainly wrong: standing aside\n * costs an optional rule nothing, so coercing trades a clean report for a\n * heading error about a section the template never insisted on.\n */\nexport const ALIGNMENT_COSTS = {\n match: 0,\n coerce: 1,\n skipRule: 2,\n skipSection: 2,\n} as const;\n\n/**\n * How equal-cost alignments are settled, in order, after the total cost.\n *\n * Also interface: two of these decide real reports, and all three are stated in\n * words so the docs page and the code cannot drift apart.\n */\nexport const TIE_BREAKS = [\n \"a rule that names its heading beats a wildcard taking the same section\",\n \"a repeating rule prefers its sections adjacent\",\n \"earliest rule, then the smallest edit sequence under match < coerce < skip-rule < skip-section\",\n] as const;\n\n/**\n * Most states a compiled rule list may expand to.\n *\n * Counted repetition is expanded into copies, so `max: 100000` on a rule with\n * five subsections is a hundred thousand copies of five states and a lattice\n * nobody asked for. The cap turns that into a template error naming the file,\n * rather than a lint run that appears to hang.\n */\nexport const STATE_LIMIT = 2000;\n\n/* -------------------------------------------------------------------------- *\n * What the matcher hands on\n * -------------------------------------------------------------------------- */\n\n/** One rule paired with the section it claimed. */\nexport interface Match {\n /** The rule itself - a `repeat` group's member, never the group. */\n rule: Rule;\n section: SectionNode;\n /**\n * True when the rule was paired with a section whose heading does not\n * satisfy it, because nothing else could claim that section. Keeps the\n * precise \"Expected title X, but found Y\" report for the common one-for-one\n * case instead of degrading it into missing + unexpected.\n */\n coerced: boolean;\n}\n\nexport interface MatchResult {\n matches: Match[];\n findings: Finding[];\n}\n\nexport interface MatchOptions {\n /** Section these are the subsections of, for anchoring a trailing gap. */\n parent?: SectionNode | null;\n /** File the rules came from. Used only to name the state-cap failure. */\n source?: string;\n /** Template within that file. Used only to name the state-cap failure. */\n template?: string;\n}\n\n/* -------------------------------------------------------------------------- *\n * Compilation\n * -------------------------------------------------------------------------- */\n\n/**\n * One copy of a `repeat` group, and every leaf occurrence inside it.\n *\n * It exists so an absent copy can report once for the group. A copy whose\n * leaves were *all* skipped is a group that is not there at all, which reads\n * as one finding; a copy that matched some of them is a group that is there and\n * incomplete, whose absent members read better one by one.\n */\ninterface GroupCopy {\n rule: Rule;\n members: Occurrence[];\n}\n\n/** One occurrence of one rule: the chance to consume exactly one section. */\ninterface Occurrence {\n rule: Rule;\n /** Below the rule's `min`, so skipping it costs rather than being free. */\n required: boolean;\n /** Required and `max: 1`, so it may take a section its heading rejects. */\n coercible: boolean;\n /** Says nothing about its heading, so it loses ties to a rule that does. */\n wildcard: boolean;\n /** Enclosing `repeat` copies, outermost first. */\n groups: GroupCopy[];\n}\n\ninterface Eps {\n from: number;\n to: number;\n cost: number;\n rank: number;\n /** Set when this edge is a rule being skipped rather than structure. */\n occ: Occurrence | null;\n}\n\ninterface Automaton {\n states: number;\n start: number;\n accept: number;\n /** The occurrence a state may consume a section through, if any. */\n consume: (Occurrence | null)[];\n /** Where that consumption lands. */\n consumeTo: number[];\n epsOut: Eps[][];\n epsIn: Eps[][];\n /** States strictly inside a repetition, where a skipped section breaks a run. */\n inRepeat: boolean[];\n}\n\n/**\n * Edit ranks, used only to settle a tie the costs and the two structural\n * tie-breaks left open. Structural epsilons - entering, repeating and leaving a\n * self-loop - rank with `match`, because they are not edits at all and a path\n * must be free to leave a loop before it starts skipping the rules inside it.\n */\nconst RANK = {\n match: 0,\n structure: 0,\n coerce: 1,\n skipRule: 2,\n skipSection: 3,\n} as const;\n\nconst NO_EPS: Eps[] = [];\n\n/**\n * States the rule list expands to, counted without building anything.\n *\n * Checked before compilation so a template with an absurd `max` fails on its\n * own terms rather than by exhausting memory. The two extra states per\n * unbounded rule are its self-loop's entry and exit.\n */\nfunction expandedStates(rules: Rule[]): number {\n let total = 1;\n for (const rule of rules) total += ruleStates(rule);\n return total;\n}\n\nfunction ruleStates(rule: Rule): number {\n let unit = 1;\n if (rule.repeat) {\n unit = 0;\n for (const member of rule.repeat) unit += ruleStates(member);\n }\n const { min, max } = occurrenceRange(rule);\n if (max === null) return unit * (Math.max(min, 0) + 1) + 2;\n return unit * Math.max(0, max);\n}\n\nfunction listAt<T>(lists: T[][], index: number): T[] {\n const list = lists[index];\n if (list) return list;\n const created: T[] = [];\n lists[index] = created;\n return created;\n}\n\n/**\n * Compile a rule list into an automaton over section predicates.\n *\n * Bounded repetition is unrolled: `min: 1, max: 3` is three copies, the first\n * required and the rest free to skip. An unbounded `max` is a self-loop after\n * the required copies, which is the only construct here that can consume\n * nothing and return to where it started - hence the Dijkstra in the alignment.\n */\nfunction compile(rules: Rule[]): Automaton {\n const consume: (Occurrence | null)[] = [];\n const consumeTo: number[] = [];\n const epsOut: Eps[][] = [];\n const epsIn: Eps[][] = [];\n const inRepeat: boolean[] = [];\n\n const newState = (): number => {\n consume.push(null);\n consumeTo.push(-1);\n epsOut.push([]);\n epsIn.push([]);\n inRepeat.push(false);\n return consume.length - 1;\n };\n\n const eps = (\n from: number,\n to: number,\n cost: number,\n rank: number,\n occ: Occurrence | null,\n ): void => {\n const edge: Eps = { from, to, cost, rank, occ };\n listAt(epsOut, from).push(edge);\n listAt(epsIn, to).push(edge);\n };\n\n const leaf = (from: number, occ: Occurrence): number => {\n const to = newState();\n consume[from] = occ;\n consumeTo[from] = to;\n // Skipping the occurrence: free when the rule can do without it.\n eps(from, to, occ.required ? ALIGNMENT_COSTS.skipRule : 0, RANK.skipRule, occ);\n return to;\n };\n\n /** One copy of a rule's unit: its members, or the rule's own occurrence. */\n const buildCopy = (\n rule: Rule,\n from: number,\n groups: GroupCopy[],\n required: boolean,\n ): number => {\n if (rule.repeat) {\n const copy: GroupCopy = { rule, members: [] };\n const nested = [...groups, copy];\n let cursor = from;\n for (const member of rule.repeat) {\n cursor = buildRule(member, cursor, nested, required);\n }\n return cursor;\n }\n const { max } = occurrenceRange(rule);\n const occ: Occurrence = {\n rule,\n required,\n coercible: required && max === 1,\n wildcard: isWildcard(rule),\n groups,\n };\n for (const group of groups) group.members.push(occ);\n return leaf(from, occ);\n };\n\n function buildRule(\n rule: Rule,\n from: number,\n groups: GroupCopy[],\n context: boolean,\n ): number {\n const { min, max } = occurrenceRange(rule);\n // `max` below `min` is refused by the loader where both are written; a bare\n // `max: 0` still reaches here against the default `min: 1`, and means none.\n const floor = max === null ? Math.max(min, 0) : Math.min(Math.max(min, 0), max);\n const copies = max === null ? floor : Math.max(0, max);\n const first = consume.length;\n\n let cursor = from;\n for (let copy = 0; copy < copies; copy++) {\n cursor = buildCopy(rule, cursor, groups, context && copy < floor);\n }\n\n let end = cursor;\n if (max === null) {\n const loop = newState();\n eps(cursor, loop, 0, RANK.structure, null);\n const back = buildCopy(rule, loop, groups, false);\n eps(back, loop, 0, RANK.structure, null);\n end = newState();\n eps(loop, end, 0, RANK.structure, null);\n }\n\n // A skipped section inside a repetition breaks the run it is inside, which\n // tie-break 2 charges for. The repetition's own boundaries are not inside\n // it: a section skipped before the first copy or after the last one sits\n // beside the run rather than in the middle of it.\n if (copies > 1 || max === null) {\n for (let state = first; state < consume.length; state++) {\n if (state !== end) inRepeat[state] = true;\n }\n }\n return end;\n }\n\n const start = newState();\n let cursor = start;\n for (const rule of rules) cursor = buildRule(rule, cursor, [], true);\n\n return {\n states: consume.length,\n start,\n accept: cursor,\n consume,\n consumeTo,\n epsOut,\n epsIn,\n inRepeat,\n };\n}\n\n/**\n * Compiled rule lists, keyed by the array the template holds.\n *\n * A template is loaded once and applied to every page of its doctype, and every\n * level of every page re-enters this module. The automaton is immutable once\n * built, so one compilation serves them all.\n */\nconst compiled = new WeakMap<Rule[], Automaton>();\n\nfunction automatonFor(rules: Rule[], options: MatchOptions): Automaton {\n const hit = compiled.get(rules);\n if (hit) return hit;\n\n const states = expandedStates(rules);\n if (states > STATE_LIMIT) {\n const source = options.source ?? \"template\";\n // A template is referred to as `./templates.yaml#how-to` everywhere else,\n // so a named template fragment joins the source the same way here. Absent\n // a name - the file failed to compile a rule list outside any named\n // template - there is nothing to put after a `#`, so the sentence falls\n // back to its old, colon-joined phrasing.\n const label =\n options.template != null ? `${source}#${options.template}` : `${source}: the rule list`;\n throw new LintError(\n `${label} expands to ${states} states; the limit is ${STATE_LIMIT}. ` +\n `Cap a max, or split the template.`,\n );\n }\n\n const built = compile(rules);\n compiled.set(rules, built);\n return built;\n}\n\n/* -------------------------------------------------------------------------- *\n * Alignment\n * -------------------------------------------------------------------------- */\n\ntype StepKind = \"match\" | \"coerce\" | \"skip-rule\" | \"skip-section\";\n\n/** One candidate edge out of a lattice node, during the forward walk. */\ninterface Move {\n kind: StepKind;\n /** State it lands in. */\n to: number;\n /** Section index it lands in - the same one unless a section was consumed. */\n column: number;\n occ: Occurrence | null;\n /** This edge plus the cheapest completion from where it lands. */\n total: number;\n rank: number;\n}\n\ninterface Step {\n kind: StepKind;\n /** Section consumed, or where the cursor stood when a rule was skipped. */\n index: number;\n occ: Occurrence | null;\n}\n\n/** A section's heading, or `null` when it has none of its own. */\nfunction titleOf(section: SectionNode): string | null {\n return section.titlePosition === null ? null : section.title;\n}\n\n/** Binary heap over (cost, state), smallest cost first. */\nclass Heap {\n private readonly costs: number[] = [];\n private readonly items: number[] = [];\n\n get size(): number {\n return this.items.length;\n }\n\n /*\n * Every `?? 0` in this class is unreachable, and is here only because\n * `noUncheckedIndexedAccess` cannot see the bounds the arithmetic already\n * guarantees. `costs` and `items` are pushed and popped together and so\n * always have the same length; `child` is the index just pushed, and\n * `parent = (child - 1) >> 1` is in bounds whenever `child > 0`; `left` and\n * `right` are compared against `length` before they are read.\n *\n * Worth stating rather than leaving to inference: were an index ever out of\n * bounds, the fallback would read as cost 0, quietly inverting the heap\n * order rather than throwing. It is a type-checker concession, not a\n * defensive default.\n */\n push(cost: number, item: number): void {\n this.costs.push(cost);\n this.items.push(item);\n let child = this.items.length - 1;\n while (child > 0) {\n const parent = (child - 1) >> 1;\n if ((this.costs[parent] ?? 0) <= (this.costs[child] ?? 0)) break;\n this.swap(parent, child);\n child = parent;\n }\n }\n\n pop(): { cost: number; item: number } {\n const cost = this.costs[0] ?? 0;\n const item = this.items[0] ?? 0;\n const lastCost = this.costs.pop();\n const lastItem = this.items.pop();\n if (this.items.length > 0 && lastCost !== undefined && lastItem !== undefined) {\n this.costs[0] = lastCost;\n this.items[0] = lastItem;\n let parent = 0;\n for (;;) {\n const left = parent * 2 + 1;\n const right = left + 1;\n let smallest = parent;\n if (left < this.items.length && (this.costs[left] ?? 0) < (this.costs[smallest] ?? 0)) {\n smallest = left;\n }\n if (right < this.items.length && (this.costs[right] ?? 0) < (this.costs[smallest] ?? 0)) {\n smallest = right;\n }\n if (smallest === parent) break;\n this.swap(parent, smallest);\n parent = smallest;\n }\n }\n return { cost, item };\n }\n\n private swap(a: number, b: number): void {\n const cost = this.costs[a] ?? 0;\n const item = this.items[a] ?? 0;\n this.costs[a] = this.costs[b] ?? 0;\n this.items[a] = this.items[b] ?? 0;\n this.costs[b] = cost;\n this.items[b] = item;\n }\n}\n\n/**\n * The cheapest edit sequence turning the rule list into the section list.\n *\n * Costs are packed into one integer so the lattice can be a typed array:\n * `((primary * radix) + wildcards) * radix + brokenRuns`, compared as one\n * number, which is lexicographic because no component can reach the radix.\n *\n * The lattice is filled backwards, from the end of the document to the start,\n * and the path is then walked forwards. That order is what makes tie-break 3\n * expressible: with the cost of every remaining suffix already known, the walk\n * can take the lowest-ranked optimal edit at each step, which is exactly\n * \"earliest rule, then the smallest edit sequence\".\n */\nfunction align(sections: SectionNode[], nfa: Automaton): Step[] {\n const n = sections.length;\n const states = nfa.states;\n const radix = 2 * (n + states) + 2;\n const weigh = (primary: number, wildcards: number, brokenRuns: number): number =>\n (primary * radix + wildcards) * radix + brokenRuns;\n\n const SKIP_SECTION = weigh(ALIGNMENT_COSTS.skipSection, 0, 0);\n const SKIP_SECTION_IN_RUN = weigh(ALIGNMENT_COSTS.skipSection, 0, 1);\n const MATCH = weigh(ALIGNMENT_COSTS.match, 0, 0);\n const MATCH_WILDCARD = weigh(ALIGNMENT_COSTS.match, 1, 0);\n const COERCE = weigh(ALIGNMENT_COSTS.coerce, 0, 0);\n\n /** What a state's consuming edge costs against one section, or null. */\n const consumeCost = (\n state: number,\n index: number,\n ): { cost: number; rank: number; to: number; occ: Occurrence } | null => {\n const occ = nfa.consume[state];\n const section = sections[index];\n const to = nfa.consumeTo[state];\n if (!occ || !section || to === undefined || to < 0) return null;\n if (headingMatches(occ.rule.heading, titleOf(section))) {\n const cost = occ.wildcard ? MATCH_WILDCARD : MATCH;\n return { cost, rank: RANK.match, to, occ };\n }\n if (occ.coercible) return { cost: COERCE, rank: RANK.coerce, to, occ };\n return null;\n };\n\n const skipSectionCost = (state: number): number =>\n nfa.inRepeat[state] === true ? SKIP_SECTION_IN_RUN : SKIP_SECTION;\n\n // dist[i * states + s]: cheapest way from (section i, state s) to the end.\n const dist = new Float64Array((n + 1) * states).fill(Infinity);\n const distAt = (slot: number): number => dist[slot] ?? Infinity;\n\n for (let index = n; index >= 0; index--) {\n const base = index * states;\n const next = base + states;\n const heap = new Heap();\n\n for (let state = 0; state < states; state++) {\n let best = Infinity;\n if (index === n) {\n if (state === nfa.accept) best = 0;\n } else {\n const step = consumeCost(state, index);\n if (step) best = step.cost + distAt(next + step.to);\n const skipped = skipSectionCost(state) + distAt(next + state);\n if (skipped < best) best = skipped;\n }\n dist[base + state] = best;\n if (best < Infinity) heap.push(best, state);\n }\n\n // Close the column under epsilon edges. They can form zero-consuming\n // cycles - a `repeat` with `min: 0` and no `max` - so this is Dijkstra on\n // the reversed epsilon graph rather than a sweep in state order.\n const done = new Uint8Array(states);\n while (heap.size > 0) {\n const { cost, item } = heap.pop();\n if (done[item] === 1 || cost > distAt(base + item)) continue;\n done[item] = 1;\n for (const edge of nfa.epsIn[item] ?? NO_EPS) {\n const candidate = cost + edge.cost;\n if (candidate < distAt(base + edge.from)) {\n dist[base + edge.from] = candidate;\n heap.push(candidate, edge.from);\n }\n }\n }\n }\n\n if (distAt(nfa.start) === Infinity) {\n // Every state has a skip-section edge and every occurrence a skip edge, so\n // the accept state is always reachable. Reaching this would be a\n // construction bug, not a template the user can fix.\n throw new LintError(\"internal: no alignment exists for this rule list.\");\n }\n\n const steps: Step[] = [];\n let index = 0;\n let state = nfa.start;\n let seen = new Set<number>([state]);\n\n while (!(index === n && state === nfa.accept)) {\n const moves: Move[] = [];\n\n const offer = (\n cost: number,\n rank: number,\n to: number,\n column: number,\n kind: StepKind,\n occ: Occurrence | null,\n ): void => {\n const total = cost + distAt(column * states + to);\n if (total === Infinity) return;\n moves.push({ kind, to, column, occ, total, rank });\n };\n\n if (index < n) {\n const step = consumeCost(state, index);\n if (step) {\n offer(\n step.cost,\n step.rank,\n step.to,\n index + 1,\n step.rank === RANK.coerce ? \"coerce\" : \"match\",\n step.occ,\n );\n }\n offer(skipSectionCost(state), RANK.skipSection, state, index + 1, \"skip-section\", null);\n }\n for (const edge of nfa.epsOut[state] ?? NO_EPS) {\n if (seen.has(edge.to)) continue;\n offer(edge.cost, edge.rank, edge.to, index, \"skip-rule\", edge.occ);\n }\n\n // Cheapest first; then the lowest-ranked edit, which is tie-break 3; then\n // the earliest state, so the walk is reproducible to the edge.\n let move: Move | undefined;\n for (const candidate of moves) {\n if (\n move === undefined ||\n candidate.total < move.total ||\n (candidate.total === move.total && candidate.rank < move.rank) ||\n (candidate.total === move.total &&\n candidate.rank === move.rank &&\n candidate.to < move.to)\n ) {\n move = candidate;\n }\n }\n if (move === undefined) {\n throw new LintError(\"internal: the alignment could not be reconstructed.\");\n }\n\n if (move.kind !== \"skip-rule\" || move.occ !== null) {\n steps.push({ kind: move.kind, index, occ: move.occ });\n }\n if (move.column !== index) {\n index = move.column;\n seen = new Set<number>();\n }\n state = move.to;\n seen.add(state);\n }\n\n return steps;\n}\n\n/* -------------------------------------------------------------------------- *\n * Findings\n * -------------------------------------------------------------------------- */\n\nfunction collapse(point: Position[\"end\"]): Position {\n return { start: { ...point }, end: { ...point } };\n}\n\n/**\n * Where a finding about the cursor position lands.\n *\n * A gap in the middle of a document anchors on the section standing where the\n * missing one should be. A gap at the *end* has no such section, and anchoring\n * on the parent - which is what the previous matcher did - spans the parent's\n * whole subtree, so the finding starts at the parent's heading and sorts to the\n * top of a report about the bottom of the file. It anchors at the parent's end\n * instead, which is where the section would have gone.\n */\nfunction anchor(\n index: number,\n sections: SectionNode[],\n parent: SectionNode | null,\n): { heading: string | null; position: Position } {\n const section = sections[index];\n if (section) {\n return { heading: section.title || null, position: section.position };\n }\n if (parent) {\n return { heading: parent.title || null, position: collapse(parent.position.end) };\n }\n const last = sections[sections.length - 1];\n if (last) return { heading: null, position: collapse(last.position.end) };\n return { heading: null, position: collapse({ line: 1, column: 1, offset: 0 }) };\n}\n\n/** How a rule's heading reads inside a longer sentence. */\nfunction describeHeading(rule: Rule): string {\n const heading = rule.heading;\n if (typeof heading === \"string\") return `\"${heading}\"`;\n if (Array.isArray(heading)) return heading.map((text) => `\"${text}\"`).join(\", \");\n if (heading === false) return \"a section with no heading\";\n if (heading !== undefined) return `/${heading.pattern}/`;\n return rule.id === undefined ? \"any section\" : `\"${rule.id}\"`;\n}\n\n/**\n * What an absent occurrence is called.\n *\n * A rule names itself by its heading where it has one, because that is the text\n * the reader will type into the document. A wildcard has only its `id`, which\n * is why one is worth writing.\n */\nfunction missingMessage(rule: Rule): string {\n const heading = rule.heading;\n if (typeof heading === \"string\") return `Missing section \"${heading}\"`;\n if (Array.isArray(heading)) {\n return `Missing one of ${heading.map((text) => `\"${text}\"`).join(\", \")}`;\n }\n if (heading === false) return \"Missing section without a heading\";\n if (heading !== undefined) return `Missing section matching /${heading.pattern}/`;\n return rule.id === undefined ? \"Missing section\" : `Missing section \"${rule.id}\"`;\n}\n\nfunction missingGroupMessage(copy: GroupCopy): string {\n const members = (copy.rule.repeat ?? []).map(describeHeading).join(\" followed by \");\n const name = copy.rule.id === undefined ? \"\" : ` \"${copy.rule.id}\"`;\n return `Missing group${name}: expected ${members}`;\n}\n\nfunction unexpectedMessage(section: SectionNode): string {\n const what =\n section.titlePosition === null\n ? \"Unexpected section without a heading\"\n : `Unexpected section \"${section.title}\"`;\n return `${what}. Add a trailing rule with min: 0 to allow sections the template does not describe.`;\n}\n\n/* -------------------------------------------------------------------------- *\n * The entry point\n * -------------------------------------------------------------------------- */\n\n/**\n * Align `sections` against `rules` and say what is missing, what is extra, and\n * which rule describes which section.\n *\n * `rules` being absent means the template says nothing about this level, which\n * is silence rather than \"no sections allowed\". An empty list is the other\n * thing: a rule list that describes no sections, so every section is\n * unexpected.\n */\nexport function matchSections(\n sections: SectionNode[],\n rules: Rule[] | undefined,\n options: MatchOptions = {},\n): MatchResult {\n const matches: Match[] = [];\n const findings: Finding[] = [];\n if (!rules) return { matches, findings };\n\n const parent = options.parent ?? null;\n const nfa = automatonFor(rules, options);\n const steps = align(sections, nfa);\n\n const taken = new Set<Occurrence>();\n for (const step of steps) {\n if ((step.kind === \"match\" || step.kind === \"coerce\") && step.occ) {\n taken.add(step.occ);\n }\n }\n\n /** The outermost enclosing `repeat` copy that is absent whole, if any. */\n const absentGroup = (occ: Occurrence): GroupCopy | null => {\n for (const group of occ.groups) {\n if (group.members.every((member) => !taken.has(member))) return group;\n }\n return null;\n };\n\n const reported = new Set<GroupCopy>();\n\n for (const step of steps) {\n const section = sections[step.index];\n if ((step.kind === \"match\" || step.kind === \"coerce\") && step.occ && section) {\n matches.push({\n rule: step.occ.rule,\n section,\n coerced: step.kind === \"coerce\",\n });\n continue;\n }\n\n if (step.kind === \"skip-section\" && section) {\n findings.push({\n type: \"unexpected_section\",\n heading: section.title || null,\n message: unexpectedMessage(section),\n position: section.position,\n severity: \"error\",\n });\n continue;\n }\n\n if (step.kind !== \"skip-rule\" || !step.occ || !step.occ.required) continue;\n\n const where = anchor(step.index, sections, parent);\n const group = absentGroup(step.occ);\n if (group) {\n if (reported.has(group)) continue;\n reported.add(group);\n findings.push({\n type: \"missing_group\",\n heading: where.heading,\n message: missingGroupMessage(group),\n position: where.position,\n severity: \"error\",\n });\n continue;\n }\n\n findings.push({\n type: \"missing_section\",\n heading: where.heading,\n message: missingMessage(step.occ.rule),\n position: where.position,\n severity: \"error\",\n });\n }\n\n return { matches, findings };\n}\n"],"mapp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