semantic-atlas 0.3.0 → 1.0.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 (322) hide show
  1. package/.agents/skills/semantic-atlas/SKILL.md +134 -166
  2. package/.agents/skills/semantic-atlas/agents/openai.yaml +4 -0
  3. package/.agents/skills/semantic-atlas/references/observations.md +131 -0
  4. package/.agents/skills/semantic-atlas/scripts/query-context.mjs +110 -0
  5. package/.agents/skills/semantic-atlas-maintenance/SKILL.md +93 -0
  6. package/.agents/skills/semantic-atlas-maintenance/agents/openai.yaml +4 -0
  7. package/.agents/skills/semantic-atlas-maintenance/references/reconciliation.md +56 -0
  8. package/README.md +134 -239
  9. package/dist/application/map-application.d.ts +24 -0
  10. package/dist/application/map-application.d.ts.map +1 -0
  11. package/dist/application/map-application.js +134 -0
  12. package/dist/application/map-application.js.map +1 -0
  13. package/dist/cli/bin.js +6 -35
  14. package/dist/cli/bin.js.map +1 -0
  15. package/dist/cli/observation-commands.d.ts +16 -0
  16. package/dist/cli/observation-commands.d.ts.map +1 -0
  17. package/dist/cli/observation-commands.js +118 -0
  18. package/dist/cli/observation-commands.js.map +1 -0
  19. package/dist/cli/projection-writer.d.ts +2 -0
  20. package/dist/cli/projection-writer.d.ts.map +1 -0
  21. package/dist/cli/projection-writer.js +9 -0
  22. package/dist/cli/projection-writer.js.map +1 -0
  23. package/dist/cli/reconciliation-command.d.ts +7 -0
  24. package/dist/cli/reconciliation-command.d.ts.map +1 -0
  25. package/dist/cli/reconciliation-command.js +33 -0
  26. package/dist/cli/reconciliation-command.js.map +1 -0
  27. package/dist/cli/run-cli.d.ts +21 -0
  28. package/dist/cli/run-cli.d.ts.map +1 -0
  29. package/dist/cli/run-cli.js +299 -0
  30. package/dist/cli/run-cli.js.map +1 -0
  31. package/dist/contracts/cli.d.ts +166 -1211
  32. package/dist/contracts/cli.d.ts.map +1 -1
  33. package/dist/contracts/cli.js +2 -232
  34. package/dist/contracts/cli.js.map +1 -0
  35. package/dist/contracts/insights.d.ts +39 -1
  36. package/dist/contracts/insights.d.ts.map +1 -1
  37. package/dist/contracts/insights.js +2 -1
  38. package/dist/contracts/insights.js.map +1 -0
  39. package/dist/contracts/map.d.ts +154 -0
  40. package/dist/contracts/map.d.ts.map +1 -0
  41. package/dist/contracts/map.js +60 -0
  42. package/dist/contracts/map.js.map +1 -0
  43. package/dist/contracts/observation.d.ts +649 -0
  44. package/dist/contracts/observation.d.ts.map +1 -0
  45. package/dist/contracts/observation.js +140 -0
  46. package/dist/contracts/observation.js.map +1 -0
  47. package/dist/contracts/projection.d.ts +7 -0
  48. package/dist/contracts/projection.d.ts.map +1 -0
  49. package/dist/contracts/projection.js +2 -0
  50. package/dist/contracts/projection.js.map +1 -0
  51. package/dist/contracts/reconciliation.d.ts +40 -0
  52. package/dist/contracts/reconciliation.d.ts.map +1 -0
  53. package/dist/contracts/reconciliation.js +2 -0
  54. package/dist/contracts/reconciliation.js.map +1 -0
  55. package/dist/index.d.ts +7 -17
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +3 -9
  58. package/dist/index.js.map +1 -0
  59. package/dist/insights/insight-service.d.ts +14 -0
  60. package/dist/insights/insight-service.d.ts.map +1 -0
  61. package/dist/insights/insight-service.js +129 -0
  62. package/dist/insights/insight-service.js.map +1 -0
  63. package/dist/map/business-graph.d.ts +32 -0
  64. package/dist/map/business-graph.d.ts.map +1 -0
  65. package/dist/map/business-graph.js +122 -0
  66. package/dist/map/business-graph.js.map +1 -0
  67. package/dist/map/map-document-loader.d.ts +13 -0
  68. package/dist/map/map-document-loader.d.ts.map +1 -0
  69. package/dist/map/map-document-loader.js +86 -0
  70. package/dist/map/map-document-loader.js.map +1 -0
  71. package/dist/map/map-validator.d.ts +12 -0
  72. package/dist/map/map-validator.d.ts.map +1 -0
  73. package/dist/map/map-validator.js +322 -0
  74. package/dist/map/map-validator.js.map +1 -0
  75. package/dist/observations/observation-application.d.ts +23 -0
  76. package/dist/observations/observation-application.d.ts.map +1 -0
  77. package/dist/observations/observation-application.js +62 -0
  78. package/dist/observations/observation-application.js.map +1 -0
  79. package/dist/observations/observation-claim-manager.d.ts +13 -0
  80. package/dist/observations/observation-claim-manager.d.ts.map +1 -0
  81. package/dist/observations/observation-claim-manager.js +247 -0
  82. package/dist/observations/observation-claim-manager.js.map +1 -0
  83. package/dist/observations/observation-store.d.ts +43 -0
  84. package/dist/observations/observation-store.d.ts.map +1 -0
  85. package/dist/observations/observation-store.js +208 -0
  86. package/dist/observations/observation-store.js.map +1 -0
  87. package/dist/observations/repository-identity.d.ts +12 -0
  88. package/dist/observations/repository-identity.d.ts.map +1 -0
  89. package/dist/observations/repository-identity.js +108 -0
  90. package/dist/observations/repository-identity.js.map +1 -0
  91. package/dist/query/context-query-service.d.ts +15 -0
  92. package/dist/query/context-query-service.d.ts.map +1 -0
  93. package/dist/query/context-query-service.js +36 -0
  94. package/dist/query/context-query-service.js.map +1 -0
  95. package/dist/reconciliation/reconciliation-service.d.ts +10 -0
  96. package/dist/reconciliation/reconciliation-service.d.ts.map +1 -0
  97. package/dist/reconciliation/reconciliation-service.js +116 -0
  98. package/dist/reconciliation/reconciliation-service.js.map +1 -0
  99. package/dist/rendering/map-projector.d.ts +8 -0
  100. package/dist/rendering/map-projector.d.ts.map +1 -0
  101. package/dist/rendering/map-projector.js +386 -0
  102. package/dist/rendering/map-projector.js.map +1 -0
  103. package/dist/setup/managed-skill-installer.d.ts +60 -0
  104. package/dist/setup/managed-skill-installer.d.ts.map +1 -0
  105. package/dist/setup/managed-skill-installer.js +307 -0
  106. package/dist/setup/managed-skill-installer.js.map +1 -0
  107. package/dist/setup/package-identity.d.ts +6 -0
  108. package/dist/setup/package-identity.d.ts.map +1 -0
  109. package/dist/setup/package-identity.js +16 -0
  110. package/dist/setup/package-identity.js.map +1 -0
  111. package/dist/setup/package-upgrader.d.ts +10 -22
  112. package/dist/setup/package-upgrader.d.ts.map +1 -1
  113. package/dist/setup/package-upgrader.js +60 -76
  114. package/dist/setup/package-upgrader.js.map +1 -0
  115. package/docs/architecture.md +428 -0
  116. package/docs/evaluation.md +220 -174
  117. package/docs/index.md +27 -40
  118. package/docs/map-format.md +224 -0
  119. package/docs/observations.md +175 -0
  120. package/docs/product-contract.md +295 -137
  121. package/examples/commerce.yaml +204 -0
  122. package/package.json +31 -30
  123. package/.agents/skills/semantic-atlas/references/graph-patch.md +0 -190
  124. package/.agents/skills/semantic-atlas/references/product-feedback.md +0 -34
  125. package/.agents/skills/semantic-atlas/references/result-routing.md +0 -104
  126. package/.agents/skills/semantic-atlas/references/snapshot-bootstrap.md +0 -42
  127. package/.agents/skills/semantic-atlas-insights/SKILL.md +0 -55
  128. package/README.zh-CN.md +0 -273
  129. package/dist/business-flow/business-flow-derivation-service.d.ts +0 -11
  130. package/dist/business-flow/business-flow-derivation-service.d.ts.map +0 -1
  131. package/dist/business-flow/business-flow-derivation-service.js +0 -151
  132. package/dist/business-flow/business-flow-draft.d.ts +0 -16
  133. package/dist/business-flow/business-flow-draft.d.ts.map +0 -1
  134. package/dist/business-flow/business-flow-draft.js +0 -150
  135. package/dist/business-flow/framework-business-strategy.d.ts +0 -7
  136. package/dist/business-flow/framework-business-strategy.d.ts.map +0 -1
  137. package/dist/business-flow/framework-business-strategy.js +0 -1
  138. package/dist/business-flow/strategies/bullmq-business-strategy.d.ts +0 -10
  139. package/dist/business-flow/strategies/bullmq-business-strategy.d.ts.map +0 -1
  140. package/dist/business-flow/strategies/bullmq-business-strategy.js +0 -79
  141. package/dist/business-flow/strategies/called-operation-derivation.d.ts +0 -13
  142. package/dist/business-flow/strategies/called-operation-derivation.d.ts.map +0 -1
  143. package/dist/business-flow/strategies/called-operation-derivation.js +0 -32
  144. package/dist/business-flow/strategies/graphql-business-strategy.d.ts +0 -8
  145. package/dist/business-flow/strategies/graphql-business-strategy.d.ts.map +0 -1
  146. package/dist/business-flow/strategies/graphql-business-strategy.js +0 -65
  147. package/dist/business-flow/strategies/nestjs-business-strategy.d.ts +0 -8
  148. package/dist/business-flow/strategies/nestjs-business-strategy.d.ts.map +0 -1
  149. package/dist/business-flow/strategies/nestjs-business-strategy.js +0 -72
  150. package/dist/business-flow/strategies/strategy-helpers.d.ts +0 -32
  151. package/dist/business-flow/strategies/strategy-helpers.d.ts.map +0 -1
  152. package/dist/business-flow/strategies/strategy-helpers.js +0 -49
  153. package/dist/business-flow/strategies/typeorm-business-strategy.d.ts +0 -10
  154. package/dist/business-flow/strategies/typeorm-business-strategy.d.ts.map +0 -1
  155. package/dist/business-flow/strategies/typeorm-business-strategy.js +0 -136
  156. package/dist/business-flow/strategies/verified-invariant-strategy.d.ts +0 -5
  157. package/dist/business-flow/strategies/verified-invariant-strategy.d.ts.map +0 -1
  158. package/dist/business-flow/strategies/verified-invariant-strategy.js +0 -38
  159. package/dist/business-flow/strategies/verified-test-strategy.d.ts +0 -5
  160. package/dist/business-flow/strategies/verified-test-strategy.d.ts.map +0 -1
  161. package/dist/business-flow/strategies/verified-test-strategy.js +0 -26
  162. package/dist/business-flow/structural-flow-catalog.d.ts +0 -21
  163. package/dist/business-flow/structural-flow-catalog.d.ts.map +0 -1
  164. package/dist/business-flow/structural-flow-catalog.js +0 -125
  165. package/dist/business-flow/types.d.ts +0 -51
  166. package/dist/business-flow/types.d.ts.map +0 -1
  167. package/dist/business-flow/types.js +0 -1
  168. package/dist/cli/argument-parser.d.ts +0 -3
  169. package/dist/cli/argument-parser.d.ts.map +0 -1
  170. package/dist/cli/argument-parser.js +0 -200
  171. package/dist/cli/cli-application.d.ts +0 -39
  172. package/dist/cli/cli-application.d.ts.map +0 -1
  173. package/dist/cli/cli-application.js +0 -571
  174. package/dist/cli/cli-error.d.ts +0 -12
  175. package/dist/cli/cli-error.d.ts.map +0 -1
  176. package/dist/cli/cli-error.js +0 -44
  177. package/dist/cli/cli-presenter.d.ts +0 -14
  178. package/dist/cli/cli-presenter.d.ts.map +0 -1
  179. package/dist/cli/cli-presenter.js +0 -36
  180. package/dist/cli/insights-cli.d.ts +0 -6
  181. package/dist/cli/insights-cli.d.ts.map +0 -1
  182. package/dist/cli/insights-cli.js +0 -236
  183. package/dist/cli/main.d.ts +0 -3
  184. package/dist/cli/main.d.ts.map +0 -1
  185. package/dist/cli/main.js +0 -137
  186. package/dist/cli/standalone-cli.d.ts +0 -3
  187. package/dist/cli/standalone-cli.d.ts.map +0 -1
  188. package/dist/cli/standalone-cli.js +0 -96
  189. package/dist/cli/types.d.ts +0 -49
  190. package/dist/cli/types.d.ts.map +0 -1
  191. package/dist/cli/types.js +0 -1
  192. package/dist/contracts/graph.d.ts +0 -266
  193. package/dist/contracts/graph.d.ts.map +0 -1
  194. package/dist/contracts/graph.js +0 -182
  195. package/dist/contracts/identifiers.d.ts +0 -4
  196. package/dist/contracts/identifiers.d.ts.map +0 -1
  197. package/dist/contracts/identifiers.js +0 -7
  198. package/dist/contracts/public-contracts.d.ts +0 -5
  199. package/dist/contracts/public-contracts.d.ts.map +0 -1
  200. package/dist/contracts/public-contracts.js +0 -4
  201. package/dist/evaluation/comparison.d.ts +0 -30
  202. package/dist/evaluation/comparison.d.ts.map +0 -1
  203. package/dist/evaluation/comparison.js +0 -108
  204. package/dist/evaluation/contracts.d.ts +0 -301
  205. package/dist/evaluation/contracts.d.ts.map +0 -1
  206. package/dist/evaluation/contracts.js +0 -413
  207. package/dist/graph/graph-store.d.ts +0 -55
  208. package/dist/graph/graph-store.d.ts.map +0 -1
  209. package/dist/graph/graph-store.js +0 -912
  210. package/dist/graph/types.d.ts +0 -189
  211. package/dist/graph/types.d.ts.map +0 -1
  212. package/dist/graph/types.js +0 -1
  213. package/dist/insights/contracts.d.ts +0 -266
  214. package/dist/insights/contracts.d.ts.map +0 -1
  215. package/dist/insights/contracts.js +0 -124
  216. package/dist/insights/insights-store.d.ts +0 -73
  217. package/dist/insights/insights-store.d.ts.map +0 -1
  218. package/dist/insights/insights-store.js +0 -246
  219. package/dist/knowledge/business-knowledge-service.d.ts +0 -24
  220. package/dist/knowledge/business-knowledge-service.d.ts.map +0 -1
  221. package/dist/knowledge/business-knowledge-service.js +0 -200
  222. package/dist/knowledge/graph-patch-conflict-error.d.ts +0 -8
  223. package/dist/knowledge/graph-patch-conflict-error.d.ts.map +0 -1
  224. package/dist/knowledge/graph-patch-conflict-error.js +0 -12
  225. package/dist/knowledge/structural-target-binding.d.ts +0 -14
  226. package/dist/knowledge/structural-target-binding.d.ts.map +0 -1
  227. package/dist/knowledge/structural-target-binding.js +0 -11
  228. package/dist/package-metadata.d.ts +0 -2
  229. package/dist/package-metadata.d.ts.map +0 -1
  230. package/dist/package-metadata.js +0 -9
  231. package/dist/repository/git-command.d.ts +0 -3
  232. package/dist/repository/git-command.d.ts.map +0 -1
  233. package/dist/repository/git-command.js +0 -25
  234. package/dist/repository/repository-inspector.d.ts +0 -7
  235. package/dist/repository/repository-inspector.d.ts.map +0 -1
  236. package/dist/repository/repository-inspector.js +0 -84
  237. package/dist/repository/repository-language-support.d.ts +0 -14
  238. package/dist/repository/repository-language-support.d.ts.map +0 -1
  239. package/dist/repository/repository-language-support.js +0 -64
  240. package/dist/repository/types.d.ts +0 -9
  241. package/dist/repository/types.d.ts.map +0 -1
  242. package/dist/repository/types.js +0 -1
  243. package/dist/runtime/sqlite-compatibility-process.d.ts +0 -8
  244. package/dist/runtime/sqlite-compatibility-process.d.ts.map +0 -1
  245. package/dist/runtime/sqlite-compatibility-process.js +0 -20
  246. package/dist/setup/skill-installer.d.ts +0 -20
  247. package/dist/setup/skill-installer.d.ts.map +0 -1
  248. package/dist/setup/skill-installer.js +0 -187
  249. package/dist/snapshots/repository-snapshot.d.ts +0 -4
  250. package/dist/snapshots/repository-snapshot.d.ts.map +0 -1
  251. package/dist/snapshots/repository-snapshot.js +0 -119
  252. package/dist/snapshots/types.d.ts +0 -30
  253. package/dist/snapshots/types.d.ts.map +0 -1
  254. package/dist/snapshots/types.js +0 -1
  255. package/dist/storage/atlas-database.d.ts +0 -19
  256. package/dist/storage/atlas-database.d.ts.map +0 -1
  257. package/dist/storage/atlas-database.js +0 -433
  258. package/dist/storage/snapshot-store.d.ts +0 -19
  259. package/dist/storage/snapshot-store.d.ts.map +0 -1
  260. package/dist/storage/snapshot-store.js +0 -74
  261. package/dist/structural-backend/codegraph-backend.d.ts +0 -57
  262. package/dist/structural-backend/codegraph-backend.d.ts.map +0 -1
  263. package/dist/structural-backend/codegraph-backend.js +0 -1230
  264. package/dist/structural-backend/codegraph-worker-client.d.ts +0 -5
  265. package/dist/structural-backend/codegraph-worker-client.d.ts.map +0 -1
  266. package/dist/structural-backend/codegraph-worker-client.js +0 -118
  267. package/dist/structural-backend/codegraph-worker-protocol.d.ts +0 -35
  268. package/dist/structural-backend/codegraph-worker-protocol.d.ts.map +0 -1
  269. package/dist/structural-backend/codegraph-worker-protocol.js +0 -1
  270. package/dist/structural-backend/codegraph-worker.d.ts +0 -2
  271. package/dist/structural-backend/codegraph-worker.d.ts.map +0 -1
  272. package/dist/structural-backend/codegraph-worker.js +0 -131
  273. package/dist/structural-backend/process-instance.d.ts +0 -18
  274. package/dist/structural-backend/process-instance.d.ts.map +0 -1
  275. package/dist/structural-backend/process-instance.js +0 -207
  276. package/dist/structural-backend/structural-fact-changes.d.ts +0 -7
  277. package/dist/structural-backend/structural-fact-changes.d.ts.map +0 -1
  278. package/dist/structural-backend/structural-fact-changes.js +0 -78
  279. package/dist/structural-backend/structural-projection-bootstrapper.d.ts +0 -10
  280. package/dist/structural-backend/structural-projection-bootstrapper.d.ts.map +0 -1
  281. package/dist/structural-backend/structural-projection-bootstrapper.js +0 -295
  282. package/dist/structural-backend/structural-publication.d.ts +0 -13
  283. package/dist/structural-backend/structural-publication.d.ts.map +0 -1
  284. package/dist/structural-backend/structural-publication.js +0 -255
  285. package/dist/structural-backend/structural-write-lock.d.ts +0 -8
  286. package/dist/structural-backend/structural-write-lock.d.ts.map +0 -1
  287. package/dist/structural-backend/structural-write-lock.js +0 -415
  288. package/dist/structural-backend/types.d.ts +0 -144
  289. package/dist/structural-backend/types.d.ts.map +0 -1
  290. package/dist/structural-backend/types.js +0 -11
  291. package/dist/world/business-map-projector.d.ts +0 -14
  292. package/dist/world/business-map-projector.d.ts.map +0 -1
  293. package/dist/world/business-map-projector.js +0 -178
  294. package/dist/world/types.d.ts +0 -77
  295. package/dist/world/types.d.ts.map +0 -1
  296. package/dist/world/types.js +0 -1
  297. package/dist/world/world-graph-query.d.ts +0 -26
  298. package/dist/world/world-graph-query.d.ts.map +0 -1
  299. package/dist/world/world-graph-query.js +0 -250
  300. package/dist/world/world-model-service.d.ts +0 -21
  301. package/dist/world/world-model-service.d.ts.map +0 -1
  302. package/dist/world/world-model-service.js +0 -219
  303. package/dist/world/world-snapshot-store.d.ts +0 -40
  304. package/dist/world/world-snapshot-store.d.ts.map +0 -1
  305. package/dist/world/world-snapshot-store.js +0 -581
  306. package/docs/README.md +0 -30
  307. package/docs/architecture/codegraph-backend.md +0 -190
  308. package/docs/architecture/continuous-business-learning.md +0 -240
  309. package/docs/contracts/cli-v1.md +0 -164
  310. package/docs/contracts/graph-model.md +0 -106
  311. package/docs/contracts/graph-patch-v1.md +0 -105
  312. package/docs/contracts/insights-v1.md +0 -84
  313. package/docs/log.md +0 -80
  314. package/docs/mindmaps/semantic-atlas-overview.drawio +0 -255
  315. package/docs/mindmaps/semantic-atlas-overview.png +0 -0
  316. package/docs/mindmaps/semantic-atlas-overview.zh-CN.drawio +0 -255
  317. package/docs/mindmaps/semantic-atlas-overview.zh-CN.png +0 -0
  318. package/schemas/cli-envelope-v1.schema.json +0 -1244
  319. package/schemas/evaluation-plan-v1.schema.json +0 -211
  320. package/schemas/evaluation-run-v1.schema.json +0 -659
  321. package/schemas/graph-patch-v1.schema.json +0 -392
  322. package/schemas/insights-envelope-v1.schema.json +0 -428
@@ -1,178 +0,0 @@
1
- export class BusinessMapProjector {
2
- #nodes;
3
- #parentByChild;
4
- #childrenByParent;
5
- #relations;
6
- constructor(nodes, relations) {
7
- this.#nodes = new Map(nodes.map((node) => [node.key, node]));
8
- this.#parentByChild = new Map(relations.flatMap((relation) => (relation.type === "part_of" && relation.to.domain === "business"
9
- ? [[relation.from.key, relation.to.key]]
10
- : [])));
11
- this.#childrenByParent = childrenByParent(this.#parentByChild);
12
- this.#relations = relations;
13
- }
14
- project(focusKey) {
15
- const focus = focusKey === undefined ? null : this.#nodes.get(focusKey);
16
- if (focus === undefined) {
17
- return undefined;
18
- }
19
- const breadcrumbs = focus === null ? [] : this.pathFromRoot(focus.key);
20
- const regions = new Map();
21
- const visibleKeys = focus === null
22
- ? this.rootKeys()
23
- : this.#childrenByParent.get(focus.key) ?? [];
24
- const role = focus === null ? "root" : "child";
25
- visibleKeys.forEach((key) => this.addRegion(regions, key, role));
26
- const connections = new Map();
27
- for (const relation of this.#relations) {
28
- if (!isMapRelation(relation)) {
29
- continue;
30
- }
31
- if (focus !== null && !this.touchesSubtree(relation, focus.key)) {
32
- continue;
33
- }
34
- const projectedFrom = this.projectEndpoint(relation.from.key, focus, breadcrumbs);
35
- const projectedTo = this.projectEndpoint(relation.to.key, focus, breadcrumbs);
36
- if (projectedFrom === projectedTo) {
37
- continue;
38
- }
39
- this.addContextRegion(regions, projectedFrom, focus);
40
- this.addContextRegion(regions, projectedTo, focus);
41
- const direct = projectedFrom === relation.from.key && projectedTo === relation.to.key;
42
- addConnectionContribution(connections, projectedFrom, projectedTo, relation, direct);
43
- }
44
- return {
45
- focus,
46
- breadcrumbs,
47
- regions: [...regions.values()].sort(compareRegions),
48
- connections: presentConnections(connections),
49
- };
50
- }
51
- rootKeys() {
52
- return [...this.#nodes.keys()]
53
- .filter((key) => !this.#parentByChild.has(key))
54
- .sort((left, right) => left.localeCompare(right));
55
- }
56
- pathFromRoot(key) {
57
- const path = [];
58
- let current = key;
59
- while (current !== undefined) {
60
- const node = this.#nodes.get(current);
61
- if (node === undefined) {
62
- break;
63
- }
64
- path.push(node);
65
- current = this.#parentByChild.get(current);
66
- }
67
- return path.reverse();
68
- }
69
- touchesSubtree(relation, focusKey) {
70
- return this.isDescendantOrSelf(relation.from.key, focusKey)
71
- || (relation.to.domain === "business" && this.isDescendantOrSelf(relation.to.key, focusKey));
72
- }
73
- isDescendantOrSelf(key, ancestorKey) {
74
- let current = key;
75
- while (current !== undefined) {
76
- if (current === ancestorKey) {
77
- return true;
78
- }
79
- current = this.#parentByChild.get(current);
80
- }
81
- return false;
82
- }
83
- projectEndpoint(key, focus, focusPath) {
84
- const endpointPath = this.pathFromRoot(key);
85
- if (focus === null) {
86
- return endpointPath[0]?.key ?? key;
87
- }
88
- if (this.isDescendantOrSelf(key, focus.key)) {
89
- if (key === focus.key) {
90
- return key;
91
- }
92
- const focusIndex = endpointPath.findIndex((node) => node.key === focus.key);
93
- return endpointPath[focusIndex + 1]?.key ?? key;
94
- }
95
- const commonLength = sharedPrefixLength(focusPath, endpointPath);
96
- return endpointPath[commonLength]?.key ?? key;
97
- }
98
- addContextRegion(regions, key, focus) {
99
- if (key !== focus?.key && !regions.has(key)) {
100
- this.addRegion(regions, key, "context");
101
- }
102
- }
103
- addRegion(regions, key, role) {
104
- const node = this.#nodes.get(key);
105
- if (node === undefined) {
106
- return;
107
- }
108
- const childCount = this.#childrenByParent.get(key)?.length ?? 0;
109
- regions.set(key, { node, role, childCount, expandable: childCount > 0 });
110
- }
111
- }
112
- function childrenByParent(parentByChild) {
113
- const result = new Map();
114
- for (const [child, parent] of parentByChild) {
115
- const children = result.get(parent) ?? [];
116
- children.push(child);
117
- result.set(parent, children);
118
- }
119
- result.forEach((children) => children.sort((left, right) => left.localeCompare(right)));
120
- return result;
121
- }
122
- function isMapRelation(relation) {
123
- return relation.to.domain === "business"
124
- && relation.type !== "part_of"
125
- && relation.type !== "realized_by"
126
- && relation.type !== "verified_by";
127
- }
128
- function sharedPrefixLength(left, right) {
129
- let length = 0;
130
- while (length < left.length && length < right.length && left[length].key === right[length].key) {
131
- length += 1;
132
- }
133
- return length;
134
- }
135
- function addConnectionContribution(connections, fromKey, toKey, relation, direct) {
136
- const connectionKey = `${fromKey}\0${toKey}`;
137
- const connection = connections.get(connectionKey) ?? {
138
- fromKey,
139
- toKey,
140
- relations: new Map(),
141
- };
142
- connections.set(connectionKey, connection);
143
- const summary = connection.relations.get(relation.type) ?? emptySummary(relation.type);
144
- connection.relations.set(relation.type, summary);
145
- if (direct) {
146
- summary.directCount += 1;
147
- }
148
- else {
149
- summary.aggregatedCount += 1;
150
- }
151
- summary.certainty[relation.certainty] += 1;
152
- summary.validity[relation.validity] += 1;
153
- }
154
- function emptySummary(type) {
155
- return {
156
- type,
157
- directCount: 0,
158
- aggregatedCount: 0,
159
- certainty: { exact: 0, inferred: 0, hypothesis: 0 },
160
- validity: { valid: 0, stale: 0 },
161
- };
162
- }
163
- function compareRegions(left, right) {
164
- const leftRank = left.role === "context" ? 1 : 0;
165
- const rightRank = right.role === "context" ? 1 : 0;
166
- return leftRank - rightRank || left.node.key.localeCompare(right.node.key);
167
- }
168
- function presentConnections(connections) {
169
- return [...connections.values()]
170
- .sort((left, right) => (left.fromKey.localeCompare(right.fromKey) || left.toKey.localeCompare(right.toKey)))
171
- .map((connection) => ({
172
- from: { domain: "business", key: connection.fromKey },
173
- to: { domain: "business", key: connection.toKey },
174
- relations: [...connection.relations.values()]
175
- .sort((left, right) => left.type.localeCompare(right.type))
176
- .map((relation) => relation),
177
- }));
178
- }
@@ -1,77 +0,0 @@
1
- import type { StructuralFileChanges, StructuralIndexState, StructuralNode } from "../structural-backend/types.js";
2
- import type { RepositorySnapshot } from "../snapshots/types.js";
3
- export type WorldSnapshotStatus = "missing" | "building" | "current" | "failed";
4
- export interface WorldSnapshotState {
5
- readonly status: WorldSnapshotStatus;
6
- readonly currentSnapshotId: string | null;
7
- readonly targetSnapshotId: string | null;
8
- readonly backendVersion: string | null;
9
- readonly extractionVersion: number | null;
10
- readonly failureMessage: string | null;
11
- readonly startedAt: string | null;
12
- readonly publishedAt: string | null;
13
- readonly updatedAt: string;
14
- }
15
- export interface CurrentWorldSnapshot {
16
- readonly publicationId: number;
17
- readonly snapshot: RepositorySnapshot;
18
- }
19
- export interface StructuralLocator {
20
- readonly structuralReference: string;
21
- readonly file: string;
22
- readonly qualifiedSymbol: string | null;
23
- readonly structuralKind: string | null;
24
- readonly range: {
25
- readonly start: {
26
- readonly line: number;
27
- readonly column: number;
28
- };
29
- readonly end: {
30
- readonly line: number;
31
- readonly column: number;
32
- };
33
- };
34
- readonly backendLocator?: string;
35
- }
36
- export interface EvidenceLocator extends StructuralLocator {
37
- readonly contentHash: string;
38
- }
39
- export type StructuralTargetLocator = StructuralLocator;
40
- export interface StructuralEvidenceResolver {
41
- getNode(reference: string): StructuralNode | undefined;
42
- findCandidates(locator: StructuralLocator): readonly StructuralNode[];
43
- backendLocator(node: StructuralNode): string | undefined;
44
- }
45
- export interface IndexedSourceFile {
46
- readonly path: string;
47
- readonly contentHash: string;
48
- }
49
- export interface WorldWriteCoordinator {
50
- withWorldWriteLock<T>(operation: (state: StructuralIndexState, resolver: StructuralEvidenceResolver) => Promise<T>): Promise<T>;
51
- }
52
- export interface WorldPublicationMetadata {
53
- readonly fromSnapshotId: string | null;
54
- readonly toSnapshotId: string;
55
- readonly structural: StructuralFileChanges;
56
- readonly staleAssertions: readonly string[];
57
- }
58
- export interface SemanticGraphChanges {
59
- readonly fromSnapshotId: string;
60
- readonly toSnapshotId: string;
61
- readonly nodes: {
62
- readonly added: readonly string[];
63
- readonly changed: readonly string[];
64
- readonly removed: readonly string[];
65
- };
66
- readonly relations: {
67
- readonly added: readonly string[];
68
- readonly changed: readonly string[];
69
- readonly removed: readonly string[];
70
- };
71
- readonly staleAssertions: readonly string[];
72
- }
73
- export interface SemanticGraphChangeOptions {
74
- readonly fromSnapshotId?: string;
75
- readonly toSnapshotId?: string;
76
- }
77
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/world/types.ts"],"names":[],"mappings":"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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- import type { GitRepository } from "../repository/types.js";
2
- import { GraphStore } from "../graph/graph-store.js";
3
- import type { BusinessGraphView, BusinessGraphNode, BusinessMapView, GraphSearchResult, StructuralGraphNode } from "../graph/types.js";
4
- import type { StructuralIndexBackend } from "../structural-backend/types.js";
5
- import type { SemanticGraphChangeOptions, SemanticGraphChanges } from "./types.js";
6
- export declare class WorldGraphQuery implements Disposable {
7
- #private;
8
- constructor(repository: GitRepository, graph?: GraphStore, structural?: StructuralIndexBackend);
9
- view(focusKey?: string): Promise<BusinessMapView | undefined>;
10
- searchBusiness(query: string, options?: {
11
- readonly limit?: number;
12
- }): Promise<readonly GraphSearchResult<BusinessGraphNode>[]>;
13
- searchCode(query: string, options?: {
14
- readonly limit?: number;
15
- }): Promise<readonly GraphSearchResult<StructuralGraphNode>[]>;
16
- showBusiness(key: string): Promise<BusinessGraphView | undefined>;
17
- changes(options?: SemanticGraphChangeOptions): SemanticGraphChanges | undefined;
18
- close(): void;
19
- [Symbol.dispose](): void;
20
- private currentWorld;
21
- private withCurrentWorld;
22
- private getNode;
23
- private businessAdjacency;
24
- private structuralNode;
25
- }
26
- //# sourceMappingURL=world-graph-query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"world-graph-query.d.ts","sourceRoot":"","sources":["../../src/world/world-graph-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAEjB,eAAe,EAIf,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,gCAAgC,CAAC;AAIxC,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAQpB,qBAAa,eAAgB,YAAW,UAAU;;gBAO9C,UAAU,EAAE,aAAa,EACzB,KAAK,CAAC,EAAE,UAAU,EAClB,UAAU,GAAE,sBAAmE;IAS3E,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAQ7D,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GACxC,OAAO,CAAC,SAAS,iBAAiB,CAAC,iBAAiB,CAAC,EAAE,CAAC;IAcrD,UAAU,CACd,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GACxC,OAAO,CAAC,SAAS,iBAAiB,CAAC,mBAAmB,CAAC,EAAE,CAAC;IAevD,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAgBvE,OAAO,CAAC,OAAO,GAAE,0BAA+B,GAAG,oBAAoB,GAAG,SAAS;IAKnF,KAAK,IAAI,IAAI;IAMb,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAIxB,OAAO,CAAC,YAAY;YAKN,gBAAgB;YAgBhB,OAAO;YAWP,iBAAiB;YAmBjB,cAAc;CAgB7B"}
@@ -1,250 +0,0 @@
1
- var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
- if (value !== null && value !== void 0) {
3
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
- var dispose, inner;
5
- if (async) {
6
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
- dispose = value[Symbol.asyncDispose];
8
- }
9
- if (dispose === void 0) {
10
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
- dispose = value[Symbol.dispose];
12
- if (async) inner = dispose;
13
- }
14
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
- if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
- env.stack.push({ value: value, dispose: dispose, async: async });
17
- }
18
- else if (async) {
19
- env.stack.push({ async: true });
20
- }
21
- return value;
22
- };
23
- var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
- return function (env) {
25
- function fail(e) {
26
- env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
- env.hasError = true;
28
- }
29
- var r, s = 0;
30
- function next() {
31
- while (r = env.stack.pop()) {
32
- try {
33
- if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
- if (r.dispose) {
35
- var result = r.dispose.call(r.value);
36
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
- }
38
- else s |= 1;
39
- }
40
- catch (e) {
41
- fail(e);
42
- }
43
- }
44
- if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
- if (env.hasError) throw env.error;
46
- }
47
- return next();
48
- };
49
- })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
- var e = new Error(message);
51
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
- });
53
- import { GraphStore } from "../graph/graph-store.js";
54
- import { CodeGraphStructuralBackend } from "../structural-backend/codegraph-backend.js";
55
- import { BusinessMapProjector } from "./business-map-projector.js";
56
- import { WorldSnapshotStore } from "./world-snapshot-store.js";
57
- export class WorldGraphQuery {
58
- #repository;
59
- #graph;
60
- #structural;
61
- #ownsGraph;
62
- constructor(repository, graph, structural = new CodeGraphStructuralBackend(repository)) {
63
- const dependencies = createDependencies(repository, graph, structural);
64
- this.#repository = repository;
65
- this.#graph = dependencies.graph;
66
- this.#structural = dependencies.structural;
67
- this.#ownsGraph = dependencies.ownsGraph;
68
- }
69
- async view(focusKey) {
70
- return this.withCurrentWorld(async (snapshot) => {
71
- const nodes = this.#graph.listBusinessNodes(snapshot.snapshotId);
72
- const relations = this.#graph.listBusinessRelations(snapshot.snapshotId);
73
- return new BusinessMapProjector(nodes, relations).project(focusKey);
74
- });
75
- }
76
- async searchBusiness(query, options = {}) {
77
- const terms = lexicalTerms(query);
78
- if (terms.length === 0) {
79
- return [];
80
- }
81
- return this.withCurrentWorld(async (snapshot) => {
82
- const limit = requireSearchLimit(options.limit);
83
- return this.#graph.search(query, { snapshotId: snapshot.snapshotId, limit })
84
- .flatMap((result) => (result.node.domain === "business" ? [{ score: result.score, node: result.node }] : []));
85
- });
86
- }
87
- async searchCode(query, options = {}) {
88
- const terms = lexicalTerms(query);
89
- if (terms.length === 0) {
90
- return [];
91
- }
92
- return this.withCurrentWorld(async (snapshot) => {
93
- const limit = requireSearchLimit(options.limit);
94
- const results = await this.#structural.search({ query, limit });
95
- return Promise.all(results.map(async (result, index) => ({
96
- score: reciprocalRank(index),
97
- node: await this.structuralNode(result.node, snapshot),
98
- })));
99
- });
100
- }
101
- async showBusiness(key) {
102
- return this.withCurrentWorld(async (snapshot) => {
103
- const node = this.#graph.getNode({ domain: "business", key }, snapshot.snapshotId);
104
- if (node?.domain !== "business") {
105
- return undefined;
106
- }
107
- return {
108
- node,
109
- relations: (await this.businessAdjacency({ domain: "business", key }, snapshot)).sort(compareNeighbors),
110
- };
111
- });
112
- }
113
- changes(options = {}) {
114
- const env_1 = { stack: [], error: void 0, hasError: false };
115
- try {
116
- const store = __addDisposableResource(env_1, new WorldSnapshotStore(this.#repository), false);
117
- return store.readSemanticChanges(options);
118
- }
119
- catch (e_1) {
120
- env_1.error = e_1;
121
- env_1.hasError = true;
122
- }
123
- finally {
124
- __disposeResources(env_1);
125
- }
126
- }
127
- close() {
128
- if (this.#ownsGraph) {
129
- this.#graph.close();
130
- }
131
- }
132
- [Symbol.dispose]() {
133
- this.close();
134
- }
135
- currentWorld() {
136
- const env_2 = { stack: [], error: void 0, hasError: false };
137
- try {
138
- const store = __addDisposableResource(env_2, new WorldSnapshotStore(this.#repository), false);
139
- return store.requireCurrentWorld();
140
- }
141
- catch (e_2) {
142
- env_2.error = e_2;
143
- env_2.hasError = true;
144
- }
145
- finally {
146
- __disposeResources(env_2);
147
- }
148
- }
149
- async withCurrentWorld(query) {
150
- const currentWorld = this.currentWorld();
151
- const snapshot = currentWorld.snapshot;
152
- const result = await query(snapshot);
153
- const verifiedWorld = this.currentWorld();
154
- if (verifiedWorld.publicationId !== currentWorld.publicationId) {
155
- throw new Error(`World publication changed from ${currentWorld.publicationId} ` +
156
- `to ${verifiedWorld.publicationId} during the query`);
157
- }
158
- return result;
159
- }
160
- async getNode(reference, snapshot) {
161
- if (reference.domain === "business") {
162
- return this.#graph.getNode(reference, snapshot.snapshotId);
163
- }
164
- const node = await this.#structural.getNode({ id: reference.id });
165
- return node === undefined ? undefined : this.structuralNode(node, snapshot);
166
- }
167
- async businessAdjacency(reference, snapshot) {
168
- const result = [];
169
- for (const relation of this.#graph.listBusinessRelations(snapshot.snapshotId)) {
170
- const relationDirection = directionForRelation(reference, relation);
171
- if (relationDirection === undefined) {
172
- continue;
173
- }
174
- const otherReference = relationDirection === "outgoing" ? relation.to : relation.from;
175
- const node = await this.getNode(otherReference, snapshot);
176
- if (node !== undefined) {
177
- result.push({ depth: 1, direction: relationDirection, relation, node });
178
- }
179
- }
180
- return result;
181
- }
182
- async structuralNode(node, snapshot) {
183
- return {
184
- domain: "structural",
185
- id: node.reference.id,
186
- kind: node.kind,
187
- label: node.name,
188
- snapshotId: snapshot.snapshotId,
189
- validity: "valid",
190
- locations: node.virtual === true ? [] : [sourceLocation(node, snapshot)],
191
- support: node.support,
192
- };
193
- }
194
- }
195
- function createDependencies(repository, graph, structural) {
196
- return {
197
- graph: graph ?? new GraphStore(repository),
198
- structural,
199
- ownsGraph: graph === undefined,
200
- };
201
- }
202
- function sourceLocation(node, snapshot) {
203
- return {
204
- file: node.path,
205
- range: node.range,
206
- contentHash: contentHashFor(node.path, snapshot),
207
- };
208
- }
209
- function contentHashFor(path, snapshot) {
210
- const file = snapshot.files.find((candidate) => candidate.path === path);
211
- if (file?.worktree === null || file?.worktree === undefined) {
212
- throw new Error(`Structural source ${path} is absent from world snapshot ${snapshot.snapshotId}`);
213
- }
214
- return file.worktree.contentHash;
215
- }
216
- function directionForRelation(reference, relation) {
217
- if (sameReference(reference, relation.from)) {
218
- return "outgoing";
219
- }
220
- return sameReference(reference, relation.to) ? "incoming" : undefined;
221
- }
222
- function sameReference(left, right) {
223
- return referenceIdentity(left) === referenceIdentity(right);
224
- }
225
- function referenceIdentity(reference) {
226
- return reference.domain === "business"
227
- ? `business:${reference.key}`
228
- : `structural:${reference.id}`;
229
- }
230
- function nodeIdentity(node) {
231
- return node.domain === "business" ? `business:${node.key}` : `structural:${node.id}`;
232
- }
233
- function compareNeighbors(left, right) {
234
- return left.depth - right.depth
235
- || left.relation.type.localeCompare(right.relation.type)
236
- || nodeIdentity(left.node).localeCompare(nodeIdentity(right.node));
237
- }
238
- function reciprocalRank(index) {
239
- return 1 / (index + 1);
240
- }
241
- function lexicalTerms(query) {
242
- return query.toLowerCase().match(/[\p{L}\p{N}_]+/gu) ?? [];
243
- }
244
- function requireSearchLimit(limit) {
245
- const resolved = limit ?? 20;
246
- if (!Number.isInteger(resolved) || resolved < 1) {
247
- throw new Error("World graph search limit must be a positive integer");
248
- }
249
- return resolved;
250
- }
@@ -1,21 +0,0 @@
1
- import type { GitRepository } from "../repository/types.js";
2
- import type { StructuralBuildResult } from "../structural-backend/types.js";
3
- import type { RepositorySnapshot } from "../snapshots/types.js";
4
- import type { IndexedSourceFile, WorldSnapshotState } from "./types.js";
5
- export interface PublishedWorldSnapshot {
6
- readonly snapshotId: string;
7
- readonly structural: StructuralBuildResult;
8
- readonly staleAssertions: readonly string[];
9
- }
10
- export declare class WorldModelService {
11
- #private;
12
- readonly repository: GitRepository;
13
- constructor(repository: GitRepository);
14
- build(): Promise<PublishedWorldSnapshot>;
15
- sync(): Promise<PublishedWorldSnapshot>;
16
- state(): WorldSnapshotState;
17
- currentSnapshotId(): string;
18
- private publish;
19
- }
20
- export declare function worldPublicationMismatch(indexedSnapshot: RepositorySnapshot, publishableSnapshot: RepositorySnapshot, indexedSources: readonly IndexedSourceFile[]): string | null;
21
- //# sourceMappingURL=world-model-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"world-model-service.d.ts","sourceRoot":"","sources":["../../src/world/world-model-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAExE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAED,qBAAa,iBAAiB;;IAGhB,QAAQ,CAAC,UAAU,EAAE,aAAa;gBAAzB,UAAU,EAAE,aAAa;IAIxC,KAAK,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAIxC,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAI7C,KAAK,IAAI,kBAAkB;IAK3B,iBAAiB,IAAI,MAAM;YAKb,OAAO;CAsEtB;AAWD,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,kBAAkB,EACnC,mBAAmB,EAAE,kBAAkB,EACvC,cAAc,EAAE,SAAS,iBAAiB,EAAE,GAC3C,MAAM,GAAG,IAAI,CA6Bf"}