@ai-matrx/associations 0.8.9 → 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 };
@@ -164,7 +164,9 @@ var ENTITY_TYPE_METADATA = {
164
164
  "context_item_value": { token: "context_item_value", schema: "context", table: "context_item_values", label: "Record Value", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
165
165
  "conversation": { token: "conversation", schema: "chat", table: "conversation", label: "Conversation", baseTier: 1, isComponent: false, isModule: true, isListed: false, scopeable: true, category: "Outputs", referencePickable: true, titleColumn: "title", contentRole: "destination", referenceCategory: null },
166
166
  "conversation_value": { token: "conversation_value", schema: "chat", table: "conversation_value", label: "Conversation Value", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: false, category: null, referencePickable: false, titleColumn: "key", contentRole: null, referenceCategory: null },
167
+ "credential_attachment": { token: "credential_attachment", schema: "users", table: "credential_attachments", label: "Credential attachment", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
167
168
  "credential_item": { token: "credential_item", schema: "users", table: "credential_items", label: "Credential item", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
169
+ "credential_mutation_receipt": { token: "credential_mutation_receipt", schema: "users", table: "credential_mutation_receipts", label: "Credential Mutation Receipt", baseTier: 1, isComponent: false, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
168
170
  "crm_address": { token: "crm_address", schema: "crm", table: "address", label: "Address", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: "label", contentRole: null, referenceCategory: null },
169
171
  "crm_affiliation": { token: "crm_affiliation", schema: "crm", table: "affiliation", label: "Affiliation", baseTier: 1, isComponent: true, isModule: false, isListed: false, scopeable: true, category: null, referencePickable: false, titleColumn: "title", contentRole: null, referenceCategory: null },
170
172
  "crm_blocklist_entry": { token: "crm_blocklist_entry", schema: "crm", table: "blocklist_entry", label: "Blocklist Entry", baseTier: 1, isComponent: false, isModule: false, isListed: true, scopeable: true, category: null, referencePickable: false, titleColumn: null, contentRole: null, referenceCategory: null },
@@ -840,7 +842,9 @@ var ENTITY_TYPE_TOKENS = [
840
842
  "context_item_value",
841
843
  "conversation",
842
844
  "conversation_value",
845
+ "credential_attachment",
843
846
  "credential_item",
847
+ "credential_mutation_receipt",
844
848
  "crm_address",
845
849
  "crm_affiliation",
846
850
  "crm_blocklist_entry",
@@ -3258,169 +3262,6 @@ function createAssociationsStore(config) {
3258
3262
  };
3259
3263
  }
3260
3264
 
3261
- // src/demanded-rpcs.generated.ts
3262
- var DEMANDED_RPC_NAMES = [
3263
- "assoc_add",
3264
- "assoc_remove",
3265
- "assoc_set_targets",
3266
- "assoc_remove_for_entity",
3267
- "assoc_for_entity",
3268
- "assoc_for_targets",
3269
- "assoc_for_sources",
3270
- "assoc_members_visible",
3271
- "conversation_file_add",
3272
- "conversation_file_remove",
3273
- "conversation_files",
3274
- "agent_resource_add",
3275
- "agent_resource_remove",
3276
- "cat_list",
3277
- "cat_create",
3278
- "cat_update",
3279
- "cat_reparent",
3280
- "cat_delete",
3281
- "ues_set",
3282
- "ues_list",
3283
- "ues_get_bulk",
3284
- "ues_touch",
3285
- "reference_search_candidates",
3286
- "cmt_list",
3287
- "cmt_add",
3288
- "cmt_edit",
3289
- "cmt_delete"
3290
- ];
3291
-
3292
- // src/core/assertDemandedSchema.ts
3293
- var BAD_UUID = "__not_a_uuid__";
3294
- var SELF_TEST_MISSING_RPC = "assoc_probe_self_test_missing_fn";
3295
- var PROBE_ARGS = {
3296
- // edges — writes
3297
- assoc_add: {
3298
- p_source_type: "note",
3299
- p_source_id: BAD_UUID,
3300
- p_target_type: "task",
3301
- p_target_id: BAD_UUID
3302
- },
3303
- assoc_remove: {
3304
- p_source_type: "note",
3305
- p_source_id: BAD_UUID,
3306
- p_target_type: "task",
3307
- p_target_id: BAD_UUID
3308
- },
3309
- assoc_set_targets: {
3310
- p_source_type: "note",
3311
- p_source_id: BAD_UUID,
3312
- p_target_type: "task",
3313
- p_target_ids: [BAD_UUID]
3314
- },
3315
- assoc_remove_for_entity: { p_type: "note", p_id: BAD_UUID },
3316
- // edges — reads
3317
- assoc_for_entity: { p_type: "note", p_id: BAD_UUID },
3318
- assoc_for_targets: { p_target_type: "task", p_target_ids: [BAD_UUID] },
3319
- assoc_for_sources: { p_source_type: "note", p_source_ids: [BAD_UUID] },
3320
- assoc_members_visible: { p_target_type: "task", p_target_ids: [BAD_UUID] },
3321
- // conversation files
3322
- conversation_file_add: {
3323
- p_conversation_id: BAD_UUID,
3324
- p_file_id: BAD_UUID
3325
- },
3326
- conversation_file_remove: {
3327
- p_conversation_id: BAD_UUID,
3328
- p_file_id: BAD_UUID
3329
- },
3330
- conversation_files: { p_conversation_id: BAD_UUID },
3331
- // agent resources
3332
- agent_resource_add: {
3333
- p_agent_id: BAD_UUID,
3334
- p_source_type: "note",
3335
- p_source_id: BAD_UUID
3336
- },
3337
- agent_resource_remove: {
3338
- p_agent_id: BAD_UUID,
3339
- p_source_type: "note",
3340
- p_source_id: BAD_UUID
3341
- },
3342
- // categories
3343
- cat_list: {},
3344
- cat_create: { p_dimension: "", p_name: "", p_org_id: BAD_UUID },
3345
- cat_update: { p_category_id: BAD_UUID, p_name: "__probe__" },
3346
- cat_reparent: { p_category_id: BAD_UUID },
3347
- cat_delete: { p_category_id: BAD_UUID },
3348
- // favorites / recents
3349
- ues_set: { p_entity_type: "__probe__", p_entity_id: BAD_UUID },
3350
- ues_list: {},
3351
- ues_get_bulk: { p_entity_type: "__probe__", p_entity_ids: [BAD_UUID] },
3352
- ues_touch: { p_entity_type: "__probe__", p_entity_id: BAD_UUID },
3353
- // candidates
3354
- reference_search_candidates: { p_token: "__probe__", p_limit: 1 },
3355
- // comments (W6) — every fn takes a uuid arg, so the unparseable sentinel
3356
- // guarantees 22P02 before any SECURITY DEFINER body runs (no write occurs).
3357
- cmt_list: { p_entity_type: "__probe__", p_entity_id: BAD_UUID },
3358
- cmt_add: {
3359
- p_entity_type: "__probe__",
3360
- p_entity_id: BAD_UUID,
3361
- p_body: "__probe__"
3362
- },
3363
- cmt_edit: { p_id: BAD_UUID, p_body: "__probe__" },
3364
- cmt_delete: { p_id: BAD_UUID }
3365
- };
3366
- function isMissingFunctionError(error) {
3367
- if (!error || typeof error !== "object") return false;
3368
- return error.code === "PGRST202";
3369
- }
3370
- async function assertDemandedSchema(dataSource, options = {}) {
3371
- const { selfTest = false, concurrency = 6, throwOnViolation = true } = options;
3372
- const names = [...DEMANDED_RPC_NAMES];
3373
- if (selfTest) names.push(SELF_TEST_MISSING_RPC);
3374
- const missing = [];
3375
- const unreachable = [];
3376
- const answered = [];
3377
- let cursor = 0;
3378
- async function worker() {
3379
- while (cursor < names.length) {
3380
- const fn = names[cursor];
3381
- cursor += 1;
3382
- if (!fn) continue;
3383
- const args = fn === SELF_TEST_MISSING_RPC ? {} : PROBE_ARGS[fn];
3384
- try {
3385
- const { error } = await dataSource.rpc(fn, args);
3386
- if (error == null) answered.push(fn);
3387
- else if (isMissingFunctionError(error)) missing.push(fn);
3388
- else answered.push(fn);
3389
- } catch (e) {
3390
- unreachable.push({ fn, error: e });
3391
- }
3392
- }
3393
- }
3394
- await Promise.all(
3395
- Array.from({ length: Math.min(concurrency, names.length) }, worker)
3396
- );
3397
- if (selfTest) {
3398
- const selfTestMissing = missing.includes(SELF_TEST_MISSING_RPC);
3399
- const idx = missing.indexOf(SELF_TEST_MISSING_RPC);
3400
- if (idx >= 0) missing.splice(idx, 1);
3401
- const answeredIdx = answered.indexOf(SELF_TEST_MISSING_RPC);
3402
- if (answeredIdx >= 0) answered.splice(answeredIdx, 1);
3403
- if (!selfTestMissing) {
3404
- throw new Error(
3405
- `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.`
3406
- );
3407
- }
3408
- }
3409
- if (unreachable.length > 0) {
3410
- throw new Error(
3411
- `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.`
3412
- );
3413
- }
3414
- const ok2 = missing.length === 0;
3415
- const report = { ok: ok2, missing, unreachable, answered };
3416
- if (!ok2 && throwOnViolation) {
3417
- throw new Error(
3418
- `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.`
3419
- );
3420
- }
3421
- return report;
3422
- }
3423
-
3424
3265
  // src/core/edgeClassifier.ts
3425
3266
  var NON_CONTENT_SOURCE_TYPES = /* @__PURE__ */ new Set([
3426
3267
  "thread",
@@ -3505,8 +3346,6 @@ export {
3505
3346
  DEFAULT_ORG_COLUMN,
3506
3347
  DEFAULT_OWNER_COLUMN,
3507
3348
  NON_CONTENT_SOURCE_TYPES,
3508
- SELF_TEST_MISSING_RPC,
3509
- assertDemandedSchema,
3510
3349
  associationsKey,
3511
3350
  buildCategoryHierarchy,
3512
3351
  createAssociationGuards,