From 8161cea7fc2e74f76f413dc8976e6bd3284d0edb Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Sun, 29 Nov 2026 21:14:18 +0700 Subject: [PATCH 1/4] fix(node-type-registry): take DataFileRef and the backend's status default The registry is the closed schema db-tools checks a custom blueprint against before it sends it. It had drifted from the backend's generators and the curated blueprints, so the curated Fundraise blueprint and every app with a status default were refused before they reached the server. - Add DataFileRef (a file column's storage binding). - DataStatusField.default_value takes the backend's FieldDefault object. --- .../__tests__/blueprint-schema.test.ts | 22 ++++++ .../src/blueprint-schema.generated.ts | 2 +- .../src/blueprint-types.generated.ts | 27 ++++++- .../src/data/data-file-ref.ts | 71 +++++++++++++++++++ .../src/data/data-status-field.ts | 5 +- packages/node-type-registry/src/data/index.ts | 1 + 6 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 packages/node-type-registry/src/data/data-file-ref.ts diff --git a/packages/node-type-registry/__tests__/blueprint-schema.test.ts b/packages/node-type-registry/__tests__/blueprint-schema.test.ts index 48f95603a0..e9432c7cea 100644 --- a/packages/node-type-registry/__tests__/blueprint-schema.test.ts +++ b/packages/node-type-registry/__tests__/blueprint-schema.test.ts @@ -50,6 +50,28 @@ describe('the blueprint definition JSON Schema', () => { expect(errors(table({ policies: [{ ...TEAM, privileges: ['select', 'update'], with_check: check }] }))).toContain('/tables/0/policies/0/privileges/0 must match pattern "^[Uu][Pp][Dd][Aa][Tt][Ee]$"'); }); + test('a DataFileRef node binds a file column to a storage module and a bucket', () => { + const nodes = (...refs: Record[]) => table({ nodes: refs.map((data) => ({ $type: 'DataFileRef', data })) }); + expect( + errors( + nodes( + { field: 'logo', storage: { scope: 'org' }, bucket: 'org-files', is_public: false }, + { field: 'contract', storage: { scope: 'properties' }, bucket: 'properties-files', is_public: false }, + { field: 'attachment', storage: { scope: 'app' } }, + { field: 'avatar', storage: { scope: 'app', key: 'vault' }, bucket_tags: ['images'], is_public: true, enforce_fk: false }, + { field: 'photo' } + ) + ) + ).toEqual([]); + expect(errors(nodes({ storage: { scope: 'org' } }))).toContain('/tables/0/nodes/0/data must have required property \'field\''); + }); + + test('a DataStatusField default is a FieldDefault, as the backend reads it', () => { + const status = (data: Record) => table({ nodes: [{ $type: 'DataStatusField', data }] }); + expect(errors(status({ field_name: 'status', allowed_values: ['open', 'full'], is_required: false, default_value: { value: 'open' } }))).toEqual([]); + expect(errors(status({ field_name: 'status', default_value: 'open' }))).toContain('/tables/0/nodes/0/data/default_value must be object'); + }); + test('a check constraint names one of the backend\'s check types', () => { expect(errors(table({ check_constraints: [{ $type: 'CheckOwnedRelation', name: 'x', data: { column: 'a' } }] }))).toContain( '/tables/0/check_constraints/0/$type must be equal to one of the allowed values' diff --git a/packages/node-type-registry/src/blueprint-schema.generated.ts b/packages/node-type-registry/src/blueprint-schema.generated.ts index 0684fcc34b..b7421c1b23 100644 --- a/packages/node-type-registry/src/blueprint-schema.generated.ts +++ b/packages/node-type-registry/src/blueprint-schema.generated.ts @@ -6,4 +6,4 @@ import type { JSONSchema } from './types'; /** JSON Schema (draft-07) of a blueprint definition: the shapes construct_blueprint() reads, with each node's data checked against its parameter_schema in the form a caller writes it. */ -export const blueprintDefinitionJsonSchema: JSONSchema = {"$schema":"http://json-schema.org/draft-07/schema#","title":"BlueprintDefinition","description":"The complete blueprint definition -- the JSONB shape accepted by construct_blueprint().","allOf":[{"$ref":"#/$defs/BlueprintDefinition"}],"$defs":{"AuthzAllowAllParams":{"type":"object","properties":{},"additionalProperties":false,"description":"Allows all access. Generates TRUE expression."},"AuthzAppMemberOwnerParams":{"type":"object","properties":{"owner_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the owner user ID (e.g., actor_id)","default":"owner_id"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["owner_field"],"additionalProperties":false,"description":"Compound policy: the row must be owned by the current user (owner_field = current_user_id) AND the current user must hold an app membership (hardcoded membership_type=1). App-level analog of AuthzMemberOwner for global scopes with no entity key — authorship never survives losing app membership."},"AuthzAppMembershipParams":{"type":"object","properties":{"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":[],"additionalProperties":false,"description":"App-level membership check (hardcoded membership_type=1). Verifies the user has app membership (optionally with specific capability) without binding to any entity from the row. Uses EXISTS subquery against SPRT table. For entity-scoped checks (org, channel, etc.), use AuthzEntityMembership instead."},"AuthzColumnSecurityParams":{"type":"object","properties":{"columns":{"type":"array","items":{"$ref":"#/$defs/shared-ad437cb66f"},"minItems":1,"description":"Guarded columns that share the same rule and authorization (e.g. [\"is_shared\"])."},"rule":{"type":"string","enum":["set_true","set_false","set_values","not_values","writable_when","transition","immutable"],"description":"Write pattern that arms the guard: set_true/set_false (column set to that boolean), set_values (column set to one of values), not_values (column set to a non-NULL value outside values), writable_when (column written/changed at all), transition (OLD->NEW pairs in allowed), immutable (delegates to DataImmutableFields).","default":"writable_when"},"authz":{"$ref":"#/$defs/AuthzExpression","description":"An Authz expression (one node such as {\"AuthzAppMembership\": {...}}, or AND, OR or NOT over nodes) that must be satisfied to perform the guarded write. Required for all rules except immutable."},"values":{"type":"array","items":{"type":"string"},"description":"For rule=set_values: the protected values that arm the guard. For rule=not_values: the allowed values; any non-NULL value outside them arms the guard."},"allowed":{"type":"array","items":{"type":"string"},"description":"For rule=transition: allowed guarded transitions expressed as \"from->to\" (e.g. [\"member->admin\"])."},"allow_system":{"type":"boolean","description":"When true, the system role (AuthzSystemOnly) bypasses the guard so provisioning/seed paths without a JWT principal can write freely.","default":false},"error_code":{"type":"string","description":"Machine-readable code prefixed onto the raised error message (e.g. MANAGED_DOMAIN_PUBLISH_FORBIDDEN)."},"error_message":{"type":"string","description":"Human-readable message raised when the guard denies the write."},"conditions":{"type":["object","array"],"items":{"type":"object"},"description":"Conditions on the row being written; the guard arms only when the write matches the rule and the row meets them."}},"required":["columns","rule"],"allOf":[{"if":{"properties":{"rule":{"not":{"const":"immutable"}}}},"then":{"required":["authz"]}},{"if":{"properties":{"rule":{"enum":["set_values","not_values"]}}},"then":{"required":["values"],"properties":{"values":{"minItems":1}}}},{"if":{"properties":{"rule":{"const":"transition"}}},"then":{"required":["allowed"],"properties":{"allowed":{"minItems":1}}}}],"additionalProperties":false,"description":"Column-level write authorization. Generates BEFORE INSERT/UPDATE triggers that enforce an authorization node whenever a guarded column is written to a protected value or transitions. The write-time counterpart to RLS SELECT/WITH CHECK policies: any table can declare \"only an actor satisfying may set column X\". The nested authz value is a normal Authz node compiled by the standard RLS pipeline; row-referencing nodes have their protected-table column references rebound to NEW. The immutable rule delegates to the native DataImmutableFields generator."},"AuthzCompositeParams":{"$ref":"#/$defs/AuthzExpression","description":"Composite authorization policy that combines multiple authorization nodes using boolean logic (AND/OR). The data field contains a JSONB AST with nested authorization nodes."},"AuthzDatabaseClaimParams":{"type":"object","properties":{"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column carrying the row's database id","default":"database_id"},"schema_id":{"type":"string","format":"uuid","description":"A schema whose database must be the claimed one, in place of a column; the rule then reads no column."},"lane_attested":{"type":"boolean","description":"Only connections the platform attests for the claimed database pass.","default":false}},"additionalProperties":false,"description":"Passes when the row's database column equals the session's pinned database claim (jwt.claims.database_id). Consults no principal, membership or entity, so it admits a connection whose identity the platform sets — such as a cloud function's database connection, whose claim comes from the connection and cannot widen it — to exactly the database that connection is bound to. A session with no claim fails loudly rather than reading nothing."},"AuthzDenyAllParams":{"type":"object","properties":{},"additionalProperties":false,"description":"Denies all access. Generates FALSE expression."},"AuthzDirectOwnerAnyParams":{"type":"object","properties":{"entity_fields":{"type":"array","items":{"$ref":"#/$defs/shared-ad437cb66f"},"minItems":1,"description":"Array of column names to check for ownership"}},"required":["entity_fields"],"additionalProperties":false,"description":"OR logic for multiple ownership fields. Checks if current user matches any of the specified fields."},"AuthzDirectOwnerParams":{"type":"object","properties":{"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the owner user ID (e.g., owner_id)"}},"required":["entity_field"],"additionalProperties":false,"description":"Direct equality comparison between a table column and the current user ID. Simplest authorization pattern with no subqueries."},"AuthzEntityMembershipParams":{"type":"object","properties":{"entity_field":{"$ref":"#/$defs/shared-9d6147637c"},"sel_field":{"type":"string","description":"SPRT column to select for the entity match","default":"entity_id"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"mask_column":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Per-row required permissions (DataCapabilities): a bit(n) column on this table whose bits the actor must hold, checked as sprt.capabilities & row.mask = row.mask. Narrows access row by row without joining a grant table; a zero mask requires nothing. Composes with capability/capabilities — both are ANDed."},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"},"check_function_name":{"type":"string","description":"A function that checks the membership instead of the member list; it is called with the row's team column."},"check_function_schema":{"type":"string","description":"The schema of that function."}},"required":["entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"}],"additionalProperties":false,"description":"Membership check scoped by a field on the row through the SPRT table. Verifies user has membership in the entity referenced by the row."},"AuthzExpression":{"type":"object","description":"One Authz node as {\"AuthzEntityMembership\": {...}}, or AND or OR with a list of expressions, or NOT with one expression.","minProperties":1,"maxProperties":1,"properties":{"AND":{"$ref":"#/$defs/shared-040cc005ef"},"OR":{"$ref":"#/$defs/shared-040cc005ef"},"NOT":{"$ref":"#/$defs/AuthzExpression"},"AuthzAllowAll":{"$ref":"#/$defs/AuthzAllowAllParams"},"AuthzAppMemberOwner":{"$ref":"#/$defs/AuthzAppMemberOwnerParams"},"AuthzAppMembership":{"$ref":"#/$defs/AuthzAppMembershipParams"},"AuthzDatabaseClaim":{"$ref":"#/$defs/AuthzDatabaseClaimParams"},"AuthzDenyAll":{"$ref":"#/$defs/AuthzDenyAllParams"},"AuthzDirectOwner":{"$ref":"#/$defs/AuthzDirectOwnerParams"},"AuthzDirectOwnerAny":{"$ref":"#/$defs/AuthzDirectOwnerAnyParams"},"AuthzEntityMembership":{"$ref":"#/$defs/AuthzEntityMembershipParams"},"AuthzFilePath":{"$ref":"#/$defs/AuthzFilePathParams"},"AuthzHumanOnly":{"$ref":"#/$defs/AuthzHumanOnlyParams"},"AuthzMemberList":{"$ref":"#/$defs/AuthzMemberListParams"},"AuthzMemberOwner":{"$ref":"#/$defs/AuthzMemberOwnerParams"},"AuthzOrgHierarchy":{"$ref":"#/$defs/AuthzOrgHierarchyParams"},"AuthzPeerOwnership":{"$ref":"#/$defs/AuthzPeerOwnershipParams"},"AuthzPublishable":{"$ref":"#/$defs/AuthzPublishableParams"},"AuthzRelatedEntityMembership":{"$ref":"#/$defs/AuthzRelatedEntityMembershipParams"},"AuthzRelatedMemberList":{"$ref":"#/$defs/AuthzRelatedMemberListParams"},"AuthzRelatedMemberOwner":{"$ref":"#/$defs/AuthzRelatedMemberOwnerParams"},"AuthzRelatedPeerOwnership":{"$ref":"#/$defs/AuthzRelatedPeerOwnershipParams"},"AuthzSystemOnly":{"$ref":"#/$defs/AuthzSystemOnlyParams"},"AuthzTemporal":{"$ref":"#/$defs/AuthzTemporalParams"},"AuthzValueAllowed":{"$ref":"#/$defs/AuthzValueAllowedParams"},"AuthzValueExists":{"$ref":"#/$defs/AuthzValueExistsParams"},"AuthzValueMatch":{"$ref":"#/$defs/AuthzValueMatchParams"}},"additionalProperties":false},"AuthzFilePathParams":{"type":"object","properties":{"shares_table_id":{"type":"string","format":"uuid","description":"UUID of the path_shares table (alternative to shares_schema/shares_table)"},"shares_schema":{"type":"string","description":"Schema of the path_shares table (or use shares_table_id)"},"shares_table":{"type":"string","description":"Name of the path_shares table (or use shares_table_id)"},"files_table_id":{"type":"string","format":"uuid","description":"UUID of the files table (alternative to files_schema/files_table)"},"files_schema":{"type":"string","description":"Schema of the files table (or use files_table_id)"},"files_table":{"type":"string","description":"Name of the files table (or use files_table_id)"},"capability_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Boolean column on the path_shares table that grants the required permission (e.g. can_read, can_write)"},"bucket_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Column on the files table referencing the bucket","default":"bucket_id"},"path_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Ltree column on the files table representing the file path","default":"path"}},"required":["capability_field"],"allOf":[{"anyOf":[{"required":["shares_table_id"]},{"required":["shares_schema","shares_table"]}]},{"anyOf":[{"required":["files_table_id"]},{"required":["files_schema","files_table"]}]}],"additionalProperties":false,"description":"Path-scoped file sharing via ltree containment. Grants access when a path_shares row matches the current user, bucket, and an ancestor path with the required permission."},"AuthzHumanOnlyParams":{"type":"object","properties":{},"additionalProperties":false,"description":"Passes only for human sessions: compares the session's principal claim to its user claim, so service principals (API keys, agents) are excluded. Typically applied as a restrictive policy alongside a permissive membership policy."},"AuthzMemberListParams":{"type":"object","properties":{"array_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the array of user IDs"}},"required":["array_field"],"additionalProperties":false,"description":"Check if current user is in an array column on the same row."},"AuthzMemberOwnerParams":{"type":"object","properties":{"owner_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the owner user ID (e.g., owner_id)","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name referencing the entity (e.g., entity_id)","default":"entity_id"},"sel_field":{"type":"string","description":"SPRT column to select for the entity match","default":"entity_id"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["owner_field","entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"}],"additionalProperties":false,"description":"Compound policy: the row must be owned by the current user (owner_field = current_user_id) AND the current user must be a member of the entity referenced by entity_field. Combines direct ownership with entity membership — the actor can only access rows they own within entities they belong to."},"AuthzNotReadOnlyParams":{"type":"object","properties":{"entity_field":{"$ref":"#/$defs/shared-9d6147637c"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"}},"required":["entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"}],"additionalProperties":false,"description":"Restrictive policy that blocks read-only members from mutations. Checks actor_id + is_read_only IS NOT TRUE on the SPRT. Designed to run as a restrictive counterpart after a permissive AuthzEntityMembership policy has already verified membership."},"AuthzOrgHierarchyParams":{"type":"object","properties":{"direction":{"type":"string","enum":["up","down"],"description":"down=manager sees subordinates, up=subordinate sees managers"},"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Field referencing the org entity","default":"entity_id"},"anchor_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Field referencing the user (e.g., owner_id)"},"max_depth":{"type":"integer","description":"Optional max depth to limit visibility"}},"required":["direction","anchor_field"],"additionalProperties":false,"description":"Organizational hierarchy visibility using closure table. Managers can see subordinate data or subordinates can see manager data."},"AuthzPeerOwnershipParams":{"type":"object","properties":{"owner_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name on protected table referencing the owning user (e.g., owner_id)"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-d3e6ac0b5d"},"is_owner":{"$ref":"#/$defs/shared-5e11bfeb01"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["owner_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"}],"additionalProperties":false,"description":"Peer visibility through shared entity membership. Authorizes access to user-owned rows when the owner and current user are both members of the same entity. Self-joins the SPRT table to find peers."},"AuthzPublishableParams":{"type":"object","properties":{"is_published_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Boolean field indicating published state","default":"is_published"},"published_at_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Timestamp field for publish time","default":"published_at"},"require_published_at":{"type":"boolean","description":"Require published_at to be non-null and <= now()","default":true}},"additionalProperties":false,"description":"Published state access control. Restricts access to records that are published."},"AuthzRelatedEntityMembershipParams":{"type":"object","properties":{"entity_field":{"$ref":"#/$defs/shared-dfbaf50fc6"},"sel_field":{"type":"string","description":"SPRT column to select for the entity match","default":"entity_id"},"sprt_join_field":{"type":"string","description":"SPRT column to join on with the related table","default":"entity_id"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"obj_table_id":{"$ref":"#/$defs/shared-9146e81ef6"},"obj_schema":{"$ref":"#/$defs/shared-0968d06284"},"obj_table":{"$ref":"#/$defs/shared-cd4dc6cdf6"},"obj_field_id":{"$ref":"#/$defs/shared-d8e76848ea"},"obj_field":{"$ref":"#/$defs/shared-5249d2cd90"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"sel_obj":{"$ref":"#/$defs/shared-7a53e1103e"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"},{"$ref":"#/$defs/shared-066977ff2f"},{"$ref":"#/$defs/shared-001d8d7cd3"}],"additionalProperties":false,"description":"JOIN-based membership verification through related tables. Joins SPRT table with another table to verify membership."},"AuthzRelatedMemberListParams":{"type":"object","properties":{"owned_table_id":{"type":"string","format":"uuid","description":"UUID of the related table (alternative to owned_schema/owned_table)"},"owned_schema":{"type":"string","description":"Schema of the related table (or use owned_table_id)"},"owned_table":{"type":"string","description":"Name of the related table (or use owned_table_id)"},"owned_table_key":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Array column in related table"},"owned_table_ref_key":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"FK column in related table"},"this_object_key":{"type":"string","format":"column-ref","x-column-scope":"local","description":"PK column in protected table"}},"required":["owned_table_key","owned_table_ref_key","this_object_key"],"anyOf":[{"required":["owned_table_id"]},{"required":["owned_schema","owned_table"]}],"additionalProperties":false,"description":"Array membership check in a related table."},"AuthzRelatedMemberOwnerParams":{"type":"object","properties":{"owner_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the owner user ID (e.g., actor_id)","default":"owner_id"},"entity_field":{"$ref":"#/$defs/shared-dfbaf50fc6"},"sel_field":{"type":"string","description":"SPRT column to select for the entity match","default":"entity_id"},"sprt_join_field":{"type":"string","description":"SPRT column to join on with the related table","default":"entity_id"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"obj_table_id":{"$ref":"#/$defs/shared-9146e81ef6"},"obj_schema":{"$ref":"#/$defs/shared-0968d06284"},"obj_table":{"$ref":"#/$defs/shared-cd4dc6cdf6"},"obj_field_id":{"$ref":"#/$defs/shared-d8e76848ea"},"obj_field":{"$ref":"#/$defs/shared-5249d2cd90"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"sel_obj":{"$ref":"#/$defs/shared-7a53e1103e"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["owner_field","entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"},{"$ref":"#/$defs/shared-066977ff2f"},{"$ref":"#/$defs/shared-001d8d7cd3"}],"additionalProperties":false,"description":"Compound policy: the row must be owned by the current user (owner_field = current_user_id) AND the row must belong to a related entity the current user is a member of (SPRT joined through the related table, as in AuthzRelatedEntityMembership). Related-entity analog of AuthzMemberOwner — authorship never survives losing membership."},"AuthzRelatedPeerOwnershipParams":{"type":"object","properties":{"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name on protected table referencing the related table (e.g., message_id)"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"obj_table_id":{"type":"string","format":"uuid","description":"UUID of the related table (alternative to obj_schema/obj_table)"},"obj_schema":{"type":"string","description":"Schema of the related table (or use obj_table_id)"},"obj_table":{"type":"string","description":"Name of the related table (or use obj_table_id)"},"obj_field_id":{"type":"string","format":"uuid","description":"UUID of field on related table containing the owner user ID (alternative to obj_field)"},"obj_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Field name on related table containing the owner user ID (e.g., sender_id)"},"obj_ref_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Field on related table to select for matching entity_field","default":"id"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-d3e6ac0b5d"},"is_owner":{"$ref":"#/$defs/shared-5e11bfeb01"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"},{"$ref":"#/$defs/shared-066977ff2f"},{"$ref":"#/$defs/shared-001d8d7cd3"}],"additionalProperties":false,"description":"Peer visibility through shared entity membership via a related table. Like AuthzPeerOwnership but the owning user is resolved through a FK JOIN to a related table. Combines SPRT self-join with object table JOIN."},"AuthzSystemOnlyParams":{"type":"object","properties":{},"additionalProperties":false,"description":"Restricts access to system-initiated operations (triggers, background jobs). Checks jwt.claims.role_type = \"system\". Normal API requests default to \"user\" and are denied. Use for INSERT policies on append-only event/audit/usage tables."},"AuthzTemporalParams":{"type":"object","properties":{"valid_from_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column for start time (at least one of valid_from_field or valid_until_field required)"},"valid_until_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column for end time (at least one of valid_from_field or valid_until_field required)"},"valid_from_inclusive":{"type":"boolean","description":"Include start boundary","default":true},"valid_until_inclusive":{"type":"boolean","description":"Include end boundary","default":false}},"anyOf":[{"required":["valid_from_field"]},{"required":["valid_until_field"]}],"additionalProperties":false,"description":"Time-window based access control. Restricts access based on valid_from and/or valid_until timestamps. At least one of valid_from_field or valid_until_field must be provided."},"AuthzValueAllowedParams":{"type":"object","properties":{"column":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column on the protected table to check"},"allowed":{"$ref":"#/$defs/shared-b1944d8f7b"},"operator":{"type":"string","enum":["in","any","overlap","contains","contained"],"description":"Operator to use for the value check"}},"required":["column","allowed","operator"],"additionalProperties":false,"description":"Check the protected row's own column against an allowed set of values."},"AuthzValueExistsParams":{"type":"object","properties":{"ref_table_id":{"$ref":"#/$defs/shared-8cc6b29877"},"ref_schema":{"$ref":"#/$defs/shared-411f8ee76d"},"ref_table":{"$ref":"#/$defs/shared-7f50b0e5b7"},"ref_module":{"$ref":"#/$defs/shared-d85a10e177"},"join":{"$ref":"#/$defs/shared-1ca2c9bd61"},"conditions":{"$ref":"#/$defs/shared-55595a36d2"},"exists":{"$ref":"#/$defs/shared-effacc6003"}},"required":["join"],"anyOf":[{"required":["ref_table_id"]},{"required":["ref_schema","ref_table"]},{"required":["ref_module"]}],"additionalProperties":false,"description":"EXISTS check in a referenced table joined by a local column, with optional additional conditions."},"AuthzValueMatchParams":{"type":"object","properties":{"ref_table_id":{"$ref":"#/$defs/shared-8cc6b29877"},"ref_schema":{"$ref":"#/$defs/shared-411f8ee76d"},"ref_table":{"$ref":"#/$defs/shared-7f50b0e5b7"},"ref_module":{"$ref":"#/$defs/shared-d85a10e177"},"join":{"$ref":"#/$defs/shared-1ca2c9bd61"},"match":{"type":"object","description":"Value match on a referenced column","properties":{"ref_column":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Column on the referenced table to match"},"allowed":{"$ref":"#/$defs/shared-b1944d8f7b"},"operator":{"type":"string","enum":["in","any","overlap","contains","contained"],"description":"Operator to use for the match"}},"required":["ref_column","allowed","operator"],"additionalProperties":false},"conditions":{"$ref":"#/$defs/shared-55595a36d2"},"exists":{"$ref":"#/$defs/shared-effacc6003"}},"required":["match","join"],"anyOf":[{"required":["ref_table_id"]},{"required":["ref_schema","ref_table"]},{"required":["ref_module"]}],"additionalProperties":false,"description":"EXISTS check in a referenced table joined by a local column, with a value/array match on a referenced column and optional additional conditions."},"BlueprintAchievement":{"type":"object","properties":{"name":{"type":"string","description":"Unique name for the achievement level."},"description":{"type":"string","description":"Human-readable description of this achievement."},"priority":{"type":"number","description":"Display ordering priority; lower values appear first. Defaults to 100."},"requirements":{"type":"array","items":{"$ref":"#/$defs/BlueprintAchievementRequirement"},"description":"Requirements that must be met to earn this achievement."},"rewards":{"type":"array","items":{"$ref":"#/$defs/BlueprintAchievementReward"},"description":"Rewards granted when the achievement is earned."},"entity_prefix":{"type":"string","description":"Entity prefix to scope this achievement to (e.g., \"org\", \"app\"). Used to resolve the correct events_module. Defaults to \"app\"."}},"required":["name","requirements"],"description":"An achievement entry for the blueprint achievements[] section. Creates a level with requirements and optional rewards in the events_module. Requires events_module to be provisioned (e.g., via entity_types[].has_levels = true or modules includes events_module)."},"BlueprintAchievementRequirement":{"type":"object","properties":{"event_name":{"type":"string","description":"Name identifier matching an event_type or step name."},"count":{"type":"number","description":"Number of events needed to satisfy this requirement."},"description":{"type":"string","description":"Human-readable description of what this requirement entails."}},"required":["event_name","count"],"description":"A requirement entry within a blueprint achievement. Defines what events must occur to earn the achievement."},"BlueprintAchievementReward":{"type":"object","properties":{"reward_type":{"enum":["limit_credit","meter_credit"],"description":"Type of reward: limit_credit (grants limit credits) or meter_credit (grants meter credits)."},"target_name":{"type":"string","description":"Target limit name or meter slug for the credit grant."},"amount":{"type":"number","description":"Number of credits to grant."},"credit_type":{"type":"string","description":"Credit type: permanent, expiring, etc. Defaults to \"permanent\"."}},"required":["reward_type","target_name","amount"],"description":"A reward entry within a blueprint achievement. Defines credits granted when the achievement is earned."},"BlueprintAgentConfig":{"type":"object","properties":{"scope":{"enum":["app","org"],"description":"Agent scope. \"app\" (default) creates app-level agent tables (membership_type = NULL). \"org\" creates per-org agent tables. Only used at the top level of a blueprint definition — entity-scoped agents inherit scope from the entity type."},"key":{"type":"string","description":"Module discriminator for multi-module agents. Defaults to \"default\" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_agent_thread."},"api_name":{"type":"string","description":"API name for the agent module. Used in GraphQL naming. Defaults to \"agent\"."},"has_plans":{"type":"boolean","description":"Whether to provision the agent_plan table for workflow plans with ordered tasks and approval gates. When true, tasks belong to plans (plan_id NOT NULL) instead of directly to threads. Defaults to false."},"has_resources":{"type":"boolean","description":"Whether to provision the unified agent_resource table (skills + knowledge with slug, kind, search, embedding). Standalone flag — also auto-enabled by has_agents. Defaults to false."},"has_agents":{"type":"boolean","description":"Whether to provision the agent registry (agent table + agent_persona table). Implies has_resources = true. Defaults to false."},"has_runs":{"type":"boolean","description":"Whether to provision the agent execution surface: agent_run (one supervised run of a thread — placement, cursor, artifacts), agent_event (that run's append-only transcript, agent session entries stored verbatim, append-only by grant with UNIQUE (run_id, seq)) and agent_run_workspace (the repositories a run works in — zero rows for a chat with no clone, one per repository otherwise, UNIQUE (run_id, repo)). Defaults to false."},"resources":{"type":"array","items":{"type":"object","properties":{"dimensions":{"type":"number"},"chunk_size":{"type":"number"},"chunk_overlap":{"type":"number"},"chunk_strategy":{"enum":["paragraph","sentence","token"]},"embedding_model":{"type":"string"},"embedding_provider":{"type":"string"},"search_indexes":{"type":"array","items":{"type":"string"}}}},"description":"Resource configuration array. First element configures the agent_resource table: vector dimensions (default 768), chunk_size (default 1000), chunk_strategy (default \"paragraph\"), chunk_overlap (default 200), embedding_model, embedding_provider, search_indexes (default [\"bm25\"])."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policy overrides for the agent tables. NULL = apply defaults from apply_agent_security()."},"provisions":{"type":"object","properties":{"thread":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"message":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"task":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"prompt":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"plan":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"resource":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"agent":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"persona":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"run":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"event":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"workspace":{"$ref":"#/$defs/BlueprintEntityTableProvision"}},"description":"Per-table overrides for agent tables. Each key targets a specific table (thread, message, task, prompt, plan, resource, agent, persona, run, event, workspace) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision. Overriding `event` replaces the append-only default, so a grant list there can make the transcript mutable; overriding `workspace` replaces its no-delete default."}},"description":"Agent module configuration. When used at the top level of a blueprint, the scope field controls whether agents are app-level (\"app\", default) or org-level (\"org\"). When used inside entity_types[], scope is inherited from the entity type. Provisions thread, message, task, prompt tables. has_resources adds unified agent_resource (skills + knowledge). has_agents adds agent registry + personas (implies has_resources)."},"BlueprintBucketSeed":{"type":"object","properties":{"name":{"type":"string","description":"Bucket key name (e.g., \"avatars\", \"documents\"). Becomes the key column value."},"description":{"type":"string","description":"Human-readable description of this bucket."},"is_public":{"type":"boolean","description":"Whether the bucket is publicly readable. Defaults to false."},"allowed_mime_types":{"type":"array","items":{"type":"string"},"description":"MIME type allowlist (e.g., [\"image/png\", \"image/jpeg\"]). NULL means all types allowed."},"max_file_size":{"type":"number","description":"Maximum file size in bytes for this bucket. NULL means no limit."},"allowed_origins":{"type":"array","items":{"type":"string"},"description":"CORS allowed origins for this bucket."}},"required":["name"],"description":"A bucket seed entry for storage.buckets[]. Creates an initial bucket row in the {prefix}_buckets table during entity type provisioning. Only used for app-level storage (not entity-scoped)."},"BlueprintCheckConstraint":{"allOf":[{"$ref":"#/$defs/BlueprintTableCheckConstraint"},{"type":"object","properties":{"table_name":{"type":"string","description":"Table name this CHECK constraint belongs to."}},"required":["table_name"]}],"description":"A CHECK constraint definition within a blueprint (top-level, requires table_name)."},"BlueprintDefinition":{"type":"object","properties":{"tables":{"type":"array","items":{"$ref":"#/$defs/BlueprintTable"},"description":"Tables to create."},"relations":{"type":"array","items":{"$ref":"#/$defs/BlueprintRelation"},"description":"Relations between tables."},"indexes":{"type":"array","items":{"$ref":"#/$defs/BlueprintIndex"},"description":"Indexes on table columns."},"full_text_searches":{"type":"array","items":{"$ref":"#/$defs/BlueprintFullTextSearch"},"description":"Full-text search configurations."},"unique_constraints":{"type":"array","items":{"$ref":"#/$defs/BlueprintUniqueConstraint"},"description":"Unique constraints on table columns."},"check_constraints":{"type":"array","items":{"$ref":"#/$defs/BlueprintCheckConstraint"},"description":"CHECK constraints on table columns."},"entity_types":{"type":"array","items":{"$ref":"#/$defs/BlueprintEntityType"},"description":"Entity types to provision in Phase 0 (before tables). Each entry creates an entity table with membership modules and security."},"storage":{"type":"array","items":{"$ref":"#/$defs/BlueprintStorageConfig"},"description":"Top-level storage configuration array. Each entry has an optional scope (\"app\" or \"org\"). App-scoped (default) creates storage_module with membership_type = NULL. Org-scoped creates per-org/user storage with owner_id and AFTER INSERT bucket seeding. When infra is installed, a private \"functions\" bucket is auto-injected into org-scoped entries. For child entity type storage, use entity_types[].storage instead."},"achievements":{"type":"array","items":{"$ref":"#/$defs/BlueprintAchievement"},"description":"Achievement definitions. Each entry creates a level with requirements and optional rewards in the events_module. Requires events_module to be provisioned (e.g., via entity_types[].has_levels = true or modules includes events_module)."},"namespaces":{"type":"array","items":{"$ref":"#/$defs/BlueprintNamespaceConfig"},"description":"Top-level namespace configuration array (Phase 0.6). Each entry has an optional scope (\"app\" or \"org\"). App-scoped (default) creates namespace_module with membership_type = NULL. Org-scoped creates per-org namespaces. For entity-scoped namespaces, use entity_types[].namespaces instead."},"functions":{"type":"array","items":{"$ref":"#/$defs/BlueprintFunctionConfig"},"description":"Top-level function configuration array (Phase 0.6). Each entry has an optional scope (\"app\" or \"org\"). App-scoped (default) creates function_module with membership_type = NULL. Org-scoped creates per-org functions. For entity-scoped functions, use entity_types[].functions instead."},"agents":{"type":"array","items":{"$ref":"#/$defs/BlueprintAgentConfig"},"description":"Top-level agent configuration array (Phase 0.6). Each entry has an optional scope (\"app\" or \"org\"). App-scoped (default) creates agent_module with membership_type = NULL. Org-scoped creates per-org agents. For entity-scoped agents, use entity_types[].agents instead."}},"required":["tables"],"description":"The complete blueprint definition -- the JSONB shape accepted by construct_blueprint()."},"BlueprintEntityTableProvision":{"type":"object","properties":{"use_rls":{"type":"boolean","description":"Whether to enable RLS on the entity table. Forwarded to secure_table_provision. Defaults to true."},"nodes":{"type":"array","items":{"$ref":"#/$defs/BlueprintNode"},"description":"Node objects applied to the entity table for field creation (e.g., DataTimestamps, DataPeoplestamps). Forwarded to secure_table_provision as-is."},"fields":{"type":"array","items":{"$ref":"#/$defs/BlueprintField"},"description":"Custom fields (columns) to add to the entity table. Forwarded to secure_table_provision as-is."},"grants":{"type":"array","items":{"$ref":"#/$defs/shared-bc381c03de"},"description":"Unified grant objects for the entity table. Each entry is { roles: string[], privileges: unknown[] } where privileges are [verb, columns] tuples. Forwarded to secure_table_provision as-is. Defaults to []."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policies for the entity table. When present, these policies fully replace the five default entity-table policies (is_visible becomes a no-op)."}},"description":"Override object for the entity table created by a BlueprintEntityType. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, policies[] replaces the default entity-table policies entirely."},"BlueprintEntityType":{"type":"object","properties":{"name":{"type":"string","description":"Entity type name (e.g., \"data_room\", \"channel\", \"department\"). Required when creating a new entity type. Omit when extending an existing entity type (e.g., prefix: \"org\") — the entry will add storage/config to the existing type without creating a new one."},"prefix":{"type":"string","description":"Short prefix for generated objects (e.g., \"dr\", \"ch\", \"dept\"). Used in table/trigger naming."},"description":{"type":"string","description":"Human-readable description of this entity type."},"parent_entity":{"type":"string","description":"Parent entity type name. Defaults to \"org\"."},"table_name":{"type":"string","description":"Custom table name for the entity table. Defaults to name-derived convention."},"is_visible":{"type":"boolean","description":"Whether parent-entity members can see child entities via the default parent_member SELECT policy. Gates one of the five default policies. No-op when table_provision is supplied. Defaults to true."},"has_limits":{"type":"boolean","description":"Whether to provision a limits module for this entity type. Defaults to false."},"has_profiles":{"type":"boolean","description":"Whether to provision a profiles module for this entity type. Defaults to false. A membership may hold any number of profiles: the {prefix}_membership_profiles assignment table holds every profile it holds and the membership mask is granted | bit_or(held profile masks)."},"has_levels":{"type":"boolean","description":"Whether to provision a levels module for this entity type. Defaults to false."},"has_invites":{"type":"boolean","description":"Whether to provision entity-scoped invite tables ({prefix}_invites, {prefix}_claimed_invites) and a submit_{prefix}_invite_code() function. Defaults to false."},"has_invite_achievements":{"type":"boolean","description":"Whether to auto-attach an EventTracker to the claimed_invites table for invite-based achievements. Requires has_invites=true AND has_levels=true. When true, records 'invite_claimed' events credited to the sender (inviter) on each claimed invite. Defaults to false."},"skip_entity_policies":{"type":"boolean","description":"Escape hatch: when true AND table_provision is NULL, zero policies are provisioned on the entity table. Defaults to false."},"table_provision":{"$ref":"#/$defs/BlueprintEntityTableProvision","description":"Override for the entity table. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, its policies[] replaces the five default entity-table policies; is_visible becomes a no-op. When NULL (default), the five default policies are applied (gated by is_visible)."},"storage":{"type":"array","items":{"$ref":"#/$defs/BlueprintStorageConfig"},"description":"Storage module configuration array. Presence triggers provisioning (same inference model as namespaces, functions, agents). Each entry provisions a separate storage module with its own tables, RLS, and settings. Each entry may specify a key for multi-module support (defaults to \"default\")."},"namespaces":{"type":"array","items":{"$ref":"#/$defs/BlueprintNamespaceConfig"},"description":"Namespace module configuration array. Presence triggers provisioning. Each entry provisions a namespace_module with its own tables, computed-name proxy, and entity-scoped RLS. Registers manage_namespaces capability bit. \"[{}]\" = provision one default namespace module."},"functions":{"type":"array","items":{"$ref":"#/$defs/BlueprintFunctionConfig"},"description":"Function module configuration array. Presence triggers provisioning. Each entry provisions function_definitions, function_invocations (partitioned), and function_execution_logs tables. Registers manage_functions + invoke_functions capability bits. \"[{}]\" = provision one default function module."},"agents":{"type":"array","items":{"$ref":"#/$defs/BlueprintAgentConfig"},"description":"Agent module configuration array. Presence triggers provisioning. Each entry provisions thread, message, task, prompt tables (and optionally knowledge with vector embeddings). \"[{}]\" = provision one default agent module."},"graphs":{"type":"array","items":{"$ref":"#/$defs/BlueprintGraphConfig"},"description":"Graph module configuration array. Presence triggers capability registration (manage_graphs, execute_graphs). Graph module requires a merkle_store_module_id dependency, so entity_type_provision only registers capabilities here. \"[{}]\" = register default graph capabilities."}},"required":["prefix"],"description":"An entity type entry for Phase 0 of construct_blueprint(). When name is provided, provisions a new entity type with its own entity table, membership modules, and security policies via entity_type_provision. When name is omitted and only prefix is given, extends an existing entity type (e.g., the built-in \"org\") with additional capabilities like storage — without creating a new entity type."},"BlueprintField":{"type":"object","properties":{"name":{"type":"string","description":"The column name."},"type":{"$ref":"#/$defs/FieldType","description":"The structured PostgreSQL type (e.g., { name: \"text\" })."},"is_required":{"type":"boolean","description":"Whether the column has a NOT NULL constraint."},"default":{"$ref":"#/$defs/FieldDefault","description":"The structured default (e.g., { value: \"pending\" })."},"min":{"type":"number"},"max":{"type":"number"},"regexp":{"type":"string"},"index":{"enum":["btree","gin","gist","brin","hash"]},"description":{"type":"string","description":"Comment/description for this field."}},"required":["name","type"],"description":"A custom field (column) to add to a blueprint table."},"BlueprintFtsSource":{"type":"object","properties":{"field":{"type":"string","description":"Column name of the source field."},"weight":{"type":"string","description":"TSVector weight: \"A\", \"B\", \"C\", or \"D\"."},"lang":{"type":"string","description":"Language for text search. Defaults to \"english\"."}},"required":["field","weight"],"description":"A source field contributing to a full-text search tsvector column."},"BlueprintFullTextSearch":{"type":"object","properties":{"table_name":{"type":"string","description":"Table name this full-text search belongs to."},"schema_name":{"$ref":"#/$defs/shared-6adc1df48e"},"field":{"$ref":"#/$defs/shared-ee69c55731"},"sources":{"$ref":"#/$defs/shared-626b0c3c0b"}},"required":["table_name","field","sources"],"description":"A full-text search configuration for a blueprint table (top-level, requires table_name)."},"BlueprintFunctionConfig":{"type":"object","properties":{"scope":{"enum":["app","org"],"description":"Function scope. \"app\" (default) creates app-level functions (membership_type = NULL). \"org\" creates per-org functions. Only used at the top level of a blueprint definition — entity-scoped functions inherit scope from the entity type."},"key":{"type":"string","description":"Module discriminator for multi-module functions. Defaults to \"default\" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_function_definitions."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policy overrides for the function tables. NULL = apply defaults from apply_function_security()."},"provisions":{"type":"object","properties":{"definitions":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"invocations":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"execution_logs":{"$ref":"#/$defs/BlueprintEntityTableProvision"}},"description":"Per-table overrides for function tables. Each key targets a specific table (definitions, invocations, execution_logs) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision."}},"description":"Function module configuration. When used at the top level of a blueprint, the scope field controls whether functions are app-level (\"app\", default) or org-level (\"org\"). When used inside entity_types[], scope is inherited from the entity type. Provisions function_definitions, function_invocations (partitioned, 12-month retention), and function_execution_logs tables."},"BlueprintGraphConfig":{"type":"object","properties":{"key":{"type":"string","description":"Module discriminator for multi-module graphs. Defaults to \"default\"."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policy overrides for the graph tables. NULL = apply defaults from apply_graph_security()."}},"description":"Graph module configuration. Presence triggers capability registration (manage_graphs, execute_graphs). The graph module requires a merkle_store_module_id dependency, so entity_type_provision only registers capabilities here — the graph module itself must be provisioned separately."},"BlueprintIndex":{"type":"object","properties":{"table_name":{"type":"string","description":"Table name this index belongs to."},"schema_name":{"$ref":"#/$defs/shared-6adc1df48e"},"column":{"$ref":"#/$defs/shared-0a22d2c3f6"},"columns":{"$ref":"#/$defs/shared-5a2832df1c"},"access_method":{"$ref":"#/$defs/shared-2a834ba4ff"},"is_unique":{"$ref":"#/$defs/shared-bb55f34041"},"name":{"$ref":"#/$defs/shared-f35a015b21"},"op_classes":{"$ref":"#/$defs/shared-22f38cc906"},"options":{"$ref":"#/$defs/shared-e772a2f2a5"}},"required":["table_name","access_method"],"description":"An index definition within a blueprint (top-level, requires table_name)."},"BlueprintModuleInstallRef":{"type":"object","properties":{"type":{"type":"string","description":"Module type of the install, e.g. \"image\"."},"scope":{"$ref":"#/$defs/shared-e1125a4a5e"},"prefix":{"$ref":"#/$defs/shared-ab15ceab40"}},"required":["type"],"description":"A reference to an installed module, naming no table of its own. Used by a table entry whose provisions map supplies the table keys."},"BlueprintModuleTableRef":{"type":"object","properties":{"type":{"type":"string","description":"Module type owning the table. Currently \"agent\"."},"table":{"type":"string","description":"Logical table key within the module, not a table name. Agent: \"thread\", \"message\", \"task\", \"prompt\", \"plan\", \"agent\", \"persona\", \"resource\"."},"scope":{"$ref":"#/$defs/shared-e1125a4a5e"},"prefix":{"$ref":"#/$defs/shared-ab15ceab40"}},"required":["type","table"],"description":"A reference from a blueprint table entry to a table generated by an installed module. Resolved through the module row's recorded table ids; a reference that matches no module instance or no provisioned table fails construction rather than creating a table."},"BlueprintNamespaceConfig":{"type":"object","properties":{"scope":{"enum":["app","org"],"description":"Namespace scope. \"app\" (default) creates app-level namespaces (membership_type = NULL). \"org\" creates per-org namespaces. Only used at the top level of a blueprint definition — entity-scoped namespaces inherit scope from the entity type."},"key":{"type":"string","description":"Module discriminator for multi-module namespaces. Defaults to \"default\" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_namespaces."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policy overrides for the namespaces table. NULL = apply defaults from apply_namespace_security()."},"provisions":{"type":"object","properties":{"namespaces":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"namespace_events":{"$ref":"#/$defs/BlueprintEntityTableProvision"}},"description":"Per-table overrides for namespace tables. Each key targets a specific table (namespaces, namespace_events) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision."}},"description":"Namespace module configuration. When used at the top level of a blueprint, the scope field controls whether namespaces are app-level (\"app\", default) or org-level (\"org\"). When used inside entity_types[], scope is inherited from the entity type. Provisions a namespaces table with computed-name proxy, rename trigger, and entity-scoped RLS."},"BlueprintNode":{"anyOf":[{"$ref":"#/$defs/BlueprintNodeShorthand"},{"$ref":"#/$defs/BlueprintNodeObject"}],"description":"A node entry in a blueprint table. Either a string shorthand or a typed object."},"BlueprintNodeObject":{"type":"object","properties":{"data":{"type":"object"},"$type":{"enum":["AuthzAllowAll","AuthzAppMemberOwner","AuthzAppMembership","AuthzColumnSecurity","AuthzComposite","AuthzDatabaseClaim","AuthzDenyAll","AuthzDirectOwner","AuthzDirectOwnerAny","AuthzEntityMembership","AuthzFilePath","AuthzHumanOnly","AuthzMemberList","AuthzMemberOwner","AuthzNotReadOnly","AuthzOrgHierarchy","AuthzPeerOwnership","AuthzPublishable","AuthzRelatedEntityMembership","AuthzRelatedMemberList","AuthzRelatedMemberOwner","AuthzRelatedPeerOwnership","AuthzSystemOnly","AuthzTemporal","AuthzValueAllowed","AuthzValueExists","AuthzValueMatch","CheckGreaterThan","CheckLessThan","CheckNotEqual","CheckOneOf","CheckOwnedRelation","DataArchivable","DataBulk","DataCapabilities","DataCompositeField","DataDenormalized","DataDirectOwner","DataEntityMembership","DataForceCurrentUser","DataGenerated","DataHistory","DataI18n","DataId","DataIdentity","DataImmutableFields","DataInflection","DataInheritFromParent","DataJsonb","DataLock","DataMemberOwner","DataOwnedFields","DataOwnershipInEntity","DataPeoplestamps","DataPrincipalstamps","DataPublishable","DataRealtime","DataSlug","DataSoftDelete","DataStatusField","DataTags","DataTimestamps","SearchBm25","SearchFullText","SearchSpatial","SearchSpatialAggregate","SearchTrgm","SearchUnified","SearchVector","TableOrganizationSettings","TableUserProfiles","TableUserSettings","EventReferral","EventTracker","GuardStepUp","JobTrigger","LimitEnforceAggregate","LimitEnforceCounter","LimitEnforceFeature","LimitEnforceRate","LimitTrackUsage","LimitWarningAggregate","LimitWarningCounter","LimitWarningRate","ProcessChunks","ProcessExtraction","ProcessFileEmbedding","ProcessImageEmbedding","ProcessImageVersions"]}},"additionalProperties":false,"required":["$type"],"allOf":[{"$ref":"#/$defs/shared-39f66ad592"},{"if":{"$ref":"#/$defs/shared-49ec07b1f5"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzAppMemberOwnerParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-21a1ba9587"},{"if":{"properties":{"$type":{"const":"AuthzColumnSecurity"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzColumnSecurityParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-6639e33d04"},{"$ref":"#/$defs/shared-36ea8e912e"},{"$ref":"#/$defs/shared-152f619c56"},{"if":{"$ref":"#/$defs/shared-47ab73adbe"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDirectOwnerParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-34021cf1ff"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDirectOwnerAnyParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-15602a740a"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzEntityMembershipParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-5f5453df14"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzFilePathParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-aced6572ca"},{"if":{"$ref":"#/$defs/shared-eff5f86cd2"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzMemberListParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-d91c021eee"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzMemberOwnerParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-2c17992067"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzNotReadOnlyParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-97d5c3be03"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzOrgHierarchyParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-b1dc7b2e4f"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzPeerOwnershipParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-6dbc2f5a83"},{"if":{"$ref":"#/$defs/shared-f93f3b8ac9"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedEntityMembershipParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-584ca266e8"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedMemberListParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-433a283165"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedMemberOwnerParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-5192cb016d"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedPeerOwnershipParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-2997c2f821"},{"$ref":"#/$defs/shared-8881b94a41"},{"if":{"$ref":"#/$defs/shared-57b27779bd"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueAllowedParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-e23bde2ba6"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueExistsParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-3245b618eb"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueMatchParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-2c20767ba3"},"then":{"properties":{"data":{"$ref":"#/$defs/CheckGreaterThanParams"}}}},{"if":{"$ref":"#/$defs/shared-8358853df2"},"then":{"properties":{"data":{"$ref":"#/$defs/CheckLessThanParams"}}}},{"if":{"$ref":"#/$defs/shared-1c8d46d43b"},"then":{"properties":{"data":{"$ref":"#/$defs/CheckNotEqualParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-078ee82414"},"then":{"properties":{"data":{"$ref":"#/$defs/CheckOneOfParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"CheckOwnedRelation"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/CheckOwnedRelationParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataArchivable"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataArchivableParams"}}}},{"if":{"properties":{"$type":{"const":"DataBulk"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataBulkParams"}}}},{"if":{"properties":{"$type":{"const":"DataCapabilities"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataCapabilitiesParams"}}}},{"if":{"properties":{"$type":{"const":"DataCompositeField"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataCompositeFieldParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataDenormalized"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataDenormalizedParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataDirectOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataDirectOwnerParams"}}}},{"if":{"properties":{"$type":{"const":"DataEntityMembership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataEntityMembershipParams"}}}},{"if":{"properties":{"$type":{"const":"DataForceCurrentUser"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataForceCurrentUserParams"}}}},{"if":{"properties":{"$type":{"const":"DataGenerated"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataGeneratedParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataHistory"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataHistoryParams"}}}},{"if":{"properties":{"$type":{"const":"DataI18n"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataI18nParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataId"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataIdParams"}}}},{"if":{"properties":{"$type":{"const":"DataIdentity"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataIdentityParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataImmutableFields"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataImmutableFieldsParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataInflection"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataInflectionParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataInheritFromParent"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataInheritFromParentParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataJsonb"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataJsonbParams"}}}},{"if":{"properties":{"$type":{"const":"DataLock"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataLockParams"}}}},{"if":{"properties":{"$type":{"const":"DataMemberOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataMemberOwnerParams"}}}},{"if":{"properties":{"$type":{"const":"DataOwnedFields"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataOwnedFieldsParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataOwnershipInEntity"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataOwnershipInEntityParams"}}}},{"if":{"properties":{"$type":{"const":"DataPeoplestamps"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataPeoplestampsParams"}}}},{"if":{"properties":{"$type":{"const":"DataPrincipalstamps"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataPrincipalstampsParams"}}}},{"if":{"properties":{"$type":{"const":"DataPublishable"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataPublishableParams"}}}},{"if":{"properties":{"$type":{"const":"DataRealtime"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataRealtimeParams"}}}},{"if":{"properties":{"$type":{"const":"DataSlug"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataSlugParams"}}}},{"if":{"properties":{"$type":{"const":"DataSoftDelete"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataSoftDeleteParams"}}}},{"if":{"properties":{"$type":{"const":"DataStatusField"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataStatusFieldParams"}}}},{"if":{"properties":{"$type":{"const":"DataTags"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataTagsParams"}}}},{"if":{"properties":{"$type":{"const":"DataTimestamps"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataTimestampsParams"}}}},{"if":{"properties":{"$type":{"const":"SearchBm25"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchBm25Params"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"SearchFullText"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchFullTextParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"SearchSpatial"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchSpatialParams"}}}},{"if":{"properties":{"$type":{"const":"SearchSpatialAggregate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchSpatialAggregateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"SearchTrgm"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchTrgmParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"SearchUnified"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchUnifiedParams"}}}},{"if":{"properties":{"$type":{"const":"SearchVector"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchVectorParams"}}}},{"if":{"properties":{"$type":{"const":"TableOrganizationSettings"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/TableOrganizationSettingsParams"}}}},{"if":{"properties":{"$type":{"const":"TableUserProfiles"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/TableUserProfilesParams"}}}},{"if":{"properties":{"$type":{"const":"TableUserSettings"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/TableUserSettingsParams"}}}},{"if":{"properties":{"$type":{"const":"EventReferral"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/EventReferralParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"EventTracker"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/EventTrackerParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"GuardStepUp"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/GuardStepUpParams"}}}},{"if":{"properties":{"$type":{"const":"JobTrigger"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/JobTriggerParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitEnforceAggregate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitEnforceAggregateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitEnforceCounter"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitEnforceCounterParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitEnforceFeature"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitEnforceFeatureParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitEnforceRate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitEnforceRateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitTrackUsage"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitTrackUsageParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitWarningAggregate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitWarningAggregateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitWarningCounter"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitWarningCounterParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitWarningRate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitWarningRateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"ProcessChunks"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessChunksParams"}}}},{"if":{"properties":{"$type":{"const":"ProcessExtraction"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessExtractionParams"}}}},{"if":{"properties":{"$type":{"const":"ProcessFileEmbedding"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessFileEmbeddingParams"}}}},{"if":{"properties":{"$type":{"const":"ProcessImageEmbedding"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessImageEmbeddingParams"}}}},{"if":{"properties":{"$type":{"const":"ProcessImageVersions"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessImageVersionsParams"}},"required":["data"]}}],"description":"Object form -- { $type, data } with typed parameters."},"BlueprintNodeShorthand":{"enum":["AuthzAllowAll","AuthzAppMemberOwner","AuthzAppMembership","AuthzColumnSecurity","AuthzComposite","AuthzDatabaseClaim","AuthzDenyAll","AuthzDirectOwner","AuthzDirectOwnerAny","AuthzEntityMembership","AuthzFilePath","AuthzHumanOnly","AuthzMemberList","AuthzMemberOwner","AuthzNotReadOnly","AuthzOrgHierarchy","AuthzPeerOwnership","AuthzPublishable","AuthzRelatedEntityMembership","AuthzRelatedMemberList","AuthzRelatedMemberOwner","AuthzRelatedPeerOwnership","AuthzSystemOnly","AuthzTemporal","AuthzValueAllowed","AuthzValueExists","AuthzValueMatch","CheckGreaterThan","CheckLessThan","CheckNotEqual","CheckOneOf","CheckOwnedRelation","DataArchivable","DataBulk","DataCapabilities","DataCompositeField","DataDenormalized","DataDirectOwner","DataEntityMembership","DataForceCurrentUser","DataGenerated","DataHistory","DataI18n","DataId","DataIdentity","DataImmutableFields","DataInflection","DataInheritFromParent","DataJsonb","DataLock","DataMemberOwner","DataOwnedFields","DataOwnershipInEntity","DataPeoplestamps","DataPrincipalstamps","DataPublishable","DataRealtime","DataSlug","DataSoftDelete","DataStatusField","DataTags","DataTimestamps","SearchBm25","SearchFullText","SearchSpatial","SearchSpatialAggregate","SearchTrgm","SearchUnified","SearchVector","TableOrganizationSettings","TableUserProfiles","TableUserSettings","EventReferral","EventTracker","GuardStepUp","JobTrigger","LimitEnforceAggregate","LimitEnforceCounter","LimitEnforceFeature","LimitEnforceRate","LimitTrackUsage","LimitWarningAggregate","LimitWarningCounter","LimitWarningRate","ProcessChunks","ProcessExtraction","ProcessFileEmbedding","ProcessImageEmbedding","ProcessImageVersions"],"description":"String shorthand -- just the node type name."},"BlueprintPolicy":{"type":"object","properties":{"privileges":{"type":"array","minItems":1,"items":{"type":"string","pattern":"^([Ss][Ee][Ll][Ee][Cc][Tt]|[Ii][Nn][Ss][Ee][Rr][Tt]|[Uu][Pp][Dd][Aa][Tt][Ee]|[Dd][Ee][Ll][Ee][Tt][Ee])$"}},"permissive":{"type":"boolean"},"policy_role":{"type":"string"},"policy_name":{"type":"string"},"data":{"type":"object"},"with_check":{"$ref":"#/$defs/BlueprintPolicyWithCheck"},"$type":{"$ref":"#/$defs/shared-af38a22089"}},"additionalProperties":false,"required":["$type"],"allOf":[{"$ref":"#/$defs/shared-39f66ad592"},{"$ref":"#/$defs/shared-eb6d498d14"},{"$ref":"#/$defs/shared-21a1ba9587"},{"$ref":"#/$defs/shared-6639e33d04"},{"$ref":"#/$defs/shared-36ea8e912e"},{"$ref":"#/$defs/shared-152f619c56"},{"$ref":"#/$defs/shared-c893ee8510"},{"$ref":"#/$defs/shared-a2c45e97d1"},{"$ref":"#/$defs/shared-85b2c2543e"},{"$ref":"#/$defs/shared-e3e4ac8f48"},{"$ref":"#/$defs/shared-aced6572ca"},{"$ref":"#/$defs/shared-11809f0714"},{"$ref":"#/$defs/shared-a9d73b8ba7"},{"$ref":"#/$defs/shared-8e6e495eb6"},{"$ref":"#/$defs/shared-c2c61348f0"},{"$ref":"#/$defs/shared-4f25156f61"},{"$ref":"#/$defs/shared-6dbc2f5a83"},{"$ref":"#/$defs/shared-33013a269d"},{"$ref":"#/$defs/shared-0596961db6"},{"$ref":"#/$defs/shared-89ec3722aa"},{"$ref":"#/$defs/shared-1a97ddc6fb"},{"$ref":"#/$defs/shared-2997c2f821"},{"$ref":"#/$defs/shared-8881b94a41"},{"$ref":"#/$defs/shared-c88c54a5c5"},{"$ref":"#/$defs/shared-3fc6945ad1"},{"$ref":"#/$defs/shared-c1527c6159"}],"description":"An RLS policy entry for a blueprint table. A with_check override applies to UPDATE only.","if":{"required":["with_check"]},"then":{"required":["privileges"],"properties":{"privileges":{"items":{"type":"string","pattern":"^[Uu][Pp][Dd][Aa][Tt][Ee]$"}}}}},"BlueprintPolicyWithCheck":{"type":"object","properties":{"data":{"type":"object"},"$type":{"$ref":"#/$defs/shared-af38a22089"}},"additionalProperties":false,"required":["$type"],"allOf":[{"$ref":"#/$defs/shared-39f66ad592"},{"$ref":"#/$defs/shared-eb6d498d14"},{"$ref":"#/$defs/shared-21a1ba9587"},{"$ref":"#/$defs/shared-6639e33d04"},{"$ref":"#/$defs/shared-36ea8e912e"},{"$ref":"#/$defs/shared-152f619c56"},{"$ref":"#/$defs/shared-c893ee8510"},{"$ref":"#/$defs/shared-a2c45e97d1"},{"$ref":"#/$defs/shared-85b2c2543e"},{"$ref":"#/$defs/shared-e3e4ac8f48"},{"$ref":"#/$defs/shared-aced6572ca"},{"$ref":"#/$defs/shared-11809f0714"},{"$ref":"#/$defs/shared-a9d73b8ba7"},{"$ref":"#/$defs/shared-8e6e495eb6"},{"$ref":"#/$defs/shared-c2c61348f0"},{"$ref":"#/$defs/shared-4f25156f61"},{"$ref":"#/$defs/shared-6dbc2f5a83"},{"$ref":"#/$defs/shared-33013a269d"},{"$ref":"#/$defs/shared-0596961db6"},{"$ref":"#/$defs/shared-89ec3722aa"},{"$ref":"#/$defs/shared-1a97ddc6fb"},{"$ref":"#/$defs/shared-2997c2f821"},{"$ref":"#/$defs/shared-8881b94a41"},{"$ref":"#/$defs/shared-c88c54a5c5"},{"$ref":"#/$defs/shared-3fc6945ad1"},{"$ref":"#/$defs/shared-c1527c6159"}]},"BlueprintRelation":{"type":"object","description":"A relation entry in a blueprint definition.","properties":{"source_table":{"type":"string"},"target_table":{"type":"string"},"source_schema":{"type":"string"},"target_schema":{"type":"string"},"source_module":{"$ref":"#/$defs/BlueprintModuleTableRef"},"target_module":{"$ref":"#/$defs/BlueprintModuleTableRef"},"$type":{"enum":["RelationBelongsTo","RelationHasMany","RelationHasOne","RelationManyToMany","RelationSpatial"]}},"required":["$type"],"allOf":[{"if":{"properties":{"$type":{"const":"RelationBelongsTo"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"Table that will have the FK field added"},"target_table_id":{"$ref":"#/$defs/shared-db0e2e6361"},"field_name":{"type":"string","format":"column-ref","description":"FK field name on the source table. Auto-derived from target table name if omitted (e.g., projects → project_id)"},"delete_action":{"$ref":"#/$defs/shared-e6dbbbcd8d"},"is_required":{"type":"boolean","description":"Whether the FK field is NOT NULL","default":true}}}},{"if":{"properties":{"$type":{"const":"RelationHasMany"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"Parent table being referenced by the FK (e.g., projects in projects has many tasks)"},"target_table_id":{"type":"string","format":"uuid","description":"Child table that receives the FK field (e.g., tasks in projects has many tasks)"},"field_name":{"type":"string","format":"column-ref","description":"FK field name on the target table. Auto-derived from source table name if omitted (e.g., projects derives project_id)"},"delete_action":{"$ref":"#/$defs/shared-e6dbbbcd8d"},"is_required":{"type":"boolean","description":"Whether the FK field is NOT NULL","default":true}}}},{"if":{"properties":{"$type":{"const":"RelationHasOne"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"Table that will have the FK field and unique constraint"},"target_table_id":{"$ref":"#/$defs/shared-db0e2e6361"},"field_name":{"type":"string","format":"column-ref","description":"FK field name on the source table. Auto-derived from target table name if omitted (e.g., users → user_id)"},"delete_action":{"$ref":"#/$defs/shared-e6dbbbcd8d"},"is_required":{"type":"boolean","description":"Whether the FK field is NOT NULL","default":true}}}},{"if":{"properties":{"$type":{"const":"RelationManyToMany"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"First table in the M:N relationship"},"target_table_id":{"type":"string","format":"uuid","description":"Second table in the M:N relationship"},"junction_table_id":{"type":"string","format":"uuid","description":"Existing junction table to use. If uuid_nil(), a new bare table is created"},"junction_table_name":{"type":"string","description":"Junction table name. Auto-derived from both table names if omitted (e.g., projects + tags derives project_tags)"},"source_field_name":{"type":"string","format":"column-ref","description":"FK field name on junction for source table. Auto-derived if omitted (e.g., projects derives project_id)"},"target_field_name":{"type":"string","format":"column-ref","description":"FK field name on junction for target table. Auto-derived if omitted (e.g., tags derives tag_id)"},"use_composite_key":{"type":"boolean","description":"When true, creates a composite PK from the two FK fields. When false, no PK is created by the trigger (use nodes with DataId for UUID PK). Mutually exclusive with nodes containing DataId.","default":false},"nodes":{"type":"array","items":{"type":"object"},"description":"Array of node objects for field creation on junction table. Each object has a $type key (e.g. DataId, DataEntityMembership) and optional data keys. Forwarded to secure_table_provision as-is. Empty array means no additional fields."},"grants":{"type":"array","items":{"type":"object","properties":{"roles":{"type":"array","items":{"type":"string"}},"privileges":{"type":"array","items":{"type":"array","items":{"type":"string"}}}},"required":["roles","privileges"]},"description":"Unified grant objects for the junction table. Each entry is { roles: string[], privileges: string[][] }. Forwarded to secure_table_provision as-is. Default: []"},"policies":{"type":"array","items":{"type":"object","properties":{"$type":{"type":"string"},"data":{"type":"object"},"privileges":{"type":"array","items":{"type":"string"}},"policy_role":{"type":"string"},"permissive":{"type":"boolean"},"policy_name":{"type":"string"}},"required":["$type"]},"description":"RLS policy objects for the junction table. Each entry has $type (Authz* generator), optional data, privileges, policy_role, permissive, policy_name. Forwarded to secure_table_provision as-is. Default: []"}}}},{"if":{"properties":{"$type":{"const":"RelationSpatial"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"Table that owns the relation (the @spatialRelation tag is emitted on the owner column of this table)"},"source_field_id":{"type":"string","format":"uuid","description":"Geometry/geography column on source_table that carries the @spatialRelation smart tag"},"target_table_id":{"type":"string","format":"uuid","description":"Table being referenced by the spatial predicate"},"target_field_id":{"type":"string","format":"uuid","description":"Geometry/geography column on target_table that the predicate is evaluated against"},"name":{"type":"string","description":"Relation name (stable, snake_case). Becomes the generated filter field name in GraphQL (e.g. nearby_clinic). Unique per (source_table_id, name) — idempotency key."},"operator":{"type":"string","enum":["st_contains","st_within","st_intersects","st_covers","st_coveredby","st_overlaps","st_touches","st_dwithin"],"description":"PostGIS spatial predicate. One of the 8 whitelisted operators. st_dwithin requires param_name."},"param_name":{"type":"string","description":"Parameter name for parametric operators (currently only st_dwithin, which needs a distance argument). Must be NULL for all other operators. Enforced by table CHECK."},"source_field":{"type":"string"},"target_field":{"type":"string"}},"required":["source_field","target_field"]}}]},"BlueprintStorageConfig":{"type":"object","properties":{"scope":{"enum":["app","org"],"description":"Storage scope. \"app\" (default) creates app-level storage (no owner_id). \"org\" creates per-org/user storage (owner_id = org entity id, buckets seeded per-entity via AFTER INSERT trigger). Only \"app\" and \"org\" are allowed — child entity types get storage via entity_types[].storage."},"key":{"type":"string","description":"Module key discriminator. Defaults to \"default\" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_buckets. Max 16 chars, lowercase snake_case."},"storage_key":{"type":"string","description":"@deprecated Use `key` instead. Kept for backward compatibility."},"buckets":{"type":"array","items":{"$ref":"#/$defs/BlueprintBucketSeed"},"description":"Initial bucket seed entries. Each creates a row in {prefix}_buckets during provisioning."},"upload_url_expiry_seconds":{"type":"number","description":"Override for presigned upload URL expiry time in seconds."},"download_url_expiry_seconds":{"type":"number","description":"Override for presigned download URL expiry time in seconds."},"default_max_file_size":{"type":"number","description":"Default maximum file size in bytes for the storage module."},"allowed_origins":{"type":"array","items":{"type":"string"},"description":"CORS allowed origins for the storage module."},"confirm_upload_delay":{"type":"string","description":"Delay before the first upload confirmation attempt (PostgreSQL interval string, e.g. \"30 seconds\"). Defaults to \"30 seconds\"."},"staging":{"type":"boolean","description":"Provision a temporary staging bucket (type temp, tagged default-temp) that stages for the private default bucket, so uploads land there and are promoted into their destination on confirmation. Setting staging_ttl implies this. Defaults to false."},"staging_ttl":{"type":"string","description":"How long an unpromoted staged file survives before it is eligible for expiry (PostgreSQL interval string, e.g. \"24 hours\"). Implies staging. Defaults to \"24 hours\"."},"provisions":{"type":"object","properties":{"files":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"buckets":{"$ref":"#/$defs/BlueprintEntityTableProvision"}},"description":"Per-table overrides for storage tables. Each key targets a specific storage table (files, buckets) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision targeting the corresponding table. When a key includes policies[], those REPLACE the default storage policies for that table; tables without a key still get defaults."}},"description":"Storage configuration with optional scope. When used at the top level of a blueprint, the scope field controls whether storage is app-level (\"app\", default) or org-level (\"org\"). Seeds initial buckets, overrides module-level settings (expiry times, file size limits, CORS), and provides per-table provisioning overrides via provisions."},"BlueprintTable":{"type":"object","properties":{"table_name":{"type":"string","description":"The PostgreSQL table name to create. Required unless the entry carries a module reference instead."},"schema_name":{"type":"string","description":"Optional schema name (falls back to top-level default)."},"module":{"anyOf":[{"$ref":"#/$defs/BlueprintModuleTableRef"},{"$ref":"#/$defs/BlueprintModuleInstallRef"}],"description":"Attach this entry to a table an installed module generated instead of naming one, e.g. { type: \"agent\", scope: \"org\", table: \"message\" }. Mutually exclusive with table_name/schema_name. An entry carrying provisions names the install alone and leaves out table, since the provisions keys name the tables."},"provisions":{"type":"object","additionalProperties":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"description":"Provision security onto the tables the referenced module generated, keyed by the module's own table keys (e.g. { registries: { policies: [...] } } for an image module). Requires a module reference without \"table\", since the keys name the tables. Each entry takes ownership of the security it declares: the grants/policies given become that table's whole set, replacing what the module installed — unlike this entry's own policies[]/grants[], which layer onto one table."},"nodes":{"type":"array","items":{"$ref":"#/$defs/BlueprintNode"},"description":"Array of node type entries that define the table's behavior. Omitted by an entry that only carries provisions or only attaches policies to a module table."},"fields":{"type":"array","items":{"$ref":"#/$defs/BlueprintField"},"description":"Custom fields (columns) to add to the table."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policies for this table."},"grants":{"type":"array","items":{"$ref":"#/$defs/shared-bc381c03de"},"description":"Unified grant objects. Each entry is { roles: string[], privileges: unknown[] } where privileges are [verb, columns] tuples (e.g. [[\"select\",\"*\"]]). Enables per-role targeting. Defaults to []."},"use_rls":{"type":"boolean","description":"Whether to enable RLS on this table. Defaults to true."},"indexes":{"type":"array","items":{"$ref":"#/$defs/BlueprintTableIndex"},"description":"Table-level indexes (table_name inherited from parent)."},"full_text_searches":{"type":"array","items":{"$ref":"#/$defs/BlueprintTableFullTextSearch"},"description":"Table-level full-text search configurations (table_name inherited from parent)."},"unique_constraints":{"type":"array","items":{"$ref":"#/$defs/BlueprintTableUniqueConstraint"},"description":"Table-level unique constraints (table_name inherited from parent)."},"check_constraints":{"type":"array","items":{"$ref":"#/$defs/BlueprintTableCheckConstraint"},"description":"Table-level CHECK constraints (table_name inherited from parent)."}},"description":"A table definition within a blueprint."},"BlueprintTableCheckConstraint":{"type":"object","properties":{"$type":{"enum":["CheckOneOf","CheckGreaterThan","CheckLessThan","CheckNotEqual"]}},"required":["$type"],"allOf":[{"if":{"$ref":"#/$defs/shared-078ee82414"},"then":{"type":"object","properties":{"$type":{"const":"CheckOneOf"},"name":{"$ref":"#/$defs/shared-757c15800e"},"data":{"$ref":"#/$defs/CheckOneOfParams","description":"The check node's parameters."},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["$type","name","data"]}},{"if":{"$ref":"#/$defs/shared-2c20767ba3"},"then":{"type":"object","properties":{"$type":{"const":"CheckGreaterThan"},"name":{"$ref":"#/$defs/shared-757c15800e"},"data":{"$ref":"#/$defs/CheckGreaterThanParams","description":"The check node's parameters."},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["$type","name","data"]}},{"if":{"$ref":"#/$defs/shared-8358853df2"},"then":{"type":"object","properties":{"$type":{"const":"CheckLessThan"},"name":{"$ref":"#/$defs/shared-757c15800e"},"data":{"$ref":"#/$defs/CheckLessThanParams","description":"The check node's parameters."},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["$type","name","data"]}},{"if":{"$ref":"#/$defs/shared-1c8d46d43b"},"then":{"type":"object","properties":{"$type":{"const":"CheckNotEqual"},"name":{"$ref":"#/$defs/shared-757c15800e"},"data":{"$ref":"#/$defs/CheckNotEqualParams","description":"The check node's parameters."},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["$type","name","data"]}}],"description":"A CHECK constraint nested inside a table definition (table_name not required)."},"BlueprintTableFullTextSearch":{"type":"object","properties":{"field":{"$ref":"#/$defs/shared-ee69c55731"},"sources":{"$ref":"#/$defs/shared-626b0c3c0b"},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["field","sources"],"description":"A full-text search configuration nested inside a table definition (table_name not required)."},"BlueprintTableIndex":{"type":"object","properties":{"column":{"$ref":"#/$defs/shared-0a22d2c3f6"},"columns":{"$ref":"#/$defs/shared-5a2832df1c"},"access_method":{"$ref":"#/$defs/shared-2a834ba4ff"},"is_unique":{"$ref":"#/$defs/shared-bb55f34041"},"name":{"$ref":"#/$defs/shared-f35a015b21"},"op_classes":{"$ref":"#/$defs/shared-22f38cc906"},"options":{"$ref":"#/$defs/shared-e772a2f2a5"},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["access_method"],"description":"An index definition nested inside a table definition (table_name not required)."},"BlueprintTableUniqueConstraint":{"type":"object","properties":{"columns":{"$ref":"#/$defs/shared-a0bfcadf85"},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["columns"],"description":"A unique constraint nested inside a table definition (table_name not required)."},"BlueprintUniqueConstraint":{"type":"object","properties":{"table_name":{"type":"string","description":"Table name this unique constraint belongs to."},"schema_name":{"$ref":"#/$defs/shared-6adc1df48e"},"columns":{"$ref":"#/$defs/shared-a0bfcadf85"}},"required":["table_name","columns"],"description":"A unique constraint definition within a blueprint (top-level, requires table_name)."},"CheckGreaterThanParams":{"type":"object","properties":{"column":{"$ref":"#/$defs/shared-33af0ede37"},"value":{"type":"number","description":"Threshold value for single-column comparison (column > value)","default":0},"columns":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Two columns for cross-column comparison (columns[0] > columns[1])","minItems":2,"maxItems":2}},"description":"Adds a CHECK constraint that validates a column value is greater than a threshold (single-column: column > value) or that one column is greater than another (cross-column: columns[0] > columns[1]). Compiled via AST helpers."},"CheckLessThanParams":{"type":"object","properties":{"column":{"$ref":"#/$defs/shared-33af0ede37"},"value":{"type":"number","description":"Threshold value for single-column comparison (column < value)"},"columns":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Two columns for cross-column comparison (columns[0] < columns[1])","minItems":2,"maxItems":2}},"description":"Adds a CHECK constraint that validates a column value is less than a threshold (single-column: column < value) or that one column is less than another (cross-column: columns[0] < columns[1]). Compiled via AST helpers."},"CheckNotEqualParams":{"type":"object","properties":{"columns":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Two columns that must not be equal","minItems":2,"maxItems":2}},"required":["columns"],"description":"Adds a CHECK constraint that validates two columns are not equal (columns[0] != columns[1]). Useful for preventing self-referencing rows. Compiled via AST helpers."},"CheckOneOfParams":{"type":"object","properties":{"column":{"type":"string","format":"column-ref","description":"Column to validate against the allowed values"},"values":{"type":"array","items":{"type":"string"},"description":"Array of allowed values for the column"}},"required":["column","values"],"description":"Adds a CHECK constraint that validates a column value is one of an allowed set (e.g. tier IN ('free', 'paid', 'custom')). Compiled to column = ANY(ARRAY[...]) via AST helpers."},"CheckOwnedRelationParams":{"type":"object","properties":{"link_schema_name":{"type":"string","description":"Schema holding the link tables the ownership is proven through"},"owner_scope":{"type":"string","description":"Scope that owns the referencing rows; matched against the link row's owner_scope (e.g. database, platform)"},"owner_key_field_name":{"type":"string","format":"column-ref","description":"Column on the referencing table carrying its scope key, matched against the link row's owner_key. NULL for a global scope, whose owner key is NULL by construction"},"pointers":{"type":"array","description":"Typed pointer columns to guard, each resolved through its own link table","items":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Pointer column on the referencing table"},"link_table_name":{"type":"string","description":"Link table in link_schema_name whose ids this column points at"},"target_type_field_name":{"type":"string","description":"Optional link column additionally restricted regardless of ownership (e.g. a bucket type)"},"target_type_value":{"type":"string","description":"Value target_type_field_name must equal"},"allow_owner_tier":{"type":"boolean","description":"Admit the same database's global-scope rows (app/platform, ownerless by construction) for this column, for pointers whose legal target set is a scope hierarchy within one database","default":false}},"required":["field_name","link_table_name"]}},"arity":{"type":"string","enum":["exactly_one","all","any"],"description":"How many pointers a row must set: exactly_one for a polymorphic target (route → api OR site OR bucket), all for a junction/join row of a has-and-belongs-to-many relation (and for a mandatory belongs-to), any for optional pointers that are only checked when set","default":"exactly_one"},"required_error":{"type":"string","description":"Error code raised when the arity rule over the pointers is violated","default":"OWNED_RELATION_TARGET_REQUIRED"},"denied_error":{"type":"string","description":"Error code raised when the target is not owned by the referencing row owner","default":"OWNED_RELATION_TARGET_NOT_OWNED"},"trigger_function_schema":{"type":"string","description":"Schema the guard trigger function is created in; defaults to the table schema"},"trigger_function_name":{"type":"string","description":"Guard trigger function name; defaults to tg__owned_relation_guard"},"trigger_name":{"type":"string","description":"Guard trigger name; defaults to
_owned_relation_guard"}},"required":["link_schema_name","owner_scope","pointers"],"description":"Declares that typed pointer columns may only reference rows owned by the same scope owner as the referencing row, proven through a link table that carries the owner (owner_scope, owner_key) — typically a catalog projection that must never be referenced structurally. Creates one BEFORE INSERT OR UPDATE trigger enforcing the declared arity over the pointers and requiring every pointer that is set to resolve to a same-owner row, so it covers belongs-to / has-one / has-many (key on the row being written) and has-and-belongs-to-many (both keys on the junction row, arity all). Visibility/publication flags are never an authorization input."},"DataArchivableParams":{"type":"object","properties":{"is_archived_field":{"type":"string","format":"column-ref","description":"Column name for the archive boolean flag","default":"is_archived"},"archived_at_field":{"type":"string","format":"column-ref","description":"Column name for the archive timestamp","default":"archived_at"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true}},"description":"Adds user-reversible archive support with is_archived boolean and archived_at timestamp, plus a partial index for efficient active-row queries."},"DataBulkParams":{"type":"object","properties":{"insert":{"type":"boolean","description":"Enable bulk insert (+bulkInsert)","default":true},"upsert":{"type":"boolean","description":"Enable bulk upsert (+bulkUpsert)","default":false},"update":{"type":"boolean","description":"Enable bulk update (+bulkUpdate)","default":false},"delete":{"type":"boolean","description":"Enable bulk delete (+bulkDelete)","default":false}},"description":"Enables bulk mutation smart tags on a table. When provisioned, adds @behavior tags for the selected bulk operations (insert, upsert, update, delete). Requires the graphile-bulk-mutations plugin."},"DataCapabilitiesParams":{"type":"object","properties":{"field":{"type":"string","format":"column-ref","description":"Name of the bit(n) mask column to create on this table.","default":"required_capabilities"},"capabilities":{"type":"string","description":"Selects the capabilities module whose bit numbering the mask is measured in, by scope (e.g. \"app\", \"org\") or by table prefix. Required only when the database has more than one; several with no selector raises naming the candidates."},"default":{"type":"array","items":{"type":"string"},"description":"Capability names every row requires unless told otherwise, resolved to a literal mask and baked into the column default. Omitted means a zero mask: requires nothing."},"mode":{"type":"string","enum":["direct","derived"],"description":"Who writes the mask: \"direct\" the writer, bounded by the subset guard; \"derived\" the mapping row named by from_column, stamped by generated triggers and hidden from mutations.","default":"direct"},"from_column":{"type":"string","format":"column-ref","description":"Derived mode only: the column on this table naming the mapping row to copy the mask from (e.g. classification_id)."},"mapping_table":{"type":"string","description":"Derived mode only: table holding one mask per class (e.g. document_classifications)."},"mapping_key":{"type":"string","format":"column-ref","description":"Derived mode only: column on the mapping table that from_column matches.","default":"id"},"mapping_column":{"type":"string","format":"column-ref","description":"Derived mode only: the mapping table's own bit(n) mask column. Created when absent, so a classification table needs no DataCapabilities declaration of its own. Defaults to the same name as field."},"subset_guard":{"type":"boolean","description":"Direct mode only: refuse a write requiring bits the writer does not hold, so nobody can lock a row away from everyone including themselves. Off is for trusted-writer tables only.","default":true},"entity_field":{"type":"string","format":"column-ref","description":"Direct mode only: the entity column the subset guard's membership check reads.","default":"entity_id"}},"description":"Per-row required permissions. A profile compiles a person to bits so no policy joins a profiles table; this compiles a row to bits so no policy joins a grant table either — the row carries the mask an actor must hold, and an AuthzEntityMembership policy with mask_column checks it as one bitwise subset test against the SPRT. The mask only narrows: it takes access away from someone membership already lets in, and never grants access to a non-member. Zero requires nothing, which is what an unclassified row defaults to. In direct mode the writer sets the mask and the subset guard bounds it to bits the writer holds; in derived mode it is copied from a mapping row (classification -> mask) by generated triggers, so authors edit one classification instead of every document."},"DataCompositeFieldParams":{"type":"object","properties":{"target":{"type":"string","format":"column-ref","description":"Name of the derived text field to create","default":"embedding_text"},"source_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Array of source field names to concatenate into the target field"},"format":{"type":"string","enum":["labeled","plain"],"description":"Output format: 'labeled' (field_name: value) or 'plain' (values only)","default":"labeled"}},"required":["source_fields"],"description":"Creates a derived text field that automatically concatenates multiple source fields via BEFORE INSERT/UPDATE triggers. Used to produce a unified text representation (e.g., embedding_text) from multiple columns on a table. The trigger fires with '_000' prefix to run before Search* triggers alphabetically."},"DataDenormalizedParams":{"type":"object","properties":{"field":{"type":"string","format":"column-ref","description":"FK field on this table that references the parent row (e.g. view_id)"},"set_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names on this table to be populated from the parent (e.g. [\"database_id\"])"},"ref_field":{"type":"string","format":"column-ref","description":"Field on the parent table that is the FK target (e.g. id)"},"ref_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names on the parent table to copy from (e.g. [\"database_id\"])"},"use_updates":{"type":"boolean","description":"If true, also creates an UPDATE trigger so changes to the FK re-copy values","default":true},"update_defaults":{"type":"boolean","description":"If true, sets the default value of set_fields to uuid_nil() so they are populated by the trigger","default":true},"func_name":{"type":"string","description":"Custom function name suffix (defaults to the FK field name)"},"func_order":{"type":"integer","description":"Trigger ordering (0-padded). Lower numbers fire first","default":0}},"required":["field","set_fields","ref_field","ref_fields"],"description":"Creates INSERT and UPDATE triggers that copy field values from a referenced (parent) table into the current table whenever the FK changes. Used to denormalize frequently-read columns (e.g. database_id on junction tables) so that RLS and queries can filter locally without joining."},"DataDirectOwnerParams":{"type":"object","properties":{"owner_field_name":{"type":"string","format":"column-ref","description":"Column name for owner ID","default":"owner_id"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds a foreign key constraint from owner_id to the users table","default":true},"create_index":{"type":"boolean","description":"If true, creates a B-tree index on the owner column","default":true}},"description":"Adds ownership column for direct user ownership. Enables AuthzDirectOwner authorization."},"DataEntityMembershipParams":{"type":"object","properties":{"entity_field_name":{"type":"string","format":"column-ref","description":"Column name for entity ID","default":"entity_id"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds a foreign key constraint from entity_id to the users table","default":true},"create_index":{"type":"boolean","description":"If true, creates a B-tree index on the entity column","default":true}},"description":"Adds entity reference for organization/group scoping. Enables AuthzEntityMembership, AuthzMembership, AuthzOrgHierarchy authorization."},"DataForceCurrentUserParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the field to force to current_user_id()","default":"actor_id"}},"description":"BEFORE INSERT trigger that forces a field to the value of jwt_public.current_user_id(). Prevents clients from spoofing the actor/uploader identity. The field value is always overwritten regardless of what the client provides."},"DataGeneratedParams":{"type":"object","properties":{"target":{"type":"string","format":"column-ref","description":"Name of the generated column to create"},"type":{"type":"object","description":"FieldType for the generated column (default: text)","default":{"name":"text"}},"kind":{"type":"string","enum":["expression","concat","slug","object_name","hash"],"description":"Preset for building the generation expression","default":"expression"},"generation_type":{"type":"string","enum":["stored","virtual"],"description":"Whether the column is STORED (persisted on write) or VIRTUAL (computed on read, PostgreSQL 18+)","default":"stored"},"source_field":{"type":"string","format":"column-ref","description":"Single source field for expression/slug/object_name presets"},"source_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Array of source field names for concat/hash presets"},"expression":{"type":"object","description":"Raw FieldGeneration DSL or AST (used when kind is expression)"},"separator":{"type":"string","description":"Separator used by concat preset","default":" "},"format":{"type":"string","enum":["labeled","plain"],"description":"Output format for concat preset: 'labeled' (field_name: value) or 'plain' (values only)","default":"plain"},"prefix":{"type":"string","description":"Optional prefix for object_name preset"},"suffix":{"type":"string","description":"Optional suffix for object_name preset"},"algorithm":{"type":"string","description":"Hash algorithm for hash preset (e.g. sha256, md5)","default":"sha256"},"is_required":{"type":"boolean","description":"Whether the generated column is NOT NULL","default":false}},"required":["target"],"description":"Creates a native PostgreSQL GENERATED ALWAYS AS (expr) column (STORED or VIRTUAL) from a source field expression, preset, or raw AST. The column is read-only for clients and computed automatically by PostgreSQL."},"DataHistoryParams":{"type":"object","properties":{"table_suffix":{"type":"string","description":"Suffix for the history table name","default":"_history"},"recorded_at_field":{"type":"string","format":"column-ref","description":"Column name for the version timestamp (also the partition key when partitioned)","default":"recorded_at"},"operation_field":{"type":"string","format":"column-ref","description":"Column name recording the operation ('INSERT' | 'UPDATE' | 'DELETE')","default":"history_op"},"exclude_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Source columns to omit from the history table (e.g. large jsonb or vector columns). Excluded columns are never created on the history table and never written by the trigger.","default":[]},"copy_mutation_policies":{"type":"boolean","description":"Whether to also clone INSERT/UPDATE/DELETE policies (not just SELECT). Default false — the history table is written only by the trigger and exposed read-only through GraphQL.","default":false},"partitioned":{"type":"boolean","description":"When true, range-partition the history table by recorded_at via pg_partman so old partitions can be dropped per the retention window.","default":false},"partition_interval":{"type":"string","description":"pg_partman partition interval (when partitioned)","default":"1 month"},"retention":{"type":"string","description":"pg_partman retention window; partitions older than this are dropped by run_maintenance (when partitioned). Empty keeps forever.","default":"12 months"},"premake":{"type":"integer","description":"Number of future partitions pg_partman pre-creates","default":2}},"description":"Creates a companion
_history table that records a new version row on every INSERT/UPDATE/DELETE via an AFTER trigger. The history table copies the source columns as plain nullable columns with NO keys or constraints, plus a recorded_at timestamp and a history_op column (NEW-append: INSERT/UPDATE store the new row, DELETE stores a tombstone). SELECT policies are cloned from the base table. Optionally range-partitions the history table by recorded_at (pg_partman) with a retention window so history is kept for a while but not forever. Adds an @history smart comment so the Graphile history plugin can expose version queries and restore mutations."},"DataI18nParams":{"type":"object","properties":{"fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names on the base table to make translatable. Each field is duplicated on the translation table with the same type."},"table_suffix":{"type":"string","description":"Suffix for the translation table name","default":"_translations"},"lang_code_type":{"type":"string","enum":["citext","text"],"description":"Type for the lang_code column","default":"citext"},"copy_mutation_policies":{"type":"boolean","description":"Whether to also copy INSERT/UPDATE/DELETE policies (not just SELECT). Default true — translations should be editable by the same users who can edit the base row.","default":true},"search":{"type":"object","description":"SearchFullText configuration for the translations table. When provided, creates a tsvector column on the translations table with lang_column=lang_code for dynamic per-row language stemming.","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the tsvector column on the translations table","default":"search"},"source_fields":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string","format":"column-ref","description":"Name of the translatable source column"},"weight":{"type":"string","enum":["A","B","C","D"],"description":"tsvector weight class (A=highest, D=lowest)","default":"D"}},"required":["field"]},"description":"Translatable columns that feed the tsvector. Language is determined dynamically from the lang_code column of each row."},"search_score_weight":{"type":"number","description":"Weight for this algorithm in composite searchScore","default":1}},"required":["source_fields"]}},"required":["fields"],"description":"Creates a companion _translations table with lang_code + translatable fields. Copies SELECT policies and column-ref fields from the base table. Adds @i18n smart comment so the Graphile i18n plugin discovers it. Requires i18n_module to be provisioned for the database."},"DataIdParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Column name for the primary key","default":"id"}},"description":"Adds a UUID primary key column with auto-generation default (uuidv7). This is the standard primary key pattern for all tables."},"DataIdentityParams":{"type":"object","properties":{"target":{"type":"string","format":"column-ref","description":"Name of the identity column to create"},"type":{"type":"object","description":"FieldType for the identity column (default: bigint)","default":{"name":"bigint"}},"generation":{"type":"string","enum":["always","by_default"],"description":"'always' for GENERATED ALWAYS AS IDENTITY, 'by_default' for GENERATED BY DEFAULT AS IDENTITY","default":"by_default"},"sequence":{"type":"object","description":"Optional sequence tuning for the backing identity sequence","properties":{"start":{"type":"integer","description":"START WITH value"},"increment":{"type":"integer","description":"INCREMENT BY value"},"min":{"type":["integer","null"],"description":"MINVALUE (null uses the default)"},"max":{"type":["integer","null"],"description":"MAXVALUE (null uses the default)"},"cache":{"type":"integer","description":"CACHE value"},"cycle":{"type":"boolean","description":"Whether the sequence cycles (CYCLE / NO CYCLE)"}}},"is_required":{"type":"boolean","description":"Whether the identity column is NOT NULL (identity columns are implicitly NOT NULL)","default":false}},"required":["target"],"description":"Creates a native PostgreSQL identity column (GENERATED ALWAYS / BY DEFAULT AS IDENTITY) backed by an implicit sequence. The database assigns values automatically; ALWAYS identity columns are not writable by clients."},"DataImmutableFieldsParams":{"type":"object","properties":{"fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names that cannot be modified after INSERT (e.g. [\"key\", \"bucket_id\", \"owner_id\"])"}},"required":["fields"],"description":"BEFORE UPDATE trigger that prevents changes to a list of specified fields after INSERT. Raises an exception if any of the listed fields have changed. Unlike FieldImmutable (single-field), this handles multiple fields in a single trigger for efficiency."},"DataInflectionParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the field to transform"},"ops":{"type":"array","items":{"type":"string","enum":["plural","singular","camel","pascal","dashed","slugify","underscore","lower","upper"]},"description":"Inflection operations to apply in order"}},"required":["field_name","ops"],"description":"Transforms field values using inflection operations (snake_case, camelCase, slugify, plural, singular, etc). Attaches BEFORE INSERT and BEFORE UPDATE triggers. References fields by name in data jsonb."},"DataInheritFromParentParams":{"type":"object","properties":{"parent_fk_field":{"type":"string","format":"column-ref","description":"Name of the FK field on this table that references the parent (e.g. bucket_id)"},"fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names to copy from the parent row (e.g. [\"owner_id\", \"is_public\"])"},"parent_table":{"type":"string","description":"Parent table name (optional fallback if FK not yet registered in metaschema)"},"parent_schema":{"type":"string","description":"Parent table schema (optional, defaults to same schema as child table)"}},"required":["parent_fk_field","fields"],"description":"BEFORE INSERT trigger that copies specified fields from a parent table via a foreign key. The parent row is looked up through RLS (SECURITY INVOKER), so the insert fails if the caller cannot see the parent. Used by the storage module to inherit owner_id and is_public from buckets to files."},"DataJsonbParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Column name for the JSONB field","default":"metadata"},"default_value":{"$ref":"#/$defs/FieldDefault","description":"Default value as a FieldDefault object"},"is_required":{"type":"boolean","description":"Whether the column has a NOT NULL constraint","default":false},"create_index":{"type":"boolean","description":"Whether to create a GIN index","default":true}},"description":"Adds a JSONB column with optional GIN index for containment queries (@>, ?, ?|, ?&). Standard pattern for semi-structured metadata."},"DataLockParams":{"type":"object","properties":{"lock_field":{"type":"string","format":"column-ref","description":"Boolean column holding the lock state","default":"locked"},"events":{"type":"array","items":{"type":"string","enum":["UPDATE","DELETE"]},"description":"Which DML events are guarded while the row is locked. INSERT is not lockable — a row cannot be locked before it exists.","default":["DELETE"]},"enforcement":{"type":"string","enum":["step_up","block"],"description":"How a guarded verb is stopped while locked. step_up requires recent strong verification (needs a provisioned user_auth_module); block refuses the verb outright with ROW_LOCKED until unlocked.","default":"step_up"},"step_up_type":{"type":"string","enum":["password","mfa","fresh_auth","password_or_mfa"],"description":"Verification method satisfying the step-up requirement, for the guarded verbs in step_up mode and for clearing the lock","default":"fresh_auth"},"guard_unlock":{"type":"boolean","description":"Require step-up to change the lock column itself, so a locked row cannot be quietly unlocked and then deleted. Redundant (and therefore skipped) in step_up mode when UPDATE is already guarded.","default":true},"protect_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"For a guarded UPDATE, restrict the guard to changes touching these columns. Empty guards the whole row.","default":[]},"default_locked":{"type":"boolean","description":"Initial value of the lock column for new rows","default":false},"min_age":{"type":"string","description":"Optional interval (e.g. \"24 hours\"); in step_up mode the guard only fires for rows older than this, so freshly created rows stay easy to clean up. Empty guards rows of any age.","default":""}},"description":"Adds a boolean lock column and guards mutations while a row is locked, so infrastructure rows other things depend on (a bucket a function needs, a route, a resource) are not deleted or edited by accident. Two enforcement modes: step_up requires recent strong verification (via GuardStepUp / require_step_up) for the guarded verbs, while block refuses them outright until the row is unlocked. Clearing the lock is itself step-up guarded, so unlocking is a deliberate, re-authenticated step rather than a silent prelude to deletion."},"DataMemberOwnerParams":{"type":"object","properties":{"owner_field_name":{"type":"string","format":"column-ref","description":"Column name for the owner reference","default":"owner_id"},"entity_field_name":{"type":"string","format":"column-ref","description":"Column name for the entity reference","default":"entity_id"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds foreign key constraints from owner_id and entity_id to the users table","default":true},"create_index":{"type":"boolean","description":"If true, creates B-tree indexes on the owner and entity columns","default":true},"entity_type":{"type":"string","description":"Scope name for SPRT resolution (e.g. 'org', 'room'). Resolved to a membership type via the database's membership_types_module. This is the authoring form — use it instead of membership_type."},"membership_type":{"type":"integer","description":"Resolved membership type for SPRT resolution. Internal: prefer entity_type. Cannot be combined with entity_type.","default":null}},"description":"Adds owner_id and entity_id columns with a compound AuthzMemberOwner policy. The actor must own the row (owner_id = current_user_id()) AND be a member of the entity (entity_id in SPRT). Use for private data within an entity scope — e.g., personal chat threads that belong to the company but only the author can see."},"DataOwnedFieldsParams":{"type":"object","properties":{"role_key_field_name":{"type":"string","format":"column-ref","description":"Name of the field identifying the owner (e.g. sender_id)"},"protected_field_names":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Names of fields only this owner can modify"}},"required":["role_key_field_name","protected_field_names"],"description":"Restricts which user can modify specific columns in shared objects. Creates an AFTER UPDATE trigger that throws OWNED_PROPS when a non-owner tries to change protected fields. References fields by name in data jsonb."},"DataOwnershipInEntityParams":{"type":"object","properties":{"owner_field_name":{"type":"string","format":"column-ref","description":"Column name for the owner reference","default":"owner_id"},"entity_field_name":{"type":"string","format":"column-ref","description":"Column name for the entity reference","default":"entity_id"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds foreign key constraints from owner_id and entity_id to the users table","default":true},"create_index":{"type":"boolean","description":"If true, creates B-tree indexes on the owner and entity columns","default":true}},"description":"Combines direct ownership with entity scoping. Adds both owner_id and entity_id columns. Enables AuthzDirectOwner, AuthzEntityMembership, and AuthzOrgHierarchy authorization. Particularly useful for OrgHierarchy where a user owns a row (owner_id) within an entity (entity_id), and managers above can see subordinate-owned records via the hierarchy closure table."},"DataPeoplestampsParams":{"type":"object","properties":{"created_by_field":{"type":"string","format":"column-ref","description":"Column name for the creating user reference","default":"created_by"},"updated_by_field":{"type":"string","format":"column-ref","description":"Column name for the last-updating user reference","default":"updated_by"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds foreign key constraints from created_by and updated_by to the users table","default":false},"create_index":{"type":"boolean","description":"If true, creates B-tree indexes on the peoplestamp columns","default":true}},"description":"Adds human actor tracking for creates/updates: created_by/updated_by record the human user (jwt_public.current_user_id())."},"DataPrincipalstampsParams":{"type":"object","properties":{"created_by_principal_field":{"type":"string","format":"column-ref","description":"Column name for the creating principal reference (agent, API key, or user)","default":"created_by_principal"},"updated_by_principal_field":{"type":"string","format":"column-ref","description":"Column name for the last-updating principal reference (agent, API key, or user)","default":"updated_by_principal"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"create_index":{"type":"boolean","description":"If true, creates B-tree indexes on the principalstamp columns","default":true}},"description":"Adds acting-principal tracking for creates/updates: created_by_principal/updated_by_principal record the acting principal — agent, API key, service identity, or the user itself (jwt_public.current_principal_id())."},"DataPublishableParams":{"type":"object","properties":{"is_published_field_name":{"type":"string","format":"column-ref","description":"Column name for the published boolean flag","default":"is_published"},"published_at_field_name":{"type":"string","format":"column-ref","description":"Column name for the publish timestamp","default":"published_at"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true}},"description":"Adds publish state columns (is_published, published_at) for content visibility. Enables AuthzPublishable and AuthzTemporal authorization."},"DataRealtimeParams":{"type":"object","properties":{"operations":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"Which DML operations to track with emit_change triggers","default":["INSERT","UPDATE","DELETE"]},"subscriber_table_name":{"type":"string","description":"Custom name for the subscriber table (defaults to {source_table}_subscriber)"},"ephemeral":{"type":"boolean","description":"When true, events are delivered via pg_notify only without writing to change_log. Ideal for high-frequency ephemeral signals (e.g. cursor positions, live indicators) where persistence is unnecessary. Subscriber table and RLS policies are still created for access control.","default":false}},"description":"Creates per-table subscriber tables in subscriptions_public with RLS policies derived from source table SELECT policies. Attaches statement-level triggers to emit changes to subscribers."},"DataSlugParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the field to slugify","default":"slug"},"source_field_name":{"type":"string","format":"column-ref","description":"Optional source field name (defaults to field_name)"}},"required":[],"description":"Auto-generates URL-friendly slugs from field values on insert/update. Attaches BEFORE INSERT and BEFORE UPDATE triggers that call inflection.slugify() on the target field. References fields by name in data jsonb."},"DataSoftDeleteParams":{"type":"object","properties":{"deleted_at_field":{"type":"string","format":"column-ref","description":"Column name for the soft-delete timestamp","default":"deleted_at"},"is_deleted_field":{"type":"string","format":"column-ref","description":"Column name for the soft-delete boolean flag","default":"is_deleted"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true}},"description":"Adds soft delete support with deleted_at and is_deleted columns."},"DataStatusFieldParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Column name for the status field","default":"status"},"type":{"$ref":"#/$defs/FieldType","description":"Column type as a FieldType object"},"default_value":{"type":"string","description":"Default value expression (e.g., active)"},"is_required":{"type":"boolean","description":"Whether the column has a NOT NULL constraint","default":true},"allowed_values":{"type":"array","items":{"type":"string"},"description":"If provided, creates a CHECK constraint restricting the column to these values"}},"description":"Adds a status column with B-tree index for efficient equality filtering and sorting. Optionally constrains values via CHECK constraint when allowed_values is provided."},"DataTagsParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Column name for the tags array","default":"tags"},"default_value":{"$ref":"#/$defs/FieldDefault","description":"Default value as a FieldDefault object"},"is_required":{"type":"boolean","description":"Whether the column has a NOT NULL constraint","default":false}},"description":"Adds a citext[] tags column with GIN index for efficient array containment queries (@>, &&). Standard tagging pattern for categorization and filtering."},"DataTimestampsParams":{"type":"object","properties":{"created_at_field":{"type":"string","format":"column-ref","description":"Column name for the creation timestamp","default":"created_at"},"updated_at_field":{"type":"string","format":"column-ref","description":"Column name for the last-updated timestamp","default":"updated_at"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true}},"description":"Adds automatic timestamp tracking with created_at and updated_at columns."},"EventReferralParams":{"type":"object","properties":{"event_name":{"type":"string","description":"Event type name to record for the referrer (e.g., \"invitee_uploaded_avatar\", \"invitee_completed_onboarding\")"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"DML events that trigger recording","default":["INSERT"]},"actor_field":{"type":"string","format":"column-ref","description":"Column containing the invitee (actor) ID on the source table — used to look up the referrer via claimed_invites.receiver_id","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","description":"Column containing the entity ID (org/group) for entity-scoped referral events. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup. Omit for user-only events."},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"max_depth":{"type":"integer","description":"Maximum depth to walk up the invite chain. Default 1 (direct inviter only). Set 2–10 to enable multi-level referral rewards. App-level only — must not be combined with entity_field.","default":1,"minimum":1,"maximum":10},"auto_register_type":{"type":"boolean","description":"Automatically register the event_name in event_types during provisioning","default":true},"condition_field":{"$ref":"#/$defs/shared-88656ecafa"},"condition_value":{"$ref":"#/$defs/shared-f7ad90b1e2"},"conditions":{"$ref":"#/$defs/shared-cc52e308f2"},"watch_fields":{"$ref":"#/$defs/shared-fe3f452ee5"}},"required":["event_name"],"description":"Creates triggers that record events for the referrer (inviter) when their invitees perform actions on a watched table. Resolves the referrer automatically via the invites module's claimed_invites table using the membership_type context. Supports the same compound condition system as EventTracker. Use with achievements to unlock levels and grant credits based on invitee activity."},"EventTrackerParams":{"type":"object","properties":{"event_name":{"type":"string","description":"Event type name to record (e.g., \"avatar_uploaded\", \"order_completed\")"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"DML events that trigger recording","default":["INSERT"]},"count":{"type":"integer","description":"Number of events to record per trigger fire","default":1},"toggle":{"type":"boolean","description":"Toggle mode: records event when condition is met, removes when condition is unmet","default":false},"actor_field":{"type":"string","format":"column-ref","description":"Column containing the actor (user) ID to attribute the event to","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","description":"Column containing the entity ID (org/group) for entity-scoped events. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup. Omit for user-only events."},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"auto_register_type":{"type":"boolean","description":"Automatically register the event_name in event_types during provisioning","default":true},"condition_field":{"$ref":"#/$defs/shared-88656ecafa"},"condition_value":{"$ref":"#/$defs/shared-f7ad90b1e2"},"conditions":{"$ref":"#/$defs/shared-cc52e308f2"},"watch_fields":{"$ref":"#/$defs/shared-fe3f452ee5"}},"required":["event_name"],"description":"Creates triggers that record events via the events module when table rows change. Supports the same compound condition system as JobTrigger (condition_field, watch_fields, or full AND/OR/NOT conditions). Events are recorded to app_events and aggregated automatically. Use with achievements (blueprint-level) to unlock levels and grant credits based on event accumulation."},"FieldDefault":{"type":"object","description":"A structured default expression, e.g. { value: false }, { function: \"now\" } or { value: {}, cast: { name: \"jsonb\" } }.","properties":{"value":{"description":"Literal value."},"function":{"type":"string","description":"Function name."},"schema":{"type":"string","description":"Schema qualifier of the function."},"args":{"type":"array","items":{"anyOf":[{"type":["string","number","boolean","null"]},{"$ref":"#/$defs/FieldDefault"}]},"description":"Function arguments."},"cast":{"$ref":"#/$defs/FieldType"},"operator":{"type":"string","description":"Binary operator, e.g. \"+\"."},"left":{"$ref":"#/$defs/FieldDefault"},"right":{"$ref":"#/$defs/FieldDefault"},"sql_keyword":{"type":"string","description":"SQL keyword, e.g. \"CURRENT_TIMESTAMP\"."}}},"FieldType":{"type":"object","description":"A structured PostgreSQL type, e.g. { name: \"text\" } or { name: \"numeric\", args: [10, 2] }.","properties":{"name":{"type":"string","description":"Type name."},"schema":{"type":"string","description":"Schema qualifier."},"args":{"type":"array","items":{"type":["string","number","boolean"]},"description":"Type arguments."},"array_dimensions":{"type":"integer","description":"Number of array dimensions: 1 is text[]."},"range":{"type":"array","items":{"type":"string"},"maxItems":2,"description":"Interval field range, e.g. [\"day\", \"second\"]."}},"required":["name"]},"GuardStepUpParams":{"type":"object","properties":{"step_up_type":{"type":"string","enum":["password","mfa","fresh_auth","password_or_mfa"],"description":"Which recent proof satisfies the step-up requirement: password (password re-entry), mfa (second factor), password_or_mfa (either factor; an SSO sign-in alone does not count), or fresh_auth (any recent sign-in or re-verification, including SSO, magic link and OTP)","default":"fresh_auth"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"Which DML events require step-up verification","default":["UPDATE","DELETE"]},"condition_field":{"$ref":"#/$defs/shared-88656ecafa"},"condition_value":{"$ref":"#/$defs/shared-f7ad90b1e2"},"conditions":{"$ref":"#/$defs/shared-cc52e308f2"},"watch_fields":{"$ref":"#/$defs/shared-fe3f452ee5"}},"required":[],"description":"Attaches a BEFORE trigger that calls require_step_up() to enforce recent strong verification (password, MFA, or identity-provider assertion) before allowing mutations. Requires a provisioned sessions_module (with app_settings_auth) for the target database. The step_up_window is read from app_settings_auth at runtime (default 30 minutes). Supports compound conditions (AND/OR/NOT), watch_fields (fire only when specific fields change), and simple condition_field/condition_value leaf conditions."},"JobTriggerParams":{"type":"object","properties":{"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier passed to add_job (e.g., process_invoice, sync_to_stripe). Must match a registered function definition when function_module is installed."},"payload_strategy":{"type":"string","enum":["row","row_id","fields","custom"],"description":"How to build the job payload: row (full NEW/OLD), row_id (just id), fields (selected columns), custom (mapped columns)","default":"row_id"},"payload_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Column names to include in payload (only for fields strategy)"},"payload_custom":{"type":"object","additionalProperties":{"type":"string","format":"column-ref"},"description":"Key-to-column mapping for custom payload (e.g., {\"invoice_id\": \"id\", \"total\": \"amount\"})"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"Trigger events to create","default":["INSERT","UPDATE"]},"include_old":{"type":"boolean","description":"Include OLD row in payload (for UPDATE triggers)","default":false},"include_meta":{"type":"boolean","description":"Include table/schema metadata in payload","default":false},"condition_field":{"$ref":"#/$defs/shared-88656ecafa"},"condition_value":{"$ref":"#/$defs/shared-f7ad90b1e2"},"conditions":{"$ref":"#/$defs/shared-cc52e308f2"},"watch_fields":{"$ref":"#/$defs/shared-fe3f452ee5"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the trigger table that holds (or references) the entity_id for billing scope. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup."},"entity_lookup":{"type":"object","description":"FK lookup configuration for resolving entity_id through a related table. Used when entity_field is a FK (e.g., channel_id) rather than a direct entity_id. The generator validates all fields against metaschema within the same database_id.","properties":{"obj_table":{"$ref":"#/$defs/shared-6b829f5502"},"obj_schema":{"$ref":"#/$defs/shared-11a9ffe32a"},"obj_field":{"type":"string","format":"column-ref","description":"Column on the related table that holds the entity_id (e.g., \"entity_id\"). Required."}},"required":["obj_table","obj_field"]},"job_key":{"type":"string","description":"Static job key for upsert semantics (prevents duplicate jobs)"},"queue_name":{"type":"string","description":"Job queue name for routing to specific workers"},"priority":{"type":"integer","description":"Job priority (lower = higher priority)","default":0},"run_at_delay":{"type":"string","description":"Delay before job runs as PostgreSQL interval (e.g., 30 seconds, 5 minutes)"},"max_attempts":{"type":"integer","description":"Maximum retry attempts for the job","default":25}},"required":["task_identifier"],"description":"Dynamically creates PostgreSQL triggers that enqueue jobs via app_jobs.add_job() when table rows are inserted, updated, or deleted. Supports configurable payload strategies (full row, row ID, selected fields, or custom mapping), conditional firing via WHEN clauses, watched field changes, and extended job options (queue, priority, delay, max attempts)."},"LimitEnforceAggregateParams":{"type":"object","properties":{"limit_name":{"type":"string","description":"Name of the aggregate limit to track (must match a default_limits entry, e.g. \"databases\", \"members\")"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"org\", \"data_room\", \"channel\", \"team\").","default":"org"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for aggregate limit lookup. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-6eb30390ff"},"description":"Which DML events to attach triggers for","default":["INSERT","DELETE"]}},"required":["limit_name"],"description":"Declaratively attaches aggregate limit-tracking triggers to a table. On INSERT the named limit is incremented per entity; on DELETE it is decremented. Uses org_limit_aggregates_inc/dec for per-entity (org-level) aggregate limits rather than per-user limits. Requires a provisioned limits_module for the target database."},"LimitEnforceCounterParams":{"type":"object","properties":{"limit_name":{"type":"string","description":"Name of the limit to track (must match a default_limits entry, e.g. \"projects\", \"members\")"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"app\", \"org\", \"data_room\", \"channel\", \"team\").","default":"app"},"actor_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds the actor or entity id used for limit lookup","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for entity context resolution. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup."},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-6eb30390ff"},"description":"Which DML events to attach triggers for","default":["INSERT","DELETE"]}},"required":["limit_name"],"description":"Declaratively attaches limit-tracking triggers to a table. On INSERT the named limit is incremented; on DELETE it is decremented. Requires a provisioned limits_module for the target scope."},"LimitEnforceFeatureParams":{"type":"object","properties":{"feature_name":{"type":"string","description":"Cap name representing this feature (must match a limit_caps_defaults entry with max=0 or max=1)"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"app\", \"org\", \"data_room\", \"channel\", \"team\").","default":"app"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for per-entity cap lookups (only used for org scope). For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"}},"required":["feature_name"],"description":"Gates a table behind a feature flag backed by the cap tables. Attaches a BEFORE INSERT trigger that checks whether the named feature cap value is > 0. Features are modeled as caps with max=0 (disabled) or max=1 (enabled) in limit_caps / limit_caps_defaults tables. Resolution: COALESCE(per-entity cap, scope default, 0)."},"LimitEnforceRateParams":{"type":"object","properties":{"meter_slug":{"type":"string","description":"Slug of the billing meter to check rate limits against (must match a meters table entry, e.g. \"messaging\", \"inference\")"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for rate limiting. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"actor_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds the actor id (user) for rate limiting","default":"owner_id"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Which DML events to enforce rate limits on (DELETE is excluded since it reduces load)","default":["INSERT"]}},"required":["meter_slug"],"description":"Attaches a BEFORE trigger that calls check_rate_limit() to enforce sliding-window rate limits before allowing mutations. The function checks all three scopes (entity, actor-in-entity, actor) in a single call; which scopes are actually enforced is controlled by what rows exist in rate_window_limits (plan-based config). Requires a provisioned meter_rate_limits_module and billing_module for the target database."},"LimitTrackUsageParams":{"type":"object","properties":{"meter_slug":{"type":"string","description":"Slug of the billing meter to record usage against (must match a meters table entry, e.g. \"databases\", \"seats\")"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for billing. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"quantity":{"type":"integer","description":"Units to record per event (default 1)","default":1},"events":{"type":"array","items":{"$ref":"#/$defs/shared-6eb30390ff"},"description":"Which DML events to attach triggers for","default":["INSERT","DELETE"]}},"required":["meter_slug"],"description":"Declaratively attaches billing usage-recording triggers to a table. On INSERT the named meter is incremented via record_usage; on DELETE it is decremented (reversal). On UPDATE, if the entity_field changes, the old entity is decremented and the new entity is incremented. Requires a provisioned billing_module for the target database."},"LimitWarningAggregateParams":{"type":"object","properties":{"limit_name":{"type":"string","description":"Name of the aggregate limit to watch (must match a limit_warnings.name entry, e.g. \"databases\", \"members\")"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"org\", \"data_room\", \"channel\", \"team\").","default":"org"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for aggregate limit lookup. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"}},"required":["limit_name"],"description":"Attaches an AFTER INSERT trigger that checks if the entity's aggregate usage has crossed any warning threshold configured in the limit_warnings table. If a threshold is reached for the first time, enqueues a background job (e.g. email notification). Uses limit_warning_state for one-time dedup per warning/actor/entity triple. Requires a provisioned limits_module with limit_warnings and aggregate limits enabled."},"LimitWarningCounterParams":{"type":"object","properties":{"limit_name":{"type":"string","description":"Name of the limit to watch (must match a limit_warnings.name entry, e.g. \"projects\", \"members\")"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"app\", \"org\", \"data_room\", \"channel\", \"team\").","default":"app"},"actor_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds the actor id for limit lookup","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id. When provided, entity_id is included in the job payload and dedup state. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup."},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"}},"required":["limit_name"],"description":"Attaches an AFTER INSERT trigger that checks if the actor's current usage has crossed any warning threshold configured in the limit_warnings table. If a threshold is reached for the first time, enqueues a background job (e.g. email notification). Uses limit_warning_state for one-time dedup per warning/actor pair. Requires a provisioned limits_module with limit_warnings enabled."},"LimitWarningRateParams":{"type":"object","properties":{"meter_slug":{"type":"string","description":"Slug of the billing meter to check rate limits against (must match a meters table entry)"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use for warnings and warning_state tables. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"app\", \"org\", \"data_room\", \"channel\", \"team\").","default":"app"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for rate limit lookup. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"actor_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds the actor id for rate limit lookup","default":"owner_id"}},"required":["meter_slug"],"description":"Attaches an AFTER INSERT trigger that checks if the actor's current request count in the active sliding window has crossed any warning threshold configured in the limit_warnings table. If a threshold is reached for the first time, enqueues a background job (e.g. email notification). Uses limit_warning_state for one-time dedup per warning/actor pair. Requires both a limits_module with limit_warnings enabled and a rate_limit_meters_module."},"ProcessChunksParams":{"type":"object","properties":{"content_field_name":{"type":"string","format":"column-ref","description":"Name of the text content column in the chunks table","default":"content"},"chunk_size":{"type":"integer","description":"Maximum number of characters per chunk","default":1000},"chunk_overlap":{"type":"integer","description":"Number of overlapping characters between consecutive chunks","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"description":"Strategy for splitting text into chunks","default":"paragraph"},"dimensions":{"type":"integer","description":"Vector dimensions for per-chunk embeddings","default":768},"metric":{"type":"string","enum":["cosine","l2","ip"],"description":"Distance metric for the HNSW index on chunk embeddings","default":"cosine"},"embedding_model":{"type":"string","description":"Embedding model identifier for per-chunk embeddings. When null, the worker falls back to runtime config (llm_module / env vars)."},"embedding_provider":{"$ref":"#/$defs/shared-ac9a0977fa"},"chunks_table_name":{"type":"string","description":"Override the chunks table name. Defaults to {parent_table}_chunks."},"metadata_fields":{"type":"array","items":{"type":"string"},"description":"Field names from the parent table to copy into chunk metadata"},"search_indexes":{"type":"array","items":{"$ref":"#/$defs/shared-5492e6a87c"},"description":"Text search indexes to create on the chunks content column. Omit to mirror the parent table's text search indexes. Set explicitly to override (e.g. [\"fulltext\", \"bm25\"])."},"entity_field":{"type":"string","format":"column-ref","description":"Column on the parent table that holds (or references) the entity_id for billing scope. Forwarded to the chunking job trigger."},"entity_lookup":{"type":"object","description":"FK lookup configuration for resolving entity_id through a related table. Forwarded to the chunking job trigger.","properties":{"obj_table":{"$ref":"#/$defs/shared-462d3d2412"},"obj_schema":{"$ref":"#/$defs/shared-3d0fa23a34"},"obj_field":{"$ref":"#/$defs/shared-d4553f7be9"}},"required":["obj_table","obj_field"]},"enqueue_chunking_job":{"type":"boolean","description":"Whether to create a job trigger that auto-enqueues chunking on parent INSERT/UPDATE","default":true},"chunking_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the chunking job queue","default":"embedding:chunk_record"}},"description":"Creates a chunked-embedding child table for any parent table. Provisions the chunks table with content, chunk_index, embedding vector, metadata, HNSW index, inherited RLS, and optional job trigger for automatic text splitting. Composed internally by ProcessFileEmbedding (enabled by default in extract mode) but can also be used standalone."},"ProcessExtractionParams":{"type":"object","properties":{"text_field":{"type":"string","format":"column-ref","description":"Field to store extracted text/markdown","default":"extracted_text"},"metadata_field":{"type":"string","format":"column-ref","description":"JSONB field for extraction metadata (page count, language, etc.)","default":"extracted_metadata"},"extraction_model":{"type":"string","description":"Extraction model identifier (e.g. a vision model for OCR, an LLM for structured extraction). Included in the job payload so the worker knows which model to use. When null, the worker falls back to runtime config."},"extraction_provider":{"type":"string","description":"Extraction provider name (e.g. \"ollama\", \"openai\"). When null, the worker falls back to runtime config."},"mime_patterns":{"type":"array","items":{"type":"string"},"description":"MIME type LIKE patterns to match. Multiple patterns are OR'd together. Examples: ['application/pdf', 'text/%'], ['application/vnd.openxmlformats%'].","default":["application/pdf","text/%"]},"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier for the extraction worker","default":"document:extract_file_text"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Trigger events that fire the job","default":["INSERT"]},"file_field":{"$ref":"#/$defs/shared-9af2f9702a"},"payload_custom":{"$ref":"#/$defs/shared-8cef65cfda"},"trigger_conditions":{"$ref":"#/$defs/shared-787b8adf81"},"entity_field":{"$ref":"#/$defs/shared-1a317ed066"},"entity_lookup":{"$ref":"#/$defs/shared-7edb884d72"},"queue_name":{"type":"string","description":"Job queue name for extraction tasks","default":"extraction"},"max_attempts":{"type":"integer","description":"Maximum number of retry attempts","default":5},"priority":{"type":"integer","description":"Job priority (lower = higher priority)","default":0}},"description":"Creates extraction output fields and a job trigger for file text extraction. Fires when a file is uploaded (status = 'uploaded') or on INSERT. The external worker extracts text/metadata from the file (PDF, DOCX, HTML, etc.) and writes the result back to the configured output fields. Typically used upstream of ProcessFileEmbedding or ProcessChunks."},"ProcessFileEmbeddingParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the vector embedding column","default":"embedding"},"dimensions":{"type":"integer","description":"Vector dimensions (e.g. 512 for CLIP, 768 for nomic, 1536 for ada-002)","default":768},"index_method":{"type":"string","enum":["hnsw","ivfflat"],"description":"Index type for similarity search","default":"hnsw"},"metric":{"type":"string","enum":["cosine","l2","ip"],"description":"Distance metric","default":"cosine"},"index_options":{"type":"object","description":"Index-specific options. HNSW: {m, ef_construction}. IVFFlat: {lists}.","default":{}},"embedding_model":{"type":"string","description":"Embedding model identifier (e.g. \"nomic-embed-text\", \"text-embedding-3-small\", \"clip-vit-base-patch32\"). Included in the job payload so the worker knows which model to use. When null, the worker falls back to runtime config (llm_module / env vars)."},"embedding_provider":{"$ref":"#/$defs/shared-ac9a0977fa"},"mime_patterns":{"type":"array","items":{"type":"string"},"description":"MIME type LIKE patterns to match. Multiple patterns are OR'd together. Examples: ['image/%'], ['application/pdf', 'text/%'], ['audio/%'].","default":["image/%"]},"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier for the worker. In direct mode this is the embedding worker; in extract mode this is the extraction worker.","default":"embedding:process_file_embedding"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Trigger events that fire the job","default":["INSERT"]},"file_field":{"$ref":"#/$defs/shared-9af2f9702a"},"payload_custom":{"$ref":"#/$defs/shared-8cef65cfda"},"trigger_conditions":{"$ref":"#/$defs/shared-787b8adf81"},"source_bucket":{"type":"object","description":"Typed bucket reference ({\"$ref\":\"bucket\",\"tags\":[...],\"type\":...}) for the bucket the source files live in, when it is not the record's own bucket_id (which payload_custom already carries). Stamped into the trigger payload at attach time and resolved to coordinates at dispatch.","properties":{"$ref":{"type":"string","enum":["bucket"]},"tags":{"type":"array","items":{"type":"string"}},"key":{"type":"string"},"type":{"$ref":"#/$defs/shared-f4262069e5"}},"required":["$ref"]},"variants_bucket":{"type":"object","description":"Typed bucket reference for where derived outputs (thumbnails, resized variants, extracted assets) are written. Stamped into the trigger payload at attach time and resolved to coordinates at dispatch, so the function never selects a bucket.","properties":{"$ref":{"type":"string","enum":["bucket"]},"tags":{"type":"array","items":{"type":"string"}},"key":{"type":"string"},"type":{"$ref":"#/$defs/shared-f4262069e5"}},"required":["$ref"]},"entity_field":{"$ref":"#/$defs/shared-1a317ed066"},"entity_lookup":{"$ref":"#/$defs/shared-7edb884d72"},"extraction":{"type":"object","description":"Text extraction configuration. When present, the generator creates extraction output fields on the table and configures SearchVector with source_fields + stale tracking. When absent, the node operates in direct mode (single vector per file, no text extraction).","properties":{"text_field":{"type":"string","format":"column-ref","description":"Field to store extracted text/markdown","default":"extracted_text"},"metadata_field":{"type":"string","format":"column-ref","description":"JSONB field for extraction metadata (page count, language, etc.)","default":"extracted_metadata"}}},"include_chunks":{"type":"boolean","description":"Whether to create a chunks table via ProcessChunks. Defaults to true when extraction is provided, false in direct mode. Set explicitly to override."},"chunks":{"type":"object","description":"Chunking configuration passed through to ProcessChunks. When include_chunks is true (or defaults to true in extract mode), these params configure the chunks table, embedding dimensions, strategy, etc.","default":{},"properties":{"content_field_name":{"type":"string","format":"column-ref","description":"Name of the text content column in the chunks table","default":"content"},"chunk_size":{"type":"integer","description":"Maximum number of characters per chunk","default":1000},"chunk_overlap":{"type":"integer","description":"Number of overlapping characters between consecutive chunks","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"description":"Strategy for splitting text into chunks","default":"paragraph"},"metadata_fields":{"type":"array","items":{"type":"string"},"description":"Field names from parent to copy into chunk metadata"},"search_indexes":{"type":"array","items":{"$ref":"#/$defs/shared-5492e6a87c"},"description":"Text search indexes to create on the chunks content column. Omit to mirror the parent table's text search indexes. Set explicitly to override."},"enqueue_chunking_job":{"type":"boolean","description":"Whether to auto-enqueue a chunking job on insert/update","default":true},"chunking_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the chunking job queue","default":"embedding:chunk_record"}}}},"description":"Generic, MIME-scoped embedding node for file tables. Supports two modes: direct (whole-file to single vector, e.g. CLIP for images) when extraction is omitted, or extract (file to text to chunks to per-chunk vectors) when extraction config is provided. Composes SearchVector + JobTrigger + ProcessChunks (enabled by default in extract mode) internally. Multiple instances can coexist on the same table with different MIME scopes, field names, and embedding strategies."},"ProcessImageEmbeddingParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the vector embedding column","default":"embedding"},"dimensions":{"type":"integer","description":"Vector dimensions (default 512 for CLIP-style image embeddings)","default":512},"index_method":{"type":"string","enum":["hnsw","ivfflat"],"description":"Index type for similarity search","default":"hnsw"},"metric":{"type":"string","enum":["cosine","l2","ip"],"description":"Distance metric","default":"cosine"},"index_options":{"type":"object","description":"Index-specific options. HNSW: {m, ef_construction}. IVFFlat: {lists}.","default":{}},"embedding_model":{"type":"string","description":"Embedding model identifier (e.g. \"clip-vit-base-patch32\"). Included in the job payload so the worker knows which model to use. When null, the worker falls back to runtime config (llm_module / env vars)."},"embedding_provider":{"$ref":"#/$defs/shared-ac9a0977fa"},"mime_patterns":{"type":"array","items":{"type":"string"},"description":"MIME type LIKE patterns to match. Multiple patterns are OR'd together.","default":["image/%"]},"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier for the image embedding worker","default":"embedding:process_image_embedding"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Trigger events that fire the job","default":["INSERT"]},"file_field":{"$ref":"#/$defs/shared-9af2f9702a"},"payload_custom":{"$ref":"#/$defs/shared-8cef65cfda"},"trigger_conditions":{"$ref":"#/$defs/shared-787b8adf81"},"entity_field":{"$ref":"#/$defs/shared-1a317ed066"},"entity_lookup":{"$ref":"#/$defs/shared-7edb884d72"},"extraction":{"type":"object","description":"Text extraction configuration. Forwarded to ProcessFileEmbedding. When present, enables extract mode (e.g., OCR for images).","properties":{"text_field":{"type":"string","format":"column-ref","description":"Field to store extracted text","default":"extracted_text"},"metadata_field":{"type":"string","format":"column-ref","description":"JSONB field for extraction metadata","default":"extracted_metadata"}}},"chunks":{"type":"object","description":"Chunking configuration. Forwarded to ProcessFileEmbedding. Only meaningful when extraction is also provided.","properties":{"content_field_name":{"type":"string","format":"column-ref","default":"content"},"chunk_size":{"type":"integer","default":1000},"chunk_overlap":{"type":"integer","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"default":"paragraph"},"metadata_fields":{"type":"object"},"enqueue_chunking_job":{"type":"boolean","default":true},"chunking_task_name":{"type":"string","format":"function-ref","default":"embedding:chunk_record"}}}},"description":"Image-specific preset of ProcessFileEmbedding. Delegates to ProcessFileEmbedding with image-oriented defaults: dimensions=512 (CLIP), mime_patterns=['image/%'], task_identifier='embedding:process_image_embedding', direct mode (no extraction). Accepts all ProcessFileEmbedding parameters — any overrides are forwarded through."},"ProcessImageVersionsParams":{"type":"object","required":["versions"],"properties":{"versions":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","description":"Version identifier (e.g., \"thumb\", \"preview\", \"hero\")"},"width":{"type":"integer","description":"Target width in pixels"},"height":{"type":"integer","description":"Target height in pixels"},"fit":{"type":"string","enum":["cover","contain","fill","inside","outside"],"description":"Resize fitting strategy","default":"cover"},"format":{"type":"string","enum":["jpeg","png","webp","avif"],"description":"Output image format","default":"webp"},"quality":{"type":"integer","description":"Output quality (1-100)","default":80}},"required":["name"]},"description":"Array of version definitions. Each version specifies dimensions, format, and quality for a generated image variant. Required — the blueprint must explicitly define what variants to generate.","minItems":1},"mime_patterns":{"type":"array","items":{"type":"string"},"description":"MIME type LIKE patterns to match. Defaults to all image types.","default":["image/%"]},"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier for the image processing worker","default":"image:process_image_versions"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Trigger events that fire the job","default":["INSERT"]},"file_field":{"$ref":"#/$defs/shared-9af2f9702a"},"payload_custom":{"$ref":"#/$defs/shared-8cef65cfda"},"trigger_conditions":{"$ref":"#/$defs/shared-787b8adf81"},"entity_field":{"$ref":"#/$defs/shared-1a317ed066"},"entity_lookup":{"$ref":"#/$defs/shared-7edb884d72"},"queue_name":{"type":"string","description":"Job queue name for image processing tasks","default":"image_processing"},"max_attempts":{"type":"integer","description":"Maximum number of retry attempts","default":5},"priority":{"type":"integer","description":"Job priority (lower = higher priority)","default":0}},"description":"Creates a job trigger for image variant generation. Fires when an image file is uploaded (status = 'uploaded') or on INSERT. The external worker generates resized, cropped, or reformatted versions (thumbnails, previews, WebP conversions, etc.) and stores them as new file records linked to the source image."},"SearchBm25Params":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of existing text column to index with BM25"},"text_config":{"type":"string","description":"PostgreSQL text search configuration for BM25","default":"english"},"k1":{"type":"number","description":"BM25 k1 parameter: term frequency saturation (typical: 1.2-2.0)","default":null},"b":{"type":"number","description":"BM25 b parameter: document length normalization (0=none, 1=full, typical: 0.75)","default":null},"search_score_weight":{"type":"number","description":"Weight for this algorithm in composite searchScore","default":1}},"required":["field_name"],"description":"Creates a BM25 index on an existing text column using pg_textsearch. Enables statistical relevance ranking with configurable k1 and b parameters. The BM25 index is auto-detected by graphile-search."},"SearchFullTextParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the tsvector column","default":"search"},"source_fields":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string","format":"column-ref","description":"Name of the source column"},"weight":{"type":"string","enum":["A","B","C","D"],"description":"tsvector weight class (A=highest, D=lowest)","default":"D"},"lang":{"type":"string","description":"PostgreSQL text search configuration","default":"english"}},"required":["field"]},"description":"Source columns that feed the tsvector. Each has a field name, weight (A-D), and language config."},"lang_column":{"type":"string","format":"column-ref","description":"Column name whose value determines the text search configuration per row. When set, the tsvector trigger uses NEW.::regconfig instead of a static language, enabling dynamic per-row language stemming. The per-field lang values in source_fields are used as fallback defaults for the langs array but the trigger reads from this column at runtime."},"search_score_weight":{"type":"number","description":"Weight for this algorithm in composite searchScore","default":1}},"required":["source_fields"],"description":"Adds a tsvector column with GIN index and automatic trigger population from source fields. Enables PostgreSQL full-text search with configurable weights and language support. Leverages the existing metaschema full_text_search infrastructure."},"SearchSpatialAggregateParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the aggregate geometry column on the parent table","default":"geom_aggregate"},"source_table_id":{"type":"string","format":"uuid","description":"UUID of the source (child) table containing individual geometries"},"source_geom_field":{"type":"string","format":"column-ref","description":"Name of the geometry column on the source table","default":"geom"},"source_fk_field":{"type":"string","format":"column-ref","description":"Name of the foreign key column on the source table pointing to the parent"},"aggregate_function":{"type":"string","enum":["union","collect","convex_hull","concave_hull"],"description":"PostGIS aggregation function: union (ST_Union, merges overlapping), collect (ST_Collect, groups without merging), convex_hull (smallest convex polygon), concave_hull (tighter boundary)","default":"union"},"geometry_type":{"type":"string","enum":["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection","Geometry"],"description":"Output geometry type constraint for the aggregate field","default":"MultiPolygon"},"srid":{"type":"integer","description":"Spatial Reference System Identifier (e.g. 4326 for WGS84)","default":4326},"dimension":{"type":"integer","enum":[2,3,4],"description":"Coordinate dimension (2=XY, 3=XYZ, 4=XYZM)","default":2},"use_geography":{"type":"boolean","description":"Use geography type instead of geometry","default":false},"index_method":{"type":"string","enum":["gist","spgist"],"description":"Spatial index method for the aggregate field","default":"gist"}},"required":["source_table_id","source_fk_field"],"description":"Creates a derived/materialized geometry field on the parent table that automatically aggregates geometries from a source (child) table via triggers. When child rows are inserted/updated/deleted, the parent aggregate field is recalculated using the specified PostGIS aggregation function (ST_Union, ST_Collect, ST_ConvexHull, ST_ConcaveHull). Useful for materializing spatial boundaries from collections of points or polygons."},"SearchSpatialParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the geometry/geography column","default":"geom"},"geometry_type":{"type":"string","enum":["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection","Geometry"],"description":"PostGIS geometry type constraint","default":"Point"},"srid":{"type":"integer","description":"Spatial Reference System Identifier (e.g. 4326 for WGS84)","default":4326},"dimension":{"type":"integer","enum":[2,3,4],"description":"Coordinate dimension (2=XY, 3=XYZ, 4=XYZM)","default":2},"use_geography":{"type":"boolean","description":"Use geography type instead of geometry (for geodetic calculations on the sphere)","default":false},"index_method":{"type":"string","enum":["gist","spgist"],"description":"Spatial index method","default":"gist"}},"description":"Adds a PostGIS geometry or geography column with a spatial index (GiST or SP-GiST). Supports configurable geometry types (Point, Polygon, etc.), SRID, and dimensionality. The graphile-postgis plugin auto-detects geometry/geography columns by codec type for spatial filtering (ST_Contains, ST_DWithin, bbox operators)."},"SearchTrgmParams":{"type":"object","properties":{"fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names to create trigram indexes on (fields must already exist on the table)"}},"required":["fields"],"description":"Creates GIN trigram indexes (gin_trgm_ops) on specified text/citext fields for fuzzy LIKE/ILIKE/similarity search. Adds @trgmSearch smart tag for PostGraphile integration. Fields must already exist on the table."},"SearchUnifiedParams":{"type":"object","properties":{"full_text_search":{"type":"object","description":"SearchFullText parameters. Omit to skip FTS setup.","properties":{"field_name":{"type":"string","format":"column-ref","default":"search"},"source_fields":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string","format":"column-ref"},"weight":{"type":"string","enum":["A","B","C","D"]},"lang":{"type":"string"}},"required":["field"]}},"search_score_weight":{"type":"number","default":1}}},"bm25":{"type":"object","description":"SearchBm25 parameters. Omit to skip BM25 setup.","properties":{"field_name":{"type":"string","format":"column-ref"},"text_config":{"type":"string","default":"english"},"k1":{"type":"number"},"b":{"type":"number"},"search_score_weight":{"type":"number","default":1}}},"embedding":{"type":"object","description":"SearchVector parameters. Omit to skip embedding setup.","properties":{"field_name":{"type":"string","format":"column-ref","default":"embedding"},"dimensions":{"type":"integer","default":768},"index_method":{"type":"string","enum":["hnsw","ivfflat"]},"metric":{"type":"string","enum":["cosine","l2","ip"]},"source_fields":{"type":"array","items":{"type":"string","format":"column-ref"}},"embedding_model":{"type":"string","description":"Embedding model identifier. When null, the worker falls back to runtime config."},"embedding_provider":{"type":"string","description":"Embedding provider name. When null, the worker falls back to runtime config."},"search_score_weight":{"type":"number","default":1},"chunks":{"type":"object","description":"Chunking configuration for long-text embedding. Creates an embedding_chunks record that drives automatic text splitting and per-chunk embedding. Omit to skip chunking.","properties":{"content_field_name":{"type":"string","format":"column-ref","description":"Name of the text content column in the chunks table","default":"content"},"chunk_size":{"type":"integer","description":"Maximum number of characters per chunk","default":1000},"chunk_overlap":{"type":"integer","description":"Number of overlapping characters between consecutive chunks","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"description":"Strategy for splitting text into chunks","default":"fixed"},"metadata_fields":{"$ref":"#/$defs/shared-3a33134347"},"enqueue_chunking_job":{"type":"boolean","description":"Whether to auto-enqueue a chunking job on insert/update","default":true},"chunking_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the chunking job queue","default":"embedding:chunk_record"}}}}},"embedding_text_field":{"type":"string","format":"column-ref","description":"Name of the composite text field created for embedding input","default":"embedding_text"},"composite_format":{"type":"string","enum":["labeled","plain"],"description":"Output format for the composite text field","default":"labeled"},"trgm_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names to tag with @trgmSearch for fuzzy/typo-tolerant matching"},"search_config":{"type":"object","description":"Unified search score configuration written to @searchConfig smart tag","properties":{"weights":{"type":"object","description":"Per-algorithm weights: {tsv: 1.5, bm25: 1.0, pgvector: 0.8, trgm: 0.3}"},"normalization":{"type":"string","enum":["linear","sigmoid"],"description":"Score normalization strategy","default":"linear"},"boost_recent":{"type":"boolean","description":"Enable recency boost for search results","default":false},"boost_recency_field":{"type":"string","format":"column-ref","description":"Timestamp field for recency boost (e.g. created_at, updated_at)"},"boost_recency_decay":{"type":"number","description":"Decay rate for recency boost (0-1, lower = faster decay)","default":0.5}}}},"description":"Composite node type that orchestrates multiple search modalities (full-text search, BM25, embeddings, trigram) on a single table. Configures per-table search score weights, normalization strategy, and recency boost via the @searchConfig smart tag."},"SearchVectorParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the vector column","default":"embedding"},"dimensions":{"type":"integer","description":"Vector dimensions (e.g. 384, 768, 1536, 3072)","default":768},"index_method":{"type":"string","enum":["hnsw","ivfflat"],"description":"Index type for similarity search","default":"hnsw"},"metric":{"type":"string","enum":["cosine","l2","ip"],"description":"Distance metric (cosine, l2, ip)","default":"cosine"},"index_options":{"type":"object","description":"Index-specific options. HNSW: {m, ef_construction}. IVFFlat: {lists}.","default":{}},"source_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Column names that feed the embedding. Used by stale trigger to detect content changes."},"embedding_model":{"type":"string","description":"Embedding model identifier (e.g. \"nomic-embed-text\", \"text-embedding-3-small\"). Included in the job payload so the worker knows which model to use. When null, the worker falls back to runtime config (llm_module / env vars)."},"embedding_provider":{"$ref":"#/$defs/shared-ac9a0977fa"},"enqueue_job":{"type":"boolean","description":"Auto-create trigger that enqueues embedding generation jobs","default":true},"job_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the job queue. Must match a registered function definition when function_module is installed.","default":"embedding:embed_record"},"chunks":{"type":"object","description":"Chunking configuration for long-text embedding. Creates an embedding_chunks record that drives automatic text splitting and per-chunk embedding. Omit to skip chunking.","properties":{"content_field_name":{"type":"string","format":"column-ref","description":"Name of the text content column in the chunks table","default":"content"},"chunk_size":{"type":"integer","description":"Maximum number of characters per chunk","default":1000},"chunk_overlap":{"type":"integer","description":"Number of overlapping characters between consecutive chunks","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"description":"Strategy for splitting text into chunks","default":"fixed"},"metadata_fields":{"$ref":"#/$defs/shared-3a33134347"},"enqueue_chunking_job":{"type":"boolean","description":"Whether to auto-enqueue a chunking job on insert/update","default":true},"chunking_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the chunking job queue. Must match a registered function definition when function_module is installed.","default":"embedding:chunk_record"}}}},"description":"Adds a vector embedding column with HNSW or IVFFlat index for similarity search. Supports configurable dimensions, distance metrics (cosine, l2, ip), per-field {field_name}_updated_at timestamp tracking (read-only in GraphQL), and automatic job enqueue triggers for embedding generation."},"TableOrganizationSettingsParams":{"type":"object","properties":{},"description":"Creates an organization settings table with standard business fields (legal_name, address fields). Uses AuthzEntityMembership for access control."},"TableUserProfilesParams":{"type":"object","properties":{},"description":"Creates a user profiles table with standard profile fields (profile_picture, bio, first_name, last_name, tags, desired). Uses AuthzDirectOwner for edit access and AuthzAllowAll for select."},"TableUserSettingsParams":{"type":"object","properties":{},"description":"Creates a user settings table for user-specific configuration. Uses AuthzDirectOwner for access control."},"TriggerCondition":{"type":"object","properties":{"field":{"type":"string","description":"Column name (validated against the table)."},"op":{"enum":["=","!=",">","<",">=","<=","LIKE","NOT LIKE","IS NULL","IS NOT NULL","IS DISTINCT FROM"],"description":"Comparison operator."},"value":{"description":"Comparison value. Type is resolved from the column definition."},"row":{"enum":["NEW","OLD"],"description":"Row reference (default: NEW)."},"ref":{"type":"object","properties":{"field":{"type":"string"},"row":{"enum":["NEW","OLD"]}},"description":"Column reference for field-to-field comparison (alternative to value)."},"AND":{"type":"array","items":{"$ref":"#/$defs/TriggerCondition"},"description":"Array of conditions combined with AND."},"OR":{"type":"array","items":{"$ref":"#/$defs/TriggerCondition"},"description":"Array of conditions combined with OR."},"NOT":{"$ref":"#/$defs/TriggerCondition","description":"Negated condition."}},"description":"Recursive condition type for compound trigger WHEN clauses. Leaf conditions specify {field, op, value?, row?, ref?}. Combinators nest via AND, OR, NOT."},"shared-001d8d7cd3":{"anyOf":[{"required":["obj_table_id"]},{"required":["obj_schema","obj_table"]}]},"shared-0165627a32":{"type":"array","items":{"type":"string"},"description":"Capability names of any kind (capability, level, ...) merged into the same mask"},"shared-040cc005ef":{"type":"array","minItems":1,"items":{"$ref":"#/$defs/AuthzExpression"}},"shared-0596961db6":{"if":{"properties":{"$type":{"const":"AuthzRelatedMemberList"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedMemberListParams"}}}},"shared-066977ff2f":{"anyOf":[{"required":["obj_field"]},{"required":["obj_field_id"]}]},"shared-078ee82414":{"properties":{"$type":{"const":"CheckOneOf"}},"required":["$type"]},"shared-0968d06284":{"type":"string","description":"Schema of the join table (or use obj_table_id)"},"shared-0a22d2c3f6":{"type":"string","description":"Single column name for the index."},"shared-11809f0714":{"if":{"properties":{"$type":{"const":"AuthzMemberList"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzMemberListParams"}}}},"shared-11a9ffe32a":{"type":"string","description":"Schema of the related table (user-facing name, e.g., \"public\"). Optional — if omitted, resolved by table name within the same database_id (raises error if ambiguous)."},"shared-13aff2afe8":{"type":"string","description":"The member list the policy reads. With a team kind the backend resolves it and replaces this value."},"shared-152f619c56":{"if":{"properties":{"$type":{"const":"AuthzDenyAll"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDenyAllParams"}}}},"shared-15602a740a":{"properties":{"$type":{"const":"AuthzEntityMembership"}},"required":["$type"]},"shared-1a317ed066":{"type":"string","format":"column-ref","description":"Column on the trigger table that holds (or references) the entity_id for billing scope. Forwarded to the composed JobTrigger."},"shared-1a97ddc6fb":{"if":{"properties":{"$type":{"const":"AuthzRelatedPeerOwnership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedPeerOwnershipParams"}}}},"shared-1c8d46d43b":{"properties":{"$type":{"const":"CheckNotEqual"}},"required":["$type"]},"shared-1ca2c9bd61":{"type":"array","description":"Join conditions between the protected row and the referenced table","items":{"type":"object","properties":{"local_column":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column on the protected table"},"ref_column":{"$ref":"#/$defs/shared-7539b204c0"},"operator":{"type":"string","enum":["=","!=",">","<",">=","<="],"default":"=","description":"Join operator"}},"required":["local_column","ref_column"],"additionalProperties":false}},"shared-1d7aaec830":{"type":"string","description":"Per-row required permissions (DataCapabilities): a bit(n) column on this table whose bits the actor must hold, checked as sprt.capabilities & row.mask = row.mask. A zero mask requires nothing."},"shared-21a1ba9587":{"if":{"properties":{"$type":{"const":"AuthzAppMembership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzAppMembershipParams"}}}},"shared-22f38cc906":{"type":"array","items":{"type":"string"},"description":"Operator classes for the index columns."},"shared-230094622e":{"type":"object","description":"FK lookup configuration for resolving entity_id through a related table. Used when entity_field is a FK (e.g., channel_id) rather than a direct entity_id. The generator validates all fields against metaschema within the same database_id.","properties":{"obj_table":{"type":"string","description":"Name of the related table to look up entity_id from (e.g., \"channels\"). Required."},"obj_schema":{"type":"string","description":"Schema of the related table (user-facing name, e.g., \"public\"). Optional — if omitted, resolved by table name within the same database_id (raises error if ambiguous)."},"obj_field":{"type":"string","description":"Column on the related table that holds the entity_id (e.g., \"entity_id\"). Required."}},"required":["obj_table","obj_field"]},"shared-2997c2f821":{"if":{"properties":{"$type":{"const":"AuthzSystemOnly"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzSystemOnlyParams"}}}},"shared-2a834ba4ff":{"type":"string","description":"Index access method (e.g., \"BTREE\", \"GIN\", \"GIST\", \"HNSW\", \"BM25\")."},"shared-2c17992067":{"properties":{"$type":{"const":"AuthzNotReadOnly"}},"required":["$type"]},"shared-2c20767ba3":{"properties":{"$type":{"const":"CheckGreaterThan"}},"required":["$type"]},"shared-3245b618eb":{"properties":{"$type":{"const":"AuthzValueMatch"}},"required":["$type"]},"shared-33013a269d":{"if":{"properties":{"$type":{"const":"AuthzRelatedEntityMembership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedEntityMembershipParams"}}}},"shared-33af0ede37":{"type":"string","format":"column-ref","description":"Single column to compare against value (mutually exclusive with columns)"},"shared-34021cf1ff":{"properties":{"$type":{"const":"AuthzDirectOwnerAny"}},"required":["$type"]},"shared-36ea8e912e":{"if":{"properties":{"$type":{"const":"AuthzDatabaseClaim"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDatabaseClaimParams"}}}},"shared-39f66ad592":{"if":{"properties":{"$type":{"const":"AuthzAllowAll"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzAllowAllParams"}}}},"shared-3a33134347":{"type":"object","description":"Metadata fields from parent to copy into chunks"},"shared-3d0fa23a34":{"type":"string","description":"Schema of the related table (user-facing name, optional)"},"shared-3fc6945ad1":{"if":{"properties":{"$type":{"const":"AuthzValueExists"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueExistsParams"}}}},"shared-411f8ee76d":{"type":"string","description":"Schema of the referenced table (or use ref_table_id)"},"shared-433a283165":{"properties":{"$type":{"const":"AuthzRelatedMemberOwner"}},"required":["$type"]},"shared-462d3d2412":{"type":"string","description":"Name of the related table to look up entity_id from"},"shared-47ab73adbe":{"properties":{"$type":{"const":"AuthzDirectOwner"}},"required":["$type"]},"shared-48649a3a43":{"type":"array","items":{"$ref":"#/$defs/TriggerCondition"}},"shared-49ec07b1f5":{"properties":{"$type":{"const":"AuthzAppMemberOwner"}},"required":["$type"]},"shared-4f25156f61":{"if":{"properties":{"$type":{"const":"AuthzPeerOwnership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzPeerOwnershipParams"}}}},"shared-5192cb016d":{"properties":{"$type":{"const":"AuthzRelatedPeerOwnership"}},"required":["$type"]},"shared-51c1d9a5f0":{"type":"string","minLength":1,"not":{"const":"app"},"description":"Entity type prefix (e.g. 'org', 'channel', 'department'), resolved to its membership_type; use it instead of membership_type for readability."},"shared-5249d2cd90":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Field name on join table to match against SPRT entity_id"},"shared-5492e6a87c":{"type":"string","enum":["fulltext","bm25","trigram"]},"shared-55595a36d2":{"type":["array","object"],"items":{"type":"object"},"description":"Optional higher-level condition JSON applied to the referenced table (row alias d)"},"shared-57b27779bd":{"properties":{"$type":{"const":"AuthzValueAllowed"}},"required":["$type"]},"shared-584ca266e8":{"properties":{"$type":{"const":"AuthzRelatedMemberList"}},"required":["$type"]},"shared-5a2832df1c":{"type":"array","items":{"type":"string"},"description":"Array of column names for a multi-column index."},"shared-5e11bfeb01":{"type":"boolean","description":"If true, require is_owner flag on current user membership"},"shared-5f5453df14":{"properties":{"$type":{"const":"AuthzFilePath"}},"required":["$type"]},"shared-626b0c3c0b":{"type":"array","items":{"$ref":"#/$defs/BlueprintFtsSource"},"description":"Source fields that feed into this tsvector."},"shared-637ef72440":{"type":"string","pattern":"^[01]+$","description":"Capability bits a member must hold, as a bit string. Capabilities or levels, when given, replace it."},"shared-6639e33d04":{"if":{"properties":{"$type":{"const":"AuthzComposite"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzCompositeParams"}}}},"shared-698b2fd59a":{"type":"integer","minimum":2,"maximum":2147483647,"description":"The team kind: 2=org, 3+=dynamic entity types."},"shared-6adc1df48e":{"type":"string","description":"Optional schema name for disambiguation (falls back to top-level default)."},"shared-6b829f5502":{"type":"string","description":"Name of the related table to look up entity_id from (e.g., \"channels\"). Required."},"shared-6dbc2f5a83":{"if":{"properties":{"$type":{"const":"AuthzPublishable"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzPublishableParams"}}}},"shared-6eb30390ff":{"type":"string","enum":["INSERT","DELETE","UPDATE"]},"shared-7539b204c0":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Column on the referenced table"},"shared-757c15800e":{"type":"string","description":"Name of the CHECK constraint."},"shared-787b8adf81":{"anyOf":[{"$ref":"#/$defs/TriggerCondition"},{"$ref":"#/$defs/shared-48649a3a43"}],"description":"Additional compound conditions beyond auto-generated filtering. Merged with the auto-generated conditions via AND."},"shared-7a53e1103e":{"type":"boolean","description":"Select sel_field from the related row instead of the team id; the platform's own related policies set it with sel_field \"id\"."},"shared-7edb884d72":{"type":"object","description":"FK lookup configuration for resolving entity_id through a related table. Forwarded to the composed JobTrigger.","properties":{"obj_table":{"type":"string","description":"Name of the related table to look up entity_id from"},"obj_schema":{"type":"string","description":"Schema of the related table (user-facing name, optional)"},"obj_field":{"type":"string","format":"column-ref","description":"Column on the related table that holds the entity_id"}},"required":["obj_table","obj_field"]},"shared-7f50b0e5b7":{"type":"string","description":"Name of the referenced table (or use ref_table_id)"},"shared-8358853df2":{"properties":{"$type":{"const":"CheckLessThan"}},"required":["$type"]},"shared-85b2c2543e":{"if":{"properties":{"$type":{"const":"AuthzEntityMembership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzEntityMembershipParams"}}}},"shared-8763e18b77":{"anyOf":[{"required":["membership_type"]},{"required":["entity_type"]},{"required":["sprt_schema","sprt_table"]}]},"shared-88656ecafa":{"type":"string","format":"column-ref","description":"Column name for conditional WHEN clause (fires only when field equals condition_value)"},"shared-8881b94a41":{"if":{"properties":{"$type":{"const":"AuthzTemporal"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzTemporalParams"}}}},"shared-89ec3722aa":{"if":{"properties":{"$type":{"const":"AuthzRelatedMemberOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedMemberOwnerParams"}}}},"shared-8cc6b29877":{"type":"string","format":"uuid","description":"UUID of the referenced table (alternative to ref_schema/ref_table)"},"shared-8cef65cfda":{"type":"object","additionalProperties":{"oneOf":[{"type":"string","format":"column-ref"},{"type":"object","properties":{"field":{"type":"string","format":"column-ref"},"path":{"type":"array","items":{"type":"string"},"minItems":1}},"required":["field","path"]}]},"description":"Custom payload key-to-source mapping for the job trigger. A source is either a column name or a read into a jsonb column ({\"field\": \"upload\", \"path\": [\"key\"]}). Defaults to the four file columns, or to the file_field document when file_field is set."},"shared-8e6e495eb6":{"if":{"properties":{"$type":{"const":"AuthzNotReadOnly"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzNotReadOnlyParams"}}}},"shared-9146e81ef6":{"type":"string","format":"uuid","description":"UUID of the join table (alternative to obj_schema/obj_table)"},"shared-927486214a":{"type":"boolean","description":"If true, require is_admin flag"},"shared-9572999fa8":{"type":"string","description":"The schema of the member list the policy reads. With a team kind the backend resolves it and replaces this value."},"shared-97d5c3be03":{"properties":{"$type":{"const":"AuthzOrgHierarchy"}},"required":["$type"]},"shared-9af2f9702a":{"type":"string","format":"column-ref","description":"Name of an upload/image domain column holding the file reference. When set, the trigger reads the object key, MIME type and bucket id out of that document (NEW. ->> 'key', ...) instead of requiring key/mime_type/bucket_id columns beside it, and the MIME patterns match against ->> 'mime'."},"shared-9d6147637c":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name referencing the entity (e.g., entity_id, org_id)"},"shared-a0bfcadf85":{"type":"array","items":{"type":"string"},"description":"Column names that form the unique constraint."},"shared-a2c45e97d1":{"if":{"properties":{"$type":{"const":"AuthzDirectOwnerAny"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDirectOwnerAnyParams"}}}},"shared-a9d73b8ba7":{"if":{"properties":{"$type":{"const":"AuthzMemberOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzMemberOwnerParams"}}}},"shared-ab071ec2f8":{"type":"boolean","description":"If true, require is_owner flag"},"shared-ab15ceab40":{"type":"string","description":"Prefix of the module instance, for entity-scoped installations."},"shared-ac9a0977fa":{"type":"string","description":"Embedding provider name (e.g. \"ollama\", \"openai\"). When null, the worker falls back to runtime config."},"shared-aced6572ca":{"if":{"properties":{"$type":{"const":"AuthzHumanOnly"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzHumanOnlyParams"}}}},"shared-ad437cb66f":{"type":"string","format":"column-ref","x-column-scope":"local"},"shared-ad8f69741a":{"type":"string","description":"Optional schema name override."},"shared-af38a22089":{"enum":["AuthzAllowAll","AuthzAppMemberOwner","AuthzAppMembership","AuthzComposite","AuthzDatabaseClaim","AuthzDenyAll","AuthzDirectOwner","AuthzDirectOwnerAny","AuthzEntityMembership","AuthzFilePath","AuthzHumanOnly","AuthzMemberList","AuthzMemberOwner","AuthzNotReadOnly","AuthzOrgHierarchy","AuthzPeerOwnership","AuthzPublishable","AuthzRelatedEntityMembership","AuthzRelatedMemberList","AuthzRelatedMemberOwner","AuthzRelatedPeerOwnership","AuthzSystemOnly","AuthzTemporal","AuthzValueAllowed","AuthzValueExists","AuthzValueMatch"]},"shared-b0876b5627":{"type":"array","items":{"type":"string"},"description":"Achievement level names to require (kind=level catalog rows, merged into the same mask)"},"shared-b1944d8f7b":{"description":"Allowed values as a constant list, or a local column name containing the allowed values","anyOf":[{"type":"string","format":"column-ref","x-column-scope":"local","description":"Local column name containing allowed values"},{"type":"array","items":{"type":["string","boolean","number","null"]},"description":"Constant list of allowed values. Element JSON type is preserved: booleans/numbers emit typed constants (e.g. [true] -> TRUE, [5] -> 5), strings emit text literals."}]},"shared-b1dc7b2e4f":{"properties":{"$type":{"const":"AuthzPeerOwnership"}},"required":["$type"]},"shared-b68f53d1ed":{"type":"integer","description":"The width the mask is padded to; by default the length of the mask."},"shared-bb55f34041":{"type":"boolean","description":"Whether this is a unique index."},"shared-bc381c03de":{"type":"object","properties":{"roles":{"type":"array","items":{"type":"string"}},"privileges":{"type":"array","items":{}}},"required":["roles","privileges"]},"shared-c1527c6159":{"if":{"properties":{"$type":{"const":"AuthzValueMatch"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueMatchParams"}}}},"shared-c2c61348f0":{"if":{"properties":{"$type":{"const":"AuthzOrgHierarchy"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzOrgHierarchyParams"}}}},"shared-c88c54a5c5":{"if":{"properties":{"$type":{"const":"AuthzValueAllowed"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueAllowedParams"}}}},"shared-c893ee8510":{"if":{"properties":{"$type":{"const":"AuthzDirectOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDirectOwnerParams"}}}},"shared-cc52e308f2":{"anyOf":[{"$ref":"#/$defs/TriggerCondition"},{"$ref":"#/$defs/shared-48649a3a43"}],"description":"Compound conditions for the trigger WHEN clause. Accepts a single leaf condition, an array of conditions (implicitly AND), or a nested combinator tree ({AND: [...], OR: [...], NOT: {...}}). Each leaf is {field, op, value?, row?, ref?}. Column types are resolved automatically from the table schema. Cannot be combined with condition_field or watch_fields."},"shared-cd4dc6cdf6":{"type":"string","description":"Name of the join table (or use obj_table_id)"},"shared-d3e6ac0b5d":{"type":"boolean","description":"If true, require is_admin flag on current user membership"},"shared-d4553f7be9":{"type":"string","format":"column-ref","description":"Column on the related table that holds the entity_id"},"shared-d85a10e177":{"type":"object","description":"Reference to a table an installed module generated, resolved during blueprint construction (alternative to ref_table_id / ref_schema + ref_table)","properties":{"type":{"type":"string","description":"Module type owning the table, e.g. \"agent\""},"table":{"type":"string","description":"Logical table key within the module, e.g. \"thread\""},"scope":{"type":"string","description":"Scope of the module instance, e.g. \"app\" or \"org\""},"prefix":{"type":"string","description":"Prefix of the module instance, for entity-scoped installations"}},"required":["type","table"]},"shared-d8e76848ea":{"type":"string","format":"uuid","description":"UUID of field on join table (alternative to obj_field)"},"shared-d91c021eee":{"properties":{"$type":{"const":"AuthzMemberOwner"}},"required":["$type"]},"shared-db0e2e6361":{"type":"string","format":"uuid","description":"Table being referenced by the FK"},"shared-dfbaf50fc6":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name on protected table referencing the join table"},"shared-e1125a4a5e":{"type":"string","description":"Scope of the module instance (e.g. \"app\", \"org\"). Required when the database installs the module at more than one scope."},"shared-e23bde2ba6":{"properties":{"$type":{"const":"AuthzValueExists"}},"required":["$type"]},"shared-e3e4ac8f48":{"if":{"properties":{"$type":{"const":"AuthzFilePath"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzFilePathParams"}}}},"shared-e6dbbbcd8d":{"type":"string","enum":["c","r","n","d","a"],"description":"FK delete action: c=CASCADE, r=RESTRICT, n=SET NULL, d=SET DEFAULT, a=NO ACTION. Required."},"shared-e772a2f2a5":{"type":"object","additionalProperties":{},"description":"Additional index-specific options."},"shared-eb6d498d14":{"if":{"properties":{"$type":{"const":"AuthzAppMemberOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzAppMemberOwnerParams"}}}},"shared-eb860e1011":{"type":"string","enum":["INSERT","UPDATE","DELETE"]},"shared-ee69c55731":{"type":"string","description":"Name of the tsvector field on the table."},"shared-eff5f86cd2":{"properties":{"$type":{"const":"AuthzMemberList"}},"required":["$type"]},"shared-effacc6003":{"type":"object","description":"A further row that must exist in a third table, joined to the referenced row (alias b unless ref_alias says otherwise).","properties":{"ref_table_id":{"type":"string","format":"uuid","description":"UUID of the third table (alternative to ref_schema/ref_table)"},"ref_schema":{"type":"string","description":"Schema of the third table (or use ref_table_id)"},"ref_table":{"type":"string","description":"Name of the third table (or use ref_table_id)"},"ref_alias":{"type":"string","description":"Alias of the third table in the join","default":"b"},"join":{"type":"array","description":"Join conditions between the referenced row and the third table","items":{"type":"object","properties":{"local_column":{"$ref":"#/$defs/shared-7539b204c0"},"ref_column":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Column on the third table"},"operator":{"type":"string","enum":["=","!=",">","<",">=","<="],"default":"=","description":"Join operator"}},"required":["local_column","ref_column"],"additionalProperties":false}},"conditions":{"type":["array","object"],"items":{"type":"object"},"description":"Optional condition JSON applied to the third table"}},"anyOf":[{"required":["ref_table_id"]},{"required":["ref_schema","ref_table"]}],"additionalProperties":false},"shared-f35a015b21":{"type":"string","description":"Optional custom name for the index."},"shared-f4262069e5":{"type":"string","enum":["public","private","temp"]},"shared-f7ad90b1e2":{"type":"string","description":"Value to compare against condition_field in WHEN clause"},"shared-f93f3b8ac9":{"properties":{"$type":{"const":"AuthzRelatedEntityMembership"}},"required":["$type"]},"shared-fe3f452ee5":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"For UPDATE triggers, only fire when these fields change (uses DISTINCT FROM)"}}}; +export const blueprintDefinitionJsonSchema: JSONSchema = {"$schema":"http://json-schema.org/draft-07/schema#","title":"BlueprintDefinition","description":"The complete blueprint definition -- the JSONB shape accepted by construct_blueprint().","allOf":[{"$ref":"#/$defs/BlueprintDefinition"}],"$defs":{"AuthzAllowAllParams":{"type":"object","properties":{},"additionalProperties":false,"description":"Allows all access. Generates TRUE expression."},"AuthzAppMemberOwnerParams":{"type":"object","properties":{"owner_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the owner user ID (e.g., actor_id)","default":"owner_id"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["owner_field"],"additionalProperties":false,"description":"Compound policy: the row must be owned by the current user (owner_field = current_user_id) AND the current user must hold an app membership (hardcoded membership_type=1). App-level analog of AuthzMemberOwner for global scopes with no entity key — authorship never survives losing app membership."},"AuthzAppMembershipParams":{"type":"object","properties":{"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":[],"additionalProperties":false,"description":"App-level membership check (hardcoded membership_type=1). Verifies the user has app membership (optionally with specific capability) without binding to any entity from the row. Uses EXISTS subquery against SPRT table. For entity-scoped checks (org, channel, etc.), use AuthzEntityMembership instead."},"AuthzColumnSecurityParams":{"type":"object","properties":{"columns":{"type":"array","items":{"$ref":"#/$defs/shared-ad437cb66f"},"minItems":1,"description":"Guarded columns that share the same rule and authorization (e.g. [\"is_shared\"])."},"rule":{"type":"string","enum":["set_true","set_false","set_values","not_values","writable_when","transition","immutable"],"description":"Write pattern that arms the guard: set_true/set_false (column set to that boolean), set_values (column set to one of values), not_values (column set to a non-NULL value outside values), writable_when (column written/changed at all), transition (OLD->NEW pairs in allowed), immutable (delegates to DataImmutableFields).","default":"writable_when"},"authz":{"$ref":"#/$defs/AuthzExpression","description":"An Authz expression (one node such as {\"AuthzAppMembership\": {...}}, or AND, OR or NOT over nodes) that must be satisfied to perform the guarded write. Required for all rules except immutable."},"values":{"type":"array","items":{"type":"string"},"description":"For rule=set_values: the protected values that arm the guard. For rule=not_values: the allowed values; any non-NULL value outside them arms the guard."},"allowed":{"type":"array","items":{"type":"string"},"description":"For rule=transition: allowed guarded transitions expressed as \"from->to\" (e.g. [\"member->admin\"])."},"allow_system":{"type":"boolean","description":"When true, the system role (AuthzSystemOnly) bypasses the guard so provisioning/seed paths without a JWT principal can write freely.","default":false},"error_code":{"type":"string","description":"Machine-readable code prefixed onto the raised error message (e.g. MANAGED_DOMAIN_PUBLISH_FORBIDDEN)."},"error_message":{"type":"string","description":"Human-readable message raised when the guard denies the write."},"conditions":{"type":["object","array"],"items":{"type":"object"},"description":"Conditions on the row being written; the guard arms only when the write matches the rule and the row meets them."}},"required":["columns","rule"],"allOf":[{"if":{"properties":{"rule":{"not":{"const":"immutable"}}}},"then":{"required":["authz"]}},{"if":{"properties":{"rule":{"enum":["set_values","not_values"]}}},"then":{"required":["values"],"properties":{"values":{"minItems":1}}}},{"if":{"properties":{"rule":{"const":"transition"}}},"then":{"required":["allowed"],"properties":{"allowed":{"minItems":1}}}}],"additionalProperties":false,"description":"Column-level write authorization. Generates BEFORE INSERT/UPDATE triggers that enforce an authorization node whenever a guarded column is written to a protected value or transitions. The write-time counterpart to RLS SELECT/WITH CHECK policies: any table can declare \"only an actor satisfying may set column X\". The nested authz value is a normal Authz node compiled by the standard RLS pipeline; row-referencing nodes have their protected-table column references rebound to NEW. The immutable rule delegates to the native DataImmutableFields generator."},"AuthzCompositeParams":{"$ref":"#/$defs/AuthzExpression","description":"Composite authorization policy that combines multiple authorization nodes using boolean logic (AND/OR). The data field contains a JSONB AST with nested authorization nodes."},"AuthzDatabaseClaimParams":{"type":"object","properties":{"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column carrying the row's database id","default":"database_id"},"schema_id":{"type":"string","format":"uuid","description":"A schema whose database must be the claimed one, in place of a column; the rule then reads no column."},"lane_attested":{"type":"boolean","description":"Only connections the platform attests for the claimed database pass.","default":false}},"additionalProperties":false,"description":"Passes when the row's database column equals the session's pinned database claim (jwt.claims.database_id). Consults no principal, membership or entity, so it admits a connection whose identity the platform sets — such as a cloud function's database connection, whose claim comes from the connection and cannot widen it — to exactly the database that connection is bound to. A session with no claim fails loudly rather than reading nothing."},"AuthzDenyAllParams":{"type":"object","properties":{},"additionalProperties":false,"description":"Denies all access. Generates FALSE expression."},"AuthzDirectOwnerAnyParams":{"type":"object","properties":{"entity_fields":{"type":"array","items":{"$ref":"#/$defs/shared-ad437cb66f"},"minItems":1,"description":"Array of column names to check for ownership"}},"required":["entity_fields"],"additionalProperties":false,"description":"OR logic for multiple ownership fields. Checks if current user matches any of the specified fields."},"AuthzDirectOwnerParams":{"type":"object","properties":{"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the owner user ID (e.g., owner_id)"}},"required":["entity_field"],"additionalProperties":false,"description":"Direct equality comparison between a table column and the current user ID. Simplest authorization pattern with no subqueries."},"AuthzEntityMembershipParams":{"type":"object","properties":{"entity_field":{"$ref":"#/$defs/shared-9d6147637c"},"sel_field":{"type":"string","description":"SPRT column to select for the entity match","default":"entity_id"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"mask_column":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Per-row required permissions (DataCapabilities): a bit(n) column on this table whose bits the actor must hold, checked as sprt.capabilities & row.mask = row.mask. Narrows access row by row without joining a grant table; a zero mask requires nothing. Composes with capability/capabilities — both are ANDed."},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"},"check_function_name":{"type":"string","description":"A function that checks the membership instead of the member list; it is called with the row's team column."},"check_function_schema":{"type":"string","description":"The schema of that function."}},"required":["entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"}],"additionalProperties":false,"description":"Membership check scoped by a field on the row through the SPRT table. Verifies user has membership in the entity referenced by the row."},"AuthzExpression":{"type":"object","description":"One Authz node as {\"AuthzEntityMembership\": {...}}, or AND or OR with a list of expressions, or NOT with one expression.","minProperties":1,"maxProperties":1,"properties":{"AND":{"$ref":"#/$defs/shared-040cc005ef"},"OR":{"$ref":"#/$defs/shared-040cc005ef"},"NOT":{"$ref":"#/$defs/AuthzExpression"},"AuthzAllowAll":{"$ref":"#/$defs/AuthzAllowAllParams"},"AuthzAppMemberOwner":{"$ref":"#/$defs/AuthzAppMemberOwnerParams"},"AuthzAppMembership":{"$ref":"#/$defs/AuthzAppMembershipParams"},"AuthzDatabaseClaim":{"$ref":"#/$defs/AuthzDatabaseClaimParams"},"AuthzDenyAll":{"$ref":"#/$defs/AuthzDenyAllParams"},"AuthzDirectOwner":{"$ref":"#/$defs/AuthzDirectOwnerParams"},"AuthzDirectOwnerAny":{"$ref":"#/$defs/AuthzDirectOwnerAnyParams"},"AuthzEntityMembership":{"$ref":"#/$defs/AuthzEntityMembershipParams"},"AuthzFilePath":{"$ref":"#/$defs/AuthzFilePathParams"},"AuthzHumanOnly":{"$ref":"#/$defs/AuthzHumanOnlyParams"},"AuthzMemberList":{"$ref":"#/$defs/AuthzMemberListParams"},"AuthzMemberOwner":{"$ref":"#/$defs/AuthzMemberOwnerParams"},"AuthzOrgHierarchy":{"$ref":"#/$defs/AuthzOrgHierarchyParams"},"AuthzPeerOwnership":{"$ref":"#/$defs/AuthzPeerOwnershipParams"},"AuthzPublishable":{"$ref":"#/$defs/AuthzPublishableParams"},"AuthzRelatedEntityMembership":{"$ref":"#/$defs/AuthzRelatedEntityMembershipParams"},"AuthzRelatedMemberList":{"$ref":"#/$defs/AuthzRelatedMemberListParams"},"AuthzRelatedMemberOwner":{"$ref":"#/$defs/AuthzRelatedMemberOwnerParams"},"AuthzRelatedPeerOwnership":{"$ref":"#/$defs/AuthzRelatedPeerOwnershipParams"},"AuthzSystemOnly":{"$ref":"#/$defs/AuthzSystemOnlyParams"},"AuthzTemporal":{"$ref":"#/$defs/AuthzTemporalParams"},"AuthzValueAllowed":{"$ref":"#/$defs/AuthzValueAllowedParams"},"AuthzValueExists":{"$ref":"#/$defs/AuthzValueExistsParams"},"AuthzValueMatch":{"$ref":"#/$defs/AuthzValueMatchParams"}},"additionalProperties":false},"AuthzFilePathParams":{"type":"object","properties":{"shares_table_id":{"type":"string","format":"uuid","description":"UUID of the path_shares table (alternative to shares_schema/shares_table)"},"shares_schema":{"type":"string","description":"Schema of the path_shares table (or use shares_table_id)"},"shares_table":{"type":"string","description":"Name of the path_shares table (or use shares_table_id)"},"files_table_id":{"type":"string","format":"uuid","description":"UUID of the files table (alternative to files_schema/files_table)"},"files_schema":{"type":"string","description":"Schema of the files table (or use files_table_id)"},"files_table":{"type":"string","description":"Name of the files table (or use files_table_id)"},"capability_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Boolean column on the path_shares table that grants the required permission (e.g. can_read, can_write)"},"bucket_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Column on the files table referencing the bucket","default":"bucket_id"},"path_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Ltree column on the files table representing the file path","default":"path"}},"required":["capability_field"],"allOf":[{"anyOf":[{"required":["shares_table_id"]},{"required":["shares_schema","shares_table"]}]},{"anyOf":[{"required":["files_table_id"]},{"required":["files_schema","files_table"]}]}],"additionalProperties":false,"description":"Path-scoped file sharing via ltree containment. Grants access when a path_shares row matches the current user, bucket, and an ancestor path with the required permission."},"AuthzHumanOnlyParams":{"type":"object","properties":{},"additionalProperties":false,"description":"Passes only for human sessions: compares the session's principal claim to its user claim, so service principals (API keys, agents) are excluded. Typically applied as a restrictive policy alongside a permissive membership policy."},"AuthzMemberListParams":{"type":"object","properties":{"array_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the array of user IDs"}},"required":["array_field"],"additionalProperties":false,"description":"Check if current user is in an array column on the same row."},"AuthzMemberOwnerParams":{"type":"object","properties":{"owner_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the owner user ID (e.g., owner_id)","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name referencing the entity (e.g., entity_id)","default":"entity_id"},"sel_field":{"type":"string","description":"SPRT column to select for the entity match","default":"entity_id"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["owner_field","entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"}],"additionalProperties":false,"description":"Compound policy: the row must be owned by the current user (owner_field = current_user_id) AND the current user must be a member of the entity referenced by entity_field. Combines direct ownership with entity membership — the actor can only access rows they own within entities they belong to."},"AuthzNotReadOnlyParams":{"type":"object","properties":{"entity_field":{"$ref":"#/$defs/shared-9d6147637c"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"}},"required":["entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"}],"additionalProperties":false,"description":"Restrictive policy that blocks read-only members from mutations. Checks actor_id + is_read_only IS NOT TRUE on the SPRT. Designed to run as a restrictive counterpart after a permissive AuthzEntityMembership policy has already verified membership."},"AuthzOrgHierarchyParams":{"type":"object","properties":{"direction":{"type":"string","enum":["up","down"],"description":"down=manager sees subordinates, up=subordinate sees managers"},"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Field referencing the org entity","default":"entity_id"},"anchor_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Field referencing the user (e.g., owner_id)"},"max_depth":{"type":"integer","description":"Optional max depth to limit visibility"}},"required":["direction","anchor_field"],"additionalProperties":false,"description":"Organizational hierarchy visibility using closure table. Managers can see subordinate data or subordinates can see manager data."},"AuthzPeerOwnershipParams":{"type":"object","properties":{"owner_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name on protected table referencing the owning user (e.g., owner_id)"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-d3e6ac0b5d"},"is_owner":{"$ref":"#/$defs/shared-5e11bfeb01"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["owner_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"}],"additionalProperties":false,"description":"Peer visibility through shared entity membership. Authorizes access to user-owned rows when the owner and current user are both members of the same entity. Self-joins the SPRT table to find peers."},"AuthzPublishableParams":{"type":"object","properties":{"is_published_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Boolean field indicating published state","default":"is_published"},"published_at_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Timestamp field for publish time","default":"published_at"},"require_published_at":{"type":"boolean","description":"Require published_at to be non-null and <= now()","default":true}},"additionalProperties":false,"description":"Published state access control. Restricts access to records that are published."},"AuthzRelatedEntityMembershipParams":{"type":"object","properties":{"entity_field":{"$ref":"#/$defs/shared-dfbaf50fc6"},"sel_field":{"type":"string","description":"SPRT column to select for the entity match","default":"entity_id"},"sprt_join_field":{"type":"string","description":"SPRT column to join on with the related table","default":"entity_id"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"obj_table_id":{"$ref":"#/$defs/shared-9146e81ef6"},"obj_schema":{"$ref":"#/$defs/shared-0968d06284"},"obj_table":{"$ref":"#/$defs/shared-cd4dc6cdf6"},"obj_field_id":{"$ref":"#/$defs/shared-d8e76848ea"},"obj_field":{"$ref":"#/$defs/shared-5249d2cd90"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"sel_obj":{"$ref":"#/$defs/shared-7a53e1103e"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"},{"$ref":"#/$defs/shared-066977ff2f"},{"$ref":"#/$defs/shared-001d8d7cd3"}],"additionalProperties":false,"description":"JOIN-based membership verification through related tables. Joins SPRT table with another table to verify membership."},"AuthzRelatedMemberListParams":{"type":"object","properties":{"owned_table_id":{"type":"string","format":"uuid","description":"UUID of the related table (alternative to owned_schema/owned_table)"},"owned_schema":{"type":"string","description":"Schema of the related table (or use owned_table_id)"},"owned_table":{"type":"string","description":"Name of the related table (or use owned_table_id)"},"owned_table_key":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Array column in related table"},"owned_table_ref_key":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"FK column in related table"},"this_object_key":{"type":"string","format":"column-ref","x-column-scope":"local","description":"PK column in protected table"}},"required":["owned_table_key","owned_table_ref_key","this_object_key"],"anyOf":[{"required":["owned_table_id"]},{"required":["owned_schema","owned_table"]}],"additionalProperties":false,"description":"Array membership check in a related table."},"AuthzRelatedMemberOwnerParams":{"type":"object","properties":{"owner_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name containing the owner user ID (e.g., actor_id)","default":"owner_id"},"entity_field":{"$ref":"#/$defs/shared-dfbaf50fc6"},"sel_field":{"type":"string","description":"SPRT column to select for the entity match","default":"entity_id"},"sprt_join_field":{"type":"string","description":"SPRT column to join on with the related table","default":"entity_id"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"obj_table_id":{"$ref":"#/$defs/shared-9146e81ef6"},"obj_schema":{"$ref":"#/$defs/shared-0968d06284"},"obj_table":{"$ref":"#/$defs/shared-cd4dc6cdf6"},"obj_field_id":{"$ref":"#/$defs/shared-d8e76848ea"},"obj_field":{"$ref":"#/$defs/shared-5249d2cd90"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-927486214a"},"is_owner":{"$ref":"#/$defs/shared-ab071ec2f8"},"sel_obj":{"$ref":"#/$defs/shared-7a53e1103e"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["owner_field","entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"},{"$ref":"#/$defs/shared-066977ff2f"},{"$ref":"#/$defs/shared-001d8d7cd3"}],"additionalProperties":false,"description":"Compound policy: the row must be owned by the current user (owner_field = current_user_id) AND the row must belong to a related entity the current user is a member of (SPRT joined through the related table, as in AuthzRelatedEntityMembership). Related-entity analog of AuthzMemberOwner — authorship never survives losing membership."},"AuthzRelatedPeerOwnershipParams":{"type":"object","properties":{"entity_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name on protected table referencing the related table (e.g., message_id)"},"membership_type":{"$ref":"#/$defs/shared-698b2fd59a"},"entity_type":{"$ref":"#/$defs/shared-51c1d9a5f0"},"obj_table_id":{"type":"string","format":"uuid","description":"UUID of the related table (alternative to obj_schema/obj_table)"},"obj_schema":{"type":"string","description":"Schema of the related table (or use obj_table_id)"},"obj_table":{"type":"string","description":"Name of the related table (or use obj_table_id)"},"obj_field_id":{"type":"string","format":"uuid","description":"UUID of field on related table containing the owner user ID (alternative to obj_field)"},"obj_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Field name on related table containing the owner user ID (e.g., sender_id)"},"obj_ref_field":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Field on related table to select for matching entity_field","default":"id"},"levels":{"$ref":"#/$defs/shared-b0876b5627"},"capabilities":{"$ref":"#/$defs/shared-0165627a32"},"is_admin":{"$ref":"#/$defs/shared-d3e6ac0b5d"},"is_owner":{"$ref":"#/$defs/shared-5e11bfeb01"},"mask_column":{"$ref":"#/$defs/shared-1d7aaec830"},"sprt_schema":{"$ref":"#/$defs/shared-9572999fa8"},"sprt_table":{"$ref":"#/$defs/shared-13aff2afe8"},"mask":{"$ref":"#/$defs/shared-637ef72440"},"bitlen":{"$ref":"#/$defs/shared-b68f53d1ed"}},"required":["entity_field"],"allOf":[{"$ref":"#/$defs/shared-8763e18b77"},{"$ref":"#/$defs/shared-066977ff2f"},{"$ref":"#/$defs/shared-001d8d7cd3"}],"additionalProperties":false,"description":"Peer visibility through shared entity membership via a related table. Like AuthzPeerOwnership but the owning user is resolved through a FK JOIN to a related table. Combines SPRT self-join with object table JOIN."},"AuthzSystemOnlyParams":{"type":"object","properties":{},"additionalProperties":false,"description":"Restricts access to system-initiated operations (triggers, background jobs). Checks jwt.claims.role_type = \"system\". Normal API requests default to \"user\" and are denied. Use for INSERT policies on append-only event/audit/usage tables."},"AuthzTemporalParams":{"type":"object","properties":{"valid_from_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column for start time (at least one of valid_from_field or valid_until_field required)"},"valid_until_field":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column for end time (at least one of valid_from_field or valid_until_field required)"},"valid_from_inclusive":{"type":"boolean","description":"Include start boundary","default":true},"valid_until_inclusive":{"type":"boolean","description":"Include end boundary","default":false}},"anyOf":[{"required":["valid_from_field"]},{"required":["valid_until_field"]}],"additionalProperties":false,"description":"Time-window based access control. Restricts access based on valid_from and/or valid_until timestamps. At least one of valid_from_field or valid_until_field must be provided."},"AuthzValueAllowedParams":{"type":"object","properties":{"column":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column on the protected table to check"},"allowed":{"$ref":"#/$defs/shared-b1944d8f7b"},"operator":{"type":"string","enum":["in","any","overlap","contains","contained"],"description":"Operator to use for the value check"}},"required":["column","allowed","operator"],"additionalProperties":false,"description":"Check the protected row's own column against an allowed set of values."},"AuthzValueExistsParams":{"type":"object","properties":{"ref_table_id":{"$ref":"#/$defs/shared-8cc6b29877"},"ref_schema":{"$ref":"#/$defs/shared-411f8ee76d"},"ref_table":{"$ref":"#/$defs/shared-7f50b0e5b7"},"ref_module":{"$ref":"#/$defs/shared-d85a10e177"},"join":{"$ref":"#/$defs/shared-1ca2c9bd61"},"conditions":{"$ref":"#/$defs/shared-55595a36d2"},"exists":{"$ref":"#/$defs/shared-effacc6003"}},"required":["join"],"anyOf":[{"required":["ref_table_id"]},{"required":["ref_schema","ref_table"]},{"required":["ref_module"]}],"additionalProperties":false,"description":"EXISTS check in a referenced table joined by a local column, with optional additional conditions."},"AuthzValueMatchParams":{"type":"object","properties":{"ref_table_id":{"$ref":"#/$defs/shared-8cc6b29877"},"ref_schema":{"$ref":"#/$defs/shared-411f8ee76d"},"ref_table":{"$ref":"#/$defs/shared-7f50b0e5b7"},"ref_module":{"$ref":"#/$defs/shared-d85a10e177"},"join":{"$ref":"#/$defs/shared-1ca2c9bd61"},"match":{"type":"object","description":"Value match on a referenced column","properties":{"ref_column":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Column on the referenced table to match"},"allowed":{"$ref":"#/$defs/shared-b1944d8f7b"},"operator":{"type":"string","enum":["in","any","overlap","contains","contained"],"description":"Operator to use for the match"}},"required":["ref_column","allowed","operator"],"additionalProperties":false},"conditions":{"$ref":"#/$defs/shared-55595a36d2"},"exists":{"$ref":"#/$defs/shared-effacc6003"}},"required":["match","join"],"anyOf":[{"required":["ref_table_id"]},{"required":["ref_schema","ref_table"]},{"required":["ref_module"]}],"additionalProperties":false,"description":"EXISTS check in a referenced table joined by a local column, with a value/array match on a referenced column and optional additional conditions."},"BlueprintAchievement":{"type":"object","properties":{"name":{"type":"string","description":"Unique name for the achievement level."},"description":{"type":"string","description":"Human-readable description of this achievement."},"priority":{"type":"number","description":"Display ordering priority; lower values appear first. Defaults to 100."},"requirements":{"type":"array","items":{"$ref":"#/$defs/BlueprintAchievementRequirement"},"description":"Requirements that must be met to earn this achievement."},"rewards":{"type":"array","items":{"$ref":"#/$defs/BlueprintAchievementReward"},"description":"Rewards granted when the achievement is earned."},"entity_prefix":{"type":"string","description":"Entity prefix to scope this achievement to (e.g., \"org\", \"app\"). Used to resolve the correct events_module. Defaults to \"app\"."}},"required":["name","requirements"],"description":"An achievement entry for the blueprint achievements[] section. Creates a level with requirements and optional rewards in the events_module. Requires events_module to be provisioned (e.g., via entity_types[].has_levels = true or modules includes events_module)."},"BlueprintAchievementRequirement":{"type":"object","properties":{"event_name":{"type":"string","description":"Name identifier matching an event_type or step name."},"count":{"type":"number","description":"Number of events needed to satisfy this requirement."},"description":{"type":"string","description":"Human-readable description of what this requirement entails."}},"required":["event_name","count"],"description":"A requirement entry within a blueprint achievement. Defines what events must occur to earn the achievement."},"BlueprintAchievementReward":{"type":"object","properties":{"reward_type":{"enum":["limit_credit","meter_credit"],"description":"Type of reward: limit_credit (grants limit credits) or meter_credit (grants meter credits)."},"target_name":{"type":"string","description":"Target limit name or meter slug for the credit grant."},"amount":{"type":"number","description":"Number of credits to grant."},"credit_type":{"type":"string","description":"Credit type: permanent, expiring, etc. Defaults to \"permanent\"."}},"required":["reward_type","target_name","amount"],"description":"A reward entry within a blueprint achievement. Defines credits granted when the achievement is earned."},"BlueprintAgentConfig":{"type":"object","properties":{"scope":{"enum":["app","org"],"description":"Agent scope. \"app\" (default) creates app-level agent tables (membership_type = NULL). \"org\" creates per-org agent tables. Only used at the top level of a blueprint definition — entity-scoped agents inherit scope from the entity type."},"key":{"type":"string","description":"Module discriminator for multi-module agents. Defaults to \"default\" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_agent_thread."},"api_name":{"type":"string","description":"API name for the agent module. Used in GraphQL naming. Defaults to \"agent\"."},"has_plans":{"type":"boolean","description":"Whether to provision the agent_plan table for workflow plans with ordered tasks and approval gates. When true, tasks belong to plans (plan_id NOT NULL) instead of directly to threads. Defaults to false."},"has_resources":{"type":"boolean","description":"Whether to provision the unified agent_resource table (skills + knowledge with slug, kind, search, embedding). Standalone flag — also auto-enabled by has_agents. Defaults to false."},"has_agents":{"type":"boolean","description":"Whether to provision the agent registry (agent table + agent_persona table). Implies has_resources = true. Defaults to false."},"has_runs":{"type":"boolean","description":"Whether to provision the agent execution surface: agent_run (one supervised run of a thread — placement, cursor, artifacts), agent_event (that run's append-only transcript, agent session entries stored verbatim, append-only by grant with UNIQUE (run_id, seq)) and agent_run_workspace (the repositories a run works in — zero rows for a chat with no clone, one per repository otherwise, UNIQUE (run_id, repo)). Defaults to false."},"resources":{"type":"array","items":{"type":"object","properties":{"dimensions":{"type":"number"},"chunk_size":{"type":"number"},"chunk_overlap":{"type":"number"},"chunk_strategy":{"enum":["paragraph","sentence","token"]},"embedding_model":{"type":"string"},"embedding_provider":{"type":"string"},"search_indexes":{"type":"array","items":{"type":"string"}}}},"description":"Resource configuration array. First element configures the agent_resource table: vector dimensions (default 768), chunk_size (default 1000), chunk_strategy (default \"paragraph\"), chunk_overlap (default 200), embedding_model, embedding_provider, search_indexes (default [\"bm25\"])."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policy overrides for the agent tables. NULL = apply defaults from apply_agent_security()."},"provisions":{"type":"object","properties":{"thread":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"message":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"task":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"prompt":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"plan":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"resource":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"agent":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"persona":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"run":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"event":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"workspace":{"$ref":"#/$defs/BlueprintEntityTableProvision"}},"description":"Per-table overrides for agent tables. Each key targets a specific table (thread, message, task, prompt, plan, resource, agent, persona, run, event, workspace) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision. Overriding `event` replaces the append-only default, so a grant list there can make the transcript mutable; overriding `workspace` replaces its no-delete default."}},"description":"Agent module configuration. When used at the top level of a blueprint, the scope field controls whether agents are app-level (\"app\", default) or org-level (\"org\"). When used inside entity_types[], scope is inherited from the entity type. Provisions thread, message, task, prompt tables. has_resources adds unified agent_resource (skills + knowledge). has_agents adds agent registry + personas (implies has_resources)."},"BlueprintBucketSeed":{"type":"object","properties":{"name":{"type":"string","description":"Bucket key name (e.g., \"avatars\", \"documents\"). Becomes the key column value."},"description":{"type":"string","description":"Human-readable description of this bucket."},"is_public":{"type":"boolean","description":"Whether the bucket is publicly readable. Defaults to false."},"allowed_mime_types":{"type":"array","items":{"type":"string"},"description":"MIME type allowlist (e.g., [\"image/png\", \"image/jpeg\"]). NULL means all types allowed."},"max_file_size":{"type":"number","description":"Maximum file size in bytes for this bucket. NULL means no limit."},"allowed_origins":{"type":"array","items":{"type":"string"},"description":"CORS allowed origins for this bucket."}},"required":["name"],"description":"A bucket seed entry for storage.buckets[]. Creates an initial bucket row in the {prefix}_buckets table during entity type provisioning. Only used for app-level storage (not entity-scoped)."},"BlueprintCheckConstraint":{"allOf":[{"$ref":"#/$defs/BlueprintTableCheckConstraint"},{"type":"object","properties":{"table_name":{"type":"string","description":"Table name this CHECK constraint belongs to."}},"required":["table_name"]}],"description":"A CHECK constraint definition within a blueprint (top-level, requires table_name)."},"BlueprintDefinition":{"type":"object","properties":{"tables":{"type":"array","items":{"$ref":"#/$defs/BlueprintTable"},"description":"Tables to create."},"relations":{"type":"array","items":{"$ref":"#/$defs/BlueprintRelation"},"description":"Relations between tables."},"indexes":{"type":"array","items":{"$ref":"#/$defs/BlueprintIndex"},"description":"Indexes on table columns."},"full_text_searches":{"type":"array","items":{"$ref":"#/$defs/BlueprintFullTextSearch"},"description":"Full-text search configurations."},"unique_constraints":{"type":"array","items":{"$ref":"#/$defs/BlueprintUniqueConstraint"},"description":"Unique constraints on table columns."},"check_constraints":{"type":"array","items":{"$ref":"#/$defs/BlueprintCheckConstraint"},"description":"CHECK constraints on table columns."},"entity_types":{"type":"array","items":{"$ref":"#/$defs/BlueprintEntityType"},"description":"Entity types to provision in Phase 0 (before tables). Each entry creates an entity table with membership modules and security."},"storage":{"type":"array","items":{"$ref":"#/$defs/BlueprintStorageConfig"},"description":"Top-level storage configuration array. Each entry has an optional scope (\"app\" or \"org\"). App-scoped (default) creates storage_module with membership_type = NULL. Org-scoped creates per-org/user storage with owner_id and AFTER INSERT bucket seeding. When infra is installed, a private \"functions\" bucket is auto-injected into org-scoped entries. For child entity type storage, use entity_types[].storage instead."},"achievements":{"type":"array","items":{"$ref":"#/$defs/BlueprintAchievement"},"description":"Achievement definitions. Each entry creates a level with requirements and optional rewards in the events_module. Requires events_module to be provisioned (e.g., via entity_types[].has_levels = true or modules includes events_module)."},"namespaces":{"type":"array","items":{"$ref":"#/$defs/BlueprintNamespaceConfig"},"description":"Top-level namespace configuration array (Phase 0.6). Each entry has an optional scope (\"app\" or \"org\"). App-scoped (default) creates namespace_module with membership_type = NULL. Org-scoped creates per-org namespaces. For entity-scoped namespaces, use entity_types[].namespaces instead."},"functions":{"type":"array","items":{"$ref":"#/$defs/BlueprintFunctionConfig"},"description":"Top-level function configuration array (Phase 0.6). Each entry has an optional scope (\"app\" or \"org\"). App-scoped (default) creates function_module with membership_type = NULL. Org-scoped creates per-org functions. For entity-scoped functions, use entity_types[].functions instead."},"agents":{"type":"array","items":{"$ref":"#/$defs/BlueprintAgentConfig"},"description":"Top-level agent configuration array (Phase 0.6). Each entry has an optional scope (\"app\" or \"org\"). App-scoped (default) creates agent_module with membership_type = NULL. Org-scoped creates per-org agents. For entity-scoped agents, use entity_types[].agents instead."}},"required":["tables"],"description":"The complete blueprint definition -- the JSONB shape accepted by construct_blueprint()."},"BlueprintEntityTableProvision":{"type":"object","properties":{"use_rls":{"type":"boolean","description":"Whether to enable RLS on the entity table. Forwarded to secure_table_provision. Defaults to true."},"nodes":{"type":"array","items":{"$ref":"#/$defs/BlueprintNode"},"description":"Node objects applied to the entity table for field creation (e.g., DataTimestamps, DataPeoplestamps). Forwarded to secure_table_provision as-is."},"fields":{"type":"array","items":{"$ref":"#/$defs/BlueprintField"},"description":"Custom fields (columns) to add to the entity table. Forwarded to secure_table_provision as-is."},"grants":{"type":"array","items":{"$ref":"#/$defs/shared-bc381c03de"},"description":"Unified grant objects for the entity table. Each entry is { roles: string[], privileges: unknown[] } where privileges are [verb, columns] tuples. Forwarded to secure_table_provision as-is. Defaults to []."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policies for the entity table. When present, these policies fully replace the five default entity-table policies (is_visible becomes a no-op)."}},"description":"Override object for the entity table created by a BlueprintEntityType. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, policies[] replaces the default entity-table policies entirely."},"BlueprintEntityType":{"type":"object","properties":{"name":{"type":"string","description":"Entity type name (e.g., \"data_room\", \"channel\", \"department\"). Required when creating a new entity type. Omit when extending an existing entity type (e.g., prefix: \"org\") — the entry will add storage/config to the existing type without creating a new one."},"prefix":{"type":"string","description":"Short prefix for generated objects (e.g., \"dr\", \"ch\", \"dept\"). Used in table/trigger naming."},"description":{"type":"string","description":"Human-readable description of this entity type."},"parent_entity":{"type":"string","description":"Parent entity type name. Defaults to \"org\"."},"table_name":{"type":"string","description":"Custom table name for the entity table. Defaults to name-derived convention."},"is_visible":{"type":"boolean","description":"Whether parent-entity members can see child entities via the default parent_member SELECT policy. Gates one of the five default policies. No-op when table_provision is supplied. Defaults to true."},"has_limits":{"type":"boolean","description":"Whether to provision a limits module for this entity type. Defaults to false."},"has_profiles":{"type":"boolean","description":"Whether to provision a profiles module for this entity type. Defaults to false. A membership may hold any number of profiles: the {prefix}_membership_profiles assignment table holds every profile it holds and the membership mask is granted | bit_or(held profile masks)."},"has_levels":{"type":"boolean","description":"Whether to provision a levels module for this entity type. Defaults to false."},"has_invites":{"type":"boolean","description":"Whether to provision entity-scoped invite tables ({prefix}_invites, {prefix}_claimed_invites) and a submit_{prefix}_invite_code() function. Defaults to false."},"has_invite_achievements":{"type":"boolean","description":"Whether to auto-attach an EventTracker to the claimed_invites table for invite-based achievements. Requires has_invites=true AND has_levels=true. When true, records 'invite_claimed' events credited to the sender (inviter) on each claimed invite. Defaults to false."},"skip_entity_policies":{"type":"boolean","description":"Escape hatch: when true AND table_provision is NULL, zero policies are provisioned on the entity table. Defaults to false."},"table_provision":{"$ref":"#/$defs/BlueprintEntityTableProvision","description":"Override for the entity table. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, its policies[] replaces the five default entity-table policies; is_visible becomes a no-op. When NULL (default), the five default policies are applied (gated by is_visible)."},"storage":{"type":"array","items":{"$ref":"#/$defs/BlueprintStorageConfig"},"description":"Storage module configuration array. Presence triggers provisioning (same inference model as namespaces, functions, agents). Each entry provisions a separate storage module with its own tables, RLS, and settings. Each entry may specify a key for multi-module support (defaults to \"default\")."},"namespaces":{"type":"array","items":{"$ref":"#/$defs/BlueprintNamespaceConfig"},"description":"Namespace module configuration array. Presence triggers provisioning. Each entry provisions a namespace_module with its own tables, computed-name proxy, and entity-scoped RLS. Registers manage_namespaces capability bit. \"[{}]\" = provision one default namespace module."},"functions":{"type":"array","items":{"$ref":"#/$defs/BlueprintFunctionConfig"},"description":"Function module configuration array. Presence triggers provisioning. Each entry provisions function_definitions, function_invocations (partitioned), and function_execution_logs tables. Registers manage_functions + invoke_functions capability bits. \"[{}]\" = provision one default function module."},"agents":{"type":"array","items":{"$ref":"#/$defs/BlueprintAgentConfig"},"description":"Agent module configuration array. Presence triggers provisioning. Each entry provisions thread, message, task, prompt tables (and optionally knowledge with vector embeddings). \"[{}]\" = provision one default agent module."},"graphs":{"type":"array","items":{"$ref":"#/$defs/BlueprintGraphConfig"},"description":"Graph module configuration array. Presence triggers capability registration (manage_graphs, execute_graphs). Graph module requires a merkle_store_module_id dependency, so entity_type_provision only registers capabilities here. \"[{}]\" = register default graph capabilities."}},"required":["prefix"],"description":"An entity type entry for Phase 0 of construct_blueprint(). When name is provided, provisions a new entity type with its own entity table, membership modules, and security policies via entity_type_provision. When name is omitted and only prefix is given, extends an existing entity type (e.g., the built-in \"org\") with additional capabilities like storage — without creating a new entity type."},"BlueprintField":{"type":"object","properties":{"name":{"type":"string","description":"The column name."},"type":{"$ref":"#/$defs/FieldType","description":"The structured PostgreSQL type (e.g., { name: \"text\" })."},"is_required":{"type":"boolean","description":"Whether the column has a NOT NULL constraint."},"default":{"$ref":"#/$defs/FieldDefault","description":"The structured default (e.g., { value: \"pending\" })."},"min":{"type":"number"},"max":{"type":"number"},"regexp":{"type":"string"},"index":{"enum":["btree","gin","gist","brin","hash"]},"description":{"type":"string","description":"Comment/description for this field."}},"required":["name","type"],"description":"A custom field (column) to add to a blueprint table."},"BlueprintFtsSource":{"type":"object","properties":{"field":{"type":"string","description":"Column name of the source field."},"weight":{"type":"string","description":"TSVector weight: \"A\", \"B\", \"C\", or \"D\"."},"lang":{"type":"string","description":"Language for text search. Defaults to \"english\"."}},"required":["field","weight"],"description":"A source field contributing to a full-text search tsvector column."},"BlueprintFullTextSearch":{"type":"object","properties":{"table_name":{"type":"string","description":"Table name this full-text search belongs to."},"schema_name":{"$ref":"#/$defs/shared-6adc1df48e"},"field":{"$ref":"#/$defs/shared-ee69c55731"},"sources":{"$ref":"#/$defs/shared-626b0c3c0b"}},"required":["table_name","field","sources"],"description":"A full-text search configuration for a blueprint table (top-level, requires table_name)."},"BlueprintFunctionConfig":{"type":"object","properties":{"scope":{"enum":["app","org"],"description":"Function scope. \"app\" (default) creates app-level functions (membership_type = NULL). \"org\" creates per-org functions. Only used at the top level of a blueprint definition — entity-scoped functions inherit scope from the entity type."},"key":{"type":"string","description":"Module discriminator for multi-module functions. Defaults to \"default\" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_function_definitions."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policy overrides for the function tables. NULL = apply defaults from apply_function_security()."},"provisions":{"type":"object","properties":{"definitions":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"invocations":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"execution_logs":{"$ref":"#/$defs/BlueprintEntityTableProvision"}},"description":"Per-table overrides for function tables. Each key targets a specific table (definitions, invocations, execution_logs) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision."}},"description":"Function module configuration. When used at the top level of a blueprint, the scope field controls whether functions are app-level (\"app\", default) or org-level (\"org\"). When used inside entity_types[], scope is inherited from the entity type. Provisions function_definitions, function_invocations (partitioned, 12-month retention), and function_execution_logs tables."},"BlueprintGraphConfig":{"type":"object","properties":{"key":{"type":"string","description":"Module discriminator for multi-module graphs. Defaults to \"default\"."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policy overrides for the graph tables. NULL = apply defaults from apply_graph_security()."}},"description":"Graph module configuration. Presence triggers capability registration (manage_graphs, execute_graphs). The graph module requires a merkle_store_module_id dependency, so entity_type_provision only registers capabilities here — the graph module itself must be provisioned separately."},"BlueprintIndex":{"type":"object","properties":{"table_name":{"type":"string","description":"Table name this index belongs to."},"schema_name":{"$ref":"#/$defs/shared-6adc1df48e"},"column":{"$ref":"#/$defs/shared-0a22d2c3f6"},"columns":{"$ref":"#/$defs/shared-5a2832df1c"},"access_method":{"$ref":"#/$defs/shared-2a834ba4ff"},"is_unique":{"$ref":"#/$defs/shared-bb55f34041"},"name":{"$ref":"#/$defs/shared-f35a015b21"},"op_classes":{"$ref":"#/$defs/shared-22f38cc906"},"options":{"$ref":"#/$defs/shared-e772a2f2a5"}},"required":["table_name","access_method"],"description":"An index definition within a blueprint (top-level, requires table_name)."},"BlueprintModuleInstallRef":{"type":"object","properties":{"type":{"type":"string","description":"Module type of the install, e.g. \"image\"."},"scope":{"$ref":"#/$defs/shared-e1125a4a5e"},"prefix":{"$ref":"#/$defs/shared-ab15ceab40"}},"required":["type"],"description":"A reference to an installed module, naming no table of its own. Used by a table entry whose provisions map supplies the table keys."},"BlueprintModuleTableRef":{"type":"object","properties":{"type":{"type":"string","description":"Module type owning the table. Currently \"agent\"."},"table":{"type":"string","description":"Logical table key within the module, not a table name. Agent: \"thread\", \"message\", \"task\", \"prompt\", \"plan\", \"agent\", \"persona\", \"resource\"."},"scope":{"$ref":"#/$defs/shared-e1125a4a5e"},"prefix":{"$ref":"#/$defs/shared-ab15ceab40"}},"required":["type","table"],"description":"A reference from a blueprint table entry to a table generated by an installed module. Resolved through the module row's recorded table ids; a reference that matches no module instance or no provisioned table fails construction rather than creating a table."},"BlueprintNamespaceConfig":{"type":"object","properties":{"scope":{"enum":["app","org"],"description":"Namespace scope. \"app\" (default) creates app-level namespaces (membership_type = NULL). \"org\" creates per-org namespaces. Only used at the top level of a blueprint definition — entity-scoped namespaces inherit scope from the entity type."},"key":{"type":"string","description":"Module discriminator for multi-module namespaces. Defaults to \"default\" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_namespaces."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policy overrides for the namespaces table. NULL = apply defaults from apply_namespace_security()."},"provisions":{"type":"object","properties":{"namespaces":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"namespace_events":{"$ref":"#/$defs/BlueprintEntityTableProvision"}},"description":"Per-table overrides for namespace tables. Each key targets a specific table (namespaces, namespace_events) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision."}},"description":"Namespace module configuration. When used at the top level of a blueprint, the scope field controls whether namespaces are app-level (\"app\", default) or org-level (\"org\"). When used inside entity_types[], scope is inherited from the entity type. Provisions a namespaces table with computed-name proxy, rename trigger, and entity-scoped RLS."},"BlueprintNode":{"anyOf":[{"$ref":"#/$defs/BlueprintNodeShorthand"},{"$ref":"#/$defs/BlueprintNodeObject"}],"description":"A node entry in a blueprint table. Either a string shorthand or a typed object."},"BlueprintNodeObject":{"type":"object","properties":{"data":{"type":"object"},"$type":{"enum":["AuthzAllowAll","AuthzAppMemberOwner","AuthzAppMembership","AuthzColumnSecurity","AuthzComposite","AuthzDatabaseClaim","AuthzDenyAll","AuthzDirectOwner","AuthzDirectOwnerAny","AuthzEntityMembership","AuthzFilePath","AuthzHumanOnly","AuthzMemberList","AuthzMemberOwner","AuthzNotReadOnly","AuthzOrgHierarchy","AuthzPeerOwnership","AuthzPublishable","AuthzRelatedEntityMembership","AuthzRelatedMemberList","AuthzRelatedMemberOwner","AuthzRelatedPeerOwnership","AuthzSystemOnly","AuthzTemporal","AuthzValueAllowed","AuthzValueExists","AuthzValueMatch","CheckGreaterThan","CheckLessThan","CheckNotEqual","CheckOneOf","CheckOwnedRelation","DataArchivable","DataBulk","DataCapabilities","DataCompositeField","DataDenormalized","DataDirectOwner","DataEntityMembership","DataFileRef","DataForceCurrentUser","DataGenerated","DataHistory","DataI18n","DataId","DataIdentity","DataImmutableFields","DataInflection","DataInheritFromParent","DataJsonb","DataLock","DataMemberOwner","DataOwnedFields","DataOwnershipInEntity","DataPeoplestamps","DataPrincipalstamps","DataPublishable","DataRealtime","DataSlug","DataSoftDelete","DataStatusField","DataTags","DataTimestamps","SearchBm25","SearchFullText","SearchSpatial","SearchSpatialAggregate","SearchTrgm","SearchUnified","SearchVector","TableOrganizationSettings","TableUserProfiles","TableUserSettings","EventReferral","EventTracker","GuardStepUp","JobTrigger","LimitEnforceAggregate","LimitEnforceCounter","LimitEnforceFeature","LimitEnforceRate","LimitTrackUsage","LimitWarningAggregate","LimitWarningCounter","LimitWarningRate","ProcessChunks","ProcessExtraction","ProcessFileEmbedding","ProcessImageEmbedding","ProcessImageVersions"]}},"additionalProperties":false,"required":["$type"],"allOf":[{"$ref":"#/$defs/shared-39f66ad592"},{"if":{"$ref":"#/$defs/shared-49ec07b1f5"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzAppMemberOwnerParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-21a1ba9587"},{"if":{"properties":{"$type":{"const":"AuthzColumnSecurity"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzColumnSecurityParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-6639e33d04"},{"$ref":"#/$defs/shared-36ea8e912e"},{"$ref":"#/$defs/shared-152f619c56"},{"if":{"$ref":"#/$defs/shared-47ab73adbe"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDirectOwnerParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-34021cf1ff"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDirectOwnerAnyParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-15602a740a"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzEntityMembershipParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-5f5453df14"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzFilePathParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-aced6572ca"},{"if":{"$ref":"#/$defs/shared-eff5f86cd2"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzMemberListParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-d91c021eee"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzMemberOwnerParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-2c17992067"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzNotReadOnlyParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-97d5c3be03"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzOrgHierarchyParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-b1dc7b2e4f"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzPeerOwnershipParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-6dbc2f5a83"},{"if":{"$ref":"#/$defs/shared-f93f3b8ac9"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedEntityMembershipParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-584ca266e8"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedMemberListParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-433a283165"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedMemberOwnerParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-5192cb016d"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedPeerOwnershipParams"}},"required":["data"]}},{"$ref":"#/$defs/shared-2997c2f821"},{"$ref":"#/$defs/shared-8881b94a41"},{"if":{"$ref":"#/$defs/shared-57b27779bd"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueAllowedParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-e23bde2ba6"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueExistsParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-3245b618eb"},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueMatchParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-2c20767ba3"},"then":{"properties":{"data":{"$ref":"#/$defs/CheckGreaterThanParams"}}}},{"if":{"$ref":"#/$defs/shared-8358853df2"},"then":{"properties":{"data":{"$ref":"#/$defs/CheckLessThanParams"}}}},{"if":{"$ref":"#/$defs/shared-1c8d46d43b"},"then":{"properties":{"data":{"$ref":"#/$defs/CheckNotEqualParams"}},"required":["data"]}},{"if":{"$ref":"#/$defs/shared-078ee82414"},"then":{"properties":{"data":{"$ref":"#/$defs/CheckOneOfParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"CheckOwnedRelation"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/CheckOwnedRelationParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataArchivable"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataArchivableParams"}}}},{"if":{"properties":{"$type":{"const":"DataBulk"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataBulkParams"}}}},{"if":{"properties":{"$type":{"const":"DataCapabilities"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataCapabilitiesParams"}}}},{"if":{"properties":{"$type":{"const":"DataCompositeField"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataCompositeFieldParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataDenormalized"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataDenormalizedParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataDirectOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataDirectOwnerParams"}}}},{"if":{"properties":{"$type":{"const":"DataEntityMembership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataEntityMembershipParams"}}}},{"if":{"properties":{"$type":{"const":"DataFileRef"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataFileRefParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataForceCurrentUser"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataForceCurrentUserParams"}}}},{"if":{"properties":{"$type":{"const":"DataGenerated"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataGeneratedParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataHistory"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataHistoryParams"}}}},{"if":{"properties":{"$type":{"const":"DataI18n"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataI18nParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataId"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataIdParams"}}}},{"if":{"properties":{"$type":{"const":"DataIdentity"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataIdentityParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataImmutableFields"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataImmutableFieldsParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataInflection"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataInflectionParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataInheritFromParent"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataInheritFromParentParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataJsonb"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataJsonbParams"}}}},{"if":{"properties":{"$type":{"const":"DataLock"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataLockParams"}}}},{"if":{"properties":{"$type":{"const":"DataMemberOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataMemberOwnerParams"}}}},{"if":{"properties":{"$type":{"const":"DataOwnedFields"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataOwnedFieldsParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"DataOwnershipInEntity"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataOwnershipInEntityParams"}}}},{"if":{"properties":{"$type":{"const":"DataPeoplestamps"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataPeoplestampsParams"}}}},{"if":{"properties":{"$type":{"const":"DataPrincipalstamps"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataPrincipalstampsParams"}}}},{"if":{"properties":{"$type":{"const":"DataPublishable"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataPublishableParams"}}}},{"if":{"properties":{"$type":{"const":"DataRealtime"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataRealtimeParams"}}}},{"if":{"properties":{"$type":{"const":"DataSlug"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataSlugParams"}}}},{"if":{"properties":{"$type":{"const":"DataSoftDelete"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataSoftDeleteParams"}}}},{"if":{"properties":{"$type":{"const":"DataStatusField"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataStatusFieldParams"}}}},{"if":{"properties":{"$type":{"const":"DataTags"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataTagsParams"}}}},{"if":{"properties":{"$type":{"const":"DataTimestamps"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/DataTimestampsParams"}}}},{"if":{"properties":{"$type":{"const":"SearchBm25"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchBm25Params"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"SearchFullText"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchFullTextParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"SearchSpatial"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchSpatialParams"}}}},{"if":{"properties":{"$type":{"const":"SearchSpatialAggregate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchSpatialAggregateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"SearchTrgm"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchTrgmParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"SearchUnified"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchUnifiedParams"}}}},{"if":{"properties":{"$type":{"const":"SearchVector"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/SearchVectorParams"}}}},{"if":{"properties":{"$type":{"const":"TableOrganizationSettings"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/TableOrganizationSettingsParams"}}}},{"if":{"properties":{"$type":{"const":"TableUserProfiles"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/TableUserProfilesParams"}}}},{"if":{"properties":{"$type":{"const":"TableUserSettings"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/TableUserSettingsParams"}}}},{"if":{"properties":{"$type":{"const":"EventReferral"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/EventReferralParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"EventTracker"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/EventTrackerParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"GuardStepUp"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/GuardStepUpParams"}}}},{"if":{"properties":{"$type":{"const":"JobTrigger"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/JobTriggerParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitEnforceAggregate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitEnforceAggregateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitEnforceCounter"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitEnforceCounterParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitEnforceFeature"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitEnforceFeatureParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitEnforceRate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitEnforceRateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitTrackUsage"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitTrackUsageParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitWarningAggregate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitWarningAggregateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitWarningCounter"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitWarningCounterParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"LimitWarningRate"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/LimitWarningRateParams"}},"required":["data"]}},{"if":{"properties":{"$type":{"const":"ProcessChunks"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessChunksParams"}}}},{"if":{"properties":{"$type":{"const":"ProcessExtraction"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessExtractionParams"}}}},{"if":{"properties":{"$type":{"const":"ProcessFileEmbedding"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessFileEmbeddingParams"}}}},{"if":{"properties":{"$type":{"const":"ProcessImageEmbedding"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessImageEmbeddingParams"}}}},{"if":{"properties":{"$type":{"const":"ProcessImageVersions"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/ProcessImageVersionsParams"}},"required":["data"]}}],"description":"Object form -- { $type, data } with typed parameters."},"BlueprintNodeShorthand":{"enum":["AuthzAllowAll","AuthzAppMemberOwner","AuthzAppMembership","AuthzColumnSecurity","AuthzComposite","AuthzDatabaseClaim","AuthzDenyAll","AuthzDirectOwner","AuthzDirectOwnerAny","AuthzEntityMembership","AuthzFilePath","AuthzHumanOnly","AuthzMemberList","AuthzMemberOwner","AuthzNotReadOnly","AuthzOrgHierarchy","AuthzPeerOwnership","AuthzPublishable","AuthzRelatedEntityMembership","AuthzRelatedMemberList","AuthzRelatedMemberOwner","AuthzRelatedPeerOwnership","AuthzSystemOnly","AuthzTemporal","AuthzValueAllowed","AuthzValueExists","AuthzValueMatch","CheckGreaterThan","CheckLessThan","CheckNotEqual","CheckOneOf","CheckOwnedRelation","DataArchivable","DataBulk","DataCapabilities","DataCompositeField","DataDenormalized","DataDirectOwner","DataEntityMembership","DataFileRef","DataForceCurrentUser","DataGenerated","DataHistory","DataI18n","DataId","DataIdentity","DataImmutableFields","DataInflection","DataInheritFromParent","DataJsonb","DataLock","DataMemberOwner","DataOwnedFields","DataOwnershipInEntity","DataPeoplestamps","DataPrincipalstamps","DataPublishable","DataRealtime","DataSlug","DataSoftDelete","DataStatusField","DataTags","DataTimestamps","SearchBm25","SearchFullText","SearchSpatial","SearchSpatialAggregate","SearchTrgm","SearchUnified","SearchVector","TableOrganizationSettings","TableUserProfiles","TableUserSettings","EventReferral","EventTracker","GuardStepUp","JobTrigger","LimitEnforceAggregate","LimitEnforceCounter","LimitEnforceFeature","LimitEnforceRate","LimitTrackUsage","LimitWarningAggregate","LimitWarningCounter","LimitWarningRate","ProcessChunks","ProcessExtraction","ProcessFileEmbedding","ProcessImageEmbedding","ProcessImageVersions"],"description":"String shorthand -- just the node type name."},"BlueprintPolicy":{"type":"object","properties":{"privileges":{"type":"array","minItems":1,"items":{"type":"string","pattern":"^([Ss][Ee][Ll][Ee][Cc][Tt]|[Ii][Nn][Ss][Ee][Rr][Tt]|[Uu][Pp][Dd][Aa][Tt][Ee]|[Dd][Ee][Ll][Ee][Tt][Ee])$"}},"permissive":{"type":"boolean"},"policy_role":{"type":"string"},"policy_name":{"type":"string"},"data":{"type":"object"},"with_check":{"$ref":"#/$defs/BlueprintPolicyWithCheck"},"$type":{"$ref":"#/$defs/shared-af38a22089"}},"additionalProperties":false,"required":["$type"],"allOf":[{"$ref":"#/$defs/shared-39f66ad592"},{"$ref":"#/$defs/shared-eb6d498d14"},{"$ref":"#/$defs/shared-21a1ba9587"},{"$ref":"#/$defs/shared-6639e33d04"},{"$ref":"#/$defs/shared-36ea8e912e"},{"$ref":"#/$defs/shared-152f619c56"},{"$ref":"#/$defs/shared-c893ee8510"},{"$ref":"#/$defs/shared-a2c45e97d1"},{"$ref":"#/$defs/shared-85b2c2543e"},{"$ref":"#/$defs/shared-e3e4ac8f48"},{"$ref":"#/$defs/shared-aced6572ca"},{"$ref":"#/$defs/shared-11809f0714"},{"$ref":"#/$defs/shared-a9d73b8ba7"},{"$ref":"#/$defs/shared-8e6e495eb6"},{"$ref":"#/$defs/shared-c2c61348f0"},{"$ref":"#/$defs/shared-4f25156f61"},{"$ref":"#/$defs/shared-6dbc2f5a83"},{"$ref":"#/$defs/shared-33013a269d"},{"$ref":"#/$defs/shared-0596961db6"},{"$ref":"#/$defs/shared-89ec3722aa"},{"$ref":"#/$defs/shared-1a97ddc6fb"},{"$ref":"#/$defs/shared-2997c2f821"},{"$ref":"#/$defs/shared-8881b94a41"},{"$ref":"#/$defs/shared-c88c54a5c5"},{"$ref":"#/$defs/shared-3fc6945ad1"},{"$ref":"#/$defs/shared-c1527c6159"}],"description":"An RLS policy entry for a blueprint table. A with_check override applies to UPDATE only.","if":{"required":["with_check"]},"then":{"required":["privileges"],"properties":{"privileges":{"items":{"type":"string","pattern":"^[Uu][Pp][Dd][Aa][Tt][Ee]$"}}}}},"BlueprintPolicyWithCheck":{"type":"object","properties":{"data":{"type":"object"},"$type":{"$ref":"#/$defs/shared-af38a22089"}},"additionalProperties":false,"required":["$type"],"allOf":[{"$ref":"#/$defs/shared-39f66ad592"},{"$ref":"#/$defs/shared-eb6d498d14"},{"$ref":"#/$defs/shared-21a1ba9587"},{"$ref":"#/$defs/shared-6639e33d04"},{"$ref":"#/$defs/shared-36ea8e912e"},{"$ref":"#/$defs/shared-152f619c56"},{"$ref":"#/$defs/shared-c893ee8510"},{"$ref":"#/$defs/shared-a2c45e97d1"},{"$ref":"#/$defs/shared-85b2c2543e"},{"$ref":"#/$defs/shared-e3e4ac8f48"},{"$ref":"#/$defs/shared-aced6572ca"},{"$ref":"#/$defs/shared-11809f0714"},{"$ref":"#/$defs/shared-a9d73b8ba7"},{"$ref":"#/$defs/shared-8e6e495eb6"},{"$ref":"#/$defs/shared-c2c61348f0"},{"$ref":"#/$defs/shared-4f25156f61"},{"$ref":"#/$defs/shared-6dbc2f5a83"},{"$ref":"#/$defs/shared-33013a269d"},{"$ref":"#/$defs/shared-0596961db6"},{"$ref":"#/$defs/shared-89ec3722aa"},{"$ref":"#/$defs/shared-1a97ddc6fb"},{"$ref":"#/$defs/shared-2997c2f821"},{"$ref":"#/$defs/shared-8881b94a41"},{"$ref":"#/$defs/shared-c88c54a5c5"},{"$ref":"#/$defs/shared-3fc6945ad1"},{"$ref":"#/$defs/shared-c1527c6159"}]},"BlueprintRelation":{"type":"object","description":"A relation entry in a blueprint definition.","properties":{"source_table":{"type":"string"},"target_table":{"type":"string"},"source_schema":{"type":"string"},"target_schema":{"type":"string"},"source_module":{"$ref":"#/$defs/BlueprintModuleTableRef"},"target_module":{"$ref":"#/$defs/BlueprintModuleTableRef"},"$type":{"enum":["RelationBelongsTo","RelationHasMany","RelationHasOne","RelationManyToMany","RelationSpatial"]}},"required":["$type"],"allOf":[{"if":{"properties":{"$type":{"const":"RelationBelongsTo"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"Table that will have the FK field added"},"target_table_id":{"$ref":"#/$defs/shared-db0e2e6361"},"field_name":{"type":"string","format":"column-ref","description":"FK field name on the source table. Auto-derived from target table name if omitted (e.g., projects → project_id)"},"delete_action":{"$ref":"#/$defs/shared-e6dbbbcd8d"},"is_required":{"type":"boolean","description":"Whether the FK field is NOT NULL","default":true}}}},{"if":{"properties":{"$type":{"const":"RelationHasMany"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"Parent table being referenced by the FK (e.g., projects in projects has many tasks)"},"target_table_id":{"type":"string","format":"uuid","description":"Child table that receives the FK field (e.g., tasks in projects has many tasks)"},"field_name":{"type":"string","format":"column-ref","description":"FK field name on the target table. Auto-derived from source table name if omitted (e.g., projects derives project_id)"},"delete_action":{"$ref":"#/$defs/shared-e6dbbbcd8d"},"is_required":{"type":"boolean","description":"Whether the FK field is NOT NULL","default":true}}}},{"if":{"properties":{"$type":{"const":"RelationHasOne"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"Table that will have the FK field and unique constraint"},"target_table_id":{"$ref":"#/$defs/shared-db0e2e6361"},"field_name":{"type":"string","format":"column-ref","description":"FK field name on the source table. Auto-derived from target table name if omitted (e.g., users → user_id)"},"delete_action":{"$ref":"#/$defs/shared-e6dbbbcd8d"},"is_required":{"type":"boolean","description":"Whether the FK field is NOT NULL","default":true}}}},{"if":{"properties":{"$type":{"const":"RelationManyToMany"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"First table in the M:N relationship"},"target_table_id":{"type":"string","format":"uuid","description":"Second table in the M:N relationship"},"junction_table_id":{"type":"string","format":"uuid","description":"Existing junction table to use. If uuid_nil(), a new bare table is created"},"junction_table_name":{"type":"string","description":"Junction table name. Auto-derived from both table names if omitted (e.g., projects + tags derives project_tags)"},"source_field_name":{"type":"string","format":"column-ref","description":"FK field name on junction for source table. Auto-derived if omitted (e.g., projects derives project_id)"},"target_field_name":{"type":"string","format":"column-ref","description":"FK field name on junction for target table. Auto-derived if omitted (e.g., tags derives tag_id)"},"use_composite_key":{"type":"boolean","description":"When true, creates a composite PK from the two FK fields. When false, no PK is created by the trigger (use nodes with DataId for UUID PK). Mutually exclusive with nodes containing DataId.","default":false},"nodes":{"type":"array","items":{"type":"object"},"description":"Array of node objects for field creation on junction table. Each object has a $type key (e.g. DataId, DataEntityMembership) and optional data keys. Forwarded to secure_table_provision as-is. Empty array means no additional fields."},"grants":{"type":"array","items":{"type":"object","properties":{"roles":{"type":"array","items":{"type":"string"}},"privileges":{"type":"array","items":{"type":"array","items":{"type":"string"}}}},"required":["roles","privileges"]},"description":"Unified grant objects for the junction table. Each entry is { roles: string[], privileges: string[][] }. Forwarded to secure_table_provision as-is. Default: []"},"policies":{"type":"array","items":{"type":"object","properties":{"$type":{"type":"string"},"data":{"type":"object"},"privileges":{"type":"array","items":{"type":"string"}},"policy_role":{"type":"string"},"permissive":{"type":"boolean"},"policy_name":{"type":"string"}},"required":["$type"]},"description":"RLS policy objects for the junction table. Each entry has $type (Authz* generator), optional data, privileges, policy_role, permissive, policy_name. Forwarded to secure_table_provision as-is. Default: []"}}}},{"if":{"properties":{"$type":{"const":"RelationSpatial"}},"required":["$type"]},"then":{"properties":{"source_table_id":{"type":"string","format":"uuid","description":"Table that owns the relation (the @spatialRelation tag is emitted on the owner column of this table)"},"source_field_id":{"type":"string","format":"uuid","description":"Geometry/geography column on source_table that carries the @spatialRelation smart tag"},"target_table_id":{"type":"string","format":"uuid","description":"Table being referenced by the spatial predicate"},"target_field_id":{"type":"string","format":"uuid","description":"Geometry/geography column on target_table that the predicate is evaluated against"},"name":{"type":"string","description":"Relation name (stable, snake_case). Becomes the generated filter field name in GraphQL (e.g. nearby_clinic). Unique per (source_table_id, name) — idempotency key."},"operator":{"type":"string","enum":["st_contains","st_within","st_intersects","st_covers","st_coveredby","st_overlaps","st_touches","st_dwithin"],"description":"PostGIS spatial predicate. One of the 8 whitelisted operators. st_dwithin requires param_name."},"param_name":{"type":"string","description":"Parameter name for parametric operators (currently only st_dwithin, which needs a distance argument). Must be NULL for all other operators. Enforced by table CHECK."},"source_field":{"type":"string"},"target_field":{"type":"string"}},"required":["source_field","target_field"]}}]},"BlueprintStorageConfig":{"type":"object","properties":{"scope":{"enum":["app","org"],"description":"Storage scope. \"app\" (default) creates app-level storage (no owner_id). \"org\" creates per-org/user storage (owner_id = org entity id, buckets seeded per-entity via AFTER INSERT trigger). Only \"app\" and \"org\" are allowed — child entity types get storage via entity_types[].storage."},"key":{"type":"string","description":"Module key discriminator. Defaults to \"default\" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_buckets. Max 16 chars, lowercase snake_case."},"storage_key":{"type":"string","description":"@deprecated Use `key` instead. Kept for backward compatibility."},"buckets":{"type":"array","items":{"$ref":"#/$defs/BlueprintBucketSeed"},"description":"Initial bucket seed entries. Each creates a row in {prefix}_buckets during provisioning."},"upload_url_expiry_seconds":{"type":"number","description":"Override for presigned upload URL expiry time in seconds."},"download_url_expiry_seconds":{"type":"number","description":"Override for presigned download URL expiry time in seconds."},"default_max_file_size":{"type":"number","description":"Default maximum file size in bytes for the storage module."},"allowed_origins":{"type":"array","items":{"type":"string"},"description":"CORS allowed origins for the storage module."},"confirm_upload_delay":{"type":"string","description":"Delay before the first upload confirmation attempt (PostgreSQL interval string, e.g. \"30 seconds\"). Defaults to \"30 seconds\"."},"staging":{"type":"boolean","description":"Provision a temporary staging bucket (type temp, tagged default-temp) that stages for the private default bucket, so uploads land there and are promoted into their destination on confirmation. Setting staging_ttl implies this. Defaults to false."},"staging_ttl":{"type":"string","description":"How long an unpromoted staged file survives before it is eligible for expiry (PostgreSQL interval string, e.g. \"24 hours\"). Implies staging. Defaults to \"24 hours\"."},"provisions":{"type":"object","properties":{"files":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"buckets":{"$ref":"#/$defs/BlueprintEntityTableProvision"}},"description":"Per-table overrides for storage tables. Each key targets a specific storage table (files, buckets) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision targeting the corresponding table. When a key includes policies[], those REPLACE the default storage policies for that table; tables without a key still get defaults."}},"description":"Storage configuration with optional scope. When used at the top level of a blueprint, the scope field controls whether storage is app-level (\"app\", default) or org-level (\"org\"). Seeds initial buckets, overrides module-level settings (expiry times, file size limits, CORS), and provides per-table provisioning overrides via provisions."},"BlueprintTable":{"type":"object","properties":{"table_name":{"type":"string","description":"The PostgreSQL table name to create. Required unless the entry carries a module reference instead."},"schema_name":{"type":"string","description":"Optional schema name (falls back to top-level default)."},"module":{"anyOf":[{"$ref":"#/$defs/BlueprintModuleTableRef"},{"$ref":"#/$defs/BlueprintModuleInstallRef"}],"description":"Attach this entry to a table an installed module generated instead of naming one, e.g. { type: \"agent\", scope: \"org\", table: \"message\" }. Mutually exclusive with table_name/schema_name. An entry carrying provisions names the install alone and leaves out table, since the provisions keys name the tables."},"provisions":{"type":"object","additionalProperties":{"$ref":"#/$defs/BlueprintEntityTableProvision"},"description":"Provision security onto the tables the referenced module generated, keyed by the module's own table keys (e.g. { registries: { policies: [...] } } for an image module). Requires a module reference without \"table\", since the keys name the tables. Each entry takes ownership of the security it declares: the grants/policies given become that table's whole set, replacing what the module installed — unlike this entry's own policies[]/grants[], which layer onto one table."},"nodes":{"type":"array","items":{"$ref":"#/$defs/BlueprintNode"},"description":"Array of node type entries that define the table's behavior. Omitted by an entry that only carries provisions or only attaches policies to a module table."},"fields":{"type":"array","items":{"$ref":"#/$defs/BlueprintField"},"description":"Custom fields (columns) to add to the table."},"policies":{"type":"array","items":{"$ref":"#/$defs/BlueprintPolicy"},"description":"RLS policies for this table."},"grants":{"type":"array","items":{"$ref":"#/$defs/shared-bc381c03de"},"description":"Unified grant objects. Each entry is { roles: string[], privileges: unknown[] } where privileges are [verb, columns] tuples (e.g. [[\"select\",\"*\"]]). Enables per-role targeting. Defaults to []."},"use_rls":{"type":"boolean","description":"Whether to enable RLS on this table. Defaults to true."},"indexes":{"type":"array","items":{"$ref":"#/$defs/BlueprintTableIndex"},"description":"Table-level indexes (table_name inherited from parent)."},"full_text_searches":{"type":"array","items":{"$ref":"#/$defs/BlueprintTableFullTextSearch"},"description":"Table-level full-text search configurations (table_name inherited from parent)."},"unique_constraints":{"type":"array","items":{"$ref":"#/$defs/BlueprintTableUniqueConstraint"},"description":"Table-level unique constraints (table_name inherited from parent)."},"check_constraints":{"type":"array","items":{"$ref":"#/$defs/BlueprintTableCheckConstraint"},"description":"Table-level CHECK constraints (table_name inherited from parent)."}},"description":"A table definition within a blueprint."},"BlueprintTableCheckConstraint":{"type":"object","properties":{"$type":{"enum":["CheckOneOf","CheckGreaterThan","CheckLessThan","CheckNotEqual"]}},"required":["$type"],"allOf":[{"if":{"$ref":"#/$defs/shared-078ee82414"},"then":{"type":"object","properties":{"$type":{"const":"CheckOneOf"},"name":{"$ref":"#/$defs/shared-757c15800e"},"data":{"$ref":"#/$defs/CheckOneOfParams","description":"The check node's parameters."},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["$type","name","data"]}},{"if":{"$ref":"#/$defs/shared-2c20767ba3"},"then":{"type":"object","properties":{"$type":{"const":"CheckGreaterThan"},"name":{"$ref":"#/$defs/shared-757c15800e"},"data":{"$ref":"#/$defs/CheckGreaterThanParams","description":"The check node's parameters."},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["$type","name","data"]}},{"if":{"$ref":"#/$defs/shared-8358853df2"},"then":{"type":"object","properties":{"$type":{"const":"CheckLessThan"},"name":{"$ref":"#/$defs/shared-757c15800e"},"data":{"$ref":"#/$defs/CheckLessThanParams","description":"The check node's parameters."},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["$type","name","data"]}},{"if":{"$ref":"#/$defs/shared-1c8d46d43b"},"then":{"type":"object","properties":{"$type":{"const":"CheckNotEqual"},"name":{"$ref":"#/$defs/shared-757c15800e"},"data":{"$ref":"#/$defs/CheckNotEqualParams","description":"The check node's parameters."},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["$type","name","data"]}}],"description":"A CHECK constraint nested inside a table definition (table_name not required)."},"BlueprintTableFullTextSearch":{"type":"object","properties":{"field":{"$ref":"#/$defs/shared-ee69c55731"},"sources":{"$ref":"#/$defs/shared-626b0c3c0b"},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["field","sources"],"description":"A full-text search configuration nested inside a table definition (table_name not required)."},"BlueprintTableIndex":{"type":"object","properties":{"column":{"$ref":"#/$defs/shared-0a22d2c3f6"},"columns":{"$ref":"#/$defs/shared-5a2832df1c"},"access_method":{"$ref":"#/$defs/shared-2a834ba4ff"},"is_unique":{"$ref":"#/$defs/shared-bb55f34041"},"name":{"$ref":"#/$defs/shared-f35a015b21"},"op_classes":{"$ref":"#/$defs/shared-22f38cc906"},"options":{"$ref":"#/$defs/shared-e772a2f2a5"},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["access_method"],"description":"An index definition nested inside a table definition (table_name not required)."},"BlueprintTableUniqueConstraint":{"type":"object","properties":{"columns":{"$ref":"#/$defs/shared-a0bfcadf85"},"schema_name":{"$ref":"#/$defs/shared-ad8f69741a"}},"required":["columns"],"description":"A unique constraint nested inside a table definition (table_name not required)."},"BlueprintUniqueConstraint":{"type":"object","properties":{"table_name":{"type":"string","description":"Table name this unique constraint belongs to."},"schema_name":{"$ref":"#/$defs/shared-6adc1df48e"},"columns":{"$ref":"#/$defs/shared-a0bfcadf85"}},"required":["table_name","columns"],"description":"A unique constraint definition within a blueprint (top-level, requires table_name)."},"CheckGreaterThanParams":{"type":"object","properties":{"column":{"$ref":"#/$defs/shared-33af0ede37"},"value":{"type":"number","description":"Threshold value for single-column comparison (column > value)","default":0},"columns":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Two columns for cross-column comparison (columns[0] > columns[1])","minItems":2,"maxItems":2}},"description":"Adds a CHECK constraint that validates a column value is greater than a threshold (single-column: column > value) or that one column is greater than another (cross-column: columns[0] > columns[1]). Compiled via AST helpers."},"CheckLessThanParams":{"type":"object","properties":{"column":{"$ref":"#/$defs/shared-33af0ede37"},"value":{"type":"number","description":"Threshold value for single-column comparison (column < value)"},"columns":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Two columns for cross-column comparison (columns[0] < columns[1])","minItems":2,"maxItems":2}},"description":"Adds a CHECK constraint that validates a column value is less than a threshold (single-column: column < value) or that one column is less than another (cross-column: columns[0] < columns[1]). Compiled via AST helpers."},"CheckNotEqualParams":{"type":"object","properties":{"columns":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Two columns that must not be equal","minItems":2,"maxItems":2}},"required":["columns"],"description":"Adds a CHECK constraint that validates two columns are not equal (columns[0] != columns[1]). Useful for preventing self-referencing rows. Compiled via AST helpers."},"CheckOneOfParams":{"type":"object","properties":{"column":{"type":"string","format":"column-ref","description":"Column to validate against the allowed values"},"values":{"type":"array","items":{"type":"string"},"description":"Array of allowed values for the column"}},"required":["column","values"],"description":"Adds a CHECK constraint that validates a column value is one of an allowed set (e.g. tier IN ('free', 'paid', 'custom')). Compiled to column = ANY(ARRAY[...]) via AST helpers."},"CheckOwnedRelationParams":{"type":"object","properties":{"link_schema_name":{"type":"string","description":"Schema holding the link tables the ownership is proven through"},"owner_scope":{"type":"string","description":"Scope that owns the referencing rows; matched against the link row's owner_scope (e.g. database, platform)"},"owner_key_field_name":{"type":"string","format":"column-ref","description":"Column on the referencing table carrying its scope key, matched against the link row's owner_key. NULL for a global scope, whose owner key is NULL by construction"},"pointers":{"type":"array","description":"Typed pointer columns to guard, each resolved through its own link table","items":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Pointer column on the referencing table"},"link_table_name":{"type":"string","description":"Link table in link_schema_name whose ids this column points at"},"target_type_field_name":{"type":"string","description":"Optional link column additionally restricted regardless of ownership (e.g. a bucket type)"},"target_type_value":{"type":"string","description":"Value target_type_field_name must equal"},"allow_owner_tier":{"type":"boolean","description":"Admit the same database's global-scope rows (app/platform, ownerless by construction) for this column, for pointers whose legal target set is a scope hierarchy within one database","default":false}},"required":["field_name","link_table_name"]}},"arity":{"type":"string","enum":["exactly_one","all","any"],"description":"How many pointers a row must set: exactly_one for a polymorphic target (route → api OR site OR bucket), all for a junction/join row of a has-and-belongs-to-many relation (and for a mandatory belongs-to), any for optional pointers that are only checked when set","default":"exactly_one"},"required_error":{"type":"string","description":"Error code raised when the arity rule over the pointers is violated","default":"OWNED_RELATION_TARGET_REQUIRED"},"denied_error":{"type":"string","description":"Error code raised when the target is not owned by the referencing row owner","default":"OWNED_RELATION_TARGET_NOT_OWNED"},"trigger_function_schema":{"type":"string","description":"Schema the guard trigger function is created in; defaults to the table schema"},"trigger_function_name":{"type":"string","description":"Guard trigger function name; defaults to tg_
_owned_relation_guard"},"trigger_name":{"type":"string","description":"Guard trigger name; defaults to
_owned_relation_guard"}},"required":["link_schema_name","owner_scope","pointers"],"description":"Declares that typed pointer columns may only reference rows owned by the same scope owner as the referencing row, proven through a link table that carries the owner (owner_scope, owner_key) — typically a catalog projection that must never be referenced structurally. Creates one BEFORE INSERT OR UPDATE trigger enforcing the declared arity over the pointers and requiring every pointer that is set to resolve to a same-owner row, so it covers belongs-to / has-one / has-many (key on the row being written) and has-and-belongs-to-many (both keys on the junction row, arity all). Visibility/publication flags are never an authorization input."},"DataArchivableParams":{"type":"object","properties":{"is_archived_field":{"type":"string","format":"column-ref","description":"Column name for the archive boolean flag","default":"is_archived"},"archived_at_field":{"type":"string","format":"column-ref","description":"Column name for the archive timestamp","default":"archived_at"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true}},"description":"Adds user-reversible archive support with is_archived boolean and archived_at timestamp, plus a partial index for efficient active-row queries."},"DataBulkParams":{"type":"object","properties":{"insert":{"type":"boolean","description":"Enable bulk insert (+bulkInsert)","default":true},"upsert":{"type":"boolean","description":"Enable bulk upsert (+bulkUpsert)","default":false},"update":{"type":"boolean","description":"Enable bulk update (+bulkUpdate)","default":false},"delete":{"type":"boolean","description":"Enable bulk delete (+bulkDelete)","default":false}},"description":"Enables bulk mutation smart tags on a table. When provisioned, adds @behavior tags for the selected bulk operations (insert, upsert, update, delete). Requires the graphile-bulk-mutations plugin."},"DataCapabilitiesParams":{"type":"object","properties":{"field":{"type":"string","format":"column-ref","description":"Name of the bit(n) mask column to create on this table.","default":"required_capabilities"},"capabilities":{"type":"string","description":"Selects the capabilities module whose bit numbering the mask is measured in, by scope (e.g. \"app\", \"org\") or by table prefix. Required only when the database has more than one; several with no selector raises naming the candidates."},"default":{"type":"array","items":{"type":"string"},"description":"Capability names every row requires unless told otherwise, resolved to a literal mask and baked into the column default. Omitted means a zero mask: requires nothing."},"mode":{"type":"string","enum":["direct","derived"],"description":"Who writes the mask: \"direct\" the writer, bounded by the subset guard; \"derived\" the mapping row named by from_column, stamped by generated triggers and hidden from mutations.","default":"direct"},"from_column":{"type":"string","format":"column-ref","description":"Derived mode only: the column on this table naming the mapping row to copy the mask from (e.g. classification_id)."},"mapping_table":{"type":"string","description":"Derived mode only: table holding one mask per class (e.g. document_classifications)."},"mapping_key":{"type":"string","format":"column-ref","description":"Derived mode only: column on the mapping table that from_column matches.","default":"id"},"mapping_column":{"type":"string","format":"column-ref","description":"Derived mode only: the mapping table's own bit(n) mask column. Created when absent, so a classification table needs no DataCapabilities declaration of its own. Defaults to the same name as field."},"subset_guard":{"type":"boolean","description":"Direct mode only: refuse a write requiring bits the writer does not hold, so nobody can lock a row away from everyone including themselves. Off is for trusted-writer tables only.","default":true},"entity_field":{"type":"string","format":"column-ref","description":"Direct mode only: the entity column the subset guard's membership check reads.","default":"entity_id"}},"description":"Per-row required permissions. A profile compiles a person to bits so no policy joins a profiles table; this compiles a row to bits so no policy joins a grant table either — the row carries the mask an actor must hold, and an AuthzEntityMembership policy with mask_column checks it as one bitwise subset test against the SPRT. The mask only narrows: it takes access away from someone membership already lets in, and never grants access to a non-member. Zero requires nothing, which is what an unclassified row defaults to. In direct mode the writer sets the mask and the subset guard bounds it to bits the writer holds; in derived mode it is copied from a mapping row (classification -> mask) by generated triggers, so authors edit one classification instead of every document."},"DataCompositeFieldParams":{"type":"object","properties":{"target":{"type":"string","format":"column-ref","description":"Name of the derived text field to create","default":"embedding_text"},"source_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Array of source field names to concatenate into the target field"},"format":{"type":"string","enum":["labeled","plain"],"description":"Output format: 'labeled' (field_name: value) or 'plain' (values only)","default":"labeled"}},"required":["source_fields"],"description":"Creates a derived text field that automatically concatenates multiple source fields via BEFORE INSERT/UPDATE triggers. Used to produce a unified text representation (e.g., embedding_text) from multiple columns on a table. The trigger fires with '_000' prefix to run before Search* triggers alphabetically."},"DataDenormalizedParams":{"type":"object","properties":{"field":{"type":"string","format":"column-ref","description":"FK field on this table that references the parent row (e.g. view_id)"},"set_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names on this table to be populated from the parent (e.g. [\"database_id\"])"},"ref_field":{"type":"string","format":"column-ref","description":"Field on the parent table that is the FK target (e.g. id)"},"ref_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names on the parent table to copy from (e.g. [\"database_id\"])"},"use_updates":{"type":"boolean","description":"If true, also creates an UPDATE trigger so changes to the FK re-copy values","default":true},"update_defaults":{"type":"boolean","description":"If true, sets the default value of set_fields to uuid_nil() so they are populated by the trigger","default":true},"func_name":{"type":"string","description":"Custom function name suffix (defaults to the FK field name)"},"func_order":{"type":"integer","description":"Trigger ordering (0-padded). Lower numbers fire first","default":0}},"required":["field","set_fields","ref_field","ref_fields"],"description":"Creates INSERT and UPDATE triggers that copy field values from a referenced (parent) table into the current table whenever the FK changes. Used to denormalize frequently-read columns (e.g. database_id on junction tables) so that RLS and queries can filter locally without joining."},"DataDirectOwnerParams":{"type":"object","properties":{"owner_field_name":{"type":"string","format":"column-ref","description":"Column name for owner ID","default":"owner_id"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds a foreign key constraint from owner_id to the users table","default":true},"create_index":{"type":"boolean","description":"If true, creates a B-tree index on the owner column","default":true}},"description":"Adds ownership column for direct user ownership. Enables AuthzDirectOwner authorization."},"DataEntityMembershipParams":{"type":"object","properties":{"entity_field_name":{"type":"string","format":"column-ref","description":"Column name for entity ID","default":"entity_id"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds a foreign key constraint from entity_id to the users table","default":true},"create_index":{"type":"boolean","description":"If true, creates a B-tree index on the entity column","default":true}},"description":"Adds entity reference for organization/group scoping. Enables AuthzEntityMembership, AuthzMembership, AuthzOrgHierarchy authorization."},"DataFileRefParams":{"type":"object","required":["field"],"properties":{"field":{"type":"string","format":"column-ref","pattern":"\\S","description":"The upload, image or attachment column to register"},"storage":{"type":"object","description":"The storage module the file lives in, selected by its scope and/or key; every key given must match exactly one module. When omitted, the table's scope column decides, and a table with no scope column uses the app's storage.","properties":{"scope":{"type":"string","pattern":"\\S","description":"Scope of the storage module, e.g. \"app\", \"org\" or an entity type's scope"},"key":{"type":"string","pattern":"\\S","description":"Key of the storage module, for a scope with more than one"}},"minProperties":1,"additionalProperties":false},"bucket":{"type":"string","pattern":"\\S","description":"Key of the bucket an upload resolves to. Set this or bucket_tags, not both."},"bucket_tags":{"type":"array","items":{"type":"string"},"description":"Tags of the bucket an upload resolves to. Set this or bucket, not both."},"is_public":{"type":"boolean","description":"With no bucket named, picks the default public (true) or private (false) bucket; with a bucket named, asserts that bucket is public or private. Omitted, the bucket alone decides."},"enforce_fk":{"type":"boolean","description":"Strict mode: a real foreign key beside the column. Not implemented yet, so the backend refuses true.","default":false}},"not":{"required":["bucket","bucket_tags"]},"description":"Registers an existing upload, image or attachment column as a managed reference to a files row: it records which storage module the file lives in and which bucket an upload resolves to, and the backend generates the sync trigger and the GC index from that. The column must be declared in fields[] first; the node creates no column."},"DataForceCurrentUserParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the field to force to current_user_id()","default":"actor_id"}},"description":"BEFORE INSERT trigger that forces a field to the value of jwt_public.current_user_id(). Prevents clients from spoofing the actor/uploader identity. The field value is always overwritten regardless of what the client provides."},"DataGeneratedParams":{"type":"object","properties":{"target":{"type":"string","format":"column-ref","description":"Name of the generated column to create"},"type":{"type":"object","description":"FieldType for the generated column (default: text)","default":{"name":"text"}},"kind":{"type":"string","enum":["expression","concat","slug","object_name","hash"],"description":"Preset for building the generation expression","default":"expression"},"generation_type":{"type":"string","enum":["stored","virtual"],"description":"Whether the column is STORED (persisted on write) or VIRTUAL (computed on read, PostgreSQL 18+)","default":"stored"},"source_field":{"type":"string","format":"column-ref","description":"Single source field for expression/slug/object_name presets"},"source_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Array of source field names for concat/hash presets"},"expression":{"type":"object","description":"Raw FieldGeneration DSL or AST (used when kind is expression)"},"separator":{"type":"string","description":"Separator used by concat preset","default":" "},"format":{"type":"string","enum":["labeled","plain"],"description":"Output format for concat preset: 'labeled' (field_name: value) or 'plain' (values only)","default":"plain"},"prefix":{"type":"string","description":"Optional prefix for object_name preset"},"suffix":{"type":"string","description":"Optional suffix for object_name preset"},"algorithm":{"type":"string","description":"Hash algorithm for hash preset (e.g. sha256, md5)","default":"sha256"},"is_required":{"type":"boolean","description":"Whether the generated column is NOT NULL","default":false}},"required":["target"],"description":"Creates a native PostgreSQL GENERATED ALWAYS AS (expr) column (STORED or VIRTUAL) from a source field expression, preset, or raw AST. The column is read-only for clients and computed automatically by PostgreSQL."},"DataHistoryParams":{"type":"object","properties":{"table_suffix":{"type":"string","description":"Suffix for the history table name","default":"_history"},"recorded_at_field":{"type":"string","format":"column-ref","description":"Column name for the version timestamp (also the partition key when partitioned)","default":"recorded_at"},"operation_field":{"type":"string","format":"column-ref","description":"Column name recording the operation ('INSERT' | 'UPDATE' | 'DELETE')","default":"history_op"},"exclude_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Source columns to omit from the history table (e.g. large jsonb or vector columns). Excluded columns are never created on the history table and never written by the trigger.","default":[]},"copy_mutation_policies":{"type":"boolean","description":"Whether to also clone INSERT/UPDATE/DELETE policies (not just SELECT). Default false — the history table is written only by the trigger and exposed read-only through GraphQL.","default":false},"partitioned":{"type":"boolean","description":"When true, range-partition the history table by recorded_at via pg_partman so old partitions can be dropped per the retention window.","default":false},"partition_interval":{"type":"string","description":"pg_partman partition interval (when partitioned)","default":"1 month"},"retention":{"type":"string","description":"pg_partman retention window; partitions older than this are dropped by run_maintenance (when partitioned). Empty keeps forever.","default":"12 months"},"premake":{"type":"integer","description":"Number of future partitions pg_partman pre-creates","default":2}},"description":"Creates a companion
_history table that records a new version row on every INSERT/UPDATE/DELETE via an AFTER trigger. The history table copies the source columns as plain nullable columns with NO keys or constraints, plus a recorded_at timestamp and a history_op column (NEW-append: INSERT/UPDATE store the new row, DELETE stores a tombstone). SELECT policies are cloned from the base table. Optionally range-partitions the history table by recorded_at (pg_partman) with a retention window so history is kept for a while but not forever. Adds an @history smart comment so the Graphile history plugin can expose version queries and restore mutations."},"DataI18nParams":{"type":"object","properties":{"fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names on the base table to make translatable. Each field is duplicated on the translation table with the same type."},"table_suffix":{"type":"string","description":"Suffix for the translation table name","default":"_translations"},"lang_code_type":{"type":"string","enum":["citext","text"],"description":"Type for the lang_code column","default":"citext"},"copy_mutation_policies":{"type":"boolean","description":"Whether to also copy INSERT/UPDATE/DELETE policies (not just SELECT). Default true — translations should be editable by the same users who can edit the base row.","default":true},"search":{"type":"object","description":"SearchFullText configuration for the translations table. When provided, creates a tsvector column on the translations table with lang_column=lang_code for dynamic per-row language stemming.","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the tsvector column on the translations table","default":"search"},"source_fields":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string","format":"column-ref","description":"Name of the translatable source column"},"weight":{"type":"string","enum":["A","B","C","D"],"description":"tsvector weight class (A=highest, D=lowest)","default":"D"}},"required":["field"]},"description":"Translatable columns that feed the tsvector. Language is determined dynamically from the lang_code column of each row."},"search_score_weight":{"type":"number","description":"Weight for this algorithm in composite searchScore","default":1}},"required":["source_fields"]}},"required":["fields"],"description":"Creates a companion _translations table with lang_code + translatable fields. Copies SELECT policies and column-ref fields from the base table. Adds @i18n smart comment so the Graphile i18n plugin discovers it. Requires i18n_module to be provisioned for the database."},"DataIdParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Column name for the primary key","default":"id"}},"description":"Adds a UUID primary key column with auto-generation default (uuidv7). This is the standard primary key pattern for all tables."},"DataIdentityParams":{"type":"object","properties":{"target":{"type":"string","format":"column-ref","description":"Name of the identity column to create"},"type":{"type":"object","description":"FieldType for the identity column (default: bigint)","default":{"name":"bigint"}},"generation":{"type":"string","enum":["always","by_default"],"description":"'always' for GENERATED ALWAYS AS IDENTITY, 'by_default' for GENERATED BY DEFAULT AS IDENTITY","default":"by_default"},"sequence":{"type":"object","description":"Optional sequence tuning for the backing identity sequence","properties":{"start":{"type":"integer","description":"START WITH value"},"increment":{"type":"integer","description":"INCREMENT BY value"},"min":{"type":["integer","null"],"description":"MINVALUE (null uses the default)"},"max":{"type":["integer","null"],"description":"MAXVALUE (null uses the default)"},"cache":{"type":"integer","description":"CACHE value"},"cycle":{"type":"boolean","description":"Whether the sequence cycles (CYCLE / NO CYCLE)"}}},"is_required":{"type":"boolean","description":"Whether the identity column is NOT NULL (identity columns are implicitly NOT NULL)","default":false}},"required":["target"],"description":"Creates a native PostgreSQL identity column (GENERATED ALWAYS / BY DEFAULT AS IDENTITY) backed by an implicit sequence. The database assigns values automatically; ALWAYS identity columns are not writable by clients."},"DataImmutableFieldsParams":{"type":"object","properties":{"fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names that cannot be modified after INSERT (e.g. [\"key\", \"bucket_id\", \"owner_id\"])"}},"required":["fields"],"description":"BEFORE UPDATE trigger that prevents changes to a list of specified fields after INSERT. Raises an exception if any of the listed fields have changed. Unlike FieldImmutable (single-field), this handles multiple fields in a single trigger for efficiency."},"DataInflectionParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the field to transform"},"ops":{"type":"array","items":{"type":"string","enum":["plural","singular","camel","pascal","dashed","slugify","underscore","lower","upper"]},"description":"Inflection operations to apply in order"}},"required":["field_name","ops"],"description":"Transforms field values using inflection operations (snake_case, camelCase, slugify, plural, singular, etc). Attaches BEFORE INSERT and BEFORE UPDATE triggers. References fields by name in data jsonb."},"DataInheritFromParentParams":{"type":"object","properties":{"parent_fk_field":{"type":"string","format":"column-ref","description":"Name of the FK field on this table that references the parent (e.g. bucket_id)"},"fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names to copy from the parent row (e.g. [\"owner_id\", \"is_public\"])"},"parent_table":{"type":"string","description":"Parent table name (optional fallback if FK not yet registered in metaschema)"},"parent_schema":{"type":"string","description":"Parent table schema (optional, defaults to same schema as child table)"}},"required":["parent_fk_field","fields"],"description":"BEFORE INSERT trigger that copies specified fields from a parent table via a foreign key. The parent row is looked up through RLS (SECURITY INVOKER), so the insert fails if the caller cannot see the parent. Used by the storage module to inherit owner_id and is_public from buckets to files."},"DataJsonbParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Column name for the JSONB field","default":"metadata"},"default_value":{"$ref":"#/$defs/FieldDefault","description":"Default value as a FieldDefault object"},"is_required":{"type":"boolean","description":"Whether the column has a NOT NULL constraint","default":false},"create_index":{"type":"boolean","description":"Whether to create a GIN index","default":true}},"description":"Adds a JSONB column with optional GIN index for containment queries (@>, ?, ?|, ?&). Standard pattern for semi-structured metadata."},"DataLockParams":{"type":"object","properties":{"lock_field":{"type":"string","format":"column-ref","description":"Boolean column holding the lock state","default":"locked"},"events":{"type":"array","items":{"type":"string","enum":["UPDATE","DELETE"]},"description":"Which DML events are guarded while the row is locked. INSERT is not lockable — a row cannot be locked before it exists.","default":["DELETE"]},"enforcement":{"type":"string","enum":["step_up","block"],"description":"How a guarded verb is stopped while locked. step_up requires recent strong verification (needs a provisioned user_auth_module); block refuses the verb outright with ROW_LOCKED until unlocked.","default":"step_up"},"step_up_type":{"type":"string","enum":["password","mfa","fresh_auth","password_or_mfa"],"description":"Verification method satisfying the step-up requirement, for the guarded verbs in step_up mode and for clearing the lock","default":"fresh_auth"},"guard_unlock":{"type":"boolean","description":"Require step-up to change the lock column itself, so a locked row cannot be quietly unlocked and then deleted. Redundant (and therefore skipped) in step_up mode when UPDATE is already guarded.","default":true},"protect_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"For a guarded UPDATE, restrict the guard to changes touching these columns. Empty guards the whole row.","default":[]},"default_locked":{"type":"boolean","description":"Initial value of the lock column for new rows","default":false},"min_age":{"type":"string","description":"Optional interval (e.g. \"24 hours\"); in step_up mode the guard only fires for rows older than this, so freshly created rows stay easy to clean up. Empty guards rows of any age.","default":""}},"description":"Adds a boolean lock column and guards mutations while a row is locked, so infrastructure rows other things depend on (a bucket a function needs, a route, a resource) are not deleted or edited by accident. Two enforcement modes: step_up requires recent strong verification (via GuardStepUp / require_step_up) for the guarded verbs, while block refuses them outright until the row is unlocked. Clearing the lock is itself step-up guarded, so unlocking is a deliberate, re-authenticated step rather than a silent prelude to deletion."},"DataMemberOwnerParams":{"type":"object","properties":{"owner_field_name":{"type":"string","format":"column-ref","description":"Column name for the owner reference","default":"owner_id"},"entity_field_name":{"type":"string","format":"column-ref","description":"Column name for the entity reference","default":"entity_id"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds foreign key constraints from owner_id and entity_id to the users table","default":true},"create_index":{"type":"boolean","description":"If true, creates B-tree indexes on the owner and entity columns","default":true},"entity_type":{"type":"string","description":"Scope name for SPRT resolution (e.g. 'org', 'room'). Resolved to a membership type via the database's membership_types_module. This is the authoring form — use it instead of membership_type."},"membership_type":{"type":"integer","description":"Resolved membership type for SPRT resolution. Internal: prefer entity_type. Cannot be combined with entity_type.","default":null}},"description":"Adds owner_id and entity_id columns with a compound AuthzMemberOwner policy. The actor must own the row (owner_id = current_user_id()) AND be a member of the entity (entity_id in SPRT). Use for private data within an entity scope — e.g., personal chat threads that belong to the company but only the author can see."},"DataOwnedFieldsParams":{"type":"object","properties":{"role_key_field_name":{"type":"string","format":"column-ref","description":"Name of the field identifying the owner (e.g. sender_id)"},"protected_field_names":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Names of fields only this owner can modify"}},"required":["role_key_field_name","protected_field_names"],"description":"Restricts which user can modify specific columns in shared objects. Creates an AFTER UPDATE trigger that throws OWNED_PROPS when a non-owner tries to change protected fields. References fields by name in data jsonb."},"DataOwnershipInEntityParams":{"type":"object","properties":{"owner_field_name":{"type":"string","format":"column-ref","description":"Column name for the owner reference","default":"owner_id"},"entity_field_name":{"type":"string","format":"column-ref","description":"Column name for the entity reference","default":"entity_id"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds foreign key constraints from owner_id and entity_id to the users table","default":true},"create_index":{"type":"boolean","description":"If true, creates B-tree indexes on the owner and entity columns","default":true}},"description":"Combines direct ownership with entity scoping. Adds both owner_id and entity_id columns. Enables AuthzDirectOwner, AuthzEntityMembership, and AuthzOrgHierarchy authorization. Particularly useful for OrgHierarchy where a user owns a row (owner_id) within an entity (entity_id), and managers above can see subordinate-owned records via the hierarchy closure table."},"DataPeoplestampsParams":{"type":"object","properties":{"created_by_field":{"type":"string","format":"column-ref","description":"Column name for the creating user reference","default":"created_by"},"updated_by_field":{"type":"string","format":"column-ref","description":"Column name for the last-updating user reference","default":"updated_by"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"include_user_fk":{"type":"boolean","description":"If true, adds foreign key constraints from created_by and updated_by to the users table","default":false},"create_index":{"type":"boolean","description":"If true, creates B-tree indexes on the peoplestamp columns","default":true}},"description":"Adds human actor tracking for creates/updates: created_by/updated_by record the human user (jwt_public.current_user_id())."},"DataPrincipalstampsParams":{"type":"object","properties":{"created_by_principal_field":{"type":"string","format":"column-ref","description":"Column name for the creating principal reference (agent, API key, or user)","default":"created_by_principal"},"updated_by_principal_field":{"type":"string","format":"column-ref","description":"Column name for the last-updating principal reference (agent, API key, or user)","default":"updated_by_principal"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true},"create_index":{"type":"boolean","description":"If true, creates B-tree indexes on the principalstamp columns","default":true}},"description":"Adds acting-principal tracking for creates/updates: created_by_principal/updated_by_principal record the acting principal — agent, API key, service identity, or the user itself (jwt_public.current_principal_id())."},"DataPublishableParams":{"type":"object","properties":{"is_published_field_name":{"type":"string","format":"column-ref","description":"Column name for the published boolean flag","default":"is_published"},"published_at_field_name":{"type":"string","format":"column-ref","description":"Column name for the publish timestamp","default":"published_at"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true}},"description":"Adds publish state columns (is_published, published_at) for content visibility. Enables AuthzPublishable and AuthzTemporal authorization."},"DataRealtimeParams":{"type":"object","properties":{"operations":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"Which DML operations to track with emit_change triggers","default":["INSERT","UPDATE","DELETE"]},"subscriber_table_name":{"type":"string","description":"Custom name for the subscriber table (defaults to {source_table}_subscriber)"},"ephemeral":{"type":"boolean","description":"When true, events are delivered via pg_notify only without writing to change_log. Ideal for high-frequency ephemeral signals (e.g. cursor positions, live indicators) where persistence is unnecessary. Subscriber table and RLS policies are still created for access control.","default":false}},"description":"Creates per-table subscriber tables in subscriptions_public with RLS policies derived from source table SELECT policies. Attaches statement-level triggers to emit changes to subscribers."},"DataSlugParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the field to slugify","default":"slug"},"source_field_name":{"type":"string","format":"column-ref","description":"Optional source field name (defaults to field_name)"}},"required":[],"description":"Auto-generates URL-friendly slugs from field values on insert/update. Attaches BEFORE INSERT and BEFORE UPDATE triggers that call inflection.slugify() on the target field. References fields by name in data jsonb."},"DataSoftDeleteParams":{"type":"object","properties":{"deleted_at_field":{"type":"string","format":"column-ref","description":"Column name for the soft-delete timestamp","default":"deleted_at"},"is_deleted_field":{"type":"string","format":"column-ref","description":"Column name for the soft-delete boolean flag","default":"is_deleted"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true}},"description":"Adds soft delete support with deleted_at and is_deleted columns."},"DataStatusFieldParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Column name for the status field","default":"status"},"type":{"$ref":"#/$defs/FieldType","description":"Column type as a FieldType object"},"default_value":{"$ref":"#/$defs/FieldDefault","description":"Default value as a FieldDefault object (e.g., { value: \"active\" })"},"is_required":{"type":"boolean","description":"Whether the column has a NOT NULL constraint","default":true},"allowed_values":{"type":"array","items":{"type":"string"},"description":"If provided, creates a CHECK constraint restricting the column to these values"}},"description":"Adds a status column with B-tree index for efficient equality filtering and sorting. Optionally constrains values via CHECK constraint when allowed_values is provided."},"DataTagsParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Column name for the tags array","default":"tags"},"default_value":{"$ref":"#/$defs/FieldDefault","description":"Default value as a FieldDefault object"},"is_required":{"type":"boolean","description":"Whether the column has a NOT NULL constraint","default":false}},"description":"Adds a citext[] tags column with GIN index for efficient array containment queries (@>, &&). Standard tagging pattern for categorization and filtering."},"DataTimestampsParams":{"type":"object","properties":{"created_at_field":{"type":"string","format":"column-ref","description":"Column name for the creation timestamp","default":"created_at"},"updated_at_field":{"type":"string","format":"column-ref","description":"Column name for the last-updated timestamp","default":"updated_at"},"include_id":{"type":"boolean","description":"If true, also adds a UUID primary key column with auto-generation","default":true}},"description":"Adds automatic timestamp tracking with created_at and updated_at columns."},"EventReferralParams":{"type":"object","properties":{"event_name":{"type":"string","description":"Event type name to record for the referrer (e.g., \"invitee_uploaded_avatar\", \"invitee_completed_onboarding\")"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"DML events that trigger recording","default":["INSERT"]},"actor_field":{"type":"string","format":"column-ref","description":"Column containing the invitee (actor) ID on the source table — used to look up the referrer via claimed_invites.receiver_id","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","description":"Column containing the entity ID (org/group) for entity-scoped referral events. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup. Omit for user-only events."},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"max_depth":{"type":"integer","description":"Maximum depth to walk up the invite chain. Default 1 (direct inviter only). Set 2–10 to enable multi-level referral rewards. App-level only — must not be combined with entity_field.","default":1,"minimum":1,"maximum":10},"auto_register_type":{"type":"boolean","description":"Automatically register the event_name in event_types during provisioning","default":true},"condition_field":{"$ref":"#/$defs/shared-88656ecafa"},"condition_value":{"$ref":"#/$defs/shared-f7ad90b1e2"},"conditions":{"$ref":"#/$defs/shared-cc52e308f2"},"watch_fields":{"$ref":"#/$defs/shared-fe3f452ee5"}},"required":["event_name"],"description":"Creates triggers that record events for the referrer (inviter) when their invitees perform actions on a watched table. Resolves the referrer automatically via the invites module's claimed_invites table using the membership_type context. Supports the same compound condition system as EventTracker. Use with achievements to unlock levels and grant credits based on invitee activity."},"EventTrackerParams":{"type":"object","properties":{"event_name":{"type":"string","description":"Event type name to record (e.g., \"avatar_uploaded\", \"order_completed\")"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"DML events that trigger recording","default":["INSERT"]},"count":{"type":"integer","description":"Number of events to record per trigger fire","default":1},"toggle":{"type":"boolean","description":"Toggle mode: records event when condition is met, removes when condition is unmet","default":false},"actor_field":{"type":"string","format":"column-ref","description":"Column containing the actor (user) ID to attribute the event to","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","description":"Column containing the entity ID (org/group) for entity-scoped events. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup. Omit for user-only events."},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"auto_register_type":{"type":"boolean","description":"Automatically register the event_name in event_types during provisioning","default":true},"condition_field":{"$ref":"#/$defs/shared-88656ecafa"},"condition_value":{"$ref":"#/$defs/shared-f7ad90b1e2"},"conditions":{"$ref":"#/$defs/shared-cc52e308f2"},"watch_fields":{"$ref":"#/$defs/shared-fe3f452ee5"}},"required":["event_name"],"description":"Creates triggers that record events via the events module when table rows change. Supports the same compound condition system as JobTrigger (condition_field, watch_fields, or full AND/OR/NOT conditions). Events are recorded to app_events and aggregated automatically. Use with achievements (blueprint-level) to unlock levels and grant credits based on event accumulation."},"FieldDefault":{"type":"object","description":"A structured default expression, e.g. { value: false }, { function: \"now\" } or { value: {}, cast: { name: \"jsonb\" } }.","properties":{"value":{"description":"Literal value."},"function":{"type":"string","description":"Function name."},"schema":{"type":"string","description":"Schema qualifier of the function."},"args":{"type":"array","items":{"anyOf":[{"type":["string","number","boolean","null"]},{"$ref":"#/$defs/FieldDefault"}]},"description":"Function arguments."},"cast":{"$ref":"#/$defs/FieldType"},"operator":{"type":"string","description":"Binary operator, e.g. \"+\"."},"left":{"$ref":"#/$defs/FieldDefault"},"right":{"$ref":"#/$defs/FieldDefault"},"sql_keyword":{"type":"string","description":"SQL keyword, e.g. \"CURRENT_TIMESTAMP\"."}}},"FieldType":{"type":"object","description":"A structured PostgreSQL type, e.g. { name: \"text\" } or { name: \"numeric\", args: [10, 2] }.","properties":{"name":{"type":"string","description":"Type name."},"schema":{"type":"string","description":"Schema qualifier."},"args":{"type":"array","items":{"type":["string","number","boolean"]},"description":"Type arguments."},"array_dimensions":{"type":"integer","description":"Number of array dimensions: 1 is text[]."},"range":{"type":"array","items":{"type":"string"},"maxItems":2,"description":"Interval field range, e.g. [\"day\", \"second\"]."}},"required":["name"]},"GuardStepUpParams":{"type":"object","properties":{"step_up_type":{"type":"string","enum":["password","mfa","fresh_auth","password_or_mfa"],"description":"Which recent proof satisfies the step-up requirement: password (password re-entry), mfa (second factor), password_or_mfa (either factor; an SSO sign-in alone does not count), or fresh_auth (any recent sign-in or re-verification, including SSO, magic link and OTP)","default":"fresh_auth"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"Which DML events require step-up verification","default":["UPDATE","DELETE"]},"condition_field":{"$ref":"#/$defs/shared-88656ecafa"},"condition_value":{"$ref":"#/$defs/shared-f7ad90b1e2"},"conditions":{"$ref":"#/$defs/shared-cc52e308f2"},"watch_fields":{"$ref":"#/$defs/shared-fe3f452ee5"}},"required":[],"description":"Attaches a BEFORE trigger that calls require_step_up() to enforce recent strong verification (password, MFA, or identity-provider assertion) before allowing mutations. Requires a provisioned sessions_module (with app_settings_auth) for the target database. The step_up_window is read from app_settings_auth at runtime (default 30 minutes). Supports compound conditions (AND/OR/NOT), watch_fields (fire only when specific fields change), and simple condition_field/condition_value leaf conditions."},"JobTriggerParams":{"type":"object","properties":{"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier passed to add_job (e.g., process_invoice, sync_to_stripe). Must match a registered function definition when function_module is installed."},"payload_strategy":{"type":"string","enum":["row","row_id","fields","custom"],"description":"How to build the job payload: row (full NEW/OLD), row_id (just id), fields (selected columns), custom (mapped columns)","default":"row_id"},"payload_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Column names to include in payload (only for fields strategy)"},"payload_custom":{"type":"object","additionalProperties":{"type":"string","format":"column-ref"},"description":"Key-to-column mapping for custom payload (e.g., {\"invoice_id\": \"id\", \"total\": \"amount\"})"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-eb860e1011"},"description":"Trigger events to create","default":["INSERT","UPDATE"]},"include_old":{"type":"boolean","description":"Include OLD row in payload (for UPDATE triggers)","default":false},"include_meta":{"type":"boolean","description":"Include table/schema metadata in payload","default":false},"condition_field":{"$ref":"#/$defs/shared-88656ecafa"},"condition_value":{"$ref":"#/$defs/shared-f7ad90b1e2"},"conditions":{"$ref":"#/$defs/shared-cc52e308f2"},"watch_fields":{"$ref":"#/$defs/shared-fe3f452ee5"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the trigger table that holds (or references) the entity_id for billing scope. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup."},"entity_lookup":{"type":"object","description":"FK lookup configuration for resolving entity_id through a related table. Used when entity_field is a FK (e.g., channel_id) rather than a direct entity_id. The generator validates all fields against metaschema within the same database_id.","properties":{"obj_table":{"$ref":"#/$defs/shared-6b829f5502"},"obj_schema":{"$ref":"#/$defs/shared-11a9ffe32a"},"obj_field":{"type":"string","format":"column-ref","description":"Column on the related table that holds the entity_id (e.g., \"entity_id\"). Required."}},"required":["obj_table","obj_field"]},"job_key":{"type":"string","description":"Static job key for upsert semantics (prevents duplicate jobs)"},"queue_name":{"type":"string","description":"Job queue name for routing to specific workers"},"priority":{"type":"integer","description":"Job priority (lower = higher priority)","default":0},"run_at_delay":{"type":"string","description":"Delay before job runs as PostgreSQL interval (e.g., 30 seconds, 5 minutes)"},"max_attempts":{"type":"integer","description":"Maximum retry attempts for the job","default":25}},"required":["task_identifier"],"description":"Dynamically creates PostgreSQL triggers that enqueue jobs via app_jobs.add_job() when table rows are inserted, updated, or deleted. Supports configurable payload strategies (full row, row ID, selected fields, or custom mapping), conditional firing via WHEN clauses, watched field changes, and extended job options (queue, priority, delay, max attempts)."},"LimitEnforceAggregateParams":{"type":"object","properties":{"limit_name":{"type":"string","description":"Name of the aggregate limit to track (must match a default_limits entry, e.g. \"databases\", \"members\")"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"org\", \"data_room\", \"channel\", \"team\").","default":"org"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for aggregate limit lookup. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-6eb30390ff"},"description":"Which DML events to attach triggers for","default":["INSERT","DELETE"]}},"required":["limit_name"],"description":"Declaratively attaches aggregate limit-tracking triggers to a table. On INSERT the named limit is incremented per entity; on DELETE it is decremented. Uses org_limit_aggregates_inc/dec for per-entity (org-level) aggregate limits rather than per-user limits. Requires a provisioned limits_module for the target database."},"LimitEnforceCounterParams":{"type":"object","properties":{"limit_name":{"type":"string","description":"Name of the limit to track (must match a default_limits entry, e.g. \"projects\", \"members\")"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"app\", \"org\", \"data_room\", \"channel\", \"team\").","default":"app"},"actor_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds the actor or entity id used for limit lookup","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for entity context resolution. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup."},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"events":{"type":"array","items":{"$ref":"#/$defs/shared-6eb30390ff"},"description":"Which DML events to attach triggers for","default":["INSERT","DELETE"]}},"required":["limit_name"],"description":"Declaratively attaches limit-tracking triggers to a table. On INSERT the named limit is incremented; on DELETE it is decremented. Requires a provisioned limits_module for the target scope."},"LimitEnforceFeatureParams":{"type":"object","properties":{"feature_name":{"type":"string","description":"Cap name representing this feature (must match a limit_caps_defaults entry with max=0 or max=1)"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"app\", \"org\", \"data_room\", \"channel\", \"team\").","default":"app"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for per-entity cap lookups (only used for org scope). For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"}},"required":["feature_name"],"description":"Gates a table behind a feature flag backed by the cap tables. Attaches a BEFORE INSERT trigger that checks whether the named feature cap value is > 0. Features are modeled as caps with max=0 (disabled) or max=1 (enabled) in limit_caps / limit_caps_defaults tables. Resolution: COALESCE(per-entity cap, scope default, 0)."},"LimitEnforceRateParams":{"type":"object","properties":{"meter_slug":{"type":"string","description":"Slug of the billing meter to check rate limits against (must match a meters table entry, e.g. \"messaging\", \"inference\")"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for rate limiting. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"actor_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds the actor id (user) for rate limiting","default":"owner_id"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Which DML events to enforce rate limits on (DELETE is excluded since it reduces load)","default":["INSERT"]}},"required":["meter_slug"],"description":"Attaches a BEFORE trigger that calls check_rate_limit() to enforce sliding-window rate limits before allowing mutations. The function checks all three scopes (entity, actor-in-entity, actor) in a single call; which scopes are actually enforced is controlled by what rows exist in rate_window_limits (plan-based config). Requires a provisioned meter_rate_limits_module and billing_module for the target database."},"LimitTrackUsageParams":{"type":"object","properties":{"meter_slug":{"type":"string","description":"Slug of the billing meter to record usage against (must match a meters table entry, e.g. \"databases\", \"seats\")"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for billing. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"quantity":{"type":"integer","description":"Units to record per event (default 1)","default":1},"events":{"type":"array","items":{"$ref":"#/$defs/shared-6eb30390ff"},"description":"Which DML events to attach triggers for","default":["INSERT","DELETE"]}},"required":["meter_slug"],"description":"Declaratively attaches billing usage-recording triggers to a table. On INSERT the named meter is incremented via record_usage; on DELETE it is decremented (reversal). On UPDATE, if the entity_field changes, the old entity is decremented and the new entity is incremented. Requires a provisioned billing_module for the target database."},"LimitWarningAggregateParams":{"type":"object","properties":{"limit_name":{"type":"string","description":"Name of the aggregate limit to watch (must match a limit_warnings.name entry, e.g. \"databases\", \"members\")"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"org\", \"data_room\", \"channel\", \"team\").","default":"org"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for aggregate limit lookup. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"}},"required":["limit_name"],"description":"Attaches an AFTER INSERT trigger that checks if the entity's aggregate usage has crossed any warning threshold configured in the limit_warnings table. If a threshold is reached for the first time, enqueues a background job (e.g. email notification). Uses limit_warning_state for one-time dedup per warning/actor/entity triple. Requires a provisioned limits_module with limit_warnings and aggregate limits enabled."},"LimitWarningCounterParams":{"type":"object","properties":{"limit_name":{"type":"string","description":"Name of the limit to watch (must match a limit_warnings.name entry, e.g. \"projects\", \"members\")"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"app\", \"org\", \"data_room\", \"channel\", \"team\").","default":"app"},"actor_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds the actor id for limit lookup","default":"owner_id"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id. When provided, entity_id is included in the job payload and dedup state. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup."},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"}},"required":["limit_name"],"description":"Attaches an AFTER INSERT trigger that checks if the actor's current usage has crossed any warning threshold configured in the limit_warnings table. If a threshold is reached for the first time, enqueues a background job (e.g. email notification). Uses limit_warning_state for one-time dedup per warning/actor pair. Requires a provisioned limits_module with limit_warnings enabled."},"LimitWarningRateParams":{"type":"object","properties":{"meter_slug":{"type":"string","description":"Slug of the billing meter to check rate limits against (must match a meters table entry)"},"scope":{"type":"string","description":"Membership type prefix that determines which limits_module row to use for warnings and warning_state tables. Resolved dynamically via memberships_module — supports any provisioned type (e.g. \"app\", \"org\", \"data_room\", \"channel\", \"team\").","default":"app"},"entity_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds (or references) the entity id for rate limit lookup. For direct entity_id columns, just set this field. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup.","default":"entity_id"},"entity_lookup":{"$ref":"#/$defs/shared-230094622e"},"actor_field":{"type":"string","format":"column-ref","description":"Column on the target table that holds the actor id for rate limit lookup","default":"owner_id"}},"required":["meter_slug"],"description":"Attaches an AFTER INSERT trigger that checks if the actor's current request count in the active sliding window has crossed any warning threshold configured in the limit_warnings table. If a threshold is reached for the first time, enqueues a background job (e.g. email notification). Uses limit_warning_state for one-time dedup per warning/actor pair. Requires both a limits_module with limit_warnings enabled and a rate_limit_meters_module."},"ProcessChunksParams":{"type":"object","properties":{"content_field_name":{"type":"string","format":"column-ref","description":"Name of the text content column in the chunks table","default":"content"},"chunk_size":{"type":"integer","description":"Maximum number of characters per chunk","default":1000},"chunk_overlap":{"type":"integer","description":"Number of overlapping characters between consecutive chunks","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"description":"Strategy for splitting text into chunks","default":"paragraph"},"dimensions":{"type":"integer","description":"Vector dimensions for per-chunk embeddings","default":768},"metric":{"type":"string","enum":["cosine","l2","ip"],"description":"Distance metric for the HNSW index on chunk embeddings","default":"cosine"},"embedding_model":{"type":"string","description":"Embedding model identifier for per-chunk embeddings. When null, the worker falls back to runtime config (llm_module / env vars)."},"embedding_provider":{"$ref":"#/$defs/shared-ac9a0977fa"},"chunks_table_name":{"type":"string","description":"Override the chunks table name. Defaults to {parent_table}_chunks."},"metadata_fields":{"type":"array","items":{"type":"string"},"description":"Field names from the parent table to copy into chunk metadata"},"search_indexes":{"type":"array","items":{"$ref":"#/$defs/shared-5492e6a87c"},"description":"Text search indexes to create on the chunks content column. Omit to mirror the parent table's text search indexes. Set explicitly to override (e.g. [\"fulltext\", \"bm25\"])."},"entity_field":{"type":"string","format":"column-ref","description":"Column on the parent table that holds (or references) the entity_id for billing scope. Forwarded to the chunking job trigger."},"entity_lookup":{"type":"object","description":"FK lookup configuration for resolving entity_id through a related table. Forwarded to the chunking job trigger.","properties":{"obj_table":{"$ref":"#/$defs/shared-462d3d2412"},"obj_schema":{"$ref":"#/$defs/shared-3d0fa23a34"},"obj_field":{"$ref":"#/$defs/shared-d4553f7be9"}},"required":["obj_table","obj_field"]},"enqueue_chunking_job":{"type":"boolean","description":"Whether to create a job trigger that auto-enqueues chunking on parent INSERT/UPDATE","default":true},"chunking_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the chunking job queue","default":"embedding:chunk_record"}},"description":"Creates a chunked-embedding child table for any parent table. Provisions the chunks table with content, chunk_index, embedding vector, metadata, HNSW index, inherited RLS, and optional job trigger for automatic text splitting. Composed internally by ProcessFileEmbedding (enabled by default in extract mode) but can also be used standalone."},"ProcessExtractionParams":{"type":"object","properties":{"text_field":{"type":"string","format":"column-ref","description":"Field to store extracted text/markdown","default":"extracted_text"},"metadata_field":{"type":"string","format":"column-ref","description":"JSONB field for extraction metadata (page count, language, etc.)","default":"extracted_metadata"},"extraction_model":{"type":"string","description":"Extraction model identifier (e.g. a vision model for OCR, an LLM for structured extraction). Included in the job payload so the worker knows which model to use. When null, the worker falls back to runtime config."},"extraction_provider":{"type":"string","description":"Extraction provider name (e.g. \"ollama\", \"openai\"). When null, the worker falls back to runtime config."},"mime_patterns":{"type":"array","items":{"type":"string"},"description":"MIME type LIKE patterns to match. Multiple patterns are OR'd together. Examples: ['application/pdf', 'text/%'], ['application/vnd.openxmlformats%'].","default":["application/pdf","text/%"]},"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier for the extraction worker","default":"document:extract_file_text"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Trigger events that fire the job","default":["INSERT"]},"file_field":{"$ref":"#/$defs/shared-9af2f9702a"},"payload_custom":{"$ref":"#/$defs/shared-8cef65cfda"},"trigger_conditions":{"$ref":"#/$defs/shared-787b8adf81"},"entity_field":{"$ref":"#/$defs/shared-1a317ed066"},"entity_lookup":{"$ref":"#/$defs/shared-7edb884d72"},"queue_name":{"type":"string","description":"Job queue name for extraction tasks","default":"extraction"},"max_attempts":{"type":"integer","description":"Maximum number of retry attempts","default":5},"priority":{"type":"integer","description":"Job priority (lower = higher priority)","default":0}},"description":"Creates extraction output fields and a job trigger for file text extraction. Fires when a file is uploaded (status = 'uploaded') or on INSERT. The external worker extracts text/metadata from the file (PDF, DOCX, HTML, etc.) and writes the result back to the configured output fields. Typically used upstream of ProcessFileEmbedding or ProcessChunks."},"ProcessFileEmbeddingParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the vector embedding column","default":"embedding"},"dimensions":{"type":"integer","description":"Vector dimensions (e.g. 512 for CLIP, 768 for nomic, 1536 for ada-002)","default":768},"index_method":{"type":"string","enum":["hnsw","ivfflat"],"description":"Index type for similarity search","default":"hnsw"},"metric":{"type":"string","enum":["cosine","l2","ip"],"description":"Distance metric","default":"cosine"},"index_options":{"type":"object","description":"Index-specific options. HNSW: {m, ef_construction}. IVFFlat: {lists}.","default":{}},"embedding_model":{"type":"string","description":"Embedding model identifier (e.g. \"nomic-embed-text\", \"text-embedding-3-small\", \"clip-vit-base-patch32\"). Included in the job payload so the worker knows which model to use. When null, the worker falls back to runtime config (llm_module / env vars)."},"embedding_provider":{"$ref":"#/$defs/shared-ac9a0977fa"},"mime_patterns":{"type":"array","items":{"type":"string"},"description":"MIME type LIKE patterns to match. Multiple patterns are OR'd together. Examples: ['image/%'], ['application/pdf', 'text/%'], ['audio/%'].","default":["image/%"]},"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier for the worker. In direct mode this is the embedding worker; in extract mode this is the extraction worker.","default":"embedding:process_file_embedding"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Trigger events that fire the job","default":["INSERT"]},"file_field":{"$ref":"#/$defs/shared-9af2f9702a"},"payload_custom":{"$ref":"#/$defs/shared-8cef65cfda"},"trigger_conditions":{"$ref":"#/$defs/shared-787b8adf81"},"source_bucket":{"type":"object","description":"Typed bucket reference ({\"$ref\":\"bucket\",\"tags\":[...],\"type\":...}) for the bucket the source files live in, when it is not the record's own bucket_id (which payload_custom already carries). Stamped into the trigger payload at attach time and resolved to coordinates at dispatch.","properties":{"$ref":{"type":"string","enum":["bucket"]},"tags":{"type":"array","items":{"type":"string"}},"key":{"type":"string"},"type":{"$ref":"#/$defs/shared-f4262069e5"}},"required":["$ref"]},"variants_bucket":{"type":"object","description":"Typed bucket reference for where derived outputs (thumbnails, resized variants, extracted assets) are written. Stamped into the trigger payload at attach time and resolved to coordinates at dispatch, so the function never selects a bucket.","properties":{"$ref":{"type":"string","enum":["bucket"]},"tags":{"type":"array","items":{"type":"string"}},"key":{"type":"string"},"type":{"$ref":"#/$defs/shared-f4262069e5"}},"required":["$ref"]},"entity_field":{"$ref":"#/$defs/shared-1a317ed066"},"entity_lookup":{"$ref":"#/$defs/shared-7edb884d72"},"extraction":{"type":"object","description":"Text extraction configuration. When present, the generator creates extraction output fields on the table and configures SearchVector with source_fields + stale tracking. When absent, the node operates in direct mode (single vector per file, no text extraction).","properties":{"text_field":{"type":"string","format":"column-ref","description":"Field to store extracted text/markdown","default":"extracted_text"},"metadata_field":{"type":"string","format":"column-ref","description":"JSONB field for extraction metadata (page count, language, etc.)","default":"extracted_metadata"}}},"include_chunks":{"type":"boolean","description":"Whether to create a chunks table via ProcessChunks. Defaults to true when extraction is provided, false in direct mode. Set explicitly to override."},"chunks":{"type":"object","description":"Chunking configuration passed through to ProcessChunks. When include_chunks is true (or defaults to true in extract mode), these params configure the chunks table, embedding dimensions, strategy, etc.","default":{},"properties":{"content_field_name":{"type":"string","format":"column-ref","description":"Name of the text content column in the chunks table","default":"content"},"chunk_size":{"type":"integer","description":"Maximum number of characters per chunk","default":1000},"chunk_overlap":{"type":"integer","description":"Number of overlapping characters between consecutive chunks","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"description":"Strategy for splitting text into chunks","default":"paragraph"},"metadata_fields":{"type":"array","items":{"type":"string"},"description":"Field names from parent to copy into chunk metadata"},"search_indexes":{"type":"array","items":{"$ref":"#/$defs/shared-5492e6a87c"},"description":"Text search indexes to create on the chunks content column. Omit to mirror the parent table's text search indexes. Set explicitly to override."},"enqueue_chunking_job":{"type":"boolean","description":"Whether to auto-enqueue a chunking job on insert/update","default":true},"chunking_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the chunking job queue","default":"embedding:chunk_record"}}}},"description":"Generic, MIME-scoped embedding node for file tables. Supports two modes: direct (whole-file to single vector, e.g. CLIP for images) when extraction is omitted, or extract (file to text to chunks to per-chunk vectors) when extraction config is provided. Composes SearchVector + JobTrigger + ProcessChunks (enabled by default in extract mode) internally. Multiple instances can coexist on the same table with different MIME scopes, field names, and embedding strategies."},"ProcessImageEmbeddingParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the vector embedding column","default":"embedding"},"dimensions":{"type":"integer","description":"Vector dimensions (default 512 for CLIP-style image embeddings)","default":512},"index_method":{"type":"string","enum":["hnsw","ivfflat"],"description":"Index type for similarity search","default":"hnsw"},"metric":{"type":"string","enum":["cosine","l2","ip"],"description":"Distance metric","default":"cosine"},"index_options":{"type":"object","description":"Index-specific options. HNSW: {m, ef_construction}. IVFFlat: {lists}.","default":{}},"embedding_model":{"type":"string","description":"Embedding model identifier (e.g. \"clip-vit-base-patch32\"). Included in the job payload so the worker knows which model to use. When null, the worker falls back to runtime config (llm_module / env vars)."},"embedding_provider":{"$ref":"#/$defs/shared-ac9a0977fa"},"mime_patterns":{"type":"array","items":{"type":"string"},"description":"MIME type LIKE patterns to match. Multiple patterns are OR'd together.","default":["image/%"]},"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier for the image embedding worker","default":"embedding:process_image_embedding"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Trigger events that fire the job","default":["INSERT"]},"file_field":{"$ref":"#/$defs/shared-9af2f9702a"},"payload_custom":{"$ref":"#/$defs/shared-8cef65cfda"},"trigger_conditions":{"$ref":"#/$defs/shared-787b8adf81"},"entity_field":{"$ref":"#/$defs/shared-1a317ed066"},"entity_lookup":{"$ref":"#/$defs/shared-7edb884d72"},"extraction":{"type":"object","description":"Text extraction configuration. Forwarded to ProcessFileEmbedding. When present, enables extract mode (e.g., OCR for images).","properties":{"text_field":{"type":"string","format":"column-ref","description":"Field to store extracted text","default":"extracted_text"},"metadata_field":{"type":"string","format":"column-ref","description":"JSONB field for extraction metadata","default":"extracted_metadata"}}},"chunks":{"type":"object","description":"Chunking configuration. Forwarded to ProcessFileEmbedding. Only meaningful when extraction is also provided.","properties":{"content_field_name":{"type":"string","format":"column-ref","default":"content"},"chunk_size":{"type":"integer","default":1000},"chunk_overlap":{"type":"integer","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"default":"paragraph"},"metadata_fields":{"type":"object"},"enqueue_chunking_job":{"type":"boolean","default":true},"chunking_task_name":{"type":"string","format":"function-ref","default":"embedding:chunk_record"}}}},"description":"Image-specific preset of ProcessFileEmbedding. Delegates to ProcessFileEmbedding with image-oriented defaults: dimensions=512 (CLIP), mime_patterns=['image/%'], task_identifier='embedding:process_image_embedding', direct mode (no extraction). Accepts all ProcessFileEmbedding parameters — any overrides are forwarded through."},"ProcessImageVersionsParams":{"type":"object","required":["versions"],"properties":{"versions":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","description":"Version identifier (e.g., \"thumb\", \"preview\", \"hero\")"},"width":{"type":"integer","description":"Target width in pixels"},"height":{"type":"integer","description":"Target height in pixels"},"fit":{"type":"string","enum":["cover","contain","fill","inside","outside"],"description":"Resize fitting strategy","default":"cover"},"format":{"type":"string","enum":["jpeg","png","webp","avif"],"description":"Output image format","default":"webp"},"quality":{"type":"integer","description":"Output quality (1-100)","default":80}},"required":["name"]},"description":"Array of version definitions. Each version specifies dimensions, format, and quality for a generated image variant. Required — the blueprint must explicitly define what variants to generate.","minItems":1},"mime_patterns":{"type":"array","items":{"type":"string"},"description":"MIME type LIKE patterns to match. Defaults to all image types.","default":["image/%"]},"task_identifier":{"type":"string","format":"function-ref","description":"Job task identifier for the image processing worker","default":"image:process_image_versions"},"events":{"type":"array","items":{"type":"string","enum":["INSERT","UPDATE"]},"description":"Trigger events that fire the job","default":["INSERT"]},"file_field":{"$ref":"#/$defs/shared-9af2f9702a"},"payload_custom":{"$ref":"#/$defs/shared-8cef65cfda"},"trigger_conditions":{"$ref":"#/$defs/shared-787b8adf81"},"entity_field":{"$ref":"#/$defs/shared-1a317ed066"},"entity_lookup":{"$ref":"#/$defs/shared-7edb884d72"},"queue_name":{"type":"string","description":"Job queue name for image processing tasks","default":"image_processing"},"max_attempts":{"type":"integer","description":"Maximum number of retry attempts","default":5},"priority":{"type":"integer","description":"Job priority (lower = higher priority)","default":0}},"description":"Creates a job trigger for image variant generation. Fires when an image file is uploaded (status = 'uploaded') or on INSERT. The external worker generates resized, cropped, or reformatted versions (thumbnails, previews, WebP conversions, etc.) and stores them as new file records linked to the source image."},"SearchBm25Params":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of existing text column to index with BM25"},"text_config":{"type":"string","description":"PostgreSQL text search configuration for BM25","default":"english"},"k1":{"type":"number","description":"BM25 k1 parameter: term frequency saturation (typical: 1.2-2.0)","default":null},"b":{"type":"number","description":"BM25 b parameter: document length normalization (0=none, 1=full, typical: 0.75)","default":null},"search_score_weight":{"type":"number","description":"Weight for this algorithm in composite searchScore","default":1}},"required":["field_name"],"description":"Creates a BM25 index on an existing text column using pg_textsearch. Enables statistical relevance ranking with configurable k1 and b parameters. The BM25 index is auto-detected by graphile-search."},"SearchFullTextParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the tsvector column","default":"search"},"source_fields":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string","format":"column-ref","description":"Name of the source column"},"weight":{"type":"string","enum":["A","B","C","D"],"description":"tsvector weight class (A=highest, D=lowest)","default":"D"},"lang":{"type":"string","description":"PostgreSQL text search configuration","default":"english"}},"required":["field"]},"description":"Source columns that feed the tsvector. Each has a field name, weight (A-D), and language config."},"lang_column":{"type":"string","format":"column-ref","description":"Column name whose value determines the text search configuration per row. When set, the tsvector trigger uses NEW.::regconfig instead of a static language, enabling dynamic per-row language stemming. The per-field lang values in source_fields are used as fallback defaults for the langs array but the trigger reads from this column at runtime."},"search_score_weight":{"type":"number","description":"Weight for this algorithm in composite searchScore","default":1}},"required":["source_fields"],"description":"Adds a tsvector column with GIN index and automatic trigger population from source fields. Enables PostgreSQL full-text search with configurable weights and language support. Leverages the existing metaschema full_text_search infrastructure."},"SearchSpatialAggregateParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the aggregate geometry column on the parent table","default":"geom_aggregate"},"source_table_id":{"type":"string","format":"uuid","description":"UUID of the source (child) table containing individual geometries"},"source_geom_field":{"type":"string","format":"column-ref","description":"Name of the geometry column on the source table","default":"geom"},"source_fk_field":{"type":"string","format":"column-ref","description":"Name of the foreign key column on the source table pointing to the parent"},"aggregate_function":{"type":"string","enum":["union","collect","convex_hull","concave_hull"],"description":"PostGIS aggregation function: union (ST_Union, merges overlapping), collect (ST_Collect, groups without merging), convex_hull (smallest convex polygon), concave_hull (tighter boundary)","default":"union"},"geometry_type":{"type":"string","enum":["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection","Geometry"],"description":"Output geometry type constraint for the aggregate field","default":"MultiPolygon"},"srid":{"type":"integer","description":"Spatial Reference System Identifier (e.g. 4326 for WGS84)","default":4326},"dimension":{"type":"integer","enum":[2,3,4],"description":"Coordinate dimension (2=XY, 3=XYZ, 4=XYZM)","default":2},"use_geography":{"type":"boolean","description":"Use geography type instead of geometry","default":false},"index_method":{"type":"string","enum":["gist","spgist"],"description":"Spatial index method for the aggregate field","default":"gist"}},"required":["source_table_id","source_fk_field"],"description":"Creates a derived/materialized geometry field on the parent table that automatically aggregates geometries from a source (child) table via triggers. When child rows are inserted/updated/deleted, the parent aggregate field is recalculated using the specified PostGIS aggregation function (ST_Union, ST_Collect, ST_ConvexHull, ST_ConcaveHull). Useful for materializing spatial boundaries from collections of points or polygons."},"SearchSpatialParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the geometry/geography column","default":"geom"},"geometry_type":{"type":"string","enum":["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection","Geometry"],"description":"PostGIS geometry type constraint","default":"Point"},"srid":{"type":"integer","description":"Spatial Reference System Identifier (e.g. 4326 for WGS84)","default":4326},"dimension":{"type":"integer","enum":[2,3,4],"description":"Coordinate dimension (2=XY, 3=XYZ, 4=XYZM)","default":2},"use_geography":{"type":"boolean","description":"Use geography type instead of geometry (for geodetic calculations on the sphere)","default":false},"index_method":{"type":"string","enum":["gist","spgist"],"description":"Spatial index method","default":"gist"}},"description":"Adds a PostGIS geometry or geography column with a spatial index (GiST or SP-GiST). Supports configurable geometry types (Point, Polygon, etc.), SRID, and dimensionality. The graphile-postgis plugin auto-detects geometry/geography columns by codec type for spatial filtering (ST_Contains, ST_DWithin, bbox operators)."},"SearchTrgmParams":{"type":"object","properties":{"fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names to create trigram indexes on (fields must already exist on the table)"}},"required":["fields"],"description":"Creates GIN trigram indexes (gin_trgm_ops) on specified text/citext fields for fuzzy LIKE/ILIKE/similarity search. Adds @trgmSearch smart tag for PostGraphile integration. Fields must already exist on the table."},"SearchUnifiedParams":{"type":"object","properties":{"full_text_search":{"type":"object","description":"SearchFullText parameters. Omit to skip FTS setup.","properties":{"field_name":{"type":"string","format":"column-ref","default":"search"},"source_fields":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string","format":"column-ref"},"weight":{"type":"string","enum":["A","B","C","D"]},"lang":{"type":"string"}},"required":["field"]}},"search_score_weight":{"type":"number","default":1}}},"bm25":{"type":"object","description":"SearchBm25 parameters. Omit to skip BM25 setup.","properties":{"field_name":{"type":"string","format":"column-ref"},"text_config":{"type":"string","default":"english"},"k1":{"type":"number"},"b":{"type":"number"},"search_score_weight":{"type":"number","default":1}}},"embedding":{"type":"object","description":"SearchVector parameters. Omit to skip embedding setup.","properties":{"field_name":{"type":"string","format":"column-ref","default":"embedding"},"dimensions":{"type":"integer","default":768},"index_method":{"type":"string","enum":["hnsw","ivfflat"]},"metric":{"type":"string","enum":["cosine","l2","ip"]},"source_fields":{"type":"array","items":{"type":"string","format":"column-ref"}},"embedding_model":{"type":"string","description":"Embedding model identifier. When null, the worker falls back to runtime config."},"embedding_provider":{"type":"string","description":"Embedding provider name. When null, the worker falls back to runtime config."},"search_score_weight":{"type":"number","default":1},"chunks":{"type":"object","description":"Chunking configuration for long-text embedding. Creates an embedding_chunks record that drives automatic text splitting and per-chunk embedding. Omit to skip chunking.","properties":{"content_field_name":{"type":"string","format":"column-ref","description":"Name of the text content column in the chunks table","default":"content"},"chunk_size":{"type":"integer","description":"Maximum number of characters per chunk","default":1000},"chunk_overlap":{"type":"integer","description":"Number of overlapping characters between consecutive chunks","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"description":"Strategy for splitting text into chunks","default":"fixed"},"metadata_fields":{"$ref":"#/$defs/shared-3a33134347"},"enqueue_chunking_job":{"type":"boolean","description":"Whether to auto-enqueue a chunking job on insert/update","default":true},"chunking_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the chunking job queue","default":"embedding:chunk_record"}}}}},"embedding_text_field":{"type":"string","format":"column-ref","description":"Name of the composite text field created for embedding input","default":"embedding_text"},"composite_format":{"type":"string","enum":["labeled","plain"],"description":"Output format for the composite text field","default":"labeled"},"trgm_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Field names to tag with @trgmSearch for fuzzy/typo-tolerant matching"},"search_config":{"type":"object","description":"Unified search score configuration written to @searchConfig smart tag","properties":{"weights":{"type":"object","description":"Per-algorithm weights: {tsv: 1.5, bm25: 1.0, pgvector: 0.8, trgm: 0.3}"},"normalization":{"type":"string","enum":["linear","sigmoid"],"description":"Score normalization strategy","default":"linear"},"boost_recent":{"type":"boolean","description":"Enable recency boost for search results","default":false},"boost_recency_field":{"type":"string","format":"column-ref","description":"Timestamp field for recency boost (e.g. created_at, updated_at)"},"boost_recency_decay":{"type":"number","description":"Decay rate for recency boost (0-1, lower = faster decay)","default":0.5}}}},"description":"Composite node type that orchestrates multiple search modalities (full-text search, BM25, embeddings, trigram) on a single table. Configures per-table search score weights, normalization strategy, and recency boost via the @searchConfig smart tag."},"SearchVectorParams":{"type":"object","properties":{"field_name":{"type":"string","format":"column-ref","description":"Name of the vector column","default":"embedding"},"dimensions":{"type":"integer","description":"Vector dimensions (e.g. 384, 768, 1536, 3072)","default":768},"index_method":{"type":"string","enum":["hnsw","ivfflat"],"description":"Index type for similarity search","default":"hnsw"},"metric":{"type":"string","enum":["cosine","l2","ip"],"description":"Distance metric (cosine, l2, ip)","default":"cosine"},"index_options":{"type":"object","description":"Index-specific options. HNSW: {m, ef_construction}. IVFFlat: {lists}.","default":{}},"source_fields":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"Column names that feed the embedding. Used by stale trigger to detect content changes."},"embedding_model":{"type":"string","description":"Embedding model identifier (e.g. \"nomic-embed-text\", \"text-embedding-3-small\"). Included in the job payload so the worker knows which model to use. When null, the worker falls back to runtime config (llm_module / env vars)."},"embedding_provider":{"$ref":"#/$defs/shared-ac9a0977fa"},"enqueue_job":{"type":"boolean","description":"Auto-create trigger that enqueues embedding generation jobs","default":true},"job_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the job queue. Must match a registered function definition when function_module is installed.","default":"embedding:embed_record"},"chunks":{"type":"object","description":"Chunking configuration for long-text embedding. Creates an embedding_chunks record that drives automatic text splitting and per-chunk embedding. Omit to skip chunking.","properties":{"content_field_name":{"type":"string","format":"column-ref","description":"Name of the text content column in the chunks table","default":"content"},"chunk_size":{"type":"integer","description":"Maximum number of characters per chunk","default":1000},"chunk_overlap":{"type":"integer","description":"Number of overlapping characters between consecutive chunks","default":200},"chunk_strategy":{"type":"string","enum":["fixed","sentence","paragraph","semantic"],"description":"Strategy for splitting text into chunks","default":"fixed"},"metadata_fields":{"$ref":"#/$defs/shared-3a33134347"},"enqueue_chunking_job":{"type":"boolean","description":"Whether to auto-enqueue a chunking job on insert/update","default":true},"chunking_task_name":{"type":"string","format":"function-ref","description":"Task identifier for the chunking job queue. Must match a registered function definition when function_module is installed.","default":"embedding:chunk_record"}}}},"description":"Adds a vector embedding column with HNSW or IVFFlat index for similarity search. Supports configurable dimensions, distance metrics (cosine, l2, ip), per-field {field_name}_updated_at timestamp tracking (read-only in GraphQL), and automatic job enqueue triggers for embedding generation."},"TableOrganizationSettingsParams":{"type":"object","properties":{},"description":"Creates an organization settings table with standard business fields (legal_name, address fields). Uses AuthzEntityMembership for access control."},"TableUserProfilesParams":{"type":"object","properties":{},"description":"Creates a user profiles table with standard profile fields (profile_picture, bio, first_name, last_name, tags, desired). Uses AuthzDirectOwner for edit access and AuthzAllowAll for select."},"TableUserSettingsParams":{"type":"object","properties":{},"description":"Creates a user settings table for user-specific configuration. Uses AuthzDirectOwner for access control."},"TriggerCondition":{"type":"object","properties":{"field":{"type":"string","description":"Column name (validated against the table)."},"op":{"enum":["=","!=",">","<",">=","<=","LIKE","NOT LIKE","IS NULL","IS NOT NULL","IS DISTINCT FROM"],"description":"Comparison operator."},"value":{"description":"Comparison value. Type is resolved from the column definition."},"row":{"enum":["NEW","OLD"],"description":"Row reference (default: NEW)."},"ref":{"type":"object","properties":{"field":{"type":"string"},"row":{"enum":["NEW","OLD"]}},"description":"Column reference for field-to-field comparison (alternative to value)."},"AND":{"type":"array","items":{"$ref":"#/$defs/TriggerCondition"},"description":"Array of conditions combined with AND."},"OR":{"type":"array","items":{"$ref":"#/$defs/TriggerCondition"},"description":"Array of conditions combined with OR."},"NOT":{"$ref":"#/$defs/TriggerCondition","description":"Negated condition."}},"description":"Recursive condition type for compound trigger WHEN clauses. Leaf conditions specify {field, op, value?, row?, ref?}. Combinators nest via AND, OR, NOT."},"shared-001d8d7cd3":{"anyOf":[{"required":["obj_table_id"]},{"required":["obj_schema","obj_table"]}]},"shared-0165627a32":{"type":"array","items":{"type":"string"},"description":"Capability names of any kind (capability, level, ...) merged into the same mask"},"shared-040cc005ef":{"type":"array","minItems":1,"items":{"$ref":"#/$defs/AuthzExpression"}},"shared-0596961db6":{"if":{"properties":{"$type":{"const":"AuthzRelatedMemberList"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedMemberListParams"}}}},"shared-066977ff2f":{"anyOf":[{"required":["obj_field"]},{"required":["obj_field_id"]}]},"shared-078ee82414":{"properties":{"$type":{"const":"CheckOneOf"}},"required":["$type"]},"shared-0968d06284":{"type":"string","description":"Schema of the join table (or use obj_table_id)"},"shared-0a22d2c3f6":{"type":"string","description":"Single column name for the index."},"shared-11809f0714":{"if":{"properties":{"$type":{"const":"AuthzMemberList"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzMemberListParams"}}}},"shared-11a9ffe32a":{"type":"string","description":"Schema of the related table (user-facing name, e.g., \"public\"). Optional — if omitted, resolved by table name within the same database_id (raises error if ambiguous)."},"shared-13aff2afe8":{"type":"string","description":"The member list the policy reads. With a team kind the backend resolves it and replaces this value."},"shared-152f619c56":{"if":{"properties":{"$type":{"const":"AuthzDenyAll"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDenyAllParams"}}}},"shared-15602a740a":{"properties":{"$type":{"const":"AuthzEntityMembership"}},"required":["$type"]},"shared-1a317ed066":{"type":"string","format":"column-ref","description":"Column on the trigger table that holds (or references) the entity_id for billing scope. Forwarded to the composed JobTrigger."},"shared-1a97ddc6fb":{"if":{"properties":{"$type":{"const":"AuthzRelatedPeerOwnership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedPeerOwnershipParams"}}}},"shared-1c8d46d43b":{"properties":{"$type":{"const":"CheckNotEqual"}},"required":["$type"]},"shared-1ca2c9bd61":{"type":"array","description":"Join conditions between the protected row and the referenced table","items":{"type":"object","properties":{"local_column":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column on the protected table"},"ref_column":{"$ref":"#/$defs/shared-7539b204c0"},"operator":{"type":"string","enum":["=","!=",">","<",">=","<="],"default":"=","description":"Join operator"}},"required":["local_column","ref_column"],"additionalProperties":false}},"shared-1d7aaec830":{"type":"string","description":"Per-row required permissions (DataCapabilities): a bit(n) column on this table whose bits the actor must hold, checked as sprt.capabilities & row.mask = row.mask. A zero mask requires nothing."},"shared-21a1ba9587":{"if":{"properties":{"$type":{"const":"AuthzAppMembership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzAppMembershipParams"}}}},"shared-22f38cc906":{"type":"array","items":{"type":"string"},"description":"Operator classes for the index columns."},"shared-230094622e":{"type":"object","description":"FK lookup configuration for resolving entity_id through a related table. Used when entity_field is a FK (e.g., channel_id) rather than a direct entity_id. The generator validates all fields against metaschema within the same database_id.","properties":{"obj_table":{"type":"string","description":"Name of the related table to look up entity_id from (e.g., \"channels\"). Required."},"obj_schema":{"type":"string","description":"Schema of the related table (user-facing name, e.g., \"public\"). Optional — if omitted, resolved by table name within the same database_id (raises error if ambiguous)."},"obj_field":{"type":"string","description":"Column on the related table that holds the entity_id (e.g., \"entity_id\"). Required."}},"required":["obj_table","obj_field"]},"shared-2997c2f821":{"if":{"properties":{"$type":{"const":"AuthzSystemOnly"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzSystemOnlyParams"}}}},"shared-2a834ba4ff":{"type":"string","description":"Index access method (e.g., \"BTREE\", \"GIN\", \"GIST\", \"HNSW\", \"BM25\")."},"shared-2c17992067":{"properties":{"$type":{"const":"AuthzNotReadOnly"}},"required":["$type"]},"shared-2c20767ba3":{"properties":{"$type":{"const":"CheckGreaterThan"}},"required":["$type"]},"shared-3245b618eb":{"properties":{"$type":{"const":"AuthzValueMatch"}},"required":["$type"]},"shared-33013a269d":{"if":{"properties":{"$type":{"const":"AuthzRelatedEntityMembership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedEntityMembershipParams"}}}},"shared-33af0ede37":{"type":"string","format":"column-ref","description":"Single column to compare against value (mutually exclusive with columns)"},"shared-34021cf1ff":{"properties":{"$type":{"const":"AuthzDirectOwnerAny"}},"required":["$type"]},"shared-36ea8e912e":{"if":{"properties":{"$type":{"const":"AuthzDatabaseClaim"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDatabaseClaimParams"}}}},"shared-39f66ad592":{"if":{"properties":{"$type":{"const":"AuthzAllowAll"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzAllowAllParams"}}}},"shared-3a33134347":{"type":"object","description":"Metadata fields from parent to copy into chunks"},"shared-3d0fa23a34":{"type":"string","description":"Schema of the related table (user-facing name, optional)"},"shared-3fc6945ad1":{"if":{"properties":{"$type":{"const":"AuthzValueExists"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueExistsParams"}}}},"shared-411f8ee76d":{"type":"string","description":"Schema of the referenced table (or use ref_table_id)"},"shared-433a283165":{"properties":{"$type":{"const":"AuthzRelatedMemberOwner"}},"required":["$type"]},"shared-462d3d2412":{"type":"string","description":"Name of the related table to look up entity_id from"},"shared-47ab73adbe":{"properties":{"$type":{"const":"AuthzDirectOwner"}},"required":["$type"]},"shared-48649a3a43":{"type":"array","items":{"$ref":"#/$defs/TriggerCondition"}},"shared-49ec07b1f5":{"properties":{"$type":{"const":"AuthzAppMemberOwner"}},"required":["$type"]},"shared-4f25156f61":{"if":{"properties":{"$type":{"const":"AuthzPeerOwnership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzPeerOwnershipParams"}}}},"shared-5192cb016d":{"properties":{"$type":{"const":"AuthzRelatedPeerOwnership"}},"required":["$type"]},"shared-51c1d9a5f0":{"type":"string","minLength":1,"not":{"const":"app"},"description":"Entity type prefix (e.g. 'org', 'channel', 'department'), resolved to its membership_type; use it instead of membership_type for readability."},"shared-5249d2cd90":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Field name on join table to match against SPRT entity_id"},"shared-5492e6a87c":{"type":"string","enum":["fulltext","bm25","trigram"]},"shared-55595a36d2":{"type":["array","object"],"items":{"type":"object"},"description":"Optional higher-level condition JSON applied to the referenced table (row alias d)"},"shared-57b27779bd":{"properties":{"$type":{"const":"AuthzValueAllowed"}},"required":["$type"]},"shared-584ca266e8":{"properties":{"$type":{"const":"AuthzRelatedMemberList"}},"required":["$type"]},"shared-5a2832df1c":{"type":"array","items":{"type":"string"},"description":"Array of column names for a multi-column index."},"shared-5e11bfeb01":{"type":"boolean","description":"If true, require is_owner flag on current user membership"},"shared-5f5453df14":{"properties":{"$type":{"const":"AuthzFilePath"}},"required":["$type"]},"shared-626b0c3c0b":{"type":"array","items":{"$ref":"#/$defs/BlueprintFtsSource"},"description":"Source fields that feed into this tsvector."},"shared-637ef72440":{"type":"string","pattern":"^[01]+$","description":"Capability bits a member must hold, as a bit string. Capabilities or levels, when given, replace it."},"shared-6639e33d04":{"if":{"properties":{"$type":{"const":"AuthzComposite"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzCompositeParams"}}}},"shared-698b2fd59a":{"type":"integer","minimum":2,"maximum":2147483647,"description":"The team kind: 2=org, 3+=dynamic entity types."},"shared-6adc1df48e":{"type":"string","description":"Optional schema name for disambiguation (falls back to top-level default)."},"shared-6b829f5502":{"type":"string","description":"Name of the related table to look up entity_id from (e.g., \"channels\"). Required."},"shared-6dbc2f5a83":{"if":{"properties":{"$type":{"const":"AuthzPublishable"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzPublishableParams"}}}},"shared-6eb30390ff":{"type":"string","enum":["INSERT","DELETE","UPDATE"]},"shared-7539b204c0":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Column on the referenced table"},"shared-757c15800e":{"type":"string","description":"Name of the CHECK constraint."},"shared-787b8adf81":{"anyOf":[{"$ref":"#/$defs/TriggerCondition"},{"$ref":"#/$defs/shared-48649a3a43"}],"description":"Additional compound conditions beyond auto-generated filtering. Merged with the auto-generated conditions via AND."},"shared-7a53e1103e":{"type":"boolean","description":"Select sel_field from the related row instead of the team id; the platform's own related policies set it with sel_field \"id\"."},"shared-7edb884d72":{"type":"object","description":"FK lookup configuration for resolving entity_id through a related table. Forwarded to the composed JobTrigger.","properties":{"obj_table":{"type":"string","description":"Name of the related table to look up entity_id from"},"obj_schema":{"type":"string","description":"Schema of the related table (user-facing name, optional)"},"obj_field":{"type":"string","format":"column-ref","description":"Column on the related table that holds the entity_id"}},"required":["obj_table","obj_field"]},"shared-7f50b0e5b7":{"type":"string","description":"Name of the referenced table (or use ref_table_id)"},"shared-8358853df2":{"properties":{"$type":{"const":"CheckLessThan"}},"required":["$type"]},"shared-85b2c2543e":{"if":{"properties":{"$type":{"const":"AuthzEntityMembership"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzEntityMembershipParams"}}}},"shared-8763e18b77":{"anyOf":[{"required":["membership_type"]},{"required":["entity_type"]},{"required":["sprt_schema","sprt_table"]}]},"shared-88656ecafa":{"type":"string","format":"column-ref","description":"Column name for conditional WHEN clause (fires only when field equals condition_value)"},"shared-8881b94a41":{"if":{"properties":{"$type":{"const":"AuthzTemporal"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzTemporalParams"}}}},"shared-89ec3722aa":{"if":{"properties":{"$type":{"const":"AuthzRelatedMemberOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzRelatedMemberOwnerParams"}}}},"shared-8cc6b29877":{"type":"string","format":"uuid","description":"UUID of the referenced table (alternative to ref_schema/ref_table)"},"shared-8cef65cfda":{"type":"object","additionalProperties":{"oneOf":[{"type":"string","format":"column-ref"},{"type":"object","properties":{"field":{"type":"string","format":"column-ref"},"path":{"type":"array","items":{"type":"string"},"minItems":1}},"required":["field","path"]}]},"description":"Custom payload key-to-source mapping for the job trigger. A source is either a column name or a read into a jsonb column ({\"field\": \"upload\", \"path\": [\"key\"]}). Defaults to the four file columns, or to the file_field document when file_field is set."},"shared-8e6e495eb6":{"if":{"properties":{"$type":{"const":"AuthzNotReadOnly"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzNotReadOnlyParams"}}}},"shared-9146e81ef6":{"type":"string","format":"uuid","description":"UUID of the join table (alternative to obj_schema/obj_table)"},"shared-927486214a":{"type":"boolean","description":"If true, require is_admin flag"},"shared-9572999fa8":{"type":"string","description":"The schema of the member list the policy reads. With a team kind the backend resolves it and replaces this value."},"shared-97d5c3be03":{"properties":{"$type":{"const":"AuthzOrgHierarchy"}},"required":["$type"]},"shared-9af2f9702a":{"type":"string","format":"column-ref","description":"Name of an upload/image domain column holding the file reference. When set, the trigger reads the object key, MIME type and bucket id out of that document (NEW. ->> 'key', ...) instead of requiring key/mime_type/bucket_id columns beside it, and the MIME patterns match against ->> 'mime'."},"shared-9d6147637c":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name referencing the entity (e.g., entity_id, org_id)"},"shared-a0bfcadf85":{"type":"array","items":{"type":"string"},"description":"Column names that form the unique constraint."},"shared-a2c45e97d1":{"if":{"properties":{"$type":{"const":"AuthzDirectOwnerAny"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDirectOwnerAnyParams"}}}},"shared-a9d73b8ba7":{"if":{"properties":{"$type":{"const":"AuthzMemberOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzMemberOwnerParams"}}}},"shared-ab071ec2f8":{"type":"boolean","description":"If true, require is_owner flag"},"shared-ab15ceab40":{"type":"string","description":"Prefix of the module instance, for entity-scoped installations."},"shared-ac9a0977fa":{"type":"string","description":"Embedding provider name (e.g. \"ollama\", \"openai\"). When null, the worker falls back to runtime config."},"shared-aced6572ca":{"if":{"properties":{"$type":{"const":"AuthzHumanOnly"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzHumanOnlyParams"}}}},"shared-ad437cb66f":{"type":"string","format":"column-ref","x-column-scope":"local"},"shared-ad8f69741a":{"type":"string","description":"Optional schema name override."},"shared-af38a22089":{"enum":["AuthzAllowAll","AuthzAppMemberOwner","AuthzAppMembership","AuthzComposite","AuthzDatabaseClaim","AuthzDenyAll","AuthzDirectOwner","AuthzDirectOwnerAny","AuthzEntityMembership","AuthzFilePath","AuthzHumanOnly","AuthzMemberList","AuthzMemberOwner","AuthzNotReadOnly","AuthzOrgHierarchy","AuthzPeerOwnership","AuthzPublishable","AuthzRelatedEntityMembership","AuthzRelatedMemberList","AuthzRelatedMemberOwner","AuthzRelatedPeerOwnership","AuthzSystemOnly","AuthzTemporal","AuthzValueAllowed","AuthzValueExists","AuthzValueMatch"]},"shared-b0876b5627":{"type":"array","items":{"type":"string"},"description":"Achievement level names to require (kind=level catalog rows, merged into the same mask)"},"shared-b1944d8f7b":{"description":"Allowed values as a constant list, or a local column name containing the allowed values","anyOf":[{"type":"string","format":"column-ref","x-column-scope":"local","description":"Local column name containing allowed values"},{"type":"array","items":{"type":["string","boolean","number","null"]},"description":"Constant list of allowed values. Element JSON type is preserved: booleans/numbers emit typed constants (e.g. [true] -> TRUE, [5] -> 5), strings emit text literals."}]},"shared-b1dc7b2e4f":{"properties":{"$type":{"const":"AuthzPeerOwnership"}},"required":["$type"]},"shared-b68f53d1ed":{"type":"integer","description":"The width the mask is padded to; by default the length of the mask."},"shared-bb55f34041":{"type":"boolean","description":"Whether this is a unique index."},"shared-bc381c03de":{"type":"object","properties":{"roles":{"type":"array","items":{"type":"string"}},"privileges":{"type":"array","items":{}}},"required":["roles","privileges"]},"shared-c1527c6159":{"if":{"properties":{"$type":{"const":"AuthzValueMatch"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueMatchParams"}}}},"shared-c2c61348f0":{"if":{"properties":{"$type":{"const":"AuthzOrgHierarchy"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzOrgHierarchyParams"}}}},"shared-c88c54a5c5":{"if":{"properties":{"$type":{"const":"AuthzValueAllowed"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzValueAllowedParams"}}}},"shared-c893ee8510":{"if":{"properties":{"$type":{"const":"AuthzDirectOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzDirectOwnerParams"}}}},"shared-cc52e308f2":{"anyOf":[{"$ref":"#/$defs/TriggerCondition"},{"$ref":"#/$defs/shared-48649a3a43"}],"description":"Compound conditions for the trigger WHEN clause. Accepts a single leaf condition, an array of conditions (implicitly AND), or a nested combinator tree ({AND: [...], OR: [...], NOT: {...}}). Each leaf is {field, op, value?, row?, ref?}. Column types are resolved automatically from the table schema. Cannot be combined with condition_field or watch_fields."},"shared-cd4dc6cdf6":{"type":"string","description":"Name of the join table (or use obj_table_id)"},"shared-d3e6ac0b5d":{"type":"boolean","description":"If true, require is_admin flag on current user membership"},"shared-d4553f7be9":{"type":"string","format":"column-ref","description":"Column on the related table that holds the entity_id"},"shared-d85a10e177":{"type":"object","description":"Reference to a table an installed module generated, resolved during blueprint construction (alternative to ref_table_id / ref_schema + ref_table)","properties":{"type":{"type":"string","description":"Module type owning the table, e.g. \"agent\""},"table":{"type":"string","description":"Logical table key within the module, e.g. \"thread\""},"scope":{"type":"string","description":"Scope of the module instance, e.g. \"app\" or \"org\""},"prefix":{"type":"string","description":"Prefix of the module instance, for entity-scoped installations"}},"required":["type","table"]},"shared-d8e76848ea":{"type":"string","format":"uuid","description":"UUID of field on join table (alternative to obj_field)"},"shared-d91c021eee":{"properties":{"$type":{"const":"AuthzMemberOwner"}},"required":["$type"]},"shared-db0e2e6361":{"type":"string","format":"uuid","description":"Table being referenced by the FK"},"shared-dfbaf50fc6":{"type":"string","format":"column-ref","x-column-scope":"local","description":"Column name on protected table referencing the join table"},"shared-e1125a4a5e":{"type":"string","description":"Scope of the module instance (e.g. \"app\", \"org\"). Required when the database installs the module at more than one scope."},"shared-e23bde2ba6":{"properties":{"$type":{"const":"AuthzValueExists"}},"required":["$type"]},"shared-e3e4ac8f48":{"if":{"properties":{"$type":{"const":"AuthzFilePath"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzFilePathParams"}}}},"shared-e6dbbbcd8d":{"type":"string","enum":["c","r","n","d","a"],"description":"FK delete action: c=CASCADE, r=RESTRICT, n=SET NULL, d=SET DEFAULT, a=NO ACTION. Required."},"shared-e772a2f2a5":{"type":"object","additionalProperties":{},"description":"Additional index-specific options."},"shared-eb6d498d14":{"if":{"properties":{"$type":{"const":"AuthzAppMemberOwner"}},"required":["$type"]},"then":{"properties":{"data":{"$ref":"#/$defs/AuthzAppMemberOwnerParams"}}}},"shared-eb860e1011":{"type":"string","enum":["INSERT","UPDATE","DELETE"]},"shared-ee69c55731":{"type":"string","description":"Name of the tsvector field on the table."},"shared-eff5f86cd2":{"properties":{"$type":{"const":"AuthzMemberList"}},"required":["$type"]},"shared-effacc6003":{"type":"object","description":"A further row that must exist in a third table, joined to the referenced row (alias b unless ref_alias says otherwise).","properties":{"ref_table_id":{"type":"string","format":"uuid","description":"UUID of the third table (alternative to ref_schema/ref_table)"},"ref_schema":{"type":"string","description":"Schema of the third table (or use ref_table_id)"},"ref_table":{"type":"string","description":"Name of the third table (or use ref_table_id)"},"ref_alias":{"type":"string","description":"Alias of the third table in the join","default":"b"},"join":{"type":"array","description":"Join conditions between the referenced row and the third table","items":{"type":"object","properties":{"local_column":{"$ref":"#/$defs/shared-7539b204c0"},"ref_column":{"type":"string","format":"column-ref","x-column-scope":"foreign","description":"Column on the third table"},"operator":{"type":"string","enum":["=","!=",">","<",">=","<="],"default":"=","description":"Join operator"}},"required":["local_column","ref_column"],"additionalProperties":false}},"conditions":{"type":["array","object"],"items":{"type":"object"},"description":"Optional condition JSON applied to the third table"}},"anyOf":[{"required":["ref_table_id"]},{"required":["ref_schema","ref_table"]}],"additionalProperties":false},"shared-f35a015b21":{"type":"string","description":"Optional custom name for the index."},"shared-f4262069e5":{"type":"string","enum":["public","private","temp"]},"shared-f7ad90b1e2":{"type":"string","description":"Value to compare against condition_field in WHEN clause"},"shared-f93f3b8ac9":{"properties":{"$type":{"const":"AuthzRelatedEntityMembership"}},"required":["$type"]},"shared-fe3f452ee5":{"type":"array","items":{"type":"string","format":"column-ref"},"description":"For UPDATE triggers, only fire when these fields change (uses DISTINCT FROM)"}}}; diff --git a/packages/node-type-registry/src/blueprint-types.generated.ts b/packages/node-type-registry/src/blueprint-types.generated.ts index 1cb93edd3f..00d03d3629 100644 --- a/packages/node-type-registry/src/blueprint-types.generated.ts +++ b/packages/node-type-registry/src/blueprint-types.generated.ts @@ -200,6 +200,24 @@ export interface DataEntityMembershipParams { /* If true, creates a B-tree index on the entity column */ create_index?: boolean; } +/** Registers an existing upload, image or attachment column as a managed reference to a files row: it records which storage module the file lives in and which bucket an upload resolves to, and the backend generates the sync trigger and the GC index from that. The column must be declared in fields[] first; the node creates no column. */ +export interface DataFileRefParams { + /* The upload, image or attachment column to register */ + field: string; + /* The storage module the file lives in, selected by its scope and/or key; every key given must match exactly one module. When omitted, the table's scope column decides, and a table with no scope column uses the app's storage. */ + storage?: { + /* Scope of the storage module, e.g. "app", "org" or an entity type's scope */scope?: string; + /* Key of the storage module, for a scope with more than one */key?: string; + }; + /* Key of the bucket an upload resolves to. Set this or bucket_tags, not both. */ + bucket?: string; + /* Tags of the bucket an upload resolves to. Set this or bucket, not both. */ + bucket_tags?: string[]; + /* With no bucket named, picks the default public (true) or private (false) bucket; with a bucket named, asserts that bucket is public or private. Omitted, the bucket alone decides. */ + is_public?: boolean; + /* Strict mode: a real foreign key beside the column. Not implemented yet, so the backend refuses true. */ + enforce_fk?: boolean; +} /** BEFORE INSERT trigger that forces a field to the value of jwt_public.current_user_id(). Prevents clients from spoofing the actor/uploader identity. The field value is always overwritten regardless of what the client provides. */ export interface DataForceCurrentUserParams { /* Name of the field to force to current_user_id() */ @@ -460,8 +478,8 @@ export interface DataStatusFieldParams { field_name?: string; /* Column type as a FieldType object */ type?: FieldType; - /* Default value expression (e.g., active) */ - default_value?: string; + /* Default value as a FieldDefault object (e.g., { value: "active" }) */ + default_value?: FieldDefault; /* Whether the column has a NOT NULL constraint */ is_required?: boolean; /* If provided, creates a CHECK constraint restricting the column to these values */ @@ -2291,7 +2309,7 @@ export interface BlueprintEntityType { */ ; /** String shorthand -- just the node type name. */ -export type BlueprintNodeShorthand = 'AuthzAllowAll' | 'AuthzAppMemberOwner' | 'AuthzAppMembership' | 'AuthzColumnSecurity' | 'AuthzComposite' | 'AuthzDatabaseClaim' | 'AuthzDenyAll' | 'AuthzDirectOwner' | 'AuthzDirectOwnerAny' | 'AuthzEntityMembership' | 'AuthzFilePath' | 'AuthzHumanOnly' | 'AuthzMemberList' | 'AuthzMemberOwner' | 'AuthzNotReadOnly' | 'AuthzOrgHierarchy' | 'AuthzPeerOwnership' | 'AuthzPublishable' | 'AuthzRelatedEntityMembership' | 'AuthzRelatedMemberList' | 'AuthzRelatedMemberOwner' | 'AuthzRelatedPeerOwnership' | 'AuthzSystemOnly' | 'AuthzTemporal' | 'AuthzValueAllowed' | 'AuthzValueExists' | 'AuthzValueMatch' | 'CheckGreaterThan' | 'CheckLessThan' | 'CheckNotEqual' | 'CheckOneOf' | 'CheckOwnedRelation' | 'DataArchivable' | 'DataBulk' | 'DataCapabilities' | 'DataCompositeField' | 'DataDenormalized' | 'DataDirectOwner' | 'DataEntityMembership' | 'DataForceCurrentUser' | 'DataGenerated' | 'DataHistory' | 'DataI18n' | 'DataId' | 'DataIdentity' | 'DataImmutableFields' | 'DataInflection' | 'DataInheritFromParent' | 'DataJsonb' | 'DataLock' | 'DataMemberOwner' | 'DataOwnedFields' | 'DataOwnershipInEntity' | 'DataPeoplestamps' | 'DataPrincipalstamps' | 'DataPublishable' | 'DataRealtime' | 'DataSlug' | 'DataSoftDelete' | 'DataStatusField' | 'DataTags' | 'DataTimestamps' | 'SearchBm25' | 'SearchFullText' | 'SearchSpatial' | 'SearchSpatialAggregate' | 'SearchTrgm' | 'SearchUnified' | 'SearchVector' | 'TableOrganizationSettings' | 'TableUserProfiles' | 'TableUserSettings' | 'EventReferral' | 'EventTracker' | 'GuardStepUp' | 'JobTrigger' | 'LimitEnforceAggregate' | 'LimitEnforceCounter' | 'LimitEnforceFeature' | 'LimitEnforceRate' | 'LimitTrackUsage' | 'LimitWarningAggregate' | 'LimitWarningCounter' | 'LimitWarningRate' | 'ProcessChunks' | 'ProcessExtraction' | 'ProcessFileEmbedding' | 'ProcessImageEmbedding' | 'ProcessImageVersions'; +export type BlueprintNodeShorthand = 'AuthzAllowAll' | 'AuthzAppMemberOwner' | 'AuthzAppMembership' | 'AuthzColumnSecurity' | 'AuthzComposite' | 'AuthzDatabaseClaim' | 'AuthzDenyAll' | 'AuthzDirectOwner' | 'AuthzDirectOwnerAny' | 'AuthzEntityMembership' | 'AuthzFilePath' | 'AuthzHumanOnly' | 'AuthzMemberList' | 'AuthzMemberOwner' | 'AuthzNotReadOnly' | 'AuthzOrgHierarchy' | 'AuthzPeerOwnership' | 'AuthzPublishable' | 'AuthzRelatedEntityMembership' | 'AuthzRelatedMemberList' | 'AuthzRelatedMemberOwner' | 'AuthzRelatedPeerOwnership' | 'AuthzSystemOnly' | 'AuthzTemporal' | 'AuthzValueAllowed' | 'AuthzValueExists' | 'AuthzValueMatch' | 'CheckGreaterThan' | 'CheckLessThan' | 'CheckNotEqual' | 'CheckOneOf' | 'CheckOwnedRelation' | 'DataArchivable' | 'DataBulk' | 'DataCapabilities' | 'DataCompositeField' | 'DataDenormalized' | 'DataDirectOwner' | 'DataEntityMembership' | 'DataFileRef' | 'DataForceCurrentUser' | 'DataGenerated' | 'DataHistory' | 'DataI18n' | 'DataId' | 'DataIdentity' | 'DataImmutableFields' | 'DataInflection' | 'DataInheritFromParent' | 'DataJsonb' | 'DataLock' | 'DataMemberOwner' | 'DataOwnedFields' | 'DataOwnershipInEntity' | 'DataPeoplestamps' | 'DataPrincipalstamps' | 'DataPublishable' | 'DataRealtime' | 'DataSlug' | 'DataSoftDelete' | 'DataStatusField' | 'DataTags' | 'DataTimestamps' | 'SearchBm25' | 'SearchFullText' | 'SearchSpatial' | 'SearchSpatialAggregate' | 'SearchTrgm' | 'SearchUnified' | 'SearchVector' | 'TableOrganizationSettings' | 'TableUserProfiles' | 'TableUserSettings' | 'EventReferral' | 'EventTracker' | 'GuardStepUp' | 'JobTrigger' | 'LimitEnforceAggregate' | 'LimitEnforceCounter' | 'LimitEnforceFeature' | 'LimitEnforceRate' | 'LimitTrackUsage' | 'LimitWarningAggregate' | 'LimitWarningCounter' | 'LimitWarningRate' | 'ProcessChunks' | 'ProcessExtraction' | 'ProcessFileEmbedding' | 'ProcessImageEmbedding' | 'ProcessImageVersions'; /** Object form -- { $type, data } with typed parameters. */ export type BlueprintNodeObject = { $type: 'AuthzAllowAll'; @@ -2410,6 +2428,9 @@ export type BlueprintNodeObject = { } | { $type: 'DataEntityMembership'; data: DataEntityMembershipParams; +} | { + $type: 'DataFileRef'; + data: DataFileRefParams; } | { $type: 'DataForceCurrentUser'; data: DataForceCurrentUserParams; diff --git a/packages/node-type-registry/src/data/data-file-ref.ts b/packages/node-type-registry/src/data/data-file-ref.ts new file mode 100644 index 0000000000..fe3147a59f --- /dev/null +++ b/packages/node-type-registry/src/data/data-file-ref.ts @@ -0,0 +1,71 @@ +import type { NodeTypeDefinition } from '../types'; + +export const DataFileRef: NodeTypeDefinition = { + name: 'DataFileRef', + slug: 'data_file_ref', + category: 'data', + display_name: 'File Reference', + description: + 'Registers an existing upload, image or attachment column as a managed reference to a files row: it records which ' + + 'storage module the file lives in and which bucket an upload resolves to, and the backend generates the sync trigger ' + + 'and the GC index from that. The column must be declared in fields[] first; the node creates no column.', + parameter_schema: { + type: 'object', + required: ['field'], + properties: { + field: { + type: 'string', + format: 'column-ref', + pattern: '\\S', + description: 'The upload, image or attachment column to register' + }, + storage: { + type: 'object', + description: + 'The storage module the file lives in, selected by its scope and/or key; every key given must match exactly one module. ' + + 'When omitted, the table\'s scope column decides, and a table with no scope column uses the app\'s storage.', + properties: { + scope: { + type: 'string', + pattern: '\\S', + description: 'Scope of the storage module, e.g. "app", "org" or an entity type\'s scope' + }, + key: { + type: 'string', + pattern: '\\S', + description: 'Key of the storage module, for a scope with more than one' + } + }, + minProperties: 1, + additionalProperties: false + }, + bucket: { + type: 'string', + pattern: '\\S', + description: 'Key of the bucket an upload resolves to. Set this or bucket_tags, not both.' + }, + bucket_tags: { + type: 'array', + items: { type: 'string' }, + description: 'Tags of the bucket an upload resolves to. Set this or bucket, not both.' + }, + is_public: { + type: 'boolean', + description: + 'With no bucket named, picks the default public (true) or private (false) bucket; with a bucket named, ' + + 'asserts that bucket is public or private. Omitted, the bucket alone decides.' + }, + enforce_fk: { + type: 'boolean', + description: 'Strict mode: a real foreign key beside the column. Not implemented yet, so the backend refuses true.', + default: false + } + }, + not: { required: ['bucket', 'bucket_tags'] } + }, + tags: [ + 'storage', + 'files', + 'schema' + ] +}; diff --git a/packages/node-type-registry/src/data/data-status-field.ts b/packages/node-type-registry/src/data/data-status-field.ts index 0e56dd172b..ef68a09db2 100644 --- a/packages/node-type-registry/src/data/data-status-field.ts +++ b/packages/node-type-registry/src/data/data-status-field.ts @@ -22,8 +22,9 @@ export const DataStatusField: NodeTypeDefinition = { default: { name: 'text' } }, default_value: { - type: 'string', - description: 'Default value expression (e.g., active)' + type: 'object', + description: 'Default value as a FieldDefault object (e.g., { value: "active" })', + 'x-codegen-type': 'FieldDefault' }, is_required: { type: 'boolean', diff --git a/packages/node-type-registry/src/data/index.ts b/packages/node-type-registry/src/data/index.ts index 50b0068ae3..32c186d3bd 100644 --- a/packages/node-type-registry/src/data/index.ts +++ b/packages/node-type-registry/src/data/index.ts @@ -10,6 +10,7 @@ export { DataCompositeField } from './data-composite-field'; export { DataDenormalized } from './data-denormalized'; export { DataDirectOwner } from './data-direct-owner'; export { DataEntityMembership } from './data-entity-membership'; +export { DataFileRef } from './data-file-ref'; export { DataForceCurrentUser } from './data-force-current-user'; export { DataGenerated } from './data-generated'; export { DataHistory } from './data-history'; From 50d81f71948fe72875d0653abc4651eee1c3ddd9 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Sun, 29 Nov 2026 21:14:18 +0700 Subject: [PATCH 2/4] fix(graphql-query): declare the input type the reported mutation takes buildPostGraphileUpdate and buildPostGraphileDelete declared $input as Update
Input and Delete
Input from the table name, while the mutation field came from table.query. For a table keyed by "code" the server reports updateParcelByCode, which takes UpdateParcelByCodeInput, so every update_records write failed GraphQL validation. The input type now comes from the reported mutation, the way PostGraphile names it and the way codegen's getUpdateInputTypeName already derives it. _meta has no update input type, and app APIs turn introspection off by default. The generated delete input also declares the table's primary key columns, read from its constraints, in place of a fixed id, a list-typed key staying a list; a table with no primary key keeps id. --- .../__tests__/mutation-input-types.test.ts | 36 +++++++++++++++++++ graphql/query/src/generators/mutations.ts | 4 +-- .../query/src/generators/naming-helpers.ts | 17 ++++++--- graphql/query/src/generators/select.ts | 25 +++++++------ 4 files changed, 64 insertions(+), 18 deletions(-) create mode 100644 graphql/query/__tests__/mutation-input-types.test.ts diff --git a/graphql/query/__tests__/mutation-input-types.test.ts b/graphql/query/__tests__/mutation-input-types.test.ts new file mode 100644 index 0000000000..d720cffe2e --- /dev/null +++ b/graphql/query/__tests__/mutation-input-types.test.ts @@ -0,0 +1,36 @@ +import { buildPostGraphileDelete, buildPostGraphileUpdate } from '../src/generators/mutations'; +import { generateIntrospectionSchema } from '../src/generators/select'; +import type { Table } from '../src/types/schema'; + +const CODE = { name: 'code', type: { gqlType: 'String', isArray: false } }; + +// A table keyed by "code": PostGraphile names its mutations updateParcelByCode and deleteParcelByCode. +const PARCEL: Table = { + name: 'Parcel', + fields: [CODE], + relations: { belongsTo: [], hasOne: [], hasMany: [], manyToMany: [] }, + query: { all: 'parcels', one: 'parcel', create: 'createParcel', update: 'updateParcelByCode', delete: 'deleteParcelByCode' }, + constraints: { primaryKey: [{ name: 'parcels_pkey', fields: [CODE] }], foreignKey: [], unique: [] }, +}; + +describe('mutation input types', () => { + it('declares the input type that the update and delete mutations the server reported take', () => { + expect(buildPostGraphileUpdate(PARCEL, [PARCEL]).toString()).toContain('$input: UpdateParcelByCodeInput!'); + expect(buildPostGraphileDelete(PARCEL, [PARCEL]).toString()).toContain('$input: DeleteParcelByCodeInput!'); + }); + + it('gives the delete input the primary key the table is keyed by', () => { + const { input } = generateIntrospectionSchema([PARCEL]).deleteParcelByCode.properties; + + expect(input.type).toBe('DeleteParcelByCodeInput'); + expect(input.properties).toEqual({ code: { name: 'code', type: 'String', isNotNull: true, isArray: false, isArrayNotNull: false } }); + }); + + it('keeps a list-typed key column a list in the delete input', () => { + const tags = { name: 'tags', type: { gqlType: 'String', isArray: true } }; + const table: Table = { ...PARCEL, fields: [tags], constraints: { primaryKey: [{ name: 'parcels_pkey', fields: [tags] }], foreignKey: [], unique: [] } }; + const { input } = generateIntrospectionSchema([table]).deleteParcelByCode.properties; + + expect(input.properties.tags.isArray).toBe(true); + }); +}); diff --git a/graphql/query/src/generators/mutations.ts b/graphql/query/src/generators/mutations.ts index 6dba68fbd8..a02631311e 100644 --- a/graphql/query/src/generators/mutations.ts +++ b/graphql/query/src/generators/mutations.ts @@ -133,7 +133,7 @@ export function buildPostGraphileUpdate( > { const mutationName = toUpdateMutationName(table.name, table); const singularName = toCamelCaseSingular(table.name, table); - const inputTypeName = toUpdateInputTypeName(table.name); + const inputTypeName = toUpdateInputTypeName(table.name, table); // Create the variable definition for $input const variableDefinitions: VariableDefinitionNode[] = [ @@ -209,7 +209,7 @@ export function buildPostGraphileDelete( { input: { id: string | number } } > { const mutationName = toDeleteMutationName(table.name, table); - const inputTypeName = toDeleteInputTypeName(table.name); + const inputTypeName = toDeleteInputTypeName(table.name, table); // Create the variable definition for $input const variableDefinitions: VariableDefinitionNode[] = [ diff --git a/graphql/query/src/generators/naming-helpers.ts b/graphql/query/src/generators/naming-helpers.ts index 6a161e753f..18d7ab01d2 100644 --- a/graphql/query/src/generators/naming-helpers.ts +++ b/graphql/query/src/generators/naming-helpers.ts @@ -7,7 +7,7 @@ * * Back-ported from Dashboard's `packages/data/src/query-generator.ts`. */ -import { pluralize,toCamelCase, toConstantCase } from 'inflekt'; +import { pluralize,toCamelCase, toConstantCase, ucFirst } from 'inflekt'; import type { Table } from '../types/schema'; @@ -143,12 +143,19 @@ export function toCreateInputTypeName( ); } -export function toUpdateInputTypeName(tableName: string): string { - return `Update${tableName}Input`; +// PostGraphile names a mutation's input type after the mutation: updateParcelByCode takes UpdateParcelByCodeInput. +export function toUpdateInputTypeName( + tableName: string, + table?: Table | null, +): string { + return `${ucFirst(toUpdateMutationName(tableName, table))}Input`; } -export function toDeleteInputTypeName(tableName: string): string { - return `Delete${tableName}Input`; +export function toDeleteInputTypeName( + tableName: string, + table?: Table | null, +): string { + return `${ucFirst(toDeleteMutationName(tableName, table))}Input`; } export function toFilterTypeName( diff --git a/graphql/query/src/generators/select.ts b/graphql/query/src/generators/select.ts index 663302c9e8..c0b6f82c70 100644 --- a/graphql/query/src/generators/select.ts +++ b/graphql/query/src/generators/select.ts @@ -174,7 +174,7 @@ export function generateIntrospectionSchema( properties: { input: { name: 'input', - type: toUpdateInputTypeName(modelName), + type: toUpdateInputTypeName(modelName, table), isNotNull: true, isArray: false, isArrayNotNull: false, @@ -201,19 +201,11 @@ export function generateIntrospectionSchema( properties: { input: { name: 'input', - type: toDeleteInputTypeName(modelName), + type: toDeleteInputTypeName(modelName, table), isNotNull: true, isArray: false, isArrayNotNull: false, - properties: { - id: { - name: 'id', - type: 'UUID', - isNotNull: true, - isArray: false, - isArrayNotNull: false, - }, - }, + properties: primaryKeyProperties(table), }, }, } as MutationDefinition; @@ -222,6 +214,17 @@ export function generateIntrospectionSchema( return schema; } +function primaryKeyProperties(table: Table) { + const keys = table.constraints?.primaryKey?.[0]?.fields ?? []; + const fields = keys.length > 0 ? keys : [{ name: 'id', type: { gqlType: 'UUID', isArray: false } }]; + return Object.fromEntries( + fields.map((field) => [ + field.name, + { name: field.name, type: field.type.gqlType, isNotNull: true, isArray: field.type.isArray, isArrayNotNull: false }, + ]), + ); +} + /** * Convert Table fields to QueryBuilder properties */ From 9d3f07cd674c46c5795808fddbf92b70dd93f252 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Sun, 29 Nov 2026 21:14:18 +0700 Subject: [PATCH 3/4] feat(harness): an approval card for update_records, and approval channels that remember the table The confirm gate shows the rows an update_records call will change, like add_records. rememberApprovedTable lets any approval path, including a host's own approval channel, record the table a person approved, so delete_table no longer refuses a delete approved outside the kit's gate. --- agentic/harness/__tests__/plan.test.ts | 10 +++++++++ agentic/harness/src/gating/confirm-gate.ts | 24 ++++++++++++++-------- agentic/harness/src/gating/prompts.ts | 9 +++++--- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/agentic/harness/__tests__/plan.test.ts b/agentic/harness/__tests__/plan.test.ts index 9d280ac374..03cfb40f3b 100644 --- a/agentic/harness/__tests__/plan.test.ts +++ b/agentic/harness/__tests__/plan.test.ts @@ -73,6 +73,16 @@ describe('the rows of add_records', () => { }); }); +describe('the rows of update_records', () => { + it('names the rows it changes, and shows them as records', () => { + const records = [{ id: '@deals[0]', data_room_id: 'r1' }]; + const prompt = buildConfirmPrompt('update_records', { table_name: 'deals', records }, { target: TARGET }); + expect(prompt.title).toBe('Change 1 row in deals'); + expect(prompt.message).toMatch(/^~ 1 row in deals\n {4}id\s+data_room_id\n {4}@deals\[0\]\s+r1/); + expect(prompt.preview).toEqual({ kind: 'records', tableName: 'deals', rows: records }); + }); +}); + describe('the tables of create_template', () => { it('lists the tables the template takes under the change, one line each', async () => { const policy = createConstructiveGatePolicy({ diff --git a/agentic/harness/src/gating/confirm-gate.ts b/agentic/harness/src/gating/confirm-gate.ts index 92d027a572..504b70c326 100644 --- a/agentic/harness/src/gating/confirm-gate.ts +++ b/agentic/harness/src/gating/confirm-gate.ts @@ -22,6 +22,20 @@ export type GateResult = { block: true; reason: string; failure?: ToolFailure } const approvedTables = new Map>(); +/** + * Remember the table a person approved for a call, so the tool acts only on that table (`takeApprovedTable`). Every + * approval path calls it once the call is approved: this gate, and a host that asks through its own approval channel. + */ +export function rememberApprovedTable(toolCallId: string, cwd: string, target: PlanTarget): void { + if (target.kind !== 'database' || !target.table) return; + const key = JSON.stringify([cwd, toolCallId]); + const approved = structuredClone(target); + approvedTables.set(key, approved); + setTimeout(() => { + if (approvedTables.get(key) === approved) approvedTables.delete(key); + }, 60_000).unref(); +} + export function takeApprovedTable(toolCallId: string, cwd: string) { const key = JSON.stringify([cwd, toolCallId]); const target = approvedTables.get(key); @@ -96,7 +110,7 @@ export function createConfirmGate(options: ConfirmGateOptions): ConfirmGate { }; } - const tableTarget = prompt.target.kind === 'database' && prompt.target.table ? structuredClone(prompt.target) : undefined; + const target = structuredClone(prompt.target); const approved = await host.confirmTool( event.toolCallId, prompt.title, @@ -108,13 +122,7 @@ export function createConfirmGate(options: ConfirmGateOptions): ConfirmGate { declineGuard.recordDecline(event.toolName, input); return { block: true, reason: buildDeclineReason(event.toolName) }; } - if (tableTarget) { - const key = JSON.stringify([cwd, event.toolCallId]); - approvedTables.set(key, tableTarget); - setTimeout(() => { - if (approvedTables.get(key) === tableTarget) approvedTables.delete(key); - }, 60_000).unref(); - } + rememberApprovedTable(event.toolCallId, cwd, target); // An approved mutation changes state, so earlier declines may no longer // describe the same effect (e.g. a create_template preview derives from // the blueprint, not the input) — let them re-prompt with fresh eyes. diff --git a/agentic/harness/src/gating/prompts.ts b/agentic/harness/src/gating/prompts.ts index e322bfb5fe..3a74c156e8 100644 --- a/agentic/harness/src/gating/prompts.ts +++ b/agentic/harness/src/gating/prompts.ts @@ -248,12 +248,15 @@ function describeCall( const name = str(input, 'templateName') ?? '?'; return { title: `Delete template ${name}`, message: [`- template ${name}`, UNDONE].join('\n') }; } - case 'add_records': { + case 'add_records': + case 'update_records': { const rows = recordRows(input); const tableName = str(input, 'table_name') ?? '?'; + const count = plural(rows.length, 'row'); + const [title, line] = toolName === 'add_records' ? [`Add ${count} to`, `+ ${count} into`] : [`Change ${count} in`, `~ ${count} in`]; return { - title: `Add ${plural(rows.length, 'row')} to ${tableName}`, - message: [`+ ${plural(rows.length, 'row')} into ${tableName}`, ...under(rows.length ? rowLines(rows) : [])].join('\n'), + title: `${title} ${tableName}`, + message: [`${line} ${tableName}`, ...under(rows.length ? rowLines(rows) : [])].join('\n'), preview: rows.length > 0 ? { kind: 'records', tableName, rows } : undefined, }; } From 3d1f14ab388a3e78e5562b3135315a9b1f2a49c9 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Sun, 29 Nov 2026 21:14:18 +0700 Subject: [PATCH 4/4] feat(db-tools): one records layer for add_records and update_records - update_records changes rows that exist, by key or by @table[i] for a row the build seeded (through the host's seededRows hook), and waits on the same approval as add_records. - Both take the table's column names (deal_id) as well as field names, refuse a key that is neither before any row is sent, naming the nearest column, and never let an empty alias erase a value given under the other name; when both names carry a value, the field name wins. - An empty value in update_records clears the column (null), as documented, and only a record's own keys count, so a field named like toString maps. - add_records returns the new rows' ids. - A table lookup keys every GraphQL name before any SQL name, so one table's SQL name can't take another table's lookups, and an @table[i] reference matches its table ignoring case, as the host lookup does. - The CLI leaves update_records out. --- agentic/cli/README.md | 2 +- agentic/cli/__tests__/db-tools.test.ts | 4 +- agentic/cli/src/db-tools.ts | 2 +- agentic/db-tools/README.md | 2 +- .../__tests__/access-provisioning.test.ts | 1 + .../__tests__/find-meta-table.test.ts | 16 + .../__tests__/gate-precondition.test.ts | 23 +- agentic/db-tools/__tests__/host.test.ts | 1 + agentic/db-tools/__tests__/records.test.ts | 194 +++++++++++ .../db-tools/__tests__/schema-checks.test.ts | 1 + .../db-tools/__tests__/tool-contract.test.ts | 3 + agentic/db-tools/src/access/provisioning.ts | 1 + agentic/db-tools/src/host.ts | 6 + agentic/db-tools/src/index.ts | 3 +- agentic/db-tools/src/records/meta.ts | 29 +- agentic/db-tools/src/records/rows.ts | 306 ++++++++++++++++++ agentic/db-tools/src/tools/add-records.ts | 204 +----------- agentic/db-tools/src/tools/index.ts | 3 + agentic/db-tools/src/tools/update-records.ts | 64 ++++ agentic/pi/__tests__/pi-tool.test.ts | 2 +- 20 files changed, 664 insertions(+), 203 deletions(-) create mode 100644 agentic/db-tools/__tests__/find-meta-table.test.ts create mode 100644 agentic/db-tools/__tests__/records.test.ts create mode 100644 agentic/db-tools/src/records/rows.ts create mode 100644 agentic/db-tools/src/tools/update-records.ts diff --git a/agentic/cli/README.md b/agentic/cli/README.md index 1ceb6c8d8e..02eb1464da 100644 --- a/agentic/cli/README.md +++ b/agentic/cli/README.md @@ -26,7 +26,7 @@ On startup, `agent` assembles the harness skill tree and drops you into an inter 1. **Base layer** — [`constructive-io/constructive-skills`](https://github.com/constructive-io/constructive-skills), fetched as a git tag/branch/SHA tarball into `~/.constructive/data/skills//` (default ref: `main`; offline fallback: newest cached release). 2. **Local overlay** — `~/.constructive/config/skills-overlay//SKILL.md` (agentskills.io layout), highest precedence: a same-name skill replaces the base skill wholesale. -3. **Typed db tools** — the [`@agentic-kit/pi`](https://www.npmjs.com/package/@agentic-kit/pi) extension (including `provision_database`, `provision_blueprint`, `describe_schema`, and `run_codegen`) is materialized into the agent dir and loaded by pi automatically. The CLI does not register `add_records` or `create_api_key`; it has no tenant sign-in or secret-delivery integration for those tools. +3. **Typed db tools** — the [`@agentic-kit/pi`](https://www.npmjs.com/package/@agentic-kit/pi) extension (including `provision_database`, `provision_blueprint`, `describe_schema`, and `run_codegen`) is materialized into the agent dir and loaded by pi automatically. The CLI does not register `add_records`, `update_records` or `create_api_key`; it has no tenant sign-in or secret-delivery integration for those tools. The merged tree is materialized into the appstash-owned agent dir, so the session picks the skills up natively. All harness state lives in the [appstash](https://github.com/constructive-io/appstash) `~/.constructive/` layout; project directories are untouched. diff --git a/agentic/cli/__tests__/db-tools.test.ts b/agentic/cli/__tests__/db-tools.test.ts index 9ff651acb3..933ccaa596 100644 --- a/agentic/cli/__tests__/db-tools.test.ts +++ b/agentic/cli/__tests__/db-tools.test.ts @@ -56,8 +56,10 @@ describe('materializeDbTools', () => { }); expect(registered).toContain('provision_database'); expect(registered).not.toContain('add_records'); + expect(registered).not.toContain('update_records'); expect(registered).not.toContain('create_api_key'); - const expected = constructiveDbTools.map((tool) => tool.name).filter((name) => name !== 'add_records' && name !== 'create_api_key'); + const excluded = ['add_records', 'update_records', 'create_api_key']; + const expected = constructiveDbTools.map((tool) => tool.name).filter((name) => !excluded.includes(name)); expect(registered.sort()).toEqual(expected.sort()); }); diff --git a/agentic/cli/src/db-tools.ts b/agentic/cli/src/db-tools.ts index 0478ee4bd2..19e0c41728 100644 --- a/agentic/cli/src/db-tools.ts +++ b/agentic/cli/src/db-tools.ts @@ -36,7 +36,7 @@ module.exports = createDbTools({ account: resolveAccount, backendConfig: resolveBackendConfig, signInHint: 'Run \`agent login\` to sign in.' -}, { excludeTools: ['add_records', 'create_api_key'] }); +}, { excludeTools: ['add_records', 'update_records', 'create_api_key'] }); `; } diff --git a/agentic/db-tools/README.md b/agentic/db-tools/README.md index 07f63fc577..c73c53a1dd 100644 --- a/agentic/db-tools/README.md +++ b/agentic/db-tools/README.md @@ -27,7 +27,7 @@ npm install @agentic-kit/db-tools ## What's inside -- **25 typed db tools** — `provision_database` / `replace_database`, `provision_blueprint`, `describe_schema`, `add_relation`, `delete_table`, `create_field` / `update_field` / `retype_field` / `delete_field`, `add_policies`, `add_records`, `list_entity_types` / `create_entity_type` / `delete_entity_type`, `create_api_key`, `run_codegen`, the template suite (`list` / `create` / `apply` / `update` / `delete`), the access tools (`explain_access`, `set_access`), and `describe_policy_type`. `constructiveDbTools` is the list, in registration order. Each states one effect (`read`, `write` or `destructive`) for every call; a change whose effect differs is its own tool (`retype_field` beside `update_field`, `replace_database` beside `provision_database`). Every failing call returns a `failure` (code, message, hint) beside the `details` it always had. A message or hint names no tool and no parameter: the calls that help travel as data (`failure.calls`, `result.calls`). Every object of a tool's own input refuses a key it does not have and names the nearest known one, instead of dropping it; Every change that names a table, a field, a template or an entity type finds it, or finds a new name's stored form free, before there is a plan to approve. A call that did only part of what was asked (a field without its unique constraint, some of the rows) returns the code `partial`, and its `details` hold the errors of the part that failed. Backend errors are read by their `extensions.code` and `extensions.class`, then the HTTP status (`extensions.http` first: the server answers HTTP 200 and puts the status there), then a masked internal error with its `errorId`; message text never decides, because the server masks the text it does not mean to show. `failureFromErrors(errors, action, meaning?)` is that mapping, exported for code that sends its own GraphQL (`postGraphQL`, which takes an `operationName`), and `FailureMeaning` names what a unique violation means for the call. +- **26 typed db tools** — `provision_database` / `replace_database`, `provision_blueprint`, `describe_schema`, `add_relation`, `delete_table`, `create_field` / `update_field` / `retype_field` / `delete_field`, `add_policies`, `add_records` / `update_records`, `list_entity_types` / `create_entity_type` / `delete_entity_type`, `create_api_key`, `run_codegen`, the template suite (`list` / `create` / `apply` / `update` / `delete`), the access tools (`explain_access`, `set_access`), and `describe_policy_type`. `constructiveDbTools` is the list, in registration order. Each states one effect (`read`, `write` or `destructive`) for every call; a change whose effect differs is its own tool (`retype_field` beside `update_field`, `replace_database` beside `provision_database`). Every failing call returns a `failure` (code, message, hint) beside the `details` it always had. A message or hint names no tool and no parameter: the calls that help travel as data (`failure.calls`, `result.calls`). Every object of a tool's own input refuses a key it does not have and names the nearest known one, instead of dropping it; Every change that names a table, a field, a template or an entity type finds it, or finds a new name's stored form free, before there is a plan to approve. A call that did only part of what was asked (a field without its unique constraint, some of the rows) returns the code `partial`, and its `details` hold the errors of the part that failed. Backend errors are read by their `extensions.code` and `extensions.class`, then the HTTP status (`extensions.http` first: the server answers HTTP 200 and puts the status there), then a masked internal error with its `errorId`; message text never decides, because the server masks the text it does not mean to show. `failureFromErrors(errors, action, meaning?)` is that mapping, exported for code that sends its own GraphQL (`postGraphQL`, which takes an `operationName`), and `FailureMeaning` names what a unique violation means for the call. The public `extensions.context` of the error that decided goes into `failure.context`: a query over the backend's request limits (`QUERY_TOO_COSTLY`, `QUERY_TOO_DEEP`, `PAGE_SIZE_TOO_LARGE`, `REQUEST_TOO_LARGE`) is `query-too-large` with its numbers there, for example `{ cost, limit }`. An update or delete that answers with no row in its payload changed nothing: that is how row-level security answers for a row this account cannot see, so every tool that updates or deletes fails `no-rows-changed` there instead of reporting success. A create that answers without the new row fails `no-rows-changed` as well: the row may not exist, or a policy lets the account create it but not read it, and the hint names the call that shows whether it exists. `STEP_UP_REQUIRED` is `step-up-required`: the change needs a recent sign-in. diff --git a/agentic/db-tools/__tests__/access-provisioning.test.ts b/agentic/db-tools/__tests__/access-provisioning.test.ts index 9d30b7a1c5..7443091916 100644 --- a/agentic/db-tools/__tests__/access-provisioning.test.ts +++ b/agentic/db-tools/__tests__/access-provisioning.test.ts @@ -56,6 +56,7 @@ const DATA_ROWS: Array<[string, string[] | 'unknown']> = [ ['DataDenormalized', 'unknown'], ['DataDirectOwner', ['owner_id uuid not null']], ['DataEntityMembership', ['entity_id uuid not null']], + ['DataFileRef', []], ['DataForceCurrentUser', []], ['DataGenerated', 'unknown'], ['DataHistory', []], diff --git a/agentic/db-tools/__tests__/find-meta-table.test.ts b/agentic/db-tools/__tests__/find-meta-table.test.ts new file mode 100644 index 0000000000..785e9a0d0e --- /dev/null +++ b/agentic/db-tools/__tests__/find-meta-table.test.ts @@ -0,0 +1,16 @@ +import { findMetaTable, type RawMetaTable } from '../src/records/meta'; + +// People are stored in the SQL table "records"; the GraphQL type Record is stored in "record_entries". +const PERSON: RawMetaTable = { name: 'Person', tableName: 'records', query: { all: 'people', one: 'person' } }; +const RECORD: RawMetaTable = { name: 'Record', tableName: 'record_entries', query: { all: 'records', one: 'record' } }; + +describe('findMetaTable', () => { + it.each([ + [[PERSON, RECORD]], + [[RECORD, PERSON]], + ])('gives a GraphQL name to its own table before an SQL name of another table claims it', (tables) => { + expect(findMetaTable(tables, 'Record')).toBe(RECORD); + expect(findMetaTable(tables, 'record_entries')).toBe(RECORD); + expect(findMetaTable(tables, 'people')).toBe(PERSON); + }); +}); diff --git a/agentic/db-tools/__tests__/gate-precondition.test.ts b/agentic/db-tools/__tests__/gate-precondition.test.ts index eb5e76023e..8c402390bc 100644 --- a/agentic/db-tools/__tests__/gate-precondition.test.ts +++ b/agentic/db-tools/__tests__/gate-precondition.test.ts @@ -2,7 +2,7 @@ import { mkdtempSync, readdirSync, rmSync, writeFileSync } from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { createConfirmGate, createConstructiveGatePolicy, type GateHost, type PlanTarget } from '@agentic-kit/harness'; +import { createConfirmGate, createConstructiveGatePolicy, type GateHost, type PlanTarget, rememberApprovedTable } from '@agentic-kit/harness'; import { constructiveDbTools, constructiveGateDeps } from '../src'; import type { RunCommand } from '../src/app-workspace'; @@ -102,7 +102,7 @@ describe('a gated call never runs unasked', () => { // What the named things are: the table "posts" (on the control plane and on the app's API) and the template "Blog". function namedAnswer({ host, query }: SeenRequest): GraphQLAnswer { - if (host.startsWith('api-mydb.')) return { data: { _meta: { tables: [{ name: 'Post', query: { all: 'posts' }, inflection: { tableType: 'Post' }, fields: [] }] } } }; + if (host.startsWith('api-mydb.')) return { data: { _meta: { tables: [{ name: 'Post', query: { all: 'posts' }, inflection: { tableType: 'Post' }, fields: [{ name: 'title', columnName: 'title', type: { gqlType: 'String', isArray: false } }] }] } } }; if (/blueprintTemplates/.test(query)) return { data: { blueprintTemplates: { nodes: [{ id: 'tpl-1', displayName: 'Blog', definition: {} }] } } }; if (/uniqueConstraints/.test(query)) return { data: { uniqueConstraints: { nodes: [] } } }; if (/\bfields\b/.test(query)) return { data: { fields: { nodes: [] } } }; @@ -166,6 +166,25 @@ describe('the plan names what the call acts on', () => { expect(backend.requests.some(({ query }) => /mutation/.test(query))).toBe(!replaced); }); + it('deletes the table a host approved through its own approval channel', async () => { + await backend.close(); + backend = await startFakeBackend(({ query }) => { + if (/mutation/.test(query)) return { data: { deleteTable: { table: { id: 'original' } } } }; + if (/\btables\b/.test(query)) return { data: { tables: { nodes: [{ name: 'posts', id: 'original' }] } } }; + return projectAnswer(query, 'ME') ?? { data: {} }; + }); + const tool = constructiveDbTools.find(({ name }) => name === 'delete_table')!; + const event = { toolName: tool.name, toolCallId: 'delete-2', input: { table_name: 'posts' } }; + const decision = await createConstructiveGatePolicy(constructiveGateDeps()).resolvePrompt(event, cwd); + if (decision.kind !== 'ask') throw new Error('expected a card'); + rememberApprovedTable(event.toolCallId, cwd, decision.prompt.target); + + const result = await tool.execute(event.input, { cwd, toolCallId: event.toolCallId }); + + expect(result.failure).toBeUndefined(); + expect(backend.requests.some(({ query }) => /mutation/.test(query))).toBe(true); + }); + it('plans saved template access using the schema where each table will be created', async () => { await backend.close(); backend = await startFakeBackend((request) => { diff --git a/agentic/db-tools/__tests__/host.test.ts b/agentic/db-tools/__tests__/host.test.ts index bd761d5d4d..ddcd5c08bc 100644 --- a/agentic/db-tools/__tests__/host.test.ts +++ b/agentic/db-tools/__tests__/host.test.ts @@ -69,6 +69,7 @@ describe('constructiveDbTools', () => { 'update_template', 'delete_template', 'add_records', + 'update_records', 'list_entity_types', 'create_entity_type', 'delete_entity_type', diff --git a/agentic/db-tools/__tests__/records.test.ts b/agentic/db-tools/__tests__/records.test.ts new file mode 100644 index 0000000000..cd22e30a68 --- /dev/null +++ b/agentic/db-tools/__tests__/records.test.ts @@ -0,0 +1,194 @@ +import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; + +import { configureHost, type ToolsHost } from '../src/host'; +import { recordAsFields } from '../src/records/rows'; +import { addRecordsTool } from '../src/tools/add-records'; +import { updateRecordsTool } from '../src/tools/update-records'; +import { DATABASE_ID, type FakeBackend, type GraphQLAnswer, projectAnswer, startFakeBackend } from './fake-backend'; + +const DEAL = '019a1d47-0000-7000-8000-000000000001'; +const ROOM = '019a1d47-0000-7000-8000-000000000002'; + +const field = (name: string, columnName: string, extra: Record = {}) => ({ + name, + columnName, + isNotNull: false, + hasDefault: false, + type: { gqlType: name === 'id' || name.endsWith('Id') ? 'UUID' : 'String', isArray: false }, + ...extra, +}); + +// The app's own API: deals link to data rooms through deal.data_room_id (dataRoomId in GraphQL). +const TABLES = [ + { + name: 'Deal', + tableName: 'deals', + query: { all: 'deals', one: 'deal', create: 'createDeal', update: 'updateDeal', delete: 'deleteDeal' }, + inflection: { tableType: 'Deal', createInputType: 'CreateDealInput', patchType: 'DealPatch' }, + fields: [ + field('id', 'id', { isPrimaryKey: true, hasDefault: true }), + field('name', 'name'), + field('stage', 'stage'), + field('dataRoomId', 'data_room_id'), + field('updatedAt', 'updated_at', { isWritableOnUpdate: false }), + ], + }, + { + name: 'DataRoom', + tableName: 'data_rooms', + query: { all: 'dataRooms', one: 'dataRoom', create: 'createDataRoom', update: 'updateDataRoom', delete: 'deleteDataRoom' }, + inflection: { tableType: 'DataRoom', createInputType: 'CreateDataRoomInput', patchType: 'DataRoomPatch' }, + fields: [field('id', 'id', { isPrimaryKey: true, hasDefault: true }), field('name', 'name'), field('dealId', 'deal_id')], + }, + { + name: 'Parcel', + tableName: 'parcels', + query: { all: 'parcels', one: 'parcel', create: 'createParcel', update: 'updateParcelByCode', delete: 'deleteParcelByCode' }, + inflection: { tableType: 'Parcel', createInputType: 'CreateParcelInput', patchType: 'ParcelPatch' }, + fields: [field('code', 'code', { isPrimaryKey: true }), field('status', 'status')], + }, +]; + +// The input type each update mutation takes on the server. +const UPDATE_INPUT: Record = { updateDeal: 'UpdateDealInput', updateParcelByCode: 'UpdateParcelByCodeInput' }; + +function appBackend(query: string, variables: Record): GraphQLAnswer { + if (/DbToolsMeta/.test(query)) return { data: { _meta: { tables: TABLES } } }; + const update = query.match(/\$input: (\w+)!.*?(update\w+)\(input/s); + if (update && UPDATE_INPUT[update[2]] !== update[1]) { + return { data: null, errors: [{ message: `Variable "$input" of type "${update[1]}!" used in position expecting type "${UPDATE_INPUT[update[2]]}!".` }] }; + } + const input = variables.input as Record & { id?: string }>; + if (/updateDeal\(/.test(query)) return { data: { updateDeal: { deal: { id: input.id, ...input.dealPatch } } } }; + if (/updateParcelByCode\(/.test(query)) return { data: { updateParcelByCode: { parcel: { code: input.code, ...input.parcelPatch } } } }; + if (/createDataRoom\(/.test(query)) return { data: { createDataRoom: { dataRoom: { id: ROOM, ...input.dataRoom } } } }; + return { data: {} }; +} + +let cwd: string; +let backend: FakeBackend; + +const host = (extra: Partial = {}): ToolsHost => ({ + account: () => ({ userId: 'ME', accessToken: 'account-bearer' }), + backendConfig: () => ({ apiEndpoint: backend.endpoint(), modulesEndpoint: backend.endpoint('modules.localhost') }), + previewToken: async () => ({ accessToken: 'app-user-token', userId: 'U1' }), + ...extra, +}); + +beforeEach(async () => { + cwd = mkdtempSync(path.join(os.tmpdir(), 'db-records-')); + writeFileSync(path.join(cwd, '.env'), `DATABASE_ID=${DATABASE_ID}\nDATABASE_NAME=mydb\n`); + backend = await startFakeBackend(({ host: to, query, variables }) => + projectAnswer(query, 'ME') ?? (to.startsWith('api-mydb.') ? appBackend(query, variables) : { data: {} }), + ); + configureHost(host()); +}); +afterEach(async () => { + rmSync(cwd, { recursive: true, force: true }); + await backend.close(); +}); + +const writes = () => backend.requests.filter((request) => /^mutation/.test(request.query.trim())).map((request) => request.variables.input); +const update = (records: Record[]) => updateRecordsTool.execute({ table_name: 'deals', records }, { cwd }); + +describe('update_records', () => { + it('sets columns by their column names, on the row its primary key names', async () => { + const result = await update([{ id: DEAL, data_room_id: ROOM, stage: 'diligence' }]); + + expect(result.failure).toBeUndefined(); + expect(writes()).toEqual([{ id: DEAL, dealPatch: { dataRoomId: ROOM, stage: 'diligence' } }]); + expect(result.details).toMatchObject({ success: true, updatedCount: 1, rows: [{ id: DEAL, dataRoomId: ROOM, stage: 'diligence' }] }); + }); + + it.each<[Record, string]>([ + [{ data_room_id: ROOM }, 'Row 0 names no row: give its "id".'], + [{ id: DEAL }, 'Row 0 sets no column besides "id".'], + [{ id: DEAL, updated_at: '2026-11-29T00:00:00Z' }, 'Row 0 sets "updated_at", which the app API does not let anyone change.'], + ])('refuses %j before it changes any row', async (record, message) => { + const result = await update([record]); + + expect(result.failure).toMatchObject({ code: 'invalid-input', message }); + expect(writes()).toEqual([]); + }); + + it('names a row, and points a column, at sample rows the host seeded, in any case', async () => { + configureHost(host({ seededRows: async () => ({ deals: [DEAL], DataRooms: [ROOM] }) })); + + const result = await update([{ id: '@Deals[0]', data_room_id: '@data_rooms[0]' }]); + + expect(result.failure).toBeUndefined(); + expect(writes()).toEqual([{ id: DEAL, dealPatch: { dataRoomId: ROOM } }]); + }); + + it.each<[string, unknown]>([ + ['an id', DEAL], + ['a sample row', '@deals[0]'], + ])('takes the field name over the column name when both give a value, when the column name gives %s', async (_, other) => { + configureHost(host({ seededRows: async () => ({ deals: [DEAL] }) })); + + const result = await update([{ id: DEAL, dataRoomId: ROOM, data_room_id: other }]); + + expect(result.failure).toBeUndefined(); + expect(writes()).toEqual([{ id: DEAL, dealPatch: { dataRoomId: ROOM } }]); + }); + + it('refuses a sample row that was not seeded, on a host that seeds rows and on one that does not', async () => { + for (const extra of [{ seededRows: async () => ({ deals: [DEAL] }) }, {}]) { + configureHost(host(extra)); + const result = await update([{ id: '@deals[3]', stage: 'won' }]); + expect(result.failure).toMatchObject({ code: 'invalid-input', message: 'Row 0 names "@deals[3]", but no sample row was seeded there: use the row\'s id.' }); + } + expect(writes()).toEqual([]); + }); + + it('updates a table whose primary key is not id, with the input type its update mutation takes', async () => { + const result = await updateRecordsTool.execute({ table_name: 'parcels', records: [{ code: 'P-7', status: 'sold' }] }, { cwd }); + + expect(result.failure).toBeUndefined(); + expect(writes()).toEqual([{ code: 'P-7', parcelPatch: { status: 'sold' } }]); + }); + + it.each([null, ''])('clears a column given as %j', async (value) => { + await update([{ id: DEAL, data_room_id: value }]); + + expect(writes()).toEqual([{ id: DEAL, dealPatch: { dataRoomId: null } }]); + }); +}); + +describe('add_records', () => { + const add = (records: Record[]) => addRecordsTool.execute({ table_name: 'data_rooms', records }, { cwd }); + + it('points a new row at a seeded row by its column name, and gives the new rows\' keys so a later call can name them', async () => { + configureHost(host({ seededRows: async () => ({ deals: [DEAL] }) })); + + const result = await add([{ name: 'Arcadia room', deal_id: '@deals[0]' }]); + + expect(writes()).toEqual([{ dataRoom: { name: 'Arcadia room', dealId: DEAL } }]); + expect(result.content[0]).toEqual({ type: 'text', text: `Inserted 1 row(s) into data_rooms.\nThe new rows' id values, in insert order: "${ROOM}".` }); + }); + + it('keeps a value given under one name when the other name for the same column is empty', async () => { + await add([{ name: 'Arcadia', dealId: DEAL, deal_id: null }]); + + expect(writes()).toEqual([{ dataRoom: { name: 'Arcadia', dealId: DEAL } }]); + }); + + it('refuses a name that is no column of the table before it inserts any row, and names the nearest column', async () => { + const result = await add([{ name: 'Arcadia' }, { name: 'Beacon', deals_id: DEAL }]); + + expect(result.failure).toMatchObject({ code: 'invalid-input', message: 'Row 1 names "deals_id", which is not a column of data_rooms: use "deal_id".' }); + expect(writes()).toEqual([]); + }); +}); + +describe('recordAsFields', () => { + it('maps a column whose field name is also an inherited object property', () => { + const table = { name: 'Note', fields: [field('id', 'id', { isPrimaryKey: true }), field('toString', 'to_string')] }; + + const result = recordAsFields(table as never, 'notes', 0, { to_string: 'kept' }, new Map(), true); + + expect(result).toEqual({ kind: 'ok', value: { toString: 'kept' } }); + }); +}); diff --git a/agentic/db-tools/__tests__/schema-checks.test.ts b/agentic/db-tools/__tests__/schema-checks.test.ts index e5271e2a97..6d36d47252 100644 --- a/agentic/db-tools/__tests__/schema-checks.test.ts +++ b/agentic/db-tools/__tests__/schema-checks.test.ts @@ -213,6 +213,7 @@ describe('no plan for a change that cannot work', () => { ['set_access', { table_name: 'no_such_table', policies: [{ $type: 'AuthzAppMembership', privileges: ['select'] }] }, 'not-found', 'Table "no_such_table" was not found'], ['add_relation', { source_table: 'no_such_table', target_table: 'users', field_name: 'owner_id' }, 'not-found', 'Table "no_such_table" not found'], ['add_records', { table_name: 'no_such_table', records: [{ title: 'x' }] }, 'not-found', 'Table "no_such_table" was not found in the app database'], + ['update_records', { table_name: 'no_such_table', records: [{ id: 'x', title: 'x' }] }, 'not-found', 'Table "no_such_table" was not found in the app database'], [ 'provision_blueprint', { diff --git a/agentic/db-tools/__tests__/tool-contract.test.ts b/agentic/db-tools/__tests__/tool-contract.test.ts index c5652cbf13..e472103bb2 100644 --- a/agentic/db-tools/__tests__/tool-contract.test.ts +++ b/agentic/db-tools/__tests__/tool-contract.test.ts @@ -57,6 +57,7 @@ const CALLS: [string, Record, ToolEffect][] = [ ['update_template', { templateName: 'CRM', patch: { description: 'Contacts' } }, 'write'], ['delete_template', { templateName: 'CRM' }, 'destructive'], ['add_records', { table_name: 'posts', records: [{ title: 'Hello' }] }, 'write'], + ['update_records', { table_name: 'posts', records: [{ id: UUID, title: 'Hello' }] }, 'write'], ['list_entity_types', {}, 'read'], ['create_entity_type', { name: 'team' }, 'write'], ['delete_entity_type', { entity_type_id: UUID }, 'destructive'], @@ -103,6 +104,7 @@ describe('the Constructive gate policy', () => { 'update_template', 'delete_template', 'add_records', + 'update_records', 'create_entity_type', 'delete_entity_type', 'create_api_key', @@ -272,6 +274,7 @@ describe('tool failures without a network', () => { ['no .env', 'create_entity_type', { name: ' ' }, 'invalid-input'], ['no .env', 'create_api_key', { key_name: ' ' }, 'invalid-input'], ['no .env', 'add_records', { table_name: 'posts', records: [] }, 'invalid-input'], + ['no .env', 'update_records', { table_name: 'posts', records: [] }, 'invalid-input'], ]; it.each(ROWS)('%s: %s %j fails with %s', async (scenario, name, params, code) => { diff --git a/agentic/db-tools/src/access/provisioning.ts b/agentic/db-tools/src/access/provisioning.ts index af6f787ddf..7504aaeda8 100644 --- a/agentic/db-tools/src/access/provisioning.ts +++ b/agentic/db-tools/src/access/provisioning.ts @@ -139,6 +139,7 @@ export const ADDED_FIELDS: Record = { } ], DataEntityMembership: [{ name: { param: 'entity_field_name' }, type: 'uuid', required: true, default: null }], + DataFileRef: [], DataForceCurrentUser: [], DataGenerated: [ { diff --git a/agentic/db-tools/src/host.ts b/agentic/db-tools/src/host.ts index 27c990cd94..178a9cac94 100644 --- a/agentic/db-tools/src/host.ts +++ b/agentic/db-tools/src/host.ts @@ -197,6 +197,12 @@ export interface ToolsHost { * the call fails with `binding-not-saved`. */ persistBinding?(binding: ProjectBinding): Promise; + /** + * The ids of the sample rows the host seeded into the project's database, by table name, in seed order (null for + * a row that did not land). A record value "@
[]" in add_records or update_records names one of them. + * A host that seeds no rows leaves it out, and such a value then fails. + */ + seededRows?(cwd: string): Promise> | null>; } export const DEFAULT_DATA_TOKEN_SKEW_MS = 30_000; diff --git a/agentic/db-tools/src/index.ts b/agentic/db-tools/src/index.ts index da17a75120..694d7b01be 100644 --- a/agentic/db-tools/src/index.ts +++ b/agentic/db-tools/src/index.ts @@ -152,6 +152,7 @@ export { type ProvisionOverlay, resolveProvisionModules, } from './provision-database/resolve'; +export { type RecordsDetails } from './records/rows'; export { accessOf, type ColumnDefault, @@ -170,7 +171,7 @@ export { accessState, asWritten, grantWords, planRule, ruleWords, type WrittenRu export { toolSchema } from './tool-schema'; export { describePolicyTypeTool, explainAccessTool, type ExplainedRule, type ExplainedTable, setAccessTool } from './tools/access'; export { type AddPoliciesDetails, addPoliciesTool } from './tools/add-policies'; -export { type AddRecordsDetails, addRecordsTool } from './tools/add-records'; +export { addRecordsTool } from './tools/add-records'; export { type AddRelationDetails, addRelationTool } from './tools/add-relation'; export { type CreateApiKeyDetails, createApiKeyTool } from './tools/create-api-key'; export { type DescribeSchemaDetails, describeSchemaTool } from './tools/describe-schema'; diff --git a/agentic/db-tools/src/records/meta.ts b/agentic/db-tools/src/records/meta.ts index 5de37c6649..fc4b59f29b 100644 --- a/agentic/db-tools/src/records/meta.ts +++ b/agentic/db-tools/src/records/meta.ts @@ -16,6 +16,7 @@ export const META_QUERY = ` _meta { tables { name + tableName query { all one create update delete } inflection { allRows @@ -33,8 +34,11 @@ export const META_QUERY = ` } fields { name + columnName isNotNull hasDefault + isPrimaryKey + isWritableOnUpdate type { gqlType isArray @@ -61,10 +65,13 @@ type RawType = { hasDefault?: boolean | null; }; -type RawField = { +export type RawField = { name: string; + columnName?: string | null; isNotNull?: boolean | null; hasDefault?: boolean | null; + isPrimaryKey?: boolean | null; + isWritableOnUpdate?: boolean | null; type: RawType; }; @@ -80,6 +87,8 @@ type RawQuery = { export type RawMetaTable = { name: string; + /** The SQL name; `name` is the GraphQL type. */ + tableName?: string | null; query?: RawQuery | null; inflection?: RawInflection | null; fields?: (RawField | null)[] | null; @@ -182,23 +191,27 @@ function getTableLookupVariants(value: string | null | undefined): string[] { // Resolve a user-supplied table name (snake_case singular or plural) against the // PascalCase-singular `_meta` table names, tolerating pluralization differences. +// Every table's GraphQL names are indexed before any SQL name, so a GraphQL name always finds its own table. export function findMetaTable(tables: RawMetaTable[], requested: string): RawMetaTable | undefined { const index = new Map(); + const add = (table: RawMetaTable, keys: (string | null | undefined)[]) => { + for (const key of keys) { + for (const variant of getTableLookupVariants(key)) { + if (!index.has(variant)) index.set(variant, table); + } + } + }; for (const table of tables) { - const keys = [ + add(table, [ table.name, table.query?.all, table.query?.one, table.inflection?.tableType, table.inflection?.tableFieldName, table.inflection?.allRows, - ]; - for (const key of keys) { - for (const variant of getTableLookupVariants(key)) { - if (!index.has(variant)) index.set(variant, table); - } - } + ]); } + for (const table of tables) add(table, [table.tableName]); for (const variant of getTableLookupVariants(requested)) { const match = index.get(variant); if (match) return match; diff --git a/agentic/db-tools/src/records/rows.ts b/agentic/db-tools/src/records/rows.ts new file mode 100644 index 0000000000..0022149dbd --- /dev/null +++ b/agentic/db-tools/src/records/rows.ts @@ -0,0 +1,306 @@ +// What add_records and update_records share: the app table a call names, read from the app API's `_meta` as the +// person signed in to the app; each record's keys as the API's field names, with "@
[]" as the id of a +// sample row the host seeded; and one write per row, with what each row's answer was. + +import { type HarnessToolResult, listed, nearestName, type ToolFailure } from '@agentic-kit/harness'; +import { toCamelCaseSingular } from '@constructive-io/graphql-query/generators'; + +import type { ProjectContext } from '../context'; +import { + DESCRIBE_SCHEMA, + explainAccessCall, + failedResult, + failureFromError, + failureFromErrors, + failureText, + NO_NEW_ROW, + noRowCreated, + noRowsChanged, + type Result, +} from '../failure'; +import { answerText, classifyBackendErrors, type GraphQLError, statusAdapter, thrownText } from '../graphql-http'; +import { getHost } from '../host'; +import { appSessionReady, projectReady } from '../ready'; +import { cleanTable, findMetaTable, META_QUERY, type MetaResponse, type RawField, type RawMetaTable } from './meta'; + +export type RecordsDetails = { + success: boolean; + message: string; + tableName?: string; + columns?: string[]; + rows?: Record[]; + createdCount?: number; + updatedCount?: number; + asOf?: string; + // Set when there's no valid data-plane token: the user hasn't signed into their + // app in the Preview (or the session token expired). The renderer shows a + // text prompt to sign in there. + needsAuth?: boolean; + // The app API answered ACCESS_SUSPENDED: the database is deleted or suspended. + code?: 'database-unavailable'; + /** The rows that were not written: their place in `records` and what the backend said. */ + failedRows?: { index: number; message: string }[]; +}; + +type Verb = 'insert' | 'update'; + +const WORDS = { + insert: { + done: 'Inserted', + into: 'into', + action: 'Failed to insert into', + count: 'createdCount', + noRow: NO_NEW_ROW, + // A row the backend answers without was refused by, or is hidden by, the read rule. + noRows: (action: string, tableName: string): ToolFailure => ({ + ...noRowCreated(action), + hint: "The table's read rules may hide the new row from this person: read the rules of the table to see who they let read.", + calls: [explainAccessCall(tableName)], + }), + }, + update: { + done: 'Updated', + into: 'in', + action: 'Failed to update', + count: 'updatedCount', + noRow: 'The backend answered without the row, so it does not exist, or this account may not change or read it.', + noRows: (action: string, tableName: string) => noRowsChanged(action, explainAccessCall(tableName)), + }, +} as const; + +const UNAVAILABLE = + "The app database is unavailable: the backend answered ACCESS_SUSPENDED, so it was deleted or is suspended. Retrying won't help until it is restored."; + +const isSuspended = (errors: readonly GraphQLError[]) => classifyBackendErrors(errors) === 'suspended'; + +export function recordsFailed(failure: ToolFailure, extra: Partial = {}): HarnessToolResult { + const flag = failure.code === 'app-signed-out' ? { needsAuth: true } : failure.code === 'database-unavailable' ? { code: failure.code } : {}; + return failedResult(failure, { success: false, message: failureText(failure), ...flag, ...extra }); +} + +export const invalid = (message: string): Result => ({ kind: 'failed', failure: { code: 'invalid-input', message, calls: [DESCRIBE_SCHEMA] } }); + +export type RecordsReady = { + context: ProjectContext; + token: string; + userId?: string; + /** The app's own API, as the person signed in to the app. */ + adapter: ReturnType; + tables: RawMetaTable[]; + table: RawMetaTable; + /** The records with each key as the API's field name. */ + records: Record[]; +}; + +/** + * What a records call checks before it writes anything: rows to write, the project, its data endpoint, an app + * sign-in, the table on the app's API, and every record's keys and seeded-row values. + */ +export async function recordsReady( + verb: Verb, + params: { table_name: string; records: Record[] }, + cwd: string, +): Promise> { + if (params.records.length === 0) return { kind: 'failed', failure: { code: 'invalid-input', message: 'No records provided.' } }; + const ready = await projectReady(cwd); + if (ready.kind === 'failed') return ready; + if (!ready.value.dataEndpoint) { + return { + kind: 'failed', + failure: { + code: 'missing-credentials', + message: 'Cannot resolve the app data endpoint (DATABASE_NAME missing from .env).', + hint: "Add DATABASE_NAME with the database's name to .env, then retry.", + }, + }; + } + const session = await appSessionReady(ready.value); + if (session.kind === 'failed') return session; + // Keeps the status and extensions.code that the SDK adapter drops. + const adapter = statusAdapter(ready.value.dataEndpoint, { Authorization: `Bearer ${session.value.token}` }); + let tables: RawMetaTable[]; + try { + const meta = await adapter.execute(META_QUERY); + if (!meta.ok) { + const failure = isSuspended(meta.errors) + ? { code: 'database-unavailable' as const, message: `${UNAVAILABLE} No rows were ${WORDS[verb].done.toLowerCase()}.` } + : failureFromErrors(meta.errors, 'Failed to read schema from the app database'); + return { kind: 'failed', failure }; + } + tables = (meta.data._meta?.tables ?? []).filter((t): t is NonNullable => Boolean(t)) as RawMetaTable[]; + } catch (err) { + return { kind: 'failed', failure: failureFromError(err, 'Failed to query the app database schema') }; + } + const table = findMetaTable(tables, params.table_name); + if (!table) { + return { + kind: 'failed', + failure: { + code: 'not-found', + message: `Table "${params.table_name}" was not found in the app database.`, + hint: 'Check the table names that exist, then retry.', + calls: [DESCRIBE_SCHEMA], + }, + }; + } + const seeded = await seededIds(params.records, cwd); + if (seeded.kind === 'failed') return seeded; + const records: Record[] = []; + for (const [index, record] of params.records.entries()) { + const row = recordAsFields(table, params.table_name, index, record, seeded.value, verb === 'update'); + if (row.kind === 'failed') return row; + records.push(row.value); + } + return { kind: 'ok', value: { context: ready.value, ...session.value, adapter, tables, table, records } }; +} + +export const fieldsOf = (table: RawMetaTable): RawField[] => (table.fields ?? []).filter((f): f is RawField => Boolean(f)); + +export const columnOf = (field: RawField): string => field.columnName ?? field.name; + +/** The table's single-column primary key, or undefined for none or a composite one. */ +export function primaryKeyOf(table: RawMetaTable): RawField | undefined { + const keys = fieldsOf(table).filter((field) => field.isPrimaryKey); + return keys.length === 1 ? keys[0] : undefined; +} + +const ROW_REF = /^@([a-z][a-z0-9_]*)\[(\d+)\]$/i; + +const tableKey = (value: string) => value.toLowerCase().replace(/[^a-z0-9]/g, ''); + +type SeededIds = ReadonlyMap; + +/** The ids of the sample rows the host seeded, by `tableKey`, read only when a record names one. */ +async function seededIds(records: readonly Record[], cwd: string): Promise> { + const named = records.some((record) => Object.values(record).some((value) => typeof value === 'string' && ROW_REF.test(value))); + const host = getHost(); + if (!named || !host.seededRows) return { kind: 'ok', value: new Map() }; + try { + const rows = (await host.seededRows(cwd)) ?? {}; + return { kind: 'ok', value: new Map(Object.entries(rows).map(([table, ids]) => [tableKey(table), ids])) }; + } catch (err) { + return { kind: 'failed', failure: { code: 'failed', message: `Could not read the sample rows seeded for this project: ${thrownText(err)}` } }; + } +} + +const isEmpty = (value: unknown) => value === undefined || value === null || value === ''; + +/** + * A record with each key as the API's field name. A key may be a field name or a column name, and the field name's + * value wins when both carry one; an empty value never replaces a given one. With nothing but empty values, a column + * is left out so the server's default applies, or set to null when `clear`. A "@
[]" value becomes that + * seeded row's id. + */ +export function recordAsFields( + table: RawMetaTable, + tableName: string, + index: number, + record: Record, + seeded: SeededIds, + clear: boolean, +): Result> { + const fields = fieldsOf(table); + const names = new Set(fields.flatMap((field) => [field.name, columnOf(field)])); + const unknown = Object.keys(record).find((key) => !names.has(key)); + if (unknown !== undefined) { + const columns = fields.map(columnOf); + const nearest = nearestName(unknown, columns); + const next = nearest ? `use "${nearest}".` : `its columns are ${listed(columns.map((c) => `"${c}"`))}.`; + return invalid(`Row ${index} names "${unknown}", which is not a column of ${tableName}: ${next}`); + } + const row: Record = {}; + for (const field of fields) { + const given = [field.name, columnOf(field)].filter((key) => Object.hasOwn(record, key)).map((key) => record[key]); + if (given.length === 0) continue; + const value = given.find((v) => !isEmpty(v)); + if (value === undefined) { + if (clear) row[field.name] = null; + continue; + } + const ref = typeof value === 'string' ? value.match(ROW_REF) : null; + if (!ref) { + row[field.name] = value; + continue; + } + const id = seeded.get(tableKey(ref[1]))?.[Number(ref[2])]; + if (!id) return invalid(`Row ${index} names "${value}", but no sample row was seeded there: use the row's id.`); + row[field.name] = id; + } + return { kind: 'ok', value: row }; +} + +/** One write per input, in order, until the database is suspended, and the call's result from each row's answer. */ +export async function writeRecords( + verb: Verb, + tableName: string, + { adapter, table: rawTable }: RecordsReady, + mutation: string, + mutationName: string, + inputs: readonly Record[], +): Promise> { + const words = WORDS[verb]; + const table = cleanTable(rawTable); + const singularName = toCamelCaseSingular(table.name, table); + const rows: Record[] = []; + const errors: GraphQLError[] = []; + const failedRows: { index: number; message: string }[] = []; + let suspended = false; + for (const [index, input] of inputs.entries()) { + let rowErrors: GraphQLError[]; + try { + const result = await adapter.execute>(mutation, { input }); + if (result.ok) { + const row = (result.data?.[mutationName] as Record | undefined)?.[singularName] as Record | undefined; + if (row) rows.push(row); + else failedRows.push({ index, message: words.noRow }); + continue; + } + if (isSuspended(result.errors)) { + suspended = true; + break; + } + rowErrors = result.errors; + } catch (err) { + // The request threw before any answer came back, so the error is the local one. + rowErrors = [{ message: thrownText(err), extensions: { code: 'NETWORK' } }]; + } + errors.push(...rowErrors); + failedRows.push({ index, message: answerText(rowErrors) }); + } + + const done = words.done.toLowerCase(); + const details = { + tableName: rawTable.name, + columns: table.fields.map((f) => f.name), + rows, + [words.count]: rows.length, + asOf: new Date().toISOString(), + }; + const failed = (failure: ToolFailure) => + recordsFailed(failure, { ...(rows.length > 0 ? details : {}), ...(failedRows.length > 0 ? { failedRows } : {}) }); + if (suspended) { + const message = rows.length > 0 ? `${UNAVAILABLE} ${rows.length} row(s) were ${done} before it stopped.` : `${UNAVAILABLE} No rows were ${done}.`; + return failed({ code: 'database-unavailable', message }); + } + if (rows.length === 0) { + const action = `${words.action} "${tableName}"`; + return failed(errors.length ? failureFromErrors(errors, action, { rows: { table: tableName } }) : words.noRows(action, tableName)); + } + if (failedRows.length > 0) { + const [first] = failedRows; + return failed({ + code: 'partial', + message: `${words.done} ${rows.length} of ${inputs.length} rows ${words.into} ${tableName}; ${failedRows.length} were not ${done} (row ${first.index}: ${first.message}).`, + hint: `Fix the rows listed in details.failedRows, then call again with only those rows: the ${done} rows stay.`, + }); + } + + const message = `${words.done} ${rows.length} row(s) ${words.into} ${tableName}.${verb === 'insert' ? keysLine(rows, primaryKeyOf(rawTable)?.name) : ''}`; + return { content: [{ type: 'text', text: message }], details: { success: true, message, ...details } }; +} + +/** The line that gives the new rows' keys, so a later call can point another row at one. */ +function keysLine(rows: readonly Record[], key: string | undefined): string { + const keys = key ? rows.map((row) => row[key]).filter((value) => value !== undefined && value !== null) : []; + return keys.length ? `\nThe new rows' ${key} values, in insert order: ${keys.map((value) => JSON.stringify(value)).join(', ')}.` : ''; +} diff --git a/agentic/db-tools/src/tools/add-records.ts b/agentic/db-tools/src/tools/add-records.ts index 8a3758d28d..8d33412620 100644 --- a/agentic/db-tools/src/tools/add-records.ts +++ b/agentic/db-tools/src/tools/add-records.ts @@ -1,4 +1,4 @@ -import { type HarnessTool, type HarnessToolResult, identifierParam, strictObject,type ToolFailure } from '@agentic-kit/harness'; +import { type HarnessTool, identifierParam, strictObject } from '@agentic-kit/harness'; import { buildPostGraphileCreate, toCamelCaseSingular, @@ -6,59 +6,9 @@ import { } from '@constructive-io/graphql-query/generators'; import { z } from 'zod'; -import type { ProjectContext } from '../context'; -import { DESCRIBE_SCHEMA, explainAccessCall, failedResult, failureFromError, failureFromErrors, failureText, NO_NEW_ROW, noRowCreated, type Result } from '../failure'; -import { answerText, classifyBackendErrors, type GraphQLError, statusAdapter, thrownText } from '../graphql-http'; -import { appSessionReady, projectReady } from '../ready'; -import { cleanTable, findMetaTable, META_QUERY, type MetaResponse, type RawMetaTable } from '../records/meta'; - -export type AddRecordsDetails = { - success: boolean; - message: string; - tableName?: string; - columns?: string[]; - rows?: Record[]; - createdCount?: number; - asOf?: string; - // Set when there's no valid data-plane token: the user hasn't signed into their - // app in the Preview (or the session token expired). The renderer shows a - // text prompt to sign in there. - needsAuth?: boolean; - // The app API answered ACCESS_SUSPENDED: the database is deleted or suspended. - code?: 'database-unavailable'; - /** The rows that were not inserted: their place in `records` and what the backend said. */ - failedRows?: { index: number; message: string }[]; -}; - -type ToolResult = HarnessToolResult; - -function fail(failure: ToolFailure, extra: Partial = {}): ToolResult { - return failedResult(failure, { success: false, message: failureText(failure), ...extra }); -} - -const UNAVAILABLE = - "The app database is unavailable: the backend answered ACCESS_SUSPENDED, so it was deleted or is suspended. Retrying won't help until it is restored."; - -function unavailable(inserted = 0): ToolResult { - const message = inserted > 0 ? `${UNAVAILABLE} ${inserted} row(s) were inserted before it stopped.` : `${UNAVAILABLE} No rows were inserted.`; - return fail( - { code: 'database-unavailable', message }, - { code: 'database-unavailable', ...(inserted > 0 ? { createdCount: inserted } : {}) }, - ); -} - -const isSuspended = (errors: readonly GraphQLError[]) => classifyBackendErrors(errors) === 'suspended'; - -// Mirror @constructive-io/data's prepareCreateInput (create semantics): drop -// undefined/null/empty-string so server defaults apply; keep false/0/[]/objects. -function stripForCreate(record: Record): Record { - const out: Record = {}; - for (const [key, value] of Object.entries(record)) { - if (value === undefined || value === null || value === '') continue; - out[key] = value; - } - return out; -} +import type { Result } from '../failure'; +import { cleanTable } from '../records/meta'; +import { type RecordsDetails, recordsFailed, type RecordsReady, recordsReady, writeRecords } from '../records/rows'; const AddRecordsZod = strictObject('the input', { table_name: identifierParam() @@ -66,70 +16,18 @@ const AddRecordsZod = strictObject('the input', { records: z .array(z.record(z.string(), z.unknown())) .describe( - 'Rows to insert. Each is an object of column → value (camelCase or snake_case column names).', + 'Rows to insert. Each is an object of the table\'s column names (snake_case) → value. A value "@
[]" is the id of a sample row seeded when the app was built.', ), }); type AddRecordsParams = z.infer; -type AddRecordsReady = { - context: ProjectContext; - token: string; - userId?: string; - /** The app's own API, as the person signed in to the app. */ - adapter: ReturnType; - tables: RawMetaTable[]; - table: RawMetaTable; -}; - -/** What add_records checks before it changes anything: rows to add, the project, its data endpoint, an app sign-in, and the table on the app's API. */ -export async function addRecordsReady(params: AddRecordsParams, cwd: string): Promise> { - if (params.records.length === 0) return { kind: 'failed', failure: { code: 'invalid-input', message: 'No records provided.' } }; - const ready = await projectReady(cwd); - if (ready.kind === 'failed') return ready; - if (!ready.value.dataEndpoint) { - return { - kind: 'failed', - failure: { - code: 'missing-credentials', - message: 'Cannot resolve the app data endpoint (DATABASE_NAME missing from .env).', - hint: "Add DATABASE_NAME with the database's name to .env, then retry.", - }, - }; - } - const session = await appSessionReady(ready.value); - if (session.kind === 'failed') return session; - // Keeps the status and extensions.code that the SDK adapter drops. - const adapter = statusAdapter(ready.value.dataEndpoint, { Authorization: `Bearer ${session.value.token}` }); - let tables: RawMetaTable[]; - try { - const meta = await adapter.execute(META_QUERY); - if (!meta.ok) { - const failure = isSuspended(meta.errors) - ? { code: 'database-unavailable' as const, message: `${UNAVAILABLE} No rows were inserted.` } - : failureFromErrors(meta.errors, 'Failed to read schema from the app database'); - return { kind: 'failed', failure }; - } - tables = (meta.data._meta?.tables ?? []).filter((t): t is NonNullable => Boolean(t)) as RawMetaTable[]; - } catch (err) { - return { kind: 'failed', failure: failureFromError(err, 'Failed to query the app database schema') }; - } - const table = findMetaTable(tables, params.table_name); - if (!table) { - return { - kind: 'failed', - failure: { - code: 'not-found', - message: `Table "${params.table_name}" was not found in the app database.`, - hint: 'Check the table names that exist, then retry.', - calls: [DESCRIBE_SCHEMA], - }, - }; - } - return { kind: 'ok', value: { context: ready.value, ...session.value, adapter, tables, table } }; +/** What add_records checks before it changes anything: rows to add, the project, its data endpoint, an app sign-in, the table on the app's API, and every record's keys and seeded-row values. */ +export function addRecordsReady(params: AddRecordsParams, cwd: string): Promise> { + return recordsReady('insert', params, cwd); } -export const addRecordsTool: HarnessTool = { +export const addRecordsTool: HarnessTool = { name: 'add_records', label: 'Add records', description: "Insert one or more rows into a table in the project's app database.", @@ -138,16 +36,10 @@ export const addRecordsTool: HarnessTool f.name === 'entityId'); + const inputs = records.map((record) => ({ + [singularName]: hasEntityId && userId && record.entityId == null ? { ...record, entityId: userId } : record, + })); - const created: Record[] = []; - const errors: GraphQLError[] = []; - const failedRows: { index: number; message: string }[] = []; - - for (const [index, record] of params.records.entries()) { - const prepared = - hasEntityId && userId && record.entityId == null && record.entity_id == null - ? { ...record, entityId: userId } - : record; - const variables = { input: { [singularName]: stripForCreate(prepared) } }; - let rowErrors: GraphQLError[]; - try { - const result = await adapter.execute>(mutation, variables); - if (result.ok) { - const payload = result.data?.[mutationName] as Record | undefined; - const row = payload?.[singularName] as Record | undefined; - if (row) { - created.push(row); - } else { - failedRows.push({ index, message: NO_NEW_ROW }); - } - continue; - } - if (isSuspended(result.errors)) return unavailable(created.length); - rowErrors = result.errors; - } catch (err) { - // The request threw before any answer came back, so the error is the local one. - rowErrors = [{ message: thrownText(err), extensions: { code: 'NETWORK' } }]; - } - errors.push(...rowErrors); - failedRows.push({ index, message: answerText(rowErrors) }); - } - - const columns = table.fields.map((f) => f.name); - const rowDetails = { - tableName: rawTable.name, - columns, - rows: created, - createdCount: created.length, - asOf: new Date().toISOString(), - }; - - if (created.length === 0) { - const action = `Failed to insert into "${params.table_name}"`; - const rows = { table: params.table_name }; - // A row the backend answers without was refused by, or is hidden by, the read rule. - const hidden = { - ...noRowCreated(action), - hint: "The table's read rules may hide the new row from this person: read the rules of the table to see who they let read.", - calls: [explainAccessCall(params.table_name)], - }; - return fail(errors.length ? failureFromErrors(errors, action, { rows }) : hidden, { failedRows }); - } - if (failedRows.length > 0) { - const first = failedRows[0]; - return fail( - { - code: 'partial', - message: `Inserted ${created.length} of ${params.records.length} rows into ${params.table_name}; ${failedRows.length} were not inserted (row ${first.index}: ${first.message}).`, - hint: 'Fix the rows listed in details.failedRows, then call again with only those rows: the inserted rows stay.', - }, - { ...rowDetails, failedRows }, - ); - } - - const message = `Inserted ${created.length} row(s) into ${params.table_name}.`; - return { content: [{ type: 'text', text: message }], details: { success: true, message, ...rowDetails } }; + const mutation = buildPostGraphileCreate(table, tables.map(cleanTable)).toString(); + return writeRecords('insert', params.table_name, ready.value, mutation, toCreateMutationName(table.name, table), inputs); }, }; diff --git a/agentic/db-tools/src/tools/index.ts b/agentic/db-tools/src/tools/index.ts index 84945f0946..2a4e14f2f9 100644 --- a/agentic/db-tools/src/tools/index.ts +++ b/agentic/db-tools/src/tools/index.ts @@ -40,6 +40,7 @@ import { templateReady, updateTemplateTool, } from './templates'; +import { updateRecordsReady, updateRecordsTool } from './update-records'; /** * The Constructive database tools, in registration order. @@ -66,6 +67,7 @@ export const constructiveDbTools: readonly AnyHarnessTool[] = [ updateTemplateTool, deleteTemplateTool, addRecordsTool, + updateRecordsTool, listEntityTypesTool, createEntityTypeTool, deleteEntityTypeTool, @@ -171,6 +173,7 @@ export const toolPreconditions: ReadonlyMap = new Map accountTarget(context))], [deleteTemplateTool.name, targeting(templateReady, ({ context }) => accountTarget(context))], [addRecordsTool.name, targeting(addRecordsReady, ({ context, userId }) => databaseTarget(context, userId))], + [updateRecordsTool.name, targeting(updateRecordsReady, ({ context, userId }) => databaseTarget(context, userId))], [listEntityTypesTool.name, onDatabase(project)], [createEntityTypeTool.name, onDatabase(createEntityTypeReady)], [deleteEntityTypeTool.name, onDatabase(deleteEntityTypeReady)], diff --git a/agentic/db-tools/src/tools/update-records.ts b/agentic/db-tools/src/tools/update-records.ts new file mode 100644 index 0000000000..fe3466c3f2 --- /dev/null +++ b/agentic/db-tools/src/tools/update-records.ts @@ -0,0 +1,64 @@ +import { type HarnessTool, identifierParam, strictObject } from '@agentic-kit/harness'; +import { buildPostGraphileUpdate, toPatchFieldName, toUpdateMutationName } from '@constructive-io/graphql-query/generators'; +import { z } from 'zod'; + +import type { Result } from '../failure'; +import { cleanTable, type RawField } from '../records/meta'; +import { columnOf, fieldsOf, invalid, primaryKeyOf, type RecordsDetails, recordsFailed, type RecordsReady, recordsReady, writeRecords } from '../records/rows'; + +const UpdateRecordsZod = strictObject('the input', { + table_name: identifierParam() + .describe('Name of the table whose rows to change (snake_case, singular or plural).'), + records: z + .array(z.record(z.string(), z.unknown())) + .describe( + 'One object per row. Its primary key column (usually "id") names the row: its id, or "@
[]" for a sample row seeded when the app was built. The other keys are the columns to set, by column name (snake_case); a value may also be "@
[]".', + ), +}); + +type UpdateRecordsParams = z.infer; + +/** What update_records checks before it changes anything: the table on the app's API, its key, and for every record the row it names and the columns it sets. */ +export async function updateRecordsReady(params: UpdateRecordsParams, cwd: string): Promise> { + const ready = await recordsReady('update', params, cwd); + if (ready.kind === 'failed') return ready; + const { table, records } = ready.value; + const primaryKey = primaryKeyOf(table); + if (!primaryKey) { + return { kind: 'failed', failure: { code: 'unsupported', message: `${params.table_name} has no single-column primary key, so its rows can't be named.` } }; + } + if (!table.query?.update) { + return { kind: 'failed', failure: { code: 'unsupported', message: `The app API can't update ${params.table_name} rows.` } }; + } + const fields = new Map(fieldsOf(table).map((field) => [field.name, field])); + const keyColumn = columnOf(primaryKey); + for (const [index, { [primaryKey.name]: key, ...patch }] of records.entries()) { + if (key == null) return invalid(`Row ${index} names no row: give its "${keyColumn}".`); + const kept = Object.keys(patch).find((name) => fields.get(name)?.isWritableOnUpdate === false); + if (kept) return invalid(`Row ${index} sets "${columnOf(fields.get(kept)!)}", which the app API does not let anyone change.`); + if (Object.keys(patch).length === 0) return invalid(`Row ${index} sets no column besides "${keyColumn}".`); + } + return { kind: 'ok', value: { ...ready.value, primaryKey } }; +} + +export const updateRecordsTool: HarnessTool = { + name: 'update_records', + label: 'Update records', + description: + "Set columns on rows that are already in the project's app database, each row named by its primary key. Use it to link rows, for example a key column of a row add_records made to a sample row seeded when the app was built.", + promptSnippet: 'update_records: set columns on existing rows by primary key, such as linking rows. Gated.', + parameters: UpdateRecordsZod, + effect: 'write', + async execute(params: UpdateRecordsParams, ctx) { + const ready = await updateRecordsReady(params, ctx.cwd); + if (ready.kind === 'failed') return recordsFailed(ready.failure); + const { tables, records, primaryKey } = ready.value; + + const table = cleanTable(ready.value.table); + const patchField = toPatchFieldName(table.name, table); + const inputs = records.map(({ [primaryKey.name]: key, ...patch }) => ({ [primaryKey.name]: key, [patchField]: patch })); + + const mutation = buildPostGraphileUpdate(table, tables.map(cleanTable)).toString(); + return writeRecords('update', params.table_name, ready.value, mutation, toUpdateMutationName(table.name, table), inputs); + }, +}; diff --git a/agentic/pi/__tests__/pi-tool.test.ts b/agentic/pi/__tests__/pi-tool.test.ts index d9ed611e1a..feee138b65 100644 --- a/agentic/pi/__tests__/pi-tool.test.ts +++ b/agentic/pi/__tests__/pi-tool.test.ts @@ -90,7 +90,7 @@ describe('dbTools', () => { expect(registered.map((tool) => tool.name)).toEqual( constructiveDbTools.map((tool) => tool.name), ); - expect(registered).toHaveLength(25); + expect(registered).toHaveLength(26); for (const tool of registered) { expect(typeof tool.execute).toBe('function'); expect(tool.parameters).toMatchObject({ type: 'object' });