@capybara-hq/kernel 0.1.0-rc.120 → 0.1.0-rc.122

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.
Files changed (230) hide show
  1. package/dist/background/finish.d.ts +5 -1
  2. package/dist/background/finish.js +29 -18
  3. package/dist/background/launch.d.ts +0 -5
  4. package/dist/background/launch.js +1 -6
  5. package/dist/background/managed.js +1 -4
  6. package/dist/background/poll.job.d.ts +3 -25
  7. package/dist/background/poll.job.js +20 -112
  8. package/dist/background/render.d.ts +2 -8
  9. package/dist/background/render.js +3 -17
  10. package/dist/background/stop.d.ts +15 -16
  11. package/dist/background/stop.js +39 -76
  12. package/dist/background/store.d.ts +17 -45
  13. package/dist/background/store.js +60 -94
  14. package/dist/background/tasks.service.d.ts +2 -5
  15. package/dist/background/tasks.service.js +9 -20
  16. package/dist/background/wake.js +3 -2
  17. package/dist/catalog/admin-catalog.controller.d.ts +2 -18
  18. package/dist/catalog/admin-catalog.controller.js +2 -28
  19. package/dist/catalog/catalog-content.d.ts +1 -5
  20. package/dist/catalog/catalog-items.d.ts +2 -6
  21. package/dist/catalog/catalog-items.js +5 -26
  22. package/dist/catalog/catalog-scope.service.d.ts +1 -121
  23. package/dist/catalog/catalog-scope.service.js +12 -552
  24. package/dist/catalog/catalog.service.d.ts +4 -15
  25. package/dist/catalog/catalog.service.js +7 -35
  26. package/dist/catalog/job-ids.d.ts +0 -18
  27. package/dist/catalog/job-ids.js +0 -20
  28. package/dist/catalog/marketplaces.service.d.ts +1 -1
  29. package/dist/catalog/org-catalog.service.js +6 -20
  30. package/dist/catalog/org-plugin-uploads.controller.d.ts +4 -19
  31. package/dist/catalog/org-plugin-uploads.controller.js +6 -34
  32. package/dist/catalog/org-plugin-uploads.d.ts +3 -10
  33. package/dist/catalog/org-plugin-uploads.js +4 -18
  34. package/dist/catalog/org-plugin-uploads.schemas.js +0 -1
  35. package/dist/catalog/owned-items.d.ts +6 -11
  36. package/dist/catalog/owned-items.js +10 -20
  37. package/dist/catalog/ownership.d.ts +3 -29
  38. package/dist/catalog/ownership.js +4 -54
  39. package/dist/catalog/platform-components.d.ts +5 -11
  40. package/dist/catalog/platform-components.js +8 -15
  41. package/dist/catalog/plugin-import.d.ts +3 -42
  42. package/dist/catalog/plugin-import.js +26 -195
  43. package/dist/catalog/plugin-install.js +1 -6
  44. package/dist/catalog/plugin-package.d.ts +1 -0
  45. package/dist/catalog/plugin-package.js +5 -0
  46. package/dist/catalog/plugin-upgrade.d.ts +3 -26
  47. package/dist/catalog/plugin-upgrade.js +20 -103
  48. package/dist/catalog/request-rules.js +4 -6
  49. package/dist/catalog/scope-sync.js +2 -4
  50. package/dist/catalog/scope.d.ts +2 -5
  51. package/dist/channels/jobs.d.ts +3 -3
  52. package/dist/channels/jobs.js +4 -3
  53. package/dist/channels/outbound.d.ts +1 -0
  54. package/dist/channels/outbound.js +32 -8
  55. package/dist/config/load.d.ts +0 -25
  56. package/dist/config/load.js +0 -57
  57. package/dist/config/schema.js +2 -3
  58. package/dist/conversations/attachments.service.js +3 -5
  59. package/dist/conversations/conversations.service.d.ts +3 -3
  60. package/dist/conversations/conversations.service.js +3 -3
  61. package/dist/conversations/job-org.d.ts +3 -0
  62. package/dist/conversations/job-org.js +11 -0
  63. package/dist/conversations/prompt-suggestions.d.ts +2 -7
  64. package/dist/conversations/prompt-suggestions.js +29 -27
  65. package/dist/conversations/titles.d.ts +3 -4
  66. package/dist/conversations/titles.js +19 -30
  67. package/dist/db/kernel-schema.d.ts +6 -16
  68. package/dist/db/pool.js +7 -2
  69. package/dist/devices/devices.controller.d.ts +0 -5
  70. package/dist/devices/devices.controller.js +2 -20
  71. package/dist/devices/devices.service.d.ts +1 -17
  72. package/dist/devices/devices.service.js +0 -22
  73. package/dist/errors.d.ts +1 -5
  74. package/dist/errors.js +1 -5
  75. package/dist/evals/judge.d.ts +3 -0
  76. package/dist/evals/judge.js +1 -1
  77. package/dist/evals/run-replay.d.ts +1 -1
  78. package/dist/evals/run-replay.js +26 -29
  79. package/dist/evals/step-replay.d.ts +3 -1
  80. package/dist/evals/step-replay.js +10 -1
  81. package/dist/evals/worker.d.ts +3 -1
  82. package/dist/evals/worker.js +53 -21
  83. package/dist/extensions/deployment-config-store.js +18 -14
  84. package/dist/extensions/effective-config.d.ts +1 -5
  85. package/dist/extensions/effective-config.js +1 -5
  86. package/dist/extensions/hooks.d.ts +3 -1
  87. package/dist/extensions/hooks.js +7 -2
  88. package/dist/extensions/installs.d.ts +2 -14
  89. package/dist/extensions/installs.js +10 -32
  90. package/dist/extensions/org-config.d.ts +3 -4
  91. package/dist/extensions/org-config.js +3 -4
  92. package/dist/extensions/plugin-guides.d.ts +0 -1
  93. package/dist/extensions/plugin-guides.js +0 -1
  94. package/dist/extensions/plugin-icons.d.ts +0 -1
  95. package/dist/extensions/plugin-icons.js +0 -3
  96. package/dist/files/blob-sweep.job.d.ts +2 -11
  97. package/dist/files/blob-sweep.job.js +7 -21
  98. package/dist/files/hash-job.d.ts +5 -15
  99. package/dist/files/hash-job.js +14 -33
  100. package/dist/files/library-jobs.module.d.ts +1 -6
  101. package/dist/files/library-jobs.module.js +3 -9
  102. package/dist/identity/api-tokens.js +54 -40
  103. package/dist/identity/auth.guard.js +2 -2
  104. package/dist/identity/sessions.js +7 -3
  105. package/dist/identity/settings.js +5 -21
  106. package/dist/inbox/inbox.service.d.ts +2 -3
  107. package/dist/inbox/org-notices.d.ts +0 -14
  108. package/dist/inbox/platform-inbox.service.d.ts +1 -8
  109. package/dist/inbox/platform-inbox.service.js +2 -6
  110. package/dist/inbox/platform-notices.d.ts +3 -3
  111. package/dist/index.d.ts +0 -4
  112. package/dist/index.js +0 -3
  113. package/dist/infra/database/database.module.js +2 -1
  114. package/dist/infra/database/org-scope.d.ts +5 -3
  115. package/dist/infra/database/org-scope.js +7 -1
  116. package/dist/infra/database/scoped-dialect.d.ts +3 -1
  117. package/dist/infra/database/scoped-dialect.js +17 -5
  118. package/dist/infra/events/kernel-events.d.ts +2 -0
  119. package/dist/infra/outbox/outbox.service.d.ts +2 -0
  120. package/dist/infra/outbox/outbox.service.js +10 -0
  121. package/dist/infra/outbox/registry.d.ts +0 -41
  122. package/dist/infra/outbox/registry.js +0 -37
  123. package/dist/models/embeddings.d.ts +0 -5
  124. package/dist/models/embeddings.js +28 -35
  125. package/dist/models/images.d.ts +3 -8
  126. package/dist/models/images.js +19 -37
  127. package/dist/models/purposes.d.ts +7 -2
  128. package/dist/models/purposes.js +16 -3
  129. package/dist/orgs/device-network-setting.d.ts +0 -44
  130. package/dist/orgs/device-network-setting.js +0 -83
  131. package/dist/orgs/invitations.service.js +34 -30
  132. package/dist/orgs/offboarding.d.ts +2 -2
  133. package/dist/orgs/offboarding.js +2 -2
  134. package/dist/orgs/orgs.service.d.ts +1 -1
  135. package/dist/orgs/orgs.service.js +19 -15
  136. package/dist/orgs/settings.service.d.ts +19 -14
  137. package/dist/orgs/settings.service.js +12 -37
  138. package/dist/platform/exclusions.js +0 -11
  139. package/dist/platform/ops/catalog-admin.ops.js +0 -8
  140. package/dist/platform/ops/devices.ops.js +0 -28
  141. package/dist/platform/ops/extensions-admin.ops.js +3 -3
  142. package/dist/platform/ops/inbox.ops.js +5 -22
  143. package/dist/platform/ops/org-plugins.ops.d.ts +1 -3
  144. package/dist/platform/ops/org-plugins.ops.js +11 -67
  145. package/dist/plugin-reads/plugin-reads.service.js +2 -1
  146. package/dist/roles/worker.module.js +0 -9
  147. package/dist/runtime/hook-calls.d.ts +13 -6
  148. package/dist/runtime/hook-calls.js +26 -4
  149. package/dist/runtime/maintenance.d.ts +3 -12
  150. package/dist/runtime/maintenance.js +25 -55
  151. package/dist/runtime/model-call.d.ts +4 -2
  152. package/dist/runtime/model-call.js +59 -58
  153. package/dist/runtime/providers.d.ts +27 -1
  154. package/dist/runtime/providers.js +57 -0
  155. package/dist/runtime/run-jobs.d.ts +1 -1
  156. package/dist/runtime/run-processors.d.ts +3 -9
  157. package/dist/runtime/run-worker.d.ts +2 -0
  158. package/dist/runtime/run-worker.js +23 -8
  159. package/dist/runtime/subagents/deliveries.js +6 -1
  160. package/dist/runtime/subagents/dispatch.d.ts +3 -3
  161. package/dist/runtime/write-base.service.d.ts +2 -3
  162. package/dist/runtime/write-base.service.js +3 -5
  163. package/dist/sandbox/device-sandbox-settings.d.ts +38 -92
  164. package/dist/sandbox/device-sandbox-settings.js +19 -325
  165. package/dist/sandbox/jobs.d.ts +3 -14
  166. package/dist/sandbox/jobs.js +2 -20
  167. package/dist/sandbox/modes.d.ts +5 -45
  168. package/dist/sandbox/modes.js +3 -60
  169. package/dist/sandbox/operation-authority.js +0 -11
  170. package/dist/sandbox/operation-intents.d.ts +32 -9
  171. package/dist/sandbox/operation-intents.js +241 -32
  172. package/dist/sandbox/operation-intents.module.js +2 -1
  173. package/dist/sandbox/operation-reconcile.job.d.ts +9 -11
  174. package/dist/sandbox/operation-reconcile.job.js +119 -33
  175. package/dist/sandbox/operation-revoke.d.ts +20 -0
  176. package/dist/sandbox/operation-revoke.js +3 -0
  177. package/dist/sandbox/permission-ceiling-writes.d.ts +1 -2
  178. package/dist/sandbox/permission-ceiling-writes.js +3 -6
  179. package/dist/sandbox/permission-config-publication.d.ts +1 -28
  180. package/dist/sandbox/permission-config-publication.js +14 -211
  181. package/dist/sandbox/permission-facts.d.ts +4 -15
  182. package/dist/sandbox/permission-facts.js +7 -29
  183. package/dist/sandbox/permission-instance-writes.d.ts +1 -4
  184. package/dist/sandbox/permission-instance-writes.js +1 -55
  185. package/dist/sandbox/providers.d.ts +1 -6
  186. package/dist/sandbox/providers.js +1 -15
  187. package/dist/sandbox/review/classifier.js +12 -13
  188. package/dist/sandbox/sandbox.module.js +3 -6
  189. package/dist/sandbox/sandbox.service.d.ts +17 -123
  190. package/dist/sandbox/sandbox.service.js +239 -998
  191. package/dist/shares/liveness.d.ts +1 -2
  192. package/dist/shares/liveness.js +1 -2
  193. package/dist/shares/shares.module.d.ts +1 -2
  194. package/dist/shares/shares.module.js +2 -5
  195. package/dist/shares/shares.service.js +1 -2
  196. package/dist/tools/builtins/image/generate.js +7 -15
  197. package/dist/tools/builtins/sandbox/common.d.ts +0 -2
  198. package/dist/tools/builtins/sandbox/common.js +1 -27
  199. package/dist/tools/builtins/sandbox/task-list.js +10 -10
  200. package/dist/tools/builtins/sandbox/task-output.d.ts +3 -10
  201. package/dist/tools/builtins/sandbox/task-output.js +13 -83
  202. package/dist/tools/builtins/sandbox/task-stop.js +18 -22
  203. package/dist/tools/builtins/vision/read-image.js +9 -10
  204. package/dist/tools/builtins/web/extract.js +9 -10
  205. package/package.json +3 -3
  206. package/src/migrations/0206_retire_org_extension_uploads.sql +125 -0
  207. package/src/migrations/0207_confirm_device_instance_destruction.sql +25 -0
  208. package/src/migrations/0208_convert_stored_permission_settings.sql +189 -0
  209. package/dist/background/retire-legacy-tasks.job.d.ts +0 -57
  210. package/dist/background/retire-legacy-tasks.job.js +0 -149
  211. package/dist/catalog/owned-plugin-cleanup.d.ts +0 -47
  212. package/dist/catalog/owned-plugin-cleanup.js +0 -140
  213. package/dist/config/permission-migration.d.ts +0 -34
  214. package/dist/config/permission-migration.js +0 -115
  215. package/dist/devices/legacy-cleanup.job.d.ts +0 -34
  216. package/dist/devices/legacy-cleanup.job.js +0 -147
  217. package/dist/files/library-backfill.d.ts +0 -63
  218. package/dist/files/library-backfill.js +0 -143
  219. package/dist/infra/cli/permission-cutover.d.ts +0 -59
  220. package/dist/infra/cli/permission-cutover.js +0 -107
  221. package/dist/sandbox/cloud-permission-snapshot.d.ts +0 -159
  222. package/dist/sandbox/cloud-permission-snapshot.js +0 -430
  223. package/dist/sandbox/cloud-permission-snapshot.module.d.ts +0 -8
  224. package/dist/sandbox/cloud-permission-snapshot.module.js +0 -34
  225. package/dist/sandbox/legacy-retirement.d.ts +0 -284
  226. package/dist/sandbox/legacy-retirement.js +0 -1165
  227. package/dist/sandbox/legacy-retirement.module.d.ts +0 -8
  228. package/dist/sandbox/legacy-retirement.module.js +0 -25
  229. package/dist/shares/share-objects.d.ts +0 -47
  230. package/dist/shares/share-objects.js +0 -93
@@ -0,0 +1,125 @@
1
+ -- Org uploads accept declarative packages. Retire the old approval state in the same transaction
2
+ -- as the scope changes. This pre-0.1.0 change drops the retired columns after the backfill.
3
+ -- capybara:allow-destructive archive first uploads and release their unused claims before dropping the old columns; skip the backfill on rerun
4
+ DO $$
5
+ BEGIN
6
+ IF EXISTS (
7
+ SELECT 1 FROM information_schema.columns
8
+ WHERE table_schema = 'capybara' AND table_name = 'catalog_items'
9
+ AND column_name = 'awaiting_confirmation'
10
+ ) THEN
11
+ WITH retired AS (
12
+ UPDATE catalog_items
13
+ SET deleted_at = now(), updated_at = now(), scope_version = scope_version + 1
14
+ WHERE awaiting_confirmation AND deleted_at IS NULL
15
+ RETURNING id, name, package_name
16
+ )
17
+ DELETE FROM extension_name_owners x
18
+ USING retired r
19
+ WHERE x.name = r.name AND x.package_name = r.package_name
20
+ AND NOT EXISTS (SELECT 1 FROM extension_installs i WHERE i.name = x.name);
21
+
22
+ UPDATE catalog_items SET pending_version = NULL, pending_by = NULL, pending_at = NULL
23
+ WHERE pending_version IS NOT NULL OR pending_by IS NOT NULL OR pending_at IS NOT NULL;
24
+ END IF;
25
+
26
+ IF EXISTS (
27
+ SELECT 1 FROM information_schema.columns
28
+ WHERE table_schema = 'capybara' AND table_name = 'catalog_item_versions'
29
+ AND column_name = 'rejected_at'
30
+ ) THEN
31
+ UPDATE catalog_item_versions SET applied_at = NULL WHERE rejected_at IS NOT NULL;
32
+ END IF;
33
+ END
34
+ $$;
35
+
36
+ -- Stop orphaned installs before discarding the old cleanup jobs. A super admin may have
37
+ -- reimported the same package, keeping the install record and its former catalog item id.
38
+ UPDATE extension_installs x
39
+ SET desired_state = 'disabled', enabled_at = NULL, updated_at = now()
40
+ FROM catalog_items i
41
+ WHERE x.catalog_item_id = i.id AND x.desired_state = 'enabled'
42
+ AND i.owner_org_id IS NOT NULL AND i.deleted_at IS NOT NULL
43
+ AND NOT EXISTS (
44
+ SELECT 1 FROM catalog_items live
45
+ WHERE live.name = i.name AND live.package_name = i.package_name
46
+ AND live.deleted_at IS NULL
47
+ );
48
+
49
+ -- Keep approved deployments and their extension state. Narrow the plugin's listed orgs without
50
+ -- changing the former owner's switch. Components keep their independent scopes and origins.
51
+ -- Preserve the share gate's effect on their visibility when their ownership changes.
52
+ -- capybara:allow-destructive remove former scope associations outside the owning org as the plugin transfers to the platform
53
+ WITH candidates AS (
54
+ SELECT i.id, i.owner_org_id, o.name AS org_name,
55
+ NOT i.disabled AND o.deleted_at IS NULL AND COALESCE(s.enabled, true) AS used
56
+ FROM catalog_items i
57
+ JOIN orgs o ON o.id = i.owner_org_id
58
+ LEFT JOIN catalog_item_org_switches s ON s.item_id = i.id AND s.org_id = i.owner_org_id
59
+ WHERE i.deleted_at IS NULL
60
+ AND (
61
+ EXISTS (
62
+ SELECT 1 FROM catalog_item_versions v
63
+ WHERE v.item_id = i.id AND v.version = COALESCE(i.platform_synced_version, i.latest_version)
64
+ AND v.applied_at IS NOT NULL
65
+ AND (v.extension_sha256 IS NOT NULL OR jsonb_typeof(v.manifest -> 'extension') = 'object')
66
+ )
67
+ OR EXISTS (SELECT 1 FROM extension_installs x WHERE x.catalog_item_id = i.id)
68
+ )
69
+ ), transferred AS (
70
+ UPDATE catalog_items i
71
+ SET owner_org_id = NULL, scope = 'named', shown_to_others = false,
72
+ scope_version = i.scope_version + 1, updated_at = now()
73
+ FROM candidates c WHERE i.id = c.id
74
+ RETURNING i.id, i.name, c.owner_org_id, c.org_name, c.used
75
+ ), remove_other_orgs AS (
76
+ DELETE FROM catalog_item_scope_orgs s
77
+ USING transferred t WHERE s.item_id = t.id AND s.org_id <> t.owner_org_id
78
+ ), list_former_owner AS (
79
+ INSERT INTO catalog_item_scope_orgs (item_id, org_id)
80
+ SELECT id, owner_org_id FROM transferred ON CONFLICT DO NOTHING
81
+ ), transfer_skills AS (
82
+ UPDATE platform_skills p SET owner_org_id = NULL, shown_to_others = p.shown_to_others AND p.shareable
83
+ FROM transferred t WHERE p.catalog_item_id = t.id
84
+ ), transfer_agents AS (
85
+ UPDATE platform_agent_templates p SET owner_org_id = NULL, shown_to_others = p.shown_to_others AND p.shareable
86
+ FROM transferred t WHERE p.catalog_item_id = t.id
87
+ ), transfer_connectors AS (
88
+ UPDATE platform_connector_templates p SET owner_org_id = NULL, shown_to_others = p.shown_to_others AND p.shareable
89
+ FROM transferred t WHERE p.catalog_item_id = t.id
90
+ ), transfer_themes AS (
91
+ UPDATE platform_themes p SET owner_org_id = NULL, shown_to_others = p.shown_to_others AND p.shareable
92
+ FROM transferred t WHERE p.catalog_item_id = t.id
93
+ ), notify AS (
94
+ INSERT INTO platform_notices (id, kind, detail)
95
+ SELECT gen_random_uuid(), 'ownership_transferred',
96
+ jsonb_build_object(
97
+ 'ref', jsonb_build_object('kind', 'plugin', 'id', id), 'name', name,
98
+ 'fromOrg', jsonb_build_object('id', owner_org_id, 'name', org_name),
99
+ 'reason', 'extension_upload_retired', 'usedBy', CASE WHEN used THEN 1 ELSE 0 END)
100
+ FROM transferred
101
+ )
102
+ INSERT INTO outbox (queue, job_name, job_id, data)
103
+ SELECT 'cap-kernel-plugin-scope', 'scope-item', 'scope-item-' || id || '-x' || pg_current_xact_id(),
104
+ jsonb_build_object('kind', 'item', 'itemId', id)
105
+ FROM transferred
106
+ ON CONFLICT (queue, job_id) WHERE dead_at IS NULL DO NOTHING;
107
+
108
+ -- capybara:allow-destructive the organization inbox no longer reads the two upload decision kinds
109
+ DELETE FROM org_notices WHERE kind IN ('upload_confirmed', 'upload_rejected');
110
+ -- capybara:allow-destructive replace the notice constraint after deleting the retired kinds
111
+ ALTER TABLE org_notices DROP CONSTRAINT IF EXISTS org_notices_kind_check;
112
+ ALTER TABLE org_notices ADD CONSTRAINT org_notices_kind_check
113
+ CHECK (kind IN ('item_shared', 'shared_item_updated'));
114
+
115
+ -- capybara:allow-destructive workers no longer consume this retired job
116
+ DELETE FROM outbox WHERE queue = 'cap-kernel-maintenance' AND job_name = 'owned-plugin-cleanup';
117
+
118
+ -- capybara:allow-destructive the backfill consumed these pre-0.1.0 upload fields and no reader or writer remains
119
+ ALTER TABLE catalog_items
120
+ DROP COLUMN IF EXISTS awaiting_confirmation,
121
+ DROP COLUMN IF EXISTS pending_version,
122
+ DROP COLUMN IF EXISTS pending_by,
123
+ DROP COLUMN IF EXISTS pending_at;
124
+ -- capybara:allow-destructive rejected versions were marked unapplied and no reader or writer remains
125
+ ALTER TABLE catalog_item_versions DROP COLUMN IF EXISTS rejected_at;
@@ -0,0 +1,25 @@
1
+ -- Older receipts include best-effort dial-in destroys. Only the fenced lifecycle can confirm
2
+ -- that a non-dial-in provider destroyed this exact instance generation.
3
+ ALTER TABLE device_instance_destructions
4
+ ADD COLUMN IF NOT EXISTS confirmed boolean NOT NULL DEFAULT false;
5
+
6
+ -- Managed revocation has an independent retry budget from launch reconciliation.
7
+ ALTER TABLE sandbox_operation_intents
8
+ ADD COLUMN IF NOT EXISTS revoke_attempt integer NOT NULL DEFAULT 0 CHECK (revoke_attempt >= 0);
9
+
10
+ -- Existing managed stops previously relied on the poller. Give each one its initial delivery.
11
+ INSERT INTO outbox (queue, job_name, job_id, data, org_id)
12
+ SELECT
13
+ 'cap-kernel-maintenance',
14
+ 'sandbox-operation-revoke',
15
+ 'sandbox-operation-revoke-' || intent.operation_id || '-stop',
16
+ jsonb_build_object('operationId', intent.operation_id, 'orgId', intent.org_id, 'attempt', 0),
17
+ intent.org_id
18
+ FROM sandbox_operation_intents AS intent
19
+ JOIN background_tasks AS task
20
+ ON task.operation_id = intent.operation_id AND task.org_id = intent.org_id
21
+ WHERE intent.method = 'backgroundStart'
22
+ AND intent.state = 'background-running'
23
+ AND task.status = 'running'
24
+ AND task.launch_state = 'cancel-pending'
25
+ ON CONFLICT (queue, job_id) WHERE dead_at IS NULL DO NOTHING;
@@ -0,0 +1,189 @@
1
+ -- Preserve stored restrictions after the old writers stop and before the current readers start.
2
+ -- Helpers live only in the migrator's PostgreSQL session.
3
+ CREATE OR REPLACE FUNCTION pg_temp.permission_hosts_valid(hosts jsonb) RETURNS boolean
4
+ LANGUAGE sql IMMUTABLE AS $$
5
+ SELECT CASE
6
+ WHEN hosts IS NULL THEN true
7
+ WHEN jsonb_typeof(hosts) <> 'array' THEN false
8
+ ELSE jsonb_array_length(hosts) <= 200
9
+ AND (SELECT count(DISTINCT value) = count(*) FROM jsonb_array_elements(hosts))
10
+ AND NOT EXISTS (
11
+ SELECT 1 FROM jsonb_array_elements(hosts) AS entry(value)
12
+ CROSS JOIN LATERAL (SELECT entry.value #>> '{}' AS host) AS name
13
+ WHERE jsonb_typeof(entry.value) <> 'string' OR length(host) > 253
14
+ OR host !~ '^(\*\.)?([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]([a-z0-9-]{0,61}[a-z0-9])?$'
15
+ OR host ~ '\.(local|internal|localhost)$'
16
+ )
17
+ END
18
+ $$;
19
+
20
+ CREATE OR REPLACE FUNCTION pg_temp.permission_host_overlap(a jsonb, b jsonb) RETURNS jsonb
21
+ LANGUAGE sql IMMUTABLE AS $$
22
+ WITH patterns AS (
23
+ SELECT host, false AS rhs FROM jsonb_array_elements_text(COALESCE(a, '[]')) AS p(host)
24
+ UNION ALL
25
+ SELECT host, true AS rhs FROM jsonb_array_elements_text(COALESCE(b, '[]')) AS p(host)
26
+ ), overlap AS (
27
+ SELECT DISTINCT candidate.host FROM patterns AS candidate
28
+ JOIN patterns AS pattern ON candidate.rhs <> pattern.rhs
29
+ WHERE candidate.host = pattern.host
30
+ OR (left(pattern.host, 2) = '*.'
31
+ AND right(candidate.host, length(pattern.host) - 1) = substring(pattern.host FROM 2))
32
+ )
33
+ SELECT COALESCE(jsonb_agg(host ORDER BY host), '[]') FROM overlap
34
+ $$;
35
+
36
+ CREATE OR REPLACE FUNCTION pg_temp.org_permission_network(value jsonb, legacy boolean) RETURNS jsonb
37
+ LANGUAGE plpgsql IMMUTABLE AS $$
38
+ DECLARE
39
+ closed CONSTANT jsonb := '{"default":"allowlist","ceiling":"allowlist","base":"none"}';
40
+ BEGIN
41
+ IF value IS NULL THEN RETURN NULL; END IF;
42
+ IF jsonb_typeof(value) <> 'object' THEN RETURN closed; END IF;
43
+ IF value - (ARRAY['base', 'extraHosts', 'excludedHosts']
44
+ || CASE WHEN legacy THEN ARRAY['mode'] ELSE ARRAY['default', 'ceiling'] END) <> '{}'
45
+ OR (value ? 'base' AND NOT COALESCE(value ->> 'base' IN ('platform', 'none'), false))
46
+ OR EXISTS (
47
+ SELECT 1 FROM unnest(ARRAY['mode', 'default', 'ceiling']) AS field(key)
48
+ WHERE value ? field.key AND NOT COALESCE(value ->> field.key IN ('open', 'allowlist'), false)
49
+ )
50
+ OR NOT pg_temp.permission_hosts_valid(value -> 'extraHosts')
51
+ OR NOT pg_temp.permission_hosts_valid(value -> 'excludedHosts')
52
+ OR (value ->> 'default' = 'open' AND value ->> 'ceiling' = 'allowlist')
53
+ THEN RETURN closed; END IF;
54
+ IF legacy THEN
55
+ RETURN (value - 'mode') || CASE WHEN value ->> 'mode' = 'allowlist'
56
+ THEN '{"ceiling":"allowlist"}'::jsonb ELSE '{}'::jsonb END;
57
+ END IF;
58
+ RETURN value;
59
+ END
60
+ $$;
61
+
62
+ CREATE OR REPLACE FUNCTION pg_temp.narrow_permission_network(current_choice jsonb, old_choice jsonb, legacy_off boolean)
63
+ RETURNS jsonb LANGUAGE plpgsql IMMUTABLE AS $$
64
+ DECLARE
65
+ network jsonb;
66
+ extras jsonb;
67
+ exclusions jsonb;
68
+ ceiling text;
69
+ default_mode text;
70
+ BEGIN
71
+ IF current_choice IS NULL OR old_choice IS NULL THEN
72
+ network := COALESCE(current_choice, old_choice, '{}');
73
+ ELSE
74
+ -- Keep the old reader's exact match for conflicting org extras. Devices below intersect
75
+ -- actual address patterns, where an explicit hostname can narrow a wildcard.
76
+ SELECT COALESCE(jsonb_agg(host ORDER BY host), '[]') INTO extras
77
+ FROM (
78
+ SELECT host FROM jsonb_array_elements_text(COALESCE(current_choice -> 'extraHosts', '[]')) AS e(host)
79
+ INTERSECT
80
+ SELECT host FROM jsonb_array_elements_text(COALESCE(old_choice -> 'extraHosts', '[]')) AS e(host)
81
+ ) AS hosts;
82
+ SELECT COALESCE(jsonb_agg(host ORDER BY host), '[]') INTO exclusions
83
+ FROM (
84
+ SELECT host FROM jsonb_array_elements_text(COALESCE(current_choice -> 'excludedHosts', '[]')) AS e(host)
85
+ UNION
86
+ SELECT host FROM jsonb_array_elements_text(COALESCE(old_choice -> 'excludedHosts', '[]')) AS e(host)
87
+ ) AS hosts;
88
+ IF jsonb_array_length(extras) > 200 OR jsonb_array_length(exclusions) > 200 THEN
89
+ RETURN '{"default":"allowlist","ceiling":"allowlist","base":"none"}';
90
+ END IF;
91
+ ceiling := CASE WHEN 'allowlist' IN (current_choice ->> 'ceiling', old_choice ->> 'ceiling')
92
+ THEN 'allowlist' ELSE COALESCE(current_choice ->> 'ceiling', old_choice ->> 'ceiling') END;
93
+ default_mode := CASE WHEN 'allowlist' IN (current_choice ->> 'default', old_choice ->> 'default')
94
+ THEN 'allowlist' ELSE COALESCE(current_choice ->> 'default', old_choice ->> 'default') END;
95
+ network := jsonb_strip_nulls(jsonb_build_object(
96
+ 'default', default_mode,
97
+ 'ceiling', ceiling,
98
+ 'base', CASE WHEN 'none' IN (current_choice ->> 'base', old_choice ->> 'base') THEN 'none'
99
+ ELSE COALESCE(current_choice ->> 'base', old_choice ->> 'base') END,
100
+ 'extraHosts', NULLIF(extras, '[]'::jsonb),
101
+ 'excludedHosts', NULLIF(exclusions, '[]'::jsonb)));
102
+ END IF;
103
+
104
+ IF legacy_off THEN network := network || '{"ceiling":"allowlist"}'; END IF;
105
+ IF network ->> 'ceiling' = 'allowlist' AND network ->> 'default' = 'open' THEN
106
+ network := network || '{"default":"allowlist"}';
107
+ END IF;
108
+ RETURN NULLIF(network, '{}'::jsonb);
109
+ END
110
+ $$;
111
+
112
+ -- capybara:allow-destructive replace retired org permission keys with the narrower current choices
113
+ WITH legacy_orgs AS (
114
+ SELECT id, settings,
115
+ (settings ? 'autoMode' AND settings ->> 'autoMode' IS DISTINCT FROM 'allowed')
116
+ OR (settings ? 'fullAccess' AND settings ->> 'fullAccess' IS DISTINCT FROM 'allowed') AS legacy_off
117
+ FROM orgs
118
+ WHERE jsonb_typeof(settings) = 'object' AND settings ?| ARRAY['autoMode', 'fullAccess', 'cloudNetwork']
119
+ )
120
+ UPDATE orgs AS org
121
+ SET settings = (old.settings - ARRAY['autoMode', 'fullAccess', 'cloudNetwork', 'outsideSandbox', 'deviceNetwork'])
122
+ || jsonb_strip_nulls(jsonb_build_object(
123
+ 'outsideSandbox', CASE
124
+ WHEN old.legacy_off OR (old.settings ? 'outsideSandbox'
125
+ AND old.settings ->> 'outsideSandbox' IS DISTINCT FROM 'allowed') THEN 'off'
126
+ WHEN old.settings ?| ARRAY['autoMode', 'fullAccess', 'outsideSandbox'] THEN 'allowed'
127
+ END,
128
+ 'deviceNetwork', pg_temp.narrow_permission_network(
129
+ pg_temp.org_permission_network(old.settings -> 'deviceNetwork', false),
130
+ pg_temp.org_permission_network(old.settings -> 'cloudNetwork', true),
131
+ old.legacy_off)))
132
+ FROM legacy_orgs AS old WHERE org.id = old.id;
133
+
134
+ CREATE OR REPLACE FUNCTION pg_temp.permission_choice(value jsonb, field text) RETURNS text
135
+ LANGUAGE sql IMMUTABLE AS $$
136
+ SELECT CASE
137
+ WHEN jsonb_typeof(value) <> 'object' THEN 'off'
138
+ WHEN value - field <> '{}' OR (value ? field AND NOT COALESCE(value ->> field IN ('allowed', 'off'), false))
139
+ THEN 'off'
140
+ ELSE value ->> field
141
+ END
142
+ $$;
143
+
144
+ WITH legacy AS (
145
+ SELECT pg_temp.permission_choice(value, CASE key WHEN 'devicesFullAccess' THEN 'permission' ELSE 'mode' END) AS choice
146
+ FROM deployment_settings WHERE key IN ('devicesAutoMode', 'devicesFullAccess')
147
+ )
148
+ INSERT INTO deployment_settings (key, value)
149
+ SELECT 'devicesOutsideSandbox', jsonb_build_object('permission', CASE WHEN bool_or(choice = 'off') THEN 'off' ELSE 'allowed' END)
150
+ FROM legacy HAVING count(choice) > 0
151
+ ON CONFLICT (key) DO UPDATE SET value = CASE
152
+ WHEN 'off' IN (pg_temp.permission_choice(deployment_settings.value, 'permission'), EXCLUDED.value ->> 'permission')
153
+ THEN '{"permission":"off"}'::jsonb ELSE EXCLUDED.value END;
154
+
155
+ INSERT INTO deployment_settings (key, value)
156
+ SELECT 'devicesNetwork', '{"ceiling":"allowlist"}'
157
+ WHERE EXISTS (
158
+ SELECT 1 FROM deployment_settings
159
+ WHERE key IN ('devicesAutoMode', 'devicesFullAccess')
160
+ AND pg_temp.permission_choice(value, CASE key WHEN 'devicesFullAccess' THEN 'permission' ELSE 'mode' END) = 'off'
161
+ )
162
+ ON CONFLICT (key) DO UPDATE SET value = CASE
163
+ WHEN jsonb_typeof(deployment_settings.value) <> 'object'
164
+ THEN '{"default":"allowlist","ceiling":"allowlist"}'::jsonb
165
+ WHEN deployment_settings.value - ARRAY['default', 'ceiling'] <> '{}'
166
+ OR EXISTS (
167
+ SELECT 1 FROM jsonb_each_text(deployment_settings.value) AS setting(field, mode)
168
+ WHERE mode IS NULL OR mode NOT IN ('open', 'allowlist')
169
+ ) THEN '{"default":"allowlist","ceiling":"allowlist"}'::jsonb
170
+ ELSE deployment_settings.value || EXCLUDED.value
171
+ END;
172
+
173
+ -- capybara:allow-destructive the current deployment settings now carry both legacy permission switches
174
+ DELETE FROM deployment_settings WHERE key IN ('devicesAutoMode', 'devicesFullAccess');
175
+
176
+ -- capybara:allow-destructive replace each inherited device's retired allowlist snapshot with its current network choice
177
+ WITH pinned AS (
178
+ SELECT id, CASE
179
+ WHEN NOT pg_temp.permission_hosts_valid(outer_network -> 'hosts')
180
+ OR NOT pg_temp.permission_hosts_valid(network_hosts) THEN '[]'::jsonb
181
+ WHEN network_hosts = '[]' THEN COALESCE(outer_network -> 'hosts', '[]')
182
+ ELSE pg_temp.permission_host_overlap(outer_network -> 'hosts', network_hosts)
183
+ END AS hosts
184
+ FROM devices WHERE network_mode IS NULL AND outer_network ->> 'kind' = 'allowlist'
185
+ )
186
+ UPDATE devices AS device
187
+ SET network_mode = CASE WHEN pinned.hosts = '[]' THEN 'none' ELSE 'allowlist' END,
188
+ network_hosts = pinned.hosts, outer_network = NULL
189
+ FROM pinned WHERE device.id = pinned.id;
@@ -1,57 +0,0 @@
1
- import { KernelConfigService } from "../infra/config/kernel-config.service.js";
2
- import { LockService } from "../infra/lock/lock.service.js";
3
- import type { KernelLogger } from "../log.js";
4
- import { LegacyRetirementStore } from "../sandbox/legacy-retirement.js";
5
- import { SandboxOperationIntents } from "../sandbox/operation-intents.js";
6
- import { SandboxService } from "../sandbox/sandbox.service.js";
7
- import { BackgroundTaskStore } from "./store.js";
8
- /** The job's name (`@LockedInterval`, run lock `cron:background-retire-legacy-tasks`). */
9
- export declare const RETIRE_LEGACY_TASKS_JOB = "background-retire-legacy-tasks";
10
- /** Devices one tick tries (each one exclusive lease and at most one provider destroy each). */
11
- export declare const RETIRE_DEVICES_PER_TICK = 10;
12
- /** What one run did. */
13
- export interface RetireLegacyResult {
14
- /** New obligation members the enumeration recorded. */
15
- added: number;
16
- /** Devices left without an unresolved obligation. */
17
- cleared: number;
18
- /** Devices still unavailable (quarantined, or a destroy that failed). */
19
- unavailable: number;
20
- /** Devices held by someone: their next lifecycle acquisition runs the gate inline. */
21
- busy: number;
22
- /** Members whose own records were settled. */
23
- settled: number;
24
- /** Obligations abandoned with their deleted devices this tick. */
25
- abandoned: number;
26
- }
27
- /**
28
- * Legacy retirement (permission runtime cutover phase 8.5), once per tick across replicas:
29
- * 1. enumerates, until a pass adds nothing ({@link LegacyRetirementStore.scanUntilStable}),
30
- * the legacy rows (once the legacy-launch freeze is published) and the revoked managed starts
31
- * on incarnations that no longer run, as members of their device incarnation's obligation;
32
- * 2. for up to {@link RETIRE_DEVICES_PER_TICK} devices with an obligation due (backoff per
33
- * attempt), runs the sandbox service's retirement gate under one try at the exclusive
34
- * lifecycle lease (`SandboxService.retireLegacy`): a cloud incarnation is destroyed whole by its
35
- * provider, a local or unverifiable one is quarantined, a failure keeps the obligation;
36
- * 3. settles the members of resolved obligations: a revoked start's revocation is acknowledged
37
- * and its task's owed cancellation settled (`settleOwedCancel`; finish and event stay the
38
- * task's own), a legacy row's `kill_pending` is cleared (no process of a confirmed destroyed
39
- * incarnation can exist).
40
- * Retryable and bounded; the job missing or late never lets a device be used: every lifecycle
41
- * acquisition runs the same gate inline.
42
- */
43
- export declare class RetireLegacyTasksJob {
44
- private readonly retirement;
45
- private readonly sandbox;
46
- private readonly intents;
47
- private readonly tasks;
48
- readonly config: KernelConfigService;
49
- readonly lockService: LockService;
50
- readonly log: KernelLogger;
51
- constructor(retirement: Pick<LegacyRetirementStore, "scanUntilStable" | "due" | "unsettledMembers" | "markSettled" | "abandonDeleted">, sandbox: Pick<SandboxService, "retireLegacy">, intents: Pick<SandboxOperationIntents, "acknowledgeRevocation">, tasks: Pick<BackgroundTaskStore, "byOperation" | "settleOwedCancel" | "clearKill">, config: KernelConfigService, lockService: LockService, log: KernelLogger);
52
- tick(signal?: AbortSignal): Promise<void>;
53
- /** One run (see the class); `signal` (the stop, or a lost run lock) is read between devices. */
54
- runOnce(signal?: AbortSignal): Promise<RetireLegacyResult>;
55
- /** Settles one member of a resolved obligation; false while its task still runs. */
56
- private settle;
57
- }
@@ -1,149 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __param = (this && this.__param) || function (paramIndex, decorator) {
8
- return function (target, key) { decorator(target, key, paramIndex); }
9
- };
10
- import { Inject, Injectable } from "@nestjs/common";
11
- import { KernelConfigService } from "../infra/config/kernel-config.service.js";
12
- import { LockService } from "../infra/lock/lock.service.js";
13
- import { LockedInterval } from "../infra/schedule/locked-interval.js";
14
- import { KERNEL_LOGGER } from "../infra/tokens.js";
15
- import { LegacyRetirementStore } from "../sandbox/legacy-retirement.js";
16
- import { SandboxOperationIntents } from "../sandbox/operation-intents.js";
17
- import { SandboxService } from "../sandbox/sandbox.service.js";
18
- import { BackgroundTaskStore } from "./store.js";
19
- /** The job's name (`@LockedInterval`, run lock `cron:background-retire-legacy-tasks`). */
20
- export const RETIRE_LEGACY_TASKS_JOB = "background-retire-legacy-tasks";
21
- /** Every minute, once per tick across replicas. */
22
- const PERIOD_MS = 60_000;
23
- /** Devices one tick tries (each one exclusive lease and at most one provider destroy each). */
24
- export const RETIRE_DEVICES_PER_TICK = 10;
25
- /** Members of resolved obligations one tick settles. */
26
- const SETTLE_PER_TICK = 100;
27
- /** Obligations of gone devices resolved or abandoned per tick. */
28
- const ABANDON_PER_TICK = 100;
29
- /** The run lock outlives the slowest tick: a destroy per device. */
30
- const TICK_TTL_MS = 15 * 60_000;
31
- /**
32
- * Legacy retirement (permission runtime cutover phase 8.5), once per tick across replicas:
33
- * 1. enumerates, until a pass adds nothing ({@link LegacyRetirementStore.scanUntilStable}),
34
- * the legacy rows (once the legacy-launch freeze is published) and the revoked managed starts
35
- * on incarnations that no longer run, as members of their device incarnation's obligation;
36
- * 2. for up to {@link RETIRE_DEVICES_PER_TICK} devices with an obligation due (backoff per
37
- * attempt), runs the sandbox service's retirement gate under one try at the exclusive
38
- * lifecycle lease (`SandboxService.retireLegacy`): a cloud incarnation is destroyed whole by its
39
- * provider, a local or unverifiable one is quarantined, a failure keeps the obligation;
40
- * 3. settles the members of resolved obligations: a revoked start's revocation is acknowledged
41
- * and its task's owed cancellation settled (`settleOwedCancel`; finish and event stay the
42
- * task's own), a legacy row's `kill_pending` is cleared (no process of a confirmed destroyed
43
- * incarnation can exist).
44
- * Retryable and bounded; the job missing or late never lets a device be used: every lifecycle
45
- * acquisition runs the same gate inline.
46
- */
47
- let RetireLegacyTasksJob = class RetireLegacyTasksJob {
48
- retirement;
49
- sandbox;
50
- intents;
51
- tasks;
52
- config;
53
- lockService;
54
- log;
55
- constructor(retirement, sandbox, intents, tasks, config, lockService, log) {
56
- this.retirement = retirement;
57
- this.sandbox = sandbox;
58
- this.intents = intents;
59
- this.tasks = tasks;
60
- this.config = config;
61
- this.lockService = lockService;
62
- this.log = log;
63
- }
64
- async tick(signal) {
65
- const r = await this.runOnce(signal);
66
- if (r.added + r.cleared + r.unavailable + r.settled + r.abandoned > 0)
67
- this.log.info("legacy retirement tick", { ...r });
68
- }
69
- /** One run (see the class); `signal` (the stop, or a lost run lock) is read between devices. */
70
- async runOnce(signal) {
71
- const result = {
72
- added: 0,
73
- cleared: 0,
74
- unavailable: 0,
75
- busy: 0,
76
- settled: 0,
77
- abandoned: 0,
78
- };
79
- result.added = (await this.retirement.scanUntilStable()).added;
80
- // obligations of gone devices (deleted, or their org soft-deleted): a cloud one waits while
81
- // its destroy is owed (instance row kept), then resolves by a recorded confirmed destroy (an
82
- // abandoned one too), else abandoned (never evidence; no device can reuse them)
83
- result.abandoned = (await this.retirement.abandonDeleted(ABANDON_PER_TICK)).abandoned;
84
- for (const deviceId of await this.retirement.due(RETIRE_DEVICES_PER_TICK)) {
85
- if (signal?.aborted)
86
- return result;
87
- try {
88
- const outcome = await this.sandbox.retireLegacy(deviceId, signal);
89
- if (outcome === "clear")
90
- result.cleared++;
91
- else if (outcome === "unavailable")
92
- result.unavailable++;
93
- else
94
- result.busy++;
95
- }
96
- catch (err) {
97
- // retried at a later tick; the inline gate keeps the device closed meanwhile
98
- this.log.warn("legacy retirement failed; will retry", { deviceId, err });
99
- result.unavailable++;
100
- }
101
- }
102
- for (const m of await this.retirement.unsettledMembers(SETTLE_PER_TICK)) {
103
- if (signal?.aborted)
104
- return result;
105
- try {
106
- if (await this.settle(m)) {
107
- await this.retirement.markSettled(m);
108
- result.settled++;
109
- }
110
- }
111
- catch (err) {
112
- this.log.warn("cannot settle a retired legacy member; will retry", {
113
- kind: m.kind,
114
- ref: m.refId,
115
- err,
116
- });
117
- }
118
- }
119
- return result;
120
- }
121
- /** Settles one member of a resolved obligation; false while its task still runs. */
122
- async settle(m) {
123
- if (m.kind === "legacy-task") {
124
- await this.tasks.clearKill([m.refId]);
125
- return true;
126
- }
127
- await this.intents.acknowledgeRevocation(m.refId);
128
- const task = await this.tasks.byOperation(m.refId);
129
- if (!task)
130
- return true;
131
- await this.tasks.settleOwedCancel(task.id);
132
- const after = await this.tasks.byOperation(m.refId);
133
- return after === undefined || after.launchState !== "cancel-pending";
134
- }
135
- };
136
- __decorate([
137
- LockedInterval(RETIRE_LEGACY_TASKS_JOB, () => PERIOD_MS, { ttl: TICK_TTL_MS })
138
- ], RetireLegacyTasksJob.prototype, "tick", null);
139
- RetireLegacyTasksJob = __decorate([
140
- Injectable(),
141
- __param(0, Inject(LegacyRetirementStore)),
142
- __param(1, Inject(SandboxService)),
143
- __param(2, Inject(SandboxOperationIntents)),
144
- __param(3, Inject(BackgroundTaskStore)),
145
- __param(4, Inject(KernelConfigService)),
146
- __param(5, Inject(LockService)),
147
- __param(6, Inject(KERNEL_LOGGER))
148
- ], RetireLegacyTasksJob);
149
- export { RetireLegacyTasksJob };
@@ -1,47 +0,0 @@
1
- import { ExtensionAdminOps } from "../extensions/admin-ops.js";
2
- import { KernelDb } from "../infra/database/kernel-db.js";
3
- import { TransactionHost } from "../infra/database/transaction-host.js";
4
- import type { KernelLogger } from "../log.js";
5
- import { CatalogItemLock } from "./locks.js";
6
- /**
7
- * The cleanup of a removed org-owned plugin: {@link run} disables and uninstalls its extension (an
8
- * install of the item's name from the item's package) when no live catalog item uses it any more
9
- * ({@link OwnedPluginCleanup.referenced}), then releases the extension name claim, in one
10
- * transaction under the import's item name lock (pre-flight F10: the claim of an installed
11
- * extension is released here, never at the removal). Idempotent: a live item (a transferred one),
12
- * a platform item or nothing installed changes nothing but the claim. The extension's data,
13
- * secrets and configs stay, as with every uninstall.
14
- */
15
- export declare class OwnedPluginCleanup {
16
- private readonly kdb;
17
- private readonly ops;
18
- /** The import's item name lock (M5: no uninstall racing a re-import of the package). */
19
- private readonly itemLock;
20
- private readonly log;
21
- readonly txHost: TransactionHost;
22
- constructor(kdb: KernelDb, ops: ExtensionAdminOps,
23
- /** The import's item name lock (M5: no uninstall racing a re-import of the package). */
24
- itemLock: CatalogItemLock, log: KernelLogger, txHost: TransactionHost);
25
- private get db();
26
- /** Takes out the extension of removed item `itemId` (see the class). */
27
- run(itemId: string): Promise<void>;
28
- /**
29
- * {@link run}'s one transaction, under the catalog item name lock an import of that name takes
30
- * to write its item: a re-import of the package either committed first (a live item: nothing
31
- * is taken out) or waits until this commits, so a newly imported extension is never uninstalled.
32
- */
33
- private takeOut;
34
- /**
35
- * A live catalog item still uses the extension: one named like it (a plugin and its extension
36
- * share one name) from the same package whose owner is the removed item's owner (a re-upload)
37
- * or the platform (the super admin imported it over the install). Never any item of the package
38
- * name alone: another org choosing the same package name keeps nothing installed (ruling P3-51).
39
- */
40
- private referenced;
41
- }
42
- /**
43
- * {@link OwnedPluginCleanup}: imported only by `MaintenanceModule` (the job's dispatcher), which
44
- * only the worker role imports.
45
- */
46
- export declare class OwnedPluginCleanupModule {
47
- }