@fortemi/core 2026.5.3 → 2026.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -52,6 +52,13 @@ interface EventMap {
52
52
  name: string;
53
53
  progress?: number;
54
54
  };
55
+ 'capability.required': {
56
+ name: string;
57
+ jobId: string;
58
+ noteId: string;
59
+ type: string;
60
+ message: string;
61
+ };
55
62
  'job.completed': {
56
63
  id: string;
57
64
  noteId: string;
@@ -63,6 +70,13 @@ interface EventMap {
63
70
  type: string;
64
71
  error: string;
65
72
  };
73
+ 'job.blocked': {
74
+ id: string;
75
+ noteId: string;
76
+ type: string;
77
+ capability: string;
78
+ message: string;
79
+ };
66
80
  'archive.switched': {
67
81
  name: string;
68
82
  };
@@ -507,6 +521,195 @@ declare class TransactionProxy {
507
521
  exec(sql: string): Promise<void>;
508
522
  }
509
523
 
524
+ /**
525
+ * EmbeddingSetsRepository - named, filter, and virtual embedding set API.
526
+ */
527
+
528
+ type EmbeddingSetKind = 'physical' | 'filter' | 'virtual';
529
+ type EmbeddingSetMode = 'auto' | 'manual' | 'mixed';
530
+ interface EmbeddingSetCriteria {
531
+ query?: string;
532
+ tags?: string[];
533
+ collectionIds?: string[];
534
+ conceptIds?: string[];
535
+ noteIds?: string[];
536
+ updatedAfter?: string;
537
+ updatedBefore?: string;
538
+ }
539
+ interface EmbeddingSetFreshness {
540
+ status: 'fresh' | 'stale' | 'unknown';
541
+ sourceHash?: string;
542
+ checkedAt?: string;
543
+ reason?: string;
544
+ }
545
+ interface EmbeddingCompatibilityPolicy {
546
+ model: 'require-same' | 'allow-compatible-family';
547
+ dimension: 'require-same' | 'allow-truncation';
548
+ duplicateVectors: 'prefer-latest' | 'prefer-set-order' | 'error';
549
+ missingVectors: 'omit' | 'include-unembedded-note' | 'error';
550
+ }
551
+ interface VirtualMaterializationPolicy {
552
+ allowed: boolean;
553
+ includeResolvedMembers?: boolean;
554
+ includeResolvedEdges?: boolean;
555
+ freshness: 'fresh' | 'stale' | 'unknown';
556
+ }
557
+ interface CriteriaVirtualSource {
558
+ type: 'criteria';
559
+ baseSetId: string;
560
+ criteria: EmbeddingSetCriteria;
561
+ }
562
+ interface SetOperationVirtualSource {
563
+ type: 'set-operation';
564
+ operation: 'union' | 'intersection' | 'difference';
565
+ setIds: string[];
566
+ }
567
+ interface FallbackVirtualSource {
568
+ type: 'fallback';
569
+ preferredSetIds: string[];
570
+ }
571
+ interface LatestCompatibleVirtualSource {
572
+ type: 'latest-compatible';
573
+ candidateSetIds: string[];
574
+ model?: string;
575
+ dimension?: number;
576
+ }
577
+ interface SnapshotVirtualSource {
578
+ type: 'snapshot';
579
+ snapshotId: string;
580
+ sourceDefinitionId: string;
581
+ generatedAt: string;
582
+ inputHash: string;
583
+ }
584
+ type VirtualEmbeddingSetSource = CriteriaVirtualSource | SetOperationVirtualSource | FallbackVirtualSource | LatestCompatibleVirtualSource | SnapshotVirtualSource;
585
+ interface VirtualEmbeddingSetDefinition {
586
+ id: string;
587
+ name: string;
588
+ purpose?: string | null;
589
+ source: VirtualEmbeddingSetSource;
590
+ compatibility: EmbeddingCompatibilityPolicy;
591
+ materialization?: VirtualMaterializationPolicy;
592
+ createdAt?: string;
593
+ updatedAt?: string;
594
+ }
595
+ interface EmbeddingSetSelector {
596
+ kind: 'default' | 'embedding-set' | 'virtual-definition';
597
+ embeddingSetId?: string;
598
+ definition?: VirtualEmbeddingSetDefinition;
599
+ }
600
+ interface EmbeddingSetDescriptor {
601
+ id: string;
602
+ name: string;
603
+ purpose?: string | null;
604
+ kind: EmbeddingSetKind;
605
+ mode?: EmbeddingSetMode;
606
+ model?: string;
607
+ dimension?: number;
608
+ truncateDimension?: number | null;
609
+ criteria?: EmbeddingSetCriteria | null;
610
+ createdAt?: string;
611
+ updatedAt?: string;
612
+ freshness?: EmbeddingSetFreshness;
613
+ }
614
+ type VirtualEmbeddingSetValidationError = {
615
+ code: 'mixed-models';
616
+ setIds: string[];
617
+ } | {
618
+ code: 'mixed-dimensions';
619
+ setIds: string[];
620
+ } | {
621
+ code: 'missing-vector';
622
+ noteId: string;
623
+ setId: string;
624
+ } | {
625
+ code: 'duplicate-vector';
626
+ noteId: string;
627
+ setIds: string[];
628
+ } | {
629
+ code: 'stale-snapshot';
630
+ snapshotId: string;
631
+ } | {
632
+ code: 'unsupported-criteria';
633
+ field: string;
634
+ };
635
+ interface ResolvedEmbeddingRow {
636
+ note_id: string;
637
+ embedding_set_id: string;
638
+ embedding_id: string;
639
+ vector: string;
640
+ created_at: Date;
641
+ }
642
+ interface ResolvedEmbeddingSet {
643
+ selector: EmbeddingSetSelector;
644
+ rows: ResolvedEmbeddingRow[];
645
+ noteIds: string[];
646
+ embeddingIds: string[];
647
+ errors: VirtualEmbeddingSetValidationError[];
648
+ freshness: EmbeddingSetFreshness;
649
+ }
650
+ interface EmbeddingSetRow {
651
+ id: string;
652
+ name: string;
653
+ purpose: string | null;
654
+ model_name: string;
655
+ dimensions: number;
656
+ kind: EmbeddingSetKind;
657
+ mode: EmbeddingSetMode | null;
658
+ truncate_dimension: number | null;
659
+ criteria_json: unknown | null;
660
+ source_json: unknown | null;
661
+ compatibility_json: unknown | null;
662
+ materialization_json: unknown | null;
663
+ freshness_json: unknown | null;
664
+ created_at: Date;
665
+ updated_at: Date;
666
+ }
667
+ interface EmbeddingSetCreateInput {
668
+ id?: string;
669
+ name: string;
670
+ purpose?: string | null;
671
+ model_name?: string;
672
+ dimensions?: number;
673
+ kind?: EmbeddingSetKind;
674
+ mode?: EmbeddingSetMode | null;
675
+ truncate_dimension?: number | null;
676
+ criteria?: EmbeddingSetCriteria | null;
677
+ }
678
+ interface EmbeddingSetEmbeddingInput {
679
+ id?: string;
680
+ note_id: string;
681
+ embedding_set_id: string;
682
+ vector: number[];
683
+ }
684
+ declare class EmbeddingSetsRepository {
685
+ private db;
686
+ constructor(db: QueryExecutor);
687
+ create(input: EmbeddingSetCreateInput): Promise<EmbeddingSetRow>;
688
+ createVirtualDefinition(input: VirtualEmbeddingSetDefinition): Promise<EmbeddingSetRow>;
689
+ ensureDefault(): Promise<EmbeddingSetRow>;
690
+ get(id: string): Promise<EmbeddingSetRow>;
691
+ list(): Promise<EmbeddingSetRow[]>;
692
+ listDescriptors(): Promise<EmbeddingSetDescriptor[]>;
693
+ toDescriptor(row: EmbeddingSetRow): EmbeddingSetDescriptor;
694
+ putEmbedding(input: EmbeddingSetEmbeddingInput): Promise<{
695
+ id: string;
696
+ }>;
697
+ resolveSelector(selector: EmbeddingSetSelector): Promise<ResolvedEmbeddingSet>;
698
+ private resolveDefinition;
699
+ private resolvePhysicalSet;
700
+ private resolvePhysicalRows;
701
+ private resolveCriteriaSource;
702
+ private resolveSetOperationSource;
703
+ private resolveFallbackSource;
704
+ private resolveLatestCompatibleSource;
705
+ private validateCompatibility;
706
+ private resolveDuplicateRows;
707
+ private finalizeResolution;
708
+ private definitionFromRow;
709
+ private inferDefinitionModel;
710
+ private inferDefinitionDimension;
711
+ }
712
+
510
713
  /**
511
714
  * Shared types for repository layer.
512
715
  * All repository methods use these types as inputs and outputs.
@@ -622,6 +825,8 @@ interface SearchOptions {
622
825
  visibility?: string;
623
826
  include_facets?: boolean;
624
827
  mode?: 'text' | 'semantic' | 'hybrid' | 'auto';
828
+ embeddingSetId?: string;
829
+ embeddingSetSelector?: EmbeddingSetSelector;
625
830
  }
626
831
  interface NoteRevision {
627
832
  id: string;
@@ -700,61 +905,169 @@ declare class NotesRepository {
700
905
  }
701
906
 
702
907
  /**
703
- * SearchRepository full-text search using DatabaseClient tsvector/tsquery,
908
+ * SearchRepository - full-text search using DatabaseClient tsvector/tsquery,
704
909
  * 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
910
  */
727
911
 
728
912
  declare class SearchRepository {
729
913
  private db;
730
914
  private semanticAvailable;
731
915
  constructor(db: DatabaseClient, semanticAvailable?: boolean);
732
- /** Select tsquery function based on whether query contains quoted phrases */
733
916
  private tsqueryFn;
734
- /** Returns a Set of note IDs that have an embedding record */
735
917
  private fetchEmbeddingSet;
736
- /** Attach has_embedding to each SearchResult using the provided embedding set */
918
+ private selectorFromOptions;
919
+ private resolveEmbeddingSet;
920
+ private scopeToResolvedEmbeddingSet;
921
+ private scopeToResolvedEmbeddingRows;
922
+ private fetchEmbeddingStatus;
737
923
  private attachEmbeddingStatus;
738
924
  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
925
  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
926
  hybridSearch(query: string, queryEmbedding: number[], options?: SearchOptions): Promise<SearchResponse>;
749
927
  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
928
  private fetchFacets;
755
929
  private fetchTagMap;
756
930
  }
757
931
 
932
+ interface GraphNode {
933
+ id: string;
934
+ }
935
+ interface GraphEdge {
936
+ source: string;
937
+ target: string;
938
+ weight: number;
939
+ kind?: string;
940
+ }
941
+ interface GraphCommunity {
942
+ id: string;
943
+ nodes: string[];
944
+ }
945
+ interface CommunityGraph {
946
+ nodes: GraphNode[];
947
+ edges: GraphEdge[];
948
+ communities: GraphCommunity[];
949
+ }
950
+ interface SimilarityGraphOptions {
951
+ k?: number;
952
+ minSimilarity?: number;
953
+ threshold?: number;
954
+ }
955
+ interface SimilarityGraphRequest extends SimilarityGraphOptions {
956
+ selector: EmbeddingSetSelector;
957
+ metric?: 'cosine' | 'inner_product' | 'l2';
958
+ source?: 'cache-preferred' | 'live-only' | 'cache-only';
959
+ }
960
+ interface SimilarityGraphCacheKey {
961
+ selectorHash: string;
962
+ resolvedEmbeddingSetId?: string;
963
+ virtualSetId?: string;
964
+ k: number;
965
+ minSimilarity: number;
966
+ metric: 'cosine' | 'inner_product' | 'l2';
967
+ model: string;
968
+ dimension: number;
969
+ truncateDimension?: number | null;
970
+ memberHash: string;
971
+ vectorHash: string;
972
+ parameterHash: string;
973
+ }
974
+ interface SimilarityGraphResult {
975
+ graph: CommunityGraph;
976
+ graphSource: {
977
+ id: string;
978
+ name: string;
979
+ input_hash: string;
980
+ freshness: 'fresh' | 'stale' | 'unknown';
981
+ };
982
+ cache: 'hit' | 'miss-live-built' | 'stale-live-built' | 'live-only';
983
+ freshness: 'fresh' | 'stale' | 'unknown';
984
+ }
985
+ interface CommunityOptions {
986
+ maxIterations?: number;
987
+ }
988
+ declare function detectCommunities(edges: GraphEdge[], nodes?: GraphNode[], options?: CommunityOptions): GraphCommunity[];
989
+ declare class GraphRepository {
990
+ private db;
991
+ constructor(db: QueryExecutor);
992
+ normalizeSimilarityRequest(request: SimilarityGraphRequest): Required<Pick<SimilarityGraphRequest, 'selector' | 'k' | 'minSimilarity' | 'metric' | 'source'>>;
993
+ buildSimilarityGraph(embeddingSet: string | EmbeddingSetSelector, options?: SimilarityGraphOptions): Promise<CommunityGraph>;
994
+ buildSimilarityGraphLive(request: SimilarityGraphRequest): Promise<CommunityGraph>;
995
+ getCachedSimilarityGraph(request: SimilarityGraphRequest): Promise<SimilarityGraphResult | null>;
996
+ buildOrLoadSimilarityGraph(request: SimilarityGraphRequest): Promise<SimilarityGraphResult>;
997
+ saveSimilarityGraphArtifact(input: {
998
+ graph: CommunityGraph;
999
+ request: Required<Pick<SimilarityGraphRequest, 'selector' | 'k' | 'minSimilarity' | 'metric' | 'source'>>;
1000
+ resolved: ResolvedEmbeddingSet;
1001
+ cacheKey: SimilarityGraphCacheKey;
1002
+ freshness?: 'fresh' | 'stale' | 'unknown';
1003
+ }): Promise<SimilarityGraphResult['graphSource']>;
1004
+ markSimilarityGraphStale(graphSourceId: string, reason: string): Promise<void>;
1005
+ loadGraphArtifact(graphSourceId: string, noteIds?: string[]): Promise<CommunityGraph>;
1006
+ private buildSimilarityGraphFromResolved;
1007
+ private computeSimilarityGraphCacheKey;
1008
+ private findGraphSource;
1009
+ private graphFromArtifact;
1010
+ buildLinkGraph(linkType?: string): Promise<CommunityGraph>;
1011
+ }
1012
+
1013
+ type CommunitySourceType = 'computed' | 'precomputed' | 'dynamic' | 'dynamic-snapshot' | 'user-authored' | 'imported';
1014
+ interface CommunityFilterDefinition {
1015
+ query?: string;
1016
+ tags?: string[];
1017
+ collectionIds?: string[];
1018
+ conceptIds?: string[];
1019
+ noteIds?: string[];
1020
+ embeddingSetSelector?: EmbeddingSetSelector;
1021
+ }
1022
+ interface CommunitySourceDescriptor {
1023
+ id: string;
1024
+ name: string;
1025
+ sourceType: CommunitySourceType;
1026
+ graphSourceId?: string;
1027
+ selector?: EmbeddingSetSelector;
1028
+ searchQuery?: string;
1029
+ filters?: CommunityFilterDefinition;
1030
+ createdAt?: string;
1031
+ updatedAt?: string;
1032
+ freshness?: 'fresh' | 'stale' | 'unknown';
1033
+ }
1034
+ interface CommunityAssignmentView {
1035
+ communitySourceId: string;
1036
+ communityId: string;
1037
+ noteId: string;
1038
+ label?: string | null;
1039
+ confidence?: number | null;
1040
+ sourceType: CommunitySourceType;
1041
+ }
1042
+ interface CommunitySummary {
1043
+ id: string;
1044
+ label: string;
1045
+ sourceType: CommunitySourceType;
1046
+ size: number;
1047
+ confidence?: number | null;
1048
+ representativeNoteIds: string[];
1049
+ freshness?: 'fresh' | 'stale' | 'unknown';
1050
+ }
1051
+ interface CommunityCreateInput {
1052
+ name: string;
1053
+ label?: string;
1054
+ sourceType: 'dynamic-snapshot' | 'user-authored';
1055
+ filters?: CommunityFilterDefinition;
1056
+ noteIds?: string[];
1057
+ representativeNoteIds?: string[];
1058
+ }
1059
+ declare class CommunitiesRepository {
1060
+ private db;
1061
+ constructor(db: DatabaseClient);
1062
+ previewDynamicCommunity(filters: CommunityFilterDefinition): Promise<CommunityAssignmentView[]>;
1063
+ saveCommunity(input: CommunityCreateInput): Promise<CommunitySourceDescriptor>;
1064
+ rerunDynamicCommunity(sourceId: string): Promise<CommunityAssignmentView[]>;
1065
+ listCommunitySources(): Promise<CommunitySourceDescriptor[]>;
1066
+ getCommunityAssignments(sourceId: string): Promise<CommunityAssignmentView[]>;
1067
+ listCommunitySummaries(sourceId: string): Promise<CommunitySummary[]>;
1068
+ private resolveFilterNoteIds;
1069
+ }
1070
+
758
1071
  /**
759
1072
  * Shared SQL condition builder for note filtering.
760
1073
  * Used by both SearchRepository and NotesRepository to prevent drift
@@ -878,6 +1191,7 @@ declare class JobQueueWorker {
878
1191
  processOnce(): Promise<number>;
879
1192
  private poll;
880
1193
  private processPendingJobs;
1194
+ private blockForCapability;
881
1195
  getBackoffDelay(retryCount: number): number;
882
1196
  }
883
1197
  /** Title generation: LLM first, fallback to first-line extraction */
@@ -1293,9 +1607,9 @@ declare const ListNotesInputSchema: z.ZodObject<{
1293
1607
  collection_id: z.ZodOptional<z.ZodString>;
1294
1608
  include_deleted: z.ZodOptional<z.ZodBoolean>;
1295
1609
  }, "strip", z.ZodTypeAny, {
1610
+ sort: "created_at" | "updated_at" | "title";
1296
1611
  limit: number;
1297
1612
  offset: number;
1298
- sort: "created_at" | "updated_at" | "title";
1299
1613
  order: "asc" | "desc";
1300
1614
  is_starred?: boolean | undefined;
1301
1615
  is_archived?: boolean | undefined;
@@ -1303,12 +1617,12 @@ declare const ListNotesInputSchema: z.ZodObject<{
1303
1617
  include_deleted?: boolean | undefined;
1304
1618
  collection_id?: string | undefined;
1305
1619
  }, {
1620
+ sort?: "created_at" | "updated_at" | "title" | undefined;
1306
1621
  is_starred?: boolean | undefined;
1307
1622
  is_archived?: boolean | undefined;
1308
1623
  tags?: string[] | undefined;
1309
1624
  limit?: number | undefined;
1310
1625
  offset?: number | undefined;
1311
- sort?: "created_at" | "updated_at" | "title" | undefined;
1312
1626
  order?: "asc" | "desc" | undefined;
1313
1627
  include_deleted?: boolean | undefined;
1314
1628
  collection_id?: string | undefined;
@@ -2092,7 +2406,7 @@ declare function createCspReportHandler(onReport: (report: CspViolationReport) =
2092
2406
  declare const CURRENT_SHARD_VERSION = "1.0.0";
2093
2407
  declare const SHARD_FORMAT = "matric-shard";
2094
2408
  /** Components that can appear in a shard archive. */
2095
- type ShardComponent = 'notes' | 'collections' | 'tags' | 'links' | 'embedding_sets' | 'embedding_set_members' | 'embedding_configs' | 'embeddings';
2409
+ 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
2410
  /** Manifest included in every shard as manifest.json. */
2097
2411
  interface ShardManifest {
2098
2412
  version: string;
@@ -2100,7 +2414,7 @@ interface ShardManifest {
2100
2414
  format: typeof SHARD_FORMAT;
2101
2415
  created_at: string;
2102
2416
  components: ShardComponent[];
2103
- counts: Partial<Record<ShardComponent, number>>;
2417
+ counts: Partial<Record<ShardComponent | 'community_sets', number>>;
2104
2418
  checksums: Record<string, string>;
2105
2419
  min_reader_version: string;
2106
2420
  }
@@ -2127,6 +2441,16 @@ interface ImportCounts {
2127
2441
  embedding_sets: number;
2128
2442
  embedding_set_members: number;
2129
2443
  embeddings: number;
2444
+ skos_schemes: number;
2445
+ skos_concepts: number;
2446
+ skos_relations: number;
2447
+ note_skos_tags: number;
2448
+ provenance_edges: number;
2449
+ graph_sources: number;
2450
+ graph_edges: number;
2451
+ community_sets: number;
2452
+ communities: number;
2453
+ community_assignments: number;
2130
2454
  }
2131
2455
  /** Result of a shard import operation. */
2132
2456
  interface ImportResult {
@@ -2179,9 +2503,20 @@ interface ShardLink {
2179
2503
  /** Embedding set as serialized in the shard JSON array. */
2180
2504
  interface ShardEmbeddingSet {
2181
2505
  id: string;
2506
+ name?: string;
2507
+ purpose?: string | null;
2182
2508
  model: string;
2183
2509
  dimension: number;
2510
+ kind?: 'physical' | 'filter' | 'virtual';
2511
+ mode?: 'auto' | 'manual' | 'mixed' | null;
2512
+ truncate_dimension?: number | null;
2513
+ criteria?: Record<string, unknown> | null;
2514
+ source?: Record<string, unknown> | null;
2515
+ compatibility?: Record<string, unknown> | null;
2516
+ materialization?: Record<string, unknown> | null;
2517
+ freshness?: ShardArtifactFreshness | null;
2184
2518
  created_at: string;
2519
+ updated_at?: string;
2185
2520
  }
2186
2521
  /** Embedding set member as serialized in the shard JSONL. */
2187
2522
  interface ShardEmbeddingSetMember {
@@ -2197,6 +2532,63 @@ interface ShardEmbedding {
2197
2532
  vector: number[];
2198
2533
  created_at: string;
2199
2534
  }
2535
+ /** SKOS scheme as serialized in the shard JSON array. */
2536
+ interface ShardSkosScheme {
2537
+ id: string;
2538
+ title: string;
2539
+ description: string | null;
2540
+ created_at: string;
2541
+ updated_at: string;
2542
+ }
2543
+ /** SKOS concept as serialized in the shard JSON array. */
2544
+ interface ShardSkosConcept {
2545
+ id: string;
2546
+ scheme_id: string;
2547
+ pref_label: string;
2548
+ alt_labels: string[];
2549
+ definition: string | null;
2550
+ created_at: string;
2551
+ updated_at: string;
2552
+ }
2553
+ /** SKOS concept relation as serialized in the shard JSONL. */
2554
+ interface ShardSkosRelation {
2555
+ id: string;
2556
+ source_concept_id: string;
2557
+ target_concept_id: string;
2558
+ relation_type: 'broader' | 'narrower' | 'related';
2559
+ created_at: string;
2560
+ }
2561
+ /** Note-to-SKOS-concept assignment as serialized in the shard JSONL. */
2562
+ interface ShardNoteSkosTag {
2563
+ id: string;
2564
+ note_id: string;
2565
+ concept_id: string;
2566
+ created_at: string;
2567
+ }
2568
+ /** Provenance edge as serialized in the shard JSONL. */
2569
+ interface ShardProvenanceEdge {
2570
+ id: string;
2571
+ entity_type: string;
2572
+ entity_id: string;
2573
+ activity: string;
2574
+ agent: string;
2575
+ started_at: string;
2576
+ ended_at: string | null;
2577
+ attributes: Record<string, unknown> | null;
2578
+ }
2579
+ interface ShardArtifactFreshness {
2580
+ status: 'fresh' | 'stale' | 'unknown';
2581
+ checked_at?: string;
2582
+ stale_reason?: string;
2583
+ source_hashes?: {
2584
+ notes?: string;
2585
+ links?: string;
2586
+ embeddings?: string;
2587
+ embedding_set_members?: string;
2588
+ virtual_set_definition?: string;
2589
+ parameters?: string;
2590
+ };
2591
+ }
2200
2592
 
2201
2593
  /**
2202
2594
  * Minimal tar + gzip packing/unpacking for shard archives.
@@ -2301,16 +2693,38 @@ declare function tagsFromShard(shardTags: ShardTag[]): string[];
2301
2693
  /** Convert a browser embedding_set to shard format. */
2302
2694
  declare function embeddingSetToShard(set: {
2303
2695
  id: string;
2696
+ name?: string;
2697
+ purpose?: string | null;
2304
2698
  model_name: string;
2305
2699
  dimensions: number;
2700
+ kind?: 'physical' | 'filter' | 'virtual';
2701
+ mode?: 'auto' | 'manual' | 'mixed' | null;
2702
+ truncate_dimension?: number | null;
2703
+ criteria_json?: unknown | null;
2704
+ source_json?: unknown | null;
2705
+ compatibility_json?: unknown | null;
2706
+ materialization_json?: unknown | null;
2707
+ freshness_json?: unknown | null;
2306
2708
  created_at: Date | string;
2709
+ updated_at?: Date | string;
2307
2710
  }): ShardEmbeddingSet;
2308
2711
  /** Convert a shard embedding set back to browser format. */
2309
2712
  declare function embeddingSetFromShard(shard: ShardEmbeddingSet): {
2310
2713
  id: string;
2714
+ name: string;
2715
+ purpose: string | null;
2311
2716
  model_name: string;
2312
2717
  dimensions: number;
2718
+ kind: 'physical' | 'filter' | 'virtual';
2719
+ mode: 'auto' | 'manual' | 'mixed' | null;
2720
+ truncate_dimension: number | null;
2721
+ criteria_json: string | null;
2722
+ source_json: string | null;
2723
+ compatibility_json: string | null;
2724
+ materialization_json: string | null;
2725
+ freshness_json: string | null;
2313
2726
  created_at: string;
2727
+ updated_at: string | null;
2314
2728
  };
2315
2729
  /** Convert a browser embedding_set_member to shard format. */
2316
2730
  declare function embeddingSetMemberToShard(member: {
@@ -2334,6 +2748,45 @@ declare function embeddingFromShard(shard: ShardEmbedding): {
2334
2748
  vector: string;
2335
2749
  created_at: string;
2336
2750
  };
2751
+ declare function skosSchemeToShard(scheme: {
2752
+ id: string;
2753
+ title: string;
2754
+ description: string | null;
2755
+ created_at: Date | string;
2756
+ updated_at: Date | string;
2757
+ }): ShardSkosScheme;
2758
+ declare function skosConceptToShard(concept: {
2759
+ id: string;
2760
+ scheme_id: string;
2761
+ pref_label: string;
2762
+ alt_labels: string[] | string | null;
2763
+ definition: string | null;
2764
+ created_at: Date | string;
2765
+ updated_at: Date | string;
2766
+ }): ShardSkosConcept;
2767
+ declare function skosRelationToShard(relation: {
2768
+ id: string;
2769
+ source_concept_id: string;
2770
+ target_concept_id: string;
2771
+ relation_type: 'broader' | 'narrower' | 'related';
2772
+ created_at: Date | string;
2773
+ }): ShardSkosRelation;
2774
+ declare function noteSkosTagToShard(tag: {
2775
+ id: string;
2776
+ note_id: string;
2777
+ concept_id: string;
2778
+ created_at: Date | string;
2779
+ }): ShardNoteSkosTag;
2780
+ declare function provenanceEdgeToShard(edge: {
2781
+ id: string;
2782
+ entity_type: string;
2783
+ entity_id: string;
2784
+ activity: string;
2785
+ agent: string;
2786
+ started_at: Date | string;
2787
+ ended_at: Date | string | null;
2788
+ attributes: Record<string, unknown> | string | null;
2789
+ }): ShardProvenanceEdge;
2337
2790
 
2338
2791
  /**
2339
2792
  * Shard export pipeline — query all entities, serialize, pack into .shard archive.
@@ -2370,6 +2823,92 @@ declare function exportShard(db: DatabaseClient, options?: ExportOptions): Promi
2370
2823
  */
2371
2824
  declare function importShard(db: DatabaseClient, data: Uint8Array | ArrayBuffer, options?: ImportOptions): Promise<ImportResult>;
2372
2825
 
2373
- declare const VERSION = "2026.5.3";
2826
+ type AiwgFortemiRecordType = 'crm.contact' | 'crm.organization' | 'crm.event' | 'crm.interaction' | 'aiwg.artifact';
2827
+ type AiwgPrivacyClassification = 'private' | 'sanitized' | 'public';
2828
+ type AiwgProvenanceConfidence = 'source' | 'candidate' | 'reviewed' | 'rejected';
2829
+ type AiwgReviewAction = 'accept' | 'reject' | 'defer';
2830
+ interface AiwgFortemiRecordSource {
2831
+ path: string;
2832
+ repo_relative_path: string;
2833
+ locator: string;
2834
+ }
2835
+ interface AiwgFortemiRelationship {
2836
+ type: string;
2837
+ target_id: string;
2838
+ source_path?: string;
2839
+ }
2840
+ interface AiwgFortemiProvenance {
2841
+ field: string;
2842
+ source: string;
2843
+ path: string;
2844
+ confidence: AiwgProvenanceConfidence;
2845
+ privacy: AiwgPrivacyClassification;
2846
+ }
2847
+ interface AiwgFortemiRecord {
2848
+ schema_version: 'aiwg.fortemi.index.record.v1';
2849
+ id: string;
2850
+ type: AiwgFortemiRecordType;
2851
+ source: AiwgFortemiRecordSource;
2852
+ title: string;
2853
+ text: string;
2854
+ facets: Record<string, string[]>;
2855
+ tags: string[];
2856
+ concepts: string[];
2857
+ relationships: AiwgFortemiRelationship[];
2858
+ provenance: AiwgFortemiProvenance[];
2859
+ privacy: {
2860
+ classification: AiwgPrivacyClassification;
2861
+ pii: boolean;
2862
+ };
2863
+ updated_at: string;
2864
+ }
2865
+ interface AiwgFortemiIndexExport {
2866
+ schema_version: 'aiwg.fortemi.index.export.v1';
2867
+ generated_at: string;
2868
+ source: {
2869
+ repo: string;
2870
+ privacy: AiwgPrivacyClassification;
2871
+ };
2872
+ items: AiwgFortemiRecord[];
2873
+ }
2874
+ interface AiwgIndexValidationResult {
2875
+ valid: boolean;
2876
+ errors: string[];
2877
+ counts: Partial<Record<AiwgFortemiRecordType, number>>;
2878
+ }
2879
+ interface AiwgIndexQueryOptions {
2880
+ types?: AiwgFortemiRecordType[];
2881
+ facets?: Record<string, string[]>;
2882
+ tags?: string[];
2883
+ concepts?: string[];
2884
+ privacy?: AiwgPrivacyClassification[];
2885
+ relationshipTargetId?: string;
2886
+ limit?: number;
2887
+ offset?: number;
2888
+ }
2889
+ interface AiwgIndexQueryResult {
2890
+ items: AiwgFortemiRecord[];
2891
+ total: number;
2892
+ facets: Record<string, Record<string, number>>;
2893
+ }
2894
+ interface AiwgReviewDecision {
2895
+ item_id: string;
2896
+ action: AiwgReviewAction;
2897
+ reason?: string;
2898
+ updated_at: string;
2899
+ }
2900
+ interface AiwgReviewDecisionExport {
2901
+ schema_version: 'aiwg.fortemi.review-decisions.v1';
2902
+ generated_at: string;
2903
+ source_export_schema_version: string;
2904
+ decisions: AiwgReviewDecision[];
2905
+ }
2906
+ declare function validateAiwgFortemiIndexExport(value: unknown): AiwgIndexValidationResult;
2907
+ declare function assertAiwgFortemiIndexExport(value: unknown): AiwgFortemiIndexExport;
2908
+ declare function getAiwgFortemiFacets(items: AiwgFortemiRecord[]): Record<string, Record<string, number>>;
2909
+ declare function queryAiwgFortemiIndex(index: AiwgFortemiIndexExport, query?: string, options?: AiwgIndexQueryOptions): AiwgIndexQueryResult;
2910
+ declare function createAiwgReviewDecisionExport(source: AiwgFortemiIndexExport, decisions: AiwgReviewDecision[], generatedAt?: string): AiwgReviewDecisionExport;
2911
+
2912
+ declare const VERSION = "2026.6.0";
2374
2913
 
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 };
2914
+ export { type AiwgFortemiIndexExport, type AiwgFortemiProvenance, type AiwgFortemiRecord, type AiwgFortemiRecordSource, type AiwgFortemiRecordType, type AiwgFortemiRelationship, type AiwgIndexQueryOptions, type AiwgIndexQueryResult, type AiwgIndexValidationResult, type AiwgPrivacyClassification, type AiwgProvenanceConfidence, type AiwgReviewAction, type AiwgReviewDecision, type AiwgReviewDecisionExport, 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, assertAiwgFortemiIndexExport, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createAiwgReviewDecisionExport, 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, getAiwgFortemiFacets, getEmbedFunction, getJobQueueStatus, getLlmFunction, getNote, importShard, isPluginScriptAllowed, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, packTarGz, parseCspReport, provenanceEdgeToShard, queryAiwgFortemiIndex, registerLlmCapability, registerSemanticCapability, registerServiceWorker, searchTool, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateAiwgFortemiIndexExport, validateChecksums, verifySri };