forgedock 1.67.0 → 1.69.0
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/bin/config-schema.mjs +1 -0
- package/bin/engine/outcome-codes.mjs +1 -0
- package/bin/engine-cli.mjs +103 -21
- package/bin/engine.mjs +10 -0
- package/bin/forgedock.mjs +17 -1
- package/bin/help-text.mjs +1 -0
- package/bin/lean/admission.mjs +21 -0
- package/bin/lean/admission.test.mjs +30 -0
- package/bin/lean/advisory.test.mjs +39 -15
- package/bin/lean/amendment-schema.mjs +3 -4
- package/bin/lean/attempts.mjs +34 -31
- package/bin/lean/attempts.test.mjs +33 -19
- package/bin/lean/basered.mjs +26 -0
- package/bin/lean/batch-health.mjs +17 -12
- package/bin/lean/batch-health.test.mjs +39 -11
- package/bin/lean/batch.mjs +11 -1
- package/bin/lean/batch.test.mjs +51 -2
- package/bin/lean/capsample.mjs +25 -0
- package/bin/lean/ci-gate.mjs +2 -90
- package/bin/lean/ci-gate.test.mjs +1 -127
- package/bin/lean/ci-precheck.mjs +25 -8
- package/bin/lean/ci-precheck.test.mjs +24 -0
- package/bin/lean/clear-breaker.test.mjs +4 -3
- package/bin/lean/commentstate.mjs +10 -5
- package/bin/lean/commentstate.test.mjs +12 -1
- package/bin/lean/conformance.e2e.test.mjs +9 -6
- package/bin/lean/conformance.mjs +62 -197
- package/bin/lean/conformance.test.mjs +46 -376
- package/bin/lean/depcache.mjs +102 -10
- package/bin/lean/depcache.test.mjs +105 -0
- package/bin/lean/docsgate.mjs +0 -32
- package/bin/lean/docsgate.test.mjs +2 -23
- package/bin/lean/effects-cap.test.mjs +9 -1
- package/bin/lean/effects-killtree.test.mjs +35 -0
- package/bin/lean/effects.mjs +57 -25
- package/bin/lean/engine-readmit.test.mjs +35 -0
- package/bin/lean/envgap.mjs +111 -0
- package/bin/lean/envgap.test.mjs +64 -0
- package/bin/lean/execution.mjs +13 -4
- package/bin/lean/execution.test.mjs +33 -0
- package/bin/lean/failure-census.mjs +170 -0
- package/bin/lean/failure-census.test.mjs +59 -0
- package/bin/lean/failure-stop.mjs +12 -1
- package/bin/lean/failure-stop.test.mjs +14 -1
- package/bin/lean/guardgate.test.mjs +2 -3
- package/bin/lean/heavy.mjs +33 -4
- package/bin/lean/heavy.test.mjs +38 -6
- package/bin/lean/hostconfig.mjs +54 -0
- package/bin/lean/hostconfig.test.mjs +67 -0
- package/bin/lean/hotarea.mjs +0 -36
- package/bin/lean/hotarea.test.mjs +1 -22
- package/bin/lean/issuewatch-verify.mjs +19 -4
- package/bin/lean/issuewatch.mjs +21 -4
- package/bin/lean/issuewatch.test.mjs +48 -1
- package/bin/lean/lane-audit-gap.mjs +66 -0
- package/bin/lean/lane-audit-gap.test.mjs +59 -0
- package/bin/lean/lane-audit-llm.mjs +52 -0
- package/bin/lean/lane-audit-llm.test.mjs +57 -0
- package/bin/lean/lane-audit-query.mjs +47 -0
- package/bin/lean/lane-audit-query.test.mjs +44 -0
- package/bin/lean/lane-audit-signatures.mjs +33 -0
- package/bin/lean/lane-audit.mjs +110 -0
- package/bin/lean/lane-audit.test.mjs +97 -0
- package/bin/lean/lane-recovery.test.mjs +33 -0
- package/bin/lean/lanecheck.mjs +5 -3
- package/bin/lean/lanecheck.test.mjs +6 -0
- package/bin/lean/lean.mjs +247 -152
- package/bin/lean/lean.test.mjs +502 -206
- package/bin/lean/limits.mjs +17 -0
- package/bin/lean/limits.test.mjs +15 -1
- package/bin/lean/live-execution.mjs +24 -2
- package/bin/lean/live-execution.test.mjs +62 -0
- package/bin/lean/orchestrate-attempts.test.mjs +17 -9
- package/bin/lean/orchestrate-dispatch-placement.test.mjs +81 -0
- package/bin/lean/orchestrate-envhold.test.mjs +62 -1
- package/bin/lean/orchestrate-heldroot.test.mjs +72 -0
- package/bin/lean/orchestrate-hostfallback.test.mjs +59 -1
- package/bin/lean/orchestrate-overload-recovery.test.mjs +37 -0
- package/bin/lean/orchestrate-pause.test.mjs +53 -1
- package/bin/lean/orchestrate-reconcile.test.mjs +17 -0
- package/bin/lean/orchestrate-relaunch-gates.test.mjs +57 -0
- package/bin/lean/orchestrate-stacking.test.mjs +10 -0
- package/bin/lean/orchestrate.mjs +215 -42
- package/bin/lean/postdeploy-check.test.mjs +1 -3
- package/bin/lean/precheck.mjs +20 -0
- package/bin/lean/preflight.mjs +110 -14
- package/bin/lean/preflight.test.mjs +64 -4
- package/bin/lean/prompts.mjs +11 -21
- package/bin/lean/recurrence.mjs +6 -148
- package/bin/lean/recurrence.test.mjs +11 -147
- package/bin/lean/release-deploy.mjs +35 -5
- package/bin/lean/release-deploy.test.mjs +50 -3
- package/bin/lean/release-flakes.mjs +48 -2
- package/bin/lean/release-flakes.test.mjs +45 -1
- package/bin/lean/release-ledger.mjs +19 -1
- package/bin/lean/release-ledger.test.mjs +23 -0
- package/bin/lean/release-preflight.mjs +28 -0
- package/bin/lean/release-preflight.test.mjs +42 -1
- package/bin/lean/release-review.mjs +40 -5
- package/bin/lean/release-review.test.mjs +43 -2
- package/bin/lean/release.mjs +45 -15
- package/bin/lean/release.test.mjs +32 -0
- package/bin/lean/retry.mjs +1 -1
- package/bin/lean/retry.test.mjs +6 -1
- package/bin/lean/rotator.mjs +9 -0
- package/bin/lean/rotator.test.mjs +11 -1
- package/bin/lean/sandbox-remote.mjs +51 -13
- package/bin/lean/schedd.mjs +13 -8
- package/bin/lean/schedd.test.mjs +65 -5
- package/bin/lean/selfreview.mjs +1 -1
- package/bin/lean/statuscomment.mjs +4 -1
- package/bin/lean/validate-catalog.mjs +108 -0
- package/bin/lean/validate-catalog.test.mjs +46 -1
- package/bin/lean/verify.mjs +1 -1
- package/bin/pool/affinity.test.mjs +91 -0
- package/bin/pool/agent.mjs +247 -23
- package/bin/pool/cache-sweep.mjs +31 -10
- package/bin/pool/ci-autoscale.mjs +160 -0
- package/bin/pool/cli.mjs +56 -9
- package/bin/pool/docker.mjs +5 -0
- package/bin/pool/engine-placement.test.mjs +94 -0
- package/bin/pool/image-manifest.mjs +24 -0
- package/bin/pool/image-manifest.test.mjs +20 -0
- package/bin/pool/lane-target.mjs +41 -0
- package/bin/pool/lane-tools.mjs +29 -5
- package/bin/pool/lane-tools.test.mjs +36 -7
- package/bin/pool/mirror-seed.mjs +15 -11
- package/bin/pool/project-layer.mjs +142 -0
- package/bin/pool/project-layer.test.mjs +73 -0
- package/bin/pool/router.mjs +106 -36
- package/bin/pool/version.mjs +72 -2
- package/bin/review-staging.mjs +11 -3
- package/bin/runner.mjs +59 -11
- package/bin/stats/release.mjs +7 -0
- package/bin/stats/release.test.mjs +20 -0
- package/bin/stats/scorecard.mjs +187 -0
- package/bin/stats/scorecard.test.mjs +89 -0
- package/bin/stats/tool-parks.mjs +29 -0
- package/bin/stats/tool-parks.test.mjs +21 -0
- package/docs/CONFIG.md +41 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/docs/STATS.md +17 -0
- package/package.json +1 -1
- package/pool/image/Dockerfile +15 -3
- package/pool/image/manifest.json +25 -0
- package/pool/image/mirror.sh +11 -2
- package/pool/install/install-agent.ps1 +11 -4
- package/scripts/ci-local/adapters/github-actions.mjs +8 -0
- package/scripts/ci-local/cli.mjs +1 -1
- package/scripts/ci-local/plan.mjs +3 -2
- package/scripts/ci-local.test.sh +14 -2
- package/scripts/failure-census.mjs +67 -0
- package/scripts/review-finalize.sh +5 -5
- package/scripts/review-finalize.test.sh +8 -1
- package/scripts/verify-phase-trail.sh +11 -0
- package/scripts/verify-phase-trail.test.sh +9 -0
package/bin/lean/lean.mjs
CHANGED
|
@@ -23,21 +23,21 @@ import { createHash, randomBytes } from "node:crypto";
|
|
|
23
23
|
import { otherLaneOwner } from "./lanelock.mjs";
|
|
24
24
|
import { stampText, checkStamp } from "./stagestamp.mjs";
|
|
25
25
|
import { acquireBranchLock, waitPidsExit } from "./branchlock.mjs";
|
|
26
|
-
import { parseRecurrenceConfig
|
|
27
|
-
import { areaOf, acquireHotArea
|
|
28
|
-
import { isEnvValidateFailure, outputTail, contractRuleCounts, onlyTestPlanProblems, isTestPath, applyValidateRecipes, rewriteProjectDirCommand, deferChecklessPostDeploy, autoPostDeployE2e, applyRequirementDecisions, dedupeAddRequirements, loneE2eRows, reproEnvMiss, resolveForgedockPaths, resolvingIo, portableForgedockPaths, FORGEDOCK_CHECKS_VAR, FORGEDOCK_ENTRY_VAR, describesUnrunnableCommand, removedPathsOf, TRACKED, normalizeKindModes, blockingFailures, splitAdvisory, unverifiedRequirements, mutationTargets, mutationFailures, runMutationCheck, MUTATION_SURVIVED, isBugIssue, scopeText, explainFailures, inIssue, validateContract, snapQuotes, cliUsageError, normalizeRunnerCommand, applyAmendments,
|
|
29
|
-
import { checkAdmission, hostParallelism, ADMISSION_RETRY_SECONDS } from "./admission.mjs";
|
|
26
|
+
import { parseRecurrenceConfig } from "./recurrence.mjs"; // #5751: hot-area locks only; recurrence design routing was cut (#6083)
|
|
27
|
+
import { areaOf, acquireHotArea } from "./hotarea.mjs"; // #5751
|
|
28
|
+
import { isEnvValidateFailure, outputTail, contractRuleCounts, onlyTestPlanProblems, isTestPath, applyValidateRecipes, rewriteProjectDirCommand, deferChecklessPostDeploy, autoPostDeployE2e, applyRequirementDecisions, dedupeAddRequirements, loneE2eRows, reproEnvMiss, resolveForgedockPaths, resolvingIo, portableForgedockPaths, FORGEDOCK_CHECKS_VAR, FORGEDOCK_ENTRY_VAR, describesUnrunnableCommand, removedPathsOf, TRACKED, normalizeKindModes, blockingFailures, splitAdvisory, unverifiedRequirements, mutationTargets, mutationFailures, runMutationCheck, MUTATION_SURVIVED, isBugIssue, scopeText, explainFailures, inIssue, validateContract, snapQuotes, cliUsageError, normalizeRunnerCommand, applyAmendments, precheck, alreadyFixedOnBase, READONLY_PROD_RE, EXTERNAL_NEED_RE, intakeHostWork, repoTracks, dropScopeValidates, tagOutOfBand, parseReview, decide, mergeReviewRows, reaskable, criterionLines, closePlan, followupItems, renderPendingFollowups, bucketTally, pendingTracking, unnamedEdges, structureNote, convertDelivered } from "./conformance.mjs";
|
|
29
|
+
import { checkAdmission, hostParallelism, quotaCores, ADMISSION_RETRY_SECONDS } from "./admission.mjs";
|
|
30
30
|
import { namedPaths, isTrustedIssueComment, prodFailureSignal } from "./prefilter.mjs";
|
|
31
|
-
import {
|
|
32
|
-
import { writeStatus, postUpsert, postKeyed, isKeyedPost, isStatusPost, isUpsertPost, hasSection, clearPipelineLabels, IN_PLACE_MARKERS, commentId } from "./statuscomment.mjs";
|
|
31
|
+
import { writeStatus, postUpsert, postKeyed, isKeyedPost, isStatusPost, isUpsertPost, hasSection, clearPipelineLabels, IN_PLACE_MARKERS, commentId, contractKey } from "./statuscomment.mjs";
|
|
33
32
|
import { decidePost } from "./commentstate.mjs"; // #5979
|
|
34
33
|
import { repeatSignature, countIdentical, shouldPark, summaryComment } from "./failure-stop.mjs"; // #5979
|
|
35
34
|
import { checksAt, mergeCheckEntries, CHECKS_FILE } from "./postdeploy-check.mjs";
|
|
36
35
|
import { matchBaselines, baselineFailures, foldRegression } from "./baselines.mjs";
|
|
37
36
|
import { readRollouts, detectNewOffKeys, rolloutModes, liveDeferralBlocks } from "./activation.mjs";
|
|
38
37
|
import { toolMisses } from "./toolplace.mjs";
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
38
|
+
import { loadImageManifest, manifestProvides } from "../pool/image-manifest.mjs";
|
|
39
|
+
import { hasRecipe, installLaneTools, genericInstallCommands, missingPythonModules, RECIPES } from "../pool/lane-tools.mjs";
|
|
40
|
+
import { testRunnerProblems, hostOnlyProblems, preflightProbes, preflightProblems, hostEnvDefects, unsetEnvVars, runPreflight, knownToContract, declaredEnv, depInstallFailures, toolMissingInstalls, testRunSummary, projectBinDirs, withLocalBins, manifestDepOwner, collectOnlyCommand, collectImportMiss, contractCommands } from "./preflight.mjs";
|
|
41
41
|
import { resolveLane, isDefaultLane, isShippedLane, DEFAULT_STAGING_BRANCH } from "./lane.mjs";
|
|
42
42
|
import { splitGate, rationaleLine } from "./decompose.mjs";
|
|
43
43
|
import { ceilingFor, modelInfo, restartDecision, DEFAULT_CEILING, WINDOW_SHARE, RESTART_COST_USD, CACHE_READ_USD, REAL_LIMIT_SHARE, predictRestart, handoffFacts, routeHandoff, buildReadsOf, NARROW_NOTE } from "./ceiling.mjs";
|
|
@@ -45,16 +45,18 @@ import { dockerLabels, LEDGER_TTL_MS } from "./ledger.mjs";
|
|
|
45
45
|
import { batchImageCache, envNamesOf, provisionSandboxes } from "./testsandbox.mjs";
|
|
46
46
|
import { repoKey, estimateCostUsd } from "../runner.mjs";
|
|
47
47
|
import { depcacheNamespace } from "./depcache.mjs";
|
|
48
|
+
import { laneConfigEnv } from "./hostconfig.mjs"; // #5917
|
|
48
49
|
import { prepareToolchain } from "./toolchain.mjs";
|
|
49
50
|
import { toolStats } from "./toolstats.mjs";
|
|
50
51
|
import { readTestMap, readTestMapAtRef, selectCommands, mergeChecks, factsPath, TEST_MAP_FILE } from "./testmap.mjs";
|
|
51
52
|
import { deriveCiPrecheck, ciPrecheckOutcome, parseCiPrecheckConfig } from "./ci-precheck.mjs";
|
|
52
|
-
import { runChecks, runWithTimeoutRetry, splitPrecheckResults, timedOutDetail, planPrecheck, worktreeFingerprint, selfCheckState, quietFailure, CHECK_PLAN_FILE, SELF_CHECK_FILE, CHECK_LOG_DIR } from "./precheck.mjs";
|
|
53
|
+
import { runChecks, runWithTimeoutRetry, splitPrecheckResults, timedOutDetail, planPrecheck, worktreeFingerprint, selfCheckState, quietFailure, checkFailureTail, CHECK_PLAN_FILE, SELF_CHECK_FILE, CHECK_LOG_DIR } from "./precheck.mjs";
|
|
53
54
|
import { retrying, ghCacheRetry, refreshAuthOnce, runRefreshScript, GH_AUTH_RE, GH_AUTH_RETRY_SECONDS, PUSH_TRANSIENT_RE, PUSH_PERMANENT_RE, GH_TRANSIENT_RE, MERGE_TRANSIENT_RE, MERGE_CONFLICT_RE } from "./retry.mjs";
|
|
54
55
|
import { renderInvestigation, renderImplementation, renderReview, renderPrBody, renderTrajectory, renderContract, renderAmendments, renderShadowReview, parseContractComment, parseAmendmentsComment, contractJson, capComment, sanitizeMd, MAX_COMMENT_CHARS, recoveryEvidence } from "./render.mjs";
|
|
55
56
|
import { parseVerifierConfig, pickVerifierModel, changedSymbols, callersOf, verifierBudget, verifierPrompt, parseVerifierFindings, findingsToFailures, renderVerifierNote, VERIFIER_SYSTEM } from "./verifier.mjs";
|
|
56
57
|
import { computeTrigger, riskPathHits, TRIGGER_MODES, pathDomains, parseEnforceDomains } from "./review-trigger.mjs";
|
|
57
58
|
import { hostCapabilityBlock, contractHostNeeds } from "./execution.mjs";
|
|
59
|
+
import { baseMergeOnlyBlock, envGapBlockCode, toolGapFailures, packageDirsMissingDeps, failureOutsideDiff } from "./envgap.mjs"; // #6106
|
|
58
60
|
|
|
59
61
|
const MISSING_TOOL_RE = /command not found|not found in PATH|no such file or directory.*\b(?:docker|promtool)\b|\b(?:docker|promtool)\b[^\n]{0,80}(?:not (?:installed|found|available)|no such file|cannot connect|daemon)|cannot connect to the docker daemon|no docker daemon|no module named|ModuleNotFoundError|\bENOENT\b[^\n]{0,60}spawn/i;
|
|
60
62
|
/** #4685: true when a builder's block summary names a missing tool or module (environment), not a credential. */
|
|
@@ -68,16 +70,14 @@ export function contractSelfCorrectable(problems) {
|
|
|
68
70
|
export function missingToolBlock(summary) { return MISSING_TOOL_RE.test(String(summary ?? "")); }
|
|
69
71
|
import { reserveForBuild, revalidate } from "./seqreserve.mjs";
|
|
70
72
|
import { patchEcho, mutationsOf, runReproMutations, classifyRepro } from "./reproquality.mjs";
|
|
71
|
-
import { CHECKS_CLI, FORGEDOCK_CLI, REVIEWER_SYSTEM, LEAN_DIR, RESULT_FILE, INVESTIGATION_FILE, IMPLEMENTATION_FILE, CONTRACT_FILE, builderPlanPrompt, builderImplementPrompt, contractCorrectionPrompt, conformanceResumePrompt,
|
|
73
|
+
import { CHECKS_CLI, FORGEDOCK_CLI, REVIEWER_SYSTEM, LEAN_DIR, RESULT_FILE, INVESTIGATION_FILE, IMPLEMENTATION_FILE, CONTRACT_FILE, builderPlanPrompt, builderImplementPrompt, contractCorrectionPrompt, conformanceResumePrompt, reviewerPrompt, investigationVerdict, decisionNote, reviewerRepairPrompt, REVIEW_DIFF_MAX_BYTES, blockCorrectionPrompt, HUMAN_BLOCK_REASONS, structurePrompt, hotspotPlanNote, hotspotBuildRule, reproPlanNote, unrunnableValidateNote, pagePlanNote, contextPackNote, buildOpeningNote, sequenceBuildRule, ciFailurePrompt, ciUnavailablePrompt, precheckFailurePrompt, contextRestartPrompt, routeDigestPrompt, turnBudgetWrapupPrompt, syncChecks, GROUPING_SYSTEM, enumeratingPlanNote, enumeratingBuildRule, invariantsPlanNote, invariantsBuildRule, missingEntriesPrompt, sequencePrompt, sequenceSyncNote, sequenceSyncPrompt, fixSessionPrompt, postMergeFailurePrompt, duplicateExportsPrompt, migrationGeneratorPrompt, i18nCopiesPrompt, narrowFixPrompt } from "./prompts.mjs";
|
|
72
74
|
import { postMergeCommands } from "./postmerge.mjs";
|
|
73
|
-
import { classifyBaseRed, attribute as attributeBaseRed, runOnBase, reportBaseRed, recordBaseVerdict, bypassesGuard } from "./basered.mjs"; // #5239
|
|
75
|
+
import { reportParityGaps, classifyBaseRed, diffTouchesGuard, attribute as attributeBaseRed, runOnBase, reportBaseRed, recordBaseVerdict, bypassesGuard } from "./basered.mjs"; // #5239
|
|
74
76
|
import { guardAfterMerge, withHistoryRows } from "./guards.mjs";
|
|
75
77
|
import { parseProdParity, prodParityFailures as prodParityOf } from "./prodparity.mjs";
|
|
76
78
|
import { routePathsFromFiles, routeReachabilityFailures } from "./routecheck.mjs";
|
|
77
|
-
import { docsFailures } from "./docsgate.mjs";
|
|
78
79
|
import { outcomeEvidenceFailures, rawChecksAt } from "./outcomeevidence.mjs";
|
|
79
|
-
import {
|
|
80
|
-
import { pageFailures, designSpecApproved, designLabelApproved, specOnlyFailures, pageFiles, designOnlyFiles } from "./pagegate.mjs"; // #5428
|
|
80
|
+
import { pageFailures, designSpecApproved, designLabelApproved, pageFiles, designOnlyFiles } from "./pagegate.mjs"; // #5428
|
|
81
81
|
import { changedRoutes, captureVisualCheck, publishToRef, visualMarkdown } from "./page-capture.mjs"; // #5770
|
|
82
82
|
import { uiBuildRule, uiIssue, uiChanged } from "./ui-quality.mjs"; // #5330
|
|
83
83
|
import { designGate, designGateNote, designFailures, specApproved as designSpecOk } from "./design-gate.mjs"; // #5330
|
|
@@ -127,8 +127,12 @@ import { ensureSignedOff, salvageBranch, dropSalvageTracking } from "./signoff.m
|
|
|
127
127
|
import { reconcileCheckpoints } from "./checkpoint-reconcile.mjs";
|
|
128
128
|
import { guardStagedDeletions, deletionEvidence, maxForeignDeletions } from "./delguard.mjs";
|
|
129
129
|
import { createLedger, flattenPhases, overheadStats } from "./phaseledger.mjs";
|
|
130
|
-
import { DEFAULT_CATALOG_SOURCES, deriveCatalog, mergeRecipes, rewriteMissed, isDriftFailure, rewriteSubprojectVenv } from "./validate-catalog.mjs";
|
|
130
|
+
import { DEFAULT_CATALOG_SOURCES, deriveCatalog, mergeRecipes, rewriteMissed, isDriftFailure, rewriteSubprojectVenv, deriveTestEnvMap, rewriteToCiEnv } from "./validate-catalog.mjs";
|
|
131
131
|
import { holderGone } from "./liveness.mjs";
|
|
132
|
+
import { runLaneAudit, buildStamp, forgeYamlHash } from "./lane-audit.mjs"; // #6076
|
|
133
|
+
import { classifyWithLlm } from "./lane-audit-llm.mjs"; // #6079
|
|
134
|
+
import { makeGapAuditor, parseGapConfig } from "./lane-audit-gap.mjs"; // #6078
|
|
135
|
+
import { parseForgeYaml } from "../forge-utils.mjs";
|
|
132
136
|
import { planStale, stackedBaseBlock, validStackedOn, cascadeDecision, invalidatedChecks } from "./stacking.mjs";
|
|
133
137
|
import { runLightStep, runLightTests, lightBuildPrompt, upgradeNote, renderLiteReceipt } from "./lightlane.mjs";
|
|
134
138
|
|
|
@@ -164,6 +168,9 @@ export function builderFixable(failures) {
|
|
|
164
168
|
const AUTH_RETRY_SECONDS = 900;
|
|
165
169
|
/** #5762: retry-in for a `backend.cli_failed` deferral (transient, not an account condition). */
|
|
166
170
|
const CLI_FAILED_RETRY_SECONDS = 120;
|
|
171
|
+
/** #6105: a builder session the API cut short (terminal_reason api_error and kin) is resumed by id after these backoffs; past them the lane defers (backend.cli_failed), never the breaker. */
|
|
172
|
+
export const API_RESUME_BACKOFF_MS = Object.freeze([20_000, 60_000, 180_000]);
|
|
173
|
+
const API_RESUME_PROMPT = "Your previous turn was cut off by a transient API error (not by anything you did). Nothing you committed or wrote in the worktree was lost. Continue the task exactly where you left off; do not start over and do not redo finished work.";
|
|
167
174
|
/** #5762: the account number (digits only) a lane used: the rotator's capture, else TOKENBATON_ACCOUNT / CLAUDE_CONFIG_DIR `.claude-<n>`; null when unknown. */
|
|
168
175
|
export function laneAccountNumber(env = process.env, account = null) {
|
|
169
176
|
if (account != null && /^\d+$/.test(String(account))) return String(account);
|
|
@@ -196,7 +203,7 @@ const SHADOW_BLOCKS = [OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, OUTCOME_CODES.CO
|
|
|
196
203
|
* not done, an invalid amendment) or conformance.regression, the same codes a review blocks on, and unexempted growth of an
|
|
197
204
|
* over-threshold file (maintenance.hotspot_growth, forge#4195). Scope creep stays recorded-only.
|
|
198
205
|
*/
|
|
199
|
-
const SHADOW_PRE_BLOCKS = [...SHADOW_BLOCKS
|
|
206
|
+
const SHADOW_PRE_BLOCKS = [...SHADOW_BLOCKS];
|
|
200
207
|
/** #4395: cap on the engine.lane_instructions file; a larger one is not slim and falls back to CLAUDE.md. */
|
|
201
208
|
export const LANE_INSTRUCTIONS_MAX_BYTES = 16384;
|
|
202
209
|
/** forge.yaml engine.review_incomplete (#4160): "needs-human" (default), or "degraded": in shadow, merge an incomplete review with a review-degraded label and a tracked follow-up. */
|
|
@@ -271,7 +278,7 @@ export function classifyBlock(result, issue) {
|
|
|
271
278
|
if (b.kind === "human") {
|
|
272
279
|
const remainder = (Array.isArray(b.remainder) ? b.remainder : []).filter((x) => x && typeof x.title === "string" && x.title.trim() && typeof x.body === "string").slice(0, MAX_SUBISSUES).map((x) => ({ title: x.title.trim(), body: x.body })); // #4730
|
|
273
280
|
if (b.why === "product-decision" && describesUnrunnableCommand(`${result?.summary ?? ""} ${b.reason ?? ""} ${b.detail ?? ""}`)) { // #4857
|
|
274
|
-
return { kind: "untyped", problem: "an unrunnable validate command is an environment defect, never a product-decision: run an equivalent through the repo's toolchain and record it
|
|
281
|
+
return { kind: "untyped", problem: "an unrunnable validate command is an environment defect, never a product-decision: run an equivalent through the repo's toolchain and record the equivalent command in the contract only if it was probed at freeze" };
|
|
275
282
|
}
|
|
276
283
|
return HUMAN_BLOCK_REASONS.includes(b.why) ? { kind: "human", why: b.why, ...(remainder.length ? { remainder } : {}) }
|
|
277
284
|
: { kind: "untyped", problem: `"${String(b.why ?? "").slice(0, 80)}" is not a human-only reason (${HUMAN_BLOCK_REASONS.join(", ")})` };
|
|
@@ -468,6 +475,7 @@ export async function runCore(o) {
|
|
|
468
475
|
const localPosts = []; // #5979: comments this lane created, so a second post in the same run sees them
|
|
469
476
|
const allComments = () => [...(iss?.comments ?? []), ...localPosts];
|
|
470
477
|
let statusCache = null; // #5592: {id, sections} of this issue's one FORGE:STATUS comment, edited in place
|
|
478
|
+
let postContractHash = null; // #5931: the frozen contract hash once known; in-place comments are keyed to it
|
|
471
479
|
const post = async (marker, body, on = issue) => {
|
|
472
480
|
if (on === issue && isStatusPost(marker)) { // machine-state markers: a section of the one status comment, not a comment of their own
|
|
473
481
|
try {
|
|
@@ -481,14 +489,15 @@ export async function runCore(o) {
|
|
|
481
489
|
if (on === issue && isUpsertPost(marker)) { // one comment edited in place across requeues (the marker still leads the body)
|
|
482
490
|
return postUpsert({ gh: ghw, repo, issue: on, markers: marker, body, comments: iss?.comments, cap: capComment });
|
|
483
491
|
}
|
|
484
|
-
if (on === issue && isKeyedPost(marker)) { // #5986: one comment per (kind, content hash) with a repeat counter; at 12 engine comments edit in place only
|
|
492
|
+
if (on === issue && isKeyedPost(marker) && !(postContractHash && IN_PLACE_MARKERS.includes(Array.isArray(marker) ? marker[0] : marker))) { // #5986: one comment per (kind, content hash) with a repeat counter; at 12 engine comments edit in place only
|
|
485
493
|
return postKeyed({ gh: ghw, repo, issue: on, marker: Array.isArray(marker) ? marker[0] : marker, body, cap: capComment });
|
|
486
494
|
}
|
|
487
495
|
const marks = (Array.isArray(marker) ? marker : [marker]).map((m) => `<!-- ${m} -->`).join("\n");
|
|
488
|
-
const full = capComment(`${marks}\n${body}`);
|
|
489
496
|
const first = Array.isArray(marker) ? marker[0] : marker;
|
|
490
|
-
|
|
491
|
-
|
|
497
|
+
const keyed = on === issue && !!postContractHash && IN_PLACE_MARKERS.includes(first);
|
|
498
|
+
const full = capComment(`${marks}\n${body}${keyed ? `\n${contractKey(postContractHash)}` : ""}`);
|
|
499
|
+
if (on === issue && IN_PLACE_MARKERS.includes(first)) { // #5979: re-post only on a state change; FACTS and DEPENDENCY are edited in place; #5931: all of them per contract hash once frozen
|
|
500
|
+
const d = decidePost({ marker: first, body: full, contractHash: keyed ? postContractHash : null, comments: allComments(), trusted: (c) => c?.__mine === true || isTrustedIssueComment(c) });
|
|
492
501
|
if (d.action === "skip") return d.prior.url ?? null;
|
|
493
502
|
const id = d.action === "patch" ? commentId(d.prior) : null;
|
|
494
503
|
if (id) {
|
|
@@ -608,6 +617,7 @@ export async function runCore(o) {
|
|
|
608
617
|
}
|
|
609
618
|
let sparse = null; // #4221: {excluded, maxKb} when the lane worktree is a sparse checkout; null leaves prompts unchanged
|
|
610
619
|
// #4395: lane profile. full (FORGEDOCK_FULL_SESSION=1): unchanged sessions; memory-off: no auto-memory; lane: also no CLAUDE.md, the lane file appended
|
|
620
|
+
let laneApiResumes = 0; // #6105: builder sessions resumed after a transient API termination (RUN_TERMINAL api_resumes)
|
|
611
621
|
let laneProfile = { name: process.env.FORGEDOCK_FULL_SESSION === "1" ? "full" : "memory-off", text: null };
|
|
612
622
|
let toolchain = null; // #4163: {env, summary} when the repo pins its toolchain (env only with a pm shim); null leaves runner env and prompts unchanged
|
|
613
623
|
// #4169: heavy steps take a host semaphore slot (io.heavy); LLM phases are not gated. `heavyEnv` puts the heavy shims on
|
|
@@ -616,7 +626,7 @@ export async function runCore(o) {
|
|
|
616
626
|
let heavyEnv = null, heavyWaitsFile = null, heavyQueueMax = 0, stage = "plan";
|
|
617
627
|
let seqBuildNote = ""; // #5235: numbers reserved for this lane at build start (prompt paragraph)
|
|
618
628
|
const recCfg = parseRecurrenceConfig(o.recurrenceConfig); // #5751: forge.yaml recurrence: (absent: mode on, threshold 2, no hot areas or counters)
|
|
619
|
-
let
|
|
629
|
+
let hotLock = null; // #5751: the hot-area locks held until teardown
|
|
620
630
|
let seqLease = null; // #4386: the host sequence lease, held from the merge-gate renumber through the merge
|
|
621
631
|
const waits = {};
|
|
622
632
|
const followupsFiled = []; // #5078: {issue, class, count} per tracking issue this lane filed into, for the batch report
|
|
@@ -772,7 +782,7 @@ export async function runCore(o) {
|
|
|
772
782
|
const term = { event: "RUN_TERMINAL", reason, code, ...(extra.cliResult != null ? { cli_result: extra.cliResult } : {}), ...(typeof extra.cliIsError === "boolean" ? { cli_is_error: extra.cliIsError } : {}), ...(extra.account ? { account: extra.account } : {}), // #5762
|
|
773
783
|
...(extra.pr ? { pr: extra.pr } : {}), ...(milestone ? { milestone } : {}), ...(verifiedLane != null ? { verified: verifiedLane } : {}),
|
|
774
784
|
...(reproQ ? { repro_quality: reproQ } : {}), conformance_mode: conformance === "enforce" || riskEnforced ? "enforce" : "shadow", ...(shadowWould ? { shadow_would: shadowWould } : {}), ...(firstReview ? { first_review: firstReview } : {}), ...(adequacyTel ?? {}),
|
|
775
|
-
...(laneHead && reason !== "merged" ? { lane_branch: laneHead.pushedTo ?? "unpushed", lane_sha: laneHead.sha } : {}), context_pack: ctxCfg.mode, ...ctxAb, ...expTag, explore: exploreCfg.mode, wall_ms: now() - t0, ...(guardAddedMs ? { guard_added_ms: guardAddedMs } : {}), model_ms: modelMs, ...(usageUnknown ? { usage_unknown: true } : {}), light, ...(ctxLane ? { lane_type: ctxLane } : {}), ...(pitMatched != null ? { pitfalls_matched: pitMatched } : {}), ...(tb.record() ? { turns: tb.record() } : {}),
|
|
785
|
+
...(laneHead && reason !== "merged" ? { lane_branch: laneHead.pushedTo ?? "unpushed", lane_sha: laneHead.sha } : {}), context_pack: ctxCfg.mode, ...ctxAb, ...expTag, explore: exploreCfg.mode, wall_ms: now() - t0, ...(guardAddedMs ? { guard_added_ms: guardAddedMs } : {}), model_ms: modelMs, ...(usageUnknown ? { usage_unknown: true } : {}), light, ...(ctxLane ? { lane_type: ctxLane } : {}), ...(pitMatched != null ? { pitfalls_matched: pitMatched } : {}), ...(laneApiResumes ? { api_resumes: laneApiResumes } : {}), ...(tb.record() ? { turns: tb.record() } : {}),
|
|
776
786
|
...(route ? { builder_tier: route.tier, builder_class: route.class, builder_escalated: escalated, builder_model: route.model ?? "default" } : {}) }; // forge#4275: the on/off A/B groups runs by these; #4394: per-tier stats
|
|
777
787
|
Object.assign(term, overheadStats(null, term.wall_ms, term.model_ms)); // fixed_overhead_ms + model_share for the SLO
|
|
778
788
|
const phases = phaseLedger.snapshot(); // #4908: run log gets the nested ledger, FORGE:TELEMETRY the flattened scalars
|
|
@@ -788,6 +798,13 @@ export async function runCore(o) {
|
|
|
788
798
|
await ghc(["issue", "edit", String(issue), "-R", repo, "--add-label", "needs-human"]);
|
|
789
799
|
} catch { /* best effort */ }
|
|
790
800
|
}
|
|
801
|
+
if (reason === "needs-human" || reason === "engine-error" || (recoverUnlabelled && recover.final && (reason === "ci-pending" || reason === "budget-exceeded"))) { // #6076: one version-stamped FORGE:LANE_AUDIT at the unhappy terminals; never changes how the lane ends
|
|
802
|
+
try {
|
|
803
|
+
let gapCfg; try { gapCfg = parseGapConfig(parseForgeYaml(readFileSync(join(o.cwd ?? wt, "forge.yaml"), "utf8"))); } catch { gapCfg = parseGapConfig({}); }
|
|
804
|
+
await runLaneAudit({ gap: makeGapAuditor({ gh: ghc, cfg: gapCfg, repo }), issue, reason, code, detail, comments: allComments(), trusted: (c) => c?.__mine === true || isTrustedIssueComment(c), phases: phaseLedger.snapshot(), post: (m, b) => post(m, b), llm: (ev) => classifyWithLlm(ev, { runner: io.runner, cwd: o.cwd ?? wt }),
|
|
805
|
+
stamp: buildStamp({ engineVersion: ENGINE_VERSION, forgeYamlHash: forgeYamlHash(o.cwd ?? wt), batchId: o.batchId ?? null, attempt: recover?.attempt ?? o.attempt ?? 1 }) });
|
|
806
|
+
} catch { /* the audit is best effort */ }
|
|
807
|
+
}
|
|
791
808
|
if (["needs-human", "engine-error", "dependency-open", "dependency-blocked", "dependency-unreadable", "decomposed", "host-task"].includes(reason)) {
|
|
792
809
|
const wf = ["investigating", "building", "in-review"].map((x) => `workflow:${x}`).join(",");
|
|
793
810
|
try { await ghc(["issue", "edit", String(issue), "-R", repo, "--remove-label", wf]); } catch { /* best effort */ }
|
|
@@ -805,7 +822,7 @@ export async function runCore(o) {
|
|
|
805
822
|
if (deferTail) postRun.add("teardown", () => teardown(reason, extra)); // last: the structure delta and guard read the worktree
|
|
806
823
|
if (reason === "merged" || reason === "invalid") await clearPipelineLabels({ gh: ghc, repo, issue, onFail: (n, e) => T.anomalies.push(`pipeline labels not cleared${n.length ? `: ${n.join(", ")}` : ""} (${String(e?.message ?? e).slice(0, 120)})`) }); // #5592/#5759: a merged or closed issue keeps no needs-human / parked:* / remediation-queue
|
|
807
824
|
await releaseLease(reason, code, extra.mergedTo ?? null);
|
|
808
|
-
done = { terminalReason: reason, detail, branch, worktree: wt, ...(cascadeLog.kinds.length ? { cascade: cascadeLog.kinds[cascadeLog.kinds.length - 1], cascades: [...cascadeLog.kinds], cascade_cost_usd: Math.round(cascadeLog.costUsd * 1e6) / 1e6, cascade_minutes: Math.round(cascadeLog.ms / 6000) / 10 } : {}), cost_usd: usage.cost_usd, tokens: { input: usage.input, output: usage.output, cache: usage.cache }, wall_ms: now() - t0, model_ms: modelMs, phases: phaseLedger.snapshot(),
|
|
825
|
+
done = { terminalReason: reason, detail, branch, worktree: wt, engineVersion: ENGINE_VERSION, ...(postContractHash ? { contractHash: postContractHash } : {}), ...(cascadeLog.kinds.length ? { cascade: cascadeLog.kinds[cascadeLog.kinds.length - 1], cascades: [...cascadeLog.kinds], cascade_cost_usd: Math.round(cascadeLog.costUsd * 1e6) / 1e6, cascade_minutes: Math.round(cascadeLog.ms / 6000) / 10 } : {}), cost_usd: usage.cost_usd, tokens: { input: usage.input, output: usage.output, cache: usage.cache }, wall_ms: now() - t0, model_ms: modelMs, phases: phaseLedger.snapshot(),
|
|
809
826
|
...(laneHead && reason !== "merged" ? { laneHead: { ...laneHead } } : {}), light, ...(lightVerdict ? { light_eligibility: lightVerdict } : {}), ...(lightUpgrade ? { light_upgrade: lightUpgrade } : {}), // #4453
|
|
810
827
|
...(Object.keys(waits).length ? { waits: { ...waits } } : {}), ...(followupsFiled.length ? { followups: followupsFiled.map((f) => ({ ...f })) } : {}), ...(pendingRecord().length ? { pendingFollowups: pendingRecord() } : {}), ...(heavyQueueMax ? { heavyQueueMax } : {}), ...(precheckRan ? { precheckMs, precheckDeferred } : {}),
|
|
811
828
|
...(firstPassOf(builderTriggers) != null ? { firstPass: firstPassOf(builderTriggers) } : {}), ...(tb.record() ? { turns: tb.record() } : {}), context: { ...ctxStats, cost_usd: impl.cost }, // #4392, #5829
|
|
@@ -968,7 +985,7 @@ export async function runCore(o) {
|
|
|
968
985
|
const set = String(process.env.FORGE_HOST_PARALLELISM ?? "").trim();
|
|
969
986
|
if (/^\d+$/.test(set) && Number(set) > 0) return set;
|
|
970
987
|
if (!io.host?.cores) return null;
|
|
971
|
-
try { return String(hostParallelism({ cores: io.host.cores(), lanes: io.host.activeLanes?.() })); } catch { return null; }
|
|
988
|
+
try { return String(hostParallelism({ cores: quotaCores({ cores: io.host.cores(), read: (f) => (io.host.readFile ?? readFileSync)(f, "utf8"), env: process.env }), lanes: io.host.activeLanes?.() })); } catch { return null; }
|
|
972
989
|
}
|
|
973
990
|
/**
|
|
974
991
|
* #4325: the lane env every engine-run command shares with the builder: shared package-manager stores (#4220), the run
|
|
@@ -990,11 +1007,14 @@ export async function runCore(o) {
|
|
|
990
1007
|
ev({ event: "SIGNOFF_HOOK", dir });
|
|
991
1008
|
} catch { signoffEnv = {}; }
|
|
992
1009
|
}
|
|
1010
|
+
/** #5917: tool user-config redirected into the run dir (created once), beneath every engine key; {} without a run dir. */
|
|
1011
|
+
let laneCfgEnv = null, laneCfgDir = null;
|
|
1012
|
+
function laneCfg() { if (!runTmp) return {}; if (laneCfgDir !== runTmp) { laneCfgDir = runTmp; laneCfgEnv = laneConfigEnv({ dir: runTmp }); } return laneCfgEnv; }
|
|
993
1013
|
function laneEnv() {
|
|
994
1014
|
let deps = {};
|
|
995
1015
|
try { deps = io.deps?.env?.() ?? {}; } catch { deps = {}; }
|
|
996
1016
|
const par = verifyParallelism();
|
|
997
|
-
return { ...deps, ...(runTmp ? { TMPDIR: runTmp } : {}), ...(par ? { FORGE_HOST_PARALLELISM: par } : {}), FORGE_LANE_WORKTREE: "1", ...laneGitEnv, [FORGEDOCK_CHECKS_VAR]: CHECKS_CLI, [FORGEDOCK_ENTRY_VAR]: FORGEDOCK_CLI, ...sandboxEnv, ...(toolchain?.env ?? {}) }; // #5333: the hook denies git stash where this is set; #5825: git in a lane child never walks up out of the worktree
|
|
1017
|
+
return { ...laneCfg(), ...deps, ...(runTmp ? { TMPDIR: runTmp } : {}), ...(par ? { FORGE_HOST_PARALLELISM: par } : {}), FORGE_LANE_WORKTREE: "1", ...laneGitEnv, [FORGEDOCK_CHECKS_VAR]: CHECKS_CLI, [FORGEDOCK_ENTRY_VAR]: FORGEDOCK_CLI, ...sandboxEnv, ...(toolchain?.env ?? {}) }; // #5333: the hook denies git stash where this is set; #5825: git in a lane child never walks up out of the worktree
|
|
998
1018
|
}
|
|
999
1019
|
/** #5168: a failed claude login ends the lane `deferred` `backend.auth`, held per account by the batch (never the relaunch or the breaker). */
|
|
1000
1020
|
const authDeferral = (e, account = null) => Object.assign(e, { deferCode: OUTCOME_CODES.BACKEND_AUTH, retryInSeconds: AUTH_RETRY_SECONDS, backendId: laneBackendId(process.env, rotator), ...cliDeferFacts(e, account),
|
|
@@ -1221,7 +1241,7 @@ export async function runCore(o) {
|
|
|
1221
1241
|
let planSession = null;
|
|
1222
1242
|
const notePlanSession = (r, trigger) => { planSession = { endTokens: num(r.endTokens), read: [...new Set([...(planSession?.read ?? []), ...handoffFacts(r.toolUses).read])], text: trigger === "plan" ? String(r.text ?? "") : planSession?.text ?? "" }; };
|
|
1223
1243
|
async function builder(n, prompt, resume, live = false, restart = implementRestart, opts = {}) {
|
|
1224
|
-
let timeoutRetries = 0, contextRestarts = 0, p = prompt;
|
|
1244
|
+
let timeoutRetries = 0, contextRestarts = 0, apiResumes = 0, p = prompt;
|
|
1225
1245
|
opts = { ...opts };
|
|
1226
1246
|
const ceiled = laneCeiling > 0 && !opts.noCeiling && !UNCEILED.includes(opts.trigger); // #5346: per-size ceiling; noCeiling = a restart is certain
|
|
1227
1247
|
for (;;) {
|
|
@@ -1241,6 +1261,20 @@ export async function runCore(o) {
|
|
|
1241
1261
|
await attempt("implement", n, { usage: e.usage ?? null, turns: e.turns ?? null, tools: toolStats(e.toolUses), costUsd: null, model: opts.model ?? builderModel ?? null }, opts.mode, opts.trigger, opts.restartOf);
|
|
1242
1262
|
return await budgetWrapup(n, opts);
|
|
1243
1263
|
}
|
|
1264
|
+
if (e?.apiError === true) { // #6105: the API ended the session after real work: resume the same session (worktree and commits kept) with backoff, never relaunch the lane
|
|
1265
|
+
const sid = e.cliSessionId ?? null;
|
|
1266
|
+
if (!sid || apiResumes >= API_RESUME_BACKOFF_MS.length) {
|
|
1267
|
+
ev({ event: "API_ERROR_RESUME_EXHAUSTED", session_id: sid, terminal_reason: e.cliTerminalReason ?? null, resumes: apiResumes, trigger: opts.trigger ?? null });
|
|
1268
|
+
T.anomalies.push(`builder session ended ${e.cliTerminalReason ?? "api_error"} ${sid ? `after ${apiResumes} resume(s)` : "with no session id to resume"}: lane deferred`);
|
|
1269
|
+
throw Object.assign(cliFailedDeferral(e), { deferDetail: `builder session ended ${e.cliTerminalReason ?? "api_error"} (transient API error) ${sid ? `and ${apiResumes} resume(s) of ${sid} failed` : "with no session id to resume"}; the branch keeps its commits; retried shortly${cliDetail(e)}` });
|
|
1270
|
+
}
|
|
1271
|
+
const waitMs = API_RESUME_BACKOFF_MS[apiResumes++]; laneApiResumes++;
|
|
1272
|
+
ev({ event: "API_ERROR_RESUME", session_id: sid, terminal_reason: e.cliTerminalReason ?? null, attempt: apiResumes, wait_ms: waitMs, trigger: opts.trigger ?? null });
|
|
1273
|
+
T.decisions.push(`Builder session ${sid} ended ${e.cliTerminalReason ?? "api_error"}: resuming the same session after ${Math.round(waitMs / 1000)}s (resume ${apiResumes}/${API_RESUME_BACKOFF_MS.length}), no relaunch`);
|
|
1274
|
+
await renew(); await sleep(waitMs); await renew();
|
|
1275
|
+
p = API_RESUME_PROMPT; resume = sid; opts.restartOf ??= opts.trigger ?? null; opts.trigger = "api_error_resume";
|
|
1276
|
+
continue;
|
|
1277
|
+
}
|
|
1244
1278
|
if (e?.code === "CLI_CONTEXT") {
|
|
1245
1279
|
contextRestarts++; ctxStats.restarts++;
|
|
1246
1280
|
ev({ event: "CONTEXT_CEILING", context_tokens: e.context ?? null, ceiling: e.contextMax ?? laneCeiling, real_limit: Boolean(continued), turns: e.turns ?? null, trigger: opts.trigger ?? null, restart: contextRestarts, last_tool: e.lastTool?.name ?? null });
|
|
@@ -1483,6 +1517,14 @@ export async function runCore(o) {
|
|
|
1483
1517
|
// #4685: a tool the sandbox lacks (docker, promtool, a Python module) is an environment gap the host recovers, never a credential.
|
|
1484
1518
|
return await needsHuman(`Remote sandbox lacks a validate tool (Builder is blocked (credentials)): ${s}\n\nNot a credential: the lane is recovered where the tool exists.`, OUTCOME_CODES.ENV_TOOL_MISSING);
|
|
1485
1519
|
}
|
|
1520
|
+
if (b.kind === "human" && baseMergeOnlyBlock(b.why, s)) { // #6137: merging the base into the lane's own branch is the engine's base-sync, never a human gate
|
|
1521
|
+
T.decisions.push(`Builder block (${b.why}) reclassified to base-sync: it only asks for a merge of the base into the lane branch`);
|
|
1522
|
+
return await needsHuman(`Base merge, not a human decision (Builder reported blocked (${b.why})): ${s}\n\nMerging ${base} into the lane's own branch is the engine's base-sync: the lane is recovered with the base merged.`, OUTCOME_CODES.BASE_CONFLICT);
|
|
1523
|
+
}
|
|
1524
|
+
if (b.kind === "human") { // #6106: a missing tool/interpreter/recipe/package/sandbox capability is an env gap that recovers, whatever reason the builder typed; genuine human reasons stay human
|
|
1525
|
+
const envCode = envGapBlockCode(b.why, s);
|
|
1526
|
+
if (envCode) { T.decisions.push(`Builder block (${b.why}) reclassified to ${envCode}: it names an environment gap, not a human decision`); return await needsHuman(`Environment gap, not a human decision (Builder reported blocked (${b.why})): ${s}\n\nThe lane is recovered where the tool, interpreter or capability exists.`, envCode); }
|
|
1527
|
+
}
|
|
1486
1528
|
if (b.kind === "human") {
|
|
1487
1529
|
// #4730: the agent-doable remainder is re-queued as its own lane; only the owner step keeps needs-human.
|
|
1488
1530
|
let note = "";
|
|
@@ -2192,6 +2234,11 @@ export async function runCore(o) {
|
|
|
2192
2234
|
const vr = rewriteSubprojectVenv(r.contract, freezeTracked, (rel) => existsSync(join(wt, rel))); // #5683
|
|
2193
2235
|
r.contract = vr.contract;
|
|
2194
2236
|
for (const x of vr.applied) T.decisions.push(`sub-project venv rewrite of ${x.id}: \`${x.from}\` -> \`${x.to}\``);
|
|
2237
|
+
// #5753: a pytest path CI runs in another env (working-directory + poetry/uv run) runs there, not under a bare interpreter
|
|
2238
|
+
const ciTexts = (validateCatalogSources ?? DEFAULT_CATALOG_SOURCES).map((p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } });
|
|
2239
|
+
const ce = rewriteToCiEnv(r.contract, deriveTestEnvMap(ciTexts), freezeTracked, (rel) => existsSync(join(wt, rel)));
|
|
2240
|
+
r.contract = ce.contract;
|
|
2241
|
+
for (const x of ce.applied) T.decisions.push(`CI test-env rewrite of ${x.id}: \`${x.from}\` -> \`${x.to}\``);
|
|
2195
2242
|
r.contract = foldRegression(r.contract); // #5448: the blast-radius regression set runs as validate G# entries
|
|
2196
2243
|
const e = autoPostDeployE2e(r.contract); // #5468: production-only e2e/manual rows become post-deploy with a generated check
|
|
2197
2244
|
for (const x of e.converted) { if (x.check) genChecks[x.check] = x.entry; T.decisions.push(`Production-only e2e/manual requirement ${x.id} frozen as post-deploy with ${x.check ? `generated check ${x.check}` : "no check (production observation window)"}`); }
|
|
@@ -2200,7 +2247,9 @@ export async function runCore(o) {
|
|
|
2200
2247
|
if (d.converted.length) T.decisions.push(`Post-deploy with no registered check deferred to the orchestrator: ${d.converted.join(", ")}`);
|
|
2201
2248
|
return d.contract;
|
|
2202
2249
|
}
|
|
2250
|
+
const imageManifest = loadImageManifest();
|
|
2203
2251
|
async function preflightValidates(contract) {
|
|
2252
|
+
for (const d of hostEnvDefects()) { T.anomalies.push(`Host environment defect (${d.code}): ${d.detail}`); ev({ event: "HOST_ENV_DEFECT", code: d.code, detail: d.detail }); } // #5917: an env defect, never a miss that blames the contract
|
|
2204
2253
|
if ((!io.probeCommand && !io.preflightRun) || !contract || typeof contract !== "object") return [];
|
|
2205
2254
|
const files = String(await git(["ls-files"]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean);
|
|
2206
2255
|
const env = laneEnv(), missing = new Set(), misses = []; // #4325: the env the validate commands run with
|
|
@@ -2208,7 +2257,7 @@ export async function runCore(o) {
|
|
|
2208
2257
|
const local = projectBinDirs(wt, files);
|
|
2209
2258
|
if (local.length) env.PATH = withLocalBins(env.PATH ?? process.env.PATH ?? "", local);
|
|
2210
2259
|
if (io.probeCommand) {
|
|
2211
|
-
const { probes, dropped } = preflightProbes(contract, { repoHas: repoTracks(files) });
|
|
2260
|
+
const { probes, dropped } = preflightProbes(contract, { repoHas: repoTracks(files), provided: (t) => manifestProvides(imageManifest, t) });
|
|
2212
2261
|
if (dropped) T.anomalies.push(`Validate preflight probed ${probes.length} tool(s); ${dropped} more not probed`);
|
|
2213
2262
|
for (const p of probes) {
|
|
2214
2263
|
if (p.needs && missing.has(p.needs)) continue;
|
|
@@ -2223,6 +2272,17 @@ export async function runCore(o) {
|
|
|
2223
2272
|
for (const v of Array.isArray(contract.validate) ? contract.validate : []) {
|
|
2224
2273
|
if (v?.id && typeof v.command === "string") for (const name of unsetEnvVars(v.command, fullEnv)) misses.push({ ids: [v.id], tool: name, kind: "env-var", source: "env" });
|
|
2225
2274
|
}
|
|
2275
|
+
if (io.preflightRun) { // #5753: one collect-only run per pytest command imports its test modules before a builder is spent
|
|
2276
|
+
const done = new Set(misses.flatMap((m) => m.ids)), repoHas = repoTracks(files);
|
|
2277
|
+
for (const v of contractCommands(contract)) {
|
|
2278
|
+
const cmd = done.has(v.id) ? null : collectOnlyCommand(v.command);
|
|
2279
|
+
if (!cmd) continue;
|
|
2280
|
+
let r;
|
|
2281
|
+
try { r = await heavyStep("precheck", () => io.preflightRun({ command: cmd, timeoutMs: 60000, env, cwd: wt })); } catch (e) { r = { rc: 127, output: String(e?.message ?? e) }; }
|
|
2282
|
+
const miss = collectImportMiss(r, { repoHas });
|
|
2283
|
+
if (miss) misses.push({ ids: [v.id], ...miss, source: "collect" });
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2226
2286
|
if (io.preflightRun) {
|
|
2227
2287
|
const skipIds = [...new Set(misses.flatMap((m) => m.ids))];
|
|
2228
2288
|
const run = (a) => heavyStep("precheck", () => io.preflightRun({ ...a, cwd: wt }));
|
|
@@ -2241,19 +2301,20 @@ export async function runCore(o) {
|
|
|
2241
2301
|
let out = "";
|
|
2242
2302
|
try { out = String(await ghc(["api", "--paginate", `repos/${repo}/issues/${issue}/comments`, "--jq", ".[] | {body, author_association, user: {type: .user.type, login: .user.login}}"])); } catch { return null; }
|
|
2243
2303
|
let found = null;
|
|
2244
|
-
const amendLog = []; // #4899: trusted FORGE:AMENDMENT payloads in order, bound to a contract hash
|
|
2304
|
+
const amendLog = [], rewritePosted = []; // #4899: trusted FORGE:AMENDMENT payloads in order, bound to a contract hash
|
|
2245
2305
|
for (const l of out.split("\n")) {
|
|
2246
2306
|
let c; try { c = JSON.parse(l); } catch { continue; }
|
|
2247
2307
|
if (!isTrustedComment(c)) continue;
|
|
2248
2308
|
const b = String(c?.body ?? "");
|
|
2249
2309
|
const am = parseAmendmentsComment(b);
|
|
2250
2310
|
if (am) amendLog.push(am);
|
|
2311
|
+
if (b.includes("rewrite-validate")) rewritePosted.push(b); // #5920: audit comments already posted
|
|
2251
2312
|
if (!b.startsWith("<!-- FORGE:CONTRACT -->")) { if (found && b.trim() && !b.trimStart().startsWith("<!-- FORGE:")) found.humanAfter = true; continue; }
|
|
2252
2313
|
const fc = parseContractComment(b);
|
|
2253
2314
|
if (fc && contractHash(fc.text) === fc.hash) found = { ...fc, humanAfter: false };
|
|
2254
2315
|
}
|
|
2255
2316
|
if (found) {
|
|
2256
|
-
const seen = new Set(); found.amendments = [];
|
|
2317
|
+
const seen = new Set(); found.amendments = []; found.rewritePosted = rewritePosted;
|
|
2257
2318
|
for (const st of amendLog) if (st.contract === found.hash) for (const a of st.amendments) { const k = JSON.stringify(a); if (!seen.has(k)) { seen.add(k); found.amendments.push(a); } }
|
|
2258
2319
|
}
|
|
2259
2320
|
return found;
|
|
@@ -2318,13 +2379,6 @@ export async function runCore(o) {
|
|
|
2318
2379
|
let frozen = null, hash = null, planned = false, files = [], split = null, planMisses = null; // planMisses (#5331): validate preflight misses from this run
|
|
2319
2380
|
/** #5804: paths that place the change: the issue's named paths, then the frozen deliverables once they exist */
|
|
2320
2381
|
const toolFiles = () => [...namedPaths(iss?.body ?? ""), ...(frozen?.deliverables ?? []).map((d) => d?.path)].filter(Boolean);
|
|
2321
|
-
const impliedDocs = []; // add-deliverable amendments for doc edits the docs-freshness rule demanded (docs round, CI fix round)
|
|
2322
|
-
/** Doc files a fix round added to satisfy the freshness rule: recorded only when the rule failed before and passes after. */
|
|
2323
|
-
async function noteFreshnessDocs(before, wasFailing) {
|
|
2324
|
-
if (!io.docsFreshness || !wasFailing) return;
|
|
2325
|
-
const nowOk = (await io.docsFreshness({ cwd: wt, base }).catch(() => null))?.ok === true;
|
|
2326
|
-
for (const a of impliedDocDeliverables({ before, after: await changedFiles(), contract: frozen, wasFailing, nowOk })) if (!impliedDocs.some((x) => x.path === a.path)) impliedDocs.push(a);
|
|
2327
|
-
}
|
|
2328
2382
|
let priorAmendments = []; // #4899: accepted amendments recovered with the frozen contract
|
|
2329
2383
|
const pendingPits = []; // #4375: rework rounds whose gate has not passed again yet
|
|
2330
2384
|
async function notePitfall(trigger, text) {
|
|
@@ -2408,7 +2462,7 @@ export async function runCore(o) {
|
|
|
2408
2462
|
{ const f = await gateSetup(); if (f) return f; }
|
|
2409
2463
|
files = await changedFiles();
|
|
2410
2464
|
frozen = { requirements: [], deliverables: files.map((path, i) => ({ id: `D${i + 1}`, path, change: `adopted from PR #${adoptPr.number}: reviewed as built`, requirements: [] })), preserve: [], validate: [] };
|
|
2411
|
-
hash = contractHash(contractJson(frozen));
|
|
2465
|
+
hash = contractHash(contractJson(frozen)); postContractHash = hash;
|
|
2412
2466
|
T.decisions.push(`Adopted PR #${adoptPr.number}: ${files.length} changed file(s) go to review as built`);
|
|
2413
2467
|
} else if (isSplit) {
|
|
2414
2468
|
// ---- 3'. refactor:split (#4211): deterministic move + proof replaces the builder; no builder session exists ----
|
|
@@ -2435,7 +2489,22 @@ export async function runCore(o) {
|
|
|
2435
2489
|
T.decisions.push(`Rerun: frozen contract ${fc.hash} is stale (${stale}); re-planning`);
|
|
2436
2490
|
} else {
|
|
2437
2491
|
frozen = fc.contract; hash = fc.hash; priorAmendments = fc.amendments ?? []; T.decisions.push(`Rerun: frozen contract ${hash} recovered from the issue`);
|
|
2438
|
-
ev({ event: "CONTRACT_REUSED", hash, recover: recover?.code ?? null, resumed: Boolean(resumed) }); // #5811: no pre-contract session; routing is next
|
|
2492
|
+
postContractHash = hash; ev({ event: "CONTRACT_REUSED", hash, recover: recover?.code ?? null, resumed: Boolean(resumed) }); // #5811: no pre-contract session; routing is next
|
|
2493
|
+
freezeTracked = (await depOwnerOf()).files;
|
|
2494
|
+
const rw = freezeRewrites(structuredClone(frozen)); // #5920: the freeze-time rewrites (validate.recipes, venv, CI env) apply to a reused contract too; only commands are adopted
|
|
2495
|
+
const swaps = [];
|
|
2496
|
+
const swap = (id, o, n) => { if (o && typeof o.command === "string" && typeof n?.command === "string" && n.command !== o.command) { swaps.push({ id, from: o.command, to: n.command }); o.command = n.command; } };
|
|
2497
|
+
frozen = structuredClone(frozen);
|
|
2498
|
+
for (const v of Array.isArray(frozen.validate) ? frozen.validate : []) swap(v?.id, v, (rw.validate ?? []).find((x) => x?.id === v?.id));
|
|
2499
|
+
swap("repro_test", frozen.repro_test, rw.repro_test);
|
|
2500
|
+
if (swaps.length) { // audit-only comment (no AMENDMENT-STATE, so a later reuse never replays it); the rewrite is deterministic and re-derived each reuse
|
|
2501
|
+
const why = `rewrite of frozen contract ${hash} on reuse (#5920)`;
|
|
2502
|
+
const body = renderAmendments(swaps.map((x) => ({ kind: "rewrite-validate", target: x.id, why: `${why}: \`${x.from}\` -> \`${x.to}\`` })));
|
|
2503
|
+
T.decisions.push(`Reused contract ${hash}: ${swaps.map((x) => x.id).join(", ")} rewritten at reuse`);
|
|
2504
|
+
if (!(fc.rewritePosted ?? []).some((c) => c.includes(body))) {
|
|
2505
|
+
try { await post("FORGE:AMENDMENT", body); } catch (e) { T.anomalies.push(`FORGE:AMENDMENT comment not posted: ${String(e?.message ?? e).slice(0, 160)}`); }
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2439
2508
|
const ad = applyRequirementDecisions(frozen, trustedComments); // #5547: a structured operator decision amends the frozen row
|
|
2440
2509
|
if (ad.applied.length) { frozen = deferChecklessPostDeploy(ad.contract).contract; T.decisions.push(`FORGE:DECISION applied to the frozen contract: ${ad.applied.join(", ")} tracked post-deploy`); }
|
|
2441
2510
|
}
|
|
@@ -2461,15 +2530,6 @@ export async function runCore(o) {
|
|
|
2461
2530
|
if (!planOnly) await label("building"); // #5831
|
|
2462
2531
|
// #4450: the light lane (lean.light mode on, eligible, fresh lane): one builder session, derived contract, or an upgrade
|
|
2463
2532
|
const waitMs = Math.max(0, Number(contextWaitSeconds) || 0) * 1000, tHot = now();
|
|
2464
|
-
if (recCfg.mode === "on" && !recurrence && (namedPaths(iss.body ?? "").length || recursLinks(iss.body ?? "").length)) { // #5751: 0 LLM calls; an issue naming no path and no Recurs link cannot recur
|
|
2465
|
-
recurrence = await recurrenceFacts({ io: { gh: ghc, git: (a) => git(a) }, repo, issue, title: iss.title, body: iss.body ?? "", base, namedPaths: namedPaths(iss.body ?? ""), threshold: recCfg.threshold, createdAt: iss.createdAt ?? null }).catch(() => null);
|
|
2466
|
-
if (recurrence?.recurs) {
|
|
2467
|
-
recurrence.demanded = designDemanded(allComments()); // #5979: the design block is demanded once
|
|
2468
|
-
ev({ event: "RECURRENCE", count: recurrence.count, threshold: recurrence.threshold, fixes: recurrence.evidence.map((e) => e.number), reason: recurrence.reason });
|
|
2469
|
-
T.decisions.push(`Design lane (#5751): ${recurrence.reason}`);
|
|
2470
|
-
try { await post("FORGE:RECURRENCE", `Routed to a design lane: ${recurrence.reason}.\nThe contract must say why the earlier fixes did not hold, whether to delete or replace them, and a measurable outcome; it may decompose into ordinary lanes.`); } catch { /* best effort */ }
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
2533
|
await takeHotAreas(namedPaths(iss.body ?? "")); // #5751
|
|
2474
2534
|
const hotR = await within(hotspotsOf({ paths: namedPaths(iss.body ?? "") }), waitMs); // #5209: churn and hotspot signals for eligibility; #5434: bounded, overlaps the install
|
|
2475
2535
|
const hotLate = hotR === TIMED_OUT, namedHot = hotLate ? null : hotR;
|
|
@@ -2480,9 +2540,8 @@ export async function runCore(o) {
|
|
|
2480
2540
|
lightVerdict = elig.verdict;
|
|
2481
2541
|
if (elig.mode !== "off") T.decisions.push(`Light lane ${elig.mode}: ${elig.verdict}${elig.reasons.length ? ` (${elig.reasons.map((x) => x.code).join(", ")})` : ""}`);
|
|
2482
2542
|
// #4451: a light try skips the hotspots and the context pack; an upgrade computes them before the plan call
|
|
2483
|
-
const ffSource = fastForwardSource(o.light), ffFresh = !planOnly && ffSource === "investigation" && !frozen && !resumed && !salvagedRef && !recover
|
|
2484
|
-
const lightTry = !planOnly && ffSource === "text" && elig.light && !hotLate && !frozen && !resumed && !salvagedRef && !recover
|
|
2485
|
-
if (recurrence?.recurs && elig.light) T.decisions.push("Light lane skipped: the issue recurs (design lane)");
|
|
2543
|
+
const ffSource = fastForwardSource(o.light), ffFresh = !planOnly && ffSource === "investigation" && !frozen && !resumed && !salvagedRef && !recover; // #5426: the text verdict above is only a shadow signal then
|
|
2544
|
+
const lightTry = !planOnly && ffSource === "text" && elig.light && !hotLate && !frozen && !resumed && !salvagedRef && !recover;
|
|
2486
2545
|
if (!lightTry) hotFacts = namedHot; // #4451: a light try still gives its builder no hotspot facts
|
|
2487
2546
|
enumList = io.enumeratingTests ? ((await within(io.enumeratingTests({ cwd: wt, paths: namedPaths(iss.body ?? "") }), waitMs)) ?? []) : [];
|
|
2488
2547
|
if (enumList === TIMED_OUT) enumList = [];
|
|
@@ -2497,7 +2556,7 @@ export async function runCore(o) {
|
|
|
2497
2556
|
if (!depsDone && left > 0) await within(depsP, left);
|
|
2498
2557
|
const f = await toolStop(toolFiles()); if (f) return f;
|
|
2499
2558
|
}
|
|
2500
|
-
const planPrompt = () => builderPlanPrompt(issue, tcOpts()) + uiBuildRule(uiOn = uiOn || uiIssue(iss ?? {}), designConfig) + hotspotPlanNote(hotFacts) + enumeratingPlanNote(enumList) + invariantsPlanNote(vcfg.invariants) + reproPlanNote(reproOn()) +
|
|
2559
|
+
const planPrompt = () => builderPlanPrompt(issue, tcOpts()) + uiBuildRule(uiOn = uiOn || uiIssue(iss ?? {}), designConfig) + hotspotPlanNote(hotFacts) + enumeratingPlanNote(enumList) + invariantsPlanNote(vcfg.invariants) + reproPlanNote(reproOn()) + pagePlanNote(pagesConfig) + unrunnableValidateNote(testRunners) + explorePlanRule(exploreCfg) + (ctxCfg.mode === "on" ? contextPackNote(ctxPack) : "");
|
|
2501
2560
|
let lightDone = false, lightCommits = false;
|
|
2502
2561
|
let ffPlan = "full", ffGo = false, lightElig = elig, lightPred = null, ffTriage = null; // #5426: how the plan call runs; ffGo = fast-forward to the light step
|
|
2503
2562
|
const ffTriageOf = async (raw) => parseTriage(raw, await io.fs.read(`${wt}/${INVESTIGATION_FILE}`).catch(() => ""));
|
|
@@ -2530,6 +2589,7 @@ export async function runCore(o) {
|
|
|
2530
2589
|
stage = "plan"; liveKeys = ["investigation"]; result = (await readResult()) ?? result;
|
|
2531
2590
|
if (!lr.upgrade) {
|
|
2532
2591
|
lightDone = true; light = true; frozen = historyRows(lr.contract); hash = contractHash(contractJson(frozen));
|
|
2592
|
+
postContractHash = hash;
|
|
2533
2593
|
let body = renderContract(frozen, hash, { scope: scopeHash, base: lane });
|
|
2534
2594
|
if (body.length > MAX_COMMENT_CHARS - 500) body = renderContract(frozen, hash, { compact: true, scope: scopeHash, base: lane });
|
|
2535
2595
|
await post(["FORGE:CONTRACT", "FORGE:PLAN"], body);
|
|
@@ -2608,8 +2668,7 @@ export async function runCore(o) {
|
|
|
2608
2668
|
await classifyStage(sessionId ? (problems) => builder(++attemptN, `${contractCorrectionPrompt(problems)}\nThis concerns .forge-lean/classification.json: fix only the invalid fields.`, sessionId, false, planPrompt, { trigger: "contract_correction" }) : null);
|
|
2609
2669
|
const wtRead = (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } }; // #5585: noindex pages are not public
|
|
2610
2670
|
const freezeBase = pagesConfig ? String(await git(["ls-tree", "-r", "-z", "--name-only", base]).catch(() => "")).split("\0").filter(Boolean) : null; // #5648
|
|
2611
|
-
|
|
2612
|
-
let vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds, reproRecipe });
|
|
2671
|
+
let vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, reproRecipe });
|
|
2613
2672
|
const found0 = await preflightValidates(contract); // #4328: validate commands the host cannot run share the one correction
|
|
2614
2673
|
let missed = found0;
|
|
2615
2674
|
// #5653: an unrunnable command is rewritten from the repo catalogue (forge.yaml recipes first, then CI-derived) before any builder correction
|
|
@@ -2619,7 +2678,7 @@ export async function runCore(o) {
|
|
|
2619
2678
|
if (rw.applied.length) {
|
|
2620
2679
|
contract = snapContract(rw.contract);
|
|
2621
2680
|
for (const x of rw.applied) T.decisions.push(`validate catalogue rewrote unrunnable ${x.id}: \`${x.from}\` -> \`${x.to}\``);
|
|
2622
|
-
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead,
|
|
2681
|
+
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, reproRecipe });
|
|
2623
2682
|
missed = await preflightValidates(contract);
|
|
2624
2683
|
}
|
|
2625
2684
|
}
|
|
@@ -2631,10 +2690,11 @@ export async function runCore(o) {
|
|
|
2631
2690
|
await persistGenChecks();
|
|
2632
2691
|
await refreshIssue("contract validation");
|
|
2633
2692
|
contract = snapContract(contract);
|
|
2634
|
-
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead,
|
|
2693
|
+
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, reproRecipe });
|
|
2635
2694
|
};
|
|
2636
|
-
|
|
2637
|
-
|
|
2695
|
+
const hostOnly = () => hostOnlyProblems(contract); // #5749: a host-only wrapper or busy loop in a frozen command is corrected at freeze
|
|
2696
|
+
if ((!vc.ok || missed.length || testRunnerProblems(contract, testRunners).length || hostOnly().length) && sessionId) {
|
|
2697
|
+
await correctContract([...vc.problems, ...preflightProblems(missed), ...testRunnerProblems(contract, testRunners), ...hostOnly()], "resumed once");
|
|
2638
2698
|
if (missed.length) misses = await preflightValidates(contract);
|
|
2639
2699
|
}
|
|
2640
2700
|
// #5623: builder-correctable contract problems get up to contractMaxCorrections rounds (default 3), each with only the
|
|
@@ -2657,6 +2717,7 @@ export async function runCore(o) {
|
|
|
2657
2717
|
}
|
|
2658
2718
|
await flushStages(result ?? { status: "fixed" }, ["investigation"]); // always posted: FORGE:INVESTIGATION/VALIDATE are read downstream
|
|
2659
2719
|
if (!vc.ok) return await needsHuman(`The builder's contract is still invalid after ${rounds} correction(s):\n${vc.problems.slice(0, 12).map((x) => `- ${x}`).join("\n")}`, OUTCOME_CODES.CONTRACT_INVALID, { ...(issueEdited ? { issueEdited: true } : {}), ...(vc.problems.every((x) => /: quote is not verbatim/.test(x)) ? { quoteMismatch: true } : {}) });
|
|
2720
|
+
{ const ho = hostOnly(); if (ho.length) return await needsHuman(`The builder's contract still has host-only or busy-loop commands after correction (#5749); nothing was built:\n${ho.slice(0, 12).map((x) => `- ${x}`).join("\n")}`, OUTCOME_CODES.CONTRACT_INVALID, { ...(issueEdited ? { issueEdited: true } : {}) }); }
|
|
2660
2721
|
frozen = historyRows(contract); // #4694 guards
|
|
2661
2722
|
frozen = withDecisionRows(frozen, readDecisionIndex(repo)); // #4695: anchored decisions on the deliverable paths; one index read
|
|
2662
2723
|
await takeHotAreas((frozen.deliverables ?? []).map((d) => d?.path)); // #5751: the contract's paths before building
|
|
@@ -2690,8 +2751,8 @@ export async function runCore(o) {
|
|
|
2690
2751
|
}
|
|
2691
2752
|
{ // #5447: the test plan's declared env is checked on the host the lane runs on before building; a missing runner is provisioned once, else the lane ends env.tool_missing (the orchestrator re-places it on a host that has it)
|
|
2692
2753
|
const deps5683 = await depOwnerOf(), projEnv = () => { const e = laneEnv(); const d = projectBinDirs(wt, deps5683.files); if (d.length) e.PATH = withLocalBins(e.PATH ?? process.env.PATH ?? "", d); return e; };
|
|
2693
|
-
const projDeps = declaredEnv(frozen).filter((t) => deps5683.owner(t) !== null); // #5683: a sub-project's declared dependency is prepared and resolved through its bin dirs, never a host tool
|
|
2694
|
-
const probeEnv = async () => { const miss = []; for (const t of declaredEnv(frozen)) { if (deps5683.owner(t) !== null) continue; const r = io.runCommand ? await io.runCommand({ command: t === "pytest" ? "python3 -m pytest --version" : `command -v ${t} >/dev/null || { test -d node_modules/${t} && ! test -e node_modules/.bin/${t}; } || ls -d .venv/lib/python*/site-packages/${t} >/dev/null 2>&1`, cwd: wt, timeoutMs: 30000, env: projEnv() }).catch(() => ({ rc: 1 })) : { rc: 0 }; if ((r?.rc ?? 0) !== 0) miss.push(t); } return miss; };
|
|
2754
|
+
const projDeps = declaredEnv(frozen, deps5683.files).filter((t) => deps5683.owner(t) !== null); // #5683: a sub-project's declared dependency is prepared and resolved through its bin dirs, never a host tool
|
|
2755
|
+
const probeEnv = async () => { const miss = []; for (const t of declaredEnv(frozen, deps5683.files)) { if (deps5683.owner(t) !== null) continue; const r = io.runCommand ? await io.runCommand({ command: t === "pytest" ? "python3 -m pytest --version" : `command -v ${t} >/dev/null || { test -d node_modules/${t} && ! test -e node_modules/.bin/${t}; } || ls -d .venv/lib/python*/site-packages/${t} >/dev/null 2>&1`, cwd: wt, timeoutMs: 30000, env: projEnv() }).catch(() => ({ rc: 1 })) : { rc: 0 }; if ((r?.rc ?? 0) !== 0) miss.push(t); } return miss; };
|
|
2695
2756
|
let envMiss = await probeEnv();
|
|
2696
2757
|
if (projDeps.length && io.deps?.prepare) { try { await io.deps.prepare({ wt, repoKey: depcacheNamespace({ repo, fallback: repoKey(cwd) }), env: toolchain?.env ?? undefined }); ev({ event: "TESTPLAN_ENV_PROJECT_DEPS", names: projDeps }); } catch { /* the install gate reports failures */ } }
|
|
2697
2758
|
if (envMiss.length) {
|
|
@@ -2733,7 +2794,10 @@ export async function runCore(o) {
|
|
|
2733
2794
|
} catch { /* keep the original miss */ }
|
|
2734
2795
|
}
|
|
2735
2796
|
if (tm.tools.length) { // #5652: a recipe-backed tool is installed in this sandbox and re-probed before any host re-placement
|
|
2736
|
-
const
|
|
2797
|
+
const inImage = tm.tools.filter((t) => manifestProvides(imageManifest, t)); // #6037: the image ships it; a miss is an image defect, never a recipe or generic install
|
|
2798
|
+
if (inImage.length) ev({ event: "REMOTE_TOOL_IMAGE_DEFECT", tools: inImage });
|
|
2799
|
+
const installable = tm.tools.filter((t) => !inImage.includes(t));
|
|
2800
|
+
const withRecipe = installable.filter(hasRecipe), noRecipe = installable.filter((t) => !hasRecipe(t));
|
|
2737
2801
|
if (withRecipe.length && io.runCommand) {
|
|
2738
2802
|
const ins = await installLaneTools(withRecipe, { run: (a) => io.runCommand({ command: a.command, cwd: wt, timeoutMs: a.timeoutMs, env: laneEnv() }), root: process.getuid?.() === 0 });
|
|
2739
2803
|
ev({ event: "REMOTE_TOOLS_INSTALLED", tools: withRecipe, ok: ins.ok });
|
|
@@ -2750,6 +2814,7 @@ export async function runCore(o) {
|
|
|
2750
2814
|
for (const command of shim ?? genericInstallCommands(miss, { root })) {
|
|
2751
2815
|
const r = await io.runCommand({ command, cwd: wt, timeoutMs: 600000, env: laneEnv() }).catch((e) => ({ rc: 1, stderr: String(e?.message ?? e) }));
|
|
2752
2816
|
tried.push({ tool: t, kind: miss.kind, rc: r?.rc ?? 0 });
|
|
2817
|
+
process.stderr.write(`forgedock: generic install of ${t} (${miss.kind}) rc=${r?.rc ?? 0}${(r?.rc ?? 0) ? `: ${String(r?.output ?? r?.stderr ?? "").trim().split("\n").slice(-3).join(" | ").slice(0, 300)}` : ""}\n`); // lands in the lane log (dispatcher side)
|
|
2753
2818
|
}
|
|
2754
2819
|
}
|
|
2755
2820
|
rawMisses = await preflightValidates(frozen).catch(() => []);
|
|
@@ -2861,18 +2926,58 @@ export async function runCore(o) {
|
|
|
2861
2926
|
// #4331: a learned command the map covers runs only when its globs match a changed file; unmapped ones always run (#4315)
|
|
2862
2927
|
// #5820: the PR's required CI jobs (scripts/ci-local plan, heavy jobs CI-only) join the round as derived commands
|
|
2863
2928
|
const ciCfg = o.precheck?.ci ?? parseCiPrecheckConfig(null);
|
|
2864
|
-
let ciRequired, ciDerived = new Map(); // command -> {job, name, why, steps}
|
|
2929
|
+
let ciRequired, ciRelease, ciDerived = new Map(); // command -> {job, name, why, steps}
|
|
2865
2930
|
const ciGaveUp = new Set(); // jobs found unrunnable in an earlier round: recorded once, not rerun
|
|
2866
2931
|
async function ciPrecheckPlan(round) {
|
|
2867
2932
|
ciDerived = new Map();
|
|
2868
2933
|
if (ciCfg.mode === "off" || isSplit || !io.ciLocalPlan || !io.fs?.write) return [];
|
|
2869
2934
|
if (ciRequired === undefined) { try { ciRequired = (await io.requiredChecks?.(lane)) ?? null; } catch { ciRequired = null; } }
|
|
2870
|
-
|
|
2935
|
+
// #6049: the release branch's required checks (the integration target's CI) join the lane's pre-PR set
|
|
2936
|
+
const releaseBranch = String(defaults.find(Boolean) ?? "");
|
|
2937
|
+
const useRelease = Boolean(releaseBranch) && releaseBranch !== lane;
|
|
2938
|
+
if (useRelease && ciRelease === undefined) { try { ciRelease = (await io.requiredChecks?.(releaseBranch)) ?? []; } catch { ciRelease = []; } }
|
|
2939
|
+
const p = await deriveCiPrecheck({ buildPlan: io.ciLocalPlan, required: ciRequired, releaseRequired: useRelease ? ciRelease : null, releaseBranch: useRelease ? releaseBranch : "", cfg: ciCfg, wt, base, lane, files, perCommandMs: vcfg.precheckTimeoutSeconds * 1000, writeFile: (rel, text) => io.fs.write(`${wt}/${rel}`, text), skipJobs: ciGaveUp });
|
|
2871
2940
|
for (const c of p.commands) ciDerived.set(c.command, c);
|
|
2941
|
+
if (useRelease && p.parity?.length) {
|
|
2942
|
+
ev({ event: "CI_PRECHECK_PARITY", round, release: releaseBranch, gaps: p.parity });
|
|
2943
|
+
if (!round) { const issues = await reportParityGaps({ ghc, repo, release: releaseBranch, gaps: p.parity }); T.decisions.push(`Lane-check parity gap(s) vs ${releaseBranch}: ${p.parity.map((g) => g.context).join(", ")}${issues.length ? ` (filed ${issues.map((n) => `#${n}`).join(", ")})` : ""}`); }
|
|
2944
|
+
}
|
|
2872
2945
|
ev({ event: "CI_PRECHECK_PLAN", round, source: p.source, ...(p.note ? { note: p.note } : {}), commands: p.commands.map(({ job, name, workflow, kind, why, steps, command }) => ({ job, name, workflow, kind, why, steps, command })), skipped: p.skipped, unrunnable: p.unrunnable });
|
|
2873
2946
|
if (!round) T.decisions.push(`CI precheck (${p.source}): ${p.commands.length ? p.commands.map((c) => `${c.name} (${c.why})`).join(", ") : "no job to run locally"}${p.unrunnable.length ? `; unrunnable: ${p.unrunnable.map((u) => `${u.name}: ${u.reason}`).join("; ")}` : ""}`);
|
|
2874
2947
|
return p.commands.map((c) => c.command);
|
|
2875
2948
|
}
|
|
2949
|
+
// #6107: a ci.red recovery must not judge a stale tree: the base's current head is merged in before any check runs. A conflict
|
|
2950
|
+
// the engine cannot resolve deterministically ends base.conflict (recoverable), never ci.red for a branch that is only behind.
|
|
2951
|
+
// #6153: the same sync runs for an env.tool_missing recovery, and once more when a precheck round fails on a branch that is behind
|
|
2952
|
+
// its base (the base may have fixed the failing guard script): the lane's own stale copy of a check never decides a verdict.
|
|
2953
|
+
let precheckBaseSynced = false;
|
|
2954
|
+
const syncBaseForChecks = async (why, { parkOnConflict = false } = {}) => { // -> {ended} (a terminal result), {merged: true} (rerun the checks) or {merged: false}
|
|
2955
|
+
if (precheckBaseSynced || isSplit || !io.runCommand) return { merged: false };
|
|
2956
|
+
try { await git(["fetch", "origin", lane]); } catch { /* offline: the local ref */ }
|
|
2957
|
+
const behind = Number(String(await git(["rev-list", "--count", `HEAD..${base}`]).catch(() => "0")).trim()) || 0;
|
|
2958
|
+
if (behind <= 0) return { merged: false };
|
|
2959
|
+
precheckBaseSynced = true;
|
|
2960
|
+
let merged = true, conflicted = [];
|
|
2961
|
+
try { await git(["merge", "--no-edit", base]); } catch { merged = false; conflicted = String(await git(["diff", "--name-only", "--diff-filter=U"]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean); }
|
|
2962
|
+
if (!merged && conflicted.length) {
|
|
2963
|
+
const bm = o.baseMerge, cr = io.conflictResolve && bm && Object.values(bm).some((v) => v?.length) ? await io.conflictResolve({ cwd: wt, files: conflicted, cfg: bm }).catch(() => null) : null;
|
|
2964
|
+
if (cr?.resolved?.length && !(cr.remaining ?? []).length) { try { await git(["commit", "--no-edit"]); merged = true; } catch { /* abort below */ } }
|
|
2965
|
+
if (!merged) { // first-failure sync: a conflict falls back to the old path (builder fix round, PR-time base-sync resolves it); a recovery lane parks base.conflict (#6107)
|
|
2966
|
+
await git(["merge", "--abort"]).catch(() => {});
|
|
2967
|
+
ev({ event: "RECOVERY_BASE_SYNC", base, behind, result: "conflict", why, files: conflicted.slice(0, 20) });
|
|
2968
|
+
if (parkOnConflict) return { ended: await needsHuman(`The branch conflicts with ${base} in ${conflicted.slice(0, 20).join(", ")}; the checks were not judged on the stale tree (a conflicting base is not a check failure); nothing merged.`, OUTCOME_CODES.BASE_CONFLICT) };
|
|
2969
|
+
T.anomalies.push(`Base-sync before the checks hit a conflict with ${base} in ${conflicted.slice(0, 20).join(", ")}; checks judged on the branch as it is, the PR-time base-sync resolves it`);
|
|
2970
|
+
return { merged: false };
|
|
2971
|
+
}
|
|
2972
|
+
} else if (!merged) { await git(["merge", "--abort"]).catch(() => {}); T.anomalies.push(`Base-sync before the checks could not merge ${base} (${behind} commit(s) behind, no conflict files); checks judged on the branch as it is`); return { merged: false }; }
|
|
2973
|
+
ev({ event: "RECOVERY_BASE_SYNC", base, behind, result: "merged", why });
|
|
2974
|
+
T.decisions.push(`Merged ${base} (${behind} commit(s) behind) ${why}`);
|
|
2975
|
+
files = await changedFiles();
|
|
2976
|
+
return { merged: true };
|
|
2977
|
+
};
|
|
2978
|
+
if ((recover?.code === OUTCOME_CODES.CI_RED || recover?.code === OUTCOME_CODES.ENV_TOOL_MISSING) && !isSplit && io.runCommand) {
|
|
2979
|
+
const sy = await syncBaseForChecks("before the recovery's first check run", { parkOnConflict: true }); if (sy.ended) return sy.ended;
|
|
2980
|
+
}
|
|
2876
2981
|
let ciCommands = await ciPrecheckPlan(0);
|
|
2877
2982
|
const pickChecks = () => planPrecheck({ testMap, files, learned: [...learnedCommands, ...ciCommands], maxMinutes: o.precheck?.maxMinutes, verify: vcfg });
|
|
2878
2983
|
let picked = pickChecks();
|
|
@@ -2881,6 +2986,18 @@ export async function runCore(o) {
|
|
|
2881
2986
|
if (picked.source !== "learned") T.decisions.push(`Pre-PR checks selected from ${TEST_MAP_FILE}: ${picked.selected} of ${testMap.entries.length} entries${learnedCommands.length ? `, plus ${learnedCommands.length - picked.dropped.length} learned` : ""}${picked.dropped.length ? `; ${picked.dropped.length} mapped learned command(s) not matching the changed files left to CI` : ""}`);
|
|
2882
2987
|
if (picked.commands.length && io.runCommand) {
|
|
2883
2988
|
precheckRan = true;
|
|
2989
|
+
// #6106: dependencies for every package the checks touch are prepared before the checks run; a missing tool afterwards is env, not ci.red
|
|
2990
|
+
let depsReprovisioned = false;
|
|
2991
|
+
const flakeReran = new Set();
|
|
2992
|
+
const pyModTried = new Set(); // #6138
|
|
2993
|
+
const reprovisionDeps = async (why) => {
|
|
2994
|
+
if (depsReprovisioned || !io.deps?.prepare) return false;
|
|
2995
|
+
depsReprovisioned = true;
|
|
2996
|
+
try { const rp = await io.deps.prepare({ wt, repoKey: depcacheNamespace({ repo, fallback: repoKey(cwd) }), env: toolchain?.env ?? undefined }); depResults = Array.isArray(rp) ? rp : depResults; } catch { /* the check result below says what is still missing */ }
|
|
2997
|
+
ev({ event: "PRECHECK_DEPS_PREPARED", why });
|
|
2998
|
+
return true;
|
|
2999
|
+
};
|
|
3000
|
+
{ const unprepared = packageDirsMissingDeps(picked.commands, (rel) => existsSync(join(wt, rel))); if (unprepared.length) await reprovisionDeps(`no node_modules in ${unprepared.join(", ")}`); }
|
|
2884
3001
|
for (let round = 0; ; round++) {
|
|
2885
3002
|
await renew();
|
|
2886
3003
|
if (round) { ciCommands = await ciPrecheckPlan(round); picked = pickChecks(); }
|
|
@@ -2917,10 +3034,43 @@ export async function runCore(o) {
|
|
|
2917
3034
|
if (!failed.length && timedOut.length && (vcfg.precheckBlock || guardFailing(timedOut))) return await needsHuman(`Environment error (not a check failure): pre-PR check command(s) timed out even after one longer retry, which is host load rather than a failing check; no builder resume was spent, the branch is pushed and nothing merged: ${timedNames}`, ENV_VALIDATE_TIMEOUT);
|
|
2918
3035
|
if (!failed.length) { checkCommandsFailing = false; if (round) T.decisions.push(`Declared check commands pass after ${round} builder fix round(s)`); await gatePassed("precheck"); break; }
|
|
2919
3036
|
const names = failed.map((f) => `\`${f.command}\` (exit ${f.rc})`).join(", ");
|
|
2920
|
-
|
|
3037
|
+
// #5749/#6107: the park names each failing check and carries the last ~40 lines of its output, secrets redacted (run log too)
|
|
3038
|
+
const failTail = (fs) => { const rows = fs.map((f) => ({ name: ciDerived.get(f.command)?.name ?? null, command: f.command, rc: f.rc, tail: checkFailureTail(f, { name: ciDerived.get(f.command)?.name }) })); ev({ event: "PRECHECK_FAILED", round, checks: rows.map(({ name, command, rc, tail }) => ({ name, command, rc, tail })) }); return rows.map((r) => r.tail).join(""); };
|
|
3039
|
+
{ // #6153: a failing check on a branch behind its base is rerun once on the merged tree before it is classified (the base may have fixed the guard script)
|
|
3040
|
+
const sy = await syncBaseForChecks(`after a failing check, before classifying it (the base may have fixed the check's script)`); if (sy.ended) return sy.ended;
|
|
3041
|
+
if (sy.merged) { picked = pickChecks(); round--; continue; }
|
|
3042
|
+
}
|
|
3043
|
+
if (isSplit) return await needsHuman(`Declared check command(s) fail on the refactor:split move (no builder edits a split); nothing merged: ${names}${failTail(failed)}`, OUTCOME_CODES.CI_RED);
|
|
3044
|
+
{ // #6106: every failed check died on a missing tool/binary (not on its own assertion): prepare dependencies once and rerun, then it is env.tool_missing
|
|
3045
|
+
const gap = toolGapFailures(failed);
|
|
3046
|
+
if (gap.length && gap.length === failed.length) {
|
|
3047
|
+
{ // #6138: the probe passed but the run still lacks a module (isolated interpreter ignores user site): install it system-wide once, rerun, then it is env
|
|
3048
|
+
const mods = missingPythonModules(gap.map((f) => f.output).join("\n")).filter((m) => !pyModTried.has(m));
|
|
3049
|
+
if (mods.length && io.runCommand) {
|
|
3050
|
+
const root = process.getuid?.() === 0;
|
|
3051
|
+
for (const m of mods) { pyModTried.add(m); for (const command of genericInstallCommands({ kind: "python-module", tool: m }, { root })) await io.runCommand({ command, cwd: wt, timeoutMs: 600000, env: laneEnv() }).catch(() => null); }
|
|
3052
|
+
ev({ event: "PRECHECK_PYTHON_MODULE_INSTALL", modules: mods });
|
|
3053
|
+
round--; continue;
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
if (await reprovisionDeps("check failed on a missing tool")) { round--; continue; }
|
|
3057
|
+
ev({ event: "PRECHECK_TOOL_MISSING", commands: gap.map((f) => f.command) });
|
|
3058
|
+
return await needsHuman(`Environment error (not a check failure): declared check command(s) could not run because a tool or binary is missing, even after the dependencies were prepared; nothing merged: ${names}${failTail(gap)}`, OUTCOME_CODES.ENV_TOOL_MISSING);
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
{ // #6094: a failure in a test the diff does not touch gets one rerun before it can be ci.red or spend a builder round
|
|
3062
|
+
const dirty = await changedFiles();
|
|
3063
|
+
const todo = failed.filter((f) => !flakeReran.has(f.command) && failureOutsideDiff(f.output, dirty));
|
|
3064
|
+
if (todo.length && todo.length === failed.length) {
|
|
3065
|
+
for (const f of todo) flakeReran.add(f.command);
|
|
3066
|
+
const reruns = await heavyStep("precheck", async () => { const out = []; for (const f of todo) { try { out.push(await io.runCommand({ command: f.command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() })); } catch { out.push({ rc: 1 }); } } return out; });
|
|
3067
|
+
ev({ event: "PRECHECK_FLAKE_RERUN", round, commands: todo.map((f) => f.command), results: reruns.map((r) => r?.rc ?? null) });
|
|
3068
|
+
if (reruns.every((r) => r?.rc === 0)) { T.decisions.push(`Declared check(s) ${todo.map((f) => `\`${f.command}\``).join(", ")} failed in test file(s) the diff does not touch and passed on one rerun (flake); no fix round spent`); checkCommandsFailing = false; await gatePassed("precheck"); break; }
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
2921
3071
|
checkCommandsFailing = true;
|
|
2922
3072
|
{ const red = await guardRed(failed, { bypass: vcfg.guardBypass === true }); if (red === "bypass") { checkCommandsFailing = false; break; } if (red) return red; } // #5239: a guard that also fails on the base defers the lane; #5992: unless the lane is clear of the guarded surface
|
|
2923
|
-
if (round >= vcfg.maxRounds || !sessionId) { if (vcfg.precheckBlock || guardFailing(failed)) return await needsHuman(`Declared check command(s) still failing before the PR (verify.precheck_block); nothing merged: ${names}`, OUTCOME_CODES.CI_RED); T.anomalies.push(`Declared check command(s) still failing before the PR: ${names}`); break; }
|
|
3073
|
+
if (round >= vcfg.maxRounds || !sessionId) { if (vcfg.precheckBlock || guardFailing(failed)) return await needsHuman(`Declared check command(s) still failing before the PR (verify.precheck_block); nothing merged: ${names}${failTail(failed)}`, OUTCOME_CODES.CI_RED); T.anomalies.push(`Declared check command(s) still failing before the PR: ${names}`); break; }
|
|
2924
3074
|
T.decisions.push(`Declared check command(s) failed: ${names}; builder resumed (round ${round + 1}/${vcfg.maxRounds})`);
|
|
2925
3075
|
const before = String(await git(["rev-parse", "HEAD"])).trim();
|
|
2926
3076
|
const capped = capLogs(failed.map((f) => ({ ...f, log: f.output }))).map((f) => ({ command: f.command, rc: f.rc, output: f.log }));
|
|
@@ -2935,7 +3085,7 @@ export async function runCore(o) {
|
|
|
2935
3085
|
await fixRound("precheck", precheckFailurePrompt(quiet, vcfg.mode), [], "precheck", capped.map((f) => `${f.command}\n${f.output ?? ""}`).join("\n"));
|
|
2936
3086
|
await upsertStage("implementation");
|
|
2937
3087
|
result = (await readResult()) ?? result;
|
|
2938
|
-
if (String(await git(["rev-parse", "HEAD"])).trim() === before) { if (vcfg.precheckBlock || guardFailing(failed)) return await needsHuman(`Declared check command(s) failing and the builder made no new commit for them (verify.precheck_block); nothing merged: ${names}`, OUTCOME_CODES.CI_RED); T.anomalies.push(`Declared check command(s) failing and the builder made no new commit for them: ${names}`); break; }
|
|
3088
|
+
if (String(await git(["rev-parse", "HEAD"])).trim() === before) { if (vcfg.precheckBlock || guardFailing(failed)) return await needsHuman(`Declared check command(s) failing and the builder made no new commit for them (verify.precheck_block); nothing merged: ${names}${failTail(failed)}`, OUTCOME_CODES.CI_RED); T.anomalies.push(`Declared check command(s) failing and the builder made no new commit for them: ${names}`); break; }
|
|
2939
3089
|
files = await changedFiles();
|
|
2940
3090
|
}
|
|
2941
3091
|
}
|
|
@@ -2970,26 +3120,6 @@ export async function runCore(o) {
|
|
|
2970
3120
|
return await needsHuman(`The change adds dependencies between workspace packages that the frozen contract does not name${sessionId ? ", after one builder resume" : ""}; nothing merged:\n${edges.slice(0, 15).map((e) => `- ${e.from} → ${e.to} (${e.kind}, \`${e.manifest}\`)`).join("\n")}\n\nAdd each to the contract with a reason, or remove it.`, OUTCOME_CODES.STRUCTURE_UNDECLARED_EDGE);
|
|
2971
3121
|
}
|
|
2972
3122
|
}
|
|
2973
|
-
// ---- 3c. the target repo's devdocs freshness rule, when it has one: deterministic, before any PR, so a lane does not
|
|
2974
|
-
// pay for a failed required check. Exit 1 resumes the builder once; still failing is needs-human docs.stale.
|
|
2975
|
-
if (io.docsFreshness) {
|
|
2976
|
-
let docs = await io.docsFreshness({ cwd: wt, base }).catch(() => null);
|
|
2977
|
-
if (docs && !docs.ok && sessionId) {
|
|
2978
|
-
ev({ event: "DOCS_STALE", round: 1 });
|
|
2979
|
-
T.decisions.push("Docs freshness check failed; builder resumed once");
|
|
2980
|
-
const docsBefore = await changedFiles();
|
|
2981
|
-
await fixRound("docs", docsPrompt(docs.output), [], "docs", String(docs.output ?? ""));
|
|
2982
|
-
await upsertStage("implementation");
|
|
2983
|
-
result = (await readResult()) ?? result;
|
|
2984
|
-
await noteFreshnessDocs(docsBefore, true);
|
|
2985
|
-
docs = await io.docsFreshness({ cwd: wt, base }).catch(() => null);
|
|
2986
|
-
}
|
|
2987
|
-
verifyFacts.docs = docs;
|
|
2988
|
-
if (docs?.ok) await gatePassed("docs");
|
|
2989
|
-
if (docs && !docs.ok) {
|
|
2990
|
-
return await needsHuman(`The repository's docs freshness check still fails${sessionId ? " after one builder resume" : ""}; nothing merged:\n\n${String(docs.output).slice(0, 2000)}`, OUTCOME_CODES.DOCS_STALE);
|
|
2991
|
-
}
|
|
2992
|
-
}
|
|
2993
3123
|
// ---- 3d. enumerating tests (#4322): new symbols that tests listing their siblings do not name; one resume, then an
|
|
2994
3124
|
// anomaly (CI stays the gate). Sequence numbers the base already uses: renumbered at hand-off, still colliding = base.conflict.
|
|
2995
3125
|
if (io.enumeratingMissing && !isSplit) {
|
|
@@ -3198,6 +3328,12 @@ export async function runCore(o) {
|
|
|
3198
3328
|
if (ok.length) { T.decisions.push(`env.base_probe: guard command(s) ${ok.map((f) => `\`${f.command}\``).join(", ")} pass on the bare ${base} tip at the host; the sandbox base failure is environment, no issue filed`); baseRed = baseRed.filter((f) => !ok.includes(f)); }
|
|
3199
3329
|
}
|
|
3200
3330
|
if (!baseRed.length) return null;
|
|
3331
|
+
// #5913: a lane whose own diff touches the failing guard's files may be the base fix; deferring it behind the red it repairs is circular. Skip the deferral only when the guard re-run on the lane tree passes.
|
|
3332
|
+
const changedNow = String(await git(["diff", "--name-only", `${base}...HEAD`]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean);
|
|
3333
|
+
if (diffTouchesGuard({ changed: changedNow, failed: baseRed })) {
|
|
3334
|
+
const reruns = await heavyStep("precheck", async () => { const out = []; for (const f of baseRed) { try { out.push(await io.runCommand({ command: f.command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() })); } catch { out.push({ rc: 1 }); } } return out; });
|
|
3335
|
+
if (reruns.every((r) => r?.rc === 0)) { T.decisions.push(`Guard command(s) ${baseRed.map((f) => `\`${f.command}\``).join(", ")} fail on ${base} but pass on this lane's tree (the lane changes the files the failure names); not deferred (base.red)`); return null; }
|
|
3336
|
+
}
|
|
3201
3337
|
const att = await attributeBaseRed({ failed: baseRed, git, base });
|
|
3202
3338
|
if (bypass && baseRed.length === failed.length) { // R2: bypass only when every failed command is base-red; non-guard or lane-broken failures stay the lane's. #5992: a lane clear of the guarded surface goes on; the guard is re-run on the merged tree at merge (the base-sync post-merge gate)
|
|
3203
3339
|
let laneFiles = [];
|
|
@@ -3213,10 +3349,10 @@ export async function runCore(o) {
|
|
|
3213
3349
|
try { if (att?.sha) commitDate = String(await git(["show", "-s", "--format=%cI", att.sha])).trim(); } catch { /* no reopen */ }
|
|
3214
3350
|
const cmds = baseRed.map((f) => f.command), outputs = Object.fromEntries(cmds.map((c) => [c, tailOf(c)]));
|
|
3215
3351
|
const n = await reportBaseRed({ ghc: ghw, repo, base, att, laneIssue: issue, commands: cmds, outputs, baseSha, commitDate });
|
|
3216
|
-
T.decisions.push(`Guard command(s) ${cmds.map((c) => `\`${c}\``).join(", ")} also fail on ${base}${att ? ` (last change ${att.sha.slice(0, 12)}${att.issue ? `, #${att.issue}` : ""})` : ""}; lane deferred behind ${n ? `#${n}` : "the base fix"}`);
|
|
3352
|
+
T.decisions.push(`Guard command(s) ${cmds.map((c) => `\`${c}\``).join(", ")} also fail on ${base}${att ? ` (last change ${att.sha.slice(0, 12)}${att.issue ? `, #${att.issue}` : ""})` : ""}; lane deferred behind ${n ? `#${n}` : "the base fix"}; if this lane fixes it, change the guard's files or land it through review-finalize merge-gate --manual-pr --owner-requested`);
|
|
3217
3353
|
recordBaseVerdict({ repo, base, sha: baseSha, red: true, att, commands: cmds, outputs }); // #5992: later lanes and the dispatcher's probe reuse this verdict
|
|
3218
3354
|
ev({ event: "BASE_RED", commands: cmds, output: cmds.map((c) => tailOf(c).slice(-500)), sha: att?.sha ?? null, issue: att?.issue ?? null, tracked: n });
|
|
3219
|
-
return await finish("deferred", `base ${base} is red on guard command(s) ${cmds.join(", ")}; deferred behind ${n ? `#${n}` : "the base fix"}`, { code: OUTCOME_CODES.BASE_RED, retryInSeconds: 900 }, OUTCOME_CODES.BASE_RED);
|
|
3355
|
+
return await finish("deferred", `base ${base} is red on guard command(s) ${cmds.join(", ")}; deferred behind ${n ? `#${n}` : "the base fix"} (owner escape: review-finalize merge-gate --manual-pr --owner-requested)`, { code: OUTCOME_CODES.BASE_RED, retryInSeconds: 900 }, OUTCOME_CODES.BASE_RED);
|
|
3220
3356
|
}
|
|
3221
3357
|
const structureLine = structureNote(structure);
|
|
3222
3358
|
|
|
@@ -3307,12 +3443,9 @@ export async function runCore(o) {
|
|
|
3307
3443
|
ciRounds++; fixes++;
|
|
3308
3444
|
T.decisions.push(`CI verification red (${jobs}); builder resumed with the failed logs (round ${ciRounds}/${vcfg.maxRounds})`);
|
|
3309
3445
|
ev({ event: "CI_FIX_ROUND", trigger, round: ciRounds, jobs: sp.own.map((f) => f.job) });
|
|
3310
|
-
const ciBefore = io.docsFreshness ? await changedFiles() : [];
|
|
3311
|
-
const ciDocsStale = io.docsFreshness ? (await io.docsFreshness({ cwd: wt, base }).catch(() => null))?.ok === false : false;
|
|
3312
3446
|
await fixRound("ci", ciFailurePrompt(sp.own, vcfg.mode), [], "ci_red", failureLog(sp.own));
|
|
3313
3447
|
await upsertStage("implementation");
|
|
3314
3448
|
result = (await readResult()) ?? result;
|
|
3315
|
-
await noteFreshnessDocs(ciBefore, ciDocsStale);
|
|
3316
3449
|
if (String(await git(["rev-parse", "HEAD"])).trim() === head) {
|
|
3317
3450
|
// #4387/#4586: no commit says the failure is not the change's; the failed jobs were already rerun once on this head (before the round).
|
|
3318
3451
|
const rr = ciReruns.get(head)?.rr ?? { ok: false, detail: isSplit ? "refactor:split" : "no rerun seam" };
|
|
@@ -3356,7 +3489,7 @@ export async function runCore(o) {
|
|
|
3356
3489
|
const wantsDecision = (Array.isArray(result?.amendments) ? result.amendments : []).some((x) => x?.kind === "decision");
|
|
3357
3490
|
baseTree ??= wantsDecision ? String(await git(["ls-tree", "-r", "-z", "--name-only", base]).catch(() => "")).split("\0").filter(Boolean) : null;
|
|
3358
3491
|
const addedPaths = wantsDecision ? String(await git(["diff", "--name-only", "--diff-filter=A", `${base}...HEAD`]).catch(() => "")).split("\n").filter(Boolean) : [];
|
|
3359
|
-
const own =
|
|
3492
|
+
const own = Array.isArray(result?.amendments) ? result.amendments : [];
|
|
3360
3493
|
const ownKeys = new Set(own.map((x) => JSON.stringify(x)));
|
|
3361
3494
|
const dd = dedupeAddRequirements(frozen, [...priorAmendments.filter((x) => !ownKeys.has(JSON.stringify(x))), ...own]); // #5773: a requeue does not renumber a re-added row
|
|
3362
3495
|
const all = dd.amendments;
|
|
@@ -3377,7 +3510,7 @@ export async function runCore(o) {
|
|
|
3377
3510
|
}
|
|
3378
3511
|
pendingDecisions = a.decisions; // #4737: persisted only once the PR merges
|
|
3379
3512
|
effective = a.contract;
|
|
3380
|
-
return
|
|
3513
|
+
return []; // #6083: an invalid amendment is simply not applied; no amendment syntax or id-reuse gate
|
|
3381
3514
|
}
|
|
3382
3515
|
const IGNORE = [`${LEAN_DIR}/`];
|
|
3383
3516
|
/** Up to two reviewer runs; a reply without usable rows (unparseable, incomplete, inconsistent) is re-asked, never charged to the builder. */
|
|
@@ -3519,25 +3652,6 @@ export async function runCore(o) {
|
|
|
3519
3652
|
if (Object.keys(out).length) ev({ event: "VALIDATE_RERUN", runs: Object.entries(out).map(([id, x]) => ({ id, rc: x.rc, ...(x.engine ? { engine: true } : {}) })) });
|
|
3520
3653
|
return out;
|
|
3521
3654
|
}
|
|
3522
|
-
/** #4979 SPEC-2: rerun the frozen command of every substituted validate, so precheck accepts a substitute only for a command that cannot run. */
|
|
3523
|
-
async function rerunSubstitutedOriginals(contract) {
|
|
3524
|
-
const out = {};
|
|
3525
|
-
if (!io.runCommand) return out;
|
|
3526
|
-
const env = laneEnv();
|
|
3527
|
-
for (const v of contract.validate ?? []) {
|
|
3528
|
-
if (!v.substituted?.from) continue;
|
|
3529
|
-
let x;
|
|
3530
|
-
try { x = await heavyStep("precheck", async () => (await runWithTimeoutRetry((timeoutMs) => io.runCommand({ command: forgedockResolved(v.substituted.from), cwd: wt, timeoutMs, env }), vcfg.precheckTimeoutSeconds * 1000)).r); } catch (e) { x = { rc: 127, output: String(e?.message ?? e) }; }
|
|
3531
|
-
out[v.id] = { rc: Number.isInteger(x?.rc) ? x.rc : 1, output: String(x?.output ?? "") };
|
|
3532
|
-
// #5653: the substitute runs too, so conformance can judge "same test ids, same result" (equivalentRuns)
|
|
3533
|
-
if (out[v.id].rc !== 0 && out[v.id].rc !== 124) {
|
|
3534
|
-
let y; try { y = await heavyStep("precheck", async () => (await runWithTimeoutRetry((timeoutMs) => io.runCommand({ command: forgedockResolved(v.command), cwd: wt, timeoutMs, env }), vcfg.precheckTimeoutSeconds * 1000)).r); } catch { y = null; }
|
|
3535
|
-
if (y) out[v.id].sub = { rc: Number.isInteger(y.rc) ? y.rc : 1, output: String(y.output ?? "") };
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
if (Object.keys(out).length) ev({ event: "SUBSTITUTE_RERUN", runs: Object.entries(out).map(([id, x]) => ({ id, rc: x.rc })) });
|
|
3539
|
-
return out;
|
|
3540
|
-
}
|
|
3541
3655
|
/** #4693: select the guards this diff intersects and rerun their base test files; zero cost when none is selected. Best effort: an error skips the gate. */
|
|
3542
3656
|
let guardSel = [], guardNoted = "", laneRemoved = []; let guardEv = null; // #5752: laneRemoved: the lane's deleted paths, for mechanism-retired guards // #4705: this pass's guard_run event, emitted by the caller once the added wall time is known
|
|
3543
3657
|
async function guardGate(files) {
|
|
@@ -3571,7 +3685,6 @@ export async function runCore(o) {
|
|
|
3571
3685
|
if (!want.run) T.decisions.push(`Real-browser check skipped for interactive UI change (${ui.slice(0, 3).join(", ")}): ${want.reason} (#5285)`);
|
|
3572
3686
|
return { files: ui, ran: want.run, reason: want.reason, highRisk: riskPathHits(ui, riskPaths).length > 0 };
|
|
3573
3687
|
}
|
|
3574
|
-
let amendFixed = false;
|
|
3575
3688
|
/** #5436: a review started beside guard+precheck is dropped on every return that does not reach the reviewer. */
|
|
3576
3689
|
async function gate() {
|
|
3577
3690
|
try { return await gateRun(); } finally { specReview?.discard(); specReview = null; }
|
|
@@ -3602,26 +3715,10 @@ export async function runCore(o) {
|
|
|
3602
3715
|
domainsLogged = domains.join(",");
|
|
3603
3716
|
ev({ event: "REVIEW_DOMAINS", domains, enforced: dHits.length ? dHits : undefined, ...(pd === null ? { error: "roster.failed" } : {}) });
|
|
3604
3717
|
}
|
|
3605
|
-
const vIds = [...(frozen?.validate ?? []), ...(frozen?.regression ?? [])].map((v) => v?.id);
|
|
3606
|
-
const amendBad = (am) => [...new Set([...validateAmendments(am), ...amendmentKindProblems(am, vIds)])]; // #5089/#5986: the shared amendment schema, plus #5979's validate-row supersedes hint
|
|
3607
|
-
if (!amendFixed && sessionId && amendBad(result?.amendments).length) { // one in-lane correction, outside the conformance resume budget; a still-invalid shape is never posted
|
|
3608
|
-
amendFixed = true;
|
|
3609
|
-
const bad = amendBad(result.amendments);
|
|
3610
|
-
T.decisions.push(`Amendment kinds invalid (${bad.length}); builder asked to correct ${RESULT_FILE} once`);
|
|
3611
|
-
await builder(++attemptN, amendmentCorrectionPrompt(bad), sessionId, false, undefined, { mode: "resume", trigger: "contract_correction" });
|
|
3612
|
-
result = (await readResult()) ?? result;
|
|
3613
|
-
files = await changedFiles();
|
|
3614
|
-
}
|
|
3615
3718
|
const amendProblems = await amend();
|
|
3616
3719
|
const gateHead = String(await git(["rev-parse", "HEAD"])).trim();
|
|
3617
3720
|
const ciVerified = remoteVerify && ciVerifiedHead !== null && ciVerifiedHead === gateHead;
|
|
3618
3721
|
const hotspots = await hotspotsOf({ base, paths: files }); // #4502
|
|
3619
|
-
let counters = null; // #5751: recurrence.counters at the lane's merge base and at its head
|
|
3620
|
-
if (recCfg.counters.length) {
|
|
3621
|
-
const mb = String(await git(["merge-base", base, "HEAD"]).catch(() => "")).trim() || base;
|
|
3622
|
-
counters = { before: await countCounters({ git, ref: mb, counters: recCfg.counters }), after: await countCounters({ git, ref: "HEAD", counters: recCfg.counters }) };
|
|
3623
|
-
ev({ event: "COUNTERS", ...counters });
|
|
3624
|
-
}
|
|
3625
3722
|
const rx = await relaxationsOf(files); // #5237
|
|
3626
3723
|
relaxations = rx.relaxations;
|
|
3627
3724
|
if (relaxations.length) {
|
|
@@ -3632,16 +3729,15 @@ export async function runCore(o) {
|
|
|
3632
3729
|
// #5436: the review reads the same committed diff as guard+precheck, so its session starts now; reviewOnce adopts it, any earlier return discards it
|
|
3633
3730
|
const repro = await reproOf(effective);
|
|
3634
3731
|
// a precheck that already fails on facts at hand (no engine rerun) would discard the review, so it is not started then
|
|
3635
|
-
const early = triggerMode === "enforce"
|
|
3732
|
+
const early = triggerMode === "enforce" ? null : precheck({ contract: effective, result, changedFiles: files, ignore: IGNORE, ciVerified, frozen, repro, repoHas: repoTracks(String(await git(["ls-files"]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean)) });
|
|
3636
3733
|
specReview = !early || early.failures.length ? null : startSpeculative(async () => reviewerCall((await reviewPrep()).prompt));
|
|
3637
3734
|
const gateT0 = now(); let validateMs = 0;
|
|
3638
|
-
// #4693: guards run beside the validate rerun
|
|
3639
|
-
const validatePhase = phaseLedger.during("validate", async () => ({ runs: await rerunFailedValidatesRaw(effective, { ciVerified })
|
|
3640
|
-
const [{ runs: validateRuns
|
|
3735
|
+
// #4693: guards run beside the validate rerun
|
|
3736
|
+
const validatePhase = phaseLedger.during("validate", async () => ({ runs: await rerunFailedValidatesRaw(effective, { ciVerified }) })).finally(() => { validateMs = now() - gateT0; });
|
|
3737
|
+
const [{ runs: validateRuns }, guardFailures] = await Promise.all([validatePhase, guardGate(files)]);
|
|
3641
3738
|
// #5087: forge.yaml topology.route_reachability gates the route handlers this diff adds; unset = no check
|
|
3642
3739
|
const routeFailures = routeReachability && io.runCommand ? await routeReachabilityFailures({ command: routeReachability, paths: routePathsFromFiles(String(await git(["diff", "--name-only", "--diff-filter=A", `${base}...HEAD`]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean)), run: async ({ command }) => (await io.runCommand({ command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() }).then((x) => x?.r ?? x)) ?? { rc: 127 } }) : [];
|
|
3643
3740
|
// #5419: forge.yaml docs: user-facing surfaces need docs, and added /docs links must resolve; unset = no check
|
|
3644
|
-
const docsFail = docsConfig ? await docsFailures({ cfg: docsConfig, files, result, diff: String(await git(["diff", "-U0", `${base}...HEAD`]).catch(() => "")), tracked: String(await git(["ls-files"]).catch(() => "")).split("\n").filter(Boolean), run: io.runCommand ? async ({ command }) => (await io.runCommand({ command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() }).then((x) => x?.r ?? x)) ?? { rc: 127 } : null }) : [];
|
|
3645
3741
|
// #5752: forge.yaml outcome_evidence: a touched declared area needs a before/after on recorded real inputs; unset = no check
|
|
3646
3742
|
const outcomeFail = outcomeEvidenceConfig ? outcomeEvidenceFailures({ cfg: outcomeEvidenceConfig, files, result, contract: effective, exists: (p) => existsSync(join(wt, p)), checks: effective.requirements?.some((r) => r.disposition === "post-deploy") ? await rawChecksAt(git, [base, "HEAD"]) : null }) : [];
|
|
3647
3743
|
// #5428: forge.yaml pages: a public page needs design, SEO and GEO briefs and passes the deterministic page checks; unset = no check
|
|
@@ -3667,12 +3763,9 @@ export async function runCore(o) {
|
|
|
3667
3763
|
const guardRunMs = guardEv && !guardEv.error ? Math.max(0, now() - gateT0 - validateMs) : 0;
|
|
3668
3764
|
guardAddedMs += guardRunMs;
|
|
3669
3765
|
if (guardEv) ev({ ...guardEv, added_wall_ms: guardRunMs });
|
|
3670
|
-
const repoHas = (validateRuns && Object.keys(validateRuns).length)
|
|
3671
|
-
|
|
3672
|
-
const checkIds = effective.requirements?.some((r) => r.disposition === "post-deploy") ? new Set(Object.keys(await checksAt(git, [base, "HEAD"], wt))) : null;
|
|
3673
|
-
const removedPaths = (effective.validate ?? []).some((v) => v.substituted) || effective.mechanisms?.length ? await removedPathsOf(git, base) : []; // #4990; #5752: a mechanism supersedes retires deleted guard tests
|
|
3766
|
+
const repoHas = (validateRuns && Object.keys(validateRuns).length) ? repoTracks(String(await git(["ls-files"]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean)) : undefined;
|
|
3767
|
+
const removedPaths = effective.mechanisms?.length ? await removedPathsOf(git, base) : []; // #4990; #5752: a mechanism supersedes retires deleted guard tests
|
|
3674
3768
|
laneRemoved = removedPaths ?? [];
|
|
3675
|
-
const subBaseFiles = (effective.validate ?? []).some((v) => v.substituted) ? String(await git(["ls-tree", "-r", "-z", "--name-only", base]).catch(() => "")).split("\0").filter(Boolean) : []; // #5003
|
|
3676
3769
|
const baselineRuns = [];
|
|
3677
3770
|
for (const b of matchBaselines(files, vcfg.baselines)) { // #5448: project baseline suites for the changed paths, enforced
|
|
3678
3771
|
let x;
|
|
@@ -3680,9 +3773,7 @@ export async function runCore(o) {
|
|
|
3680
3773
|
baselineRuns.push({ ...b, rc: Number.isInteger(x?.rc) ? x.rc : 1, output: String(x?.output ?? "") });
|
|
3681
3774
|
}
|
|
3682
3775
|
if (baselineRuns.length) ev({ event: "BASELINES_RUN", runs: baselineRuns.map((b) => ({ run: b.run, rc: b.rc })) });
|
|
3683
|
-
|
|
3684
|
-
const ciBudgetFail = await ciBudgetFailures({ cfg: ciBudget ?? parseCiBudget(null), base, git }).catch((e) => { ev({ event: "CI_BUDGET_GATE_ERROR", error: String(e?.message ?? e).slice(0, 200) }); return []; });
|
|
3685
|
-
const pc = precheck({ baselineFailures: baselineFailures(baselineRuns), contract: effective, result, changedFiles: files, ignore: IGNORE, ciVerified, hotspots, counters, recurrence, repro: (adequacyIn.repro = repro), validateRuns, repoHas, frozen, checkIds, guardFailures, coupledFailures: await coupledOf(files), relaxationFailures: relaxationFailures(rx), routeFailures, docsFailures: docsFail, outcomeEvidenceFailures: outcomeFail, ciBudgetFailures: ciBudgetFail, pageFailures: [...pageFail, ...designFail], seamFailures: seamFail, docsPaths: docsConfig ? [...(docsConfig.paths ?? []), ...(docsConfig.registries ?? [])] : null, prodParityFailures, newOffKeys: await newOffKeysOf(), uiBrowser: uiBrowserOf(files), substitutedRuns, removedPaths, baseFiles: subBaseFiles });
|
|
3776
|
+
const pc = precheck({ baselineFailures: baselineFailures(baselineRuns), contract: effective, result, changedFiles: files, ignore: IGNORE, ciVerified, repro: (adequacyIn.repro = repro), validateRuns, repoHas, frozen, guardFailures, coupledFailures: await coupledOf(files), relaxationFailures: relaxationFailures(rx), routeFailures, outcomeEvidenceFailures: outcomeFail, pageFailures: [...pageFail, ...designFail], seamFailures: seamFail, prodParityFailures, newOffKeys: await newOffKeysOf(), uiBrowser: uiBrowserOf(files), removedPaths });
|
|
3686
3777
|
// #5447: an install failure for a package the changed files import blocks (env.tool_missing); unrelated ones are logged
|
|
3687
3778
|
const depFail = depInstallFailures({ results: depResults, changedFiles: files });
|
|
3688
3779
|
for (const l of depFail.logged) if (!T.decisions.includes(l)) T.decisions.push(l);
|
|
@@ -3739,18 +3830,17 @@ export async function runCore(o) {
|
|
|
3739
3830
|
adequacyTel = testAdequacyTelemetry(effective, adequacy, { repro: adequacyIn.repro, mutation: adequacyIn.mutation, regression: regressionRan(effective, adequacyIn) });
|
|
3740
3831
|
// an environment or repro-verdict failure is settled first (already-fixed, env.repro_unrunnable): adequacy never mixes into it
|
|
3741
3832
|
const adqFail = pc.failures.some((f) => ENV_CODES.includes(f.code) || String(f.kind ?? "").startsWith("repro")) ? [] : testAdequacyFailures(adequacy, { bug: adequacyIn.bug, firstRound: resumes === 0 });
|
|
3742
|
-
Object.assign(verifyFacts, { precheck: pc.failures, amendments:
|
|
3833
|
+
Object.assign(verifyFacts, { precheck: pc.failures, amendments: [], hotspots: Boolean(hotspots && hotspots.enabled !== false && Array.isArray(hotspots.files)) });
|
|
3743
3834
|
// #4323/#4334: a missing host tool or module, or a repro test the harness could not run, is an environment error:
|
|
3744
3835
|
// never a conformance failure, never a builder resume
|
|
3745
|
-
|
|
3746
|
-
const preSplit = splitAdvisory([...pc.failures
|
|
3836
|
+
// #6083: environment codes are advisory too (CI decides); only a repo that sets the code to enforce parks on them
|
|
3837
|
+
const preSplit = splitAdvisory([...pc.failures, ...mutBlock, ...adqFail], { enforce: enforcedKinds() });
|
|
3747
3838
|
noteAdvisory(preSplit.advisory);
|
|
3748
|
-
const
|
|
3839
|
+
const envFails = preSplit.block.filter((f) => ENV_CODES.includes(f.code));
|
|
3840
|
+
const pre = preSplit.block.filter((f) => !ENV_CODES.includes(f.code));
|
|
3749
3841
|
if (pre.length) ev({ event: "PRECHECK", failures: pre.map((f) => f.code) });
|
|
3750
3842
|
// #5080: the repro already passes on the base and the diff changes no source: the fix is on the base, not missing
|
|
3751
3843
|
if (alreadyFixedOnBase(pre, files, IGNORE)) return { state: "already-fixed", by: "precheck", failures: pre };
|
|
3752
|
-
// #5729: a missing /design spec or visual evidence is not a builder fix: end design.spec_required before any resume or recovery lane
|
|
3753
|
-
if (pre.length && !recording() && specOnlyFailures(pre)) return { state: "spec-only", by: "precheck", failures: pre };
|
|
3754
3844
|
if (pre.length && !recording()) return { state: "nonconforming", by: "precheck", failures: pre };
|
|
3755
3845
|
// shadow: the builder's own failed checks block before any reviewer tokens are spent (#4160)
|
|
3756
3846
|
const hard = recording() ? blockingOf(pre, SHADOW_PRE_BLOCKS).block : [];
|
|
@@ -3872,7 +3962,6 @@ export async function runCore(o) {
|
|
|
3872
3962
|
const explained = explainFailures(outcome.failures, effective); // #4265: name the unmet requirement, not only the code
|
|
3873
3963
|
const list = explained.slice(0, 15).map((f) => `- ${f.code}: ${f.detail}`).join("\n");
|
|
3874
3964
|
if (outcome.state === "environment") return await envNeedsHuman(outcome.failures);
|
|
3875
|
-
if (outcome.state === "spec-only") return await needsHuman(`The page gate needs an approved FORGE:DESIGN_SPEC (run /design) or visual evidence a builder resume cannot produce, so no resume or recovery lane was spent:\n\n${list}`, OUTCOME_CODES.DESIGN_SPEC_REQUIRED, { ask: `Run /design for #${issue}` });
|
|
3876
3965
|
// #5371: a remote sandbox is a different environment from the host: its failed frozen validate is rerun once in a local recovery lane before it counts
|
|
3877
3966
|
// #5732: so is a repro head failure whose output carries no assertion text (an env error of the sandbox, not a red test)
|
|
3878
3967
|
if (o.placement?.where === "remote" && !recover && outcome.failures?.length && outcome.failures.every((f) => (f?.kind === "validate_failed" && isEnvValidateFailure(f.output)) || (f?.kind === "repro_red_green" && f.head === "FAILED" && f.assertion === false))) {
|
|
@@ -3898,7 +3987,12 @@ export async function runCore(o) {
|
|
|
3898
3987
|
if (outcome.state === "review.incomplete") return await needsHuman(`The conformance review was incomplete twice (a review without complete rows cannot pass); nothing merged:\n${list}`, OUTCOME_CODES.REVIEW_INCOMPLETE);
|
|
3899
3988
|
if (outcome.state === "review.inconsistent") return await needsHuman(`The conformance reviewer twice said NONCONFORMING without a failing row; nothing merged.`, OUTCOME_CODES.REVIEW_INCONSISTENT);
|
|
3900
3989
|
let failKey = JSON.stringify((outcome.failures ?? []).map((f) => `${f.code}|${f.detail}`).sort()); // #5644: a round that leaves the failure set unchanged ends the rounds
|
|
3901
|
-
if (!sessionId || resumes >= (builderFixable(outcome.failures) ? reviewMaxResumes : 1) || failKey === lastFailKey)
|
|
3990
|
+
if (!sessionId || resumes >= (builderFixable(outcome.failures) ? reviewMaxResumes : 1) || failKey === lastFailKey) {
|
|
3991
|
+
// #6058: a requirement with no status row was skipped after the targeted resume, not failed: a distinct park (kind requirement_no_status)
|
|
3992
|
+
const skippedIds = [...new Set((outcome.failures ?? []).filter((f) => f?.kind === "requirement_no_status" && f.reqId).map((f) => f.reqId))];
|
|
3993
|
+
if (skippedIds.length) return await needsHuman(`The builder did not address ${skippedIds.join(", ")}: no status row in ${RESULT_FILE}${resumes ? ` after ${resumes === 1 ? "a targeted resume" : `${resumes} targeted resumes`} naming ${skippedIds.length === 1 ? "it" : "them"}` : " (no session to resume)"} (skipped, not a failing check); nothing merged:\n${list}`, outcome.failures?.[0]?.code, { kind: "requirement_no_status", requirements: skippedIds });
|
|
3994
|
+
return await needsHuman(`The change does not conform to the issue and its frozen contract after ${resumes ? (resumes === 1 ? "one builder resume" : `${resumes} builder resumes`) : "the build (no session to resume)"} (${outcome.by}); nothing merged:\n${list}`, outcome.failures?.[0]?.code);
|
|
3995
|
+
}
|
|
3902
3996
|
lastFailKey = failKey;
|
|
3903
3997
|
resumes++;
|
|
3904
3998
|
T.decisions.push(`Not conforming (${outcome.by}${outcome.inconsistent ? ", reviewer verdict contradicted its rows" : ""}): ${[...new Set(outcome.failures.map((f) => f.code))].join(", ")} (${explained.slice(0, 5).map((f) => String(f.detail).slice(0, 160)).join("; ")}); builder resumed (round ${resumes} of ${reviewMaxResumes})`);
|
|
@@ -4150,7 +4244,8 @@ export async function runCore(o) {
|
|
|
4150
4244
|
await reportVerify();
|
|
4151
4245
|
syncRow.push(`${trigger}: ${clean ? "clean" : "conflicts"} (${baseSha})`);
|
|
4152
4246
|
T.baseSync = [`${syncs} sync(s)`, syncRow.join("; ")];
|
|
4153
|
-
await post("FORGE:BASE_SYNC", `## Base Sync\n**Trigger:** ${trigger}\n**Base merged:** \`${base}\` at \`${baseSha}\`\n**Result:** ${clean ? "clean merge" : `conflicts in ${files.map((f) => `\`${f}\``).join(", ") || "unknown files"}`}\n**Resolution:** ${how}\n**Tests run:** ${tests}\n**Re-review:** ${rereview}\n**New head:** \`${localHead.slice(0, 12)}\``);
|
|
4247
|
+
try { await post("FORGE:BASE_SYNC", `## Base Sync\n**Trigger:** ${trigger}\n**Base merged:** \`${base}\` at \`${baseSha}\`\n**Result:** ${clean ? "clean merge" : `conflicts in ${files.map((f) => `\`${f}\``).join(", ") || "unknown files"}`}\n**Resolution:** ${how}\n**Tests run:** ${tests}\n**Re-review:** ${rereview}\n**New head:** \`${localHead.slice(0, 12)}\``); } // #5898: the merge is done; a failed status comment is an anomaly, never an engine-error (as #5020 for FORGE:AMENDMENT)
|
|
4248
|
+
catch (e) { T.anomalies.push(`FORGE:BASE_SYNC comment not posted: ${String(e?.message ?? e).slice(0, 160)}`); }
|
|
4154
4249
|
return null;
|
|
4155
4250
|
}
|
|
4156
4251
|
const NR_TESTS = "not reported";
|
|
@@ -4212,7 +4307,7 @@ export async function runCore(o) {
|
|
|
4212
4307
|
}
|
|
4213
4308
|
lost = lost.filter((id) => !ran?.[id]);
|
|
4214
4309
|
}
|
|
4215
|
-
if (lost.length)
|
|
4310
|
+
if (lost.length) T.anomalies.push(`Validate result(s) ${lost.join(", ")} missing after a CI fix round on PR #${pr}: recorded, the lane continues (CI is the judge; #6083)`);
|
|
4216
4311
|
const rv = await doReview(); // never merge an unreviewed head
|
|
4217
4312
|
if (!rv) return await needsHuman("Reviewer returned no parseable verdict after a CI fix round.", OUTCOME_CODES.REVIEW_NO_VERDICT);
|
|
4218
4313
|
if (rv.env) return await envNeedsHuman(rv.env);
|