forgedock 1.52.0 → 1.53.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 (93) hide show
  1. package/bin/engine/outcome-codes.mjs +3 -0
  2. package/bin/engine/telemetry-seam.mjs +4 -2
  3. package/bin/engine-cli.mjs +53 -16
  4. package/bin/experiment.mjs +58 -6
  5. package/bin/forge-utils.mjs +6 -2
  6. package/bin/forgedock.mjs +15 -1
  7. package/bin/lean/account-watch.mjs +28 -0
  8. package/bin/lean/account-watch.test.mjs +30 -0
  9. package/bin/lean/activation.mjs +20 -0
  10. package/bin/lean/activation.test.mjs +14 -1
  11. package/bin/lean/basered.mjs +115 -0
  12. package/bin/lean/basered.test.mjs +66 -0
  13. package/bin/lean/batch-health.mjs +40 -6
  14. package/bin/lean/batch-health.test.mjs +34 -1
  15. package/bin/lean/batch.mjs +41 -2
  16. package/bin/lean/batch.test.mjs +104 -2
  17. package/bin/lean/checkpoint-reconcile.mjs +43 -0
  18. package/bin/lean/checkpoint-reconcile.test.mjs +95 -0
  19. package/bin/lean/conformance.e2e.test.mjs +1 -1
  20. package/bin/lean/conformance.mjs +195 -22
  21. package/bin/lean/conformance.test.mjs +152 -5
  22. package/bin/lean/effects.mjs +8 -4
  23. package/bin/lean/execution.mjs +19 -3
  24. package/bin/lean/execution.test.mjs +39 -0
  25. package/bin/lean/findinglabel.mjs +16 -0
  26. package/bin/lean/findinglabel.test.mjs +39 -0
  27. package/bin/lean/issuewatch-release.mjs +6 -2
  28. package/bin/lean/issuewatch-release.test.mjs +16 -0
  29. package/bin/lean/issuewatch.mjs +11 -1
  30. package/bin/lean/lanelock.mjs +14 -0
  31. package/bin/lean/lean.mjs +165 -34
  32. package/bin/lean/lean.test.mjs +289 -9
  33. package/bin/lean/light.mjs +48 -7
  34. package/bin/lean/light.test.mjs +37 -3
  35. package/bin/lean/limits.test.mjs +142 -9
  36. package/bin/lean/orchestrate-cancel.test.mjs +143 -0
  37. package/bin/lean/orchestrate.mjs +96 -26
  38. package/bin/lean/postdeploy-check.test.mjs +39 -0
  39. package/bin/lean/prompts.mjs +8 -7
  40. package/bin/lean/quota.mjs +39 -0
  41. package/bin/lean/recovery.test.mjs +10 -0
  42. package/bin/lean/relaxation.mjs +73 -0
  43. package/bin/lean/relaxation.test.mjs +54 -0
  44. package/bin/lean/release-postmerge.mjs +119 -0
  45. package/bin/lean/release-rehearsal.mjs +63 -0
  46. package/bin/lean/release-rehearsal.test.mjs +93 -0
  47. package/bin/lean/release-review.e2e.test.mjs +77 -0
  48. package/bin/lean/release-review.mjs +198 -0
  49. package/bin/lean/release-review.test.mjs +180 -0
  50. package/bin/lean/release.mjs +228 -0
  51. package/bin/lean/release.test.mjs +292 -0
  52. package/bin/lean/rotator.mjs +150 -31
  53. package/bin/lean/rotator.test.mjs +105 -2
  54. package/bin/lean/sandbox-remote.mjs +9 -2
  55. package/bin/lean/schedd.mjs +49 -4
  56. package/bin/lean/schedd.test.mjs +87 -6
  57. package/bin/lean/verifier.mjs +3 -2
  58. package/bin/lean/verify.mjs +2 -1
  59. package/bin/lean/verify.test.mjs +6 -0
  60. package/bin/pool/agent.mjs +18 -4
  61. package/bin/pool/router.mjs +66 -24
  62. package/bin/review-staging.mjs +23 -0
  63. package/bin/stats/conformance-outcomes.mjs +208 -0
  64. package/bin/stats/conformance-outcomes.test.mjs +188 -0
  65. package/bin/stats/depth.mjs +218 -0
  66. package/bin/stats/depth.test.mjs +133 -0
  67. package/bin/stats/experiment.mjs +7 -5
  68. package/bin/stats/github-source.mjs +2 -2
  69. package/bin/stats/index.mjs +64 -2
  70. package/bin/stats/local-source.mjs +11 -0
  71. package/bin/stats/query.mjs +69 -0
  72. package/bin/stats/selffiled.mjs +52 -0
  73. package/bin/stats/selffiled.test.mjs +71 -0
  74. package/commands/orchestrate.md +1 -1
  75. package/commands/review-pr-agents/security.md +4 -0
  76. package/commands/review-pr-staging.md +2 -0
  77. package/commands/work-on/build.md +4 -6
  78. package/docs/CONFIG.md +65 -8
  79. package/docs/ISSUE-WATCH.md +2 -0
  80. package/docs/OUTCOME-CODES.md +3 -0
  81. package/docs/STATS.md +44 -0
  82. package/docs/TELEMETRY.md +1 -1
  83. package/package.json +1 -1
  84. package/pool/README.md +1 -1
  85. package/pool/image/cs-cred +14 -1
  86. package/scripts/backfill-finding-labels.mjs +50 -0
  87. package/scripts/backfill-finding-labels.test.mjs +36 -0
  88. package/scripts/doctor-pipeline-state.sh +21 -6
  89. package/scripts/file-deferred-followups.sh +59 -251
  90. package/scripts/file-deferred-followups.test.sh +85 -206
  91. package/scripts/followup-route.mjs +12 -0
  92. package/scripts/owner-route-parity.test.sh +17 -1
  93. package/scripts/review-pr-side-effects.test.sh +40 -0
@@ -376,7 +376,7 @@ Every item in the contract's `### Out of Scope` section must carry exactly one d
376
376
  - **Known-flaw rule**: a contract that keeps a known-flawed design (a design the investigation or architect plan identified as flawed, a fail-open caller, an unsound threshold) must state the flaw and list it as a `deferred → #N` item with a linked follow-up. It may not hide behind `accepted-risk` or free text.
377
377
  - Free-text exclusions without a disposition are invalid. `->` is accepted for `→`.
378
378
 
379
- **Fold, then batch** <!-- Added: forge#3843 -->: before filing anything, fold small siblings into scope. A candidate deferred item that is the same mechanical change at a sibling path and fits the remaining scope budget (a small fraction of the plan's own estimate: at most 20% of the current `ESTIMATED_DIFF_LINES`, or 200 lines when no estimate exists) goes into the contract's Deliverables, not Out of Scope; count it as `folded`. Defer only genuinely separate work (different module, design or owner). All remaining deferred items of this build go into ONE follow-up issue per class (engineering | post-deploy | external | ops, each labelled `followup:<class>` and carrying the parent's milestone, #4664) with a checklist; `scripts/file-deferred-followups.sh` appends to an existing trusted follow-up for the same parent (exact path match; a closed one is reopened only if completed, not resolved by a person, and given new items) or creates one, then records a `<!-- FORGE:DEFERRED_ISSUE: #M -->` claim marker on the parent.
379
+ **Fold, then batch** <!-- Added: forge#3843 -->: before filing anything, fold small siblings into scope. A candidate deferred item that is the same mechanical change at a sibling path and fits the remaining scope budget (a small fraction of the plan's own estimate: at most 20% of the current `ESTIMATED_DIFF_LINES`, or 200 lines when no estimate exists) goes into the contract's Deliverables, not Out of Scope; count it as `folded`. Defer only genuinely separate work (different module, design or owner). Engineering items are never filed (#5207): fold them into scope, or list them in the PR body under Out of scope. Only `post-deploy:`/`external:`/`ops:`/`host:` items are piped to `scripts/file-deferred-followups.sh`, which appends them to the aggregates (the release rollup, the batch external aggregate, the batch host aggregate), never a per-parent issue; an engineering row exits 2.
380
380
 
381
381
  **File the `deferred` follow-ups** (skip the filing on resume when the contract already exists):
382
382
 
@@ -384,7 +384,7 @@ Every item in the contract's `### Out of Scope` section must carry exactly one d
384
384
  # <Script resolution block from work-on/build.md, verbatim>
385
385
  # DEFERRED_TSV: one line per remaining deferred item: path-or-`-`<TAB>one-line why<TAB>known-flaw (or empty)[<TAB>class<TAB>label]
386
386
  # Column 1 must be a path or `-` (never requirement text or an `R<n>:` prefix: that exits 2, nothing filed); a requirement-level item
387
- # is `-` with its text in the label column. class: engineering|post-deploy|external|ops (default: the why's `post-deploy:`/`external:`/`ops:` prefix, else engineering).
387
+ # is `-` with its text in the label column. class: post-deploy|external|ops|host (default: the why's prefix; none = engineering, rejected).
388
388
  SCRIPT_REF=$(resolve_script 'file-deferred-followups')
389
389
  case "$SCRIPT_REF" in
390
390
  prose:*) echo "DEFERRED_SCRIPT=PROSE" ;; # file ONE issue by hand: marker + checklist of every path (see below)
@@ -695,7 +695,6 @@ if [ -n "$JUSTIFICATION" ]; then echo "OVERRIDE=VALID"; else echo "OVERRIDE=NONE
695
695
  # <Script resolution block from above goes here, verbatim>
696
696
  MB=$(git -C "{WORKTREE_PATH}" merge-base HEAD "origin/{PR_BASE}") || { echo "TRIM=FAILED"; exit 0; }
697
697
  PATCH_PATH="$(git -C "{WORKTREE_PATH}" rev-parse --git-common-dir)/forge-trimmed-{NUMBER}.patch"
698
- DEFERRED_TSV=""
699
698
  # OOP_PATHS: the out_of_plan= values, one per line (data, never evaluated)
700
699
  while IFS= read -r _p; do
701
700
  [ -n "$_p" ] || continue
@@ -705,12 +704,11 @@ while IFS= read -r _p; do
705
704
  else
706
705
  git -C "{WORKTREE_PATH}" rm -q -f --cached -- "$_p" && rm -f -- "{WORKTREE_PATH}/$_p" || { echo "TRIM=FAILED"; exit 0; }
707
706
  fi
708
- DEFERRED_TSV="${DEFERRED_TSV}${_p}"$'\t'"out-of-plan hunks trimmed from #{NUMBER}; saved in ${PATCH_PATH}"$'\t'$'\n'
709
707
  done <<< "$OOP_PATHS"
710
- printf '%s' "$DEFERRED_TSV" | bash "$(resolve_script 'file-deferred-followups' | sed 's/^[^:]*://')" --parent {NUMBER} --repo {GH_REPO}; echo "DEFERRED_RC=$?"
708
+ echo "TRIMMED_PATCH=${PATCH_PATH}"
711
709
  ```
712
710
 
713
- `TRIM=FAILED` or a non-zero `DEFERRED_RC` → do not trim further; keep whatever state is staged, fall back to the flag outcome (`SCOPE_FLAGGED`, nothing lost), and say so in the comment. After a successful trim re-run Step 2 once so `FORGE:DIFF_SIZE` records the trimmed numbers, set `trimmed: <N> file(s) -> #<follow-up>` and result `SCOPE_FLAGGED`.
711
+ The trimmed paths and `TRIMMED_PATCH` go into the PR body under Out of scope, never into a follow-up issue (#5207). `TRIM=FAILED` → do not trim further; keep whatever state is staged, fall back to the flag outcome (`SCOPE_FLAGGED`, nothing lost), and say so in the comment. After a successful trim re-run Step 2 once so `FORGE:DIFF_SIZE` records the trimmed numbers, set `trimmed: <N> file(s) -> <patch path>` and result `SCOPE_FLAGGED`.
714
712
 
715
713
  **Step 5 — record.** Set `DIFF_LINES`, `EXCLUDED_LINES`, `WS_LINES`, `REVIEW_WEIGHT`, `MODULES`, `ESTIMATE`, `SCOPE`, `REVIEW_DEPTH` and `RESULT` from the steps above, then post one `<!-- FORGE:DIFF_SIZE -->` comment, idempotently: find the latest trusted comment starting with the marker and edit it, otherwise create it (on resume never stack duplicates; readers use the latest trusted one). `diff_lines` stays the first field close.md and the protocol read:
716
714
 
package/docs/CONFIG.md CHANGED
@@ -721,6 +721,38 @@ selftest:
721
721
 
722
722
  ---
723
723
 
724
+ ## `release` (OPTIONAL)
725
+
726
+ Settings for `forgedock release [--repo owner/repo] [--merge] [--watch] [--resume <id>]` (#5208), which runs the `branches.staging` → `branches.default` release as one resumable job. State is kept in `~/.forge/releases/<id>/` (or `FORGEDOCK_RELEASE_DIR`); `--resume <id>` continues from the last completed step (preflight, release-pr, review, fixes, promotion, post-merge). Preflight refuses while lanes of the repo run or PRs to the staging branch are open, and sets the repo's batches to K=1 until the job ends. Review and fixes are not automated yet: the job stops there and tells you to use the manual path (`commands/review-pr-staging.md`). Post-merge is automated (#5213): it confirms a publish run for the merge commit (dispatching one when none appears), waits for `artifact_check`, then opens and merges the version-sync PR; a bound that runs out stops the job as blocked and `--resume <id>` retries. `--watch` is accepted and has no effect until the review step lands.
727
+
728
+ ```yaml
729
+ release:
730
+ auto_merge: false
731
+ artifact_check: ""
732
+ version_sync: false
733
+ publish_workflow: publish.yml
734
+ rehearsal_command: ""
735
+ rehearsal_timeout: 1200
736
+ rehearsal_blocking: true
737
+ ```
738
+
739
+ The forge.yaml reader handles two levels, so the rehearsal block is written as the flat keys `rehearsal_command`, `rehearsal_timeout` and `rehearsal_blocking`.
740
+
741
+ | Key | Type | Required | Description |
742
+ |-----|------|----------|-------------|
743
+ | `auto_merge` | boolean | No | `true` merges the release PR with `--match-head-commit` once `FORGE:GATE_PASS` is posted and `forge/deploy-gate` is success, as `--merge` does. Default: `false` (the job stops at GATE_PASS and prints the merge command). |
744
+ | `artifact_check` | string | No | Shell command that confirms the published artifact (e.g. `npm view pkg@1.2.3 version`). Post-merge retries it with a bounded exponential backoff (npm propagation delay) and blocks when it keeps failing. Default: none. |
745
+ | `version_sync` | boolean | No | The repo pushes a `chore/sync-version-<VERSION>` branch after a release. Post-merge opens its PR to `branches.staging` if missing and merges it with `--match-head-commit` once its checks are green (no checks, or a red one, blocks the job). Default: `false`. |
746
+ | `publish_workflow` | string | No | Workflow file post-merge looks for (and dispatches when no run appears) for the merge commit. Default: `publish.yml`. |
747
+
748
+ | `rehearsal_command` | string | No | Shell command run on the host (not as Actions minutes) in the repo checkout, on the release-PR head after review and before promotion (#5253). Wire the project's deploy dry-run here: bundle build, env load and the trusted-runtime closure check, e.g. `rehearsal_command: ./scripts/deploy-dry-run.sh` where the script builds the release bundle, loads the production env file in check mode and verifies the trusted-runtime closure, exiting non-zero on the first failure. Unset: no rehearsal, release behavior is unchanged. |
749
+ | `rehearsal_timeout` | integer | No | Seconds before the command is killed (counts as a failure). Default: `1200`. |
750
+ | `rehearsal_blocking` | boolean | No | `true` (default): a failure files one `release-blocker` issue per release head (a re-run at the same head comments on it) with the output tail and the head SHA, and stops the job before promotion; fix it and `--resume <id>`. `false`: the failure is recorded and promotion goes on. |
751
+
752
+ The result (pass or fail, head SHA, blocker issue) is recorded in the release state (`steps.rehearsal`) and in a `FORGE:REHEARSAL` section of the release PR body next to the gate result.
753
+
754
+ **Commands that use this section**: `forgedock release`
755
+
724
756
  ## `issue_watch` (OPTIONAL)
725
757
 
726
758
  Named, scoped, capped watches for `forgedock issue-watch` (see [ISSUE-WATCH.md](ISSUE-WATCH.md)). Write `issue_watch:`, then `watches:`, then one block per watch name. The release keys need `mode: release` and at least a `threshold` or `immediate`.
@@ -775,12 +807,12 @@ Deferred follow-ups (`scripts/file-deferred-followups.sh`) are routed by kind (#
775
807
  | Kind | Where it goes |
776
808
  |---|---|
777
809
  | Post-promotion, production-verify, rollout-promote (`post-deploy`, `owner:orchestrator`, `owner:promote:<flag>`, or an owner why such as "after release", "rollout", "purge") | A checklist line in the repo's ONE open post-deploy rollup (`FORGE:POSTDEPLOY_ROLLUP`, else the lowest open issue labelled `followups.rollup_issue_label`). Never a new issue when one is open. |
778
- | Read-only production data or capture (bucket `host`, or an owner why naming obs-psql, a `*-monitor` or a read-only prod query) | Class `host`: added to the parent's engineering follow-up of the same run, else one per-parent follow-up. Labels `followup:host` and `host-task`, never `needs-human`. |
779
- | Truly external (credentials, spend, an account, a third party, a customer) | ONE issue per batch (`FORGE:EXTERNAL_BATCH: <batch id>`) holding every item under a `### #<parent>` heading, labelled `followup:external`, `external-prerequisite` and `needs-human`. |
780
- | Deferred engineering work (bucket `new-issue`) | ONE issue per batch (`FORGE:BACKLOG_BATCH: <batch id>`) holding every item under a `### #<parent>` heading (deduplicated), labelled `followup:engineering` and `followup:backlog`. |
781
- | Engineering | The parent's open follow-up when one exists, else one issue per parent with all its items together. `ops` and `verify-now` also keep one issue per parent. |
810
+ | Read-only production data or capture (bucket `host`, or an owner why naming obs-psql, a `*-monitor` or a read-only prod query) | ONE host aggregate per batch (`FORGE:HOST_BATCH: <batch id>`) holding every item under a `### #<parent>` heading. Labels `followup:host` and `host-task`, never `needs-human` (#5207). |
811
+ | Truly external, and `ops` (credentials, spend, an account, a third party, a customer) | ONE issue per batch (`FORGE:EXTERNAL_BATCH: <batch id>`) holding every item under a `### #<parent>` heading, labelled `followup:external`, `external-prerequisite` and `needs-human`. |
812
+ | `verify-now` | The release rollup, like `post-deploy` (#5207). |
813
+ | Engineering (bucket `new-issue`, class `engineering`, or no class) | Never filed (#5207): the conformance review rejects the deferral and the builder delivers it in the same lane; the script exits 2. No per-parent follow-up issue is filed for any class. |
782
814
 
783
- Each issue carries the label `followup:<class>` and inherits the parent's milestone. A requirement may set an optional `class` in the contract. Otherwise `post-deploy` items are `post-deploy` and the rest `engineering`. A parent milestone that has shipped (closed) is replaced by the next open milestone by due date, else `followups.default_milestone`. The batch report lists `follow-ups appended: #N (<class>: k item(s) from #a,#b)` per issue, not "issues filed".
815
+ Each issue carries the label `followup:<class>` and inherits the parent's milestone. A requirement may set an optional `class` in the contract. Otherwise `post-deploy` items are `post-deploy` and the rest `engineering` (rejected). A parent milestone that has shipped (closed) is replaced by the next open milestone by due date, else `followups.default_milestone`. The batch report lists `follow-ups appended: #N (<class>: k item(s) from #a,#b)` per issue, not "issues filed".
784
816
 
785
817
  ```yaml
786
818
  followups:
@@ -816,6 +848,29 @@ A post-deploy requirement carries a check id (`[check:<id>]` in the follow-up it
816
848
 
817
849
  `pass` is `exit 0` (default) or a `/regex/flags` over the output; `timeout` is seconds. When the gate reports the follow-up ready, the check runs with no model call: pass closes the follow-up with a `FORGE:PROBE` record, fail reopens the parent with the output. An item with no check id, or an id the default branch does not define, gets the `awaiting-measurement` label and never a lane. A contract's check id must be on the default branch or added by the same PR.
818
850
 
851
+ ### Experiment arm overrides (#5206)
852
+
853
+ An `experiment:` arm can carry config overrides that apply only to the lanes hashed to that arm, so one batch, one checkout and the normal issue flow run both arms. A key is `<arm>.<key>: <value>`, where `<arm>` is a declared arm:
854
+
855
+ ```yaml
856
+ experiment:
857
+ id: explore-ab
858
+ arms: on,off
859
+ on.lean.explore: on
860
+ off.lean.explore: off
861
+ min_n: 20
862
+ ```
863
+
864
+ | Override key | Values | Overrides |
865
+ |---|---|---|
866
+ | `lean.explore` | `on`, `off` | `lean.explore` |
867
+ | `lean.explore_model` | a model id | `lean.explore_model` |
868
+ | `lean.light_mode` | `off`, `shadow`, `on` | `lean.light_mode` |
869
+ | `context_pack` | `shadow`, `on`, `off` (not `ab`) | `engine.context_pack` |
870
+ | `review.verifier` | `off`, `shadow`, `enforce` | `review.verifier` |
871
+
872
+ Any other dotted key, a key for an undeclared arm, or an invalid value makes the whole `experiment:` declaration invalid. The experiment is then ignored, with the reason printed to stderr, and no override is ever partly applied. The lane applies its arm's overrides before it reads any of these settings. `RUN_TERMINAL` (and `phase_attempt` telemetry) records `arm_overrides`: the applied overrides as a sorted `key=value` list, or `none`. `forgedock stats --experiment <id>` adds an `applied` column per arm: the runs whose recorded overrides match the arm's. A count below `n` means the toggle did not apply on some runs.
873
+
819
874
  Closing an experiment follow-up (#4634): add a check that runs `forgedock stats --experiment <id> --require-met` (exit 0 only when every target of the forge.yaml `experiment:` is met; n/a below min n is not met), and put `[check:<check id>]` in the follow-up item:
820
875
 
821
876
  ```json
@@ -877,9 +932,9 @@ lean:
877
932
  | `repro_test` | string | No | `prefer` (default): on an issue labelled `bug` or `type:bug`, the plan step must freeze a `repro_test` in the contract (`{"path","id","command"}`) when the bug is testable. Before review, the engine runs `scripts/acceptance-red-green.sh` for that command on the host in every verify mode: one targeted test, red on the base (head's changed test files overlaid) and green on head. A test that ran but is not red on the base and green on head fails the precheck as `conformance.unimplemented` (it blocks in shadow too) and goes back to the builder for one in-session fix round. A head the harness could not run at all (timeout, missing runner or dependencies) ends `needs-human` with the recoverable code `env.repro_unrunnable`, not a builder round: the batch runner's recovery lane reruns it through the repo's own toolchain (see docs/OUTCOME-CODES.md). The harness runs with the lane env (`TMPDIR`, toolchain) and the workspace dependency trees, and a repro test file that is new on head is run against the base sources. A bug that is not testable (specs, docs, workflows, environment) records `"repro_test":"none"` with a one-line `repro_test_reason` and the lane continues as before. `off` gives exactly the previous contract and precheck. Each proof emits a `REPRO_RED_GREEN` run-log event (`base`, `head`) and adds a trajectory decision. |
878
933
  | `precheck.max_minutes` | number | No | Total budget in minutes (1–120) of one round of pre-PR check commands (#4331). The flat form `lean.precheck_max_minutes` also works and wins. When unset, `verify.precheck_total_seconds` applies (default 600 s). Check commands run change-scoped (a learned command with a test-map entry runs only when its globs match the changed files; unmapped commands always run), concurrently up to the host worker cap under one heavy slot, each timed (`ms` in the `PRECHECK_COMMANDS` run-log event). Commands not started when the budget runs out are recorded `deferred-to-ci` (an anomaly, not a failure) and left to CI. |
879
934
  | `fix_model` | string | No | Model of fresh fix-round sessions (#4363; `engine.lean_fix_model` is also read). Default: the reviewer model (`engine.lean_reviewer_model`, else Sonnet). Fix rounds for precheck, CI, docs, structure, enumerating-test and sequence-number failures, and conformance or review FAILs whose failures all cite a `file:line`, run in a fresh session (no resume of the builder's transcript) whose prompt carries only the round's failure output, the capped `git diff <base>...HEAD`, the frozen contract and the issue title and summary (under 60K characters). A fresh session that makes no commit gets one resume of the original builder session in the same round. Other rounds (block or contract corrections, CI unavailable, base-sync conflicts, failures without a file:line) resume the builder as before; round limits (`verify.max_rounds`, the one review retry) are unchanged. The run log's `PHASE_ATTEMPT_USAGE` records `mode: "fresh"\|"resume"` on each fix-round attempt. Plan and build sessions keep the builder model. |
880
- | `builder_routing` | string | No | `on` (default) or `off` (#4394). After the contract is frozen, the lane is classed from its deliverable paths only: `risk` (any path with a built-in risk word such as auth, billing, payments, session, secret or migration, or matching a `review.risk_paths` glob), `docs-config-test` (every path is a test, doc or config file; lockfiles count as code), `small` (at most 2 non-test deliverables) or `large` (more, or none). `docs-config-test` and `small` build on the mid tier (`builder_mid_model`); `risk` and `large` build on the top model (`--model`, else the CLI default). The plan and contract-correction calls always run on the top model. A failed validate round on the mid tier (`precheck`, `ci_red`, `merge_ci`) escalates the lane once: that fix round and every later builder call, fresh fix sessions included, run on the top model. Escalation adds no round. Conformance or review fix rounds do not escalate and keep `fix_model`. `off` keeps every builder call on the top model, as before, and still records the class. The run log gets `BUILDER_ROUTE {mode, class, tier, model, risk}` and `BUILDER_ESCALATED {from, to, trigger}`, and `RUN_TERMINAL` gets `builder_tier`, `builder_class`, `builder_escalated` and `builder_model`. `forgedock stats --tiers` reports merge, conformance and post-merge-rework rates, first-pass yield and cost per tier (`mid`, `mid->top`, `top`) and class, from local run logs. Target-repo risk areas (for example detection code) belong in `review.risk_paths`. |
935
+ | `builder_routing` | string | No | `on` (default) or `off` (#4394). After the contract is frozen, the lane is classed from its deliverable paths only: `risk` (any path with a built-in risk word such as auth, billing, payments, session, secret or migration, or matching a `review.risk_paths` glob), `docs-config-test` (every path is a test, doc or config file; lockfiles count as code), `small` (at most 2 non-test deliverables) or `large` (more, or none). `docs-config-test` and `small` build on the mid tier (`builder_mid_model`); `risk` and `large` build on the top model (`--model`, else the CLI default). The plan and contract-correction calls always run on the top model. A failed validate round on the mid tier (`precheck`, `ci_red`, `merge_ci`) escalates the lane once: that fix round and every later builder call, fresh fix sessions included, run on the top model. Escalation adds no round. Conformance or review fix rounds do not escalate and keep `fix_model`. `off` keeps every builder call on the top model, as before, and still records the class. The run log gets `BUILDER_ROUTE {mode, class, tier, model, risk}` and `BUILDER_ESCALATED {from, to, trigger}`, and `RUN_TERMINAL` gets `builder_tier`, `builder_class`, `builder_escalated` and `builder_model`. `forgedock stats --tiers` reports merge, conformance and post-merge-rework rates, first-pass yield and cost per tier (`mid`, `mid->top`, `top`) and class, from local run logs. Target-repo risk areas (for example detection code) belong in `review.risk_paths`. A diff that relaxes a rule in a declared `review.risk_paths` path (a new accept/rescue/allow branch or a removed deny) must add a negative test (`conformance.unimplemented` `relaxation_untested` otherwise) and always gets the independent verifier, even with `review.verifier: off` (#5237). |
881
936
  | `builder_mid_model` | string | No | Mid-tier builder model for `builder_routing` (#4394; `engine.lean_builder_mid_model` is also read). Default `claude-sonnet-5-5`. An invalid id is ignored. |
882
- | `light.mode` | string | No | `off`, `shadow` (default) or `on` (#4448). `bin/lean/light.mjs` decides whether an issue qualifies for the light lane: a repro, steps to reproduce, expected or actual behaviour or a code block in the body; 1 to `max_files` predicted non-test files; no `size:M`/`size:L` label; no predicted path with a built-in risk word or matching `review.risk_paths`; not an `investigate(` issue, a post-deploy issue (`post-deploy`/`awaiting-promotion` label, or only post-deploy checklist items) or a decision issue (`decision`, `needs-decision`, `product-decision`, `rfc` or `adr` label, or a `decision(`/`rfc(`/`adr(` title). A missing repro or file prediction is `ambiguous`, left to a cheap classifier. `off` is never eligible; `shadow` reports the verdict without changing the lane; `on` lets an eligible issue run light. The lane wiring is #4450. A light lane posts a `FORGE:LITE` receipt on the issue (outcome light or upgraded, diff stat, red/green repro, gates, true cost from the #4407 per-session deltas, eligibility reason, upgrade reasons), and the batch efficiency report ends with a `lanes:` line: the light/upgraded/full split with cost and the upgrade rate, upgraded ÷ (light + upgraded) (#4452). The flat form `lean.light_mode` also works and wins. |
937
+ | `light.mode` | string | No | `off`, `shadow` (default) or `on` (#4448). `bin/lean/light.mjs` decides whether an issue qualifies for the light lane: a repro, steps to reproduce, expected or actual behaviour or a code block in the body; 1 to `max_files` predicted non-test files; no `size:M`/`size:L` label; no predicted path with a built-in risk word or matching `review.risk_paths`; not an `investigate(` issue, a post-deploy issue (`post-deploy`/`awaiting-promotion` label, or only post-deploy checklist items) or a decision issue (`decision`, `needs-decision`, `product-decision`, `rfc` or `adr` label, or a `decision(`/`rfc(`/`adr(` title). A missing repro or file prediction is `ambiguous`, left to a cheap classifier. `off` is never eligible; `shadow` reports the verdict without changing the lane; `on` lets an eligible issue run light. The lane wiring is #4450. A light lane posts a `FORGE:LITE` receipt on the issue (outcome light or upgraded, diff stat, red/green repro, gates, true cost from the #4407 per-session deltas, eligibility reason, upgrade reasons), and the batch efficiency report ends with a `lanes:` line: the light/upgraded/full split with cost and the upgrade rate, upgraded ÷ (light + upgraded) (#4452). A predicted file over `maintenance.hotspot.file_lines` is a hard `hotspot` reason, and every evaluated signal (repro, named files, churn, hotspot, risk path, `docs`/`config`/`chore` labels, size) is recorded in the `LIGHT_ELIGIBILITY` event's `signals` without changing the verdict (#5209). `forgedock stats --depth` reports outcomes per verdict and signal and whether the #5052 promotion criterion is met; flipping `mode: on` stays a config decision. The flat form `lean.light_mode` also works and wins. |
883
938
  | `light.max_lines` | number | No | Upgrade trigger (#4448): a light lane whose non-test diff (added + deleted lines) exceeds this moves to the full lane. Default 40. The other triggers: more than `max_files` non-test changed files, a repro that is not red on the base, two failed test runs, a touched risk path, or a public-API-shape change (#4449). Flat `lean.light_max_lines` wins. |
884
939
  | `light.max_files` | number | No | Max predicted non-test files for eligibility and max changed non-test files before an upgrade (#4448). Default 2. Flat `lean.light_max_files` wins. |
885
940
  | `sequence.regenerate` | string | No | Command run in the lane worktree (`sh -c`) after the engine renumbers a schema-changing sequence-numbered migration (#4386), to regenerate its snapshot, e.g. `pnpm --filter @x/db db:generate`. The flat form `lean.sequence_regenerate` also works and wins. When a lane-added numbered file (`NNNN_*.sql`, a drizzle `meta/_journal.json` + `meta/NNNN_snapshot.json`, a numbered ADR) shares its number with the base, the engine renumbers it without a builder session: `git mv` to max(base)+1…, the document's own number in its heading, references to the old name repo-wide, the base journal plus the lane's entries, and a data-only migration's snapshot cloned from the base tip with a new `id`/`prevId`. A schema-changing migration without this command, or a migration in another language (`.py`, `.ts`), falls back to the builder renumber, and the trajectory records why. When the generator writes no snapshot for a hand-written migration (no schema diff), the engine reruns it with ` --custom` appended (drizzle-kit's empty migration), keeps its snapshot and restores the lane's SQL byte-identical, so the command must forward trailing args (a pnpm/yarn script, or `npm run x --`). A base-sync whose conflicts are only in such files is resolved the same way, with no re-review. At the merge gate a lane with numbered files holds a host sequence lease per (repo, lane branch, directory) from its last renumber check through the merge, so only one numbered-file PR is in the renumber→CI→merge window at a time. |
@@ -940,6 +995,7 @@ verify:
940
995
  ".py": "scripts/pytest {path}"
941
996
  e2e: auto # optional e2e merge gate: auto (default) | always | never
942
997
  precheck_block: false # optional (#5079); true: a declared pre-PR check still failing after the fix round (or a round with no commit) ends the lane needs-human ci.red (recoverable) instead of opening the PR with an anomaly
998
+ guard_block: true # optional (#5239); default true: verify.invariants (the pre-merge guard set) block the merge; false keeps a failing invariant advisory
943
999
  e2e_label: full-ci # PR label that makes the repo's CI run e2e (label path)
944
1000
  e2e_checks: "e2e" # check names of the e2e jobs the label path waits on
945
1001
  # e2e_workflow: e2e.yml # or: a workflow_dispatch workflow that runs e2e (wins over the label)
@@ -959,6 +1015,7 @@ verify:
959
1015
  | `precheck_total_seconds` | integer | No | Total budget of one round of pre-PR check commands (1–7200, default 600; it was 1800 before 1.30.0). `lean.precheck.max_minutes` takes precedence. Commands not started within the budget are deferred to CI, not failed. |
960
1016
  | `checks` | string | No | Comma-separated check names that gate CI verification without `workflow` (forge#4387). Overrides the required-check set; other checks are reported, not gating. |
961
1017
  | `invariants` | list | No | Block list of cheap repo-wide check commands (#4585), e.g. the suites that list every table, export, key or namespace (cross-tenant registry, export and purge coverage, i18n status, boundary tests). They run in the pre-PR check round in every verify mode, whichever tests the test map selected: never scoped away by `.forge/test-map.json`, deduplicated against the learned commands, and subject to the same round budget and per-command timeout. A failure goes to the builder in the precheck fix round like a failed declared check. The plan and implement prompts also carry an invariants checklist built from the list (a new table, export or key must join every registry that enumerates its kind). `forgedock check` and the light lane run them too. Absent: nothing changes. |
1018
+ | `guard_block` | boolean | No | Default `true` (#5239). `invariants` are the repo's pre-merge guard set: they also run on the merged tree after a base-sync (before the push), and one still failing after the fix rounds ends the lane needs-human `ci.red` instead of opening or merging the PR. Before spending a builder round, a failing invariant is run once on the merge base: if it fails there too the base is already red, so the lane ends `deferred` with `base.red` (never needs-human, retried after 900 s), the commit that last changed the files the failure names is found with `git log`, and the issue it belongs to (closing keyword, `issue-N` branch, or last `(#N)` in the message) gets a `FORGE:BASE_RED` comment and is reopened if closed; with no issue number a tracking issue is filed. `false`: failing invariants stay advisory as before. No effect without `invariants`. |
962
1019
  | `guard_command` | map | No | Guard gate (#4693) test-file command per extension (#4792), e.g. `".py": "scripts/pytest {path}"` for a repo whose tests need a managed environment. Consulted before the contract's validate commands and the hard-coded `node --test` / `python -m pytest -q` fallbacks. `{path}` is replaced by the repo-relative path of the guard's base copy (`<name>__guardbase.<ext>`); a template without `{path}` gets it appended. Runs from the worktree root. Keys may be written with or without the leading dot. Absent: unchanged. |
963
1020
  | `check_run` | boolean | No | Default `false` (no Checks API call, behaviour unchanged). `true`: after each push of a reviewed head (PR open, base-sync, merge-time fix round) the engine posts one completed `forgedock/verify` check run on that head (forge#4270), `success` iff every deterministic gate the lane already ran passed: declared check commands, undeclared package edges, docs freshness, contract scope, validate ids, requirement status, hotspot growth, amendments. The output carries each gate's id, pass/fail and evidence as JSON; the run log records a `VERIFY` event. Report only: ForgeDock never makes it required and never waits on it (it is ignored by its own CI waits); requiring it is the repository's branch-protection choice. Creating check runs needs a token that may (a GitHub App with `checks: write`); a Checks API failure is logged as an anomaly and never fails the lane. |
964
1021
  | `post_merge` | string | No | Command run in the lane worktree on the merged tree after each base-sync merge, before the push (forge#4406). Default: the typecheck rows of the lane's change-scoped checks (`bin/lean/checks.mjs`), in `local` and `hybrid` mode only; `ci` mode runs no host typecheck unless `post_merge` is set. A failure resumes the builder with the output, up to `max_rounds` rounds, and the fixed head is re-reviewed; still failing is a trajectory anomaly and CI stays the gate. |
@@ -1071,7 +1128,7 @@ execution:
1071
1128
  | `day_budget_minutes`, `day_budget_usd` | number | No | The same cap per host UTC day, summed over every batch on the host from the host-day store (`execution-budget.json` in `~/.forge/sched/`, or `FORGEDOCK_EXECUTION_BUDGET_FILE`). A corrupt or unreadable store refuses remote lanes while a day cap is set; remove the file to reset it. |
1072
1129
  | `fallback_local` | boolean | No | `true`: a remote-placed lane runs on the host while the provider reports no agent online (`GET {endpoint}/status -> {"online": N}`, the built-in router answers it with `online`, `total` and per-agent `ok`/`paused`), so a batch completes locally with every pool agent offline or asleep (forge#4547). Default `false`: such lanes defer (`sandbox.capacity`). A missing or failing `/status` is unknown and never triggers it. It also covers a sustained `sandbox.capacity`: an issue the pool refused `capacity_fallback_after` times (default 3) for capacity runs on the host when the host has headroom (the host-busy guard; a busy host or a failing probe keeps it waiting remote) (forge#5112). |
1073
1130
  | `capacity_fallback_after` | integer | No | With `fallback_local: true`: how many `sandbox.capacity` deferrals of one issue make it run on the host, subject to the host-busy guard (forge#5112). Default: 3. A missing, non-integer or non-positive value uses the default. |
1074
- | `account_rotator` | string | No | `tokenbaton`: the `claude` on PATH is the tokenbaton shim, which runs each call on the logged-in account with the most room (`CLAUDE_CONFIG_DIR=~/.claude-<n>`) (forge#5094). forgedock reads `~/.tokenbaton/current` (the account number) and `~/.tokenbaton/live.<n>` (`<5h used %> <5h reset s> <weekly used %> <weekly reset s> <updated s>`), re-read on every check and never written. An account has headroom when its 5-hour use is under 95% and its weekly use under 100% (a window whose reset has passed counts as 0). While any account has headroom no host-wide usage hold is recorded and admissions continue; they stop only when every account is exhausted and resume when the first one resets. A lane whose call hits a usage limit retries that same call (same session) on the next account at once, at most once per account, before it pauses or defers. `forgedock limits show` lists each account's 5-hour use. Any other value, or unreadable files: off (per-account holds as before). |
1131
+ | `account_rotator` | string | No | `tokenbaton`: the `claude` on PATH is the tokenbaton shim, which runs each call on the logged-in account with the most room (`CLAUDE_CONFIG_DIR=~/.claude-<n>`) (forge#5094). Unset: detected (forge#5205) when `TOKENBATON_HOME` is set or the first `claude` on PATH resolves to `tokenbaton-exec` / a `.tokenbaton/shim/claude`; `off` (also `none`, `false`) or env `FORGEDOCK_ACCOUNT_ROTATOR=off` disables it. forgedock reads `$TOKENBATON_HOME` (as-is, else `~/.tokenbaton`): `current` (the account number) and `live.<n>` (`<5h used %> <5h reset s> <weekly used %> <weekly reset s> <updated s>`), re-read on every check and never written. An account has headroom when its 5-hour use is under 95% and its weekly use under 100%; a sample whose reset has passed is stale: unknown, never 0%, worth one try but ranked after fresh samples. While any account has headroom no host-wide usage hold is recorded and admissions continue. A lane whose call hits a usage limit records that account (from the run's `/proc/<pid>/environ`), excludes it until its reset, and relaunches the same call (same session) at once pinned to the account tokenbaton picks (the real `claude` past the shim, `CLAUDE_CONFIG_DIR=~/.claude-<n>`), at most once per account; the lane result reports `rotations` and `limited`, and the batch keeps excluding those accounts until their reset. Only when no account has room does the lane pause or defer, and the batch holds until tokenbaton's earliest reset over every account. When the installed tokenbaton has the tokenbaton#3 API, forgedock uses `tokenbaton --pick --json --exclude <n,..>` (exit 2 = none with room, `earliest_reset`) and `tokenbaton-ctl mark-limited <n> --until <s>`; otherwise it computes the same from `live.<n>`. `forgedock limits show` lists each account's 5-hour use, `(stale)` for a passed reset. Any other value, or unreadable files: off (per-account holds as before). |
1075
1132
  | `warm_sandboxes` | integer | No | Warm sandboxes per repo the pool agent keeps ready (checkout at the base ref, dependency cache primed). When `N > 0` the launch spec carries `warm: N` and the lane first calls `POST {endpoint}/sandboxes/claim`; a ready warm sandbox takes the lane (refreshed to the lane's base ref with an incremental fetch before work starts), and when none is ready, the claim fails or the endpoint lacks the route the lane starts cold. Default `0` (off): no claim call and the launch spec is unchanged (forge#4912). |
1076
1133
  | `unreachable_window_min` | number | No | Remote providers: how long a lane keeps polling (with backoff, up to 30s) after the provider's transport fails (connection refused/reset, `fetch failed`, timeout, 502/503/504) before it ends `deferred` with `sandbox.unreachable` (forge#4672). Inside the window the lane never ends and the sandbox is never torn down; after it the sandbox is kept and adopted on the next attempt or `--resume`; the engine-error breaker does not count it. `adopt` applies the same window. Default: 5 |
1077
1134
  | `on_budget` | string | No | `stop` (default): running lanes finish and the rest end `held` (`execution budget: ...`) for a later `--resume`. `local`: the rest run as detached host lanes. |
@@ -107,6 +107,8 @@ All pass: the issue counts as **verified**, and a `FORGE:WATCH_VERIFY` comment r
107
107
 
108
108
  `mode: release` claims nothing immediately. It pools the issues that match the selectors and cut a **themed release** when a trigger fires, then orchestrates just that set.
109
109
 
110
+ Once the batch reports and the deploy PR is open, the watch starts `forgedock release` for it (resumable; promotion stays opt-in via `--merge` / `release.auto_merge`, the watch never merges).
111
+
110
112
  ```yaml
111
113
  issue_watch:
112
114
  watches:
@@ -45,8 +45,10 @@ An absent or unknown code is recorded as `unclassified`, with the raw reason kep
45
45
  | `gh.auth` | A `gh` call in a core run answered HTTP 401 (expired or revoked bot token) and one run of `scripts/refresh-bot-token.sh` plus a retry did not fix it; the run is `deferred` (retry in 120s), never `engine-error`. See `docs/CONFIG.md` "Bot token refresh" | lean | `bin/lean/retry.mjs` |
46
46
  | `rate_limited` | Session or usage limit outlasted the pause budget | engine | `err.usageLimit` / `err.resetAtEpochMs` |
47
47
  | `backend.auth` | The claude CLI login failed ("Failed to authenticate", expired or invalid login); the lane is `deferred` (retry in 900s) under a per-account hold like a usage limit, never `engine-error`, never relaunched or counted by the breaker (#5168) | lean | `bin/runner.mjs` `err.authFailure` |
48
+ | `quota.exhausted` | No account has capacity (the rotator picks none: every login at its ceiling); the lane is `deferred` until the earliest reset, never spawned through the shim, never `backend.auth` (#5236) | lean | `bin/lean/quota.mjs` `poolExhausted` |
48
49
  | `engine.error` | Engine or tool failure (missing key/SDK, CLI crash, max turns, unresolved args, runner threw every attempt) | engine | `err.code` |
49
50
  | `engine.dco_rewrite` | Core work-on (forge#4997): the DCO sign-off rewrite (`git filter-branch`) of the lane's unpushed commits failed, or the lane's uncommitted changes could not be restored after it (kept on `refs/forgedock/dco-stash`). A mechanical engine step, not a human block: the lane ends `engine-error` (never `needs-human`), which `forgedock orchestrate` relaunches like any engine-error | lean | `bin/lean/signoff.mjs` `ensureSignedOff` |
51
+ | `engine.push_diverged` | Core work-on (forge#5202): the lane-branch push was rejected non-fast-forward and no other live lane owns the branch (no open PR, no live lease), after the pre-push reconcile could not merge the remote-only commits (they are not this worktree's own `wip(forge): checkpoint` commits). The lane's own history diverged: a mechanical engine state, not a human block. The lane ends `engine-error` (never `needs-human`), which `forgedock orchestrate` relaunches; the exit rescue pushes HEAD to `forge-salvage/<issue>-<sha>` | lean | `bin/lean/lean.mjs` push-rejection classification, `bin/lean/checkpoint-reconcile.mjs` |
50
52
  | `engine.validate_result_lost` | Core work-on (forge#4708): a validate result recorded before a merge-time CI fix round is missing from the fix session's result file and could not be carried forward; an engine bookkeeping error, not an unimplemented requirement | lean | `bin/lean/lean.mjs` `mergeFixRound` |
51
53
  | `infra.disk_quota` | Disk full or quota exhausted (EDQUOT/ENOSPC, errno -28/-122); retryable infra failure, never `needs-human` | engine | Runner error text |
52
54
  | `infra.cli_spawn_transient` | CLI spawn failed transiently before the child ran (ETIMEDOUT, EAGAIN, ENOMEM, EMFILE); retried with backoff on a separate bounded counter that does not consume a phase attempt | engine | `err.code` `CLI_SPAWN_TRANSIENT` |
@@ -58,6 +60,7 @@ An absent or unknown code is recorded as `unclassified`, with the raw reason kep
58
60
  | `env.repro_unrunnable` | Core work-on (forge#4334): on a bug lane the frozen `repro_test` could not be run on head by `scripts/acceptance-red-green.sh` (`HEAD=UNRUNNABLE`: timeout, exit 126/127, unclassifiable output) or the harness returned no result. An environment error, not a conformance failure: no builder resume, no reviewer. Ends `needs-human`; recoverable by `forgedock orchestrate` (the recovery lane reruns the repro command through the repo's own toolchain and installed dependencies). Other non-proofs (passes on base, fails on head, base unrunnable) stay `conformance.unimplemented` | lean | `gate()` `io.redGreen` words, classified by `conformance.mjs` `reproFailures` |
59
61
  | `env.capability_remote` | Core work-on (forge#4542): a lane placed in a remote sandbox ended `builder.blocked (credentials)` and its summary names only host capabilities declared in `execution.host_capabilities` (SOPS/age key, ops credentials, prod monitor SSH), which the sandbox does not relay but the dispatching host has. Recoverable by `forgedock orchestrate`: the recovery lane is placed local, once, under the same lease. A credential need the host lacks too stays `builder.blocked` | lean | `endBlocked` via `execution.mjs` `hostCapabilityBlock` |
60
62
  | `sandbox.start_failed` | A `forgedock orchestrate` lane sandbox (forge.yaml `execution`, provider `container` or `remote`) could not start: bad image, missing endpoint, a refused launch (HTTP 4xx other than 401/403/429) or a non-HTTP start failure. The lane never ran. Final `needs-human` row: not relaunched and not counted by the engine-error circuit breaker | orchestrate | `bin/lean/execution.mjs` `providerLanes`: `provider.start` threw without `retryable`, `transient` or a 5xx/401/403 `status` |
63
+ | `base.red` | Core work-on: a `verify.invariants` guard command fails on the base too (forge#5239). `deferred` (retry 900 s), never needs-human; the introducing issue gets a `FORGE:BASE_RED` comment (reopened if closed) | lean | `bin/lean/basered.mjs` guard run on the base |
61
64
  | `sandbox.capacity` | The sandbox provider had no capacity for the lane (HTTP 429/503 from the remote transport). `deferred`, requeued after `Retry-After` when sent, else 60s; not counted toward `orchestration.max_deferrals`, like `host.busy` (forge#4528) | orchestrate | `provider.start` threw with `err.retryable: true` |
62
65
  | `sandbox.transient` | The remote sandbox provider answered HTTP 500/502/504 on launch: a router or agent infrastructure failure, not a code or human problem (forge#5095). `deferred`, requeued after `Retry-After` when sent, else 60s; counted toward `orchestration.max_deferrals` (so a broken pool ends `deferred`, never `needs-human`); not counted by the engine-error circuit breaker | orchestrate | `bin/lean/execution.mjs` `providerLanes` `startFailed`: `provider.start` threw with `err.status` 5xx (not retryable) or `err.transient` |
63
66
  | `sandbox.auth` | The remote sandbox provider refused the lane's credential (HTTP 401/403) at start (forge#4685). `deferred`, retried after 300s, never `needs-human`; the pool token resolves from the env, the keychain, then `~/.config/computeshare/forgedock.token` | orchestrate | `provider.start` threw with `err.status` 401/403 |
package/docs/STATS.md CHANGED
@@ -106,6 +106,25 @@ conformance pass, and then the post − pre delta.
106
106
  the result is under `query.efficiency.compare`. Cohorts are split by batch `plan.created`, as `--window` is; a lane run
107
107
  outside a batch is in neither.
108
108
 
109
+ ## Lane depth (`--depth`, forge#5209)
110
+
111
+ `forgedock stats --depth [--since <version|date>] [--min-n N] [--offline] [--repo <owner/repo>] [--json]` reads the local
112
+ run logs (`~/.forge/runs/*.jsonl`, every RUN_START..RUN_TERMINAL slice that logged `LIGHT_ELIGIBILITY`) and uses gh only
113
+ for post-merge defect signals; `--offline` skips that crawl (defects print n/a, as does a gh failure).
114
+
115
+ Columns per cell: n, merge rate, first-pass rate, needs-human rate, median cost, median wall minutes, median wall/model
116
+ time, review findings per lane (conformance failures + verifier findings) and the share of lanes with any, conformance
117
+ failure rate, and the post-merge defect rate (a reopen, a revert naming the PR, or a `fix`/`bug` PR touching the same
118
+ non-test files within 7 days) over merged lanes with known defect data.
119
+
120
+ Cells are grouped by verdict (eligible, ambiguous, ineligible) and by every reason and signal code (`hotspot`,
121
+ `churn_high`, `label_docs`, `size_S`, ...), so outcomes can be attributed to each signal.
122
+
123
+ Promotion (#5052): treatment = light-shaped lanes (light or upgraded), control = full lanes the gate rated eligible, in the
124
+ size buckets both have. Met when median cost ratio <= 1.2x, median wall/model <= 1.3x and the treatment defect rate is no
125
+ worse than the control's; a cell under `--min-n` (default 10) is `insufficient data`, with n per cell printed. Flipping
126
+ `lean.light.mode: on` stays a config decision.
127
+
109
128
  ## Pool utilisation (`--pool`, forge#4549)
110
129
 
111
130
  `forgedock stats --pool [--window 7d,30d] [--json]` reads the repo's local batch `report.json` rows and prints, per window,
@@ -133,6 +152,31 @@ Efficiency next to quality: run `forgedock stats --efficiency --compare <date|ve
133
152
  $/merge, turns/merge and wall p50. Baseline before #4693 enforces: run `forgedock stats --compounding --json --since <date>` in
134
153
  a full clone of this repo and one other and keep the output with the #4697 tracker.
135
154
 
155
+ ## Conformance outcomes (`--conformance-outcomes`, forge#5210)
156
+
157
+ `forgedock stats --conformance-outcomes [--repo R] [--since <date>] [--window-days 7] [--min-n 20] [--json]` asks whether conformance
158
+ blocks predict post-merge defects. Read only, no model and no GitHub writes. GitHub reads are one `gh api graphql` search per
159
+ page of 100 merged PRs (`repo:R is:pr is:merged merged:>=<since>`, `--since` defaults to 30 days ago; GitHub search stops at
160
+ 1000 results, flagged `capped`) plus the usual FORGE:TELEMETRY crawl. Verdicts also come from the local run logs and batch
161
+ reports unless `--no-local`.
162
+
163
+ - **lane PR**: a merged PR with a conformance verdict (`query.mjs` `conformanceVerdicts`; the latest of the telemetry
164
+ `run_terminal`/`conformance_shadow`, run-log `RUN_TERMINAL`/`CONFORMANCE_SHADOW`/`CONFORMANCE` and batch-row `conformance`
165
+ wins). `shadow_would: conforms` conforms. Any other `would` is nonconforming, and its failure codes are the kinds. An
166
+ enforce merge with no `would` passed the enforced gate and conforms. A merged PR without a verdict counts under `unjoined`.
167
+ - **signals** inside `--window-days` after the merge:
168
+ - `reverted`: a later merged `Revert ...` PR naming `#N`, `Reverts R#N` or the title.
169
+ - `reopened`: a closing issue was reopened.
170
+ - `cited`: a later merged PR says `fix ... #N` or `review-finding ... #N` for the PR or its issue on one line.
171
+ - `same_hunks`: a later `fix`/`revert` PR whose old-side lines `git blame` to this PR's merge commit. Only in a clone of R.
172
+ Otherwise it is `null` and counted under `same_hunks_unresolved`.
173
+ - A PR is defective when any signal is true. A PR whose window has not elapsed is `pending` and is not counted.
174
+ - **cells**: per repo, then the same split per mode and per failure kind. Each cell is `defects/n rate [Wilson 95% interval]`
175
+ for nonconforming-merged vs conforming-merged, `n/a` under `--min-n` (default 20 per cell).
176
+ - **conclusion** (last line): `nonconforming merges show a higher defect rate` when the nonconforming interval lies wholly
177
+ above the conforming one, `no higher defect rate shown for nonconforming merges` otherwise, and `insufficient data` when
178
+ either overall cell is under min n.
179
+
136
180
  ## Explorer A/B (`--explore-ab`, forge#4418)
137
181
 
138
182
  Compares lanes run with forge.yaml `lean.explore: on` against `off` (#4391), from the local run logs only (no GitHub
package/docs/TELEMETRY.md CHANGED
@@ -43,7 +43,7 @@ is dropped. Payload keys are `[A-Za-z0-9_]+` and cannot shadow the shared keys;
43
43
  | `ci_local_check` | `scripts/ci-local.sh run`, one per scoped, widened or executed check (at most 20 per run) | `job`, `selector`, `selected`, `total`, `cache` = `hit` \| `miss` \| `dedup` \| `na`, `duration_ms`, `wait_ms` (job slot wait), `widen` (reason or `none`). A remote-CI failure at merge on a check recorded here as narrowed is a selector bug |
44
44
  | `liveness` | `scripts/remediate-liveness.sh` | `decision` = `PROCEED` \| `DEFER` \| `EXHAUSTED`, `why` |
45
45
  | `phase_attempt` | the engine (`bin/engine/telemetry-seam.mjs`, one per phase attempt; `phase` = the phase id) | `attempt`, `trigger` (#4362: why the attempt ran, one of `plan`, `build`, `block_correction`, `contract_correction`, `precheck`, `structure`, `docs`, `enumerating`, `sequence`, `ci_unavailable`, `ci_red`, `conformance`, `review`, `merge_ci`, `timeout_restart`, `recovery`; `restart_of` = the trigger a `timeout_restart` replaced), `model`, `backend` (`cli`/`api`), `turns`, `duration_ms`, `cost_usd` (the raw reported value: a running total when the attempt resumed a CLI session), `cost_usd_delta` (#4407: this attempt's cost; consumers sum it when present, else `cost_usd`), `cost_usd_session` (the CLI session's running total), `input_tokens`, `output_tokens`, `cache_read_tokens`, `cache_creation_tokens` (any value the runner did not report is omitted) |
46
- | `run_terminal` | the engine (`terminate()`, one per run segment) | `experiment` and `arm` (#4629, only when forge.yaml declares an `experiment:`; also on `phase_attempt`), `reason` (terminal reason), `code` (see `docs/OUTCOME-CODES.md`), `wall_ms` (this engine process, start to terminal) |
46
+ | `run_terminal` | the engine (`terminate()`, one per run segment) | `experiment` and `arm` (#4629, only when forge.yaml declares an `experiment:`; also on `phase_attempt`), `arm_overrides` (#5206, with them: the arm's applied overrides as sorted `key=value,...`, `none` when the arm has none), `reason` (terminal reason), `code` (see `docs/OUTCOME-CODES.md`), `wall_ms` (this engine process, start to terminal) |
47
47
 
48
48
  The engine records carry `run` = `r_<issue>_<start epoch seconds>` (one per `forgedock run-issue` process) so `forgedock stats`
49
49
  (`docs/STATS.md`) can group the attempts of a run and tell a finished run from an unfinished one. They are the GitHub-side
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forgedock",
3
- "version": "1.52.0",
3
+ "version": "1.53.0",
4
4
  "description": "Autonomous development pipeline for coding agents. GitHub as institutional memory, with native Claude Code and OpenCode entrypoints.",
5
5
  "bin": {
6
6
  "forgedock": "bin/forgedock.mjs"
package/pool/README.md CHANGED
@@ -10,6 +10,6 @@ ForgeDock's built-in remote compute pool (imported from computeshare; AGPL-3.0-o
10
10
 
11
11
  The module boundary is the ForgeDock HTTP sandbox protocol: the router speaks it to the dispatcher and relays to agents over HTTP. Sandboxes receive only short-lived GitHub and Claude access tokens; refresh tokens stay on the router host.
12
12
 
13
- Claude login choice (#5165): among the router host's logins with 30+ minutes left, the router hands out the one with the lowest 5-hour use in tokenbaton's `live.<n>` (account `n` = `~/.claude-<n>`), read from router.json `usage_source` (default `$TOKENBATON_HOME`, else `~/.tokenbaton`); validity only breaks ties. An account at or above `usage_ceiling_pct` (default 95) or at 100% weekly use is skipped; when every login is, `/agent/creds/claude` answers a typed 429 (`code: rate_limited`, `reset_at` = the earliest reset, `retry-after`), which the agent passes through and `cs-cred` prints as `usage limit hit; resets at <ISO>` so the lane defers. Without readable usage it falls back to the longest validity and logs a warning. The selected account index and usage are logged, never the token.
13
+ Claude login choice (#5165): among the router host's logins with 30+ minutes left, the router hands out the one with the lowest 5-hour use in tokenbaton's `live.<n>` (account `n` = `~/.claude-<n>`), read from router.json `usage_source` (default `$TOKENBATON_HOME`, else `~/.tokenbaton`); validity only breaks ties. An account at or above `usage_ceiling_pct` (default 95) or at 100% weekly use is skipped; when every login is, `/agent/creds/claude` answers a typed 429 (`code: rate_limited`, `reset_at` = the earliest reset, `retry-after`), which the agent passes through and `cs-cred` prints as `usage limit hit; resets at <ISO>` so the lane defers. Without readable usage it falls back to the longest validity and logs a warning. The selected account index and usage are logged, never the token. A sample whose 5-hour reset has passed is stale (#5205): unknown usage, never 0%, ranked after fresh samples. A lane that hits a usage limit runs `cs-cred claude --limited <reset>`, which drops the sandbox's cached token and posts to `/sandboxes/<id>/creds/claude/limited`; the agent drops its own cache and forwards to the router's `POST /agent/creds/claude/limited`, which excludes the account it last handed that agent until the reset (default one hour), then the lane fetches the next login and relaunches at once. With every login excluded or blocked, the 429 carries the earliest reset, limited accounts included.
14
14
 
15
15
  The `forgedock pool` CLI wiring is tracked separately (#4544).
@@ -2,9 +2,19 @@
2
2
  # SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
3
3
  # SPDX-License-Identifier: AGPL-3.0-or-later
4
4
  # cs-cred <github|claude>: prints a current credential, fetched through the agent and cached briefly.
5
+ # cs-cred claude --limited [reset]: the lane hit a usage limit (#5205): drop the cache, report it (reset: epoch s or
6
+ # unknown) so the router excludes that account until then, and fetch the next login's token as usual.
5
7
  set -euo pipefail
6
8
  kind="${1:?kind}"; ttl=240; [ "$kind" = claude ] && ttl=600
7
9
  cache="/tmp/.cs-cred-$kind"
10
+ if [ "$kind" = claude ] && [ "${2:-}" = --limited ]; then
11
+ rm -f "$cache"
12
+ [ -n "${CS_CRED_BASE:-}" ] || { echo "no credential relay (CS_CRED_BASE)" >&2; exit 1; }
13
+ reset="${3:-}"; [[ "$reset" =~ ^[0-9]+$ ]] || reset=""
14
+ acct=$(cat "$cache.account" 2>/dev/null || true); [[ "$acct" =~ ^[0-9]+$ ]] || acct=""
15
+ curl -sS --max-time 30 -o /dev/null -X POST -H "authorization: Bearer ${CS_CRED_TOKEN}" -H "content-type: application/json" \
16
+ -d "{\"reset_at\":${reset:-null},\"account\":${acct:-null}}" "$CS_CRED_BASE/claude/limited" || true
17
+ fi
8
18
  if [ -s "$cache" ] && [ $(( $(date +%s) - $(stat -c %Y "$cache") )) -lt $ttl ]; then cat "$cache"; exit 0; fi
9
19
  [ -n "${CS_CRED_BASE:-}" ] || { echo "no credential relay (CS_CRED_BASE)" >&2; exit 1; }
10
20
  body=$(mktemp); trap 'rm -f "$body"' EXIT
@@ -16,4 +26,7 @@ if [ "$code" = 429 ]; then
16
26
  fi
17
27
  tok=""; [ "$code" = 200 ] && tok=$(jq -r .token "$body" 2>/dev/null || true)
18
28
  [ -n "$tok" ] && [ "$tok" != null ] || { echo "credential fetch failed ($kind)" >&2; exit 1; }
19
- umask 077; printf '%s' "$tok" > "$cache"; printf '%s' "$tok"
29
+ umask 077; printf '%s' "$tok" > "$cache"
30
+ acct=""; [ "$code" = 200 ] && acct=$(jq -r '.account // empty' "$body" 2>/dev/null || true)
31
+ if [[ "$acct" =~ ^[0-9]+$ ]]; then printf '%s' "$acct" > "$cache.account"; else rm -f "$cache.account"; fi
32
+ printf '%s' "$tok"
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+ /**
5
+ * One-shot backfill (#5254): closed `review-finding` issues still labelled `needs-validation`.
6
+ * workflow:merged -> validated; workflow:invalid or closed "not planned" -> false-positive; anything else is skipped.
7
+ * Dry run by default: prints the counts it would change; edits only with --apply.
8
+ * Usage: backfill-finding-labels.mjs --repo owner/name [--apply] [--limit N]
9
+ */
10
+ import { execFileSync } from "node:child_process";
11
+ import { fileURLToPath } from "node:url";
12
+
13
+ const names = (i) => (i.labels ?? []).map((l) => l?.name ?? l);
14
+
15
+ /** The label an old closed finding should carry, or null when its outcome is not derivable. */
16
+ export function targetLabel(issue) {
17
+ const l = names(issue);
18
+ if (l.includes("workflow:invalid") || issue.stateReason === "NOT_PLANNED") return "false-positive";
19
+ if (l.includes("workflow:merged")) return "validated";
20
+ return null;
21
+ }
22
+
23
+ export function backfill({ issues, apply = false, edit }) {
24
+ const counts = { validated: 0, "false-positive": 0, skipped: 0, failed: 0 };
25
+ const changes = [];
26
+ for (const i of issues) {
27
+ const t = targetLabel(i);
28
+ if (!t) { counts.skipped++; continue; }
29
+ if (apply) {
30
+ try { edit(i.number, t); } catch { counts.failed++; continue; }
31
+ }
32
+ counts[t]++; changes.push({ number: i.number, add: t });
33
+ }
34
+ return { mode: apply ? "apply" : "dry-run", counts, changes };
35
+ }
36
+
37
+ function main(argv) {
38
+ const get = (f) => { const k = argv.indexOf(f); return k >= 0 ? argv[k + 1] : null; };
39
+ const repo = get("--repo"), limit = get("--limit") ?? "1000", apply = argv.includes("--apply");
40
+ if (!repo) { console.error("usage: backfill-finding-labels.mjs --repo owner/name [--apply] [--limit N]"); return 2; }
41
+ const gh = (a) => execFileSync("gh", a, { encoding: "utf8" });
42
+ const issues = JSON.parse(gh(["issue", "list", "-R", repo, "--state", "closed", "--label", "review-finding", "--label", "needs-validation", "--limit", limit, "--json", "number,labels,stateReason"]) || "[]");
43
+ const edit = (n, add) => gh(["issue", "edit", String(n), "-R", repo, "--add-label", add, "--remove-label", "needs-validation"]);
44
+ const r = backfill({ issues, apply, edit });
45
+ const c = r.counts;
46
+ console.log(`${apply ? "applied" : "dry-run (pass --apply to change)"}: ${c.validated} -> validated, ${c["false-positive"]} -> false-positive, ${c.skipped} skipped${c.failed ? `, ${c.failed} failed` : ""}`);
47
+ return c.failed ? 1 : 0;
48
+ }
49
+
50
+ if (process.argv[1] === fileURLToPath(import.meta.url)) process.exit(main(process.argv.slice(2)));
@@ -0,0 +1,36 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ import { describe, it } from "node:test";
4
+ import assert from "node:assert/strict";
5
+ import { backfill, targetLabel } from "./backfill-finding-labels.mjs";
6
+
7
+ const issues = [
8
+ { number: 1, labels: [{ name: "workflow:merged" }] },
9
+ { number: 2, labels: [{ name: "workflow:invalid" }] },
10
+ { number: 3, labels: [], stateReason: "NOT_PLANNED" },
11
+ { number: 4, labels: [{ name: "workflow:merged" }, { name: "workflow:invalid" }] },
12
+ { number: 5, labels: [] },
13
+ ];
14
+
15
+ describe("backfill-finding-labels (#5254)", () => {
16
+ it("maps merged to validated, invalid / not planned to false-positive, else null", () => {
17
+ assert.deepEqual(issues.map(targetLabel), ["validated", "false-positive", "false-positive", "false-positive", null]);
18
+ });
19
+ it("dry-run reports counts and edits nothing", () => {
20
+ const calls = [];
21
+ const r = backfill({ issues, edit: (...a) => calls.push(a) });
22
+ assert.equal(r.mode, "dry-run");
23
+ assert.deepEqual(r.counts, { validated: 1, "false-positive": 3, skipped: 1, failed: 0 });
24
+ assert.deepEqual(calls, []);
25
+ });
26
+ it("--apply edits each mapped issue", () => {
27
+ const calls = [];
28
+ const r = backfill({ issues, apply: true, edit: (n, l) => calls.push([n, l]) });
29
+ assert.equal(r.mode, "apply");
30
+ assert.deepEqual(calls, [[1, "validated"], [2, "false-positive"], [3, "false-positive"], [4, "false-positive"]]);
31
+ });
32
+ it("a failed edit is counted, not reported as changed", () => {
33
+ const r = backfill({ issues: [issues[0]], apply: true, edit: () => { throw new Error("x"); } });
34
+ assert.deepEqual(r.counts, { validated: 0, "false-positive": 0, skipped: 0, failed: 1 });
35
+ });
36
+ });
@@ -41,9 +41,11 @@
41
41
  # I1 Issues stuck in workflow:investigating beyond threshold
42
42
  # I2 Issues stuck in workflow:building beyond threshold
43
43
  # I3 Issues stuck in workflow:in-review beyond threshold
44
- # I4 Issues in workflow:building with no FORGE:BUILDER annotation
44
+ # I4 Issues in workflow:building past the threshold with no builder evidence
45
+ # (FORGE:BUILDER, or the lean FORGE:CONTRACT / FORGE:PLAN / FORGE:WORK-ON)
45
46
  # I5 Issues in workflow:in-review with no open PR
46
- # I6 PRs open without a FORGE:CONTRACT or FORGE:BUILDER annotation
47
+ # I6 PRs open without a FORGE: marker that are not lane PRs (lean head branch or
48
+ # pipeline bot author) or dependency-bot PRs (dependabot, renovate)
47
49
  # I7 Orphaned worktree branches (local branches fix/* with no open PR)
48
50
  # I8 FORGE-referenced gists with public visibility (KNOWLEDGE_GIST, MILESTONE_INDEX,
49
51
  # PRIOR_GIST annotations in recent issue comments)
@@ -401,16 +403,21 @@ while IFS= read -r row; do
401
403
  done < <(echo "$ENGINE_ERRORS" | jq -c '.[]')
402
404
 
403
405
  # ---------------------------------------------------------------------------
404
- # I4: Issues in workflow:building with no FORGE:BUILDER annotation
406
+ # I4: Issues in workflow:building with no builder evidence
407
+ # Lean lanes never write FORGE:BUILDER; FORGE:CONTRACT / FORGE:PLAN / FORGE:WORK-ON
408
+ # count as evidence. Issues active within the stuck threshold are in flight, not broken.
405
409
  # ---------------------------------------------------------------------------
406
410
  while IFS= read -r row; do
407
411
  num=$(echo "$row" | jq -r '.number')
408
- # Check for FORGE:BUILDER annotation in issue comments.
412
+ if [ "$(hours_since "$(echo "$row" | jq -r '.updatedAt')")" -lt "$STUCK_HOURS" ]; then
413
+ continue
414
+ fi
415
+ # Check for builder evidence in issue comments.
409
416
  # Distinguish a confirmed-absent annotation from a gh API failure (rate limit,
410
417
  # network blip, auth issue) — an API failure must NOT be treated as confirmed-missing.
411
418
  if ! has_builder=$(gh issue view "$num" $GH_FLAG \
412
419
  --json comments \
413
- --jq '[.comments[].body | contains("FORGE:BUILDER")] | any' 2>"$GH_STDERR_TMP"); then
420
+ --jq '[.comments[].body | test("FORGE:(BUILDER|CONTRACT|PLAN|WORK-ON)")] | any' 2>"$GH_STDERR_TMP"); then
414
421
  echo "WARNING: gh issue view failed for #$num — I4 check inconclusive, skipping (not treated as missing): $(cat "$GH_STDERR_TMP")" >&2
415
422
  add_skip "I4" "$num" "gh issue view failed: $(bounded_reason "$(cat "$GH_STDERR_TMP")")"
416
423
  continue
@@ -458,7 +465,7 @@ done < <(echo "$IN_REVIEW" | jq -c '.[]')
458
465
  if ! OPEN_PRS=$(gh pr list $GH_FLAG \
459
466
  --state open \
460
467
  --limit 50 \
461
- --json number,title,body,createdAt 2>"$GH_STDERR_TMP"); then
468
+ --json number,title,body,createdAt,author,headRefName 2>"$GH_STDERR_TMP"); then
462
469
  echo "WARNING: gh pr list failed for open PRs — I6 check inconclusive, skipping (not treated as empty): $(cat "$GH_STDERR_TMP")" >&2
463
470
  add_skip "I6" "all" "gh pr list failed: $(bounded_reason "$(cat "$GH_STDERR_TMP")")"
464
471
  OPEN_PRS="[]"
@@ -474,6 +481,14 @@ while IFS= read -r row; do
474
481
  continue
475
482
  fi
476
483
  has_forge=$(echo "$body" | grep -c "FORGE:" || true)
484
+ # Lane PRs (lean head branch or pipeline bot app) and dependency-bot PRs are not hand-made.
485
+ head_ref=$(echo "$row" | jq -r '.headRefName // ""')
486
+ author=$(echo "$row" | jq -r '.author.login // ""')
487
+ if [[ "$head_ref" =~ ^(feat|fix)/issue-[0-9]+-lean$ ]] || \
488
+ [[ "$author" =~ ^(app/)?(rapiercraft-forgedock|forgedock)(\[bot\])?$ ]] || \
489
+ [[ "$author" =~ ^(app/)?(dependabot|renovate)(\[bot\])?$ ]]; then
490
+ continue
491
+ fi
477
492
  if [ "$has_forge" -eq 0 ]; then
478
493
  add_finding \
479
494
  "pr_missing_annotations" "warning" \