feat(code-review,gitea-pr): auto-publish PR review comments and enforce 3-exit finding triage gate

- skills/code-review/SKILL.md, references/axes.md, & references/finding-schema.md: ban agent self-assigned Accepted Trade-off, introduce Pending Triage verdict when untriaged Medium/Low findings exist, require 1 of 3 explicit exits (fix-in-branch, live-tracker Gitea issue/todo.txt, or owner-approved Accepted Trade-off) before recommending merge, and auto-publish --comment reviews on standalone open PR runs

- skills/gitea-pr/SKILL.md & references/pr-lifecycle.md: block Ready for Merge while any code-review finding remains Pending Triage

- tests/fixtures/test_skills_behavioral_contracts.py: assert auto-publish recipe, ban on self-assigned Accepted Trade-off, Pending Triage status, and live-tracker exit
This commit is contained in:
kiskaadee committed 2026-11-18 17:31:52 -05:00
1 parent 3bca64c258
commit d2ac585e3e
6 files changed
+52 -43

No files matched your search

+5 -6
View File
@@ -23,16 +23,15 @@ description: >-
- **Standards & Smells**: repository rules and Fowler smell diagnostics from [smell-heuristics](references/smell-heuristics.md) (evaluated as confirmed violations, potential smells, or contextual trade-offs). - **Standards & Smells**: repository rules and Fowler smell diagnostics from [smell-heuristics](references/smell-heuristics.md) (evaluated as confirmed violations, potential smells, or contextual trade-offs).
- **Seam & Test Integrity**: audit test diffs against [seams-and-mocking](../tdd/references/seams-and-mocking.md) and [test-quality](../tdd/references/test-quality.md) (public seams, injected timing callables, deterministic waits/teardown, non-tautological literals, boundary coverage, single-behavior naming). - **Seam & Test Integrity**: audit test diffs against [seams-and-mocking](../tdd/references/seams-and-mocking.md) and [test-quality](../tdd/references/test-quality.md) (public seams, injected timing callables, deterministic waits/teardown, non-tautological literals, boundary coverage, single-behavior naming).
- **Defensive Invariants**: system properties from [defensive-invariants](references/defensive-invariants.md) (trust boundaries, authority, consistency, failure semantics, resource limits). - **Defensive Invariants**: system properties from [defensive-invariants](references/defensive-invariants.md) (trust boundaries, authority, consistency, failure semantics, resource limits).
4. **Record structured findings.** Record every finding using the schema in [finding-schema](references/finding-schema.md) (`ID`, `Axis`, `Severity`, `Evidence`, `Invariant`, `Impact`, `Disposition`). A strong pass on one axis never compensates for a failure on another. 4. **Record structured findings.** Record every finding using the schema in [finding-schema](references/finding-schema.md) (`ID`, `Axis`, `Severity`, `Evidence`, `Invariant`, `Impact`, `Disposition`). Never self-assign `Accepted Trade-off` on a review pass: all valid findings start as `Confirmed` (or `Unresolved`); only the human owner may grant `Accepted Trade-off`. A strong pass on one axis never compensates for a failure on another.
5. **Aggregate without silent resolution.** When multiple reviewers or passes disagree, keep the disagreement visible under `Unresolved` until evidence settles it. 5. **Aggregate without silent resolution.** When multiple reviewers or passes disagree, keep the disagreement visible under `Unresolved` until evidence settles it.
6. **Emit executable runtime checks.** For stateful or high-risk paths that static inspection cannot prove, emit runnable fenced shell commands for `verify-slice` following the Step 6 contract in [finding-schema](references/finding-schema.md) (stating purpose, `local` vs. `live-infra` scope classification, explicit pass condition, and explicit failure signal). 6. **Emit executable runtime checks.** For stateful or high-risk paths that static inspection cannot prove, emit runnable fenced shell commands for `verify-slice` following the Step 6 contract in [finding-schema](references/finding-schema.md) (stating purpose, `local` vs. `live-infra` scope classification, explicit pass condition, and explicit failure signal).
7. **Present the review summary.** Group findings by axis and apply the decision matrix from [axes](references/axes.md): `Needs Rework` (confirmed defects require changes), `Blocked` (unresolved Critical/High risks or unestablished scope), or `Ready` (all four axes completed, no confirmed or unresolved blocking findings remain, and exact covered revisions plus working-tree state are recorded). Static review establishes static provenance for that diff only; never authorize release. 7. **Present the review summary.** Group findings by axis and apply the decision matrix from [axes](references/axes.md): `Needs Rework` (confirmed defects require changes), `Blocked` (unresolved Critical/High risks or unestablished scope), `Pending Triage` (only untriaged Medium/Low findings remain; never recommend merging until each takes one of the 3 triage exits in [finding-schema](references/finding-schema.md)), or `Ready` (all four axes completed and zero untriaged findings remain). Static review establishes static provenance for that diff only; never authorize release.
8. **Draft and publish the PR review block (standalone open PR only).** Keep the codebase strictly read-only (never edit repo files or mutate project boards). When invoked standalone on an open PR, draft `review-body.md` (and `inline-comments.json` when inline findings exist) per section 4 of [finding-schema](references/finding-schema.md), including the compact 4-axis pass block on clean `Ready` reviews. Show the draft for owner approval; once approved, publish one `--comment` review pinned with `--commit <reviewed-head-sha>` (passing `head_sha` and duplicate/pending guards, and creating any `issue`-routed follow-ups via `gitea-plan` first). Skip PR publishing when delegated inside `implement-slice`. 8. **Auto-publish the PR review block (standalone open PR only).** Keep the codebase strictly read-only (never edit repo files or mutate project boards). When invoked standalone on an open PR, draft `review-body.md` (and `inline-comments.json` when inline findings exist) per section 4 of [finding-schema](references/finding-schema.md), including the compact 4-axis pass block on clean `Ready` reviews, verify `head_sha` and duplicate/pending guards, and automatically publish one `--comment` review pinned with `--commit <reviewed-head-sha>` in the same turn. Skip PR publishing when delegated inside `implement-slice`.
## Your call ## Your call
- **Handling findings**: decide whether confirmed findings block merge, trigger a rework loop, or become tracked follow-up issues. - **Triaging findings (3 exits before merge)**: for each `Confirmed` or `Unresolved` finding, decide whether to (A) fix in-branch now, (B) promote to a live tracker (append/create Gitea issue or `todo.txt` via `tuxedo add`), or (C) grant permanent `Accepted Trade-off` (`record`).
- **Publishing findings**: approve the drafted review body, inline list, and follow-up routes before `code-review` posts to the PR. - **Adjudicating unresolved disagreements**: resolve conflicting reviewer perspectives.
- **Adjudicating unresolved disagreements**: resolve conflicting reviewer perspectives or accepted architectural trade-offs.
- **Authorizing release**: verification and review evidence inform decisions, but the human owner remains the sole release authority. - **Authorizing release**: verification and review evidence inform decisions, but the human owner remains the sole release authority.
## Done when ## Done when
+7 -9
View File
@@ -25,18 +25,16 @@ The distinction between recommendations is clear: `Needs Rework` means an establ
| Condition Observed | Final Recommendation | Action Required | | Condition Observed | Final Recommendation | Action Required |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| **Confirmed Critical or High** | `Needs Rework` | Fix confirmed defects before release review. | | **Confirmed Critical or High** | `Needs Rework` | Fix confirmed defects on the branch before release review. |
| **Confirmed Medium or Low requiring changes** | `Needs Rework` | Apply requested refactoring or test coverage fixes. | | **Confirmed or Unresolved Medium or Low (untriaged)** | `Pending Triage` | Do not recommend merge. Human owner chooses 1 of 3 exits per finding: (A) fix in-branch, (B) promote to live tracker (Gitea issue or `todo.txt`), or (C) grant permanent `Accepted Trade-off`. |
| **Unresolved Critical or High** | `Blocked` | Resolve missing evidence or escalate to human owner before proceeding. | | **Unresolved Critical or High** | `Blocked` | Resolve missing evidence or escalate to human owner before proceeding. |
| **Unresolved Medium or Low** | `Ready` (Conditional) | Human owner may adjudicate and accept trade-offs without blocking. |
| **Scope Inability or Missing Base Ref** | `Blocked` | Establish base commit and diff boundaries before reviewing. | | **Scope Inability or Missing Base Ref** | `Blocked` | Establish base commit and diff boundaries before reviewing. |
| **No Blocking Findings** | `Ready` | Implementation is structurally sound; proceed to `verify-slice` or release. | | **Zero Untriaged Findings** | `Ready` | All findings resolved, tracked in a live tracker, or explicitly granted `Accepted Trade-off` by the owner. |
### `Ready` Semantics and Downstream Reuse ### `Ready` vs. `Pending Triage` Semantics and Downstream Reuse
`Ready` means the review completed across all four axes, no confirmed or unresolved blocking findings remain (`Needs Rework` or `Blocked`), and the report explicitly identifies the base revision, head revision, and relevant working-tree state it covered. `Ready (Conditional)` qualifies as `Ready` for downstream handshake reuse only after the human owner adjudicates the open Medium/Low items (`Accepted Trade-off` or `Rejected`). A `Ready` review establishes static provenance for that exact diff; it does not substitute for runtime verification or authorize release. - **No agent self-adjudication**: Reviewer agents must never self-assign `Accepted Trade-off` on a review pass. Every valid observation (including `Low` nits) starts as `Confirmed` (or `Unresolved`), producing `Pending Triage` (or `Needs Rework`) rather than `Ready`.
- **`Pending Triage` blocks merge recommendations**: A review in `Pending Triage` qualifies as `Ready` for `gitea-pr` merge readiness only after every finding has taken one of the three explicit exits: (A) fixed in a new commit on the branch, (B) recorded in a live tracker that future agents read (an open Gitea issue or `todo.txt` via `tuxedo add`), or (C) explicitly approved by the human owner as a permanent `Accepted Trade-off` (no future action needed).
### Documented Trade-Off Acceptance - A `Ready` review establishes static provenance for that exact diff; it does not substitute for runtime verification or authorize release.
When a human owner accepts a documented trade-off for a Medium or Low finding, record the finding disposition as `Accepted Trade-off` (distinct from `Rejected`). This preserves audit traceability without misclassifying an intentional compromise as a disproven defect.
## 3. Risk-Scaled Execution Tiers ## 3. Risk-Scaled Execution Tiers
+25 -20
View File
@@ -18,14 +18,19 @@ Every reported finding must populate all seven fields:
| **Impact** | Concrete failure consequence if left unaddressed. | What breaks in production, concurrency, or maintenance (e.g., "Stored XSS when name contains `<script>`"). | | **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). | | **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 ## 2. Disposition, Severity, and the 3 Triage Exits
1. **Blocking status**: Only `Confirmed` findings (Critical, High, or changes-required Medium/Low) trigger a `Needs Rework` verdict. 1. **No agent self-assigned `Accepted Trade-off`**: On a review pass, every valid finding (even `Low` severity) must be logged as `Confirmed` (or `Unresolved`). Only the human owner may assign `Accepted Trade-off`.
2. **Unresolved findings**: `Unresolved Critical` or `Unresolved High` findings result in a `Blocked` verdict until resolved with evidence or owner adjudication. `Unresolved Medium` or `Low` findings can remain `Ready` if the owner accepts the trade-off. 2. **Verdict gating (`Needs Rework` vs. `Pending Triage` vs. `Ready`)**:
3. **Rejected vs. Accepted Trade-off**: - `Confirmed Critical` or `Confirmed High` -> `Needs Rework`.
- `Rejected`: The finding was an invalid concern or disproven by facts. - `Unresolved Critical` or `Unresolved High` -> `Blocked`.
- `Accepted Trade-off`: The finding identifies a genuine compromise where the owner explicitly accepts the local cost for an engineering reason. - Only `Confirmed` or `Unresolved` `Medium`/`Low` findings remain -> `Pending Triage` (never recommend merging while findings are untriaged).
Both remain in the ledger for full audit traceability. - Zero untriaged findings remain -> `Ready`.
3. **Three Mandatory Exits for `Pending Triage` Findings (No Silent Tech-Debt in Closed PRs)**:
Because future coding agents do not read closed PR comments, an unresolved problem cannot simply be left as a closed PR comment and forgotten. Prompt the human owner to choose one exit per finding before merge:
- **Exit A (`fix-in-branch`)**: Fix the finding on the PR branch now (`/tdd` or `/git-manager`) and re-verify.
- **Exit B (`live-tracker`)**: Defer the work by recording it in a live tracker that future agents read before starting the next slice: append to an upcoming Gitea issue (`gt issue edit <next>`), create a follow-up Gitea issue (`gt issue create` / `gitea-plan`), or add to `todo.txt` (`tuxedo add "(B) ..."`), and link that tracker ID on the PR.
- **Exit C (`record` / `Accepted Trade-off`, human-only)**: The human owner explicitly decides no future code change is desired and permanently accepts the trade-off as-is.
4. **Severity vs. confidence**: `Severity` describes potential impact, never reviewer confidence. A suspected high-impact flaw with incomplete evidence must be logged as `High` severity with `Unresolved` disposition, not downgraded to `Low`. 4. **Severity vs. confidence**: `Severity` describes potential impact, never reviewer confidence. A suspected high-impact flaw with incomplete evidence must be logged as `High` severity with `Unresolved` disposition, not downgraded to `Low`.
## 3. Review Report Layout ## 3. Review Report Layout
@@ -90,24 +95,24 @@ systemctl reload app-daemon.service && systemctl is-active --quiet app-daemon.se
``` ```
## Overall Recommendation ## Overall Recommendation
- **Status**: `Ready` | `Needs Rework` | `Blocked` - **Status**: `Ready` | `Pending Triage` | `Needs Rework` | `Blocked`
- **Next Action**: State whether to hand off to `verify-slice` for runtime verification, `diagnose` for root-cause fixes, `tdd` for Mode B test hardening, or `gitea-pr` for PR packaging/comment publishing. Static provenance and runtime verification remain distinct inputs; neither authorizes release on its own. - **Next Action**: When `Pending Triage` or `Needs Rework`, do not recommend merging; prompt the human owner to select Exit A (`fix-in-branch`), Exit B (`live-tracker`: Gitea issue or `todo.txt`), or Exit C (permanent `Accepted Trade-off`) for each finding. Static provenance and runtime verification remain distinct inputs; neither authorizes release on its own.
- **Suggested Next Step**: `/<skill> <args>` (emit one concrete command matched to the recommendation on standalone turns; omit when running inside a delegated subagent). - **Suggested Next Step**: `/<skill> <args>` (emit one concrete command matched to the recommendation on standalone turns; omit when running inside a delegated subagent).
``` ```
## 4. PR Review Block (Drafted and Published Here After Owner Approval) ## 4. PR Review Block (Drafted and Auto-Published Here on Standalone Open PRs)
`code-review` is strictly read-only regarding the codebase (never modifies repository files, commits, or Gitea project boards), and owns publishing comment-only PR reviews when invoked standalone on an open pull request. When running as a delegated subagent inside `implement-slice`, skip PR posting and return the compact report to the orchestrator. `code-review` is strictly read-only regarding the codebase (never modifies repository files, commits, or Gitea project boards), and automatically publishes a comment-only PR review in the same turn when invoked standalone on an open pull request. When running as a delegated subagent inside `implement-slice`, skip PR posting and return the compact report to the orchestrator.
### What goes in ### What goes in
- Every finding except `Rejected` ones (those stay in the local ledger only). - Every finding except `Rejected` ones (those stay in the local ledger only).
- Zero eligible findings on a `Ready` review: still draft `review-body.md` using the compact 4-axis pass template below (and omit `inline-comments.json`) so every reviewed PR head has an immutable, commit-pinned review record on Gitea. - Zero eligible findings on a `Ready` review: still draft and auto-publish `review-body.md` using the compact 4-axis pass template below (and omit `inline-comments.json`) so every reviewed PR head has an immutable, commit-pinned review record on Gitea.
### Per-finding routing (proposed here, decided by the owner) ### Per-finding routing (proposed here, decided by the owner before merge)
| Field | Values | Rule | | 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`. | | **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. | | **Follow-up** | `fix-in-branch`, `live-tracker`, or `record` | Proposed triage exit: `fix-in-branch` (quick fix on PR branch), `live-tracker` (defer to Gitea issue or `todo.txt` via `tuxedo add` before merge), or `record` (only after owner grants permanent `Accepted Trade-off`). A closed PR comment is never a task tracker. |
### Identity across re-reviews ### 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. 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.
@@ -117,13 +122,13 @@ Write both files to an untracked scratch location (never inside the repository t
`review-body.md`: `review-body.md`:
```markdown ```markdown
**Code review @ `<short-head-sha>`** (`<base-ref>`..`<head-ref>`): `<Ready | Needs Rework | Blocked>` **Code review @ `<short-head-sha>`** (`<base-ref>`..`<head-ref>`): `<Ready | Pending Triage | Needs Rework | Blocked>`
Covered state: `<Clean | fingerprint>`. Tier: `<tier>`. Static provenance only; merge authority stays with the owner. Covered state: `<Clean | fingerprint>`. Tier: `<tier>`. Static provenance only; merge authority stays with the owner.
| ID | Axis | Severity | Disposition | Placement | Follow-up | | ID | Axis | Severity | Disposition | Placement | Proposed Exit |
| :--- | :--- | :--- | :--- | :--- | :--- | | :--- | :--- | :--- | :--- | :--- | :--- |
| CR-01 | Standards & Smells | Low | Accepted Trade-off | inline | record | | CR-01 | Standards & Smells | Low | Confirmed | inline | fix-in-branch (or live-tracker) |
### Body-placed findings ### Body-placed findings
- **CR-02** (`<location>`): <invariant, impact, and suggested change>. - **CR-02** (`<location>`): <invariant, impact, and suggested change>.
@@ -158,8 +163,8 @@ No non-rejected findings.
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. 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.
### Publishing via `gt pr review` (After Owner Approval) ### Auto-Publishing via `gt pr review` (Standalone Open PR Runs)
If any finding is routed `follow-up: issue`, create the tracked issue via `gitea-plan` first so the comment links to it. Then verify guards and publish one comment-only review pinned to the reviewed commit: When invoked standalone on an open PR, verify guards and publish one comment-only review pinned to the reviewed commit in the same turn:
```bash ```bash
# 1. Staleness: the PR head must equal the reviewed head SHA. Mismatch: stop, re-run code-review. # 1. Staleness: the PR head must equal the reviewed head SHA. Mismatch: stop, re-run code-review.
@@ -169,7 +174,7 @@ gt pr view <number> --json head_sha -q .head_sha
# inline comments too) or if a review already exists for the reviewed SHA from this block. # inline comments too) or if a review already exists for the reviewed SHA from this block.
gt pr review list <number> --json id,state,commit,body gt pr review list <number> --json id,state,commit,body
# 3. After owner approval: one comment-only review, pinned to the reviewed commit. # 3. Auto-publish one comment-only review, pinned to the reviewed commit.
gt pr review <number> --comment --commit <reviewed-head-sha> \ gt pr review <number> --comment --commit <reviewed-head-sha> \
-F review-body.md --comments-file inline-comments.json --json id,url -F review-body.md --comments-file inline-comments.json --json id,url
+7 -4
View File
@@ -42,13 +42,16 @@ description: >-
`gt pr create -t "<title>" -B "<base>" -H "<branch>" -F <body-file> --json number,url`. `gt pr create -t "<title>" -B "<base>" -H "<branch>" -F <body-file> --json number,url`.
Pass `--draft` if work remains in progress. Extract verified PR number and URL, and ensure Pass `--draft` if work remains in progress. Extract verified PR number and URL, and ensure
the linked issue card is in `Review` (`Work in Progress -> Review`) on the project board. the linked issue card is in `Review` (`Work in Progress -> Review`) on the project board.
6. **Track review feedback, merge on owner approval, and move card `Review -> Completed`.** 6. **Track review feedback, enforce finding triage, merge on owner approval, and move card `Review -> Completed`.**
Inspect status checks (`gt pr checks <number>`), mergeability Inspect status checks (`gt pr checks <number>`), mergeability
(`gt pr view <number> --json mergeable,review_decision`), and review comments (`gt pr view <number> --json mergeable,review_decision`), and review comments
(`gt pr review comments <number>`). If the current PR head lacks a published `code-review` (`gt pr review comments <number>`). If the current PR head lacks a published `code-review`
comment, hand off to `code-review`. When checks pass and feedback is resolved, report comment, hand off to `code-review`. Never report `Ready for Merge` while any `code-review`
`Ready for Merge`. Once the owner explicitly authorizes merge, run `gt pr merge <number>` finding is `Pending Triage`: every finding must first be (A) fixed in-branch, (B) promoted
and move the linked issue card `Review -> Completed`. to a live tracker (Gitea issue or `todo.txt` via `tuxedo add`) and linked in a PR reply, or
(C) explicitly accepted by the owner as a permanent trade-off. When checks pass and all
findings are triaged/resolved, report `Ready for Merge`. Once the owner explicitly authorizes
merge, run `gt pr merge <number>` and move the linked issue card `Review -> Completed`.
## Your call ## Your call
- **PR title and description approval**: review and approve the draft PR content and issue linkage. - **PR title and description approval**: review and approve the draft PR content and issue linkage.
+1 -1
View File
@@ -13,7 +13,7 @@ Draft (WIP) -> Review -> Changes Requested -> Ready for Merge -> Merged
1. **Draft (WIP)**: PR opened early for visibility. In Gitea, prefixed with `WIP:` or flagged `--draft`. CI may run; reviews are informal. 1. **Draft (WIP)**: PR opened early for visibility. In Gitea, prefixed with `WIP:` or flagged `--draft`. CI may run; reviews are informal.
2. **Review**: Feature complete, working tree clean, static `code-review` and runtime `verify-slice` evidence packets attached. Ready for formal audit. 2. **Review**: Feature complete, working tree clean, static `code-review` and runtime `verify-slice` evidence packets attached. Ready for formal audit.
3. **Changes Requested**: Reviewer identified defects, missing tests, or security concerns. Agent addresses feedback, commits fixes via `git-manager`, and refreshes evidence. 3. **Changes Requested**: Reviewer identified defects, missing tests, or security concerns. Agent addresses feedback, commits fixes via `git-manager`, and refreshes evidence.
4. **Ready for Merge**: All review threads resolved, static review confirms `Ready`, runtime checks pass, and mergeability is green. Linked issue card sits in `Review`. 4. **Ready for Merge**: All review threads resolved, every `code-review` finding has completed one of the 3 mandatory exits (fixed in-branch, promoted to an open Gitea issue or `todo.txt` task with a linked reply, or explicitly granted permanent `Accepted Trade-off` by the human owner), static review confirms `Ready` on current `head_sha`, runtime checks pass, and mergeability is green. Linked issue card sits in `Review`.
5. **Completed (Merged)**: After explicit authorization by the human owner, `gitea-pr` merges the PR into the target base branch (`gt pr merge <number>`), verifies Gitea auto-closed the linked issue (`Closes #<id>`), and moves the issue card `Review -> Completed` on the project board. 5. **Completed (Merged)**: After explicit authorization by the human owner, `gitea-pr` merges the PR into the target base branch (`gt pr merge <number>`), verifies Gitea auto-closed the linked issue (`Closes #<id>`), and moves the issue card `Review -> Completed` on the project board.
--- ---
+7 -3
View File
@@ -366,16 +366,19 @@ class TestSkillsBehavioralContracts(unittest.TestCase):
self.assertEqual(initial_commit, current_commit) self.assertEqual(initial_commit, current_commit)
def test_review_comment_publishing_ownership(self): def test_review_comment_publishing_ownership(self):
"""Proves code-review stays codebase-read-only while owning guarded PR review publishing, and gitea-pr delegates it.""" """Proves code-review auto-publishes guarded PR reviews, bans self-assigned Accepted Trade-off, and gates gitea-pr merge on 3 triage exits."""
cr_dir = REPO_ROOT / "skills" / "code-review" cr_dir = REPO_ROOT / "skills" / "code-review"
cr_text = "\n".join(p.read_text() for p in cr_dir.rglob("*.md")) cr_text = "\n".join(p.read_text() for p in cr_dir.rglob("*.md"))
self.assertIn("review-body.md", cr_text) self.assertIn("review-body.md", cr_text)
self.assertIn("inline-comments.json", cr_text) self.assertIn("inline-comments.json", cr_text)
self.assertIn("No non-rejected findings.", cr_text) self.assertIn("No non-rejected findings.", cr_text)
self.assertIn("read-only regarding the codebase", cr_text) self.assertIn("read-only regarding the codebase", cr_text)
self.assertIn("Never self-assign `Accepted Trade-off`", cr_text)
self.assertIn("Pending Triage", cr_text)
self.assertIn("live-tracker", cr_text)
schema = (cr_dir / "references" / "finding-schema.md").read_text() schema = (cr_dir / "references" / "finding-schema.md").read_text()
publish = schema.split("### Publishing via `gt pr review`", 1)[1] publish = schema.split("### Auto-Publishing via `gt pr review`", 1)[1]
post_cmd = re.search(r"gt pr review <number> --comment[^\n]*\n[^\n]*", publish).group(0) post_cmd = re.search(r"gt pr review <number> --comment[^\n]*\n[^\n]*", publish).group(0)
# pinned to the reviewed commit, comment-only, no blanket confirmation # pinned to the reviewed commit, comment-only, no blanket confirmation
self.assertIn("--commit <reviewed-head-sha>", post_cmd) self.assertIn("--commit <reviewed-head-sha>", post_cmd)
@@ -385,9 +388,10 @@ class TestSkillsBehavioralContracts(unittest.TestCase):
self.assertLess(publish.index("head_sha"), publish.index(post_cmd)) self.assertLess(publish.index("head_sha"), publish.index(post_cmd))
self.assertLess(publish.index("gt pr review list"), publish.index(post_cmd)) self.assertLess(publish.index("gt pr review list"), publish.index(post_cmd))
# gitea-pr no longer owns PR review block publishing (no duplicate recipe) # gitea-pr gates Ready for Merge on Pending Triage resolution and no longer duplicates publish recipe
pr_skill = (REPO_ROOT / "skills" / "gitea-pr" / "SKILL.md").read_text() pr_skill = (REPO_ROOT / "skills" / "gitea-pr" / "SKILL.md").read_text()
pr_pulls = (REPO_ROOT / "skills" / "gitea-pr" / "references" / "gt-pulls.md").read_text() pr_pulls = (REPO_ROOT / "skills" / "gitea-pr" / "references" / "gt-pulls.md").read_text()
self.assertIn("Pending Triage", pr_skill)
self.assertNotIn("Publish review findings", pr_skill) self.assertNotIn("Publish review findings", pr_skill)
self.assertNotIn("### Publish a `code-review` Comment Block", pr_pulls) self.assertNotIn("### Publish a `code-review` Comment Block", pr_pulls)
self.assertIn("/orgs/<org>/projects/<project-id>/issues/<global-issue-id>/move", (REPO_ROOT / "skills" / "implement-slice" / "references" / "handoff-contracts.md").read_text()) self.assertIn("/orgs/<org>/projects/<project-id>/issues/<global-issue-id>/move", (REPO_ROOT / "skills" / "implement-slice" / "references" / "handoff-contracts.md").read_text())