@equationalapplications/core-llm-wiki 9.15.0 → 9.16.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/dist/{chunk-JCMA74YK.mjs → chunk-DD5G4VRF.mjs} +192 -14
- package/dist/chunk-DD5G4VRF.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +310 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -30
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-ziEQOLjo.d.mts → testing-C8sYdo2S.d.mts} +73 -13
- package/dist/{testing-ziEQOLjo.d.ts → testing-C8sYdo2S.d.ts} +73 -13
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +170 -10
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-JCMA74YK.mjs.map +0 -1
|
@@ -299,11 +299,14 @@ var SEVERITY = {
|
|
|
299
299
|
event_created_at_clamped: "warn",
|
|
300
300
|
event_created_at_restamped: "info",
|
|
301
301
|
external_deletion_pending: "warn",
|
|
302
|
+
supersede_scheduled_end_replaced: "info",
|
|
302
303
|
external_deletion_discarded: "warn",
|
|
303
304
|
guidance_too_long: "warn",
|
|
304
305
|
guidance_resolver_failed: "warn",
|
|
305
306
|
source_pointer_unresolved: "warn",
|
|
306
307
|
source_pointer_invalid: "warn",
|
|
308
|
+
source_event_gone: "warn",
|
|
309
|
+
derived_events_invalid: "warn",
|
|
307
310
|
source_store_source_too_large: "warn",
|
|
308
311
|
source_store_budget_exceeded: "warn",
|
|
309
312
|
source_store_hash_mismatch: "warn",
|
|
@@ -355,12 +358,15 @@ var MESSAGE = {
|
|
|
355
358
|
import_tombstone_skipped: "Import skipped live dump rows (facts and tasks) whose ids were forgotten locally. The protection holds while the tombstone is retained; once a prune hard-deletes the row, an old dump can import the fact again \u2014 see the OKF guide\u2019s restore caveat.",
|
|
356
359
|
event_created_at_clamped: "Imported events dated in the future were re-dated just after the current time, or after the librarian position if that is later, keeping their order.",
|
|
357
360
|
event_created_at_restamped: "Imported events that would have sorted behind the librarian position, or had an unusable date, were adjusted: an affected created_at was re-dated just after the current time, or after the librarian position if that is later, keeping their order; an unusable occurred_at was cleared.",
|
|
361
|
+
supersede_scheduled_end_replaced: "A supersede replaced a scheduled end date on the old fact; the prior end is kept in prior_valid_to and reopen() can restore it.",
|
|
358
362
|
external_deletion_pending: "Removals owed to the external vector index are still pending.",
|
|
359
363
|
external_deletion_discarded: "Pending external vector removals were discarded because forceDeleteIgnoreRankerHook is set.",
|
|
360
364
|
guidance_too_long: "The configured guidance exceeded the length cap and was not sent for this pass.",
|
|
361
365
|
guidance_resolver_failed: "The per-entity guidance resolver failed; its value was not used for this pass.",
|
|
362
|
-
source_pointer_unresolved: "A stored librarian fact carries no source pointer because the model answer could not yield one.",
|
|
366
|
+
source_pointer_unresolved: "A stored librarian fact carries no source pointer because the model answer could not yield one, or the librarian merged such an unattributed candidate into this fact in place (its derived_events list was not extended).",
|
|
363
367
|
source_pointer_invalid: "Import met a malformed source pointer value and stored a null pointer.",
|
|
368
|
+
source_event_gone: "A librarian candidate was dropped at apply time because the event it came from no longer exists (deleted outside the engine while the pass ran).",
|
|
369
|
+
derived_events_invalid: "Import met a malformed derived_events value and stored null.",
|
|
364
370
|
source_store_source_too_large: "A source document exceeded the per-document size cap and was not stored.",
|
|
365
371
|
source_store_budget_exceeded: "Storing a source document would exceed the store UTF-16 code-unit budget and it was not stored.",
|
|
366
372
|
source_store_hash_mismatch: "A source document text did not match its recorded hash and was not stored.",
|
|
@@ -4538,10 +4544,17 @@ var TemporalService = class {
|
|
|
4538
4544
|
if (predecessors.some((r) => r.id === newId)) throw new WikiSupersedeError("cycle");
|
|
4539
4545
|
const start = old.valid_from ?? old.created_at;
|
|
4540
4546
|
if (t <= start) throw new WikiSupersedeError("invalid_interval");
|
|
4541
|
-
|
|
4547
|
+
const replacedScheduledEnd = old.valid_to;
|
|
4548
|
+
await this.entryRepo.setTemporal(oldId, entityId, {
|
|
4549
|
+
valid_to: t,
|
|
4550
|
+
superseded_by: newId,
|
|
4551
|
+
superseded_at: now,
|
|
4552
|
+
prior_valid_to: replacedScheduledEnd
|
|
4553
|
+
}, tx);
|
|
4542
4554
|
if (repl.valid_from == null) {
|
|
4543
4555
|
await this.entryRepo.setTemporal(newId, entityId, { valid_from: t }, tx);
|
|
4544
4556
|
}
|
|
4557
|
+
return { replacedScheduledEnd };
|
|
4545
4558
|
}
|
|
4546
4559
|
async supersede(entityId, oldId, replacement, options) {
|
|
4547
4560
|
const now = Date.now();
|
|
@@ -4570,6 +4583,7 @@ var TemporalService = class {
|
|
|
4570
4583
|
}
|
|
4571
4584
|
const newId = typeof replacement === "string" ? replacement : created.id;
|
|
4572
4585
|
const newValidFrom = typeof replacement !== "string" && replacement.valid_from !== void 0 ? assertEpochMs("replacement.valid_from", replacement.valid_from) : void 0;
|
|
4586
|
+
let replacedScheduledEnd = null;
|
|
4573
4587
|
await this.db.withTransactionAsync(async (tx) => {
|
|
4574
4588
|
if (created) {
|
|
4575
4589
|
await this.entryRepo.upsert(created, tx);
|
|
@@ -4577,8 +4591,17 @@ var TemporalService = class {
|
|
|
4577
4591
|
await this.entryRepo.setTemporal(created.id, entityId, { valid_from: newValidFrom }, tx);
|
|
4578
4592
|
}
|
|
4579
4593
|
}
|
|
4580
|
-
await this.supersedeInTx(tx, entityId, oldId, newId, t, now);
|
|
4594
|
+
({ replacedScheduledEnd } = await this.supersedeInTx(tx, entityId, oldId, newId, t, now));
|
|
4581
4595
|
});
|
|
4596
|
+
if (replacedScheduledEnd != null) {
|
|
4597
|
+
emitDiagnostic(this.options, {
|
|
4598
|
+
code: "supersede_scheduled_end_replaced",
|
|
4599
|
+
operation: "supersede",
|
|
4600
|
+
trigger: "call",
|
|
4601
|
+
entityId,
|
|
4602
|
+
detail: { factId: oldId, priorValidTo: replacedScheduledEnd }
|
|
4603
|
+
});
|
|
4604
|
+
}
|
|
4582
4605
|
await this.searchService.syncEntries(entityId, [oldId, newId]);
|
|
4583
4606
|
if (created) {
|
|
4584
4607
|
await this.embeddingService.embedFact(
|
|
@@ -4610,6 +4633,35 @@ var TemporalService = class {
|
|
|
4610
4633
|
await this.searchService.syncEntries(entityId, [factId]);
|
|
4611
4634
|
this.searchService.evictCache(entityId);
|
|
4612
4635
|
}
|
|
4636
|
+
/**
|
|
4637
|
+
* Return a superseded fact to live once its replacement is forgotten or gone
|
|
4638
|
+
* (INTENT rule 12, specs/supersede-future-valid-to D4). Restores `valid_to`
|
|
4639
|
+
* to `prior_valid_to` (null when none was recorded).
|
|
4640
|
+
*/
|
|
4641
|
+
async reopen(entityId, factId) {
|
|
4642
|
+
let restored = null;
|
|
4643
|
+
await this.db.withTransactionAsync(async (tx) => {
|
|
4644
|
+
const row = await this.entryRepo.findTemporalRow(factId, tx);
|
|
4645
|
+
if (!row || row.deleted_at != null) throw new WikiSupersedeError("not_found", "reopen()");
|
|
4646
|
+
if (row.entity_id !== entityId) throw new WikiSupersedeError("cross_entity", "reopen()");
|
|
4647
|
+
if (row.superseded_by == null) throw new WikiSupersedeError("not_superseded", "reopen()");
|
|
4648
|
+
if (row.source_type === "immutable_document") throw new WikiSupersedeError("immutable_target", "reopen()");
|
|
4649
|
+
const successor = await this.entryRepo.findTemporalRow(row.superseded_by, tx);
|
|
4650
|
+
if (successor && successor.deleted_at == null) throw new WikiSupersedeError("successor_live", "reopen()");
|
|
4651
|
+
const p = row.prior_valid_to;
|
|
4652
|
+
restored = p != null && Number.isInteger(p) && p > (row.valid_from ?? row.created_at) ? p : null;
|
|
4653
|
+
const changes = await this.entryRepo.setTemporal(factId, entityId, {
|
|
4654
|
+
valid_to: restored,
|
|
4655
|
+
superseded_by: null,
|
|
4656
|
+
superseded_at: null,
|
|
4657
|
+
prior_valid_to: null
|
|
4658
|
+
}, tx);
|
|
4659
|
+
if (changes === 0) throw new WikiSupersedeError("cross_entity", "reopen()");
|
|
4660
|
+
});
|
|
4661
|
+
await this.searchService.syncEntries(entityId, [factId]);
|
|
4662
|
+
this.searchService.evictCache(entityId);
|
|
4663
|
+
return { valid_to: restored };
|
|
4664
|
+
}
|
|
4613
4665
|
async history(entityId, factId) {
|
|
4614
4666
|
const start = await this.entryRepo.findTemporalRow(factId);
|
|
4615
4667
|
if (!start || start.entity_id !== entityId || start.deleted_at != null) return [];
|
|
@@ -5417,7 +5469,9 @@ async function setupDatabase(db, prefix) {
|
|
|
5417
5469
|
valid_to INTEGER,
|
|
5418
5470
|
superseded_by TEXT,
|
|
5419
5471
|
superseded_at INTEGER,
|
|
5420
|
-
|
|
5472
|
+
prior_valid_to INTEGER,
|
|
5473
|
+
source_pointer TEXT,
|
|
5474
|
+
derived_events TEXT
|
|
5421
5475
|
);
|
|
5422
5476
|
|
|
5423
5477
|
CREATE INDEX IF NOT EXISTS ${prefix}entries_entity_idx ON ${prefix}entries(entity_id);
|
|
@@ -6201,8 +6255,34 @@ var MIGRATIONS = [
|
|
|
6201
6255
|
);`
|
|
6202
6256
|
);
|
|
6203
6257
|
}
|
|
6258
|
+
},
|
|
6259
|
+
{
|
|
6260
|
+
version: 18,
|
|
6261
|
+
description: "Partial index on entries(entity_id, deleted_at) for prune and tombstone probes; nullable prior_valid_to column recording the scheduled end a supersede overwrote; nullable derived_events column listing the events an in-place librarian merge drew on",
|
|
6262
|
+
run: async (db, prefix) => {
|
|
6263
|
+
await createEntriesDeletedIndex(db, prefix);
|
|
6264
|
+
await addPriorValidToColumn(db, prefix);
|
|
6265
|
+
await addDerivedEventsColumn(db, prefix);
|
|
6266
|
+
}
|
|
6204
6267
|
}
|
|
6205
6268
|
];
|
|
6269
|
+
async function addPriorValidToColumn(db, prefix) {
|
|
6270
|
+
const cols = await db.getAllAsync(`PRAGMA table_info(${prefix}entries)`);
|
|
6271
|
+
if (!cols.some((c) => c.name === "prior_valid_to")) {
|
|
6272
|
+
await db.execAsync(`ALTER TABLE ${prefix}entries ADD COLUMN prior_valid_to INTEGER`);
|
|
6273
|
+
}
|
|
6274
|
+
}
|
|
6275
|
+
async function createEntriesDeletedIndex(db, prefix) {
|
|
6276
|
+
await db.execAsync(
|
|
6277
|
+
`CREATE INDEX IF NOT EXISTS ${prefix}entries_deleted_idx ON ${prefix}entries(entity_id, deleted_at) WHERE deleted_at IS NOT NULL`
|
|
6278
|
+
);
|
|
6279
|
+
}
|
|
6280
|
+
async function addDerivedEventsColumn(db, prefix) {
|
|
6281
|
+
const cols = await db.getAllAsync(`PRAGMA table_info(${prefix}entries)`);
|
|
6282
|
+
if (!cols.some((c) => c.name === "derived_events")) {
|
|
6283
|
+
await db.execAsync(`ALTER TABLE ${prefix}entries ADD COLUMN derived_events TEXT`);
|
|
6284
|
+
}
|
|
6285
|
+
}
|
|
6206
6286
|
async function createLegacySourceTypeIndex(db, prefix) {
|
|
6207
6287
|
await db.execAsync(
|
|
6208
6288
|
`CREATE INDEX IF NOT EXISTS ${prefix}entries_legacy_source_type_idx ON ${prefix}entries(source_type) WHERE source_type IN ('user_document', 'agent_inferred')`
|
|
@@ -7053,6 +7133,43 @@ async function runResolve(deps, ctx, ambiguous, budget) {
|
|
|
7053
7133
|
return out;
|
|
7054
7134
|
}
|
|
7055
7135
|
|
|
7136
|
+
// src/utils/derivedEvents.ts
|
|
7137
|
+
function validateDerivedEventsValue(v) {
|
|
7138
|
+
if (v === null) return null;
|
|
7139
|
+
if (!Array.isArray(v)) return void 0;
|
|
7140
|
+
for (const x of v) {
|
|
7141
|
+
if (typeof x !== "string" || x.length === 0) return void 0;
|
|
7142
|
+
}
|
|
7143
|
+
const out = dedupeEventIds(v);
|
|
7144
|
+
return out.length === 0 ? null : out;
|
|
7145
|
+
}
|
|
7146
|
+
function parseStoredDerivedEvents(raw) {
|
|
7147
|
+
if (typeof raw !== "string") return null;
|
|
7148
|
+
let parsed;
|
|
7149
|
+
try {
|
|
7150
|
+
parsed = JSON.parse(raw);
|
|
7151
|
+
} catch {
|
|
7152
|
+
return null;
|
|
7153
|
+
}
|
|
7154
|
+
if (!Array.isArray(parsed)) return null;
|
|
7155
|
+
const kept = dedupeEventIds(parsed.filter((x) => typeof x === "string"));
|
|
7156
|
+
return kept.length === 0 ? null : kept;
|
|
7157
|
+
}
|
|
7158
|
+
function serializeDerivedEvents(list) {
|
|
7159
|
+
if (!list || list.length === 0) return null;
|
|
7160
|
+
return JSON.stringify(list);
|
|
7161
|
+
}
|
|
7162
|
+
function dedupeEventIds(ids) {
|
|
7163
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7164
|
+
const out = [];
|
|
7165
|
+
for (const id of ids) {
|
|
7166
|
+
if (typeof id !== "string" || id.length === 0 || seen.has(id)) continue;
|
|
7167
|
+
seen.add(id);
|
|
7168
|
+
out.push(id);
|
|
7169
|
+
}
|
|
7170
|
+
return out;
|
|
7171
|
+
}
|
|
7172
|
+
|
|
7056
7173
|
// src/services/librarian/ops/apply.ts
|
|
7057
7174
|
function buildSourcePointer(candidate, verdict, groundingOn, groundingCorpus) {
|
|
7058
7175
|
if (candidate.sourceEventId === null) return null;
|
|
@@ -7065,6 +7182,17 @@ function buildSourcePointer(candidate, verdict, groundingOn, groundingCorpus) {
|
|
|
7065
7182
|
}
|
|
7066
7183
|
return { event_id: candidate.sourceEventId, ref: null, quote, position: null };
|
|
7067
7184
|
}
|
|
7185
|
+
function mergeDerivedEvents(existing, contributing) {
|
|
7186
|
+
if (contributing === null || contributing === existing.source_pointer?.event_id) return void 0;
|
|
7187
|
+
const prior = existing.derived_events ?? [];
|
|
7188
|
+
if (prior.includes(contributing)) return void 0;
|
|
7189
|
+
return dedupeEventIds([...prior, contributing]);
|
|
7190
|
+
}
|
|
7191
|
+
function inheritedDerivedEvents(target, ownEventId) {
|
|
7192
|
+
if (!target) return {};
|
|
7193
|
+
const list = dedupeEventIds([target.source_pointer?.event_id, ...target.derived_events ?? []]).filter((id) => id !== ownEventId);
|
|
7194
|
+
return list.length > 0 ? { derived_events: list } : {};
|
|
7195
|
+
}
|
|
7068
7196
|
async function applyOps(deps, ctx, input) {
|
|
7069
7197
|
const { entityId, trigger } = ctx;
|
|
7070
7198
|
const diagBase = { entityId, operation: "librarian", trigger };
|
|
@@ -7095,7 +7223,7 @@ async function applyOps(deps, ctx, input) {
|
|
|
7095
7223
|
titleIndex.set(normalizeTitleKey(f.title), { id: f.id, okf_type: f.okf_type ?? null });
|
|
7096
7224
|
}
|
|
7097
7225
|
const pendingEdges = [];
|
|
7098
|
-
const insert = async (g, draft, validFrom, overrides) => {
|
|
7226
|
+
const insert = async (g, draft, validFrom, overrides, inheritFrom) => {
|
|
7099
7227
|
const fact = g.candidate.fact;
|
|
7100
7228
|
const title = overrides?.title ?? fact.title;
|
|
7101
7229
|
const body = overrides?.body ?? fact.body;
|
|
@@ -7139,6 +7267,9 @@ async function applyOps(deps, ctx, input) {
|
|
|
7139
7267
|
deleted_at: null,
|
|
7140
7268
|
okf_type: normalized.okf_type,
|
|
7141
7269
|
source_pointer: pointer,
|
|
7270
|
+
// §2: only an UPDATE converted to SUPERSEDE inherits (the merged text
|
|
7271
|
+
// rests on the target); ADD and plain SUPERSEDE carry no list.
|
|
7272
|
+
...inheritedDerivedEvents(inheritFrom, pointer?.event_id ?? null),
|
|
7142
7273
|
...g2?.trust,
|
|
7143
7274
|
...draft ? { lifecycle_status: "draft" } : {}
|
|
7144
7275
|
};
|
|
@@ -7157,7 +7288,18 @@ async function applyOps(deps, ctx, input) {
|
|
|
7157
7288
|
written.push({ id, vector: textChanged ? null : g.vector, fact: { id, entity_id: entityId, title, body, tags: fact.tags } });
|
|
7158
7289
|
return id;
|
|
7159
7290
|
};
|
|
7291
|
+
const sourceIds = [...new Set(input.gated.map((g) => g.candidate.sourceEventId).filter((x) => x !== null))];
|
|
7292
|
+
const presentIds = sourceIds.length > 0 ? await deps.eventRepo.findExistingIds(entityId, sourceIds, tx) : /* @__PURE__ */ new Set();
|
|
7293
|
+
const gatedLive = [];
|
|
7160
7294
|
for (const g of input.gated) {
|
|
7295
|
+
const ev = g.candidate.sourceEventId;
|
|
7296
|
+
if (ev !== null && !presentIds.has(ev)) {
|
|
7297
|
+
input.diagnostics.push({ ...diagBase, code: "source_event_gone", detail: { itemIndex: g.candidate.index, sourceRef: ev } });
|
|
7298
|
+
continue;
|
|
7299
|
+
}
|
|
7300
|
+
gatedLive.push(g);
|
|
7301
|
+
}
|
|
7302
|
+
for (const g of gatedLive) {
|
|
7161
7303
|
const idx = g.candidate.index;
|
|
7162
7304
|
const vf = g.candidate.validFrom;
|
|
7163
7305
|
if (g.decision.kind === "noop") continue;
|
|
@@ -7186,11 +7328,21 @@ async function applyOps(deps, ctx, input) {
|
|
|
7186
7328
|
const [existing] = await deps.entryRepo.findByIds([op.targetId], [entityId], tx);
|
|
7187
7329
|
if (existing) {
|
|
7188
7330
|
const newTitle = op.title ?? g.candidate.fact.title;
|
|
7331
|
+
const contributing = g.candidate.sourceEventId;
|
|
7332
|
+
if (contributing === null && g.candidate.pointerUnresolved !== null) {
|
|
7333
|
+
input.diagnostics.push({
|
|
7334
|
+
...diagBase,
|
|
7335
|
+
code: "source_pointer_unresolved",
|
|
7336
|
+
detail: { factId: existing.id, itemIndex: idx, reason: g.candidate.pointerUnresolved }
|
|
7337
|
+
});
|
|
7338
|
+
}
|
|
7339
|
+
const derived = mergeDerivedEvents(existing, contributing);
|
|
7189
7340
|
await deps.entryRepo.upsert({
|
|
7190
7341
|
...existing,
|
|
7191
7342
|
title: newTitle,
|
|
7192
7343
|
body: op.body ?? g.candidate.fact.body,
|
|
7193
|
-
updated_at: now
|
|
7344
|
+
updated_at: now,
|
|
7345
|
+
...derived ? { derived_events: derived } : {}
|
|
7194
7346
|
}, tx);
|
|
7195
7347
|
titleIndex.delete(normalizeTitleKey(existing.title));
|
|
7196
7348
|
titleIndex.set(normalizeTitleKey(newTitle), { id: existing.id, okf_type: existing.okf_type ?? null });
|
|
@@ -7202,15 +7354,24 @@ async function applyOps(deps, ctx, input) {
|
|
|
7202
7354
|
const supersedeFrom = op.op === "SUPERSEDE" && op.validFrom !== void 0 ? op.validFrom : vf;
|
|
7203
7355
|
const overrides = op.op === "UPDATE" ? { title: op.title, body: op.body } : void 0;
|
|
7204
7356
|
if (target.source_type === "immutable_document") {
|
|
7205
|
-
const
|
|
7357
|
+
const docTarget = op.op === "UPDATE" ? (await deps.entryRepo.findByIds([op.targetId], [entityId], tx))[0] : void 0;
|
|
7358
|
+
const id = await insert(g, true, supersedeFrom, overrides, docTarget);
|
|
7206
7359
|
input.diagnostics.push({ ...diagBase, code: "contradicts_document", detail: { factId: id, itemIndex: idx } });
|
|
7207
7360
|
continue;
|
|
7208
7361
|
}
|
|
7209
|
-
const
|
|
7362
|
+
const inheritFrom = op.op === "UPDATE" ? (await deps.entryRepo.findByIds([op.targetId], [entityId], tx))[0] : void 0;
|
|
7363
|
+
const newId = await insert(g, false, supersedeFrom, overrides, inheritFrom);
|
|
7210
7364
|
try {
|
|
7211
|
-
await temporal.supersedeInTx(tx, entityId, op.targetId, newId, supersedeFrom, now);
|
|
7365
|
+
const { replacedScheduledEnd } = await temporal.supersedeInTx(tx, entityId, op.targetId, newId, supersedeFrom, now);
|
|
7212
7366
|
supersededIds.push(op.targetId);
|
|
7213
7367
|
input.diagnostics.push({ ...diagBase, code: "librarian_superseded", detail: { factId: op.targetId, replacementId: newId } });
|
|
7368
|
+
if (replacedScheduledEnd != null) {
|
|
7369
|
+
input.diagnostics.push({
|
|
7370
|
+
...diagBase,
|
|
7371
|
+
code: "supersede_scheduled_end_replaced",
|
|
7372
|
+
detail: { factId: op.targetId, priorValidTo: replacedScheduledEnd }
|
|
7373
|
+
});
|
|
7374
|
+
}
|
|
7214
7375
|
} catch (err) {
|
|
7215
7376
|
if (!(err instanceof WikiSupersedeError)) throw err;
|
|
7216
7377
|
input.diagnostics.push({
|
|
@@ -10429,6 +10590,19 @@ var ImportExportService = class {
|
|
|
10429
10590
|
});
|
|
10430
10591
|
}
|
|
10431
10592
|
const sourcePointer = pointerValidated === void 0 ? null : pointerValidated;
|
|
10593
|
+
const rawDerived = fact["derived_events"];
|
|
10594
|
+
const hasDerivedEventsKey = rawDerived !== void 0;
|
|
10595
|
+
const derivedValidated = hasDerivedEventsKey ? validateDerivedEventsValue(rawDerived) : null;
|
|
10596
|
+
if (derivedValidated === void 0) {
|
|
10597
|
+
refusalDiagnostics.push({
|
|
10598
|
+
code: "derived_events_invalid",
|
|
10599
|
+
operation: "importDump",
|
|
10600
|
+
trigger: "call",
|
|
10601
|
+
entityId,
|
|
10602
|
+
detail: { factId: fact.id }
|
|
10603
|
+
});
|
|
10604
|
+
}
|
|
10605
|
+
const derivedEvents = derivedValidated ?? null;
|
|
10432
10606
|
const factObj = {
|
|
10433
10607
|
id: fact.id,
|
|
10434
10608
|
entity_id: entityId,
|
|
@@ -10447,6 +10621,7 @@ var ImportExportService = class {
|
|
|
10447
10621
|
embedding_blob: blobData ?? void 0,
|
|
10448
10622
|
okf_type: fact.okf_type ?? null,
|
|
10449
10623
|
source_pointer: sourcePointer,
|
|
10624
|
+
...derivedEvents ? { derived_events: derivedEvents } : {},
|
|
10450
10625
|
// OKF v0.2 — forwarded as-is; parseOkfBundle / the caller is responsible for
|
|
10451
10626
|
// populating these per spec, importDump does not derive or validate them.
|
|
10452
10627
|
lifecycle_status: fact.lifecycle_status ?? "stable",
|
|
@@ -10464,12 +10639,15 @@ var ImportExportService = class {
|
|
|
10464
10639
|
return { last_verified_at: latest?.at ?? null, last_verified_by: latest?.by ?? null };
|
|
10465
10640
|
})()
|
|
10466
10641
|
};
|
|
10467
|
-
await this.entryRepo.upsertForImport(factObj, tx, hasSourcePointerKey);
|
|
10642
|
+
await this.entryRepo.upsertForImport(factObj, tx, hasSourcePointerKey, hasDerivedEventsKey);
|
|
10468
10643
|
await this.entryRepo.setTemporal(fact.id, entityId, {
|
|
10469
10644
|
valid_from: fact.valid_from ?? null,
|
|
10470
10645
|
valid_to: fact.valid_to ?? null,
|
|
10471
10646
|
superseded_by: fact.superseded_by ?? null,
|
|
10472
|
-
superseded_at: fact.superseded_at ?? null
|
|
10647
|
+
superseded_at: fact.superseded_at ?? null,
|
|
10648
|
+
// prior_valid_to (spec D5): replace semantics like the four siblings;
|
|
10649
|
+
// null whenever the row is not superseded (the column's invariant).
|
|
10650
|
+
prior_valid_to: fact.superseded_by == null ? null : fact.prior_valid_to ?? null
|
|
10473
10651
|
}, tx, { outbox: false });
|
|
10474
10652
|
if (blobData != null) {
|
|
10475
10653
|
factsWithPreservedBlob.set(fact.id, blobData);
|
|
@@ -12215,6 +12393,6 @@ var WriteService = class {
|
|
|
12215
12393
|
}
|
|
12216
12394
|
};
|
|
12217
12395
|
|
|
12218
|
-
export { BaseRepository, CLASSIFIER_MAX_CHOICES, CURRENT_SCHEMA_VERSION, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_TYPING_MIN_CONFIDENCE, DiagnosticBuffer, EMBED_CHARS_CEILING, EdgeRepository, EmbeddingService, EraseStepError, FTS5_DRAIN_CHUNK, FTS5_REBUILD_SNAPSHOT_KEY, FTS5_REBUILD_WM_KEY, FTS5_RECLAIM_MERGE_PAGES, FTS5_RETIRED_COUNTER_KEY, FTS5_RETIRED_TABLES_KEY, FTS5_STATE_KEY, FTS5_SWEEP_CURSOR_KEY, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MAX_EMBED_ATTEMPTS, MIGRATIONS, MaintenanceService, MetadataRepository, ONTOLOGY_ABSTAIN_SENTINEL, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, SourceStoreService, TemporalService, UnavailableIndexStrategy, UsageMeter, VectorRemovalRepository, VectorRemovalService, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, assertEntityId, assertEpochMs, canEngageWriteTyping, chunkText, configureRandomSource, createLegacySourceTypeIndex, createdAtValue, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emitDiagnostic, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isReservedAbstainSlug, isRetiredTableName, isUsableDate, isWikiSearchUnavailableError, liveAtSql, nodeTypeReceipts, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, parseStoredSourcePointer, passageFtsTablesDdl, passageFtsTriggerNames, passageFtsTriggersDdl, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveContextBudget, resolveContextBudgetOrThrow, resolveDefaultChunkLength, resolveEdgeDefinitions, resolveEdgesMinConfidence, resolveGrounding, resolveHealScreenMinConfidence, resolveLibrarianStrategy, resolveMaxPromptChars, resolveNodeType, resolveNodeTypeMatch, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTypeOnWrite, resolveSystemOneTyping, resolveTypingMinConfidence, retiredTableName, runSourceRefNormalize, safeSlice, serializeSourcePointer, setupDatabase, shouldEmitOntologyReceipt, sweepChunkSql, sweepHiSql, typeSatisfies, validUsage, validateInlineEdges, validateManifest, validateSourcePointerValue, warnChangedDefaultsOnce, warnOnce, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
12219
|
-
//# sourceMappingURL=chunk-
|
|
12220
|
-
//# sourceMappingURL=chunk-
|
|
12396
|
+
export { BaseRepository, CLASSIFIER_MAX_CHOICES, CURRENT_SCHEMA_VERSION, CheckpointIncompleteError, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_TYPING_MIN_CONFIDENCE, DiagnosticBuffer, EMBED_CHARS_CEILING, EdgeRepository, EmbeddingService, EraseStepError, FTS5_DRAIN_CHUNK, FTS5_REBUILD_SNAPSHOT_KEY, FTS5_REBUILD_WM_KEY, FTS5_RECLAIM_MERGE_PAGES, FTS5_RETIRED_COUNTER_KEY, FTS5_RETIRED_TABLES_KEY, FTS5_STATE_KEY, FTS5_SWEEP_CURSOR_KEY, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MAX_EMBED_ATTEMPTS, MIGRATIONS, MaintenanceService, MetadataRepository, ONTOLOGY_ABSTAIN_SENTINEL, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, SourceStoreService, TemporalService, UnavailableIndexStrategy, UsageMeter, VectorRemovalRepository, VectorRemovalService, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiExternalDeletionError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, assertEntityId, assertEpochMs, canEngageWriteTyping, chunkText, configureRandomSource, createEntriesDeletedIndex, createLegacySourceTypeIndex, createdAtValue, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emitDiagnostic, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isReservedAbstainSlug, isRetiredTableName, isUsableDate, isWikiSearchUnavailableError, liveAtSql, nodeTypeReceipts, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, parseStoredDerivedEvents, parseStoredSourcePointer, passageFtsTablesDdl, passageFtsTriggerNames, passageFtsTriggersDdl, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveContextBudget, resolveContextBudgetOrThrow, resolveDefaultChunkLength, resolveEdgeDefinitions, resolveEdgesMinConfidence, resolveGrounding, resolveHealScreenMinConfidence, resolveLibrarianStrategy, resolveMaxPromptChars, resolveNodeType, resolveNodeTypeMatch, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTypeOnWrite, resolveSystemOneTyping, resolveTypingMinConfidence, retiredTableName, runSourceRefNormalize, safeSlice, serializeDerivedEvents, serializeSourcePointer, setupDatabase, shouldEmitOntologyReceipt, sweepChunkSql, sweepHiSql, typeSatisfies, validUsage, validateDerivedEventsValue, validateInlineEdges, validateManifest, validateSourcePointerValue, warnChangedDefaultsOnce, warnOnce, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
12397
|
+
//# sourceMappingURL=chunk-DD5G4VRF.mjs.map
|
|
12398
|
+
//# sourceMappingURL=chunk-DD5G4VRF.mjs.map
|