@loucompanion/forge-bridge 0.1.4-dev.e3697e9f5c98 → 0.1.4-dev.f22f5e3d01fe
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 +13 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
- package/dist/bridge/bridge-chat-provider-command.js +125 -0
- package/dist/bridge/bridge.service.d.ts +1 -1
- package/dist/bridge/bridge.service.js +4 -110
- package/dist/bridge/runner-host-capabilities.d.ts +3 -0
- package/dist/bridge/runner-host-capabilities.js +13 -0
- package/dist/runtime/host-facts.d.ts +2 -1
- package/dist/runtime/host-load-admission.d.ts +9 -2
- package/dist/runtime/host-load-child-environment.d.ts +11 -6
- package/dist/runtime/host-load-child-environment.js +19 -10
- package/dist/runtime/host-load-governor-config.d.ts +10 -1
- package/dist/runtime/host-load-governor-config.js +7 -0
- package/dist/runtime/host-load-governor.d.ts +10 -0
- package/dist/runtime/host-load-governor.js +125 -34
- package/dist/runtime/host-load-sampler.d.ts +26 -3
- package/dist/runtime/host-load-sampler.js +61 -2
- package/dist/runtime/host-load-step-class.d.ts +3 -1
- package/dist/runtime/host-load-step-class.js +60 -5
- 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 +26 -0
- package/dist/runtime/host-load-token-ledger.js +93 -61
- 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-runtime-lease.d.ts +1 -1
- package/dist/runtime/host-runtime-lease.js +1 -1
- package/dist/sandbox/host-capacity-broker.d.ts +7 -1
- package/dist/sandbox/host-capacity-broker.js +23 -4
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.js +8 -9
- package/dist/session/managed-command-host-load.d.ts +2 -0
- package/dist/session/managed-command-host-load.js +2 -1
- package/dist/session/phase-completion.schemas.js +25 -23
- package/dist/session/phase-completion.validation.js +3 -1
- package/dist/session/pre-publication-pass.d.ts +2 -1
- package/dist/session/pre-publication-pass.js +8 -5
- package/dist/session/pre-publication-validation.d.ts +2 -0
- package/dist/session/pre-publication-validation.js +30 -4
- package/dist/session/provider-cli/claude-background-work.d.ts +66 -0
- package/dist/session/provider-cli/claude-background-work.js +180 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +73 -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.process.d.ts +13 -22
- package/dist/session/provider-cli/provider-cli.process.js +36 -337
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +2 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +45 -8
- package/dist/session/provider-cli/provider-cli.runtime.js +7 -0
- package/dist/session/provider-cli/provider-cli.service.js +2 -8
- 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-in-flight-work.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -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 +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/sandbox-host-capacity-gate.js +12 -3
- package/dist/session/session.types.js +1 -1
- 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/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ import { attachManagedCommandProcess, ManagedCommandHostCapacity, } from "./mana
|
|
|
14
14
|
import { HostCapacityLedgerUnavailableError } from "../runtime/host-load-ledger-lock.js";
|
|
15
15
|
import { isProcessTreeTerminationUnproven } from "../shared/process/process.js";
|
|
16
16
|
import { HostCapacityTokenFencedError } from "../runtime/host-load-token-ledger.js";
|
|
17
|
-
import {
|
|
17
|
+
import { withoutHostLoadGovernorVariables } from "../runtime/host-load-child-environment.js";
|
|
18
18
|
import { managedBuildConfiguration, publishManagedBuildReceipt, verifyManagedBuildReceipt, } from "./managed-build-receipt.js";
|
|
19
19
|
import { managedLongTierTimeoutMs, managedMaximumCommandTimeoutMs, managedVerificationTierTimeoutMs, } from "./managed-verification-timeouts.js";
|
|
20
20
|
import { resolveWindowsCommandFromPath, StreamingProviderProcessRunner } from "./provider-cli/provider-cli.process.js";
|
|
@@ -447,7 +447,7 @@ export function buildManagedVerificationCommand(profile, outputDirectory, shardC
|
|
|
447
447
|
export function preferredPowerShellExecutable(platform = process.platform, pathValue = process.env.PATH ?? "") {
|
|
448
448
|
if (platform !== "win32")
|
|
449
449
|
return "pwsh";
|
|
450
|
-
return resolveWindowsCommandFromPath("pwsh.exe", pathValue) ?? "powershell.exe";
|
|
450
|
+
return resolveWindowsCommandFromPath("pwsh.exe", pathValue, undefined, { skipAppExecutionAliases: true }) ?? "powershell.exe";
|
|
451
451
|
}
|
|
452
452
|
export function validatePlaywrightProjectName(project, availableProjects) {
|
|
453
453
|
if (!availableProjects.includes(project)) {
|
|
@@ -907,7 +907,7 @@ async function waitManagedCommand(input) {
|
|
|
907
907
|
const lastOutputAt = Date.parse(String(receipt.structuredContent.last_output_at));
|
|
908
908
|
const hostLoadWaitMs = receipt.structuredContent.host_load_wait_ms;
|
|
909
909
|
const progress = receipt.structuredContent.status === "waiting_for_host_capacity" && typeof hostLoadWaitMs === "number"
|
|
910
|
-
? ` It has waited ${Math.round(hostLoadWaitMs / 1000)}s for host capacity and has not started yet; its timeout starts only once it is admitted, so queue time never counts against it. Keep waiting; a queued command is not a blocker.`
|
|
910
|
+
? ` It has waited ${Math.round(hostLoadWaitMs / 1000)}s for host capacity${typeof receipt.structuredContent.host_load_wait_detail === "string" ? ` (${receipt.structuredContent.host_load_wait_detail})` : ""} and has not started yet; its timeout starts only once it is admitted, so queue time never counts against it. Keep waiting; a queued command is not a blocker.`
|
|
911
911
|
: receipt.structuredContent.status === "running" && typeof elapsedMs === "number"
|
|
912
912
|
? ` It has run for ${Math.round(elapsedMs / 1000)}s`
|
|
913
913
|
+ (Number.isFinite(lastOutputAt) ? `, last output ${Math.max(0, Math.round((Date.now() - lastOutputAt) / 1000))}s ago` : ", with no output yet")
|
|
@@ -1033,7 +1033,7 @@ function managedCommandHostLoadReceipt(hostLoad) {
|
|
|
1033
1033
|
return {
|
|
1034
1034
|
host_load_step_class: hostLoad.stepClass,
|
|
1035
1035
|
host_load_wait_ms: waiting ? Math.max(0, Date.now() - hostLoad.waitStartedAt) : hostLoad.waitMs,
|
|
1036
|
-
...(waiting ? { host_load_wait_started_at: new Date(hostLoad.waitStartedAt).toISOString() } : {}),
|
|
1036
|
+
...(waiting ? { host_load_wait_started_at: new Date(hostLoad.waitStartedAt).toISOString(), host_load_wait_detail: hostLoad.waitDetail ?? null } : {}),
|
|
1037
1037
|
};
|
|
1038
1038
|
}
|
|
1039
1039
|
async function annotateManagedCommandReceipt(receiptPath, fields) {
|
|
@@ -1115,11 +1115,10 @@ async function containedWorkingDirectory(worktreePath, input) {
|
|
|
1115
1115
|
}
|
|
1116
1116
|
function inheritedEnvironment(overrides) {
|
|
1117
1117
|
const env = {};
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
continue;
|
|
1118
|
+
// A nested Forge process must not join the host ledger: it would queue behind the
|
|
1119
|
+
// token this command already holds. Every FORGE_HOST_LOAD_* variable is dropped,
|
|
1120
|
+
// the test slot count too (decision 0018).
|
|
1121
|
+
for (const [key, value] of Object.entries(withoutHostLoadGovernorVariables(process.env))) {
|
|
1123
1122
|
if (typeof value === "string" && !looksSensitiveEnvironmentName(key))
|
|
1124
1123
|
env[key] = value;
|
|
1125
1124
|
}
|
|
@@ -8,6 +8,8 @@ export interface ManagedCommandHostLoadFields {
|
|
|
8
8
|
readonly waitMs: number;
|
|
9
9
|
/** Set while the command is still queued: the receipt reports the wait so far. */
|
|
10
10
|
readonly waitStartedAt?: number;
|
|
11
|
+
/** Why it waits, for example for the host test slot and who holds it (decision 0018). */
|
|
12
|
+
readonly waitDetail?: string;
|
|
11
13
|
/** When the command was admitted; elapsed_ms counts from here. */
|
|
12
14
|
readonly executionStartedAt?: number;
|
|
13
15
|
}
|
|
@@ -45,11 +45,12 @@ export class ManagedCommandHostCapacity {
|
|
|
45
45
|
signal,
|
|
46
46
|
// The receipt says host_capacity_token_fenced itself (termination_reason).
|
|
47
47
|
reportsOwnFence: true,
|
|
48
|
-
onWaiting:
|
|
48
|
+
onWaiting: decision => {
|
|
49
49
|
this.waitingWrite = this.persistWaiting({
|
|
50
50
|
stepClass: this.classification.stepClass,
|
|
51
51
|
waitMs: 0,
|
|
52
52
|
waitStartedAt: this.requestedAtMs ?? Date.now(),
|
|
53
|
+
waitDetail: decision.detail,
|
|
53
54
|
}).catch(() => undefined);
|
|
54
55
|
},
|
|
55
56
|
onReleaseFailed,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { decomposeGateFileNames, decomposeStatuses, draftStatuses, isDebugCompletionPhase, phaseFiles, qaBlockerReasons, qaGateFileNames } from "./phase-completion.js";
|
|
2
2
|
import { browserCheckSchema, qaSidecarsSchema, qaEvidenceWrapperSchema, qaGateEvidenceWrapperSchema, findingEvidenceSchema, objectToolSchema, evidenceObjectSchema, qaScopeSchema, commandEvidenceSchema, resolvedFindingSchema, acceptanceCriteriaSchema, reviewSectionSchema, reviewSectionProperties } from "./phase-completion.schema-parts.js";
|
|
3
|
+
import { architectNonPassProperties } from "./architect-waits.js";
|
|
3
4
|
export function toolDescription(phase, qaGate = null, decomposeGate = null, draftGate = null) {
|
|
4
5
|
if (qaGate) {
|
|
5
6
|
return qaGate === "qa_verdict"
|
|
@@ -499,17 +500,8 @@ export function toolInputSchema(phase, qaGate = null, decomposeGate = null, draf
|
|
|
499
500
|
report_markdown: { type: "string", description: "Human-readable Architect report. Use report as an alias only when the client cannot send report_markdown." },
|
|
500
501
|
report: { type: "string", description: "Alias for report_markdown." },
|
|
501
502
|
blockers: baseProperties.blockers,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
description: "Required for needs_revision when blockers are not used.",
|
|
505
|
-
items: { type: "string" }
|
|
506
|
-
},
|
|
507
|
-
revision_reasons: {
|
|
508
|
-
type: "array",
|
|
509
|
-
description: "Concrete reasons that prevent pass status.",
|
|
510
|
-
items: { type: "string" }
|
|
511
|
-
}
|
|
512
|
-
}, ["status", "summary"], "For status pass, include implementation_plan and qa_plan at the top level of the MCP tool arguments, as JSON objects rather than quoted strings. implementation_plan.phases must be a top-level array inside implementation_plan, not nested under another object. For needs_revision or blocked, implementation_plan and qa_plan may be omitted; include blockers, revision_questions, or revision_reasons instead.");
|
|
503
|
+
...architectNonPassProperties()
|
|
504
|
+
}, ["status", "summary"], "For status pass, include implementation_plan and qa_plan at the top level of the MCP tool arguments, as JSON objects rather than quoted strings. implementation_plan.phases must be a top-level array inside implementation_plan, not nested under another object. For needs_revision or blocked, implementation_plan and qa_plan may be omitted; include blockers, revision_questions, or revision_reasons instead. When blocked because another Story or pull request must merge first, also list it in waits_on; when the owner must choose, also set owner_decision.");
|
|
513
505
|
}
|
|
514
506
|
return objectToolSchema({
|
|
515
507
|
...baseProperties,
|
|
@@ -536,6 +528,27 @@ export function toolInputSchema(phase, qaGate = null, decomposeGate = null, draf
|
|
|
536
528
|
ready_for_dev_test: { type: "boolean", default: true, description: "Required for pass and must be true." }
|
|
537
529
|
}, ["status", "summary"], "For status pass, commands must include at least one passing deterministic command, acceptance criteria entries must use status: satisfied plus evidence, and ready_for_dev_test must be true.");
|
|
538
530
|
}
|
|
531
|
+
// Feature-to-Story candidate fields: schedule order, handoff to dependents, and whether the Story
|
|
532
|
+
// needs a design reference before Forge builds it.
|
|
533
|
+
const storyCandidateScheduleProperties = {
|
|
534
|
+
scheduleIndex: { type: "number", description: "Feature-to-Story total schedule order for dependency-safe execution." },
|
|
535
|
+
schedule_index: { type: "number", description: "Snake_case alias for scheduleIndex." },
|
|
536
|
+
waveIndex: { type: "number", description: "Feature-to-Story parallel wave number." },
|
|
537
|
+
wave_index: { type: "number", description: "Snake_case alias for waveIndex." },
|
|
538
|
+
featureScheduleIndex: { type: "number", description: "Optional ordering within the Feature." },
|
|
539
|
+
feature_schedule_index: { type: "number", description: "Snake_case alias for featureScheduleIndex." },
|
|
540
|
+
expectedOutput: { type: "string", description: "Durable output this Story should produce for dependents." },
|
|
541
|
+
expected_output: { type: "string", description: "Snake_case alias for expectedOutput." },
|
|
542
|
+
handoffSummary: { type: "string", description: "How dependent Stories should consume this Story output." },
|
|
543
|
+
handoff_summary: { type: "string", description: "Snake_case alias for handoffSummary." },
|
|
544
|
+
dependencyReason: { type: "string", description: "Why this Story depends on its dependsOn predecessors." },
|
|
545
|
+
dependency_reason: { type: "string", description: "Snake_case alias for dependencyReason." },
|
|
546
|
+
requiresDesign: {
|
|
547
|
+
type: "boolean",
|
|
548
|
+
description: "Feature-to-Story only. True when the Story adds or changes user-visible UI; Forge holds it until a design reference is attached. False for non-visual Stories."
|
|
549
|
+
},
|
|
550
|
+
requires_design: { type: "boolean", description: "Snake_case alias for requiresDesign." }
|
|
551
|
+
};
|
|
539
552
|
function decomposeGateToolInputSchema(gate, phaseProperties) {
|
|
540
553
|
// Advertise every status the Decompose writer accepts, so the schema and the runtime agree.
|
|
541
554
|
const baseProperties = {
|
|
@@ -572,18 +585,7 @@ function decomposeGateToolInputSchema(gate, phaseProperties) {
|
|
|
572
585
|
acceptanceCriteria: { type: "string" },
|
|
573
586
|
planningPacket: { type: "string" },
|
|
574
587
|
sortOrder: { type: "number" },
|
|
575
|
-
|
|
576
|
-
schedule_index: { type: "number", description: "Snake_case alias for scheduleIndex." },
|
|
577
|
-
waveIndex: { type: "number", description: "Feature-to-Story parallel wave number." },
|
|
578
|
-
wave_index: { type: "number", description: "Snake_case alias for waveIndex." },
|
|
579
|
-
featureScheduleIndex: { type: "number", description: "Optional ordering within the Feature." },
|
|
580
|
-
feature_schedule_index: { type: "number", description: "Snake_case alias for featureScheduleIndex." },
|
|
581
|
-
expectedOutput: { type: "string", description: "Durable output this Story should produce for dependents." },
|
|
582
|
-
expected_output: { type: "string", description: "Snake_case alias for expectedOutput." },
|
|
583
|
-
handoffSummary: { type: "string", description: "How dependent Stories should consume this Story output." },
|
|
584
|
-
handoff_summary: { type: "string", description: "Snake_case alias for handoffSummary." },
|
|
585
|
-
dependencyReason: { type: "string", description: "Why this Story depends on its dependsOn predecessors." },
|
|
586
|
-
dependency_reason: { type: "string", description: "Snake_case alias for dependencyReason." },
|
|
588
|
+
...storyCandidateScheduleProperties,
|
|
587
589
|
points: { type: "number" },
|
|
588
590
|
dependsOn: { type: "array", items: { type: "string" } },
|
|
589
591
|
estimatedQaScope: qaScopeSchema("Work Order-to-Feature planning QA estimate. This is not dispatch-authoritative QA scope."),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { qaBlockerReasons, qaCandidateBugActions, qaFindingScopes, qaFindingSeverities, qaGateToolNames, qaScopeAuthorities, qaScopeCapabilities, qaScopeConfidence, qaScopeEvidence, qaScopeFields, qaScopeSources, qaScopeSurfaces } from "./phase-completion.js";
|
|
2
2
|
import { structuredTypeHint } from "./mcp-argument-coercion.js";
|
|
3
|
+
import { validateArchitectWaits } from "./architect-waits.js";
|
|
3
4
|
import { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
|
|
4
5
|
export { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
|
|
5
6
|
export const qaEvidenceGates = new Set(["qa_regression", "qa_api", "qa_manual_web", "qa_bug_repro"]);
|
|
@@ -353,6 +354,7 @@ export function validateQaGatePayloadShape(gate, payload, status) {
|
|
|
353
354
|
}
|
|
354
355
|
}
|
|
355
356
|
export function validateArchitectPayloadShape(payload, status) {
|
|
357
|
+
validateArchitectWaits(payload, status);
|
|
356
358
|
if (status !== "pass") {
|
|
357
359
|
requireArchitectNonPassEvidence(payload);
|
|
358
360
|
return;
|
|
@@ -706,7 +708,7 @@ export function hasArchitectDependencyCycle(edges) {
|
|
|
706
708
|
return false;
|
|
707
709
|
}
|
|
708
710
|
export function requireArchitectNonPassEvidence(payload) {
|
|
709
|
-
const evidenceKeys = ["blockers", "revision_questions", "revision_reasons", "known_gaps", "findings", "remaining_risks", "failures"];
|
|
711
|
+
const evidenceKeys = ["blockers", "revision_questions", "revision_reasons", "waits_on", "owner_decision", "known_gaps", "findings", "remaining_risks", "failures"];
|
|
710
712
|
const hasEvidence = evidenceKeys.some((key) => {
|
|
711
713
|
const value = payload[key];
|
|
712
714
|
if (typeof value === "string") {
|
|
@@ -29,7 +29,8 @@ export declare class PrePublicationValidationError extends ForgeFailureError {
|
|
|
29
29
|
export declare class PrePublicationPass {
|
|
30
30
|
private readonly runtimeRestartFailure?;
|
|
31
31
|
private readonly failures;
|
|
32
|
-
|
|
32
|
+
/** The check whose .NET build failed to compile in this pass, if any. */
|
|
33
|
+
private dotnetCompileFailedIn;
|
|
33
34
|
/** A failed runtime restart before the pass is its first failure. */
|
|
34
35
|
constructor(runtimeRestartFailure?: PrePublicationValidationError | undefined);
|
|
35
36
|
record(failure: PrePublicationCheckFailure, failedStep?: ValidationStep): void;
|
|
@@ -7,7 +7,9 @@ import { ForgeFailureError, failureFactsFromError } from "./session.types.js";
|
|
|
7
7
|
// could not run because a check they depend on failed, and reports them all as one failure.
|
|
8
8
|
/** The check id a failed restart of the attempt's runtime stack before the pass is reported under. */
|
|
9
9
|
export const runtimeRestartCheckId = "host-runtime-restart";
|
|
10
|
-
|
|
10
|
+
// The checks whose first step builds the .NET solution: CI's whole-tier check and the affected
|
|
11
|
+
// tests every gate profile runs (decision 0017).
|
|
12
|
+
const dotnetBuildCheckIds = new Set(["dotnet-build-and-unit", "comment-repair-dotnet-regression"]);
|
|
11
13
|
// Checks that build the .NET solution themselves and would only repeat the compiler errors once its
|
|
12
14
|
// compile step fails: the OpenAPI export builds Forge.Api and the E2E suite publishes it.
|
|
13
15
|
const dotnetBuildConsumers = new Set(["openapi-and-generated-types", "playwright-e2e"]);
|
|
@@ -62,7 +64,8 @@ function clipDetail(detail) {
|
|
|
62
64
|
export class PrePublicationPass {
|
|
63
65
|
runtimeRestartFailure;
|
|
64
66
|
failures = [];
|
|
65
|
-
|
|
67
|
+
/** The check whose .NET build failed to compile in this pass, if any. */
|
|
68
|
+
dotnetCompileFailedIn = null;
|
|
66
69
|
/** A failed runtime restart before the pass is its first failure. */
|
|
67
70
|
constructor(runtimeRestartFailure) {
|
|
68
71
|
this.runtimeRestartFailure = runtimeRestartFailure;
|
|
@@ -70,14 +73,14 @@ export class PrePublicationPass {
|
|
|
70
73
|
}
|
|
71
74
|
record(failure, failedStep) {
|
|
72
75
|
this.failures.push(failure);
|
|
73
|
-
if (failure.checkId
|
|
74
|
-
this.
|
|
76
|
+
if (dotnetBuildCheckIds.has(failure.checkId) && failedStep?.command === "dotnet" && failedStep.args[0] === "build") {
|
|
77
|
+
this.dotnetCompileFailedIn ??= failure.checkId;
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
/** The failed checks that keep this check from running meaningfully in this pass. */
|
|
78
81
|
blockers(checkId) {
|
|
79
82
|
return [
|
|
80
|
-
...(this.
|
|
83
|
+
...(this.dotnetCompileFailedIn && dotnetBuildConsumers.has(checkId) ? [this.dotnetCompileFailedIn] : []),
|
|
81
84
|
...(this.runtimeRestartFailure && runtimeStackConsumers.has(checkId) ? [runtimeRestartCheckId] : []),
|
|
82
85
|
];
|
|
83
86
|
}
|
|
@@ -77,6 +77,8 @@ export declare class PrePublicationValidator {
|
|
|
77
77
|
private checkTestOnlyExports;
|
|
78
78
|
private changedPaths;
|
|
79
79
|
private assertContractMatchesDispatchBaseline;
|
|
80
|
+
/** The approved contract of the branch an in-progress merge brings in (MERGE_HEAD), else null. */
|
|
81
|
+
private mergedInContractDigest;
|
|
80
82
|
private runStep;
|
|
81
83
|
private launchStep;
|
|
82
84
|
private runCommand;
|
|
@@ -23,16 +23,21 @@ const requiredCheckIds = new Set([
|
|
|
23
23
|
"playwright-e2e",
|
|
24
24
|
"github-provider-policy",
|
|
25
25
|
]);
|
|
26
|
-
|
|
26
|
+
// Every gate profile runs the affected .NET tests; only CI runs the whole tiers (decision 0017).
|
|
27
|
+
const currentApprovedContractDigest = "9cf3a3070de56f3d3bc2c013dfa45b0fd463d257722849087e6743fb9cb1fd0d";
|
|
28
|
+
// Only comment repair ran the affected tests; the other profiles ran Unit, Contract and
|
|
29
|
+
// Infrastructure whole. Story branches cut before decision 0017 still carry it.
|
|
30
|
+
const commentRepairOnlyAffectedContractDigest = "378c767c7977c850140ffb19d69db41da62d0187c37a33828d6cda8803a61c83";
|
|
27
31
|
// Comment repair ran the whole ApiComponent and Orchestration tiers under this contract.
|
|
28
|
-
// Story branches cut before the affected-tests contract still carry it.
|
|
29
32
|
const wholeTierCommentRepairContractDigest = "024de3648c907db9c0eab13def9a4f91e81148433e0a2ba7f44776446421054a";
|
|
30
33
|
// Contracts that declare the comment-repair-dotnet-regression check.
|
|
31
34
|
const commentRepairRegressionContractDigests = new Set([
|
|
32
35
|
currentApprovedContractDigest,
|
|
36
|
+
commentRepairOnlyAffectedContractDigest,
|
|
33
37
|
wholeTierCommentRepairContractDigest,
|
|
34
38
|
]);
|
|
35
39
|
const compatibleApprovedContractDigests = new Set([
|
|
40
|
+
commentRepairOnlyAffectedContractDigest,
|
|
36
41
|
wholeTierCommentRepairContractDigest,
|
|
37
42
|
// Preserve dispatches pinned before comment repair gained all .NET regression tiers.
|
|
38
43
|
"c0014ce6abc0e0b2e66dd2bcf6cb14c47d28506444c73f87d1b76b3d1c06027b",
|
|
@@ -139,7 +144,7 @@ export class PrePublicationValidator {
|
|
|
139
144
|
capabilities,
|
|
140
145
|
emit,
|
|
141
146
|
signal,
|
|
142
|
-
execution: scoped.execution,
|
|
147
|
+
execution: withValidationBaseRevision(scoped.execution),
|
|
143
148
|
postgresAdminConnection: scoped.postgresAdminConnection,
|
|
144
149
|
};
|
|
145
150
|
return await this.runChecks(applicableChecks(contract, profile, changedPaths), run, pass);
|
|
@@ -353,10 +358,24 @@ export class PrePublicationValidator {
|
|
|
353
358
|
if (!approvedContractDigests.has(baselineDigest)) {
|
|
354
359
|
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the dispatch baseline uses unapproved CI parity contract ${baselineDigest}.`, "bridge");
|
|
355
360
|
}
|
|
356
|
-
|
|
361
|
+
// A conflict repair's uncommitted merge brings the target branch's contract with it.
|
|
362
|
+
if (baselineDigest !== contractDigest && await this.mergedInContractDigest(worktreePath, signal, execution) !== contractDigest) {
|
|
357
363
|
throw new ForgeFailureError("prepublication_contract_invalid", `prepublication_contract_invalid: the CI parity contract changed after dispatch (baseline ${baselineDigest}, worktree ${contractDigest}).`, "bridge");
|
|
358
364
|
}
|
|
359
365
|
}
|
|
366
|
+
/** The approved contract of the branch an in-progress merge brings in (MERGE_HEAD), else null. */
|
|
367
|
+
async mergedInContractDigest(worktreePath, signal, execution) {
|
|
368
|
+
const merged = await this.runCommand("git", ["show", `MERGE_HEAD:${contractRelativePath}`], worktreePath, signal, execution);
|
|
369
|
+
if (merged.exitCode !== 0)
|
|
370
|
+
return null;
|
|
371
|
+
try {
|
|
372
|
+
const digest = validationContractDigest(JSON.parse(merged.stdout ?? ""));
|
|
373
|
+
return approvedContractDigests.has(digest) ? digest : null;
|
|
374
|
+
}
|
|
375
|
+
catch {
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
360
379
|
async runStep(checkId, step, cwd, signal, execution, postgresAdminConnection, emit) {
|
|
361
380
|
const invocation = managedAttemptInvocation(checkId, step, execution?.environment);
|
|
362
381
|
// Every launch, including confirmation reruns, is admitted by the host load governor first.
|
|
@@ -626,6 +645,13 @@ export async function loadValidationContract(worktreePath) {
|
|
|
626
645
|
}
|
|
627
646
|
return contract;
|
|
628
647
|
}
|
|
648
|
+
/** The affected .NET tests measure the attempt's change against its dispatch baseline (run-affected-dotnet-tests.mjs). */
|
|
649
|
+
function withValidationBaseRevision(execution) {
|
|
650
|
+
const baseline = execution?.baselineRevision?.trim();
|
|
651
|
+
if (!baseline)
|
|
652
|
+
return execution;
|
|
653
|
+
return { ...execution, environment: { ...execution?.environment, FORGE_VALIDATION_BASE_REVISION: baseline } };
|
|
654
|
+
}
|
|
629
655
|
function validationContractDigest(contract) {
|
|
630
656
|
return createHash("sha256")
|
|
631
657
|
.update(JSON.stringify(canonicalizeJson(contract)))
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ForgeFailureError } from "../session.types.js";
|
|
2
|
+
import type { ProviderProcessHandlers, ProviderProcessRunner, ProviderProcessRunRequest, ProviderProcessRunResult } from "./provider-cli.process.js";
|
|
3
|
+
/**
|
|
4
|
+
* Removes the `run_in_background` parameter from Bash, PowerShell and the Agent tool, runs
|
|
5
|
+
* forked subagents and forked skills in the foreground, and stops Claude Code from moving long
|
|
6
|
+
* shell commands, subagents and MCP calls to the background on its own. Cron disables the
|
|
7
|
+
* session-scoped scheduled tasks (`CronCreate`, `/loop`). Applied last, so a project's runtime
|
|
8
|
+
* environment cannot turn them back on.
|
|
9
|
+
*/
|
|
10
|
+
export declare const claudeHeadlessEnvironment: Readonly<Record<string, string>>;
|
|
11
|
+
/**
|
|
12
|
+
* Tools whose only purpose is work that reports after the turn. `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS`
|
|
13
|
+
* leaves Monitor running in the background, so it is removed here, together with self-paced
|
|
14
|
+
* wakeups, workflows (which run their agents in the background), cloud routines, cron
|
|
15
|
+
* (also disabled by environment), SendMessage, which resumes an earlier subagent in the
|
|
16
|
+
* background, and agent teams, whose teammates run alongside the turn. Foreground subagents
|
|
17
|
+
* stay available: they block the turn until they finish.
|
|
18
|
+
*/
|
|
19
|
+
export declare const claudeHeadlessDisallowedTools: readonly string[];
|
|
20
|
+
/**
|
|
21
|
+
* The Claude Code arguments that apply the restrictions: the tool deny list, and the environment
|
|
22
|
+
* again as flag settings, which outrank a user's or repository's settings `env` block.
|
|
23
|
+
*/
|
|
24
|
+
export declare function claudeHeadlessToolArgs(): readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* The provider ended its turn while background work it started (a background subagent or
|
|
27
|
+
* shell, a Monitor watch, a wakeup) was still live. Claude Code withholds the turn's terminal
|
|
28
|
+
* result for such work, and nothing started in the background reports to Forge, so Forge stops
|
|
29
|
+
* the provider at once instead of waiting for an idle watchdog. Retryable: the harness, not the
|
|
30
|
+
* task, ended the run.
|
|
31
|
+
*/
|
|
32
|
+
export declare function providerTurnEndedWithBackgroundWorkFailure(message: string): ForgeFailureError;
|
|
33
|
+
/**
|
|
34
|
+
* Fails every provider run Forge stopped because its turn ended with background work still live,
|
|
35
|
+
* whether or not the turn recorded a completion first: the stop cut that work short, so nothing
|
|
36
|
+
* may validate, commit or publish the worktree it left behind.
|
|
37
|
+
*/
|
|
38
|
+
export declare class BackgroundWorkStopFailingRunner implements ProviderProcessRunner {
|
|
39
|
+
private readonly inner;
|
|
40
|
+
constructor(inner: ProviderProcessRunner);
|
|
41
|
+
run(request: ProviderProcessRunRequest, handlers?: ProviderProcessHandlers, signal?: AbortSignal): Promise<ProviderProcessRunResult>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Recognizes a main-conversation turn that ended while background tasks it started were still
|
|
45
|
+
* live, the case in which Claude Code withholds the turn's `result`. The turn end is Claude
|
|
46
|
+
* Code's `post_turn_summary` event; the live set is the documented `background_tasks_changed`
|
|
47
|
+
* event (Claude Code's own `ambient` tasks and `awaited` ones do not count). After `graceMs`
|
|
48
|
+
* without the result or new main-conversation activity, it calls `onTurnEndedWithBackgroundWork`
|
|
49
|
+
* once, so the runner can stop the provider instead of waiting on work no one will collect.
|
|
50
|
+
*/
|
|
51
|
+
export declare class ClaudeBackgroundTurnEndWatch {
|
|
52
|
+
private readonly graceMs;
|
|
53
|
+
private readonly onTurnEndedWithBackgroundWork;
|
|
54
|
+
private liveBackgroundTasks;
|
|
55
|
+
private terminalSinceMainActivity;
|
|
56
|
+
private mainTurnEnded;
|
|
57
|
+
private timer;
|
|
58
|
+
private stopped;
|
|
59
|
+
private readonly enabled;
|
|
60
|
+
/** Watches only Claude Code, by its executable `command`; other output is left alone. */
|
|
61
|
+
constructor(command: string, graceMs: number, onTurnEndedWithBackgroundWork: () => void);
|
|
62
|
+
consume(line: string): void;
|
|
63
|
+
stop(): void;
|
|
64
|
+
private armIfTurnEndedWithBackgroundWork;
|
|
65
|
+
private cancel;
|
|
66
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless Claude Code runs must not start work that outlives the turn.
|
|
3
|
+
*
|
|
4
|
+
* Forge runs `claude -p` and treats the turn's terminal `result` event as the end of the run.
|
|
5
|
+
* When background work is still live at the end of a turn (a background subagent or shell, a
|
|
6
|
+
* Monitor watch, a scheduled wakeup), Claude Code withholds that `result` and keeps the process
|
|
7
|
+
* open for the work, so Forge sees a silent provider instead of a finished one. The launch
|
|
8
|
+
* restrictions below remove the ways to start such work; `ClaudeBackgroundTurnEndWatch` is the
|
|
9
|
+
* backstop for anything that still gets through.
|
|
10
|
+
*/
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { ForgeFailureError } from "../session.types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Removes the `run_in_background` parameter from Bash, PowerShell and the Agent tool, runs
|
|
15
|
+
* forked subagents and forked skills in the foreground, and stops Claude Code from moving long
|
|
16
|
+
* shell commands, subagents and MCP calls to the background on its own. Cron disables the
|
|
17
|
+
* session-scoped scheduled tasks (`CronCreate`, `/loop`). Applied last, so a project's runtime
|
|
18
|
+
* environment cannot turn them back on.
|
|
19
|
+
*/
|
|
20
|
+
export const claudeHeadlessEnvironment = Object.freeze({
|
|
21
|
+
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS: "1",
|
|
22
|
+
CLAUDE_CODE_DISABLE_CRON: "1",
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Tools whose only purpose is work that reports after the turn. `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS`
|
|
26
|
+
* leaves Monitor running in the background, so it is removed here, together with self-paced
|
|
27
|
+
* wakeups, workflows (which run their agents in the background), cloud routines, cron
|
|
28
|
+
* (also disabled by environment), SendMessage, which resumes an earlier subagent in the
|
|
29
|
+
* background, and agent teams, whose teammates run alongside the turn. Foreground subagents
|
|
30
|
+
* stay available: they block the turn until they finish.
|
|
31
|
+
*/
|
|
32
|
+
export const claudeHeadlessDisallowedTools = Object.freeze([
|
|
33
|
+
"Monitor",
|
|
34
|
+
"ScheduleWakeup",
|
|
35
|
+
"Workflow",
|
|
36
|
+
"RemoteTrigger",
|
|
37
|
+
"CronCreate",
|
|
38
|
+
"SendMessage",
|
|
39
|
+
"TeamCreate",
|
|
40
|
+
]);
|
|
41
|
+
/**
|
|
42
|
+
* The Claude Code arguments that apply the restrictions: the tool deny list, and the environment
|
|
43
|
+
* again as flag settings, which outrank a user's or repository's settings `env` block.
|
|
44
|
+
*/
|
|
45
|
+
export function claudeHeadlessToolArgs() {
|
|
46
|
+
return [
|
|
47
|
+
"--disallowedTools", claudeHeadlessDisallowedTools.join(","),
|
|
48
|
+
"--settings", JSON.stringify({ env: claudeHeadlessEnvironment }),
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The provider ended its turn while background work it started (a background subagent or
|
|
53
|
+
* shell, a Monitor watch, a wakeup) was still live. Claude Code withholds the turn's terminal
|
|
54
|
+
* result for such work, and nothing started in the background reports to Forge, so Forge stops
|
|
55
|
+
* the provider at once instead of waiting for an idle watchdog. Retryable: the harness, not the
|
|
56
|
+
* task, ended the run.
|
|
57
|
+
*/
|
|
58
|
+
export function providerTurnEndedWithBackgroundWorkFailure(message) {
|
|
59
|
+
return new ForgeFailureError("provider_turn_ended_with_background_work", `${message} The provider ended its turn while background work it started was still running, so it never delivered a terminal result; Forge stopped it instead of waiting.`);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fails every provider run Forge stopped because its turn ended with background work still live,
|
|
63
|
+
* whether or not the turn recorded a completion first: the stop cut that work short, so nothing
|
|
64
|
+
* may validate, commit or publish the worktree it left behind.
|
|
65
|
+
*/
|
|
66
|
+
export class BackgroundWorkStopFailingRunner {
|
|
67
|
+
inner;
|
|
68
|
+
constructor(inner) {
|
|
69
|
+
this.inner = inner;
|
|
70
|
+
}
|
|
71
|
+
async run(request, handlers, signal) {
|
|
72
|
+
const result = await this.inner.run(request, handlers, signal);
|
|
73
|
+
if (result.terminalStopReason === "turn_ended_with_background_work") {
|
|
74
|
+
throw providerTurnEndedWithBackgroundWorkFailure("The provider turn did not finish.");
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Recognizes a main-conversation turn that ended while background tasks it started were still
|
|
81
|
+
* live, the case in which Claude Code withholds the turn's `result`. The turn end is Claude
|
|
82
|
+
* Code's `post_turn_summary` event; the live set is the documented `background_tasks_changed`
|
|
83
|
+
* event (Claude Code's own `ambient` tasks and `awaited` ones do not count). After `graceMs`
|
|
84
|
+
* without the result or new main-conversation activity, it calls `onTurnEndedWithBackgroundWork`
|
|
85
|
+
* once, so the runner can stop the provider instead of waiting on work no one will collect.
|
|
86
|
+
*/
|
|
87
|
+
export class ClaudeBackgroundTurnEndWatch {
|
|
88
|
+
graceMs;
|
|
89
|
+
onTurnEndedWithBackgroundWork;
|
|
90
|
+
liveBackgroundTasks = 0;
|
|
91
|
+
terminalSinceMainActivity = false;
|
|
92
|
+
mainTurnEnded = false;
|
|
93
|
+
timer = null;
|
|
94
|
+
stopped = false;
|
|
95
|
+
enabled;
|
|
96
|
+
/** Watches only Claude Code, by its executable `command`; other output is left alone. */
|
|
97
|
+
constructor(command, graceMs, onTurnEndedWithBackgroundWork) {
|
|
98
|
+
this.graceMs = graceMs;
|
|
99
|
+
this.onTurnEndedWithBackgroundWork = onTurnEndedWithBackgroundWork;
|
|
100
|
+
this.enabled = path.parse(command).name.toLowerCase() === "claude";
|
|
101
|
+
}
|
|
102
|
+
consume(line) {
|
|
103
|
+
if (!this.enabled || this.stopped)
|
|
104
|
+
return;
|
|
105
|
+
const event = parseStreamEvent(line);
|
|
106
|
+
if (!event)
|
|
107
|
+
return;
|
|
108
|
+
if (isTerminalEvent(event)) {
|
|
109
|
+
this.terminalSinceMainActivity = true;
|
|
110
|
+
this.cancel();
|
|
111
|
+
}
|
|
112
|
+
else if (event.type === "system" && event.subtype === "background_tasks_changed") {
|
|
113
|
+
this.liveBackgroundTasks = liveBackgroundTaskCount(event.tasks);
|
|
114
|
+
// The work settled: Claude Code now delivers the result or starts a turn for it, and a
|
|
115
|
+
// follow-up turn can think for a while before its first event.
|
|
116
|
+
if (this.liveBackgroundTasks === 0)
|
|
117
|
+
this.cancel();
|
|
118
|
+
// A task can be reported just after the turn summary, as the turn ends.
|
|
119
|
+
else if (this.mainTurnEnded)
|
|
120
|
+
this.armIfTurnEndedWithBackgroundWork();
|
|
121
|
+
}
|
|
122
|
+
else if (event.type === "system" && event.subtype === "post_turn_summary") {
|
|
123
|
+
this.mainTurnEnded = true;
|
|
124
|
+
this.armIfTurnEndedWithBackgroundWork();
|
|
125
|
+
}
|
|
126
|
+
else if ((event.type === "assistant" || event.type === "user") && !event.parent_tool_use_id) {
|
|
127
|
+
// The main conversation is working again (a new turn, or a turn that is still going).
|
|
128
|
+
this.terminalSinceMainActivity = false;
|
|
129
|
+
this.mainTurnEnded = false;
|
|
130
|
+
this.cancel();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
stop() {
|
|
134
|
+
this.stopped = true;
|
|
135
|
+
this.cancel();
|
|
136
|
+
}
|
|
137
|
+
armIfTurnEndedWithBackgroundWork() {
|
|
138
|
+
if (this.timer || this.terminalSinceMainActivity || this.liveBackgroundTasks === 0)
|
|
139
|
+
return;
|
|
140
|
+
this.timer = setTimeout(() => {
|
|
141
|
+
this.timer = null;
|
|
142
|
+
this.stopped = true;
|
|
143
|
+
this.onTurnEndedWithBackgroundWork();
|
|
144
|
+
}, this.graceMs);
|
|
145
|
+
this.timer.unref?.();
|
|
146
|
+
}
|
|
147
|
+
cancel() {
|
|
148
|
+
if (!this.timer)
|
|
149
|
+
return;
|
|
150
|
+
clearTimeout(this.timer);
|
|
151
|
+
this.timer = null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function parseStreamEvent(line) {
|
|
155
|
+
const trimmed = line.trim();
|
|
156
|
+
if (!trimmed.startsWith("{"))
|
|
157
|
+
return null;
|
|
158
|
+
try {
|
|
159
|
+
const parsed = JSON.parse(trimmed);
|
|
160
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function isTerminalEvent(event) {
|
|
167
|
+
return event.type === "result" || event.type === "error";
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Tasks that keep the turn's result back: not Claude Code's own `ambient` tasks, and not
|
|
171
|
+
* `awaited` ones, which a still-running tool call of the turn waits for.
|
|
172
|
+
*/
|
|
173
|
+
function liveBackgroundTaskCount(tasks) {
|
|
174
|
+
if (!Array.isArray(tasks))
|
|
175
|
+
return 0;
|
|
176
|
+
return tasks.filter(task => {
|
|
177
|
+
const entry = task && typeof task === "object" ? task : {};
|
|
178
|
+
return entry.ambient !== true && entry.awaited !== true;
|
|
179
|
+
}).length;
|
|
180
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ProviderChildEnvironmentOptions {
|
|
2
|
+
readonly parentEnv?: NodeJS.ProcessEnv;
|
|
3
|
+
readonly platform?: NodeJS.Platform;
|
|
4
|
+
readonly homeDir?: string;
|
|
5
|
+
readonly arch?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function buildProviderChildEnvironment(requestEnv?: Readonly<Record<string, string>>, options?: ProviderChildEnvironmentOptions): NodeJS.ProcessEnv;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import { normalizeWindowsProviderEnvironment, windowsAllowedProviderParentEnvNames } from "./provider-cli.windows-environment.js";
|
|
3
|
+
// The environment a provider child process starts with: an allowlist of the Bridge's own
|
|
4
|
+
// variables, the request's values, the Windows defaults, then the .NET build-server settings.
|
|
5
|
+
const allowedProviderParentEnvNames = [
|
|
6
|
+
"PATH",
|
|
7
|
+
"HOME",
|
|
8
|
+
"USERPROFILE",
|
|
9
|
+
"TMPDIR",
|
|
10
|
+
"TEMP",
|
|
11
|
+
"TMP",
|
|
12
|
+
"LANG",
|
|
13
|
+
"CLAUDE_CONFIG_DIR"
|
|
14
|
+
];
|
|
15
|
+
export function buildProviderChildEnvironment(requestEnv, options = {}) {
|
|
16
|
+
const parentEnv = options.parentEnv ?? process.env;
|
|
17
|
+
const platform = options.platform ?? process.platform;
|
|
18
|
+
const env = {};
|
|
19
|
+
for (const [key, value] of Object.entries(parentEnv)) {
|
|
20
|
+
if (typeof value === "string" && isAllowedProviderParentEnv(key, platform)) {
|
|
21
|
+
env[key] = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (requestEnv) {
|
|
25
|
+
for (const [key, value] of Object.entries(requestEnv)) {
|
|
26
|
+
const trimmedKey = key.trim();
|
|
27
|
+
if (trimmedKey.length > 0) {
|
|
28
|
+
env[trimmedKey] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (platform === "win32") {
|
|
33
|
+
normalizeWindowsProviderEnvironment(env, parentEnv, options.homeDir ?? os.homedir(), options.arch ?? os.arch());
|
|
34
|
+
}
|
|
35
|
+
normalizeProviderBuildEnvironment(env);
|
|
36
|
+
return env;
|
|
37
|
+
}
|
|
38
|
+
function normalizeProviderBuildEnvironment(env) {
|
|
39
|
+
// Provider sessions are long lived and commonly run many dotnet builds. Persistent
|
|
40
|
+
// MSBuild and Roslyn compiler servers otherwise survive individual commands and can
|
|
41
|
+
// retain more memory than the active Forge lane. Keep those caches process-scoped by
|
|
42
|
+
// default on every runner OS; an explicitly supplied request value still wins.
|
|
43
|
+
setCanonicalProviderBuildEnvironmentValue(env, "DOTNET_CLI_USE_MSBUILD_SERVER", "0");
|
|
44
|
+
setCanonicalProviderBuildEnvironmentValue(env, "MSBUILDDISABLENODEREUSE", "1");
|
|
45
|
+
setCanonicalProviderBuildEnvironmentValue(env, "UseSharedCompilation", "false");
|
|
46
|
+
}
|
|
47
|
+
function setCanonicalProviderBuildEnvironmentValue(env, name, value) {
|
|
48
|
+
// The dotnet CLI uses case-sensitive environment lookup on POSIX, while MSBuild
|
|
49
|
+
// property names are case-insensitive on every OS. Collapse request aliases to
|
|
50
|
+
// one canonical key so the explicit value wins without producing ambiguity.
|
|
51
|
+
const exact = env[name];
|
|
52
|
+
const alias = Object.entries(env).find(([key, candidate]) => key !== name
|
|
53
|
+
&& key.toLowerCase() === name.toLowerCase()
|
|
54
|
+
&& typeof candidate === "string"
|
|
55
|
+
&& candidate.trim().length > 0)?.[1];
|
|
56
|
+
const resolved = typeof exact === "string" && exact.trim().length > 0
|
|
57
|
+
? exact
|
|
58
|
+
: alias ?? value;
|
|
59
|
+
for (const key of Object.keys(env)) {
|
|
60
|
+
if (key !== name && key.toLowerCase() === name.toLowerCase()) {
|
|
61
|
+
delete env[key];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
env[name] = resolved;
|
|
65
|
+
}
|
|
66
|
+
function isAllowedProviderParentEnv(key, platform = process.platform) {
|
|
67
|
+
return isAllowedProviderParentEnvName(key, allowedProviderParentEnvNames)
|
|
68
|
+
|| key.toUpperCase().startsWith("LC_")
|
|
69
|
+
|| (platform === "win32" && isAllowedProviderParentEnvName(key, windowsAllowedProviderParentEnvNames));
|
|
70
|
+
}
|
|
71
|
+
function isAllowedProviderParentEnvName(key, allowedNames) {
|
|
72
|
+
return allowedNames.some((allowed) => allowed.toLowerCase() === key.toLowerCase());
|
|
73
|
+
}
|