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