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
|
@@ -18,6 +18,7 @@ param(
|
|
|
18
18
|
[int] $AllowMemGb = 0, # 0 = half of physical RAM (min 4)
|
|
19
19
|
[string] $Distro = 'computeshare',
|
|
20
20
|
[ValidateSet('auto', 'mirrored', 'nat')] [string] $Networking = 'auto', # nat: for PCs where mirrored mode fails (e.g. WSL error 0x8007054f)
|
|
21
|
+
[switch] $KeepaliveAtStartup, # run the keep-alive at boot (S4U) for accounts that never log on interactively
|
|
21
22
|
[switch] $Force # kept for compatibility; the install never prompts
|
|
22
23
|
)
|
|
23
24
|
$ErrorActionPreference = 'Stop'
|
|
@@ -35,8 +36,13 @@ New-Item -ItemType Directory -Force -Path $installDir | Out-Null
|
|
|
35
36
|
$ts = (Get-Command tailscale.exe -ErrorAction SilentlyContinue).Source
|
|
36
37
|
if (-not $ts) { $ts = Join-Path $env:ProgramFiles 'Tailscale\tailscale.exe' }
|
|
37
38
|
if (-not (Test-Path $ts)) { Fail 'Tailscale is not installed.' }
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
# The CLI refuses (401) when Tailscale belongs to another Windows user and prints nothing; fall back to the adapter.
|
|
40
|
+
$tsIp = ''
|
|
41
|
+
try { $tsIp = ("$(& $ts ip -4 2>$null | Select-Object -First 1)").Trim() } catch { $tsIp = '' }
|
|
42
|
+
if ($tsIp -notmatch '^100\.') {
|
|
43
|
+
$tsIp = ("$(Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue | Where-Object { $_.InterfaceAlias -like 'Tailscale*' -and $_.IPAddress -like '100.*' } | Select-Object -First 1 -ExpandProperty IPAddress)").Trim()
|
|
44
|
+
}
|
|
45
|
+
if ($tsIp -notmatch '^100\.') { Fail 'Found no Tailscale IPv4 address (the tailscale CLI was denied or empty and no Tailscale adapter has a 100.x address).' }
|
|
40
46
|
Say "Tailscale IP $tsIp"
|
|
41
47
|
|
|
42
48
|
# --- Resource ceiling --------------------------------------------------------------------------------------------
|
|
@@ -222,10 +228,11 @@ $keep = Join-Path $installDir 'keepalive.ps1'
|
|
|
222
228
|
Copy-Item (Join-Path $PSScriptRoot 'keepalive.ps1') $keep -Force
|
|
223
229
|
$taskArgs = "-NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$keep`" -Distro $Distro -Port $Port -TailscaleIp $tsIp" + $(if ($mirrored) { ' -Mirrored' } else { '' })
|
|
224
230
|
$action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument $taskArgs
|
|
225
|
-
$trigger = New-ScheduledTaskTrigger -AtLogOn -User "$env:USERDOMAIN\$env:USERNAME"
|
|
231
|
+
$trigger = if ($KeepaliveAtStartup) { New-ScheduledTaskTrigger -AtStartup } else { New-ScheduledTaskTrigger -AtLogOn -User "$env:USERDOMAIN\$env:USERNAME" }
|
|
232
|
+
$logonType = if ($KeepaliveAtStartup) { 'S4U' } else { 'Interactive' }
|
|
226
233
|
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit ([TimeSpan]::Zero) -RestartCount 999 -RestartInterval (New-TimeSpan -Minutes 1)
|
|
227
234
|
# Highest: on NAT networking the task maintains a netsh portproxy, which needs an elevated token.
|
|
228
|
-
$principal = New-ScheduledTaskPrincipal -UserId "$env:USERDOMAIN\$env:USERNAME" -LogonType
|
|
235
|
+
$principal = New-ScheduledTaskPrincipal -UserId "$env:USERDOMAIN\$env:USERNAME" -LogonType $logonType -RunLevel Highest
|
|
229
236
|
Register-ScheduledTask -TaskName 'computeshare-keepalive' -Action $action -Trigger $trigger -Settings $settings -Principal $principal -Description 'computeshare agent keep-alive' -Force | Out-Null
|
|
230
237
|
Start-ScheduledTask -TaskName 'computeshare-keepalive'
|
|
231
238
|
|
|
@@ -53,7 +53,15 @@ function branchOk(cfg, branch) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// Does this workflow gate a pull request into the base branch? Returns '' when yes, else the reason it does not.
|
|
56
|
+
// With a release branch (a.releaseBranch, #6049) a workflow that gates a pull request into it, or runs on a push to it, also counts.
|
|
56
57
|
function gateReason(ev, a) {
|
|
58
|
+
const why = gateReasonLane(ev, a);
|
|
59
|
+
if (!why || !a.releaseBranch || a.releaseBranch === a.baseBranch) return why;
|
|
60
|
+
if (ev.pull_request && branchOk(ev.pull_request, a.releaseBranch) && pathsOk(ev.pull_request, a.changed)) return '';
|
|
61
|
+
if (ev.push && !(Array.isArray(ev.push.tags) && !Array.isArray(ev.push.branches) && !Array.isArray(ev.push['branches-ignore'])) && branchOk(ev.push, a.releaseBranch) && pathsOk(ev.push, a.changed)) return '';
|
|
62
|
+
return why;
|
|
63
|
+
}
|
|
64
|
+
function gateReasonLane(ev, a) {
|
|
57
65
|
const names = Object.keys(ev);
|
|
58
66
|
if (ev.pull_request) {
|
|
59
67
|
const c = ev.pull_request;
|
package/scripts/ci-local/cli.mjs
CHANGED
|
@@ -14,7 +14,7 @@ function parseArgs(argv) {
|
|
|
14
14
|
const t = argv[i];
|
|
15
15
|
const take = () => { if (i + 1 >= argv.length) throw new Error(`${t} needs a value`); return argv[++i]; };
|
|
16
16
|
if (t === '--repo') o.repo = take(); else if (t === '--base') o.base = take(); else if (t === '--base-branch') o.baseBranch = take();
|
|
17
|
-
else if (t === '--head-branch') o.headBranch = take(); else if (t === '--files') o.files = take().split(/[\n ]+/).filter(Boolean);
|
|
17
|
+
else if (t === '--head-branch') o.headBranch = take(); else if (t === '--release-branch') o.releaseBranch = take(); else if (t === '--files') o.files = take().split(/[\n ]+/).filter(Boolean);
|
|
18
18
|
else if (t === '--files-from') o.files = fs.readFileSync(take(), 'utf8').split('\n').filter(Boolean);
|
|
19
19
|
else if (t === '--out') o.out = take(); else if (t === '--plan') o.planFile = take(); else if (t === '--no-cache') o.noCache = true;
|
|
20
20
|
else if (t === '--budget-minutes') o.budgetMinutes = Number(take()); else if (t === '--max-parallel') o.maxParallel = Number(take());
|
|
@@ -62,8 +62,9 @@ export function buildPlan(opts) {
|
|
|
62
62
|
const tracked = git(repo, ['ls-files', '-z', '--cached', '--others', '--exclude-standard']).out.split('\0').filter(Boolean);
|
|
63
63
|
const baseFiles = baseSha ? listAtRef(repo, baseRef) : [];
|
|
64
64
|
|
|
65
|
+
const releaseBranch = opts.releaseBranch && opts.releaseBranch !== baseBranch ? String(opts.releaseBranch) : '';
|
|
65
66
|
const a = {
|
|
66
|
-
repo, baseRef, baseSha, baseBranch, headBranch, headSha: head, changed, from, tracked, config, repository: repoSlug(repo),
|
|
67
|
+
repo, releaseBranch, baseRef, baseSha, baseBranch, headBranch, headSha: head, changed, from, tracked, config, repository: repoSlug(repo),
|
|
67
68
|
defFiles(re) { return [...new Set([...baseFiles, ...tracked].filter((f) => re.test(f)))].sort(); },
|
|
68
69
|
readDefs(f) {
|
|
69
70
|
const baseText = baseSha ? readAtRef(repo, baseRef, f) : null;
|
|
@@ -76,7 +77,7 @@ export function buildPlan(opts) {
|
|
|
76
77
|
const defRe = new RegExp([gha, gitlab, circle, azure, bitbucket, buildkite].map((m) => m.DEF_RE.source).join('|'));
|
|
77
78
|
const defContents = a.defFiles(defRe).map((f) => { const d = a.readDefs(f); return `${f}\n${d.base}\n${d.head}`; }).join('\n--\n');
|
|
78
79
|
const changeContents = changed.map((f) => `${f}:${fileHash(repo, f)}`);
|
|
79
|
-
const key = sha256(JSON.stringify([PLAN_VERSION, repo, defContents, changeContents, baseSha, baseBranch, headBranch, hostClass(), config, process.version, process.env.FORGE_CI_LOCAL_SERVICES || '', fs.existsSync(path.join(repo, 'package.json')) ? sha256(fs.readFileSync(path.join(repo, 'package.json'))) : '']));
|
|
80
|
+
const key = sha256(JSON.stringify([PLAN_VERSION, repo, defContents, changeContents, baseSha, baseBranch, headBranch, hostClass(), config, releaseBranch, process.version, process.env.FORGE_CI_LOCAL_SERVICES || '', fs.existsSync(path.join(repo, 'package.json')) ? sha256(fs.readFileSync(path.join(repo, 'package.json'))) : '']));
|
|
80
81
|
const cacheDir = path.join(opts.cacheDir || path.join(homeForgeDir(), 'ci-local', 'plans'));
|
|
81
82
|
const cacheFile = path.join(cacheDir, key + '.json');
|
|
82
83
|
if (!opts.noCache && fs.existsSync(cacheFile)) {
|
package/scripts/ci-local.test.sh
CHANGED
|
@@ -518,7 +518,8 @@ echo '{"a":1}' > "$r/lib/data.json"; P=$(plan "$r")
|
|
|
518
518
|
has "jest: a changed data file widens (not reachable through imports)" "$(step_field "$P" task:npm:test 1 '.scope.widen_reason')" "unknown-language"
|
|
519
519
|
|
|
520
520
|
# ------------------------------------------------------------------------------------------------ ForgeDock's own workflows
|
|
521
|
-
|
|
521
|
+
# PR CI runs only on release PRs to main (owner decision 2026-11-27); staging is checked on push.
|
|
522
|
+
P=$(bash "$S" plan --repo "$ROOT" --base HEAD --base-branch main --head-branch release/spec-change --files "commands/work-on/build.md" --json --no-cache 2>/dev/null)
|
|
522
523
|
if [ -z "$P" ]; then bad "plan on ForgeDock's own workflows produced no output"; else
|
|
523
524
|
eq "ForgeDock: a spec change selects a check-commands job" runnable "$(state "$P" gha:check-commands:check-native-conflicts)"
|
|
524
525
|
eq "ForgeDock: a spec change selects the ci unit-tests job" runnable "$(state "$P" gha:ci:unit-tests)"
|
|
@@ -529,7 +530,7 @@ if [ -z "$P" ]; then bad "plan on ForgeDock's own workflows produced no output";
|
|
|
529
530
|
eq "ForgeDock: portability checks run" runnable "$(state "$P" portability:builtin)"
|
|
530
531
|
# Narrowing is asserted on a spec with a small reference reach (design-bench.md: ~10 referrers). Specs that name the release engine
|
|
531
532
|
# (build.md, review-pr-staging.md) sit near the 600-file fan-out cap, so any growth in bin/lean widens them to the full suite; that is the cap working.
|
|
532
|
-
PN=$(bash "$S" plan --repo "$ROOT" --base HEAD --base-branch
|
|
533
|
+
PN=$(bash "$S" plan --repo "$ROOT" --base HEAD --base-branch main --head-branch release/spec-change --files "commands/design-bench.md" --json --no-cache 2>/dev/null)
|
|
533
534
|
eq "ForgeDock: the unit-test step is narrowed by the reference graph" scoped "$(printf '%s' "$PN" | jq -r '[.jobs[] | select(.id == "gha:ci:unit-tests") | .steps[] | select(.scope.selector == "refgraph-nodetest") | .scope.mode][0]')"
|
|
534
535
|
fi
|
|
535
536
|
|
|
@@ -1134,5 +1135,16 @@ FIRST=$(printf '%s\n' "$OUT" | grep '^CI_LOCAL_JOB: pass' | head -n 1)
|
|
|
1134
1135
|
has "4057: the cheapest known job runs first (small before big)" "$FIRST" "gha:ci:small"
|
|
1135
1136
|
FORGE_TELEMETRY=off bash -c 'grep -q "wait_ms" "$0"' "$S" && ok || bad "4057: ci-local.sh forwards wait_ms to telemetry"
|
|
1136
1137
|
|
|
1138
|
+
# 6049: a workflow that only runs on a push to the release branch is a gate with --release-branch, not without it
|
|
1139
|
+
r=$(blank rel); mkdir -p "$r/.github/workflows"
|
|
1140
|
+
printf 'name: Release\non:\n push:\n branches: [main]\njobs:\n fmt:\n runs-on: ubuntu-latest\n steps:\n - run: echo fmt-check\n' > "$r/.github/workflows/release.yml"
|
|
1141
|
+
commit_base "$r"; echo x > "$r/a.txt"
|
|
1142
|
+
P=$(plan "$r" --base-branch dev --files "a.txt" | jq -c .)
|
|
1143
|
+
eq "release-only push workflow is not a lane gate without --release-branch" not-applicable "$(state "$P" gha:release)"
|
|
1144
|
+
P=$(plan "$r" --base-branch dev --files "a.txt" --release-branch main | jq -c .)
|
|
1145
|
+
eq "release-only push workflow is a gate with --release-branch" runnable "$(state "$P" gha:release:fmt)"
|
|
1146
|
+
P=$(plan "$r" --base-branch dev --files "a.txt" --release-branch other | jq -c .)
|
|
1147
|
+
eq "a different release branch does not select it" not-applicable "$(state "$P" gha:release)"
|
|
1148
|
+
|
|
1137
1149
|
echo "ci-local.test.sh: $pass passed, $fail failed"
|
|
1138
1150
|
[ "$fail" -eq 0 ]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
3
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
/**
|
|
5
|
+
* failure-census: why lanes left the happy path, measured from the register (read-only).
|
|
6
|
+
*
|
|
7
|
+
* node scripts/failure-census.mjs --repo owner/repo [--since YYYY-MM-DD] [--state open|all] [--limit N]
|
|
8
|
+
* [--batches ~/.forge/batches] [--no-batches] [--json]
|
|
9
|
+
*
|
|
10
|
+
* Reads issue comments with `gh` (issues updated since --since that have comments) and the local batch logs of that repo,
|
|
11
|
+
* then prints the census (bin/lean/failure-census.mjs): parks by class and day, normalised failure rows, amendment
|
|
12
|
+
* classes, base-sync conflict hotspots, most-parked issues, batch outcome/deferral codes and phase timing.
|
|
13
|
+
* Use it before changing a gate, the engine or the pool: solve the measured classes, not a guess.
|
|
14
|
+
*/
|
|
15
|
+
import { execFileSync } from "node:child_process";
|
|
16
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
17
|
+
import { homedir } from "node:os";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import { censusIssues, censusBatchRows, renderCensus } from "../bin/lean/failure-census.mjs";
|
|
20
|
+
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
const opt = (k, d = null) => { const i = args.indexOf(k); return i >= 0 && args[i + 1] && !args[i + 1].startsWith("--") ? args[i + 1] : d; };
|
|
23
|
+
const has = (k) => args.includes(k);
|
|
24
|
+
const repo = opt("--repo");
|
|
25
|
+
if (!repo || !/^[\w.-]+\/[\w.-]+$/.test(repo)) { console.error("usage: failure-census.mjs --repo owner/repo [--since YYYY-MM-DD] [--state open|all] [--limit N] [--batches DIR] [--no-batches] [--json]"); process.exit(2); }
|
|
26
|
+
const since = opt("--since");
|
|
27
|
+
const state = opt("--state", "all");
|
|
28
|
+
const limit = Number(opt("--limit", "300"));
|
|
29
|
+
const gh = (a) => execFileSync("gh", a, { encoding: "utf8", maxBuffer: 256 * 1024 * 1024 });
|
|
30
|
+
|
|
31
|
+
// Issues: comments >= 1, optionally updated since; comments fetched per issue (paginated) with small parallelism.
|
|
32
|
+
const search = ["comments:>=1", since ? `updated:>=${since}` : ""].filter(Boolean).join(" ");
|
|
33
|
+
const list = JSON.parse(gh(["issue", "list", "-R", repo, "--state", state, "--limit", String(limit), "--search", search, "--json", "number,title"]));
|
|
34
|
+
const issues = [];
|
|
35
|
+
const queue = [...list];
|
|
36
|
+
async function worker() {
|
|
37
|
+
for (let it = queue.shift(); it; it = queue.shift()) {
|
|
38
|
+
try {
|
|
39
|
+
const raw = gh(["api", `repos/${repo}/issues/${it.number}/comments?per_page=100`, "--paginate", "--jq", ".[] | {body, createdAt: .created_at, author: .user.login}"]);
|
|
40
|
+
const comments = raw.split("\n").filter(Boolean).map((l) => JSON.parse(l));
|
|
41
|
+
issues.push({ number: it.number, title: it.title, comments });
|
|
42
|
+
} catch (e) { process.stderr.write(`#${it.number}: ${String(e?.message ?? e).split("\n")[0]}\n`); }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
await Promise.all(Array.from({ length: 4 }, worker));
|
|
46
|
+
const ic = censusIssues(issues.sort((a, b) => a.number - b.number));
|
|
47
|
+
|
|
48
|
+
// Batch logs of this repo (local caches of the register; absent on a fresh host).
|
|
49
|
+
let bc = null;
|
|
50
|
+
if (!has("--no-batches")) {
|
|
51
|
+
const dir = opt("--batches", join(homedir(), ".forge", "batches"));
|
|
52
|
+
const rows = [];
|
|
53
|
+
if (existsSync(dir)) for (const b of readdirSync(dir)) {
|
|
54
|
+
try {
|
|
55
|
+
const plan = JSON.parse(readFileSync(join(dir, b, "plan.json"), "utf8"));
|
|
56
|
+
if (plan?.repo !== repo) continue;
|
|
57
|
+
for (const l of readFileSync(join(dir, b, "log.jsonl"), "utf8").split("\n")) {
|
|
58
|
+
if (!l) continue;
|
|
59
|
+
try { const r = JSON.parse(l); if (!since || String(r.at ?? "") >= since) rows.push(r); } catch { /* partial line */ }
|
|
60
|
+
}
|
|
61
|
+
} catch { /* not a batch dir */ }
|
|
62
|
+
}
|
|
63
|
+
bc = rows.length ? censusBatchRows(rows) : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (has("--json")) console.log(JSON.stringify({ repo, since, issues: ic, batches: bc }, null, 2));
|
|
67
|
+
else process.stdout.write(renderCensus({ repo, since, issues: ic, batches: bc }));
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
# [--intensity-tier T] [--table-cell-key K] [--trust-shadow-mode B] [--other-blocking true|false] [--out-dir D] [--dry-run]
|
|
54
54
|
# (--other-blocking: the reviewer's criterion 1/2/3/5 result; resolved and persisted to OUT_DIR/other-blocking.txt, which merge-gate ORs in)
|
|
55
55
|
# calibrate: [--intensity-tier T] [--table-cell-key K] [--trust-shadow-mode B] [--trust-needs-human B] [--dry-run]; the issue is context contract.issue or --issue N
|
|
56
|
-
# merge-gate: [--manual-pr [--owner-requested]] (hand-built PR: skips ONLY the phase-trail preflight, recorded as FORGE:PHASE_TRAIL_SKIPPED;
|
|
56
|
+
# merge-gate: [--manual-pr [--owner-requested]] (hand-built PR: skips ONLY the phase-trail preflight, recorded as FORGE:PHASE_TRAIL_SKIPPED; a pipeline issue is refused unless --owner-requested, see manual_pr_eligibility)
|
|
57
57
|
# --verdict "APPROVED|CHANGES REQUESTED" --has-purpose-regression B --calibration-needs-human B --trust-needs-human B
|
|
58
58
|
# --base-conflict B --other-blocking B [--calibration-note-file F | --calibration-note T] [--table-cell-key K] [--base B] [--issue N]
|
|
59
59
|
# (every B is true|false; an empty or other value aborts the merge: the guard state must be bound)
|
|
@@ -1307,13 +1307,13 @@ is_pipeline_issue() {
|
|
|
1307
1307
|
--jq '([.labels[].name | startswith("workflow:")] + [.body | contains("<!-- FORGE:STATE")] + [.comments[].body | contains("FORGE:STARTED") or contains("<!-- FORGE:STATE")]) | any' 2>/dev/null) || return 0
|
|
1308
1308
|
[ "$v" != "false" ]
|
|
1309
1309
|
}
|
|
1310
|
-
# manual_pr_eligibility: --manual-pr never applies to a pipeline lane. An explicit --issue that is a pipeline
|
|
1311
|
-
# a closing reference to one
|
|
1310
|
+
# manual_pr_eligibility: --manual-pr never applies to a pipeline lane unless the owner asked for it. An explicit --issue that is a pipeline
|
|
1311
|
+
# issue and a closing reference to one are both refused unless the caller passed --owner-requested (#5913); every other gate still runs. Any unreadable lookup refuses.
|
|
1312
1312
|
manual_pr_eligibility() {
|
|
1313
1313
|
local refs n
|
|
1314
|
-
if [ -n "${MERGE_ISSUE:-}" ] && is_pipeline_issue "$MERGE_ISSUE"; then
|
|
1314
|
+
if [ -n "${MERGE_ISSUE:-}" ] && [ "$OWNER_REQUESTED" != "true" ] && is_pipeline_issue "$MERGE_ISSUE"; then
|
|
1315
1315
|
echo "MANUAL PR: #${MERGE_ISSUE} is a pipeline issue — --manual-pr never applies to a /work-on or /orchestrate lane" >&2
|
|
1316
|
-
blocked "manual-pr refused: #${MERGE_ISSUE} is a pipeline issue"
|
|
1316
|
+
blocked "manual-pr refused: #${MERGE_ISSUE} is a pipeline issue (pass --owner-requested only when the owner explicitly asked for this merge)"
|
|
1317
1317
|
fi
|
|
1318
1318
|
refs=$(gh pr view "$PR_NUMBER" -R "$REPO" --json closingIssuesReferences --jq '.closingIssuesReferences[].number' 2>/dev/null) || blocked "manual-pr refused: closing references unreadable"
|
|
1319
1319
|
for n in $refs; do
|
|
@@ -883,7 +883,14 @@ rc_is "manual: CHANGES REQUESTED blocks" "$RC" 3; not_merged "manual: CHANGES RE
|
|
|
883
883
|
gate_reset; mkctx 1 FULL "" ""; echo true > "$FIX/pipeline-42"; mgm "$GATE" --issue 42
|
|
884
884
|
rc_is "manual: pipeline --issue refused" "$RC" 3; has "manual: pipeline --issue" "manual-pr refused"; not_merged "manual: pipeline --issue"
|
|
885
885
|
gate_reset; mkctx 1 FULL "" ""; echo true > "$FIX/pipeline-42"; mgm "$GATE" --issue 42 --owner-requested
|
|
886
|
-
rc_is "manual: owner
|
|
886
|
+
rc_is "manual: owner-requested explicit --issue on a pipeline issue runs the remaining gates" "$RC" 0; merged "manual: owner vs pipeline issue"
|
|
887
|
+
[ ! -f "$FIX/trail-args" ] && ok || bad "manual: owner pipeline issue ran the verifier"
|
|
888
|
+
gate_reset; mkctx 1 FULL "" ""; echo true > "$FIX/pipeline-42"; echo 1 > "$FIX/ci-rc"; printf 'CI_GATE: FAIL\n' > "$FIX/ci-out"; mgm "$GATE" --issue 42 --owner-requested
|
|
889
|
+
rc_is "manual: owner-requested pipeline issue still blocked by red CI" "$RC" 3; has "manual: owner pipeline CI red" "ci gate not green"; not_merged "manual: owner pipeline CI red"
|
|
890
|
+
# lean-lane issue (#5913): merge-gate on a lean-lane issue with a valid contract and an APPROVED review passes the phase-trail preflight
|
|
891
|
+
gate_reset; mkctx 1 FULL "" ""; printf 'PHASE_TRAIL: PASS\nBAND: LEAN\nNOTE: lean-lane trail\n' > "$FIX/trail-out"; mg "$GATE" --issue 42
|
|
892
|
+
rc_is "merge-gate lean issue passes phase-trail preflight" "$RC" 0; has "lean issue" "MERGE_OUTCOME=merged"; merged "lean issue"
|
|
893
|
+
[ -f "$FIX/trail-args" ] && ok || bad "lean issue: the phase-trail verifier did not run"
|
|
887
894
|
gate_reset; mkctx 1 FULL "" ""; echo 55 > "$FIX/closing"; echo true > "$FIX/pipeline-55"; mgm "$GATE"
|
|
888
895
|
rc_is "manual: closing a pipeline issue refused" "$RC" 3; has "manual: closing ref" "manual-pr refused"; not_merged "manual: closing ref"
|
|
889
896
|
gate_reset; mkctx 1 FULL "" ""; echo 55 > "$FIX/closing"; echo true > "$FIX/pipeline-55"; mgm "$GATE" --owner-requested
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
# STANDARD/COMPLEX (or unknown band)
|
|
35
35
|
# INVESTIGATOR, CONTRACT, FAST_PATH, CONTEXT, ARCHITECT, QUALITY_GATE*
|
|
36
36
|
# (* waived with --docs-only)
|
|
37
|
+
# LEAN LANE CONTRACT + the lean run record (trusted FORGE:STATE comment, run core_*); nothing else (#5913)
|
|
37
38
|
# A missing FAST_PATH is itself a failure; the remaining checks then use the
|
|
38
39
|
# conservative STANDARD requirement set.
|
|
39
40
|
#
|
|
@@ -262,6 +263,16 @@ if has '<!-- FORGE:FAST_PATH -->'; then
|
|
|
262
263
|
| sed -n 's/.*\*\*COMPLEXITY_BAND\*\*: *\([A-Za-z_]*\).*/\1/p' | tr '[:lower:]' '[:upper:]')
|
|
263
264
|
fi
|
|
264
265
|
|
|
266
|
+
# Lean-lane trail (#5913): a lean lane (forgedock run-issue) posts no INVESTIGATOR/FAST_PATH/CONTEXT/ARCHITECT/QUALITY_GATE. Its
|
|
267
|
+
# trail is a trusted FORGE:CONTRACT comment plus the trusted lean run record (a FORGE:STATE comment whose run is `core_*`; the
|
|
268
|
+
# classic engine's STARTED/STATUS markers are shared and never select this mode). Both come from the trusted-author filter above, never the issue body, so an untrusted commenter cannot select this mode.
|
|
269
|
+
if has '<!-- FORGE:CONTRACT -->' && printf '%s\n' "$COMMENTS" | grep -E '^<!-- FORGE:STATE' | grep -E '"run" *: *"core_[A-Za-z0-9_.-]+"' >/dev/null; then
|
|
270
|
+
echo "PHASE_TRAIL: PASS"
|
|
271
|
+
echo "BAND: LEAN"
|
|
272
|
+
echo "NOTE: lean-lane trail (trusted FORGE:CONTRACT + lean run record); classic work-on phases not required"
|
|
273
|
+
exit 0
|
|
274
|
+
fi
|
|
275
|
+
|
|
265
276
|
MISSING=()
|
|
266
277
|
add_missing() { MISSING+=("$1 -> $2"); }
|
|
267
278
|
|
|
@@ -59,6 +59,8 @@ mk() {
|
|
|
59
59
|
QUOTED) items+=('{"body":"see `<!-- FORGE:CONTRACT -->` `<!-- FORGE:CONTEXT -->` `<!-- FORGE:ARCHITECT -->` `<!-- FORGE:QUALITY_GATE -->` **Result**: PASS"}') ;;
|
|
60
60
|
INV_INVALID) items+=('{"body":"<!-- FORGE:INVESTIGATOR -->\nInvalid\n<!-- INVESTIGATION:INVALID -->"}') ;;
|
|
61
61
|
SR) items+=('{"body":"<!-- FORGE:SELFREVIEW-AGENT:security -->\nTree: abc\n<!-- REVIEW-FINDINGS-START -->\n<!-- REVIEW-FINDINGS-END -->"}' '{"body":"<!-- FORGE:SELFREVIEW -->\n## Self-review\nTree: abc"}') ;;
|
|
62
|
+
LEAN_STATUS) items+=('{"body":"<!-- FORGE:STATE\n{\"v\":1,\"run\":\"core_1\",\"issue\":1}\n-->"}') ;;
|
|
63
|
+
CLASSIC_STATUS) items+=('{"body":"<!-- FORGE:STATUS -->\n<!-- FORGE:STARTED -->\nStarted work on #1"}') ;;
|
|
62
64
|
PROSE) items+=('{"body":"I ran the architect and context inline; FORGE:CONTEXT FORGE:ARCHITECT FORGE:QUALITY_GATE done"}') ;;
|
|
63
65
|
esac
|
|
64
66
|
done
|
|
@@ -93,6 +95,13 @@ expect_fail "partial investigation (no COMPLETE) fails" "$(mk b INV_PARTIAL CONT
|
|
|
93
95
|
expect_fail "missing CONTRACT" "$(mk c INV FP_COMPLEX CONTEXT ARCH QG_PASS)" CONTRACT
|
|
94
96
|
expect_fail "missing CONTEXT on STANDARD" "$(mk d INV CONTRACT FP_STANDARD ARCH QG_PASS)" CONTEXT
|
|
95
97
|
expect_fail "missing ARCHITECT on STANDARD" "$(mk e INV CONTRACT FP_STANDARD CONTEXT QG_PASS)" ARCHITECT
|
|
98
|
+
# lean-lane trail (#5913): trusted CONTRACT + lean run record passes with no classic markers; a lone half or an untrusted author does not
|
|
99
|
+
expect_pass "lean lane: trusted CONTRACT + lean run record passes the trail" "$(mk lean1 CONTRACT LEAN_STATUS)"
|
|
100
|
+
expect_fail "lean lane: CONTRACT without the lean run record is still the classic trail" "$(mk lean2 CONTRACT)" INVESTIGATOR
|
|
101
|
+
expect_fail "lean lane: CONTRACT + classic STATUS/STARTED (no core_ run) does not pass" "$(mk lean5 CONTRACT CLASSIC_STATUS)" INVESTIGATOR
|
|
102
|
+
expect_fail "lean lane: run record without CONTRACT does not pass" "$(mk lean3 LEAN_STATUS)" INVESTIGATOR
|
|
103
|
+
jq -c 'map(.author_association="NONE" | .user.type="User")' "$(mk lean4 CONTRACT LEAN_STATUS)" > "$TMP_FX/lean4u.json"
|
|
104
|
+
expect_fail "lean lane: markers from an untrusted author cannot select lean mode" "$TMP_FX/lean4u.json" INVESTIGATOR
|
|
96
105
|
expect_fail "missing FAST_PATH" "$(mk f INV CONTRACT CONTEXT ARCH QG_PASS)" FAST_PATH
|
|
97
106
|
expect_fail "FAST_PATH without band value fails" "$(mk g INV CONTRACT FP_NOBAND CONTEXT ARCH QG_PASS)" FAST_PATH
|
|
98
107
|
expect_fail "missing QUALITY_GATE" "$(mk h INV CONTRACT FP_COMPLEX CONTEXT ARCH)" QUALITY_GATE
|