@fortemi/core 2026.9.4 → 2026.9.6

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.
Files changed (24) hide show
  1. package/dist/index.d.ts +1617 -1486
  2. package/dist/index.js +2310 -438
  3. package/dist/index.js.map +1 -1
  4. package/package.json +5 -3
  5. package/schemas/dataset-execution-capabilities/validation/1.0.1/manifest.json +29 -0
  6. package/schemas/dataset-execution-capabilities/validation/1.0.1/negotiation-vectors.json +127 -0
  7. package/schemas/dataset-execution-capabilities/validation/1.0.1/schema.json +469 -0
  8. package/schemas/dataset-execution-capabilities/validation/1.0.1/wire-vectors.json +681 -0
  9. package/schemas/metadata-search/candidate/1.0.0/README.md +36 -0
  10. package/schemas/metadata-search/candidate/1.0.0/contract.receipt.json +38 -0
  11. package/schemas/metadata-search/candidate/1.0.0/evidence-locator.schema.json +50 -0
  12. package/schemas/metadata-search/candidate/1.0.0/evidence-resolution-vectors.json +355 -0
  13. package/schemas/metadata-search/candidate/1.0.0/evidence-resolution.schema.json +25 -0
  14. package/schemas/metadata-search/candidate/1.0.0/evidence-set-vectors.json +6095 -0
  15. package/schemas/metadata-search/candidate/1.0.0/evidence-set.schema.json +21 -0
  16. package/schemas/metadata-search/candidate/1.0.0/evidence-vectors.json +1603 -0
  17. package/schemas/metadata-search/candidate/1.0.0/predicate-vectors.json +919 -0
  18. package/schemas/metadata-search/candidate/1.0.0/predicates.schema.json +287 -0
  19. package/schemas/metadata-search/candidate/1.0.0/resolution.receipt.json +44 -0
  20. package/schemas/metadata-search/candidate/1.0.0/rest.receipt.json +51 -0
  21. package/schemas/metadata-search/candidate/1.0.0/search-rest-vectors.json +28 -0
  22. package/schemas/metadata-search/candidate/1.0.0/search-rest.schema.json +318 -0
  23. package/schemas/metadata-search/candidate/1.0.0/source.receipt.json +46 -0
  24. package/schemas/metadata-search/candidate/1.0.0/sql-scope-vectors.json +894 -0
package/dist/index.d.ts CHANGED
@@ -546,7 +546,17 @@ interface DatasetCapabilityNegotiationResult {
546
546
  degradations: DatasetCapabilityDegradation[];
547
547
  diagnostics: DatasetCapabilityDiagnostic[];
548
548
  }
549
- declare function validateDatasetExecutionDescriptor(descriptor: DatasetExecutionCapabilityDescriptor): DatasetCapabilityDiagnostic[];
549
+ type DatasetCapabilityWireResult = {
550
+ diagnostics: DatasetCapabilityDiagnostic[];
551
+ valid: false;
552
+ } | {
553
+ result: DatasetCapabilityNegotiationResult;
554
+ valid: true;
555
+ };
556
+ declare function validateDatasetExecutionDescriptor(descriptor: unknown): DatasetCapabilityDiagnostic[];
557
+ declare function validateDatasetExecutionRequest(request: unknown): DatasetCapabilityDiagnostic[];
558
+ /** Validate untrusted JSON before exposing a typed negotiation result. */
559
+ declare function negotiateDatasetExecutionCapabilitiesFromWire(descriptor: unknown, request: unknown): DatasetCapabilityWireResult;
550
560
  /** Pure negotiation: performs no I/O and cannot mutate the descriptor or request. */
551
561
  declare function negotiateDatasetExecutionCapabilities(descriptor: DatasetExecutionCapabilityDescriptor, request: DatasetCapabilityNegotiationRequest): DatasetCapabilityNegotiationResult;
552
562
  /** Descriptor for the journaled browser-local RecordStore/PGlite projection. */
@@ -1167,6 +1177,58 @@ declare class RemoteBackendError extends Error {
1167
1177
  readonly name = "RemoteBackendError";
1168
1178
  constructor(kind: RemoteBackendErrorKind, status?: number | undefined, problemCode?: string | undefined, requestId?: string | undefined, retryAfterSeconds?: number | undefined);
1169
1179
  }
1180
+ interface EvidenceTextUnit {
1181
+ readonly kind: 'attachment' | 'current' | 'embedding' | 'title';
1182
+ readonly id: string;
1183
+ readonly index: number;
1184
+ }
1185
+ interface EvidenceSourceIdentity {
1186
+ readonly namespace: string;
1187
+ readonly external_id_hash: string;
1188
+ readonly import_run_id: string;
1189
+ readonly schema_version: string;
1190
+ }
1191
+ interface SearchEvidenceLocator {
1192
+ readonly version: '1.0.0';
1193
+ readonly note_id: string;
1194
+ readonly unit: EvidenceTextUnit;
1195
+ readonly content_digest: string;
1196
+ readonly span: {
1197
+ readonly end: number;
1198
+ readonly start: number;
1199
+ readonly unit: 'utf8-bytes';
1200
+ };
1201
+ readonly source?: EvidenceSourceIdentity;
1202
+ }
1203
+ /** The caller supplies already-authorized text, not an access grant from this type. */
1204
+ interface EvidenceTextSnapshot {
1205
+ readonly note_id: string;
1206
+ readonly unit: EvidenceTextUnit;
1207
+ readonly content: string;
1208
+ readonly source?: EvidenceSourceIdentity;
1209
+ }
1210
+ /** Parse an untrusted wire value, taking an immutable validated copy. */
1211
+ declare function parseSearchEvidenceLocator(value: unknown): SearchEvidenceLocator;
1212
+ /** Bind exact raw text. No Unicode normalization, trimming or HTML processing. */
1213
+ declare function bindSearchEvidence(text: EvidenceTextSnapshot, start: number, end: number): SearchEvidenceLocator;
1214
+ /** Pure binding check over already-authorized text; never performs database I/O. */
1215
+ declare function resolveSearchEvidence(value: unknown, text: EvidenceTextSnapshot | null): string;
1216
+ declare const EVIDENCE_OMISSIONS: readonly [
1217
+ "unavailable-unit",
1218
+ "locator-limit"
1219
+ ];
1220
+ type SearchEvidenceOmission = typeof EVIDENCE_OMISSIONS[number];
1221
+ interface SearchEvidenceSet {
1222
+ readonly version: '1.0.0';
1223
+ readonly locators: readonly SearchEvidenceLocator[];
1224
+ readonly omissions: readonly SearchEvidenceOmission[];
1225
+ }
1226
+ /** Validate canonical ordering and the enclosing hit's native note identity. */
1227
+ declare function parseSearchEvidenceSet(value: unknown, noteId: string): SearchEvidenceSet;
1228
+ /** Bound and deduplicate already-projected locators; never fetch or invent text. */
1229
+ declare function createSearchEvidenceSet(noteId: string, values: readonly unknown[], omissions?: readonly SearchEvidenceOmission[]): SearchEvidenceSet;
1230
+ /** Merge one hit's retrieval legs, retaining partial/unavailable provenance. */
1231
+ declare function mergeSearchEvidenceSets(noteId: string, sets: readonly SearchEvidenceSet[]): SearchEvidenceSet;
1170
1232
  /**
1171
1233
  * Type-safe client for the PGlite Worker.
1172
1234
  *
@@ -1634,1565 +1696,1628 @@ interface ShardReader {
1634
1696
  * reader than this build throws (the host should fall back to `importShard`).
1635
1697
  */
1636
1698
  declare function openShard(source: ShardReaderSource, options?: OpenShardOptions): Promise<ShardReader>;
1637
- /**
1638
- * Backend seam (#191) — a uniform tool-intent operation interface that lets the
1639
- * PGlite database backend (#187) and the static-file shard backend (#189) be
1640
- * selected and dispatched against the same way, plus a capability-negotiation
1641
- * API so a caller asks for the operations it needs and gets the lightest backend
1642
- * that provides them.
1643
- *
1644
- * The seam sits one level above SQL: every adapter exposes the same read
1645
- * operations (and optional relationship, write, semantic, and full-content ops)
1646
- * regardless of whether the data lives in a queryable PGlite instance, a set of
1647
- * static shard files fetched over HTTP, or the Fortemi server tier.
1648
- */
1649
- /**
1650
- * Semantic-search tier a backend offers, in increasing capability:
1651
- * - `none` — no vector search (text / facets only)
1652
- * - `cosine-small` — brute-force cosine over a small static vector set (#189)
1653
- * - `ann-full` — prebuilt/queryable approximate-nearest-neighbour over the full
1654
- * corpus (PGlite + pgvector, or a prebuilt ANN snapshot)
1655
- * - `server` — delegated to the remote Fortemi server backend
1656
- */
1657
- type BackendSemanticTier = 'ann-full' | 'cosine-small' | 'none' | 'server';
1658
- /** Relative startup cost of bringing a backend online. */
1659
- type BackendStartupCost = 'index-build' | 'instant' | 'network';
1660
- /** What a backend can do — the unit of capability negotiation. */
1661
- interface BackendCapabilities {
1662
- /** Can answer list / get / search read operations. */
1663
- read: boolean;
1664
- /** Can mutate notes (manageNote). */
1665
- write: boolean;
1666
- /** Can merge external shards into its store. */
1667
- merge: boolean;
1668
- /** Coordinates concurrent multi-user writes. */
1669
- multiUser: boolean;
1670
- /** Highest semantic-search tier available. */
1671
- semantic: BackendSemanticTier;
1672
- /** Relative cost to bring the backend online. */
1673
- startupCost: BackendStartupCost;
1699
+ type JsonObject = Record<string, unknown>;
1700
+ interface NativeEmbeddingConfig {
1701
+ id: string;
1702
+ name: string;
1703
+ description: null | string;
1704
+ model: string;
1705
+ dimension: number;
1706
+ chunk_size: number;
1707
+ chunk_overlap: number;
1708
+ hnsw_m: null | number;
1709
+ hnsw_ef_construction: null | number;
1710
+ ivfflat_lists: null | number;
1711
+ is_default: boolean | null;
1712
+ supports_mrl: boolean | null;
1713
+ matryoshka_dims: null | number[];
1714
+ default_truncate_dim: null | number;
1715
+ provider: null | string;
1716
+ provider_config: JsonObject | null;
1717
+ content_types: null | string[];
1718
+ strengths: null | string[];
1719
+ limitations: null | string[];
1720
+ recommended_for: null | string[];
1721
+ benchmark_scores: JsonObject | null;
1722
+ is_available: boolean | null;
1723
+ document_composition: JsonObject;
1724
+ created_at: string;
1725
+ updated_at: string;
1674
1726
  }
1675
- /**
1676
- * Backend-neutral note record. `source`/`starred`/`archived` are optional
1677
- * because lean read paths (PGlite full-text search) do not return them; list,
1678
- * get, and every shard path populate all fields.
1679
- */
1680
- interface BackendNote {
1727
+ interface NativeEmbeddingSet {
1681
1728
  id: string;
1682
- title: null | string;
1683
- tags: string[];
1684
- createdAt: string;
1685
- updatedAt: string;
1686
- source?: string;
1687
- starred?: boolean;
1688
- archived?: boolean;
1729
+ name: string;
1730
+ slug: null | string;
1731
+ description: null | string;
1732
+ purpose: null | string;
1733
+ usage_hints: null | string;
1734
+ keywords: null | string[];
1735
+ set_type: 'filter' | 'full';
1736
+ mode: 'auto' | 'manual' | 'mixed' | null;
1737
+ criteria: JsonObject | null;
1738
+ embedding_config_id: null | string;
1739
+ truncate_dim: null | number;
1740
+ auto_embed_rules: JsonObject | null;
1741
+ index_status: string;
1742
+ index_type: null | string;
1743
+ last_indexed_at: null | string;
1744
+ document_count: null | number;
1745
+ embedding_count: null | number;
1746
+ embeddings_current: boolean | null;
1747
+ index_size_bytes: null | number;
1748
+ is_system: boolean | null;
1749
+ is_active: boolean | null;
1750
+ auto_refresh: boolean | null;
1751
+ refresh_interval: null | string;
1752
+ last_refresh_at: null | string;
1753
+ agent_metadata: JsonObject | null;
1754
+ created_at: string;
1755
+ updated_at: string;
1756
+ created_by: null | string;
1689
1757
  }
1690
- /** A note plus its current rendered content. */
1691
- interface BackendNoteFull extends BackendNote {
1692
- content: string;
1693
- /** Native note metadata, separate from inference metadata where supported. */
1694
- metadata?: unknown;
1695
- links?: BackendLink[];
1696
- concepts?: BackendConcept[];
1697
- provenance?: BackendProvenanceEdge[];
1698
- /** Server revision/activity graph; not interchangeable with local provenance edges. */
1699
- provenanceGraph?: RemoteProvenanceGraph;
1758
+ interface NativeEmbeddingMember {
1759
+ embedding_set_id: string;
1760
+ note_id: string;
1761
+ membership_type: null | string;
1762
+ added_at: null | string;
1763
+ added_by: null | string;
1700
1764
  }
1701
- interface BackendLink {
1702
- id: string;
1703
- fromNoteId: string;
1704
- toNoteId: null | string;
1705
- toUrl?: null | string;
1706
- kind: string;
1707
- score: null | number;
1708
- createdAt: string;
1709
- metadata?: Record<string, unknown>;
1710
- /** Exact server JSON metadata, including non-object values and null. */
1711
- remoteMetadata?: unknown;
1712
- /** Relative to the requested note; remote self-links can appear in both directions. */
1713
- direction?: 'incoming' | 'outgoing';
1714
- snippet?: null | string;
1765
+ /**
1766
+ * EmbeddingSetsRepository - named, filter, and virtual embedding set API.
1767
+ */
1768
+ type EmbeddingSetKind = 'filter' | 'physical' | 'virtual';
1769
+ type EmbeddingSetMode = 'auto' | 'manual' | 'mixed';
1770
+ interface EmbeddingSetCriteria {
1771
+ query?: string;
1772
+ tags?: string[];
1773
+ collectionIds?: string[];
1774
+ conceptIds?: string[];
1775
+ noteIds?: string[];
1776
+ sources?: string[];
1777
+ formats?: string[];
1778
+ visibilities?: string[];
1779
+ isStarred?: boolean;
1780
+ isArchived?: boolean;
1781
+ hasTitle?: boolean;
1782
+ hasEmbedding?: boolean;
1783
+ isUserEdited?: boolean;
1784
+ hasAiMetadata?: boolean;
1785
+ hasRevisions?: boolean;
1786
+ minGenerationCount?: number;
1787
+ maxGenerationCount?: number;
1788
+ updatedAfter?: string;
1789
+ updatedBefore?: string;
1715
1790
  }
1716
- interface BackendConcept {
1717
- id: string;
1718
- schemeId: string;
1719
- prefLabel: string;
1720
- altLabels: string[];
1721
- definition: null | string;
1722
- createdAt: string;
1723
- updatedAt: string;
1724
- /** Placeholder values for these fields are unavailable, not evidence of absence. */
1725
- unavailableFields?: Array<'altLabels' | 'definition'>;
1726
- assignment?: {
1727
- confidence?: number;
1728
- createdAt: string;
1729
- createdBy?: string;
1730
- isPrimary: boolean;
1731
- noteId: string;
1732
- relevanceScore: number;
1733
- source: string;
1734
- };
1791
+ interface EmbeddingSetFreshness {
1792
+ status: 'fresh' | 'stale' | 'unknown';
1793
+ sourceHash?: string;
1794
+ checkedAt?: string;
1795
+ reason?: string;
1735
1796
  }
1736
- interface BackendProvenanceEdge {
1737
- id: string;
1738
- entityType: string;
1739
- entityId: string;
1740
- activity: string;
1741
- agent: null | string;
1742
- startedAt: string;
1743
- endedAt: null | string;
1744
- attributes: unknown;
1797
+ interface EmbeddingCompatibilityPolicy {
1798
+ model: 'allow-compatible-family' | 'require-same';
1799
+ dimension: 'allow-truncation' | 'require-same';
1800
+ duplicateVectors: 'error' | 'prefer-latest' | 'prefer-set-order';
1801
+ missingVectors: 'error' | 'include-unembedded-note' | 'omit';
1745
1802
  }
1746
- /** One search hit — note plus optional rank/snippet when the backend ranks. */
1747
- interface BackendSearchHit {
1748
- note: BackendNote;
1749
- rank?: number;
1750
- snippet?: string;
1751
- /** Original remote search metadata; detail enrichment is a separate read. */
1752
- remoteSearch?: RemoteSearchMetadata;
1803
+ interface VirtualMaterializationPolicy {
1804
+ allowed: boolean;
1805
+ includeResolvedMembers?: boolean;
1806
+ includeResolvedEdges?: boolean;
1807
+ freshness: 'fresh' | 'stale' | 'unknown';
1808
+ inputHash?: string;
1809
+ generatedAt?: string;
1810
+ resolvedMemberCount?: number;
1753
1811
  }
1754
- /** Search response with optional facet counts. */
1755
- interface BackendSearchResult {
1756
- hits: BackendSearchHit[];
1757
- total: number;
1758
- facets?: {
1759
- source?: Record<string, number>;
1760
- tags: Record<string, number>;
1761
- };
1812
+ interface CriteriaVirtualSource {
1813
+ type: 'criteria';
1814
+ baseSetId: string;
1815
+ criteria: EmbeddingSetCriteria;
1762
1816
  }
1763
- interface BackendListOptions {
1764
- offset?: number;
1765
- limit?: number;
1817
+ interface SetOperationVirtualSource {
1818
+ type: 'set-operation';
1819
+ operation: 'difference' | 'intersection' | 'union';
1820
+ setIds: string[];
1766
1821
  }
1767
- interface BackendSearchQueryOptions extends BackendListOptions {
1768
- /** AND-filter: note must carry every listed tag. */
1769
- tags?: string[];
1770
- /** OR-filter on note source. */
1771
- source?: string[];
1822
+ interface FallbackVirtualSource {
1823
+ type: 'fallback';
1824
+ preferredSetIds: string[];
1772
1825
  }
1773
- /**
1774
- * Uniform tool-intent operation interface. Every backend implements the read
1775
- * core; `getNoteFull`, `semantic`, and `manageNote` are optional and present
1776
- * only on backends whose capabilities advertise them.
1777
- */
1778
- interface DataBackend {
1779
- readonly id: string;
1780
- readonly capabilities: BackendCapabilities;
1781
- listNotes(options?: BackendListOptions): Promise<{
1782
- items: BackendNote[];
1783
- total: number;
1784
- }>;
1785
- getNote(id: string): Promise<BackendNote | null>;
1786
- search(query: string, options?: BackendSearchQueryOptions): Promise<BackendSearchResult>;
1787
- /** Lazy full content (present when capabilities.read). */
1788
- getNoteFull?(id: string): Promise<BackendNoteFull | null>;
1789
- /** Note links (present when capabilities.read). */
1790
- linksOf?(id: string): Promise<BackendLink[]>;
1791
- /** SKOS concepts assigned to a note (present when capabilities.read). */
1792
- conceptsOf?(id: string): Promise<BackendConcept[]>;
1793
- /** W3C PROV edges for a note (present when capabilities.read). */
1794
- provenanceOf?(id: string): Promise<BackendProvenanceEdge[]>;
1795
- /** Remote revision/activity graph, preserving the server model and field names. */
1796
- provenanceGraphOf?(id: string): Promise<RemoteProvenanceGraph>;
1797
- /** Vector search (present when capabilities.semantic !== 'none'). */
1798
- semantic?(query: string, k?: number): Promise<BackendSearchHit[]>;
1799
- /** Write op (present when capabilities.write). */
1800
- manageNote?(input: unknown): Promise<unknown>;
1826
+ interface LatestCompatibleVirtualSource {
1827
+ type: 'latest-compatible';
1828
+ candidateSetIds: string[];
1829
+ model?: string;
1830
+ dimension?: number;
1801
1831
  }
1802
- /** What a caller needs. Booleans require `true`; `semantic` is a minimum tier. */
1803
- interface BackendRequest {
1804
- read?: boolean;
1805
- write?: boolean;
1806
- merge?: boolean;
1807
- multiUser?: boolean;
1808
- /** Minimum acceptable semantic tier (a higher tier satisfies a lower request). */
1809
- semantic?: BackendSemanticTier;
1832
+ interface SnapshotVirtualSource {
1833
+ type: 'snapshot';
1834
+ snapshotId: string;
1835
+ sourceDefinitionId: string;
1836
+ generatedAt: string;
1837
+ inputHash: string;
1810
1838
  }
1811
- interface BackendCandidate {
1812
- backend: DataBackend;
1813
- /** Requested capabilities this backend cannot satisfy ([] = fully satisfies). */
1814
- missing: string[];
1839
+ type VirtualEmbeddingSetSource = CriteriaVirtualSource | FallbackVirtualSource | LatestCompatibleVirtualSource | SetOperationVirtualSource | SnapshotVirtualSource;
1840
+ interface VirtualEmbeddingSetDefinition {
1841
+ id: string;
1842
+ name: string;
1843
+ purpose?: null | string;
1844
+ source: VirtualEmbeddingSetSource;
1845
+ compatibility: EmbeddingCompatibilityPolicy;
1846
+ materialization?: VirtualMaterializationPolicy;
1847
+ createdAt?: string;
1848
+ updatedAt?: string;
1815
1849
  }
1816
- interface BackendSelection {
1817
- /** Chosen backend — fully-satisfying-and-lightest, else fewest-missing. Null only when no backends are available. */
1818
- backend: DataBackend | null;
1819
- capabilities: BackendCapabilities | null;
1820
- /** Requested capabilities the chosen backend cannot satisfy. */
1821
- missing: string[];
1822
- /** Every candidate with its own missing set, ordered as evaluated. */
1823
- candidates: BackendCandidate[];
1850
+ interface EmbeddingSetSelector {
1851
+ kind: 'default' | 'embedding-set' | 'virtual-definition';
1852
+ embeddingSetId?: string;
1853
+ definition?: VirtualEmbeddingSetDefinition;
1824
1854
  }
1825
- /**
1826
- * Pick the backend that best satisfies `request` from `available`. Prefers a
1827
- * fully-satisfying backend with the lightest startup cost; if none fully
1828
- * satisfy, returns the one missing the fewest capabilities (lightest on ties) so
1829
- * the caller can degrade with eyes open via `selection.missing`.
1830
- */
1831
- declare function selectBackend(request: BackendRequest, available: DataBackend[]): BackendSelection;
1832
- interface PGliteBackendOptions {
1833
- id?: string;
1834
- /** Whether embeddings exist so search can use the semantic path. */
1835
- semanticAvailable?: boolean;
1855
+ interface EmbeddingSetDescriptor {
1856
+ id: string;
1857
+ name: string;
1858
+ purpose?: null | string;
1859
+ kind: EmbeddingSetKind;
1860
+ mode?: EmbeddingSetMode;
1861
+ model?: string;
1862
+ dimension?: number;
1863
+ truncateDimension?: null | number;
1864
+ criteria?: EmbeddingSetCriteria | null;
1865
+ createdAt?: string;
1866
+ updatedAt?: string;
1867
+ freshness?: EmbeddingSetFreshness;
1836
1868
  }
1837
- /**
1838
- * Wrap a PGlite-backed `DatabaseClient` as a `DataBackend`. Read ops delegate to
1839
- * the repositories; writes go through the `manageNote` tool. Advertises full
1840
- * read+write+merge with `ann-full` semantic when embeddings are present.
1841
- */
1842
- declare function createPGliteBackend(db: DatabaseClient, options?: PGliteBackendOptions): DataBackend;
1843
- interface RemoteBackendPaths {
1844
- notes: string;
1845
- note: string;
1846
- search: string;
1847
- links: string;
1848
- concepts: string;
1849
- provenance: string;
1850
- restore: string;
1851
- /** @deprecated Tool-intent path overrides cannot adapt the REST contract and are rejected. */
1852
- manageNote?: string;
1853
- /** @deprecated Semantic search uses the search path and mode parameter. Overrides are rejected. */
1854
- semantic?: string;
1869
+ type VirtualEmbeddingSetValidationError = {
1870
+ code: 'duplicate-vector';
1871
+ noteId: string;
1872
+ setIds: string[];
1873
+ } | {
1874
+ code: 'missing-vector';
1875
+ noteId: string;
1876
+ setId: string;
1877
+ } | {
1878
+ code: 'mixed-dimensions';
1879
+ setIds: string[];
1880
+ } | {
1881
+ code: 'mixed-models';
1882
+ setIds: string[];
1883
+ } | {
1884
+ code: 'stale-snapshot';
1885
+ snapshotId: string;
1886
+ } | {
1887
+ code: 'unsupported-criteria';
1888
+ field: string;
1889
+ };
1890
+ interface ResolvedEmbeddingRow {
1891
+ note_id: string;
1892
+ embedding_set_id: string;
1893
+ embedding_id: string;
1894
+ vector: string;
1895
+ created_at: Date | null;
1855
1896
  }
1856
- interface RemoteSearchOptions extends BackendSearchQueryOptions {
1857
- mode?: RemoteSearchMode;
1897
+ interface ResolvedEmbeddingSet {
1898
+ selector: EmbeddingSetSelector;
1899
+ rows: ResolvedEmbeddingRow[];
1900
+ noteIds: string[];
1901
+ embeddingIds: string[];
1902
+ errors: VirtualEmbeddingSetValidationError[];
1903
+ freshness: EmbeddingSetFreshness;
1904
+ resolutionSource: 'live' | 'materialized';
1858
1905
  }
1859
- interface RemoteSearchResult extends BackendSearchResult {
1860
- /** The server total counts returned hits, not the corpus or a pagination estimate. */
1861
- totalKind: 'returned-hits';
1862
- requestedMode: RemoteSearchMode;
1863
- effectiveMode: RemoteSearchMode;
1864
- degraded: boolean;
1865
- degradation?: RemoteSearchDegradation;
1906
+ interface EmbeddingConfigRow extends Omit<NativeEmbeddingConfig, 'created_at' | 'updated_at'> {
1907
+ created_at: Date;
1908
+ updated_at: Date;
1866
1909
  }
1867
- interface RemoteManageNoteResult {
1868
- action: 'archive' | 'create' | 'delete' | 'restore' | 'star' | 'unarchive' | 'unstar' | 'update';
1869
- note_id: string;
1870
- /** Present only when the mutation itself returns a note envelope. */
1871
- note?: BackendNoteFull;
1910
+ interface EmbeddingMemberRow extends Omit<NativeEmbeddingMember, 'added_at'> {
1911
+ embedding_id: null | string;
1912
+ added_at: Date | null;
1872
1913
  }
1873
- interface RemoteDataBackend extends DataBackend {
1874
- search(query: string, options?: RemoteSearchOptions): Promise<RemoteSearchResult>;
1875
- semanticWithReport(query: string, k?: number): Promise<RemoteSearchResult>;
1876
- manageNote(input: unknown): Promise<RemoteManageNoteResult>;
1914
+ interface EmbeddingRow {
1915
+ id: string;
1916
+ note_id: null | string;
1917
+ embedding_set_id: null | string;
1918
+ chunk_index: number;
1919
+ text: string;
1920
+ vector: null | string;
1921
+ model: null | string;
1922
+ contract_fingerprint: null | string;
1923
+ shard_contract_fingerprint_present: boolean;
1924
+ created_at: Date | null;
1877
1925
  }
1878
- interface RemoteBackendConfig {
1879
- baseUrl: string;
1926
+ interface EmbeddingSetRow extends Partial<Omit<NativeEmbeddingSet, 'created_at' | 'criteria' | 'keywords' | 'mode' | 'set_type' | 'truncate_dim' | 'updated_at'>> {
1927
+ id: string;
1928
+ name: string;
1929
+ purpose: null | string;
1930
+ model_name: string;
1931
+ dimensions: number;
1932
+ kind: EmbeddingSetKind;
1933
+ mode: EmbeddingSetMode | null;
1934
+ truncate_dimension: null | number;
1935
+ criteria_json: null | unknown;
1936
+ source_json: null | unknown;
1937
+ compatibility_json: null | unknown;
1938
+ materialization_json: null | unknown;
1939
+ freshness_json: null | unknown;
1940
+ created_at: Date;
1941
+ updated_at: Date;
1942
+ }
1943
+ interface EmbeddingSetCreateInput {
1880
1944
  id?: string;
1881
- fetchImpl?: typeof fetch;
1882
- headers?: (() => HeadersInit | Promise<HeadersInit>) | HeadersInit;
1883
- authToken?: string;
1884
- paths?: Partial<RemoteBackendPaths>;
1945
+ name: string;
1946
+ slug?: null | string;
1947
+ purpose?: null | string;
1948
+ model_name?: string;
1949
+ dimensions?: number;
1950
+ kind?: EmbeddingSetKind;
1951
+ mode?: EmbeddingSetMode | null;
1952
+ truncate_dimension?: null | number;
1953
+ criteria?: EmbeddingSetCriteria | null;
1885
1954
  }
1886
- declare function createRemoteBackend(config: RemoteBackendConfig): RemoteDataBackend;
1887
- interface ShardBackendOptions {
1955
+ interface EmbeddingSetEmbeddingInput {
1888
1956
  id?: string;
1889
- /** Declared semantic tier this shard provides (default `none`). Set to `cosine-small` when the reader has a vector provider. */
1890
- semantic?: BackendSemanticTier;
1957
+ note_id: string;
1958
+ embedding_set_id: string;
1959
+ vector: number[];
1891
1960
  }
1892
- /**
1893
- * Wrap a `ShardReader` (#189) as a read-only `DataBackend`. Startup is instant
1894
- * (no index build) and the semantic tier is whatever the reader's provider
1895
- * offers — `none` for text/facets-only shards, `cosine-small` when a vector
1896
- * provider is attached.
1897
- */
1898
- declare function createShardBackend(reader: ShardReader, options?: ShardBackendOptions): DataBackend;
1899
- declare const provenanceGraph: z.ZodObject<{
1900
- all_activities: z.ZodArray<z.ZodObject<{
1901
- activity_type: z.ZodString;
1902
- ended_at: z.ZodNullable<z.ZodString>;
1903
- id: z.ZodEffects<z.ZodString, string, string>;
1904
- metadata: z.ZodEffects<z.ZodUnknown, {} | null, unknown>;
1905
- model_name: z.ZodNullable<z.ZodString>;
1906
- note_id: z.ZodEffects<z.ZodString, string, string>;
1907
- revision_id: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
1908
- started_at: z.ZodString;
1909
- }, "strip", z.ZodTypeAny, {
1910
- activity_type: string;
1911
- ended_at: null | string;
1961
+ declare class EmbeddingSetsRepository {
1962
+ private db;
1963
+ constructor(db: QueryExecutor);
1964
+ getConfig(id: string): Promise<EmbeddingConfigRow>;
1965
+ listConfigs(): Promise<EmbeddingConfigRow[]>;
1966
+ listMembers(setId: string): Promise<EmbeddingMemberRow[]>;
1967
+ /** Includes metadata-only records and every chunk, unlike a resolved graph selector. */
1968
+ listEmbeddings(setId: string): Promise<EmbeddingRow[]>;
1969
+ create(input: EmbeddingSetCreateInput): Promise<EmbeddingSetRow>;
1970
+ createVirtualDefinition(input: VirtualEmbeddingSetDefinition): Promise<EmbeddingSetRow>;
1971
+ ensureDefault(): Promise<EmbeddingSetRow>;
1972
+ get(id: string): Promise<EmbeddingSetRow>;
1973
+ list(): Promise<EmbeddingSetRow[]>;
1974
+ listDescriptors(): Promise<EmbeddingSetDescriptor[]>;
1975
+ toDescriptor(row: EmbeddingSetRow): EmbeddingSetDescriptor;
1976
+ putEmbedding(input: EmbeddingSetEmbeddingInput): Promise<{
1912
1977
  id: string;
1913
- metadata: {} | null;
1914
- model_name: null | string;
1915
- note_id: string;
1916
- revision_id: null | string;
1917
- started_at: string;
1918
- }, {
1919
- activity_type: string;
1920
- ended_at: null | string;
1921
- id: string;
1922
- metadata?: unknown;
1923
- model_name: null | string;
1924
- note_id: string;
1925
- revision_id: null | string;
1926
- started_at: string;
1927
- }>, "many">;
1928
- all_edges: z.ZodArray<z.ZodObject<{
1929
- created_at_utc: z.ZodString;
1930
- id: z.ZodEffects<z.ZodString, string, string>;
1931
- relation: z.ZodString;
1932
- revision_id: z.ZodEffects<z.ZodString, string, string>;
1933
- source_note_id: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
1934
- source_url: z.ZodNullable<z.ZodString>;
1935
- }, "strip", z.ZodTypeAny, {
1936
- created_at_utc: string;
1937
- id: string;
1938
- relation: string;
1939
- revision_id: string;
1940
- source_note_id: null | string;
1941
- source_url: null | string;
1942
- }, {
1943
- created_at_utc: string;
1944
- id: string;
1945
- relation: string;
1946
- revision_id: string;
1947
- source_note_id: null | string;
1948
- source_url: null | string;
1949
- }>, "many">;
1950
- current_chain: z.ZodNullable<z.ZodObject<{
1951
- activity: z.ZodNullable<z.ZodObject<{
1952
- activity_type: z.ZodString;
1953
- ended_at: z.ZodNullable<z.ZodString>;
1954
- id: z.ZodEffects<z.ZodString, string, string>;
1955
- metadata: z.ZodEffects<z.ZodUnknown, {} | null, unknown>;
1956
- model_name: z.ZodNullable<z.ZodString>;
1957
- note_id: z.ZodEffects<z.ZodString, string, string>;
1958
- revision_id: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
1959
- started_at: z.ZodString;
1960
- }, "strip", z.ZodTypeAny, {
1961
- activity_type: string;
1962
- ended_at: null | string;
1963
- id: string;
1964
- metadata: {} | null;
1965
- model_name: null | string;
1966
- note_id: string;
1967
- revision_id: null | string;
1968
- started_at: string;
1969
- }, {
1970
- activity_type: string;
1971
- ended_at: null | string;
1972
- id: string;
1973
- metadata?: unknown;
1974
- model_name: null | string;
1975
- note_id: string;
1976
- revision_id: null | string;
1977
- started_at: string;
1978
- }>>;
1979
- edges: z.ZodArray<z.ZodObject<{
1980
- created_at_utc: z.ZodString;
1981
- id: z.ZodEffects<z.ZodString, string, string>;
1982
- relation: z.ZodString;
1983
- revision_id: z.ZodEffects<z.ZodString, string, string>;
1984
- source_note_id: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
1985
- source_url: z.ZodNullable<z.ZodString>;
1986
- }, "strip", z.ZodTypeAny, {
1987
- created_at_utc: string;
1988
- id: string;
1989
- relation: string;
1990
- revision_id: string;
1991
- source_note_id: null | string;
1992
- source_url: null | string;
1993
- }, {
1994
- created_at_utc: string;
1995
- id: string;
1996
- relation: string;
1997
- revision_id: string;
1998
- source_note_id: null | string;
1999
- source_url: null | string;
2000
- }>, "many">;
2001
- note_id: z.ZodEffects<z.ZodString, string, string>;
2002
- revision_id: z.ZodEffects<z.ZodString, string, string>;
2003
- }, "strip", z.ZodTypeAny, {
2004
- activity: {
2005
- activity_type: string;
2006
- ended_at: null | string;
2007
- id: string;
2008
- metadata: {} | null;
2009
- model_name: null | string;
2010
- note_id: string;
2011
- revision_id: null | string;
2012
- started_at: string;
2013
- } | null;
2014
- edges: {
2015
- created_at_utc: string;
2016
- id: string;
2017
- relation: string;
2018
- revision_id: string;
2019
- source_note_id: null | string;
2020
- source_url: null | string;
2021
- }[];
2022
- note_id: string;
2023
- revision_id: string;
2024
- }, {
2025
- activity: {
2026
- activity_type: string;
2027
- ended_at: null | string;
2028
- id: string;
2029
- metadata?: unknown;
2030
- model_name: null | string;
2031
- note_id: string;
2032
- revision_id: null | string;
2033
- started_at: string;
2034
- } | null;
2035
- edges: {
2036
- created_at_utc: string;
2037
- id: string;
2038
- relation: string;
2039
- revision_id: string;
2040
- source_note_id: null | string;
2041
- source_url: null | string;
2042
- }[];
2043
- note_id: string;
2044
- revision_id: string;
2045
- }>>;
2046
- derived_count: z.ZodNumber;
2047
- derived_notes: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
2048
- note_id: z.ZodEffects<z.ZodString, string, string>;
2049
- }, "strip", z.ZodTypeAny, {
2050
- all_activities: {
2051
- activity_type: string;
2052
- ended_at: null | string;
2053
- id: string;
2054
- metadata: {} | null;
2055
- model_name: null | string;
2056
- note_id: string;
2057
- revision_id: null | string;
2058
- started_at: string;
2059
- }[];
2060
- all_edges: {
2061
- created_at_utc: string;
2062
- id: string;
2063
- relation: string;
2064
- revision_id: string;
2065
- source_note_id: null | string;
2066
- source_url: null | string;
2067
- }[];
2068
- current_chain: {
2069
- activity: {
2070
- activity_type: string;
2071
- ended_at: null | string;
2072
- id: string;
2073
- metadata: {} | null;
2074
- model_name: null | string;
2075
- note_id: string;
2076
- revision_id: null | string;
2077
- started_at: string;
2078
- } | null;
2079
- edges: {
2080
- created_at_utc: string;
2081
- id: string;
2082
- relation: string;
2083
- revision_id: string;
2084
- source_note_id: null | string;
2085
- source_url: null | string;
2086
- }[];
2087
- note_id: string;
2088
- revision_id: string;
2089
- } | null;
2090
- derived_count: number;
2091
- derived_notes: string[];
2092
- note_id: string;
2093
- }, {
2094
- all_activities: {
2095
- activity_type: string;
2096
- ended_at: null | string;
2097
- id: string;
2098
- metadata?: unknown;
2099
- model_name: null | string;
2100
- note_id: string;
2101
- revision_id: null | string;
2102
- started_at: string;
1978
+ }>;
1979
+ resolveSelector(selector: EmbeddingSetSelector): Promise<ResolvedEmbeddingSet>;
1980
+ refreshMaterializedVirtualSet(setId: string): Promise<ResolvedEmbeddingSet>;
1981
+ markVirtualSetStale(setId: string, reason: string): Promise<void>;
1982
+ /** @internal The repository and mutation must use the same caller-owned transaction. */
1983
+ withMaterializationInvalidation<T>(mutate: () => Promise<T>): Promise<T>;
1984
+ private liveResolutionHash;
1985
+ private resolveDefinition;
1986
+ private resolvePhysicalSet;
1987
+ private resolvePhysicalRows;
1988
+ private resolveMaterializedRows;
1989
+ private resolveCriteriaSource;
1990
+ private resolveSetOperationSource;
1991
+ private resolveFallbackSource;
1992
+ private resolveLatestCompatibleSource;
1993
+ private validateCompatibility;
1994
+ private resolveDuplicateRows;
1995
+ private finalizeResolution;
1996
+ private resolutionInputHash;
1997
+ private definitionFromRow;
1998
+ private inferDefinitionModel;
1999
+ private inferDefinitionDimension;
2000
+ }
2001
+ /**
2002
+ * Shared types for repository layer.
2003
+ * All repository methods use these types as inputs and outputs.
2004
+ */
2005
+ interface NoteSummary {
2006
+ id: string;
2007
+ title: null | string;
2008
+ format: string;
2009
+ source: string;
2010
+ visibility: string;
2011
+ is_starred: boolean;
2012
+ is_pinned: boolean;
2013
+ is_archived: boolean;
2014
+ created_at: Date;
2015
+ updated_at: Date;
2016
+ deleted_at: Date | null;
2017
+ tags: string[];
2018
+ }
2019
+ interface NoteFull extends NoteSummary {
2020
+ /** Note metadata is independent of the current revision's AI metadata. */
2021
+ metadata?: unknown;
2022
+ archive_id: null | string;
2023
+ revision_mode: string;
2024
+ original: {
2025
+ content_hash: string;
2026
+ content: string;
2027
+ created_at: Date;
2028
+ id: null | string;
2029
+ user_created_at?: null | string;
2030
+ user_last_edited_at?: null | string;
2031
+ version_number?: number;
2032
+ };
2033
+ current: {
2034
+ ai_metadata: null | unknown;
2035
+ content: string;
2036
+ generation_count: number;
2037
+ is_user_edited: boolean;
2038
+ last_revision_id?: null | string;
2039
+ model: null | string;
2040
+ updated_at: Date;
2041
+ };
2042
+ }
2043
+ interface NoteCreateInput {
2044
+ metadata?: unknown;
2045
+ content: string;
2046
+ title?: string;
2047
+ format?: string;
2048
+ source?: string;
2049
+ visibility?: string;
2050
+ tags?: string[];
2051
+ archive_id?: string;
2052
+ /**
2053
+ * Explicit primary key. When omitted a UUIDv7 is minted (the default). Supply
2054
+ * this only for deterministic seeding or cross-instance identity — e.g. two
2055
+ * in-browser databases that must agree on a shared note's id so a shard swap
2056
+ * can dedupe it under the `skip` conflict strategy.
2057
+ */
2058
+ id?: string;
2059
+ }
2060
+ interface NoteUpdateInput {
2061
+ metadata?: unknown;
2062
+ title?: string;
2063
+ content?: string;
2064
+ format?: string;
2065
+ visibility?: string;
2066
+ }
2067
+ interface NoteListOptions {
2068
+ limit?: number;
2069
+ offset?: number;
2070
+ sort?: 'created_at' | 'title' | 'updated_at';
2071
+ order?: 'asc' | 'desc';
2072
+ is_starred?: boolean;
2073
+ is_pinned?: boolean;
2074
+ is_archived?: boolean;
2075
+ include_deleted?: boolean;
2076
+ include_archived?: boolean;
2077
+ collection_id?: string;
2078
+ tags?: string[];
2079
+ }
2080
+ interface PaginatedResult<T> {
2081
+ items: T[];
2082
+ total: number;
2083
+ limit: number;
2084
+ offset: number;
2085
+ }
2086
+ interface SearchResult {
2087
+ id: string;
2088
+ title: null | string;
2089
+ snippet: string;
2090
+ rank: number;
2091
+ created_at: Date;
2092
+ updated_at: Date;
2093
+ tags: string[];
2094
+ has_embedding?: boolean;
2095
+ locators?: EvidenceLocator[];
2096
+ /** Candidate matched-unit citations, separate from legacy source projections. */
2097
+ evidence?: SearchEvidenceSet;
2098
+ }
2099
+ interface SearchFacets {
2100
+ tags: {
2101
+ count: number;
2102
+ tag: string;
2103
2103
  }[];
2104
- all_edges: {
2105
- created_at_utc: string;
2104
+ collections: {
2105
+ count: number;
2106
2106
  id: string;
2107
- relation: string;
2108
- revision_id: string;
2109
- source_note_id: null | string;
2110
- source_url: null | string;
2107
+ name: string;
2111
2108
  }[];
2112
- current_chain: {
2113
- activity: {
2114
- activity_type: string;
2115
- ended_at: null | string;
2116
- id: string;
2117
- metadata?: unknown;
2118
- model_name: null | string;
2119
- note_id: string;
2120
- revision_id: null | string;
2121
- started_at: string;
2122
- } | null;
2123
- edges: {
2124
- created_at_utc: string;
2125
- id: string;
2126
- relation: string;
2127
- revision_id: string;
2128
- source_note_id: null | string;
2129
- source_url: null | string;
2130
- }[];
2131
- note_id: string;
2132
- revision_id: string;
2133
- } | null;
2134
- derived_count: number;
2135
- derived_notes: string[];
2136
- note_id: string;
2137
- }>;
2138
- /** Producer field names intentionally distinguish this graph from local PGlite PROV edges. */
2139
- type RemoteProvenanceGraph = z.infer<typeof provenanceGraph>;
2140
- declare const searchMode: z.ZodEnum<[
2141
- "fts",
2142
- "semantic",
2143
- "hybrid"
2144
- ]>;
2145
- type RemoteSearchMode = z.infer<typeof searchMode>;
2146
- declare const searchHit: z.ZodObject<{
2147
- chain_info: z.ZodOptional<z.ZodObject<{
2148
- best_chunk_sequence: z.ZodNumber;
2149
- chain_id: z.ZodEffects<z.ZodString, string, string>;
2150
- chunks_matched: z.ZodNumber;
2151
- original_title: z.ZodString;
2152
- total_chunks: z.ZodNumber;
2153
- }, "strip", z.ZodTypeAny, {
2154
- best_chunk_sequence: number;
2155
- chain_id: string;
2156
- chunks_matched: number;
2157
- original_title: string;
2158
- total_chunks: number;
2159
- }, {
2160
- best_chunk_sequence: number;
2161
- chain_id: string;
2162
- chunks_matched: number;
2163
- original_title: string;
2164
- total_chunks: number;
2165
- }>>;
2166
- embedding_status: z.ZodOptional<z.ZodEnum<[
2167
- "ready",
2168
- "pending",
2169
- "failed",
2170
- "none"
2171
- ]>>;
2172
- note_id: z.ZodEffects<z.ZodString, string, string>;
2173
- score: z.ZodNumber;
2174
- snippet: z.ZodNullable<z.ZodString>;
2175
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2176
- title: z.ZodOptional<z.ZodString>;
2177
- }, "strip", z.ZodTypeAny, {
2178
- chain_info?: {
2179
- best_chunk_sequence: number;
2180
- chain_id: string;
2181
- chunks_matched: number;
2182
- original_title: string;
2183
- total_chunks: number;
2184
- } | undefined;
2185
- embedding_status?: "failed" | "none" | "pending" | "ready" | undefined;
2109
+ }
2110
+ interface SearchResponse {
2111
+ results: SearchResult[];
2112
+ total: number;
2113
+ query: string;
2114
+ mode: 'hybrid' | 'semantic' | 'text';
2115
+ semantic_available: boolean;
2116
+ limit: number;
2117
+ offset: number;
2118
+ facets?: SearchFacets;
2119
+ }
2120
+ interface SearchOptions {
2121
+ limit?: number;
2122
+ offset?: number;
2123
+ tags?: string[];
2124
+ /** Require every tag; the existing tags option retains its ANY semantics. */
2125
+ tagsAll?: string[];
2126
+ collection_id?: string;
2127
+ date_from?: Date;
2128
+ date_to?: Date;
2129
+ is_starred?: boolean;
2130
+ is_archived?: boolean;
2131
+ format?: string;
2132
+ source?: string;
2133
+ /** Match any listed source before ranking. */
2134
+ sources?: string[];
2135
+ visibility?: string;
2136
+ tenant_id?: string;
2137
+ archive_id?: null | string;
2138
+ metadataPredicates?: readonly MetadataPredicate[];
2139
+ include_facets?: boolean;
2140
+ mode?: 'auto' | 'hybrid' | 'semantic' | 'text';
2141
+ embeddingSetId?: string;
2142
+ embeddingSetSelector?: EmbeddingSetSelector;
2143
+ }
2144
+ interface NoteRevision {
2145
+ id: string;
2186
2146
  note_id: string;
2187
- score: number;
2188
- snippet: null | string;
2189
- tags?: string[] | undefined;
2190
- title?: string | undefined;
2191
- }, {
2192
- chain_info?: {
2193
- best_chunk_sequence: number;
2194
- chain_id: string;
2195
- chunks_matched: number;
2196
- original_title: string;
2197
- total_chunks: number;
2198
- } | undefined;
2199
- embedding_status?: "failed" | "none" | "pending" | "ready" | undefined;
2147
+ revision_number: number;
2148
+ type: string;
2149
+ content: string;
2150
+ ai_metadata: null | unknown;
2151
+ model: null | string;
2152
+ created_at: Date;
2153
+ parent_revision_id?: null | string;
2154
+ summary?: null | string;
2155
+ rationale?: null | string;
2156
+ created_at_utc?: null | string;
2157
+ ai_generated_at?: null | string;
2158
+ user_last_edited_at?: null | string;
2159
+ is_user_edited?: boolean;
2160
+ generation_count?: number;
2161
+ }
2162
+ interface OriginalContentRevision {
2163
+ id: string;
2200
2164
  note_id: string;
2201
- score: number;
2202
- snippet: null | string;
2203
- tags?: string[] | undefined;
2204
- title?: string | undefined;
2205
- }>;
2206
- declare const searchDegradation: z.ZodObject<{
2207
- code: z.ZodString;
2208
- effective_mode: z.ZodEnum<[
2209
- "fts",
2210
- "semantic",
2211
- "hybrid"
2212
- ]>;
2213
- }, "strip", z.ZodTypeAny, {
2214
- code: string;
2215
- effective_mode: "fts" | "hybrid" | "semantic";
2216
- }, {
2217
- code: string;
2218
- effective_mode: "fts" | "hybrid" | "semantic";
2219
- }>;
2220
- type RemoteSearchDegradation = z.infer<typeof searchDegradation>;
2221
- type RemoteSearchMetadata = Pick<z.infer<typeof searchHit>, 'chain_info' | 'embedding_status' | 'tags' | 'title'>;
2222
- declare const manageInput: z.ZodUnion<[
2223
- z.ZodObject<{
2224
- action: z.ZodLiteral<"create">;
2225
- content: z.ZodString;
2226
- source: z.ZodOptional<z.ZodString>;
2227
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2228
- title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2229
- }, "strict", z.ZodTypeAny, {
2230
- action: "create";
2231
- content: string;
2232
- source?: string | undefined;
2233
- tags?: string[] | undefined;
2234
- title?: null | string | undefined;
2235
- }, {
2236
- action: "create";
2237
- content: string;
2238
- source?: string | undefined;
2239
- tags?: string[] | undefined;
2240
- title?: null | string | undefined;
2241
- }>,
2242
- z.ZodEffects<z.ZodObject<{
2243
- action: z.ZodLiteral<"update">;
2244
- content: z.ZodOptional<z.ZodString>;
2245
- note_id: z.ZodEffects<z.ZodString, string, string>;
2246
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2247
- }, "strict", z.ZodTypeAny, {
2248
- action: "update";
2249
- content?: string | undefined;
2250
- note_id: string;
2251
- tags?: string[] | undefined;
2252
- }, {
2253
- action: "update";
2254
- content?: string | undefined;
2255
- note_id: string;
2256
- tags?: string[] | undefined;
2257
- }>, {
2258
- action: "update";
2259
- content?: string | undefined;
2260
- note_id: string;
2261
- tags?: string[] | undefined;
2262
- }, {
2263
- action: "update";
2264
- content?: string | undefined;
2265
- note_id: string;
2266
- tags?: string[] | undefined;
2267
- }>,
2268
- z.ZodObject<{
2269
- action: z.ZodEnum<[
2270
- "delete",
2271
- "restore",
2272
- "archive",
2273
- "unarchive",
2274
- "star",
2275
- "unstar"
2276
- ]>;
2277
- note_id: z.ZodEffects<z.ZodString, string, string>;
2278
- }, "strict", z.ZodTypeAny, {
2279
- action: "archive" | "delete" | "restore" | "star" | "unarchive" | "unstar";
2280
- note_id: string;
2281
- }, {
2282
- action: "archive" | "delete" | "restore" | "star" | "unarchive" | "unstar";
2283
- note_id: string;
2284
- }>
2285
- ]>;
2286
- type RemoteManageNoteInput = z.infer<typeof manageInput>;
2165
+ version_number: number;
2166
+ content: string;
2167
+ hash: string;
2168
+ created_at_utc: string;
2169
+ created_by: string;
2170
+ }
2171
+ declare const REGISTERED_METADATA_PATHS: readonly [
2172
+ "provider",
2173
+ "model",
2174
+ "role",
2175
+ "event_kind",
2176
+ "sensitivity",
2177
+ "import_run_id"
2178
+ ];
2179
+ type RegisteredMetadataPath = typeof REGISTERED_METADATA_PATHS[number];
2180
+ type MetadataPredicate = {
2181
+ gte?: number | string;
2182
+ lte?: number | string;
2183
+ op: 'range';
2184
+ path: RegisteredMetadataPath;
2185
+ } | {
2186
+ op: 'eq';
2187
+ path: RegisteredMetadataPath;
2188
+ value: boolean | null | number | string;
2189
+ } | {
2190
+ op: 'exists';
2191
+ path: RegisteredMetadataPath;
2192
+ value?: boolean;
2193
+ } | {
2194
+ op: 'in';
2195
+ path: RegisteredMetadataPath;
2196
+ value: readonly (boolean | null | number | string)[];
2197
+ };
2198
+ interface EvidenceLocator {
2199
+ note_id: string;
2200
+ chunk?: {
2201
+ index: number;
2202
+ kind: 'attachment' | 'current' | 'title';
2203
+ };
2204
+ span?: {
2205
+ end: number;
2206
+ start: number;
2207
+ };
2208
+ source?: {
2209
+ external_id_hash: string;
2210
+ import_run_id: string;
2211
+ namespace: string;
2212
+ schema_version: string;
2213
+ };
2214
+ metadata_paths: RegisteredMetadataPath[];
2215
+ }
2216
+ interface MetadataPredicateConditionResult {
2217
+ conditions: string[];
2218
+ joins: string[];
2219
+ params: unknown[];
2220
+ nextIdx: number;
2221
+ }
2222
+ type ScopeOptions = Pick<SearchOptions, 'archive_id' | 'metadataPredicates' | 'tenant_id'>;
2223
+ declare function buildMetadataPredicateConditions(options: ScopeOptions, startIdx: number): MetadataPredicateConditionResult;
2224
+ interface RemoteEvidenceResolutionOptions {
2225
+ metadataPredicates?: readonly MetadataPredicate[];
2226
+ includeArchived?: boolean;
2227
+ /** Cancels header lookup, transport and response reading; a 30-second ceiling also applies. */
2228
+ signal?: AbortSignal;
2229
+ }
2287
2230
  /**
2288
- * Capability module system (ADR-002).
2289
- * Tracks opt-in WASM module states. No WASM loaded by default (CAP-001).
2231
+ * Backend seam (#191) — a uniform tool-intent operation interface that lets the
2232
+ * PGlite database backend (#187) and the static-file shard backend (#189) be
2233
+ * selected and dispatched against the same way, plus a capability-negotiation
2234
+ * API so a caller asks for the operations it needs and gets the lightest backend
2235
+ * that provides them.
2290
2236
  *
2291
- * State machine (valid transitions):
2292
- * unloaded -> loading (via enable)
2293
- * loading -> ready (via markReady or successful loader)
2294
- * loading -> error (via markError or failed loader)
2295
- * ready -> disabled (via disable)
2296
- * disabled -> loading (via enable, re-enable)
2297
- * error -> loading (via enable, retry)
2237
+ * The seam sits one level above SQL: every adapter exposes the same read
2238
+ * operations (and optional relationship, write, semantic, and full-content ops)
2239
+ * regardless of whether the data lives in a queryable PGlite instance, a set of
2240
+ * static shard files fetched over HTTP, or the Fortemi server tier.
2298
2241
  */
2299
- type CapabilityState = 'disabled' | 'error' | 'loading' | 'ready' | 'unloaded';
2300
- type CapabilityName = 'audio' | 'llm' | 'pdf' | 'semantic' | 'vision';
2301
- declare class CapabilityManager {
2302
- private events;
2303
- private capabilities;
2304
- private loaders;
2305
- private progressMessages;
2306
- constructor(events: TypedEventBus);
2307
- /**
2308
- * Register an async loader for a capability.
2309
- * Called by enable(); if no loader is registered the capability transitions
2310
- * directly to ready (useful for capabilities that require no async init).
2311
- */
2312
- registerLoader(name: CapabilityName, loader: () => Promise<void>): void;
2313
- getState(name: CapabilityName): CapabilityState;
2314
- isReady(name: CapabilityName): boolean;
2315
- /**
2316
- * Enable a capability.
2317
- * Valid from: unloaded, disabled, error (retry).
2318
- * Runs the registered loader if present; transitions to ready on success,
2319
- * error on failure.
2320
- */
2321
- enable(name: CapabilityName): Promise<void>;
2322
- /**
2323
- * Disable a ready capability.
2324
- * Valid from: ready only.
2325
- */
2326
- disable(name: CapabilityName): void;
2327
- /**
2328
- * Mark a loading capability as ready (external use, e.g. bridge protocol).
2329
- * Valid from: loading only.
2330
- */
2331
- markReady(name: CapabilityName): void;
2332
- /**
2333
- * Mark a loading capability as errored (external use, e.g. bridge protocol).
2334
- * Valid from: loading only.
2335
- */
2336
- markError(name: CapabilityName, error: string): void;
2337
- /**
2338
- * Report loading progress (0-100).
2339
- * Emits capability.loading with progress if the capability is currently loading.
2340
- * No-op if the capability is not in loading state.
2341
- */
2342
- reportProgress(name: CapabilityName, progress: number): void;
2343
- /** Set a human-readable progress message for a loading capability */
2344
- setProgress(name: CapabilityName, message: string): void;
2345
- /** Get the current progress message for a capability */
2346
- getProgress(name: CapabilityName): string | undefined;
2347
- getError(name: CapabilityName): string | undefined;
2348
- listAll(): Array<{
2349
- name: CapabilityName;
2350
- state: CapabilityState;
2351
- }>;
2352
- }
2353
2242
  /**
2354
- * Sequential SQL migration runner for DatabaseClient.
2355
- * Tracks applied migrations in a schema_version table.
2356
- * Each migration runs in a transaction; version updated atomically.
2243
+ * Semantic-search tier a backend offers, in increasing capability:
2244
+ * - `none` — no vector search (text / facets only)
2245
+ * - `cosine-small` brute-force cosine over a small static vector set (#189)
2246
+ * - `ann-full` — prebuilt/queryable approximate-nearest-neighbour over the full
2247
+ * corpus (PGlite + pgvector, or a prebuilt ANN snapshot)
2248
+ * - `server` — delegated to the remote Fortemi server backend
2357
2249
  */
2358
- interface Migration {
2359
- version: number;
2360
- name: string;
2361
- sql: string;
2362
- }
2363
- declare class MigrationRunner {
2364
- private db;
2365
- private events?;
2366
- constructor(db: DatabaseClient, events?: TypedEventBus | undefined);
2367
- ensureSchemaTable(): Promise<void>;
2368
- getCurrentVersion(): Promise<number>;
2369
- apply(migrations: Migration[]): Promise<number>;
2370
- getAppliedMigrations(): Promise<Array<{
2371
- name: string;
2372
- version: number;
2373
- }>>;
2250
+ type BackendSemanticTier = 'ann-full' | 'cosine-small' | 'none' | 'server';
2251
+ /** Relative startup cost of bringing a backend online. */
2252
+ type BackendStartupCost = 'index-build' | 'instant' | 'network';
2253
+ /** What a backend can do — the unit of capability negotiation. */
2254
+ interface BackendCapabilities {
2255
+ /** Local candidate-v1 indexed predicate operations, not server contract negotiation. */
2256
+ typedMetadataPredicates?: boolean;
2257
+ /** Complete reproducible citations, not merely partial source projections. */
2258
+ evidenceLocators?: boolean;
2259
+ /** Can answer list / get / search read operations. */
2260
+ read: boolean;
2261
+ /** Can mutate notes (manageNote). */
2262
+ write: boolean;
2263
+ /** Can merge external shards into its store. */
2264
+ merge: boolean;
2265
+ /** Coordinates concurrent multi-user writes. */
2266
+ multiUser: boolean;
2267
+ /** Highest semantic-search tier available. */
2268
+ semantic: BackendSemanticTier;
2269
+ /** Relative cost to bring the backend online. */
2270
+ startupCost: BackendStartupCost;
2374
2271
  }
2375
- declare const allMigrations: Migration[];
2376
2272
  /**
2377
- * Multi-archive manager for Fortemi.
2378
- * Each archive is a separate PGlite instance with its own persistence path.
2379
- * Migrations are applied automatically on open.
2273
+ * Backend-neutral note record. `source`/`starred`/`archived` are optional
2274
+ * because lean read paths (PGlite full-text search) do not return them; list,
2275
+ * get, and every shard path populate all fields.
2380
2276
  */
2381
- interface ArchiveInfo {
2382
- name: string;
2277
+ interface BackendNote {
2278
+ id: string;
2279
+ title: null | string;
2280
+ tags: string[];
2383
2281
  createdAt: string;
2282
+ updatedAt: string;
2283
+ source?: string;
2284
+ starred?: boolean;
2285
+ archived?: boolean;
2384
2286
  }
2385
- declare class ArchiveManager {
2386
- private events?;
2387
- private currentArchive;
2388
- private db;
2389
- private archives;
2390
- private persistence;
2391
- private backendFactory;
2392
- /**
2393
- * Persistence is a PLUGGABLE, opt-in backend (issue #261). Pass a
2394
- * `StorageBackendFactory` to run against any `StorageBackend`
2395
- * implementation; PGlite is merely the built-in default, selected only when
2396
- * the convenience `PersistenceMode` string form is used. Because
2397
- * `defaultStorageBackendFactory` reaches PGlite through the lazily-imported
2398
- * `createPGliteInstance` (see `db.ts`), a consumer that supplies its own
2399
- * factory or never opens an archive at all — never pulls the PGlite WASM
2400
- * engine into its bundle.
2401
- *
2402
- * @param persistenceOrFactory `PersistenceMode` string (uses the built-in
2403
- * PGlite backend) OR a custom `StorageBackendFactory`.
2404
- * @param persistenceOverride persistence hint passed to a custom factory.
2405
- */
2406
- constructor(persistenceOrFactory: PersistenceMode | StorageBackendFactory, events?: TypedEventBus | undefined, persistenceOverride?: PersistenceMode);
2407
- getCurrentArchiveName(): string;
2408
- getDb(): null | StorageBackend;
2409
- open(archiveName?: string): Promise<StorageBackend>;
2410
- /**
2411
- * Adopt an already-created backend WITHOUT running migrations — for a backend
2412
- * whose schema is already present, e.g. a PGlite restored from a physical
2413
- * data-dir snapshot (issue #187, `restoreDbSnapshot`). Running migrations here
2414
- * would be wrong: the restored dir already carries them (and the HNSW index).
2415
- */
2416
- adopt(backend: StorageBackend, archiveName?: string): Promise<StorageBackend>;
2417
- create(archiveName: string): Promise<StorageBackend>;
2418
- switchTo(archiveName: string): Promise<StorageBackend>;
2419
- delete(archiveName: string): Promise<void>;
2420
- listArchives(): ArchiveInfo[];
2421
- close(): Promise<void>;
2287
+ /** A note plus its current rendered content. */
2288
+ interface BackendNoteFull extends BackendNote {
2289
+ content: string;
2290
+ /** Native note metadata, separate from inference metadata where supported. */
2291
+ metadata?: unknown;
2292
+ links?: BackendLink[];
2293
+ concepts?: BackendConcept[];
2294
+ provenance?: BackendProvenanceEdge[];
2295
+ /** Server revision/activity graph; not interchangeable with local provenance edges. */
2296
+ provenanceGraph?: RemoteProvenanceGraph;
2297
+ }
2298
+ interface BackendLink {
2299
+ id: string;
2300
+ fromNoteId: string;
2301
+ toNoteId: null | string;
2302
+ toUrl?: null | string;
2303
+ kind: string;
2304
+ score: null | number;
2305
+ createdAt: string;
2306
+ metadata?: Record<string, unknown>;
2307
+ /** Exact server JSON metadata, including non-object values and null. */
2308
+ remoteMetadata?: unknown;
2309
+ /** Relative to the requested note; remote self-links can appear in both directions. */
2310
+ direction?: 'incoming' | 'outgoing';
2311
+ snippet?: null | string;
2312
+ }
2313
+ interface BackendConcept {
2314
+ id: string;
2315
+ schemeId: string;
2316
+ prefLabel: string;
2317
+ altLabels: string[];
2318
+ definition: null | string;
2319
+ createdAt: string;
2320
+ updatedAt: string;
2321
+ /** Placeholder values for these fields are unavailable, not evidence of absence. */
2322
+ unavailableFields?: Array<'altLabels' | 'definition'>;
2323
+ assignment?: {
2324
+ confidence?: number;
2325
+ createdAt: string;
2326
+ createdBy?: string;
2327
+ isPrimary: boolean;
2328
+ noteId: string;
2329
+ relevanceScore: number;
2330
+ source: string;
2331
+ };
2332
+ }
2333
+ interface BackendProvenanceEdge {
2334
+ id: string;
2335
+ entityType: string;
2336
+ entityId: string;
2337
+ activity: string;
2338
+ agent: null | string;
2339
+ startedAt: string;
2340
+ endedAt: null | string;
2341
+ attributes: unknown;
2342
+ }
2343
+ /** One search hit — note plus optional rank/snippet when the backend ranks. */
2344
+ interface BackendSearchHit {
2345
+ note: BackendNote;
2346
+ rank?: number;
2347
+ snippet?: string;
2348
+ /** Original remote search metadata; detail enrichment is a separate read. */
2349
+ remoteSearch?: RemoteSearchMetadata;
2350
+ /** Partial local source projections; does not imply complete citation capability. */
2351
+ locators?: EvidenceLocator[];
2352
+ /** Candidate matched-unit evidence; not a negotiated complete capability. */
2353
+ evidence?: SearchEvidenceSet;
2354
+ }
2355
+ /** Search response with optional facet counts. */
2356
+ interface BackendSearchResult {
2357
+ hits: BackendSearchHit[];
2358
+ total: number;
2359
+ facets?: {
2360
+ source?: Record<string, number>;
2361
+ tags: Record<string, number>;
2362
+ };
2363
+ }
2364
+ interface BackendListOptions {
2365
+ offset?: number;
2366
+ limit?: number;
2367
+ }
2368
+ interface BackendSearchQueryOptions extends BackendListOptions {
2369
+ /** AND-filter: note must carry every listed tag. */
2370
+ tags?: string[];
2371
+ /** OR-filter on note source. */
2372
+ source?: string[];
2373
+ mode?: 'fts' | 'hybrid' | 'semantic';
2374
+ metadataPredicates?: readonly MetadataPredicate[];
2375
+ /** Local source-identity selection, never a grant of authorization. */
2376
+ tenant_id?: string;
2377
+ archive_id?: null | string;
2422
2378
  }
2423
2379
  /**
2424
- * Factory function for creating a FortemiCore instance.
2425
- * All deployment modes use this entry point.
2380
+ * Uniform tool-intent operation interface. Every backend implements the read
2381
+ * core; `getNoteFull`, `semantic`, and `manageNote` are optional and present
2382
+ * only on backends whose capabilities advertise them.
2426
2383
  */
2427
- interface FortemiConfig {
2428
- persistence: 'idb' | 'memory' | 'opfs';
2429
- archiveName?: string;
2384
+ interface DataBackend {
2385
+ readonly id: string;
2386
+ readonly capabilities: BackendCapabilities;
2387
+ listNotes(options?: BackendListOptions): Promise<{
2388
+ items: BackendNote[];
2389
+ total: number;
2390
+ }>;
2391
+ getNote(id: string): Promise<BackendNote | null>;
2392
+ search(query: string, options?: BackendSearchQueryOptions): Promise<BackendSearchResult>;
2393
+ /** Lazy full content (present when capabilities.read). */
2394
+ getNoteFull?(id: string): Promise<BackendNoteFull | null>;
2395
+ /** Note links (present when capabilities.read). */
2396
+ linksOf?(id: string): Promise<BackendLink[]>;
2397
+ /** SKOS concepts assigned to a note (present when capabilities.read). */
2398
+ conceptsOf?(id: string): Promise<BackendConcept[]>;
2399
+ /** W3C PROV edges for a note (present when capabilities.read). */
2400
+ provenanceOf?(id: string): Promise<BackendProvenanceEdge[]>;
2401
+ /** Remote revision/activity graph, preserving the server model and field names. */
2402
+ provenanceGraphOf?(id: string): Promise<RemoteProvenanceGraph>;
2403
+ /** Vector search (present when capabilities.semantic !== 'none'). */
2404
+ semantic?(query: string, k?: number): Promise<BackendSearchHit[]>;
2405
+ /** Write op (present when capabilities.write). */
2406
+ manageNote?(input: unknown): Promise<unknown>;
2430
2407
  }
2431
- interface FortemiCore {
2432
- events: TypedEventBus;
2433
- config: FortemiConfig;
2434
- destroy(): void;
2408
+ /** What a caller needs. Booleans require `true`; `semantic` is a minimum tier. */
2409
+ interface BackendRequest {
2410
+ typedMetadataPredicates?: boolean;
2411
+ evidenceLocators?: boolean;
2412
+ read?: boolean;
2413
+ write?: boolean;
2414
+ merge?: boolean;
2415
+ multiUser?: boolean;
2416
+ /** Minimum acceptable semantic tier (a higher tier satisfies a lower request). */
2417
+ semantic?: BackendSemanticTier;
2418
+ }
2419
+ interface BackendCandidate {
2420
+ backend: DataBackend;
2421
+ /** Requested capabilities this backend cannot satisfy ([] = fully satisfies). */
2422
+ missing: string[];
2423
+ }
2424
+ interface BackendSelection {
2425
+ /** Chosen backend — fully-satisfying-and-lightest, else fewest-missing. Null only when no backends are available. */
2426
+ backend: DataBackend | null;
2427
+ capabilities: BackendCapabilities | null;
2428
+ /** Requested capabilities the chosen backend cannot satisfy. */
2429
+ missing: string[];
2430
+ /** Every candidate with its own missing set, ordered as evaluated. */
2431
+ candidates: BackendCandidate[];
2435
2432
  }
2436
- declare function createFortemi(config: FortemiConfig): FortemiCore;
2437
2433
  /**
2438
- * Compute a browser-local content-identity hash (SHA-256), encoded as
2439
- * `sha256:<64-char lowercase hex>`.
2440
- *
2441
- * This is an internal identity/dedup digest used for note content, embedding
2442
- * configs, the AIWG index, and graph identity — NOT the server's attachment
2443
- * content-hash convention. Binary-attachment blobs use {@link computeBlobHash}
2444
- * (BLAKE3), which is the canonical checksum defined by the binary-attachment
2445
- * projection contract (`checksum: "blake3:<hex>"`). Keeping these two functions
2446
- * separate preserves JSON format parity for the identity hashes above while
2447
- * letting attachments match the server's `compute_content_hash`.
2448
- *
2449
- * @param data - Raw bytes to hash
2450
- * @returns `'sha256:<64-char lowercase hex>'`
2434
+ * Pick the backend that best satisfies `request` from `available`. Prefers a
2435
+ * fully-satisfying backend with the lightest startup cost; if none fully
2436
+ * satisfy, returns the one missing the fewest capabilities (lightest on ties) so
2437
+ * the caller can degrade with eyes open via `selection.missing`.
2451
2438
  */
2452
- declare function computeHash(data: Uint8Array): string;
2439
+ declare function selectBackend(request: BackendRequest, available: DataBackend[]): BackendSelection;
2440
+ interface PGliteBackendOptions {
2441
+ id?: string;
2442
+ /** Whether embeddings exist so search can use the semantic path. */
2443
+ semanticAvailable?: boolean;
2444
+ /** Host-owned query embedding, required to expose semantic/hybrid operations. */
2445
+ embedQuery?: (query: string) => Promise<number[]>;
2446
+ }
2453
2447
  /**
2454
- * Compute the canonical attachment content hash: **BLAKE3**, encoded as
2455
- * `blake3:<64-char lowercase hex>`.
2456
- *
2457
- * Matches the fortemi server (`crates/matric-db/src/file_storage.rs`
2458
- * `compute_content_hash`) and the portable Knowledge-Shard byte-sidecar
2459
- * contract, where the sidecar tar entry name is the bare hex (the `blake3:`
2460
- * prefix stripped). SubtleCrypto has no BLAKE3, so this uses `@noble/hashes`.
2461
- *
2462
- * @param data - Raw attachment bytes to hash
2463
- * @returns `'blake3:<64-char lowercase hex>'`
2448
+ * Wrap a PGlite-backed `DatabaseClient` as a `DataBackend`. Read ops delegate to
2449
+ * the repositories; writes go through the `manageNote` tool. Advertises full
2450
+ * read+write+merge with `ann-full` only when vector storage and a query embedder
2451
+ * are configured. Typed predicates refer to the local unpublished candidate.
2464
2452
  */
2465
- declare function computeBlobHash(data: Uint8Array): string;
2466
- declare const FORTEMI_COMPATIBILITY_PATH = "/api/v1/system/compatibility";
2467
- declare const FORTEMI_SERVER_COMPATIBILITY_REVISION = "2026-07-06";
2468
- declare const FORTEMI_COMPATIBILITY_STATES: readonly [
2469
- "available",
2470
- "degraded",
2471
- "preview",
2472
- "unavailable",
2473
- "unknown"
2474
- ];
2475
- type FortemiCompatibilityState = (typeof FORTEMI_COMPATIBILITY_STATES)[number];
2476
- declare const FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES: readonly [
2477
- "core_notes",
2478
- "search",
2479
- "jobs",
2480
- "realtime_activity",
2481
- "hosted_auth",
2482
- "premium_components",
2483
- "backoffice_api",
2484
- "audit_posture",
2485
- "quota_status",
2486
- "kms_status",
2487
- "mcp_scope_gate"
2488
- ];
2489
- type FortemiRequiredCompatibilityCapability = (typeof FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES)[number];
2490
- interface FortemiCompatibilityCapability {
2491
- state: FortemiCompatibilityState;
2492
- reason_code?: string;
2453
+ declare function createPGliteBackend(db: DatabaseClient, options?: PGliteBackendOptions): DataBackend;
2454
+ interface RemoteBackendPaths {
2455
+ notes: string;
2456
+ note: string;
2457
+ search: string;
2458
+ resolveEvidence?: string;
2459
+ links: string;
2460
+ concepts: string;
2461
+ provenance: string;
2462
+ restore: string;
2463
+ /** @deprecated Tool-intent path overrides cannot adapt the REST contract and are rejected. */
2464
+ manageNote?: string;
2465
+ /** @deprecated Semantic search uses the search path and mode parameter. Overrides are rejected. */
2466
+ semantic?: string;
2493
2467
  }
2494
- interface FortemiCompatibilityResponse {
2495
- schema_version: number;
2496
- contract_revision: string;
2497
- api: {
2498
- build_date_present: boolean;
2499
- git_sha_present: boolean;
2500
- minimum_hotm_enterprise_client: string;
2501
- name: string;
2502
- version: string;
2503
- };
2504
- deployment: {
2505
- edition: string;
2506
- hosted_multi_tenant_ready: boolean;
2507
- mode: string;
2508
- };
2509
- auth: {
2510
- mode: string;
2511
- oauth_issuer_configured: boolean;
2512
- required: boolean;
2513
- tenant_context_available: boolean;
2514
- };
2515
- capabilities: Record<string, FortemiCompatibilityCapability>;
2516
- links: {
2517
- asyncapi: string;
2518
- health: string;
2519
- openapi: string;
2520
- streaming_health: string;
2521
- };
2468
+ interface RemoteSearchOptions extends BackendSearchQueryOptions {
2469
+ mode?: RemoteSearchMode;
2522
2470
  }
2523
- interface FortemiCompatibilityValidationResult {
2524
- ok: boolean;
2525
- errors: string[];
2526
- warnings: string[];
2527
- response?: FortemiCompatibilityResponse;
2471
+ interface RemoteSearchResult extends BackendSearchResult {
2472
+ /** The server total counts returned hits, not the corpus or a pagination estimate. */
2473
+ totalKind: 'returned-hits';
2474
+ requestedMode: RemoteSearchMode;
2475
+ effectiveMode: RemoteSearchMode;
2476
+ degraded: boolean;
2477
+ degradation?: RemoteSearchDegradation;
2528
2478
  }
2529
- interface FetchFortemiCompatibilityOptions {
2530
- baseUrl?: string;
2479
+ interface RemoteManageNoteResult {
2480
+ action: 'archive' | 'create' | 'delete' | 'restore' | 'star' | 'unarchive' | 'unstar' | 'update';
2481
+ note_id: string;
2482
+ /** Present only when the mutation itself returns a note envelope. */
2483
+ note?: BackendNoteFull;
2484
+ }
2485
+ interface RemoteDataBackend extends DataBackend {
2486
+ /** Candidate current-storage resolution; not a complete evidence capability advertisement. */
2487
+ resolveEvidence(locator: unknown, options?: RemoteEvidenceResolutionOptions): Promise<string>;
2488
+ search(query: string, options?: RemoteSearchOptions): Promise<RemoteSearchResult>;
2489
+ semanticWithReport(query: string, k?: number): Promise<RemoteSearchResult>;
2490
+ manageNote(input: unknown): Promise<RemoteManageNoteResult>;
2491
+ }
2492
+ interface RemoteBackendConfig {
2493
+ baseUrl: string;
2494
+ id?: string;
2531
2495
  fetchImpl?: typeof fetch;
2532
- timeoutMs?: number;
2496
+ headers?: (() => HeadersInit | Promise<HeadersInit>) | HeadersInit;
2497
+ authToken?: string;
2498
+ paths?: Partial<RemoteBackendPaths>;
2533
2499
  }
2534
- declare function fortemiCompatibilityUrl(baseUrl?: string): string;
2535
- declare function validateFortemiCompatibilityResponse(raw: unknown): FortemiCompatibilityValidationResult;
2536
- declare function formatFortemiCompatibilitySummary(response: FortemiCompatibilityResponse): string;
2537
- declare function fetchAndValidateFortemiCompatibility(options?: FetchFortemiCompatibilityOptions): Promise<FortemiCompatibilityValidationResult & {
2538
- status?: number;
2539
- url: string;
2500
+ declare function createRemoteBackend(config: RemoteBackendConfig): RemoteDataBackend;
2501
+ interface ShardBackendOptions {
2502
+ id?: string;
2503
+ /** Declared semantic tier this shard provides (default `none`). Set to `cosine-small` when the reader has a vector provider. */
2504
+ semantic?: BackendSemanticTier;
2505
+ }
2506
+ /**
2507
+ * Wrap a `ShardReader` (#189) as a read-only `DataBackend`. Startup is instant
2508
+ * (no index build) and the semantic tier is whatever the reader's provider
2509
+ * offers — `none` for text/facets-only shards, `cosine-small` when a vector
2510
+ * provider is attached.
2511
+ */
2512
+ declare function createShardBackend(reader: ShardReader, options?: ShardBackendOptions): DataBackend;
2513
+ declare const provenanceGraph: z.ZodObject<{
2514
+ all_activities: z.ZodArray<z.ZodObject<{
2515
+ activity_type: z.ZodString;
2516
+ ended_at: z.ZodNullable<z.ZodString>;
2517
+ id: z.ZodEffects<z.ZodString, string, string>;
2518
+ metadata: z.ZodEffects<z.ZodUnknown, {} | null, unknown>;
2519
+ model_name: z.ZodNullable<z.ZodString>;
2520
+ note_id: z.ZodEffects<z.ZodString, string, string>;
2521
+ revision_id: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
2522
+ started_at: z.ZodString;
2523
+ }, "strip", z.ZodTypeAny, {
2524
+ activity_type: string;
2525
+ ended_at: null | string;
2526
+ id: string;
2527
+ metadata: {} | null;
2528
+ model_name: null | string;
2529
+ note_id: string;
2530
+ revision_id: null | string;
2531
+ started_at: string;
2532
+ }, {
2533
+ activity_type: string;
2534
+ ended_at: null | string;
2535
+ id: string;
2536
+ metadata?: unknown;
2537
+ model_name: null | string;
2538
+ note_id: string;
2539
+ revision_id: null | string;
2540
+ started_at: string;
2541
+ }>, "many">;
2542
+ all_edges: z.ZodArray<z.ZodObject<{
2543
+ created_at_utc: z.ZodString;
2544
+ id: z.ZodEffects<z.ZodString, string, string>;
2545
+ relation: z.ZodString;
2546
+ revision_id: z.ZodEffects<z.ZodString, string, string>;
2547
+ source_note_id: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
2548
+ source_url: z.ZodNullable<z.ZodString>;
2549
+ }, "strip", z.ZodTypeAny, {
2550
+ created_at_utc: string;
2551
+ id: string;
2552
+ relation: string;
2553
+ revision_id: string;
2554
+ source_note_id: null | string;
2555
+ source_url: null | string;
2556
+ }, {
2557
+ created_at_utc: string;
2558
+ id: string;
2559
+ relation: string;
2560
+ revision_id: string;
2561
+ source_note_id: null | string;
2562
+ source_url: null | string;
2563
+ }>, "many">;
2564
+ current_chain: z.ZodNullable<z.ZodObject<{
2565
+ activity: z.ZodNullable<z.ZodObject<{
2566
+ activity_type: z.ZodString;
2567
+ ended_at: z.ZodNullable<z.ZodString>;
2568
+ id: z.ZodEffects<z.ZodString, string, string>;
2569
+ metadata: z.ZodEffects<z.ZodUnknown, {} | null, unknown>;
2570
+ model_name: z.ZodNullable<z.ZodString>;
2571
+ note_id: z.ZodEffects<z.ZodString, string, string>;
2572
+ revision_id: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
2573
+ started_at: z.ZodString;
2574
+ }, "strip", z.ZodTypeAny, {
2575
+ activity_type: string;
2576
+ ended_at: null | string;
2577
+ id: string;
2578
+ metadata: {} | null;
2579
+ model_name: null | string;
2580
+ note_id: string;
2581
+ revision_id: null | string;
2582
+ started_at: string;
2583
+ }, {
2584
+ activity_type: string;
2585
+ ended_at: null | string;
2586
+ id: string;
2587
+ metadata?: unknown;
2588
+ model_name: null | string;
2589
+ note_id: string;
2590
+ revision_id: null | string;
2591
+ started_at: string;
2592
+ }>>;
2593
+ edges: z.ZodArray<z.ZodObject<{
2594
+ created_at_utc: z.ZodString;
2595
+ id: z.ZodEffects<z.ZodString, string, string>;
2596
+ relation: z.ZodString;
2597
+ revision_id: z.ZodEffects<z.ZodString, string, string>;
2598
+ source_note_id: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
2599
+ source_url: z.ZodNullable<z.ZodString>;
2600
+ }, "strip", z.ZodTypeAny, {
2601
+ created_at_utc: string;
2602
+ id: string;
2603
+ relation: string;
2604
+ revision_id: string;
2605
+ source_note_id: null | string;
2606
+ source_url: null | string;
2607
+ }, {
2608
+ created_at_utc: string;
2609
+ id: string;
2610
+ relation: string;
2611
+ revision_id: string;
2612
+ source_note_id: null | string;
2613
+ source_url: null | string;
2614
+ }>, "many">;
2615
+ note_id: z.ZodEffects<z.ZodString, string, string>;
2616
+ revision_id: z.ZodEffects<z.ZodString, string, string>;
2617
+ }, "strip", z.ZodTypeAny, {
2618
+ activity: {
2619
+ activity_type: string;
2620
+ ended_at: null | string;
2621
+ id: string;
2622
+ metadata: {} | null;
2623
+ model_name: null | string;
2624
+ note_id: string;
2625
+ revision_id: null | string;
2626
+ started_at: string;
2627
+ } | null;
2628
+ edges: {
2629
+ created_at_utc: string;
2630
+ id: string;
2631
+ relation: string;
2632
+ revision_id: string;
2633
+ source_note_id: null | string;
2634
+ source_url: null | string;
2635
+ }[];
2636
+ note_id: string;
2637
+ revision_id: string;
2638
+ }, {
2639
+ activity: {
2640
+ activity_type: string;
2641
+ ended_at: null | string;
2642
+ id: string;
2643
+ metadata?: unknown;
2644
+ model_name: null | string;
2645
+ note_id: string;
2646
+ revision_id: null | string;
2647
+ started_at: string;
2648
+ } | null;
2649
+ edges: {
2650
+ created_at_utc: string;
2651
+ id: string;
2652
+ relation: string;
2653
+ revision_id: string;
2654
+ source_note_id: null | string;
2655
+ source_url: null | string;
2656
+ }[];
2657
+ note_id: string;
2658
+ revision_id: string;
2659
+ }>>;
2660
+ derived_count: z.ZodNumber;
2661
+ derived_notes: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
2662
+ note_id: z.ZodEffects<z.ZodString, string, string>;
2663
+ }, "strip", z.ZodTypeAny, {
2664
+ all_activities: {
2665
+ activity_type: string;
2666
+ ended_at: null | string;
2667
+ id: string;
2668
+ metadata: {} | null;
2669
+ model_name: null | string;
2670
+ note_id: string;
2671
+ revision_id: null | string;
2672
+ started_at: string;
2673
+ }[];
2674
+ all_edges: {
2675
+ created_at_utc: string;
2676
+ id: string;
2677
+ relation: string;
2678
+ revision_id: string;
2679
+ source_note_id: null | string;
2680
+ source_url: null | string;
2681
+ }[];
2682
+ current_chain: {
2683
+ activity: {
2684
+ activity_type: string;
2685
+ ended_at: null | string;
2686
+ id: string;
2687
+ metadata: {} | null;
2688
+ model_name: null | string;
2689
+ note_id: string;
2690
+ revision_id: null | string;
2691
+ started_at: string;
2692
+ } | null;
2693
+ edges: {
2694
+ created_at_utc: string;
2695
+ id: string;
2696
+ relation: string;
2697
+ revision_id: string;
2698
+ source_note_id: null | string;
2699
+ source_url: null | string;
2700
+ }[];
2701
+ note_id: string;
2702
+ revision_id: string;
2703
+ } | null;
2704
+ derived_count: number;
2705
+ derived_notes: string[];
2706
+ note_id: string;
2707
+ }, {
2708
+ all_activities: {
2709
+ activity_type: string;
2710
+ ended_at: null | string;
2711
+ id: string;
2712
+ metadata?: unknown;
2713
+ model_name: null | string;
2714
+ note_id: string;
2715
+ revision_id: null | string;
2716
+ started_at: string;
2717
+ }[];
2718
+ all_edges: {
2719
+ created_at_utc: string;
2720
+ id: string;
2721
+ relation: string;
2722
+ revision_id: string;
2723
+ source_note_id: null | string;
2724
+ source_url: null | string;
2725
+ }[];
2726
+ current_chain: {
2727
+ activity: {
2728
+ activity_type: string;
2729
+ ended_at: null | string;
2730
+ id: string;
2731
+ metadata?: unknown;
2732
+ model_name: null | string;
2733
+ note_id: string;
2734
+ revision_id: null | string;
2735
+ started_at: string;
2736
+ } | null;
2737
+ edges: {
2738
+ created_at_utc: string;
2739
+ id: string;
2740
+ relation: string;
2741
+ revision_id: string;
2742
+ source_note_id: null | string;
2743
+ source_url: null | string;
2744
+ }[];
2745
+ note_id: string;
2746
+ revision_id: string;
2747
+ } | null;
2748
+ derived_count: number;
2749
+ derived_notes: string[];
2750
+ note_id: string;
2540
2751
  }>;
2541
- interface SWRegistrationResult {
2542
- registered: boolean;
2543
- registration?: ServiceWorkerRegistration;
2544
- error?: string;
2545
- }
2546
- declare function registerServiceWorker(swUrl?: string): Promise<SWRegistrationResult>;
2547
- /**
2548
- * REST route definitions for Service Worker.
2549
- * These are pure functions that transform HTTP Request → tool input and tool output → Response.
2550
- * The actual DB connection is injected at registration time.
2551
- *
2552
- * All routes currently return 503 Not Implemented — the DB wiring happens in a later issue.
2553
- * The URL structure and request/response shapes are the valuable contract defined here.
2554
- */
2555
- interface RouteHandler {
2556
- method: string;
2557
- pattern: RegExp;
2558
- handler: (request: Request, match: RegExpMatchArray, params: URLSearchParams) => Promise<Response>;
2559
- }
2560
- /**
2561
- * Create route handlers.
2562
- * db parameter will be injected when the SW gets access to PGlite.
2563
- * For now, returns 503 Not Implemented for all routes.
2564
- */
2565
- declare function createRoutes(): RouteHandler[];
2566
- /**
2567
- * Match a request against the registered routes and return the first matching
2568
- * handler, or null if no route matches.
2569
- */
2570
- declare function matchRoute(routes: RouteHandler[], request: Request, url: URL): null | RouteHandler;
2571
- /**
2572
- * One-shot migration of the pre-bytecask blob layout into the new store.
2573
- *
2574
- * The legacy layout (shipped through v2026.7.x) was:
2575
- * - IndexedDB: database `fortemi-<archive>-blobs`, object store `blobs`,
2576
- * values keyed by the full checksum string (`blake3:<hex>`, historically
2577
- * also `sha256:<hex>`).
2578
- * - OPFS: directory `fortemi-<archive>-blobs/<h0h1>/<h2h3>/<checksum>`.
2579
- *
2580
- * Migration re-`put()`s every payload — the new store recomputes BLAKE3, so
2581
- * legacy `sha256:`-keyed entries converge to canonical keys for free
2582
- * (ADR-012 D3). The legacy source is deleted only after every entry migrated
2583
- * without error; any failure leaves it untouched for the next attempt.
2584
- */
2585
- /** Outcome of one migration attempt (for diagnostics/logging). */
2586
- interface LegacyMigrationReport {
2587
- migrated: number;
2588
- /** Migration aborted without deleting the legacy source. */
2589
- failed: boolean;
2590
- }
2591
- /**
2592
- * Migrate any legacy blob layout for `archiveName` into `target`, then delete
2593
- * the legacy source. Failures are contained: the legacy data stays in place
2594
- * and the new store keeps whatever was already re-put (idempotent on retry).
2595
- */
2596
- declare function migrateLegacyBlobStore(archiveName: string, target: BlobStore, indexedDbFactory?: IDBFactory): Promise<LegacyMigrationReport>;
2752
+ /** Producer field names intentionally distinguish this graph from local PGlite PROV edges. */
2753
+ type RemoteProvenanceGraph = z.infer<typeof provenanceGraph>;
2754
+ declare const searchMode: z.ZodEnum<[
2755
+ "fts",
2756
+ "semantic",
2757
+ "hybrid"
2758
+ ]>;
2759
+ type RemoteSearchMode = z.infer<typeof searchMode>;
2760
+ declare const searchHit: z.ZodEffects<z.ZodObject<{
2761
+ chain_info: z.ZodOptional<z.ZodObject<{
2762
+ best_chunk_sequence: z.ZodNumber;
2763
+ chain_id: z.ZodEffects<z.ZodString, string, string>;
2764
+ chunks_matched: z.ZodNumber;
2765
+ original_title: z.ZodString;
2766
+ total_chunks: z.ZodNumber;
2767
+ }, "strip", z.ZodTypeAny, {
2768
+ best_chunk_sequence: number;
2769
+ chain_id: string;
2770
+ chunks_matched: number;
2771
+ original_title: string;
2772
+ total_chunks: number;
2773
+ }, {
2774
+ best_chunk_sequence: number;
2775
+ chain_id: string;
2776
+ chunks_matched: number;
2777
+ original_title: string;
2778
+ total_chunks: number;
2779
+ }>>;
2780
+ embedding_status: z.ZodOptional<z.ZodEnum<[
2781
+ "ready",
2782
+ "pending",
2783
+ "failed",
2784
+ "none"
2785
+ ]>>;
2786
+ evidence: z.ZodOptional<z.ZodUnknown>;
2787
+ note_id: z.ZodEffects<z.ZodString, string, string>;
2788
+ score: z.ZodNumber;
2789
+ snippet: z.ZodNullable<z.ZodString>;
2790
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2791
+ title: z.ZodOptional<z.ZodString>;
2792
+ }, "strip", z.ZodTypeAny, {
2793
+ chain_info?: {
2794
+ best_chunk_sequence: number;
2795
+ chain_id: string;
2796
+ chunks_matched: number;
2797
+ original_title: string;
2798
+ total_chunks: number;
2799
+ } | undefined;
2800
+ embedding_status?: "failed" | "none" | "pending" | "ready" | undefined;
2801
+ evidence?: unknown;
2802
+ note_id: string;
2803
+ score: number;
2804
+ snippet: null | string;
2805
+ tags?: string[] | undefined;
2806
+ title?: string | undefined;
2807
+ }, {
2808
+ chain_info?: {
2809
+ best_chunk_sequence: number;
2810
+ chain_id: string;
2811
+ chunks_matched: number;
2812
+ original_title: string;
2813
+ total_chunks: number;
2814
+ } | undefined;
2815
+ embedding_status?: "failed" | "none" | "pending" | "ready" | undefined;
2816
+ evidence?: unknown;
2817
+ note_id: string;
2818
+ score: number;
2819
+ snippet: null | string;
2820
+ tags?: string[] | undefined;
2821
+ title?: string | undefined;
2822
+ }>, {
2823
+ chain_info?: {
2824
+ best_chunk_sequence: number;
2825
+ chain_id: string;
2826
+ chunks_matched: number;
2827
+ original_title: string;
2828
+ total_chunks: number;
2829
+ } | undefined;
2830
+ embedding_status?: "failed" | "none" | "pending" | "ready" | undefined;
2831
+ evidence?: SearchEvidenceSet | undefined;
2832
+ note_id: string;
2833
+ score: number;
2834
+ snippet: null | string;
2835
+ tags?: string[] | undefined;
2836
+ title?: string | undefined;
2837
+ }, {
2838
+ chain_info?: {
2839
+ best_chunk_sequence: number;
2840
+ chain_id: string;
2841
+ chunks_matched: number;
2842
+ original_title: string;
2843
+ total_chunks: number;
2844
+ } | undefined;
2845
+ embedding_status?: "failed" | "none" | "pending" | "ready" | undefined;
2846
+ evidence?: unknown;
2847
+ note_id: string;
2848
+ score: number;
2849
+ snippet: null | string;
2850
+ tags?: string[] | undefined;
2851
+ title?: string | undefined;
2852
+ }>;
2853
+ declare const searchDegradation: z.ZodObject<{
2854
+ code: z.ZodString;
2855
+ effective_mode: z.ZodLiteral<"fts">;
2856
+ }, "strip", z.ZodTypeAny, {
2857
+ code: string;
2858
+ effective_mode: "fts";
2859
+ }, {
2860
+ code: string;
2861
+ effective_mode: "fts";
2862
+ }>;
2863
+ type RemoteSearchDegradation = z.infer<typeof searchDegradation>;
2864
+ type RemoteSearchMetadata = Pick<z.infer<typeof searchHit>, 'chain_info' | 'embedding_status' | 'tags' | 'title'>;
2865
+ declare const manageInput: z.ZodUnion<[
2866
+ z.ZodObject<{
2867
+ action: z.ZodLiteral<"create">;
2868
+ content: z.ZodString;
2869
+ source: z.ZodOptional<z.ZodString>;
2870
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2871
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2872
+ }, "strict", z.ZodTypeAny, {
2873
+ action: "create";
2874
+ content: string;
2875
+ source?: string | undefined;
2876
+ tags?: string[] | undefined;
2877
+ title?: null | string | undefined;
2878
+ }, {
2879
+ action: "create";
2880
+ content: string;
2881
+ source?: string | undefined;
2882
+ tags?: string[] | undefined;
2883
+ title?: null | string | undefined;
2884
+ }>,
2885
+ z.ZodEffects<z.ZodObject<{
2886
+ action: z.ZodLiteral<"update">;
2887
+ content: z.ZodOptional<z.ZodString>;
2888
+ note_id: z.ZodEffects<z.ZodString, string, string>;
2889
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2890
+ }, "strict", z.ZodTypeAny, {
2891
+ action: "update";
2892
+ content?: string | undefined;
2893
+ note_id: string;
2894
+ tags?: string[] | undefined;
2895
+ }, {
2896
+ action: "update";
2897
+ content?: string | undefined;
2898
+ note_id: string;
2899
+ tags?: string[] | undefined;
2900
+ }>, {
2901
+ action: "update";
2902
+ content?: string | undefined;
2903
+ note_id: string;
2904
+ tags?: string[] | undefined;
2905
+ }, {
2906
+ action: "update";
2907
+ content?: string | undefined;
2908
+ note_id: string;
2909
+ tags?: string[] | undefined;
2910
+ }>,
2911
+ z.ZodObject<{
2912
+ action: z.ZodEnum<[
2913
+ "delete",
2914
+ "restore",
2915
+ "archive",
2916
+ "unarchive",
2917
+ "star",
2918
+ "unstar"
2919
+ ]>;
2920
+ note_id: z.ZodEffects<z.ZodString, string, string>;
2921
+ }, "strict", z.ZodTypeAny, {
2922
+ action: "archive" | "delete" | "restore" | "star" | "unarchive" | "unstar";
2923
+ note_id: string;
2924
+ }, {
2925
+ action: "archive" | "delete" | "restore" | "star" | "unarchive" | "unstar";
2926
+ note_id: string;
2927
+ }>
2928
+ ]>;
2929
+ type RemoteManageNoteInput = z.infer<typeof manageInput>;
2597
2930
  /**
2598
- * Shared postMessage protocol types for the PGlite worker.
2599
- *
2600
- * WorkerRequest — messages sent from the client to the worker.
2601
- * WorkerResponse — messages sent from the worker back to the client.
2931
+ * Capability module system (ADR-002).
2932
+ * Tracks opt-in WASM module states. No WASM loaded by default (CAP-001).
2602
2933
  *
2603
- * Every request carries a unique `id` that the worker echoes in its response,
2604
- * allowing the client to correlate replies with pending promises.
2605
- * The READY broadcast is the only message without an `id` — it is sent once
2606
- * on startup before any requests are processed.
2934
+ * State machine (valid transitions):
2935
+ * unloaded -> loading (via enable)
2936
+ * loading -> ready (via markReady or successful loader)
2937
+ * loading -> error (via markError or failed loader)
2938
+ * ready -> disabled (via disable)
2939
+ * disabled -> loading (via enable, re-enable)
2940
+ * error -> loading (via enable, retry)
2607
2941
  */
2608
- /** Messages from client to worker */
2609
- type WorkerRequest = {
2610
- id: string;
2611
- isolationLevel?: string;
2612
- type: 'BEGIN';
2613
- } | {
2614
- id: string;
2615
- params?: unknown[];
2616
- sql: string;
2617
- txId: string;
2618
- type: 'TX_QUERY';
2619
- } | {
2620
- id: string;
2621
- params?: unknown[];
2622
- sql: string;
2623
- type: 'QUERY';
2624
- } | {
2625
- id: string;
2626
- sql: string;
2627
- txId: string;
2628
- type: 'TX_EXEC';
2629
- } | {
2630
- id: string;
2631
- sql: string;
2632
- type: 'EXEC';
2633
- } | {
2634
- id: string;
2635
- txId: string;
2636
- type: 'COMMIT';
2637
- } | {
2638
- id: string;
2639
- txId: string;
2640
- type: 'ROLLBACK';
2641
- } | {
2642
- id: string;
2643
- type: 'CLOSE';
2644
- } | {
2645
- id: string;
2646
- type: 'PING';
2647
- };
2648
- /** Messages from worker to client */
2649
- type WorkerResponse = {
2650
- affectedRows?: number;
2651
- id: string;
2652
- type: 'EXEC_DONE';
2653
- } | {
2654
- error: string;
2655
- id: string;
2656
- type: 'ERROR';
2657
- } | {
2658
- fields?: Array<{
2659
- dataTypeID: number;
2660
- name: string;
2661
- }>;
2662
- id: string;
2663
- rows: unknown[];
2664
- type: 'RESULT';
2665
- } | {
2666
- id: string;
2667
- txId: string;
2668
- type: 'TX_STARTED';
2669
- } | {
2670
- id: string;
2671
- type: 'PONG';
2672
- } | {
2673
- id: string;
2674
- type: 'TX_DONE';
2675
- } | {
2676
- type: 'READY';
2677
- };
2678
- type JsonObject = Record<string, unknown>;
2679
- interface NativeEmbeddingConfig {
2680
- id: string;
2681
- name: string;
2682
- description: null | string;
2683
- model: string;
2684
- dimension: number;
2685
- chunk_size: number;
2686
- chunk_overlap: number;
2687
- hnsw_m: null | number;
2688
- hnsw_ef_construction: null | number;
2689
- ivfflat_lists: null | number;
2690
- is_default: boolean | null;
2691
- supports_mrl: boolean | null;
2692
- matryoshka_dims: null | number[];
2693
- default_truncate_dim: null | number;
2694
- provider: null | string;
2695
- provider_config: JsonObject | null;
2696
- content_types: null | string[];
2697
- strengths: null | string[];
2698
- limitations: null | string[];
2699
- recommended_for: null | string[];
2700
- benchmark_scores: JsonObject | null;
2701
- is_available: boolean | null;
2702
- document_composition: JsonObject;
2703
- created_at: string;
2704
- updated_at: string;
2942
+ type CapabilityState = 'disabled' | 'error' | 'loading' | 'ready' | 'unloaded';
2943
+ type CapabilityName = 'audio' | 'llm' | 'pdf' | 'semantic' | 'vision';
2944
+ declare class CapabilityManager {
2945
+ private events;
2946
+ private capabilities;
2947
+ private loaders;
2948
+ private progressMessages;
2949
+ constructor(events: TypedEventBus);
2950
+ /**
2951
+ * Register an async loader for a capability.
2952
+ * Called by enable(); if no loader is registered the capability transitions
2953
+ * directly to ready (useful for capabilities that require no async init).
2954
+ */
2955
+ registerLoader(name: CapabilityName, loader: () => Promise<void>): void;
2956
+ getState(name: CapabilityName): CapabilityState;
2957
+ isReady(name: CapabilityName): boolean;
2958
+ /**
2959
+ * Enable a capability.
2960
+ * Valid from: unloaded, disabled, error (retry).
2961
+ * Runs the registered loader if present; transitions to ready on success,
2962
+ * error on failure.
2963
+ */
2964
+ enable(name: CapabilityName): Promise<void>;
2965
+ /**
2966
+ * Disable a ready capability.
2967
+ * Valid from: ready only.
2968
+ */
2969
+ disable(name: CapabilityName): void;
2970
+ /**
2971
+ * Mark a loading capability as ready (external use, e.g. bridge protocol).
2972
+ * Valid from: loading only.
2973
+ */
2974
+ markReady(name: CapabilityName): void;
2975
+ /**
2976
+ * Mark a loading capability as errored (external use, e.g. bridge protocol).
2977
+ * Valid from: loading only.
2978
+ */
2979
+ markError(name: CapabilityName, error: string): void;
2980
+ /**
2981
+ * Report loading progress (0-100).
2982
+ * Emits capability.loading with progress if the capability is currently loading.
2983
+ * No-op if the capability is not in loading state.
2984
+ */
2985
+ reportProgress(name: CapabilityName, progress: number): void;
2986
+ /** Set a human-readable progress message for a loading capability */
2987
+ setProgress(name: CapabilityName, message: string): void;
2988
+ /** Get the current progress message for a capability */
2989
+ getProgress(name: CapabilityName): string | undefined;
2990
+ getError(name: CapabilityName): string | undefined;
2991
+ listAll(): Array<{
2992
+ name: CapabilityName;
2993
+ state: CapabilityState;
2994
+ }>;
2705
2995
  }
2706
- interface NativeEmbeddingSet {
2707
- id: string;
2996
+ /**
2997
+ * Sequential SQL migration runner for DatabaseClient.
2998
+ * Tracks applied migrations in a schema_version table.
2999
+ * Each migration runs in a transaction; version updated atomically.
3000
+ */
3001
+ interface Migration {
3002
+ version: number;
2708
3003
  name: string;
2709
- slug: null | string;
2710
- description: null | string;
2711
- purpose: null | string;
2712
- usage_hints: null | string;
2713
- keywords: null | string[];
2714
- set_type: 'filter' | 'full';
2715
- mode: 'auto' | 'manual' | 'mixed' | null;
2716
- criteria: JsonObject | null;
2717
- embedding_config_id: null | string;
2718
- truncate_dim: null | number;
2719
- auto_embed_rules: JsonObject | null;
2720
- index_status: string;
2721
- index_type: null | string;
2722
- last_indexed_at: null | string;
2723
- document_count: null | number;
2724
- embedding_count: null | number;
2725
- embeddings_current: boolean | null;
2726
- index_size_bytes: null | number;
2727
- is_system: boolean | null;
2728
- is_active: boolean | null;
2729
- auto_refresh: boolean | null;
2730
- refresh_interval: null | string;
2731
- last_refresh_at: null | string;
2732
- agent_metadata: JsonObject | null;
2733
- created_at: string;
2734
- updated_at: string;
2735
- created_by: null | string;
3004
+ sql: string;
2736
3005
  }
2737
- interface NativeEmbeddingMember {
2738
- embedding_set_id: string;
2739
- note_id: string;
2740
- membership_type: null | string;
2741
- added_at: null | string;
2742
- added_by: null | string;
3006
+ declare class MigrationRunner {
3007
+ private db;
3008
+ private events?;
3009
+ constructor(db: DatabaseClient, events?: TypedEventBus | undefined);
3010
+ ensureSchemaTable(): Promise<void>;
3011
+ getCurrentVersion(): Promise<number>;
3012
+ apply(migrations: Migration[]): Promise<number>;
3013
+ getAppliedMigrations(): Promise<Array<{
3014
+ name: string;
3015
+ version: number;
3016
+ }>>;
2743
3017
  }
3018
+ declare const allMigrations: Migration[];
2744
3019
  /**
2745
- * EmbeddingSetsRepository - named, filter, and virtual embedding set API.
3020
+ * Multi-archive manager for Fortemi.
3021
+ * Each archive is a separate PGlite instance with its own persistence path.
3022
+ * Migrations are applied automatically on open.
2746
3023
  */
2747
- type EmbeddingSetKind = 'filter' | 'physical' | 'virtual';
2748
- type EmbeddingSetMode = 'auto' | 'manual' | 'mixed';
2749
- interface EmbeddingSetCriteria {
2750
- query?: string;
2751
- tags?: string[];
2752
- collectionIds?: string[];
2753
- conceptIds?: string[];
2754
- noteIds?: string[];
2755
- sources?: string[];
2756
- formats?: string[];
2757
- visibilities?: string[];
2758
- isStarred?: boolean;
2759
- isArchived?: boolean;
2760
- hasTitle?: boolean;
2761
- hasEmbedding?: boolean;
2762
- isUserEdited?: boolean;
2763
- hasAiMetadata?: boolean;
2764
- hasRevisions?: boolean;
2765
- minGenerationCount?: number;
2766
- maxGenerationCount?: number;
2767
- updatedAfter?: string;
2768
- updatedBefore?: string;
2769
- }
2770
- interface EmbeddingSetFreshness {
2771
- status: 'fresh' | 'stale' | 'unknown';
2772
- sourceHash?: string;
2773
- checkedAt?: string;
2774
- reason?: string;
2775
- }
2776
- interface EmbeddingCompatibilityPolicy {
2777
- model: 'allow-compatible-family' | 'require-same';
2778
- dimension: 'allow-truncation' | 'require-same';
2779
- duplicateVectors: 'error' | 'prefer-latest' | 'prefer-set-order';
2780
- missingVectors: 'error' | 'include-unembedded-note' | 'omit';
2781
- }
2782
- interface VirtualMaterializationPolicy {
2783
- allowed: boolean;
2784
- includeResolvedMembers?: boolean;
2785
- includeResolvedEdges?: boolean;
2786
- freshness: 'fresh' | 'stale' | 'unknown';
2787
- inputHash?: string;
2788
- generatedAt?: string;
2789
- resolvedMemberCount?: number;
2790
- }
2791
- interface CriteriaVirtualSource {
2792
- type: 'criteria';
2793
- baseSetId: string;
2794
- criteria: EmbeddingSetCriteria;
2795
- }
2796
- interface SetOperationVirtualSource {
2797
- type: 'set-operation';
2798
- operation: 'difference' | 'intersection' | 'union';
2799
- setIds: string[];
2800
- }
2801
- interface FallbackVirtualSource {
2802
- type: 'fallback';
2803
- preferredSetIds: string[];
2804
- }
2805
- interface LatestCompatibleVirtualSource {
2806
- type: 'latest-compatible';
2807
- candidateSetIds: string[];
2808
- model?: string;
2809
- dimension?: number;
2810
- }
2811
- interface SnapshotVirtualSource {
2812
- type: 'snapshot';
2813
- snapshotId: string;
2814
- sourceDefinitionId: string;
2815
- generatedAt: string;
2816
- inputHash: string;
2817
- }
2818
- type VirtualEmbeddingSetSource = CriteriaVirtualSource | FallbackVirtualSource | LatestCompatibleVirtualSource | SetOperationVirtualSource | SnapshotVirtualSource;
2819
- interface VirtualEmbeddingSetDefinition {
2820
- id: string;
3024
+ interface ArchiveInfo {
2821
3025
  name: string;
2822
- purpose?: null | string;
2823
- source: VirtualEmbeddingSetSource;
2824
- compatibility: EmbeddingCompatibilityPolicy;
2825
- materialization?: VirtualMaterializationPolicy;
2826
- createdAt?: string;
2827
- updatedAt?: string;
2828
- }
2829
- interface EmbeddingSetSelector {
2830
- kind: 'default' | 'embedding-set' | 'virtual-definition';
2831
- embeddingSetId?: string;
2832
- definition?: VirtualEmbeddingSetDefinition;
3026
+ createdAt: string;
2833
3027
  }
2834
- interface EmbeddingSetDescriptor {
2835
- id: string;
2836
- name: string;
2837
- purpose?: null | string;
2838
- kind: EmbeddingSetKind;
2839
- mode?: EmbeddingSetMode;
2840
- model?: string;
2841
- dimension?: number;
2842
- truncateDimension?: null | number;
2843
- criteria?: EmbeddingSetCriteria | null;
2844
- createdAt?: string;
2845
- updatedAt?: string;
2846
- freshness?: EmbeddingSetFreshness;
3028
+ declare class ArchiveManager {
3029
+ private events?;
3030
+ private currentArchive;
3031
+ private db;
3032
+ private archives;
3033
+ private persistence;
3034
+ private backendFactory;
3035
+ /**
3036
+ * Persistence is a PLUGGABLE, opt-in backend (issue #261). Pass a
3037
+ * `StorageBackendFactory` to run against any `StorageBackend`
3038
+ * implementation; PGlite is merely the built-in default, selected only when
3039
+ * the convenience `PersistenceMode` string form is used. Because
3040
+ * `defaultStorageBackendFactory` reaches PGlite through the lazily-imported
3041
+ * `createPGliteInstance` (see `db.ts`), a consumer that supplies its own
3042
+ * factory — or never opens an archive at all — never pulls the PGlite WASM
3043
+ * engine into its bundle.
3044
+ *
3045
+ * @param persistenceOrFactory `PersistenceMode` string (uses the built-in
3046
+ * PGlite backend) OR a custom `StorageBackendFactory`.
3047
+ * @param persistenceOverride persistence hint passed to a custom factory.
3048
+ */
3049
+ constructor(persistenceOrFactory: PersistenceMode | StorageBackendFactory, events?: TypedEventBus | undefined, persistenceOverride?: PersistenceMode);
3050
+ getCurrentArchiveName(): string;
3051
+ getDb(): null | StorageBackend;
3052
+ open(archiveName?: string): Promise<StorageBackend>;
3053
+ /**
3054
+ * Adopt an already-created backend WITHOUT running migrations — for a backend
3055
+ * whose schema is already present, e.g. a PGlite restored from a physical
3056
+ * data-dir snapshot (issue #187, `restoreDbSnapshot`). Running migrations here
3057
+ * would be wrong: the restored dir already carries them (and the HNSW index).
3058
+ */
3059
+ adopt(backend: StorageBackend, archiveName?: string): Promise<StorageBackend>;
3060
+ create(archiveName: string): Promise<StorageBackend>;
3061
+ switchTo(archiveName: string): Promise<StorageBackend>;
3062
+ delete(archiveName: string): Promise<void>;
3063
+ listArchives(): ArchiveInfo[];
3064
+ close(): Promise<void>;
2847
3065
  }
2848
- type VirtualEmbeddingSetValidationError = {
2849
- code: 'duplicate-vector';
2850
- noteId: string;
2851
- setIds: string[];
2852
- } | {
2853
- code: 'missing-vector';
2854
- noteId: string;
2855
- setId: string;
2856
- } | {
2857
- code: 'mixed-dimensions';
2858
- setIds: string[];
2859
- } | {
2860
- code: 'mixed-models';
2861
- setIds: string[];
2862
- } | {
2863
- code: 'stale-snapshot';
2864
- snapshotId: string;
2865
- } | {
2866
- code: 'unsupported-criteria';
2867
- field: string;
2868
- };
2869
- interface ResolvedEmbeddingRow {
2870
- note_id: string;
2871
- embedding_set_id: string;
2872
- embedding_id: string;
2873
- vector: string;
2874
- created_at: Date | null;
3066
+ /**
3067
+ * Factory function for creating a FortemiCore instance.
3068
+ * All deployment modes use this entry point.
3069
+ */
3070
+ interface FortemiConfig {
3071
+ persistence: 'idb' | 'memory' | 'opfs';
3072
+ archiveName?: string;
2875
3073
  }
2876
- interface ResolvedEmbeddingSet {
2877
- selector: EmbeddingSetSelector;
2878
- rows: ResolvedEmbeddingRow[];
2879
- noteIds: string[];
2880
- embeddingIds: string[];
2881
- errors: VirtualEmbeddingSetValidationError[];
2882
- freshness: EmbeddingSetFreshness;
2883
- resolutionSource: 'live' | 'materialized';
3074
+ interface FortemiCore {
3075
+ events: TypedEventBus;
3076
+ config: FortemiConfig;
3077
+ destroy(): void;
2884
3078
  }
2885
- interface EmbeddingConfigRow extends Omit<NativeEmbeddingConfig, 'created_at' | 'updated_at'> {
2886
- created_at: Date;
2887
- updated_at: Date;
3079
+ declare function createFortemi(config: FortemiConfig): FortemiCore;
3080
+ /**
3081
+ * Compute a browser-local content-identity hash (SHA-256), encoded as
3082
+ * `sha256:<64-char lowercase hex>`.
3083
+ *
3084
+ * This is an internal identity/dedup digest used for note content, embedding
3085
+ * configs, the AIWG index, and graph identity — NOT the server's attachment
3086
+ * content-hash convention. Binary-attachment blobs use {@link computeBlobHash}
3087
+ * (BLAKE3), which is the canonical checksum defined by the binary-attachment
3088
+ * projection contract (`checksum: "blake3:<hex>"`). Keeping these two functions
3089
+ * separate preserves JSON format parity for the identity hashes above while
3090
+ * letting attachments match the server's `compute_content_hash`.
3091
+ *
3092
+ * @param data - Raw bytes to hash
3093
+ * @returns `'sha256:<64-char lowercase hex>'`
3094
+ */
3095
+ declare function computeHash(data: Uint8Array): string;
3096
+ /**
3097
+ * Compute the canonical attachment content hash: **BLAKE3**, encoded as
3098
+ * `blake3:<64-char lowercase hex>`.
3099
+ *
3100
+ * Matches the fortemi server (`crates/matric-db/src/file_storage.rs`
3101
+ * `compute_content_hash`) and the portable Knowledge-Shard byte-sidecar
3102
+ * contract, where the sidecar tar entry name is the bare hex (the `blake3:`
3103
+ * prefix stripped). SubtleCrypto has no BLAKE3, so this uses `@noble/hashes`.
3104
+ *
3105
+ * @param data - Raw attachment bytes to hash
3106
+ * @returns `'blake3:<64-char lowercase hex>'`
3107
+ */
3108
+ declare function computeBlobHash(data: Uint8Array): string;
3109
+ declare const FORTEMI_COMPATIBILITY_PATH = "/api/v1/system/compatibility";
3110
+ declare const FORTEMI_SERVER_COMPATIBILITY_REVISION = "2026-07-06";
3111
+ declare const FORTEMI_COMPATIBILITY_STATES: readonly [
3112
+ "available",
3113
+ "degraded",
3114
+ "preview",
3115
+ "unavailable",
3116
+ "unknown"
3117
+ ];
3118
+ type FortemiCompatibilityState = (typeof FORTEMI_COMPATIBILITY_STATES)[number];
3119
+ declare const FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES: readonly [
3120
+ "core_notes",
3121
+ "search",
3122
+ "jobs",
3123
+ "realtime_activity",
3124
+ "hosted_auth",
3125
+ "premium_components",
3126
+ "backoffice_api",
3127
+ "audit_posture",
3128
+ "quota_status",
3129
+ "kms_status",
3130
+ "mcp_scope_gate"
3131
+ ];
3132
+ type FortemiRequiredCompatibilityCapability = (typeof FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES)[number];
3133
+ interface FortemiCompatibilityCapability {
3134
+ state: FortemiCompatibilityState;
3135
+ reason_code?: string;
2888
3136
  }
2889
- interface EmbeddingMemberRow extends Omit<NativeEmbeddingMember, 'added_at'> {
2890
- embedding_id: null | string;
2891
- added_at: Date | null;
3137
+ interface FortemiCompatibilityResponse {
3138
+ schema_version: number;
3139
+ contract_revision: string;
3140
+ api: {
3141
+ build_date_present: boolean;
3142
+ git_sha_present: boolean;
3143
+ minimum_hotm_enterprise_client: string;
3144
+ name: string;
3145
+ version: string;
3146
+ };
3147
+ deployment: {
3148
+ edition: string;
3149
+ hosted_multi_tenant_ready: boolean;
3150
+ mode: string;
3151
+ };
3152
+ auth: {
3153
+ mode: string;
3154
+ oauth_issuer_configured: boolean;
3155
+ required: boolean;
3156
+ tenant_context_available: boolean;
3157
+ };
3158
+ capabilities: Record<string, FortemiCompatibilityCapability>;
3159
+ links: {
3160
+ asyncapi: string;
3161
+ health: string;
3162
+ openapi: string;
3163
+ streaming_health: string;
3164
+ };
2892
3165
  }
2893
- interface EmbeddingRow {
2894
- id: string;
2895
- note_id: null | string;
2896
- embedding_set_id: null | string;
2897
- chunk_index: number;
2898
- text: string;
2899
- vector: null | string;
2900
- model: null | string;
2901
- contract_fingerprint: null | string;
2902
- shard_contract_fingerprint_present: boolean;
2903
- created_at: Date | null;
3166
+ interface FortemiCompatibilityValidationResult {
3167
+ ok: boolean;
3168
+ errors: string[];
3169
+ warnings: string[];
3170
+ response?: FortemiCompatibilityResponse;
2904
3171
  }
2905
- interface EmbeddingSetRow extends Partial<Omit<NativeEmbeddingSet, 'created_at' | 'criteria' | 'keywords' | 'mode' | 'set_type' | 'truncate_dim' | 'updated_at'>> {
2906
- id: string;
2907
- name: string;
2908
- purpose: null | string;
2909
- model_name: string;
2910
- dimensions: number;
2911
- kind: EmbeddingSetKind;
2912
- mode: EmbeddingSetMode | null;
2913
- truncate_dimension: null | number;
2914
- criteria_json: null | unknown;
2915
- source_json: null | unknown;
2916
- compatibility_json: null | unknown;
2917
- materialization_json: null | unknown;
2918
- freshness_json: null | unknown;
2919
- created_at: Date;
2920
- updated_at: Date;
3172
+ interface FetchFortemiCompatibilityOptions {
3173
+ baseUrl?: string;
3174
+ fetchImpl?: typeof fetch;
3175
+ timeoutMs?: number;
2921
3176
  }
2922
- interface EmbeddingSetCreateInput {
2923
- id?: string;
2924
- name: string;
2925
- slug?: null | string;
2926
- purpose?: null | string;
2927
- model_name?: string;
2928
- dimensions?: number;
2929
- kind?: EmbeddingSetKind;
2930
- mode?: EmbeddingSetMode | null;
2931
- truncate_dimension?: null | number;
2932
- criteria?: EmbeddingSetCriteria | null;
3177
+ declare function fortemiCompatibilityUrl(baseUrl?: string): string;
3178
+ declare function validateFortemiCompatibilityResponse(raw: unknown): FortemiCompatibilityValidationResult;
3179
+ declare function formatFortemiCompatibilitySummary(response: FortemiCompatibilityResponse): string;
3180
+ declare function fetchAndValidateFortemiCompatibility(options?: FetchFortemiCompatibilityOptions): Promise<FortemiCompatibilityValidationResult & {
3181
+ status?: number;
3182
+ url: string;
3183
+ }>;
3184
+ interface SWRegistrationResult {
3185
+ registered: boolean;
3186
+ registration?: ServiceWorkerRegistration;
3187
+ error?: string;
2933
3188
  }
2934
- interface EmbeddingSetEmbeddingInput {
2935
- id?: string;
2936
- note_id: string;
2937
- embedding_set_id: string;
2938
- vector: number[];
3189
+ declare function registerServiceWorker(swUrl?: string): Promise<SWRegistrationResult>;
3190
+ /**
3191
+ * REST route definitions for Service Worker.
3192
+ * These are pure functions that transform HTTP Request → tool input and tool output → Response.
3193
+ * The actual DB connection is injected at registration time.
3194
+ *
3195
+ * All routes currently return 503 Not Implemented — the DB wiring happens in a later issue.
3196
+ * The URL structure and request/response shapes are the valuable contract defined here.
3197
+ */
3198
+ interface RouteHandler {
3199
+ method: string;
3200
+ pattern: RegExp;
3201
+ handler: (request: Request, match: RegExpMatchArray, params: URLSearchParams) => Promise<Response>;
2939
3202
  }
2940
- declare class EmbeddingSetsRepository {
2941
- private db;
2942
- constructor(db: QueryExecutor);
2943
- getConfig(id: string): Promise<EmbeddingConfigRow>;
2944
- listConfigs(): Promise<EmbeddingConfigRow[]>;
2945
- listMembers(setId: string): Promise<EmbeddingMemberRow[]>;
2946
- /** Includes metadata-only records and every chunk, unlike a resolved graph selector. */
2947
- listEmbeddings(setId: string): Promise<EmbeddingRow[]>;
2948
- create(input: EmbeddingSetCreateInput): Promise<EmbeddingSetRow>;
2949
- createVirtualDefinition(input: VirtualEmbeddingSetDefinition): Promise<EmbeddingSetRow>;
2950
- ensureDefault(): Promise<EmbeddingSetRow>;
2951
- get(id: string): Promise<EmbeddingSetRow>;
2952
- list(): Promise<EmbeddingSetRow[]>;
2953
- listDescriptors(): Promise<EmbeddingSetDescriptor[]>;
2954
- toDescriptor(row: EmbeddingSetRow): EmbeddingSetDescriptor;
2955
- putEmbedding(input: EmbeddingSetEmbeddingInput): Promise<{
2956
- id: string;
2957
- }>;
2958
- resolveSelector(selector: EmbeddingSetSelector): Promise<ResolvedEmbeddingSet>;
2959
- refreshMaterializedVirtualSet(setId: string): Promise<ResolvedEmbeddingSet>;
2960
- markVirtualSetStale(setId: string, reason: string): Promise<void>;
2961
- /** @internal The repository and mutation must use the same caller-owned transaction. */
2962
- withMaterializationInvalidation<T>(mutate: () => Promise<T>): Promise<T>;
2963
- private liveResolutionHash;
2964
- private resolveDefinition;
2965
- private resolvePhysicalSet;
2966
- private resolvePhysicalRows;
2967
- private resolveMaterializedRows;
2968
- private resolveCriteriaSource;
2969
- private resolveSetOperationSource;
2970
- private resolveFallbackSource;
2971
- private resolveLatestCompatibleSource;
2972
- private validateCompatibility;
2973
- private resolveDuplicateRows;
2974
- private finalizeResolution;
2975
- private resolutionInputHash;
2976
- private definitionFromRow;
2977
- private inferDefinitionModel;
2978
- private inferDefinitionDimension;
3203
+ /**
3204
+ * Create route handlers.
3205
+ * db parameter will be injected when the SW gets access to PGlite.
3206
+ * For now, returns 503 Not Implemented for all routes.
3207
+ */
3208
+ declare function createRoutes(): RouteHandler[];
3209
+ /**
3210
+ * Match a request against the registered routes and return the first matching
3211
+ * handler, or null if no route matches.
3212
+ */
3213
+ declare function matchRoute(routes: RouteHandler[], request: Request, url: URL): null | RouteHandler;
3214
+ /**
3215
+ * One-shot migration of the pre-bytecask blob layout into the new store.
3216
+ *
3217
+ * The legacy layout (shipped through v2026.7.x) was:
3218
+ * - IndexedDB: database `fortemi-<archive>-blobs`, object store `blobs`,
3219
+ * values keyed by the full checksum string (`blake3:<hex>`, historically
3220
+ * also `sha256:<hex>`).
3221
+ * - OPFS: directory `fortemi-<archive>-blobs/<h0h1>/<h2h3>/<checksum>`.
3222
+ *
3223
+ * Migration re-`put()`s every payload — the new store recomputes BLAKE3, so
3224
+ * legacy `sha256:`-keyed entries converge to canonical keys for free
3225
+ * (ADR-012 D3). The legacy source is deleted only after every entry migrated
3226
+ * without error; any failure leaves it untouched for the next attempt.
3227
+ */
3228
+ /** Outcome of one migration attempt (for diagnostics/logging). */
3229
+ interface LegacyMigrationReport {
3230
+ migrated: number;
3231
+ /** Migration aborted without deleting the legacy source. */
3232
+ failed: boolean;
2979
3233
  }
2980
- declare const REGISTERED_METADATA_PATHS: readonly [
2981
- "provider",
2982
- "model",
2983
- "role",
2984
- "event_kind",
2985
- "sensitivity",
2986
- "import_run_id"
2987
- ];
2988
- type RegisteredMetadataPath = typeof REGISTERED_METADATA_PATHS[number];
2989
- type MetadataPredicate = {
2990
- gte?: number | string;
2991
- lte?: number | string;
2992
- op: 'range';
2993
- path: RegisteredMetadataPath;
3234
+ /**
3235
+ * Migrate any legacy blob layout for `archiveName` into `target`, then delete
3236
+ * the legacy source. Failures are contained: the legacy data stays in place
3237
+ * and the new store keeps whatever was already re-put (idempotent on retry).
3238
+ */
3239
+ declare function migrateLegacyBlobStore(archiveName: string, target: BlobStore, indexedDbFactory?: IDBFactory): Promise<LegacyMigrationReport>;
3240
+ /**
3241
+ * Shared postMessage protocol types for the PGlite worker.
3242
+ *
3243
+ * WorkerRequest — messages sent from the client to the worker.
3244
+ * WorkerResponse — messages sent from the worker back to the client.
3245
+ *
3246
+ * Every request carries a unique `id` that the worker echoes in its response,
3247
+ * allowing the client to correlate replies with pending promises.
3248
+ * The READY broadcast is the only message without an `id` — it is sent once
3249
+ * on startup before any requests are processed.
3250
+ */
3251
+ /** Messages from client to worker */
3252
+ type WorkerRequest = {
3253
+ id: string;
3254
+ isolationLevel?: string;
3255
+ type: 'BEGIN';
2994
3256
  } | {
2995
- op: 'eq';
2996
- path: RegisteredMetadataPath;
2997
- value: boolean | null | number | string;
3257
+ id: string;
3258
+ params?: unknown[];
3259
+ sql: string;
3260
+ txId: string;
3261
+ type: 'TX_QUERY';
2998
3262
  } | {
2999
- op: 'exists';
3000
- path: RegisteredMetadataPath;
3001
- value?: boolean;
3263
+ id: string;
3264
+ params?: unknown[];
3265
+ sql: string;
3266
+ type: 'QUERY';
3002
3267
  } | {
3003
- op: 'in';
3004
- path: RegisteredMetadataPath;
3005
- value: readonly (boolean | null | number | string)[];
3268
+ id: string;
3269
+ sql: string;
3270
+ txId: string;
3271
+ type: 'TX_EXEC';
3272
+ } | {
3273
+ id: string;
3274
+ sql: string;
3275
+ type: 'EXEC';
3276
+ } | {
3277
+ id: string;
3278
+ txId: string;
3279
+ type: 'COMMIT';
3280
+ } | {
3281
+ id: string;
3282
+ txId: string;
3283
+ type: 'ROLLBACK';
3284
+ } | {
3285
+ id: string;
3286
+ type: 'CLOSE';
3287
+ } | {
3288
+ id: string;
3289
+ type: 'PING';
3006
3290
  };
3007
- interface EvidenceLocator {
3008
- note_id: string;
3009
- chunk?: {
3010
- index: number;
3011
- kind: 'attachment' | 'current' | 'title';
3012
- };
3013
- span?: {
3014
- end: number;
3015
- start: number;
3016
- };
3017
- source?: {
3018
- external_id_hash: string;
3019
- import_run_id: string;
3020
- namespace: string;
3021
- schema_version: string;
3022
- };
3023
- metadata_paths: RegisteredMetadataPath[];
3024
- }
3025
- interface MetadataPredicateConditionResult {
3026
- conditions: string[];
3027
- joins: string[];
3028
- params: unknown[];
3029
- nextIdx: number;
3030
- }
3031
- declare function buildMetadataPredicateConditions(options: Pick<SearchOptions, 'archive_id' | 'metadataPredicates' | 'tenant_id'>, startIdx: number): MetadataPredicateConditionResult;
3032
- /**
3033
- * Shared types for repository layer.
3034
- * All repository methods use these types as inputs and outputs.
3035
- */
3036
- interface NoteSummary {
3291
+ /** Messages from worker to client */
3292
+ type WorkerResponse = {
3293
+ affectedRows?: number;
3037
3294
  id: string;
3038
- title: null | string;
3039
- format: string;
3040
- source: string;
3041
- visibility: string;
3042
- is_starred: boolean;
3043
- is_pinned: boolean;
3044
- is_archived: boolean;
3045
- created_at: Date;
3046
- updated_at: Date;
3047
- deleted_at: Date | null;
3048
- tags: string[];
3049
- }
3050
- interface NoteFull extends NoteSummary {
3051
- /** Note metadata is independent of the current revision's AI metadata. */
3052
- metadata?: unknown;
3053
- archive_id: null | string;
3054
- revision_mode: string;
3055
- original: {
3056
- content_hash: string;
3057
- content: string;
3058
- created_at: Date;
3059
- id: null | string;
3060
- user_created_at?: null | string;
3061
- user_last_edited_at?: null | string;
3062
- version_number?: number;
3063
- };
3064
- current: {
3065
- ai_metadata: null | unknown;
3066
- content: string;
3067
- generation_count: number;
3068
- is_user_edited: boolean;
3069
- last_revision_id?: null | string;
3070
- model: null | string;
3071
- updated_at: Date;
3072
- };
3073
- }
3074
- interface NoteCreateInput {
3075
- metadata?: unknown;
3076
- content: string;
3077
- title?: string;
3078
- format?: string;
3079
- source?: string;
3080
- visibility?: string;
3081
- tags?: string[];
3082
- archive_id?: string;
3083
- /**
3084
- * Explicit primary key. When omitted a UUIDv7 is minted (the default). Supply
3085
- * this only for deterministic seeding or cross-instance identity — e.g. two
3086
- * in-browser databases that must agree on a shared note's id so a shard swap
3087
- * can dedupe it under the `skip` conflict strategy.
3088
- */
3089
- id?: string;
3090
- }
3091
- interface NoteUpdateInput {
3092
- metadata?: unknown;
3093
- title?: string;
3094
- content?: string;
3095
- format?: string;
3096
- visibility?: string;
3097
- }
3098
- interface NoteListOptions {
3099
- limit?: number;
3100
- offset?: number;
3101
- sort?: 'created_at' | 'title' | 'updated_at';
3102
- order?: 'asc' | 'desc';
3103
- is_starred?: boolean;
3104
- is_pinned?: boolean;
3105
- is_archived?: boolean;
3106
- include_deleted?: boolean;
3107
- include_archived?: boolean;
3108
- collection_id?: string;
3109
- tags?: string[];
3110
- }
3111
- interface PaginatedResult<T> {
3112
- items: T[];
3113
- total: number;
3114
- limit: number;
3115
- offset: number;
3116
- }
3117
- interface SearchResult {
3295
+ type: 'EXEC_DONE';
3296
+ } | {
3297
+ error: string;
3118
3298
  id: string;
3119
- title: null | string;
3120
- snippet: string;
3121
- rank: number;
3122
- created_at: Date;
3123
- updated_at: Date;
3124
- tags: string[];
3125
- has_embedding?: boolean;
3126
- locators?: EvidenceLocator[];
3127
- }
3128
- interface SearchFacets {
3129
- tags: {
3130
- count: number;
3131
- tag: string;
3132
- }[];
3133
- collections: {
3134
- count: number;
3135
- id: string;
3299
+ type: 'ERROR';
3300
+ } | {
3301
+ fields?: Array<{
3302
+ dataTypeID: number;
3136
3303
  name: string;
3137
- }[];
3138
- }
3139
- interface SearchResponse {
3140
- results: SearchResult[];
3141
- total: number;
3142
- query: string;
3143
- mode: 'hybrid' | 'semantic' | 'text';
3144
- semantic_available: boolean;
3145
- limit: number;
3146
- offset: number;
3147
- facets?: SearchFacets;
3148
- }
3149
- interface SearchOptions {
3150
- limit?: number;
3151
- offset?: number;
3152
- tags?: string[];
3153
- collection_id?: string;
3154
- date_from?: Date;
3155
- date_to?: Date;
3156
- is_starred?: boolean;
3157
- is_archived?: boolean;
3158
- format?: string;
3159
- source?: string;
3160
- visibility?: string;
3161
- tenant_id?: string;
3162
- archive_id?: null | string;
3163
- metadataPredicates?: readonly MetadataPredicate[];
3164
- include_facets?: boolean;
3165
- mode?: 'auto' | 'hybrid' | 'semantic' | 'text';
3166
- embeddingSetId?: string;
3167
- embeddingSetSelector?: EmbeddingSetSelector;
3168
- }
3169
- interface NoteRevision {
3304
+ }>;
3170
3305
  id: string;
3171
- note_id: string;
3172
- revision_number: number;
3173
- type: string;
3174
- content: string;
3175
- ai_metadata: null | unknown;
3176
- model: null | string;
3177
- created_at: Date;
3178
- parent_revision_id?: null | string;
3179
- summary?: null | string;
3180
- rationale?: null | string;
3181
- created_at_utc?: null | string;
3182
- ai_generated_at?: null | string;
3183
- user_last_edited_at?: null | string;
3184
- is_user_edited?: boolean;
3185
- generation_count?: number;
3186
- }
3187
- interface OriginalContentRevision {
3306
+ rows: unknown[];
3307
+ type: 'RESULT';
3308
+ } | {
3188
3309
  id: string;
3189
- note_id: string;
3190
- version_number: number;
3191
- content: string;
3192
- hash: string;
3193
- created_at_utc: string;
3194
- created_by: string;
3195
- }
3310
+ txId: string;
3311
+ type: 'TX_STARTED';
3312
+ } | {
3313
+ id: string;
3314
+ type: 'PONG';
3315
+ } | {
3316
+ id: string;
3317
+ type: 'TX_DONE';
3318
+ } | {
3319
+ type: 'READY';
3320
+ };
3196
3321
  /**
3197
3322
  * NotesRepository — CRUD and lifecycle operations for the note entity.
3198
3323
  *
@@ -3258,6 +3383,8 @@ declare class NotesRepository {
3258
3383
  /** User-authored original history is distinct from generated revision history. */
3259
3384
  getOriginalHistory(noteId: string): Promise<OriginalContentRevision[]>;
3260
3385
  }
3386
+ /** Local selection only. Hosted callers must supply their own authorized database context. */
3387
+ type SearchEvidenceScope = Pick<SearchOptions, 'archive_id' | 'metadataPredicates' | 'tenant_id' | 'visibility'>;
3261
3388
  /**
3262
3389
  * SearchRepository - full-text search using DatabaseClient tsvector/tsquery,
3263
3390
  * with optional semantic search (pgvector) and hybrid (BM25 + vector RRF).
@@ -3266,6 +3393,8 @@ declare class SearchRepository {
3266
3393
  private db;
3267
3394
  private semanticAvailable;
3268
3395
  constructor(db: DatabaseClient, semanticAvailable?: boolean);
3396
+ /** Candidate citation resolution with fresh local scope and content checks. */
3397
+ resolveEvidence(locator: unknown, scope?: SearchEvidenceScope): Promise<string>;
3269
3398
  private tsqueryFn;
3270
3399
  private fetchEmbeddingSet;
3271
3400
  private selectorFromOptions;
@@ -3648,7 +3777,7 @@ interface ConditionResult {
3648
3777
  * @param startIdx - Starting parameter index ($N)
3649
3778
  * @param includeDeleted - Whether to include soft-deleted notes (default: false)
3650
3779
  */
3651
- declare function buildNoteConditions(options: Pick<SearchOptions, 'collection_id' | 'date_from' | 'date_to' | 'format' | 'is_archived' | 'is_starred' | 'source' | 'tags' | 'visibility'>, startIdx: number, includeDeleted?: boolean): ConditionResult;
3780
+ declare function buildNoteConditions(options: Pick<SearchOptions, 'collection_id' | 'date_from' | 'date_to' | 'format' | 'is_archived' | 'is_starred' | 'source' | 'sources' | 'tags' | 'tagsAll' | 'visibility'>, startIdx: number, includeDeleted?: boolean): ConditionResult;
3652
3781
  /**
3653
3782
  * Job queue worker — polls job_queue for pending jobs, dispatches to registered
3654
3783
  * handlers, manages status transitions and exponential backoff retries.
@@ -4293,13 +4422,6 @@ declare function manageNote(db: DatabaseClient, rawInput: unknown, events?: Type
4293
4422
  * Input is Zod-validated at entry.
4294
4423
  */
4295
4424
  declare function searchTool(db: DatabaseClient, rawInput: unknown): Promise<SearchResponse>;
4296
- /**
4297
- * Zod schemas for tool function inputs.
4298
- *
4299
- * These schemas are the contract between callers (e.g. host platform bridge) and
4300
- * the tool functions. All inputs are validated at the tool boundary so that
4301
- * repository methods only receive well-typed data.
4302
- */
4303
4425
  declare const CaptureKnowledgeInputSchema: z.ZodObject<{
4304
4426
  action: z.ZodEnum<[
4305
4427
  "create",
@@ -4411,6 +4533,7 @@ declare const ManageNoteInputSchema: z.ZodObject<{
4411
4533
  }>;
4412
4534
  type ManageNoteInput = z.infer<typeof ManageNoteInputSchema>;
4413
4535
  declare const SearchInputSchema: z.ZodObject<{
4536
+ archive_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
4414
4537
  collection_id: z.ZodOptional<z.ZodString>;
4415
4538
  date_from: z.ZodOptional<z.ZodDate>;
4416
4539
  date_to: z.ZodOptional<z.ZodDate>;
@@ -4424,6 +4547,7 @@ declare const SearchInputSchema: z.ZodObject<{
4424
4547
  is_archived: z.ZodOptional<z.ZodBoolean>;
4425
4548
  is_starred: z.ZodOptional<z.ZodBoolean>;
4426
4549
  limit: z.ZodDefault<z.ZodNumber>;
4550
+ metadataPredicates: z.ZodOptional<z.ZodEffects<z.ZodUnknown, readonly MetadataPredicate[], unknown>>;
4427
4551
  mode: z.ZodDefault<z.ZodEnum<[
4428
4552
  "text",
4429
4553
  "semantic",
@@ -4435,12 +4559,14 @@ declare const SearchInputSchema: z.ZodObject<{
4435
4559
  query: z.ZodString;
4436
4560
  source: z.ZodOptional<z.ZodString>;
4437
4561
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
4562
+ tenant_id: z.ZodOptional<z.ZodString>;
4438
4563
  visibility: z.ZodOptional<z.ZodEnum<[
4439
4564
  "private",
4440
4565
  "shared",
4441
4566
  "public"
4442
4567
  ]>>;
4443
4568
  }, "strip", z.ZodTypeAny, {
4569
+ archive_id?: null | string | undefined;
4444
4570
  collection_id?: string | undefined;
4445
4571
  date_from?: Date | undefined;
4446
4572
  date_to?: Date | undefined;
@@ -4450,14 +4576,17 @@ declare const SearchInputSchema: z.ZodObject<{
4450
4576
  is_archived?: boolean | undefined;
4451
4577
  is_starred?: boolean | undefined;
4452
4578
  limit: number;
4579
+ metadataPredicates?: readonly MetadataPredicate[] | undefined;
4453
4580
  mode: "auto" | "hybrid" | "semantic" | "text";
4454
4581
  offset: number;
4455
4582
  query_embedding?: number[] | undefined;
4456
4583
  query: string;
4457
4584
  source?: string | undefined;
4458
4585
  tags?: string[] | undefined;
4586
+ tenant_id?: string | undefined;
4459
4587
  visibility?: "private" | "public" | "shared" | undefined;
4460
4588
  }, {
4589
+ archive_id?: null | string | undefined;
4461
4590
  collection_id?: string | undefined;
4462
4591
  date_from?: Date | undefined;
4463
4592
  date_to?: Date | undefined;
@@ -4467,12 +4596,14 @@ declare const SearchInputSchema: z.ZodObject<{
4467
4596
  is_archived?: boolean | undefined;
4468
4597
  is_starred?: boolean | undefined;
4469
4598
  limit?: number | undefined;
4599
+ metadataPredicates?: unknown;
4470
4600
  mode?: "auto" | "hybrid" | "semantic" | "text" | undefined;
4471
4601
  offset?: number | undefined;
4472
4602
  query_embedding?: number[] | undefined;
4473
4603
  query: string;
4474
4604
  source?: string | undefined;
4475
4605
  tags?: string[] | undefined;
4606
+ tenant_id?: string | undefined;
4476
4607
  visibility?: "private" | "public" | "shared" | undefined;
4477
4608
  }>;
4478
4609
  type SearchInput = z.infer<typeof SearchInputSchema>;
@@ -6283,7 +6414,7 @@ interface RecordStoreCapabilities {
6283
6414
  sourceAddressedUpsert?: true;
6284
6415
  deletionReceipts?: true;
6285
6416
  typedMetadataPredicates?: false;
6286
- evidenceLocators?: true;
6417
+ evidenceLocators?: false;
6287
6418
  fullTextSearch: false;
6288
6419
  vectorSearch: false;
6289
6420
  sqlJoins: false;
@@ -6437,7 +6568,7 @@ declare class CanonicalNotesRepository {
6437
6568
  * Bounded substring scan over title + revised content (case-insensitive).
6438
6569
  * This is deliberately not ranked FTS — see `store.capabilities`.
6439
6570
  */
6440
- searchText(query: string, limit?: number): Promise<NoteRecord0[]>;
6571
+ searchText(query: string, limit?: number, accept?: (note: NoteRecord0) => boolean): Promise<NoteRecord0[]>;
6441
6572
  addTag(noteId: string, tag: string): Promise<void>;
6442
6573
  removeTag(noteId: string, tag: string): Promise<void>;
6443
6574
  notesByTag(tag: string): Promise<NoteRecord0[]>;
@@ -6655,5 +6786,5 @@ declare function purgeRecordStoreGraph(store: RecordStore, selector: PurgeSelect
6655
6786
  * @created 2026-07-17
6656
6787
  * @agent Codex
6657
6788
  */
6658
- declare const VERSION = "2026.9.4";
6659
- export { type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRecord, type AttachmentBlobRow, type AttachmentProjectionResult, type AttachmentRecord, type AttachmentRow, AttachmentsRepository, type BackendCandidate, type BackendCapabilities, type BackendConcept, type BackendLink, type BackendListOptions, type BackendNote, type BackendNoteFull, type BackendProvenanceEdge, type BackendRequest, type BackendSearchHit, type BackendSearchQueryOptions, type BackendSearchResult, type BackendSelection, type BackendSemanticTier, type BackendStartupCost, BlobGcOptions, BlobGcResult, BlobReconcileOptions, BlobReconcileResult, BlobStore, type BridgeCapability, BridgeInferenceProvider, type BridgeProviderInfo, type BrowserNoteExport, CORE_V1_COMPONENTS, CURRENT_MIGRATION_HEAD, type CanonicalAttachInput, CanonicalAttachmentsRepository, type CanonicalNoteCreateInput, type CanonicalNoteUpdateInput, type CanonicalNoteView, CanonicalNotesRepository, type CapabilityInfo, CapabilityManager, type CapabilityName, type CapabilityState, type CaptureKnowledgeInput, CaptureKnowledgeInputSchema, type CaptureKnowledgeResult, type CollectionCreateInput, type CollectionNoteRecord, type NativeCollection as CollectionRecord, type CollectionRow, CollectionsRepository, CommunitiesRepository, type NativeCommunityAssignment as CommunityAssignmentRecord, type CommunityAssignmentView, type CommunityCreateInput, type CommunityFilterDefinition, type CommunityGraph, type CommunityOptions, type NativeCommunity as CommunityRecord, type NativeCommunitySet as CommunitySetRecord, type CommunitySourceDescriptor, type CommunitySourceType, type CommunitySummary, type CompletionRequest, type CompletionResponse, type ConditionResult, type ConfigureInferenceRuntimeOptions, type ConfiguredInferenceProvider, type ConfiguredInferenceRuntime, type CooldownConfig, type CooldownEvent, type CosineSemanticProviderOptions, type CreatePGliteOptions, type CreateRecordStoreOptions, type CspDirectiveName, type CspDirectives, type CspViolationReport, DATASET_EXECUTION_CAPABILITY_IDS, DATASET_EXECUTION_CONTRACT, DATASET_EXECUTION_SCHEMA_VERSION, DATASET_INGEST_CONTRACT, DATASET_INGEST_SCHEMA_VERSION, DATASET_LINEAGE_CONTRACT, DATASET_LINEAGE_SCHEMA_VERSION, DATASET_MATERIALIZATION_CONTRACT, DATASET_MATERIALIZATION_KINDS, DATASET_MATERIALIZATION_SCHEMA_VERSION, DB_SNAPSHOT_SCHEMA_VERSION, DEFAULT_LARGE_DOCUMENT_CHARS, DEFAULT_LARGE_DOCUMENT_CHUNKS, type DataBackend, type DatabaseClient, type DatasetBenchmarkEvidence, type DatasetCapabilityDeclaration, type DatasetCapabilityDegradation, type DatasetCapabilityDiagnostic, type DatasetCapabilityDiagnosticCode, type DatasetCapabilityEvidence, type DatasetCapabilityLimits, type DatasetCapabilityNegotiationRequest, type DatasetCapabilityNegotiationResult, type DatasetCapabilityRequirement, type DatasetCapabilityStatus, type DatasetCheckpoint, type DatasetDestinationScope, type DatasetDeterminismClass, type DatasetDigest, type DatasetExecutionCapabilityDescriptor, type DatasetExecutionCapabilityId, type DatasetExecutionDataClass, type DatasetExecutionMaturity, type DatasetExecutionPlane, type DatasetImplementationIdentity, type DatasetIncrementalParityResult, DatasetIngestError, type DatasetIngestErrorCode, DatasetIngestExecutor, type DatasetIngestHooks, type DatasetIngestMode, type DatasetIngestStore, type DatasetIngestTransaction, DatasetLineageLedger, type DatasetLineageLedgerOptions, type DatasetMaterializationAdapter, type DatasetMaterializationArtifact, DatasetMaterializationError, type DatasetMaterializationKind, type DatasetMaterializationOperation, type DatasetMaterializationProfile, type DatasetMaterializationReceipt, type DatasetMaterializationRequest, type DatasetMeasuredResources, type DatasetMutation, type DatasetMutationBatch, type DatasetOptionalCapabilityRequirement, type DatasetPrivacyBoundary, type DatasetPrivacyDecision, type DatasetProcessingPlan, type DatasetProfileNegotiationRequest, type DatasetProfileNegotiationResult, type DatasetProfileStatus, type DatasetRecordAuthorizer, type DatasetRecordRejection, type DatasetRetrievalRequest, type DatasetRetrievalResponse, type DatasetRunAttempt, type DatasetRunReceipt, type DatasetRunState, type DatasetRunStatus, type DatasetSourceRecord, type DatasetSourceSnapshot, type DatasetStoredRecord, type DatasetTombstoneMutation, type DatasetUpsertMutation, type DatasetVerificationState, type DbSnapshot, type DbSnapshotCompat, type DbSnapshotCompression, type DbSnapshotExpectations, type DbSnapshotMeta, type DbSnapshotSource, DbSnapshotVersionError, type DeletionReceipt, type DeletionReceiptRecord, type DiscoveredProvider, type DiscoveryOptions, type DumpDbSnapshotOptions, type DumpableDb, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, type EmbedFunction, type EmbedFunctionOptions, type EmbedRequest, type EmbedRequestMessage, type EmbedResponse, type EmbedResponseMessage, type EmbedTransportPort, type EmbedWorkerOptions, type EmbeddingCompatibilityPolicy, type EmbeddingConfigRow, type EmbeddingMemberRow, type EmbeddingRow, type EmbeddingSetCreateInput, type EmbeddingSetCriteria, type EmbeddingSetDescriptor, type EmbeddingSetEmbeddingInput, type EmbeddingSetFreshness, type EmbeddingSetKind, type EmbeddingSetMode, type EmbeddingSetRow, type EmbeddingSetSelector, EmbeddingSetsRepository, type EmbeddingTaskSelectionOptions, type EnqueueJobInput, type ErrorCategory, type EventMap, type EvidenceLocator, type ExecuteDatasetBatchOptions, ExportOptions, FORTEMI_BROWSER_LOCAL_DATASET_EXECUTION_DESCRIPTOR, FORTEMI_COMPATIBILITY_PATH, FORTEMI_COMPATIBILITY_STATES, FORTEMI_PORTABLE_SHARD_DATASET_EXECUTION_DESCRIPTOR, FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES, FORTEMI_SERVER_COMPATIBILITY_REVISION, FORTEMI_STATIC_CACHE_DATASET_EXECUTION_DESCRIPTOR, type FallbackEvent, FallbackRouter, type FallbackRouterConfig, type FetchFortemiCompatibilityOptions, type FortemiBridge, type FortemiBridgeCapabilities, type FortemiBridgeHost, type FortemiCompatibilityCapability, type FortemiCompatibilityResponse, type FortemiCompatibilityState, type FortemiCompatibilityValidationResult, type FortemiConfig, type FortemiCore, type FortemiInferenceRouter, type FortemiRequiredCompatibilityCapability, type FortemiSecretStore, type FortemiToolDefinition, FortemiToolManifest, type FullV1SnapshotImportOptions, type GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type NativeGraphEdge as GraphEdgeRecord, type GraphNode, GraphRepository, type NativeGraphSource as GraphSourceRecord, type IDisposable, IdbRecordStore, ImportOptions, ImportResult, type InferenceCapabilities, type InferenceProvider, type InferenceRuntimeConfig, type InferenceTask, JOB_CAPABILITIES, JOB_PRIORITIES, type JobQueueOptions, JobQueueWorker, type JobStatus, type JobType, type JournalEntry, LINEAGE_ENTITY_KINDS, LINEAGE_RELATIONSHIP_KINDS, LOCAL_ENDPOINTS, type LegacyInferenceProviderConfig, type LegacyMigrationReport, LifecyclePurgeRepository, type LineageActivity, type LineageAgent, type LineageAssertion, type LineageAssertionKind, type LineageAuthorizationPolicy, type LineageCorrection, type LineageEntity, type LineageEntityKind, type LineageEvidence, type LineageEvidenceReference, type LineageLedgerArchive, type LineageLossItem, type LineageLossReceipt, type LineagePrivacy, type LineageProjection, type LineageProjectionCapabilities, type LineageRelationshipKind, type LineageTraversalEdge, type LineageTraversalNode, type LineageTraversalRequest, type LineageTraversalResult, type LineageValidationCode, LineageValidationError, type NativeLink as LinkRecord, type LinkRecord0, type LinkRow, LinksRepository, type ListNotesInput, ListNotesInputSchema, type LlmCapabilityOptions, type LlmCompleteFn, type LlmCompleteOptions, type LoadedPluginScript, type LocalEndpoint, type ManageArchiveInput, ManageArchiveInputSchema, type ManageArchiveResult, type ManageAttachmentsInput, ManageAttachmentsInputSchema, type ManageAttachmentsResult, type ManageCapabilitiesInput, ManageCapabilitiesInputSchema, type ManageCapabilitiesResult, type ManageCollectionsInput, ManageCollectionsInputSchema, type ManageCollectionsResult, type ManageLinksInput, ManageLinksInputSchema, type ManageLinksResult, type ManageNoteInput, ManageNoteInputSchema, type ManageNoteResult, type ManageTagsInput, ManageTagsInputSchema, type ManageTagsResult, MemoryDatasetIngestStore, MemoryRecordStore, type MetadataPredicate, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NativeNamedLocation as NamedLocation, type NativeAttachmentProjection as NativeAttachmentRecord, type NativeNote as NativeNoteRecord, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteOriginalRecord, type NoteProjectionResult, type NoteRecord0, type NoteRevisedCurrentRecord, type NoteRevision, type NoteRevisionRecord, type NativeNoteSkosTag as NoteSkosAssignment, type NoteSkosTag, type NoteSummary, type NoteTagRecord, type NoteUpdateInput, NotesRepository, OpenAICompatibleProvider, type OpenAIProviderConfig, type OpenShardOptions, type OriginalContentRevision, type PGliteBackendOptions, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, type PGliteWorkerStorageBackendFactoryOptions, type PaginatedResult, type PersistenceMode, type PluginCspOptions, type PluginScriptDescriptor, type PluginScriptPolicy, type PrefetchOptions, type PrefetchResult, type PresenceTrackedRecord, type ProbeResult, type ProbeStatus, type NativeProvenanceActivity as ProvenanceActivity, type NativeProvenanceRecord as ProvenanceCapture, type NativeProvenanceEdge as ProvenanceDerivation, type NativeProvenanceDevice as ProvenanceDevice, type ProvenanceEdge, type NativeProvenanceLocation as ProvenanceLocation, ProvenanceRepository, type NativeTimestampRange as ProvenanceTimeRange, type ProviderCapabilities, type ProviderCostTier, type ProviderDataClass, type ProviderPrivacyTier, type ProviderProfile, ProviderRegistry, type ProviderRoutePolicy, type ProviderRouteProbeResult, type ProviderRouteRequirements, type ProviderRouteSelection, type ProviderRouteValidation, type ProviderRouteValidationIssue, type ProviderRouteValidationSeverity, type ProviderTier, type PurgeCounts, type PurgePreview, type PurgeSelector, type QueryExecutor, type QueryResult, RECORD_COLLECTIONS, RECORD_SCHEMA_VERSION, RECORD_STORE_CAPABILITIES, REGISTERED_METADATA_PATHS, type RecommendedTier, type RecordBackendManageNoteResult, type RecordBackendOptions, type RecordCollectionName, type RecordCollections, type RecordListOptions, type RecordMutation, type RecordProjectionResult, type RecordProvenanceInput, type RecordStore, type RecordStoreCapabilities, type RegisteredMetadataPath, type RemoteBackendConfig, RemoteBackendError, type RemoteBackendErrorKind, type RemoteBackendPaths, type RemoteDataBackend, type RemoteManageNoteInput, type RemoteManageNoteResult, type RemoteProvenanceGraph, type RemoteSearchDegradation, type RemoteSearchMetadata, type RemoteSearchMode, type RemoteSearchOptions, type RemoteSearchResult, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RestoreDbSnapshotOptions, type RouteHandler, SOURCE_UPSERT_CONTRACT_VERSION, SOURCE_UPSERT_MAX_ITEMS, SUPPORTED_PGLITE_VERSION, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, ShardBackend, type ShardBackendOptions, ShardCapabilityReport, ShardCollection, ShardComponent, type ShardComponentStore, ShardEmbedding, ShardEmbeddingConfig, ShardEmbeddingSet, ShardEmbeddingSetMember, ShardExportResult, ShardLink, type ShardListOptions, ShardLossEntry, ShardManifest, ShardNote, type ShardNoteFull, ShardNoteSkosTag, ShardOperation, ShardProfileRegistryEntry, ShardProvenanceEdge, type ShardReader, type ShardReaderNote, type ShardReaderSource, type ShardSchemaValidationResult, type ShardSearchOptions, type ShardSearchRankedNote, type ShardSearchResult, type ShardSearchWeights, ShardSkosConcept, ShardSkosRelation, ShardSkosScheme, ShardTag, ShardTemplate, type SimilarityGraphCacheKey, type SimilarityGraphOptions, type SimilarityGraphRequest, type SimilarityGraphResult, type NativeSkosCollection as SkosCollection, type NativeSkosCollectionMember as SkosCollectionMember, type SkosConcept, type NativeSkosConcept as SkosConceptRecord, type NativeSkosLabel as SkosLabel, type NativeSkosMapping as SkosMapping, type NativeSkosMembership as SkosMembership, type NativeSkosNote as SkosNote, type SkosRelation, SkosRepository, type SkosScheme, type NativeSkosScheme as SkosSchemeRecord, type SourceIdentityInput, type SourceIdentityRecord, type SourceImportBatchRecord, type SourceImportRunRecord, type SourceUpsertBatchOutcome, type SourceUpsertBatchResult, type SourceUpsertItem, type SourceUpsertItemResult, type SourceUpsertOptions, type SourceUpsertOutcome, type SourceUpsertPolicy, type SourceUpsertReasonCode, SourceUpsertRepository, type SourceUpsertRequest, type SourceUpsertRequestItem, type SourceUpsertResponse, type SourceUpsertScope, type StaticSemanticProvider, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, type NativeTag as TagRecord, TagsRepository, type TemplateCreateInput, type NativeTemplate as TemplateRecord, TemplatesRepository, TransactionProxy, TypedEventBus, VERSION, type VectorEntry, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, allMigrations, appendPluginScript, assertShardComponentRecord, buildMetadataPredicateConditions, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, compareDatasetIncrementalParity, computeBlobHash, computeHash, computeLineageDigest, computeSri, conceptTaggingHandler, configureInferenceRuntime, cosineSimilarity, createBridgeInferenceProviders, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLegacyProvider, createLocalProviderProfile, createPGliteBackend, createPGliteInstance, createRecordBackend, createRecordStore, createRemoteBackend, createRoutes, createShardBackend, createShardCapabilityReport, createWorkerEmbedFunction, datasetDestinationScopeKey, defaultStorageBackendFactory, defineInferenceProvider, defineInferenceRuntime, defineLegacyInferenceProvider, defineOpenAICompatibleProvider, deriveDatasetIngestIdempotencyKey, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, digestDatasetMaterializationValue, discoverLocalProviders, dropAttachmentProjection, dropNoteProjection, dumpDbSnapshot, embeddingConfigToShard, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, executeDatasetMaterialization, executeDatasetRetrieval, exportFullV1Snapshot, exportShard, exportShardFromRecords, exportShardFromRecordsWithReport, exportShardWithReport, fetchAndValidateFortemiCompatibility, fetchPluginScript, formatFortemiCompatibilitySummary, fortemiCompatibilityUrl, fortemiManifest, fromPrefetched, generateId, getConfiguredInferenceProviderId, getEmbedFunction, getEmbeddingTaskSelectionOptions, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getKnowledgeShardContractReceipt, getKnowledgeShardProfileRegistry, getKnowledgeShardSchema, getLlmFunction, getNote, getPrefetchedSha256, getProviderRouteRequirementIssue, handleEmbedRequests, hasFortemiSecureSecrets, importFullV1Snapshot, importShard, importShardToRecords, inferInferenceTaskCapability, inferLocalEmbeddingDimensions, isPluginScriptAllowed, isShardPrefetched, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, mergeInferenceRuntimeConfigs, migrateLegacyBlobStore, negotiateDatasetExecutionCapabilities, negotiateDatasetMaterializationProfile, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, previewRecordStorePurge, profileSupportError, projectAttachments, projectNotes, projectRecords, provenanceEdgeToShard, providerSatisfiesRouteRequirements, purgeRecordStoreGraph, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectEmbeddingTask, selectLlmModel, setEmbedFunction, setEmbeddingTaskSelectionOptions, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsToShard, templateToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, upsertRecordStoreRequest, upsertRecordStoreSources, urlLinkToShard, validateChecksums, validateCoreV1ShardArchive, validateDatasetBenchmarkEvidence, validateDatasetExecutionDescriptor, validateFortemiCompatibilityResponse, validateFullV1ShardArchive, validateProviderRoute, validateRecordV1ShardArchive, validateShardArchive, validateShardComponentRecord, validateShardManifest, verifyDbSnapshotMeta, verifySri };
6789
+ declare const VERSION = "2026.9.6";
6790
+ export { type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRecord, type AttachmentBlobRow, type AttachmentProjectionResult, type AttachmentRecord, type AttachmentRow, AttachmentsRepository, type BackendCandidate, type BackendCapabilities, type BackendConcept, type BackendLink, type BackendListOptions, type BackendNote, type BackendNoteFull, type BackendProvenanceEdge, type BackendRequest, type BackendSearchHit, type BackendSearchQueryOptions, type BackendSearchResult, type BackendSelection, type BackendSemanticTier, type BackendStartupCost, BlobGcOptions, BlobGcResult, BlobReconcileOptions, BlobReconcileResult, BlobStore, type BridgeCapability, BridgeInferenceProvider, type BridgeProviderInfo, type BrowserNoteExport, CORE_V1_COMPONENTS, CURRENT_MIGRATION_HEAD, type CanonicalAttachInput, CanonicalAttachmentsRepository, type CanonicalNoteCreateInput, type CanonicalNoteUpdateInput, type CanonicalNoteView, CanonicalNotesRepository, type CapabilityInfo, CapabilityManager, type CapabilityName, type CapabilityState, type CaptureKnowledgeInput, CaptureKnowledgeInputSchema, type CaptureKnowledgeResult, type CollectionCreateInput, type CollectionNoteRecord, type NativeCollection as CollectionRecord, type CollectionRow, CollectionsRepository, CommunitiesRepository, type NativeCommunityAssignment as CommunityAssignmentRecord, type CommunityAssignmentView, type CommunityCreateInput, type CommunityFilterDefinition, type CommunityGraph, type CommunityOptions, type NativeCommunity as CommunityRecord, type NativeCommunitySet as CommunitySetRecord, type CommunitySourceDescriptor, type CommunitySourceType, type CommunitySummary, type CompletionRequest, type CompletionResponse, type ConditionResult, type ConfigureInferenceRuntimeOptions, type ConfiguredInferenceProvider, type ConfiguredInferenceRuntime, type CooldownConfig, type CooldownEvent, type CosineSemanticProviderOptions, type CreatePGliteOptions, type CreateRecordStoreOptions, type CspDirectiveName, type CspDirectives, type CspViolationReport, DATASET_EXECUTION_CAPABILITY_IDS, DATASET_EXECUTION_CONTRACT, DATASET_EXECUTION_SCHEMA_VERSION, DATASET_INGEST_CONTRACT, DATASET_INGEST_SCHEMA_VERSION, DATASET_LINEAGE_CONTRACT, DATASET_LINEAGE_SCHEMA_VERSION, DATASET_MATERIALIZATION_CONTRACT, DATASET_MATERIALIZATION_KINDS, DATASET_MATERIALIZATION_SCHEMA_VERSION, DB_SNAPSHOT_SCHEMA_VERSION, DEFAULT_LARGE_DOCUMENT_CHARS, DEFAULT_LARGE_DOCUMENT_CHUNKS, type DataBackend, type DatabaseClient, type DatasetBenchmarkEvidence, type DatasetCapabilityDeclaration, type DatasetCapabilityDegradation, type DatasetCapabilityDiagnostic, type DatasetCapabilityDiagnosticCode, type DatasetCapabilityEvidence, type DatasetCapabilityLimits, type DatasetCapabilityNegotiationRequest, type DatasetCapabilityNegotiationResult, type DatasetCapabilityRequirement, type DatasetCapabilityStatus, type DatasetCapabilityWireResult, type DatasetCheckpoint, type DatasetDestinationScope, type DatasetDeterminismClass, type DatasetDigest, type DatasetExecutionCapabilityDescriptor, type DatasetExecutionCapabilityId, type DatasetExecutionDataClass, type DatasetExecutionMaturity, type DatasetExecutionPlane, type DatasetImplementationIdentity, type DatasetIncrementalParityResult, DatasetIngestError, type DatasetIngestErrorCode, DatasetIngestExecutor, type DatasetIngestHooks, type DatasetIngestMode, type DatasetIngestStore, type DatasetIngestTransaction, DatasetLineageLedger, type DatasetLineageLedgerOptions, type DatasetMaterializationAdapter, type DatasetMaterializationArtifact, DatasetMaterializationError, type DatasetMaterializationKind, type DatasetMaterializationOperation, type DatasetMaterializationProfile, type DatasetMaterializationReceipt, type DatasetMaterializationRequest, type DatasetMeasuredResources, type DatasetMutation, type DatasetMutationBatch, type DatasetOptionalCapabilityRequirement, type DatasetPrivacyBoundary, type DatasetPrivacyDecision, type DatasetProcessingPlan, type DatasetProfileNegotiationRequest, type DatasetProfileNegotiationResult, type DatasetProfileStatus, type DatasetRecordAuthorizer, type DatasetRecordRejection, type DatasetRetrievalRequest, type DatasetRetrievalResponse, type DatasetRunAttempt, type DatasetRunReceipt, type DatasetRunState, type DatasetRunStatus, type DatasetSourceRecord, type DatasetSourceSnapshot, type DatasetStoredRecord, type DatasetTombstoneMutation, type DatasetUpsertMutation, type DatasetVerificationState, type DbSnapshot, type DbSnapshotCompat, type DbSnapshotCompression, type DbSnapshotExpectations, type DbSnapshotMeta, type DbSnapshotSource, DbSnapshotVersionError, type DeletionReceipt, type DeletionReceiptRecord, type DiscoveredProvider, type DiscoveryOptions, type DumpDbSnapshotOptions, type DumpableDb, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, type EmbedFunction, type EmbedFunctionOptions, type EmbedRequest, type EmbedRequestMessage, type EmbedResponse, type EmbedResponseMessage, type EmbedTransportPort, type EmbedWorkerOptions, type EmbeddingCompatibilityPolicy, type EmbeddingConfigRow, type EmbeddingMemberRow, type EmbeddingRow, type EmbeddingSetCreateInput, type EmbeddingSetCriteria, type EmbeddingSetDescriptor, type EmbeddingSetEmbeddingInput, type EmbeddingSetFreshness, type EmbeddingSetKind, type EmbeddingSetMode, type EmbeddingSetRow, type EmbeddingSetSelector, EmbeddingSetsRepository, type EmbeddingTaskSelectionOptions, type EnqueueJobInput, type ErrorCategory, type EventMap, type EvidenceLocator, type EvidenceSourceIdentity, type EvidenceTextSnapshot, type EvidenceTextUnit, type ExecuteDatasetBatchOptions, ExportOptions, FORTEMI_BROWSER_LOCAL_DATASET_EXECUTION_DESCRIPTOR, FORTEMI_COMPATIBILITY_PATH, FORTEMI_COMPATIBILITY_STATES, FORTEMI_PORTABLE_SHARD_DATASET_EXECUTION_DESCRIPTOR, FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES, FORTEMI_SERVER_COMPATIBILITY_REVISION, FORTEMI_STATIC_CACHE_DATASET_EXECUTION_DESCRIPTOR, type FallbackEvent, FallbackRouter, type FallbackRouterConfig, type FetchFortemiCompatibilityOptions, type FortemiBridge, type FortemiBridgeCapabilities, type FortemiBridgeHost, type FortemiCompatibilityCapability, type FortemiCompatibilityResponse, type FortemiCompatibilityState, type FortemiCompatibilityValidationResult, type FortemiConfig, type FortemiCore, type FortemiInferenceRouter, type FortemiRequiredCompatibilityCapability, type FortemiSecretStore, type FortemiToolDefinition, FortemiToolManifest, type FullV1SnapshotImportOptions, type GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type NativeGraphEdge as GraphEdgeRecord, type GraphNode, GraphRepository, type NativeGraphSource as GraphSourceRecord, type IDisposable, IdbRecordStore, ImportOptions, ImportResult, type InferenceCapabilities, type InferenceProvider, type InferenceRuntimeConfig, type InferenceTask, JOB_CAPABILITIES, JOB_PRIORITIES, type JobQueueOptions, JobQueueWorker, type JobStatus, type JobType, type JournalEntry, LINEAGE_ENTITY_KINDS, LINEAGE_RELATIONSHIP_KINDS, LOCAL_ENDPOINTS, type LegacyInferenceProviderConfig, type LegacyMigrationReport, LifecyclePurgeRepository, type LineageActivity, type LineageAgent, type LineageAssertion, type LineageAssertionKind, type LineageAuthorizationPolicy, type LineageCorrection, type LineageEntity, type LineageEntityKind, type LineageEvidence, type LineageEvidenceReference, type LineageLedgerArchive, type LineageLossItem, type LineageLossReceipt, type LineagePrivacy, type LineageProjection, type LineageProjectionCapabilities, type LineageRelationshipKind, type LineageTraversalEdge, type LineageTraversalNode, type LineageTraversalRequest, type LineageTraversalResult, type LineageValidationCode, LineageValidationError, type NativeLink as LinkRecord, type LinkRecord0, type LinkRow, LinksRepository, type ListNotesInput, ListNotesInputSchema, type LlmCapabilityOptions, type LlmCompleteFn, type LlmCompleteOptions, type LoadedPluginScript, type LocalEndpoint, type ManageArchiveInput, ManageArchiveInputSchema, type ManageArchiveResult, type ManageAttachmentsInput, ManageAttachmentsInputSchema, type ManageAttachmentsResult, type ManageCapabilitiesInput, ManageCapabilitiesInputSchema, type ManageCapabilitiesResult, type ManageCollectionsInput, ManageCollectionsInputSchema, type ManageCollectionsResult, type ManageLinksInput, ManageLinksInputSchema, type ManageLinksResult, type ManageNoteInput, ManageNoteInputSchema, type ManageNoteResult, type ManageTagsInput, ManageTagsInputSchema, type ManageTagsResult, MemoryDatasetIngestStore, MemoryRecordStore, type MetadataPredicate, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NativeNamedLocation as NamedLocation, type NativeAttachmentProjection as NativeAttachmentRecord, type NativeNote as NativeNoteRecord, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteOriginalRecord, type NoteProjectionResult, type NoteRecord0, type NoteRevisedCurrentRecord, type NoteRevision, type NoteRevisionRecord, type NativeNoteSkosTag as NoteSkosAssignment, type NoteSkosTag, type NoteSummary, type NoteTagRecord, type NoteUpdateInput, NotesRepository, OpenAICompatibleProvider, type OpenAIProviderConfig, type OpenShardOptions, type OriginalContentRevision, type PGliteBackendOptions, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, type PGliteWorkerStorageBackendFactoryOptions, type PaginatedResult, type PersistenceMode, type PluginCspOptions, type PluginScriptDescriptor, type PluginScriptPolicy, type PrefetchOptions, type PrefetchResult, type PresenceTrackedRecord, type ProbeResult, type ProbeStatus, type NativeProvenanceActivity as ProvenanceActivity, type NativeProvenanceRecord as ProvenanceCapture, type NativeProvenanceEdge as ProvenanceDerivation, type NativeProvenanceDevice as ProvenanceDevice, type ProvenanceEdge, type NativeProvenanceLocation as ProvenanceLocation, ProvenanceRepository, type NativeTimestampRange as ProvenanceTimeRange, type ProviderCapabilities, type ProviderCostTier, type ProviderDataClass, type ProviderPrivacyTier, type ProviderProfile, ProviderRegistry, type ProviderRoutePolicy, type ProviderRouteProbeResult, type ProviderRouteRequirements, type ProviderRouteSelection, type ProviderRouteValidation, type ProviderRouteValidationIssue, type ProviderRouteValidationSeverity, type ProviderTier, type PurgeCounts, type PurgePreview, type PurgeSelector, type QueryExecutor, type QueryResult, RECORD_COLLECTIONS, RECORD_SCHEMA_VERSION, RECORD_STORE_CAPABILITIES, REGISTERED_METADATA_PATHS, type RecommendedTier, type RecordBackendManageNoteResult, type RecordBackendOptions, type RecordCollectionName, type RecordCollections, type RecordListOptions, type RecordMutation, type RecordProjectionResult, type RecordProvenanceInput, type RecordStore, type RecordStoreCapabilities, type RegisteredMetadataPath, type RemoteBackendConfig, RemoteBackendError, type RemoteBackendErrorKind, type RemoteBackendPaths, type RemoteDataBackend, type RemoteEvidenceResolutionOptions, type RemoteManageNoteInput, type RemoteManageNoteResult, type RemoteProvenanceGraph, type RemoteSearchDegradation, type RemoteSearchMetadata, type RemoteSearchMode, type RemoteSearchOptions, type RemoteSearchResult, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RestoreDbSnapshotOptions, type RouteHandler, SOURCE_UPSERT_CONTRACT_VERSION, SOURCE_UPSERT_MAX_ITEMS, SUPPORTED_PGLITE_VERSION, type SWRegistrationResult, type SearchEvidenceLocator, type SearchEvidenceOmission, type SearchEvidenceScope, type SearchEvidenceSet, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, ShardBackend, type ShardBackendOptions, ShardCapabilityReport, ShardCollection, ShardComponent, type ShardComponentStore, ShardEmbedding, ShardEmbeddingConfig, ShardEmbeddingSet, ShardEmbeddingSetMember, ShardExportResult, ShardLink, type ShardListOptions, ShardLossEntry, ShardManifest, ShardNote, type ShardNoteFull, ShardNoteSkosTag, ShardOperation, ShardProfileRegistryEntry, ShardProvenanceEdge, type ShardReader, type ShardReaderNote, type ShardReaderSource, type ShardSchemaValidationResult, type ShardSearchOptions, type ShardSearchRankedNote, type ShardSearchResult, type ShardSearchWeights, ShardSkosConcept, ShardSkosRelation, ShardSkosScheme, ShardTag, ShardTemplate, type SimilarityGraphCacheKey, type SimilarityGraphOptions, type SimilarityGraphRequest, type SimilarityGraphResult, type NativeSkosCollection as SkosCollection, type NativeSkosCollectionMember as SkosCollectionMember, type SkosConcept, type NativeSkosConcept as SkosConceptRecord, type NativeSkosLabel as SkosLabel, type NativeSkosMapping as SkosMapping, type NativeSkosMembership as SkosMembership, type NativeSkosNote as SkosNote, type SkosRelation, SkosRepository, type SkosScheme, type NativeSkosScheme as SkosSchemeRecord, type SourceIdentityInput, type SourceIdentityRecord, type SourceImportBatchRecord, type SourceImportRunRecord, type SourceUpsertBatchOutcome, type SourceUpsertBatchResult, type SourceUpsertItem, type SourceUpsertItemResult, type SourceUpsertOptions, type SourceUpsertOutcome, type SourceUpsertPolicy, type SourceUpsertReasonCode, SourceUpsertRepository, type SourceUpsertRequest, type SourceUpsertRequestItem, type SourceUpsertResponse, type SourceUpsertScope, type StaticSemanticProvider, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, type NativeTag as TagRecord, TagsRepository, type TemplateCreateInput, type NativeTemplate as TemplateRecord, TemplatesRepository, TransactionProxy, TypedEventBus, VERSION, type VectorEntry, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, allMigrations, appendPluginScript, assertShardComponentRecord, bindSearchEvidence, buildMetadataPredicateConditions, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, compareDatasetIncrementalParity, computeBlobHash, computeHash, computeLineageDigest, computeSri, conceptTaggingHandler, configureInferenceRuntime, cosineSimilarity, createBridgeInferenceProviders, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLegacyProvider, createLocalProviderProfile, createPGliteBackend, createPGliteInstance, createRecordBackend, createRecordStore, createRemoteBackend, createRoutes, createSearchEvidenceSet, createShardBackend, createShardCapabilityReport, createWorkerEmbedFunction, datasetDestinationScopeKey, defaultStorageBackendFactory, defineInferenceProvider, defineInferenceRuntime, defineLegacyInferenceProvider, defineOpenAICompatibleProvider, deriveDatasetIngestIdempotencyKey, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, digestDatasetMaterializationValue, discoverLocalProviders, dropAttachmentProjection, dropNoteProjection, dumpDbSnapshot, embeddingConfigToShard, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, executeDatasetMaterialization, executeDatasetRetrieval, exportFullV1Snapshot, exportShard, exportShardFromRecords, exportShardFromRecordsWithReport, exportShardWithReport, fetchAndValidateFortemiCompatibility, fetchPluginScript, formatFortemiCompatibilitySummary, fortemiCompatibilityUrl, fortemiManifest, fromPrefetched, generateId, getConfiguredInferenceProviderId, getEmbedFunction, getEmbeddingTaskSelectionOptions, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getKnowledgeShardContractReceipt, getKnowledgeShardProfileRegistry, getKnowledgeShardSchema, getLlmFunction, getNote, getPrefetchedSha256, getProviderRouteRequirementIssue, handleEmbedRequests, hasFortemiSecureSecrets, importFullV1Snapshot, importShard, importShardToRecords, inferInferenceTaskCapability, inferLocalEmbeddingDimensions, isPluginScriptAllowed, isShardPrefetched, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, mergeInferenceRuntimeConfigs, mergeSearchEvidenceSets, migrateLegacyBlobStore, negotiateDatasetExecutionCapabilities, negotiateDatasetExecutionCapabilitiesFromWire, negotiateDatasetMaterializationProfile, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, parseSearchEvidenceLocator, parseSearchEvidenceSet, prefetchShard, previewRecordStorePurge, profileSupportError, projectAttachments, projectNotes, projectRecords, provenanceEdgeToShard, providerSatisfiesRouteRequirements, purgeRecordStoreGraph, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, resolveSearchEvidence, restoreDbSnapshot, searchTool, selectBackend, selectEmbeddingTask, selectLlmModel, setEmbedFunction, setEmbeddingTaskSelectionOptions, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsToShard, templateToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, upsertRecordStoreRequest, upsertRecordStoreSources, urlLinkToShard, validateChecksums, validateCoreV1ShardArchive, validateDatasetBenchmarkEvidence, validateDatasetExecutionDescriptor, validateDatasetExecutionRequest, validateFortemiCompatibilityResponse, validateFullV1ShardArchive, validateProviderRoute, validateRecordV1ShardArchive, validateShardArchive, validateShardComponentRecord, validateShardManifest, verifyDbSnapshotMeta, verifySri };