refactor(code-review,gitea-pr): move guarded PR review publishing to code-review and document org board moves

- skills/code-review/SKILL.md & references/finding-schema.md: keep code-review strictly read-only regarding the codebase while owning owner-approved, commit-pinned --comment PR review publishing (with head_sha and duplicate/pending guards)

- skills/gitea-pr/SKILL.md & references/gt-pulls.md: delegate PR review publishing to code-review, remove duplicate recipe, and ensure Suggested Next Step emits when CI is pending

- skills/implement-slice/references/handoff-contracts.md: document /orgs/<org>/projects/<project-id>/issues/<global-issue-id>/move alongside repo-scoped board moves

- tests/fixtures/test_skills_behavioral_contracts.py: update test_review_comment_publishing_ownership for new boundary
This commit is contained in:
kiskaadee committed 2026-11-18 16:44:16 -05:00
1 parent a42120b1aa
commit b2146510af
6 files changed
+49 -54

No files matched your search

+2 -2
View File
@@ -27,11 +27,11 @@ description: >-
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).
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.
8. **Draft the PR comment block.** When the target is an open pull request, 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. Never post to Gitea yourself: hand the block to `gitea-pr`.
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`.
## Your call
- **Handling findings**: decide whether confirmed findings block merge, trigger a rework loop, or become tracked follow-up issues.
- **Publishing findings**: decide whether the PR comment block is posted, and confirm each finding's placement and follow-up route.
- **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 or accepted architectural trade-offs.
- **Authorizing release**: verification and review evidence inform decisions, but the human owner remains the sole release authority.
@@ -95,9 +95,9 @@ systemctl reload app-daemon.service && systemctl is-active --quiet app-daemon.se
- **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 Comment Block (Drafted Here, Published by `gitea-pr`)
## 4. PR Review Block (Drafted and Published Here After Owner Approval)
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 and never mutates Gitea project boards: it hands the block to `gitea-pr` (or `implement-slice`), which publishes the review and ensures the issue card sits in `Review` when the verdict is `Ready`.
`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.
### What goes in
- Every finding except `Rejected` ones (those stay in the local ledger only).
@@ -157,3 +157,26 @@ 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.
### Publishing via `gt pr review` (After Owner Approval)
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:
```bash
# 1. Staleness: the PR head must equal the reviewed head SHA. Mismatch: stop, re-run code-review.
gt pr view <number> --json head_sha -q .head_sha
# 2. Duplicates and pending state: stop if any review is PENDING (posting would publish its
# 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
# 3. After owner approval: one comment-only review, pinned to the reviewed commit.
gt pr review <number> --comment --commit <reviewed-head-sha> \
-F review-body.md --comments-file inline-comments.json --json id,url
# Body-only block (no inline entries): omit --comments-file.
```
- Never pass `--approve` or `--request-changes`: the verdict in the body is informational, and merge authority stays with the owner (Gitea also refuses approval on your own PR).
- Never pass `--yes`: it exists to publish a pending review, which step 2 already rules out.
- If Gitea rejects an inline entry (line outside a diff hunk), confirm with step 2 that no review was created, move that entry into the body, and retry once.
- Record the returned review `id` and `url`. Later fixes use `gt pr review reply` with `Fixed in <sha>` and `gt pr review resolve` via `gitea-pr`.
+9 -17
View File
@@ -13,8 +13,7 @@ description: >-
- Opening or updating a pull request on Gitea after implementing an issue or feature.
- Synthesizing static code review and runtime verification evidence into a reviewable PR.
- Tracking review comments, requested changes, and CI checks toward merge readiness.
- Publishing a `code-review` PR comment block (findings and nits) onto an open pull request.
- Not for static code inspection: use `code-review`.
- Not for static code inspection or publishing PR review blocks: use `code-review`.
- Not for runtime behavioral verification: use `verify-slice`.
- Not for branch creation, committing, rebasing, or local history integration: use `git-manager`.
@@ -43,22 +42,16 @@ description: >-
`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
the linked issue card is in `Review` (`Work in Progress -> Review`) on the project board.
6. **Publish review findings (when a `code-review` comment block exists).** Follow
[references/gt-pulls.md](references/gt-pulls.md) section 3: confirm the remote PR head equals
the reviewed head SHA (else stop and re-run `code-review`), confirm no pending review and no
prior review for that SHA exists, show the body and inline list for approval, then post one
`--comment` review pinned with `--commit`. Never `--approve` or `--request-changes`. Findings
routed `issue` get their issue (via `gitea-plan`) before posting so the comment links to it.
7. **Track review feedback, merge on owner approval, and move card `Review -> Completed`.**
6. **Track review feedback, merge on owner approval, and move card `Review -> Completed`.**
Inspect status checks (`gt pr checks <number>`), mergeability
(`gt pr view <number> --json mergeable,review_decision`), and review comments
(`gt pr review comments <number>`). When all checks pass and review feedback is resolved,
report `Ready for Merge`. Never merge automatically: once the human owner explicitly
authorizes merge, run `gt pr merge <number>` and move the linked issue card `Review -> Completed`.
(`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
`Ready for Merge`. Once the owner explicitly authorizes merge, run `gt pr merge <number>`
and move the linked issue card `Review -> Completed`.
## Your call
- **PR title and description approval**: review and approve the draft PR content and issue linkage.
- **Publishing review findings**: approve the comment block and each finding's placement and follow-up route before it is posted.
- **Review feedback triage**: decide how to address review comments (rework, clarification, deferral).
- **Merge and release authorization**: decide when to merge the PR into the target base branch.
@@ -67,10 +60,9 @@ description: >-
review and mergeability status is reported to the user.
## Hands off to
- `code-review`: if review packet is missing/stale (`Suggested Next Step: /code-review <base>..HEAD`).
- `verify-slice`: if runtime QA packet is missing/stale (`Suggested Next Step: /verify-slice`).
- `gitea-plan`: to create follow-up issues routed `issue` (`Suggested Next Step: /gitea-plan`).
- `code-review`: if the PR head lacks a static review comment or the diff changed (`Suggested Next Step: /code-review <pr-number>`).
- `verify-slice`: if new code requires runtime verification (`Suggested Next Step: /verify-slice`).
- `reconcile-docs`: after merge when docs/milestones shift (`Suggested Next Step: /reconcile-docs`).
- `implement-slice`: after merge when next issue is queued (`Suggested Next Step: /implement-slice #<next-issue>`).
- `git-manager`: to commit review fixes, rebase, or update against base.
- Emit one outcome-matched `Suggested Next Step` per [skeleton](../build-skill/references/skeleton.md).
- Emit one outcome-matched `Suggested Next Step` on every standalone turn (including when CI is pending after PR creation: `/code-review <pr-number>` or `/gitea-pr <pr-number>`) per [skeleton](../build-skill/references/skeleton.md).
+1 -22
View File
@@ -86,28 +86,7 @@ gt pr review resolve <comment-id>
gt pr review unresolve <comment-id>
```
### Publish a `code-review` Comment Block
Input: `review-body.md` and `inline-comments.json` drafted by `code-review` (section 4 of its `finding-schema.md`), plus the reviewed head SHA from the block header.
```bash
# 1. Staleness: the PR head must equal the reviewed head SHA. Mismatch: stop, re-run code-review.
gt pr view <number> --json head_sha -q .head_sha
# 2. Duplicates and pending state: stop if any review is PENDING (posting would publish its
# 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
# 3. After owner approval: one comment-only review, pinned to the reviewed commit.
gt pr review <number> --comment --commit <reviewed-head-sha> \
-F review-body.md --comments-file inline-comments.json --json id,url
# Body-only block (no inline entries): omit --comments-file.
```
- Never pass `--approve` or `--request-changes`: the verdict in the body is informational, and merge authority stays with the owner (Gitea also refuses approval on your own PR).
- Never pass `--yes`: it exists to publish a pending review, which step 2 already rules out.
- If Gitea rejects an inline entry (line outside a diff hunk), confirm with step 2 that no review was created, move that entry into the body, and retry once.
- Record the returned review `id` and `url`. Later fixes use `gt pr review reply` with `Fixed in <sha>` and `gt pr review resolve`, per the triage workflow in `pr-lifecycle.md`.
*(Publishing new `code-review` PR review blocks is owned by `code-review` in `skills/code-review/references/finding-schema.md`.)*
---
@@ -137,7 +137,7 @@ Never relay "QA failed" blindly. Classify each non-passing outcome and route to
## 9. Project Board Card Transitions Owned by `implement-slice`
When the repository tracks a Gitea Project Board (resolved from the `AGENTS.md` planning contract or `gt project list`), `implement-slice` owns moving the target issue's card across the pipeline using the `gt-usage` move recipe (`POST /repos/{owner}/{repo}/projects/<project-id>/issues/<global-issue-id>/move -F column_id=<target-col-id>`):
When the repository tracks a Gitea Project Board (resolved from the `AGENTS.md` planning contract or `gt project list`), `implement-slice` owns moving the target issue's card across the pipeline using the `gt-usage` move recipe (`POST /repos/{owner}/{repo}/projects/<project-id>/issues/<global-issue-id>/move -F column_id=<target-col-id>` for repo boards, or `POST /orgs/<org>/projects/<project-id>/issues/<global-issue-id>/move -F column_id=<target-col-id>` for organization-level boards):
| Step | Transition | Condition |
| :--- | :--- | :--- |
+11 -10
View File
@@ -365,22 +365,16 @@ class TestSkillsBehavioralContracts(unittest.TestCase):
self.assertEqual(initial_commit, current_commit)
def test_review_comment_publishing_ownership(self):
"""Proves code-review only drafts the PR comment block and gitea-pr alone posts it, guarded."""
"""Proves code-review stays codebase-read-only while owning guarded PR review publishing, and gitea-pr delegates it."""
cr_dir = REPO_ROOT / "skills" / "code-review"
cr_text = "\n".join(p.read_text() for p in cr_dir.rglob("*.md"))
# code-review drafts the block (including clean Ready reviews) but never contains a posting command
self.assertIn("review-body.md", cr_text)
self.assertIn("inline-comments.json", cr_text)
self.assertIn("No non-rejected findings.", cr_text)
self.assertIsNone(
re.search(r"gt pr (comment|review)\s+<", cr_text),
"code-review must not contain gt posting commands; gitea-pr owns publishing",
)
self.assertIn("read-only regarding the codebase", cr_text)
pr_skill = (REPO_ROOT / "skills" / "gitea-pr" / "SKILL.md").read_text()
recipes = (REPO_ROOT / "skills" / "gitea-pr" / "references" / "gt-pulls.md").read_text()
self.assertIn("Publish review findings", pr_skill)
publish = recipes.split("### Publish a `code-review` Comment Block", 1)[1].split("\n## ", 1)[0]
schema = (cr_dir / "references" / "finding-schema.md").read_text()
publish = schema.split("### Publishing via `gt pr review`", 1)[1]
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
self.assertIn("--commit <reviewed-head-sha>", post_cmd)
@@ -390,6 +384,13 @@ class TestSkillsBehavioralContracts(unittest.TestCase):
self.assertLess(publish.index("head_sha"), 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)
pr_skill = (REPO_ROOT / "skills" / "gitea-pr" / "SKILL.md").read_text()
pr_pulls = (REPO_ROOT / "skills" / "gitea-pr" / "references" / "gt-pulls.md").read_text()
self.assertNotIn("Publish review findings", pr_skill)
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())
def test_project_board_reconciliation_and_card_transitions(self):
"""Proves 5-column board reconciliation, Deep Signal colors, and card transition ownership."""
tiers_text = (REPO_ROOT / "skills" / "gitea-plan" / "references" / "decomposition-tiers.md").read_text()