semantic-atlas 0.4.0 → 2.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.
- package/.agents/skills/semantic-atlas/SKILL.md +134 -166
- package/.agents/skills/semantic-atlas/agents/openai.yaml +4 -0
- package/.agents/skills/semantic-atlas/references/observations.md +130 -0
- package/.agents/skills/semantic-atlas/scripts/query-context.mjs +110 -0
- package/.agents/skills/semantic-atlas-maintenance/SKILL.md +93 -0
- package/.agents/skills/semantic-atlas-maintenance/agents/openai.yaml +4 -0
- package/.agents/skills/semantic-atlas-maintenance/references/reconciliation.md +56 -0
- package/README.md +133 -265
- package/dist/application/map-application.d.ts +24 -0
- package/dist/application/map-application.d.ts.map +1 -0
- package/dist/application/map-application.js +134 -0
- package/dist/application/map-application.js.map +1 -0
- package/dist/cli/bin.js +6 -42
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/observation-commands.d.ts +16 -0
- package/dist/cli/observation-commands.d.ts.map +1 -0
- package/dist/cli/observation-commands.js +118 -0
- package/dist/cli/observation-commands.js.map +1 -0
- package/dist/cli/projection-writer.d.ts +2 -0
- package/dist/cli/projection-writer.d.ts.map +1 -0
- package/dist/cli/projection-writer.js +9 -0
- package/dist/cli/projection-writer.js.map +1 -0
- package/dist/cli/reconciliation-command.d.ts +7 -0
- package/dist/cli/reconciliation-command.d.ts.map +1 -0
- package/dist/cli/reconciliation-command.js +33 -0
- package/dist/cli/reconciliation-command.js.map +1 -0
- package/dist/cli/run-cli.d.ts +21 -0
- package/dist/cli/run-cli.d.ts.map +1 -0
- package/dist/cli/run-cli.js +299 -0
- package/dist/cli/run-cli.js.map +1 -0
- package/dist/contracts/cli.d.ts +166 -1211
- package/dist/contracts/cli.d.ts.map +1 -1
- package/dist/contracts/cli.js +2 -232
- package/dist/contracts/cli.js.map +1 -0
- package/dist/contracts/insights.d.ts +39 -1
- package/dist/contracts/insights.d.ts.map +1 -1
- package/dist/contracts/insights.js +2 -1
- package/dist/contracts/insights.js.map +1 -0
- package/dist/contracts/map.d.ts +154 -0
- package/dist/contracts/map.d.ts.map +1 -0
- package/dist/contracts/map.js +60 -0
- package/dist/contracts/map.js.map +1 -0
- package/dist/contracts/observation.d.ts +414 -0
- package/dist/contracts/observation.d.ts.map +1 -0
- package/dist/contracts/observation.js +125 -0
- package/dist/contracts/observation.js.map +1 -0
- package/dist/contracts/projection.d.ts +7 -0
- package/dist/contracts/projection.d.ts.map +1 -0
- package/dist/contracts/projection.js +2 -0
- package/dist/contracts/projection.js.map +1 -0
- package/dist/contracts/reconciliation.d.ts +40 -0
- package/dist/contracts/reconciliation.d.ts.map +1 -0
- package/dist/contracts/reconciliation.js +2 -0
- package/dist/contracts/reconciliation.js.map +1 -0
- package/dist/index.d.ts +7 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -9
- package/dist/index.js.map +1 -0
- package/dist/insights/insight-service.d.ts +14 -0
- package/dist/insights/insight-service.d.ts.map +1 -0
- package/dist/insights/insight-service.js +129 -0
- package/dist/insights/insight-service.js.map +1 -0
- package/dist/map/business-graph.d.ts +32 -0
- package/dist/map/business-graph.d.ts.map +1 -0
- package/dist/map/business-graph.js +122 -0
- package/dist/map/business-graph.js.map +1 -0
- package/dist/map/map-document-loader.d.ts +13 -0
- package/dist/map/map-document-loader.d.ts.map +1 -0
- package/dist/map/map-document-loader.js +86 -0
- package/dist/map/map-document-loader.js.map +1 -0
- package/dist/map/map-validator.d.ts +12 -0
- package/dist/map/map-validator.d.ts.map +1 -0
- package/dist/map/map-validator.js +322 -0
- package/dist/map/map-validator.js.map +1 -0
- package/dist/observations/observation-application.d.ts +23 -0
- package/dist/observations/observation-application.d.ts.map +1 -0
- package/dist/observations/observation-application.js +62 -0
- package/dist/observations/observation-application.js.map +1 -0
- package/dist/observations/observation-claim-manager.d.ts +17 -0
- package/dist/observations/observation-claim-manager.d.ts.map +1 -0
- package/dist/observations/observation-claim-manager.js +198 -0
- package/dist/observations/observation-claim-manager.js.map +1 -0
- package/dist/observations/observation-store.d.ts +43 -0
- package/dist/observations/observation-store.d.ts.map +1 -0
- package/dist/observations/observation-store.js +213 -0
- package/dist/observations/observation-store.js.map +1 -0
- package/dist/observations/repository-identity.d.ts +12 -0
- package/dist/observations/repository-identity.d.ts.map +1 -0
- package/dist/observations/repository-identity.js +108 -0
- package/dist/observations/repository-identity.js.map +1 -0
- package/dist/query/context-query-service.d.ts +15 -0
- package/dist/query/context-query-service.d.ts.map +1 -0
- package/dist/query/context-query-service.js +36 -0
- package/dist/query/context-query-service.js.map +1 -0
- package/dist/reconciliation/reconciliation-service.d.ts +10 -0
- package/dist/reconciliation/reconciliation-service.d.ts.map +1 -0
- package/dist/reconciliation/reconciliation-service.js +114 -0
- package/dist/reconciliation/reconciliation-service.js.map +1 -0
- package/dist/rendering/map-projector.d.ts +8 -0
- package/dist/rendering/map-projector.d.ts.map +1 -0
- package/dist/rendering/map-projector.js +386 -0
- package/dist/rendering/map-projector.js.map +1 -0
- package/dist/setup/managed-skill-installer.d.ts +60 -0
- package/dist/setup/managed-skill-installer.d.ts.map +1 -0
- package/dist/setup/managed-skill-installer.js +293 -0
- package/dist/setup/managed-skill-installer.js.map +1 -0
- package/dist/setup/package-identity.d.ts +6 -0
- package/dist/setup/package-identity.d.ts.map +1 -0
- package/dist/setup/package-identity.js +16 -0
- package/dist/setup/package-identity.js.map +1 -0
- package/dist/setup/package-upgrader.d.ts +10 -22
- package/dist/setup/package-upgrader.d.ts.map +1 -1
- package/dist/setup/package-upgrader.js +60 -76
- package/dist/setup/package-upgrader.js.map +1 -0
- package/docs/architecture.md +426 -0
- package/docs/evaluation.md +220 -174
- package/docs/index.md +27 -45
- package/docs/map-format.md +225 -0
- package/docs/observations.md +167 -0
- package/docs/product-contract.md +282 -165
- package/examples/commerce.yaml +204 -0
- package/package.json +31 -32
- package/.agents/skills/semantic-atlas/references/graph-patch.md +0 -190
- package/.agents/skills/semantic-atlas/references/product-feedback.md +0 -34
- package/.agents/skills/semantic-atlas/references/result-routing.md +0 -104
- package/.agents/skills/semantic-atlas/references/snapshot-bootstrap.md +0 -42
- package/.agents/skills/semantic-atlas-insights/SKILL.md +0 -55
- package/README.zh-CN.md +0 -296
- package/dist/business-flow/business-flow-derivation-service.d.ts +0 -11
- package/dist/business-flow/business-flow-derivation-service.d.ts.map +0 -1
- package/dist/business-flow/business-flow-derivation-service.js +0 -151
- package/dist/business-flow/business-flow-draft.d.ts +0 -16
- package/dist/business-flow/business-flow-draft.d.ts.map +0 -1
- package/dist/business-flow/business-flow-draft.js +0 -150
- package/dist/business-flow/framework-business-strategy.d.ts +0 -7
- package/dist/business-flow/framework-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/framework-business-strategy.js +0 -1
- package/dist/business-flow/strategies/bullmq-business-strategy.d.ts +0 -10
- package/dist/business-flow/strategies/bullmq-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/bullmq-business-strategy.js +0 -79
- package/dist/business-flow/strategies/called-operation-derivation.d.ts +0 -13
- package/dist/business-flow/strategies/called-operation-derivation.d.ts.map +0 -1
- package/dist/business-flow/strategies/called-operation-derivation.js +0 -32
- package/dist/business-flow/strategies/graphql-business-strategy.d.ts +0 -8
- package/dist/business-flow/strategies/graphql-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/graphql-business-strategy.js +0 -65
- package/dist/business-flow/strategies/nestjs-business-strategy.d.ts +0 -8
- package/dist/business-flow/strategies/nestjs-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/nestjs-business-strategy.js +0 -72
- package/dist/business-flow/strategies/strategy-helpers.d.ts +0 -32
- package/dist/business-flow/strategies/strategy-helpers.d.ts.map +0 -1
- package/dist/business-flow/strategies/strategy-helpers.js +0 -49
- package/dist/business-flow/strategies/typeorm-business-strategy.d.ts +0 -10
- package/dist/business-flow/strategies/typeorm-business-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/typeorm-business-strategy.js +0 -136
- package/dist/business-flow/strategies/verified-invariant-strategy.d.ts +0 -5
- package/dist/business-flow/strategies/verified-invariant-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/verified-invariant-strategy.js +0 -38
- package/dist/business-flow/strategies/verified-test-strategy.d.ts +0 -5
- package/dist/business-flow/strategies/verified-test-strategy.d.ts.map +0 -1
- package/dist/business-flow/strategies/verified-test-strategy.js +0 -26
- package/dist/business-flow/structural-flow-catalog.d.ts +0 -21
- package/dist/business-flow/structural-flow-catalog.d.ts.map +0 -1
- package/dist/business-flow/structural-flow-catalog.js +0 -125
- package/dist/business-flow/types.d.ts +0 -51
- package/dist/business-flow/types.d.ts.map +0 -1
- package/dist/business-flow/types.js +0 -1
- package/dist/cli/argument-parser.d.ts +0 -3
- package/dist/cli/argument-parser.d.ts.map +0 -1
- package/dist/cli/argument-parser.js +0 -200
- package/dist/cli/cli-application.d.ts +0 -39
- package/dist/cli/cli-application.d.ts.map +0 -1
- package/dist/cli/cli-application.js +0 -571
- package/dist/cli/cli-error.d.ts +0 -12
- package/dist/cli/cli-error.d.ts.map +0 -1
- package/dist/cli/cli-error.js +0 -44
- package/dist/cli/cli-presenter.d.ts +0 -14
- package/dist/cli/cli-presenter.d.ts.map +0 -1
- package/dist/cli/cli-presenter.js +0 -36
- package/dist/cli/insights-cli.d.ts +0 -6
- package/dist/cli/insights-cli.d.ts.map +0 -1
- package/dist/cli/insights-cli.js +0 -236
- package/dist/cli/main.d.ts +0 -3
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js +0 -137
- package/dist/cli/standalone-cli.d.ts +0 -3
- package/dist/cli/standalone-cli.d.ts.map +0 -1
- package/dist/cli/standalone-cli.js +0 -104
- package/dist/cli/types.d.ts +0 -49
- package/dist/cli/types.d.ts.map +0 -1
- package/dist/cli/types.js +0 -1
- package/dist/cli/web-cli.d.ts +0 -9
- package/dist/cli/web-cli.d.ts.map +0 -1
- package/dist/cli/web-cli.js +0 -134
- package/dist/contracts/graph.d.ts +0 -266
- package/dist/contracts/graph.d.ts.map +0 -1
- package/dist/contracts/graph.js +0 -182
- package/dist/contracts/identifiers.d.ts +0 -4
- package/dist/contracts/identifiers.d.ts.map +0 -1
- package/dist/contracts/identifiers.js +0 -7
- package/dist/contracts/public-contracts.d.ts +0 -5
- package/dist/contracts/public-contracts.d.ts.map +0 -1
- package/dist/contracts/public-contracts.js +0 -4
- package/dist/evaluation/comparison.d.ts +0 -30
- package/dist/evaluation/comparison.d.ts.map +0 -1
- package/dist/evaluation/comparison.js +0 -108
- package/dist/evaluation/contracts.d.ts +0 -301
- package/dist/evaluation/contracts.d.ts.map +0 -1
- package/dist/evaluation/contracts.js +0 -413
- package/dist/graph/graph-store.d.ts +0 -55
- package/dist/graph/graph-store.d.ts.map +0 -1
- package/dist/graph/graph-store.js +0 -912
- package/dist/graph/types.d.ts +0 -189
- package/dist/graph/types.d.ts.map +0 -1
- package/dist/graph/types.js +0 -1
- package/dist/insights/contracts.d.ts +0 -266
- package/dist/insights/contracts.d.ts.map +0 -1
- package/dist/insights/contracts.js +0 -124
- package/dist/insights/insights-store.d.ts +0 -73
- package/dist/insights/insights-store.d.ts.map +0 -1
- package/dist/insights/insights-store.js +0 -246
- package/dist/knowledge/business-knowledge-service.d.ts +0 -24
- package/dist/knowledge/business-knowledge-service.d.ts.map +0 -1
- package/dist/knowledge/business-knowledge-service.js +0 -200
- package/dist/knowledge/graph-patch-conflict-error.d.ts +0 -8
- package/dist/knowledge/graph-patch-conflict-error.d.ts.map +0 -1
- package/dist/knowledge/graph-patch-conflict-error.js +0 -12
- package/dist/knowledge/structural-target-binding.d.ts +0 -14
- package/dist/knowledge/structural-target-binding.d.ts.map +0 -1
- package/dist/knowledge/structural-target-binding.js +0 -11
- package/dist/package-metadata.d.ts +0 -2
- package/dist/package-metadata.d.ts.map +0 -1
- package/dist/package-metadata.js +0 -9
- package/dist/repository/git-command.d.ts +0 -3
- package/dist/repository/git-command.d.ts.map +0 -1
- package/dist/repository/git-command.js +0 -25
- package/dist/repository/repository-inspector.d.ts +0 -8
- package/dist/repository/repository-inspector.d.ts.map +0 -1
- package/dist/repository/repository-inspector.js +0 -97
- package/dist/repository/repository-language-support.d.ts +0 -14
- package/dist/repository/repository-language-support.d.ts.map +0 -1
- package/dist/repository/repository-language-support.js +0 -64
- package/dist/repository/types.d.ts +0 -9
- package/dist/repository/types.d.ts.map +0 -1
- package/dist/repository/types.js +0 -1
- package/dist/runtime/sqlite-compatibility-process.d.ts +0 -8
- package/dist/runtime/sqlite-compatibility-process.d.ts.map +0 -1
- package/dist/runtime/sqlite-compatibility-process.js +0 -20
- package/dist/setup/skill-installer.d.ts +0 -20
- package/dist/setup/skill-installer.d.ts.map +0 -1
- package/dist/setup/skill-installer.js +0 -187
- package/dist/snapshots/repository-snapshot.d.ts +0 -4
- package/dist/snapshots/repository-snapshot.d.ts.map +0 -1
- package/dist/snapshots/repository-snapshot.js +0 -119
- package/dist/snapshots/types.d.ts +0 -30
- package/dist/snapshots/types.d.ts.map +0 -1
- package/dist/snapshots/types.js +0 -1
- package/dist/storage/atlas-database.d.ts +0 -25
- package/dist/storage/atlas-database.d.ts.map +0 -1
- package/dist/storage/atlas-database.js +0 -483
- package/dist/storage/snapshot-store.d.ts +0 -19
- package/dist/storage/snapshot-store.d.ts.map +0 -1
- package/dist/storage/snapshot-store.js +0 -74
- package/dist/structural-backend/codegraph-backend.d.ts +0 -57
- package/dist/structural-backend/codegraph-backend.d.ts.map +0 -1
- package/dist/structural-backend/codegraph-backend.js +0 -1230
- package/dist/structural-backend/codegraph-worker-client.d.ts +0 -5
- package/dist/structural-backend/codegraph-worker-client.d.ts.map +0 -1
- package/dist/structural-backend/codegraph-worker-client.js +0 -118
- package/dist/structural-backend/codegraph-worker-protocol.d.ts +0 -35
- package/dist/structural-backend/codegraph-worker-protocol.d.ts.map +0 -1
- package/dist/structural-backend/codegraph-worker-protocol.js +0 -1
- package/dist/structural-backend/codegraph-worker.d.ts +0 -2
- package/dist/structural-backend/codegraph-worker.d.ts.map +0 -1
- package/dist/structural-backend/codegraph-worker.js +0 -131
- package/dist/structural-backend/process-instance.d.ts +0 -18
- package/dist/structural-backend/process-instance.d.ts.map +0 -1
- package/dist/structural-backend/process-instance.js +0 -207
- package/dist/structural-backend/structural-fact-changes.d.ts +0 -7
- package/dist/structural-backend/structural-fact-changes.d.ts.map +0 -1
- package/dist/structural-backend/structural-fact-changes.js +0 -78
- package/dist/structural-backend/structural-projection-bootstrapper.d.ts +0 -10
- package/dist/structural-backend/structural-projection-bootstrapper.d.ts.map +0 -1
- package/dist/structural-backend/structural-projection-bootstrapper.js +0 -295
- package/dist/structural-backend/structural-publication.d.ts +0 -13
- package/dist/structural-backend/structural-publication.d.ts.map +0 -1
- package/dist/structural-backend/structural-publication.js +0 -255
- package/dist/structural-backend/structural-write-lock.d.ts +0 -8
- package/dist/structural-backend/structural-write-lock.d.ts.map +0 -1
- package/dist/structural-backend/structural-write-lock.js +0 -415
- package/dist/structural-backend/types.d.ts +0 -144
- package/dist/structural-backend/types.d.ts.map +0 -1
- package/dist/structural-backend/types.js +0 -11
- package/dist/web/application/atlas-read-service.d.ts +0 -27
- package/dist/web/application/atlas-read-service.d.ts.map +0 -1
- package/dist/web/application/atlas-read-service.js +0 -216
- package/dist/web/application/primary-repository-catalog.d.ts +0 -15
- package/dist/web/application/primary-repository-catalog.d.ts.map +0 -1
- package/dist/web/application/primary-repository-catalog.js +0 -202
- package/dist/web/application/types.d.ts +0 -41
- package/dist/web/application/types.d.ts.map +0 -1
- package/dist/web/application/types.js +0 -1
- package/dist/web/server/api-router.d.ts +0 -4
- package/dist/web/server/api-router.d.ts.map +0 -1
- package/dist/web/server/api-router.js +0 -151
- package/dist/web/server/local-web-server.d.ts +0 -12
- package/dist/web/server/local-web-server.d.ts.map +0 -1
- package/dist/web/server/local-web-server.js +0 -100
- package/dist/web-client/assets/index-DneaErDj.css +0 -1
- package/dist/web-client/assets/index-cze_4vtt.js +0 -2
- package/dist/web-client/assets/index-cze_4vtt.js.map +0 -1
- package/dist/web-client/index.html +0 -61
- package/dist/world/business-map-projector.d.ts +0 -14
- package/dist/world/business-map-projector.d.ts.map +0 -1
- package/dist/world/business-map-projector.js +0 -178
- package/dist/world/types.d.ts +0 -77
- package/dist/world/types.d.ts.map +0 -1
- package/dist/world/types.js +0 -1
- package/dist/world/world-graph-query.d.ts +0 -30
- package/dist/world/world-graph-query.d.ts.map +0 -1
- package/dist/world/world-graph-query.js +0 -252
- package/dist/world/world-model-service.d.ts +0 -21
- package/dist/world/world-model-service.d.ts.map +0 -1
- package/dist/world/world-model-service.js +0 -219
- package/dist/world/world-snapshot-store.d.ts +0 -41
- package/dist/world/world-snapshot-store.d.ts.map +0 -1
- package/dist/world/world-snapshot-store.js +0 -581
- package/docs/README.md +0 -30
- package/docs/architecture/codegraph-backend.md +0 -190
- package/docs/architecture/continuous-business-learning.md +0 -240
- package/docs/architecture/web-viewer.md +0 -225
- package/docs/contracts/cli-v1.md +0 -179
- package/docs/contracts/graph-model.md +0 -106
- package/docs/contracts/graph-patch-v1.md +0 -105
- package/docs/contracts/http-api-v1.md +0 -155
- package/docs/contracts/insights-v1.md +0 -84
- package/docs/log.md +0 -159
- package/docs/mindmaps/semantic-atlas-overview.drawio +0 -255
- package/docs/mindmaps/semantic-atlas-overview.png +0 -0
- package/docs/mindmaps/semantic-atlas-overview.zh-CN.drawio +0 -255
- package/docs/mindmaps/semantic-atlas-overview.zh-CN.png +0 -0
- package/schemas/cli-envelope-v1.schema.json +0 -1244
- package/schemas/evaluation-plan-v1.schema.json +0 -211
- package/schemas/evaluation-run-v1.schema.json +0 -659
- package/schemas/graph-patch-v1.schema.json +0 -392
- package/schemas/insights-envelope-v1.schema.json +0 -428
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
import { lstatSync, mkdirSync, realpathSync } from "node:fs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
-
export const CURRENT_ATLAS_SCHEMA_VERSION = 1;
|
|
6
|
-
export const SEMANTIC_ATLAS_HOME_ENVIRONMENT_VARIABLE = "SEMANTIC_ATLAS_HOME";
|
|
7
|
-
const require = createRequire(import.meta.url);
|
|
8
|
-
export class AtlasDatabase {
|
|
9
|
-
databasePath;
|
|
10
|
-
connection;
|
|
11
|
-
#closed = false;
|
|
12
|
-
constructor(repository, options = {}) {
|
|
13
|
-
const access = options.access ?? "read-write";
|
|
14
|
-
this.databasePath = access === "read-only"
|
|
15
|
-
? resolveExistingAtlasDatabasePath(repository)
|
|
16
|
-
: resolveAtlasDatabasePath(repository);
|
|
17
|
-
const { DatabaseSync } = require("node:sqlite");
|
|
18
|
-
this.connection = new DatabaseSync(this.databasePath, { readOnly: access === "read-only" });
|
|
19
|
-
try {
|
|
20
|
-
this.connection.exec(access === "read-only"
|
|
21
|
-
? "PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 5000;"
|
|
22
|
-
: "PRAGMA foreign_keys = ON; PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 5000;");
|
|
23
|
-
if (access === "read-only") {
|
|
24
|
-
this.requireCurrentSchema();
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
this.initializeSchema();
|
|
28
|
-
this.registerRepository(repository);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
this.connection.close();
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
get schemaVersion() {
|
|
36
|
-
const row = this.connection.prepare(`
|
|
37
|
-
SELECT version
|
|
38
|
-
FROM atlas_schema
|
|
39
|
-
WHERE singleton = 1
|
|
40
|
-
`).get();
|
|
41
|
-
return row.version;
|
|
42
|
-
}
|
|
43
|
-
close() {
|
|
44
|
-
if (this.#closed) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
this.connection.close();
|
|
48
|
-
this.#closed = true;
|
|
49
|
-
}
|
|
50
|
-
[Symbol.dispose]() {
|
|
51
|
-
this.close();
|
|
52
|
-
}
|
|
53
|
-
initializeSchema() {
|
|
54
|
-
const atlasSchema = this.connection.prepare(`
|
|
55
|
-
SELECT name
|
|
56
|
-
FROM sqlite_schema
|
|
57
|
-
WHERE type = 'table' AND name = 'atlas_schema'
|
|
58
|
-
`).get();
|
|
59
|
-
if (atlasSchema !== undefined) {
|
|
60
|
-
const version = this.schemaVersion;
|
|
61
|
-
if (version !== CURRENT_ATLAS_SCHEMA_VERSION) {
|
|
62
|
-
throw new Error(`Atlas database schema ${version} is not supported; expected schema ${CURRENT_ATLAS_SCHEMA_VERSION}`);
|
|
63
|
-
}
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const existingTables = this.connection.prepare(`
|
|
67
|
-
SELECT COUNT(*) AS count
|
|
68
|
-
FROM sqlite_schema
|
|
69
|
-
WHERE type = 'table' AND name NOT LIKE 'sqlite_%'
|
|
70
|
-
`).get();
|
|
71
|
-
if (existingTables.count > 0) {
|
|
72
|
-
throw new Error("The Atlas database is not a fresh schema v1 store");
|
|
73
|
-
}
|
|
74
|
-
this.connection.exec("BEGIN IMMEDIATE");
|
|
75
|
-
try {
|
|
76
|
-
this.connection.exec(ATLAS_SCHEMA_V1);
|
|
77
|
-
this.connection.prepare(`
|
|
78
|
-
INSERT INTO atlas_schema (singleton, version, created_at)
|
|
79
|
-
VALUES (1, ?, ?)
|
|
80
|
-
`).run(CURRENT_ATLAS_SCHEMA_VERSION, new Date().toISOString());
|
|
81
|
-
this.connection.exec("COMMIT");
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
this.connection.exec("ROLLBACK");
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
requireCurrentSchema() {
|
|
89
|
-
const atlasSchema = this.connection.prepare(`
|
|
90
|
-
SELECT name
|
|
91
|
-
FROM sqlite_schema
|
|
92
|
-
WHERE type = 'table' AND name = 'atlas_schema'
|
|
93
|
-
`).get();
|
|
94
|
-
if (atlasSchema === undefined || this.schemaVersion !== CURRENT_ATLAS_SCHEMA_VERSION) {
|
|
95
|
-
throw new Error(`The Atlas database is not a supported schema v${CURRENT_ATLAS_SCHEMA_VERSION} store`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
registerRepository(repository) {
|
|
99
|
-
const timestamp = new Date().toISOString();
|
|
100
|
-
this.connection.exec("BEGIN IMMEDIATE");
|
|
101
|
-
try {
|
|
102
|
-
this.connection.prepare(`
|
|
103
|
-
INSERT INTO atlas_repositories (
|
|
104
|
-
repository_id,
|
|
105
|
-
common_git_directory,
|
|
106
|
-
updated_at
|
|
107
|
-
) VALUES (?, ?, ?)
|
|
108
|
-
ON CONFLICT (repository_id) DO UPDATE SET
|
|
109
|
-
common_git_directory = excluded.common_git_directory,
|
|
110
|
-
updated_at = excluded.updated_at
|
|
111
|
-
`).run(repository.repositoryId, repository.commonGitDirectory, timestamp);
|
|
112
|
-
this.connection.prepare(`
|
|
113
|
-
INSERT INTO atlas_worktree_states (
|
|
114
|
-
repository_id,
|
|
115
|
-
git_directory,
|
|
116
|
-
worktree_root,
|
|
117
|
-
status,
|
|
118
|
-
updated_at
|
|
119
|
-
) VALUES (?, ?, ?, 'missing', ?)
|
|
120
|
-
ON CONFLICT (repository_id, git_directory) DO UPDATE SET
|
|
121
|
-
worktree_root = excluded.worktree_root,
|
|
122
|
-
updated_at = excluded.updated_at
|
|
123
|
-
`).run(repository.repositoryId, repository.gitDirectory, repository.worktreeRoot, timestamp);
|
|
124
|
-
this.connection.exec("COMMIT");
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
this.connection.exec("ROLLBACK");
|
|
128
|
-
throw error;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
export function resolveAtlasHome(repository) {
|
|
133
|
-
const realAtlasHome = resolveConfiguredAtlasHome();
|
|
134
|
-
requireAtlasHomeOutsideRepository(realAtlasHome, repository);
|
|
135
|
-
return realAtlasHome;
|
|
136
|
-
}
|
|
137
|
-
export function resolveExistingAtlasHome() {
|
|
138
|
-
const atlasHome = configuredAtlasHomePath();
|
|
139
|
-
try {
|
|
140
|
-
requireRealDirectory(atlasHome, "The Semantic Atlas home");
|
|
141
|
-
return realpathSync(atlasHome);
|
|
142
|
-
}
|
|
143
|
-
catch (error) {
|
|
144
|
-
if (error.code === "ENOENT") {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
throw error;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function requireAtlasHomeOutsideRepository(realAtlasHome, repository) {
|
|
151
|
-
for (const worktreeRoot of repository.worktreeRoots) {
|
|
152
|
-
const realWorktreeRoot = realpathExistingPath(worktreeRoot);
|
|
153
|
-
if (realWorktreeRoot !== null && isPathInside(realAtlasHome, realWorktreeRoot)) {
|
|
154
|
-
throw new Error("The Semantic Atlas home must be outside every repository worktree");
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
export function resolveInsightsDatabasePath() {
|
|
159
|
-
return join(resolveConfiguredAtlasHome(), "insights.db");
|
|
160
|
-
}
|
|
161
|
-
function resolveConfiguredAtlasHome() {
|
|
162
|
-
const atlasHome = configuredAtlasHomePath();
|
|
163
|
-
mkdirSync(atlasHome, { recursive: true, mode: 0o700 });
|
|
164
|
-
requireRealDirectory(atlasHome, "The Semantic Atlas home");
|
|
165
|
-
const realAtlasHome = realpathSync(atlasHome);
|
|
166
|
-
return realAtlasHome;
|
|
167
|
-
}
|
|
168
|
-
function configuredAtlasHomePath() {
|
|
169
|
-
const configuredHome = process.env[SEMANTIC_ATLAS_HOME_ENVIRONMENT_VARIABLE];
|
|
170
|
-
if (configuredHome !== undefined && !isAbsolute(configuredHome)) {
|
|
171
|
-
throw new Error(`${SEMANTIC_ATLAS_HOME_ENVIRONMENT_VARIABLE} must be an absolute path`);
|
|
172
|
-
}
|
|
173
|
-
return resolve(configuredHome ?? join(homedir(), ".semantic-atlas"));
|
|
174
|
-
}
|
|
175
|
-
export function resolveAtlasDatabasePath(repository) {
|
|
176
|
-
const atlasHome = resolveAtlasHome(repository);
|
|
177
|
-
const repositoriesDirectory = join(atlasHome, "repositories");
|
|
178
|
-
const repositoryDirectory = join(repositoriesDirectory, repository.repositoryId);
|
|
179
|
-
mkdirSync(repositoryDirectory, { recursive: true, mode: 0o700 });
|
|
180
|
-
requireRealDirectory(repositoriesDirectory, "The Semantic Atlas repositories directory");
|
|
181
|
-
requireRealDirectory(repositoryDirectory, "The repository Atlas directory");
|
|
182
|
-
return join(repositoryDirectory, "atlas.db");
|
|
183
|
-
}
|
|
184
|
-
function resolveExistingAtlasDatabasePath(repository) {
|
|
185
|
-
const atlasHome = resolveExistingAtlasHome();
|
|
186
|
-
if (atlasHome === null) {
|
|
187
|
-
throw new Error("The Semantic Atlas home does not exist");
|
|
188
|
-
}
|
|
189
|
-
requireAtlasHomeOutsideRepository(atlasHome, repository);
|
|
190
|
-
const repositoriesDirectory = join(atlasHome, "repositories");
|
|
191
|
-
const repositoryDirectory = join(repositoriesDirectory, repository.repositoryId);
|
|
192
|
-
requireRealDirectory(repositoriesDirectory, "The Semantic Atlas repositories directory");
|
|
193
|
-
requireRealDirectory(repositoryDirectory, "The repository Atlas directory");
|
|
194
|
-
return join(repositoryDirectory, "atlas.db");
|
|
195
|
-
}
|
|
196
|
-
function requireRealDirectory(path, label) {
|
|
197
|
-
const metadata = lstatSync(path);
|
|
198
|
-
if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
|
|
199
|
-
throw new Error(`${label} must be a real directory`);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function realpathExistingPath(path) {
|
|
203
|
-
try {
|
|
204
|
-
return realpathSync(path);
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
if (error.code === "ENOENT") {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
throw error;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function isPathInside(candidate, parent) {
|
|
214
|
-
const pathFromParent = relative(parent, candidate);
|
|
215
|
-
return pathFromParent === "" || (pathFromParent !== ".."
|
|
216
|
-
&& !pathFromParent.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`)
|
|
217
|
-
&& !isAbsolute(pathFromParent));
|
|
218
|
-
}
|
|
219
|
-
const ATLAS_SCHEMA_V1 = `
|
|
220
|
-
CREATE TABLE atlas_schema (
|
|
221
|
-
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
222
|
-
version INTEGER NOT NULL CHECK (version = 1),
|
|
223
|
-
created_at TEXT NOT NULL
|
|
224
|
-
) STRICT;
|
|
225
|
-
|
|
226
|
-
CREATE TABLE atlas_repositories (
|
|
227
|
-
repository_id TEXT PRIMARY KEY,
|
|
228
|
-
common_git_directory TEXT NOT NULL,
|
|
229
|
-
updated_at TEXT NOT NULL
|
|
230
|
-
) STRICT;
|
|
231
|
-
|
|
232
|
-
CREATE TABLE atlas_repository_snapshots (
|
|
233
|
-
repository_id TEXT NOT NULL,
|
|
234
|
-
snapshot_id TEXT NOT NULL,
|
|
235
|
-
payload TEXT NOT NULL,
|
|
236
|
-
created_at TEXT NOT NULL,
|
|
237
|
-
PRIMARY KEY (repository_id, snapshot_id),
|
|
238
|
-
FOREIGN KEY (repository_id)
|
|
239
|
-
REFERENCES atlas_repositories(repository_id) ON DELETE CASCADE
|
|
240
|
-
) STRICT;
|
|
241
|
-
|
|
242
|
-
CREATE TABLE atlas_world_publications (
|
|
243
|
-
publication_id INTEGER PRIMARY KEY,
|
|
244
|
-
repository_id TEXT NOT NULL,
|
|
245
|
-
git_directory TEXT NOT NULL,
|
|
246
|
-
previous_publication_id INTEGER CHECK (
|
|
247
|
-
previous_publication_id IS NULL OR previous_publication_id < publication_id
|
|
248
|
-
),
|
|
249
|
-
snapshot_id TEXT NOT NULL,
|
|
250
|
-
added_paths TEXT NOT NULL,
|
|
251
|
-
modified_paths TEXT NOT NULL,
|
|
252
|
-
removed_paths TEXT NOT NULL,
|
|
253
|
-
stale_assertions TEXT NOT NULL,
|
|
254
|
-
published_at TEXT NOT NULL,
|
|
255
|
-
UNIQUE (repository_id, git_directory, publication_id),
|
|
256
|
-
FOREIGN KEY (repository_id)
|
|
257
|
-
REFERENCES atlas_repositories(repository_id) ON DELETE CASCADE,
|
|
258
|
-
FOREIGN KEY (repository_id, snapshot_id)
|
|
259
|
-
REFERENCES atlas_repository_snapshots(repository_id, snapshot_id) ON DELETE CASCADE,
|
|
260
|
-
FOREIGN KEY (repository_id, git_directory, previous_publication_id)
|
|
261
|
-
REFERENCES atlas_world_publications(repository_id, git_directory, publication_id)
|
|
262
|
-
) STRICT;
|
|
263
|
-
|
|
264
|
-
CREATE TABLE atlas_worktree_states (
|
|
265
|
-
repository_id TEXT NOT NULL,
|
|
266
|
-
git_directory TEXT NOT NULL,
|
|
267
|
-
worktree_root TEXT NOT NULL,
|
|
268
|
-
status TEXT NOT NULL CHECK (status IN ('missing', 'building', 'current', 'failed')),
|
|
269
|
-
current_snapshot_id TEXT,
|
|
270
|
-
target_snapshot_id TEXT,
|
|
271
|
-
backend_version TEXT,
|
|
272
|
-
extraction_version INTEGER,
|
|
273
|
-
current_publication_id INTEGER,
|
|
274
|
-
failure_message TEXT,
|
|
275
|
-
started_at TEXT,
|
|
276
|
-
published_at TEXT,
|
|
277
|
-
updated_at TEXT NOT NULL,
|
|
278
|
-
PRIMARY KEY (repository_id, git_directory),
|
|
279
|
-
FOREIGN KEY (repository_id)
|
|
280
|
-
REFERENCES atlas_repositories(repository_id) ON DELETE CASCADE,
|
|
281
|
-
FOREIGN KEY (repository_id, current_snapshot_id)
|
|
282
|
-
REFERENCES atlas_repository_snapshots(repository_id, snapshot_id),
|
|
283
|
-
FOREIGN KEY (repository_id, git_directory, current_publication_id)
|
|
284
|
-
REFERENCES atlas_world_publications(repository_id, git_directory, publication_id)
|
|
285
|
-
) STRICT;
|
|
286
|
-
|
|
287
|
-
CREATE INDEX atlas_worktree_states_current_index
|
|
288
|
-
ON atlas_worktree_states (repository_id, status, published_at DESC, worktree_root);
|
|
289
|
-
CREATE INDEX atlas_world_publications_worktree_order_index
|
|
290
|
-
ON atlas_world_publications (repository_id, git_directory, publication_id DESC);
|
|
291
|
-
CREATE INDEX atlas_world_publications_snapshot_index
|
|
292
|
-
ON atlas_world_publications (repository_id, git_directory, snapshot_id, publication_id DESC);
|
|
293
|
-
|
|
294
|
-
CREATE TABLE atlas_business_nodes (
|
|
295
|
-
node_id INTEGER PRIMARY KEY,
|
|
296
|
-
repository_id TEXT NOT NULL,
|
|
297
|
-
node_key TEXT NOT NULL,
|
|
298
|
-
base_snapshot_id TEXT NOT NULL,
|
|
299
|
-
kind TEXT NOT NULL CHECK (kind IN (
|
|
300
|
-
'Capability', 'Scenario', 'Operation', 'Invariant', 'Interface', 'Data'
|
|
301
|
-
)),
|
|
302
|
-
label TEXT NOT NULL,
|
|
303
|
-
summary TEXT NOT NULL,
|
|
304
|
-
certainty TEXT NOT NULL CHECK (certainty IN ('exact', 'inferred', 'hypothesis')),
|
|
305
|
-
UNIQUE (repository_id, node_key),
|
|
306
|
-
FOREIGN KEY (repository_id, base_snapshot_id)
|
|
307
|
-
REFERENCES atlas_repository_snapshots(repository_id, snapshot_id)
|
|
308
|
-
) STRICT;
|
|
309
|
-
|
|
310
|
-
CREATE TABLE atlas_business_node_aliases (
|
|
311
|
-
node_id INTEGER NOT NULL,
|
|
312
|
-
position INTEGER NOT NULL,
|
|
313
|
-
alias TEXT NOT NULL,
|
|
314
|
-
PRIMARY KEY (node_id, position),
|
|
315
|
-
FOREIGN KEY (node_id) REFERENCES atlas_business_nodes(node_id) ON DELETE CASCADE
|
|
316
|
-
) STRICT;
|
|
317
|
-
|
|
318
|
-
CREATE TABLE atlas_business_node_evidence (
|
|
319
|
-
node_id INTEGER NOT NULL,
|
|
320
|
-
position INTEGER NOT NULL,
|
|
321
|
-
structural_reference TEXT NOT NULL,
|
|
322
|
-
file TEXT NOT NULL,
|
|
323
|
-
qualified_symbol TEXT,
|
|
324
|
-
structural_kind TEXT,
|
|
325
|
-
start_line INTEGER NOT NULL,
|
|
326
|
-
start_column INTEGER NOT NULL,
|
|
327
|
-
end_line INTEGER NOT NULL,
|
|
328
|
-
end_column INTEGER NOT NULL,
|
|
329
|
-
content_hash TEXT NOT NULL,
|
|
330
|
-
backend_locator TEXT,
|
|
331
|
-
PRIMARY KEY (node_id, position),
|
|
332
|
-
FOREIGN KEY (node_id) REFERENCES atlas_business_nodes(node_id) ON DELETE CASCADE
|
|
333
|
-
) STRICT;
|
|
334
|
-
|
|
335
|
-
CREATE TABLE atlas_business_node_evidence_bindings (
|
|
336
|
-
node_id INTEGER NOT NULL,
|
|
337
|
-
position INTEGER NOT NULL,
|
|
338
|
-
repository_id TEXT NOT NULL,
|
|
339
|
-
snapshot_id TEXT NOT NULL,
|
|
340
|
-
resolved_structural_reference TEXT,
|
|
341
|
-
resolved_qualified_symbol TEXT,
|
|
342
|
-
resolved_structural_kind TEXT,
|
|
343
|
-
backend_version TEXT,
|
|
344
|
-
backend_locator TEXT,
|
|
345
|
-
binding_status TEXT NOT NULL CHECK (
|
|
346
|
-
binding_status IN ('bound', 'missing', 'ambiguous', 'unresolved')
|
|
347
|
-
),
|
|
348
|
-
PRIMARY KEY (node_id, position, snapshot_id),
|
|
349
|
-
FOREIGN KEY (node_id, position)
|
|
350
|
-
REFERENCES atlas_business_node_evidence(node_id, position) ON DELETE CASCADE,
|
|
351
|
-
FOREIGN KEY (repository_id, snapshot_id)
|
|
352
|
-
REFERENCES atlas_repository_snapshots(repository_id, snapshot_id) ON DELETE CASCADE
|
|
353
|
-
) STRICT;
|
|
354
|
-
|
|
355
|
-
CREATE TABLE atlas_business_relations (
|
|
356
|
-
relation_id INTEGER PRIMARY KEY,
|
|
357
|
-
repository_id TEXT NOT NULL,
|
|
358
|
-
base_snapshot_id TEXT NOT NULL,
|
|
359
|
-
from_key TEXT NOT NULL,
|
|
360
|
-
relation_type TEXT NOT NULL CHECK (relation_type IN (
|
|
361
|
-
'part_of', 'invokes', 'realized_by', 'reads', 'writes', 'publishes',
|
|
362
|
-
'consumes', 'constrained_by', 'verified_by'
|
|
363
|
-
)),
|
|
364
|
-
to_domain TEXT NOT NULL CHECK (to_domain IN ('structural', 'business')),
|
|
365
|
-
to_key TEXT NOT NULL,
|
|
366
|
-
certainty TEXT NOT NULL CHECK (certainty IN ('exact', 'inferred', 'hypothesis')),
|
|
367
|
-
target_file TEXT,
|
|
368
|
-
target_qualified_symbol TEXT,
|
|
369
|
-
target_structural_kind TEXT,
|
|
370
|
-
target_start_line INTEGER,
|
|
371
|
-
target_start_column INTEGER,
|
|
372
|
-
target_end_line INTEGER,
|
|
373
|
-
target_end_column INTEGER,
|
|
374
|
-
target_backend_locator TEXT,
|
|
375
|
-
UNIQUE (repository_id, from_key, relation_type, to_domain, to_key),
|
|
376
|
-
FOREIGN KEY (repository_id, base_snapshot_id)
|
|
377
|
-
REFERENCES atlas_repository_snapshots(repository_id, snapshot_id),
|
|
378
|
-
FOREIGN KEY (repository_id, from_key)
|
|
379
|
-
REFERENCES atlas_business_nodes(repository_id, node_key)
|
|
380
|
-
) STRICT;
|
|
381
|
-
|
|
382
|
-
CREATE INDEX atlas_business_relations_from_index
|
|
383
|
-
ON atlas_business_relations (repository_id, from_key);
|
|
384
|
-
CREATE INDEX atlas_business_relations_to_index
|
|
385
|
-
ON atlas_business_relations (repository_id, to_domain, to_key);
|
|
386
|
-
|
|
387
|
-
CREATE TABLE atlas_business_relation_evidence (
|
|
388
|
-
relation_id INTEGER NOT NULL,
|
|
389
|
-
position INTEGER NOT NULL,
|
|
390
|
-
structural_reference TEXT NOT NULL,
|
|
391
|
-
file TEXT NOT NULL,
|
|
392
|
-
qualified_symbol TEXT,
|
|
393
|
-
structural_kind TEXT,
|
|
394
|
-
start_line INTEGER NOT NULL,
|
|
395
|
-
start_column INTEGER NOT NULL,
|
|
396
|
-
end_line INTEGER NOT NULL,
|
|
397
|
-
end_column INTEGER NOT NULL,
|
|
398
|
-
content_hash TEXT NOT NULL,
|
|
399
|
-
backend_locator TEXT,
|
|
400
|
-
PRIMARY KEY (relation_id, position),
|
|
401
|
-
FOREIGN KEY (relation_id)
|
|
402
|
-
REFERENCES atlas_business_relations(relation_id) ON DELETE CASCADE
|
|
403
|
-
) STRICT;
|
|
404
|
-
|
|
405
|
-
CREATE TABLE atlas_business_relation_evidence_bindings (
|
|
406
|
-
relation_id INTEGER NOT NULL,
|
|
407
|
-
position INTEGER NOT NULL,
|
|
408
|
-
repository_id TEXT NOT NULL,
|
|
409
|
-
snapshot_id TEXT NOT NULL,
|
|
410
|
-
resolved_structural_reference TEXT,
|
|
411
|
-
resolved_qualified_symbol TEXT,
|
|
412
|
-
resolved_structural_kind TEXT,
|
|
413
|
-
backend_version TEXT,
|
|
414
|
-
backend_locator TEXT,
|
|
415
|
-
binding_status TEXT NOT NULL CHECK (
|
|
416
|
-
binding_status IN ('bound', 'missing', 'ambiguous', 'unresolved')
|
|
417
|
-
),
|
|
418
|
-
PRIMARY KEY (relation_id, position, snapshot_id),
|
|
419
|
-
FOREIGN KEY (relation_id, position)
|
|
420
|
-
REFERENCES atlas_business_relation_evidence(relation_id, position) ON DELETE CASCADE,
|
|
421
|
-
FOREIGN KEY (repository_id, snapshot_id)
|
|
422
|
-
REFERENCES atlas_repository_snapshots(repository_id, snapshot_id) ON DELETE CASCADE
|
|
423
|
-
) STRICT;
|
|
424
|
-
|
|
425
|
-
CREATE TABLE atlas_structural_relation_target_bindings (
|
|
426
|
-
relation_id INTEGER NOT NULL,
|
|
427
|
-
repository_id TEXT NOT NULL,
|
|
428
|
-
snapshot_id TEXT NOT NULL,
|
|
429
|
-
resolved_structural_reference TEXT,
|
|
430
|
-
resolved_file TEXT,
|
|
431
|
-
resolved_qualified_symbol TEXT,
|
|
432
|
-
resolved_structural_kind TEXT,
|
|
433
|
-
resolved_start_line INTEGER,
|
|
434
|
-
resolved_start_column INTEGER,
|
|
435
|
-
resolved_end_line INTEGER,
|
|
436
|
-
resolved_end_column INTEGER,
|
|
437
|
-
backend_version TEXT,
|
|
438
|
-
backend_locator TEXT,
|
|
439
|
-
binding_status TEXT NOT NULL CHECK (
|
|
440
|
-
binding_status IN ('bound', 'missing', 'ambiguous', 'unresolved')
|
|
441
|
-
),
|
|
442
|
-
PRIMARY KEY (relation_id, snapshot_id),
|
|
443
|
-
FOREIGN KEY (relation_id)
|
|
444
|
-
REFERENCES atlas_business_relations(relation_id) ON DELETE CASCADE,
|
|
445
|
-
FOREIGN KEY (repository_id, snapshot_id)
|
|
446
|
-
REFERENCES atlas_repository_snapshots(repository_id, snapshot_id) ON DELETE CASCADE
|
|
447
|
-
) STRICT;
|
|
448
|
-
|
|
449
|
-
CREATE TABLE atlas_business_node_validity (
|
|
450
|
-
node_id INTEGER NOT NULL,
|
|
451
|
-
repository_id TEXT NOT NULL,
|
|
452
|
-
snapshot_id TEXT NOT NULL,
|
|
453
|
-
validity TEXT NOT NULL CHECK (validity IN ('valid', 'stale')),
|
|
454
|
-
PRIMARY KEY (node_id, snapshot_id),
|
|
455
|
-
FOREIGN KEY (node_id) REFERENCES atlas_business_nodes(node_id) ON DELETE CASCADE,
|
|
456
|
-
FOREIGN KEY (repository_id, snapshot_id)
|
|
457
|
-
REFERENCES atlas_repository_snapshots(repository_id, snapshot_id) ON DELETE CASCADE
|
|
458
|
-
) STRICT;
|
|
459
|
-
|
|
460
|
-
CREATE TABLE atlas_business_relation_validity (
|
|
461
|
-
relation_id INTEGER NOT NULL,
|
|
462
|
-
repository_id TEXT NOT NULL,
|
|
463
|
-
snapshot_id TEXT NOT NULL,
|
|
464
|
-
validity TEXT NOT NULL CHECK (validity IN ('valid', 'stale')),
|
|
465
|
-
PRIMARY KEY (relation_id, snapshot_id),
|
|
466
|
-
FOREIGN KEY (relation_id) REFERENCES atlas_business_relations(relation_id) ON DELETE CASCADE,
|
|
467
|
-
FOREIGN KEY (repository_id, snapshot_id)
|
|
468
|
-
REFERENCES atlas_repository_snapshots(repository_id, snapshot_id) ON DELETE CASCADE
|
|
469
|
-
) STRICT;
|
|
470
|
-
|
|
471
|
-
CREATE TABLE atlas_graph_search (
|
|
472
|
-
repository_id TEXT NOT NULL,
|
|
473
|
-
node_key TEXT NOT NULL,
|
|
474
|
-
label TEXT NOT NULL,
|
|
475
|
-
aliases TEXT NOT NULL,
|
|
476
|
-
summary TEXT NOT NULL,
|
|
477
|
-
symbols TEXT NOT NULL,
|
|
478
|
-
paths TEXT NOT NULL,
|
|
479
|
-
PRIMARY KEY (repository_id, node_key),
|
|
480
|
-
FOREIGN KEY (repository_id, node_key)
|
|
481
|
-
REFERENCES atlas_business_nodes(repository_id, node_key) ON DELETE CASCADE
|
|
482
|
-
) STRICT;
|
|
483
|
-
`;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { GitRepository } from "../repository/types.js";
|
|
2
|
-
import type { RepositorySnapshot } from "../snapshots/types.js";
|
|
3
|
-
export interface StoredRepositorySnapshot {
|
|
4
|
-
readonly snapshot: RepositorySnapshot;
|
|
5
|
-
readonly createdAt: string;
|
|
6
|
-
}
|
|
7
|
-
export declare class SnapshotStore implements Disposable {
|
|
8
|
-
#private;
|
|
9
|
-
readonly databasePath: string;
|
|
10
|
-
constructor(repository: GitRepository);
|
|
11
|
-
save(snapshot: RepositorySnapshot): void;
|
|
12
|
-
find(snapshotId: string): RepositorySnapshot | undefined;
|
|
13
|
-
findStored(snapshotId: string): StoredRepositorySnapshot | undefined;
|
|
14
|
-
latest(): RepositorySnapshot | undefined;
|
|
15
|
-
latestStored(): StoredRepositorySnapshot | undefined;
|
|
16
|
-
close(): void;
|
|
17
|
-
[Symbol.dispose](): void;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=snapshot-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot-store.d.ts","sourceRoot":"","sources":["../../src/storage/snapshot-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,qBAAa,aAAc,YAAW,UAAU;;IAC9C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;gBAKlB,UAAU,EAAE,aAAa;IAOrC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAyBxC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIxD,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAepE,MAAM,IAAI,kBAAkB,GAAG,SAAS;IAIxC,YAAY,IAAI,wBAAwB,GAAG,SAAS;IAkBpD,KAAK,IAAI,IAAI;IAIb,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { AtlasDatabase } from "./atlas-database.js";
|
|
2
|
-
export class SnapshotStore {
|
|
3
|
-
databasePath;
|
|
4
|
-
#atlasDatabase;
|
|
5
|
-
#repositoryId;
|
|
6
|
-
#gitDirectory;
|
|
7
|
-
constructor(repository) {
|
|
8
|
-
this.#repositoryId = repository.repositoryId;
|
|
9
|
-
this.#gitDirectory = repository.gitDirectory;
|
|
10
|
-
this.#atlasDatabase = new AtlasDatabase(repository);
|
|
11
|
-
this.databasePath = this.#atlasDatabase.databasePath;
|
|
12
|
-
}
|
|
13
|
-
save(snapshot) {
|
|
14
|
-
if (snapshot.repositoryId !== this.#repositoryId) {
|
|
15
|
-
throw new Error("Cannot store a snapshot from another repository");
|
|
16
|
-
}
|
|
17
|
-
const timestamp = new Date().toISOString();
|
|
18
|
-
const database = this.#atlasDatabase.connection;
|
|
19
|
-
database.exec("BEGIN IMMEDIATE");
|
|
20
|
-
try {
|
|
21
|
-
database.prepare(`
|
|
22
|
-
INSERT INTO atlas_repository_snapshots (
|
|
23
|
-
repository_id,
|
|
24
|
-
snapshot_id,
|
|
25
|
-
payload,
|
|
26
|
-
created_at
|
|
27
|
-
) VALUES (?, ?, ?, ?)
|
|
28
|
-
ON CONFLICT (repository_id, snapshot_id) DO NOTHING
|
|
29
|
-
`).run(this.#repositoryId, snapshot.snapshotId, JSON.stringify(snapshot), timestamp);
|
|
30
|
-
database.exec("COMMIT");
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
database.exec("ROLLBACK");
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
find(snapshotId) {
|
|
38
|
-
return this.findStored(snapshotId)?.snapshot;
|
|
39
|
-
}
|
|
40
|
-
findStored(snapshotId) {
|
|
41
|
-
const row = this.#atlasDatabase.connection.prepare(`
|
|
42
|
-
SELECT payload, created_at
|
|
43
|
-
FROM atlas_repository_snapshots
|
|
44
|
-
WHERE repository_id = ? AND snapshot_id = ?
|
|
45
|
-
`).get(this.#repositoryId, snapshotId);
|
|
46
|
-
return row === undefined ? undefined : {
|
|
47
|
-
snapshot: JSON.parse(row.payload),
|
|
48
|
-
createdAt: row.created_at,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
latest() {
|
|
52
|
-
return this.latestStored()?.snapshot;
|
|
53
|
-
}
|
|
54
|
-
latestStored() {
|
|
55
|
-
const row = this.#atlasDatabase.connection.prepare(`
|
|
56
|
-
SELECT snapshot.payload, snapshot.created_at
|
|
57
|
-
FROM atlas_worktree_states AS worktree
|
|
58
|
-
JOIN atlas_repository_snapshots AS snapshot
|
|
59
|
-
ON snapshot.repository_id = worktree.repository_id
|
|
60
|
-
AND snapshot.snapshot_id = worktree.current_snapshot_id
|
|
61
|
-
WHERE worktree.repository_id = ? AND worktree.git_directory = ?
|
|
62
|
-
`).get(this.#repositoryId, this.#gitDirectory);
|
|
63
|
-
return row === undefined ? undefined : {
|
|
64
|
-
snapshot: JSON.parse(row.payload),
|
|
65
|
-
createdAt: row.created_at,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
close() {
|
|
69
|
-
this.#atlasDatabase.close();
|
|
70
|
-
}
|
|
71
|
-
[Symbol.dispose]() {
|
|
72
|
-
this.close();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { GitRepository } from "../repository/types.js";
|
|
2
|
-
import type { IndexedSourceFile, StructuralEvidenceResolver, WorldWriteCoordinator } from "../world/types.js";
|
|
3
|
-
import { type StructuralBuildResult, type StructuralCallRelation, type StructuralFileDependency, type StructuralIndexBackend, type StructuralIndexState, type StructuralNode, type StructuralProjectGraphQuery, type StructuralReference, type StructuralSearchQuery, type StructuralSearchResult, type StructuralTraversalQuery, type StructuralTraversalResult, type StructuralUnknownBoundary } from "./types.js";
|
|
4
|
-
export interface StructuralWorldPublicationHooks {
|
|
5
|
-
onBuilding(): void | Promise<void>;
|
|
6
|
-
prepareProjection(): void | Promise<void>;
|
|
7
|
-
validate(result: StructuralBuildResult, indexedSources: readonly IndexedSourceFile[]): void | Promise<void>;
|
|
8
|
-
publish(result: StructuralBuildResult, resolver: StructuralEvidenceResolver): void | Promise<void>;
|
|
9
|
-
fail(error: unknown): void;
|
|
10
|
-
}
|
|
11
|
-
export declare class CodeGraphStructuralBackend implements StructuralIndexBackend, WorldWriteCoordinator {
|
|
12
|
-
#private;
|
|
13
|
-
constructor(repository: GitRepository);
|
|
14
|
-
prepareStorageForBootstrap(): Promise<void>;
|
|
15
|
-
inspect(): Promise<StructuralIndexState>;
|
|
16
|
-
build(): Promise<StructuralBuildResult>;
|
|
17
|
-
sync(): Promise<StructuralBuildResult>;
|
|
18
|
-
listUnknownBoundaries(): Promise<readonly StructuralUnknownBoundary[]>;
|
|
19
|
-
publishWorld(requestedMode: "full" | "incremental", hooks: StructuralWorldPublicationHooks): Promise<StructuralBuildResult>;
|
|
20
|
-
withWorldWriteLock<T>(operation: (state: StructuralIndexState, resolver: StructuralEvidenceResolver) => Promise<T>): Promise<T>;
|
|
21
|
-
listRoots(): Promise<readonly StructuralNode[]>;
|
|
22
|
-
readProjectGraph(query: StructuralProjectGraphQuery): Promise<StructuralTraversalResult>;
|
|
23
|
-
search(query: StructuralSearchQuery): Promise<readonly StructuralSearchResult[]>;
|
|
24
|
-
getNode(reference: StructuralReference): Promise<StructuralNode | undefined>;
|
|
25
|
-
traverse(query: StructuralTraversalQuery): Promise<StructuralTraversalResult>;
|
|
26
|
-
getCallers(reference: StructuralReference): Promise<readonly StructuralCallRelation[]>;
|
|
27
|
-
getCallees(reference: StructuralReference): Promise<readonly StructuralCallRelation[]>;
|
|
28
|
-
getFileDependencies(path: string): Promise<readonly StructuralFileDependency[]>;
|
|
29
|
-
private runBuild;
|
|
30
|
-
private runLockedBuild;
|
|
31
|
-
private persistWorldFailure;
|
|
32
|
-
private synchronizeGraph;
|
|
33
|
-
private rebuildGraph;
|
|
34
|
-
private restorePublishedGraph;
|
|
35
|
-
private createFullBuildResult;
|
|
36
|
-
private createSyncResult;
|
|
37
|
-
private createLockUnavailableSyncResult;
|
|
38
|
-
private createLockUnavailableBuildResult;
|
|
39
|
-
private failedBuildResult;
|
|
40
|
-
private withCurrentGraph;
|
|
41
|
-
private readState;
|
|
42
|
-
private stateFromGraph;
|
|
43
|
-
private missingState;
|
|
44
|
-
private incompleteState;
|
|
45
|
-
private prepareAtlasDirectory;
|
|
46
|
-
private inspectWithSdk;
|
|
47
|
-
private withPublishedGraph;
|
|
48
|
-
private acquireAtlasWriteLock;
|
|
49
|
-
private createCodeGraphWriteLock;
|
|
50
|
-
private atlasDirectoryExists;
|
|
51
|
-
private prepareAtlasIgnoreFile;
|
|
52
|
-
private verifyAtlasIgnoreIsUntracked;
|
|
53
|
-
private verifyExistingAtlasIgnoreFile;
|
|
54
|
-
private verifyAtlasDirectory;
|
|
55
|
-
private verifyDatabasePath;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=codegraph-backend.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codegraph-backend.d.ts","sourceRoot":"","sources":["../../src/structural-backend/codegraph-backend.ts"],"names":[],"mappings":"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"}
|