@cavelang/store 0.15.0 → 0.20.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/README.md +22 -3
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/resolve.d.ts +105 -0
- package/dist/src/resolve.d.ts.map +1 -0
- package/dist/src/resolve.js +0 -0
- package/dist/src/resolve.js.map +1 -0
- package/dist/src/store.d.ts +65 -3
- package/dist/src/store.d.ts.map +1 -1
- package/dist/src/store.js +143 -23
- package/dist/src/store.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/resolve.ts +0 -0
- package/src/store.ts +182 -25
package/README.md
CHANGED
|
@@ -52,6 +52,19 @@ store.exportText({ current: true }) // canonical CAVE text back out
|
|
|
52
52
|
different actors keeps separate belief series (§9.4). A written `@src:`
|
|
53
53
|
always wins; `raw_line` stays as authored. Interchange replay (`cave
|
|
54
54
|
import`) passes no source, preserving exported keys.
|
|
55
|
+
- **Contradiction resolution is opt-in** (§26): `{ resolve: true }` on
|
|
56
|
+
traversal reads only the winners — coexisting series about one fact
|
|
57
|
+
(claim key modulo `src:` contexts and polarity) collapse to the row the
|
|
58
|
+
policy picks: precedence class (max over the row's sources), then
|
|
59
|
+
reliability-weighted confidence (min over sources), then tx. The policy
|
|
60
|
+
merges a built-in ladder (`cli` 4 > `agent`/`action` 3 > root 2 >
|
|
61
|
+
`rule` 1) with in-band `source/<name> HAS precedence:` /
|
|
62
|
+
`HAS reliability:` claims, matched to `src:` contexts by longest
|
|
63
|
+
segment prefix; the declarations themselves resolve under the built-ins
|
|
64
|
+
alone, so ingested text cannot self-elevate. Winners come back
|
|
65
|
+
verbatim — resolution filters, it never rewrites — and it composes with
|
|
66
|
+
`aliases`, which widens groups through the closure (the §13.6
|
|
67
|
+
pick-a-winner story).
|
|
55
68
|
|
|
56
69
|
## API
|
|
57
70
|
|
|
@@ -61,6 +74,9 @@ store.exportText({ current: true }) // canonical CAVE text back out
|
|
|
61
74
|
| `insertResult(result, {source})` | | append a pre-canonicalized `@cavelang/canonical` result |
|
|
62
75
|
| `currentBeliefs({minConf})` | §13.5 | latest row per key |
|
|
63
76
|
| `currentBelief(key)` / `history(key)` | §9.1 | one fact's belief series |
|
|
77
|
+
| `resolvedBeliefs({aliases})` | §26 | one winner per resolution group |
|
|
78
|
+
| `contested({aliases})` | §26.4 | contested groups, candidates ranked winner-first — the fusion feed |
|
|
79
|
+
| `resolutionPolicy()` | §26.3 | effective policy: built-ins merged with in-band declarations |
|
|
64
80
|
| `claimsAbout(entity, {aliases})` | §13.5 | both directions, all rows |
|
|
65
81
|
| `forward(entity)` / `reverse(entity)` | §13.3 | named traversal, inverse-aware |
|
|
66
82
|
| `aliasesOf(entity)` | §13.6 | the entity's alias closure |
|
|
@@ -104,6 +120,9 @@ Covers the §9.1 belief series, §5.5 one-fact-two-names invariants
|
|
|
104
120
|
materialized inverses), every §13.5 query, the §13.6 alias closure
|
|
105
121
|
(merge, unmerge by retraction, opt-in traversal, union semantics), the
|
|
106
122
|
§9.5 provenance stamping (written `@src:` wins, per-actor series,
|
|
107
|
-
cross-actor retraction, stamped round-trips), the §
|
|
108
|
-
|
|
109
|
-
|
|
123
|
+
cross-actor retraction, stamped round-trips), the §26 resolution policy
|
|
124
|
+
(human-over-ingest precedence, reliability weighting, longest-prefix
|
|
125
|
+
specificity, polarity contests, no self-elevation, alias-widened
|
|
126
|
+
groups, contested ranking), the §11.2 topic reads, edge persistence,
|
|
127
|
+
registry rebuild across reopen, transactional strict ingest and export
|
|
128
|
+
round-trips.
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAChD,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAChD,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/src/index.js
CHANGED
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contradiction resolution (spec §26) — the explicit, configurable policy
|
|
3
|
+
* that picks one winner per fact among coexisting current beliefs.
|
|
4
|
+
*
|
|
5
|
+
* §9.4 tolerates contradictions at write time; §9.5 actor stamps, content
|
|
6
|
+
* sources, negation and aliased names (§13.6) all fork belief series about
|
|
7
|
+
* one fact on purpose. Latest-tx resolves *within* a series; this module
|
|
8
|
+
* resolves *across* them:
|
|
9
|
+
*
|
|
10
|
+
* - the **resolution group** of a current row is its claim key with every
|
|
11
|
+
* `src:` context removed and the negation flag dropped (§26.1) —
|
|
12
|
+
* sources say who asserted a fact, polarity is the contest;
|
|
13
|
+
* - **candidates** are the current row of each series in the group,
|
|
14
|
+
* excluding retracted rows (`@ 0%` neither wins nor blocks);
|
|
15
|
+
* - the **winner** compares precedence class (max over the row's
|
|
16
|
+
* sources), then reliability-weighted confidence (min over sources),
|
|
17
|
+
* then latest tx (§26.2);
|
|
18
|
+
* - the policy is declared **in-band** as `source/<name> HAS precedence:`
|
|
19
|
+
* / `HAS reliability:` claims matched to `src:` contexts by longest
|
|
20
|
+
* path prefix (§26.3), over the built-in ladder below. Policy claims
|
|
21
|
+
* themselves resolve under the built-ins alone — bootstrapping ends
|
|
22
|
+
* there, so an ingested document can never elevate its own batch above
|
|
23
|
+
* the humans and agents it is answerable to.
|
|
24
|
+
*
|
|
25
|
+
* Resolution is a read mode: nothing is rewritten, the winner is a stored
|
|
26
|
+
* row returned verbatim.
|
|
27
|
+
*/
|
|
28
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
29
|
+
import type * as Row from './row.ts';
|
|
30
|
+
/** One effective policy entry (spec §26.3). */
|
|
31
|
+
export type Entry = {
|
|
32
|
+
/**
|
|
33
|
+
* `source/`-relative path the entry covers by whole-segment prefix:
|
|
34
|
+
* `''` is the root (every source, and rows with no source), `'cli'`,
|
|
35
|
+
* `'agent'`, `'ingest/93a0'`. The most specific match of each
|
|
36
|
+
* dimension applies.
|
|
37
|
+
*/
|
|
38
|
+
readonly prefix: string;
|
|
39
|
+
/** Precedence class — higher outranks (spec §26.2). */
|
|
40
|
+
readonly precedence?: number;
|
|
41
|
+
/** Reliability weight `0..1` multiplying stored confidence (spec §26.2). */
|
|
42
|
+
readonly reliability?: number;
|
|
43
|
+
};
|
|
44
|
+
/** A current row scored and ranked inside its resolution group. */
|
|
45
|
+
export type Ranked = Row.t & {
|
|
46
|
+
/** The resolution group key (claim key modulo `src:` contexts and polarity). */
|
|
47
|
+
readonly res_group: string;
|
|
48
|
+
/** Precedence class of the row's sources (spec §26.2). */
|
|
49
|
+
readonly res_class: number;
|
|
50
|
+
/** Reliability-weighted confidence — ranks, never rewrites `conf`. */
|
|
51
|
+
readonly res_conf: number;
|
|
52
|
+
/** 1 = the group's winner. */
|
|
53
|
+
readonly res_rank: number;
|
|
54
|
+
};
|
|
55
|
+
/** A fact more than one series currently speaks about (spec §26.4). */
|
|
56
|
+
export type Contested = {
|
|
57
|
+
/** The resolution group key. */
|
|
58
|
+
readonly group: string;
|
|
59
|
+
/** Candidates ranked by the policy — the winner first. */
|
|
60
|
+
readonly rows: readonly Ranked[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The built-in default ladder (spec §26.3): human corrections outrank
|
|
64
|
+
* agent writes, which outrank source material (content sources,
|
|
65
|
+
* `connect`, `ingest`, unstamped rows), which outranks derived claims.
|
|
66
|
+
* Overridable by declaring the same subject in-band.
|
|
67
|
+
*/
|
|
68
|
+
export declare const builtins: readonly Entry[];
|
|
69
|
+
/**
|
|
70
|
+
* Reads the effective resolution policy (spec §26.3): the built-in ladder
|
|
71
|
+
* merged with current positive in-band `source[/<path>] HAS precedence:`
|
|
72
|
+
* / `HAS reliability:` declarations. When several series declare one
|
|
73
|
+
* (subject, dimension) — different actors, per §9.5 — the contest is
|
|
74
|
+
* resolved under the **built-ins alone**: class of the declaring sources,
|
|
75
|
+
* then confidence, then tx.
|
|
76
|
+
*
|
|
77
|
+
* `currentSql` is the current-belief universe to read declarations from —
|
|
78
|
+
* the caller's, so an as-of query reads the policy as of its boundary
|
|
79
|
+
* (§12.3).
|
|
80
|
+
*/
|
|
81
|
+
export declare const readPolicy: (db: DatabaseSync, currentSql: string) => Entry[];
|
|
82
|
+
/**
|
|
83
|
+
* SQL over `currentSql` (a current-belief SELECT, §13.5) scoring and
|
|
84
|
+
* ranking every supported current row inside its resolution group
|
|
85
|
+
* (spec §26.1–§26.2): the row columns plus `res_group`, `res_class`,
|
|
86
|
+
* `res_conf` (reliability-weighted) and `res_rank` (1 = winner).
|
|
87
|
+
*
|
|
88
|
+
* With `aliases`, group keys widen through the alias closure — the
|
|
89
|
+
* caller MUST have an `alias_pair(a, b)` recursive CTE in scope (the
|
|
90
|
+
* §13.6 transitive closure over current positive `ALIAS` edges); entity
|
|
91
|
+
* parts of the key resolve to their closure group's smallest name, for
|
|
92
|
+
* grouping only — returned rows keep their stored spelling.
|
|
93
|
+
*/
|
|
94
|
+
export declare const rankedSql: (entries: readonly Entry[], currentSql: string, options?: {
|
|
95
|
+
aliases?: boolean;
|
|
96
|
+
}) => string;
|
|
97
|
+
/**
|
|
98
|
+
* SQL for the resolved universe (spec §26.4): one winner row per
|
|
99
|
+
* resolution group, plain `cave_claim` columns. Same `aliases` contract
|
|
100
|
+
* as {@link rankedSql}.
|
|
101
|
+
*/
|
|
102
|
+
export declare const resolvedSql: (entries: readonly Entry[], currentSql: string, options?: {
|
|
103
|
+
aliases?: boolean;
|
|
104
|
+
}) => string;
|
|
105
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,KAAK,GAAG,MAA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M,WAAW,GAAG,CACzB,OAAyB,EACzB,UAAkB,EAClB,UAAiC,EAAE,EAC3B,EAAE,CACV,UAAU,YAAY,UAAU,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,sBAAsB,CAAA"}
|
package/dist/src/store.d.ts
CHANGED
|
@@ -11,16 +11,24 @@
|
|
|
11
11
|
* lines via FTS5;
|
|
12
12
|
* - appends can stamp actor provenance (spec §9.5): pass `source` and every
|
|
13
13
|
* claim without a `src:` context gets `@src:<actor>` — applied before the
|
|
14
|
-
* claim key is computed, so different actors keep separate belief series
|
|
14
|
+
* claim key is computed, so different actors keep separate belief series;
|
|
15
|
+
* - contradiction resolution (spec §26): coexisting series about one fact
|
|
16
|
+
* resolve to one winner by precedence class, reliability-weighted
|
|
17
|
+
* confidence and tx — `resolvedBeliefs`, `contested`, and the `resolve`
|
|
18
|
+
* traversal opt-in.
|
|
15
19
|
*/
|
|
16
20
|
import { DatabaseSync } from 'node:sqlite';
|
|
17
21
|
import { Claim } from '@cavelang/core';
|
|
18
22
|
import * as Canonical from '@cavelang/canonical';
|
|
23
|
+
import * as Resolve from './resolve.ts';
|
|
19
24
|
import * as Row from './row.ts';
|
|
20
25
|
export type IngestResult = {
|
|
21
|
-
/** ids of
|
|
26
|
+
/** ids of the batch's claim rows, in document order — for a row skipped as already present (`ids` replay, spec §28.1), the existing id. */
|
|
22
27
|
readonly ids: readonly string[];
|
|
28
|
+
/** Edges actually inserted (an identity replay skips edges already stored). */
|
|
23
29
|
readonly edges: number;
|
|
30
|
+
/** Rows skipped because their explicit id already exists (spec §28.1); always 0 without `ids`. */
|
|
31
|
+
readonly skipped: number;
|
|
24
32
|
readonly problems: readonly Canonical.Problem[];
|
|
25
33
|
};
|
|
26
34
|
export type AppendOptions = {
|
|
@@ -33,6 +41,15 @@ export type AppendOptions = {
|
|
|
33
41
|
* preserve claim keys as exported.
|
|
34
42
|
*/
|
|
35
43
|
readonly source?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Explicit row identity (spec §28.1), index-aligned with the result's
|
|
46
|
+
* claims: a claim with an id here is replayed under it — inserted with
|
|
47
|
+
* `id = tx = ids[i]` when absent, skipped when the store already has the
|
|
48
|
+
* row — and the generator observes it (spec §28.2). Claims without an
|
|
49
|
+
* entry mint fresh ids as usual. Edges deduplicate against stored edges
|
|
50
|
+
* in this mode, so replaying a sync export is idempotent end to end.
|
|
51
|
+
*/
|
|
52
|
+
readonly ids?: readonly (undefined | string)[];
|
|
36
53
|
};
|
|
37
54
|
export type ForwardFact = {
|
|
38
55
|
/** Canonical (primary) verb. */
|
|
@@ -59,6 +76,14 @@ export type TraverseOptions = {
|
|
|
59
76
|
* Union-of-rows: matching widens, returned rows keep their stored names.
|
|
60
77
|
*/
|
|
61
78
|
readonly aliases?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Traverse resolved winners only (spec §26, default `false`): when
|
|
81
|
+
* several series assert one fact — actor stamps, content sources,
|
|
82
|
+
* polarity — the resolution policy picks one and the rest are
|
|
83
|
+
* invisible. Composes with `aliases`, which widens resolution groups
|
|
84
|
+
* through the closure.
|
|
85
|
+
*/
|
|
86
|
+
readonly resolve?: boolean;
|
|
62
87
|
};
|
|
63
88
|
export type Store = ReturnType<typeof open>;
|
|
64
89
|
/**
|
|
@@ -81,6 +106,13 @@ export declare const open: (path?: string, options?: {
|
|
|
81
106
|
db: DatabaseSync;
|
|
82
107
|
/** Current verb registry (input registry + stored + ingested declarations). */
|
|
83
108
|
registry: () => Canonical.Registry.t;
|
|
109
|
+
/**
|
|
110
|
+
* Rebuilds the registry from the base plus stored declarations — after
|
|
111
|
+
* rows arrive outside `ingest`/`insertResult` (a §28 merge writes
|
|
112
|
+
* through SQL), merged in-band declarations take effect without
|
|
113
|
+
* reopening.
|
|
114
|
+
*/
|
|
115
|
+
reloadRegistry(): void;
|
|
84
116
|
/**
|
|
85
117
|
* Runs `body` atomically; throwing rolls everything back, including
|
|
86
118
|
* nested appends and their registry declarations. Nestable
|
|
@@ -107,6 +139,32 @@ export declare const open: (path?: string, options?: {
|
|
|
107
139
|
currentBelief(claimKey: string): undefined | Row.t;
|
|
108
140
|
/** Full belief series of one claim key, oldest first (spec §9.1). */
|
|
109
141
|
history(claimKey: string): Row.t[];
|
|
142
|
+
/**
|
|
143
|
+
* The effective resolution policy (spec §26.3): the built-in ladder
|
|
144
|
+
* merged with current in-band `source[/<path>] HAS precedence:` /
|
|
145
|
+
* `HAS reliability:` declarations, sorted by prefix.
|
|
146
|
+
*/
|
|
147
|
+
resolutionPolicy(): Resolve.Entry[];
|
|
148
|
+
/**
|
|
149
|
+
* Resolved current beliefs (spec §26): one winner per resolution
|
|
150
|
+
* group — coexisting series about one fact (actor stamps, content
|
|
151
|
+
* sources, polarity) collapse to the row the policy picks; the rest
|
|
152
|
+
* are invisible. Oldest first, rows returned verbatim. With
|
|
153
|
+
* `aliases`, groups widen through the alias closure (spec §26.1).
|
|
154
|
+
*/
|
|
155
|
+
resolvedBeliefs(options_?: {
|
|
156
|
+
aliases?: boolean;
|
|
157
|
+
}): Row.t[];
|
|
158
|
+
/**
|
|
159
|
+
* Contested facts (spec §26.4): resolution groups where more than one
|
|
160
|
+
* candidate currently speaks, each candidate scored (`res_class`,
|
|
161
|
+
* `res_conf`) and ranked — the winner first. The feed for fusion
|
|
162
|
+
* (§10.1 combines a contested group's numeric estimates instead of
|
|
163
|
+
* picking) and for the `cave resolve` view.
|
|
164
|
+
*/
|
|
165
|
+
contested(options_?: {
|
|
166
|
+
aliases?: boolean;
|
|
167
|
+
}): Resolve.Contested[];
|
|
110
168
|
/**
|
|
111
169
|
* The alias closure of an entity (spec §13.6): the entity itself plus
|
|
112
170
|
* every name reachable through current positive `ALIAS` claims, read as
|
|
@@ -165,7 +223,10 @@ export declare const open: (path?: string, options?: {
|
|
|
165
223
|
toClaim: (row: Row.t) => Claim.t;
|
|
166
224
|
/**
|
|
167
225
|
* Emits the store as canonical CAVE text — all rows in transaction
|
|
168
|
-
* order, or only current beliefs with `current`.
|
|
226
|
+
* order, or only current beliefs with `current`. With `tx`, every
|
|
227
|
+
* claim line is preceded by its §28.4 transaction annotation
|
|
228
|
+
* (`;@ <tx>`), so the text carries row identity: `cave sync` replays
|
|
229
|
+
* it idempotently, plain `cave import` reads it unchanged.
|
|
169
230
|
*
|
|
170
231
|
* In current-only export an edge endpoint may be a superseded row;
|
|
171
232
|
* dropping such edges would silently un-condition current claims and
|
|
@@ -175,6 +236,7 @@ export declare const open: (path?: string, options?: {
|
|
|
175
236
|
*/
|
|
176
237
|
exportText(options_?: {
|
|
177
238
|
current?: boolean;
|
|
239
|
+
tx?: boolean;
|
|
178
240
|
}): string;
|
|
179
241
|
close(): void;
|
|
180
242
|
};
|
package/dist/src/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,KAAK,EAA8B,MAAM,gBAAgB,CAAA;AAClE,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAmD/B,MAAM,MAAM,YAAY,GAAG;IACzB,2IAA2I;IAC3I,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAA;IAC/B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,kGAAkG;IAClG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,SAAS,CAAC,OAAO,EAAE,CAAA;CAChD,CAAA;AAED,MAAM,MAAM,aAA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Y,eAAe,GAAQ,MAAM,EAAE;IAOrE,8EAA8E;qBAC7D,MAAM,aAAY,eAAe,GAAQ,MAAM,EAAE;IAOlE;;;;;OAKG;kBACW,MAAM,aAAY;QAAE,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE,GAAQ,GAAG,CAAC,CAAC,EAAE;IAOhE;;;;;;;OAOG;uBACgB,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,IAAI;IAQpG,4DAA4D;sBAC1C,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAA;KAAE,EAAE;IAO3D,6EAA6E;mBAzQzD,GAAG,CAAC,CAAC,KAAG,KAAK,CAAC,CAAC;IA4QnC;;;;;;;;;;;;OAYG;0BACkB;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,EAAE,CAAC,EAAE,OAAO,CAAA;KAAE,GAAQ,MAAM;aAsC7D,IAAI;CAIhB,CAAA"}
|
package/dist/src/store.js
CHANGED
|
@@ -11,11 +11,16 @@
|
|
|
11
11
|
* lines via FTS5;
|
|
12
12
|
* - appends can stamp actor provenance (spec §9.5): pass `source` and every
|
|
13
13
|
* claim without a `src:` context gets `@src:<actor>` — applied before the
|
|
14
|
-
* claim key is computed, so different actors keep separate belief series
|
|
14
|
+
* claim key is computed, so different actors keep separate belief series;
|
|
15
|
+
* - contradiction resolution (spec §26): coexisting series about one fact
|
|
16
|
+
* resolve to one winner by precedence class, reliability-weighted
|
|
17
|
+
* confidence and tx — `resolvedBeliefs`, `contested`, and the `resolve`
|
|
18
|
+
* traversal opt-in.
|
|
15
19
|
*/
|
|
16
20
|
import { DatabaseSync } from 'node:sqlite';
|
|
17
21
|
import { Claim, Context, Key, Uuidv7, Verb } from '@cavelang/core';
|
|
18
22
|
import * as Canonical from '@cavelang/canonical';
|
|
23
|
+
import * as Resolve from "./resolve.js";
|
|
19
24
|
import * as Row from "./row.js";
|
|
20
25
|
import * as Schema from "./schema.js";
|
|
21
26
|
const currentSql = `
|
|
@@ -26,24 +31,40 @@ JOIN (
|
|
|
26
31
|
) latest ON c.claim_key = latest.claim_key AND c.tx = latest.max_tx
|
|
27
32
|
`;
|
|
28
33
|
/**
|
|
29
|
-
* Alias
|
|
30
|
-
*
|
|
31
|
-
* claim key — both assert the same link)
|
|
32
|
-
*
|
|
33
|
-
* The seed is the query's single positional parameter.
|
|
34
|
+
* Alias edges (spec §13.6): current positive `ALIAS` claims read as
|
|
35
|
+
* undirected (`ALIAS` has no `REVERSE`, so each written direction is its
|
|
36
|
+
* own claim key — both assert the same link). Retraction unmerges:
|
|
37
|
+
* `a ALIAS b @ 0%` drops that direction's edge.
|
|
34
38
|
*/
|
|
35
|
-
const
|
|
36
|
-
WITH RECURSIVE alias_edge(a, b) AS (
|
|
39
|
+
const aliasEdgeSql = `alias_edge(a, b) AS (
|
|
37
40
|
SELECT c.subject, c.object FROM (${currentSql}) c
|
|
38
41
|
WHERE c.verb = 'ALIAS' AND c.negated = 0 AND c.conf > 0 AND c.object IS NOT NULL
|
|
39
42
|
UNION
|
|
40
43
|
SELECT c.object, c.subject FROM (${currentSql}) c
|
|
41
44
|
WHERE c.verb = 'ALIAS' AND c.negated = 0 AND c.conf > 0 AND c.object IS NOT NULL
|
|
42
|
-
)
|
|
45
|
+
)`;
|
|
46
|
+
/**
|
|
47
|
+
* The closure walked from a seed entity — the seed is the query's first
|
|
48
|
+
* positional parameter. Requires `alias_edge` in scope.
|
|
49
|
+
*/
|
|
50
|
+
const aliasSeedSql = `alias_closure(name) AS (
|
|
43
51
|
SELECT ?
|
|
44
52
|
UNION
|
|
45
53
|
SELECT e.b FROM alias_closure s JOIN alias_edge e ON e.a = s.name
|
|
46
|
-
)
|
|
54
|
+
)`;
|
|
55
|
+
/**
|
|
56
|
+
* The full transitive closure as ordered pairs — every two names currently
|
|
57
|
+
* believed to denote one entity. Resolution grouping widens through it
|
|
58
|
+
* (spec §26.1). Requires `alias_edge` in scope.
|
|
59
|
+
*/
|
|
60
|
+
const aliasPairSql = `alias_pair(a, b) AS (
|
|
61
|
+
SELECT a, b FROM alias_edge
|
|
62
|
+
UNION
|
|
63
|
+
SELECT p.a, e.b FROM alias_pair p JOIN alias_edge e ON e.a = p.b
|
|
64
|
+
)`;
|
|
65
|
+
/** Seeded alias closure (spec §13.6), ready to prefix a SELECT. */
|
|
66
|
+
const aliasClosureSql = `
|
|
67
|
+
WITH RECURSIVE ${aliasEdgeSql}, ${aliasSeedSql}
|
|
47
68
|
`;
|
|
48
69
|
/** Stamps `@src:<source>` on a claim without a source context (spec §9.5). */
|
|
49
70
|
const stampSource = (claim, source) => source === undefined || Context.hasSource(claim.contexts) ?
|
|
@@ -66,7 +87,15 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
66
87
|
const db = new DatabaseSync(path);
|
|
67
88
|
db.exec('PRAGMA foreign_keys = ON');
|
|
68
89
|
Schema.init(db);
|
|
69
|
-
|
|
90
|
+
// The receive rule (spec §28.2): the store, not the wall clock, is the
|
|
91
|
+
// monotonic authority — every append outsorts every tx already stored,
|
|
92
|
+
// merged history from fast-clocked origins included.
|
|
93
|
+
const maxTx = db.prepare('SELECT MAX(tx) AS tx FROM cave_claim').get();
|
|
94
|
+
if (maxTx?.tx != null) {
|
|
95
|
+
Uuidv7.observe(maxTx.tx);
|
|
96
|
+
}
|
|
97
|
+
const baseRegistry = options.registry ?? Canonical.standardRegistry;
|
|
98
|
+
let registry = baseRegistry;
|
|
70
99
|
const insertClaim = db.prepare(`
|
|
71
100
|
INSERT INTO cave_claim (
|
|
72
101
|
id, tx, subject, verb, negated, object, attribute,
|
|
@@ -138,12 +167,27 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
138
167
|
transactionDepth -= 1;
|
|
139
168
|
}
|
|
140
169
|
};
|
|
170
|
+
const claimExists = db.prepare('SELECT 1 FROM cave_claim WHERE id = ?');
|
|
171
|
+
const edgeExists = db.prepare('SELECT 1 FROM cave_edge WHERE parent_id = ? AND role = ? AND child_id = ?');
|
|
141
172
|
/** Appends a canonicalization result — one row per claim, per-row tx. */
|
|
142
173
|
const insertResult = (result, options_ = {}) => transaction(() => {
|
|
143
174
|
const ids = [];
|
|
144
|
-
|
|
175
|
+
const replay = options_.ids !== undefined;
|
|
176
|
+
let skipped = 0;
|
|
177
|
+
result.claims.forEach((entry, index) => {
|
|
178
|
+
const explicit = options_.ids?.[index];
|
|
179
|
+
if (explicit !== undefined) {
|
|
180
|
+
// Identity replay (spec §28.1): the id is the row — present means
|
|
181
|
+
// merged already; either way subsequent mints outsort it (§28.2).
|
|
182
|
+
Uuidv7.observe(explicit);
|
|
183
|
+
if (claimExists.get(explicit) !== undefined) {
|
|
184
|
+
skipped += 1;
|
|
185
|
+
ids.push(explicit);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
145
189
|
const claim = stampSource(entry.claim, options_.source);
|
|
146
|
-
const id = Uuidv7.next();
|
|
190
|
+
const id = explicit ?? Uuidv7.next();
|
|
147
191
|
const columns = Row.toColumns(claim);
|
|
148
192
|
const rawLine = columns.rawLine === '' ? Canonical.emitClaim(claim) : columns.rawLine;
|
|
149
193
|
insertClaim.run(id, id, columns.subject, columns.verb, columns.negated, columns.object, columns.attribute, columns.valueText, columns.valueNum, columns.valueUnit, columns.valueApprox, columns.deltaText, columns.deltaNum, columns.deltaUnit, columns.sigmaLevel, columns.conf, columns.importance, columns.comment, rawLine, Key.of(claim));
|
|
@@ -155,12 +199,19 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
155
199
|
}
|
|
156
200
|
insertFts.run(id, columns.subject, columns.verb, columns.object, columns.attribute, columns.valueText, columns.comment, rawLine);
|
|
157
201
|
ids.push(id);
|
|
158
|
-
}
|
|
202
|
+
});
|
|
203
|
+
let edges = 0;
|
|
159
204
|
for (const edge of result.edges) {
|
|
160
|
-
|
|
205
|
+
const parentId = ids[edge.parent];
|
|
206
|
+
const childId = ids[edge.child];
|
|
207
|
+
if (replay && edgeExists.get(parentId, edge.role, childId) !== undefined) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
insertEdge.run(parentId, edge.role, childId);
|
|
211
|
+
edges += 1;
|
|
161
212
|
}
|
|
162
213
|
registry = result.registry;
|
|
163
|
-
return { ids, edges
|
|
214
|
+
return { ids, edges, skipped, problems: result.problems };
|
|
164
215
|
});
|
|
165
216
|
const rows = (sql, ...params) => db.prepare(sql).all(...params);
|
|
166
217
|
const contextsOf = (id) => db.prepare('SELECT context FROM cave_context WHERE claim_id = ?').all(id)
|
|
@@ -176,12 +227,35 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
176
227
|
* must be prepended when `aliases` is set).
|
|
177
228
|
*/
|
|
178
229
|
const entityMatch = (column, options) => options.aliases === true ? `${column} IN (SELECT name FROM alias_closure)` : `${column} = ?`;
|
|
179
|
-
const withAliases = (options) => options.aliases === true ?
|
|
230
|
+
const withAliases = (options) => options.aliases === true ?
|
|
231
|
+
// Resolution grouping needs the pair closure too (spec §26.1).
|
|
232
|
+
(options.resolve === true ?
|
|
233
|
+
`\nWITH RECURSIVE ${aliasEdgeSql}, ${aliasPairSql}, ${aliasSeedSql}\n` :
|
|
234
|
+
aliasClosureSql) :
|
|
235
|
+
'';
|
|
236
|
+
const readPolicy = () => Resolve.readPolicy(db, currentSql);
|
|
237
|
+
/**
|
|
238
|
+
* Row universe of a traversal: current beliefs, or the §26 resolved
|
|
239
|
+
* winners among them when `resolve` is set.
|
|
240
|
+
*/
|
|
241
|
+
const universe = (options) => options.resolve === true ?
|
|
242
|
+
Resolve.resolvedSql(readPolicy(), currentSql, { aliases: options.aliases === true }) :
|
|
243
|
+
currentSql;
|
|
180
244
|
return {
|
|
181
245
|
/** Raw database handle — used by `@cavelang/query`; treat as read-only. */
|
|
182
246
|
db,
|
|
183
247
|
/** Current verb registry (input registry + stored + ingested declarations). */
|
|
184
248
|
registry: () => registry,
|
|
249
|
+
/**
|
|
250
|
+
* Rebuilds the registry from the base plus stored declarations — after
|
|
251
|
+
* rows arrive outside `ingest`/`insertResult` (a §28 merge writes
|
|
252
|
+
* through SQL), merged in-band declarations take effect without
|
|
253
|
+
* reopening.
|
|
254
|
+
*/
|
|
255
|
+
reloadRegistry() {
|
|
256
|
+
registry = baseRegistry;
|
|
257
|
+
rebuildRegistry();
|
|
258
|
+
},
|
|
185
259
|
/**
|
|
186
260
|
* Runs `body` atomically; throwing rolls everything back, including
|
|
187
261
|
* nested appends and their registry declarations. Nestable
|
|
@@ -220,6 +294,49 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
220
294
|
history(claimKey) {
|
|
221
295
|
return rows('SELECT * FROM cave_claim WHERE claim_key = ? ORDER BY tx', claimKey);
|
|
222
296
|
},
|
|
297
|
+
/**
|
|
298
|
+
* The effective resolution policy (spec §26.3): the built-in ladder
|
|
299
|
+
* merged with current in-band `source[/<path>] HAS precedence:` /
|
|
300
|
+
* `HAS reliability:` declarations, sorted by prefix.
|
|
301
|
+
*/
|
|
302
|
+
resolutionPolicy() {
|
|
303
|
+
return readPolicy();
|
|
304
|
+
},
|
|
305
|
+
/**
|
|
306
|
+
* Resolved current beliefs (spec §26): one winner per resolution
|
|
307
|
+
* group — coexisting series about one fact (actor stamps, content
|
|
308
|
+
* sources, polarity) collapse to the row the policy picks; the rest
|
|
309
|
+
* are invisible. Oldest first, rows returned verbatim. With
|
|
310
|
+
* `aliases`, groups widen through the alias closure (spec §26.1).
|
|
311
|
+
*/
|
|
312
|
+
resolvedBeliefs(options_ = {}) {
|
|
313
|
+
const aliases = options_.aliases === true;
|
|
314
|
+
const prefix = aliases ? `WITH RECURSIVE ${aliasEdgeSql}, ${aliasPairSql}\n` : '';
|
|
315
|
+
return rows(`${prefix}SELECT * FROM (${Resolve.resolvedSql(readPolicy(), currentSql, { aliases })}) ORDER BY tx`);
|
|
316
|
+
},
|
|
317
|
+
/**
|
|
318
|
+
* Contested facts (spec §26.4): resolution groups where more than one
|
|
319
|
+
* candidate currently speaks, each candidate scored (`res_class`,
|
|
320
|
+
* `res_conf`) and ranked — the winner first. The feed for fusion
|
|
321
|
+
* (§10.1 combines a contested group's numeric estimates instead of
|
|
322
|
+
* picking) and for the `cave resolve` view.
|
|
323
|
+
*/
|
|
324
|
+
contested(options_ = {}) {
|
|
325
|
+
const aliases = options_.aliases === true;
|
|
326
|
+
const prefix = aliases ? `WITH RECURSIVE ${aliasEdgeSql}, ${aliasPairSql}\n` : '';
|
|
327
|
+
const ranked = rows(`${prefix}SELECT * FROM (${Resolve.rankedSql(readPolicy(), currentSql, { aliases })}) ORDER BY res_group, res_rank`);
|
|
328
|
+
const groups = [];
|
|
329
|
+
for (const row of ranked) {
|
|
330
|
+
const last = groups[groups.length - 1];
|
|
331
|
+
if (last !== undefined && last.group === row.res_group) {
|
|
332
|
+
last.rows.push(row);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
groups.push({ group: row.res_group, rows: [row] });
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return groups.filter(group => group.rows.length > 1);
|
|
339
|
+
},
|
|
223
340
|
/**
|
|
224
341
|
* The alias closure of an entity (spec §13.6): the entity itself plus
|
|
225
342
|
* every name reachable through current positive `ALIAS` claims, read as
|
|
@@ -241,7 +358,7 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
241
358
|
},
|
|
242
359
|
/** Forward reads: current relational facts with `entity` as subject (spec §13.3). */
|
|
243
360
|
forward(entity, options_ = {}) {
|
|
244
|
-
return rows(`${withAliases(options_)} SELECT * FROM (${
|
|
361
|
+
return rows(`${withAliases(options_)} SELECT * FROM (${universe(options_)}) WHERE ${entityMatch('subject', options_)} AND object IS NOT NULL${traversalFilter(options_)} ORDER BY tx`, entity).map(row => ({ verb: row.verb, target: row.object, row }));
|
|
245
362
|
},
|
|
246
363
|
/**
|
|
247
364
|
* Inverse reads (spec §13.3): current relational facts
|
|
@@ -249,7 +366,7 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
249
366
|
* when one is declared.
|
|
250
367
|
*/
|
|
251
368
|
reverse(entity, options_ = {}) {
|
|
252
|
-
return rows(`${withAliases(options_)} SELECT * FROM (${
|
|
369
|
+
return rows(`${withAliases(options_)} SELECT * FROM (${universe(options_)}) WHERE ${entityMatch('object', options_)} AND object IS NOT NULL${traversalFilter(options_)} ORDER BY tx`, entity).map(row => {
|
|
253
370
|
const rel = Canonical.Registry.inverseOf(registry, row.verb);
|
|
254
371
|
return { verb: row.verb, ...rel === undefined ? {} : { rel }, source: row.subject, row };
|
|
255
372
|
});
|
|
@@ -272,11 +389,11 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
272
389
|
},
|
|
273
390
|
/** Members of a topic — forward `CONTAINS` traversal (spec §11.2). */
|
|
274
391
|
topicMembers(topic, options_ = {}) {
|
|
275
|
-
return rows(`${withAliases(options_)} SELECT * FROM (${
|
|
392
|
+
return rows(`${withAliases(options_)} SELECT * FROM (${universe(options_)}) WHERE ${entityMatch('subject', options_)} AND verb = 'CONTAINS' AND object IS NOT NULL${traversalFilter(options_)} ORDER BY tx`, topic).map(row => row.object);
|
|
276
393
|
},
|
|
277
394
|
/** Topics containing an entity — the inverse `CONTAINS` read (spec §11.2). */
|
|
278
395
|
topicsOf(entity, options_ = {}) {
|
|
279
|
-
return rows(`${withAliases(options_)} SELECT * FROM (${
|
|
396
|
+
return rows(`${withAliases(options_)} SELECT * FROM (${universe(options_)}) WHERE ${entityMatch('object', options_)} AND verb = 'CONTAINS'${traversalFilter(options_)} ORDER BY tx`, entity).map(row => row.subject);
|
|
280
397
|
},
|
|
281
398
|
/**
|
|
282
399
|
* Full-text search, newest first. The query is treated as a literal
|
|
@@ -315,7 +432,10 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
315
432
|
toClaim,
|
|
316
433
|
/**
|
|
317
434
|
* Emits the store as canonical CAVE text — all rows in transaction
|
|
318
|
-
* order, or only current beliefs with `current`.
|
|
435
|
+
* order, or only current beliefs with `current`. With `tx`, every
|
|
436
|
+
* claim line is preceded by its §28.4 transaction annotation
|
|
437
|
+
* (`;@ <tx>`), so the text carries row identity: `cave sync` replays
|
|
438
|
+
* it idempotently, plain `cave import` reads it unchanged.
|
|
319
439
|
*
|
|
320
440
|
* In current-only export an edge endpoint may be a superseded row;
|
|
321
441
|
* dropping such edges would silently un-condition current claims and
|
|
@@ -352,7 +472,7 @@ export const open = (path = ':memory:', options = {}) => {
|
|
|
352
472
|
seen.add(dedupe);
|
|
353
473
|
return [{ parent, role: edge.role, child }];
|
|
354
474
|
});
|
|
355
|
-
return Canonical.emit({ claims, edges });
|
|
475
|
+
return Canonical.emit({ claims, edges }, options_.tx === true ? { annotate: index => Canonical.txComment(claimRows[index].tx) } : {});
|
|
356
476
|
},
|
|
357
477
|
close() {
|
|
358
478
|
db.close();
|
package/dist/src/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,MAAM,UAAU,GAAG;;;;;;CAMlB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,eAAe,GAAG;;qCAEa,UAAU;;;qCAGV,UAAU;;;;;;;CAO9C,CAAA;AAqBD,8EAA8E;AAC9E,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,MAA0B,EAAW,EAAE,CAC1E,MAAM,KAAK,SAAS,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,EAAE,CAAA;gBACX,CAAC;gBACD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;gBAChB,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;YAC7C,CAAC,CAAC,CAAA;YACF,OAAO,SAAS,CAAC,IAAI,CACnB,EAAE,MAAM,EAAE,KAAK,EAAE,EACjB,QAAQ,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAC7F,CAAA;QACH,CAAC;QAED,KAAK;YACH,EAAE,CAAC,KAAK,EAAE,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cavelang/store",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CAVE persistence on node:sqlite — §13 storage model, append-only belief series, inverse-aware reads.",
|
|
6
6
|
"license": "CC0-1.0",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@cavelang/core": "0.
|
|
36
|
-
"@cavelang/canonical": "0.
|
|
35
|
+
"@cavelang/core": "0.20.0",
|
|
36
|
+
"@cavelang/canonical": "0.20.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsc -b",
|
package/src/index.ts
CHANGED
package/src/resolve.ts
ADDED
|
Binary file
|
package/src/store.ts
CHANGED
|
@@ -11,12 +11,17 @@
|
|
|
11
11
|
* lines via FTS5;
|
|
12
12
|
* - appends can stamp actor provenance (spec §9.5): pass `source` and every
|
|
13
13
|
* claim without a `src:` context gets `@src:<actor>` — applied before the
|
|
14
|
-
* claim key is computed, so different actors keep separate belief series
|
|
14
|
+
* claim key is computed, so different actors keep separate belief series;
|
|
15
|
+
* - contradiction resolution (spec §26): coexisting series about one fact
|
|
16
|
+
* resolve to one winner by precedence class, reliability-weighted
|
|
17
|
+
* confidence and tx — `resolvedBeliefs`, `contested`, and the `resolve`
|
|
18
|
+
* traversal opt-in.
|
|
15
19
|
*/
|
|
16
20
|
|
|
17
21
|
import { DatabaseSync } from 'node:sqlite'
|
|
18
22
|
import { Claim, Context, Key, Uuidv7, Verb } from '@cavelang/core'
|
|
19
23
|
import * as Canonical from '@cavelang/canonical'
|
|
24
|
+
import * as Resolve from './resolve.ts'
|
|
20
25
|
import * as Row from './row.ts'
|
|
21
26
|
import * as Schema from './schema.ts'
|
|
22
27
|
|
|
@@ -29,30 +34,52 @@ JOIN (
|
|
|
29
34
|
`
|
|
30
35
|
|
|
31
36
|
/**
|
|
32
|
-
* Alias
|
|
33
|
-
*
|
|
34
|
-
* claim key — both assert the same link)
|
|
35
|
-
*
|
|
36
|
-
* The seed is the query's single positional parameter.
|
|
37
|
+
* Alias edges (spec §13.6): current positive `ALIAS` claims read as
|
|
38
|
+
* undirected (`ALIAS` has no `REVERSE`, so each written direction is its
|
|
39
|
+
* own claim key — both assert the same link). Retraction unmerges:
|
|
40
|
+
* `a ALIAS b @ 0%` drops that direction's edge.
|
|
37
41
|
*/
|
|
38
|
-
const
|
|
39
|
-
WITH RECURSIVE alias_edge(a, b) AS (
|
|
42
|
+
const aliasEdgeSql = `alias_edge(a, b) AS (
|
|
40
43
|
SELECT c.subject, c.object FROM (${currentSql}) c
|
|
41
44
|
WHERE c.verb = 'ALIAS' AND c.negated = 0 AND c.conf > 0 AND c.object IS NOT NULL
|
|
42
45
|
UNION
|
|
43
46
|
SELECT c.object, c.subject FROM (${currentSql}) c
|
|
44
47
|
WHERE c.verb = 'ALIAS' AND c.negated = 0 AND c.conf > 0 AND c.object IS NOT NULL
|
|
45
|
-
)
|
|
48
|
+
)`
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The closure walked from a seed entity — the seed is the query's first
|
|
52
|
+
* positional parameter. Requires `alias_edge` in scope.
|
|
53
|
+
*/
|
|
54
|
+
const aliasSeedSql = `alias_closure(name) AS (
|
|
46
55
|
SELECT ?
|
|
47
56
|
UNION
|
|
48
57
|
SELECT e.b FROM alias_closure s JOIN alias_edge e ON e.a = s.name
|
|
49
|
-
)
|
|
58
|
+
)`
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The full transitive closure as ordered pairs — every two names currently
|
|
62
|
+
* believed to denote one entity. Resolution grouping widens through it
|
|
63
|
+
* (spec §26.1). Requires `alias_edge` in scope.
|
|
64
|
+
*/
|
|
65
|
+
const aliasPairSql = `alias_pair(a, b) AS (
|
|
66
|
+
SELECT a, b FROM alias_edge
|
|
67
|
+
UNION
|
|
68
|
+
SELECT p.a, e.b FROM alias_pair p JOIN alias_edge e ON e.a = p.b
|
|
69
|
+
)`
|
|
70
|
+
|
|
71
|
+
/** Seeded alias closure (spec §13.6), ready to prefix a SELECT. */
|
|
72
|
+
const aliasClosureSql = `
|
|
73
|
+
WITH RECURSIVE ${aliasEdgeSql}, ${aliasSeedSql}
|
|
50
74
|
`
|
|
51
75
|
|
|
52
76
|
export type IngestResult = {
|
|
53
|
-
/** ids of
|
|
77
|
+
/** ids of the batch's claim rows, in document order — for a row skipped as already present (`ids` replay, spec §28.1), the existing id. */
|
|
54
78
|
readonly ids: readonly string[]
|
|
79
|
+
/** Edges actually inserted (an identity replay skips edges already stored). */
|
|
55
80
|
readonly edges: number
|
|
81
|
+
/** Rows skipped because their explicit id already exists (spec §28.1); always 0 without `ids`. */
|
|
82
|
+
readonly skipped: number
|
|
56
83
|
readonly problems: readonly Canonical.Problem[]
|
|
57
84
|
}
|
|
58
85
|
|
|
@@ -66,6 +93,15 @@ export type AppendOptions = {
|
|
|
66
93
|
* preserve claim keys as exported.
|
|
67
94
|
*/
|
|
68
95
|
readonly source?: string
|
|
96
|
+
/**
|
|
97
|
+
* Explicit row identity (spec §28.1), index-aligned with the result's
|
|
98
|
+
* claims: a claim with an id here is replayed under it — inserted with
|
|
99
|
+
* `id = tx = ids[i]` when absent, skipped when the store already has the
|
|
100
|
+
* row — and the generator observes it (spec §28.2). Claims without an
|
|
101
|
+
* entry mint fresh ids as usual. Edges deduplicate against stored edges
|
|
102
|
+
* in this mode, so replaying a sync export is idempotent end to end.
|
|
103
|
+
*/
|
|
104
|
+
readonly ids?: readonly (undefined | string)[]
|
|
69
105
|
}
|
|
70
106
|
|
|
71
107
|
/** Stamps `@src:<source>` on a claim without a source context (spec §9.5). */
|
|
@@ -101,6 +137,14 @@ export type TraverseOptions = {
|
|
|
101
137
|
* Union-of-rows: matching widens, returned rows keep their stored names.
|
|
102
138
|
*/
|
|
103
139
|
readonly aliases?: boolean
|
|
140
|
+
/**
|
|
141
|
+
* Traverse resolved winners only (spec §26, default `false`): when
|
|
142
|
+
* several series assert one fact — actor stamps, content sources,
|
|
143
|
+
* polarity — the resolution policy picks one and the rest are
|
|
144
|
+
* invisible. Composes with `aliases`, which widens resolution groups
|
|
145
|
+
* through the closure.
|
|
146
|
+
*/
|
|
147
|
+
readonly resolve?: boolean
|
|
104
148
|
}
|
|
105
149
|
|
|
106
150
|
export type Store = ReturnType<typeof open>
|
|
@@ -125,7 +169,16 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
125
169
|
db.exec('PRAGMA foreign_keys = ON')
|
|
126
170
|
Schema.init(db)
|
|
127
171
|
|
|
128
|
-
|
|
172
|
+
// The receive rule (spec §28.2): the store, not the wall clock, is the
|
|
173
|
+
// monotonic authority — every append outsorts every tx already stored,
|
|
174
|
+
// merged history from fast-clocked origins included.
|
|
175
|
+
const maxTx = db.prepare('SELECT MAX(tx) AS tx FROM cave_claim').get() as undefined | { tx: null | string }
|
|
176
|
+
if (maxTx?.tx != null) {
|
|
177
|
+
Uuidv7.observe(maxTx.tx)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const baseRegistry = options.registry ?? Canonical.standardRegistry
|
|
181
|
+
let registry = baseRegistry
|
|
129
182
|
|
|
130
183
|
const insertClaim = db.prepare(`
|
|
131
184
|
INSERT INTO cave_claim (
|
|
@@ -198,13 +251,29 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
198
251
|
}
|
|
199
252
|
}
|
|
200
253
|
|
|
254
|
+
const claimExists = db.prepare('SELECT 1 FROM cave_claim WHERE id = ?')
|
|
255
|
+
const edgeExists = db.prepare('SELECT 1 FROM cave_edge WHERE parent_id = ? AND role = ? AND child_id = ?')
|
|
256
|
+
|
|
201
257
|
/** Appends a canonicalization result — one row per claim, per-row tx. */
|
|
202
258
|
const insertResult = (result: Canonical.Result, options_: AppendOptions = {}): IngestResult =>
|
|
203
259
|
transaction(() => {
|
|
204
260
|
const ids: string[] = []
|
|
205
|
-
|
|
261
|
+
const replay = options_.ids !== undefined
|
|
262
|
+
let skipped = 0
|
|
263
|
+
result.claims.forEach((entry, index) => {
|
|
264
|
+
const explicit = options_.ids?.[index]
|
|
265
|
+
if (explicit !== undefined) {
|
|
266
|
+
// Identity replay (spec §28.1): the id is the row — present means
|
|
267
|
+
// merged already; either way subsequent mints outsort it (§28.2).
|
|
268
|
+
Uuidv7.observe(explicit)
|
|
269
|
+
if (claimExists.get(explicit) !== undefined) {
|
|
270
|
+
skipped += 1
|
|
271
|
+
ids.push(explicit)
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
}
|
|
206
275
|
const claim = stampSource(entry.claim, options_.source)
|
|
207
|
-
const id = Uuidv7.next()
|
|
276
|
+
const id = explicit ?? Uuidv7.next()
|
|
208
277
|
const columns = Row.toColumns(claim)
|
|
209
278
|
const rawLine = columns.rawLine === '' ? Canonical.emitClaim(claim) : columns.rawLine
|
|
210
279
|
insertClaim.run(
|
|
@@ -227,12 +296,19 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
227
296
|
columns.valueText, columns.comment, rawLine
|
|
228
297
|
)
|
|
229
298
|
ids.push(id)
|
|
230
|
-
}
|
|
299
|
+
})
|
|
300
|
+
let edges = 0
|
|
231
301
|
for (const edge of result.edges) {
|
|
232
|
-
|
|
302
|
+
const parentId = ids[edge.parent]!
|
|
303
|
+
const childId = ids[edge.child]!
|
|
304
|
+
if (replay && edgeExists.get(parentId, edge.role, childId) !== undefined) {
|
|
305
|
+
continue
|
|
306
|
+
}
|
|
307
|
+
insertEdge.run(parentId, edge.role, childId)
|
|
308
|
+
edges += 1
|
|
233
309
|
}
|
|
234
310
|
registry = result.registry
|
|
235
|
-
return { ids, edges
|
|
311
|
+
return { ids, edges, skipped, problems: result.problems }
|
|
236
312
|
})
|
|
237
313
|
|
|
238
314
|
const rows = (sql: string, ...params: (string | number)[]): Row.t[] =>
|
|
@@ -262,7 +338,24 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
262
338
|
options.aliases === true ? `${column} IN (SELECT name FROM alias_closure)` : `${column} = ?`
|
|
263
339
|
|
|
264
340
|
const withAliases = (options: TraverseOptions): string =>
|
|
265
|
-
options.aliases === true ?
|
|
341
|
+
options.aliases === true ?
|
|
342
|
+
// Resolution grouping needs the pair closure too (spec §26.1).
|
|
343
|
+
(options.resolve === true ?
|
|
344
|
+
`\nWITH RECURSIVE ${aliasEdgeSql}, ${aliasPairSql}, ${aliasSeedSql}\n` :
|
|
345
|
+
aliasClosureSql) :
|
|
346
|
+
''
|
|
347
|
+
|
|
348
|
+
const readPolicy = (): Resolve.Entry[] =>
|
|
349
|
+
Resolve.readPolicy(db, currentSql)
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Row universe of a traversal: current beliefs, or the §26 resolved
|
|
353
|
+
* winners among them when `resolve` is set.
|
|
354
|
+
*/
|
|
355
|
+
const universe = (options: TraverseOptions): string =>
|
|
356
|
+
options.resolve === true ?
|
|
357
|
+
Resolve.resolvedSql(readPolicy(), currentSql, { aliases: options.aliases === true }) :
|
|
358
|
+
currentSql
|
|
266
359
|
|
|
267
360
|
return {
|
|
268
361
|
/** Raw database handle — used by `@cavelang/query`; treat as read-only. */
|
|
@@ -271,6 +364,17 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
271
364
|
/** Current verb registry (input registry + stored + ingested declarations). */
|
|
272
365
|
registry: (): Canonical.Registry.t => registry,
|
|
273
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Rebuilds the registry from the base plus stored declarations — after
|
|
369
|
+
* rows arrive outside `ingest`/`insertResult` (a §28 merge writes
|
|
370
|
+
* through SQL), merged in-band declarations take effect without
|
|
371
|
+
* reopening.
|
|
372
|
+
*/
|
|
373
|
+
reloadRegistry(): void {
|
|
374
|
+
registry = baseRegistry
|
|
375
|
+
rebuildRegistry()
|
|
376
|
+
},
|
|
377
|
+
|
|
274
378
|
/**
|
|
275
379
|
* Runs `body` atomically; throwing rolls everything back, including
|
|
276
380
|
* nested appends and their registry declarations. Nestable
|
|
@@ -317,6 +421,53 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
317
421
|
return rows('SELECT * FROM cave_claim WHERE claim_key = ? ORDER BY tx', claimKey)
|
|
318
422
|
},
|
|
319
423
|
|
|
424
|
+
/**
|
|
425
|
+
* The effective resolution policy (spec §26.3): the built-in ladder
|
|
426
|
+
* merged with current in-band `source[/<path>] HAS precedence:` /
|
|
427
|
+
* `HAS reliability:` declarations, sorted by prefix.
|
|
428
|
+
*/
|
|
429
|
+
resolutionPolicy(): Resolve.Entry[] {
|
|
430
|
+
return readPolicy()
|
|
431
|
+
},
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Resolved current beliefs (spec §26): one winner per resolution
|
|
435
|
+
* group — coexisting series about one fact (actor stamps, content
|
|
436
|
+
* sources, polarity) collapse to the row the policy picks; the rest
|
|
437
|
+
* are invisible. Oldest first, rows returned verbatim. With
|
|
438
|
+
* `aliases`, groups widen through the alias closure (spec §26.1).
|
|
439
|
+
*/
|
|
440
|
+
resolvedBeliefs(options_: { aliases?: boolean } = {}): Row.t[] {
|
|
441
|
+
const aliases = options_.aliases === true
|
|
442
|
+
const prefix = aliases ? `WITH RECURSIVE ${aliasEdgeSql}, ${aliasPairSql}\n` : ''
|
|
443
|
+
return rows(`${prefix}SELECT * FROM (${Resolve.resolvedSql(readPolicy(), currentSql, { aliases })}) ORDER BY tx`)
|
|
444
|
+
},
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Contested facts (spec §26.4): resolution groups where more than one
|
|
448
|
+
* candidate currently speaks, each candidate scored (`res_class`,
|
|
449
|
+
* `res_conf`) and ranked — the winner first. The feed for fusion
|
|
450
|
+
* (§10.1 combines a contested group's numeric estimates instead of
|
|
451
|
+
* picking) and for the `cave resolve` view.
|
|
452
|
+
*/
|
|
453
|
+
contested(options_: { aliases?: boolean } = {}): Resolve.Contested[] {
|
|
454
|
+
const aliases = options_.aliases === true
|
|
455
|
+
const prefix = aliases ? `WITH RECURSIVE ${aliasEdgeSql}, ${aliasPairSql}\n` : ''
|
|
456
|
+
const ranked = rows(
|
|
457
|
+
`${prefix}SELECT * FROM (${Resolve.rankedSql(readPolicy(), currentSql, { aliases })}) ORDER BY res_group, res_rank`
|
|
458
|
+
) as Resolve.Ranked[]
|
|
459
|
+
const groups: { group: string, rows: Resolve.Ranked[] }[] = []
|
|
460
|
+
for (const row of ranked) {
|
|
461
|
+
const last = groups[groups.length - 1]
|
|
462
|
+
if (last !== undefined && last.group === row.res_group) {
|
|
463
|
+
last.rows.push(row)
|
|
464
|
+
} else {
|
|
465
|
+
groups.push({ group: row.res_group, rows: [row] })
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return groups.filter(group => group.rows.length > 1)
|
|
469
|
+
},
|
|
470
|
+
|
|
320
471
|
/**
|
|
321
472
|
* The alias closure of an entity (spec §13.6): the entity itself plus
|
|
322
473
|
* every name reachable through current positive `ALIAS` claims, read as
|
|
@@ -344,7 +495,7 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
344
495
|
/** Forward reads: current relational facts with `entity` as subject (spec §13.3). */
|
|
345
496
|
forward(entity: string, options_: TraverseOptions = {}): ForwardFact[] {
|
|
346
497
|
return rows(
|
|
347
|
-
`${withAliases(options_)} SELECT * FROM (${
|
|
498
|
+
`${withAliases(options_)} SELECT * FROM (${universe(options_)}) WHERE ${entityMatch('subject', options_)} AND object IS NOT NULL${traversalFilter(options_)} ORDER BY tx`,
|
|
348
499
|
entity
|
|
349
500
|
).map(row => ({ verb: row.verb, target: row.object!, row }))
|
|
350
501
|
},
|
|
@@ -356,7 +507,7 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
356
507
|
*/
|
|
357
508
|
reverse(entity: string, options_: TraverseOptions = {}): ReverseFact[] {
|
|
358
509
|
return rows(
|
|
359
|
-
`${withAliases(options_)} SELECT * FROM (${
|
|
510
|
+
`${withAliases(options_)} SELECT * FROM (${universe(options_)}) WHERE ${entityMatch('object', options_)} AND object IS NOT NULL${traversalFilter(options_)} ORDER BY tx`,
|
|
360
511
|
entity
|
|
361
512
|
).map(row => {
|
|
362
513
|
const rel = Canonical.Registry.inverseOf(registry, row.verb)
|
|
@@ -385,7 +536,7 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
385
536
|
/** Members of a topic — forward `CONTAINS` traversal (spec §11.2). */
|
|
386
537
|
topicMembers(topic: string, options_: TraverseOptions = {}): string[] {
|
|
387
538
|
return rows(
|
|
388
|
-
`${withAliases(options_)} SELECT * FROM (${
|
|
539
|
+
`${withAliases(options_)} SELECT * FROM (${universe(options_)}) WHERE ${entityMatch('subject', options_)} AND verb = 'CONTAINS' AND object IS NOT NULL${traversalFilter(options_)} ORDER BY tx`,
|
|
389
540
|
topic
|
|
390
541
|
).map(row => row.object!)
|
|
391
542
|
},
|
|
@@ -393,7 +544,7 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
393
544
|
/** Topics containing an entity — the inverse `CONTAINS` read (spec §11.2). */
|
|
394
545
|
topicsOf(entity: string, options_: TraverseOptions = {}): string[] {
|
|
395
546
|
return rows(
|
|
396
|
-
`${withAliases(options_)} SELECT * FROM (${
|
|
547
|
+
`${withAliases(options_)} SELECT * FROM (${universe(options_)}) WHERE ${entityMatch('object', options_)} AND verb = 'CONTAINS'${traversalFilter(options_)} ORDER BY tx`,
|
|
397
548
|
entity
|
|
398
549
|
).map(row => row.subject)
|
|
399
550
|
},
|
|
@@ -440,7 +591,10 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
440
591
|
|
|
441
592
|
/**
|
|
442
593
|
* Emits the store as canonical CAVE text — all rows in transaction
|
|
443
|
-
* order, or only current beliefs with `current`.
|
|
594
|
+
* order, or only current beliefs with `current`. With `tx`, every
|
|
595
|
+
* claim line is preceded by its §28.4 transaction annotation
|
|
596
|
+
* (`;@ <tx>`), so the text carries row identity: `cave sync` replays
|
|
597
|
+
* it idempotently, plain `cave import` reads it unchanged.
|
|
444
598
|
*
|
|
445
599
|
* In current-only export an edge endpoint may be a superseded row;
|
|
446
600
|
* dropping such edges would silently un-condition current claims and
|
|
@@ -448,7 +602,7 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
448
602
|
* endpoint resolves to the *current row of its claim key*, and the
|
|
449
603
|
* resulting edges are deduplicated.
|
|
450
604
|
*/
|
|
451
|
-
exportText(options_: { current?: boolean } = {}): string {
|
|
605
|
+
exportText(options_: { current?: boolean, tx?: boolean } = {}): string {
|
|
452
606
|
const current = options_.current === true
|
|
453
607
|
const claimRows = current ?
|
|
454
608
|
rows(`${currentSql} ORDER BY c.tx`) :
|
|
@@ -480,7 +634,10 @@ export const open = (path: string = ':memory:', options: { registry?: Canonical.
|
|
|
480
634
|
seen.add(dedupe)
|
|
481
635
|
return [{ parent, role: edge.role, child }]
|
|
482
636
|
})
|
|
483
|
-
return Canonical.emit(
|
|
637
|
+
return Canonical.emit(
|
|
638
|
+
{ claims, edges },
|
|
639
|
+
options_.tx === true ? { annotate: index => Canonical.txComment(claimRows[index]!.tx) } : {}
|
|
640
|
+
)
|
|
484
641
|
},
|
|
485
642
|
|
|
486
643
|
close(): void {
|