@fortemi/core 2026.9.2 → 2026.9.3

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
@@ -5692,5 +5692,5 @@ declare function purgeRecordStoreGraph(store: RecordStore, selector: PurgeSelect
5692
5692
  * @created 2026-07-17
5693
5693
  * @agent Codex
5694
5694
  */
5695
- declare const VERSION = "2026.9.2";
5695
+ declare const VERSION = "2026.9.3";
5696
5696
  export { type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRecord, type AttachmentBlobRow, type AttachmentProjectionResult, type AttachmentRecord, type AttachmentRow, AttachmentsRepository, type BackendCandidate, type BackendCapabilities, type BackendConcept, type BackendLink, type BackendListOptions, type BackendNote, type BackendNoteFull, type BackendProvenanceEdge, type BackendRequest, type BackendSearchHit, type BackendSearchQueryOptions, type BackendSearchResult, type BackendSelection, type BackendSemanticTier, type BackendStartupCost, BlobGcOptions, BlobGcResult, BlobReconcileOptions, BlobReconcileResult, BlobStore, type BridgeCapability, BridgeInferenceProvider, type BridgeProviderInfo, type BrowserNoteExport, CORE_V1_COMPONENTS, CURRENT_MIGRATION_HEAD, type CanonicalAttachInput, CanonicalAttachmentsRepository, type CanonicalNoteCreateInput, type CanonicalNoteUpdateInput, type CanonicalNoteView, CanonicalNotesRepository, type CapabilityInfo, CapabilityManager, type CapabilityName, type CapabilityState, type CaptureKnowledgeInput, CaptureKnowledgeInputSchema, type CaptureKnowledgeResult, type CollectionCreateInput, type CollectionNoteRecord, type 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 ConfigureInferenceRuntimeOptions, type ConfiguredInferenceProvider, type ConfiguredInferenceRuntime, type CooldownConfig, type CooldownEvent, type CosineSemanticProviderOptions, type CreatePGliteOptions, type CreateRecordStoreOptions, type CspDirectiveName, type CspDirectives, type CspViolationReport, DATASET_EXECUTION_CAPABILITY_IDS, DATASET_EXECUTION_CONTRACT, DATASET_EXECUTION_SCHEMA_VERSION, DATASET_INGEST_CONTRACT, DATASET_INGEST_SCHEMA_VERSION, DATASET_LINEAGE_CONTRACT, DATASET_LINEAGE_SCHEMA_VERSION, DATASET_MATERIALIZATION_CONTRACT, DATASET_MATERIALIZATION_KINDS, DATASET_MATERIALIZATION_SCHEMA_VERSION, DB_SNAPSHOT_SCHEMA_VERSION, DEFAULT_LARGE_DOCUMENT_CHARS, DEFAULT_LARGE_DOCUMENT_CHUNKS, type DataBackend, type DatabaseClient, type DatasetBenchmarkEvidence, type DatasetCapabilityDeclaration, type DatasetCapabilityDegradation, type DatasetCapabilityDiagnostic, type DatasetCapabilityDiagnosticCode, type DatasetCapabilityEvidence, type DatasetCapabilityLimits, type DatasetCapabilityNegotiationRequest, type DatasetCapabilityNegotiationResult, type DatasetCapabilityRequirement, type DatasetCapabilityStatus, type DatasetCheckpoint, type DatasetDestinationScope, type DatasetDeterminismClass, type DatasetDigest, type DatasetExecutionCapabilityDescriptor, type DatasetExecutionCapabilityId, type DatasetExecutionDataClass, type DatasetExecutionMaturity, type DatasetExecutionPlane, type DatasetImplementationIdentity, type DatasetIncrementalParityResult, DatasetIngestError, type DatasetIngestErrorCode, DatasetIngestExecutor, type DatasetIngestHooks, type DatasetIngestMode, type DatasetIngestStore, type DatasetIngestTransaction, DatasetLineageLedger, type DatasetLineageLedgerOptions, type DatasetMaterializationAdapter, type DatasetMaterializationArtifact, DatasetMaterializationError, type DatasetMaterializationKind, type DatasetMaterializationOperation, type DatasetMaterializationProfile, type DatasetMaterializationReceipt, type DatasetMaterializationRequest, type DatasetMeasuredResources, type DatasetMutation, type DatasetMutationBatch, type DatasetOptionalCapabilityRequirement, type DatasetPrivacyBoundary, type DatasetPrivacyDecision, type DatasetProcessingPlan, type DatasetProfileNegotiationRequest, type DatasetProfileNegotiationResult, type DatasetProfileStatus, type DatasetRecordAuthorizer, type DatasetRecordRejection, type DatasetRetrievalRequest, type DatasetRetrievalResponse, type DatasetRunAttempt, type DatasetRunReceipt, type DatasetRunState, type DatasetRunStatus, type DatasetSourceRecord, type DatasetSourceSnapshot, type DatasetStoredRecord, type DatasetTombstoneMutation, type DatasetUpsertMutation, type DatasetVerificationState, type DbSnapshot, type DbSnapshotCompat, type DbSnapshotCompression, type DbSnapshotExpectations, type DbSnapshotMeta, type DbSnapshotSource, DbSnapshotVersionError, type DeletionReceipt, type DeletionReceiptRecord, type DiscoveredProvider, type DiscoveryOptions, type DumpDbSnapshotOptions, type DumpableDb, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, type EmbedFunction, type EmbedFunctionOptions, type EmbedRequest, type EmbedRequestMessage, type EmbedResponse, type EmbedResponseMessage, type EmbedTransportPort, type EmbedWorkerOptions, type EmbeddingCompatibilityPolicy, type EmbeddingSetCreateInput, type EmbeddingSetCriteria, type EmbeddingSetDescriptor, type EmbeddingSetEmbeddingInput, type EmbeddingSetFreshness, type EmbeddingSetKind, type EmbeddingSetMode, type EmbeddingSetRow, type EmbeddingSetSelector, EmbeddingSetsRepository, type EmbeddingTaskSelectionOptions, type EnqueueJobInput, type ErrorCategory, type EventMap, type EvidenceLocator, type ExecuteDatasetBatchOptions, ExportOptions, FORTEMI_BROWSER_LOCAL_DATASET_EXECUTION_DESCRIPTOR, FORTEMI_COMPATIBILITY_PATH, FORTEMI_COMPATIBILITY_STATES, FORTEMI_PORTABLE_SHARD_DATASET_EXECUTION_DESCRIPTOR, FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES, FORTEMI_SERVER_COMPATIBILITY_REVISION, FORTEMI_STATIC_CACHE_DATASET_EXECUTION_DESCRIPTOR, type FallbackEvent, FallbackRouter, type FallbackRouterConfig, type FetchFortemiCompatibilityOptions, type FortemiBridge, type FortemiBridgeCapabilities, type FortemiBridgeHost, type FortemiCompatibilityCapability, type FortemiCompatibilityResponse, type FortemiCompatibilityState, type FortemiCompatibilityValidationResult, type FortemiConfig, type FortemiCore, type FortemiInferenceRouter, type FortemiRequiredCompatibilityCapability, type FortemiSecretStore, type FortemiToolDefinition, FortemiToolManifest, type GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type GraphNode, GraphRepository, type IDisposable, IdbRecordStore, ImportOptions, ImportResult, type InferenceCapabilities, type InferenceProvider, type InferenceRuntimeConfig, type InferenceTask, JOB_CAPABILITIES, JOB_PRIORITIES, type JobQueueOptions, JobQueueWorker, type JobStatus, type JobType, type JournalEntry, LINEAGE_ENTITY_KINDS, LINEAGE_RELATIONSHIP_KINDS, LOCAL_ENDPOINTS, type LegacyInferenceProviderConfig, type LegacyMigrationReport, LifecyclePurgeRepository, type LineageActivity, type LineageAgent, type LineageAssertion, type LineageAssertionKind, type LineageAuthorizationPolicy, type LineageCorrection, type LineageEntity, type LineageEntityKind, type LineageEvidence, type LineageEvidenceReference, type LineageLedgerArchive, type LineageLossItem, type LineageLossReceipt, type LineagePrivacy, type LineageProjection, type LineageProjectionCapabilities, type LineageRelationshipKind, type LineageTraversalEdge, type LineageTraversalNode, type LineageTraversalRequest, type LineageTraversalResult, type LineageValidationCode, LineageValidationError, type LinkRecord0, type LinkRow, LinksRepository, type ListNotesInput, ListNotesInputSchema, type LlmCapabilityOptions, type LlmCompleteFn, type LlmCompleteOptions, type LoadedPluginScript, type LocalEndpoint, type ManageArchiveInput, ManageArchiveInputSchema, type ManageArchiveResult, type ManageAttachmentsInput, ManageAttachmentsInputSchema, type ManageAttachmentsResult, type ManageCapabilitiesInput, ManageCapabilitiesInputSchema, type ManageCapabilitiesResult, type ManageCollectionsInput, ManageCollectionsInputSchema, type ManageCollectionsResult, type ManageLinksInput, ManageLinksInputSchema, type ManageLinksResult, type ManageNoteInput, ManageNoteInputSchema, type ManageNoteResult, type ManageTagsInput, ManageTagsInputSchema, type ManageTagsResult, MemoryDatasetIngestStore, MemoryRecordStore, type MetadataPredicate, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteOriginalRecord, type NoteProjectionResult, type NoteRecord0, type NoteRevisedCurrentRecord, type NoteRevision, type NoteRevisionRecord, 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 PresenceTrackedRecord, type ProbeResult, type ProbeStatus, type ProvenanceEdge, ProvenanceRepository, type ProviderCapabilities, type ProviderCostTier, type ProviderDataClass, type ProviderPrivacyTier, type ProviderProfile, ProviderRegistry, type ProviderRoutePolicy, type ProviderRouteProbeResult, type ProviderRouteRequirements, type ProviderRouteSelection, type ProviderRouteValidation, type ProviderRouteValidationIssue, type ProviderRouteValidationSeverity, type ProviderTier, type PurgeCounts, type PurgePreview, type PurgeSelector, type QueryExecutor, type QueryResult, RECORD_COLLECTIONS, RECORD_SCHEMA_VERSION, RECORD_STORE_CAPABILITIES, REGISTERED_METADATA_PATHS, type RecommendedTier, type RecordBackendManageNoteResult, type RecordBackendOptions, type RecordCollectionName, type RecordCollections, type RecordListOptions, type RecordMutation, type RecordProjectionResult, type RecordProvenanceInput, type RecordStore, type RecordStoreCapabilities, type RegisteredMetadataPath, type RemoteBackendConfig, type RemoteBackendPaths, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RestoreDbSnapshotOptions, type RouteHandler, SOURCE_UPSERT_CONTRACT_VERSION, SOURCE_UPSERT_MAX_ITEMS, SUPPORTED_PGLITE_VERSION, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, ShardBackend, type ShardBackendOptions, ShardCapabilityReport, ShardCollection, ShardComponent, type ShardComponentStore, ShardEmbedding, ShardEmbeddingConfig, ShardEmbeddingSet, ShardEmbeddingSetMember, ShardExportResult, ShardLink, type ShardListOptions, ShardLossEntry, ShardManifest, ShardNote, type ShardNoteFull, ShardNoteSkosTag, ShardOperation, ShardProfileRegistryEntry, ShardProvenanceEdge, type ShardReader, type ShardReaderNote, type ShardReaderSource, type ShardSchemaValidationResult, type ShardSearchOptions, type ShardSearchRankedNote, type ShardSearchResult, type ShardSearchWeights, ShardSkosConcept, ShardSkosRelation, ShardSkosScheme, ShardTag, ShardTemplate, type SimilarityGraphCacheKey, type SimilarityGraphOptions, type SimilarityGraphRequest, type SimilarityGraphResult, type SkosConcept, type SkosRelation, SkosRepository, type SkosScheme, type SourceIdentityInput, type SourceIdentityRecord, type SourceImportBatchRecord, type SourceImportRunRecord, type SourceUpsertBatchOutcome, type SourceUpsertBatchResult, type SourceUpsertItem, type SourceUpsertItemResult, type SourceUpsertOptions, type SourceUpsertOutcome, type SourceUpsertPolicy, type SourceUpsertReasonCode, SourceUpsertRepository, type SourceUpsertRequest, type SourceUpsertRequestItem, type SourceUpsertResponse, type SourceUpsertScope, type StaticSemanticProvider, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, TagsRepository, TransactionProxy, TypedEventBus, VERSION, type VectorEntry, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, allMigrations, appendPluginScript, assertShardComponentRecord, buildMetadataPredicateConditions, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, compareDatasetIncrementalParity, computeBlobHash, computeHash, computeLineageDigest, computeSri, conceptTaggingHandler, configureInferenceRuntime, cosineSimilarity, createBridgeInferenceProviders, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLegacyProvider, createLocalProviderProfile, createPGliteBackend, createPGliteInstance, createRecordBackend, createRecordStore, createRemoteBackend, createRoutes, createShardBackend, createShardCapabilityReport, createWorkerEmbedFunction, datasetDestinationScopeKey, defaultStorageBackendFactory, defineInferenceProvider, defineInferenceRuntime, defineLegacyInferenceProvider, defineOpenAICompatibleProvider, deriveDatasetIngestIdempotencyKey, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, digestDatasetMaterializationValue, discoverLocalProviders, dropAttachmentProjection, dropNoteProjection, dumpDbSnapshot, embeddingConfigToShard, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, executeDatasetMaterialization, executeDatasetRetrieval, exportShard, exportShardFromRecords, exportShardFromRecordsWithReport, exportShardWithReport, fetchAndValidateFortemiCompatibility, fetchPluginScript, formatFortemiCompatibilitySummary, fortemiCompatibilityUrl, fortemiManifest, fromPrefetched, generateId, getConfiguredInferenceProviderId, getEmbedFunction, getEmbeddingTaskSelectionOptions, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getKnowledgeShardContractReceipt, getKnowledgeShardProfileRegistry, getKnowledgeShardSchema, getLlmFunction, getNote, getPrefetchedSha256, getProviderRouteRequirementIssue, handleEmbedRequests, hasFortemiSecureSecrets, importShard, importShardToRecords, inferInferenceTaskCapability, inferLocalEmbeddingDimensions, isPluginScriptAllowed, isShardPrefetched, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, mergeInferenceRuntimeConfigs, migrateLegacyBlobStore, negotiateDatasetExecutionCapabilities, negotiateDatasetMaterializationProfile, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, previewRecordStorePurge, profileSupportError, projectAttachments, projectNotes, projectRecords, provenanceEdgeToShard, providerSatisfiesRouteRequirements, purgeRecordStoreGraph, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectEmbeddingTask, selectLlmModel, setEmbedFunction, setEmbeddingTaskSelectionOptions, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsToShard, templateToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, upsertRecordStoreRequest, upsertRecordStoreSources, urlLinkToShard, validateChecksums, validateCoreV1ShardArchive, validateDatasetBenchmarkEvidence, validateDatasetExecutionDescriptor, validateFortemiCompatibilityResponse, validateFullV1ShardArchive, validateProviderRoute, validateRecordV1ShardArchive, validateShardArchive, validateShardComponentRecord, validateShardManifest, verifyDbSnapshotMeta, verifySri };
package/dist/index.js CHANGED
@@ -30501,7 +30501,10 @@ function writeRecords(files, component, records) {
30501
30501
  const text = spec.encoding === "json-array" ? JSON.stringify(records) : records.map((record) => JSON.stringify(record)).join("\n");
30502
30502
  files.set(spec.file, encoder3.encode(text));
30503
30503
  }
30504
- async function liveRepresentationLosses(db) {
30504
+ function scoped(values) {
30505
+ return values ? [...values] : void 0;
30506
+ }
30507
+ async function liveRepresentationLosses(db, scope = {}) {
30505
30508
  const tables = [
30506
30509
  ["collection", "collections"],
30507
30510
  ["link", "links"],
@@ -30512,8 +30515,39 @@ async function liveRepresentationLosses(db) {
30512
30515
  ];
30513
30516
  const losses = [];
30514
30517
  for (const [table, component] of tables) {
30518
+ const noteIds2 = scoped(scope.noteIds);
30519
+ let sql = `SELECT COUNT(*) AS count FROM ${table} WHERE deleted_at IS NOT NULL`;
30520
+ let params = [];
30521
+ if (noteIds2) {
30522
+ if (noteIds2.length === 0) continue;
30523
+ if (table === "attachment") {
30524
+ sql += " AND note_id = ANY($1)";
30525
+ params = [noteIds2];
30526
+ } else if (table === "link") {
30527
+ sql += " AND source_note_id = ANY($1) AND target_note_id = ANY($1)";
30528
+ params = [noteIds2];
30529
+ } else if (table === "link_url_target") {
30530
+ sql += " AND source_note_id = ANY($1)";
30531
+ params = [noteIds2];
30532
+ } else if (table === "collection") {
30533
+ sql += " AND EXISTS (SELECT 1 FROM collection_note cn WHERE cn.collection_id = collection.id AND cn.note_id = ANY($1))";
30534
+ params = [noteIds2];
30535
+ } else if (table === "skos_concept") {
30536
+ sql += " AND EXISTS (SELECT 1 FROM note_skos_tag nst WHERE nst.concept_id = skos_concept.id AND nst.note_id = ANY($1))";
30537
+ params = [noteIds2];
30538
+ } else if (table === "skos_scheme") {
30539
+ sql += ` AND EXISTS (
30540
+ SELECT 1
30541
+ FROM skos_concept sc
30542
+ JOIN note_skos_tag nst ON nst.concept_id = sc.id
30543
+ WHERE sc.scheme_id = skos_scheme.id AND nst.note_id = ANY($1)
30544
+ )`;
30545
+ params = [noteIds2];
30546
+ }
30547
+ }
30515
30548
  const result = await db.query(
30516
- `SELECT COUNT(*) AS count FROM ${table} WHERE deleted_at IS NOT NULL`
30549
+ sql,
30550
+ params
30517
30551
  );
30518
30552
  const count2 = Number(result.rows[0]?.count ?? 0);
30519
30553
  if (count2 > 0) {
@@ -30527,8 +30561,11 @@ async function liveRepresentationLosses(db) {
30527
30561
  });
30528
30562
  }
30529
30563
  }
30564
+ const noteIds = scoped(scope.noteIds);
30565
+ const embeddingSetIds = scoped(scope.embeddingSetIds);
30530
30566
  const nullRevisions = await db.query(
30531
- "SELECT COUNT(*) AS count FROM note_revised_current WHERE content IS NULL"
30567
+ noteIds ? noteIds.length === 0 ? "SELECT 0 AS count" : "SELECT COUNT(*) AS count FROM note_revised_current WHERE content IS NULL AND note_id = ANY($1)" : "SELECT COUNT(*) AS count FROM note_revised_current WHERE content IS NULL",
30568
+ noteIds && noteIds.length > 0 ? [noteIds] : []
30532
30569
  );
30533
30570
  const nullRevisionCount = Number(nullRevisions.rows[0]?.count ?? 0);
30534
30571
  if (nullRevisionCount > 0) {
@@ -30544,11 +30581,31 @@ async function liveRepresentationLosses(db) {
30544
30581
  reason: "full-v1-live-production"
30545
30582
  });
30546
30583
  }
30584
+ const vectorConditions = [];
30585
+ const vectorParams = [];
30586
+ if (noteIds) {
30587
+ if (noteIds.length === 0) {
30588
+ vectorConditions.push("FALSE");
30589
+ } else {
30590
+ vectorParams.push(noteIds);
30591
+ vectorConditions.push(`note_id = ANY($${vectorParams.length})`);
30592
+ }
30593
+ }
30594
+ if (embeddingSetIds) {
30595
+ if (embeddingSetIds.length === 0) {
30596
+ vectorConditions.push("FALSE");
30597
+ } else {
30598
+ vectorParams.push(embeddingSetIds);
30599
+ vectorConditions.push(`embedding_set_id = ANY($${vectorParams.length})`);
30600
+ }
30601
+ }
30547
30602
  const vectorDimensions = await db.query(
30548
30603
  `SELECT vector_dims(vector)::int AS dimension, COUNT(*)::int AS count
30549
30604
  FROM embedding
30605
+ ${vectorConditions.length > 0 ? `WHERE ${vectorConditions.join(" AND ")}` : ""}
30550
30606
  GROUP BY vector_dims(vector)
30551
- ORDER BY vector_dims(vector)`
30607
+ ORDER BY vector_dims(vector)`,
30608
+ vectorParams
30552
30609
  );
30553
30610
  for (const row of vectorDimensions.rows) {
30554
30611
  const dimension = Number(row.dimension);
@@ -30567,9 +30624,19 @@ async function liveRepresentationLosses(db) {
30567
30624
  });
30568
30625
  }
30569
30626
  const unsupportedProvenance = await db.query(
30570
- `SELECT COUNT(*) AS count
30627
+ noteIds ? noteIds.length === 0 ? "SELECT 0 AS count" : `SELECT COUNT(*) AS count
30628
+ FROM provenance_edge pe
30629
+ WHERE entity_type NOT IN ('note', 'revision')
30630
+ AND (
30631
+ (pe.entity_type = 'note' AND pe.entity_id = ANY($1))
30632
+ OR EXISTS (
30633
+ SELECT 1 FROM note_revision nr
30634
+ WHERE nr.id = pe.entity_id AND nr.note_id = ANY($1)
30635
+ )
30636
+ )` : `SELECT COUNT(*) AS count
30571
30637
  FROM provenance_edge
30572
- WHERE entity_type NOT IN ('note', 'revision')`
30638
+ WHERE entity_type NOT IN ('note', 'revision')`,
30639
+ noteIds && noteIds.length > 0 ? [noteIds] : []
30573
30640
  );
30574
30641
  const unsupportedProvenanceCount = Number(unsupportedProvenance.rows[0]?.count ?? 0);
30575
30642
  if (unsupportedProvenanceCount > 0) {
@@ -30587,13 +30654,17 @@ async function liveRepresentationLosses(db) {
30587
30654
  }
30588
30655
  return losses;
30589
30656
  }
30590
- async function noteHistoryRecords(db) {
30657
+ async function noteHistoryRecords(db, noteIds) {
30591
30658
  const originals = await db.query("SELECT * FROM note_original ORDER BY created_at, id");
30592
30659
  const revisions = await db.query("SELECT * FROM note_revision ORDER BY note_id, revision_number, id");
30593
30660
  const current = await db.query("SELECT note_id, content, ai_metadata FROM note_revised_current ORDER BY note_id");
30661
+ const includesNote = (noteId) => !noteIds || noteIds.has(noteId);
30662
+ const originalRows = originals.rows.filter((row) => includesNote(row.note_id));
30663
+ const revisionRows = revisions.rows.filter((row) => includesNote(row.note_id));
30664
+ const currentRows = current.rows.filter((row) => includesNote(row.note_id));
30594
30665
  const previousByNote = /* @__PURE__ */ new Map();
30595
30666
  const lastByNote = /* @__PURE__ */ new Map();
30596
- const revisionRecords = revisions.rows.map((row) => {
30667
+ const revisionRecords = revisionRows.map((row) => {
30597
30668
  const metadata = jsonObject3(row.ai_metadata);
30598
30669
  const parentRevisionId = previousByNote.get(row.note_id) ?? null;
30599
30670
  previousByNote.set(row.note_id, row.id);
@@ -30617,7 +30688,7 @@ async function noteHistoryRecords(db) {
30617
30688
  };
30618
30689
  });
30619
30690
  return {
30620
- note_originals: originals.rows.map((row) => ({
30691
+ note_originals: originalRows.map((row) => ({
30621
30692
  id: row.id,
30622
30693
  note_id: row.note_id,
30623
30694
  content: row.content,
@@ -30627,7 +30698,7 @@ async function noteHistoryRecords(db) {
30627
30698
  version_number: 1
30628
30699
  })),
30629
30700
  note_original_history: [],
30630
- note_revised_current: current.rows.map((row) => ({
30701
+ note_revised_current: currentRows.map((row) => ({
30631
30702
  note_id: row.note_id,
30632
30703
  content: row.content,
30633
30704
  last_revision_id: lastByNote.get(row.note_id) ?? null,
@@ -30850,9 +30921,14 @@ function skosRecords(legacy) {
30850
30921
  skos_collection_members: []
30851
30922
  };
30852
30923
  }
30853
- async function provenanceActivities(db) {
30924
+ async function provenanceActivities(db, noteIds, revisionIds) {
30854
30925
  const rows = await db.query("SELECT * FROM provenance_edge ORDER BY started_at, id");
30855
- return rows.rows.map((row) => ({
30926
+ const scopedRows = noteIds ? rows.rows.filter((row) => {
30927
+ if (row.entity_type === "note") return noteIds.has(row.entity_id);
30928
+ if (row.entity_type === "revision") return revisionIds?.has(row.entity_id) ?? false;
30929
+ return false;
30930
+ }) : rows.rows;
30931
+ return scopedRows.map((row) => ({
30856
30932
  id: row.id,
30857
30933
  note_id: row.entity_type === "note" ? row.entity_id : null,
30858
30934
  revision_id: row.entity_type === "revision" ? row.entity_id : null,
@@ -30871,7 +30947,20 @@ async function exportLiveFullV1(db, coreArchive, legacyArchive, options) {
30871
30947
  requestedSchemaVersion: "2.0.0",
30872
30948
  declaredComponents: Object.keys(FULL_V1_COMPONENT_FILES)
30873
30949
  });
30874
- const losses = await liveRepresentationLosses(db);
30950
+ const core = unpackTarGz(coreArchive);
30951
+ const legacy = unpackTarGz(legacyArchive);
30952
+ const records = Object.fromEntries(
30953
+ Object.keys(FULL_V1_COMPONENT_FILES).map((component) => [component, []])
30954
+ );
30955
+ for (const component of ["notes", "collections", "tags", "templates", "links"]) {
30956
+ records[component] = readRecords(core, component);
30957
+ }
30958
+ const exportedNoteIds = new Set(records.notes.map((note) => String(note.id)));
30959
+ const exportedEmbeddingSetIds = new Set(readRecords(legacy, "embedding_sets").map((set) => String(set.id)));
30960
+ const losses = await liveRepresentationLosses(db, {
30961
+ noteIds: exportedNoteIds,
30962
+ embeddingSetIds: exportedEmbeddingSetIds
30963
+ });
30875
30964
  if (losses.length > 0) {
30876
30965
  capability = { ...capability, losses };
30877
30966
  return {
@@ -30881,18 +30970,16 @@ async function exportLiveFullV1(db, coreArchive, legacyArchive, options) {
30881
30970
  capability_report: capability
30882
30971
  };
30883
30972
  }
30884
- const core = unpackTarGz(coreArchive);
30885
- const legacy = unpackTarGz(legacyArchive);
30886
- const records = Object.fromEntries(
30887
- Object.keys(FULL_V1_COMPONENT_FILES).map((component) => [component, []])
30888
- );
30889
- for (const component of ["notes", "collections", "tags", "templates", "links"]) {
30890
- records[component] = readRecords(core, component);
30891
- }
30892
- Object.assign(records, await noteHistoryRecords(db));
30973
+ const history = await noteHistoryRecords(db, exportedNoteIds);
30974
+ Object.assign(records, history);
30975
+ const exportedRevisionIds = new Set(history.note_revisions.map((revision) => String(revision.id)));
30893
30976
  Object.assign(records, await embeddingRecords(db, legacy));
30894
30977
  Object.assign(records, skosRecords(legacy));
30895
- records.provenance_activities = await provenanceActivities(db);
30978
+ records.provenance_activities = await provenanceActivities(
30979
+ db,
30980
+ exportedNoteIds,
30981
+ exportedRevisionIds
30982
+ );
30896
30983
  records.graph_sources = readRecords(legacy, "graph_sources").map((row) => ({
30897
30984
  ...row,
30898
30985
  parameters: row.parameters ?? null
@@ -31052,6 +31139,11 @@ function coreV1OptionErrors(options) {
31052
31139
  }
31053
31140
  return errors;
31054
31141
  }
31142
+ function hasFullV1ScopeOptions(options) {
31143
+ return Boolean(
31144
+ options.collectionId || options.tag || (options.embeddingSetIds?.filter(Boolean).length ?? 0) > 0
31145
+ );
31146
+ }
31055
31147
  function toCoreV1Note(note) {
31056
31148
  return {
31057
31149
  ...note,
@@ -31205,16 +31297,34 @@ async function exportShardWithReport(db, options) {
31205
31297
  ) AS present`
31206
31298
  );
31207
31299
  if (persisted.rows[0]?.present) {
31300
+ if (hasFullV1ScopeOptions(options)) {
31301
+ return {
31302
+ success: false,
31303
+ archive: null,
31304
+ errors: [
31305
+ "Persisted full-v1 snapshots cannot be filtered by collection, tag, or embedding set; use a live scoped export or export the complete persisted snapshot."
31306
+ ],
31307
+ capability_report: capabilityReport2
31308
+ };
31309
+ }
31208
31310
  return exportFullV1Snapshot(db, options.blobStore);
31209
31311
  }
31210
31312
  const coreArchive = await exportShardBytes(
31211
31313
  db,
31212
- { profile: "core-v1", schemaVersion: "2.0.0" },
31314
+ {
31315
+ profile: "core-v1",
31316
+ schemaVersion: "2.0.0",
31317
+ collectionId: options.collectionId,
31318
+ tag: options.tag
31319
+ },
31213
31320
  { nativeSchema2Presence: true }
31214
31321
  );
31215
31322
  const legacyArchive = await exportShardBytes(db, {
31216
31323
  includeEmbeddings: true,
31217
- includeMaterializedSelectors: true
31324
+ includeMaterializedSelectors: true,
31325
+ collectionId: options.collectionId,
31326
+ tag: options.tag,
31327
+ embeddingSetIds: options.embeddingSetIds
31218
31328
  });
31219
31329
  return exportLiveFullV1(db, coreArchive, legacyArchive, {
31220
31330
  blobStore: options.blobStore,
@@ -39841,7 +39951,7 @@ async function purgeRecordStoreGraph(store, selector, operationKey) {
39841
39951
  }
39842
39952
 
39843
39953
  // src/index.ts
39844
- var VERSION = "2026.9.2";
39954
+ var VERSION = "2026.9.3";
39845
39955
 
39846
39956
  export { AIWG_SCAN_REQUIRED_FIELDS, AllowlistTrustStore, ArchiveManager, AttachmentsRepository, BridgeInferenceProvider, CORE_V1_COMPONENTS, CURRENT_MIGRATION_HEAD, CURRENT_SHARD_VERSION, CanonicalAttachmentsRepository, CanonicalNotesRepository, CapabilityManager, CaptureKnowledgeInputSchema, CollectionsRepository, CommunitiesRepository, DATASET_EXECUTION_CAPABILITY_IDS, DATASET_EXECUTION_CONTRACT, DATASET_EXECUTION_SCHEMA_VERSION, DATASET_INGEST_CONTRACT, DATASET_INGEST_SCHEMA_VERSION, DATASET_LINEAGE_CONTRACT, DATASET_LINEAGE_SCHEMA_VERSION, DATASET_MATERIALIZATION_CONTRACT, DATASET_MATERIALIZATION_KINDS, DATASET_MATERIALIZATION_SCHEMA_VERSION, DB_SNAPSHOT_SCHEMA_VERSION, DEFAULT_LARGE_DOCUMENT_CHARS, DEFAULT_LARGE_DOCUMENT_CHUNKS, DatasetIngestError, DatasetIngestExecutor, DatasetLineageLedger, DatasetMaterializationError, DbSnapshotVersionError, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, EmbeddingSetsRepository, FORTEMI_BROWSER_LOCAL_DATASET_EXECUTION_DESCRIPTOR, FORTEMI_COMPATIBILITY_PATH, FORTEMI_COMPATIBILITY_STATES, FORTEMI_PORTABLE_SHARD_DATASET_EXECUTION_DESCRIPTOR, FORTEMI_REQUIRED_COMPATIBILITY_CAPABILITIES, FORTEMI_SERVER_COMPATIBILITY_REVISION, FORTEMI_STATIC_CACHE_DATASET_EXECUTION_DESCRIPTOR, FallbackRouter, FortemiToolManifest, GetNoteInputSchema, GraphRepository, IdbRecordStore, JOB_CAPABILITIES, JOB_PRIORITIES, JobQueueWorker, LINEAGE_ENTITY_KINDS, LINEAGE_RELATIONSHIP_KINDS, LOCAL_ENDPOINTS, LifecyclePurgeRepository, LineageValidationError, LinksRepository, ListNotesInputSchema, ManageArchiveInputSchema, ManageAttachmentsInputSchema, ManageCapabilitiesInputSchema, ManageCollectionsInputSchema, ManageLinksInputSchema, ManageNoteInputSchema, ManageTagsInputSchema, MemoryBlobStore, MemoryDatasetIngestStore, MemoryRecordStore, MigrationRunner, NotesRepository, OpenAICompatibleProvider, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, ProvenanceRepository, ProviderRegistry, RECORD_COLLECTIONS, RECORD_SCHEMA_VERSION, RECORD_STORE_CAPABILITIES, REGISTERED_METADATA_PATHS, SHARD_FORMAT, SIGNATURE_ENTRY, SIGNING_ENVELOPE_VERSION, SOURCE_UPSERT_CONTRACT_VERSION, SOURCE_UPSERT_MAX_ITEMS, SUPPORTED_PGLITE_VERSION, SearchInputSchema, SearchRepository, SkosRepository, SourceUpsertRepository, TagsRepository, TransactionProxy, TypedEventBus, VERSION, aiRevisionHandler, aiwgFortemiIndexFromKnowledgeShard, aiwgFortemiIndexToCommunityGraph, aiwgFortemiIndexToKnowledgeShard, aiwgFortemiIndexToKnowledgeShardWithReport, allMigrations, appendPluginScript, assertAiwgFortemiChunkManifest, assertAiwgFortemiChunkPart, assertAiwgFortemiIndexExport, assertAiwgStaticEmbeddingSet, assertShardComponentRecord, buildAiwgChunkedIndex, buildAiwgStaticEmbeddingSet, buildMetadataPredicateConditions, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, compareDatasetIncrementalParity, computeBlobHash, computeHash, computeLineageDigest, computeSri, conceptTaggingHandler, configureInferenceRuntime, cosineSimilarity, createAiwgFetchChunkLoader, createAiwgFetchDetailLoader, createAiwgIndexController, createAiwgReviewDecisionExport, createBlobStore, createBridgeInferenceProviders, createCosineSemanticProvider, createCspReportHandler, createFortemi, createLazyBlobStore, createLegacyProvider, createLocalProviderProfile, createPGliteBackend, createPGliteInstance, createRecordBackend, createRecordStore, createRemoteBackend, createRoutes, createShardBackend, createShardCapabilityReport, createWorkerEmbedFunction, datasetDestinationScopeKey, defaultStorageBackendFactory, defineInferenceProvider, defineInferenceRuntime, defineLegacyInferenceProvider, defineOpenAICompatibleProvider, deriveDatasetIngestIdempotencyKey, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, digestDatasetMaterializationValue, discoverLocalProviders, dropAttachmentProjection, dropNoteProjection, dumpDbSnapshot, embeddingConfigToShard, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, executeDatasetMaterialization, executeDatasetRetrieval, exportShard, exportShardFromRecords, exportShardFromRecordsWithReport, exportShardWithReport, fetchAndValidateFortemiCompatibility, fetchPluginScript, filterAiwgRecordsByPrivacy, findAiwgStaticDuplicatePairs, formatFortemiCompatibilitySummary, fortemiCompatibilityUrl, fortemiManifest, fromPrefetched, generateId, getAiwgFortemiFacets, getAiwgFortemiIndexExportSchema, getConfiguredInferenceProviderId, getEmbedFunction, getEmbeddingTaskSelectionOptions, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getKnowledgeShardContractReceipt, getKnowledgeShardProfileRegistry, getKnowledgeShardSchema, getLlmFunction, getNote, getPrefetchedSha256, getProviderRouteRequirementIssue, handleEmbedRequests, hasFortemiSecureSecrets, importShard, importShardToRecords, inferInferenceTaskCapability, inferLocalEmbeddingDimensions, isPluginScriptAllowed, isShardPrefetched, isShardSigningSupported, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, mergeInferenceRuntimeConfigs, migrateLegacyBlobStore, negotiateDatasetExecutionCapabilities, negotiateDatasetMaterializationProfile, noteFromShard, noteSkosTagToShard, noteToShard, openShard, packTarGz, parseCspReport, prefetchShard, previewRecordStorePurge, profileSupportError, projectAttachments, projectNotes, projectRecords, provenanceEdgeToShard, providerSatisfiesRouteRequirements, purgeRecordStoreGraph, queryAiwgFortemiIndex, queryAiwgHybridIndex, queryAiwgSemanticIndex, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, restoreDbSnapshot, searchTool, selectBackend, selectEmbeddingTask, selectLlmModel, setEmbedFunction, setEmbeddingTaskSelectionOptions, setLlmFunction, sha256Hex, sidecarBlobDigests, signShard, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsToShard, templateToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, upsertRecordStoreRequest, upsertRecordStoreSources, urlLinkToShard, validateAiwgFortemiChunkManifest, validateAiwgFortemiChunkPart, validateAiwgFortemiIndexExport, validateAiwgFortemiIndexExportSchema, validateAiwgFortemiProjectedRecordSchema, validateAiwgStaticEmbeddingSet, validateChecksums, validateCoreV1ShardArchive, validateDatasetBenchmarkEvidence, validateDatasetExecutionDescriptor, validateFortemiCompatibilityResponse, validateFullV1ShardArchive, validateProviderRoute, validateRecordV1ShardArchive, validateShardArchive, validateShardComponentRecord, validateShardManifest, verifyDbSnapshotMeta, verifyShardSignature, verifySri };
39847
39957
  //# sourceMappingURL=index.js.map