@loucompanion/forge-bridge 0.1.4-dev.f22f5e3d01fe → 0.2.1-dev.0fedbc5c9ef7
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/README.md +89 -1
- package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
- package/dist/bridge/bridge-chat-giphy-look.js +55 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +27 -3
- package/dist/bridge/bridge-chat-provider-command.js +131 -26
- package/dist/bridge/bridge-chat.types.d.ts +20 -0
- package/dist/bridge/bridge-chat.types.js +28 -1
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +11 -0
- package/dist/bridge/bridge-state-io.js +50 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.service.d.ts +19 -12
- package/dist/bridge/bridge.service.js +155 -282
- package/dist/bridge/bridge.types.d.ts +5 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.js +14 -1
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/windows-bash-resolution.d.ts +31 -0
- package/dist/bridge/windows-bash-resolution.js +153 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +11 -1
- package/dist/cleanup/cleanup.service.js +80 -62
- package/dist/cleanup/cleanup.types.d.ts +2 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +2 -0
- package/dist/cleanup/host-runtime-ledger.js +30 -9
- package/dist/cli/cli.help.js +56 -12
- package/dist/cli/cli.service.d.ts +3 -10
- package/dist/cli/cli.service.js +10 -171
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +2 -0
- package/dist/cli/local-config.js +7 -1
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +104 -26
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
- package/dist/runtime/attempt-process-supervisor.js +12 -6
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
- package/dist/runtime/dotnet-build-outputs.js +402 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-listener-inspector.d.ts +26 -0
- package/dist/runtime/host-listener-inspector.js +84 -3
- package/dist/runtime/host-load-admission.d.ts +5 -0
- package/dist/runtime/host-load-governor-config.d.ts +10 -1
- package/dist/runtime/host-load-governor-config.js +4 -1
- package/dist/runtime/host-load-governor.d.ts +10 -1
- package/dist/runtime/host-load-governor.js +33 -3
- package/dist/runtime/host-load-ledger-lock.js +6 -4
- package/dist/runtime/host-load-runtime-settings.js +4 -2
- package/dist/runtime/host-load-sampler.d.ts +8 -1
- package/dist/runtime/host-load-sampler.js +14 -7
- package/dist/runtime/host-load-test-slot.js +7 -0
- package/dist/runtime/host-runtime-contract.d.ts +12 -0
- package/dist/runtime/host-runtime-contract.js +29 -1
- package/dist/runtime/host-runtime-lease.d.ts +28 -3
- package/dist/runtime/host-runtime-lease.js +140 -296
- package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
- package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
- package/dist/runtime/host-runtime-promotion.d.ts +78 -2
- package/dist/runtime/host-runtime-promotion.js +307 -14
- package/dist/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
- package/dist/runtime/prepared-runtime-identity.js +130 -9
- package/dist/runtime/prepared-runtime-readiness.d.ts +13 -1
- package/dist/runtime/prepared-runtime-readiness.js +63 -16
- package/dist/runtime/runner-settings.d.ts +4 -0
- package/dist/runtime/runner-settings.js +22 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -0
- package/dist/sandbox/host-capacity-broker.d.ts +3 -1
- package/dist/sandbox/host-capacity-broker.js +4 -2
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +90 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.js +3 -7
- package/dist/session/managed-attempt-tools.d.ts +0 -7
- package/dist/session/managed-attempt-tools.js +50 -82
- package/dist/session/managed-build-coordinator.d.ts +16 -0
- package/dist/session/managed-build-coordinator.js +10 -0
- package/dist/session/managed-build-receipt.d.ts +5 -0
- package/dist/session/managed-build-receipt.js +8 -3
- package/dist/session/phase-completion.artifacts.js +2 -1
- package/dist/session/phase-completion.d.ts +8 -0
- package/dist/session/phase-completion.js +1 -0
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.runtime.d.ts +0 -8
- package/dist/session/phase-completion.runtime.js +43 -197
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-process.js +10 -10
- package/dist/session/pre-publication-step-execution.d.ts +2 -1
- package/dist/session/pre-publication-step-execution.js +6 -5
- package/dist/session/pre-publication-validation.d.ts +7 -3
- package/dist/session/pre-publication-validation.js +32 -30
- package/dist/session/provider-cli/claude-background-work.d.ts +3 -2
- package/dist/session/provider-cli/claude-background-work.js +4 -3
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +16 -0
- package/dist/session/provider-cli/pre-publication-repair.js +33 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +4 -2
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +28 -8
- package/dist/session/provider-cli/provider-cli.process.d.ts +2 -14
- package/dist/session/provider-cli/provider-cli.process.js +4 -94
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +27 -27
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +23 -2
- package/dist/session/provider-cli/provider-cli.service.d.ts +4 -1
- package/dist/session/provider-cli/provider-cli.service.js +27 -43
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +22 -1
- package/dist/session/sandbox-host-capacity-gate.js +35 -16
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.service.d.ts +6 -0
- package/dist/session/session.service.js +131 -88
- package/dist/session/session.types.d.ts +1 -0
- package/dist/session/session.types.js +3 -3
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +13 -1
- package/dist/shared/process/host-process-supervisor.js +66 -14
- package/dist/shared/provider-capabilities.js +9 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/orphan-relink.d.ts +19 -0
- package/dist/worktree/orphan-relink.js +106 -0
- package/dist/worktree/wip-git.d.ts +42 -0
- package/dist/worktree/wip-git.js +139 -0
- package/dist/worktree/wip-refs.d.ts +77 -0
- package/dist/worktree/wip-refs.js +146 -0
- package/dist/worktree/wip-restore.d.ts +46 -0
- package/dist/worktree/wip-restore.js +280 -0
- package/dist/worktree/wip-snapshot.d.ts +53 -0
- package/dist/worktree/wip-snapshot.js +270 -0
- package/dist/worktree/worktree-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +35 -0
- package/dist/worktree/worktree-origin-sync.js +128 -0
- package/dist/worktree/worktree-wip-events.d.ts +18 -0
- package/dist/worktree/worktree-wip-events.js +115 -0
- package/dist/worktree/worktree-wip.d.ts +51 -0
- package/dist/worktree/worktree-wip.js +190 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +27 -5
- package/dist/worktree/worktree.service.js +112 -181
- package/dist/worktree/worktree.types.d.ts +35 -0
- package/package.json +1 -1
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { redactText, shouldRedactJsonProperty } from "../shared/redaction/redaction.js";
|
|
2
|
-
import {
|
|
2
|
+
import { decodeJsonEscapesLeniently, decodeJsonStringToken, inspectJsonText, isJsonPunctuation, isJsonWhitespace, JsonShapeError, sidecarJsonShapeProblem, } from "./sidecar-json-shape.js";
|
|
3
|
+
import { ForgeFailureError } from "./session.types.js";
|
|
3
4
|
const integrityProtectedEventDataTypes = new Set(["sandbox_started"]);
|
|
4
5
|
const structuralSecretMessage = "runner result structural metadata contains protected secret material and cannot be redacted without changing protocol identity.";
|
|
5
6
|
const sidecarSecretMessage = "runner result sidecar contains protected secret material and cannot be redacted without invalidating integrity metadata.";
|
|
6
7
|
const artifactJsonMessage = "runner result artifact JSON is invalid or exceeds safe inspection limits; transport was rejected.";
|
|
7
8
|
const artifactJsonKeySecretMessage = "runner result artifact JSON property name contains protected secret material and cannot be redacted without changing protocol identity.";
|
|
8
9
|
const artifactJsonPrimitiveSecretMessage = "runner result artifact JSON primitive contains protected secret material and cannot be redacted without changing protocol identity.";
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const maximumIntegrityJsonTokens = 262_144;
|
|
10
|
+
// Stable failure code for a sidecar that starts like JSON but does not parse (see sidecar-json-shape.ts).
|
|
11
|
+
const malformedSidecarFailureCode = "runner_result_sidecar_malformed";
|
|
12
12
|
export function redactRunnerDispatchEvent(event, exactSecrets = []) {
|
|
13
13
|
assertStructuralFieldsDoNotContainSecrets([
|
|
14
14
|
event.role,
|
|
@@ -149,7 +149,7 @@ function redactArtifactJson(value, exactSecrets) {
|
|
|
149
149
|
}
|
|
150
150
|
continue;
|
|
151
151
|
}
|
|
152
|
-
const token =
|
|
152
|
+
const token = decodeArtifactJsonStringToken(value, index);
|
|
153
153
|
const afterToken = skipJsonWhitespace(value, token.nextIndex);
|
|
154
154
|
if (value.charCodeAt(afterToken) === 0x3a) {
|
|
155
155
|
assertJsonStringDoesNotContainSecrets(token.decoded, exactSecrets, artifactJsonKeySecretMessage);
|
|
@@ -159,7 +159,7 @@ function redactArtifactJson(value, exactSecrets) {
|
|
|
159
159
|
const valueStart = skipJsonWhitespace(value, afterToken + 1);
|
|
160
160
|
const valueEnd = jsonValueEnd(value, valueStart);
|
|
161
161
|
if (value[valueStart] !== '"'
|
|
162
|
-
||
|
|
162
|
+
|| decodeArtifactJsonStringToken(value, valueStart).decoded !== "[REDACTED]") {
|
|
163
163
|
replace(valueStart, valueEnd, '"[REDACTED]"');
|
|
164
164
|
}
|
|
165
165
|
index = valueEnd;
|
|
@@ -193,13 +193,13 @@ function skipJsonWhitespace(value, start) {
|
|
|
193
193
|
// value (including objects/arrays) without decoding or rewriting adjacent data.
|
|
194
194
|
function jsonValueEnd(value, start) {
|
|
195
195
|
if (value.charCodeAt(start) === 0x22) {
|
|
196
|
-
return
|
|
196
|
+
return decodeArtifactJsonStringToken(value, start).nextIndex;
|
|
197
197
|
}
|
|
198
198
|
if (value[start] === "{" || value[start] === "[") {
|
|
199
199
|
let depth = 0;
|
|
200
200
|
for (let index = start; index < value.length; index += 1) {
|
|
201
201
|
if (value[index] === '"') {
|
|
202
|
-
index =
|
|
202
|
+
index = decodeArtifactJsonStringToken(value, index).nextIndex - 1;
|
|
203
203
|
}
|
|
204
204
|
else if (value[index] === "{" || value[index] === "[") {
|
|
205
205
|
depth += 1;
|
|
@@ -248,7 +248,7 @@ function assertSidecarsDoNotContainSecrets(sidecars, exactSecrets) {
|
|
|
248
248
|
throw new Error(sidecarSecretMessage);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
|
|
251
|
+
assertSidecarJsonShape(decoded, sidecar.path, exactSecrets);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
function assertSerializedJsonDoesNotContainSecrets(value, exactSecrets, errorMessage) {
|
|
@@ -257,187 +257,37 @@ function assertSerializedJsonDoesNotContainSecrets(value, exactSecrets, errorMes
|
|
|
257
257
|
assertJsonStringDoesNotContainSecrets(value, exactSecrets, errorMessage);
|
|
258
258
|
inspectJsonStringTokens(value, exactSecrets, errorMessage);
|
|
259
259
|
}
|
|
260
|
-
function
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
decoded = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(value);
|
|
264
|
-
}
|
|
265
|
-
catch {
|
|
266
|
-
if (path.toLowerCase().endsWith(".json"))
|
|
267
|
-
throw new Error(errorMessage);
|
|
260
|
+
function assertSidecarJsonShape(content, path, exactSecrets) {
|
|
261
|
+
const problem = sidecarJsonShapeProblem(content, path, decoded => assertJsonStringDoesNotContainSecrets(decoded, exactSecrets, sidecarSecretMessage));
|
|
262
|
+
if (problem === null)
|
|
268
263
|
return;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (hasUtf8Bom)
|
|
277
|
-
throw new Error(errorMessage);
|
|
278
|
-
inspectJsonStringTokens(decoded, exactSecrets, errorMessage);
|
|
264
|
+
// A malformed file cannot be read token by token, so decode its escapes leniently first: a
|
|
265
|
+
// secret hidden behind JSON escapes keeps the secret error instead of the malformed one.
|
|
266
|
+
assertJsonStringDoesNotContainSecrets(decodeJsonEscapesLeniently(content.toString("utf8")), exactSecrets, sidecarSecretMessage);
|
|
267
|
+
// Still fail closed: the bytes cannot be redacted, so the result is rejected either way. The
|
|
268
|
+
// distinct code and message say the file is malformed, not that a secret was found.
|
|
269
|
+
throw new ForgeFailureError(malformedSidecarFailureCode, `runner result sidecar ${path} looks like JSON but is not valid JSON (${problem}); `
|
|
270
|
+
+ "Forge rejects sidecars it cannot fully inspect, so the result was not accepted.");
|
|
279
271
|
}
|
|
280
272
|
function inspectJsonStringTokens(value, exactSecrets, errorMessage) {
|
|
281
|
-
if (Buffer.byteLength(value, "utf8") > maximumIntegrityJsonBytes) {
|
|
282
|
-
throw new Error(errorMessage);
|
|
283
|
-
}
|
|
284
|
-
const containers = [];
|
|
285
|
-
let index = 0;
|
|
286
|
-
let tokenCount = 0;
|
|
287
|
-
const countToken = () => {
|
|
288
|
-
tokenCount += 1;
|
|
289
|
-
if (tokenCount > maximumIntegrityJsonTokens)
|
|
290
|
-
throw new Error(errorMessage);
|
|
291
|
-
};
|
|
292
|
-
while (index < value.length) {
|
|
293
|
-
const code = value.charCodeAt(index);
|
|
294
|
-
if (code === 0x22) {
|
|
295
|
-
countToken();
|
|
296
|
-
const token = decodeJsonStringToken(value, index, errorMessage);
|
|
297
|
-
assertJsonStringDoesNotContainSecrets(token.decoded, exactSecrets, errorMessage);
|
|
298
|
-
index = token.nextIndex;
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
if (code === 0x7b || code === 0x5b) {
|
|
302
|
-
countToken();
|
|
303
|
-
containers.push(code);
|
|
304
|
-
if (containers.length > maximumIntegrityJsonDepth)
|
|
305
|
-
throw new Error(errorMessage);
|
|
306
|
-
index += 1;
|
|
307
|
-
continue;
|
|
308
|
-
}
|
|
309
|
-
if (code === 0x7d || code === 0x5d) {
|
|
310
|
-
countToken();
|
|
311
|
-
const expected = code === 0x7d ? 0x7b : 0x5b;
|
|
312
|
-
if (containers.pop() !== expected)
|
|
313
|
-
throw new Error(errorMessage);
|
|
314
|
-
index += 1;
|
|
315
|
-
continue;
|
|
316
|
-
}
|
|
317
|
-
if (code === 0x2c || code === 0x3a) {
|
|
318
|
-
index += 1;
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
if (isJsonWhitespace(code)) {
|
|
322
|
-
index += 1;
|
|
323
|
-
continue;
|
|
324
|
-
}
|
|
325
|
-
countToken();
|
|
326
|
-
do {
|
|
327
|
-
index += 1;
|
|
328
|
-
} while (index < value.length
|
|
329
|
-
&& !isJsonWhitespace(value.charCodeAt(index))
|
|
330
|
-
&& !isJsonPunctuation(value.charCodeAt(index)));
|
|
331
|
-
}
|
|
332
|
-
if (containers.length !== 0)
|
|
333
|
-
throw new Error(errorMessage);
|
|
334
273
|
try {
|
|
335
|
-
|
|
274
|
+
inspectJsonText(value, decoded => assertJsonStringDoesNotContainSecrets(decoded, exactSecrets, errorMessage));
|
|
336
275
|
}
|
|
337
|
-
catch {
|
|
338
|
-
|
|
276
|
+
catch (error) {
|
|
277
|
+
if (error instanceof JsonShapeError)
|
|
278
|
+
throw new Error(errorMessage, { cause: error });
|
|
279
|
+
throw error;
|
|
339
280
|
}
|
|
340
281
|
}
|
|
341
|
-
function
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
let index = segmentStart;
|
|
345
|
-
while (index < value.length) {
|
|
346
|
-
const code = value.charCodeAt(index);
|
|
347
|
-
if (code === 0x22) {
|
|
348
|
-
chunks.push(value.slice(segmentStart, index));
|
|
349
|
-
const decoded = chunks.join("");
|
|
350
|
-
if (!isWellFormedUnicode(decoded))
|
|
351
|
-
throw new Error(errorMessage);
|
|
352
|
-
return { decoded, nextIndex: index + 1 };
|
|
353
|
-
}
|
|
354
|
-
if (code < 0x20)
|
|
355
|
-
throw new Error(errorMessage);
|
|
356
|
-
if (code !== 0x5c) {
|
|
357
|
-
index += 1;
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
chunks.push(value.slice(segmentStart, index));
|
|
361
|
-
index += 1;
|
|
362
|
-
if (index >= value.length)
|
|
363
|
-
throw new Error(errorMessage);
|
|
364
|
-
const escaped = value[index];
|
|
365
|
-
switch (escaped) {
|
|
366
|
-
case "\"":
|
|
367
|
-
chunks.push("\"");
|
|
368
|
-
index += 1;
|
|
369
|
-
break;
|
|
370
|
-
case "\\":
|
|
371
|
-
chunks.push("\\");
|
|
372
|
-
index += 1;
|
|
373
|
-
break;
|
|
374
|
-
case "/":
|
|
375
|
-
chunks.push("/");
|
|
376
|
-
index += 1;
|
|
377
|
-
break;
|
|
378
|
-
case "b":
|
|
379
|
-
chunks.push("\b");
|
|
380
|
-
index += 1;
|
|
381
|
-
break;
|
|
382
|
-
case "f":
|
|
383
|
-
chunks.push("\f");
|
|
384
|
-
index += 1;
|
|
385
|
-
break;
|
|
386
|
-
case "n":
|
|
387
|
-
chunks.push("\n");
|
|
388
|
-
index += 1;
|
|
389
|
-
break;
|
|
390
|
-
case "r":
|
|
391
|
-
chunks.push("\r");
|
|
392
|
-
index += 1;
|
|
393
|
-
break;
|
|
394
|
-
case "t":
|
|
395
|
-
chunks.push("\t");
|
|
396
|
-
index += 1;
|
|
397
|
-
break;
|
|
398
|
-
case "u": {
|
|
399
|
-
const hex = value.slice(index + 1, index + 5);
|
|
400
|
-
if (!/^[0-9a-fA-F]{4}$/u.test(hex))
|
|
401
|
-
throw new Error(errorMessage);
|
|
402
|
-
chunks.push(String.fromCharCode(Number.parseInt(hex, 16)));
|
|
403
|
-
index += 5;
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
default: throw new Error(errorMessage);
|
|
407
|
-
}
|
|
408
|
-
segmentStart = index;
|
|
282
|
+
function decodeArtifactJsonStringToken(value, openingQuoteIndex) {
|
|
283
|
+
try {
|
|
284
|
+
return decodeJsonStringToken(value, openingQuoteIndex);
|
|
409
285
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const code = value.charCodeAt(index);
|
|
415
|
-
if (code >= 0xd800 && code <= 0xdbff) {
|
|
416
|
-
if (index + 1 >= value.length)
|
|
417
|
-
return false;
|
|
418
|
-
const next = value.charCodeAt(index + 1);
|
|
419
|
-
if (next < 0xdc00 || next > 0xdfff)
|
|
420
|
-
return false;
|
|
421
|
-
index += 1;
|
|
422
|
-
}
|
|
423
|
-
else if (code >= 0xdc00 && code <= 0xdfff) {
|
|
424
|
-
return false;
|
|
425
|
-
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
if (error instanceof JsonShapeError)
|
|
288
|
+
throw new Error(artifactJsonMessage, { cause: error });
|
|
289
|
+
throw error;
|
|
426
290
|
}
|
|
427
|
-
return true;
|
|
428
|
-
}
|
|
429
|
-
function looksLikeJson(value, path) {
|
|
430
|
-
if (path.toLowerCase().endsWith(".json"))
|
|
431
|
-
return true;
|
|
432
|
-
const candidate = value.trimStart().replace(/^\uFEFF/u, "").trimStart();
|
|
433
|
-
return candidate.startsWith("{") || candidate.startsWith("[") || candidate.startsWith("\"");
|
|
434
|
-
}
|
|
435
|
-
function isJsonWhitespace(code) {
|
|
436
|
-
return code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0d;
|
|
437
|
-
}
|
|
438
|
-
function isJsonPunctuation(code) {
|
|
439
|
-
return code === 0x7b || code === 0x7d || code === 0x5b || code === 0x5d
|
|
440
|
-
|| code === 0x2c || code === 0x3a || code === 0x22;
|
|
441
291
|
}
|
|
442
292
|
function assertJsonStringDoesNotContainSecrets(value, exactSecrets, errorMessage) {
|
|
443
293
|
for (const secret of exactSecrets) {
|
|
@@ -20,4 +20,10 @@ export declare class BridgeSessionService implements SessionService {
|
|
|
20
20
|
runtimeCapacity(): HostRuntimeCapacitySnapshot | null;
|
|
21
21
|
probeHostRuntime(request: HostRuntimeReadinessProbeRequest, signal?: AbortSignal): Promise<HostRuntimeReadinessProbeResult>;
|
|
22
22
|
runOnce(dispatch: RunOnceDispatchPacket, sink: SessionEventSink, signal?: AbortSignal): Promise<RunOnceResultPacket>;
|
|
23
|
+
/** Launches a parallel-eligible probe's project, unless its contract is quarantined and so could never earn proof. */
|
|
24
|
+
private probeConfiguredProject;
|
|
25
|
+
/** A late isolation violation stopped the attempt's project in the background: fail rather than report success. */
|
|
26
|
+
private throwIfAbortedOrIsolationViolated;
|
|
27
|
+
/** Reports the provider's peak memory and releases the attempt's host runtime lease. */
|
|
28
|
+
private releaseHostRuntime;
|
|
23
29
|
}
|
|
@@ -2,7 +2,7 @@ import { redactRunnerDispatchEvent, redactRunOnceResultPacket } from "./session-
|
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { RoutingProviderCliService } from "./provider-cli/provider-cli.service.js";
|
|
4
4
|
import { ForgeFailureError, waitKindForEvent, waitWakeCondition } from "./session.types.js";
|
|
5
|
-
import { GitWorktreeService } from "../worktree/worktree.service.js";
|
|
5
|
+
import { emitWorktreePreparedEvents, GitWorktreeService, sessionWipOutcome, settleWorktree } from "../worktree/worktree.service.js";
|
|
6
6
|
import { SandboxWorkspaceService } from "../sandbox/workspace.service.js";
|
|
7
7
|
import { HostRuntimeAdmissionExpiredError, hostRuntimeEventResources, hostRuntimeStackEnvironmentKeys, runtimeAdmissionPriority, } from "../runtime/host-runtime-lease.js";
|
|
8
8
|
import { configuredLaunchPortNames, hostRuntimeContractFingerprint, hostRuntimeParallelEligible, } from "../runtime/host-runtime-promotion.js";
|
|
@@ -77,7 +77,7 @@ export class BridgeSessionService {
|
|
|
77
77
|
signal,
|
|
78
78
|
});
|
|
79
79
|
assertReadinessProbeStartupBudget(request.expiresAt);
|
|
80
|
-
|
|
80
|
+
const started = await this.hostRuntime.start(dispatch, worktree.worktreePath, signal);
|
|
81
81
|
runtimeStarted = true;
|
|
82
82
|
const discovery = started.runtimeContract.discovery;
|
|
83
83
|
if (!hostRuntimeParallelEligible(started.runtimeContract)) {
|
|
@@ -92,23 +92,7 @@ export class BridgeSessionService {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
|
-
|
|
96
|
-
started = await this.hostRuntime.startConfiguredProject(request.requestId, request.fencingToken, signal);
|
|
97
|
-
const requiredPorts = configuredLaunchPortNames(started.runtimeContract);
|
|
98
|
-
const verifiedPorts = started.lease.resources.ports.map(port => port.name);
|
|
99
|
-
const verified = requiredPorts.length > 0 && requiredPorts.every(name => verifiedPorts.includes(name));
|
|
100
|
-
result = verified
|
|
101
|
-
? {
|
|
102
|
-
status: "parallel_ready",
|
|
103
|
-
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
104
|
-
runtimeContractSource: started.runtimeContract.source,
|
|
105
|
-
runtimeRequirements: started.runtimeContract.contract.requires ?? null,
|
|
106
|
-
reasonCode: null,
|
|
107
|
-
reasonMessage: null,
|
|
108
|
-
qaAppLaunchTarget: managedQaLaunchTarget(started.runtimeContract),
|
|
109
|
-
checkedAt: new Date().toISOString(),
|
|
110
|
-
}
|
|
111
|
-
: failedProbe("host_runtime_probe_unverified", "The application did not prove ownership and readiness on every Forge-assigned port.");
|
|
95
|
+
result = await this.probeConfiguredProject(this.hostRuntime, request, started, signal);
|
|
112
96
|
}
|
|
113
97
|
}
|
|
114
98
|
catch (error) {
|
|
@@ -190,6 +174,7 @@ export class BridgeSessionService {
|
|
|
190
174
|
let worktree = null;
|
|
191
175
|
let hostSingletonKeys = null;
|
|
192
176
|
let hostLease = null;
|
|
177
|
+
let succeeded = false;
|
|
193
178
|
try {
|
|
194
179
|
if (dispatch.sandbox?.executionMode === "host" && this.hostRuntime) {
|
|
195
180
|
const capacity = this.hostRuntime.snapshot?.() ?? null;
|
|
@@ -265,10 +250,8 @@ export class BridgeSessionService {
|
|
|
265
250
|
warmPathOverrides: dispatch.warmPathOverrides,
|
|
266
251
|
applicationRuntimeRequired: dispatch.runtimeIntent.applicationRuntimeRequired,
|
|
267
252
|
preserveExistingState: Boolean(dispatch.session.resumedFromSessionId),
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
priority: runtimeAdmissionPriority(dispatch),
|
|
271
|
-
},
|
|
253
|
+
sessionId: dispatch.session.id,
|
|
254
|
+
...preparedAttemptOwner(dispatch),
|
|
272
255
|
signal,
|
|
273
256
|
});
|
|
274
257
|
}
|
|
@@ -285,6 +268,7 @@ export class BridgeSessionService {
|
|
|
285
268
|
: `Prepared worktree ${worktree.branchName}.`,
|
|
286
269
|
eventType: dispatch.session.resumedFromSessionId ? "worktree_reattached" : "worktree_prepared"
|
|
287
270
|
});
|
|
271
|
+
await emitWorktreePreparedEvents(worktree, emit);
|
|
288
272
|
if ((worktree.hydratedPriorPhaseArtifactCount ?? 0) > 0) {
|
|
289
273
|
await emit({
|
|
290
274
|
role: "runner",
|
|
@@ -363,6 +347,8 @@ export class BridgeSessionService {
|
|
|
363
347
|
// Set while the stack may not match the workspace: a failed restart is retried on the next pass.
|
|
364
348
|
let restartPending = false;
|
|
365
349
|
refreshRuntimeEnvironment = async (refreshSignal) => {
|
|
350
|
+
// A late violation stopped the stack: fail this validation pass rather than run it against closed ports.
|
|
351
|
+
this.throwIfAbortedOrIsolationViolated(undefined, dispatch, hostLease);
|
|
366
352
|
const current = await this.workspaceFingerprint(worktreePath).catch(() => null);
|
|
367
353
|
if (!restartPending && sameWorkspaceRuntimeFingerprint(launchFingerprint, current))
|
|
368
354
|
return null;
|
|
@@ -452,17 +438,18 @@ export class BridgeSessionService {
|
|
|
452
438
|
emit,
|
|
453
439
|
signal
|
|
454
440
|
});
|
|
455
|
-
|
|
441
|
+
this.throwIfAbortedOrIsolationViolated(signal, dispatch, hostLease);
|
|
456
442
|
const draftArtifacts = run.artifacts?.length ? run.artifacts : run.artifact ? [run.artifact] : [];
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
exitCode: 0,
|
|
460
|
-
summary: run.summary,
|
|
443
|
+
// Redaction can throw (a secret in a structural field); only a returned result is a success.
|
|
444
|
+
const draftResult = redactRunOnceResultPacket({
|
|
445
|
+
schemaVersion: 2, exitCode: 0, summary: run.summary,
|
|
461
446
|
events,
|
|
462
447
|
spec: run.spec ?? null,
|
|
463
448
|
artifact: run.artifact ?? null,
|
|
464
449
|
artifacts: draftArtifacts
|
|
465
450
|
}, redactionSecrets);
|
|
451
|
+
succeeded = true;
|
|
452
|
+
return draftResult;
|
|
466
453
|
}
|
|
467
454
|
throwIfAborted(signal);
|
|
468
455
|
const lane = dispatch.execution.lane.trim().toLowerCase();
|
|
@@ -506,12 +493,10 @@ export class BridgeSessionService {
|
|
|
506
493
|
}
|
|
507
494
|
throw error;
|
|
508
495
|
}
|
|
509
|
-
|
|
496
|
+
this.throwIfAbortedOrIsolationViolated(signal, dispatch, hostLease);
|
|
510
497
|
const phaseArtifacts = run.artifacts?.length ? run.artifacts : run.artifact ? [run.artifact] : [];
|
|
511
|
-
|
|
512
|
-
schemaVersion: 2,
|
|
513
|
-
exitCode: 0,
|
|
514
|
-
summary: run.summary,
|
|
498
|
+
const result = redactRunOnceResultPacket({
|
|
499
|
+
schemaVersion: 2, exitCode: 0, summary: run.summary,
|
|
515
500
|
resultCommitSha: run.resultCommitSha ?? null,
|
|
516
501
|
publishedCommitSha: run.publishedCommitSha ?? null,
|
|
517
502
|
events,
|
|
@@ -519,72 +504,102 @@ export class BridgeSessionService {
|
|
|
519
504
|
artifact: run.artifact ?? null,
|
|
520
505
|
artifacts: phaseArtifacts
|
|
521
506
|
}, redactionSecrets);
|
|
507
|
+
succeeded = true;
|
|
508
|
+
return result;
|
|
522
509
|
}
|
|
523
510
|
finally {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
511
|
+
await this.releaseHostRuntime(dispatch, hostLease, hostSingletonKeys, emitLifecycle);
|
|
512
|
+
if (worktree) {
|
|
513
|
+
await settleWorktree(this.worktrees, worktree, sessionWipOutcome(signal, events, succeeded), signal, emitLifecycle);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
/** Launches a parallel-eligible probe's project, unless its contract is quarantined and so could never earn proof. */
|
|
518
|
+
async probeConfiguredProject(hostRuntime, request, started, signal) {
|
|
519
|
+
if (await hostRuntime.promotionQuarantined?.(request.repoId, hostRuntimeContractFingerprint(started.runtimeContract))) {
|
|
520
|
+
// Not launched; the server retries on its backoff, and the check passes once the quarantine expires.
|
|
521
|
+
return failedProbe("host_runtime_isolation_quarantined", "The runtime contract is quarantined after a recent isolation violation, so it was not probed; its runs stay serialized.");
|
|
522
|
+
}
|
|
523
|
+
assertReadinessProbeStartupBudget(request.expiresAt);
|
|
524
|
+
let isolationDetail = null;
|
|
525
|
+
const launched = await hostRuntime.startConfiguredProject(request.requestId, request.fencingToken, signal, async (checkpoint) => {
|
|
526
|
+
if (checkpoint.code === "host_runtime_isolation_serialized")
|
|
527
|
+
isolationDetail = checkpoint.message;
|
|
528
|
+
});
|
|
529
|
+
return configuredProbeResult(launched, isolationDetail);
|
|
530
|
+
}
|
|
531
|
+
/** A late isolation violation stopped the attempt's project in the background: fail rather than report success. */
|
|
532
|
+
throwIfAbortedOrIsolationViolated(signal, dispatch, hostLease) {
|
|
533
|
+
throwIfAborted(signal);
|
|
534
|
+
const violation = hostLease && dispatch.sandbox
|
|
535
|
+
? this.hostRuntime?.isolationViolation?.(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken)
|
|
536
|
+
: null;
|
|
537
|
+
if (violation)
|
|
538
|
+
throw violation;
|
|
539
|
+
}
|
|
540
|
+
/** Reports the provider's peak memory and releases the attempt's host runtime lease. */
|
|
541
|
+
async releaseHostRuntime(dispatch, hostLease, hostSingletonKeys, emitLifecycle) {
|
|
542
|
+
if (hostLease && dispatch.sandbox) {
|
|
543
|
+
const providerMemory = this.hostRuntime?.providerMemoryTelemetry?.(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken);
|
|
544
|
+
if (providerMemory) {
|
|
545
545
|
await emitLifecycle({
|
|
546
546
|
role: "runner",
|
|
547
547
|
kind: "checkpoint",
|
|
548
|
-
content: `
|
|
549
|
-
eventType: "
|
|
550
|
-
occurredAt:
|
|
548
|
+
content: `Observed managed-host provider process-tree peak memory ${formatMemoryBytes(providerMemory.peakMemoryBytes)} from ${providerMemory.sampleCount} sample${providerMemory.sampleCount === 1 ? "" : "s"}.`,
|
|
549
|
+
eventType: "sandbox_peak_memory_observed",
|
|
550
|
+
occurredAt: providerMemory.observedAt,
|
|
551
|
+
data: JSON.stringify({
|
|
552
|
+
peakMemoryBytes: providerMemory.peakMemoryBytes,
|
|
553
|
+
sampleCount: providerMemory.sampleCount,
|
|
554
|
+
source: providerMemory.source,
|
|
555
|
+
containers: [{
|
|
556
|
+
role: "agent",
|
|
557
|
+
peakMemoryBytes: providerMemory.peakMemoryBytes,
|
|
558
|
+
}],
|
|
559
|
+
}),
|
|
551
560
|
}).catch(() => undefined);
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
await emitLifecycle({
|
|
565
|
-
role: "runner",
|
|
566
|
-
kind: "checkpoint",
|
|
567
|
-
content: `Released host runtime lease ${released.leaseId}. Diagnostics remain runner-local.`,
|
|
568
|
-
eventType: "sandbox_teardown_completed",
|
|
569
|
-
occurredAt: released.releasedAt,
|
|
570
|
-
}).catch(() => undefined);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
catch (error) {
|
|
561
|
+
}
|
|
562
|
+
const teardownAt = new Date().toISOString();
|
|
563
|
+
await emitLifecycle({
|
|
564
|
+
role: "runner",
|
|
565
|
+
kind: "checkpoint",
|
|
566
|
+
content: `Releasing host runtime lease ${hostLease.lease.leaseId}.`,
|
|
567
|
+
eventType: "sandbox_teardown_started",
|
|
568
|
+
occurredAt: teardownAt,
|
|
569
|
+
}).catch(() => undefined);
|
|
570
|
+
try {
|
|
571
|
+
const released = await this.hostRuntime?.release(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken);
|
|
572
|
+
if (!released) {
|
|
574
573
|
await emitLifecycle({
|
|
575
574
|
role: "runner",
|
|
576
575
|
kind: "error",
|
|
577
|
-
content:
|
|
576
|
+
content: "Host runtime cleanup requires reconciliation: the runtime lease was not current during release.",
|
|
578
577
|
eventType: "teardown_failed",
|
|
579
578
|
occurredAt: new Date().toISOString(),
|
|
580
579
|
}).catch(() => undefined);
|
|
581
580
|
}
|
|
581
|
+
else {
|
|
582
|
+
await emitLifecycle({
|
|
583
|
+
role: "runner",
|
|
584
|
+
kind: "checkpoint",
|
|
585
|
+
content: `Released host runtime lease ${released.leaseId}. Diagnostics remain runner-local.`,
|
|
586
|
+
eventType: "sandbox_teardown_completed",
|
|
587
|
+
occurredAt: released.releasedAt,
|
|
588
|
+
}).catch(() => undefined);
|
|
589
|
+
}
|
|
582
590
|
}
|
|
583
|
-
|
|
584
|
-
await
|
|
591
|
+
catch (error) {
|
|
592
|
+
await emitLifecycle({
|
|
593
|
+
role: "runner",
|
|
594
|
+
kind: "error",
|
|
595
|
+
content: `Host runtime cleanup requires reconciliation: ${error instanceof Error ? error.message : String(error)}`,
|
|
596
|
+
eventType: "teardown_failed",
|
|
597
|
+
occurredAt: new Date().toISOString(),
|
|
598
|
+
}).catch(() => undefined);
|
|
585
599
|
}
|
|
586
|
-
|
|
587
|
-
|
|
600
|
+
}
|
|
601
|
+
if (!hostLease && hostSingletonKeys && dispatch.sandbox) {
|
|
602
|
+
await this.hostRuntime?.release(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken).catch(() => undefined);
|
|
588
603
|
}
|
|
589
604
|
}
|
|
590
605
|
}
|
|
@@ -594,10 +609,6 @@ function failureMessage(error) {
|
|
|
594
609
|
function formatMemoryBytes(bytes) {
|
|
595
610
|
return `${(bytes / (1024 ** 2)).toFixed(bytes >= 1024 ** 3 ? 0 : 1)} MiB`;
|
|
596
611
|
}
|
|
597
|
-
function isPauseCancellation(signal) {
|
|
598
|
-
return signal?.aborted === true
|
|
599
|
-
&& String(signal.reason ?? "").trim().toLowerCase() === "session pause requested";
|
|
600
|
-
}
|
|
601
612
|
function readinessProbeDispatch(request) {
|
|
602
613
|
return {
|
|
603
614
|
schemaVersion: 2,
|
|
@@ -677,6 +688,31 @@ function readinessProbeDispatch(request) {
|
|
|
677
688
|
artifacts: [],
|
|
678
689
|
};
|
|
679
690
|
}
|
|
691
|
+
/**
|
|
692
|
+
* A probe is parallel_ready only when every configured port proved readiness and the launch earned the
|
|
693
|
+
* parallel promotion, which an isolation violation or a quarantined contract withholds while it runs.
|
|
694
|
+
*/
|
|
695
|
+
function configuredProbeResult(started, isolationDetail) {
|
|
696
|
+
const requiredPorts = configuredLaunchPortNames(started.runtimeContract);
|
|
697
|
+
const verifiedPorts = started.lease.resources.ports.map(port => port.name);
|
|
698
|
+
if (requiredPorts.length === 0 || !requiredPorts.every(name => verifiedPorts.includes(name))) {
|
|
699
|
+
return failedProbe("host_runtime_probe_unverified", "The application did not prove ownership and readiness on every Forge-assigned port.");
|
|
700
|
+
}
|
|
701
|
+
if (started.environment.FORGE_HOST_CONCURRENCY !== "host_parallel_safe") {
|
|
702
|
+
return failedProbe("host_runtime_isolation_violation", isolationDetail
|
|
703
|
+
?? "The application served every Forge-assigned port, but did not earn parallel-safety proof for this runtime contract.");
|
|
704
|
+
}
|
|
705
|
+
return {
|
|
706
|
+
status: "parallel_ready",
|
|
707
|
+
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
708
|
+
runtimeContractSource: started.runtimeContract.source,
|
|
709
|
+
runtimeRequirements: started.runtimeContract.contract.requires ?? null,
|
|
710
|
+
reasonCode: null,
|
|
711
|
+
reasonMessage: null,
|
|
712
|
+
qaAppLaunchTarget: managedQaLaunchTarget(started.runtimeContract),
|
|
713
|
+
checkedAt: new Date().toISOString(),
|
|
714
|
+
};
|
|
715
|
+
}
|
|
680
716
|
function failedProbe(reasonCode, reasonMessage) {
|
|
681
717
|
return { status: "failed", reasonCode, reasonMessage, checkedAt: new Date().toISOString() };
|
|
682
718
|
}
|
|
@@ -737,6 +773,13 @@ function throwIfAborted(signal) {
|
|
|
737
773
|
throw new Error(String(signal.reason ?? "Dispatch cancelled."));
|
|
738
774
|
}
|
|
739
775
|
}
|
|
776
|
+
/** The dispatch attempt a worktree is prepared for: Forge's attempt for its WIP refs, and whose host load it reserves. */
|
|
777
|
+
function preparedAttemptOwner(dispatch) {
|
|
778
|
+
return {
|
|
779
|
+
wipAttempt: dispatch.wipAttempt ?? null,
|
|
780
|
+
hostLoadOwner: { dispatchAttemptId: dispatch.sandbox?.dispatchAttemptId ?? null, priority: runtimeAdmissionPriority(dispatch) },
|
|
781
|
+
};
|
|
782
|
+
}
|
|
740
783
|
function validateApiKeySecretGrant(dispatch) {
|
|
741
784
|
if (!dispatch.execution.requiresApiKeySecretGrant) {
|
|
742
785
|
return;
|
|
@@ -11,6 +11,7 @@ export interface RunOnceDispatchPacket {
|
|
|
11
11
|
readonly runtimeIntent: DispatchRuntimeIntent;
|
|
12
12
|
readonly serverLocal: DispatchServerLocalConfig;
|
|
13
13
|
readonly sandbox?: DispatchSandboxContext | null;
|
|
14
|
+
readonly wipAttempt?: number | null;
|
|
14
15
|
readonly pullRequest?: DispatchPullRequestContext | null;
|
|
15
16
|
readonly apiKeySecretGrant?: ApiKeySecretGrant | null;
|
|
16
17
|
readonly apiKeySecretGrantHandle?: ApiKeySecretGrantHandle | null;
|
|
@@ -28,6 +28,7 @@ export function parseRunOnceDispatchPacket(value) {
|
|
|
28
28
|
runtimeIntent: parseRuntimeIntent(packet.runtimeIntent),
|
|
29
29
|
serverLocal: parseServerLocal(packet.serverLocal),
|
|
30
30
|
sandbox: parseSandbox(packet.sandbox, schemaVersion),
|
|
31
|
+
wipAttempt: optionalNonNegativeInteger(packet, "wipAttempt"),
|
|
31
32
|
pullRequest: parsePullRequest(packet.pullRequest),
|
|
32
33
|
apiKeySecretGrant: parseApiKeySecretGrant(packet.apiKeySecretGrant),
|
|
33
34
|
apiKeySecretGrantHandle: parseApiKeySecretGrantHandle(packet.apiKeySecretGrantHandle),
|
|
@@ -481,7 +482,7 @@ function unvalidatedFailureFactsForCode(code, source) {
|
|
|
481
482
|
if (["prepublication_validation_failed", "prepublication_contract_invalid", "prepublication_execution_scope_invalid"].includes(code)) {
|
|
482
483
|
return facts(code, "domain", "validation", source, "non_retryable", "fix_input");
|
|
483
484
|
}
|
|
484
|
-
if (
|
|
485
|
+
if (["comment_repair_changed_files_mismatch", "runner_result_sidecar_malformed"].includes(code)) {
|
|
485
486
|
return facts(code, "domain", "validation", source, "non_retryable", "inspect_failure");
|
|
486
487
|
}
|
|
487
488
|
if (["generated_output_reset_failed", "generated_output_reset_unverified", "worktree_prepare_failed", "host_runtime_ledger_write_failed", "host_diagnostics_temporary_unavailable", "attempt_process_supervisor_start_failed", "attempt_process_supervisor_start_timeout"].includes(code)) {
|
|
@@ -1373,9 +1374,8 @@ function optionalPositiveInteger(source, key) {
|
|
|
1373
1374
|
}
|
|
1374
1375
|
function optionalNonNegativeInteger(source, key) {
|
|
1375
1376
|
const value = source[key];
|
|
1376
|
-
if (value === undefined || value === null)
|
|
1377
|
+
if (value === undefined || value === null)
|
|
1377
1378
|
return null;
|
|
1378
|
-
}
|
|
1379
1379
|
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
|
|
1380
1380
|
throw new Error(`${key} must be a non-negative integer when provided.`);
|
|
1381
1381
|
}
|