@opengeni/db 0.28.9 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attached-browser-devices.d.ts +42 -0
- package/dist/attempt-tool-catalogs.d.ts +16 -0
- package/dist/browser-auth.d.ts +299 -0
- package/dist/browser-downloads.d.ts +51 -0
- package/dist/browser-identities.d.ts +137 -0
- package/dist/browser-sessions.d.ts +354 -0
- package/dist/browser-state-artifacts.d.ts +91 -0
- package/dist/canonical-human-identities.d.ts +48 -0
- package/dist/canonical-human-identities.js +28 -0
- package/dist/canonical-human-identities.js.map +1 -0
- package/dist/capability-components.d.ts +37 -0
- package/dist/capability-integrations.d.ts +194 -0
- package/dist/chunk-5KTIEDX7.js +13200 -0
- package/dist/chunk-5KTIEDX7.js.map +1 -0
- package/dist/chunk-CQZ4QSP5.js +995 -0
- package/dist/chunk-CQZ4QSP5.js.map +1 -0
- package/dist/chunk-F32YT7MP.js +117 -0
- package/dist/chunk-F32YT7MP.js.map +1 -0
- package/dist/chunk-JC5QPLUM.js +666 -0
- package/dist/chunk-JC5QPLUM.js.map +1 -0
- package/dist/chunk-P3RE4D2B.js +3535 -0
- package/dist/chunk-P3RE4D2B.js.map +1 -0
- package/dist/chunk-TAUTWOS5.js +259 -0
- package/dist/chunk-TAUTWOS5.js.map +1 -0
- package/dist/chunk-VKLB2ZGI.js +2389 -0
- package/dist/chunk-VKLB2ZGI.js.map +1 -0
- package/dist/codemode-operations.d.ts +117 -0
- package/dist/codex-token-resolver.d.ts +2 -2
- package/dist/company-profile-schema.d.ts +798 -0
- package/dist/company-profile.d.ts +268 -0
- package/dist/computer-sessions.d.ts +109 -0
- package/dist/connection-token-resolver.d.ts +9 -4
- package/dist/database.d.ts +57 -3
- package/dist/editable-artifact-durable-export.d.ts +153 -0
- package/dist/editable-artifact-durable-export.js +788 -0
- package/dist/editable-artifact-durable-export.js.map +1 -0
- package/dist/editable-artifact-materialization.d.ts +123 -0
- package/dist/editable-artifacts-schema.d.ts +4152 -0
- package/dist/editable-artifacts.d.ts +610 -0
- package/dist/editable-artifacts.js +26 -0
- package/dist/editable-artifacts.js.map +1 -0
- package/dist/generated-images.d.ts +139 -0
- package/dist/index.d.ts +1122 -126
- package/dist/index.js +42329 -18407
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +73 -10
- package/dist/integration-bindings.d.ts +70 -0
- package/dist/integration-facets.d.ts +99 -0
- package/dist/interaction-revisions.d.ts +14 -0
- package/dist/interaction-schema.d.ts +6036 -0
- package/dist/knowledge-source-sync-schema.d.ts +1679 -0
- package/dist/knowledge-source-sync.d.ts +274 -0
- package/dist/memory-governance.d.ts +2 -2
- package/dist/memory-slack-delivery.d.ts +101 -0
- package/dist/new-session-drafts.d.ts +2 -2
- package/dist/pack-components.d.ts +76 -0
- package/dist/pack-installations.d.ts +86 -0
- package/dist/persistence-errors.d.ts +3 -3
- package/dist/plugin-packages.d.ts +126 -0
- package/dist/preference-registry.d.ts +1 -1
- package/dist/provision-roles.d.ts +9 -1
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +19 -6
- package/dist/schema.d.ts +22654 -9359
- package/dist/schema.js +209 -3
- package/dist/scoped-knowledge.d.ts +97 -1
- package/dist/session-control.d.ts +33 -7
- package/dist/session-queue-commands.d.ts +19 -11
- package/dist/session-realtime-context.d.ts +2 -2
- package/dist/session-realtime-ledger.d.ts +4 -4
- package/dist/session-realtime-mirror.d.ts +2 -2
- package/dist/session-realtime-state.d.ts +1 -1
- package/dist/session-realtime-terminal.d.ts +1 -1
- package/dist/session-realtime.d.ts +7 -7
- package/dist/session-tenancy.d.ts +44 -0
- package/dist/session-tenancy.js +16 -0
- package/dist/session-tenancy.js.map +1 -0
- package/dist/session-tool-call-settlement.d.ts +1 -1
- package/dist/slack-task-policy-schema.d.ts +847 -0
- package/dist/slack-task-policy.d.ts +65 -0
- package/dist/slack-user-link-access.d.ts +54 -0
- package/dist/task-notes-schema.d.ts +924 -0
- package/dist/task-notes.d.ts +85 -0
- package/dist/transcription-recordings.d.ts +2 -2
- package/dist/turn-initiator.d.ts +2 -2
- package/dist/video-generation.d.ts +225 -0
- package/dist/video-generation.js +68 -0
- package/dist/video-generation.js.map +1 -0
- package/dist/workspace-artifacts.d.ts +1 -1
- package/dist/workspace-instruction-policies.d.ts +1 -1
- package/dist/workspace-learning-policy-schema.d.ts +932 -0
- package/dist/workspace-learning-policy.d.ts +161 -0
- package/dist/xai-subscription.d.ts +326 -0
- package/drizzle/0183_model_call_provider_cost_estimates.sql +39 -0
- package/drizzle/0184_sandbox_drain_teardown_fence.sql +682 -0
- package/drizzle/0185_temporal_schedule_cleanup_outbox.sql +168 -0
- package/drizzle/0186_sandbox_capture_provider_contract.sql +400 -0
- package/drizzle/0187_generated_image_artifacts.sql +173 -0
- package/drizzle/0188_image_generation_retention_failure.sql +25 -0
- package/drizzle/0189_retained_session_image_formats.sql +13 -0
- package/drizzle/0190_timeline_annotations.sql +31 -0
- package/drizzle/0191_editable_artifact_engine.sql +3853 -0
- package/drizzle/0192_editable_artifact_live_tickets.sql +338 -0
- package/drizzle/0193_editable_artifact_authorization.sql +190 -0
- package/drizzle/0194_editable_artifact_durable_exports.sql +160 -0
- package/drizzle/0195_editable_artifact_import_authorization.sql +203 -0
- package/drizzle/0196_rig_provider_images.sql +152 -0
- package/drizzle/0197_knowledge_source_sync_schedules.sql +523 -0
- package/drizzle/0198_memory_slack_publication_delivery.sql +393 -0
- package/drizzle/0199_workspace_learning_policy.sql +980 -0
- package/drizzle/0201_company_profile_authority.sql +849 -0
- package/drizzle/0202_document_index_checkpoints.sql +85 -0
- package/drizzle/0203_durable_video_generation.sql +353 -0
- package/drizzle/0204_video_generation_funding.sql +44 -0
- package/drizzle/0205_attempt_tool_catalogs.sql +230 -0
- package/drizzle/0206_browser_sessions.sql +646 -0
- package/drizzle/0207_browser_identities.sql +379 -0
- package/drizzle/0208_attached_browser_devices.sql +165 -0
- package/drizzle/0209_computer_sessions.sql +575 -0
- package/drizzle/0210_browser_auth_network_interventions.sql +441 -0
- package/drizzle/0211_editable_artifact_session_links.sql +58 -0
- package/drizzle/0212_browser_state_transfer_hardening.sql +560 -0
- package/drizzle/0212_slack_installation_bindings.sql +348 -0
- package/drizzle/0213_browser_interaction_authority.sql +67 -0
- package/drizzle/0213_slack_user_link_access_requests.sql +177 -0
- package/drizzle/0214_browser_download_saves.sql +34 -0
- package/drizzle/0214_session_activity_commit_gate.sql +262 -0
- package/drizzle/0215_browser_controller_host.sql +385 -0
- package/drizzle/0215_capabilities_platform.sql +980 -0
- package/drizzle/0216_browser_auth_health_evidence.sql +137 -0
- package/drizzle/0216_pack_component_ownership.sql +235 -0
- package/drizzle/0217_capability_definition_delete_authority.sql +32 -0
- package/drizzle/0217_external_browser_auth_operations.sql +22 -0
- package/drizzle/0218_organization_tenancy_foundation.sql +299 -0
- package/drizzle/0219_organization_tenancy_managed_human_provisioning.sql +317 -0
- package/drizzle/0219_site_auth_maintenance_sessions.sql +234 -0
- package/drizzle/0220_memory_slack_append_only_cascade.sql +38 -0
- package/drizzle/0220_session_channels.sql +54 -0
- package/drizzle/0221_sessions_channel_index.sql +5 -0
- package/drizzle/0222_session_visibility_authority_epochs.sql +158 -0
- package/drizzle/0222_sessions_channel_fk.sql +89 -0
- package/drizzle/0223_pending_tool_event_output.sql +55 -0
- package/drizzle/0223_sessions_channel_fk_validate.sql +118 -0
- package/drizzle/0224_slack_post_outcome_reconciliation.sql +123 -0
- package/drizzle/0225_session_visibility_fork_activation.sql +1363 -0
- package/drizzle/0226_personal_codex_authority_foundation.sql +365 -0
- package/drizzle/0227_slack_native_actions.sql +145 -0
- package/drizzle/0228_interaction_controller_data_plane.sql +14 -0
- package/drizzle/0228_slack_task_policy.sql +400 -0
- package/drizzle/0229_slack_inbox_file_fact.sql +10 -0
- package/drizzle/0230_user_scoped_variable_sets_rigs.sql +84 -0
- package/drizzle/0231_integration_definition_identity_cutover.sql +271 -0
- package/drizzle/0232_integration_facet_authority_cutover.sql +610 -0
- package/drizzle/0233_skill_and_integration_authority_cutover.sql +1162 -0
- package/drizzle/0234_xai_subscription_authority.sql +1139 -0
- package/drizzle/0235_canonical_human_login_bindings.sql +920 -0
- package/drizzle/0236_browser_identity_lifecycle.sql +39 -0
- package/drizzle/0236_session_visibility_slack_policy.sql +72 -0
- package/drizzle/0237_interaction_transition_reaper.sql +263 -0
- package/drizzle/0238_goal_persistence_policy.sql +471 -0
- package/drizzle/0238_supergrok_realtime_model.sql +29 -0
- package/drizzle/0239_supergrok_video_funding.sql +50 -0
- package/drizzle/0239_task_tree_notes.sql +990 -0
- package/package.json +26 -5
- package/src/attached-browser-devices.ts +371 -0
- package/src/attempt-tool-catalogs.ts +131 -0
- package/src/browser-auth.ts +4373 -0
- package/src/browser-downloads.ts +517 -0
- package/src/browser-identities.ts +1385 -0
- package/src/browser-sessions.ts +2294 -0
- package/src/browser-state-artifacts.ts +449 -0
- package/src/canonical-human-identities.ts +317 -0
- package/src/capability-components.ts +166 -0
- package/src/capability-integrations.ts +1571 -0
- package/src/codemode-operations.ts +674 -0
- package/src/company-profile-schema.ts +143 -0
- package/src/company-profile.ts +968 -0
- package/src/computer-sessions.ts +1130 -0
- package/src/connection-token-resolver.ts +270 -25
- package/src/database.ts +468 -24
- package/src/editable-artifact-durable-export.ts +1201 -0
- package/src/editable-artifact-materialization.ts +893 -0
- package/src/editable-artifacts-schema.ts +879 -0
- package/src/editable-artifacts.ts +5404 -0
- package/src/generated-images.ts +740 -0
- package/src/index.ts +9963 -1465
- package/src/insights.ts +251 -23
- package/src/integration-bindings.ts +455 -0
- package/src/integration-facets.ts +862 -0
- package/src/interaction-revisions.ts +70 -0
- package/src/interaction-schema.ts +1606 -0
- package/src/knowledge-source-sync-schema.ts +192 -0
- package/src/knowledge-source-sync.ts +1922 -0
- package/src/memory-slack-delivery.ts +801 -0
- package/src/pack-components.ts +954 -0
- package/src/pack-installations.ts +886 -0
- package/src/persistence-errors.ts +4 -7
- package/src/plugin-packages.ts +1186 -0
- package/src/provision-roles.ts +534 -1
- package/src/runtime-posture-cli.ts +9 -0
- package/src/runtime-posture.ts +721 -5
- package/src/schema.ts +6270 -3159
- package/src/scoped-knowledge-schema.ts +1 -1
- package/src/scoped-knowledge.ts +655 -3
- package/src/session-control.ts +130 -42
- package/src/session-queue-commands.ts +265 -15
- package/src/session-realtime-context.ts +2 -2
- package/src/session-realtime-ledger.ts +3 -3
- package/src/session-realtime.ts +7 -7
- package/src/session-tenancy.ts +188 -0
- package/src/session-tool-call-settlement.ts +18 -3
- package/src/slack-task-policy-schema.ts +130 -0
- package/src/slack-task-policy.ts +341 -0
- package/src/slack-user-link-access.ts +702 -0
- package/src/task-notes-schema.ts +135 -0
- package/src/task-notes.ts +178 -0
- package/src/video-generation.ts +1530 -0
- package/src/workspace-artifacts.ts +1 -1
- package/src/workspace-learning-policy-schema.ts +139 -0
- package/src/workspace-learning-policy.ts +595 -0
- package/src/xai-subscription.ts +1887 -0
- package/dist/chunk-P6CUHXQZ.js +0 -7248
- package/dist/chunk-P6CUHXQZ.js.map +0 -1
- package/dist/chunk-VHBFHMPC.js +0 -1219
- package/dist/chunk-VHBFHMPC.js.map +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
-- deployment-mode: maintenance
|
|
2
|
+
-- Causally ordered SiteAuth health evidence. Browser runs remain independent;
|
|
3
|
+
-- only the newest-started terminal evidence may change the shared projection.
|
|
4
|
+
SET LOCAL lock_timeout = '5s';
|
|
5
|
+
SET LOCAL statement_timeout = '30s';
|
|
6
|
+
|
|
7
|
+
CREATE SEQUENCE "auth_runs_health_sequence_seq" AS bigint;
|
|
8
|
+
|
|
9
|
+
ALTER TABLE "auth_runs"
|
|
10
|
+
ADD COLUMN "purpose" text NOT NULL DEFAULT 'authenticate',
|
|
11
|
+
ADD COLUMN "health_sequence" bigint NOT NULL
|
|
12
|
+
DEFAULT nextval('auth_runs_health_sequence_seq'::regclass);
|
|
13
|
+
|
|
14
|
+
ALTER SEQUENCE "auth_runs_health_sequence_seq"
|
|
15
|
+
OWNED BY "auth_runs"."health_sequence";
|
|
16
|
+
|
|
17
|
+
-- The volatile default gives legacy rows values, but physical row order is not
|
|
18
|
+
-- causal. Re-rank the bounded pre-cutover history before admitting writers.
|
|
19
|
+
WITH ordered AS (
|
|
20
|
+
SELECT
|
|
21
|
+
"id",
|
|
22
|
+
row_number() OVER (ORDER BY "created_at", "id")::bigint AS "health_sequence"
|
|
23
|
+
FROM "auth_runs"
|
|
24
|
+
)
|
|
25
|
+
UPDATE "auth_runs" AS run
|
|
26
|
+
SET "health_sequence" = ordered."health_sequence"
|
|
27
|
+
FROM ordered
|
|
28
|
+
WHERE run."id" = ordered."id";
|
|
29
|
+
|
|
30
|
+
SELECT setval(
|
|
31
|
+
'auth_runs_health_sequence_seq'::regclass,
|
|
32
|
+
greatest(coalesce((SELECT max("health_sequence") FROM "auth_runs"), 0), 1),
|
|
33
|
+
coalesce((SELECT max("health_sequence") FROM "auth_runs"), 0) > 0
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
ALTER TABLE "auth_runs"
|
|
37
|
+
ADD CONSTRAINT "auth_runs_health_evidence_check" CHECK (
|
|
38
|
+
"purpose" IN ('authenticate', 'health_check', 'repair')
|
|
39
|
+
AND "health_sequence" > 0
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
ALTER TABLE "site_auth_connections"
|
|
43
|
+
ADD COLUMN "last_checked_at" timestamptz,
|
|
44
|
+
ADD COLUMN "next_check_at" timestamptz,
|
|
45
|
+
ADD COLUMN "health_sequence" bigint NOT NULL DEFAULT 0;
|
|
46
|
+
|
|
47
|
+
-- Existing successful verification is preserved. Existing terminal failures,
|
|
48
|
+
-- which the old writer failed to project, become repair evidence now.
|
|
49
|
+
WITH latest AS (
|
|
50
|
+
SELECT DISTINCT ON (run."site_auth_connection_id")
|
|
51
|
+
run."site_auth_connection_id",
|
|
52
|
+
run."id",
|
|
53
|
+
run."state",
|
|
54
|
+
run."purpose",
|
|
55
|
+
run."health_sequence",
|
|
56
|
+
run."verified_url",
|
|
57
|
+
run."failure_code",
|
|
58
|
+
run."settled_at"
|
|
59
|
+
FROM "auth_runs" AS run
|
|
60
|
+
WHERE run."state" IN ('verified', 'failed')
|
|
61
|
+
AND run."settled_at" IS NOT NULL
|
|
62
|
+
ORDER BY run."site_auth_connection_id", run."health_sequence" DESC
|
|
63
|
+
)
|
|
64
|
+
UPDATE "site_auth_connections" AS connection
|
|
65
|
+
SET
|
|
66
|
+
"verification_state" = CASE
|
|
67
|
+
WHEN latest."state" = 'verified' THEN 'verified'
|
|
68
|
+
WHEN latest."purpose" = 'repair' THEN 'failed'
|
|
69
|
+
ELSE 'needs_repair'
|
|
70
|
+
END,
|
|
71
|
+
"last_verified_at" = CASE
|
|
72
|
+
WHEN latest."state" = 'verified' THEN latest."settled_at"
|
|
73
|
+
ELSE connection."last_verified_at"
|
|
74
|
+
END,
|
|
75
|
+
"last_verified_url" = CASE
|
|
76
|
+
WHEN latest."state" = 'verified' THEN latest."verified_url"
|
|
77
|
+
ELSE connection."last_verified_url"
|
|
78
|
+
END,
|
|
79
|
+
"repair_code" = CASE
|
|
80
|
+
WHEN latest."state" = 'verified' THEN NULL
|
|
81
|
+
ELSE latest."failure_code"
|
|
82
|
+
END,
|
|
83
|
+
"last_checked_at" = latest."settled_at",
|
|
84
|
+
"health_sequence" = latest."health_sequence"
|
|
85
|
+
FROM latest
|
|
86
|
+
WHERE connection."id" = latest."site_auth_connection_id";
|
|
87
|
+
|
|
88
|
+
UPDATE "site_auth_connections"
|
|
89
|
+
SET
|
|
90
|
+
"next_check_at" = CASE
|
|
91
|
+
WHEN "status" = 'active' AND "health_policy"->>'mode' = 'maintained'
|
|
92
|
+
THEN CASE
|
|
93
|
+
WHEN "last_checked_at" IS NULL THEN now()
|
|
94
|
+
ELSE "last_checked_at"
|
|
95
|
+
+ ((("health_policy"->>'intervalSeconds')::bigint) * interval '1 second')
|
|
96
|
+
END
|
|
97
|
+
ELSE NULL
|
|
98
|
+
END,
|
|
99
|
+
"version" = "version" + 1,
|
|
100
|
+
"updated_at" = now();
|
|
101
|
+
|
|
102
|
+
ALTER TABLE "site_auth_connections"
|
|
103
|
+
ADD CONSTRAINT "site_auth_connections_health_check" CHECK (
|
|
104
|
+
(
|
|
105
|
+
(
|
|
106
|
+
"health_sequence" = 0
|
|
107
|
+
AND "last_checked_at" IS NULL
|
|
108
|
+
) OR (
|
|
109
|
+
"health_sequence" > 0
|
|
110
|
+
AND "last_checked_at" IS NOT NULL
|
|
111
|
+
)
|
|
112
|
+
) AND (
|
|
113
|
+
(
|
|
114
|
+
"status" = 'active'
|
|
115
|
+
AND "health_policy"->>'mode' = 'maintained'
|
|
116
|
+
AND "next_check_at" IS NOT NULL
|
|
117
|
+
) OR (
|
|
118
|
+
NOT ("status" = 'active' AND "health_policy"->>'mode' = 'maintained')
|
|
119
|
+
AND "next_check_at" IS NULL
|
|
120
|
+
)
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
CREATE INDEX "site_auth_connections_health_maintenance_idx"
|
|
125
|
+
ON "site_auth_connections" ("workspace_id", "next_check_at", "id");
|
|
126
|
+
|
|
127
|
+
REVOKE ALL ON SEQUENCE "auth_runs_health_sequence_seq" FROM PUBLIC;
|
|
128
|
+
DO $browser_auth_health_role_grants$
|
|
129
|
+
BEGIN
|
|
130
|
+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'opengeni_app') THEN
|
|
131
|
+
EXECUTE format(
|
|
132
|
+
'GRANT USAGE, SELECT ON SEQUENCE %I.auth_runs_health_sequence_seq TO opengeni_app',
|
|
133
|
+
current_schema()
|
|
134
|
+
);
|
|
135
|
+
END IF;
|
|
136
|
+
END
|
|
137
|
+
$browser_auth_health_role_grants$;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- Additive Pack installation evidence and component ownership. Old API/worker
|
|
3
|
+
-- binaries continue to use the original columns; new binaries freeze the
|
|
4
|
+
-- reviewed manifest and populate the normalized component ledger.
|
|
5
|
+
|
|
6
|
+
ALTER TABLE "pack_installations"
|
|
7
|
+
ADD COLUMN "version" integer NOT NULL DEFAULT 1,
|
|
8
|
+
ADD COLUMN "manifest_snapshot" jsonb,
|
|
9
|
+
ADD COLUMN "manifest_digest" text,
|
|
10
|
+
ADD COLUMN "selected_rig_id" uuid REFERENCES "rigs"("id") ON DELETE SET NULL,
|
|
11
|
+
ADD COLUMN "installed_by_subject_id" text;
|
|
12
|
+
|
|
13
|
+
ALTER TABLE "pack_installations"
|
|
14
|
+
ADD CONSTRAINT "pack_installations_version_chk" CHECK ("version" > 0) NOT VALID,
|
|
15
|
+
ADD CONSTRAINT "pack_installations_manifest_chk" CHECK (
|
|
16
|
+
("manifest_snapshot" IS NULL AND "manifest_digest" IS NULL)
|
|
17
|
+
OR (
|
|
18
|
+
jsonb_typeof("manifest_snapshot") = 'object'
|
|
19
|
+
AND octet_length(convert_to("manifest_snapshot"::text, 'UTF8')) <= 1048576
|
|
20
|
+
AND "manifest_digest" ~ '^[0-9a-f]{64}$'
|
|
21
|
+
)
|
|
22
|
+
) NOT VALID,
|
|
23
|
+
ADD CONSTRAINT "pack_installations_actor_chk" CHECK (
|
|
24
|
+
"installed_by_subject_id" IS NULL
|
|
25
|
+
OR length(btrim("installed_by_subject_id")) BETWEEN 1 AND 1024
|
|
26
|
+
) NOT VALID,
|
|
27
|
+
ADD CONSTRAINT "pack_installations_status_chk" CHECK (
|
|
28
|
+
"status" IN ('installing', 'active', 'needs_attention', 'disabled')
|
|
29
|
+
) NOT VALID;
|
|
30
|
+
|
|
31
|
+
ALTER TABLE "pack_installations"
|
|
32
|
+
VALIDATE CONSTRAINT "pack_installations_version_chk";
|
|
33
|
+
ALTER TABLE "pack_installations"
|
|
34
|
+
VALIDATE CONSTRAINT "pack_installations_manifest_chk";
|
|
35
|
+
ALTER TABLE "pack_installations"
|
|
36
|
+
VALIDATE CONSTRAINT "pack_installations_actor_chk";
|
|
37
|
+
ALTER TABLE "pack_installations"
|
|
38
|
+
VALIDATE CONSTRAINT "pack_installations_status_chk";
|
|
39
|
+
|
|
40
|
+
CREATE INDEX "pack_installations_workspace_rig_idx"
|
|
41
|
+
ON "pack_installations" ("workspace_id", "selected_rig_id")
|
|
42
|
+
WHERE "selected_rig_id" IS NOT NULL;
|
|
43
|
+
|
|
44
|
+
CREATE TABLE "pack_installation_components" (
|
|
45
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
46
|
+
"account_id" uuid NOT NULL REFERENCES "managed_accounts"("id") ON DELETE CASCADE,
|
|
47
|
+
"workspace_id" uuid NOT NULL REFERENCES "workspaces"("id") ON DELETE CASCADE,
|
|
48
|
+
"pack_installation_id" uuid NOT NULL REFERENCES "pack_installations"("id") ON DELETE CASCADE,
|
|
49
|
+
"component_key" text NOT NULL,
|
|
50
|
+
"kind" text NOT NULL,
|
|
51
|
+
"capability_id" text NOT NULL,
|
|
52
|
+
"resolved_id" text NOT NULL,
|
|
53
|
+
"digest" text NOT NULL,
|
|
54
|
+
"metadata" jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
55
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
56
|
+
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
57
|
+
CONSTRAINT "pack_installation_components_key_chk" CHECK (
|
|
58
|
+
length("component_key") BETWEEN 1 AND 128
|
|
59
|
+
AND "component_key" ~ '^[a-z0-9]([a-z0-9._/-]*[a-z0-9])?$'
|
|
60
|
+
),
|
|
61
|
+
CONSTRAINT "pack_installation_components_kind_chk" CHECK (
|
|
62
|
+
"kind" IN ('plugin', 'skill', 'integration', 'feature', 'inline_skill')
|
|
63
|
+
),
|
|
64
|
+
CONSTRAINT "pack_installation_components_identity_chk" CHECK (
|
|
65
|
+
length("capability_id") BETWEEN 1 AND 512
|
|
66
|
+
AND length("resolved_id") BETWEEN 1 AND 512
|
|
67
|
+
AND "capability_id" !~ '[[:cntrl:]]'
|
|
68
|
+
AND "resolved_id" !~ '[[:cntrl:]]'
|
|
69
|
+
AND "digest" ~ '^[0-9a-f]{64}$'
|
|
70
|
+
),
|
|
71
|
+
CONSTRAINT "pack_installation_components_metadata_chk" CHECK (
|
|
72
|
+
jsonb_typeof("metadata") = 'object'
|
|
73
|
+
AND octet_length(convert_to("metadata"::text, 'UTF8')) <= 131072
|
|
74
|
+
),
|
|
75
|
+
CONSTRAINT "pack_installation_components_pack_key_uq"
|
|
76
|
+
UNIQUE ("pack_installation_id", "component_key")
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
CREATE INDEX "pack_installation_components_workspace_capability_idx"
|
|
80
|
+
ON "pack_installation_components" ("workspace_id", "kind", "capability_id");
|
|
81
|
+
|
|
82
|
+
CREATE OR REPLACE FUNCTION pack_v2_validate_installation()
|
|
83
|
+
RETURNS trigger
|
|
84
|
+
LANGUAGE plpgsql
|
|
85
|
+
AS $$
|
|
86
|
+
BEGIN
|
|
87
|
+
IF NEW."manifest_snapshot" IS NOT NULL
|
|
88
|
+
AND NEW."manifest_snapshot" ->> 'id' IS DISTINCT FROM NEW."pack_id"
|
|
89
|
+
THEN
|
|
90
|
+
RAISE EXCEPTION 'pack installation snapshot id does not match pack_id'
|
|
91
|
+
USING ERRCODE = '23514';
|
|
92
|
+
END IF;
|
|
93
|
+
IF NEW."selected_rig_id" IS NOT NULL AND NOT EXISTS (
|
|
94
|
+
SELECT 1 FROM "rigs" r
|
|
95
|
+
WHERE r."id" = NEW."selected_rig_id"
|
|
96
|
+
AND r."account_id" = NEW."account_id"
|
|
97
|
+
AND r."workspace_id" = NEW."workspace_id"
|
|
98
|
+
) THEN
|
|
99
|
+
RAISE EXCEPTION 'pack installation Rig belongs to another tenant'
|
|
100
|
+
USING ERRCODE = '23514';
|
|
101
|
+
END IF;
|
|
102
|
+
RETURN NEW;
|
|
103
|
+
END;
|
|
104
|
+
$$;
|
|
105
|
+
|
|
106
|
+
CREATE TRIGGER pack_installations_v2_validate
|
|
107
|
+
BEFORE INSERT OR UPDATE ON "pack_installations"
|
|
108
|
+
FOR EACH ROW EXECUTE FUNCTION pack_v2_validate_installation();
|
|
109
|
+
|
|
110
|
+
CREATE OR REPLACE FUNCTION pack_v2_validate_component()
|
|
111
|
+
RETURNS trigger
|
|
112
|
+
LANGUAGE plpgsql
|
|
113
|
+
AS $$
|
|
114
|
+
BEGIN
|
|
115
|
+
IF NOT EXISTS (
|
|
116
|
+
SELECT 1 FROM "pack_installations" i
|
|
117
|
+
WHERE i."id" = NEW."pack_installation_id"
|
|
118
|
+
AND i."account_id" = NEW."account_id"
|
|
119
|
+
AND i."workspace_id" = NEW."workspace_id"
|
|
120
|
+
) THEN
|
|
121
|
+
RAISE EXCEPTION 'Pack component does not match its installation tenant'
|
|
122
|
+
USING ERRCODE = '23514';
|
|
123
|
+
END IF;
|
|
124
|
+
RETURN NEW;
|
|
125
|
+
END;
|
|
126
|
+
$$;
|
|
127
|
+
|
|
128
|
+
CREATE TRIGGER pack_installation_components_validate
|
|
129
|
+
BEFORE INSERT OR UPDATE ON "pack_installation_components"
|
|
130
|
+
FOR EACH ROW EXECUTE FUNCTION pack_v2_validate_component();
|
|
131
|
+
|
|
132
|
+
-- Harden the polymorphic owner identity added by 0202 now that first-class
|
|
133
|
+
-- Pack installation ids exist. Direct/migration owners remain textual, and
|
|
134
|
+
-- rolling legacy Pack owners remain valid when they are not UUID-shaped.
|
|
135
|
+
CREATE OR REPLACE FUNCTION capability_v2_validate_component_owner()
|
|
136
|
+
RETURNS trigger
|
|
137
|
+
LANGUAGE plpgsql
|
|
138
|
+
AS $$
|
|
139
|
+
BEGIN
|
|
140
|
+
IF NOT EXISTS (
|
|
141
|
+
SELECT 1 FROM "capability_facet_installations" i
|
|
142
|
+
WHERE i."id" = NEW."facet_installation_id"
|
|
143
|
+
AND i."account_id" = NEW."account_id"
|
|
144
|
+
AND i."workspace_id" = NEW."workspace_id"
|
|
145
|
+
) THEN
|
|
146
|
+
RAISE EXCEPTION 'component owner does not match its facet installation tenant'
|
|
147
|
+
USING ERRCODE = '23514';
|
|
148
|
+
END IF;
|
|
149
|
+
IF NEW."owner_kind" = 'plugin' THEN
|
|
150
|
+
IF NEW."owner_id" !~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$' THEN
|
|
151
|
+
RAISE EXCEPTION 'plugin component owner belongs to another tenant or does not exist'
|
|
152
|
+
USING ERRCODE = '23514';
|
|
153
|
+
ELSIF NOT EXISTS (
|
|
154
|
+
SELECT 1 FROM "capability_plugin_installations" p
|
|
155
|
+
WHERE p."id" = NEW."owner_id"::uuid
|
|
156
|
+
AND p."account_id" = NEW."account_id"
|
|
157
|
+
AND p."workspace_id" = NEW."workspace_id"
|
|
158
|
+
) THEN
|
|
159
|
+
RAISE EXCEPTION 'plugin component owner belongs to another tenant or does not exist'
|
|
160
|
+
USING ERRCODE = '23514';
|
|
161
|
+
END IF;
|
|
162
|
+
ELSIF NEW."owner_kind" = 'pack'
|
|
163
|
+
AND NEW."owner_id" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
|
|
164
|
+
THEN
|
|
165
|
+
IF NOT EXISTS (
|
|
166
|
+
SELECT 1 FROM "pack_installations" p
|
|
167
|
+
WHERE p."id" = NEW."owner_id"::uuid
|
|
168
|
+
AND p."account_id" = NEW."account_id"
|
|
169
|
+
AND p."workspace_id" = NEW."workspace_id"
|
|
170
|
+
) THEN
|
|
171
|
+
RAISE EXCEPTION 'Pack component owner belongs to another tenant or does not exist'
|
|
172
|
+
USING ERRCODE = '23514';
|
|
173
|
+
END IF;
|
|
174
|
+
END IF;
|
|
175
|
+
RETURN NEW;
|
|
176
|
+
END;
|
|
177
|
+
$$;
|
|
178
|
+
|
|
179
|
+
CREATE OR REPLACE FUNCTION capability_v2_validate_feature_binding_owner()
|
|
180
|
+
RETURNS trigger
|
|
181
|
+
LANGUAGE plpgsql
|
|
182
|
+
AS $$
|
|
183
|
+
BEGIN
|
|
184
|
+
IF NOT EXISTS (
|
|
185
|
+
SELECT 1 FROM "integration_feature_bindings" b
|
|
186
|
+
WHERE b."id" = NEW."binding_id"
|
|
187
|
+
AND b."account_id" = NEW."account_id"
|
|
188
|
+
AND b."workspace_id" = NEW."workspace_id"
|
|
189
|
+
) THEN
|
|
190
|
+
RAISE EXCEPTION 'feature binding owner does not match its binding tenant'
|
|
191
|
+
USING ERRCODE = '23514';
|
|
192
|
+
END IF;
|
|
193
|
+
IF NEW."owner_kind" = 'plugin' THEN
|
|
194
|
+
IF NEW."owner_id" !~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$' THEN
|
|
195
|
+
RAISE EXCEPTION 'plugin feature binding owner belongs to another tenant or does not exist'
|
|
196
|
+
USING ERRCODE = '23514';
|
|
197
|
+
ELSIF NOT EXISTS (
|
|
198
|
+
SELECT 1 FROM "capability_plugin_installations" p
|
|
199
|
+
WHERE p."id" = NEW."owner_id"::uuid
|
|
200
|
+
AND p."account_id" = NEW."account_id"
|
|
201
|
+
AND p."workspace_id" = NEW."workspace_id"
|
|
202
|
+
) THEN
|
|
203
|
+
RAISE EXCEPTION 'plugin feature binding owner belongs to another tenant or does not exist'
|
|
204
|
+
USING ERRCODE = '23514';
|
|
205
|
+
END IF;
|
|
206
|
+
ELSIF NEW."owner_kind" = 'pack'
|
|
207
|
+
AND NEW."owner_id" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
|
|
208
|
+
THEN
|
|
209
|
+
IF NOT EXISTS (
|
|
210
|
+
SELECT 1 FROM "pack_installations" p
|
|
211
|
+
WHERE p."id" = NEW."owner_id"::uuid
|
|
212
|
+
AND p."account_id" = NEW."account_id"
|
|
213
|
+
AND p."workspace_id" = NEW."workspace_id"
|
|
214
|
+
) THEN
|
|
215
|
+
RAISE EXCEPTION 'Pack feature binding owner belongs to another tenant or does not exist'
|
|
216
|
+
USING ERRCODE = '23514';
|
|
217
|
+
END IF;
|
|
218
|
+
END IF;
|
|
219
|
+
RETURN NEW;
|
|
220
|
+
END;
|
|
221
|
+
$$;
|
|
222
|
+
|
|
223
|
+
ALTER TABLE "pack_installation_components" ENABLE ROW LEVEL SECURITY;
|
|
224
|
+
ALTER TABLE "pack_installation_components" FORCE ROW LEVEL SECURITY;
|
|
225
|
+
|
|
226
|
+
CREATE POLICY workspace_isolation ON "pack_installation_components"
|
|
227
|
+
USING (opengeni_private.workspace_rls_visible(account_id, workspace_id))
|
|
228
|
+
WITH CHECK (opengeni_private.workspace_rls_visible(account_id, workspace_id));
|
|
229
|
+
|
|
230
|
+
DO $$
|
|
231
|
+
BEGIN
|
|
232
|
+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'opengeni_app') THEN
|
|
233
|
+
GRANT SELECT, INSERT, UPDATE, DELETE ON "pack_installation_components" TO opengeni_app;
|
|
234
|
+
END IF;
|
|
235
|
+
END $$;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- Shared capability and Integration definitions are globally readable catalog
|
|
3
|
+
-- data, not tenant lifecycle rows. Revoke ordinary runtime deletion authority
|
|
4
|
+
-- without narrowing the installation, binding, owner, or operation lifecycle.
|
|
5
|
+
|
|
6
|
+
DO $$
|
|
7
|
+
BEGIN
|
|
8
|
+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'opengeni_app') THEN
|
|
9
|
+
REVOKE DELETE ON
|
|
10
|
+
"capability_plugins",
|
|
11
|
+
"capability_plugin_versions",
|
|
12
|
+
"capability_facets",
|
|
13
|
+
"capability_integration_facets",
|
|
14
|
+
"capability_mcp_facets",
|
|
15
|
+
"capability_api_facets",
|
|
16
|
+
"capability_skill_facets",
|
|
17
|
+
"capability_skill_files",
|
|
18
|
+
"integration_spec_revisions",
|
|
19
|
+
"integration_tools",
|
|
20
|
+
"integration_feature_facets"
|
|
21
|
+
FROM opengeni_app;
|
|
22
|
+
|
|
23
|
+
GRANT SELECT, INSERT, UPDATE, DELETE ON
|
|
24
|
+
"capability_plugin_installations",
|
|
25
|
+
"capability_facet_installations",
|
|
26
|
+
"capability_component_owners",
|
|
27
|
+
"integration_feature_bindings",
|
|
28
|
+
"integration_feature_binding_owners",
|
|
29
|
+
"capability_operations"
|
|
30
|
+
TO opengeni_app;
|
|
31
|
+
END IF;
|
|
32
|
+
END $$;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
-- deployment-mode: maintenance
|
|
2
|
+
-- Extend the durable interaction-operation journal with provider-managed
|
|
3
|
+
-- browser authentication. No rows are rewritten and no authority is exposed.
|
|
4
|
+
SET LOCAL lock_timeout = '5s';
|
|
5
|
+
SET LOCAL statement_timeout = '30s';
|
|
6
|
+
|
|
7
|
+
ALTER TABLE "interaction_resource_operations"
|
|
8
|
+
DROP CONSTRAINT "interaction_resource_operations_kind_check";
|
|
9
|
+
|
|
10
|
+
ALTER TABLE "interaction_resource_operations"
|
|
11
|
+
ADD CONSTRAINT "interaction_resource_operations_kind_check"
|
|
12
|
+
CHECK ("kind" IN (
|
|
13
|
+
'create',
|
|
14
|
+
'update',
|
|
15
|
+
'start',
|
|
16
|
+
'report',
|
|
17
|
+
'protected_fill',
|
|
18
|
+
'external_auth',
|
|
19
|
+
'verify',
|
|
20
|
+
'resolve',
|
|
21
|
+
'save'
|
|
22
|
+
));
|