@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,322 @@
|
|
|
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
|
+
import { NODE_ID_PREFIX } from "@descryy/ir";
|
|
51
|
+
/**
|
|
52
|
+
* Bumped when the IR itself changes shape, not when an adapter changes.
|
|
53
|
+
*
|
|
54
|
+
* DEC-017: on mismatch, refuse to read, drop derived, rebuild, migrate earned.
|
|
55
|
+
* A stored graph is derived data and is never the source of truth.
|
|
56
|
+
*/
|
|
57
|
+
export const IR_SCHEMA_VERSION = 4; // 3 -> 4: edge ids move e1: -> e2:, DEC-323
|
|
58
|
+
/**
|
|
59
|
+
* The tag on every node id, derived from the constant rather than restated.
|
|
60
|
+
*
|
|
61
|
+
* A graph tagged otherwise is not ours, and the whole point of the tag is to say
|
|
62
|
+
* so out loud instead of silently failing to match. Restating it here as a
|
|
63
|
+
* literal would let the store keep validating the previous scheme after an id
|
|
64
|
+
* change — the exact failure the tag exists to prevent.
|
|
65
|
+
*/
|
|
66
|
+
export const NODE_ID_SCHEME = NODE_ID_PREFIX.replace(":", "");
|
|
67
|
+
/**
|
|
68
|
+
* Regenerable from source. Dropping these loses time, never information.
|
|
69
|
+
*/
|
|
70
|
+
export const DERIVED_TABLES = [
|
|
71
|
+
"nodes",
|
|
72
|
+
"edges",
|
|
73
|
+
"unresolved_refs",
|
|
74
|
+
"file_hashes",
|
|
75
|
+
"embeddings",
|
|
76
|
+
"adapter_runs",
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* Cannot be regenerated: a run that witnessed an edge fire is gone once the
|
|
80
|
+
* process exits, and a human's correction of a wrong edge is not in the source
|
|
81
|
+
* at all. These survive every rebuild.
|
|
82
|
+
*/
|
|
83
|
+
export const EARNED_TABLES = [
|
|
84
|
+
"observed_edges",
|
|
85
|
+
"edge_corrections",
|
|
86
|
+
"incident_links",
|
|
87
|
+
"pr_scopes",
|
|
88
|
+
];
|
|
89
|
+
/**
|
|
90
|
+
* Children before parents. Stated explicitly rather than derived by reversing
|
|
91
|
+
* `DERIVED_TABLES`: `PRAGMA foreign_keys` cannot be changed inside a
|
|
92
|
+
* transaction, so a drop in the wrong order either fails or leans on cascade
|
|
93
|
+
* behaviour to rescue it. Neither should be left to the order someone happened
|
|
94
|
+
* to list the tables in.
|
|
95
|
+
*/
|
|
96
|
+
export const DERIVED_DROP_ORDER = [
|
|
97
|
+
"embeddings",
|
|
98
|
+
"unresolved_refs",
|
|
99
|
+
"edges",
|
|
100
|
+
"nodes",
|
|
101
|
+
"file_hashes",
|
|
102
|
+
"adapter_runs",
|
|
103
|
+
];
|
|
104
|
+
export const SCHEMA_SQL = `
|
|
105
|
+
-- ---------------------------------------------------------------------------
|
|
106
|
+
-- graph_meta — identity of the store itself. Read before anything else.
|
|
107
|
+
-- ---------------------------------------------------------------------------
|
|
108
|
+
CREATE TABLE IF NOT EXISTS graph_meta (
|
|
109
|
+
key TEXT PRIMARY KEY,
|
|
110
|
+
value TEXT NOT NULL
|
|
111
|
+
) STRICT;
|
|
112
|
+
|
|
113
|
+
-- ---------------------------------------------------------------------------
|
|
114
|
+
-- adapter_runs — one row per accepted IRBatch. §24.1's adapter registry state
|
|
115
|
+
-- and DEC-015's invalidation key are the same thing, so they are one table.
|
|
116
|
+
--
|
|
117
|
+
-- id is derived (hash of producer + repo + commit + source files), never an
|
|
118
|
+
-- autoincrement rowid: re-ingesting an identical batch must reuse the same row,
|
|
119
|
+
-- or idempotence is impossible to state.
|
|
120
|
+
-- ---------------------------------------------------------------------------
|
|
121
|
+
CREATE TABLE IF NOT EXISTS adapter_runs (
|
|
122
|
+
id TEXT PRIMARY KEY,
|
|
123
|
+
repo TEXT NOT NULL,
|
|
124
|
+
-- The identity scope workspace-scoped ids in this batch were computed under
|
|
125
|
+
-- (DEC-054). NULL means "this repository alone". Recorded because the scope is
|
|
126
|
+
-- configuration: once it changes, no node id in this run can be re-derived from
|
|
127
|
+
-- the row itself, and a workspace typo is otherwise invisible after the fact.
|
|
128
|
+
workspace TEXT,
|
|
129
|
+
commit_sha TEXT NOT NULL,
|
|
130
|
+
adapter_id TEXT NOT NULL, -- the part before '@'
|
|
131
|
+
adapter_version TEXT NOT NULL, -- the part after '@'
|
|
132
|
+
produced_by TEXT NOT NULL, -- adapter_id@adapter_version, as written on every row
|
|
133
|
+
reached_resolution INTEGER NOT NULL,
|
|
134
|
+
source_files TEXT NOT NULL, -- JSON array; the invalidation key (DEC-015)
|
|
135
|
+
file_count INTEGER NOT NULL,
|
|
136
|
+
written_at INTEGER NOT NULL
|
|
137
|
+
) STRICT;
|
|
138
|
+
|
|
139
|
+
CREATE INDEX IF NOT EXISTS idx_runs_adapter ON adapter_runs(adapter_id);
|
|
140
|
+
CREATE INDEX IF NOT EXISTS idx_runs_producer ON adapter_runs(produced_by);
|
|
141
|
+
|
|
142
|
+
-- ---------------------------------------------------------------------------
|
|
143
|
+
-- nodes
|
|
144
|
+
-- ---------------------------------------------------------------------------
|
|
145
|
+
CREATE TABLE IF NOT EXISTS nodes (
|
|
146
|
+
id TEXT PRIMARY KEY,
|
|
147
|
+
type TEXT NOT NULL,
|
|
148
|
+
name TEXT NOT NULL,
|
|
149
|
+
file_path TEXT, -- null for fileless types (DEC-014)
|
|
150
|
+
start_line INTEGER,
|
|
151
|
+
end_line INTEGER,
|
|
152
|
+
language TEXT, -- correction 4: nullable
|
|
153
|
+
produced_by TEXT NOT NULL,
|
|
154
|
+
resolution INTEGER NOT NULL,
|
|
155
|
+
attrs TEXT NOT NULL, -- JSON; correction 1
|
|
156
|
+
run_id TEXT NOT NULL REFERENCES adapter_runs(id) ON DELETE CASCADE
|
|
157
|
+
) STRICT;
|
|
158
|
+
|
|
159
|
+
CREATE INDEX IF NOT EXISTS idx_nodes_type ON nodes(type);
|
|
160
|
+
CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name);
|
|
161
|
+
CREATE INDEX IF NOT EXISTS idx_nodes_file ON nodes(file_path);
|
|
162
|
+
CREATE INDEX IF NOT EXISTS idx_nodes_resolution ON nodes(resolution);
|
|
163
|
+
CREATE INDEX IF NOT EXISTS idx_nodes_run ON nodes(run_id);
|
|
164
|
+
|
|
165
|
+
-- ---------------------------------------------------------------------------
|
|
166
|
+
-- edges. Primary key is hash(from, to, type) per DEC-012, so two adapters
|
|
167
|
+
-- finding the same relationship collide by construction — which is what makes
|
|
168
|
+
-- a merge policy statable at all. 30% of prior-art edges were exact
|
|
169
|
+
-- duplicates, so this is load-bearing rather than tidy.
|
|
170
|
+
-- ---------------------------------------------------------------------------
|
|
171
|
+
CREATE TABLE IF NOT EXISTS edges (
|
|
172
|
+
id TEXT PRIMARY KEY,
|
|
173
|
+
source TEXT NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,
|
|
174
|
+
target TEXT NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,
|
|
175
|
+
type TEXT NOT NULL,
|
|
176
|
+
resolution INTEGER NOT NULL,
|
|
177
|
+
confidence REAL NOT NULL,
|
|
178
|
+
produced_by TEXT NOT NULL,
|
|
179
|
+
observed_by_run TEXT, -- present exactly when resolution = 4
|
|
180
|
+
attrs TEXT, -- JSON or null; corrections 1 and 2
|
|
181
|
+
run_id TEXT NOT NULL REFERENCES adapter_runs(id) ON DELETE CASCADE,
|
|
182
|
+
CHECK (resolution BETWEEN 0 AND 4),
|
|
183
|
+
CHECK (confidence BETWEEN 0.0 AND 1.0),
|
|
184
|
+
CHECK ((resolution = 4) = (observed_by_run IS NOT NULL))
|
|
185
|
+
) STRICT;
|
|
186
|
+
|
|
187
|
+
-- Correction 5: the real access paths. Every hop filters by type.
|
|
188
|
+
CREATE INDEX IF NOT EXISTS idx_edges_source_type ON edges(source, type);
|
|
189
|
+
CREATE INDEX IF NOT EXISTS idx_edges_target_type ON edges(target, type);
|
|
190
|
+
CREATE INDEX IF NOT EXISTS idx_edges_resolution ON edges(resolution);
|
|
191
|
+
CREATE INDEX IF NOT EXISTS idx_edges_run ON edges(run_id);
|
|
192
|
+
|
|
193
|
+
-- ---------------------------------------------------------------------------
|
|
194
|
+
-- unresolved_refs — DEC-016. What an adapter saw but could not resolve.
|
|
195
|
+
--
|
|
196
|
+
-- Not edges, because a name-matched guess is a false claim under §11B.1. Not
|
|
197
|
+
-- discarded either, because then §11B.6 recall has no denominator and §20.2's
|
|
198
|
+
-- "not analysable" category has nothing to count. On the prior-art graphs this
|
|
199
|
+
-- is 52-60% of everything emitted.
|
|
200
|
+
-- ---------------------------------------------------------------------------
|
|
201
|
+
-- id is a content hash, never an autoincrement rowid: an insertion-order key
|
|
202
|
+
-- would make the permuted-ingest determinism proof impossible to state, and two
|
|
203
|
+
-- byte-identical references are the same reference.
|
|
204
|
+
CREATE TABLE IF NOT EXISTS unresolved_refs (
|
|
205
|
+
id TEXT PRIMARY KEY,
|
|
206
|
+
from_node_id TEXT NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,
|
|
207
|
+
edge_type TEXT NOT NULL,
|
|
208
|
+
raw_target TEXT NOT NULL,
|
|
209
|
+
file_path TEXT,
|
|
210
|
+
line INTEGER,
|
|
211
|
+
produced_by TEXT NOT NULL,
|
|
212
|
+
reason TEXT NOT NULL,
|
|
213
|
+
-- DEC-242's attrs.blockedBy/attrs.refusalClass live here, JSON or null --
|
|
214
|
+
-- same optional-attrs treatment as edges (correction 2), and deliberately
|
|
215
|
+
-- excluded from id's content hash below: this is classification of a
|
|
216
|
+
-- refusal, not part of what makes two refusals the same refusal. Added in
|
|
217
|
+
-- schema version 3 -- DEC-017 governs what that bump costs an existing
|
|
218
|
+
-- store (drop derived, rebuild; earned tables untouched).
|
|
219
|
+
attrs TEXT,
|
|
220
|
+
run_id TEXT NOT NULL REFERENCES adapter_runs(id) ON DELETE CASCADE
|
|
221
|
+
) STRICT;
|
|
222
|
+
|
|
223
|
+
CREATE INDEX IF NOT EXISTS idx_unresolved_from ON unresolved_refs(from_node_id);
|
|
224
|
+
CREATE INDEX IF NOT EXISTS idx_unresolved_target ON unresolved_refs(raw_target);
|
|
225
|
+
CREATE INDEX IF NOT EXISTS idx_unresolved_run ON unresolved_refs(run_id);
|
|
226
|
+
|
|
227
|
+
-- ---------------------------------------------------------------------------
|
|
228
|
+
-- file_hashes — §11.14 rebuild acceleration. Layer 1 change detection is
|
|
229
|
+
-- defined against this table and v2.1 never declared it.
|
|
230
|
+
-- ---------------------------------------------------------------------------
|
|
231
|
+
CREATE TABLE IF NOT EXISTS file_hashes (
|
|
232
|
+
file_path TEXT PRIMARY KEY,
|
|
233
|
+
hash TEXT NOT NULL,
|
|
234
|
+
last_parsed_at INTEGER NOT NULL
|
|
235
|
+
) STRICT;
|
|
236
|
+
|
|
237
|
+
-- ---------------------------------------------------------------------------
|
|
238
|
+
-- embeddings — pointer table only. No vector extension is loaded in this build;
|
|
239
|
+
-- §8.2 keeps vectors in pgvector hosted or a local extension, and a column of
|
|
240
|
+
-- serialised floats with no index would be a scan, not a search.
|
|
241
|
+
-- ---------------------------------------------------------------------------
|
|
242
|
+
CREATE TABLE IF NOT EXISTS embeddings (
|
|
243
|
+
node_id TEXT PRIMARY KEY REFERENCES nodes(id) ON DELETE CASCADE,
|
|
244
|
+
vector_reference TEXT NOT NULL,
|
|
245
|
+
model_version TEXT NOT NULL
|
|
246
|
+
) STRICT;
|
|
247
|
+
|
|
248
|
+
-- ===========================================================================
|
|
249
|
+
-- EARNED — DEC-017. Never dropped. No REFERENCES into the derived tables:
|
|
250
|
+
-- a foreign key would cascade these away with the graph they describe, which
|
|
251
|
+
-- is precisely the outcome the partition exists to prevent.
|
|
252
|
+
-- ===========================================================================
|
|
253
|
+
|
|
254
|
+
-- R4 evidence. An edge witnessed firing during a live run (§11B.3). This is the
|
|
255
|
+
-- product's core moat and cannot be recomputed from source at any price.
|
|
256
|
+
CREATE TABLE IF NOT EXISTS observed_edges (
|
|
257
|
+
edge_id TEXT NOT NULL,
|
|
258
|
+
run_id TEXT NOT NULL,
|
|
259
|
+
from_node_id TEXT NOT NULL,
|
|
260
|
+
to_node_id TEXT NOT NULL,
|
|
261
|
+
edge_type TEXT NOT NULL,
|
|
262
|
+
commit_sha TEXT NOT NULL,
|
|
263
|
+
observed_at INTEGER NOT NULL,
|
|
264
|
+
PRIMARY KEY (edge_id, run_id)
|
|
265
|
+
) STRICT;
|
|
266
|
+
|
|
267
|
+
-- §11B.5. A human said an edge was wrong, or runtime contradicted it. Feeding
|
|
268
|
+
-- this back is how precision improves; losing it repeats the same false claim.
|
|
269
|
+
CREATE TABLE IF NOT EXISTS edge_corrections (
|
|
270
|
+
edge_id TEXT PRIMARY KEY,
|
|
271
|
+
verdict TEXT NOT NULL, -- 'wrong' | 'right'
|
|
272
|
+
reason TEXT NOT NULL,
|
|
273
|
+
corrected_at INTEGER NOT NULL
|
|
274
|
+
) STRICT;
|
|
275
|
+
|
|
276
|
+
-- §14.2. One pull request's computed scope, and it is EARNED rather than derived
|
|
277
|
+
-- for a reason that is easy to get backwards.
|
|
278
|
+
--
|
|
279
|
+
-- Everything else on the derived side can be regenerated from source because the
|
|
280
|
+
-- source is what produced it. A PR scope cannot: it was computed against a graph
|
|
281
|
+
-- at one commit, and that graph moves. Recomputing it later answers a DIFFERENT
|
|
282
|
+
-- question and returns a plausible answer to it — so dropping this table does
|
|
283
|
+
-- not lose time, it loses the COMPARISON BASIS. Overlap scoring between two PRs
|
|
284
|
+
-- is only meaningful when both scopes were computed against the same graph, and
|
|
285
|
+
-- nothing in a recomputed row would say that it was not.
|
|
286
|
+
--
|
|
287
|
+
-- graph_commit_sha is therefore not decoration: it is the field that makes two
|
|
288
|
+
-- rows comparable or not, and a reader that ignores it will happily overlap a
|
|
289
|
+
-- scope from last week with one from today and report a number.
|
|
290
|
+
--
|
|
291
|
+
-- scope_json holds the node id set. Kept opaque here on purpose: the shape of a
|
|
292
|
+
-- scope is the scoping layer's business, and a column per dimension would need
|
|
293
|
+
-- a migration every time that layer learns something. What the store guarantees
|
|
294
|
+
-- is that the bytes come back unchanged with the commit they were computed at.
|
|
295
|
+
CREATE TABLE IF NOT EXISTS pr_scopes (
|
|
296
|
+
pr_id TEXT NOT NULL,
|
|
297
|
+
repo TEXT NOT NULL,
|
|
298
|
+
-- The head commit of the PR itself.
|
|
299
|
+
head_sha TEXT NOT NULL,
|
|
300
|
+
-- The commit the GRAPH was at when this scope was computed. Two scopes are
|
|
301
|
+
-- comparable only when these agree.
|
|
302
|
+
graph_commit_sha TEXT NOT NULL,
|
|
303
|
+
scope_json TEXT NOT NULL,
|
|
304
|
+
node_count INTEGER NOT NULL,
|
|
305
|
+
computed_at INTEGER NOT NULL,
|
|
306
|
+
PRIMARY KEY (repo, pr_id, graph_commit_sha)
|
|
307
|
+
) STRICT;
|
|
308
|
+
|
|
309
|
+
-- The access path for overlap scoring: every scope computed against one graph.
|
|
310
|
+
-- Without it, comparing N PRs scans the whole table N times.
|
|
311
|
+
CREATE INDEX IF NOT EXISTS idx_pr_scopes_graph ON pr_scopes(repo, graph_commit_sha);
|
|
312
|
+
|
|
313
|
+
-- Incident and fix-pattern links. Accumulated from real failures over time.
|
|
314
|
+
CREATE TABLE IF NOT EXISTS incident_links (
|
|
315
|
+
incident_node_id TEXT NOT NULL,
|
|
316
|
+
target_node_id TEXT NOT NULL,
|
|
317
|
+
kind TEXT NOT NULL,
|
|
318
|
+
created_at INTEGER NOT NULL,
|
|
319
|
+
PRIMARY KEY (incident_node_id, target_node_id, kind)
|
|
320
|
+
) STRICT;
|
|
321
|
+
`;
|
|
322
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/store/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,CAAC,4CAA4C;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,cAAc;CACN,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,gBAAgB;IAChB,kBAAkB;IAClB,gBAAgB;IAChB,WAAW;CACH,CAAC;AAKX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,YAAY;IACZ,iBAAiB;IACjB,OAAO;IACP,OAAO;IACP,aAAa;IACb,cAAc;CAC4B,CAAC;AAE7C,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyNzB,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The batch writer — DEC-015.
|
|
3
|
+
*
|
|
4
|
+
* "The writer deletes everything previously written by `producedBy` for
|
|
5
|
+
* `sourceFiles`, then inserts, in one transaction." That sentence hides three
|
|
6
|
+
* decisions the decision entry does not make, and getting any of them wrong
|
|
7
|
+
* loses data silently. They are made here and each is tested.
|
|
8
|
+
*
|
|
9
|
+
* ## 1. Invalidation matches on adapter *id* and *repo*, not `producedBy` alone
|
|
10
|
+
*
|
|
11
|
+
* `producedBy` is `id@version`. Matching the full string would mean an adapter
|
|
12
|
+
* upgrade never invalidates anything the old version wrote — the two producers
|
|
13
|
+
* would simply coexist, and the graph would hold both readings of every file
|
|
14
|
+
* forever. §24.1 is explicit: "an adapter version bump invalidates every node
|
|
15
|
+
* and edge that adapter produced". So overlap is computed on the id, and the
|
|
16
|
+
* version is what makes the *stale* rows recognisable.
|
|
17
|
+
*
|
|
18
|
+
* `repo` is a second, equally load-bearing part of the same match, added after
|
|
19
|
+
* a real defect: a store holding more than one repository (`descry-runtime`'s
|
|
20
|
+
* graph correlator merges a frontend and a backend into one store to trace
|
|
21
|
+
* across them, per DEC-228) can have two repos using the same adapter with an
|
|
22
|
+
* overlapping relative file path — `src/index.ts`, `package.json`, anything
|
|
23
|
+
* common. Without `repo` in this match, writing the second repo's batch reads
|
|
24
|
+
* as "adapter X re-ran over a file it already owned" and evicts the first
|
|
25
|
+
* repo's run outright — silent cross-repository data loss, not a wrong
|
|
26
|
+
* answer. `invalidateAdapter` below is intentionally *not* repo-scoped — its
|
|
27
|
+
* own contract is "every repo," a different, explicitly global operation.
|
|
28
|
+
*
|
|
29
|
+
* ## 2. Prior runs are matched by file-set *overlap*, not equality
|
|
30
|
+
*
|
|
31
|
+
* A batch is the unit of invalidation, but the batch that previously owned a
|
|
32
|
+
* file may have covered a different set of files. Deleting only exact-matching
|
|
33
|
+
* runs leaves two rows for the same symbol; deleting only the intersection is
|
|
34
|
+
* impossible, because an edge has no file. So every prior run of the same
|
|
35
|
+
* adapter that touches *any* of these files is replaced whole — and the files
|
|
36
|
+
* it covered that this batch does not re-supply are reported as `evictedFiles`.
|
|
37
|
+
* Reporting them is the honest-degradation rule (principle 7): the caller is
|
|
38
|
+
* told what fell out, rather than discovering it as a missing edge next week.
|
|
39
|
+
*
|
|
40
|
+
* ## 3. A run also cleans up after its own previous write
|
|
41
|
+
*
|
|
42
|
+
* The run id is content-derived from producer, repo, commit and file set — not
|
|
43
|
+
* from the nodes. So an adapter re-run at the same commit over the same files
|
|
44
|
+
* lands on the *same* run id, and "delete the prior runs" excludes it by
|
|
45
|
+
* definition. Without a self-clean pass, rows that run no longer produces stay
|
|
46
|
+
* forever: the upsert refreshes what is still there and nothing removes what is
|
|
47
|
+
* not. Every write therefore ends by deleting its own run's rows that this batch
|
|
48
|
+
* did not supply.
|
|
49
|
+
*
|
|
50
|
+
* ## 4. Re-supplied nodes are updated, not deleted and recreated
|
|
51
|
+
*
|
|
52
|
+
* A node id is stable across file moves by construction (DEC-004), so re-parsing
|
|
53
|
+
* a file normally yields the ids that were already there. Deleting a prior run's
|
|
54
|
+
* nodes wholesale would cascade away every edge *other* runs had pointing into
|
|
55
|
+
* them, and those runs will not be re-run. Instead: upsert the ids this batch
|
|
56
|
+
* supplies, then delete the prior run — whose remaining nodes are exactly those
|
|
57
|
+
* it no longer produces. Edges into a node that genuinely disappeared do cascade
|
|
58
|
+
* away, and are reported as `orphanedEdges`, because keeping an edge to a node
|
|
59
|
+
* that no longer exists is the wrong-edge failure the precision rule forbids.
|
|
60
|
+
*/
|
|
61
|
+
import { type IRBatch } from "@descryy/ir";
|
|
62
|
+
import type { SqlDriver } from "./driver/driver.ts";
|
|
63
|
+
export interface WriteResult {
|
|
64
|
+
readonly runId: string;
|
|
65
|
+
readonly nodesWritten: number;
|
|
66
|
+
readonly edgesWritten: number;
|
|
67
|
+
readonly unresolvedWritten: number;
|
|
68
|
+
/** Prior runs of the same adapter that this batch replaced. */
|
|
69
|
+
readonly runsReplaced: number;
|
|
70
|
+
/**
|
|
71
|
+
* Files a replaced run covered that this batch did not re-supply. Their rows
|
|
72
|
+
* are gone and will not come back until the adapter is re-run over them.
|
|
73
|
+
* Non-empty is not an error, but it is never silent.
|
|
74
|
+
*/
|
|
75
|
+
readonly evictedFiles: readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* Edges removed because an endpoint node ceased to exist. Always reported:
|
|
78
|
+
* this is the one place the store deletes something nobody asked it to.
|
|
79
|
+
*/
|
|
80
|
+
readonly orphanedEdges: number;
|
|
81
|
+
}
|
|
82
|
+
export interface WriteOptions {
|
|
83
|
+
/** Injectable so the determinism proof is not at the mercy of the wall clock. */
|
|
84
|
+
readonly now?: () => number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A run id derived from the batch's content, never a counter.
|
|
88
|
+
*
|
|
89
|
+
* Re-ingesting an identical batch must land on the same row, or "idempotent"
|
|
90
|
+
* cannot even be stated as a property. `sourceFiles` is sorted first so that an
|
|
91
|
+
* adapter listing the same files in a different order does not create a second
|
|
92
|
+
* run for identical work.
|
|
93
|
+
*/
|
|
94
|
+
export declare function runIdFor(batch: IRBatch): string;
|
|
95
|
+
/**
|
|
96
|
+
* Write one normalised batch. **Input must already have passed the Normaliser** —
|
|
97
|
+
* this function does no validation, on purpose. Two validators drift; one
|
|
98
|
+
* validator at the boundary is a boundary.
|
|
99
|
+
*/
|
|
100
|
+
export declare function writeBatch(driver: SqlDriver, batch: IRBatch, options?: WriteOptions): WriteResult;
|
|
101
|
+
/**
|
|
102
|
+
* Remove everything an adapter ever produced, at every version, for every repo.
|
|
103
|
+
*
|
|
104
|
+
* §24.1's invalidation rule, as its own operation rather than a side effect of
|
|
105
|
+
* writing. It is deliberately separate from `writeBatch`: an upgraded adapter
|
|
106
|
+
* usually re-runs over a subset of files first, and folding this into the write
|
|
107
|
+
* path would make a partial re-run delete data it was never going to replace.
|
|
108
|
+
*/
|
|
109
|
+
export declare function invalidateAdapter(driver: SqlDriver, adapterId: string): {
|
|
110
|
+
runsRemoved: number;
|
|
111
|
+
};
|
|
112
|
+
/** §11.14 rebuild acceleration. Layer 1 change detection reads this. */
|
|
113
|
+
export declare function putFileHash(driver: SqlDriver, filePath: string, hash: string, parsedAt: number): void;
|
|
114
|
+
/** Nodes touching these files, unchanged. */
|
|
115
|
+
export declare function getFileHash(driver: SqlDriver, filePath: string): string | undefined;
|
|
116
|
+
//# sourceMappingURL=writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/store/writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAGH,OAAO,EAAyB,KAAK,OAAO,EAAmC,MAAM,aAAa,CAAC;AAGnG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,iFAAiF;IACjF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAYD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI/C;AAmCD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,YAAiB,GACzB,WAAW,CA0Nb;AAYD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAK/F;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,IAAI,CAON;AAED,6CAA6C;AAC7C,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAInF"}
|