@graphorin/memory 0.6.1 → 0.7.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/CHANGELOG.md +71 -0
- package/README.md +1 -1
- package/dist/conflict/index.js +0 -1
- package/dist/conflict/pipeline.js +0 -1
- package/dist/conflict/pipeline.js.map +1 -1
- package/dist/conflict/stages/stage3-heuristic-regex.js +0 -1
- package/dist/conflict/stages/stage3-heuristic-regex.js.map +1 -1
- package/dist/conflict/types.d.ts +1 -1
- package/dist/conflict/types.js.map +1 -1
- package/dist/consolidator/index.js +2 -0
- package/dist/consolidator/index.js.map +1 -1
- package/dist/consolidator/lock.js +7 -1
- package/dist/consolidator/lock.js.map +1 -1
- package/dist/consolidator/phases/deep.js +19 -12
- package/dist/consolidator/phases/deep.js.map +1 -1
- package/dist/consolidator/phases/induce.d.ts.map +1 -1
- package/dist/consolidator/phases/induce.js +2 -3
- package/dist/consolidator/phases/induce.js.map +1 -1
- package/dist/consolidator/phases/reflect.js +35 -8
- package/dist/consolidator/phases/reflect.js.map +1 -1
- package/dist/consolidator/phases/standard.js +199 -28
- package/dist/consolidator/phases/standard.js.map +1 -1
- package/dist/consolidator/reconcile.js +16 -15
- package/dist/consolidator/reconcile.js.map +1 -1
- package/dist/consolidator/runtime.d.ts.map +1 -1
- package/dist/consolidator/runtime.js +129 -47
- package/dist/consolidator/runtime.js.map +1 -1
- package/dist/consolidator/scheduler.d.ts +17 -3
- package/dist/consolidator/scheduler.d.ts.map +1 -1
- package/dist/consolidator/scheduler.js.map +1 -1
- package/dist/consolidator/types.d.ts +30 -1
- package/dist/consolidator/types.d.ts.map +1 -1
- package/dist/consolidator/types.js +10 -0
- package/dist/consolidator/types.js.map +1 -1
- package/dist/context-engine/compaction/clear-tool-results.d.ts +1 -1
- package/dist/context-engine/compaction/clear-tool-results.js +1 -1
- package/dist/context-engine/compaction/clear-tool-results.js.map +1 -1
- package/dist/context-engine/compaction/compactor.d.ts +1 -0
- package/dist/context-engine/compaction/compactor.d.ts.map +1 -1
- package/dist/context-engine/compaction/compactor.js +32 -8
- package/dist/context-engine/compaction/compactor.js.map +1 -1
- package/dist/context-engine/compaction/hooks/types.d.ts +1 -1
- package/dist/context-engine/compaction/index.d.ts +1 -0
- package/dist/context-engine/compaction/templates/marker.d.ts +33 -0
- package/dist/context-engine/compaction/templates/marker.d.ts.map +1 -0
- package/dist/context-engine/compaction/templates/marker.js +34 -0
- package/dist/context-engine/compaction/templates/marker.js.map +1 -0
- package/dist/context-engine/compaction/templates/summary-9-section.d.ts +1 -1
- package/dist/context-engine/compaction/templates/summary-9-section.d.ts.map +1 -1
- package/dist/context-engine/compaction/templates/summary-9-section.js +4 -3
- package/dist/context-engine/compaction/templates/summary-9-section.js.map +1 -1
- package/dist/context-engine/engine.d.ts +7 -176
- package/dist/context-engine/engine.d.ts.map +1 -1
- package/dist/context-engine/engine.js +0 -2
- package/dist/context-engine/engine.js.map +1 -1
- package/dist/context-engine/index.d.ts +8 -49
- package/dist/context-engine/io-types.d.ts +144 -0
- package/dist/context-engine/io-types.d.ts.map +1 -0
- package/dist/context-engine/locale-packs/types.d.ts +1 -1
- package/dist/context-engine/locale-packs/types.js.map +1 -1
- package/dist/context-engine/privacy-filter.d.ts +1 -2
- package/dist/context-engine/privacy-filter.d.ts.map +1 -1
- package/dist/context-engine/privacy-filter.js +1 -2
- package/dist/context-engine/privacy-filter.js.map +1 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.js +2 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/facade.d.ts +43 -52
- package/dist/facade.d.ts.map +1 -1
- package/dist/facade.js +5 -3
- package/dist/facade.js.map +1 -1
- package/dist/graph/entity-resolver.js +1 -1
- package/dist/graph/entity-resolver.js.map +1 -1
- package/dist/index.d.ts +16 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/envelope.js +57 -0
- package/dist/internal/envelope.js.map +1 -0
- package/dist/internal/injection-heuristics.js +0 -0
- package/dist/internal/injection-heuristics.js.map +1 -1
- package/dist/internal/llm-json.js +40 -0
- package/dist/internal/llm-json.js.map +1 -0
- package/dist/internal/storage-adapter.d.ts +23 -10
- package/dist/internal/storage-adapter.d.ts.map +1 -1
- package/dist/memory-interface.d.ts +131 -0
- package/dist/memory-interface.d.ts.map +1 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/dist/search/iterative.d.ts.map +1 -1
- package/dist/search/iterative.js +2 -3
- package/dist/search/iterative.js.map +1 -1
- package/dist/search/query-transform.d.ts.map +1 -1
- package/dist/search/query-transform.js +2 -3
- package/dist/search/query-transform.js.map +1 -1
- package/dist/tiers/episodic-memory.js +3 -3
- package/dist/tiers/episodic-memory.js.map +1 -1
- package/dist/tiers/index.d.ts +2 -2
- package/dist/tiers/insight-memory.js +1 -1
- package/dist/tiers/insight-memory.js.map +1 -1
- package/dist/tiers/procedural-memory.d.ts +1 -1
- package/dist/tiers/procedural-memory.js +2 -2
- package/dist/tiers/procedural-memory.js.map +1 -1
- package/dist/tiers/semantic-memory.d.ts +58 -4
- package/dist/tiers/semantic-memory.d.ts.map +1 -1
- package/dist/tiers/semantic-memory.js +103 -20
- package/dist/tiers/semantic-memory.js.map +1 -1
- package/dist/tools/block-tools.d.ts +19 -57
- package/dist/tools/block-tools.d.ts.map +1 -1
- package/dist/tools/block-tools.js.map +1 -1
- package/dist/tools/fact-tools.d.ts +53 -214
- package/dist/tools/fact-tools.d.ts.map +1 -1
- package/dist/tools/fact-tools.js +3 -2
- package/dist/tools/fact-tools.js.map +1 -1
- package/dist/tools/recall-tools.d.ts +34 -175
- package/dist/tools/recall-tools.d.ts.map +1 -1
- package/dist/tools/recall-tools.js +5 -4
- package/dist/tools/recall-tools.js.map +1 -1
- package/dist/tools/runbook-tools.d.ts +15 -58
- package/dist/tools/runbook-tools.d.ts.map +1 -1
- package/dist/tools/runbook-tools.js.map +1 -1
- package/dist/tools/types.d.ts +1 -1
- package/package.json +18 -17
- package/src/conflict/index.ts +29 -0
- package/src/conflict/locale-packs/en.ts +142 -0
- package/src/conflict/locale-packs/index.ts +17 -0
- package/src/conflict/locale-packs/types.ts +138 -0
- package/src/conflict/pipeline.ts +371 -0
- package/src/conflict/stages/helpers.ts +65 -0
- package/src/conflict/stages/stage1-exact-dedup.ts +40 -0
- package/src/conflict/stages/stage2-embedding-three-zone.ts +54 -0
- package/src/conflict/stages/stage3-heuristic-regex.ts +51 -0
- package/src/conflict/stages/stage4-subject-predicate.ts +46 -0
- package/src/conflict/stages/stage5-defer-to-deep.ts +34 -0
- package/src/conflict/types.ts +263 -0
- package/src/consolidator/budget.ts +312 -0
- package/src/consolidator/decay.ts +246 -0
- package/src/consolidator/dlq.ts +61 -0
- package/src/consolidator/errors.ts +87 -0
- package/src/consolidator/idempotency.ts +27 -0
- package/src/consolidator/index.ts +269 -0
- package/src/consolidator/lock.ts +141 -0
- package/src/consolidator/noise-filter.ts +235 -0
- package/src/consolidator/phases/deep.ts +308 -0
- package/src/consolidator/phases/induce.ts +423 -0
- package/src/consolidator/phases/learned-context.ts +233 -0
- package/src/consolidator/phases/light.ts +166 -0
- package/src/consolidator/phases/reflect.ts +504 -0
- package/src/consolidator/phases/standard.ts +1002 -0
- package/src/consolidator/reconcile.ts +273 -0
- package/src/consolidator/runtime.ts +1049 -0
- package/src/consolidator/scheduler.ts +182 -0
- package/src/consolidator/triggers.ts +134 -0
- package/src/consolidator/types.ts +622 -0
- package/src/context-engine/annotations.ts +161 -0
- package/src/context-engine/auto-recall.ts +92 -0
- package/src/context-engine/compaction/clear-tool-results.ts +232 -0
- package/src/context-engine/compaction/compactor.ts +403 -0
- package/src/context-engine/compaction/hooks/reanchor-persona-block.ts +55 -0
- package/src/context-engine/compaction/hooks/reanchor-pinned-facts.ts +66 -0
- package/src/context-engine/compaction/hooks/reanchor-project-rules.ts +57 -0
- package/src/context-engine/compaction/hooks/reanchor-recent-results.ts +116 -0
- package/src/context-engine/compaction/hooks/types.ts +68 -0
- package/src/context-engine/compaction/index.ts +60 -0
- package/src/context-engine/compaction/templates/marker.ts +33 -0
- package/src/context-engine/compaction/templates/summary-9-section.ts +223 -0
- package/src/context-engine/compaction/thresholds.ts +107 -0
- package/src/context-engine/compaction/types.ts +255 -0
- package/src/context-engine/engine.ts +970 -0
- package/src/context-engine/index.ts +118 -0
- package/src/context-engine/io-types.ts +162 -0
- package/src/context-engine/locale-packs/en.ts +107 -0
- package/src/context-engine/locale-packs/index.ts +19 -0
- package/src/context-engine/locale-packs/resolver.ts +197 -0
- package/src/context-engine/locale-packs/types.ts +177 -0
- package/src/context-engine/metadata.ts +114 -0
- package/src/context-engine/preambles/inbound-en.ts +19 -0
- package/src/context-engine/privacy-filter.ts +190 -0
- package/src/context-engine/templates/base-en.ts +19 -0
- package/src/context-engine/templates/composer.ts +91 -0
- package/src/context-engine/token-budget.ts +319 -0
- package/src/context-engine/token-counter.ts +157 -0
- package/src/errors/index.ts +273 -0
- package/src/facade.ts +750 -0
- package/src/graph/entity-resolver.ts +364 -0
- package/src/graph/index.ts +24 -0
- package/src/index.ts +259 -0
- package/src/internal/contextualize.ts +173 -0
- package/src/internal/embedder-binding.ts +53 -0
- package/src/internal/envelope.ts +70 -0
- package/src/internal/id.ts +23 -0
- package/src/internal/injection-heuristics.ts +0 -0
- package/src/internal/llm-json.ts +38 -0
- package/src/internal/spans.ts +35 -0
- package/src/internal/storage-adapter.ts +963 -0
- package/src/memory-interface.ts +158 -0
- package/src/migration/embedder-migration.ts +237 -0
- package/src/migration/index.ts +13 -0
- package/src/search/explain.ts +123 -0
- package/src/search/fit-weights.ts +109 -0
- package/src/search/graph-ppr.ts +38 -0
- package/src/search/index.ts +55 -0
- package/src/search/iterative.ts +658 -0
- package/src/search/query-transform.ts +285 -0
- package/src/search/rrf.ts +225 -0
- package/src/search/trust.ts +55 -0
- package/src/search/types.ts +50 -0
- package/src/tiers/episodic-memory.ts +463 -0
- package/src/tiers/index.ts +50 -0
- package/src/tiers/insight-memory.ts +208 -0
- package/src/tiers/procedural-memory.ts +482 -0
- package/src/tiers/semantic-memory.ts +1729 -0
- package/src/tiers/session-memory.ts +271 -0
- package/src/tiers/shared-memory.ts +62 -0
- package/src/tiers/working-memory.ts +368 -0
- package/src/tools/block-tools.ts +172 -0
- package/src/tools/fact-tools.ts +473 -0
- package/src/tools/index.ts +109 -0
- package/src/tools/recall-tools.ts +303 -0
- package/src/tools/runbook-tools.ts +107 -0
- package/src/tools/taint.ts +39 -0
- package/src/tools/types.ts +37 -0
- package/dist/conflict/locale-packs/index.js +0 -4
- package/dist/context-engine/compaction/index.js +0 -10
- package/dist/context-engine/index.d.ts.map +0 -1
- package/dist/context-engine/index.js +0 -25
- package/dist/context-engine/locale-packs/index.js +0 -4
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error classes raised by `@graphorin/memory`. Every memory
|
|
3
|
+
* subsystem throws one of these instead of plain `Error` so consumers
|
|
4
|
+
* can pattern-match on `kind` and `name` without parsing the message.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Base class for every error raised by `@graphorin/memory`. Carries a
|
|
11
|
+
* stable lowercase `kind` discriminator and an optional `hint`
|
|
12
|
+
* surfaced to operators (CLI command / docs link to fix the issue).
|
|
13
|
+
*
|
|
14
|
+
* @stable
|
|
15
|
+
*/
|
|
16
|
+
export abstract class GraphorinMemoryError extends Error {
|
|
17
|
+
/** Stable lowercase discriminator. */
|
|
18
|
+
abstract readonly kind: string;
|
|
19
|
+
/** Optional actionable hint surfaced to operators. */
|
|
20
|
+
readonly hint?: string;
|
|
21
|
+
|
|
22
|
+
constructor(message: string, options?: { cause?: unknown; hint?: string }) {
|
|
23
|
+
super(message, options !== undefined && 'cause' in options ? { cause: options.cause } : {});
|
|
24
|
+
if (options?.hint !== undefined) {
|
|
25
|
+
this.hint = options.hint;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Raised when a memory write would reference an embedder that is not
|
|
32
|
+
* registered in the storage layer's `embedding_meta` registry.
|
|
33
|
+
*
|
|
34
|
+
* @stable
|
|
35
|
+
*/
|
|
36
|
+
export class EmbedderRegistrationError extends GraphorinMemoryError {
|
|
37
|
+
override readonly name = 'EmbedderRegistrationError';
|
|
38
|
+
readonly kind = 'embedder-registration' as const;
|
|
39
|
+
readonly embedderId: string;
|
|
40
|
+
|
|
41
|
+
constructor(embedderId: string, options?: { cause?: unknown }) {
|
|
42
|
+
super(
|
|
43
|
+
`[graphorin/memory] embedder '${embedderId}' is not registered. ` +
|
|
44
|
+
'createMemory({ embedder, ... }) registers the configured embedder; ' +
|
|
45
|
+
'manual writes must reference an already-registered embedder_id.',
|
|
46
|
+
{
|
|
47
|
+
...(options?.cause !== undefined ? { cause: options.cause } : {}),
|
|
48
|
+
hint: 'Pass `embedder` to createMemory(...) so the registration runs at startup.',
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
this.embedderId = embedderId;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Raised when a memory tool is invoked outside the per-tool ACL or the
|
|
57
|
+
* memory-modification guard tier rejects the call.
|
|
58
|
+
*
|
|
59
|
+
* @stable
|
|
60
|
+
*/
|
|
61
|
+
export class MemoryToolDeniedError extends GraphorinMemoryError {
|
|
62
|
+
override readonly name = 'MemoryToolDeniedError';
|
|
63
|
+
readonly kind = 'memory-tool-denied' as const;
|
|
64
|
+
readonly toolName: string;
|
|
65
|
+
readonly reason: string;
|
|
66
|
+
|
|
67
|
+
constructor(toolName: string, reason: string) {
|
|
68
|
+
super(`[graphorin/memory] memory tool '${toolName}' was denied: ${reason}`, {
|
|
69
|
+
hint: 'Check the tool authorisation matrix and the memory-modification guard tier policy.',
|
|
70
|
+
});
|
|
71
|
+
this.toolName = toolName;
|
|
72
|
+
this.reason = reason;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Raised by `WorkingMemory` when a write would exceed the declared
|
|
78
|
+
* `charLimit` and the overflow policy is `'reject'`.
|
|
79
|
+
*
|
|
80
|
+
* @stable
|
|
81
|
+
*/
|
|
82
|
+
export class WorkingBlockOverflowError extends GraphorinMemoryError {
|
|
83
|
+
override readonly name = 'WorkingBlockOverflowError';
|
|
84
|
+
readonly kind = 'working-block-overflow' as const;
|
|
85
|
+
readonly label: string;
|
|
86
|
+
readonly attempted: number;
|
|
87
|
+
readonly charLimit: number;
|
|
88
|
+
|
|
89
|
+
constructor(label: string, attempted: number, charLimit: number) {
|
|
90
|
+
super(
|
|
91
|
+
`[graphorin/memory] working block '${label}' overflow: attempted ${attempted} chars, limit is ${charLimit}.`,
|
|
92
|
+
{
|
|
93
|
+
hint: "Switch the block's overflow policy to 'truncate' or shorten the input.",
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
this.label = label;
|
|
97
|
+
this.attempted = attempted;
|
|
98
|
+
this.charLimit = charLimit;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Raised by `WorkingMemory.replace(...)` when the supplied unique
|
|
104
|
+
* substring is not present (or appears more than once) in the block
|
|
105
|
+
* value.
|
|
106
|
+
*
|
|
107
|
+
* @stable
|
|
108
|
+
*/
|
|
109
|
+
export class WorkingBlockReplaceMismatchError extends GraphorinMemoryError {
|
|
110
|
+
override readonly name = 'WorkingBlockReplaceMismatchError';
|
|
111
|
+
readonly kind = 'working-block-replace-mismatch' as const;
|
|
112
|
+
readonly label: string;
|
|
113
|
+
readonly occurrences: number;
|
|
114
|
+
|
|
115
|
+
constructor(label: string, occurrences: number) {
|
|
116
|
+
super(
|
|
117
|
+
`[graphorin/memory] block_replace on '${label}' expected exactly one occurrence of the unique substring, found ${occurrences}.`,
|
|
118
|
+
{
|
|
119
|
+
hint: 'Pass a longer unique substring or use block_rethink to replace the entire value.',
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
this.label = label;
|
|
123
|
+
this.occurrences = occurrences;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Thrown when any mutation targets a block defined with
|
|
129
|
+
* `readOnly: true` (MRET-14). Previously this guard threw
|
|
130
|
+
* `WorkingBlockReplaceMismatchError(label, 0)` - semantically "your
|
|
131
|
+
* unique substring matched 0 times", which misled callers that retry
|
|
132
|
+
* replace operations on mismatch.
|
|
133
|
+
*
|
|
134
|
+
* @stable
|
|
135
|
+
*/
|
|
136
|
+
export class WorkingBlockReadOnlyError extends GraphorinMemoryError {
|
|
137
|
+
override readonly name = 'WorkingBlockReadOnlyError';
|
|
138
|
+
readonly kind = 'working-block-read-only' as const;
|
|
139
|
+
readonly label: string;
|
|
140
|
+
|
|
141
|
+
constructor(label: string) {
|
|
142
|
+
super(`[graphorin/memory] block '${label}' is read-only - mutations are not allowed.`, {
|
|
143
|
+
hint: 'Define the block without readOnly, or write through an operator path that redefines it.',
|
|
144
|
+
});
|
|
145
|
+
this.label = label;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Raised by the embedder migration runner when the operator attempts a
|
|
151
|
+
* silent embedder swap under the `lock-on-first` policy.
|
|
152
|
+
*
|
|
153
|
+
* @stable
|
|
154
|
+
*/
|
|
155
|
+
export class EmbedderMigrationLockedError extends GraphorinMemoryError {
|
|
156
|
+
override readonly name = 'EmbedderMigrationLockedError';
|
|
157
|
+
readonly kind = 'embedder-migration-locked' as const;
|
|
158
|
+
readonly source: string;
|
|
159
|
+
readonly target: string;
|
|
160
|
+
|
|
161
|
+
constructor(source: string, target: string) {
|
|
162
|
+
super(
|
|
163
|
+
`[graphorin/memory] cannot swap embedder from '${source}' to '${target}' under the 'lock-on-first' policy. ` +
|
|
164
|
+
'Run `graphorin memory migrate` (Phase 15) or pass `policy: "auto-migrate"` / "multi-active".',
|
|
165
|
+
{
|
|
166
|
+
hint: 'Plan an explicit migration before swapping the active embedder.',
|
|
167
|
+
},
|
|
168
|
+
);
|
|
169
|
+
this.source = source;
|
|
170
|
+
this.target = target;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Raised by `migrateEmbedder(...)` when the runner is interrupted via
|
|
176
|
+
* `AbortSignal`. The surrounding `for-await` loop receives this error so
|
|
177
|
+
* the operator can re-run the migration. MST-12: there is no persisted
|
|
178
|
+
* cursor today, so a re-run restarts from the beginning.
|
|
179
|
+
*
|
|
180
|
+
* @stable
|
|
181
|
+
*/
|
|
182
|
+
export class EmbedderMigrationAbortedError extends GraphorinMemoryError {
|
|
183
|
+
override readonly name = 'EmbedderMigrationAbortedError';
|
|
184
|
+
readonly kind = 'embedder-migration-aborted' as const;
|
|
185
|
+
readonly migrationId: string;
|
|
186
|
+
|
|
187
|
+
constructor(migrationId: string) {
|
|
188
|
+
super(
|
|
189
|
+
`[graphorin/memory] embedder migration '${migrationId}' aborted before completion. ` +
|
|
190
|
+
'Re-run `migrateEmbedder(...)` to restart (there is no persisted cursor yet, so it begins again).',
|
|
191
|
+
{
|
|
192
|
+
hint: 'Re-invoke migrateEmbedder(...) to restart the migration.',
|
|
193
|
+
},
|
|
194
|
+
);
|
|
195
|
+
this.migrationId = migrationId;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Raised by the migration runner when the migration references embedders
|
|
201
|
+
* that are no longer registered (e.g. the operator removed the underlying
|
|
202
|
+
* tables manually).
|
|
203
|
+
*
|
|
204
|
+
* @stable
|
|
205
|
+
*/
|
|
206
|
+
export class EmbedderMigrationStateError extends GraphorinMemoryError {
|
|
207
|
+
override readonly name = 'EmbedderMigrationStateError';
|
|
208
|
+
readonly kind = 'embedder-migration-state' as const;
|
|
209
|
+
|
|
210
|
+
constructor(message: string) {
|
|
211
|
+
super(`[graphorin/memory] ${message}`, {
|
|
212
|
+
hint: 'Re-register the source/target embedders (or re-run with the current ones) before retrying.',
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Raised by `SemanticMemory.validate` (P1-4 / MRET-3) when a caller
|
|
219
|
+
* tries to promote a fact whose quarantine was triggered by the offline
|
|
220
|
+
* injection heuristics. Such a fact is a memory-poisoning candidate: the
|
|
221
|
+
* agent's own `fact_validate` tool must never be able to admit it into
|
|
222
|
+
* action-driving recall, so promotion is refused unless an operator
|
|
223
|
+
* passes the explicit `force` flag through the programmatic API.
|
|
224
|
+
*
|
|
225
|
+
* @stable
|
|
226
|
+
*/
|
|
227
|
+
export class QuarantinePromotionRefusedError extends GraphorinMemoryError {
|
|
228
|
+
override readonly name = 'QuarantinePromotionRefusedError';
|
|
229
|
+
readonly kind = 'quarantine-promotion-refused' as const;
|
|
230
|
+
readonly factId: string;
|
|
231
|
+
/** Injection-rule labels that tripped on the fact's text. */
|
|
232
|
+
readonly markers: ReadonlyArray<string>;
|
|
233
|
+
|
|
234
|
+
constructor(factId: string, markers: ReadonlyArray<string>) {
|
|
235
|
+
super(
|
|
236
|
+
`[graphorin/memory] refusing to promote fact '${factId}' out of quarantine: ` +
|
|
237
|
+
`its text trips the injection heuristics (${markers.join(', ')}). ` +
|
|
238
|
+
'Promotion of an injection-flagged memory is an operator action - ' +
|
|
239
|
+
'pass `{ force: true }` to validate(...) from a trusted (non-agent) caller after review.',
|
|
240
|
+
{
|
|
241
|
+
hint: 'Review the quarantined fact, then promote it with validate(scope, id, reason, { force: true }) from an operator context.',
|
|
242
|
+
},
|
|
243
|
+
);
|
|
244
|
+
this.factId = factId;
|
|
245
|
+
this.markers = Object.freeze([...markers]);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Raised when `ProceduralMemory.induce` (P2-2) is called but no
|
|
251
|
+
* workflow inducer was configured. Induction abstracts concrete values into
|
|
252
|
+
* variables, which needs a provider - so the capability is opt-in and the
|
|
253
|
+
* default (offline) procedural tier never silently no-ops a requested
|
|
254
|
+
* induction.
|
|
255
|
+
*
|
|
256
|
+
* @stable
|
|
257
|
+
*/
|
|
258
|
+
export class ProcedureInductionNotConfiguredError extends GraphorinMemoryError {
|
|
259
|
+
override readonly name = 'ProcedureInductionNotConfiguredError';
|
|
260
|
+
readonly kind = 'procedure-induction-not-configured' as const;
|
|
261
|
+
|
|
262
|
+
constructor(options?: { cause?: unknown }) {
|
|
263
|
+
super(
|
|
264
|
+
'[graphorin/memory] procedure induction requires a provider. ' +
|
|
265
|
+
'ProceduralMemory.induce(...) needs an inducer to abstract values into ' +
|
|
266
|
+
'variables; enable it with createMemory({ procedureInduction: { provider } }).',
|
|
267
|
+
{
|
|
268
|
+
...(options?.cause !== undefined ? { cause: options.cause } : {}),
|
|
269
|
+
hint: 'Pass `procedureInduction: { provider }` to createMemory(...).',
|
|
270
|
+
},
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
}
|