forgedock 1.65.0 → 1.67.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 +2 -0
- package/bin/engine/outcome-codes.mjs +1 -0
- package/bin/engine-cli.mjs +143 -19
- package/bin/forgedock.mjs +7 -0
- package/bin/help-text.mjs +3 -3
- package/bin/introspect-schedule.mjs +98 -0
- package/bin/introspect-schedule.test.mjs +67 -0
- package/bin/lean/advisory.test.mjs +49 -0
- package/bin/lean/amendment-schema.mjs +31 -0
- package/bin/lean/attempts.mjs +159 -0
- package/bin/lean/attempts.test.mjs +127 -0
- package/bin/lean/basered.mjs +55 -0
- package/bin/lean/basered.test.mjs +68 -1
- package/bin/lean/batch-health.mjs +13 -5
- package/bin/lean/batch-health.test.mjs +16 -0
- package/bin/lean/batch.mjs +62 -0
- package/bin/lean/batch.test.mjs +119 -3
- package/bin/lean/capwait.mjs +14 -3
- package/bin/lean/capwait.test.mjs +20 -0
- package/bin/lean/clear-breaker.mjs +14 -0
- package/bin/lean/commentstate.mjs +41 -0
- package/bin/lean/commentstate.test.mjs +32 -0
- package/bin/lean/concurrency.mjs +89 -0
- package/bin/lean/concurrency.test.mjs +113 -0
- package/bin/lean/conformance.e2e.test.mjs +4 -2
- package/bin/lean/conformance.mjs +35 -3
- package/bin/lean/conformance.test.mjs +52 -0
- package/bin/lean/depcache.mjs +9 -0
- package/bin/lean/efficiency.mjs +162 -0
- package/bin/lean/efficiency.test.mjs +79 -0
- package/bin/lean/execution.mjs +31 -13
- package/bin/lean/execution.test.mjs +46 -0
- package/bin/lean/failure-stop.mjs +46 -0
- package/bin/lean/failure-stop.test.mjs +45 -0
- package/bin/lean/fixtures/capacity-storm.json +609 -0
- package/bin/lean/lean.mjs +130 -30
- package/bin/lean/lean.test.mjs +138 -47
- package/bin/lean/liveness.mjs +37 -0
- package/bin/lean/liveness.test.mjs +33 -0
- package/bin/lean/orchestrate-attempts.test.mjs +74 -0
- package/bin/lean/orchestrate-envhold.test.mjs +17 -0
- package/bin/lean/orchestrate-pause.test.mjs +84 -0
- package/bin/lean/orchestrate-reconcile.test.mjs +147 -0
- package/bin/lean/orchestrate.mjs +202 -28
- package/bin/lean/phaseledger.mjs +6 -0
- package/bin/lean/phaseledger.test.mjs +13 -1
- package/bin/lean/prompts.mjs +6 -10
- package/bin/lean/reconcile.mjs +90 -0
- package/bin/lean/recurrence.mjs +38 -2
- package/bin/lean/recurrence.test.mjs +56 -1
- package/bin/lean/sandbox-remote.mjs +33 -2
- package/bin/lean/sched.mjs +19 -0
- package/bin/lean/sched.test.mjs +11 -1
- package/bin/lean/schedd-health.mjs +8 -1
- package/bin/lean/schedd-health.test.mjs +19 -0
- package/bin/lean/schedd.mjs +97 -10
- package/bin/lean/schedd.test.mjs +138 -1
- package/bin/lean/slo.mjs +126 -0
- package/bin/lean/slo.test.mjs +112 -0
- package/bin/lean/statuscomment.mjs +37 -0
- package/bin/lean/statuscomment.test.mjs +48 -1
- package/bin/lean/verify.mjs +2 -1
- package/bin/pool/agent.mjs +46 -8
- package/bin/pool/cache-sweep.mjs +41 -4
- package/bin/pool/cli.mjs +28 -1
- package/bin/pool/health.mjs +18 -0
- package/bin/pool/lane-tools.mjs +21 -0
- package/bin/pool/mirror-seed.mjs +21 -2
- package/bin/pool/router.mjs +6 -2
- package/bin/stats/attempts.mjs +54 -0
- package/bin/stats/attempts.test.mjs +30 -0
- package/bin/stats/churn.mjs +49 -0
- package/bin/stats/churn.test.mjs +31 -0
- package/bin/stats/index.mjs +11 -3
- package/commands/orchestrate.md +21 -18
- package/docs/CONFIG.md +1 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/package.json +1 -1
- package/pool/image/entrypoint.sh +2 -1
- package/scripts/check-devdocs-freshness.sh +1 -1
package/bin/lean/lean.mjs
CHANGED
|
@@ -16,24 +16,27 @@ import { hostname as osHostname, tmpdir as osTmpdir } from "node:os";
|
|
|
16
16
|
import { appendEvent } from "../engine/runlog.mjs";
|
|
17
17
|
import { testAdequacyRows, testAdequacyFailures, testAdequacyTelemetry, adequacyCounts, regressionRan } from "./testadequacy.mjs";
|
|
18
18
|
import { readSelfReview, compareSelfReview, firstReviewRecord, selfCheckFailures } from "./selfreview.mjs";
|
|
19
|
-
import { codeForTerminalReason, OUTCOME_CODES, ENV_VALIDATE_TIMEOUT, ENV_VALIDATE_PLACEMENT, ENV_ENGINE_OWNED_CODES } from "../engine/outcome-codes.mjs";
|
|
19
|
+
import { codeForTerminalReason, parkedLabel, OUTCOME_CODES, ENV_VALIDATE_TIMEOUT, ENV_VALIDATE_PLACEMENT, ENV_ENGINE_OWNED_CODES } from "../engine/outcome-codes.mjs";
|
|
20
20
|
import { ciPollDelayMs, ENGINE_VERSION, DEFAULT_MAX_SESSION_LIMIT_PAUSES, DEFAULT_SESSION_LIMIT_WAIT_MS, parseLeaseHolder, sanitizeLeaseHost } from "../engine.mjs";
|
|
21
21
|
import { openDependency, laneMergedPrs, dependencyOnLane, isTrustedComment, decomposedSubissues, isDecomposedRecord, reopenRevokedDecomposition } from "../engine/phases.mjs";
|
|
22
22
|
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, recurrenceFacts, recursLinks, designLaneNote } from "./recurrence.mjs"; // #5751
|
|
26
|
+
import { parseRecurrenceConfig, recurrenceFacts, recursLinks, designLaneNote, designDemanded } from "./recurrence.mjs"; // #5751
|
|
27
27
|
import { areaOf, acquireHotArea, countCounters } 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, unverifiedRequirements, mutationTargets, mutationFailures, runMutationCheck, MUTATION_SURVIVED, isBugIssue, scopeText, explainFailures, inIssue, validateContract, snapQuotes, cliUsageError, normalizeRunnerCommand, applyAmendments, amendmentKindProblems, precheck, alreadyFixedOnBase, READONLY_PROD_RE, EXTERNAL_NEED_RE, intakeHostWork, repoTracks, dropScopeValidates, tagOutOfBand, parseReview, decide, mergeReviewRows, reaskable, criterionLines, closePlan, followupItems, renderPendingFollowups, bucketTally, pendingTracking, unnamedEdges, structureNote, impliedDocDeliverables, convertDelivered } from "./conformance.mjs";
|
|
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, amendmentKindProblems, precheck, alreadyFixedOnBase, READONLY_PROD_RE, EXTERNAL_NEED_RE, intakeHostWork, repoTracks, dropScopeValidates, tagOutOfBand, parseReview, decide, mergeReviewRows, reaskable, criterionLines, closePlan, followupItems, renderPendingFollowups, bucketTally, pendingTracking, unnamedEdges, structureNote, impliedDocDeliverables, convertDelivered } from "./conformance.mjs";
|
|
29
29
|
import { checkAdmission, hostParallelism, ADMISSION_RETRY_SECONDS } from "./admission.mjs";
|
|
30
30
|
import { namedPaths, isTrustedIssueComment, prodFailureSignal } from "./prefilter.mjs";
|
|
31
|
-
import {
|
|
31
|
+
import { validateAmendments } from "./attempts.mjs";
|
|
32
|
+
import { writeStatus, postUpsert, postKeyed, isKeyedPost, isStatusPost, isUpsertPost, hasSection, clearPipelineLabels, IN_PLACE_MARKERS, commentId } from "./statuscomment.mjs";
|
|
33
|
+
import { decidePost } from "./commentstate.mjs"; // #5979
|
|
34
|
+
import { repeatSignature, countIdentical, shouldPark, summaryComment } from "./failure-stop.mjs"; // #5979
|
|
32
35
|
import { checksAt, mergeCheckEntries, CHECKS_FILE } from "./postdeploy-check.mjs";
|
|
33
36
|
import { matchBaselines, baselineFailures, foldRegression } from "./baselines.mjs";
|
|
34
37
|
import { readRollouts, detectNewOffKeys, rolloutModes, liveDeferralBlocks } from "./activation.mjs";
|
|
35
38
|
import { toolMisses } from "./toolplace.mjs";
|
|
36
|
-
import { hasRecipe, installLaneTools, RECIPES } from "../pool/lane-tools.mjs";
|
|
39
|
+
import { hasRecipe, installLaneTools, genericInstallCommands, RECIPES } from "../pool/lane-tools.mjs";
|
|
37
40
|
import { testRunnerProblems, preflightProbes, preflightProblems, unsetEnvVars, runPreflight, knownToContract, declaredEnv, depInstallFailures, toolMissingInstalls, testRunSummary, projectBinDirs, withLocalBins, manifestDepOwner } from "./preflight.mjs";
|
|
38
41
|
import { resolveLane, isDefaultLane, isShippedLane, DEFAULT_STAGING_BRANCH } from "./lane.mjs";
|
|
39
42
|
import { splitGate, rationaleLine } from "./decompose.mjs";
|
|
@@ -41,6 +44,7 @@ import { ceilingFor, modelInfo, restartDecision, DEFAULT_CEILING, WINDOW_SHARE,
|
|
|
41
44
|
import { dockerLabels, LEDGER_TTL_MS } from "./ledger.mjs";
|
|
42
45
|
import { batchImageCache, envNamesOf, provisionSandboxes } from "./testsandbox.mjs";
|
|
43
46
|
import { repoKey, estimateCostUsd } from "../runner.mjs";
|
|
47
|
+
import { depcacheNamespace } from "./depcache.mjs";
|
|
44
48
|
import { prepareToolchain } from "./toolchain.mjs";
|
|
45
49
|
import { toolStats } from "./toolstats.mjs";
|
|
46
50
|
import { readTestMap, readTestMapAtRef, selectCommands, mergeChecks, factsPath, TEST_MAP_FILE } from "./testmap.mjs";
|
|
@@ -66,7 +70,7 @@ import { reserveForBuild, revalidate } from "./seqreserve.mjs";
|
|
|
66
70
|
import { patchEcho, mutationsOf, runReproMutations, classifyRepro } from "./reproquality.mjs";
|
|
67
71
|
import { CHECKS_CLI, FORGEDOCK_CLI, REVIEWER_SYSTEM, LEAN_DIR, RESULT_FILE, INVESTIGATION_FILE, IMPLEMENTATION_FILE, CONTRACT_FILE, builderPlanPrompt, builderImplementPrompt, contractCorrectionPrompt, conformanceResumePrompt, amendmentCorrectionPrompt, reviewerPrompt, investigationVerdict, decisionNote, reviewerRepairPrompt, REVIEW_DIFF_MAX_BYTES, blockCorrectionPrompt, HUMAN_BLOCK_REASONS, structurePrompt, hotspotPlanNote, hotspotBuildRule, reproPlanNote, unrunnableValidateNote, docsPlanNote, pagePlanNote, contextPackNote, buildOpeningNote, sequenceBuildRule, docsPrompt, 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";
|
|
68
72
|
import { postMergeCommands } from "./postmerge.mjs";
|
|
69
|
-
import { classifyBaseRed, attribute as attributeBaseRed, runOnBase, reportBaseRed } from "./basered.mjs"; // #5239
|
|
73
|
+
import { classifyBaseRed, attribute as attributeBaseRed, runOnBase, reportBaseRed, recordBaseVerdict, bypassesGuard } from "./basered.mjs"; // #5239
|
|
70
74
|
import { guardAfterMerge, withHistoryRows } from "./guards.mjs";
|
|
71
75
|
import { parseProdParity, prodParityFailures as prodParityOf } from "./prodparity.mjs";
|
|
72
76
|
import { routePathsFromFiles, routeReachabilityFailures } from "./routecheck.mjs";
|
|
@@ -122,8 +126,9 @@ import { makePostRun } from "./postrun.mjs";
|
|
|
122
126
|
import { ensureSignedOff, salvageBranch, dropSalvageTracking } from "./signoff.mjs";
|
|
123
127
|
import { reconcileCheckpoints } from "./checkpoint-reconcile.mjs";
|
|
124
128
|
import { guardStagedDeletions, deletionEvidence, maxForeignDeletions } from "./delguard.mjs";
|
|
125
|
-
import { createLedger, flattenPhases } from "./phaseledger.mjs";
|
|
129
|
+
import { createLedger, flattenPhases, overheadStats } from "./phaseledger.mjs";
|
|
126
130
|
import { DEFAULT_CATALOG_SOURCES, deriveCatalog, mergeRecipes, rewriteMissed, isDriftFailure, rewriteSubprojectVenv } from "./validate-catalog.mjs";
|
|
131
|
+
import { holderGone } from "./liveness.mjs";
|
|
127
132
|
import { planStale, stackedBaseBlock, validStackedOn, cascadeDecision, invalidatedChecks } from "./stacking.mjs";
|
|
128
133
|
import { runLightStep, runLightTests, lightBuildPrompt, upgradeNote, renderLiteReceipt } from "./lightlane.mjs";
|
|
129
134
|
|
|
@@ -459,6 +464,9 @@ export async function runCore(o) {
|
|
|
459
464
|
usage.input += u.input_tokens ?? 0; usage.output += u.output_tokens ?? 0;
|
|
460
465
|
usage.cache += (u.cache_read_input_tokens ?? 0) + (u.cache_creation_input_tokens ?? 0);
|
|
461
466
|
}
|
|
467
|
+
let iss; // the issue as read at intake; declared early so the comment helpers below can see it
|
|
468
|
+
const localPosts = []; // #5979: comments this lane created, so a second post in the same run sees them
|
|
469
|
+
const allComments = () => [...(iss?.comments ?? []), ...localPosts];
|
|
462
470
|
let statusCache = null; // #5592: {id, sections} of this issue's one FORGE:STATUS comment, edited in place
|
|
463
471
|
const post = async (marker, body, on = issue) => {
|
|
464
472
|
if (on === issue && isStatusPost(marker)) { // machine-state markers: a section of the one status comment, not a comment of their own
|
|
@@ -473,9 +481,24 @@ export async function runCore(o) {
|
|
|
473
481
|
if (on === issue && isUpsertPost(marker)) { // one comment edited in place across requeues (the marker still leads the body)
|
|
474
482
|
return postUpsert({ gh: ghw, repo, issue: on, markers: marker, body, comments: iss?.comments, cap: capComment });
|
|
475
483
|
}
|
|
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
|
|
485
|
+
return postKeyed({ gh: ghw, repo, issue: on, marker: Array.isArray(marker) ? marker[0] : marker, body, cap: capComment });
|
|
486
|
+
}
|
|
476
487
|
const marks = (Array.isArray(marker) ? marker : [marker]).map((m) => `<!-- ${m} -->`).join("\n");
|
|
477
|
-
const
|
|
478
|
-
|
|
488
|
+
const full = capComment(`${marks}\n${body}`);
|
|
489
|
+
const first = Array.isArray(marker) ? marker[0] : marker;
|
|
490
|
+
if (on === issue && IN_PLACE_MARKERS.includes(first)) { // #5979: re-post only on a state change; FACTS and DEPENDENCY are edited in place
|
|
491
|
+
const d = decidePost({ marker: first, body: full, comments: allComments(), trusted: (c) => c?.__mine === true || isTrustedIssueComment(c) });
|
|
492
|
+
if (d.action === "skip") return d.prior.url ?? null;
|
|
493
|
+
const id = d.action === "patch" ? commentId(d.prior) : null;
|
|
494
|
+
if (id) {
|
|
495
|
+
try { await ghw(["api", "-X", "PATCH", `repos/${repo}/issues/comments/${id}`, "-f", `body=${full}`]); d.prior.body = full; return d.prior.url ?? null; } catch { /* deleted or not ours: a new comment */ }
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
const out = String(await ghw(["issue", "comment", String(on), "-R", repo, "--body", full])).trim();
|
|
499
|
+
const url = /https?:\/\/\S+/.exec(out)?.[0] ?? null;
|
|
500
|
+
if (on === issue) localPosts.push({ body: full, url, __mine: true });
|
|
501
|
+
return url;
|
|
479
502
|
};
|
|
480
503
|
/** Best effort; `true` when the transition succeeded (#4337: the decomposed close needs to know). */
|
|
481
504
|
const label = async (state) => { try { await retrying(() => io.transitionLabel(issue, state), { transient: GH_TRANSIENT_RE, attempts: 4, sleep: sleepFn, random }); return true; } catch { /* labels are best effort */ return false; } };
|
|
@@ -494,10 +517,12 @@ export async function runCore(o) {
|
|
|
494
517
|
if (!h || !Number.isSafeInteger(pid) || pid <= 0 || sanitizeLeaseHost(h) !== sanitizeLeaseHost(myHost)) return false;
|
|
495
518
|
try { (o.killFn ?? process.kill.bind(process))(pid, 0); return false; } catch (e) { return e?.code === "ESRCH"; }
|
|
496
519
|
};
|
|
520
|
+
// #5991: a lease of a batch that no longer owns the issue (a sandbox holder is pid 1 on another host) is taken over at once
|
|
521
|
+
const gone = (l) => holderDead(l) || holderGone(l, { liveBatches: typeof o.liveBatches === "function" ? (() => { try { const ids = o.liveBatches(issue); return Array.isArray(ids) ? [...ids, o.batchId] : null; } catch { return null; } })() : null });
|
|
497
522
|
const leaseTtlMs = o.leaseTtlMs ?? 25 * 60000; // below the projector's 30 min honour cap
|
|
498
523
|
let leaseState = null, leaseTimer = null;
|
|
499
524
|
const writeLease = (lease, extra = {}) => io.projector.writeState(issue, { ...leaseState, ...extra, lease });
|
|
500
|
-
const renew = async () => { if (io.projector && leaseState && !finishing) { /* never re-take a lease a finish (or signal) released */ try { await writeLease(leaseObj()); } catch { /* best effort */ } } };
|
|
525
|
+
const renew = async () => { if (io.projector && leaseState && !finishing) { /* never re-take a lease a finish (or signal) released */ try { if (o.batchId && io.projector.readState && (await io.projector.readState(issue))?.suspend) return; /* #6008: the dispatcher's suspend marker stays; the lease is not renewed under it */ await writeLease(leaseObj()); } catch { /* best effort */ } } };
|
|
501
526
|
async function releaseLease(reason, code = null, mergedTo = null) {
|
|
502
527
|
if (leaseTimer) { clearInterval(leaseTimer); leaseTimer = null; }
|
|
503
528
|
if (!io.projector || !leaseState) return;
|
|
@@ -588,7 +613,7 @@ export async function runCore(o) {
|
|
|
588
613
|
// #4169: heavy steps take a host semaphore slot (io.heavy); LLM phases are not gated. `heavyEnv` puts the heavy shims on
|
|
589
614
|
// the runner PATH; `waits` ({phase: ms}) and `heavyQueueMax` ride on the lane result for the batch report.
|
|
590
615
|
const heavyCfg = o.heavy ?? {}, heavyOn = Boolean(io.heavy) && heavyCfg.enabled !== false;
|
|
591
|
-
let heavyEnv = null, heavyWaitsFile = null, heavyQueueMax = 0, stage = "plan"
|
|
616
|
+
let heavyEnv = null, heavyWaitsFile = null, heavyQueueMax = 0, stage = "plan";
|
|
592
617
|
let seqBuildNote = ""; // #5235: numbers reserved for this lane at build start (prompt paragraph)
|
|
593
618
|
const recCfg = parseRecurrenceConfig(o.recurrenceConfig); // #5751: forge.yaml recurrence: (absent: mode on, threshold 2, no hot areas or counters)
|
|
594
619
|
let recurrence = null, hotLock = null; // #5751: the recurrence detection; the hot-area locks held until teardown
|
|
@@ -749,6 +774,7 @@ export async function runCore(o) {
|
|
|
749
774
|
...(reproQ ? { repro_quality: reproQ } : {}), conformance_mode: conformance === "enforce" || riskEnforced ? "enforce" : "shadow", ...(shadowWould ? { shadow_would: shadowWould } : {}), ...(firstReview ? { first_review: firstReview } : {}), ...(adequacyTel ?? {}),
|
|
750
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() } : {}),
|
|
751
776
|
...(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
|
+
Object.assign(term, overheadStats(null, term.wall_ms, term.model_ms)); // fixed_overhead_ms + model_share for the SLO
|
|
752
778
|
const phases = phaseLedger.snapshot(); // #4908: run log gets the nested ledger, FORGE:TELEMETRY the flattened scalars
|
|
753
779
|
ev({ ...term, phases });
|
|
754
780
|
await emit({ ...term, ...flattenPhases(phases) });
|
|
@@ -758,7 +784,7 @@ export async function runCore(o) {
|
|
|
758
784
|
// either launches the next attempt or relabels in settle.
|
|
759
785
|
if (recoverUnlabelled && recover.final && (reason === "ci-pending" || reason === "budget-exceeded")) { // #4505: budget-exceeded too
|
|
760
786
|
try {
|
|
761
|
-
await post("FORGE:NEEDS_HUMAN", `## Needs human\n${laneRecoveryEvidence(reason, code, detail)}\n\n_${usageLine()}_`);
|
|
787
|
+
await post("FORGE:NEEDS_HUMAN", `## Needs human\n${laneRecoveryEvidence(reason, code, detail)}\n\nsig=${repeatSignature(code, detail)}\n\n_${usageLine()}_`);
|
|
762
788
|
await ghc(["issue", "edit", String(issue), "-R", repo, "--add-label", "needs-human"]);
|
|
763
789
|
} catch { /* best effort */ }
|
|
764
790
|
}
|
|
@@ -835,8 +861,18 @@ export async function runCore(o) {
|
|
|
835
861
|
if (reg.existing && (!recover || recover.final) && await duplicateAskIssue(reg.existing, [why, askText])) return finish("invalid", `only content is the owner ask of #${reg.existing}; closed as a duplicate`); // #4730
|
|
836
862
|
link = reg.existing ? `Same owner ask as #${reg.existing} (one ask, linked): answering it unblocks this issue too.` : reg.entry ?? "";
|
|
837
863
|
}
|
|
864
|
+
// #5979: the second identical failure (same code and normalised detail as an earlier NEEDS_HUMAN/PARKED of this issue) parks with one summary, no recovery
|
|
865
|
+
const sig = repeatSignature(code, why);
|
|
866
|
+
const stoppable = code !== OUTCOME_CODES.BUILDER_BLOCKED && code !== OUTCOME_CODES.FAILURE_REPEATED && !ENV_ENGINE_OWNED_CODES.includes(code);
|
|
867
|
+
const identical = stoppable ? countIdentical(allComments(), sig, (c) => c?.__mine === true || isTrustedIssueComment(c)) + 1 : 1;
|
|
868
|
+
if (shouldPark(identical)) {
|
|
869
|
+
try { await post("FORGE:PARKED", summaryComment({ attempts: identical, code, detail: why, sig })); } catch (e) { labelFailed("comment", e); }
|
|
870
|
+
try { await ghc(["issue", "edit", String(issue), "-R", repo, "--add-label", "needs-human", "--add-label", parkedLabel(OUTCOME_CODES.FAILURE_REPEATED)]); } catch (e) { labelFailed("label", e); }
|
|
871
|
+
T.decisions.push(`Identical failure ${code} (${sig}) seen ${identical}x: parked as ${OUTCOME_CODES.FAILURE_REPEATED}, not relaunched`);
|
|
872
|
+
return finish("needs-human", why, { code: OUTCOME_CODES.FAILURE_REPEATED, ...extra, ...(recover ? { recovery: true } : {}) }, OUTCOME_CODES.FAILURE_REPEATED);
|
|
873
|
+
}
|
|
838
874
|
const notes = [premiseAnnotation(predicate), closedEdgeNote(closedDeps), link, askNote].filter(Boolean).join("\n");
|
|
839
|
-
try { await post("FORGE:NEEDS_HUMAN", `## Needs human\n${why}${notes ? `\n\n${notes}` : ""}${recoverUnlabelled ? `\n\n${laneRecoveryEvidence("needs-human", code, "")}` : ""}\n\n_${usageLine()}_`); }
|
|
875
|
+
try { await post("FORGE:NEEDS_HUMAN", `## Needs human\n${why}${notes ? `\n\n${notes}` : ""}${recoverUnlabelled ? `\n\n${laneRecoveryEvidence("needs-human", code, "")}` : ""}\n\nsig=${sig}\n\n_${usageLine()}_`); }
|
|
840
876
|
catch (e) { labelFailed("comment", e); }
|
|
841
877
|
// #5423/#5755: an environment gap is the engine's to recover or hold on an env issue, so a first lane leaves the issue visible; a final recovery lane (no seam) still labels
|
|
842
878
|
if (!(!recover && ENV_ENGINE_OWNED_CODES.includes(code))) {
|
|
@@ -1042,9 +1078,23 @@ export async function runCore(o) {
|
|
|
1042
1078
|
} else if (r.state === "foreign" || r.state === "error") ev({ event: "CHECKPOINT_RECONCILE_SKIPPED", state: r.state, ...(r.commits ? { commits: r.commits.length } : {}), ...(r.error ? { error: r.error } : {}) });
|
|
1043
1079
|
return r;
|
|
1044
1080
|
};
|
|
1081
|
+
/** #6008: a batch-dispatched lane re-reads its FORGE:STATE before it pushes or merges. No current lease of its batch, or a dispatcher hold/pause marker (`suspend`), suspends it (deferred, sandbox kept for adopt). Lanes without a batch (run-issue, tests) are not guarded. */
|
|
1082
|
+
const suspensionGuard = async (what) => {
|
|
1083
|
+
if (!o.batchId || !io.projector?.readState || !leaseState) return;
|
|
1084
|
+
let st = null;
|
|
1085
|
+
try { st = await io.projector.readState(issue); } catch { return; /* unreadable: fail open like admission */ }
|
|
1086
|
+
if (!st) return; // no FORGE:STATE readable at all: unknown, fail open
|
|
1087
|
+
const l = st?.lease, mine = l && (l.by === agentId || l.batch === o.batchId);
|
|
1088
|
+
const why = st?.suspend ? `the issue is ${st.suspend.reason ?? "held"} by the dispatcher (${st.suspend.batch ?? "batch"})`
|
|
1089
|
+
: !l ? "no dispatcher lease is current" : l.until <= now() ? "the dispatcher lease expired" : !mine && !gone(l) ? `the lease belongs to ${l.batch ?? l.by}, not batch ${o.batchId}` : null;
|
|
1090
|
+
if (!why) return;
|
|
1091
|
+
ev({ event: "LANE_SUSPENDED", what, reason: why });
|
|
1092
|
+
throw Object.assign(new Error(`refusing to ${what}: ${why}`), { deferCode: "lane.suspended", deferDetail: `suspended before ${what}: ${why}; the sandbox is kept for adopt` });
|
|
1093
|
+
};
|
|
1045
1094
|
const gitPush = async (args) => {
|
|
1046
1095
|
if (deletionRefusal && !args.includes("--delete")) throw Object.assign(new Error(deletionRefusal), { engineCode: OUTCOME_CODES.ENGINE_ERROR }); // #5819
|
|
1047
1096
|
await assertConfined(`git ${args.join(" ").slice(0, 80)}`); // #5825
|
|
1097
|
+
if (!args.includes("--delete")) await suspensionGuard("push"); // #6008
|
|
1048
1098
|
if (!args.includes("--delete")) { await untrackToolState({ git, base, ev, keep: await keepPaths() });
|
|
1049
1099
|
await reconcileLaneBranch();
|
|
1050
1100
|
try { await signOffUnpushed(); }
|
|
@@ -1547,7 +1597,7 @@ export async function runCore(o) {
|
|
|
1547
1597
|
if (io.projector) {
|
|
1548
1598
|
let st = null;
|
|
1549
1599
|
try { st = await io.projector.readState(issue); } catch { /* unreadable: proceed */ }
|
|
1550
|
-
if (st?.lease && st.lease.until > now() && st.lease.by !== agentId &&
|
|
1600
|
+
if (st?.lease && st.lease.until > now() && st.lease.by !== agentId && gone(st.lease)) {
|
|
1551
1601
|
ev({ event: "LEASE_TAKEOVER", from: st.lease.by, host: st.lease.host ?? null, pid: st.lease.pid ?? null });
|
|
1552
1602
|
onProgress({ event: "lease_takeover", detail: `taking over the lease of dead holder ${st.lease.by} (pid ${st.lease.pid ?? "?"} gone)` });
|
|
1553
1603
|
} else if (st?.lease && st.lease.until > now() && st.lease.by !== agentId) {
|
|
@@ -1582,7 +1632,7 @@ export async function runCore(o) {
|
|
|
1582
1632
|
ev({ event: "RUN_START", run: `core_${issue}_${t0}`, issue, lane, path: "core", version: ENGINE_VERSION, forge_version: ENGINE_VERSION, repo });
|
|
1583
1633
|
await emit({ event: "RUN_START", run: `core_${issue}_${t0}`, lane, path: "core" }); // #4630: lifecycle event stream
|
|
1584
1634
|
try {
|
|
1585
|
-
iss = JSON.parse(await ghc(["issue", "view", String(issue), "-R", repo, "--json", "number,title,body,state,comments,labels,updatedAt"]));
|
|
1635
|
+
iss = JSON.parse(await ghc(["issue", "view", String(issue), "-R", repo, "--json", "number,title,body,state,comments,labels,updatedAt,createdAt"]));
|
|
1586
1636
|
} catch (e) {
|
|
1587
1637
|
if (e?.deferCode) return finish("deferred", e.deferDetail ?? String(e.message), { code: e.deferCode, ...(e.retryInSeconds ? { retryInSeconds: e.retryInSeconds } : {}), ...(e.backendId ? { backendId: e.backendId } : {}), ...(e.cliResult != null ? { cliResult: e.cliResult } : {}), ...(typeof e.cliIsError === "boolean" ? { cliIsError: e.cliIsError } : {}), ...(e.account ? { account: e.account } : {}) }, e.deferCode); // #4662; #5168 backendId
|
|
1588
1638
|
return finish("engine-error", `cannot read issue: ${e.message}`);
|
|
@@ -1819,7 +1869,7 @@ export async function runCore(o) {
|
|
|
1819
1869
|
if (io.deps?.prepare) {
|
|
1820
1870
|
const tD = now();
|
|
1821
1871
|
let res;
|
|
1822
|
-
try { res = await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined }); } catch (e) { res = [{ status: "failed", eco: null, key: null, ms: 0, reason: String(e?.message ?? e).slice(0, 300) }]; }
|
|
1872
|
+
try { res = await io.deps.prepare({ wt, repoKey: depcacheNamespace({ repo, fallback: repoKey(cwd) }), env: toolchain?.env ?? undefined }); } catch (e) { res = [{ status: "failed", eco: null, key: null, ms: 0, reason: String(e?.message ?? e).slice(0, 300) }]; }
|
|
1823
1873
|
depResults = Array.isArray(res) ? res : []; // #5447: classified against the changed files at the gate
|
|
1824
1874
|
setupStep("deps", tD);
|
|
1825
1875
|
for (const r of Array.isArray(res) ? res : []) {
|
|
@@ -2031,7 +2081,7 @@ export async function runCore(o) {
|
|
|
2031
2081
|
/** #4188: the builder reads the live issue, so quotes are checked against the current text, not the RUN_START snapshot. Best effort. */
|
|
2032
2082
|
async function refreshIssue(stage) {
|
|
2033
2083
|
let next;
|
|
2034
|
-
try { next = JSON.parse(String(await ghc(["issue", "view", String(issue), "-R", repo, "--json", "number,title,body,state,comments,labels,updatedAt"]))); } catch { return; }
|
|
2084
|
+
try { next = JSON.parse(String(await ghc(["issue", "view", String(issue), "-R", repo, "--json", "number,title,body,state,comments,labels,updatedAt,createdAt"]))); } catch { return; }
|
|
2035
2085
|
if (!next || typeof next !== "object") return;
|
|
2036
2086
|
const tc = trustedOf(next), text = textOf(next, tc);
|
|
2037
2087
|
if (contractHash(issueText) === contractHash(text)) return;
|
|
@@ -2412,8 +2462,9 @@ export async function runCore(o) {
|
|
|
2412
2462
|
// #4450: the light lane (lean.light mode on, eligible, fresh lane): one builder session, derived contract, or an upgrade
|
|
2413
2463
|
const waitMs = Math.max(0, Number(contextWaitSeconds) || 0) * 1000, tHot = now();
|
|
2414
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
|
|
2415
|
-
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 }).catch(() => null);
|
|
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);
|
|
2416
2466
|
if (recurrence?.recurs) {
|
|
2467
|
+
recurrence.demanded = designDemanded(allComments()); // #5979: the design block is demanded once
|
|
2417
2468
|
ev({ event: "RECURRENCE", count: recurrence.count, threshold: recurrence.threshold, fixes: recurrence.evidence.map((e) => e.number), reason: recurrence.reason });
|
|
2418
2469
|
T.decisions.push(`Design lane (#5751): ${recurrence.reason}`);
|
|
2419
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 */ }
|
|
@@ -2642,10 +2693,10 @@ export async function runCore(o) {
|
|
|
2642
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
|
|
2643
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; };
|
|
2644
2695
|
let envMiss = await probeEnv();
|
|
2645
|
-
if (projDeps.length && io.deps?.prepare) { try { await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined }); ev({ event: "TESTPLAN_ENV_PROJECT_DEPS", names: projDeps }); } catch { /* the install gate reports failures */ } }
|
|
2696
|
+
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 */ } }
|
|
2646
2697
|
if (envMiss.length) {
|
|
2647
2698
|
try {
|
|
2648
|
-
if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined });
|
|
2699
|
+
if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: depcacheNamespace({ repo, fallback: repoKey(cwd) }), env: toolchain?.env ?? undefined });
|
|
2649
2700
|
if (envMiss.includes("pytest") && io.runCommand) await io.runCommand({ command: "python3 -m pip install --user --quiet pytest", cwd: wt, timeoutMs: 180000, env: laneEnv() });
|
|
2650
2701
|
envMiss = await probeEnv();
|
|
2651
2702
|
ev({ event: "TESTPLAN_ENV_PROVISIONED", remaining: envMiss });
|
|
@@ -2670,11 +2721,12 @@ export async function runCore(o) {
|
|
|
2670
2721
|
// #5331: a tool the sandbox itself lacks (probed where the lane runs) ends the lane before the builder implements; the tool-missing recovery places it on the host (orchestrate placeOf)
|
|
2671
2722
|
const remoteDeps = await depOwnerOf(); // #5683: a tool that is a tracked manifest dependency is prepared in the sandbox, never a lane_tools recipe or a host tool
|
|
2672
2723
|
const ownedDep = (t) => t === "forgedock" || remoteDeps.owner(t) !== null, notOwned = (m) => ({ ...m, tools: m.tools.filter((t) => !ownedDep(t)) });
|
|
2673
|
-
let
|
|
2674
|
-
|
|
2724
|
+
let rawMisses = planMisses ?? await preflightValidates(frozen).catch(() => []);
|
|
2725
|
+
let tm0 = toolMisses(rawMisses), tm = notOwned(tm0);
|
|
2726
|
+
if (tm0.tools.length && !tm.tools.length) { try { if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: depcacheNamespace({ repo, fallback: repoKey(cwd) }), env: toolchain?.env ?? undefined }); ev({ event: "REMOTE_PROJECT_DEPS", tools: tm0.tools }); } catch { /* the install gate reports failures */ } }
|
|
2675
2727
|
if (tm.tools.length) { // #5423: provision the sandbox once (nested lockfiles, pytest) and re-probe before giving the lane up
|
|
2676
2728
|
try {
|
|
2677
|
-
if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined });
|
|
2729
|
+
if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: depcacheNamespace({ repo, fallback: repoKey(cwd) }), env: toolchain?.env ?? undefined });
|
|
2678
2730
|
if (tm.tools.includes("pytest") && io.runCommand) await io.runCommand({ command: "python3 -m pip install --user --quiet pytest", cwd: wt, timeoutMs: 180000, env: laneEnv() });
|
|
2679
2731
|
tm = notOwned(toolMisses(await preflightValidates(frozen).catch(() => [])));
|
|
2680
2732
|
ev({ event: "REMOTE_PROVISIONED", remaining: tm.tools });
|
|
@@ -2689,6 +2741,22 @@ export async function runCore(o) {
|
|
|
2689
2741
|
tm = notOwned(toolMisses(await preflightValidates(frozen).catch(() => [])));
|
|
2690
2742
|
ev({ event: "REMOTE_PROVISIONED", remaining: tm.tools });
|
|
2691
2743
|
}
|
|
2744
|
+
if (noRecipe.length && tm.tools.some((t) => noRecipe.includes(t)) && io.runCommand) { // unclog: a generic pip/npm/apt install before any park
|
|
2745
|
+
const root = process.getuid?.() === 0, tried = [];
|
|
2746
|
+
for (const t of noRecipe.filter((x) => tm.tools.includes(x))) {
|
|
2747
|
+
const miss = (Array.isArray(rawMisses) ? rawMisses : []).find((m) => String(m?.tool) === t) ?? { kind: "command", tool: t };
|
|
2748
|
+
const shim = (o.hostCaps?.offloadWrappers ?? []).includes(t) && /^[A-Za-z0-9._-]+$/.test(t) // the sandbox is already where the wrapper sends work: run its argument directly
|
|
2749
|
+
? [`${root ? "" : "sudo "}sh -c 'printf "#!/bin/sh\\nexec \\"\\$@\\"\\n" > /usr/local/bin/${t} && chmod +x /usr/local/bin/${t}'`] : null;
|
|
2750
|
+
for (const command of shim ?? genericInstallCommands(miss, { root })) {
|
|
2751
|
+
const r = await io.runCommand({ command, cwd: wt, timeoutMs: 600000, env: laneEnv() }).catch((e) => ({ rc: 1, stderr: String(e?.message ?? e) }));
|
|
2752
|
+
tried.push({ tool: t, kind: miss.kind, rc: r?.rc ?? 0 });
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
rawMisses = await preflightValidates(frozen).catch(() => []);
|
|
2756
|
+
tm = notOwned(toolMisses(rawMisses));
|
|
2757
|
+
ev({ event: "REMOTE_TOOLS_GENERIC", tried, remaining: tm.tools });
|
|
2758
|
+
if (tried.length) T.decisions.push(`Remote sandbox lacked ${tried.map((x) => `${x.tool} (${x.kind})`).join(", ")}: generic install ${tm.tools.length ? `left ${tm.tools.join(", ")} missing` : "provided them"}`);
|
|
2759
|
+
}
|
|
2692
2760
|
if (noRecipe.length && tm.tools.some((t) => noRecipe.includes(t))) return await needsHuman(`Remote sandbox lacks ${noRecipe.join(", ")}, and no lane_tools recipe exists for ${noRecipe.length > 1 ? "them" : "it"}. Add it to \`execution.lane_tools\` in forge.yaml once a recipe exists, or add a recipe for ${noRecipe.join(", ")} in bin/pool/lane-tools.mjs (RECIPES). Known recipes: ${Object.keys(RECIPES).join(", ")}.`, OUTCOME_CODES.ENV_TOOL_MISSING, { toolNoRecipe: true }); // #5727: the orchestrator re-places it on the host without spending an attempt
|
|
2693
2761
|
}
|
|
2694
2762
|
if (tm.tools.length) {
|
|
@@ -2851,7 +2919,7 @@ export async function runCore(o) {
|
|
|
2851
2919
|
const names = failed.map((f) => `\`${f.command}\` (exit ${f.rc})`).join(", ");
|
|
2852
2920
|
if (isSplit) return await needsHuman(`Declared check command(s) fail on the refactor:split move (no builder edits a split); nothing merged: ${names}`, OUTCOME_CODES.CI_RED);
|
|
2853
2921
|
checkCommandsFailing = true;
|
|
2854
|
-
{ const red = await guardRed(failed); if (red) return red; } // #5239: a guard that also fails on the base defers the lane
|
|
2922
|
+
{ 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
|
|
2855
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; }
|
|
2856
2924
|
T.decisions.push(`Declared check command(s) failed: ${names}; builder resumed (round ${round + 1}/${vcfg.maxRounds})`);
|
|
2857
2925
|
const before = String(await git(["rev-parse", "HEAD"])).trim();
|
|
@@ -3113,7 +3181,7 @@ export async function runCore(o) {
|
|
|
3113
3181
|
function guardOn() { return vcfg.guardBlock !== false && (vcfg.invariants ?? []).length > 0; }
|
|
3114
3182
|
function guardFailing(failed) { return guardOn() && failed.some((f) => vcfg.invariants.includes(f.command)); }
|
|
3115
3183
|
/** #5239: guard commands failing here are run once on the base; failing there too, the lane is deferred (base.red) and the introducing issue is told. null: the failure is the lane's. */
|
|
3116
|
-
async function guardRed(failed) {
|
|
3184
|
+
async function guardRed(failed, { bypass = false } = {}) {
|
|
3117
3185
|
const g = failed.filter((f) => guardFailing([f]));
|
|
3118
3186
|
if (!g.length || isSplit || !io.runCommand) return null;
|
|
3119
3187
|
const baseRuns = await heavyStep("precheck", () => runOnBase({ commands: g.map((f) => f.command), git, runCommand: io.runCommand, mergeBase: base, cwd: wt, env: laneEnv(), timeoutMs: vcfg.precheckTimeoutSeconds * 1000 }));
|
|
@@ -3131,12 +3199,22 @@ export async function runCore(o) {
|
|
|
3131
3199
|
}
|
|
3132
3200
|
if (!baseRed.length) return null;
|
|
3133
3201
|
const att = await attributeBaseRed({ failed: baseRed, git, base });
|
|
3202
|
+
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
|
+
let laneFiles = [];
|
|
3204
|
+
try { laneFiles = String(await git(["diff", "--name-only", `${base}...HEAD`])).split("\n"); } catch { /* no diff: no bypass */ }
|
|
3205
|
+
if (bypassesGuard({ laneFiles, att })) {
|
|
3206
|
+
T.decisions.push(`Guard command(s) ${baseRed.map((f) => `\`${f.command}\``).join(", ")} are red on ${base} (last change ${att.sha.slice(0, 12)}${att.issue ? `, #${att.issue}` : ""}) but this lane touches none of the files they name; proceeding, the guard is re-run at merge`);
|
|
3207
|
+
ev({ event: "BASE_RED_BYPASS", commands: baseRed.map((f) => f.command), sha: att.sha, issue: att.issue ?? null });
|
|
3208
|
+
return "bypass";
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3134
3211
|
let baseSha = "", commitDate = "";
|
|
3135
3212
|
try { baseSha = String(await git(["rev-parse", base])).trim(); } catch { /* key falls back to the attributed sha */ }
|
|
3136
3213
|
try { if (att?.sha) commitDate = String(await git(["show", "-s", "--format=%cI", att.sha])).trim(); } catch { /* no reopen */ }
|
|
3137
3214
|
const cmds = baseRed.map((f) => f.command), outputs = Object.fromEntries(cmds.map((c) => [c, tailOf(c)]));
|
|
3138
3215
|
const n = await reportBaseRed({ ghc: ghw, repo, base, att, laneIssue: issue, commands: cmds, outputs, baseSha, commitDate });
|
|
3139
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"}`);
|
|
3217
|
+
recordBaseVerdict({ repo, base, sha: baseSha, red: true, att, commands: cmds, outputs }); // #5992: later lanes and the dispatcher's probe reuse this verdict
|
|
3140
3218
|
ev({ event: "BASE_RED", commands: cmds, output: cmds.map((c) => tailOf(c).slice(-500)), sha: att?.sha ?? null, issue: att?.issue ?? null, tracked: n });
|
|
3141
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);
|
|
3142
3220
|
}
|
|
@@ -3256,12 +3334,23 @@ export async function runCore(o) {
|
|
|
3256
3334
|
const kindsNow = () => (riskEnforced ? null : kinds);
|
|
3257
3335
|
const recording = () => shadow || (!riskEnforced && Object.keys(kinds).length > 0); // the gate records what it would have blocked
|
|
3258
3336
|
const blockingOf = (fs, allow) => blockingFailures(fs, { shadow, kinds: kindsNow(), allow });
|
|
3337
|
+
const enforcedKinds = () => Object.entries(kinds ?? {}).filter(([, m]) => m === "enforce").map(([c]) => c); // unclog: an explicit enforce re-promotes an advisory code
|
|
3259
3338
|
let effective = frozen, review = null, lastAmend = "", resumes = 0, lastFailKey = null, verdict = null, degraded = null, triggerSkipped = false, selfReviewCompared = false;
|
|
3260
3339
|
const TRIGGER_SKIP = "skipped (review.trigger enforce: no risk trigger)";
|
|
3261
3340
|
const triggerSkipNote = "## Conformance Review\n**Skipped by `review.trigger: enforce`:** no risk path, package edge or hotspot in the diff, and every deterministic gate passed; no reviewer ran (#4273).";
|
|
3262
3341
|
let pendingDecisions = [], firstRounds = null, firstReply = null, lastDecided = "";
|
|
3263
3342
|
let baseTree = null; // #4695: the base file list, read once and only when a decision amendment needs it
|
|
3264
3343
|
let genPaths = null; // forge#4519: maintenance.generated_paths from hotspots.sh (plan facts; one config-only call without them, never on light lanes)
|
|
3344
|
+
const advisorySeen = new Set();
|
|
3345
|
+
/** unclog: an advisory row is recorded once per lane as a decision line (trajectory + PR), never as a failure. */
|
|
3346
|
+
function noteAdvisory(rows) {
|
|
3347
|
+
for (const f of rows ?? []) {
|
|
3348
|
+
const line = `Advisory (not blocking): ${f.code}${f.kind ? ` ${f.kind}` : ""}: ${String(f.detail ?? "").slice(0, 300)}`;
|
|
3349
|
+
if (advisorySeen.has(line)) continue;
|
|
3350
|
+
advisorySeen.add(line); T.decisions.push(line);
|
|
3351
|
+
}
|
|
3352
|
+
if (rows?.length) ev({ event: "ADVISORY", rows: rows.map((f) => f.kind ?? f.code) });
|
|
3353
|
+
}
|
|
3265
3354
|
async function amend() {
|
|
3266
3355
|
genPaths ??= (hotFacts ? hotFacts.generated_paths : light ? [] : (await hotspotsOf({ paths: [] }))?.generated_paths) ?? [];
|
|
3267
3356
|
const wantsDecision = (Array.isArray(result?.amendments) ? result.amendments : []).some((x) => x?.kind === "decision");
|
|
@@ -3288,7 +3377,7 @@ export async function runCore(o) {
|
|
|
3288
3377
|
}
|
|
3289
3378
|
pendingDecisions = a.decisions; // #4737: persisted only once the PR merges
|
|
3290
3379
|
effective = a.contract;
|
|
3291
|
-
return a.problems.map((d) => ({ code: OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, detail: d }));
|
|
3380
|
+
return a.problems.map((d) => ({ code: OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, kind: "amendment_invalid", detail: d })); // unclog: advisory, the amendment is simply not applied
|
|
3292
3381
|
}
|
|
3293
3382
|
const IGNORE = [`${LEAN_DIR}/`];
|
|
3294
3383
|
/** Up to two reviewer runs; a reply without usable rows (unparseable, incomplete, inconsistent) is re-asked, never charged to the builder. */
|
|
@@ -3513,9 +3602,11 @@ export async function runCore(o) {
|
|
|
3513
3602
|
domainsLogged = domains.join(",");
|
|
3514
3603
|
ev({ event: "REVIEW_DOMAINS", domains, enforced: dHits.length ? dHits : undefined, ...(pd === null ? { error: "roster.failed" } : {}) });
|
|
3515
3604
|
}
|
|
3516
|
-
|
|
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
|
|
3517
3608
|
amendFixed = true;
|
|
3518
|
-
const bad =
|
|
3609
|
+
const bad = amendBad(result.amendments);
|
|
3519
3610
|
T.decisions.push(`Amendment kinds invalid (${bad.length}); builder asked to correct ${RESULT_FILE} once`);
|
|
3520
3611
|
await builder(++attemptN, amendmentCorrectionPrompt(bad), sessionId, false, undefined, { mode: "resume", trigger: "contract_correction" });
|
|
3521
3612
|
result = (await readResult()) ?? result;
|
|
@@ -3602,7 +3693,7 @@ export async function runCore(o) {
|
|
|
3602
3693
|
if (unrun.length && !gateProvisioned && (io.deps?.prepare || (wantsPytest && io.runCommand))) {
|
|
3603
3694
|
gateProvisioned = true;
|
|
3604
3695
|
try {
|
|
3605
|
-
if (io.deps?.prepare) { const rp = await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined }); depResults = Array.isArray(rp) ? rp : []; }
|
|
3696
|
+
if (io.deps?.prepare) { const rp = await io.deps.prepare({ wt, repoKey: depcacheNamespace({ repo, fallback: repoKey(cwd) }), env: toolchain?.env ?? undefined }); depResults = Array.isArray(rp) ? rp : []; }
|
|
3606
3697
|
if (wantsPytest && io.runCommand) await io.runCommand({ command: "python3 -m pip install --user --quiet pytest", cwd: wt, timeoutMs: 180000, env: laneEnv() });
|
|
3607
3698
|
} catch { /* the rerun below reports what is still missing */ }
|
|
3608
3699
|
ev({ event: "GATE_PROVISIONED", kinds: [...new Set(unrun.map((f) => f.kind))] });
|
|
@@ -3652,7 +3743,9 @@ export async function runCore(o) {
|
|
|
3652
3743
|
// #4323/#4334: a missing host tool or module, or a repro test the harness could not run, is an environment error:
|
|
3653
3744
|
// never a conformance failure, never a builder resume
|
|
3654
3745
|
const envFails = pc.failures.filter((f) => ENV_CODES.includes(f.code));
|
|
3655
|
-
const
|
|
3746
|
+
const preSplit = splitAdvisory([...pc.failures.filter((f) => !ENV_CODES.includes(f.code)), ...amendProblems, ...mutBlock, ...adqFail], { enforce: enforcedKinds() });
|
|
3747
|
+
noteAdvisory(preSplit.advisory);
|
|
3748
|
+
const pre = preSplit.block;
|
|
3656
3749
|
if (pre.length) ev({ event: "PRECHECK", failures: pre.map((f) => f.code) });
|
|
3657
3750
|
// #5080: the repro already passes on the base and the diff changes no source: the fix is on the base, not missing
|
|
3658
3751
|
if (alreadyFixedOnBase(pre, files, IGNORE)) return { state: "already-fixed", by: "precheck", failures: pre };
|
|
@@ -3699,6 +3792,12 @@ export async function runCore(o) {
|
|
|
3699
3792
|
const vf = await runVerifier();
|
|
3700
3793
|
if (vf.length) d = { state: "nonconforming", failures: vf, by: "verifier" };
|
|
3701
3794
|
}
|
|
3795
|
+
if (d.state === "nonconforming") { // unclog: advisory kinds from the reviewer/verifier never park a lane either
|
|
3796
|
+
const ds = splitAdvisory(d.failures, { enforce: enforcedKinds() });
|
|
3797
|
+
noteAdvisory(ds.advisory);
|
|
3798
|
+
if (!ds.block.length) d = { ...d, state: "conforms", failures: [] };
|
|
3799
|
+
else d = { ...d, failures: ds.block };
|
|
3800
|
+
}
|
|
3702
3801
|
if (!recording()) return { ...d, by: d.by ?? "review" };
|
|
3703
3802
|
// shadow: record what enforce would have done; block only on what the previous reviewer blocked on
|
|
3704
3803
|
const would = d.state === "conforms" && !pre.length ? "conforms" : d.state.startsWith("review.") ? d.state : "nonconforming";
|
|
@@ -4414,6 +4513,7 @@ export async function runCore(o) {
|
|
|
4414
4513
|
}
|
|
4415
4514
|
T.merge = [policyText, `merged at ${localHead.slice(0, 12)}`];
|
|
4416
4515
|
laneGuard(resumed?.base ?? lane, "merge");
|
|
4516
|
+
await suspensionGuard("merge"); // #6008
|
|
4417
4517
|
try {
|
|
4418
4518
|
phaseLedger.enter("merge");
|
|
4419
4519
|
await ghc(["pr", "merge", String(pr), "-R", repo, "--merge", "--match-head-commit", localHead]);
|