forgedock 1.18.0 → 1.20.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.
Files changed (135) hide show
  1. package/README.md +2 -0
  2. package/bin/engine/outcome-codes.mjs +13 -0
  3. package/bin/engine/phases.mjs +54 -4
  4. package/bin/engine/runlog.mjs +10 -2
  5. package/bin/engine/telemetry-seam.mjs +3 -0
  6. package/bin/engine/telemetry.test.mjs +3 -2
  7. package/bin/engine-cli.mjs +32 -2
  8. package/bin/engine.mjs +187 -10
  9. package/bin/runner.mjs +89 -13
  10. package/bin/stats/aggregate.mjs +7 -3
  11. package/bin/stats/cache.mjs +7 -3
  12. package/bin/stats/github-source.mjs +136 -28
  13. package/bin/stats/index.mjs +46 -9
  14. package/bin/stats/render.mjs +1 -1
  15. package/bin/stats/stats.test.mjs +201 -40
  16. package/commands/orchestrate/phase-4-execution.md +1 -1
  17. package/commands/review-pr-agents/protocols.md +19 -0
  18. package/commands/review-pr-staging.md +4 -4
  19. package/commands/review-pr.md +31 -20
  20. package/commands/work-on/build/architect.md +54 -1
  21. package/commands/work-on/build/implement.md +28 -1
  22. package/commands/work-on/build/validate.md +321 -29
  23. package/commands/work-on/build.md +184 -17
  24. package/commands/work-on/close.md +9 -4
  25. package/commands/work-on/investigate.md +7 -0
  26. package/commands/work-on/remediate.md +43 -17
  27. package/commands/work-on/review.md +43 -22
  28. package/commands/work-on.md +4 -4
  29. package/docs/CONFIG.md +93 -2
  30. package/docs/OUTCOME-CODES.md +5 -1
  31. package/docs/RELEASE-NOTES.md +15 -0
  32. package/docs/STATS.md +11 -4
  33. package/docs/TELEMETRY.md +5 -2
  34. package/docs/WORK-ON-RUNTIME.md +29 -3
  35. package/package.json +2 -2
  36. package/packages/protocol/src/types.js +1 -1
  37. package/scripts/acceptance-red-green.sh +90 -0
  38. package/scripts/acceptance-red-green.test.sh +74 -0
  39. package/scripts/architect-resume-match.test.sh +12 -3
  40. package/scripts/build-knowledge-index.mjs +8 -5
  41. package/scripts/builder-resume-match.test.sh +12 -3
  42. package/scripts/calibration.mjs +5 -2
  43. package/scripts/cap-findings.test.sh +2 -0
  44. package/scripts/check-contract-scope.test.sh +2 -0
  45. package/scripts/check-edge-cases.sh +143 -0
  46. package/scripts/check-edge-cases.test.sh +175 -0
  47. package/scripts/check-spec-markers.sh +4 -0
  48. package/scripts/check-test-tmp-cleanup.sh +56 -0
  49. package/scripts/check-test-tmp-cleanup.test.sh +69 -0
  50. package/scripts/ci-local/adapters/azure-pipelines.mjs +113 -0
  51. package/scripts/ci-local/adapters/bitbucket.mjs +64 -0
  52. package/scripts/ci-local/adapters/buildkite.mjs +58 -0
  53. package/scripts/ci-local/adapters/circleci.mjs +101 -0
  54. package/scripts/ci-local/adapters/common.mjs +115 -0
  55. package/scripts/ci-local/adapters/explicit.mjs +21 -0
  56. package/scripts/ci-local/adapters/github-actions.mjs +349 -0
  57. package/scripts/ci-local/adapters/gitlab-ci.mjs +184 -0
  58. package/scripts/ci-local/adapters/portability.mjs +104 -0
  59. package/scripts/ci-local/adapters/task-runners.mjs +67 -0
  60. package/scripts/ci-local/cli.mjs +50 -0
  61. package/scripts/ci-local/lib.mjs +379 -0
  62. package/scripts/ci-local/plan.mjs +186 -0
  63. package/scripts/ci-local/run.mjs +451 -0
  64. package/scripts/ci-local/scoping.mjs +531 -0
  65. package/scripts/ci-local.sh +98 -0
  66. package/scripts/ci-local.test.sh +1108 -0
  67. package/scripts/classify-finding.sh +33 -7
  68. package/scripts/classify-finding.test.sh +23 -0
  69. package/scripts/classify-test-run.sh +69 -0
  70. package/scripts/classify-test-run.test.sh +90 -0
  71. package/scripts/close-parent-c3.test.sh +2 -0
  72. package/scripts/consumer-sweep.sh +569 -0
  73. package/scripts/consumer-sweep.test.sh +357 -0
  74. package/scripts/detect-append-registries.sh +106 -0
  75. package/scripts/detect-append-registries.test.sh +64 -0
  76. package/scripts/file-deferred-followups.sh +91 -30
  77. package/scripts/file-deferred-followups.test.sh +101 -8
  78. package/scripts/fixtures/ci-local/azure/azure-pipelines.yml +11 -0
  79. package/scripts/fixtures/ci-local/bitbucket/bitbucket-pipelines.yml +12 -0
  80. package/scripts/fixtures/ci-local/buildkite/.buildkite/pipeline.yml +10 -0
  81. package/scripts/fixtures/ci-local/circleci/.circleci/config.yml +29 -0
  82. package/scripts/fixtures/ci-local/gha-basic/.github/workflows/ci.yml +59 -0
  83. package/scripts/fixtures/ci-local/gha-basic/.github/workflows/docs.yml +10 -0
  84. package/scripts/fixtures/ci-local/gha-basic/.github/workflows/nightly.yml +10 -0
  85. package/scripts/fixtures/ci-local/gha-basic/docs/index.md +1 -0
  86. package/scripts/fixtures/ci-local/gha-basic/src/greet.sh +2 -0
  87. package/scripts/fixtures/ci-local/gha-basic/tests/greet.test.sh +3 -0
  88. package/scripts/fixtures/ci-local/gha-dorny/.github/workflows/ci.yml +51 -0
  89. package/scripts/fixtures/ci-local/gha-dorny/backend/app.py +1 -0
  90. package/scripts/fixtures/ci-local/gha-dorny/docs/a.md +1 -0
  91. package/scripts/fixtures/ci-local/gha-dorny/frontend/app.js +1 -0
  92. package/scripts/fixtures/ci-local/gha-run/.github/workflows/ci.yml +39 -0
  93. package/scripts/fixtures/ci-local/gha-run/src/x.txt +1 -0
  94. package/scripts/fixtures/ci-local/gitlab/.gitlab-ci.yml +43 -0
  95. package/scripts/fixtures/ci-local/gitlab/docs/d.md +1 -0
  96. package/scripts/fixtures/ci-local/gitlab/src/a.txt +1 -0
  97. package/scripts/fixtures/ci-local/monorepo/.github/workflows/ci.yml +13 -0
  98. package/scripts/fixtures/ci-local/monorepo/package-lock.json +1 -0
  99. package/scripts/fixtures/ci-local/monorepo/packages/a/src/a.sh +2 -0
  100. package/scripts/fixtures/ci-local/monorepo/packages/a/tests/a.test.sh +3 -0
  101. package/scripts/fixtures/ci-local/monorepo/packages/b/src/b.sh +2 -0
  102. package/scripts/fixtures/ci-local/monorepo/packages/b/tests/b.test.sh +3 -0
  103. package/scripts/fixtures/ci-local/no-ci/Makefile +6 -0
  104. package/scripts/fixtures/ci-local/no-ci/package.json +1 -0
  105. package/scripts/fixtures/ci-local/no-ci/src/a.js +1 -0
  106. package/scripts/fixtures/ci-local/no-ci/src/b.js +1 -0
  107. package/scripts/fixtures/ci-local/no-ci/tests/a.test.js +2 -0
  108. package/scripts/fixtures/ci-local/no-ci/tests/b.test.js +2 -0
  109. package/scripts/forge-root.test.sh +1 -1
  110. package/scripts/lib/telemetry.sh +3 -0
  111. package/scripts/remediate-approved-head.test.sh +2 -0
  112. package/scripts/remediate-basesync.test.sh +1 -1
  113. package/scripts/review-acceptance-gate.sh +2 -2
  114. package/scripts/review-acceptance-gate.test.sh +20 -0
  115. package/scripts/review-delta.sh +8 -1
  116. package/scripts/review-delta.test.sh +19 -0
  117. package/scripts/review-finalize.sh +294 -53
  118. package/scripts/review-finalize.test.sh +347 -9
  119. package/scripts/review-pr-delta-wiring.test.sh +13 -0
  120. package/scripts/review-prepare.sh +5 -3
  121. package/scripts/review-prepare.test.sh +18 -2
  122. package/scripts/review-roster.sh +18 -5
  123. package/scripts/review-roster.test.sh +57 -1
  124. package/scripts/run-shell-tests.sh +5 -0
  125. package/scripts/selfreview-plan.sh +86 -0
  126. package/scripts/selfreview-plan.test.sh +90 -0
  127. package/scripts/spawn-depth-check.sh +5 -4
  128. package/scripts/spawn-depth-check.test.sh +3 -0
  129. package/scripts/telemetry.test.sh +10 -0
  130. package/scripts/transition-label.sh +26 -0
  131. package/scripts/trusted-comments.test.sh +2 -1
  132. package/scripts/verify-phase-trail.test.sh +14 -0
  133. package/scripts/wait-ci-green.sh +61 -9
  134. package/scripts/wait-ci-green.test.sh +41 -3
  135. package/scripts/with-run-tmpdir.sh +20 -0
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env bash
2
+ # SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
3
+ # SPDX-License-Identifier: AGPL-3.0-or-later
4
+ #
5
+ # ci-local.sh - run the repo's own pull-request checks locally, before review, without spending CI minutes.
6
+ #
7
+ # Usage:
8
+ # ci-local.sh plan --repo <worktree> --base <ref> [--base-branch B] [--head-branch B] [--files "a b" | --files-from FILE]
9
+ # [--out FILE] [--json] [--no-cache]
10
+ # ci-local.sh run --repo <worktree> --base <ref> [same options] [--budget-minutes N] [--max-parallel N]
11
+ # [--iteration N] [--result-file FILE]
12
+ #
13
+ # plan derives the check set from the repo's CI definitions (GitHub Actions, GitLab CI, CircleCI, Azure Pipelines,
14
+ # Bitbucket Pipelines, Buildkite; task runners when no CI gates the change; forge.yaml ci_local.extra_commands),
15
+ # reading definitions from the trusted base ref plus the PR's own edits, and scopes every check to what the
16
+ # change can affect (per-file lint on changed files, test impact selection, fail-safe widening).
17
+ # run executes the plan in the worktree (parallel jobs, machine-wide slot semaphore, timeouts, overall budget,
18
+ # docker-backed services, result cache) and emits `ci_local` telemetry.
19
+ #
20
+ # Output (stdout): CI_LOCAL_JOB / CI_LOCAL_DEFERRED / CI_LOCAL_CHECK / CI_LOCAL_FAIL lines, then exactly one
21
+ # CI_LOCAL_RESULT: PASS|FAIL|DEGRADED line.
22
+ # Exit: 0 every runnable job passed (deferred-to-ci jobs are listed), 1 a runnable job failed,
23
+ # 2 degraded (job timeout, exhausted or capped budget, gate could not run) or usage error; never a pass.
24
+ #
25
+ # This script only reads CI definitions and runs the commands they name on this machine. It never contacts GitHub
26
+ # and never starts a remote workflow. Requires: bash, node, git, and mikefarah yq v4 for YAML CI definitions.
27
+ # bash 3.2 portable.
28
+
29
+ set -u
30
+
31
+ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
32
+ CLI="$SCRIPT_DIR/ci-local/cli.mjs"
33
+
34
+ degraded() { echo "CI_LOCAL_RESULT: DEGRADED reason=$1"; exit 2; }
35
+
36
+ SUB="${1:-}"
37
+ case "$SUB" in
38
+ plan|run) shift ;;
39
+ -h|--help|help) sed -n '2,27p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
40
+ *) echo "usage: ci-local.sh plan|run --repo <worktree> --base <ref> [options]" >&2; exit 2 ;;
41
+ esac
42
+
43
+ command -v node >/dev/null 2>&1 || degraded "node not found"
44
+ [ -f "$CLI" ] || degraded "ci-local/cli.mjs not found next to ci-local.sh"
45
+
46
+ # Telemetry reuses the shared emitter (never fails the caller; FORGE_TELEMETRY=off disables it).
47
+ type forge_emit >/dev/null 2>&1 || { [ -f "$SCRIPT_DIR/lib/telemetry.sh" ] && . "$SCRIPT_DIR/lib/telemetry.sh"; }
48
+ type forge_emit >/dev/null 2>&1 || forge_emit() { :; }
49
+
50
+ if [ "$SUB" = "plan" ]; then
51
+ node "$CLI" plan "$@"
52
+ exit $?
53
+ fi
54
+
55
+ ITER=0
56
+ prev=""
57
+ for arg in "$@"; do
58
+ [ "$prev" = "--iteration" ] && ITER="$arg"
59
+ prev="$arg"
60
+ done
61
+ case "$ITER" in ''|*[!0-9]*) ITER=0 ;; esac
62
+
63
+ OUT=$(mktemp "${TMPDIR:-/tmp}/ci-local-out.XXXXXX") || degraded "could not create a temp file"
64
+ trap 'rm -f "$OUT"' EXIT
65
+ node "$CLI" run "$@" | tee "$OUT"
66
+ RC=${PIPESTATUS[0]}
67
+
68
+ RES=$(grep '^CI_LOCAL_RESULT:' "$OUT" | tail -n 1)
69
+ if [ -z "$RES" ]; then
70
+ echo "CI_LOCAL_RESULT: DEGRADED reason=runner produced no result line (exit $RC)"
71
+ RC=2
72
+ RES="CI_LOCAL_RESULT: DEGRADED"
73
+ fi
74
+
75
+ field() { printf '%s\n' "$RES" | tr ' ' '\n' | sed -n "s/^$1=//p" | head -n 1; }
76
+ STATE=$(printf '%s\n' "$RES" | awk '{print $2}')
77
+ JR=$(field jobs_run); JD=$(field jobs_deferred); JF=$(field jobs_failed); DUR=$(field duration_ms)
78
+ forge_emit ci_local result="${STATE:-DEGRADED}" jobs_run="${JR:-0}" jobs_deferred="${JD:-0}" jobs_failed="${JF:-0}" \
79
+ duration_ms="${DUR:-0}" wait_ms="$(field wait_ms)" fix_iterations="$ITER" checks="$(field checks)" cache_hits="$(field cache_hits)" \
80
+ narrowed="$(field narrowed)" widened="$(field widened)" selected="$(field selected)" total="$(field total)" >/dev/null 2>&1 || true
81
+
82
+ # One event per scoped/widened/executed check, capped so a large plan never floods the telemetry comment.
83
+ EMITTED=0
84
+ while IFS= read -r line; do
85
+ [ "$EMITTED" -ge 20 ] && break
86
+ job=$(printf '%s\n' "$line" | sed -n 's/.* job=\([^ ]*\).*/\1/p')
87
+ sel=$(printf '%s\n' "$line" | sed -n 's/.* selector=\([^ ]*\).*/\1/p')
88
+ sc=$(printf '%s\n' "$line" | sed -n 's/.* selected=\([^ ]*\).*/\1/p')
89
+ tt=$(printf '%s\n' "$line" | sed -n 's/.* total=\([^ ]*\).*/\1/p')
90
+ ch=$(printf '%s\n' "$line" | sed -n 's/.* cache=\([^ ]*\).*/\1/p')
91
+ dm=$(printf '%s\n' "$line" | sed -n 's/.* duration_ms=\([^ ]*\).*/\1/p')
92
+ wd=$(printf '%s\n' "$line" | sed -n 's/.* widen=\([^ ]*\).*/\1/p')
93
+ wm=$(printf '%s\n' "$line" | sed -n 's/.* wait_ms=\([^ ]*\).*/\1/p')
94
+ forge_emit ci_local_check job="$job" selector="$sel" selected="${sc:-0}" total="${tt:-0}" cache="$ch" duration_ms="${dm:-0}" wait_ms="${wm:-0}" widen="$wd" >/dev/null 2>&1 || true
95
+ EMITTED=$((EMITTED + 1))
96
+ done < <(grep '^CI_LOCAL_CHECK:' "$OUT")
97
+
98
+ exit "$RC"