@descryy/core 0.1.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/LICENSE +21 -0
- package/dist/capabilities/index.d.ts +3 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +2 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/preconditions.d.ts +99 -0
- package/dist/capabilities/preconditions.d.ts.map +1 -0
- package/dist/capabilities/preconditions.js +94 -0
- package/dist/capabilities/preconditions.js.map +1 -0
- package/dist/contracts/engine.d.ts +90 -0
- package/dist/contracts/engine.d.ts.map +1 -0
- package/dist/contracts/engine.js +291 -0
- package/dist/contracts/engine.js.map +1 -0
- package/dist/contracts/index.d.ts +9 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +5 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/orphans.d.ts +96 -0
- package/dist/contracts/orphans.d.ts.map +1 -0
- package/dist/contracts/orphans.js +241 -0
- package/dist/contracts/orphans.js.map +1 -0
- package/dist/contracts/paths.d.ts +132 -0
- package/dist/contracts/paths.d.ts.map +1 -0
- package/dist/contracts/paths.js +245 -0
- package/dist/contracts/paths.js.map +1 -0
- package/dist/contracts/shapes.d.ts +99 -0
- package/dist/contracts/shapes.d.ts.map +1 -0
- package/dist/contracts/shapes.js +196 -0
- package/dist/contracts/shapes.js.map +1 -0
- package/dist/governance/budget.d.ts +89 -0
- package/dist/governance/budget.d.ts.map +1 -0
- package/dist/governance/budget.js +101 -0
- package/dist/governance/budget.js.map +1 -0
- package/dist/governance/candidate-boundary.d.ts +49 -0
- package/dist/governance/candidate-boundary.d.ts.map +1 -0
- package/dist/governance/candidate-boundary.js +51 -0
- package/dist/governance/candidate-boundary.js.map +1 -0
- package/dist/governance/escalation.d.ts +63 -0
- package/dist/governance/escalation.d.ts.map +1 -0
- package/dist/governance/escalation.js +72 -0
- package/dist/governance/escalation.js.map +1 -0
- package/dist/governance/fact-boundary.d.ts +77 -0
- package/dist/governance/fact-boundary.d.ts.map +1 -0
- package/dist/governance/fact-boundary.js +91 -0
- package/dist/governance/fact-boundary.js.map +1 -0
- package/dist/governance/finding-funnel.d.ts +109 -0
- package/dist/governance/finding-funnel.d.ts.map +1 -0
- package/dist/governance/finding-funnel.js +137 -0
- package/dist/governance/finding-funnel.js.map +1 -0
- package/dist/governance/index.d.ts +11 -0
- package/dist/governance/index.d.ts.map +1 -0
- package/dist/governance/index.js +6 -0
- package/dist/governance/index.js.map +1 -0
- package/dist/graph/build.d.ts +127 -0
- package/dist/graph/build.d.ts.map +1 -0
- package/dist/graph/build.js +0 -0
- package/dist/graph/build.js.map +1 -0
- package/dist/graph/cross-language.d.ts +70 -0
- package/dist/graph/cross-language.d.ts.map +1 -0
- package/dist/graph/cross-language.js +104 -0
- package/dist/graph/cross-language.js.map +1 -0
- package/dist/graph/index.d.ts +11 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +6 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/merge.d.ts +95 -0
- package/dist/graph/merge.d.ts.map +1 -0
- package/dist/graph/merge.js +131 -0
- package/dist/graph/merge.js.map +1 -0
- package/dist/graph/persist.d.ts +42 -0
- package/dist/graph/persist.d.ts.map +1 -0
- package/dist/graph/persist.js +52 -0
- package/dist/graph/persist.js.map +1 -0
- package/dist/graph/runtime-confirmation.d.ts +169 -0
- package/dist/graph/runtime-confirmation.d.ts.map +1 -0
- package/dist/graph/runtime-confirmation.js +318 -0
- package/dist/graph/runtime-confirmation.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger/index.d.ts +5 -0
- package/dist/ledger/index.d.ts.map +1 -0
- package/dist/ledger/index.js +3 -0
- package/dist/ledger/index.js.map +1 -0
- package/dist/ledger/mint.d.ts +81 -0
- package/dist/ledger/mint.d.ts.map +1 -0
- package/dist/ledger/mint.js +138 -0
- package/dist/ledger/mint.js.map +1 -0
- package/dist/ledger/resolve.d.ts +124 -0
- package/dist/ledger/resolve.d.ts.map +1 -0
- package/dist/ledger/resolve.js +290 -0
- package/dist/ledger/resolve.js.map +1 -0
- package/dist/multipr/fingerprint.d.ts +56 -0
- package/dist/multipr/fingerprint.d.ts.map +1 -0
- package/dist/multipr/fingerprint.js +169 -0
- package/dist/multipr/fingerprint.js.map +1 -0
- package/dist/multipr/hidden-dependency.d.ts +120 -0
- package/dist/multipr/hidden-dependency.d.ts.map +1 -0
- package/dist/multipr/hidden-dependency.js +185 -0
- package/dist/multipr/hidden-dependency.js.map +1 -0
- package/dist/multipr/index.d.ts +14 -0
- package/dist/multipr/index.d.ts.map +1 -0
- package/dist/multipr/index.js +8 -0
- package/dist/multipr/index.js.map +1 -0
- package/dist/multipr/mechanical.d.ts +239 -0
- package/dist/multipr/mechanical.d.ts.map +1 -0
- package/dist/multipr/mechanical.js +333 -0
- package/dist/multipr/mechanical.js.map +1 -0
- package/dist/multipr/migration-heads.d.ts +160 -0
- package/dist/multipr/migration-heads.d.ts.map +1 -0
- package/dist/multipr/migration-heads.js +212 -0
- package/dist/multipr/migration-heads.js.map +1 -0
- package/dist/multipr/overlap.d.ts +186 -0
- package/dist/multipr/overlap.d.ts.map +1 -0
- package/dist/multipr/overlap.js +254 -0
- package/dist/multipr/overlap.js.map +1 -0
- package/dist/multipr/scope-store.d.ts +105 -0
- package/dist/multipr/scope-store.d.ts.map +1 -0
- package/dist/multipr/scope-store.js +182 -0
- package/dist/multipr/scope-store.js.map +1 -0
- package/dist/multipr/superseded.d.ts +133 -0
- package/dist/multipr/superseded.d.ts.map +1 -0
- package/dist/multipr/superseded.js +128 -0
- package/dist/multipr/superseded.js.map +1 -0
- package/dist/query/confirmed-facts.d.ts +56 -0
- package/dist/query/confirmed-facts.d.ts.map +1 -0
- package/dist/query/confirmed-facts.js +64 -0
- package/dist/query/confirmed-facts.js.map +1 -0
- package/dist/query/declared-value-closure.d.ts +126 -0
- package/dist/query/declared-value-closure.d.ts.map +1 -0
- package/dist/query/declared-value-closure.js +156 -0
- package/dist/query/declared-value-closure.js.map +1 -0
- package/dist/query/index.d.ts +28 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +15 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/memory.d.ts +20 -0
- package/dist/query/memory.d.ts.map +1 -0
- package/dist/query/memory.js +55 -0
- package/dist/query/memory.js.map +1 -0
- package/dist/query/provider.d.ts +127 -0
- package/dist/query/provider.d.ts.map +1 -0
- package/dist/query/provider.js +54 -0
- package/dist/query/provider.js.map +1 -0
- package/dist/query/queries.d.ts +119 -0
- package/dist/query/queries.d.ts.map +1 -0
- package/dist/query/queries.js +267 -0
- package/dist/query/queries.js.map +1 -0
- package/dist/query/refusal-fetch.d.ts +114 -0
- package/dist/query/refusal-fetch.d.ts.map +1 -0
- package/dist/query/refusal-fetch.js +200 -0
- package/dist/query/refusal-fetch.js.map +1 -0
- package/dist/query/refusal-questions.d.ts +123 -0
- package/dist/query/refusal-questions.d.ts.map +1 -0
- package/dist/query/refusal-questions.js +122 -0
- package/dist/query/refusal-questions.js.map +1 -0
- package/dist/query/root-cause-score.d.ts +218 -0
- package/dist/query/root-cause-score.d.ts.map +1 -0
- package/dist/query/root-cause-score.js +251 -0
- package/dist/query/root-cause-score.js.map +1 -0
- package/dist/query/row-closure-picture.d.ts +108 -0
- package/dist/query/row-closure-picture.d.ts.map +1 -0
- package/dist/query/row-closure-picture.js +131 -0
- package/dist/query/row-closure-picture.js.map +1 -0
- package/dist/query/similar-incidents.d.ts +76 -0
- package/dist/query/similar-incidents.d.ts.map +1 -0
- package/dist/query/similar-incidents.js +169 -0
- package/dist/query/similar-incidents.js.map +1 -0
- package/dist/query/sqlite.d.ts +13 -0
- package/dist/query/sqlite.d.ts.map +1 -0
- package/dist/query/sqlite.js +54 -0
- package/dist/query/sqlite.js.map +1 -0
- package/dist/query/traverse.d.ts +110 -0
- package/dist/query/traverse.d.ts.map +1 -0
- package/dist/query/traverse.js +0 -0
- package/dist/query/traverse.js.map +1 -0
- package/dist/query/unresolved.d.ts +195 -0
- package/dist/query/unresolved.d.ts.map +1 -0
- package/dist/query/unresolved.js +225 -0
- package/dist/query/unresolved.js.map +1 -0
- package/dist/query/verification-status.d.ts +134 -0
- package/dist/query/verification-status.d.ts.map +1 -0
- package/dist/query/verification-status.js +163 -0
- package/dist/query/verification-status.js.map +1 -0
- package/dist/recording/index.d.ts +26 -0
- package/dist/recording/index.d.ts.map +1 -0
- package/dist/recording/index.js +30 -0
- package/dist/recording/index.js.map +1 -0
- package/dist/recording/migrate.d.ts +22 -0
- package/dist/recording/migrate.d.ts.map +1 -0
- package/dist/recording/migrate.js +51 -0
- package/dist/recording/migrate.js.map +1 -0
- package/dist/recording/reader.d.ts +27 -0
- package/dist/recording/reader.d.ts.map +1 -0
- package/dist/recording/reader.js +55 -0
- package/dist/recording/reader.js.map +1 -0
- package/dist/recording/redact.d.ts +63 -0
- package/dist/recording/redact.d.ts.map +1 -0
- package/dist/recording/redact.js +98 -0
- package/dist/recording/redact.js.map +1 -0
- package/dist/recording/schema.d.ts +41 -0
- package/dist/recording/schema.d.ts.map +1 -0
- package/dist/recording/schema.js +104 -0
- package/dist/recording/schema.js.map +1 -0
- package/dist/recording/writer.d.ts +120 -0
- package/dist/recording/writer.d.ts.map +1 -0
- package/dist/recording/writer.js +81 -0
- package/dist/recording/writer.js.map +1 -0
- package/dist/scoping/fanout.d.ts +86 -0
- package/dist/scoping/fanout.d.ts.map +1 -0
- package/dist/scoping/fanout.js +95 -0
- package/dist/scoping/fanout.js.map +1 -0
- package/dist/scoping/index.d.ts +10 -0
- package/dist/scoping/index.d.ts.map +1 -0
- package/dist/scoping/index.js +6 -0
- package/dist/scoping/index.js.map +1 -0
- package/dist/scoping/score.d.ts +83 -0
- package/dist/scoping/score.d.ts.map +1 -0
- package/dist/scoping/score.js +125 -0
- package/dist/scoping/score.js.map +1 -0
- package/dist/scoping/tiers.d.ts +32 -0
- package/dist/scoping/tiers.d.ts.map +1 -0
- package/dist/scoping/tiers.js +35 -0
- package/dist/scoping/tiers.js.map +1 -0
- package/dist/scoping/traverse.d.ts +60 -0
- package/dist/scoping/traverse.d.ts.map +1 -0
- package/dist/scoping/traverse.js +172 -0
- package/dist/scoping/traverse.js.map +1 -0
- package/dist/scoping/weights.d.ts +97 -0
- package/dist/scoping/weights.d.ts.map +1 -0
- package/dist/scoping/weights.js +167 -0
- package/dist/scoping/weights.js.map +1 -0
- package/dist/sources/git/diff.d.ts +53 -0
- package/dist/sources/git/diff.d.ts.map +1 -0
- package/dist/sources/git/diff.js +140 -0
- package/dist/sources/git/diff.js.map +1 -0
- package/dist/sources/git/env.d.ts +2 -0
- package/dist/sources/git/env.d.ts.map +1 -0
- package/dist/sources/git/env.js +21 -0
- package/dist/sources/git/env.js.map +1 -0
- package/dist/sources/git/history.d.ts +140 -0
- package/dist/sources/git/history.d.ts.map +1 -0
- package/dist/sources/git/history.js +314 -0
- package/dist/sources/git/history.js.map +1 -0
- package/dist/sources/git/index.d.ts +7 -0
- package/dist/sources/git/index.d.ts.map +1 -0
- package/dist/sources/git/index.js +4 -0
- package/dist/sources/git/index.js.map +1 -0
- package/dist/sources/git/source.d.ts +95 -0
- package/dist/sources/git/source.d.ts.map +1 -0
- package/dist/sources/git/source.js +0 -0
- package/dist/sources/git/source.js.map +1 -0
- package/dist/sources/migrations/dialects.d.ts +59 -0
- package/dist/sources/migrations/dialects.d.ts.map +1 -0
- package/dist/sources/migrations/dialects.js +84 -0
- package/dist/sources/migrations/dialects.js.map +1 -0
- package/dist/sources/migrations/index.d.ts +3 -0
- package/dist/sources/migrations/index.d.ts.map +1 -0
- package/dist/sources/migrations/index.js +2 -0
- package/dist/sources/migrations/index.js.map +1 -0
- package/dist/sources/migrations/read.d.ts +113 -0
- package/dist/sources/migrations/read.d.ts.map +1 -0
- package/dist/sources/migrations/read.js +270 -0
- package/dist/sources/migrations/read.js.map +1 -0
- package/dist/sources/workspace/index.d.ts +3 -0
- package/dist/sources/workspace/index.d.ts.map +1 -0
- package/dist/sources/workspace/index.js +2 -0
- package/dist/sources/workspace/index.js.map +1 -0
- package/dist/sources/workspace/workspace.d.ts +64 -0
- package/dist/sources/workspace/workspace.d.ts.map +1 -0
- package/dist/sources/workspace/workspace.js +294 -0
- package/dist/sources/workspace/workspace.js.map +1 -0
- package/dist/store/driver/driver.d.ts +82 -0
- package/dist/store/driver/driver.d.ts.map +1 -0
- package/dist/store/driver/driver.js +31 -0
- package/dist/store/driver/driver.js.map +1 -0
- package/dist/store/driver/node-sqlite.d.ts +28 -0
- package/dist/store/driver/node-sqlite.d.ts.map +1 -0
- package/dist/store/driver/node-sqlite.js +188 -0
- package/dist/store/driver/node-sqlite.js.map +1 -0
- package/dist/store/index.d.ts +33 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +46 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/migrate.d.ts +68 -0
- package/dist/store/migrate.d.ts.map +1 -0
- package/dist/store/migrate.js +140 -0
- package/dist/store/migrate.js.map +1 -0
- package/dist/store/reader.d.ts +127 -0
- package/dist/store/reader.d.ts.map +1 -0
- package/dist/store/reader.js +269 -0
- package/dist/store/reader.js.map +1 -0
- package/dist/store/schema.d.ts +87 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/schema.js +322 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/writer.d.ts +116 -0
- package/dist/store/writer.d.ts.map +1 -0
- package/dist/store/writer.js +279 -0
- package/dist/store/writer.js.map +1 -0
- package/dist/tiers/certify.d.ts +375 -0
- package/dist/tiers/certify.d.ts.map +1 -0
- package/dist/tiers/certify.js +434 -0
- package/dist/tiers/certify.js.map +1 -0
- package/dist/tiers/index.d.ts +5 -0
- package/dist/tiers/index.d.ts.map +1 -0
- package/dist/tiers/index.js +3 -0
- package/dist/tiers/index.js.map +1 -0
- package/dist/tiers/ladder.d.ts +73 -0
- package/dist/tiers/ladder.d.ts.map +1 -0
- package/dist/tiers/ladder.js +197 -0
- package/dist/tiers/ladder.js.map +1 -0
- package/dist/validation/config-graph.d.ts +104 -0
- package/dist/validation/config-graph.d.ts.map +1 -0
- package/dist/validation/config-graph.js +205 -0
- package/dist/validation/config-graph.js.map +1 -0
- package/dist/validation/env.d.ts +243 -0
- package/dist/validation/env.d.ts.map +1 -0
- package/dist/validation/env.js +447 -0
- package/dist/validation/env.js.map +1 -0
- package/dist/validation/index.d.ts +16 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +9 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/join-substitution.d.ts +186 -0
- package/dist/validation/join-substitution.d.ts.map +1 -0
- package/dist/validation/join-substitution.js +191 -0
- package/dist/validation/join-substitution.js.map +1 -0
- package/dist/validation/migrations.d.ts +133 -0
- package/dist/validation/migrations.d.ts.map +1 -0
- package/dist/validation/migrations.js +315 -0
- package/dist/validation/migrations.js.map +1 -0
- package/dist/validation/nodes.d.ts +32 -0
- package/dist/validation/nodes.d.ts.map +1 -0
- package/dist/validation/nodes.js +45 -0
- package/dist/validation/nodes.js.map +1 -0
- package/dist/validation/rollback.d.ts +124 -0
- package/dist/validation/rollback.d.ts.map +1 -0
- package/dist/validation/rollback.js +302 -0
- package/dist/validation/rollback.js.map +1 -0
- package/dist/validation/route-drift.d.ts +108 -0
- package/dist/validation/route-drift.d.ts.map +1 -0
- package/dist/validation/route-drift.js +103 -0
- package/dist/validation/route-drift.js.map +1 -0
- package/dist/validation/sources.d.ts +153 -0
- package/dist/validation/sources.d.ts.map +1 -0
- package/dist/validation/sources.js +409 -0
- package/dist/validation/sources.js.map +1 -0
- package/dist/worker/index.d.ts +5 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +3 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/pool.d.ts +73 -0
- package/dist/worker/pool.d.ts.map +1 -0
- package/dist/worker/pool.js +203 -0
- package/dist/worker/pool.js.map +1 -0
- package/dist/worker/protocol.d.ts +91 -0
- package/dist/worker/protocol.d.ts.map +1 -0
- package/dist/worker/protocol.js +19 -0
- package/dist/worker/protocol.js.map +1 -0
- package/dist/worker/traversal.worker.d.ts +25 -0
- package/dist/worker/traversal.worker.d.ts.map +1 -0
- package/dist/worker/traversal.worker.js +124 -0
- package/dist/worker/traversal.worker.js.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads over the stored graph.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately thin. This is not the query layer (plan Step 9) — it is the row
|
|
5
|
+
* access the query layer will be written against, and nothing here knows about
|
|
6
|
+
* scoring, budgets or traversal. Keeping the split means the query layer can be
|
|
7
|
+
* tested against an in-memory adjacency provider with no database at all, which
|
|
8
|
+
* is what stops 95% of the engine's tests needing SQLite and a worker.
|
|
9
|
+
*
|
|
10
|
+
* No row from `driver/` reaches a caller unconverted: SQLite has no booleans, no
|
|
11
|
+
* null-vs-undefined distinction and no nested values, so every read here maps
|
|
12
|
+
* columns back into IR shapes rather than handing out raw rows.
|
|
13
|
+
*/
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
import { canonicalJson, isEdgeType, isNodeType, } from "@descryy/ir";
|
|
16
|
+
import { DERIVED_TABLES, EARNED_TABLES } from "./schema.js";
|
|
17
|
+
const NODE_COLUMNS = "id, type, name, file_path, start_line, end_line, language, produced_by, resolution, attrs";
|
|
18
|
+
const EDGE_COLUMNS = "id, source, target, type, resolution, confidence, produced_by, observed_by_run, attrs";
|
|
19
|
+
const UNRESOLVED_REF_COLUMNS = "from_node_id, edge_type, raw_target, file_path, line, produced_by, reason, attrs";
|
|
20
|
+
function toNode(row) {
|
|
21
|
+
if (!isNodeType(row.type)) {
|
|
22
|
+
// Only reachable if something wrote around the Normaliser, which is exactly
|
|
23
|
+
// the case worth failing loudly on rather than coercing.
|
|
24
|
+
throw new Error(`stored node ${row.id} has an unknown type: ${row.type}`);
|
|
25
|
+
}
|
|
26
|
+
const type = row.type;
|
|
27
|
+
return {
|
|
28
|
+
id: row.id,
|
|
29
|
+
type,
|
|
30
|
+
name: row.name,
|
|
31
|
+
file: row.file_path,
|
|
32
|
+
range: row.start_line === null || row.end_line === null
|
|
33
|
+
? null
|
|
34
|
+
: { startLine: row.start_line, endLine: row.end_line },
|
|
35
|
+
language: row.language,
|
|
36
|
+
producedBy: row.produced_by,
|
|
37
|
+
resolution: row.resolution,
|
|
38
|
+
attrs: JSON.parse(row.attrs),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function toEdge(row) {
|
|
42
|
+
if (!isEdgeType(row.type)) {
|
|
43
|
+
throw new Error(`stored edge ${row.id} has an unknown type: ${row.type}`);
|
|
44
|
+
}
|
|
45
|
+
const type = row.type;
|
|
46
|
+
return {
|
|
47
|
+
from: row.source,
|
|
48
|
+
to: row.target,
|
|
49
|
+
type,
|
|
50
|
+
resolution: row.resolution,
|
|
51
|
+
confidence: row.confidence,
|
|
52
|
+
producedBy: row.produced_by,
|
|
53
|
+
...(row.observed_by_run === null ? {} : { observedByRun: row.observed_by_run }),
|
|
54
|
+
...(row.attrs === null ? {} : { attrs: JSON.parse(row.attrs) }),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function toUnresolvedRef(row) {
|
|
58
|
+
if (!isEdgeType(row.edge_type)) {
|
|
59
|
+
throw new Error(`stored unresolved ref on ${row.from_node_id} has an unknown edge type: ${row.edge_type}`);
|
|
60
|
+
}
|
|
61
|
+
const edgeType = row.edge_type;
|
|
62
|
+
return {
|
|
63
|
+
fromNodeId: row.from_node_id,
|
|
64
|
+
edgeType,
|
|
65
|
+
rawTarget: row.raw_target,
|
|
66
|
+
file: row.file_path,
|
|
67
|
+
line: row.line,
|
|
68
|
+
producedBy: row.produced_by,
|
|
69
|
+
reason: row.reason,
|
|
70
|
+
...(row.attrs === null ? {} : { attrs: JSON.parse(row.attrs) }),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export function getNode(driver, id) {
|
|
74
|
+
const row = driver.prepare(`SELECT ${NODE_COLUMNS} FROM nodes WHERE id = ?`).get(id);
|
|
75
|
+
return row === undefined ? undefined : toNode(row);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Every node declared in any of `paths` — the diff-to-seeds step.
|
|
79
|
+
*
|
|
80
|
+
* A diff names files; scoping seeds on nodes. Nothing bridged the two until now,
|
|
81
|
+
* because every measurement so far started from node ids it had just built.
|
|
82
|
+
*
|
|
83
|
+
* **Which files miss is as important as which nodes hit.** A path present in the
|
|
84
|
+
* diff and absent from the graph is not an empty result — it is a file the
|
|
85
|
+
* analysis never read, and reporting its blast radius as "nothing affected"
|
|
86
|
+
* would put an unanalysed file in §20.2's *confirmed clean* category when it
|
|
87
|
+
* belongs in *not analysable*. So the misses come back alongside the hits and
|
|
88
|
+
* the caller cannot take one without the other.
|
|
89
|
+
*
|
|
90
|
+
* Paths are matched exactly. They are repo-relative by the Normaliser's rule, so
|
|
91
|
+
* a caller passing absolute paths gets zero hits and is told so by `missing`
|
|
92
|
+
* rather than by silence.
|
|
93
|
+
*/
|
|
94
|
+
export function nodesInFiles(driver, paths) {
|
|
95
|
+
const wanted = [...new Set(paths)].sort();
|
|
96
|
+
if (wanted.length === 0)
|
|
97
|
+
return { nodes: [], missing: [] };
|
|
98
|
+
const nodes = [];
|
|
99
|
+
const seen = new Set();
|
|
100
|
+
// Chunked because SQLite's default parameter ceiling is 999 and a large PR
|
|
101
|
+
// legitimately exceeds it. Splitting here rather than asking the caller to
|
|
102
|
+
// keeps the limit where it belongs — a property of the driver, not of a diff.
|
|
103
|
+
const CHUNK = 500;
|
|
104
|
+
for (let i = 0; i < wanted.length; i += CHUNK) {
|
|
105
|
+
const chunk = wanted.slice(i, i + CHUNK);
|
|
106
|
+
const rows = driver
|
|
107
|
+
.prepare(`SELECT ${NODE_COLUMNS} FROM nodes WHERE file_path IN (${chunk.map(() => "?").join(", ")})` +
|
|
108
|
+
` ORDER BY id ASC`)
|
|
109
|
+
.all(...chunk);
|
|
110
|
+
for (const row of rows) {
|
|
111
|
+
if (seen.has(row.id))
|
|
112
|
+
continue;
|
|
113
|
+
seen.add(row.id);
|
|
114
|
+
nodes.push(toNode(row));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const hit = new Set(nodes.map((n) => n.file).filter((f) => f !== null));
|
|
118
|
+
return { nodes, missing: wanted.filter((p) => !hit.has(p)) };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Every node of one type, capped, with one row of headroom.
|
|
122
|
+
*
|
|
123
|
+
* `limit + 1` is fetched so the caller can tell "exactly the limit" from "the
|
|
124
|
+
* limit and more" without a second `COUNT(*)`. A set-property question answered
|
|
125
|
+
* over a silently truncated set is a fact computed from a sample, so the
|
|
126
|
+
* distinction has to be available.
|
|
127
|
+
*/
|
|
128
|
+
export function nodesOfType(driver, type, limit) {
|
|
129
|
+
const rows = driver
|
|
130
|
+
.prepare(`SELECT ${NODE_COLUMNS} FROM nodes WHERE type = ? ORDER BY id ASC LIMIT ${Math.max(1, Math.floor(limit)) + 1}`)
|
|
131
|
+
.all(type);
|
|
132
|
+
const truncated = rows.length > limit;
|
|
133
|
+
return { nodes: rows.slice(0, limit).map(toNode), truncated };
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Nodes matching a name and/or a file — the "I know what it's called" lookup.
|
|
137
|
+
*
|
|
138
|
+
* Deliberately returns **every** match rather than a best one. Two functions in
|
|
139
|
+
* a repository can legitimately share a name, and picking one by a heuristic —
|
|
140
|
+
* shortest path, most edges, first row — is how a caller ends up reasoning
|
|
141
|
+
* confidently about the wrong symbol. Ambiguity is the caller's to report, so
|
|
142
|
+
* the reader hands it over intact.
|
|
143
|
+
*
|
|
144
|
+
* `repo` narrows to nodes minted by a run recorded against that repository —
|
|
145
|
+
* a subquery against `adapter_runs`, since `nodes` itself carries no `repo`
|
|
146
|
+
* column (only `run_id`). Added for `descry-runtime`'s graph correlator: a
|
|
147
|
+
* multi-repo session (frontend + backend merged into one store, per DEC-228)
|
|
148
|
+
* makes a same-named symbol in the wrong repository a real candidate for a
|
|
149
|
+
* bare `findNodes({ name })` call, and nothing before this filtered it out.
|
|
150
|
+
* Omitted, this behaves exactly as before — existing callers are unaffected.
|
|
151
|
+
*/
|
|
152
|
+
export function findNodes(driver, criteria) {
|
|
153
|
+
const clauses = [];
|
|
154
|
+
const params = [];
|
|
155
|
+
if (criteria.name !== undefined) {
|
|
156
|
+
clauses.push("name = ?");
|
|
157
|
+
params.push(criteria.name);
|
|
158
|
+
}
|
|
159
|
+
if (criteria.file !== undefined) {
|
|
160
|
+
clauses.push("file_path = ?");
|
|
161
|
+
params.push(criteria.file);
|
|
162
|
+
}
|
|
163
|
+
if (criteria.repo !== undefined) {
|
|
164
|
+
clauses.push("run_id IN (SELECT id FROM adapter_runs WHERE repo = ?)");
|
|
165
|
+
params.push(criteria.repo);
|
|
166
|
+
}
|
|
167
|
+
if (clauses.length === 0)
|
|
168
|
+
return [];
|
|
169
|
+
const limit = Math.max(1, Math.floor(criteria.limit ?? 50));
|
|
170
|
+
return driver
|
|
171
|
+
.prepare(`SELECT ${NODE_COLUMNS} FROM nodes WHERE ${clauses.join(" AND ")}` +
|
|
172
|
+
` ORDER BY resolution DESC, id ASC LIMIT ${limit}`)
|
|
173
|
+
.all(...params)
|
|
174
|
+
.map(toNode);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Edges leaving a node, optionally filtered by type and capped.
|
|
178
|
+
*
|
|
179
|
+
* The cap is not optional politeness. The prior-art graphs on this machine have
|
|
180
|
+
* a max in-degree of 1,036 (`append`) — materialising every neighbour of a hub
|
|
181
|
+
* node during a traversal is how a 200-node budget turns into a 10,000-row read.
|
|
182
|
+
*/
|
|
183
|
+
export function outgoing(driver, id, options = {}) {
|
|
184
|
+
return adjacency(driver, "source", id, options);
|
|
185
|
+
}
|
|
186
|
+
export function incoming(driver, id, options = {}) {
|
|
187
|
+
return adjacency(driver, "target", id, options);
|
|
188
|
+
}
|
|
189
|
+
function adjacency(driver, column, id, options) {
|
|
190
|
+
const types = options.types;
|
|
191
|
+
const typeFilter = types === undefined || types.length === 0
|
|
192
|
+
? ""
|
|
193
|
+
: ` AND type IN (${types.map(() => "?").join(", ")})`;
|
|
194
|
+
// Ranked before truncation, so a cap keeps the most trustworthy neighbours
|
|
195
|
+
// rather than whichever rows the index happened to reach first. `id` breaks
|
|
196
|
+
// ties so the result is stable across runs.
|
|
197
|
+
const sql = `SELECT ${EDGE_COLUMNS} FROM edges WHERE ${column} = ?${typeFilter}` +
|
|
198
|
+
` ORDER BY resolution DESC, confidence DESC, id ASC` +
|
|
199
|
+
(options.limit === undefined ? "" : ` LIMIT ${Math.max(0, Math.floor(options.limit))}`);
|
|
200
|
+
return driver
|
|
201
|
+
.prepare(sql)
|
|
202
|
+
.all(id, ...(types ?? []))
|
|
203
|
+
.map(toEdge);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Refusal-ledger rows, for the question-grouping layer (DEC-243) to consume.
|
|
207
|
+
*
|
|
208
|
+
* `classified` (default `true`) restricts to `attrs IS NOT NULL` — rows with
|
|
209
|
+
* no `attrs` at all can never become a question (DEC-242: an unset
|
|
210
|
+
* `refusalClass` is never askable) and are always the majority of this table
|
|
211
|
+
* early in a producer's rollout — sherpa-frontend alone carries ~13,000. That
|
|
212
|
+
* filter is a real optimisation, not an approximation: it changes which rows
|
|
213
|
+
* are *materialised*, never which rows the grouper would have turned into a
|
|
214
|
+
* question. The unclassified count for disclosure is `counts(driver)
|
|
215
|
+
* .unresolvedRefs` minus this function's own row count, not recomputed here.
|
|
216
|
+
*/
|
|
217
|
+
export function unresolvedRefs(driver, options = {}) {
|
|
218
|
+
const classified = options.classified ?? true;
|
|
219
|
+
const where = classified ? "WHERE attrs IS NOT NULL" : "";
|
|
220
|
+
const limit = options.limit === undefined ? undefined : Math.max(1, Math.floor(options.limit));
|
|
221
|
+
const sql = `SELECT ${UNRESOLVED_REF_COLUMNS} FROM unresolved_refs ${where}` +
|
|
222
|
+
` ORDER BY id ASC` +
|
|
223
|
+
(limit === undefined ? "" : ` LIMIT ${limit + 1}`);
|
|
224
|
+
const rows = driver.prepare(sql).all();
|
|
225
|
+
const truncated = limit !== undefined && rows.length > limit;
|
|
226
|
+
return { refs: (truncated ? rows.slice(0, limit) : rows).map(toUnresolvedRef), truncated };
|
|
227
|
+
}
|
|
228
|
+
export function counts(driver) {
|
|
229
|
+
const one = (sql) => driver.prepare(sql).get()?.n ?? 0;
|
|
230
|
+
return {
|
|
231
|
+
nodes: one("SELECT COUNT(*) AS n FROM nodes"),
|
|
232
|
+
edges: one("SELECT COUNT(*) AS n FROM edges"),
|
|
233
|
+
unresolvedRefs: one("SELECT COUNT(*) AS n FROM unresolved_refs"),
|
|
234
|
+
runs: one("SELECT COUNT(*) AS n FROM adapter_runs"),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* A hash of the store's logical content, independent of insertion order.
|
|
239
|
+
*
|
|
240
|
+
* This is the instrument for the determinism proof: ingesting the same batches
|
|
241
|
+
* in a permuted order must produce the same hash. Without it, "the graph does
|
|
242
|
+
* not depend on adapter ordering" is an assertion nobody can check, and by the
|
|
243
|
+
* time a real ordering dependency shows up it presents as an unreproducible
|
|
244
|
+
* difference in impact scores.
|
|
245
|
+
*
|
|
246
|
+
* `written_at` is excluded — a wall-clock stamp is not logical content, and
|
|
247
|
+
* including it would make the proof untestable rather than making it stronger.
|
|
248
|
+
*/
|
|
249
|
+
export function contentHash(driver) {
|
|
250
|
+
const digest = createHash("sha256");
|
|
251
|
+
for (const table of [...DERIVED_TABLES, ...EARNED_TABLES].sort()) {
|
|
252
|
+
const columns = driver
|
|
253
|
+
.prepare(`SELECT name FROM pragma_table_info(?) ORDER BY name`)
|
|
254
|
+
.all(table)
|
|
255
|
+
.map((r) => r.name)
|
|
256
|
+
.filter((name) => name !== "written_at" && name !== "last_parsed_at");
|
|
257
|
+
if (columns.length === 0)
|
|
258
|
+
continue;
|
|
259
|
+
const select = columns.map((c) => `"${c}"`).join(", ");
|
|
260
|
+
const rows = driver
|
|
261
|
+
.prepare(`SELECT ${select} FROM "${table}" ORDER BY ${select}`)
|
|
262
|
+
.all();
|
|
263
|
+
digest.update(`${table}\n`);
|
|
264
|
+
for (const row of rows)
|
|
265
|
+
digest.update(`${canonicalJson(row)}\n`);
|
|
266
|
+
}
|
|
267
|
+
return digest.digest("hex");
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../../src/store/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,GAOX,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAsC5D,MAAM,YAAY,GAChB,2FAA2F,CAAC;AAC9F,MAAM,YAAY,GAChB,uFAAuF,CAAC;AAC1F,MAAM,sBAAsB,GAC1B,kFAAkF,CAAC;AAErF,SAAS,MAAM,CAAC,GAAY;IAC1B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,4EAA4E;QAC5E,yDAAyD;QACzD,MAAM,IAAI,KAAK,CAAC,eAAe,GAAG,CAAC,EAAE,yBAAyB,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,IAAI,GAAa,GAAG,CAAC,IAAI,CAAC;IAChC,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC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AM,UAAU,KAAK,cAAc,MAAM,EAAE,CAAC;aACvF,GAAG,EAAE,CAAC;QAET,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;QAC5B,KAAK,MAAM,GAAG,IAAI,IAAI;YAAE,MAAM,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The graph schema.
|
|
3
|
+
*
|
|
4
|
+
* Held as a TypeScript constant rather than a `.sql` file on disk. Reading a
|
|
5
|
+
* sibling `.sql` at runtime resolves to `src/` under Node's type stripping and
|
|
6
|
+
* `dist/` after `tsc`, so it needs an asset-copy build step and then behaves
|
|
7
|
+
* differently in tests than in production — the same class of trap the build
|
|
8
|
+
* plan flags for the traversal worker entrypoint. A constant has neither
|
|
9
|
+
* problem and costs nothing but syntax highlighting.
|
|
10
|
+
*
|
|
11
|
+
* ## Five corrections to the written schema
|
|
12
|
+
*
|
|
13
|
+
* Architecture §24.1 and blueprint §0.8 both describe this schema, and both need
|
|
14
|
+
* amending. Each is recorded here because the docs are the shared reference and
|
|
15
|
+
* a silent divergence is worse than either version.
|
|
16
|
+
*
|
|
17
|
+
* 1. **No `properties` table.** §11.8 names `nodes`/`edges`/`properties`, but
|
|
18
|
+
* §24.1 and blueprint §0.8 both use a JSON column instead. An entity-
|
|
19
|
+
* attribute-value table turns every node read into a join and defeats the
|
|
20
|
+
* adjacency performance target that §11.8's own traversal decision rests on.
|
|
21
|
+
* Language-specific detail lives in the `attrs` JSON column, which nothing
|
|
22
|
+
* above the IR reads.
|
|
23
|
+
*
|
|
24
|
+
* 2. **No `edges.weight`.** Blueprint §0.8 lists it. But `EdgeWeight` in §12.4
|
|
25
|
+
* is tuning config keyed by edge *type*, not a per-row value — storing it per
|
|
26
|
+
* row would let 30,000 copies of one tunable drift apart. The single genuine
|
|
27
|
+
* per-edge quantity, `CHANGES_WITH`'s co-change count, lives in `attrs`.
|
|
28
|
+
*
|
|
29
|
+
* 3. **No `edges.language`.** Both §24.1 and blueprint §0.8 declare it, and
|
|
30
|
+
* `IREdge` has no such field — nothing in the IR could ever populate it. A
|
|
31
|
+
* column no producer can fill is a column every reader must special-case.
|
|
32
|
+
*
|
|
33
|
+
* 4. **`nodes.language` is nullable.** §24.1 declares it `NOT NULL`. DEC-014
|
|
34
|
+
* establishes that `API_ENDPOINT` — the cross-language join node — belongs to
|
|
35
|
+
* no language, and XL-2 asserts it carries none. `NOT NULL` makes the join
|
|
36
|
+
* node unstorable.
|
|
37
|
+
*
|
|
38
|
+
* 5. **Composite adjacency indices.** Blueprint §0.8 indexes `edges(source)` and
|
|
39
|
+
* `edges(target)`. Every traversal hop filters by edge type as well, and the
|
|
40
|
+
* prior-art measurement on this machine found a max in-degree of 1,036 — so
|
|
41
|
+
* a single-column index means scanning a thousand rows to keep four.
|
|
42
|
+
* `edges(source, type)` and `edges(target, type)` are the real access paths.
|
|
43
|
+
*
|
|
44
|
+
* ## Derived vs earned — DEC-017
|
|
45
|
+
*
|
|
46
|
+
* The partition is expressed in `DERIVED_TABLES` / `EARNED_TABLES` below rather
|
|
47
|
+
* than left as prose, because the only thing that makes DEC-017 real is that
|
|
48
|
+
* `dropDerived()` can be tested to leave the earned side untouched.
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* Bumped when the IR itself changes shape, not when an adapter changes.
|
|
52
|
+
*
|
|
53
|
+
* DEC-017: on mismatch, refuse to read, drop derived, rebuild, migrate earned.
|
|
54
|
+
* A stored graph is derived data and is never the source of truth.
|
|
55
|
+
*/
|
|
56
|
+
export declare const IR_SCHEMA_VERSION = 4;
|
|
57
|
+
/**
|
|
58
|
+
* The tag on every node id, derived from the constant rather than restated.
|
|
59
|
+
*
|
|
60
|
+
* A graph tagged otherwise is not ours, and the whole point of the tag is to say
|
|
61
|
+
* so out loud instead of silently failing to match. Restating it here as a
|
|
62
|
+
* literal would let the store keep validating the previous scheme after an id
|
|
63
|
+
* change — the exact failure the tag exists to prevent.
|
|
64
|
+
*/
|
|
65
|
+
export declare const NODE_ID_SCHEME: string;
|
|
66
|
+
/**
|
|
67
|
+
* Regenerable from source. Dropping these loses time, never information.
|
|
68
|
+
*/
|
|
69
|
+
export declare const DERIVED_TABLES: readonly ["nodes", "edges", "unresolved_refs", "file_hashes", "embeddings", "adapter_runs"];
|
|
70
|
+
/**
|
|
71
|
+
* Cannot be regenerated: a run that witnessed an edge fire is gone once the
|
|
72
|
+
* process exits, and a human's correction of a wrong edge is not in the source
|
|
73
|
+
* at all. These survive every rebuild.
|
|
74
|
+
*/
|
|
75
|
+
export declare const EARNED_TABLES: readonly ["observed_edges", "edge_corrections", "incident_links", "pr_scopes"];
|
|
76
|
+
export type DerivedTable = (typeof DERIVED_TABLES)[number];
|
|
77
|
+
export type EarnedTable = (typeof EARNED_TABLES)[number];
|
|
78
|
+
/**
|
|
79
|
+
* Children before parents. Stated explicitly rather than derived by reversing
|
|
80
|
+
* `DERIVED_TABLES`: `PRAGMA foreign_keys` cannot be changed inside a
|
|
81
|
+
* transaction, so a drop in the wrong order either fails or leans on cascade
|
|
82
|
+
* behaviour to rescue it. Neither should be left to the order someone happened
|
|
83
|
+
* to list the tables in.
|
|
84
|
+
*/
|
|
85
|
+
export declare const DERIVED_DROP_ORDER: readonly ["embeddings", "unresolved_refs", "edges", "nodes", "file_hashes", "adapter_runs"];
|
|
86
|
+
export declare const SCHEMA_SQL = "\n-- ---------------------------------------------------------------------------\n-- graph_meta \u2014 identity of the store itself. Read before anything else.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS graph_meta (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n) STRICT;\n\n-- ---------------------------------------------------------------------------\n-- adapter_runs \u2014 one row per accepted IRBatch. \u00A724.1's adapter registry state\n-- and DEC-015's invalidation key are the same thing, so they are one table.\n--\n-- id is derived (hash of producer + repo + commit + source files), never an\n-- autoincrement rowid: re-ingesting an identical batch must reuse the same row,\n-- or idempotence is impossible to state.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS adapter_runs (\n id TEXT PRIMARY KEY,\n repo TEXT NOT NULL,\n -- The identity scope workspace-scoped ids in this batch were computed under\n -- (DEC-054). NULL means \"this repository alone\". Recorded because the scope is\n -- configuration: once it changes, no node id in this run can be re-derived from\n -- the row itself, and a workspace typo is otherwise invisible after the fact.\n workspace TEXT,\n commit_sha TEXT NOT NULL,\n adapter_id TEXT NOT NULL, -- the part before '@'\n adapter_version TEXT NOT NULL, -- the part after '@'\n produced_by TEXT NOT NULL, -- adapter_id@adapter_version, as written on every row\n reached_resolution INTEGER NOT NULL,\n source_files TEXT NOT NULL, -- JSON array; the invalidation key (DEC-015)\n file_count INTEGER NOT NULL,\n written_at INTEGER NOT NULL\n) STRICT;\n\nCREATE INDEX IF NOT EXISTS idx_runs_adapter ON adapter_runs(adapter_id);\nCREATE INDEX IF NOT EXISTS idx_runs_producer ON adapter_runs(produced_by);\n\n-- ---------------------------------------------------------------------------\n-- nodes\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS nodes (\n id TEXT PRIMARY KEY,\n type TEXT NOT NULL,\n name TEXT NOT NULL,\n file_path TEXT, -- null for fileless types (DEC-014)\n start_line INTEGER,\n end_line INTEGER,\n language TEXT, -- correction 4: nullable\n produced_by TEXT NOT NULL,\n resolution INTEGER NOT NULL,\n attrs TEXT NOT NULL, -- JSON; correction 1\n run_id TEXT NOT NULL REFERENCES adapter_runs(id) ON DELETE CASCADE\n) STRICT;\n\nCREATE INDEX IF NOT EXISTS idx_nodes_type ON nodes(type);\nCREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name);\nCREATE INDEX IF NOT EXISTS idx_nodes_file ON nodes(file_path);\nCREATE INDEX IF NOT EXISTS idx_nodes_resolution ON nodes(resolution);\nCREATE INDEX IF NOT EXISTS idx_nodes_run ON nodes(run_id);\n\n-- ---------------------------------------------------------------------------\n-- edges. Primary key is hash(from, to, type) per DEC-012, so two adapters\n-- finding the same relationship collide by construction \u2014 which is what makes\n-- a merge policy statable at all. 30% of prior-art edges were exact\n-- duplicates, so this is load-bearing rather than tidy.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS edges (\n id TEXT PRIMARY KEY,\n source TEXT NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,\n target TEXT NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,\n type TEXT NOT NULL,\n resolution INTEGER NOT NULL,\n confidence REAL NOT NULL,\n produced_by TEXT NOT NULL,\n observed_by_run TEXT, -- present exactly when resolution = 4\n attrs TEXT, -- JSON or null; corrections 1 and 2\n run_id TEXT NOT NULL REFERENCES adapter_runs(id) ON DELETE CASCADE,\n CHECK (resolution BETWEEN 0 AND 4),\n CHECK (confidence BETWEEN 0.0 AND 1.0),\n CHECK ((resolution = 4) = (observed_by_run IS NOT NULL))\n) STRICT;\n\n-- Correction 5: the real access paths. Every hop filters by type.\nCREATE INDEX IF NOT EXISTS idx_edges_source_type ON edges(source, type);\nCREATE INDEX IF NOT EXISTS idx_edges_target_type ON edges(target, type);\nCREATE INDEX IF NOT EXISTS idx_edges_resolution ON edges(resolution);\nCREATE INDEX IF NOT EXISTS idx_edges_run ON edges(run_id);\n\n-- ---------------------------------------------------------------------------\n-- unresolved_refs \u2014 DEC-016. What an adapter saw but could not resolve.\n--\n-- Not edges, because a name-matched guess is a false claim under \u00A711B.1. Not\n-- discarded either, because then \u00A711B.6 recall has no denominator and \u00A720.2's\n-- \"not analysable\" category has nothing to count. On the prior-art graphs this\n-- is 52-60% of everything emitted.\n-- ---------------------------------------------------------------------------\n-- id is a content hash, never an autoincrement rowid: an insertion-order key\n-- would make the permuted-ingest determinism proof impossible to state, and two\n-- byte-identical references are the same reference.\nCREATE TABLE IF NOT EXISTS unresolved_refs (\n id TEXT PRIMARY KEY,\n from_node_id TEXT NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,\n edge_type TEXT NOT NULL,\n raw_target TEXT NOT NULL,\n file_path TEXT,\n line INTEGER,\n produced_by TEXT NOT NULL,\n reason TEXT NOT NULL,\n -- DEC-242's attrs.blockedBy/attrs.refusalClass live here, JSON or null --\n -- same optional-attrs treatment as edges (correction 2), and deliberately\n -- excluded from id's content hash below: this is classification of a\n -- refusal, not part of what makes two refusals the same refusal. Added in\n -- schema version 3 -- DEC-017 governs what that bump costs an existing\n -- store (drop derived, rebuild; earned tables untouched).\n attrs TEXT,\n run_id TEXT NOT NULL REFERENCES adapter_runs(id) ON DELETE CASCADE\n) STRICT;\n\nCREATE INDEX IF NOT EXISTS idx_unresolved_from ON unresolved_refs(from_node_id);\nCREATE INDEX IF NOT EXISTS idx_unresolved_target ON unresolved_refs(raw_target);\nCREATE INDEX IF NOT EXISTS idx_unresolved_run ON unresolved_refs(run_id);\n\n-- ---------------------------------------------------------------------------\n-- file_hashes \u2014 \u00A711.14 rebuild acceleration. Layer 1 change detection is\n-- defined against this table and v2.1 never declared it.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS file_hashes (\n file_path TEXT PRIMARY KEY,\n hash TEXT NOT NULL,\n last_parsed_at INTEGER NOT NULL\n) STRICT;\n\n-- ---------------------------------------------------------------------------\n-- embeddings \u2014 pointer table only. No vector extension is loaded in this build;\n-- \u00A78.2 keeps vectors in pgvector hosted or a local extension, and a column of\n-- serialised floats with no index would be a scan, not a search.\n-- ---------------------------------------------------------------------------\nCREATE TABLE IF NOT EXISTS embeddings (\n node_id TEXT PRIMARY KEY REFERENCES nodes(id) ON DELETE CASCADE,\n vector_reference TEXT NOT NULL,\n model_version TEXT NOT NULL\n) STRICT;\n\n-- ===========================================================================\n-- EARNED \u2014 DEC-017. Never dropped. No REFERENCES into the derived tables:\n-- a foreign key would cascade these away with the graph they describe, which\n-- is precisely the outcome the partition exists to prevent.\n-- ===========================================================================\n\n-- R4 evidence. An edge witnessed firing during a live run (\u00A711B.3). This is the\n-- product's core moat and cannot be recomputed from source at any price.\nCREATE TABLE IF NOT EXISTS observed_edges (\n edge_id TEXT NOT NULL,\n run_id TEXT NOT NULL,\n from_node_id TEXT NOT NULL,\n to_node_id TEXT NOT NULL,\n edge_type TEXT NOT NULL,\n commit_sha TEXT NOT NULL,\n observed_at INTEGER NOT NULL,\n PRIMARY KEY (edge_id, run_id)\n) STRICT;\n\n-- \u00A711B.5. A human said an edge was wrong, or runtime contradicted it. Feeding\n-- this back is how precision improves; losing it repeats the same false claim.\nCREATE TABLE IF NOT EXISTS edge_corrections (\n edge_id TEXT PRIMARY KEY,\n verdict TEXT NOT NULL, -- 'wrong' | 'right'\n reason TEXT NOT NULL,\n corrected_at INTEGER NOT NULL\n) STRICT;\n\n-- \u00A714.2. One pull request's computed scope, and it is EARNED rather than derived\n-- for a reason that is easy to get backwards.\n--\n-- Everything else on the derived side can be regenerated from source because the\n-- source is what produced it. A PR scope cannot: it was computed against a graph\n-- at one commit, and that graph moves. Recomputing it later answers a DIFFERENT\n-- question and returns a plausible answer to it \u2014 so dropping this table does\n-- not lose time, it loses the COMPARISON BASIS. Overlap scoring between two PRs\n-- is only meaningful when both scopes were computed against the same graph, and\n-- nothing in a recomputed row would say that it was not.\n--\n-- graph_commit_sha is therefore not decoration: it is the field that makes two\n-- rows comparable or not, and a reader that ignores it will happily overlap a\n-- scope from last week with one from today and report a number.\n--\n-- scope_json holds the node id set. Kept opaque here on purpose: the shape of a\n-- scope is the scoping layer's business, and a column per dimension would need\n-- a migration every time that layer learns something. What the store guarantees\n-- is that the bytes come back unchanged with the commit they were computed at.\nCREATE TABLE IF NOT EXISTS pr_scopes (\n pr_id TEXT NOT NULL,\n repo TEXT NOT NULL,\n -- The head commit of the PR itself.\n head_sha TEXT NOT NULL,\n -- The commit the GRAPH was at when this scope was computed. Two scopes are\n -- comparable only when these agree.\n graph_commit_sha TEXT NOT NULL,\n scope_json TEXT NOT NULL,\n node_count INTEGER NOT NULL,\n computed_at INTEGER NOT NULL,\n PRIMARY KEY (repo, pr_id, graph_commit_sha)\n) STRICT;\n\n-- The access path for overlap scoring: every scope computed against one graph.\n-- Without it, comparing N PRs scans the whole table N times.\nCREATE INDEX IF NOT EXISTS idx_pr_scopes_graph ON pr_scopes(repo, graph_commit_sha);\n\n-- Incident and fix-pattern links. Accumulated from real failures over time.\nCREATE TABLE IF NOT EXISTS incident_links (\n incident_node_id TEXT NOT NULL,\n target_node_id TEXT NOT NULL,\n kind TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n PRIMARY KEY (incident_node_id, target_node_id, kind)\n) STRICT;\n";
|
|
87
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/store/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,QAAkC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,cAAc,6FAOjB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,aAAa,gFAKhB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,6FAOa,CAAC;AAE7C,eAAO,MAAM,UAAU,43VAyNtB,CAAC"}
|