You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<pclass="pending-note"><strong>Content pending.</strong> Reserved for the chapter author. Fill the <code>data-slot="objective"</code> block in <code>content/chapters/continuous-review-and-testing.html</code>.</p>
102
+
<p>By the end of this chapter you can close the repository's <strong>quality loop</strong> with four more patterns — <strong>Review</strong>, <strong>Testing</strong>, <strong>CI-Doctor</strong>, and <strong>Refactoring</strong> — while keeping humans firmly on the merge decision. This is the second half of the Continuous-X library and the close of Part II.</p>
103
+
<p>Everything targets <strong>gh aw v0.81.6</strong>. The Repo Assistant graduates from tending the issue tracker to helping tend the <em>code</em>.</p>
<h2id="concept-closing-the-quality-loop"><aclass="anchor-link" href="#concept-closing-the-quality-loop" aria-label="Link to Concept: closing the quality loop section">Concept: closing the quality loop</a></h2>
<pclass="pending-note"><strong>Content pending.</strong> Reserved for the chapter author. Fill the <code>data-slot="concept-closing-the-quality-loop"</code> block in <code>content/chapters/continuous-review-and-testing.html</code>.</p>
109
+
<p>A repository's quality has a <strong>loop</strong>: code is proposed (a PR), reviewed, tested, merged, and — when something slips — fixed. Traditional CI automates the <em>deterministic</em> checks in that loop: does it compile, do the tests pass, does the linter approve. But the <em>judgement</em> steps — is this a good change? is this test worth adding? why did CI actually break? — still wait on a human.</p>
110
+
<p>Continuous-X patterns fill exactly those judgement gaps. Where <aclass="xref" href="continuous-triage-and-docs.html">Chapter 9</a> kept the <em>inbox</em> honest, these keep the <em>codebase</em> honest — each one a mini-product owning one link in the quality loop.</p>
111
+
112
+
<h3>The one rule that makes it safe: humans keep the merge</h3>
113
+
<p>The defining constraint of quality automation is that <strong>the agent proposes; a human disposes</strong>. A review agent <em>comments</em>, it doesn't approve. A test-improver <em>opens a draft PR</em>, it doesn't push to main. This isn't timidity — it's what lets you run these patterns at all. The agent accelerates the work up to the decision point and stops, leaving the irreversible call to a person. That's the human-in-the-loop principle, and it's why the safe-outputs boundary from <aclass="xref" href="safe-outputs.html">Chapter 6</a> matters most here.</p>
<pclass="callout-title">Measured: quality agents at scale</p>
116
+
<p>A single PR-review agent originating in <code>clash-verge-rev</code> has been cloned across <strong>215+ repositories</strong>; <code>backend.ai-webui</code> runs both a daily test-improver and an e2e-healer; <code>camunda</code> runs CI cost analysis. Quality is the category where Continuous-X adoption has spread fastest — because the human-keeps-the-merge rule makes it low-risk to try.</p>
<h2id="in-gh-aw-the-review-testing-ci-doctor-and-refactoring-recipes"><aclass="anchor-link" href="#in-gh-aw-the-review-testing-ci-doctor-and-refactoring-recipes" aria-label="Link to In gh-aw: the Review, Testing, CI-Doctor, and Refactoring recipes section">In gh-aw: the Review, Testing, CI-Doctor, and Refactoring recipes</a></h2>
<pclass="pending-note"><strong>Content pending.</strong> Reserved for the chapter author. Fill the <code>data-slot="in-gh-aw-the-review-testing-ci-doctor-and-refactoring-recipes"</code> block in <code>content/chapters/continuous-review-and-testing.html</code>.</p>
123
+
<p>Four patterns, each triggered by a different moment in the quality loop — and each writing through a safe output that stops short of merging.</p>
<tr><td><strong>Refactoring</strong></td><td><code>schedule</code> or command</td><td><code>create-pull-request</code> (draft)</td></tr>
133
+
</tbody>
134
+
</table>
135
+
136
+
<h3>Review: comment, never approve</h3>
137
+
<p>The Review pattern reads a PR diff and leaves inline feedback. The critical setting is <code>allowed-events: [COMMENT]</code>, which “prevents the agent from submitting APPROVE reviews regardless of what the agent attempts to output” — the docs explicitly recommend it as “the default for automated review workflows… without creating a persistent merge-blocking state” (<ahref="https://github.github.com/gh-aw/reference/safe-outputs/">Safe Outputs</a>). Infrastructure enforces the human-keeps-the-merge rule.</p>
138
+
139
+
<h3>CI-Doctor: react to the failure</h3>
140
+
<p>CI-Doctor is the elegant use of the <code>workflow_run</code> trigger from <aclass="xref" href="triggers.html">Chapter 4</a> with <strong>conclusion filtering</strong>: fire only when a named CI workflow finishes with <code>failure</code>, read the logs, and post a diagnosis. Because <code>workflow_run</code> is hardened against cross-repo abuse, this stays safe even on public repos.</p>
141
+
<figureclass="code">
142
+
<figcaption>The CI-Doctor trigger — wake only on a real CI failure</figcaption>
143
+
<pre><codeclass="language-yaml">on:
144
+
workflow_run:
145
+
workflows: ["CI"]
146
+
types: [completed]
147
+
conclusion: [failure] # only when CI actually broke
148
+
branches: [main]</code></pre>
149
+
</figure>
150
+
151
+
<h3>Testing & Refactoring: propose a diff</h3>
152
+
<p>Both run on a schedule, do focused work, and open a <strong>draft</strong><code>create-pull-request</code>. Testing adds coverage without touching production code; Refactoring makes a small, behavior-preserving cleanup. Draft PRs keep the human on the merge, exactly as in the Docs pattern.</p>
<pclass="callout-title">Builder detail: give the tester a scoped shell</p>
155
+
<p>A test-improver has to <em>run</em> the suite, so it needs <code>bash</code> — but scope it. Prefer an explicit allowlist like <code>bash: ["npm ci", "npm test", "npx jest"]</code> over the unrestricted <code>bash: [":*"]</code>, and add only the ecosystem the build needs to <code>network.allowed</code> (e.g. <code>node</code>). Capability where required, tight everywhere else.</p>
<h2id="when-to-automate-quality-and-where-humans-stay-in-the-loop"><aclass="anchor-link" href="#when-to-automate-quality-and-where-humans-stay-in-the-loop" aria-label="Link to When to automate quality (and where humans stay in the loop) section">When to automate quality (and where humans stay in the loop)</a></h2>
<pclass="pending-note"><strong>Content pending.</strong> Reserved for the chapter author. Fill the <code>data-slot="when-to-automate-quality-and-where-humans-stay-in-the-loop"</code> block in <code>content/chapters/continuous-review-and-testing.html</code>.</p>
162
+
<p>Quality patterns pay off when they act as a <strong>tireless first pass</strong> — catching the obvious before a human spends attention, never replacing the human's final say. The line to hold: <em>automate the noticing and the drafting; reserve the deciding.</em></p>
<tr><td>comment on a PR, flag risks</td><td>approve / request changes / merge</td></tr>
169
+
<tr><td>open a draft test or refactor PR</td><td>review and merge that PR</td></tr>
170
+
<tr><td>diagnose a CI failure, file an issue</td><td>decide the fix and ship it</td></tr>
171
+
</tbody>
172
+
</table>
173
+
174
+
<h3>When <em>not</em> to</h3>
175
+
<ul>
176
+
<li><strong>Don't let a review agent block merges.</strong> Auto <code>REQUEST_CHANGES</code> creates a persistent merge-blocking state from a fallible model. Keep <code>allowed-events: [COMMENT]</code> unless a human explicitly wants gating.</li>
177
+
<li><strong>Don't let the test-improver edit production code.</strong> Instruct it to add tests only; a PR that “fixes” code to make a test pass is the opposite of what you want.</li>
178
+
<li><strong>Don't auto-merge agent PRs.</strong> The draft PR is the human's decision point — automating the merge throws away the one safeguard that makes this safe.</li>
179
+
<li><strong>Don't run a refactoring agent on a repo without good tests.</strong> “Behavior-preserving” is only verifiable if the tests can prove it. Ship Testing before Refactoring.</li>
<h2id="worked-example-a-pr-review-plus-daily-test-improver-pair"><aclass="anchor-link" href="#worked-example-a-pr-review-plus-daily-test-improver-pair" aria-label="Link to Worked example: a PR-review plus daily-test-improver pair section">Worked example: a PR-review plus daily-test-improver pair</a></h2>
<pclass="pending-note"><strong>Content pending.</strong> Reserved for the chapter author. Fill the <code>data-slot="worked-example-a-pr-review-plus-daily-test-improver-pair"</code> block in <code>content/chapters/continuous-review-and-testing.html</code>.</p>
186
+
<p>Two complementary quality agents: one reacts to every PR, the other proactively strengthens the tests. Both compile cleanly, and both stop short of the merge.</p>
<p>The review agent holds <strong>read-only</strong> PR access and can only emit a <code>COMMENT</code> review — the <code>allowed-events</code> setting makes “never block a merge” an infrastructural guarantee, not a hope. The test-improver gets a <strong>scoped shell</strong> to run the suite and <code>edit</code> to write tests, but its sole output is a <strong>draft</strong> PR a human reviews. Both accelerate the work right up to the human's decision, then hand it over.</p>
221
+
222
+
<figureclass="code">
223
+
<figcaption>Verifying both examples</figcaption>
224
+
<pre><codeclass="language-text">gh aw compile examples/ch10/continuous-review.md
<asideclass="callout callout--note" aria-label="The safe output enforces the principle">
230
+
<pclass="callout-title">The principle is enforced, not just documented</p>
231
+
<p>Notice how <code>allowed-events: [COMMENT]</code> and <code>draft: true</code> turn “humans keep the merge” from a guideline into a compiled constraint. Even a hijacked agent can't approve a PR or merge one — the safe-outputs layer simply won't let the request through. That's the quality loop closed <em>safely</em>.</p>
<h2id="recap-and-what-s-next"><aclass="anchor-link" href="#recap-and-what-s-next" aria-label="Link to Recap & what's next section">Recap & what's next</a></h2>
<pclass="pending-note"><strong>Content pending.</strong> Reserved for the chapter author. Fill the <code>data-slot="recap-and-what-s-next"</code> block in <code>content/chapters/continuous-review-and-testing.html</code>.</p>
238
+
<p>You've closed the quality loop — and Part II:</p>
239
+
<ul>
240
+
<li>Quality automation fills the <strong>judgement gaps</strong> CI can't: is this change good, is this test worth adding, why did CI break.</li>
<li>The unbreakable rule is <strong>humans keep the merge</strong> — enforced by <code>allowed-events: [COMMENT]</code> and <code>draft: true</code>, not just by convention.</li>
243
+
<li>Automate the noticing and drafting; reserve the deciding. Ship Testing before Refactoring, and never auto-merge an agent's PR.</li>
244
+
</ul>
245
+
<p><strong>What's next.</strong> You now have a shelf of patterns — and you're about to notice how much they repeat. <strong>Part III</strong> scales from one repo to an org. <aclass="xref" href="reuse-and-memory.html">Chapter 11: Reuse & Memory</a> factors the shared parts into imported components and gives the Repo Assistant memory that persists across runs.</p>
0 commit comments