mrplex 0.0.1

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 (319) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +284 -0
  3. package/dist/cli/config.d.ts +28 -0
  4. package/dist/cli/config.js +48 -0
  5. package/dist/cli/config.js.map +1 -0
  6. package/dist/cli/exit-codes.d.ts +13 -0
  7. package/dist/cli/exit-codes.js +39 -0
  8. package/dist/cli/exit-codes.js.map +1 -0
  9. package/dist/cli/format.d.ts +22 -0
  10. package/dist/cli/format.js +148 -0
  11. package/dist/cli/format.js.map +1 -0
  12. package/dist/cli/main.d.ts +16 -0
  13. package/dist/cli/main.js +1518 -0
  14. package/dist/cli/main.js.map +1 -0
  15. package/dist/client/kernel-client.d.ts +97 -0
  16. package/dist/client/kernel-client.js +14 -0
  17. package/dist/client/kernel-client.js.map +1 -0
  18. package/dist/client/local.d.ts +26 -0
  19. package/dist/client/local.js +103 -0
  20. package/dist/client/local.js.map +1 -0
  21. package/dist/client/remote-mcp.d.ts +35 -0
  22. package/dist/client/remote-mcp.js +174 -0
  23. package/dist/client/remote-mcp.js.map +1 -0
  24. package/dist/embed/backfill.d.ts +24 -0
  25. package/dist/embed/backfill.js +33 -0
  26. package/dist/embed/backfill.js.map +1 -0
  27. package/dist/embed/chunker.d.ts +31 -0
  28. package/dist/embed/chunker.js +121 -0
  29. package/dist/embed/chunker.js.map +1 -0
  30. package/dist/embed/cmd-hook.d.ts +21 -0
  31. package/dist/embed/cmd-hook.js +100 -0
  32. package/dist/embed/cmd-hook.js.map +1 -0
  33. package/dist/embed/config.d.ts +61 -0
  34. package/dist/embed/config.js +109 -0
  35. package/dist/embed/config.js.map +1 -0
  36. package/dist/embed/hook.d.ts +38 -0
  37. package/dist/embed/hook.js +56 -0
  38. package/dist/embed/hook.js.map +1 -0
  39. package/dist/embed/http-hook.d.ts +13 -0
  40. package/dist/embed/http-hook.js +39 -0
  41. package/dist/embed/http-hook.js.map +1 -0
  42. package/dist/embed/worker.d.ts +62 -0
  43. package/dist/embed/worker.js +228 -0
  44. package/dist/embed/worker.js.map +1 -0
  45. package/dist/fixtures/hwe/characters/albion-ever.md +12 -0
  46. package/dist/fixtures/hwe/characters/cent.md +11 -0
  47. package/dist/fixtures/hwe/concepts/cent-demiurge-resonance.md +10 -0
  48. package/dist/fixtures/hwe/concepts/phase-looper.md +10 -0
  49. package/dist/fixtures/hwe/entities/demiurge.md +11 -0
  50. package/dist/fixtures/hwe/entities/monad.md +11 -0
  51. package/dist/fixtures/hwe/moc/globocorp-network.md +19 -0
  52. package/dist/fixtures/hwe/organizations/globocorp.md +11 -0
  53. package/dist/fixtures/hwe/readme.md +24 -0
  54. package/dist/fixtures/starship/crew/aria-okonkwo.md +14 -0
  55. package/dist/fixtures/starship/crew/bexley-orr.md +14 -0
  56. package/dist/fixtures/starship/crew/dax-thorne.md +14 -0
  57. package/dist/fixtures/starship/crew/isolde-marsh.md +16 -0
  58. package/dist/fixtures/starship/crew/kestrel-vance.md +15 -0
  59. package/dist/fixtures/starship/crew/quill-vasquez.md +14 -0
  60. package/dist/fixtures/starship/crew/soren-halloway.md +16 -0
  61. package/dist/fixtures/starship/encounters/the-drift-choir.md +14 -0
  62. package/dist/fixtures/starship/encounters/the-hollow-signal.md +16 -0
  63. package/dist/fixtures/starship/encounters/the-wandering-buoy.md +14 -0
  64. package/dist/fixtures/starship/equipment/coolant-loop-b.md +13 -0
  65. package/dist/fixtures/starship/equipment/emergency-ration-bars.md +12 -0
  66. package/dist/fixtures/starship/equipment/long-range-sensors.md +13 -0
  67. package/dist/fixtures/starship/equipment/plasma-manifold-3.md +15 -0
  68. package/dist/fixtures/starship/equipment/shuttle-corvid.md +13 -0
  69. package/dist/fixtures/starship/logs/marsh-4419-1.md +13 -0
  70. package/dist/fixtures/starship/logs/okonkwo-4415-1.md +13 -0
  71. package/dist/fixtures/starship/logs/orr-4413-1.md +13 -0
  72. package/dist/fixtures/starship/logs/orr-4420-1.md +12 -0
  73. package/dist/fixtures/starship/logs/thorne-4413-2.md +13 -0
  74. package/dist/fixtures/starship/logs/vance-4419-2.md +13 -0
  75. package/dist/fixtures/starship/misc/the-galley-ficus.md +11 -0
  76. package/dist/fixtures/starship/missions/the-cinder-run.md +17 -0
  77. package/dist/fixtures/starship/missions/the-drift-choir.md +17 -0
  78. package/dist/fixtures/starship/missions/the-hollow-signal.md +17 -0
  79. package/dist/fixtures/starship/missions/the-silent-beacon.md +17 -0
  80. package/dist/fixtures/starship/moc/crew.md +19 -0
  81. package/dist/fixtures/starship/moc/encounters.md +14 -0
  82. package/dist/fixtures/starship/moc/missions.md +15 -0
  83. package/dist/fixtures/starship/readme.md +60 -0
  84. package/dist/index.d.ts +1 -0
  85. package/dist/index.js +3 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/kernel/auth/glob.d.ts +46 -0
  88. package/dist/kernel/auth/glob.js +112 -0
  89. package/dist/kernel/auth/glob.js.map +1 -0
  90. package/dist/kernel/auth/scope.d.ts +53 -0
  91. package/dist/kernel/auth/scope.js +83 -0
  92. package/dist/kernel/auth/scope.js.map +1 -0
  93. package/dist/kernel/casefold.d.ts +37 -0
  94. package/dist/kernel/casefold.js +44 -0
  95. package/dist/kernel/casefold.js.map +1 -0
  96. package/dist/kernel/constants.d.ts +21 -0
  97. package/dist/kernel/constants.js +22 -0
  98. package/dist/kernel/constants.js.map +1 -0
  99. package/dist/kernel/context.d.ts +70 -0
  100. package/dist/kernel/context.js +114 -0
  101. package/dist/kernel/context.js.map +1 -0
  102. package/dist/kernel/deletion.d.ts +50 -0
  103. package/dist/kernel/deletion.js +83 -0
  104. package/dist/kernel/deletion.js.map +1 -0
  105. package/dist/kernel/diff.d.ts +36 -0
  106. package/dist/kernel/diff.js +61 -0
  107. package/dist/kernel/diff.js.map +1 -0
  108. package/dist/kernel/errors.d.ts +37 -0
  109. package/dist/kernel/errors.js +55 -0
  110. package/dist/kernel/errors.js.map +1 -0
  111. package/dist/kernel/frontmatter-input.d.ts +32 -0
  112. package/dist/kernel/frontmatter-input.js +85 -0
  113. package/dist/kernel/frontmatter-input.js.map +1 -0
  114. package/dist/kernel/graph.d.ts +34 -0
  115. package/dist/kernel/graph.js +559 -0
  116. package/dist/kernel/graph.js.map +1 -0
  117. package/dist/kernel/history.d.ts +74 -0
  118. package/dist/kernel/history.js +143 -0
  119. package/dist/kernel/history.js.map +1 -0
  120. package/dist/kernel/kernel.d.ts +162 -0
  121. package/dist/kernel/kernel.js +675 -0
  122. package/dist/kernel/kernel.js.map +1 -0
  123. package/dist/kernel/path-config.d.ts +101 -0
  124. package/dist/kernel/path-config.js +171 -0
  125. package/dist/kernel/path-config.js.map +1 -0
  126. package/dist/kernel/query/ast.d.ts +24 -0
  127. package/dist/kernel/query/ast.js +52 -0
  128. package/dist/kernel/query/ast.js.map +1 -0
  129. package/dist/kernel/query/cel-parse.d.ts +37 -0
  130. package/dist/kernel/query/cel-parse.js +88 -0
  131. package/dist/kernel/query/cel-parse.js.map +1 -0
  132. package/dist/kernel/query/degrees.d.ts +31 -0
  133. package/dist/kernel/query/degrees.js +135 -0
  134. package/dist/kernel/query/degrees.js.map +1 -0
  135. package/dist/kernel/query/graph-ast.d.ts +51 -0
  136. package/dist/kernel/query/graph-ast.js +139 -0
  137. package/dist/kernel/query/graph-ast.js.map +1 -0
  138. package/dist/kernel/query/query.d.ts +56 -0
  139. package/dist/kernel/query/query.js +276 -0
  140. package/dist/kernel/query/query.js.map +1 -0
  141. package/dist/kernel/validation.d.ts +64 -0
  142. package/dist/kernel/validation.js +183 -0
  143. package/dist/kernel/validation.js.map +1 -0
  144. package/dist/kernel/version-id.d.ts +10 -0
  145. package/dist/kernel/version-id.js +21 -0
  146. package/dist/kernel/version-id.js.map +1 -0
  147. package/dist/kernel/wire.d.ts +148 -0
  148. package/dist/kernel/wire.js +6 -0
  149. package/dist/kernel/wire.js.map +1 -0
  150. package/dist/links/backfill.d.ts +28 -0
  151. package/dist/links/backfill.js +33 -0
  152. package/dist/links/backfill.js.map +1 -0
  153. package/dist/links/extract.d.ts +29 -0
  154. package/dist/links/extract.js +233 -0
  155. package/dist/links/extract.js.map +1 -0
  156. package/dist/links/link-config.d.ts +70 -0
  157. package/dist/links/link-config.js +107 -0
  158. package/dist/links/link-config.js.map +1 -0
  159. package/dist/links/maintain.d.ts +37 -0
  160. package/dist/links/maintain.js +91 -0
  161. package/dist/links/maintain.js.map +1 -0
  162. package/dist/links/repair.d.ts +46 -0
  163. package/dist/links/repair.js +96 -0
  164. package/dist/links/repair.js.map +1 -0
  165. package/dist/links/resolve.d.ts +41 -0
  166. package/dist/links/resolve.js +121 -0
  167. package/dist/links/resolve.js.map +1 -0
  168. package/dist/links/stale.d.ts +32 -0
  169. package/dist/links/stale.js +73 -0
  170. package/dist/links/stale.js.map +1 -0
  171. package/dist/markdown/content-hash.d.ts +34 -0
  172. package/dist/markdown/content-hash.js +46 -0
  173. package/dist/markdown/content-hash.js.map +1 -0
  174. package/dist/markdown/frontmatter.d.ts +69 -0
  175. package/dist/markdown/frontmatter.js +147 -0
  176. package/dist/markdown/frontmatter.js.map +1 -0
  177. package/dist/markdown/hash-backfill.d.ts +22 -0
  178. package/dist/markdown/hash-backfill.js +43 -0
  179. package/dist/markdown/hash-backfill.js.map +1 -0
  180. package/dist/mcp/query-syntax.d.ts +20 -0
  181. package/dist/mcp/query-syntax.js +194 -0
  182. package/dist/mcp/query-syntax.js.map +1 -0
  183. package/dist/mcp/render.d.ts +31 -0
  184. package/dist/mcp/render.js +110 -0
  185. package/dist/mcp/render.js.map +1 -0
  186. package/dist/mcp/server.d.ts +60 -0
  187. package/dist/mcp/server.js +170 -0
  188. package/dist/mcp/server.js.map +1 -0
  189. package/dist/mcp/tools.d.ts +93 -0
  190. package/dist/mcp/tools.js +1218 -0
  191. package/dist/mcp/tools.js.map +1 -0
  192. package/dist/rest/conditional.d.ts +37 -0
  193. package/dist/rest/conditional.js +58 -0
  194. package/dist/rest/conditional.js.map +1 -0
  195. package/dist/rest/negotiate.d.ts +33 -0
  196. package/dist/rest/negotiate.js +54 -0
  197. package/dist/rest/negotiate.js.map +1 -0
  198. package/dist/rest/routes.d.ts +37 -0
  199. package/dist/rest/routes.js +744 -0
  200. package/dist/rest/routes.js.map +1 -0
  201. package/dist/seed/fixture-seed.d.ts +35 -0
  202. package/dist/seed/fixture-seed.js +75 -0
  203. package/dist/seed/fixture-seed.js.map +1 -0
  204. package/dist/seed/starship-config.d.ts +3 -0
  205. package/dist/seed/starship-config.js +5 -0
  206. package/dist/seed/starship-config.js.map +1 -0
  207. package/dist/server/headers.d.ts +36 -0
  208. package/dist/server/headers.js +30 -0
  209. package/dist/server/headers.js.map +1 -0
  210. package/dist/server/http-error.d.ts +53 -0
  211. package/dist/server/http-error.js +104 -0
  212. package/dist/server/http-error.js.map +1 -0
  213. package/dist/server/serve.d.ts +56 -0
  214. package/dist/server/serve.js +135 -0
  215. package/dist/server/serve.js.map +1 -0
  216. package/dist/shell/audit.d.ts +32 -0
  217. package/dist/shell/audit.js +28 -0
  218. package/dist/shell/audit.js.map +1 -0
  219. package/dist/shell/guard.d.ts +50 -0
  220. package/dist/shell/guard.js +176 -0
  221. package/dist/shell/guard.js.map +1 -0
  222. package/dist/shell/keys.d.ts +36 -0
  223. package/dist/shell/keys.js +64 -0
  224. package/dist/shell/keys.js.map +1 -0
  225. package/dist/shell/login.d.ts +56 -0
  226. package/dist/shell/login.js +130 -0
  227. package/dist/shell/login.js.map +1 -0
  228. package/dist/shell/oidc.d.ts +62 -0
  229. package/dist/shell/oidc.js +102 -0
  230. package/dist/shell/oidc.js.map +1 -0
  231. package/dist/shell/policy.d.ts +100 -0
  232. package/dist/shell/policy.js +232 -0
  233. package/dist/shell/policy.js.map +1 -0
  234. package/dist/shell/proxy-policy.d.ts +34 -0
  235. package/dist/shell/proxy-policy.js +120 -0
  236. package/dist/shell/proxy-policy.js.map +1 -0
  237. package/dist/shell/proxy.d.ts +47 -0
  238. package/dist/shell/proxy.js +253 -0
  239. package/dist/shell/proxy.js.map +1 -0
  240. package/dist/shell/serve.d.ts +86 -0
  241. package/dist/shell/serve.js +0 -0
  242. package/dist/shell/serve.js.map +1 -0
  243. package/dist/shell/stdio.d.ts +55 -0
  244. package/dist/shell/stdio.js +63 -0
  245. package/dist/shell/stdio.js.map +1 -0
  246. package/dist/storage/registry.d.ts +20 -0
  247. package/dist/storage/registry.js +38 -0
  248. package/dist/storage/registry.js.map +1 -0
  249. package/dist/storage/search-plan.d.ts +93 -0
  250. package/dist/storage/search-plan.js +15 -0
  251. package/dist/storage/search-plan.js.map +1 -0
  252. package/dist/storage/types.d.ts +448 -0
  253. package/dist/storage/types.js +14 -0
  254. package/dist/storage/types.js.map +1 -0
  255. package/dist/storage/versions-since.d.ts +72 -0
  256. package/dist/storage/versions-since.js +92 -0
  257. package/dist/storage/versions-since.js.map +1 -0
  258. package/dist/storage-postgres/adapter.d.ts +17 -0
  259. package/dist/storage-postgres/adapter.js +782 -0
  260. package/dist/storage-postgres/adapter.js.map +1 -0
  261. package/dist/storage-postgres/compile-postgres.d.ts +22 -0
  262. package/dist/storage-postgres/compile-postgres.js +830 -0
  263. package/dist/storage-postgres/compile-postgres.js.map +1 -0
  264. package/dist/storage-postgres/errors.d.ts +34 -0
  265. package/dist/storage-postgres/errors.js +50 -0
  266. package/dist/storage-postgres/errors.js.map +1 -0
  267. package/dist/storage-postgres/migrations/0001_init.sql +113 -0
  268. package/dist/storage-postgres/migrations/0002_content_hash.sql +7 -0
  269. package/dist/storage-postgres/migrations/index.d.ts +22 -0
  270. package/dist/storage-postgres/migrations/index.js +70 -0
  271. package/dist/storage-postgres/migrations/index.js.map +1 -0
  272. package/dist/storage-sqlite/adapter.d.ts +2 -0
  273. package/dist/storage-sqlite/adapter.js +688 -0
  274. package/dist/storage-sqlite/adapter.js.map +1 -0
  275. package/dist/storage-sqlite/compile-filter.d.ts +41 -0
  276. package/dist/storage-sqlite/compile-filter.js +881 -0
  277. package/dist/storage-sqlite/compile-filter.js.map +1 -0
  278. package/dist/storage-sqlite/compile-sqlite.d.ts +19 -0
  279. package/dist/storage-sqlite/compile-sqlite.js +176 -0
  280. package/dist/storage-sqlite/compile-sqlite.js.map +1 -0
  281. package/dist/storage-sqlite/migrations/0001_init.sql +123 -0
  282. package/dist/storage-sqlite/migrations/0002_content_hash.sql +7 -0
  283. package/dist/storage-sqlite/migrations/index.d.ts +6 -0
  284. package/dist/storage-sqlite/migrations/index.js +41 -0
  285. package/dist/storage-sqlite/migrations/index.js.map +1 -0
  286. package/dist/storage-sqlite/vec.d.ts +40 -0
  287. package/dist/storage-sqlite/vec.js +62 -0
  288. package/dist/storage-sqlite/vec.js.map +1 -0
  289. package/dist/sync/cursor.d.ts +36 -0
  290. package/dist/sync/cursor.js +66 -0
  291. package/dist/sync/cursor.js.map +1 -0
  292. package/dist/sync/daemon.d.ts +40 -0
  293. package/dist/sync/daemon.js +202 -0
  294. package/dist/sync/daemon.js.map +1 -0
  295. package/dist/sync/feed.d.ts +38 -0
  296. package/dist/sync/feed.js +125 -0
  297. package/dist/sync/feed.js.map +1 -0
  298. package/dist/sync/fs-store.d.ts +8 -0
  299. package/dist/sync/fs-store.js +76 -0
  300. package/dist/sync/fs-store.js.map +1 -0
  301. package/dist/sync/intrinsics.d.ts +52 -0
  302. package/dist/sync/intrinsics.js +76 -0
  303. package/dist/sync/intrinsics.js.map +1 -0
  304. package/dist/sync/paths.d.ts +38 -0
  305. package/dist/sync/paths.js +56 -0
  306. package/dist/sync/paths.js.map +1 -0
  307. package/dist/sync/push.d.ts +48 -0
  308. package/dist/sync/push.js +328 -0
  309. package/dist/sync/push.js.map +1 -0
  310. package/dist/sync/reconcile.d.ts +54 -0
  311. package/dist/sync/reconcile.js +252 -0
  312. package/dist/sync/reconcile.js.map +1 -0
  313. package/dist/sync/run.d.ts +27 -0
  314. package/dist/sync/run.js +46 -0
  315. package/dist/sync/run.js.map +1 -0
  316. package/dist/version.d.ts +2 -0
  317. package/dist/version.js +5 -0
  318. package/dist/version.js.map +1 -0
  319. package/package.json +80 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/kernel/query/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAqB,eAAe,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAoB1C,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAkB;IACjD,MAAM;IACN,QAAQ;IACR,MAAM;IACN,UAAU;IACV,OAAO;IACP,gBAAgB;IAChB,gBAAgB;IAChB,QAAQ;CACT,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,4BAA4B,GAA4C;IAC5E,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;IACpB,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;IACpB,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU;IAChC,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe;IAC1C,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe;IAC1C,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU;IAChC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM;IACxB,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;IACpB,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAA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,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,gFAAgF;AAChF,kCAAkC;AAClC,gFAAgF;AAEhF,SAAS,UAAU,CACjB,MAA6B,EAC7B,WAA+B;IAE/B,yEAAyE;IACzE,2EAA2E;IAC3E,kCAAkC;IAClC,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAClD,MAAM,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACxD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAa,EAAE,YAAwB;IACzE,OAAO,mBAAmB,CAAC,YAAY,EAAE,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Slug + path segment validation — the write-time gate.
3
+ *
4
+ * Design §3.5.1 pins the structural constants (grammar, not policy):
5
+ * PATH_SEPARATOR = "/", CURRENT_SEGMENT = ".", PARENT_SEGMENT = "..",
6
+ * EMPTY_SEGMENT = ""
7
+ *
8
+ * Design §3.5.2 defines the configurable policy layered per repo:
9
+ * disallowed_chars: single chars forbidden anywhere in a user segment
10
+ * system_sigils: leading string prefixes marking kernel-owned segments
11
+ * hidden_sigils: leading string prefixes marking user-hidden segments
12
+ *
13
+ * Design §3.5.3 says validation is write-time only — existing rows keep
14
+ * whatever paths they had. §3.5.6 says slugs use the SERVER-level config
15
+ * (per-repo config doesn't gate slug validation).
16
+ */
17
+ export declare const PATH_SEPARATOR = "/";
18
+ export declare const CURRENT_SEGMENT = ".";
19
+ export declare const PARENT_SEGMENT = "..";
20
+ export declare const EMPTY_SEGMENT = "";
21
+ export declare const SLUG_MAX_LENGTH = 64;
22
+ export type EffectivePathConfig = {
23
+ disallowed_chars: string[];
24
+ system_sigils: string[];
25
+ hidden_sigils: string[];
26
+ };
27
+ /** True when `path` is a glob/pattern operand (not an exact document path). */
28
+ export declare function isPathGlobPattern(path: string): boolean;
29
+ /**
30
+ * Normalize an exact document path for API lookup and writes. Accepts a
31
+ * canonical slashless path unchanged, or exactly one leading `/` as a
32
+ * repository-root reference alias (Markdown-style). Returns the slashless
33
+ * canonical form after applying `validatePath`. Failure → `path_invalid`.
34
+ *
35
+ * Idempotent: `normalizeExactDocumentPath(normalizeExactDocumentPath(p))`
36
+ * equals `normalizeExactDocumentPath(p)`.
37
+ *
38
+ * Do not use for glob operands, CEL `$path` literals, or stored link text —
39
+ * those keep their own semantics.
40
+ */
41
+ export declare function normalizeExactDocumentPath(input: string, config: EffectivePathConfig): string;
42
+ /**
43
+ * Validate every segment of a canonical (slashless) user-written path.
44
+ * Applied at `docs.create` and `docs.put` (design §3.5.3) after exact-path
45
+ * alias normalization. Failure → `path_invalid`.
46
+ *
47
+ * The kernel bypasses these checks for its own deletion moves (§4.1 rule 4);
48
+ * that bypass lives in the write surface, not here.
49
+ */
50
+ export declare function validatePath(path: string, config: EffectivePathConfig): void;
51
+ /**
52
+ * Validate a repo or user slug against server-level path config (§3.5.6).
53
+ * Per-repo config doesn't apply: slug is validated before any repo has a
54
+ * chance to override, and users are global.
55
+ *
56
+ * Slug hygiene numbers are pinned by m1-plan §5: ≤ 64 chars, no leading/
57
+ * trailing whitespace, no control chars.
58
+ */
59
+ export declare function validateSlug(slug: string, config: EffectivePathConfig): void;
60
+ /**
61
+ * True if any segment of `path` starts with any of the given sigils.
62
+ * Design §5.1 uses this to compile the default-exclude clause.
63
+ */
64
+ export declare function pathHasSigilSegment(path: string, sigils: readonly string[]): boolean;
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Slug + path segment validation — the write-time gate.
3
+ *
4
+ * Design §3.5.1 pins the structural constants (grammar, not policy):
5
+ * PATH_SEPARATOR = "/", CURRENT_SEGMENT = ".", PARENT_SEGMENT = "..",
6
+ * EMPTY_SEGMENT = ""
7
+ *
8
+ * Design §3.5.2 defines the configurable policy layered per repo:
9
+ * disallowed_chars: single chars forbidden anywhere in a user segment
10
+ * system_sigils: leading string prefixes marking kernel-owned segments
11
+ * hidden_sigils: leading string prefixes marking user-hidden segments
12
+ *
13
+ * Design §3.5.3 says validation is write-time only — existing rows keep
14
+ * whatever paths they had. §3.5.6 says slugs use the SERVER-level config
15
+ * (per-repo config doesn't gate slug validation).
16
+ */
17
+ import { KernelError } from "./errors.js";
18
+ // -----------------------------------------------------------------------------
19
+ // Structural constants (§3.5.1) — grammar, not policy.
20
+ // -----------------------------------------------------------------------------
21
+ export const PATH_SEPARATOR = "/";
22
+ export const CURRENT_SEGMENT = ".";
23
+ export const PARENT_SEGMENT = "..";
24
+ export const EMPTY_SEGMENT = "";
25
+ // Slug hygiene — pinned in m1-plan §5.
26
+ export const SLUG_MAX_LENGTH = 64;
27
+ const slugInvalid = (slug, reason) => new KernelError("slug_invalid", { slug, reason });
28
+ const pathInvalid = (path, segment, reason) => new KernelError("path_invalid", { path, segment, reason });
29
+ // -----------------------------------------------------------------------------
30
+ // Segment-level predicates (shared by slug and path validators).
31
+ // -----------------------------------------------------------------------------
32
+ function isReservedSegment(segment) {
33
+ return segment === EMPTY_SEGMENT || segment === CURRENT_SEGMENT || segment === PARENT_SEGMENT;
34
+ }
35
+ function containsDisallowedChar(segment, disallowed) {
36
+ for (const ch of disallowed) {
37
+ if (segment.includes(ch))
38
+ return ch;
39
+ }
40
+ return null;
41
+ }
42
+ function startsWithAnySigil(segment, sigils) {
43
+ for (const sigil of sigils) {
44
+ if (segment.startsWith(sigil))
45
+ return sigil;
46
+ }
47
+ return null;
48
+ }
49
+ // -----------------------------------------------------------------------------
50
+ // Exact document path normalization (canonical-path-normalization plan).
51
+ // -----------------------------------------------------------------------------
52
+ /** True when `path` is a glob/pattern operand (not an exact document path). */
53
+ export function isPathGlobPattern(path) {
54
+ return path.includes("*") || path.includes("?");
55
+ }
56
+ /**
57
+ * Normalize an exact document path for API lookup and writes. Accepts a
58
+ * canonical slashless path unchanged, or exactly one leading `/` as a
59
+ * repository-root reference alias (Markdown-style). Returns the slashless
60
+ * canonical form after applying `validatePath`. Failure → `path_invalid`.
61
+ *
62
+ * Idempotent: `normalizeExactDocumentPath(normalizeExactDocumentPath(p))`
63
+ * equals `normalizeExactDocumentPath(p)`.
64
+ *
65
+ * Do not use for glob operands, CEL `$path` literals, or stored link text —
66
+ * those keep their own semantics.
67
+ */
68
+ export function normalizeExactDocumentPath(input, config) {
69
+ if (input.includes("\\")) {
70
+ throw pathInvalid(input, "", "path contains backslash");
71
+ }
72
+ let path = input;
73
+ if (path.startsWith(PATH_SEPARATOR)) {
74
+ if (path === PATH_SEPARATOR) {
75
+ throw pathInvalid(path, "", "path is empty");
76
+ }
77
+ if (path.length > 1 && path[1] === PATH_SEPARATOR) {
78
+ throw pathInvalid(path, "", "path has multiple leading '/'");
79
+ }
80
+ path = path.slice(1);
81
+ }
82
+ validatePath(path, config);
83
+ return path;
84
+ }
85
+ // -----------------------------------------------------------------------------
86
+ // Path validation (§3.5.3).
87
+ // -----------------------------------------------------------------------------
88
+ /**
89
+ * Validate every segment of a canonical (slashless) user-written path.
90
+ * Applied at `docs.create` and `docs.put` (design §3.5.3) after exact-path
91
+ * alias normalization. Failure → `path_invalid`.
92
+ *
93
+ * The kernel bypasses these checks for its own deletion moves (§4.1 rule 4);
94
+ * that bypass lives in the write surface, not here.
95
+ */
96
+ export function validatePath(path, config) {
97
+ if (path === EMPTY_SEGMENT) {
98
+ throw pathInvalid(path, "", "path is empty");
99
+ }
100
+ if (path.startsWith(PATH_SEPARATOR)) {
101
+ throw pathInvalid(path, "", "path has a leading '/'");
102
+ }
103
+ if (path.endsWith(PATH_SEPARATOR)) {
104
+ throw pathInvalid(path, "", "path has a trailing '/'");
105
+ }
106
+ const segments = path.split(PATH_SEPARATOR);
107
+ for (const segment of segments) {
108
+ if (isReservedSegment(segment)) {
109
+ throw pathInvalid(path, segment, `segment is reserved ("${segment}")`);
110
+ }
111
+ const sysSigil = startsWithAnySigil(segment, config.system_sigils);
112
+ if (sysSigil !== null) {
113
+ throw pathInvalid(path, segment, `segment starts with system sigil "${sysSigil}" — reserved for the kernel`);
114
+ }
115
+ const bad = containsDisallowedChar(segment, config.disallowed_chars);
116
+ if (bad !== null) {
117
+ throw pathInvalid(path, segment, `segment contains disallowed character "${bad}"`);
118
+ }
119
+ }
120
+ }
121
+ // -----------------------------------------------------------------------------
122
+ // Slug validation (§3.5.6) — server-config only, single segment, no '/'.
123
+ // -----------------------------------------------------------------------------
124
+ /**
125
+ * Validate a repo or user slug against server-level path config (§3.5.6).
126
+ * Per-repo config doesn't apply: slug is validated before any repo has a
127
+ * chance to override, and users are global.
128
+ *
129
+ * Slug hygiene numbers are pinned by m1-plan §5: ≤ 64 chars, no leading/
130
+ * trailing whitespace, no control chars.
131
+ */
132
+ export function validateSlug(slug, config) {
133
+ if (isReservedSegment(slug)) {
134
+ throw slugInvalid(slug, `slug is reserved ("${slug}")`);
135
+ }
136
+ if (slug.length > SLUG_MAX_LENGTH) {
137
+ throw slugInvalid(slug, `slug exceeds ${SLUG_MAX_LENGTH} characters`);
138
+ }
139
+ if (slug !== slug.trim()) {
140
+ throw slugInvalid(slug, "slug has leading or trailing whitespace");
141
+ }
142
+ if (slug.includes(PATH_SEPARATOR)) {
143
+ throw slugInvalid(slug, "slug contains '/'");
144
+ }
145
+ // Control chars (0x00–0x1F, 0x7F) are always illegal — they don't need to
146
+ // be in disallowed_chars to be forbidden.
147
+ for (const ch of slug) {
148
+ const code = ch.charCodeAt(0);
149
+ if (code < 0x20 || code === 0x7f) {
150
+ throw slugInvalid(slug, "slug contains a control character");
151
+ }
152
+ }
153
+ const sysSigil = startsWithAnySigil(slug, config.system_sigils);
154
+ if (sysSigil !== null) {
155
+ throw slugInvalid(slug, `slug starts with system sigil "${sysSigil}"`);
156
+ }
157
+ const hidSigil = startsWithAnySigil(slug, config.hidden_sigils);
158
+ if (hidSigil !== null) {
159
+ throw slugInvalid(slug, `slug starts with hidden sigil "${hidSigil}"`);
160
+ }
161
+ const bad = containsDisallowedChar(slug, config.disallowed_chars);
162
+ if (bad !== null) {
163
+ throw slugInvalid(slug, `slug contains disallowed character "${bad}"`);
164
+ }
165
+ }
166
+ // -----------------------------------------------------------------------------
167
+ // Sigil classification helpers (used by both writes and query default exclusion).
168
+ // -----------------------------------------------------------------------------
169
+ /**
170
+ * True if any segment of `path` starts with any of the given sigils.
171
+ * Design §5.1 uses this to compile the default-exclude clause.
172
+ */
173
+ export function pathHasSigilSegment(path, sigils) {
174
+ if (sigils.length === 0)
175
+ return false;
176
+ const segments = path.split(PATH_SEPARATOR);
177
+ for (const segment of segments) {
178
+ if (startsWithAnySigil(segment, sigils) !== null)
179
+ return true;
180
+ }
181
+ return false;
182
+ }
183
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/kernel/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,gFAAgF;AAChF,uDAAuD;AACvD,gFAAgF;AAEhF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AACnC,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC,uCAAuC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAmBlC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,MAAc,EAAE,EAAE,CACnD,IAAI,WAAW,CAAkB,cAAc,EAAE,EA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E,OAAO,IAAI,CAAC;IAChE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Opaque `version_id` wire encoding. Design §3.3 says clients echo these back
3
+ * and never construct or parse them; the server owns the representation.
4
+ *
5
+ * M0 decision (see docs/archive/m0-plan.md §5): `v{integer}` — trivially readable
6
+ * during dev/debug, opaque by *contract*, and already the form the design's
7
+ * deletion-path examples use (`:deleted/…/foo-v45129.md`).
8
+ */
9
+ export declare function encodeVersionId(id: number): string;
10
+ export declare function decodeVersionId(versionId: string): number | null;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Opaque `version_id` wire encoding. Design §3.3 says clients echo these back
3
+ * and never construct or parse them; the server owns the representation.
4
+ *
5
+ * M0 decision (see docs/archive/m0-plan.md §5): `v{integer}` — trivially readable
6
+ * during dev/debug, opaque by *contract*, and already the form the design's
7
+ * deletion-path examples use (`:deleted/…/foo-v45129.md`).
8
+ */
9
+ export function encodeVersionId(id) {
10
+ return `v${id}`;
11
+ }
12
+ export function decodeVersionId(versionId) {
13
+ const m = versionId.match(/^v(\d+)$/);
14
+ if (!m || !m[1])
15
+ return null;
16
+ const n = Number.parseInt(m[1], 10);
17
+ if (!Number.isSafeInteger(n) || n <= 0)
18
+ return null;
19
+ return n;
20
+ }
21
+ //# sourceMappingURL=version-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-id.js","sourceRoot":"","sources":["../../src/kernel/version-id.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,OAAO,IAAI,EAAE,EAAE,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACtC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACpC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACpD,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Kernel wire types — the shapes returned to surfaces (design §6.4).
3
+ * Integer ids never appear here; version_ids are opaque strings.
4
+ */
5
+ import type { KernelErrorCode } from "./errors.js";
6
+ export type PathConfig = {
7
+ disallowed_chars?: string[];
8
+ system_sigils?: string[];
9
+ hidden_sigils?: string[];
10
+ };
11
+ export type Repo = {
12
+ repo: string;
13
+ path_config: PathConfig | null;
14
+ };
15
+ export type Version = {
16
+ version_id: string;
17
+ prev_version_id: string | null;
18
+ next_version_id: string | null;
19
+ repo: string;
20
+ path: string;
21
+ frontmatter: Record<string, unknown>;
22
+ frontmatter_raw: string;
23
+ body: string;
24
+ author: string;
25
+ created_at: string;
26
+ content_hash: string;
27
+ };
28
+ export type PathWarning = {
29
+ version_id: string;
30
+ path: string;
31
+ reason: string;
32
+ };
33
+ /** The operation a version row represents, derived server-side (§3.3). */
34
+ export type VersionOp = "create" | "update" | "move" | "delete";
35
+ /**
36
+ * A lightweight change-feed pointer (sync/history plan §3.3). Consumers fetch
37
+ * bodies via `docs.get_version` only when needed; `content_hash` lets them
38
+ * skip no-op materializations and `prev_path` names both ends of a move/delete.
39
+ * `op` is derived server-side so consumers never parse path sigils.
40
+ */
41
+ export type VersionRef = {
42
+ version_id: string;
43
+ prev_version_id: string | null;
44
+ repo: string;
45
+ path: string;
46
+ prev_path: string | null;
47
+ content_hash: string;
48
+ op: VersionOp;
49
+ created_at: string;
50
+ };
51
+ /** Result of `history.since` — a page of refs plus the resume cursor (§3.3). */
52
+ export type HistorySincePage = {
53
+ refs: VersionRef[];
54
+ next_since: string;
55
+ };
56
+ /** One live-set entry from `history.index` (§3.4). */
57
+ export type IndexItem = {
58
+ path: string;
59
+ version_id: string;
60
+ content_hash: string;
61
+ };
62
+ /**
63
+ * A page of `history.index` (sync/history plan §3.4). `through_version` is the
64
+ * safe head `R` — captured on the first call, echoed on later pages;
65
+ * `next_after_version` is absent on the final page.
66
+ */
67
+ export type HistoryIndexPage = {
68
+ items: IndexItem[];
69
+ through_version: string;
70
+ next_after_version?: string;
71
+ };
72
+ /**
73
+ * A projected `query` hit (docs/query-select-plan.md). `query` names the
74
+ * fields it wants via `select` and gets back these lean objects rather than
75
+ * full `Version` rows. Following `GraphDocument`'s precedent, any field that
76
+ * isn't user-authored frontmatter carries the `$` sigil, so a document whose
77
+ * frontmatter literally contains a key named `path`/`repo` still round-trips
78
+ * without colliding with the system's `$path`/`$repo`.
79
+ */
80
+ export type QueryHit = {
81
+ [intrinsic: `$${string}`]: unknown;
82
+ [frontmatterKey: string]: unknown;
83
+ };
84
+ /** Direction lens for a graph expansion (§2.1). */
85
+ export type GraphDirection = "out" | "in" | "both";
86
+ /**
87
+ * Input to `kernel.graph` (§2.1). `roots` is a path or gitignore-style glob,
88
+ * string or array. `filter` is CEL, evaluated as *visibility* (not selection);
89
+ * `$degrees` is legal only here. `fields` restricts both traversal and the
90
+ * output `links`. `select` names bare frontmatter keys projected onto result
91
+ * documents (default `["title"]`).
92
+ */
93
+ export type GraphSpec = {
94
+ repo: string;
95
+ roots: string | string[];
96
+ direction?: GraphDirection;
97
+ degrees?: number;
98
+ fields?: string[];
99
+ filter?: string;
100
+ select?: string[];
101
+ max_documents?: number;
102
+ };
103
+ /**
104
+ * A result document (§2.2): the filter language's data model reified. Bare
105
+ * keys are `select`-projected frontmatter; `$`-keys are system intrinsics, so
106
+ * no user frontmatter key can collide. `$degrees` is call-relative (minimum
107
+ * hops from the nearest root under this call's lens) and must not be persisted
108
+ * across calls. `$links`/`$backlinks` are counts of distinct scope-visible
109
+ * documents, independent of this call's filter/fields/degrees.
110
+ */
111
+ export type GraphDocument = {
112
+ $path: string;
113
+ $degrees: number;
114
+ $links: number;
115
+ $backlinks: number;
116
+ [frontmatterKey: string]: unknown;
117
+ };
118
+ /** An induced link on the wire (§2.2): a distinct (source, target, field)
119
+ * triple, both endpoints present in `documents`. No `ord`, no counts. */
120
+ export type GraphLink = {
121
+ source: string;
122
+ target: string;
123
+ field: string;
124
+ };
125
+ /** Structured result of `kernel.graph` (§2.2). */
126
+ export type GraphResult = {
127
+ documents: GraphDocument[];
128
+ links: GraphLink[];
129
+ /** Paths of returned documents whose links were not fully enumerated —
130
+ * the continuation contract (§2.2, decision 10). Sorted by path. */
131
+ frontier: string[];
132
+ /** Largest d such that every effective-graph document within d hops of a
133
+ * root is present (§2.2). Equals `degrees` when `truncated` is false. */
134
+ complete_degrees: number;
135
+ /** True iff `max_documents` or the links ceiling elided anything. */
136
+ truncated: boolean;
137
+ };
138
+ /** Per-path failure from `docs.get_many` — the call still succeeds. */
139
+ export type DocGetManyError = {
140
+ path: string;
141
+ code: KernelErrorCode;
142
+ data: Record<string, unknown>;
143
+ };
144
+ /** Result of `docs.get_many` — found versions plus per-path errors. */
145
+ export type DocGetManyResult = {
146
+ items: Version[];
147
+ errors: DocGetManyError[];
148
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Kernel wire types — the shapes returned to surfaces (design §6.4).
3
+ * Integer ids never appear here; version_ids are opaque strings.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.js","sourceRoot":"","sources":["../../src/kernel/wire.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Links backfill — rebuild the derived index for a repo (design §11.2, WS3).
3
+ *
4
+ * Mirrors src/embed/backfill.ts in shape, but synchronous (no hook, no
5
+ * worker): extraction is pure CPU, so a full rebuild is just a walk over
6
+ * the repo's live versions, re-extracting + resolving each document's
7
+ * outbound edges. Because every live document already exists when the walk
8
+ * runs, candidate resolution binds immediately — no separate dangling
9
+ * sweep is needed for a full rebuild (a dangling edge here means the target
10
+ * genuinely has no live document).
11
+ *
12
+ * Used by `mrplex links backfill` (build the index for an existing corpus)
13
+ * and by link-config-change re-extraction (the effective config changed, so
14
+ * every document must be re-parsed under the new rules).
15
+ */
16
+ import type { Storage } from "../storage/types.js";
17
+ import type { LinkConfig } from "./link-config.js";
18
+ export type LinksBackfillReport = {
19
+ documents: number;
20
+ edges: number;
21
+ };
22
+ /**
23
+ * Rebuild `repo`'s link index from its current live versions. Idempotent:
24
+ * re-running produces the same rows (links_replace is delete-then-insert
25
+ * per source). Each document is reindexed in its own transaction so a huge
26
+ * repo doesn't hold one giant tx.
27
+ */
28
+ export declare function backfillRepoLinks(storage: Storage, repoId: number, config: LinkConfig): Promise<LinksBackfillReport>;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Links backfill — rebuild the derived index for a repo (design §11.2, WS3).
3
+ *
4
+ * Mirrors src/embed/backfill.ts in shape, but synchronous (no hook, no
5
+ * worker): extraction is pure CPU, so a full rebuild is just a walk over
6
+ * the repo's live versions, re-extracting + resolving each document's
7
+ * outbound edges. Because every live document already exists when the walk
8
+ * runs, candidate resolution binds immediately — no separate dangling
9
+ * sweep is needed for a full rebuild (a dangling edge here means the target
10
+ * genuinely has no live document).
11
+ *
12
+ * Used by `mrplex links backfill` (build the index for an existing corpus)
13
+ * and by link-config-change re-extraction (the effective config changed, so
14
+ * every document must be re-parsed under the new rules).
15
+ */
16
+ import { reindexOutboundLinks } from "./maintain.js";
17
+ /**
18
+ * Rebuild `repo`'s link index from its current live versions. Idempotent:
19
+ * re-running produces the same rows (links_replace is delete-then-insert
20
+ * per source). Each document is reindexed in its own transaction so a huge
21
+ * repo doesn't hold one giant tx.
22
+ */
23
+ export async function backfillRepoLinks(storage, repoId, config) {
24
+ const live = await storage.versions_live_by_repo(repoId);
25
+ let edges = 0;
26
+ for (const version of live) {
27
+ await reindexOutboundLinks(storage, config, repoId, version.document_id, version.path, version.body, version.frontmatter);
28
+ const rows = await storage.links_by_source(version.document_id);
29
+ edges += rows.length;
30
+ }
31
+ return { documents: live.length, edges };
32
+ }
33
+ //# sourceMappingURL=backfill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backfill.js","sourceRoot":"","sources":["../../src/links/backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAOrD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAgB,EAChB,MAAc,EACd,MAAkB;IAElB,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;QAC3B,MAAM,oBAAoB,CACxB,OAAO,EACP,MAAM,EACN,MAAM,EACN,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,WAAW,CACpB,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAChE,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Deterministic link extraction — design §11.2 "Extraction" (WS2).
3
+ *
4
+ * Body and frontmatter string values each honor their own LinkSyntaxes profile.
5
+ * Frontmatter links are discovered by walking all scalar string values — no
6
+ * per-field opt-in list.
7
+ */
8
+ import type { FrontmatterJson } from "../markdown/frontmatter.js";
9
+ import type { LinkConfig } from "./link-config.js";
10
+ /** The `field` value for body-derived edges (§11.2 reserved sentinel). */
11
+ export declare const BODY_FIELD = "$body";
12
+ /** Repo-root absolute path ending in `.md` — whole frontmatter value form. */
13
+ export declare const FRONTMATTER_FULLPATH_WHOLE: RegExp;
14
+ export type RawEdge = {
15
+ ord: number;
16
+ field: string;
17
+ target: string;
18
+ wikilink: boolean;
19
+ dest_span?: {
20
+ start: number;
21
+ end: number;
22
+ };
23
+ };
24
+ export type ExtractInput = {
25
+ body: string;
26
+ frontmatter: FrontmatterJson;
27
+ config: LinkConfig;
28
+ };
29
+ export declare function extractEdges(input: ExtractInput): RawEdge[];