@hy-sde-org/dsh-memory-extraction 0.1.2-rc.1 → 0.1.5-rc.1

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.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/memory/memory-extraction/README.md
5
- README.md: 25234ba6ae648ede9e26988d72271e257596e5eb
6
- README.zh.md: c7b48d15b06fe6381c66ad5bfd3824ba6e54a258
5
+ README.md: 5d53e50b06ffb7d095101de40a8ae807f5a29f57
6
+ README.zh.md: f2c32b514ce9d3a27540479d0f5dcd4ba503210d
package/README.md CHANGED
@@ -1,8 +1,3 @@
1
- ---
2
- description: "Automatic long-term-memory extraction at compaction checkpoints: evidence projection, proposal/canonicalization pipeline, gated ctx.memory commit, and durable cursors/receipts/failure ledger (Maka port, slice No. 2)."
3
- kind: "package-reference"
4
- ---
5
-
6
1
  # @hy-sde-org/dsh-memory-extraction
7
2
 
8
3
  English | [中文](README.zh.md)
@@ -46,6 +41,16 @@ per-session serialized and never block the compaction listener.
46
41
  commit-side dedupe probe heals a crash between items and receipt.
47
42
  5. **Subagents are excluded** — the gate re-checks after every model call and
48
43
  rejects child sessions by default (`excludeSubagents: true`).
44
+ 6. **Cross-session evidence floor (E1)** — a fact only commits once
45
+ `minGapEvidence` **distinct** sessions (default 2; one session never counts
46
+ twice, even across its own compactions) have proposed the same durable fact.
47
+ Uncorroborated facts become `gaps` sighted in the ledger, shown to later
48
+ proposal passes as open pending facts (the model cites a `gapId` instead of
49
+ coining a paraphrase); identity falls back to the normalized content hash.
50
+ A fact retires (covered) when it commits or is found already in the bank.
51
+ Sightings older than `gapLedgerMaxAgeMs` (default 90 d) expire. Deferrals
52
+ still advance the cursor and settle the receipt; reads/writes of the ledger
53
+ take a config value of `0` off entirely (pre-E1 behavior).
49
54
 
50
55
  ## Table of Contents
51
56
 
@@ -74,11 +79,12 @@ every session's events. There is no agent-preset contribution and no tool.
74
79
  importance: 0.5 # bank importance for auto-extracted facts (default 0.5)
75
80
  dedupe: true # probe the bank before committing duplicates (default true)
76
81
  timeoutMs: 60000 # auxiliary call timeout (default 60000)
82
+ minGapEvidence: 2 # distinct sessions before a fact commits (default 2; 0 disables the floor)
83
+ gapLedgerMaxAgeMs: 7776000000 # sightings older than this stop counting (default 90 d in ms)
77
84
  ```
78
85
 
79
86
  Its storage backend must expose a `kv` facet (the shipped `sqlite` backend
80
- does; `storage-json` does not) — see the
81
- [example patch](../../../apps/cli/config/examples/memory-extraction/cordis.yml).
87
+ does; `storage-json` does not) — the row above is the complete host wiring.
82
88
  The engine itself is pure and testable without cordis:
83
89
 
84
90
  ```ts
@@ -92,7 +98,10 @@ const result = await engine.execute(snapshot) // never throws; idempotent by o
92
98
 
93
99
  The plugin boots asynchronously: an effect opens the control unit via
94
100
  `storage.backend.<backend>.kv.open(MemoryExtractionControlStore.descriptor)`
95
- (`memory_extraction`, version 1, tables `cursors`/`receipts`/`failures`) and
101
+ (`memory_extraction`, version 1, tables `cursors`/`receipts`/`failures`/`gaps`
102
+ — the gap table is additive and the version stays 1 because the storage-sqlite
103
+ backend rejects version bumps on existing media; `CREATE TABLE IF NOT EXISTS`
104
+ materializes it on upgrade) and
96
105
  registers the `session/event` listener. A missing backend logs and leaves the
97
106
  plugin inert instead of failing composition.
98
107
 
@@ -105,7 +114,7 @@ plugin inert instead of failing composition.
105
114
  `search_required` / `cannot_resolve` / canonicalization), prompt builders that
106
115
  frame evidence as **untrusted data**, admission (verbatim quotes, min 4 chars,
107
116
  secret rejection, NFC + injection neutralization, 2 000-char content cap).
108
- - `src/control.ts` — the durable cursor/receipt/failure store over one
117
+ - `src/control.ts` — the durable cursor/receipt/failure/gap store over one
109
118
  `KvUnit` (single write chain; heal-on-open; write ordering documented).
110
119
  - `src/engine.ts` — the state machine: idempotency receipt, gate, empty-range
111
120
  advance, one-retry-then-discard, 3-call budget, commit ordering.
@@ -119,8 +128,7 @@ plugin inert instead of failing composition.
119
128
 
120
129
  ## Further Exploration
121
130
 
122
- - The Maka source this was ported from: `packages/runtime/src/memory-extraction.ts`
123
- in the Maka repository.
131
+ - The Maka source this was ported from: [`memory-extraction.ts`](https://github.com/apache/maka/blob/main/packages/runtime/src/memory-extraction.ts).
124
132
  - The compaction lifecycle that emits the boundary events:
125
133
  `@deepseek-ai/dsh-compaction`.
126
134
 
@@ -140,6 +148,13 @@ the bounded, user-authored evidence plus a short localization context.
140
148
  retry.
141
149
  - **No persistent re-extraction** on evidence growth: a checkpoint that failed
142
150
  is retried once and then dropped.
151
+ - **Gap identity is model-cited or exact-hash** — a paraphrase the proposal
152
+ pass does not link to an open pending fact via `gapId` falls back to the
153
+ normalized content hash and stays pending until a byte-identical sighting (or
154
+ an explicit cite) corroborates it. No lexical/semantic matching is done.
155
+ - **Deferred facts are not dedupe-probed** — a fact someone already
156
+ `retain`ed that the extraction proposes never retires via the bank check; it
157
+ retires when a second session cites it or its sighting expires.
143
158
  - **Maka facets are not ported** (kind/temporal/scope/tags); every extracted
144
159
  fact lands with `source: 'memory_extract'` and the configured importance.
145
160
  - **No per-verb tools**: `memory_remember`/`memory_extract` are reserved names;
package/README.zh.md CHANGED
@@ -1,8 +1,3 @@
1
- ---
2
- description: "在压缩检查点自动提取长期记忆:证据投影、提案/规范化流水线、受门控的 ctx.memory 提交,以及持久化的游标/回执/失败账本(Maka 移植,切片 No. 2)。"
3
- kind: "package-reference"
4
- ---
5
-
6
1
  # @hy-sde-org/dsh-memory-extraction
7
2
 
8
3
  [English](README.md) | 中文
@@ -69,8 +64,7 @@ kind: "package-reference"
69
64
  ```
70
65
 
71
66
  其存储后端必须暴露 `kv` 面(shipped 的 `sqlite` 后端可以;`storage-json`
72
- 不可以)—— 参见
73
- [示例补丁](../../../apps/cli/config/examples/memory-extraction/cordis.yml)。
67
+ 不可以)—— 上面展示的行即完整主机接线。
74
68
  引擎本身是纯的,可在无 cordis 下测试:
75
69
 
76
70
  ```ts
@@ -110,7 +104,7 @@ const result = await engine.execute(snapshot) // never throws; idempotent by o
110
104
  <a id="further-exploration"></a>
111
105
  ## 进一步探索
112
106
 
113
- - 移植来源:Maka 仓库 `packages/runtime/src/memory-extraction.ts`。
107
+ - 移植来源:[Maka 的 `memory-extraction.ts`](https://github.com/apache/maka/blob/main/packages/runtime/src/memory-extraction.ts)。
114
108
  - 产生边界事件的压缩生命周期:`@deepseek-ai/dsh-compaction`。
115
109
 
116
110
  <a id="model-experience"></a>
package/dist/control.d.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  /**
2
2
  * The memory-extraction control store: durable per-session cursor, idempotency
3
- * receipts, and the single pending-failure record, over one {@link KvUnit}
4
- * (`memory_extraction`). Same pattern as `dsh-graph-control`: single write
5
- * chain, heal-on-open, no SQL transactions (the storage contract already
6
- * forbids concurrent writers on one unit).
3
+ * receipts, the single pending-failure record, and the cross-session gap
4
+ * ledger, over one {@link KvUnit} (`memory_extraction`). Same pattern as
5
+ * `dsh-graph-control`: single write chain, heal-on-open, no SQL transactions
6
+ * (the storage contract already forbids concurrent writers on one unit).
7
+ *
8
+ * The `gaps` table is ADDITIVE and the unit version stays 1 on purpose: the
9
+ * storage-sqlite backend stamps a unit's version on the medium at first
10
+ * materialization and rejects any mismatch on reopen (no migrations exist), so
11
+ * a version bump would brick every existing control unit on upgrade. Adding a
12
+ * table is the compatible path: `CREATE TABLE IF NOT EXISTS` at open
13
+ * materializes `gaps` on an existing v1 unit with no data loss.
7
14
  *
8
15
  * Write ordering is load-bearing: the CURSOR is written before the receipt so
9
16
  * a crash between the two can never double-process a range (the next trigger's
@@ -12,7 +19,7 @@
12
19
  * @module @hy-sde-org/dsh-memory-extraction/control
13
20
  */
14
21
  import type { KvUnit } from '@deepseek-ai/dsh-storage';
15
- import type { MemoryExtractionCursor, MemoryExtractionReceipt, PendingMemoryExtractionFailure } from './types.ts';
22
+ import type { MemoryExtractionCursor, MemoryExtractionGapEntry, MemoryExtractionReceipt, PendingMemoryExtractionFailure } from './types.ts';
16
23
  export declare const MEMORY_EXTRACTION_CONTROL_UNIT_NAME = "memory_extraction";
17
24
  export declare const MEMORY_EXTRACTION_CONTROL_UNIT_VERSION = 1;
18
25
  export declare class MemoryExtractionControlStore {
@@ -21,7 +28,7 @@ export declare class MemoryExtractionControlStore {
21
28
  static readonly descriptor: {
22
29
  name: string;
23
30
  version: number;
24
- tables: ("cursors" | "receipts" | "failures")[];
31
+ tables: ("cursors" | "receipts" | "failures" | "gaps")[];
25
32
  hasGlobal: boolean;
26
33
  };
27
34
  private constructor();
@@ -38,5 +45,9 @@ export declare class MemoryExtractionControlStore {
38
45
  readFailure(sessionId: string): Promise<PendingMemoryExtractionFailure | undefined>;
39
46
  writeFailure(failure: PendingMemoryExtractionFailure): Promise<void>;
40
47
  deleteFailure(sessionId: string): Promise<void>;
48
+ /** Read every gap entry (open and covered). The engine applies expiry/floor math. */
49
+ readGaps(): Promise<readonly MemoryExtractionGapEntry[]>;
50
+ writeGap(entry: MemoryExtractionGapEntry): Promise<void>;
51
+ deleteGap(id: string): Promise<void>;
41
52
  }
42
53
  //# sourceMappingURL=control.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../src/control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC/B,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,mCAAmC,sBAAsB,CAAA;AACtE,eAAO,MAAM,sCAAsC,IAAI,CAAA;AAQvD,qBAAa,4BAA4B;IASnB,OAAO,CAAC,QAAQ,CAAC,EAAE;IARvC,0FAA0F;IAC1F,MAAM,CAAC,QAAQ,CAAC,UAAU;;;;;MAKzB;IAED,OAAO;IAEP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AAG,4BAA4B;IAIrD,8EAA8E;IAC9E,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,IAAI,CAAsC;IAI5C,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAUhF,8EAA8E;IAC9E,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpD,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC;IAqBpF,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMvD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,GAAG,SAAS,CAAC;IA8BzF,YAAY,CAAC,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM/C,qFAAqF;IAC/E,QAAQ,IAAI,OAAO,CAAC,SAAS,wBAAwB,EAAE,CAAC;IAW9D,QAAQ,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrC"}
package/dist/control.js CHANGED
@@ -1,9 +1,16 @@
1
1
  /**
2
2
  * The memory-extraction control store: durable per-session cursor, idempotency
3
- * receipts, and the single pending-failure record, over one {@link KvUnit}
4
- * (`memory_extraction`). Same pattern as `dsh-graph-control`: single write
5
- * chain, heal-on-open, no SQL transactions (the storage contract already
6
- * forbids concurrent writers on one unit).
3
+ * receipts, the single pending-failure record, and the cross-session gap
4
+ * ledger, over one {@link KvUnit} (`memory_extraction`). Same pattern as
5
+ * `dsh-graph-control`: single write chain, heal-on-open, no SQL transactions
6
+ * (the storage contract already forbids concurrent writers on one unit).
7
+ *
8
+ * The `gaps` table is ADDITIVE and the unit version stays 1 on purpose: the
9
+ * storage-sqlite backend stamps a unit's version on the medium at first
10
+ * materialization and rejects any mismatch on reopen (no migrations exist), so
11
+ * a version bump would brick every existing control unit on upgrade. Adding a
12
+ * table is the compatible path: `CREATE TABLE IF NOT EXISTS` at open
13
+ * materializes `gaps` on an existing v1 unit with no data loss.
7
14
  *
8
15
  * Write ordering is load-bearing: the CURSOR is written before the receipt so
9
16
  * a crash between the two can never double-process a range (the next trigger's
@@ -13,7 +20,7 @@
13
20
  */
14
21
  export const MEMORY_EXTRACTION_CONTROL_UNIT_NAME = 'memory_extraction';
15
22
  export const MEMORY_EXTRACTION_CONTROL_UNIT_VERSION = 1;
16
- const UNIT_TABLES = ['cursors', 'receipts', 'failures'];
23
+ const UNIT_TABLES = ['cursors', 'receipts', 'failures', 'gaps'];
17
24
  function isRecord(value) {
18
25
  return typeof value === 'object' && value !== null && !Array.isArray(value);
19
26
  }
@@ -121,5 +128,56 @@ export class MemoryExtractionControlStore {
121
128
  deleteFailure(sessionId) {
122
129
  return this.withChain(() => this.kv.deleteRecord('failures', sessionId));
123
130
  }
131
+ /* ── gap ledger (cross-session evidence floor) ────────────────────────── */
132
+ /** Read every gap entry (open and covered). The engine applies expiry/floor math. */
133
+ async readGaps() {
134
+ const { tables } = await this.kv.loadAll();
135
+ const rows = tables['gaps'] ?? {};
136
+ const entries = [];
137
+ for (const [id, value] of Object.entries(rows)) {
138
+ const entry = parseGapEntry(id, value);
139
+ if (entry !== undefined)
140
+ entries.push(entry);
141
+ }
142
+ return entries;
143
+ }
144
+ writeGap(entry) {
145
+ return this.withChain(() => this.kv.putRecord('gaps', entry.id, { ...entry }));
146
+ }
147
+ deleteGap(id) {
148
+ return this.withChain(() => this.kv.deleteRecord('gaps', id));
149
+ }
150
+ }
151
+ function parseGapEntry(id, value) {
152
+ if (!isRecord(value))
153
+ return undefined;
154
+ const content = value['content'];
155
+ const sightings = value['sightings'];
156
+ const covered = value['covered'];
157
+ const updatedAt = value['updatedAt'];
158
+ if (typeof id !== 'string' || id.length < 1
159
+ || typeof content !== 'string' || content.length < 1
160
+ || !Array.isArray(sightings) || typeof covered !== 'boolean' || typeof updatedAt !== 'number') {
161
+ return undefined;
162
+ }
163
+ const parsed = [];
164
+ for (const sighting of sightings) {
165
+ if (!isRecord(sighting))
166
+ return undefined;
167
+ const sessionId = sighting['sessionId'];
168
+ const at = sighting['at'];
169
+ if (typeof sessionId !== 'string' || sessionId.length < 1 || typeof at !== 'number')
170
+ return undefined;
171
+ parsed.push({ sessionId, at });
172
+ }
173
+ const coveredAt = value['coveredAt'];
174
+ return {
175
+ id,
176
+ content,
177
+ sightings: parsed,
178
+ covered,
179
+ ...typeof coveredAt === 'number' ? { coveredAt } : {},
180
+ updatedAt,
181
+ };
124
182
  }
125
183
  //# sourceMappingURL=control.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.js","sourceRoot":"","sources":["../src/control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,MAAM,CAAC,MAAM,mCAAmC,GAAG,mBAAmB,CAAA;AACtE,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,CAAA;AAEvD,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAU,CAAA;AAEhE,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,MAAM,OAAO,4BAA4B;IASF;IARrC,0FAA0F;IAC1F,MAAM,CAAU,UAAU,GAAG;QAC3B,IAAI,EAAE,mCAAmC;QACzC,OAAO,EAAE,sCAAsC;QAC/C,MAAM,EAAE,CAAC,GAAG,WAAW,CAAC;QACxB,SAAS,EAAE,KAAK;KACjB,CAAA;IAED,YAAqC,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;IAAI,CA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AAO;QACL,EAAE;QACF,OAAO;QACP,SAAS,EAAE,MAAM;QACjB,OAAO;QACP,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE;QACrD,SAAS;KACV,CAAA;AACH,CAAC"}
package/dist/engine.d.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  * state machine is unit-testable with fakes.
17
17
  * @module @hy-sde-org/dsh-memory-extraction/engine
18
18
  */
19
- import type { AdmittedMemoryItem, MemoryExtractionCursor, MemoryExtractionEventEntry, MemoryExtractionGate, MemoryExtractionReceipt, MemoryExtractionRunResult, MemoryExtractionSourceSnapshot, PendingMemoryExtractionFailure } from './types.ts';
19
+ import type { AdmittedMemoryItem, MemoryExtractionCursor, MemoryExtractionEventEntry, MemoryExtractionGapEntry, MemoryExtractionGate, MemoryExtractionReceipt, MemoryExtractionRunResult, MemoryExtractionSourceSnapshot, PendingMemoryExtractionFailure } from './types.ts';
20
20
  export type MemoryExtractionStage = 'proposal' | 'localized' | 'canonicalize';
21
21
  export type MemoryGenerateResult = {
22
22
  readonly ok: true;
@@ -37,6 +37,12 @@ export interface MemoryExtractionPorts {
37
37
  writeReceipt(receipt: MemoryExtractionReceipt): void | Promise<void>;
38
38
  writeFailure(failure: PendingMemoryExtractionFailure): void | Promise<void>;
39
39
  deleteFailure(sessionId: string): void | Promise<void>;
40
+ /** Read every gap-ledger entry (open and covered); the engine applies floor/expiry math. */
41
+ readGaps(): readonly MemoryExtractionGapEntry[] | Promise<readonly MemoryExtractionGapEntry[]>;
42
+ /** Upsert one gap-ledger entry. */
43
+ writeGap(entry: MemoryExtractionGapEntry): void | Promise<void>;
44
+ /** Delete one gap-ledger entry (expiry purge). */
45
+ deleteGap(id: string): void | Promise<void>;
40
46
  /** Commit admitted items into the project memory store; returns what was actually stored. */
41
47
  commitItems(input: {
42
48
  readonly sessionId: string;
@@ -45,9 +51,15 @@ export interface MemoryExtractionPorts {
45
51
  readonly boundarySeq: number;
46
52
  readonly items: readonly AdmittedMemoryItem[];
47
53
  }): {
48
- readonly committed: readonly string[];
54
+ readonly results: readonly {
55
+ readonly content: string;
56
+ readonly outcome: 'committed' | 'duplicate' | 'dropped';
57
+ }[];
49
58
  } | Promise<{
50
- readonly committed: readonly string[];
59
+ readonly results: readonly {
60
+ readonly content: string;
61
+ readonly outcome: 'committed' | 'duplicate' | 'dropped';
62
+ }[];
51
63
  }>;
52
64
  /** One bounded auxiliary model call. Implementations own the timeout signal. */
53
65
  generate(input: {
@@ -57,22 +69,66 @@ export interface MemoryExtractionPorts {
57
69
  }): MemoryGenerateResult | Promise<MemoryGenerateResult>;
58
70
  now?(): number;
59
71
  }
72
+ /**
73
+ * Engine options (config-derived). The evidence floor is opt-in per value:
74
+ * `minGapEvidence` 0 disables the ledger entirely (pre-E1 behavior); 1 admits
75
+ * on the first sighting while still recording; 2+ (default) requires that many
76
+ * distinct sessions.
77
+ */
78
+ export interface MemoryExtractionEngineOptions {
79
+ /** Distinct sessions a fact needs before it commits (default 2; 0 disables the floor). */
80
+ readonly minGapEvidence?: number;
81
+ /** Gap sightings older than this expire and stop counting (default 90 days). */
82
+ readonly gapLedgerMaxAgeMs?: number;
83
+ }
60
84
  /** Max auxiliary model calls per range (Maka: 3). */
61
85
  export declare const MAX_MEMORY_EXTRACTION_MODEL_CALLS = 3;
62
86
  /** One later retry after a settled failure, then discard (Maka keeps more states). */
63
87
  export declare const MAX_FAILURE_ATTEMPTS = 2;
88
+ /** Distinct sessions a fact needs before committing (backpass `minGapEvidence` default). */
89
+ export declare const DEFAULT_MIN_GAP_EVIDENCE = 2;
90
+ /** Gap sightings older than this stop counting (backpass `gapLedgerMaxAge` default). */
91
+ export declare const DEFAULT_GAP_LEDGER_MAX_AGE_MS: number;
92
+ /** Content-hash identity: `gap_` + 24 hex chars of the normalized content's sha256. */
93
+ export declare const GAP_CONTENT_HASH_HEX = 24;
64
94
  export declare class MemoryExtractionEngine {
65
95
  private readonly ports;
66
- constructor(ports: MemoryExtractionPorts);
96
+ private readonly options;
97
+ constructor(ports: MemoryExtractionPorts, options?: MemoryExtractionEngineOptions);
67
98
  execute(snapshot: MemoryExtractionSourceSnapshot): Promise<MemoryExtractionRunResult>;
68
99
  private processRange;
69
100
  private processCoverage;
70
101
  private commitEmpty;
71
102
  private settleCountedFailure;
103
+ private minGapEvidence;
104
+ private gapMaxAge;
105
+ /**
106
+ * Load the whole gap ledger once per range: the identity index (for the
107
+ * floor gate) plus the open, uncorroborated, non-expired entries for the
108
+ * proposal prompt (most recently sighted first, capped). Disabled floor →
109
+ * empty index (no reads at all).
110
+ */
111
+ private loadGapIndex;
112
+ /**
113
+ * Apply the evidence floor to the final writes: a write commits only when
114
+ * `minGapEvidence` DISTINCT sessions (fresh sightings plus this one, counted
115
+ * once per session) have proposed the same gap identity; otherwise it is
116
+ * recorded as a new sighting and deferred. `minGapEvidence <= 0` is the
117
+ * pre-E1 path: everything commits, nothing is tracked.
118
+ */
119
+ private gateWrites;
120
+ /** Mark one gap entry covered (committed or found already in the bank). */
121
+ private coveredGapEntry;
72
122
  private callModel;
73
123
  private allowed;
74
124
  private now;
75
125
  }
76
126
  export declare function memoryExtractionOperationId(snapshot: MemoryExtractionSourceSnapshot): string;
77
127
  export declare function memoryCoverageHash(entries: readonly MemoryExtractionEventEntry[], fromSeq: number, throughSeq: number): string;
128
+ /**
129
+ * Content-hash gap identity fallback (used when the proposal cited no gapId):
130
+ * `gap_` + the first 24 hex chars of the normalized content's sha256, so two
131
+ * sessions proposing byte-identical normalized facts land on one ledger entry.
132
+ */
133
+ export declare function memoryGapIdForContent(content: string): string | undefined;
78
134
  //# sourceMappingURL=engine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAqBH,OAAO,KAAK,EACV,kBAAkB,EAElB,sBAAsB,EACtB,0BAA0B,EAE1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