hippo-memory 3.3.3 → 3.5.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.md +4 -4
- package/dist/api/callers.d.ts +4 -1
- package/dist/api/context/context-plan.js +3 -0
- package/dist/api/context/context-pools.js +4 -1
- package/dist/api/context/user-rule.js +2 -1
- package/dist/api/dashboard/detail.js +2 -1
- package/dist/api/dashboard/live.d.ts +0 -4
- package/dist/api/dashboard/live.js +0 -8
- package/dist/api/memories/conflicts.d.ts +2 -1
- package/dist/api/memories/conflicts.js +3 -8
- package/dist/api/memories/promote.js +6 -2
- package/dist/api/objects/object-kinds.d.ts +1 -4
- package/dist/api/objects/object-kinds.js +1 -5
- package/dist/api/recall/compose.js +2 -1
- package/dist/api/recall/rank-stages.js +2 -1
- package/dist/api/recall/rows.js +2 -1
- package/dist/api/session-end.d.ts +3 -2
- package/dist/api/session-end.js +8 -4
- package/dist/api/sharing.d.ts +4 -3
- package/dist/api/sharing.js +2 -2
- package/dist/api/sleep/auto-sleep.d.ts +3 -2
- package/dist/api/sleep/auto-sleep.js +16 -3
- package/dist/api/sleep/one-sleep.d.ts +23 -0
- package/dist/api/sleep/one-sleep.js +53 -0
- package/dist/api/sleep/sleep-run.js +2 -1
- package/dist/api/sleep/sleep.d.ts +5 -0
- package/dist/api/sleep/sleep.js +2 -1
- package/dist/api/summary-parents.js +2 -1
- package/dist/base/config/config-keys.js +1 -0
- package/dist/base/config/config.d.ts +2 -0
- package/dist/base/config/config.js +1 -0
- package/dist/base/embeddings/local.d.ts +1 -1
- package/dist/base/embeddings/local.js +2 -3
- package/dist/base/memory/ambient.js +2 -1
- package/dist/base/memory/entry.d.ts +4 -1
- package/dist/base/memory/entry.js +7 -1
- package/dist/base/memory/half-life-plan.js +6 -4
- package/dist/base/memory/keep-rules.js +2 -1
- package/dist/base/memory/liveness.d.ts +7 -0
- package/dist/base/memory/liveness.js +6 -0
- package/dist/base/memory/markdown.js +15 -5
- package/dist/base/memory/memory-audit.js +2 -1
- package/dist/base/memory/memory-facts.d.ts +0 -2
- package/dist/base/memory/memory-facts.js +0 -2
- package/dist/base/memory/merged-row.js +3 -2
- package/dist/base/memory/rule-replaces.js +2 -1
- package/dist/base/memory/stale-mark.d.ts +9 -0
- package/dist/base/memory/stale-mark.js +18 -0
- package/dist/base/ports/store/capture.d.ts +2 -0
- package/dist/base/ports/store/conflicts.d.ts +5 -1
- package/dist/base/ports/store/conflicts.js +2 -0
- package/dist/base/ports/store/consolidation.d.ts +66 -2
- package/dist/base/ports/store/consolidation.js +5 -0
- package/dist/base/ports/store/context-reads.d.ts +2 -0
- package/dist/base/ports/store/objects.d.ts +15 -4
- package/dist/base/ports/store/sessions.d.ts +8 -2
- package/dist/base/ports/store/sessions.js +6 -0
- package/dist/base/ports/store/store-effects.d.ts +5 -0
- package/dist/base/ports/store.d.ts +1 -1
- package/dist/base/scope/live-memory.d.ts +7 -0
- package/dist/base/scope/live-memory.js +10 -0
- package/dist/base/scope/read-admission.d.ts +2 -0
- package/dist/base/scope/read-admission.js +9 -2
- package/dist/base/util/version.d.ts +1 -1
- package/dist/base/util/version.js +1 -1
- package/dist/db/continuity-tables.d.ts +4 -1
- package/dist/db/continuity-tables.js +21 -12
- package/dist/db/migrate.js +2 -2
- package/dist/db/migrations/index.d.ts +1 -1
- package/dist/db/migrations/index.js +5 -1
- package/dist/db/migrations/v61.js +3 -3
- package/dist/db/migrations/v62.d.ts +3 -0
- package/dist/db/migrations/v62.js +43 -0
- package/dist/db/migrations/v63.d.ts +3 -0
- package/dist/db/migrations/v63.js +9 -0
- package/dist/db/required-objects.js +2 -1
- package/dist/db/sql-predicates.d.ts +22 -2
- package/dist/db/sql-predicates.js +27 -2
- package/dist/domain/agent-memories/apply.js +2 -1
- package/dist/domain/agent-memories/container-view.js +2 -1
- package/dist/domain/consolidate/conflicts.js +2 -1
- package/dist/domain/consolidate/dag-summary.d.ts +2 -0
- package/dist/domain/consolidate/dag.d.ts +3 -0
- package/dist/domain/consolidate/dag.js +53 -8
- package/dist/domain/consolidate/dedupe.js +2 -1
- package/dist/domain/consolidate/events.d.ts +2 -0
- package/dist/domain/consolidate/llm-passes.js +94 -20
- package/dist/domain/consolidate/merge.js +11 -10
- package/dist/domain/consolidate/retry-holds.d.ts +14 -0
- package/dist/domain/consolidate/retry-holds.js +26 -0
- package/dist/domain/consolidate/run.d.ts +8 -0
- package/dist/domain/consolidate/run.js +2 -0
- package/dist/domain/consolidate/tombstones.d.ts +3 -4
- package/dist/domain/consolidate/tombstones.js +3 -3
- package/dist/domain/graph/recall.js +3 -2
- package/dist/domain/learn/churn-stale.js +2 -1
- package/dist/domain/learn/extract.d.ts +10 -0
- package/dist/domain/learn/extract.js +10 -5
- package/dist/domain/learn/invalidation.d.ts +1 -1
- package/dist/domain/learn/invalidation.js +4 -11
- package/dist/domain/objects/decisions.d.ts +4 -7
- package/dist/domain/objects/decisions.js +1 -14
- package/dist/domain/objects/descriptor.d.ts +2 -0
- package/dist/domain/objects/lifecycle.js +8 -2
- package/dist/domain/search/as-of.js +3 -2
- package/dist/domain/sharing/share.d.ts +16 -4
- package/dist/domain/sharing/share.js +33 -17
- package/dist/entry/store-kit.js +2 -1
- package/dist/infra/local-embedder.js +14 -2
- package/dist/infra/spool-claims.d.ts +2 -2
- package/dist/infra/spool-claims.js +4 -3
- package/dist/infra/spool-import.js +1 -1
- package/dist/infra/spool-record.d.ts +3 -1
- package/dist/store/sqlite/capture/compaction-hooks.js +14 -6
- package/dist/store/sqlite/capture/compaction-rows.js +9 -2
- package/dist/store/sqlite/capture/spool-request-id.d.ts +3 -0
- package/dist/store/sqlite/capture/spool-request-id.js +12 -0
- package/dist/store/sqlite/connectors/quarantine.js +13 -4
- package/dist/store/sqlite/consolidation/consolidation-summaries.d.ts +4 -5
- package/dist/store/sqlite/consolidation/consolidation-summaries.js +46 -26
- package/dist/store/sqlite/consolidation/consolidation.js +7 -0
- package/dist/store/sqlite/consolidation/empty-extractions.d.ts +14 -0
- package/dist/store/sqlite/consolidation/empty-extractions.js +57 -0
- package/dist/store/sqlite/consolidation/rebuild-holds.d.ts +21 -0
- package/dist/store/sqlite/consolidation/rebuild-holds.js +68 -0
- package/dist/store/sqlite/consolidation/sleep-lock.d.ts +4 -0
- package/dist/store/sqlite/consolidation/sleep-lock.js +69 -0
- package/dist/store/sqlite/entries/entry-filter.js +3 -3
- package/dist/store/sqlite/entries/entry-reads.js +2 -1
- package/dist/store/sqlite/entries/entry-row.js +5 -1
- package/dist/store/sqlite/entries/entry-writes.js +9 -15
- package/dist/store/sqlite/entries/raw-archive.d.ts +2 -1
- package/dist/store/sqlite/entries/raw-archive.js +12 -3
- package/dist/store/sqlite/maintenance/agent-import-steps.js +7 -2
- package/dist/store/sqlite/maintenance/project-tags.js +4 -3
- package/dist/store/sqlite/recall/candidates.js +12 -11
- package/dist/store/sqlite/recall/search-rows.d.ts +3 -0
- package/dist/store/sqlite/recall/search-rows.js +26 -9
- package/dist/store/sqlite/records/object-rows.d.ts +2 -0
- package/dist/store/sqlite/records/object-rows.js +5 -1
- package/dist/store/sqlite/records/object-writes.d.ts +3 -0
- package/dist/store/sqlite/records/object-writes.js +43 -1
- package/dist/store/sqlite/reports/dashboard-lists.js +3 -2
- package/dist/store/sqlite/reports/dashboard-reads.js +5 -3
- package/dist/store/sqlite/reports/dashboard-sql.d.ts +0 -3
- package/dist/store/sqlite/reports/dashboard-sql.js +2 -9
- package/dist/store/sqlite/reports/reports.js +2 -1
- package/dist/store/sqlite/review/conflicts.js +10 -5
- package/dist/store/sqlite/runtime/rule-sql.d.ts +1 -0
- package/dist/store/sqlite/runtime/rule-sql.js +4 -1
- package/dist/store/sqlite/runtime/status-transitions.d.ts +98 -0
- package/dist/store/sqlite/runtime/status-transitions.js +105 -0
- package/dist/store/sqlite/sessions/goals.js +11 -12
- package/dist/store/sqlite/sessions/sessions.d.ts +1 -1
- package/dist/store/sqlite/sessions/sessions.js +20 -8
- package/dist/surface/capture/session-worker.d.ts +3 -2
- package/dist/surface/capture/session-worker.js +36 -10
- package/dist/surface/cli/api-context.js +2 -1
- package/dist/surface/cli/client.d.ts +6 -5
- package/dist/surface/cli/client.js +50 -19
- package/dist/surface/cli/conflicts.js +12 -1
- package/dist/surface/cli/continuity.js +4 -0
- package/dist/surface/cli/decisions.js +16 -17
- package/dist/surface/cli/hooks/session-end-worker.js +3 -2
- package/dist/surface/cli/install-steps.js +99 -13
- package/dist/surface/cli/memory-writes.js +3 -2
- package/dist/surface/cli/print.js +2 -1
- package/dist/surface/cli/sleep-render.js +7 -0
- package/dist/surface/cli/sleep.d.ts +3 -2
- package/dist/surface/cli/sleep.js +10 -4
- package/dist/surface/cli/transfer.js +6 -3
- package/dist/surface/cli/verbs/objects.js +2 -2
- package/dist/surface/dashboard/dashboard-actions.js +1 -1
- package/dist/surface/hooks-install/codex-wrapper.js +52 -11
- package/dist/surface/hooks-install/rules/hook-blocks.js +9 -2
- package/dist/surface/mcp/admin-tools.js +5 -2
- package/dist/surface/render/sleep-events.js +2 -0
- package/dist/surface/server/routes/decisions.js +2 -2
- package/dist/surface/server/sleep-child.js +5 -4
- package/dist/surface/server/sleep-offload.js +36 -25
- package/dist-ui/assets/index-Cst0ubfs.js +1 -0
- package/dist-ui/index.html +1 -1
- package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
- package/extensions/openclaw-plugin/package.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist-ui/assets/index-Q9SY-1Bj.js +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// whatever store the caller holds: the CLI's, a served one, or a test's. The tenant, the fields and
|
|
4
4
|
// the list status are checked first, so a bad request fails before a store is asked.
|
|
5
5
|
import { DEFAULT_LIST_LIMIT } from '../../base/util/limits.js';
|
|
6
|
-
import { BadRequestError, ConflictError, NotFoundError } from '../../base/errors/api-errors.js';
|
|
6
|
+
import { BadRequestError, ConflictError, memoryNotFoundText, NotFoundError, } from '../../base/errors/api-errors.js';
|
|
7
7
|
import { createMemory, Layer } from '../../base/memory/entry.js';
|
|
8
8
|
import { isObjectRefusal, } from '../../base/records/object-types.js';
|
|
9
9
|
import { assertTenantId } from '../../base/scope/tenant-id.js';
|
|
@@ -73,12 +73,16 @@ function objectSave(site, kind, draft) {
|
|
|
73
73
|
fields: draft.fields,
|
|
74
74
|
supersedesId: draft.supersedesId,
|
|
75
75
|
changeSummary: draft.changeSummary,
|
|
76
|
+
weakensMemoryId: draft.weakensMemoryId,
|
|
76
77
|
actor: site.actor,
|
|
77
78
|
at: draft.at,
|
|
78
79
|
};
|
|
79
80
|
}
|
|
81
|
+
function isSaveRefusal(written) {
|
|
82
|
+
return 'refused' in written;
|
|
83
|
+
}
|
|
80
84
|
function saved(d, tenantId, replaced, written) {
|
|
81
|
-
if (!
|
|
85
|
+
if (!isSaveRefusal(written))
|
|
82
86
|
return written;
|
|
83
87
|
switch (written.refused) {
|
|
84
88
|
case 'missing':
|
|
@@ -89,6 +93,8 @@ function saved(d, tenantId, replaced, written) {
|
|
|
89
93
|
throw new ConflictError(`${d.label} ${replaced} could not be superseded (no longer active or self-reference).`);
|
|
90
94
|
case 'vanished':
|
|
91
95
|
throw new Error(`failed to reload saved ${d.label} row`);
|
|
96
|
+
case 'memory_missing':
|
|
97
|
+
throw new NotFoundError(memoryNotFoundText(written.memoryId));
|
|
92
98
|
}
|
|
93
99
|
}
|
|
94
100
|
/** Creates an object, or the version that replaces the one its options name, with its mirror
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { isSuperseded } from '../../base/memory/liveness.js';
|
|
1
2
|
/** Rows current at `asOf`, or rows not superseded unless `includeSuperseded`. */
|
|
2
3
|
export function currentEntries(entries, options) {
|
|
3
4
|
if (options.asOf)
|
|
4
5
|
return entriesAsOf(entries, new Date(options.asOf));
|
|
5
|
-
return options.includeSuperseded ? entries : entries.filter((e) => !e
|
|
6
|
+
return options.includeSuperseded ? entries : entries.filter((e) => !isSuperseded(e));
|
|
6
7
|
}
|
|
7
8
|
function entriesAsOf(entries, asOfDate) {
|
|
8
9
|
// A merged pool can repeat an id; the first row wins, as a scan from the front would pick.
|
|
@@ -13,7 +14,7 @@ function entriesAsOf(entries, asOfDate) {
|
|
|
13
14
|
return entries.filter((e) => {
|
|
14
15
|
if (new Date(e.validFrom) > asOfDate)
|
|
15
16
|
return false;
|
|
16
|
-
if (!e
|
|
17
|
+
if (!isSuperseded(e))
|
|
17
18
|
return true;
|
|
18
19
|
const successor = byId.get(e.supersededBy);
|
|
19
20
|
return successor?.validFrom ? new Date(successor.validFrom) > asOfDate : true;
|
|
@@ -18,17 +18,29 @@ export declare const AUTO_SHARE_MIN_SCORE = 0.6;
|
|
|
18
18
|
/** Estimate how well a memory would transfer to other projects.
|
|
19
19
|
* Returns 0..1 where >0.5 = good candidate for sharing. */
|
|
20
20
|
export declare function transferScore(entry: MemoryEntry): number;
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
21
|
+
/** What a hand-run share did: wrote a copy, left a row below the transfer score alone, or found
|
|
22
|
+
* the global store already holding its text (`existingId` is that row). */
|
|
23
|
+
export type ShareOutcome = {
|
|
24
|
+
readonly kind: 'shared';
|
|
25
|
+
readonly entry: MemoryEntry;
|
|
26
|
+
} | {
|
|
27
|
+
readonly kind: 'low-score';
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: 'already-shared';
|
|
30
|
+
readonly existingId: string;
|
|
31
|
+
};
|
|
32
|
+
/** Share a memory to the global store with attribution (source enriched with project path and
|
|
33
|
+
* timestamp). Writes nothing when the global store holds the text, `force` or not; throws when the
|
|
34
|
+
* row may not be shared. */
|
|
23
35
|
export declare function shareMemory(local: {
|
|
24
36
|
readonly store: StoreWith<'folderFiles'>;
|
|
25
|
-
}, global: ConfiguredFolder<SharingStore & StoreWith<'vectors' | 'vectorWrites'>>, id: string, options: {
|
|
37
|
+
}, global: ConfiguredFolder<SharingStore & StoreWith<'vectors' | 'vectorWrites' | 'captures'>>, id: string, options: {
|
|
26
38
|
force?: boolean;
|
|
27
39
|
tenantId: string;
|
|
28
40
|
skipEmbed?: boolean;
|
|
29
41
|
embed: EmbedRun;
|
|
30
42
|
detached: DetachedWork;
|
|
31
|
-
}): Promise<
|
|
43
|
+
}): Promise<ShareOutcome>;
|
|
32
44
|
/** List all projects that contributed memories to the global store, parsed from
|
|
33
45
|
* 'shared:<project>:' or 'promoted:<path>' sources; ALL_TENANTS is the host-wide view. */
|
|
34
46
|
export declare function listPeers(global: {
|
|
@@ -8,7 +8,7 @@ import { AGENT_MEMORY_SOURCE_PREFIX, AGENT_MEMORY_TAGS, } from '../../base/memor
|
|
|
8
8
|
import { isPersonalScope, isQuarantineScope } from '../../base/scope/recall-scope.js';
|
|
9
9
|
import { detectSecret } from '../../base/util/secret-detect.js';
|
|
10
10
|
import { embedMemoryDetached, embedAll, folderEmbedTarget, } from '../search/embed-memories.js';
|
|
11
|
-
import { duplicateKey,
|
|
11
|
+
import { duplicateKey, heldTextKeys } from '../../base/util/same-text.js';
|
|
12
12
|
import { chunked } from '../../base/util/chunked.js';
|
|
13
13
|
import { ALL_TENANTS } from '../../base/util/tenant.js';
|
|
14
14
|
import { isReusable } from '../../base/memory/memory-quality.js';
|
|
@@ -111,16 +111,25 @@ export function transferScore(entry) {
|
|
|
111
111
|
}
|
|
112
112
|
return Math.min(1, Math.max(0, score));
|
|
113
113
|
}
|
|
114
|
-
/** Share a memory to the global store with attribution (source enriched with project path and
|
|
115
|
-
*
|
|
114
|
+
/** Share a memory to the global store with attribution (source enriched with project path and
|
|
115
|
+
* timestamp). Writes nothing when the global store holds the text, `force` or not; throws when the
|
|
116
|
+
* row may not be shared. */
|
|
116
117
|
export async function shareMemory(local, global, id, options) {
|
|
117
118
|
// Tenant A cannot share tenant B's memory to global: the read finds no row of another tenant.
|
|
118
119
|
const [entry] = await local.store.entriesByIds([id], options.tenantId);
|
|
119
120
|
if (!entry)
|
|
120
121
|
throw new NotFoundError(`Memory not found: ${id}`);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
// Built first because it throws for a row that may not be shared, ahead of the held-text answer.
|
|
123
|
+
const globalEntry = toGlobalEntry(await local.store.folderFiles.home(), entry, options.embed.clock());
|
|
124
|
+
// The caller's tenant and the default scope filter, not autoShare's whole-store view: a copy
|
|
125
|
+
// carries its row's tenant, so another tenant's twin is no copy of this row and must stay unnamed.
|
|
126
|
+
const held = await heldGlobalTexts(global.store.captures, [entry.content], options.tenantId);
|
|
127
|
+
const twin = held.get(duplicateKey(entry.content));
|
|
128
|
+
if (twin?.id !== undefined)
|
|
129
|
+
return { kind: 'already-shared', existingId: twin.id };
|
|
130
|
+
const lowScore = transferScore(entry) < SHARE_MIN_SCORE && options.force !== true;
|
|
131
|
+
if (lowScore)
|
|
132
|
+
return { kind: 'low-score' };
|
|
124
133
|
await global.store.entryWrites.writeEntry({ entry: globalEntry, actor: CLI_ACTOR });
|
|
125
134
|
// Embed here unless the caller opts out: autoShare sets skipEmbed to batch one embedAll(), since
|
|
126
135
|
// embedMemory rewrites the whole index per call.
|
|
@@ -135,15 +144,11 @@ export async function shareMemory(local, global, id, options) {
|
|
|
135
144
|
};
|
|
136
145
|
embedMemoryDetached(target, globalEntry, options.detached);
|
|
137
146
|
}
|
|
138
|
-
return globalEntry;
|
|
147
|
+
return { kind: 'shared', entry: globalEntry };
|
|
139
148
|
}
|
|
140
|
-
/** The global copy of a local row
|
|
141
|
-
|
|
142
|
-
function toGlobalEntry(local, entry, force, now) {
|
|
149
|
+
/** The global copy of a local row; throws when the row may not be shared. */
|
|
150
|
+
function toGlobalEntry(local, entry, now) {
|
|
143
151
|
assertShareable(entry, entry.id);
|
|
144
|
-
const score = transferScore(entry);
|
|
145
|
-
if (score < SHARE_MIN_SCORE && !force)
|
|
146
|
-
return null;
|
|
147
152
|
// The label keeps the folder name for a user-global row; a NULL row gets `shared::`, which
|
|
148
153
|
// originFromSource reads as no project.
|
|
149
154
|
const fallbackName = local.folderName;
|
|
@@ -256,20 +261,31 @@ async function* autoSharePages(store, minScore, tenantId) {
|
|
|
256
261
|
after = next;
|
|
257
262
|
} while (after !== null);
|
|
258
263
|
}
|
|
264
|
+
/** Each text key `texts` have that a row in the global store holds, with the first such row;
|
|
265
|
+
* `tenantId` and `opts` pick which rows count. */
|
|
266
|
+
async function heldGlobalTexts(captures, texts, tenantId, opts) {
|
|
267
|
+
const rows = await captures.textsHolding(tenantId, texts.filter((text) => duplicateKey(text) !== ''), opts);
|
|
268
|
+
const held = new Map();
|
|
269
|
+
for (const row of rows) {
|
|
270
|
+
for (const key of heldTextKeys(row))
|
|
271
|
+
if (!held.has(key))
|
|
272
|
+
held.set(key, row);
|
|
273
|
+
}
|
|
274
|
+
return held;
|
|
275
|
+
}
|
|
259
276
|
/** The page's rows that share. The global store, the union of every tenant, is asked only for
|
|
260
277
|
* the rows that may hold a page row's text. */
|
|
261
278
|
async function pageCandidates(to, page, minScore, stats) {
|
|
262
279
|
const scored = page.filter((entry) => clearsShareRules(entry, minScore, stats));
|
|
263
280
|
if (scored.length === 0)
|
|
264
281
|
return [];
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
return scored.filter((entry) => isNewAndClean(entry, globalKeys, stats));
|
|
282
|
+
const held = await heldGlobalTexts(to, scored.map((entry) => entry.content), ALL_TENANTS, { everyScope: true });
|
|
283
|
+
return scored.filter((entry) => isNewAndClean(entry, held, stats));
|
|
268
284
|
}
|
|
269
285
|
/** Writes one page of candidates in one transaction; returns the copies written and how many a
|
|
270
286
|
* tombstone refused. */
|
|
271
287
|
async function sharePage(local, to, page, now) {
|
|
272
|
-
const copies = page.
|
|
288
|
+
const copies = page.map((entry) => toGlobalEntry(local, entry, now));
|
|
273
289
|
const written = new Set(await to.lessonWrites.writeSkippingRejected(copies, CLI_ACTOR));
|
|
274
290
|
const shared = copies.filter((copy) => written.has(copy.id));
|
|
275
291
|
return { shared, refused: copies.length - shared.length };
|
package/dist/entry/store-kit.js
CHANGED
|
@@ -35,7 +35,8 @@ export { bufferToFloat32, float32ToBuffer } from '../base/util/vector-codec.js';
|
|
|
35
35
|
export { replacesIndex } from '../base/embeddings/index-identity.js';
|
|
36
36
|
// An add-on's ContextReads applies hippo.db's scope, secret, tally and rarest-term rules with the
|
|
37
37
|
// same code. An add-on's ambientCandidates and summaryWithDescendants admit rows by hippo.db's
|
|
38
|
-
// rule.
|
|
38
|
+
// rule. A store that ignores `admit.excludeTags` or `recall.excludeTags` gets only core's after-load
|
|
39
|
+
// filter, so its recent-N or recall pool can come short.
|
|
39
40
|
export { ambientRefusal, descendantAdmits, } from '../base/scope/read-admission.js';
|
|
40
41
|
export { SECRET_TAGS } from '../base/util/secret-detect.js';
|
|
41
42
|
/** An add-on's ambient tallies, scored as hippo.db's are under the environment's eval switches. */
|
|
@@ -25,13 +25,25 @@ const INSTALLED_TRANSFORMERS = {
|
|
|
25
25
|
installed: () => resolveTransformersPackage() !== null,
|
|
26
26
|
load: () => importTransformers(),
|
|
27
27
|
};
|
|
28
|
+
// Sharing the model-load backoff is deliberate: one window, one attempt.
|
|
29
|
+
const INSTALL_RECHECK_MS = MODEL_LOAD_POLICY.backoffMs;
|
|
28
30
|
/** One pipeline per model for the embedder's life, since a pipeline is expensive to load. */
|
|
29
31
|
export function createLocalEmbedder(transformers = INSTALLED_TRANSFORMERS) {
|
|
30
|
-
let
|
|
32
|
+
let state = { kind: 'no', retryAt: 0 };
|
|
31
33
|
const gates = new Map();
|
|
32
34
|
const pipelines = createModelLoads(MODEL_LOAD_POLICY, warnLoadFailure);
|
|
33
35
|
const load = (model) => pipelines.load(model, () => createPipeline(transformers, model, gates));
|
|
34
|
-
const isAvailable = () =>
|
|
36
|
+
const isAvailable = () => {
|
|
37
|
+
if (state.kind === 'yes')
|
|
38
|
+
return true;
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
if (now < state.retryAt)
|
|
41
|
+
return false;
|
|
42
|
+
state = transformers.installed()
|
|
43
|
+
? { kind: 'yes' }
|
|
44
|
+
: { kind: 'no', retryAt: now + INSTALL_RECHECK_MS };
|
|
45
|
+
return state.kind === 'yes';
|
|
46
|
+
};
|
|
35
47
|
return {
|
|
36
48
|
isAvailable,
|
|
37
49
|
requirePipeline: (model, signal) => waitForPipeline(load(model), signal && gateOf(gates, model).opened, signal),
|
|
@@ -35,8 +35,8 @@ interface MoveBadOptions {
|
|
|
35
35
|
* busy write puts the claim back.
|
|
36
36
|
*/
|
|
37
37
|
export declare function moveBad(fsx: SpoolFs, dir: string, claim: string, options: MoveBadOptions): boolean;
|
|
38
|
-
/** Removes a claim once the store holds its summary; a claim left behind
|
|
39
|
-
* the log
|
|
38
|
+
/** Removes a claim once the store holds its summary; a claim left behind comes back for another
|
|
39
|
+
* import, so the log names it. */
|
|
40
40
|
export declare function removeClaim(fsx: SpoolFs, claim: string, name: string, log: Log): void;
|
|
41
41
|
export {};
|
|
42
42
|
//# sourceMappingURL=spool-claims.d.ts.map
|
|
@@ -54,12 +54,13 @@ export function moveBad(fsx, dir, claim, options) {
|
|
|
54
54
|
settle(() => fsx.unlinkSync(claim), log, what);
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
|
-
/** Removes a claim once the store holds its summary; a claim left behind
|
|
58
|
-
* the log
|
|
57
|
+
/** Removes a claim once the store holds its summary; a claim left behind comes back for another
|
|
58
|
+
* import, so the log names it. */
|
|
59
59
|
export function removeClaim(fsx, claim, name, log) {
|
|
60
60
|
const removed = settleCode(() => fsx.unlinkSync(claim), log, `spool file ${name} claim not removed`);
|
|
61
61
|
if (removed.settled === 'busy') {
|
|
62
|
-
log(`spool file ${name} saved; its claim could not be removed (${removed.code});
|
|
62
|
+
log(`spool file ${name} saved; its claim could not be removed (${removed.code}); ` +
|
|
63
|
+
'a later import reuses the saved record');
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
//# sourceMappingURL=spool-claims.js.map
|
|
@@ -61,7 +61,7 @@ export async function importFile(options) {
|
|
|
61
61
|
};
|
|
62
62
|
let failure;
|
|
63
63
|
try {
|
|
64
|
-
failure = await importOne(spooled, markRecorded);
|
|
64
|
+
failure = await importOne({ ...spooled, importKey: entry.stem }, markRecorded);
|
|
65
65
|
}
|
|
66
66
|
catch (err) {
|
|
67
67
|
failure = { busy: isStoreBusy(err), message: errorMessage(err), fields: errorFields(err) };
|
|
@@ -5,6 +5,8 @@ export interface SpooledCompaction {
|
|
|
5
5
|
payload: PostCompactPayload;
|
|
6
6
|
text: CompactionText;
|
|
7
7
|
at: Date;
|
|
8
|
+
/** The spool file's stem, which a put-back keeps, so the store can tell two imports of one file. */
|
|
9
|
+
importKey: string;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Records one spooled compaction; it calls `recorded` once the store holds the summary, so the file
|
|
@@ -15,5 +17,5 @@ export type SpoolImporter = (spooled: SpooledCompaction, recorded: () => void) =
|
|
|
15
17
|
/** The JSON text of one spooled compaction, which parseSpooled reads back. */
|
|
16
18
|
export declare function spoolBody(tenantId: string, payload: PostCompactPayload, text: CompactionText, at: Date): string;
|
|
17
19
|
/** null when the text is not a spooled compaction. */
|
|
18
|
-
export declare function parseSpooled(text: string, fallbackTenantId: string): SpooledCompaction | null;
|
|
20
|
+
export declare function parseSpooled(text: string, fallbackTenantId: string): Omit<SpooledCompaction, 'importKey'> | null;
|
|
19
21
|
//# sourceMappingURL=spool-record.d.ts.map
|
|
@@ -4,7 +4,8 @@ import { COMPACTION_DB_WAIT_MS, REPLAY_AFTER_MS, TRANSCRIPT_FILL_WINDOW_MS, } fr
|
|
|
4
4
|
import { errorFields, errorMessage, log as hippoLog, reportCompactionFailure, } from '../../../base/util/log.js';
|
|
5
5
|
import { isSqliteBusy } from '../../../db/index.js';
|
|
6
6
|
import { closeStartedWithoutSummary, nextCompactionStart, openTranscriptRows, stalledSummarizedRows, } from './compaction-rows.js';
|
|
7
|
-
import { compactionOrigin, markSnapshotSaved, markSummarized, recordSummary, saveItems, startCompaction, toRecord, } from './compactions-record.js';
|
|
7
|
+
import { compactionByRequest, compactionOrigin, markSnapshotSaved, markSummarized, recordSummary, saveItems, startCompaction, toRecord, } from './compactions-record.js';
|
|
8
|
+
import { spoolRequestId } from './spool-request-id.js';
|
|
8
9
|
import { answered, bound } from '../runtime/bound.js';
|
|
9
10
|
import { waitingOpener } from '../runtime/open.js';
|
|
10
11
|
import { handleNow } from '../runtime/handle-clock.js';
|
|
@@ -126,11 +127,18 @@ function saveStalled(db, files, tenantId, opts) {
|
|
|
126
127
|
return { saved, notes };
|
|
127
128
|
}
|
|
128
129
|
function recordSpooled(db, files, spooled) {
|
|
129
|
-
const {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
const { tenantId, payload, importKey } = spooled;
|
|
131
|
+
const requestId = importKey === undefined ? undefined : spoolRequestId(importKey);
|
|
132
|
+
const earlier = requestId === undefined
|
|
133
|
+
? null
|
|
134
|
+
: compactionByRequest(db, { tenantId, requestId, sessionId: payload.sessionId });
|
|
135
|
+
const { id, sessionId, originProject, cwd, items } = earlier ??
|
|
136
|
+
recordSummary(db, files, tenantId, {
|
|
137
|
+
meta: payload,
|
|
138
|
+
text: spooled.text,
|
|
139
|
+
at: spooled.at,
|
|
140
|
+
caller: { requestId },
|
|
141
|
+
});
|
|
134
142
|
return { id, sessionId, originProject, cwd, items };
|
|
135
143
|
}
|
|
136
144
|
function saveRecordItems(db, files, tenantId, record, opts) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { originInSql, scopeAdmitSql } from '../runtime/rule-sql.js';
|
|
2
2
|
import { cachedStatement } from '../../../db/statement-cache.js';
|
|
3
|
+
import { notSupersededIn } from '../../../db/sql-predicates.js';
|
|
4
|
+
import { moveOneStatus } from '../runtime/status-transitions.js';
|
|
3
5
|
const COLUMNS = 'tenant_id, id, session_id, origin_project, compact_trigger, cwd, transcript_path, snapshot_saved, started_at, ' +
|
|
4
6
|
'summarised_at, summary, items_json, items_written, status';
|
|
5
7
|
function listRows(db, where, ...params) {
|
|
@@ -55,7 +57,12 @@ export function compactionProgress(db, tenantId, id) {
|
|
|
55
57
|
return cachedStatement(db, `SELECT status, items_written FROM compactions WHERE tenant_id = ? AND id = ?`).get(tenantId, id);
|
|
56
58
|
}
|
|
57
59
|
export function markCompactionDone(db, tenantId, id, itemsWritten) {
|
|
58
|
-
|
|
60
|
+
moveOneStatus(db, 'compactionDone', {
|
|
61
|
+
tenantId,
|
|
62
|
+
id,
|
|
63
|
+
to: 'done',
|
|
64
|
+
set: { items_written: itemsWritten },
|
|
65
|
+
});
|
|
59
66
|
}
|
|
60
67
|
/** Rows changed: 1 when the `started` row was closed, 0 when it had already moved. */
|
|
61
68
|
export function closeStartedWithoutSummary(db, tenantId, id) {
|
|
@@ -70,7 +77,7 @@ export function nextCompactionStart(db, { tenantId, sessionId, after }) {
|
|
|
70
77
|
export function heldMemoryRows(db, tenantId, origins) {
|
|
71
78
|
const deny = scopeAdmitSql('');
|
|
72
79
|
return cachedStatement(db, `SELECT id, source_session_id, content FROM memories WHERE tenant_id = ? AND ${originInSql(origins)} AND ` +
|
|
73
|
-
|
|
80
|
+
`${notSupersededIn()} AND kind != 'raw'
|
|
74
81
|
AND ${deny.sql}`).all(tenantId, ...origins, ...deny.params);
|
|
75
82
|
}
|
|
76
83
|
export function restampCompactionOrigin(db, { tenantId, from, into }) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The request id a spool file's compaction record carries, so a second import of the file finds it.
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { MAX_ID_LEN } from '../../../base/util/limits.js';
|
|
4
|
+
const PREFIX = 'spool:';
|
|
5
|
+
/** `spool:` plus the key; a key too long for an id is hashed, so one key always gives one id. */
|
|
6
|
+
export function spoolRequestId(importKey) {
|
|
7
|
+
const id = `${PREFIX}${importKey}`;
|
|
8
|
+
if (id.length <= MAX_ID_LEN)
|
|
9
|
+
return id;
|
|
10
|
+
return `${PREFIX}${createHash('sha256').update(importKey).digest('hex')}`;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=spool-request-id.js.map
|
|
@@ -12,6 +12,7 @@ import { bound } from '../runtime/bound.js';
|
|
|
12
12
|
import { writeEntryMirrors } from '../entries/entry-writes.js';
|
|
13
13
|
import { cachedStatement } from '../../../db/statement-cache.js';
|
|
14
14
|
import { handleStamp } from '../runtime/handle-clock.js';
|
|
15
|
+
import { moveOneStatus } from '../runtime/status-transitions.js';
|
|
15
16
|
export { QUARANTINE_SCOPE_PREFIX };
|
|
16
17
|
const SELECT_COLUMNS = 'tenant_id, memory_id, original_scope, reason, status, quarantined_at, decided_at, decided_by';
|
|
17
18
|
function fromDbRow(row) {
|
|
@@ -63,12 +64,20 @@ export function recordQuarantine(db, opts) {
|
|
|
63
64
|
]);
|
|
64
65
|
}
|
|
65
66
|
function approveQuarantineRow(db, { tenantId, id: memoryId, actor: decidedBy }) {
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
moveOneStatus(db, 'quarantineApprove', {
|
|
68
|
+
id: memoryId,
|
|
69
|
+
to: 'approved',
|
|
70
|
+
tenantId,
|
|
71
|
+
set: { decided_at: handleStamp(db), decided_by: decidedBy },
|
|
72
|
+
});
|
|
68
73
|
}
|
|
69
74
|
function rejectQuarantineRow(db, { tenantId, id: memoryId, actor: decidedBy }) {
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
moveOneStatus(db, 'quarantineReject', {
|
|
76
|
+
id: memoryId,
|
|
77
|
+
to: 'rejected',
|
|
78
|
+
tenantId,
|
|
79
|
+
set: { decided_at: handleStamp(db), decided_by: decidedBy },
|
|
80
|
+
});
|
|
72
81
|
}
|
|
73
82
|
/** A page of the tenant's records, each with its memory's content read in the same query batch. */
|
|
74
83
|
function listQuarantined(db, tenantId, { status, limit, after }) {
|
|
@@ -8,11 +8,10 @@ export declare function listL2SummariesPage(db: DatabaseSyncLike, page: {
|
|
|
8
8
|
readonly after?: EntryCursor;
|
|
9
9
|
}): EntryPage;
|
|
10
10
|
/** The `limit` dirty summaries of every tenant changed last (latest_at DESC NULLS LAST, id ASC),
|
|
11
|
-
* each with its live children; one row past the limit tells whether more
|
|
12
|
-
*
|
|
13
|
-
export declare function dirtySummaries(db: DatabaseSyncLike, limit: number): DirtySummaries;
|
|
14
|
-
/** Lands the settle
|
|
15
|
-
* clean is one UPDATE. */
|
|
11
|
+
* each with its live children and stored failure count; one row past the limit tells whether more
|
|
12
|
+
* were waiting. With `at`, a summary held past it is skipped and counted in `held`. */
|
|
13
|
+
export declare function dirtySummaries(db: DatabaseSyncLike, limit: number, at?: string): DirtySummaries;
|
|
14
|
+
/** Lands the settle and ends the summary's rebuild hold in one write scope when the row changed. */
|
|
16
15
|
export declare function settleSummary(db: DatabaseSyncLike, settle: SummarySettle): SummarySettled;
|
|
17
16
|
/** Each row its own write, a failed one logged: an audit row never undoes the change it records. */
|
|
18
17
|
export declare function auditRows(db: DatabaseSyncLike, events: readonly AppendAuditOptions[]): number;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// hippo.db's DAG summary reads and the one write that settles a dirty summary; what a summary
|
|
2
2
|
// settles to is decided in src/domain/consolidate/dag.ts.
|
|
3
3
|
import { DAG_LEVEL } from '../../../base/memory/entry.js';
|
|
4
|
-
import { withWriteScope } from '../../../db/index.js';
|
|
4
|
+
import { withReadSnapshot, withWriteScope } from '../../../db/index.js';
|
|
5
5
|
import { assertTenantId } from '../../../base/scope/tenant-id.js';
|
|
6
6
|
import { rejectionDigest } from '../../../base/records/rejection-digest.js';
|
|
7
7
|
import { readRejectedValue } from '../review/rejection.js';
|
|
8
|
-
import { MEMORY_SELECT_COLUMNS, parseJsonArray, rowToEntry, } from '../runtime/rows.js';
|
|
8
|
+
import { MEMORY_SEARCH_COLUMNS, MEMORY_SELECT_COLUMNS, parseJsonArray, rowToEntry, } from '../runtime/rows.js';
|
|
9
|
+
import { clearRebuildHold, heldSummaryCount, holdFailuresSql, holdRetryAfterSql, REBUILD_HOLD_KEY, } from './rebuild-holds.js';
|
|
9
10
|
import { refusalAudit } from '../../rules/audit-rows.js';
|
|
10
11
|
import { syncFtsRow } from '../entries/entry-row.js';
|
|
11
12
|
import { chunked } from '../../../base/util/chunked.js';
|
|
@@ -13,6 +14,7 @@ import { keysetPage } from '../../../base/util/keyset.js';
|
|
|
13
14
|
import { recordAuditEventsRowByRow } from '../audit/audit.js';
|
|
14
15
|
import { reportAuditWriteFailure } from '../../../base/records/audit-report.js';
|
|
15
16
|
import { cachedStatement } from '../../../db/statement-cache.js';
|
|
17
|
+
import { notSupersededIn } from '../../../db/sql-predicates.js';
|
|
16
18
|
/** One keyset page of the L2 topic summaries without an L3 parent, across all tenants; a SQL
|
|
17
19
|
* filter, since sleep's survivors lack the L2s its own DAG pass just wrote. */
|
|
18
20
|
export function listL2SummariesPage(db, page) {
|
|
@@ -24,7 +26,7 @@ export function listL2SummariesPage(db, page) {
|
|
|
24
26
|
WHERE dag_level = ${DAG_LEVEL.topic}
|
|
25
27
|
AND dag_parent_id IS NULL
|
|
26
28
|
AND kind != 'archived'
|
|
27
|
-
AND
|
|
29
|
+
AND ${notSupersededIn()}
|
|
28
30
|
${range}
|
|
29
31
|
ORDER BY created ASC, id ASC
|
|
30
32
|
LIMIT ?
|
|
@@ -33,23 +35,37 @@ export function listL2SummariesPage(db, page) {
|
|
|
33
35
|
return { entries: kept.rows.map(rowToEntry), next: kept.next };
|
|
34
36
|
}
|
|
35
37
|
/** The `limit` dirty summaries of every tenant changed last (latest_at DESC NULLS LAST, id ASC),
|
|
36
|
-
* each with its live children; one row past the limit tells whether more
|
|
37
|
-
*
|
|
38
|
-
export function dirtySummaries(db, limit) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
* each with its live children and stored failure count; one row past the limit tells whether more
|
|
39
|
+
* were waiting. With `at`, a summary held past it is skipped and counted in `held`. */
|
|
40
|
+
export function dirtySummaries(db, limit, at) {
|
|
41
|
+
return withReadSnapshot(db, () => {
|
|
42
|
+
const retry = holdRetryAfterSql('h');
|
|
43
|
+
const unheld = at === undefined ? '' : `AND (${retry} IS NULL OR ${retry} <= ?)`;
|
|
44
|
+
// SAFETY: MEMORY_SEARCH_COLUMNS selects every MemoryRow key and hold_failures is named here.
|
|
45
|
+
// The literal summary_dirty = 1 lets idx_memories_summary_dirty drive the order and the limit.
|
|
46
|
+
const rows = cachedStatement(db, `
|
|
47
|
+
SELECT ${MEMORY_SEARCH_COLUMNS}, ${holdFailuresSql('h')} AS hold_failures
|
|
48
|
+
FROM memories m
|
|
49
|
+
LEFT JOIN meta h ON h.key = '${REBUILD_HOLD_KEY}' || m.id
|
|
50
|
+
WHERE m.summary_dirty = 1
|
|
51
|
+
AND m.kind != 'archived'
|
|
52
|
+
${unheld}
|
|
53
|
+
ORDER BY m.latest_at DESC NULLS LAST, m.id ASC
|
|
54
|
+
LIMIT ?
|
|
55
|
+
`).all(...(at === undefined ? [] : [at]), limit + 1);
|
|
56
|
+
const kept = rows.slice(0, limit);
|
|
57
|
+
const summaries = kept.map(rowToEntry);
|
|
58
|
+
const children = childrenOfSummaries(db, summaries);
|
|
59
|
+
return {
|
|
60
|
+
summaries: summaries.map((summary, i) => ({
|
|
61
|
+
summary,
|
|
62
|
+
children: children[i],
|
|
63
|
+
failures: kept[i].hold_failures,
|
|
64
|
+
})),
|
|
65
|
+
more: rows.length > limit,
|
|
66
|
+
held: at === undefined ? undefined : heldSummaryCount(db, at),
|
|
67
|
+
};
|
|
68
|
+
});
|
|
53
69
|
}
|
|
54
70
|
/** The live children of each summary in one IN query per tenant chunk: one list per summary in
|
|
55
71
|
* the order given, each by created then id; tenant-scoped as defence in depth. */
|
|
@@ -70,7 +86,7 @@ function childrenOfSummaries(db, summaries) {
|
|
|
70
86
|
WHERE dag_parent_id IN (SELECT value FROM json_each(?))
|
|
71
87
|
AND tenant_id = ?
|
|
72
88
|
AND kind != 'archived'
|
|
73
|
-
AND
|
|
89
|
+
AND ${notSupersededIn()}
|
|
74
90
|
ORDER BY created ASC, id ASC
|
|
75
91
|
`).all(JSON.stringify(slice), tenantId);
|
|
76
92
|
for (const entry of rows.map(rowToEntry)) {
|
|
@@ -112,13 +128,17 @@ const SETTLE_FIELDS_SQL = `UPDATE memories
|
|
|
112
128
|
summary_dirty = 0
|
|
113
129
|
${STILL_DIRTY}`;
|
|
114
130
|
const SETTLE_CLEAN_SQL = `UPDATE memories SET summary_dirty = 0 ${STILL_DIRTY}`;
|
|
115
|
-
/** Lands the settle
|
|
116
|
-
* clean is one UPDATE. */
|
|
131
|
+
/** Lands the settle and ends the summary's rebuild hold in one write scope when the row changed. */
|
|
117
132
|
export function settleSummary(db, settle) {
|
|
118
133
|
assertTenantId('settleSummary', settle.tenantId);
|
|
119
|
-
return
|
|
120
|
-
|
|
121
|
-
|
|
134
|
+
return withWriteScope(db, 'rebuild_summary', () => {
|
|
135
|
+
const settled = settle.fields
|
|
136
|
+
? settleFields(db, settle, settle.fields)
|
|
137
|
+
: settleClean(db, settle);
|
|
138
|
+
if (settled.changed)
|
|
139
|
+
clearRebuildHold(db, settle.id);
|
|
140
|
+
return settled;
|
|
141
|
+
});
|
|
122
142
|
}
|
|
123
143
|
function settleClean(db, settle) {
|
|
124
144
|
const row = cachedStatement(db, SETTLE_CLEAN_SQL).get(settle.id, settle.tenantId);
|
|
@@ -22,6 +22,9 @@ import { bound } from '../runtime/bound.js';
|
|
|
22
22
|
import { rethrowInPortTerms } from '../runtime/port-errors.js';
|
|
23
23
|
import { auditRows, dirtySummaries, listL2SummariesPage, settleSummary, } from './consolidation-summaries.js';
|
|
24
24
|
import { META_KEY } from '../../../db/meta.js';
|
|
25
|
+
import { noteRebuildFailures } from './rebuild-holds.js';
|
|
26
|
+
import { emptyExtractions, noteEmptyExtractions } from './empty-extractions.js';
|
|
27
|
+
import { sleepClaim } from './sleep-lock.js';
|
|
25
28
|
// A half-life move reads, writes, audits and records its base on one handle, so it commits whole or
|
|
26
29
|
// not at all.
|
|
27
30
|
function listHalfLifeRows(db, from, typedPending) {
|
|
@@ -124,6 +127,9 @@ const bareBodies = {
|
|
|
124
127
|
particlesByRecall: storedParticlesByRecall,
|
|
125
128
|
saveParticles: saveStoredParticles,
|
|
126
129
|
auditEachRow: auditRows,
|
|
130
|
+
noteRebuildFailures,
|
|
131
|
+
emptyExtractions,
|
|
132
|
+
noteEmptyExtractions,
|
|
127
133
|
dirtyGraphTenants: listPendingExtractionTenants,
|
|
128
134
|
markGraphDrained: markPendingProcessedUpTo,
|
|
129
135
|
};
|
|
@@ -135,6 +141,7 @@ export function sqliteConsolidation(handles) {
|
|
|
135
141
|
...bound(on, recordSleepBody(files), openStore),
|
|
136
142
|
...bound(on, bareBodies),
|
|
137
143
|
commit: chunkedCommit(handles),
|
|
144
|
+
...sleepClaim(files.hippoRoot),
|
|
138
145
|
};
|
|
139
146
|
}
|
|
140
147
|
//# sourceMappingURL=consolidation.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type DatabaseSyncLike } from '../../../db/index.js';
|
|
2
|
+
import type { Consolidation } from '../../../base/ports/store/consolidation.js';
|
|
3
|
+
type Page = Awaited<ReturnType<NonNullable<Consolidation['emptyExtractions']>>>;
|
|
4
|
+
type Note = Parameters<NonNullable<Consolidation['noteEmptyExtractions']>>[0];
|
|
5
|
+
/** One page of marks by source id, after the id `after`; a row that is not a mark is skipped. */
|
|
6
|
+
export declare function emptyExtractions(db: DatabaseSyncLike, page: {
|
|
7
|
+
readonly limit: number;
|
|
8
|
+
readonly after?: string;
|
|
9
|
+
}): Page;
|
|
10
|
+
/** Stores the marks and drops the cleared ones in one write, then drops the marks of sources that
|
|
11
|
+
* are no longer live. */
|
|
12
|
+
export declare function noteEmptyExtractions(db: DatabaseSyncLike, { mark, clear }: Note): void;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=empty-extractions.d.ts.map
|