@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
@@ -20,7 +20,6 @@ import { KernelDb } from "../infra/database/kernel-db.js";
20
20
  import { TransactionHost } from "../infra/database/transaction-host.js";
21
21
  import { Transactional } from "../infra/database/transactional.decorator.js";
22
22
  import { KEYRING } from "../infra/tokens.js";
23
- import { OrgLock } from "../orgs/org-lock.js";
24
23
  import { fetchNpmPackage, IntegrityMismatchError, NpmFetchError, PackageTooLargeError, } from "../packages/npm.js";
25
24
  import { fetchProvenance, PROVENANCE_TIMEOUT_MS, } from "../packages/provenance.js";
26
25
  import { ExtensionApprovals } from "./approvals.js";
@@ -48,14 +47,11 @@ let ExtensionInstalls = class ExtensionInstalls {
48
47
  registry;
49
48
  config;
50
49
  keyring;
51
- orgLock;
52
50
  constructor(db, txHost,
53
51
  /** The super admin lock (identity/super-admin.ts): joins the transaction. */
54
52
  adminLock, blobs, approvals,
55
53
  /** The config-declared extension names (an install cannot take them, C15). */
56
- registry, config, keyring,
57
- /** The owner org's lock: an org upload re-checks its org admin instead (ruling P3-10). */
58
- orgLock) {
54
+ registry, config, keyring) {
59
55
  this.db = db;
60
56
  this.txHost = txHost;
61
57
  this.adminLock = adminLock;
@@ -64,7 +60,6 @@ let ExtensionInstalls = class ExtensionInstalls {
64
60
  this.registry = registry;
65
61
  this.config = config;
66
62
  this.keyring = keyring;
67
- this.orgLock = orgLock;
68
63
  }
69
64
  /**
70
65
  * An extension's effective deployment config, not validated yet (C10): the startup config
@@ -103,14 +98,9 @@ let ExtensionInstalls = class ExtensionInstalls {
103
98
  * - extension name equal to a config-declared one -> `extension.config_declared`;
104
99
  * - an install record of the same name comes from another npm package -> `extension.name_conflict`
105
100
  * (a new version of the same package is an upgrade, handled elsewhere).
106
- * `actor` null means the CLI (no super admin re-check, audit without an actor). `owner`: an org
107
- * upload (spec §14, P3-10): the actor is re-checked as an org admin of that org (`catalog.upload`)
108
- * instead of a super admin; the package is only stored, as always (nothing runs, no install).
101
+ * A null actor means the CLI, which audits without an actor.
109
102
  */
110
103
  async ingest(actor, bytes, src, opts = {}) {
111
- if (opts.owner !== undefined && actor === null) {
112
- throw new Error("an org upload has an actor");
113
- }
114
104
  const maxBytes = this.config.get().packages.maxBytes;
115
105
  if (bytes.byteLength > maxBytes) {
116
106
  throw new ApiError("extension.package_too_large", `The extension package is larger than ${maxBytes} bytes`);
@@ -145,9 +135,9 @@ let ExtensionInstalls = class ExtensionInstalls {
145
135
  if (installed && installed.package_name !== packageName) {
146
136
  throw new ApiError("extension.name_conflict", `Extension ${m.name} is already installed from package ${installed.package_name}; package ${packageName} uses the same extension name`);
147
137
  }
148
- // 写包之前在锁内复核发起人仍是超级管理员(守卫读到的身份可能已过期);审计在写完后同样复核
138
+ // Recheck the actor under the super admin lock before storing the package and before auditing.
149
139
  if (actor !== null)
150
- await this.authorize(actor, opts.owner);
140
+ await this.authorize(actor);
151
141
  await this.blobs.put(pkg, bytes, {
152
142
  source: src.source,
153
143
  ref: src.ref,
@@ -159,9 +149,8 @@ let ExtensionInstalls = class ExtensionInstalls {
159
149
  version: m.version,
160
150
  sha256: pkg.sha256,
161
151
  source: src.source,
162
- ...(opts.owner !== undefined && { orgId: opts.owner.orgId }),
163
152
  ...opts.auditDetail,
164
- }, opts.owner);
153
+ });
165
154
  const set = permissionSetOfPackage(pkg);
166
155
  const snapshot = (await this.approvals.all()).get(m.name);
167
156
  const { added, removed } = diffPermissions(snapshot?.permissions, set);
@@ -183,23 +172,16 @@ let ExtensionInstalls = class ExtensionInstalls {
183
172
  * before the conversion): the package write that follows never runs inside a caller's
184
173
  * transaction holding the lock.
185
174
  */
186
- async authorize(actor, owner) {
187
- await this.authorizeIn(actor, owner);
188
- }
189
- /** The super admin, or for an org upload the owner org's admin, re-checked under its lock. */
190
- async authorizeIn(actor, owner) {
191
- if (owner !== undefined)
192
- await this.orgLock.lockAndAuthorize(owner.orgId, actor, "catalog.upload");
193
- else
194
- await this.adminLock.lockAndAuthorize(actor);
175
+ async authorize(actor) {
176
+ await this.adminLock.lockAndAuthorize(actor);
195
177
  }
196
178
  /**
197
179
  * The `extension.package_uploaded` audit, re-checking the actor under the lock, committed on its
198
180
  * own (`requires_new`): the stored package it records is not rolled back by a caller either.
199
181
  */
200
- async auditUpload(actor, actorTokenId, detail, owner) {
182
+ async auditUpload(actor, actorTokenId, detail) {
201
183
  if (actor !== null)
202
- await this.authorizeIn(actor, owner);
184
+ await this.adminLock.lockAndAuthorize(actor);
203
185
  await audit(this.db.db, {
204
186
  ...(actor !== null && { actorAccountId: actor }),
205
187
  ...(actorTokenId !== undefined && { actorTokenId }),
@@ -373,9 +355,6 @@ let ExtensionInstalls = class ExtensionInstalls {
373
355
  __decorate([
374
356
  Transactional({ propagation: "requires_new" })
375
357
  ], ExtensionInstalls.prototype, "authorize", null);
376
- __decorate([
377
- Transactional({ propagation: "mandatory" })
378
- ], ExtensionInstalls.prototype, "authorizeIn", null);
379
358
  __decorate([
380
359
  Transactional({ propagation: "requires_new" })
381
360
  ], ExtensionInstalls.prototype, "auditUpload", null);
@@ -388,7 +367,6 @@ ExtensionInstalls = __decorate([
388
367
  __param(4, Inject(ExtensionApprovals)),
389
368
  __param(5, Inject(ExtensionRegistry)),
390
369
  __param(6, Inject(KernelConfigService)),
391
- __param(7, Inject(KEYRING)),
392
- __param(8, Inject(OrgLock))
370
+ __param(7, Inject(KEYRING))
393
371
  ], ExtensionInstalls);
394
372
  export { ExtensionInstalls };
@@ -102,10 +102,9 @@ export interface OrgExtensionPutOptions {
102
102
  }
103
103
  /**
104
104
  * Org-level extension enablement (`capybara.extension_org_configs.enabled`) and the org's view of
105
- * each extension. An org's config of an extension is its copy of the overridable deployment fields
106
- * (`OrgOverrides`, `EffectiveConfigs`); the retired `config` column and the `plugin-config:` org
107
- * secrets are neither read nor written (spec §5.4; dropped by a later contract migration).
108
- * No in-process state: every call reads PG, safe with multiple replicas.
105
+ * each extension. OrgOverrides manages the org's copy of overridable deployment fields.
106
+ * EffectiveConfigs validates the config used for org-bound calls. Each replica reads enablement
107
+ * from PostgreSQL.
109
108
  */
110
109
  export declare class OrgExtensionConfigs {
111
110
  private readonly kdb;
@@ -50,10 +50,9 @@ function scopeFields(items, required) {
50
50
  }
51
51
  /**
52
52
  * Org-level extension enablement (`capybara.extension_org_configs.enabled`) and the org's view of
53
- * each extension. An org's config of an extension is its copy of the overridable deployment fields
54
- * (`OrgOverrides`, `EffectiveConfigs`); the retired `config` column and the `plugin-config:` org
55
- * secrets are neither read nor written (spec §5.4; dropped by a later contract migration).
56
- * No in-process state: every call reads PG, safe with multiple replicas.
53
+ * each extension. OrgOverrides manages the org's copy of overridable deployment fields.
54
+ * EffectiveConfigs validates the config used for org-bound calls. Each replica reads enablement
55
+ * from PostgreSQL.
57
56
  */
58
57
  let OrgExtensionConfigs = class OrgExtensionConfigs {
59
58
  kdb;
@@ -109,7 +109,6 @@ type VersionFile = {
109
109
  };
110
110
  /** The live items (with their latest version) by name or id. */
111
111
  declare function latestItems(db: KernelDb, by: "name" | "id", keys: string[]): Promise<{
112
- awaiting_confirmation: boolean;
113
112
  builtin: boolean;
114
113
  disabled: boolean;
115
114
  files: {
@@ -41,7 +41,6 @@ function latestItems(db, by, keys) {
41
41
  "i.shown_to_others",
42
42
  "i.owner_org_id",
43
43
  "i.shareable",
44
- "i.awaiting_confirmation",
45
44
  "i.latest_version",
46
45
  "v.manifest",
47
46
  "v.files",
@@ -32,7 +32,6 @@ export interface OrgVisibilityRow {
32
32
  shown_to_others: boolean;
33
33
  owner_org_id: string | null;
34
34
  shareable: boolean;
35
- awaiting_confirmation: boolean;
36
35
  }
37
36
  /**
38
37
  * The rows of live catalog items the org's catalog shows (one query for the org's list rows):
@@ -44,7 +44,6 @@ export async function orgVisibleItems(db, rows, orgId, isAdmin) {
44
44
  const inList = listed.has(r.id);
45
45
  const own = r.owner_org_id === orgId;
46
46
  return ((isAdmin || !r.disabled) &&
47
- (!r.awaiting_confirmation || own) &&
48
47
  // the share gate: another org's item reaches this org only when shareable or listed here
49
48
  (r.owner_org_id === null || own || r.shareable || inList) &&
50
49
  (r.builtin || r.scope !== "named" || inList || requestable(r, inList)));
@@ -258,7 +257,6 @@ let PluginIcons = class PluginIcons {
258
257
  "i.shown_to_others",
259
258
  "i.owner_org_id",
260
259
  "i.shareable",
261
- "i.awaiting_confirmation",
262
260
  ])
263
261
  .where("t.id", "in", unique)
264
262
  .where("t.deleted_at", "is", null)
@@ -305,7 +303,6 @@ let PluginIcons = class PluginIcons {
305
303
  "i.shown_to_others",
306
304
  "i.owner_org_id",
307
305
  "i.shareable",
308
- "i.awaiting_confirmation",
309
306
  "i.latest_version",
310
307
  sql `v.manifest->>'icon'`.as("icon"),
311
308
  "v.files",
@@ -6,7 +6,6 @@ import { LockService } from "../infra/lock/lock.service.js";
6
6
  import { OutboxService } from "../infra/outbox/outbox.service.js";
7
7
  import type { KernelLogger } from "../log.js";
8
8
  import { StorageService } from "../storage/storage.service.js";
9
- import { FileLibraryBackfill } from "./library-backfill.js";
10
9
  /** The daily blob sweep's name (scheduler key and lock; no `:`). */
11
10
  export declare const BLOB_SWEEP_JOB = "blob-sweep";
12
11
  /** When the daily blob sweep runs (the deployment's time zone): after the share sweep (03:40). */
@@ -40,8 +39,6 @@ export interface BlobSweepResult {
40
39
  interface ReleaseKind {
41
40
  statuses: readonly BlobStatus[];
42
41
  olderThanHours: number;
43
- /** Only blobs with a sha256 (while the catch-up copy has not settled; see the class comment). */
44
- hashedOnly?: boolean;
45
42
  }
46
43
  /**
47
44
  * The daily blob sweep (file library spec §7), a `@LockedCron` (once per tick across replicas,
@@ -56,12 +53,7 @@ interface ReleaseKind {
56
53
  * settled) likewise;
57
54
  * 4. `deleting` blobs older than {@link STALE_DELETING_AFTER_HOURS} are reconciled: one nothing
58
55
  * refers to has its deletion owed again (the job may have run out of attempts); one something
59
- * refers to (only `file_library_copy` inserts a reference without `BlobsService.lockReady`, and
60
- * the deletion job refuses a referenced blob before touching its bytes) is restored: `ready`
61
- * when its object is still the recorded bytes, else `gone`.
62
- *
63
- * Until the catch-up copy settled ({@link FileLibraryBackfill.settled}) step 2 leaves unhashed
64
- * (migrated) blobs alone: the copy may still point new files or shares at them.
56
+ * refers to is restored: `ready` when its object is still the recorded bytes, else `gone`.
65
57
  *
66
58
  * A claim locks its candidates `FOR UPDATE SKIP LOCKED` (a blob another transaction is pointing a
67
59
  * reference at holds `FOR SHARE` through `BlobsService.lockReady` and is skipped), then sets
@@ -77,10 +69,9 @@ export declare class BlobSweepJob {
77
69
  private readonly outbox;
78
70
  private readonly config;
79
71
  private readonly storage;
80
- private readonly backfill;
81
72
  readonly lockService: LockService;
82
73
  readonly log: KernelLogger;
83
- constructor(db: KernelDb, txHost: TransactionHost, outbox: Pick<OutboxService, "add">, config: Pick<KernelConfigService, "get">, storage: Pick<StorageService, "kernel">, backfill: Pick<FileLibraryBackfill, "settled">, lockService: LockService, log: KernelLogger);
74
+ constructor(db: KernelDb, txHost: TransactionHost, outbox: Pick<OutboxService, "add">, config: Pick<KernelConfigService, "get">, storage: Pick<StorageService, "kernel">, lockService: LockService, log: KernelLogger);
84
75
  sweep(signal?: AbortSignal): Promise<void>;
85
76
  /** One sweep without the tick lock (the cron body; tests call it directly). */
86
77
  runOnce(signal?: AbortSignal): Promise<BlobSweepResult>;
@@ -23,7 +23,6 @@ import { StorageService } from "../storage/storage.service.js";
23
23
  import { oweBlobDelete } from "./blob-objects.js";
24
24
  import { blobUnreferenced } from "./blob-references.js";
25
25
  import { blobContentMatches } from "./blobs.service.js";
26
- import { FileLibraryBackfill } from "./library-backfill.js";
27
26
  /** The daily blob sweep's name (scheduler key and lock; no `:`). */
28
27
  export const BLOB_SWEEP_JOB = "blob-sweep";
29
28
  /** When the daily blob sweep runs (the deployment's time zone): after the share sweep (03:40). */
@@ -62,12 +61,7 @@ const ABANDONED = { statuses: ["pending"], olderThanHours: PENDING_AFTER_HOURS }
62
61
  * settled) likewise;
63
62
  * 4. `deleting` blobs older than {@link STALE_DELETING_AFTER_HOURS} are reconciled: one nothing
64
63
  * refers to has its deletion owed again (the job may have run out of attempts); one something
65
- * refers to (only `file_library_copy` inserts a reference without `BlobsService.lockReady`, and
66
- * the deletion job refuses a referenced blob before touching its bytes) is restored: `ready`
67
- * when its object is still the recorded bytes, else `gone`.
68
- *
69
- * Until the catch-up copy settled ({@link FileLibraryBackfill.settled}) step 2 leaves unhashed
70
- * (migrated) blobs alone: the copy may still point new files or shares at them.
64
+ * refers to is restored: `ready` when its object is still the recorded bytes, else `gone`.
71
65
  *
72
66
  * A claim locks its candidates `FOR UPDATE SKIP LOCKED` (a blob another transaction is pointing a
73
67
  * reference at holds `FOR SHARE` through `BlobsService.lockReady` and is skipped), then sets
@@ -83,16 +77,14 @@ let BlobSweepJob = class BlobSweepJob {
83
77
  outbox;
84
78
  config;
85
79
  storage;
86
- backfill;
87
80
  lockService;
88
81
  log;
89
- constructor(db, txHost, outbox, config, storage, backfill, lockService, log) {
82
+ constructor(db, txHost, outbox, config, storage, lockService, log) {
90
83
  this.db = db;
91
84
  this.txHost = txHost;
92
85
  this.outbox = outbox;
93
86
  this.config = config;
94
87
  this.storage = storage;
95
- this.backfill = backfill;
96
88
  this.lockService = lockService;
97
89
  this.log = log;
98
90
  }
@@ -111,16 +103,13 @@ let BlobSweepJob = class BlobSweepJob {
111
103
  deletionsReowed: 0,
112
104
  deletingRestored: 0,
113
105
  };
114
- const unreferencedKind = (await this.backfill.settled())
115
- ? UNREFERENCED
116
- : { ...UNREFERENCED, hashedOnly: true };
117
106
  let after = null;
118
107
  while (!signal?.aborted) {
119
108
  const orgs = await this.orgPage(after);
120
109
  for (const orgId of orgs) {
121
110
  if (signal?.aborted)
122
111
  return r;
123
- await withOrgScope(orgId, () => this.sweepOrg(orgId, unreferencedKind, r, signal));
112
+ await withOrgScope(orgId, () => this.sweepOrg(orgId, r, signal));
124
113
  }
125
114
  if (orgs.length < ORG_PAGE)
126
115
  break;
@@ -143,7 +132,7 @@ let BlobSweepJob = class BlobSweepJob {
143
132
  });
144
133
  }
145
134
  /** The four steps for one org (in its scope). */
146
- async sweepOrg(orgId, unreferencedKind, r, signal) {
135
+ async sweepOrg(orgId, r, signal) {
147
136
  for (;;) {
148
137
  if (signal?.aborted)
149
138
  return;
@@ -152,7 +141,7 @@ let BlobSweepJob = class BlobSweepJob {
152
141
  if (n < BATCH)
153
142
  break;
154
143
  }
155
- r.blobsReleased += await this.releaseAll(orgId, unreferencedKind, signal);
144
+ r.blobsReleased += await this.releaseAll(orgId, UNREFERENCED, signal);
156
145
  r.pendingReleased += await this.releaseAll(orgId, ABANDONED, signal);
157
146
  let after = null;
158
147
  while (!signal?.aborted) {
@@ -226,7 +215,6 @@ let BlobSweepJob = class BlobSweepJob {
226
215
  .where("status", "in", [...kind.statuses])
227
216
  .where("created_at", "<", old)
228
217
  .where(blobUnreferenced(orgId))
229
- .$if(kind.hashedOnly === true, (q) => q.where("sha256", "is not", null))
230
218
  .$if(after !== null, (q) => q.where("id", ">", after))
231
219
  .orderBy("id")
232
220
  .limit(BATCH)
@@ -244,7 +232,6 @@ let BlobSweepJob = class BlobSweepJob {
244
232
  .where("id", "in", candidates.map((c) => c.id))
245
233
  .where("status", "in", [...kind.statuses])
246
234
  .where(blobUnreferenced(orgId))
247
- .$if(kind.hashedOnly === true, (q) => q.where("sha256", "is not", null))
248
235
  .returning("id")
249
236
  .execute();
250
237
  for (const b of released)
@@ -364,8 +351,7 @@ BlobSweepJob = __decorate([
364
351
  __param(2, Inject(OutboxService)),
365
352
  __param(3, Inject(KernelConfigService)),
366
353
  __param(4, Inject(StorageService)),
367
- __param(5, Inject(FileLibraryBackfill)),
368
- __param(6, Inject(LockService)),
369
- __param(7, Inject(KERNEL_LOGGER))
354
+ __param(5, Inject(LockService)),
355
+ __param(6, Inject(KERNEL_LOGGER))
370
356
  ], BlobSweepJob);
371
357
  export { BlobSweepJob };
@@ -6,7 +6,6 @@ import { OutboxService } from "../infra/outbox/outbox.service.js";
6
6
  import type { KernelLogger } from "../log.js";
7
7
  import { StorageService } from "../storage/storage.service.js";
8
8
  import { BlobHashLock, BlobsService } from "./blobs.service.js";
9
- import { FileLibraryBackfill } from "./library-backfill.js";
10
9
  /** The hashing dispatcher's job name and deterministic id (no `:`). */
11
10
  export declare const FILE_LIBRARY_HASH_JOB = "file-library-hash";
12
11
  /** The job name of one org's hashing batch. */
@@ -69,8 +68,6 @@ interface UnhashedBlob {
69
68
  * the holder (locked through `BlobsService.lockReady`), this blob becomes `deleting` and its
70
69
  * deletion is owed (deferred {@link MERGE_DELETE_DELAY_MS}). Anything else leaves the blob for a
71
70
  * later pass. A file keeps the reference it was first stored under (`ref_key` / `ref_etag`).
72
- *
73
- * Nothing merges before the catch-up copy settled ({@link FileLibraryBackfill.settled}).
74
71
  */
75
72
  export declare class FileLibraryHashJob {
76
73
  private readonly db;
@@ -79,10 +76,9 @@ export declare class FileLibraryHashJob {
79
76
  private readonly outbox;
80
77
  private readonly hashLock;
81
78
  private readonly blobs;
82
- private readonly backfill;
83
79
  private readonly locks;
84
80
  private readonly log;
85
- constructor(db: KernelDb, txHost: TransactionHost, storage: Pick<StorageService, "kernel">, outbox: Pick<OutboxService, "add" | "addMany">, hashLock: Pick<BlobHashLock, "lock">, blobs: Pick<BlobsService, "lockReady">, backfill: Pick<FileLibraryBackfill, "settled">, locks: Pick<LockService, "acquire">, log: Pick<KernelLogger, "info" | "warn">);
81
+ constructor(db: KernelDb, txHost: TransactionHost, storage: Pick<StorageService, "kernel">, outbox: Pick<OutboxService, "add" | "addMany">, hashLock: Pick<BlobHashLock, "lock">, blobs: Pick<BlobsService, "lockReady">, locks: Pick<LockService, "acquire">, log: Pick<KernelLogger, "info" | "warn">);
86
82
  /** Whether any org has a blob to hash (the kickoff's test). */
87
83
  anyUnhashed(): Promise<boolean>;
88
84
  /** Owes the dispatcher (a no-op while it is owed or waiting: the same job id). */
@@ -105,23 +101,17 @@ export declare class FileLibraryHashJob {
105
101
  }
106
102
  /**
107
103
  * The hourly kickoff of the file library's background work (`@LockedInterval`, once per tick
108
- * across replicas, also once at worker start; provided only under `WorkerModule`): until the
109
- * catch-up copy settled it owes {@link FileLibraryBackfill} (30 minutes later while the deploy is
110
- * recent); afterwards, while unhashed blobs exist, it owes the hashing dispatcher. Both are owed
111
- * under deterministic ids, so owing them again while they wait is a no-op.
104
+ * across replicas, also once at worker start; provided only under `WorkerModule`). While unhashed
105
+ * blobs exist, it owes the hashing dispatcher under a deterministic id.
112
106
  */
113
107
  export declare class FileLibraryKickoffJob {
114
- private readonly backfill;
115
108
  private readonly hashing;
116
109
  readonly config: KernelConfigService;
117
110
  readonly lockService: LockService;
118
111
  readonly log: KernelLogger;
119
- constructor(backfill: Pick<FileLibraryBackfill, "settled" | "ensureOwed">, hashing: Pick<FileLibraryHashJob, "anyUnhashed" | "oweDispatch">, config: KernelConfigService, lockService: LockService, log: KernelLogger);
112
+ constructor(hashing: Pick<FileLibraryHashJob, "anyUnhashed" | "oweDispatch">, config: KernelConfigService, lockService: LockService, log: KernelLogger);
120
113
  tick(): Promise<void>;
121
114
  /** One kickoff without the tick lock (the interval body; tests call it directly). */
122
- runOnce(): Promise<{
123
- backfillOwed: boolean;
124
- hashOwed: boolean;
125
- }>;
115
+ runOnce(): Promise<boolean>;
126
116
  }
127
117
  export {};
@@ -23,7 +23,6 @@ import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
23
23
  import { StorageService } from "../storage/storage.service.js";
24
24
  import { oweBlobDelete } from "./blob-objects.js";
25
25
  import { BlobHashLock, BlobsService, blobContentMatches } from "./blobs.service.js";
26
- import { FileLibraryBackfill } from "./library-backfill.js";
27
26
  /** The hashing dispatcher's job name and deterministic id (no `:`). */
28
27
  export const FILE_LIBRARY_HASH_JOB = "file-library-hash";
29
28
  /** The job name of one org's hashing batch. */
@@ -67,8 +66,6 @@ export const fileLibraryHashOrgJobId = (orgId, after) => `file-library-hash-${or
67
66
  * the holder (locked through `BlobsService.lockReady`), this blob becomes `deleting` and its
68
67
  * deletion is owed (deferred {@link MERGE_DELETE_DELAY_MS}). Anything else leaves the blob for a
69
68
  * later pass. A file keeps the reference it was first stored under (`ref_key` / `ref_etag`).
70
- *
71
- * Nothing merges before the catch-up copy settled ({@link FileLibraryBackfill.settled}).
72
69
  */
73
70
  let FileLibraryHashJob = class FileLibraryHashJob {
74
71
  db;
@@ -77,17 +74,15 @@ let FileLibraryHashJob = class FileLibraryHashJob {
77
74
  outbox;
78
75
  hashLock;
79
76
  blobs;
80
- backfill;
81
77
  locks;
82
78
  log;
83
- constructor(db, txHost, storage, outbox, hashLock, blobs, backfill, locks, log) {
79
+ constructor(db, txHost, storage, outbox, hashLock, blobs, locks, log) {
84
80
  this.db = db;
85
81
  this.txHost = txHost;
86
82
  this.storage = storage;
87
83
  this.outbox = outbox;
88
84
  this.hashLock = hashLock;
89
85
  this.blobs = blobs;
90
- this.backfill = backfill;
91
86
  this.locks = locks;
92
87
  this.log = log;
93
88
  }
@@ -119,8 +114,6 @@ let FileLibraryHashJob = class FileLibraryHashJob {
119
114
  }
120
115
  /** The dispatcher job: owes the first batch of every live org with unhashed blobs. */
121
116
  async dispatch() {
122
- if (!(await this.backfill.settled()))
123
- return 0;
124
117
  const orgs = await asPlatform("file library hashing: the orgs with unhashed blobs", async () => {
125
118
  // deployment-wide: which orgs to hash (each org then hashes in its scope)
126
119
  const rows = await this.db
@@ -159,8 +152,6 @@ let FileLibraryHashJob = class FileLibraryHashJob {
159
152
  if (!handle)
160
153
  return result;
161
154
  try {
162
- if (!(await this.backfill.settled()))
163
- return result;
164
155
  result.ran = true;
165
156
  const rows = await this.unhashed(data);
166
157
  for (const row of rows) {
@@ -391,44 +382,35 @@ FileLibraryHashJob = __decorate([
391
382
  __param(3, Inject(OutboxService)),
392
383
  __param(4, Inject(BlobHashLock)),
393
384
  __param(5, Inject(BlobsService)),
394
- __param(6, Inject(FileLibraryBackfill)),
395
- __param(7, Inject(LockService)),
396
- __param(8, Inject(KERNEL_LOGGER))
385
+ __param(6, Inject(LockService)),
386
+ __param(7, Inject(KERNEL_LOGGER))
397
387
  ], FileLibraryHashJob);
398
388
  export { FileLibraryHashJob };
399
389
  /**
400
390
  * The hourly kickoff of the file library's background work (`@LockedInterval`, once per tick
401
- * across replicas, also once at worker start; provided only under `WorkerModule`): until the
402
- * catch-up copy settled it owes {@link FileLibraryBackfill} (30 minutes later while the deploy is
403
- * recent); afterwards, while unhashed blobs exist, it owes the hashing dispatcher. Both are owed
404
- * under deterministic ids, so owing them again while they wait is a no-op.
391
+ * across replicas, also once at worker start; provided only under `WorkerModule`). While unhashed
392
+ * blobs exist, it owes the hashing dispatcher under a deterministic id.
405
393
  */
406
394
  let FileLibraryKickoffJob = class FileLibraryKickoffJob {
407
- backfill;
408
395
  hashing;
409
396
  config;
410
397
  lockService;
411
398
  log;
412
- constructor(backfill, hashing, config, lockService, log) {
413
- this.backfill = backfill;
399
+ constructor(hashing, config, lockService, log) {
414
400
  this.hashing = hashing;
415
401
  this.config = config;
416
402
  this.lockService = lockService;
417
403
  this.log = log;
418
404
  }
419
405
  async tick() {
420
- const r = await this.runOnce();
421
- if (r.backfillOwed || r.hashOwed)
422
- this.log.info("file library jobs owed", { ...r });
406
+ if (await this.runOnce())
407
+ this.log.info("file library hashing owed");
423
408
  }
424
409
  /** One kickoff without the tick lock (the interval body; tests call it directly). */
425
410
  async runOnce() {
426
- if (!(await this.backfill.settled())) {
427
- return { backfillOwed: await this.backfill.ensureOwed(), hashOwed: false };
428
- }
429
411
  if (!(await this.hashing.anyUnhashed()))
430
- return { backfillOwed: false, hashOwed: false };
431
- return { backfillOwed: false, hashOwed: await this.hashing.oweDispatch() };
412
+ return false;
413
+ return this.hashing.oweDispatch();
432
414
  }
433
415
  };
434
416
  __decorate([
@@ -438,10 +420,9 @@ __decorate([
438
420
  ], FileLibraryKickoffJob.prototype, "tick", null);
439
421
  FileLibraryKickoffJob = __decorate([
440
422
  Injectable(),
441
- __param(0, Inject(FileLibraryBackfill)),
442
- __param(1, Inject(FileLibraryHashJob)),
443
- __param(2, Inject(KernelConfigService)),
444
- __param(3, Inject(LockService)),
445
- __param(4, Inject(KERNEL_LOGGER))
423
+ __param(0, Inject(FileLibraryHashJob)),
424
+ __param(1, Inject(KernelConfigService)),
425
+ __param(2, Inject(LockService)),
426
+ __param(3, Inject(KERNEL_LOGGER))
446
427
  ], FileLibraryKickoffJob);
447
428
  export { FileLibraryKickoffJob };
@@ -1,8 +1,3 @@
1
- /**
2
- * The file library's background jobs that the maintenance queue runs: the one-off catch-up copy
3
- * ({@link FileLibraryBackfill}) and the hashing of migrated blobs ({@link FileLibraryHashJob}).
4
- * Imported by the worker role only (`MaintenanceModule`, `WorkerModule`), which also provides
5
- * their kickoff and the daily blob sweep.
6
- */
1
+ /** Hashing of migrated blobs ({@link FileLibraryHashJob}), provided to the worker. */
7
2
  export declare class FileLibraryJobsModule {
8
3
  }
@@ -8,20 +8,14 @@ import { Module } from "@nestjs/common";
8
8
  import { StorageModule } from "../storage/storage.module.js";
9
9
  import { FileLibraryHashJob } from "./hash-job.js";
10
10
  import { LibraryFilesModule } from "./library.module.js";
11
- import { FileLibraryBackfill } from "./library-backfill.js";
12
- /**
13
- * The file library's background jobs that the maintenance queue runs: the one-off catch-up copy
14
- * ({@link FileLibraryBackfill}) and the hashing of migrated blobs ({@link FileLibraryHashJob}).
15
- * Imported by the worker role only (`MaintenanceModule`, `WorkerModule`), which also provides
16
- * their kickoff and the daily blob sweep.
17
- */
11
+ /** Hashing of migrated blobs ({@link FileLibraryHashJob}), provided to the worker. */
18
12
  let FileLibraryJobsModule = class FileLibraryJobsModule {
19
13
  };
20
14
  FileLibraryJobsModule = __decorate([
21
15
  Module({
22
16
  imports: [StorageModule, LibraryFilesModule],
23
- providers: [FileLibraryBackfill, FileLibraryHashJob],
24
- exports: [FileLibraryBackfill, FileLibraryHashJob],
17
+ providers: [FileLibraryHashJob],
18
+ exports: [FileLibraryHashJob],
25
19
  })
26
20
  ], FileLibraryJobsModule);
27
21
  export { FileLibraryJobsModule };