@capybara-hq/kernel 0.1.0-rc.146 → 0.1.0-rc.147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/extensions.controller.d.ts +0 -11
- package/dist/admin/extensions.controller.js +0 -28
- package/dist/admin/health.service.d.ts +25 -1
- package/dist/admin/health.service.js +50 -18
- package/dist/audit/full-access.d.ts +78 -0
- package/dist/audit/full-access.js +283 -0
- package/dist/automations/automations.service.d.ts +1 -0
- package/dist/automations/automations.service.js +3 -1
- package/dist/automations/calendar.js +3 -1
- package/dist/automations/grant-rules.d.ts +2 -1
- package/dist/automations/grant-rules.js +8 -1
- package/dist/automations/unattended.d.ts +13 -1
- package/dist/automations/unattended.js +13 -1
- package/dist/catalog/admin-catalog.controller.d.ts +8 -0
- package/dist/catalog/admin-catalog.controller.js +8 -2
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +8 -1
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-scope.service.d.ts +22 -2
- package/dist/catalog/catalog-scope.service.js +27 -3
- package/dist/catalog/catalog.service.js +19 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +8 -1
- package/dist/catalog/org-catalog.service.js +36 -3
- package/dist/catalog/platform-components.js +3 -2
- package/dist/catalog/platform-import-update.d.ts +2 -0
- package/dist/catalog/platform-import-update.js +8 -1
- package/dist/catalog/plugin-connectors.d.ts +11 -0
- package/dist/catalog/plugin-connectors.js +33 -0
- package/dist/catalog/plugin-import.d.ts +35 -15
- package/dist/catalog/plugin-import.js +110 -35
- package/dist/catalog/plugin-install.js +6 -0
- package/dist/catalog/provenance.d.ts +2 -0
- package/dist/catalog/provenance.js +5 -1
- package/dist/config/auto-approve.d.ts +16 -0
- package/dist/config/auto-approve.js +24 -0
- package/dist/config/capacity-presets.d.ts +243 -0
- package/dist/config/capacity-presets.js +195 -0
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +6 -1
- package/dist/config/load.js +15 -0
- package/dist/config/schema.d.ts +46 -9
- package/dist/config/schema.js +154 -30
- package/dist/ctx/net.d.ts +5 -1
- package/dist/ctx/net.js +62 -12
- package/dist/db/kernel-schema.d.ts +31 -0
- package/dist/db/migrator.js +0 -36
- package/dist/dial-in/routes.js +1 -1
- package/dist/erasure/org-batches.js +1 -6
- package/dist/erasure/org-catalog.js +6 -2
- package/dist/erasure/org-rules.js +1 -0
- package/dist/erasure/org-worker.js +0 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/admin-ops.d.ts +14 -1
- package/dist/extensions/admin-ops.js +30 -3
- package/dist/extensions/admin-view.d.ts +21 -1
- package/dist/extensions/admin-view.js +43 -0
- package/dist/extensions/bootstrap-packages.d.ts +5 -0
- package/dist/extensions/bootstrap-packages.js +1 -1
- package/dist/extensions/bootstrap-review.d.ts +251 -0
- package/dist/extensions/bootstrap-review.js +676 -0
- package/dist/extensions/bootstrap.d.ts +21 -1
- package/dist/extensions/bootstrap.js +72 -2
- package/dist/extensions/cli.d.ts +6 -0
- package/dist/extensions/cli.js +4 -0
- package/dist/extensions/enabled.d.ts +3 -0
- package/dist/extensions/extensions.module.js +9 -0
- package/dist/extensions/full-access-disclosure.d.ts +15 -0
- package/dist/extensions/full-access-disclosure.js +57 -0
- package/dist/extensions/grant-epoch.d.ts +5 -0
- package/dist/extensions/grant-epoch.js +9 -0
- package/dist/extensions/host.d.ts +71 -2
- package/dist/extensions/host.js +293 -27
- package/dist/extensions/installs.d.ts +18 -0
- package/dist/extensions/installs.js +28 -0
- package/dist/extensions/isolated/admission.d.ts +17 -2
- package/dist/extensions/isolated/admission.js +15 -7
- package/dist/extensions/isolated/authorization.d.ts +8 -2
- package/dist/extensions/isolated/authorization.js +11 -3
- package/dist/extensions/isolated/broker.d.ts +3 -0
- package/dist/extensions/isolated/broker.js +50 -14
- package/dist/extensions/isolated/configured-package.d.ts +5 -0
- package/dist/extensions/isolated/configured-package.js +2 -0
- package/dist/extensions/isolated/lanes.d.ts +44 -3
- package/dist/extensions/isolated/lanes.js +263 -80
- package/dist/extensions/isolated/metrics.d.ts +146 -0
- package/dist/extensions/isolated/metrics.js +304 -0
- package/dist/extensions/isolated/revision.d.ts +7 -1
- package/dist/extensions/isolated/revision.js +26 -5
- package/dist/extensions/isolated/rpc.d.ts +5 -0
- package/dist/extensions/isolated/rpc.js +7 -2
- package/dist/extensions/isolated/sandbox.d.ts +23 -0
- package/dist/extensions/isolated/sandbox.js +50 -0
- package/dist/extensions/isolated/status.d.ts +79 -0
- package/dist/extensions/isolated/status.js +216 -0
- package/dist/extensions/isolated/tier.d.ts +127 -2
- package/dist/extensions/isolated/tier.js +266 -7
- package/dist/extensions/isolated/usage.d.ts +134 -0
- package/dist/extensions/isolated/usage.js +322 -0
- package/dist/extensions/lifecycle.d.ts +42 -2
- package/dist/extensions/lifecycle.js +100 -4
- package/dist/extensions/org-config.js +11 -0
- package/dist/extensions/package.d.ts +14 -0
- package/dist/extensions/package.js +23 -0
- package/dist/extensions/permissions.controller.d.ts +35 -0
- package/dist/extensions/permissions.controller.js +98 -0
- package/dist/extensions/permissions.schemas.d.ts +288 -0
- package/dist/extensions/permissions.schemas.js +96 -0
- package/dist/extensions/permissions.service.d.ts +116 -0
- package/dist/extensions/permissions.service.js +428 -0
- package/dist/extensions/realm-retirement.d.ts +65 -0
- package/dist/extensions/realm-retirement.js +150 -0
- package/dist/extensions/revision-approvals.d.ts +58 -3
- package/dist/extensions/revision-approvals.js +135 -14
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation.js +3 -0
- package/dist/extensions/state.module.js +12 -0
- package/dist/git/run-end.d.ts +35 -7
- package/dist/git/run-end.js +87 -38
- package/dist/http/api.module.js +2 -0
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/audit.js +4 -17
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/infra/config/kernel-config.service.d.ts +6 -0
- package/dist/infra/config/kernel-config.service.js +21 -0
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +25 -1
- package/dist/lifecycle/kernel-lifecycle.js +73 -18
- package/dist/net/private-endpoint-preflight.d.ts +159 -0
- package/dist/net/private-endpoint-preflight.js +417 -0
- package/dist/net/private-endpoints.d.ts +68 -0
- package/dist/net/private-endpoints.js +164 -0
- package/dist/net/public-address.d.ts +14 -0
- package/dist/net/public-address.js +15 -1
- package/dist/net/safe-fetch.d.ts +2 -1
- package/dist/net/safe-fetch.js +10 -3
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/packages/official-publisher.d.ts +26 -1
- package/dist/packages/official-publisher.js +48 -1
- package/dist/packages/provenance.d.ts +11 -0
- package/dist/packages/provenance.js +24 -0
- package/dist/platform/exclusions.js +4 -4
- package/dist/platform/ops/automations.ops.js +1 -1
- package/dist/platform/ops/catalog-admin.ops.js +25 -4
- package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
- package/dist/platform/ops/extension-permissions.ops.js +159 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +2 -0
- package/dist/platform/route-schemas.js +2 -0
- package/dist/retention/purge-batch.js +10 -14
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -3
- package/dist/runtime/run-finish.d.ts +3 -3
- package/dist/runtime/run-finish.js +7 -3
- package/dist/sandbox/permission-availability.d.ts +17 -2
- package/dist/sandbox/permission-availability.js +22 -1
- package/dist/sandbox/permission-facts.js +7 -1
- package/dist/tools/builtins/sandbox/common.js +2 -0
- package/dist/tools/pipeline.d.ts +2 -1
- package/dist/tools/pipeline.js +7 -2
- package/package.json +4 -3
- package/src/migrations/0238_extension_usage.sql +40 -0
- package/src/migrations/0239_extension_replica_isolation.sql +28 -0
|
@@ -6,6 +6,7 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
6
6
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
7
7
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
8
8
|
import type { KernelLogger } from "../log.js";
|
|
9
|
+
import { type BrokeredEndpointPin } from "../net/private-endpoint-preflight.js";
|
|
9
10
|
import { ExtensionAdminOps } from "./admin-ops.js";
|
|
10
11
|
import { type ExtraManifestTraces, type MergedBootstrapManifest } from "./bootstrap-extra.js";
|
|
11
12
|
import { ExtensionInstalls } from "./installs.js";
|
|
@@ -144,6 +145,8 @@ export declare class BootstrapFailedError extends Error {
|
|
|
144
145
|
}
|
|
145
146
|
/** The lock around a whole run (`lock:bootstrap`). */
|
|
146
147
|
export declare const BOOTSTRAP_LOCK_KEY = "bootstrap";
|
|
148
|
+
/** How long the start's platform URL check may take (DNS lookups) before it is skipped. */
|
|
149
|
+
export declare const PLATFORM_URL_CHECK_MS = 10000;
|
|
147
150
|
/** Its lifetime without renewal; a run keeps it by renewal, a crashed holder's expires. */
|
|
148
151
|
export declare const BOOTSTRAP_LOCK_TTL_MS = 120000;
|
|
149
152
|
/** Optional provider: the lock's lifetime (ms) instead of {@link BOOTSTRAP_LOCK_TTL_MS} (tests shorten it). */
|
|
@@ -173,6 +176,8 @@ export declare class BootstrapService {
|
|
|
173
176
|
private readonly log;
|
|
174
177
|
/** The lock's lifetime without renewal. */
|
|
175
178
|
private readonly lockTtlMs;
|
|
179
|
+
/** Tests only: the brokered pins the private endpoint preflight checks. */
|
|
180
|
+
private readonly brokeredPins;
|
|
176
181
|
constructor(kdb: KernelDb, txHost: TransactionHost, locks: LockService, approveLock: PluginApproveLock, installs: ExtensionInstalls, ops: ExtensionAdminOps, outbox: Pick<OutboxService, "add" | "addMany">,
|
|
177
182
|
/**
|
|
178
183
|
* Config-declared extension names (an entry of the same name is kept, config wins, and no
|
|
@@ -181,7 +186,9 @@ export declare class BootstrapService {
|
|
|
181
186
|
*/
|
|
182
187
|
registry: ExtensionRegistry, configService: KernelConfigService, log: KernelLogger,
|
|
183
188
|
/** The lock's lifetime without renewal. */
|
|
184
|
-
lockTtlMs?: number
|
|
189
|
+
lockTtlMs?: number,
|
|
190
|
+
/** Tests only: the brokered pins the private endpoint preflight checks. */
|
|
191
|
+
brokeredPins?: readonly BrokeredEndpointPin[]);
|
|
185
192
|
private get db();
|
|
186
193
|
private config;
|
|
187
194
|
/**
|
|
@@ -232,6 +239,19 @@ export declare class BootstrapService {
|
|
|
232
239
|
/** The platform update a raised pin goes through (after the extension step, if any). */
|
|
233
240
|
updater: BootstrapUpdater;
|
|
234
241
|
}): Promise<BootstrapResult>;
|
|
242
|
+
/**
|
|
243
|
+
* The generic platform URL check (`platformUrlGaps`): one warning per URL field of an enabled
|
|
244
|
+
* extension that `ctx.net` would refuse without an org, with the alias to add. Bounded by
|
|
245
|
+
* {@link PLATFORM_URL_CHECK_MS} (DNS may hang); a failure or timeout only warns.
|
|
246
|
+
*/
|
|
247
|
+
private warnPlatformUrls;
|
|
248
|
+
/**
|
|
249
|
+
* The private endpoint preflight (`net/private-endpoint-preflight.ts`): a pin moving to its
|
|
250
|
+
* `ctx.net` build while its private platform endpoint has no `net.privateEndpoints` alias throws
|
|
251
|
+
* {@link PrivateEndpointMissingError} before anything is written; a pin that is not yet that
|
|
252
|
+
* build only warns, naming the alias to add.
|
|
253
|
+
*/
|
|
254
|
+
private preflightPrivateEndpoints;
|
|
235
255
|
/**
|
|
236
256
|
* A pin whose plugin name an org holds (a live org-owned catalog item): the bootstrap takes no
|
|
237
257
|
* name over (ruling P3-28), so the entry fails; this warning tells the super admin why and
|
|
@@ -28,6 +28,7 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
28
28
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
29
29
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
30
30
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
31
|
+
import { BROKERED_ENDPOINT_PINS, BROKERED_ENDPOINT_PINS_SEAM, enabledExtensionsForScan, PrivateEndpointMissingError, platformUrlGaps, privateEndpointGaps, storedDeploymentConfig, } from "../net/private-endpoint-preflight.js";
|
|
31
32
|
import { PackageTgzError, unpackPackageTgz } from "../packages/tgz.js";
|
|
32
33
|
import { ExtensionAdminOps } from "./admin-ops.js";
|
|
33
34
|
import { writeSnapshot } from "./approvals.js";
|
|
@@ -74,6 +75,8 @@ export class BootstrapFailedError extends Error {
|
|
|
74
75
|
const managedMarketplaceId = (name) => `${CONFIG_MARKETPLACE_PREFIX}${name}`;
|
|
75
76
|
/** The lock around a whole run (`lock:bootstrap`). */
|
|
76
77
|
export const BOOTSTRAP_LOCK_KEY = "bootstrap";
|
|
78
|
+
/** How long the start's platform URL check may take (DNS lookups) before it is skipped. */
|
|
79
|
+
export const PLATFORM_URL_CHECK_MS = 10_000;
|
|
77
80
|
/** Its lifetime without renewal; a run keeps it by renewal, a crashed holder's expires. */
|
|
78
81
|
export const BOOTSTRAP_LOCK_TTL_MS = 120_000;
|
|
79
82
|
/** Optional provider: the lock's lifetime (ms) instead of {@link BOOTSTRAP_LOCK_TTL_MS} (tests shorten it). */
|
|
@@ -92,6 +95,7 @@ let BootstrapService = class BootstrapService {
|
|
|
92
95
|
configService;
|
|
93
96
|
log;
|
|
94
97
|
lockTtlMs;
|
|
98
|
+
brokeredPins;
|
|
95
99
|
constructor(kdb, txHost, locks, approveLock, installs, ops, outbox,
|
|
96
100
|
/**
|
|
97
101
|
* Config-declared extension names (an entry of the same name is kept, config wins, and no
|
|
@@ -100,7 +104,9 @@ let BootstrapService = class BootstrapService {
|
|
|
100
104
|
*/
|
|
101
105
|
registry, configService, log,
|
|
102
106
|
/** The lock's lifetime without renewal. */
|
|
103
|
-
lockTtlMs = BOOTSTRAP_LOCK_TTL_MS
|
|
107
|
+
lockTtlMs = BOOTSTRAP_LOCK_TTL_MS,
|
|
108
|
+
/** Tests only: the brokered pins the private endpoint preflight checks. */
|
|
109
|
+
brokeredPins = BROKERED_ENDPOINT_PINS) {
|
|
104
110
|
this.kdb = kdb;
|
|
105
111
|
this.txHost = txHost;
|
|
106
112
|
this.locks = locks;
|
|
@@ -112,6 +118,7 @@ let BootstrapService = class BootstrapService {
|
|
|
112
118
|
this.configService = configService;
|
|
113
119
|
this.log = log;
|
|
114
120
|
this.lockTtlMs = lockTtlMs;
|
|
121
|
+
this.brokeredPins = brokeredPins;
|
|
115
122
|
}
|
|
116
123
|
get db() {
|
|
117
124
|
return this.kdb.db;
|
|
@@ -186,6 +193,9 @@ let BootstrapService = class BootstrapService {
|
|
|
186
193
|
*/
|
|
187
194
|
async run(o) {
|
|
188
195
|
const manifestSha256 = bootstrapManifestSha256(o.manifest);
|
|
196
|
+
// Every run (init and each kernel start), done or not: warn about platform URLs ctx.net
|
|
197
|
+
// would refuse without an org (never refuses)
|
|
198
|
+
await this.warnPlatformUrls();
|
|
189
199
|
// Done: no lock, no directory, no network
|
|
190
200
|
const before = await this.recorded(o.manifest);
|
|
191
201
|
if (before)
|
|
@@ -200,6 +210,8 @@ let BootstrapService = class BootstrapService {
|
|
|
200
210
|
if (hasExtraManifestTraces(traces))
|
|
201
211
|
throw new BootstrapExtraMismatchError(traces);
|
|
202
212
|
}
|
|
213
|
+
// Before anything is obtained or written: a brokered pin's private endpoint needs its alias
|
|
214
|
+
await this.preflightPrivateEndpoints(o.manifest);
|
|
203
215
|
const fromExtra = new Set(o.manifest.extra?.plugins);
|
|
204
216
|
const deferBuiltin = o.deferBuiltin === true;
|
|
205
217
|
const isDeferred = (e) => deferBuiltin && e.builtin === true;
|
|
@@ -282,6 +294,62 @@ let BootstrapService = class BootstrapService {
|
|
|
282
294
|
return { manifestSha256, results };
|
|
283
295
|
});
|
|
284
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* The generic platform URL check (`platformUrlGaps`): one warning per URL field of an enabled
|
|
299
|
+
* extension that `ctx.net` would refuse without an org, with the alias to add. Bounded by
|
|
300
|
+
* {@link PLATFORM_URL_CHECK_MS} (DNS may hang); a failure or timeout only warns.
|
|
301
|
+
*/
|
|
302
|
+
async warnPlatformUrls() {
|
|
303
|
+
let timer;
|
|
304
|
+
try {
|
|
305
|
+
const gaps = await Promise.race([
|
|
306
|
+
(async () => platformUrlGaps({
|
|
307
|
+
config: this.config(),
|
|
308
|
+
extensions: await enabledExtensionsForScan(this.db),
|
|
309
|
+
}))(),
|
|
310
|
+
new Promise((_, reject) => {
|
|
311
|
+
timer = setTimeout(() => reject(new Error(`no answer within ${PLATFORM_URL_CHECK_MS} ms`)), PLATFORM_URL_CHECK_MS);
|
|
312
|
+
timer.unref?.();
|
|
313
|
+
}),
|
|
314
|
+
]);
|
|
315
|
+
for (const g of gaps) {
|
|
316
|
+
this.log.warn("a plugin's platform URL would be refused by ctx.net without a net.privateEndpoints alias", { plugin: g.plugin, field: g.field, origin: g.origin, kind: g.kind, hint: g.message });
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
this.log.warn("platform URL check skipped", { err });
|
|
321
|
+
}
|
|
322
|
+
finally {
|
|
323
|
+
clearTimeout(timer);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The private endpoint preflight (`net/private-endpoint-preflight.ts`): a pin moving to its
|
|
328
|
+
* `ctx.net` build while its private platform endpoint has no `net.privateEndpoints` alias throws
|
|
329
|
+
* {@link PrivateEndpointMissingError} before anything is written; a pin that is not yet that
|
|
330
|
+
* build only warns, naming the alias to add.
|
|
331
|
+
*/
|
|
332
|
+
async preflightPrivateEndpoints(manifest) {
|
|
333
|
+
const gaps = await privateEndpointGaps({
|
|
334
|
+
config: this.config(),
|
|
335
|
+
pins: manifest.plugins.map((e) => ({ name: e.name, version: e.version })),
|
|
336
|
+
storedConfig: (plugin) => storedDeploymentConfig(this.db, plugin),
|
|
337
|
+
brokered: this.brokeredPins,
|
|
338
|
+
});
|
|
339
|
+
for (const g of gaps) {
|
|
340
|
+
if (g.blocking)
|
|
341
|
+
continue;
|
|
342
|
+
this.log.warn("bootstrap: a plugin's private platform endpoint has no net.privateEndpoints alias", {
|
|
343
|
+
plugin: g.plugin,
|
|
344
|
+
origin: g.origin,
|
|
345
|
+
alias: g.alias,
|
|
346
|
+
hint: g.message,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
const blocking = gaps.filter((g) => g.blocking);
|
|
350
|
+
if (blocking.length > 0)
|
|
351
|
+
throw new PrivateEndpointMissingError(blocking);
|
|
352
|
+
}
|
|
285
353
|
/**
|
|
286
354
|
* A pin whose plugin name an org holds (a live org-owned catalog item): the bootstrap takes no
|
|
287
355
|
* name over (ruling P3-28), so the entry fails; this warning tells the super admin why and
|
|
@@ -886,7 +954,9 @@ BootstrapService = __decorate([
|
|
|
886
954
|
__param(8, Inject(KernelConfigService)),
|
|
887
955
|
__param(9, Inject(KERNEL_LOGGER)),
|
|
888
956
|
__param(10, Optional()),
|
|
889
|
-
__param(10, Inject(BOOTSTRAP_LOCK_TTL))
|
|
957
|
+
__param(10, Inject(BOOTSTRAP_LOCK_TTL)),
|
|
958
|
+
__param(11, Optional()),
|
|
959
|
+
__param(11, Inject(BROKERED_ENDPOINT_PINS_SEAM))
|
|
890
960
|
], BootstrapService);
|
|
891
961
|
export { BootstrapService };
|
|
892
962
|
/** A `kept` result whose entry an earlier pass of the same start installed / upgraded / imported. */
|
package/dist/extensions/cli.d.ts
CHANGED
|
@@ -6,10 +6,12 @@ import { ExtensionAdminOps } from "./admin-ops.js";
|
|
|
6
6
|
import { ExtensionAdmin } from "./admin-view.js";
|
|
7
7
|
import { ExtensionApprovals } from "./approvals.js";
|
|
8
8
|
import { BootstrapService } from "./bootstrap.js";
|
|
9
|
+
import { BootstrapReviewService } from "./bootstrap-review.js";
|
|
9
10
|
import { type ConfigIssue } from "./config-issues.js";
|
|
10
11
|
import { type InspectedExtension } from "./host.js";
|
|
11
12
|
import { ExtensionInstalls } from "./installs.js";
|
|
12
13
|
import type { PermissionSet } from "./permission-set.js";
|
|
14
|
+
import { ExtensionPermissions } from "./permissions.service.js";
|
|
13
15
|
/** {@link openExtensionCli} 的结果:CLI 的 `capybara extensions *` 共用。 */
|
|
14
16
|
export interface ExtensionCli {
|
|
15
17
|
config: KernelConfig;
|
|
@@ -42,8 +44,12 @@ export interface ExtensionCli {
|
|
|
42
44
|
admin: ExtensionAdmin;
|
|
43
45
|
ops: ExtensionAdminOps;
|
|
44
46
|
approvals: ExtensionApprovals;
|
|
47
|
+
/** The revision review and operator approval of an install (plan task 1.4a). */
|
|
48
|
+
permissions: ExtensionPermissions;
|
|
45
49
|
/** The bootstrap step (`capybara bootstrap`), under the same `lock:bootstrap` as the kernel. */
|
|
46
50
|
bootstrap: BootstrapService;
|
|
51
|
+
/** The bootstrap review and its approval (`capybara bootstrap review | approve`). */
|
|
52
|
+
bootstrapReview: BootstrapReviewService;
|
|
47
53
|
/** CLI 本次刚导入的包字节(降级判断等读包时优先用它:包可能存在 CLI 读不到的对象存储里)。 */
|
|
48
54
|
remember(sha256: string, bytes: Uint8Array): void;
|
|
49
55
|
/** 安装记录包的权限集合(与后台审阅相同);包在对象存储里时 CLI 读不到,抛错。 */
|
package/dist/extensions/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ import { ExtensionAdmin } from "./admin-view.js";
|
|
|
7
7
|
import { ExtensionApprovals } from "./approvals.js";
|
|
8
8
|
import { ExtensionBlobs } from "./blobs.js";
|
|
9
9
|
import { BootstrapService } from "./bootstrap.js";
|
|
10
|
+
import { BootstrapReviewService } from "./bootstrap-review.js";
|
|
10
11
|
import { toIssues } from "./config-issues.js";
|
|
11
12
|
import { mergeDeploymentConfig, readStoredDeploymentConfig, schemaFields, secretPathsOf, } from "./deployment-config-store.js";
|
|
12
13
|
import { ExtensionsModule } from "./extensions.module.js";
|
|
@@ -15,6 +16,7 @@ import { ExtensionInstalls } from "./installs.js";
|
|
|
15
16
|
import { PLUGINS_CHANGED_TOPIC } from "./lifecycle-topics.js";
|
|
16
17
|
import { parseLoadGate } from "./org-levels.js";
|
|
17
18
|
import { ExtensionPackageError, extensionPackageApiError, permissionSetOfPackage, readExtensionPackage, } from "./package.js";
|
|
19
|
+
import { ExtensionPermissions } from "./permissions.service.js";
|
|
18
20
|
/**
|
|
19
21
|
* The effective deployment config (the startup config `fileValue` completed by the `stored` PG
|
|
20
22
|
* fields) parsed as the host's load gate does: overridable fields may stay empty (spec A §5.4a),
|
|
@@ -92,7 +94,9 @@ export async function openExtensionCli(config, log, opts = {}) {
|
|
|
92
94
|
admin: app.get(ExtensionAdmin),
|
|
93
95
|
ops: app.get(ExtensionAdminOps),
|
|
94
96
|
approvals: app.get(ExtensionApprovals),
|
|
97
|
+
permissions: app.get(ExtensionPermissions),
|
|
95
98
|
bootstrap: app.get(BootstrapService),
|
|
99
|
+
bootstrapReview: app.get(BootstrapReviewService),
|
|
96
100
|
remember: (sha256, bytes) => blobs.remember(sha256, bytes),
|
|
97
101
|
readPackage: (sha256) => blobs.get(sha256),
|
|
98
102
|
async packageSet(sha256) {
|
|
@@ -122,9 +122,12 @@ export declare function extensionOrgCountsQuery(db: KernelSchemaDb, names: reado
|
|
|
122
122
|
extension_org_overrides: import("../db/kernel-schema.js").ExtensionOrgOverridesTable;
|
|
123
123
|
extension_packages: import("../db/kernel-schema.js").ExtensionPackagesTable;
|
|
124
124
|
extension_permission_snapshots: import("../db/kernel-schema.js").ExtensionPermissionSnapshotsTable;
|
|
125
|
+
extension_replica_isolation: import("../db/kernel-schema.js").ExtensionReplicaIsolationTable;
|
|
125
126
|
extension_replica_status: import("../db/kernel-schema.js").ExtensionReplicaStatusTable;
|
|
126
127
|
extension_revision_grant_orgs: import("../db/kernel-schema.js").ExtensionRevisionGrantOrgsTable;
|
|
127
128
|
extension_revision_grants: import("../db/kernel-schema.js").ExtensionRevisionGrantsTable;
|
|
129
|
+
extension_usage: import("../db/kernel-schema.js").ExtensionUsageTable;
|
|
130
|
+
extension_usage_batches: import("../db/kernel-schema.js").ExtensionUsageBatchesTable;
|
|
128
131
|
file_previewers: import("../db/kernel-schema.js").FilePreviewersTable;
|
|
129
132
|
file_shares: import("../db/kernel-schema.js").FileSharesTable;
|
|
130
133
|
files: import("../db/kernel-schema.js").FilesTable;
|
|
@@ -23,6 +23,7 @@ import { EmbedTokensModule } from "../ui/embed-token.js";
|
|
|
23
23
|
import { ExtensionAdminOps } from "./admin-ops.js";
|
|
24
24
|
import { ExtensionAdmin } from "./admin-view.js";
|
|
25
25
|
import { BootstrapService } from "./bootstrap.js";
|
|
26
|
+
import { BootstrapReviewService } from "./bootstrap-review.js";
|
|
26
27
|
import { ExtensionDeploymentConfigService } from "./deployment-config.js";
|
|
27
28
|
import { ExtensionDisplayNames } from "./display-name.js";
|
|
28
29
|
import { ExtensionHost } from "./host.js";
|
|
@@ -30,10 +31,12 @@ import { ExtensionLifecycle } from "./lifecycle.js";
|
|
|
30
31
|
import { PluginApproveLock, PluginDeploymentConfigLock, PluginInstallLock, SingleProviderLock, } from "./locks.js";
|
|
31
32
|
import { OrgExtensionConfigs } from "./org-config.js";
|
|
32
33
|
import { OrgOverrides } from "./org-overrides.js";
|
|
34
|
+
import { ExtensionPermissions } from "./permissions.service.js";
|
|
33
35
|
import { PluginGuides } from "./plugin-guides.js";
|
|
34
36
|
import { PluginIcons } from "./plugin-icons.js";
|
|
35
37
|
import { ExtensionPointDefaults } from "./point-defaults.js";
|
|
36
38
|
import { ExtensionPointServingModule } from "./point-serving.js";
|
|
39
|
+
import { HostReasonRetirement } from "./realm-retirement.js";
|
|
37
40
|
import { ExtensionRegistryModule } from "./registry.js";
|
|
38
41
|
import { ExtensionRevocations } from "./revocation.js";
|
|
39
42
|
import { SingleProviderGuard } from "./single-provider.js";
|
|
@@ -91,6 +94,8 @@ ExtensionsModule = __decorate([
|
|
|
91
94
|
ExtensionEffectKeys,
|
|
92
95
|
ExtensionLifecycle,
|
|
93
96
|
ExtensionRevocations,
|
|
97
|
+
ExtensionPermissions,
|
|
98
|
+
HostReasonRetirement,
|
|
94
99
|
ExtensionAdmin,
|
|
95
100
|
ExtensionAdminOps,
|
|
96
101
|
ExtensionDisplayNames,
|
|
@@ -101,6 +106,7 @@ ExtensionsModule = __decorate([
|
|
|
101
106
|
OrgOverrides,
|
|
102
107
|
ExtensionPointDefaults,
|
|
103
108
|
BootstrapService,
|
|
109
|
+
BootstrapReviewService,
|
|
104
110
|
ExtensionAvailability,
|
|
105
111
|
],
|
|
106
112
|
exports: [
|
|
@@ -115,6 +121,8 @@ ExtensionsModule = __decorate([
|
|
|
115
121
|
ExtensionEffectKeys,
|
|
116
122
|
ExtensionLifecycle,
|
|
117
123
|
ExtensionRevocations,
|
|
124
|
+
ExtensionPermissions,
|
|
125
|
+
HostReasonRetirement,
|
|
118
126
|
ExtensionAdmin,
|
|
119
127
|
ExtensionAdminOps,
|
|
120
128
|
ExtensionDisplayNames,
|
|
@@ -125,6 +133,7 @@ ExtensionsModule = __decorate([
|
|
|
125
133
|
OrgOverrides,
|
|
126
134
|
ExtensionPointDefaults,
|
|
127
135
|
BootstrapService,
|
|
136
|
+
BootstrapReviewService,
|
|
128
137
|
ExtensionAvailability,
|
|
129
138
|
SingleProviderGuard,
|
|
130
139
|
],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
import type { FullAccessDisclosure, FullAccessReason } from "./permissions.schemas.js";
|
|
3
|
+
import { type ExecutionRealm, type ExtensionRevisionGrants, type RevisionGrant } from "./revision-grants.js";
|
|
4
|
+
/**
|
|
5
|
+
* The org-facing disclosure of a full-access plugin (spec "Review, updates and provenance" step 3;
|
|
6
|
+
* the 1.4f org page): the install's approved revision, the realms its live grant runs with full
|
|
7
|
+
* access, why (by class), who approved it and when. Nothing else of the grant: no other org's
|
|
8
|
+
* names, no forcing keys, no purposes. Null when the extension is not installed, has no approved
|
|
9
|
+
* revision, or its approved grant is not live or confers no full access.
|
|
10
|
+
*/
|
|
11
|
+
export declare function readFullAccessDisclosure(db: KernelSchemaDb, grants: Pick<ExtensionRevisionGrants, "live">, plugin: string): Promise<FullAccessDisclosure | null>;
|
|
12
|
+
/** The live grant of the install's approved revision, if any. */
|
|
13
|
+
export declare function approvedGrant(db: KernelSchemaDb, grants: Pick<ExtensionRevisionGrants, "live">, plugin: string): Promise<RevisionGrant | undefined>;
|
|
14
|
+
/** The class of one forcing key: what the org admin is told, never the key itself. */
|
|
15
|
+
export declare function reasonOf(realm: ExecutionRealm, key: string): FullAccessReason;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { EXECUTION_REALMS, effectiveRealms, isLive, } from "./revision-grants.js";
|
|
2
|
+
/**
|
|
3
|
+
* The org-facing disclosure of a full-access plugin (spec "Review, updates and provenance" step 3;
|
|
4
|
+
* the 1.4f org page): the install's approved revision, the realms its live grant runs with full
|
|
5
|
+
* access, why (by class), who approved it and when. Nothing else of the grant: no other org's
|
|
6
|
+
* names, no forcing keys, no purposes. Null when the extension is not installed, has no approved
|
|
7
|
+
* revision, or its approved grant is not live or confers no full access.
|
|
8
|
+
*/
|
|
9
|
+
export async function readFullAccessDisclosure(db, grants, plugin) {
|
|
10
|
+
const grant = await approvedGrant(db, grants, plugin);
|
|
11
|
+
if (!grant)
|
|
12
|
+
return null;
|
|
13
|
+
const realms = effectiveRealms(grant);
|
|
14
|
+
const present = EXECUTION_REALMS.filter((realm) => (realms[realm] ?? []).length > 0);
|
|
15
|
+
if (present.length === 0)
|
|
16
|
+
return null;
|
|
17
|
+
const reasons = new Set();
|
|
18
|
+
for (const realm of present) {
|
|
19
|
+
for (const key of realms[realm] ?? [])
|
|
20
|
+
reasons.add(reasonOf(realm, key));
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
approvedRevision: { version: grant.revision.version },
|
|
24
|
+
realms: present,
|
|
25
|
+
reasons: [...reasons].sort(),
|
|
26
|
+
approverAuthority: grant.authority,
|
|
27
|
+
approvedAt: grant.approvedAt.toISOString(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** The live grant of the install's approved revision, if any. */
|
|
31
|
+
export async function approvedGrant(db, grants, plugin) {
|
|
32
|
+
const row = await db
|
|
33
|
+
.selectFrom("extension_installs")
|
|
34
|
+
.select(["approved_version", "approved_sha512"])
|
|
35
|
+
.where("name", "=", plugin)
|
|
36
|
+
.executeTakeFirst();
|
|
37
|
+
if (!row?.approved_version || !row.approved_sha512)
|
|
38
|
+
return undefined;
|
|
39
|
+
const grant = await grants.live({
|
|
40
|
+
plugin,
|
|
41
|
+
version: row.approved_version,
|
|
42
|
+
sha512: row.approved_sha512,
|
|
43
|
+
});
|
|
44
|
+
return grant && isLive(grant.state) ? grant : undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The class of one forcing key: what the org admin is told, never the key itself. */
|
|
47
|
+
export function reasonOf(realm, key) {
|
|
48
|
+
if (key === "host.no-isolation")
|
|
49
|
+
return "host_no_isolation";
|
|
50
|
+
if (key.startsWith("execution.provider.unsupported:"))
|
|
51
|
+
return "provider_contract";
|
|
52
|
+
if (realm === "browser")
|
|
53
|
+
return "client_code";
|
|
54
|
+
if (realm === "device")
|
|
55
|
+
return "device_host";
|
|
56
|
+
return "declared";
|
|
57
|
+
}
|
|
@@ -94,6 +94,11 @@ export declare class GrantEpoch {
|
|
|
94
94
|
stop(): void;
|
|
95
95
|
/** The epoch when the last successful read is younger than `maxAgeMs`, otherwise undefined. */
|
|
96
96
|
fresh(): string | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Seconds since the start of the last successful read, while polling; undefined before the
|
|
99
|
+
* first read or when stopped (the `grant_epoch_lag` gauge).
|
|
100
|
+
*/
|
|
101
|
+
lagSeconds(): number | undefined;
|
|
97
102
|
/** The fresh epoch, reading PostgreSQL first when needed; undefined when that read fails. */
|
|
98
103
|
ensureFresh(): Promise<string | undefined>;
|
|
99
104
|
/** One read at a time; concurrent callers share it. It settles within the read timeout. */
|
|
@@ -138,6 +138,15 @@ export class GrantEpoch {
|
|
|
138
138
|
fresh() {
|
|
139
139
|
return this.now() - this.readAt < this.options.maxAgeMs ? this.epoch : undefined;
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Seconds since the start of the last successful read, while polling; undefined before the
|
|
143
|
+
* first read or when stopped (the `grant_epoch_lag` gauge).
|
|
144
|
+
*/
|
|
145
|
+
lagSeconds() {
|
|
146
|
+
if (!this.running || this.readAt === Number.NEGATIVE_INFINITY)
|
|
147
|
+
return undefined;
|
|
148
|
+
return Math.max(0, this.now() - this.readAt) / 1000;
|
|
149
|
+
}
|
|
141
150
|
/** The fresh epoch, reading PostgreSQL first when needed; undefined when that read fails. */
|
|
142
151
|
async ensureFresh() {
|
|
143
152
|
return this.fresh() ?? (await this.refresh());
|
|
@@ -3,7 +3,7 @@ import type { Redis } from "ioredis";
|
|
|
3
3
|
import type { core } from "zod";
|
|
4
4
|
import type { KernelAppOptions } from "../app.js";
|
|
5
5
|
import { TRIGGER_EVENTS_BACKEND } from "../automations/events/token.js";
|
|
6
|
-
import {
|
|
6
|
+
import type { KernelConfig } from "../config/schema.js";
|
|
7
7
|
import type { ExternalConversationsBackend } from "../conversations/external/external-conversations.service.js";
|
|
8
8
|
import { EXTERNAL_CONVERSATIONS_BACKEND } from "../conversations/external/token.js";
|
|
9
9
|
import type { BusSubscriber } from "../ctx/bus.js";
|
|
@@ -34,12 +34,14 @@ import type { UiActionHandler, UiQueryHandler, UiRender } from "../ui/registry.j
|
|
|
34
34
|
import { ExtensionApprovals, type PendingExtension } from "./approvals.js";
|
|
35
35
|
import { deploymentConfigHash } from "./config-hash.js";
|
|
36
36
|
import { EffectiveConfigs } from "./effective-config.js";
|
|
37
|
+
import type { HostIsolation } from "./execution-realm.js";
|
|
37
38
|
import { HookRegistry } from "./hooks.js";
|
|
38
39
|
import type { InflightTracker } from "./inflight.js";
|
|
39
40
|
import { type DesiredExtension, ExtensionInstalls } from "./installs.js";
|
|
40
41
|
import { type ExtensionInstance } from "./instance.js";
|
|
41
42
|
import { type IsolatedRevocation } from "./isolated/authorization.js";
|
|
42
|
-
import {
|
|
43
|
+
import type { ReplicaIsolationRecord } from "./isolated/status.js";
|
|
44
|
+
import { type ExtensionTier, type ShadowExecution } from "./isolated/tier.js";
|
|
43
45
|
import { type PermissionSet } from "./permission-set.js";
|
|
44
46
|
import { type ExtensionPointEntry, ExtensionRegistry } from "./registry.js";
|
|
45
47
|
import { ExtensionRevisionApprovals } from "./revision-approvals.js";
|
|
@@ -106,6 +108,11 @@ export interface InstalledExtensionLoader {
|
|
|
106
108
|
* 导入失败、模块清单与审阅过的静态清单不符、setup 失败、迁移失败。
|
|
107
109
|
*/
|
|
108
110
|
export type InstallFailureReason = "sync_failed" | "sha_mismatch" | "import_failed" | "manifest_mismatch" | "setup_failed" | "migration_failed";
|
|
111
|
+
/**
|
|
112
|
+
* A pending status reason: the revision's grant could not be read (plan task 1.3b). It is retried
|
|
113
|
+
* at the next convergence; a serving revision keeps its tier instead.
|
|
114
|
+
*/
|
|
115
|
+
export declare const GRANT_UNAVAILABLE = "grant_unavailable";
|
|
109
116
|
/** One item of {@link ExtensionHost.declaredPlugins}. */
|
|
110
117
|
export interface DeclaredExtensionInfo {
|
|
111
118
|
name: string;
|
|
@@ -225,6 +232,13 @@ export declare class ExtensionHost {
|
|
|
225
232
|
*/
|
|
226
233
|
private readonly grantEpoch;
|
|
227
234
|
private readonly epochReader;
|
|
235
|
+
/** Which orgs get their own label on the isolation metrics (the largest few). */
|
|
236
|
+
private readonly orgLabels;
|
|
237
|
+
/** This replica's isolated usage increments, flushed every 10 s once isolated work started. */
|
|
238
|
+
private readonly usageCounters;
|
|
239
|
+
private readonly usageFlusher;
|
|
240
|
+
private readonly unobserveEpochLag;
|
|
241
|
+
private capacityCache;
|
|
228
242
|
private readonly executionTier;
|
|
229
243
|
private policyExpected;
|
|
230
244
|
/**
|
|
@@ -443,6 +457,47 @@ export declare class ExtensionHost {
|
|
|
443
457
|
* `plugin host closed during load` at the next checkpoint.
|
|
444
458
|
*/
|
|
445
459
|
load(plan: string[] | ExtensionLoadPlan): Promise<void>;
|
|
460
|
+
/**
|
|
461
|
+
* This replica's isolation supervisor as last observed (plan task 1.3b): `not_configured`
|
|
462
|
+
* without `extensionHost.isolation`; otherwise `available` only after the Engine answered
|
|
463
|
+
* ({@link probeIsolation}), `failing` when it did not. Configuration alone is never readiness.
|
|
464
|
+
*/
|
|
465
|
+
private isolationState;
|
|
466
|
+
hostIsolation(): HostIsolation;
|
|
467
|
+
/**
|
|
468
|
+
* Probes the isolation supervisor with the same read-only Engine and image checks a sandbox start
|
|
469
|
+
* runs (Linux, cgroup v2, the mandatory security options, the local runtime image): the positive
|
|
470
|
+
* readiness signal host-reason retirement waits for. Called at load and on each periodic
|
|
471
|
+
* convergence, so the reported state may lag a failure by one period (reporting only: a sandbox
|
|
472
|
+
* start runs the checks again and fails closed).
|
|
473
|
+
*/
|
|
474
|
+
probeIsolation(): Promise<HostIsolation>;
|
|
475
|
+
/** The last probe with its named checks (plan task 1.4j), undefined before any or unconfigured. */
|
|
476
|
+
private lastProbe;
|
|
477
|
+
/**
|
|
478
|
+
* What this replica records for the isolation status projection (`ReplicaIsolationStore`): its
|
|
479
|
+
* last probe and the shadow placements of its last convergence.
|
|
480
|
+
*/
|
|
481
|
+
isolationRecord(): ReplicaIsolationRecord;
|
|
482
|
+
/**
|
|
483
|
+
* The newest grant of each install's revision, or undefined when the read failed: a revision
|
|
484
|
+
* already serving then keeps its admission (a read error is never a refusal), and any other
|
|
485
|
+
* revision is admitted as without a grant (today's admission).
|
|
486
|
+
*/
|
|
487
|
+
private grantSurfaces;
|
|
488
|
+
/** The last shadow execution report logged by this replica (log de-duplication, not state). */
|
|
489
|
+
private lastExecutionReport;
|
|
490
|
+
/** The shadow execution decisions of the last convergence on this replica (for the inventory). */
|
|
491
|
+
private executions;
|
|
492
|
+
/** This replica's shadow execution decisions of the installs it last converged. */
|
|
493
|
+
shadowExecutions(): ShadowExecution[];
|
|
494
|
+
/**
|
|
495
|
+
* Shadow mode (plan task 1.3b, rollout fence until 1.5a): where each admitted install would run
|
|
496
|
+
* under the execution-realm decision and whether its grant covers the forcing keys, including
|
|
497
|
+
* the kernel's `host.no-isolation` on a host without isolation. Logged when it changes; never
|
|
498
|
+
* refuses or moves a revision: the legacy tier governs.
|
|
499
|
+
*/
|
|
500
|
+
private reportShadowExecution;
|
|
446
501
|
/** The last shadow report logged by this replica (a log de-duplication, not state). */
|
|
447
502
|
private lastShadowReport;
|
|
448
503
|
/**
|
|
@@ -479,6 +534,14 @@ export declare class ExtensionHost {
|
|
|
479
534
|
/** 把一份已校验部署配置里的密钥值登记到日志打码。 */
|
|
480
535
|
private reportSecrets;
|
|
481
536
|
private tierOf;
|
|
537
|
+
/**
|
|
538
|
+
* What the isolated admission of an instance start takes from its grant. In shadow mode the
|
|
539
|
+
* activation's decision (a reload reuses it; a grant change is reported, not enforced); once
|
|
540
|
+
* enforcing (task 1.5a) the grant is read again, so a reload follows a revoked browser realm.
|
|
541
|
+
*/
|
|
542
|
+
private isolatedGrantFor;
|
|
543
|
+
/** The tier this replica serves the exact revision in, or undefined when it does not serve it. */
|
|
544
|
+
private servingTier;
|
|
482
545
|
/**
|
|
483
546
|
* The tier after a revocation (plan task 1.3e; enforced from task 1.5a, until then the leases
|
|
484
547
|
* only report it). A revision whose whole grant is revoked waits for a new review. A trusted
|
|
@@ -805,4 +868,10 @@ export declare class ExtensionHost {
|
|
|
805
868
|
close(opts?: {
|
|
806
869
|
lifecycleWaitMs?: number;
|
|
807
870
|
}): Promise<void>;
|
|
871
|
+
/**
|
|
872
|
+
* The resolved `extensionHost.capacity` (preset plus explicit fields), read at every isolated
|
|
873
|
+
* admission and lane start so hot fields apply at once. Invalid fields fell back to the preset
|
|
874
|
+
* when the config was parsed; the config service logs them.
|
|
875
|
+
*/
|
|
876
|
+
private capacity;
|
|
808
877
|
}
|