@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,825 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- Migration 0268: deterministic, inert governed-learning evaluation.
|
|
3
|
+
--
|
|
4
|
+
-- This leaf authority consumes one exact accepted learning-policy snapshot and
|
|
5
|
+
-- one exact workspace-scoped Knowledge proposal/evidence lineage. It records
|
|
6
|
+
-- only IDs, hashes, versions, bounded enums, counts, and timestamps. It never
|
|
7
|
+
-- copies source/proposal content, calls a destination writer, or activates a
|
|
8
|
+
-- policy, preference, Memory record, instruction, or Knowledge head.
|
|
9
|
+
|
|
10
|
+
SET LOCAL lock_timeout = '5s';
|
|
11
|
+
SET LOCAL statement_timeout = '10min';
|
|
12
|
+
|
|
13
|
+
CREATE OR REPLACE FUNCTION opengeni_private.governed_learning_reason_codes_valid(value text[])
|
|
14
|
+
RETURNS boolean
|
|
15
|
+
LANGUAGE plpgsql
|
|
16
|
+
IMMUTABLE
|
|
17
|
+
PARALLEL SAFE
|
|
18
|
+
SET search_path = pg_catalog
|
|
19
|
+
AS $$
|
|
20
|
+
DECLARE
|
|
21
|
+
canonical constant text[] := ARRAY[
|
|
22
|
+
'policy_off', 'evidence_revoked', 'proposal_stale', 'evidence_conflict',
|
|
23
|
+
'confidence_below_floor', 'policy_suggest', 'policy_automatic'
|
|
24
|
+
]::text[];
|
|
25
|
+
expected text[] := ARRAY[]::text[];
|
|
26
|
+
candidate text;
|
|
27
|
+
BEGIN
|
|
28
|
+
IF value IS NULL OR pg_catalog.cardinality(value) NOT BETWEEN 1 AND 7 THEN
|
|
29
|
+
RETURN false;
|
|
30
|
+
END IF;
|
|
31
|
+
FOREACH candidate IN ARRAY canonical LOOP
|
|
32
|
+
IF candidate = ANY(value) THEN
|
|
33
|
+
expected := pg_catalog.array_append(expected, candidate);
|
|
34
|
+
END IF;
|
|
35
|
+
END LOOP;
|
|
36
|
+
RETURN expected = value;
|
|
37
|
+
END;
|
|
38
|
+
$$;
|
|
39
|
+
|
|
40
|
+
REVOKE ALL ON FUNCTION opengeni_private.governed_learning_reason_codes_valid(text[])
|
|
41
|
+
FROM PUBLIC;
|
|
42
|
+
|
|
43
|
+
CREATE TABLE "governed_learning_decision_receipts" (
|
|
44
|
+
"id" uuid PRIMARY KEY DEFAULT pg_catalog.gen_random_uuid(),
|
|
45
|
+
"account_id" uuid NOT NULL,
|
|
46
|
+
"workspace_id" uuid NOT NULL,
|
|
47
|
+
"operation_id" uuid NOT NULL,
|
|
48
|
+
"input_hash" text NOT NULL,
|
|
49
|
+
"session_id" uuid NOT NULL,
|
|
50
|
+
"turn_id" uuid NOT NULL,
|
|
51
|
+
"attempt_id" uuid NOT NULL,
|
|
52
|
+
"execution_generation" integer NOT NULL,
|
|
53
|
+
"initiating_human_subject_id" text NOT NULL,
|
|
54
|
+
"policy_snapshot_id" uuid NOT NULL,
|
|
55
|
+
"policy_snapshot_hash" text NOT NULL,
|
|
56
|
+
"policy_revision_id" uuid,
|
|
57
|
+
"policy_activation_version" bigint NOT NULL,
|
|
58
|
+
"source_kind" text NOT NULL,
|
|
59
|
+
"source_id" uuid NOT NULL,
|
|
60
|
+
"proposal_id" uuid NOT NULL,
|
|
61
|
+
"proposal_input_hash" text NOT NULL,
|
|
62
|
+
"proposal_content_hash" text NOT NULL,
|
|
63
|
+
"claim_id" uuid NOT NULL,
|
|
64
|
+
"claim_input_hash" text NOT NULL,
|
|
65
|
+
"evidence_id" uuid NOT NULL,
|
|
66
|
+
"evidence_input_hash" text NOT NULL,
|
|
67
|
+
"evidence_content_hash" text NOT NULL,
|
|
68
|
+
"evidence_authority_hash" text NOT NULL,
|
|
69
|
+
"review_revision" bigint NOT NULL,
|
|
70
|
+
"review_state" text NOT NULL,
|
|
71
|
+
"effective_mode" text NOT NULL,
|
|
72
|
+
"confidence_bps" integer NOT NULL,
|
|
73
|
+
"conflict_count" integer NOT NULL,
|
|
74
|
+
"outcome" text NOT NULL,
|
|
75
|
+
"reason_codes" text[] NOT NULL,
|
|
76
|
+
"automatic_eligible" boolean NOT NULL,
|
|
77
|
+
"confidence_floor_bps" integer NOT NULL,
|
|
78
|
+
"created_at" timestamptz NOT NULL DEFAULT pg_catalog.transaction_timestamp(),
|
|
79
|
+
CONSTRAINT "governed_learning_decision_receipts_workspace_fk"
|
|
80
|
+
FOREIGN KEY ("workspace_id", "account_id")
|
|
81
|
+
REFERENCES "workspaces" ("id", "account_id") ON DELETE CASCADE,
|
|
82
|
+
CONSTRAINT "governed_learning_decision_receipts_session_fk"
|
|
83
|
+
FOREIGN KEY ("workspace_id", "session_id")
|
|
84
|
+
REFERENCES "sessions" ("workspace_id", "id") ON DELETE CASCADE,
|
|
85
|
+
CONSTRAINT "governed_learning_decision_receipts_turn_fk"
|
|
86
|
+
FOREIGN KEY ("workspace_id", "turn_id")
|
|
87
|
+
REFERENCES "session_turns" ("workspace_id", "id") ON DELETE CASCADE,
|
|
88
|
+
CONSTRAINT "governed_learning_decision_receipts_attempt_fk"
|
|
89
|
+
FOREIGN KEY ("workspace_id", "attempt_id")
|
|
90
|
+
REFERENCES "session_turn_attempts" ("workspace_id", "id") ON DELETE CASCADE,
|
|
91
|
+
CONSTRAINT "governed_learning_decision_receipts_snapshot_fk"
|
|
92
|
+
FOREIGN KEY ("policy_snapshot_id")
|
|
93
|
+
REFERENCES "workspace_learning_policy_snapshots" ("id") ON DELETE CASCADE,
|
|
94
|
+
CONSTRAINT "governed_learning_decision_receipts_proposal_fk"
|
|
95
|
+
FOREIGN KEY ("proposal_id")
|
|
96
|
+
REFERENCES "knowledge_change_proposals" ("id") ON DELETE CASCADE,
|
|
97
|
+
CONSTRAINT "governed_learning_decision_receipts_claim_fk"
|
|
98
|
+
FOREIGN KEY ("claim_id")
|
|
99
|
+
REFERENCES "knowledge_claims" ("id") ON DELETE CASCADE,
|
|
100
|
+
CONSTRAINT "governed_learning_decision_receipts_evidence_fk"
|
|
101
|
+
FOREIGN KEY ("evidence_id")
|
|
102
|
+
REFERENCES "knowledge_claim_evidence" ("id") ON DELETE CASCADE,
|
|
103
|
+
CONSTRAINT "governed_learning_decision_receipts_operation_uq"
|
|
104
|
+
UNIQUE ("workspace_id", "operation_id"),
|
|
105
|
+
CONSTRAINT "governed_learning_decision_receipts_snapshot_proposal_uq"
|
|
106
|
+
UNIQUE ("policy_snapshot_id", "proposal_id"),
|
|
107
|
+
CONSTRAINT "governed_learning_decision_receipts_identity_chk" CHECK (
|
|
108
|
+
"execution_generation" > 0
|
|
109
|
+
AND pg_catalog.length(pg_catalog.btrim("initiating_human_subject_id")) BETWEEN 1 AND 1024
|
|
110
|
+
AND pg_catalog.octet_length(
|
|
111
|
+
pg_catalog.convert_to("initiating_human_subject_id", 'UTF8')
|
|
112
|
+
) <= 4096
|
|
113
|
+
AND "policy_activation_version" >= 0
|
|
114
|
+
AND "review_revision" > 0
|
|
115
|
+
),
|
|
116
|
+
CONSTRAINT "governed_learning_decision_receipts_hashes_chk" CHECK (
|
|
117
|
+
"input_hash" ~ '^[0-9a-f]{64}$'
|
|
118
|
+
AND "policy_snapshot_hash" ~ '^[0-9a-f]{64}$'
|
|
119
|
+
AND "proposal_input_hash" ~ '^[0-9a-f]{64}$'
|
|
120
|
+
AND "proposal_content_hash" ~ '^[0-9a-f]{64}$'
|
|
121
|
+
AND "claim_input_hash" ~ '^[0-9a-f]{64}$'
|
|
122
|
+
AND "evidence_input_hash" ~ '^[0-9a-f]{64}$'
|
|
123
|
+
AND "evidence_content_hash" ~ '^[0-9a-f]{64}$'
|
|
124
|
+
AND "evidence_authority_hash" ~ '^[0-9a-f]{64}$'
|
|
125
|
+
),
|
|
126
|
+
CONSTRAINT "governed_learning_decision_receipts_source_chk" CHECK (
|
|
127
|
+
"source_kind" IN ('scoped-knowledge-evidence', 'task-note')
|
|
128
|
+
AND ("source_kind" <> 'scoped-knowledge-evidence' OR "source_id" = "evidence_id")
|
|
129
|
+
),
|
|
130
|
+
CONSTRAINT "governed_learning_decision_receipts_facts_chk" CHECK (
|
|
131
|
+
"review_state" IN ('proposed', 'approved', 'rejected', 'revoked')
|
|
132
|
+
AND "effective_mode" IN ('off', 'suggest', 'automatic')
|
|
133
|
+
AND "confidence_bps" BETWEEN 0 AND 10000
|
|
134
|
+
AND "conflict_count" BETWEEN 0 AND 1000
|
|
135
|
+
AND "confidence_floor_bps" = 8500
|
|
136
|
+
),
|
|
137
|
+
CONSTRAINT "governed_learning_decision_receipts_decision_chk" CHECK (
|
|
138
|
+
"outcome" IN ('off','suggest','automatic','confidence','conflict','stale','revoked')
|
|
139
|
+
AND opengeni_private.governed_learning_reason_codes_valid("reason_codes")
|
|
140
|
+
AND "automatic_eligible" = ("outcome" = 'automatic')
|
|
141
|
+
)
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
CREATE INDEX "governed_learning_decision_receipts_workspace_time_idx"
|
|
145
|
+
ON "governed_learning_decision_receipts" ("workspace_id", "created_at" DESC, "id" DESC);
|
|
146
|
+
|
|
147
|
+
ALTER TABLE "governed_learning_decision_receipts" ENABLE ROW LEVEL SECURITY;
|
|
148
|
+
ALTER TABLE "governed_learning_decision_receipts" FORCE ROW LEVEL SECURITY;
|
|
149
|
+
|
|
150
|
+
CREATE POLICY governed_learning_decision_receipts_tenant
|
|
151
|
+
ON "governed_learning_decision_receipts"
|
|
152
|
+
USING (opengeni_private.workspace_rls_visible("account_id", "workspace_id"))
|
|
153
|
+
WITH CHECK (opengeni_private.workspace_rls_visible("account_id", "workspace_id"));
|
|
154
|
+
CREATE POLICY session_visibility_isolation
|
|
155
|
+
ON "governed_learning_decision_receipts" AS RESTRICTIVE
|
|
156
|
+
USING (session_reference_visible("account_id", "workspace_id", "session_id"))
|
|
157
|
+
WITH CHECK (session_reference_visible("account_id", "workspace_id", "session_id"));
|
|
158
|
+
|
|
159
|
+
CREATE OR REPLACE FUNCTION reject_governed_learning_decision_receipt_mutation()
|
|
160
|
+
RETURNS trigger
|
|
161
|
+
LANGUAGE plpgsql
|
|
162
|
+
AS $$
|
|
163
|
+
BEGIN
|
|
164
|
+
IF TG_OP = 'DELETE'
|
|
165
|
+
AND pg_catalog.pg_trigger_depth() > 1
|
|
166
|
+
AND (
|
|
167
|
+
NOT EXISTS (SELECT 1 FROM workspaces WHERE id = OLD.workspace_id)
|
|
168
|
+
OR NOT EXISTS (
|
|
169
|
+
SELECT 1 FROM sessions
|
|
170
|
+
WHERE workspace_id = OLD.workspace_id AND id = OLD.session_id
|
|
171
|
+
)
|
|
172
|
+
OR NOT EXISTS (
|
|
173
|
+
SELECT 1 FROM session_turns
|
|
174
|
+
WHERE workspace_id = OLD.workspace_id AND id = OLD.turn_id
|
|
175
|
+
)
|
|
176
|
+
OR NOT EXISTS (
|
|
177
|
+
SELECT 1 FROM session_turn_attempts
|
|
178
|
+
WHERE workspace_id = OLD.workspace_id AND id = OLD.attempt_id
|
|
179
|
+
)
|
|
180
|
+
OR NOT EXISTS (
|
|
181
|
+
SELECT 1 FROM workspace_learning_policy_snapshots WHERE id = OLD.policy_snapshot_id
|
|
182
|
+
)
|
|
183
|
+
OR NOT EXISTS (SELECT 1 FROM knowledge_change_proposals WHERE id = OLD.proposal_id)
|
|
184
|
+
OR NOT EXISTS (SELECT 1 FROM knowledge_claims WHERE id = OLD.claim_id)
|
|
185
|
+
OR NOT EXISTS (SELECT 1 FROM knowledge_claim_evidence WHERE id = OLD.evidence_id)
|
|
186
|
+
)
|
|
187
|
+
THEN
|
|
188
|
+
RETURN OLD;
|
|
189
|
+
END IF;
|
|
190
|
+
RAISE EXCEPTION 'Governed-learning decision receipts are immutable'
|
|
191
|
+
USING ERRCODE = '55000';
|
|
192
|
+
END;
|
|
193
|
+
$$;
|
|
194
|
+
|
|
195
|
+
CREATE TRIGGER governed_learning_decision_receipts_immutable
|
|
196
|
+
BEFORE UPDATE OR DELETE ON "governed_learning_decision_receipts"
|
|
197
|
+
FOR EACH ROW EXECUTE FUNCTION reject_governed_learning_decision_receipt_mutation();
|
|
198
|
+
|
|
199
|
+
CREATE OR REPLACE FUNCTION evaluate_governed_learning_proposal(
|
|
200
|
+
p_account_id uuid,
|
|
201
|
+
p_workspace_id uuid,
|
|
202
|
+
p_session_id uuid,
|
|
203
|
+
p_turn_id uuid,
|
|
204
|
+
p_attempt_id uuid,
|
|
205
|
+
p_execution_generation integer,
|
|
206
|
+
p_operation_id uuid,
|
|
207
|
+
p_policy_snapshot_id uuid,
|
|
208
|
+
p_proposal_id uuid,
|
|
209
|
+
p_claim_id uuid,
|
|
210
|
+
p_evidence_id uuid
|
|
211
|
+
) RETURNS TABLE (
|
|
212
|
+
receipt_id uuid,
|
|
213
|
+
operation_id uuid,
|
|
214
|
+
input_hash text,
|
|
215
|
+
account_id uuid,
|
|
216
|
+
workspace_id uuid,
|
|
217
|
+
session_id uuid,
|
|
218
|
+
turn_id uuid,
|
|
219
|
+
attempt_id uuid,
|
|
220
|
+
execution_generation integer,
|
|
221
|
+
initiating_human_subject_id text,
|
|
222
|
+
policy_snapshot_id uuid,
|
|
223
|
+
policy_snapshot_hash text,
|
|
224
|
+
policy_revision_id uuid,
|
|
225
|
+
policy_activation_version bigint,
|
|
226
|
+
source_kind text,
|
|
227
|
+
source_id uuid,
|
|
228
|
+
proposal_id uuid,
|
|
229
|
+
proposal_input_hash text,
|
|
230
|
+
proposal_content_hash text,
|
|
231
|
+
claim_id uuid,
|
|
232
|
+
claim_input_hash text,
|
|
233
|
+
evidence_id uuid,
|
|
234
|
+
evidence_input_hash text,
|
|
235
|
+
evidence_content_hash text,
|
|
236
|
+
evidence_authority_hash text,
|
|
237
|
+
review_revision bigint,
|
|
238
|
+
review_state text,
|
|
239
|
+
effective_mode text,
|
|
240
|
+
confidence_bps integer,
|
|
241
|
+
conflict_count integer,
|
|
242
|
+
outcome text,
|
|
243
|
+
reason_codes text[],
|
|
244
|
+
automatic_eligible boolean,
|
|
245
|
+
confidence_floor_bps integer,
|
|
246
|
+
created_at timestamptz
|
|
247
|
+
)
|
|
248
|
+
LANGUAGE plpgsql
|
|
249
|
+
SECURITY DEFINER
|
|
250
|
+
AS $$
|
|
251
|
+
DECLARE
|
|
252
|
+
caller_subject_id text := nullif(
|
|
253
|
+
pg_catalog.current_setting('opengeni.subject_id', true), ''
|
|
254
|
+
);
|
|
255
|
+
calculated_input_hash text;
|
|
256
|
+
turn_row session_turns%ROWTYPE;
|
|
257
|
+
snapshot_row workspace_learning_policy_snapshots%ROWTYPE;
|
|
258
|
+
proposal_row knowledge_change_proposals%ROWTYPE;
|
|
259
|
+
claim_row knowledge_claims%ROWTYPE;
|
|
260
|
+
evidence_row knowledge_claim_evidence%ROWTYPE;
|
|
261
|
+
review_row knowledge_claim_reviews%ROWTYPE;
|
|
262
|
+
receipt_row governed_learning_decision_receipts%ROWTYPE;
|
|
263
|
+
document_authority record;
|
|
264
|
+
task_note_row task_notes%ROWTYPE;
|
|
265
|
+
source_kind_value text;
|
|
266
|
+
source_id_value uuid;
|
|
267
|
+
effective_mode_value text;
|
|
268
|
+
authority_hash_value text;
|
|
269
|
+
conflict_count_value integer;
|
|
270
|
+
revoked_value boolean := false;
|
|
271
|
+
stale_value boolean := false;
|
|
272
|
+
outcome_value text;
|
|
273
|
+
reason_codes_value text[] := ARRAY[]::text[];
|
|
274
|
+
BEGIN
|
|
275
|
+
IF p_account_id IS NULL OR p_workspace_id IS NULL OR p_session_id IS NULL
|
|
276
|
+
OR p_turn_id IS NULL OR p_attempt_id IS NULL OR p_operation_id IS NULL
|
|
277
|
+
OR p_policy_snapshot_id IS NULL OR p_proposal_id IS NULL
|
|
278
|
+
OR p_claim_id IS NULL OR p_evidence_id IS NULL
|
|
279
|
+
OR p_execution_generation IS NULL OR p_execution_generation <= 0
|
|
280
|
+
OR caller_subject_id IS NULL
|
|
281
|
+
OR pg_catalog.length(pg_catalog.btrim(caller_subject_id)) NOT BETWEEN 1 AND 1024
|
|
282
|
+
OR pg_catalog.octet_length(pg_catalog.convert_to(caller_subject_id, 'UTF8')) > 4096
|
|
283
|
+
OR p_account_id IS DISTINCT FROM opengeni_private.current_account_id()
|
|
284
|
+
OR p_workspace_id IS DISTINCT FROM opengeni_private.current_workspace_id()
|
|
285
|
+
THEN
|
|
286
|
+
RAISE EXCEPTION 'governed-learning evaluation requires exact bounded tenant authority'
|
|
287
|
+
USING ERRCODE = '42501';
|
|
288
|
+
END IF;
|
|
289
|
+
|
|
290
|
+
calculated_input_hash := pg_catalog.encode(sha256(pg_catalog.convert_to(
|
|
291
|
+
pg_catalog.jsonb_build_array(
|
|
292
|
+
'governed-learning-evaluation', 1, p_account_id, p_workspace_id,
|
|
293
|
+
p_session_id, p_turn_id, p_attempt_id, p_execution_generation,
|
|
294
|
+
p_operation_id, p_policy_snapshot_id, p_proposal_id, p_claim_id, p_evidence_id
|
|
295
|
+
)::text,
|
|
296
|
+
'UTF8'
|
|
297
|
+
)), 'hex');
|
|
298
|
+
|
|
299
|
+
-- An exact replay remains immutable evidence even after the source changes.
|
|
300
|
+
-- Any later activation controller must perform its own current authorization
|
|
301
|
+
-- recheck; this inert evaluator grants no reusable write capability.
|
|
302
|
+
SELECT receipt.* INTO receipt_row
|
|
303
|
+
FROM governed_learning_decision_receipts receipt
|
|
304
|
+
WHERE receipt.workspace_id = p_workspace_id
|
|
305
|
+
AND receipt.operation_id = p_operation_id
|
|
306
|
+
FOR SHARE;
|
|
307
|
+
IF FOUND THEN
|
|
308
|
+
IF receipt_row.account_id <> p_account_id
|
|
309
|
+
OR receipt_row.input_hash <> calculated_input_hash
|
|
310
|
+
OR receipt_row.session_id <> p_session_id
|
|
311
|
+
OR receipt_row.turn_id <> p_turn_id
|
|
312
|
+
OR receipt_row.attempt_id <> p_attempt_id
|
|
313
|
+
OR receipt_row.execution_generation <> p_execution_generation
|
|
314
|
+
OR receipt_row.policy_snapshot_id <> p_policy_snapshot_id
|
|
315
|
+
OR receipt_row.proposal_id <> p_proposal_id
|
|
316
|
+
OR receipt_row.claim_id <> p_claim_id
|
|
317
|
+
OR receipt_row.evidence_id <> p_evidence_id
|
|
318
|
+
THEN
|
|
319
|
+
RAISE EXCEPTION 'governed-learning operation conflicts with immutable receipt'
|
|
320
|
+
USING ERRCODE = '23505';
|
|
321
|
+
END IF;
|
|
322
|
+
IF receipt_row.initiating_human_subject_id <> caller_subject_id
|
|
323
|
+
OR NOT session_reference_visible(
|
|
324
|
+
receipt_row.account_id, receipt_row.workspace_id, receipt_row.session_id
|
|
325
|
+
)
|
|
326
|
+
THEN
|
|
327
|
+
RAISE EXCEPTION 'governed-learning receipt is unavailable'
|
|
328
|
+
USING ERRCODE = '42501';
|
|
329
|
+
END IF;
|
|
330
|
+
RETURN QUERY SELECT
|
|
331
|
+
receipt_row.id, receipt_row.operation_id, receipt_row.input_hash,
|
|
332
|
+
receipt_row.account_id, receipt_row.workspace_id, receipt_row.session_id,
|
|
333
|
+
receipt_row.turn_id, receipt_row.attempt_id, receipt_row.execution_generation,
|
|
334
|
+
receipt_row.initiating_human_subject_id, receipt_row.policy_snapshot_id,
|
|
335
|
+
receipt_row.policy_snapshot_hash, receipt_row.policy_revision_id,
|
|
336
|
+
receipt_row.policy_activation_version, receipt_row.source_kind,
|
|
337
|
+
receipt_row.source_id, receipt_row.proposal_id, receipt_row.proposal_input_hash,
|
|
338
|
+
receipt_row.proposal_content_hash, receipt_row.claim_id,
|
|
339
|
+
receipt_row.claim_input_hash, receipt_row.evidence_id,
|
|
340
|
+
receipt_row.evidence_input_hash, receipt_row.evidence_content_hash,
|
|
341
|
+
receipt_row.evidence_authority_hash, receipt_row.review_revision,
|
|
342
|
+
receipt_row.review_state, receipt_row.effective_mode,
|
|
343
|
+
receipt_row.confidence_bps, receipt_row.conflict_count,
|
|
344
|
+
receipt_row.outcome, receipt_row.reason_codes, receipt_row.automatic_eligible,
|
|
345
|
+
receipt_row.confidence_floor_bps, receipt_row.created_at;
|
|
346
|
+
RETURN;
|
|
347
|
+
END IF;
|
|
348
|
+
|
|
349
|
+
-- Canonical mutation/read lock prefix: workspace, session, turn, attempt.
|
|
350
|
+
PERFORM 1
|
|
351
|
+
FROM workspaces workspace
|
|
352
|
+
WHERE workspace.account_id = p_account_id AND workspace.id = p_workspace_id
|
|
353
|
+
FOR KEY SHARE;
|
|
354
|
+
IF NOT FOUND THEN
|
|
355
|
+
RAISE EXCEPTION 'governed-learning workspace is unavailable' USING ERRCODE = '42501';
|
|
356
|
+
END IF;
|
|
357
|
+
|
|
358
|
+
PERFORM 1
|
|
359
|
+
FROM sessions session
|
|
360
|
+
WHERE session.account_id = p_account_id
|
|
361
|
+
AND session.workspace_id = p_workspace_id
|
|
362
|
+
AND session.id = p_session_id
|
|
363
|
+
AND session.active_turn_id = p_turn_id
|
|
364
|
+
AND session_reference_visible(session.account_id, session.workspace_id, session.id)
|
|
365
|
+
FOR SHARE;
|
|
366
|
+
IF NOT FOUND THEN
|
|
367
|
+
RAISE EXCEPTION 'governed-learning session is unavailable' USING ERRCODE = '42501';
|
|
368
|
+
END IF;
|
|
369
|
+
|
|
370
|
+
SELECT turn.* INTO turn_row
|
|
371
|
+
FROM session_turns turn
|
|
372
|
+
WHERE turn.account_id = p_account_id
|
|
373
|
+
AND turn.workspace_id = p_workspace_id
|
|
374
|
+
AND turn.session_id = p_session_id
|
|
375
|
+
AND turn.id = p_turn_id
|
|
376
|
+
AND turn.active_attempt_id = p_attempt_id
|
|
377
|
+
AND turn.execution_generation = p_execution_generation
|
|
378
|
+
AND turn.status IN ('running', 'requires_action', 'recovering', 'waiting_capacity')
|
|
379
|
+
AND coalesce(
|
|
380
|
+
turn.initiating_human_subject_id,
|
|
381
|
+
CASE WHEN turn.initiator_kind = 'subject' THEN turn.initiator_subject_id END
|
|
382
|
+
) = caller_subject_id
|
|
383
|
+
FOR SHARE;
|
|
384
|
+
IF NOT FOUND THEN
|
|
385
|
+
RAISE EXCEPTION 'governed-learning turn authority is unavailable' USING ERRCODE = '42501';
|
|
386
|
+
END IF;
|
|
387
|
+
|
|
388
|
+
PERFORM 1
|
|
389
|
+
FROM session_turn_attempts attempt
|
|
390
|
+
WHERE attempt.account_id = p_account_id
|
|
391
|
+
AND attempt.workspace_id = p_workspace_id
|
|
392
|
+
AND attempt.session_id = p_session_id
|
|
393
|
+
AND attempt.turn_id = p_turn_id
|
|
394
|
+
AND attempt.id = p_attempt_id
|
|
395
|
+
AND attempt.execution_generation = p_execution_generation
|
|
396
|
+
AND attempt.state IN ('claimed', 'running')
|
|
397
|
+
AND NOT EXISTS (
|
|
398
|
+
SELECT 1 FROM session_attempt_interruptions interruption
|
|
399
|
+
WHERE interruption.workspace_id = p_workspace_id
|
|
400
|
+
AND interruption.attempt_id = p_attempt_id
|
|
401
|
+
AND interruption.state IN ('pending', 'delivered', 'acknowledged')
|
|
402
|
+
)
|
|
403
|
+
FOR SHARE;
|
|
404
|
+
IF NOT FOUND THEN
|
|
405
|
+
RAISE EXCEPTION 'governed-learning attempt authority is unavailable' USING ERRCODE = '42501';
|
|
406
|
+
END IF;
|
|
407
|
+
|
|
408
|
+
SELECT snapshot.* INTO snapshot_row
|
|
409
|
+
FROM workspace_learning_policy_snapshots snapshot
|
|
410
|
+
WHERE snapshot.id = p_policy_snapshot_id
|
|
411
|
+
AND snapshot.account_id = p_account_id
|
|
412
|
+
AND snapshot.workspace_id = p_workspace_id
|
|
413
|
+
AND snapshot.session_id = p_session_id
|
|
414
|
+
AND snapshot.turn_id = p_turn_id
|
|
415
|
+
AND snapshot.attempt_id = p_attempt_id
|
|
416
|
+
AND snapshot.execution_generation = p_execution_generation
|
|
417
|
+
FOR SHARE;
|
|
418
|
+
IF NOT FOUND THEN
|
|
419
|
+
RAISE EXCEPTION 'governed-learning requires the exact accepted policy snapshot'
|
|
420
|
+
USING ERRCODE = '42501';
|
|
421
|
+
END IF;
|
|
422
|
+
|
|
423
|
+
-- Serialize all evaluations of the same accepted snapshot/proposal pair.
|
|
424
|
+
PERFORM pg_catalog.pg_advisory_xact_lock(pg_catalog.hashtextextended(
|
|
425
|
+
pg_catalog.concat('governed-learning:', p_policy_snapshot_id, ':', p_proposal_id),
|
|
426
|
+
0::bigint
|
|
427
|
+
));
|
|
428
|
+
|
|
429
|
+
SELECT receipt.* INTO receipt_row
|
|
430
|
+
FROM governed_learning_decision_receipts receipt
|
|
431
|
+
WHERE receipt.workspace_id = p_workspace_id
|
|
432
|
+
AND (
|
|
433
|
+
receipt.operation_id = p_operation_id
|
|
434
|
+
OR (
|
|
435
|
+
receipt.policy_snapshot_id = p_policy_snapshot_id
|
|
436
|
+
AND receipt.proposal_id = p_proposal_id
|
|
437
|
+
)
|
|
438
|
+
)
|
|
439
|
+
FOR SHARE;
|
|
440
|
+
IF FOUND THEN
|
|
441
|
+
IF receipt_row.operation_id <> p_operation_id
|
|
442
|
+
OR receipt_row.input_hash <> calculated_input_hash
|
|
443
|
+
OR receipt_row.initiating_human_subject_id <> caller_subject_id
|
|
444
|
+
THEN
|
|
445
|
+
RAISE EXCEPTION 'governed-learning proposal was already evaluated under another operation'
|
|
446
|
+
USING ERRCODE = '23505';
|
|
447
|
+
END IF;
|
|
448
|
+
RETURN QUERY SELECT
|
|
449
|
+
receipt_row.id, receipt_row.operation_id, receipt_row.input_hash,
|
|
450
|
+
receipt_row.account_id, receipt_row.workspace_id, receipt_row.session_id,
|
|
451
|
+
receipt_row.turn_id, receipt_row.attempt_id, receipt_row.execution_generation,
|
|
452
|
+
receipt_row.initiating_human_subject_id, receipt_row.policy_snapshot_id,
|
|
453
|
+
receipt_row.policy_snapshot_hash, receipt_row.policy_revision_id,
|
|
454
|
+
receipt_row.policy_activation_version, receipt_row.source_kind,
|
|
455
|
+
receipt_row.source_id, receipt_row.proposal_id, receipt_row.proposal_input_hash,
|
|
456
|
+
receipt_row.proposal_content_hash, receipt_row.claim_id,
|
|
457
|
+
receipt_row.claim_input_hash, receipt_row.evidence_id,
|
|
458
|
+
receipt_row.evidence_input_hash, receipt_row.evidence_content_hash,
|
|
459
|
+
receipt_row.evidence_authority_hash, receipt_row.review_revision,
|
|
460
|
+
receipt_row.review_state, receipt_row.effective_mode,
|
|
461
|
+
receipt_row.confidence_bps, receipt_row.conflict_count,
|
|
462
|
+
receipt_row.outcome, receipt_row.reason_codes, receipt_row.automatic_eligible,
|
|
463
|
+
receipt_row.confidence_floor_bps, receipt_row.created_at;
|
|
464
|
+
RETURN;
|
|
465
|
+
END IF;
|
|
466
|
+
|
|
467
|
+
SELECT proposal.* INTO proposal_row
|
|
468
|
+
FROM knowledge_change_proposals proposal
|
|
469
|
+
WHERE proposal.id = p_proposal_id
|
|
470
|
+
AND proposal.account_id = p_account_id
|
|
471
|
+
AND proposal.scope_kind = 'workspace'
|
|
472
|
+
AND proposal.scope_workspace_id = p_workspace_id
|
|
473
|
+
AND proposal.scope_subject_id IS NULL
|
|
474
|
+
AND proposal.claim_id = p_claim_id
|
|
475
|
+
AND proposal.evidence_id = p_evidence_id
|
|
476
|
+
AND proposal.initiating_human_subject_id = caller_subject_id
|
|
477
|
+
FOR SHARE;
|
|
478
|
+
SELECT claim.* INTO claim_row
|
|
479
|
+
FROM knowledge_claims claim
|
|
480
|
+
WHERE claim.id = p_claim_id
|
|
481
|
+
AND claim.account_id = p_account_id
|
|
482
|
+
AND claim.scope_kind = 'workspace'
|
|
483
|
+
AND claim.scope_workspace_id = p_workspace_id
|
|
484
|
+
AND claim.scope_subject_id IS NULL
|
|
485
|
+
AND claim.initiating_human_subject_id = caller_subject_id
|
|
486
|
+
-- Serialize review, contradictory-evidence, and relation admission through
|
|
487
|
+
-- their referenced claim so the later current-state reads form one exact
|
|
488
|
+
-- evaluation point rather than racing a newly inserted lifecycle row.
|
|
489
|
+
FOR UPDATE;
|
|
490
|
+
SELECT evidence.* INTO evidence_row
|
|
491
|
+
FROM knowledge_claim_evidence evidence
|
|
492
|
+
WHERE evidence.id = p_evidence_id
|
|
493
|
+
AND evidence.account_id = p_account_id
|
|
494
|
+
AND evidence.scope_kind = 'workspace'
|
|
495
|
+
AND evidence.scope_workspace_id = p_workspace_id
|
|
496
|
+
AND evidence.scope_subject_id IS NULL
|
|
497
|
+
AND evidence.claim_id = p_claim_id
|
|
498
|
+
AND evidence.polarity = 'supports'
|
|
499
|
+
AND evidence.initiating_human_subject_id = caller_subject_id
|
|
500
|
+
FOR SHARE;
|
|
501
|
+
IF proposal_row.id IS NULL OR claim_row.id IS NULL OR evidence_row.id IS NULL THEN
|
|
502
|
+
RAISE EXCEPTION 'governed-learning proposal lineage is unavailable'
|
|
503
|
+
USING ERRCODE = '42501';
|
|
504
|
+
END IF;
|
|
505
|
+
|
|
506
|
+
SELECT review.* INTO review_row
|
|
507
|
+
FROM knowledge_claim_reviews review
|
|
508
|
+
WHERE review.account_id = p_account_id AND review.claim_id = p_claim_id
|
|
509
|
+
ORDER BY review.review_revision DESC
|
|
510
|
+
LIMIT 1
|
|
511
|
+
FOR SHARE;
|
|
512
|
+
IF review_row.id IS NULL THEN
|
|
513
|
+
RAISE EXCEPTION 'governed-learning proposal has no review lifecycle'
|
|
514
|
+
USING ERRCODE = '23514';
|
|
515
|
+
END IF;
|
|
516
|
+
|
|
517
|
+
IF evidence_row.task_note_id IS NOT NULL THEN
|
|
518
|
+
source_kind_value := 'task-note';
|
|
519
|
+
source_id_value := evidence_row.task_note_id;
|
|
520
|
+
SELECT note.* INTO task_note_row
|
|
521
|
+
FROM task_notes note
|
|
522
|
+
WHERE note.id = evidence_row.task_note_id
|
|
523
|
+
AND note.account_id = p_account_id
|
|
524
|
+
AND note.workspace_id = p_workspace_id
|
|
525
|
+
AND note.root_session_id = evidence_row.task_note_root_session_id
|
|
526
|
+
AND note.version = evidence_row.task_note_version
|
|
527
|
+
AND note.text_hash = evidence_row.content_hash
|
|
528
|
+
AND session_reference_visible(note.account_id, note.workspace_id, note.root_session_id)
|
|
529
|
+
FOR SHARE;
|
|
530
|
+
revoked_value := task_note_row.id IS NULL
|
|
531
|
+
OR task_note_row.status <> 'active'
|
|
532
|
+
OR task_note_row.expires_at <= pg_catalog.transaction_timestamp();
|
|
533
|
+
authority_hash_value := pg_catalog.encode(sha256(pg_catalog.convert_to(
|
|
534
|
+
pg_catalog.jsonb_build_array(
|
|
535
|
+
'task-note-authority', 1, evidence_row.task_note_id,
|
|
536
|
+
evidence_row.task_note_root_session_id, evidence_row.task_note_version,
|
|
537
|
+
evidence_row.content_hash, coalesce(task_note_row.status, 'unavailable'),
|
|
538
|
+
task_note_row.expires_at
|
|
539
|
+
)::text,
|
|
540
|
+
'UTF8'
|
|
541
|
+
)), 'hex');
|
|
542
|
+
ELSE
|
|
543
|
+
source_kind_value := 'scoped-knowledge-evidence';
|
|
544
|
+
source_id_value := evidence_row.id;
|
|
545
|
+
SELECT
|
|
546
|
+
provider.id AS provider_id,
|
|
547
|
+
provider.lifecycle_state AS provider_state,
|
|
548
|
+
provider.lifecycle_generation AS provider_generation,
|
|
549
|
+
source.id AS source_id,
|
|
550
|
+
source.lifecycle_state AS source_state,
|
|
551
|
+
source.lifecycle_generation AS source_generation,
|
|
552
|
+
source.current_acl_generation,
|
|
553
|
+
object.id AS object_id,
|
|
554
|
+
object.lifecycle_state AS object_state,
|
|
555
|
+
object.lifecycle_generation AS object_generation,
|
|
556
|
+
object.version_generation AS object_version_generation,
|
|
557
|
+
object.current_version_id,
|
|
558
|
+
version.id AS version_id,
|
|
559
|
+
version.version_generation,
|
|
560
|
+
version.content_sha256,
|
|
561
|
+
version.acl_version_id,
|
|
562
|
+
version.acl_generation,
|
|
563
|
+
version.document_id,
|
|
564
|
+
evidence_acl.acl_hash AS evidence_acl_hash,
|
|
565
|
+
evidence_acl.agent_access AS evidence_agent_access,
|
|
566
|
+
current_acl.id AS current_acl_id,
|
|
567
|
+
current_acl.acl_hash AS current_acl_hash,
|
|
568
|
+
current_acl.agent_access AS current_agent_access
|
|
569
|
+
INTO document_authority
|
|
570
|
+
FROM knowledge_document_versions version
|
|
571
|
+
JOIN knowledge_source_objects object
|
|
572
|
+
ON object.account_id = version.account_id
|
|
573
|
+
AND object.id = version.object_id
|
|
574
|
+
AND object.scope_key = version.scope_key
|
|
575
|
+
JOIN knowledge_sources source
|
|
576
|
+
ON source.account_id = version.account_id
|
|
577
|
+
AND source.id = version.source_id
|
|
578
|
+
AND source.scope_key = version.scope_key
|
|
579
|
+
JOIN knowledge_providers provider
|
|
580
|
+
ON provider.account_id = source.account_id
|
|
581
|
+
AND provider.id = source.provider_id
|
|
582
|
+
AND provider.scope_key = source.scope_key
|
|
583
|
+
JOIN knowledge_source_acl_versions evidence_acl
|
|
584
|
+
ON evidence_acl.account_id = version.account_id
|
|
585
|
+
AND evidence_acl.id = version.acl_version_id
|
|
586
|
+
AND evidence_acl.source_id = version.source_id
|
|
587
|
+
AND evidence_acl.generation = version.acl_generation
|
|
588
|
+
LEFT JOIN knowledge_source_acl_versions current_acl
|
|
589
|
+
ON current_acl.account_id = source.account_id
|
|
590
|
+
AND current_acl.source_id = source.id
|
|
591
|
+
AND current_acl.generation = source.current_acl_generation
|
|
592
|
+
WHERE version.id = evidence_row.document_version_id
|
|
593
|
+
AND version.account_id = p_account_id
|
|
594
|
+
AND version.scope_kind = 'workspace'
|
|
595
|
+
AND version.scope_workspace_id = p_workspace_id
|
|
596
|
+
AND version.scope_subject_id IS NULL
|
|
597
|
+
FOR SHARE OF version, object, source, provider, evidence_acl;
|
|
598
|
+
|
|
599
|
+
revoked_value := document_authority.version_id IS NULL
|
|
600
|
+
OR document_authority.provider_state IS DISTINCT FROM 'active'
|
|
601
|
+
OR document_authority.source_state IS DISTINCT FROM 'active'
|
|
602
|
+
OR document_authority.object_state IS DISTINCT FROM 'active'
|
|
603
|
+
OR document_authority.current_version_id IS DISTINCT FROM document_authority.version_id
|
|
604
|
+
OR document_authority.object_version_generation IS DISTINCT FROM
|
|
605
|
+
document_authority.version_generation
|
|
606
|
+
OR document_authority.current_acl_id IS NULL
|
|
607
|
+
OR NOT coalesce(document_authority.evidence_agent_access, false)
|
|
608
|
+
OR NOT coalesce(document_authority.current_agent_access, false)
|
|
609
|
+
OR (
|
|
610
|
+
document_authority.document_id IS NOT NULL
|
|
611
|
+
AND NOT EXISTS (
|
|
612
|
+
SELECT 1
|
|
613
|
+
FROM documents document
|
|
614
|
+
WHERE document.id = document_authority.document_id
|
|
615
|
+
AND document.account_id = p_account_id
|
|
616
|
+
AND document.workspace_id = p_workspace_id
|
|
617
|
+
AND document.status = 'ready'
|
|
618
|
+
AND document.agent_access
|
|
619
|
+
AND (
|
|
620
|
+
document.visibility <> 'private'
|
|
621
|
+
OR document.created_by = caller_subject_id
|
|
622
|
+
)
|
|
623
|
+
)
|
|
624
|
+
)
|
|
625
|
+
OR (
|
|
626
|
+
evidence_row.document_chunk_id IS NOT NULL
|
|
627
|
+
AND NOT EXISTS (
|
|
628
|
+
SELECT 1
|
|
629
|
+
FROM document_chunks chunk
|
|
630
|
+
WHERE chunk.id = evidence_row.document_chunk_id
|
|
631
|
+
AND chunk.account_id = p_account_id
|
|
632
|
+
AND chunk.workspace_id = p_workspace_id
|
|
633
|
+
AND chunk.document_id = document_authority.document_id
|
|
634
|
+
)
|
|
635
|
+
);
|
|
636
|
+
authority_hash_value := pg_catalog.encode(sha256(pg_catalog.convert_to(
|
|
637
|
+
pg_catalog.jsonb_build_array(
|
|
638
|
+
'document-evidence-authority', 1, evidence_row.document_version_id,
|
|
639
|
+
document_authority.provider_id, document_authority.provider_state,
|
|
640
|
+
document_authority.provider_generation, document_authority.source_id,
|
|
641
|
+
document_authority.source_state, document_authority.source_generation,
|
|
642
|
+
document_authority.current_acl_generation, document_authority.object_id,
|
|
643
|
+
document_authority.object_state, document_authority.object_generation,
|
|
644
|
+
document_authority.object_version_generation, document_authority.current_version_id,
|
|
645
|
+
document_authority.version_id, document_authority.version_generation,
|
|
646
|
+
document_authority.content_sha256, document_authority.acl_version_id,
|
|
647
|
+
document_authority.acl_generation, document_authority.evidence_acl_hash,
|
|
648
|
+
document_authority.current_acl_id, document_authority.current_acl_hash,
|
|
649
|
+
evidence_row.document_chunk_id, revoked_value
|
|
650
|
+
)::text,
|
|
651
|
+
'UTF8'
|
|
652
|
+
)), 'hex');
|
|
653
|
+
END IF;
|
|
654
|
+
|
|
655
|
+
effective_mode_value := coalesce(
|
|
656
|
+
(
|
|
657
|
+
SELECT override.value->>'mode'
|
|
658
|
+
FROM pg_catalog.jsonb_array_elements(snapshot_row.source_overrides) override(value)
|
|
659
|
+
WHERE override.value->>'kind' = source_kind_value
|
|
660
|
+
AND override.value->>'id' = source_id_value::text
|
|
661
|
+
LIMIT 1
|
|
662
|
+
),
|
|
663
|
+
snapshot_row.workspace_mode
|
|
664
|
+
);
|
|
665
|
+
|
|
666
|
+
SELECT least(1000, pg_catalog.count(*))::integer
|
|
667
|
+
INTO conflict_count_value
|
|
668
|
+
FROM (
|
|
669
|
+
SELECT relation.id
|
|
670
|
+
FROM knowledge_claim_relations relation
|
|
671
|
+
WHERE relation.account_id = p_account_id
|
|
672
|
+
AND relation.scope_kind = 'workspace'
|
|
673
|
+
AND relation.scope_workspace_id = p_workspace_id
|
|
674
|
+
AND relation.scope_subject_id IS NULL
|
|
675
|
+
AND relation.relation_type = 'conflicts_with'
|
|
676
|
+
AND (relation.from_claim_id = p_claim_id OR relation.to_claim_id = p_claim_id)
|
|
677
|
+
UNION ALL
|
|
678
|
+
SELECT contradiction.id
|
|
679
|
+
FROM knowledge_claim_evidence contradiction
|
|
680
|
+
WHERE contradiction.account_id = p_account_id
|
|
681
|
+
AND contradiction.scope_kind = 'workspace'
|
|
682
|
+
AND contradiction.scope_workspace_id = p_workspace_id
|
|
683
|
+
AND contradiction.scope_subject_id IS NULL
|
|
684
|
+
AND contradiction.claim_id = p_claim_id
|
|
685
|
+
AND contradiction.polarity = 'contradicts'
|
|
686
|
+
) conflicts;
|
|
687
|
+
|
|
688
|
+
revoked_value := revoked_value OR review_row.state = 'revoked';
|
|
689
|
+
stale_value := proposal_row.status <> 'proposed'
|
|
690
|
+
OR claim_row.effective_at > pg_catalog.transaction_timestamp()
|
|
691
|
+
OR (
|
|
692
|
+
claim_row.expires_at IS NOT NULL
|
|
693
|
+
AND claim_row.expires_at <= pg_catalog.transaction_timestamp()
|
|
694
|
+
)
|
|
695
|
+
OR review_row.state IN ('approved', 'rejected');
|
|
696
|
+
|
|
697
|
+
IF effective_mode_value = 'off' THEN
|
|
698
|
+
reason_codes_value := pg_catalog.array_append(reason_codes_value, 'policy_off');
|
|
699
|
+
END IF;
|
|
700
|
+
IF revoked_value THEN
|
|
701
|
+
reason_codes_value := pg_catalog.array_append(reason_codes_value, 'evidence_revoked');
|
|
702
|
+
END IF;
|
|
703
|
+
IF stale_value THEN
|
|
704
|
+
reason_codes_value := pg_catalog.array_append(reason_codes_value, 'proposal_stale');
|
|
705
|
+
END IF;
|
|
706
|
+
IF conflict_count_value > 0 THEN
|
|
707
|
+
reason_codes_value := pg_catalog.array_append(reason_codes_value, 'evidence_conflict');
|
|
708
|
+
END IF;
|
|
709
|
+
IF claim_row.confidence_bps < 8500 THEN
|
|
710
|
+
reason_codes_value := pg_catalog.array_append(reason_codes_value, 'confidence_below_floor');
|
|
711
|
+
END IF;
|
|
712
|
+
IF effective_mode_value = 'suggest' THEN
|
|
713
|
+
reason_codes_value := pg_catalog.array_append(reason_codes_value, 'policy_suggest');
|
|
714
|
+
END IF;
|
|
715
|
+
IF effective_mode_value = 'automatic' THEN
|
|
716
|
+
reason_codes_value := pg_catalog.array_append(reason_codes_value, 'policy_automatic');
|
|
717
|
+
END IF;
|
|
718
|
+
|
|
719
|
+
outcome_value := CASE
|
|
720
|
+
WHEN effective_mode_value = 'off' THEN 'off'
|
|
721
|
+
WHEN revoked_value THEN 'revoked'
|
|
722
|
+
WHEN stale_value THEN 'stale'
|
|
723
|
+
WHEN conflict_count_value > 0 THEN 'conflict'
|
|
724
|
+
WHEN claim_row.confidence_bps < 8500 THEN 'confidence'
|
|
725
|
+
ELSE effective_mode_value
|
|
726
|
+
END;
|
|
727
|
+
|
|
728
|
+
INSERT INTO governed_learning_decision_receipts (
|
|
729
|
+
account_id, workspace_id, operation_id, input_hash,
|
|
730
|
+
session_id, turn_id, attempt_id, execution_generation,
|
|
731
|
+
initiating_human_subject_id, policy_snapshot_id, policy_snapshot_hash,
|
|
732
|
+
policy_revision_id, policy_activation_version, source_kind, source_id,
|
|
733
|
+
proposal_id, proposal_input_hash, proposal_content_hash,
|
|
734
|
+
claim_id, claim_input_hash, evidence_id, evidence_input_hash,
|
|
735
|
+
evidence_content_hash, evidence_authority_hash, review_revision, review_state,
|
|
736
|
+
effective_mode, confidence_bps, conflict_count, outcome, reason_codes,
|
|
737
|
+
automatic_eligible, confidence_floor_bps
|
|
738
|
+
) VALUES (
|
|
739
|
+
p_account_id, p_workspace_id, p_operation_id, calculated_input_hash,
|
|
740
|
+
p_session_id, p_turn_id, p_attempt_id, p_execution_generation,
|
|
741
|
+
caller_subject_id, p_policy_snapshot_id, snapshot_row.snapshot_hash,
|
|
742
|
+
snapshot_row.revision_id, snapshot_row.activation_version, source_kind_value,
|
|
743
|
+
source_id_value, p_proposal_id, proposal_row.input_hash,
|
|
744
|
+
proposal_row.content_hash, p_claim_id, claim_row.input_hash, p_evidence_id,
|
|
745
|
+
evidence_row.input_hash, evidence_row.content_hash, authority_hash_value,
|
|
746
|
+
review_row.review_revision, review_row.state, effective_mode_value,
|
|
747
|
+
claim_row.confidence_bps, conflict_count_value, outcome_value,
|
|
748
|
+
reason_codes_value, outcome_value = 'automatic', 8500
|
|
749
|
+
) RETURNING * INTO receipt_row;
|
|
750
|
+
|
|
751
|
+
RETURN QUERY SELECT
|
|
752
|
+
receipt_row.id, receipt_row.operation_id, receipt_row.input_hash,
|
|
753
|
+
receipt_row.account_id, receipt_row.workspace_id, receipt_row.session_id,
|
|
754
|
+
receipt_row.turn_id, receipt_row.attempt_id, receipt_row.execution_generation,
|
|
755
|
+
receipt_row.initiating_human_subject_id, receipt_row.policy_snapshot_id,
|
|
756
|
+
receipt_row.policy_snapshot_hash, receipt_row.policy_revision_id,
|
|
757
|
+
receipt_row.policy_activation_version, receipt_row.source_kind,
|
|
758
|
+
receipt_row.source_id, receipt_row.proposal_id, receipt_row.proposal_input_hash,
|
|
759
|
+
receipt_row.proposal_content_hash, receipt_row.claim_id,
|
|
760
|
+
receipt_row.claim_input_hash, receipt_row.evidence_id,
|
|
761
|
+
receipt_row.evidence_input_hash, receipt_row.evidence_content_hash,
|
|
762
|
+
receipt_row.evidence_authority_hash, receipt_row.review_revision,
|
|
763
|
+
receipt_row.review_state, receipt_row.effective_mode,
|
|
764
|
+
receipt_row.confidence_bps, receipt_row.conflict_count,
|
|
765
|
+
receipt_row.outcome, receipt_row.reason_codes, receipt_row.automatic_eligible,
|
|
766
|
+
receipt_row.confidence_floor_bps, receipt_row.created_at;
|
|
767
|
+
END;
|
|
768
|
+
$$;
|
|
769
|
+
|
|
770
|
+
REVOKE ALL ON TABLE "governed_learning_decision_receipts" FROM PUBLIC;
|
|
771
|
+
REVOKE ALL ON FUNCTION evaluate_governed_learning_proposal(
|
|
772
|
+
uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid,uuid,uuid
|
|
773
|
+
) FROM PUBLIC;
|
|
774
|
+
|
|
775
|
+
DO $governed_learning_authority$
|
|
776
|
+
DECLARE
|
|
777
|
+
data_schema text := pg_catalog.current_schema();
|
|
778
|
+
BEGIN
|
|
779
|
+
IF pg_catalog.to_regclass(
|
|
780
|
+
pg_catalog.format('%I.workspace_learning_policy_snapshots', data_schema)
|
|
781
|
+
) IS NULL
|
|
782
|
+
OR pg_catalog.to_regclass(
|
|
783
|
+
pg_catalog.format('%I.knowledge_change_proposals', data_schema)
|
|
784
|
+
) IS NULL
|
|
785
|
+
OR pg_catalog.to_regprocedure(
|
|
786
|
+
pg_catalog.format('%I.session_reference_visible(uuid,uuid,uuid)', data_schema)
|
|
787
|
+
) IS NULL
|
|
788
|
+
THEN
|
|
789
|
+
RAISE EXCEPTION 'governed-learning evaluator predecessor authority is incomplete'
|
|
790
|
+
USING ERRCODE = '42P01';
|
|
791
|
+
END IF;
|
|
792
|
+
|
|
793
|
+
EXECUTE pg_catalog.format(
|
|
794
|
+
'ALTER FUNCTION %I.reject_governed_learning_decision_receipt_mutation() '
|
|
795
|
+
|| 'SET search_path = pg_catalog, %I, pg_temp',
|
|
796
|
+
data_schema, data_schema
|
|
797
|
+
);
|
|
798
|
+
EXECUTE pg_catalog.format(
|
|
799
|
+
'ALTER FUNCTION %I.evaluate_governed_learning_proposal('
|
|
800
|
+
|| 'uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid,uuid,uuid) '
|
|
801
|
+
|| 'SET search_path = pg_catalog, %I, pg_temp',
|
|
802
|
+
data_schema, data_schema
|
|
803
|
+
);
|
|
804
|
+
EXECUTE pg_catalog.format(
|
|
805
|
+
'REVOKE ALL ON FUNCTION %I.evaluate_governed_learning_proposal('
|
|
806
|
+
|| 'uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid,uuid,uuid) FROM PUBLIC',
|
|
807
|
+
data_schema
|
|
808
|
+
);
|
|
809
|
+
EXECUTE pg_catalog.format(
|
|
810
|
+
'REVOKE ALL ON TABLE %I.governed_learning_decision_receipts FROM PUBLIC',
|
|
811
|
+
data_schema
|
|
812
|
+
);
|
|
813
|
+
IF EXISTS (SELECT 1 FROM pg_catalog.pg_roles WHERE rolname = 'opengeni_app') THEN
|
|
814
|
+
EXECUTE pg_catalog.format(
|
|
815
|
+
'REVOKE ALL ON TABLE %I.governed_learning_decision_receipts FROM opengeni_app',
|
|
816
|
+
data_schema
|
|
817
|
+
);
|
|
818
|
+
EXECUTE pg_catalog.format(
|
|
819
|
+
'GRANT EXECUTE ON FUNCTION %I.evaluate_governed_learning_proposal('
|
|
820
|
+
|| 'uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid,uuid,uuid) TO opengeni_app',
|
|
821
|
+
data_schema
|
|
822
|
+
);
|
|
823
|
+
END IF;
|
|
824
|
+
END
|
|
825
|
+
$governed_learning_authority$;
|