@quolu/lattice 0.1.0 → 0.12.2

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 (370) hide show
  1. package/README.md +87 -4
  2. package/bin/lattice-bridge.mjs +87 -0
  3. package/bin/lattice-dashboard.mjs +70 -0
  4. package/bin/lattice-mcp.mjs +9 -9
  5. package/bin/lattice.mjs +61 -8
  6. package/docs/bridge-setup.md +87 -0
  7. package/docs/schemas/lattice.plan_create_input.v1.schema.json +56 -0
  8. package/docs/schemas/lattice.plan_create_input.v2.schema.json +72 -0
  9. package/docs/schemas/lattice.plan_create_input.v3.schema.json +81 -0
  10. package/package.json +19 -7
  11. package/sensor/dist/bin/command-supervision.d.ts +1 -1
  12. package/sensor/dist/bin/command-supervision.js +4 -4
  13. package/sensor/dist/bin/command-supervision.js.map +1 -1
  14. package/sensor/dist/bin/fatal-handler.js +2 -2
  15. package/sensor/dist/bin/fatal-handler.js.map +1 -1
  16. package/sensor/dist/bin/{codegraph.js → lattice-sensor.js} +207 -328
  17. package/sensor/dist/bin/node-version-check.d.ts +7 -5
  18. package/sensor/dist/bin/node-version-check.d.ts.map +1 -1
  19. package/sensor/dist/bin/node-version-check.js +19 -14
  20. package/sensor/dist/bin/node-version-check.js.map +1 -1
  21. package/sensor/dist/context/index.d.ts +1 -1
  22. package/sensor/dist/context/index.js +6 -6
  23. package/sensor/dist/context/index.js.map +1 -1
  24. package/sensor/dist/db/index.d.ts +5 -5
  25. package/sensor/dist/db/index.d.ts.map +1 -1
  26. package/sensor/dist/db/index.js +7 -7
  27. package/sensor/dist/db/index.js.map +1 -1
  28. package/sensor/dist/db/migrations.js +1 -1
  29. package/sensor/dist/db/migrations.js.map +1 -1
  30. package/sensor/dist/db/queries.d.ts +1 -1
  31. package/sensor/dist/db/queries.js +5 -5
  32. package/sensor/dist/db/queries.js.map +1 -1
  33. package/sensor/dist/db/schema.sql +2 -2
  34. package/sensor/dist/db/sqlite-adapter.d.ts +2 -2
  35. package/sensor/dist/db/sqlite-adapter.js +3 -3
  36. package/sensor/dist/db/sqlite-adapter.js.map +1 -1
  37. package/sensor/dist/db/wal-valve.d.ts +1 -1
  38. package/sensor/dist/db/wal-valve.d.ts.map +1 -1
  39. package/sensor/dist/db/wal-valve.js +2 -2
  40. package/sensor/dist/db/wal-valve.js.map +1 -1
  41. package/sensor/dist/directory.d.ts +27 -63
  42. package/sensor/dist/directory.d.ts.map +1 -1
  43. package/sensor/dist/directory.js +78 -134
  44. package/sensor/dist/directory.js.map +1 -1
  45. package/sensor/dist/errors.d.ts +15 -15
  46. package/sensor/dist/errors.d.ts.map +1 -1
  47. package/sensor/dist/errors.js +21 -21
  48. package/sensor/dist/errors.js.map +1 -1
  49. package/sensor/dist/extraction/dynamic-import.d.ts +1 -1
  50. package/sensor/dist/extraction/dynamic-import.js +1 -1
  51. package/sensor/dist/extraction/extraction-version.d.ts +1 -1
  52. package/sensor/dist/extraction/extraction-version.js +1 -1
  53. package/sensor/dist/extraction/generated-detection.d.ts +1 -1
  54. package/sensor/dist/extraction/generated-detection.js +1 -1
  55. package/sensor/dist/extraction/grammars.d.ts +3 -3
  56. package/sensor/dist/extraction/grammars.js +5 -5
  57. package/sensor/dist/extraction/grammars.js.map +1 -1
  58. package/sensor/dist/extraction/index.d.ts +6 -6
  59. package/sensor/dist/extraction/index.js +50 -50
  60. package/sensor/dist/extraction/index.js.map +1 -1
  61. package/sensor/dist/extraction/kernel/decode.d.ts +1 -1
  62. package/sensor/dist/extraction/kernel/decode.js +1 -1
  63. package/sensor/dist/extraction/kernel/index.d.ts +3 -3
  64. package/sensor/dist/extraction/kernel/index.js +6 -6
  65. package/sensor/dist/extraction/kernel/index.js.map +1 -1
  66. package/sensor/dist/extraction/kernel/layout.d.ts +1 -1
  67. package/sensor/dist/extraction/kernel/layout.js +1 -1
  68. package/sensor/dist/extraction/kernel/loader.d.ts +6 -6
  69. package/sensor/dist/extraction/kernel/loader.js +13 -13
  70. package/sensor/dist/extraction/kernel/loader.js.map +1 -1
  71. package/sensor/dist/extraction/languages/cfquery.d.ts +1 -1
  72. package/sensor/dist/extraction/languages/cfquery.js +1 -1
  73. package/sensor/dist/extraction/languages/lua.d.ts +11 -0
  74. package/sensor/dist/extraction/languages/lua.d.ts.map +1 -1
  75. package/sensor/dist/extraction/languages/lua.js +1 -0
  76. package/sensor/dist/extraction/languages/lua.js.map +1 -1
  77. package/sensor/dist/extraction/parse-pool.d.ts +5 -5
  78. package/sensor/dist/extraction/parse-pool.d.ts.map +1 -1
  79. package/sensor/dist/extraction/parse-pool.js +4 -4
  80. package/sensor/dist/extraction/parse-worker.js +1 -1
  81. package/sensor/dist/extraction/parse-worker.js.map +1 -1
  82. package/sensor/dist/extraction/store-writer.d.ts +1 -1
  83. package/sensor/dist/extraction/store-writer.js +1 -1
  84. package/sensor/dist/extraction/svelte-extractor.d.ts +1 -1
  85. package/sensor/dist/extraction/svelte-extractor.js +1 -1
  86. package/sensor/dist/extraction/tree-sitter-helpers.js +1 -1
  87. package/sensor/dist/extraction/tree-sitter.d.ts +2 -2
  88. package/sensor/dist/extraction/tree-sitter.d.ts.map +1 -1
  89. package/sensor/dist/extraction/tree-sitter.js +71 -4
  90. package/sensor/dist/extraction/tree-sitter.js.map +1 -1
  91. package/sensor/dist/extraction/wasm-runtime-flags.d.ts +2 -2
  92. package/sensor/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
  93. package/sensor/dist/extraction/wasm-runtime-flags.js +5 -5
  94. package/sensor/dist/extraction/wasm-runtime-flags.js.map +1 -1
  95. package/sensor/dist/index.d.ts +36 -36
  96. package/sensor/dist/index.d.ts.map +1 -1
  97. package/sensor/dist/index.js +71 -71
  98. package/sensor/dist/index.js.map +1 -1
  99. package/sensor/dist/mcp/daemon-manager.js +1 -1
  100. package/sensor/dist/mcp/daemon-paths.d.ts +3 -3
  101. package/sensor/dist/mcp/daemon-paths.js +7 -7
  102. package/sensor/dist/mcp/daemon-paths.js.map +1 -1
  103. package/sensor/dist/mcp/daemon-registry.d.ts +2 -2
  104. package/sensor/dist/mcp/daemon-registry.js +5 -5
  105. package/sensor/dist/mcp/daemon.d.ts +7 -7
  106. package/sensor/dist/mcp/daemon.d.ts.map +1 -1
  107. package/sensor/dist/mcp/daemon.js +21 -21
  108. package/sensor/dist/mcp/daemon.js.map +1 -1
  109. package/sensor/dist/mcp/dynamic-boundaries.js +1 -1
  110. package/sensor/dist/mcp/engine.d.ts +9 -9
  111. package/sensor/dist/mcp/engine.d.ts.map +1 -1
  112. package/sensor/dist/mcp/engine.js +44 -44
  113. package/sensor/dist/mcp/engine.js.map +1 -1
  114. package/sensor/dist/mcp/index.d.ts +14 -14
  115. package/sensor/dist/mcp/index.d.ts.map +1 -1
  116. package/sensor/dist/mcp/index.js +41 -41
  117. package/sensor/dist/mcp/index.js.map +1 -1
  118. package/sensor/dist/mcp/liveness-watchdog.js +7 -7
  119. package/sensor/dist/mcp/liveness-watchdog.js.map +1 -1
  120. package/sensor/dist/mcp/ppid-watchdog.d.ts +3 -3
  121. package/sensor/dist/mcp/ppid-watchdog.js +2 -2
  122. package/sensor/dist/mcp/proxy.d.ts.map +1 -1
  123. package/sensor/dist/mcp/proxy.js +37 -37
  124. package/sensor/dist/mcp/proxy.js.map +1 -1
  125. package/sensor/dist/mcp/query-pool.d.ts +3 -3
  126. package/sensor/dist/mcp/query-pool.js +7 -7
  127. package/sensor/dist/mcp/query-pool.js.map +1 -1
  128. package/sensor/dist/mcp/query-worker.d.ts +2 -2
  129. package/sensor/dist/mcp/query-worker.js +7 -7
  130. package/sensor/dist/mcp/query-worker.js.map +1 -1
  131. package/sensor/dist/mcp/server-instructions.d.ts +10 -12
  132. package/sensor/dist/mcp/server-instructions.d.ts.map +1 -1
  133. package/sensor/dist/mcp/server-instructions.js +39 -37
  134. package/sensor/dist/mcp/server-instructions.js.map +1 -1
  135. package/sensor/dist/mcp/session.d.ts +2 -2
  136. package/sensor/dist/mcp/session.js +18 -18
  137. package/sensor/dist/mcp/session.js.map +1 -1
  138. package/sensor/dist/mcp/startup-handshake.d.ts +3 -3
  139. package/sensor/dist/mcp/startup-handshake.d.ts.map +1 -1
  140. package/sensor/dist/mcp/startup-handshake.js +3 -3
  141. package/sensor/dist/mcp/startup-handshake.js.map +1 -1
  142. package/sensor/dist/mcp/tools.d.ts +53 -53
  143. package/sensor/dist/mcp/tools.d.ts.map +1 -1
  144. package/sensor/dist/mcp/tools.js +180 -216
  145. package/sensor/dist/mcp/tools.js.map +1 -1
  146. package/sensor/dist/mcp/transport.d.ts +1 -1
  147. package/sensor/dist/mcp/transport.js +6 -6
  148. package/sensor/dist/mcp/transport.js.map +1 -1
  149. package/sensor/dist/mcp/version.d.ts +2 -2
  150. package/sensor/dist/mcp/version.d.ts.map +1 -1
  151. package/sensor/dist/mcp/version.js +3 -3
  152. package/sensor/dist/mcp/version.js.map +1 -1
  153. package/sensor/dist/project-config.d.ts +6 -6
  154. package/sensor/dist/project-config.d.ts.map +1 -1
  155. package/sensor/dist/project-config.js +10 -10
  156. package/sensor/dist/project-config.js.map +1 -1
  157. package/sensor/dist/resolution/callback-synthesizer.js +4 -4
  158. package/sensor/dist/resolution/callback-synthesizer.js.map +1 -1
  159. package/sensor/dist/resolution/frameworks/drupal.d.ts +3 -3
  160. package/sensor/dist/resolution/frameworks/drupal.js +3 -3
  161. package/sensor/dist/resolution/frameworks/fabric.js +1 -1
  162. package/sensor/dist/resolution/frameworks/fabric.js.map +1 -1
  163. package/sensor/dist/resolution/frameworks/java.js +1 -1
  164. package/sensor/dist/resolution/frameworks/java.js.map +1 -1
  165. package/sensor/dist/resolution/frameworks/svelte.js +1 -1
  166. package/sensor/dist/resolution/frameworks/svelte.js.map +1 -1
  167. package/sensor/dist/resolution/goframe-synthesizer.d.ts +1 -1
  168. package/sensor/dist/resolution/goframe-synthesizer.js +1 -1
  169. package/sensor/dist/resolution/index.d.ts +1 -1
  170. package/sensor/dist/resolution/index.js +9 -9
  171. package/sensor/dist/resolution/index.js.map +1 -1
  172. package/sensor/dist/resolution/name-matcher.js +2 -2
  173. package/sensor/dist/resolution/name-matcher.js.map +1 -1
  174. package/sensor/dist/resolution/resolver-pool.d.ts +2 -2
  175. package/sensor/dist/resolution/resolver-pool.js +4 -4
  176. package/sensor/dist/resolution/resolver-pool.js.map +1 -1
  177. package/sensor/dist/resolution/resolver-worker.js +2 -2
  178. package/sensor/dist/resolution/resolver-worker.js.map +1 -1
  179. package/sensor/dist/resolution/workspace-packages.js +1 -1
  180. package/sensor/dist/resolution/workspace-packages.js.map +1 -1
  181. package/sensor/dist/search/identifier-segments.d.ts +1 -1
  182. package/sensor/dist/search/identifier-segments.js +1 -1
  183. package/sensor/dist/search/query-utils.d.ts +1 -0
  184. package/sensor/dist/search/query-utils.d.ts.map +1 -1
  185. package/sensor/dist/search/query-utils.js +10 -3
  186. package/sensor/dist/search/query-utils.js.map +1 -1
  187. package/sensor/dist/sync/git-hooks.d.ts +9 -9
  188. package/sensor/dist/sync/git-hooks.d.ts.map +1 -1
  189. package/sensor/dist/sync/git-hooks.js +15 -15
  190. package/sensor/dist/sync/git-hooks.js.map +1 -1
  191. package/sensor/dist/sync/watch-policy.d.ts +2 -2
  192. package/sensor/dist/sync/watch-policy.js +5 -5
  193. package/sensor/dist/sync/watch-policy.js.map +1 -1
  194. package/sensor/dist/sync/watcher.d.ts +2 -2
  195. package/sensor/dist/sync/watcher.d.ts.map +1 -1
  196. package/sensor/dist/sync/watcher.js +16 -16
  197. package/sensor/dist/sync/watcher.js.map +1 -1
  198. package/sensor/dist/sync/worktree.d.ts +5 -5
  199. package/sensor/dist/sync/worktree.d.ts.map +1 -1
  200. package/sensor/dist/sync/worktree.js +9 -9
  201. package/sensor/dist/sync/worktree.js.map +1 -1
  202. package/sensor/dist/telemetry/index.d.ts +8 -8
  203. package/sensor/dist/telemetry/index.d.ts.map +1 -1
  204. package/sensor/dist/telemetry/index.js +16 -16
  205. package/sensor/dist/telemetry/index.js.map +1 -1
  206. package/sensor/dist/types.d.ts +2 -2
  207. package/sensor/dist/types.js +1 -1
  208. package/sensor/dist/ui/color.d.ts +2 -2
  209. package/sensor/dist/ui/color.js +2 -2
  210. package/sensor/dist/ui/glyphs.d.ts +3 -3
  211. package/sensor/dist/ui/glyphs.js +7 -7
  212. package/sensor/dist/ui/glyphs.js.map +1 -1
  213. package/sensor/dist/utils.d.ts +4 -4
  214. package/sensor/dist/utils.js +8 -8
  215. package/sensor/dist/utils.js.map +1 -1
  216. package/sensor/package.json +8 -13
  217. package/src/artifact-contracts.mjs +2 -2
  218. package/src/boundary-compiler.mjs +28 -28
  219. package/src/boundary-observation-compiler-v2.mjs +10 -10
  220. package/src/bounded-seam.mjs +144 -0
  221. package/src/bridge-cli.mjs +227 -0
  222. package/src/bridge-config.mjs +346 -0
  223. package/src/bridge-daemon.mjs +328 -0
  224. package/src/bridge-launch-agent.mjs +311 -0
  225. package/src/bridge-server.mjs +309 -0
  226. package/src/cli-help.mjs +163 -0
  227. package/src/control-compiler.mjs +30 -30
  228. package/src/dag-chain.mjs +261 -0
  229. package/src/factory-diagnostics.mjs +8 -7
  230. package/src/hash-chain.mjs +76 -0
  231. package/src/node-version-guard.mjs +5 -4
  232. package/src/project-cli.mjs +392 -0
  233. package/src/project-identity.mjs +71 -0
  234. package/src/rc1-evidence-bundle.mjs +16 -16
  235. package/src/rc1-v4-campaign.mjs +15 -14
  236. package/src/rc1-v5-artifact-set.mjs +2 -2
  237. package/src/rc1-v5-campaign.mjs +15 -14
  238. package/src/rc1-v6-artifact-set.mjs +18 -18
  239. package/src/rc1-v6-campaign.mjs +16 -16
  240. package/src/rc1-v6-causal-binding.mjs +16 -14
  241. package/src/rc1-v6-measurement.mjs +20 -38
  242. package/src/rc2-artifact-set.mjs +45 -40
  243. package/src/rc2-campaign.mjs +48 -66
  244. package/src/rc2-delivery-policy-front-end.mjs +30 -30
  245. package/src/rc2-rc1-transfer-front-end.mjs +5 -5
  246. package/src/rc3-actual-dogfood.mjs +6 -6
  247. package/src/rc3-dogfood-scaffold.mjs +12 -7
  248. package/src/rc3-scripted-campaign.mjs +75 -21
  249. package/src/rc4-stage1-dogfood.mjs +24 -7
  250. package/src/runtime-cli.mjs +2424 -45
  251. package/src/runtime-contracts.mjs +7 -7
  252. package/src/runtime-control-store.mjs +547 -0
  253. package/src/runtime-controller-protocol.mjs +517 -0
  254. package/src/runtime-direct-os-observer.mjs +284 -0
  255. package/src/runtime-engine.mjs +2 -2
  256. package/src/runtime-errors.mjs +1 -1
  257. package/src/runtime-event-store.mjs +15 -43
  258. package/src/runtime-front-end.mjs +26 -26
  259. package/src/runtime-gate-store.mjs +477 -0
  260. package/src/runtime-hold-recompile.mjs +214 -23
  261. package/src/runtime-lifecycle-lock.mjs +290 -0
  262. package/src/runtime-managed-supervisor.mjs +1276 -0
  263. package/src/runtime-multi-epoch-store.mjs +761 -0
  264. package/src/runtime-projection.mjs +62 -0
  265. package/src/seam-transform.mjs +38 -38
  266. package/src/{codegraph-adapter.mjs → sensor-adapter.mjs} +7 -7
  267. package/src/sensor-cli.mjs +107 -0
  268. package/src/sensor-runtime.mjs +48 -0
  269. package/src/timestamp-contract.mjs +8 -0
  270. package/src/todo-chain.mjs +178 -0
  271. package/src/todo-cli.mjs +1032 -0
  272. package/src/todo-contracts.mjs +501 -0
  273. package/src/todo-dashboard-registry.mjs +318 -0
  274. package/src/todo-gantt-html.mjs +416 -0
  275. package/src/todo-gantt-layout.mjs +603 -0
  276. package/src/todo-gantt-live.mjs +269 -0
  277. package/src/todo-gantt-presentation.mjs +217 -0
  278. package/src/todo-gantt-svg.mjs +249 -0
  279. package/src/todo-markdown-renderer.mjs +260 -0
  280. package/src/todo-migration.mjs +260 -0
  281. package/src/todo-narrative-anchor.mjs +130 -0
  282. package/src/todo-revision.mjs +425 -0
  283. package/src/todo-status.mjs +340 -0
  284. package/src/todo-store.mjs +3451 -0
  285. package/src/treatment-compiler.mjs +28 -28
  286. package/src/treatment-runner.mjs +42 -44
  287. package/sensor/dist/bin/codegraph.d.ts +0 -26
  288. package/sensor/dist/bin/codegraph.d.ts.map +0 -1
  289. package/sensor/dist/bin/codegraph.js.map +0 -1
  290. package/sensor/dist/bin/uninstall.d.ts +0 -14
  291. package/sensor/dist/bin/uninstall.d.ts.map +0 -1
  292. package/sensor/dist/bin/uninstall.js +0 -36
  293. package/sensor/dist/bin/uninstall.js.map +0 -1
  294. package/sensor/dist/installer/beta-signup.d.ts +0 -54
  295. package/sensor/dist/installer/beta-signup.d.ts.map +0 -1
  296. package/sensor/dist/installer/beta-signup.js +0 -178
  297. package/sensor/dist/installer/beta-signup.js.map +0 -1
  298. package/sensor/dist/installer/config-writer.d.ts +0 -28
  299. package/sensor/dist/installer/config-writer.d.ts.map +0 -1
  300. package/sensor/dist/installer/config-writer.js +0 -91
  301. package/sensor/dist/installer/config-writer.js.map +0 -1
  302. package/sensor/dist/installer/index.d.ts +0 -142
  303. package/sensor/dist/installer/index.d.ts.map +0 -1
  304. package/sensor/dist/installer/index.js +0 -622
  305. package/sensor/dist/installer/index.js.map +0 -1
  306. package/sensor/dist/installer/instructions-template.d.ts +0 -41
  307. package/sensor/dist/installer/instructions-template.d.ts.map +0 -1
  308. package/sensor/dist/installer/instructions-template.js +0 -53
  309. package/sensor/dist/installer/instructions-template.js.map +0 -1
  310. package/sensor/dist/installer/targets/antigravity.d.ts +0 -57
  311. package/sensor/dist/installer/targets/antigravity.d.ts.map +0 -1
  312. package/sensor/dist/installer/targets/antigravity.js +0 -308
  313. package/sensor/dist/installer/targets/antigravity.js.map +0 -1
  314. package/sensor/dist/installer/targets/claude.d.ts +0 -62
  315. package/sensor/dist/installer/targets/claude.d.ts.map +0 -1
  316. package/sensor/dist/installer/targets/claude.js +0 -454
  317. package/sensor/dist/installer/targets/claude.js.map +0 -1
  318. package/sensor/dist/installer/targets/codex.d.ts +0 -18
  319. package/sensor/dist/installer/targets/codex.d.ts.map +0 -1
  320. package/sensor/dist/installer/targets/codex.js +0 -185
  321. package/sensor/dist/installer/targets/codex.js.map +0 -1
  322. package/sensor/dist/installer/targets/cursor.d.ts +0 -35
  323. package/sensor/dist/installer/targets/cursor.d.ts.map +0 -1
  324. package/sensor/dist/installer/targets/cursor.js +0 -254
  325. package/sensor/dist/installer/targets/cursor.js.map +0 -1
  326. package/sensor/dist/installer/targets/gemini.d.ts +0 -26
  327. package/sensor/dist/installer/targets/gemini.d.ts.map +0 -1
  328. package/sensor/dist/installer/targets/gemini.js +0 -165
  329. package/sensor/dist/installer/targets/gemini.js.map +0 -1
  330. package/sensor/dist/installer/targets/hermes.d.ts +0 -18
  331. package/sensor/dist/installer/targets/hermes.d.ts.map +0 -1
  332. package/sensor/dist/installer/targets/hermes.js +0 -359
  333. package/sensor/dist/installer/targets/hermes.js.map +0 -1
  334. package/sensor/dist/installer/targets/kiro.d.ts +0 -27
  335. package/sensor/dist/installer/targets/kiro.d.ts.map +0 -1
  336. package/sensor/dist/installer/targets/kiro.js +0 -178
  337. package/sensor/dist/installer/targets/kiro.js.map +0 -1
  338. package/sensor/dist/installer/targets/opencode.d.ts +0 -38
  339. package/sensor/dist/installer/targets/opencode.d.ts.map +0 -1
  340. package/sensor/dist/installer/targets/opencode.js +0 -288
  341. package/sensor/dist/installer/targets/opencode.js.map +0 -1
  342. package/sensor/dist/installer/targets/registry.d.ts +0 -35
  343. package/sensor/dist/installer/targets/registry.d.ts.map +0 -1
  344. package/sensor/dist/installer/targets/registry.js +0 -91
  345. package/sensor/dist/installer/targets/registry.js.map +0 -1
  346. package/sensor/dist/installer/targets/shared.d.ts +0 -101
  347. package/sensor/dist/installer/targets/shared.d.ts.map +0 -1
  348. package/sensor/dist/installer/targets/shared.js +0 -264
  349. package/sensor/dist/installer/targets/shared.js.map +0 -1
  350. package/sensor/dist/installer/targets/toml.d.ts +0 -52
  351. package/sensor/dist/installer/targets/toml.d.ts.map +0 -1
  352. package/sensor/dist/installer/targets/toml.js +0 -147
  353. package/sensor/dist/installer/targets/toml.js.map +0 -1
  354. package/sensor/dist/installer/targets/types.d.ts +0 -108
  355. package/sensor/dist/installer/targets/types.d.ts.map +0 -1
  356. package/sensor/dist/installer/targets/types.js +0 -16
  357. package/sensor/dist/installer/targets/types.js.map +0 -1
  358. package/sensor/dist/upgrade/index.d.ts +0 -171
  359. package/sensor/dist/upgrade/index.d.ts.map +0 -1
  360. package/sensor/dist/upgrade/index.js +0 -659
  361. package/sensor/dist/upgrade/index.js.map +0 -1
  362. package/sensor/dist/upgrade/remove-binary.d.ts +0 -87
  363. package/sensor/dist/upgrade/remove-binary.d.ts.map +0 -1
  364. package/sensor/dist/upgrade/remove-binary.js +0 -289
  365. package/sensor/dist/upgrade/remove-binary.js.map +0 -1
  366. package/sensor/dist/upgrade/update-check.d.ts +0 -92
  367. package/sensor/dist/upgrade/update-check.d.ts.map +0 -1
  368. package/sensor/dist/upgrade/update-check.js +0 -258
  369. package/sensor/dist/upgrade/update-check.js.map +0 -1
  370. package/src/bootstrap.mjs +0 -88
@@ -0,0 +1,144 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { mkdtemp, rm } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import path from 'node:path';
5
+
6
+ import {
7
+ exactRecord, isTodoDigest, isTodoIdentifier, isTodoRef, todoSelfDigest,
8
+ } from './todo-contracts.mjs';
9
+
10
+ const GIT_OID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u;
11
+
12
+ function sortedUniqueRefs(value, { nonempty = false } = {}) {
13
+ return Array.isArray(value) && (!nonempty || value.length > 0) && value.every(isTodoRef)
14
+ && value.every((entry, index) => index === 0 || value[index - 1] < entry);
15
+ }
16
+
17
+ export function validateBoundedSeamCandidate(value) {
18
+ try {
19
+ return exactRecord(value, [
20
+ 'schema', 'candidate_id', 'base_sha', 'manifest_digest', 'finding_digest',
21
+ 'todo_refs', 'anchor', 'allowed_paths', 'required_paths', 'verification_policy',
22
+ 'candidate_digest',
23
+ ]) && value.schema === 'lattice.bounded_seam_candidate.v1'
24
+ && isTodoIdentifier(value.candidate_id) && GIT_OID.test(value.base_sha)
25
+ && isTodoDigest(value.manifest_digest) && isTodoDigest(value.finding_digest)
26
+ && Array.isArray(value.todo_refs) && value.todo_refs.length >= 2
27
+ && value.todo_refs.every((entry) => exactRecord(entry, ['plan_key', 'task_id'])
28
+ && isTodoIdentifier(entry.plan_key) && isTodoIdentifier(entry.task_id))
29
+ && value.todo_refs.every((entry, index) => index === 0
30
+ || `${value.todo_refs[index - 1].plan_key}\0${value.todo_refs[index - 1].task_id}`
31
+ < `${entry.plan_key}\0${entry.task_id}`)
32
+ && exactRecord(value.anchor, ['path', 'symbol', 'start_line', 'end_line'])
33
+ && isTodoRef(value.anchor.path) && isTodoIdentifier(value.anchor.symbol)
34
+ && Number.isSafeInteger(value.anchor.start_line) && value.anchor.start_line >= 1
35
+ && Number.isSafeInteger(value.anchor.end_line) && value.anchor.end_line >= value.anchor.start_line
36
+ && sortedUniqueRefs(value.allowed_paths, { nonempty: true })
37
+ && sortedUniqueRefs(value.required_paths, { nonempty: true })
38
+ && value.required_paths.every((entry) => value.allowed_paths.includes(entry))
39
+ && value.allowed_paths.includes(value.anchor.path)
40
+ && exactRecord(value.verification_policy, [
41
+ 'focused_test_ids', 'require_behavior_equivalence', 'require_fresh_sensor',
42
+ 'require_overlap_reduction',
43
+ ]) && Array.isArray(value.verification_policy.focused_test_ids)
44
+ && value.verification_policy.focused_test_ids.length > 0
45
+ && value.verification_policy.focused_test_ids.every(isTodoIdentifier)
46
+ && value.verification_policy.focused_test_ids.every((entry, index) => index === 0
47
+ || value.verification_policy.focused_test_ids[index - 1] < entry)
48
+ && value.verification_policy.require_behavior_equivalence === true
49
+ && value.verification_policy.require_fresh_sensor === true
50
+ && value.verification_policy.require_overlap_reduction === true
51
+ && isTodoDigest(value.candidate_digest)
52
+ && value.candidate_digest === todoSelfDigest(value, 'candidate_digest');
53
+ } catch { return false; }
54
+ }
55
+
56
+ function run(command, args, cwd) {
57
+ return new Promise((resolve, reject) => {
58
+ const child = spawn(command, args, { cwd, shell: false, stdio: ['ignore', 'pipe', 'pipe'] });
59
+ const stdout = []; const stderr = [];
60
+ child.stdout.on('data', (chunk) => stdout.push(chunk));
61
+ child.stderr.on('data', (chunk) => stderr.push(chunk));
62
+ child.once('error', reject);
63
+ child.once('close', (code, signal) => {
64
+ if (code === 0 && signal === null) resolve(Buffer.concat(stdout));
65
+ else reject(new Error(`${command} failed (${signal ?? code}): ${Buffer.concat(stderr).toString('utf8').trim()}`));
66
+ });
67
+ });
68
+ }
69
+
70
+ async function fingerprint(repoRoot) {
71
+ const [head, status, refs] = await Promise.all([
72
+ run('git', ['rev-parse', 'HEAD'], repoRoot),
73
+ run('git', ['status', '--porcelain=v1', '--untracked-files=all'], repoRoot),
74
+ run('git', ['for-each-ref', '--format=%(refname) %(objectname)'], repoRoot),
75
+ ]);
76
+ return Buffer.concat([head, status, refs]).toString('hex');
77
+ }
78
+
79
+ async function changedPaths(worktreePath) {
80
+ const bytes = await run('git', ['status', '--porcelain=v1', '-z', '--untracked-files=all'], worktreePath);
81
+ const fields = bytes.toString('utf8').split('\0').filter(Boolean);
82
+ const paths = [];
83
+ for (let index = 0; index < fields.length; index += 1) {
84
+ const field = fields[index];
85
+ const status = field.slice(0, 2);
86
+ paths.push(field.slice(3));
87
+ if (status.includes('R') || status.includes('C')) paths.push(fields[++index]);
88
+ }
89
+ return [...new Set(paths)].sort();
90
+ }
91
+
92
+ function outcome(candidate, decision, reason, changed, verification, cleanupOk) {
93
+ const result = { schema: 'lattice.bounded_seam_outcome.v1', candidate_id: candidate.candidate_id,
94
+ candidate_digest: candidate.candidate_digest, decision, reason, changed_paths: changed,
95
+ verification, cleanup_ok: cleanupOk, outcome_digest: '' };
96
+ result.outcome_digest = todoSelfDigest(result, 'outcome_digest');
97
+ return result;
98
+ }
99
+
100
+ export async function runBoundedSeamCandidate({ repoRoot, candidate, transform, verify }) {
101
+ if (!validateBoundedSeamCandidate(candidate)) throw new TypeError('bounded seam candidate invalid');
102
+ if (typeof repoRoot !== 'string' || typeof transform !== 'function' || typeof verify !== 'function') {
103
+ throw new TypeError('bounded seam runner options invalid');
104
+ }
105
+ const before = await fingerprint(repoRoot);
106
+ const head = (await run('git', ['rev-parse', 'HEAD'], repoRoot)).toString('utf8').trim();
107
+ if (head !== candidate.base_sha) return outcome(candidate, 'rejected', 'stale_base', [], null, true);
108
+ const worktreeRoot = await mkdtemp(path.join(tmpdir(), 'lattice-bounded-seam-'));
109
+ const worktreePath = path.join(worktreeRoot, 'tree');
110
+ let changed = [];
111
+ let result;
112
+ let cleanupOk = false;
113
+ try {
114
+ await run('git', ['worktree', 'add', '--detach', worktreePath, candidate.base_sha], repoRoot);
115
+ try { await transform({ worktreePath, candidate: structuredClone(candidate) }); }
116
+ catch { result = outcome(candidate, 'rejected', 'transform_failed', [], null, false); }
117
+ if (result === undefined) changed = await changedPaths(worktreePath);
118
+ if (result === undefined && (changed.some((entry) => !candidate.allowed_paths.includes(entry))
119
+ || candidate.required_paths.some((entry) => !changed.includes(entry)))) {
120
+ result = outcome(candidate, 'rejected', 'scope_drift', changed, null, false);
121
+ } else if (result === undefined) {
122
+ let verification;
123
+ try { verification = await verify({ worktreePath, candidate: structuredClone(candidate), changed_paths: changed }); }
124
+ catch { verification = null; }
125
+ const valid = exactRecord(verification, [
126
+ 'behavior_equivalent', 'focused_tests_passed', 'sensor_fresh', 'overlap_reduced',
127
+ 'evidence_digest',
128
+ ]) && verification.behavior_equivalent === true && verification.focused_tests_passed === true
129
+ && verification.sensor_fresh === true && verification.overlap_reduced === true
130
+ && isTodoDigest(verification.evidence_digest);
131
+ result = outcome(candidate, valid ? 'accepted' : 'rejected',
132
+ valid ? 'all_gates_passed' : 'verification_failed', changed, verification, false);
133
+ }
134
+ } finally {
135
+ try {
136
+ await run('git', ['worktree', 'remove', '--force', worktreePath], repoRoot);
137
+ await rm(worktreeRoot, { recursive: true, force: true });
138
+ cleanupOk = true;
139
+ } catch { cleanupOk = false; }
140
+ }
141
+ const after = await fingerprint(repoRoot);
142
+ if (before !== after) throw new TypeError('bounded seam runner modified canonical repository');
143
+ return outcome(candidate, result.decision, result.reason, changed, result.verification, cleanupOk);
144
+ }
@@ -0,0 +1,227 @@
1
+ import { isIP } from 'node:net';
2
+ import * as clack from '@clack/prompts';
3
+
4
+ import {
5
+ BridgeConfigError, configureBridge, disableBridge, readBridgeConfig, restoreBridgeConfig,
6
+ normalizeBridgeAllowedHost, withBridgeOperationLock,
7
+ } from './bridge-config.mjs';
8
+ import {
9
+ clearBridgeStopControl, ensureBridgeDaemon, readBridgeDaemonDescriptor,
10
+ removeBridgeDaemonActiveMarker, removeBridgeDaemonDescriptor, requestBridgeDaemonStop,
11
+ stopBridgeDaemon,
12
+ } from './bridge-daemon.mjs';
13
+ import {
14
+ disableBridgeLaunchAgent, installBridgeLaunchAgent, restoreBridgeLaunchAgent,
15
+ snapshotBridgeLaunchAgent,
16
+ } from './bridge-launch-agent.mjs';
17
+
18
+ const RESULT_SCHEMA = 'lattice.bridge_cli_result.v1';
19
+
20
+ function fail(stderr, code, message) {
21
+ stderr.write(`${JSON.stringify({ schema: 'lattice.cli_error.v2', code, message })}\n`);
22
+ return 2;
23
+ }
24
+
25
+ function parseOptions(words) {
26
+ const options = { address: undefined, port: undefined, upstream: undefined, allowedHosts: [] };
27
+ for (let index = 0; index < words.length; index += 1) {
28
+ const flag = words[index];
29
+ if (flag === '--listen') {
30
+ if (options.address !== undefined) throw new BridgeConfigError('USAGE', 'duplicate --listen');
31
+ options.address = words[++index];
32
+ }
33
+ else if (flag === '--port') {
34
+ if (options.port !== undefined) throw new BridgeConfigError('USAGE', 'duplicate --port');
35
+ const value = words[++index];
36
+ options.port = value === 'auto' ? null : Number(value);
37
+ } else if (flag === '--dashboard') {
38
+ if (options.upstream !== undefined) throw new BridgeConfigError('USAGE', 'upstream option is ambiguous');
39
+ options.upstream = { mode: 'dashboard_descriptor' };
40
+ } else if (flag === '--upstream') {
41
+ if (options.upstream !== undefined) throw new BridgeConfigError('USAGE', 'upstream option is ambiguous');
42
+ options.upstream = { mode: 'url', url: words[++index] };
43
+ } else if (flag === '--allow-host') options.allowedHosts.push(words[++index]);
44
+ else throw new BridgeConfigError('USAGE', `unknown bridge option: ${flag}`);
45
+ if ((flag === '--listen' || flag === '--port' || flag === '--upstream' || flag === '--allow-host')
46
+ && words[index] === undefined) throw new BridgeConfigError('USAGE', `missing value for ${flag}`);
47
+ }
48
+ return options;
49
+ }
50
+
51
+ function result(action, config, recovery = null) {
52
+ return { schema: RESULT_SCHEMA, action, configured: config !== null, enabled: config?.enabled ?? false,
53
+ listen: config?.listen ?? null, allowed_hosts: config?.allowed_hosts ?? null,
54
+ upstream: config?.upstream ?? null, updated_at: config?.updated_at ?? null, recovery };
55
+ }
56
+
57
+ export async function collectBridgeSetupWizard({ input, output, prompts = clack } = {}) {
58
+ const common = { input, output };
59
+ const enabled = await prompts.confirm({ ...common,
60
+ message: 'Lattice dashboardのnetwork bridgeを有効にしますか?', initialValue: false });
61
+ if (prompts.isCancel(enabled) || enabled !== true) return null;
62
+ const address = await prompts.text({ ...common, message: 'listenするIP address',
63
+ placeholder: '192.168.1.102', validate: (value) => isIP(value) === 0 ? 'IP literalを入力してください' : undefined });
64
+ if (prompts.isCancel(address)) return null;
65
+ const portMode = await prompts.select({ ...common, message: 'bridge port', initialValue: 'auto', options: [
66
+ { value: 'auto', label: '自動選択', hint: '49152–65535からexclusive bind' },
67
+ { value: 'custom', label: '指定する' },
68
+ ] });
69
+ if (prompts.isCancel(portMode)) return null;
70
+ let port = null;
71
+ if (portMode === 'custom') {
72
+ const selected = await prompts.text({ ...common, message: 'port (49152–65535)',
73
+ validate: (value) => /^\d+$/u.test(value) && Number(value) >= 49_152 && Number(value) <= 65_535
74
+ ? undefined : '49152–65535の整数を入力してください' });
75
+ if (prompts.isCancel(selected)) return null;
76
+ port = Number(selected);
77
+ }
78
+ const upstreamMode = await prompts.select({ ...common, message: 'upstream', initialValue: 'dashboard', options: [
79
+ { value: 'dashboard', label: '現在のLattice dashboard', hint: '再起動時もdescriptorから追従' },
80
+ { value: 'custom', label: '固定URL' },
81
+ ] });
82
+ if (prompts.isCancel(upstreamMode)) return null;
83
+ let upstream = { mode: 'dashboard_descriptor' };
84
+ if (upstreamMode === 'custom') {
85
+ const url = await prompts.text({ ...common, message: 'upstream HTTP(S) URL',
86
+ placeholder: 'http://127.0.0.1:4318/' });
87
+ if (prompts.isCancel(url)) return null;
88
+ upstream = { mode: 'url', url };
89
+ }
90
+ const publicHost = await prompts.text({ ...common,
91
+ message: '追加で許可する公開hostname(なければ空欄)', placeholder: 'lattice.kitepon.dev',
92
+ validate: (value) => {
93
+ if (value === '') return undefined;
94
+ try { normalizeBridgeAllowedHost(value); return undefined; } catch {
95
+ return 'portやschemeを含まないhostnameを入力してください';
96
+ }
97
+ } });
98
+ if (prompts.isCancel(publicHost)) return null;
99
+ return { address, port, upstream, allowedHosts: publicHost === '' ? [] : [publicHost] };
100
+ }
101
+
102
+ export async function runBridgeCli({ argv, stdout, stderr, env = process.env,
103
+ stdin = process.stdin, daemon = { ensure: ensureBridgeDaemon, requestStop: requestBridgeDaemonStop,
104
+ stop: stopBridgeDaemon, clearStop: clearBridgeStopControl },
105
+ launchAgent = { snapshot: snapshotBridgeLaunchAgent, install: installBridgeLaunchAgent,
106
+ disable: disableBridgeLaunchAgent, restore: restoreBridgeLaunchAgent },
107
+ prompts = clack } = {}) {
108
+ if (!Array.isArray(argv)) {
109
+ return fail(stderr, 'USAGE', 'usage: lattice bridge <setup|reconfigure|status|disable> [options] --json');
110
+ }
111
+ const wizard = argv.length === 1 && argv[0] === 'setup';
112
+ if (!wizard && argv.at(-1) !== '--json') {
113
+ return fail(stderr, 'USAGE', 'usage: lattice bridge <setup|reconfigure|status|disable> [options] --json');
114
+ }
115
+ if (wizard && (!stdin?.isTTY || !stdout?.isTTY)) {
116
+ return fail(stderr, 'BRIDGE_SETUP_REQUIRES_TTY',
117
+ 'interactive setup requires a TTY; use lattice bridge setup --listen <IP> --port auto --dashboard --json');
118
+ }
119
+ const [command, ...words] = wizard ? argv : argv.slice(0, -1);
120
+ try {
121
+ let config;
122
+ let recovery = null;
123
+ if (command === 'status' && words.length === 0) config = await readBridgeConfig({ env });
124
+ else if (command === 'disable' && words.length === 0) {
125
+ config = await withBridgeOperationLock({ env }, async () => {
126
+ let previous;
127
+ let descriptor = null;
128
+ let invalidConfig = false;
129
+ let invalidDescriptor = false;
130
+ try {
131
+ previous = await readBridgeConfig({ env });
132
+ } catch (error) {
133
+ if (!['BRIDGE_CONFIG_INVALID', 'BRIDGE_CONFIG_MODE_INVALID'].includes(error?.code)) throw error;
134
+ invalidConfig = true;
135
+ }
136
+ try { descriptor = await readBridgeDaemonDescriptor({ env }); } catch (error) {
137
+ if (error?.code !== 'BRIDGE_DAEMON_DESCRIPTOR_INVALID') throw error;
138
+ invalidDescriptor = true;
139
+ }
140
+ const agentSnapshot = await launchAgent.snapshot({ env });
141
+ const witnessedListen = previous?.listen ?? (descriptor === null ? null
142
+ : { address: descriptor.address, port: descriptor.port });
143
+ let stopResult = null;
144
+ try {
145
+ await launchAgent.disable({ snapshot: agentSnapshot, listen: witnessedListen, env });
146
+ if (!agentSnapshot.loaded) {
147
+ const requestStop = daemon.requestStop ?? daemon.stop ?? requestBridgeDaemonStop;
148
+ stopResult = await requestStop({ env, listen: witnessedListen });
149
+ }
150
+ const disabled = invalidConfig ? await restoreBridgeConfig(null, { env })
151
+ : await disableBridge({ env });
152
+ if (invalidConfig) recovery = 'invalid_config_removed_after_fail_closed_shutdown';
153
+ else if (invalidDescriptor) recovery = 'invalid_descriptor_removed_after_fail_closed_shutdown';
154
+ await removeBridgeDaemonDescriptor({ env });
155
+ await removeBridgeDaemonActiveMarker({ env });
156
+ const clearStop = daemon.clearStop ?? clearBridgeStopControl;
157
+ await clearStop({ env });
158
+ if (stopResult?.state === 'not_running' && recovery === null) recovery = 'bridge_was_not_running';
159
+ return disabled;
160
+ } catch (error) {
161
+ try {
162
+ await launchAgent.restore({ snapshot: agentSnapshot, listen: witnessedListen,
163
+ config: previous, env });
164
+ }
165
+ catch (rollbackError) {
166
+ throw new BridgeConfigError('BRIDGE_ROLLBACK_FAILED',
167
+ `bridge disable failed and LaunchAgent rollback failed: ${rollbackError.message}`, undefined, error);
168
+ }
169
+ throw error;
170
+ }
171
+ });
172
+ }
173
+ else if (command === 'setup' || command === 'reconfigure') {
174
+ const options = wizard ? await collectBridgeSetupWizard({ input: stdin, output: stdout, prompts })
175
+ : parseOptions(words);
176
+ if (options === null) {
177
+ stdout.write('Lattice bridge setupを取り消しました。設定は変更していません。\n');
178
+ return 0;
179
+ }
180
+ if (command === 'setup' && options.address === undefined) {
181
+ throw new BridgeConfigError('USAGE', 'setup requires explicit --listen <IP> opt-in');
182
+ }
183
+ config = await withBridgeOperationLock({ env }, async () => {
184
+ const clearStop = daemon.clearStop ?? clearBridgeStopControl;
185
+ await clearStop({ env });
186
+ const current = await readBridgeConfig({ env });
187
+ const agentSnapshot = await launchAgent.snapshot({ env });
188
+ const configured = await configureBridge({
189
+ address: options.address ?? current?.listen.address,
190
+ port: options.port === undefined ? (command === 'reconfigure' ? current?.listen.port ?? null : null) : options.port,
191
+ upstream: options.upstream ?? current?.upstream ?? { mode: 'dashboard_descriptor' }, env,
192
+ allowedHosts: options.allowedHosts.length > 0 ? options.allowedHosts
193
+ : current?.allowed_hosts?.filter((host) => host !== current.listen.address) ?? [],
194
+ reuseCurrentPort: options.port === undefined,
195
+ });
196
+ try {
197
+ if (!agentSnapshot.loaded && current !== null) {
198
+ const requestStop = daemon.requestStop ?? daemon.stop ?? requestBridgeDaemonStop;
199
+ await requestStop({ env, listen: current.listen });
200
+ await clearStop({ env });
201
+ }
202
+ await launchAgent.install({ config: configured, previousListen: current?.listen ?? null, env });
203
+ } catch (error) {
204
+ try {
205
+ await restoreBridgeConfig(current, { env });
206
+ await clearStop({ env });
207
+ await launchAgent.restore({ snapshot: agentSnapshot, listen: configured.listen,
208
+ config: current, env });
209
+ if (current?.enabled && !agentSnapshot.loaded) await daemon.ensure({ env });
210
+ } catch (rollbackError) {
211
+ throw new BridgeConfigError('BRIDGE_ROLLBACK_FAILED',
212
+ `bridge setup failed and rollback failed: ${rollbackError.message}`, undefined, error);
213
+ }
214
+ throw error;
215
+ }
216
+ return configured;
217
+ });
218
+ } else return fail(stderr, 'USAGE', 'unknown bridge command or options');
219
+ if (wizard) stdout.write(`Lattice bridgeを${config.listen.address}:${config.listen.port}で有効にしました。\n`);
220
+ else stdout.write(`${JSON.stringify(result(command, config, recovery))}\n`);
221
+ return 0;
222
+ } catch (error) {
223
+ stderr.write(`${JSON.stringify({ schema: 'lattice.cli_error.v2',
224
+ code: error?.code ?? 'BRIDGE_FAILED', message: error?.message ?? 'bridge command failed' })}\n`);
225
+ return error?.code === 'USAGE' ? 2 : 1;
226
+ }
227
+ }