@loucompanion/forge-bridge 0.1.4-dev.494233aa2e50 → 0.1.4-dev.4e7855579f82
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 +144 -3
- package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
- package/dist/bridge/bridge-chat-provider-command.js +132 -0
- package/dist/bridge/bridge-chat.types.d.ts +10 -0
- package/dist/bridge/bridge-chat.types.js +16 -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.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +89 -14
- package/dist/bridge/bridge.service.js +423 -342
- package/dist/bridge/bridge.types.d.ts +21 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -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.d.ts +5 -0
- package/dist/bridge/runner-host-capabilities.js +17 -0
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/cleanup/cleanup.service.d.ts +9 -0
- package/dist/cleanup/cleanup.service.js +72 -109
- package/dist/cleanup/cleanup.types.d.ts +4 -0
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
- package/dist/cleanup/host-runtime-ledger.js +109 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +74 -12
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +152 -187
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +6 -0
- package/dist/cli/local-config.js +32 -4
- 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 +5 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +138 -6
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -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-facts.d.ts +2 -1
- package/dist/runtime/host-load-admission.d.ts +67 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-child-environment.d.ts +27 -0
- package/dist/runtime/host-load-child-environment.js +76 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +52 -0
- package/dist/runtime/host-load-governor-config.js +83 -0
- package/dist/runtime/host-load-governor.d.ts +184 -0
- package/dist/runtime/host-load-governor.js +632 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +185 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +78 -0
- package/dist/runtime/host-load-sampler.d.ts +75 -2
- package/dist/runtime/host-load-sampler.js +142 -8
- package/dist/runtime/host-load-step-class.d.ts +70 -0
- package/dist/runtime/host-load-step-class.js +161 -0
- package/dist/runtime/host-load-step-reaper.d.ts +27 -0
- package/dist/runtime/host-load-step-reaper.js +95 -0
- package/dist/runtime/host-load-step-run.d.ts +73 -0
- package/dist/runtime/host-load-step-run.js +102 -0
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +81 -0
- package/dist/runtime/host-load-token-ledger.d.ts +200 -0
- package/dist/runtime/host-load-token-ledger.js +453 -0
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-pressure-stall.d.ts +21 -1
- package/dist/runtime/host-pressure-stall.js +48 -1
- package/dist/runtime/host-runtime-contract.d.ts +15 -0
- package/dist/runtime/host-runtime-contract.js +33 -2
- package/dist/runtime/host-runtime-lease.d.ts +74 -4
- package/dist/runtime/host-runtime-lease.js +285 -55
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +48 -0
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/sandbox/host-capacity-broker.d.ts +113 -0
- package/dist/sandbox/host-capacity-broker.js +334 -0
- package/dist/sandbox/runtime.d.ts +10 -1
- package/dist/sandbox/runtime.js +45 -2
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -7
- package/dist/session/managed-attempt-tools.js +200 -92
- package/dist/session/managed-command-host-load.d.ts +47 -0
- package/dist/session/managed-command-host-load.js +83 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +7 -0
- package/dist/session/phase-completion.artifacts.js +96 -26
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +12 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +5 -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.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +5 -11
- package/dist/session/phase-completion.runtime.js +91 -215
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +208 -231
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +49 -93
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +111 -0
- 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-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-process.d.ts +3 -0
- package/dist/session/pre-publication-process.js +23 -11
- package/dist/session/pre-publication-step-execution.d.ts +12 -0
- package/dist/session/pre-publication-step-execution.js +50 -0
- package/dist/session/pre-publication-validation.d.ts +37 -21
- package/dist/session/pre-publication-validation.js +221 -182
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- 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 +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
- package/dist/session/provider-cli/provider-cli.artifacts.js +20 -7
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +41 -31
- package/dist/session/provider-cli/provider-cli.process.js +139 -438
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +87 -32
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +29 -1
- package/dist/session/provider-cli/provider-cli.service.d.ts +7 -1
- package/dist/session/provider-cli/provider-cli.service.js +146 -182
- package/dist/session/provider-cli/provider-cli.types.d.ts +30 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- 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-in-flight-work.d.ts +10 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +8 -0
- package/dist/session/provider-cli/provider-output-state.js +15 -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/publishable-worktree-changes.d.ts +10 -1
- package/dist/session/publishable-worktree-changes.js +21 -5
- 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 +30 -0
- package/dist/session/sandbox-host-capacity-gate.js +238 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.service.d.ts +9 -2
- package/dist/session/session.service.js +120 -5
- package/dist/session/session.types.d.ts +3 -0
- package/dist/session/session.types.js +13 -4
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/process/host-process-supervisor.d.ts +1 -0
- package/dist/shared/process/host-process-supervisor.js +1 -1
- package/dist/shared/process/process-tree.d.ts +52 -0
- package/dist/shared/process/process-tree.js +144 -0
- package/dist/shared/process/process.d.ts +67 -0
- package/dist/shared/process/process.js +213 -11
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.js +14 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +46 -10
- package/dist/worktree/worktree.service.d.ts +10 -1
- package/dist/worktree/worktree.service.js +42 -2
- package/dist/worktree/worktree.types.d.ts +7 -0
- package/package.json +2 -2
|
@@ -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) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { HostRequirementsCheck } from "../runtime/host-runtime-requirements-check.js";
|
|
1
2
|
import type { HostRuntimeReadinessProbeRequest, HostRuntimeReadinessProbeResult, RunOnceDispatchPacket, RunOnceResultPacket, RunnerDispatchEvent } from "./session.types.js";
|
|
2
|
-
import type {
|
|
3
|
+
import type { RunnerHostDefaults } from "../runtime/runner-settings.js";
|
|
4
|
+
import type { HostCapacityLimits, HostRuntimeCapacitySnapshot, HostRuntimeReapOptions, HostRuntimeReapReport } from "../runtime/host-runtime-lease.js";
|
|
3
5
|
export interface SessionEventSink {
|
|
4
6
|
emit(event: RunnerDispatchEvent): Promise<void>;
|
|
5
7
|
}
|
|
@@ -9,4 +11,10 @@ export interface SessionService {
|
|
|
9
11
|
reapHostRuntime?(options: HostRuntimeReapOptions): Promise<HostRuntimeReapReport | null>;
|
|
10
12
|
runtimeCapacity?(): HostRuntimeCapacitySnapshot | null;
|
|
11
13
|
probeHostRuntime?(request: HostRuntimeReadinessProbeRequest, signal?: AbortSignal): Promise<HostRuntimeReadinessProbeResult>;
|
|
14
|
+
/** Decision 0013: host attempts recheck the project's requirements before starting. */
|
|
15
|
+
setHostRequirementsCheck?(check: HostRequirementsCheck | null): void;
|
|
16
|
+
/** Decision 0014: the host's max attempts and memory reserve defaults; null without host attempts. */
|
|
17
|
+
runnerLimitDefaults?(): RunnerHostDefaults | null;
|
|
18
|
+
/** Decision 0014: applies the effective max attempts and memory reserve to host attempt admission. */
|
|
19
|
+
applyRunnerLimits?(limits: HostCapacityLimits): void | Promise<void>;
|
|
12
20
|
}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import type { HostRequirementsCheck } from "../runtime/host-runtime-requirements-check.js";
|
|
1
2
|
import type { ProviderCliService } from "./provider-cli/provider-cli.base.js";
|
|
2
3
|
import type { SessionEventSink, SessionService } from "./session.base.js";
|
|
3
4
|
import type { HostRuntimeReadinessProbeRequest, HostRuntimeReadinessProbeResult, RunOnceDispatchPacket, RunOnceResultPacket } from "./session.types.js";
|
|
4
5
|
import type { WorktreeService } from "../worktree/worktree.base.js";
|
|
5
|
-
import { type HostRuntimeCapacitySnapshot, type HostRuntimeLeaseRuntime, type HostRuntimeReapOptions, type HostRuntimeReapReport } from "../runtime/host-runtime-lease.js";
|
|
6
|
+
import { type HostCapacityLimits, type HostRuntimeCapacitySnapshot, type HostRuntimeLeaseRuntime, type HostRuntimeReapOptions, type HostRuntimeReapReport } from "../runtime/host-runtime-lease.js";
|
|
7
|
+
import type { RunnerHostDefaults } from "../runtime/runner-settings.js";
|
|
8
|
+
import { type WorkspaceRuntimeFingerprintReader } from "./workspace-runtime-fingerprint.js";
|
|
6
9
|
export declare class BridgeSessionService implements SessionService {
|
|
7
10
|
private readonly worktrees;
|
|
8
11
|
private readonly providerCli;
|
|
9
12
|
private readonly hostRuntime?;
|
|
10
|
-
|
|
13
|
+
private readonly workspaceFingerprint;
|
|
14
|
+
constructor(worktrees?: WorktreeService, providerCli?: ProviderCliService, hostRuntime?: HostRuntimeLeaseRuntime | undefined, workspaceFingerprint?: WorkspaceRuntimeFingerprintReader);
|
|
15
|
+
setHostRequirementsCheck(check: HostRequirementsCheck | null): void;
|
|
16
|
+
runnerLimitDefaults(): RunnerHostDefaults | null;
|
|
17
|
+
applyRunnerLimits(limits: HostCapacityLimits): void;
|
|
11
18
|
updateLease(dispatchAttemptId: string, fencingToken: string, expiresAt: string): Promise<void>;
|
|
12
19
|
reapHostRuntime(options: HostRuntimeReapOptions): Promise<HostRuntimeReapReport | null>;
|
|
13
20
|
runtimeCapacity(): HostRuntimeCapacitySnapshot | null;
|
|
@@ -4,19 +4,31 @@ import { RoutingProviderCliService } from "./provider-cli/provider-cli.service.j
|
|
|
4
4
|
import { ForgeFailureError, waitKindForEvent, waitWakeCondition } from "./session.types.js";
|
|
5
5
|
import { GitWorktreeService } from "../worktree/worktree.service.js";
|
|
6
6
|
import { SandboxWorkspaceService } from "../sandbox/workspace.service.js";
|
|
7
|
-
import { HostRuntimeAdmissionExpiredError, hostRuntimeEventResources, } from "../runtime/host-runtime-lease.js";
|
|
7
|
+
import { HostRuntimeAdmissionExpiredError, hostRuntimeEventResources, hostRuntimeStackEnvironmentKeys, runtimeAdmissionPriority, } from "../runtime/host-runtime-lease.js";
|
|
8
8
|
import { configuredLaunchPortNames, hostRuntimeContractFingerprint, hostRuntimeParallelEligible, } from "../runtime/host-runtime-promotion.js";
|
|
9
|
+
import { readWorkspaceRuntimeFingerprint, sameWorkspaceRuntimeFingerprint, workspaceRuntimeFingerprintChanges, } from "./workspace-runtime-fingerprint.js";
|
|
9
10
|
const minimumReadinessProbeStartupBudgetMs = 150_000;
|
|
10
11
|
export class BridgeSessionService {
|
|
11
12
|
worktrees;
|
|
12
13
|
providerCli;
|
|
13
14
|
hostRuntime;
|
|
15
|
+
workspaceFingerprint;
|
|
14
16
|
constructor(worktrees = process.env.FORGE_SANDBOX_ID
|
|
15
17
|
? new SandboxWorkspaceService()
|
|
16
|
-
: new GitWorktreeService(), providerCli = new RoutingProviderCliService(), hostRuntime) {
|
|
18
|
+
: new GitWorktreeService(), providerCli = new RoutingProviderCliService(), hostRuntime, workspaceFingerprint = readWorkspaceRuntimeFingerprint) {
|
|
17
19
|
this.worktrees = worktrees;
|
|
18
20
|
this.providerCli = providerCli;
|
|
19
21
|
this.hostRuntime = hostRuntime;
|
|
22
|
+
this.workspaceFingerprint = workspaceFingerprint;
|
|
23
|
+
}
|
|
24
|
+
setHostRequirementsCheck(check) {
|
|
25
|
+
this.hostRuntime?.setRequirementsCheck?.(check);
|
|
26
|
+
}
|
|
27
|
+
runnerLimitDefaults() {
|
|
28
|
+
return this.hostRuntime?.capacityLimitDefaults?.() ?? null;
|
|
29
|
+
}
|
|
30
|
+
applyRunnerLimits(limits) {
|
|
31
|
+
this.hostRuntime?.applyCapacityLimits?.(limits);
|
|
20
32
|
}
|
|
21
33
|
async updateLease(dispatchAttemptId, fencingToken, expiresAt) {
|
|
22
34
|
await this.hostRuntime?.updateLease(dispatchAttemptId, fencingToken, expiresAt);
|
|
@@ -61,6 +73,8 @@ export class BridgeSessionService {
|
|
|
61
73
|
// failed agent worktrees for inspection.
|
|
62
74
|
cleanupWorktrees: dispatch.serverLocal.cleanupWorktrees,
|
|
63
75
|
artifacts: [],
|
|
76
|
+
hostLoadOwner: { dispatchAttemptId: dispatch.sandbox?.dispatchAttemptId ?? null, priority: "background" },
|
|
77
|
+
signal,
|
|
64
78
|
});
|
|
65
79
|
assertReadinessProbeStartupBudget(request.expiresAt);
|
|
66
80
|
let started = await this.hostRuntime.start(dispatch, worktree.worktreePath, signal);
|
|
@@ -71,6 +85,7 @@ export class BridgeSessionService {
|
|
|
71
85
|
status: "serialized",
|
|
72
86
|
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
73
87
|
runtimeContractSource: started.runtimeContract.source,
|
|
88
|
+
runtimeRequirements: started.runtimeContract.contract.requires ?? null,
|
|
74
89
|
reasonCode: discovery?.reasonCode ?? "host_runtime_contract_serialized",
|
|
75
90
|
reasonMessage: discovery?.summary ?? "The detected runtime requires serialized host execution.",
|
|
76
91
|
checkedAt: new Date().toISOString(),
|
|
@@ -87,6 +102,7 @@ export class BridgeSessionService {
|
|
|
87
102
|
status: "parallel_ready",
|
|
88
103
|
runtimeContractFingerprint: hostRuntimeContractFingerprint(started.runtimeContract),
|
|
89
104
|
runtimeContractSource: started.runtimeContract.source,
|
|
105
|
+
runtimeRequirements: started.runtimeContract.contract.requires ?? null,
|
|
90
106
|
reasonCode: null,
|
|
91
107
|
reasonMessage: null,
|
|
92
108
|
qaAppLaunchTarget: managedQaLaunchTarget(started.runtimeContract),
|
|
@@ -248,7 +264,12 @@ export class BridgeSessionService {
|
|
|
248
264
|
qaRework: dispatch.qaRework,
|
|
249
265
|
warmPathOverrides: dispatch.warmPathOverrides,
|
|
250
266
|
applicationRuntimeRequired: dispatch.runtimeIntent.applicationRuntimeRequired,
|
|
251
|
-
preserveExistingState: Boolean(dispatch.session.resumedFromSessionId)
|
|
267
|
+
preserveExistingState: Boolean(dispatch.session.resumedFromSessionId),
|
|
268
|
+
hostLoadOwner: {
|
|
269
|
+
dispatchAttemptId: dispatch.sandbox?.dispatchAttemptId ?? null,
|
|
270
|
+
priority: runtimeAdmissionPriority(dispatch),
|
|
271
|
+
},
|
|
272
|
+
signal,
|
|
252
273
|
});
|
|
253
274
|
}
|
|
254
275
|
catch (error) {
|
|
@@ -326,7 +347,98 @@ export class BridgeSessionService {
|
|
|
326
347
|
});
|
|
327
348
|
}
|
|
328
349
|
}
|
|
350
|
+
// The stack was built and launched from this workspace state. Pre-publication
|
|
351
|
+
// validation restarts it when the provider has changed the source since.
|
|
352
|
+
let refreshRuntimeEnvironment;
|
|
353
|
+
const hostRuntime = this.hostRuntime;
|
|
354
|
+
if (hostLease && dispatch.sandbox && hostRuntime?.restartConfiguredProject
|
|
355
|
+
&& hostLease.executionClass === "managed_runtime"
|
|
356
|
+
&& configuredLaunchPortNames(hostLease.runtimeContract).length > 0) {
|
|
357
|
+
const worktreePath = worktree.worktreePath;
|
|
358
|
+
const dispatchAttemptId = dispatch.sandbox.dispatchAttemptId;
|
|
359
|
+
const fencingToken = dispatch.lease.fencingToken;
|
|
360
|
+
const restartConfiguredProject = hostRuntime.restartConfiguredProject.bind(hostRuntime);
|
|
361
|
+
let launchFingerprint = await this.workspaceFingerprint(worktreePath)
|
|
362
|
+
.catch(() => null);
|
|
363
|
+
// Set while the stack may not match the workspace: a failed restart is retried on the next pass.
|
|
364
|
+
let restartPending = false;
|
|
365
|
+
refreshRuntimeEnvironment = async (refreshSignal) => {
|
|
366
|
+
const current = await this.workspaceFingerprint(worktreePath).catch(() => null);
|
|
367
|
+
if (!restartPending && sameWorkspaceRuntimeFingerprint(launchFingerprint, current))
|
|
368
|
+
return null;
|
|
369
|
+
// Every cause that applies is reported; `reason` is the first of them. Changes are named
|
|
370
|
+
// only when both states were read: an unreadable baseline is not a workspace change.
|
|
371
|
+
const comparable = launchFingerprint !== null && current !== null;
|
|
372
|
+
const changes = comparable ? workspaceRuntimeFingerprintChanges(launchFingerprint, current) : [];
|
|
373
|
+
const causes = [
|
|
374
|
+
...(restartPending ? ["previous_restart_incomplete"] : []),
|
|
375
|
+
...(comparable ? [] : ["fingerprint_unavailable"]),
|
|
376
|
+
...(changes.length > 0 ? ["workspace_changed"] : []),
|
|
377
|
+
];
|
|
378
|
+
const reason = causes[0] ?? "workspace_changed";
|
|
379
|
+
const changeText = changes.length > 0 ? ` The workspace also changed since launch (${changes.join(", ")}).` : "";
|
|
380
|
+
await emitLifecycle({
|
|
381
|
+
role: "runner",
|
|
382
|
+
kind: "checkpoint",
|
|
383
|
+
content: reason === "workspace_changed"
|
|
384
|
+
? `The workspace changed since the attempt runtime stack was launched (${changes.join(", ")}); restarting it so validation runs against the current source.`
|
|
385
|
+
: reason === "previous_restart_incomplete"
|
|
386
|
+
? `The previous attempt runtime restart did not complete; restarting it again so validation runs against the current source.${changeText}`
|
|
387
|
+
: `The workspace state could not be compared with the attempt runtime stack; restarting it so validation runs against the current source.`,
|
|
388
|
+
eventType: "host_runtime_restart_started",
|
|
389
|
+
data: JSON.stringify({
|
|
390
|
+
reason,
|
|
391
|
+
causes,
|
|
392
|
+
changes,
|
|
393
|
+
head_sha: current?.headSha ?? null,
|
|
394
|
+
merge_in_progress: Boolean(current?.mergeHead),
|
|
395
|
+
}),
|
|
396
|
+
});
|
|
397
|
+
restartPending = true;
|
|
398
|
+
let restarted;
|
|
399
|
+
try {
|
|
400
|
+
restarted = await restartConfiguredProject(dispatchAttemptId, fencingToken, refreshSignal ?? signal, async (checkpoint) => {
|
|
401
|
+
await emitLifecycle({
|
|
402
|
+
role: "runner",
|
|
403
|
+
kind: "checkpoint",
|
|
404
|
+
content: checkpoint.message,
|
|
405
|
+
eventType: checkpoint.code,
|
|
406
|
+
data: checkpoint.data ? JSON.stringify(checkpoint.data) : undefined,
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
catch (error) {
|
|
411
|
+
await emitLifecycle({
|
|
412
|
+
role: "runner",
|
|
413
|
+
kind: "error",
|
|
414
|
+
content: `Restarting the attempt runtime stack failed: ${failureMessage(error)}`,
|
|
415
|
+
eventType: "host_runtime_restart_failed",
|
|
416
|
+
data: JSON.stringify({ reason, causes, changes }),
|
|
417
|
+
}).catch(() => undefined);
|
|
418
|
+
throw error;
|
|
419
|
+
}
|
|
420
|
+
hostLease = restarted;
|
|
421
|
+
// The restarted stack serves the workspace as it is now. Read that state again rather than
|
|
422
|
+
// keep the pre-restart reading, which is null when it could not be collected; a null
|
|
423
|
+
// baseline never matches, so every later pass would restart and rotate ports again.
|
|
424
|
+
launchFingerprint = await this.workspaceFingerprint(worktreePath).catch(() => current);
|
|
425
|
+
restartPending = false;
|
|
426
|
+
await emitLifecycle({
|
|
427
|
+
role: "runner",
|
|
428
|
+
kind: "checkpoint",
|
|
429
|
+
content: `Restarted the supervised project runtime on ${restarted.lease.resources.ports.map(port => `${port.name} ${port.hostIp}:${port.hostPort}`).join(", ") || "no ports"}.`,
|
|
430
|
+
eventType: "host_runtime_restarted",
|
|
431
|
+
data: JSON.stringify(hostRuntimeEventResources(restarted.lease, restarted.runtimeContract, restarted.executionClass)),
|
|
432
|
+
});
|
|
433
|
+
return { environment: restarted.environment, reason, changes };
|
|
434
|
+
};
|
|
435
|
+
}
|
|
329
436
|
providerDispatch = withMaterializedManagedQaTarget(providerDispatch, hostLease);
|
|
437
|
+
const providerEnvironment = {
|
|
438
|
+
runtimeEnvironment: hostLease?.environment,
|
|
439
|
+
// Only the completion MCP server gets these: its managed commands share the host ledger.
|
|
440
|
+
hostLoadEnvironment: hostLease ? this.hostRuntime?.hostLoadChildEnvironment?.() : undefined,
|
|
441
|
+
};
|
|
330
442
|
if (dispatch.draft) {
|
|
331
443
|
throwIfAborted(signal);
|
|
332
444
|
const processRunner = hostLease && dispatch.sandbox
|
|
@@ -335,7 +447,7 @@ export class BridgeSessionService {
|
|
|
335
447
|
const run = await this.providerCli.runDraft({
|
|
336
448
|
dispatch: providerDispatch,
|
|
337
449
|
worktree,
|
|
338
|
-
|
|
450
|
+
...providerEnvironment,
|
|
339
451
|
processRunner,
|
|
340
452
|
emit,
|
|
341
453
|
signal
|
|
@@ -363,10 +475,13 @@ export class BridgeSessionService {
|
|
|
363
475
|
const context = {
|
|
364
476
|
dispatch: providerDispatch,
|
|
365
477
|
worktree,
|
|
366
|
-
|
|
478
|
+
...providerEnvironment,
|
|
367
479
|
processRunner: hostLease && dispatch.sandbox
|
|
368
480
|
? this.hostRuntime?.providerProcessRunner?.(dispatch.sandbox.dispatchAttemptId, dispatch.lease.fencingToken) ?? undefined
|
|
369
481
|
: undefined,
|
|
482
|
+
...(refreshRuntimeEnvironment && hostLease
|
|
483
|
+
? { refreshRuntimeEnvironment, runtimeStackEnvironmentKeys: hostRuntimeStackEnvironmentKeys(hostLease.runtimeContract) }
|
|
484
|
+
: {}),
|
|
370
485
|
emit,
|
|
371
486
|
signal
|
|
372
487
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HostRuntimeRequirements } from "../runtime/host-runtime-requirements.js";
|
|
1
2
|
export interface RunOnceDispatchPacket {
|
|
2
3
|
readonly schemaVersion: 1 | 2;
|
|
3
4
|
readonly userId: string;
|
|
@@ -546,6 +547,8 @@ export interface HostRuntimeReadinessProbeResult {
|
|
|
546
547
|
readonly status: "parallel_ready" | "serialized" | "failed";
|
|
547
548
|
readonly runtimeContractFingerprint?: string | null;
|
|
548
549
|
readonly runtimeContractSource?: string | null;
|
|
550
|
+
/** Requirements declared by the probed contract (decision 0013); null when none. */
|
|
551
|
+
readonly runtimeRequirements?: HostRuntimeRequirements | null;
|
|
549
552
|
readonly reasonCode?: string | null;
|
|
550
553
|
readonly reasonMessage?: string | null;
|
|
551
554
|
readonly qaAppLaunchTarget?: HostRuntimeReadinessQaLaunchTarget | null;
|
|
@@ -469,19 +469,19 @@ function unvalidatedFailureFactsForCode(code, source) {
|
|
|
469
469
|
if (code === "bridge.unavailable") {
|
|
470
470
|
return facts(code, "transport", "offer", source, "retryable", "retry_dispatch");
|
|
471
471
|
}
|
|
472
|
-
if (["capacity_unavailable", "bridge.runner_draining", "docker_engine_unavailable", "docker_memory_low", "docker_memory_sample_unavailable", "docker_cpu_low", "docker_disk_low", "server_local.resource_pressure", "server_local.capacity_unavailable", "dispatch.preparation_resource_pressure", "sandbox_capacity_profile_unavailable", "host_runtime_admission_expired"].includes(code)) {
|
|
472
|
+
if (["capacity_unavailable", "bridge.runner_draining", "docker_engine_unavailable", "docker_memory_low", "docker_memory_sample_unavailable", "docker_cpu_low", "docker_disk_low", "server_local.resource_pressure", "server_local.capacity_unavailable", "dispatch.preparation_resource_pressure", "sandbox_capacity_profile_unavailable", "host_runtime_admission_expired", "placement_requirements_unmet", "runner_yielding", "runner_settings_pending", "runner_settings_apply_failed", "runner_tier_light", "runner_project_not_allowed"].includes(code)) {
|
|
473
473
|
return facts(code, "resource", "offer", source, "retryable", "retry_dispatch");
|
|
474
474
|
}
|
|
475
475
|
if (["bridge.lease_retry_exhausted", "bridge.capacity_wait_exhausted"].includes(code)) {
|
|
476
476
|
return facts(code, "resource", "offer", source, "non_retryable", "inspect_failure");
|
|
477
477
|
}
|
|
478
|
-
if (["prepublication_infrastructure_failed", "prepublication_capability_unavailable"].includes(code)) {
|
|
478
|
+
if (["prepublication_infrastructure_failed", "prepublication_capability_unavailable", "host_capacity_timeout", "host_capacity_token_fenced", "host_capacity_ledger_unavailable"].includes(code)) {
|
|
479
479
|
return facts(code, "resource", "validation", source, "retryable", "retry_with_policy");
|
|
480
480
|
}
|
|
481
481
|
if (["prepublication_validation_failed", "prepublication_contract_invalid", "prepublication_execution_scope_invalid"].includes(code)) {
|
|
482
482
|
return facts(code, "domain", "validation", source, "non_retryable", "fix_input");
|
|
483
483
|
}
|
|
484
|
-
if (
|
|
484
|
+
if (["comment_repair_changed_files_mismatch", "runner_result_sidecar_malformed"].includes(code)) {
|
|
485
485
|
return facts(code, "domain", "validation", source, "non_retryable", "inspect_failure");
|
|
486
486
|
}
|
|
487
487
|
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)) {
|
|
@@ -496,7 +496,7 @@ function unvalidatedFailureFactsForCode(code, source) {
|
|
|
496
496
|
if (code === "provider_configuration_invalid") {
|
|
497
497
|
return facts(code, "provider", "prepare", source, "non_retryable", "fix_environment");
|
|
498
498
|
}
|
|
499
|
-
if (["host_port_collision", "host_runtime_process_exited", "host_runtime_listener_timeout", "host_runtime_http_readiness_timeout", "host_runtime_prepared_source_changed", "host_runtime_prepared_probe_incomplete", "host_runtime_prepared_probe_cleanup_unconfirmed"].includes(code)) {
|
|
499
|
+
if (["host_port_collision", "host_runtime_process_exited", "host_runtime_listener_timeout", "host_runtime_http_readiness_timeout", "host_runtime_prepared_source_changed", "host_runtime_contract_changed", "host_runtime_prepared_probe_incomplete", "host_runtime_prepared_probe_cleanup_unconfirmed"].includes(code)) {
|
|
500
500
|
return facts(code, "resource", "prepare", source, "retryable", "retry_dispatch");
|
|
501
501
|
}
|
|
502
502
|
if (code === "host_runtime_project_start_failed") {
|
|
@@ -522,6 +522,12 @@ function unvalidatedFailureFactsForCode(code, source) {
|
|
|
522
522
|
if (code === "provider_capacity_unavailable") {
|
|
523
523
|
return facts(code, "resource", "offer", source, "retryable", "retry_dispatch");
|
|
524
524
|
}
|
|
525
|
+
if (code === "provider_completion_tool_missing") {
|
|
526
|
+
return facts(code, "provider", "agent", source, "non_retryable", "inspect_failure");
|
|
527
|
+
}
|
|
528
|
+
if (["provider_terminated_at_turn_ceiling", "provider_turn_ended_with_background_work"].includes(code)) {
|
|
529
|
+
return facts(code, "provider", "agent", source, "retryable", "retry_with_policy");
|
|
530
|
+
}
|
|
525
531
|
if (code === "provider_context_window_exhausted") {
|
|
526
532
|
return facts(code, "provider", "agent", source, "retryable", "retry_dispatch");
|
|
527
533
|
}
|
|
@@ -566,6 +572,9 @@ function unvalidatedFailureFactsForCode(code, source) {
|
|
|
566
572
|
if (code === "worktree_branch_integration_conflict") {
|
|
567
573
|
return facts(code, "domain", "agent", source, "non_retryable", "fix_input");
|
|
568
574
|
}
|
|
575
|
+
if (["merge_resolution_reverts_upstream_changes", "merge_resolution_unresolved_conflict"].includes(code)) {
|
|
576
|
+
return facts(code, "domain", "validation", source, "non_retryable", "inspect_failure");
|
|
577
|
+
}
|
|
569
578
|
if (stableFailureFamilyCodes.has(code) && code.startsWith("sandbox_")) {
|
|
570
579
|
return facts(code, "provider", "agent", source, "non_retryable", "inspect_failure");
|
|
571
580
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const maximumIntegrityJsonBytes: number;
|
|
2
|
+
/** A JSON text that breaks a shape rule. `reason` names the rule and never quotes file content. */
|
|
3
|
+
export declare class JsonShapeError extends Error {
|
|
4
|
+
readonly reason: string;
|
|
5
|
+
constructor(reason: string);
|
|
6
|
+
}
|
|
7
|
+
export declare const oversizedJsonReason = "it is larger than the 8 MiB JSON inspection limit";
|
|
8
|
+
/**
|
|
9
|
+
* Checks a bounded JSON text and calls `onString` with every decoded string token (property names
|
|
10
|
+
* and values). Throws JsonShapeError for a shape problem; errors thrown by `onString` propagate.
|
|
11
|
+
*/
|
|
12
|
+
export declare function inspectJsonText(value: string, onString?: (decoded: string) => void): void;
|
|
13
|
+
export declare function decodeJsonStringToken(value: string, openingQuoteIndex: number): {
|
|
14
|
+
readonly decoded: string;
|
|
15
|
+
readonly nextIndex: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Why a sidecar that looks like JSON is not acceptable JSON, or null when it is fine: valid JSON,
|
|
19
|
+
* plain text that does not start like JSON, or binary content that is not named *.json.
|
|
20
|
+
*/
|
|
21
|
+
export declare function sidecarJsonShapeProblem(content: Uint8Array, path: string, onString?: (decoded: string) => void): string | null;
|
|
22
|
+
/** The instruction an agent gets when it records a sidecar that fails the shape check. */
|
|
23
|
+
export declare function sidecarJsonRepairInstruction(path: string, reason: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Best-effort decoding of every JSON escape in a text that failed the shape check, so a secret
|
|
26
|
+
* hidden behind escapes still gets the secret error rather than the malformed-sidecar error.
|
|
27
|
+
*/
|
|
28
|
+
export declare function decodeJsonEscapesLeniently(value: string): string;
|
|
29
|
+
export declare function looksLikeJson(value: string, path: string): boolean;
|
|
30
|
+
export declare function isJsonWhitespace(code: number): boolean;
|
|
31
|
+
export declare function isJsonPunctuation(code: number): boolean;
|