@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,109 @@
|
|
|
1
|
+
import { PersonalResourceAttachmentSummary, type PersonalResourceAttachmentIntent, USER_RESOURCE_ACTION_BY_KIND, type UserResourceDelegation, type UserResourceKind } from "@opengeni/contracts";
|
|
2
|
+
import { type Database } from "./database.js";
|
|
3
|
+
export type UserResourceAuthorityGrant = {
|
|
4
|
+
grantId: string;
|
|
5
|
+
targetWorkspaceId: string;
|
|
6
|
+
targetSessionId: string | null;
|
|
7
|
+
action: (typeof USER_RESOURCE_ACTION_BY_KIND)[UserResourceKind];
|
|
8
|
+
mode: "once" | "session" | "always";
|
|
9
|
+
context: "user_private" | "workspace_shared";
|
|
10
|
+
authorityEpoch: number | null;
|
|
11
|
+
generation: number;
|
|
12
|
+
status: "active" | "consumed" | "revoked" | "expired";
|
|
13
|
+
expiresAt: string | null;
|
|
14
|
+
delegation: UserResourceDelegation;
|
|
15
|
+
};
|
|
16
|
+
export type UserResourceAuthoritySummary = {
|
|
17
|
+
authorityId: string;
|
|
18
|
+
resourceKind: UserResourceKind;
|
|
19
|
+
resourceId: string;
|
|
20
|
+
originWorkspaceId: string | null;
|
|
21
|
+
generation: number;
|
|
22
|
+
status: "active" | "retained" | "revoked";
|
|
23
|
+
grants: UserResourceAuthorityGrant[];
|
|
24
|
+
};
|
|
25
|
+
export type AcceptedTurnPersonalResourceAttachment = {
|
|
26
|
+
summary: PersonalResourceAttachmentSummary;
|
|
27
|
+
replay: boolean;
|
|
28
|
+
};
|
|
29
|
+
export declare class PersonalResourceAttachmentAcceptanceError extends Error {
|
|
30
|
+
readonly kind: "invalid" | "forbidden" | "conflict";
|
|
31
|
+
readonly name = "PersonalResourceAttachmentAcceptanceError";
|
|
32
|
+
constructor(kind: "invalid" | "forbidden" | "conflict", options?: ErrorOptions);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Issue and freeze the locked session's personal Variable Set/Rig/Connected
|
|
36
|
+
* Machine closure on
|
|
37
|
+
* one already-inserted logical turn. The caller owns the surrounding accepted-
|
|
38
|
+
* work transaction; this helper must never be called as a standalone grant
|
|
39
|
+
* mutation.
|
|
40
|
+
*/
|
|
41
|
+
export declare function acceptTurnPersonalResourceAttachmentInTransaction(db: Database, input: {
|
|
42
|
+
accountId: string;
|
|
43
|
+
workspaceId: string;
|
|
44
|
+
sessionId: string;
|
|
45
|
+
turnId: string;
|
|
46
|
+
subjectId: string;
|
|
47
|
+
intent: PersonalResourceAttachmentIntent & {
|
|
48
|
+
expectedAuthorityEpoch: number;
|
|
49
|
+
};
|
|
50
|
+
}): Promise<AcceptedTurnPersonalResourceAttachment>;
|
|
51
|
+
export declare function listSelfUserResourceAuthorities(db: Database, input: {
|
|
52
|
+
accountId: string;
|
|
53
|
+
workspaceId: string;
|
|
54
|
+
subjectId: string;
|
|
55
|
+
resourceKind: UserResourceKind;
|
|
56
|
+
cursor?: string | undefined;
|
|
57
|
+
limit: number;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
authorities: UserResourceAuthoritySummary[];
|
|
60
|
+
nextCursor: string | null;
|
|
61
|
+
}>;
|
|
62
|
+
export declare function issueSelfUserResourceGrant(db: Database, input: {
|
|
63
|
+
accountId: string;
|
|
64
|
+
workspaceId: string;
|
|
65
|
+
subjectId: string;
|
|
66
|
+
authorityId: string;
|
|
67
|
+
resourceKind: UserResourceKind;
|
|
68
|
+
mode: "session" | "always";
|
|
69
|
+
context: "user_private" | "workspace_shared";
|
|
70
|
+
sessionId?: string | null;
|
|
71
|
+
expectedAuthorityEpoch?: number | null;
|
|
72
|
+
workspaceSharedAcknowledged: boolean;
|
|
73
|
+
}): Promise<UserResourceAuthorityGrant>;
|
|
74
|
+
export declare function revokeSelfUserResourceGrant(db: Database, input: {
|
|
75
|
+
accountId: string;
|
|
76
|
+
workspaceId: string;
|
|
77
|
+
subjectId: string;
|
|
78
|
+
grantId: string;
|
|
79
|
+
}): Promise<{
|
|
80
|
+
grantId: string;
|
|
81
|
+
generation: number;
|
|
82
|
+
status: "revoked";
|
|
83
|
+
revokedAt: string;
|
|
84
|
+
}>;
|
|
85
|
+
export declare function resolveSessionAttemptPersonalResources(db: Database, input: {
|
|
86
|
+
accountId: string;
|
|
87
|
+
workspaceId: string;
|
|
88
|
+
subjectId: string | null;
|
|
89
|
+
attemptId: string;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
export type PersonalDocumentAuthority = {
|
|
92
|
+
authorityId: string;
|
|
93
|
+
ownerOrganizationMembershipId: string;
|
|
94
|
+
authorityGeneration: number;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Create the common organization-user authority before inserting a personal
|
|
98
|
+
* Document. Returns null for a configured/local or rolling-legacy subject that
|
|
99
|
+
* has no eligible active organization membership, preserving the existing
|
|
100
|
+
* workspace-anchored personal lane. Call this inside the same database
|
|
101
|
+
* transaction as the Document insert so a failed write cannot leave an orphan
|
|
102
|
+
* authority.
|
|
103
|
+
*/
|
|
104
|
+
export declare function createPersonalDocumentAuthority(db: Database, input: {
|
|
105
|
+
accountId: string;
|
|
106
|
+
workspaceId: string;
|
|
107
|
+
subjectId: string;
|
|
108
|
+
documentId: string;
|
|
109
|
+
}): Promise<PersonalDocumentAuthority | null>;
|
package/dist/video-generation.js
CHANGED
|
@@ -29,9 +29,9 @@ import {
|
|
|
29
29
|
settleVideoGenerationFailure,
|
|
30
30
|
settleVideoGenerationReady,
|
|
31
31
|
updateWorkspaceVideoGenerationPolicy
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
34
|
-
import "./chunk-
|
|
32
|
+
} from "./chunk-NJVZPWXY.js";
|
|
33
|
+
import "./chunk-SCPUJS53.js";
|
|
34
|
+
import "./chunk-PR2WMLOQ.js";
|
|
35
35
|
import "./chunk-PZ5AY32C.js";
|
|
36
36
|
export {
|
|
37
37
|
ACTIVE_VIDEO_GENERATION_STATUSES,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type Database } from "./database.js";
|
|
2
|
+
/**
|
|
3
|
+
* THE canonical live-workspace-authority resolver for one exact subject, run on
|
|
4
|
+
* a handle that is ALREADY inside the caller's transaction with that subject's
|
|
5
|
+
* RLS context applied.
|
|
6
|
+
*
|
|
7
|
+
* `getWorkspaceGrant` is a bare `workspace_memberships` join and is therefore
|
|
8
|
+
* NOT a complete authority answer: a managed human's personal workspace
|
|
9
|
+
* deliberately has no row in that table (migration 0219 raises on one), so its
|
|
10
|
+
* owner's access is the `organization_memberships.personal_workspace_id`
|
|
11
|
+
* pointer instead. Any seam that re-derives "does this subject still hold
|
|
12
|
+
* workspace authority here" from that bare join denies the one human who always
|
|
13
|
+
* belongs. This module exists so that rule has exactly one implementation.
|
|
14
|
+
*
|
|
15
|
+
* Seams that must serialize the answer with their own writes — session listing,
|
|
16
|
+
* session pins, the composer draft — call this variant so the read and the write
|
|
17
|
+
* share one transaction snapshot and one advisory fence. Seams that need to ask
|
|
18
|
+
* about a subject that is NOT the caller call
|
|
19
|
+
* {@link namedSubjectHasLiveWorkspaceAuthority} (`@opengeni/db`), which is a thin
|
|
20
|
+
* scope wrapper over exactly this body.
|
|
21
|
+
*
|
|
22
|
+
* True when the subject currently holds workspace authority the same way the
|
|
23
|
+
* route-time access builder derives it: a `workspace_memberships` row whose
|
|
24
|
+
* owning organization membership (when one exists) is active, or an active
|
|
25
|
+
* organization membership whose personal-workspace pointer is exactly this
|
|
26
|
+
* workspace. Never infers authority any other way; a deleted membership row and
|
|
27
|
+
* a suspended/revoked organization membership are both false. Only the
|
|
28
|
+
* membership's own `personal_workspace_id` counts as stated authority — nothing
|
|
29
|
+
* is read from `created_by`, a default workspace, a resource name, or current
|
|
30
|
+
* access.
|
|
31
|
+
*
|
|
32
|
+
* # This function is NOT an authorization. Read this before relying on it.
|
|
33
|
+
*
|
|
34
|
+
* It answers "does subject X hold authority over workspace W". It does NOT
|
|
35
|
+
* establish that the caller is X. Nothing here authenticates anybody.
|
|
36
|
+
*
|
|
37
|
+
* The scope assertion below is a **consistency check, not an authorization**.
|
|
38
|
+
* It prevents one thing: a caller naming a third-party subject while its
|
|
39
|
+
* transaction is scoped to someone else. It cannot detect a caller that scoped
|
|
40
|
+
* the transaction to an attacker-chosen subject in the first place, because
|
|
41
|
+
* `withWorkspaceSubjectRls(db, workspaceId, subjectId, ...)` takes that subject
|
|
42
|
+
* from its argument too. At today's three call sites both sides come from the
|
|
43
|
+
* same variable, so the check is a tautology there and fires only if a future
|
|
44
|
+
* refactor makes them diverge. Treat it as a tripwire against that refactor —
|
|
45
|
+
* never as evidence that the subject was authenticated.
|
|
46
|
+
*
|
|
47
|
+
* **The actual authorization for the personal-workspace exception lives in the
|
|
48
|
+
* API layer**: `AccessGrantAuthorization.canonicalManagedHumanSession`
|
|
49
|
+
* (`@opengeni/core`), stamped only where a Better Auth cookie was verified. A
|
|
50
|
+
* caller that has not proven that must not enable the exception. If you are
|
|
51
|
+
* adding a caller, that stamp is the part you have to get right; this function
|
|
52
|
+
* will happily answer `true` for any subject you scope a transaction to.
|
|
53
|
+
*
|
|
54
|
+
* Non-`user:` subjects (API keys, delegated service principals, configured and
|
|
55
|
+
* local principals) can never own an organization membership, so they
|
|
56
|
+
* short-circuit to the plain membership answer instead of tripping
|
|
57
|
+
* `list_self_organization_memberships`' `42501`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function subjectHasLiveWorkspaceAuthorityInScope(scopedDb: Database, input: {
|
|
60
|
+
accountId: string;
|
|
61
|
+
workspaceId: string;
|
|
62
|
+
subjectId: string;
|
|
63
|
+
}): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* The applied subject GUC, or `""` when none is set. `""` is the canonical
|
|
66
|
+
* "unset" for this GUC: `current_subject_id()` is
|
|
67
|
+
* `nullif(current_setting('opengeni.subject_id', true), '')` (0239 precedent), so
|
|
68
|
+
* a caller restoring `""` genuinely clears it rather than pinning an empty
|
|
69
|
+
* subject. Never throws, so it is safe for capturing a prior value that may
|
|
70
|
+
* legitimately be absent.
|
|
71
|
+
*/
|
|
72
|
+
export declare function rlsSubjectIdOrEmpty(scopedDb: Database): Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* The tenant account of the caller's ALREADY-applied RLS scope. `withRlsContext`
|
|
75
|
+
* sets and read-back-verifies this GUC on the pinned backend before running the
|
|
76
|
+
* scoped body, so it is exact rather than a re-derivation — which lets a seam
|
|
77
|
+
* that only received a workspace id consult
|
|
78
|
+
* {@link subjectHasLiveWorkspaceAuthorityInScope} without a second round trip to
|
|
79
|
+
* resolve the account.
|
|
80
|
+
*/
|
|
81
|
+
export declare function accountIdInRlsScope(scopedDb: Database): Promise<string>;
|
|
@@ -801,6 +801,285 @@ export declare const workspaceInstructionPolicyActivationEvents: import("drizzle
|
|
|
801
801
|
};
|
|
802
802
|
dialect: 'pg';
|
|
803
803
|
}>;
|
|
804
|
+
export declare const workspaceInstructionPolicyDeactivationEvents: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
805
|
+
name: "workspace_instruction_policy_deactivation_events";
|
|
806
|
+
schema: undefined;
|
|
807
|
+
columns: {
|
|
808
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
809
|
+
name: "id";
|
|
810
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
811
|
+
dataType: "string";
|
|
812
|
+
columnType: "PgUUID";
|
|
813
|
+
data: string;
|
|
814
|
+
driverParam: string;
|
|
815
|
+
notNull: true;
|
|
816
|
+
hasDefault: true;
|
|
817
|
+
isPrimaryKey: true;
|
|
818
|
+
isAutoincrement: false;
|
|
819
|
+
hasRuntimeDefault: false;
|
|
820
|
+
enumValues: undefined;
|
|
821
|
+
baseColumn: never;
|
|
822
|
+
identity: undefined;
|
|
823
|
+
generated: undefined;
|
|
824
|
+
}, {}, {}>;
|
|
825
|
+
operationId: import("drizzle-orm/pg-core").PgColumn<{
|
|
826
|
+
name: "operation_id";
|
|
827
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
828
|
+
dataType: "string";
|
|
829
|
+
columnType: "PgUUID";
|
|
830
|
+
data: string;
|
|
831
|
+
driverParam: string;
|
|
832
|
+
notNull: true;
|
|
833
|
+
hasDefault: false;
|
|
834
|
+
isPrimaryKey: false;
|
|
835
|
+
isAutoincrement: false;
|
|
836
|
+
hasRuntimeDefault: false;
|
|
837
|
+
enumValues: undefined;
|
|
838
|
+
baseColumn: never;
|
|
839
|
+
identity: undefined;
|
|
840
|
+
generated: undefined;
|
|
841
|
+
}, {}, {}>;
|
|
842
|
+
requestFingerprint: import("drizzle-orm/pg-core").PgColumn<{
|
|
843
|
+
name: "request_fingerprint";
|
|
844
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
845
|
+
dataType: "string";
|
|
846
|
+
columnType: "PgText";
|
|
847
|
+
data: string;
|
|
848
|
+
driverParam: string;
|
|
849
|
+
notNull: true;
|
|
850
|
+
hasDefault: false;
|
|
851
|
+
isPrimaryKey: false;
|
|
852
|
+
isAutoincrement: false;
|
|
853
|
+
hasRuntimeDefault: false;
|
|
854
|
+
enumValues: [string, ...string[]];
|
|
855
|
+
baseColumn: never;
|
|
856
|
+
identity: undefined;
|
|
857
|
+
generated: undefined;
|
|
858
|
+
}, {}, {}>;
|
|
859
|
+
accountId: import("drizzle-orm/pg-core").PgColumn<{
|
|
860
|
+
name: "account_id";
|
|
861
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
862
|
+
dataType: "string";
|
|
863
|
+
columnType: "PgUUID";
|
|
864
|
+
data: string;
|
|
865
|
+
driverParam: string;
|
|
866
|
+
notNull: true;
|
|
867
|
+
hasDefault: false;
|
|
868
|
+
isPrimaryKey: false;
|
|
869
|
+
isAutoincrement: false;
|
|
870
|
+
hasRuntimeDefault: false;
|
|
871
|
+
enumValues: undefined;
|
|
872
|
+
baseColumn: never;
|
|
873
|
+
identity: undefined;
|
|
874
|
+
generated: undefined;
|
|
875
|
+
}, {}, {}>;
|
|
876
|
+
workspaceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
877
|
+
name: "workspace_id";
|
|
878
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
879
|
+
dataType: "string";
|
|
880
|
+
columnType: "PgUUID";
|
|
881
|
+
data: string;
|
|
882
|
+
driverParam: string;
|
|
883
|
+
notNull: true;
|
|
884
|
+
hasDefault: false;
|
|
885
|
+
isPrimaryKey: false;
|
|
886
|
+
isAutoincrement: false;
|
|
887
|
+
hasRuntimeDefault: false;
|
|
888
|
+
enumValues: undefined;
|
|
889
|
+
baseColumn: never;
|
|
890
|
+
identity: undefined;
|
|
891
|
+
generated: undefined;
|
|
892
|
+
}, {}, {}>;
|
|
893
|
+
kind: import("drizzle-orm/pg-core").PgColumn<{
|
|
894
|
+
name: "kind";
|
|
895
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
896
|
+
dataType: "string";
|
|
897
|
+
columnType: "PgText";
|
|
898
|
+
data: string;
|
|
899
|
+
driverParam: string;
|
|
900
|
+
notNull: true;
|
|
901
|
+
hasDefault: false;
|
|
902
|
+
isPrimaryKey: false;
|
|
903
|
+
isAutoincrement: false;
|
|
904
|
+
hasRuntimeDefault: false;
|
|
905
|
+
enumValues: [string, ...string[]];
|
|
906
|
+
baseColumn: never;
|
|
907
|
+
identity: undefined;
|
|
908
|
+
generated: undefined;
|
|
909
|
+
}, {}, {}>;
|
|
910
|
+
scope: import("drizzle-orm/pg-core").PgColumn<{
|
|
911
|
+
name: "scope";
|
|
912
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
913
|
+
dataType: "string";
|
|
914
|
+
columnType: "PgText";
|
|
915
|
+
data: string;
|
|
916
|
+
driverParam: string;
|
|
917
|
+
notNull: true;
|
|
918
|
+
hasDefault: false;
|
|
919
|
+
isPrimaryKey: false;
|
|
920
|
+
isAutoincrement: false;
|
|
921
|
+
hasRuntimeDefault: false;
|
|
922
|
+
enumValues: [string, ...string[]];
|
|
923
|
+
baseColumn: never;
|
|
924
|
+
identity: undefined;
|
|
925
|
+
generated: undefined;
|
|
926
|
+
}, {}, {}>;
|
|
927
|
+
roleKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
928
|
+
name: "role_key";
|
|
929
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
930
|
+
dataType: "string";
|
|
931
|
+
columnType: "PgText";
|
|
932
|
+
data: string;
|
|
933
|
+
driverParam: string;
|
|
934
|
+
notNull: false;
|
|
935
|
+
hasDefault: false;
|
|
936
|
+
isPrimaryKey: false;
|
|
937
|
+
isAutoincrement: false;
|
|
938
|
+
hasRuntimeDefault: false;
|
|
939
|
+
enumValues: [string, ...string[]];
|
|
940
|
+
baseColumn: never;
|
|
941
|
+
identity: undefined;
|
|
942
|
+
generated: undefined;
|
|
943
|
+
}, {}, {}>;
|
|
944
|
+
type: import("drizzle-orm/pg-core").PgColumn<{
|
|
945
|
+
name: "type";
|
|
946
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
947
|
+
dataType: "string";
|
|
948
|
+
columnType: "PgText";
|
|
949
|
+
data: string;
|
|
950
|
+
driverParam: string;
|
|
951
|
+
notNull: true;
|
|
952
|
+
hasDefault: false;
|
|
953
|
+
isPrimaryKey: false;
|
|
954
|
+
isAutoincrement: false;
|
|
955
|
+
hasRuntimeDefault: false;
|
|
956
|
+
enumValues: [string, ...string[]];
|
|
957
|
+
baseColumn: never;
|
|
958
|
+
identity: undefined;
|
|
959
|
+
generated: undefined;
|
|
960
|
+
}, {}, {}>;
|
|
961
|
+
activationVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
962
|
+
name: "activation_version";
|
|
963
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
964
|
+
dataType: "number";
|
|
965
|
+
columnType: "PgBigInt53";
|
|
966
|
+
data: number;
|
|
967
|
+
driverParam: string | number;
|
|
968
|
+
notNull: true;
|
|
969
|
+
hasDefault: false;
|
|
970
|
+
isPrimaryKey: false;
|
|
971
|
+
isAutoincrement: false;
|
|
972
|
+
hasRuntimeDefault: false;
|
|
973
|
+
enumValues: undefined;
|
|
974
|
+
baseColumn: never;
|
|
975
|
+
identity: undefined;
|
|
976
|
+
generated: undefined;
|
|
977
|
+
}, {}, {}>;
|
|
978
|
+
oldRevisionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
979
|
+
name: "old_revision_id";
|
|
980
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
981
|
+
dataType: "string";
|
|
982
|
+
columnType: "PgUUID";
|
|
983
|
+
data: string;
|
|
984
|
+
driverParam: string;
|
|
985
|
+
notNull: true;
|
|
986
|
+
hasDefault: false;
|
|
987
|
+
isPrimaryKey: false;
|
|
988
|
+
isAutoincrement: false;
|
|
989
|
+
hasRuntimeDefault: false;
|
|
990
|
+
enumValues: undefined;
|
|
991
|
+
baseColumn: never;
|
|
992
|
+
identity: undefined;
|
|
993
|
+
generated: undefined;
|
|
994
|
+
}, {}, {}>;
|
|
995
|
+
oldRevision: import("drizzle-orm/pg-core").PgColumn<{
|
|
996
|
+
name: "old_revision";
|
|
997
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
998
|
+
dataType: "number";
|
|
999
|
+
columnType: "PgBigInt53";
|
|
1000
|
+
data: number;
|
|
1001
|
+
driverParam: string | number;
|
|
1002
|
+
notNull: true;
|
|
1003
|
+
hasDefault: false;
|
|
1004
|
+
isPrimaryKey: false;
|
|
1005
|
+
isAutoincrement: false;
|
|
1006
|
+
hasRuntimeDefault: false;
|
|
1007
|
+
enumValues: undefined;
|
|
1008
|
+
baseColumn: never;
|
|
1009
|
+
identity: undefined;
|
|
1010
|
+
generated: undefined;
|
|
1011
|
+
}, {}, {}>;
|
|
1012
|
+
oldContentHash: import("drizzle-orm/pg-core").PgColumn<{
|
|
1013
|
+
name: "old_content_hash";
|
|
1014
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
1015
|
+
dataType: "string";
|
|
1016
|
+
columnType: "PgText";
|
|
1017
|
+
data: string;
|
|
1018
|
+
driverParam: string;
|
|
1019
|
+
notNull: true;
|
|
1020
|
+
hasDefault: false;
|
|
1021
|
+
isPrimaryKey: false;
|
|
1022
|
+
isAutoincrement: false;
|
|
1023
|
+
hasRuntimeDefault: false;
|
|
1024
|
+
enumValues: [string, ...string[]];
|
|
1025
|
+
baseColumn: never;
|
|
1026
|
+
identity: undefined;
|
|
1027
|
+
generated: undefined;
|
|
1028
|
+
}, {}, {}>;
|
|
1029
|
+
actorSubjectId: import("drizzle-orm/pg-core").PgColumn<{
|
|
1030
|
+
name: "actor_subject_id";
|
|
1031
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
1032
|
+
dataType: "string";
|
|
1033
|
+
columnType: "PgText";
|
|
1034
|
+
data: string;
|
|
1035
|
+
driverParam: string;
|
|
1036
|
+
notNull: true;
|
|
1037
|
+
hasDefault: false;
|
|
1038
|
+
isPrimaryKey: false;
|
|
1039
|
+
isAutoincrement: false;
|
|
1040
|
+
hasRuntimeDefault: false;
|
|
1041
|
+
enumValues: [string, ...string[]];
|
|
1042
|
+
baseColumn: never;
|
|
1043
|
+
identity: undefined;
|
|
1044
|
+
generated: undefined;
|
|
1045
|
+
}, {}, {}>;
|
|
1046
|
+
reason: import("drizzle-orm/pg-core").PgColumn<{
|
|
1047
|
+
name: "reason";
|
|
1048
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
1049
|
+
dataType: "string";
|
|
1050
|
+
columnType: "PgText";
|
|
1051
|
+
data: string;
|
|
1052
|
+
driverParam: string;
|
|
1053
|
+
notNull: true;
|
|
1054
|
+
hasDefault: false;
|
|
1055
|
+
isPrimaryKey: false;
|
|
1056
|
+
isAutoincrement: false;
|
|
1057
|
+
hasRuntimeDefault: false;
|
|
1058
|
+
enumValues: [string, ...string[]];
|
|
1059
|
+
baseColumn: never;
|
|
1060
|
+
identity: undefined;
|
|
1061
|
+
generated: undefined;
|
|
1062
|
+
}, {}, {}>;
|
|
1063
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
1064
|
+
name: "created_at";
|
|
1065
|
+
tableName: "workspace_instruction_policy_deactivation_events";
|
|
1066
|
+
dataType: "date";
|
|
1067
|
+
columnType: "PgTimestamp";
|
|
1068
|
+
data: Date;
|
|
1069
|
+
driverParam: string;
|
|
1070
|
+
notNull: true;
|
|
1071
|
+
hasDefault: true;
|
|
1072
|
+
isPrimaryKey: false;
|
|
1073
|
+
isAutoincrement: false;
|
|
1074
|
+
hasRuntimeDefault: false;
|
|
1075
|
+
enumValues: undefined;
|
|
1076
|
+
baseColumn: never;
|
|
1077
|
+
identity: undefined;
|
|
1078
|
+
generated: undefined;
|
|
1079
|
+
}, {}, {}>;
|
|
1080
|
+
};
|
|
1081
|
+
dialect: 'pg';
|
|
1082
|
+
}>;
|
|
804
1083
|
export declare const workspaceInstructionPolicyOnboardingProposals: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
805
1084
|
name: "workspace_instruction_policy_onboarding_proposals";
|
|
806
1085
|
schema: undefined;
|
|
@@ -34,6 +34,18 @@ type OnboardingProposalRequestInput = WorkspaceInstructionPolicyTarget & {
|
|
|
34
34
|
expectedActivationVersion: number;
|
|
35
35
|
createdBySubjectId: string;
|
|
36
36
|
};
|
|
37
|
+
export type WorkspaceInstructionPolicyKnowledgeProposalInput = WorkspaceInstructionPolicyTarget & {
|
|
38
|
+
operationId: string;
|
|
39
|
+
accountId: string;
|
|
40
|
+
workspaceId: string;
|
|
41
|
+
content: string;
|
|
42
|
+
knowledgeProposalId: string;
|
|
43
|
+
knowledgeProposalContentHash: string;
|
|
44
|
+
confidenceBps: number;
|
|
45
|
+
expectedCurrentRevisionId: string | null;
|
|
46
|
+
expectedActivationVersion: number;
|
|
47
|
+
createdBySubjectId: string;
|
|
48
|
+
};
|
|
37
49
|
export declare class WorkspaceInstructionPolicyConflictError extends Error {
|
|
38
50
|
readonly currentHead: WorkspaceInstructionPolicyHead | null;
|
|
39
51
|
readonly name = "WorkspaceInstructionPolicyConflictError";
|
|
@@ -61,6 +73,14 @@ export declare class WorkspaceInstructionPolicyOnboardingProposalContentError ex
|
|
|
61
73
|
readonly name = "WorkspaceInstructionPolicyOnboardingProposalContentError";
|
|
62
74
|
constructor(code: "WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_EMPTY" | "WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_OVERSIZED");
|
|
63
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The exact diagnostic `activate_human_confirmed_learning_decision` raises when
|
|
78
|
+
* a proposal's compare-and-set baseline no longer matches the live head. It is
|
|
79
|
+
* matched by message because the SQLSTATE (40001) is shared with other
|
|
80
|
+
* conflicts. Kept here so the SQL and the code that keys recovery off it cannot
|
|
81
|
+
* drift apart silently - the migration test pins the same string.
|
|
82
|
+
*/
|
|
83
|
+
export declare const INSTRUCTION_POLICY_STALE_BASELINE_DIAGNOSTIC = "instruction-policy proposal baseline is stale";
|
|
64
84
|
export declare class WorkspaceInstructionPolicyOnboardingProposalStaleError extends Error {
|
|
65
85
|
readonly currentHead: WorkspaceInstructionPolicyHead | null;
|
|
66
86
|
readonly name = "WorkspaceInstructionPolicyOnboardingProposalStaleError";
|
|
@@ -123,6 +143,33 @@ export declare function importLegacyWorkspaceInstructionPolicyDraft(db: Database
|
|
|
123
143
|
export declare function createWorkspaceInstructionPolicyOnboardingProposal(db: Database, input: Omit<OnboardingProposalRequestInput, "operationId"> & {
|
|
124
144
|
operationId?: string;
|
|
125
145
|
}): Promise<WorkspaceInstructionPolicyOnboardingProposal>;
|
|
146
|
+
/**
|
|
147
|
+
* Materialize an immutable Knowledge change proposal as an inactive instruction
|
|
148
|
+
* draft. Human activation remains exclusively in the existing lifecycle API.
|
|
149
|
+
*/
|
|
150
|
+
export declare function createWorkspaceInstructionPolicyKnowledgeProposal(db: Database, input: WorkspaceInstructionPolicyKnowledgeProposalInput): Promise<WorkspaceInstructionPolicyOnboardingProposal>;
|
|
151
|
+
/**
|
|
152
|
+
* Add a successor instruction-policy proposal for a knowledge proposal whose
|
|
153
|
+
* existing proposal was left behind by a moved head.
|
|
154
|
+
*
|
|
155
|
+
* This exists for one case: the human already answered "save", and only then
|
|
156
|
+
* did the head move. Re-asking them would be the alternative. The successor
|
|
157
|
+
* reuses the exact immutable source facts of the stranded proposal - same
|
|
158
|
+
* knowledge proposal id, same content hash, same target, same author - so the
|
|
159
|
+
* human's confirmation, which is bound to the knowledge proposal id, still
|
|
160
|
+
* describes precisely what gets activated. Only the compare-and-set baseline
|
|
161
|
+
* and the draft's place in the revision chain move forward.
|
|
162
|
+
*
|
|
163
|
+
* Returns the existing proposal unchanged when it is already current, so a
|
|
164
|
+
* retry of the same confirmation is idempotent.
|
|
165
|
+
*/
|
|
166
|
+
export declare function rebaselineWorkspaceInstructionPolicyKnowledgeProposal(db: Database, input: {
|
|
167
|
+
accountId: string;
|
|
168
|
+
workspaceId: string;
|
|
169
|
+
knowledgeProposalId: string;
|
|
170
|
+
operationId: string;
|
|
171
|
+
initiatingHumanSubjectId: string;
|
|
172
|
+
}): Promise<WorkspaceInstructionPolicyOnboardingProposal>;
|
|
126
173
|
export declare function listWorkspaceInstructionPolicyOnboardingProposals(db: Database, workspaceId: string, query: WorkspaceInstructionPolicyOnboardingProposalListQuery): Promise<WorkspaceInstructionPolicyOnboardingProposalListResponse>;
|
|
127
174
|
export declare function listWorkspaceInstructionPolicyRevisions(db: Database, workspaceId: string, query: WorkspaceInstructionPolicyListQuery): Promise<WorkspaceInstructionPolicyListResponse>;
|
|
128
175
|
export declare function getWorkspaceInstructionPolicyRevision(db: Database, workspaceId: string, revisionId: string): Promise<WorkspaceInstructionPolicyRevision>;
|
|
@@ -185,4 +232,19 @@ export declare function getOrCreateWorkspaceInstructionPolicySnapshot(db: Databa
|
|
|
185
232
|
content: string;
|
|
186
233
|
}[];
|
|
187
234
|
}>;
|
|
235
|
+
/**
|
|
236
|
+
* Current activation baseline for one instruction-policy target: the active
|
|
237
|
+
* head's revision (or null) and the CAS activation version that a new draft
|
|
238
|
+
* proposal must expect. A deactivated-to-null target keeps its monotonic
|
|
239
|
+
* boundary, so the version is the max of the head and latest deactivation.
|
|
240
|
+
* Read-only under workspace RLS; used by `remember` to bind a user-directed
|
|
241
|
+
* rule to the exact current baseline instead of assuming an empty workspace.
|
|
242
|
+
*/
|
|
243
|
+
export declare function getWorkspaceInstructionPolicyBaseline(db: Database, input: {
|
|
244
|
+
workspaceId: string;
|
|
245
|
+
target: WorkspaceInstructionPolicyTarget;
|
|
246
|
+
}): Promise<{
|
|
247
|
+
expectedCurrentRevisionId: string | null;
|
|
248
|
+
expectedActivationVersion: number;
|
|
249
|
+
}>;
|
|
188
250
|
export {};
|
|
@@ -156,6 +156,7 @@ export declare function listWorkspaceLearningPolicyHistory(db: Database, input:
|
|
|
156
156
|
head: WorkspaceLearningPolicyHead | null;
|
|
157
157
|
revisions: WorkspaceLearningPolicyRevision[];
|
|
158
158
|
events: WorkspaceLearningPolicyActivationEvent[];
|
|
159
|
+
truncated: boolean;
|
|
159
160
|
}>;
|
|
160
161
|
export declare function getOrCreateWorkspaceLearningPolicySnapshot(db: Database, claims: WorkspaceLearningPolicyAttemptClaims): Promise<WorkspaceLearningPolicySnapshot>;
|
|
161
162
|
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- Fence each Connected Machine to one live runner instance. The credential
|
|
3
|
+
-- generation proves enrollment authority; this independent connection lease
|
|
4
|
+
-- prevents two processes holding the same still-valid credential from sharing
|
|
5
|
+
-- one RPC subject and receiving work nondeterministically.
|
|
6
|
+
|
|
7
|
+
SET lock_timeout = '5s';
|
|
8
|
+
SET statement_timeout = '10min';
|
|
9
|
+
|
|
10
|
+
ALTER TABLE "enrollments"
|
|
11
|
+
ADD COLUMN "connection_instance_id" text,
|
|
12
|
+
ADD COLUMN "connection_generation" integer NOT NULL DEFAULT 0,
|
|
13
|
+
ADD COLUMN "connection_lease_expires_at" timestamptz,
|
|
14
|
+
ADD COLUMN "connection_duplicate_denied_count" integer NOT NULL DEFAULT 0,
|
|
15
|
+
ADD COLUMN "connection_duplicate_denied_at" timestamptz;
|
|
16
|
+
|
|
17
|
+
ALTER TABLE "enrollments"
|
|
18
|
+
ADD CONSTRAINT "enrollments_connection_authority_shape_chk" CHECK (
|
|
19
|
+
("connection_instance_id" IS NULL AND "connection_lease_expires_at" IS NULL)
|
|
20
|
+
OR ("connection_instance_id" IS NOT NULL
|
|
21
|
+
AND length("connection_instance_id") BETWEEN 1 AND 128
|
|
22
|
+
AND "connection_lease_expires_at" IS NOT NULL)
|
|
23
|
+
) NOT VALID,
|
|
24
|
+
ADD CONSTRAINT "enrollments_connection_generation_chk" CHECK (
|
|
25
|
+
"connection_generation" >= 0
|
|
26
|
+
) NOT VALID,
|
|
27
|
+
ADD CONSTRAINT "enrollments_connection_duplicate_denied_count_chk" CHECK (
|
|
28
|
+
"connection_duplicate_denied_count" >= 0
|
|
29
|
+
) NOT VALID;
|
|
30
|
+
|
|
31
|
+
ALTER TABLE "enrollments"
|
|
32
|
+
VALIDATE CONSTRAINT "enrollments_connection_authority_shape_chk";
|
|
33
|
+
ALTER TABLE "enrollments"
|
|
34
|
+
VALIDATE CONSTRAINT "enrollments_connection_generation_chk";
|
|
35
|
+
ALTER TABLE "enrollments"
|
|
36
|
+
VALIDATE CONSTRAINT "enrollments_connection_duplicate_denied_count_chk";
|
|
37
|
+
|
|
38
|
+
RESET statement_timeout;
|
|
39
|
+
RESET lock_timeout;
|