@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.
Files changed (172) hide show
  1. package/dist/admin/extensions.controller.d.ts +0 -11
  2. package/dist/admin/extensions.controller.js +0 -28
  3. package/dist/admin/health.service.d.ts +25 -1
  4. package/dist/admin/health.service.js +50 -18
  5. package/dist/audit/full-access.d.ts +78 -0
  6. package/dist/audit/full-access.js +283 -0
  7. package/dist/automations/automations.service.d.ts +1 -0
  8. package/dist/automations/automations.service.js +3 -1
  9. package/dist/automations/calendar.js +3 -1
  10. package/dist/automations/grant-rules.d.ts +2 -1
  11. package/dist/automations/grant-rules.js +8 -1
  12. package/dist/automations/unattended.d.ts +13 -1
  13. package/dist/automations/unattended.js +13 -1
  14. package/dist/catalog/admin-catalog.controller.d.ts +8 -0
  15. package/dist/catalog/admin-catalog.controller.js +8 -2
  16. package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
  17. package/dist/catalog/admin-catalog.schemas.js +8 -1
  18. package/dist/catalog/catalog-content.d.ts +6 -0
  19. package/dist/catalog/catalog-scope.service.d.ts +22 -2
  20. package/dist/catalog/catalog-scope.service.js +27 -3
  21. package/dist/catalog/catalog.service.js +19 -2
  22. package/dist/catalog/marketplaces.service.d.ts +1 -1
  23. package/dist/catalog/org-catalog.service.d.ts +8 -1
  24. package/dist/catalog/org-catalog.service.js +36 -3
  25. package/dist/catalog/platform-components.js +3 -2
  26. package/dist/catalog/platform-import-update.d.ts +2 -0
  27. package/dist/catalog/platform-import-update.js +8 -1
  28. package/dist/catalog/plugin-connectors.d.ts +11 -0
  29. package/dist/catalog/plugin-connectors.js +33 -0
  30. package/dist/catalog/plugin-import.d.ts +35 -15
  31. package/dist/catalog/plugin-import.js +110 -35
  32. package/dist/catalog/plugin-install.js +6 -0
  33. package/dist/catalog/provenance.d.ts +2 -0
  34. package/dist/catalog/provenance.js +5 -1
  35. package/dist/config/auto-approve.d.ts +16 -0
  36. package/dist/config/auto-approve.js +24 -0
  37. package/dist/config/capacity-presets.d.ts +243 -0
  38. package/dist/config/capacity-presets.js +195 -0
  39. package/dist/config/env.d.ts +2 -1
  40. package/dist/config/env.js +6 -1
  41. package/dist/config/load.js +15 -0
  42. package/dist/config/schema.d.ts +46 -9
  43. package/dist/config/schema.js +154 -30
  44. package/dist/ctx/net.d.ts +5 -1
  45. package/dist/ctx/net.js +62 -12
  46. package/dist/db/kernel-schema.d.ts +31 -0
  47. package/dist/db/migrator.js +0 -36
  48. package/dist/dial-in/routes.js +1 -1
  49. package/dist/erasure/org-batches.js +1 -6
  50. package/dist/erasure/org-catalog.js +6 -2
  51. package/dist/erasure/org-rules.js +1 -0
  52. package/dist/erasure/org-worker.js +0 -13
  53. package/dist/errors.d.ts +6 -0
  54. package/dist/errors.js +6 -0
  55. package/dist/extensions/admin-ops.d.ts +14 -1
  56. package/dist/extensions/admin-ops.js +30 -3
  57. package/dist/extensions/admin-view.d.ts +21 -1
  58. package/dist/extensions/admin-view.js +43 -0
  59. package/dist/extensions/bootstrap-packages.d.ts +5 -0
  60. package/dist/extensions/bootstrap-packages.js +1 -1
  61. package/dist/extensions/bootstrap-review.d.ts +251 -0
  62. package/dist/extensions/bootstrap-review.js +676 -0
  63. package/dist/extensions/bootstrap.d.ts +21 -1
  64. package/dist/extensions/bootstrap.js +72 -2
  65. package/dist/extensions/cli.d.ts +6 -0
  66. package/dist/extensions/cli.js +4 -0
  67. package/dist/extensions/enabled.d.ts +3 -0
  68. package/dist/extensions/extensions.module.js +9 -0
  69. package/dist/extensions/full-access-disclosure.d.ts +15 -0
  70. package/dist/extensions/full-access-disclosure.js +57 -0
  71. package/dist/extensions/grant-epoch.d.ts +5 -0
  72. package/dist/extensions/grant-epoch.js +9 -0
  73. package/dist/extensions/host.d.ts +71 -2
  74. package/dist/extensions/host.js +293 -27
  75. package/dist/extensions/installs.d.ts +18 -0
  76. package/dist/extensions/installs.js +28 -0
  77. package/dist/extensions/isolated/admission.d.ts +17 -2
  78. package/dist/extensions/isolated/admission.js +18 -8
  79. package/dist/extensions/isolated/authorization.d.ts +8 -2
  80. package/dist/extensions/isolated/authorization.js +11 -3
  81. package/dist/extensions/isolated/broker.d.ts +3 -0
  82. package/dist/extensions/isolated/broker.js +50 -14
  83. package/dist/extensions/isolated/configured-package.d.ts +5 -0
  84. package/dist/extensions/isolated/configured-package.js +2 -0
  85. package/dist/extensions/isolated/lanes.d.ts +44 -3
  86. package/dist/extensions/isolated/lanes.js +263 -80
  87. package/dist/extensions/isolated/metrics.d.ts +146 -0
  88. package/dist/extensions/isolated/metrics.js +304 -0
  89. package/dist/extensions/isolated/revision.d.ts +7 -1
  90. package/dist/extensions/isolated/revision.js +26 -5
  91. package/dist/extensions/isolated/rpc.d.ts +5 -0
  92. package/dist/extensions/isolated/rpc.js +7 -2
  93. package/dist/extensions/isolated/sandbox.d.ts +23 -0
  94. package/dist/extensions/isolated/sandbox.js +50 -0
  95. package/dist/extensions/isolated/status.d.ts +79 -0
  96. package/dist/extensions/isolated/status.js +216 -0
  97. package/dist/extensions/isolated/tier.d.ts +127 -2
  98. package/dist/extensions/isolated/tier.js +266 -7
  99. package/dist/extensions/isolated/usage.d.ts +134 -0
  100. package/dist/extensions/isolated/usage.js +322 -0
  101. package/dist/extensions/lifecycle.d.ts +42 -2
  102. package/dist/extensions/lifecycle.js +100 -4
  103. package/dist/extensions/org-config.js +11 -0
  104. package/dist/extensions/package.d.ts +14 -0
  105. package/dist/extensions/package.js +24 -3
  106. package/dist/extensions/permission-set.d.ts +12 -3
  107. package/dist/extensions/permission-set.js +5 -5
  108. package/dist/extensions/permission-view.d.ts +12 -5
  109. package/dist/extensions/permission-view.js +23 -2
  110. package/dist/extensions/permissions.controller.d.ts +35 -0
  111. package/dist/extensions/permissions.controller.js +98 -0
  112. package/dist/extensions/permissions.schemas.d.ts +288 -0
  113. package/dist/extensions/permissions.schemas.js +96 -0
  114. package/dist/extensions/permissions.service.d.ts +116 -0
  115. package/dist/extensions/permissions.service.js +428 -0
  116. package/dist/extensions/realm-retirement.d.ts +65 -0
  117. package/dist/extensions/realm-retirement.js +150 -0
  118. package/dist/extensions/revision-approvals.d.ts +58 -3
  119. package/dist/extensions/revision-approvals.js +135 -14
  120. package/dist/extensions/revision-review.d.ts +144 -0
  121. package/dist/extensions/revision-review.js +297 -0
  122. package/dist/extensions/revocation.js +3 -0
  123. package/dist/extensions/state.module.js +12 -0
  124. package/dist/git/run-end.d.ts +35 -7
  125. package/dist/git/run-end.js +87 -38
  126. package/dist/http/api.module.js +2 -0
  127. package/dist/identity/audit.d.ts +2 -1
  128. package/dist/identity/audit.js +4 -17
  129. package/dist/index.d.ts +6 -2
  130. package/dist/index.js +6 -2
  131. package/dist/infra/config/kernel-config.service.d.ts +6 -0
  132. package/dist/infra/config/kernel-config.service.js +21 -0
  133. package/dist/infra/outbox/registry.d.ts +13 -0
  134. package/dist/infra/outbox/registry.js +8 -0
  135. package/dist/lifecycle/kernel-lifecycle.d.ts +25 -1
  136. package/dist/lifecycle/kernel-lifecycle.js +73 -18
  137. package/dist/net/private-endpoint-preflight.d.ts +159 -0
  138. package/dist/net/private-endpoint-preflight.js +417 -0
  139. package/dist/net/private-endpoints.d.ts +68 -0
  140. package/dist/net/private-endpoints.js +164 -0
  141. package/dist/net/public-address.d.ts +14 -0
  142. package/dist/net/public-address.js +15 -1
  143. package/dist/net/safe-fetch.d.ts +2 -1
  144. package/dist/net/safe-fetch.js +10 -3
  145. package/dist/overrides.d.ts +4 -0
  146. package/dist/overrides.js +2 -0
  147. package/dist/packages/official-publisher.d.ts +26 -1
  148. package/dist/packages/official-publisher.js +48 -1
  149. package/dist/packages/provenance.d.ts +11 -0
  150. package/dist/packages/provenance.js +24 -0
  151. package/dist/platform/exclusions.js +4 -4
  152. package/dist/platform/ops/automations.ops.js +1 -1
  153. package/dist/platform/ops/catalog-admin.ops.js +25 -4
  154. package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
  155. package/dist/platform/ops/extension-permissions.ops.js +159 -0
  156. package/dist/platform/platform-ops.module.d.ts +2 -1
  157. package/dist/platform/platform-ops.module.js +2 -0
  158. package/dist/platform/route-schemas.js +2 -0
  159. package/dist/retention/purge-batch.js +10 -14
  160. package/dist/runtime/maintenance.d.ts +4 -2
  161. package/dist/runtime/maintenance.js +16 -3
  162. package/dist/runtime/run-finish.d.ts +3 -3
  163. package/dist/runtime/run-finish.js +7 -3
  164. package/dist/sandbox/permission-availability.d.ts +17 -2
  165. package/dist/sandbox/permission-availability.js +22 -1
  166. package/dist/sandbox/permission-facts.js +7 -1
  167. package/dist/tools/builtins/sandbox/common.js +2 -0
  168. package/dist/tools/pipeline.d.ts +2 -1
  169. package/dist/tools/pipeline.js +7 -2
  170. package/package.json +4 -3
  171. package/src/migrations/0238_extension_usage.sql +40 -0
  172. package/src/migrations/0239_extension_replica_isolation.sql +28 -0
@@ -8,16 +8,36 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { Inject, Injectable } from "@nestjs/common";
11
+ import { sql } from "kysely";
11
12
  import { audit } from "../identity/audit.js";
12
13
  import { KernelDb } from "../infra/database/kernel-db.js";
14
+ import { TransactionHost } from "../infra/database/transaction-host.js";
15
+ import { Transactional } from "../infra/database/transactional.decorator.js";
13
16
  import { KERNEL_LOGGER, REDIS } from "../infra/tokens.js";
17
+ import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
14
18
  import { GitTickets } from "./tickets.js";
15
19
  /**
16
20
  * What a run's end does for the git gateway (sandbox git credentials spec §9): revokes the run's
17
- * tickets and writes the `git.fetch` summaries. `RunFinish` calls it in `afterCommit` of the
18
- * transaction that set the terminal status (set first, then revoke: `GitTickets.resolve` already
19
- * refuses a run that is not active, so revocation is cleanup and defense in depth).
21
+ * tickets and writes the `git.fetch` summaries. `RunFinish` revokes in `afterCommit` of the
22
+ * transaction that set the terminal status (a hint: `GitTickets.resolve` already refuses a run that
23
+ * is not active, so revocation is cleanup and defense in depth), and owes the summaries in that
24
+ * transaction as a {@link GIT_FETCH_AUDIT_JOB} outbox job, so a crash after the commit never loses
25
+ * the audit.
20
26
  */
27
+ /** The maintenance job that writes a finished run's `git.fetch` summaries (outbox registry). */
28
+ export const GIT_FETCH_AUDIT_JOB = "git-fetch-audit";
29
+ /** One job per run (no `:`): a second owe of the same run's end is a no-op. */
30
+ export const gitFetchAuditJobId = (runId) => `git-fetch-audit-${runId}`;
31
+ /** Owes the run's fetch summaries in the caller's transaction (throws outside one). */
32
+ export function oweGitFetchAudit(outbox, runId, orgId) {
33
+ return outbox.add({
34
+ queue: MAINTENANCE_QUEUE_NAME,
35
+ name: GIT_FETCH_AUDIT_JOB,
36
+ jobId: gitFetchAuditJobId(runId),
37
+ data: { runId },
38
+ orgId,
39
+ });
40
+ }
21
41
  /** The Redis hash of a run's fetch counters: fields `<host>/<repo>|n` and `<host>/<repo>|bytes`. */
22
42
  export const gitFetchKey = (runId) => `git-fetch:${runId}`;
23
43
  /**
@@ -35,63 +55,88 @@ export async function recordGitFetch(redis, runId, host, repo, bytes, countReque
35
55
  m.hincrby(key, `${field}|bytes`, Math.max(0, Math.round(bytes)));
36
56
  await m.expire(key, FETCH_COUNTER_TTL_SECONDS).exec();
37
57
  }
38
- /** Reads and deletes a hash in one step, so a summary is written once. */
39
- const TAKE_HASH = `
40
- local all = redis.call('HGETALL', KEYS[1])
41
- redis.call('DEL', KEYS[1])
42
- return all
43
- `;
44
58
  let GitRunEnd = class GitRunEnd {
45
59
  tickets;
46
60
  db;
47
61
  redis;
48
62
  log;
49
- constructor(tickets, db, redis, log) {
63
+ txHost;
64
+ constructor(tickets, db, redis, log, txHost) {
50
65
  this.tickets = tickets;
51
66
  this.db = db;
52
67
  this.redis = redis;
53
68
  this.log = log;
69
+ this.txHost = txHost;
54
70
  }
55
- /** Run end: revokes the run's tickets and writes one `git.fetch` audit row per repository. */
56
- async onRunFinished(runId) {
57
- // both steps always run: a failing revocation must not lose the summaries, nor the reverse
58
- const results = await Promise.allSettled([
59
- this.tickets.revokeRun(runId),
60
- this.writeFetchSummaries(runId),
61
- ]);
62
- for (const r of results) {
63
- if (r.status === "rejected") {
64
- this.log.warn("git run end failed", {
65
- runId,
66
- error: r.reason instanceof Error ? r.reason.name : "unknown",
67
- });
68
- }
71
+ /**
72
+ * Whether the run counted any fetch, read in its terminal transaction: only then is a summary
73
+ * owed. A failed read owes it anyway (the job finds nothing to write).
74
+ */
75
+ async hasFetches(runId) {
76
+ try {
77
+ return (await this.redis.exists(gitFetchKey(runId))) === 1;
78
+ }
79
+ catch {
80
+ return true;
81
+ }
82
+ }
83
+ /** Run end, after the commit: revokes the run's tickets (a hint whose loss is harmless). */
84
+ async revokeTickets(runId) {
85
+ try {
86
+ await this.tickets.revokeRun(runId);
87
+ }
88
+ catch (err) {
89
+ this.log.warn("git ticket revocation at run end failed", {
90
+ runId,
91
+ error: err instanceof Error ? err.name : "unknown",
92
+ });
69
93
  }
70
94
  }
95
+ /**
96
+ * The {@link GIT_FETCH_AUDIT_JOB} body, in the run's org scope: one `git.fetch` audit row per
97
+ * repository from the run's counters, then the counters dropped. The rows commit before the
98
+ * delete, and a run that already has summaries gets none again, so a redelivery after a crash
99
+ * between the two writes no duplicate.
100
+ */
71
101
  async writeFetchSummaries(runId) {
72
- const flat = (await this.redis.eval(TAKE_HASH, 1, gitFetchKey(runId)));
102
+ const key = gitFetchKey(runId);
103
+ const flat = Object.entries(await this.redis.hgetall(key));
73
104
  if (flat.length === 0)
74
105
  return;
106
+ await this.insertSummaries(runId, flat);
107
+ await this.redis.del(key);
108
+ }
109
+ /** The rows, committed in their own transaction before the caller drops the counters. */
110
+ async insertSummaries(runId, fields) {
111
+ const run = await this.db
112
+ .selectFrom("runs")
113
+ .innerJoin("conversations", "conversations.id", "runs.conversation_id")
114
+ .select(["runs.conversation_id", "runs.trigger_account_id", "conversations.org_id"])
115
+ .where("runs.id", "=", runId)
116
+ .executeTakeFirst();
117
+ if (run === undefined)
118
+ return;
119
+ const written = await this.db
120
+ .selectFrom("audit_events")
121
+ .select("id")
122
+ .where("org_id", "=", run.org_id)
123
+ .where("action", "=", "git.fetch")
124
+ .where(sql `detail->>'runId'`, "=", runId)
125
+ .limit(1)
126
+ .executeTakeFirst();
127
+ if (written !== undefined)
128
+ return;
75
129
  const perRepo = new Map();
76
- for (let i = 0; i + 1 < flat.length; i += 2) {
77
- const field = String(flat[i]);
130
+ for (const [field, value] of fields) {
78
131
  const cut = field.lastIndexOf("|");
79
132
  const target = field.slice(0, cut);
80
133
  const entry = perRepo.get(target) ?? { count: 0, bytes: 0 };
81
134
  if (field.slice(cut + 1) === "n")
82
- entry.count = Number(flat[i + 1]);
135
+ entry.count = Number(value);
83
136
  else
84
- entry.bytes = Number(flat[i + 1]);
137
+ entry.bytes = Number(value);
85
138
  perRepo.set(target, entry);
86
139
  }
87
- const run = await this.db.db
88
- .selectFrom("runs")
89
- .innerJoin("conversations", "conversations.id", "runs.conversation_id")
90
- .select(["runs.conversation_id", "runs.trigger_account_id", "conversations.org_id"])
91
- .where("runs.id", "=", runId)
92
- .executeTakeFirst();
93
- if (run === undefined)
94
- return;
95
140
  for (const [target, { count, bytes }] of perRepo) {
96
141
  const slash = target.indexOf("/");
97
142
  await audit(this.db.db, {
@@ -111,11 +156,15 @@ let GitRunEnd = class GitRunEnd {
111
156
  }
112
157
  }
113
158
  };
159
+ __decorate([
160
+ Transactional({ propagation: "requires_new" })
161
+ ], GitRunEnd.prototype, "insertSummaries", null);
114
162
  GitRunEnd = __decorate([
115
163
  Injectable(),
116
164
  __param(0, Inject(GitTickets)),
117
165
  __param(1, Inject(KernelDb)),
118
166
  __param(2, Inject(REDIS)),
119
- __param(3, Inject(KERNEL_LOGGER))
167
+ __param(3, Inject(KERNEL_LOGGER)),
168
+ __param(4, Inject(TransactionHost))
120
169
  ], GitRunEnd);
121
170
  export { GitRunEnd };
@@ -55,6 +55,7 @@ import { EvalRunsController } from "../evals/runs.controller.js";
55
55
  import { EvalSetsController } from "../evals/sets.controller.js";
56
56
  import { TrajectoryController } from "../evals/trajectory.controller.js";
57
57
  import { ExtensionsModule } from "../extensions/extensions.module.js";
58
+ import { ExtensionPermissionsController } from "../extensions/permissions.controller.js";
58
59
  import { ExtensionPointDefaultsController } from "../extensions/point-defaults.controller.js";
59
60
  import { FilesModule } from "../files/files.module.js";
60
61
  import { LibraryFilesController } from "../files/library.controller.js";
@@ -151,6 +152,7 @@ const CONTROLLERS = [
151
152
  AdminOrgNetworkController,
152
153
  AdminLoginSourcesController,
153
154
  AdminExtensionsController,
155
+ ExtensionPermissionsController,
154
156
  AdminCatalogController,
155
157
  AdminComponentsController,
156
158
  MarketplacesController,
@@ -2,7 +2,8 @@ import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
2
  /**
3
3
  * Writes one audit event (`action` is dotted lower-case English, e.g. `org.member.role_changed`)
4
4
  * through `db`: a service passes `this.db.db` (`KernelDb`: the context's transaction or the pool),
5
- * so the event commits or rolls back with the write it records.
5
+ * so the event commits or rolls back with the write it records. A full-access event is also copied
6
+ * into every org it affects (`audit/full-access.ts`, plan task 1.4c).
6
7
  */
7
8
  export declare function audit(db: KernelSchemaDb, e: {
8
9
  /** The acting account; absent or null for the kernel itself (a job such as the scope sync). */
@@ -1,23 +1,10 @@
1
- import { asPlatform } from "../infra/database/org-scope.js";
1
+ import { writeAuditEvent } from "../audit/full-access.js";
2
2
  /**
3
3
  * Writes one audit event (`action` is dotted lower-case English, e.g. `org.member.role_changed`)
4
4
  * through `db`: a service passes `this.db.db` (`KernelDb`: the context's transaction or the pool),
5
- * so the event commits or rolls back with the write it records.
5
+ * so the event commits or rolls back with the write it records. A full-access event is also copied
6
+ * into every org it affects (`audit/full-access.ts`, plan task 1.4c).
6
7
  */
7
8
  export async function audit(db, e) {
8
- const query = db.insertInto("audit_events").values({
9
- actor_account_id: e.actorAccountId ?? null,
10
- actor_token_id: e.actorTokenId ?? null,
11
- org_id: e.orgId ?? null,
12
- action: e.action,
13
- target: e.target ?? null,
14
- detail: JSON.stringify(e.detail ?? {}),
15
- });
16
- if (e.orgId === undefined) {
17
- // org-filter: deployment-wide audit events have no org and may originate inside an org call.
18
- await asPlatform("Record an audit event without an org", () => query.execute());
19
- }
20
- else {
21
- await query.execute();
22
- }
9
+ await writeAuditEvent(db, e);
23
10
  }
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@ export type { PluginConfirmResult, PluginReview } from "./catalog/plugin-import.
6
6
  export { type PluginPackage, PluginPackageError, type ReadPluginPackageOptions, readPluginPackage, } from "./catalog/plugin-package.js";
7
7
  export { classifyPublisherEvidence, normalizePublisherIdentity, type PublisherEvidence, type PublisherEvidenceOutcome, refClass, samePublisher, } from "./catalog/provenance.js";
8
8
  export { gatewayReplicasKey } from "./channels/supervisor.js";
9
+ export { autoApproveRefusal, isOfficialImage, OFFICIAL_IMAGE_MARKER, } from "./config/auto-approve.js";
10
+ export { CAPACITY_PRESETS, type CapacityConfig, type CapacityPreset, type IsolatedCapacity, resolveCapacity, } from "./config/capacity-presets.js";
9
11
  export { envName, renderConfigDocs } from "./config/docs.js";
10
12
  export { envOverrides } from "./config/env.js";
11
13
  export { type ConfigField, changedPaths, configFields, secretValues } from "./config/fields.js";
@@ -37,6 +39,7 @@ export { type BootstrapEntryResult, BootstrapFailedError, type BootstrapFailure,
37
39
  export { BootstrapExtraMismatchError, type ExtraManifestTraces, hasExtraManifestTraces, loadBootstrapManifest, type MergedBootstrapManifest, mergeBootstrapManifests, missingExtraManifestMessage, readBootstrapExtraManifest, } from "./extensions/bootstrap-extra.js";
38
40
  export { BOOTSTRAP_MANIFEST_FILE, bootstrapManifestSha256, readBootstrapManifest, } from "./extensions/bootstrap-manifest.js";
39
41
  export { type BootstrapGitPlugin, type BootstrapResolveOptions, readBootstrapGitPlugin, resolveBootstrapPackages, } from "./extensions/bootstrap-packages.js";
42
+ export { type ApprovalVia, BOOTSTRAP_REVIEW_CONTRACT, type BootstrapApproval, type BootstrapEntryStatus, type BootstrapReview, type BootstrapReviewEntry, BootstrapReviewError, BootstrapReviewService, type BootstrapRevisionInput, type BootstrapStartGate, bootstrapBatchHash, bootstrapPinInputs, bootstrapRevisionDisplay, freshBootstrapReview, integrityHex, } from "./extensions/bootstrap-review.js";
40
43
  export { type ExtensionCli, openExtensionCli } from "./extensions/cli.js";
41
44
  export { DEPLOYMENT_SECRETS_ORG, type DeploymentConfigField, type DeploymentConfigView, ExtensionDeploymentConfigService, mergeDeploymentConfig, PLUGIN_DEPLOYMENT_CONFIG_TOPIC, readStoredDeploymentConfig, type SecretEntry, } from "./extensions/deployment-config.js";
42
45
  export { CONFIG_SCHEMA_UNSUPPORTED_KEY, describeExecution, type ExecutionDecision, type ExecutionInput, executionDecision, fullAccessKeys, HOST_NO_ISOLATION_KEY, type HostIsolation, type RealmPlacement, } from "./extensions/execution-realm.js";
@@ -48,11 +51,12 @@ export { deploymentConfigIsolatable, isolatedDeploymentSchema, } from "./extensi
48
51
  export { ExtensionLifecycle, PLUGINS_RECONCILE_JOB, PLUGINS_RECONCILE_TOPIC, } from "./extensions/lifecycle.js";
49
52
  export { ensureMigrated, MIGRATE_LOCK_PREFIX, type MigrateLockDeps, PLUGINS_MIGRATED_TOPIC, unrunMigrations, } from "./extensions/migrate-lock.js";
50
53
  export { EXTENSION_PACKAGE_LIMITS, type ExtensionPackage, ExtensionPackageError, type ExtensionPackageLimits, type ExtensionPackageSection, extractExtensionPackage, HOST_ZOD_VERSION, permissionSetOfPackage, type ReadExtensionPackageOptions, readExtensionPackage, } from "./extensions/package.js";
51
- export { blockingKeys, buildPermissionSet, computePermissionSet, diffPermissions, type PermissionSet, permissionKeys, WARNINGS_KEY_PREFIX, } from "./extensions/permission-set.js";
52
- export { type AdminExtensionView, type DeploymentExtensionStatus, isSensitivePermissionKey, type PermissionGroup, type PermissionItem, permissionGroups, permissionKeyItems, reviewHash, SENSITIVE_EXTENSION_POINTS, type SensitiveReason, } from "./extensions/permission-view.js";
54
+ export { blockingKeys, buildPermissionSet, computePermissionSet, diffPermissions, type PermissionSet, permissionKeys, RAW_EGRESS_PERMISSION_KEY, WARNINGS_KEY_PREFIX, } from "./extensions/permission-set.js";
55
+ export { type AdminExtensionView, type DeploymentExtensionStatus, isSensitivePermissionKey, type PermissionGroup, type PermissionItem, permissionGroups, permissionKeyItems, permissionPurposes, reviewHash, SENSITIVE_EXTENSION_POINTS, type SensitiveReason, } from "./extensions/permission-view.js";
53
56
  export { ExtensionRegistry } from "./extensions/registry.js";
54
57
  export { ExtensionResolveError, resolveExtensions } from "./extensions/resolve.js";
55
58
  export { fullAccessPurpose, grantPurposeRows, REVIEW_CONTRACT_VERSION, type ReviewDisplay, type ReviewInput, reviewDisplay, revisionReviewHash, } from "./extensions/review-hash.js";
59
+ export { type ApprovalScope, ExtensionRevisionGrants, type NewRevisionGrant, type PurposeRow, type RevisionGrant, type RevisionIdentity, } from "./extensions/revision-grants.js";
56
60
  export { type ExtensionLoadStatus, type ExtensionSource, newReplicaId, type PendingReason, ReplicaStatusStore, } from "./extensions/sources.js";
57
61
  export { syncPackage } from "./extensions/sync.js";
58
62
  export type { KernelHttp, KernelHttpApp } from "./http/app.js";
package/dist/index.js CHANGED
@@ -6,6 +6,8 @@ export { GitSourceError, readGitTree, } from "./catalog/git-source.js";
6
6
  export { PluginPackageError, readPluginPackage, } from "./catalog/plugin-package.js";
7
7
  export { classifyPublisherEvidence, normalizePublisherIdentity, refClass, samePublisher, } from "./catalog/provenance.js";
8
8
  export { gatewayReplicasKey } from "./channels/supervisor.js";
9
+ export { autoApproveRefusal, isOfficialImage, OFFICIAL_IMAGE_MARKER, } from "./config/auto-approve.js";
10
+ export { CAPACITY_PRESETS, resolveCapacity, } from "./config/capacity-presets.js";
9
11
  export { envName, renderConfigDocs } from "./config/docs.js";
10
12
  export { envOverrides } from "./config/env.js";
11
13
  export { changedPaths, configFields, secretValues } from "./config/fields.js";
@@ -36,6 +38,7 @@ export { BootstrapFailedError, BootstrapService, } from "./extensions/bootstrap.
36
38
  export { BootstrapExtraMismatchError, hasExtraManifestTraces, loadBootstrapManifest, mergeBootstrapManifests, missingExtraManifestMessage, readBootstrapExtraManifest, } from "./extensions/bootstrap-extra.js";
37
39
  export { BOOTSTRAP_MANIFEST_FILE, bootstrapManifestSha256, readBootstrapManifest, } from "./extensions/bootstrap-manifest.js";
38
40
  export { readBootstrapGitPlugin, resolveBootstrapPackages, } from "./extensions/bootstrap-packages.js";
41
+ export { BOOTSTRAP_REVIEW_CONTRACT, BootstrapReviewError, BootstrapReviewService, bootstrapBatchHash, bootstrapPinInputs, bootstrapRevisionDisplay, freshBootstrapReview, integrityHex, } from "./extensions/bootstrap-review.js";
39
42
  export { openExtensionCli } from "./extensions/cli.js";
40
43
  export { DEPLOYMENT_SECRETS_ORG, ExtensionDeploymentConfigService, mergeDeploymentConfig, PLUGIN_DEPLOYMENT_CONFIG_TOPIC, readStoredDeploymentConfig, } from "./extensions/deployment-config.js";
41
44
  export { CONFIG_SCHEMA_UNSUPPORTED_KEY, describeExecution, executionDecision, fullAccessKeys, HOST_NO_ISOLATION_KEY, } from "./extensions/execution-realm.js";
@@ -47,11 +50,12 @@ export { deploymentConfigIsolatable, isolatedDeploymentSchema, } from "./extensi
47
50
  export { ExtensionLifecycle, PLUGINS_RECONCILE_JOB, PLUGINS_RECONCILE_TOPIC, } from "./extensions/lifecycle.js";
48
51
  export { ensureMigrated, MIGRATE_LOCK_PREFIX, PLUGINS_MIGRATED_TOPIC, unrunMigrations, } from "./extensions/migrate-lock.js";
49
52
  export { EXTENSION_PACKAGE_LIMITS, ExtensionPackageError, extractExtensionPackage, HOST_ZOD_VERSION, permissionSetOfPackage, readExtensionPackage, } from "./extensions/package.js";
50
- export { blockingKeys, buildPermissionSet, computePermissionSet, diffPermissions, permissionKeys, WARNINGS_KEY_PREFIX, } from "./extensions/permission-set.js";
51
- export { isSensitivePermissionKey, permissionGroups, permissionKeyItems, reviewHash, SENSITIVE_EXTENSION_POINTS, } from "./extensions/permission-view.js";
53
+ export { blockingKeys, buildPermissionSet, computePermissionSet, diffPermissions, permissionKeys, RAW_EGRESS_PERMISSION_KEY, WARNINGS_KEY_PREFIX, } from "./extensions/permission-set.js";
54
+ export { isSensitivePermissionKey, permissionGroups, permissionKeyItems, permissionPurposes, reviewHash, SENSITIVE_EXTENSION_POINTS, } from "./extensions/permission-view.js";
52
55
  export { ExtensionRegistry } from "./extensions/registry.js";
53
56
  export { ExtensionResolveError, resolveExtensions } from "./extensions/resolve.js";
54
57
  export { fullAccessPurpose, grantPurposeRows, REVIEW_CONTRACT_VERSION, reviewDisplay, revisionReviewHash, } from "./extensions/review-hash.js";
58
+ export { ExtensionRevisionGrants, } from "./extensions/revision-grants.js";
55
59
  export { newReplicaId, ReplicaStatusStore, } from "./extensions/sources.js";
56
60
  export { syncPackage } from "./extensions/sync.js";
57
61
  export { AccountsModule, AccountsService } from "./identity/accounts.js";
@@ -14,6 +14,12 @@ export declare class KernelConfigService {
14
14
  private readonly env;
15
15
  private readonly listeners;
16
16
  constructor(input: KernelConfigInput, log: KernelLogger);
17
+ /**
18
+ * Fields whose invalid value fell back (capacity to its preset, `metrics.*` to its default) and
19
+ * unknown capacity keys that were dropped while the config was parsed: never fatal, never
20
+ * silent. Logged at startup and after each reload that produced any.
21
+ */
22
+ private warnFallbacks;
17
23
  get(): KernelConfig;
18
24
  /**
19
25
  * Where the current value of a field without a schema default comes from: `env` when an
@@ -8,6 +8,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { Inject, Injectable } from "@nestjs/common";
11
+ import { CAPACITY_HOT_PATHS, takeConfigFallbacks } from "../../config/capacity-presets.js";
11
12
  import { envOverrides } from "../../config/env.js";
12
13
  import { changedPaths, configFields, getPath, secretValues, setPath } from "../../config/fields.js";
13
14
  import { resolveConfig } from "../../config/load.js";
@@ -104,6 +105,11 @@ const HOT_APPLIERS = {
104
105
  // The sharing switches are read live at every share create, open and settings read.
105
106
  "sharing.external": () => { },
106
107
  "sharing.maxExpiryDays": () => { },
108
+ // The isolated extension host resolves its capacity on every admission and lane start.
109
+ ...Object.fromEntries(CAPACITY_HOT_PATHS.map((path) => [path, () => { }])),
110
+ // The isolation metrics read the org label bounds at every label refresh.
111
+ "metrics.orgLabelMinMembers": () => { },
112
+ "metrics.orgLabelMaxOrgs": () => { },
107
113
  };
108
114
  /**
109
115
  * The hot fields the permission configuration publication covers: a change to any of them is
@@ -136,6 +142,18 @@ let KernelConfigService = class KernelConfigService {
136
142
  this.env = input.env ?? process.env;
137
143
  log.setLevel(input.config.log.level);
138
144
  log.addSecrets(secretValues(KernelConfigSchema, input.config));
145
+ this.warnFallbacks();
146
+ }
147
+ /**
148
+ * Fields whose invalid value fell back (capacity to its preset, `metrics.*` to its default) and
149
+ * unknown capacity keys that were dropped while the config was parsed: never fatal, never
150
+ * silent. Logged at startup and after each reload that produced any.
151
+ */
152
+ warnFallbacks() {
153
+ const keys = takeConfigFallbacks();
154
+ if (keys.length > 0) {
155
+ this.log.warn("invalid config values fell back to their preset or default", { keys });
156
+ }
139
157
  }
140
158
  get() {
141
159
  return this.current;
@@ -173,6 +191,9 @@ let KernelConfigService = class KernelConfigService {
173
191
  log.error("config reload rejected; keeping current config", { error: errMsg(e) });
174
192
  return;
175
193
  }
194
+ finally {
195
+ this.warnFallbacks();
196
+ }
176
197
  log.addSecrets(secretValues(KernelConfigSchema, next));
177
198
  const changed = changedPaths(KernelConfigSchema, this.current, next);
178
199
  if (changed.length === 0)
@@ -163,6 +163,19 @@ export declare const OUTBOX_JOBS: {
163
163
  readonly removeOnFail: true;
164
164
  };
165
165
  };
166
+ readonly "git-fetch-audit": {
167
+ readonly queue: "cap-kernel-maintenance";
168
+ readonly idempotent: "Writes the run's git.fetch rows only when it has none yet, then drops its counters; a repeat finds rows or no counters";
169
+ readonly processedIn: "packages/kernel/src/runtime/maintenance.ts";
170
+ readonly opts: {
171
+ readonly attempts: 5;
172
+ readonly backoff: {
173
+ readonly type: "exponential";
174
+ readonly delay: 5000;
175
+ };
176
+ readonly removeOnComplete: true;
177
+ };
178
+ };
166
179
  readonly "permission-approval-recheck": {
167
180
  readonly queue: "cap-kernel-maintenance";
168
181
  readonly idempotent: "Reads the current revision and resumes only waiting runs without another pending wait; queued runs are unchanged.";
@@ -134,6 +134,14 @@ export const OUTBOX_JOBS = {
134
134
  removeOnFail: true,
135
135
  },
136
136
  },
137
+ // `git/run-end.ts` GIT_FETCH_AUDIT_JOB: owed by a run's terminal transaction when the run counted
138
+ // git fetches (`RunFinish`), under `gitFetchAuditJobId`
139
+ "git-fetch-audit": {
140
+ queue: "cap-kernel-maintenance",
141
+ idempotent: "Writes the run's git.fetch rows only when it has none yet, then drops its counters; a repeat finds rows or no counters",
142
+ processedIn: "packages/kernel/src/runtime/maintenance.ts",
143
+ opts: { attempts: 5, backoff: { type: "exponential", delay: 5000 }, removeOnComplete: true },
144
+ },
137
145
  "permission-approval-recheck": {
138
146
  queue: "cap-kernel-maintenance",
139
147
  idempotent: "Reads the current revision and resumes only waiting runs without another pending wait; queued runs are unchanged.",
@@ -15,8 +15,11 @@ import { type ExtensionDbIdentity } from "../db/extension-db.js";
15
15
  import { ExtensionBlobs } from "../extensions/blobs.js";
16
16
  import { BootstrapService } from "../extensions/bootstrap.js";
17
17
  import { BootstrapDefaultsService } from "../extensions/bootstrap-defaults.js";
18
+ import { BootstrapReviewService } from "../extensions/bootstrap-review.js";
18
19
  import { ExtensionHost } from "../extensions/host.js";
19
20
  import { ExtensionInstalls } from "../extensions/installs.js";
21
+ import { ReplicaIsolationStore } from "../extensions/isolated/status.js";
22
+ import { type ReviewedGrants } from "../extensions/isolated/tier.js";
20
23
  import { ExtensionLifecycle } from "../extensions/lifecycle.js";
21
24
  import { ExtensionRegistry } from "../extensions/registry.js";
22
25
  import { ExtensionRevocations } from "../extensions/revocation.js";
@@ -88,6 +91,7 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
88
91
  private readonly replicaStatus;
89
92
  private readonly bootstrap;
90
93
  private readonly bootstrapDefaults;
94
+ private readonly bootstrapReview;
91
95
  private readonly marketplaces;
92
96
  private readonly pluginImport;
93
97
  private readonly pluginUpdater;
@@ -101,6 +105,15 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
101
105
  private readonly presence;
102
106
  private readonly worker?;
103
107
  private readonly gateway?;
108
+ /**
109
+ * The human-reviewed grant of an exact revision (`ExtensionRevisionApprovals`, plan task 1.3a):
110
+ * admits a proofless official revision under pin-only (#1368) and places an extra-manifest
111
+ * pin under its reviewed full-access grant (#1371). Absent where the extension state module is
112
+ * not loaded, which keeps the pin-only refusal and leaves an extra pin isolated.
113
+ */
114
+ private readonly reviewedGrants?;
115
+ /** This replica's isolation row, removed on a clean stop (plan task 1.4j). */
116
+ private readonly isolationStatus?;
104
117
  /** The startup config (hot fields are read through the config service). */
105
118
  private readonly config;
106
119
  /** Set when the application was never set up completely: shutdown only releases connections. */
@@ -117,7 +130,18 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
117
130
  private bootstrapPackages;
118
131
  /** The merged bootstrap manifest, read once per start. */
119
132
  private mergedManifest;
120
- constructor(permissionConfig: PermissionConfigPublication, accounts: AccountsService, configService: KernelConfigService, log: KernelLogger, options: KernelAppOptions, pool: Kysely<any>, redis: Redis, kdb: KernelDb, shutdown: GracefulShutdown, host: ExtensionHost, extensionDbIdentity: ExtensionDbIdentity, registry: ExtensionRegistry, installs: ExtensionInstalls, blobs: ExtensionBlobs, extensionLifecycle: ExtensionLifecycle, revocations: ExtensionRevocations, replicaStatus: ReplicaStatusStore, bootstrap: BootstrapService, bootstrapDefaults: BootstrapDefaultsService, marketplaces: MarketplacesService, pluginImport: PluginImport, pluginUpdater: PlatformPluginUpdater, platformComponents: PlatformComponents, bus: Pick<ExtensionContext["bus"], "publish" | "subscribe">, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelJobs: ChannelJobs, channelOutbound: ChannelOutbound, presence: ReplicaPresence, worker?: WorkerRole | undefined, gateway?: GatewayRole | undefined);
133
+ constructor(permissionConfig: PermissionConfigPublication, accounts: AccountsService, configService: KernelConfigService, log: KernelLogger, options: KernelAppOptions, pool: Kysely<any>, redis: Redis, kdb: KernelDb, shutdown: GracefulShutdown, host: ExtensionHost, extensionDbIdentity: ExtensionDbIdentity, registry: ExtensionRegistry, installs: ExtensionInstalls, blobs: ExtensionBlobs, extensionLifecycle: ExtensionLifecycle, revocations: ExtensionRevocations, replicaStatus: ReplicaStatusStore, bootstrap: BootstrapService, bootstrapDefaults: BootstrapDefaultsService, bootstrapReview: BootstrapReviewService, marketplaces: MarketplacesService, pluginImport: PluginImport, pluginUpdater: PlatformPluginUpdater, platformComponents: PlatformComponents, bus: Pick<ExtensionContext["bus"], "publish" | "subscribe">, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelJobs: ChannelJobs, channelOutbound: ChannelOutbound, presence: ReplicaPresence, worker?: WorkerRole | undefined, gateway?: GatewayRole | undefined,
134
+ /**
135
+ * The human-reviewed grant of an exact revision (`ExtensionRevisionApprovals`, plan task 1.3a):
136
+ * admits a proofless official revision under pin-only (#1368) and places an extra-manifest
137
+ * pin under its reviewed full-access grant (#1371). Absent where the extension state module is
138
+ * not loaded, which keeps the pin-only refusal and leaves an extra pin isolated.
139
+ */
140
+ reviewedGrants?: ReviewedGrants | undefined,
141
+ /** This replica's isolation row, removed on a clean stop (plan task 1.4j). */
142
+ isolationStatus?: Pick<ReplicaIsolationStore, "remove"> | undefined);
143
+ /** Pin-only admission of proofless official revisions, once the reviewed-grant lookup exists. */
144
+ private pinOnlyAdmission;
121
145
  /** The kernel HTTP application (set up by `buildKernelApp` before `init()`). */
122
146
  get http(): KernelHttpApp;
123
147
  attachHttp(http: KernelHttpApp): void;
@@ -14,6 +14,7 @@ import { MarketplacesService } from "../catalog/marketplaces.service.js";
14
14
  import { PlatformComponents } from "../catalog/platform-components.js";
15
15
  import { PluginImport } from "../catalog/plugin-import.js";
16
16
  import { PlatformPluginUpdater } from "../catalog/plugin-upgrade.js";
17
+ import { officialPublisherProofMode } from "../catalog/publisher-policy.js";
17
18
  import { ChannelJobs } from "../channels/jobs.js";
18
19
  import { ChannelOutbound } from "../channels/outbound.js";
19
20
  import { PromptSuggestionQueue } from "../conversations/prompt-suggestions.js";
@@ -23,9 +24,11 @@ import { ExtensionBlobs } from "../extensions/blobs.js";
23
24
  import { BootstrapFailedError, BootstrapService, } from "../extensions/bootstrap.js";
24
25
  import { BootstrapDefaultsService } from "../extensions/bootstrap-defaults.js";
25
26
  import { BootstrapExtraMismatchError, hasExtraManifestTraces, loadBootstrapManifest, missingExtraManifestMessage, syncExtraMarketplaces, } from "../extensions/bootstrap-extra.js";
27
+ import { BootstrapReviewService } from "../extensions/bootstrap-review.js";
26
28
  import { ExtensionHost } from "../extensions/host.js";
27
29
  import { ExtensionInstalls } from "../extensions/installs.js";
28
- import { installedExtensionTier } from "../extensions/isolated/tier.js";
30
+ import { ReplicaIsolationStore } from "../extensions/isolated/status.js";
31
+ import { installedExtensionTier, REVIEWED_GRANTS, } from "../extensions/isolated/tier.js";
29
32
  import { ExtensionLifecycle } from "../extensions/lifecycle.js";
30
33
  import { ensureMigrated } from "../extensions/migrate-lock.js";
31
34
  import { ExtensionRegistry } from "../extensions/registry.js";
@@ -111,6 +114,7 @@ let KernelLifecycle = class KernelLifecycle {
111
114
  replicaStatus;
112
115
  bootstrap;
113
116
  bootstrapDefaults;
117
+ bootstrapReview;
114
118
  marketplaces;
115
119
  pluginImport;
116
120
  pluginUpdater;
@@ -124,6 +128,8 @@ let KernelLifecycle = class KernelLifecycle {
124
128
  presence;
125
129
  worker;
126
130
  gateway;
131
+ reviewedGrants;
132
+ isolationStatus;
127
133
  /** The startup config (hot fields are read through the config service). */
128
134
  config;
129
135
  /** Set when the application was never set up completely: shutdown only releases connections. */
@@ -142,14 +148,23 @@ let KernelLifecycle = class KernelLifecycle {
142
148
  mergedManifest;
143
149
  constructor(permissionConfig, accounts, configService, log, options,
144
150
  // biome-ignore lint/suspicious/noExplicitAny: the pool carries no schema types
145
- pool, redis, kdb, shutdown, host, extensionDbIdentity, registry, installs, blobs, extensionLifecycle, revocations, replicaStatus, bootstrap, bootstrapDefaults, marketplaces, pluginImport, pluginUpdater, platformComponents, bus,
151
+ pool, redis, kdb, shutdown, host, extensionDbIdentity, registry, installs, blobs, extensionLifecycle, revocations, replicaStatus, bootstrap, bootstrapDefaults, bootstrapReview, marketplaces, pluginImport, pluginUpdater, platformComponents, bus,
146
152
  // the producers closed on every role (their consumers are the worker role's)
147
153
  usageReport, titles, suggestions, channelJobs, channelOutbound,
148
154
  // this process's presence beat, on every role (admin overview spec §5.1)
149
155
  presence,
150
156
  // The role modules' parts: a role module is imported only when `roles` names it, so each is
151
157
  // present exactly when its role is (checked at the start)
152
- worker, gateway) {
158
+ worker, gateway,
159
+ /**
160
+ * The human-reviewed grant of an exact revision (`ExtensionRevisionApprovals`, plan task 1.3a):
161
+ * admits a proofless official revision under pin-only (#1368) and places an extra-manifest
162
+ * pin under its reviewed full-access grant (#1371). Absent where the extension state module is
163
+ * not loaded, which keeps the pin-only refusal and leaves an extra pin isolated.
164
+ */
165
+ reviewedGrants,
166
+ /** This replica's isolation row, removed on a clean stop (plan task 1.4j). */
167
+ isolationStatus) {
153
168
  this.permissionConfig = permissionConfig;
154
169
  this.accounts = accounts;
155
170
  this.configService = configService;
@@ -169,6 +184,7 @@ let KernelLifecycle = class KernelLifecycle {
169
184
  this.replicaStatus = replicaStatus;
170
185
  this.bootstrap = bootstrap;
171
186
  this.bootstrapDefaults = bootstrapDefaults;
187
+ this.bootstrapReview = bootstrapReview;
172
188
  this.marketplaces = marketplaces;
173
189
  this.pluginImport = pluginImport;
174
190
  this.pluginUpdater = pluginUpdater;
@@ -182,8 +198,20 @@ let KernelLifecycle = class KernelLifecycle {
182
198
  this.presence = presence;
183
199
  this.worker = worker;
184
200
  this.gateway = gateway;
201
+ this.reviewedGrants = reviewedGrants;
202
+ this.isolationStatus = isolationStatus;
185
203
  this.config = configService.get();
186
204
  }
205
+ /** Pin-only admission of proofless official revisions, once the reviewed-grant lookup exists. */
206
+ pinOnlyAdmission() {
207
+ const grants = this.reviewedGrants;
208
+ if (!grants)
209
+ return undefined;
210
+ return {
211
+ mode: () => officialPublisherProofMode(this.kdb.db),
212
+ reviewedGrant: (revision) => grants.reviewedGrant(revision),
213
+ };
214
+ }
187
215
  /** The kernel HTTP application (set up by `buildKernelApp` before `init()`). */
188
216
  get http() {
189
217
  if (!this.httpApp)
@@ -299,7 +327,10 @@ let KernelLifecycle = class KernelLifecycle {
299
327
  config: config.extensions,
300
328
  installs: {
301
329
  desired: () => this.installs.desired(),
302
- tier: (d, verifyBytes) => installedExtensionTier(d, () => this.manifest(), this.blobs, verifyBytes),
330
+ tier: (d, verifyBytes) => installedExtensionTier(d, () => this.manifest(), this.blobs, verifyBytes, this.pinOnlyAdmission(),
331
+ // #1371: the extra pin's own grant, from the same reviewed-grant lookup as pin-only
332
+ // admission (extraPinTier still rechecks a live human-made grant covering the server)
333
+ this.reviewedGrants),
303
334
  sync: (d) => syncPackage(cfg().extensionHost.dir, d.name, d.sha256, this.blobs, {
304
335
  maxBytes: cfg().packages.maxBytes,
305
336
  }),
@@ -353,6 +384,22 @@ let KernelLifecycle = class KernelLifecycle {
353
384
  await this.extensionLifecycle.reconcile("bootstrap");
354
385
  this.checkpoint();
355
386
  }
387
+ // The bootstrap review's start gate (shadow mode until plan task 1.5a): a matching
388
+ // `bootstrap.approvedReviews` preseed and `autoApprove` grant the batch; a missing required
389
+ // approval is logged with the batch hash and the command, and never refuses the start
390
+ const reviewed = await this.bootstrapReview.atStart({
391
+ manifest: opts.bootstrap !== undefined && !mismatch ? await this.manifest() : undefined,
392
+ dir: opts.bootstrap?.dir,
393
+ declared: !opts[KERNEL_FIXTURE_TRUST],
394
+ resolveFrom: opts.resolveFrom,
395
+ });
396
+ this.checkpoint();
397
+ if (reviewed !== undefined && reviewed.granted > 0) {
398
+ // Grants made now (a preseed, autoApprove) reach admission in this start: an extra-manifest
399
+ // pin's tier reads them (#1371)
400
+ await this.extensionLifecycle.reconcile("bootstrap-review");
401
+ this.checkpoint();
402
+ }
356
403
  // The extra manifest's defaults (the platform default theme), at every start whether or not
357
404
  // the step ran in it (compose's `init` usually ran it): its themes exist only once the second
358
405
  // pass imported them. A no-op once applied or once a super admin chose; never fails the start
@@ -575,6 +622,9 @@ let KernelLifecycle = class KernelLifecycle {
575
622
  await within("plugins", this.host.close(), STOP_BUDGET_MS.plugins);
576
623
  // 删掉本副本的加载状态行(尽力而为;崩溃副本心跳过期的行由 reconcile 清理)
577
624
  await within("plugin-status", this.replicaStatus.removeAll(), 1_000);
625
+ if (this.isolationStatus) {
626
+ await within("isolation-status", this.isolationStatus.remove(this.replicaStatus.replicaId), 1_000);
627
+ }
578
628
  }
579
629
  };
580
630
  KernelLifecycle = __decorate([
@@ -598,20 +648,25 @@ KernelLifecycle = __decorate([
598
648
  __param(16, Inject(ReplicaStatusStore)),
599
649
  __param(17, Inject(BootstrapService)),
600
650
  __param(18, Inject(BootstrapDefaultsService)),
601
- __param(19, Inject(MarketplacesService)),
602
- __param(20, Inject(PluginImport)),
603
- __param(21, Inject(PlatformPluginUpdater)),
604
- __param(22, Inject(PlatformComponents)),
605
- __param(23, Inject(KERNEL_BUS)),
606
- __param(24, Inject(UsageReporter)),
607
- __param(25, Inject(TitleQueue)),
608
- __param(26, Inject(PromptSuggestionQueue)),
609
- __param(27, Inject(ChannelJobs)),
610
- __param(28, Inject(ChannelOutbound)),
611
- __param(29, Inject(ReplicaPresence)),
612
- __param(30, Optional()),
613
- __param(30, Inject(WorkerRole)),
651
+ __param(19, Inject(BootstrapReviewService)),
652
+ __param(20, Inject(MarketplacesService)),
653
+ __param(21, Inject(PluginImport)),
654
+ __param(22, Inject(PlatformPluginUpdater)),
655
+ __param(23, Inject(PlatformComponents)),
656
+ __param(24, Inject(KERNEL_BUS)),
657
+ __param(25, Inject(UsageReporter)),
658
+ __param(26, Inject(TitleQueue)),
659
+ __param(27, Inject(PromptSuggestionQueue)),
660
+ __param(28, Inject(ChannelJobs)),
661
+ __param(29, Inject(ChannelOutbound)),
662
+ __param(30, Inject(ReplicaPresence)),
614
663
  __param(31, Optional()),
615
- __param(31, Inject(GatewayRole))
664
+ __param(31, Inject(WorkerRole)),
665
+ __param(32, Optional()),
666
+ __param(32, Inject(GatewayRole)),
667
+ __param(33, Optional()),
668
+ __param(33, Inject(REVIEWED_GRANTS)),
669
+ __param(34, Optional()),
670
+ __param(34, Inject(ReplicaIsolationStore))
616
671
  ], KernelLifecycle);
617
672
  export { KernelLifecycle };