@segmentstream/ontology 0.0.0-stage → 0.92.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +2 -0
- package/README.md +1655 -2
- package/dist/action.d.ts +193 -0
- package/dist/action.js +41 -0
- package/dist/agent-chat.d.ts +44 -0
- package/dist/agent-chat.js +91 -0
- package/dist/agent-task-contract.d.ts +64 -0
- package/dist/agent-task-contract.js +15 -0
- package/dist/agent-task.d.ts +39 -0
- package/dist/agent-task.js +112 -0
- package/dist/analyze.d.ts +215 -0
- package/dist/analyze.js +2438 -0
- package/dist/app-feedback.d.ts +167 -0
- package/dist/app-feedback.js +176 -0
- package/dist/authoring-input.d.ts +3 -0
- package/dist/authoring-input.js +107 -0
- package/dist/authoring-names.d.ts +4 -0
- package/dist/authoring-names.js +13 -0
- package/dist/authoring-records.d.ts +35 -0
- package/dist/authoring-records.js +264 -0
- package/dist/authoring.d.ts +15 -0
- package/dist/authoring.js +331 -0
- package/dist/bin/check.d.ts +30 -0
- package/dist/bin/check.js +99 -0
- package/dist/bin/load.d.ts +48 -0
- package/dist/bin/load.js +139 -0
- package/dist/bin/main.d.ts +31 -0
- package/dist/bin/main.js +121 -0
- package/dist/bin/migrate.d.ts +57 -0
- package/dist/bin/migrate.js +170 -0
- package/dist/bin/output.d.ts +31 -0
- package/dist/bin/output.js +84 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +31 -0
- package/dist/blob.d.ts +52 -0
- package/dist/blob.js +87 -0
- package/dist/channel-session.d.ts +16 -0
- package/dist/channel-session.js +16 -0
- package/dist/chat.d.ts +43 -0
- package/dist/chat.js +34 -0
- package/dist/confirmation.d.ts +46 -0
- package/dist/confirmation.js +41 -0
- package/dist/connection.d.ts +213 -0
- package/dist/connection.js +289 -0
- package/dist/deployment.d.ts +35 -0
- package/dist/deployment.js +76 -0
- package/dist/diagnostics.d.ts +27 -0
- package/dist/diagnostics.js +106 -0
- package/dist/emails.d.ts +70 -0
- package/dist/emails.js +221 -0
- package/dist/entity.d.ts +331 -0
- package/dist/entity.js +153 -0
- package/dist/errors.d.ts +154 -0
- package/dist/errors.js +109 -0
- package/dist/feedback-config.d.ts +24 -0
- package/dist/feedback-config.js +126 -0
- package/dist/files.d.ts +39 -0
- package/dist/files.js +4 -0
- package/dist/groups.d.ts +95 -0
- package/dist/groups.js +280 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +70 -0
- package/dist/internal/diagnostics.js +594 -0
- package/dist/legacy.d.ts +160 -0
- package/dist/legacy.js +270 -0
- package/dist/manifest-compatibility.d.ts +8 -0
- package/dist/manifest-compatibility.js +87 -0
- package/dist/manifest.d.ts +3329 -0
- package/dist/manifest.js +757 -0
- package/dist/me.d.ts +46 -0
- package/dist/me.js +109 -0
- package/dist/metric-filters.d.ts +48 -0
- package/dist/metric-filters.js +252 -0
- package/dist/metric-routes.d.ts +132 -0
- package/dist/metric-routes.js +498 -0
- package/dist/metric.d.ts +172 -0
- package/dist/metric.js +132 -0
- package/dist/migrate/apply.d.ts +94 -0
- package/dist/migrate/apply.js +526 -0
- package/dist/migrate/errors.d.ts +46 -0
- package/dist/migrate/errors.js +38 -0
- package/dist/migrate/index.d.ts +10 -0
- package/dist/migrate/index.js +7 -0
- package/dist/migrate/model.d.ts +2311 -0
- package/dist/migrate/model.js +148 -0
- package/dist/migrate/plan.d.ts +51 -0
- package/dist/migrate/plan.js +1856 -0
- package/dist/migrate/preview.d.ts +13 -0
- package/dist/migrate/preview.js +65 -0
- package/dist/migrate/storage.d.ts +226 -0
- package/dist/migrate/storage.js +774 -0
- package/dist/model-metrics.d.ts +22 -0
- package/dist/model-metrics.js +545 -0
- package/dist/names.d.ts +49 -0
- package/dist/names.js +110 -0
- package/dist/navigation-artifact.d.ts +13 -0
- package/dist/navigation-artifact.js +11 -0
- package/dist/navigation-catalog.d.ts +55 -0
- package/dist/navigation-catalog.js +297 -0
- package/dist/nitro-navigation.d.ts +3 -0
- package/dist/nitro-navigation.js +64 -0
- package/dist/nitro-workflows.d.ts +108 -0
- package/dist/nitro-workflows.js +286 -0
- package/dist/nitro.d.ts +40 -0
- package/dist/nitro.js +50 -0
- package/dist/ontology.d.ts +41 -0
- package/dist/ontology.js +46 -0
- package/dist/permissions.d.ts +198 -0
- package/dist/permissions.js +272 -0
- package/dist/property.d.ts +188 -0
- package/dist/property.js +301 -0
- package/dist/query.d.ts +245 -0
- package/dist/query.js +615 -0
- package/dist/relationship.d.ts +99 -0
- package/dist/relationship.js +33 -0
- package/dist/render.d.ts +81 -0
- package/dist/render.js +512 -0
- package/dist/replication/baseline.d.ts +51 -0
- package/dist/replication/baseline.js +215 -0
- package/dist/replication/bigquery.d.ts +37 -0
- package/dist/replication/bigquery.js +211 -0
- package/dist/replication/coverage.d.ts +14 -0
- package/dist/replication/coverage.js +53 -0
- package/dist/replication/evolution.d.ts +25 -0
- package/dist/replication/evolution.js +184 -0
- package/dist/replication/identities.d.ts +6 -0
- package/dist/replication/identities.js +47 -0
- package/dist/replication/legacy-baseline.d.ts +27 -0
- package/dist/replication/legacy-baseline.js +109 -0
- package/dist/replication/legacy-store.d.ts +19 -0
- package/dist/replication/legacy-store.js +63 -0
- package/dist/replication/lineage.d.ts +36 -0
- package/dist/replication/lineage.js +72 -0
- package/dist/replication/migrate.d.ts +21 -0
- package/dist/replication/migrate.js +84 -0
- package/dist/replication/model.d.ts +52 -0
- package/dist/replication/model.js +99 -0
- package/dist/replication/scans.d.ts +34 -0
- package/dist/replication/scans.js +158 -0
- package/dist/replication/schema.d.ts +11 -0
- package/dist/replication/schema.js +226 -0
- package/dist/replication/shadow-schema.d.ts +4 -0
- package/dist/replication/shadow-schema.js +61 -0
- package/dist/replication/shadow.d.ts +127 -0
- package/dist/replication/shadow.js +614 -0
- package/dist/replication/source-replacement.d.ts +33 -0
- package/dist/replication/source-replacement.js +76 -0
- package/dist/replication/store.d.ts +36 -0
- package/dist/replication/store.js +382 -0
- package/dist/replication/transaction.d.ts +23 -0
- package/dist/replication/transaction.js +88 -0
- package/dist/role.d.ts +61 -0
- package/dist/role.js +76 -0
- package/dist/runtime/action-deadlocks.d.ts +21 -0
- package/dist/runtime/action-deadlocks.js +130 -0
- package/dist/runtime/action-transactions.d.ts +35 -0
- package/dist/runtime/action-transactions.js +54 -0
- package/dist/runtime/agent-counters.d.ts +26 -0
- package/dist/runtime/agent-counters.js +98 -0
- package/dist/runtime/agent-tasks.d.ts +63 -0
- package/dist/runtime/agent-tasks.js +120 -0
- package/dist/runtime/agents.d.ts +15 -0
- package/dist/runtime/agents.js +457 -0
- package/dist/runtime/batch-diagnostics.d.ts +22 -0
- package/dist/runtime/batch-diagnostics.js +89 -0
- package/dist/runtime/batch.d.ts +52 -0
- package/dist/runtime/batch.js +534 -0
- package/dist/runtime/channel-session-revocation.d.ts +3 -0
- package/dist/runtime/channel-session-revocation.js +5 -0
- package/dist/runtime/channel-sessions.d.ts +4 -0
- package/dist/runtime/channel-sessions.js +61 -0
- package/dist/runtime/confirmations.d.ts +29 -0
- package/dist/runtime/confirmations.js +57 -0
- package/dist/runtime/cursor.d.ts +23 -0
- package/dist/runtime/cursor.js +100 -0
- package/dist/runtime/deployment.d.ts +7 -0
- package/dist/runtime/deployment.js +4 -0
- package/dist/runtime/errors.d.ts +118 -0
- package/dist/runtime/errors.js +109 -0
- package/dist/runtime/federation-tables.d.ts +2 -0
- package/dist/runtime/federation-tables.js +20 -0
- package/dist/runtime/federation.d.ts +42 -0
- package/dist/runtime/federation.js +222 -0
- package/dist/runtime/files.d.ts +39 -0
- package/dist/runtime/files.js +44 -0
- package/dist/runtime/generated-actions.d.ts +37 -0
- package/dist/runtime/generated-actions.js +307 -0
- package/dist/runtime/history.d.ts +91 -0
- package/dist/runtime/history.js +77 -0
- package/dist/runtime/ids.d.ts +6 -0
- package/dist/runtime/ids.js +39 -0
- package/dist/runtime/member-tables.d.ts +8 -0
- package/dist/runtime/member-tables.js +33 -0
- package/dist/runtime/member-writes.d.ts +78 -0
- package/dist/runtime/member-writes.js +202 -0
- package/dist/runtime/metric-query.d.ts +19 -0
- package/dist/runtime/metric-query.js +411 -0
- package/dist/runtime/model.d.ts +67 -0
- package/dist/runtime/model.js +150 -0
- package/dist/runtime/new-user-hook.d.ts +6 -0
- package/dist/runtime/new-user-hook.js +37 -0
- package/dist/runtime/oauth.d.ts +9 -0
- package/dist/runtime/oauth.js +299 -0
- package/dist/runtime/pipeline.d.ts +155 -0
- package/dist/runtime/pipeline.js +597 -0
- package/dist/runtime/postgres-tls.d.ts +10 -0
- package/dist/runtime/postgres-tls.js +14 -0
- package/dist/runtime/principals.d.ts +302 -0
- package/dist/runtime/principals.js +1307 -0
- package/dist/runtime/reads.d.ts +55 -0
- package/dist/runtime/reads.js +313 -0
- package/dist/runtime/records.d.ts +42 -0
- package/dist/runtime/records.js +245 -0
- package/dist/runtime/resolve-agent-identity.d.ts +6 -0
- package/dist/runtime/resolve-agent-identity.js +181 -0
- package/dist/runtime/service-binding.d.ts +18 -0
- package/dist/runtime/service-binding.js +266 -0
- package/dist/runtime/sign-in-links.d.ts +68 -0
- package/dist/runtime/sign-in-links.js +147 -0
- package/dist/runtime/sql-runtime.d.ts +131 -0
- package/dist/runtime/sql-runtime.js +362 -0
- package/dist/runtime/statement.d.ts +18 -0
- package/dist/runtime/statement.js +31 -0
- package/dist/runtime/user-identities.d.ts +66 -0
- package/dist/runtime/user-identities.js +106 -0
- package/dist/runtime/user-identity-sql.d.ts +86 -0
- package/dist/runtime/user-identity-sql.js +297 -0
- package/dist/runtime/user-roles.d.ts +16 -0
- package/dist/runtime/user-roles.js +32 -0
- package/dist/runtime/validation.d.ts +16 -0
- package/dist/runtime/validation.js +26 -0
- package/dist/runtime/where.d.ts +57 -0
- package/dist/runtime/where.js +404 -0
- package/dist/runtime/workflow-admission.d.ts +49 -0
- package/dist/runtime/workflow-admission.js +92 -0
- package/dist/runtime/workflow-argument-codec.d.ts +10 -0
- package/dist/runtime/workflow-argument-codec.js +120 -0
- package/dist/runtime/workflow-arguments.d.ts +17 -0
- package/dist/runtime/workflow-arguments.js +99 -0
- package/dist/runtime/workflow-starts.d.ts +203 -0
- package/dist/runtime/workflow-starts.js +493 -0
- package/dist/runtime/workflow-users.d.ts +9 -0
- package/dist/runtime/workflow-users.js +17 -0
- package/dist/runtime/workload.d.ts +25 -0
- package/dist/runtime/workload.js +24 -0
- package/dist/runtime/writes.d.ts +108 -0
- package/dist/runtime/writes.js +491 -0
- package/dist/runtime-source.d.ts +22 -0
- package/dist/runtime-source.js +28 -0
- package/dist/runtime.d.ts +310 -0
- package/dist/runtime.js +31 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.js +107 -0
- package/dist/service/agent/attachments.d.ts +33 -0
- package/dist/service/agent/attachments.js +228 -0
- package/dist/service/agent/authentication.d.ts +22 -0
- package/dist/service/agent/authentication.js +58 -0
- package/dist/service/agent/confirmations.d.ts +5 -0
- package/dist/service/agent/confirmations.js +73 -0
- package/dist/service/agent/conversation-routes.d.ts +14 -0
- package/dist/service/agent/conversation-routes.js +45 -0
- package/dist/service/agent/conversations.d.ts +40 -0
- package/dist/service/agent/conversations.js +69 -0
- package/dist/service/agent/files.d.ts +12 -0
- package/dist/service/agent/files.js +69 -0
- package/dist/service/agent/protocol.d.ts +90 -0
- package/dist/service/agent/protocol.js +114 -0
- package/dist/service/agent/server.d.ts +28 -0
- package/dist/service/agent/server.js +374 -0
- package/dist/service/agent/task-caller.d.ts +21 -0
- package/dist/service/agent/task-caller.js +35 -0
- package/dist/service/agent/task-start.d.ts +53 -0
- package/dist/service/agent/task-start.js +161 -0
- package/dist/service/agent/tasks.d.ts +40 -0
- package/dist/service/agent/tasks.js +155 -0
- package/dist/service/api.d.ts +50 -0
- package/dist/service/api.js +288 -0
- package/dist/service/authentication.d.ts +227 -0
- package/dist/service/authentication.js +767 -0
- package/dist/service/caller-context.d.ts +24 -0
- package/dist/service/caller-context.js +6 -0
- package/dist/service/catalog.d.ts +42 -0
- package/dist/service/catalog.js +66 -0
- package/dist/service/channel/provider.d.ts +10 -0
- package/dist/service/channel/provider.js +1 -0
- package/dist/service/channel/providers/telegram.d.ts +18 -0
- package/dist/service/channel/providers/telegram.js +108 -0
- package/dist/service/channel/sessions.d.ts +5 -0
- package/dist/service/channel/sessions.js +53 -0
- package/dist/service/channel/sign-in.d.ts +7 -0
- package/dist/service/channel/sign-in.js +78 -0
- package/dist/service/chat/archive.d.ts +64 -0
- package/dist/service/chat/archive.js +62 -0
- package/dist/service/chat/attribution.d.ts +26 -0
- package/dist/service/chat/attribution.js +28 -0
- package/dist/service/chat/delivery.d.ts +18 -0
- package/dist/service/chat/delivery.js +251 -0
- package/dist/service/chat/diagnostics.d.ts +2 -0
- package/dist/service/chat/diagnostics.js +35 -0
- package/dist/service/chat/envelope.d.ts +96 -0
- package/dist/service/chat/envelope.js +39 -0
- package/dist/service/chat/idempotency.d.ts +19 -0
- package/dist/service/chat/idempotency.js +37 -0
- package/dist/service/chat/providers/telegram.d.ts +36 -0
- package/dist/service/chat/providers/telegram.js +133 -0
- package/dist/service/chat/reads.d.ts +25 -0
- package/dist/service/chat/reads.js +75 -0
- package/dist/service/chat/resolve.d.ts +34 -0
- package/dist/service/chat/resolve.js +150 -0
- package/dist/service/chat/routes.d.ts +23 -0
- package/dist/service/chat/routes.js +75 -0
- package/dist/service/chat/schemas.d.ts +43 -0
- package/dist/service/chat/schemas.js +31 -0
- package/dist/service/config.d.ts +218 -0
- package/dist/service/config.js +265 -0
- package/dist/service/connection-stream.d.ts +10 -0
- package/dist/service/connection-stream.js +191 -0
- package/dist/service/connections.d.ts +60 -0
- package/dist/service/connections.js +271 -0
- package/dist/service/decisions.d.ts +35 -0
- package/dist/service/decisions.js +63 -0
- package/dist/service/descriptions.d.ts +8 -0
- package/dist/service/descriptions.js +20 -0
- package/dist/service/discovery-schemas.d.ts +92 -0
- package/dist/service/discovery-schemas.js +59 -0
- package/dist/service/discovery-search.d.ts +30 -0
- package/dist/service/discovery-search.js +95 -0
- package/dist/service/discovery.d.ts +37 -0
- package/dist/service/discovery.js +436 -0
- package/dist/service/docs.d.ts +9 -0
- package/dist/service/docs.js +197 -0
- package/dist/service/errors.d.ts +145 -0
- package/dist/service/errors.js +704 -0
- package/dist/service/federation-provider.d.ts +36 -0
- package/dist/service/federation-provider.js +110 -0
- package/dist/service/federation-server.d.ts +20 -0
- package/dist/service/federation-server.js +249 -0
- package/dist/service/federation-status.d.ts +40 -0
- package/dist/service/federation-status.js +151 -0
- package/dist/service/handlers.d.ts +18 -0
- package/dist/service/handlers.js +287 -0
- package/dist/service/mcp/confirmation.d.ts +68 -0
- package/dist/service/mcp/confirmation.js +178 -0
- package/dist/service/mcp/find-input.d.ts +12 -0
- package/dist/service/mcp/find-input.js +122 -0
- package/dist/service/mcp/input-schema.d.ts +6 -0
- package/dist/service/mcp/input-schema.js +126 -0
- package/dist/service/mcp/listing.d.ts +26 -0
- package/dist/service/mcp/listing.js +92 -0
- package/dist/service/mcp/metric-tools.d.ts +85 -0
- package/dist/service/mcp/metric-tools.js +258 -0
- package/dist/service/mcp/request-log.d.ts +5 -0
- package/dist/service/mcp/request-log.js +53 -0
- package/dist/service/mcp/runtime-policy.d.ts +27 -0
- package/dist/service/mcp/runtime-policy.js +62 -0
- package/dist/service/mcp/server.d.ts +52 -0
- package/dist/service/mcp/server.js +861 -0
- package/dist/service/mcp/tools.d.ts +99 -0
- package/dist/service/mcp/tools.js +938 -0
- package/dist/service/member-file-routes.d.ts +22 -0
- package/dist/service/member-file-routes.js +52 -0
- package/dist/service/member-files.d.ts +245 -0
- package/dist/service/member-files.js +258 -0
- package/dist/service/metric-query-platform.d.ts +77 -0
- package/dist/service/metric-query-platform.js +198 -0
- package/dist/service/metric-query-scopes.d.ts +43 -0
- package/dist/service/metric-query-scopes.js +147 -0
- package/dist/service/metric-query.d.ts +48 -0
- package/dist/service/metric-query.js +200 -0
- package/dist/service/name-suggestions.d.ts +3 -0
- package/dist/service/name-suggestions.js +38 -0
- package/dist/service/navigation-schemas.d.ts +80 -0
- package/dist/service/navigation-schemas.js +49 -0
- package/dist/service/navigation.d.ts +20 -0
- package/dist/service/navigation.js +165 -0
- package/dist/service/oauth/protocol.d.ts +70 -0
- package/dist/service/oauth/protocol.js +157 -0
- package/dist/service/oauth/refresh-replay.d.ts +2 -0
- package/dist/service/oauth/refresh-replay.js +20 -0
- package/dist/service/oauth/server.d.ts +28 -0
- package/dist/service/oauth/server.js +769 -0
- package/dist/service/operations.d.ts +170 -0
- package/dist/service/operations.js +392 -0
- package/dist/service/plan.d.ts +57 -0
- package/dist/service/plan.js +96 -0
- package/dist/service/rate-limit.d.ts +22 -0
- package/dist/service/rate-limit.js +52 -0
- package/dist/service/record-reads.d.ts +21 -0
- package/dist/service/record-reads.js +155 -0
- package/dist/service/replication.d.ts +5 -0
- package/dist/service/replication.js +39 -0
- package/dist/service/runtime-contract.d.ts +508 -0
- package/dist/service/runtime-contract.js +18 -0
- package/dist/service/runtime-identity.d.ts +71 -0
- package/dist/service/runtime-identity.js +122 -0
- package/dist/service/schemas.d.ts +961 -0
- package/dist/service/schemas.js +639 -0
- package/dist/service/service.d.ts +21 -0
- package/dist/service/service.js +526 -0
- package/dist/service/warehouse-platform.d.ts +17 -0
- package/dist/service/warehouse-platform.js +122 -0
- package/dist/service/warehouse-query.d.ts +24 -0
- package/dist/service/warehouse-query.js +280 -0
- package/dist/service/webhooks.d.ts +106 -0
- package/dist/service/webhooks.js +233 -0
- package/dist/service/workflow-admission-provider.d.ts +31 -0
- package/dist/service/workflow-admission-provider.js +205 -0
- package/dist/service/workflow-argument-serialization.d.ts +2 -0
- package/dist/service/workflow-argument-serialization.js +14 -0
- package/dist/service/workflow-callback.d.ts +22 -0
- package/dist/service/workflow-callback.js +75 -0
- package/dist/service/workflow-deployment.d.ts +8 -0
- package/dist/service/workflow-deployment.js +131 -0
- package/dist/service/workflow-diagnostics.d.ts +23 -0
- package/dist/service/workflow-diagnostics.js +263 -0
- package/dist/service/workflow-errors.d.ts +26 -0
- package/dist/service/workflow-errors.js +181 -0
- package/dist/service/workflow-logging.d.ts +2 -0
- package/dist/service/workflow-logging.js +50 -0
- package/dist/service/workflow-queue-fence.d.ts +6 -0
- package/dist/service/workflow-queue-fence.js +66 -0
- package/dist/service/workflows.d.ts +200 -0
- package/dist/service/workflows.js +1549 -0
- package/dist/sign-in.d.ts +58 -0
- package/dist/sign-in.js +57 -0
- package/dist/source.d.ts +30 -0
- package/dist/source.js +107 -0
- package/dist/start-recovery-contract.d.ts +49 -0
- package/dist/start-recovery-contract.js +26 -0
- package/dist/start-recovery.d.ts +27 -0
- package/dist/start-recovery.js +81 -0
- package/dist/storage/api.d.ts +4 -0
- package/dist/storage/api.js +40 -0
- package/dist/storage/attachments.d.ts +146 -0
- package/dist/storage/attachments.js +733 -0
- package/dist/storage/authorization.d.ts +38 -0
- package/dist/storage/authorization.js +83 -0
- package/dist/storage/file-access.d.ts +17 -0
- package/dist/storage/file-access.js +8 -0
- package/dist/storage/limits.d.ts +12 -0
- package/dist/storage/limits.js +17 -0
- package/dist/storage/maintenance-auth.d.ts +20 -0
- package/dist/storage/maintenance-auth.js +24 -0
- package/dist/storage/maintenance.d.ts +11 -0
- package/dist/storage/maintenance.js +67 -0
- package/dist/storage/neon.d.ts +4 -0
- package/dist/storage/neon.js +318 -0
- package/dist/storage/operator.d.ts +11 -0
- package/dist/storage/operator.js +30 -0
- package/dist/storage/provider.d.ts +93 -0
- package/dist/storage/provider.js +36 -0
- package/dist/storage/sessions.d.ts +184 -0
- package/dist/storage/sessions.js +688 -0
- package/dist/storage/tables.d.ts +54 -0
- package/dist/storage/tables.js +205 -0
- package/dist/storage/transfers.d.ts +16 -0
- package/dist/storage/transfers.js +153 -0
- package/dist/storage/writes.d.ts +7 -0
- package/dist/storage/writes.js +88 -0
- package/dist/telegram.d.ts +35 -0
- package/dist/telegram.js +173 -0
- package/dist/user-identity.d.ts +28 -0
- package/dist/user-identity.js +106 -0
- package/dist/user.d.ts +75 -0
- package/dist/user.js +111 -0
- package/dist/warehouse-backed.d.ts +6 -0
- package/dist/warehouse-backed.js +495 -0
- package/dist/webhook-token.d.ts +11 -0
- package/dist/webhook-token.js +18 -0
- package/dist/webhooks.d.ts +40 -0
- package/dist/webhooks.js +55 -0
- package/dist/wire.d.ts +10 -0
- package/dist/wire.js +35 -0
- package/dist/workflow-runtime.d.ts +116 -0
- package/dist/workflow-runtime.js +109 -0
- package/dist/workflow-topics.d.ts +28 -0
- package/dist/workflow-topics.js +28 -0
- package/dist/workflow.d.ts +284 -0
- package/dist/workflow.js +259 -0
- package/dist/workflows.d.ts +24 -0
- package/dist/workflows.js +18 -0
- package/package.json +127 -4
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { queryFields } from "../query.js";
|
|
3
|
+
import { columnName, historyTableName, quoteIdentifier as qi, quoteLiteral as ql, relationshipColumnName, SYSTEM_COLUMNS, tableName, joinTableName, } from "../migrate/storage.js";
|
|
4
|
+
import { REPLICATION_RECORD_BYTES } from "./model.js";
|
|
5
|
+
import { SHADOW_REPLICATION_DDL, SHADOW_CONTROL_JOBS_DDL, SHADOW_SOURCE_REPLACEMENTS_DDL, } from "./shadow-schema.js";
|
|
6
|
+
export const REPLICATION_SCHEMA_VERSION = 6;
|
|
7
|
+
/** Targets of sources not migrated since fills were introduced have no `fills` column. */
|
|
8
|
+
export const REPLICATION_TARGET_FILLS = `COALESCE(to_jsonb(_ontology_replication_targets) -> 'fills',
|
|
9
|
+
'{}'::jsonb) AS fills`;
|
|
10
|
+
/** Optional metadata keeps the platform reader compatible with sources not upgraded yet. */
|
|
11
|
+
export const REPLICATION_TARGET_METADATA = `
|
|
12
|
+
to_jsonb(_ontology_replication_targets)->'identities' AS identities,
|
|
13
|
+
COALESCE(to_jsonb(_ontology_replication_targets)->'lineage', 'null'::jsonb) AS lineage,
|
|
14
|
+
COALESCE((to_jsonb(_ontology_replication_targets)->>'scans_complete')::boolean, true) AS scans_complete,
|
|
15
|
+
to_jsonb(_ontology_replication_targets)->'backfill_sources' AS backfill_sources,
|
|
16
|
+
(SELECT version FROM _ontology_replication WHERE id) AS schema_version`;
|
|
17
|
+
/** Installed only by the SDK migration runner, never at service startup. */
|
|
18
|
+
export const REPLICATION_DDL = [
|
|
19
|
+
`CREATE TABLE IF NOT EXISTS _ontology_replication (
|
|
20
|
+
id boolean PRIMARY KEY DEFAULT true CHECK (id), version integer NOT NULL,
|
|
21
|
+
source_id uuid NOT NULL DEFAULT gen_random_uuid(), revision bigint NOT NULL DEFAULT 0,
|
|
22
|
+
selection jsonb NOT NULL DEFAULT '{}'::jsonb, enabled boolean NOT NULL DEFAULT false
|
|
23
|
+
)`,
|
|
24
|
+
`INSERT INTO _ontology_replication (id, version) VALUES (true, ${REPLICATION_SCHEMA_VERSION}) ON CONFLICT DO NOTHING`,
|
|
25
|
+
`ALTER TABLE _ontology_replication ADD COLUMN IF NOT EXISTS exclusions jsonb NOT NULL DEFAULT '[]'::jsonb`,
|
|
26
|
+
`ALTER TABLE _ontology_replication ADD COLUMN IF NOT EXISTS active_generation uuid`,
|
|
27
|
+
`CREATE TABLE IF NOT EXISTS _ontology_replication_targets (
|
|
28
|
+
generation uuid PRIMARY KEY, source_id uuid NOT NULL, from_revision bigint NOT NULL,
|
|
29
|
+
manifest jsonb NOT NULL, selection jsonb NOT NULL, created_at timestamptz NOT NULL DEFAULT now()
|
|
30
|
+
)`,
|
|
31
|
+
`DO $$ BEGIN
|
|
32
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint
|
|
33
|
+
WHERE conrelid = '_ontology_replication'::regclass AND conname = '_ontology_replication_protocol_floor') THEN
|
|
34
|
+
ALTER TABLE _ontology_replication ADD CONSTRAINT _ontology_replication_protocol_floor
|
|
35
|
+
CHECK (version >= 4) NOT VALID;
|
|
36
|
+
END IF;
|
|
37
|
+
END $$`,
|
|
38
|
+
`DO $$ BEGIN
|
|
39
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint
|
|
40
|
+
WHERE conrelid = '_ontology_replication'::regclass AND conname = '_ontology_replication_schema_floor_v5') THEN
|
|
41
|
+
ALTER TABLE _ontology_replication ADD CONSTRAINT _ontology_replication_schema_floor_v5
|
|
42
|
+
CHECK (version >= 5) NOT VALID;
|
|
43
|
+
END IF;
|
|
44
|
+
END $$`,
|
|
45
|
+
`CREATE SEQUENCE IF NOT EXISTS _ontology_replication_revision AS bigint CACHE 1`,
|
|
46
|
+
`SELECT setval('_ontology_replication_revision', GREATEST(
|
|
47
|
+
(SELECT revision FROM _ontology_replication WHERE id),
|
|
48
|
+
(SELECT last_value FROM _ontology_replication_revision), 1), true)
|
|
49
|
+
WHERE (SELECT version FROM _ontology_replication WHERE id) < 4`,
|
|
50
|
+
`ALTER TABLE _ontology_replication_targets
|
|
51
|
+
ADD COLUMN IF NOT EXISTS protocol integer NOT NULL DEFAULT 3,
|
|
52
|
+
ADD COLUMN IF NOT EXISTS baseline_complete boolean NOT NULL DEFAULT true,
|
|
53
|
+
ADD COLUMN IF NOT EXISTS baseline_cursor jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
54
|
+
ADD COLUMN IF NOT EXISTS initial_revision bigint,
|
|
55
|
+
ADD COLUMN IF NOT EXISTS backfill_complete boolean NOT NULL DEFAULT true,
|
|
56
|
+
ADD COLUMN IF NOT EXISTS backfill_cursor jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
57
|
+
ADD COLUMN IF NOT EXISTS backfill_revision bigint,
|
|
58
|
+
ADD COLUMN IF NOT EXISTS verified_count bigint NOT NULL DEFAULT 0,
|
|
59
|
+
ADD COLUMN IF NOT EXISTS replay_complete boolean NOT NULL DEFAULT true,
|
|
60
|
+
ADD COLUMN IF NOT EXISTS replay_cursor uuid,
|
|
61
|
+
ADD COLUMN IF NOT EXISTS fills jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
62
|
+
ADD COLUMN IF NOT EXISTS lineage jsonb,
|
|
63
|
+
ADD COLUMN IF NOT EXISTS scans_complete boolean NOT NULL DEFAULT true,
|
|
64
|
+
ADD COLUMN IF NOT EXISTS backfill_sources jsonb`,
|
|
65
|
+
`CREATE TABLE IF NOT EXISTS _ontology_replication_scans (
|
|
66
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
67
|
+
generation uuid NOT NULL REFERENCES _ontology_replication_targets(generation),
|
|
68
|
+
entity_id text NOT NULL, record_kind text NOT NULL,
|
|
69
|
+
initial boolean NOT NULL DEFAULT false, required boolean NOT NULL DEFAULT true,
|
|
70
|
+
complete boolean NOT NULL DEFAULT false, cursor text NOT NULL DEFAULT ''
|
|
71
|
+
)`,
|
|
72
|
+
`CREATE UNIQUE INDEX IF NOT EXISTS _ontology_replication_scan_pending
|
|
73
|
+
ON _ontology_replication_scans (generation, entity_id, record_kind) WHERE NOT complete`,
|
|
74
|
+
`CREATE TABLE IF NOT EXISTS _ontology_replication_delivery (
|
|
75
|
+
generation uuid NOT NULL REFERENCES _ontology_replication_targets(generation),
|
|
76
|
+
event_id uuid NOT NULL, history_table text, revision bigint NOT NULL,
|
|
77
|
+
is_baseline boolean NOT NULL DEFAULT false,
|
|
78
|
+
accepted_at timestamptz, verified_at timestamptz,
|
|
79
|
+
next_verify_at timestamptz NOT NULL DEFAULT now(), last_checked_at timestamptz,
|
|
80
|
+
PRIMARY KEY (generation, event_id)
|
|
81
|
+
)`,
|
|
82
|
+
`ALTER TABLE _ontology_replication_delivery
|
|
83
|
+
ADD COLUMN IF NOT EXISTS payload jsonb,
|
|
84
|
+
ADD COLUMN IF NOT EXISTS scan_id uuid REFERENCES _ontology_replication_scans(id)`,
|
|
85
|
+
`CREATE INDEX IF NOT EXISTS _ontology_delivery_scan_pending
|
|
86
|
+
ON _ontology_replication_delivery (generation, scan_id) WHERE accepted_at IS NULL AND scan_id IS NOT NULL`,
|
|
87
|
+
`CREATE INDEX IF NOT EXISTS _ontology_delivery_pending ON _ontology_replication_delivery
|
|
88
|
+
(generation, revision, event_id) WHERE accepted_at IS NULL`,
|
|
89
|
+
`CREATE INDEX IF NOT EXISTS _ontology_delivery_verify ON _ontology_replication_delivery
|
|
90
|
+
(generation, next_verify_at, event_id) WHERE accepted_at IS NOT NULL AND verified_at IS NULL`,
|
|
91
|
+
`CREATE INDEX IF NOT EXISTS _ontology_delivery_unverified ON _ontology_replication_delivery
|
|
92
|
+
(generation, event_id) WHERE verified_at IS NULL`,
|
|
93
|
+
`CREATE INDEX IF NOT EXISTS _ontology_delivery_initial ON _ontology_replication_delivery
|
|
94
|
+
(generation, revision, event_id) WHERE verified_at IS NULL`,
|
|
95
|
+
`UPDATE _ontology_replication_targets SET backfill_complete = false,
|
|
96
|
+
backfill_revision = (SELECT revision FROM _ontology_replication WHERE id),
|
|
97
|
+
initial_revision = (SELECT revision FROM _ontology_replication WHERE id)
|
|
98
|
+
WHERE protocol = 3 AND backfill_revision IS NULL`,
|
|
99
|
+
`CREATE TABLE IF NOT EXISTS _ontology_replication_baselines (
|
|
100
|
+
generation uuid NOT NULL REFERENCES _ontology_replication_targets(generation),
|
|
101
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(), event jsonb NOT NULL
|
|
102
|
+
)`,
|
|
103
|
+
`CREATE TABLE IF NOT EXISTS _ontology_replication_receipts (
|
|
104
|
+
generation uuid NOT NULL REFERENCES _ontology_replication_targets(generation),
|
|
105
|
+
event_id uuid NOT NULL, accepted_at timestamptz NOT NULL DEFAULT now(), verified_at timestamptz,
|
|
106
|
+
PRIMARY KEY (generation, event_id)
|
|
107
|
+
)`,
|
|
108
|
+
...SHADOW_REPLICATION_DDL,
|
|
109
|
+
SHADOW_CONTROL_JOBS_DDL,
|
|
110
|
+
SHADOW_SOURCE_REPLACEMENTS_DDL,
|
|
111
|
+
`CREATE OR REPLACE FUNCTION _ontology_replication_guard() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
112
|
+
BEGIN
|
|
113
|
+
IF (SELECT enabled FROM _ontology_replication WHERE id) AND
|
|
114
|
+
COALESCE(current_setting('segmentstream.writer', true), '') NOT IN ('1', '2') THEN
|
|
115
|
+
RAISE EXCEPTION 'replication_writer_incompatible' USING ERRCODE='55000';
|
|
116
|
+
END IF;
|
|
117
|
+
RETURN NULL;
|
|
118
|
+
END $$`,
|
|
119
|
+
];
|
|
120
|
+
export function snapshotExpression(entity, alias) {
|
|
121
|
+
const values = queryFields(entity).flatMap((field) => {
|
|
122
|
+
const system = SYSTEM_COLUMNS[field.name];
|
|
123
|
+
const column = system ??
|
|
124
|
+
(entity.properties.some((p) => p.name === field.name)
|
|
125
|
+
? columnName(field.name)
|
|
126
|
+
: relationshipColumnName(field.name.slice(0, -3)));
|
|
127
|
+
// JSON numbers cannot safely carry a PostgreSQL bigint across all transports.
|
|
128
|
+
const cast = field.storage === "integer" ? "::text" : "";
|
|
129
|
+
return [ql(field.name), `${alias}.${qi(column)}${cast}`];
|
|
130
|
+
});
|
|
131
|
+
const chunks = [];
|
|
132
|
+
for (let offset = 0; offset < values.length; offset += 80) {
|
|
133
|
+
chunks.push(`jsonb_build_object(${values.slice(offset, offset + 80).join(", ")})`);
|
|
134
|
+
}
|
|
135
|
+
return `(${chunks.join(" || ")})`;
|
|
136
|
+
}
|
|
137
|
+
/** History is the durable source. Triggers also reject old writers while capture is enabled. */
|
|
138
|
+
export function replicationEntityDdl(manifest, previous) {
|
|
139
|
+
return manifest.entities
|
|
140
|
+
.filter((e) => e.source === undefined && !e.builtIn)
|
|
141
|
+
.flatMap((entity) => {
|
|
142
|
+
const old = previous?.entities.find((item) => item.id === entity.id);
|
|
143
|
+
const compatible = {
|
|
144
|
+
...entity,
|
|
145
|
+
properties: [
|
|
146
|
+
...entity.properties,
|
|
147
|
+
...(old?.properties ?? []).filter((property) => !entity.properties.some((item) => item.name === property.name || item.renamedFrom === property.name)),
|
|
148
|
+
],
|
|
149
|
+
};
|
|
150
|
+
const history = qi(historyTableName(entity.name));
|
|
151
|
+
const table = qi(tableName(entity.name));
|
|
152
|
+
// Keep names stable across renames and below PostgreSQL's 63-byte identifier limit.
|
|
153
|
+
const key = createHash("sha256").update(entity.id).digest("hex").slice(0, 40);
|
|
154
|
+
const fn = qi(`_replicate_${key}`);
|
|
155
|
+
const declared = entity.relationships
|
|
156
|
+
.filter((r) => r.cardinality === "many")
|
|
157
|
+
.map((r) => r.name);
|
|
158
|
+
return [
|
|
159
|
+
`ALTER TABLE ${history} ADD COLUMN IF NOT EXISTS replication jsonb`,
|
|
160
|
+
`CREATE INDEX IF NOT EXISTS ${qi(`_replication_${key}_idx`)} ON ${history}
|
|
161
|
+
(((replication->>'revision')::bigint)) WHERE replication IS NOT NULL`,
|
|
162
|
+
`CREATE OR REPLACE FUNCTION ${fn}() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
163
|
+
DECLARE state _ontology_replication; policy jsonb; snapshot jsonb; relation text; other_id text;
|
|
164
|
+
event_revision bigint; record_key text; record_kind text := 'entity';
|
|
165
|
+
is_deleted boolean := NEW.kind = 'delete';
|
|
166
|
+
BEGIN
|
|
167
|
+
SELECT * INTO state FROM _ontology_replication WHERE id;
|
|
168
|
+
policy := state.selection->${ql(entity.id)};
|
|
169
|
+
IF NOT state.enabled OR policy IS NULL THEN RETURN NEW; END IF;
|
|
170
|
+
record_key := NEW.record_id::text;
|
|
171
|
+
IF NEW.kind IN ('link', 'unlink') THEN
|
|
172
|
+
SELECT key INTO relation FROM jsonb_object_keys(NEW.changes) AS key LIMIT 1;
|
|
173
|
+
IF NOT (${ql(JSON.stringify(declared))}::jsonb ? relation) OR
|
|
174
|
+
NOT (COALESCE(policy->'relationships', '[]'::jsonb) ? relation) THEN RETURN NEW; END IF;
|
|
175
|
+
other_id := COALESCE(NEW.changes->relation->>'after', NEW.changes->relation->>'before');
|
|
176
|
+
record_key := NEW.record_id::text || ':' || other_id;
|
|
177
|
+
record_kind := 'edge:' || relation;
|
|
178
|
+
is_deleted := NEW.kind = 'unlink';
|
|
179
|
+
snapshot := jsonb_build_object('source_id', NEW.record_id::text, 'target_id', other_id);
|
|
180
|
+
ELSIF is_deleted THEN snapshot := '{}'::jsonb;
|
|
181
|
+
ELSE
|
|
182
|
+
SELECT ${snapshotExpression(compatible, "record")} INTO snapshot
|
|
183
|
+
FROM ${table} AS record WHERE id = NEW.record_id;
|
|
184
|
+
SELECT COALESCE(jsonb_object_agg(key, value), '{}'::jsonb) INTO snapshot
|
|
185
|
+
FROM jsonb_each(snapshot) WHERE key = 'id' OR (policy->'fields' ? key);
|
|
186
|
+
IF snapshot IS NULL OR snapshot = '{}'::jsonb THEN RAISE EXCEPTION 'Replication snapshot is missing'; END IF;
|
|
187
|
+
END IF;
|
|
188
|
+
IF octet_length(snapshot::text) > ${REPLICATION_RECORD_BYTES} THEN
|
|
189
|
+
RAISE EXCEPTION 'Projected ontology record exceeds the replication size limit';
|
|
190
|
+
END IF;
|
|
191
|
+
event_revision := nextval('_ontology_replication_revision');
|
|
192
|
+
NEW.replication := jsonb_build_object('source_id', state.source_id::text,
|
|
193
|
+
'entity_id', ${ql(entity.id)}, 'record_key', record_key, 'record_kind', record_kind,
|
|
194
|
+
'revision', event_revision::text, 'generation', state.active_generation::text, 'deleted', is_deleted,
|
|
195
|
+
'schema_hash', ${ql(manifest.hash)}, 'payload', snapshot::text);
|
|
196
|
+
IF state.version >= 6 THEN
|
|
197
|
+
INSERT INTO _ontology_replication_delivery (generation, event_id, history_table, revision, payload_bytes)
|
|
198
|
+
SELECT t.generation, NEW.id, TG_TABLE_NAME, event_revision, octet_length(NEW.replication::text)
|
|
199
|
+
FROM _ontology_replication_targets t
|
|
200
|
+
WHERE t.capturing AND t.source_id = state.source_id
|
|
201
|
+
AND (t.capture_scopes IS NULL OR t.capture_scopes @>
|
|
202
|
+
jsonb_build_array(jsonb_build_object('entityId',${ql(entity.id)},'kind',record_kind)));
|
|
203
|
+
ELSE
|
|
204
|
+
INSERT INTO _ontology_replication_delivery (generation, event_id, history_table, revision)
|
|
205
|
+
VALUES (state.active_generation, NEW.id, TG_TABLE_NAME, event_revision);
|
|
206
|
+
END IF;
|
|
207
|
+
RETURN NEW;
|
|
208
|
+
END $$`,
|
|
209
|
+
`DROP TRIGGER IF EXISTS _ontology_capture ON ${history}`,
|
|
210
|
+
`CREATE TRIGGER _ontology_capture BEFORE INSERT ON ${history} FOR EACH ROW EXECUTE FUNCTION ${fn}()`,
|
|
211
|
+
`DROP TRIGGER IF EXISTS _ontology_writer_guard ON ${table}`,
|
|
212
|
+
`CREATE TRIGGER _ontology_writer_guard BEFORE INSERT OR UPDATE OR DELETE OR TRUNCATE ON ${table}
|
|
213
|
+
FOR EACH STATEMENT EXECUTE FUNCTION _ontology_replication_guard()`,
|
|
214
|
+
...entity.relationships
|
|
215
|
+
.filter((r) => r.cardinality === "many")
|
|
216
|
+
.flatMap((r) => {
|
|
217
|
+
const join = qi(joinTableName(entity.name, r.name));
|
|
218
|
+
return [
|
|
219
|
+
`DROP TRIGGER IF EXISTS _ontology_writer_guard ON ${join}`,
|
|
220
|
+
`CREATE TRIGGER _ontology_writer_guard BEFORE INSERT OR UPDATE OR DELETE OR TRUNCATE ON ${join}
|
|
221
|
+
FOR EACH STATEMENT EXECUTE FUNCTION _ontology_replication_guard()`,
|
|
222
|
+
];
|
|
223
|
+
}),
|
|
224
|
+
];
|
|
225
|
+
});
|
|
226
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Source-side checkpoints commit with capture. Provider operations are always outside transactions. */
|
|
2
|
+
export declare const SHADOW_REPLICATION_DDL: string[];
|
|
3
|
+
export declare const SHADOW_CONTROL_JOBS_DDL = "CREATE TABLE IF NOT EXISTS _ontology_replication_control_jobs (\n logical_id text PRIMARY KEY, configuration_hash text NOT NULL, attempt integer NOT NULL DEFAULT 0,\n failure text, updated_at timestamptz NOT NULL DEFAULT now()\n)";
|
|
4
|
+
export declare const SHADOW_SOURCE_REPLACEMENTS_DDL = "CREATE TABLE IF NOT EXISTS _ontology_replication_source_replacements (\n source_id uuid PRIMARY KEY, operation_id uuid NOT NULL UNIQUE, expected jsonb NOT NULL, proof jsonb,\n attempts jsonb NOT NULL DEFAULT '[]'::jsonb,\n state text NOT NULL CHECK(state IN ('pending','completed')), created_at timestamptz NOT NULL DEFAULT now()\n)";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Source-side checkpoints commit with capture. Provider operations are always outside transactions. */
|
|
2
|
+
export const SHADOW_REPLICATION_DDL = [
|
|
3
|
+
`DO $$ BEGIN
|
|
4
|
+
IF NOT EXISTS(SELECT 1 FROM pg_constraint WHERE conrelid='_ontology_replication'::regclass
|
|
5
|
+
AND conname='_ontology_replication_schema_floor_v6') THEN
|
|
6
|
+
ALTER TABLE _ontology_replication ADD CONSTRAINT _ontology_replication_schema_floor_v6
|
|
7
|
+
CHECK(version>=6) NOT VALID;
|
|
8
|
+
END IF;
|
|
9
|
+
END $$`,
|
|
10
|
+
`ALTER TABLE _ontology_replication ADD COLUMN IF NOT EXISTS serving_epoch uuid`,
|
|
11
|
+
`ALTER TABLE _ontology_replication
|
|
12
|
+
ADD COLUMN IF NOT EXISTS requested_manifest_hash text,
|
|
13
|
+
ADD COLUMN IF NOT EXISTS destination_repair_pending boolean NOT NULL DEFAULT false,
|
|
14
|
+
ADD COLUMN IF NOT EXISTS destination_rebuilding boolean NOT NULL DEFAULT false,
|
|
15
|
+
ADD COLUMN IF NOT EXISTS requested_manifest_until timestamptz`,
|
|
16
|
+
`ALTER TABLE _ontology_replication_targets
|
|
17
|
+
ADD COLUMN IF NOT EXISTS identities jsonb,
|
|
18
|
+
ADD COLUMN IF NOT EXISTS capturing boolean NOT NULL DEFAULT false,
|
|
19
|
+
ADD COLUMN IF NOT EXISTS capture_bindings jsonb,
|
|
20
|
+
ADD COLUMN IF NOT EXISTS capture_versions jsonb,
|
|
21
|
+
ADD COLUMN IF NOT EXISTS capture_scopes jsonb`,
|
|
22
|
+
`CREATE SEQUENCE IF NOT EXISTS _ontology_replication_cutover_fence AS bigint CACHE 1`,
|
|
23
|
+
`CREATE TABLE IF NOT EXISTS _ontology_replication_epochs (
|
|
24
|
+
id uuid PRIMARY KEY REFERENCES _ontology_replication_targets(generation),
|
|
25
|
+
source_id uuid NOT NULL, desired_hash text NOT NULL,
|
|
26
|
+
target jsonb NOT NULL, routes jsonb NOT NULL,
|
|
27
|
+
state text NOT NULL CHECK (state IN ('candidate','serving','retired','cancelled')),
|
|
28
|
+
predecessor uuid, created_at timestamptz NOT NULL DEFAULT now(), retired_at timestamptz,
|
|
29
|
+
owner uuid, owner_until timestamptz,
|
|
30
|
+
boundary bigint, catchup_boundary bigint, token uuid, fence bigint, handoff_until timestamptz, operation_id uuid,
|
|
31
|
+
installed boolean NOT NULL DEFAULT false, cancel_requested boolean NOT NULL DEFAULT false,
|
|
32
|
+
policy_installed boolean NOT NULL DEFAULT false
|
|
33
|
+
)`,
|
|
34
|
+
`CREATE UNIQUE INDEX IF NOT EXISTS _ontology_replication_one_candidate
|
|
35
|
+
ON _ontology_replication_epochs ((true)) WHERE state = 'candidate'`,
|
|
36
|
+
`CREATE TABLE IF NOT EXISTS _ontology_replication_segments (
|
|
37
|
+
id uuid PRIMARY KEY, epoch uuid NOT NULL REFERENCES _ontology_replication_epochs(id),
|
|
38
|
+
generation uuid NOT NULL, source_id uuid NOT NULL, through_revision bigint NOT NULL,
|
|
39
|
+
events jsonb NOT NULL, event_ids jsonb NOT NULL, digest text NOT NULL,
|
|
40
|
+
object_uri text NOT NULL, job_id text NOT NULL, attempt integer NOT NULL DEFAULT 0,
|
|
41
|
+
state text NOT NULL DEFAULT 'pending' CHECK (state IN ('pending','committed','failed')),
|
|
42
|
+
failure jsonb, retry_after timestamptz NOT NULL DEFAULT now(),
|
|
43
|
+
created_at timestamptz NOT NULL DEFAULT now(), committed_at timestamptz
|
|
44
|
+
)`,
|
|
45
|
+
`ALTER TABLE _ontology_replication_delivery
|
|
46
|
+
ADD COLUMN IF NOT EXISTS committed_at timestamptz,
|
|
47
|
+
ADD COLUMN IF NOT EXISTS suppressed_at timestamptz,
|
|
48
|
+
ADD COLUMN IF NOT EXISTS payload_bytes integer NOT NULL DEFAULT 401000,
|
|
49
|
+
ADD COLUMN IF NOT EXISTS segment_id uuid REFERENCES _ontology_replication_segments(id)`,
|
|
50
|
+
`CREATE INDEX IF NOT EXISTS _ontology_replication_uncommitted
|
|
51
|
+
ON _ontology_replication_delivery (generation,revision,event_id) WHERE committed_at IS NULL`,
|
|
52
|
+
];
|
|
53
|
+
export const SHADOW_CONTROL_JOBS_DDL = `CREATE TABLE IF NOT EXISTS _ontology_replication_control_jobs (
|
|
54
|
+
logical_id text PRIMARY KEY, configuration_hash text NOT NULL, attempt integer NOT NULL DEFAULT 0,
|
|
55
|
+
failure text, updated_at timestamptz NOT NULL DEFAULT now()
|
|
56
|
+
)`;
|
|
57
|
+
export const SHADOW_SOURCE_REPLACEMENTS_DDL = `CREATE TABLE IF NOT EXISTS _ontology_replication_source_replacements (
|
|
58
|
+
source_id uuid PRIMARY KEY, operation_id uuid NOT NULL UNIQUE, expected jsonb NOT NULL, proof jsonb,
|
|
59
|
+
attempts jsonb NOT NULL DEFAULT '[]'::jsonb,
|
|
60
|
+
state text NOT NULL CHECK(state IN ('pending','completed')), created_at timestamptz NOT NULL DEFAULT now()
|
|
61
|
+
)`;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type ReplicationIdentities } from "./identities.js";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import type { SqlClient } from "effect/unstable/sql";
|
|
4
|
+
import { type OntologyManifest } from "../manifest.js";
|
|
5
|
+
import type { ReplicationTarget } from "./baseline.js";
|
|
6
|
+
import { ReplicationBaselineFailed } from "./baseline.js";
|
|
7
|
+
import { type ReplicationScanScope } from "./scans.js";
|
|
8
|
+
import type { ReplicationEvent, ReplicationSelection } from "./model.js";
|
|
9
|
+
export declare const SHADOW_HANDOFF_MS = 30000;
|
|
10
|
+
export declare const SHADOW_RETENTION_MS: number;
|
|
11
|
+
export declare const SHADOW_QUERY_LIFETIME_MS: number;
|
|
12
|
+
export interface ShadowRoute extends ReplicationScanScope {
|
|
13
|
+
readonly target: ReplicationTarget;
|
|
14
|
+
}
|
|
15
|
+
export interface ShadowEpoch {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly source_id: string;
|
|
18
|
+
readonly desired_hash: string;
|
|
19
|
+
readonly target: ReplicationTarget;
|
|
20
|
+
readonly routes: readonly ShadowRoute[];
|
|
21
|
+
readonly state: "candidate" | "serving" | "retired" | "cancelled";
|
|
22
|
+
readonly predecessor: string | null;
|
|
23
|
+
readonly boundary: string | null;
|
|
24
|
+
readonly catchup_boundary?: string | null;
|
|
25
|
+
readonly token: string | null;
|
|
26
|
+
readonly fence: string | null;
|
|
27
|
+
readonly handoff_until: string | null;
|
|
28
|
+
readonly operation_id: string | null;
|
|
29
|
+
readonly installed: boolean;
|
|
30
|
+
readonly cancel_requested?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface ShadowSegment {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly epoch: string;
|
|
35
|
+
readonly generation: string;
|
|
36
|
+
readonly source_id: string;
|
|
37
|
+
readonly through_revision: string;
|
|
38
|
+
readonly events: readonly ReplicationEvent[];
|
|
39
|
+
readonly event_ids: readonly string[];
|
|
40
|
+
readonly digest: string;
|
|
41
|
+
readonly object_uri: string;
|
|
42
|
+
readonly job_id: string;
|
|
43
|
+
readonly attempt: number;
|
|
44
|
+
readonly retry_after: string;
|
|
45
|
+
readonly state: "pending" | "committed" | "failed";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Every route carries a full target, and most routes repeat the epoch target's manifest and
|
|
49
|
+
* projection. One copy per scope grows with entities times manifest size, past what a single
|
|
50
|
+
* PostgreSQL message may carry, so a stored route names the keys it takes from its epoch target.
|
|
51
|
+
*/
|
|
52
|
+
export declare function compactShadowRoutes(routes: readonly ShadowRoute[], target: ReplicationTarget): readonly unknown[];
|
|
53
|
+
/** Restores the keys a stored route took from its epoch target. Full stored routes pass through. */
|
|
54
|
+
export declare function expandShadowRoutes(routes: readonly unknown[], target: ReplicationTarget): readonly ShadowRoute[];
|
|
55
|
+
export declare const shadowEpoch: (sql: SqlClient.SqlClient, id: string) => Effect.Effect<ShadowEpoch | undefined, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
56
|
+
export declare const servingShadowEpoch: (sql: SqlClient.SqlClient) => Effect.Effect<ShadowEpoch | undefined, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
57
|
+
export declare const candidateShadowEpoch: (sql: SqlClient.SqlClient) => Effect.Effect<ShadowEpoch | undefined, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
58
|
+
export declare const shadowProjectionHash: (target: ReplicationTarget) => string;
|
|
59
|
+
/** Called under exclusive lifecycle admission; no provider I/O is permitted here. */
|
|
60
|
+
export declare const adoptShadowServing: (sql: SqlClient.SqlClient, target: ReplicationTarget) => Effect.Effect<ShadowEpoch, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
61
|
+
/** Capture bindings name wire fields, not public columns. Renames never rewrite historical JSON. */
|
|
62
|
+
export declare const enableShadowCapture: (sql: SqlClient.SqlClient, target: ReplicationTarget, scopes: readonly ReplicationScanScope[]) => Effect.Effect<readonly object[], import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
63
|
+
/**
|
|
64
|
+
* Immutable epochs may share unaffected generations. Only complete affected entity scopes get a
|
|
65
|
+
* fresh incarnation. Generation-zero snapshots cannot overwrite mutations in another incarnation.
|
|
66
|
+
*/
|
|
67
|
+
export declare const prepareShadowEpoch: (sql: SqlClient.SqlClient, input: {
|
|
68
|
+
readonly target: ReplicationTarget;
|
|
69
|
+
readonly affected: readonly ReplicationScanScope[];
|
|
70
|
+
readonly predecessor?: ShadowEpoch;
|
|
71
|
+
readonly force?: boolean;
|
|
72
|
+
}) => Effect.Effect<ShadowEpoch, import("effect/unstable/sql/SqlError").SqlError | ReplicationBaselineFailed, never>;
|
|
73
|
+
/** Remap destination wire bindings before installing the next source snapshot trigger. */
|
|
74
|
+
export declare const migrateShadowCapture: (sql: SqlClient.SqlClient, current: OntologyManifest, next: OntologyManifest, selection: readonly ReplicationSelection[], identities: ReplicationIdentities) => Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
75
|
+
/** Every pass has a source-side lease as well as the product lease; stale completions are rejected. */
|
|
76
|
+
export declare const claimShadowEpoch: (sql: SqlClient.SqlClient, id: string, owner: string) => Effect.Effect<boolean, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
77
|
+
export declare const releaseShadowEpoch: (sql: SqlClient.SqlClient, id: string, owner: string) => import("effect/unstable/sql/Statement").Statement<object>;
|
|
78
|
+
/** A closed source boundary is selected only after all admitted writers and scans have drained. */
|
|
79
|
+
export declare const beginShadowHandoff: (sql: SqlClient.SqlClient, id: string, owner: string, minimumFence?: string) => Effect.Effect<ShadowEpoch | undefined, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
80
|
+
/** Destination invalidation must have succeeded (or switched) before this transaction runs. */
|
|
81
|
+
export declare const abandonShadowHandoff: (sql: SqlClient.SqlClient, epoch: ShadowEpoch) => Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
82
|
+
export declare const completeShadowEpoch: (sql: SqlClient.SqlClient, epoch: ShadowEpoch) => Effect.Effect<undefined, import("effect/unstable/sql/SqlError").SqlError | ReplicationBaselineFailed, never>;
|
|
83
|
+
export declare const pendingShadowSegment: (sql: SqlClient.SqlClient, epoch: string) => Effect.Effect<ShadowSegment | undefined, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
84
|
+
/** Source events, immutable object names and job identities commit before the first upload. */
|
|
85
|
+
export declare const journalShadowSegment: (sql: SqlClient.SqlClient, input: {
|
|
86
|
+
readonly epoch: ShadowEpoch;
|
|
87
|
+
readonly owner: string;
|
|
88
|
+
readonly projectId: string;
|
|
89
|
+
readonly events: readonly {
|
|
90
|
+
readonly historyId: string;
|
|
91
|
+
readonly event: ReplicationEvent;
|
|
92
|
+
}[];
|
|
93
|
+
}) => Effect.Effect<ShadowSegment | undefined, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
94
|
+
export declare const finishShadowSegment: (sql: SqlClient.SqlClient, segment: ShadowSegment, owner: string) => Effect.Effect<boolean, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
95
|
+
export declare const retryShadowSegment: (sql: SqlClient.SqlClient, segment: ShadowSegment, owner: string, failure: unknown) => import("effect/unstable/sql/Statement").Statement<object>;
|
|
96
|
+
/** Recheck references under the lifecycle fence. Audit journals and immutable epoch routes survive. */
|
|
97
|
+
export declare const retireShadowCapture: (sql: SqlClient.SqlClient) => Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
98
|
+
/** Filter by the destination's immutable wire schema, including missing keys and explicit nulls. */
|
|
99
|
+
export declare function shadowWireEvent(event: ReplicationEvent, bindings: Record<string, Record<string, string>>, selection: readonly ReplicationSelection[]): ReplicationEvent;
|
|
100
|
+
/** Capture is the union needed by live destinations; export shaping remains destination-specific. */
|
|
101
|
+
export declare const refreshShadowCapturePolicy: (sql: SqlClient.SqlClient) => import("effect/unstable/sql/Statement").Statement<object>;
|
|
102
|
+
/** Only generations retired for seven days qualify; creation time is never a query-safety fence. */
|
|
103
|
+
export declare const retiredShadowGenerations: (sql: SqlClient.SqlClient) => Effect.Effect<readonly {
|
|
104
|
+
generation: string;
|
|
105
|
+
source_id: string;
|
|
106
|
+
}[], import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
107
|
+
/** The destination has already fenced and deselected an observably destroyed event table. */
|
|
108
|
+
export declare const replaceDestroyedShadowDestination: (sql: SqlClient.SqlClient, input: {
|
|
109
|
+
readonly target: ReplicationTarget;
|
|
110
|
+
readonly fence: string;
|
|
111
|
+
}) => Effect.Effect<ShadowEpoch, import("effect/unstable/sql/SqlError").SqlError | ReplicationBaselineFailed, never>;
|
|
112
|
+
export declare const installShadowEpoch: (sql: SqlClient.SqlClient, id: string, owner: string) => Effect.Effect<boolean, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
113
|
+
/** Strict warehouse job completion, not Pub/Sub acceptance, is the publication prerequisite. */
|
|
114
|
+
export declare const shadowPublicationReady: (sql: SqlClient.SqlClient, epoch: ShadowEpoch, owner: string) => Effect.Effect<boolean, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
115
|
+
export declare const unfinishedRetiredSegments: (sql: SqlClient.SqlClient) => import("effect/unstable/sql/Statement").Statement<ShadowSegment>;
|
|
116
|
+
export declare const settleRetiredSegment: (sql: SqlClient.SqlClient, segment: ShadowSegment, committed: boolean) => import("effect/unstable/sql/Statement").Statement<object>;
|
|
117
|
+
/** Restriction-only refresh is independent of build leases and cannot confer publication eligibility. */
|
|
118
|
+
export declare const shadowPolicyViewOwnership: (sql: SqlClient.SqlClient, generation: string, source: string, exclusions: unknown) => Effect.Effect<boolean, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
119
|
+
export declare const recordShadowPolicyViews: (sql: SqlClient.SqlClient, generation: string, source: string, exclusions: unknown) => import("effect/unstable/sql/Statement").Statement<object>;
|
|
120
|
+
/** Used after reading a destination view's etag, before its conditional DDL update. */
|
|
121
|
+
export declare const shadowViewOwnership: (sql: SqlClient.SqlClient, id: string) => Effect.Effect<boolean, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
122
|
+
/** A finite background goal prevents continuous writes from moving initialization's finish line. */
|
|
123
|
+
export declare const closeShadowCatchup: (sql: SqlClient.SqlClient, id: string, owner: string) => Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
124
|
+
/** Persist cancellation before returning a retryable migration decision; provider fencing follows. */
|
|
125
|
+
export declare const requestShadowSupersession: (sql: SqlClient.SqlClient, manifestHash: string) => Effect.Effect<boolean, import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
126
|
+
/** The destination token has been invalidated, or no token ever existed. */
|
|
127
|
+
export declare const cancelShadowEpoch: (sql: SqlClient.SqlClient, epoch: ShadowEpoch) => Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, never>;
|