@capybara-hq/kernel 0.1.0-rc.126 → 0.1.0-rc.127
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/bootstrap.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"schemaVersion": 1,
|
|
4
4
|
"marketplace": {
|
|
5
5
|
"url": "https://github.com/capybara-hq/plugins.git",
|
|
6
|
-
"commit": "
|
|
6
|
+
"commit": "0b6d898d9481190adc74d5554dd53e78382b1e31"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"name": "device-local",
|
|
99
99
|
"source": "npm",
|
|
100
100
|
"npm": "@capybara-hq/plugin-device-local",
|
|
101
|
-
"version": "0.1.0-rc.
|
|
102
|
-
"integrity": "sha512-
|
|
101
|
+
"version": "0.1.0-rc.18",
|
|
102
|
+
"integrity": "sha512-i+0Ixm83k967TXjDh7EcgpwQSwKBMtHE1owhLfgg06zMzhkkrfAqE4YdegdRj0hFWf79rAYQwN95pYoMGLZBdw==",
|
|
103
103
|
"required": false,
|
|
104
104
|
"scope": "all"
|
|
105
105
|
},
|
|
@@ -3,7 +3,6 @@ import type { ColumnType, Generated, Kysely } from "kysely";
|
|
|
3
3
|
import type { ModelRef } from "../agents/definition.js";
|
|
4
4
|
import type { AutomationChat, AutomationEventMarker, AutomationMode, AutomationOrigin, AutomationPauseReason, AutomationPrincipal, AutomationStatus, AutomationTrigger, AutomationUnattendedAsk, ScheduleMarker, TaskRunSkipReason, TaskRunStatus } from "../automations/types.js";
|
|
5
5
|
import type { AccountAvatar } from "../identity/account-avatar.js";
|
|
6
|
-
import type { DeviceNetwork } from "../sandbox/modes.js";
|
|
7
6
|
import type { StartingExecutionGrants } from "../sandbox/operation-authority-types.js";
|
|
8
7
|
import type { AuthorityEpochVector } from "../sandbox/permission-authority-epochs.js";
|
|
9
8
|
import type { PermissionEscalation, PermissionExpansion, PermissionGrantSource, PermissionScopeKind } from "../sandbox/permission-call-types.js";
|
|
@@ -958,13 +957,13 @@ export interface AttachmentsTable {
|
|
|
958
957
|
pages: number | null;
|
|
959
958
|
created_at: Ts;
|
|
960
959
|
expires_at: TsNullable;
|
|
961
|
-
/**
|
|
962
|
-
purpose:
|
|
960
|
+
/** Attachment purposes are explicit on insert. */
|
|
961
|
+
purpose: AttachmentPurpose;
|
|
963
962
|
/** 0068: the agent whose profile uses this avatar upload (set once, when it is saved). */
|
|
964
963
|
agent_id: ColumnType<string | null, string | null | undefined, string | null>;
|
|
965
964
|
}
|
|
966
965
|
/**
|
|
967
|
-
* What an attachment row is for: a
|
|
966
|
+
* What an attachment row is for: a skill package zip, an agent avatar image, or
|
|
968
967
|
* (0163) an image the builtin Read stored with the calling conversation.
|
|
969
968
|
*/
|
|
970
969
|
export type AttachmentPurpose = "skill-package" | "agent-avatar" | "read";
|
|
@@ -1074,11 +1073,6 @@ export interface BackgroundTasksTable {
|
|
|
1074
1073
|
trigger_account_id: string;
|
|
1075
1074
|
description: string;
|
|
1076
1075
|
command: string;
|
|
1077
|
-
/**
|
|
1078
|
-
* A legacy row's session id (0071); NULL on every managed row. Never written after insert: no
|
|
1079
|
-
* launch records a SID any more (permission activation W5-P2), so updates are refused by type.
|
|
1080
|
-
*/
|
|
1081
|
-
sid: ColumnType<string | null, string | null | undefined, never>;
|
|
1082
1076
|
output_path: string;
|
|
1083
1077
|
status: ColumnType<"running" | "completed" | "failed" | "stopped" | "timed_out" | "lost", string | undefined, string>;
|
|
1084
1078
|
lost_reason: ColumnType<string | null, string | null | undefined, string | null>;
|
|
@@ -1088,14 +1082,13 @@ export interface BackgroundTasksTable {
|
|
|
1088
1082
|
deadline_at: Date | string;
|
|
1089
1083
|
/** NULL while the launch is reserved but not started (0071). */
|
|
1090
1084
|
sandbox_created_at: Date | string | null;
|
|
1091
|
-
kill_pending: ColumnType<boolean, boolean | undefined, boolean>;
|
|
1092
1085
|
read_offset: ColumnType<string, number | string | undefined, number | string>;
|
|
1093
1086
|
/** Set while a stop is under way (0072); the poller skips such a task. */
|
|
1094
1087
|
stopping_at: ColumnType<Date | null, Date | string | null | undefined, Date | string | null>;
|
|
1095
1088
|
/** 0088, renamed in 0105: the device the task runs in. */
|
|
1096
1089
|
device_id: ColumnType<string | null, string | null | undefined, string | null>;
|
|
1097
|
-
/** 0152: the durable launch state of a managed task
|
|
1098
|
-
launch_state:
|
|
1090
|
+
/** 0152: the durable launch state of a managed task. */
|
|
1091
|
+
launch_state: BackgroundLaunchState;
|
|
1099
1092
|
operation_id: NullableText;
|
|
1100
1093
|
input_digest: NullableText;
|
|
1101
1094
|
run_execution_id: NullableText;
|
|
@@ -1120,42 +1113,9 @@ export interface BackgroundTasksTable {
|
|
|
1120
1113
|
cancel_failure: ColumnType<"unreachable" | "failed" | null, "unreachable" | "failed" | null | undefined, "unreachable" | "failed" | null>;
|
|
1121
1114
|
/** 0184: that failure's message, clipped. */
|
|
1122
1115
|
cancel_failure_detail: NullableText;
|
|
1123
|
-
/** 0157: the exact incarnation a legacy dispatch was admitted for; null on historical rows. */
|
|
1124
|
-
legacy_dispatch_provider: NullableText;
|
|
1125
|
-
legacy_dispatch_generation: NullableText;
|
|
1126
|
-
/** 0157: whether a legacy launch may have dispatched its command (see the migration). */
|
|
1127
|
-
legacy_dispatch: ColumnType<"unknown" | "reserved" | "dispatched", "unknown" | "reserved" | "dispatched" | undefined, "unknown" | "reserved" | "dispatched">;
|
|
1128
|
-
}
|
|
1129
|
-
/** 0152: see the migration for the meaning of each state. */
|
|
1130
|
-
export type BackgroundLaunchState = "legacy" | "pending" | "dispatched" | "acknowledged" | "cancel-pending" | "terminal";
|
|
1131
|
-
/** 0023_sandboxes.sql: the legacy per-conversation sandbox; kept only for the cleanup job (0088). */
|
|
1132
|
-
export interface LegacySandboxesTable {
|
|
1133
|
-
conversation_id: string;
|
|
1134
|
-
org_id: string;
|
|
1135
|
-
provider: string;
|
|
1136
|
-
/** 提供方的 `SandboxHandle`;creating 时为 NULL。 */
|
|
1137
|
-
handle: ColumnType<{
|
|
1138
|
-
id: string;
|
|
1139
|
-
[k: string]: unknown;
|
|
1140
|
-
} | null, string | null | undefined, string | null>;
|
|
1141
|
-
status: "creating" | "running" | "suspended" | "destroyed";
|
|
1142
|
-
last_used_at: Ts;
|
|
1143
|
-
running_since: TsNullable;
|
|
1144
|
-
created_at: Ts;
|
|
1145
|
-
suspended_at: TsNullable;
|
|
1146
|
-
destroyed_at: TsNullable;
|
|
1147
|
-
/** 防护号:锁内的每次 status / handle 写入都按它比较并加一。 */
|
|
1148
|
-
generation: ColumnType<number, number | undefined, number>;
|
|
1149
|
-
/** 曾经成功创建过实例(只会置 true)。 */
|
|
1150
|
-
had_instance: ColumnType<boolean, boolean | undefined, boolean>;
|
|
1151
|
-
/** 换提供方时留下的旧实例。 */
|
|
1152
|
-
prev_provider: string | null;
|
|
1153
|
-
prev_handle: ColumnType<{
|
|
1154
|
-
id: string;
|
|
1155
|
-
[k: string]: unknown;
|
|
1156
|
-
} | null, string | null | undefined, string | null>;
|
|
1157
|
-
sweep_failed_at: TsNullable;
|
|
1158
1116
|
}
|
|
1117
|
+
/** 0152: see the migration for the meaning of each managed launch state. */
|
|
1118
|
+
export type BackgroundLaunchState = "pending" | "dispatched" | "acknowledged" | "cancel-pending" | "terminal";
|
|
1159
1119
|
type InstanceHandle = ColumnType<{
|
|
1160
1120
|
id: string;
|
|
1161
1121
|
[k: string]: unknown;
|
|
@@ -1176,14 +1136,6 @@ export interface DevicesTable {
|
|
|
1176
1136
|
demoted_from_provider: ColumnType<string | null, string | null | undefined, string | null>;
|
|
1177
1137
|
/** 0131: a cloud device's narrowing switch (`sandbox`); null follows the platform and the org. */
|
|
1178
1138
|
mode: ColumnType<"sandbox" | null, "sandbox" | null | undefined, "sandbox" | null>;
|
|
1179
|
-
/** 0154: a cloud device's owner Full ceiling (B1 snapshot); null: not snapshotted yet. */
|
|
1180
|
-
owner_full_access: ColumnType<boolean | null, boolean | null | undefined, boolean | null>;
|
|
1181
|
-
/** 0154: a cloud device's outer network (B1 snapshot); null: not snapshotted yet. */
|
|
1182
|
-
outer_network: ColumnType<DeviceNetwork | null, string | null | undefined, string | null>;
|
|
1183
|
-
/** 0154: the provenance of the B1 snapshot. */
|
|
1184
|
-
permission_migration: ColumnType<unknown, string | null | undefined, string | null>;
|
|
1185
|
-
/** 0154: the applied limits must be established before any operation is admitted. */
|
|
1186
|
-
permission_reconcile_required: ColumnType<boolean, boolean | undefined, boolean>;
|
|
1187
1139
|
/** 0165: a cloud device's sandbox network choice; null follows the org, `none` is closed. */
|
|
1188
1140
|
network_mode: ColumnType<"open" | "allowlist" | "none" | null, "open" | "allowlist" | "none" | null | undefined, "open" | "allowlist" | "none" | null>;
|
|
1189
1141
|
/** 0165: a cloud device's allowlist hosts (a JSON array), used while the mode is `allowlist`. */
|
|
@@ -1937,50 +1889,6 @@ export interface DeviceGenerationHighWaterTable {
|
|
|
1937
1889
|
high_water_ms: ColumnType<string, string | number, string | number>;
|
|
1938
1890
|
updated_at: Ts;
|
|
1939
1891
|
}
|
|
1940
|
-
export interface LegacyLaunchFreezeTable {
|
|
1941
|
-
id: "platform";
|
|
1942
|
-
frozen_at: Generated<Date>;
|
|
1943
|
-
frozen_by: string;
|
|
1944
|
-
/** Migration 0158: when the freeze's enumeration last completed stable; null before. */
|
|
1945
|
-
enumerated_at: TsNullable;
|
|
1946
|
-
}
|
|
1947
|
-
export interface DeviceRetirementObligationsTable {
|
|
1948
|
-
id: Generated<string>;
|
|
1949
|
-
device_id: string;
|
|
1950
|
-
org_id: string;
|
|
1951
|
-
provider: string;
|
|
1952
|
-
instance_generation: string;
|
|
1953
|
-
state: ColumnType<"open" | "quarantined" | "resolved" | "abandoned", "open" | "quarantined" | "resolved" | "abandoned" | undefined, "open" | "quarantined" | "resolved" | "abandoned">;
|
|
1954
|
-
/** When the obligation was abandoned with its deleted device (never evidence). */
|
|
1955
|
-
abandoned_at: TsNullable;
|
|
1956
|
-
/** `exact-cancelled`: every member was a revoked start cancelled by its exact ref (B-22). */
|
|
1957
|
-
resolution: ColumnType<"provider-destroyed" | "host-rebooted" | "exact-cancelled" | null, "provider-destroyed" | "host-rebooted" | "exact-cancelled" | null | undefined, "provider-destroyed" | "host-rebooted" | "exact-cancelled" | null>;
|
|
1958
|
-
/** A local incarnation: the machine and its boot identity when recorded (null: none). */
|
|
1959
|
-
boot_machine_id: ColumnType<string | null, string | null | undefined, string | null>;
|
|
1960
|
-
boot_id: ColumnType<string | null, string | null | undefined, string | null>;
|
|
1961
|
-
reason: ColumnType<string | null, string | null | undefined, string | null>;
|
|
1962
|
-
attempts: ColumnType<number, number | undefined, number>;
|
|
1963
|
-
last_attempt_at: TsNullable;
|
|
1964
|
-
last_error: ColumnType<string | null, string | null | undefined, string | null>;
|
|
1965
|
-
created_at: Generated<Date>;
|
|
1966
|
-
resolved_at: TsNullable;
|
|
1967
|
-
}
|
|
1968
|
-
export interface DeviceRetirementMembersTable {
|
|
1969
|
-
obligation_id: string;
|
|
1970
|
-
kind: "legacy-task" | "revoked-start";
|
|
1971
|
-
ref_id: string;
|
|
1972
|
-
settled: ColumnType<boolean, boolean | undefined, boolean>;
|
|
1973
|
-
created_at: Generated<Date>;
|
|
1974
|
-
}
|
|
1975
|
-
/** 0204: the exact local provider identity of a committed kernel incarnation. */
|
|
1976
|
-
export interface DeviceInstanceRetirementIdentitiesTable {
|
|
1977
|
-
org_id: string;
|
|
1978
|
-
device_id: string;
|
|
1979
|
-
provider: string;
|
|
1980
|
-
instance_generation: string;
|
|
1981
|
-
provider_generation: string;
|
|
1982
|
-
attested_at: TsNullable;
|
|
1983
|
-
}
|
|
1984
1892
|
export interface DeviceInstanceDestructionsTable {
|
|
1985
1893
|
confirmed: Generated<boolean>;
|
|
1986
1894
|
device_id: string;
|
|
@@ -2007,15 +1915,8 @@ export interface KernelDatabase {
|
|
|
2007
1915
|
device_permission_reports: DevicePermissionReportsTable;
|
|
2008
1916
|
/** Migration 0155: per-device generation high-water mark; outlives instance rows. */
|
|
2009
1917
|
device_generation_high_water: DeviceGenerationHighWaterTable;
|
|
2010
|
-
/** Migration 0157: the durable legacy-launch freeze (one row, never removed). */
|
|
2011
|
-
legacy_launch_freeze: LegacyLaunchFreezeTable;
|
|
2012
|
-
/** Migration 0157: the physical no-reuse obligation of one old instance incarnation. */
|
|
2013
|
-
device_retirement_obligations: DeviceRetirementObligationsTable;
|
|
2014
|
-
/** Migration 0157: what put a retirement obligation there. */
|
|
2015
|
-
device_retirement_members: DeviceRetirementMembersTable;
|
|
2016
1918
|
/** Migration 0157: provider-confirmed destruction of a cloud instance incarnation. */
|
|
2017
1919
|
device_instance_destructions: DeviceInstanceDestructionsTable;
|
|
2018
|
-
device_instance_retirement_identities: DeviceInstanceRetirementIdentitiesTable;
|
|
2019
1920
|
sandbox_operation_intents: SandboxOperationIntentsTable;
|
|
2020
1921
|
sandbox_operation_payload_chunks: SandboxOperationPayloadChunksTable;
|
|
2021
1922
|
permission_config_publication: PermissionConfigPublicationTable;
|
|
@@ -2072,7 +1973,6 @@ export interface KernelDatabase {
|
|
|
2072
1973
|
org_anonymous_accounts: OrgAnonymousAccountsTable;
|
|
2073
1974
|
directory_exclusions: DirectoryExclusionsTable;
|
|
2074
1975
|
attachments: AttachmentsTable;
|
|
2075
|
-
sandboxes: LegacySandboxesTable;
|
|
2076
1976
|
devices: DevicesTable;
|
|
2077
1977
|
device_instances: DeviceInstancesTable;
|
|
2078
1978
|
device_defaults: DeviceDefaultsTable;
|
package/package.json
CHANGED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
-- Contract the storage left behind by the pre-release reader and writer removals.
|
|
2
|
+
-- 0208 already converted permission settings and 0210 verified any history export receipt.
|
|
3
|
+
|
|
4
|
+
-- These are the two tables whose metadata is about to be contracted.
|
|
5
|
+
LOCK TABLE attachments, file_shares IN ACCESS EXCLUSIVE MODE;
|
|
6
|
+
|
|
7
|
+
-- capybara:allow-destructive Block the contract if the earlier copy did not carry forward still-live file or share metadata.
|
|
8
|
+
DO $$
|
|
9
|
+
BEGIN
|
|
10
|
+
IF EXISTS (
|
|
11
|
+
SELECT FROM attachments a
|
|
12
|
+
WHERE a.purpose = 'chat' AND a.status IN ('ready', 'pending')
|
|
13
|
+
AND (a.expires_at IS NULL OR a.expires_at > now() OR a.conversation_id IS NOT NULL)
|
|
14
|
+
AND NOT EXISTS (
|
|
15
|
+
SELECT FROM files f
|
|
16
|
+
WHERE f.id = a.id AND f.org_id = a.org_id AND f.account_id = a.account_id
|
|
17
|
+
AND (f.status = 'deleted' OR (a.status = 'pending' AND f.staging_key = a.object_key)
|
|
18
|
+
OR (f.blob_id IS NOT NULL AND (a.conversation_id IS NULL OR EXISTS (
|
|
19
|
+
SELECT FROM conversation_files cf
|
|
20
|
+
WHERE cf.conversation_id = a.conversation_id AND cf.file_id = f.id
|
|
21
|
+
AND cf.org_id = a.org_id
|
|
22
|
+
))))
|
|
23
|
+
)
|
|
24
|
+
) THEN
|
|
25
|
+
RAISE EXCEPTION '0211 has live chat attachments without migrated library metadata. Follow the pre-release cleanup release notes.';
|
|
26
|
+
END IF;
|
|
27
|
+
|
|
28
|
+
IF EXISTS (
|
|
29
|
+
SELECT FROM file_shares
|
|
30
|
+
WHERE object_key IS NOT NULL AND blob_id IS NULL AND revoked_at IS NULL
|
|
31
|
+
AND (expires_at IS NULL OR expires_at > now())
|
|
32
|
+
) THEN
|
|
33
|
+
RAISE EXCEPTION '0211 has live shares without a migrated blob. Follow the pre-release cleanup release notes.';
|
|
34
|
+
END IF;
|
|
35
|
+
END
|
|
36
|
+
$$;
|
|
37
|
+
|
|
38
|
+
-- capybara:allow-destructive Only the retired SID launcher wrote these tasks. Managed reservations keep their exact execution state.
|
|
39
|
+
DELETE FROM background_tasks WHERE launch_state = 'legacy';
|
|
40
|
+
|
|
41
|
+
-- capybara:allow-destructive Remove SID-only fields and checks whose writers were removed before the contract.
|
|
42
|
+
ALTER TABLE background_tasks
|
|
43
|
+
DROP COLUMN IF EXISTS sid,
|
|
44
|
+
DROP COLUMN IF EXISTS kill_pending,
|
|
45
|
+
DROP COLUMN IF EXISTS legacy_dispatch,
|
|
46
|
+
DROP COLUMN IF EXISTS legacy_dispatch_provider,
|
|
47
|
+
DROP COLUMN IF EXISTS legacy_dispatch_generation,
|
|
48
|
+
ALTER COLUMN launch_state DROP DEFAULT,
|
|
49
|
+
DROP CONSTRAINT IF EXISTS background_tasks_launch_state_check,
|
|
50
|
+
DROP CONSTRAINT IF EXISTS background_tasks_managed_reservation_check,
|
|
51
|
+
DROP CONSTRAINT IF EXISTS background_tasks_managed_dispatch_check;
|
|
52
|
+
|
|
53
|
+
ALTER TABLE background_tasks
|
|
54
|
+
ADD CONSTRAINT background_tasks_launch_state_check
|
|
55
|
+
CHECK (launch_state IN ('pending', 'dispatched', 'acknowledged', 'cancel-pending', 'terminal')),
|
|
56
|
+
ADD CONSTRAINT background_tasks_managed_reservation_check
|
|
57
|
+
CHECK (operation_id IS NOT NULL AND working_root IS NOT NULL AND retain_until IS NOT NULL
|
|
58
|
+
AND left(output_path, 1) = '/'),
|
|
59
|
+
ADD CONSTRAINT background_tasks_managed_dispatch_check
|
|
60
|
+
CHECK (launch_state IN ('pending', 'terminal')
|
|
61
|
+
OR (input_digest IS NOT NULL AND run_execution_id IS NOT NULL AND task_tag IS NOT NULL
|
|
62
|
+
AND instance_id IS NOT NULL AND instance_provider IS NOT NULL
|
|
63
|
+
AND instance_provider_version IS NOT NULL AND instance_generation IS NOT NULL
|
|
64
|
+
AND profile_revision IS NOT NULL AND ceiling_revision IS NOT NULL));
|
|
65
|
+
|
|
66
|
+
-- capybara:allow-destructive Replace the managed-call partial index with the same uniqueness over all remaining tasks.
|
|
67
|
+
DROP INDEX IF EXISTS background_tasks_managed_call_idx;
|
|
68
|
+
CREATE UNIQUE INDEX IF NOT EXISTS background_tasks_managed_call_idx ON background_tasks (run_id, call_id);
|
|
69
|
+
|
|
70
|
+
-- capybara:allow-destructive 0208 carried forward the inherited network restrictions. The report-driven runtime has no snapshot readers.
|
|
71
|
+
ALTER TABLE devices
|
|
72
|
+
DROP COLUMN IF EXISTS owner_full_access,
|
|
73
|
+
DROP COLUMN IF EXISTS outer_network,
|
|
74
|
+
DROP COLUMN IF EXISTS permission_migration,
|
|
75
|
+
DROP COLUMN IF EXISTS permission_reconcile_required;
|
|
76
|
+
|
|
77
|
+
-- capybara:allow-destructive Obsolete per-conversation sandbox records. The device instances and their storage remain.
|
|
78
|
+
DROP TABLE IF EXISTS sandboxes;
|
|
79
|
+
-- capybara:allow-destructive The legacy launch freeze has no writers or readers after retirement removal.
|
|
80
|
+
DROP TABLE IF EXISTS legacy_launch_freeze;
|
|
81
|
+
-- capybara:allow-destructive Retire obsolete proof membership and its trigger before dropping the referenced obligations.
|
|
82
|
+
DROP TABLE IF EXISTS device_retirement_members;
|
|
83
|
+
-- capybara:allow-destructive The proof trigger belonged only to the removed retirement members.
|
|
84
|
+
DROP FUNCTION IF EXISTS reopen_local_retirement_proof();
|
|
85
|
+
-- capybara:allow-destructive The old retirement ledger no longer owns cleanup. Keep device_instance_destructions for live reconciliation.
|
|
86
|
+
DROP TABLE IF EXISTS device_retirement_obligations;
|
|
87
|
+
-- capybara:allow-destructive Remove exact identities used only by the retired local proof flow.
|
|
88
|
+
DROP TABLE IF EXISTS device_instance_retirement_identities;
|
|
89
|
+
-- capybara:allow-destructive This generation scan index served the removed retirement enumerator only.
|
|
90
|
+
DROP INDEX IF EXISTS sandbox_operation_intents_owed_background_revoke_idx;
|
|
91
|
+
|
|
92
|
+
-- capybara:allow-destructive Only the retired permission tier syntax used this prefix.
|
|
93
|
+
DELETE FROM automation_grants WHERE tool_key LIKE 'tier:%';
|
|
94
|
+
|
|
95
|
+
-- capybara:allow-destructive Effective extension config now uses scoped secret storage instead of the retired plugin-config credentials.
|
|
96
|
+
DELETE FROM secrets
|
|
97
|
+
WHERE namespace = 'kernel' AND org_id <> '_deployment' AND key LIKE 'plugin-config:%';
|
|
98
|
+
|
|
99
|
+
-- capybara:allow-destructive Delete obsolete markers and retired permission keys whose current restrictions were migrated by 0208.
|
|
100
|
+
DELETE FROM deployment_settings WHERE key IN (
|
|
101
|
+
'fileLibraryCopySettled', 'templateConnectorsReconciled', 'devicesAutoMode', 'devicesFullAccess'
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
-- capybara:allow-destructive Remove retired permission keys already converted by 0208, leaving current and unrelated settings untouched.
|
|
105
|
+
UPDATE orgs SET settings = settings - ARRAY['autoMode', 'fullAccess', 'cloudNetwork']
|
|
106
|
+
WHERE jsonb_typeof(settings) = 'object' AND settings ?| ARRAY['autoMode', 'fullAccess', 'cloudNetwork'];
|
|
107
|
+
|
|
108
|
+
-- capybara:allow-destructive These jobs belonged to the removed backfill and share-object paths.
|
|
109
|
+
DELETE FROM outbox
|
|
110
|
+
WHERE queue = 'cap-kernel-maintenance' AND job_name IN ('file-library-backfill', 'share-object-delete');
|
|
111
|
+
|
|
112
|
+
CREATE TEMP TABLE IF NOT EXISTS retired_trigger_dispatches ON COMMIT DROP AS
|
|
113
|
+
SELECT id, data ->> 'eventId' AS event_id
|
|
114
|
+
FROM outbox
|
|
115
|
+
WHERE queue = 'cap-kernel-maintenance' AND job_name = 'trigger-dispatch'
|
|
116
|
+
AND job_id ~ '^trigger-dispatch-[0-9a-f-]{36}-sweep-[0-9]+$'
|
|
117
|
+
AND starts_with(job_id, 'trigger-dispatch-' || (data ->> 'eventId') || '-sweep-');
|
|
118
|
+
|
|
119
|
+
-- A sweep dispatch could be the only job owed for a still-pending event. Transfer it to the
|
|
120
|
+
-- current dispatcher with a deterministic fresh id, distinct from any old BullMQ job.
|
|
121
|
+
INSERT INTO outbox (queue, job_name, job_id, data, org_id)
|
|
122
|
+
SELECT 'cap-kernel-maintenance', 'trigger-dispatch', 'trigger-dispatch-' || e.id || '-0211',
|
|
123
|
+
jsonb_build_object('eventId', e.id, 'orgId', e.org_id), e.org_id
|
|
124
|
+
FROM trigger_events e
|
|
125
|
+
WHERE e.state = 'pending' AND e.audience IS NOT NULL
|
|
126
|
+
AND EXISTS (SELECT FROM retired_trigger_dispatches d WHERE d.event_id = e.id)
|
|
127
|
+
AND NOT EXISTS (
|
|
128
|
+
SELECT FROM outbox current_dispatch
|
|
129
|
+
WHERE current_dispatch.queue = 'cap-kernel-maintenance'
|
|
130
|
+
AND current_dispatch.job_name = 'trigger-dispatch' AND current_dispatch.dead_at IS NULL
|
|
131
|
+
AND current_dispatch.job_id = 'trigger-dispatch-' || e.id
|
|
132
|
+
)
|
|
133
|
+
ON CONFLICT (queue, job_id) WHERE dead_at IS NULL DO NOTHING;
|
|
134
|
+
|
|
135
|
+
-- capybara:allow-destructive Remove only the retired directed-trigger recovery jobs after preserving pending delivery.
|
|
136
|
+
DELETE FROM outbox WHERE id IN (SELECT id FROM retired_trigger_dispatches);
|
|
137
|
+
|
|
138
|
+
-- capybara:allow-destructive The earlier copy migrated chat attachment metadata to the file library. Leave blob and storage objects alone.
|
|
139
|
+
DELETE FROM attachments WHERE purpose = 'chat';
|
|
140
|
+
|
|
141
|
+
-- capybara:allow-destructive Replace the attachment default and check with the current explicit purposes.
|
|
142
|
+
ALTER TABLE attachments ALTER COLUMN purpose DROP DEFAULT,
|
|
143
|
+
DROP CONSTRAINT IF EXISTS attachments_purpose_check;
|
|
144
|
+
ALTER TABLE attachments ADD CONSTRAINT attachments_purpose_check
|
|
145
|
+
CHECK (purpose IN ('skill-package', 'agent-avatar', 'read'));
|
|
146
|
+
|
|
147
|
+
-- capybara:allow-destructive The one-off file library copy has run and its runtime callers are gone.
|
|
148
|
+
DROP FUNCTION IF EXISTS file_library_copy(timestamptz);
|
|
149
|
+
-- capybara:allow-destructive Shares resolve their snapshot through blob_id after the file library cutover.
|
|
150
|
+
ALTER TABLE file_shares DROP COLUMN IF EXISTS object_key;
|
|
151
|
+
-- capybara:allow-destructive The removed org config reader has been replaced by the current storage paths.
|
|
152
|
+
ALTER TABLE extension_org_configs DROP COLUMN IF EXISTS config;
|
|
153
|
+
-- capybara:allow-destructive 0210 has consumed the one-time export receipt. The verified manifests and transcripts stay outside PostgreSQL.
|
|
154
|
+
DROP TABLE IF EXISTS capybara._history_export_0210;
|