@opengeni/db 1.0.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-LTG3S6ZY.js → chunk-EULAN2NP.js} +2 -2
- package/dist/{chunk-CUPM3FGB.js → chunk-NJVZPWXY.js} +3 -3
- package/dist/{chunk-4SR4HKKA.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-6ZYKCRFO.js → chunk-PR2WMLOQ.js} +7580 -4417
- package/dist/chunk-PR2WMLOQ.js.map +1 -0
- package/dist/{chunk-ZWREYEWA.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.js +2 -2
- 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 +1595 -81
- package/dist/index.js +21571 -8126
- 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/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 +22 -8
- package/dist/schema.d.ts +24914 -13703
- package/dist/schema.js +99 -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 +41 -4
- package/dist/session-realtime-ledger.d.ts +2 -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/0241_atomic_personal_resource_delegation.sql +1000 -0
- package/drizzle/0241_enrollment_agent_runtime.sql +70 -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-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 +11651 -1548
- 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/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 +877 -6
- package/src/runtime-posture-cli.ts +2 -0
- package/src/runtime-posture.ts +1291 -76
- package/src/schema.ts +3303 -428
- 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 +437 -84
- package/src/session-realtime-context.ts +3 -3
- package/src/session-realtime-ledger.ts +22 -11
- 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-4SR4HKKA.js.map +0 -1
- package/dist/chunk-6ZYKCRFO.js.map +0 -1
- package/dist/chunk-NXAFLCQX.js +0 -2468
- package/dist/chunk-NXAFLCQX.js.map +0 -1
- package/dist/chunk-SK7YYHBI.js.map +0 -1
- package/dist/chunk-WD5ROSLL.js +0 -117
- package/dist/chunk-WD5ROSLL.js.map +0 -1
- package/dist/chunk-ZWREYEWA.js.map +0 -1
- /package/dist/{chunk-LTG3S6ZY.js.map → chunk-EULAN2NP.js.map} +0 -0
- /package/dist/{chunk-CUPM3FGB.js.map → chunk-NJVZPWXY.js.map} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- Migration 0281: viewer lease holders record the authenticated viewer
|
|
3
|
+
-- subject and the session authority epoch observed when the viewer attached.
|
|
4
|
+
--
|
|
5
|
+
-- Stream tokens (`ogs_`) previously carried only workspace/session/viewer/
|
|
6
|
+
-- lease-epoch claims with a 120 s TTL: nothing bound a live stream to the
|
|
7
|
+
-- human (or API principal) watching it, and an authority revocation
|
|
8
|
+
-- (session authority epoch advance) left in-TTL tokens indistinguishable
|
|
9
|
+
-- from current ones. The token now carries optional `subjectId` and
|
|
10
|
+
-- `authorityEpoch` claims minted from live state, and the viewer holder row
|
|
11
|
+
-- records the same pair so revocation sweeps and audits can resolve exactly
|
|
12
|
+
-- who was attached under which authority.
|
|
13
|
+
--
|
|
14
|
+
-- Rolling window: two nullable columns; old images keep inserting holder
|
|
15
|
+
-- rows without them, and old token verifiers (TypeScript zod strips unknown
|
|
16
|
+
-- keys; the Rust relay's serde ignores unknown fields) accept new tokens
|
|
17
|
+
-- while enforcing nothing new. The claims are identities and epochs only -
|
|
18
|
+
-- never a secret value - and the 120 s TTL is unchanged.
|
|
19
|
+
|
|
20
|
+
SET LOCAL lock_timeout = '5s';
|
|
21
|
+
SET LOCAL statement_timeout = '5min';
|
|
22
|
+
|
|
23
|
+
ALTER TABLE "sandbox_lease_holders"
|
|
24
|
+
ADD COLUMN IF NOT EXISTS "viewer_subject_id" text,
|
|
25
|
+
ADD COLUMN IF NOT EXISTS "viewer_authority_epoch" integer;
|
|
26
|
+
|
|
27
|
+
DO $viewer_holder_authority_check$
|
|
28
|
+
BEGIN
|
|
29
|
+
IF NOT EXISTS (
|
|
30
|
+
SELECT 1 FROM pg_constraint
|
|
31
|
+
WHERE conname = 'sandbox_lease_holders_viewer_authority_check'
|
|
32
|
+
AND conrelid = 'sandbox_lease_holders'::regclass
|
|
33
|
+
) THEN
|
|
34
|
+
ALTER TABLE "sandbox_lease_holders"
|
|
35
|
+
ADD CONSTRAINT "sandbox_lease_holders_viewer_authority_check"
|
|
36
|
+
CHECK (
|
|
37
|
+
("viewer_authority_epoch" IS NULL OR "viewer_authority_epoch" > 0)
|
|
38
|
+
AND ("viewer_subject_id" IS NULL
|
|
39
|
+
OR length(btrim("viewer_subject_id")) BETWEEN 1 AND 512)
|
|
40
|
+
) NOT VALID;
|
|
41
|
+
END IF;
|
|
42
|
+
END
|
|
43
|
+
$viewer_holder_authority_check$;
|
|
44
|
+
ALTER TABLE "sandbox_lease_holders"
|
|
45
|
+
VALIDATE CONSTRAINT "sandbox_lease_holders_viewer_authority_check";
|
|
46
|
+
|
|
47
|
+
COMMENT ON COLUMN "sandbox_lease_holders"."viewer_subject_id" IS
|
|
48
|
+
'Authenticated subject that attached this viewer holder. Identity only - '
|
|
49
|
+
'never a secret value. NULL for non-viewer holders and pre-0281 rows.';
|
|
50
|
+
COMMENT ON COLUMN "sandbox_lease_holders"."viewer_authority_epoch" IS
|
|
51
|
+
'Session authority epoch observed when the viewer attached; the stream '
|
|
52
|
+
'token minted for this holder carries the same claim.';
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- Migration 0282: the session-attach variable-set materialization records the
|
|
3
|
+
-- accepted subject and an audit fact.
|
|
4
|
+
--
|
|
5
|
+
-- `materialize_scoped_variable_set_for_session` (0254) is the API-direct
|
|
6
|
+
-- lane: a viewer attach or a direct channel operation cold-creating a box
|
|
7
|
+
-- materializes the session's variable set so the manifest environment matches
|
|
8
|
+
-- the next turn's. Unlike the attempt lane (0254/0280), it validated only the
|
|
9
|
+
-- session linkage - it took no subject and wrote no audit event, so a
|
|
10
|
+
-- materialization through this lane was invisible to the audit timeline.
|
|
11
|
+
--
|
|
12
|
+
-- The function keeps its exact signature and grants. Attribution arrives
|
|
13
|
+
-- through the standard request context GUCs (`opengeni.subject_id`,
|
|
14
|
+
-- `opengeni.initiating_human_subject_id`) that the application wrapper sets,
|
|
15
|
+
-- and the function now writes the same `variable_set.materialized` audit fact
|
|
16
|
+
-- the attempt lane writes: actor kind `session_attach`, the caller subject,
|
|
17
|
+
-- the derived causal human, and the live session authority tuple
|
|
18
|
+
-- (epoch/visibility/owner membership) read from the exact session row this
|
|
19
|
+
-- transaction already locks FOR SHARE. Metadata only - never a value.
|
|
20
|
+
--
|
|
21
|
+
-- Rolling window: unchanged signature; an old image calls without the subject
|
|
22
|
+
-- GUC and the audit row records the explicit legacy subject
|
|
23
|
+
-- `service:session` (the same honest sentinel the application's denial
|
|
24
|
+
-- recorder already uses for this lane) with NULL causal human. Denials keep
|
|
25
|
+
-- RAISE + rollback semantics; denial recording remains with the application
|
|
26
|
+
-- caller in a fresh transaction.
|
|
27
|
+
|
|
28
|
+
SET LOCAL lock_timeout = '5s';
|
|
29
|
+
SET LOCAL statement_timeout = '5min';
|
|
30
|
+
|
|
31
|
+
CREATE OR REPLACE FUNCTION materialize_scoped_variable_set_for_session(
|
|
32
|
+
p_account_id uuid,
|
|
33
|
+
p_workspace_id uuid,
|
|
34
|
+
p_session_id uuid,
|
|
35
|
+
p_variable_set_id uuid
|
|
36
|
+
) RETURNS TABLE (
|
|
37
|
+
variable_set_id uuid,
|
|
38
|
+
variable_set_name text,
|
|
39
|
+
variable_set_description text,
|
|
40
|
+
authority_scope text,
|
|
41
|
+
variable_set_generation bigint,
|
|
42
|
+
variable_name text,
|
|
43
|
+
value_encrypted text
|
|
44
|
+
)
|
|
45
|
+
LANGUAGE plpgsql
|
|
46
|
+
SECURITY DEFINER
|
|
47
|
+
SET search_path FROM CURRENT
|
|
48
|
+
AS $$
|
|
49
|
+
DECLARE
|
|
50
|
+
selected_row record;
|
|
51
|
+
variable_set_row workspace_variable_sets%ROWTYPE;
|
|
52
|
+
session_authority_epoch integer;
|
|
53
|
+
session_authority_visibility text;
|
|
54
|
+
session_owner_membership uuid;
|
|
55
|
+
audit_subject text;
|
|
56
|
+
causal_human text;
|
|
57
|
+
BEGIN
|
|
58
|
+
IF p_account_id IS DISTINCT FROM nullif(
|
|
59
|
+
pg_catalog.current_setting('opengeni.account_id', true), ''
|
|
60
|
+
)::uuid
|
|
61
|
+
OR p_workspace_id IS DISTINCT FROM nullif(
|
|
62
|
+
pg_catalog.current_setting('opengeni.workspace_id', true), ''
|
|
63
|
+
)::uuid
|
|
64
|
+
THEN
|
|
65
|
+
RAISE EXCEPTION 'variable-set session materialization scope mismatch'
|
|
66
|
+
USING ERRCODE = '42501';
|
|
67
|
+
END IF;
|
|
68
|
+
|
|
69
|
+
-- Attribution (0282): the request subject from the standard context GUCs.
|
|
70
|
+
-- An old image that sets no subject records the explicit legacy sentinel.
|
|
71
|
+
audit_subject := coalesce(
|
|
72
|
+
nullif(pg_catalog.current_setting('opengeni.subject_id', true), ''),
|
|
73
|
+
'service:session'
|
|
74
|
+
);
|
|
75
|
+
causal_human := coalesce(
|
|
76
|
+
nullif(pg_catalog.current_setting('opengeni.initiating_human_subject_id', true), ''),
|
|
77
|
+
CASE WHEN audit_subject LIKE 'user:%' THEN audit_subject END
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
INSERT INTO opengeni_private.variable_set_authority_capabilities (
|
|
81
|
+
backend_pid, transaction_id, capability_kind
|
|
82
|
+
) VALUES (pg_catalog.pg_backend_pid(), pg_catalog.pg_current_xact_id(), 'materialize')
|
|
83
|
+
ON CONFLICT DO NOTHING;
|
|
84
|
+
|
|
85
|
+
SELECT variable_set AS selected_set,
|
|
86
|
+
session_value.authority_epoch AS session_epoch,
|
|
87
|
+
session_value.visibility AS session_visibility,
|
|
88
|
+
session_value.owner_organization_membership_id AS session_owner_membership
|
|
89
|
+
INTO STRICT selected_row
|
|
90
|
+
FROM sessions session_value
|
|
91
|
+
JOIN workspace_variable_sets variable_set
|
|
92
|
+
ON variable_set.id = p_variable_set_id
|
|
93
|
+
AND variable_set.account_id = session_value.account_id
|
|
94
|
+
WHERE session_value.id = p_session_id
|
|
95
|
+
AND session_value.account_id = p_account_id
|
|
96
|
+
AND session_value.workspace_id = p_workspace_id
|
|
97
|
+
AND session_value.variable_set_id = p_variable_set_id
|
|
98
|
+
AND session_value.status IN (
|
|
99
|
+
'queued', 'running', 'idle', 'requires_action', 'recovering', 'waiting_capacity'
|
|
100
|
+
)
|
|
101
|
+
AND variable_set.status = 'active'
|
|
102
|
+
AND (
|
|
103
|
+
variable_set.authority_scope = 'organization'
|
|
104
|
+
OR (
|
|
105
|
+
variable_set.authority_scope = 'workspace'
|
|
106
|
+
AND variable_set.workspace_id = p_workspace_id
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
FOR SHARE OF session_value, variable_set;
|
|
110
|
+
variable_set_row := selected_row.selected_set;
|
|
111
|
+
session_authority_epoch := selected_row.session_epoch;
|
|
112
|
+
session_authority_visibility := selected_row.session_visibility;
|
|
113
|
+
session_owner_membership := selected_row.session_owner_membership;
|
|
114
|
+
|
|
115
|
+
-- The audit fact (0282): same action as the attempt lane, actor kind
|
|
116
|
+
-- session_attach, live session authority from the row locked above.
|
|
117
|
+
-- Metadata only - never a variable value.
|
|
118
|
+
INSERT INTO audit_events (
|
|
119
|
+
account_id, workspace_id, subject_id, action, target_type, target_id,
|
|
120
|
+
metadata, metadata_codec_version
|
|
121
|
+
) VALUES (
|
|
122
|
+
p_account_id, p_workspace_id, audit_subject,
|
|
123
|
+
'variable_set.materialized', 'workspace_variable_set',
|
|
124
|
+
variable_set_row.id::text,
|
|
125
|
+
pg_catalog.jsonb_build_object(
|
|
126
|
+
'variableSetId', variable_set_row.id,
|
|
127
|
+
'scope', variable_set_row.authority_scope,
|
|
128
|
+
'generation', variable_set_row.generation,
|
|
129
|
+
'actorKind', 'session_attach',
|
|
130
|
+
'sessionId', p_session_id,
|
|
131
|
+
'causalHumanSubjectId', causal_human,
|
|
132
|
+
'authorityEpoch', session_authority_epoch,
|
|
133
|
+
'authorityVisibility', session_authority_visibility,
|
|
134
|
+
'authorityOwnerOrganizationMembershipId', session_owner_membership,
|
|
135
|
+
'ownerAuthorityId', variable_set_row.authority_id,
|
|
136
|
+
'ownerOrganizationMembershipId', variable_set_row.owner_organization_membership_id,
|
|
137
|
+
'originWorkspaceId', variable_set_row.origin_workspace_id
|
|
138
|
+
),
|
|
139
|
+
1
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
RETURN QUERY
|
|
143
|
+
SELECT selected.id, selected.name, selected.description,
|
|
144
|
+
selected.authority_scope, selected.generation,
|
|
145
|
+
variable.name, variable.value_encrypted
|
|
146
|
+
FROM workspace_variable_sets selected
|
|
147
|
+
LEFT JOIN workspace_variable_set_variables variable
|
|
148
|
+
ON variable.account_id = selected.account_id
|
|
149
|
+
AND variable.variable_set_id = selected.id
|
|
150
|
+
WHERE selected.id = variable_set_row.id
|
|
151
|
+
ORDER BY variable.name;
|
|
152
|
+
|
|
153
|
+
DELETE FROM opengeni_private.variable_set_authority_capabilities
|
|
154
|
+
WHERE backend_pid = pg_catalog.pg_backend_pid()
|
|
155
|
+
AND transaction_id = pg_catalog.pg_current_xact_id_if_assigned()
|
|
156
|
+
AND capability_kind = 'materialize';
|
|
157
|
+
RETURN;
|
|
158
|
+
EXCEPTION WHEN OTHERS THEN
|
|
159
|
+
DELETE FROM opengeni_private.variable_set_authority_capabilities
|
|
160
|
+
WHERE backend_pid = pg_catalog.pg_backend_pid()
|
|
161
|
+
AND transaction_id = pg_catalog.pg_current_xact_id_if_assigned()
|
|
162
|
+
AND capability_kind = 'materialize';
|
|
163
|
+
RAISE;
|
|
164
|
+
END
|
|
165
|
+
$$;
|
|
166
|
+
|
|
167
|
+
REVOKE ALL ON FUNCTION materialize_scoped_variable_set_for_session(
|
|
168
|
+
uuid, uuid, uuid, uuid
|
|
169
|
+
) FROM PUBLIC;
|
|
170
|
+
DO $session_materialize_attribution_grant$
|
|
171
|
+
BEGIN
|
|
172
|
+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'opengeni_app') THEN
|
|
173
|
+
GRANT EXECUTE ON FUNCTION materialize_scoped_variable_set_for_session(
|
|
174
|
+
uuid, uuid, uuid, uuid
|
|
175
|
+
) TO opengeni_app;
|
|
176
|
+
END IF;
|
|
177
|
+
END
|
|
178
|
+
$session_materialize_attribution_grant$;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
-- deployment-mode: maintenance
|
|
2
|
+
-- Hard cut to the single authored-only spreadsheet format. Existing rows are
|
|
3
|
+
-- deliberately not converted or validated; every new write must be current.
|
|
4
|
+
|
|
5
|
+
SET LOCAL lock_timeout = '5s';
|
|
6
|
+
SET LOCAL statement_timeout = '10min';
|
|
7
|
+
|
|
8
|
+
ALTER TABLE "editable_artifact_transactions"
|
|
9
|
+
DROP CONSTRAINT "editable_artifact_transactions_result_chk";
|
|
10
|
+
ALTER TABLE "editable_artifact_transactions"
|
|
11
|
+
ADD CONSTRAINT "editable_artifact_transactions_result_chk" CHECK (
|
|
12
|
+
"prior_state_hash" ~ '^sha256:[0-9a-f]{64}$'
|
|
13
|
+
AND "state_hash" ~ '^sha256:[0-9a-f]{64}$'
|
|
14
|
+
AND octet_length("kernel_version") BETWEEN 1 AND 512
|
|
15
|
+
AND "committed_transaction_byte_size" BETWEEN 1 AND 8388608
|
|
16
|
+
AND octet_length("committed_transaction_bytes") = "committed_transaction_byte_size"
|
|
17
|
+
AND "committed_transaction_hash" ~ '^sha256:[0-9a-f]{64}$'
|
|
18
|
+
AND "committed_transaction_hash" =
|
|
19
|
+
'sha256:' || encode(sha256("committed_transaction_bytes"), 'hex')
|
|
20
|
+
AND (("modality" = 'spreadsheet'
|
|
21
|
+
AND "model_schema_version" = 2
|
|
22
|
+
AND "command_protocol_version" = 2
|
|
23
|
+
AND "operation_protocol_version" = 2
|
|
24
|
+
AND "commit_protocol_version" IS NULL
|
|
25
|
+
AND "prior_native_revision" IS NULL AND "native_revision" IS NULL
|
|
26
|
+
AND "command_count" IS NULL AND "native_receipt_byte_size" IS NULL
|
|
27
|
+
AND "native_receipt_hash" IS NULL AND "native_receipt_bytes" IS NULL
|
|
28
|
+
AND substring("committed_transaction_bytes" FROM 1 FOR 8) = convert_to('OGACO002', 'UTF8'))
|
|
29
|
+
OR ("modality" IN ('document', 'presentation')
|
|
30
|
+
AND "model_schema_version" = 1
|
|
31
|
+
AND "command_protocol_version" = 1
|
|
32
|
+
AND "operation_protocol_version" IS NULL
|
|
33
|
+
AND "commit_protocol_version" = 1
|
|
34
|
+
AND "prior_native_revision" BETWEEN 0 AND 9007199254740991
|
|
35
|
+
AND (("modality" = 'document' AND (
|
|
36
|
+
("native_revision" = "prior_native_revision" AND "state_hash" = "prior_state_hash")
|
|
37
|
+
OR ("native_revision" = "prior_native_revision" + 1
|
|
38
|
+
AND "state_hash" <> "prior_state_hash")
|
|
39
|
+
)) OR ("modality" = 'presentation'
|
|
40
|
+
AND "native_revision" = "prior_native_revision" + 1
|
|
41
|
+
AND "state_hash" <> "prior_state_hash"))
|
|
42
|
+
AND "command_count" BETWEEN 1 AND 4096
|
|
43
|
+
AND "native_receipt_byte_size" BETWEEN 1 AND 524288
|
|
44
|
+
AND octet_length("native_receipt_bytes") = "native_receipt_byte_size"
|
|
45
|
+
AND "native_receipt_hash" ~ '^sha256:[0-9a-f]{64}$'
|
|
46
|
+
AND "native_receipt_hash" = 'sha256:' || encode(sha256("native_receipt_bytes"), 'hex')
|
|
47
|
+
AND substring("committed_transaction_bytes" FROM 1 FOR 8) = convert_to('OGAST001', 'UTF8')
|
|
48
|
+
AND get_byte("committed_transaction_bytes", 12) =
|
|
49
|
+
CASE "modality" WHEN 'document' THEN 1 ELSE 2 END
|
|
50
|
+
AND get_byte("committed_transaction_bytes", 13) = 0
|
|
51
|
+
AND get_byte("committed_transaction_bytes", 14) = 0
|
|
52
|
+
AND get_byte("committed_transaction_bytes", 15) = 0
|
|
53
|
+
AND substring("native_receipt_bytes" FROM 1 FOR 8) = convert_to(
|
|
54
|
+
CASE "modality" WHEN 'document' THEN 'OGADR001' ELSE 'OGAPR001' END,
|
|
55
|
+
'UTF8'
|
|
56
|
+
)))
|
|
57
|
+
) NOT VALID;
|
|
58
|
+
|
|
59
|
+
ALTER TABLE "editable_artifact_snapshots"
|
|
60
|
+
DROP CONSTRAINT "editable_artifact_snapshots_facts_chk";
|
|
61
|
+
ALTER TABLE "editable_artifact_snapshots"
|
|
62
|
+
ADD CONSTRAINT "editable_artifact_snapshots_facts_chk" CHECK (
|
|
63
|
+
"byte_size" BETWEEN 1 AND 67108864
|
|
64
|
+
AND "content_hash" ~ '^sha256:[0-9a-f]{64}$'
|
|
65
|
+
AND "mime_type" = 'application/vnd.opengeni.editable-artifact-snapshot'
|
|
66
|
+
AND "covered_head_sequence" BETWEEN 0 AND 9007199254740991
|
|
67
|
+
AND "state_hash" ~ '^sha256:[0-9a-f]{64}$'
|
|
68
|
+
AND (("modality" = 'spreadsheet'
|
|
69
|
+
AND "model_schema_version" = 2
|
|
70
|
+
AND opengeni_private.editable_artifact_frontier_valid("covered_causal_frontier")
|
|
71
|
+
AND "operation_protocol_version" = 2
|
|
72
|
+
AND "crdt_state_version" = 2
|
|
73
|
+
AND "native_revision" IS NULL)
|
|
74
|
+
OR ("modality" IN ('document', 'presentation')
|
|
75
|
+
AND "model_schema_version" = 1
|
|
76
|
+
AND "covered_causal_frontier" IS NULL
|
|
77
|
+
AND "operation_protocol_version" IS NULL
|
|
78
|
+
AND "crdt_state_version" IS NULL
|
|
79
|
+
AND "native_revision" BETWEEN 0 AND 9007199254740991))
|
|
80
|
+
AND octet_length("kernel_version") BETWEEN 1 AND 512
|
|
81
|
+
AND "verified_at" <= "published_at"
|
|
82
|
+
) NOT VALID;
|