@capybara-hq/kernel 0.1.0-rc.146 → 0.1.0-rc.148
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 +18 -8
- 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 +24 -3
- package/dist/extensions/permission-set.d.ts +12 -3
- package/dist/extensions/permission-set.js +5 -5
- package/dist/extensions/permission-view.d.ts +12 -5
- package/dist/extensions/permission-view.js +23 -2
- 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 +6 -2
- package/dist/index.js +6 -2
- 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
|
@@ -165,8 +165,56 @@ export async function sweepExtensionSandboxOrphans(engineUrl) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* The supervisor's readiness as named checks (plan task 1.4j's isolation status), read-only and
|
|
170
|
+
* under the Engine deadline: the Engine guard answers (`guard_reachability`), the daemon provides
|
|
171
|
+
* the mandatory isolation (`engine_runtime`), the runtime image is a local Linux image without
|
|
172
|
+
* volumes (`image`), and the staged PostgreSQL socket and the socket directory are real local
|
|
173
|
+
* paths (`postgres_socket`). The same checks a sandbox start runs; never throws.
|
|
174
|
+
*/
|
|
175
|
+
export async function probeExtensionSandboxChecks(isolation) {
|
|
176
|
+
const failed = (check, err) => ({
|
|
177
|
+
ok: false,
|
|
178
|
+
check,
|
|
179
|
+
message: err instanceof ExtensionSandboxError ? err.message : "The isolation supervisor check failed",
|
|
180
|
+
});
|
|
181
|
+
const signal = deadline();
|
|
182
|
+
let engine;
|
|
183
|
+
let info;
|
|
184
|
+
try {
|
|
185
|
+
engine = new Engine(isolation.engineUrl);
|
|
186
|
+
info = await engine.json("GET", "/info", [200], undefined, signal);
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
return failed("guard_reachability", err);
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
assertEngineRuntime(info);
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
return failed("engine_runtime", err);
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
await checkImage(engine, isolation.image, signal);
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
return failed("image", err);
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
await verifiedPath(isolation.socketDir, "directory");
|
|
205
|
+
await verifiedPath(isolation.postgresSocket, "socket");
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
return failed("postgres_socket", err);
|
|
209
|
+
}
|
|
210
|
+
return { ok: true };
|
|
211
|
+
}
|
|
168
212
|
async function checkEngine(engine, image, signal) {
|
|
169
213
|
const info = await engine.json("GET", "/info", [200], undefined, signal);
|
|
214
|
+
assertEngineRuntime(info);
|
|
215
|
+
await checkImage(engine, image, signal);
|
|
216
|
+
}
|
|
217
|
+
function assertEngineRuntime(info) {
|
|
170
218
|
const security = new Set(info?.SecurityOptions ?? []);
|
|
171
219
|
if (info?.OSType !== "linux" ||
|
|
172
220
|
info.CgroupVersion !== "2" ||
|
|
@@ -180,6 +228,8 @@ async function checkEngine(engine, image, signal) {
|
|
|
180
228
|
(security.has("name=rootless") && info.CgroupDriver === "systemd"))) {
|
|
181
229
|
throw new ExtensionSandboxError("The Docker daemon does not provide mandatory extension isolation");
|
|
182
230
|
}
|
|
231
|
+
}
|
|
232
|
+
async function checkImage(engine, image, signal) {
|
|
183
233
|
const local = await engine.json("GET", `/images/${encodeURIComponent(image)}/json`, [200], undefined, signal);
|
|
184
234
|
if (!local?.Id ||
|
|
185
235
|
!SHA256.test(local.Id) ||
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
2
|
+
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
3
|
+
import type { HostIsolation } from "../execution-realm.js";
|
|
4
|
+
import type { IsolationPausedPlugin, PermissionShadowExecution, ReplicaIsolation } from "../permissions.schemas.js";
|
|
5
|
+
import type { SandboxProbe } from "./sandbox.js";
|
|
6
|
+
import type { ShadowExecution } from "./tier.js";
|
|
7
|
+
/**
|
|
8
|
+
* The isolation status projection (extension permission model plan task 1.4j). Each replica
|
|
9
|
+
* probes its own isolation supervisor (`ExtensionHost.probeIsolation`, the named checks of
|
|
10
|
+
* `probeExtensionSandboxChecks`) and places its revisions (1.3b's shadow executions) in memory;
|
|
11
|
+
* the status route and permission reviews read them deployment-wide, so each replica writes its
|
|
12
|
+
* row after its probe and convergence (`extension_replica_isolation`), refreshes it with its
|
|
13
|
+
* heartbeat, removes it on a clean stop, and rows of replicas gone stale are pruned like
|
|
14
|
+
* `extension_replica_status`. Not configured, nothing is probed. The table has no org: its
|
|
15
|
+
* reads and writes are deployment-wide by construction.
|
|
16
|
+
*/
|
|
17
|
+
/** What a replica records after its probe and convergence. */
|
|
18
|
+
export interface ReplicaIsolationRecord {
|
|
19
|
+
/** The last probe, or undefined without `extensionHost.isolation` (nothing probed). */
|
|
20
|
+
probe: {
|
|
21
|
+
result: SandboxProbe;
|
|
22
|
+
at: Date;
|
|
23
|
+
} | undefined;
|
|
24
|
+
shadow: readonly ShadowExecution[];
|
|
25
|
+
}
|
|
26
|
+
/** The deployment-wide state from the live replicas' rows. */
|
|
27
|
+
export type DeploymentIsolation = "not_configured" | "available" | "failing" | "unknown";
|
|
28
|
+
/** Writes this replica's row (the extension lifecycle, after each convergence). */
|
|
29
|
+
export declare class ReplicaIsolationStore {
|
|
30
|
+
private readonly kdb;
|
|
31
|
+
private readonly config;
|
|
32
|
+
constructor(kdb: KernelDb, config: KernelConfigService);
|
|
33
|
+
write(replicaId: string, record: ReplicaIsolationRecord): Promise<void>;
|
|
34
|
+
/** Deletes rows of replicas whose heartbeat is older than `staleSeconds`. */
|
|
35
|
+
prune(staleSeconds: number): Promise<number>;
|
|
36
|
+
/** A clean stop: this replica no longer counts. */
|
|
37
|
+
remove(replicaId: string): Promise<void>;
|
|
38
|
+
private httpReplicaId;
|
|
39
|
+
}
|
|
40
|
+
/** The deployment-wide reads of the live replicas' rows. */
|
|
41
|
+
export declare class IsolationStatusReader {
|
|
42
|
+
private readonly kdb;
|
|
43
|
+
private readonly config;
|
|
44
|
+
constructor(kdb: KernelDb, config: KernelConfigService);
|
|
45
|
+
private configured;
|
|
46
|
+
private rows;
|
|
47
|
+
/**
|
|
48
|
+
* Failing when any live replica's supervisor fails, available only when every live replica's
|
|
49
|
+
* passed, unknown before any probed; not configured without reading anything.
|
|
50
|
+
*/
|
|
51
|
+
deployment(): Promise<DeploymentIsolation>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the deployment runs the supervisor: this replica's config, or any live replica that
|
|
54
|
+
* probed (a mixed configuration answers the same on every replica).
|
|
55
|
+
*/
|
|
56
|
+
private deploymentConfigured;
|
|
57
|
+
/**
|
|
58
|
+
* The host profile a permission review binds: `available` when the supervisor is configured,
|
|
59
|
+
* `not_configured` otherwise. A grant's realms depend on the profile, not on the supervisor's
|
|
60
|
+
* readiness at the moment (available and failing need the same grants), so a probe flapping
|
|
61
|
+
* between prepare and confirm never makes a review stale; the live state is shown beside the
|
|
62
|
+
* review ({@link deployment}).
|
|
63
|
+
*/
|
|
64
|
+
reviewProfile(): Promise<HostIsolation>;
|
|
65
|
+
/** The live host state the shadow decisions are computed for: unknown counts as failing. */
|
|
66
|
+
hostIsolation(): Promise<HostIsolation>;
|
|
67
|
+
/** Each live replica's readiness and the plugins a failing supervisor pauses. */
|
|
68
|
+
replicas(): Promise<{
|
|
69
|
+
state: DeploymentIsolation;
|
|
70
|
+
replicas: ReplicaIsolation[];
|
|
71
|
+
paused: IsolationPausedPlugin[];
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Per plugin, each live replica's shadow placement of its last convergence. Read without
|
|
75
|
+
* `extensionHost.isolation` too: the placements say where a revision would run on a host
|
|
76
|
+
* without isolation.
|
|
77
|
+
*/
|
|
78
|
+
shadowExecutions(): Promise<Map<string, PermissionShadowExecution[]>>;
|
|
79
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
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 { sql } from "kysely";
|
|
12
|
+
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
13
|
+
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
14
|
+
import { STALE_RECONCILE_PERIODS } from "../lifecycle-topics.js";
|
|
15
|
+
/** Writes this replica's row (the extension lifecycle, after each convergence). */
|
|
16
|
+
let ReplicaIsolationStore = class ReplicaIsolationStore {
|
|
17
|
+
kdb;
|
|
18
|
+
config;
|
|
19
|
+
constructor(kdb, config) {
|
|
20
|
+
this.kdb = kdb;
|
|
21
|
+
this.config = config;
|
|
22
|
+
}
|
|
23
|
+
async write(replicaId, record) {
|
|
24
|
+
const probe = record.probe;
|
|
25
|
+
// configured but not probed yet (the first probe runs at load): nothing true to record
|
|
26
|
+
if (!probe && this.config.get().extensionHost.isolation)
|
|
27
|
+
return;
|
|
28
|
+
const values = {
|
|
29
|
+
replica_id: replicaId,
|
|
30
|
+
state: !probe
|
|
31
|
+
? "not_configured"
|
|
32
|
+
: probe.result.ok
|
|
33
|
+
? "available"
|
|
34
|
+
: "failing",
|
|
35
|
+
failed_check: probe && !probe.result.ok ? probe.result.check : null,
|
|
36
|
+
message: probe && !probe.result.ok ? probe.result.message : null,
|
|
37
|
+
shadow: JSON.stringify(record.shadow.map(shadowRow)),
|
|
38
|
+
http_replica_id: this.httpReplicaId(),
|
|
39
|
+
probed_at: probe?.at ?? null,
|
|
40
|
+
heartbeat_at: sql `now()`,
|
|
41
|
+
};
|
|
42
|
+
await this.kdb.db
|
|
43
|
+
.insertInto("extension_replica_isolation")
|
|
44
|
+
.values(values)
|
|
45
|
+
.onConflict((oc) => oc.column("replica_id").doUpdateSet({
|
|
46
|
+
state: values.state,
|
|
47
|
+
failed_check: values.failed_check,
|
|
48
|
+
message: values.message,
|
|
49
|
+
shadow: values.shadow,
|
|
50
|
+
http_replica_id: values.http_replica_id,
|
|
51
|
+
probed_at: values.probed_at,
|
|
52
|
+
heartbeat_at: values.heartbeat_at,
|
|
53
|
+
}))
|
|
54
|
+
.execute();
|
|
55
|
+
}
|
|
56
|
+
/** Deletes rows of replicas whose heartbeat is older than `staleSeconds`. */
|
|
57
|
+
async prune(staleSeconds) {
|
|
58
|
+
const r = await this.kdb.db
|
|
59
|
+
.deleteFrom("extension_replica_isolation")
|
|
60
|
+
.where("heartbeat_at", "<", sql `now() - make_interval(secs => ${staleSeconds})`)
|
|
61
|
+
.executeTakeFirst();
|
|
62
|
+
return Number(r.numDeletedRows);
|
|
63
|
+
}
|
|
64
|
+
/** A clean stop: this replica no longer counts. */
|
|
65
|
+
async remove(replicaId) {
|
|
66
|
+
await this.kdb.db
|
|
67
|
+
.deleteFrom("extension_replica_isolation")
|
|
68
|
+
.where("replica_id", "=", replicaId)
|
|
69
|
+
.execute();
|
|
70
|
+
}
|
|
71
|
+
httpReplicaId() {
|
|
72
|
+
const id = this.config.get().http.replicaId;
|
|
73
|
+
return id === undefined ? null : String(id);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
ReplicaIsolationStore = __decorate([
|
|
77
|
+
Injectable(),
|
|
78
|
+
__param(0, Inject(KernelDb)),
|
|
79
|
+
__param(1, Inject(KernelConfigService))
|
|
80
|
+
], ReplicaIsolationStore);
|
|
81
|
+
export { ReplicaIsolationStore };
|
|
82
|
+
function shadowRow(e) {
|
|
83
|
+
return {
|
|
84
|
+
plugin: e.plugin,
|
|
85
|
+
version: e.version,
|
|
86
|
+
host: e.host,
|
|
87
|
+
decision: {
|
|
88
|
+
kind: e.decision.kind,
|
|
89
|
+
fullAccess: e.decision.fullAccess,
|
|
90
|
+
unknownKeys: e.decision.unknownKeys,
|
|
91
|
+
confirmable: e.decision.confirmable,
|
|
92
|
+
},
|
|
93
|
+
uncovered: e.uncovered,
|
|
94
|
+
would: e.would,
|
|
95
|
+
diverges: e.diverges,
|
|
96
|
+
hostReasonRetired: e.hostReasonRetired,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** The deployment-wide reads of the live replicas' rows. */
|
|
100
|
+
let IsolationStatusReader = class IsolationStatusReader {
|
|
101
|
+
kdb;
|
|
102
|
+
config;
|
|
103
|
+
constructor(kdb, config) {
|
|
104
|
+
this.kdb = kdb;
|
|
105
|
+
this.config = config;
|
|
106
|
+
}
|
|
107
|
+
configured() {
|
|
108
|
+
return this.config.get().extensionHost.isolation !== undefined;
|
|
109
|
+
}
|
|
110
|
+
async rows() {
|
|
111
|
+
const staleSeconds = STALE_RECONCILE_PERIODS * this.config.get().extensionHost.reconcileIntervalSeconds;
|
|
112
|
+
return this.kdb.db
|
|
113
|
+
.selectFrom("extension_replica_isolation")
|
|
114
|
+
.selectAll()
|
|
115
|
+
.where("heartbeat_at", ">", sql `now() - make_interval(secs => ${staleSeconds})`)
|
|
116
|
+
.orderBy("replica_id")
|
|
117
|
+
.execute();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Failing when any live replica's supervisor fails, available only when every live replica's
|
|
121
|
+
* passed, unknown before any probed; not configured without reading anything.
|
|
122
|
+
*/
|
|
123
|
+
async deployment() {
|
|
124
|
+
const rows = await this.rows();
|
|
125
|
+
if (!this.deploymentConfigured(rows))
|
|
126
|
+
return "not_configured";
|
|
127
|
+
return deploymentOf(rows);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Whether the deployment runs the supervisor: this replica's config, or any live replica that
|
|
131
|
+
* probed (a mixed configuration answers the same on every replica).
|
|
132
|
+
*/
|
|
133
|
+
deploymentConfigured(rows) {
|
|
134
|
+
return this.configured() || rows.some((row) => row.state !== "not_configured");
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The host profile a permission review binds: `available` when the supervisor is configured,
|
|
138
|
+
* `not_configured` otherwise. A grant's realms depend on the profile, not on the supervisor's
|
|
139
|
+
* readiness at the moment (available and failing need the same grants), so a probe flapping
|
|
140
|
+
* between prepare and confirm never makes a review stale; the live state is shown beside the
|
|
141
|
+
* review ({@link deployment}).
|
|
142
|
+
*/
|
|
143
|
+
async reviewProfile() {
|
|
144
|
+
// the deployment's configuration, not just this replica's: a prepare and a confirm served by
|
|
145
|
+
// two replicas of a mixed configuration bind the same profile
|
|
146
|
+
if (this.configured())
|
|
147
|
+
return "available";
|
|
148
|
+
return this.deploymentConfigured(await this.rows()) ? "available" : "not_configured";
|
|
149
|
+
}
|
|
150
|
+
/** The live host state the shadow decisions are computed for: unknown counts as failing. */
|
|
151
|
+
async hostIsolation() {
|
|
152
|
+
const state = await this.deployment();
|
|
153
|
+
return state === "unknown" ? "failing" : state;
|
|
154
|
+
}
|
|
155
|
+
/** Each live replica's readiness and the plugins a failing supervisor pauses. */
|
|
156
|
+
async replicas() {
|
|
157
|
+
const rows = await this.rows();
|
|
158
|
+
if (!this.deploymentConfigured(rows)) {
|
|
159
|
+
return { state: "not_configured", replicas: [], paused: [] };
|
|
160
|
+
}
|
|
161
|
+
const paused = new Map();
|
|
162
|
+
for (const row of rows) {
|
|
163
|
+
for (const e of shadowOf(row.shadow)) {
|
|
164
|
+
if (e.would !== "unavailable")
|
|
165
|
+
continue;
|
|
166
|
+
const key = `${e.plugin}@${e.version}`;
|
|
167
|
+
const entry = paused.get(key) ?? { plugin: e.plugin, version: e.version, replicas: [] };
|
|
168
|
+
entry.replicas.push(row.replica_id);
|
|
169
|
+
paused.set(key, entry);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
state: deploymentOf(rows),
|
|
174
|
+
replicas: rows.map((row) => ({
|
|
175
|
+
replicaId: row.replica_id,
|
|
176
|
+
state: row.state,
|
|
177
|
+
failedCheck: row.failed_check,
|
|
178
|
+
message: row.message,
|
|
179
|
+
probedAt: row.probed_at?.toISOString() ?? null,
|
|
180
|
+
})),
|
|
181
|
+
paused: [...paused.values()].sort((a, b) => a.plugin === b.plugin ? (a.version < b.version ? -1 : 1) : a.plugin < b.plugin ? -1 : 1),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Per plugin, each live replica's shadow placement of its last convergence. Read without
|
|
186
|
+
* `extensionHost.isolation` too: the placements say where a revision would run on a host
|
|
187
|
+
* without isolation.
|
|
188
|
+
*/
|
|
189
|
+
async shadowExecutions() {
|
|
190
|
+
const out = new Map();
|
|
191
|
+
for (const row of await this.rows()) {
|
|
192
|
+
for (const e of shadowOf(row.shadow)) {
|
|
193
|
+
const { plugin, ...placement } = e;
|
|
194
|
+
const list = out.get(plugin) ?? [];
|
|
195
|
+
list.push({ replicaId: row.replica_id, ...placement });
|
|
196
|
+
out.set(plugin, list);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return out;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
IsolationStatusReader = __decorate([
|
|
203
|
+
Injectable(),
|
|
204
|
+
__param(0, Inject(KernelDb)),
|
|
205
|
+
__param(1, Inject(KernelConfigService))
|
|
206
|
+
], IsolationStatusReader);
|
|
207
|
+
export { IsolationStatusReader };
|
|
208
|
+
/** A replica without the supervisor (a mixed configuration) counts as failing. */
|
|
209
|
+
function deploymentOf(rows) {
|
|
210
|
+
if (rows.length === 0)
|
|
211
|
+
return "unknown";
|
|
212
|
+
return rows.every((row) => row.state === "available") ? "available" : "failing";
|
|
213
|
+
}
|
|
214
|
+
function shadowOf(value) {
|
|
215
|
+
return Array.isArray(value) ? value : [];
|
|
216
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ExtensionBlobs } from "../blobs.js";
|
|
2
2
|
import type { LoadedBootstrapManifest } from "../bootstrap-extra.js";
|
|
3
|
+
import { type ExecutionDecision, type HostIsolation } from "../execution-realm.js";
|
|
3
4
|
import type { DesiredExtension } from "../installs.js";
|
|
5
|
+
import { type ExecutionRealm, type RevisionGrant, type RevisionIdentity } from "../revision-grants.js";
|
|
6
|
+
import type { GrantSurface } from "../revocation-leases.js";
|
|
7
|
+
import { type IsolatedSectionGrant } from "./admission.js";
|
|
4
8
|
export type ExtensionTier = "trusted" | "isolated" | "refused";
|
|
5
9
|
export declare const PUBLISHER_PROOF_MISSING = "Publisher proof missing for this revision; upgrade it from the official marketplace";
|
|
6
10
|
/**
|
|
@@ -16,5 +20,126 @@ export declare function publisherProofRefusal(mode: "require" | "pin-only"): {
|
|
|
16
20
|
* `extension-publisher-proof-recheck` worker job verifies and records it, or it stays refused.
|
|
17
21
|
*/
|
|
18
22
|
export declare function publisherProofMissing(extension: DesiredExtension): boolean;
|
|
19
|
-
/**
|
|
20
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The human-reviewed grant of one exact revision: the interface plan task 1.3a's
|
|
25
|
+
* `ExtensionRevisionApprovals` implements (`implements ReviewedGrants`, provided under
|
|
26
|
+
* {@link REVIEWED_GRANTS}). It returns the live grant (approved or partially revoked) of exactly
|
|
27
|
+
* this revision when a human made it (source `review`, `operator_cli` or `operator_config`), any
|
|
28
|
+
* publisher evidence, and undefined otherwise (no grant, revoked, retired, continuity, automatic).
|
|
29
|
+
* A plain read, safe on every replica.
|
|
30
|
+
*/
|
|
31
|
+
export interface ReviewedGrants {
|
|
32
|
+
reviewedGrant(revision: RevisionIdentity): Promise<RevisionGrant | undefined>;
|
|
33
|
+
}
|
|
34
|
+
/** The Nest token under which the {@link ReviewedGrants} implementation is provided. */
|
|
35
|
+
export declare const REVIEWED_GRANTS: unique symbol;
|
|
36
|
+
/**
|
|
37
|
+
* What admits an official revision without a publisher proof (#1368, plan task 1.3a's pin-only
|
|
38
|
+
* review): the deployment's official proof mode and the human-reviewed grant of the exact revision
|
|
39
|
+
* (a continuity or automatic grant never admits a proofless revision).
|
|
40
|
+
*/
|
|
41
|
+
export interface PinOnlyAdmission extends ReviewedGrants {
|
|
42
|
+
mode(): Promise<"require" | "pin-only">;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Reading the proof mode or the revision's grant failed: not a refusal. A serving revision keeps
|
|
46
|
+
* its tier; any other waits for the next convergence with its own status reason.
|
|
47
|
+
*/
|
|
48
|
+
export declare class GrantReadError extends Error {
|
|
49
|
+
constructor(cause: unknown);
|
|
50
|
+
}
|
|
51
|
+
/** The lowercase hex sha512 of an SRI `sha512-<base64>` integrity, or undefined when malformed. */
|
|
52
|
+
export declare function sha512HexOfIntegrity(integrity: string): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Source, reviewed package revision and integrity jointly determine admission, never the plugin
|
|
55
|
+
* name. `pinOnly` (absent in the CLI) admits a proofless official revision a human reviewed under
|
|
56
|
+
* pin-only (see {@link PinOnlyAdmission}); `extraPins` places an extra-manifest npm pin under its
|
|
57
|
+
* reviewed full-access grant ({@link extraPinTier}).
|
|
58
|
+
*/
|
|
59
|
+
export declare function installedExtensionTier(extension: DesiredExtension, builtin: () => Promise<LoadedBootstrapManifest>, blobs: Pick<ExtensionBlobs, "get">, verifyBytes: boolean, pinOnly?: PinOnlyAdmission,
|
|
60
|
+
/** The grant lookup an extra-manifest npm pin is placed by (#1371); absent: it stays isolated. */
|
|
61
|
+
extraPins?: ReviewedGrants): Promise<ExtensionTier>;
|
|
62
|
+
/**
|
|
63
|
+
* Where one installed revision would run under the execution-realm decision (plan task 1.3b), as
|
|
64
|
+
* the enforcing path of task 1.5a would place it:
|
|
65
|
+
* - `in_process`: server full access, every forcing key covered by its live grant;
|
|
66
|
+
* - `isolated`: the server runs in the supervisor (a client beside it under its browser grant);
|
|
67
|
+
* - `unavailable`: it would run isolated but this replica's supervisor is failing (fail closed,
|
|
68
|
+
* never an in-process fallback);
|
|
69
|
+
* - `pending_review`: a full-access realm whose forcing keys its live grant does not cover;
|
|
70
|
+
* - `client_only` / `declarative`: no server code.
|
|
71
|
+
*/
|
|
72
|
+
export type ShadowPlacement = "in_process" | "isolated" | "unavailable" | "pending_review" | "client_only" | "declarative";
|
|
73
|
+
export interface ShadowExecution {
|
|
74
|
+
plugin: string;
|
|
75
|
+
version: string;
|
|
76
|
+
/** The legacy tier, which governs until task 1.5a. */
|
|
77
|
+
legacy: Exclude<ExtensionTier, "refused">;
|
|
78
|
+
host: HostIsolation;
|
|
79
|
+
decision: ExecutionDecision;
|
|
80
|
+
/** The live grant's generation the coverage was read from. */
|
|
81
|
+
generation?: number;
|
|
82
|
+
/** Per full-access realm, the forcing keys the revision's live grant does not cover. */
|
|
83
|
+
uncovered: Partial<Record<ExecutionRealm, string[]>>;
|
|
84
|
+
/**
|
|
85
|
+
* `host.no-isolation` was retired from this grant (the supervisor became available) and this
|
|
86
|
+
* host lacks isolation again. A later loss of isolation never restores a retired reason: the
|
|
87
|
+
* revision needs a new review before it may run in process here.
|
|
88
|
+
*/
|
|
89
|
+
hostReasonRetired: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The supervisor is available here and the live grant still carries `host.no-isolation` for the
|
|
92
|
+
* server realm: the lifecycle retires it (positive readiness signal only).
|
|
93
|
+
*/
|
|
94
|
+
retireHostReason: boolean;
|
|
95
|
+
would: ShadowPlacement;
|
|
96
|
+
/** The legacy placement and {@link would} differ: what the cutover would change. */
|
|
97
|
+
diverges: boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Per full-access realm of a decision, the forcing keys a grant does not cover: its realm key must
|
|
101
|
+
* still serve and each forcing key must be reviewed and not retired. Empty when the grant covers
|
|
102
|
+
* every realm. The single realm-coverage rule (the shadow execution decision, and the revision
|
|
103
|
+
* approvals' shadow decision of plan task 1.3a).
|
|
104
|
+
*/
|
|
105
|
+
export declare function uncoveredForcing(decision: Pick<ExecutionDecision, "fullAccess">, grant: GrantSurface | undefined): Partial<Record<ExecutionRealm, string[]>>;
|
|
106
|
+
/**
|
|
107
|
+
* The shadow execution decision of one installed revision (plan task 1.3b; rollout fence "shadow
|
|
108
|
+
* mode until 1.5a"): computed and reported, never refused. `keys` are the revision's canonical
|
|
109
|
+
* permission keys; `grant` is its newest grant generation (any state), if any.
|
|
110
|
+
*/
|
|
111
|
+
export declare function shadowExecution(input: {
|
|
112
|
+
plugin: string;
|
|
113
|
+
version: string;
|
|
114
|
+
legacy: Exclude<ExtensionTier, "refused">;
|
|
115
|
+
section: DesiredExtension["section"];
|
|
116
|
+
keys: readonly string[];
|
|
117
|
+
host: HostIsolation;
|
|
118
|
+
grant: GrantSurface | undefined;
|
|
119
|
+
}): ShadowExecution;
|
|
120
|
+
/** {@link shadowExecution} for an installed revision, its keys read from its reviewed section. */
|
|
121
|
+
export declare function shadowExecutionOf(extension: Pick<DesiredExtension, "name" | "version" | "section">, legacy: Exclude<ExtensionTier, "refused">, host: HostIsolation, grant: GrantSurface | undefined): ShadowExecution;
|
|
122
|
+
/**
|
|
123
|
+
* What the isolated admission takes from a revision's newest grant: whether its live grant covers
|
|
124
|
+
* every browser forcing key of the revision (its client entry beside an isolated server).
|
|
125
|
+
*/
|
|
126
|
+
export declare function isolatedSectionGrant(extension: Pick<DesiredExtension, "name" | "version" | "section">, grant: GrantSurface | undefined): IsolatedSectionGrant;
|
|
127
|
+
/**
|
|
128
|
+
* Whether a convergence keeps the admission of a revision this replica already serves (`serving`,
|
|
129
|
+
* its current tier; undefined when it does not serve this exact revision). Shadow mode until task
|
|
130
|
+
* 1.5a: a grant change is reported, never acted on.
|
|
131
|
+
* - `pin_only_grant`: a pin-only revision's grant changed (a retired host reason, a revoked realm or
|
|
132
|
+
* grant); kept until enforcing, when 1.3e's afterRevocation moves or refuses it.
|
|
133
|
+
* - `browser_grant`: the browser realm beside an isolated server is no longer covered; kept in the
|
|
134
|
+
* same tier until enforcing.
|
|
135
|
+
* - `extra_pin_grant`: a bootstrap-source revision (an extra-manifest pin placed by its grant,
|
|
136
|
+
* #1371) whose grant changed (revoked, a host reason retired); kept until enforcing. A built-in
|
|
137
|
+
* pin's placement depends only on its exact revision, so keeping it changes nothing.
|
|
138
|
+
* - `grant_read_failed`: the grant could not be read; always kept (a read error is no refusal).
|
|
139
|
+
*/
|
|
140
|
+
export declare function keepsServingAdmission(input: {
|
|
141
|
+
serving: ExtensionTier | undefined;
|
|
142
|
+
tier?: ExtensionTier;
|
|
143
|
+
enforced: boolean;
|
|
144
|
+
cause: "pin_only_grant" | "extra_pin_grant" | "browser_grant" | "grant_read_failed";
|
|
145
|
+
}): boolean;
|