diff --git a/skills/code-review/SKILL.md b/skills/code-review/SKILL.md index 2bc3c41..dca7574 100644 --- a/skills/code-review/SKILL.md +++ b/skills/code-review/SKILL.md @@ -6,127 +6,146 @@ license: Apache-2.0 (modified; see UPSTREAMS.json) # Code Review -Provide a high-signal code review for a pull request or set of pending changes. The goal is to surface only issues that are clearly real and actionable, while filtering out noise, nitpicks, and false positives. +Provide a high-signal review of one frozen change set. Surface real, actionable issues while making incomplete coverage visible instead of treating missing work as a clean result. -## When to use this skill +## Workflow -Trigger on phrases like "review this PR", "code review", "check my diff", "audit the pending changes on this branch", or when the user asks for a security/quality pass before merging. +Track scope discovery, detection, cross-checking, validation, and output in a todo list. Execute the following steps in order. -## High-level process +### 1. Freeze the scope -Follow these steps in order. Use OpenCode's parallel sub-task dispatch where the original Claude Code workflow used parallel agents. +Resolve review mode with this precedence: -### 1. Pre-flight check +1. An explicit PR URL or number selects PR mode. +2. An explicit commit range or path list selects range mode. +3. Otherwise select local mode and review all pending changes. -Before doing any review work, verify the PR (or change set) is worth reviewing. Skip the review and stop early if any of the following hold: +Do not mix modes or widen an explicit scope. -- The PR is closed -- The PR is a draft -- The change is trivial (single-line typo, formatting, automated dependency bump) and obviously correct -- A previous review by the agent already exists on this PR +#### PR mode -Use `gh pr view ` (or the local `git diff` for non-PR review) to gather state. +Run `gh pr view --json number,title,body,state,isDraft,baseRefName,baseRefOid,headRefOid,files`. Stop without reviewing a closed PR, a draft PR, or a change that is both trivial and obviously correct. -### 2. Identify project conventions +Pin `baseRefOid` and `headRefOid` from that response. Ensure those objects are available, compute the baseline with `git merge-base `, and diff that merge base against the pinned `headRefOid`. Never substitute `origin/HEAD`, a symbolic branch tip, or the current checkout for either pinned PR object. Record every file and status, including deletions and renames. -Build a list of all project-convention files relevant to the change: +#### Range mode -- The repository root `CLAUDE.md` / `AGENTS.md` (whichever exists) -- Any nested `CLAUDE.md` / `AGENTS.md` in directories containing modified files +Use the explicit baseline, implementation, and paths exactly as requested. For an explicit path list without commits, use `HEAD` as the baseline and the complete working tree as the implementation; include staged, unstaged, deleted, renamed, and untracked changes only for those paths. Do not add nearby files to the change set. -You only need the file paths at this stage, not the contents. +#### Local mode -### 3. Summarize the change +Set the baseline to `HEAD` and the implementation to the complete working tree. Use `git diff --find-renames HEAD` so staged and unstaged changes are represented together. Run `git ls-files --others --exclude-standard`, read every untracked file as an addition, and include it in the diff evidence. Record staged, unstaged, deleted, renamed, and untracked statuses. -Read `gh pr view --json title,body` and `gh pr diff` (or `git diff`) and produce a one-paragraph summary of what the PR is doing and why. This grounds the rest of the review. +#### Rules and manifest -### 4. Parallel issue detection (deep mode) +Discover repository-root and path-ancestor `AGENTS.md` and `CLAUDE.md` files. Read the applicable rules and map them to each changed path rather than applying unrelated nested rules. -Dispatch **seven independent reviewers** in parallel. Each returns a list of candidate issues, where each issue includes a description, a reason category, an initial confidence (0–100), and a one-sentence failure scenario explaining how this would manifest in practice. +Create a stable `SCOPE_ID` from the repository identity, mode, pinned baseline and implementation, and changed paths. Emit this frozen scope manifest before any dispatch: -- **Reviewer 1 + Reviewer 2 — Convention compliance.** Audit the diff against the relevant `CLAUDE.md` / `AGENTS.md` rules. Only consider rule files that apply to the file being reviewed (same path or ancestor directory). Quote the exact rule being violated. -- **Reviewer 3 — Diff-only bug scan.** Scan the diff for obvious bugs without reading surrounding files. Flag only clear issues that do not need unseen context. -- **Reviewer 4 — Deep-context bug scan.** Read the **full file(s)** for each changed function, not just the diff hunks. Trace data flow into and out of the changed code. Flag bugs that depend on context the diff alone does not show (e.g., callers that pass `None`, shared state mutated elsewhere, lock ordering across files). -- **Reviewer 5 — Concurrency, ordering & state.** Race conditions, time-of-check-time-of-use, cache invalidation, idempotency, retry safety, ordering guarantees. Especially important in PRs that touch caches, queues, locks, or any shared mutable state. -- **Reviewer 6 — Error handling & edge cases.** What happens on empty input, max input, partial failure, downstream errors, network timeouts, malformed data? Is failure logged, swallowed, or propagated? Are exceptions caught at the right layer? -- **Reviewer 7 — Test coverage gap.** What scenarios in the changed code are *not* covered by existing tests? List them concretely (no generic "needs more tests"). Especially flag changed branches with no test exercising them. +```text +SCOPE_ID: +MODE: pr | range | local +REPOSITORY_ROOT: +BASELINE: +IMPLEMENTATION: +DIFF_SOURCE: +CHANGED_PATHS_AND_STATUSES: +UNTRACKED_PATHS: +PR_NUMBER: +PR_TITLE: +PR_BODY: +PR_BASE_REF: +PR_BASE_SHA: +PR_HEAD_SHA: +RULES_BY_PATH: +``` -Each reviewer must receive the PR title, description, and the relevant project rules. Take the time to read the actual files; do not rely on the diff alone for reviewers 4–7. +Use empty PR fields outside PR mode. Summarize the intent and implementation only from this manifest and its pinned evidence. -**Critical: only HIGH-SIGNAL issues should be flagged.** Do flag: -- Code that will fail to compile or parse (syntax, type errors, missing imports) -- Code that will definitely produce wrong results regardless of inputs -- Clear, unambiguous convention violations (must quote the exact rule) -- Concrete edge cases that are reachable in production with a specific trigger -- Scope creep — code that adds abstractions, configurability, or features that do not trace to the change's stated goal +### 2. Detect candidates -Do NOT flag: -- Style or quality concerns that aren't in the project rules -- Potential issues that depend on specific runtime state or inputs -- Subjective suggestions -- Anything a linter would catch — you are not the linter -- Pre-existing issues -- Issues silenced via lint-ignore comments +Dispatch these seven independent detection roles in parallel when task dispatch is available: -When uncertain, do not flag. False positives erode trust. +- Two convention-compliance roles: compare each path only with its applicable rules and quote any violated rule. +- Diff-only bug scan: identify clear defects visible in the frozen diff. +- Deep-context bug scan: read each changed file and relevant callers, then trace changed data flow. +- Concurrency, ordering, and state scan: inspect races, invalidation, retry safety, idempotency, and shared mutable state. +- Error-handling and edge-case scan: inspect empty and boundary inputs, malformed data, partial failures, timeouts, and propagation. +- Test-coverage scan: identify concrete reachable changed behavior not exercised by tests. -### 5. Cross-check pass +Give every detection, cross-check, and validation child the frozen manifest, its role requirements, baseline evidence, and the assigned or known candidate IDs. Children may inspect context needed to evaluate a changed path, but cannot alter the frozen change set. -Before validation, dispatch a **second-pass reviewer** that explicitly tries to **break** each candidate finding: +Every child must return this envelope: -- For each candidate, ask: "What is the strongest argument this is *not* a real issue?" Write that argument out. -- If the strongest counter-argument holds, drop the finding before validation (it is likely a false positive). -- If the candidate survives, keep it for validation in step 6. +```text +STATUS: complete | partial | blocked +SCOPE_ID: +ROLE: +COVERAGE: +CANDIDATES: none | candidate records +ERRORS: none | details +``` -This pass exists to catch the failure mode of "looks suspicious but is actually correct in this codebase". +Each candidate record contains a stable ID, path and line, category, evidence, initial confidence from 0–100, a concrete reachable failure scenario, baseline comparison showing the issue is introduced by this scope, and the applicable rule when relevant. -### 6. Validate each surviving issue +Flag scope creep when the change adds abstractions, configurability, or features that do not trace to its stated goal. Do not flag style preferences, linter findings, pre-existing issues, or unsupported speculation. Do not flag speculative issues whose required runtime state or input is not shown to be reachable; concrete reachable runtime conditions are valid and required. -For each candidate from step 5, dispatch a validator sub-task. Give it the PR title, description, the exact issue description, and the failure scenario. Its job is to verify with high confidence that the issue is real: +### 3. Validate children and recover coverage -- For "variable not defined" → verify it is actually undefined in the relevant scope by reading the imports and surrounding code. -- For convention violations → verify the rule applies to the file's path and is genuinely violated. Quote the rule. -- For concurrency / state issues → trace the state through at least two callers and confirm the unsafe interleaving is reachable. -- For edge cases → identify the specific input or condition that triggers the failure. +Validate every child envelope against the frozen `SCOPE_ID`, assigned role, expected paths, required fields, and evidence before consuming it. Apply this recovery contract independently to detection, cross-check, and validation: -For each validated issue, the validator must produce: -1. A re-stated confidence score (0–100). Drop anything below 80. -2. A 1–3 line **reproduction scenario**: concrete inputs or conditions that trigger the failure. -3. A pointer to the smallest test that would have caught this (if no such test exists, that goes in the suggested fix). +1. Preserve valid partial output and identify only the missing work. +2. When a successful child response is incomplete or malformed, resume the same child exactly once with the missing fields and scope named. +3. For transient timeout, rate-limit, or transport dispatch failure, retry the task exactly once as a fresh dispatch. +4. For permission denial, unavailable tools, invalid requests, or deterministic failures, do not retry. +5. If parallel dispatch is unavailable, continue unfinished work with serial children. +6. If task dispatch is unavailable or denied, or bounded recovery is exhausted, complete the missing role checklist in the parent. -Drop any issue the validator cannot confirm with confidence ≥ 80 *and* a concrete reproduction scenario. +Never interpret failed, blank, malformed, or partial output as no findings. Preserve valid sibling results and cover only missing work locally. -### 7. Output +Maintain a detection coverage ledger keyed by detection role and expected path. Record status (`pending | complete | partial | blocked | local-fallback`), dispatch/resume/retry counts, evidence, missing coverage, and fallback result. -Output a summary to the terminal. For each validated issue include: +Maintain a candidate ledger keyed by stable candidate ID. Record source role, evidence, cross-check disposition, validation status, final confidence, and final disposition (`reported | rejected | unresolved`). Do not silently discard a candidate because a child failed. -- File path and line number -- Severity (Critical / Important) -- Confidence (0–100) -- One-sentence problem statement -- 1–3 line reproduction scenario from step 6 -- Concrete fix suggestion (or path to add a missing test) -- The exact rule or bug category +### 4. Cross-check and validate candidates -Group by severity. If no issues were validated, output exactly: `No issues found. Checked for bugs, edge cases, concurrency, and project-convention compliance.` +For each candidate, perform an adversarial cross-check using the same frozen manifest. State the strongest evidence that it is not a defect. Reject it only when that evidence holds; otherwise retain its stable ID for validation. -This review is expected to take multiple minutes when run on a non-trivial PR. Quality and concrete reproduction scenarios are the deliverable; if you find yourself finishing in seconds, you have skipped steps 4–6. +Validate each survivor against full-file context, relevant callers, baseline evidence, applicable rules, and its concrete reachable failure scenario. For concurrency issues, confirm a reachable interleaving; for edge cases, identify the triggering input; for undefined names, inspect imports and scope. Record the smallest regression test that would catch the defect. -### 8. Optional GitHub posting +The final reporting threshold is confidence ≥ 80. Reject candidates below the threshold or without a concrete reachable reproduction, and record that disposition in the candidate ledger. -If the user invoked the review with a `--comment` style instruction (i.e. "post the review on the PR"): +### 5. Gate and format output -- If no issues found, post the summary as a single PR comment via `gh pr comment` -- If issues found, post one inline comment per issue using the GitHub inline-comment API. Do not duplicate comments. Include a link to the relevant code with the format: - ``` - https://github.com///blob//#L-L - ``` - Always provide the full SHA (no shell substitution), include 1+ line of context above and below, and use `L-L` format. +For each reported finding provide path and line, Critical or Important severity, confidence, concise problem statement, concrete reproduction, fix direction or regression-test location, and rule or bug category. Findings come first and are grouped by severity. -For small, self-contained fixes, include a committable suggestion block. For larger fixes (6+ lines, multi-location, or structural), describe the issue and suggested fix without a suggestion block. Never post a committable suggestion unless committing it fixes the issue entirely. +Emit the exact no-issues sentence only when every detection role is complete and every candidate has a final disposition. Complete detection also requires every expected path to be covered for every applicable role, including parent-owned fallback work: + +`No issues found. Checked for bugs, edge cases, concurrency, and project-convention compliance.` + +Otherwise emit `Review incomplete` and report completed coverage, missing coverage, recovery attempts, validated findings, and unresolved candidates. Never emit a clean result when either ledger is incomplete. + +### 6. Post to GitHub only when requested + +Posting requires PR scope. If `--comment` or equivalent is requested without PR scope, report the missing target and do not post. Never post a clean summary for incomplete coverage. + +Use a marker tied to repository, PR, pinned head SHA, and either `summary` or a stable finding key: + +```html + +``` + +Determine the authenticated login, then query both issue comments and inline review comments with `gh api --paginate`. Match both the exact marker and authenticated author. For each intended comment: + +- If its marker exists and content is identical, do nothing. +- If its marker exists and content changed, `PATCH` that comment through its returned API URL. +- `POST only when` no exact authenticated-author marker exists. + +Post a complete clean result as one issue comment. Post findings as inline comments against the pinned head SHA, with a full-SHA code link and enough context to locate the line. Use a committable suggestion only when that suggestion fixes the entire issue. + +After an ambiguous posting failure, query both comment collections before retrying. If the marker now exists, follow the no-op or `PATCH` rule; otherwise retry the mutation once. This makes repeated review posting idempotent for one PR head while allowing a new head to receive a new review. ## Notes -- Use `gh` CLI for all GitHub interactions; do not use web fetch -- Keep a todo list for the steps above -- Cite each issue with a link when posting +- Use `gh` CLI for GitHub state and posting; do not use web fetch. +- A non-trivial review should not complete until every ledger entry reaches a final state. diff --git a/skills/code-reviewer/SKILL.md b/skills/code-reviewer/SKILL.md index bc2b65f..fc88702 100644 --- a/skills/code-reviewer/SKILL.md +++ b/skills/code-reviewer/SKILL.md @@ -6,109 +6,104 @@ license: Apache-2.0 (modified; see UPSTREAMS.json) # Code Reviewer -You are an expert code reviewer specializing in modern software development across multiple languages and frameworks. Your primary responsibility is to review code against project guidelines (typically `CLAUDE.md` or `AGENTS.md`) with high precision to minimize false positives. +Review the assigned change set with high precision. Read enough surrounding code to establish reachability and report only actionable defects introduced by the scope. -## Scope +## Scope modes -By default, review unstaged changes from `git diff`. The user may specify different files, a commit range, or a specific function to review. +### Standalone review -## Required reading depth +Honor an explicit file, function, or commit range. Without explicit scope, review all pending staged, unstaged, and untracked changes. Use the `HEAD` baseline, inspect the combined working-tree diff, list untracked paths, and read every untracked file as an addition. -Do not review from the diff alone. For each function or class touched by the change: +Freeze the baseline, implementation, changed paths and statuses, untracked paths, and applicable project rules before analysis. Do not silently narrow the review to one Git state. -1. Read the **entire file** containing it, not just the changed hunks. -2. Identify and read at least **one caller** of the changed code (search with grep / glob for call sites). -3. If the change touches shared state (caches, globals, locks, queues, modules with module-level data), trace at least one path that mutates and one path that reads that state. +### Dispatched handoff -This reading is the input to the analysis below. Skipping it is the most common cause of both false positives and missed bugs. +Treat a supplied scope manifest as authoritative. Do not rediscover or widen the change set. Compare the baseline and implementation supplied by the parent, and use its identifiers, role focus, exclusions, baseline evidence, candidate IDs, and completion criteria. -## Core review responsibilities +A feature-dev dispatch consumes the Phase 5 implementation baseline and implementation delta. Preserve its baseline commit, pre-existing change ledger, implementation commits, exact changed paths, and exact committed/staged/unstaged/untracked provenance. Review only the implementation attributable to that handoff. + +Return the exact response contract supplied by the parent. For feature-dev, start with `Status: complete | partial | blocked`, repeat `ASSIGNMENT_ID`, and report covered scope, uncovered scope, evidence, findings, and errors or blockers. For a code-review scope manifest, return: + +```text +STATUS: complete | partial | blocked +SCOPE_ID: +ROLE: +COVERAGE: +CANDIDATES: none | candidate records +ERRORS: none | details +``` + +Report partial or blocked rather than success whenever required coverage or evidence is missing. + +## Scope and reading ledger + +Maintain a scope/reading ledger for every changed path. Record provenance, applicable rules, changed functions or classes, full-file read status, callers read, shared-state paths traced, tests inspected, and uncovered work. A clean result requires every in-scope path to have complete required reading. + +For each changed function or class: + +1. Read the entire containing file, not only changed hunks. +2. Read at least one relevant caller or explain why no caller exists. +3. For shared state, trace at least one mutation path and one read path. +4. Compare behavior with the supplied baseline so pre-existing issues are excluded. + +## Four review categories ### Project-guidelines compliance -Verify adherence to explicit project rules: - -- Import patterns -- Framework conventions -- Language-specific style -- Function declarations -- Error handling and logging conventions -- Testing practices -- Platform compatibility -- Naming conventions +Apply only explicit `AGENTS.md` or `CLAUDE.md` rules governing the path. Quote the violated rule. ### Bug detection -Identify actual bugs that will impact functionality: - -- Logic errors -- Null / undefined handling -- Race conditions -- Memory leaks -- Security vulnerabilities -- Performance problems +Check logic, null handling, races, memory/resource lifetime, security, and material performance failures. ### Code quality -Evaluate significant issues: +Check significant duplication, missing critical error handling, accessibility failures, inadequate test coverage, and scope creep that does not trace to the change's goal. Do not report style preferences. -- Code duplication -- Missing critical error handling -- Accessibility problems -- Inadequate test coverage -- Scope creep — speculative abstractions, configurability, or features that do not trace to the change's goal +### Edge cases + +Check empty and boundary inputs, malformed data, downstream failure or timeout, partial success, ordering, idempotency, and cache invalidation. ## Multi-pass analysis -Do **two analysis passes**, not one. The first pass is broad; the second pass is adversarial. +### Pass 1: broad scan -### Pass 1 — Broad scan +Walk every ledger path through all four review categories. Create candidate records with stable IDs, evidence, baseline comparison, initial confidence, and a concrete reachable reproduction scenario. -Walk through every changed function and check it against the four review categories above (project-guidelines compliance, bug detection, code quality, edge cases). Produce a candidate list with initial confidence scores. +### Pass 2: adversarial scan -### Pass 2 — Adversarial / edge-case pass +For every changed function and every candidate, check: -For every candidate from pass 1, AND for every changed function regardless of whether it raised a flag in pass 1, ask the following questions explicitly. Each one should produce either a "no issue here" line or a new candidate. +- Empty, null, zero-length, maximum, and boundary inputs. +- Downstream failure, timeout, malformed response, or swallowed exception. +- Shared mutable state, races, ordering, retries, and idempotency. +- Cache keys or invalidation that can remain unchanged while values change. +- New branches without a regression test. +- The strongest evidence that each candidate is not a real issue. -- What happens with empty / `None` / zero-length input? -- What happens with the maximum input size or boundary value? -- What happens if a downstream call fails or times out? -- Is there shared mutable state? Can two callers race? -- Does the cache (or memoization, or singleton) invalidate on every relevant change, or only some? Could it serve a stale value? -- Is there a comparison or check that uses a length, count, or hash where the underlying values can change while preserving that key? (Common cache-invalidation bug pattern.) -- For each new branch, is there a test that exercises it? If not, that is a candidate. -- Could an exception silently swallow a real failure? - -For every candidate from either pass, write a one-sentence **reproduction scenario** that names a concrete input or condition triggering the failure. If you cannot write one, drop the candidate before scoring. +Drop a candidate if no concrete reachable input or condition can trigger it. Record why each dropped candidate was rejected rather than silently omitting it. ## Confidence scoring -Rate each potential issue on 0–100: +Score candidates from 0–100 based on direct evidence, reachability, baseline attribution, and impact: -- **0** — Not confident at all. False positive, or pre-existing. -- **25** — Somewhat confident. Might be real, might be a false positive. If stylistic and not in project rules, lower. -- **50** — Moderately confident. Real issue, but possibly a nitpick or rare in practice. Not very important relative to the rest of the changes. -- **75** — Highly confident. Verified twice. Likely to be hit in practice. The existing approach is insufficient. Important and impacts functionality, or directly mentioned in project guidelines. -- **100** — Absolutely certain. Confirmed this will happen frequently. Direct evidence. +- **0**: false positive or pre-existing. +- **25**: weak evidence or unsupported condition. +- **50**: plausible but not adequately verified. +- **75**: strong evidence, but below the reporting bar. +- **80**: final reporting threshold; report at or above this score only. +- **100**: direct evidence makes the failure certain. -**Only report issues with confidence ≥ 80.** Quality over quantity. +Quality takes precedence over quantity. Do not flag speculative failures whose required runtime state or input is not shown to be reachable. ## Output -Start by stating clearly what you are reviewing (files, scope, branch). +State the exact reviewed scope and its provenance. Put findings first, grouped by Critical then Important. For each finding include: -For each high-confidence issue, provide: +- Confidence, path, and line. +- Concise defect and bug category or governing rule. +- Concrete reachable reproduction scenario. +- Baseline evidence showing the scope introduced it. +- Fix direction and regression-test location. -- Clear description with confidence score -- File path and line number -- Specific project-guideline reference or bug explanation -- **Reproduction scenario** from the multi-pass analysis (concrete inputs or conditions that trigger the failure) -- Concrete fix suggestion (and where to add a test if none exists) - -Group issues by severity (Critical vs. Important). - -If no high-confidence issues exist, confirm the code meets standards with a brief summary that lists the four categories you checked and the multi-pass questions you asked. - -Structure the response for maximum actionability. The developer should know exactly what to fix and why. - -A thorough review of a non-trivial change set will take multiple minutes. If you finish in under a minute on a non-trivial PR, you have skipped the required reading depth or the multi-pass analysis. Do not rush. +If no finding reaches the threshold, emit a clean result only when the scope/reading ledger is complete. Otherwise report partial or blocked status with covered scope, missing coverage, preserved candidates, and errors. diff --git a/tests/code-review-contracts.test.mjs b/tests/code-review-contracts.test.mjs new file mode 100644 index 0000000..052a98b --- /dev/null +++ b/tests/code-review-contracts.test.mjs @@ -0,0 +1,59 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; + +const REPO = process.env.REPO || process.cwd(); +const read = (path) => readFileSync(join(REPO, path), "utf8"); +const review = read("skills/code-review/SKILL.md"); +const reviewer = read("skills/code-reviewer/SKILL.md"); + +test("code-review freezes complete PR and local scopes", () => { + assert.match(review, /MODE: pr \| range \| local/); + for (const field of ["SCOPE_ID", "REPOSITORY_ROOT", "BASELINE", "IMPLEMENTATION", "DIFF_SOURCE", "CHANGED_PATHS_AND_STATUSES", "UNTRACKED_PATHS", "RULES_BY_PATH"]) { + assert.ok(review.includes(field), `missing ${field}`); + } + for (const field of ["baseRefName", "baseRefOid", "headRefOid"]) assert.ok(review.includes(field)); + assert.match(review, /git diff --find-renames HEAD/); + assert.match(review, /git ls-files --others --exclude-standard/); + assert.doesNotMatch(review, /or the local `git diff`/); +}); + +test("code-review validates child output and bounds recovery", () => { + for (const field of ["STATUS:", "SCOPE_ID:", "ROLE:", "COVERAGE:", "CANDIDATES:", "ERRORS:"]) assert.ok(review.includes(field)); + assert.match(review, /validate every child/i); + assert.match(review, /resume the same .* exactly once/is); + assert.match(review, /transient .* retry .* exactly once/is); + assert.match(review, /permission denial.*do not retry/is); + assert.match(review, /parallel dispatch.*serial/is); + assert.match(review, /task dispatch.*denied.*parent/is); + assert.match(review, /never .*failed.*blank.*partial.*no findings/is); +}); + +test("code-review gates clean output on complete ledgers", () => { + assert.match(review, /detection coverage ledger/i); + assert.match(review, /candidate ledger/i); + assert.match(review, /Review incomplete/); + assert.match(review, /Emit the exact no-issues sentence only when every detection role is complete and every candidate has a final disposition\./); + assert.ok(review.includes("No issues found. Checked for bugs, edge cases, concurrency, and project-convention compliance.")); +}); + +test("code-review reconciles confidence, runtime inputs, and posting", () => { + assert.match(review, /final reporting threshold.*confidence\s*≥\s*80/i); + assert.match(review, /required runtime state or input is not shown to be reachable/i); + assert.ok(review.includes("