@opengeni/db 0.36.1 → 3.1.0-canary.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 +7 -0
- package/dist/automations.d.ts +154 -0
- package/dist/canonical-human-identities.js +3 -3
- package/dist/capability-integrations.d.ts +13 -0
- package/dist/child-lifecycle-notices.d.ts +68 -0
- package/dist/{chunk-GYO7ED2Q.js → chunk-EULAN2NP.js} +2 -2
- package/dist/{chunk-VTPRIXKG.js → chunk-NJVZPWXY.js} +3 -3
- package/dist/{chunk-HSOWSYOX.js → chunk-NMUBV7Z5.js} +19 -11
- package/dist/chunk-NMUBV7Z5.js.map +1 -0
- package/dist/chunk-OF5OBB76.js +4457 -0
- package/dist/chunk-OF5OBB76.js.map +1 -0
- package/dist/{chunk-5KTIEDX7.js → chunk-PR2WMLOQ.js} +7714 -4443
- package/dist/chunk-PR2WMLOQ.js.map +1 -0
- package/dist/{chunk-Z7VYMNPZ.js → chunk-SCPUJS53.js} +41 -4
- package/dist/chunk-SCPUJS53.js.map +1 -0
- package/dist/{chunk-SK7YYHBI.js → chunk-SIBYBA2D.js} +46 -1
- package/dist/chunk-SIBYBA2D.js.map +1 -0
- package/dist/chunk-TIKF3KTI.js +383 -0
- package/dist/chunk-TIKF3KTI.js.map +1 -0
- package/dist/chunk-ZZ5LJEFX.js +516 -0
- package/dist/chunk-ZZ5LJEFX.js.map +1 -0
- package/dist/codemode-operations.d.ts +1 -6
- package/dist/company-brain-context-selection-schema.d.ts +705 -0
- package/dist/company-brain-context-selection.d.ts +94 -0
- package/dist/company-brain-governed-writes.d.ts +24 -0
- package/dist/company-brain.d.ts +55 -0
- package/dist/company-profile-agent-admin.d.ts +15 -0
- package/dist/company-profile-schema.d.ts +619 -2
- package/dist/company-profile.d.ts +9 -4
- package/dist/connection-authority.d.ts +95 -0
- package/dist/connection-scopes.d.ts +8 -0
- package/dist/connection-tenancy-backfill.d.ts +41 -0
- package/dist/connection-token-resolver.d.ts +30 -1
- package/dist/database.d.ts +19 -0
- package/dist/editable-artifact-durable-export.d.ts +10 -0
- package/dist/editable-artifact-durable-export.js +18 -3
- package/dist/editable-artifact-durable-export.js.map +1 -1
- package/dist/editable-artifacts.d.ts +2 -2
- package/dist/editable-artifacts.js +3 -3
- package/dist/governed-learning-activation-schema.d.ts +984 -0
- package/dist/governed-learning-activation.d.ts +98 -0
- package/dist/governed-learning-evaluator-schema.d.ts +633 -0
- package/dist/governed-learning-evaluator.d.ts +28 -0
- package/dist/index.d.ts +1633 -87
- package/dist/index.js +22004 -8109
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +18 -0
- package/dist/integration-bindings.d.ts +1 -0
- package/dist/integration-facets.d.ts +30 -0
- package/dist/interaction-placement-loss.d.ts +22 -0
- package/dist/knowledge-source-sync-schema.d.ts +730 -0
- package/dist/knowledge-source-sync.d.ts +60 -0
- package/dist/managed-human-provisioning.d.ts +25 -0
- package/dist/memory-domain.d.ts +3 -3
- package/dist/migrate.d.ts +11 -1
- package/dist/migrate.js +1 -1
- package/dist/new-session-drafts.d.ts +43 -5
- package/dist/organization-membership-backfill.d.ts +174 -0
- package/dist/organization-membership-lifecycle.d.ts +162 -0
- package/dist/pr-review.d.ts +107 -0
- package/dist/preference-registry-schema.d.ts +2 -0
- package/dist/preference-registry.d.ts +2 -0
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +23 -9
- package/dist/schema.d.ts +24925 -13697
- package/dist/schema.js +103 -1
- package/dist/scoped-knowledge-schema.d.ts +52 -1
- package/dist/session-background-commands.d.ts +125 -0
- package/dist/session-background-commands.js +34 -0
- package/dist/session-background-commands.js.map +1 -0
- package/dist/session-control.d.ts +156 -3
- package/dist/session-goal-pacing.d.ts +68 -0
- package/dist/session-queue-commands.d.ts +42 -5
- package/dist/session-realtime-ledger.d.ts +3 -0
- package/dist/session-tenancy.d.ts +71 -1
- package/dist/session-tenancy.js +25 -3
- package/dist/session-tool-call-settlement.d.ts +9 -4
- package/dist/slack-routing-personal-workspace.d.ts +23 -0
- package/dist/slack-routing.d.ts +153 -0
- package/dist/slack-task-policy-schema.d.ts +34 -0
- package/dist/slack-task-policy.d.ts +8 -0
- package/dist/slack-user-link-access.d.ts +1 -0
- package/dist/task-notes-schema.d.ts +594 -0
- package/dist/task-notes.d.ts +39 -0
- package/dist/turn-initiator.d.ts +2 -0
- package/dist/user-resource-authority.d.ts +109 -0
- package/dist/video-generation.js +3 -3
- package/dist/workspace-authority.d.ts +81 -0
- package/dist/workspace-instruction-policies-schema.d.ts +279 -0
- package/dist/workspace-instruction-policies.d.ts +62 -0
- package/dist/workspace-learning-policy.d.ts +1 -0
- package/dist/workspace-membership-permissions.d.ts +2 -0
- package/drizzle/0240_enrollment_connection_authority.sql +39 -0
- package/drizzle/0240_model_context_user_messages.sql +204 -0
- package/drizzle/0241_atomic_personal_resource_delegation.sql +1000 -0
- package/drizzle/0241_enrollment_agent_runtime.sql +70 -0
- package/drizzle/0243_google_drive_object_acl_authority.sql +554 -0
- package/drizzle/0244_slack_app_home_refresh_queue.sql +120 -0
- package/drizzle/0245_model_context_contribution_facts.sql +88 -0
- package/drizzle/0246_integration_personal_instance_authority.sql +70 -0
- package/drizzle/0247_terraform_stacks_provenance_repair.sql +428 -0
- package/drizzle/0248_terraform_stacks_component_resolution_fence.sql +83 -0
- package/drizzle/0249_personal_resource_delegation_authority_correction.sql +662 -0
- package/drizzle/0250_direct_retained_process_owner_liveness.sql +199 -0
- package/drizzle/0251_connected_machine_operation_policy.sql +45 -0
- package/drizzle/0252_scheduled_personal_resource_delegation.sql +1867 -0
- package/drizzle/0253_common_user_resource_authority_lifecycle.sql +1555 -0
- package/drizzle/0254_scoped_variable_set_authority.sql +1255 -0
- package/drizzle/0255_company_brain_governed_write_proposals.sql +524 -0
- package/drizzle/0256_connection_authority_delegation.sql +703 -0
- package/drizzle/0257_goal_revision_decisions_and_root_constraints.sql +436 -0
- package/drizzle/0258_three_scope_document_knowledge_authority.sql +1273 -0
- package/drizzle/0259_company_brain_context_selection_receipts.sql +869 -0
- package/drizzle/0260_task_note_knowledge_promotion.sql +820 -0
- package/drizzle/0261_preference_knowledge_proposal_actor_binding.sql +471 -0
- package/drizzle/0262_scoped_connected_machines_and_rigs.sql +1700 -0
- package/drizzle/0263_organization_membership_lifecycle.sql +3284 -0
- package/drizzle/0264_connection_authority_runtime_activation.sql +1084 -0
- package/drizzle/0266_company_brain_context_receipt_inspection.sql +156 -0
- package/drizzle/0268_governed_learning_decision_receipts.sql +825 -0
- package/drizzle/0269_governed_learning_activation_controller.sql +1874 -0
- package/drizzle/0270_governed_learning_history_inspection.sql +170 -0
- package/drizzle/0271_company_brain_retrieval_only_default.sql +524 -0
- package/drizzle/0272_human_confirmed_learning_activation.sql +591 -0
- package/drizzle/0273_scheduled_variable_set_materialization.sql +268 -0
- package/drizzle/0274_human_confirmed_knowledge_review.sql +310 -0
- package/drizzle/0275_scheduled_connection_authority.sql +5527 -0
- package/drizzle/0276_onboarding_proposal_initiating_human_guc.sql +198 -0
- package/drizzle/0277_workspace_writer_authority_attribution.sql +393 -0
- package/drizzle/0278_workspace_membership_removal_fencing.sql +1174 -0
- package/drizzle/0279_workspace_connection_use_lane.sql +343 -0
- package/drizzle/0280_connection_and_variable_set_audit_attribution.sql +773 -0
- package/drizzle/0281_viewer_holder_authority_claims.sql +52 -0
- package/drizzle/0282_variable_set_session_attach_attribution.sql +178 -0
- package/drizzle/0283_editable_spreadsheet_authored_state.sql +82 -0
- package/drizzle/0284_truthful_human_confirmed_review_reason.sql +930 -0
- package/drizzle/0285_organization_tenancy_inventory.sql +329 -0
- package/drizzle/0286_widen_task_note_expiry_ceiling.sql +391 -0
- package/drizzle/0287_open_suffix_pending_tool_calls.sql +18 -0
- package/drizzle/0288_attached_browser_reenrollment.sql +64 -0
- package/drizzle/0289_session_composer_policy_authority.sql +597 -0
- package/drizzle/0290_organization_membership_backfill.sql +268 -0
- package/drizzle/0291_resource_authority_classification_assertion.sql +371 -0
- package/drizzle/0292_truthful_tenancy_inventory_counters.sql +291 -0
- package/drizzle/0293_confirm_time_rule_rebaseline.sql +615 -0
- package/drizzle/0294_preference_activation_authority.sql +237 -0
- package/drizzle/0295_retire_legacy_standing_memory_mode.sql +476 -0
- package/drizzle/0296_force_rls_backfill_noop_repair.sql +215 -0
- package/drizzle/0297_session_ownership_classification_and_backfill.sql +752 -0
- package/drizzle/0298_organization_tenancy_parity.sql +609 -0
- package/drizzle/0299_organization_membership_lock_order.sql +291 -0
- package/drizzle/0300_tenancy_backfill_ledger.sql +459 -0
- package/drizzle/0301_session_snapshot_and_pin_visibility.sql +181 -0
- package/drizzle/0302_personal_workspace_session_ownership.sql +303 -0
- package/drizzle/0303_session_tenancy_product_activation.sql +919 -0
- package/drizzle/0304_personal_workspace_private_session_reads.sql +97 -0
- package/drizzle/0305_personal_resource_grant_management.sql +584 -0
- package/drizzle/0306_atomic_personal_resource_attachments.sql +1374 -0
- package/drizzle/0307_session_attention_state.sql +51 -0
- package/drizzle/0308_session_archives.sql +35 -0
- package/drizzle/0309_channel_project_pins.sql +6 -0
- package/drizzle/0310_channel_project_order.sql +27 -0
- package/drizzle/0311_company_scope_and_private_session_create.sql +656 -0
- package/drizzle/0312_quiescent_session_tree_deletion.sql +39 -0
- package/drizzle/0313_private_child_session_authority.sql +365 -0
- package/drizzle/0314_unregistered_organization_invitations.sql +606 -0
- package/drizzle/0315_personal_github_repository_selection.sql +624 -0
- package/drizzle/0316_human_confirmed_activation_resumed_generation.sql +869 -0
- package/drizzle/0317_session_goal_continuation_hold.sql +64 -0
- package/drizzle/0318_session_turn_startup_milestones.sql +115 -0
- package/drizzle/0319_event_triggered_automations.sql +254 -0
- package/drizzle/0320_pr_review_pack.sql +113 -0
- package/drizzle/0321_slack_bot_environment_display_name.sql +15 -0
- package/drizzle/0322_session_turns_unclaimed_prompt_trigger_index.sql +5 -0
- package/drizzle/0323_organization_private_session_enablement.sql +489 -0
- package/drizzle/0324_human_confirmed_company_profile_agent_admin.sql +856 -0
- package/drizzle/0325_child_lifecycle_notices.sql +44 -0
- package/drizzle/0326_interaction_operation_error_codes.sql +62 -0
- package/drizzle/0327_slack_first_task_hint.sql +29 -0
- package/drizzle/0328_session_background_commands.sql +590 -0
- package/drizzle/0329_slack_orchestration_delivery_events.sql +91 -0
- package/drizzle/0330_api_key_descriptions.sql +20 -0
- package/drizzle/0331_managed_organization_creation.sql +163 -0
- package/drizzle/0332_organization_shared_workspace_control_plane.sql +539 -0
- package/drizzle/0333_session_turn_prompt_routing.sql +45 -0
- package/drizzle/0334_connected_machine_workspace_root.sql +99 -0
- package/drizzle/0335_slack_workspace_routing.sql +460 -0
- package/drizzle/0336_atomic_session_fork_visibility.sql +667 -0
- package/drizzle/0337_slack_routed_action_handles.sql +189 -0
- package/drizzle/0338_atomic_connected_machine_attachments.sql +410 -0
- package/drizzle/0339_document_authority_reclassification.sql +1153 -0
- package/drizzle/0340_tenancy_backfill_activation_evidence.sql +1347 -0
- package/drizzle/0341_slack_routing_probe_organization_fence.sql +109 -0
- package/package.json +10 -6
- package/src/attached-browser-devices.ts +233 -5
- package/src/automations.ts +911 -0
- package/src/browser-sessions.ts +10 -0
- package/src/capability-integrations.ts +175 -1
- package/src/child-lifecycle-notices.ts +241 -0
- package/src/codemode-operations.ts +1 -35
- package/src/company-brain-context-selection-schema.ts +100 -0
- package/src/company-brain-context-selection.ts +359 -0
- package/src/company-brain-governed-writes.ts +1170 -0
- package/src/company-brain.ts +309 -0
- package/src/company-profile-agent-admin.ts +225 -0
- package/src/company-profile-schema.ts +121 -1
- package/src/company-profile.ts +21 -0
- package/src/computer-sessions.ts +10 -1
- package/src/connection-authority.ts +290 -0
- package/src/connection-scopes.ts +20 -0
- package/src/connection-tenancy-backfill.ts +81 -0
- package/src/connection-token-resolver.ts +263 -31
- package/src/database.ts +75 -2
- package/src/editable-artifact-durable-export.ts +27 -0
- package/src/editable-artifacts-schema.ts +10 -5
- package/src/editable-artifacts.ts +21 -11
- package/src/governed-learning-activation-schema.ts +121 -0
- package/src/governed-learning-activation.ts +588 -0
- package/src/governed-learning-evaluator-schema.ts +72 -0
- package/src/governed-learning-evaluator.ts +217 -0
- package/src/index.ts +12001 -1699
- package/src/insights.ts +107 -0
- package/src/integration-bindings.ts +88 -6
- package/src/integration-facets.ts +287 -84
- package/src/interaction-placement-loss.ts +234 -0
- package/src/knowledge-source-sync-schema.ts +83 -0
- package/src/knowledge-source-sync.ts +530 -0
- package/src/managed-human-provisioning.ts +116 -0
- package/src/memory-domain.ts +27 -32
- package/src/migrate.ts +77 -1
- package/src/new-session-drafts.ts +229 -35
- package/src/organization-membership-backfill.ts +735 -0
- package/src/organization-membership-lifecycle.ts +985 -0
- package/src/pr-review.ts +890 -0
- package/src/preference-registry.ts +31 -1
- package/src/provision-roles.ts +931 -24
- package/src/runtime-posture-cli.ts +2 -0
- package/src/runtime-posture.ts +1315 -52
- package/src/schema.ts +3336 -438
- package/src/scoped-knowledge-schema.ts +16 -8
- package/src/scoped-knowledge.ts +1 -1
- package/src/session-background-commands.ts +759 -0
- package/src/session-control.ts +640 -74
- package/src/session-goal-pacing.ts +126 -0
- package/src/session-queue-commands.ts +450 -98
- package/src/session-realtime-context.ts +19 -3
- package/src/session-realtime-ledger.ts +75 -12
- package/src/session-realtime-mirror.ts +1 -1
- package/src/session-tenancy.ts +403 -49
- package/src/session-tool-call-settlement.ts +38 -29
- package/src/slack-routing-personal-workspace.ts +67 -0
- package/src/slack-routing.ts +469 -0
- package/src/slack-task-policy-schema.ts +5 -0
- package/src/slack-task-policy.ts +18 -0
- package/src/slack-user-link-access.ts +17 -1
- package/src/task-notes-schema.ts +74 -0
- package/src/task-notes.ts +124 -2
- package/src/turn-initiator.ts +8 -0
- package/src/user-resource-authority.ts +377 -0
- package/src/workspace-authority.ts +160 -0
- package/src/workspace-instruction-policies-schema.ts +53 -1
- package/src/workspace-instruction-policies.ts +528 -77
- package/src/workspace-learning-policy.ts +21 -5
- package/src/workspace-membership-permissions.ts +9 -0
- package/dist/chunk-5KTIEDX7.js.map +0 -1
- package/dist/chunk-FPVAD4CO.js +0 -117
- package/dist/chunk-FPVAD4CO.js.map +0 -1
- package/dist/chunk-HSOWSYOX.js.map +0 -1
- package/dist/chunk-SK7YYHBI.js.map +0 -1
- package/dist/chunk-VKLB2ZGI.js +0 -2389
- package/dist/chunk-VKLB2ZGI.js.map +0 -1
- package/dist/chunk-Z7VYMNPZ.js.map +0 -1
- /package/dist/{chunk-GYO7ED2Q.js.map → chunk-EULAN2NP.js.map} +0 -0
- /package/dist/{chunk-VTPRIXKG.js.map → chunk-NJVZPWXY.js.map} +0 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
-- deployment-mode: maintenance
|
|
2
|
+
-- Repair the reviewed Terraform Stacks provenance URL embedded by migration
|
|
3
|
+
-- 0233 without rewriting published migration history. The affected Skill
|
|
4
|
+
-- facet and Plugin version are immutable, so all opengeni_app writers must be
|
|
5
|
+
-- stopped while the two exact metadata fields and manifest digest are repaired.
|
|
6
|
+
|
|
7
|
+
SET LOCAL lock_timeout = '5s';
|
|
8
|
+
SET LOCAL statement_timeout = '10min';
|
|
9
|
+
|
|
10
|
+
DO $maintenance_preflight_guard$
|
|
11
|
+
BEGIN
|
|
12
|
+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'opengeni_app')
|
|
13
|
+
AND EXISTS (
|
|
14
|
+
SELECT 1
|
|
15
|
+
FROM pg_stat_activity
|
|
16
|
+
WHERE datname = current_database()
|
|
17
|
+
AND usename = 'opengeni_app'
|
|
18
|
+
AND pid <> pg_backend_pid()
|
|
19
|
+
)
|
|
20
|
+
THEN
|
|
21
|
+
RAISE EXCEPTION
|
|
22
|
+
'Terraform Stacks provenance repair requires all opengeni_app sessions to be stopped'
|
|
23
|
+
USING ERRCODE = '55000';
|
|
24
|
+
END IF;
|
|
25
|
+
END
|
|
26
|
+
$maintenance_preflight_guard$;
|
|
27
|
+
|
|
28
|
+
LOCK TABLE capability_plugins IN ACCESS EXCLUSIVE MODE;
|
|
29
|
+
LOCK TABLE capability_plugin_versions IN ACCESS EXCLUSIVE MODE;
|
|
30
|
+
LOCK TABLE capability_facets IN ACCESS EXCLUSIVE MODE;
|
|
31
|
+
LOCK TABLE capability_skill_facets IN ACCESS EXCLUSIVE MODE;
|
|
32
|
+
LOCK TABLE workspace_packs IN ACCESS EXCLUSIVE MODE;
|
|
33
|
+
LOCK TABLE pack_installations IN ACCESS EXCLUSIVE MODE;
|
|
34
|
+
LOCK TABLE pack_installation_components IN ACCESS EXCLUSIVE MODE;
|
|
35
|
+
|
|
36
|
+
CREATE OR REPLACE FUNCTION opengeni_private.terraform_stacks_provenance_rewrite_pack(value jsonb)
|
|
37
|
+
RETURNS jsonb
|
|
38
|
+
LANGUAGE plpgsql
|
|
39
|
+
IMMUTABLE
|
|
40
|
+
STRICT
|
|
41
|
+
PARALLEL SAFE
|
|
42
|
+
AS $rewrite_pack$
|
|
43
|
+
DECLARE
|
|
44
|
+
components jsonb;
|
|
45
|
+
BEGIN
|
|
46
|
+
IF NOT (value ? 'components') THEN
|
|
47
|
+
RETURN value;
|
|
48
|
+
END IF;
|
|
49
|
+
IF jsonb_typeof(value -> 'components') <> 'array' THEN
|
|
50
|
+
RAISE EXCEPTION 'Pack components must be an array' USING ERRCODE = '23514';
|
|
51
|
+
END IF;
|
|
52
|
+
SELECT COALESCE(
|
|
53
|
+
jsonb_agg(
|
|
54
|
+
CASE
|
|
55
|
+
WHEN component.value ->> 'kind' = 'plugin'
|
|
56
|
+
AND component.value ->> 'pluginKey' = 'skill/library/terraform-stacks'
|
|
57
|
+
AND component.value ->> 'version' = '0.0.1'
|
|
58
|
+
AND component.value ->> 'manifestDigest' = 'd484ccc1279954e5dbcdd9b8b57bc21e6a0fa47d38dc11854ffcf8e61289e883'
|
|
59
|
+
THEN jsonb_set(
|
|
60
|
+
component.value,
|
|
61
|
+
'{manifestDigest}',
|
|
62
|
+
to_jsonb('3a58c98b725573b8fd524555b7ed9dbff04df4df9f8fad44e2e850bac3824809'::text),
|
|
63
|
+
false
|
|
64
|
+
)
|
|
65
|
+
ELSE component.value
|
|
66
|
+
END
|
|
67
|
+
ORDER BY component.ordinality
|
|
68
|
+
),
|
|
69
|
+
'[]'::jsonb
|
|
70
|
+
)
|
|
71
|
+
INTO components
|
|
72
|
+
FROM jsonb_array_elements(value -> 'components') WITH ORDINALITY AS component(value, ordinality);
|
|
73
|
+
RETURN jsonb_set(value, '{components}', components, false);
|
|
74
|
+
END
|
|
75
|
+
$rewrite_pack$;
|
|
76
|
+
|
|
77
|
+
-- Runtime stableJson() sorts keys with the default en-US Intl comparator and
|
|
78
|
+
-- preserves the input order of comparator-equal keys. jsonb_each ordinality is
|
|
79
|
+
-- the stable order emitted when the stored snapshot is read back into runtime.
|
|
80
|
+
-- The exact old-digest precondition below remains authoritative: an ICU/version
|
|
81
|
+
-- or scalar-rendering mismatch aborts before any row is changed.
|
|
82
|
+
CREATE COLLATION opengeni_private.terraform_stacks_provenance_js_en_us (
|
|
83
|
+
provider = icu,
|
|
84
|
+
locale = 'en-US',
|
|
85
|
+
deterministic = false
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
CREATE OR REPLACE FUNCTION opengeni_private.terraform_stacks_provenance_canonical_json(value jsonb)
|
|
89
|
+
RETURNS text
|
|
90
|
+
LANGUAGE plpgsql
|
|
91
|
+
IMMUTABLE
|
|
92
|
+
STRICT
|
|
93
|
+
PARALLEL SAFE
|
|
94
|
+
AS $canonical_json$
|
|
95
|
+
DECLARE
|
|
96
|
+
rendered text;
|
|
97
|
+
BEGIN
|
|
98
|
+
CASE jsonb_typeof(value)
|
|
99
|
+
WHEN 'object' THEN
|
|
100
|
+
SELECT COALESCE(
|
|
101
|
+
'{' || string_agg(
|
|
102
|
+
to_jsonb(entry.key)::text || ':' ||
|
|
103
|
+
opengeni_private.terraform_stacks_provenance_canonical_json(entry.value),
|
|
104
|
+
',' ORDER BY
|
|
105
|
+
entry.key COLLATE opengeni_private.terraform_stacks_provenance_js_en_us,
|
|
106
|
+
entry.ordinality
|
|
107
|
+
) || '}',
|
|
108
|
+
'{}'
|
|
109
|
+
)
|
|
110
|
+
INTO rendered
|
|
111
|
+
FROM jsonb_each(value) WITH ORDINALITY AS entry(key, value, ordinality);
|
|
112
|
+
RETURN rendered;
|
|
113
|
+
WHEN 'array' THEN
|
|
114
|
+
SELECT COALESCE(
|
|
115
|
+
'[' || string_agg(
|
|
116
|
+
opengeni_private.terraform_stacks_provenance_canonical_json(entry.value),
|
|
117
|
+
',' ORDER BY entry.ordinality
|
|
118
|
+
) || ']',
|
|
119
|
+
'[]'
|
|
120
|
+
)
|
|
121
|
+
INTO rendered
|
|
122
|
+
FROM jsonb_array_elements(value) WITH ORDINALITY AS entry(value, ordinality);
|
|
123
|
+
RETURN rendered;
|
|
124
|
+
ELSE
|
|
125
|
+
RETURN value::text;
|
|
126
|
+
END CASE;
|
|
127
|
+
END
|
|
128
|
+
$canonical_json$;
|
|
129
|
+
|
|
130
|
+
DO $provenance_precondition$
|
|
131
|
+
DECLARE
|
|
132
|
+
old_url constant text := 'https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/code-generation/skills/terraform-stacks';
|
|
133
|
+
new_url constant text := 'https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/module-generation/skills/terraform-stacks';
|
|
134
|
+
old_digest constant text := 'd484ccc1279954e5dbcdd9b8b57bc21e6a0fa47d38dc11854ffcf8e61289e883';
|
|
135
|
+
new_digest constant text := '3a58c98b725573b8fd524555b7ed9dbff04df4df9f8fad44e2e850bac3824809';
|
|
136
|
+
old_manifest constant jsonb := '{"schemaVersion":1,"kind":"skill","source":"library","sourceUrl":"https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/code-generation/skills/terraform-stacks","repositoryUrl":"https://github.com/hashicorp/agent-skills","version":"0.0.1","sourceCommit":"de4323afdfbc30d1387f287b55062fa8d82b62e8","sourcePath":"terraform-stacks","sourceProvenance":"Vendored from hashicorp/agent-skills; reviewed immutable opt-in entry.","contentSha256":"0a6244ecddf1cce0357db41b41b3b20a1bfa71f331092ebc8bbd15e649733d35","fileCount":7,"totalBytes":104793}'::jsonb;
|
|
137
|
+
new_manifest constant jsonb := '{"schemaVersion":1,"kind":"skill","source":"library","sourceUrl":"https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/module-generation/skills/terraform-stacks","repositoryUrl":"https://github.com/hashicorp/agent-skills","version":"0.0.1","sourceCommit":"de4323afdfbc30d1387f287b55062fa8d82b62e8","sourcePath":"terraform-stacks","sourceProvenance":"Vendored from hashicorp/agent-skills; reviewed immutable opt-in entry.","contentSha256":"0a6244ecddf1cce0357db41b41b3b20a1bfa71f331092ebc8bbd15e649733d35","fileCount":7,"totalBytes":104793}'::jsonb;
|
|
138
|
+
BEGIN
|
|
139
|
+
IF EXISTS (
|
|
140
|
+
SELECT 1
|
|
141
|
+
FROM capability_skill_facets skill
|
|
142
|
+
JOIN capability_facets facet ON facet.id = skill.facet_id
|
|
143
|
+
JOIN capability_plugin_versions version ON version.id = facet.plugin_version_id
|
|
144
|
+
JOIN capability_plugins plugin ON plugin.id = version.plugin_id
|
|
145
|
+
WHERE skill.capability_id = 'skill:terraform-stacks'
|
|
146
|
+
AND (
|
|
147
|
+
plugin.plugin_key <> 'skill/library/terraform-stacks'
|
|
148
|
+
OR version.version <> '0.0.1'
|
|
149
|
+
OR facet.facet_key <> 'skill'
|
|
150
|
+
OR facet.kind <> 'skill'
|
|
151
|
+
OR skill.name <> 'terraform-stacks'
|
|
152
|
+
OR skill.description <>
|
|
153
|
+
'Create, modify, validate, and troubleshoot Terraform Stack component and deployment configurations.'
|
|
154
|
+
OR skill.source_url NOT IN (old_url, new_url)
|
|
155
|
+
OR skill.source_commit <> 'de4323afdfbc30d1387f287b55062fa8d82b62e8'
|
|
156
|
+
OR skill.source_path <> 'terraform-stacks'
|
|
157
|
+
OR skill.content_sha256 <> '0a6244ecddf1cce0357db41b41b3b20a1bfa71f331092ebc8bbd15e649733d35'
|
|
158
|
+
OR skill.file_count <> 7
|
|
159
|
+
OR skill.total_bytes <> 104793
|
|
160
|
+
OR skill.license IS DISTINCT FROM 'MPL-2.0'
|
|
161
|
+
OR NOT (
|
|
162
|
+
(version.manifest = old_manifest AND version.manifest_digest = old_digest)
|
|
163
|
+
OR (version.manifest = new_manifest AND version.manifest_digest = new_digest)
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
) THEN
|
|
167
|
+
RAISE EXCEPTION 'Terraform Stacks provenance repair found unexpected immutable state'
|
|
168
|
+
USING ERRCODE = '23514';
|
|
169
|
+
END IF;
|
|
170
|
+
|
|
171
|
+
IF EXISTS (
|
|
172
|
+
SELECT 1
|
|
173
|
+
FROM workspace_packs pack,
|
|
174
|
+
LATERAL jsonb_array_elements(COALESCE(pack.manifest -> 'components', '[]'::jsonb)) component
|
|
175
|
+
WHERE component ->> 'pluginKey' = 'skill/library/terraform-stacks'
|
|
176
|
+
AND component ->> 'version' = '0.0.1'
|
|
177
|
+
AND (
|
|
178
|
+
component ->> 'kind' IS DISTINCT FROM 'plugin'
|
|
179
|
+
OR (
|
|
180
|
+
component ->> 'manifestDigest' IS DISTINCT FROM old_digest
|
|
181
|
+
AND component ->> 'manifestDigest' IS DISTINCT FROM new_digest
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
) OR EXISTS (
|
|
185
|
+
SELECT 1
|
|
186
|
+
FROM pack_installations installation,
|
|
187
|
+
LATERAL jsonb_array_elements(
|
|
188
|
+
COALESCE(installation.manifest_snapshot -> 'components', '[]'::jsonb)
|
|
189
|
+
) component
|
|
190
|
+
WHERE installation.manifest_snapshot IS NOT NULL
|
|
191
|
+
AND component ->> 'pluginKey' = 'skill/library/terraform-stacks'
|
|
192
|
+
AND component ->> 'version' = '0.0.1'
|
|
193
|
+
AND (
|
|
194
|
+
component ->> 'kind' IS DISTINCT FROM 'plugin'
|
|
195
|
+
OR (
|
|
196
|
+
component ->> 'manifestDigest' IS DISTINCT FROM old_digest
|
|
197
|
+
AND component ->> 'manifestDigest' IS DISTINCT FROM new_digest
|
|
198
|
+
)
|
|
199
|
+
)
|
|
200
|
+
) OR EXISTS (
|
|
201
|
+
SELECT 1
|
|
202
|
+
FROM pack_installation_components component
|
|
203
|
+
WHERE (
|
|
204
|
+
component.capability_id = 'plugin:skill/library/terraform-stacks'
|
|
205
|
+
OR component.metadata ->> 'pluginKey' = 'skill/library/terraform-stacks'
|
|
206
|
+
OR EXISTS (
|
|
207
|
+
SELECT 1
|
|
208
|
+
FROM capability_plugin_installations installation
|
|
209
|
+
JOIN capability_plugins plugin ON plugin.id = installation.plugin_id
|
|
210
|
+
WHERE installation.id::text = component.resolved_id
|
|
211
|
+
AND plugin.plugin_key = 'skill/library/terraform-stacks'
|
|
212
|
+
)
|
|
213
|
+
)
|
|
214
|
+
AND (
|
|
215
|
+
component.kind IS DISTINCT FROM 'plugin'
|
|
216
|
+
OR component.capability_id IS DISTINCT FROM
|
|
217
|
+
'plugin:skill/library/terraform-stacks'
|
|
218
|
+
OR component.metadata ->> 'pluginKey' IS DISTINCT FROM
|
|
219
|
+
'skill/library/terraform-stacks'
|
|
220
|
+
OR component.metadata ->> 'version' IS DISTINCT FROM '0.0.1'
|
|
221
|
+
OR (
|
|
222
|
+
component.digest IS DISTINCT FROM old_digest
|
|
223
|
+
AND component.digest IS DISTINCT FROM new_digest
|
|
224
|
+
)
|
|
225
|
+
)
|
|
226
|
+
) THEN
|
|
227
|
+
RAISE EXCEPTION 'Terraform Stacks provenance repair found unexpected Pack state'
|
|
228
|
+
USING ERRCODE = '23514';
|
|
229
|
+
END IF;
|
|
230
|
+
END
|
|
231
|
+
$provenance_precondition$;
|
|
232
|
+
|
|
233
|
+
ALTER TABLE capability_skill_facets
|
|
234
|
+
DISABLE TRIGGER capability_skill_facets_immutable;
|
|
235
|
+
ALTER TABLE capability_plugin_versions
|
|
236
|
+
DISABLE TRIGGER capability_plugin_versions_restrict_update;
|
|
237
|
+
|
|
238
|
+
UPDATE capability_skill_facets skill
|
|
239
|
+
SET source_url = 'https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/module-generation/skills/terraform-stacks'
|
|
240
|
+
FROM capability_facets facet
|
|
241
|
+
JOIN capability_plugin_versions version ON version.id = facet.plugin_version_id
|
|
242
|
+
JOIN capability_plugins plugin ON plugin.id = version.plugin_id
|
|
243
|
+
WHERE skill.facet_id = facet.id
|
|
244
|
+
AND skill.capability_id = 'skill:terraform-stacks'
|
|
245
|
+
AND plugin.plugin_key = 'skill/library/terraform-stacks'
|
|
246
|
+
AND version.version = '0.0.1'
|
|
247
|
+
AND skill.source_url = 'https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/code-generation/skills/terraform-stacks';
|
|
248
|
+
|
|
249
|
+
UPDATE capability_plugin_versions version
|
|
250
|
+
SET manifest = '{"schemaVersion":1,"kind":"skill","source":"library","sourceUrl":"https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/module-generation/skills/terraform-stacks","repositoryUrl":"https://github.com/hashicorp/agent-skills","version":"0.0.1","sourceCommit":"de4323afdfbc30d1387f287b55062fa8d82b62e8","sourcePath":"terraform-stacks","sourceProvenance":"Vendored from hashicorp/agent-skills; reviewed immutable opt-in entry.","contentSha256":"0a6244ecddf1cce0357db41b41b3b20a1bfa71f331092ebc8bbd15e649733d35","fileCount":7,"totalBytes":104793}'::jsonb,
|
|
251
|
+
manifest_digest = '3a58c98b725573b8fd524555b7ed9dbff04df4df9f8fad44e2e850bac3824809'
|
|
252
|
+
FROM capability_facets facet
|
|
253
|
+
JOIN capability_skill_facets skill ON skill.facet_id = facet.id
|
|
254
|
+
CROSS JOIN capability_plugins plugin
|
|
255
|
+
WHERE facet.plugin_version_id = version.id
|
|
256
|
+
AND plugin.id = version.plugin_id
|
|
257
|
+
AND skill.capability_id = 'skill:terraform-stacks'
|
|
258
|
+
AND plugin.plugin_key = 'skill/library/terraform-stacks'
|
|
259
|
+
AND version.version = '0.0.1'
|
|
260
|
+
AND version.manifest = '{"schemaVersion":1,"kind":"skill","source":"library","sourceUrl":"https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/code-generation/skills/terraform-stacks","repositoryUrl":"https://github.com/hashicorp/agent-skills","version":"0.0.1","sourceCommit":"de4323afdfbc30d1387f287b55062fa8d82b62e8","sourcePath":"terraform-stacks","sourceProvenance":"Vendored from hashicorp/agent-skills; reviewed immutable opt-in entry.","contentSha256":"0a6244ecddf1cce0357db41b41b3b20a1bfa71f331092ebc8bbd15e649733d35","fileCount":7,"totalBytes":104793}'::jsonb
|
|
261
|
+
AND version.manifest_digest = 'd484ccc1279954e5dbcdd9b8b57bc21e6a0fa47d38dc11854ffcf8e61289e883';
|
|
262
|
+
|
|
263
|
+
UPDATE workspace_packs pack
|
|
264
|
+
SET manifest = opengeni_private.terraform_stacks_provenance_rewrite_pack(pack.manifest)
|
|
265
|
+
WHERE pack.manifest IS DISTINCT FROM
|
|
266
|
+
opengeni_private.terraform_stacks_provenance_rewrite_pack(pack.manifest);
|
|
267
|
+
|
|
268
|
+
CREATE TEMP TABLE terraform_stacks_pack_snapshot_repair ON COMMIT DROP AS
|
|
269
|
+
SELECT
|
|
270
|
+
installation.id,
|
|
271
|
+
installation.manifest_snapshot AS previous_manifest_snapshot,
|
|
272
|
+
installation.manifest_digest AS previous_manifest_digest,
|
|
273
|
+
opengeni_private.terraform_stacks_provenance_rewrite_pack(
|
|
274
|
+
installation.manifest_snapshot
|
|
275
|
+
) AS manifest_snapshot,
|
|
276
|
+
encode(
|
|
277
|
+
digest(
|
|
278
|
+
convert_to(
|
|
279
|
+
opengeni_private.terraform_stacks_provenance_canonical_json(
|
|
280
|
+
opengeni_private.terraform_stacks_provenance_rewrite_pack(
|
|
281
|
+
installation.manifest_snapshot
|
|
282
|
+
)
|
|
283
|
+
),
|
|
284
|
+
'UTF8'
|
|
285
|
+
),
|
|
286
|
+
'sha256'
|
|
287
|
+
),
|
|
288
|
+
'hex'
|
|
289
|
+
) AS manifest_digest
|
|
290
|
+
FROM pack_installations installation
|
|
291
|
+
WHERE installation.manifest_snapshot IS NOT NULL
|
|
292
|
+
AND installation.manifest_snapshot IS DISTINCT FROM
|
|
293
|
+
opengeni_private.terraform_stacks_provenance_rewrite_pack(
|
|
294
|
+
installation.manifest_snapshot
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
DO $pack_digest_precondition$
|
|
298
|
+
BEGIN
|
|
299
|
+
-- The repair changes only one same-shaped JSON string value. Reproducing the
|
|
300
|
+
-- already-stored runtime digest proves this renderer's bytes for every other
|
|
301
|
+
-- key and value in that exact snapshot before it computes the new digest.
|
|
302
|
+
IF EXISTS (
|
|
303
|
+
SELECT 1
|
|
304
|
+
FROM terraform_stacks_pack_snapshot_repair repaired
|
|
305
|
+
WHERE repaired.previous_manifest_digest IS DISTINCT FROM encode(
|
|
306
|
+
digest(
|
|
307
|
+
convert_to(
|
|
308
|
+
opengeni_private.terraform_stacks_provenance_canonical_json(
|
|
309
|
+
repaired.previous_manifest_snapshot
|
|
310
|
+
),
|
|
311
|
+
'UTF8'
|
|
312
|
+
),
|
|
313
|
+
'sha256'
|
|
314
|
+
),
|
|
315
|
+
'hex'
|
|
316
|
+
)
|
|
317
|
+
) THEN
|
|
318
|
+
RAISE EXCEPTION
|
|
319
|
+
'Terraform Stacks provenance repair cannot reproduce the stored runtime Pack digest'
|
|
320
|
+
USING ERRCODE = '23514';
|
|
321
|
+
END IF;
|
|
322
|
+
END
|
|
323
|
+
$pack_digest_precondition$;
|
|
324
|
+
|
|
325
|
+
UPDATE pack_installations installation
|
|
326
|
+
SET manifest_snapshot = repaired.manifest_snapshot,
|
|
327
|
+
manifest_digest = repaired.manifest_digest
|
|
328
|
+
FROM terraform_stacks_pack_snapshot_repair repaired
|
|
329
|
+
WHERE installation.id = repaired.id;
|
|
330
|
+
|
|
331
|
+
UPDATE pack_installation_components component
|
|
332
|
+
SET digest = '3a58c98b725573b8fd524555b7ed9dbff04df4df9f8fad44e2e850bac3824809'
|
|
333
|
+
WHERE component.kind = 'plugin'
|
|
334
|
+
AND component.capability_id = 'plugin:skill/library/terraform-stacks'
|
|
335
|
+
AND component.metadata ->> 'pluginKey' = 'skill/library/terraform-stacks'
|
|
336
|
+
AND component.metadata ->> 'version' = '0.0.1'
|
|
337
|
+
AND component.digest = 'd484ccc1279954e5dbcdd9b8b57bc21e6a0fa47d38dc11854ffcf8e61289e883';
|
|
338
|
+
|
|
339
|
+
ALTER TABLE capability_plugin_versions
|
|
340
|
+
ENABLE TRIGGER capability_plugin_versions_restrict_update;
|
|
341
|
+
ALTER TABLE capability_skill_facets
|
|
342
|
+
ENABLE TRIGGER capability_skill_facets_immutable;
|
|
343
|
+
|
|
344
|
+
DO $provenance_postcondition$
|
|
345
|
+
BEGIN
|
|
346
|
+
IF EXISTS (
|
|
347
|
+
SELECT 1
|
|
348
|
+
FROM capability_skill_facets skill
|
|
349
|
+
JOIN capability_facets facet ON facet.id = skill.facet_id
|
|
350
|
+
JOIN capability_plugin_versions version ON version.id = facet.plugin_version_id
|
|
351
|
+
JOIN capability_plugins plugin ON plugin.id = version.plugin_id
|
|
352
|
+
WHERE skill.capability_id = 'skill:terraform-stacks'
|
|
353
|
+
AND (
|
|
354
|
+
plugin.plugin_key <> 'skill/library/terraform-stacks'
|
|
355
|
+
OR version.version <> '0.0.1'
|
|
356
|
+
OR skill.source_url <> 'https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/module-generation/skills/terraform-stacks'
|
|
357
|
+
OR version.manifest ->> 'sourceUrl' <> 'https://github.com/hashicorp/agent-skills/tree/de4323afdfbc30d1387f287b55062fa8d82b62e8/terraform/module-generation/skills/terraform-stacks'
|
|
358
|
+
OR version.manifest_digest <> '3a58c98b725573b8fd524555b7ed9dbff04df4df9f8fad44e2e850bac3824809'
|
|
359
|
+
)
|
|
360
|
+
) THEN
|
|
361
|
+
RAISE EXCEPTION 'Terraform Stacks provenance repair did not converge'
|
|
362
|
+
USING ERRCODE = '23514';
|
|
363
|
+
END IF;
|
|
364
|
+
|
|
365
|
+
IF EXISTS (
|
|
366
|
+
SELECT 1
|
|
367
|
+
FROM workspace_packs pack,
|
|
368
|
+
LATERAL jsonb_array_elements(COALESCE(pack.manifest -> 'components', '[]'::jsonb)) component
|
|
369
|
+
WHERE component ->> 'kind' = 'plugin'
|
|
370
|
+
AND component ->> 'pluginKey' = 'skill/library/terraform-stacks'
|
|
371
|
+
AND component ->> 'version' = '0.0.1'
|
|
372
|
+
AND component ->> 'manifestDigest' IS DISTINCT FROM
|
|
373
|
+
'3a58c98b725573b8fd524555b7ed9dbff04df4df9f8fad44e2e850bac3824809'
|
|
374
|
+
) OR EXISTS (
|
|
375
|
+
SELECT 1
|
|
376
|
+
FROM pack_installations installation,
|
|
377
|
+
LATERAL jsonb_array_elements(
|
|
378
|
+
COALESCE(installation.manifest_snapshot -> 'components', '[]'::jsonb)
|
|
379
|
+
) component
|
|
380
|
+
WHERE installation.manifest_snapshot IS NOT NULL
|
|
381
|
+
AND component ->> 'kind' = 'plugin'
|
|
382
|
+
AND component ->> 'pluginKey' = 'skill/library/terraform-stacks'
|
|
383
|
+
AND component ->> 'version' = '0.0.1'
|
|
384
|
+
AND component ->> 'manifestDigest' IS DISTINCT FROM
|
|
385
|
+
'3a58c98b725573b8fd524555b7ed9dbff04df4df9f8fad44e2e850bac3824809'
|
|
386
|
+
) OR EXISTS (
|
|
387
|
+
SELECT 1
|
|
388
|
+
FROM terraform_stacks_pack_snapshot_repair repaired
|
|
389
|
+
JOIN pack_installations installation ON installation.id = repaired.id
|
|
390
|
+
WHERE installation.manifest_snapshot IS DISTINCT FROM repaired.manifest_snapshot
|
|
391
|
+
OR installation.manifest_digest IS DISTINCT FROM repaired.manifest_digest
|
|
392
|
+
) OR EXISTS (
|
|
393
|
+
SELECT 1
|
|
394
|
+
FROM pack_installation_components component
|
|
395
|
+
WHERE (
|
|
396
|
+
component.capability_id = 'plugin:skill/library/terraform-stacks'
|
|
397
|
+
OR component.metadata ->> 'pluginKey' = 'skill/library/terraform-stacks'
|
|
398
|
+
OR EXISTS (
|
|
399
|
+
SELECT 1
|
|
400
|
+
FROM capability_plugin_installations installation
|
|
401
|
+
JOIN capability_plugins plugin ON plugin.id = installation.plugin_id
|
|
402
|
+
WHERE installation.id::text = component.resolved_id
|
|
403
|
+
AND plugin.plugin_key = 'skill/library/terraform-stacks'
|
|
404
|
+
)
|
|
405
|
+
)
|
|
406
|
+
AND (
|
|
407
|
+
component.kind IS DISTINCT FROM 'plugin'
|
|
408
|
+
OR component.capability_id IS DISTINCT FROM
|
|
409
|
+
'plugin:skill/library/terraform-stacks'
|
|
410
|
+
OR component.metadata ->> 'pluginKey' IS DISTINCT FROM
|
|
411
|
+
'skill/library/terraform-stacks'
|
|
412
|
+
OR component.metadata ->> 'version' IS DISTINCT FROM '0.0.1'
|
|
413
|
+
OR component.digest IS DISTINCT FROM
|
|
414
|
+
'3a58c98b725573b8fd524555b7ed9dbff04df4df9f8fad44e2e850bac3824809'
|
|
415
|
+
)
|
|
416
|
+
) THEN
|
|
417
|
+
RAISE EXCEPTION 'Terraform Stacks Pack provenance repair did not converge'
|
|
418
|
+
USING ERRCODE = '23514';
|
|
419
|
+
END IF;
|
|
420
|
+
END
|
|
421
|
+
$provenance_postcondition$;
|
|
422
|
+
|
|
423
|
+
DROP FUNCTION opengeni_private.terraform_stacks_provenance_rewrite_pack(jsonb);
|
|
424
|
+
DROP FUNCTION opengeni_private.terraform_stacks_provenance_canonical_json(jsonb);
|
|
425
|
+
DROP COLLATION opengeni_private.terraform_stacks_provenance_js_en_us;
|
|
426
|
+
|
|
427
|
+
RESET statement_timeout;
|
|
428
|
+
RESET lock_timeout;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
-- deployment-mode: maintenance
|
|
2
|
+
-- Forward-only successor to migration 0247. Migration 0247 repaired the
|
|
3
|
+
-- Terraform Stacks provenance projection but did not prove that an affected
|
|
4
|
+
-- Pack component's polymorphic resolved_id still named the exact normalized
|
|
5
|
+
-- Plugin installation described by its canonical component fields.
|
|
6
|
+
|
|
7
|
+
SET LOCAL lock_timeout = '5s';
|
|
8
|
+
SET LOCAL statement_timeout = '10min';
|
|
9
|
+
|
|
10
|
+
DO $maintenance_preflight_guard$
|
|
11
|
+
BEGIN
|
|
12
|
+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'opengeni_app')
|
|
13
|
+
AND EXISTS (
|
|
14
|
+
SELECT 1
|
|
15
|
+
FROM pg_stat_activity
|
|
16
|
+
WHERE datname = current_database()
|
|
17
|
+
AND usename = 'opengeni_app'
|
|
18
|
+
AND pid <> pg_backend_pid()
|
|
19
|
+
)
|
|
20
|
+
THEN
|
|
21
|
+
RAISE EXCEPTION
|
|
22
|
+
'Terraform Stacks component resolution fence requires all opengeni_app sessions to be stopped'
|
|
23
|
+
USING ERRCODE = '55000';
|
|
24
|
+
END IF;
|
|
25
|
+
END
|
|
26
|
+
$maintenance_preflight_guard$;
|
|
27
|
+
|
|
28
|
+
LOCK TABLE capability_plugins IN ACCESS EXCLUSIVE MODE;
|
|
29
|
+
LOCK TABLE capability_plugin_versions IN ACCESS EXCLUSIVE MODE;
|
|
30
|
+
LOCK TABLE capability_plugin_installations IN ACCESS EXCLUSIVE MODE;
|
|
31
|
+
LOCK TABLE pack_installation_components IN ACCESS EXCLUSIVE MODE;
|
|
32
|
+
|
|
33
|
+
DO $terraform_stacks_component_resolution_fence$
|
|
34
|
+
BEGIN
|
|
35
|
+
IF EXISTS (
|
|
36
|
+
SELECT 1
|
|
37
|
+
FROM pack_installation_components component
|
|
38
|
+
WHERE (
|
|
39
|
+
component.capability_id = 'plugin:skill/library/terraform-stacks'
|
|
40
|
+
OR component.metadata ->> 'pluginKey' = 'skill/library/terraform-stacks'
|
|
41
|
+
OR EXISTS (
|
|
42
|
+
SELECT 1
|
|
43
|
+
FROM capability_plugin_installations installation
|
|
44
|
+
JOIN capability_plugins plugin ON plugin.id = installation.plugin_id
|
|
45
|
+
WHERE installation.id::text = component.resolved_id
|
|
46
|
+
AND plugin.plugin_key = 'skill/library/terraform-stacks'
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
AND (
|
|
50
|
+
component.kind IS DISTINCT FROM 'plugin'
|
|
51
|
+
OR component.capability_id IS DISTINCT FROM
|
|
52
|
+
'plugin:skill/library/terraform-stacks'
|
|
53
|
+
OR component.metadata ->> 'pluginKey' IS DISTINCT FROM
|
|
54
|
+
'skill/library/terraform-stacks'
|
|
55
|
+
OR component.metadata ->> 'version' IS DISTINCT FROM '0.0.1'
|
|
56
|
+
OR component.digest IS DISTINCT FROM
|
|
57
|
+
'3a58c98b725573b8fd524555b7ed9dbff04df4df9f8fad44e2e850bac3824809'
|
|
58
|
+
OR NOT EXISTS (
|
|
59
|
+
SELECT 1
|
|
60
|
+
FROM capability_plugin_installations installation
|
|
61
|
+
JOIN capability_plugins plugin ON plugin.id = installation.plugin_id
|
|
62
|
+
JOIN capability_plugin_versions version
|
|
63
|
+
ON version.id = installation.plugin_version_id
|
|
64
|
+
AND version.plugin_id = installation.plugin_id
|
|
65
|
+
WHERE installation.id::text = component.resolved_id
|
|
66
|
+
AND installation.account_id = component.account_id
|
|
67
|
+
AND installation.workspace_id = component.workspace_id
|
|
68
|
+
AND installation.status = 'active'
|
|
69
|
+
AND plugin.plugin_key = 'skill/library/terraform-stacks'
|
|
70
|
+
AND version.version = '0.0.1'
|
|
71
|
+
AND version.manifest_digest = component.digest
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
) THEN
|
|
75
|
+
RAISE EXCEPTION
|
|
76
|
+
'Terraform Stacks component resolution fence found unexpected Pack state'
|
|
77
|
+
USING ERRCODE = '23514';
|
|
78
|
+
END IF;
|
|
79
|
+
END
|
|
80
|
+
$terraform_stacks_component_resolution_fence$;
|
|
81
|
+
|
|
82
|
+
RESET statement_timeout;
|
|
83
|
+
RESET lock_timeout;
|