forgedock 1.0.22 → 1.1.2

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 (184) hide show
  1. package/README.md +255 -211
  2. package/bin/batch-runner.mjs +339 -0
  3. package/bin/cinema.mjs +320 -0
  4. package/bin/demo.mjs +92 -7
  5. package/bin/engine/phases.mjs +168 -0
  6. package/bin/engine/projector.mjs +32 -0
  7. package/bin/engine/reconcile.mjs +11 -0
  8. package/bin/engine/runlog.mjs +79 -0
  9. package/bin/engine/state.mjs +32 -0
  10. package/bin/engine-cli.mjs +222 -0
  11. package/bin/engine.mjs +138 -0
  12. package/bin/forgedock.mjs +896 -1540
  13. package/bin/hooks/interactive-engine.mjs +509 -0
  14. package/bin/hooks/pre-tool-use.mjs +498 -0
  15. package/bin/hooks/subagent-stop-enforce.mjs +197 -0
  16. package/bin/journey.mjs +841 -0
  17. package/bin/registry.mjs +139 -0
  18. package/bin/report.mjs +447 -0
  19. package/bin/runner.mjs +136 -20
  20. package/bin/settings-hook.mjs +346 -0
  21. package/bin/tui.mjs +6 -3
  22. package/commands/adopt.md +4 -1
  23. package/commands/analytics.md +4 -1
  24. package/commands/audit-agents.md +110 -27
  25. package/commands/audit.md +20 -1
  26. package/commands/autopilot.md +84 -12
  27. package/commands/changelog.md +2 -1
  28. package/commands/ci-audit.md +2 -1
  29. package/commands/cleanup.md +161 -1
  30. package/commands/compat-audit.md +2 -1
  31. package/commands/deploy-info.md +63 -4
  32. package/commands/design-bench.md +6 -1
  33. package/commands/design-render-critique-loop.md +2 -1
  34. package/commands/design.md +1 -0
  35. package/commands/diagnose.md +2 -1
  36. package/commands/explain.md +2 -1
  37. package/commands/forge-stats.md +122 -2
  38. package/commands/forgedock-init.md +1 -1
  39. package/commands/geo-audit.md +3 -0
  40. package/commands/incident-response.md +2 -1
  41. package/commands/issue.md +24 -3
  42. package/commands/milestone.md +77 -12
  43. package/commands/optimize.md +2 -1
  44. package/commands/orchestrate/config.md +67 -0
  45. package/commands/orchestrate/phase-1-resolve.md +159 -0
  46. package/commands/orchestrate/phase-2-triage.md +126 -0
  47. package/commands/orchestrate/phase-2.5-synthesis.md +156 -0
  48. package/commands/orchestrate/phase-3-dependency.md +591 -0
  49. package/commands/orchestrate/phase-4-execution.md +962 -0
  50. package/commands/orchestrate/phase-5-cleanup.md +47 -0
  51. package/commands/orchestrate/phase-6-report.md +198 -0
  52. package/commands/orchestrate/safety.md +62 -0
  53. package/commands/orchestrate.md +25 -2027
  54. package/commands/pipeline-health/config.md +34 -0
  55. package/commands/pipeline-health/phase-1-context.md +180 -0
  56. package/commands/pipeline-health/phase-2-metrics.md +1729 -0
  57. package/commands/pipeline-health/phase-3-analyze.md +204 -0
  58. package/commands/pipeline-health/phase-4-proposals.md +117 -0
  59. package/commands/pipeline-health/phase-5-report.md +284 -0
  60. package/commands/pipeline-health/phase-6-summary.md +52 -0
  61. package/commands/pipeline-health.md +25 -2401
  62. package/commands/pipeline-resume.md +24 -1
  63. package/commands/pipeline-status.md +65 -0
  64. package/commands/qa-sweep.md +4 -1
  65. package/commands/quality-gate.md +326 -42
  66. package/commands/replay.md +2 -1
  67. package/commands/review-pr-agents/api.md +135 -0
  68. package/commands/review-pr-agents/auth.md +137 -0
  69. package/commands/review-pr-agents/billing.md +101 -0
  70. package/commands/review-pr-agents/concurrency.md +145 -0
  71. package/commands/review-pr-agents/database.md +103 -0
  72. package/commands/review-pr-agents/frontend.md +89 -0
  73. package/commands/review-pr-agents/infra.md +385 -0
  74. package/commands/review-pr-agents/protocols.md +185 -0
  75. package/commands/review-pr-agents/scraper.md +185 -0
  76. package/commands/review-pr-agents/security.md +406 -0
  77. package/commands/review-pr-agents.md +45 -1722
  78. package/commands/review-pr-staging.md +196 -40
  79. package/commands/review-pr.md +612 -56
  80. package/commands/rollback.md +2 -1
  81. package/commands/scope.md +2 -1
  82. package/commands/security-audit.md +2 -1
  83. package/commands/signal-planner.md +623 -0
  84. package/commands/sync-ecosystem.md +1 -0
  85. package/commands/test-gate.md +17 -1
  86. package/commands/validate.md +2 -1
  87. package/commands/work-on/build/architect.md +28 -0
  88. package/commands/work-on/build/context.md +2 -0
  89. package/commands/work-on/build/implement.md +19 -5
  90. package/commands/work-on/build/validate.md +62 -6
  91. package/commands/work-on/build.md +187 -30
  92. package/commands/work-on/close.md +132 -5
  93. package/commands/work-on/decompose.md +19 -1
  94. package/commands/work-on/investigate.md +117 -2
  95. package/commands/work-on/review.md +48 -4
  96. package/commands/work-on-monolithic.md +8 -2
  97. package/commands/work-on.md +247 -7
  98. package/docs/BRAND.md +16 -5
  99. package/docs/CI.md +2 -2
  100. package/docs/CODEX.md +36 -1
  101. package/docs/CONFIG.md +44 -42
  102. package/docs/FORGE-PROTOCOL.md +15 -1064
  103. package/docs/anthropic-devrel-outreach.md +2 -2
  104. package/docs/articles/command-decomposition-token-savings.md +214 -0
  105. package/docs/articles/model-release-playbook.md +131 -0
  106. package/docs/articles/per-repo-adaptive-scripts-token-savings.md +27 -25
  107. package/docs/claude-breakpoints.json +75 -5
  108. package/docs/design/abc-benchmark.md +1 -1
  109. package/docs/design/design-spec-schema.md +1 -1
  110. package/docs/design/divergent-generation.md +1 -1
  111. package/docs/design/eval-gate-runbook.md +178 -0
  112. package/docs/design/show-hn-draft.md +26 -1
  113. package/docs/design/token-cost-baseline-1298.md +59 -0
  114. package/docs/eval/README.md +117 -0
  115. package/docs/eval/corpus/seed-v1.json +6 -0
  116. package/docs/eval/published/claude-sonnet-4-6-2026-07-04.json +33 -0
  117. package/docs/site/annotations-explained.md +24 -0
  118. package/docs/site/command-learning-path.md +51 -14
  119. package/docs/site/command-reference.md +339 -113
  120. package/docs/site/for-companies.md +95 -0
  121. package/docs/site/forge-annotation-protocol.md +12 -256
  122. package/docs/site/getting-started.md +58 -12
  123. package/docs/site/github-is-the-memory.md +113 -0
  124. package/docs/site/how-it-works.md +3 -13
  125. package/docs/site/index.md +10 -2
  126. package/docs/spec/eval-run-result.md +147 -0
  127. package/docs/spec/forge-protocol-v1.md +441 -18
  128. package/docs/spec/label-state-machine.md +55 -0
  129. package/docs/spec/review-protocol.md +158 -0
  130. package/docs/spec-graph-schema.md +28 -0
  131. package/docs/superpowers/plans/2026-07-03-cinematic-onboarding-tui.md +2339 -0
  132. package/docs/superpowers/plans/2026-07-03-durable-execution-engine.md +1223 -0
  133. package/docs/superpowers/specs/2026-07-03-cinematic-onboarding-tui-design.md +157 -0
  134. package/docs/superpowers/specs/2026-07-03-durable-execution-engine-design.md +194 -0
  135. package/docs/superpowers/specs/2026-07-04-economic-self-governance-design.md +181 -0
  136. package/docs/superpowers/specs/2026-07-04-provenance-trail-design.md +189 -0
  137. package/examples/forgedock-demo/README.md +41 -22
  138. package/examples/forgedock-demo/issues/06-bug-tags-type-validation.md +43 -0
  139. package/examples/forgedock-demo/issues/07-bug-negative-offset-pagination.md +42 -0
  140. package/examples/forgedock-demo/issues/08-bug-patch-mass-assignment.md +49 -0
  141. package/examples/forgedock-demo/issues/09-bug-count-injection.md +47 -0
  142. package/examples/forgedock-demo/issues/10-feature-sort-param.md +39 -0
  143. package/examples/forgedock-demo/issues/11-feature-patch-tags.md +37 -0
  144. package/examples/forgedock-demo/issues/12-feature-bulk-create.md +42 -0
  145. package/examples/forgedock-demo/issues/13-feature-archive-notes.md +46 -0
  146. package/examples/forgedock-demo/issues/14-refactor-extract-title-validation.md +41 -0
  147. package/examples/forgedock-demo/issues/15-refactor-protected-route-flag.md +43 -0
  148. package/examples/forgedock-demo/issues/16-refactor-extract-store.md +45 -0
  149. package/examples/forgedock-demo/issues/17-perf-tags-dedup-set.md +35 -0
  150. package/examples/forgedock-demo/issues/18-perf-remove-redundant-sort.md +37 -0
  151. package/examples/forgedock-demo/issues/19-docs-api-reference-full.md +53 -0
  152. package/examples/forgedock-demo/issues/20-docs-intentional-flaw-convention.md +46 -0
  153. package/examples/forgedock-demo/scripts/smoke.js +18 -1
  154. package/examples/forgedock-demo/src/db.js +36 -11
  155. package/examples/forgedock-demo/src/routes/notes.js +106 -9
  156. package/examples/forgedock-demo/src/server.js +4 -1
  157. package/package.json +12 -4
  158. package/packages/protocol/LICENSE +21 -0
  159. package/packages/protocol/src/cli.js +135 -0
  160. package/packages/protocol/src/emit.js +146 -0
  161. package/packages/protocol/src/index.js +43 -0
  162. package/packages/protocol/src/parse.js +229 -0
  163. package/packages/protocol/src/types.js +171 -0
  164. package/packages/protocol/src/validate.js +122 -0
  165. package/scripts/bench-topology-cost.mjs +372 -0
  166. package/scripts/check-command-docs-drift.sh +198 -0
  167. package/scripts/check-protocol-restatements.sh +176 -0
  168. package/scripts/check-registry/README.md +72 -0
  169. package/scripts/check-registry/manifest.json +6 -0
  170. package/scripts/code-index.sh +454 -0
  171. package/scripts/conformance-check.mjs +168 -0
  172. package/scripts/doctor-pipeline-state.sh +484 -0
  173. package/scripts/eval-gate-baseline.json +17 -0
  174. package/scripts/eval-gate-scorecard.mjs +242 -0
  175. package/scripts/eval-scorecard-aggregator.mjs +252 -0
  176. package/scripts/flaky-quarantine.sh +241 -0
  177. package/scripts/forge-annotation.sh +567 -0
  178. package/scripts/issue-dedup.sh +236 -0
  179. package/scripts/validate-annotation-node.mjs +233 -0
  180. package/scripts/verify-env-vars.sh +18 -2
  181. package/scripts/verify-host-headers.sh +4 -4
  182. package/scripts/verify-route-registration.sh +2 -2
  183. package/scripts/worktree-lifecycle.sh +202 -0
  184. package/templates/devdocs/agent/using-forgedock.md +14 -0
@@ -2,6 +2,7 @@
2
2
  description: Staging review mode — comprehensive review of staging branch before deploy to main
3
3
  argument-hint: [PR number or "staging"]
4
4
  allowed-tools: Task, Bash, Read, Grep, Glob, WebFetch
5
+ install: extras
5
6
  ---
6
7
  <!-- SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios -->
7
8
  <!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
@@ -12,7 +13,22 @@ allowed-tools: Task, Bash, Read, Grep, Glob, WebFetch
12
13
 
13
14
  Performs comprehensive review of `staging` before merging to `main`. Handles large diffs (1,000-10,000+ lines), diverse changes, deep analysis, and business impact assessment.
14
15
 
15
- **Agent model policy**: Default `model: "sonnet"`. If Sonnet is rate-limited, fall back to `model: "opus"`. User can override with `--model <name>`.
16
+ **Agent model policy**: `model: "sonnet"` (standard tier). Fallback: `model: "opus"` if rate-limited. User can override with `--model <name>`. Feature gate: pass `effort` in Task/Skill spawns only on Claude Code >= 2.1.154.
17
+ **NEVER use plan mode (EnterPlanMode).**
18
+ **NEVER use the Agent tool** — this spec uses `Task` for domain agent dispatch. The Agent tool bypasses the allowed-tools constraint declared in this spec's frontmatter and produces opaque output that cannot be structured into the review verdict.
19
+
20
+ <!-- FORGE:SPEC_LOADED — review-pr-staging.md loaded and active. Agent is bound by this spec. -->
21
+
22
+ ## Forbidden Tools Self-Check
23
+
24
+ **Before executing any phase**, verify you are NOT using any of these tools:
25
+
26
+ | Tool | Status | Reason |
27
+ |------|--------|--------|
28
+ | `Agent` | **FORBIDDEN** | Bypasses allowed-tools constraint; produces opaque output that cannot be structured into the review verdict |
29
+ | `EnterPlanMode` | **FORBIDDEN** | Breaks execution context; phases must be executed, not planned |
30
+
31
+ If you find yourself about to call `Agent(...)`, stop and use `Task(...)` instead.
16
32
 
17
33
  ---
18
34
 
@@ -36,59 +52,93 @@ All `$DEFAULT_BRANCH`, `$STAGING_BRANCH`, `$GATE_POSTURE`, and `$OVERRIDE_PHRASE
36
52
 
37
53
  ---
38
54
 
39
- ## Evidence-Based Review Protocol (ALL Agents)
55
+ ## Review Protocol Reference
40
56
 
41
- ### Diff-First Approach
42
- ```bash
43
- git fetch origin $DEFAULT_BRANCH $STAGING_BRANCH
44
- git diff origin/$DEFAULT_BRANCH...origin/$STAGING_BRANCH
45
- ```
57
+ <!-- FORGE:PROTOCOL_SOURCE — canonical definition lives in docs/spec/review-protocol.md -->
46
58
 
47
- ### Dynamic Exploration
48
- From each changed file, follow imports and function calls. Trace data flows across service boundaries (API → Redis → Worker).
59
+ The **Evidence-Based Review Protocol** and **Structured Findings Protocol** are defined in `docs/spec/review-protocol.md`. All agents spawned by this spec MUST follow both protocols as specified there. The full protocol text is embedded in `commands/review-pr-agents.md` for agent use.
49
60
 
50
- ### Validation Before Reporting
61
+ **Key protocol rules (summary — see `docs/spec/review-protocol.md` for the normative definition)**:
62
+ - Start from the diff. Follow imports. Trace data flows across service boundaries.
63
+ - Confidence levels: CONFIRMED (full code-path proof, P1) → LIKELY (pattern + caveat, P2) → POSSIBLE (advisory, P3) → UNFOUNDED (do not report)
64
+ - REPRODUCTION GATE: CONFIRMED requires a full code-path trace or concrete input demonstration
65
+ - Severity: runtime error → HIGH/CRITICAL; wrong data silently → HIGH; degraded perf → MEDIUM; cosmetic → LOW
66
+ - INTERACTION ANALYSIS: never dismiss as "pre-existing" without checking NEW code interactions
67
+ - FALSE POSITIVE PREVENTION: trace scope, types, callers before reporting
68
+ - Structured findings block MANDATORY at end of every agent comment
51
69
 
52
- | Confidence | Criteria | Action |
53
- |------------|----------|--------|
54
- | CONFIRMED | Traced full code path, found specific proof | Report as priority:P1 |
55
- | LIKELY | Pattern suggests issue, mitigations might exist | Report as priority:P2 |
56
- | POSSIBLE | Suspicious but couldn't trace fully | Report as priority:P3 |
57
- | UNFOUNDED | Found correct handling | Do NOT report |
70
+ ---
58
71
 
59
- ### Severity Decision Tree
60
- 1. Runtime error → HIGH/CRITICAL
61
- 2. Wrong data silently → HIGH
62
- 3. Degraded performance → MEDIUM
63
- 4. Genuinely cosmetic after tracing all consumers → LOW
72
+ ## Phase -1: Route Assertion
64
73
 
65
- ### Interaction Analysis
66
- NEVER dismiss as "pre-existing" without checking whether NEW code interacts with it to create a bug. List every new line referencing the pre-existing construct; if any would fail at runtime → CONFIRMED finding.
74
+ **This phase is MANDATORY and must execute before Phase 0A. No phase may be skipped.**
67
75
 
68
- ### False Positive Prevention
69
- - Variable scope: Read FULL function, count indentation, check if/else structure
70
- - Type mismatches: Trace variable to source, check naming
71
- - Missing functions: `grep -rn "functionName" .` — check re-exports/aliases
72
- - Unreachable code: Check all callers, dynamic dispatch, tests
73
- - Redundant imports: In Python, local `import X` makes X local for entire function scope — check for UnboundLocalError
76
+ **Idempotent re-review (merge-train aware)**: <!-- Added: forge#1328, extended: forge#1332 --> This spec is safe to invoke multiple times on the same PR. Each invocation posts a new `FORGE:REVIEW_ROUTE` marker with the current SHA — re-review passes are distinguished by SHA, not by PR number. When a staging→main deploy PR receives blocking findings and the fixes are pushed to the head branch, re-invoke this spec on the same PR number. Do NOT close the PR and create a new one.
74
77
 
75
- ### Report Format
76
- Every finding: File:Line, code snippet, evidence, confidence, files checked.
78
+ **Prior-finding awareness on re-entry**: On each re-invocation, load findings from prior review passes on the same PR before running any new checks. Previously-resolved findings (issues that are now closed or marked `false-positive`) are excluded from the current verdict to avoid re-surfacing already-fixed issues. Previously-unresolved findings (open issues from a prior pass) are carried forward as context so agents know what was previously flagged:
77
79
 
78
- ---
80
+ ```bash
81
+ # Load prior FORGE:REVIEW_ROUTE comments to detect re-entry
82
+ PRIOR_ROUTES=$(gh api repos/${GH_REPO}/issues/${PR_NUMBER}/comments \
83
+ --jq '[.[] | select(.body | test("FORGE:REVIEW_ROUTE")) | .body] | length' 2>/dev/null || echo 0)
79
84
 
80
- ## Structured Findings Protocol
85
+ IS_REENTRY=0
86
+ if [ "$PRIOR_ROUTES" -gt 0 ]; then
87
+ IS_REENTRY=1
88
+ echo "Re-entry detected: $PRIOR_ROUTES prior review pass(es) on PR #${PR_NUMBER}"
81
89
 
82
- Append at end of every agent comment:
83
- ```
84
- <!-- REVIEW-FINDINGS-START -->
85
- <!-- FINDING:PREFIX-N|CONFIDENCE|SEVERITY|file.py:line|One-line summary -->
86
- <!-- REVIEW-FINDINGS-END -->
90
+ # Load findings from prior passes that are still open
91
+ PRIOR_OPEN_FINDINGS=$(gh issue list ${GH_FLAG} \
92
+ --label "review-finding" \
93
+ --state open \
94
+ --search "PR #${PR_NUMBER}" \
95
+ --limit 50 \
96
+ --json number,title,labels \
97
+ --jq '.[] | " - #\(.number): \(.title)"' 2>/dev/null || true)
98
+
99
+ # Load findings that were resolved (closed) since the last pass
100
+ PRIOR_RESOLVED_FINDINGS=$(gh issue list ${GH_FLAG} \
101
+ --label "review-finding" \
102
+ --state closed \
103
+ --search "PR #${PR_NUMBER}" \
104
+ --limit 50 \
105
+ --json number,title \
106
+ --jq '.[] | " - #\(.number): \(.title)"' 2>/dev/null || true)
107
+
108
+ echo "Prior open findings (carry forward): $(echo "$PRIOR_OPEN_FINDINGS" | grep -c '.' || echo 0)"
109
+ echo "Prior resolved findings (exclude from verdict): $(echo "$PRIOR_RESOLVED_FINDINGS" | grep -c '.' || echo 0)"
110
+ fi
87
111
  ```
88
112
 
89
- Include ALL findings (CONFIRMED, LIKELY, POSSIBLE). One line per finding, sequential numbering.
113
+ Agents receive `$IS_REENTRY`, `$PRIOR_OPEN_FINDINGS`, and `$PRIOR_RESOLVED_FINDINGS` as context. They MUST NOT re-file issues that already exist in `$PRIOR_OPEN_FINDINGS` (dedup gate in Phase 7 covers this). Resolved findings do NOT contribute to the BLOCK verdict for the current pass.
90
114
 
91
- **Prefixes**: SEC, AUTH, BILL, CONC, SCRP, FE, API, DB, INFRA, BUG, QA, REG
115
+ Resolve the staging→main PR number and post a routing marker immediately. This creates an audit trail — if a staging→main PR has no `FORGE:REVIEW_ROUTE` comment after this command was invoked, the review was bypassed or never started.
116
+
117
+ ```bash
118
+ # Resolve PR_NUMBER from $ARGUMENTS
119
+ # $ARGUMENTS may be: a PR number, "staging", "feature", or "staging:feature"
120
+ if echo "$ARGUMENTS" | grep -qE '^[0-9]+$'; then
121
+ PR_NUMBER="$ARGUMENTS"
122
+ else
123
+ # Find the open staging→main PR
124
+ PR_NUMBER=$(gh pr list ${GH_FLAG} \
125
+ --head "$STAGING_BRANCH" \
126
+ --base "$DEFAULT_BRANCH" \
127
+ --state open \
128
+ --json number \
129
+ --jq '.[0].number' 2>/dev/null || echo "")
130
+ fi
131
+
132
+ REVIEW_SHA_STAGING=$(gh pr view "$PR_NUMBER" ${GH_FLAG} --json headRefOid --jq '.headRefOid' 2>/dev/null | cut -c1-7 || echo "n/a")
133
+
134
+ if [ -n "$PR_NUMBER" ]; then
135
+ gh pr comment "$PR_NUMBER" ${GH_FLAG} --body "<!-- FORGE:REVIEW_ROUTE mode=staging-deploy spec=review-pr-staging.md sha=${REVIEW_SHA_STAGING} -->"
136
+ else
137
+ echo "WARNING: Could not resolve staging→main PR number. FORGE:REVIEW_ROUTE marker not posted."
138
+ fi
139
+ ```
140
+
141
+ `$PR_NUMBER` is now set for all downstream phases that conditionally post gate comments to the PR.
92
142
 
93
143
  ---
94
144
 
@@ -190,11 +240,25 @@ To override (ship known issues with documented reason), post a comment starting
190
240
  fi
191
241
  else
192
242
  echo "✅ Open review-finding gate: PASSED — no open findings for PRs in this bundle."
243
+ # Post FORGE:GATE_PASS for symmetric observability — bypass is indistinguishable from clean pass without this
244
+ if [ -n "$PR_NUMBER" ]; then
245
+ gh pr comment "$PR_NUMBER" -R {GH_REPO} --body "<!-- FORGE:GATE_PASS -->
246
+ ## Deploy Gate: PASSED
247
+
248
+ **Gate**: open-review-finding check
249
+ **Result**: PASS — no open \`review-finding\` issues exist for PRs in this bundle.
250
+ **Bundle PRs**: ${ALL_PR_NUMBERS}
251
+ **Timestamp**: $(date -u +%Y-%m-%dT%H:%M:%SZ)
252
+
253
+ <!-- FORGE:GATE_PASS:TYPE=open-review-finding -->" 2>/dev/null || true
254
+ fi
193
255
  fi
194
256
  ```
195
257
 
196
258
  If the gate exits with `RESULT: BLOCK DEPLOY` → **STOP**. Do NOT proceed to Phase 0B or any downstream phases. A `<!-- FORGE:GATE_FAILURE -->` structured comment is automatically posted on the staging→main PR (if `$PR_NUMBER` is set) for pipeline-health tracking. Report the blocking finding list.
197
259
 
260
+ If the gate exits with `RESULT: PASS` → a `<!-- FORGE:GATE_PASS -->` structured comment is posted on the staging→main PR so that `/pipeline-health` can distinguish a clean gate from a silently skipped one. A PR with no gate comment at all indicates a gate bypass — not a clean pass.
261
+
198
262
  ---
199
263
 
200
264
  ## Phase 0B: Scope Analysis
@@ -308,6 +372,19 @@ For fixable failures: checkout staging, apply fix, verify locally, commit as `fi
308
372
 
309
373
  Launch agent (model: sonnet) to analyze all commits since last deploy. Categorize as: NEW FEATURE, ENHANCEMENT, BUG FIX, REFACTOR, SECURITY, PERFORMANCE, INFRASTRUCTURE, DEPENDENCY. Separate user-facing vs internal. Document breaking changes and required pre-deploy actions.
310
374
 
375
+ **MANDATORY — post findings as PR comment**: After completing analysis, the agent MUST post its full report directly to the PR:
376
+ ```bash
377
+ gh pr comment ${PR_NUMBER} -R ${GH_REPO} --body "<!-- FORGE:REVIEW-AGENT:material-change -->
378
+ ## Material Change Analysis
379
+
380
+ [full analysis report here]
381
+
382
+ <!-- REVIEW-FINDINGS-START -->
383
+ <!-- FINDING:... -->
384
+ <!-- REVIEW-FINDINGS-END -->"
385
+ ```
386
+ Include the structured `<!-- REVIEW-FINDINGS-START -->` block even if there are no findings (empty block). This ensures auditability even if the orchestrator crashes mid-review. <!-- Added: forge#1400 -->
387
+
311
388
  ---
312
389
 
313
390
  ## Phase 3: Bug Hunter Review (Per-Service)
@@ -322,24 +399,76 @@ Launch Bug Hunter agents for each service with changes:
322
399
 
323
400
  Each reads the service diff, hunts for bugs, traces context across imports, posts findings with structured block.
324
401
 
402
+ **MANDATORY — each Bug Hunter agent MUST post its findings directly to the PR immediately upon completion** (do not wait for the orchestrator to batch-post):
403
+ ```bash
404
+ gh pr comment ${PR_NUMBER} -R ${GH_REPO} --body "<!-- FORGE:REVIEW-AGENT:bug-hunter-{service} -->
405
+ ## Bug Hunter Review — {service}
406
+
407
+ [full findings here]
408
+
409
+ <!-- REVIEW-FINDINGS-START -->
410
+ <!-- FINDING:BUG-N|CONFIDENCE|SEVERITY|file:line|summary -->
411
+ <!-- REVIEW-FINDINGS-END -->"
412
+ ```
413
+ Where `{service}` is `api`, `worker`, or `web`. Post one comment per service agent. <!-- Added: forge#1400 -->
414
+
325
415
  ---
326
416
 
327
417
  ## Phase 4: Code Quality Review
328
418
 
329
419
  Agent hunts for: dead code, duplicate logic, complexity (>50 line functions), naming issues, missing abstractions, logging quality, magic numbers. Prefix: QA.
330
420
 
421
+ **MANDATORY — post findings as PR comment**: After completing analysis, the agent MUST post its full report directly to the PR:
422
+ ```bash
423
+ gh pr comment ${PR_NUMBER} -R ${GH_REPO} --body "<!-- FORGE:REVIEW-AGENT:code-quality -->
424
+ ## Code Quality Review
425
+
426
+ [full analysis here]
427
+
428
+ <!-- REVIEW-FINDINGS-START -->
429
+ <!-- FINDING:QA-N|CONFIDENCE|SEVERITY|file:line|summary -->
430
+ <!-- REVIEW-FINDINGS-END -->"
431
+ ```
432
+ <!-- Added: forge#1400 -->
433
+
331
434
  ---
332
435
 
333
436
  ## Phase 5: Security & Billing Deep Dive
334
437
 
335
438
  Read agent catalog from `.claude/commands/review-pr-agents.md`. Launch domain-specific agents based on which domains have changes. Substitute PR diff commands with staging diff commands. Agents: General Security (always), Auth, Billing, Concurrency, Scraper, API Design, Database, Infrastructure.
336
439
 
440
+ **MANDATORY — each domain agent MUST post its findings directly to the PR immediately upon completion** (not batched by the orchestrator):
441
+ ```bash
442
+ gh pr comment ${PR_NUMBER} -R ${GH_REPO} --body "<!-- FORGE:REVIEW-AGENT:{domain} -->
443
+ ## {Domain} Review
444
+
445
+ [full analysis here]
446
+
447
+ <!-- REVIEW-FINDINGS-START -->
448
+ <!-- FINDING:{PREFIX}-N|CONFIDENCE|SEVERITY|file:line|summary -->
449
+ <!-- REVIEW-FINDINGS-END -->"
450
+ ```
451
+ Where `{domain}` is `security`, `auth`, `billing`, `concurrency`, `scraper`, `api-design`, `database`, or `infrastructure`. Post one comment per domain agent. This ensures findings are posted even if the orchestrator crashes mid-review. <!-- Added: forge#1400 -->
452
+
337
453
  ---
338
454
 
339
455
  ## Phase 6: Regression Risk Assessment
340
456
 
341
457
  Agent maps dependencies, assesses integration points (service boundaries, env vars, Docker changes, workflow sibling drift between ci.yml and deploy-production.yml), evaluates rollback difficulty (easy/hard/destructive/state-dependent), checks test coverage. Posts risk matrix with rollback plan. Prefix: REG.
342
458
 
459
+ **MANDATORY — post findings as PR comment**: After completing analysis, the agent MUST post its full report directly to the PR:
460
+ ```bash
461
+ gh pr comment ${PR_NUMBER} -R ${GH_REPO} --body "<!-- FORGE:REVIEW-AGENT:regression-risk -->
462
+ ## Regression Risk Assessment
463
+
464
+ [full risk matrix and rollback plan here]
465
+
466
+ <!-- REVIEW-FINDINGS-START -->
467
+ <!-- FINDING:REG-N|CONFIDENCE|SEVERITY|file:line|summary -->
468
+ <!-- REVIEW-FINDINGS-END -->"
469
+ ```
470
+ <!-- Added: forge#1400 -->
471
+
343
472
  **Workflow sibling drift (MANDATORY)**: Deep-diff ci.yml and deploy-production.yml shared jobs. Compare PYTHONPATH, dependency install steps, step names. Pre-existing drift is invisible until deploy fails.
344
473
 
345
474
  **Database container restart risk (MANDATORY when `docker-compose*.yml` changes touch `postgres` or `redis` service)**: Any change to a stateful container's `command:`, `image:`, `volumes:`, or `environment:` forces container recreation on deploy. Auto-escalate to HIGH risk. Verify: `stop_grace_period` is sufficient (≥30s for PG), `full_page_writes = on`, `fsync = on`, no active long-running transactions will be interrupted. Recommend maintenance window — stateful container restarts must NOT happen as a side effect of routine deploys. A Postgres restart under active write load can corrupt btree indexes and bypass UNIQUE constraints. <!-- Added: forge#146 -->
@@ -387,6 +516,18 @@ case "$TEST_GATE_VERDICT" in
387
516
  PASS)
388
517
  echo "✅ Test gate: PASS — all test clusters passed. Deploy may proceed."
389
518
  TEST_GATE_REASON="PASS — all automated test clusters passed"
519
+ # Post FORGE:GATE_PASS for symmetric observability
520
+ if [ -n "$PR_NUMBER" ]; then
521
+ gh pr comment "$PR_NUMBER" ${GH_FLAG} --body "<!-- FORGE:GATE_PASS -->
522
+ ## Deploy Gate: PASSED
523
+
524
+ **Gate**: test-gate (runtime acceptance criteria)
525
+ **Result**: PASS — all test clusters passed. Deploy may proceed.
526
+ **Bundle PRs**: ${ALL_PR_NUMBERS}
527
+ **Timestamp**: $(date -u +%Y-%m-%dT%H:%M:%SZ)
528
+
529
+ <!-- FORGE:GATE_PASS:TYPE=test-gate|BUNDLE=$(echo $ALL_PR_NUMBERS | tr '\n' ' ' | xargs) -->" 2>/dev/null || true
530
+ fi
390
531
  ;;
391
532
 
392
533
  BLOCK)
@@ -587,3 +728,18 @@ If `TEST_GATE_VERDICT` is `BLOCK` and Phase 8 was reached (advisory posture or o
587
728
  > **Test Gate: BLOCK (override/advisory)** — Runtime failures were detected but deploy is proceeding. Reason: `${TEST_GATE_REASON}`. Filed `test-failure` issues track the failures.
588
729
 
589
730
  **CRITICAL**: This review NEVER merges staging → main. User makes deploy decision via GitHub web UI.
731
+
732
+ ---
733
+
734
+ ## Gate Marker Contract
735
+
736
+ Every completed staging review MUST leave one of the following structured markers on the PR:
737
+
738
+ | Marker | Meaning |
739
+ |--------|---------|
740
+ | `<!-- FORGE:GATE_PASS -->` | Gate ran and passed — deploy may proceed |
741
+ | `<!-- FORGE:GATE_FAILURE -->` | Gate ran and blocked — do NOT deploy |
742
+
743
+ **Absence of both markers = bypass detected.** The `.github/workflows/gate-marker-check.yml` workflow enforces this: it scans the PR timeline after review completes and fails CI if no gate marker is present within 30 minutes of the PR being opened/updated. A missing marker is treated as a deploy blocker — not a pass.
744
+
745
+ This symmetry closes the silent-bypass gap identified in forge#1387: previously, gate PASS posted nothing, making a clean pass indistinguishable from a skipped spec.