@driftsys/markspec 0.10.3 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. package/README.md +2 -2
  2. package/esm/compiler/deserialize.d.ts +49 -0
  3. package/esm/compiler/deserialize.d.ts.map +1 -0
  4. package/esm/compiler/deserialize.js +139 -0
  5. package/esm/compiler/manifest.d.ts +3 -0
  6. package/esm/compiler/manifest.d.ts.map +1 -1
  7. package/esm/compiler/manifest.js +9 -3
  8. package/esm/compiler/mod.d.ts.map +1 -1
  9. package/esm/compiler/mod.js +16 -7
  10. package/esm/config/markspec.d.ts +38 -1
  11. package/esm/config/markspec.d.ts.map +1 -1
  12. package/esm/config/markspec.js +127 -2
  13. package/esm/config/mod.d.ts.map +1 -1
  14. package/esm/config/mod.js +143 -147
  15. package/esm/decl/duplicates.d.ts +29 -0
  16. package/esm/decl/duplicates.d.ts.map +1 -0
  17. package/esm/decl/duplicates.js +28 -0
  18. package/esm/decl/mod.d.ts +4 -2
  19. package/esm/decl/mod.d.ts.map +1 -1
  20. package/esm/decl/mod.js +2 -1
  21. package/esm/decl/surfaces.d.ts +29 -7
  22. package/esm/decl/surfaces.d.ts.map +1 -1
  23. package/esm/decl/surfaces.js +31 -18
  24. package/esm/gates/mod.d.ts +13 -2
  25. package/esm/gates/mod.d.ts.map +1 -1
  26. package/esm/gates/mod.js +38 -11
  27. package/esm/lint/runner.d.ts.map +1 -1
  28. package/esm/lint/runner.js +3 -1
  29. package/esm/lock/acquire_compile.d.ts +31 -0
  30. package/esm/lock/acquire_compile.d.ts.map +1 -0
  31. package/esm/lock/acquire_compile.js +83 -0
  32. package/esm/lock/cache_check.d.ts +28 -0
  33. package/esm/lock/cache_check.d.ts.map +1 -0
  34. package/esm/lock/cache_check.js +51 -0
  35. package/esm/lock/check.d.ts +14 -3
  36. package/esm/lock/check.d.ts.map +1 -1
  37. package/esm/lock/check.js +41 -3
  38. package/esm/lock/git_intent.d.ts +46 -0
  39. package/esm/lock/git_intent.d.ts.map +1 -0
  40. package/esm/lock/git_intent.js +111 -0
  41. package/esm/lock/mod.d.ts +10 -3
  42. package/esm/lock/mod.d.ts.map +1 -1
  43. package/esm/lock/mod.js +7 -1
  44. package/esm/lock/model.d.ts +24 -1
  45. package/esm/lock/model.d.ts.map +1 -1
  46. package/esm/lock/parser.d.ts.map +1 -1
  47. package/esm/lock/parser.js +32 -0
  48. package/esm/lock/pin_assurance.d.ts +20 -0
  49. package/esm/lock/pin_assurance.d.ts.map +1 -0
  50. package/esm/lock/pin_assurance.js +34 -0
  51. package/esm/lock/resolve.d.ts +8 -17
  52. package/esm/lock/resolve.d.ts.map +1 -1
  53. package/esm/lock/resolve.js +7 -67
  54. package/esm/lock/serializer.d.ts.map +1 -1
  55. package/esm/lock/serializer.js +23 -0
  56. package/esm/lock/upstream_common.d.ts +29 -0
  57. package/esm/lock/upstream_common.d.ts.map +1 -0
  58. package/esm/lock/upstream_common.js +38 -0
  59. package/esm/lock/upstream_deps.d.ts +63 -0
  60. package/esm/lock/upstream_deps.d.ts.map +1 -0
  61. package/esm/lock/upstream_deps.js +172 -0
  62. package/esm/lock/upstream_refs.d.ts +69 -0
  63. package/esm/lock/upstream_refs.d.ts.map +1 -0
  64. package/esm/lock/upstream_refs.js +238 -0
  65. package/esm/mod.d.ts +16 -8
  66. package/esm/mod.d.ts.map +1 -1
  67. package/esm/mod.js +15 -5
  68. package/esm/model/mod.d.ts +93 -28
  69. package/esm/model/mod.d.ts.map +1 -1
  70. package/esm/model/mod.js +66 -13
  71. package/esm/model/profile.d.ts +13 -0
  72. package/esm/model/profile.d.ts.map +1 -1
  73. package/esm/parser/markdown.d.ts.map +1 -1
  74. package/esm/parser/markdown.js +7 -51
  75. package/esm/profile/manifest.d.ts.map +1 -1
  76. package/esm/profile/manifest.js +20 -3
  77. package/esm/profile/merge.js +7 -0
  78. package/esm/reporter/mod.d.ts +11 -0
  79. package/esm/reporter/mod.d.ts.map +1 -1
  80. package/esm/reporter/mod.js +19 -8
  81. package/esm/typl/assemble.d.ts +53 -0
  82. package/esm/typl/assemble.d.ts.map +1 -0
  83. package/esm/typl/assemble.js +238 -0
  84. package/esm/typl/ast.d.ts +7 -1
  85. package/esm/typl/ast.d.ts.map +1 -1
  86. package/esm/typl/ast.js +3 -0
  87. package/esm/typl/bullet.d.ts +9 -7
  88. package/esm/typl/bullet.d.ts.map +1 -1
  89. package/esm/typl/bullet.js +6 -4
  90. package/esm/typl/citations.d.ts +27 -0
  91. package/esm/typl/citations.d.ts.map +1 -0
  92. package/esm/typl/citations.js +16 -0
  93. package/esm/typl/diagnostics.d.ts +2 -2
  94. package/esm/typl/diagnostics.d.ts.map +1 -1
  95. package/esm/typl/diagnostics.js +18 -0
  96. package/esm/typl/grammar.d.ts.map +1 -1
  97. package/esm/typl/grammar.js +6 -0
  98. package/esm/typl/lexer.d.ts.map +1 -1
  99. package/esm/typl/lexer.js +25 -4
  100. package/esm/typl/mod.d.ts +8 -2
  101. package/esm/typl/mod.d.ts.map +1 -1
  102. package/esm/typl/mod.js +5 -1
  103. package/esm/typl/recognize.js +2 -2
  104. package/esm/typl/registry.d.ts +1 -1
  105. package/esm/typl/resolve.d.ts +31 -0
  106. package/esm/typl/resolve.d.ts.map +1 -0
  107. package/esm/typl/resolve.js +27 -0
  108. package/esm/typl/table.d.ts +52 -0
  109. package/esm/typl/table.d.ts.map +1 -0
  110. package/esm/typl/table.js +69 -0
  111. package/esm/typl/validator.d.ts +24 -5
  112. package/esm/typl/validator.d.ts.map +1 -1
  113. package/esm/typl/validator.js +55 -75
  114. package/esm/upstream/mod.d.ts +45 -0
  115. package/esm/upstream/mod.d.ts.map +1 -0
  116. package/esm/upstream/mod.js +98 -0
  117. package/esm/upstream/project.d.ts +33 -0
  118. package/esm/upstream/project.d.ts.map +1 -0
  119. package/esm/upstream/project.js +38 -0
  120. package/esm/upstream/refs.d.ts +23 -0
  121. package/esm/upstream/refs.d.ts.map +1 -0
  122. package/esm/upstream/refs.js +71 -0
  123. package/esm/util/paths.d.ts +14 -0
  124. package/esm/util/paths.d.ts.map +1 -0
  125. package/esm/util/paths.js +22 -0
  126. package/esm/uxil/assemble.d.ts +38 -0
  127. package/esm/uxil/assemble.d.ts.map +1 -0
  128. package/esm/uxil/assemble.js +268 -0
  129. package/esm/uxil/ast.d.ts +63 -0
  130. package/esm/uxil/ast.d.ts.map +1 -0
  131. package/esm/uxil/ast.js +9 -0
  132. package/esm/uxil/citations.d.ts +27 -0
  133. package/esm/uxil/citations.d.ts.map +1 -0
  134. package/esm/uxil/citations.js +25 -0
  135. package/esm/uxil/diagnostics.d.ts +39 -0
  136. package/esm/uxil/diagnostics.d.ts.map +1 -0
  137. package/esm/uxil/diagnostics.js +135 -0
  138. package/esm/uxil/grammar.d.ts +72 -0
  139. package/esm/uxil/grammar.d.ts.map +1 -0
  140. package/esm/uxil/grammar.js +505 -0
  141. package/esm/uxil/lexer.d.ts +23 -0
  142. package/esm/uxil/lexer.d.ts.map +1 -0
  143. package/esm/uxil/lexer.js +58 -0
  144. package/esm/uxil/mod.d.ts +32 -0
  145. package/esm/uxil/mod.d.ts.map +1 -0
  146. package/esm/uxil/mod.js +11 -0
  147. package/esm/uxil/projection.d.ts +40 -0
  148. package/esm/uxil/projection.d.ts.map +1 -0
  149. package/esm/uxil/projection.js +41 -0
  150. package/esm/uxil/recognize.d.ts +16 -0
  151. package/esm/uxil/recognize.d.ts.map +1 -0
  152. package/esm/uxil/recognize.js +28 -0
  153. package/esm/uxil/registry.d.ts +37 -0
  154. package/esm/uxil/registry.d.ts.map +1 -0
  155. package/esm/uxil/registry.js +29 -0
  156. package/esm/uxil/surfaces.d.ts +36 -0
  157. package/esm/uxil/surfaces.d.ts.map +1 -0
  158. package/esm/uxil/surfaces.js +34 -0
  159. package/esm/uxil/validator.d.ts +36 -0
  160. package/esm/uxil/validator.d.ts.map +1 -0
  161. package/esm/uxil/validator.js +139 -0
  162. package/esm/uxil/vocab.d.ts +33 -0
  163. package/esm/uxil/vocab.d.ts.map +1 -0
  164. package/esm/uxil/vocab.js +36 -0
  165. package/esm/validator/caption_convention.d.ts +2 -1
  166. package/esm/validator/caption_convention.d.ts.map +1 -1
  167. package/esm/validator/caption_convention.js +2 -1
  168. package/esm/validator/corpus.d.ts.map +1 -1
  169. package/esm/validator/corpus.js +40 -17
  170. package/esm/validator/discipline.d.ts +6 -4
  171. package/esm/validator/discipline.d.ts.map +1 -1
  172. package/esm/validator/discipline.js +6 -4
  173. package/esm/validator/mod.d.ts.map +1 -1
  174. package/esm/validator/mod.js +28 -15
  175. package/esm/validator/pipeline.d.ts +11 -1
  176. package/esm/validator/pipeline.d.ts.map +1 -1
  177. package/esm/validator/pipeline.js +68 -18
  178. package/esm/validator/trace_types.d.ts +9 -2
  179. package/esm/validator/trace_types.d.ts.map +1 -1
  180. package/esm/validator/trace_types.js +21 -5
  181. package/esm/validator/traceability.d.ts +15 -3
  182. package/esm/validator/traceability.d.ts.map +1 -1
  183. package/esm/validator/traceability.js +39 -4
  184. package/esm/validator/types.d.ts.map +1 -1
  185. package/esm/validator/types.js +11 -1
  186. package/esm/validator/uxil_family.d.ts +43 -0
  187. package/esm/validator/uxil_family.d.ts.map +1 -0
  188. package/esm/validator/uxil_family.js +52 -0
  189. package/package.json +1 -1
  190. package/script/compiler/deserialize.d.ts +49 -0
  191. package/script/compiler/deserialize.d.ts.map +1 -0
  192. package/script/compiler/deserialize.js +144 -0
  193. package/script/compiler/manifest.d.ts +3 -0
  194. package/script/compiler/manifest.d.ts.map +1 -1
  195. package/script/compiler/manifest.js +10 -3
  196. package/script/compiler/mod.d.ts.map +1 -1
  197. package/script/compiler/mod.js +15 -6
  198. package/script/config/markspec.d.ts +38 -1
  199. package/script/config/markspec.d.ts.map +1 -1
  200. package/script/config/markspec.js +129 -3
  201. package/script/config/mod.d.ts.map +1 -1
  202. package/script/config/mod.js +143 -147
  203. package/script/decl/duplicates.d.ts +29 -0
  204. package/script/decl/duplicates.d.ts.map +1 -0
  205. package/script/decl/duplicates.js +31 -0
  206. package/script/decl/mod.d.ts +4 -2
  207. package/script/decl/mod.d.ts.map +1 -1
  208. package/script/decl/mod.js +4 -2
  209. package/script/decl/surfaces.d.ts +29 -7
  210. package/script/decl/surfaces.d.ts.map +1 -1
  211. package/script/decl/surfaces.js +32 -19
  212. package/script/gates/mod.d.ts +13 -2
  213. package/script/gates/mod.d.ts.map +1 -1
  214. package/script/gates/mod.js +37 -10
  215. package/script/lint/runner.d.ts.map +1 -1
  216. package/script/lint/runner.js +3 -1
  217. package/script/lock/acquire_compile.d.ts +31 -0
  218. package/script/lock/acquire_compile.d.ts.map +1 -0
  219. package/script/lock/acquire_compile.js +86 -0
  220. package/script/lock/cache_check.d.ts +28 -0
  221. package/script/lock/cache_check.d.ts.map +1 -0
  222. package/script/lock/cache_check.js +54 -0
  223. package/script/lock/check.d.ts +14 -3
  224. package/script/lock/check.d.ts.map +1 -1
  225. package/script/lock/check.js +41 -3
  226. package/script/lock/git_intent.d.ts +46 -0
  227. package/script/lock/git_intent.d.ts.map +1 -0
  228. package/script/lock/git_intent.js +115 -0
  229. package/script/lock/mod.d.ts +10 -3
  230. package/script/lock/mod.d.ts.map +1 -1
  231. package/script/lock/mod.js +16 -2
  232. package/script/lock/model.d.ts +24 -1
  233. package/script/lock/model.d.ts.map +1 -1
  234. package/script/lock/parser.d.ts.map +1 -1
  235. package/script/lock/parser.js +32 -0
  236. package/script/lock/pin_assurance.d.ts +20 -0
  237. package/script/lock/pin_assurance.d.ts.map +1 -0
  238. package/script/lock/pin_assurance.js +37 -0
  239. package/script/lock/resolve.d.ts +8 -17
  240. package/script/lock/resolve.d.ts.map +1 -1
  241. package/script/lock/resolve.js +7 -68
  242. package/script/lock/serializer.d.ts.map +1 -1
  243. package/script/lock/serializer.js +23 -0
  244. package/script/lock/upstream_common.d.ts +29 -0
  245. package/script/lock/upstream_common.d.ts.map +1 -0
  246. package/script/lock/upstream_common.js +42 -0
  247. package/script/lock/upstream_deps.d.ts +63 -0
  248. package/script/lock/upstream_deps.d.ts.map +1 -0
  249. package/script/lock/upstream_deps.js +175 -0
  250. package/script/lock/upstream_refs.d.ts +69 -0
  251. package/script/lock/upstream_refs.d.ts.map +1 -0
  252. package/script/lock/upstream_refs.js +244 -0
  253. package/script/mod.d.ts +16 -8
  254. package/script/mod.d.ts.map +1 -1
  255. package/script/mod.js +40 -7
  256. package/script/model/mod.d.ts +93 -28
  257. package/script/model/mod.d.ts.map +1 -1
  258. package/script/model/mod.js +70 -14
  259. package/script/model/profile.d.ts +13 -0
  260. package/script/model/profile.d.ts.map +1 -1
  261. package/script/parser/markdown.d.ts.map +1 -1
  262. package/script/parser/markdown.js +6 -50
  263. package/script/profile/manifest.d.ts.map +1 -1
  264. package/script/profile/manifest.js +20 -3
  265. package/script/profile/merge.js +7 -0
  266. package/script/reporter/mod.d.ts +11 -0
  267. package/script/reporter/mod.d.ts.map +1 -1
  268. package/script/reporter/mod.js +18 -7
  269. package/script/typl/assemble.d.ts +53 -0
  270. package/script/typl/assemble.d.ts.map +1 -0
  271. package/script/typl/assemble.js +241 -0
  272. package/script/typl/ast.d.ts +7 -1
  273. package/script/typl/ast.d.ts.map +1 -1
  274. package/script/typl/ast.js +3 -0
  275. package/script/typl/bullet.d.ts +9 -7
  276. package/script/typl/bullet.d.ts.map +1 -1
  277. package/script/typl/bullet.js +6 -4
  278. package/script/typl/citations.d.ts +27 -0
  279. package/script/typl/citations.d.ts.map +1 -0
  280. package/script/typl/citations.js +20 -0
  281. package/script/typl/diagnostics.d.ts +2 -2
  282. package/script/typl/diagnostics.d.ts.map +1 -1
  283. package/script/typl/diagnostics.js +18 -0
  284. package/script/typl/grammar.d.ts.map +1 -1
  285. package/script/typl/grammar.js +6 -0
  286. package/script/typl/lexer.d.ts.map +1 -1
  287. package/script/typl/lexer.js +25 -4
  288. package/script/typl/mod.d.ts +8 -2
  289. package/script/typl/mod.d.ts.map +1 -1
  290. package/script/typl/mod.js +14 -2
  291. package/script/typl/recognize.js +2 -2
  292. package/script/typl/registry.d.ts +1 -1
  293. package/script/typl/resolve.d.ts +31 -0
  294. package/script/typl/resolve.d.ts.map +1 -0
  295. package/script/typl/resolve.js +33 -0
  296. package/script/typl/table.d.ts +52 -0
  297. package/script/typl/table.d.ts.map +1 -0
  298. package/script/typl/table.js +75 -0
  299. package/script/typl/validator.d.ts +24 -5
  300. package/script/typl/validator.d.ts.map +1 -1
  301. package/script/typl/validator.js +55 -75
  302. package/script/upstream/mod.d.ts +45 -0
  303. package/script/upstream/mod.d.ts.map +1 -0
  304. package/script/upstream/mod.js +101 -0
  305. package/script/upstream/project.d.ts +33 -0
  306. package/script/upstream/project.d.ts.map +1 -0
  307. package/script/upstream/project.js +41 -0
  308. package/script/upstream/refs.d.ts +23 -0
  309. package/script/upstream/refs.d.ts.map +1 -0
  310. package/script/upstream/refs.js +74 -0
  311. package/script/util/paths.d.ts +14 -0
  312. package/script/util/paths.d.ts.map +1 -0
  313. package/script/util/paths.js +25 -0
  314. package/script/uxil/assemble.d.ts +38 -0
  315. package/script/uxil/assemble.d.ts.map +1 -0
  316. package/script/uxil/assemble.js +272 -0
  317. package/script/uxil/ast.d.ts +63 -0
  318. package/script/uxil/ast.d.ts.map +1 -0
  319. package/script/uxil/ast.js +10 -0
  320. package/script/uxil/citations.d.ts +27 -0
  321. package/script/uxil/citations.d.ts.map +1 -0
  322. package/script/uxil/citations.js +29 -0
  323. package/script/uxil/diagnostics.d.ts +39 -0
  324. package/script/uxil/diagnostics.d.ts.map +1 -0
  325. package/script/uxil/diagnostics.js +140 -0
  326. package/script/uxil/grammar.d.ts +72 -0
  327. package/script/uxil/grammar.d.ts.map +1 -0
  328. package/script/uxil/grammar.js +511 -0
  329. package/script/uxil/lexer.d.ts +23 -0
  330. package/script/uxil/lexer.d.ts.map +1 -0
  331. package/script/uxil/lexer.js +61 -0
  332. package/script/uxil/mod.d.ts +32 -0
  333. package/script/uxil/mod.d.ts.map +1 -0
  334. package/script/uxil/mod.js +37 -0
  335. package/script/uxil/projection.d.ts +40 -0
  336. package/script/uxil/projection.d.ts.map +1 -0
  337. package/script/uxil/projection.js +44 -0
  338. package/script/uxil/recognize.d.ts +16 -0
  339. package/script/uxil/recognize.d.ts.map +1 -0
  340. package/script/uxil/recognize.js +31 -0
  341. package/script/uxil/registry.d.ts +37 -0
  342. package/script/uxil/registry.d.ts.map +1 -0
  343. package/script/uxil/registry.js +32 -0
  344. package/script/uxil/surfaces.d.ts +36 -0
  345. package/script/uxil/surfaces.d.ts.map +1 -0
  346. package/script/uxil/surfaces.js +39 -0
  347. package/script/uxil/validator.d.ts +36 -0
  348. package/script/uxil/validator.d.ts.map +1 -0
  349. package/script/uxil/validator.js +142 -0
  350. package/script/uxil/vocab.d.ts +33 -0
  351. package/script/uxil/vocab.d.ts.map +1 -0
  352. package/script/uxil/vocab.js +41 -0
  353. package/script/validator/caption_convention.d.ts +2 -1
  354. package/script/validator/caption_convention.d.ts.map +1 -1
  355. package/script/validator/caption_convention.js +2 -1
  356. package/script/validator/corpus.d.ts.map +1 -1
  357. package/script/validator/corpus.js +39 -16
  358. package/script/validator/discipline.d.ts +6 -4
  359. package/script/validator/discipline.d.ts.map +1 -1
  360. package/script/validator/discipline.js +6 -4
  361. package/script/validator/mod.d.ts.map +1 -1
  362. package/script/validator/mod.js +27 -14
  363. package/script/validator/pipeline.d.ts +11 -1
  364. package/script/validator/pipeline.d.ts.map +1 -1
  365. package/script/validator/pipeline.js +67 -17
  366. package/script/validator/trace_types.d.ts +9 -2
  367. package/script/validator/trace_types.d.ts.map +1 -1
  368. package/script/validator/trace_types.js +20 -4
  369. package/script/validator/traceability.d.ts +15 -3
  370. package/script/validator/traceability.d.ts.map +1 -1
  371. package/script/validator/traceability.js +38 -3
  372. package/script/validator/types.d.ts.map +1 -1
  373. package/script/validator/types.js +10 -0
  374. package/script/validator/uxil_family.d.ts +43 -0
  375. package/script/validator/uxil_family.d.ts.map +1 -0
  376. package/script/validator/uxil_family.js +56 -0
package/esm/gates/mod.js CHANGED
@@ -20,7 +20,7 @@
20
20
  import { format } from "../formatter/mod.js";
21
21
  import { parseFile } from "../parser/mod.js";
22
22
  import { buildRefIndex, canonicalizeRefs } from "../refs/mod.js";
23
- import { detectOfflineEdgeDrift, } from "../lock/mod.js";
23
+ import { detectOfflineEdgeDrift, verifyUpstreamCache, } from "../lock/mod.js";
24
24
  import { runLint } from "../lint/mod.js";
25
25
  /**
26
26
  * Format-drift gate — the `MSL-F010` (formatter drift) and `MSL-F011`
@@ -50,7 +50,8 @@ export async function fmtDriftGate(mdContents, entries, ledger, formatMarkdownPr
50
50
  // Building the heal index over the full set (including corpus) would flag an
51
51
  // MSL-F011 drift that `fmt` can never fix — a permanently red gate for any
52
52
  // consumer using a delivered corpus. Filter to `!e.origin`, mirroring
53
- // lockfileDriftGate.
53
+ // lockfileDriftGate — deliberately BROADER than the validators'
54
+ // `emittableEntries` (upstream-only, #771); do not "unify" it.
54
55
  const refIndex = buildRefIndex(entries.filter((e) => !e.origin));
55
56
  for (const [filePath, content] of mdContents) {
56
57
  const formatted = format(content, {
@@ -93,25 +94,51 @@ export async function fmtDriftGate(mdContents, entries, ledger, formatMarkdownPr
93
94
  * re-lock. The gate therefore filters to project-owned entries (`!e.origin`),
94
95
  * mirroring `markspec lock`.
95
96
  *
97
+ * Also carries the MSL-L212 offline cache-drift case (Task 9): when `cache`
98
+ * is supplied and the lockfile parsed, every snapshot-carrying upstream row
99
+ * is verified against its on-disk cache under `cache.cacheRoot` and any
100
+ * cache-drift diagnostics are appended to the edge-drift result. Offline by
101
+ * design, like the edge-drift check — no network fetch.
102
+ *
96
103
  * @param lockParse The parsed `markspec.lock` (already read from disk).
97
104
  * @param lockPath Absolute path to `markspec.lock`, used as the diagnostic
98
105
  * location so JSON consumers that group by `location.file` keep the finding.
99
106
  * @param entries The full parsed entry set; corpus entries are filtered out.
107
+ * @param cache Optional upstream cache-verification inputs. Omitted →
108
+ * backward-compatible with callers that only want the edge-drift case.
100
109
  */
101
- export async function lockfileDriftGate(lockParse, lockPath, entries) {
110
+ export async function lockfileDriftGate(lockParse, lockPath, entries, cache) {
102
111
  if (!lockParse.lockfile) {
103
112
  return [...lockParse.diagnostics];
104
113
  }
114
+ // `!e.origin` (project-owned only) — deliberately BROADER than the
115
+ // validators' `emittableEntries` partition (upstream-only, #771): the
116
+ // edge ledger records only edges the project authors.
105
117
  const projectEntries = entries.filter((e) => !e.origin);
106
118
  const drift = await detectOfflineEdgeDrift(projectEntries, lockParse.lockfile.generatedCache);
107
- if (!drift.drifted)
108
- return [];
109
- return [{
110
- code: "MSL-L212",
111
- severity: "error",
112
- message: `traceability edges drifted from markspec.lock: locked ${drift.lockedCount} edge(s), current ${drift.currentCount} — run \`markspec lock\` to refresh. (After upgrading MarkSpec this can also fire once because traceability inputs now include source-file doc comments; re-running \`markspec lock\` clears it.)`,
113
- location: { file: lockPath, line: 1, column: 1 },
114
- }];
119
+ const diagnostics = drift.drifted
120
+ ? [{
121
+ code: "MSL-L212",
122
+ severity: "error",
123
+ message: `traceability edges drifted from markspec.lock: locked ${drift.lockedCount} edge(s), current ${drift.currentCount} — run \`markspec lock\` to refresh. (After upgrading MarkSpec this can also fire once because traceability inputs now include source-file doc comments; re-running \`markspec lock\` clears it.)`,
124
+ location: { file: lockPath, line: 1, column: 1 },
125
+ }]
126
+ : [];
127
+ if (cache !== undefined) {
128
+ const cacheDiags = await verifyUpstreamCache(lockParse.lockfile.upstreams, cache.cacheRoot, cache.readFile);
129
+ // verifyUpstreamCache is a reusable, lockfile-path-agnostic probe and
130
+ // emits `location: undefined` (see cache_check.ts). Stamp the same
131
+ // lockfile location the sibling edge-drift MSL-L212 above uses, so both
132
+ // findings from the same `markspec.lock` group under one file for a
133
+ // JSON consumer keyed on `location.file`.
134
+ for (const d of cacheDiags) {
135
+ diagnostics.push({
136
+ ...d,
137
+ location: { file: lockPath, line: 1, column: 1 },
138
+ });
139
+ }
140
+ }
141
+ return diagnostics;
115
142
  }
116
143
  /**
117
144
  * Prose-lint gate — the advisory `MSL-Q` prose-analysis findings, projected to
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/lint/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAUjD,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AAY/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgB9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAKT;AAMD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,6EAA6E;IAC7E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,yEAAyE;IACzE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA0FvE"}
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/lint/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAUjD,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AAY/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgB9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAKT;AAMD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,6EAA6E;IAC7E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,yEAAyE;IACzE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA4FvE"}
@@ -116,7 +116,9 @@ export async function runLint(options) {
116
116
  // Steps 1–9: collect diagnostics keyed by entry. Delivered-corpus entries
117
117
  // (`entry.origin`) are excluded from rule execution — a consumer cannot fix
118
118
  // upstream prose (ADR-030 §D4) — even though they contribute to the indexes
119
- // above.
119
+ // above. Deliberately BROADER than the validators' `emittableEntries`
120
+ // partition (upstream-only, #771): profile corpus stays structurally
121
+ // validated but is never prose-linted — do not "unify" this filter.
120
122
  const inScopeDiags = new Map();
121
123
  for (const entry of entries) {
122
124
  if (entry.origin)
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @module core/lock/acquire_compile
3
+ *
4
+ * Deterministic in-process compile of an acquired dependency tree
5
+ * (design §4.3). Produces the same `manifest.json` + `compiled.json` layout
6
+ * a published `references:` site serves, so `loadUpstreamCorpus` /
7
+ * `probeCacheSnapshot` read a dependency snapshot identically to a reference
8
+ * snapshot. The output is byte-reproducible from (tree, markspec version):
9
+ * files are compiled in sorted, tree-relative order with no stat/git IO, so
10
+ * `entry.location.file`, `properties.file.path`, and entry ordering are all
11
+ * stable. Pure — every file touch flows through {@linkcode AcquireCompileIO}.
12
+ */
13
+ import { type ManifestJson } from "../compiler/manifest.js";
14
+ import { type DiscoveryIO } from "../discovery/mod.js";
15
+ export interface AcquireCompileIO {
16
+ /** Config/profile reader — returns text or undefined (core `ReadFile`). */
17
+ readonly readFile: (path: string) => Promise<string | undefined>;
18
+ /** Throwing reader compile() consumes (`(path) => Promise<string>`). */
19
+ readonly readText: (path: string) => Promise<string>;
20
+ /** Discovery seam (`{ readDir, readFile }`) — same as `denoDiscoveryIO()`. */
21
+ readonly discovery: DiscoveryIO;
22
+ }
23
+ export interface CompiledSnapshot {
24
+ readonly manifestJson: ManifestJson;
25
+ readonly compiledBytes: Uint8Array;
26
+ readonly snapshot: string;
27
+ }
28
+ export declare function compileAcquiredTree(treeRoot: string, io: AcquireCompileIO, release: string): Promise<CompiledSnapshot | {
29
+ error: string;
30
+ }>;
31
+ //# sourceMappingURL=acquire_compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acquire_compile.d.ts","sourceRoot":"","sources":["../../src/lock/acquire_compile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK3E,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGtE,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACjE,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,gBAAgB,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CA0E/C"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @module core/lock/acquire_compile
3
+ *
4
+ * Deterministic in-process compile of an acquired dependency tree
5
+ * (design §4.3). Produces the same `manifest.json` + `compiled.json` layout
6
+ * a published `references:` site serves, so `loadUpstreamCorpus` /
7
+ * `probeCacheSnapshot` read a dependency snapshot identically to a reference
8
+ * snapshot. The output is byte-reproducible from (tree, markspec version):
9
+ * files are compiled in sorted, tree-relative order with no stat/git IO, so
10
+ * `entry.location.file`, `properties.file.path`, and entry ordering are all
11
+ * stable. Pure — every file touch flows through {@linkcode AcquireCompileIO}.
12
+ */
13
+ import { join, relative } from "@std/path";
14
+ import { compile } from "../compiler/mod.js";
15
+ import { buildManifest } from "../compiler/manifest.js";
16
+ import { serializeCompileResult } from "../compiler/schema.js";
17
+ import { loadConfig } from "../config/mod.js";
18
+ import { loadToolConfig } from "../config/markspec.js";
19
+ import { loadProfileForCommand } from "../profile/load.js";
20
+ import { discoverFiles } from "../discovery/mod.js";
21
+ import { sha256Bytes } from "./hash.js";
22
+ export async function compileAcquiredTree(treeRoot, io, release) {
23
+ // Memoize by path: loadConfig, loadProfileForCommand, and loadToolConfig
24
+ // each walk + read the same project.yaml/.markspec.yaml, so cache the
25
+ // in-flight promise per path to read each file exactly once per acquired
26
+ // tree. The tree is immutable (just fetched at a fixed sha), so a
27
+ // per-call cache is sound and deterministic.
28
+ const readCache = new Map();
29
+ const readFile = (path) => {
30
+ let pending = readCache.get(path);
31
+ if (pending === undefined) {
32
+ pending = io.readFile(path);
33
+ readCache.set(path, pending);
34
+ }
35
+ return pending;
36
+ };
37
+ const configResult = await loadConfig(treeRoot, readFile);
38
+ if (!configResult) {
39
+ return { error: "dependency tree has no discoverable project.yaml" };
40
+ }
41
+ const profileResult = await loadProfileForCommand(treeRoot, readFile);
42
+ const profile = profileResult.chain?.effective;
43
+ const toolConfig = await loadToolConfig(treeRoot, readFile);
44
+ // Discover → relativize → normalize to POSIX separators → sort. The
45
+ // `\\`→`/` normalization is load-bearing for cross-machine determinism:
46
+ // `relative()` yields OS-native separators, so a Windows host would emit
47
+ // `docs\reqs.md` while POSIX emits `docs/reqs.md`, giving two different
48
+ // `location.file`/`properties.file.path` values → two different snapshot
49
+ // hashes for the same source → spurious MSL-L212 drift between a Windows
50
+ // and a macOS/Linux developer sharing one lockfile. Normalizing before
51
+ // the sort also makes the entry order (hence JSON key order) identical
52
+ // on every platform.
53
+ const abs = [];
54
+ for await (const f of discoverFiles(treeRoot, io.discovery, {
55
+ exclude: toolConfig.config.exclude,
56
+ })) {
57
+ abs.push(f);
58
+ }
59
+ const rel = abs
60
+ .map((p) => relative(treeRoot, p).replaceAll("\\", "/"))
61
+ .sort();
62
+ // Compile with a root-resolving reader and NO stat/git callbacks →
63
+ // deterministic properties (no mtime, no contributors, relative path).
64
+ const result = await compile(rel, {
65
+ readFile: (r) => io.readText(join(treeRoot, r)),
66
+ profile,
67
+ });
68
+ // `root` is cosmetic here — manifest.json is not hashed (only compiled.json
69
+ // is) and lives in the gitignored cache; pass "." so no temp path leaks.
70
+ const manifestJson = buildManifest(result, configResult.config, ".", profile, release, false);
71
+ // Compact (no whitespace) rather than the CLI's pretty-printed form —
72
+ // this cache file is machine-read only (loadUpstreamCorpus /
73
+ // probeCacheSnapshot JSON.parse it), and compact output keeps
74
+ // `entry.location.file`'s tree-relative path adjacent to its `"file":`
75
+ // key with no formatting-introduced variance to reason about.
76
+ const compiled = serializeCompileResult(result);
77
+ const compiledBytes = new TextEncoder().encode(JSON.stringify(compiled));
78
+ return {
79
+ manifestJson,
80
+ compiledBytes,
81
+ snapshot: await sha256Bytes(compiledBytes),
82
+ };
83
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @module core/lock/cache_check
3
+ *
4
+ * Offline upstream cache-integrity check — the MSL-L212 cache-drift case
5
+ * (Task 9). For every locked upstream row that carries a `snapshot` hash
6
+ * (a federated registry or git-repository dependency), verify its cache
7
+ * under `<cacheRoot>/<id>/` is still present and hash-intact.
8
+ *
9
+ * Reuses {@linkcode probeCacheSnapshot} — the exact probe
10
+ * `resolveProjectReferences`'s keep/restore flow already uses
11
+ * (`upstream_refs.ts`, Task 5) — so `markspec check` and `markspec lock`
12
+ * never disagree on what "cache intact" means. Rows without a `snapshot`
13
+ * (legacy registry rows predating this field, or upstream kinds that never
14
+ * carry one — reference, profile) are skipped: there is nothing to verify
15
+ * offline.
16
+ *
17
+ * Pure module: file access only via the injected {@linkcode ReadFile}.
18
+ */
19
+ import type { Diagnostic } from "../model/mod.js";
20
+ import type { Upstream } from "./model.js";
21
+ import type { ReadFile } from "./resolve.js";
22
+ /**
23
+ * Verify every snapshot-carrying upstream row's cache under `cacheRoot`.
24
+ * One `MSL-L212` diagnostic per row whose cache is missing or whose
25
+ * entries-file hash no longer matches the locked `snapshot`.
26
+ */
27
+ export declare function verifyUpstreamCache(upstreams: readonly Upstream[], cacheRoot: string, readFile: ReadFile): Promise<Diagnostic[]>;
28
+ //# sourceMappingURL=cache_check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache_check.d.ts","sourceRoot":"","sources":["../../src/lock/cache_check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAa7C;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,SAAS,QAAQ,EAAE,EAC9B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,UAAU,EAAE,CAAC,CAevB"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @module core/lock/cache_check
3
+ *
4
+ * Offline upstream cache-integrity check — the MSL-L212 cache-drift case
5
+ * (Task 9). For every locked upstream row that carries a `snapshot` hash
6
+ * (a federated registry or git-repository dependency), verify its cache
7
+ * under `<cacheRoot>/<id>/` is still present and hash-intact.
8
+ *
9
+ * Reuses {@linkcode probeCacheSnapshot} — the exact probe
10
+ * `resolveProjectReferences`'s keep/restore flow already uses
11
+ * (`upstream_refs.ts`, Task 5) — so `markspec check` and `markspec lock`
12
+ * never disagree on what "cache intact" means. Rows without a `snapshot`
13
+ * (legacy registry rows predating this field, or upstream kinds that never
14
+ * carry one — reference, profile) are skipped: there is nothing to verify
15
+ * offline.
16
+ *
17
+ * Pure module: file access only via the injected {@linkcode ReadFile}.
18
+ */
19
+ import { join } from "@std/path";
20
+ import { probeCacheSnapshot } from "./upstream_refs.js";
21
+ function cacheDriftDiagnostic(id) {
22
+ return {
23
+ code: "MSL-L212",
24
+ severity: "error",
25
+ message: `upstream '${id}' cache snapshot is missing or does not match markspec.lock — run 'markspec lock'`,
26
+ location: undefined,
27
+ };
28
+ }
29
+ /**
30
+ * Verify every snapshot-carrying upstream row's cache under `cacheRoot`.
31
+ * One `MSL-L212` diagnostic per row whose cache is missing or whose
32
+ * entries-file hash no longer matches the locked `snapshot`.
33
+ */
34
+ export async function verifyUpstreamCache(upstreams, cacheRoot, readFile) {
35
+ const diagnostics = [];
36
+ for (const upstream of upstreams) {
37
+ if (upstream.kind !== "registry" && upstream.kind !== "dependency") {
38
+ continue; // references/profiles never carry a cache snapshot
39
+ }
40
+ if (upstream.snapshot === undefined)
41
+ continue; // legacy row — skip
42
+ // join() at construction (#771): a template concat would mix the
43
+ // platform separator with a literal `/` — the Windows drift class
44
+ // that bit slices 2 and 4. Writer and reader must agree byte-for-byte.
45
+ const dir = join(cacheRoot, upstream.id);
46
+ const intact = await probeCacheSnapshot(dir, upstream.snapshot, readFile);
47
+ if (!intact)
48
+ diagnostics.push(cacheDriftDiagnostic(upstream.id));
49
+ }
50
+ return diagnostics;
51
+ }
@@ -6,11 +6,18 @@
6
6
  * category. Pure function — no I/O.
7
7
  *
8
8
  * Drift categories:
9
- * - MSL-L202 — upstream in resolved but missing from lockfile
10
- * - MSL-L203 — upstream in lockfile but missing from resolved
9
+ * - MSL-L202 — upstream in resolved but missing from lockfile (also:
10
+ * a declared reference with no lockfile registry row)
11
+ * - MSL-L203 — upstream in lockfile but missing from resolved (also:
12
+ * a locked registry row no longer declared in project.yaml)
11
13
  * - MSL-L210 — hash mismatch (same identity, different bytes)
12
14
  * - MSL-L211 — profile resolved-version drift (npm range now resolves a different exact version)
13
15
  * - MSL-L212 — canonical edge hash drift (traceability graph changed)
16
+ *
17
+ * Federated registry rows (org `references:`) are checked by pure
18
+ * id-presence against `declaredReferenceIds` — no hash comparison.
19
+ * Content integrity for those rows is the offline cache gate (a later
20
+ * task), not this online-vs-lockfile comparison.
14
21
  */
15
22
  import type { Diagnostic } from "../model/mod.js";
16
23
  import type { Lockfile } from "./model.js";
@@ -19,6 +26,10 @@ import type { ResolvedUpstreams } from "./resolve.js";
19
26
  * Compare locked vs resolved upstreams; return one diagnostic per drift
20
27
  * case. An empty result means the lockfile is in sync with the current
21
28
  * project state.
29
+ *
30
+ * @param declaredReferenceIds - Upstream ids derived from
31
+ * `config.references` (via `deriveUpstreamId`) — the id-presence
32
+ * comparison set for federated registry rows.
22
33
  */
23
- export declare function checkDrift(locked: Lockfile, resolved: ResolvedUpstreams): Diagnostic[];
34
+ export declare function checkDrift(locked: Lockfile, resolved: ResolvedUpstreams, declaredReferenceIds: readonly string[]): Diagnostic[];
24
35
  //# sourceMappingURL=check.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/lock/check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAsC,MAAM,YAAY,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,iBAAiB,GAC1B,UAAU,EAAE,CAyHd"}
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/lock/check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EACV,QAAQ,EAIT,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,iBAAiB,EAC3B,oBAAoB,EAAE,SAAS,MAAM,EAAE,GACtC,UAAU,EAAE,CA0Jd"}
package/esm/lock/check.js CHANGED
@@ -6,18 +6,29 @@
6
6
  * category. Pure function — no I/O.
7
7
  *
8
8
  * Drift categories:
9
- * - MSL-L202 — upstream in resolved but missing from lockfile
10
- * - MSL-L203 — upstream in lockfile but missing from resolved
9
+ * - MSL-L202 — upstream in resolved but missing from lockfile (also:
10
+ * a declared reference with no lockfile registry row)
11
+ * - MSL-L203 — upstream in lockfile but missing from resolved (also:
12
+ * a locked registry row no longer declared in project.yaml)
11
13
  * - MSL-L210 — hash mismatch (same identity, different bytes)
12
14
  * - MSL-L211 — profile resolved-version drift (npm range now resolves a different exact version)
13
15
  * - MSL-L212 — canonical edge hash drift (traceability graph changed)
16
+ *
17
+ * Federated registry rows (org `references:`) are checked by pure
18
+ * id-presence against `declaredReferenceIds` — no hash comparison.
19
+ * Content integrity for those rows is the offline cache gate (a later
20
+ * task), not this online-vs-lockfile comparison.
14
21
  */
15
22
  /**
16
23
  * Compare locked vs resolved upstreams; return one diagnostic per drift
17
24
  * case. An empty result means the lockfile is in sync with the current
18
25
  * project state.
26
+ *
27
+ * @param declaredReferenceIds - Upstream ids derived from
28
+ * `config.references` (via `deriveUpstreamId`) — the id-presence
29
+ * comparison set for federated registry rows.
19
30
  */
20
- export function checkDrift(locked, resolved) {
31
+ export function checkDrift(locked, resolved, declaredReferenceIds) {
21
32
  const diags = [];
22
33
  // -------------------------------------------------------------------------
23
34
  // References — match by slug.
@@ -113,6 +124,33 @@ export function checkDrift(locked, resolved) {
113
124
  }
114
125
  }
115
126
  // -------------------------------------------------------------------------
127
+ // Federated registries — pure id-presence against declared references.
128
+ // No hash comparison: content integrity is the offline cache gate.
129
+ // -------------------------------------------------------------------------
130
+ const lockedRegistries = locked.upstreams.filter((u) => u.kind === "registry");
131
+ const lockedRegistryIds = new Set(lockedRegistries.map((r) => r.id));
132
+ for (const id of declaredReferenceIds) {
133
+ if (!lockedRegistryIds.has(id)) {
134
+ diags.push({
135
+ code: "MSL-L202",
136
+ severity: "error",
137
+ message: `declared reference '${id}' has no lockfile row — run 'markspec lock'`,
138
+ location: undefined,
139
+ });
140
+ }
141
+ }
142
+ const declaredRegistryIds = new Set(declaredReferenceIds);
143
+ for (const row of lockedRegistries) {
144
+ if (!declaredRegistryIds.has(row.id)) {
145
+ diags.push({
146
+ code: "MSL-L203",
147
+ severity: "error",
148
+ message: `locked reference '${row.id}' is no longer declared in project.yaml — run 'markspec lock'`,
149
+ location: undefined,
150
+ });
151
+ }
152
+ }
153
+ // -------------------------------------------------------------------------
116
154
  // Canonical edge hash — single comparison, MSL-L212 on mismatch.
117
155
  // -------------------------------------------------------------------------
118
156
  if (locked.generatedCache.edgesHash !== resolved.canonicalEdgeHash) {
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @module core/lock/git_intent
3
+ *
4
+ * Pure git-intent resolution for federated dependencies (design §4.3).
5
+ * Parses `git ls-remote --symref` output into a {@linkcode RefList} and
6
+ * resolves a declared version intent (`auto` | `<tag>` | `<branch>` |
7
+ * `<sha>`) to an exact commit + a resolution-kind label. No I/O — the CLI
8
+ * runs git and hands the raw stdout in; unit tests feed fixture strings.
9
+ */
10
+ export interface GitRef {
11
+ readonly name: string;
12
+ readonly kind: "tag" | "branch";
13
+ readonly sha: string;
14
+ }
15
+ export interface RefList {
16
+ readonly refs: readonly GitRef[];
17
+ readonly headSha?: string;
18
+ readonly defaultBranch?: string;
19
+ }
20
+ export interface ResolvedIntent {
21
+ readonly sha: string;
22
+ readonly resolved: string;
23
+ }
24
+ /**
25
+ * Parse `git ls-remote --symref <url>` output. Peeled annotated-tag lines
26
+ * (`refs/tags/x^{}`) override the tag-object sha with the underlying commit
27
+ * — that commit is what a checkout resolves to and what we pin.
28
+ */
29
+ export declare function parseLsRemote(stdout: string): RefList;
30
+ /**
31
+ * Resolve a declared intent to an exact `{ sha, resolved }`.
32
+ *
33
+ * - `auto` → highest valid-semver tag (leading `v` tolerated); if none, the
34
+ * default-branch head.
35
+ * - a name matching a tag → `tag:<name>` (tag wins if a branch shares the name).
36
+ * - a name matching a branch → `branch:<name>`.
37
+ * - a 40-hex string (any case) → normalized to lowercase → `sha:<sha>` (the
38
+ * acquire step validates it). Lowercasing keeps the pin byte-identical
39
+ * regardless of the case a developer typed, so two lockfiles never differ
40
+ * on sha case alone.
41
+ * - otherwise → `{ error }`.
42
+ */
43
+ export declare function resolveIntent(intent: string, refs: RefList): ResolvedIntent | {
44
+ error: string;
45
+ };
46
+ //# sourceMappingURL=git_intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git_intent.d.ts","sourceRoot":"","sources":["../../src/lock/git_intent.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAQD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CA0CrD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,GACZ,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAiCpC"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @module core/lock/git_intent
3
+ *
4
+ * Pure git-intent resolution for federated dependencies (design §4.3).
5
+ * Parses `git ls-remote --symref` output into a {@linkcode RefList} and
6
+ * resolves a declared version intent (`auto` | `<tag>` | `<branch>` |
7
+ * `<sha>`) to an exact commit + a resolution-kind label. No I/O — the CLI
8
+ * runs git and hands the raw stdout in; unit tests feed fixture strings.
9
+ */
10
+ import { compare, tryParse } from "@std/semver";
11
+ const SHA_RE = /^[0-9a-fA-F]{40}$/;
12
+ /** Strip a single leading `v`/`V` so `v2.1.0` parses as semver. */
13
+ function semverText(tag) {
14
+ return /^[vV]/.test(tag) ? tag.slice(1) : tag;
15
+ }
16
+ /**
17
+ * Parse `git ls-remote --symref <url>` output. Peeled annotated-tag lines
18
+ * (`refs/tags/x^{}`) override the tag-object sha with the underlying commit
19
+ * — that commit is what a checkout resolves to and what we pin.
20
+ */
21
+ export function parseLsRemote(stdout) {
22
+ const branches = new Map();
23
+ const tags = new Map();
24
+ let headSha;
25
+ let defaultBranch;
26
+ for (const raw of stdout.split("\n")) {
27
+ const line = raw.trimEnd();
28
+ if (line.length === 0)
29
+ continue;
30
+ if (line.startsWith("ref: ")) {
31
+ // `ref: refs/heads/main\tHEAD` — the symref for HEAD.
32
+ const m = line.match(/^ref:\s+refs\/heads\/(\S+)\s+HEAD$/);
33
+ if (m)
34
+ defaultBranch = m[1];
35
+ continue;
36
+ }
37
+ const tab = line.indexOf("\t");
38
+ if (tab < 0)
39
+ continue;
40
+ const sha = line.slice(0, tab);
41
+ const ref = line.slice(tab + 1);
42
+ if (ref === "HEAD") {
43
+ headSha = sha;
44
+ }
45
+ else if (ref.startsWith("refs/heads/")) {
46
+ branches.set(ref.slice("refs/heads/".length), sha);
47
+ }
48
+ else if (ref.startsWith("refs/tags/")) {
49
+ const rest = ref.slice("refs/tags/".length);
50
+ const peeled = rest.endsWith("^{}");
51
+ const name = peeled ? rest.slice(0, -3) : rest;
52
+ // A peeled line always wins; a bare tag line only sets the sha if no
53
+ // peeled sha was recorded yet.
54
+ if (peeled || !tags.has(name))
55
+ tags.set(name, sha);
56
+ }
57
+ }
58
+ const refs = [
59
+ ...[...branches].map(([name, sha]) => ({
60
+ name,
61
+ kind: "branch",
62
+ sha,
63
+ })),
64
+ ...[...tags].map(([name, sha]) => ({ name, kind: "tag", sha })),
65
+ ];
66
+ return { refs, headSha, defaultBranch };
67
+ }
68
+ /**
69
+ * Resolve a declared intent to an exact `{ sha, resolved }`.
70
+ *
71
+ * - `auto` → highest valid-semver tag (leading `v` tolerated); if none, the
72
+ * default-branch head.
73
+ * - a name matching a tag → `tag:<name>` (tag wins if a branch shares the name).
74
+ * - a name matching a branch → `branch:<name>`.
75
+ * - a 40-hex string (any case) → normalized to lowercase → `sha:<sha>` (the
76
+ * acquire step validates it). Lowercasing keeps the pin byte-identical
77
+ * regardless of the case a developer typed, so two lockfiles never differ
78
+ * on sha case alone.
79
+ * - otherwise → `{ error }`.
80
+ */
81
+ export function resolveIntent(intent, refs) {
82
+ if (intent === "auto") {
83
+ const semverTags = refs.refs
84
+ .filter((r) => r.kind === "tag")
85
+ .map((r) => ({ r, v: tryParse(semverText(r.name)) }))
86
+ .filter((x) => x.v !== undefined)
87
+ .sort((a, b) => compare(b.v, a.v));
88
+ if (semverTags.length > 0) {
89
+ const top = semverTags[0].r;
90
+ return { sha: top.sha, resolved: `tag:${top.name}` };
91
+ }
92
+ if (refs.headSha !== undefined) {
93
+ return {
94
+ sha: refs.headSha,
95
+ resolved: `branch:${refs.defaultBranch ?? "HEAD"}`,
96
+ };
97
+ }
98
+ return { error: "intent 'auto': remote has no tags and no HEAD" };
99
+ }
100
+ const tag = refs.refs.find((r) => r.kind === "tag" && r.name === intent);
101
+ if (tag)
102
+ return { sha: tag.sha, resolved: `tag:${tag.name}` };
103
+ const branch = refs.refs.find((r) => r.kind === "branch" && r.name === intent);
104
+ if (branch)
105
+ return { sha: branch.sha, resolved: `branch:${branch.name}` };
106
+ if (SHA_RE.test(intent)) {
107
+ const sha = intent.toLowerCase();
108
+ return { sha, resolved: `sha:${sha}` };
109
+ }
110
+ return { error: `intent '${intent}' matched no tag or branch on the remote` };
111
+ }
package/esm/lock/mod.d.ts CHANGED
@@ -5,11 +5,12 @@
5
5
  * model, upstream resolution, drift detection. The public boundary
6
6
  * for both `markspec lock` and `markspec compile --frozen`.
7
7
  */
8
- export type { BoundEntry, BoundEntryBinding, GeneratedCache, LockedAttributes, LockEdge, Lockfile, LockfileMeta, LockfileToolchain, Upstream, UpstreamProfile, UpstreamReference, UpstreamRegistry, } from "./model.js";
8
+ export type { BoundEntry, BoundEntryBinding, GeneratedCache, LockedAttributes, LockEdge, Lockfile, LockfileMeta, LockfileToolchain, Upstream, UpstreamDependency, UpstreamProfile, UpstreamReference, UpstreamRegistry, } from "./model.js";
9
9
  export { LOCKFILE_SCHEMA_VERSION } from "./model.js";
10
10
  export { serializeLockfile } from "./serializer.js";
11
11
  export { parseLockfile } from "./parser.js";
12
12
  export type { ParseLockfileResult } from "./parser.js";
13
+ export { dependencyPinAssurance } from "./pin_assurance.js";
13
14
  export { isBelowFloor } from "./compare.js";
14
15
  export { checkDrift } from "./check.js";
15
16
  export { sha256Bytes, sha256String } from "./hash.js";
@@ -17,6 +18,12 @@ export { canonicalEdgeJson, hashCanonicalEdges } from "./canonical_edges.js";
17
18
  export type { EdgeQuad } from "./canonical_edges.js";
18
19
  export { detectOfflineEdgeDrift } from "./edge_drift.js";
19
20
  export type { OfflineEdgeDrift } from "./edge_drift.js";
20
- export { extractEdgeLedger, extractEdgeQuads, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveRegistries, resolveUpstreams, } from "./resolve.js";
21
- export type { FetchUrl, ReadFile, ResolvedBoundEntry, ResolvedProfile, ResolvedReference, ResolvedRegistry, ResolvedUpstreams, ResolveUpstreamsOptions, } from "./resolve.js";
21
+ export { verifyUpstreamCache } from "./cache_check.js";
22
+ export { extractEdgeLedger, extractEdgeQuads, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveUpstreams, } from "./resolve.js";
23
+ export type { FetchUrl, ReadFile, ResolvedBoundEntry, ResolvedProfile, ResolvedReference, ResolvedUpstreams, ResolveUpstreamsOptions, } from "./resolve.js";
24
+ export { deriveUpstreamId, resolveProjectReferences, upstreamCacheRoot, } from "./upstream_refs.js";
25
+ export type { ResolveProjectReferencesOptions, ResolveProjectReferencesResult, UpstreamRefsIO, } from "./upstream_refs.js";
26
+ export { type GitIO, resolveProjectDependencies, type ResolveProjectDependenciesOptions, type ResolveProjectDependenciesResult, type UpstreamDepsIO, } from "./upstream_deps.js";
27
+ export { type AcquireCompileIO, compileAcquiredTree, type CompiledSnapshot, } from "./acquire_compile.js";
28
+ export { type GitRef, parseLsRemote, type RefList, type ResolvedIntent, resolveIntent, } from "./git_intent.js";
22
29
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/lock/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/lock/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,cAAc,GACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,KAAK,KAAK,EACV,0BAA0B,EAC1B,KAAK,iCAAiC,EACtC,KAAK,gCAAgC,EACrC,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,gBAAgB,EACrB,mBAAmB,EACnB,KAAK,gBAAgB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,MAAM,EACX,aAAa,EACb,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,aAAa,GACd,MAAM,iBAAiB,CAAC"}
package/esm/lock/mod.js CHANGED
@@ -8,9 +8,15 @@
8
8
  export { LOCKFILE_SCHEMA_VERSION } from "./model.js";
9
9
  export { serializeLockfile } from "./serializer.js";
10
10
  export { parseLockfile } from "./parser.js";
11
+ export { dependencyPinAssurance } from "./pin_assurance.js";
11
12
  export { isBelowFloor } from "./compare.js";
12
13
  export { checkDrift } from "./check.js";
13
14
  export { sha256Bytes, sha256String } from "./hash.js";
14
15
  export { canonicalEdgeJson, hashCanonicalEdges } from "./canonical_edges.js";
15
16
  export { detectOfflineEdgeDrift } from "./edge_drift.js";
16
- export { extractEdgeLedger, extractEdgeQuads, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveRegistries, resolveUpstreams, } from "./resolve.js";
17
+ export { verifyUpstreamCache } from "./cache_check.js";
18
+ export { extractEdgeLedger, extractEdgeQuads, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveUpstreams, } from "./resolve.js";
19
+ export { deriveUpstreamId, resolveProjectReferences, upstreamCacheRoot, } from "./upstream_refs.js";
20
+ export { resolveProjectDependencies, } from "./upstream_deps.js";
21
+ export { compileAcquiredTree, } from "./acquire_compile.js";
22
+ export { parseLsRemote, resolveIntent, } from "./git_intent.js";