@fortemi/core 2026.7.5 → 2026.7.8

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
@@ -1,4 +1,5 @@
1
1
  import { PGlite } from '@electric-sql/pglite';
2
+ import { ProbeReport } from '@bytecask/core';
2
3
  import { z, ZodType } from 'zod';
3
4
  export { AiwgIndexSchemaValidationResult, getAiwgFortemiIndexExportSchema, validateAiwgFortemiIndexExportSchema, validateAiwgFortemiProjectedRecordSchema } from './aiwg-index-schema.js';
4
5
 
@@ -390,34 +391,233 @@ declare class PGliteWorkerStorageBackendFactory implements StorageBackendFactory
390
391
  }
391
392
 
392
393
  /**
393
- * Content-addressable blob storage.
394
+ * Content-addressed attachment-byte storage — the Fortemi `BlobStore` seam.
394
395
  *
395
- * Path format: blobs/{dir1}/{dir2}/{hash}
396
- * dir1 = first 2 hex chars of hash
397
- * dir2 = next 2 hex chars of hash
398
- * filename = full hash
396
+ * The store computes the key: `put(bytes)` BLAKE3-hashes the payload and
397
+ * returns the canonical checksum encoding `blake3:<64-char lowercase hex>`
398
+ * (server convention; ADR-012 D1/D3). Every method at this seam speaks that
399
+ * canonical encoding — the bare-hex ⇄ prefixed conversions live in
400
+ * `shard/blob-sidecar.ts` helpers and inside the bytecask adapter here, and
401
+ * nowhere else.
399
402
  *
400
- * Two implementations are provided:
401
- * - OpfsBlobStore — Origin Private File System (Chrome/Edge 86+)
402
- * - IdbBlobStore — IndexedDB fallback (Firefox, Safari)
403
+ * Lifecycle authority (ADR-013 D2): canonical attachment manifests decide
404
+ * which bytes are live. `reconcile(liveChecksums)` hands that authoritative
405
+ * set to the store; `gc()` physically removes only unreferenced,
406
+ * age-thresholded objects. Internal refcounts are an implementation detail,
407
+ * never a source of truth.
403
408
  *
404
- * Use createBlobStore() to get the best available implementation.
405
- * Export MemoryBlobStore for use in tests.
409
+ * Implementations:
410
+ * - `createBlobStore()` — `@bytecask/core` behind a dynamic import
411
+ * (IndexedDB tier by default, OPFS opt-in, memory fallback). Zero bundle
412
+ * cost until the first byte operation (ADR-012 D6).
413
+ * - `createLazyBlobStore()` — synchronous facade that defers the dynamic
414
+ * import until the first method call (what `FortemiProvider` wires).
415
+ * - `MemoryBlobStore` — dependency-free in-process implementation for
416
+ * tests and the no-persistence tier.
417
+ */
418
+
419
+ type BlobBackendKind = 'idb' | 'opfs' | 'memory';
420
+ interface BlobStoreDiagnostics {
421
+ /** The storage tier actually serving bytes. */
422
+ backend: BlobBackendKind;
423
+ /** Tier-probe outcome from `@bytecask/core` (null for memory/test stores). */
424
+ probe: ProbeReport | null;
425
+ }
426
+ interface BlobReconcileOptions {
427
+ /** Physically remove unreferenced objects now instead of leaving them for gc(). */
428
+ removeUnreferenced?: boolean;
429
+ }
430
+ interface BlobReconcileResult {
431
+ /** Live checksums whose bytes are present. */
432
+ referenced: number;
433
+ /** Live checksums whose bytes are absent — the reference-only set. */
434
+ missing: string[];
435
+ /** Stored checksums not in the live set — GC candidates. */
436
+ unreferenced: string[];
437
+ /** Objects physically removed (only when `removeUnreferenced`). */
438
+ removed: number;
439
+ bytesFreed: number;
440
+ }
441
+ interface BlobGcOptions {
442
+ /** Collect only unreferenced objects at least this old (ms). Default 0. */
443
+ minAgeMs?: number;
444
+ }
445
+ interface BlobGcResult {
446
+ collected: number;
447
+ bytesFreed: number;
448
+ }
449
+ /**
450
+ * The Fortemi attachment-byte seam. All checksums are the canonical
451
+ * `blake3:<hex>` encoding stored in `attachment_blob.content_hash` and shard
452
+ * projection records.
406
453
  */
407
454
  interface BlobStore {
408
- write(hash: string, data: Uint8Array): Promise<void>;
409
- read(hash: string): Promise<Uint8Array | null>;
410
- remove(hash: string): Promise<void>;
411
- exists(hash: string): Promise<boolean>;
455
+ /** Store bytes, return their canonical checksum. Idempotent (content-addressed). */
456
+ put(bytes: Uint8Array): Promise<string>;
457
+ /** Fetch bytes by canonical checksum; null when absent (reference-only). */
458
+ read(checksum: string): Promise<Uint8Array | null>;
459
+ /** True when the bytes for this checksum are physically present. */
460
+ has(checksum: string): Promise<boolean>;
461
+ /**
462
+ * Reconcile stored bytes against the authoritative live-checksum set
463
+ * derived from canonical attachment manifests (ADR-013 D4).
464
+ */
465
+ reconcile(liveChecksums: Iterable<string>, opts?: BlobReconcileOptions): Promise<BlobReconcileResult>;
466
+ /** Physically remove unreferenced, age-thresholded objects. */
467
+ gc(opts?: BlobGcOptions): Promise<BlobGcResult>;
468
+ /** Selected backend + probe report, for capability/diagnostic surfaces. */
469
+ diagnostics(): Promise<BlobStoreDiagnostics>;
470
+ close(): Promise<void>;
412
471
  }
413
472
  declare class MemoryBlobStore implements BlobStore {
414
- private store;
415
- write(hash: string, data: Uint8Array): Promise<void>;
416
- read(hash: string): Promise<Uint8Array | null>;
417
- remove(hash: string): Promise<void>;
418
- exists(hash: string): Promise<boolean>;
473
+ private now;
474
+ private entries;
475
+ constructor(now?: () => number);
476
+ put(bytes: Uint8Array): Promise<string>;
477
+ read(checksum: string): Promise<Uint8Array | null>;
478
+ has(checksum: string): Promise<boolean>;
479
+ reconcile(liveChecksums: Iterable<string>, opts?: BlobReconcileOptions): Promise<BlobReconcileResult>;
480
+ gc(opts?: BlobGcOptions): Promise<BlobGcResult>;
481
+ diagnostics(): Promise<BlobStoreDiagnostics>;
482
+ close(): Promise<void>;
483
+ }
484
+ interface CreateBlobStoreOptions {
485
+ /** Force a tier; omit to probe IndexedDB → OPFS → memory (measured default). */
486
+ backend?: BlobBackendKind;
487
+ /** Injectable IDBFactory for tests (fake-indexeddb). Defaults to the global. */
488
+ indexedDB?: IDBFactory;
489
+ /** Skip the one-shot migration of the pre-bytecask blob layout. */
490
+ migrateLegacy?: boolean;
491
+ }
492
+ /**
493
+ * Construct the bytecask-backed BlobStore for one archive namespace.
494
+ *
495
+ * `@bytecask/core` is reached only through a dynamic `import()` here, so
496
+ * hosts that never touch attachment bytes never load it. The namespace is a
497
+ * function of `archiveName` alone — identical in DB-free and PGlite modes.
498
+ *
499
+ * Tiering: IndexedDB by default (measured default per bytecask's C3
500
+ * benchmark), memory fallback when IndexedDB is unavailable. The OPFS opt-in
501
+ * tier arrives with the upstream `createBlobStore()` factory switch
502
+ * (`@bytecask/core` 2026.7.2); requesting it now fails loudly rather than
503
+ * silently falling back.
504
+ */
505
+ declare function createBlobStore(archiveName: string, options?: CreateBlobStoreOptions): Promise<BlobStore>;
506
+ /**
507
+ * Synchronous facade over {@link createBlobStore}: construction is free, the
508
+ * dynamic import happens on the first byte operation. This is what
509
+ * `FortemiProvider` wires so hosts that never touch attachment bytes never
510
+ * pay for the substrate (ADR-012 D6).
511
+ */
512
+ declare function createLazyBlobStore(archiveName: string, options?: CreateBlobStoreOptions): BlobStore;
513
+
514
+ /**
515
+ * Signed Knowledge-Shard verification (#324, ADR-014).
516
+ *
517
+ * Authenticity — as distinct from the consistency the in-archive checksums
518
+ * provide (SEC7) — comes from an Ed25519 signature over a canonical payload
519
+ * that commits to the manifest digest and the referenced blob-byte digests.
520
+ * Verification is pure and side-effect-free; it runs BEFORE any record or
521
+ * blob mutation (ADR-013 D6 / ADR-014 D3). Bytecask never sees keys.
522
+ */
523
+
524
+ declare const SIGNATURE_ENTRY = "signature.json";
525
+ declare const SIGNING_ENVELOPE_VERSION = "1";
526
+ declare const SIGNING_ALGORITHM = "ed25519";
527
+ interface ShardSigner {
528
+ key_id: string;
529
+ algorithm: typeof SIGNING_ALGORITHM;
530
+ /** Raw 32-byte Ed25519 public key, base64url. */
531
+ public_key: string;
532
+ }
533
+ /** The signed payload (never contains its own signature — ADR-014 D2). */
534
+ interface ShardSigningPayload {
535
+ format_version: typeof SIGNING_ENVELOPE_VERSION;
536
+ signer: ShardSigner;
537
+ /** SHA-256 hex of the canonical manifest.json bytes. */
538
+ manifest_digest: string;
539
+ /** Sorted bare-hex BLAKE3 digests of referenced sidecar blobs. */
540
+ blob_digests: string[];
541
+ }
542
+ /** `signature.json` archive entry: the payload plus its base64url signature. */
543
+ interface ShardSignatureEnvelope extends ShardSigningPayload {
544
+ signature: string;
545
+ }
546
+ interface TrustedKey {
547
+ key_id: string;
548
+ /** Raw 32-byte Ed25519 public key, base64url. */
549
+ public_key: string;
550
+ revoked?: boolean;
551
+ }
552
+ interface ShardTrustStore {
553
+ resolve(keyId: string): TrustedKey | null | Promise<TrustedKey | null>;
554
+ }
555
+ /** In-memory allowlist trust store seeded from `{ key_id, public_key }` entries. */
556
+ declare class AllowlistTrustStore implements ShardTrustStore {
557
+ private keys;
558
+ constructor(keys: TrustedKey[]);
559
+ resolve(keyId: string): TrustedKey | null;
560
+ /** Mark a key revoked without removing it (still resolvable, verdict `revoked`). */
561
+ revoke(keyId: string): void;
562
+ }
563
+ type ShardSignatureVerdict = {
564
+ ok: true;
565
+ keyId: string;
566
+ } | {
567
+ ok: false;
568
+ reason: 'unsigned';
569
+ } | {
570
+ ok: false;
571
+ reason: 'malformed';
572
+ detail: string;
573
+ } | {
574
+ ok: false;
575
+ reason: 'unknown-signer';
576
+ keyId: string;
577
+ } | {
578
+ ok: false;
579
+ reason: 'revoked';
580
+ keyId: string;
581
+ } | {
582
+ ok: false;
583
+ reason: 'bad-signature';
584
+ keyId: string;
585
+ } | {
586
+ ok: false;
587
+ reason: 'content-mismatch';
588
+ detail: string;
589
+ } | {
590
+ ok: false;
591
+ reason: 'unsupported';
592
+ };
593
+ /** True when this runtime's WebCrypto verifies Ed25519 (ADR-014 D1). */
594
+ declare function isShardSigningSupported(): Promise<boolean>;
595
+ /** Sorted bare-hex BLAKE3 digests of the sidecar blobs present in the archive. */
596
+ declare function sidecarBlobDigests(files: Map<string, Uint8Array>): string[];
597
+ interface VerifyShardSignatureInput {
598
+ files: Map<string, Uint8Array>;
599
+ trustStore: ShardTrustStore;
600
+ }
601
+ /**
602
+ * Verify a shard's Ed25519 signature over its canonical payload. Pure: reads
603
+ * archive bytes, resolves the key, checks the signature and the
604
+ * manifest/blob-digest commitments. No persistence, no mutation.
605
+ */
606
+ declare function verifyShardSignature(input: VerifyShardSignatureInput): Promise<ShardSignatureVerdict>;
607
+ interface SignShardInput {
608
+ files: Map<string, Uint8Array>;
609
+ keyId: string;
610
+ /** Ed25519 private key (raw 32-byte seed or PKCS8), imported by the caller. */
611
+ privateKey: CryptoKey;
612
+ /** Raw 32-byte public key, base64url — embedded in the envelope + trust store. */
613
+ publicKey: string;
419
614
  }
420
- declare function createBlobStore(archiveName: string): BlobStore;
615
+ /**
616
+ * Produce the `signature.json` envelope for an assembled archive `files` map.
617
+ * The caller adds the returned bytes to the archive under {@link SIGNATURE_ENTRY}
618
+ * (excluded from manifest.checksums — it post-dates the manifest).
619
+ */
620
+ declare function signShard(input: SignShardInput): Promise<Uint8Array>;
421
621
 
422
622
  /**
423
623
  * Shard format types — matches the fortemi server matric-shard specification.
@@ -533,6 +733,19 @@ interface ImportOptions {
533
733
  * bytes. Absent → attachments import as reference-only metadata (unchanged).
534
734
  */
535
735
  blobStore?: BlobStore;
736
+ /**
737
+ * Publisher-provenance policy for signed shards (#324, ADR-014):
738
+ * - `require` — reject unsigned or bad-signature shards (default when a
739
+ * `trustStore` is supplied);
740
+ * - `prefer` — verify signed shards; import unsigned ones with a warning;
741
+ * still reject a present-but-invalid signature;
742
+ * - `trusted-local-only` — ignore signatures (own-export import).
743
+ * When both `trustStore` and this are omitted, verification is skipped
744
+ * entirely (checksum-only, unchanged behavior).
745
+ */
746
+ verifySignature?: 'require' | 'prefer' | 'trusted-local-only';
747
+ /** Trust store resolving signer key_id → public key (required for `require`/`prefer`). */
748
+ trustStore?: ShardTrustStore;
536
749
  }
537
750
  type ImportProgressPhase = 'unpack' | 'validate' | 'collections' | 'notes' | 'skos' | 'templates' | 'links' | 'provenance' | 'embedding_sets' | 'embedding_configs' | 'embeddings' | 'embedding_set_members' | 'graph' | 'communities' | 'index';
538
751
  interface ImportProgress {
@@ -577,6 +790,7 @@ interface ShardNote {
577
790
  title: string | null;
578
791
  original_content: string;
579
792
  revised_content: string | null;
793
+ metadata?: Record<string, unknown> | null;
580
794
  collection_id?: string | null;
581
795
  attachments?: ShardAttachmentProjection[];
582
796
  /** @deprecated Legacy React shard field name. Use `attachments`. */
@@ -621,23 +835,31 @@ interface ShardLink {
621
835
  id: string;
622
836
  from_note_id: string;
623
837
  to_note_id: string | null;
624
- to_url: string | null;
838
+ /** Optional for legacy React shards exported before URL links existed. */
839
+ to_url?: string | null;
625
840
  kind: string;
626
841
  score: number | null;
627
842
  created_at: string;
628
- metadata: Record<string, unknown> | null;
843
+ /** Optional for legacy React shards exported before link metadata existed. */
844
+ metadata?: Record<string, unknown> | null;
629
845
  }
630
- /** Embedding set as serialized in the shard JSON array. */
846
+ /**
847
+ * Embedding set as serialized in the shard JSON array.
848
+ *
849
+ * Fields beyond id/model/dimension are optional for backward compatibility:
850
+ * legacy React shards omit them and import falls back to the same defaults
851
+ * `embeddingSetFromShard` applies (name → model, is_system → false, …).
852
+ */
631
853
  interface ShardEmbeddingSet {
632
854
  id: string;
633
- name: string;
634
- slug: string | null;
635
- description: string | null;
636
- purpose: string | null;
637
- document_count: number;
638
- embedding_count: number;
639
- is_system: boolean;
640
- keywords: string[];
855
+ name?: string;
856
+ slug?: string | null;
857
+ description?: string | null;
858
+ purpose?: string | null;
859
+ document_count?: number;
860
+ embedding_count?: number;
861
+ is_system?: boolean;
862
+ keywords?: string[];
641
863
  model: string;
642
864
  dimension: number;
643
865
  kind?: 'physical' | 'filter' | 'virtual';
@@ -657,9 +879,12 @@ interface ShardEmbeddingSetMember {
657
879
  note_id: string;
658
880
  /** Legacy React shard field; new exports use server membership metadata instead. */
659
881
  embedding_id?: string;
660
- membership_type: string;
661
- added_at: string;
662
- added_by: string | null;
882
+ /** Optional for legacy React shards; import defaults to 'materialized'. */
883
+ membership_type?: string;
884
+ /** Optional for legacy React shards; import falls back to the manifest timestamp. */
885
+ added_at?: string;
886
+ /** Optional for legacy React shards; import defaults to NULL. */
887
+ added_by?: string | null;
663
888
  }
664
889
  /** Embedding config as serialized in the shard JSON array. */
665
890
  interface ShardEmbeddingConfig {
@@ -672,14 +897,21 @@ interface ShardEmbeddingConfig {
672
897
  chunk_overlap: number;
673
898
  is_default: boolean;
674
899
  }
675
- /** Embedding as serialized in the shard JSONL. */
900
+ /**
901
+ * Embedding as serialized in the shard JSONL.
902
+ *
903
+ * Server metadata fields (`chunk_index`, `text`, `model`) are optional for
904
+ * backward compatibility: legacy React shards exported before migration 0016
905
+ * carry only `id`, `note_id`, `embedding_set_id`, `vector`, `created_at`.
906
+ * Import normalizes absent metadata to schema defaults (0, '', NULL).
907
+ */
676
908
  interface ShardEmbedding {
677
909
  id: string;
678
910
  note_id: string;
679
- chunk_index: number;
680
- text: string;
911
+ chunk_index?: number;
912
+ text?: string;
681
913
  vector: number[];
682
- model: string;
914
+ model?: string;
683
915
  /** React shard extension used to preserve local embedding-set scoping. */
684
916
  embedding_set_id?: string;
685
917
  /** React shard extension used to preserve local creation ordering. */
@@ -743,79 +975,6 @@ interface ShardArtifactFreshness {
743
975
  };
744
976
  }
745
977
 
746
- /**
747
- * LinksRepository — bidirectional note link management.
748
- *
749
- * Responsibilities:
750
- * - Create typed links between notes with duplicate prevention
751
- * - Soft-delete links
752
- * - Query outbound, inbound, and backlinks for a note
753
- */
754
-
755
- interface LinkRow {
756
- id: string;
757
- source_note_id: string;
758
- target_note_id: string;
759
- link_type: string;
760
- confidence: number | null;
761
- created_at: Date;
762
- updated_at: Date | null;
763
- deleted_at: Date | null;
764
- }
765
- declare class LinksRepository {
766
- private db;
767
- constructor(db: DatabaseClient);
768
- create(sourceNoteId: string, targetNoteId: string, linkType?: string): Promise<LinkRow>;
769
- get(id: string): Promise<LinkRow>;
770
- listForNote(noteId: string): Promise<{
771
- outbound: LinkRow[];
772
- inbound: LinkRow[];
773
- }>;
774
- getBacklinks(noteId: string): Promise<string[]>;
775
- delete(id: string): Promise<void>;
776
- }
777
-
778
- /**
779
- * CollectionsRepository — folder/category management for notes.
780
- *
781
- * Responsibilities:
782
- * - Create, read, update, and soft-delete collections
783
- * - Prevent circular parent references
784
- * - Assign and unassign notes from collections
785
- * - Return flat list and shallow tree views
786
- */
787
-
788
- interface CollectionRow {
789
- id: string;
790
- name: string;
791
- description: string | null;
792
- parent_id: string | null;
793
- position: number;
794
- created_at: Date;
795
- updated_at: Date;
796
- deleted_at: Date | null;
797
- }
798
- interface CollectionCreateInput {
799
- name: string;
800
- description?: string;
801
- parent_id?: string;
802
- }
803
- declare class CollectionsRepository {
804
- private db;
805
- constructor(db: DatabaseClient);
806
- create(input: CollectionCreateInput): Promise<CollectionRow>;
807
- get(id: string): Promise<CollectionRow>;
808
- list(): Promise<CollectionRow[]>;
809
- listTree(): Promise<Array<CollectionRow & {
810
- children: CollectionRow[];
811
- }>>;
812
- update(id: string, fields: Partial<Pick<CollectionRow, 'name' | 'description' | 'parent_id' | 'position'>>): Promise<CollectionRow>;
813
- delete(id: string): Promise<void>;
814
- assignNote(collectionId: string, noteId: string): Promise<void>;
815
- unassignNote(collectionId: string, noteId: string): Promise<void>;
816
- getNotesInCollection(collectionId: string): Promise<string[]>;
817
- }
818
-
819
978
  /**
820
979
  * Field mapper — converts between browser schema and shard (server) schema.
821
980
  *
@@ -836,6 +995,7 @@ interface BrowserNoteExport {
836
995
  deleted_at: Date | string | null;
837
996
  original_content: string;
838
997
  revised_content: string | null;
998
+ ai_metadata?: Record<string, unknown> | null;
839
999
  collection_id?: string | null;
840
1000
  attachments?: ShardAttachmentProjection[];
841
1001
  tags: string[];
@@ -844,8 +1004,15 @@ interface BrowserNoteExport {
844
1004
  declare function noteToShard(note: BrowserNoteExport): ShardNote;
845
1005
  /** Convert a shard note back to browser-insertable format. */
846
1006
  declare function noteFromShard(shard: ShardNote): BrowserNoteExport;
847
- /** Convert a browser link to shard format. */
848
- declare function linkToShard(link: LinkRow): ShardLink;
1007
+ /** Convert a browser link to shard format (accepts SQL rows or canonical ISO-string records). */
1008
+ declare function linkToShard(link: {
1009
+ id: string;
1010
+ source_note_id: string;
1011
+ target_note_id: string;
1012
+ link_type: string;
1013
+ confidence: number | null;
1014
+ created_at: Date | string;
1015
+ }): ShardLink;
849
1016
  /** Convert a browser URL-target link row to shard format. */
850
1017
  declare function urlLinkToShard(link: {
851
1018
  id: string;
@@ -867,8 +1034,14 @@ declare function linkFromShard(shard: ShardLink): {
867
1034
  created_at: string;
868
1035
  metadata: Record<string, unknown> | null;
869
1036
  };
870
- /** Convert a browser collection to shard format. */
871
- declare function collectionToShard(collection: CollectionRow, noteCount?: number): ShardCollection;
1037
+ /** Convert a browser collection to shard format (accepts SQL rows or canonical ISO-string records). */
1038
+ declare function collectionToShard(collection: {
1039
+ id: string;
1040
+ name: string;
1041
+ description: string | null;
1042
+ parent_id: string | null;
1043
+ created_at: Date | string;
1044
+ }, noteCount?: number): ShardCollection;
872
1045
  /** Convert a shard collection back to browser-insertable format. */
873
1046
  declare function collectionFromShard(shard: ShardCollection): {
874
1047
  id: string;
@@ -975,7 +1148,7 @@ declare function embeddingFromShard(shard: ShardEmbedding): {
975
1148
  chunk_index: number;
976
1149
  text: string;
977
1150
  vector: string;
978
- model: string;
1151
+ model: string | null;
979
1152
  created_at: string | null;
980
1153
  };
981
1154
  declare function skosSchemeToShard(scheme: {
@@ -1632,6 +1805,34 @@ declare function createRoutes(): RouteHandler[];
1632
1805
  */
1633
1806
  declare function matchRoute(routes: RouteHandler[], request: Request, url: URL): RouteHandler | null;
1634
1807
 
1808
+ /**
1809
+ * One-shot migration of the pre-bytecask blob layout into the new store.
1810
+ *
1811
+ * The legacy layout (shipped through v2026.7.x) was:
1812
+ * - IndexedDB: database `fortemi-<archive>-blobs`, object store `blobs`,
1813
+ * values keyed by the full checksum string (`blake3:<hex>`, historically
1814
+ * also `sha256:<hex>`).
1815
+ * - OPFS: directory `fortemi-<archive>-blobs/<h0h1>/<h2h3>/<checksum>`.
1816
+ *
1817
+ * Migration re-`put()`s every payload — the new store recomputes BLAKE3, so
1818
+ * legacy `sha256:`-keyed entries converge to canonical keys for free
1819
+ * (ADR-012 D3). The legacy source is deleted only after every entry migrated
1820
+ * without error; any failure leaves it untouched for the next attempt.
1821
+ */
1822
+
1823
+ /** Outcome of one migration attempt (for diagnostics/logging). */
1824
+ interface LegacyMigrationReport {
1825
+ migrated: number;
1826
+ /** Migration aborted without deleting the legacy source. */
1827
+ failed: boolean;
1828
+ }
1829
+ /**
1830
+ * Migrate any legacy blob layout for `archiveName` into `target`, then delete
1831
+ * the legacy source. Failures are contained: the legacy data stays in place
1832
+ * and the new store keeps whatever was already re-put (idempotent on retry).
1833
+ */
1834
+ declare function migrateLegacyBlobStore(archiveName: string, target: BlobStore, indexedDbFactory?: IDBFactory): Promise<LegacyMigrationReport>;
1835
+
1635
1836
  /**
1636
1837
  * Shared postMessage protocol types for the PGlite worker.
1637
1838
  *
@@ -1967,6 +2168,13 @@ interface NoteCreateInput {
1967
2168
  visibility?: string;
1968
2169
  tags?: string[];
1969
2170
  archive_id?: string;
2171
+ /**
2172
+ * Explicit primary key. When omitted a UUIDv7 is minted (the default). Supply
2173
+ * this only for deterministic seeding or cross-instance identity — e.g. two
2174
+ * in-browser databases that must agree on a shared note's id so a shard swap
2175
+ * can dedupe it under the `skip` conflict strategy.
2176
+ */
2177
+ id?: string;
1970
2178
  }
1971
2179
  interface NoteUpdateInput {
1972
2180
  title?: string;
@@ -2446,6 +2654,79 @@ declare class TagsRepository {
2446
2654
  }>>;
2447
2655
  }
2448
2656
 
2657
+ /**
2658
+ * CollectionsRepository — folder/category management for notes.
2659
+ *
2660
+ * Responsibilities:
2661
+ * - Create, read, update, and soft-delete collections
2662
+ * - Prevent circular parent references
2663
+ * - Assign and unassign notes from collections
2664
+ * - Return flat list and shallow tree views
2665
+ */
2666
+
2667
+ interface CollectionRow {
2668
+ id: string;
2669
+ name: string;
2670
+ description: string | null;
2671
+ parent_id: string | null;
2672
+ position: number;
2673
+ created_at: Date;
2674
+ updated_at: Date;
2675
+ deleted_at: Date | null;
2676
+ }
2677
+ interface CollectionCreateInput {
2678
+ name: string;
2679
+ description?: string;
2680
+ parent_id?: string;
2681
+ }
2682
+ declare class CollectionsRepository {
2683
+ private db;
2684
+ constructor(db: DatabaseClient);
2685
+ create(input: CollectionCreateInput): Promise<CollectionRow>;
2686
+ get(id: string): Promise<CollectionRow>;
2687
+ list(): Promise<CollectionRow[]>;
2688
+ listTree(): Promise<Array<CollectionRow & {
2689
+ children: CollectionRow[];
2690
+ }>>;
2691
+ update(id: string, fields: Partial<Pick<CollectionRow, 'name' | 'description' | 'parent_id' | 'position'>>): Promise<CollectionRow>;
2692
+ delete(id: string): Promise<void>;
2693
+ assignNote(collectionId: string, noteId: string): Promise<void>;
2694
+ unassignNote(collectionId: string, noteId: string): Promise<void>;
2695
+ getNotesInCollection(collectionId: string): Promise<string[]>;
2696
+ }
2697
+
2698
+ /**
2699
+ * LinksRepository — bidirectional note link management.
2700
+ *
2701
+ * Responsibilities:
2702
+ * - Create typed links between notes with duplicate prevention
2703
+ * - Soft-delete links
2704
+ * - Query outbound, inbound, and backlinks for a note
2705
+ */
2706
+
2707
+ interface LinkRow {
2708
+ id: string;
2709
+ source_note_id: string;
2710
+ target_note_id: string;
2711
+ link_type: string;
2712
+ confidence: number | null;
2713
+ created_at: Date;
2714
+ updated_at: Date | null;
2715
+ deleted_at: Date | null;
2716
+ }
2717
+ declare class LinksRepository {
2718
+ private db;
2719
+ constructor(db: DatabaseClient);
2720
+ create(sourceNoteId: string, targetNoteId: string, linkType?: string): Promise<LinkRow>;
2721
+ get(id: string): Promise<LinkRow>;
2722
+ listForNote(noteId: string): Promise<{
2723
+ outbound: LinkRow[];
2724
+ inbound: LinkRow[];
2725
+ }>;
2726
+ getBacklinks(noteId: string): Promise<string[]>;
2727
+ delete(id: string): Promise<void>;
2728
+ }
2729
+
2449
2730
  /**
2450
2731
  * SkosRepository — SKOS taxonomy management (schemes, concepts, relations).
2451
2732
  *
@@ -2603,19 +2884,19 @@ declare const CaptureKnowledgeInputSchema: z.ZodObject<{
2603
2884
  }, {
2604
2885
  content: string;
2605
2886
  title?: string | undefined;
2606
- format?: "markdown" | "plain" | "html" | undefined;
2607
2887
  tags?: string[] | undefined;
2888
+ format?: "markdown" | "plain" | "html" | undefined;
2608
2889
  }>, "many">>;
2609
2890
  template: z.ZodOptional<z.ZodString>;
2610
2891
  variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2611
2892
  }, "strip", z.ZodTypeAny, {
2612
2893
  source: string;
2613
2894
  format: "markdown" | "plain" | "html";
2614
- visibility: "private" | "shared" | "public";
2895
+ visibility: "private" | "public" | "shared";
2615
2896
  action: "create" | "bulk_create" | "from_template";
2616
2897
  title?: string | undefined;
2617
- archive_id?: string | undefined;
2618
2898
  tags?: string[] | undefined;
2899
+ archive_id?: string | undefined;
2619
2900
  content?: string | undefined;
2620
2901
  notes?: {
2621
2902
  format: "markdown" | "plain" | "html";
@@ -2629,16 +2910,16 @@ declare const CaptureKnowledgeInputSchema: z.ZodObject<{
2629
2910
  action: "create" | "bulk_create" | "from_template";
2630
2911
  source?: string | undefined;
2631
2912
  title?: string | undefined;
2632
- archive_id?: string | undefined;
2633
- format?: "markdown" | "plain" | "html" | undefined;
2634
- visibility?: "private" | "shared" | "public" | undefined;
2635
2913
  tags?: string[] | undefined;
2914
+ format?: "markdown" | "plain" | "html" | undefined;
2915
+ archive_id?: string | undefined;
2916
+ visibility?: "private" | "public" | "shared" | undefined;
2636
2917
  content?: string | undefined;
2637
2918
  notes?: {
2638
2919
  content: string;
2639
2920
  title?: string | undefined;
2640
- format?: "markdown" | "plain" | "html" | undefined;
2641
2921
  tags?: string[] | undefined;
2922
+ format?: "markdown" | "plain" | "html" | undefined;
2642
2923
  }[] | undefined;
2643
2924
  template?: string | undefined;
2644
2925
  variables?: Record<string, string> | undefined;
@@ -2688,14 +2969,14 @@ declare const SearchInputSchema: z.ZodObject<{
2688
2969
  limit: number;
2689
2970
  offset: number;
2690
2971
  include_facets: boolean;
2691
- mode: "auto" | "text" | "semantic" | "hybrid";
2972
+ mode: "text" | "auto" | "semantic" | "hybrid";
2692
2973
  query: string;
2693
2974
  source?: string | undefined;
2975
+ tags?: string[] | undefined;
2694
2976
  format?: "markdown" | "plain" | "html" | undefined;
2695
- visibility?: "private" | "shared" | "public" | undefined;
2977
+ visibility?: "private" | "public" | "shared" | undefined;
2696
2978
  is_starred?: boolean | undefined;
2697
2979
  is_archived?: boolean | undefined;
2698
- tags?: string[] | undefined;
2699
2980
  collection_id?: string | undefined;
2700
2981
  date_from?: Date | undefined;
2701
2982
  date_to?: Date | undefined;
@@ -2704,18 +2985,18 @@ declare const SearchInputSchema: z.ZodObject<{
2704
2985
  }, {
2705
2986
  query: string;
2706
2987
  source?: string | undefined;
2988
+ tags?: string[] | undefined;
2707
2989
  format?: "markdown" | "plain" | "html" | undefined;
2708
- visibility?: "private" | "shared" | "public" | undefined;
2990
+ visibility?: "private" | "public" | "shared" | undefined;
2709
2991
  is_starred?: boolean | undefined;
2710
2992
  is_archived?: boolean | undefined;
2711
- tags?: string[] | undefined;
2712
2993
  limit?: number | undefined;
2713
2994
  offset?: number | undefined;
2714
2995
  collection_id?: string | undefined;
2715
2996
  date_from?: Date | undefined;
2716
2997
  date_to?: Date | undefined;
2717
2998
  include_facets?: boolean | undefined;
2718
- mode?: "auto" | "text" | "semantic" | "hybrid" | undefined;
2999
+ mode?: "text" | "auto" | "semantic" | "hybrid" | undefined;
2719
3000
  embeddingSetId?: string | undefined;
2720
3001
  query_embedding?: number[] | undefined;
2721
3002
  }>;
@@ -2795,20 +3076,20 @@ declare const ListNotesInputSchema: z.ZodObject<{
2795
3076
  collection_id: z.ZodOptional<z.ZodString>;
2796
3077
  include_deleted: z.ZodOptional<z.ZodBoolean>;
2797
3078
  }, "strip", z.ZodTypeAny, {
2798
- sort: "created_at" | "updated_at" | "title";
3079
+ sort: "updated_at" | "title" | "created_at";
2799
3080
  limit: number;
2800
3081
  offset: number;
2801
3082
  order: "asc" | "desc";
3083
+ tags?: string[] | undefined;
2802
3084
  is_starred?: boolean | undefined;
2803
3085
  is_archived?: boolean | undefined;
2804
- tags?: string[] | undefined;
2805
3086
  include_deleted?: boolean | undefined;
2806
3087
  collection_id?: string | undefined;
2807
3088
  }, {
2808
- sort?: "created_at" | "updated_at" | "title" | undefined;
3089
+ tags?: string[] | undefined;
3090
+ sort?: "updated_at" | "title" | "created_at" | undefined;
2809
3091
  is_starred?: boolean | undefined;
2810
3092
  is_archived?: boolean | undefined;
2811
- tags?: string[] | undefined;
2812
3093
  limit?: number | undefined;
2813
3094
  offset?: number | undefined;
2814
3095
  order?: "asc" | "desc" | undefined;
@@ -2851,16 +3132,16 @@ declare const ManageCollectionsInputSchema: z.ZodObject<{
2851
3132
  note_id: z.ZodOptional<z.ZodString>;
2852
3133
  }, "strip", z.ZodTypeAny, {
2853
3134
  action: "create" | "delete" | "list" | "assign" | "unassign" | "list_tree";
3135
+ name?: string | undefined;
2854
3136
  collection_id?: string | undefined;
2855
3137
  note_id?: string | undefined;
2856
- name?: string | undefined;
2857
3138
  description?: string | undefined;
2858
3139
  parent_id?: string | undefined;
2859
3140
  }, {
2860
3141
  action: "create" | "delete" | "list" | "assign" | "unassign" | "list_tree";
3142
+ name?: string | undefined;
2861
3143
  collection_id?: string | undefined;
2862
3144
  note_id?: string | undefined;
2863
- name?: string | undefined;
2864
3145
  description?: string | undefined;
2865
3146
  parent_id?: string | undefined;
2866
3147
  }>;
@@ -2959,11 +3240,13 @@ declare function manageCapabilities(capabilityManager: CapabilityManager, rawInp
2959
3240
  * AttachmentsRepository — attach and retrieve binary files linked to notes.
2960
3241
  *
2961
3242
  * Responsibilities:
2962
- * - Content-addressed blob deduplication via SHA-256 hash
3243
+ * - Content-addressed blob deduplication via the store-computed BLAKE3 hash
2963
3244
  * - Store blob metadata in DatabaseClient (attachment_blob table)
2964
- * - Store binary data in a BlobStore implementation
3245
+ * - Store binary data in a BlobStore implementation (bytes-first ordering)
2965
3246
  * - Create/soft-delete attachment records linked to notes
2966
3247
  * - List active attachments for a note
3248
+ * - Reconcile/GC blob bytes against the canonical manifest live set
3249
+ * (ADR-013 D2/D4: manifests are the sole lifecycle authority)
2967
3250
  */
2968
3251
 
2969
3252
  interface AttachmentRow {
@@ -3001,11 +3284,16 @@ declare class AttachmentsRepository {
3001
3284
  /**
3002
3285
  * Attach a binary file to a note.
3003
3286
  *
3004
- * If a blob with the same BLAKE3 content hash already exists, the existing
3005
- * blob row is reused (deduplication). Otherwise a new blob row is inserted
3006
- * and the raw bytes are written to the BlobStore. The BLAKE3 `content_hash`
3007
- * (`blake3:<hex>`) matches the server convention and is the key used by the
3008
- * portable Knowledge-Shard byte sidecar.
3287
+ * Bytes are written first (`put()` is idempotent content addressing makes
3288
+ * replays safe), then the metadata rows commit (ADR-013 D5). A crash
3289
+ * between the two leaves an unreferenced blob that reconcile/gc sweeps
3290
+ * never a manifest without recoverable state. The store-computed BLAKE3
3291
+ * `content_hash` (`blake3:<hex>`) matches the server convention and is the
3292
+ * key used by the portable Knowledge-Shard byte sidecar.
3293
+ *
3294
+ * If a blob row with the same content hash already exists, it is reused
3295
+ * (deduplication) — re-putting the bytes also heals a previously
3296
+ * reference-only blob whose bytes went missing.
3009
3297
  *
3010
3298
  * Returns the newly created AttachmentRow.
3011
3299
  */
@@ -3017,9 +3305,16 @@ declare class AttachmentsRepository {
3017
3305
  get(id: string): Promise<AttachmentRow>;
3018
3306
  /**
3019
3307
  * Retrieve the raw binary data for an attachment.
3020
- * Returns null if the blob cannot be found in the BlobStore.
3308
+ * Returns null when the bytes are not present the attachment is then in
3309
+ * the recoverable reference-only state (metadata intact, bytes
3310
+ * re-hydratable from a shard sidecar or a re-attach of the same content).
3021
3311
  */
3022
3312
  getBlob(attachmentId: string): Promise<Uint8Array | null>;
3313
+ /**
3314
+ * True when the attachment's bytes are physically present in the BlobStore.
3315
+ * False means reference-only (recoverable), not an error.
3316
+ */
3317
+ hasBlob(attachmentId: string): Promise<boolean>;
3023
3318
  /**
3024
3319
  * List active (non-deleted) attachments for a note.
3025
3320
  * Ordered by position ascending, then created_at ascending.
@@ -3027,9 +3322,29 @@ declare class AttachmentsRepository {
3027
3322
  list(noteId: string): Promise<AttachmentRow[]>;
3028
3323
  /**
3029
3324
  * Soft-delete an attachment by setting deleted_at to the current timestamp.
3030
- * The underlying blob row and BlobStore data are not removed.
3325
+ * The blob row is untouched and no bytes are removed inline — physical
3326
+ * removal happens only through deferred `reconcileBlobs()`/`gcBlobs()`
3327
+ * against the canonical live set (ADR-013 D4).
3031
3328
  */
3032
3329
  delete(id: string): Promise<void>;
3330
+ /**
3331
+ * The authoritative live-checksum set: content hashes referenced by at
3332
+ * least one non-deleted attachment. This — not any refcount — decides
3333
+ * which bytes are reachable.
3334
+ */
3335
+ liveBlobChecksums(): Promise<string[]>;
3336
+ /**
3337
+ * Reconcile the BlobStore against the canonical live set (startup, after
3338
+ * quota events, after interrupted writes). `missing` lists reference-only
3339
+ * checksums; `unreferenced` lists GC candidates.
3340
+ */
3341
+ reconcileBlobs(opts?: BlobReconcileOptions): Promise<BlobReconcileResult>;
3342
+ /**
3343
+ * Deferred, age-thresholded physical removal of unreachable bytes.
3344
+ * Runs a reconcile first so GC always acts on current manifest truth.
3345
+ */
3346
+ gcBlobs(opts?: BlobGcOptions): Promise<BlobGcResult>;
3347
+ private blobChecksumOf;
3033
3348
  }
3034
3349
 
3035
3350
  declare const ManageAttachmentsInputSchema: z.ZodObject<{
@@ -3842,6 +4157,12 @@ declare function sha256Hex(data: Uint8Array): Promise<string>;
3842
4157
  * checked against the whole archive (see `prefetchShard`'s `expectedSha256`,
3843
4158
  * which is real integrity because the hash arrives on a separate channel).
3844
4159
  *
4160
+ * The signed-manifest path is now implemented: `verifyShardSignature`
4161
+ * (`shard-signature.ts`, #324/ADR-014) authenticates publisher provenance via
4162
+ * an Ed25519 signature over the manifest digest + blob-digest set, and
4163
+ * `importShard` runs it BEFORE any record or blob mutation. These in-archive
4164
+ * checksums remain the consistency layer *inside* that verified boundary.
4165
+ *
3845
4166
  * @returns Object with `valid` flag and list of failed filenames.
3846
4167
  */
3847
4168
  declare function validateChecksums(checksums: Record<string, string>, files: Map<string, Uint8Array>): Promise<{
@@ -4237,6 +4558,16 @@ interface AiwgIndexValidationResult {
4237
4558
  errors: string[];
4238
4559
  counts: Partial<Record<string, number>>;
4239
4560
  }
4561
+ interface AiwgKnowledgeShardOptions {
4562
+ createdAt?: string;
4563
+ matricVersion?: string;
4564
+ /**
4565
+ * Include React-native SKOS and provenance component files. The default
4566
+ * portable profile keeps those projections in lossless note metadata so the
4567
+ * shard remains importable by the current Fortemi server.
4568
+ */
4569
+ includeNativeRichComponents?: boolean;
4570
+ }
4240
4571
  interface AiwgChunkedIndexValidationResult {
4241
4572
  valid: boolean;
4242
4573
  errors: string[];
@@ -4527,7 +4858,499 @@ declare function aiwgFortemiIndexToCommunityGraph(index: AiwgFortemiIndexExport,
4527
4858
  nodes: string[];
4528
4859
  }[];
4529
4860
  };
4861
+ /**
4862
+ * Convert the static AIWG/Fortemi v2 index contract into a portable Knowledge
4863
+ * Shard. Every note retains the complete source envelope and record in metadata,
4864
+ * so the native note/link/SKOS/provenance projections are reversible.
4865
+ */
4866
+ declare function aiwgFortemiIndexToKnowledgeShard(index: AiwgFortemiIndexExport, options?: AiwgKnowledgeShardOptions): Promise<Uint8Array>;
4867
+ /**
4868
+ * Recover the exact AIWG index envelope and records embedded by
4869
+ * {@link aiwgFortemiIndexToKnowledgeShard}.
4870
+ */
4871
+ declare function aiwgFortemiIndexFromKnowledgeShard(bytes: Uint8Array): AiwgFortemiIndexExport;
4872
+
4873
+ /**
4874
+ * Canonical RecordStore contract — the writable structured-record layer that
4875
+ * exists independently of PGlite (#323, ADR-013 D3).
4876
+ *
4877
+ * Records mirror the browser SQL rows one-to-one (same field names, ISO-8601
4878
+ * timestamp strings) so the optional PGlite projection is a row-for-row
4879
+ * replay of the change journal — rebuildable at any time without touching
4880
+ * canonical records or attachment bytes.
4881
+ */
4882
+ interface NoteRecord0 {
4883
+ id: string;
4884
+ archive_id: string | null;
4885
+ title: string | null;
4886
+ format: string;
4887
+ source: string;
4888
+ visibility: string;
4889
+ revision_mode: string;
4890
+ is_starred: boolean;
4891
+ is_pinned: boolean;
4892
+ is_archived: boolean;
4893
+ created_at: string;
4894
+ updated_at: string;
4895
+ deleted_at: string | null;
4896
+ }
4897
+ interface NoteOriginalRecord {
4898
+ id: string;
4899
+ note_id: string;
4900
+ content: string;
4901
+ content_hash: string;
4902
+ created_at: string;
4903
+ }
4904
+ interface NoteRevisedCurrentRecord {
4905
+ /** Keyed by note id (mirrors the SQL PK `note_id`). */
4906
+ id: string;
4907
+ content: string;
4908
+ ai_metadata: unknown | null;
4909
+ generation_count: number;
4910
+ model: string | null;
4911
+ is_user_edited: boolean;
4912
+ updated_at: string;
4913
+ }
4914
+ interface NoteTagRecord {
4915
+ id: string;
4916
+ note_id: string;
4917
+ tag: string;
4918
+ created_at: string;
4919
+ }
4920
+ interface LinkRecord0 {
4921
+ id: string;
4922
+ source_note_id: string;
4923
+ target_note_id: string;
4924
+ link_type: string;
4925
+ created_at: string;
4926
+ deleted_at: string | null;
4927
+ }
4928
+ interface CollectionRecord {
4929
+ id: string;
4930
+ name: string;
4931
+ description: string | null;
4932
+ created_at: string;
4933
+ updated_at: string;
4934
+ deleted_at: string | null;
4935
+ }
4936
+ interface CollectionNoteRecord {
4937
+ id: string;
4938
+ collection_id: string;
4939
+ note_id: string;
4940
+ created_at: string;
4941
+ }
4942
+ interface AttachmentRecord {
4943
+ id: string;
4944
+ note_id: string;
4945
+ blob_id: string;
4946
+ document_type_id: string | null;
4947
+ mime_type: string | null;
4948
+ extracted_text: string | null;
4949
+ filename: string;
4950
+ display_name: string | null;
4951
+ position: number;
4952
+ created_at: string;
4953
+ deleted_at: string | null;
4954
+ }
4955
+ interface AttachmentBlobRecord {
4956
+ id: string;
4957
+ content_hash: string;
4958
+ size_bytes: number;
4959
+ created_at: string;
4960
+ }
4961
+ /** Collection name → record type. The store is generic over this map. */
4962
+ interface RecordCollections {
4963
+ note: NoteRecord0;
4964
+ note_original: NoteOriginalRecord;
4965
+ note_revised_current: NoteRevisedCurrentRecord;
4966
+ note_tag: NoteTagRecord;
4967
+ link: LinkRecord0;
4968
+ collection: CollectionRecord;
4969
+ collection_note: CollectionNoteRecord;
4970
+ attachment: AttachmentRecord;
4971
+ attachment_blob: AttachmentBlobRecord;
4972
+ }
4973
+ type RecordCollectionName = keyof RecordCollections;
4974
+ declare const RECORD_COLLECTIONS: readonly RecordCollectionName[];
4975
+ /**
4976
+ * One committed mutation. Journal entries carry the full record snapshot so
4977
+ * the PGlite projection (and any other consumer) can replay mutations without
4978
+ * re-reading canonical state, and so a rebuild has a total order to follow.
4979
+ */
4980
+ interface JournalEntry {
4981
+ /** Monotonically increasing commit sequence (assigned by the store). */
4982
+ seq: number;
4983
+ /** ISO-8601 commit timestamp. */
4984
+ ts: string;
4985
+ op: 'put' | 'delete';
4986
+ collection: RecordCollectionName;
4987
+ id: string;
4988
+ /** Snapshot for `put`; absent for `delete`. */
4989
+ record?: RecordCollections[RecordCollectionName];
4990
+ }
4991
+ /**
4992
+ * What the canonical record tier can and cannot serve, reported explicitly
4993
+ * (never emulated badly). Advanced capabilities may require the optional
4994
+ * PGlite projection (ADR-013 D3).
4995
+ */
4996
+ interface RecordStoreCapabilities {
4997
+ crud: true;
4998
+ journal: true;
4999
+ /** Bounded substring scan over titles/content — not ranked FTS. */
5000
+ boundedTextScan: true;
5001
+ fullTextSearch: false;
5002
+ vectorSearch: false;
5003
+ sqlJoins: false;
5004
+ }
5005
+ declare const RECORD_STORE_CAPABILITIES: RecordStoreCapabilities;
5006
+ interface RecordListOptions {
5007
+ /** Maximum records returned (applied after filtering). */
5008
+ limit?: number;
5009
+ }
5010
+ /**
5011
+ * The writable canonical structured-record store. Implementations MUST make
5012
+ * each `put`/`remove` an atomic commit of the record mutation plus its
5013
+ * journal entry (the recoverable commit protocol): a torn write leaves
5014
+ * neither, never one without the other.
5015
+ */
5016
+ interface RecordStore {
5017
+ get<C extends RecordCollectionName>(collection: C, id: string): Promise<RecordCollections[C] | null>;
5018
+ /** Insert or replace one record, journaled atomically. */
5019
+ put<C extends RecordCollectionName>(collection: C, record: RecordCollections[C]): Promise<JournalEntry>;
5020
+ /** Hard-remove one record, journaled atomically (soft-delete is a field upstream). */
5021
+ remove(collection: RecordCollectionName, id: string): Promise<JournalEntry>;
5022
+ /** All records of a collection (insertion order not guaranteed). */
5023
+ list<C extends RecordCollectionName>(collection: C, opts?: RecordListOptions): Promise<RecordCollections[C][]>;
5024
+ /** Journal entries with `seq > sinceSeq`, ascending. */
5025
+ journalSince(sinceSeq: number, limit?: number): Promise<JournalEntry[]>;
5026
+ /** Highest committed sequence (0 when empty). */
5027
+ headSeq(): Promise<number>;
5028
+ readonly capabilities: RecordStoreCapabilities;
5029
+ close(): Promise<void>;
5030
+ }
5031
+
5032
+ /**
5033
+ * In-memory RecordStore — the test/SSR tier of the canonical record layer.
5034
+ * Same commit semantics as the durable store: record + journal move together.
5035
+ */
5036
+
5037
+ declare class MemoryRecordStore implements RecordStore {
5038
+ readonly capabilities: RecordStoreCapabilities;
5039
+ private collections;
5040
+ private journal;
5041
+ private seq;
5042
+ private table;
5043
+ get<C extends RecordCollectionName>(collection: C, id: string): Promise<RecordCollections[C] | null>;
5044
+ put<C extends RecordCollectionName>(collection: C, record: RecordCollections[C]): Promise<JournalEntry>;
5045
+ remove(collection: RecordCollectionName, id: string): Promise<JournalEntry>;
5046
+ list<C extends RecordCollectionName>(collection: C, opts?: RecordListOptions): Promise<RecordCollections[C][]>;
5047
+ journalSince(sinceSeq: number, limit?: number): Promise<JournalEntry[]>;
5048
+ headSeq(): Promise<number>;
5049
+ close(): Promise<void>;
5050
+ }
5051
+
5052
+ /**
5053
+ * Durable canonical RecordStore over IndexedDB (#323, ADR-013 D3).
5054
+ *
5055
+ * One database per archive namespace: `fortemi-<archive>-records`. Object
5056
+ * stores: one per record collection (keyPath `id`), plus `journal`
5057
+ * (autoIncrement `seq`) and `meta` (schema version).
5058
+ *
5059
+ * Recoverable commit protocol (ADR-013 D5): every mutation writes the record
5060
+ * change AND its journal entry in a single IndexedDB transaction, so a torn
5061
+ * write commits neither. The journal `seq` is the total order the optional
5062
+ * PGlite projection consumes.
5063
+ *
5064
+ * Schema evolution: `meta.schemaVersion` records the logical record-schema
5065
+ * version; `migrate` hooks run inside the version-change transaction when the
5066
+ * database structure grows. Additive-only, mirroring the SQL migration
5067
+ * discipline.
5068
+ */
5069
+
5070
+ /** Logical record-schema version stored in `meta` (independent of DB_VERSION). */
5071
+ declare const RECORD_SCHEMA_VERSION = 1;
5072
+ interface CreateRecordStoreOptions {
5073
+ /** Injectable factory for tests (fake-indexeddb). Defaults to the global. */
5074
+ indexedDB?: IDBFactory;
5075
+ }
5076
+ declare class IdbRecordStore implements RecordStore {
5077
+ private db;
5078
+ readonly capabilities: RecordStoreCapabilities;
5079
+ private constructor();
5080
+ static open(archiveName: string, options?: CreateRecordStoreOptions): Promise<IdbRecordStore>;
5081
+ private ensureSchemaVersion;
5082
+ get<C extends RecordCollectionName>(collection: C, id: string): Promise<RecordCollections[C] | null>;
5083
+ put<C extends RecordCollectionName>(collection: C, record: RecordCollections[C]): Promise<JournalEntry>;
5084
+ remove(collection: RecordCollectionName, id: string): Promise<JournalEntry>;
5085
+ list<C extends RecordCollectionName>(collection: C, opts?: RecordListOptions): Promise<RecordCollections[C][]>;
5086
+ journalSince(sinceSeq: number, limit?: number): Promise<JournalEntry[]>;
5087
+ headSeq(): Promise<number>;
5088
+ close(): Promise<void>;
5089
+ }
5090
+ /** Open the durable canonical record store for one archive namespace. */
5091
+ declare function createRecordStore(archiveName: string, options?: CreateRecordStoreOptions): Promise<IdbRecordStore>;
5092
+
5093
+ /**
5094
+ * Canonical notes repository — DB-free note/tag/link/collection workflows
5095
+ * over the RecordStore (#323). Mirrors the SQL repositories' semantics
5096
+ * (UUIDv7 ids, immutable note_original, mutable note_revised_current,
5097
+ * soft-delete everywhere) so the PGlite projection replay is row-for-row.
5098
+ *
5099
+ * Query tier: id/recent/tag/link/collection lookups plus a bounded substring
5100
+ * text scan. Ranked FTS, vectors, and complex joins are explicitly NOT
5101
+ * served here — `store.capabilities` reports the boundary (ADR-013 D3).
5102
+ */
5103
+
5104
+ interface CanonicalNoteCreateInput {
5105
+ id?: string;
5106
+ title?: string;
5107
+ content: string;
5108
+ format?: string;
5109
+ source?: string;
5110
+ visibility?: string;
5111
+ }
5112
+ interface CanonicalNoteUpdateInput {
5113
+ title?: string;
5114
+ content?: string;
5115
+ format?: string;
5116
+ visibility?: string;
5117
+ is_starred?: boolean;
5118
+ is_pinned?: boolean;
5119
+ is_archived?: boolean;
5120
+ }
5121
+ interface CanonicalNoteView {
5122
+ note: NoteRecord0;
5123
+ original_content: string;
5124
+ revised_content: string;
5125
+ tags: string[];
5126
+ }
5127
+ declare class CanonicalNotesRepository {
5128
+ private store;
5129
+ constructor(store: RecordStore);
5130
+ create(input: CanonicalNoteCreateInput): Promise<CanonicalNoteView>;
5131
+ get(noteId: string): Promise<CanonicalNoteView | null>;
5132
+ update(noteId: string, input: CanonicalNoteUpdateInput): Promise<CanonicalNoteView>;
5133
+ /** Soft-delete: sets `deleted_at`; the record (and history) remains. */
5134
+ softDelete(noteId: string): Promise<void>;
5135
+ restore(noteId: string): Promise<void>;
5136
+ /** Non-deleted notes, most recently updated first. */
5137
+ listRecent(limit?: number): Promise<NoteRecord0[]>;
5138
+ /**
5139
+ * Bounded substring scan over title + revised content (case-insensitive).
5140
+ * This is deliberately not ranked FTS — see `store.capabilities`.
5141
+ */
5142
+ searchText(query: string, limit?: number): Promise<NoteRecord0[]>;
5143
+ addTag(noteId: string, tag: string): Promise<void>;
5144
+ removeTag(noteId: string, tag: string): Promise<void>;
5145
+ notesByTag(tag: string): Promise<NoteRecord0[]>;
5146
+ createLink(sourceNoteId: string, targetNoteId: string, linkType?: string): Promise<LinkRecord0>;
5147
+ softDeleteLink(linkId: string): Promise<void>;
5148
+ /** Active links touching a note (either direction). */
5149
+ linksOf(noteId: string): Promise<LinkRecord0[]>;
5150
+ createCollection(name: string, description?: string): Promise<CollectionRecord>;
5151
+ addNoteToCollection(collectionId: string, noteId: string): Promise<void>;
5152
+ notesInCollection(collectionId: string): Promise<NoteRecord0[]>;
5153
+ }
5154
+
5155
+ /**
5156
+ * Canonical attachments repository — DB-free attachment manifests over the
5157
+ * RecordStore, bytes through the Bytecask BlobStore (#323, ADR-013 D2/D4/D5).
5158
+ *
5159
+ * Same lifecycle semantics as the SQL-backed AttachmentsRepository: bytes
5160
+ * first (idempotent put), then manifest commit; soft-delete never removes
5161
+ * bytes inline; the manifest-derived live set drives reconcile/gc; missing
5162
+ * bytes are the recoverable reference-only state.
5163
+ */
5164
+
5165
+ interface CanonicalAttachInput {
5166
+ noteId: string;
5167
+ data: Uint8Array;
5168
+ filename: string;
5169
+ mimeType?: string;
5170
+ extractedText?: string;
5171
+ displayName?: string;
5172
+ }
5173
+ declare class CanonicalAttachmentsRepository {
5174
+ private store;
5175
+ private blobStore;
5176
+ constructor(store: RecordStore, blobStore: BlobStore);
5177
+ /** Bytes-first attach (ADR-013 D5); dedupes on the store-computed hash. */
5178
+ attach(input: CanonicalAttachInput): Promise<AttachmentRecord>;
5179
+ get(id: string): Promise<AttachmentRecord>;
5180
+ /** Null when bytes are absent — the recoverable reference-only state. */
5181
+ getBlob(attachmentId: string): Promise<Uint8Array | null>;
5182
+ hasBlob(attachmentId: string): Promise<boolean>;
5183
+ list(noteId: string): Promise<AttachmentRecord[]>;
5184
+ /** Soft-delete the manifest; bytes are only swept via reconcile/gc. */
5185
+ delete(id: string): Promise<void>;
5186
+ /** Authoritative live set: hashes referenced by non-deleted manifests. */
5187
+ liveBlobChecksums(): Promise<string[]>;
5188
+ /** Startup / post-quota reconciliation against canonical manifests (ADR-013 D4). */
5189
+ reconcileBlobs(opts?: BlobReconcileOptions): Promise<BlobReconcileResult>;
5190
+ /** Deferred reachability-based blob GC. */
5191
+ gcBlobs(opts?: BlobGcOptions): Promise<BlobGcResult>;
5192
+ private checksumOf;
5193
+ }
5194
+
5195
+ /**
5196
+ * PGlite attachment projection (#320, ADR-013 D3).
5197
+ *
5198
+ * Projects canonical attachment state (RecordStore) into the optional PGlite
5199
+ * `attachment_blob` / `attachment` tables. Properties:
5200
+ *
5201
+ * - Idempotent: every row upserts on its primary key; re-running with the
5202
+ * same canonical state changes nothing.
5203
+ * - Rebuildable: dropping the projection rows and re-projecting yields
5204
+ * equivalent query results — the canonical records are the source of truth.
5205
+ * - Derived refcounts: `attachment_blob.reference_count` is recomputed from
5206
+ * live manifests on every projection pass; it is never lifecycle authority
5207
+ * and no trigger touches it.
5208
+ * - Bytes never enter PGlite; only metadata is projected.
5209
+ */
5210
+
5211
+ interface AttachmentProjectionResult {
5212
+ blobs: number;
5213
+ attachments: number;
5214
+ }
5215
+ /**
5216
+ * Project all canonical attachment records into PGlite. Safe to run at any
5217
+ * time: startup, after journal consumption, or as a full rebuild after the
5218
+ * projection was dropped.
5219
+ *
5220
+ * The parent `note` rows must already exist in the projection (note
5221
+ * projection is the #323 cycle-2 surface); this function owns only the
5222
+ * attachment tables.
5223
+ */
5224
+ declare function projectAttachments(db: DatabaseClient, store: RecordStore): Promise<AttachmentProjectionResult>;
5225
+ /**
5226
+ * Drop the attachment projection rows (test/rebuild support). Canonical
5227
+ * records and Bytecask bytes are untouched — this is the "PGlite can be
5228
+ * dropped and rebuilt" invariant made executable.
5229
+ */
5230
+ declare function dropAttachmentProjection(db: DatabaseClient): Promise<void>;
5231
+
5232
+ /**
5233
+ * PGlite record projection — notes tier (#323 cycle 2, ADR-013 D3).
5234
+ *
5235
+ * Projects canonical note / tag / link / collection state (RecordStore) into
5236
+ * the optional PGlite tables, completing the projection the attachment tier
5237
+ * (#320, attachment-projection.ts) deferred to this cycle. Properties:
5238
+ *
5239
+ * - Idempotent: rows upsert on their primary keys; re-running with the same
5240
+ * canonical state changes nothing.
5241
+ * - Rebuildable: dropping the projection rows and re-projecting yields
5242
+ * equivalent query results — canonical records are the source of truth.
5243
+ * - Reconciling: canonically hard-removed rows (note_tag, collection_note)
5244
+ * are deleted from the projection so parity holds after removals, not just
5245
+ * after inserts.
5246
+ * - Bytes never enter PGlite; `projectRecords` composes this pass with the
5247
+ * attachment projection for a full canonical → PGlite rebuild.
5248
+ */
5249
+
5250
+ interface NoteProjectionResult {
5251
+ notes: number;
5252
+ tags: number;
5253
+ links: number;
5254
+ collections: number;
5255
+ memberships: number;
5256
+ }
5257
+ interface RecordProjectionResult extends NoteProjectionResult {
5258
+ attachments: AttachmentProjectionResult;
5259
+ }
5260
+ /**
5261
+ * Project all canonical note-tier records into PGlite. Safe to run at any
5262
+ * time: startup, after journal consumption, or as a full rebuild after the
5263
+ * projection was dropped. Parent rows land before children (note before
5264
+ * note_original / tags / links / memberships) so FKs hold.
5265
+ */
5266
+ declare function projectNotes(db: DatabaseClient, store: RecordStore): Promise<NoteProjectionResult>;
5267
+ /**
5268
+ * Full canonical → PGlite projection: note tier, then attachment tier
5269
+ * (parents before children). This is the "PGlite is a derived, rebuildable
5270
+ * projection" invariant (#322 acceptance) made executable.
5271
+ */
5272
+ declare function projectRecords(db: DatabaseClient, store: RecordStore): Promise<RecordProjectionResult>;
5273
+ /**
5274
+ * Drop the note-tier projection rows (test/rebuild support). Canonical
5275
+ * records are untouched. Callers must drop dependent projections first
5276
+ * (attachments via `dropAttachmentProjection`, plus any embedding/SKOS rows
5277
+ * created outside the canonical tier) so FKs allow the deletes.
5278
+ */
5279
+ declare function dropNoteProjection(db: DatabaseClient): Promise<void>;
5280
+
5281
+ /**
5282
+ * Writable non-PGlite `DataBackend` over the canonical RecordStore
5283
+ * (#323 cycle 2, ADR-013 D3) — the record tier in the backend seam.
5284
+ *
5285
+ * Fills the seam's historical gap: the static shard backend is read-only and
5286
+ * the PGlite backend needs a database. This adapter serves the canonical
5287
+ * repositories' full write surface plus the bounded read tier (id / recent /
5288
+ * tag / link lookups and a bounded substring scan) with instant startup.
5289
+ *
5290
+ * Capability boundary, reported honestly: `semantic: 'none'` (no vectors) and
5291
+ * search is a bounded scan, not ranked FTS. SKOS concepts and provenance
5292
+ * edges are not part of the canonical record collections, so `conceptsOf` /
5293
+ * `provenanceOf` are deliberately absent — callers feature-detect via the
5294
+ * optional methods rather than receiving silently empty emulations.
5295
+ * `merge: true` is served by `importShardToRecords` (record-shard.ts).
5296
+ */
5297
+
5298
+ interface RecordBackendOptions {
5299
+ id?: string;
5300
+ }
5301
+ interface RecordBackendManageNoteResult {
5302
+ action: string;
5303
+ note_id: string;
5304
+ note?: CanonicalNoteView;
5305
+ }
5306
+ /**
5307
+ * Wrap a canonical `RecordStore` as a writable `DataBackend`. Reads and
5308
+ * writes delegate to `CanonicalNotesRepository`; `manageNote` accepts the
5309
+ * same Zod-validated input as the PGlite tool (update / delete / restore /
5310
+ * archive / unarchive / star / unstar).
5311
+ */
5312
+ declare function createRecordBackend(store: RecordStore, options?: RecordBackendOptions): DataBackend;
5313
+
5314
+ /**
5315
+ * DB-free Knowledge Shard export/import over the canonical RecordStore
5316
+ * (#323 cycle 2, ADR-013 D3/D6) — the same `.shard` archive format as the
5317
+ * PGlite pipeline (`shard/shard-export.ts` / `shard/shard-import.ts`), built
5318
+ * from and applied to canonical records with zero PGlite.
5319
+ *
5320
+ * Capability boundary (reported, never emulated): the canonical tier holds
5321
+ * notes, tags, note-to-note links, collections, and attachment manifests.
5322
+ * Shard components outside that set (templates, embeddings, SKOS, provenance,
5323
+ * graph/community artifacts, URL links) are skipped on import with explicit
5324
+ * warnings, and are never emitted on export.
5325
+ *
5326
+ * Atomicity: manifest, version, signature (ADR-014 verify-before-persist),
5327
+ * and checksum validation all run BEFORE any record or byte is written, and
5328
+ * `error`-strategy conflicts are pre-scanned so a conflicting archive writes
5329
+ * nothing. Each record commit is then individually atomic and journaled; an
5330
+ * interrupted import leaves a recoverable prefix that a re-import with
5331
+ * `conflictStrategy: 'skip'` completes idempotently.
5332
+ */
5333
+
5334
+ /**
5335
+ * Export canonical records as a `.shard` archive (Uint8Array), format-parity
5336
+ * with the PGlite `exportShard`. Honored options: `collectionId` / `tag`
5337
+ * filters, `clusterNotesSize`, and the portable byte sidecar
5338
+ * (`includeBlobs` + `blobStore`). Embedding options are inert — the canonical
5339
+ * tier stores no embeddings, so there is nothing to include.
5340
+ */
5341
+ declare function exportShardFromRecords(store: RecordStore, options?: ExportOptions): Promise<Uint8Array>;
5342
+ /**
5343
+ * Import a `.shard` archive into the canonical RecordStore (and optionally
5344
+ * hydrate attachment bytes into a Bytecask BlobStore) with zero PGlite.
5345
+ *
5346
+ * Honors `conflictStrategy` (`skip` default / `replace` / `error` — `error`
5347
+ * conflicts are pre-scanned so nothing is written), the ADR-014
5348
+ * `verifySignature`/`trustStore` policy, and byte-sidecar hydration via
5349
+ * `blobStore`. Components the canonical tier cannot persist are skipped with
5350
+ * explicit warnings and reported under `skipped`.
5351
+ */
5352
+ declare function importShardToRecords(store: RecordStore, data: Uint8Array | ArrayBuffer, options?: ImportOptions): Promise<ImportResult>;
4530
5353
 
4531
- declare const VERSION = "2026.7.5";
5354
+ declare const VERSION = "2026.7.8";
4532
5355
 
4533
- export { AIWG_SCAN_REQUIRED_FIELDS, type AiwgChunkedIndexBuildOptions, type AiwgChunkedIndexBuildResult, type AiwgChunkedIndexDetailLoader, type AiwgChunkedIndexLoadOptions, type AiwgChunkedIndexLoader, type AiwgChunkedIndexProgress, type AiwgChunkedIndexProgressPhase, type AiwgChunkedIndexQueryOptions, type AiwgChunkedIndexQueryResult, type AiwgChunkedIndexValidationResult, type AiwgFortemiAttachmentReference, type AiwgFortemiBinarySource, type AiwgFortemiChunk, type AiwgFortemiChunkDetailRef, type AiwgFortemiChunkManifest, type AiwgFortemiChunkPart, type AiwgFortemiChunkPartRef, type AiwgFortemiIndexExport, type AiwgFortemiIndexExportSchemaVersion, type AiwgFortemiProjectedRecord, type AiwgFortemiProvenance, type AiwgFortemiProvenanceEvent, type AiwgFortemiRecord, type AiwgFortemiRecordEmbedding, type AiwgFortemiRecordSchemaVersion, type AiwgFortemiRecordSource, type AiwgFortemiRecordType, type AiwgFortemiRelationship, type AiwgFortemiRelationshipDirection, type AiwgFortemiSearchProjection, type AiwgFortemiSkosConcept, type AiwgFortemiSkosRelation, type AiwgFortemiSkosRelationType, type AiwgHeadlessEmbeddingBackend, type AiwgIndexController, type AiwgIndexControllerListener, type AiwgIndexControllerSnapshot, type AiwgIndexGraphOptions, type AiwgIndexQueryMatch, type AiwgIndexQueryOptions, type AiwgIndexQueryRankedItem, type AiwgIndexQueryResult, type AiwgIndexQueryWeights, type AiwgIndexValidationResult, type AiwgPrivacyClassification, type AiwgPrivacyFilterOptions, type AiwgProvenanceConfidence, type AiwgRelationshipDirection, type AiwgRelationshipEdgeSummary, type AiwgRelationshipNodeSummary, type AiwgRelationshipQueryOptions, type AiwgRelationshipSetOperation, type AiwgRelationshipSetOptions, type AiwgRelationshipSetResult, type AiwgRelationshipTraversalOptions, type AiwgRelationshipTraversalResult, type AiwgReviewAction, type AiwgReviewDecision, type AiwgReviewDecisionExport, type AiwgReviewInput, type AiwgStaticDuplicatePair, type AiwgStaticEmbeddingRecord, type AiwgStaticEmbeddingSet, type AiwgStaticHybridQueryOptions, type AiwgStaticSemanticQueryOptions, type AiwgStaticSemanticResult, type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRow, 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, type BlobStore, type BridgeCapability, type BridgeProviderInfo, type BrowserNoteExport, type BuildAiwgStaticEmbeddingSetOptions, CURRENT_MIGRATION_HEAD, 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 CosineSemanticProviderOptions, type CreatePGliteOptions, type CspDirectiveName, type CspDirectives, type CspViolationReport, DB_SNAPSHOT_SCHEMA_VERSION, type DataBackend, type DatabaseClient, type DbSnapshot, type DbSnapshotCompat, type DbSnapshotCompression, type DbSnapshotExpectations, type DbSnapshotMeta, type DbSnapshotSource, DbSnapshotVersionError, type DiscoveredProvider, type DiscoveryOptions, type DumpDbSnapshotOptions, type DumpableDb, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, type EmbedFunction, type EmbedRequest, type EmbedRequestMessage, type EmbedResponse, type EmbedResponseMessage, type EmbedTransportPort, type EmbedWorkerOptions, 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, FORTEMI_COMPATIBILITY_PATH, FORTEMI_COMPATIBILITY_STATES, FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES, 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 GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type GraphNode, GraphRepository, type IDisposable, type ImportCounts, type ImportOptions, type ImportProgress, type ImportProgressPhase, 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 NoteSkosTag, type NoteSummary, type NoteUpdateInput, NotesRepository, OpenAICompatibleProvider, type OpenAIProviderConfig, type OpenShardOptions, type PGliteBackendOptions, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, type PGliteWorkerStorageBackendFactoryOptions, type PaginatedResult, type PersistenceMode, type PluginCspOptions, type PluginScriptDescriptor, type PluginScriptPolicy, type PrefetchOptions, type PrefetchResult, type ProbeResult, type ProbeStatus, type ProvenanceEdge, ProvenanceRepository, type ProviderCapabilities, ProviderRegistry, type ProviderTier, type QueryExecutor, type QueryResult, type RecommendedTier, type RecordProvenanceInput, type RemoteBackendConfig, type RemoteBackendPaths, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RestoreDbSnapshotOptions, type RouteHandler, SHARD_FORMAT, SUPPORTED_PGLITE_VERSION, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, type ShardBackendOptions, type ShardClusterRef, type ShardCollection, type ShardComponent, type ShardComponentStore, type ShardEmbedding, type ShardEmbeddingConfig, type ShardEmbeddingSet, type ShardEmbeddingSetMember, type ShardLayout, type ShardLink, type ShardListOptions, type ShardManifest, type ShardNote, type ShardNoteFull, type ShardNoteSkosTag, type ShardProvenanceEdge, type ShardReader, type ShardReaderNote, type ShardReaderSource, type ShardSchemaValidationResult, type ShardSearchOptions, type ShardSearchRankedNote, type ShardSearchResult, type ShardSearchWeights, type ShardSkosConcept, type ShardSkosRelation, type ShardSkosScheme, type ShardTag, type ShardTemplate, type SimilarityGraphCacheKey, type SimilarityGraphOptions, type SimilarityGraphRequest, type SimilarityGraphResult, type SkosConcept, type SkosRelation, SkosRepository, type SkosScheme, type StaticSemanticProvider, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, TagsRepository, TransactionProxy, TypedEventBus, VERSION, type VectorEntry, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, aiwgFortemiIndexToCommunityGraph, allMigrations, appendPluginScript, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, assertAiwgStaticEmbeddingSet, assertShardComponentRecord, buildAiwgChunkedIndex, buildAiwgStaticEmbeddingSet, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, computeBlobHash, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, createBlobStore, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteBackend, createPGliteInstance, createRemoteBackend, createRoutes, createShardBackend, createWorkerEmbedFunction, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, dumpDbSnapshot, embeddingConfigToShard, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchAndValidateFortemiCompatibility, fetchPluginScript, filterAiwgRecordsByPrivacy, findAiwgStaticDuplicatePairs, formatFortemiCompatibilitySummary, fortemiCompatibilityUrl, fortemiManifest, fromPrefetched, generateId, getAiwgFortemiFacets, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getKnowledgeShardSchema, getLlmFunction, getNote, getPrefetchedSha256, handleEmbedRequests, hasFortemiSecureSecrets, importShard, isPluginScriptAllowed, isShardPrefetched, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, provenanceEdgeToShard, queryAiwgFortemiIndex, queryAiwgHybridIndex, queryAiwgSemanticIndex, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsToShard, templateToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, urlLinkToShard, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateAiwgStaticEmbeddingSet, validateChecksums, validateFortemiCompatibilityResponse, validateShardArchive, validateShardComponentRecord, validateShardManifest, verifyDbSnapshotMeta, verifySri };
5356
+ export { AIWG_SCAN_REQUIRED_FIELDS, type AiwgChunkedIndexBuildOptions, type AiwgChunkedIndexBuildResult, type AiwgChunkedIndexDetailLoader, type AiwgChunkedIndexLoadOptions, type AiwgChunkedIndexLoader, type AiwgChunkedIndexProgress, type AiwgChunkedIndexProgressPhase, type AiwgChunkedIndexQueryOptions, type AiwgChunkedIndexQueryResult, type AiwgChunkedIndexValidationResult, type AiwgFortemiAttachmentReference, type AiwgFortemiBinarySource, type AiwgFortemiChunk, type AiwgFortemiChunkDetailRef, type AiwgFortemiChunkManifest, type AiwgFortemiChunkPart, type AiwgFortemiChunkPartRef, type AiwgFortemiIndexExport, type AiwgFortemiIndexExportSchemaVersion, type AiwgFortemiProjectedRecord, type AiwgFortemiProvenance, type AiwgFortemiProvenanceEvent, type AiwgFortemiRecord, type AiwgFortemiRecordEmbedding, type AiwgFortemiRecordSchemaVersion, type AiwgFortemiRecordSource, type AiwgFortemiRecordType, type AiwgFortemiRelationship, type AiwgFortemiRelationshipDirection, type AiwgFortemiSearchProjection, type AiwgFortemiSkosConcept, type AiwgFortemiSkosRelation, type AiwgFortemiSkosRelationType, type AiwgHeadlessEmbeddingBackend, type AiwgIndexController, type AiwgIndexControllerListener, type AiwgIndexControllerSnapshot, type AiwgIndexGraphOptions, type AiwgIndexQueryMatch, type AiwgIndexQueryOptions, type AiwgIndexQueryRankedItem, type AiwgIndexQueryResult, type AiwgIndexQueryWeights, type AiwgIndexValidationResult, type AiwgKnowledgeShardOptions, type AiwgPrivacyClassification, type AiwgPrivacyFilterOptions, type AiwgProvenanceConfidence, type AiwgRelationshipDirection, type AiwgRelationshipEdgeSummary, type AiwgRelationshipNodeSummary, type AiwgRelationshipQueryOptions, type AiwgRelationshipSetOperation, type AiwgRelationshipSetOptions, type AiwgRelationshipSetResult, type AiwgRelationshipTraversalOptions, type AiwgRelationshipTraversalResult, type AiwgReviewAction, type AiwgReviewDecision, type AiwgReviewDecisionExport, type AiwgReviewInput, type AiwgStaticDuplicatePair, type AiwgStaticEmbeddingRecord, type AiwgStaticEmbeddingSet, type AiwgStaticHybridQueryOptions, type AiwgStaticSemanticQueryOptions, type AiwgStaticSemanticResult, AllowlistTrustStore, 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, type BlobBackendKind, type BlobGcOptions, type BlobGcResult, type BlobReconcileOptions, type BlobReconcileResult, type BlobStore, type BlobStoreDiagnostics, type BridgeCapability, type BridgeProviderInfo, type BrowserNoteExport, type BuildAiwgStaticEmbeddingSetOptions, CURRENT_MIGRATION_HEAD, CURRENT_SHARD_VERSION, 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 CollectionRecord, 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 CosineSemanticProviderOptions, type CreateBlobStoreOptions, type CreatePGliteOptions, type CreateRecordStoreOptions, type CspDirectiveName, type CspDirectives, type CspViolationReport, DB_SNAPSHOT_SCHEMA_VERSION, type DataBackend, type DatabaseClient, type DbSnapshot, type DbSnapshotCompat, type DbSnapshotCompression, type DbSnapshotExpectations, type DbSnapshotMeta, type DbSnapshotSource, DbSnapshotVersionError, type DiscoveredProvider, type DiscoveryOptions, type DumpDbSnapshotOptions, type DumpableDb, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, type EmbedFunction, type EmbedRequest, type EmbedRequestMessage, type EmbedResponse, type EmbedResponseMessage, type EmbedTransportPort, type EmbedWorkerOptions, 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, FORTEMI_COMPATIBILITY_PATH, FORTEMI_COMPATIBILITY_STATES, FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES, 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 GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type GraphNode, GraphRepository, type IDisposable, IdbRecordStore, type ImportCounts, type ImportOptions, type ImportProgress, type ImportProgressPhase, type ImportResult, type InferenceCapabilities, type InferenceProvider, JOB_CAPABILITIES, JOB_PRIORITIES, type JobQueueOptions, JobQueueWorker, type JobStatus, type JobType, type JournalEntry, LOCAL_ENDPOINTS, type LegacyMigrationReport, type LinkRecord0, 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, MemoryRecordStore, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteOriginalRecord, type NoteProjectionResult, type NoteRecord0, type NoteRevisedCurrentRecord, type NoteRevision, type NoteSkosTag, type NoteSummary, type NoteTagRecord, type NoteUpdateInput, NotesRepository, OpenAICompatibleProvider, type OpenAIProviderConfig, type OpenShardOptions, type PGliteBackendOptions, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, type PGliteWorkerStorageBackendFactoryOptions, type PaginatedResult, type PersistenceMode, type PluginCspOptions, type PluginScriptDescriptor, type PluginScriptPolicy, type PrefetchOptions, type PrefetchResult, type ProbeResult, type ProbeStatus, type ProvenanceEdge, ProvenanceRepository, type ProviderCapabilities, ProviderRegistry, type ProviderTier, type QueryExecutor, type QueryResult, RECORD_COLLECTIONS, RECORD_SCHEMA_VERSION, RECORD_STORE_CAPABILITIES, type RecommendedTier, type RecordBackendManageNoteResult, type RecordBackendOptions, type RecordCollectionName, type RecordCollections, type RecordListOptions, type RecordProjectionResult, type RecordProvenanceInput, type RecordStore, type RecordStoreCapabilities, type RemoteBackendConfig, type RemoteBackendPaths, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RestoreDbSnapshotOptions, type RouteHandler, SHARD_FORMAT, SIGNATURE_ENTRY, SIGNING_ENVELOPE_VERSION, SUPPORTED_PGLITE_VERSION, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, type ShardBackendOptions, type ShardClusterRef, type ShardCollection, type ShardComponent, type ShardComponentStore, type ShardEmbedding, type ShardEmbeddingConfig, type ShardEmbeddingSet, type ShardEmbeddingSetMember, type ShardLayout, type ShardLink, type ShardListOptions, type ShardManifest, type ShardNote, type ShardNoteFull, type ShardNoteSkosTag, type ShardProvenanceEdge, type ShardReader, type ShardReaderNote, type ShardReaderSource, type ShardSchemaValidationResult, type ShardSearchOptions, type ShardSearchRankedNote, type ShardSearchResult, type ShardSearchWeights, type ShardSignatureEnvelope, type ShardSignatureVerdict, type ShardSigner, type ShardSigningPayload, type ShardSkosConcept, type ShardSkosRelation, type ShardSkosScheme, type ShardTag, type ShardTemplate, type ShardTrustStore, type SignShardInput, type SimilarityGraphCacheKey, type SimilarityGraphOptions, type SimilarityGraphRequest, type SimilarityGraphResult, type SkosConcept, type SkosRelation, SkosRepository, type SkosScheme, type StaticSemanticProvider, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, TagsRepository, TransactionProxy, type TrustedKey, TypedEventBus, VERSION, type VectorEntry, type VerifyShardSignatureInput, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, aiwgFortemiIndexFromKnowledgeShard, aiwgFortemiIndexToCommunityGraph, aiwgFortemiIndexToKnowledgeShard, allMigrations, appendPluginScript, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, assertAiwgStaticEmbeddingSet, assertShardComponentRecord, buildAiwgChunkedIndex, buildAiwgStaticEmbeddingSet, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, computeBlobHash, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, createBlobStore, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLazyBlobStore, createLegacyProvider, createPGliteBackend, createPGliteInstance, createRecordBackend, createRecordStore, createRemoteBackend, createRoutes, createShardBackend, createWorkerEmbedFunction, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, dropAttachmentProjection, dropNoteProjection, dumpDbSnapshot, embeddingConfigToShard, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, exportShardFromRecords, fetchAndValidateFortemiCompatibility, fetchPluginScript, filterAiwgRecordsByPrivacy, findAiwgStaticDuplicatePairs, formatFortemiCompatibilitySummary, fortemiCompatibilityUrl, fortemiManifest, fromPrefetched, generateId, getAiwgFortemiFacets, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getKnowledgeShardSchema, getLlmFunction, getNote, getPrefetchedSha256, handleEmbedRequests, hasFortemiSecureSecrets, importShard, importShardToRecords, isPluginScriptAllowed, isShardPrefetched, isShardSigningSupported, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, migrateLegacyBlobStore, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, projectAttachments, projectNotes, projectRecords, provenanceEdgeToShard, queryAiwgFortemiIndex, queryAiwgHybridIndex, queryAiwgSemanticIndex, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, sidecarBlobDigests, signShard, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsToShard, templateToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, urlLinkToShard, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateAiwgStaticEmbeddingSet, validateChecksums, validateFortemiCompatibilityResponse, validateShardArchive, validateShardComponentRecord, validateShardManifest, verifyDbSnapshotMeta, verifyShardSignature, verifySri };