@ai-matrx/associations 0.8.11 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -679,42 +679,6 @@ interface AssociationsStore {
679
679
  */
680
680
  declare function createAssociationsStore(config: AssociationsConfig): AssociationsStore;
681
681
 
682
- /** The name the self-test probes; MUST NOT exist in any schema. */
683
- declare const SELF_TEST_MISSING_RPC = "assoc_probe_self_test_missing_fn";
684
- interface DemandedSchemaReport {
685
- ok: boolean;
686
- /** Demanded functions the database cannot answer (PGRST202). */
687
- missing: string[];
688
- /** Functions the probe could not reach (transport/unknown failure). */
689
- unreachable: {
690
- fn: string;
691
- error: unknown;
692
- }[];
693
- /** Functions that answered (success or any non-PGRST202 refusal). */
694
- answered: string[];
695
- }
696
- interface AssertDemandedSchemaOptions {
697
- /**
698
- * Also probe a fabricated function name and REQUIRE it to come back
699
- * missing — proves the probe can fail (the falsifiability rule).
700
- */
701
- selfTest?: boolean;
702
- /** Max in-flight probe calls (default 6). */
703
- concurrency?: number;
704
- /**
705
- * Return the report instead of throwing on violation (for surfaces that
706
- * render the report). The self-test failure ALWAYS throws.
707
- */
708
- throwOnViolation?: boolean;
709
- }
710
- /**
711
- * Probe every demanded RPC against `dataSource`. Throws an `Error` naming
712
- * every missing function when the database violates the demanded schema
713
- * (unless `throwOnViolation: false`), and ALWAYS throws when the probe
714
- * itself cannot be trusted (unreachable database, failed self-test).
715
- */
716
- declare function assertDemandedSchema(dataSource: AssociationsDataSource, options?: AssertDemandedSchemaOptions): Promise<DemandedSchemaReport>;
717
-
718
682
  /** Source tokens that are structure, never container content. */
719
683
  declare const NON_CONTENT_SOURCE_TYPES: ReadonlySet<string>;
720
684
  /** True when edge metadata marks a container-membership edge. */
@@ -751,4 +715,4 @@ declare function buildCategoryHierarchy(categories: PlatformCategory[]): Categor
751
715
  */
752
716
  declare function createDefaultErrorSink(): ErrorSink;
753
717
 
754
- export { type AddAssociationArgs, type AddCommentArgs, type AssertDemandedSchemaOptions, type AssociationGuards, type AssociationHelpersApi, type AssociationWriteResult, type AssociationsServiceApi, type AssociationsStore, type CandidateRecord, type CandidatesResult, type CandidatesServiceApi, type CategoriesServiceApi, type CategoryHierarchy, type CategoryHierarchyItem, type CategoryMutationResult, type CommentMutationResult, type CommentsServiceApi, type ContainerRef, type ContentRole, type ConversationFileLink, type CoreDeps, type CreateEntityRowArgs, DEFAULT_ORG_COLUMN, DEFAULT_OWNER_COLUMN, type DemandedSchemaReport, type EdgeAttrs, type EdgeSpec, type EntityInfo, type EntityRef, type EntityRegistry, type EntityRowResult, type EntityRowsServiceApi, type FavoritesServiceApi, type ListCandidatesArgs, NON_CONTENT_SOURCE_TYPES, type PgErrorMapper, type RpcResultHelpers, SELF_TEST_MISSING_RPC, type SearchAcrossTokensArgs, type TitlesServiceApi, type UniversalCandidate, assertDemandedSchema, associationsKey, buildCategoryHierarchy, createAssociationGuards, createAssociationHelpers, createAssociationsService, createAssociationsStore, createCandidatesService, createCategoriesService, createCommentsService, createDefaultErrorSink, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, ok, resolveEntityToken };
718
+ export { type AddAssociationArgs, type AddCommentArgs, type AssociationGuards, type AssociationHelpersApi, type AssociationWriteResult, type AssociationsServiceApi, type AssociationsStore, type CandidateRecord, type CandidatesResult, type CandidatesServiceApi, type CategoriesServiceApi, type CategoryHierarchy, type CategoryHierarchyItem, type CategoryMutationResult, type CommentMutationResult, type CommentsServiceApi, type ContainerRef, type ContentRole, type ConversationFileLink, type CoreDeps, type CreateEntityRowArgs, DEFAULT_ORG_COLUMN, DEFAULT_OWNER_COLUMN, type EdgeAttrs, type EdgeSpec, type EntityInfo, type EntityRef, type EntityRegistry, type EntityRowResult, type EntityRowsServiceApi, type FavoritesServiceApi, type ListCandidatesArgs, NON_CONTENT_SOURCE_TYPES, type PgErrorMapper, type RpcResultHelpers, type SearchAcrossTokensArgs, type TitlesServiceApi, type UniversalCandidate, associationsKey, buildCategoryHierarchy, createAssociationGuards, createAssociationHelpers, createAssociationsService, createAssociationsStore, createCandidatesService, createCategoriesService, createCommentsService, createDefaultErrorSink, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, ok, resolveEntityToken };
@@ -679,42 +679,6 @@ interface AssociationsStore {
679
679
  */
680
680
  declare function createAssociationsStore(config: AssociationsConfig): AssociationsStore;
681
681
 
682
- /** The name the self-test probes; MUST NOT exist in any schema. */
683
- declare const SELF_TEST_MISSING_RPC = "assoc_probe_self_test_missing_fn";
684
- interface DemandedSchemaReport {
685
- ok: boolean;
686
- /** Demanded functions the database cannot answer (PGRST202). */
687
- missing: string[];
688
- /** Functions the probe could not reach (transport/unknown failure). */
689
- unreachable: {
690
- fn: string;
691
- error: unknown;
692
- }[];
693
- /** Functions that answered (success or any non-PGRST202 refusal). */
694
- answered: string[];
695
- }
696
- interface AssertDemandedSchemaOptions {
697
- /**
698
- * Also probe a fabricated function name and REQUIRE it to come back
699
- * missing — proves the probe can fail (the falsifiability rule).
700
- */
701
- selfTest?: boolean;
702
- /** Max in-flight probe calls (default 6). */
703
- concurrency?: number;
704
- /**
705
- * Return the report instead of throwing on violation (for surfaces that
706
- * render the report). The self-test failure ALWAYS throws.
707
- */
708
- throwOnViolation?: boolean;
709
- }
710
- /**
711
- * Probe every demanded RPC against `dataSource`. Throws an `Error` naming
712
- * every missing function when the database violates the demanded schema
713
- * (unless `throwOnViolation: false`), and ALWAYS throws when the probe
714
- * itself cannot be trusted (unreachable database, failed self-test).
715
- */
716
- declare function assertDemandedSchema(dataSource: AssociationsDataSource, options?: AssertDemandedSchemaOptions): Promise<DemandedSchemaReport>;
717
-
718
682
  /** Source tokens that are structure, never container content. */
719
683
  declare const NON_CONTENT_SOURCE_TYPES: ReadonlySet<string>;
720
684
  /** True when edge metadata marks a container-membership edge. */
@@ -751,4 +715,4 @@ declare function buildCategoryHierarchy(categories: PlatformCategory[]): Categor
751
715
  */
752
716
  declare function createDefaultErrorSink(): ErrorSink;
753
717
 
754
- export { type AddAssociationArgs, type AddCommentArgs, type AssertDemandedSchemaOptions, type AssociationGuards, type AssociationHelpersApi, type AssociationWriteResult, type AssociationsServiceApi, type AssociationsStore, type CandidateRecord, type CandidatesResult, type CandidatesServiceApi, type CategoriesServiceApi, type CategoryHierarchy, type CategoryHierarchyItem, type CategoryMutationResult, type CommentMutationResult, type CommentsServiceApi, type ContainerRef, type ContentRole, type ConversationFileLink, type CoreDeps, type CreateEntityRowArgs, DEFAULT_ORG_COLUMN, DEFAULT_OWNER_COLUMN, type DemandedSchemaReport, type EdgeAttrs, type EdgeSpec, type EntityInfo, type EntityRef, type EntityRegistry, type EntityRowResult, type EntityRowsServiceApi, type FavoritesServiceApi, type ListCandidatesArgs, NON_CONTENT_SOURCE_TYPES, type PgErrorMapper, type RpcResultHelpers, SELF_TEST_MISSING_RPC, type SearchAcrossTokensArgs, type TitlesServiceApi, type UniversalCandidate, assertDemandedSchema, associationsKey, buildCategoryHierarchy, createAssociationGuards, createAssociationHelpers, createAssociationsService, createAssociationsStore, createCandidatesService, createCategoriesService, createCommentsService, createDefaultErrorSink, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, ok, resolveEntityToken };
718
+ export { type AddAssociationArgs, type AddCommentArgs, type AssociationGuards, type AssociationHelpersApi, type AssociationWriteResult, type AssociationsServiceApi, type AssociationsStore, type CandidateRecord, type CandidatesResult, type CandidatesServiceApi, type CategoriesServiceApi, type CategoryHierarchy, type CategoryHierarchyItem, type CategoryMutationResult, type CommentMutationResult, type CommentsServiceApi, type ContainerRef, type ContentRole, type ConversationFileLink, type CoreDeps, type CreateEntityRowArgs, DEFAULT_ORG_COLUMN, DEFAULT_OWNER_COLUMN, type EdgeAttrs, type EdgeSpec, type EntityInfo, type EntityRef, type EntityRegistry, type EntityRowResult, type EntityRowsServiceApi, type FavoritesServiceApi, type ListCandidatesArgs, NON_CONTENT_SOURCE_TYPES, type PgErrorMapper, type RpcResultHelpers, type SearchAcrossTokensArgs, type TitlesServiceApi, type UniversalCandidate, associationsKey, buildCategoryHierarchy, createAssociationGuards, createAssociationHelpers, createAssociationsService, createAssociationsStore, createCandidatesService, createCategoriesService, createCommentsService, createDefaultErrorSink, createEntityRegistry, createEntityRowsService, createFavoritesService, createRpcResultHelpers, createTitlesService, entityTitleCacheKey, err, firstError, isContentRole, isContentSourceEdge, isMembershipMetadata, isTransportFailure, ok, resolveEntityToken };
@@ -3262,169 +3262,6 @@ function createAssociationsStore(config) {
3262
3262
  };
3263
3263
  }
3264
3264
 
3265
- // src/demanded-rpcs.generated.ts
3266
- var DEMANDED_RPC_NAMES = [
3267
- "assoc_add",
3268
- "assoc_remove",
3269
- "assoc_set_targets",
3270
- "assoc_remove_for_entity",
3271
- "assoc_for_entity",
3272
- "assoc_for_targets",
3273
- "assoc_for_sources",
3274
- "assoc_members_visible",
3275
- "conversation_file_add",
3276
- "conversation_file_remove",
3277
- "conversation_files",
3278
- "agent_resource_add",
3279
- "agent_resource_remove",
3280
- "cat_list",
3281
- "cat_create",
3282
- "cat_update",
3283
- "cat_reparent",
3284
- "cat_delete",
3285
- "ues_set",
3286
- "ues_list",
3287
- "ues_get_bulk",
3288
- "ues_touch",
3289
- "reference_search_candidates",
3290
- "cmt_list",
3291
- "cmt_add",
3292
- "cmt_edit",
3293
- "cmt_delete"
3294
- ];
3295
-
3296
- // src/core/assertDemandedSchema.ts
3297
- var BAD_UUID = "__not_a_uuid__";
3298
- var SELF_TEST_MISSING_RPC = "assoc_probe_self_test_missing_fn";
3299
- var PROBE_ARGS = {
3300
- // edges — writes
3301
- assoc_add: {
3302
- p_source_type: "note",
3303
- p_source_id: BAD_UUID,
3304
- p_target_type: "task",
3305
- p_target_id: BAD_UUID
3306
- },
3307
- assoc_remove: {
3308
- p_source_type: "note",
3309
- p_source_id: BAD_UUID,
3310
- p_target_type: "task",
3311
- p_target_id: BAD_UUID
3312
- },
3313
- assoc_set_targets: {
3314
- p_source_type: "note",
3315
- p_source_id: BAD_UUID,
3316
- p_target_type: "task",
3317
- p_target_ids: [BAD_UUID]
3318
- },
3319
- assoc_remove_for_entity: { p_type: "note", p_id: BAD_UUID },
3320
- // edges — reads
3321
- assoc_for_entity: { p_type: "note", p_id: BAD_UUID },
3322
- assoc_for_targets: { p_target_type: "task", p_target_ids: [BAD_UUID] },
3323
- assoc_for_sources: { p_source_type: "note", p_source_ids: [BAD_UUID] },
3324
- assoc_members_visible: { p_target_type: "task", p_target_ids: [BAD_UUID] },
3325
- // conversation files
3326
- conversation_file_add: {
3327
- p_conversation_id: BAD_UUID,
3328
- p_file_id: BAD_UUID
3329
- },
3330
- conversation_file_remove: {
3331
- p_conversation_id: BAD_UUID,
3332
- p_file_id: BAD_UUID
3333
- },
3334
- conversation_files: { p_conversation_id: BAD_UUID },
3335
- // agent resources
3336
- agent_resource_add: {
3337
- p_agent_id: BAD_UUID,
3338
- p_source_type: "note",
3339
- p_source_id: BAD_UUID
3340
- },
3341
- agent_resource_remove: {
3342
- p_agent_id: BAD_UUID,
3343
- p_source_type: "note",
3344
- p_source_id: BAD_UUID
3345
- },
3346
- // categories
3347
- cat_list: {},
3348
- cat_create: { p_dimension: "", p_name: "", p_org_id: BAD_UUID },
3349
- cat_update: { p_category_id: BAD_UUID, p_name: "__probe__" },
3350
- cat_reparent: { p_category_id: BAD_UUID },
3351
- cat_delete: { p_category_id: BAD_UUID },
3352
- // favorites / recents
3353
- ues_set: { p_entity_type: "__probe__", p_entity_id: BAD_UUID },
3354
- ues_list: {},
3355
- ues_get_bulk: { p_entity_type: "__probe__", p_entity_ids: [BAD_UUID] },
3356
- ues_touch: { p_entity_type: "__probe__", p_entity_id: BAD_UUID },
3357
- // candidates
3358
- reference_search_candidates: { p_token: "__probe__", p_limit: 1 },
3359
- // comments (W6) — every fn takes a uuid arg, so the unparseable sentinel
3360
- // guarantees 22P02 before any SECURITY DEFINER body runs (no write occurs).
3361
- cmt_list: { p_entity_type: "__probe__", p_entity_id: BAD_UUID },
3362
- cmt_add: {
3363
- p_entity_type: "__probe__",
3364
- p_entity_id: BAD_UUID,
3365
- p_body: "__probe__"
3366
- },
3367
- cmt_edit: { p_id: BAD_UUID, p_body: "__probe__" },
3368
- cmt_delete: { p_id: BAD_UUID }
3369
- };
3370
- function isMissingFunctionError(error) {
3371
- if (!error || typeof error !== "object") return false;
3372
- return error.code === "PGRST202";
3373
- }
3374
- async function assertDemandedSchema(dataSource, options = {}) {
3375
- const { selfTest = false, concurrency = 6, throwOnViolation = true } = options;
3376
- const names = [...DEMANDED_RPC_NAMES];
3377
- if (selfTest) names.push(SELF_TEST_MISSING_RPC);
3378
- const missing = [];
3379
- const unreachable = [];
3380
- const answered = [];
3381
- let cursor = 0;
3382
- async function worker() {
3383
- while (cursor < names.length) {
3384
- const fn = names[cursor];
3385
- cursor += 1;
3386
- if (!fn) continue;
3387
- const args = fn === SELF_TEST_MISSING_RPC ? {} : PROBE_ARGS[fn];
3388
- try {
3389
- const { error } = await dataSource.rpc(fn, args);
3390
- if (error == null) answered.push(fn);
3391
- else if (isMissingFunctionError(error)) missing.push(fn);
3392
- else answered.push(fn);
3393
- } catch (e) {
3394
- unreachable.push({ fn, error: e });
3395
- }
3396
- }
3397
- }
3398
- await Promise.all(
3399
- Array.from({ length: Math.min(concurrency, names.length) }, worker)
3400
- );
3401
- if (selfTest) {
3402
- const selfTestMissing = missing.includes(SELF_TEST_MISSING_RPC);
3403
- const idx = missing.indexOf(SELF_TEST_MISSING_RPC);
3404
- if (idx >= 0) missing.splice(idx, 1);
3405
- const answeredIdx = answered.indexOf(SELF_TEST_MISSING_RPC);
3406
- if (answeredIdx >= 0) answered.splice(answeredIdx, 1);
3407
- if (!selfTestMissing) {
3408
- throw new Error(
3409
- `assertDemandedSchema self-test FAILED: the fabricated function "${SELF_TEST_MISSING_RPC}" did not come back as missing (PGRST202). This probe cannot currently fail, so its green result proves nothing \u2014 the dataSource is swallowing or faking errors.`
3410
- );
3411
- }
3412
- }
3413
- if (unreachable.length > 0) {
3414
- throw new Error(
3415
- `assertDemandedSchema could not complete: ${unreachable.length} probe call(s) failed to reach the database (${unreachable.map((u) => u.fn).join(", ")}). This is NOT a schema verdict \u2014 fix connectivity and re-run.`
3416
- );
3417
- }
3418
- const ok2 = missing.length === 0;
3419
- const report = { ok: ok2, missing, unreachable, answered };
3420
- if (!ok2 && throwOnViolation) {
3421
- throw new Error(
3422
- `DEMANDED SCHEMA VIOLATION: the database this dataSource points at cannot answer ${missing.length} demanded @ai-matrx/associations function(s): ${missing.join(", ")}. This package demands the AI Matrx platform schema (README \xA7 The demanded schema); a database without it is not this package's database.`
3423
- );
3424
- }
3425
- return report;
3426
- }
3427
-
3428
3265
  // src/core/edgeClassifier.ts
3429
3266
  var NON_CONTENT_SOURCE_TYPES = /* @__PURE__ */ new Set([
3430
3267
  "thread",
@@ -3509,8 +3346,6 @@ export {
3509
3346
  DEFAULT_ORG_COLUMN,
3510
3347
  DEFAULT_OWNER_COLUMN,
3511
3348
  NON_CONTENT_SOURCE_TYPES,
3512
- SELF_TEST_MISSING_RPC,
3513
- assertDemandedSchema,
3514
3349
  associationsKey,
3515
3350
  buildCategoryHierarchy,
3516
3351
  createAssociationGuards,