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,190 +0,0 @@
1
- # CodeGraph Backend Architecture
2
-
3
- ## Decision
4
-
5
- Semantic Atlas embeds the verified `@colbymchenry/codegraph` 1.5.0 package as its structural-index SDK. It uses the SDK's fixed `.atlas/codegraph.db` path as a worktree-local disposable projection and stores durable Atlas knowledge in a separate user-level repository database.
6
-
7
- This decision produces one product, one index command, two explicit storage lifecycles, and one logical world graph. It requires no upstream database-path option and lets linked worktrees share durable business meaning without sharing one mutable structural index.
8
-
9
- ## System model
10
-
11
- ```text
12
- Calling AI
13
- |
14
- Semantic Atlas Skill
15
- |
16
- semantic-atlas CLI
17
- |
18
- WorldModelService
19
- |-- CodeGraphBackend ------ @colbymchenry/codegraph SDK
20
- | |-- extraction and resolution
21
- | |-- structural search and traversal
22
- |
23
- |-- BusinessKnowledgeStore -- ~/.semantic-atlas/repositories/<id>/atlas.db
24
- |
25
- `-- WorldGraphQuery -------- normalizes and composes both domains
26
- |
27
- <worktree>/.atlas/codegraph.db
28
- ```
29
-
30
- `CodeGraphBackend` is an anti-corruption layer, not a second public API. Atlas domain code depends on Atlas structural query types. Backend node kinds, edge kinds, identifiers, errors, and version metadata are translated at this boundary.
31
-
32
- ## Physical and logical ownership
33
-
34
- The two SQLite files have different owners and lifecycles. They remain internal stores behind one Atlas query contract.
35
-
36
- | Owner | Table family | Lifecycle |
37
- | --- | --- | --- |
38
- | CodeGraph worktree projection | `nodes`, `edges`, `files`, `unresolved_refs`, FTS, schema and backend metadata | Copied from a compatible sibling, rebuilt, or incrementally synchronized from source |
39
- | Atlas repository store | `atlas_*` business, snapshot, binding, validity, worktree-state, and publication objects | Shared by all worktrees and updated by Atlas only |
40
-
41
- Atlas accesses structural behavior through the CodeGraph public SDK and durable knowledge through its user-level database. `WorldGraphQuery` joins evidence locators and structural references in memory; the public CLI never exposes table origin or a second workflow.
42
-
43
- The implementation contains no Atlas-owned structural projection tables. Keeping those tables would duplicate CodeGraph data and restore the two-graph problem this design resolves.
44
-
45
- ## Stable Atlas contracts
46
-
47
- The adapter exposes only the structural operations required by business understanding:
48
-
49
- ```ts
50
- interface StructuralIndexBackend {
51
- inspect(): Promise<StructuralIndexState>;
52
- build(): Promise<StructuralBuildResult>;
53
- sync(): Promise<StructuralBuildResult>;
54
- listRoots(): Promise<StructuralNode[]>;
55
- readProjectGraph(query: StructuralProjectGraphQuery): Promise<StructuralTraversalResult>;
56
- search(query: StructuralSearchQuery): Promise<StructuralSearchResult[]>;
57
- getNode(reference: StructuralReference): Promise<StructuralNode | undefined>;
58
- traverse(query: StructuralTraversalQuery): Promise<StructuralTraversalResult>;
59
- getCallers(reference: StructuralReference): Promise<StructuralCallRelation[]>;
60
- getCallees(reference: StructuralReference): Promise<StructuralCallRelation[]>;
61
- getFileDependencies(path: string): Promise<StructuralFileDependency[]>;
62
- }
63
- ```
64
-
65
- These are domain-level capabilities rather than a mirror of every CodeGraph API. The adapter may use `CodeGraph.init`, `open`, `indexAll`, `sync`, search, callers, callees, call graph, impact, and file-dependency APIs internally.
66
-
67
- Business-flow derivation requests one bounded project graph containing only the
68
- declaration kinds used by its framework strategies. A caller supplies explicit
69
- capability roots; Atlas follows exact ownership and execution relations from
70
- those roots and uses same-file framework declarations only as interpretation
71
- context. The adapter returns normalized declaration kinds, decorator names,
72
- supported relations, and unknown boundaries in one query so Node 22
73
- private-worker execution does not degenerate into a process-per-node traversal.
74
-
75
- `WorldModelService` owns orchestration. `BusinessKnowledgeStore` owns Atlas tables and transactions. `WorldGraphQuery` resolves cross-domain references and returns the existing versioned CLI graph contract.
76
-
77
- `WorldGraphQuery` is the read coordinator used by map, code-search, and change workflows. It requires one published world snapshot, projects the business hierarchy into semantic zoom views, resolves direct evidence links, delegates bounded structural search to the adapter, and verifies that the published snapshot did not change while an asynchronous structural query was running. Structural results retain normalized support and provenance; business results retain certainty, validity, and evidence.
78
-
79
- Lexical search keeps its ownership domains explicit. `map search` ranks only Atlas business vocabulary. `code search` ranks only CodeGraph structural results and normalizes their order into bounded public scores. The query layer performs no cross-domain score fusion, embeddings, model calls, or natural-language inference.
80
-
81
- When CodeGraph has no explicit module or namespace nodes, the adapter exposes deterministic top-directory module roots with Atlas `module:` references. These roots are computed from the current backend file manifest and traverse to backend file nodes; they are not stored in Atlas tables or presented as business facts.
82
-
83
- ## Evidence references
84
-
85
- Atlas business knowledge does not own CodeGraph rows. An evidence record contains:
86
-
87
- - an optional backend node locator for fast rebinding;
88
- - a normalized repository-relative source path;
89
- - a structural kind and qualified symbol identity when available;
90
- - a one-based source range;
91
- - a source content hash;
92
- - the Atlas snapshot and structural-backend version observed at learning time.
93
-
94
- No cascading foreign key points from `atlas_*` evidence to a CodeGraph structural table. The original evidence locator remains repository-wide. After every successful index, Atlas writes a binding for that content snapshot; a unique match is current, a missing or ambiguous match is stale, and certainty remains unchanged. One worktree's rebinding never overwrites another snapshot's result.
95
-
96
- Structural relation targets own the same kind of durable locator independently from their supporting evidence. A relation may target one structural node while its evidence cites another; Atlas resolves both locators separately and marks the relation stale when either one is missing or ambiguous.
97
-
98
- ## Directory lifecycle
99
-
100
- Atlas owns directory preparation:
101
-
102
- 1. resolve the current Git worktree root;
103
- 2. create `<worktree>/.atlas/` when needed;
104
- 3. create an Atlas-owned `.atlas/.gitignore` that ignores the directory contents, including itself, so generated state remains invisible to normal Git status;
105
- 4. run CodeGraph in a scoped environment where `CODEGRAPH_DIR` is `.atlas`;
106
- 5. verify the resolved CodeGraph database path is exactly `<worktree>/.atlas/codegraph.db` before writing.
107
-
108
- The environment override is contained inside `CodeGraphBackend`; callers do not configure CodeGraph. Each worktree has its own `.atlas/` because CodeGraph's index, SQLite locks, and dirty source state are worktree- and operating-system-specific.
109
-
110
- When `codegraph.db` is missing, `StructuralProjectionBootstrapper` reads compatible `current` sibling states from the repository Atlas database. Exact-snapshot candidates sort first, followed by the most recent successful publication and normalized path. Under the sibling's existing structural lock, Atlas rejects symlinks, integrity failures, incomplete metadata, version mismatches, and source-manifest mismatches; it copies only the SQLite database with `node:sqlite.backup()`, atomically installs the destination, and always runs incremental `sync` in the destination root. All failed candidates lead to the normal full-index fallback.
111
-
112
- ## Index state machine
113
-
114
- ```text
115
- missing -> building -> current
116
- | |
117
- v v
118
- failed <- building
119
- ```
120
-
121
- - `missing` means no completed Atlas world snapshot exists.
122
- - `building` is written before structural mutation begins.
123
- - `current` is published only after CodeGraph completes and Atlas snapshot/evidence reconciliation commits.
124
- - `failed` records the last failure while preventing a partial structural graph from being reported as current.
125
-
126
- All Semantic Atlas commands use one Atlas-owned worktree lock. Its PID, operating-system process-instance proof, and ownership token cover the complete publication lifecycle, do not expire while that process instance is alive, and permit recovery after that instance exits even if its PID is later reused. Linux and Windows use high-resolution OS process-start identities. On macOS and other POSIX hosts without `/proc`, owners keep the authoritative lease inode open for the full lifecycle; process exit closes that kernel-held proof, which cannot be inherited by a later process reusing the PID. Structural writes complete before Atlas knowledge writes. Read commands require a `current` snapshot or return explicit stale/failed state.
127
-
128
- Normal updates use CodeGraph incremental sync. A full structural rebuild uses `CodeGraph.clear()` followed by `indexAll()` because the current SDK clears only structural rows. The adapter never calls:
129
-
130
- - `CodeGraph.recreate()`, which removes `codegraph.db` and its sidecars;
131
- - `CodeGraph.uninitialize()`, which removes the entire `.atlas/` directory;
132
- - the CodeGraph CLI rebuild path, which is allowed to choose destructive lifecycle operations.
133
-
134
- Before mutating an existing structural index, the adapter captures an online backup of the CodeGraph database. Both full rebuild and incremental sync discard that backup only after a complete result; an incomplete result or exception restores the previously published structural graph before the Atlas lock is released.
135
-
136
- The structural database contains no Atlas-owned tables, so replacing or deleting a worktree projection cannot delete durable business knowledge.
137
-
138
- ## Snapshot semantics
139
-
140
- CodeGraph's structural tables represent the current code projection. Atlas snapshots record repository content identity, Git state, relevant file hashes, the CodeGraph package and extraction versions, build outcome, and evidence validity.
141
-
142
- Atlas does not preserve a second full historical structural graph. Repository snapshots are content-addressed and may recur, while every successful index/sync creates a distinct immutable publication occurrence scoped to `(repository_id, git_directory)`. Each worktree state points to its own latest occurrence and predecessor chain. Business assertions remain repository-wide and expose binding-derived validity for the requested snapshot.
143
-
144
- The change query proves the requested source snapshot is an ancestor of the target by following the immutable publication-occurrence chain. Repeated content identities resolve deterministically within the current chain: `to` selects the latest matching occurrence and `from` selects the latest match at or before that target; equal endpoints select the same occurrence. Atlas compares the supported source content stored in the two endpoint snapshots and returns the net added, changed, and removed `file:` references. This endpoint comparison is independent of the structural backend's incremental Git baseline: intermediate additions that are later removed and removals restored with identical content cancel naturally. Stale assertions describe validity at the selected target occurrence rather than the union of intermediate failures. Atlas does not query mutable CodeGraph rows as if they were a historical snapshot or reconstruct unsupported historical node and relation changes.
145
-
146
- World publication captures the repository snapshot after acquiring the Atlas write lock, verifies it again after structural indexing, and compares its source hashes with CodeGraph's indexed file manifest. A mismatch rolls back the structural database and leaves the prior world snapshot current. After validation, Atlas commits CodeGraph first and then publishes the user-level Atlas transaction. If that central transaction fails, the durable CodeGraph projection remains, the worktree state is non-current, and the next `index` repairs publication through incremental sync. Every successful occurrence is immutable.
147
-
148
- ## Failure and upgrade behavior
149
-
150
- - A CodeGraph index or sync error fails the Atlas index command and leaves the world snapshot non-current.
151
- - A user-level Atlas transaction failure leaves complete CodeGraph structural data present but unavailable to map and learn until a later index republishes the worktree state.
152
- - Unsupported structure is returned as backend support metadata or an unresolved boundary; Atlas does not invent an exact edge.
153
- - The dependency version is pinned exactly rather than selected through a semver range. The compatible host range is Node.js 22.12 through 24. Node.js 22.12 through 22.15 lack the FTS5 module required by CodeGraph 1.5.0, so the adapter runs its private SDK worker with the dependency's bundled Node.js runtime on those hosts; Node.js 22.16 through 24 use the SDK in process. Both paths expose the same Atlas contract and invoke no CodeGraph CLI, MCP, or daemon lifecycle. Upgrades run fixture repositories through index, sync, rebuild, query normalization, split-schema ownership, and evidence-rebinding tests before changing the lockfile.
154
- - If an upstream release changes structural IDs, locator-based rebinding preserves stable Atlas business keys and makes unmatched evidence stale.
155
-
156
- Run `pnpm validation:backend` to validate the installed tarball against the
157
- current exact dependency. To evaluate a new release before changing the pin,
158
- run `pnpm validation:backend -- --candidate <version> --allow-network`. The
159
- isolated consumer overrides only its installed candidate; the source manifest
160
- and lockfile remain unchanged. The gate validates a pure CodeGraph worktree
161
- projection, the user-level Atlas schema, sibling bootstrap plus incremental
162
- sync, snapshot-specific rebinding, and business-knowledge preservation. It also
163
- compares required structural endpoints and bounded false exact links with the
164
- pinned baseline, and prints measured index, database, and query costs.
165
-
166
- ## Pre-release storage transition
167
-
168
- The previous colocated `.atlas/codegraph.db` layout is intentionally reset rather than imported. Existing `.atlas` data is a disposable development cache. The user-level schema starts at v1, and durable knowledge is learned through the current GraphPatch contract.
169
-
170
- ## Alternatives considered
171
-
172
- ### Wait for an upstream database-path option
173
-
174
- This would permit relocating CodeGraph itself, but the product no longer needs that capability. Atlas accepts the SDK's local path and moves only its own durable state.
175
-
176
- ### Run CodeGraph as a separate CLI or MCP product
177
-
178
- This would force agents to coordinate two tools, two public contracts, and two failure models. It conflicts with the single Semantic Atlas workflow.
179
-
180
- ### Share one mutable CodeGraph database across worktrees
181
-
182
- Different branches and dirty files require independent structural projections. Sharing a mutable projection would mix snapshots and locks; sibling backup plus incremental sync reuses work without sharing mutation.
183
-
184
- ### Copy CodeGraph source into Semantic Atlas
185
-
186
- This imports a large parser, resolver, database, CLI, MCP, and maintenance surface. Direct SDK use preserves the boundary with much lower ownership cost. A thin fork remains available only if a demonstrated SDK limitation blocks the product contract.
187
-
188
- ### Extend CodeGraph node and edge enums with business concepts
189
-
190
- CodeGraph structural rows require code-centric fields and are legitimately disposable during structural rebuilds. Business assertions have different identity, evidence, certainty, and validity lifecycles, so they remain Atlas-owned and are composed at the query boundary.
@@ -1,240 +0,0 @@
1
- # 持续业务学习与演进式业务地图
2
-
3
- 本页回答 Semantic Atlas 何时学习业务知识、业务根节点如何随认知演进、
4
- 以及层级调整如何保持身份与证据稳定。适用于业务图查询、GraphPatch、
5
- Agent Skill 和后续影响分析设计。状态:已接受,按垂直切片逐步实施。
6
-
7
- ## 产品判断
8
-
9
- Semantic Atlas 在真实工程任务中持续学习业务,不在首次索引时生成一套
10
- 推测性的完整业务模型。真实任务同时提供产品意图、相关源码、测试、修改
11
- 结果和复用价值,是形成可靠业务知识的最佳证据边界。
12
-
13
- `index` 只发布当前工作树的结构投影、仓库快照和已有证据有效性。调用
14
- Agent 负责理解自然语言和业务意义;CodeGraph 负责提供符号、引用、调用、
15
- 模块和源码位置等结构事实。两者通过证据关系协作,但结构目录不替代业务
16
- 地图。
17
-
18
- 业务地图是一个持续成长并允许重组的心智模型:
19
-
20
- ```text
21
- 真实工程任务
22
- -> 查询已有业务知识
23
- -> 从 CodeGraph 与源码补足未知部分
24
- -> 完成修改与验证
25
- -> 提炼可复用业务知识
26
- -> 新增、扩展、修正或重挂载业务子树
27
- ```
28
-
29
- ## 根节点语义
30
-
31
- 根节点表示当前有效业务图中没有已知主要父节点的业务节点。它是查询时的
32
- 结构状态,不是永久地位,也不是 `Capability` 等节点类型。
33
-
34
- 第一次任务可能只验证“退款”,它暂时作为根节点;后续任务发现“退款”
35
- 属于“订单”,再发现“订单”属于“Commerce”,地图可以持续演进:
36
-
37
- ```text
38
- Refunds
39
-
40
- Orders
41
- └── Refunds
42
-
43
- Commerce
44
- └── Orders
45
- └── Refunds
46
- ```
47
-
48
- 世界层 `map view` 只把当前父节点为空的业务知识作为 root regions:
49
-
50
- - 空业务图返回空数组和稳定的 `BUSINESS_KNOWLEDGE_EMPTY` 告警;
51
- - 结构 `Module` 根节点通过 `code search` 参与源码回退,不进入业务 regions;
52
- - 任意业务节点类型都可以在尚未发现父节点时暂时成为根;
53
- - 新的上层知识可以在一个原子事务中把既有根节点变成子节点;
54
- - 根节点变化不改变节点身份、证据或其他业务关系。
55
-
56
- ## 稳定身份与可变位置
57
-
58
- 业务身份的生命周期长于当前分类位置。v1 继续使用 `key` 作为仓库内稳定
59
- 身份;key 中的斜杠只表达可读命名空间,不构成父子关系,也不随重挂载
60
- 改写。权威层级只来自 `part_of` 关系。
61
-
62
- 例如 `refunds` 或既有的 `commerce/refunds` 在挂到 `orders` 下时保持原 key。
63
- 调用方通过稳定 key 继续引用该节点,展示路径则根据当前 `part_of` 链计算。
64
- 后续版本只有在真实碰撞或跨仓库身份需求出现时,才引入独立 opaque ID;
65
- 本阶段不为假设性需求迁移现有知识。
66
-
67
- ## 业务层级不变量
68
-
69
- `part_of` 是导航层级关系,并满足以下不变量:
70
-
71
- 1. 一个业务节点最多拥有一个 outgoing `part_of` 主要父节点。
72
- 2. 父节点和子节点都属于业务域并已存在或在同一 GraphPatch 中创建。
73
- 3. `part_of` 图保持无环;节点不能成为自身或自身后代的父节点。
74
- 4. 横向关系不受主要父节点限制,继续使用 `invokes`、`reads`、`writes`、
75
- `publishes`、`consumes`、`constrained_by`、`realized_by` 和 `verified_by`。
76
- 5. 层级变化保留节点 key、业务断言、证据和非层级关系。
77
-
78
- 树形主要归属提供稳定的逐层导航;横向关系表达真实业务协作。需要从多个
79
- 角度发现同一节点时,使用 aliases、搜索和横向关系,而不是创建多个主要
80
- 父节点。
81
-
82
- ## 原子重挂载
83
-
84
- GraphPatch v1 已支持在一个事务中删除旧关系并新增关系。重挂载使用同一
85
- patch 完成以下动作:
86
-
87
- 1. 必要时 upsert 新的上层业务节点;
88
- 2. remove 既有 outgoing `part_of`;
89
- 3. upsert 指向新父节点的 `part_of`;
90
- 4. 保持被移动节点及其子树 key 不变。
91
-
92
- Atlas 在写入前根据删除和新增操作计算最终层级,并整体校验单父节点和无环
93
- 不变量。任何一步失败都会拒绝完整 patch,旧地图保持不变。
94
-
95
- 未来若多个 Agent 同时修改共享业务地图,需要在 GraphPatch 中加入独立于
96
- 源码 snapshot 的 knowledge revision。当前 v1 继续依赖串行 Skill 工作流、
97
- SQLite 写事务和完整 patch 校验;知识 revision 属于后续并发切片。
98
-
99
- ## 任务驱动的知识协调
100
-
101
- 每个受支持任务先查询已有业务图。地图不足时,Agent 显式使用结构搜索和
102
- 有界源码阅读完成工程工作。在最终源码和测试得到验证后,Agent 对新理解
103
- 执行一次知识协调:
104
-
105
- | 决策 | 含义 |
106
- | --- | --- |
107
- | `reuse` | 已有节点和关系完整表达本次验证的业务意义 |
108
- | `extend` | 给已有知识增加节点、断言或横向关系 |
109
- | `introduce` | 当前没有可信上层概念,新增暂时的根节点 |
110
- | `reparent` | 发现更高层归属,原子移动已有节点或子树 |
111
- | `refine` | 修正 kind、label、summary、aliases 或 certainty |
112
- | `transient` | 本次信息是实现细节、症状或未验证假设,不持久化 |
113
-
114
- 创建节点前必须搜索近似业务词并查看世界 regions,减少重复根节点。发现更上层业务
115
- 时优先重挂载现有知识,而不是复制一棵新子树。所有持久事实仍需要当前源码
116
- 证据;结构不确定性保留为显式边界。
117
-
118
- ## CodeGraph 的位置
119
-
120
- CodeGraph 保持为 Semantic Atlas 内部结构证据层:
121
-
122
- - 索引文件、符号和可静态证明的关系;
123
- - 为业务断言提供 source range、content hash 和可重绑定身份;
124
- - 在业务知识不足时提供有界源码种子;
125
- - 从已选业务节点向调用方、消费者、数据和测试扩展未来 impact 查询。
126
-
127
- CodeGraph 不命名业务、不决定业务父子关系,也不把目录层级呈现为业务地图。
128
- 结构 exact 不自动成为业务 exact;无法证明的运行时行为继续保持
129
- `UnknownBoundary`。
130
-
131
- ## 一张地图与语义缩放
132
-
133
- Semantic Atlas 保存一张权威业务图,不分别保存总览图和模块子图。`part_of`
134
- 形成可逐层进入的区域层级,其他业务关系形成跨区域连接。查询根据当前焦点
135
- 选择一个可见业务边界,同一底图因此可以像游戏地图一样连续缩放。
136
-
137
- 世界视图显示当前 roots。聚焦某个节点后,视图显示它的直接子区域,并把与
138
- 当前区域发生业务关系的外部节点折叠到最接近当前视野的业务分支。例如源码
139
- 确认的关系是 `place-order reads user-profile`,在 Commerce 视图中可以投影为
140
- `orders reads users`,在 Orders 视图中投影为
141
- `place-order reads users`。
142
-
143
- 投影关系满足以下规则:
144
-
145
- 1. GraphPatch 只保存 Agent 明确验证的原始业务关系。
146
- 2. 缩放视图把下层关系端点提升到当前可见区域,形成只读聚合连接。
147
- 3. 同一对可见区域按 relation type 合并贡献关系,分别报告 direct 与
148
- aggregated 数量、certainty 分布和 validity 分布。
149
- 4. 投影后落在同一可见区域内的关系属于该区域内部细节,本层隐藏,放大后
150
- 再显示。
151
- 5. 聚合连接不是新的业务事实,不写回 GraphPatch,也不获得虚构的 certainty。
152
- 6. breadcrumb 始终从当前 root 指向焦点;每个区域返回 direct child count 和
153
- expandable 状态,让 Agent 明确下一次缩放入口。
154
-
155
- 节点 kind 表达业务角色,不表达固定缩放级别。`Capability` 可以包含更细的
156
- `Capability`,尚未发现父节点的 `Operation` 也可以暂时成为世界区域;视图
157
- 完全根据当前 `part_of` 层级计算。
158
-
159
- ## AI-first 查询契约
160
-
161
- 公共 API 以调用 Agent 完成真实工程任务的最短可靠路径设计:
162
-
163
- ```text
164
- status -> index when needed
165
- map view [business-key]
166
- map search <business vocabulary>
167
- map show <business-key>
168
- code search <symbol or structural vocabulary> when business knowledge is insufficient
169
- source confirmation -> engineering work -> index -> changes -> learn
170
- ```
171
-
172
- - `map view` 是主要导航入口。省略 key 时返回世界视图;提供 key 时向该业务
173
- 区域放大一层,同时返回 breadcrumb、child/context regions 和聚合连接。
174
- - `map search` 只搜索业务词汇并返回业务节点,避免代码符号淹没业务意图。
175
- - `map show` 只接受业务 key,返回该业务断言、直接业务关系和直接结构证据,
176
- 不递归展开 CodeGraph。
177
- - `code search` 是业务知识为空或不足时的显式结构回退,返回有界源码种子。
178
- - 源码读取、编辑和测试继续属于 Agent 的正常工程工具,不包装进 Atlas CLI。
179
-
180
- `map roots`、`map children`、混合业务/结构的 `map search`、接受结构 ID 与任意
181
- depth 的 `map show` 不再属于公共契约。当前没有外部使用者,本阶段直接替换
182
- 旧 API,不增加 alias、兼容 schema 或双轨行为。
183
-
184
- API 的首要 dogfood 场景是让一个没有预置 key 的 Agent 使用 Semantic Atlas
185
- 理解并修改 Semantic Atlas 自身:先从世界视图寻找业务区域;知识不足时通过
186
- `code search` 定位 `WorldGraphQuery` 等结构入口;完成修改后学习查询能力、
187
- 层级和关系,使下一个 Agent 能从 `map view` 逐层到达实现证据。
188
-
189
- ## 分阶段实现
190
-
191
- ### Slice 1:业务 roots 与安全层级
192
-
193
- - 世界视图只选择所有类型的 parentless business nodes;
194
- - 空业务图返回 `BUSINESS_KNOWLEDGE_EMPTY`;
195
- - GraphPatch 最终状态强制单父节点和无环;
196
- - Skill 在真实任务后执行 `reuse/extend/introduce/reparent/refine/transient`;
197
- - 文档明确 key 与位置分离。
198
-
199
- ### Slice 2:语义缩放与 AI-first 查询视角
200
-
201
- - 以 `map view` 替换 roots/children,生成 breadcrumb、可展开区域和聚合连接;
202
- - 业务搜索不与结构结果混排,增加 `code search` 作为显式回退;
203
- - `map show` 限制在业务关系和直接结构证据,避免结构图淹没业务语境;
204
- - 使用 Semantic Atlas 对自身完成一次世界视图到源码修改再到知识写回的验证。
205
-
206
- ### Slice 3:业务影响分析
207
-
208
- - 从业务节点遍历 scenario、operation、data、interface 和 invariant;
209
- - 通过 `realized_by`、`verified_by` 和 CodeGraph 扩展实现、调用者、消费者与
210
- 测试;
211
- - 分别报告 exact、inferred 和 unknown 影响,支持 Agent 制定修改范围。
212
-
213
- ### Slice 4:并发知识 revision 与长期治理
214
-
215
- - 为共享业务知识增加 optimistic knowledge revision;
216
- - 显式记录 reparent、merge 和分类修正;
217
- - 在真实重复知识或并发冲突出现后设计 merge 操作,不提前引入复杂治理。
218
-
219
- ## 验收场景
220
-
221
- 1. 新仓库完成 `index` 后,世界 `map view` 返回空业务图而不是 `src` 或 `libs`。
222
- 2. 第一次任务学到一个 Operation 时,它可以作为暂时根节点被后续任务复用。
223
- 3. 后续任务创建更高层 Capability,并在一个 GraphPatch 中把该 Operation
224
- 重挂载到 Capability 下;Operation key 与证据保持不变。
225
- 4. 同一 patch 尝试给节点添加两个主要父节点时整体失败。
226
- 5. 同一 patch 尝试形成 `A -> B -> A` 层级环时整体失败。
227
- 6. 世界视图只显示根区域;聚焦父节点时显示直接子区域、breadcrumb 和可展开
228
- 状态。
229
- 7. 两个深层节点的横向关系在上层视图聚合到各自可见祖先,放大后恢复更具体
230
- 的端点;聚合连接保留贡献关系的 certainty 与 validity 分布。
231
- 8. 一个 Fresh Agent 通过 `map view/search/show` 发现当前业务路径,并在业务
232
- 知识不足时通过 `code search` 明确转入结构与源码回退。
233
-
234
- ## 相关页面
235
-
236
- - [产品契约](../product-contract.md)
237
- - [图模型](../contracts/graph-model.md)
238
- - [GraphPatch v1](../contracts/graph-patch-v1.md)
239
- - [CLI v1](../contracts/cli-v1.md)
240
- - [CodeGraph 后端边界](codegraph-backend.md)
@@ -1,164 +0,0 @@
1
- # CLI Contract v1
2
-
3
- ## Invocation
4
-
5
- The npm package and executable are both named `semantic-atlas`. Development uses Node.js 24; the published CLI supports Node.js 22.12 through 24.
6
-
7
- Repository-independent lifecycle commands run before Git, Atlas storage, or
8
- SQLite is opened:
9
-
10
- | Command | Contract |
11
- | --- | --- |
12
- | `setup` | Atomically install or update the exact bundled `semantic-atlas` and `semantic-atlas-insights` Skills at `~/.agents/skills/`. A recognized legacy `~/.codex/skills/semantic-atlas` copy is removed after the shared installation succeeds. |
13
- | `upgrade` | Resolve npm's `latest` tag, install that exact release globally, verify the new executable, and invoke the new package's `setup`. An already-current package still verifies and repairs its bundled Skills. |
14
- | `-h`, `--help` | Print top-level usage and command help. |
15
- | `--version` | Print the installed package version. |
16
-
17
- These commands write conventional text to standard output and diagnostics to
18
- standard error. `setup` records the package version and a content fingerprint;
19
- repeated execution verifies the installed files and restores a changed managed
20
- copy. A directory that does not identify itself as the Semantic Atlas Skill is
21
- reported as a conflict and left unchanged.
22
-
23
- `upgrade` resolves a version before mutation and installs
24
- `semantic-atlas@<resolved-version>` rather than leaving the install step bound to
25
- a moving tag. It locates the new package through npm's global root and starts its
26
- CLI through the current Node executable, so Skill synchronization is owned by
27
- the package that was actually installed. Registry lookup, package installation,
28
- new-version verification, and Skill synchronization are one fail-closed command:
29
- any failed step returns exit code `1` and does not report the upgrade as ready.
30
- These lifecycle commands do not discover a Git repository or open Atlas storage.
31
- Installation-scoped `insights` commands also avoid Git and repository Atlas
32
- storage, while opening the separate local insights store described in
33
- [Insights v1](insights-v1.md).
34
-
35
- Global project options:
36
-
37
- - `--repo <path>` selects a directory within the target repository; the default is the current directory.
38
- - `--pretty` indents a project or insights JSON envelope without changing fields or values.
39
-
40
- Project commands:
41
-
42
- | Command | Contract |
43
- | --- | --- |
44
- | `status` | Report worktree identity, current revision, latest world snapshot, freshness, local store location, language support, and additive structural-backend metadata. |
45
- | `index` | Build or synchronize the embedded structural index, reconcile Atlas evidence, publish the completed world snapshot, and report changed facts and unknowns. |
46
- | `map view [business-key]` | Return the world business frontier, or zoom one level into a selected business region with breadcrumbs, child/context regions, and projected cross-boundary connections. An empty world returns `regions: []` with `BUSINESS_KNOWLEDGE_EMPTY`. |
47
- | `map search <business-term> [--limit <n>]` | Lexically rank business labels, aliases, summaries, and attached evidence vocabulary; every result is a business node and the default limit is 20. |
48
- | `map show <business-key>` | Return one business assertion plus its direct business relations and direct structural evidence links. The command does not recursively traverse CodeGraph. |
49
- | `code search <structural-term> [--limit <n>]` | Return bounded structural symbols and source locations when business knowledge is absent or insufficient; the default limit is 20. |
50
- | `learn --stdin` | Read one complete GraphPatch v1 JSON value from standard input and apply it atomically. |
51
- | `changes [--from <snapshot-id>] [--to <snapshot-id>]` | Report net semantic graph changes between persisted Atlas snapshot endpoints, not a raw Git diff. The source must be an ancestor of the target in the publication chain; defaults compare the previous and current snapshots. |
52
- | `feedback report --stdin` | Store an explicit, evidence-contextual product problem or suggestion after source confirmation. The report links nearby local command-event IDs without storing arguments or output. |
53
-
54
- `map` commands expose business navigation. `code search` is the explicit structural fallback. The calling agent extracts concepts, reformulates searches, opens returned source locations, and judges impact.
55
-
56
- ## Response envelope
57
-
58
- Every project command writes one JSON envelope to standard output. The normative discriminated schema is `schemas/cli-envelope-v1.schema.json`.
59
-
60
- ```json
61
- {
62
- "schemaVersion": 1,
63
- "repository": {
64
- "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
65
- "root": "/workspace/example",
66
- "headCommit": "0123456789abcdef0123456789abcdef01234567"
67
- },
68
- "snapshot": null,
69
- "status": "ok",
70
- "data": {
71
- "command": "status",
72
- "currentRevision": {
73
- "headCommit": "0123456789abcdef0123456789abcdef01234567",
74
- "changes": { "staged": 0, "unstaged": 0, "untracked": 0 }
75
- },
76
- "freshness": "missing",
77
- "storeLocation": "/home/agent/.semantic-atlas/repositories/0123456789abcdef/atlas.db",
78
- "languages": [
79
- { "language": "typescript", "support": "supported" }
80
- ]
81
- },
82
- "warnings": []
83
- }
84
- ```
85
-
86
- - Successful responses have `status: "ok" | "partial"`, a non-null repository, and command data selected by `data.command`.
87
- - `snapshot` is `null` before the first successful index. Otherwise it includes the snapshot ID, Git HEAD, creation time, and `current` or `stale` freshness.
88
- - `partial` means usable data is accompanied by a warning or contains stale or otherwise bounded knowledge. An empty business map and an index with unresolved structural counts are usable `partial` results, not indexing failures.
89
- - Business map nodes and direct relations always include `certainty`, derived `validity`, and evidence. Projected connections report contributor counts and certainty/validity distributions without becoming stored assertions. Structural code-search nodes preserve normalized backend provenance and support. Unsupported languages include a reason instead of an approximate analysis.
90
- - `warnings` contains stable codes and descriptions for non-fatal conditions. Consumers use codes rather than parsing messages.
91
- - `storeLocation` identifies the repository-wide Atlas knowledge database. The current worktree's `.atlas/codegraph.db` path remains an internal structural-backend detail.
92
-
93
- ## Command data
94
-
95
- The schema requires these fields while allowing additive fields inside command data:
96
-
97
- | `data.command` | Required result fields |
98
- | --- | --- |
99
- | `status` | `currentRevision`, `freshness`, `storeLocation`, `languages` |
100
- | `index` | `snapshotId`, fact counts, unknown-boundary counts; backend version and evidence-rebinding counts are additive metadata until promoted by a later schema version |
101
- | `map.view` | nullable `focus`, root-to-focus `breadcrumbs`, `regions`, and projected `connections` |
102
- | `map.search` | `query`, `limit`, scored business-only `results` |
103
- | `map.show` | business `node` and direct evidence-aware `relations` |
104
- | `code.search` | `query`, `limit`, scored structural-only `results` with source locations and support |
105
- | `learn` | `baseSnapshotId`, `snapshotId`, applied operation counts |
106
- | `changes` | source and target snapshot IDs, node/relation change sets, stale assertions |
107
- | `feedback.report` | created report ID, classification, source-confirmed flag, status, and linked-event count |
108
-
109
- `index.facts` uses one structural-fact unit across every publication: one backend node or
110
- relation is one fact. `added`, `changed`, and `reused` partition the facts in the newly
111
- published graph; `removed` counts facts present only in the previous publication. A fact
112
- is changed when its stable node identity or relation endpoints remain while its structural
113
- content, location, or support changes.
114
-
115
- Map node and direct relation objects preserve their evidence lifecycle. When evidence cannot uniquely rebind after indexing, a business node can remain addressable by key while its `summary` is returned with `validity: "stale"`; callers therefore cannot confuse vocabulary identity with a current fact.
116
-
117
- In a world view, `focus` is null, `breadcrumbs` is empty, and every region has role `root`. In a focused view, `focus` is the selected business node, breadcrumbs run from its current root to the focus, direct children have role `child`, and related external branches have role `context`. Every region reports `childCount` and `expandable`.
118
-
119
- Each connection identifies visible business endpoints and groups summaries by relation type. `directCount` counts stored relations whose endpoints are already visible at this level; `aggregatedCount` counts stored deeper relations lifted to the visible frontier. Certainty and validity objects count the underlying contributors. A relation projected to the same visible region is hidden until the agent zooms further in.
120
-
121
- `BUSINESS_KNOWLEDGE_EMPTY` is the stable warning code for a current indexed world with no learned business nodes. World `map.view` returns an empty `regions` array in this state. Structural modules and symbols remain discoverable through `code.search`; they are never emitted as business regions.
122
-
123
- `feedback report --stdin` accepts one strict JSON object with `kind`, `category`,
124
- `impact`, `observed`, `expected`, optional `suggestion`, and `sourceConfirmed`.
125
- The report itself is explicit feedback; the surrounding passive command event
126
- contains only objective metadata. It is operational product data and never a
127
- GraphPatch or business-world assertion.
128
-
129
- Change ranges follow the current publication history and fold the requested endpoints into one content comparison. When a content-addressed snapshot was published more than once, `--to` selects its latest occurrence in that history and `--from` selects the latest matching occurrence at or before the target; equal IDs compare the selected occurrence with itself. Paths that have the same presence and content at both endpoints are omitted even if they changed in between, while `staleAssertions` reports the selected target occurrence's final validity state. An unknown target has no change result.
130
-
131
- ## Errors
132
-
133
- Handled failures have `status: "error"` and structured data:
134
-
135
- ```json
136
- {
137
- "command": null,
138
- "error": {
139
- "code": "INVALID_INPUT",
140
- "message": "The command arguments are invalid."
141
- }
142
- }
143
- ```
144
-
145
- `command` is null when parsing fails before a public command is identified. Scalar or command-success data is invalid in an error envelope. Standard output contains only the envelope; human diagnostics and unexpected stack information go to standard error. Pretty formatting never changes the schema.
146
-
147
- ## Exit codes
148
-
149
- | Code | Meaning |
150
- | --- | --- |
151
- | `0` | Command completed with `ok` or `partial` data |
152
- | `1` | Unexpected internal failure |
153
- | `2` | Invalid command, option, stdin, or schema version |
154
- | `3` | Repository discovery or unsupported-repository failure |
155
- | `4` | Required Atlas state is missing or stale for the requested operation |
156
- | `5` | GraphPatch concurrency, evidence, or repository-boundary rejection |
157
-
158
- Handled nonzero failures still emit a versioned error envelope when a response can be formed. Diagnostics never replace the machine-readable response.
159
-
160
- ## Contract stability
161
-
162
- This pre-adoption revision directly replaces the earlier roots/children/mixed-search/depth-traversal command set. It exposes no aliases or dual response shapes. The generated schema is the current v1 authority.
163
-
164
- After adoption, top-level envelope fields, command discriminants, and required command fields are closed within version 1. Additive fields may appear inside command data and result objects; callers ignore fields they do not understand. A future removed field, changed meaning, enum incompatibility, or operation change requires a new `schemaVersion`. GraphPatch and other input objects remain strict and reject unknown fields.