- code-review: new step 8 drafts review-body.md and inline-comments.json when the target is an open PR; finding-schema section 4 defines contents (all non-rejected findings), inline/body placement, record/issue follow-up routing, and SHA-scoped finding identity across re-reviews. code-review never posts, keeping it a read-only inspector. - gitea-pr: new step 6 publishes the block as one comment-only review pinned with --commit, after owner approval; gt-pulls recipe adds head_sha staleness, pending-review, and duplicate-SHA guards and forbids --approve, --request-changes, and --yes. Findings routed to an issue get one via gitea-plan first so the comment links to tracked work. - pr-lifecycle: triage keeps the published ID, disposition, and route labels. - tests: contract test asserting code-review has no posting commands and the gitea-pr publish recipe keeps its guards ahead of the post command. Motivated by lg-smtv-mcp PR #6, where nits were posted manually as a top-level comment on request.
9.6 KiB
Finding Schema and Review Output
Reference for code-review. Defines the required structure for reporting findings, ensuring every note is actionable, evidence-backed, and auditable.
Derived and adapted from Matt Pocock's review principles (github.com/mattpocock/skills), combining side-by-side axis reporting with strict defect provenance and disposition contracts.
1. Finding Record Schema
Every reported finding must populate all seven fields:
| Field | Description | Allowed Values / Format |
|---|---|---|
| ID | Stable identifier within this review. | CR-01, CR-02, etc. |
| Axis | The review axis that uncovered the finding. | Spec & Scope, Standards & Smells, Seam & Test Integrity, Defensive Invariants. |
| Severity | Potential failure consequence if the defect occurs. Describes impact, not reviewer confidence. | Critical (system security breach, data loss, fatal crash), High (broken invariant, missing spec requirement), Medium (code smell, fragile logic, missing edge test), Low (minor style inconsistency, naming). |
| Evidence | Exact location, change category, and reproducible behavior. | Distinguishes whether the code is committed, staged, or unstaged: e.g. src/view.ts:L45 (unstaged) with excerpt. |
| Invariant | The requirement, contract, or system property violated. | Clear statement of expectation (e.g., "Untrusted DOM values must be escaped before interpolation"). |
| Impact | Concrete failure consequence if left unaddressed. | What breaks in production, concurrency, or maintenance (e.g., "Stored XSS when name contains <script>"). |
| Disposition | Current evidentiary status of the finding. | Confirmed (proven defect backed by evidence), Rejected (disproven or false positive), Unresolved (open disagreement or missing evidence), Accepted Trade-off (conscious compromise approved by owner). |
2. Disposition and Severity Rules
- Blocking status: Only
Confirmedfindings (Critical, High, or changes-required Medium/Low) trigger aNeeds Reworkverdict. - Unresolved findings:
Unresolved CriticalorUnresolved Highfindings result in aBlockedverdict until resolved with evidence or owner adjudication.Unresolved MediumorLowfindings can remainReadyif the owner accepts the trade-off. - Rejected vs. Accepted Trade-off:
Rejected: The finding was an invalid concern or disproven by facts.Accepted Trade-off: The finding identifies a genuine compromise where the owner explicitly accepts the local cost for an engineering reason. Both remain in the ledger for full audit traceability.
- Severity vs. confidence:
Severitydescribes potential impact, never reviewer confidence. A suspected high-impact flaw with incomplete evidence must be logged asHighseverity withUnresolveddisposition, not downgraded toLow.
3. Review Report Layout
The final review summary presented to the user must follow this structure:
# Code Review Summary: <branch or commit range>
## Overview & Scope State
- **Base Commit**: `<base-ref>` (`<base-commit-sha>`) -> `<HEAD>` (`<head-commit-sha>`)
- **Covered Working-Tree State**: `Clean` | Staged, unstaged, and relevant untracked summary plus content fingerprint (covering staged changes, unstaged changes, and relevant untracked file contents so downstream tools can verify zero state drift)
- **Assigned Risk Tier**: `Lightweight` | `Standard` | `High-Assurance`
- **Execution Mode**: `Sequential` | `Independent Passes` | `Subagent Reviewers`
## Findings Ledger
### Confirmed Findings (Needs Rework)
| ID | Axis | Severity | State | Location | Invariant Violated | Impact |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| CR-01 | Defensive Invariants | Critical | Committed | `src/view.ts:L45` | Unescaped dynamic HTML sink | DOM XSS via attendee name |
### Unresolved Disagreements / Material Risks (Blocked if Critical/High)
| ID | Axis | Severity | Location | Competing Perspectives / Open Risk | Decision Needed |
| :--- | :--- | :--- | :--- | :--- | :--- |
| CR-02 | Standards & Smells | Medium | `src/api.ts:L110` | Reviewer A flags Primitive Obsession; Author notes single call site. | Accept string or introduce domain type |
### Accepted Trade-offs & Rejected Findings (Audit Traceability)
| ID | Axis | Disposition | Location | Rationale / Decision |
| :--- | :--- | :--- | :--- | :--- |
| CR-03 | Spec & Scope | Rejected | `src/main.ts:L12` | Suspected scope creep confirmed as required wiring for acceptance criterion 2. |
| CR-04 | Standards & Smells | Accepted Trade-off | `scripts/seed.py:L10` | Inlined script logic accepted to keep utility independent of core module. |
## Axis Breakdown
- **Spec & Scope**: Pass/Fail summary. Notes on scope containment and shared entrypoints across working-tree and commits.
- **Standards & Smells**: Adherence to repo conventions and Fowler smell diagnostics.
- **Seam & Test Integrity**: Evaluation of test boundaries, tautological assertions, and vertical slice evidence.
- **Defensive Invariants**: Status of trust boundaries, authority, consistency, failure semantics, and resource limits.
## Executable Runtime Checks for verify-slice
Every candidate runtime check must be directly consumable by `verify-slice` without reinterpreting narrative prose. Commands must assume execution from the repository root and use repository-relative paths (if an external path or environment dependency is genuinely required, declare that dependency and scope explicitly). Each entry requires:
- **Purpose** in the check header (`Check RV-XX: <purpose>`).
- **Scope**: `local` (safe workstation or isolated fixture execution) or `live-infra` (touches privileged permissions, host state, or external/production infrastructure; executable when the human owner explicitly authorizes the target environment and operation, otherwise recorded by `verify-slice` as `BLOCKED (out-of-bounds)`).
- **Pass Condition**: explicit observable output or state transition.
- **Failure Signal**: explicit contradiction condition.
- **Command**: copy-pasteable fenced shell block.
### Check RV-01: Out-of-band conflict handling on concurrent submission
- **Scope**: `local`
- **Pass Condition**: First request returns HTTP `200`; concurrent duplicate returns HTTP `409` with JSON code `conflict` and persisted count increments by `1`.
- **Failure Signal**: Duplicate returns `200` or `500`, unhandled traceback, or persisted count increments by `2`.
```sh
./scripts/test-concurrency-check.sh --endpoint /api/check-in
Check RV-02: Privileged service reload and health verification
- Scope:
live-infra - Pass Condition: Target service reloads cleanly and health endpoint returns
200 OK. - Failure Signal: Non-zero exit status, permission refusal, or failed unit healthcheck.
systemctl reload app-daemon.service && systemctl is-active --quiet app-daemon.service
Overall Recommendation
- Status:
Ready|Needs Rework|Blocked - Next Action: State whether to hand off to
verify-slicefor runtime verification,diagnosefor root-cause fixes, or present to human owner for adjudication. Static provenance and runtime verification remain distinct inputs; neither authorizes release on its own.
## 4. PR Comment Block (Drafted Here, Published by `gitea-pr`)
When the review target is an open pull request, `code-review` also drafts a PR comment block so the findings stay attached to the change they describe. `code-review` never posts it: it hands the block to `gitea-pr`, which publishes it after the human owner approves.
### What goes in
- Every finding except `Rejected` ones (those stay in the local ledger only).
- Zero eligible findings: draft nothing. A clean review is not posted unless the owner asks.
### Per-finding routing (proposed here, decided by the owner)
| Field | Values | Rule |
| :--- | :--- | :--- |
| **Placement** | `inline` or `body` | `inline` only when the location is a committed line inside a diff hunk at the reviewed head SHA. Unstaged, staged, file-level, or cross-cutting findings go in `body`. |
| **Follow-up** | `record` or `issue` | `record`: the comment is the whole record (accepted nit, trade-off). `issue`: the owner intends to fix it later, so it needs a tracked issue (created via `gitea-plan`) and the comment links to it. A PR comment is a record, not a task tracker. |
### Identity across re-reviews
Finding IDs (`CR-01`) are only unique within one review. The block header names the reviewed head SHA, and any cross-review reference uses `<short-sha>/CR-01`. `gitea-pr` uses the header SHA to avoid posting the same review twice.
### Files
Write both files to an untracked scratch location (never inside the repository tree):
`review-body.md`:
```markdown
**Code review @ `<short-head-sha>`** (`<base-ref>`..`<head-ref>`): `<Ready | Needs Rework | Blocked>`
Covered state: `<Clean | fingerprint>`. Tier: `<tier>`. Static provenance only; merge authority stays with the owner.
| ID | Axis | Severity | Disposition | Placement | Follow-up |
| :--- | :--- | :--- | :--- | :--- | :--- |
| CR-01 | Standards & Smells | Low | Accepted Trade-off | inline | record |
### Body-placed findings
- **CR-02** (`<location>`): <invariant, impact, and suggested change>.
inline-comments.json (the gt pr review --comments-file format; new_position is the line number in the new version of the file and must fall inside a diff hunk):
[
{
"path": "src/pkg/config.py",
"new_position": 40,
"body": "**CR-01** (Low, Accepted Trade-off, record): <invariant and impact>. <Suggested change>."
}
]
Every inline entry also appears in the body table, so the record stays complete if inline placement is rejected and the entry moves to the body.