@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,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime confirmation — architecture §11B.3, the R4 half of the moat.
|
|
3
|
+
*
|
|
4
|
+
* > *"A purely static code-graph tool is capped at R3 permanently. It has no
|
|
5
|
+
* > runtime. This is the one accuracy source that cannot be copied without
|
|
6
|
+
* > also building the testing half, and it should be treated as the core
|
|
7
|
+
* > technical moat rather than the graph itself."* — §11B.3
|
|
8
|
+
*
|
|
9
|
+
* The schema has held `observed_edges` and `edge_corrections` since the store
|
|
10
|
+
* was first written, both on the EARNED side of DEC-017's partition, both
|
|
11
|
+
* carrying a comment explaining why they cannot be recomputed. **Nothing read
|
|
12
|
+
* or wrote either one.** This module is what they were for.
|
|
13
|
+
*
|
|
14
|
+
* ## The three arrows §11B.3 draws, and where each one lands
|
|
15
|
+
*
|
|
16
|
+
* | Observation | What happens |
|
|
17
|
+
* | --- | --- |
|
|
18
|
+
* | confirms an edge the graph already has, below R4 | **promote** to R4, `observed_by_run` set |
|
|
19
|
+
* | confirms an edge the graph does not have | **create** it at R4 — "recall gap closed" |
|
|
20
|
+
* | denies an edge the graph has, below R4 | **correct** it: an `edge_corrections` row, and a {@link GraphDefectRecord} out |
|
|
21
|
+
*
|
|
22
|
+
* ## Why a denial demotes confidence and does not delete the edge
|
|
23
|
+
*
|
|
24
|
+
* `edges` is DERIVED. Deleting a row there is undone by the next index, which
|
|
25
|
+
* regenerates the identical guess from the identical source and has no memory
|
|
26
|
+
* of the run that disproved it — the correction would evaporate exactly when
|
|
27
|
+
* it was needed again. §11B.5 already states the answer: corrections are
|
|
28
|
+
* *"stored as graph overrides keyed by stable node IDs, surviving re-index and
|
|
29
|
+
* adapter upgrades."* So the durable statement is the `edge_corrections` row,
|
|
30
|
+
* and the effect on the derived graph is a confidence demotion that
|
|
31
|
+
* {@link reapplyEarnedOverlays} re-applies after every rebuild.
|
|
32
|
+
*
|
|
33
|
+
* Demotion rather than deletion is also DEC-284's own stated direction — *"it
|
|
34
|
+
* fails toward demote, which is the safe direction"* — and it keeps rule 2
|
|
35
|
+
* intact from the other side: a wrong edge stops being load-bearing without
|
|
36
|
+
* the graph asserting a *new* fact (that the call does not exist) that no
|
|
37
|
+
* single observation actually establishes.
|
|
38
|
+
*
|
|
39
|
+
* ## What this module refuses to do
|
|
40
|
+
*
|
|
41
|
+
* - **Invent a node.** An observation naming a node this graph does not hold
|
|
42
|
+
* is refused with its reason, never created. Rule 2, and the same posture
|
|
43
|
+
* `correlateExecution` takes one layer down for an ambiguous resolution.
|
|
44
|
+
* - **Adjudicate R4 against R4.** A denial against an edge already at R4 is
|
|
45
|
+
* two runtime observations disagreeing across time — a staleness question
|
|
46
|
+
* whose policy is decided (DEC-284 + a 7-day backstop) but whose consumer
|
|
47
|
+
* does not exist yet. `contradiction.ts` excludes the case by construction
|
|
48
|
+
* and this module reports it as {@link RuntimeConfirmationResult.staleR4}
|
|
49
|
+
* rather than laundering it through a path that looks decided.
|
|
50
|
+
* - **Judge a finding.** Resolution has no opinion on confidence (RT-027).
|
|
51
|
+
* Nothing here reads or writes a finding, a hypothesis or a category.
|
|
52
|
+
*
|
|
53
|
+
* @see `packages/ir/src/contradiction.ts` — the pure detection this persists.
|
|
54
|
+
* @see `documents/plans/ai-layer-plan.md` §10 — *"the valuable half."*
|
|
55
|
+
*/
|
|
56
|
+
import { edgeId } from "@descryy/ir";
|
|
57
|
+
const SYSTEM_CLOCK = { now: () => Date.now() };
|
|
58
|
+
/**
|
|
59
|
+
* Apply a run's edge observations to the graph, writing the earned record and
|
|
60
|
+
* projecting it onto the derived edges in one transaction.
|
|
61
|
+
*
|
|
62
|
+
* Pure with respect to its inputs and total over them: every observation lands
|
|
63
|
+
* in exactly one of the six result arrays, so a caller can account for all of
|
|
64
|
+
* them without inspecting the store. Never throws for an observation it cannot
|
|
65
|
+
* act on — that is a refusal, per the five-result-states rule the tool contract
|
|
66
|
+
* applies one layer up.
|
|
67
|
+
*/
|
|
68
|
+
export function applyRuntimeObservations(driver, input, clock = SYSTEM_CLOCK) {
|
|
69
|
+
const promoted = [];
|
|
70
|
+
const created = [];
|
|
71
|
+
const confirmed = [];
|
|
72
|
+
const contradictions = [];
|
|
73
|
+
const staleR4 = [];
|
|
74
|
+
const refused = [];
|
|
75
|
+
const now = clock.now();
|
|
76
|
+
driver.transaction(() => {
|
|
77
|
+
for (const observation of input.observations) {
|
|
78
|
+
const id = edgeId(observation.from, observation.to, observation.edgeType);
|
|
79
|
+
const existing = readEdge(driver, id);
|
|
80
|
+
if (observation.held) {
|
|
81
|
+
// Both endpoints must already be nodes. Creating one would be the
|
|
82
|
+
// graph inventing a symbol from a runtime string, which is the exact
|
|
83
|
+
// shape rule 2 exists to forbid.
|
|
84
|
+
const missing = missingNode(driver, observation.from, observation.to);
|
|
85
|
+
if (missing !== null) {
|
|
86
|
+
refused.push({
|
|
87
|
+
from: observation.from,
|
|
88
|
+
to: observation.to,
|
|
89
|
+
edgeType: observation.edgeType,
|
|
90
|
+
reason: `${missing} is not in this graph, so the observed ${observation.edgeType} edge cannot be ` +
|
|
91
|
+
"recorded against it. The graph is not extended from a runtime name.",
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
recordObservedEdge(driver, id, input, observation, now);
|
|
96
|
+
if (existing === undefined) {
|
|
97
|
+
insertEdgeAtR4(driver, id, observation, input.runId, input.commitSha);
|
|
98
|
+
created.push(id);
|
|
99
|
+
}
|
|
100
|
+
else if (existing.resolution < 4) {
|
|
101
|
+
promoteEdge(driver, id, input.runId);
|
|
102
|
+
promoted.push(id);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
confirmed.push(id);
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
// A denial.
|
|
110
|
+
if (existing === undefined) {
|
|
111
|
+
refused.push({
|
|
112
|
+
from: observation.from,
|
|
113
|
+
to: observation.to,
|
|
114
|
+
edgeType: observation.edgeType,
|
|
115
|
+
reason: `no ${observation.edgeType} edge from ${observation.from} to ${observation.to} exists in this ` +
|
|
116
|
+
"graph, so there is nothing for this observation to contradict.",
|
|
117
|
+
});
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (existing.resolution >= 4) {
|
|
121
|
+
// contradiction.ts's own exclusion, enforced here rather than restated.
|
|
122
|
+
staleR4.push({ edgeId: id, observedByRun: existing.observed_by_run, detail: observation.detail });
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
recordCorrection(driver, id, observation.detail, now);
|
|
126
|
+
demoteEdge(driver, id);
|
|
127
|
+
contradictions.push({
|
|
128
|
+
from: observation.from,
|
|
129
|
+
to: observation.to,
|
|
130
|
+
edgeType: observation.edgeType,
|
|
131
|
+
claimedResolution: existing.resolution,
|
|
132
|
+
detail: observation.detail,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return { promoted, created, confirmed, contradictions, staleR4, refused };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Re-project the EARNED ledgers onto a freshly rebuilt derived graph.
|
|
140
|
+
*
|
|
141
|
+
* **This is what makes the DEC-017 partition pay.** `dropDerived()` removes
|
|
142
|
+
* `edges` and leaves `observed_edges`/`edge_corrections` standing; a re-index
|
|
143
|
+
* then regenerates the same static guesses, at their static resolutions, with
|
|
144
|
+
* no memory of any run. Without this call the moat is silently reset on every
|
|
145
|
+
* rebuild — the edges would be back at R2 and the R4 rows would sit in a table
|
|
146
|
+
* nothing consults, which is indistinguishable from never having observed
|
|
147
|
+
* anything.
|
|
148
|
+
*
|
|
149
|
+
* Observations whose endpoints no longer exist are reported as refusals rather
|
|
150
|
+
* than recreated: the code moved, and re-minting a node from an old run's
|
|
151
|
+
* record would be the same rule-2 violation one rebuild later.
|
|
152
|
+
*/
|
|
153
|
+
export function reapplyEarnedOverlays(driver) {
|
|
154
|
+
const rows = observedEdges(driver);
|
|
155
|
+
const corrections = edgeCorrections(driver).filter((c) => c.verdict === "wrong");
|
|
156
|
+
const promoted = [];
|
|
157
|
+
const created = [];
|
|
158
|
+
const confirmed = [];
|
|
159
|
+
const refused = [];
|
|
160
|
+
driver.transaction(() => {
|
|
161
|
+
for (const row of rows) {
|
|
162
|
+
const missing = missingNode(driver, row.from, row.to);
|
|
163
|
+
if (missing !== null) {
|
|
164
|
+
refused.push({
|
|
165
|
+
from: row.from,
|
|
166
|
+
to: row.to,
|
|
167
|
+
edgeType: row.edgeType,
|
|
168
|
+
reason: `${missing} is not in this graph any more; run ${row.runId}'s observation is not re-applied.`,
|
|
169
|
+
});
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const existing = readEdge(driver, row.edgeId);
|
|
173
|
+
if (existing === undefined) {
|
|
174
|
+
insertEdgeAtR4(driver, row.edgeId, row, row.runId, row.commitSha);
|
|
175
|
+
created.push(row.edgeId);
|
|
176
|
+
}
|
|
177
|
+
else if (existing.resolution < 4) {
|
|
178
|
+
promoteEdge(driver, row.edgeId, row.runId);
|
|
179
|
+
promoted.push(row.edgeId);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
confirmed.push(row.edgeId);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
for (const correction of corrections) {
|
|
186
|
+
// A correction never wins over a later observation: an edge re-observed
|
|
187
|
+
// firing is a stronger, more recent statement than the denial that
|
|
188
|
+
// demoted it, and `observed_edges` carries the run that saw it.
|
|
189
|
+
const existing = readEdge(driver, correction.edgeId);
|
|
190
|
+
if (existing !== undefined && existing.resolution < 4)
|
|
191
|
+
demoteEdge(driver, correction.edgeId);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
return { promoted, created, confirmed, contradictions: [], staleR4: [], refused };
|
|
195
|
+
}
|
|
196
|
+
/** Every row of the EARNED R4 ledger, oldest first, optionally for one run. */
|
|
197
|
+
export function observedEdges(driver, options = {}) {
|
|
198
|
+
const where = options.runId === undefined ? "" : " WHERE run_id = ?";
|
|
199
|
+
const sql = "SELECT edge_id, run_id, from_node_id, to_node_id, edge_type, commit_sha, observed_at" +
|
|
200
|
+
` FROM observed_edges${where} ORDER BY observed_at ASC, edge_id ASC`;
|
|
201
|
+
const args = options.runId === undefined ? [] : [options.runId];
|
|
202
|
+
return driver
|
|
203
|
+
.prepare(sql)
|
|
204
|
+
.all(...args)
|
|
205
|
+
.map((row) => ({
|
|
206
|
+
edgeId: row.edge_id,
|
|
207
|
+
runId: row.run_id,
|
|
208
|
+
from: row.from_node_id,
|
|
209
|
+
to: row.to_node_id,
|
|
210
|
+
edgeType: row.edge_type,
|
|
211
|
+
commitSha: row.commit_sha,
|
|
212
|
+
observedAt: row.observed_at,
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
/** Every row of the EARNED correction ledger (§11B.5), oldest first. */
|
|
216
|
+
export function edgeCorrections(driver) {
|
|
217
|
+
return driver
|
|
218
|
+
.prepare("SELECT edge_id, verdict, reason, corrected_at FROM edge_corrections ORDER BY corrected_at ASC, edge_id ASC")
|
|
219
|
+
.all()
|
|
220
|
+
.map((row) => ({
|
|
221
|
+
edgeId: row.edge_id,
|
|
222
|
+
verdict: row.verdict === "right" ? "right" : "wrong",
|
|
223
|
+
reason: row.reason,
|
|
224
|
+
correctedAt: row.corrected_at,
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Record a human's verdict on an edge — §11B.5's other producer.
|
|
229
|
+
*
|
|
230
|
+
* *"On one team's codebase, a few hundred corrections buy more accuracy than a
|
|
231
|
+
* quarter of parser work."* Same table the runtime's own denials land in, on
|
|
232
|
+
* purpose: an edge is wrong or it is not, and who noticed does not change what
|
|
233
|
+
* the graph should do about it. The `reason` is the correction's provenance and
|
|
234
|
+
* is never summarised.
|
|
235
|
+
*/
|
|
236
|
+
export function recordEdgeCorrection(driver, input, clock = SYSTEM_CLOCK) {
|
|
237
|
+
const id = edgeId(input.from, input.to, input.edgeType);
|
|
238
|
+
driver.transaction(() => {
|
|
239
|
+
recordCorrectionRow(driver, id, input.verdict, input.reason, clock.now());
|
|
240
|
+
const existing = readEdge(driver, id);
|
|
241
|
+
if (input.verdict === "wrong" && existing !== undefined && existing.resolution < 4)
|
|
242
|
+
demoteEdge(driver, id);
|
|
243
|
+
});
|
|
244
|
+
return { edgeId: id };
|
|
245
|
+
}
|
|
246
|
+
// ---------------------------------------------------------------------------
|
|
247
|
+
// Internals.
|
|
248
|
+
// ---------------------------------------------------------------------------
|
|
249
|
+
function readEdge(driver, id) {
|
|
250
|
+
return driver
|
|
251
|
+
.prepare("SELECT id, resolution, observed_by_run FROM edges WHERE id = ?")
|
|
252
|
+
.all(id)[0];
|
|
253
|
+
}
|
|
254
|
+
/** The first of `from`/`to` this graph does not hold, or `null` when it holds both. */
|
|
255
|
+
function missingNode(driver, from, to) {
|
|
256
|
+
const statement = driver.prepare("SELECT id FROM nodes WHERE id = ?");
|
|
257
|
+
if (statement.all(from).length === 0)
|
|
258
|
+
return from;
|
|
259
|
+
if (statement.all(to).length === 0)
|
|
260
|
+
return to;
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
function recordObservedEdge(driver, id, input, observation, now) {
|
|
264
|
+
driver
|
|
265
|
+
.prepare("INSERT INTO observed_edges (edge_id, run_id, from_node_id, to_node_id, edge_type, commit_sha, observed_at)" +
|
|
266
|
+
" VALUES (?, ?, ?, ?, ?, ?, ?)" +
|
|
267
|
+
" ON CONFLICT(edge_id, run_id) DO NOTHING")
|
|
268
|
+
.run(id, input.runId, observation.from, observation.to, observation.edgeType, input.commitSha, now);
|
|
269
|
+
}
|
|
270
|
+
function recordCorrection(driver, id, detail, now) {
|
|
271
|
+
recordCorrectionRow(driver, id, "wrong", detail, now);
|
|
272
|
+
}
|
|
273
|
+
function recordCorrectionRow(driver, id, verdict, reason, now) {
|
|
274
|
+
driver
|
|
275
|
+
.prepare("INSERT INTO edge_corrections (edge_id, verdict, reason, corrected_at) VALUES (?, ?, ?, ?)" +
|
|
276
|
+
" ON CONFLICT(edge_id) DO UPDATE SET verdict = excluded.verdict, reason = excluded.reason," +
|
|
277
|
+
" corrected_at = excluded.corrected_at")
|
|
278
|
+
.run(id, verdict, reason, now);
|
|
279
|
+
}
|
|
280
|
+
function promoteEdge(driver, id, runId) {
|
|
281
|
+
// Confidence goes to 1 with the resolution: R4 is unconditionally class A
|
|
282
|
+
// (DEC-115), and leaving a witnessed edge at the guess's own confidence
|
|
283
|
+
// would let a downstream ranker treat proof as inference.
|
|
284
|
+
driver
|
|
285
|
+
.prepare("UPDATE edges SET resolution = 4, observed_by_run = ?, confidence = 1.0 WHERE id = ?")
|
|
286
|
+
.run(runId, id);
|
|
287
|
+
}
|
|
288
|
+
function demoteEdge(driver, id) {
|
|
289
|
+
driver.prepare("UPDATE edges SET confidence = 0.0 WHERE id = ?").run(id);
|
|
290
|
+
}
|
|
291
|
+
function insertEdgeAtR4(driver, id, observation, runId, commitSha) {
|
|
292
|
+
// `run_id` must reference a real `adapter_runs` row (FK), and this edge was
|
|
293
|
+
// produced by a runtime observation rather than by any adapter — so the pass
|
|
294
|
+
// owns a run row of its own, created once and reused. Deleting it cascades
|
|
295
|
+
// exactly the edges this module minted and nothing else, which is the
|
|
296
|
+
// correct blast radius for invalidating a runtime producer.
|
|
297
|
+
const producerRunId = ensureRuntimeRun(driver, runId, commitSha);
|
|
298
|
+
driver
|
|
299
|
+
.prepare("INSERT INTO edges (id, source, target, type, resolution, confidence, produced_by, observed_by_run, attrs, run_id)" +
|
|
300
|
+
" VALUES (?, ?, ?, ?, 4, 1.0, ?, ?, NULL, ?)" +
|
|
301
|
+
" ON CONFLICT(id) DO UPDATE SET resolution = 4, confidence = 1.0, observed_by_run = excluded.observed_by_run")
|
|
302
|
+
.run(id, observation.from, observation.to, observation.edgeType, RUNTIME_PRODUCER, runId, producerRunId);
|
|
303
|
+
}
|
|
304
|
+
/** The `producedBy` every runtime-minted edge carries. Provenance is load-bearing (§11A.5). */
|
|
305
|
+
export const RUNTIME_ADAPTER_ID = "runtime-confirmation";
|
|
306
|
+
export const RUNTIME_ADAPTER_VERSION = "1";
|
|
307
|
+
export const RUNTIME_PRODUCER = `${RUNTIME_ADAPTER_ID}@${RUNTIME_ADAPTER_VERSION}`;
|
|
308
|
+
function ensureRuntimeRun(driver, runId, commitSha) {
|
|
309
|
+
const id = `runtime:${runId}`;
|
|
310
|
+
driver
|
|
311
|
+
.prepare("INSERT INTO adapter_runs (id, repo, workspace, commit_sha, adapter_id, adapter_version, produced_by," +
|
|
312
|
+
" reached_resolution, source_files, file_count, written_at)" +
|
|
313
|
+
" VALUES (?, '', NULL, ?, ?, ?, ?, 4, '[]', 0, ?)" +
|
|
314
|
+
" ON CONFLICT(id) DO NOTHING")
|
|
315
|
+
.run(id, commitSha, RUNTIME_ADAPTER_ID, RUNTIME_ADAPTER_VERSION, RUNTIME_PRODUCER, Date.now());
|
|
316
|
+
return id;
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=runtime-confirmation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-confirmation.js","sourceRoot":"","sources":["../../src/graph/runtime-confirmation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,EAAE,MAAM,EAAsE,MAAM,aAAa,CAAC;AAyEzG,MAAM,YAAY,GAAU,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,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MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IACjE,MAAM;SACH,OAAO,CACN,mHAAmH;QACjH,6CAA6C;QAC7C,6GAA6G,CAChH;SACA,GAAG,CAAC,EAAE,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;AAC7G,CAAC;AAED,+FAA+F;AAC/F,MAAM,CAAC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,kBAAkB,IAAI,uBAAuB,EAAE,CAAC;AAEnF,SAAS,gBAAgB,CAAC,MAAiB,EAAE,KAAa,EAAE,SAAiB;IAC3E,MAAM,EAAE,GAAG,WAAW,KAAK,EAAE,CAAC;IAC9B,MAAM;SACH,OAAO,CACN,sGAAsG;QACpG,4DAA4D;QAC5D,kDAAkD;QAClD,6BAA6B,CAChC;SACA,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACjG,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const CORE_PACKAGE = "@descryy/core";
|
|
2
|
+
export * from "./store/index.ts";
|
|
3
|
+
export * from "./graph/index.ts";
|
|
4
|
+
export * from "./query/index.ts";
|
|
5
|
+
export * from "./worker/index.ts";
|
|
6
|
+
export * from "./sources/git/index.ts";
|
|
7
|
+
export * from "./sources/migrations/index.ts";
|
|
8
|
+
export * from "./sources/workspace/index.ts";
|
|
9
|
+
export * from "./scoping/index.ts";
|
|
10
|
+
export * from "./contracts/index.ts";
|
|
11
|
+
export * from "./capabilities/index.ts";
|
|
12
|
+
export * from "./multipr/index.ts";
|
|
13
|
+
export * from "./tiers/index.ts";
|
|
14
|
+
export * from "./validation/index.ts";
|
|
15
|
+
export * from "./ledger/index.ts";
|
|
16
|
+
export * from "./recording/index.ts";
|
|
17
|
+
export * from "./governance/index.ts";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,kBAAkB,CAAC;AAE5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @descryy/core — graph engine: storage, builder, query, traversal, scoping.
|
|
2
|
+
export const CORE_PACKAGE = "@descryy/core";
|
|
3
|
+
export * from "./store/index.js";
|
|
4
|
+
export * from "./graph/index.js";
|
|
5
|
+
export * from "./query/index.js";
|
|
6
|
+
export * from "./worker/index.js";
|
|
7
|
+
export * from "./sources/git/index.js";
|
|
8
|
+
export * from "./sources/migrations/index.js";
|
|
9
|
+
export * from "./sources/workspace/index.js";
|
|
10
|
+
export * from "./scoping/index.js";
|
|
11
|
+
export * from "./contracts/index.js";
|
|
12
|
+
export * from "./capabilities/index.js";
|
|
13
|
+
export * from "./multipr/index.js";
|
|
14
|
+
export * from "./tiers/index.js";
|
|
15
|
+
export * from "./validation/index.js";
|
|
16
|
+
export * from "./ledger/index.js";
|
|
17
|
+
export * from "./recording/index.js";
|
|
18
|
+
export * from "./governance/index.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;AAE5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { candidateEnvNames, readDeclaredEnvValues, resolveAgainstDeclared, } from "./resolve.ts";
|
|
2
|
+
export type { DeclaredEnvValue, LedgerAccessorResolution, ResolvedValue, } from "./resolve.ts";
|
|
3
|
+
export { mintEdgesFromConfirmedFacts, MINT_PRODUCED_BY, MINT_SOURCE_ID, MINT_SOURCE_VERSION, } from "./mint.ts";
|
|
4
|
+
export type { EndpointLookup, MintedEdge, MintResult, OrphanedAnswer, UnjoinableAnswer, } from "./mint.ts";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ledger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ledger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DEC-223's answer half, minting side.
|
|
3
|
+
*
|
|
4
|
+
* `applyConfirmedFacts` (`../query/confirmed-facts.ts`) decides *which*
|
|
5
|
+
* refusal-ledger rows a confirmed fact answers. It deliberately does not
|
|
6
|
+
* mint an edge — it has no target to join against, and said so in its own
|
|
7
|
+
* header. This module owns that join.
|
|
8
|
+
*
|
|
9
|
+
* The confirmed base URL is testimony: it tells us the call is real, not
|
|
10
|
+
* dynamic, and gives a human's word for what the blocked expression
|
|
11
|
+
* evaluates to. It is **not** what identifies the endpoint. DEC-054 makes
|
|
12
|
+
* `API_ENDPOINT` identity `METHOD + normalisedPath`, base-independent by
|
|
13
|
+
* design — the same mechanism that lets a caller in one repository and a
|
|
14
|
+
* route in another join on nothing but a shared path template. What
|
|
15
|
+
* identifies the endpoint here is the row's own `attrs.path`/`attrs.method`
|
|
16
|
+
* — the relative path adapter-typescript already read from the call site,
|
|
17
|
+
* before the base blocked it (DEC-260's `templateSuffixAfterFirstSpan`).
|
|
18
|
+
*
|
|
19
|
+
* No match, no edge. A row whose candidate id is not in the supplied graph
|
|
20
|
+
* is reported as an orphan — never guessed into existence (rule 2) and
|
|
21
|
+
* never silently dropped (rule 5).
|
|
22
|
+
*/
|
|
23
|
+
import type { ConfirmedFact, IdentityScope, IREdge, UnresolvedRef } from "@descryy/ir";
|
|
24
|
+
import type { ConfirmedFactMatch } from "../query/confirmed-facts.ts";
|
|
25
|
+
/**
|
|
26
|
+
* This module's own `producedBy`, on the same pattern as `git-history`'s
|
|
27
|
+
* (`sources/git/source.ts`) — a core-owned synthetic producer, not a
|
|
28
|
+
* language adapter. A minted edge's invalidation is scoped to this id, never
|
|
29
|
+
* to whichever adapter produced the endpoint or the caller it joins.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MINT_SOURCE_ID = "ledger-mint";
|
|
32
|
+
export declare const MINT_SOURCE_VERSION = "0.1.0";
|
|
33
|
+
export declare const MINT_PRODUCED_BY = "ledger-mint@0.1.0";
|
|
34
|
+
export interface MintedEdge {
|
|
35
|
+
readonly edge: IREdge;
|
|
36
|
+
readonly ref: UnresolvedRef;
|
|
37
|
+
/** Every fact that grounded this edge — see `ConfirmedFactMatch.facts`; never narrowed to one. */
|
|
38
|
+
readonly facts: readonly ConfirmedFact[];
|
|
39
|
+
}
|
|
40
|
+
/** A row a confirmed fact answered, but whose candidate endpoint matches no known route. */
|
|
41
|
+
export interface OrphanedAnswer {
|
|
42
|
+
readonly ref: UnresolvedRef;
|
|
43
|
+
readonly path: string;
|
|
44
|
+
readonly method: string;
|
|
45
|
+
readonly candidateEndpointId: string;
|
|
46
|
+
}
|
|
47
|
+
/** A row a confirmed fact answered, but which carries no resolved path/method to join with at all. */
|
|
48
|
+
export interface UnjoinableAnswer {
|
|
49
|
+
readonly ref: UnresolvedRef;
|
|
50
|
+
readonly reason: string;
|
|
51
|
+
}
|
|
52
|
+
export interface MintResult {
|
|
53
|
+
readonly minted: readonly MintedEdge[];
|
|
54
|
+
readonly orphaned: readonly OrphanedAnswer[];
|
|
55
|
+
readonly unjoinable: readonly UnjoinableAnswer[];
|
|
56
|
+
}
|
|
57
|
+
/** The one thing mint needs from `AdjacencyProvider` — kept narrow rather than importing the whole query-layer type. */
|
|
58
|
+
export interface EndpointLookup {
|
|
59
|
+
node(id: string): {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
} | undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Join `applyConfirmedFacts`'s `answered` rows against a real endpoint graph.
|
|
65
|
+
*
|
|
66
|
+
* `scope` is the *caller's* identity scope (its own repo, plus the workspace
|
|
67
|
+
* it shares with whichever repository serves the route) — `API_ENDPOINT`
|
|
68
|
+
* being workspace-scoped means the repo half is discarded by `scopeOf`
|
|
69
|
+
* whenever a workspace is set, so passing the caller's own repo here is
|
|
70
|
+
* correct even though the target endpoint may live in a different one.
|
|
71
|
+
*
|
|
72
|
+
* `currentCommit` is the repo's `commitSha` for *this* run (`root.commitSha`
|
|
73
|
+
* at the call site) — compared against each fact's own `confirmedAtCommit`
|
|
74
|
+
* so a minted edge discloses whether the human answer it rests on was given
|
|
75
|
+
* against the code as it stands today. This is the disclosure floor named in
|
|
76
|
+
* the item this closes, not re-verification: nobody re-checks the fact
|
|
77
|
+
* against a live source, the edge just stops reading as unconditionally
|
|
78
|
+
* current when it isn't.
|
|
79
|
+
*/
|
|
80
|
+
export declare function mintEdgesFromConfirmedFacts(matches: readonly ConfirmedFactMatch[], endpoints: EndpointLookup, scope: IdentityScope, producedBy: string, currentCommit?: string): MintResult;
|
|
81
|
+
//# sourceMappingURL=mint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mint.d.ts","sourceRoot":"","sources":["../../src/ledger/mint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAA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kBAAkB,EAAE,EACtC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,MAAM,EAClB,aAAa,CAAC,EAAE,MAAM,GACrB,UAAU,CAkFZ"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DEC-223's answer half, minting side.
|
|
3
|
+
*
|
|
4
|
+
* `applyConfirmedFacts` (`../query/confirmed-facts.ts`) decides *which*
|
|
5
|
+
* refusal-ledger rows a confirmed fact answers. It deliberately does not
|
|
6
|
+
* mint an edge — it has no target to join against, and said so in its own
|
|
7
|
+
* header. This module owns that join.
|
|
8
|
+
*
|
|
9
|
+
* The confirmed base URL is testimony: it tells us the call is real, not
|
|
10
|
+
* dynamic, and gives a human's word for what the blocked expression
|
|
11
|
+
* evaluates to. It is **not** what identifies the endpoint. DEC-054 makes
|
|
12
|
+
* `API_ENDPOINT` identity `METHOD + normalisedPath`, base-independent by
|
|
13
|
+
* design — the same mechanism that lets a caller in one repository and a
|
|
14
|
+
* route in another join on nothing but a shared path template. What
|
|
15
|
+
* identifies the endpoint here is the row's own `attrs.path`/`attrs.method`
|
|
16
|
+
* — the relative path adapter-typescript already read from the call site,
|
|
17
|
+
* before the base blocked it (DEC-260's `templateSuffixAfterFirstSpan`).
|
|
18
|
+
*
|
|
19
|
+
* No match, no edge. A row whose candidate id is not in the supplied graph
|
|
20
|
+
* is reported as an orphan — never guessed into existence (rule 2) and
|
|
21
|
+
* never silently dropped (rule 5).
|
|
22
|
+
*/
|
|
23
|
+
import { endpointQsp, nodeId, reliabilityCap, reliabilityNote } from "@descryy/ir";
|
|
24
|
+
/**
|
|
25
|
+
* The evidence a minted edge rests on: a name-level path/method match against
|
|
26
|
+
* a real route, the same strength any other resolved `USES_API` join in this
|
|
27
|
+
* adapter carries (`extract.ts` mints those at `resolution: 2` too) — plus
|
|
28
|
+
* `humanAsserted: true` for the base itself, which `reliabilityCap` treats as
|
|
29
|
+
* a second, independent ceiling. At R2 with `nameLevel: true` the structural
|
|
30
|
+
* cap is A; `humanAsserted` pulls that down to B. Not asserted directly —
|
|
31
|
+
* computed below, so the class actually reported is whatever the two
|
|
32
|
+
* arguments produce, not a hardcoded "B".
|
|
33
|
+
*/
|
|
34
|
+
const MINT_RESOLUTION = 2;
|
|
35
|
+
const MINT_NAME_LEVEL = true;
|
|
36
|
+
const MINT_CONFIDENCE = 0.9;
|
|
37
|
+
/**
|
|
38
|
+
* This module's own `producedBy`, on the same pattern as `git-history`'s
|
|
39
|
+
* (`sources/git/source.ts`) — a core-owned synthetic producer, not a
|
|
40
|
+
* language adapter. A minted edge's invalidation is scoped to this id, never
|
|
41
|
+
* to whichever adapter produced the endpoint or the caller it joins.
|
|
42
|
+
*/
|
|
43
|
+
export const MINT_SOURCE_ID = "ledger-mint";
|
|
44
|
+
export const MINT_SOURCE_VERSION = "0.1.0";
|
|
45
|
+
export const MINT_PRODUCED_BY = `${MINT_SOURCE_ID}@${MINT_SOURCE_VERSION}`;
|
|
46
|
+
/**
|
|
47
|
+
* Join `applyConfirmedFacts`'s `answered` rows against a real endpoint graph.
|
|
48
|
+
*
|
|
49
|
+
* `scope` is the *caller's* identity scope (its own repo, plus the workspace
|
|
50
|
+
* it shares with whichever repository serves the route) — `API_ENDPOINT`
|
|
51
|
+
* being workspace-scoped means the repo half is discarded by `scopeOf`
|
|
52
|
+
* whenever a workspace is set, so passing the caller's own repo here is
|
|
53
|
+
* correct even though the target endpoint may live in a different one.
|
|
54
|
+
*
|
|
55
|
+
* `currentCommit` is the repo's `commitSha` for *this* run (`root.commitSha`
|
|
56
|
+
* at the call site) — compared against each fact's own `confirmedAtCommit`
|
|
57
|
+
* so a minted edge discloses whether the human answer it rests on was given
|
|
58
|
+
* against the code as it stands today. This is the disclosure floor named in
|
|
59
|
+
* the item this closes, not re-verification: nobody re-checks the fact
|
|
60
|
+
* against a live source, the edge just stops reading as unconditionally
|
|
61
|
+
* current when it isn't.
|
|
62
|
+
*/
|
|
63
|
+
export function mintEdgesFromConfirmedFacts(matches, endpoints, scope, producedBy, currentCommit) {
|
|
64
|
+
const minted = [];
|
|
65
|
+
const orphaned = [];
|
|
66
|
+
const unjoinable = [];
|
|
67
|
+
for (const match of matches) {
|
|
68
|
+
const { ref, facts } = match;
|
|
69
|
+
const path = ref.attrs?.["path"];
|
|
70
|
+
const method = ref.attrs?.["method"];
|
|
71
|
+
if (typeof path !== "string" || path === "" || typeof method !== "string" || method === "") {
|
|
72
|
+
unjoinable.push({
|
|
73
|
+
ref,
|
|
74
|
+
reason: "a confirmed value answers this row's blockedBy, but the row carries no resolved " +
|
|
75
|
+
"path/method to join against an endpoint — refusing rather than guessing one",
|
|
76
|
+
});
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const id = nodeId(scope, "API_ENDPOINT", endpointQsp(method, path), null);
|
|
80
|
+
const target = endpoints.node(id);
|
|
81
|
+
if (target === undefined) {
|
|
82
|
+
orphaned.push({ ref, path, method, candidateEndpointId: id });
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const reliabilityClass = reliabilityCap(MINT_RESOLUTION, MINT_NAME_LEVEL, true);
|
|
86
|
+
const note = reliabilityNote(MINT_RESOLUTION, MINT_NAME_LEVEL, true);
|
|
87
|
+
// Staleness disclosure (the item this closes): "current" only when both
|
|
88
|
+
// this run's commit and the fact's own commit are known and equal;
|
|
89
|
+
// "stale" when both are known and differ; "unknown" when either is
|
|
90
|
+
// missing — a fact confirmed before `confirmedAtCommit` existed, or a run
|
|
91
|
+
// with no commit available, is disclosed as unknown rather than assumed
|
|
92
|
+
// fresh. `staleFact` on the edge is `true` the moment any grounding fact
|
|
93
|
+
// is not affirmatively current, so a consumer can filter on one field
|
|
94
|
+
// without re-deriving this per-fact logic.
|
|
95
|
+
const factFreshness = facts.map((f) => {
|
|
96
|
+
const staleness = currentCommit === undefined || f.confirmedAtCommit === undefined
|
|
97
|
+
? "unknown"
|
|
98
|
+
: f.confirmedAtCommit === currentCommit
|
|
99
|
+
? "current"
|
|
100
|
+
: "stale";
|
|
101
|
+
return { fact: f, staleness };
|
|
102
|
+
});
|
|
103
|
+
const staleFact = factFreshness.some((f) => f.staleness !== "current");
|
|
104
|
+
minted.push({
|
|
105
|
+
ref,
|
|
106
|
+
facts,
|
|
107
|
+
edge: {
|
|
108
|
+
from: ref.fromNodeId,
|
|
109
|
+
to: id,
|
|
110
|
+
type: "USES_API",
|
|
111
|
+
resolution: MINT_RESOLUTION,
|
|
112
|
+
confidence: MINT_CONFIDENCE,
|
|
113
|
+
producedBy,
|
|
114
|
+
attrs: {
|
|
115
|
+
humanAsserted: true,
|
|
116
|
+
reliabilityClass,
|
|
117
|
+
reliabilityNote: note,
|
|
118
|
+
blockedBy: ref.attrs?.["blockedBy"],
|
|
119
|
+
staleFact,
|
|
120
|
+
// Every fact that answered this row, verbatim — never collapsed to
|
|
121
|
+
// one value. A row genuinely answered by facts scoped to two
|
|
122
|
+
// different environments stays disclosed as two, not silently
|
|
123
|
+
// narrowed to whichever sorted first.
|
|
124
|
+
confirmedFacts: factFreshness.map(({ fact: f, staleness }) => ({
|
|
125
|
+
value: f.value,
|
|
126
|
+
...(f.environment === undefined ? {} : { environment: f.environment }),
|
|
127
|
+
confirmedBy: f.confirmedBy,
|
|
128
|
+
confirmedAt: f.confirmedAt,
|
|
129
|
+
...(f.confirmedAtCommit === undefined ? {} : { confirmedAtCommit: f.confirmedAtCommit }),
|
|
130
|
+
staleness,
|
|
131
|
+
})),
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return { minted, orphaned, unjoinable };
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=mint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mint.js","sourceRoot":"","sources":["../../src/ledger/mint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAA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