@equationalapplications/core-llm-wiki 9.20.2 → 9.21.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.
@@ -1,4 +1,4 @@
1
- import { OkfSource, OkfVerifiedEntry, OkfSourceUsageWindow } from '@equationalapplications/core-okf';
1
+ import { OkfSource, OkfVerifiedEntry, OkfSourceUsageWindow, OkfFrontmatterValue } from '@equationalapplications/core-okf';
2
2
 
3
3
  /**
4
4
  * System-One config surface (specs/system-one-config §1, §10).
@@ -577,6 +577,8 @@ interface WikiConfig {
577
577
  /**
578
578
  * Engine default for `ReadOptions.excludeDrafts` and
579
579
  * `GraphTraversalOptions.excludeDrafts`. Default false (drafts visible).
580
+ * A fact passes the filter when its `lifecycle_status` is `'stable'` or
581
+ * `'deprecated'` — an unknown status is excluded too (spec okf-v03 §B4).
580
582
  */
581
583
  excludeDrafts?: boolean;
582
584
  /** Evidence check for LLM-authored facts (spec §6). Default off. */
@@ -669,8 +671,13 @@ interface ReadOptions {
669
671
  */
670
672
  tierFloors?: Record<string, number>;
671
673
  /**
672
- * When true, facts whose `lifecycle_status` is `'draft'` are excluded before
673
- * `maxResults`, `tierFloors` and every other cut, on every read path.
674
+ * When true, facts whose `lifecycle_status` is `'draft'` — and facts with an
675
+ * unknown status, i.e. any value that is neither `'stable'` nor
676
+ * `'deprecated'` (spec okf-v03 §B4) — are excluded before `maxResults`,
677
+ * `tierFloors` and every other cut, on every read path. A fact passes when
678
+ * its `lifecycle_status` is `'stable'` or `'deprecated'`. Unknown statuses
679
+ * stay visible on default reads and are counted by `lint()`'s
680
+ * `unknownStatus`; the way out is `setLifecycleStatus(id, entityId, 'stable')`.
674
681
  * Resolves call → `WikiConfig.excludeDrafts` → false.
675
682
  */
676
683
  excludeDrafts?: boolean;
@@ -750,9 +757,14 @@ interface WikiFact {
750
757
  * OKF import. Distinct from `source_type`, which governs immutability rules.
751
758
  */
752
759
  okf_type?: string | null;
753
- /** OKF v0.2 lifecycle state. Defaults to 'stable' on the SQL side. */
754
- lifecycle_status?: 'draft' | 'stable' | 'deprecated';
755
- /** Absolute YYYY-MM-DD cutoff for staleness. NULL = never stale. */
760
+ /**
761
+ * Lifecycle state. Defaults to 'stable' on the SQL side. v0.3 (specs/okf-v03
762
+ * §B4): reads may return a stored raw string outside the vocabulary (an
763
+ * unknown wire `status` is kept, not coerced); the write APIs
764
+ * (`setLifecycleStatus`/`setLifecycleStatusTask`) keep the three-value union.
765
+ */
766
+ lifecycle_status?: 'draft' | 'stable' | 'deprecated' | (string & {});
767
+ /** Absolute cutoff for staleness (epoch ms). NULL = never stale. */
756
768
  stale_after?: number | null;
757
769
  /** Actor string per OKF v0.2 §7 (`<producer>/<version>`, `human:<id>`, `process:<id>`). */
758
770
  generated_by?: string | null;
@@ -762,6 +774,18 @@ interface WikiFact {
762
774
  okf_verified?: OkfVerifiedEntry[];
763
775
  /** Sibling-of-sources usage window object. */
764
776
  okf_usage_window?: OkfSourceUsageWindow | null;
777
+ /**
778
+ * Verbatim `stale_after` wire value when it did not parse to a cutoff
779
+ * (specs/okf-v03 §B3; v20 column). Unparseable is never fresh (§5.5).
780
+ * Present on mapped facts only when non-null; NULL = absent/parsed.
781
+ */
782
+ stale_after_raw?: string | null;
783
+ /**
784
+ * Every unmapped OKF frontmatter key, verbatim (specs/okf-v03 §B8; v20
785
+ * column, JSON object). Present on mapped facts only when non-null;
786
+ * NULL = nothing to preserve.
787
+ */
788
+ okf_extra?: Record<string, unknown> | null;
765
789
  /** Convenience: epoch ms of the latest verifier. Derived; mirrored for query speed. */
766
790
  last_verified_at?: number | null;
767
791
  /** Convenience: actor string of the latest verifier. Derived; mirrored for query speed. */
@@ -769,17 +793,28 @@ interface WikiFact {
769
793
  /**
770
794
  * Hydrated at read time: `isStaleAfter(stale_after, now)`. `true` once the
771
795
  * absolute stale_after cutoff has passed; `false` otherwise (including when
772
- * stale_after is null). Surfaced per spec §2.7 + §5.3 so hosts can render
773
- * staleness without recomputing. Always present on read paths that go
774
- * through `mapRowToFact` / `mapRowToTask`.
796
+ * stale_after is null). §B3 read rule (specs/okf-v03, refinement 37): a
797
+ * non-null `stale_after_raw` also reads `true` — a value the importer could
798
+ * not parse is never fresh (§5.5). Surfaced per spec §2.7 + §5.3 so hosts
799
+ * can render staleness without recomputing. Always present on read paths
800
+ * that go through `mapRowToFact` / `mapRowToTask`.
775
801
  */
776
802
  isStale?: boolean;
777
803
  /**
778
- * Hydrated at read time: `deriveTrustTier(okf_verified)`. `'human-reviewed'`
779
- * when any entry has `by: 'human:...'`, `'machine-confirmed'` when entries
780
- * exist without a human verifier, `'unverified'` when okf_verified is empty.
781
- * Surfaced per spec §2.7 + §5.3. Always present on read paths that go through
782
- * `mapRowToFact` / `mapRowToTask`.
804
+ * Hydrated at read time: `deriveTrustTier(okf_verified, generatedAt)`.
805
+ * `'human-reviewed'` when a current entry has `by: 'human:...'`,
806
+ * `'machine-confirmed'` when current entries exist without a human verifier,
807
+ * `'unverified'` when okf_verified is empty. Surfaced per spec §2.7 + §5.3.
808
+ * Always present on read paths that go through `mapRowToFact` /
809
+ * `mapRowToTask`.
810
+ *
811
+ * §5.3 currency: `generatedAt = generated_by != null ? updated_at : null`.
812
+ * A row last rewritten by an actor (`generated_by` set) counts only
813
+ * verifications whose `at` is `>= updated_at` as current; a row without one
814
+ * counts every event (v0.2 sticky rule). The unverified floor (owner
815
+ * amendment 2026-12-03): the tier derives from current events only — zero
816
+ * current events (all `at`s stale or unparseable) ⇒ `'unverified'`, never
817
+ * `'machine-confirmed'`.
783
818
  */
784
819
  trustTier?: 'unverified' | 'machine-confirmed' | 'human-reviewed';
785
820
  /** Epoch ms the fact became true in the world. Absent ⇒ since `created_at`. */
@@ -816,19 +851,25 @@ interface WikiTask {
816
851
  deleted_at: number | null;
817
852
  /** Verbatim OKF `type:` frontmatter value when this task originated from an OKF bundle. */
818
853
  okf_type?: string | null;
819
- lifecycle_status?: 'draft' | 'stable' | 'deprecated';
854
+ /** Mirrors {@link WikiFact.lifecycle_status}; write APIs keep the three-value union (specs/okf-v03 §B4). */
855
+ lifecycle_status?: 'draft' | 'stable' | 'deprecated' | (string & {});
820
856
  stale_after?: number | null;
821
857
  generated_by?: string | null;
822
858
  okf_sources?: OkfSource[];
823
859
  okf_verified?: OkfVerifiedEntry[];
824
860
  okf_usage_window?: OkfSourceUsageWindow | null;
861
+ /** Mirrors {@link WikiFact.stale_after_raw} (specs/okf-v03 §B3). */
862
+ stale_after_raw?: string | null;
863
+ /** Mirrors {@link WikiFact.okf_extra} (specs/okf-v03 §B8). */
864
+ okf_extra?: Record<string, unknown> | null;
825
865
  last_verified_at?: number | null;
826
866
  last_verified_by?: string | null;
827
867
  /**
828
- * Hydrated at read time: `isStaleAfter(stale_after, now)`. Mirrors
829
- * {@link WikiFact.isStale} (spec §2.5 + §5.3 treat stale_after symmetrically
830
- * for tasks and facts). Always present on read paths that go through
831
- * `mapRowToTask`.
868
+ * Hydrated at read time: `isStaleAfter(stale_after, now)`, plus the §B3
869
+ * read rule — non-null `stale_after_raw` ⇒ `true` (never fresh, §5.5).
870
+ * Mirrors {@link WikiFact.isStale} (spec §2.5 + §5.3 treat stale_after
871
+ * symmetrically for tasks and facts). Always present on read paths that go
872
+ * through `mapRowToTask`.
832
873
  */
833
874
  isStale?: boolean;
834
875
  /**
@@ -883,7 +924,9 @@ interface GraphTraversalOptions {
883
924
  excludeSourceTypes?: Array<WikiFact['source_type']>;
884
925
  /**
885
926
  * When true, draft facts are dead ends for *discovered* nodes (not
886
- * discovered, not traversed through). Does not gate the anchor.
927
+ * discovered, not traversed through), as are facts with an unknown status —
928
+ * a fact passes when its `lifecycle_status` is `'stable'` or `'deprecated'`
929
+ * (spec okf-v03 §B4). Does not gate the anchor.
887
930
  * Resolves call → `WikiConfig.excludeDrafts` → false.
888
931
  */
889
932
  excludeDrafts?: boolean;
@@ -1086,9 +1129,9 @@ type WikiDiagnosticSeverity = 'info' | 'warn' | 'error';
1086
1129
  * Closed for this release series, but new codes are added in minor versions:
1087
1130
  * hosts must tolerate codes they do not recognize.
1088
1131
  */
1089
- type WikiDiagnosticCode = 'ingest_chunk_failed' | 'fact_rejected' | 'task_rejected' | 'fact_deduplicated' | 'edge_dropped' | 'embedding_failed' | 'hook_failed' | 'background_job_failed' | 'heal_skipped' | 'heal_deleted' | 'heal_downgraded' | 'grounding_missing' | 'grounding_failed' | 'classification_low_confidence' | 'classification_invalid' | 'classification_abstained' | 'node_type_assigned' | 'context_overflow_skipped' | 'llm_usage' | 'librarian_gate' | 'librarian_op_rejected' | 'librarian_rewritten' | 'librarian_superseded' | 'contradicts_document' | 'ontology_backfill_held' | 'resolve_failed' | 'read_budget' | 'event_retention_held' | 'prune_checkpoint_incomplete' | 'erase_secure_delete_off' | 'erase_entity_skipped' | 'erase_retired_vtab_undroppable' | 'erase_fts_orphan_cleared' | 'erase_retired_remaining' | 'erase_tombstones_remaining' | 'erase_retired_read_failed' | 'erase_registry_sweep_skipped' | 'import_tombstone_skipped' | 'event_created_at_clamped' | 'event_created_at_restamped' | 'external_deletion_pending' | 'supersede_scheduled_end_replaced' | 'external_deletion_discarded' | 'vector_removals_backlog' | 'vector_removals_trim_failed' | 'guidance_too_long' | 'guidance_resolver_failed' | 'source_pointer_unresolved' | 'source_pointer_invalid' | 'source_event_gone' | 'derived_events_invalid' | 'source_store_source_too_large' | 'source_store_budget_exceeded' | 'source_store_hash_mismatch' | 'source_store_duplicate_hash' | 'source_store_text_not_storable' | 'node_type_dropped' | 'node_type_folded' | 'ontology_update_rejected' | 'ingest_zero_facts';
1132
+ type WikiDiagnosticCode = 'ingest_chunk_failed' | 'fact_rejected' | 'task_rejected' | 'fact_deduplicated' | 'edge_dropped' | 'embedding_failed' | 'hook_failed' | 'background_job_failed' | 'heal_skipped' | 'heal_deleted' | 'heal_downgraded' | 'grounding_missing' | 'grounding_failed' | 'classification_low_confidence' | 'classification_invalid' | 'classification_abstained' | 'node_type_assigned' | 'context_overflow_skipped' | 'llm_usage' | 'librarian_gate' | 'librarian_op_rejected' | 'librarian_rewritten' | 'librarian_superseded' | 'contradicts_document' | 'ontology_backfill_held' | 'resolve_failed' | 'read_budget' | 'event_retention_held' | 'prune_checkpoint_incomplete' | 'erase_secure_delete_off' | 'erase_entity_skipped' | 'erase_retired_vtab_undroppable' | 'erase_fts_orphan_cleared' | 'erase_retired_remaining' | 'erase_tombstones_remaining' | 'erase_retired_read_failed' | 'erase_registry_sweep_skipped' | 'import_tombstone_skipped' | 'event_created_at_clamped' | 'event_created_at_restamped' | 'external_deletion_pending' | 'supersede_scheduled_end_replaced' | 'external_deletion_discarded' | 'vector_removals_backlog' | 'vector_removals_trim_failed' | 'guidance_too_long' | 'guidance_resolver_failed' | 'source_pointer_unresolved' | 'source_pointer_invalid' | 'source_event_gone' | 'derived_events_invalid' | 'okf_extra_invalid' | 'okf_bundle_metadata_invalid' | 'source_store_source_too_large' | 'source_store_budget_exceeded' | 'source_store_hash_mismatch' | 'source_store_duplicate_hash' | 'source_store_text_not_storable' | 'node_type_dropped' | 'node_type_folded' | 'ontology_update_rejected' | 'ingest_zero_facts';
1090
1133
  /** The service run that emitted the diagnostic. */
1091
- type WikiDiagnosticOperation = 'ingest' | 'upsertGraph' | 'librarian' | 'heal' | 'ontologyBackfill' | 'reembed' | 'importDump' | 'write' | 'supersede' | 'remember' | 'read' | 'prune' | 'externalDeletion' | 'sourceStore' | 'erase';
1134
+ type WikiDiagnosticOperation = 'ingest' | 'upsertGraph' | 'librarian' | 'heal' | 'ontologyBackfill' | 'reembed' | 'importDump' | 'exportDump' | 'write' | 'supersede' | 'remember' | 'read' | 'prune' | 'externalDeletion' | 'sourceStore' | 'erase';
1092
1135
  /** `'auto'` when a write threshold started the run (auto-librarian / auto-heal); `'call'` when the host did. */
1093
1136
  type WikiDiagnosticTrigger = 'call' | 'auto';
1094
1137
  /** Identifiers only — never titles, bodies, quotes, LLM output, provider messages, or hashes of content. */
@@ -1096,6 +1139,8 @@ interface WikiDiagnosticDetail {
1096
1139
  /** The FTS5 surface the diagnostic names. */
1097
1140
  table?: string;
1098
1141
  factId?: string;
1142
+ /** The task a diagnostic concerns (`okf_extra_invalid` on a task row). */
1143
+ taskId?: string;
1099
1144
  sourceRef?: string;
1100
1145
  chunkIndex?: number;
1101
1146
  edgeType?: string;
@@ -1287,6 +1332,15 @@ interface MemoryBundle {
1287
1332
  edges?: WikiEdge[];
1288
1333
  /** Entity summary prose for OKF profile ≥ 1 round-trip. Omitted = no summary (Clanker default). */
1289
1334
  summary?: string;
1335
+ /**
1336
+ * Root-index metadata record of this entity's OKF bundle (§B7): every
1337
+ * root-index frontmatter key except the builder-owned `okf_version`/
1338
+ * `profile`, verbatim (a root key handed back unparsed rides the reserved
1339
+ * `x-llm-wiki-raw` slot). Omitted = the entity carries none. Rides the
1340
+ * dump's entity object through `exportDump`/`importDump` and persists per
1341
+ * entity in `{prefix}meta` under `okf_bundle_metadata:${entityId}`.
1342
+ */
1343
+ bundleMetadata?: Record<string, OkfFrontmatterValue>;
1290
1344
  /**
1291
1345
  * The exporting database's librarian position. Set by export only; the
1292
1346
  * importer trusts events at or before it as consolidated at the exporting
@@ -1367,6 +1421,42 @@ interface ImportDumpResult {
1367
1421
  type MemoryDumpEntity = MemoryBundle & {
1368
1422
  storedSources?: StoredSourceDump[];
1369
1423
  };
1424
+ /**
1425
+ * OKF parse report (spec okf-v03 §B13): the files `parseOkfBundle` skipped and
1426
+ * the values it dropped at parse — bundle paths, key names and reason slugs,
1427
+ * never a value. Present only when it has entries.
1428
+ */
1429
+ interface OkfParseReport {
1430
+ /**
1431
+ * Files the importer skipped: a type-less/empty-`type` `.md` under
1432
+ * `facts/`/`tasks/` in a v0.3 bundle (`no_type`, §B6) and a file outside
1433
+ * the path allow-list (`path_not_allowed`). Capped at 100 entries;
1434
+ * `skippedFilesOmitted` holds the rest as a count.
1435
+ */
1436
+ skippedFiles?: Array<{
1437
+ path: string;
1438
+ reason: string;
1439
+ }>;
1440
+ /** How many skipped files beyond the cap are not listed. */
1441
+ skippedFilesOmitted?: number;
1442
+ /**
1443
+ * Values dropped at parse, keyed by bundle path (covers the root
1444
+ * `index.md`): an unreadable mapped key or a key dropped for an anchor or
1445
+ * alias (reason from the parser's `issues`), the reserved `x-llm-wiki-raw`
1446
+ * wire key (`reserved_key`), a non-scalar `status` (`not_scalar`, §B4),
1447
+ * `sources` entries ignored for a missing `resource`
1448
+ * (`sources_entry_invalid:<n>`, §B5), a mapped key with a wrong-typed
1449
+ * value (`wrong_type`), `verified` entries without `by`/`at`
1450
+ * (`verified_entry_invalid:<n>`), a `generated` with no `by`
1451
+ * (`generated_without_by`), and `x-llm-wiki-lifecycle` on a bundle where
1452
+ * it is not restored (`not_applicable`, §B9).
1453
+ */
1454
+ droppedValues?: Array<{
1455
+ path: string;
1456
+ key: string;
1457
+ reason: string;
1458
+ }>;
1459
+ }
1370
1460
  interface MemoryDump {
1371
1461
  generatedAt: number;
1372
1462
  entities: Record<string, MemoryDumpEntity>;
@@ -1382,6 +1472,20 @@ interface MemoryDump {
1382
1472
  factId: string;
1383
1473
  reason: string;
1384
1474
  }>;
1475
+ /**
1476
+ * OKF parse report (spec okf-v03 §B13): the files and values the importer
1477
+ * skipped or dropped at parse — see {@link OkfParseReport}. Present ONLY
1478
+ * when it has entries. Export-only metadata; `importDump` ignores it.
1479
+ */
1480
+ okf_parse_report?: OkfParseReport;
1481
+ /**
1482
+ * Programmatic emission override (§B7): when set on a dump handed to
1483
+ * `formatOkfBundle`, this record is emitted on the bundle-root index in
1484
+ * place of any entity's (a multi-entity dump otherwise emits none).
1485
+ * Export never sets it; `importDump` ignores it — only the entity-level
1486
+ * field is read.
1487
+ */
1488
+ bundleMetadata?: Record<string, OkfFrontmatterValue>;
1385
1489
  }
1386
1490
  interface FormattedMemoryDump {
1387
1491
  manifest: string;
@@ -1784,6 +1888,14 @@ interface WikiLintReport {
1784
1888
  nodeTypeViolations: number;
1785
1889
  /** Live facts with `lifecycle_status = 'draft'`. */
1786
1890
  drafts: number;
1891
+ /**
1892
+ * Live facts whose `lifecycle_status` is none of `'stable'`, `'draft'`,
1893
+ * `'deprecated'` (spec okf-v03 §B4). Default reads return them with the raw
1894
+ * value, but `excludeDrafts` filters exclude them. The way out is
1895
+ * `setLifecycleStatus(id, entityId, 'stable')`; `promoteDraft` does not
1896
+ * apply (it matches `'draft'` only).
1897
+ */
1898
+ unknownStatus: number;
1787
1899
  /** Live `librarian_inferred` facts with an empty `okf_verified`. */
1788
1900
  unverifiedInferred: number;
1789
1901
  /** Up to 20 ids each, ascending. */
@@ -2106,8 +2218,27 @@ declare class EntryRepository extends BaseRepository {
2106
2218
  * `WikiGraphNodeOwnershipConflict` (no owner, node ID, or stored content
2107
2219
  * is disclosed). Upserts that pass both gates retain existing same-entity
2108
2220
  * update + resurrection semantics.
2109
- */
2110
- upsert(fact: WikiFact, tx: SQLiteAdapter): Promise<{
2221
+ *
2222
+ * §C2 content gate (specs/okf-v03): the ON CONFLICT SET computes one
2223
+ * `unchanged` predicate — null-safe `IS` over `title`, `body`, `tags`
2224
+ * (serialized) and `confidence` — and gates `updated_at` and `generated_by`
2225
+ * on it. A byte-identical re-upsert is a true no-op for exactly those two
2226
+ * columns (refinement 27), so a resync or replay can never falsely
2227
+ * de-current a human verification (§5.3); a real content change takes the
2228
+ * new instant and fills a NULL row actor from the caller (COALESCE — a
2229
+ * stored actor, foreign included, is never overwritten). Everything else
2230
+ * in the SET still runs and the outbox event still publishes.
2231
+ * Caller note (review T3-tail2 #2): `deleted_at` is NOT in the compared
2232
+ * set — a tombstone or resurrection over otherwise identical content
2233
+ * keeps the prior `updated_at`. Callers syncing by last-write-wins on
2234
+ * `updated_at` must consult `deleted_at` too (the plan's `hasChanged`
2235
+ * note says the same).
2236
+ * `upsertGraph` replays still advance `updated_at` (refinement 10: it
2237
+ * soft-deletes rows first; the DELETE-then-UPDATE outbox shape is kept).
2238
+ * §C5: pass `at` to share one instant between the write and a same-pass
2239
+ * verification event so the event reads current (`>=`, §A2).
2240
+ */
2241
+ upsert(fact: WikiFact, tx: SQLiteAdapter, at?: number): Promise<{
2111
2242
  changes: number;
2112
2243
  lastInsertRowId: number;
2113
2244
  }>;
@@ -2284,8 +2415,17 @@ declare class EntryRepository extends BaseRepository {
2284
2415
  /**
2285
2416
  * Downgrade specific entries to 'tentative' by IDs.
2286
2417
  * Used by MaintenanceService.doRunHeal().
2418
+ *
2419
+ * §C4 (specs/okf-v03, refinement 12): the same COALESCE stamp rule as
2420
+ * {@link downgradeStaleInferred}, and only rows whose confidence is not
2421
+ * already 'tentative' change — `RETURNING` scopes the staged outbox UPDATEs
2422
+ * to the rows actually written, so a repeated verdict against an
2423
+ * already-downgraded fact publishes nothing. The row write and its outbox
2424
+ * event are skipped; heal's `heal_downgraded` receipt still fires (the
2425
+ * model's verdict was applied — MaintenanceService owns the receipt).
2426
+ * Returns the ids that changed.
2287
2427
  */
2288
- downgradeByIds(ids: string[], entityId: string, tx: SQLiteAdapter): Promise<void>;
2428
+ downgradeByIds(ids: string[], entityId: string, tx: SQLiteAdapter): Promise<string[]>;
2289
2429
  /**
2290
2430
  * Soft-delete specific entries by IDs.
2291
2431
  * Used by MaintenanceService.doRunHeal().
@@ -2391,6 +2531,13 @@ declare class EntryRepository extends BaseRepository {
2391
2531
  * come from the exact row that wins MAX(updated_at). The `id ASC` tie-break
2392
2532
  * keeps selection deterministic when two live rows share `updated_at`.
2393
2533
  *
2534
+ * §C2 dependency (specs/okf-v03 refinement 27): the content gate lets an
2535
+ * `upsert` change `source_hash` on a row whose `updated_at` stays put, so
2536
+ * "most recently updated" is no longer guaranteed to mean "most recently
2537
+ * content-written". No shipped caller re-hashes a row in place through
2538
+ * `upsert` today; any future caller that does must be checked against
2539
+ * this ordering.
2540
+ *
2394
2541
  * Source refs are de-duplicated and processed in chunks so the per-query bind
2395
2542
  * parameter count stays under SQLite's `SQLITE_MAX_VARIABLE_NUMBER` (default
2396
2543
  * 999, leaving one slot for `entity_id`).
@@ -2465,8 +2612,15 @@ declare class EntryRepository extends BaseRepository {
2465
2612
  t: number;
2466
2613
  };
2467
2614
  }): Promise<WikiFact[]>;
2468
- /** IDs of live draft facts for the given entities (spec §5.1). Callers pass ≤ 100 entity ids. */
2469
- findDraftIdsByEntityIds(entityIds: readonly string[], tx?: SQLiteAdapter): Promise<Set<string>>;
2615
+ /**
2616
+ * IDs of live facts that are NOT current knowledge for the given entities
2617
+ * (spec §5.1 drafts, §B4 reads): `lifecycle_status` outside
2618
+ * `('stable','deprecated')` — drafts and unknown statuses. This is the
2619
+ * exclusion set scored search subtracts; `lint().unknownStatus` counts the
2620
+ * non-draft strays and `setLifecycleStatus(id, entityId, 'stable')` clears
2621
+ * them. Callers pass ≤ 100 entity ids.
2622
+ */
2623
+ findNotCurrentIdsByEntityIds(entityIds: readonly string[], tx?: SQLiteAdapter): Promise<Set<string>>;
2470
2624
  /** Live drafts for one entity, newest first, keyset-paged by (created_at, id). */
2471
2625
  listDraftsByEntityId(entityId: string, limit: number, after: {
2472
2626
  createdAt: number;
@@ -3940,6 +4094,22 @@ declare class IngestionService {
3940
4094
  };
3941
4095
  /** Insert-time trust by node id. Ingest-only (spec §6.5); the public upsertGraph never passes it, so host nodes are never grounded. */
3942
4096
  nodeTrust?: ReadonlyMap<string, GroundingTrust>;
4097
+ /**
4098
+ * §C1 (specs/okf-v03) internal authorship flag — NOT public API. True
4099
+ * when the ENGINE authored the node text (the ingest path); false for
4100
+ * the host `upsertGraph` path, which never stamps (§C1: stamping host
4101
+ * text would falsely assert engine authorship). A stored actor is never
4102
+ * overwritten either way: the upsert's COALESCE keeps it.
4103
+ */
4104
+ authoredByEngine?: boolean;
4105
+ /**
4106
+ * §C5 shared write instant (specs/okf-v03 refinement 32) — NOT public
4107
+ * API. The ingest path reads the clock once in `runFullUpsertGraph` and
4108
+ * passes it here so the rows' `updated_at` equals the same-pass
4109
+ * grounding events' `at` (the `>=` currency test, §A2, reads them
4110
+ * current). Absent, the method reads its own clock, as before.
4111
+ */
4112
+ at?: number;
3943
4113
  }): Promise<{
3944
4114
  nodesWritten: number;
3945
4115
  edgesWritten: number;
@@ -4009,6 +4179,14 @@ declare class TaskRepository extends BaseRepository {
4009
4179
  * See {@link EntryRepository.upsert} for the rationale — the same applies
4010
4180
  * symmetrically to tasks (spec §2.5). Callers that need to overwrite OKF
4011
4181
  * metadata should use {@link upsertForImport}.
4182
+ *
4183
+ * §C2/§C5 (specs/okf-v03): the SET gates `updated_at` and `generated_by`
4184
+ * on an `unchanged` predicate over `description`, `priority`, `status`,
4185
+ * `resolved_at` (null-safe `IS`; the `deleted_at` tombstone is outside the
4186
+ * tuple), so a byte-identical re-upsert leaves both untouched. `updatedAt`
4187
+ * is the shared write instant: a write that carries a same-pass
4188
+ * verification passes its event's `at` here so the event reads current
4189
+ * (`>=`, §A2).
4012
4190
  */
4013
4191
  upsert(task: WikiTask, tx: SQLiteAdapter, updatedAt?: number): Promise<void>;
4014
4192
  upsertForImport(task: WikiTask, tx: SQLiteAdapter, updatedAt?: number): Promise<void>;
@@ -4603,8 +4781,10 @@ declare class MaintenanceService {
4603
4781
  * model-directed move emits a `heal_deleted` / `heal_downgraded` receipt
4604
4782
  * after commit (`applied`, `applied_unscreened`, or `below_floor`), in every
4605
4783
  * mode. An `applied` receipt records that the model VERDICT was applied
4606
- * (`downgradeByIds` runs unconditionally): a fact that was already at
4607
- * reduced confidence still gets an `applied` receipt. A withheld delete paired with a restating `newFact` leaves the fact
4784
+ * (`downgradeByIds` runs for every applied id): a fact that was already at
4785
+ * reduced confidence still gets an `applied` receipt even though the row
4786
+ * write and its outbox UPDATE are skipped for an already-'tentative' fact
4787
+ * (specs/okf-v03 §C4). A withheld delete paired with a restating `newFact` leaves the fact
4608
4788
  * live and the restatement is skipped as `fact_deduplicated`.
4609
4789
  */
4610
4790
  doRunHeal(entityId: string, options?: {
@@ -5606,5 +5786,5 @@ declare class WikiMemory {
5606
5786
  setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
5607
5787
  }
5608
5788
 
5609
- export { ONTOLOGY_BACKFILL_BATCH_SIZE as $, HEAL_RECHECK_MS as A, HOOK_TIMEOUT_MARKER as B, CLASSIFIER_MAX_CHOICES as C, HEAL_BATCH_SIZE as H, ONTOLOGY_ABSTAIN_SENTINEL as _, isWikiSearchUnavailableError as a$, ONTOLOGY_BACKFILL_RECHECK_MS as a0, WikiDraftNotFound as aC, WikiDuplicateHashError as aD, WikiExternalDeletionError as aG, WikiGraphNodeOwnershipConflict as aI, WikiIngestEmptyError as aJ, WikiInvalidReadOptions as aL, WikiMigrationRequiredError as aO, WikiParseError as aQ, WikiSearchUnavailableError as aR, WikiSourceRefHashCollision as aT, WikiStrictOntologyViolation as aU, WikiSupersedeError as aV, WikiTransactionError as aY, isReservedAbstainSlug as a_, PromptService as ab, PrunePartialFailureError as ac, WikiBusyError as at, validateManifest as b0, EmbeddingService as b1, ImportExportService as b2, IngestionService as b3, JobManager as b4, MaintenanceService as b5, RetrievalService as b6, SearchService as b7, WriteService as b8, WikiMemory as e, CheckpointIncompleteError as f, EraseStepError as r };
5610
- export type { DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, HealResult as I, ImportDumpResult as J, IngestDocumentResult as K, IngestTypingCounters as L, MemoryBundle as M, LLMProvider as N, OntologyMode as O, LibrarianConfig as P, LibrarianGateConfig as Q, ReadOptions as R, SQLiteAdapter as S, ListStoredSourcesOptions as T, LockedMaintenanceJob as U, MaintenanceJob as V, WikiConfig as W, MaintenanceStopReason as X, MemoryDumpEntity as Y, MigrationPolicy as Z, MemoryDump as a, OntologyBackfillResult as a1, OntologyEdgeType as a2, OntologyManifest as a3, OntologyNodeType as a4, OntologyPromptContext as a5, OntologyUpdates as a6, PendingMaintenance as a7, PendingMigrationWork as a8, PendingSourceStatus as a9, WikiDiagnosticSeverity as aA, WikiDiagnosticTrigger as aB, WikiEdge as aE, WikiEvent as aF, WikiFact as aH, WikiInstructions as aK, WikiLintReport as aM, WikiMemoryTestAccess as aN, WikiOutboxEvent as aP, WikiSourcePointer as aS, WikiSupersedeReason as aW, WikiTask as aX, WriteOntologyPromptContext as aZ, PromptOverrides as aa, ReembedResult as ad, RememberInput as ae, RunPendingMaintenanceOptions as af, RunPendingMaintenanceResult as ag, SourcePassage as ah, StoreSourceResult as ai, StoredSource as aj, StoredSourceDump as ak, StoredSourceSummary as al, SupersedeReplacement as am, SystemOneConfig as an, SystemOneThresholdSite as ao, VectorRanker as ap, VectorRankerFallback as aq, VectorRankerRankArgs as ar, VectorRankerSemanticResult as as, WikiBusyOperation as au, WikiCheckpoint as av, WikiDiagnostic as aw, WikiDiagnosticCode as ax, WikiDiagnosticDetail as ay, WikiDiagnosticOperation as az, FormattedMemoryDump as b, OntologyConfig as c, WikiOptions as d, ChunkFailure as g, ClassifierAnswer as h, ClassifierQuestion as i, ClassifyRequest as j, ClassifyResponse as k, DraftPage as l, EmbedFailureKind as m, EmbeddingMarkerKind as n, EntityMaintenanceReport as o, EntityStatus as p, EraseReport as q, ExtractedFact as s, ExtractedFactEdge as t, ExtractedFactWithOntology as u, ExtractedTask as v, ForgetParams as w, ForgetResult as x, GraphTraversalOptions as y, GroundingConfig as z };
5789
+ export { ONTOLOGY_BACKFILL_BATCH_SIZE as $, HEAL_RECHECK_MS as A, HOOK_TIMEOUT_MARKER as B, CLASSIFIER_MAX_CHOICES as C, HEAL_BATCH_SIZE as H, ONTOLOGY_ABSTAIN_SENTINEL as _, isReservedAbstainSlug as a$, ONTOLOGY_BACKFILL_RECHECK_MS as a0, WikiDraftNotFound as aD, WikiDuplicateHashError as aE, WikiExternalDeletionError as aH, WikiGraphNodeOwnershipConflict as aJ, WikiIngestEmptyError as aK, WikiInvalidReadOptions as aM, WikiMigrationRequiredError as aP, WikiParseError as aR, WikiSearchUnavailableError as aS, WikiSourceRefHashCollision as aU, WikiStrictOntologyViolation as aV, WikiSupersedeError as aW, WikiTransactionError as aZ, PromptService as ac, PrunePartialFailureError as ad, WikiBusyError as au, isWikiSearchUnavailableError as b0, validateManifest as b1, EmbeddingService as b2, ImportExportService as b3, IngestionService as b4, JobManager as b5, MaintenanceService as b6, RetrievalService as b7, SearchService as b8, WriteService as b9, WikiMemory as e, CheckpointIncompleteError as f, EraseStepError as r };
5790
+ export type { DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, HealResult as I, ImportDumpResult as J, IngestDocumentResult as K, IngestTypingCounters as L, MemoryBundle as M, LLMProvider as N, OntologyMode as O, LibrarianConfig as P, LibrarianGateConfig as Q, ReadOptions as R, SQLiteAdapter as S, ListStoredSourcesOptions as T, LockedMaintenanceJob as U, MaintenanceJob as V, WikiConfig as W, MaintenanceStopReason as X, MemoryDumpEntity as Y, MigrationPolicy as Z, MemoryDump as a, OkfParseReport as a1, OntologyBackfillResult as a2, OntologyEdgeType as a3, OntologyManifest as a4, OntologyNodeType as a5, OntologyPromptContext as a6, OntologyUpdates as a7, PendingMaintenance as a8, PendingMigrationWork as a9, WikiDiagnosticOperation as aA, WikiDiagnosticSeverity as aB, WikiDiagnosticTrigger as aC, WikiEdge as aF, WikiEvent as aG, WikiFact as aI, WikiInstructions as aL, WikiLintReport as aN, WikiMemoryTestAccess as aO, WikiOutboxEvent as aQ, WikiSourcePointer as aT, WikiSupersedeReason as aX, WikiTask as aY, WriteOntologyPromptContext as a_, PendingSourceStatus as aa, PromptOverrides as ab, ReembedResult as ae, RememberInput as af, RunPendingMaintenanceOptions as ag, RunPendingMaintenanceResult as ah, SourcePassage as ai, StoreSourceResult as aj, StoredSource as ak, StoredSourceDump as al, StoredSourceSummary as am, SupersedeReplacement as an, SystemOneConfig as ao, SystemOneThresholdSite as ap, VectorRanker as aq, VectorRankerFallback as ar, VectorRankerRankArgs as as, VectorRankerSemanticResult as at, WikiBusyOperation as av, WikiCheckpoint as aw, WikiDiagnostic as ax, WikiDiagnosticCode as ay, WikiDiagnosticDetail as az, FormattedMemoryDump as b, OntologyConfig as c, WikiOptions as d, ChunkFailure as g, ClassifierAnswer as h, ClassifierQuestion as i, ClassifyRequest as j, ClassifyResponse as k, DraftPage as l, EmbedFailureKind as m, EmbeddingMarkerKind as n, EntityMaintenanceReport as o, EntityStatus as p, EraseReport as q, ExtractedFact as s, ExtractedFactEdge as t, ExtractedFactWithOntology as u, ExtractedTask as v, ForgetParams as w, ForgetResult as x, GraphTraversalOptions as y, GroundingConfig as z };