@fortemi/core 2026.5.3 → 2026.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -107,7 +107,7 @@ await registerServiceWorker()
107
107
  | Surface | Description |
108
108
  |---|---|
109
109
  | PGlite archive | `opfs`, `idb`, and `memory` persistence modes with migrations on open |
110
- | Repositories | Notes, search, tags, collections, links, SKOS concepts, attachments, jobs, and provenance |
110
+ | Repositories | Notes, search, tags, collections, links, SKOS concepts, attachments, embedding sets, graph helpers, jobs, and provenance |
111
111
  | Event bus | Typed subscriptions for note, job, archive, and capability events |
112
112
  | Capability system | Embeddings, local LLM, GPU detection, local-provider discovery, fallback routing |
113
113
  | Job queue | Server-compatible background workflow for revisions, titles, embeddings, concepts, and links |
package/dist/index.d.ts CHANGED
@@ -507,6 +507,195 @@ declare class TransactionProxy {
507
507
  exec(sql: string): Promise<void>;
508
508
  }
509
509
 
510
+ /**
511
+ * EmbeddingSetsRepository - named, filter, and virtual embedding set API.
512
+ */
513
+
514
+ type EmbeddingSetKind = 'physical' | 'filter' | 'virtual';
515
+ type EmbeddingSetMode = 'auto' | 'manual' | 'mixed';
516
+ interface EmbeddingSetCriteria {
517
+ query?: string;
518
+ tags?: string[];
519
+ collectionIds?: string[];
520
+ conceptIds?: string[];
521
+ noteIds?: string[];
522
+ updatedAfter?: string;
523
+ updatedBefore?: string;
524
+ }
525
+ interface EmbeddingSetFreshness {
526
+ status: 'fresh' | 'stale' | 'unknown';
527
+ sourceHash?: string;
528
+ checkedAt?: string;
529
+ reason?: string;
530
+ }
531
+ interface EmbeddingCompatibilityPolicy {
532
+ model: 'require-same' | 'allow-compatible-family';
533
+ dimension: 'require-same' | 'allow-truncation';
534
+ duplicateVectors: 'prefer-latest' | 'prefer-set-order' | 'error';
535
+ missingVectors: 'omit' | 'include-unembedded-note' | 'error';
536
+ }
537
+ interface VirtualMaterializationPolicy {
538
+ allowed: boolean;
539
+ includeResolvedMembers?: boolean;
540
+ includeResolvedEdges?: boolean;
541
+ freshness: 'fresh' | 'stale' | 'unknown';
542
+ }
543
+ interface CriteriaVirtualSource {
544
+ type: 'criteria';
545
+ baseSetId: string;
546
+ criteria: EmbeddingSetCriteria;
547
+ }
548
+ interface SetOperationVirtualSource {
549
+ type: 'set-operation';
550
+ operation: 'union' | 'intersection' | 'difference';
551
+ setIds: string[];
552
+ }
553
+ interface FallbackVirtualSource {
554
+ type: 'fallback';
555
+ preferredSetIds: string[];
556
+ }
557
+ interface LatestCompatibleVirtualSource {
558
+ type: 'latest-compatible';
559
+ candidateSetIds: string[];
560
+ model?: string;
561
+ dimension?: number;
562
+ }
563
+ interface SnapshotVirtualSource {
564
+ type: 'snapshot';
565
+ snapshotId: string;
566
+ sourceDefinitionId: string;
567
+ generatedAt: string;
568
+ inputHash: string;
569
+ }
570
+ type VirtualEmbeddingSetSource = CriteriaVirtualSource | SetOperationVirtualSource | FallbackVirtualSource | LatestCompatibleVirtualSource | SnapshotVirtualSource;
571
+ interface VirtualEmbeddingSetDefinition {
572
+ id: string;
573
+ name: string;
574
+ purpose?: string | null;
575
+ source: VirtualEmbeddingSetSource;
576
+ compatibility: EmbeddingCompatibilityPolicy;
577
+ materialization?: VirtualMaterializationPolicy;
578
+ createdAt?: string;
579
+ updatedAt?: string;
580
+ }
581
+ interface EmbeddingSetSelector {
582
+ kind: 'default' | 'embedding-set' | 'virtual-definition';
583
+ embeddingSetId?: string;
584
+ definition?: VirtualEmbeddingSetDefinition;
585
+ }
586
+ interface EmbeddingSetDescriptor {
587
+ id: string;
588
+ name: string;
589
+ purpose?: string | null;
590
+ kind: EmbeddingSetKind;
591
+ mode?: EmbeddingSetMode;
592
+ model?: string;
593
+ dimension?: number;
594
+ truncateDimension?: number | null;
595
+ criteria?: EmbeddingSetCriteria | null;
596
+ createdAt?: string;
597
+ updatedAt?: string;
598
+ freshness?: EmbeddingSetFreshness;
599
+ }
600
+ type VirtualEmbeddingSetValidationError = {
601
+ code: 'mixed-models';
602
+ setIds: string[];
603
+ } | {
604
+ code: 'mixed-dimensions';
605
+ setIds: string[];
606
+ } | {
607
+ code: 'missing-vector';
608
+ noteId: string;
609
+ setId: string;
610
+ } | {
611
+ code: 'duplicate-vector';
612
+ noteId: string;
613
+ setIds: string[];
614
+ } | {
615
+ code: 'stale-snapshot';
616
+ snapshotId: string;
617
+ } | {
618
+ code: 'unsupported-criteria';
619
+ field: string;
620
+ };
621
+ interface ResolvedEmbeddingRow {
622
+ note_id: string;
623
+ embedding_set_id: string;
624
+ embedding_id: string;
625
+ vector: string;
626
+ created_at: Date;
627
+ }
628
+ interface ResolvedEmbeddingSet {
629
+ selector: EmbeddingSetSelector;
630
+ rows: ResolvedEmbeddingRow[];
631
+ noteIds: string[];
632
+ embeddingIds: string[];
633
+ errors: VirtualEmbeddingSetValidationError[];
634
+ freshness: EmbeddingSetFreshness;
635
+ }
636
+ interface EmbeddingSetRow {
637
+ id: string;
638
+ name: string;
639
+ purpose: string | null;
640
+ model_name: string;
641
+ dimensions: number;
642
+ kind: EmbeddingSetKind;
643
+ mode: EmbeddingSetMode | null;
644
+ truncate_dimension: number | null;
645
+ criteria_json: unknown | null;
646
+ source_json: unknown | null;
647
+ compatibility_json: unknown | null;
648
+ materialization_json: unknown | null;
649
+ freshness_json: unknown | null;
650
+ created_at: Date;
651
+ updated_at: Date;
652
+ }
653
+ interface EmbeddingSetCreateInput {
654
+ id?: string;
655
+ name: string;
656
+ purpose?: string | null;
657
+ model_name?: string;
658
+ dimensions?: number;
659
+ kind?: EmbeddingSetKind;
660
+ mode?: EmbeddingSetMode | null;
661
+ truncate_dimension?: number | null;
662
+ criteria?: EmbeddingSetCriteria | null;
663
+ }
664
+ interface EmbeddingSetEmbeddingInput {
665
+ id?: string;
666
+ note_id: string;
667
+ embedding_set_id: string;
668
+ vector: number[];
669
+ }
670
+ declare class EmbeddingSetsRepository {
671
+ private db;
672
+ constructor(db: QueryExecutor);
673
+ create(input: EmbeddingSetCreateInput): Promise<EmbeddingSetRow>;
674
+ createVirtualDefinition(input: VirtualEmbeddingSetDefinition): Promise<EmbeddingSetRow>;
675
+ ensureDefault(): Promise<EmbeddingSetRow>;
676
+ get(id: string): Promise<EmbeddingSetRow>;
677
+ list(): Promise<EmbeddingSetRow[]>;
678
+ listDescriptors(): Promise<EmbeddingSetDescriptor[]>;
679
+ toDescriptor(row: EmbeddingSetRow): EmbeddingSetDescriptor;
680
+ putEmbedding(input: EmbeddingSetEmbeddingInput): Promise<{
681
+ id: string;
682
+ }>;
683
+ resolveSelector(selector: EmbeddingSetSelector): Promise<ResolvedEmbeddingSet>;
684
+ private resolveDefinition;
685
+ private resolvePhysicalSet;
686
+ private resolvePhysicalRows;
687
+ private resolveCriteriaSource;
688
+ private resolveSetOperationSource;
689
+ private resolveFallbackSource;
690
+ private resolveLatestCompatibleSource;
691
+ private validateCompatibility;
692
+ private resolveDuplicateRows;
693
+ private finalizeResolution;
694
+ private definitionFromRow;
695
+ private inferDefinitionModel;
696
+ private inferDefinitionDimension;
697
+ }
698
+
510
699
  /**
511
700
  * Shared types for repository layer.
512
701
  * All repository methods use these types as inputs and outputs.
@@ -622,6 +811,8 @@ interface SearchOptions {
622
811
  visibility?: string;
623
812
  include_facets?: boolean;
624
813
  mode?: 'text' | 'semantic' | 'hybrid' | 'auto';
814
+ embeddingSetId?: string;
815
+ embeddingSetSelector?: EmbeddingSetSelector;
625
816
  }
626
817
  interface NoteRevision {
627
818
  id: string;
@@ -700,61 +891,169 @@ declare class NotesRepository {
700
891
  }
701
892
 
702
893
  /**
703
- * SearchRepository full-text search using DatabaseClient tsvector/tsquery,
894
+ * SearchRepository - full-text search using DatabaseClient tsvector/tsquery,
704
895
  * with optional semantic search (pgvector) and hybrid (BM25 + vector RRF).
705
- *
706
- * Search strategy:
707
- * - Title match uses the STORED tsvector column (weight A).
708
- * - Content match uses an ad-hoc to_tsvector on note_revised_current.content (weight B).
709
- * - ts_rank combines both weighted vectors to rank title matches higher.
710
- * - ts_headline generates highlighted snippets from content.
711
- * - Empty / whitespace-only queries fall back to returning recent notes.
712
- * - semanticSearch uses pgvector cosine distance (<=>).
713
- * - hybridSearch combines BM25 and vector with Reciprocal Rank Fusion (k=60).
714
- * - Quoted phrases use phraseto_tsquery for exact phrase matching.
715
- *
716
- * @implements #64 semantic and hybrid search
717
- * @implements #77 correct mode field
718
- * @implements #79 date range filter
719
- * @implements #80 starred/archived filters
720
- * @implements #81 format/source/visibility filters
721
- * @implements #82 collection filter on semantic/hybrid
722
- * @implements #83 phrase search
723
- * @implements #87 shared condition builder
724
- * @implements #89 search mode selector
725
- * @implements #94 per-result embedding status
726
896
  */
727
897
 
728
898
  declare class SearchRepository {
729
899
  private db;
730
900
  private semanticAvailable;
731
901
  constructor(db: DatabaseClient, semanticAvailable?: boolean);
732
- /** Select tsquery function based on whether query contains quoted phrases */
733
902
  private tsqueryFn;
734
- /** Returns a Set of note IDs that have an embedding record */
735
903
  private fetchEmbeddingSet;
736
- /** Attach has_embedding to each SearchResult using the provided embedding set */
904
+ private selectorFromOptions;
905
+ private resolveEmbeddingSet;
906
+ private scopeToResolvedEmbeddingSet;
907
+ private scopeToResolvedEmbeddingRows;
908
+ private fetchEmbeddingStatus;
737
909
  private attachEmbeddingStatus;
738
910
  search(query: string, options?: SearchOptions, queryEmbedding?: number[]): Promise<SearchResponse>;
739
- /**
740
- * Semantic search using pgvector cosine distance.
741
- * Returns notes ranked by vector similarity to the query embedding.
742
- */
743
911
  semanticSearch(queryEmbedding: number[], options?: SearchOptions): Promise<SearchResponse>;
744
- /**
745
- * Hybrid search combining BM25 (full-text) and vector similarity using
746
- * Reciprocal Rank Fusion (RRF, k=60).
747
- */
748
912
  hybridSearch(query: string, queryEmbedding: number[], options?: SearchOptions): Promise<SearchResponse>;
749
913
  private recentNotes;
750
- /**
751
- * Fetch faceted aggregate counts for tags and collections across all matching note IDs.
752
- * Uses the full (unpaginated) result set for accurate counts.
753
- */
754
914
  private fetchFacets;
755
915
  private fetchTagMap;
756
916
  }
757
917
 
918
+ interface GraphNode {
919
+ id: string;
920
+ }
921
+ interface GraphEdge {
922
+ source: string;
923
+ target: string;
924
+ weight: number;
925
+ kind?: string;
926
+ }
927
+ interface GraphCommunity {
928
+ id: string;
929
+ nodes: string[];
930
+ }
931
+ interface CommunityGraph {
932
+ nodes: GraphNode[];
933
+ edges: GraphEdge[];
934
+ communities: GraphCommunity[];
935
+ }
936
+ interface SimilarityGraphOptions {
937
+ k?: number;
938
+ minSimilarity?: number;
939
+ threshold?: number;
940
+ }
941
+ interface SimilarityGraphRequest extends SimilarityGraphOptions {
942
+ selector: EmbeddingSetSelector;
943
+ metric?: 'cosine' | 'inner_product' | 'l2';
944
+ source?: 'cache-preferred' | 'live-only' | 'cache-only';
945
+ }
946
+ interface SimilarityGraphCacheKey {
947
+ selectorHash: string;
948
+ resolvedEmbeddingSetId?: string;
949
+ virtualSetId?: string;
950
+ k: number;
951
+ minSimilarity: number;
952
+ metric: 'cosine' | 'inner_product' | 'l2';
953
+ model: string;
954
+ dimension: number;
955
+ truncateDimension?: number | null;
956
+ memberHash: string;
957
+ vectorHash: string;
958
+ parameterHash: string;
959
+ }
960
+ interface SimilarityGraphResult {
961
+ graph: CommunityGraph;
962
+ graphSource: {
963
+ id: string;
964
+ name: string;
965
+ input_hash: string;
966
+ freshness: 'fresh' | 'stale' | 'unknown';
967
+ };
968
+ cache: 'hit' | 'miss-live-built' | 'stale-live-built' | 'live-only';
969
+ freshness: 'fresh' | 'stale' | 'unknown';
970
+ }
971
+ interface CommunityOptions {
972
+ maxIterations?: number;
973
+ }
974
+ declare function detectCommunities(edges: GraphEdge[], nodes?: GraphNode[], options?: CommunityOptions): GraphCommunity[];
975
+ declare class GraphRepository {
976
+ private db;
977
+ constructor(db: QueryExecutor);
978
+ normalizeSimilarityRequest(request: SimilarityGraphRequest): Required<Pick<SimilarityGraphRequest, 'selector' | 'k' | 'minSimilarity' | 'metric' | 'source'>>;
979
+ buildSimilarityGraph(embeddingSet: string | EmbeddingSetSelector, options?: SimilarityGraphOptions): Promise<CommunityGraph>;
980
+ buildSimilarityGraphLive(request: SimilarityGraphRequest): Promise<CommunityGraph>;
981
+ getCachedSimilarityGraph(request: SimilarityGraphRequest): Promise<SimilarityGraphResult | null>;
982
+ buildOrLoadSimilarityGraph(request: SimilarityGraphRequest): Promise<SimilarityGraphResult>;
983
+ saveSimilarityGraphArtifact(input: {
984
+ graph: CommunityGraph;
985
+ request: Required<Pick<SimilarityGraphRequest, 'selector' | 'k' | 'minSimilarity' | 'metric' | 'source'>>;
986
+ resolved: ResolvedEmbeddingSet;
987
+ cacheKey: SimilarityGraphCacheKey;
988
+ freshness?: 'fresh' | 'stale' | 'unknown';
989
+ }): Promise<SimilarityGraphResult['graphSource']>;
990
+ markSimilarityGraphStale(graphSourceId: string, reason: string): Promise<void>;
991
+ loadGraphArtifact(graphSourceId: string, noteIds?: string[]): Promise<CommunityGraph>;
992
+ private buildSimilarityGraphFromResolved;
993
+ private computeSimilarityGraphCacheKey;
994
+ private findGraphSource;
995
+ private graphFromArtifact;
996
+ buildLinkGraph(linkType?: string): Promise<CommunityGraph>;
997
+ }
998
+
999
+ type CommunitySourceType = 'computed' | 'precomputed' | 'dynamic' | 'dynamic-snapshot' | 'user-authored' | 'imported';
1000
+ interface CommunityFilterDefinition {
1001
+ query?: string;
1002
+ tags?: string[];
1003
+ collectionIds?: string[];
1004
+ conceptIds?: string[];
1005
+ noteIds?: string[];
1006
+ embeddingSetSelector?: EmbeddingSetSelector;
1007
+ }
1008
+ interface CommunitySourceDescriptor {
1009
+ id: string;
1010
+ name: string;
1011
+ sourceType: CommunitySourceType;
1012
+ graphSourceId?: string;
1013
+ selector?: EmbeddingSetSelector;
1014
+ searchQuery?: string;
1015
+ filters?: CommunityFilterDefinition;
1016
+ createdAt?: string;
1017
+ updatedAt?: string;
1018
+ freshness?: 'fresh' | 'stale' | 'unknown';
1019
+ }
1020
+ interface CommunityAssignmentView {
1021
+ communitySourceId: string;
1022
+ communityId: string;
1023
+ noteId: string;
1024
+ label?: string | null;
1025
+ confidence?: number | null;
1026
+ sourceType: CommunitySourceType;
1027
+ }
1028
+ interface CommunitySummary {
1029
+ id: string;
1030
+ label: string;
1031
+ sourceType: CommunitySourceType;
1032
+ size: number;
1033
+ confidence?: number | null;
1034
+ representativeNoteIds: string[];
1035
+ freshness?: 'fresh' | 'stale' | 'unknown';
1036
+ }
1037
+ interface CommunityCreateInput {
1038
+ name: string;
1039
+ label?: string;
1040
+ sourceType: 'dynamic-snapshot' | 'user-authored';
1041
+ filters?: CommunityFilterDefinition;
1042
+ noteIds?: string[];
1043
+ representativeNoteIds?: string[];
1044
+ }
1045
+ declare class CommunitiesRepository {
1046
+ private db;
1047
+ constructor(db: DatabaseClient);
1048
+ previewDynamicCommunity(filters: CommunityFilterDefinition): Promise<CommunityAssignmentView[]>;
1049
+ saveCommunity(input: CommunityCreateInput): Promise<CommunitySourceDescriptor>;
1050
+ rerunDynamicCommunity(sourceId: string): Promise<CommunityAssignmentView[]>;
1051
+ listCommunitySources(): Promise<CommunitySourceDescriptor[]>;
1052
+ getCommunityAssignments(sourceId: string): Promise<CommunityAssignmentView[]>;
1053
+ listCommunitySummaries(sourceId: string): Promise<CommunitySummary[]>;
1054
+ private resolveFilterNoteIds;
1055
+ }
1056
+
758
1057
  /**
759
1058
  * Shared SQL condition builder for note filtering.
760
1059
  * Used by both SearchRepository and NotesRepository to prevent drift
@@ -1293,9 +1592,9 @@ declare const ListNotesInputSchema: z.ZodObject<{
1293
1592
  collection_id: z.ZodOptional<z.ZodString>;
1294
1593
  include_deleted: z.ZodOptional<z.ZodBoolean>;
1295
1594
  }, "strip", z.ZodTypeAny, {
1595
+ sort: "created_at" | "updated_at" | "title";
1296
1596
  limit: number;
1297
1597
  offset: number;
1298
- sort: "created_at" | "updated_at" | "title";
1299
1598
  order: "asc" | "desc";
1300
1599
  is_starred?: boolean | undefined;
1301
1600
  is_archived?: boolean | undefined;
@@ -1303,12 +1602,12 @@ declare const ListNotesInputSchema: z.ZodObject<{
1303
1602
  include_deleted?: boolean | undefined;
1304
1603
  collection_id?: string | undefined;
1305
1604
  }, {
1605
+ sort?: "created_at" | "updated_at" | "title" | undefined;
1306
1606
  is_starred?: boolean | undefined;
1307
1607
  is_archived?: boolean | undefined;
1308
1608
  tags?: string[] | undefined;
1309
1609
  limit?: number | undefined;
1310
1610
  offset?: number | undefined;
1311
- sort?: "created_at" | "updated_at" | "title" | undefined;
1312
1611
  order?: "asc" | "desc" | undefined;
1313
1612
  include_deleted?: boolean | undefined;
1314
1613
  collection_id?: string | undefined;
@@ -2092,7 +2391,7 @@ declare function createCspReportHandler(onReport: (report: CspViolationReport) =
2092
2391
  declare const CURRENT_SHARD_VERSION = "1.0.0";
2093
2392
  declare const SHARD_FORMAT = "matric-shard";
2094
2393
  /** Components that can appear in a shard archive. */
2095
- type ShardComponent = 'notes' | 'collections' | 'tags' | 'links' | 'embedding_sets' | 'embedding_set_members' | 'embedding_configs' | 'embeddings';
2394
+ type ShardComponent = 'notes' | 'collections' | 'tags' | 'links' | 'embedding_sets' | 'embedding_set_members' | 'embedding_configs' | 'embeddings' | 'skos_schemes' | 'skos_concepts' | 'skos_relations' | 'note_skos_tags' | 'provenance_edges' | 'community_assignments' | 'communities' | 'graph_edges' | 'graph_sources';
2096
2395
  /** Manifest included in every shard as manifest.json. */
2097
2396
  interface ShardManifest {
2098
2397
  version: string;
@@ -2100,7 +2399,7 @@ interface ShardManifest {
2100
2399
  format: typeof SHARD_FORMAT;
2101
2400
  created_at: string;
2102
2401
  components: ShardComponent[];
2103
- counts: Partial<Record<ShardComponent, number>>;
2402
+ counts: Partial<Record<ShardComponent | 'community_sets', number>>;
2104
2403
  checksums: Record<string, string>;
2105
2404
  min_reader_version: string;
2106
2405
  }
@@ -2127,6 +2426,16 @@ interface ImportCounts {
2127
2426
  embedding_sets: number;
2128
2427
  embedding_set_members: number;
2129
2428
  embeddings: number;
2429
+ skos_schemes: number;
2430
+ skos_concepts: number;
2431
+ skos_relations: number;
2432
+ note_skos_tags: number;
2433
+ provenance_edges: number;
2434
+ graph_sources: number;
2435
+ graph_edges: number;
2436
+ community_sets: number;
2437
+ communities: number;
2438
+ community_assignments: number;
2130
2439
  }
2131
2440
  /** Result of a shard import operation. */
2132
2441
  interface ImportResult {
@@ -2179,9 +2488,20 @@ interface ShardLink {
2179
2488
  /** Embedding set as serialized in the shard JSON array. */
2180
2489
  interface ShardEmbeddingSet {
2181
2490
  id: string;
2491
+ name?: string;
2492
+ purpose?: string | null;
2182
2493
  model: string;
2183
2494
  dimension: number;
2495
+ kind?: 'physical' | 'filter' | 'virtual';
2496
+ mode?: 'auto' | 'manual' | 'mixed' | null;
2497
+ truncate_dimension?: number | null;
2498
+ criteria?: Record<string, unknown> | null;
2499
+ source?: Record<string, unknown> | null;
2500
+ compatibility?: Record<string, unknown> | null;
2501
+ materialization?: Record<string, unknown> | null;
2502
+ freshness?: ShardArtifactFreshness | null;
2184
2503
  created_at: string;
2504
+ updated_at?: string;
2185
2505
  }
2186
2506
  /** Embedding set member as serialized in the shard JSONL. */
2187
2507
  interface ShardEmbeddingSetMember {
@@ -2197,6 +2517,63 @@ interface ShardEmbedding {
2197
2517
  vector: number[];
2198
2518
  created_at: string;
2199
2519
  }
2520
+ /** SKOS scheme as serialized in the shard JSON array. */
2521
+ interface ShardSkosScheme {
2522
+ id: string;
2523
+ title: string;
2524
+ description: string | null;
2525
+ created_at: string;
2526
+ updated_at: string;
2527
+ }
2528
+ /** SKOS concept as serialized in the shard JSON array. */
2529
+ interface ShardSkosConcept {
2530
+ id: string;
2531
+ scheme_id: string;
2532
+ pref_label: string;
2533
+ alt_labels: string[];
2534
+ definition: string | null;
2535
+ created_at: string;
2536
+ updated_at: string;
2537
+ }
2538
+ /** SKOS concept relation as serialized in the shard JSONL. */
2539
+ interface ShardSkosRelation {
2540
+ id: string;
2541
+ source_concept_id: string;
2542
+ target_concept_id: string;
2543
+ relation_type: 'broader' | 'narrower' | 'related';
2544
+ created_at: string;
2545
+ }
2546
+ /** Note-to-SKOS-concept assignment as serialized in the shard JSONL. */
2547
+ interface ShardNoteSkosTag {
2548
+ id: string;
2549
+ note_id: string;
2550
+ concept_id: string;
2551
+ created_at: string;
2552
+ }
2553
+ /** Provenance edge as serialized in the shard JSONL. */
2554
+ interface ShardProvenanceEdge {
2555
+ id: string;
2556
+ entity_type: string;
2557
+ entity_id: string;
2558
+ activity: string;
2559
+ agent: string;
2560
+ started_at: string;
2561
+ ended_at: string | null;
2562
+ attributes: Record<string, unknown> | null;
2563
+ }
2564
+ interface ShardArtifactFreshness {
2565
+ status: 'fresh' | 'stale' | 'unknown';
2566
+ checked_at?: string;
2567
+ stale_reason?: string;
2568
+ source_hashes?: {
2569
+ notes?: string;
2570
+ links?: string;
2571
+ embeddings?: string;
2572
+ embedding_set_members?: string;
2573
+ virtual_set_definition?: string;
2574
+ parameters?: string;
2575
+ };
2576
+ }
2200
2577
 
2201
2578
  /**
2202
2579
  * Minimal tar + gzip packing/unpacking for shard archives.
@@ -2301,16 +2678,38 @@ declare function tagsFromShard(shardTags: ShardTag[]): string[];
2301
2678
  /** Convert a browser embedding_set to shard format. */
2302
2679
  declare function embeddingSetToShard(set: {
2303
2680
  id: string;
2681
+ name?: string;
2682
+ purpose?: string | null;
2304
2683
  model_name: string;
2305
2684
  dimensions: number;
2685
+ kind?: 'physical' | 'filter' | 'virtual';
2686
+ mode?: 'auto' | 'manual' | 'mixed' | null;
2687
+ truncate_dimension?: number | null;
2688
+ criteria_json?: unknown | null;
2689
+ source_json?: unknown | null;
2690
+ compatibility_json?: unknown | null;
2691
+ materialization_json?: unknown | null;
2692
+ freshness_json?: unknown | null;
2306
2693
  created_at: Date | string;
2694
+ updated_at?: Date | string;
2307
2695
  }): ShardEmbeddingSet;
2308
2696
  /** Convert a shard embedding set back to browser format. */
2309
2697
  declare function embeddingSetFromShard(shard: ShardEmbeddingSet): {
2310
2698
  id: string;
2699
+ name: string;
2700
+ purpose: string | null;
2311
2701
  model_name: string;
2312
2702
  dimensions: number;
2703
+ kind: 'physical' | 'filter' | 'virtual';
2704
+ mode: 'auto' | 'manual' | 'mixed' | null;
2705
+ truncate_dimension: number | null;
2706
+ criteria_json: string | null;
2707
+ source_json: string | null;
2708
+ compatibility_json: string | null;
2709
+ materialization_json: string | null;
2710
+ freshness_json: string | null;
2313
2711
  created_at: string;
2712
+ updated_at: string | null;
2314
2713
  };
2315
2714
  /** Convert a browser embedding_set_member to shard format. */
2316
2715
  declare function embeddingSetMemberToShard(member: {
@@ -2334,6 +2733,45 @@ declare function embeddingFromShard(shard: ShardEmbedding): {
2334
2733
  vector: string;
2335
2734
  created_at: string;
2336
2735
  };
2736
+ declare function skosSchemeToShard(scheme: {
2737
+ id: string;
2738
+ title: string;
2739
+ description: string | null;
2740
+ created_at: Date | string;
2741
+ updated_at: Date | string;
2742
+ }): ShardSkosScheme;
2743
+ declare function skosConceptToShard(concept: {
2744
+ id: string;
2745
+ scheme_id: string;
2746
+ pref_label: string;
2747
+ alt_labels: string[] | string | null;
2748
+ definition: string | null;
2749
+ created_at: Date | string;
2750
+ updated_at: Date | string;
2751
+ }): ShardSkosConcept;
2752
+ declare function skosRelationToShard(relation: {
2753
+ id: string;
2754
+ source_concept_id: string;
2755
+ target_concept_id: string;
2756
+ relation_type: 'broader' | 'narrower' | 'related';
2757
+ created_at: Date | string;
2758
+ }): ShardSkosRelation;
2759
+ declare function noteSkosTagToShard(tag: {
2760
+ id: string;
2761
+ note_id: string;
2762
+ concept_id: string;
2763
+ created_at: Date | string;
2764
+ }): ShardNoteSkosTag;
2765
+ declare function provenanceEdgeToShard(edge: {
2766
+ id: string;
2767
+ entity_type: string;
2768
+ entity_id: string;
2769
+ activity: string;
2770
+ agent: string;
2771
+ started_at: Date | string;
2772
+ ended_at: Date | string | null;
2773
+ attributes: Record<string, unknown> | string | null;
2774
+ }): ShardProvenanceEdge;
2337
2775
 
2338
2776
  /**
2339
2777
  * Shard export pipeline — query all entities, serialize, pack into .shard archive.
@@ -2370,6 +2808,6 @@ declare function exportShard(db: DatabaseClient, options?: ExportOptions): Promi
2370
2808
  */
2371
2809
  declare function importShard(db: DatabaseClient, data: Uint8Array | ArrayBuffer, options?: ImportOptions): Promise<ImportResult>;
2372
2810
 
2373
- declare const VERSION = "2026.5.3";
2811
+ declare const VERSION = "2026.5.4";
2374
2812
 
2375
- export { type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRow, type AttachmentRow, AttachmentsRepository, type BlobStore, type BridgeCapability, type BrowserNoteExport, CURRENT_SHARD_VERSION, type CapabilityInfo, CapabilityManager, type CapabilityName, type CapabilityState, type CaptureKnowledgeInput, CaptureKnowledgeInputSchema, type CaptureKnowledgeResult, type CollectionCreateInput, type CollectionRow, CollectionsRepository, type CompletionRequest, type CompletionResponse, type ConditionResult, type ConflictStrategy, type CooldownConfig, type CooldownEvent, type CspDirectiveName, type CspDirectives, type CspViolationReport, type DatabaseClient, type DiscoveredProvider, type DiscoveryOptions, type EmbedFunction, type EmbedRequest, type EmbedResponse, type EnqueueJobInput, type ErrorCategory, type EventMap, type ExportOptions, type FallbackEvent, FallbackRouter, type FallbackRouterConfig, type FortemiConfig, type FortemiCore, type FortemiToolDefinition, FortemiToolManifest, type GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type IDisposable, type ImportCounts, type ImportOptions, type ImportResult, type InferenceCapabilities, type InferenceProvider, JOB_CAPABILITIES, JOB_PRIORITIES, type JobQueueOptions, JobQueueWorker, type JobStatus, type JobType, LOCAL_ENDPOINTS, type LinkRow, LinksRepository, type ListNotesInput, ListNotesInputSchema, type LlmCapabilityOptions, type LlmCompleteFn, 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, MemoryBlobStore, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteRevision, type NoteSummary, type NoteUpdateInput, NotesRepository, OpenAICompatibleProvider, type OpenAIProviderConfig, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, type PaginatedResult, type PersistenceMode, type PluginCspOptions, type PluginScriptDescriptor, type PluginScriptPolicy, type ProbeResult, type ProbeStatus, type ProviderCapabilities, ProviderRegistry, type ProviderTier, type QueryExecutor, type QueryResult, type RecommendedTier, type RouteHandler, SHARD_FORMAT, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, type ShardCollection, type ShardComponent, type ShardEmbedding, type ShardEmbeddingSet, type ShardEmbeddingSetMember, type ShardLink, type ShardManifest, type ShardNote, type ShardTag, type SkosConcept, type SkosRelation, SkosRepository, type SkosScheme, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, TagsRepository, TransactionProxy, TypedEventBus, VERSION, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, allMigrations, appendPluginScript, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createBlobStore, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteInstance, createRoutes, defaultStorageBackendFactory, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchPluginScript, fortemiManifest, generateId, getEmbedFunction, getJobQueueStatus, getLlmFunction, getNote, importShard, isPluginScriptAllowed, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteToShard, packTarGz, parseCspReport, registerLlmCapability, registerSemanticCapability, registerServiceWorker, searchTool, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateChecksums, verifySri };
2813
+ export { type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRow, type AttachmentRow, AttachmentsRepository, type BlobStore, type BridgeCapability, type BrowserNoteExport, CURRENT_SHARD_VERSION, type CapabilityInfo, CapabilityManager, type CapabilityName, type CapabilityState, type CaptureKnowledgeInput, CaptureKnowledgeInputSchema, type CaptureKnowledgeResult, type CollectionCreateInput, type CollectionRow, CollectionsRepository, CommunitiesRepository, type CommunityAssignmentView, type CommunityCreateInput, type CommunityFilterDefinition, type CommunityGraph, type CommunityOptions, type CommunitySourceDescriptor, type CommunitySourceType, type CommunitySummary, type CompletionRequest, type CompletionResponse, type ConditionResult, type ConflictStrategy, type CooldownConfig, type CooldownEvent, type CspDirectiveName, type CspDirectives, type CspViolationReport, type DatabaseClient, type DiscoveredProvider, type DiscoveryOptions, type EmbedFunction, type EmbedRequest, type EmbedResponse, type EmbeddingCompatibilityPolicy, type EmbeddingSetCreateInput, type EmbeddingSetCriteria, type EmbeddingSetDescriptor, type EmbeddingSetEmbeddingInput, type EmbeddingSetFreshness, type EmbeddingSetKind, type EmbeddingSetMode, type EmbeddingSetRow, type EmbeddingSetSelector, EmbeddingSetsRepository, type EnqueueJobInput, type ErrorCategory, type EventMap, type ExportOptions, type FallbackEvent, FallbackRouter, type FallbackRouterConfig, type FortemiConfig, type FortemiCore, type FortemiToolDefinition, FortemiToolManifest, type GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type GraphNode, GraphRepository, type IDisposable, type ImportCounts, type ImportOptions, type ImportResult, type InferenceCapabilities, type InferenceProvider, JOB_CAPABILITIES, JOB_PRIORITIES, type JobQueueOptions, JobQueueWorker, type JobStatus, type JobType, LOCAL_ENDPOINTS, type LinkRow, LinksRepository, type ListNotesInput, ListNotesInputSchema, type LlmCapabilityOptions, type LlmCompleteFn, 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, MemoryBlobStore, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteRevision, type NoteSummary, type NoteUpdateInput, NotesRepository, OpenAICompatibleProvider, type OpenAIProviderConfig, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, type PaginatedResult, type PersistenceMode, type PluginCspOptions, type PluginScriptDescriptor, type PluginScriptPolicy, type ProbeResult, type ProbeStatus, type ProviderCapabilities, ProviderRegistry, type ProviderTier, type QueryExecutor, type QueryResult, type RecommendedTier, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RouteHandler, SHARD_FORMAT, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, type ShardCollection, type ShardComponent, type ShardEmbedding, type ShardEmbeddingSet, type ShardEmbeddingSetMember, type ShardLink, type ShardManifest, type ShardNote, type ShardNoteSkosTag, type ShardProvenanceEdge, type ShardSkosConcept, type ShardSkosRelation, type ShardSkosScheme, type ShardTag, type SimilarityGraphCacheKey, type SimilarityGraphOptions, type SimilarityGraphRequest, type SimilarityGraphResult, type SkosConcept, type SkosRelation, SkosRepository, type SkosScheme, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, TagsRepository, TransactionProxy, TypedEventBus, VERSION, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, allMigrations, appendPluginScript, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createBlobStore, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteInstance, createRoutes, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchPluginScript, fortemiManifest, generateId, getEmbedFunction, getJobQueueStatus, getLlmFunction, getNote, importShard, isPluginScriptAllowed, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, packTarGz, parseCspReport, provenanceEdgeToShard, registerLlmCapability, registerSemanticCapability, registerServiceWorker, searchTool, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateChecksums, verifySri };