instar 0.28.82 → 0.28.84
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/dashboard/index.html +239 -0
- package/dist/cli.js +10 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/memoryBackfillEvidence.d.ts +69 -0
- package/dist/commands/memoryBackfillEvidence.d.ts.map +1 -0
- package/dist/commands/memoryBackfillEvidence.js +220 -0
- package/dist/commands/memoryBackfillEvidence.js.map +1 -0
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +72 -1
- package/dist/commands/server.js.map +1 -1
- package/dist/core/EvolutionManager.d.ts +73 -0
- package/dist/core/EvolutionManager.d.ts.map +1 -1
- package/dist/core/EvolutionManager.js +376 -0
- package/dist/core/EvolutionManager.js.map +1 -1
- package/dist/core/SharedStateLedger.d.ts.map +1 -1
- package/dist/core/SharedStateLedger.js +4 -0
- package/dist/core/SharedStateLedger.js.map +1 -1
- package/dist/core/types.d.ts +90 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +8 -0
- package/dist/core/types.js.map +1 -1
- package/dist/memory/EvidenceRenderer.d.ts +64 -0
- package/dist/memory/EvidenceRenderer.d.ts.map +1 -0
- package/dist/memory/EvidenceRenderer.js +119 -0
- package/dist/memory/EvidenceRenderer.js.map +1 -0
- package/dist/memory/SemanticMemory.d.ts +61 -1
- package/dist/memory/SemanticMemory.d.ts.map +1 -1
- package/dist/memory/SemanticMemory.js +381 -11
- package/dist/memory/SemanticMemory.js.map +1 -1
- package/dist/server/AgentServer.d.ts +4 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +2 -0
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/routes.d.ts +8 -0
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +493 -3
- package/dist/server/routes.js.map +1 -1
- package/dist/tasks/DivergenceChecker.d.ts +89 -0
- package/dist/tasks/DivergenceChecker.d.ts.map +1 -0
- package/dist/tasks/DivergenceChecker.js +255 -0
- package/dist/tasks/DivergenceChecker.js.map +1 -0
- package/dist/tasks/LruCache.d.ts +33 -0
- package/dist/tasks/LruCache.d.ts.map +1 -0
- package/dist/tasks/LruCache.js +88 -0
- package/dist/tasks/LruCache.js.map +1 -0
- package/dist/tasks/RateLimiter.d.ts +61 -0
- package/dist/tasks/RateLimiter.d.ts.map +1 -0
- package/dist/tasks/RateLimiter.js +108 -0
- package/dist/tasks/RateLimiter.js.map +1 -0
- package/dist/tasks/TaskFlowDueWaker.d.ts +29 -0
- package/dist/tasks/TaskFlowDueWaker.d.ts.map +1 -0
- package/dist/tasks/TaskFlowDueWaker.js +73 -0
- package/dist/tasks/TaskFlowDueWaker.js.map +1 -0
- package/dist/tasks/TaskFlowMaintenanceSweeper.d.ts +40 -0
- package/dist/tasks/TaskFlowMaintenanceSweeper.d.ts.map +1 -0
- package/dist/tasks/TaskFlowMaintenanceSweeper.js +131 -0
- package/dist/tasks/TaskFlowMaintenanceSweeper.js.map +1 -0
- package/dist/tasks/TaskFlowRegistry.d.ts +180 -0
- package/dist/tasks/TaskFlowRegistry.d.ts.map +1 -0
- package/dist/tasks/TaskFlowRegistry.js +791 -0
- package/dist/tasks/TaskFlowRegistry.js.map +1 -0
- package/dist/tasks/ThreadlineFlowBridge.d.ts +54 -0
- package/dist/tasks/ThreadlineFlowBridge.d.ts.map +1 -0
- package/dist/tasks/ThreadlineFlowBridge.js +129 -0
- package/dist/tasks/ThreadlineFlowBridge.js.map +1 -0
- package/dist/tasks/task-flow-registry.store.sqlite.d.ts +77 -0
- package/dist/tasks/task-flow-registry.store.sqlite.d.ts.map +1 -0
- package/dist/tasks/task-flow-registry.store.sqlite.js +350 -0
- package/dist/tasks/task-flow-registry.store.sqlite.js.map +1 -0
- package/dist/tasks/task-flow-types.d.ts +229 -0
- package/dist/tasks/task-flow-types.d.ts.map +1 -0
- package/dist/tasks/task-flow-types.js +128 -0
- package/dist/tasks/task-flow-types.js.map +1 -0
- package/dist/threadline/ThreadlineNicknames.d.ts +88 -0
- package/dist/threadline/ThreadlineNicknames.d.ts.map +1 -0
- package/dist/threadline/ThreadlineNicknames.js +195 -0
- package/dist/threadline/ThreadlineNicknames.js.map +1 -0
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +78 -78
- package/upgrades/0.28.83.md +45 -0
- package/upgrades/0.28.84.md +89 -0
- package/upgrades/side-effects/taskflow-phase1.md +130 -0
- package/upgrades/side-effects/taskflow-phase2.md +110 -0
- package/upgrades/side-effects/taskflow-phase3a.md +138 -0
- package/upgrades/side-effects/taskflow-phase5.md +234 -0
- package/upgrades/side-effects/threadline-nickname-resolver-authority.md +81 -0
- package/upgrades/side-effects/wikiclaim-evidence-phase1.md +138 -0
- package/upgrades/side-effects/wikiclaim-evidence-phase4.md +129 -0
- package/upgrades/side-effects/wikiclaim-evidence-phase5.md +285 -0
package/dist/core/types.js
CHANGED
|
@@ -17,4 +17,12 @@ export const SOUL_SECTION_TRUST = {
|
|
|
17
17
|
'core-values': 'collaborative',
|
|
18
18
|
'growth-edge': 'collaborative',
|
|
19
19
|
};
|
|
20
|
+
/** Per-entity cap; overridable up to MAX_EVIDENCE_CAP_PER_ENTITY via config. */
|
|
21
|
+
export const DEFAULT_EVIDENCE_CAP_PER_ENTITY = 50;
|
|
22
|
+
/** Hard upper bound on per-entity evidence cap. */
|
|
23
|
+
export const MAX_EVIDENCE_CAP_PER_ENTITY = 500;
|
|
24
|
+
/** Hard cap on `note` field bytes. */
|
|
25
|
+
export const MAX_EVIDENCE_NOTE_BYTES = 500;
|
|
26
|
+
/** Bound for traversal of `kind:'supersedes-evidence'` chains. */
|
|
27
|
+
export const MAX_SUPERSEDES_DEPTH = 32;
|
|
20
28
|
//# sourceMappingURL=types.js.map
|
package/dist/core/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAg6BH;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA8C;IAC3E,cAAc,EAAE,UAAU;IAC1B,gBAAgB,EAAE,eAAe;IACjC,mBAAmB,EAAE,UAAU;IAC/B,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,eAAe;CAC/B,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAg6BH;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA8C;IAC3E,cAAc,EAAE,UAAU;IAC1B,gBAAgB,EAAE,eAAe;IACjC,mBAAmB,EAAE,UAAU;IAC/B,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,eAAe;CAC/B,CAAC;AA2vDF,gFAAgF;AAChF,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAClD,mDAAmD;AACnD,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAC/C,sCAAsC;AACtC,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,kEAAkE;AAClE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EvidenceRenderer — single privacy-enforcement helper for MemoryEntity
|
|
3
|
+
* evidence rendering.
|
|
4
|
+
*
|
|
5
|
+
* Per WikiClaim spec § Storage and Privacy (line 315) and § Risks line 356,
|
|
6
|
+
* "the renderer is the privacy-enforcement boundary, not the storage layer."
|
|
7
|
+
* The storage layer already filters at read time via `getEvidence` /
|
|
8
|
+
* `getEntityWithEvidence` / `findCitations`, but any downstream code path
|
|
9
|
+
* that touches an already-loaded `MemoryEntity.evidence` array must pipe
|
|
10
|
+
* through this helper instead of inlining the comparison — that way the
|
|
11
|
+
* filter rule lives in exactly ONE place and Phase 4 HTTP / dashboard /
|
|
12
|
+
* threadline render callsites can never accidentally leak.
|
|
13
|
+
*
|
|
14
|
+
* The helper enforces:
|
|
15
|
+
* 1. Entity-level visibility — if the entity's `privacyScope` exceeds the
|
|
16
|
+
* viewer's scope, the entity itself is hidden (returns null).
|
|
17
|
+
* 2. Evidence-level visibility — each evidence row's `privacyTier` (or
|
|
18
|
+
* `undefined`, which inherits the entity scope) is checked against
|
|
19
|
+
* the viewer scope; restricted rows are dropped.
|
|
20
|
+
*
|
|
21
|
+
* Spec citations:
|
|
22
|
+
* - § Storage and Privacy line 315: renderer is the enforcement boundary
|
|
23
|
+
* - § Risks line 356: "render every privacyScope × privacyTier
|
|
24
|
+
* combination" cross-product test asserts no leak
|
|
25
|
+
* - § Storage and Privacy line 316: inverse-query privacy filter
|
|
26
|
+
*/
|
|
27
|
+
import type { MemoryEntity, MemoryEvidence, EvidencePrivacyTier, PrivacyScopeType } from '../core/types.js';
|
|
28
|
+
/** True iff entity at `itemScope` is visible to a viewer at `viewerScope`. */
|
|
29
|
+
export declare function isEntityVisibleAtScope(itemScope: PrivacyScopeType | undefined, viewerScope: PrivacyScopeType): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* True iff an evidence row tagged `evidenceTier` is visible to `viewerScope`.
|
|
32
|
+
* `undefined` evidenceTier inherits the entity's scope — by the time this
|
|
33
|
+
* helper is called the entity-level filter has already accepted the entity,
|
|
34
|
+
* so undefined tiers pass through. (Mirrors SemanticMemory's `getEvidence`
|
|
35
|
+
* read-time filter.)
|
|
36
|
+
*/
|
|
37
|
+
export declare function isEvidenceVisibleAtScope(evidenceTier: EvidencePrivacyTier | undefined, viewerScope: PrivacyScopeType): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Filter an entity for a viewer. Returns:
|
|
40
|
+
* - `null` if the entity's own `privacyScope` is wider than the viewer's
|
|
41
|
+
* scope (entity itself is hidden).
|
|
42
|
+
* - A shallow clone with `evidence` filtered to only rows visible at the
|
|
43
|
+
* viewer's scope. The `evidence` field is preserved as `[]` if all rows
|
|
44
|
+
* are filtered out and as `undefined` if the input didn't have one
|
|
45
|
+
* loaded (matches the lazy-load contract in MemoryEntity).
|
|
46
|
+
*
|
|
47
|
+
* SAFETY: never mutates the input entity. Callers can pass the same entity
|
|
48
|
+
* to multiple viewers without cross-contamination.
|
|
49
|
+
*/
|
|
50
|
+
export declare function renderEvidenceForScope(entity: MemoryEntity, viewerScope: PrivacyScopeType): (MemoryEntity & {
|
|
51
|
+
evidence?: MemoryEvidence[];
|
|
52
|
+
}) | null;
|
|
53
|
+
/**
|
|
54
|
+
* Filter a bare evidence array for a viewer scope. Used when the consumer
|
|
55
|
+
* has evidence in hand without the parent entity (e.g., a separate evidence
|
|
56
|
+
* panel that received a pre-loaded array).
|
|
57
|
+
*
|
|
58
|
+
* NOTE: this skips the entity-level visibility check. Use `renderEvidenceForScope`
|
|
59
|
+
* whenever the entity is available. This helper exists for the narrow
|
|
60
|
+
* `findCitations`-derived flow where the entity was already filtered and
|
|
61
|
+
* only its evidence array is being trimmed.
|
|
62
|
+
*/
|
|
63
|
+
export declare function filterEvidenceArrayForScope(evidence: readonly MemoryEvidence[], viewerScope: PrivacyScopeType): MemoryEvidence[];
|
|
64
|
+
//# sourceMappingURL=EvidenceRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvidenceRenderer.d.ts","sourceRoot":"","sources":["../../src/memory/EvidenceRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AA4C1B,8EAA8E;AAC9E,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,gBAAgB,GAAG,SAAS,EACvC,WAAW,EAAE,gBAAgB,GAC5B,OAAO,CAGT;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,mBAAmB,GAAG,SAAS,EAC7C,WAAW,EAAE,gBAAgB,GAC5B,OAAO,CAGT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,gBAAgB,GAC5B,CAAC,YAAY,GAAG;IAAE,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAA;CAAE,CAAC,GAAG,IAAI,CAYzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,WAAW,EAAE,gBAAgB,GAC5B,cAAc,EAAE,CAElB"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EvidenceRenderer — single privacy-enforcement helper for MemoryEntity
|
|
3
|
+
* evidence rendering.
|
|
4
|
+
*
|
|
5
|
+
* Per WikiClaim spec § Storage and Privacy (line 315) and § Risks line 356,
|
|
6
|
+
* "the renderer is the privacy-enforcement boundary, not the storage layer."
|
|
7
|
+
* The storage layer already filters at read time via `getEvidence` /
|
|
8
|
+
* `getEntityWithEvidence` / `findCitations`, but any downstream code path
|
|
9
|
+
* that touches an already-loaded `MemoryEntity.evidence` array must pipe
|
|
10
|
+
* through this helper instead of inlining the comparison — that way the
|
|
11
|
+
* filter rule lives in exactly ONE place and Phase 4 HTTP / dashboard /
|
|
12
|
+
* threadline render callsites can never accidentally leak.
|
|
13
|
+
*
|
|
14
|
+
* The helper enforces:
|
|
15
|
+
* 1. Entity-level visibility — if the entity's `privacyScope` exceeds the
|
|
16
|
+
* viewer's scope, the entity itself is hidden (returns null).
|
|
17
|
+
* 2. Evidence-level visibility — each evidence row's `privacyTier` (or
|
|
18
|
+
* `undefined`, which inherits the entity scope) is checked against
|
|
19
|
+
* the viewer scope; restricted rows are dropped.
|
|
20
|
+
*
|
|
21
|
+
* Spec citations:
|
|
22
|
+
* - § Storage and Privacy line 315: renderer is the enforcement boundary
|
|
23
|
+
* - § Risks line 356: "render every privacyScope × privacyTier
|
|
24
|
+
* combination" cross-product test asserts no leak
|
|
25
|
+
* - § Storage and Privacy line 316: inverse-query privacy filter
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Entity-level privacy ordering. `private` > `shared-topic` > `shared-project`.
|
|
29
|
+
* A viewer at higher tier sees their tier and everything below.
|
|
30
|
+
*
|
|
31
|
+
* Mirrors `ENTITY_SCOPE_ORDER` in SemanticMemory.ts — kept colocated rather
|
|
32
|
+
* than imported to keep the renderer side-effect-free and avoid pulling
|
|
33
|
+
* better-sqlite3 into render contexts that don't need it (e.g., HTTP
|
|
34
|
+
* response shapers).
|
|
35
|
+
*/
|
|
36
|
+
const ENTITY_SCOPE_ORDER = {
|
|
37
|
+
'shared-project': 0,
|
|
38
|
+
'shared-topic': 1,
|
|
39
|
+
'private': 2,
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Evidence-level privacy ordering. Wider vocabulary than entity scope:
|
|
43
|
+
* adds `public` (more permissive than shared-project) and `sensitive`
|
|
44
|
+
* (more restrictive than private). Per spec § Schema Changes line 136.
|
|
45
|
+
*/
|
|
46
|
+
const EVIDENCE_TIER_ORDER = {
|
|
47
|
+
'public': 0,
|
|
48
|
+
'shared-project': 1,
|
|
49
|
+
'private': 2,
|
|
50
|
+
'sensitive': 3,
|
|
51
|
+
};
|
|
52
|
+
/** Map an entity-vocabulary scope onto the evidence-tier scale. */
|
|
53
|
+
function entityScopeToTierOrdinal(scope) {
|
|
54
|
+
switch (scope) {
|
|
55
|
+
case 'shared-project':
|
|
56
|
+
return EVIDENCE_TIER_ORDER['shared-project'];
|
|
57
|
+
case 'shared-topic':
|
|
58
|
+
// Conservative-map: 'shared-topic' is absent from the evidence
|
|
59
|
+
// vocabulary; treat it like 'private' so wider tiers cannot be
|
|
60
|
+
// attached to topic-scope entities.
|
|
61
|
+
return EVIDENCE_TIER_ORDER['private'];
|
|
62
|
+
case 'private':
|
|
63
|
+
return EVIDENCE_TIER_ORDER['private'];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** True iff entity at `itemScope` is visible to a viewer at `viewerScope`. */
|
|
67
|
+
export function isEntityVisibleAtScope(itemScope, viewerScope) {
|
|
68
|
+
const item = itemScope ?? 'shared-project';
|
|
69
|
+
return ENTITY_SCOPE_ORDER[viewerScope] >= ENTITY_SCOPE_ORDER[item];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* True iff an evidence row tagged `evidenceTier` is visible to `viewerScope`.
|
|
73
|
+
* `undefined` evidenceTier inherits the entity's scope — by the time this
|
|
74
|
+
* helper is called the entity-level filter has already accepted the entity,
|
|
75
|
+
* so undefined tiers pass through. (Mirrors SemanticMemory's `getEvidence`
|
|
76
|
+
* read-time filter.)
|
|
77
|
+
*/
|
|
78
|
+
export function isEvidenceVisibleAtScope(evidenceTier, viewerScope) {
|
|
79
|
+
if (evidenceTier === undefined)
|
|
80
|
+
return true;
|
|
81
|
+
return entityScopeToTierOrdinal(viewerScope) >= EVIDENCE_TIER_ORDER[evidenceTier];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Filter an entity for a viewer. Returns:
|
|
85
|
+
* - `null` if the entity's own `privacyScope` is wider than the viewer's
|
|
86
|
+
* scope (entity itself is hidden).
|
|
87
|
+
* - A shallow clone with `evidence` filtered to only rows visible at the
|
|
88
|
+
* viewer's scope. The `evidence` field is preserved as `[]` if all rows
|
|
89
|
+
* are filtered out and as `undefined` if the input didn't have one
|
|
90
|
+
* loaded (matches the lazy-load contract in MemoryEntity).
|
|
91
|
+
*
|
|
92
|
+
* SAFETY: never mutates the input entity. Callers can pass the same entity
|
|
93
|
+
* to multiple viewers without cross-contamination.
|
|
94
|
+
*/
|
|
95
|
+
export function renderEvidenceForScope(entity, viewerScope) {
|
|
96
|
+
if (!isEntityVisibleAtScope(entity.privacyScope, viewerScope)) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
if (entity.evidence === undefined) {
|
|
100
|
+
// Lazy: caller didn't load evidence; pass through unchanged.
|
|
101
|
+
return { ...entity };
|
|
102
|
+
}
|
|
103
|
+
const filtered = entity.evidence.filter((ev) => isEvidenceVisibleAtScope(ev.privacyTier, viewerScope));
|
|
104
|
+
return { ...entity, evidence: filtered };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Filter a bare evidence array for a viewer scope. Used when the consumer
|
|
108
|
+
* has evidence in hand without the parent entity (e.g., a separate evidence
|
|
109
|
+
* panel that received a pre-loaded array).
|
|
110
|
+
*
|
|
111
|
+
* NOTE: this skips the entity-level visibility check. Use `renderEvidenceForScope`
|
|
112
|
+
* whenever the entity is available. This helper exists for the narrow
|
|
113
|
+
* `findCitations`-derived flow where the entity was already filtered and
|
|
114
|
+
* only its evidence array is being trimmed.
|
|
115
|
+
*/
|
|
116
|
+
export function filterEvidenceArrayForScope(evidence, viewerScope) {
|
|
117
|
+
return evidence.filter((ev) => isEvidenceVisibleAtScope(ev.privacyTier, viewerScope));
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=EvidenceRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvidenceRenderer.js","sourceRoot":"","sources":["../../src/memory/EvidenceRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AASH;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAqC;IAC3D,gBAAgB,EAAE,CAAC;IACnB,cAAc,EAAE,CAAC;IACjB,SAAS,EAAE,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,MAAM,mBAAmB,GAAwC;IAC/D,QAAQ,EAAE,CAAC;IACX,gBAAgB,EAAE,CAAC;IACnB,SAAS,EAAE,CAAC;IACZ,WAAW,EAAE,CAAC;CACf,CAAC;AAEF,mEAAmE;AACnE,SAAS,wBAAwB,CAAC,KAAuB;IACvD,QAAQ,KAAK,EAAE,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AAC3C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAmC,EACnC,WAA6B;IAE7B,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,wBAAwB,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* Uses the same better-sqlite3 pattern as MemoryIndex and TopicMemory.
|
|
19
19
|
*/
|
|
20
|
-
import type { MemoryEntity, MemoryEdge, ScoredEntity, ConnectedEntity, DecayReport, ImportReport, SemanticMemoryStats, SemanticMemoryConfig, SemanticSearchOptions, ExploreOptions, EntityType, RelationType } from '../core/types.js';
|
|
20
|
+
import type { MemoryEntity, MemoryEdge, ScoredEntity, ConnectedEntity, DecayReport, ImportReport, SemanticMemoryStats, SemanticMemoryConfig, SemanticSearchOptions, ExploreOptions, EntityType, RelationType, MemoryEvidence, MemoryEvidenceKind, EvidenceProducerId } from '../core/types.js';
|
|
21
21
|
import type { PrivacyScopeType } from '../core/types.js';
|
|
22
22
|
import type { EmbeddingProvider } from './EmbeddingProvider.js';
|
|
23
23
|
export declare class SemanticMemory {
|
|
@@ -29,6 +29,12 @@ export declare class SemanticMemory {
|
|
|
29
29
|
private jsonlPath;
|
|
30
30
|
/** Set after corruption auto-recovery — caller should reimport from JSONL */
|
|
31
31
|
private _needsRebuild;
|
|
32
|
+
/** When true, `remember()` skips its own JSONL append (the wrapping
|
|
33
|
+
* `rememberWithEvidence` will emit a consolidated action instead). */
|
|
34
|
+
private _suppressRememberJournal;
|
|
35
|
+
/** Last full entity payload captured by `remember()` — read by
|
|
36
|
+
* `rememberWithEvidence` to build a full-fidelity JSONL action. */
|
|
37
|
+
private _lastRememberedEntity;
|
|
32
38
|
constructor(config: SemanticMemoryConfig);
|
|
33
39
|
/**
|
|
34
40
|
* Whether hybrid vector search is active (sqlite-vec loaded + embeddings table created).
|
|
@@ -124,6 +130,57 @@ export declare class SemanticMemory {
|
|
|
124
130
|
* Delete an entity and all its edges.
|
|
125
131
|
*/
|
|
126
132
|
forget(id: string, _reason?: string): void;
|
|
133
|
+
/**
|
|
134
|
+
* Atomic create-with-evidence. Equivalent to `remember()` followed by
|
|
135
|
+
* `addEvidence()`, but in one better-sqlite3 transaction so a producer
|
|
136
|
+
* crash mid-call cannot leave an orphan entity.
|
|
137
|
+
*/
|
|
138
|
+
rememberWithEvidence(input: Parameters<typeof this.remember>[0], evidence: MemoryEvidence[], producer: EvidenceProducerId): string;
|
|
139
|
+
/**
|
|
140
|
+
* Append one or more evidence entries to an existing entity. When called
|
|
141
|
+
* with an array, all rows are inserted inside a single better-sqlite3
|
|
142
|
+
* transaction so a partial-write crash cannot leave half the rows landed.
|
|
143
|
+
*/
|
|
144
|
+
addEvidence(entityId: string, evidence: MemoryEvidence | MemoryEvidence[], producer: EvidenceProducerId): void;
|
|
145
|
+
/**
|
|
146
|
+
* Read evidence for an entity, filtered by viewer scope. Producers may
|
|
147
|
+
* have written `privacyTier` more restrictive than the entity's own
|
|
148
|
+
* `privacyScope`; we filter at read time so the renderer is the single
|
|
149
|
+
* privacy-enforcement point.
|
|
150
|
+
*/
|
|
151
|
+
getEvidence(entityId: string, viewerScope: PrivacyScopeType): MemoryEvidence[];
|
|
152
|
+
/**
|
|
153
|
+
* Inverse query: which entities cite this `(kind, sourceId)`? Filtered by
|
|
154
|
+
* BOTH the entity's own privacyScope AND the citing evidence row's
|
|
155
|
+
* privacyTier — per spec § Storage and Privacy line 316, no leak via
|
|
156
|
+
* inverse query at any (viewerScope × evidence tier × entity scope)
|
|
157
|
+
* combination.
|
|
158
|
+
*/
|
|
159
|
+
findCitations(ref: {
|
|
160
|
+
kind: MemoryEvidenceKind;
|
|
161
|
+
sourceId: string;
|
|
162
|
+
}, viewerScope: PrivacyScopeType): MemoryEntity[];
|
|
163
|
+
/**
|
|
164
|
+
* Eager variant of `recall()` (without `connections`). Returns the entity
|
|
165
|
+
* with its evidence array attached, viewer-scope filtered.
|
|
166
|
+
*/
|
|
167
|
+
getEntityWithEvidence(entityId: string, viewerScope: PrivacyScopeType): (MemoryEntity & {
|
|
168
|
+
evidence: MemoryEvidence[];
|
|
169
|
+
}) | null;
|
|
170
|
+
private evidenceCapPerEntity;
|
|
171
|
+
private assertProducerKindsAllowed;
|
|
172
|
+
private insertEvidenceRows;
|
|
173
|
+
private assertEvidenceShape;
|
|
174
|
+
/**
|
|
175
|
+
* Bounded defenses for `kind:'supersedes-evidence'`:
|
|
176
|
+
* 1. The supersedes-evidence row's `sourceId` MUST NOT equal the entity's
|
|
177
|
+
* own id — that's a self-loop with no useful semantics.
|
|
178
|
+
* 2. The total count of supersedes-evidence rows on this entity MUST stay
|
|
179
|
+
* under MAX_SUPERSEDES_DEPTH. This bounds chain length without
|
|
180
|
+
* requiring a parent-pointer column (the spec leaves the chain shape
|
|
181
|
+
* underspecified; bounding count is the conservative defense).
|
|
182
|
+
*/
|
|
183
|
+
private assertSupersedesAcyclic;
|
|
127
184
|
/**
|
|
128
185
|
* Get all entities owned by a specific user.
|
|
129
186
|
* Used for GDPR data export (/mydata).
|
|
@@ -261,4 +318,7 @@ export declare class SemanticMemory {
|
|
|
261
318
|
}): string;
|
|
262
319
|
private getConnections;
|
|
263
320
|
}
|
|
321
|
+
export declare class EvidencePolicyError extends Error {
|
|
322
|
+
constructor(message: string);
|
|
323
|
+
}
|
|
264
324
|
//# sourceMappingURL=SemanticMemory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SemanticMemory.d.ts","sourceRoot":"","sources":["../../src/memory/SemanticMemory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,eAAe,EACf,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,cA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