@locus-forge/locus-map 0.2.0 → 0.2.2-dev.20261206.g5e970d2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/README.md +21 -6
  3. package/dist/assets/{abnfDiagram-VCTEODGH-BnTGKKaL.js → abnfDiagram-VCTEODGH-JiCO6vo-.js} +1 -1
  4. package/dist/assets/{ar-SA-G6X2FPQ2-LY3czoz9.js → ar-SA-G6X2FPQ2-BdzEBmp3.js} +1 -1
  5. package/dist/assets/{architectureDiagram-5GKGNRK7-BG9h9KRx.js → architectureDiagram-5GKGNRK7-D7T_vJwe.js} +1 -1
  6. package/dist/assets/{az-AZ-76LH7QW2-Brv6kuM6.js → az-AZ-76LH7QW2-BQ_SoVB7.js} +1 -1
  7. package/dist/assets/{bg-BG-XCXSNQG7-tsQwwvMW.js → bg-BG-XCXSNQG7-DlH1olUf.js} +1 -1
  8. package/dist/assets/{blockDiagram-I7D4REHJ-V9bUuR63.js → blockDiagram-I7D4REHJ-DPz0LEjY.js} +1 -1
  9. package/dist/assets/{bn-BD-2XOGV67Q-0Cou5nNv.js → bn-BD-2XOGV67Q-CFIZU06C.js} +1 -1
  10. package/dist/assets/{c4Diagram-7LVT6UL2-BmCtzbrY.js → c4Diagram-7LVT6UL2-B6uCi0Ol.js} +1 -1
  11. package/dist/assets/{ca-ES-6MX7JW3Y-pZF7WJUL.js → ca-ES-6MX7JW3Y-Bpe3kOti.js} +1 -1
  12. package/dist/assets/channel-DB3atv5o.js +1 -0
  13. package/dist/assets/{chunk-2Q5K7J3B-D2iTDmHh.js → chunk-2Q5K7J3B-DTWRWhpx.js} +1 -1
  14. package/dist/assets/{chunk-5VM5RSS4-CTxdXZIx.js → chunk-5VM5RSS4-Dfr1HUAN.js} +1 -1
  15. package/dist/assets/{chunk-F27PBJKO-Hic1X1pm.js → chunk-F27PBJKO-D_IVoCIK.js} +1 -1
  16. package/dist/assets/{chunk-IMKFNOWR-DhLW1JVb.js → chunk-IMKFNOWR-Boa_chn8.js} +1 -1
  17. package/dist/assets/{chunk-JWPE2WC7-_g5twKlC.js → chunk-JWPE2WC7-RaK8jzc2.js} +1 -1
  18. package/dist/assets/{chunk-POPQ4Y6H-DMV4qmkd.js → chunk-POPQ4Y6H-D7xOpv6O.js} +1 -1
  19. package/dist/assets/{chunk-SVP7TREG-BWg83oEL.js → chunk-SVP7TREG-XvJsx1jt.js} +1 -1
  20. package/dist/assets/{chunk-TICWLB2K-CPmkpa7J.js → chunk-TICWLB2K-DZCVWmZG.js} +1 -1
  21. package/dist/assets/{chunk-XXDRQBXY-KnXvIZ_8.js → chunk-XXDRQBXY-Djk-REAy.js} +1 -1
  22. package/dist/assets/classDiagram-ZZMXUADV-CzvsXoj_.js +1 -0
  23. package/dist/assets/classDiagram-v2-VYDZK3BY-HxwJpdPt.js +1 -0
  24. package/dist/assets/{cose-bilkent-JH36ORCC-BChK_CGh.js → cose-bilkent-JH36ORCC-D6XaIbtG.js} +1 -1
  25. package/dist/assets/{cs-CZ-2BRQDIVT-CtAC2Qjy.js → cs-CZ-2BRQDIVT-BdzgSHdJ.js} +1 -1
  26. package/dist/assets/{cynefin-OW5HDTMX-CdsltaMX.js → cynefin-OW5HDTMX-BMTkMDG1.js} +1 -1
  27. package/dist/assets/{cynefinDiagram-5FMLGOSQ-bXvXX3Fx.js → cynefinDiagram-5FMLGOSQ-C2s5i9h9.js} +1 -1
  28. package/dist/assets/{d3-scale-sM87TD1Z.js → d3-scale-BMIMKl27.js} +1 -1
  29. package/dist/assets/{da-DK-5WZEPLOC-DyWwaclV.js → da-DK-5WZEPLOC-Bj-GFWHU.js} +1 -1
  30. package/dist/assets/{dagre-GXQ25YYZ-CTmiZZVO.js → dagre-GXQ25YYZ-CMT8wlz0.js} +1 -1
  31. package/dist/assets/{de-DE-XR44H4JA-BDXUBHki.js → de-DE-XR44H4JA-JmpondAB.js} +1 -1
  32. package/dist/assets/{diagram-S7CK7UJ4-Bm8Fy0R_.js → diagram-S7CK7UJ4-DU1blS3M.js} +1 -1
  33. package/dist/assets/{diagram-UQ7AKVKN-BU_AmM_A.js → diagram-UQ7AKVKN-0lWi4KDV.js} +1 -1
  34. package/dist/assets/{diagram-VSXAHHWV-B78LUoXq.js → diagram-VSXAHHWV-CrseWrhn.js} +1 -1
  35. package/dist/assets/{diagram-VX7I27RA-DNvWjMlf.js → diagram-VX7I27RA-C5BMS8Ql.js} +1 -1
  36. package/dist/assets/{diagram-Z3DM3KII-DmFVt1fa.js → diagram-Z3DM3KII-Cc3vq6b8.js} +1 -1
  37. package/dist/assets/{ebnfDiagram-PWID7BFC-CpDna0Jp.js → ebnfDiagram-PWID7BFC-ZF78imma.js} +1 -1
  38. package/dist/assets/{el-GR-BZB4AONW-CNhF7oN2.js → el-GR-BZB4AONW-BFslUpdm.js} +1 -1
  39. package/dist/assets/{engines-a8mi_N6S.js → engines-BtEtIBXt.js} +1 -1
  40. package/dist/assets/{erDiagram-RLTQ6QDP-BGD-9OAS.js → erDiagram-RLTQ6QDP-CjPjDn2i.js} +1 -1
  41. package/dist/assets/{es-ES-U4NZUMDT-DXMrJcKL.js → es-ES-U4NZUMDT-B0ezBTxQ.js} +1 -1
  42. package/dist/assets/{eu-ES-A7QVB2H4-BTkMEwMi.js → eu-ES-A7QVB2H4-DP_gx2kf.js} +1 -1
  43. package/dist/assets/{fa-IR-HGAKTJCU-CgkknSS7.js → fa-IR-HGAKTJCU-BuT1ELty.js} +1 -1
  44. package/dist/assets/{fi-FI-Z5N7JZ37-B1K83nId.js → fi-FI-Z5N7JZ37-BAu_Cj7n.js} +1 -1
  45. package/dist/assets/{flowDiagram-HODETNUW-CjU1yR1F.js → flowDiagram-HODETNUW-yqPGWNdd.js} +1 -1
  46. package/dist/assets/{fr-FR-RHASNOE6-CBFZBGMr.js → fr-FR-RHASNOE6-OF1CpgtN.js} +1 -1
  47. package/dist/assets/{ganttDiagram-EL5Y4UJY-bvb8BjSh.js → ganttDiagram-EL5Y4UJY-zUY5je2K.js} +1 -1
  48. package/dist/assets/{gitGraphDiagram-WWUBYQGX-DZXQ_x8t.js → gitGraphDiagram-WWUBYQGX-oWrs7wy0.js} +1 -1
  49. package/dist/assets/{gl-ES-HMX3MZ6V-CON98Mma.js → gl-ES-HMX3MZ6V-CkJ47l98.js} +1 -1
  50. package/dist/assets/{he-IL-6SHJWFNN-CBoFaEdB.js → he-IL-6SHJWFNN-D7CecRlh.js} +1 -1
  51. package/dist/assets/{hi-IN-IWLTKZ5I-BJuoh3dl.js → hi-IN-IWLTKZ5I-CGlW2X-h.js} +1 -1
  52. package/dist/assets/{hu-HU-A5ZG7DT2-CQruu8XR.js → hu-HU-A5ZG7DT2-Dq_n_tbp.js} +1 -1
  53. package/dist/assets/{id-ID-SAP4L64H-VhaoENjR.js → id-ID-SAP4L64H-CotwO_06.js} +1 -1
  54. package/dist/assets/index-CdVc9Lmz.js +624 -0
  55. package/dist/assets/{index-CDNl17QJ.css → index-Cv-tTxNC.css} +1 -1
  56. package/dist/assets/{index-CboxqaL5.js → index-VaWCb9bx.js} +5 -5
  57. package/dist/assets/{infoDiagram-27XIBGKW-CM9Hap0f.js → infoDiagram-27XIBGKW-CYzIkNFW.js} +1 -1
  58. package/dist/assets/{ishikawaDiagram-5VMMS53U-i8pQztJI.js → ishikawaDiagram-5VMMS53U-DkgUsuk5.js} +1 -1
  59. package/dist/assets/{it-IT-JPQ66NNP-Dj9BkXfh.js → it-IT-JPQ66NNP-h97o81us.js} +1 -1
  60. package/dist/assets/{ja-JP-DBVTYXUO-CB2BlfIS.js → ja-JP-DBVTYXUO-M6EVfh0o.js} +1 -1
  61. package/dist/assets/{journeyDiagram-3NMN7TZE-PxcdqONT.js → journeyDiagram-3NMN7TZE-CuKkNrJy.js} +1 -1
  62. package/dist/assets/{kaa-6HZHGXH3-CLnR_zY5.js → kaa-6HZHGXH3-DUy85zzz.js} +1 -1
  63. package/dist/assets/{kab-KAB-ZGHBKWFO-8TJr4nPf.js → kab-KAB-ZGHBKWFO-ChL-fKtk.js} +1 -1
  64. package/dist/assets/{kanban-definition-UXKFOSKX-B2p5NBhO.js → kanban-definition-UXKFOSKX-DkOxt3kf.js} +1 -1
  65. package/dist/assets/{kk-KZ-P5N5QNE5-5uZYjZ2e.js → kk-KZ-P5N5QNE5-DY6ucSGD.js} +1 -1
  66. package/dist/assets/{km-KH-HSX4SM5Z-D54aOpMd.js → km-KH-HSX4SM5Z-BAaS4014.js} +1 -1
  67. package/dist/assets/{ko-KR-MTYHY66A-Bnm0G6eo.js → ko-KR-MTYHY66A-D-r3mJ1R.js} +1 -1
  68. package/dist/assets/{ku-TR-6OUDTVRD-CtGCn_eB.js → ku-TR-6OUDTVRD-Dk1GCoOP.js} +1 -1
  69. package/dist/assets/{layout-BBV3_Svw.js → layout-DtNEGI4_.js} +1 -1
  70. package/dist/assets/{lt-LT-XHIRWOB4-Bl8G0yv6.js → lt-LT-XHIRWOB4-3Z2Ui1VZ.js} +1 -1
  71. package/dist/assets/{lv-LV-5QDEKY6T-Cax93Eua.js → lv-LV-5QDEKY6T-Bg59rOkR.js} +1 -1
  72. package/dist/assets/{mindmap-definition-YA3MSWOX-CsOezwmE.js → mindmap-definition-YA3MSWOX-Dcs8eV7p.js} +1 -1
  73. package/dist/assets/{mr-IN-CRQNXWMA-Br7GVyJH.js → mr-IN-CRQNXWMA-DepTOG29.js} +1 -1
  74. package/dist/assets/{my-MM-5M5IBNSE-xC6lzTDV.js → my-MM-5M5IBNSE-4KqL4Tav.js} +1 -1
  75. package/dist/assets/{nb-NO-T6EIAALU-B0i5THqA.js → nb-NO-T6EIAALU-5YWO_l3W.js} +1 -1
  76. package/dist/assets/{nl-NL-IS3SIHDZ-CqYhUjP3.js → nl-NL-IS3SIHDZ-QlAndkM2.js} +1 -1
  77. package/dist/assets/{nn-NO-6E72VCQL-rpjr_9Z5.js → nn-NO-6E72VCQL-BscwhEDW.js} +1 -1
  78. package/dist/assets/{oc-FR-POXYY2M6-BlhQ99Ty.js → oc-FR-POXYY2M6-k7bYbSQj.js} +1 -1
  79. package/dist/assets/{pa-IN-N4M65BXN-N2XbQgZ_.js → pa-IN-N4M65BXN-jxBFwrWj.js} +1 -1
  80. package/dist/assets/{pegDiagram-XKGWAZYB-C2iSJgYQ.js → pegDiagram-XKGWAZYB-zM-VZA3r.js} +1 -1
  81. package/dist/assets/{pica-DvYcrBvx.js → pica-CsWQ4DPU.js} +1 -1
  82. package/dist/assets/{pieDiagram-E7YTZNPT-CUjgOGBw.js → pieDiagram-E7YTZNPT-C60FE0D8.js} +1 -1
  83. package/dist/assets/{pl-PL-T2D74RX3-CnMxn1dA.js → pl-PL-T2D74RX3-be8atU_l.js} +1 -1
  84. package/dist/assets/{pt-BR-5N22H2LF-Di-jnHb3.js → pt-BR-5N22H2LF-CSE0O2fj.js} +1 -1
  85. package/dist/assets/{pt-PT-UZXXM6DQ-BaAKq8Sh.js → pt-PT-UZXXM6DQ-5rnYJhy1.js} +1 -1
  86. package/dist/assets/{quadrantDiagram-AXDQQJYC-DwwqgJXZ.js → quadrantDiagram-AXDQQJYC-DyH84hx6.js} +1 -1
  87. package/dist/assets/{railroadDiagram-O6MQD6OU-DyRgYGPF.js → railroadDiagram-O6MQD6OU-DCrJgP9s.js} +1 -1
  88. package/dist/assets/{requirementDiagram-BXWQKSXE-C3ixXeHJ.js → requirementDiagram-BXWQKSXE-C78-QlFo.js} +1 -1
  89. package/dist/assets/{ro-RO-JPDTUUEW-BWrclVyo.js → ro-RO-JPDTUUEW-Gh6EgC27.js} +1 -1
  90. package/dist/assets/{ru-RU-B4JR7IUQ-_z0DINaG.js → ru-RU-B4JR7IUQ-BUWESZhq.js} +1 -1
  91. package/dist/assets/{sankeyDiagram-P5KCCOFB-mKpKYI_w.js → sankeyDiagram-P5KCCOFB-D_MOkKEs.js} +1 -1
  92. package/dist/assets/{sequenceDiagram-WJ2MYXX4-ZkNd0Wnj.js → sequenceDiagram-WJ2MYXX4-BeQbHZRB.js} +1 -1
  93. package/dist/assets/{si-LK-N5RQ5JYF-CdKOb383.js → si-LK-N5RQ5JYF-C9pnvQMf.js} +1 -1
  94. package/dist/assets/{sizeCapture-INFHLROL-hQLGO-0z.js → sizeCapture-INFHLROL-DUn-Mus_.js} +1 -1
  95. package/dist/assets/{sk-SK-C5VTKIMK-MHJC6ZIe.js → sk-SK-C5VTKIMK-FnkPBibb.js} +1 -1
  96. package/dist/assets/{sl-SI-NN7IZMDC-BF9YWbZx.js → sl-SI-NN7IZMDC-Cwrqj_B9.js} +1 -1
  97. package/dist/assets/{stateDiagram-D77RDMKH-CRWj3j-B.js → stateDiagram-D77RDMKH-C3EF3jQ3.js} +1 -1
  98. package/dist/assets/stateDiagram-v2-MP3YSRHH-CVQHmIvK.js +1 -0
  99. package/dist/assets/{subset-shared.chunk-DtxXjVIA.js → subset-shared.chunk-8ifLcT_D.js} +1 -1
  100. package/dist/assets/{subset-worker.chunk-DONNSbUF.js → subset-worker.chunk-DrNTybDR.js} +1 -1
  101. package/dist/assets/{sv-SE-XGPEYMSR-DkaTkfUY.js → sv-SE-XGPEYMSR-Btz80pGx.js} +1 -1
  102. package/dist/assets/{swimlanes-42K2YHIH-CFf6j7jO.js → swimlanes-42K2YHIH-B2_kGhPA.js} +1 -1
  103. package/dist/assets/swimlanesDiagram-VR7AAH4N-C1rOmrkT.js +8 -0
  104. package/dist/assets/{ta-IN-2NMHFXQM-BfxqXEDI.js → ta-IN-2NMHFXQM-B0bWtgu1.js} +1 -1
  105. package/dist/assets/{th-TH-HPSO5L25-DT3vLA39.js → th-TH-HPSO5L25-DgC0yFw3.js} +1 -1
  106. package/dist/assets/{timeline-definition-24CTP7MA-BGP2Dq8M.js → timeline-definition-24CTP7MA-Bu0W3Mcy.js} +1 -1
  107. package/dist/assets/{tr-TR-DEFEU3FU-CdfsG7py.js → tr-TR-DEFEU3FU-C9Mmy6ri.js} +1 -1
  108. package/dist/assets/{uk-UA-QMV73CPH-CZrQuC1S.js → uk-UA-QMV73CPH-rxEnqB_i.js} +1 -1
  109. package/dist/assets/{vennDiagram-4TSXK5OY-CaxGPIab.js → vennDiagram-4TSXK5OY-63JTeOph.js} +1 -1
  110. package/dist/assets/{vi-VN-M7AON7JQ-DQJk1_KV.js → vi-VN-M7AON7JQ-DOVa-vAT.js} +1 -1
  111. package/dist/assets/{wardleyDiagram-VM6X3IG4-DQxQ-zXH.js → wardleyDiagram-VM6X3IG4-Bct0TRuC.js} +1 -1
  112. package/dist/assets/{xychartDiagram-S5SC5T6Z-DoxdZQ6R.js → xychartDiagram-S5SC5T6Z-C21zgvSM.js} +1 -1
  113. package/dist/assets/{zh-CN-LNUGB5OW-DRVBfkOy.js → zh-CN-LNUGB5OW-MyifsmQ8.js} +1 -1
  114. package/dist/assets/{zh-HK-E62DVLB3-BJHrltss.js → zh-HK-E62DVLB3-Cp55UViv.js} +1 -1
  115. package/dist/assets/{zh-TW-RAJ6MFWO-DpMZ5m2x.js → zh-TW-RAJ6MFWO-DMy6SZap.js} +1 -1
  116. package/dist/index.html +2 -2
  117. package/docs/BUNDLE-FORMAT.md +18 -5
  118. package/docs/DIAGRAM-SOURCE.md +59 -12
  119. package/docs/LOCAL-DOCUMENT.md +17 -14
  120. package/docs/MODEL-CONTRACT.md +7 -4
  121. package/docs/PLANTUML-SOURCE.md +3 -2
  122. package/docs/VIEWER-LAUNCH.md +13 -3
  123. package/docs/VIEWER.md +93 -26
  124. package/docs/capabilities.json +21 -3
  125. package/package.json +2 -1
  126. package/scripts/build-map.mjs +1 -1
  127. package/scripts/lib/map-viewer-server.mjs +48 -24
  128. package/scripts/lib/original-materials.mjs +1 -1
  129. package/scripts/lib/original-report-server.mjs +7 -3
  130. package/scripts/lib/project-catalog.mjs +14 -2
  131. package/scripts/lib/project-map-inputs.mjs +1 -1
  132. package/scripts/lib/sketch-publication.mjs +1 -1
  133. package/scripts/lib/task-map-build.mjs +1 -1
  134. package/scripts/lib/view-args.mjs +183 -0
  135. package/scripts/lib/workflow/reader-surface.mjs +29 -11
  136. package/scripts/locus-map.mjs +14 -20
  137. package/scripts/open-map.mjs +84 -49
  138. package/skills/README.md +2 -1
  139. package/skills/locus-map/SKILL.md +27 -25
  140. package/skills/locus-map/assets/artifact-handoff.md +2 -1
  141. package/skills/locus-map/references/build-environment.md +11 -7
  142. package/skills/locus-map/references/checks.md +16 -4
  143. package/skills/locus-map/references/component-checkpoint.md +35 -0
  144. package/skills/locus-map/references/draw-skill.md +2 -1
  145. package/skills/locus-map/references/selection.md +36 -13
  146. package/skills/locus-map/references/task-maps.md +5 -0
  147. package/skills/locus-map/references/visual-composition.md +69 -0
  148. package/skills/locus-map-draft/SKILL.md +95 -0
  149. package/skills/locus-map-draft/assets/chosen-direction.md +47 -0
  150. package/skills/locus-map-draft/references/divergence-and-formats.md +127 -0
  151. package/skills/locus-map-primitives/SKILL.md +6 -2
  152. package/skills/locus-map-primitives/references/card-presentation.md +57 -3
  153. package/skills/locus-map-primitives/references/reading-files.md +1 -1
  154. package/src/adapter/areas.js +1 -0
  155. package/src/adapter/semanticAdmission.js +118 -5
  156. package/src/authoring/buildDiagram.mjs +99 -19
  157. package/src/authoring/canvas-source-worker.mjs +96 -0
  158. package/src/authoring/canvasSource.mjs +41 -0
  159. package/src/authoring/diagramChecks.js +143 -1
  160. package/src/authoring/diagramSource.js +31 -5
  161. package/src/authoring/printPlantumlSource.js +13 -2
  162. package/src/authoring/readDetailsFiles.mjs +100 -19
  163. package/src/bundle/chain.js +129 -32
  164. package/src/bundle/chainBrowser.js +26 -2
  165. package/src/bundle/localDocument.mjs +87 -22
  166. package/src/bundle/localDocumentClient.js +5 -1
  167. package/src/bundle/projectClient.js +59 -18
  168. package/src/chain/validation.js +7 -1
  169. package/src/contract/readingMaterials.js +18 -2
  170. package/src/contract/readingTable.js +66 -0
  171. package/src/viewer/ControlIcon.jsx +1 -0
  172. package/src/viewer/DiagramViewer.jsx +70 -30
  173. package/src/viewer/EmbeddedExcalidrawEditor.jsx +305 -0
  174. package/src/viewer/HighlightOverlay.jsx +53 -25
  175. package/src/viewer/Inspector.jsx +109 -39
  176. package/src/viewer/ProjectRail.jsx +11 -5
  177. package/src/viewer/ProjectViewChainViewer.jsx +222 -70
  178. package/src/viewer/ReadingTable.jsx +151 -0
  179. package/src/viewer/SketchCanvas.jsx +15 -75
  180. package/src/viewer/ViewChainViewer.jsx +543 -52
  181. package/src/viewer/camera.js +50 -18
  182. package/src/viewer/chainEditorSession.js +160 -35
  183. package/src/viewer/chainInstallation.js +3 -3
  184. package/src/viewer/details/CanvasPreview.jsx +303 -0
  185. package/src/viewer/details/InspectorReadingSettings.jsx +50 -13
  186. package/src/viewer/details/ReadingFiles.jsx +32 -4
  187. package/src/viewer/details/details.css +65 -26
  188. package/src/viewer/diagramControls.css +1 -1
  189. package/src/viewer/fileError.js +53 -0
  190. package/src/viewer/geometry.js +12 -0
  191. package/src/viewer/inspectorPosition.js +54 -31
  192. package/src/viewer/readingTable.css +47 -0
  193. package/src/viewer/sketchSettling.js +71 -0
  194. package/src/viewer/useInspectorPosition.js +116 -35
  195. package/src/viewer/viewChain.css +40 -4
  196. package/src/viewer/viewer.css +23 -12
  197. package/dist/assets/channel-Dx9OTBrx.js +0 -1
  198. package/dist/assets/classDiagram-ZZMXUADV-Da4s894j.js +0 -1
  199. package/dist/assets/classDiagram-v2-VYDZK3BY--H9NrCfO.js +0 -1
  200. package/dist/assets/index-DBGHN_5E.js +0 -624
  201. package/dist/assets/stateDiagram-v2-MP3YSRHH-B2DcVJGG.js +0 -1
  202. package/dist/assets/swimlanesDiagram-VR7AAH4N-DO_W2uN2.js +0 -8
@@ -4,6 +4,60 @@ Run `locus-map doctor --json` and read `references/presentation-profiles.md` rel
4
4
  returned `drawSkillPath` URL. Compare the Draw specimens, then follow the chooser to its
5
5
  per-node appearance reference and icon catalog.
6
6
 
7
- Use `c4-modern-v2` for names above bracketed C4 metadata or `editorial-v4` for verb-led actions.
8
- Set `iconId` only when it literally disambiguates sibling nodes of the same role, up to 3–5 explicit icons per view.
9
- Leave `iconId` unset to use the profile's default glyph otherwise.
7
+ ## Select the profile by diagram role
8
+
9
+ | View purpose | Default profile | Opt-in / specialized alternative |
10
+ | --- | --- | --- |
11
+ | Standard C4 architecture (Context, Container, Component) | `c4-reference-v1` | `c4-modern-v2` only when colored modern C4 cards are explicitly chosen |
12
+ | Workflows, pipelines, roadmaps, grouped overviews | `editorial-v4` | `editorial-v2` for light compact cards |
13
+ | Canonical local task list (`locus-map build --tasks-dir`) | `task-card-v1` (single vertical column) | Simplified editorial profile for multi-column grouped task boards |
14
+
15
+ - Adhere strictly to canonical **`c4-reference-v1`** for standard C4 architecture overviews: use standard C4 roles and its built-in low-chroma palette (blue owned elements, cylinders for data stores, muted grey for external participants, dashed system boundaries) without ad-hoc pastel color overrides, decorative badges, or icon clutter. Use `c4-modern-v2` only when the user explicitly opts into colored modern C4 cards.
16
+ - Keep editorial boards **neutral by default**: reserve `accent` and `tone` (`negative`, `caution`, `positive`) for 1–3 high-signal cards, never as arbitrary decorative variety.
17
+ - On `editorial-v2` through `editorial-v4`, prefer `size: "extra-wide"` (420 units, PlantUML `$tags="extra-wide"`) for ordinary cards when titles wrap—especially in Russian or descriptive research views; on `c4-modern-v2` / `c4-reference-v1`, use `size: "wide"`. When parenthetical qualifiers would leave an awkward trailing orphan on a second title line, move them into `technology` (or `badge` on profiles that admit node appearance overrides; on canonical `c4-reference-v1`, shorten the title, use `technology` for a technology qualifier, or move detail to Inspector `details`), and check `TITLE_WRAP_WARNING` in `check.json`.
18
+ - On profiles that admit node appearance overrides (`editorial-v2`–`editorial-v4`, `c4-modern-v1`–`c4-modern-v2`; `c4-reference-v1` rejects node `iconId`, `shape`, `badge`, `tone`, and root `source.accent` with `PROFILE_KIND` and ignores PlantUML style overrides with `PLANTUML_STYLE_IGNORED`), set `iconId` only when it literally disambiguates sibling nodes of the same role, up to 3–5 explicit icons per view. Leave `iconId` unset to use the profile's default glyph otherwise.
19
+
20
+ ## Minimalist 3-slot card anatomy
21
+
22
+ Keep cards clean and immediately scannable by matching the profile's actual slots without stacking decorative metadata:
23
+
24
+ 1. **Standard C4 (`c4-reference-v1`)**: renders `«role»` stereotype above **`Title` (`label`)** → optional `[Technology]` → **Essence (`body`)** (plus claim status row only when non-current).
25
+ 2. **Editorial & modern C4 (`editorial-v4`, `c4-modern-v2`) — minimalist 3-slot layout**:
26
+ - **Title (`label`)**: recognizable entity, action, or task name. On multi-column grouped task boards, put the task ID directly in `label` (for example, `T-264 · Markdown grounding corpus`), not buried in a footer slot.
27
+ - **One role/metadata line**: either `[Type: Technology]` (`c4-modern-v2`) or one concise editorial `technology` subline (module, code anchor, key type, or single status/progress value). Never stack `iconId` + `badge` + `[Type: Tech]` + uppercase `tag` + `body` + status on the same card.
28
+ - **Essence (`body`)**: 1–3 short lines explaining what the element does or delivers. Move longer detail, full file paths, and edge cases to `details` (Inspector).
29
+ 3. **Canonical task list (`task-card-v1` via `--tasks-dir`)**: header metadata, complete title, description, and optional expected outcome.
30
+
31
+ ### Workflow card slot pattern
32
+
33
+ For code-backed step-by-step workflow and pipeline diagrams on editorial profiles (preferring `editorial-v4`), use this validated 3-slot structure (authored in the language the user requested):
34
+
35
+ 1. **Line 1 — Title (`label`)**: action-oriented step heading in the form `Step N · <action>` (for example, `Step 1 · Validate submission`, or localized `Шаг N · <действие>`).
36
+ 2. **Line 2 — Code anchor (`technology`)**: compact code-location slot in the form `Code: :module → File :: fn()` (or localized `Код: :module → File :: fn()`; in `.puml`, trailing `fn()` emits a benign `TEXT_PREVIEW_DIFFERS` warning while Draw/Map preserves the text literally).
37
+ 3. **Line 3+ — Details (`body`)**: 2–3 concise bullet lines using the **Unicode bullet `• ` (`\u2022 `)** (within the 240-character `body` limit; keep extended rationale and edge cases in Inspector `details`). Prefer `editorial-v4` (or set `size: "extra-wide"` / `$tags="extra-wide"` when bullets wrap), because standard-width `editorial-v2` and `editorial-v3` cap `body` at 3 rendered lines total and throw `CARD_TEXT_OVERFLOW` on a 4th wrapped line.
38
+
39
+ ```text
40
+ Step 1 · Validate submission
41
+ Code: :quiz-api → SubmitUseCase :: execute()
42
+ • Checks active attempt and deadline
43
+ • Rejects duplicate answers with 409
44
+ • Persists raw payload before scoring
45
+ ```
46
+
47
+ > **Plain-text bullet rule (`MARKUP` guard):** Never start a line in `body` (or other plain-text fields such as `page.notes` and `page.footer`) with ASCII `- `, `+ `, `* `, or numbered `1. `. In `locus-draw`'s `MARKUP` regex (`src/source/diagramSource.ts`), leading list markers trigger markup rejection and fail validation with `INVALID_TEXT`. Always use Unicode `• ` (`\u2022 ` or literal `• ` in `.map.json` / `.mjs`; literal UTF-8 `• ` in `.puml`, where `\u` escapes fail with `TEXT_ESCAPE_UNSUPPORTED`) for inline bullet lines inside card descriptions/body slots; Markdown `- ` lists belong only in Inspector `details`.
48
+
49
+ ## Restraint with tags, folded corners, and badges
50
+
51
+ - **Tags (`tag`)**: leave `tag` unset unless it carries a self-evident, uniform axis across cards (such as `STEP 1`, `STEP 2`). Avoid cryptic ALL-CAPS shorthand like `INPUT · TODAY` whose meaning cannot be inferred from the card.
52
+ - **Folded-corner document shape (`shape: "document"` / default `kind: "artifact"` styling)**: preserve source-backed semantics (`kind: "artifact"` stays `"artifact"` — never relabel an artifact as `kind: "component"` just to hide the corner). Instead, set `shape: "card"` on a profile that admits node appearance overrides, or choose a presentation that keeps a plain rectangular silhouette unless distinguishing physical documents/files from runtime components is load-bearing and explained in the legend and anatomy note.
53
+ - **Single status slot & badge discipline**: state status/priority/progress **once** — never duplicate the same state across `badge`, `technology`, and `tag` (for example, `planned · p1` + `Plan reviewed` + `PLAN READY`). In equal-width grids using `editorial-v4` or `c4-modern-v2`, avoid combining `badge` pills with varying title lengths: a badge stays inline next to short titles but drops onto a second line under slightly longer titles, breaking list rhythm.
54
+
55
+ ## Add a card-anatomy reading guide
56
+
57
+ Whenever a diagram uses non-trivial editorial cards, structured workflow slots, custom accents/tones, shapes, or dashed/solid border rules, add a compact reading guide explaining **what each card slot, shape, fill, and border means** — a shape list in `page.legend` alone does not explain card slots:
58
+
59
+ - **Non-trivial workflow diagrams (recommended):** add a small left-side or top-left **card-anatomy breakdown** note/block (titled in the user's language, for example `Card anatomy (how to read slots)` or localized `Разбор карточки (как читать слоты)`) so readers immediately understand the slot structure (`Step title → Code anchor → • detail bullets`) without guessing. On non-`readingTree` canvases, place this `page.notes` item (`LM_Note`) using a Draw-supported anchor and `• ` (never `- `) bullets:
60
+ - **Grid layout (`layout.mode: "grid"`):** use an unoccupied left/top-left row cell via `page.notes[].cell: [row, column]` (PlantUML `LM_Note(id, text, $place="cell:<row>,<column>")`, for example `[0, 0]`) inside a column `0` that also contains at least one node in another row — a dedicated note-only column fails with `LAYOUT_COVERAGE`.
61
+ - **Automatic or explicit layout (`auto` / `explicit`):** `cell` fails with `GRID_CELL_CONFLICT`, unattached `page.notes` always render in the full-width bottom block, and native PlantUML `note left` / `note top` still place below the node with `NOTE_PLACED_BELOW`. Either anchor `below: "<leftmostNodeId>"` (`LM_Note(id, text, $place="below:<node>")`) under a left/top-left card, or use `page.footer` when the guide needs predictable bottom placement.
62
+ - Keep every `page.notes` block outside all area contours — or set `area` to its enclosing area — and check area clearance on the rendered specimen so it never triggers `AREA_NOTE_BOUNDARY`.
63
+ - **Foldable `readingTree` views and compact bottom guides:** put the 1–2 line reading guide in **`page.footer`** near `page.legend` (for example: `Card anatomy: Title → Code anchor / Status → • Details · Dashed border = proposed`). Never use `page.notes` (`role: 'note'`) on foldable `readingTree` views because it disables foldable reading-tree projection in the viewer.
@@ -18,4 +18,4 @@ Choose an existing document the reader can read from beginning to end. If the re
18
18
 
19
19
  Select the node or arrow in View mode. Read any short author's note, followed immediately by the first assigned document. Review the final meaningful section in the Inspector. Additional materials open separately. Under the `productRoot` reported by `locus-map doctor --json`, see “Inspector reading order” in `docs/VIEWER.md`.
20
20
 
21
- Markdown renders headings, lists, code and tables. The raw Markdown disclosure includes the leading YAML. Embedded HTML shows static text, headings, tables and figures within the import limits. For a long or interactive report, state what the static reader can show and provide the original path. See “Package reading files with the diagram” in `docs/DIAGRAM-SOURCE.md` under the same product root for limits and supported image paths.
21
+ Markdown renders headings, lists, code and tables. The raw Markdown disclosure includes the leading YAML. Embedded HTML shows static text, headings, tables and figures within the import limits. You can also attach up to 16 canvas diagrams (`.locus-map.json`, `.excalidraw`, `.puml`, `.map.json`, or `.mjs` at depth 1), which render inline in the Inspector with full-screen pop-out editing and retain `sourcePaths` provenance when supplied. For a long or interactive report, state what the static reader can show and provide the original path. See “Package reading files with the diagram” in `docs/DIAGRAM-SOURCE.md` for limits, canvas source compilation rules, and supported image paths, and `docs/VIEWER.md` for inline preview and pop-out navigation behavior.
@@ -23,6 +23,7 @@ const mapParts = (parts) =>
23
23
  export const areaElementId = geometry.areaElementId;
24
24
  export const areaGroupId = geometry.areaGroupId;
25
25
  export const ROUTE_DETOUR_WARN_RATIO = geometry.ROUTE_DETOUR_WARN_RATIO;
26
+ export const ADJACENT_DETOUR_WARN_RATIO = geometry.ADJACENT_DETOUR_WARN_RATIO ?? 2.5;
26
27
  export const areaGeometry = geometry.areaGeometry;
27
28
  export const canonicalAutoAreaGeometries = (model, ...args) =>
28
29
  geometry.canonicalAutoAreaGeometries(presentationInput(model), ...args);
@@ -1,8 +1,8 @@
1
1
  import { isModernProfile, isTitleFirstProfile } from '@locus-forge/locus-draw/source';
2
2
  import { mappingVersionForView } from '../contract/documentVersions.js';
3
- import { handwrittenElement, hasHandwrittenText } from '@locus-forge/locus-draw/scene';
3
+ import { handwrittenElement, hasHandwrittenText, presentation as drawPresentation } from '@locus-forge/locus-draw/scene';
4
4
  import { inspectPresentation } from '@locus-forge/locus-draw/geometry';
5
- import { toDrawInput,decodeDrawSnapshot } from './drawProjection.js';
5
+ import { toDrawInput, decodeDrawSnapshot } from './drawProjection.js';
6
6
  import { ARCHIMATE_PROFILE, archimateModelDiagnostics } from '../contract/archimateNotation.js';
7
7
  import { STRUCTURE_PROFILE, SCENARIO_PROFILE, structureRoleDiagnostics, scenarioRoleDiagnostics } from '../contract/presentationProfile.js';
8
8
  import { isDiagramPresentationProfile, relationPresentation } from '../contract/diagramPresentation.js';
@@ -23,7 +23,7 @@ import { layoutModel, legacyCe6cadaGuideWidth, nodeSize } from './layout.js';
23
23
  import { containsBox, firstPointY, inspectCueLayout } from './layoutDiagnostics.js';
24
24
  import { createGuideSkeleton, guideTextSource, isGuideElement, legacyCe6cadaOriginalText, nodeGroupId, nodeShape, presentationStyle } from './presentation.js';
25
25
  import { parseAndValidate } from '../contract/index.js';
26
- import { areaSceneParts, areaStyle } from './areas.js';
26
+ import { areaElementId, areaSceneParts, areaStyle } from './areas.js';
27
27
  import { legendReferencedNodeIds, legendReferencedRelationIds, protectedSceneParts, sceneCardHatches, verifiedNodeGroupTranslation } from './page.js';
28
28
  import { edgeGroupId, relationLabelText } from './relationLabels.js';
29
29
  import { routeEntersBox } from './routeGeometry.js';
@@ -38,6 +38,8 @@ export { SEMANTIC_MAPPING_VERSION } from '../contract/documentVersions.js';
38
38
  const MAPPING_KEYS = ['kind', 'modelId', 'role', 'semanticId', 'version'];
39
39
  const NODE_ROLES = new Set(['shape', 'lifeline', 'name', 'type', 'tag', 'technology', 'responsibility', 'badge', 'outcome', 'outcome-rule', 'claim', 'icon-body', 'icon-detail', 'icon-tab', 'card-fold', 'badge-shape', 'icon-image', 'icon-badge', 'card-outline', 'card-cap', 'tag-shape', 'external']);
40
40
  const EDGE_ROLES = new Set(['arrow', 'label', 'label-mask']);
41
+ const AREA_HEADER_ROLES = new Set(['area-title', 'area-subtitle', 'area-note']);
42
+ const MAX_GRID_GAP = 240;
41
43
  const TIER_ROLES = ['type', 'tag', 'name', 'technology', 'responsibility', 'badge', 'outcome', 'claim', 'external'];
42
44
  const ICON_ROLES = ['icon-body', 'icon-detail', 'icon-tab', 'card-fold', 'badge-shape', 'icon-image', 'icon-badge', 'card-outline', 'card-cap', 'tag-shape', 'outcome-rule'];
43
45
  const active = element => element && !element.isDeleted;
@@ -461,9 +463,113 @@ export function inspectSavedSemanticScene(model, sceneOrElements, {
461
463
  return active(element) && ['rectangle', 'diamond', 'ellipse', 'line', 'freedraw'].includes(element.type)
462
464
  && paintOrder.get(element.id) < paintOrder.get(text.id) && paintedOpaqueFill(element) && containsBox(element, text);
463
465
  }).at(-1)?.backgroundColor ?? sceneBackground;
466
+ const collectAreaRowBounds = (areas, rootArea, cells) => {
467
+ const areaIds = new Set([rootArea?.id]);
468
+ const members = new Set(rootArea?.nodeIds ?? []);
469
+ const queue = [rootArea?.id];
470
+ while (queue.length) {
471
+ const currentId = queue.shift();
472
+ for (const candidate of areas) {
473
+ if (candidate?.parentId !== currentId || areaIds.has(candidate.id)) continue;
474
+ areaIds.add(candidate.id);
475
+ queue.push(candidate.id);
476
+ for (const nodeId of candidate.nodeIds ?? []) members.add(nodeId);
477
+ }
478
+ }
479
+ let minRow = Infinity;
480
+ let maxRow = -Infinity;
481
+ for (const nodeId of members) {
482
+ const cell = cells?.[nodeId];
483
+ if (Array.isArray(cell) && Number.isFinite(cell[0])) {
484
+ minRow = Math.min(minRow, cell[0]);
485
+ maxRow = Math.max(maxRow, cell[0]);
486
+ }
487
+ }
488
+ for (const note of model.page?.notes ?? []) {
489
+ if (areaIds.has(note?.area) && Array.isArray(note.cell) && Number.isFinite(note.cell[0])) {
490
+ minRow = Math.min(minRow, note.cell[0]);
491
+ maxRow = Math.max(maxRow, note.cell[0]);
492
+ }
493
+ }
494
+ return { minRow, maxRow };
495
+ };
496
+ let cachedEffectiveVerticalGap;
497
+ const effectiveVerticalGap = () => {
498
+ if (cachedEffectiveVerticalGap !== undefined) return cachedEffectiveVerticalGap;
499
+ if (Number.isFinite(model.layout?.grid?.gap?.[1])) {
500
+ cachedEffectiveVerticalGap = model.layout.grid.gap[1];
501
+ return cachedEffectiveVerticalGap;
502
+ }
503
+ try {
504
+ const sizes = new Map(model.nodes.map(node => [node.id, nodeSize(node, family, false, template)]));
505
+ const drawModel = { ...toDrawInput(model, { template, includeGuide: false }), presentationProfile: model.presentationProfile };
506
+ const resolved = drawPresentation.resolveGridLayout(drawModel, sizes);
507
+ if (Number.isFinite(resolved?.gap?.[1])) {
508
+ cachedEffectiveVerticalGap = resolved.gap[1];
509
+ return cachedEffectiveVerticalGap;
510
+ }
511
+ } catch { /* Fall back to profile default when grid layout cannot be resolved. */ }
512
+ cachedEffectiveVerticalGap = template.id === 'c4-reference-v1' ? 80 : 64;
513
+ return cachedEffectiveVerticalGap;
514
+ };
515
+ const gridAreaCollisionHint = (element, role, cover) => {
516
+ if (!AREA_HEADER_ROLES.has(role) || model.layout?.mode !== 'grid') return '';
517
+ const coverMapping = cover?.customData?.locusMap;
518
+ const isNodeCover = coverMapping?.kind === 'node' && coverMapping.role === 'shape';
519
+ const isAreaCover = coverMapping?.kind === 'page' && coverMapping.role === 'area-shape';
520
+ if (!isNodeCover && !isAreaCover) return '';
521
+ const cells = model.layout?.grid?.cells;
522
+ const area = protectedParts.get(element.id)?.area;
523
+ if (!area) return '';
524
+ const areas = Array.isArray(model.layout?.areas) ? model.layout.areas : [];
525
+ const areasById = new Map(areas.map(item => [item.id, item]));
526
+ const areaAncestors = new Set();
527
+ for (let cursor = area; cursor && !areaAncestors.has(cursor.id); cursor = areasById.get(cursor.parentId)) {
528
+ areaAncestors.add(cursor.id);
529
+ }
530
+ const { minRow: areaMinRow } = collectAreaRowBounds(areas, area, cells);
531
+ if (!Number.isFinite(areaMinRow)) return '';
532
+ let coverRow = -Infinity;
533
+ let coverArea;
534
+ if (isNodeCover) {
535
+ const coverCell = cells?.[coverMapping.semanticId];
536
+ if (!Array.isArray(coverCell) || !Number.isFinite(coverCell[0])) return '';
537
+ coverRow = coverCell[0];
538
+ coverArea = areas.find(candidate => candidate.nodeIds?.includes(coverMapping.semanticId));
539
+ } else {
540
+ coverArea = protectedParts.get(cover.id)?.area;
541
+ if (!coverArea || areaAncestors.has(coverArea.id)) return '';
542
+ coverRow = collectAreaRowBounds(areas, coverArea, cells).maxRow;
543
+ }
544
+ if (!(coverRow < areaMinRow)) return '';
545
+ const coverBottom = cover.y + cover.height;
546
+ if (!Number.isFinite(coverBottom)) return '';
547
+ const areaShape = byId.get(areaElementId(model, area.id, 'shape'));
548
+ if (!active(areaShape) || !Number.isFinite(areaShape.y)) {
549
+ return ` (grid row collision above area "${area.id}": separate the areas across rows)`;
550
+ }
551
+ const areaTop = areaShape.y;
552
+ let requiredIncrease = (coverBottom - areaTop) / (areaMinRow - coverRow);
553
+ for (let cursor = coverArea; cursor; cursor = areasById.get(cursor.parentId)) {
554
+ if (areaAncestors.has(cursor.id)) break;
555
+ const { maxRow: upperMaxRow } = collectAreaRowBounds(areas, cursor, cells);
556
+ if (!(upperMaxRow < areaMinRow)) continue;
557
+ const upperShape = byId.get(areaElementId(model, cursor.id, 'shape'));
558
+ if (active(upperShape) && Number.isFinite(upperShape.y) && Number.isFinite(upperShape.height)) {
559
+ requiredIncrease = Math.max(requiredIncrease, (upperShape.y + upperShape.height - areaTop) / (areaMinRow - upperMaxRow));
560
+ }
561
+ }
562
+ if (!(requiredIncrease > 0)) return '';
563
+ const minGap = Math.ceil(effectiveVerticalGap() + requiredIncrease);
564
+ if (minGap > MAX_GRID_GAP) {
565
+ return ` (grid row collision above area "${area.id}": separate the areas across rows; required vertical gap exceeds the ${MAX_GRID_GAP} px grid limit)`;
566
+ }
567
+ return ` (grid row collision above area "${area.id}": increase layout.grid.gap[1] to at least ${minGap} px, or separate the areas across rows)`;
568
+ };
464
569
  if (isDiagramPresentationProfile(template.id)) {
465
570
  const opaqueCovers = elements.filter(element => active(element) && paintedOpaqueFill(element)
466
571
  && ['rectangle', 'diamond', 'ellipse', 'line', 'freedraw'].includes(element.type));
572
+ const hintedPageElements = new Set();
467
573
  for (const element of elements) {
468
574
  const owner = element?.customData?.locusMap;
469
575
  if (!active(element) || !owner || owner.kind === 'page' && !protectedParts.has(element.id)
@@ -476,9 +582,11 @@ export function inspectSavedSemanticScene(model, sceneOrElements, {
476
582
  ? boxesOverlap(candidate, { ...element, width: Math.max(1, element.width), height: Math.max(1, element.height) }, 0)
477
583
  : containsBox(candidate, element)));
478
584
  if (!cover) continue;
585
+ const hint = owner.kind === 'page' ? gridAreaCollisionHint(element, owner.role, cover) : '';
586
+ if (hint) hintedPageElements.add(element.id);
479
587
  report(owner.kind === 'node' ? 'NODE_PART_HIDDEN' : owner.kind === 'page' ? 'PAGE_PART_HIDDEN'
480
588
  : owner.role === 'arrow' ? 'EDGE_HIDDEN' : 'EDGE_LABEL_HIDDEN', element,
481
- `Protected ${owner.kind} role ${owner.role} is fully painted behind opaque shape ${cover.id}.`);
589
+ `Protected ${owner.kind} role ${owner.role} is fully painted behind opaque shape ${cover.id}.${hint}`);
482
590
  }
483
591
  for (const [id, part] of protectedParts) {
484
592
  if (!part.mapped) continue;
@@ -490,7 +598,12 @@ export function inspectSavedSemanticScene(model, sceneOrElements, {
490
598
  && paintOrder.get(candidate.id) > paintOrder.get(element.id)
491
599
  && ((paintedObscuringFill(candidate) && (element.type === 'text' ? boxesOverlap(candidate, element) : containsBox(candidate, element)))
492
600
  || (element.type === 'text' ? strokeObscuresText(candidate, element) : strokeCoversBox(candidate, element))));
493
- if (cover) report('PAGE_PART_HIDDEN', element, `Protected page role ${part.role} is painted behind opaque shape or stroke ${cover.id}.`);
601
+ if (cover) {
602
+ const hint = !hintedPageElements.has(element.id) && paintedObscuringFill(cover)
603
+ ? gridAreaCollisionHint(element, part.role, cover)
604
+ : '';
605
+ report('PAGE_PART_HIDDEN', element, `Protected page role ${part.role} is painted behind opaque shape or stroke ${cover.id}.${hint}`);
606
+ }
494
607
  }
495
608
  }
496
609
  for (const node of model.nodes) {
@@ -34,12 +34,29 @@ function diagnosticsOf(error) {
34
34
  path: String(row.path ?? '/'),
35
35
  message: String(row.message ?? error.message),
36
36
  ...(row.severity === undefined ? {} : { severity: row.severity }),
37
+ ...(row.viewId === undefined ? {} : { viewId: row.viewId }),
37
38
  ...(row.ids === undefined ? {} : { ids: row.ids }),
38
39
  ...(row.sourcePath === undefined ? {} : { sourcePath: row.sourcePath, line: row.line, column: row.column }),
39
40
  }));
40
41
  return [{ code: String(error?.code ?? 'BUILD_FAILED'), path: '/', message: String(error?.message ?? 'Build failed.') }];
41
42
  }
42
43
 
44
+ function attributeChildFailure(error, name) {
45
+ const prefix = `/canvases/${name}`;
46
+ const diagnostics = diagnosticsOf(error).map(({ viewId, ...row }) => {
47
+ if (row.path === prefix || row.path.startsWith(`${prefix}/`)) return { ...row, severity: row.severity ?? 'error' };
48
+ const suffix = row.path !== '/' ? (row.path.startsWith('/') ? row.path : `/${row.path}`) : '';
49
+ const label = viewId ? `${name} · ${viewId}` : name;
50
+ return {
51
+ ...row,
52
+ severity: row.severity ?? 'error',
53
+ path: `${prefix}${viewId ? `/views/${viewId}` : ''}${suffix}`,
54
+ message: row.message.startsWith(`[${name}`) ? row.message : `[${label}] ${row.message}`,
55
+ };
56
+ });
57
+ return new MapAuthoringError(diagnostics);
58
+ }
59
+
43
60
  const diagnosticCheck = diagnostic => ({
44
61
  ...diagnostic, severity: diagnostic.severity ?? 'error', passed: false,
45
62
  ids: diagnostic.ids ?? [diagnostic.path], value: diagnostic.ids?.length ?? 1, limit: 0,
@@ -58,6 +75,41 @@ const mainPathMissing = checks => checks.some(row => row.code === 'MAIN_PATH_MIS
58
75
  + 'Declare LM_MainPath("entry ... result"), or record "Main path and roles: none — <reason>" in handoff.md for a view without one flow.',
59
76
  }] : [];
60
77
 
78
+ const DETOUR_RULES = {
79
+ EDGE_ROUTE_DETOUR: {
80
+ defaultLimit: 4,
81
+ describe: (ratio, maxRatio, ids) => `Relation detour exceeds ${ratio}× direct distance `
82
+ + `(max ${maxRatio}×; relations: ${ids}). `
83
+ + 'Inspect the rendered route for an unnecessary outer detour or obstructing header text before publishing.',
84
+ },
85
+ ADJACENT_EDGE_DETOUR: {
86
+ defaultLimit: 2.5,
87
+ describe: (ratio, maxRatio, ids) => `Adjacent relation detour exceeds ${ratio}× card gap or abandoned facing sides `
88
+ + `(max ${maxRatio}×; relations: ${ids}). `
89
+ + 'Inspect ports and intervening headers/obstacles before publishing.',
90
+ },
91
+ };
92
+
93
+ /** Surface excessive or adjacent route detours in diagnostics and stderr alongside MAIN_PATH_MISSING. */
94
+ export const routeDetours = checks => checks
95
+ .filter(row => Object.hasOwn(DETOUR_RULES, row.code) && !row.passed)
96
+ .map(row => {
97
+ const rule = DETOUR_RULES[row.code];
98
+ const ratio = row.limit?.maxRatio ?? rule.defaultLimit;
99
+ const maxRatio = row.value?.maxRatio ?? 'unknown';
100
+ const ids = row.ids?.length ? row.ids.join(', ') : 'unknown';
101
+ return {
102
+ code: row.code,
103
+ severity: 'warning',
104
+ path: row.ids?.length === 1 ? `/relations/${row.ids[0]}` : '/relations',
105
+ ids: row.ids ?? [],
106
+ message: rule.describe(ratio, maxRatio, ids),
107
+ };
108
+ });
109
+
110
+ const hasDiagnostic = (list, code, ids) => list.some(item =>
111
+ item.code === code && (ids === undefined || isDeepStrictEqual(item.ids, ids)));
112
+
61
113
  // A project generator can supply its emitted JSON in memory while sourcePath still identifies the input.
62
114
  export async function buildDiagram({ sourcePath, sourceText: emittedSource, outputDir, style, handwrittenCardFill, multiScreen = false, citationBindings, detailsFilesPath, chromiumPath, chromiumSource = 'api', timeoutMs = 90_000 }, {
63
115
  browserBuilder = runBrowserBuild,
@@ -84,7 +136,29 @@ export async function buildDiagram({ sourcePath, sourceText: emittedSource, outp
84
136
  throw error;
85
137
  }
86
138
  let { model, chain } = compiled;
87
- const materials = detailsFilesPath === undefined ? undefined : await readDetailsFiles(detailsFilesPath, model);
139
+ let browserResolution, selectedBrowser;
140
+ const ensureBrowser = () => browserResolution ??= Promise.resolve().then(async () => {
141
+ selectedBrowser = await browserResolver?.({ chromiumPath, source: chromiumSource });
142
+ return selectedBrowser;
143
+ });
144
+ const buildInBrowser = async (model, chain) => browserBuilder({
145
+ projectRoot, model, chain, staticDelivery: false, frameToViewport: true, style, handwrittenCardFill,
146
+ browser: await ensureBrowser(), chromiumPath, viewport: { width: 1600, height: 1000 }, timeoutMs,
147
+ });
148
+ const buildCanvas = async ({ name, model, chain }) => {
149
+ try {
150
+ const child = await buildInBrowser(model, chain);
151
+ admitBuiltDelivery(child, chain.views.map(view => view.id), { viewportFramed: true });
152
+ const errors = child.layoutDiagnostics.flatMap(row => row.diagnostics
153
+ .filter(item => item.code !== 'LABEL_NO_SLOT' && item.severity !== 'warning')
154
+ .map(item => ({ ...item, viewId: item.viewId ?? row.viewId, severity: item.severity ?? 'error' })));
155
+ if (errors.length) throw new MapAuthoringError(errors);
156
+ return { bundle: child.bundle };
157
+ } catch (error) {
158
+ throw attributeChildFailure(error, name);
159
+ }
160
+ };
161
+ const materials = detailsFilesPath === undefined ? undefined : await readDetailsFiles(detailsFilesPath, model, { deferCanvasBuilds: true });
88
162
  const withReadingFiles = candidate => materials ? parseAndValidate({
89
163
  ...candidate, assets: { ...candidate.assets, ...materials.metadata }, reading: materials.reading,
90
164
  }) : candidate;
@@ -96,7 +170,7 @@ export async function buildDiagram({ sourcePath, sourceText: emittedSource, outp
96
170
  const stage = await createOutputStage(out);
97
171
 
98
172
  const pngName = `${source.id}.png`, bundleName = `${source.id}.locus-map.json`;
99
- let selectedBrowser, browser, imageBuffer, published = false, publishing = false, checkRows = [];
173
+ let browser, imageBuffer, published = false, publishing = false, checkRows = [];
100
174
 
101
175
  const publishFailure = async (error, existingChecks = []) => {
102
176
  if (published) return;
@@ -122,19 +196,8 @@ export async function buildDiagram({ sourcePath, sourceText: emittedSource, outp
122
196
 
123
197
  try {
124
198
  if (emitSource) await writeFile(resolve(stage, 'source.map.json'), json(source));
125
- selectedBrowser = await browserResolver?.({ chromiumPath, source: chromiumSource });
126
- browser = structuredClone(await browserBuilder({
127
- projectRoot,
128
- model,
129
- chain,
130
- staticDelivery: false,
131
- frameToViewport: true,
132
- style, handwrittenCardFill,
133
- browser: selectedBrowser,
134
- chromiumPath,
135
- viewport: { width: 1600, height: 1000 },
136
- timeoutMs,
137
- }));
199
+ if (materials?.pendingCanvases.length) await materials.buildPendingCanvases(buildCanvas);
200
+ browser = structuredClone(await buildInBrowser(model, chain));
138
201
  const delivery = admitBuiltDelivery(browser, [viewId], { viewportFramed: true });
139
202
  imageBuffer = delivery.imageBuffers[viewId];
140
203
  const officialBrowser = delivery.reportedOfficial && browserBuilder === runBrowserBuild && browserRestorer === runBrowserRestore;
@@ -167,9 +230,11 @@ export async function buildDiagram({ sourcePath, sourceText: emittedSource, outp
167
230
  ]);
168
231
  }
169
232
 
170
- const pathDiagnostics = mainPathMissing(evaluation.checks);
171
- sourceDiagnostics.push(...legendDiagnostics, ...pathDiagnostics);
172
- for (const diagnostic of [...legendDiagnostics, ...pathDiagnostics]) onDiagnostic(diagnostic);
233
+ const postCheckDiagnostics = [
234
+ ...legendDiagnostics,
235
+ ...mainPathMissing(evaluation.checks),
236
+ ...routeDetours(evaluation.checks),
237
+ ];
173
238
 
174
239
  if (materials) {
175
240
  const original = await loadChainBundle(browser.bundle);
@@ -179,6 +244,7 @@ export async function buildDiagram({ sourcePath, sourceText: emittedSource, outp
179
244
  model = withReadingFiles(model);
180
245
  browser.bundle = await saveChainBundle({
181
246
  model, chain: original.chain, scenes: original.scenes, assets: new Map([...original.assets, ...materials.assets]),
247
+ ...(materials.canvases.size && { canvases: materials.canvases }),
182
248
  });
183
249
  }
184
250
  const stagedBundlePath = resolve(stage, bundleName);
@@ -203,6 +269,12 @@ export async function buildDiagram({ sourcePath, sourceText: emittedSource, outp
203
269
  code: 'BROWSER_RESTORE_CHANGED', path: '/browser/restore', message: JSON.stringify(comparison.views.filter(item => !item.matches)),
204
270
  }]);
205
271
 
272
+ // Defer warning emission until post-check restore succeeds so failures report each warning once via catch.
273
+ for (const diagnostic of postCheckDiagnostics) {
274
+ sourceDiagnostics.push(diagnostic);
275
+ onDiagnostic(diagnostic);
276
+ }
277
+
206
278
  evaluation.checks.push(
207
279
  { code: 'SEMANTIC_ADMISSION', severity: 'error', passed: true, ids: [viewId], value: true, limit: true },
208
280
  { code: 'BUNDLE_READBACK', severity: 'error', passed: true, ids: [viewId], value: true, limit: true },
@@ -238,7 +310,15 @@ export async function buildDiagram({ sourcePath, sourceText: emittedSource, outp
238
310
  // Once at the final boundary: routing attempts may each fail, but the missing path is one fact.
239
311
  const missing = mainPathMissing(checkRows);
240
312
  if (!published && missing.length && Array.isArray(error?.diagnostics)
241
- && !error.diagnostics.some(item => item.code === 'MAIN_PATH_MISSING')) error.diagnostics.push(...missing);
313
+ && !hasDiagnostic(sourceDiagnostics, 'MAIN_PATH_MISSING')
314
+ && !hasDiagnostic(error.diagnostics, 'MAIN_PATH_MISSING')) error.diagnostics.push(...missing);
315
+ for (const detour of routeDetours(checkRows)) {
316
+ if (!published && Array.isArray(error?.diagnostics)
317
+ && !hasDiagnostic(sourceDiagnostics, detour.code, detour.ids)
318
+ && !hasDiagnostic(error.diagnostics, detour.code, detour.ids)) {
319
+ error.diagnostics.push(detour);
320
+ }
321
+ }
242
322
  if (!publishing && !published) await publishFailure(error);
243
323
  throw error;
244
324
  } finally {
@@ -0,0 +1,96 @@
1
+ // Build-time .mjs sources run as trusted code in a Node subprocess with the builder's permissions.
2
+ import { writeSync } from 'node:fs';
3
+ import { BUNDLE_LIMITS } from '../bundle/safety.js';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { registerHooks } from 'node:module';
6
+ import { sourcePrimitives } from './sourceView.js';
7
+
8
+ const chunks = [];
9
+ for await (const chunk of process.stdin) chunks.push(chunk);
10
+ const { source } = JSON.parse(Buffer.concat(chunks).toString('utf8'));
11
+ const filePath = process.argv[2];
12
+ const url = pathToFileURL(filePath).href;
13
+ process.argv = [process.execPath, filePath];
14
+ registerHooks({
15
+ resolve(specifier, context, next) {
16
+ return specifier === url ? { url, shortCircuit: true } : next(specifier, context);
17
+ },
18
+ load(target, context, next) {
19
+ return target === url ? { format: 'module', source, shortCircuit: true } : next(target, context);
20
+ },
21
+ });
22
+ const pauseBuffer = new Int32Array(new SharedArrayBuffer(4));
23
+ const output = [];
24
+ let stdoutBytes = 0;
25
+ let overflowed = false;
26
+ let emitted = false;
27
+ let hasExport = false;
28
+ let exportResult;
29
+ const limitError = () => {
30
+ overflowed = true;
31
+ return new Error('Canvas source stdout exceeds the size limit.');
32
+ };
33
+ function writeAllSync(fd, data) {
34
+ let offset = 0;
35
+ while (offset < data.length) {
36
+ try { offset += writeSync(fd, data, offset, data.length - offset); }
37
+ catch (error) {
38
+ if (error.code === 'EAGAIN') { Atomics.wait(pauseBuffer, 0, 0, 1); continue; }
39
+ throw error;
40
+ }
41
+ }
42
+ }
43
+ const emitSync = payload => writeAllSync(1, Buffer.from(JSON.stringify(payload), 'utf8'));
44
+ const writeStderrSync = text => writeAllSync(2, Buffer.from(text, 'utf8'));
45
+ process.stdout.write = (chunk, encoding, cb) => {
46
+ const callback = typeof encoding === 'function' ? encoding : cb;
47
+ const charset = typeof encoding === 'string' ? encoding : undefined;
48
+ const bytes = typeof chunk === 'string' ? Buffer.from(chunk, charset) : Buffer.from(chunk);
49
+ stdoutBytes += bytes.byteLength;
50
+ if (stdoutBytes > BUNDLE_LIMITS.bundleBytes) throw limitError();
51
+ if (bytes.byteLength) output.push(bytes);
52
+ callback?.();
53
+ return true;
54
+ };
55
+ function finalize(code) {
56
+ const effectiveCode = process.exitCode !== undefined ? Number(process.exitCode) : code;
57
+ if (emitted || code !== 0 || effectiveCode !== 0) return;
58
+ if (overflowed) {
59
+ writeStderrSync('Canvas source stdout exceeds the size limit.\n');
60
+ process.exitCode = 1;
61
+ return;
62
+ }
63
+ try {
64
+ if (hasExport) {
65
+ emitted = true;
66
+ emitSync(exportResult);
67
+ return;
68
+ }
69
+ const text = new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(output));
70
+ if (!text.trim()) {
71
+ writeStderrSync('Canvas source module must export a diagram source or write schema-v1 JSON to stdout.\n');
72
+ process.exitCode = 1;
73
+ return;
74
+ }
75
+ emitted = true;
76
+ emitSync({ mode: 'cli', text });
77
+ } catch (error) {
78
+ writeStderrSync(`${error?.message || error}\n`);
79
+ process.exitCode = 1;
80
+ }
81
+ }
82
+ const rawEmit = process.emit.bind(process);
83
+ process.emit = (event, ...args) => {
84
+ const result = rawEmit(event, ...args);
85
+ if (event === 'exit') finalize(args[0]);
86
+ return result;
87
+ };
88
+
89
+ const mod = await import(url);
90
+ const plain = value => value && [Object.prototype, null].includes(Object.getPrototypeOf(value));
91
+ const author = typeof mod.default === 'function' || plain(mod.default) ? mod.default : mod.diagram ?? mod.source;
92
+ if (author !== undefined) {
93
+ exportResult = { mode: 'export', source: typeof author === 'function' ? await author(sourcePrimitives) : author };
94
+ hasExport = true;
95
+ }
96
+ if (stdoutBytes > BUNDLE_LIMITS.bundleBytes) throw limitError();
@@ -0,0 +1,41 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import { execFileBounded } from './boundedProcess.mjs';
3
+ import { compileDiagramSource, parseDiagramSourceText, validateDiagramSource } from './diagramSource.js';
4
+ import { parsePlantumlSource } from './plantumlSource.js';
5
+ import { locatePlantumlDiagnostics } from './plantumlSyntax.js';
6
+ import { MapAuthoringError } from './mapAuthoring.js';
7
+ import { BUNDLE_LIMITS } from '../bundle/safety.js';
8
+
9
+ const worker = fileURLToPath(new URL('./canvas-source-worker.mjs', import.meta.url));
10
+ const bounds = { timeoutMs: 20_000, maxBuffer: 16 * 1024 * 1024 };
11
+
12
+ export async function compileCanvasSourceFile({ filePath, bytes, sourceFormat }) {
13
+ let imported;
14
+ try {
15
+ if (bytes.byteLength > BUNDLE_LIMITS.bundleBytes) throw new Error('Canvas source exceeds the size limit.');
16
+ const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
17
+ let source;
18
+ if (sourceFormat === 'mjs') {
19
+ // Execute the admitted bytes once as trusted code in a Node subprocess with the builder's permissions.
20
+ const { stdout } = await execFileBounded(process.execPath, [worker, filePath], {
21
+ ...bounds, input: JSON.stringify({ source: text }),
22
+ });
23
+ if (!stdout.trim()) throw new Error('Canvas source module must export a diagram source or write schema-v1 JSON to stdout.');
24
+ const result = JSON.parse(stdout);
25
+ if (result?.mode === 'cli') source = parseDiagramSourceText(result.text);
26
+ else if (result?.mode === 'export') source = validateDiagramSource(result.source);
27
+ else throw new Error('Invalid canvas source worker result.');
28
+ } else if (sourceFormat === 'puml') {
29
+ imported = parsePlantumlSource(text, { sourcePath: filePath });
30
+ source = imported.source;
31
+ } else if (sourceFormat === 'map-json') {
32
+ source = parseDiagramSourceText(text);
33
+ } else throw new Error('Unsupported canvas source format.');
34
+ const { model, chain } = compileDiagramSource(source);
35
+ return { sourceFormat, source, model, chain, title: source.title || model.title };
36
+ } catch (error) {
37
+ if (imported && error.diagnostics) throw new MapAuthoringError(locatePlantumlDiagnostics(error.diagnostics, imported.locations, filePath));
38
+ if (error instanceof MapAuthoringError) throw error;
39
+ throw new MapAuthoringError([{ code: 'INVALID_DETAILS_FILE', path: filePath, message: error.stderr?.trim() || error.message }]);
40
+ }
41
+ }