@capybara-hq/kernel 0.1.0-rc.146 → 0.1.0-rc.147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/extensions.controller.d.ts +0 -11
- package/dist/admin/extensions.controller.js +0 -28
- package/dist/admin/health.service.d.ts +25 -1
- package/dist/admin/health.service.js +50 -18
- package/dist/audit/full-access.d.ts +78 -0
- package/dist/audit/full-access.js +283 -0
- package/dist/automations/automations.service.d.ts +1 -0
- package/dist/automations/automations.service.js +3 -1
- package/dist/automations/calendar.js +3 -1
- package/dist/automations/grant-rules.d.ts +2 -1
- package/dist/automations/grant-rules.js +8 -1
- package/dist/automations/unattended.d.ts +13 -1
- package/dist/automations/unattended.js +13 -1
- package/dist/catalog/admin-catalog.controller.d.ts +8 -0
- package/dist/catalog/admin-catalog.controller.js +8 -2
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +8 -1
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-scope.service.d.ts +22 -2
- package/dist/catalog/catalog-scope.service.js +27 -3
- package/dist/catalog/catalog.service.js +19 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +8 -1
- package/dist/catalog/org-catalog.service.js +36 -3
- package/dist/catalog/platform-components.js +3 -2
- package/dist/catalog/platform-import-update.d.ts +2 -0
- package/dist/catalog/platform-import-update.js +8 -1
- package/dist/catalog/plugin-connectors.d.ts +11 -0
- package/dist/catalog/plugin-connectors.js +33 -0
- package/dist/catalog/plugin-import.d.ts +35 -15
- package/dist/catalog/plugin-import.js +110 -35
- package/dist/catalog/plugin-install.js +6 -0
- package/dist/catalog/provenance.d.ts +2 -0
- package/dist/catalog/provenance.js +5 -1
- package/dist/config/auto-approve.d.ts +16 -0
- package/dist/config/auto-approve.js +24 -0
- package/dist/config/capacity-presets.d.ts +243 -0
- package/dist/config/capacity-presets.js +195 -0
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +6 -1
- package/dist/config/load.js +15 -0
- package/dist/config/schema.d.ts +46 -9
- package/dist/config/schema.js +154 -30
- package/dist/ctx/net.d.ts +5 -1
- package/dist/ctx/net.js +62 -12
- package/dist/db/kernel-schema.d.ts +31 -0
- package/dist/db/migrator.js +0 -36
- package/dist/dial-in/routes.js +1 -1
- package/dist/erasure/org-batches.js +1 -6
- package/dist/erasure/org-catalog.js +6 -2
- package/dist/erasure/org-rules.js +1 -0
- package/dist/erasure/org-worker.js +0 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/admin-ops.d.ts +14 -1
- package/dist/extensions/admin-ops.js +30 -3
- package/dist/extensions/admin-view.d.ts +21 -1
- package/dist/extensions/admin-view.js +43 -0
- package/dist/extensions/bootstrap-packages.d.ts +5 -0
- package/dist/extensions/bootstrap-packages.js +1 -1
- package/dist/extensions/bootstrap-review.d.ts +251 -0
- package/dist/extensions/bootstrap-review.js +676 -0
- package/dist/extensions/bootstrap.d.ts +21 -1
- package/dist/extensions/bootstrap.js +72 -2
- package/dist/extensions/cli.d.ts +6 -0
- package/dist/extensions/cli.js +4 -0
- package/dist/extensions/enabled.d.ts +3 -0
- package/dist/extensions/extensions.module.js +9 -0
- package/dist/extensions/full-access-disclosure.d.ts +15 -0
- package/dist/extensions/full-access-disclosure.js +57 -0
- package/dist/extensions/grant-epoch.d.ts +5 -0
- package/dist/extensions/grant-epoch.js +9 -0
- package/dist/extensions/host.d.ts +71 -2
- package/dist/extensions/host.js +293 -27
- package/dist/extensions/installs.d.ts +18 -0
- package/dist/extensions/installs.js +28 -0
- package/dist/extensions/isolated/admission.d.ts +17 -2
- package/dist/extensions/isolated/admission.js +15 -7
- package/dist/extensions/isolated/authorization.d.ts +8 -2
- package/dist/extensions/isolated/authorization.js +11 -3
- package/dist/extensions/isolated/broker.d.ts +3 -0
- package/dist/extensions/isolated/broker.js +50 -14
- package/dist/extensions/isolated/configured-package.d.ts +5 -0
- package/dist/extensions/isolated/configured-package.js +2 -0
- package/dist/extensions/isolated/lanes.d.ts +44 -3
- package/dist/extensions/isolated/lanes.js +263 -80
- package/dist/extensions/isolated/metrics.d.ts +146 -0
- package/dist/extensions/isolated/metrics.js +304 -0
- package/dist/extensions/isolated/revision.d.ts +7 -1
- package/dist/extensions/isolated/revision.js +26 -5
- package/dist/extensions/isolated/rpc.d.ts +5 -0
- package/dist/extensions/isolated/rpc.js +7 -2
- package/dist/extensions/isolated/sandbox.d.ts +23 -0
- package/dist/extensions/isolated/sandbox.js +50 -0
- package/dist/extensions/isolated/status.d.ts +79 -0
- package/dist/extensions/isolated/status.js +216 -0
- package/dist/extensions/isolated/tier.d.ts +127 -2
- package/dist/extensions/isolated/tier.js +266 -7
- package/dist/extensions/isolated/usage.d.ts +134 -0
- package/dist/extensions/isolated/usage.js +322 -0
- package/dist/extensions/lifecycle.d.ts +42 -2
- package/dist/extensions/lifecycle.js +100 -4
- package/dist/extensions/org-config.js +11 -0
- package/dist/extensions/package.d.ts +14 -0
- package/dist/extensions/package.js +23 -0
- package/dist/extensions/permissions.controller.d.ts +35 -0
- package/dist/extensions/permissions.controller.js +98 -0
- package/dist/extensions/permissions.schemas.d.ts +288 -0
- package/dist/extensions/permissions.schemas.js +96 -0
- package/dist/extensions/permissions.service.d.ts +116 -0
- package/dist/extensions/permissions.service.js +428 -0
- package/dist/extensions/realm-retirement.d.ts +65 -0
- package/dist/extensions/realm-retirement.js +150 -0
- package/dist/extensions/revision-approvals.d.ts +58 -3
- package/dist/extensions/revision-approvals.js +135 -14
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation.js +3 -0
- package/dist/extensions/state.module.js +12 -0
- package/dist/git/run-end.d.ts +35 -7
- package/dist/git/run-end.js +87 -38
- package/dist/http/api.module.js +2 -0
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/audit.js +4 -17
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/infra/config/kernel-config.service.d.ts +6 -0
- package/dist/infra/config/kernel-config.service.js +21 -0
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +25 -1
- package/dist/lifecycle/kernel-lifecycle.js +73 -18
- package/dist/net/private-endpoint-preflight.d.ts +159 -0
- package/dist/net/private-endpoint-preflight.js +417 -0
- package/dist/net/private-endpoints.d.ts +68 -0
- package/dist/net/private-endpoints.js +164 -0
- package/dist/net/public-address.d.ts +14 -0
- package/dist/net/public-address.js +15 -1
- package/dist/net/safe-fetch.d.ts +2 -1
- package/dist/net/safe-fetch.js +10 -3
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/packages/official-publisher.d.ts +26 -1
- package/dist/packages/official-publisher.js +48 -1
- package/dist/packages/provenance.d.ts +11 -0
- package/dist/packages/provenance.js +24 -0
- package/dist/platform/exclusions.js +4 -4
- package/dist/platform/ops/automations.ops.js +1 -1
- package/dist/platform/ops/catalog-admin.ops.js +25 -4
- package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
- package/dist/platform/ops/extension-permissions.ops.js +159 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +2 -0
- package/dist/platform/route-schemas.js +2 -0
- package/dist/retention/purge-batch.js +10 -14
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -3
- package/dist/runtime/run-finish.d.ts +3 -3
- package/dist/runtime/run-finish.js +7 -3
- package/dist/sandbox/permission-availability.d.ts +17 -2
- package/dist/sandbox/permission-availability.js +22 -1
- package/dist/sandbox/permission-facts.js +7 -1
- package/dist/tools/builtins/sandbox/common.js +2 -0
- package/dist/tools/pipeline.d.ts +2 -1
- package/dist/tools/pipeline.js +7 -2
- package/package.json +4 -3
- package/src/migrations/0238_extension_usage.sql +40 -0
- package/src/migrations/0239_extension_replica_isolation.sql +28 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `extensionHost.capacity`: the isolated extension host's limits, by preset (isolation capacity
|
|
3
|
+
* spec 2026-12-04, §3 "Configuration"; plan task 1.2c).
|
|
4
|
+
*
|
|
5
|
+
* `preset` picks every default; a field set explicitly wins over its preset value. An invalid value
|
|
6
|
+
* (out of range, wrong type) falls back to the preset and never fails startup: the schema catches
|
|
7
|
+
* it per field and records the path, and the extension host logs the fallback.
|
|
8
|
+
*
|
|
9
|
+
* The `standard` preset is exactly the limits the isolated host had as constants before this
|
|
10
|
+
* change, so a deployment that sets nothing keeps today's behaviour. The `dev` and `large` values
|
|
11
|
+
* stay within today's lane model (one serving lane per role, mode and org). `large` sets the
|
|
12
|
+
* ingress total to spec §6.2's abuse bound for the `standard` lane class (5,000 frames/s and
|
|
13
|
+
* 16 MiB/s per extension per replica) and never above it. Until C2 that total is still split
|
|
14
|
+
* across the extension's lanes (stopping the split is C2 work, §6.2), so each of its 10 lanes
|
|
15
|
+
* (8 serving + 2 control) gets 500 frames/s and about 1.6 MiB/s, against about 102 frames/s and
|
|
16
|
+
* 838 KB/s at `standard`. The VM baseline of 2026-12-05 traced nearly every `overloaded` refusal
|
|
17
|
+
* to that per-lane share (`callback_budget`). The lane groups, classes and fair queuing of C2
|
|
18
|
+
* replace several of these fields and revise the presets then (spec §3, "C1 note").
|
|
19
|
+
*
|
|
20
|
+
* Per-extension and per-org overrides (`extension_capacity_overrides`, plan task 2.2e) layer on top
|
|
21
|
+
* of {@link resolveCapacity}'s result; they are not part of the deployment config.
|
|
22
|
+
*/
|
|
23
|
+
export declare const CAPACITY_PRESETS: readonly ["dev", "standard", "large"];
|
|
24
|
+
export type CapacityPreset = (typeof CAPACITY_PRESETS)[number];
|
|
25
|
+
export declare const DEFAULT_CAPACITY_PRESET: CapacityPreset;
|
|
26
|
+
export declare const CAPACITY_FIELDS: {
|
|
27
|
+
readonly servingLanes: {
|
|
28
|
+
readonly min: 1;
|
|
29
|
+
readonly max: 64;
|
|
30
|
+
readonly hot: true;
|
|
31
|
+
readonly description: "Serving lanes (sandboxed processes) each isolated extension may run per replica; a lane serves one role, mode and org";
|
|
32
|
+
readonly presets: {
|
|
33
|
+
readonly dev: 2;
|
|
34
|
+
readonly standard: 4;
|
|
35
|
+
readonly large: 8;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly callsPerLane: {
|
|
39
|
+
readonly min: 1;
|
|
40
|
+
readonly max: 256;
|
|
41
|
+
readonly hot: true;
|
|
42
|
+
readonly description: "Concurrent calls one serving lane admits; the extension's calls per replica are capped at servingLanes x callsPerLane";
|
|
43
|
+
readonly presets: {
|
|
44
|
+
readonly dev: 8;
|
|
45
|
+
readonly standard: 8;
|
|
46
|
+
readonly large: 16;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly maxQueued: {
|
|
50
|
+
readonly min: 1;
|
|
51
|
+
readonly max: 65536;
|
|
52
|
+
readonly hot: true;
|
|
53
|
+
readonly description: "Calls of one isolated extension that may wait for a lane per replica; beyond it a call is rejected as overloaded";
|
|
54
|
+
readonly presets: {
|
|
55
|
+
readonly dev: 32;
|
|
56
|
+
readonly standard: 32;
|
|
57
|
+
readonly large: 128;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
readonly maxQueuedPerLane: {
|
|
61
|
+
readonly min: 1;
|
|
62
|
+
readonly max: 4096;
|
|
63
|
+
readonly hot: true;
|
|
64
|
+
readonly description: "Calls that may wait for one lane key (role, mode and org) of an extension per replica";
|
|
65
|
+
readonly presets: {
|
|
66
|
+
readonly dev: 4;
|
|
67
|
+
readonly standard: 4;
|
|
68
|
+
readonly large: 8;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
readonly maxQueueWaitMs: {
|
|
72
|
+
readonly min: 100;
|
|
73
|
+
readonly max: 120000;
|
|
74
|
+
readonly hot: true;
|
|
75
|
+
readonly description: "Milliseconds a call waits for a serving lane before it is rejected as overloaded (also the lane initialize timeout)";
|
|
76
|
+
readonly presets: {
|
|
77
|
+
readonly dev: 15000;
|
|
78
|
+
readonly standard: 15000;
|
|
79
|
+
readonly large: 15000;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
readonly preflightsPerOrg: {
|
|
83
|
+
readonly min: 1;
|
|
84
|
+
readonly max: 1024;
|
|
85
|
+
readonly hot: true;
|
|
86
|
+
readonly description: "Calls of one org (or deployment role) that may resolve config and check their grant at once per extension and replica";
|
|
87
|
+
readonly presets: {
|
|
88
|
+
readonly dev: 8;
|
|
89
|
+
readonly standard: 8;
|
|
90
|
+
readonly large: 16;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
readonly controlLanes: {
|
|
94
|
+
readonly min: 1;
|
|
95
|
+
readonly max: 16;
|
|
96
|
+
readonly hot: true;
|
|
97
|
+
readonly description: "Control lanes (registration and setup checks) each isolated extension may run at once per replica";
|
|
98
|
+
readonly presets: {
|
|
99
|
+
readonly dev: 1;
|
|
100
|
+
readonly standard: 1;
|
|
101
|
+
readonly large: 2;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
readonly controlWaiters: {
|
|
105
|
+
readonly min: 1;
|
|
106
|
+
readonly max: 1024;
|
|
107
|
+
readonly hot: true;
|
|
108
|
+
readonly description: "Registrations and setup checks that may wait for a control lane per extension";
|
|
109
|
+
readonly presets: {
|
|
110
|
+
readonly dev: 4;
|
|
111
|
+
readonly standard: 4;
|
|
112
|
+
readonly large: 8;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
readonly controlWaitMs: {
|
|
116
|
+
readonly min: 100;
|
|
117
|
+
readonly max: 60000;
|
|
118
|
+
readonly hot: true;
|
|
119
|
+
readonly description: "Milliseconds a registration or setup check waits for a control lane before it is rejected";
|
|
120
|
+
readonly presets: {
|
|
121
|
+
readonly dev: 2000;
|
|
122
|
+
readonly standard: 2000;
|
|
123
|
+
readonly large: 2000;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
readonly startsPerSecond: {
|
|
127
|
+
readonly min: 1;
|
|
128
|
+
readonly max: 1000;
|
|
129
|
+
readonly hot: true;
|
|
130
|
+
readonly description: "Serving lane starts per second per extension and replica";
|
|
131
|
+
readonly presets: {
|
|
132
|
+
readonly dev: 4;
|
|
133
|
+
readonly standard: 4;
|
|
134
|
+
readonly large: 8;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
readonly controlStartsPerSecond: {
|
|
138
|
+
readonly min: 1;
|
|
139
|
+
readonly max: 1000;
|
|
140
|
+
readonly hot: true;
|
|
141
|
+
readonly description: "Control lane starts per second per extension and replica";
|
|
142
|
+
readonly presets: {
|
|
143
|
+
readonly dev: 2;
|
|
144
|
+
readonly standard: 2;
|
|
145
|
+
readonly large: 4;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
readonly ingressFramesPerSecond: {
|
|
149
|
+
readonly min: 16;
|
|
150
|
+
readonly max: 10000000;
|
|
151
|
+
readonly hot: true;
|
|
152
|
+
readonly description: "RPC frames per second an extension's lanes may send to the kernel per replica, split evenly across servingLanes + controlLanes; a new lane takes its share";
|
|
153
|
+
readonly presets: {
|
|
154
|
+
readonly dev: 512;
|
|
155
|
+
readonly standard: 512;
|
|
156
|
+
readonly large: 5000;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
readonly ingressBytesPerSecond: {
|
|
160
|
+
readonly min: 65536;
|
|
161
|
+
readonly max: 1073741824;
|
|
162
|
+
readonly hot: true;
|
|
163
|
+
readonly description: "RPC bytes per second an extension's lanes may send to the kernel per replica, split like ingressFramesPerSecond";
|
|
164
|
+
readonly presets: {
|
|
165
|
+
readonly dev: number;
|
|
166
|
+
readonly standard: number;
|
|
167
|
+
readonly large: number;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
readonly idleReapMs: {
|
|
171
|
+
readonly min: 1000;
|
|
172
|
+
readonly max: 3600000;
|
|
173
|
+
readonly hot: true;
|
|
174
|
+
readonly description: "Milliseconds a serving lane stays up without calls before it is stopped";
|
|
175
|
+
readonly presets: {
|
|
176
|
+
readonly dev: 30000;
|
|
177
|
+
readonly standard: 60000;
|
|
178
|
+
readonly large: 60000;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
readonly grantEpochMaxAgeMs: {
|
|
182
|
+
readonly min: 1500;
|
|
183
|
+
readonly max: 3500;
|
|
184
|
+
readonly hot: false;
|
|
185
|
+
readonly 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";
|
|
186
|
+
readonly presets: {
|
|
187
|
+
readonly dev: 3000;
|
|
188
|
+
readonly standard: 3000;
|
|
189
|
+
readonly large: 3000;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
readonly grantCacheEntries: {
|
|
193
|
+
readonly min: 1;
|
|
194
|
+
readonly max: 10000000;
|
|
195
|
+
readonly hot: false;
|
|
196
|
+
readonly 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";
|
|
197
|
+
readonly presets: {
|
|
198
|
+
readonly dev: 1000;
|
|
199
|
+
readonly standard: 10000;
|
|
200
|
+
readonly large: 50000;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
readonly grantFullRevalidationMs: {
|
|
204
|
+
readonly min: 10000;
|
|
205
|
+
readonly max: 86400000;
|
|
206
|
+
readonly hot: false;
|
|
207
|
+
readonly description: "Milliseconds after which a cached grant confirmed at the current grant epoch is checked against PostgreSQL again anyway (a backstop, not the revocation path)";
|
|
208
|
+
readonly presets: {
|
|
209
|
+
readonly dev: 300000;
|
|
210
|
+
readonly standard: 300000;
|
|
211
|
+
readonly large: 300000;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
export type CapacityField = keyof typeof CAPACITY_FIELDS;
|
|
216
|
+
export declare const CAPACITY_FIELD_NAMES: CapacityField[];
|
|
217
|
+
/** The resolved limits: every field has a value. */
|
|
218
|
+
export type IsolatedCapacity = {
|
|
219
|
+
readonly preset: CapacityPreset;
|
|
220
|
+
} & {
|
|
221
|
+
readonly [K in CapacityField]: number;
|
|
222
|
+
};
|
|
223
|
+
/** The parsed config object: fields left out (or invalid) are undefined. */
|
|
224
|
+
export type CapacityConfig = {
|
|
225
|
+
preset?: CapacityPreset | undefined;
|
|
226
|
+
} & {
|
|
227
|
+
[K in CapacityField]?: number | undefined;
|
|
228
|
+
};
|
|
229
|
+
/** The config docs description of a field, with its preset values. */
|
|
230
|
+
export declare function capacityDescription(field: CapacityField): string;
|
|
231
|
+
/** Whether a value is valid for a field: an integer within its range. */
|
|
232
|
+
export declare function validCapacityValue(field: CapacityField, value: unknown): value is number;
|
|
233
|
+
/**
|
|
234
|
+
* The effective limits: each field explicitly set (and valid) wins, the rest come from the preset.
|
|
235
|
+
* An unknown or missing preset is `standard`.
|
|
236
|
+
*/
|
|
237
|
+
export declare function resolveCapacity(config: CapacityConfig | undefined): IsolatedCapacity;
|
|
238
|
+
/** The standard preset, for code built without a config (tests, embedders). */
|
|
239
|
+
export declare const STANDARD_CAPACITY: IsolatedCapacity;
|
|
240
|
+
/** The dotted config paths of the hot capacity fields. */
|
|
241
|
+
export declare const CAPACITY_HOT_PATHS: readonly string[];
|
|
242
|
+
export declare function noteConfigFallback(path: string): void;
|
|
243
|
+
export declare function takeConfigFallbacks(): string[];
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `extensionHost.capacity`: the isolated extension host's limits, by preset (isolation capacity
|
|
3
|
+
* spec 2026-12-04, §3 "Configuration"; plan task 1.2c).
|
|
4
|
+
*
|
|
5
|
+
* `preset` picks every default; a field set explicitly wins over its preset value. An invalid value
|
|
6
|
+
* (out of range, wrong type) falls back to the preset and never fails startup: the schema catches
|
|
7
|
+
* it per field and records the path, and the extension host logs the fallback.
|
|
8
|
+
*
|
|
9
|
+
* The `standard` preset is exactly the limits the isolated host had as constants before this
|
|
10
|
+
* change, so a deployment that sets nothing keeps today's behaviour. The `dev` and `large` values
|
|
11
|
+
* stay within today's lane model (one serving lane per role, mode and org). `large` sets the
|
|
12
|
+
* ingress total to spec §6.2's abuse bound for the `standard` lane class (5,000 frames/s and
|
|
13
|
+
* 16 MiB/s per extension per replica) and never above it. Until C2 that total is still split
|
|
14
|
+
* across the extension's lanes (stopping the split is C2 work, §6.2), so each of its 10 lanes
|
|
15
|
+
* (8 serving + 2 control) gets 500 frames/s and about 1.6 MiB/s, against about 102 frames/s and
|
|
16
|
+
* 838 KB/s at `standard`. The VM baseline of 2026-12-05 traced nearly every `overloaded` refusal
|
|
17
|
+
* to that per-lane share (`callback_budget`). The lane groups, classes and fair queuing of C2
|
|
18
|
+
* replace several of these fields and revise the presets then (spec §3, "C1 note").
|
|
19
|
+
*
|
|
20
|
+
* Per-extension and per-org overrides (`extension_capacity_overrides`, plan task 2.2e) layer on top
|
|
21
|
+
* of {@link resolveCapacity}'s result; they are not part of the deployment config.
|
|
22
|
+
*/
|
|
23
|
+
export const CAPACITY_PRESETS = ["dev", "standard", "large"];
|
|
24
|
+
export const DEFAULT_CAPACITY_PRESET = "standard";
|
|
25
|
+
const MIB = 1024 * 1024;
|
|
26
|
+
export const CAPACITY_FIELDS = {
|
|
27
|
+
servingLanes: {
|
|
28
|
+
min: 1,
|
|
29
|
+
max: 64,
|
|
30
|
+
hot: true,
|
|
31
|
+
description: "Serving lanes (sandboxed processes) each isolated extension may run per replica; a lane serves one role, mode and org",
|
|
32
|
+
presets: { dev: 2, standard: 4, large: 8 },
|
|
33
|
+
},
|
|
34
|
+
callsPerLane: {
|
|
35
|
+
min: 1,
|
|
36
|
+
max: 256,
|
|
37
|
+
hot: true,
|
|
38
|
+
description: "Concurrent calls one serving lane admits; the extension's calls per replica are capped at servingLanes x callsPerLane",
|
|
39
|
+
presets: { dev: 8, standard: 8, large: 16 },
|
|
40
|
+
},
|
|
41
|
+
maxQueued: {
|
|
42
|
+
min: 1,
|
|
43
|
+
max: 65_536,
|
|
44
|
+
hot: true,
|
|
45
|
+
description: "Calls of one isolated extension that may wait for a lane per replica; beyond it a call is rejected as overloaded",
|
|
46
|
+
presets: { dev: 32, standard: 32, large: 128 },
|
|
47
|
+
},
|
|
48
|
+
maxQueuedPerLane: {
|
|
49
|
+
min: 1,
|
|
50
|
+
max: 4_096,
|
|
51
|
+
hot: true,
|
|
52
|
+
description: "Calls that may wait for one lane key (role, mode and org) of an extension per replica",
|
|
53
|
+
presets: { dev: 4, standard: 4, large: 8 },
|
|
54
|
+
},
|
|
55
|
+
maxQueueWaitMs: {
|
|
56
|
+
min: 100,
|
|
57
|
+
max: 120_000,
|
|
58
|
+
hot: true,
|
|
59
|
+
description: "Milliseconds a call waits for a serving lane before it is rejected as overloaded (also the lane initialize timeout)",
|
|
60
|
+
presets: { dev: 15_000, standard: 15_000, large: 15_000 },
|
|
61
|
+
},
|
|
62
|
+
preflightsPerOrg: {
|
|
63
|
+
min: 1,
|
|
64
|
+
max: 1_024,
|
|
65
|
+
hot: true,
|
|
66
|
+
description: "Calls of one org (or deployment role) that may resolve config and check their grant at once per extension and replica",
|
|
67
|
+
presets: { dev: 8, standard: 8, large: 16 },
|
|
68
|
+
},
|
|
69
|
+
controlLanes: {
|
|
70
|
+
min: 1,
|
|
71
|
+
max: 16,
|
|
72
|
+
hot: true,
|
|
73
|
+
description: "Control lanes (registration and setup checks) each isolated extension may run at once per replica",
|
|
74
|
+
presets: { dev: 1, standard: 1, large: 2 },
|
|
75
|
+
},
|
|
76
|
+
controlWaiters: {
|
|
77
|
+
min: 1,
|
|
78
|
+
max: 1_024,
|
|
79
|
+
hot: true,
|
|
80
|
+
description: "Registrations and setup checks that may wait for a control lane per extension",
|
|
81
|
+
presets: { dev: 4, standard: 4, large: 8 },
|
|
82
|
+
},
|
|
83
|
+
controlWaitMs: {
|
|
84
|
+
min: 100,
|
|
85
|
+
max: 60_000,
|
|
86
|
+
hot: true,
|
|
87
|
+
description: "Milliseconds a registration or setup check waits for a control lane before it is rejected",
|
|
88
|
+
presets: { dev: 2_000, standard: 2_000, large: 2_000 },
|
|
89
|
+
},
|
|
90
|
+
startsPerSecond: {
|
|
91
|
+
min: 1,
|
|
92
|
+
max: 1_000,
|
|
93
|
+
hot: true,
|
|
94
|
+
description: "Serving lane starts per second per extension and replica",
|
|
95
|
+
presets: { dev: 4, standard: 4, large: 8 },
|
|
96
|
+
},
|
|
97
|
+
controlStartsPerSecond: {
|
|
98
|
+
min: 1,
|
|
99
|
+
max: 1_000,
|
|
100
|
+
hot: true,
|
|
101
|
+
description: "Control lane starts per second per extension and replica",
|
|
102
|
+
presets: { dev: 2, standard: 2, large: 4 },
|
|
103
|
+
},
|
|
104
|
+
ingressFramesPerSecond: {
|
|
105
|
+
min: 16,
|
|
106
|
+
max: 10_000_000,
|
|
107
|
+
hot: true,
|
|
108
|
+
description: "RPC frames per second an extension's lanes may send to the kernel per replica, split evenly across servingLanes + controlLanes; a new lane takes its share",
|
|
109
|
+
presets: { dev: 512, standard: 512, large: 5_000 },
|
|
110
|
+
},
|
|
111
|
+
ingressBytesPerSecond: {
|
|
112
|
+
min: 65_536,
|
|
113
|
+
max: 1_073_741_824,
|
|
114
|
+
hot: true,
|
|
115
|
+
description: "RPC bytes per second an extension's lanes may send to the kernel per replica, split like ingressFramesPerSecond",
|
|
116
|
+
presets: { dev: 4 * MIB, standard: 4 * MIB, large: 16 * MIB },
|
|
117
|
+
},
|
|
118
|
+
idleReapMs: {
|
|
119
|
+
min: 1_000,
|
|
120
|
+
max: 3_600_000,
|
|
121
|
+
hot: true,
|
|
122
|
+
description: "Milliseconds a serving lane stays up without calls before it is stopped",
|
|
123
|
+
presets: { dev: 30_000, standard: 60_000, large: 60_000 },
|
|
124
|
+
},
|
|
125
|
+
grantEpochMaxAgeMs: {
|
|
126
|
+
min: 1_500,
|
|
127
|
+
max: 3_500,
|
|
128
|
+
hot: false,
|
|
129
|
+
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",
|
|
130
|
+
presets: { dev: 3_000, standard: 3_000, large: 3_000 },
|
|
131
|
+
},
|
|
132
|
+
grantCacheEntries: {
|
|
133
|
+
min: 1,
|
|
134
|
+
max: 10_000_000,
|
|
135
|
+
hot: false,
|
|
136
|
+
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",
|
|
137
|
+
presets: { dev: 1_000, standard: 10_000, large: 50_000 },
|
|
138
|
+
},
|
|
139
|
+
grantFullRevalidationMs: {
|
|
140
|
+
min: 10_000,
|
|
141
|
+
max: 86_400_000,
|
|
142
|
+
hot: false,
|
|
143
|
+
description: "Milliseconds after which a cached grant confirmed at the current grant epoch is checked against PostgreSQL again anyway (a backstop, not the revocation path)",
|
|
144
|
+
presets: { dev: 300_000, standard: 300_000, large: 300_000 },
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
export const CAPACITY_FIELD_NAMES = Object.keys(CAPACITY_FIELDS);
|
|
148
|
+
/** The config docs description of a field, with its preset values. */
|
|
149
|
+
export function capacityDescription(field) {
|
|
150
|
+
const spec = CAPACITY_FIELDS[field];
|
|
151
|
+
const values = CAPACITY_PRESETS.map((preset) => `${preset} ${spec.presets[preset]}`).join(", ");
|
|
152
|
+
return `${spec.description}. Default from extensionHost.capacity.preset (${values}); an explicit value wins, an invalid one falls back to the preset${spec.hot ? "; applies to new admissions and lane starts without a restart" : ""}`;
|
|
153
|
+
}
|
|
154
|
+
/** Whether a value is valid for a field: an integer within its range. */
|
|
155
|
+
export function validCapacityValue(field, value) {
|
|
156
|
+
const spec = CAPACITY_FIELDS[field];
|
|
157
|
+
return Number.isInteger(value) && value >= spec.min && value <= spec.max;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The effective limits: each field explicitly set (and valid) wins, the rest come from the preset.
|
|
161
|
+
* An unknown or missing preset is `standard`.
|
|
162
|
+
*/
|
|
163
|
+
export function resolveCapacity(config) {
|
|
164
|
+
const preset = config?.preset !== undefined && CAPACITY_PRESETS.includes(config.preset)
|
|
165
|
+
? config.preset
|
|
166
|
+
: DEFAULT_CAPACITY_PRESET;
|
|
167
|
+
const resolved = { preset };
|
|
168
|
+
for (const field of CAPACITY_FIELD_NAMES) {
|
|
169
|
+
const value = config?.[field];
|
|
170
|
+
resolved[field] = validCapacityValue(field, value)
|
|
171
|
+
? value
|
|
172
|
+
: CAPACITY_FIELDS[field].presets[preset];
|
|
173
|
+
}
|
|
174
|
+
return resolved;
|
|
175
|
+
}
|
|
176
|
+
/** The standard preset, for code built without a config (tests, embedders). */
|
|
177
|
+
export const STANDARD_CAPACITY = resolveCapacity(undefined);
|
|
178
|
+
/** The dotted config paths of the hot capacity fields. */
|
|
179
|
+
export const CAPACITY_HOT_PATHS = CAPACITY_FIELD_NAMES.filter((field) => CAPACITY_FIELDS[field].hot).map((field) => `extensionHost.capacity.${field}`);
|
|
180
|
+
/**
|
|
181
|
+
* Config paths whose invalid value fell back (to the preset, or to the field's default) since the
|
|
182
|
+
* last {@link takeConfigFallbacks}, and unknown keys that were dropped. Written while the config is
|
|
183
|
+
* parsed (startup and every hot reload) and drained by `KernelConfigService`, which logs them as
|
|
184
|
+
* warnings. A diagnostic only: losing it changes no limit.
|
|
185
|
+
*/
|
|
186
|
+
const fallbacks = new Set();
|
|
187
|
+
export function noteConfigFallback(path) {
|
|
188
|
+
if (fallbacks.size < 64)
|
|
189
|
+
fallbacks.add(path);
|
|
190
|
+
}
|
|
191
|
+
export function takeConfigFallbacks() {
|
|
192
|
+
const taken = [...fallbacks];
|
|
193
|
+
fallbacks.clear();
|
|
194
|
+
return taken;
|
|
195
|
+
}
|
package/dist/config/env.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 把 `CAPYBARA_A__B_C=x` 形式的环境变量转成嵌套对象 `{ a: { bC: x } }`。
|
|
3
|
-
* Under `extensionConfig` the second segment is the extension name, converted snake -> kebab
|
|
3
|
+
* Under `extensionConfig` the second segment is the extension name, converted snake -> kebab;
|
|
4
|
+
* under `net.privateEndpoints` the third segment is the alias, converted the same way.
|
|
4
5
|
* 同时存在 `CAPYBARA_X`(标量)与 `CAPYBARA_X__Y`(嵌套)时抛 ConfigError。
|
|
5
6
|
*/
|
|
6
7
|
export declare function envOverrides(env: NodeJS.ProcessEnv): Record<string, unknown>;
|
package/dist/config/env.js
CHANGED
|
@@ -45,11 +45,16 @@ function toPath(key) {
|
|
|
45
45
|
const path = segs.map(snakeToCamel);
|
|
46
46
|
if (path[0] === "extensionConfig" && segs.length > 1)
|
|
47
47
|
path[1] = snakeToKebab(segs[1]);
|
|
48
|
+
// a net.privateEndpoints alias is lower-case kebab like an extension name: OBJECT_STORE -> object-store
|
|
49
|
+
if (path[0] === "net" && path[1] === "privateEndpoints" && segs.length > 2) {
|
|
50
|
+
path[2] = snakeToKebab(segs[2]);
|
|
51
|
+
}
|
|
48
52
|
return path;
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* 把 `CAPYBARA_A__B_C=x` 形式的环境变量转成嵌套对象 `{ a: { bC: x } }`。
|
|
52
|
-
* Under `extensionConfig` the second segment is the extension name, converted snake -> kebab
|
|
56
|
+
* Under `extensionConfig` the second segment is the extension name, converted snake -> kebab;
|
|
57
|
+
* under `net.privateEndpoints` the third segment is the alias, converted the same way.
|
|
53
58
|
* 同时存在 `CAPYBARA_X`(标量)与 `CAPYBARA_X__Y`(嵌套)时抛 ConfigError。
|
|
54
59
|
*/
|
|
55
60
|
export function envOverrides(env) {
|
package/dist/config/load.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { webhookBaseUrlProblem } from "../channels/webhook-url.js";
|
|
2
|
+
import { privateEndpointEngineProblem } from "../net/private-endpoints.js";
|
|
3
|
+
import { autoApproveRefusal, isOfficialImage } from "./auto-approve.js";
|
|
2
4
|
import { envOverrides } from "./env.js";
|
|
3
5
|
import { fileSource } from "./file-source.js";
|
|
4
6
|
import { createNacosSource } from "./nacos-source.js";
|
|
@@ -122,6 +124,19 @@ export function resolveConfig(raw, env, previous) {
|
|
|
122
124
|
if (webhookProblem !== null) {
|
|
123
125
|
throw new ConfigError(`invalid configuration:\n - channels.webhookBaseUrl: ${webhookProblem}`);
|
|
124
126
|
}
|
|
127
|
+
const engineProblem = privateEndpointEngineProblem(result.data);
|
|
128
|
+
if (engineProblem !== null)
|
|
129
|
+
throw new ConfigError(`invalid configuration:\n - ${engineProblem}`);
|
|
130
|
+
// Outside production only: an official image or NODE_ENV=production refuses the setting
|
|
131
|
+
if (result.data.extensionPermissions.autoApprove) {
|
|
132
|
+
const refused = autoApproveRefusal({
|
|
133
|
+
nodeEnv: env.NODE_ENV ?? process.env.NODE_ENV,
|
|
134
|
+
officialImage: isOfficialImage(),
|
|
135
|
+
});
|
|
136
|
+
if (refused !== undefined) {
|
|
137
|
+
throw new ConfigError(`invalid configuration:\n - extensionPermissions.autoApprove: ${refused}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
125
140
|
return result.data;
|
|
126
141
|
}
|
|
127
142
|
/** 选来源 → 深合并环境变量覆盖(优先级最高)→ 校验。 */
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -10,12 +10,9 @@ export interface FieldMeta {
|
|
|
10
10
|
* 构造给 Zod 4 `.meta()` 使用的字段元信息。
|
|
11
11
|
* 用法:`z.string().meta(meta({ secret: true, description: "..." }))`。
|
|
12
12
|
*/
|
|
13
|
-
/** Defaults of `extensionHost.capacity`, also used where a hand-built config leaves it out. */
|
|
14
|
-
export declare const EXTENSION_CAPACITY_DEFAULTS: {
|
|
15
|
-
readonly grantEpochMaxAgeMs: 3000;
|
|
16
|
-
readonly grantCacheEntries: 10000;
|
|
17
|
-
};
|
|
18
13
|
export declare function meta(opts: FieldMeta): FieldMeta;
|
|
14
|
+
/** A bootstrap batch review hash (`extensions/bootstrap-review.ts`): `bootstrap:v1:<sha256 hex>`. */
|
|
15
|
+
export declare const BOOTSTRAP_REVIEW_HASH_RE: RegExp;
|
|
19
16
|
/** `sandbox.limits.maxCommandSeconds` 的默认值。 */
|
|
20
17
|
export declare const DEFAULT_MAX_COMMAND_SECONDS = 7200;
|
|
21
18
|
/** access token 寿命上限(秒);会话吊销标记的 TTL 按它计算,与实例当前配置无关。 */
|
|
@@ -107,16 +104,40 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
107
104
|
socketDir: z.ZodString;
|
|
108
105
|
postgresSocket: z.ZodString;
|
|
109
106
|
}, z.core.$strict>>;
|
|
110
|
-
capacity: z.ZodPrefault<z.ZodObject<{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
capacity: z.ZodPrefault<z.ZodCatch<z.ZodObject<{
|
|
108
|
+
preset: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
|
|
109
|
+
dev: "dev";
|
|
110
|
+
large: "large";
|
|
111
|
+
standard: "standard";
|
|
112
|
+
}>>>;
|
|
113
|
+
callsPerLane: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
114
|
+
controlLanes: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
115
|
+
controlStartsPerSecond: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
116
|
+
controlWaitMs: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
117
|
+
controlWaiters: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
118
|
+
grantCacheEntries: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
119
|
+
grantEpochMaxAgeMs: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
120
|
+
grantFullRevalidationMs: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
121
|
+
idleReapMs: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
122
|
+
ingressBytesPerSecond: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
123
|
+
ingressFramesPerSecond: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
124
|
+
maxQueueWaitMs: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
125
|
+
maxQueued: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
126
|
+
maxQueuedPerLane: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
127
|
+
preflightsPerOrg: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
128
|
+
servingLanes: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
129
|
+
startsPerSecond: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
130
|
+
}, z.core.$strict>>>;
|
|
114
131
|
drainSeconds: z.ZodDefault<z.ZodNumber>;
|
|
115
132
|
disposeTimeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
116
133
|
reloadSetupTimeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
117
134
|
migrationTimeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
118
135
|
reconcileIntervalSeconds: z.ZodDefault<z.ZodNumber>;
|
|
119
136
|
}, z.core.$strict>>;
|
|
137
|
+
metrics: z.ZodPrefault<z.ZodObject<{
|
|
138
|
+
orgLabelMinMembers: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
|
|
139
|
+
orgLabelMaxOrgs: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
|
|
140
|
+
}, z.core.$strict>>;
|
|
120
141
|
packages: z.ZodPrefault<z.ZodObject<{
|
|
121
142
|
npmRegistry: z.ZodDefault<z.ZodURL>;
|
|
122
143
|
npmToken: z.ZodOptional<z.ZodString>;
|
|
@@ -125,6 +146,7 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
125
146
|
bootstrap: z.ZodPrefault<z.ZodObject<{
|
|
126
147
|
dir: z.ZodDefault<z.ZodString>;
|
|
127
148
|
extraManifest: z.ZodOptional<z.ZodString>;
|
|
149
|
+
approvedReviews: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
128
150
|
}, z.core.$strict>>;
|
|
129
151
|
catalog: z.ZodPrefault<z.ZodObject<{
|
|
130
152
|
staleInstallMinutes: z.ZodDefault<z.ZodNumber>;
|
|
@@ -146,6 +168,21 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
146
168
|
allowPrivateHosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
147
169
|
httpsProxy: z.ZodOptional<z.ZodString>;
|
|
148
170
|
noProxy: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
171
|
+
privateEndpoints: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
172
|
+
origin: z.ZodString;
|
|
173
|
+
pathPrefix: z.ZodDefault<z.ZodString>;
|
|
174
|
+
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
175
|
+
DELETE: "DELETE";
|
|
176
|
+
GET: "GET";
|
|
177
|
+
HEAD: "HEAD";
|
|
178
|
+
OPTIONS: "OPTIONS";
|
|
179
|
+
PATCH: "PATCH";
|
|
180
|
+
POST: "POST";
|
|
181
|
+
PUT: "PUT";
|
|
182
|
+
}>>>;
|
|
183
|
+
plugins: z.ZodArray<z.ZodString>;
|
|
184
|
+
allowLoopback: z.ZodDefault<z.ZodBoolean>;
|
|
185
|
+
}, z.core.$strict>>>;
|
|
149
186
|
}, z.core.$strict>>;
|
|
150
187
|
extensionPermissions: z.ZodDefault<z.ZodObject<{
|
|
151
188
|
autoApprove: z.ZodDefault<z.ZodBoolean>;
|