@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
@@ -3,20 +3,67 @@ import { CATALOG_ITEM_NAME_RE, DOCUMENT_MEDIA_TYPES, EXTENSION_NAME_RE, IMAGE_ME
3
3
  import { z } from "zod";
4
4
  import { AllowedProfilesSchema } from "../conversations/permission-profiles.schemas.js";
5
5
  import { LOG_FORMATS, LOG_LEVELS } from "../log.js";
6
+ import { PRIVATE_ENDPOINT_ALIAS_RE, PRIVATE_ENDPOINT_METHODS, privateEndpointOriginProblem, privateEndpointPathPrefixProblem, } from "../net/private-endpoints.js";
6
7
  import { noProxyEntryProblem, proxyUrlProblem } from "../net/proxy.js";
7
- import { privateHostEntryProblem } from "../net/public-address.js";
8
+ import { isLoopbackAddress, isLoopbackHost, normalizeHost, privateHostEntryProblem, } from "../net/public-address.js";
9
+ import { autoApproveRefusal, isOfficialImage } from "./auto-approve.js";
10
+ import { CAPACITY_FIELD_NAMES, CAPACITY_FIELDS, CAPACITY_PRESETS, capacityDescription, DEFAULT_CAPACITY_PRESET, noteConfigFallback, } from "./capacity-presets.js";
8
11
  /**
9
12
  * 构造给 Zod 4 `.meta()` 使用的字段元信息。
10
13
  * 用法:`z.string().meta(meta({ secret: true, description: "..." }))`。
11
14
  */
12
- /** Defaults of `extensionHost.capacity`, also used where a hand-built config leaves it out. */
13
- export const EXTENSION_CAPACITY_DEFAULTS = {
14
- grantEpochMaxAgeMs: 3000,
15
- grantCacheEntries: 10_000,
16
- };
17
15
  export function meta(opts) {
18
16
  return { ...opts };
19
17
  }
18
+ /**
19
+ * `extensionHost.capacity` (platform-only: kernel config is never org-overridable). Every field is
20
+ * optional: unset means the preset's value (`resolveCapacity`). An invalid value never fails
21
+ * startup or a hot reload: it is caught per field, noted for the config service's warning and
22
+ * resolved from the preset. An unknown key is dropped with a warning and the valid explicit fields
23
+ * stay; only a section that is not an object at all falls back whole.
24
+ */
25
+ const capacityShape = {
26
+ preset: z
27
+ .enum(CAPACITY_PRESETS)
28
+ .optional()
29
+ .catch(() => {
30
+ noteConfigFallback("extensionHost.capacity.preset");
31
+ return undefined;
32
+ })
33
+ .meta(meta({
34
+ description: `Capacity preset that sets every default under extensionHost.capacity: dev (laptops and CI), standard (up to 10k members; exactly the isolated host's limits before presets existed) or large (10k to 100k members). Unset or invalid means ${DEFAULT_CAPACITY_PRESET}; a field set explicitly wins over its preset value. Changing it needs a restart`,
35
+ })),
36
+ ...Object.fromEntries(CAPACITY_FIELD_NAMES.map((field) => [
37
+ field,
38
+ z
39
+ .number()
40
+ .int()
41
+ .min(CAPACITY_FIELDS[field].min)
42
+ .max(CAPACITY_FIELDS[field].max)
43
+ .optional()
44
+ .catch(() => {
45
+ noteConfigFallback(`extensionHost.capacity.${field}`);
46
+ return undefined;
47
+ })
48
+ .meta(meta({ hot: CAPACITY_FIELDS[field].hot, description: capacityDescription(field) })),
49
+ ])),
50
+ };
51
+ const capacityLenient = z.object(capacityShape);
52
+ const capacitySchema = z
53
+ .strictObject(capacityShape)
54
+ .catch((ctx) => {
55
+ const input = ctx.value;
56
+ if (typeof input !== "object" || input === null || Array.isArray(input)) {
57
+ noteConfigFallback("extensionHost.capacity");
58
+ return {};
59
+ }
60
+ for (const key of Object.keys(input)) {
61
+ if (!Object.hasOwn(capacityShape, key))
62
+ noteConfigFallback(`extensionHost.capacity.${key}`);
63
+ }
64
+ return capacityLenient.parse(input);
65
+ })
66
+ .prefault({});
20
67
  /** 校验 base64 主密钥解码后恰为 32 字节。 */
21
68
  function isValidMasterKey(value) {
22
69
  if (!/^[A-Za-z0-9+/]+={0,2}$/.test(value))
@@ -25,6 +72,8 @@ function isValidMasterKey(value) {
25
72
  }
26
73
  /** Schemes an app redirect URI never uses: the consent page navigates to it. */
27
74
  const UNSAFE_REDIRECT_RE = /^\s*(?:javascript|data|vbscript|file):/i;
75
+ /** A bootstrap batch review hash (`extensions/bootstrap-review.ts`): `bootstrap:v1:<sha256 hex>`. */
76
+ export const BOOTSTRAP_REVIEW_HASH_RE = /^bootstrap:v1:[0-9a-f]{64}$/;
28
77
  /** `sandbox.limits.maxCommandSeconds` 的默认值。 */
29
78
  export const DEFAULT_MAX_COMMAND_SECONDS = 7200;
30
79
  /** access token 寿命上限(秒);会话吊销标记的 TTL 按它计算,与实例当前配置无关。 */
@@ -511,27 +560,7 @@ export const KernelConfigSchema = z.strictObject({
511
560
  })),
512
561
  })
513
562
  .optional(),
514
- capacity: z
515
- .strictObject({
516
- grantEpochMaxAgeMs: z
517
- .number()
518
- .int()
519
- .min(1500)
520
- .max(3500)
521
- .default(EXTENSION_CAPACITY_DEFAULTS.grantEpochMaxAgeMs)
522
- .meta(meta({
523
- description: "Milliseconds a replica trusts its cached isolated extension grants after its last successful read of the grant epoch (read every second); when the epoch is older, new isolated calls wait for a fresh read and are refused if it fails. Kept below the 4 s fence deadline, which leaves 1 s of slack under the 5 s revocation bound",
524
- })),
525
- grantCacheEntries: z
526
- .number()
527
- .int()
528
- .positive()
529
- .default(EXTENSION_CAPACITY_DEFAULTS.grantCacheEntries)
530
- .meta(meta({
531
- description: "Maximum isolated extension grants (one per running extension instance and org) each replica caches; the least recently used idle grant is evicted first, and a call is refused when every cached grant is in use",
532
- })),
533
- })
534
- .prefault({}),
563
+ capacity: capacitySchema,
535
564
  drainSeconds: z
536
565
  .number()
537
566
  .int()
@@ -574,6 +603,37 @@ export const KernelConfigSchema = z.strictObject({
574
603
  })),
575
604
  })
576
605
  .prefault({}),
606
+ metrics: z
607
+ .strictObject({
608
+ orgLabelMinMembers: z
609
+ .number()
610
+ .int()
611
+ .positive()
612
+ .default(1000)
613
+ .catch(() => {
614
+ noteConfigFallback("metrics.orgLabelMinMembers");
615
+ return 1000;
616
+ })
617
+ .meta(meta({
618
+ hot: true,
619
+ description: 'Members an org needs before kernel metrics that carry an org label (the isolated extension host\'s) name it; smaller orgs report as org="other". Read at the next label refresh (every 5 minutes per replica)',
620
+ })),
621
+ orgLabelMaxOrgs: z
622
+ .number()
623
+ .int()
624
+ .min(0)
625
+ .max(200)
626
+ .default(20)
627
+ .catch(() => {
628
+ noteConfigFallback("metrics.orgLabelMaxOrgs");
629
+ return 20;
630
+ })
631
+ .meta(meta({
632
+ hot: true,
633
+ description: 'At most this many orgs, the largest by member count among those at or above orgLabelMinMembers, get their own org label; every other org reports as org="other", which bounds the label set at orgLabelMaxOrgs + 2 values (with "other" and "none" for deployment work). 0 labels no org',
634
+ })),
635
+ })
636
+ .prefault({}),
577
637
  packages: z
578
638
  .strictObject({
579
639
  npmRegistry: z
@@ -614,6 +674,15 @@ export const KernelConfigSchema = z.strictObject({
614
674
  .meta(meta({
615
675
  description: "Path of a bootstrap-extra.v1 manifest, resolved against the working directory like bootstrap.dir, that is merged with the built-in bootstrap manifest (extra plugins and marketplaces for a distribution). Absent by default",
616
676
  })),
677
+ approvedReviews: z
678
+ .array(z.string().regex(BOOTSTRAP_REVIEW_HASH_RE, {
679
+ message: "a bootstrap review hash looks like bootstrap:v1:<64 lowercase hex>",
680
+ }))
681
+ .max(64)
682
+ .default([])
683
+ .meta(meta({
684
+ description: "Bootstrap review hashes the operator approves in advance (printed by `capybara bootstrap review --print-review`, published in the release notes for the shipped pins). When the review of this deployment's bootstrap pins and config-declared extensions has one of these hashes, `capybara bootstrap approve` and the kernel start grant its revisions, audited as operator (config). The hash binds this deployment's previous approvals (a live grant on another revision of a pinned plugin), so a published hash matches only deployments without one; recompute it with `capybara bootstrap review --print-review`. A hash only becomes consent once it is recorded here; a stale hash grants nothing and the start logs a warning naming the current hash",
685
+ })),
617
686
  })
618
687
  .prefault({}),
619
688
  catalog: z
@@ -717,7 +786,7 @@ export const KernelConfigSchema = z.strictObject({
717
786
  .boolean()
718
787
  .default(false)
719
788
  .meta(meta({
720
- description: "Testing only: lift every loopback and unspecified-address refusal for extensions' ctx.net.fetch (127.0.0.0/8, ::1, 0.0.0.0/8, ::), including plain http to them (fake servers in test stacks). Link-local and cloud metadata addresses stay refused. Never set it in production",
789
+ description: "Testing only: lift every loopback and unspecified-address refusal for extensions' ctx.net.fetch (127.0.0.0/8, ::1, 0.0.0.0/8, ::), including plain http to them (fake servers in test stacks). Link-local and cloud metadata addresses stay refused. It also lifts the loopback refusal for the extension isolation Engine API's port, so never set it where the Engine listens on loopback. Never set it in production",
721
790
  })),
722
791
  allowPrivateHosts: z
723
792
  .array(z.string().superRefine((entry, ctx) => {
@@ -755,7 +824,51 @@ export const KernelConfigSchema = z.strictObject({
755
824
  .max(100)
756
825
  .default([])
757
826
  .meta(meta({
758
- description: "Hostnames or IP addresses that bypass net.httpsProxy (an entry also matches its subdomains; a leading dot is allowed). These hosts are resolved locally and must resolve to public addresses unless listed in net.allowPrivateHosts (the kernel's own requests) or in an organization's allowed internal endpoints (ctx.net.fetch). List an organization's allowed internal https hosts here when net.httpsProxy is set, otherwise the proxy resolves them and the allowances do not apply",
827
+ description: "Hostnames or IP addresses that bypass net.httpsProxy (an entry also matches its subdomains; a leading dot is allowed). These hosts are resolved locally and must resolve to public addresses unless listed in net.allowPrivateHosts (the kernel's own requests) or in an organization's allowed internal endpoints (ctx.net.fetch). List an organization's allowed internal https hosts here when net.httpsProxy is set, otherwise the proxy resolves them and the allowances do not apply. net.privateEndpoints origins need no entry: alias requests always bypass the proxy",
828
+ })),
829
+ privateEndpoints: z
830
+ .record(z
831
+ .string()
832
+ .regex(PRIVATE_ENDPOINT_ALIAS_RE, "must be a lower-case alias such as llm-gateway"), z.strictObject({
833
+ origin: z.string().superRefine((value, ctx) => {
834
+ const problem = privateEndpointOriginProblem(value);
835
+ if (problem !== undefined)
836
+ ctx.addIssue({ code: "custom", message: problem });
837
+ }),
838
+ pathPrefix: z
839
+ .string()
840
+ .max(512)
841
+ .superRefine((value, ctx) => {
842
+ const problem = privateEndpointPathPrefixProblem(value);
843
+ if (problem !== undefined)
844
+ ctx.addIssue({ code: "custom", message: problem });
845
+ })
846
+ .default("/"),
847
+ methods: z.array(z.enum(PRIVATE_ENDPOINT_METHODS)).min(1).optional(),
848
+ plugins: z.array(z.string().regex(EXTENSION_NAME_RE)).min(1).max(100),
849
+ allowLoopback: z.boolean().default(false),
850
+ }))
851
+ .superRefine((endpoints, ctx) => {
852
+ for (const [alias, e] of Object.entries(endpoints)) {
853
+ if (privateEndpointOriginProblem(e.origin) !== undefined)
854
+ continue;
855
+ const host = normalizeHost(new URL(e.origin).hostname);
856
+ const loopback = isLoopbackHost(host) || (isIP(host) !== 0 && isLoopbackAddress(host));
857
+ if (loopback && !e.allowLoopback) {
858
+ ctx.addIssue({
859
+ code: "custom",
860
+ path: [alias, "origin"],
861
+ message: "a loopback origin needs allowLoopback: true",
862
+ });
863
+ }
864
+ }
865
+ if (Object.keys(endpoints).length > 50) {
866
+ ctx.addIssue({ code: "custom", message: "at most 50 private endpoints" });
867
+ }
868
+ })
869
+ .default({})
870
+ .meta(meta({
871
+ description: 'Named private destinations that extensions\' ctx.net.fetch requests made outside an organization may reach, e.g. {"llm-gateway":{"origin":"https://llm.corp.internal:8443","pathPrefix":"/v1","methods":["GET","POST"],"plugins":["anthropic","openai"]}} for a model provider pointed at an internal gateway. A request is admitted when it comes from a listed plugin (its extension name), carries no organization, and goes to exactly the origin (scheme, host and port; http allowed when the origin says http) under pathPrefix (default /; under a narrower prefix, encoded slashes or percent signs, ; parameters and encoded dot segments are refused) with one of methods (unset: any; when set, method-override headers and a _method query parameter are refused). Its host is still resolved and checked and the connection pinned to the checked addresses; link-local and cloud metadata addresses stay refused, loopback unless allowLoopback, and no alias may use the port of the extension isolation Engine API (extensionHost.isolation.engineUrl) on any host. Alias requests never use net.httpsProxy, so no net.noProxy entry is needed. Redirects are not followed. An organization\'s own URLs use its allowed internal endpoints, never an alias. Loopback, link-local, metadata and the Engine are judged on the resolved addresses at request time',
759
872
  })),
760
873
  })
761
874
  .prefault({}),
@@ -765,8 +878,19 @@ export const KernelConfigSchema = z.strictObject({
765
878
  .boolean()
766
879
  .default(false)
767
880
  .meta(meta({
768
- description: "Approve extension permissions automatically at startup (development and trials only). When false, an extension that is new or whose upgrade asks for more permissions is not loaded until an admin runs `capybara extensions approve <name>`",
881
+ description: "Approve extension permissions automatically at startup (development and trials only), including declared full access: each grant is audited with source auto and the start logs a banner naming the approved revisions and realms. Refused (the configuration does not load) in the official images and with NODE_ENV=production. When false, an extension that is new or whose upgrade asks for more permissions is not loaded until an admin approves it (`capybara extensions approve <name>`, `capybara bootstrap approve`)",
769
882
  })),
883
+ })
884
+ // Outside production only, also for a config built without resolveConfig (config/auto-approve.ts)
885
+ .superRefine((v, ctx) => {
886
+ if (!v.autoApprove)
887
+ return;
888
+ const refused = autoApproveRefusal({
889
+ nodeEnv: process.env.NODE_ENV,
890
+ officialImage: isOfficialImage(),
891
+ });
892
+ if (refused !== undefined)
893
+ ctx.addIssue({ code: "custom", path: ["autoApprove"], message: refused });
770
894
  })
771
895
  .default({ autoApprove: false }),
772
896
  http: z
package/dist/ctx/net.d.ts CHANGED
@@ -25,7 +25,7 @@ export type ExtensionNetServices = {
25
25
  /** What a refused private address tells the reader of an org-bound request. */
26
26
  export declare const ORG_PRIVATE_HINT = "ask a super admin to allow this internal endpoint for the organization";
27
27
  /** What a refused private address tells the reader of a request made outside an organization. */
28
- export declare const NO_ORG_PRIVATE_HINT = "a request made outside an organization reaches public addresses only";
28
+ export declare const NO_ORG_PRIVATE_HINT = "a request made outside an organization reaches public addresses only, or a private endpoint a super admin granted to this plugin";
29
29
  /**
30
30
  * `ctx.net` (plugin safe fetch spec): the kernel's guarded client (`safeFetch`) for URLs a person
31
31
  * supplied. Per call:
@@ -34,6 +34,10 @@ export declare const NO_ORG_PRIVATE_HINT = "a request made outside an organizati
34
34
  * replica; another org's allowances never apply), public addresses only without an org, and the
35
35
  * deployment's egress proxy (`net.httpsProxy` / `net.noProxy`: a proxied https request is
36
36
  * resolved by the proxy, which then owns SSRF protection; IP-literal targets are still checked);
37
+ * - without an org, a `net.privateEndpoints` alias granted to this plugin admits its exact origin,
38
+ * path prefix and methods (`private-endpoints.ts`): private addresses allowed, checked and pinned
39
+ * locally, never through the proxy, never the isolation Engine API; an org-bound request never
40
+ * uses an alias;
37
41
  * - loopback, link-local and cloud metadata addresses are refused whatever the allowances
38
42
  * (loopback allowed only under `net.allowInsecureLoopback`);
39
43
  * - redirects are never followed: `redirect: "manual"` returns the 3xx response, otherwise a 3xx
package/dist/ctx/net.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { NetDeniedError as SdkNetDeniedError, } from "@capybara-hq/plugin-sdk";
2
+ import { aliasConfigHint, BROKERED_ENDPOINT_PINS } from "../net/private-endpoint-preflight.js";
3
+ import { aliasNetPolicy, matchPrivateEndpoint, } from "../net/private-endpoints.js";
2
4
  import { NetDeniedError } from "../net/public-address.js";
3
5
  import { safeFetch } from "../net/safe-fetch.js";
4
6
  /**
@@ -10,7 +12,19 @@ export const EXTENSION_NET_SEAMS = Symbol("EXTENSION_NET_SEAMS");
10
12
  /** What a refused private address tells the reader of an org-bound request. */
11
13
  export const ORG_PRIVATE_HINT = "ask a super admin to allow this internal endpoint for the organization";
12
14
  /** What a refused private address tells the reader of a request made outside an organization. */
13
- export const NO_ORG_PRIVATE_HINT = "a request made outside an organization reaches public addresses only";
15
+ export const NO_ORG_PRIVATE_HINT = "a request made outside an organization reaches public addresses only, or a private endpoint a super admin granted to this plugin";
16
+ /** The refusal hint of a request made outside an organization: the alias config that would admit it. */
17
+ function noOrgPrivateHint(url, plugin) {
18
+ let origin;
19
+ try {
20
+ origin = new URL(url).origin;
21
+ }
22
+ catch {
23
+ return NO_ORG_PRIVATE_HINT;
24
+ }
25
+ const alias = BROKERED_ENDPOINT_PINS.find((p) => p.plugin === plugin)?.alias ?? plugin;
26
+ return `${NO_ORG_PRIVATE_HINT}. ${aliasConfigHint(alias, origin, plugin)}`;
27
+ }
14
28
  /**
15
29
  * `ctx.net` (plugin safe fetch spec): the kernel's guarded client (`safeFetch`) for URLs a person
16
30
  * supplied. Per call:
@@ -19,6 +33,10 @@ export const NO_ORG_PRIVATE_HINT = "a request made outside an organization reach
19
33
  * replica; another org's allowances never apply), public addresses only without an org, and the
20
34
  * deployment's egress proxy (`net.httpsProxy` / `net.noProxy`: a proxied https request is
21
35
  * resolved by the proxy, which then owns SSRF protection; IP-literal targets are still checked);
36
+ * - without an org, a `net.privateEndpoints` alias granted to this plugin admits its exact origin,
37
+ * path prefix and methods (`private-endpoints.ts`): private addresses allowed, checked and pinned
38
+ * locally, never through the proxy, never the isolation Engine API; an org-bound request never
39
+ * uses an alias;
22
40
  * - loopback, link-local and cloud metadata addresses are refused whatever the allowances
23
41
  * (loopback allowed only under `net.allowInsecureLoopback`);
24
42
  * - redirects are never followed: `redirect: "manual"` returns the 3xx response, otherwise a 3xx
@@ -31,10 +49,26 @@ export function createExtensionNet(deps) {
31
49
  return {
32
50
  async fetch(url, init, opts) {
33
51
  const orgId = opts?.orgId;
34
- const net = deps.config.get().net;
52
+ const cfg = deps.config.get();
53
+ const net = cfg.net;
35
54
  const exemptions = orgId
36
55
  ? await deps.allowances.policyFor(orgId)
37
56
  : { allowPrivateHosts: [], trustedOrigins: [] };
57
+ let alias;
58
+ try {
59
+ const match = orgId === undefined
60
+ ? matchPrivateEndpoint(net.privateEndpoints ?? {}, deps.plugin, url, init?.method ?? "GET", init?.headers)
61
+ : undefined;
62
+ if (match !== undefined) {
63
+ alias = {
64
+ ...match,
65
+ ...aliasNetPolicy(match, cfg.extensionHost?.isolation?.engineUrl),
66
+ };
67
+ }
68
+ }
69
+ catch (e) {
70
+ throw refusal(e, orgId);
71
+ }
38
72
  const policy = {
39
73
  allowInsecureLoopback: net.allowInsecureLoopback,
40
74
  allowPrivateHosts: exemptions.allowPrivateHosts,
@@ -42,7 +76,18 @@ export function createExtensionNet(deps) {
42
76
  ...(net.httpsProxy !== undefined && {
43
77
  proxy: { url: net.httpsProxy, noProxy: net.noProxy },
44
78
  }),
45
- extension: { privateHint: orgId ? ORG_PRIVATE_HINT : NO_ORG_PRIVATE_HINT },
79
+ extension: orgId
80
+ ? { privateHint: ORG_PRIVATE_HINT }
81
+ : {
82
+ privateHint: noOrgPrivateHint(url, deps.plugin),
83
+ insecureHint: noOrgPrivateHint(url, deps.plugin),
84
+ },
85
+ ...(alias !== undefined && {
86
+ privateEndpoint: {
87
+ origin: alias.origin,
88
+ allowLoopback: alias.allowLoopback,
89
+ },
90
+ }),
46
91
  };
47
92
  const signal = init?.signal ? AbortSignal.any([deps.signal, init.signal]) : deps.signal;
48
93
  try {
@@ -52,16 +97,21 @@ export function createExtensionNet(deps) {
52
97
  });
53
98
  }
54
99
  catch (e) {
55
- if (!(e instanceof NetDeniedError))
56
- throw e;
57
- deps.log.warn("ctx.net.fetch refused a request", {
58
- plugin: deps.plugin,
59
- orgId: orgId ?? null,
60
- host: e.host,
61
- code: e.code,
62
- });
63
- throw new SdkNetDeniedError(e.code, e.host, e.message, e.status);
100
+ throw refusal(e, orgId, alias?.alias);
64
101
  }
65
102
  },
66
103
  };
104
+ /** A kernel refusal logged and turned into the SDK's error; anything else passes through. */
105
+ function refusal(e, orgId, alias) {
106
+ if (!(e instanceof NetDeniedError))
107
+ return e;
108
+ deps.log.warn("ctx.net.fetch refused a request", {
109
+ plugin: deps.plugin,
110
+ orgId: orgId ?? null,
111
+ host: e.host,
112
+ code: e.code,
113
+ ...(alias !== undefined && { privateEndpoint: alias }),
114
+ });
115
+ return new SdkNetDeniedError(e.code, e.host, e.message, e.status);
116
+ }
67
117
  }
@@ -1637,6 +1637,34 @@ export interface ExtensionGrantEpochTable {
1637
1637
  epoch: Generated<string>;
1638
1638
  changed_at: Generated<Date>;
1639
1639
  }
1640
+ /**
1641
+ * Isolated extension usage counters (migration 0238): one row per org, plugin, hour and counter,
1642
+ * incremented by each replica's 10 s flush (`extensions/isolated/usage.ts`).
1643
+ */
1644
+ export interface ExtensionUsageTable {
1645
+ org_id: string;
1646
+ plugin: string;
1647
+ hour: Ts;
1648
+ counter: string;
1649
+ /** bigint; pg returns it as a string. */
1650
+ amount: Int8;
1651
+ }
1652
+ /** The flush batches already applied (migration 0238): makes a retried batch count once. */
1653
+ export interface ExtensionUsageBatchesTable {
1654
+ id: string;
1655
+ flushed_at: Generated<Date>;
1656
+ }
1657
+ /** 0239: each replica's isolation supervisor readiness and shadow placements (plan task 1.4j). */
1658
+ export interface ExtensionReplicaIsolationTable {
1659
+ replica_id: string;
1660
+ state: "available" | "failing" | "not_configured";
1661
+ failed_check: "guard_reachability" | "engine_runtime" | "image" | "postgres_socket" | null;
1662
+ message: string | null;
1663
+ shadow: ColumnType<unknown[], string | undefined, string>;
1664
+ http_replica_id: string | null;
1665
+ probed_at: TsNullable;
1666
+ heartbeat_at: Generated<Date>;
1667
+ }
1640
1668
  export interface ExtensionReplicaStatusTable {
1641
1669
  replica_id: string;
1642
1670
  plugin: string;
@@ -2248,7 +2276,10 @@ export interface KernelDatabase {
2248
2276
  extension_revision_grants: ExtensionRevisionGrantsTable;
2249
2277
  extension_revision_grant_orgs: ExtensionRevisionGrantOrgsTable;
2250
2278
  extension_replica_status: ExtensionReplicaStatusTable;
2279
+ extension_replica_isolation: ExtensionReplicaIsolationTable;
2251
2280
  extension_grant_epoch: ExtensionGrantEpochTable;
2281
+ extension_usage: ExtensionUsageTable;
2282
+ extension_usage_batches: ExtensionUsageBatchesTable;
2252
2283
  extension_name_owners: ExtensionNameOwnersTable;
2253
2284
  extension_handoff_tables: ExtensionHandoffTablesTable;
2254
2285
  extension_admission_refusals: ExtensionAdmissionRefusalsTable;
@@ -48,37 +48,6 @@ export async function canMigrateKernel(db) {
48
48
  return privileges.can_create && (privileges.owns_schema ?? true);
49
49
  }
50
50
  const migrateHint = "Run capybara migrate with CAPYBARA_DB__MIGRATION_URL set to the schema owner URL for split roles.";
51
- const eventOrgContract = "0219_event_org_constraint_check.sql";
52
- /** The rc.159 worker is the last release that can backfill events before 0219. */
53
- async function checkEventOrgBackfill(client) {
54
- await client.query("begin read only");
55
- try {
56
- await client.query("set local row_security = off");
57
- const { rows: [table], } = await client.query(`
58
- select exists (
59
- select from pg_catalog.pg_attribute
60
- where attrelid = relation and attname = 'org_id' and attnum > 0 and not attisdropped
61
- ) as has_org_id
62
- from (select pg_catalog.to_regclass('capybara.conversation_events') as relation) events
63
- where relation is not null
64
- `);
65
- if (!table)
66
- return;
67
- // Before 0215, every existing event would receive a null org_id from the expansion.
68
- const filter = table.has_org_id ? "where org_id is null" : "";
69
- const { rows: [state], } = await client.query(`select exists (select from capybara.conversation_events ${filter}) as incomplete`);
70
- if (state?.incomplete) {
71
- throw new Error("Migration 0219 requires the conversation event organization backfill. " +
72
- "Upgrade to Capybara 0.1.0-rc.159 and run its worker after older writers have drained. " +
73
- "Wait for EventOrgBackfillJob to finish, then verify " +
74
- "SELECT count(*) FROM capybara.conversation_events WHERE org_id IS NULL returns 0 " +
75
- "before rerunning capybara migrate.");
76
- }
77
- }
78
- finally {
79
- await client.query("rollback");
80
- }
81
- }
82
51
  /** Verify the files expected by this binary without taking a migration lock or writing the journal.
83
52
  * Extra entries are valid when a newer release has already migrated a shared database.
84
53
  */
@@ -209,11 +178,6 @@ export async function migrate(connectionString, owner, opts = {}) {
209
178
  throw new Error(`Migration ${schema}/${f.name} is out of order: a higher-numbered migration (${String(highest).padStart(4, "0")}) is already applied`);
210
179
  }
211
180
  }
212
- if (schema === "capybara" &&
213
- !done.has(eventOrgContract) &&
214
- files.some((f) => f.name === eventOrgContract)) {
215
- await checkEventOrgBackfill(client);
216
- }
217
181
  const applied = [];
218
182
  for (const f of files) {
219
183
  if (done.has(f.name))
@@ -57,7 +57,7 @@ export function protocolMismatchMessage(plugin, expected, spoken) {
57
57
  : "this program speaks another protocol";
58
58
  const fix = theirs && ours && theirs.name === ours.name && theirs.major > ours.major
59
59
  ? "This deployment is older than the program; ask the platform's super admin to upgrade it, or install the program release that matches this deployment."
60
- : "Update the program on the machine to the release that speaks this protocol (for capybara-device: npm install -g @capybara-hq/device@next), then start it again.";
60
+ : "Update the program on the machine to the release that speaks this protocol (for capybara-device: npm install -g @capybara-hq/device), then start it again.";
61
61
  return `This device is served by ${plugin}, which speaks ${expected}; ${said}. ${fix}`;
62
62
  }
63
63
  /**
@@ -67,14 +67,9 @@ const globalChecks = [
67
67
  AND data->'payload'->>'orgId' = (SELECT id FROM subject))
68
68
  )`,
69
69
  },
70
- {
71
- table: "conversation_events",
72
- order: "conversation_id, seq",
73
- predicate: "org_id IS NULL AND conversation_id IN (SELECT id FROM capybara.conversations WHERE org_id = (SELECT id FROM subject))",
74
- },
75
70
  ];
76
71
  function globalBlocker(db, orgId) {
77
- // org-filter: deployment-wide read checks FK survivors, detached jobs and legacy event ownership
72
+ // org-filter: deployment-wide read checks FK survivors and detached jobs
78
73
  return asPlatform("check org erasure dependencies", () => firstRemaining(db, orgId, globalChecks));
79
74
  }
80
75
  const unsettled = [
@@ -1,10 +1,14 @@
1
1
  import { sql } from "kysely";
2
- // PostgreSQL 17 after 0237. Re-review the ownership map before updating this fingerprint.
2
+ // PostgreSQL 17 after 0239. Re-review the ownership map before updating this fingerprint.
3
3
  // 0234 adds extension_grant_epoch: deployment state with no org or account reference, so it
4
4
  // needs no erasure rule. 0235 adds extension_revision_grants (approver columns cleared by account
5
5
  // erasure, deployment scope) and extension_revision_grant_orgs (an org row rule; the org FK
6
6
  // cascades), plus the install revision columns, their grant foreign key and extension_packages.sha512.
7
7
  // 0237 adds the handoff inventory and admission refusals, both deployment metadata.
8
+ // 0238 adds extension_usage (an org row rule; the org FK cascades) and extension_usage_batches
9
+ // (deployment state: flush batch ids with no org or account reference, no erasure rule).
10
+ // 0239 adds extension_replica_isolation (deployment state: each replica's supervisor checks and
11
+ // shadow placements by plugin and version, no org or account reference, no erasure rule).
8
12
  // The fingerprint includes relation/column identities and ordered PK, UNIQUE and inbound/outbound FK
9
13
  // columns and actions, including FKs from outside the kernel schema.
10
14
  export async function orgCatalogDrift(db) {
@@ -35,5 +39,5 @@ WITH catalog AS (
35
39
  )
36
40
  SELECT md5(string_agg(entry, chr(10) ORDER BY entry COLLATE "C")) AS fingerprint FROM catalog
37
41
  `.execute(db);
38
- return rows[0]?.fingerprint === "a9f59a4747b2fa6ee329121f9a0af5b3" ? undefined : "schema-drift";
42
+ return rows[0]?.fingerprint === "d3b21b83bd3b12ee253eb2800f0731c6" ? undefined : "schema-drift";
39
43
  }
@@ -33,6 +33,7 @@ export const rowRules = [
33
33
  rule("extension_org_configs", "plugin, org_id"),
34
34
  rule("extension_org_overrides", "plugin, org_id"),
35
35
  rule("extension_revision_grant_orgs", "plugin, version, sha512, generation, org_id"),
36
+ rule("extension_usage", "org_id, plugin, hour, counter"),
36
37
  rule("file_previewers", "org_id, plugin, previewer_id"),
37
38
  rule("inbox_items", "id"),
38
39
  rule("invitations", "id"),
@@ -197,19 +197,6 @@ let OrgErasure = class OrgErasure {
197
197
  await this.requests.advance(work, "roots", null, new Date(), { ...progress, storageIdentity });
198
198
  }
199
199
  async roots(work, orgId, deletedAt) {
200
- // org-filter: deployment-wide visibility for rows predating conversation event ownership.
201
- const legacy = await asPlatform("verify org conversation ownership backfill before purging", () => this.db
202
- .selectFrom("conversation_events as e")
203
- .innerJoin("conversations as c", "c.id", "e.conversation_id")
204
- .select("e.seq")
205
- .where("c.org_id", "=", orgId)
206
- .where("e.org_id", "is", null)
207
- .limit(1)
208
- .executeTakeFirst());
209
- if (legacy) {
210
- await this.defer(work, "event-ownership-backfill");
211
- return;
212
- }
213
200
  const root = await this.db
214
201
  .selectFrom("conversations")
215
202
  .select(["id", "account_id"])
package/dist/errors.d.ts CHANGED
@@ -156,6 +156,10 @@ export declare const ERROR_CODES: {
156
156
  readonly "extension.plugin_not_installed": 409;
157
157
  readonly "extension.name_conflict": 409;
158
158
  readonly "extension.approval_stale": 409;
159
+ readonly "extension.permission_review_stale": 409;
160
+ readonly "extension.permission_review_unavailable": 409;
161
+ readonly "extension.permission_keys_unknown": 409;
162
+ readonly "extension.permission_grant_not_found": 404;
159
163
  readonly "extension.not_pending": 409;
160
164
  readonly "extension.package_unavailable": 409;
161
165
  readonly "extension.package_not_found": 404;
@@ -278,6 +282,7 @@ export declare const ERROR_CODES: {
278
282
  readonly "plugin.switch_stale": 409;
279
283
  readonly "plugin.builtin": 409;
280
284
  readonly "plugin.scope_stale": 409;
285
+ readonly "plugin.scope_widening_not_allowed": 403;
281
286
  readonly "component.not_found": 404;
282
287
  readonly "component.version_stale": 409;
283
288
  /** A platform component offered to the org but off there (one more connector from a template). */
@@ -336,6 +341,7 @@ export declare const ERROR_CODES: {
336
341
  readonly "marketplace.host_not_allowed": 403;
337
342
  readonly "marketplace.path_unsupported": 422;
338
343
  readonly "plugin.review_stale": 409;
344
+ readonly "plugin.full_access_ack_invalid": 409;
339
345
  readonly "plugin.name_taken": 409;
340
346
  readonly "plugin.name_reserved": 409;
341
347
  readonly "plugin.dependency_unavailable": 409;
package/dist/errors.js CHANGED
@@ -156,6 +156,10 @@ export const ERROR_CODES = {
156
156
  "extension.plugin_not_installed": 409,
157
157
  "extension.name_conflict": 409,
158
158
  "extension.approval_stale": 409,
159
+ "extension.permission_review_stale": 409,
160
+ "extension.permission_review_unavailable": 409,
161
+ "extension.permission_keys_unknown": 409,
162
+ "extension.permission_grant_not_found": 404,
159
163
  "extension.not_pending": 409,
160
164
  "extension.package_unavailable": 409,
161
165
  "extension.package_not_found": 404,
@@ -278,6 +282,7 @@ export const ERROR_CODES = {
278
282
  "plugin.switch_stale": 409,
279
283
  "plugin.builtin": 409,
280
284
  "plugin.scope_stale": 409,
285
+ "plugin.scope_widening_not_allowed": 403,
281
286
  "component.not_found": 404,
282
287
  "component.version_stale": 409,
283
288
  /** A platform component offered to the org but off there (one more connector from a template). */
@@ -336,6 +341,7 @@ export const ERROR_CODES = {
336
341
  "marketplace.host_not_allowed": 403,
337
342
  "marketplace.path_unsupported": 422,
338
343
  "plugin.review_stale": 409,
344
+ "plugin.full_access_ack_invalid": 409,
339
345
  "plugin.name_taken": 409,
340
346
  "plugin.name_reserved": 409,
341
347
  "plugin.dependency_unavailable": 409,
@@ -14,6 +14,7 @@ import { ExtensionLifecycle } from "./lifecycle.js";
14
14
  import { PluginInstallLock } from "./locks.js";
15
15
  import type { AdminExtensionView } from "./permission-view.js";
16
16
  import { ExtensionRegistry } from "./registry.js";
17
+ import { ExtensionRevisionApprovals } from "./revision-approvals.js";
17
18
  import { SingleProviderGuard, type SingleProviderNote } from "./single-provider.js";
18
19
  /**
19
20
  * Deployment-level extension install / enable / disable / uninstall (C16 / D15): writes only the PG
@@ -88,6 +89,8 @@ export declare class ExtensionAdminOps {
88
89
  private readonly outbox;
89
90
  /** A platform enable, disable or new version publishes `platform-caps` after the commit. */
90
91
  private readonly hints;
92
+ /** The install's approved / candidate revision (shadow mode, plan task 1.3a). */
93
+ private readonly revisions;
91
94
  constructor(kdb: KernelDb, txHost: TransactionHost,
92
95
  /** The super admin lock (identity/super-admin.ts): joins the transaction. */
93
96
  adminLock: SuperAdminLock,
@@ -116,8 +119,18 @@ export declare class ExtensionAdminOps {
116
119
  /** The plugin scope sync a deploy owes (`oweDeployedExtensionSync`). */
117
120
  outbox: Pick<OutboxService, "add" | "addMany">,
118
121
  /** A platform enable, disable or new version publishes `platform-caps` after the commit. */
119
- hints: HintPublisher);
122
+ hints: HintPublisher,
123
+ /** The install's approved / candidate revision (shadow mode, plan task 1.3a). */
124
+ revisions: Pick<ExtensionRevisionApprovals, "promoteInstalled">);
120
125
  private get db();
126
+ /**
127
+ * The install now runs `sha256`: it becomes the approved revision under its own grant, or a
128
+ * continuation, else the candidate waiting for review (shadow mode until plan task 1.5a: the
129
+ * legacy snapshot keeps governing admission). A downgrade is a rollback, served only under the
130
+ * selected revision's own grant. A package whose sha512 is not recorded yet is left to the
131
+ * backfill; the shadow decision reports it.
132
+ */
133
+ private promoteRevision;
121
134
  /**
122
135
  * New install or version change (upgrade / downgrade): the install record points at package
123
136
  * `sha256`; the desired state is unchanged (a new install is disabled). Audit `extension.installed`.