Compare commits
16
Commits
3bca64c258
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c0210ecd1 | ||
|
|
7c482fe3ca | ||
|
|
5881541a82 | ||
|
|
f2494c5b91 | ||
|
|
7f12836860 | ||
|
|
f71729dc17 | ||
|
|
b51c7d0c60 | ||
|
|
c0f6e92935 | ||
|
|
8c5172eeaf | ||
|
|
bedd01e729 | ||
|
|
6280654332 | ||
|
|
65ce3bd21a | ||
|
|
f5572f2a39 | ||
|
|
1c4df2eec4 | ||
|
|
3767cbb383 | ||
|
|
d2ac585e3e |
No files matched your search
@@ -22,7 +22,7 @@ These skills exist to enforce four core principles:
|
|||||||
|
|
||||||
1. **Defeating the Comprehension Illusion**: Having an AI generate code is not the same as understanding how a system behaves. When code velocity outpaces comprehension, you end up with systems you cannot debug when production breaks. Skills like `practice` make the learner write the code and drive analysis, ensuring mental models develop alongside the codebase.
|
1. **Defeating the Comprehension Illusion**: Having an AI generate code is not the same as understanding how a system behaves. When code velocity outpaces comprehension, you end up with systems you cannot debug when production breaks. Skills like `practice` make the learner write the code and drive analysis, ensuring mental models develop alongside the codebase.
|
||||||
|
|
||||||
2. **Intentional Epistemic Friction ("Your call")**: Great engineering requires deliberate checkpoints. Instead of letting agents make unilateral architectural choices, these skills pause at critical state transitions: requiring proven root causes before patching (`diagnose`), gating branch integration and merge readiness (`git-manager` / `gitea-pr`), or identifying learning opportunities that should be preserved as durable knowledge (`document`).
|
2. **Intentional Epistemic Friction ("Your call")**: Great engineering requires deliberate checkpoints. Instead of letting agents make unilateral architectural choices, these skills pause at critical state transitions: requiring proven root causes before patching (`diagnose`), gating branch integration and merge readiness (`git-manager` / `verify`), or identifying learning opportunities that should be preserved as durable knowledge (`document`).
|
||||||
|
|
||||||
3. **Operational Ownership**: An agent should investigate, measure, and propose concrete options, but the human engineer must own the trade-offs, failure domains, and repository history. You cannot own what you did not decide.
|
3. **Operational Ownership**: An agent should investigate, measure, and propose concrete options, but the human engineer must own the trade-offs, failure domains, and repository history. You cannot own what you did not decide.
|
||||||
|
|
||||||
@@ -32,9 +32,9 @@ These skills exist to enforce four core principles:
|
|||||||
|
|
||||||
## The System Architecture
|
## The System Architecture
|
||||||
|
|
||||||
The system is under active testing and continuous improvement. Currently, the skills form an orchestrated pair-programming workflow. `build-skill` governs meta-level skill design.
|
The system is under active testing and continuous improvement. Currently, the skills form an orchestrated pair-programming workflow. `build-skill` governs meta-level skill design.
|
||||||
|
|
||||||
Three core operational skills (`practice`, `diagnose`, `git-manager`) structure day-to-day engineering. `document` evaluates whether insights produced during work warrant durable preservation.
|
Three core operational skills (`practice`, `diagnose`, `git-manager`) structure day-to-day engineering, while a 4-skill GitHub-native delivery loop (`projects` -> `implement` -> `code-review` -> `verify`) handles planning, slice execution, static review, and merge closeout. `document` evaluates whether insights produced during work warrant durable preservation, and `reconcile-docs` keeps canonical repository docs aligned with code and optional GitHub state.
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
flowchart TD
|
flowchart TD
|
||||||
@@ -44,12 +44,20 @@ flowchart TD
|
|||||||
DIAG["diagnose<br/>find out: evidence-first RCA"]
|
DIAG["diagnose<br/>find out: evidence-first RCA"]
|
||||||
GIT["git-manager<br/>branches, commits & recovery"]
|
GIT["git-manager<br/>branches, commits & recovery"]
|
||||||
end
|
end
|
||||||
|
subgraph Delivery["GitHub Delivery Loop"]
|
||||||
|
PROJ["projects<br/>milestones, issues & board"]
|
||||||
|
IMPL["implement<br/>preflight, workers & Draft PR"]
|
||||||
|
CR["code-review<br/>4-axis audit & CR-XX reviews"]
|
||||||
|
VER["verify<br/>QA, CI, promote & merge"]
|
||||||
|
PROJ --> IMPL --> CR --> VER
|
||||||
|
end
|
||||||
DOC["document<br/>classify & author: 5 epistemic types"]
|
DOC["document<br/>classify & author: 5 epistemic types"]
|
||||||
REC["reconcile-docs<br/>reconcile: history, code, Gitea, roadmap"]
|
REC["reconcile-docs<br/>reconcile: history, code, GitHub, roadmap"]
|
||||||
Storage["Repo docs/ & .internal/"]
|
Storage["Repo docs/ & .internal/"]
|
||||||
|
|
||||||
SB --> Core
|
SB --> Core
|
||||||
Core --> DOC
|
Core --> DOC
|
||||||
|
Delivery --> REC
|
||||||
DOC --> Storage
|
DOC --> Storage
|
||||||
Storage --> REC
|
Storage --> REC
|
||||||
REC --> Storage
|
REC --> Storage
|
||||||
@@ -65,22 +73,22 @@ Every skill features an explicit **"Your call"** checkpoint where the agent paus
|
|||||||
|
|
||||||
| Skill | Trigger / Command | Purpose | Length |
|
| Skill | Trigger / Command | Purpose | Length |
|
||||||
| :--- | :--- | :--- | :--- |
|
| :--- | :--- | :--- | :--- |
|
||||||
| **[`practice`](skills/practice/SKILL.md)** | `/practice [topic]`, `/practice review` | Socratic tutoring and delayed retrieval. Learner writes all code; uses graduated assistance, rubric calibration, and recall-before-reveal in gitignored `.internal/practice/`. | 51 lines |
|
| **[`practice`](skills/practice/SKILL.md)** | `/practice [topic]`, `/practice review` | Socratic tutoring, delayed retrieval, and hands-on Build-and-Break (`project-labs.md`: Ugly Heartbeat, primary specs, 30-line `scratch/` labs), Predict-Before-Run, and Code-Tracing drills with rubric calibration in gitignored `.internal/practice/`. | 57 lines |
|
||||||
| **[`diagnose`](skills/diagnose/SKILL.md)** | `/diagnose [symptom]` | Evidence-first troubleshooting. Progresses from raw logs to proven root cause and minimal, reversible fixes. | 49 lines |
|
| **[`diagnose`](skills/diagnose/SKILL.md)** | `/diagnose [symptom]` | Evidence-first troubleshooting. Progresses from raw logs to proven root cause and minimal, reversible fixes. | 49 lines |
|
||||||
| **[`git-manager`](skills/git-manager/SKILL.md)** | `/git-manager` | Repository hygiene, branch and worktree lifecycle, incremental Conventional Commits (autonomous on working branches in delivery mode; user-authored in learning mode), integration, conflict stops, and evidence-first reflog recovery. | 65 lines |
|
| **[`git-manager`](skills/git-manager/SKILL.md)** | `/git-manager` | Repository hygiene, branch and worktree lifecycle, incremental Conventional Commits (autonomous on working branches in delivery mode; user-authored in learning mode), integration, conflict stops, and evidence-first reflog recovery. | 67 lines |
|
||||||
| **[`gitea-plan`](skills/gitea-plan/SKILL.md)** | `/gitea-plan` | Translates technical goals and plans into Gitea milestones, 5-column Kanban boards, and issues with tiered sizing and falsifiable acceptance criteria. | 75 lines |
|
| **[`projects`](skills/projects/SKILL.md)** | `/projects` | Outer-loop GitHub planning: translates goals and specs into GitHub Milestones, Issues, and the canonical 5-column Projects v2 board with tiered sizing and zero-context reproducibility audits. | 75 lines |
|
||||||
| **[`implement-slice`](skills/implement-slice/SKILL.md)** | `/implement-slice` | Orchestrates end-to-end delivery of an issue or vertical slice across worker and QA subagents, pre-committed rubrics, Kanban card transitions, and final-HEAD gates without editing code directly. | 45 lines |
|
| **[`implement`](skills/implement/SKILL.md)** | `/implement` | Orchestrates a ready GitHub vertical-slice issue via preflight checks, Step 1 delta-test decomposition, branch-scoped checkpointing, adaptive `test-writer`/`code-writer` workers, 1:1 commits, and Draft PR publishing. | 78 lines |
|
||||||
| **[`gitea-pr`](skills/gitea-pr/SKILL.md)** | `/gitea-pr` | Manages Gitea pull request lifecycle: branch readiness, review/verification synthesis, PR review comment publishing, issue closing, and merge readiness. | 73 lines |
|
| **[`code-review`](skills/code-review/SKILL.md)** | `/code-review` | Inspects diffs and open GitHub PRs across four isolated axes (Spec & Scope, Standards & Smells, Seam & Test Integrity, Defensive Invariants), publishing monotonic `CR-XX` reviews and `RV-*` runtime checks via `build_review.py`. | 78 lines |
|
||||||
| **[`gt-usage`](skills/gt-usage/SKILL.md)** | `/gt-usage` | Work with Gitea repositories, issues, milestones, projects, and pull requests via the official gt CLI. Verified JSON recipes and anti-hallucination rules. | 45 lines |
|
| **[`verify`](skills/verify/SKILL.md)** | `/verify` | Runs black-box runtime QA and remote CI inspection against `verdict=ready` PRs, posts the verification ledger, promotes Draft PRs (`gh pr ready`, `Work in Progress -> Review`), and executes human-gated merge closeout (`Review -> Completed`). | 75 lines |
|
||||||
|
| **[`gitea-to-github`](skills/gitea-to-github/SKILL.md)** | `/gitea-to-github` | On-demand cutover skill migrating standalone Gitea repos or `--org` batches to GitHub primary with a Gitea pull mirror, translating `.gitea/workflows/` to `.github/workflows/`, rewriting `AGENTS.md`, and migrating open issues idempotently. | 42 lines |
|
||||||
|
| **[`gt-usage`](skills/gt-usage/SKILL.md)** | `/gt-usage` | Standalone ad-hoc Gitea CLI (`gt`) utility outside the GitHub core delivery loop for querying or mutating Gitea entities and configuring sovereign Gitea remotes. | 46 lines |
|
||||||
| **[`document`](skills/document/SKILL.md)** | `/document` | Second-order knowledge classifier (Discussion, ADR, Plan, Debug Record, Knowledge) scoped to the active repository's `docs/` (or `.internal/`). User confirms type and provides core insight. | 55 lines |
|
| **[`document`](skills/document/SKILL.md)** | `/document` | Second-order knowledge classifier (Discussion, ADR, Plan, Debug Record, Knowledge) scoped to the active repository's `docs/` (or `.internal/`). User confirms type and provides core insight. | 55 lines |
|
||||||
| **[`reconcile-docs`](skills/reconcile-docs/SKILL.md)** | `/reconcile-docs [path]` | Reconciles historical evidence, present code reality, Gitea delivery state, and future plans into canonical repo docs (`README`, `ARCHITECTURE`, `docs/adr/`, `ROADMAP`, `docs/designs/*.md`). | 44 lines |
|
| **[`reconcile-docs`](skills/reconcile-docs/SKILL.md)** | `/reconcile-docs [path]` | Reconciles historical evidence, present code reality, optional read-only GitHub delivery state, and future plans into canonical repo docs (`README`, `ARCHITECTURE`, `docs/adr/`, `ROADMAP`, `docs/designs/*.md`). | 45 lines |
|
||||||
| **[`build-skill`](skills/build-skill/SKILL.md)** | `/build-skill [topic]` | Interactive design, sizing, authoring, and empirical dogfooding of agent skills. Enforces design review gate before file creation. | 50 lines |
|
| **[`build-skill`](skills/build-skill/SKILL.md)** | `/build-skill [topic]` | Interactive design, sizing, authoring, and empirical dogfooding of agent skills. Enforces design review gate before file creation. | 50 lines |
|
||||||
| **[`derive-skill`](skills/derive-skill/SKILL.md)** | `/derive-skill <url-or-path>` | Evaluates an external skill (source, license, scripts), sorts material into preserve/adapt/reject, and decides new skill, merge, or reject. Hands an approved derivation brief to `build-skill`. | 58 lines |
|
| **[`derive-skill`](skills/derive-skill/SKILL.md)** | `/derive-skill <url-or-path>` | Evaluates an external skill (source, license, scripts), sorts material into preserve/adapt/reject, and decides new skill, merge, or reject. Hands an approved derivation brief to `build-skill`. | 58 lines |
|
||||||
| **[`inspect-flake-update`](skills/inspect-flake-update/SKILL.md)** | `/inspect-flake-update` | Inspects updated flake.lock inputs, reviews upstream revisions, runs nix flake check, and drafts commit messages. | 46 lines |
|
| **[`inspect-flake-update`](skills/inspect-flake-update/SKILL.md)** | `/inspect-flake-update` | Inspects updated flake.lock inputs, reviews upstream revisions, runs nix flake check, and drafts commit messages. | 46 lines |
|
||||||
| **[`nix-devshell`](skills/nix-devshell/SKILL.md)** | `/nix-devshell` | Authors, extends, validates, and troubleshoots project Nix development shells from repository evidence. | 76 lines |
|
| **[`nix-devshell`](skills/nix-devshell/SKILL.md)** | `/nix-devshell` | Authors, extends, validates, and troubleshoots project Nix development shells from repository evidence. | 76 lines |
|
||||||
| **[`verify-slice`](skills/verify-slice/SKILL.md)** | `/verify-slice` | Runs risk-proportional verification and PR review across behavioral, state, security, ergonomic, and regression perspectives using falsifiable assertions. | 37 lines |
|
| **[`tdd`](skills/tdd/SKILL.md)** | `/tdd` | Guides red-green test-driven development (Mode A) and test-suite hardening (Mode B) through public interface seams, boundary-only mocking, and non-tautological assertions. | 42 lines |
|
||||||
| **[`code-review`](skills/code-review/SKILL.md)** | `/code-review` | Inspects diffs across four isolated axes: Spec & Scope (including strategic project alignment), Standards & Smells, Seam & Test Integrity, and Defensive Invariants, plus drafting PR comment blocks. | 45 lines |
|
|
||||||
| **[`tdd`](skills/tdd/SKILL.md)** | `/tdd` | Guides red-green test-driven development through public interface seams, boundary-only mocking, and non-tautological assertions. | 40 lines |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -100,15 +108,22 @@ Every skill features an explicit **"Your call"** checkpoint where the agent paus
|
|||||||
|
|
||||||
1. **Investigation to History**: `diagnose` (verify root cause) -> `git-manager` (checkpoint commit) -> `document` (optional Debug Record / ADR in `docs/`).
|
1. **Investigation to History**: `diagnose` (verify root cause) -> `git-manager` (checkpoint commit) -> `document` (optional Debug Record / ADR in `docs/`).
|
||||||
2. **Deliberate Practice to Knowledge**: `practice` (solve transfer challenge, log in `.internal/practice/`) -> `document` (optional durable knowledge article in `docs/knowledge/`).
|
2. **Deliberate Practice to Knowledge**: `practice` (solve transfer challenge, log in `.internal/practice/`) -> `document` (optional durable knowledge article in `docs/knowledge/`).
|
||||||
3. **Documentation Reconciliation**: `reconcile-docs` (audit repo history, code reality, Gitea state, roadmap) -> propose updates to `README` / `ARCHITECTURE` / `docs/adr/` / `ROADMAP` / `docs/designs/*.md` -> user approves.
|
3. **Documentation Reconciliation**: `reconcile-docs` (audit repo history, code reality, optional read-only GitHub state, roadmap) -> propose updates to `README` / `ARCHITECTURE` / `docs/adr/` / `ROADMAP` / `docs/designs/*.md` -> user approves.
|
||||||
4. **Skill Design Loop**: `build-skill` (approve spec) -> dogfood run -> minimal mechanism refinement.
|
4. **Skill Design Loop**: `build-skill` (approve spec) -> dogfood run -> minimal mechanism refinement.
|
||||||
5. **Branch Lifecycle & Integration**: `git-manager` (branch-before-edits or isolated worktree) -> implementation & incremental checkpoint commits -> `code-review` / `verify-slice` -> `git-manager` (rebase or integration).
|
5. **Branch Lifecycle & Integration**: `git-manager` (branch-before-edits or isolated worktree) -> implementation & incremental checkpoint commits -> `code-review` / `verify` -> `git-manager` (rebase or integration).
|
||||||
6. **Issue Planning to PR Delivery**: `gitea-plan` (tiered sizing, 5-column Kanban reconciliation, & falsifiable acceptance criteria) -> `implement-slice` (orchestrates `git-manager` workspace isolation, worker `tdd` checkpoints, pre-committed `verify-slice` QA rubrics, Kanban card transitions, and final-HEAD `code-review`) -> `gitea-pr` (PR synthesis, review comment publishing, feedback triage, merge & `Review -> Completed`).
|
6. **GitHub Delivery Loop**: `projects` (tiered sizing, 5-column Projects v2 board, milestones, & falsifiable acceptance criteria) -> `implement` (preflight, Step 1 delta-test decomposition, branch-scoped checkpointing, adaptive `test-writer`/`code-writer` workers, & Draft PR) -> `code-review` (4-axis static audit, monotonic `CR-XX` PR reviews via `build_review.py`, & `RV-*` runtime checks) -> `verify` (black-box runtime QA, remote CI inspection, `gh pr ready` + `Work in Progress -> Review`, human-gated merge, & `Review -> Completed`).
|
||||||
|
7. **Gitea-to-GitHub Cutover**: `gitea-to-github` (dry-run inventory, backup snapshot, PR gate, `new-repo --empty --no-mirror --no-clone` push, `.gitea/workflows/` -> `.github/workflows/` & `AGENTS.md` translation, idempotent issue migration, archive rename, and `new-repo --gitea-mirror` pull-mirror swap) -> `projects` / `implement`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Installation & Portability
|
## Installation & Portability
|
||||||
|
|
||||||
|
### CLI Prerequisites
|
||||||
|
- **`git`**: required for all repository, branch, and worktree workflows.
|
||||||
|
- **`gh` (GitHub CLI)**: primary forge CLI for the 4-skill GitHub delivery loop (`projects`, `implement`, `code-review`, `verify`), `gitea-to-github`, and optional read-only GitHub ingestion in `reconcile-docs` (authenticated with `repo` and `project` scopes).
|
||||||
|
- **`gt` (Gitea CLI)**: optional CLI required for `gt-usage` (ad-hoc Gitea operations) and `gitea-to-github` (Gitea-to-GitHub cutover).
|
||||||
|
- **`new-repo`**: optional repo-provisioning CLI used by `gitea-to-github` (`--empty --no-mirror --no-clone` and `--gitea-mirror`).
|
||||||
|
|
||||||
The repository includes an idempotent install script (`install.sh`) supporting both symlink and copy modes:
|
The repository includes an idempotent install script (`install.sh`) supporting both symlink and copy modes:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -124,14 +139,14 @@ The repository includes an idempotent install script (`install.sh`) supporting b
|
|||||||
|
|
||||||
When run:
|
When run:
|
||||||
- Portable skills and active extensions are linked/copied to the target directory.
|
- Portable skills and active extensions are linked/copied to the target directory.
|
||||||
- Deprecated or superseded skills are safely relocated to a dated backup directory (`skills.backup-<date>`).
|
- Retired legacy Gitea skills (`gitea-plan`, `implement-slice`, `verify-slice`, `gitea-pr`) and other obsolete skills are safely relocated to a dated backup directory (`skills.backup-<date>`).
|
||||||
- The global profile `profile/AGENTS.md` is installed as the user's base agent instruction.
|
- The global profile `profile/AGENTS.md` is installed as the user's base agent instruction.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Behavioral Regression Testing
|
## Behavioral Regression Testing
|
||||||
|
|
||||||
To ensure portable skills and Gitea integrations maintain behavioral invariants across updates, run the deterministic regression test harness:
|
To ensure portable skills and GitHub delivery integrations maintain behavioral invariants across updates, run the deterministic regression test harness:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Run full behavioral contract and invariant test suite
|
# Run full behavioral contract and invariant test suite
|
||||||
@@ -139,15 +154,14 @@ To ensure portable skills and Gitea integrations maintain behavioral invariants
|
|||||||
```
|
```
|
||||||
|
|
||||||
Validates:
|
Validates:
|
||||||
- Prerequisite verification and actionable `gt` CLI setup guidance.
|
- Dynamic GitHub Projects v2 and milestone ID resolution rules (forbidding hardcoded Node IDs or guessed milestone numbers).
|
||||||
- Anti-hallucination querying rules (preventing hardcoded milestone/issue sequence numbers).
|
- Single-owner 5-column board state machine (`Backlog -> Ready -> Work in Progress -> Review -> Completed`) across `projects`, `implement`, and `verify`.
|
||||||
- Adaptive proportionality scaling (lightweight docs vs full test ceremony).
|
- `implement` preflight classifications, `--dry-run` zero-mutation contract, branch-scoped checkpointing, and OS-level non-interactive worker timeouts.
|
||||||
- Canonical 5-tuple workflow node schema and dynamic Mermaid projections.
|
- `code-review` `build_review.py` monotonic `CR-XX` publishing, `cr-review-meta` stamping, diff-hunk validation, and exit codes.
|
||||||
- Security invariant verification seams.
|
- `verify` 3-phase QA/CI/promotion/merge closeout and `reconcile-docs` read-only GitHub ingestion.
|
||||||
- State-preserving failure/rework routing.
|
- `gitea-to-github` safety flags, archive-before-mirror ordering, CI security guards, `<!-- gitea-origin: ... -->` idempotency, sibling handoffs, and `profile/AGENTS.md` zero-network session-start opt-out.
|
||||||
- Execution deviation logging.
|
- `practice` Build-and-Break (`project-labs.md`), Predict-Before-Run, Code-Tracing, and `Reasoning trap` contracts.
|
||||||
- Strict dry-run zero-mutation invariants.
|
- Skill line caps (≤80 lines), em-dash absence, valid relative markdown links, and path portability.
|
||||||
- Skill line caps (≤80 lines), em-dash absence, and path portability.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,260 @@
|
|||||||
|
# `gitea-to-github` Migration Skill Design
|
||||||
|
|
||||||
|
* **Author:** kiskaadee
|
||||||
|
* **Status:** Implemented
|
||||||
|
* **Date:** 2026-11-26
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
`gitea-to-github` is an on-demand portable skill in `kiskaadee/skills` (`skills/gitea-to-github/SKILL.md`, `<= 80` lines) that migrates standalone repositories or Gitea organizations from self-hosted Gitea (`gt`) to GitHub (`gh` + `new-repo`, the user's repo-provisioning CLI), reconfiguring each migrated Gitea repository as an out-of-band pull mirror of GitHub. It handles full git history transfer, in-flight Gitea PR resolution, interactive curation of open issues and milestones, GitHub Projects v2 board onboarding, `.gitea/workflows/` CI pipeline migration to `.github/workflows/`, and `AGENTS.md` planning contract updates to `project_number: <int>`. In parallel, `profile/AGENTS.md` (the user-global session-start instruction file, distinct from per-repo `AGENTS.md`) adds a session-start check that detects Gitea `origin` remotes (when not explicitly marked sovereign/Gitea-only) and suggests running `/gitea-to-github`.
|
||||||
|
|
||||||
|
## The Problem
|
||||||
|
|
||||||
|
Following the migration of the core delivery loop (`projects`, `implement`, `code-review`, `verify`) and `reconcile-docs` to GitHub-native workflows, existing repositories hosted on self-hosted Gitea still face four migration barriers:
|
||||||
|
|
||||||
|
1. **Manual multi-step repo and mirror inversion is error-prone:** Migrating a Gitea repository to GitHub primary + Gitea pull mirror requires creating an empty GitHub repository (`new-repo --empty --no-mirror --no-clone`), pushing branches and tags without Gitea's internal `refs/pull/*` refs, flipping local `origin`, archiving/replacing the source Gitea repository via `new-repo --gitea-mirror`, and aligning visibility (`internal` -> `private`). Deleting Gitea prematurely risks losing closed PRs, closed issues, releases, and webhooks if mirror creation fails.
|
||||||
|
2. **CI pipelines target Gitea runners and context:** Existing `.gitea/workflows/` files reference `${{ gitea.* }}`, `GITEA_TOKEN`, Gitea action URLs, and Gitea runner labels, so they fail or remain inactive on GitHub Actions unless translated to `.github/workflows/`.
|
||||||
|
3. **Open issues, milestones, boards, and legacy `AGENTS.md` contracts lag behind:** Repositories retain legacy `gitea-plan` `AGENTS.md` contracts (hardcoded Gitea board/column IDs and hex colors), open Gitea issues, and classic Gitea boards. Resuming an interrupted migration without an immutable provenance key risks duplicating GitHub issues.
|
||||||
|
4. **Unmigrated repositories lack proactive discovery:** Agents starting work in an unmigrated Gitea repository only discover the forge mismatch after running a GitHub delivery skill (`projects`, `implement`, `verify`), rather than receiving a targeted migration suggestion at session start (while intentionally Gitea-only repositories need a way to opt out).
|
||||||
|
|
||||||
|
## Goals
|
||||||
|
|
||||||
|
* **Safe, non-destructive repo and mirror inversion:** Create empty GitHub targets via `new-repo --empty --no-mirror --no-clone`, fail fast on Git LFS (`git lfs ls-files`), export a local Gitea API JSON snapshot before any destructive action, push all branches and tags cleanly, rename the Gitea source repo to `<repo>-archive-<timestamp>`, attach the Gitea pull mirror via `new-repo --gitea-mirror`, verify mirror sync, and delete the archive only upon explicit confirmation.
|
||||||
|
* **Dry-run default and multi-repo organization migration:** Default to a read-only dry-run inventory table across standalone repos and Gitea organizations, segmenting clean-slate repos (sequential execution from one approval) from interactive-gated repos (open PRs or uncurated issues) before mutating either forge.
|
||||||
|
* **CI pipeline migration:** Detect `.gitea/workflows/` and Gitea-targeting CI references, translate them to `.github/workflows/` (`${{ gitea.* }}` -> `${{ github.* }}`, `GITEA_TOKEN` -> `GITHUB_TOKEN`, GitHub-hosted `ubuntu-latest` default, or `self-hosted` opted in for `private` repos only), warn on unmigrated secrets, and commit them alongside any updated `AGENTS.md` in an ephemeral `/tmp/` clone before creating the Gitea pull mirror.
|
||||||
|
* **Idempotent issue, milestone, and conditional board migration:** Stamp `<!-- gitea-origin: <gitea-host>/<owner>/<repo>#<number> -->` (with `<gitea-host>` derived from `origin` or active `gt` host config, normalized to lowercase hostname without scheme or port) in migrated GitHub issue bodies, paginate existing GitHub issues and milestones for `diagnose`-pause resumability, conditionally onboard issues to a 5-column Projects v2 board (only when a legacy Gitea board/contract exists or when explicitly opted in during dry-run, leaving new boards for boardless repos to `/projects`), and propose rewriting legacy `AGENTS.md` contracts to `project_number: <int>`.
|
||||||
|
* **Zero-network session-start nudge with sovereign opt-out:** Update `profile/AGENTS.md` (user-global session-start instructions) to detect Gitea `origin` remotes via local git/file checks only and suggest `/gitea-to-github` (or flipping local `origin` via `git-manager` when `project_number:` is already present), skipping repositories that declare sovereign opt-out (`forge: gitea` in repo `AGENTS.md` or `git config --bool gitea.sovereign true`), and deferring live Gitea `mirror: true` verification to `/gitea-to-github` preflight.
|
||||||
|
* **Repository compliance:** Keep `skills/gitea-to-github/SKILL.md` `<= 80` lines following `skills/build-skill/references/skeleton.md`, with zero `/home/<user>` paths, zero secrets, zero hardcoded instance URLs, and full coverage in `install.sh` and `tests/fixtures/test_skills_behavioral_contracts.py`.
|
||||||
|
|
||||||
|
## Non-Goals
|
||||||
|
|
||||||
|
* **Migrating closed Gitea issues, closed PR review threads, wikis, webhooks, or Git LFS objects:** LFS fails fast; closed Gitea metadata (including closed issues, PRs, releases, and webhooks) is preserved in the local pre-archive JSON snapshot rather than replayed into GitHub. Because closed issues are skipped, open issues are re-numbered sequentially on GitHub (breaking `#N` cross-references).
|
||||||
|
* **Auto-merging conflicting or unreviewed Gitea PRs:** Open PRs are surfaced in dry-run and require an explicit per-PR decision (`merge`, `push branch + recreate PR on GitHub`, `close`, or `abort`).
|
||||||
|
* **Duplicating sibling skill rules:** `gt-usage` continues to own `gt` CLI conventions, `projects` continues to own Projects v2 / `AGENTS.md` schemas, and `git-manager` continues to own branch/commit hygiene.
|
||||||
|
|
||||||
|
## Open Questions
|
||||||
|
|
||||||
|
* None. All architectural decisions and upstream `new-repo --empty` prerequisites are resolved in this document.
|
||||||
|
|
||||||
|
## Critical User Journeys (CUJs)
|
||||||
|
|
||||||
|
### CUJ 1: Standalone Repository Migration (With Open Issues, CI Workflows & Legacy `AGENTS.md`)
|
||||||
|
|
||||||
|
* **Given**: A local checkout of a Gitea-hosted repository with open Gitea issues, a milestone, `.gitea/workflows/ci.yml`, and a legacy `gitea-plan` contract in `AGENTS.md`.
|
||||||
|
* **When**: The user runs `/gitea-to-github` (dry-run default), reviews the plan, resolves any open Gitea PRs, curates which open issues to carry over, and approves execution.
|
||||||
|
* **Then**:
|
||||||
|
1. `gitea-to-github` exports a local Gitea JSON snapshot to `$XDG_STATE_HOME/gitea-to-github-backup/<repo>/` (`0700`/`0600` permissions), creates the empty GitHub repo via `new-repo --empty --no-mirror --no-clone` (matching visibility), and pushes explicit `refs/heads/*:refs/heads/*` and `refs/tags/*:refs/tags/*` refspecs.
|
||||||
|
2. In an ephemeral `/tmp/` clone, it translates `.gitea/workflows/ci.yml` to `.github/workflows/ci.yml`, creates/links the 5-column Projects v2 board (triggered by the legacy `gitea-plan` contract), rewrites `AGENTS.md` to `project_number: <int>` (upon user approval), commits and pushes those changes to GitHub, and migrates selected open issues/milestones with `<!-- gitea-origin: <gitea-host>/<owner>/<repo>#<number> -->` markers.
|
||||||
|
3. If a local checkout exists, it delegates flipping local `origin` to GitHub and dirty-tree resolution to `git-manager`; it renames the Gitea repo to `<repo>-archive-<timestamp>`, attaches the Gitea pull mirror via `new-repo --gitea-mirror`, verifies sync, and deletes the archive only if the user explicitly confirms.
|
||||||
|
|
||||||
|
### CUJ 2: Organization Migration & Mid-Flight `diagnose` Resume
|
||||||
|
|
||||||
|
* **Given**: A Gitea organization containing multiple repositories (some active, some intentionally sovereign or already pull mirrors).
|
||||||
|
* **When**: The user runs `/gitea-to-github --org <gitea-org>`, reviews the dry-run inventory table (segmented into clean-slate vs. interactive-gated repos), approves execution, and hits an unexpected API/network error mid-migration.
|
||||||
|
* **Then**: `gitea-to-github` pauses and hands off to `/diagnose`; once resolved, re-running `/gitea-to-github` inspects existing GitHub repos, issues (`<!-- gitea-origin: ... -->` markers), and milestones to resume sequentially without duplicating repositories, issues, or milestones.
|
||||||
|
|
||||||
|
### CUJ 3: Session-Start Nudge & Sovereign Opt-Out
|
||||||
|
|
||||||
|
* **Given**: A developer opens an agent session inside a repository whose `origin` remote points to Gitea.
|
||||||
|
* **When**: The repository is a normal unmigrated Gitea repo vs. an intentionally sovereign repo (`forge: gitea` in `AGENTS.md` or `git config --bool gitea.sovereign true`) vs. a stale local clone already carrying `project_number:` in `AGENTS.md`.
|
||||||
|
* **Then**: `profile/AGENTS.md` performs a zero-network local check, suggests `/gitea-to-github` at session start for unmigrated repos, advises flipping local `origin` to GitHub via `git-manager` when `project_number:` is already present, and stays silent for sovereign repos (while `/gitea-to-github` preflight handles live `mirror: true` detection).
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Technical Plan (Architecture)
|
||||||
|
|
||||||
|
### System Topology & Migration Flow
|
||||||
|
|
||||||
|
`gitea-to-github` acts as an on-demand orchestrator over existing CLI/skill boundaries (`gt-usage` for Gitea queries, `new-repo` for GitHub empty creation and Gitea pull-mirror attachment, `git-manager` for local remote/commit hygiene, `projects` for Projects v2 / `AGENTS.md` schemas, and `diagnose` for mid-flight error recovery).
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
P["1. Preflight & Dry-Run\n(gt/gh auth, LFS check,\nOpen PRs, CI, Issues, AGENTS.md)"] --> G{"Explicit\nApproval / --execute"}
|
||||||
|
G -- "No" --> STOP["Exit Cleanly\n(Preview Inventory Only)"]
|
||||||
|
G -- "Yes" --> B["2. Snapshot & PRs\n(Gitea JSON snapshot;\nResolve Open Gitea PRs)"]
|
||||||
|
B --> GH["3. GitHub Repo & Push\n(new-repo --empty --no-mirror --no-clone;\nPush heads + tags, verify refs)"]
|
||||||
|
GH --> CI["4. CI, Conditional Board & AGENTS.md\n(/tmp clone: .gitea -> .github/workflows;\nProjects v2 if legacy board/contract or opted-in)"]
|
||||||
|
CI --> ISS["5. Idempotent Issues\n(Milestones + Open Issues\nwith gitea-origin marker)"]
|
||||||
|
ISS --> MIR["6. Archive & Pull Mirror\n(Flip origin -> GitHub; Rename Gitea archive;\nnew-repo --gitea-mirror; Optional archive delete)"]
|
||||||
|
B -. "Error" .-> D["/diagnose -> Resume"]
|
||||||
|
GH -. "Error" .-> D
|
||||||
|
CI -. "Error" .-> D
|
||||||
|
ISS -. "Error" .-> D
|
||||||
|
MIR -. "Error" .-> D
|
||||||
|
```
|
||||||
|
|
||||||
|
### Execution Modes & Dry-Run Default
|
||||||
|
|
||||||
|
1. **Default Dry-Run Mode:** Invoking `/gitea-to-github` (standalone or `--org <gitea-org>`, with `--dry-run` accepted as an optional explicit flag) always runs a read-only discovery pass first and halts before any mutation unless `--execute` or explicit approval is given. Passing `--execute` skips the initial confirmation gate only for `clean-slate` repos; `interactive-gated` repos still pause for per-PR and issue-curation prompts.
|
||||||
|
2. **Segmented Org Selection & Sequential Execution:** When targeting a Gitea organization, the dry-run discovery pass paginates Gitea org/repo/issue/PR API queries, classifies every repository (`migratable`, `already-pull-mirror`, `sovereign-opt-out`, `has-lfs-blocked`, `has-open-prs`, `has-open-issues`, `empty`, `archived`) into a single inventory table, and segments selected repositories into:
|
||||||
|
* **Clean-slate:** Repositories with zero open PRs and no per-item curation required; executed sequentially from one approval (applying any user-stated overrides such as visibility or target org).
|
||||||
|
* **Interactive-gated:** Repositories with open PRs or open issues needing curation; handled per-repo with explicit interactive prompts before mutation.
|
||||||
|
|
||||||
|
### Git, `new-repo --empty`, & Safe Mirror Swap
|
||||||
|
|
||||||
|
1. **Visibility, Mirror, Dirty-Path, State & LFS Pre-Checks:** Check live Gitea mirror status (skipping already-mirrored repos) and Git LFS usage (failing fast if LFS objects exist). Unarchive `archived: true` Gitea repos only on explicit approval if they are selected for migration, and handle `empty` (0-commit) repos without running git branch pushes or `/tmp/` commits. If a local checkout exists, check working-tree status specifically for `AGENTS.md` and `.gitea/workflows/`: if uncommitted edits exist on those paths, prompt the user to commit or stash them via `git-manager` first, or continue via `/tmp/` and skip the post-swap local `git pull`. Map Gitea `public` -> GitHub `public`, `private` -> GitHub `private`, and `internal` -> GitHub `private` (with an explicit warning). If the target GitHub repo already exists and is `private`, update the Gitea repo to `private` before mirroring.
|
||||||
|
2. **Pre-Migration Snapshot & Open PR Gate:** Export a local Gitea API JSON snapshot (open/closed issues, PRs, milestones, releases, and webhooks) under `$XDG_STATE_HOME/gitea-to-github-backup/<repo>/` (falling back to `~/.local/state/gitea-to-github-backup/<repo>/`) with `umask 077` (`0700`/`0600` permissions). Never auto-merge conflicting or unreviewed Gitea PRs; dry-run lists every open PR with draft/mergeable/CI status and requires a per-PR choice (`merge` on Gitea, `push branch + recreate PR on GitHub`, `close`, or `abort`) before cloning/pushing.
|
||||||
|
3. **Empty GitHub Creation & Idempotent Ref Push:** Create the empty GitHub target via `new-repo --empty --no-mirror --no-clone` (skipping creation if the target GitHub repo already exists on resume). Clone Gitea into a temp bare repo and push explicit `refs/heads/*:refs/heads/*` and `refs/tags/*:refs/tags/*` refspecs (avoiding Gitea internal refs such as `refs/pull/*`). On resume, verify whether Gitea branch tips are already ancestors of GitHub's branches before pushing (never force-pushing over Step 4 commits). Set GitHub's default branch to match Gitea's and verify `HEAD`, branch list, and tag list align.
|
||||||
|
4. **Ephemeral `/tmp/` Clone Commit & Non-Destructive Archive Swap:**
|
||||||
|
* Check whether the planned CI and/or contract updates for that repository are already present on GitHub before re-running Step 4; if missing, apply `.github/workflows/` and `AGENTS.md` updates inside an ephemeral `/tmp/` clone of the newly pushed GitHub repository and push to GitHub *before* creating the Gitea pull mirror, decoupling remote migration from local working-tree state.
|
||||||
|
* Only *after* GitHub refs, CI workflows, `AGENTS.md`, and open issues are verified on GitHub:
|
||||||
|
* If a local checkout exists, delegate flipping local `origin` to GitHub, dirty-tree resolution, and pulling the migration commit (unless skipped due to colliding local edits) to `git-manager`.
|
||||||
|
* Rename the source Gitea repository to `<repo>-archive-<timestamp>` (truncating the base name if needed to stay within Gitea's 100-character repository name limit).
|
||||||
|
* Attach the Gitea pull mirror via `new-repo --gitea-mirror <github-url> [-p] [--gitea-org <gitea-org>]` (passing private-repo credentials per `new-repo`'s mirror auth contract) and poll Gitea's mirror status endpoint until the first sync succeeds or times out.
|
||||||
|
* Ask for explicit user confirmation under the skill's destructive-action gate (aligned with `profile/AGENTS.md`) before deleting `<repo>-archive-<timestamp>`.
|
||||||
|
|
||||||
|
### CI Pipeline Migration (`.gitea/workflows/` -> `.github/workflows/`)
|
||||||
|
|
||||||
|
Before creating the Gitea pull mirror, `gitea-to-github` inspects `.gitea/workflows/*.yml|yaml` (and Gitea CI badges/URLs in `README.md`):
|
||||||
|
* Moves workflow files from `.gitea/workflows/` to `.github/workflows/` inside the ephemeral `/tmp/` clone.
|
||||||
|
* Translates Gitea-specific expressions and secrets: `${{ gitea.* }}` -> `${{ github.* }}`, `secrets.GITEA_TOKEN` / `GITEA_TOKEN` -> `secrets.GITHUB_TOKEN` / `GITHUB_TOKEN`. Extracts any non-`GITEA_TOKEN` `${{ secrets.* }}` references and warns the user during dry-run / Step 4 so those secrets can be provisioned on GitHub.
|
||||||
|
* Maps `runs-on:` labels: defaults to GitHub-hosted `ubuntu-latest` for both public and private repos, and maps to `self-hosted` only on explicit user opt-in during dry-run review when target GitHub visibility is `private` (blocking `self-hosted` on `public` repos to prevent PR supply-chain exposure).
|
||||||
|
* Flags third-party or Gitea-hosted action URLs (`https://<gitea-host>/...`) for user review/replacement and commits/pushes the migrated `.github/workflows/` from the `/tmp/` clone before mirror creation.
|
||||||
|
|
||||||
|
### Idempotent Issue, Milestone, Conditional Projects v2 & `AGENTS.md` Migration
|
||||||
|
|
||||||
|
1. **Milestones & Issues:** Query existing GitHub milestones and issues using paginated GitHub milestones and issues endpoints (filtering out pull requests), alongside paginated Gitea issue/milestone queries. Match milestones by `title` (creating missing ones with `description` and omitting null/zero `due_on` timestamps). Pre-create missing GitHub labels before creating issues, and warn if curated Gitea issue bodies contain `/attachments/<uuid>` URLs that would break once `<repo>-archive-<timestamp>` is deleted. Embed `<!-- gitea-origin: <gitea-host>/<owner>/<repo>#<number> -->` (with `<gitea-host>` derived from `origin` or active `gt` host config, normalized to lowercase hostname without scheme or port) at the bottom of each migrated GitHub issue body and skip any issue whose origin marker already exists on GitHub.
|
||||||
|
2. **Conditional Projects v2 Onboarding:** Only create or link a 5-column GitHub Projects v2 board (`Backlog`, `Ready`, `Work in Progress`, `Review`, `Completed`) when the source repo has a legacy Gitea board/contract or when the user explicitly opts in during dry-run; otherwise leave new board setup to `/projects` (respecting its tiered `Project Board Policy`, which marks boards `Omitted` for `Small`-tier work and `Recommended`/`Required` for `Medium`/`Large` tiers). Delegate all Projects v2 GraphQL mutations strictly to `skills/projects/references/github-projects-v2.md`, placing migrated issues in `Backlog` (or their mapped legacy Gitea column).
|
||||||
|
3. **`AGENTS.md` Rewrite:** Detect legacy `gitea-plan` contracts in repo `AGENTS.md` (Gitea `project_id`, `{column -> id}` maps, hex colors) and propose rewriting them to the state-free `project_number: <int>` schema from `skills/projects/references/planning-contract.md`. Commit and push `AGENTS.md` + `.github/workflows/` in the `/tmp/` clone *before* creating the Gitea pull mirror so both forges stay in sync.
|
||||||
|
|
||||||
|
### Global Session-Start Trigger (`profile/AGENTS.md`)
|
||||||
|
|
||||||
|
`profile/AGENTS.md` adds a strictly local, zero-network session-start check:
|
||||||
|
1. Inspect local `origin` remote to check if it points to the configured Gitea host.
|
||||||
|
2. Skip immediately if `origin` is already GitHub, if repo `AGENTS.md` declares sovereign opt-out (`forge: gitea`), or if `git config --bool gitea.sovereign` is `true`.
|
||||||
|
3. Otherwise, if `project_number:` is already present in repo `AGENTS.md`, warn that local `origin` still points to Gitea and advise flipping `origin` to GitHub via `git-manager`; if `project_number:` is absent, inform the user that the repository uses Gitea as `origin` and suggest running `/gitea-to-github` (leaving live Gitea API `mirror: true` verification to `/gitea-to-github` preflight).
|
||||||
|
|
||||||
|
### Component Architecture & `<= 80`-Line Partitioning
|
||||||
|
|
||||||
|
* **`skills/gitea-to-github/SKILL.md` (`<= 80` lines):** Follows `skills/build-skill/references/skeleton.md` (`Use when`, `Steps`, `Your call`, `Done when`, `Hands off to`), acting as a phase router with `Suggested Next Step:` emission (the standard handoff line printed at skill completion, suppressed when invoked by another skill) and explicit triggers to `references/` and sibling skills (`gt-usage`, `projects`, `git-manager`, `diagnose`).
|
||||||
|
* **`skills/gitea-to-github/references/remote-and-mirror.md`:** `new-repo --empty` invocation, explicit `refs/heads/*` + `refs/tags/*` refspec push, resume ancestry/phase guards, visibility mapping (`internal` -> `private`), `$XDG_STATE_HOME/gitea-to-github-backup/<repo>/` Gitea JSON snapshot (`umask 077`), preflight dirty-path check (`AGENTS.md`, `.gitea/workflows/`), ephemeral `/tmp/` clone commits, `git-manager` delegation for local remote flip, truncated `<repo>-archive-<timestamp>` rename, `new-repo --gitea-mirror` + polling/timeout verification, and explicit-confirmation archive deletion.
|
||||||
|
* **`skills/gitea-to-github/references/ci-and-contracts.md`:** `.gitea/workflows/` -> `.github/workflows/` translation rules (`gitea.*` -> `github.*`, `GITEA_TOKEN` -> `GITHUB_TOKEN`, non-`GITEA_TOKEN` secret extraction warnings, `runs-on:` defaults with `public`-repo `self-hosted` block) and legacy `AGENTS.md` -> `project_number: <int>` rewrite rules.
|
||||||
|
* **`skills/gitea-to-github/references/entity-migration.md`:** Segmented dry-run inventory table (`clean-slate` vs. `interactive-gated`, including `empty` and `archived` states), open PR resolution rules, `<!-- gitea-origin: ... -->` dedup algorithm (`gh api --paginate`, normalized `<gitea-host>`), label pre-creation, `/attachments/` warnings, null `due_on` omission, milestone & conditional Projects v2 delegation (`skills/projects/references/github-projects-v2.md`), and `diagnose` pause/resume state recovery.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
|
||||||
|
* **Sequential Safety & Resumability:** Org migrations execute sequentially per-repo using `gh` and `gt` CLI defaults, and any mid-flight error pauses for `/diagnose`; re-running `/gitea-to-github` uses phase-detection guards, branch ancestry checks, and `<!-- gitea-origin: ... -->` markers to resume idempotently without duplicating entities.
|
||||||
|
* **Portability & Hygiene:** Zero `/home/<user>` paths, zero hardcoded instance URLs (`gitea.roadtotech.me` stays solely in `profile/AGENTS.md`), zero em-dashes, and `SKILL.md <= 80` lines (enforced by `tests/fixtures/test_skills_behavioral_contracts.py`).
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Risks & Mitigations
|
||||||
|
|
||||||
|
| Risk | Impact | Mitigation |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| Data loss if Gitea repo is deleted before pull mirror syncs | Permanent loss of closed PRs/issues/releases/webhooks | Export local Gitea JSON snapshot (including releases/webhooks), rename Gitea repo to `<repo>-archive-<timestamp>`, verify `new-repo --gitea-mirror` sync first, and require explicit confirmation before deleting archive. |
|
||||||
|
| Security: private metadata exposure in backups or `self-hosted` runner RCE | Local secret/data leak or homelab runner compromise | Store JSON snapshots under `$XDG_STATE_HOME` with `umask 077` (`0700`/`0600`); block `self-hosted` runners on `public` repos and warn on unmigrated `${{ secrets.* }}` and Gitea-hosted action URLs. |
|
||||||
|
| Scalability: large org/repo pagination & secondary GitHub rate limits | Silent item truncation or mid-batch `403`/`429` failures | Use `gh api --paginate` and paginated Gitea queries; execute org batches sequentially with idempotent `<!-- gitea-origin: ... -->` resume on `/diagnose` retry. |
|
||||||
|
| Auto-merging conflicting/unreviewed Gitea PRs | Broken `main` pushed to GitHub | Never auto-merge; dry-run lists open PRs and requires explicit per-PR choice (`merge`, `recreate on GitHub`, `close`, or `abort`). |
|
||||||
|
| Resume overwriting Step 4 commits or failing on existing GitHub repo | Non-fast-forward rejection or aborted `/diagnose` retry | Skip `new-repo --empty` if GitHub repo exists; verify branch ancestry before pushing; skip Step 4 if the planned CI and/or contract updates for that repository are already present on GitHub. |
|
||||||
|
| Uncommitted local changes blocking CI/contract commit | Dirty working tree or mixed commits | Check `AGENTS.md` and `.gitea/workflows/` dirty paths in preflight; commit changes in an ephemeral `/tmp/` clone and delegate local remote/pull handling to `git-manager`. |
|
||||||
|
| Broken `/attachments/` URLs or `#N` re-numbering after closed-issue skip | Dead attachment links or shifted issue cross-references | Warn on `/attachments/<uuid>` URLs in curated issues before archive deletion; document `#N` re-numbering as a Non-Goal trade-off. |
|
||||||
|
| Prompting intentionally sovereign Gitea repos or missing stale `origin` | Developer friction or accidental push to read-only Gitea mirror | Zero-network local check in `profile/AGENTS.md` (`forge: gitea` / `git config gitea.sovereign` opt-out; still warn to flip `origin` via `git-manager` when `project_number:` is present). |
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Alternatives Considered
|
||||||
|
|
||||||
|
### Alternative 1: Use `gh repo create` Directly Instead of `new-repo --empty`
|
||||||
|
|
||||||
|
* **Summary:** Leave `new-repo` unchanged (where `--no-clone` still passes `auto_init=True` when no local `.git` exists) and invoke `gh repo create` directly from `gitea-to-github` to provision empty GitHub target repositories.
|
||||||
|
* **Pros:** Avoids any upstream change to `new-repo` and eliminates an external prerequisite for standalone skill execution.
|
||||||
|
* **Cons:** Splits repository provisioning across two tools (`new-repo` for normal creation and raw `gh repo create` inside `gitea-to-github`), losing `new-repo`'s centralized org targeting, visibility validation, and consistent Gitea mirror orchestration.
|
||||||
|
* **Reason for Rejection:** Keeping `new-repo` as the single repo-provisioning entry point preserves consistent behavior across standalone and mirrored repo creation; `--empty` (`auto_init=False`) is a minimal, reusable upstream addition in `new-repo` (`6f9f07b`).
|
||||||
|
|
||||||
|
### Alternative 2: Single-Repo Scope with Separate `/projects` Handoff
|
||||||
|
|
||||||
|
* **Summary:** Limit `gitea-to-github` to single-repository git/issue migration and delegate organization batching to a wrapper script while handing off Projects v2 onboarding and `AGENTS.md` updates to a separate `/projects` invocation.
|
||||||
|
* **Pros:** Smaller initial `gitea-to-github` skill surface and strict separation between git forge migration and project-board setup.
|
||||||
|
* **Cons:** Forces N sequential manual prompts across multi-repo organizations and leaves migrated repos without a working `project_number` or Projects v2 board until a second skill is run manually, breaking the pre-mirror commit guarantee (requiring extra post-mirror commits).
|
||||||
|
* **Reason for Rejection:** Supporting segmented org dry-run selection plus conditional Projects v2 + `AGENTS.md` `project_number` updates (when legacy boards/contracts exist or when opted in) ensures both GitHub and the new Gitea mirror inherit the complete contract in one pass without forcing boards onto repos that do not need them.
|
||||||
|
|
||||||
|
### Alternative 3: Omit Session-Start Gitea-Origin Trigger from `profile/AGENTS.md`
|
||||||
|
|
||||||
|
* **Summary:** Rely exclusively on users remembering to invoke `/gitea-to-github` manually rather than adding a session-start check in `profile/AGENTS.md`.
|
||||||
|
* **Pros:** Zero startup check overhead and zero risk of prompting on intentionally Gitea-hosted repositories.
|
||||||
|
* **Cons:** Legacy Gitea repositories and outdated `AGENTS.md` contracts go unnoticed during normal engineering sessions, stalling adoption of the GitHub-centered delivery workflow.
|
||||||
|
* **Reason for Rejection:** A strictly local, zero-network session-start check in `profile/AGENTS.md` surfaces legacy Gitea repos (and stale `origin` remotes on migrated repos) proactively without homelab coupling, while explicit opt-outs (`forge: gitea` in `AGENTS.md`, `git config --bool gitea.sovereign true`) prevent prompting intentionally sovereign repos.
|
||||||
|
|
||||||
|
### Alternative 4: In-Place Gitea `DELETE` Before `--gitea-mirror` and Title-Only Issue Deduplication
|
||||||
|
|
||||||
|
* **Summary:** Delete the original Gitea repository immediately after pushing git refs to GitHub so `new-repo --gitea-mirror` can recreate it at the same slug, and deduplicate migrated issues by matching issue titles on GitHub.
|
||||||
|
* **Pros:** Slightly fewer API calls during swap and no temporary `<repo>-archive-<timestamp>` repository to clean up.
|
||||||
|
* **Cons:** Immediate `DELETE` creates an irreversible data-loss window if mirror creation or network calls fail mid-flight; title-only issue matching silently collides or skips distinct Gitea issues that share a title.
|
||||||
|
* **Reason for Rejection:** Exporting a local Gitea JSON snapshot, renaming to `<repo>-archive-<timestamp>` until explicit deletion confirmation, and embedding an immutable `<!-- gitea-origin: <gitea-host>/<owner>/<repo>#<number> -->` marker prevent premature-deletion data loss and title-based issue collisions.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Future Improvements
|
||||||
|
|
||||||
|
* **Git LFS Object Migration:** Support optional `git lfs fetch --all` and `git lfs push --all` for repositories that store large binary assets, rather than failing fast in preflight.
|
||||||
|
* **Closed History & Webhook Migration:** Optional flag to import closed Gitea issues, PR review threads, wikis, or Gitea-to-GitHub webhook equivalents beyond the local JSON snapshot.
|
||||||
|
* **Automated Multi-Workflow Matrix Validation:** Run `actionlint` or dry-run workflow syntax validation against translated `.github/workflows/*.yml` files when available in the environment.
|
||||||
|
|
||||||
|
|
||||||
|
## Detailed Implementation Plan
|
||||||
|
|
||||||
|
> **Upstream Prerequisite Status:** `new-repo --empty --no-mirror --no-clone` (empty GitHub repo creation with `auto_init=False`) and the GitHub-primary + Gitea pull-mirror inversion (`--gitea-mirror <github-url>`, `--gitea-org <gitea-org>`) are already implemented and verified in `~/Projects/active/new-repo` (`6f9f07b`, 48/48 tests passing). All remaining changes below live in `kiskaadee/skills`.
|
||||||
|
|
||||||
|
### File Changes Overview
|
||||||
|
|
||||||
|
| Component / File | Type / Scope | Summary |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| `skills/gitea-to-github/SKILL.md` | Create (`<= 80` lines) | Phase-router skill entrypoint following `skeleton.md`. |
|
||||||
|
| `skills/gitea-to-github/references/remote-and-mirror.md` | Create | Preflight, JSON backup, git ref push, `/tmp/` commit, archive rename, and pull mirror swap. |
|
||||||
|
| `skills/gitea-to-github/references/ci-and-contracts.md` | Create | `.gitea/workflows/` to `.github/workflows/` CI and `AGENTS.md` contract migration rules. |
|
||||||
|
| `skills/gitea-to-github/references/entity-migration.md` | Create | Segmented `--org` dry-run inventory, milestone/issue dedup, and conditional Projects v2 rules. |
|
||||||
|
| `profile/AGENTS.md` | Modify | Update `new-repo` mirror wording and add local session-start Gitea-origin check. |
|
||||||
|
| `skills/projects/SKILL.md` | Modify | Reference `/gitea-to-github` in Step 1 legacy Gitea fallback. |
|
||||||
|
| `skills/projects/references/planning-contract.md` | Modify | Reference `/gitea-to-github` in Section 3 legacy Gitea contract detection. |
|
||||||
|
| `skills/gt-usage/SKILL.md` | Modify | Add `gitea-to-github` under `## Hands off to`. |
|
||||||
|
| `install.sh` | Modify | Add `gitea-to-github` to `ACTIVE_PORTABLE_SKILLS` in sorted order. |
|
||||||
|
| `tests/fixtures/test_skills_behavioral_contracts.py` | Modify | Register `gitea-to-github` in `EXPECTED_SKILLS` and add behavioral contract tests. |
|
||||||
|
|
||||||
|
### Phased Execution & Gate Checks
|
||||||
|
|
||||||
|
#### Phase 1: Create `skills/gitea-to-github/`
|
||||||
|
* **`skills/gitea-to-github/SKILL.md` (`<= 80` lines):** Follow `skills/build-skill/references/skeleton.md` (`name: gitea-to-github`, `## Use when`, `## Steps` in order: `Preflight & Dry-Run Plan -> Resolve PRs -> Push Git & Provision GitHub -> Projects v2 (if applicable) -> Translate CI & AGENTS.md (in /tmp/ clone) -> Migrate Issues -> Archive Rename & Pull Mirror -> Optional Archive Delete`, `## Your call`, `## Done when`, `## Hands off to` linking `projects`, `implement`, `gt-usage`, `diagnose`). Include `Suggested Next Step:` routing and zero `/home/<user>` paths, em-dashes, or hardcoded private domains.
|
||||||
|
* **`skills/gitea-to-github/references/remote-and-mirror.md`:**
|
||||||
|
* Preflight: verify `gt`, `gh`, `new-repo --empty --no-mirror --no-clone`, live Gitea `mirror: true` status, `git lfs ls-files` fail-fast, `empty`/`archived` repo classification, and dirty-path checks on `AGENTS.md` and `.gitea/workflows/`.
|
||||||
|
* Backup & PR gate: export Gitea JSON snapshot (issues, PRs, milestones, releases, webhooks) to `$XDG_STATE_HOME/gitea-to-github-backup/<repo>/` (fallback `~/.local/state/gitea-to-github-backup/<repo>/`) under `umask 077` (`0700`/`0600`); require per-PR choice (`merge`, `push branch + recreate PR`, `close`, `abort`).
|
||||||
|
* GitHub provisioning & push: **must invoke `new-repo <target> --empty --no-mirror --no-clone [-o <gh-org>] [-p]` from a fresh non-git temporary directory (`mktemp -d`)** so `new_repo.py`'s `determine_target()` never sees `.git` and never triggers `link_and_push_existing()` to prematurely overwrite local `origin`. Push explicit `refs/heads/*:refs/heads/*` and `refs/tags/*:refs/tags/*` refspecs from a temp bare clone; on resume, skip `new-repo --empty --no-mirror --no-clone` if the GitHub repo exists and check branch ancestry before pushing.
|
||||||
|
* Local checkout & archive swap: apply CI/`AGENTS.md` commits in an ephemeral `/tmp/` clone (skipping if planned updates are already present on GitHub); delegate local `origin` flip and `git pull` to `git-manager`. Rename Gitea repo to `<repo>-archive-YYYYMMDDHHMMSS` (UTC `YYYYMMDDHHMMSS`; `-archive-YYYYMMDDHHMMSS` is 23 chars, so truncate `<repo>` base name to `<= 77` chars to respect Gitea's 100-char limit). Attach pull mirror via `new-repo --gitea-mirror <github-url> [-p] [--gitea-org <gitea-org>]`, trigger `POST /api/v1/repos/{owner}/{repo}/mirror-sync`, and poll `GET /api/v1/repos/{owner}/{repo}` plus default-branch commit SHA parity against GitHub every `3s` up to a `60s` timeout. Delete `<repo>-archive-YYYYMMDDHHMMSS` only on explicit confirmation.
|
||||||
|
* **`skills/gitea-to-github/references/ci-and-contracts.md`:**
|
||||||
|
* Translate `.gitea/workflows/` to `.github/workflows/` (`${{ gitea.* }}` -> `${{ github.* }}`, `GITEA_TOKEN` -> `GITHUB_TOKEN`, default `runs-on: ubuntu-latest`, allow `self-hosted` only on explicit opt-in for `private` repos and block on `public` repos). Extract non-`GITEA_TOKEN` `${{ secrets.* }}` references and warn the user.
|
||||||
|
* Automatically rewrite standard Gitea workflow badge URLs in `README.md` to GitHub Actions badge URLs when the corresponding workflow is migrated; flag non-standard Gitea-hosted action or badge URLs for user review.
|
||||||
|
* Rewrite legacy `AGENTS.md` planning contracts (`project_id`, column maps, `gitea-plan`) to `project_number: <int>` inside the `/tmp/` clone before mirror attachment.
|
||||||
|
* **`skills/gitea-to-github/references/entity-migration.md`:**
|
||||||
|
* Emit segmented `--org` dry-run inventory table (`clean-slate` vs. `interactive-gated`, including `empty` and `archived`, using paginated Gitea queries).
|
||||||
|
* Migrate open milestones via `gh api --paginate repos/{owner}/{repo}/milestones?state=all` (matching by title, omitting null/zero `due_on`). Pre-create missing GitHub labels, warn on `/attachments/<uuid>` URLs, and deduplicate open issues via `gh api --paginate repos/{owner}/{repo}/issues?state=all` (filtering `select(.pull_request == null)`) using `<!-- gitea-origin: <gitea-host>/<owner>/<repo>#<number> -->` (`<gitea-host>` derived from `origin` or active `gt` host config, normalized lowercase hostname).
|
||||||
|
* Conditionally create/link a 5-column Projects v2 board (`Backlog`, `Ready`, `Work in Progress`, `Review`, `Completed`) via `skills/projects/references/github-projects-v2.md` only when a legacy Gitea board/contract exists or when explicitly opted in. Map legacy Gitea board columns case-insensitively (`To Do`/`Open` -> `Backlog`, `Ready` -> `Ready`, `In Progress`/`Doing` -> `Work in Progress`, `Review` -> `Review`, `Done`/`Closed` -> `Completed`; fallback `Backlog`).
|
||||||
|
* **Phase 1 Gate:** Verify `wc -l skills/gitea-to-github/SKILL.md <= 80` and confirm all four files exist with zero `/home/<user>` paths or private domains.
|
||||||
|
|
||||||
|
#### Phase 2: Update `profile/AGENTS.md` and Sibling Skills
|
||||||
|
* **`profile/AGENTS.md`:** Update L74 `"GitHub push mirroring"` wording for `new-repo` to `"Gitea pull mirroring"`. Under `## Homelab and connectivity` (L76), add a strictly local, zero-network session-start Gitea-origin check (`git remote -v` / `get-url origin`) that suggests `/gitea-to-github` (or flipping local `origin` via `git-manager` when `project_number:` is already present), skipping repos with `forge: gitea` in repo `AGENTS.md` or `git config --bool gitea.sovereign true`.
|
||||||
|
* **`skills/projects/SKILL.md` (Step 1) & `skills/projects/references/planning-contract.md` (Section 3):** Explicitly reference `/gitea-to-github` alongside standalone `gt-usage` in legacy Gitea fallback guidance.
|
||||||
|
* **`skills/gt-usage/SKILL.md` (`## Hands off to`):** Add `gitea-to-github` for repositories ready to migrate from Gitea to GitHub.
|
||||||
|
* **Phase 2 Gate:** Review `git diff` across `profile/AGENTS.md`, `skills/projects/`, and `skills/gt-usage/` for consistency and zero broken relative links.
|
||||||
|
|
||||||
|
#### Phase 3: Register Installer & Behavioral Contract Tests
|
||||||
|
* **`install.sh`:** Insert `gitea-to-github` in alphabetical order between `git-manager` and `gt-usage` in `ACTIVE_PORTABLE_SKILLS`.
|
||||||
|
* **`tests/fixtures/test_skills_behavioral_contracts.py`:** Add `"gitea-to-github"` in sorted order to `EXPECTED_SKILLS`, update `test_skill_inventory_and_skeletons` (L454) docstring from `15` to `16` active skills, and add `"gitea-to-github"` to `test_chained_skills_include_suggested_next_step_routing` (L261) (or validate its `Suggested Next Step:` and relative links in the new test). Add behavioral contract assertions verifying dry-run default, LFS fail-fast, `new-repo --empty --no-mirror --no-clone` from a non-git dir, archive-before-mirror rename, `<!-- gitea-origin: ... -->` idempotency, `.gitea/workflows/` -> `.github/workflows/` CI migration, and `profile/AGENTS.md` sovereign opt-out (`forge: gitea` / `git config` `gitea.sovereign`).
|
||||||
|
* **Phase 3 Gate:** Run `./install.sh check` and `./tests/fixtures/run_regression.sh` and confirm all checks pass with exit code `0`.
|
||||||
|
|
||||||
|
## Verification Plan
|
||||||
|
|
||||||
|
1. **Installation & Parity Checks:**
|
||||||
|
* Run `./install.sh check` (and `./install.sh` to sync local agent symlinks/copies) and confirm zero missing or stale skill registrations.
|
||||||
|
2. **Automated Behavioral Contract Suite:**
|
||||||
|
* Run `./tests/fixtures/run_regression.sh` and confirm all unit and regression checks pass with exit code `0` (covering `<= 80` lines, zero em-dashes, zero `/home/` paths, relative links, and `gitea-to-github` / `profile/AGENTS.md` behavioral contracts).
|
||||||
|
3. **Portability Hygiene Check (Beyond Automated Suite):**
|
||||||
|
* Verify zero hardcoded private domains (such as `gitea.roadtotech.me`) appear anywhere inside `skills/gitea-to-github/`.
|
||||||
|
4. **Manual Dry-Run & End-to-End Smoke Verification (Post-Implementation):**
|
||||||
|
* Run `/gitea-to-github` in default dry-run mode against a test Gitea repository with `.gitea/workflows/`, a legacy `AGENTS.md`, an open issue, and a milestone; confirm the emitted plan accurately previews changes without mutating Gitea or GitHub.
|
||||||
|
* Run `/gitea-to-github --org <gitea-org>` in dry-run mode and confirm the inventory table accurately segments `clean-slate` vs. `interactive-gated` (plus `empty`/`archived`/`sovereign-opt-out`) repositories (CUJ 2).
|
||||||
|
* Test `profile/AGENTS.md` session-start behavior on an unmigrated Gitea repo vs. sovereign opt-out (`forge: gitea` and `git config --bool gitea.sovereign true`) vs. stale `project_number:` repo (CUJ 3).
|
||||||
|
* Execute an end-to-end test migration on a disposable test repository and confirm: GitHub repo creation via `new-repo --empty --no-mirror --no-clone` from `mktemp -d`, `.github/workflows/` and `AGENTS.md` (`project_number: <int>`) committed in `/tmp/` prior to mirror swap, `<repo>-archive-YYYYMMDDHHMMSS` created, Gitea pull mirror attached and SHA-synced within `60s`, and re-running issue migration creates zero duplicate issues.
|
||||||
@@ -0,0 +1,389 @@
|
|||||||
|
# GitHub-Centered Delivery Ecosystem Redesign
|
||||||
|
|
||||||
|
* **Author:** kiskaadee
|
||||||
|
* **Status:** Implemented
|
||||||
|
* **Date:** 2026-11-25
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
This design migrates the primary planning, issue tracking, and pull request delivery workflows in `kiskaadee/skills` from a homelab-hosted Gitea instance (`gt`) to **GitHub Projects v2** (`gh` CLI and `gh api`). Gitea remains an out-of-band pull mirror of GitHub repositories (`gt-usage` stays installed as a standalone utility outside the delivery loop). GitHub-hosted runners serve as the default CI environment for both public and private repositories; an optional self-hosted `github_runner` on `server-local` (the homelab host) is available per repository only when a private repo approaches the 2,000 free minutes/month limit or requires homelab resources.
|
||||||
|
|
||||||
|
In parallel, the legacy Gitea delivery skills (`gitea-plan`, `implement-slice`, `verify-slice`, `gitea-pr`) are refactored into **4 GitHub-native core skills** (`projects`, `implement`, `code-review`, `verify`), plus an updated `reconcile-docs` skill. Every `SKILL.md` must adhere to `skills/build-skill/references/skeleton.md` (standardized frontmatter, trigger structure, and `Suggested Next Step:` routing), stay `<= 80` lines, enforce one owner per rule, and will be verified by `tests/fixtures/test_skills_behavioral_contracts.py` and `install.sh`.
|
||||||
|
|
||||||
|
## The Problem
|
||||||
|
|
||||||
|
The current skill ecosystem (`gitea-plan`, `implement-slice`, `code-review`, `verify-slice`, `gitea-pr`, `reconcile-docs`) is tightly coupled to a self-hosted Gitea instance on `server-local`, and suffers from four operational pain points:
|
||||||
|
|
||||||
|
1. **Homelab uptime blocks all planning and PR work:** Whenever `server-local` is offline (power loss, maintenance, or residential ISP WAN IP rotation with ~5-minute DNS propagation lag), issue creation, board transitions, PR reviews, and merges halt. Moving Gitea to a paid VPS would solve uptime, but adds recurring hosting cost and external server maintenance.
|
||||||
|
2. **Tangled skill ownership and ceremony:** `implement-slice` currently mixes preflight, decomposition, worker delegation, inline `verify-slice`, inline `code-review`, Gitea time tracking, board moves, and integration routing. Meanwhile, `gitea-pr` splits PR creation (post-QA) from PR triage and closeout, and `reconcile-docs` hardcodes Gitea `gt` queries.
|
||||||
|
3. **Broken cross-pass review traceability:** `code-review` resets its `CR-01..CR-NN` finding counter on every review pass of the same PR, causing ID collisions across rework rounds, omits `RV-*` (Runtime Verification) checks from the published PR review body so a fresh verification session cannot recover them, and risks `422 Unprocessable Entity` failures when inline comments target deleted or non-diff lines.
|
||||||
|
4. **Unbounded subagent hangs and installer blind spots:** Subagents occasionally hang for 8+ minutes on interactive CLI prompts (`/dev/tty` or stdin) or stalled network/lock calls with no OS-level timeout guard. In addition, `install.sh check` unconditionally exits `0` even when required skills are missing or obsolete symlinks remain, and `install.sh` does not prune dangling symlinks pointing into the skills repository.
|
||||||
|
|
||||||
|
## Goals
|
||||||
|
|
||||||
|
* **Decouple planning and PR workflows from homelab uptime:** All 4 core delivery skills (`projects`, `implement`, `code-review`, `verify`) and `reconcile-docs`'s GitHub read path operate natively against GitHub (`gh` CLI and `gh api`), validating GitHub repository identity via `gh repo view --json url` on forge-dependent operations.
|
||||||
|
* **Simplify the delivery loop to 4 core skills with clear single ownership:**
|
||||||
|
* `projects` owns outer-loop goals, milestones/due dates, vertical-slice issues, and the canonical 5-column board state machine (`Backlog -> Ready -> Work in Progress -> Review -> Completed`).
|
||||||
|
* `implement` absorbs Step 1 delta-test decomposition and a sole-owned branch-scoped plain-text `todo.txt`-format checkpoint under `$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt` (read/written directly without invoking `tuxedo`), executes slices with adaptive subagent isolation (`1-worker` fast path for trivial `<= 2`-file fixes; `test-writer` and `code-writer` with per-task lint/typecheck/docstring hygiene for multi-task slices), and publishes/syncs a Draft PR while keeping the board card in `Work in Progress`.
|
||||||
|
* `code-review` performs post-Draft-PR 4-axis static review (including non-documentation-drift checks) with persistent monotonic per-PR `CR-XX` IDs, deterministic `build_review.py` payload validation, `verdict=ready|needs_rework` + `RV-*` runtime checks in the review body, and split rework routing.
|
||||||
|
* `verify` owns black-box runtime QA, remote CI inspection, `verdict=ready` / `head_sha` validation, Draft PR promotion (`gh pr ready`, transitioning `Work in Progress -> Review`), human-gated merge, post-merge `Review -> Completed` transition, and drift chaining.
|
||||||
|
* **Prevent hung subagent CLI calls deterministically:** Enforce OS-level non-interactive command wrapping (`setsid timeout -k 10 <N>s <cmd> < /dev/null`) with tiered timeouts inside worker prompts.
|
||||||
|
* **Maintain strict repository invariants and atomic branch cutover:** Every `SKILL.md` stays `<= 80` lines with zero em-dashes, zero `/home/<user>` paths, and zero secrets; `install.sh` returns non-zero on `check` failures and prunes repo-scoped dangling symlinks; `tests/fixtures/test_skills_behavioral_contracts.py` and `tests/fixtures/run_regression.sh` pass; cutover executes atomically on a dedicated feature branch validated against one real private-repo slice before merging to `main`.
|
||||||
|
|
||||||
|
## Non-Goals
|
||||||
|
|
||||||
|
* **Dual-forge adapter layers in core skills:** Gitea is strictly an out-of-band pull mirror; `gt-usage` remains installed as an independent standalone utility and is not wired into `projects`, `implement`, `code-review`, `verify`, or `reconcile-docs`.
|
||||||
|
* **Standalone `gh-usage` skill:** Standard `gh` CLI flags do not require a dedicated skill; the 3 non-obvious `gh api`/GraphQL recipes (Projects v2 GraphQL Node IDs, REST milestones, commit-pinned inline reviews + paginated `CR-XX` lookup) live in `skills/projects/references/` and `skills/code-review/references/`.
|
||||||
|
* **Renaming `git-manager` to `git`:** Excluded to avoid touching 17+ files (including 7 unrelated skills) and colliding with the `git` CLI binary.
|
||||||
|
* **Automated `release` skill and per-repo Gitea-to-GitHub migration:** Automated releases are deferred until a project goes through its first manual release. Per-repo Gitea-to-GitHub migration (mirror inversion, issue migration, and legacy `AGENTS.md` conversion) is tracked as a dedicated follow-up issue (`gitea-to-github` skill).
|
||||||
|
* **`diagnose` post-mortem suggestion:** Deferred as an independent follow-up after the 4-skill GitHub loop is live.
|
||||||
|
* **Homelab `github_runner` NixOS/systemd implementation code:** This design specifies the operational hardening contract for opt-in `github_runner` deployments (`--ephemeral`, container/VM isolation, egress-only LAN firewall, resource caps, concurrency 2), while infrastructure manifests belong in the `canopy` infrastructure repository.
|
||||||
|
|
||||||
|
## Open Questions
|
||||||
|
|
||||||
|
* None. Initial exploration was captured in the brainstorm RFC; this document is the canonical resolved specification.
|
||||||
|
|
||||||
|
## Critical User Journeys (CUJs)
|
||||||
|
|
||||||
|
### CUJ 1: End-to-End Multi-Task Feature Slice on a GitHub Repo
|
||||||
|
|
||||||
|
* **Given**: A GitHub-hosted repository with `project_number` recorded in `AGENTS.md`, `gh` authenticated with `project` and `repo` scopes, and a ready vertical-slice issue `#42`.
|
||||||
|
* **When**: The user runs `implement` on issue `#42`, then `code-review` on the resulting Draft PR, addresses any findings, and runs `verify`.
|
||||||
|
* **Then**:
|
||||||
|
1. `implement` runs preflight (verifying a clean working tree on a non-`main` branch or worktree and moving `#42` `Ready -> Work in Progress`) and decomposes delta tests in Step 1.
|
||||||
|
2. `implement` tracks resume checkpoints in plain `todo.txt` format inside `$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt` (read/written directly), runs `test-writer` / `code-writer` (with per-task lint, typecheck, docstrings, and `Why:` comments), deletes the state file, and opens a Draft PR (`Closes #42`) while leaving `#42` in `Work in Progress`.
|
||||||
|
3. `code-review` audits the Draft PR, computes `max_id` deterministically via `skills/code-review/scripts/build_review.py` across paginated prior reviews/comments, and publishes one `head_sha`-pinned `--comment` review containing `<!-- cr-review-meta: max_id=NN head_sha=<sha> verdict=ready|needs_rework -->` and `RV-*` runtime checks.
|
||||||
|
4. `verify` confirms the latest `cr-review-meta` matches `head_sha` with `verdict=ready`, runs `RV-*` runtime checks and inspects `gh pr checks`, posts the verification ledger, promotes the PR (`gh pr ready`), moves `#42` `Work in Progress -> Review`, and on human approval merges the PR and executes `Review -> Completed`.
|
||||||
|
|
||||||
|
### CUJ 2: Trivial Localized Fix or Rework Pass (Fast Path)
|
||||||
|
|
||||||
|
* **Given**: An open Draft PR with a localized `code-review` finding (or a `<= 2`-file bugfix with no new test seam).
|
||||||
|
* **When**: `code-review` routes the localized finding to `implement` (or the user invokes `implement` directly).
|
||||||
|
* **Then**: `implement` runs preflight, auto-skips Step 1 decomposition, executes via a single worker with OS-level timeout wrapping, commits and pushes to the existing Draft PR branch, updates the Draft PR body if scope changed, and leaves the board card in `Work in Progress` for the next `code-review` pass (which continues numbering from `CR-(NN+1)` without colliding with earlier IDs).
|
||||||
|
|
||||||
|
### CUJ 3: Atomic Feature-Branch Cutover & Installer Verification
|
||||||
|
|
||||||
|
* **Given**: An existing local installation of `kiskaadee/skills` with legacy Gitea skills symlinked in `~/.gemini/config/skills/`.
|
||||||
|
* **When**: All new skills, updated retained skills, legacy skill deletions, `OBSOLETE_SKILLS` updates, `install.sh` fixes, and updated contract tests land together on a dedicated feature branch, and `./install.sh` is run from that branch to validate one live GitHub slice before merging to `main`.
|
||||||
|
* **Then**: `./install.sh check` exits non-zero whenever required skills are missing or obsolete symlinks remain, `python3 -m unittest tests/fixtures/test_skills_behavioral_contracts.py` and `tests/fixtures/run_regression.sh` pass, legacy symlinks are backed up and pruned cleanly, and `git checkout main && ./install.sh` rolls back cleanly with zero dangling symlinks.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Technical Plan (Architecture)
|
||||||
|
|
||||||
|
### System Topology & Delivery Loop
|
||||||
|
|
||||||
|
The delivery ecosystem is organized into 4 GitHub-native core skills (`projects`, `implement`, `code-review`, `verify`), plus `reconcile-docs` updated for GitHub read-only ingestion. Among supporting skills outside the core loop, `diagnose` and `document` remain unchanged, while `git-manager`, `tdd`, and `gt-usage` are updated only for handoff and cross-reference alignment.
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
P["projects\n(Goals, Milestones, Issues,\nBoard State Machine)"] --> I["implement\n(Preflight, Step 1 Delta Plan,\ngit-common-dir/implement-state, Workers, Draft PR)"]
|
||||||
|
I -- "Draft PR\n(Card stays in WIP)" --> CR["code-review\n(4-Axis Review, Monotonic CR-XX,\nRV-* in Review Body)"]
|
||||||
|
CR -- "Needs Rework\n(<=2 files: fast path;\ncomplex: Step 1)" --> I
|
||||||
|
CR -- "Ready\n(verdict=ready + head_sha + RV-*)" --> V["verify\n(Phase 1: QA + CI\nPhase 2: gh pr ready + WIP->Review\nPhase 3: Merge + Move Completed)"]
|
||||||
|
V -. "Contract Drift != none" .-> RD["reconcile-docs"]
|
||||||
|
V -. "Contract Drift / Next Slice" .-> P
|
||||||
|
```
|
||||||
|
|
||||||
|
### Canonical Board State Machine & Single Ownership
|
||||||
|
|
||||||
|
`projects` is the sole owner of the 5-column GitHub Projects v2 board schema (`skills/projects/references/planning-contract.md` and `skills/projects/references/github-projects-v2.md`):
|
||||||
|
|
||||||
|
| Column | Fixed GitHub Color Enum | Entering Transition Owner | Trigger Event |
|
||||||
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| `Backlog` | `GRAY` | `projects` (or `verify` on abort) | Issue created, or abandoned Draft PR closed |
|
||||||
|
| `Ready` | `BLUE` | `projects` | Slice prioritized and ready for execution |
|
||||||
|
| `Work in Progress` | `YELLOW` | `implement` (or `verify` on merge rejection) | Preflight passes (`Ready -> Work in Progress`); stays here through Draft PR open, `code-review`, and rework; human merge rejection at `verify` Phase 3 runs `gh pr ready --undo` and moves `Review -> Work in Progress` |
|
||||||
|
| `Review` | `PURPLE` | `verify` | Phase 2 passes QA + CI + `verdict=ready` gate and runs `gh pr ready` (`Work in Progress -> Review`) |
|
||||||
|
| `Completed` | `GREEN` | `verify` | Phase 3 merges PR and executes `Review -> Completed` directly |
|
||||||
|
|
||||||
|
### Repository `AGENTS.md` Planning Contract Schema
|
||||||
|
|
||||||
|
Each GitHub-managed repository stores minimal, human-readable coordinates in its `AGENTS.md` (no rotating sprint state and no brittle GraphQL Node IDs):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# Planning Contract (owned by projects)
|
||||||
|
project_number: <int>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Split Dynamic GraphQL Resolution:** `skills/projects/references/github-projects-v2.md` separates board onboarding from card transitions:
|
||||||
|
* **Onboarding (`projects`):** Uses `owner.projectV2(number: $project_number)` to resolve `project_id` for `addProjectV2ItemById` when creating or onboarding new issues not yet on the board.
|
||||||
|
* **Card transitions (`implement`, `verify`):** Uses `issue.projectItems` filtered by `project.number == $project_number` to resolve `project_id`, `status_field_id`, the issue's `PVTI_...` item ID, and target column `option_id`s in a single query matching the canonical 5 column names (`Backlog`, `Ready`, `Work in Progress`, `Review`, `Completed`). This avoids 100-item board pagination limits and fails fast with a clear mismatch error if a board's Status column names do not match.
|
||||||
|
|
||||||
|
**Scoped GitHub remote guard:** Forge-dependent operations (`projects`, `implement`, `verify`, PR publishing in `code-review`, and optional GitHub-state reads in `reconcile-docs`) verify GitHub repository identity via `gh repo view --json url` (supporting SSH host aliases and non-`origin` remotes). Local-only modes (local diff reviews in `code-review`, local git/doc reconciliation in `reconcile-docs`) run without requiring a GitHub remote. If a forge-dependent step fails `gh repo view --json url` or detects a legacy Gitea `AGENTS.md` planning contract, it fails fast advising to migrate the repo to GitHub or use standalone `gt-usage`.
|
||||||
|
|
||||||
|
### Component Architecture & `<= 80`-Line Partitioning
|
||||||
|
|
||||||
|
Every `SKILL.md` acts strictly as an invariant and transition router (`<= 80` lines) with mandatory trigger pointers (`Before <step>, read references/<file>.md`) and `Suggested Next Step: /<skill> <args>` emission on standalone turns (suppressed when delegated to a subagent, per `skills/build-skill/references/skeleton.md`).
|
||||||
|
|
||||||
|
#### 1. `projects` (Replaces `gitea-plan`)
|
||||||
|
|
||||||
|
* **`SKILL.md` (`<= 80` lines):** Outer-loop planning workflow: verify GitHub repo via `gh repo view --json url`, reconcile specs/roadmaps with GitHub Issues and Projects v2 board state (handing off to `reconcile-docs` when docs lag), select ceremony tier (`Small` / `Medium` / `Large`), create/update milestones and vertical-slice issues, run Independent Zero-Context Reproducibility Audit (`Medium`/`Large`), and hand off ready issues to `implement`.
|
||||||
|
* **`references/planning-contract.md` (Sole owner):** `AGENTS.md` `project_number` contract schema, canonical 5-column state machine, transition ownership table, and scoped GitHub remote guard.
|
||||||
|
* **`references/tiers-and-audit.md`:**
|
||||||
|
* `Small` / `Medium` / `Large` ceremony matrix (`Small`: 1-3 issues, single milestone; `Medium`: 4-8 vertical slices + clean-room audit; `Large`: phased milestones + cross-slice dependency map + clean-room audit) and vertical-slice criteria.
|
||||||
|
* Independent Zero-Context Reproducibility Audit checklist: a fresh-context subagent audits `Medium`/`Large` plans with zero prior conversation history to confirm every slice is executable without guesswork, returning an `Auditor Report Schema` (verdict, gaps/ambiguities, and required plan edits).
|
||||||
|
* **`references/github-projects-v2.md` (Sole owner of GitHub planning recipes):** `owner.projectV2(number: $project_number)` onboarding for `addProjectV2ItemById`, `issue.projectItems` (filtered by `project.number == $project_number`) dynamic Node ID resolution, `DATE` and `SINGLE_SELECT` mutations, fixed color enum map, and REST milestone commands (`gh api repos/{owner}/{repo}/milestones`). Referenced by `implement` and `verify` for board moves.
|
||||||
|
|
||||||
|
#### 2. `implement` (Replaces `implement-slice`, Absorbs Decomposition & Ephemeral State)
|
||||||
|
|
||||||
|
* **`SKILL.md` (`<= 80` lines):** Orchestrator loop (mutates only its branch-scoped checkpoint file directly; never writes production code, never writes tests, never performs code review):
|
||||||
|
1. **Preflight:** Verify GitHub repo via `gh repo view --json url`, classify working tree (`CLEAN_BASE`: clean tree on base branch; `EXISTING_SLICE_BRANCH`: clean tree on the target slice's own non-`main` branch with an active checkpoint file or open Draft PR, allowing resume and rework to proceed directly; `ADOPTABLE_DIFF`: uncommitted changes matching the target slice; `CONFLICTING_STATE`: dirty/unrelated changes or mid-merge/rebase, halt; `WRONG_BASE`: branch diverged from expected base, halt/re-branch), create/switch to non-`main` branch or worktree via `git-manager`, and move card `Ready -> Work in Progress`.
|
||||||
|
2. **Step 1 (Delta-Test Decomposition):** Inspect existing tests on affected seams (`covered (keep green)`, `partial/weak (harden)`, `missing (new Red test)`). Auto-skip for trivial `<= 2`-file localized fixes with no new test seam. If `--dry-run`, print plan and halt with zero mutations. Otherwise record slice tasks directly in plain `todo.txt` format (`<task>` / `x YYYY-MM-DD <task>`) inside `$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt` (`branch_slug="${branch//\//__}"`) without invoking `tuxedo`.
|
||||||
|
3. **Execution Loop:** Dispatch adaptive subagents (1-worker fast path for auto-skipped trivial fixes; `test-writer` -> `code-writer` with per-task lint/typecheck, docstrings on new/modified public symbols, `Why:` comments, and affected local markdown updates for multi-task slices), commit 1:1 per completed deliverable via `git-manager`, and mark tasks done in `"$state_file"`.
|
||||||
|
4. **Draft PR & State Cleanup:** Open or sync Draft PR (`gh pr create --draft`, `Closes #<N>`, `Contract Drift: none | <summary>`), delete `"$state_file"`, keep card in `Work in Progress`, and hand off to `code-review`.
|
||||||
|
* **`references/preflight.md` (Sole owner):**
|
||||||
|
* Working-tree classifications (`CLEAN_BASE`, `EXISTING_SLICE_BRANCH`, `ADOPTABLE_DIFF`, `CONFLICTING_STATE`, `WRONG_BASE`) and `--dry-run` contract.
|
||||||
|
* Branch-scoped `$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt` checkpoint lifecycle in plain-text `todo.txt` line format (so external `todo.sh`/`tuxedo` [terminal `todo.txt` CLI/TUI] can inspect it if desired), read/written directly by `implement` without invoking `tuxedo`, and deleted on Draft PR open/sync or explicit abort/escalation to `projects` (halting on `CONFLICTING_STATE` or `WRONG_BASE` leaves existing files untouched).
|
||||||
|
* **`references/decomposition-and-roles.md`:**
|
||||||
|
* Step 1 delta-test rubric and `<= 2`-file fast-path criteria (including bailout to Step 1 if scope grows).
|
||||||
|
* `test-writer` / `code-writer` contracts, 3-4 task worker recycling to prevent context bloat, and 2-turn `test-writer`/`code-writer` deadlock circuit breaker (escalate to human owner or `diagnose`).
|
||||||
|
* Mandatory OS-level non-interactive command wrapper embedded in worker prompts: `setsid timeout -k 10 <N>s <cmd> < /dev/null` with `CI=true`, `GIT_TERMINAL_PROMPT=0`, `PAGER=cat`, and tiered timeouts (60s CLI, 180s unit tests, 600s cold builds).
|
||||||
|
* **`references/pr-and-drift.md` (Sole owner):** Draft PR body template, rework sync rules, and fixed-format `Contract Drift: none | <summary>` marker (where Contract Drift means any implementation deviation from issue acceptance criteria, public interfaces/schemas, `ARCHITECTURE.md`, or `ROADMAP.md` specs).
|
||||||
|
|
||||||
|
#### 3. `code-review` (Upgraded for GitHub, `build_review.py` & Monotonic `CR-XX`)
|
||||||
|
|
||||||
|
* **`SKILL.md` (`<= 80` lines):** Select review tier (`Lightweight`: small localized diffs; `Standard`: multi-file feature slices; `High-Assurance`: security, auth, schema, or >500-line diffs requiring an isolated Axis 3 subagent), run 4-axis audit, and publish whenever invoked on an open GitHub PR (verified via `gh repo view --json url`). When no open PR exists or local-only mode is active, skip PR publishing and explicitly state in output that no open PR was found and findings are reported locally. Route `Needs Rework` -> `implement` (fast path or Step 1) and `Ready` -> `verify`.
|
||||||
|
* **`references/axes.md`:** 4-axis rubric (`Spec & Scope`, `Standards & Smells` with explicit non-documentation-drift checks for missing docstrings, stale comments, lint/format regressions, and affected local markdown, `Seam & Test Integrity`, `Defensive Invariants`) and tier selection criteria.
|
||||||
|
* **`references/finding-schema.md` (Sole owner of finding lifecycle & GitHub PR review API):**
|
||||||
|
* Monotonic `CR-XX` algorithm & `build_review.py` integration: paginate `GET /repos/{owner}/{repo}/pulls/{n}/reviews` and `GET /repos/{owner}/{repo}/pulls/{n}/comments`, extract `max_id` deterministically outside LLM context via `skills/code-review/scripts/build_review.py` parsing `cr-review-meta` markers and `^### CR-(\d+)` headings, and start new findings at `max + 1` (`CR-01`..`CR-99`, `CR-100`).
|
||||||
|
* Duplicate-SHA / pending-review guard keyed on `(head_sha, verdict)` before posting (skip re-posting only when a review with the same `(head_sha, verdict)` already exists, allowing `verdict=ready` to supersede `verdict=needs_rework` on the same commit after Exit B/C triage), plus `max 3 rework-cycle cap` enforcement before human escalation (counted from prior `verdict=needs_rework` `cr-review-meta` entries on the PR).
|
||||||
|
* `POST /repos/{owner}/{repo}/pulls/{n}/reviews` payload built by `build_review.py` (`side: "LEFT"` for deletions, `side: "RIGHT"` for additions/modifications, moving cross-file/missing-file/out-of-hunk findings into `### Findings (Unanchored / Cross-File)` in the review body to prevent `422` errors).
|
||||||
|
* Publish `<!-- cr-review-meta: max_id=NN head_sha=<sha> verdict=ready|needs_rework -->` and collapsible `RV-*` runtime checks (`local` vs. `live-infra`, explicit `FAIL if ...` signals) inside the PR review body.
|
||||||
|
* Findings start in `Pending Triage` (with no `Accepted Trade-off` status) until closed via one of 3 exits: **Exit A** (fix in-branch), **Exit B** (promote to a GitHub Issue, optionally paired with `TODO(#<N>): ...` or `Why:` + ADR link in `docs/decisions/`), or **Exit C** (dismiss as invalid/false positive). Record Exit B (`Promoted to #<N>`) and Exit C (`Dismissed: <reason>`) closures in the superseding `Ready` review body's triage summary so `code-review` emits `verdict=ready` only when zero unresolved `Pending Triage` findings remain.
|
||||||
|
* **`scripts/build_review.py`:** Stdlib-only Python helper validating PR diff hunks, routing unanchorable findings to the review body, formatting `^### CR-NN` headers, extracting `max_id`, and stamping `cr-review-meta`.
|
||||||
|
|
||||||
|
#### 4. `verify` (Replaces `verify-slice` + Closing Half of `gitea-pr`)
|
||||||
|
|
||||||
|
* **`SKILL.md` (`<= 80` lines):** Precondition: existing GitHub PR (verified via `gh repo view --json url`; no manual PR fallback). Structured into 3 linear phases (plus explicit abort invocation via `closeout-and-abort.md` when closing an abandoned/superseded Draft PR):
|
||||||
|
1. **Phase 1 (Read-Only Runtime QA + CI):** Verify latest `cr-review-meta` matches exact current `head_sha` and `verdict=ready` (block and route to `code-review` if missing, stale, or `needs_rework`), execute `RV-*` checks with explicit dispositions, and inspect `gh pr checks` (on red CI, inspect `gh run view --log-failed` and hand off to `diagnose` or `implement`).
|
||||||
|
2. **Phase 2 (Promotion):** Post final Verification Ledger comment, promote PR (`gh pr ready`), and move board card `Work in Progress -> Review` (per `skills/projects/references/github-projects-v2.md`).
|
||||||
|
3. **Phase 3 (Human Merge Gate + Closeout):** Present verification packet for human merge authorization; on approval, merge PR, execute `Review -> Completed` directly via `issue.projectItems`, and chain `reconcile-docs` + `projects` when `Contract Drift: != none`. On human rejection, run `gh pr ready --undo` and move `Review -> Work in Progress`.
|
||||||
|
* **`references/qa-dispositions.md`:** Risk-proportional QA matrix, `local` vs. `live-infra` boundaries, falsifiable `FAIL if ...` format, and 5 dispositions (`PASS`, `FAIL`, `BLOCKED (env/fixture)`, `BLOCKED (out-of-bounds)`, `INCONCLUSIVE`).
|
||||||
|
* **`references/closeout-and-abort.md`:** Verification Ledger comment template, post-merge `Review -> Completed` GraphQL mutation, and abandoned/superseded Draft PR abort path (`gh pr close` + revert board card to `Backlog`, entered only when explicitly invoked to abort a Draft PR).
|
||||||
|
|
||||||
|
#### 5. `reconcile-docs` (Updated for GitHub)
|
||||||
|
|
||||||
|
* **`SKILL.md` (`<= 80` lines):** Preserve local git/doc reconciliation for all repositories; scope optional PR/board ingestion to GitHub via `gh repo view --json url`; update handoffs from `gitea-plan`/`implement-slice` to `projects`/`implement`.
|
||||||
|
* **`references/reconciliation-matrix.md`:** Replace `gt pr` and Gitea tracker commands with `gh pr list --state merged`, `gh api` milestones/reviews, and Projects v2 board inspection.
|
||||||
|
* **`references/doc-contracts.md`:** Replace `implement-slice` Step 1 reference with `implement` preflight.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
|
||||||
|
### Security & Privacy
|
||||||
|
|
||||||
|
* **Public skill repository hygiene:** Zero secrets, tokens, or absolute `/home/<user>` paths anywhere in `kiskaadee/skills` (enforced by contract tests and secret scans).
|
||||||
|
* **Opt-in self-hosted `github_runner` isolation (operational contract for `canopy`):** Repositories opting into `github_runner` must scope it strictly to private repositories (public repos use free GitHub-hosted runners), run `--ephemeral` runners inside isolated containers/VMs with per-job workspace/cache isolation, and enforce egress-only firewall rules blocking RFC1918 homelab LAN access (except DNS) to prevent supply-chain RCE from pivoting across the LAN.
|
||||||
|
|
||||||
|
### Performance, Latency & Token Economics
|
||||||
|
|
||||||
|
* **Skill context budget:** Every `SKILL.md` stays `<= 80` lines; detailed procedures load lazily via explicit `references/` triggers.
|
||||||
|
* **Subagent token & stability bounds:** Trivial `<= 2`-file fixes take the 1-worker fast path (avoiding cold-start overhead). Multi-task slices recycle `test-writer`/`code-writer` every 3-4 tasks to prevent quadratic cumulative token growth and stale-file assumptions. Hard caps stop runaway loops: 2-turn `test-writer`/`code-writer` deadlock breaker and max 3 `code-review -> implement` rework cycles before human escalation.
|
||||||
|
* **`code-review` payload scaling:** Extracting `max_id` deterministically inside `skills/code-review/scripts/build_review.py` keeps raw prior review JSON out of LLM context (`O(1)` token overhead regardless of rework rounds).
|
||||||
|
* **Opt-in homelab runner capacity:** Start opt-in `github_runner` at concurrency 2 with systemd `MemoryMax`/`CPUQuota` caps to prevent parallel Nix/Rust/Docker builds from OOM-killing `server-local`.
|
||||||
|
|
||||||
|
### Rollout & Rollback
|
||||||
|
|
||||||
|
* **Atomic feature-branch cutover:** Implement all new skills (`projects`, `implement`, `verify`, `build_review.py`), retained-skill updates (`code-review`, `reconcile-docs`, `git-manager`, `tdd`, `gt-usage`), legacy deletions (`gitea-plan`, `implement-slice`, `verify-slice`, `gitea-pr`), `OBSOLETE_SKILLS` updates, `install.sh` fixes, and contract tests together on one dedicated feature branch. Run `./install.sh` from that branch and validate one real private-repo slice end-to-end before merging to `main`.
|
||||||
|
* **Rollback:** `install.sh` prunes broken symlinks in `$TARGET_DIR` pointing into `$SCRIPT_DIR/skills/*` and backs up replaced/obsolete skills to a timestamped directory, so `git checkout main && ./install.sh` restores the legacy Gitea loop cleanly with zero dangling symlinks.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Risks & Mitigations
|
||||||
|
|
||||||
|
| Risk / Limit | Impact | Mitigation |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| GitHub PR Review API `422` on deleted/non-diff lines | Wedges `code-review` publishing | `skills/code-review/scripts/build_review.py` enforces `side: "LEFT"` for deletions and moves out-of-hunk/cross-file findings into the top-level review body. |
|
||||||
|
| GitHub API rate limits or large PR pagination | Truncated `CR-XX` scan or GraphQL failure | Paginate `/reviews` and `/comments` via `gh api --paginate` parsed outside LLM context; query `issue.projectItems` directly instead of full-board scans. |
|
||||||
|
| Partial-failure split-brain (PR merged, board move fails) | Card stranded in `Review` | `verify` Phase 3 executes `Review -> Completed` idempotently; re-running `verify` or `projects` reconciles the board state safely. |
|
||||||
|
| Opt-in `github_runner` outage or shared cache poisoning | Private-repo CI blocked >24h or cross-repo leak | Keep GitHub-hosted runners as default; for opt-in `github_runner`, enforce `--ephemeral` isolated caches and document `gh run rerun --failed` (24h unclaimed job limit is a known limit). |
|
||||||
|
| Git worktree state isolation for `implement` checkpoints | Branch collisions or stale state | Store checkpoints at `$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt` (`/` sanitized to `__`), isolated per branch and deleted on Draft PR open or abort. |
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Alternatives Considered
|
||||||
|
|
||||||
|
### Alternative A: Deploy Gitea on a Dedicated Paid VPS
|
||||||
|
|
||||||
|
* **Pros**: Eliminates residential ISP WAN IP lag and homelab power/connectivity outages while keeping existing `gt`-based skills (`gitea-plan`, `gitea-pr`, `implement-slice`) mostly intact.
|
||||||
|
* **Cons**: Adds recurring cloud hosting cost and external server maintenance, while undermining the purpose of operating a homelab for self-hosted services. Still lacks native Projects v2 `DATE` fields and requires maintaining custom `gt` workflows.
|
||||||
|
* **Reason for Rejection**: Contradicts operating a homelab while adding paid hosting overhead; moving planning/PR workflows to GitHub Projects v2 solves uptime without a VPS.
|
||||||
|
|
||||||
|
### Alternative B: 5-Skill Core Loop with Standalone `decompose` and Root `todo.txt` Bus
|
||||||
|
|
||||||
|
* **Pros**: Separates slice planning (`decompose`) from execution (`implement`), and surfaces slice progress in root `todo.txt` and `slice-implementation.md`.
|
||||||
|
* **Cons**: Forces `implement` to support two entry paths, adds a cross-session `slice-implementation.md` artifact, leaks untracked root `todo.txt` across branch switches and worktrees, and requires `verify` to handle post-merge `todo.txt` cleanup.
|
||||||
|
* **Reason for Rejection**: Folding Step 1 decomposition and a branch-scoped `git-common-dir/implement-state` checkpoint into `implement` eliminates `slice-implementation.md`, dual entry paths, and cross-skill `todo.txt` cleanup while keeping the core loop at 4 skills.
|
||||||
|
|
||||||
|
### Alternative C: Dual-Forge Semantic Adapter (`gh-usage` + `gt-usage`) Across All Core Skills
|
||||||
|
|
||||||
|
* **Pros**: Keeps Gitea-hosted repositories as first-class citizens inside `projects`, `implement`, `code-review`, `verify`, and `reconcile-docs` via a shared adapter interface.
|
||||||
|
* **Cons**: GitHub Projects v2 (GraphQL Node IDs, fixed color enums, `line`/`side` inline reviews) and Gitea (`gt` REST CLI, hex colors, `new_position` inline reviews) have structurally different APIs and state machines. Maintaining parity doubles contract-test surface for a forge being retired from active SDLC workflows.
|
||||||
|
* **Reason for Rejection**: Keeping core skills GitHub-native eliminates cross-forge state-machine drift while `gt-usage` remains installed as a standalone utility.
|
||||||
|
|
||||||
|
### Alternative D: Keep a Thin Standalone `gh-usage` Skill
|
||||||
|
|
||||||
|
* **Pros**: Provides a single `/gh-usage` entry point for ad-hoc `gh api` or GraphQL queries outside the 4 core skills, and avoids cross-referencing `skills/projects/references/github-projects-v2.md` from `implement` and `verify`.
|
||||||
|
* **Cons**: Adds an extra skill directory, `install.sh` entry, and contract-test fixture to hold only 3 non-obvious recipes (`Projects v2 GraphQL`, `REST milestones`, and `commit-pinned inline PR reviews`), since standard `gh` CLI flags do not require a dedicated skill.
|
||||||
|
* **Reason for Rejection**: Inlining the 3 `gh api`/GraphQL recipes into `skills/projects/references/` and `skills/code-review/references/` is simpler and aligns with single rule ownership.
|
||||||
|
|
||||||
|
### Alternative E: Rename `git-manager` to `git`
|
||||||
|
|
||||||
|
* **Pros**: Shorter skill name matching the 1-word naming of `projects`, `implement`, and `verify`.
|
||||||
|
* **Cons**: Touches 17+ repository files including 7 completely unrelated skills (`build-skill`, `derive-skill`, `diagnose`, `document`, `inspect-flake-update`, `nix-devshell`, `practice`), solves zero stated pain points, and collides visually and semantically with the `git` CLI binary in prose and slash commands.
|
||||||
|
* **Reason for Rejection**: High cross-repo churn with no functional benefit.
|
||||||
|
|
||||||
|
### Alternative F: Move Board Cards to `Review` Immediately on Draft PR Creation
|
||||||
|
|
||||||
|
* **Pros**: Binary board semantics (`Work in Progress` = coding, `Review` = PR open), without waiting for `verify` to promote the PR.
|
||||||
|
* **Cons**: Places cards in `Review` while autonomous `code-review`, CI, and rework loops are still mutating the branch, adding merge-queue noise and requiring reverse `Review -> Work in Progress` transitions on rework.
|
||||||
|
* **Reason for Rejection**: Keeping Draft PRs in `Work in Progress` and moving `Work in Progress -> Review` only on `gh pr ready` keeps `Review` as a dedicated human merge queue.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Future Improvements
|
||||||
|
|
||||||
|
* **`gitea-to-github` migration skill:** Dedicated follow-up skill for on-demand per-repo migration (mirror inversion, Gitea-to-GitHub issue migration, and legacy `AGENTS.md` conversion, plus a stale-contract check in `profile/AGENTS.md` once available).
|
||||||
|
* **Educational release-planner skill:** Future skill combining `projects` + `practice` scoped to the release stage (comparing SemVer/CalVer/GitHub Releases/Nix flake pins, flagging over-engineering, and guiding a first manual release) before building an automated `release` skill.
|
||||||
|
* **`diagnose` post-mortem note suggestion:** Minor independent enhancement prompting `diagnose` to suggest capturing root-cause findings via `document`.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Detailed Implementation Plan
|
||||||
|
|
||||||
|
All changes execute atomically on a dedicated feature branch created from `main` before editing. No implementation code is included here; every file path below defines the exact behavioral scope and rationale.
|
||||||
|
|
||||||
|
### Target Files to Create, Modify, or Delete
|
||||||
|
|
||||||
|
#### New Skill: `projects` (Replaces `gitea-plan`)
|
||||||
|
1. **`skills/projects/SKILL.md` (Create)**
|
||||||
|
* **Type / Scope**: Portable Skill (`<= 80` lines, follows `skills/build-skill/references/skeleton.md`).
|
||||||
|
* **Proposed Changes**: Outer-loop GitHub planning workflow: verify GitHub repo via `gh repo view --json url`, reconcile specs/roadmaps with GitHub Issues and Projects v2, select ceremony tier, manage milestones/due dates and vertical-slice issues, trigger Independent Zero-Context Reproducibility Audit on `Medium`/`Large`, hand off ready slices to `implement` or lagging docs to `reconcile-docs`, and emit `Suggested Next Step:` on standalone turns (suppressed when delegated).
|
||||||
|
2. **`skills/projects/references/planning-contract.md` (Create)**
|
||||||
|
* **Type / Scope**: Skill Reference (sole owner of board state machine & `AGENTS.md` schema).
|
||||||
|
* **Proposed Changes**: Define the state-free `AGENTS.md` YAML planning contract (`project_number: <int>`), the canonical 5-column board state machine (`Backlog -> Ready -> Work in Progress -> Review -> Completed`), transition owners, and the scoped `gh repo view --json url` remote check (detecting legacy Gitea contracts).
|
||||||
|
3. **`skills/projects/references/tiers-and-audit.md` (Create)**
|
||||||
|
* **Type / Scope**: Skill Reference.
|
||||||
|
* **Proposed Changes**: Port of `skills/gitea-plan/references/decomposition-tiers.md` adapted to GitHub Issues and Projects v2 (`Small`/`Medium`/`Large` ceremony matrix, vertical-slice criteria, Independent Zero-Context Reproducibility Audit, and Auditor Report Schema).
|
||||||
|
4. **`skills/projects/references/github-projects-v2.md` (Create)**
|
||||||
|
* **Type / Scope**: Skill Reference (sole owner of GitHub Projects v2 & milestone recipes).
|
||||||
|
* **Proposed Changes**: Document `gh api graphql` recipes for `owner.projectV2(number: $project_number)` + `addProjectV2ItemById` onboarding, `issue.projectItems` dynamic Node ID resolution, `DATE` and `SINGLE_SELECT` status updates, the fixed 5-column color enum map (`GRAY`, `BLUE`, `YELLOW`, `PURPLE`, `GREEN`), and REST milestone operations (`gh api repos/{owner}/{repo}/milestones`).
|
||||||
|
|
||||||
|
#### New Skill: `implement` (Replaces `implement-slice`, Absorbs Step 1 Decomposition & Ephemeral State)
|
||||||
|
5. **`skills/implement/SKILL.md` (Create)**
|
||||||
|
* **Type / Scope**: Portable Skill (`<= 80` lines, follows `skills/build-skill/references/skeleton.md`).
|
||||||
|
* **Proposed Changes**: Orchestrator loop (mutates only its branch-scoped checkpoint file directly):
|
||||||
|
* Run preflight (`gh repo view --json url`, working-tree classification, non-`main` branch/worktree via `git-manager`, `Ready -> Work in Progress`).
|
||||||
|
* Run Step 1 delta-test decomposition (auto-skipped for `<= 2`-file localized fixes; halts on `--dry-run`).
|
||||||
|
* Execute adaptive worker loop (`1-worker` fast path vs. `test-writer`/`code-writer`) with 1:1 commits and `$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt` checkpointing.
|
||||||
|
* Open/sync Draft PR (`gh pr create --draft`), delete the state file, keep card in `Work in Progress`, and emit `Suggested Next Step: /code-review` (suppressed when delegated).
|
||||||
|
6. **`skills/implement/references/preflight.md` (Create)**
|
||||||
|
* **Type / Scope**: Skill Reference (sole owner of preflight & checkpoint schema).
|
||||||
|
* **Proposed Changes**: Carry forward `CLEAN_BASE`, `EXISTING_SLICE_BRANCH`, `ADOPTABLE_DIFF`, `CONFLICTING_STATE`, `WRONG_BASE` classifications and `--dry-run` zero-mutation contract. Define `$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt` (`branch_slug="${branch//\//__}"`) checkpoint rules: plain-text `todo.txt` format (append line and `x YYYY-MM-DD ` completion prefix) read/written directly without invoking `tuxedo`, and deletion on Draft PR open/sync or abort.
|
||||||
|
7. **`skills/implement/references/decomposition-and-roles.md` (Create)**
|
||||||
|
* **Type / Scope**: Skill Reference.
|
||||||
|
* **Proposed Changes**:
|
||||||
|
* Define Step 1 delta-test classification (`covered`, `partial/weak`, `missing`) and `<= 2`-file fast-path criteria (including bailout to Step 1 if scope grows).
|
||||||
|
* Define `test-writer` and `code-writer` contracts (per-task lint/typecheck, docstrings on new/modified public symbols, `Why:` comments, and affected local markdown), plus 3-4 task worker recycling and the 2-turn `test-writer`/`code-writer` deadlock circuit breaker.
|
||||||
|
* Embed mandatory OS-level non-interactive command wrapping (`setsid timeout -k 10 <N>s <cmd> < /dev/null`, `CI=true`, `GIT_TERMINAL_PROMPT=0`, `PAGER=cat`) with tiered timeouts (60s CLI, 180s unit tests, 600s cold builds) directly in worker prompts.
|
||||||
|
8. **`skills/implement/references/pr-and-drift.md` (Create)**
|
||||||
|
* **Type / Scope**: Skill Reference (sole owner of Draft PR body & drift marker).
|
||||||
|
* **Proposed Changes**: Define Draft PR body template (`Closes #<N>`, scope summary, rework sync rules) and fixed-format `Contract Drift: none | <summary>` marker read by `verify`.
|
||||||
|
|
||||||
|
#### New Skill: `verify` (Replaces `verify-slice` + Closing Half of `gitea-pr`)
|
||||||
|
9. **`skills/verify/SKILL.md` (Create)**
|
||||||
|
* **Type / Scope**: Portable Skill (`<= 80` lines, follows `skills/build-skill/references/skeleton.md`).
|
||||||
|
* **Proposed Changes**: Require an existing GitHub PR verified via `gh repo view --json url` (no manual PR fallback, zero `todo.txt` responsibility). Linear 3-phase flow plus explicit abort invocation and `Suggested Next Step:` routing (suppressed when delegated):
|
||||||
|
* Phase 1: Verify `cr-review-meta` matches exact `head_sha` with `verdict=ready`, run `RV-*` runtime QA, inspect `gh pr checks` / `gh run view --log-failed`.
|
||||||
|
* Phase 2: Post Verification Ledger, run `gh pr ready`, move `Work in Progress -> Review` (per `skills/projects/references/github-projects-v2.md`).
|
||||||
|
* Phase 3: Human merge gate, merge PR, execute `Review -> Completed` directly, chain `reconcile-docs` + `projects` when `Contract Drift != none`.
|
||||||
|
10. **`skills/verify/references/qa-dispositions.md` (Create)**
|
||||||
|
* **Type / Scope**: Skill Reference.
|
||||||
|
* **Proposed Changes**: Port risk-proportional black-box QA perspectives, `local` vs. `live-infra` boundaries, falsifiable `FAIL if ...` format, 5 explicit dispositions (`PASS`, `FAIL`, `BLOCKED (env/fixture)`, `BLOCKED (out-of-bounds)`, `INCONCLUSIVE`), and stale-`head_sha` / `needs_rework` block rule.
|
||||||
|
11. **`skills/verify/references/closeout-and-abort.md` (Create)**
|
||||||
|
* **Type / Scope**: Skill Reference.
|
||||||
|
* **Proposed Changes**: Define the Verification Ledger comment template, post-merge `Review -> Completed` GraphQL mutation (referencing `skills/projects/references/github-projects-v2.md`), and the abandoned/superseded Draft PR abort path (`gh pr close` + revert board card to `Backlog`, entered only when explicitly invoked to abort a Draft PR).
|
||||||
|
|
||||||
|
#### Updated Retained Skills & Repository Documentation
|
||||||
|
12. **`skills/code-review/SKILL.md` (Modify)**
|
||||||
|
* **Type / Scope**: Portable Skill (`<= 80` lines).
|
||||||
|
* **Proposed Changes**: Replace `implement-slice`/`verify-slice`/`gitea-pr` with `implement`/`verify`; remove delegation PR-skip rule (publish whenever invoked on an open GitHub PR verified via `gh repo view --json url`; skip only when no open PR exists or in local-only mode, explicitly stating in output that no open PR was found and findings are reported locally); remove `Accepted Trade-off` references and restrict Exit B to GitHub issues only (no `todo.txt` / Gitea); document the `build_review.py` CLI workflow (`--input`, `--diff`, `--reviews`, `--comments`, `--head-sha`, `--verdict` piped to `gh api repos/{owner}/{repo}/pulls/{n}/reviews --input -`) and split rework routing.
|
||||||
|
13. **`skills/code-review/references/axes.md` (Modify)**
|
||||||
|
* **Type / Scope**: Skill Reference.
|
||||||
|
* **Proposed Changes**: Replace Gitea issue, `todo.txt`, `gitea-pr`, `verify-slice`, and `Accepted Trade-off` references with GitHub issue and `verify` equivalents; add explicit code-hygiene checks (missing docstrings on new/modified public symbols, stale inline comments, lint/format regressions, affected local markdown) under `Standards & Smells` / `Spec & Scope`.
|
||||||
|
14. **`skills/code-review/references/finding-schema.md` (Modify)**
|
||||||
|
* **Type / Scope**: Skill Reference (sole owner of `CR-XX` lifecycle & GitHub PR review API).
|
||||||
|
* **Proposed Changes**:
|
||||||
|
* Replace all remaining `verify-slice`, `implement-slice`, `gitea-pr`, `gitea-plan`, `gt issue`, `gt pr review`, `new_position`, and `todo.txt` (`tuxedo add`) references with GitHub equivalents (`verify`, `implement`, `projects`, GitHub issues).
|
||||||
|
* Specify `POST /repos/{owner}/{repo}/pulls/{n}/reviews` payload built via `skills/code-review/scripts/build_review.py` (`--input`, `--diff`, `--reviews`, `--comments`, `--head-sha`, `--verdict`, consuming `gh api --paginate --slurp` JSON) and piped to `gh api repos/{owner}/{repo}/pulls/{n}/reviews --input -`, plus `3-rework-cycle cap` ownership.
|
||||||
|
* Define the input findings schema (`findings[]` with `path`, `line`, `side`, `severity`, `title`, `body`; optional `rv_checks[]` and `triage_closures[]`), `<!-- cr-review-meta: max_id=NN head_sha=<sha> verdict=ready|needs_rework -->`, collapsible `RV-*` block in review body, and remove `Accepted Trade-off` (3 exits: fix in-branch, promote to GitHub Issue, or dismiss as invalid/false positive).
|
||||||
|
15. **`skills/code-review/scripts/build_review.py` (Create)**
|
||||||
|
* **Type / Scope**: Stdlib-only Python Helper Script.
|
||||||
|
* **Proposed Changes**:
|
||||||
|
* **CLI:** `--input <findings.json> --diff <pr.diff> --reviews <reviews.json> --comments <comments.json> --head-sha <sha> --verdict <ready|needs_rework>`.
|
||||||
|
* **Pagination & Exit Codes:** Flatten `gh api --paginate --slurp` (`[[...]]` and `[...]`) inputs; exit `0` emitting GitHub PR review JSON (`{"commit_id", "event": "COMMENT", "body", "comments": [{"path", "line", "side", "body"}]}`) to stdout, exit `2` on duplicate `(head_sha, verdict)` skip, and exit `1` on invalid input or `3-rework-cycle cap` reached.
|
||||||
|
* **Behavior:** Extract `max_id` from `cr-review-meta` and `### CR-(\d+)` headings, validate `(path, line, side)` against PR diff hunks (`side: "LEFT"` for deletions, `"RIGHT"` for additions/modifications), move out-of-hunk/cross-file findings into `### Findings (Unanchored / Cross-File)` in `body`, format `### CR-NN` headers, and stamp `cr-review-meta`.
|
||||||
|
16. **`skills/reconcile-docs/SKILL.md` (Modify)**
|
||||||
|
* **Type / Scope**: Portable Skill (`<= 80` lines).
|
||||||
|
* **Proposed Changes**: Preserve local git/doc reconciliation on all repos; scope optional PR/board reads to GitHub via `gh repo view --json url`; update handoffs from `gitea-plan`/`implement-slice` to `projects`/`implement`.
|
||||||
|
17. **`skills/reconcile-docs/references/reconciliation-matrix.md` (Modify)**
|
||||||
|
* **Type / Scope**: Skill Reference.
|
||||||
|
* **Proposed Changes**: Replace `gt pr` and Gitea tracker commands with `gh pr list --state merged`, `gh api` milestones/reviews, and Projects v2 board inspection.
|
||||||
|
18. **`skills/reconcile-docs/references/doc-contracts.md` (Modify)**
|
||||||
|
* **Type / Scope**: Skill Reference.
|
||||||
|
* **Proposed Changes**: Replace `implement-slice` Step 1 reference with `implement` preflight.
|
||||||
|
19. **`skills/git-manager/SKILL.md` (Modify)**
|
||||||
|
* **Type / Scope**: Portable Skill (`<= 80` lines).
|
||||||
|
* **Proposed Changes**: Update `gitea-pr` references to `implement` and `verify`. Keep skill name `git-manager` unchanged.
|
||||||
|
20. **`skills/tdd/SKILL.md` (Modify)**
|
||||||
|
* **Type / Scope**: Portable Skill (`<= 80` lines).
|
||||||
|
* **Proposed Changes**: Update `verify-slice` references to `verify`.
|
||||||
|
21. **`skills/gt-usage/SKILL.md` (Modify)**
|
||||||
|
* **Type / Scope**: Portable Skill (`<= 80` lines).
|
||||||
|
* **Proposed Changes**: Document standalone ad-hoc Gitea utility role outside the GitHub core delivery loop; remove `gitea-plan` and `gitea-pr` handoff references.
|
||||||
|
22. **`README.md` (Modify)**
|
||||||
|
* **Type / Scope**: Repository Documentation.
|
||||||
|
* **Proposed Changes**: Update skill table, delivery workflow overview, and CLI prerequisites (`gh` primary, `gt` optional standalone) to match the 4-skill GitHub loop.
|
||||||
|
23. **`profile/AGENTS.md` (Modify)**
|
||||||
|
* **Type / Scope**: Global User Profile Rule.
|
||||||
|
* **Proposed Changes**: Update line 19 wording (`"creating a batch of Gitea issues"` -> `"creating a batch of GitHub issues"`).
|
||||||
|
|
||||||
|
#### Legacy Retirement, Installer & Test Harness (Atomic on Feature Branch)
|
||||||
|
24. **`skills/gitea-plan/` (Delete)**
|
||||||
|
* **Type / Scope**: Retired Legacy Skill Directory.
|
||||||
|
* **Proposed Changes**: Remove `SKILL.md`, `references/decomposition-tiers.md`, and `references/tea-cli.md`.
|
||||||
|
25. **`skills/implement-slice/` (Delete)**
|
||||||
|
* **Type / Scope**: Retired Legacy Skill Directory.
|
||||||
|
* **Proposed Changes**: Remove `SKILL.md`, `references/handoff-contracts.md`, and `references/orchestration-tiers.md`.
|
||||||
|
26. **`skills/verify-slice/` (Delete)**
|
||||||
|
* **Type / Scope**: Retired Legacy Skill Directory.
|
||||||
|
* **Proposed Changes**: Remove `SKILL.md` and `references/perspectives.md`.
|
||||||
|
27. **`skills/gitea-pr/` (Delete)**
|
||||||
|
* **Type / Scope**: Retired Legacy Skill Directory.
|
||||||
|
* **Proposed Changes**: Remove `SKILL.md`, `references/gt-pulls.md`, `references/pr-lifecycle.md`, and `references/tea-pulls.md`.
|
||||||
|
28. **`install.sh` (Modify)**
|
||||||
|
* **Type / Scope**: Shell Installer Script.
|
||||||
|
* **Proposed Changes**: Update `ACTIVE_PORTABLE_SKILLS` (add `projects`, `implement`, `verify`; remove `gitea-plan`, `implement-slice`, `verify-slice`, `gitea-pr`) and append all 4 retired names to `OBSOLETE_SKILLS`. Remove the stale `gt` / legacy-skill warning block from `check_prerequisites()` (keeping only the `git` check; NixOS provides `gh` declaratively). Fix line 112 so `./install.sh check` exits `1` when `missing > 0`. Add repo-scoped dangling-symlink pruning to remove broken symlinks in `$TARGET_DIR` pointing into `$SCRIPT_DIR/skills/*`.
|
||||||
|
29. **`tests/fixtures/test_skills_behavioral_contracts.py` & `tests/fixtures/test_build_review.py` (Modify / Create)**
|
||||||
|
* **Type / Scope**: Python Behavioral Contract & Helper Test Suites.
|
||||||
|
* **Proposed Changes**:
|
||||||
|
* Update `EXPECTED_SKILLS` and assert the 4 retired skills appear in `OBSOLETE_SKILLS`.
|
||||||
|
* Retire `WorkflowNode` 5-tuples, dynamic Mermaid projection, `WorkflowEngine` mocks (removing the 6 `WorkflowEngine`-dependent methods: `test_proportionality_scaling`, `test_feature_verification_canonical_schema`, `test_security_invariants`, `test_rework_routing`, `test_deviation_reporting`, `test_dry_run_zero_mutation`), `test_prerequisite_guidance`, Gitea time-tracking (`started_at`, `/times`), and Gitea `#RRGGBB` hex color assertions.
|
||||||
|
* Update all 8 legacy test blocks: `test_resource_id_querying_rules` (`skills/projects/`), `test_review_comment_publishing_ownership` (`code-review` + `implement`), `test_project_board_reconciliation_and_card_transitions` (`projects` + `implement` + `verify` + `code-review` read-only board), `test_reconcile_docs_gitea_ingestion_and_hooks` -> `test_reconcile_docs_github_ingestion_and_hooks` (`gh` read-only + `projects`/`implement`), `test_repo_scoped_documentation_and_vault_deprecation` (`skills/projects/` + `skills/implement/`), `test_skeleton_defines_suggested_next_step_suppression` (`skills/implement/SKILL.md`), `test_chained_skills_include_suggested_next_step_routing` (`("projects", "implement", "tdd", "code-review", "verify", "reconcile-docs")`), and `test_subagent_provenance_output_slot_guards` (`skills/code-review/SKILL.md` + `skills/code-review/references/finding-schema.md` for Axis 3, and `skills/projects/references/tiers-and-audit.md`).
|
||||||
|
* Add contract assertions for: `projects` `project_number` contract and dynamic `owner.projectV2` / `issue.projectItems` state machine; `implement` preflight classifications, `--dry-run`, `$(git rev-parse --git-common-dir)/implement-state/` plain-text `todo.txt`-format checkpointing (without `tuxedo`), and `setsid timeout`; `code-review` `build_review.py` `CR-XX`, `cr-review-meta` `verdict`, `RV-*` in review body, and no-PR announcement; `verify` 3-phase flow, zero `todo.txt`, `Work in Progress -> Review` on `gh pr ready`, and post-merge `Review -> Completed`; and `install.sh check` exit code + dangling-symlink pruning.
|
||||||
|
* Add `tests/fixtures/test_build_review.py` covering `--paginate --slurp` flattening (`[[...]]`/`[...]`), `side: "LEFT"`/`"RIGHT"`, diff-hunk validation, unanchorable body fallback, `max_id` extraction, and exit codes (`0`, `2`, `1`).
|
||||||
|
30. **`tests/fixtures/run_regression.sh` (Modify)**
|
||||||
|
* **Type / Scope**: Regression Runner Script.
|
||||||
|
* **Proposed Changes**: Update Step 2 (`run_regression.sh:21`) to run `python3 -m unittest "${SCRIPT_DIR}/test_skills_behavioral_contracts.py" "${SCRIPT_DIR}/test_build_review.py" -v`, and update Step 3 `grep -q` assertions to check `"Independent Zero-Context Reproducibility Audit"` and `"Auditor Report Schema"` in `skills/projects/references/tiers-and-audit.md`, `"CLEAN_BASE"` in `skills/implement/references/preflight.md`, `"cr-review-meta"` in `skills/code-review/references/finding-schema.md`, and `"Move issue card between columns"` in `skills/gt-usage/references/commands.md`.
|
||||||
|
|
||||||
|
### Verification Plan
|
||||||
|
|
||||||
|
* **Installer Isolated Dry-Run**: Run `./install.sh --target /tmp/skills-test-target` followed by `./install.sh --target /tmp/skills-test-target check` (must exit `0`), and test a missing/obsolete target directory with `./install.sh --target /tmp/skills-bad-target check` (must exit `1`).
|
||||||
|
* **Behavioral Contract & Helper Unit Suites**: `python3 -m unittest tests/fixtures/test_skills_behavioral_contracts.py tests/fixtures/test_build_review.py -v` (must pass).
|
||||||
|
* **Full Regression Harness**: `./tests/fixtures/run_regression.sh` (must exit `0` after local `./install.sh`).
|
||||||
|
* **Static Hygiene & Secret Scan**: `test_skills_behavioral_contracts.py` enforces `<= 80` lines per `SKILL.md`, zero em-dashes, and zero `/home/<user>` paths; run `rg -n '(ghp_|gho_|github_pat_|BEGIN .*PRIVATE KEY|Bearer )' skills/` (must return zero matches).
|
||||||
|
* **Feature-Branch Live E2E Gate (Before Merge to `main`)**: Install from the feature branch via `./install.sh`, execute one full vertical slice (`projects` -> `implement` -> `code-review` -> `verify`) on a real private GitHub repository, and verify Draft PR creation, `build_review.py` monotonic `CR-XX` across a rework pass, `gh pr ready` + `Work in Progress -> Review`, and merge + `Review -> Completed`.
|
||||||
+17
-19
@@ -33,11 +33,11 @@ while [[ $# -gt 0 ]]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Active skills to install
|
# Active skills to install
|
||||||
ACTIVE_PORTABLE_SKILLS=(build-skill code-review derive-skill diagnose document git-manager gitea-plan gitea-pr gt-usage implement-slice inspect-flake-update nix-devshell practice reconcile-docs tdd verify-slice)
|
ACTIVE_PORTABLE_SKILLS=(build-skill code-review derive-skill diagnose document git-manager gitea-to-github gt-usage implement inspect-flake-update nix-devshell practice projects reconcile-docs tdd verify)
|
||||||
ACTIVE_EXTENSION_SKILLS=()
|
ACTIVE_EXTENSION_SKILLS=()
|
||||||
|
|
||||||
# Legacy / deprecated skills to clean up or back up if found in target
|
# Legacy / deprecated skills to clean up or back up if found in target
|
||||||
OBSOLETE_SKILLS=(engineering-tutor engineering-investigation skill-builder documentation-router inbox-curation commit-logger git-commit git-workspace journal-builder draft-curation)
|
OBSOLETE_SKILLS=(engineering-tutor engineering-investigation skill-builder documentation-router inbox-curation commit-logger git-commit git-workspace journal-builder draft-curation gitea-plan implement-slice verify-slice gitea-pr)
|
||||||
OBSOLETE_AGENTS=(anne-droid.md)
|
OBSOLETE_AGENTS=(anne-droid.md)
|
||||||
|
|
||||||
check_prerequisites() {
|
check_prerequisites() {
|
||||||
@@ -46,22 +46,6 @@ check_prerequisites() {
|
|||||||
echo " [ERROR] git is required but not found in PATH." >&2
|
echo " [ERROR] git is required but not found in PATH." >&2
|
||||||
status=1
|
status=1
|
||||||
fi
|
fi
|
||||||
if ! command -v gt >/dev/null 2>&1; then
|
|
||||||
echo " [WARNING] 'gt' CLI not found in PATH." >&2
|
|
||||||
echo " Gitea skills (gt-usage, gitea-plan, gitea-pr, implement-slice) require the official Gitea CLI (v1.0.0+)." >&2
|
|
||||||
echo " Install via package manager or download from https://gitea.com/gitea/cli/releases" >&2
|
|
||||||
else
|
|
||||||
local missing_subcommands=()
|
|
||||||
for sub in issue milestone project pr; do
|
|
||||||
if ! gt "$sub" --help >/dev/null 2>&1; then
|
|
||||||
missing_subcommands+=("$sub")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ ${#missing_subcommands[@]} -gt 0 ]]; then
|
|
||||||
echo " [WARNING] 'gt' CLI found but lacks required capabilities: ${missing_subcommands[*]}" >&2
|
|
||||||
echo " Update gt to the official release (https://gitea.com/gitea/cli)." >&2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
return "$status"
|
return "$status"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,8 +92,9 @@ if [[ "$CHECK_ONLY" -eq 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
if [[ "$missing" -eq 0 ]]; then
|
if [[ "$missing" -eq 0 ]]; then
|
||||||
echo "All active skills are present."
|
echo "All active skills are present."
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare backup directory timestamp if needed
|
# Prepare backup directory timestamp if needed
|
||||||
@@ -144,6 +129,19 @@ for a in "${OBSOLETE_AGENTS[@]}"; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Prune repo-scoped dangling symlinks in target directory
|
||||||
|
for entry in "$TARGET_DIR"/*; do
|
||||||
|
if [[ -L "$entry" && ! -e "$entry" ]]; then
|
||||||
|
link_target="$(readlink "$entry")"
|
||||||
|
case "$link_target" in
|
||||||
|
"$SCRIPT_DIR/skills/"*)
|
||||||
|
rm -f "$entry"
|
||||||
|
echo " [PRUNED] dangling symlink $(basename "$entry") -> $link_target"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Install portable skills
|
# Install portable skills
|
||||||
for s in "${ACTIVE_PORTABLE_SKILLS[@]}"; do
|
for s in "${ACTIVE_PORTABLE_SKILLS[@]}"; do
|
||||||
src="$SCRIPT_DIR/skills/$s"
|
src="$SCRIPT_DIR/skills/$s"
|
||||||
|
|||||||
+7
-3
@@ -16,7 +16,7 @@ whether I really understood something), don't make it for me:
|
|||||||
- **Independent architectural decisions** (system boundaries, trade-offs, merge vs rework,
|
- **Independent architectural decisions** (system boundaries, trade-offs, merge vs rework,
|
||||||
schema or model changes, doc destinations): Frame the choice clearly with 2-3 concrete options,
|
schema or model changes, doc destinations): Frame the choice clearly with 2-3 concrete options,
|
||||||
your recommendation listed first and marked "(Recommended)", one decision at a time.
|
your recommendation listed first and marked "(Recommended)", one decision at a time.
|
||||||
- **Homogeneous operational checkpoints** (creating a batch of Gitea issues, approving
|
- **Homogeneous operational checkpoints** (creating a batch of GitHub issues, approving
|
||||||
multi-item curation or routine task batches): Orchestrators may structure multi-choice
|
multi-item curation or routine task batches): Orchestrators may structure multi-choice
|
||||||
prompts for batch approval, provided each option exposes both the concrete action and its
|
prompts for batch approval, provided each option exposes both the concrete action and its
|
||||||
consequence, consequential or destructive actions are never collapsed into a blanket
|
consequence, consequential or destructive actions are never collapsed into a blanket
|
||||||
@@ -68,14 +68,18 @@ whether I really understood something), don't make it for me:
|
|||||||
- Active codebases and workspaces resolve under:
|
- Active codebases and workspaces resolve under:
|
||||||
- `~/Projects/active/` (active tools and applications)
|
- `~/Projects/active/` (active tools and applications)
|
||||||
- `~/Projects/tests/` (benchmarks, experiments, and spikes)
|
- `~/Projects/tests/` (benchmarks, experiments, and spikes)
|
||||||
- `~/Homelab/` Shared space for Homelab's Core and Sites repositories
|
- `~/Projects/active/canopy/` Operational single source of truth for the Homelab appliance (`server-local`, `nixos-core`, and `canopy-workloads`; replaces deprecated `~/Homelab/`)
|
||||||
- `~/Config/` (system and NixOS configuration)
|
- `~/Config/` (system and NixOS configuration)
|
||||||
- When resolving a project from task context, search these workspace roots before asking the user.
|
- When resolving a project from task context, search these workspace roots before asking the user.
|
||||||
- To create new projects or repositories, always use `new-repo` (source: `~/Projects/active/new-repo`). It supports organization targeting (`-o`), GitHub push mirroring, licenses, and templates.
|
- To create new projects or repositories, always use `new-repo` (source: `~/Projects/active/new-repo`). It supports organization targeting (`-o`), Gitea pull mirroring (`--gitea-mirror`), `--empty`, licenses, and templates.
|
||||||
|
|
||||||
## Homelab and connectivity
|
## Homelab and connectivity
|
||||||
|
|
||||||
- Sovereign Gitea origin lives at `gitea.roadtotech.me` (hosted on `server-local` at `192.168.1.36`).
|
- Sovereign Gitea origin lives at `gitea.roadtotech.me` (hosted on `server-local` at `192.168.1.36`).
|
||||||
|
- **Session-start Gitea-origin check (zero-network, local only):** Inspect `git remote get-url origin` (or `git remote -v`). If `origin` points to `gitea.roadtotech.me`:
|
||||||
|
- Skip if repo `AGENTS.md` declares `forge: gitea` or `git config --bool gitea.sovereign` is `true`.
|
||||||
|
- If repo `AGENTS.md` already contains `project_number:`, warn that local `origin` still points to Gitea and advise flipping `origin` to GitHub via `git-manager`.
|
||||||
|
- Otherwise, inform the user that the repository uses Gitea as `origin` and suggest running `/gitea-to-github`.
|
||||||
- For `gt` (Gitea CLI) repository discovery against sovereign SSH remote on port 2223:
|
- For `gt` (Gitea CLI) repository discovery against sovereign SSH remote on port 2223:
|
||||||
- Run `gt config set ssh_host gitea.roadtotech.me:2223 --host https://gitea.roadtotech.me` so `gt` maps SSH remotes like `ssh://git@gitea.roadtotech.me:2223/...` to `https://gitea.roadtotech.me`.
|
- Run `gt config set ssh_host gitea.roadtotech.me:2223 --host https://gitea.roadtotech.me` so `gt` maps SSH remotes like `ssh://git@gitea.roadtotech.me:2223/...` to `https://gitea.roadtotech.me`.
|
||||||
- If `gitea.roadtotech.me` or `roadtotech.me` times out with `dial tcp ...:443: i/o timeout`:
|
- If `gitea.roadtotech.me` or `roadtotech.me` times out with `dial tcp ...:443: i/o timeout`:
|
||||||
|
|||||||
+60
-29
@@ -1,47 +1,78 @@
|
|||||||
---
|
---
|
||||||
name: code-review
|
name: code-review
|
||||||
description: >-
|
description: >-
|
||||||
Inspects git diffs, pull requests, and commit ranges across four independent
|
Inspects git diffs, GitHub pull requests, and commit ranges across four
|
||||||
axes: Spec & Scope, Standards & Smells, Seam & Test Integrity, and Defensive
|
independent axes: Spec & Scope, Standards & Smells, Seam & Test Integrity,
|
||||||
Invariants. Use when reviewing code changes before merge or verifying diff
|
and Defensive Invariants. Use when reviewing code changes before merge or
|
||||||
quality. Not for live runtime QA: use verify-slice.
|
verifying diff quality. Not for live runtime QA: use verify.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Code Review
|
# Code Review
|
||||||
|
|
||||||
## Use when
|
## Use when
|
||||||
- Reviewing a branch, pull request, work-in-progress diff, or commit range before merge.
|
- Reviewing a branch, open GitHub PR, work-in-progress diff, or commit range.
|
||||||
- Evaluating code structure, defensive invariants, and test seam integrity.
|
- Evaluating code structure, hygiene, defensive invariants, and test seams.
|
||||||
- Not for live runtime browser or deployment testing: use `verify-slice`.
|
- Not for live runtime QA, CI promotion, or merge: use `verify`.
|
||||||
- Not for debugging an unknown symptom: use `diagnose`.
|
- Not for debugging an unknown symptom: use `diagnose`.
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
1. **Pin the fixed point and scope.** Resolve the base ref and record exact base and head commit SHAs (`git rev-parse <base> HEAD`). Inspect working-tree state (`git status --short`, unstaged `git diff`, staged `git diff --cached`, and relevant untracked files) alongside committed history (`git diff <base>...HEAD` and `git log <base>..HEAD --oneline`). Record the covered revisions and working-tree diff state (for example, clean tree or diff fingerprint) so downstream tools can verify whether the reviewed diff remained unchanged, and distinguish findings across committed, staged, and unstaged changes.
|
Keep the codebase strictly read-only: never edit repository files, create
|
||||||
2. **Select execution tier.** Match the change to the risk tiers from [axes](references/axes.md) (`Lightweight`, `Standard`, or `High-Assurance`). Single-agent sequential pass for `Lightweight`; independent review passes for `Standard`; for `High-Assurance`, never run `Sequential` or a single combined subagent: spawn a dedicated isolated Axis 3 (`Seam & Test Integrity`) subagent separate from Axes 1/2/4 and record both subagent IDs in `Execution Mode`.
|
commits, or mutate GitHub Projects v2 board cards.
|
||||||
3. **Inspect the four axes.** Evaluate the diff against each axis independently using [axes](references/axes.md):
|
|
||||||
- **Spec & Scope**: originating requirements satisfied, aligned with canonical project direction (`ARCHITECTURE.md`, `ROADMAP.md`, ADRs, active milestone) when present, minimal shared-file footprint, zero scope creep.
|
1. **Pin the fixed point and scope.** Resolve `<base>` and `HEAD` SHAs
|
||||||
- **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).
|
(`git rev-parse <base> HEAD`). Inspect working-tree state (`git status --short`,
|
||||||
- **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).
|
unstaged `git diff`, staged `git diff --cached`, relevant untracked files)
|
||||||
- **Defensive Invariants**: system properties from [defensive-invariants](references/defensive-invariants.md) (trust boundaries, authority, consistency, failure semantics, resource limits).
|
and committed history (`git diff <base>...HEAD`, `git log <base>..HEAD --oneline`).
|
||||||
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.
|
2. **Select execution tier.** Before inspecting, read [axes](references/axes.md)
|
||||||
5. **Aggregate without silent resolution.** When multiple reviewers or passes disagree, keep the disagreement visible under `Unresolved` until evidence settles it.
|
and assign `Lightweight`, `Standard`, or `High-Assurance`. For `High-Assurance`,
|
||||||
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).
|
never run `Sequential` or a single combined subagent: spawn a dedicated isolated
|
||||||
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.
|
Axis 3 (`Seam & Test Integrity`) subagent separate from Axes 1/2/4 and record
|
||||||
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`.
|
both subagent IDs in `Execution Mode`.
|
||||||
|
3. **Inspect the four axes independently.**
|
||||||
|
- **Spec & Scope**: issue/spec satisfaction, alignment with canonical docs
|
||||||
|
(`ARCHITECTURE.md`, `ROADMAP.md`, ADRs), minimal shared-file footprint,
|
||||||
|
and affected local markdown accuracy.
|
||||||
|
- **Standards & Smells**: repo rules, [smell-heuristics](references/smell-heuristics.md),
|
||||||
|
missing docstrings on new/modified public symbols, stale inline comments,
|
||||||
|
and lint/format regressions.
|
||||||
|
- **Seam & Test Integrity**: audit test diffs against
|
||||||
|
[seams-and-mocking](../tdd/references/seams-and-mocking.md) and
|
||||||
|
[test-quality](../tdd/references/test-quality.md).
|
||||||
|
- **Defensive Invariants**: [defensive-invariants](references/defensive-invariants.md)
|
||||||
|
(trust boundaries, authority, consistency, failure semantics, resource limits).
|
||||||
|
4. **Record findings and executable runtime checks.** Before formatting output
|
||||||
|
or publishing, read [finding-schema](references/finding-schema.md). Valid
|
||||||
|
findings start in `Pending Triage` (never self-dismiss). Keep disagreements
|
||||||
|
under `Unresolved`. Emit runnable `RV-*` checks (`local` vs. `live-infra`,
|
||||||
|
explicit `FAIL if ...` signals) for stateful or high-risk paths.
|
||||||
|
5. **Determine verdict and publish on open GitHub PRs.** Apply [axes](references/axes.md)
|
||||||
|
(`Needs Rework`, `Blocked`, `Pending Triage`, `Ready`). Verify GitHub repo via
|
||||||
|
`gh repo view --json url` and check for an open PR on `HEAD`. Whenever an open
|
||||||
|
GitHub PR exists (standalone or delegated), build the payload via
|
||||||
|
`skills/code-review/scripts/build_review.py --input ... --diff ... --reviews ... --comments ... --head-sha <sha> --verdict <ready|needs_rework>`
|
||||||
|
and pipe stdout to `gh api repos/{owner}/{repo}/pulls/{n}/reviews --input -`.
|
||||||
|
Handle exit `2` (duplicate `(head_sha, verdict)` skip) and exit `1`
|
||||||
|
(`3-rework-cycle cap` escalation). When no open PR exists or in local-only mode,
|
||||||
|
skip publishing and explicitly state in output that no open PR was found and
|
||||||
|
findings are reported locally.
|
||||||
|
|
||||||
## 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 `Ready`)**: choose Exit A (fix in-branch),
|
||||||
- **Publishing findings**: approve the drafted review body, inline list, and follow-up routes before `code-review` posts to the PR.
|
Exit B (promote to a GitHub Issue), or Exit C (dismiss as invalid/false positive).
|
||||||
- **Adjudicating unresolved disagreements**: resolve conflicting reviewer perspectives or accepted architectural trade-offs.
|
- **Escalations and disagreements**: adjudicate `Unresolved` findings or a
|
||||||
- **Authorizing release**: verification and review evidence inform decisions, but the human owner remains the sole release authority.
|
`3-rework-cycle cap` halt.
|
||||||
|
- **Release authority**: static provenance never authorizes merge or release.
|
||||||
|
|
||||||
## Done when
|
## Done when
|
||||||
- All four axes have been inspected across working-tree and committed changes, every finding is recorded with evidence and disposition, executable Step 6 runtime checks are emitted for `verify-slice` if needed, and the human owner has reviewed the findings.
|
- All four axes are inspected, findings and `RV-*` checks are recorded, and the
|
||||||
|
review is published to the open GitHub PR (or explicitly reported locally when
|
||||||
|
no open PR exists).
|
||||||
|
|
||||||
## Hands off to
|
## Hands off to
|
||||||
- `tdd`: when Axis 3 fails (`Suggested Next Step: /tdd <affected-test-files>`) or production rework needs test-first fixes (`Suggested Next Step: /tdd <module-or-test-path>`).
|
- `implement`: on `Needs Rework` (`<= 2`-file localized fixes take the fast path;
|
||||||
|
complex rework enters Step 1; `Suggested Next Step: /implement #<issue>`).
|
||||||
|
- `verify`: on `Ready` (`Suggested Next Step: /verify`).
|
||||||
|
- `tdd`: when Axis 3 fails (`Suggested Next Step: /tdd <affected-test-files>`).
|
||||||
- `diagnose`: when a finding exposes an unknown root cause (`Suggested Next Step: /diagnose`).
|
- `diagnose`: when a finding exposes an unknown root cause (`Suggested Next Step: /diagnose`).
|
||||||
- `verify-slice`: when `Ready` and runtime/`RV-*` checks are needed (`Suggested Next Step: /verify-slice`).
|
- Emit one outcome-matched `Suggested Next Step:` on standalone turns; suppress
|
||||||
- `git-manager`: when branching, committing review fixes, or rebasing.
|
when delegated per [skeleton](../build-skill/references/skeleton.md).
|
||||||
- `gitea-pr`: when `Ready` on an open PR with clean runtime checks (`Suggested Next Step: /gitea-pr <pr-or-issue>`).
|
|
||||||
- Emit one outcome-matched `Suggested Next Step` on standalone turns; suppress when delegated (per [skeleton](../build-skill/references/skeleton.md)).
|
|
||||||
@@ -8,49 +8,47 @@ Derived and adapted from Matt Pocock's skills repository (github.com/mattpocock/
|
|||||||
|
|
||||||
| Axis | Primary Question | Failure Mode Caught | Core Inspection Questions |
|
| Axis | Primary Question | Failure Mode Caught | Core Inspection Questions |
|
||||||
| :--- | :--- | :--- | :--- |
|
| :--- | :--- | :--- | :--- |
|
||||||
| **Spec & Scope** | Did we build what was requested, aligned with project direction, and only that? | Scope creep, missing requirements, architectural or roadmap drift, leaky abstractions | 1. Does the diff satisfy the originating issue or specification contract?<br/>2. When canonical direction docs exist (`ARCHITECTURE.md`, `ROADMAP.md`, ADRs, or active milestone scope), does the change align with long-term boundaries and trajectory?<br/>3. Is there unrequested functionality or premature generalization?<br/>4. Are changes to shared entrypoints (e.g., routers, base config) minimal and additive? |
|
| **Spec & Scope** | Did we build what was requested, aligned with project direction, and only that? | Scope creep, missing requirements, architectural or roadmap drift, stale local docs | 1. Does the diff satisfy the originating GitHub issue or specification contract?<br/>2. When canonical direction docs exist (`ARCHITECTURE.md`, `ROADMAP.md`, ADRs, or active milestone scope), does the change align with long-term boundaries and trajectory?<br/>3. Is there unrequested functionality or premature generalization?<br/>4. Are changes to shared entrypoints minimal and additive, and are affected local markdown files updated when behavior or interfaces change? |
|
||||||
| **Standards & Smells** | Is the implementation maintainable and consistent? | Structural debt, friction with conventions | 1. Does the code adhere to repo standards (`CODING_STANDARDS.md`, linter configs)?<br/>2. Are code smells present that warrant refactoring? (See [smell-heuristics](smell-heuristics.md)).<br/>3. Is naming clear and aligned with domain vocabulary? |
|
| **Standards & Smells** | Is the implementation maintainable, hygienic, and consistent? | Structural debt, missing docstrings, stale comments, lint/format regressions | 1. Does the code adhere to repo standards (`CODING_STANDARDS.md`, linter and formatter configs) with zero lint/format regressions?<br/>2. Are new or modified public symbols documented with clear docstrings, and are inline comments accurate (no stale comments contradicting the new code)?<br/>3. Are code smells present that warrant refactoring? (See [smell-heuristics](smell-heuristics.md)).<br/>4. Is naming clear and aligned with domain vocabulary? |
|
||||||
| **Seam & Test Integrity** | Do tests prove actual contracts at public interfaces? | Tautological tests, implementation coupling, boundary gaps, flaky waits | Audit against [seams-and-mocking](../../tdd/references/seams-and-mocking.md) and [test-quality](../../tdd/references/test-quality.md):<br/>1. Public seams only; boundary mocks only; injected timing/clock callables instead of global runtime monkeypatching; deterministic waits and guaranteed teardown.<br/>2. Non-tautological assertions with independent literals (no imported production value constants), exact+neighbor boundary points (`[min-1, min, max, max+1]`), and single-behavior test names (no vague buckets or `_and_` chains). |
|
| **Seam & Test Integrity** | Do tests prove actual contracts at public interfaces? | Tautological tests, implementation coupling, boundary gaps, flaky waits | Audit against [seams-and-mocking](../../tdd/references/seams-and-mocking.md) and [test-quality](../../tdd/references/test-quality.md):<br/>1. Public seams only; boundary mocks only; injected timing/clock callables instead of global runtime monkeypatching; deterministic waits and guaranteed teardown.<br/>2. Non-tautological assertions with independent literals (no imported production value constants), exact+neighbor boundary points (`[min - 1, min, max, max + 1]`), and single-behavior test names (no vague buckets or `_and_` chains). |
|
||||||
| **Defensive Invariants** | Does the code preserve critical system properties under stress? | Injection, state desync, unhandled crashes | 1. Are untrusted inputs sanitized before reaching sinks? (See [defensive-invariants](defensive-invariants.md)).<br/>2. Does state reconcile against authoritative sources rather than local heuristic drift?<br/>3. Are failure semantics, timeouts, and resource limits explicit? |
|
| **Defensive Invariants** | Does the code preserve critical system properties under stress? | Injection, state desync, unhandled crashes | 1. Are untrusted inputs sanitized before reaching sinks? (See [defensive-invariants](defensive-invariants.md)).<br/>2. Does state reconcile against authoritative sources rather than local heuristic drift?<br/>3. Are failure semantics, timeouts, and resource limits explicit? |
|
||||||
|
|
||||||
### Non-Compensation Invariant
|
### Non-Compensation Invariant
|
||||||
A strong pass on one axis never excuses a failure on another:
|
A strong pass on one axis never excuses a failure on another:
|
||||||
- Clean abstractions and zero code smells cannot excuse an unescaped HTML sink or an unhandled conflict.
|
- Clean abstractions and zero code smells cannot excuse an unescaped HTML sink or an unhandled conflict.
|
||||||
- 100% test coverage cannot excuse unrequested feature drift, architectural direction drift, or broken domain invariants.
|
- 100% test coverage cannot excuse unrequested feature drift, architectural direction drift, or broken domain invariants.
|
||||||
- Strict spec compliance cannot excuse fragile code structure that breaks repository conventions.
|
- Strict spec compliance cannot excuse fragile code structure, missing public docstrings, or lint regressions that break repository conventions.
|
||||||
|
|
||||||
## 2. Review Recommendations Matrix
|
## 2. Review Recommendations Matrix
|
||||||
|
|
||||||
The distinction between recommendations is clear: `Needs Rework` means an established defect requires implementation or test changes; `Blocked` means the review cannot establish sufficient confidence or scope to proceed safely.
|
The distinction between recommendations is clear: `Needs Rework` means an established defect requires implementation or test changes; `Blocked` means the review cannot establish sufficient confidence or scope to proceed safely.
|
||||||
|
|
||||||
| Condition Observed | Final Recommendation | Action Required |
|
| Condition Observed | Final Recommendation | Published `verdict` | Action Required |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- | :--- |
|
||||||
| **Confirmed Critical or High** | `Needs Rework` | Fix confirmed defects before release review. |
|
| **Confirmed Critical or High** | `Needs Rework` | `needs_rework` | Fix confirmed defects on the branch via `implement` before `verify`. |
|
||||||
| **Confirmed Medium or Low requiring changes** | `Needs Rework` | Apply requested refactoring or test coverage fixes. |
|
| **Confirmed or Unresolved Medium or Low (untriaged)** | `Pending Triage` | `needs_rework` | Do not promote or merge. Human owner chooses 1 of 3 exits per finding: Exit A (fix in-branch), Exit B (promote to a GitHub Issue), or Exit C (dismiss as invalid/false positive). |
|
||||||
| **Unresolved Critical or High** | `Blocked` | Resolve missing evidence or escalate to human owner before proceeding. |
|
| **Unresolved Critical or High** | `Blocked` | `needs_rework` | 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` | (local halt) | Establish base commit and diff boundaries before reviewing. |
|
||||||
| **Scope Inability or Missing Base Ref** | `Blocked` | Establish base commit and diff boundaries before reviewing. |
|
| **Zero Untriaged Findings** | `Ready` | `ready` | All findings resolved in-branch, promoted to a GitHub Issue (Exit B), or dismissed as invalid/false positive (Exit C). Route to `verify`. |
|
||||||
| **No Blocking Findings** | `Ready` | Implementation is structurally sound; proceed to `verify-slice` or release. |
|
|
||||||
|
|
||||||
### `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-dismissal**: Every valid finding (including `Low` severity) starts in `Pending Triage` as `Confirmed` (or `Unresolved`), producing `Pending Triage` or `Needs Rework` (`verdict=needs_rework`) rather than `Ready`.
|
||||||
|
- **`Pending Triage` blocks `verify` promotion**: A review qualifies as `Ready` (`verdict=ready`) for `verify` only after every finding has taken one of the three explicit exits: Exit A (fixed in a new commit on the branch), Exit B (promoted to a GitHub Issue and recorded as `Promoted to #<N>` in the superseding `Ready` review's triage summary), or Exit C (dismissed as invalid/false positive and recorded as `Dismissed: <reason>` in the superseding `Ready` review's triage summary).
|
||||||
### Documented Trade-Off Acceptance
|
- A `Ready` review establishes static provenance for that exact `head_sha`; it does not substitute for runtime verification in `verify` 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
|
||||||
|
|
||||||
To keep review overhead proportional to risk, execution mode reuses the tiers established in `verify-slice`:
|
To keep review overhead proportional to risk, execution mode aligns with the risk tiers used in `verify`:
|
||||||
|
|
||||||
| Review Risk Tier | Typical Change | Review Execution Strategy |
|
| Review Risk Tier | Typical Change | Review Execution Strategy |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| **Lightweight** | Copy updates, styling adjustments, isolated bugfixes with no new state or untrusted data. | Single-agent sequential pass inspecting all 4 axes in order. |
|
| **Lightweight** | Small localized diffs, copy updates, styling adjustments, isolated bugfixes with no new state or untrusted data. | Single-agent sequential pass inspecting all 4 axes in order. |
|
||||||
| **Standard** | New UI components, regular API endpoints, database queries, or schema additions. | Independent review passes over the diff. Subagents may be used when helpful to prevent bias. |
|
| **Standard** | Multi-file feature slices, new UI components, regular API endpoints, database queries, or schema additions. | Independent review passes over the diff. Subagents may be used when helpful to prevent bias. |
|
||||||
| **High-Assurance** | Auth, permissions, payments, concurrent state reconciliation, destructive actions, or core shared libraries. | Assign a dedicated isolated reviewer to **Seam & Test Integrity** (Axis 3, auditing test diffs against `tdd/references/`), separate from `Spec & Scope` + `Defensive Invariants` and `Standards & Smells`, followed by independent aggregation. |
|
| **High-Assurance** | Security, auth, permissions, payments, schema migrations, concurrent state reconciliation, destructive actions, core shared libraries, or >500-line diffs. | Assign a dedicated isolated reviewer to **Seam & Test Integrity** (Axis 3, auditing test diffs against `tdd/references/`), separate from `Spec & Scope` + `Defensive Invariants` and `Standards & Smells`, followed by independent aggregation. |
|
||||||
|
|
||||||
## 4. Aggregation and Anti-Silence Rules
|
## 4. Aggregation and Anti-Silence Rules
|
||||||
|
|
||||||
When multiple passes or subagents inspect a change:
|
When multiple passes or subagents inspect a change:
|
||||||
1. **Never silently resolve disagreements**: If Reviewer A flags a pattern as a defect and Reviewer B considers it acceptable, record the finding under `Unresolved` with both perspectives cited. The human owner adjudicates.
|
1. **Never silently resolve disagreements**: If Reviewer A flags a pattern as a defect and Reviewer B considers it acceptable, record the finding under `Unresolved` with both perspectives cited. The human owner adjudicates.
|
||||||
2. **Preserve exact evidence**: Every finding must include exact file paths, line numbers, and code snippets demonstrating the condition.
|
2. **Preserve exact evidence**: Every finding must include exact file paths, line numbers, and code snippets demonstrating the condition.
|
||||||
3. **Emit executable runtime checks**: Where static analysis cannot verify dynamic timing, rendering, or network failure modes, formulate runnable Step 6 checks formatted per [finding-schema](finding-schema.md) and pass them to `verify-slice`.
|
3. **Emit executable runtime checks**: Where static analysis cannot verify dynamic timing, rendering, or network failure modes, formulate runnable `RV-*` checks formatted per [finding-schema](finding-schema.md) so `verify` can execute them from the published PR review body.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Finding Schema and Review Output
|
# Finding Schema and GitHub PR Review Output
|
||||||
|
|
||||||
Reference for `code-review`. Defines the required structure for reporting findings, ensuring every note is actionable, evidence-backed, and auditable.
|
Reference for `code-review`. Sole owner of the `CR-XX` finding lifecycle, the `build_review.py` payload contract, and GitHub PR review publishing.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@@ -10,40 +10,45 @@ Every reported finding must populate all seven fields:
|
|||||||
|
|
||||||
| Field | Description | Allowed Values / Format |
|
| Field | Description | Allowed Values / Format |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| **ID** | Stable identifier within this review. | `CR-01`, `CR-02`, etc. |
|
| **ID** | Monotonic per-PR identifier across all review passes. | `CR-01`..`CR-99`, `CR-100`, etc. (assigned deterministically by `build_review.py`). |
|
||||||
| **Axis** | The review axis that uncovered the finding. | `Spec & Scope`, `Standards & Smells`, `Seam & Test Integrity`, `Defensive Invariants`. |
|
| **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). |
|
| **Severity** | Potential failure consequence if the defect occurs. Describes impact, not reviewer confidence. | `Critical` (security breach, data loss, fatal crash), `High` (broken invariant, missing spec requirement), `Medium` (code smell, fragile logic, missing edge test), `Low` (minor style, docstring, or naming issue). |
|
||||||
| **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. |
|
| **Evidence** | Exact location, change category, and reproducible behavior. | Distinguishes committed, staged, or unstaged state: e.g. `src/view.ts:L45 (committed)` with excerpt. |
|
||||||
| **Invariant** | The requirement, contract, or system property violated. | Clear statement of expectation (e.g., "Untrusted DOM values must be escaped before interpolation"). |
|
| **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>`"). |
|
| **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. | `Pending Triage` / `Confirmed` (proven defect backed by evidence), `Unresolved` (open disagreement or missing evidence), `Dismissed` (invalid or false positive, Exit C). |
|
||||||
|
|
||||||
## 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. **Every valid finding starts in `Pending Triage`**: On a review pass, every valid finding (even `Low` severity) must be logged as `Confirmed` (or `Unresolved`) in `Pending Triage`. Never silently waive findings or self-dismiss defects.
|
||||||
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. `Blocked` vs. `Pending Triage` vs. `Ready`)**:
|
||||||
3. **Rejected vs. Accepted Trade-off**:
|
- `Confirmed Critical` or `Confirmed High` -> `Needs Rework` (`verdict=needs_rework`).
|
||||||
- `Rejected`: The finding was an invalid concern or disproven by facts.
|
- `Unresolved Critical` or `Unresolved High` -> `Blocked` (`verdict=needs_rework`).
|
||||||
- `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` (`verdict=needs_rework`; never promote or merge while untriaged findings remain).
|
||||||
Both remain in the ledger for full audit traceability.
|
- Zero unresolved `Pending Triage` findings remain -> `Ready` (`verdict=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 finding cannot be left behind in a closed PR thread. Prompt the human owner to choose one exit per finding before `Ready`:
|
||||||
|
- **Exit A (`fix-in-branch`)**: Fix the finding on the PR branch (`implement` fast path for `<= 2`-file localized fixes, `implement` Step 1 for complex rework, or `tdd` + `git-manager`) and re-run `code-review`.
|
||||||
|
- **Exit B (`github-issue`)**: Promote the finding to a GitHub Issue (`gh issue create` or `projects`), optionally paired with `TODO(#<N>): ...` or a `Why:` comment + ADR link in `docs/decisions/`. Record `Promoted to #<N>` in the superseding `Ready` review body's `triage_closures[]` summary.
|
||||||
|
- **Exit C (`dismiss`)**: Dismiss the finding as invalid or a false positive. Record `Dismissed: <reason>` in the superseding `Ready` review body's `triage_closures[]` summary.
|
||||||
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
|
||||||
|
|
||||||
The final review summary presented to the user must follow this structure:
|
The review summary presented to the user must follow this structure:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
# Code Review Summary: <branch or commit range>
|
# Code Review Summary: <branch or commit range>
|
||||||
|
|
||||||
## Overview & Scope State
|
## Overview & Scope State
|
||||||
- **Base Commit**: `<base-ref>` (`<base-commit-sha>`) -> `<HEAD>` (`<head-commit-sha>`)
|
- **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)
|
- **Covered Working-Tree State**: `Clean` | Staged, unstaged, and relevant untracked summary plus content fingerprint
|
||||||
- **Assigned Risk Tier**: `Lightweight` | `Standard` | `High-Assurance`
|
- **Assigned Risk Tier**: `Lightweight` | `Standard` | `High-Assurance`
|
||||||
- **Execution Mode**: `Sequential` (`Lightweight` only) | `Independent Passes` (`Standard`) | `Subagent Reviewers` (`High-Assurance` mandatory: Axes 1/2/4 subagent `<id>`, Dedicated Axis 3 Tests subagent `<id>`)
|
- **Execution Mode**: `Sequential` (`Lightweight` only) | `Independent Passes` (`Standard`) | `Subagent Reviewers` (`High-Assurance` mandatory: Axes 1/2/4 subagent `<id>`, Dedicated Axis 3 Tests subagent `<id>`)
|
||||||
|
|
||||||
## Findings Ledger
|
## Findings Ledger
|
||||||
|
|
||||||
### Confirmed Findings (Needs Rework)
|
### Confirmed Findings (Pending Triage / Needs Rework)
|
||||||
| ID | Axis | Severity | State | Location | Invariant Violated | Impact |
|
| 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 |
|
| CR-01 | Defensive Invariants | Critical | Committed | `src/view.ts:L45` | Unescaped dynamic HTML sink | DOM XSS via attendee name |
|
||||||
@@ -51,132 +56,135 @@ The final review summary presented to the user must follow this structure:
|
|||||||
### Unresolved Disagreements / Material Risks (Blocked if Critical/High)
|
### Unresolved Disagreements / Material Risks (Blocked if Critical/High)
|
||||||
| ID | Axis | Severity | Location | Competing Perspectives / Open Risk | Decision Needed |
|
| 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 |
|
| CR-02 | Standards & Smells | Medium | `src/api.ts:L110` | Reviewer A flags Primitive Obsession; Author notes single call site. | Fix in-branch, promote to GitHub Issue, or dismiss |
|
||||||
|
|
||||||
### Accepted Trade-offs & Rejected Findings (Audit Traceability)
|
### Triage Closures (Exit B / Exit C Audit Trail)
|
||||||
| ID | Axis | Disposition | Location | Rationale / Decision |
|
| ID | Exit | Resolution |
|
||||||
| :--- | :--- | :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| CR-03 | Spec & Scope | Rejected | `src/main.ts:L12` | Suspected scope creep confirmed as required wiring for acceptance criterion 2. |
|
| CR-03 | Exit B | Promoted to #45 |
|
||||||
| CR-04 | Standards & Smells | Accepted Trade-off | `scripts/seed.py:L10` | Inlined script logic accepted to keep utility independent of core module. |
|
| CR-04 | Exit C | Dismissed: false positive on test fixture |
|
||||||
|
|
||||||
## Axis Breakdown
|
## Axis Breakdown
|
||||||
- **Spec & Scope**: Pass/Fail summary. Notes on scope containment and shared entrypoints across working-tree and commits.
|
- **Spec & Scope**: Pass/Fail summary, scope containment, shared entrypoints, and affected local markdown.
|
||||||
- **Standards & Smells**: Adherence to repo conventions and Fowler smell diagnostics.
|
- **Standards & Smells**: Repo conventions, docstrings on new/modified public symbols, inline comment accuracy, lint/format hygiene, and Fowler smell diagnostics.
|
||||||
- **Seam & Test Integrity**: Evaluation of test boundaries, tautological assertions, and vertical slice evidence.
|
- **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.
|
- **Defensive Invariants**: Status of trust boundaries, authority, consistency, failure semantics, and resource limits.
|
||||||
|
|
||||||
## Executable Runtime Checks for verify-slice
|
## Executable Runtime Checks for verify
|
||||||
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:
|
Every candidate runtime check must be directly consumable by `verify` from the published PR review body without reinterpreting narrative prose. Commands assume execution from the repository root with repository-relative paths. Each entry requires:
|
||||||
- **Purpose** in the check header (`Check RV-XX: <purpose>`).
|
- **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)`).
|
- **Scope**: `local` (safe workstation or isolated fixture execution) or `live-infra` (touches privileged permissions, host state, or external/production infrastructure; requires explicit human owner authorization in `verify`, otherwise recorded as `BLOCKED (out-of-bounds)`).
|
||||||
- **Pass Condition**: explicit observable output or state transition.
|
- **Pass Condition**: explicit observable output or state transition.
|
||||||
- **Failure Signal**: explicit contradiction condition.
|
- **Failure Signal**: explicit `FAIL if ...` contradiction condition.
|
||||||
- **Command**: copy-pasteable fenced shell block.
|
- **Command**: copy-pasteable fenced shell block.
|
||||||
|
|
||||||
### Check RV-01: Out-of-band conflict handling on concurrent submission
|
### Check RV-01: Out-of-band conflict handling on concurrent submission
|
||||||
- **Scope**: `local`
|
- **Scope**: `local`
|
||||||
- **Pass Condition**: First request returns HTTP `200`; concurrent duplicate returns HTTP `409` with JSON code `conflict` and persisted count increments by `1`.
|
- **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`.
|
- **Failure Signal**: `FAIL if` duplicate returns `200` or `500`, unhandled traceback occurs, or persisted count increments by `2`.
|
||||||
```sh
|
```sh
|
||||||
./scripts/test-concurrency-check.sh --endpoint /api/check-in
|
./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.
|
|
||||||
```sh
|
|
||||||
systemctl reload app-daemon.service && systemctl is-active --quiet app-daemon.service
|
|
||||||
```
|
|
||||||
|
|
||||||
## 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.
|
- **PR Publishing**: Published review URL (or explicit notice: `No open GitHub PR found; findings reported locally.`)
|
||||||
|
- **Next Action**: Route `Needs Rework` to `implement` (`<= 2`-file fast path or Step 1), `Pending Triage` to owner triage (Exit A / Exit B / Exit C), or `Ready` to `verify`. Static provenance never 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. GitHub PR Review Publishing via `build_review.py`
|
||||||
|
|
||||||
`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 GitHub Projects v2 boards). Whenever invoked on an open GitHub PR (verified via `gh repo view --json url`), whether standalone or delegated, build the review payload deterministically with `skills/code-review/scripts/build_review.py` and publish one comment-only review pinned to `head_sha`.
|
||||||
|
|
||||||
### What goes in
|
If no open PR exists for `HEAD` (or when running in local-only mode), skip PR publishing and explicitly state in the report that no open PR was found and findings are reported locally.
|
||||||
- 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.
|
|
||||||
|
|
||||||
### Per-finding routing (proposed here, decided by the owner)
|
### Input Schema (`--input <findings.json>`)
|
||||||
| 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
|
Write temporary scratch files outside the repository tree (for example under `/tmp/cr-review-$$/`):
|
||||||
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>.
|
|
||||||
```
|
|
||||||
|
|
||||||
`review-body.md` (clean `Ready` review with zero non-rejected findings; omit `inline-comments.json`):
|
|
||||||
```markdown
|
|
||||||
**Code review @ `<short-head-sha>`** (`<base-ref>`..`<head-ref>`): `Ready`
|
|
||||||
|
|
||||||
Covered state: `<Clean | fingerprint>`. Tier: `<tier>`. Static provenance only; merge authority stays with the owner.
|
|
||||||
|
|
||||||
| Axis | Disposition |
|
|
||||||
| :--- | :--- |
|
|
||||||
| Spec & Scope | Pass |
|
|
||||||
| Standards & Smells | Pass |
|
|
||||||
| Seam & Test Integrity | Pass |
|
|
||||||
| Defensive Invariants | Pass |
|
|
||||||
|
|
||||||
No non-rejected findings.
|
|
||||||
```
|
|
||||||
|
|
||||||
`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):
|
|
||||||
```json
|
```json
|
||||||
[
|
{
|
||||||
{
|
"base_ref": "main",
|
||||||
"path": "src/pkg/config.py",
|
"head_ref": "feat/example",
|
||||||
"new_position": 40,
|
"covered_state": "Clean",
|
||||||
"body": "**CR-01** (Low, Accepted Trade-off, record): <invariant and impact>. <Suggested change>."
|
"tier": "Standard",
|
||||||
}
|
"findings": [
|
||||||
]
|
{
|
||||||
|
"path": "src/pkg/config.py",
|
||||||
|
"line": 40,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Medium",
|
||||||
|
"axis": "Standards & Smells",
|
||||||
|
"title": "Missing public docstring",
|
||||||
|
"body": "Invariant, impact, and suggested change."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rv_checks": [
|
||||||
|
{
|
||||||
|
"id": "RV-01",
|
||||||
|
"purpose": "Out-of-band conflict handling",
|
||||||
|
"scope": "local",
|
||||||
|
"pass_condition": "Duplicate returns HTTP 409",
|
||||||
|
"fail_signal": "FAIL if duplicate returns 200 or 500",
|
||||||
|
"command": "./scripts/test-concurrency-check.sh"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"triage_closures": [
|
||||||
|
{
|
||||||
|
"id": "CR-01",
|
||||||
|
"exit": "B",
|
||||||
|
"resolution": "Promoted to #45"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
- `findings[]` is required (may be `[]` on a clean `Ready` pass). Each finding requires non-empty strings `severity`, `title`, and `body`.
|
||||||
|
- `path`, `line`, and `side` (`"LEFT"` for deleted lines in the diff, `"RIGHT"` for added, modified, or context lines) are validated against `--diff`. Any finding that is cross-file (`path: null`), targets a missing file, or falls outside a diff hunk is automatically moved into `### Findings (Unanchored / Cross-File)` in the review `body` to prevent GitHub `422 Unprocessable Entity` errors.
|
||||||
|
- `rv_checks[]` (optional) renders inside a collapsible `<details>` block in the review `body` so `verify` can recover all `RV-*` checks in a fresh session.
|
||||||
|
- `triage_closures[]` (optional) renders a `### Triage Summary` section recording Exit B (`Promoted to #<N>`) and Exit C (`Dismissed: <reason>`) closures on a superseding `Ready` review.
|
||||||
|
|
||||||
### Publishing via `gt pr review` (After Owner Approval)
|
### Monotonic `CR-XX`, Guards, and `cr-review-meta`
|
||||||
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:
|
|
||||||
|
`skills/code-review/scripts/build_review.py` parses paginated prior reviews and inline comments outside LLM context:
|
||||||
|
1. **Pagination flattening**: Consumes `gh api --paginate --slurp` (`[[...]]`) or flat (`[...]`) JSON arrays for both `--reviews` and `--comments`.
|
||||||
|
2. **Monotonic `max_id`**: Extracts the maximum integer across every `<!-- cr-review-meta: max_id=NN ... -->` marker and `^### CR-(\d+)` heading in prior reviews and inline comments. New findings start at `max_id + 1` (`CR-01`..`CR-99`, `CR-100`).
|
||||||
|
3. **Duplicate `(head_sha, verdict)` guard**: If a prior review already has the exact same `(head_sha, verdict)`, `build_review.py` exits `2` with no stdout JSON (skip re-posting). A `verdict=ready` review on the same `head_sha` is allowed to supersede an earlier `verdict=needs_rework` review after Exit B/C triage.
|
||||||
|
4. **3-rework-cycle cap**: Counts prior `cr-review-meta` entries with `verdict=needs_rework`. If 3 or more already exist and `--verdict needs_rework` is requested, `build_review.py` exits `1` with an escalation message on stderr; halt and escalate to the human owner.
|
||||||
|
5. **Metadata stamp**: Appends `<!-- cr-review-meta: max_id=NN head_sha=<sha> verdict=ready|needs_rework -->` to the emitted review `body`. `verify` reads this marker to confirm `verdict=ready` matches the current PR `head_sha`.
|
||||||
|
|
||||||
|
### Publishing Workflow (`gh api`)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Staleness: the PR head must equal the reviewed head SHA. Mismatch: stop, re-run code-review.
|
# 1. Verify GitHub repository identity and resolve open PR number + head_sha
|
||||||
gt pr view <number> --json head_sha -q .head_sha
|
gh repo view --json url -q .url
|
||||||
|
pr_num=$(gh pr view --json number -q .number)
|
||||||
|
head_sha=$(gh pr view "$pr_num" --json headRefOid -q .headRefOid)
|
||||||
|
repo=$(gh repo view --json nameWithOwner -q .nameWithOwner)
|
||||||
|
|
||||||
# 2. Duplicates and pending state: stop if any review is PENDING (posting would publish its
|
# 2. Fetch PR diff and paginated review/comment history to scratch files
|
||||||
# inline comments too) or if a review already exists for the reviewed SHA from this block.
|
scratch=$(mktemp -d)
|
||||||
gt pr review list <number> --json id,state,commit,body
|
gh pr diff "$pr_num" > "$scratch/pr.diff"
|
||||||
|
gh api --paginate --slurp "repos/${repo}/pulls/${pr_num}/reviews" > "$scratch/reviews.json"
|
||||||
|
gh api --paginate --slurp "repos/${repo}/pulls/${pr_num}/comments" > "$scratch/comments.json"
|
||||||
|
|
||||||
# 3. After owner approval: one comment-only review, pinned to the reviewed commit.
|
# 3. Build validated GitHub PR review JSON (exits 0=post, 2=duplicate skip, 1=error/3-cycle cap)
|
||||||
gt pr review <number> --comment --commit <reviewed-head-sha> \
|
if payload=$(python3 skills/code-review/scripts/build_review.py \
|
||||||
-F review-body.md --comments-file inline-comments.json --json id,url
|
--input "$scratch/findings.json" \
|
||||||
|
--diff "$scratch/pr.diff" \
|
||||||
# Body-only block (no inline entries): omit --comments-file.
|
--reviews "$scratch/reviews.json" \
|
||||||
|
--comments "$scratch/comments.json" \
|
||||||
|
--head-sha "$head_sha" \
|
||||||
|
--verdict "$verdict"); then
|
||||||
|
printf '%s\n' "$payload" | gh api "repos/${repo}/pulls/${pr_num}/reviews" --input - --jq '{id, html_url}'
|
||||||
|
else
|
||||||
|
rc=$?
|
||||||
|
# rc == 2: duplicate (head_sha, verdict) already published; skip cleanly
|
||||||
|
# rc == 1: invalid input or 3-rework-cycle cap reached; escalate to human owner
|
||||||
|
fi
|
||||||
|
rm -rf "$scratch"
|
||||||
```
|
```
|
||||||
|
|
||||||
- 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).
|
- `build_review.py` always emits `"event": "COMMENT"` pinned to `"commit_id": "<head_sha>"`. Never emit `APPROVE` or `REQUEST_CHANGES`: merge authority stays with the human owner.
|
||||||
- Never pass `--yes`: it exists to publish a pending review, which step 2 already rules out.
|
- Record the returned review `id` and `html_url` in the final review summary.
|
||||||
- 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`.
|
|
||||||
Executable
+471
@@ -0,0 +1,471 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Deterministic GitHub PR review payload builder for the code-review skill.
|
||||||
|
|
||||||
|
Parses unified PR diffs and paginated prior GitHub reviews/comments to:
|
||||||
|
- Enforce duplicate (head_sha, verdict) skipping (exit 2)
|
||||||
|
- Enforce the 3-rework-cycle cap before human escalation (exit 1)
|
||||||
|
- Compute monotonic per-PR CR-XX finding IDs outside LLM context
|
||||||
|
- Anchor valid (path, line, side) findings as inline comments and move
|
||||||
|
out-of-hunk, missing-file, or cross-file findings into the review body
|
||||||
|
- Render optional collapsible RV-* runtime checks and triage closure summaries
|
||||||
|
- Stamp cr-review-meta and emit GitHub POST /pulls/{n}/reviews JSON to stdout
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
VALID_VERDICTS = ("ready", "needs_rework")
|
||||||
|
VALID_SIDES = ("LEFT", "RIGHT")
|
||||||
|
MAX_REWORK_CYCLES = 3
|
||||||
|
|
||||||
|
META_RE = re.compile(
|
||||||
|
r"<!--\s*cr-review-meta:\s*max_id=(\d+)\s+head_sha=(\S+)\s+verdict=(ready|needs_rework)\s*-->"
|
||||||
|
)
|
||||||
|
CR_HEADING_RE = re.compile(r"^###\s+CR-(\d+)\b", re.MULTILINE)
|
||||||
|
HUNK_RE = re.compile(r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@")
|
||||||
|
|
||||||
|
|
||||||
|
def fail(message: str, code: int = 1) -> None:
|
||||||
|
"""Write error message to stderr and exit with the given code."""
|
||||||
|
print(f"build_review: {message}", file=sys.stderr)
|
||||||
|
sys.exit(code)
|
||||||
|
|
||||||
|
|
||||||
|
def load_json_file(path_str: str, label: str) -> Any:
|
||||||
|
"""Load and parse a UTF-8 JSON file, exiting 1 on I/O or decode failure."""
|
||||||
|
path = Path(path_str)
|
||||||
|
try:
|
||||||
|
raw = path.read_text(encoding="utf-8")
|
||||||
|
except OSError as exc:
|
||||||
|
fail(f"cannot read {label} file '{path_str}': {exc}")
|
||||||
|
try:
|
||||||
|
return json.loads(raw)
|
||||||
|
except json.JSONDecodeError as exc:
|
||||||
|
fail(f"invalid JSON in {label} file '{path_str}': {exc}")
|
||||||
|
|
||||||
|
|
||||||
|
def flatten_paginated(data: Any, label: str) -> list[dict[str, Any]]:
|
||||||
|
"""Flatten gh api --paginate --slurp ([[...]]) or flat ([...]) JSON lists."""
|
||||||
|
if not isinstance(data, list):
|
||||||
|
fail(f"{label} must be a JSON array")
|
||||||
|
items: list[dict[str, Any]] = []
|
||||||
|
for entry in data:
|
||||||
|
if isinstance(entry, list):
|
||||||
|
for sub in entry:
|
||||||
|
if not isinstance(sub, dict):
|
||||||
|
fail(f"{label} nested page contains non-object entry")
|
||||||
|
items.append(sub)
|
||||||
|
elif isinstance(entry, dict):
|
||||||
|
items.append(entry)
|
||||||
|
else:
|
||||||
|
fail(f"{label} contains non-object entry")
|
||||||
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
def _strip_diff_prefix(path_token: str, prefix: str) -> str:
|
||||||
|
"""Strip git diff a/ or b/ prefix and optional surrounding quotes."""
|
||||||
|
token = path_token.strip()
|
||||||
|
if token.startswith('"') and token.endswith('"') and len(token) >= 2:
|
||||||
|
token = token[1:-1]
|
||||||
|
if token.startswith(prefix):
|
||||||
|
return token[len(prefix):]
|
||||||
|
return token
|
||||||
|
|
||||||
|
|
||||||
|
def parse_diff_hunks(diff_text: str) -> tuple[dict[str, set[int]], dict[str, set[int]]]:
|
||||||
|
"""
|
||||||
|
Parse unified diff text into valid inline anchor line sets per file.
|
||||||
|
|
||||||
|
Returns (left_lines, right_lines) where:
|
||||||
|
- left_lines[path] holds deleted line numbers valid for side="LEFT"
|
||||||
|
- right_lines[path] holds added/modified/context line numbers valid for side="RIGHT"
|
||||||
|
"""
|
||||||
|
left_lines: dict[str, set[int]] = {}
|
||||||
|
right_lines: dict[str, set[int]] = {}
|
||||||
|
|
||||||
|
old_path: str | None = None
|
||||||
|
current_path: str | None = None
|
||||||
|
in_hunk = False
|
||||||
|
old_line = 0
|
||||||
|
new_line = 0
|
||||||
|
old_remaining = 0
|
||||||
|
new_remaining = 0
|
||||||
|
|
||||||
|
for raw_line in diff_text.splitlines():
|
||||||
|
if in_hunk and (old_remaining > 0 or new_remaining > 0):
|
||||||
|
if raw_line.startswith("\\"):
|
||||||
|
continue
|
||||||
|
if raw_line.startswith("-"):
|
||||||
|
if current_path is not None:
|
||||||
|
left_lines.setdefault(current_path, set()).add(old_line)
|
||||||
|
old_line += 1
|
||||||
|
old_remaining = max(0, old_remaining - 1)
|
||||||
|
continue
|
||||||
|
if raw_line.startswith("+"):
|
||||||
|
if current_path is not None:
|
||||||
|
right_lines.setdefault(current_path, set()).add(new_line)
|
||||||
|
new_line += 1
|
||||||
|
new_remaining = max(0, new_remaining - 1)
|
||||||
|
continue
|
||||||
|
if raw_line.startswith(" ") or raw_line == "":
|
||||||
|
if current_path is not None:
|
||||||
|
right_lines.setdefault(current_path, set()).add(new_line)
|
||||||
|
old_line += 1
|
||||||
|
new_line += 1
|
||||||
|
old_remaining = max(0, old_remaining - 1)
|
||||||
|
new_remaining = max(0, new_remaining - 1)
|
||||||
|
continue
|
||||||
|
# Unexpected non-hunk line ends the current hunk.
|
||||||
|
in_hunk = False
|
||||||
|
|
||||||
|
if raw_line.startswith("diff --git "):
|
||||||
|
in_hunk = False
|
||||||
|
old_path = None
|
||||||
|
current_path = None
|
||||||
|
continue
|
||||||
|
|
||||||
|
if raw_line.startswith("--- "):
|
||||||
|
in_hunk = False
|
||||||
|
token = raw_line[4:].split("\t", 1)[0].strip()
|
||||||
|
old_path = None if token == "/dev/null" else _strip_diff_prefix(token, "a/")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if raw_line.startswith("+++ "):
|
||||||
|
in_hunk = False
|
||||||
|
token = raw_line[4:].split("\t", 1)[0].strip()
|
||||||
|
if token == "/dev/null":
|
||||||
|
current_path = old_path
|
||||||
|
else:
|
||||||
|
current_path = _strip_diff_prefix(token, "b/")
|
||||||
|
continue
|
||||||
|
|
||||||
|
match = HUNK_RE.match(raw_line)
|
||||||
|
if match:
|
||||||
|
old_line = int(match.group(1))
|
||||||
|
old_remaining = int(match.group(2)) if match.group(2) is not None else 1
|
||||||
|
new_line = int(match.group(3))
|
||||||
|
new_remaining = int(match.group(4)) if match.group(4) is not None else 1
|
||||||
|
in_hunk = True
|
||||||
|
|
||||||
|
return left_lines, right_lines
|
||||||
|
|
||||||
|
|
||||||
|
def inspect_history(
|
||||||
|
reviews: list[dict[str, Any]],
|
||||||
|
comments: list[dict[str, Any]],
|
||||||
|
) -> tuple[int, set[tuple[str, str]], int]:
|
||||||
|
"""
|
||||||
|
Scan prior reviews and inline comments for monotonic max_id,
|
||||||
|
prior (head_sha, verdict) pairs, and needs_rework cycle count.
|
||||||
|
"""
|
||||||
|
max_id = 0
|
||||||
|
seen_sha_verdicts: set[tuple[str, str]] = set()
|
||||||
|
needs_rework_count = 0
|
||||||
|
|
||||||
|
for review in reviews:
|
||||||
|
body = review.get("body") or ""
|
||||||
|
if not isinstance(body, str):
|
||||||
|
continue
|
||||||
|
for m in META_RE.finditer(body):
|
||||||
|
meta_max = int(m.group(1))
|
||||||
|
meta_sha = m.group(2)
|
||||||
|
meta_verdict = m.group(3)
|
||||||
|
if meta_max > max_id:
|
||||||
|
max_id = meta_max
|
||||||
|
seen_sha_verdicts.add((meta_sha, meta_verdict))
|
||||||
|
if meta_verdict == "needs_rework":
|
||||||
|
needs_rework_count += 1
|
||||||
|
for m in CR_HEADING_RE.finditer(body):
|
||||||
|
cid = int(m.group(1))
|
||||||
|
if cid > max_id:
|
||||||
|
max_id = cid
|
||||||
|
|
||||||
|
for comment in comments:
|
||||||
|
body = comment.get("body") or ""
|
||||||
|
if not isinstance(body, str):
|
||||||
|
continue
|
||||||
|
for m in META_RE.finditer(body):
|
||||||
|
meta_max = int(m.group(1))
|
||||||
|
if meta_max > max_id:
|
||||||
|
max_id = meta_max
|
||||||
|
for m in CR_HEADING_RE.finditer(body):
|
||||||
|
cid = int(m.group(1))
|
||||||
|
if cid > max_id:
|
||||||
|
max_id = cid
|
||||||
|
|
||||||
|
return max_id, seen_sha_verdicts, needs_rework_count
|
||||||
|
|
||||||
|
|
||||||
|
def validate_input(data: Any) -> tuple[list[dict[str, Any]], list[dict[str, Any]], list[dict[str, Any]], dict[str, str]]:
|
||||||
|
"""Validate input JSON schema and return (findings, rv_checks, triage_closures, meta_fields)."""
|
||||||
|
if not isinstance(data, dict):
|
||||||
|
fail("input JSON root must be an object")
|
||||||
|
if "findings" not in data or not isinstance(data["findings"], list):
|
||||||
|
fail("input JSON must include a 'findings' array")
|
||||||
|
|
||||||
|
findings: list[dict[str, Any]] = []
|
||||||
|
for idx, item in enumerate(data["findings"]):
|
||||||
|
if not isinstance(item, dict):
|
||||||
|
fail(f"findings[{idx}] must be an object")
|
||||||
|
for req in ("severity", "title", "body"):
|
||||||
|
val = item.get(req)
|
||||||
|
if not isinstance(val, str) or not val.strip():
|
||||||
|
fail(f"findings[{idx}] missing required non-empty string field '{req}'")
|
||||||
|
path_val = item.get("path")
|
||||||
|
if path_val is not None and not isinstance(path_val, str):
|
||||||
|
fail(f"findings[{idx}].path must be a string or null")
|
||||||
|
line_val = item.get("line")
|
||||||
|
if line_val is not None:
|
||||||
|
if isinstance(line_val, bool) or not isinstance(line_val, int) or line_val <= 0:
|
||||||
|
fail(f"findings[{idx}].line must be a positive integer or null")
|
||||||
|
side_val = item.get("side")
|
||||||
|
if side_val is not None and side_val not in VALID_SIDES:
|
||||||
|
fail(f"findings[{idx}].side must be 'LEFT', 'RIGHT', or null")
|
||||||
|
findings.append(item)
|
||||||
|
|
||||||
|
rv_checks = data.get("rv_checks", [])
|
||||||
|
if not isinstance(rv_checks, list):
|
||||||
|
fail("input JSON 'rv_checks' must be an array when provided")
|
||||||
|
for idx, chk in enumerate(rv_checks):
|
||||||
|
if not isinstance(chk, dict):
|
||||||
|
fail(f"rv_checks[{idx}] must be an object")
|
||||||
|
|
||||||
|
triage_closures = data.get("triage_closures", [])
|
||||||
|
if not isinstance(triage_closures, list):
|
||||||
|
fail("input JSON 'triage_closures' must be an array when provided")
|
||||||
|
for idx, cls_item in enumerate(triage_closures):
|
||||||
|
if not isinstance(cls_item, dict):
|
||||||
|
fail(f"triage_closures[{idx}] must be an object")
|
||||||
|
|
||||||
|
meta_fields: dict[str, str] = {}
|
||||||
|
for key in ("summary", "base_ref", "head_ref", "covered_state", "tier"):
|
||||||
|
val = data.get(key)
|
||||||
|
if isinstance(val, str) and val.strip():
|
||||||
|
meta_fields[key] = val.strip()
|
||||||
|
|
||||||
|
return findings, rv_checks, triage_closures, meta_fields
|
||||||
|
|
||||||
|
|
||||||
|
def format_cr_id(num: int) -> str:
|
||||||
|
"""Format numeric finding ID as CR-01..CR-99, CR-100, etc."""
|
||||||
|
return f"CR-{num:02d}"
|
||||||
|
|
||||||
|
|
||||||
|
def format_finding_block(cr_id: str, finding: dict[str, Any], include_location: bool) -> str:
|
||||||
|
"""Render a finding with a canonical ### CR-NN heading."""
|
||||||
|
title = finding["title"].strip()
|
||||||
|
severity = finding["severity"].strip()
|
||||||
|
axis = finding.get("axis")
|
||||||
|
meta_parts = [f"**Severity:** {severity}"]
|
||||||
|
if isinstance(axis, str) and axis.strip():
|
||||||
|
meta_parts.append(f"**Axis:** {axis.strip()}")
|
||||||
|
if include_location:
|
||||||
|
path_val = finding.get("path")
|
||||||
|
line_val = finding.get("line")
|
||||||
|
side_val = finding.get("side")
|
||||||
|
if isinstance(path_val, str) and path_val.strip():
|
||||||
|
loc = f"`{path_val.strip()}`"
|
||||||
|
if line_val is not None:
|
||||||
|
loc += f":L{line_val}"
|
||||||
|
if side_val:
|
||||||
|
loc += f" ({side_val})"
|
||||||
|
meta_parts.append(f"**Location:** {loc}")
|
||||||
|
else:
|
||||||
|
meta_parts.append("**Location:** Cross-file / General")
|
||||||
|
|
||||||
|
lines = [
|
||||||
|
f"### {cr_id}: {title}",
|
||||||
|
"",
|
||||||
|
" | ".join(meta_parts),
|
||||||
|
"",
|
||||||
|
finding["body"].strip(),
|
||||||
|
]
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def format_triage_summary(closures: list[dict[str, Any]]) -> str:
|
||||||
|
"""Render Exit B / Exit C triage closure summary."""
|
||||||
|
lines = ["### Triage Summary", ""]
|
||||||
|
for item in closures:
|
||||||
|
cid = str(item.get("id") or "CR-??").strip()
|
||||||
|
exit_code = str(item.get("exit", "")).strip()
|
||||||
|
resolution = str(item.get("resolution", "")).strip()
|
||||||
|
exit_label = f"Exit {exit_code}" if exit_code and not exit_code.lower().startswith("exit") else exit_code
|
||||||
|
if exit_label:
|
||||||
|
lines.append(f"- **{cid}** ({exit_label}): {resolution}")
|
||||||
|
else:
|
||||||
|
lines.append(f"- **{cid}**: {resolution}")
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def format_rv_checks(rv_checks: list[dict[str, Any]]) -> str:
|
||||||
|
"""Render collapsible RV-* executable runtime checks block."""
|
||||||
|
lines = [
|
||||||
|
"<details>",
|
||||||
|
"<summary>Executable Runtime Checks (RV-*)</summary>",
|
||||||
|
"",
|
||||||
|
]
|
||||||
|
for idx, chk in enumerate(rv_checks, start=1):
|
||||||
|
chk_id = str(chk.get("id") or f"RV-{idx:02d}").strip()
|
||||||
|
purpose = str(chk.get("purpose") or "Runtime verification check").strip()
|
||||||
|
scope = str(chk.get("scope") or "local").strip()
|
||||||
|
pass_cond = str(chk.get("pass_condition") or "").strip()
|
||||||
|
fail_sig = str(chk.get("fail_signal") or "").strip()
|
||||||
|
command = str(chk.get("command") or "").strip()
|
||||||
|
|
||||||
|
lines.append(f"#### {chk_id}: {purpose}")
|
||||||
|
lines.append(f"- **Scope:** `{scope}`")
|
||||||
|
if pass_cond:
|
||||||
|
lines.append(f"- **Pass Condition:** {pass_cond}")
|
||||||
|
if fail_sig:
|
||||||
|
lines.append(f"- **Failure Signal:** {fail_sig}")
|
||||||
|
if command:
|
||||||
|
lines.append("```sh")
|
||||||
|
lines.append(command)
|
||||||
|
lines.append("```")
|
||||||
|
lines.append("")
|
||||||
|
|
||||||
|
lines.append("</details>")
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def build_parser() -> argparse.ArgumentParser:
|
||||||
|
"""Build CLI argument parser."""
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Build a validated GitHub PR review JSON payload with monotonic CR-XX IDs."
|
||||||
|
)
|
||||||
|
parser.add_argument("--input", required=True, help="Path to findings JSON input file")
|
||||||
|
parser.add_argument("--diff", required=True, help="Path to unified PR diff file")
|
||||||
|
parser.add_argument("--reviews", required=True, help="Path to prior PR reviews JSON file")
|
||||||
|
parser.add_argument("--comments", required=True, help="Path to prior PR inline comments JSON file")
|
||||||
|
parser.add_argument("--head-sha", required=True, help="Reviewed PR head commit SHA")
|
||||||
|
parser.add_argument("--verdict", required=True, help="Review verdict: ready or needs_rework")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv: list[str] | None = None) -> int:
|
||||||
|
"""CLI entrypoint for building a GitHub PR review payload."""
|
||||||
|
parser = build_parser()
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
|
head_sha = args.head_sha.strip()
|
||||||
|
if not head_sha:
|
||||||
|
fail("--head-sha must be a non-empty string")
|
||||||
|
if args.verdict not in VALID_VERDICTS:
|
||||||
|
fail(f"invalid --verdict '{args.verdict}'; expected one of: {', '.join(VALID_VERDICTS)}")
|
||||||
|
|
||||||
|
input_data = load_json_file(args.input, "input")
|
||||||
|
reviews_raw = load_json_file(args.reviews, "reviews")
|
||||||
|
comments_raw = load_json_file(args.comments, "comments")
|
||||||
|
|
||||||
|
try:
|
||||||
|
diff_text = Path(args.diff).read_text(encoding="utf-8")
|
||||||
|
except OSError as exc:
|
||||||
|
fail(f"cannot read diff file '{args.diff}': {exc}")
|
||||||
|
|
||||||
|
findings, rv_checks, triage_closures, meta_fields = validate_input(input_data)
|
||||||
|
reviews = flatten_paginated(reviews_raw, "reviews")
|
||||||
|
comments = flatten_paginated(comments_raw, "comments")
|
||||||
|
|
||||||
|
max_id, seen_sha_verdicts, needs_rework_count = inspect_history(reviews, comments)
|
||||||
|
|
||||||
|
if (head_sha, args.verdict) in seen_sha_verdicts:
|
||||||
|
fail(
|
||||||
|
f"duplicate review skipped: (head_sha={head_sha}, verdict={args.verdict}) already exists",
|
||||||
|
code=2,
|
||||||
|
)
|
||||||
|
|
||||||
|
if args.verdict == "needs_rework" and needs_rework_count >= MAX_REWORK_CYCLES:
|
||||||
|
fail(
|
||||||
|
f"3-rework-cycle cap reached ({needs_rework_count} prior needs_rework reviews); escalate to human owner",
|
||||||
|
code=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
left_lines, right_lines = parse_diff_hunks(diff_text)
|
||||||
|
|
||||||
|
inline_comments: list[dict[str, Any]] = []
|
||||||
|
unanchored_blocks: list[str] = []
|
||||||
|
|
||||||
|
current_id = max_id
|
||||||
|
for finding in findings:
|
||||||
|
current_id += 1
|
||||||
|
cr_id = format_cr_id(current_id)
|
||||||
|
|
||||||
|
path_val = finding.get("path")
|
||||||
|
line_val = finding.get("line")
|
||||||
|
side_val = finding.get("side") or "RIGHT"
|
||||||
|
|
||||||
|
anchored = False
|
||||||
|
if isinstance(path_val, str) and path_val.strip() and isinstance(line_val, int):
|
||||||
|
norm_path = path_val.strip()
|
||||||
|
if side_val == "LEFT" and line_val in left_lines.get(norm_path, set()):
|
||||||
|
anchored = True
|
||||||
|
elif side_val == "RIGHT" and line_val in right_lines.get(norm_path, set()):
|
||||||
|
anchored = True
|
||||||
|
|
||||||
|
if anchored:
|
||||||
|
inline_comments.append(
|
||||||
|
{
|
||||||
|
"path": path_val.strip(),
|
||||||
|
"line": line_val,
|
||||||
|
"side": side_val,
|
||||||
|
"body": format_finding_block(cr_id, finding, include_location=False),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
unanchored_blocks.append(format_finding_block(cr_id, finding, include_location=True))
|
||||||
|
|
||||||
|
short_sha = head_sha[:7]
|
||||||
|
body_sections: list[str] = []
|
||||||
|
|
||||||
|
header_line = f"**Code review @ `{short_sha}`**: `{args.verdict}`"
|
||||||
|
if "base_ref" in meta_fields and "head_ref" in meta_fields:
|
||||||
|
header_line = (
|
||||||
|
f"**Code review @ `{short_sha}`** "
|
||||||
|
f"(`{meta_fields['base_ref']}`..`{meta_fields['head_ref']}`): `{args.verdict}`"
|
||||||
|
)
|
||||||
|
body_sections.append(header_line)
|
||||||
|
|
||||||
|
meta_notes: list[str] = []
|
||||||
|
if "covered_state" in meta_fields:
|
||||||
|
meta_notes.append(f"Covered state: `{meta_fields['covered_state']}`.")
|
||||||
|
if "tier" in meta_fields:
|
||||||
|
meta_notes.append(f"Tier: `{meta_fields['tier']}`.")
|
||||||
|
meta_notes.append("Static provenance only; merge authority stays with the owner.")
|
||||||
|
body_sections.append(" ".join(meta_notes))
|
||||||
|
|
||||||
|
if "summary" in meta_fields:
|
||||||
|
body_sections.append(meta_fields["summary"])
|
||||||
|
elif not findings:
|
||||||
|
body_sections.append("No new findings.")
|
||||||
|
|
||||||
|
if unanchored_blocks:
|
||||||
|
body_sections.append("### Findings (Unanchored / Cross-File)\n\n" + "\n\n".join(unanchored_blocks))
|
||||||
|
|
||||||
|
if triage_closures:
|
||||||
|
body_sections.append(format_triage_summary(triage_closures))
|
||||||
|
|
||||||
|
if rv_checks:
|
||||||
|
body_sections.append(format_rv_checks(rv_checks))
|
||||||
|
|
||||||
|
body_sections.append(
|
||||||
|
f"<!-- cr-review-meta: max_id={current_id:02d} head_sha={head_sha} verdict={args.verdict} -->"
|
||||||
|
)
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
"commit_id": head_sha,
|
||||||
|
"event": "COMMENT",
|
||||||
|
"body": "\n\n".join(body_sections),
|
||||||
|
"comments": inline_comments,
|
||||||
|
}
|
||||||
|
print(json.dumps(payload, indent=2))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -5,7 +5,8 @@ description: >-
|
|||||||
history integration (rebase, squash, cherry-pick, merge), conflict stops, and
|
history integration (rebase, squash, cherry-pick, merge), conflict stops, and
|
||||||
evidence-first reflog recovery. Use when creating branches or worktrees, committing
|
evidence-first reflog recovery. Use when creating branches or worktrees, committing
|
||||||
completed task checkpoints, integrating branches, or recovering lost commits. Not for
|
completed task checkpoints, integrating branches, or recovering lost commits. Not for
|
||||||
pull request lifecycle: use gitea-pr. Not for diff code inspection: use code-review.
|
pull request lifecycle: use implement (Draft PRs) or verify (promotion and merge). Not for
|
||||||
|
diff code inspection: use code-review.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Git Manager
|
# Git Manager
|
||||||
@@ -15,7 +16,7 @@ description: >-
|
|||||||
- Recording clean, atomic Conventional Commits as coherent tasks finish, or slicing a dirty tree.
|
- Recording clean, atomic Conventional Commits as coherent tasks finish, or slicing a dirty tree.
|
||||||
- Integrating branches (rebase, squash, merge, cherry-pick) or stopping cleanly on conflicts.
|
- Integrating branches (rebase, squash, merge, cherry-pick) or stopping cleanly on conflicts.
|
||||||
- Recovering lost commits, dangling refs, or broken working-tree state via reflog.
|
- Recovering lost commits, dangling refs, or broken working-tree state via reflog.
|
||||||
- Not for pull request creation or review threads: use `gitea-pr`.
|
- Not for Draft PR creation (`implement`) or PR promotion and merge closeout (`verify`).
|
||||||
- Not for multi-axis static diff evaluation: use `code-review`.
|
- Not for multi-axis static diff evaluation: use `code-review`.
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
@@ -61,5 +62,6 @@ description: >-
|
|||||||
|
|
||||||
## Hands off to
|
## Hands off to
|
||||||
- `code-review`: when a branch or commit range is ready for multi-axis static diff review.
|
- `code-review`: when a branch or commit range is ready for multi-axis static diff review.
|
||||||
- `gitea-pr`: when verified commits are pushed and ready for pull request creation or update.
|
- `implement`: when a slice branch is ready for Draft PR creation or rework sync.
|
||||||
|
- `verify`: when a reviewed PR is ready for runtime QA, promotion, and merge closeout.
|
||||||
- `document`: when a commit or recovery surfaces a decision or insight worth recording separately.
|
- `document`: when a commit or recovery surfaces a decision or insight worth recording separately.
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
---
|
|
||||||
name: gitea-plan
|
|
||||||
description: >-
|
|
||||||
Translate technical goals, user requests, and architecture plans into Gitea planning
|
|
||||||
primitives (issues, milestones, project boards) with tiered complexity scaling.
|
|
||||||
Use when decomposing work, creating or updating Gitea issues, or establishing planning
|
|
||||||
milestones. Not for managing pull requests: use gitea-pr.
|
|
||||||
---
|
|
||||||
|
|
||||||
# Gitea Plan
|
|
||||||
|
|
||||||
## Use when
|
|
||||||
- Decomposing a project, feature request, or technical plan into trackable Gitea units.
|
|
||||||
- Creating or editing milestones, project boards, and issues with falsifiable criteria.
|
|
||||||
- Setting rolling planning horizons for multi-phase epics.
|
|
||||||
- Not for orchestrating slice implementation across subagents: use `implement-slice`.
|
|
||||||
- Not for branch or worktree management: use `git-manager`.
|
|
||||||
- Not for pull request lifecycle or review tracking: use `gitea-pr`.
|
|
||||||
|
|
||||||
## Steps
|
|
||||||
1. **Reconcile artifacts bidirectionally.** Check specs, roadmaps, assets, and Gitea
|
|
||||||
state for contradictions. Flag zombie in-progress, premature completed, or horizon
|
|
||||||
divergence conflicts before planning new work. When closing a milestone or before
|
|
||||||
decomposing the next rolling milestone, if `ARCHITECTURE.md`, `ROADMAP.md`, or
|
|
||||||
`docs/designs/*.md` lag behind `Completed` board cards, hand off to `reconcile-docs`
|
|
||||||
first. See [references/decomposition-tiers.md](references/decomposition-tiers.md).
|
|
||||||
2. **Assess scope and select tier.** Assign `Small`, `Medium`, or `Large`.
|
|
||||||
Emit explicit `### Project Board Policy: <Omitted|Recommended|Required> (Rationale)`.
|
|
||||||
3. **Decompose into deliverable outcome slices.** Map work into verifiable issues
|
|
||||||
with test seams and falsifiable acceptance criteria (Context, Solution, Criteria),
|
|
||||||
grouping TDD test seams vertically by submodule or capability rather than a single
|
|
||||||
monolithic upfront test block across all modules.
|
|
||||||
4. **Run independent reproducibility audit (`Medium`/`Large` mandatory).** For `Medium`
|
|
||||||
and `Large` plans, spawn a clean-room subagent with raw input manifest (commit SHA,
|
|
||||||
specs, proposed issue markdown) to resolve material ambiguities before the human gate.
|
|
||||||
5. **Present decomposition for approval.** Emit `### Reproducibility Audit: <Passed|Remediated> (Subagent: <id> | Omitted: Small tier)`
|
|
||||||
alongside proposed milestone, board, issues, and any `AGENTS.md` contract diff. Stop
|
|
||||||
for approval before mutating Gitea entities or `AGENTS.md`.
|
|
||||||
6. **Execute Gitea operations via `gt` CLI.** Use verified commands from `gt-usage`:
|
|
||||||
- Milestones: `gt milestone create "<title>" -d "<desc>" --json id,url`.
|
|
||||||
- Projects: create with `gt project create "<title>" --template none --json id,url` if
|
|
||||||
missing (with `--org <org>` for multi-repo orgs), or reconcile an existing board in
|
|
||||||
place (`PATCH` matched role aliases, `POST` missing columns, set `Backlog` default,
|
|
||||||
and apply the Deep Signal hex colors per [decomposition-tiers](references/decomposition-tiers.md)).
|
|
||||||
- Issues: `gt issue create -t "<title>" -F <file> -m <id> -p <id> --json id,number,url`
|
|
||||||
(or attach to org board: `gt issue edit <number> -R <repo> --add-project <id>`).
|
|
||||||
Extract server IDs directly; never guess sequence numbers or construct `/milestone/1`.
|
|
||||||
7. **Verify created state.** Inspect `gt issue list`, `gt milestone list`, and board
|
|
||||||
columns to confirm server IDs, column colors/order, and non-hallucinated canonical URLs.
|
|
||||||
8. **Formalize repo planning contract in `AGENTS.md`.** When establishing or changing
|
|
||||||
`Medium`/`Large` planning structure, record a concise sync rule in `AGENTS.md`:
|
|
||||||
- Pin **stable coordinates only**: roadmap/checklist paths (`docs/roadmap.md`, `todo.txt`),
|
|
||||||
Gitea repo + Project Board ID + `{Backlog, Ready, Work in Progress, Review, Completed -> column_id}`
|
|
||||||
map, mirror policy, and the trigger to re-run `gitea-plan` on scope shifts or Readiness Gates.
|
|
||||||
- **Never** hardcode rotating sprint state (milestone numbers or open issues) in `AGENTS.md`.
|
|
||||||
|
|
||||||
## Your call
|
|
||||||
- **Planning tier selection**: confirm Small vs. Medium vs. Large ceremony level.
|
|
||||||
- **Issue decomposition boundaries**: approve or revise proposed issue slices.
|
|
||||||
- **Batch entity creation**: approve structured batch creation and `AGENTS.md` contract edits per `profile/AGENTS.md`.
|
|
||||||
|
|
||||||
## Done when
|
|
||||||
- Target milestone, board, and issues exist on Gitea with verified server IDs,
|
|
||||||
canonical URLs, and falsifiable acceptance criteria.
|
|
||||||
- Repository `AGENTS.md` contains an accurate, state-free planning sync contract
|
|
||||||
whenever `Medium`/`Large` planning structure is created or updated.
|
|
||||||
|
|
||||||
## Hands off to
|
|
||||||
- `implement-slice`: to deliver an approved issue (`Suggested Next Step: /implement-slice #<first-ready-issue>`).
|
|
||||||
- `git-manager`: to create dedicated branches or worktrees for decomposed issues.
|
|
||||||
- `gitea-pr`: to link, review, and close issues via pull requests.
|
|
||||||
- `reconcile-docs`: when canonical docs lag behind completed cards (`Suggested Next Step: /reconcile-docs`).
|
|
||||||
- Emit one outcome-matched `Suggested Next Step` per [skeleton](../build-skill/references/skeleton.md).
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
# Project Sizing, Ceremony Tiers, and Artifact Contracts
|
|
||||||
|
|
||||||
Reference for `gitea-plan`. Guidelines for scaling planning ceremony to risk and scope, preserving momentum while keeping architecture traceable and reproducible.
|
|
||||||
|
|
||||||
## 1. Core Axiom: Issues vs. Commits
|
|
||||||
|
|
||||||
- An **Issue** represents an **independently deliverable outcome** (what is built, verified, and closed by a pull request). It defines falsifiable acceptance criteria and expected behavior.
|
|
||||||
- A **Commit** represents an **atomic, reversible implementation checkpoint** (a step within that issue's branch). Commits must compile and pass tests, but do not need to represent an entire closed issue on their own.
|
|
||||||
- **Anti-pattern**: Never create 1:1 Gitea issues for micro-commits (such as "fix typo", "add helper function", or "clean up lint"). Group cohesive checkpoints under a single deliverable issue.
|
|
||||||
- **Vertical Submodule TDD Grouping**: Inside a multi-module issue, organize acceptance criteria and TDD test drafts vertically by submodule or dependency layer (e.g. `protocols` -> `ssap` -> `pointer` -> `manager`) rather than a single horizontal "write all tests for the entire issue first" section, so `implement-slice` executes incremental Red->Green cycles per submodule.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Entity Semantics: Issues, Boards, and Milestones
|
|
||||||
|
|
||||||
Each Gitea planning primitive tracks a distinct dimension of engineering reality:
|
|
||||||
- **Issue State (`Open` vs. `Closed`)**: Deliverable completion on `main`.
|
|
||||||
- **Board State (Columns: *Backlog*, *Ready*, *Work in Progress*, *Review*, *Completed*)**: Spatial workflow stage in the active pipeline.
|
|
||||||
- **Milestone**: Strategic delivery horizon (capacity-driven or time-bounded release boundary).
|
|
||||||
|
|
||||||
### Canonical 5-Column Pipeline & Semantic Colors (Deep Signal Palette)
|
|
||||||
|
|
||||||
| Sorting | Canonical Title | Role Aliases (Matched Case-Insensitively) | Hex Color | Default | Transition Owner |
|
|
||||||
| :--- | :--- | :--- | :--- | :--- | :--- |
|
|
||||||
| `0` | **Backlog** | `backlog`, `to-do`, `todo`, `icebox`, `triage` | `#475569` (Slate Gray) | `true` | `gitea-plan` (default placement for dependent issues) |
|
|
||||||
| `1` | **Ready** | `ready`, `next`, `up next`, `queued`, `groomed` | `#1d76db` (Signal Blue) | `false` | `implement-slice` (Step 1 preflight readiness check) |
|
|
||||||
| `2` | **Work in Progress** | `work in progress`, `in progress`, `wip`, `doing`, `active` | `#d97706` (Warm Amber) | `false` | `implement-slice` (Step 4 worker start) |
|
|
||||||
| `3` | **Review** | `review`, `in review`, `qa`, `testing`, `verification` | `#6d28d9` (Royal Purple) | `false` | `implement-slice` (Step 7 final-HEAD pass) / `gitea-pr` |
|
|
||||||
| `4` | **Completed** | `completed`, `done`, `closed`, `shipped` | `#15803d` (Forest Green) | `false` | `gitea-pr` (on owner-authorized merge) / `implement-slice` |
|
|
||||||
|
|
||||||
### Board Provisioning & Non-Destructive Reconciliation (`gitea-plan`)
|
|
||||||
1. **Create if missing**: When `Project Board Policy` is `Recommended` or `Required` and no open board exists, create one with `gt project create "<title>" --template none -d "<desc>" --json id,title,url`, then `POST` the 5 canonical columns (`sorting: 0..4`) with their Deep Signal hex colors and set `Backlog` as `default: true` (using the recipes in `gt-usage`).
|
|
||||||
2. **Reconcile in place if existing**: Never assume an existing board already adheres to the convention, and never delete columns that hold cards. Query `/projects/<id>/columns`, match existing columns to the 5 roles by their case-insensitive aliases, and `PATCH` matched columns in place (`title`, `color`, `sorting`) so attached cards stay intact. Create only the missing canonical columns via `POST`, and ensure `Backlog` is marked `default: true`.
|
|
||||||
3. **Pin column IDs in `AGENTS.md`**: Record the resolved Project Board ID and `{Backlog, Ready, Work in Progress, Review, Completed -> column_id}` map in the repository's `AGENTS.md` planning contract so `implement-slice` and `gitea-pr` move cards without guessing names.
|
|
||||||
|
|
||||||
### Meaningful Conflict Reconciliation
|
|
||||||
Never mechanically mirror or silently mutate state. Instead, detect and report semantic conflicts:
|
|
||||||
- **Zombie In-Progress**: Issue or PR is closed on Gitea, but its card still sits in *Backlog*, *Ready*, *Work in Progress*, or *Review* on the board.
|
|
||||||
- **Premature Completed**: Card is moved to *Completed*, but the issue remains open or lacks a merged PR / commit on `main`.
|
|
||||||
- **Review Orphan**: Card sits in *Review*, but no active PR or static review packet exists.
|
|
||||||
- **Horizon Divergence**: Open issue is assigned to a milestone that is closed or diverges from the active milestone in `ROADMAP.md`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. Planning Ceremony Tiers & Project Board Policy
|
|
||||||
|
|
||||||
| Tier | Typical Work | Gitea Primitives | Project Board Policy | Decomposition Rule |
|
|
||||||
| :--- | :--- | :--- | :--- | :--- |
|
|
||||||
| **Small** | Single-step bugfix, documentation tweak, dependency bump, routine chore | 1 Issue linked directly to 1 PR / Commit | **Omitted by Policy** (issue tracker suffices) | Zero milestones. Zero project boards. Keep description concise (Context, Solution, Acceptance Criteria). |
|
|
||||||
| **Medium** | Vertical feature slice, multi-step refactor, performance spike (2 to 5 issues) | 1 Milestone + 2 to 5 Issues | **Recommended** (5-column Kanban: *Backlog*, *Ready*, *Work in Progress*, *Review*, *Completed*) | Each issue has its own branch and PR. All issues include explicit numbered acceptance criteria and test seams. |
|
|
||||||
| **Large** | Architectural epic, platform cutover, multi-service evolution | Roadmap Doc + Rolling Milestones + Deliverable Issues | **Required** (Board coordinates rolling horizons) | Source of truth remains in repo docs (`ARCHITECTURE.md`, `ROADMAP.md`, ADRs). Gitea coordinates rolling execution. |
|
|
||||||
|
|
||||||
**Deterministic Output Headers**: Every planning proposal must explicitly state both headers before asking for approval:
|
|
||||||
```markdown
|
|
||||||
### Project Board Policy: <Omitted|Recommended|Required> (Rationale)
|
|
||||||
### Reproducibility Audit: <Passed | Remediated> (Subagent: `<conversation-id>` | `Omitted: Small tier`)
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Independent Zero-Context Reproducibility Audit (`Medium` and `Large` Mandatory)
|
|
||||||
|
|
||||||
Before presenting a `Medium` or `Large` decomposition for approval (Step 5), spawn a clean-room audit subagent to verify plan reproducibility without conversational context and record its `<conversation-id>` in the `### Reproducibility Audit:` header:
|
|
||||||
|
|
||||||
### Input Manifest (Strict Clean-Room)
|
|
||||||
The auditor receives strictly raw artifacts and pinned repository state:
|
|
||||||
1. Pinned repository root and commit SHA.
|
|
||||||
2. Canonical specifications (`docs/specs/*.md`) and `ROADMAP.md`.
|
|
||||||
3. Proposed raw issue titles, descriptions, and acceptance criteria markdown.
|
|
||||||
4. Proposed milestone and board specifications.
|
|
||||||
5. Declared asset paths and prerequisite environment variables.
|
|
||||||
|
|
||||||
### Auditor Report Schema
|
|
||||||
The auditor reports across five explicit sections:
|
|
||||||
1. **Reconstructed from Source Artifacts**: Scope and sequence directly supported by source text.
|
|
||||||
2. **Inferred Requirements**: Deductions made from titles or conventions lacking explicit spec text.
|
|
||||||
3. **Undetermined Seams**: Gaps or ambiguities that could not be resolved without guessing.
|
|
||||||
4. **Materiality Classification**:
|
|
||||||
- *Material*: Forces an implementer to guess about scope, behavior, acceptance, or prerequisites.
|
|
||||||
- *Non-Material*: Cosmetic or self-evident convention.
|
|
||||||
5. **Concrete Remediation Plan**: Specific edits to specs, assets, or criteria to resolve material ambiguities.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5. Rolling Horizons for Large Projects
|
|
||||||
|
|
||||||
When planning large epics, avoid waterfall decomposition where every future task is pre-created as an issue weeks before implementation:
|
|
||||||
1. **Active Milestone (Immediate Horizon)**: Decomposed into 2 to 5 concrete deliverable issues with falsifiable acceptance criteria.
|
|
||||||
2. **Future Milestones (Deferred Horizons)**: Represented as high-level milestones or single coarse placeholder issues in Gitea.
|
|
||||||
3. **Architecture Synchronization**: Update repository docs (`reconcile-docs`) before decomposing the next rolling milestone.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 6. Multi-Repository Organizations and Shared Boards
|
|
||||||
|
|
||||||
When planning across multi-repository architectures (where an organization hub coordinates multiple deliverable repositories or services):
|
|
||||||
- **Root Kanban at Organization Level**: Create the shared board at the organization level (`gt project create "<title>" --org <org> --template none`) and reconcile the 5 canonical columns. Do not isolate tracking into separate child repository boards.
|
|
||||||
- **Attach Child Issues to Org Board**: Deliverable issues and pull requests created in child repositories attach to the organization board via `gt issue create ... -p <project-id>` or `gt issue edit <number> -R <owner/repo> --add-project <project-id>`.
|
|
||||||
- **Hub Documentation Alignment**: Architectural strategy, shared documentation, and roadmaps remain centralized in the hub repository, while the organization-level Kanban board coordinates unified cross-repo delivery status.
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# [DEPRECATED] Tea CLI Subroutines
|
|
||||||
|
|
||||||
> **Notice**: Upstream `tea` CLI is archived and officially deprecated in favor of `gt` (`gitea/cli`).
|
|
||||||
> For verified command patterns, JSON extraction discipline, and sovereign instance conventions, use the official skill:
|
|
||||||
> **`skills/gt-usage/`** and its reference manual **`skills/gt-usage/references/commands.md`**.
|
|
||||||
|
|
||||||
This document is preserved for historical reference and legacy instance migrations only.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Legacy Commands Reference (Archived)
|
|
||||||
|
|
||||||
### 1. Issue Management (Legacy)
|
|
||||||
```sh
|
|
||||||
tea issues create --title "<title>" --description "<description>"
|
|
||||||
tea issues list
|
|
||||||
tea issues edit <index> --title "<new-title>"
|
|
||||||
tea issues close <index>
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Milestone Management (Legacy)
|
|
||||||
```sh
|
|
||||||
tea milestones create --title "<milestone-title>" --description "<overview>"
|
|
||||||
tea milestones list
|
|
||||||
tea milestones close "<milestone-title>"
|
|
||||||
```
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
---
|
|
||||||
name: gitea-pr
|
|
||||||
description: >-
|
|
||||||
Manage pull request lifecycle on Gitea: verify branch readiness, synthesize structured PR
|
|
||||||
descriptions from code-review and verify-slice evidence packets, link issues, digest review
|
|
||||||
feedback, and report merge readiness. Not for code inspection: use code-review. Not for
|
|
||||||
runtime QA: use verify-slice. Not for Git branch, commit, or merge mechanics: use git-manager.
|
|
||||||
---
|
|
||||||
|
|
||||||
# Gitea PR
|
|
||||||
|
|
||||||
## Use when
|
|
||||||
- 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.
|
|
||||||
- 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`.
|
|
||||||
|
|
||||||
## Steps
|
|
||||||
1. **Verify branch readiness.** Confirm the local working tree is clean (`git status --short`),
|
|
||||||
the branch tracks an upstream remote (`git rev-parse @{u}`), unpushed commits are pushed,
|
|
||||||
and the target base branch exists on the remote.
|
|
||||||
2. **Collect review and verification evidence.** Inspect outputs from preceding skills:
|
|
||||||
- `code-review`: Static provenance, covered commits/diff fingerprint, findings disposition,
|
|
||||||
and overall recommendation (`Ready`).
|
|
||||||
- `verify-slice`: Runtime evidence ledger across behavioral, security, and state checks,
|
|
||||||
confirming zero unhandled `FAIL` outcomes.
|
|
||||||
If either packet is missing or stale relative to current `HEAD`, stop and run that skill first.
|
|
||||||
3. **Draft structured PR description.** Compose the PR body following
|
|
||||||
[references/pr-lifecycle.md](references/pr-lifecycle.md):
|
|
||||||
- Issue Linkage: `Closes #<issue-index>`.
|
|
||||||
- Summary of Changes: Problem, solution, and scope boundary.
|
|
||||||
- Static Review Provenance: Base/head SHAs, diff SHA256, and 4-axis disposition.
|
|
||||||
- Runtime Verification Ledger: Markdown table of executed checks and outcomes.
|
|
||||||
- Residual Risks and Rollback: Operational considerations and reversibility.
|
|
||||||
4. **Present for human approval.** Present proposed title, target base branch, milestone,
|
|
||||||
and description body to the user per `profile/AGENTS.md`. Stop for confirmation before
|
|
||||||
creating or editing the pull request.
|
|
||||||
5. **Create or update pull request via `gt pr` and move card to `Review`.** Run verified
|
|
||||||
commands from [references/gt-pulls.md](references/gt-pulls.md):
|
|
||||||
`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. **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>`). 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.
|
|
||||||
- **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.
|
|
||||||
|
|
||||||
## Done when
|
|
||||||
- Pull request is created or updated in Gitea with complete evidence provenance, and its current
|
|
||||||
review and mergeability status is reported to the user.
|
|
||||||
|
|
||||||
## Hands off to
|
|
||||||
- `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` 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,111 +0,0 @@
|
|||||||
# Verified `gt pr` Pull Request Subroutines
|
|
||||||
|
|
||||||
Reference for `gitea-pr`. Canonical, verified syntax for managing pull requests, status checks, and review threads via `gt`.
|
|
||||||
|
|
||||||
## 1. Inspecting Pull Requests
|
|
||||||
|
|
||||||
### List Pull Requests
|
|
||||||
```bash
|
|
||||||
# List open PRs with structured fields
|
|
||||||
gt pr list --json number,title,state,url
|
|
||||||
|
|
||||||
# List all PRs including closed/merged
|
|
||||||
gt pr list --state all --json number,title,state,url
|
|
||||||
```
|
|
||||||
|
|
||||||
### View Pull Request Details & Status Checks
|
|
||||||
```bash
|
|
||||||
# View basic PR details
|
|
||||||
gt pr view <number>
|
|
||||||
|
|
||||||
# Inspect mergeability and review decision
|
|
||||||
gt pr view <number> --json number,title,state,mergeable,review_decision,url
|
|
||||||
|
|
||||||
# Show status of CI checks on the head commit
|
|
||||||
gt pr checks <number>
|
|
||||||
|
|
||||||
# Wait for CI checks to complete
|
|
||||||
gt pr checks <number> --watch
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Creating and Updating Pull Requests
|
|
||||||
|
|
||||||
### Create a Pull Request
|
|
||||||
- Create standard PR with multi-line body from file:
|
|
||||||
```bash
|
|
||||||
gt pr create -t "<title>" -B "<base-branch>" -H "<feature-branch>" -F <body-file> --json number,url
|
|
||||||
```
|
|
||||||
- Create as a Draft / WIP PR:
|
|
||||||
```bash
|
|
||||||
gt pr create -t "WIP: <title>" --draft -B "<base-branch>" -H "<feature-branch>" -F <body-file> --json number,url
|
|
||||||
```
|
|
||||||
- Assign milestone and project:
|
|
||||||
```bash
|
|
||||||
gt pr create -t "<title>" -B "<base>" -H "<branch>" -m <milestone-id> -p <project-id> -F <body-file> --json number,url
|
|
||||||
```
|
|
||||||
|
|
||||||
### Edit a Pull Request
|
|
||||||
```bash
|
|
||||||
# Update title or base branch
|
|
||||||
gt pr edit <number> --title "<new-title>"
|
|
||||||
|
|
||||||
# Mark a draft PR as ready for review
|
|
||||||
gt pr ready <number>
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. Review Comments and Discussions
|
|
||||||
|
|
||||||
### List Review Comments
|
|
||||||
```bash
|
|
||||||
# List inline review comments
|
|
||||||
gt pr review comments <number>
|
|
||||||
|
|
||||||
# View PR activity and top-level comments
|
|
||||||
gt pr timeline <number>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Reply to Review Comments
|
|
||||||
```bash
|
|
||||||
# Reply to an inline comment
|
|
||||||
gt pr review reply <number> <comment-id> "Fixed in <sha>"
|
|
||||||
|
|
||||||
# Add top-level comment
|
|
||||||
gt pr comment <number> -b "<comment-text>"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Resolve Review Comments
|
|
||||||
```bash
|
|
||||||
# Mark an inline thread as resolved
|
|
||||||
gt pr review resolve <comment-id>
|
|
||||||
|
|
||||||
# Reopen an inline thread
|
|
||||||
gt pr review unresolve <comment-id>
|
|
||||||
```
|
|
||||||
|
|
||||||
*(Publishing new `code-review` PR review blocks is owned by `code-review` in `skills/code-review/references/finding-schema.md`.)*
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Closing and Merging Pull Requests
|
|
||||||
|
|
||||||
### Close or Reopen PR
|
|
||||||
```bash
|
|
||||||
gt pr close <number>
|
|
||||||
gt pr reopen <number>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Merge Pull Request and Move Card `Review -> Completed` (Requires Explicit Human Authorization)
|
|
||||||
Release and merge authority belongs exclusively to the human owner. Once the owner explicitly approves merging:
|
|
||||||
```bash
|
|
||||||
# 1. Merge pull request (fast-forward / merge commit, or --squash --delete-branch)
|
|
||||||
gt pr merge <number>
|
|
||||||
|
|
||||||
# 2. Extract global issue ID of the linked issue and move its project board card to Completed
|
|
||||||
issue_global_id=$(gt issue view <issue-number> --json id -q .id)
|
|
||||||
gt api -X POST /repos/{owner}/{repo}/projects/<project-id>/issues/${issue_global_id}/move -F column_id=<completed-col-id>
|
|
||||||
```
|
|
||||||
Do not attach the PR itself (`-p <project-id>`) as a duplicate board card when the linked issue is already on the board; if a PR card was attached separately, move it to `Completed` as well.
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
# Pull Request Lifecycle and Evidence Synthesis
|
|
||||||
|
|
||||||
Reference for `gitea-pr`. Defines PR states, evidence synthesis template, and feedback triage workflow.
|
|
||||||
|
|
||||||
## 1. Pull Request Lifecycle States
|
|
||||||
|
|
||||||
```text
|
|
||||||
Draft (WIP) -> Review -> Changes Requested -> Ready for Merge -> Merged
|
|
||||||
| |
|
|
||||||
+-- [Rework/Fix] ----+
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
|
||||||
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`.
|
|
||||||
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.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Standard PR Description Template
|
|
||||||
|
|
||||||
Every PR description synthesizes static provenance and runtime evidence into a transparent record:
|
|
||||||
|
|
||||||
```markdown
|
|
||||||
Closes #<issue-index>
|
|
||||||
|
|
||||||
## Summary of Changes
|
|
||||||
<Concise overview of what was built, why, and what architectural decisions were made.>
|
|
||||||
|
|
||||||
## Scope & Non-Goals
|
|
||||||
- **In Scope**: <Itemized list of changes included in this PR>
|
|
||||||
- **Out of Scope**: <Explicitly deferred items or non-goals>
|
|
||||||
|
|
||||||
## Static Review Provenance (`code-review`)
|
|
||||||
- **Base Commit**: `<base-sha>` -> **Head Commit**: `<head-sha>`
|
|
||||||
- **Committed Diff Fingerprint**: `sha256:<hash>`
|
|
||||||
- **Axes Breakdown**:
|
|
||||||
- Spec & Scope: Pass
|
|
||||||
- Standards & Smells: Pass
|
|
||||||
- Seam & Test Integrity: Pass
|
|
||||||
- Defensive Invariants: Pass
|
|
||||||
- **Review Status**: `Ready`
|
|
||||||
|
|
||||||
## Runtime Verification Ledger (`verify-slice`)
|
|
||||||
| Check ID | Perspective | Scope | Description | Outcome |
|
|
||||||
| :--- | :--- | :--- | :--- | :--- |
|
|
||||||
| RV-01 | Behavioral / Seam | local | Unit & integration suite execution | PASS |
|
|
||||||
| RV-02 | State & Concurrency | local | Race condition & lock invariant check | PASS |
|
|
||||||
| RV-03 | Security / Host Boundary | local | Host socket validation boundary | PASS |
|
|
||||||
|
|
||||||
## Residual Risks & Operational Considerations
|
|
||||||
- **Environment Prerequisites**: <Any required environment variables, sockets, or permissions>
|
|
||||||
- **Reversibility**: <How to cleanly revert this slice if unexpected regressions occur>
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. Review Feedback Triage Workflow
|
|
||||||
|
|
||||||
When comments or change requests arrive on a PR:
|
|
||||||
|
|
||||||
1. **Extract review comments**:
|
|
||||||
```sh
|
|
||||||
gt pr review comments <number>
|
|
||||||
```
|
|
||||||
2. **Categorize comments**:
|
|
||||||
- *Defects & Invariants*: Logic errors, broken tests, edge-case crashes (require code fix).
|
|
||||||
- *Spec & Scope Clarifications*: Questions about intent or architectural fit (require response or doc update).
|
|
||||||
- *Nits / Polish*: Minor style preferences that do not violate repo standards (human owner decides priority).
|
|
||||||
Findings published from a `code-review` comment block arrive pre-labelled with their ID, disposition, and follow-up route (`record` or `issue`); keep those labels instead of re-categorizing.
|
|
||||||
3. **Implement fixes on the feature branch**:
|
|
||||||
- Use `tdd` or direct edits.
|
|
||||||
- Commit fixes incrementally following `git-manager` conventions (e.g. `fix(gitea-pr): address review feedback`).
|
|
||||||
4. **Re-verify after changes**:
|
|
||||||
- Run `code-review` to confirm the updated diff fingerprint is clean.
|
|
||||||
- Run `verify-slice` to substantiate runtime assertions.
|
|
||||||
5. **Reply and resolve threads via `gt pr`**:
|
|
||||||
- Reply to comment: `gt pr review reply <number> <comment-id> "Fixed in <sha>"`
|
|
||||||
- Resolve thread: `gt pr review resolve <comment-id>`
|
|
||||||
6. **Push updates to remote**:
|
|
||||||
- `git push origin <branch>`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Release Authority Guardrail
|
|
||||||
|
|
||||||
Automated skills and checks inform the human owner; they never make the merge decision independently:
|
|
||||||
- Neither passing unit tests nor a `Ready` code review implies permission to execute `gt pr merge`.
|
|
||||||
- The human owner reviews the consolidated ledger, assesses residual risks, and explicitly authorizes merge execution.
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# [DEPRECATED] Tea CLI Pull Request Subroutines
|
|
||||||
|
|
||||||
> **Notice**: Upstream `tea` CLI is archived and officially deprecated in favor of `gt` (`gitea/cli`).
|
|
||||||
> For verified command patterns and JSON recipes, use **`skills/gitea-pr/references/gt-pulls.md`**.
|
|
||||||
|
|
||||||
This document is preserved for historical reference and legacy instance migrations only.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Legacy Commands Reference (Archived)
|
|
||||||
|
|
||||||
### 1. Inspecting Pull Requests (Legacy)
|
|
||||||
```sh
|
|
||||||
tea pulls list
|
|
||||||
tea pulls <index>
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Creating Pull Requests (Legacy)
|
|
||||||
```sh
|
|
||||||
tea pulls create --title "<title>" --base "<base>" --head "<head>" --description-file -
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Review Comments (Legacy)
|
|
||||||
```sh
|
|
||||||
tea pulls review-comments <index>
|
|
||||||
tea pulls reply <index> <comment-id> "<reply-text>"
|
|
||||||
tea pulls resolve <comment-id>
|
|
||||||
```
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
name: gitea-to-github
|
||||||
|
description: >-
|
||||||
|
Migrates standalone repositories or Gitea organizations from self-hosted Gitea
|
||||||
|
to GitHub, converting each Gitea repo into a pull mirror. Use when migrating
|
||||||
|
a Gitea repo or org, translating .gitea/workflows/ CI to GitHub Actions, or
|
||||||
|
updating legacy Gitea AGENTS.md contracts to GitHub Projects v2.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Gitea to GitHub
|
||||||
|
|
||||||
|
## Use when
|
||||||
|
- Migrating a standalone Gitea repository or `--org <gitea-org>` to GitHub primary with a Gitea pull mirror.
|
||||||
|
- Translating `.gitea/workflows/` to `.github/workflows/` and legacy `AGENTS.md` contracts to `project_number: <int>`.
|
||||||
|
- Not for ad-hoc Gitea operations outside migration: use `gt-usage`.
|
||||||
|
- Not for ongoing GitHub planning or slice execution: use `projects` or `implement`.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
1. **Preflight and dry-run plan.** Read [references/remote-and-mirror.md](references/remote-and-mirror.md) and [references/entity-migration.md](references/entity-migration.md). Run read-only discovery first (dry-run is default; `--dry-run` optional). Verify `gt`/`gh` auth, `new-repo --empty --no-mirror --no-clone`, live `mirror: true` skip, `git lfs ls-files` fail-fast, `empty`/`archived` state, and dirty `AGENTS.md`/`.gitea/workflows/` paths. Halt after printing the segmented inventory/plan unless `--execute` or explicit approval is given (`interactive-gated` repos still pause per item).
|
||||||
|
2. **Snapshot and resolve open PRs.** Export Gitea JSON metadata (issues, PRs, milestones, releases, webhooks) to `$XDG_STATE_HOME/gitea-to-github-backup/<repo>/` under `umask 077`. Require an explicit per-PR choice (`merge`, `push branch + recreate PR`, `close`, or `abort`) for every open Gitea PR.
|
||||||
|
3. **Provision GitHub and push refs.** Invoke `new-repo <target> --empty --no-mirror --no-clone` from a fresh `mktemp -d` non-git directory (skip if target GitHub repo exists). Push explicit `refs/heads/*:refs/heads/*` and `refs/tags/*:refs/tags/*` refspecs from a temp bare clone after verifying branch ancestry on resume.
|
||||||
|
4. **Conditional Projects v2 onboarding.** Only if a legacy Gitea board or contract exists (or user opts in during dry-run), create or link the 5-column Projects v2 board via `../projects/references/github-projects-v2.md`.
|
||||||
|
5. **Translate CI and `AGENTS.md` in `/tmp/`.** Read [references/ci-and-contracts.md](references/ci-and-contracts.md). Skip if planned updates already exist on GitHub; otherwise translate `.gitea/workflows/` to `.github/workflows/`, rewrite `README.md` badges, warn on non-`GITEA_TOKEN` secrets, and rewrite legacy `AGENTS.md` to `project_number: <int>` in an ephemeral `/tmp/` clone and push.
|
||||||
|
6. **Migrate milestones and open issues.** Sync open milestones and curated open issues idempotently using `<!-- gitea-origin: <gitea-host>/<owner>/<repo>#<number> -->` markers.
|
||||||
|
7. **Flip local `origin`, archive, and mirror.** If a local checkout exists, delegate `origin` flip and `git pull` to `git-manager`. Rename Gitea repo to `<repo>-archive-YYYYMMDDHHMMSS` (`<= 77`-char base), attach pull mirror via `new-repo --gitea-mirror`, verify SHA parity within `60s`, and delete the archive only after explicit confirmation.
|
||||||
|
|
||||||
|
## Your call
|
||||||
|
- Dry-run approval, `--org` selection/overrides, and any `archived: true` unarchive decision.
|
||||||
|
- Per-PR resolution for open Gitea PRs and per-issue curation.
|
||||||
|
- Opt-in to `self-hosted` runners (`private` repos only) or conditional Projects v2 board creation.
|
||||||
|
- Explicit confirmation before deleting `<repo>-archive-YYYYMMDDHHMMSS`.
|
||||||
|
|
||||||
|
## Done when
|
||||||
|
- GitHub has all refs, planned `.github/workflows/` and `AGENTS.md` updates, and curated issues/milestones, and Gitea pull-mirror SHA parity is verified.
|
||||||
|
|
||||||
|
## Hands off to
|
||||||
|
- `git-manager`: local `origin` remote flip, dirty working-tree resolution, and `git pull`.
|
||||||
|
- `projects`: new Projects v2 board setup or roadmap decomposition after migration.
|
||||||
|
- `diagnose`: mid-flight API or network failures before resuming idempotently.
|
||||||
|
- `gt-usage`: standalone Gitea queries outside migration.
|
||||||
|
- Standalone turns end with `Suggested Next Step: /projects` (if planning work) or `Suggested Next Step: /implement` (suppressed when delegated).
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# CI Workflow & Planning Contract Migration
|
||||||
|
|
||||||
|
Detailed procedure for Step 5 of `gitea-to-github`. All edits run inside an ephemeral `/tmp/` clone of the newly pushed GitHub repository before Gitea pull-mirror attachment.
|
||||||
|
|
||||||
|
## 1. Resume Guard
|
||||||
|
|
||||||
|
Before modifying files in `/tmp/`, inspect the GitHub default branch:
|
||||||
|
- If all planned `.github/workflows/` files and `AGENTS.md` (`project_number: <int>` when applicable) are already present, skip Step 5 without creating duplicate commits.
|
||||||
|
|
||||||
|
## 2. `.gitea/workflows/` to `.github/workflows/` Translation
|
||||||
|
|
||||||
|
1. **Move Workflows:** Move `.gitea/workflows/*.yml` and `.gitea/workflows/*.yaml` to `.github/workflows/` (removing `.gitea/workflows/` once migrated).
|
||||||
|
2. **Context & Secret Translation:**
|
||||||
|
- Replace `${{ gitea.* }}` expressions with `${{ github.* }}`.
|
||||||
|
- Replace `secrets.GITEA_TOKEN` / `GITEA_TOKEN` with `secrets.GITHUB_TOKEN` / `GITHUB_TOKEN`.
|
||||||
|
- Extract all non-`GITEA_TOKEN` `${{ secrets.<NAME> }}` references and warn the user during dry-run and Step 5 so those secrets can be provisioned on GitHub.
|
||||||
|
3. **Runner Label Mapping & Security Boundary:**
|
||||||
|
- Default `runs-on:` to GitHub-hosted `ubuntu-latest` for both `public` and `private` repositories.
|
||||||
|
- Allow `self-hosted` only when the user explicitly opts in during dry-run review AND the target GitHub visibility is `private`. **Block `self-hosted` opt-in on `public` repositories** to prevent PR supply-chain RCE against homelab runners.
|
||||||
|
4. **Badges & External Action URLs:**
|
||||||
|
- Automatically rewrite standard Gitea workflow status badge URLs in `README.md` to GitHub Actions badge URLs (`https://github.com/<owner>/<repo>/actions/workflows/<file>/badge.svg`) when the corresponding workflow is migrated.
|
||||||
|
- Flag non-standard Gitea-hosted action URLs (`https://<gitea-host>/...`) or custom badge URLs for explicit user review/replacement.
|
||||||
|
|
||||||
|
## 3. Legacy `AGENTS.md` Planning Contract Rewrite
|
||||||
|
|
||||||
|
1. **Detect Legacy Contracts:** Inspect repo `AGENTS.md` for legacy `gitea-plan` fields (Gitea `project_id`, `{Backlog..Completed -> column_id}` maps, hex colors, or `gitea-plan` sync rules).
|
||||||
|
2. **Rewrite to State-Free Schema:** Propose rewriting legacy planning sections to the state-free `project_number: <int>` contract defined in `../../projects/references/planning-contract.md` (when a Projects v2 board was created/linked in Step 4, or remove stale Gitea board IDs for `Small`-tier boardless repos).
|
||||||
|
3. **Commit & Push:** Commit translated `.github/workflows/`, updated `README.md` badges, and rewritten `AGENTS.md` in the `/tmp/` clone and push to GitHub before Step 7 creates the Gitea pull mirror.
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
# Org Inventory, Issues, Milestones & Conditional Projects v2
|
||||||
|
|
||||||
|
Detailed procedure for Steps 1, 4, and 6 of `gitea-to-github`.
|
||||||
|
|
||||||
|
## 1. Segmented `--org` Dry-Run Inventory
|
||||||
|
|
||||||
|
1. **Paginated Gitea Discovery:** Query all org repositories, open PRs, and open issues using paginated Gitea API calls (`page=1..N`).
|
||||||
|
2. **Classification Taxonomy:** Classify each repository into one or more states:
|
||||||
|
- `migratable` (clean-slate)
|
||||||
|
- `already-pull-mirror` (`mirror: true`)
|
||||||
|
- `sovereign-opt-out` (`forge: gitea` in `AGENTS.md`)
|
||||||
|
- `has-lfs-blocked`
|
||||||
|
- `has-open-prs`
|
||||||
|
- `has-open-issues`
|
||||||
|
- `empty` (0 commits)
|
||||||
|
- `archived` (`archived: true`)
|
||||||
|
3. **Segmentation:** Present a single dry-run inventory table segmented into:
|
||||||
|
- **Clean-slate:** Zero open PRs and no per-item curation needed; execute sequentially from one approval (applying any user-stated overrides such as visibility or target org).
|
||||||
|
- **Interactive-gated:** Has open PRs (`has-open-prs`) or open issues needing curation (`has-open-issues`); prompt per repository before mutation.
|
||||||
|
|
||||||
|
## 2. Milestones & Idempotent Issue Migration
|
||||||
|
|
||||||
|
1. **Paginated GitHub Queries:** Fetch existing GitHub milestones and issues to guarantee idempotent `/diagnose` resume:
|
||||||
|
```bash
|
||||||
|
gh api --paginate repos/{owner}/{repo}/milestones?state=all
|
||||||
|
gh api --paginate repos/{owner}/{repo}/issues?state=all --jq '.[] | select(.pull_request == null)'
|
||||||
|
```
|
||||||
|
2. **Milestones:** Match Gitea open milestones by `title`. Create missing milestones on GitHub with `title`, `description`, and `due_on` (omitting `due_on` whenever the Gitea timestamp is null or zero).
|
||||||
|
3. **Labels & Attachments:**
|
||||||
|
- Pre-create any missing Gitea issue labels on GitHub before creating issues (`gh label create` with color/description).
|
||||||
|
- Scan curated open Gitea issue bodies for `/attachments/<uuid>` URLs; warn the user before archive deletion that those links will break once `<repo>-archive-YYYYMMDDHHMMSS` is removed.
|
||||||
|
4. **Immutable Deduplication Marker:** Append the following marker to the bottom of every migrated GitHub issue body (with `<gitea-host>` normalized to lowercase hostname without scheme or port):
|
||||||
|
```markdown
|
||||||
|
<!-- gitea-origin: <gitea-host>/<owner>/<repo>#<number> -->
|
||||||
|
```
|
||||||
|
Skip any Gitea issue whose origin marker already appears in the paginated GitHub issues list.
|
||||||
|
|
||||||
|
## 3. Conditional Projects v2 Onboarding
|
||||||
|
|
||||||
|
1. **Trigger Condition:** Create or link a 5-column Projects v2 board (`Backlog`, `Ready`, `Work in Progress`, `Review`, `Completed`) **only** when the source repo has a legacy Gitea board/contract or when the user explicitly opts in during dry-run. Leave new board creation for boardless repos to `projects` (respecting its tiered `Project Board Policy`).
|
||||||
|
2. **GraphQL Delegation:** Delegate all Projects v2 GraphQL mutations strictly to `../../projects/references/github-projects-v2.md`.
|
||||||
|
3. **Column Mapping:** Map legacy Gitea board columns case-insensitively onto the 5 canonical GitHub columns:
|
||||||
|
- `To Do`, `Open`, `Backlog` -> `Backlog`
|
||||||
|
- `Ready` -> `Ready`
|
||||||
|
- `In Progress`, `Doing`, `Work in Progress` -> `Work in Progress`
|
||||||
|
- `Review`, `In Review` -> `Review`
|
||||||
|
- `Done`, `Closed`, `Completed` -> `Completed`
|
||||||
|
- Unmatched column names -> fallback to `Backlog`.
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# Remote, Git Push, and Mirror Swap
|
||||||
|
|
||||||
|
Detailed procedure for Steps 1, 2, 3, and 7 of `gitea-to-github`.
|
||||||
|
|
||||||
|
## 1. Preflight Checks
|
||||||
|
|
||||||
|
1. **Tool & Auth Verification:** Verify `gt auth status` (or active Gitea token), `gh auth status`, and `command -v new-repo`.
|
||||||
|
2. **Host Discovery (No Hardcoded Domains):** Derive `<gitea-host>` dynamically from the repository's `origin` remote URL or the active `gt` CLI host configuration, normalized to lowercase hostname without scheme or port.
|
||||||
|
3. **Live Mirror & Sovereign Checks:** Query Gitea repo metadata (`GET /api/v1/repos/{owner}/{repo}`):
|
||||||
|
- If `mirror: true`, skip migration (already a pull mirror).
|
||||||
|
- If `archived: true`, classify as `archived`; Gitea blocks renames and visibility updates on archived repos, so unarchive only with explicit user approval.
|
||||||
|
- If `empty: true` (0 commits), classify as `empty` and skip git ref pushes and `/tmp/` clone commits.
|
||||||
|
4. **Git LFS Fail-Fast:** Check `git lfs ls-files` (or `.gitattributes` `filter=lfs`). If LFS objects exist, fail fast and skip migration.
|
||||||
|
5. **Dirty Local Path Check:** If a local checkout exists, run `git status --porcelain -- AGENTS.md .gitea/workflows/`. If uncommitted edits exist on those paths, prompt the user to commit or stash them via `git-manager` first, or continue via the `/tmp/` clone and skip the post-swap local `git pull`.
|
||||||
|
6. **Visibility Mapping:** Map Gitea `public` -> GitHub `public`, `private` -> GitHub `private`, and `internal` -> GitHub `private` (emitting an explicit warning). If the target GitHub repo already exists as `private`, update the Gitea repo to `private` before mirroring.
|
||||||
|
|
||||||
|
## 2. Pre-Migration Backup & Open PR Gate
|
||||||
|
|
||||||
|
1. **Secure JSON Snapshot:** Create `$XDG_STATE_HOME/gitea-to-github-backup/<repo>/` (falling back to `~/.local/state/gitea-to-github-backup/<repo>/`) with `umask 077` (`0700` dir, `0600` files). Export paginated Gitea JSON snapshots for open/closed issues, PRs, milestones, releases, and webhooks.
|
||||||
|
2. **Open PR Gate:** Never auto-merge conflicting or unreviewed Gitea PRs. List every open PR with draft, mergeable, and CI status and require an explicit per-PR choice before proceeding:
|
||||||
|
- `merge`: merge on Gitea before cloning refs.
|
||||||
|
- `push branch + recreate PR`: push head/base branches to GitHub and recreate the PR on GitHub.
|
||||||
|
- `close`: close on Gitea (preserved in JSON snapshot).
|
||||||
|
- `abort`: halt migration for this repository.
|
||||||
|
|
||||||
|
## 3. Empty GitHub Provisioning & Idempotent Ref Push
|
||||||
|
|
||||||
|
1. **Check Existing GitHub Repo (Resume Guard):** Run `gh repo view <gh-owner>/<repo> --json name,defaultBranchRef`. If it already exists, skip `new-repo` creation.
|
||||||
|
2. **Non-Git Temp Directory Creation:** Otherwise, **always invoke `new-repo` from a fresh non-git temporary directory (`mktemp -d`)** so `new_repo.py`'s `determine_target()` never sees `.git` and never triggers `link_and_push_existing()` to overwrite local `origin`:
|
||||||
|
```bash
|
||||||
|
(cd "$(mktemp -d)" && new-repo <target> --empty --no-mirror --no-clone [-o <gh-org>] [-p])
|
||||||
|
```
|
||||||
|
3. **Explicit Refspec Push & Ancestry Guard:** Clone Gitea into a temp bare directory (`git clone --bare <gitea-url> <tmp-bare>`). Before pushing, if the target GitHub repo already has branches (e.g., on `/diagnose` resume), verify whether each Gitea branch tip is already an ancestor of the corresponding GitHub branch; never force-push over Step 5 `/tmp/` commits. Push explicit refspecs only (avoiding Gitea internal refs such as `refs/pull/*`):
|
||||||
|
```bash
|
||||||
|
git push <github-url> 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'
|
||||||
|
```
|
||||||
|
Set GitHub's default branch to match Gitea's and verify `HEAD`, branch list, and tag list align.
|
||||||
|
|
||||||
|
## 4. Ephemeral `/tmp/` Commit, Archive Rename & Pull Mirror Swap
|
||||||
|
|
||||||
|
1. **Ephemeral `/tmp/` Clone:** Apply planned `.github/workflows/`, `README.md` badge updates, and `AGENTS.md` rewrites inside a fresh `/tmp/` clone of `<github-url>`, commit, and push to GitHub before touching Gitea. On resume, skip if the planned updates are already present on GitHub.
|
||||||
|
2. **Local Checkout Update:** If a local checkout exists, delegate flipping `origin` to `<github-url>`, resolving any dirty working-tree state, and pulling the migration commit (unless skipped due to colliding local edits) to `git-manager`.
|
||||||
|
3. **Archive Rename (100-Char Limit):** Compute UTC timestamp `YYYYMMDDHHMMSS` (`-archive-YYYYMMDDHHMMSS` is 23 chars). Truncate the `<repo>` base name to `<= 77` chars if needed so `<base>-archive-YYYYMMDDHHMMSS` stays within Gitea's 100-char limit, then rename via `PATCH /api/v1/repos/{owner}/{repo}`.
|
||||||
|
4. **Pull Mirror Attachment & Sync Verification:** Attach the Gitea pull mirror (passing private-repo credentials per `new-repo`'s mirror auth contract):
|
||||||
|
```bash
|
||||||
|
(cd "$(mktemp -d)" && new-repo --gitea-mirror <github-url> [-p] [--gitea-org <gitea-org>])
|
||||||
|
```
|
||||||
|
Trigger `POST /api/v1/repos/{owner}/{repo}/mirror-sync`, then poll `GET /api/v1/repos/{owner}/{repo}` and compare Gitea's default-branch commit SHA against GitHub's default-branch SHA every `3s` up to a `60s` timeout.
|
||||||
|
5. **Destructive Archive Deletion Gate:** Only after SHA parity is confirmed, ask for explicit user confirmation before deleting `<base>-archive-YYYYMMDDHHMMSS`.
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
---
|
---
|
||||||
name: gt-usage
|
name: gt-usage
|
||||||
description: >-
|
description: >-
|
||||||
Work with Gitea repositories, issues, milestones, projects, and pull requests
|
Standalone ad-hoc utility for working with Gitea repositories, issues,
|
||||||
using the official gt CLI. Use when querying or mutating Gitea entities,
|
milestones, projects, and pull requests using the official gt CLI outside the
|
||||||
extracting resource identifiers, or configuring instance remotes.
|
GitHub core delivery loop. Use when querying or mutating Gitea entities,
|
||||||
|
extracting resource identifiers, or configuring Gitea instance remotes.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Gitea CLI Usage
|
# Gitea CLI Usage
|
||||||
|
|
||||||
## Use when
|
## Use when
|
||||||
- Querying, creating, or editing Gitea issues, milestones, project boards, or PRs.
|
- Ad-hoc querying, creating, or editing Gitea issues, milestones, project boards, or PRs on Gitea-hosted repos or mirrors.
|
||||||
- Extracting exact server identifiers and URLs via JSON output.
|
- Extracting exact server identifiers and URLs via JSON output.
|
||||||
- Configuring instance remotes or SSH port mappings for sovereign instances.
|
- Configuring instance remotes or SSH port mappings for sovereign Gitea instances.
|
||||||
- Not for planning or issue decomposition: use `gitea-plan`.
|
- Standalone utility outside the GitHub core delivery loop (`projects`, `implement`, `code-review`, `verify`).
|
||||||
- Not for pull request review synthesis: use `gitea-pr`.
|
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
1. **Verify CLI availability and auth.** Run `gt auth status`. If unauthenticated,
|
1. **Verify CLI availability and auth.** Run `gt auth status`. If unauthenticated,
|
||||||
@@ -41,5 +41,6 @@ description: >-
|
|||||||
- Target Gitea entity is created, queried, or updated with confirmed server JSON output.
|
- Target Gitea entity is created, queried, or updated with confirmed server JSON output.
|
||||||
|
|
||||||
## Hands off to
|
## Hands off to
|
||||||
- `gitea-plan`: to decompose technical work into milestones and issues.
|
- `gitea-to-github`: when migrating a Gitea repository or org to GitHub primary with a Gitea pull mirror.
|
||||||
- `gitea-pr`: to manage pull request review and merge readiness.
|
- `git-manager`: for local branch, commit, or remote configuration work.
|
||||||
|
- `projects`: when planning active delivery workflows on GitHub instead of ad-hoc Gitea usage.
|
||||||
@@ -91,6 +91,9 @@ gt issue edit <number> --title "<new-title>" -m <milestone-id>
|
|||||||
|
|
||||||
# Close an issue
|
# Close an issue
|
||||||
gt issue close <number>
|
gt issue close <number>
|
||||||
|
|
||||||
|
# Log elapsed implementation time (seconds) to an issue without a global stopwatch lock
|
||||||
|
gt api -X POST /repos/{owner}/{repo}/issues/<issue-index>/times -F time=<seconds>
|
||||||
```
|
```
|
||||||
|
|
||||||
## 5. Pull Requests
|
## 5. Pull Requests
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
---
|
|
||||||
name: implement-slice
|
|
||||||
description: >-
|
|
||||||
Orchestrates end-to-end delivery of a Gitea issue or vertical feature slice
|
|
||||||
across delegated implementation and QA subagents, checkpoint commits, static
|
|
||||||
review, and pull request packaging. Never edits implementation code or
|
|
||||||
self-certifies QA. Not for decomposing epics into issues (use gitea-plan) or
|
|
||||||
executing a single already-delegated worker task (use tdd and git-manager).
|
|
||||||
---
|
|
||||||
|
|
||||||
# Implement Slice
|
|
||||||
|
|
||||||
## Use when
|
|
||||||
- Delivering an approved Gitea issue or bounded feature slice end to end via coordinated subagents.
|
|
||||||
- Coordinating multi-task checkpoints, pre-committed QA rubrics, and final review gates.
|
|
||||||
- Not for decomposing raw epics into milestones and issues: use `gitea-plan`.
|
|
||||||
- Not inside an already-delegated implementation worker task: follow the assigned worker contract (`tdd`, `git-manager`) without re-invoking `implement-slice`.
|
|
||||||
|
|
||||||
## Steps
|
|
||||||
1. **Preflight branch check, readiness audit, and `Backlog -> Ready`.** Check session mode per `profile/AGENTS.md`. Classify working tree per [handoff-contracts](references/handoff-contracts.md) (`CLEAN_BASE`, `ADOPTABLE_DIFF`, `CONFLICTING_STATE`, `WRONG_BASE`). Stop on conflicts. Read target Gitea issue/milestone/board state via `gt issue`, `gt milestone`, direction docs (`ARCHITECTURE.md`, `ROADMAP.md`, `docs/designs/*.md`, `AGENTS.md`), and `git status --short`. Reconcile issue acceptance criteria against current `HEAD` (handing off to `reconcile-docs` if canonical design docs drifted during upstream slices, or updating the Gitea issue after owner approval) and, when `--dry-run` is not active, move the issue card `Backlog -> Ready` on the project board. Hand off to `gitea-plan` if tracking issues must be created first.
|
|
||||||
2. **Select orchestration topology (`complexity x risk`).** Combine planning size with assurance risk per [orchestration-tiers](references/orchestration-tiers.md). Keep pure-orchestrator invariants: retain plan, status, commit SHAs, QA dispositions, blockers; never edit implementation files, repair Git via code edits, self-certify QA, or ingest full test logs unless resolving a failure.
|
|
||||||
3. **Lock Planned Workflow and pre-committed rubrics.** Formulate the Planned Workflow using the Canonical Node Schema (5-tuples: `node_id`, `claim`, `method`, `executor`, `pass_condition`), decomposing multi-module slices into bottom-up vertical per-submodule `Red -> Green` tasks rather than horizontal "all tests first, all code second" batching per [orchestration-tiers](references/orchestration-tiers.md). Project a dynamic Mermaid diagram deriving directly from node IDs with visible rework edges. If `--dry-run` is active, halt after displaying the plan (enforce 0 file changes, 0 commits, 0 remote calls). Hard gate: pause for human approval.
|
|
||||||
4. **Move card `Ready -> Work in Progress`, assign workspaces, and delegate.** Once the human approves Step 3, move the issue card `Ready -> Work in Progress` on the project board per [handoff-contracts](references/handoff-contracts.md). Govern branch/worktree lifecycle through `git-manager` per [orchestration-tiers](references/orchestration-tiers.md). Dispatch worker subagent(s) with the Implementation Assignment in [handoff-contracts](references/handoff-contracts.md). Never run concurrent workers in the same working tree. Update the runtime Execution Record table as nodes change state.
|
|
||||||
5. **Audit worker reports and run rubric QA.** Verify worker reports via read-only Git checks. Spawn read-only QA subagents running `verify-slice` against pre-committed rubrics. Update Execution Record with concrete evidence (SHA, exit codes).
|
|
||||||
6. **Triage outcomes and route rework.** Classify failures using [handoff-contracts](references/handoff-contracts.md): route code defects to existing worker via `send_message`; record justified rubric amendments if criteria change. Loop Steps 4-6 until all nodes pass.
|
|
||||||
7. **Enforce final-HEAD evidence, move card `Work in Progress -> Review`, and integrate.** Confirm `code-review` (`Ready`) and `verify-slice` match the exact final `HEAD` and base, then move the issue card `Work in Progress -> Review` on the project board. Present the Execution Deviation Report (skipped/added checks, rework iterations, scope drift; if scope drift evolved a contract in `docs/designs/*.md` or `ARCHITECTURE.md`, prompt to run `reconcile-docs` before the next slice). Integrate per [orchestration-tiers](references/orchestration-tiers.md) Policy Matrix: fast-forward merge (and move card `Review -> Completed`) if repo `AGENTS.md` permits and user approves, else hand off to `gitea-pr`.
|
|
||||||
|
|
||||||
## Your call
|
|
||||||
- **Session mode**: decide whether to switch from `learning` to `delivery` before autonomous delegation.
|
|
||||||
- **Planned workflow and rubrics**: approve task breakdown, node 5-tuples, assurance tier, and QA rubrics before workers spawn.
|
|
||||||
- **Rubric amendments, live-infra, and trade-offs**: approve rubric criteria changes, authorize `live-infra` checks, and adjudicate review conflicts.
|
|
||||||
- **Integration authorization**: authorize direct merge to main or PR creation and merge.
|
|
||||||
|
|
||||||
## Done when
|
|
||||||
- All slice checkpoints are committed on a clean target branch, `code-review` (`Ready`) and `verify-slice` match the same final `HEAD`, the Execution Deviation Report is recorded, and the branch is integrated per policy.
|
|
||||||
|
|
||||||
## Hands off to
|
|
||||||
- `gitea-plan`: when goals or epics require milestone and issue decomposition before slice execution.
|
|
||||||
- `git-manager`: to create/integrate slice branches and worktrees, commit worker checkpoints, or stop on conflicts.
|
|
||||||
- `tdd`: inside workers for seam-level red-green development, or standalone test hardening (`Suggested Next Step: /tdd <test-path>`).
|
|
||||||
- `verify-slice`: inside QA subagents for pre-committed chunk and final-`HEAD` runtime verification.
|
|
||||||
- `code-review`: for final-slice 4-axis static and strategic alignment inspection.
|
|
||||||
- `diagnose`: when an unexpected failure requires evidence-first root-cause investigation.
|
|
||||||
- `gitea-pr`: when policy or remote CI mandates a PR and final-`HEAD` packets are ready (`Suggested Next Step: /gitea-pr #<issue>`).
|
|
||||||
- `reconcile-docs`: when design specs drifted (`Suggested Next Step: /reconcile-docs`); on `--dry-run` or post-merge next slice, emit `Suggested Next Step: /implement-slice #<issue>`.
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
# Handoff Contracts, Failure Triage, and Final-HEAD Invariant
|
|
||||||
|
|
||||||
Reference for `implement-slice`. Every delegation uses explicit, bounded schemas so subagents execute deterministically and return compact evidence packets.
|
|
||||||
|
|
||||||
## 1. Preflight Branch and Worktree Safeguards
|
|
||||||
|
|
||||||
Before decomposing or delegating work, inspect `git status --short` and `git branch -v`:
|
|
||||||
|
|
||||||
| Working Tree & Branch State | Classification | Orchestrator Action |
|
|
||||||
| :--- | :--- | :--- |
|
|
||||||
| **Clean tree on target base branch** | `CLEAN_BASE` | Proceed directly to plan formulation. |
|
|
||||||
| **Tree contains uncommitted changes matching the target slice** | `ADOPTABLE_DIFF` | Offer to adopt uncommitted changes into the new slice branch. |
|
|
||||||
| **Tree has uncommitted edits to unrelated files or sits on an unmerged PR branch** | `CONFLICTING_STATE` | **Hard Stop.** Report active branch and diff stat. Offer structured options (stash, commit to existing branch, switch). |
|
|
||||||
| **Current branch does not match intended base** | `WRONG_BASE` | **Hard Stop.** Halt and prompt user to switch to target base before branching. |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Implementation Assignment (Orchestrator -> Worker)
|
|
||||||
|
|
||||||
Provide before spawning (or messaging) an implementation worker:
|
|
||||||
|
|
||||||
- **Session Mode & Anti-Recursion**: Active mode (`mode: delivery`) plus explicit instruction: execute this task directly using `tdd` and `git-manager`; do not invoke `implement-slice` or spawn nested workers unless explicitly authorized.
|
|
||||||
- **Task ID & Objective**: Concrete deliverable outcome and linked Gitea issue (`#<id>` when applicable).
|
|
||||||
- **Assigned Workspace & Branch**: Exact repository/worktree path and non-default working branch name.
|
|
||||||
- **Scope Boundary**: In-scope files/interfaces and explicit out-of-scope exclusions (preventing opportunistic refactors).
|
|
||||||
- **Acceptance Criteria**: Numbered, falsifiable conditions this task must satisfy.
|
|
||||||
- **Checkpoint Expectation**: Expected coherent commit boundary (or boundaries) following `git-manager` Conventional Commits.
|
|
||||||
- **Required Compact Report**: Request concise structured output (no raw multi-hundred-line logs unless a check fails) and instruct the worker to suppress standalone `Suggested Next Step` footers.
|
|
||||||
|
|
||||||
## 3. Implementation Report (Worker -> Orchestrator)
|
|
||||||
|
|
||||||
Require each worker to return:
|
|
||||||
|
|
||||||
- **Summary of Changes**: Touched files/seams and 2-5 bullet summary of what changed.
|
|
||||||
- **Criteria Coverage**: Mapping from assigned acceptance criteria to test or command proof.
|
|
||||||
- **Verification Summary**: Commands run (`pytest`, `cargo test`, typecheck, lint) with exit codes and pass counts.
|
|
||||||
- **Checkpoint Commits**: Exact commit SHA(s) and subject lines created, plus confirmation that `git status --short` is clean.
|
|
||||||
- **Scope Deviations or Open Risks**: Any unexpected constraint, untouched edge case, or blocker encountered (`None` if clean).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Pre-Committed QA Rubric Assignment (Orchestrator -> QA Subagent)
|
|
||||||
|
|
||||||
The rubric is written and approved during Step 3 (before implementation begins). When spawning the QA subagent:
|
|
||||||
|
|
||||||
- **Target Revision & Workspace**: Exact commit SHA (`HEAD`), base ref, and workspace path. State clearly: do not modify tracked files; leave `git status --short` clean.
|
|
||||||
- **Assurance Tier & Mode**: `Lightweight`, `Standard`, or `High-Assurance` per `verify-slice`. For `High-Assurance` black-box runs, withhold the diff narrative and worker self-audit.
|
|
||||||
- **Pre-Committed Falsifiable Checks**: Numbered checks with scope (`local` vs. `live-infra`), exact pass conditions, `FAIL if ...` signals, and any `code-review` Step 6 `RV-*` checks.
|
|
||||||
- **Authorization Boundary**: Explicitly state whether any `live-infra` check has human owner authorization for this run (default: unauthorized -> record `BLOCKED (out-of-bounds)`). Suppress standalone `Suggested Next Step` footers; return only the compact QA report.
|
|
||||||
|
|
||||||
## 5. QA Report (QA Subagent -> Orchestrator)
|
|
||||||
|
|
||||||
Follows the `verify-slice` disposition contract:
|
|
||||||
|
|
||||||
- **Tested Revision**: Confirmed `HEAD` SHA and clean working-tree verification.
|
|
||||||
- **Check Dispositions**: Per-criterion result (`PASS`, `FAIL`, `BLOCKED (env/fixture)`, `BLOCKED (out-of-bounds)`, or `INCONCLUSIVE`) with concise observable evidence.
|
|
||||||
- **Confirmed Defects**: Reproducible failure steps, severity, and expected vs. actual behavior.
|
|
||||||
- **Rubric Fitness**: Explicit note if any rubric criterion proved ambiguous, untestable, or mismatched against repository reality.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 6. The Tripartite Workflow Contract Schemas
|
|
||||||
|
|
||||||
### A. Planned Workflow Schema (Step 3 Gate)
|
|
||||||
```markdown
|
|
||||||
### Planned Workflow
|
|
||||||
- **Task Breakdown**:
|
|
||||||
- `TASK-01`: <Objective> (Role: Worker, Scope: <files>, Commits: <expected-commits>)
|
|
||||||
- **Verification Plan**:
|
|
||||||
- `CHK-01`: Claim: <invariant>, Method: <cmd>, Executor: <role>, Pass: <condition>, Failure: <route>
|
|
||||||
- **Workflow Graph**:
|
|
||||||
```mermaid
|
|
||||||
<dynamic-projection-from-nodes>
|
|
||||||
```
|
|
||||||
```
|
|
||||||
|
|
||||||
### B. Execution Record Schema (Steps 4-5 Log)
|
|
||||||
Updated dynamically in orchestrator turns:
|
|
||||||
```markdown
|
|
||||||
| Node ID | Claim / Invariant | Method | Executor | Evidence | Pass Condition | Status |
|
|
||||||
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|
|
||||||
| `TASK-01` | <claim> | <method> | <role> | Commit `<sha>` | Clean tree | `passed` |
|
|
||||||
| `CHK-01` | <claim> | <method> | <role> | Exit 0 stdout | Exit 0 | `passed` |
|
|
||||||
```
|
|
||||||
|
|
||||||
### C. Deviation Report Schema (Step 6 Handoff)
|
|
||||||
```markdown
|
|
||||||
### Execution Deviation Report
|
|
||||||
- **Skipped Checks**: <None | List of skipped checks with explicit rationale>
|
|
||||||
- **Added Checks**: <None | New checks introduced in response to findings>
|
|
||||||
- **Rework Iterations**: <0 | Details of remediation loops and commit references>
|
|
||||||
- **Scope Drift**: <None | Differences between planned and actual seams; if an approved contract evolution leaves `docs/designs/*.md` or `ARCHITECTURE.md` stale, flag a `reconcile-docs` handoff before the next slice>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Dynamic Mermaid Projection Rules
|
|
||||||
- **Derive directly from nodes**: Nodes in the graph must match `node_id`s from the planned workflow table.
|
|
||||||
- **Expose falsification routes**: Graph edges must explicitly show failure paths (e.g. `QA -- "Fail (rework)" --> Worker`).
|
|
||||||
- **Never paste generic templates**: Every diagram must reflect the exact slice tasks and assurance checks.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 7. Failure Triage and Rubric Amendment Routing
|
|
||||||
|
|
||||||
Never relay "QA failed" blindly. Classify each non-passing outcome and route to the right owner:
|
|
||||||
|
|
||||||
| Observed Outcome | Classification | Orchestrator Action |
|
|
||||||
| :--- | :--- | :--- |
|
|
||||||
| Behavioral check `FAIL` or `code-review` `Needs Rework` | **Implementation or test defect** | Send targeted actionable feedback (check ID, repro, expected contract) to the existing worker via `send_message` when live. |
|
|
||||||
| Acceptance criterion lacks public-seam test proof | **Missing seam test** | Route back to the existing worker (`tdd`) to add a non-tautological seam test and commit checkpoint. |
|
|
||||||
| `BLOCKED (env/fixture)` | **Environment or fixture blocker** | Delegate fixture/devshell repair (`nix-devshell` or worker task) or surface environment blocker to user before judging product code. |
|
|
||||||
| `BLOCKED (out-of-bounds)` | **Unauthorized `live-infra` boundary** | Preserve exact command and criteria; pause for human owner authorization, operator run, or documented deferral. |
|
|
||||||
| Symptom contradicts hypotheses across retries | **Unknown root cause** | Stop blind retries; hand off to `diagnose` for evidence-first root-cause investigation. |
|
|
||||||
| Criterion contradicts actual system architecture or tests the wrong seam | **Defective rubric** | Record an explicit **Rubric Amendment** stating what changed and why. Pause for human approval whenever an amendment relaxes an acceptance criterion or alters slice scope; never silently rewrite criteria to match worker output. |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 8. Final-HEAD Evidence Invariant and Terminal Delivery
|
|
||||||
|
|
||||||
### The Invariant
|
|
||||||
|
|
||||||
> Before `gitea-pr` creates or marks a PR ready (or before terminal delivery when no PR applies), the required `code-review` and `verify-slice` evidence must identify the same final `HEAD` and applicable base revision. Any change to the reviewed diff invalidates affected evidence.
|
|
||||||
|
|
||||||
### Recovery Rules When `HEAD` Advances or Checks Emit
|
|
||||||
|
|
||||||
1. **Post-QA commit**: If `HEAD` changes after `verify-slice` (for example, to address a `code-review` finding or rebase onto base), rerun `verify-slice` against the new `HEAD`.
|
|
||||||
2. **Post-review commit**: If `HEAD` changes after `code-review`, rerun `code-review` against `<base>...HEAD`.
|
|
||||||
3. **Emitted `RV-*` runtime checks**: If `code-review` Step 6 emits executable `RV-*` checks, execute them via `verify-slice` against the final `HEAD` before packaging.
|
|
||||||
4. **Handshake reuse condition**: `verify-slice` may reuse a preceding `code-review` report for static provenance only when its recommendation is `Ready` (including `Ready (Conditional)` once open items are adjudicated by the human owner per `code-review`) and its recorded base SHA, `HEAD` SHA, and working-tree diff fingerprint still match exactly.
|
|
||||||
|
|
||||||
### Conditional Terminal Paths
|
|
||||||
|
|
||||||
- **PR applies**: Once `code-review` (`Ready`) and `verify-slice` (zero unhandled `FAIL`) match final `HEAD`, hand off both packets to `gitea-pr` to draft the PR description, pause for human PR approval, create/update the PR, and report merge readiness.
|
|
||||||
- **No PR applies** (local repo, approved solo-branch workflow, or bounded spike): Enforce the identical final-`HEAD` evidence invariant, then present the commit range (`<base>..HEAD`), static review disposition, runtime verification ledger, and any open residual-risk decisions directly to the user.
|
|
||||||
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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>` 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 |
|
|
||||||
| :--- | :--- | :--- |
|
|
||||||
| **Step 1 (Preflight & Readiness)** | `Backlog -> Ready` | Blocking issues are closed, issue acceptance criteria are reconciled against current `HEAD` and `AGENTS.md`, and `--dry-run` is **not** active. |
|
|
||||||
| **Step 4 (Worker Delegation)** | `Ready -> Work in Progress` | Human owner approved the Step 3 Planned Workflow and implementation branch/worker starts. |
|
|
||||||
| **Step 7 (Final-HEAD Gate)** | `Work in Progress -> Review` | Final-`HEAD` `code-review` (`Ready`) and `verify-slice` pass with zero unhandled `FAIL` outcomes. |
|
|
||||||
| **Step 7 (Direct Merge Only)** | `Review -> Completed` | Only when repository policy permits direct fast-forward merge to `main`, human owner approves, and the issue is closed. Otherwise `gitea-pr` owns `Review -> Completed`. |
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
# Orchestration Topology, Boundaries, and Workspace Ownership
|
|
||||||
|
|
||||||
Reference for `implement-slice`. Defines how the orchestrator combines existing planning and assurance tiers without redefining them, preserves context efficiency, and prevents workspace contention.
|
|
||||||
|
|
||||||
## 1. Pure-Orchestrator and Context-Budget Invariants
|
|
||||||
|
|
||||||
These boundaries hold across every slice size and risk tier:
|
|
||||||
|
|
||||||
1. **No implementation or self-certified QA**: The orchestrator never edits product or test files, creates ad-hoc fixup commits, executes mutations to repair broken code, or declares runtime QA passing without worker/QA evidence. Read-only inspection (`gt`, `git status`, `git log`, `git diff --stat`, targeted file reads to check a contradiction) is allowed.
|
|
||||||
2. **Context-budget discipline**:
|
|
||||||
- **Retain in orchestrator context**: approved slice plan, task dependency status, assigned workspace/branch refs, checkpoint commit SHAs, QA check dispositions, active blockers, and open human decisions.
|
|
||||||
- **Delegate out of orchestrator context**: full test suite transcripts, build logs, browser traces, and line-by-line edit narratives. Require concise structured reports with exact references (commit SHAs, `path:line` locations, check IDs, or log/artifact paths) and inspect raw output only when resolving a discrepancy or failure.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Combining `Complexity x Risk` (Single-Owner Tier Mapping)
|
|
||||||
|
|
||||||
`implement-slice` does not define new sizing or risk vocabularies; it composes the canonical tiers owned by sibling skills:
|
|
||||||
|
|
||||||
- **Planning size (`Small`, `Medium`, `Large`)**: owned by [`gitea-plan`](../../gitea-plan/references/decomposition-tiers.md). Governs Gitea planning ceremony and task decomposition granularity.
|
|
||||||
- **Assurance rigor (`Lightweight`, `Standard`, `High-Assurance`)**: owned by [`code-review`](../../code-review/references/axes.md) and [`verify-slice`](../../verify-slice/references/perspectives.md). Governs worker independence, runtime check depth, and static review isolation.
|
|
||||||
|
|
||||||
**Risk override rule**: Always compute assurance rigor from failure consequences, never diff line count alone. Touching authentication, permissions, secrets, payments, concurrent state, data migrations, deployment/infrastructure, destructive operations, or core shared libraries elevates even a `Small` slice to `High-Assurance` verification and review while keeping `Small` planning ceremony.
|
|
||||||
|
|
||||||
| Planning Size x Assurance Rigor | Worker Delegation | Mid-Slice QA (`verify-slice`) | Final Slice Gate (`<base>...HEAD`) |
|
|
||||||
| :--- | :--- | :--- | :--- |
|
|
||||||
| **`Small` x `Lightweight`** | 1 implementation worker subagent on slice branch (`tdd` where applicable + `git-manager` checkpoint commit + self-audit). | Skip separate mid-slice QA subagent if deterministic worker evidence satisfies the pre-committed rubric; run final-`HEAD` `verify-slice` Lightweight checks. | Single-pass `code-review` (`Lightweight`) + final-`HEAD` `verify-slice` confirmation. |
|
|
||||||
| **`Small`/`Medium` x `Standard`** | Sequential worker subagent(s) per task/chunk on slice branch (or isolated worktrees only if tasks are genuinely independent). | Spawn independent rubric QA subagent (`verify-slice` `Standard`) at chunk boundary or slice completion when stateful/UI/API behavior warrants separation. | Independent `code-review` (`Standard`, including strategic alignment) + final-`HEAD` `verify-slice` packet. |
|
|
||||||
| **Any Size x `High-Assurance`** (or `Large` multi-chunk slice) | Sequential tasks on slice branch or isolated per-task worktrees for independent tracks; strict checkpoint boundaries. | Spawn clean black-box QA subagent (`verify-slice` `High-Assurance`), withholding diff narrative and worker self-audit per `verify-slice` Step 3. | Spawn isolated `code-review` subagents (`High-Assurance`: dedicated Axis 3 `Seam & Test Integrity` subagent + Axes 1/2/4 subagent) + final-`HEAD` `verify-slice` packet (including any emitted `RV-*` checks). |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. Branch, Worktree, and QA Ownership Boundaries
|
|
||||||
|
|
||||||
Explicit ownership prevents concurrent working-tree corruption and keeps Git recovery out of the orchestrator:
|
|
||||||
|
|
||||||
| Role | Exact Responsibility |
|
|
||||||
| :--- | :--- |
|
|
||||||
| **Orchestrator (`implement-slice`)** | Decides branch/worktree topology in the approved plan, assigns each worker an explicit workspace path and target branch, and verifies resulting refs/SHAs read-only. Never repairs broken Git state by editing files or committing directly. |
|
|
||||||
| **`git-manager`** | Owns and governs branch creation, `.worktrees/<task>` creation/removal, branch integration (`rebase`, `merge`, `cherry-pick`), conflict stops, and evidence-first `reflog` recovery. On any merge/rebase conflict or unfamiliar dirty tree, `git-manager` stops immediately for human decision. |
|
|
||||||
| **Implementation Worker** | Modifies code and tests only inside its assigned workspace and scope boundary; runs local checks via `tdd` and commits verified checkpoints autonomously on the non-default working branch per `git-manager`. |
|
|
||||||
| **QA Subagent (`verify-slice`)** | Evaluates a pinned commit SHA (`HEAD`) without modifying tracked repository files. Writes temporary fixtures or scratch state only in isolated temp directories (such as `mktemp -d`), leaving `git status --short` clean. |
|
|
||||||
|
|
||||||
### Contention and Worker Reuse Rules
|
|
||||||
|
|
||||||
1. **Sequential default**: Prefer sequential task delegation on a single slice branch when tasks touch related modules or take minutes rather than hours; parallel worktrees pay an integration cost.
|
|
||||||
2. **Mandatory isolation for concurrency**: Never run two implementation subagents concurrently in the same working directory. Concurrent implementation tasks require separate `git-manager` worktrees and an explicit integration step before final-`HEAD` review.
|
|
||||||
3. **Stateful worker reuse**: Retain each worker's subagent `conversationId`. When QA or `code-review` routes actionable rework back on a task, message that existing worker (`send_message`) so it retains design context instead of spawning a cold worker. Spawn a fresh worker only for a distinct new task or when the original worker session is unavailable.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Canonical Workflow Node Schema & Proportional Scaling
|
|
||||||
|
|
||||||
Every task, check, and gate in the slice workflow is represented by a structured node to enable inspectability and comparison:
|
|
||||||
|
|
||||||
### Mandatory Core Fields (All Nodes)
|
|
||||||
- **`node_id`**: Stable identifier (e.g. `TASK-01`, `CHK-UNIT-01`, `GATE-MERGE`).
|
|
||||||
- **`claim`**: The observable behavior, contract, or invariant being asserted.
|
|
||||||
- **`method`**: Concrete execution mechanism or harness (e.g. `node:test`, `pytest -m contract`, `git diff --check`, manual user review).
|
|
||||||
- **`executor`**: Specific assigned role (`Implementation Worker`, `Independent QA Subagent`, `Reviewer Subagent`, `Human Owner`).
|
|
||||||
- **`pass_condition`**: Deterministic pass/fail criterion (e.g. exit code 0, regex match, zero uncommitted files).
|
|
||||||
- **`status`**: Evidence-backed execution state:
|
|
||||||
* `planned`: Defined, not yet executed.
|
|
||||||
* `blocked`: Cannot run due to unmet prerequisite.
|
|
||||||
* `skipped`: Deliberately omitted, with recorded rationale.
|
|
||||||
* `failed`: Ran and failed pass condition (failure log recorded).
|
|
||||||
* `passed`: Verified with concrete evidence. Missing evidence strictly prohibits `passed`.
|
|
||||||
|
|
||||||
### Optional / Scaled Fields (Omitted or Simplified for Simple Slices)
|
|
||||||
- **`failure_route`**: For routine/doc tasks, defaults to *"rework in-place and rerun affected check"*; complex slices specify explicit rework loops across delegated subagents.
|
|
||||||
- **`evidence`**: Simple doc/format tasks record exit code and commit SHA; complex code tasks attach stdout, DOM snapshots, or test run logs.
|
|
||||||
- **Separate QA Executor**: Documentation and routine edits use the implementation agent directly; high-risk slices mandate independent verifier subagents.
|
|
||||||
|
|
||||||
### Vertical Submodule TDD Decomposition (Anti-Horizontal Batching)
|
|
||||||
When a slice spans multiple modules or layers (for example, `protocols.py` -> `ssap.py` -> `pointer.py` -> `manager.py`), never decompose the workflow horizontally into `TASK-00: write all tests for every module` followed by `TASK-01..02: implement all modules`. Instead, sequence tasks as **bottom-up vertical Red->Green cycles per submodule or capability**:
|
|
||||||
1. Each submodule task writes its own focused Red test(s) (committing a Red `@pytest.mark.xfail(strict=True)` checkpoint when requested by repo SOP), implements that submodule to turn its tests Green, and commits the Green checkpoint before the next higher-level submodule writes its tests against the settled lower layer.
|
|
||||||
2. This preserves organic Git history (`git log` and `git bisect` trace each building block in dependency order) and prevents writing tests against imagined lower-level interfaces.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5. Runtime Observability Timeline & Dry-Run Invariants
|
|
||||||
|
|
||||||
Observability is an active oversight instrument during execution, not a retrospective summary:
|
|
||||||
|
|
||||||
1. **Pre-Execution (Gate 1)**: Orchestrator surfaces the **Planned Workflow** (structured node definitions and dynamic Mermaid projection) in chat prose for human approval before spawning workers.
|
|
||||||
2. **During Execution (Runtime Updates)**: Orchestrator dynamically updates the **Execution Record** as nodes transition states (`planned` -> `passed` / `failed` / `blocked` / `skipped`), exposing progress and failure-rework loops in orchestrator turn updates.
|
|
||||||
3. **Post-Execution (Step 6 Handoff)**: Orchestrator presents the **Deviation Report** comparing actual execution against the plan, alongside links to verified commit SHAs.
|
|
||||||
|
|
||||||
### Dry-Run Mode (`/implement-slice --dry-run`)
|
|
||||||
Dry-run mode is defined strictly by **zero side-effects and zero mutations**:
|
|
||||||
- Produces the complete planned workflow, scope analysis, verification 5-tuples, and proposed diffs.
|
|
||||||
- Enforces 0 uncommitted changes, 0 new Git commits, 0 remote pushes, and 0 Gitea issue/PR/milestone mutations.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 6. Policy-Aware Integration Strategy Matrix
|
|
||||||
|
|
||||||
The choice between direct fast-forward merge and opening a Gitea pull request is governed by repository policy and authorization, not developer convenience:
|
|
||||||
|
|
||||||
| Factor | Direct Fast-Forward Merge | Pull Request (`gt pr create`) |
|
|
||||||
| :--- | :--- | :--- |
|
|
||||||
| **Repository `AGENTS.md`** | Must explicitly permit direct commits/merges to `main`. | Mandatory whenever repo policy prohibits direct commits to `main`. |
|
|
||||||
| **CI / Actions Requirement** | Permitted only if no remote CI workflows are required before merge. | Mandatory whenever remote Gitea Actions CI or deployment pipelines must validate branch. |
|
|
||||||
| **Review & QA Status** | Final-`HEAD` `code-review` and `verify-slice` evidence packets must be clean. | Packaged into PR body (`Closes #<id>`, review provenance, verification ledger). |
|
|
||||||
| **Human Authorization** | Explicit human approval required before merging. | Human owner authorizes creation and final merge. |
|
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
---
|
||||||
|
name: implement
|
||||||
|
description: >-
|
||||||
|
Execute a GitHub vertical-slice issue end-to-end with preflight checks,
|
||||||
|
delta-test decomposition, adaptive test-writer/code-writer subagents, 1:1
|
||||||
|
commits, and Draft PR publishing. Use when implementing a ready GitHub issue
|
||||||
|
or addressing code-review rework. Not for planning (use projects), static
|
||||||
|
review (use code-review), or runtime QA and merge (use verify).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Implement
|
||||||
|
|
||||||
|
## Use when
|
||||||
|
- Delivering a ready GitHub issue slice on a non-default branch or worktree.
|
||||||
|
- Executing rework passes routed back from `code-review` on an open Draft PR.
|
||||||
|
- Not for decomposing epics or creating issues: use `projects`.
|
||||||
|
- Not for static diff review or PR review publishing: use `code-review`.
|
||||||
|
- Not for black-box runtime QA, PR promotion, or merge: use `verify`.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
Pure orchestrator invariant: mutate only your branch-scoped checkpoint file
|
||||||
|
directly. Never write production code, never write tests, never perform code
|
||||||
|
review, and never publish PR review comments (`code-review` owns review
|
||||||
|
publishing).
|
||||||
|
|
||||||
|
1. **Preflight and board transition.** Before preflight or checkpointing, read
|
||||||
|
[references/preflight.md](references/preflight.md). Verify GitHub repo
|
||||||
|
identity via `gh repo view --json url` per
|
||||||
|
[planning-contract.md](../projects/references/planning-contract.md).
|
||||||
|
Classify the working tree (`CLEAN_BASE`, `EXISTING_SLICE_BRANCH`,
|
||||||
|
`ADOPTABLE_DIFF`, `CONFLICTING_STATE`, `WRONG_BASE`). Halt immediately on
|
||||||
|
`CONFLICTING_STATE` or `WRONG_BASE`. Otherwise create or switch to a
|
||||||
|
non-`main` branch or worktree via `git-manager`, and move the issue card
|
||||||
|
`Ready -> Work in Progress` per
|
||||||
|
[github-projects-v2.md](../projects/references/github-projects-v2.md).
|
||||||
|
2. **Step 1 delta-test decomposition.** Before decomposing tasks or spawning
|
||||||
|
workers, read
|
||||||
|
[references/decomposition-and-roles.md](references/decomposition-and-roles.md).
|
||||||
|
Inspect existing tests on affected seams (`covered`, `partial/weak`,
|
||||||
|
`missing`). Auto-skip Step 1 for trivial `<= 2`-file localized fixes with no
|
||||||
|
new test seam. If `--dry-run`, print the plan and halt with zero mutations.
|
||||||
|
Otherwise write slice tasks directly in plain `todo.txt` format inside
|
||||||
|
`$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt`
|
||||||
|
without invoking `tuxedo`.
|
||||||
|
3. **Adaptive execution loop.** Dispatch subagents with embedded OS-level
|
||||||
|
non-interactive timeout wrapping (`1-worker` fast path for auto-skipped
|
||||||
|
trivial fixes, or `test-writer` -> `code-writer` with 3-4 task worker
|
||||||
|
recycling and a 2-turn deadlock breaker). Commit 1:1 per completed
|
||||||
|
deliverable via `git-manager`, and mark completed tasks done in
|
||||||
|
`"$state_file"`.
|
||||||
|
4. **Draft PR and state cleanup.** Before opening or syncing a Draft PR, read
|
||||||
|
[references/pr-and-drift.md](references/pr-and-drift.md). Push via
|
||||||
|
`git-manager`, open or sync a Draft PR (`gh pr create --draft`, `Closes #<N>`,
|
||||||
|
`Contract Drift: none | <summary>`), delete `"$state_file"`, and keep the
|
||||||
|
board card in `Work in Progress`.
|
||||||
|
|
||||||
|
## Your call
|
||||||
|
- **Branch adoption (`ADOPTABLE_DIFF`) or re-branching (`WRONG_BASE`)**: confirm
|
||||||
|
how to handle existing working-tree changes or diverged branches.
|
||||||
|
- **Deadlock escalation**: resolve 2-turn `test-writer`/`code-writer` deadlocks
|
||||||
|
or approve routing to `diagnose`.
|
||||||
|
- **Scope or contract drift**: confirm whether unexpected contract changes stay
|
||||||
|
in-slice or split into a follow-up issue via `projects`.
|
||||||
|
|
||||||
|
## Done when
|
||||||
|
- Every slice task is implemented, tested, and committed 1:1 on a non-`main`
|
||||||
|
branch.
|
||||||
|
- A Draft PR is open or synced with `Closes #<N>` and `Contract Drift: ...`.
|
||||||
|
- The branch-scoped `"$state_file"` is deleted and the board card remains in
|
||||||
|
`Work in Progress`.
|
||||||
|
|
||||||
|
## Hands off to
|
||||||
|
- `code-review`: to audit the Draft PR (`Suggested Next Step: /code-review`).
|
||||||
|
- `diagnose`: when a 2-turn deadlock or unexpected failure needs root-cause
|
||||||
|
debugging (`Suggested Next Step: /diagnose`).
|
||||||
|
- `projects`: when scope splits or an explicit abort requires replanning.
|
||||||
|
- Emit one outcome-matched `Suggested Next Step:` on standalone turns; suppress
|
||||||
|
when delegated to a subagent per [skeleton.md](../build-skill/references/skeleton.md).
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
# Step 1 Delta-Test Decomposition & Worker Roles
|
||||||
|
|
||||||
|
Defines Step 1 delta-test classification, the `<= 2`-file fast path, worker role
|
||||||
|
contracts, recycling and deadlock circuit breakers, and mandatory OS-level
|
||||||
|
non-interactive command wrapping.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Step 1 Delta-Test Decomposition
|
||||||
|
|
||||||
|
Before writing tasks or spawning workers, inspect the repository's existing test
|
||||||
|
suite on every seam affected by the target issue or rework finding. Classify
|
||||||
|
each affected seam into one of three states:
|
||||||
|
|
||||||
|
| Seam State | Meaning | Required Task Ordering |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| `covered (keep green)` | Existing tests already assert the target behavior and edge cases. | Do not add redundant tests; keep existing tests green after production edits. |
|
||||||
|
| `partial/weak (harden)` | Tests touch the seam but miss edge cases, error paths, or falsifiable assertions. | `test-writer` hardens tests first (observing failure on missing behavior), then `code-writer` satisfies them. |
|
||||||
|
| `missing (new Red test)` | No test covers the new behavior or bug reproduction. | `test-writer` writes a new failing Red test first, then `code-writer` implements the minimal Green fix. |
|
||||||
|
|
||||||
|
Record the resulting ordered deliverables directly in
|
||||||
|
`$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt` per
|
||||||
|
[preflight.md](preflight.md) (unless `--dry-run` is active or the fast path
|
||||||
|
applies).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. `<= 2`-File Fast-Path Criteria & Bailout
|
||||||
|
|
||||||
|
Auto-skip Step 1 decomposition and checkpoint file creation when **all** of the
|
||||||
|
following hold:
|
||||||
|
- The change is a localized fix or localized `code-review` rework item touching
|
||||||
|
`<= 2` files.
|
||||||
|
- No new test seam is introduced (existing tests cover the behavior or a single
|
||||||
|
localized assertion suffices).
|
||||||
|
- No public interface, schema, or architecture contract changes.
|
||||||
|
|
||||||
|
### Fast-Path Bailout Rule
|
||||||
|
If execution reveals that scope exceeds 2 files, requires a new test seam, or
|
||||||
|
impacts a public contract, stop the `1-worker` fast path immediately, run Step 1
|
||||||
|
delta-test decomposition, initialize `"$state_file"`, and switch to the
|
||||||
|
multi-task `test-writer` -> `code-writer` loop.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Worker Role Contracts
|
||||||
|
|
||||||
|
`implement` is a pure orchestrator: it never edits production code, never edits
|
||||||
|
tests, never performs code review, and never publishes PR review comments.
|
||||||
|
|
||||||
|
### Shared Invariants (All Workers)
|
||||||
|
- **Anti-recursion**: Never invoke `implement` or spawn nested workers.
|
||||||
|
- **Footer suppression**: Suppress any standalone `Suggested Next Step:` footer;
|
||||||
|
return only a compact handoff summary (touched files, verification commands
|
||||||
|
and exit codes, observed contract drift or blockers).
|
||||||
|
- **Mandatory non-interactive wrapping**: Execute all shell commands using the
|
||||||
|
Section 5 wrapper and tiered timeouts.
|
||||||
|
- **No git history rewrites**: Leave commits and branch management to the
|
||||||
|
orchestrator (`git-manager`), unless explicitly instructed to run read-only
|
||||||
|
`git diff` / `git status`.
|
||||||
|
|
||||||
|
### `test-writer` Contract
|
||||||
|
- Owns Red tests and seam hardening for `missing` and `partial/weak` seams.
|
||||||
|
- Never implements production logic beyond minimal type/compilation stubs when a
|
||||||
|
statically typed language requires them to compile the Red test.
|
||||||
|
- Runs targeted test commands to confirm the new or hardened test fails for the
|
||||||
|
expected reason (Red) before returning.
|
||||||
|
- Runs repository lint/typecheck on touched test files and adds brief `Why:`
|
||||||
|
comments for non-obvious test invariants or fixtures.
|
||||||
|
|
||||||
|
### `code-writer` Contract
|
||||||
|
- Owns the minimal production implementation that turns Red tests Green while
|
||||||
|
keeping `covered` seams green.
|
||||||
|
- **Per-task hygiene** (mandatory before returning):
|
||||||
|
- Run repository lint, formatter check, and typecheck on touched files.
|
||||||
|
- Add or update docstrings on all new or modified public symbols.
|
||||||
|
- Add concise `Why:` comments for non-obvious invariants, edge-case guards, or
|
||||||
|
trade-offs (never narrating obvious code mechanics).
|
||||||
|
- Update directly affected local markdown (such as adjacent module READMEs or
|
||||||
|
inline usage docs impacted by the change).
|
||||||
|
- Report any detected Contract Drift (deviation from issue acceptance criteria,
|
||||||
|
public interfaces/schemas, `ARCHITECTURE.md`, or `ROADMAP.md`) in the handoff
|
||||||
|
packet so the orchestrator can record it in the Draft PR.
|
||||||
|
|
||||||
|
### `1-worker` Fast-Path Contract
|
||||||
|
- Used only when Section 2 fast-path criteria hold.
|
||||||
|
- Applies the localized fix and targeted verification in a single worker turn,
|
||||||
|
enforcing all `code-writer` hygiene rules (lint/typecheck, docstrings, `Why:`
|
||||||
|
comments, affected local markdown) and shared invariants.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Worker Recycling & Deadlock Circuit Breaker
|
||||||
|
|
||||||
|
- **3-4 Task Worker Recycling**: After every 3-4 completed tasks in a multi-task
|
||||||
|
slice, retire the current `test-writer` and `code-writer` instances and spawn
|
||||||
|
fresh workers. This prevents quadratic context growth and stale-file
|
||||||
|
assumptions across long slices.
|
||||||
|
- **2-Turn Deadlock Circuit Breaker**: If `test-writer` and `code-writer` fail
|
||||||
|
to converge on a single task after 2 back-and-forth turns (for example,
|
||||||
|
disputed test seam, flaky environment, or ambiguous specification):
|
||||||
|
1. Stop dispatching further retries on that task.
|
||||||
|
2. Preserve `"$state_file"` untouched.
|
||||||
|
3. Escalate to the human owner with the exact failure output and options to
|
||||||
|
clarify the spec or hand off to `diagnose`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Mandatory OS-Level Non-Interactive Command Wrapping
|
||||||
|
|
||||||
|
Embed this execution rule verbatim in every `test-writer`, `code-writer`, and
|
||||||
|
`1-worker` prompt:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
CI=true GIT_TERMINAL_PROMPT=0 PAGER=cat setsid timeout -k 10 <N>s <cmd> < /dev/null
|
||||||
|
```
|
||||||
|
|
||||||
|
### Why This Wrapper Is Required
|
||||||
|
- `setsid` detaches the command from any controlling `/dev/tty` so interactive
|
||||||
|
prompts cannot hang waiting for terminal input.
|
||||||
|
- `< /dev/null` closes stdin immediately.
|
||||||
|
- `CI=true`, `GIT_TERMINAL_PROMPT=0`, and `PAGER=cat` disable interactive CLI
|
||||||
|
wizards, credential prompts, and pagers.
|
||||||
|
- `timeout -k 10 <N>s` sends `SIGTERM` after `<N>` seconds and escalates to
|
||||||
|
`SIGKILL` 10 seconds later if the process ignores `SIGTERM`.
|
||||||
|
|
||||||
|
### Tiered Timeouts (`<N>`)
|
||||||
|
| Tier | Timeout | Applies To |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| Fast CLI | `60s` | Git commands, `gh` CLI queries, linters, formatters, typecheckers, quick scripts |
|
||||||
|
| Unit Tests | `180s` | Targeted unit test runs and local test suites |
|
||||||
|
| Cold Builds | `600s` | Cold compilation, container/Nix builds, and heavy fixture builds |
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
# Draft PR Publishing & Contract Drift Marker
|
||||||
|
|
||||||
|
Sole owner of the Draft PR body template, rework sync rules, and the fixed-format
|
||||||
|
`Contract Drift` marker read by `verify`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Board & Review Publishing Boundaries
|
||||||
|
|
||||||
|
- **Card stays in `Work in Progress`**: After opening or syncing a Draft PR,
|
||||||
|
`implement` leaves the GitHub Projects v2 card in `Work in Progress`. Never
|
||||||
|
move the card to `Review` here; `verify` owns `Work in Progress -> Review`
|
||||||
|
when promoting the PR with `gh pr ready` per
|
||||||
|
[planning-contract.md](../../projects/references/planning-contract.md).
|
||||||
|
- **No PR review comments**: `implement` never publishes PR reviews or inline
|
||||||
|
review comments. `code-review` is the sole owner of PR review publishing.
|
||||||
|
- **Checkpoint cleanup**: Immediately after the Draft PR is opened or synced,
|
||||||
|
delete `"$state_file"`
|
||||||
|
(`$(git rev-parse --git-common-dir)/implement-state/<branch_slug>.txt`) per
|
||||||
|
[preflight.md](preflight.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Draft PR Open & Rework Sync Rules
|
||||||
|
|
||||||
|
1. Push the non-`main` slice branch via `git-manager` (`git push -u origin <branch>`).
|
||||||
|
2. Check for an existing PR on the current branch (`gh pr view --json number,url,isDraft`).
|
||||||
|
3. **New Draft PR** (no PR exists yet):
|
||||||
|
```bash
|
||||||
|
gh pr create --draft --title "<Conventional PR Title>" --body-file <pr-body.md>
|
||||||
|
```
|
||||||
|
- Never open a ready-for-review PR directly from `implement`; always pass
|
||||||
|
`--draft`.
|
||||||
|
4. **Rework Sync** (an open Draft PR already exists):
|
||||||
|
- Push the new 1:1 rework commits to the existing branch.
|
||||||
|
- Update the Draft PR body with `gh pr edit <pr-number> --body-file <pr-body.md>`
|
||||||
|
whenever scope, verification commands, linked issues, or the
|
||||||
|
`Contract Drift` status changed.
|
||||||
|
- If the rework pass resolved localized findings with no change to scope or
|
||||||
|
`Contract Drift`, pushing the commits is sufficient.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Draft PR Body Template
|
||||||
|
|
||||||
|
Use this structure when creating or syncing a Draft PR body:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
Closes #<N>
|
||||||
|
|
||||||
|
## Scope Summary
|
||||||
|
- <Deliverable 1 and key files touched>
|
||||||
|
- <Deliverable 2 and key files touched>
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
- `<targeted test command>` (exit 0)
|
||||||
|
- `<lint / typecheck command>` (exit 0)
|
||||||
|
|
||||||
|
Contract Drift: none
|
||||||
|
```
|
||||||
|
|
||||||
|
*(Replace `none` with a concise single-line summary when drift occurred.)*
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Fixed-Format `Contract Drift` Marker
|
||||||
|
|
||||||
|
`verify` parses the Draft PR body during Phase 3 closeout to decide whether to
|
||||||
|
chain `reconcile-docs` and `projects` after merge.
|
||||||
|
|
||||||
|
### Format
|
||||||
|
```text
|
||||||
|
Contract Drift: none
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```text
|
||||||
|
Contract Drift: <concise summary of deviation and affected interfaces or docs>
|
||||||
|
```
|
||||||
|
|
||||||
|
### What Counts as Contract Drift
|
||||||
|
Record non-`none` drift whenever implementation deviates from any of:
|
||||||
|
- Target GitHub issue acceptance criteria.
|
||||||
|
- Public interfaces, CLI flags, API payloads, or data schemas.
|
||||||
|
- Canonical architecture or planning documents (`ARCHITECTURE.md`, `ROADMAP.md`,
|
||||||
|
or active `docs/designs/*.md` specs).
|
||||||
|
|
||||||
|
### Rules
|
||||||
|
- Include exactly one `Contract Drift:` line at the bottom of the PR body.
|
||||||
|
- Do not invent alternate labels (such as `Drift:` or `Spec Deviations:`).
|
||||||
|
- Keep the value on the same line (`Contract Drift: none` or
|
||||||
|
`Contract Drift: <summary>`) so downstream tooling and `verify` can read it
|
||||||
|
unambiguously.
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
# Preflight & Branch-Scoped Checkpoint Lifecycle
|
||||||
|
|
||||||
|
Sole owner of working-tree classifications, the `--dry-run` zero-mutation
|
||||||
|
contract, and the `implement` branch-scoped checkpoint lifecycle.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. GitHub Remote & Board Guard
|
||||||
|
|
||||||
|
Before mutating git state or moving board cards:
|
||||||
|
1. Verify GitHub repository identity with `gh repo view --json url` per
|
||||||
|
[planning-contract.md](../../projects/references/planning-contract.md). If
|
||||||
|
the command fails or `AGENTS.md` contains a legacy Gitea planning contract,
|
||||||
|
halt and advise migrating to GitHub or using standalone `gt-usage`.
|
||||||
|
2. After branch/worktree preflight passes (and only when not in `--dry-run`),
|
||||||
|
move the target issue card `Ready -> Work in Progress` using `issue.projectItems`
|
||||||
|
per [github-projects-v2.md](../../projects/references/github-projects-v2.md).
|
||||||
|
If the card is already in `Work in Progress` (resumed slice or rework pass),
|
||||||
|
leave it there idempotently.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Working-Tree Classifications
|
||||||
|
|
||||||
|
Inspect `git status --porcelain`, `git branch --show-current`, merge/rebase
|
||||||
|
sentinel files under `$(git rev-parse --git-dir)`, and any open Draft PR or
|
||||||
|
existing checkpoint file for the target slice. Classify into exactly one state:
|
||||||
|
|
||||||
|
| Classification | Condition | Required Action |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| `CLEAN_BASE` | Clean working tree on the default base branch (e.g. `main`). | Create and switch to a dedicated non-`main` slice branch or worktree via `git-manager`. |
|
||||||
|
| `EXISTING_SLICE_BRANCH` | Clean working tree on the target slice's own non-`main` branch with an active checkpoint file or an open Draft PR. | Proceed directly to resume remaining tasks or execute a `code-review` rework pass without re-branching. |
|
||||||
|
| `ADOPTABLE_DIFF` | Uncommitted changes present, all scoped cleanly to the target slice, with no merge/rebase in progress. | Ask the user to confirm adopting the diff onto a dedicated non-`main` slice branch via `git-manager` before proceeding. |
|
||||||
|
| `CONFLICTING_STATE` | Unrelated dirty changes, untracked conflicting files, or an active merge, rebase, or cherry-pick. | Halt immediately. Report the exact dirty paths or operation and leave all working-tree and checkpoint files untouched. |
|
||||||
|
| `WRONG_BASE` | Current branch is neither the base branch nor the target slice's branch, or has diverged unexpectedly from the expected base. | Halt immediately. Ask the user whether to switch or re-branch via `git-manager`, leaving existing checkpoint files untouched. |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. `--dry-run` Zero-Mutation Contract
|
||||||
|
|
||||||
|
When invoked with `--dry-run`:
|
||||||
|
- Execute read-only preflight inspection (`gh repo view --json url`, working-tree
|
||||||
|
classification, issue acceptance criteria read) and Step 1 delta-test
|
||||||
|
decomposition.
|
||||||
|
- Print the proposed branch name, working-tree classification, seam coverage map
|
||||||
|
(`covered`, `partial/weak`, `missing`), execution mode (`1-worker` fast path vs.
|
||||||
|
multi-task `test-writer`/`code-writer`), and ordered task list.
|
||||||
|
- Halt with **zero mutations**:
|
||||||
|
- Do not create or switch branches or worktrees.
|
||||||
|
- Do not move GitHub Projects v2 cards.
|
||||||
|
- Do not create, modify, or delete any checkpoint file.
|
||||||
|
- Do not spawn implementation workers, create commits, or touch Draft PRs.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Branch-Scoped Checkpoint Lifecycle
|
||||||
|
|
||||||
|
Multi-task slices store resume state inside the shared git common directory so
|
||||||
|
checkpoints stay isolated per branch across git worktrees and never pollute the
|
||||||
|
working tree or root `todo.txt`.
|
||||||
|
|
||||||
|
### Path & Branch Slug
|
||||||
|
```bash
|
||||||
|
git_common_dir="$(git rev-parse --git-common-dir)"
|
||||||
|
branch="$(git branch --show-current)"
|
||||||
|
branch_slug="${branch//\//__}"
|
||||||
|
state_file="${git_common_dir}/implement-state/${branch_slug}.txt"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Plain-Text `todo.txt` Line Format (Direct I/O Only)
|
||||||
|
- Read and write `"$state_file"` directly (e.g., standard file/shell I/O). Never
|
||||||
|
invoke `tuxedo` to read, append, or complete checkpoint tasks.
|
||||||
|
- Use plain-text `todo.txt` line conventions so external `todo.sh` or `tuxedo`
|
||||||
|
can inspect the file if desired:
|
||||||
|
- Pending task: `<task description>`
|
||||||
|
- Completed task: `x YYYY-MM-DD <task description>`
|
||||||
|
|
||||||
|
### Lifecycle Rules
|
||||||
|
1. **Create / Resume**: Create `"$state_file"` (and its parent directory
|
||||||
|
`implement-state/`) after Step 1 decomposition for multi-task slices. On
|
||||||
|
`EXISTING_SLICE_BRANCH` resume, read existing pending lines and continue from
|
||||||
|
the first uncompleted task. Auto-skipped `<= 2`-file fast-path fixes skip
|
||||||
|
checkpoint creation unless they bail out to Step 1.
|
||||||
|
2. **Update**: After each 1:1 deliverable commit via `git-manager`, prefix the
|
||||||
|
completed task line in `"$state_file"` with `x YYYY-MM-DD `.
|
||||||
|
3. **Delete**: Remove `"$state_file"` (`rm -f "$state_file"`) immediately after
|
||||||
|
opening or syncing the Draft PR, or on explicit slice abort / escalation back
|
||||||
|
to `projects`.
|
||||||
|
4. **Preserve on Halt**: Halting on `CONFLICTING_STATE`, `WRONG_BASE`, or a
|
||||||
|
recoverable worker pause leaves any existing `"$state_file"` untouched so the
|
||||||
|
user can resume cleanly.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Repo-Scoped Documentation Boundaries
|
||||||
|
|
||||||
|
- Durable engineering documentation (designs, ADRs, architecture notes, roadmaps)
|
||||||
|
belongs in repo-scoped `docs/` (`docs/designs/*.md`, `docs/adr/`,
|
||||||
|
`ARCHITECTURE.md`, `ROADMAP.md`).
|
||||||
|
- Ephemeral agent artifacts and personal practice notes belong in gitignored
|
||||||
|
`.internal/` at the repository root.
|
||||||
|
- Never hardcode external vault directories or user home paths in checkpoints,
|
||||||
|
worker prompts, or repository files.
|
||||||
@@ -20,15 +20,21 @@ description: >-
|
|||||||
`docs/` if present). If any exist, surface up to 3 and ask whether to review one or start a
|
`docs/` if present). If any exist, surface up to 3 and ask whether to review one or start a
|
||||||
new topic. When reviewing, execute recall-before-reveal per
|
new topic. When reviewing, execute recall-before-reveal per
|
||||||
[references/revisit-protocol.md](references/revisit-protocol.md).
|
[references/revisit-protocol.md](references/revisit-protocol.md).
|
||||||
2. **Establish target.** For a new topic or algorithm problem, ask what I want to understand
|
2. **Establish target.** For a new topic, stretch build, code-tracing drill, or algorithm
|
||||||
or build, and what my current mental model is.
|
problem, ask what I want to understand or build and what my current mental model is. For
|
||||||
|
stretch builds, isolation labs, or code-tracing, read
|
||||||
|
[references/project-labs.md](references/project-labs.md) and start with an **ugly heartbeat**
|
||||||
|
(thin input -> output spike) before upfront architecture.
|
||||||
3. **Help at lowest level that works**, moving up only when I am stuck:
|
3. **Help at lowest level that works**, moving up only when I am stuck:
|
||||||
1. A question that makes me check my own assumption.
|
1. A question that makes me check my own assumption.
|
||||||
2. Where to look: file/line range, docs section, or inspection tool.
|
2. Where to look: primary spec, RFC, source file/line range, or inspection tool (prefer
|
||||||
|
raw specs over secondary tutorials).
|
||||||
3. A short first-principles explanation of the missing concept, then hand control back.
|
3. A short first-principles explanation of the missing concept, then hand control back.
|
||||||
4. A minimal demo in an unrelated example (never in working code).
|
4. A learner-run **30-line `scratch/` isolation lab** (or an agent demo in an unrelated
|
||||||
4. **Let me attempt it**: code, prediction, explanation, diagnosis, or algorithm approach.
|
example) when guessing or when two unknowns collide.
|
||||||
Ask me to read my own result before you comment.
|
4. **Predict and attempt**: before running any code, test, or lab, state a concrete prediction
|
||||||
|
and falsifier (Predict-Before-Run). Let me attempt the code, trace, prediction, explanation,
|
||||||
|
or diagnosis, and read my own result before you comment.
|
||||||
5. **Review what I produced**: report calibration (rubric checklist + assistance level),
|
5. **Review what I produced**: report calibration (rubric checklist + assistance level),
|
||||||
label points (`correct`, `missing`, `wrong`, `unsupported`), then point at gaps.
|
label points (`correct`, `missing`, `wrong`, `unsupported`), then point at gaps.
|
||||||
6. **Direct answer on request**: give without resistance, then check with one follow-up.
|
6. **Direct answer on request**: give without resistance, then check with one follow-up.
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ The question, bug, or mechanism I set out to understand.
|
|||||||
## How my mental model changed
|
## How my mental model changed
|
||||||
- Before: what I assumed.
|
- Before: what I assumed.
|
||||||
- After: the mechanism, invariant, or rule that clicked.
|
- After: the mechanism, invariant, or rule that clicked.
|
||||||
|
- Reasoning trap: how my prediction or assumption got fooled (if applicable).
|
||||||
|
|
||||||
## Evidence I understood it
|
## Evidence I understood it
|
||||||
Transfer challenges, predictions, or explanations I got right without direct help.
|
Transfer challenges, predictions, or explanations I got right without direct help.
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Build-and-Break, Predict-Before-Run, and Code-Tracing Protocols
|
||||||
|
|
||||||
|
Used by `practice` when building stretch projects above your current skill level, debugging unknowns, or sharpening code-reading fluency.
|
||||||
|
|
||||||
|
## 1. Build-and-Break (Stretch Projects)
|
||||||
|
|
||||||
|
1. **Ugly Heartbeat (Vertical Flow First):**
|
||||||
|
- Skip upfront architecture, config layers, and abstractions until data moves end-to-end.
|
||||||
|
- Write the smallest working input -> output path (~30 ugly lines) in one sitting, touching raw primitives rather than hiding behind wrappers when learning is the goal.
|
||||||
|
- Layer error handling, concurrency, and edge cases one at a time after the heartbeat runs.
|
||||||
|
2. **Read the Raw Spec ("Close the Tab"):**
|
||||||
|
- When stuck on a protocol, runtime, or library, close secondary tutorials and inspect the primary specification, RFC, or upstream source directly.
|
||||||
|
- State the exact contract or invariant from the primary source in your own words before writing code.
|
||||||
|
3. **Learner-Run 30-Line `scratch/` Isolation Labs:**
|
||||||
|
- **Trigger:** Two unknowns interact, or you start guessing how a primitive behaves.
|
||||||
|
- **Protocol:** Pause edits in the main project. Create an isolated ~30-line script in `scratch/` testing only the single unknown component.
|
||||||
|
- **Break it on purpose:** Force boundary conditions (e.g., 1-byte buffers, empty input, timeouts, malformed payloads) until you predict every outcome accurately, then return to the main build.
|
||||||
|
|
||||||
|
## 2. Predict-Before-Run (Hypothesis Discipline)
|
||||||
|
|
||||||
|
Before running a test, command, or `scratch/` experiment, state your hypothesis explicitly:
|
||||||
|
- **Prediction:** "I expect `X` because of mechanism `Y`."
|
||||||
|
- **Falsifier:** "If `Z` happens instead, my assumption about `W` is wrong."
|
||||||
|
- After running, compare actual output against the prediction before changing a single line. Change one variable at a time.
|
||||||
|
|
||||||
|
## 3. Code-Tracing Drills (Read Before Running)
|
||||||
|
|
||||||
|
1. Select 25-50 lines of real code (from an active repo or standard library).
|
||||||
|
2. Given one normal input and one edge-case input, trace variables, branches, and return values on paper or in chat without executing the code.
|
||||||
|
3. State where the code could fail or misbehave, then run it to verify your trace and log any mismatch as a reasoning trap.
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
---
|
||||||
|
name: projects
|
||||||
|
description: >-
|
||||||
|
Translate technical goals, user requests, and architecture plans into GitHub
|
||||||
|
Issues, Milestones, and Projects v2 boards with tiered complexity scaling.
|
||||||
|
Use when decomposing work, creating or updating GitHub issues or milestones,
|
||||||
|
or managing rolling planning horizons. Not for slice implementation (use
|
||||||
|
implement) or PR verification (use verify).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Projects
|
||||||
|
|
||||||
|
## Use when
|
||||||
|
- Decomposing a project, feature request, or technical plan into trackable GitHub units.
|
||||||
|
- Creating or updating GitHub Milestones, Projects v2 boards, and vertical-slice issues.
|
||||||
|
- Setting rolling planning horizons for multi-phase epics.
|
||||||
|
- Not for executing an approved issue slice: use `implement`.
|
||||||
|
- Not for black-box QA, PR promotion, or merge closeout: use `verify`.
|
||||||
|
- Not for standalone Git branch or worktree mechanics: use `git-manager`.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
1. **Verify GitHub identity and contract.** Before checking remotes or editing
|
||||||
|
`AGENTS.md`, read [references/planning-contract.md](references/planning-contract.md).
|
||||||
|
Run `gh repo view --json url` to confirm a GitHub repository. If it fails or
|
||||||
|
`AGENTS.md` holds a legacy Gitea planning contract, halt and advise migrating
|
||||||
|
to GitHub via `/gitea-to-github` or using standalone `gt-usage`.
|
||||||
|
2. **Reconcile specs and GitHub state.** Compare `ARCHITECTURE.md`, `ROADMAP.md`,
|
||||||
|
`docs/designs/*.md`, GitHub Issues, Milestones, and Projects v2 cards for
|
||||||
|
contradictions (zombie in-progress, premature completed, review orphan,
|
||||||
|
horizon divergence). If canonical docs lag behind `Completed` board cards,
|
||||||
|
hand off to `reconcile-docs` first.
|
||||||
|
3. **Select tier and decompose into vertical slices.** Before sizing,
|
||||||
|
decomposing, or auditing, read
|
||||||
|
[references/tiers-and-audit.md](references/tiers-and-audit.md). Assign
|
||||||
|
`Small`, `Medium`, or `Large` and emit
|
||||||
|
`### Project Board Policy: <Omitted|Recommended|Required> (Rationale)`. Map
|
||||||
|
work into deliverable outcome issues with test seams, Vertical Submodule TDD
|
||||||
|
Grouping, and falsifiable acceptance criteria (Context, Solution, Criteria).
|
||||||
|
4. **Run Independent Zero-Context Reproducibility Audit (`Medium`/`Large`).**
|
||||||
|
Spawn a clean-room subagent with the raw input manifest (pinned commit SHA,
|
||||||
|
specs, proposed issue markdown, milestone/board plan) to surface and resolve
|
||||||
|
material ambiguities before the human gate.
|
||||||
|
5. **Present plan for approval.** Emit
|
||||||
|
`### Reproducibility Audit: <Passed | Remediated> (Subagent: <id> | Omitted: Small tier)`
|
||||||
|
alongside proposed milestones, due dates, board updates, issues, and any
|
||||||
|
`AGENTS.md` contract diff. Stop for approval before mutating GitHub or `AGENTS.md`.
|
||||||
|
6. **Execute GitHub operations.** Before running Projects v2 or milestone
|
||||||
|
mutations, read
|
||||||
|
[references/github-projects-v2.md](references/github-projects-v2.md). Use
|
||||||
|
`gh issue`, REST `gh api repos/{owner}/{repo}/milestones`, and `gh api graphql`
|
||||||
|
(`owner.projectV2` onboarding, `issue.projectItems` status updates, `DATE`
|
||||||
|
fields). Resolve all IDs dynamically; never hardcode or guess Node IDs or
|
||||||
|
construct `/milestone/1`.
|
||||||
|
7. **Verify state and formalize `AGENTS.md`.** Confirm created issue numbers,
|
||||||
|
canonical URLs, milestone due dates, and board columns. For `Medium`/`Large`
|
||||||
|
planning structure, record only the state-free `project_number: <int>`
|
||||||
|
contract in `AGENTS.md` (never rotating sprint state or GraphQL Node IDs).
|
||||||
|
|
||||||
|
## Your call
|
||||||
|
- **Planning tier selection**: confirm `Small`, `Medium`, or `Large` ceremony.
|
||||||
|
- **Slice boundaries and milestones**: approve or revise proposed issues and due dates.
|
||||||
|
- **Batch mutations**: approve GitHub entity creation and `AGENTS.md` contract edits.
|
||||||
|
|
||||||
|
## Done when
|
||||||
|
- Target milestones, board columns, and issues exist on GitHub with dynamically
|
||||||
|
verified IDs, canonical URLs, and falsifiable acceptance criteria.
|
||||||
|
- `AGENTS.md` holds an accurate, state-free `project_number` contract whenever
|
||||||
|
`Medium`/`Large` planning structure is created or updated.
|
||||||
|
|
||||||
|
## Hands off to
|
||||||
|
- `implement`: to deliver a ready issue (`Suggested Next Step: /implement #<first-ready-issue>`).
|
||||||
|
- `reconcile-docs`: when canonical docs lag behind completed cards (`Suggested Next Step: /reconcile-docs`).
|
||||||
|
- `git-manager`: for standalone branch or worktree operations.
|
||||||
|
- Emit one outcome-matched `Suggested Next Step:` on standalone turns; suppress
|
||||||
|
when delegated per [skeleton.md](../build-skill/references/skeleton.md).
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
# GitHub Projects v2 & Milestone Recipes
|
||||||
|
|
||||||
|
Sole owner of GitHub Projects v2 GraphQL recipes and REST milestone commands.
|
||||||
|
Referenced by `projects` (onboarding, milestones, due dates), `implement`
|
||||||
|
(`Ready -> Work in Progress`), and `verify` (`Work in Progress -> Review`,
|
||||||
|
`Review -> Completed`, and abort/rejection reverts).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Prerequisites & Anti-Hallucination Rules
|
||||||
|
|
||||||
|
- Verify GitHub repository identity first: `gh repo view --json url`.
|
||||||
|
- Confirm `gh auth status` includes `repo` and `project` scopes before running
|
||||||
|
Projects v2 GraphQL mutations.
|
||||||
|
- **Never hardcode or guess IDs**: Never guess milestone sequence numbers, never
|
||||||
|
construct `/milestone/1` URLs, and never hardcode GraphQL Node IDs
|
||||||
|
(`PVT_...`, `PVTSSF_...`, `PVTI_...`, or single-select option IDs). Always
|
||||||
|
resolve IDs dynamically from live `gh api` responses.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Fixed 5-Column Color Enum Map
|
||||||
|
|
||||||
|
GitHub Projects v2 `Status` single-select options use fixed enum names
|
||||||
|
(`ProjectV2SingleSelectFieldOptionColor`), not hex codes:
|
||||||
|
|
||||||
|
| Order | Column Name | GitHub Color Enum |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| `0` | `Backlog` | `GRAY` |
|
||||||
|
| `1` | `Ready` | `BLUE` |
|
||||||
|
| `2` | `Work in Progress` | `YELLOW` |
|
||||||
|
| `3` | `Review` | `PURPLE` |
|
||||||
|
| `4` | `Completed` | `GREEN` |
|
||||||
|
|
||||||
|
When reconciling an existing board's `Status` field via `updateProjectV2Field`,
|
||||||
|
match existing options case-insensitively and preserve their option IDs where
|
||||||
|
possible so attached cards stay intact. Ensure all 5 canonical column names and
|
||||||
|
color enums above exist before moving cards.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Onboarding New Issues onto a Board (`projects`)
|
||||||
|
|
||||||
|
Use `owner.projectV2(number: $project_number)` when creating or onboarding an
|
||||||
|
issue that is not yet attached to the board. Replace `organization` with `user`
|
||||||
|
for user-owned projects.
|
||||||
|
|
||||||
|
### Step 3a: Resolve `project_id` and Issue Global Node ID
|
||||||
|
```bash
|
||||||
|
gh api graphql \
|
||||||
|
-F owner="<owner>" \
|
||||||
|
-F repo="<repo>" \
|
||||||
|
-F project_number=<project_number> \
|
||||||
|
-F issue_number=<issue_number> \
|
||||||
|
-f query='
|
||||||
|
query($owner: String!, $repo: String!, $project_number: Int!, $issue_number: Int!) {
|
||||||
|
organization(login: $owner) {
|
||||||
|
projectV2(number: $project_number) { id }
|
||||||
|
}
|
||||||
|
repository(owner: $owner, name: $repo) {
|
||||||
|
issue(number: $issue_number) { id url }
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
*(For personal repositories, replace `organization(login: $owner)` with
|
||||||
|
`user(login: $owner)`.)*
|
||||||
|
|
||||||
|
### Step 3b: Add Issue to Project (`addProjectV2ItemById`)
|
||||||
|
```bash
|
||||||
|
gh api graphql \
|
||||||
|
-f project_id="<PVT_...>" \
|
||||||
|
-f content_id="<I_...>" \
|
||||||
|
-f query='
|
||||||
|
mutation($project_id: ID!, $content_id: ID!) {
|
||||||
|
addProjectV2ItemById(input: {projectId: $project_id, contentId: $content_id}) {
|
||||||
|
item { id }
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Card Transitions via `issue.projectItems` (`implement`, `verify`)
|
||||||
|
|
||||||
|
For board card moves, query `issue.projectItems` directly instead of scanning
|
||||||
|
`projectV2.items`. This avoids 100-item board pagination limits and resolves
|
||||||
|
`project_id`, `status_field_id`, the `PVTI_...` item ID, and all target column
|
||||||
|
`option_id`s in a single GraphQL request.
|
||||||
|
|
||||||
|
### Step 4a: Single-Query Dynamic Resolution
|
||||||
|
```bash
|
||||||
|
gh api graphql \
|
||||||
|
-F owner="<owner>" \
|
||||||
|
-F repo="<repo>" \
|
||||||
|
-F issue_number=<issue_number> \
|
||||||
|
-f query='
|
||||||
|
query($owner: String!, $repo: String!, $issue_number: Int!) {
|
||||||
|
repository(owner: $owner, name: $repo) {
|
||||||
|
issue(number: $issue_number) {
|
||||||
|
projectItems(first: 20) {
|
||||||
|
nodes {
|
||||||
|
id
|
||||||
|
project {
|
||||||
|
id
|
||||||
|
number
|
||||||
|
field(name: "Status") {
|
||||||
|
... on ProjectV2SingleSelectField {
|
||||||
|
id
|
||||||
|
options { id name color }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Filter `.data.repository.issue.projectItems.nodes[]` by
|
||||||
|
`select(.project.number == $project_number)` (using `project_number` from
|
||||||
|
`AGENTS.md`):
|
||||||
|
- If no matching node exists, halt and onboard the issue via Section 3 first.
|
||||||
|
- Verify the resolved `Status` field options include the target canonical column
|
||||||
|
name (`Backlog`, `Ready`, `Work in Progress`, `Review`, or `Completed`).
|
||||||
|
**Fail fast** with a clear column-name mismatch error if the target option is
|
||||||
|
missing; never fall back to a guessed option ID.
|
||||||
|
|
||||||
|
### Step 4b: Move Card (`SINGLE_SELECT` Status Mutation)
|
||||||
|
```bash
|
||||||
|
gh api graphql \
|
||||||
|
-f project_id="<PVT_...>" \
|
||||||
|
-f item_id="<PVTI_...>" \
|
||||||
|
-f field_id="<PVTSSF_...>" \
|
||||||
|
-f option_id="<option_id>" \
|
||||||
|
-f query='
|
||||||
|
mutation($project_id: ID!, $item_id: ID!, $field_id: ID!, $option_id: String!) {
|
||||||
|
updateProjectV2ItemFieldValue(input: {
|
||||||
|
projectId: $project_id
|
||||||
|
itemId: $item_id
|
||||||
|
fieldId: $field_id
|
||||||
|
value: { singleSelectOptionId: $option_id }
|
||||||
|
}) {
|
||||||
|
projectV2Item { id }
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Updating Projects v2 `DATE` Fields
|
||||||
|
|
||||||
|
Resolve the `DATE` field ID dynamically from `project.fields(first: 50)` (or
|
||||||
|
`project.field(name: "<Field Name>")`), then run `updateProjectV2ItemFieldValue`
|
||||||
|
with an ISO-8601 `YYYY-MM-DD` string:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gh api graphql \
|
||||||
|
-f project_id="<PVT_...>" \
|
||||||
|
-f item_id="<PVTI_...>" \
|
||||||
|
-f field_id="<PVTF_...>" \
|
||||||
|
-f date="YYYY-MM-DD" \
|
||||||
|
-f query='
|
||||||
|
mutation($project_id: ID!, $item_id: ID!, $field_id: ID!, $date: Date!) {
|
||||||
|
updateProjectV2ItemFieldValue(input: {
|
||||||
|
projectId: $project_id
|
||||||
|
itemId: $item_id
|
||||||
|
fieldId: $field_id
|
||||||
|
value: { date: $date }
|
||||||
|
}) {
|
||||||
|
projectV2Item { id }
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. REST Milestone & Issue Operations
|
||||||
|
|
||||||
|
GitHub CLI does not expose a native `gh milestone` subcommand; manage milestones
|
||||||
|
through REST via `gh api repos/{owner}/{repo}/milestones`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# List open milestones (extract number, title, due_on, html_url)
|
||||||
|
gh api repos/{owner}/{repo}/milestones --paginate \
|
||||||
|
--jq '.[] | {number, title, state, due_on, html_url}'
|
||||||
|
|
||||||
|
# Create a milestone (due_on is optional ISO-8601 UTC)
|
||||||
|
gh api repos/{owner}/{repo}/milestones -X POST \
|
||||||
|
-f title="<Milestone Title>" \
|
||||||
|
-f description="<Scope summary>" \
|
||||||
|
-f due_on="YYYY-MM-DDTHH:MM:SSZ"
|
||||||
|
|
||||||
|
# Update or close a milestone (use dynamically queried milestone number)
|
||||||
|
gh api repos/{owner}/{repo}/milestones/<milestone_number> -X PATCH \
|
||||||
|
-f state="closed"
|
||||||
|
|
||||||
|
# Create an issue attached to a milestone and verify returned URL
|
||||||
|
gh issue create \
|
||||||
|
--title "<Issue Title>" \
|
||||||
|
--body-file <issue-body.md> \
|
||||||
|
--milestone "<Milestone Title>"
|
||||||
|
```
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
# Planning Contract & Canonical Board State Machine
|
||||||
|
|
||||||
|
Sole owner of the repository `AGENTS.md` planning contract schema, the canonical
|
||||||
|
5-column GitHub Projects v2 board state machine, transition ownership, and the
|
||||||
|
scoped GitHub remote guard. Other delivery skills (`implement`, `verify`,
|
||||||
|
`code-review`, `reconcile-docs`) reference this file rather than duplicating it.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Repository `AGENTS.md` Planning Contract Schema
|
||||||
|
|
||||||
|
Each GitHub-managed repository stores minimal, human-readable planning
|
||||||
|
coordinates in its `AGENTS.md`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# Planning Contract (owned by projects)
|
||||||
|
project_number: <int>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Contract Invariants
|
||||||
|
- **State-free coordinates only**: Store only `project_number: <int>`. Never
|
||||||
|
hardcode rotating sprint state (active milestone numbers, open issue lists,
|
||||||
|
sprint names).
|
||||||
|
- **Zero brittle Node IDs**: Never store GraphQL Node IDs (`PVT_...`,
|
||||||
|
`PVTSSF_...`, `PVTI_...`, or single-select option IDs) in `AGENTS.md`. Skills
|
||||||
|
resolve all IDs dynamically at runtime via
|
||||||
|
[github-projects-v2.md](github-projects-v2.md).
|
||||||
|
- **Repo-scoped documentation paths**: Durable engineering specs, architecture
|
||||||
|
notes, and roadmaps live in repository-scoped `docs/` (`docs/designs/*.md`,
|
||||||
|
`docs/adr/`, `ARCHITECTURE.md`, `ROADMAP.md`). Ephemeral agent artifacts and
|
||||||
|
personal practice records live in gitignored `.internal/` at the repository
|
||||||
|
root. Never encode user home paths or external vault directories in a
|
||||||
|
repository planning contract.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Canonical 5-Column Board State Machine
|
||||||
|
|
||||||
|
All GitHub Projects v2 boards managed by the delivery loop use 5 canonical
|
||||||
|
`Status` column names paired with fixed GitHub `ProjectV2SingleSelectFieldOptionColor`
|
||||||
|
enums:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Backlog -> Ready -> Work in Progress -> Review -> Completed
|
||||||
|
```
|
||||||
|
|
||||||
|
| Order | Column | Fixed GitHub Color Enum | Entering Transition Owner | Trigger Event |
|
||||||
|
| :--- | :--- | :--- | :--- | :--- |
|
||||||
|
| `0` | `Backlog` | `GRAY` | `projects` (or `verify` on abort) | Issue created and onboarded, or abandoned/superseded Draft PR closed |
|
||||||
|
| `1` | `Ready` | `BLUE` | `projects` | Slice prioritized and ready for execution |
|
||||||
|
| `2` | `Work in Progress` | `YELLOW` | `implement` (or `verify` on merge rejection) | `implement` preflight passes (`Ready -> Work in Progress`); card stays here through Draft PR open, `code-review`, and rework; human merge rejection at `verify` Phase 3 runs `gh pr ready --undo` and moves `Review -> Work in Progress` |
|
||||||
|
| `3` | `Review` | `PURPLE` | `verify` | `verify` Phase 2 passes runtime QA + CI + `verdict=ready` gate and promotes the Draft PR (`gh pr ready`), moving `Work in Progress -> Review` |
|
||||||
|
| `4` | `Completed` | `GREEN` | `verify` | `verify` Phase 3 merges the PR on human approval and executes `Review -> Completed` directly |
|
||||||
|
|
||||||
|
### Read-Only Skill Boundaries
|
||||||
|
- **`code-review`**: Strictly read-only regarding project boards. Never executes
|
||||||
|
board card moves.
|
||||||
|
- **`reconcile-docs`**: Strictly read-only regarding GitHub state. Never mutates
|
||||||
|
GitHub issues, pull requests, milestones, or project boards.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Scoped GitHub Remote Guard
|
||||||
|
|
||||||
|
Forge-dependent operations across the delivery loop (`projects`, `implement`,
|
||||||
|
`verify`, PR review publishing in `code-review`, and optional GitHub-state reads
|
||||||
|
in `reconcile-docs`) must verify GitHub repository identity before issuing forge
|
||||||
|
commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gh repo view --json url
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Why `gh repo view --json url`**: Resolves the active GitHub repository even
|
||||||
|
when using custom SSH host aliases or non-`origin` remotes.
|
||||||
|
- **Local-only exception**: Local diff reviews in `code-review` (when no open PR
|
||||||
|
exists or local-only mode is requested) and local git/doc reconciliation in
|
||||||
|
`reconcile-docs` run without requiring a GitHub remote.
|
||||||
|
- **Legacy Gitea contract detection**: If `gh repo view --json url` fails, or if
|
||||||
|
the repository's `AGENTS.md` contains a legacy Gitea planning contract (such
|
||||||
|
as Gitea `project_id`, `{Backlog..Completed -> column_id}` maps, or
|
||||||
|
`gitea-plan` sync rules), fail fast and advise the user to either migrate the
|
||||||
|
repository to GitHub via `/gitea-to-github` or use standalone `gt-usage`
|
||||||
|
outside the core delivery loop.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Meaningful Conflict Reconciliation
|
||||||
|
|
||||||
|
When reconciling specs, roadmaps, and GitHub state in Step 2, never mechanically
|
||||||
|
mirror or silently mutate conflicting state. Detect and report semantic
|
||||||
|
conflicts before planning new work:
|
||||||
|
|
||||||
|
- **Zombie In-Progress**: Issue or linked PR is closed on GitHub, but its card
|
||||||
|
still sits in `Backlog`, `Ready`, `Work in Progress`, or `Review`.
|
||||||
|
- **Premature Completed**: Card sits in `Completed`, but the issue remains open
|
||||||
|
or lacks a merged PR / commit on the default branch.
|
||||||
|
- **Review Orphan**: Card sits in `Review`, but no open ready-for-review PR
|
||||||
|
exists.
|
||||||
|
- **Horizon Divergence**: An open issue is assigned to a closed milestone or
|
||||||
|
diverges from the active milestone in `ROADMAP.md`.
|
||||||
|
- **Doc Lag**: `ARCHITECTURE.md`, `ROADMAP.md`, or `docs/designs/*.md` lags
|
||||||
|
behind `Completed` board cards. Hand off to `reconcile-docs` before
|
||||||
|
decomposing the next rolling milestone.
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
# Project Sizing, Ceremony Tiers, and Reproducibility Audit
|
||||||
|
|
||||||
|
Reference for `projects`. Guidelines for scaling planning ceremony to risk and
|
||||||
|
scope, structuring vertical-slice issues, and running clean-room reproducibility
|
||||||
|
audits on GitHub Issues and Projects v2.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Core Axiom: Issues vs. Commits
|
||||||
|
|
||||||
|
- An **Issue** represents an **independently deliverable outcome** (what is
|
||||||
|
built, verified, and closed by a pull request). It defines test seams and
|
||||||
|
falsifiable acceptance criteria (`Context`, `Solution`, `Acceptance Criteria`).
|
||||||
|
- A **Commit** represents an **atomic, reversible implementation checkpoint**
|
||||||
|
within an issue's branch. Commits compile and pass tests, but do not need to
|
||||||
|
close an entire issue on their own.
|
||||||
|
- **Anti-pattern**: Never create 1:1 GitHub issues for micro-commits (such as
|
||||||
|
"fix typo", "add helper function", or "clean up lint"). Group cohesive
|
||||||
|
checkpoints under one deliverable issue.
|
||||||
|
- **Vertical Submodule TDD Grouping**: Inside a multi-module issue, organize
|
||||||
|
acceptance criteria and TDD test seams vertically by submodule or capability
|
||||||
|
layer (for example, `parser` -> `validator` -> `cli`) rather than a single
|
||||||
|
horizontal "write all tests for the entire issue first" block, so `implement`
|
||||||
|
executes incremental Red-Green cycles per submodule.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. GitHub Planning Primitives
|
||||||
|
|
||||||
|
Each GitHub primitive tracks a distinct dimension of delivery:
|
||||||
|
|
||||||
|
- **Issue State (`OPEN` vs. `CLOSED`)**: Deliverable completion on the default branch.
|
||||||
|
- **Projects v2 `Status` Column (`Backlog`, `Ready`, `Work in Progress`, `Review`, `Completed`)**:
|
||||||
|
Active workflow stage. See [planning-contract.md](planning-contract.md) for
|
||||||
|
canonical colors and transition ownership, and
|
||||||
|
[github-projects-v2.md](github-projects-v2.md) for GraphQL recipes.
|
||||||
|
- **Milestone & Projects v2 `DATE` Fields**: Strategic delivery horizon and
|
||||||
|
target/due dates.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Planning Ceremony Tiers & Project Board Policy
|
||||||
|
|
||||||
|
| Tier | Typical Work | GitHub Primitives | Project Board Policy | Decomposition Rule |
|
||||||
|
| :--- | :--- | :--- | :--- | :--- |
|
||||||
|
| **Small** | Localized bugfix, doc update, dependency bump, routine chore (1 to 3 issues) | 1 to 3 Issues, single optional Milestone | **Omitted** by policy (issue tracker suffices) | Keep each issue concise (`Context`, `Solution`, `Acceptance Criteria`). Clean-room audit omitted. |
|
||||||
|
| **Medium** | Vertical feature slice, multi-step refactor, capability buildout (4 to 8 vertical slices) | 1 Milestone + 4 to 8 Issues | **Recommended** (5-column Projects v2 board) | Each issue has its own branch and Draft PR. Explicit numbered acceptance criteria and test seams. Mandatory clean-room audit. |
|
||||||
|
| **Large** | Architectural epic, platform cutover, multi-service evolution | Roadmap doc + Phased Rolling Milestones + Cross-Slice Dependency Map + Deliverable Issues | **Required** (5-column Projects v2 board coordinates rolling horizons) | Source of truth stays in repo docs (`ARCHITECTURE.md`, `ROADMAP.md`, `docs/designs/*.md`, `docs/adr/`). Mandatory clean-room audit. |
|
||||||
|
|
||||||
|
### Deterministic Output Headers (Subagent Provenance Guard)
|
||||||
|
Every planning proposal must emit both headers verbatim before asking for
|
||||||
|
approval:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
### Project Board Policy: <Omitted|Recommended|Required> (Rationale)
|
||||||
|
### Reproducibility Audit: <Passed | Remediated> (Subagent: `<conversation-id>` | `Omitted: Small tier`)
|
||||||
|
```
|
||||||
|
|
||||||
|
- For `Medium` and `Large` tiers, `Subagent: <conversation-id>` must record the
|
||||||
|
real conversation ID returned by the clean-room auditor subagent. Never
|
||||||
|
fabricate a placeholder ID or claim `Passed` without running the subagent.
|
||||||
|
- `Omitted: Small tier` is valid only when the selected tier is `Small`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Independent Zero-Context Reproducibility Audit
|
||||||
|
|
||||||
|
Mandatory for `Medium` and `Large` plans before presenting the decomposition for
|
||||||
|
approval (Step 5). Spawn a fresh-context subagent with zero prior conversation
|
||||||
|
history to verify that every proposed slice is executable without guesswork.
|
||||||
|
|
||||||
|
### Input Manifest (Strict Clean-Room)
|
||||||
|
Pass strictly raw artifacts and pinned repository state to the auditor:
|
||||||
|
1. Pinned repository root and commit SHA (`git rev-parse HEAD`).
|
||||||
|
2. Canonical specifications (`ARCHITECTURE.md`, `ROADMAP.md`, `docs/designs/*.md`, `docs/adr/*.md`).
|
||||||
|
3. Proposed raw issue titles, descriptions, test seams, and acceptance criteria markdown.
|
||||||
|
4. Proposed milestone titles, due dates, and Projects v2 board specifications.
|
||||||
|
5. Declared asset paths and prerequisite environment variables.
|
||||||
|
|
||||||
|
### Auditor Report Schema
|
||||||
|
The clean-room auditor must report directly from the manifest across five
|
||||||
|
explicit sections, without inventing missing requirements or fabricating
|
||||||
|
unchecked claims:
|
||||||
|
|
||||||
|
1. **Reconstructed from Source Artifacts**: Scope and sequence directly supported by source text.
|
||||||
|
2. **Inferred Requirements**: Deductions made from titles or conventions lacking explicit spec text.
|
||||||
|
3. **Undetermined Seams**: Gaps or ambiguities that cannot be resolved without guessing.
|
||||||
|
4. **Materiality Classification**:
|
||||||
|
- *Material*: Forces an implementer to guess about scope, behavior, acceptance criteria, or prerequisites.
|
||||||
|
- *Non-Material*: Cosmetic or self-evident convention.
|
||||||
|
5. **Concrete Remediation Plan**: Specific edits to specs, assets, or issue criteria needed to resolve every *Material* ambiguity.
|
||||||
|
|
||||||
|
Resolve all *Material* findings before requesting human approval. Record the
|
||||||
|
auditor's exact outcome (`Passed` if zero material findings, `Remediated` after
|
||||||
|
applying fixes) and `<conversation-id>` in the `### Reproducibility Audit:`
|
||||||
|
header.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Rolling Horizons for Large Projects
|
||||||
|
|
||||||
|
Avoid waterfall decomposition where distant work is pre-created weeks before
|
||||||
|
execution:
|
||||||
|
|
||||||
|
1. **Active Milestone (Immediate Horizon)**: Decompose into concrete vertical
|
||||||
|
slice issues with falsifiable acceptance criteria and a cross-slice
|
||||||
|
dependency map.
|
||||||
|
2. **Future Milestones (Deferred Horizons)**: Represent as high-level milestones
|
||||||
|
with target due dates or single coarse placeholder issues.
|
||||||
|
3. **Architecture Synchronization**: Run `reconcile-docs` to sync canonical docs
|
||||||
|
against completed work before decomposing the next rolling milestone.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Organization-Level Shared Projects v2 Boards
|
||||||
|
|
||||||
|
For multi-repository architectures coordinated under one GitHub organization:
|
||||||
|
- Create one shared Projects v2 board at the organization level and record its
|
||||||
|
`project_number` in each participating repository's `AGENTS.md`.
|
||||||
|
- Onboard issues from child repositories onto that shared board using
|
||||||
|
`organization(login: $owner).projectV2(number: $project_number)` and
|
||||||
|
`addProjectV2ItemById` (see [github-projects-v2.md](github-projects-v2.md)).
|
||||||
|
- Keep architectural strategy and cross-repo roadmaps in the hub repository's
|
||||||
|
`docs/` directory while the shared board tracks unified delivery status.
|
||||||
@@ -3,7 +3,7 @@ name: reconcile-docs
|
|||||||
description: >-
|
description: >-
|
||||||
Audit, reconcile, and generate canonical repository documentation (README.md,
|
Audit, reconcile, and generate canonical repository documentation (README.md,
|
||||||
ARCHITECTURE.md, docs/adr/, ROADMAP.md, docs/designs/*.md) against commit
|
ARCHITECTURE.md, docs/adr/, ROADMAP.md, docs/designs/*.md) against commit
|
||||||
history, code reality, Gitea delivery state, and active plans. Use when
|
history, code reality, GitHub delivery state, and active plans. Use when
|
||||||
updating a repository's official documentation. For capturing a single
|
updating a repository's official documentation. For capturing a single
|
||||||
session's decision, debug record, or insight into repo docs, use document.
|
session's decision, debug record, or insight into repo docs, use document.
|
||||||
---
|
---
|
||||||
@@ -11,14 +11,14 @@ description: >-
|
|||||||
# Reconcile Docs
|
# Reconcile Docs
|
||||||
|
|
||||||
## Use when
|
## Use when
|
||||||
- `/reconcile-docs [history-path]`: audit or reconcile repository documentation against history, Gitea state, and active plans.
|
- `/reconcile-docs [history-path]`: audit or reconcile repository documentation against history, optional GitHub state, and active plans.
|
||||||
- Closing a milestone or resolving mid-milestone design spec drift flagged by `code-review` or `implement-slice`.
|
- Closing a milestone or resolving mid-milestone design spec drift flagged by `code-review`, `implement`, or `verify`.
|
||||||
- Not for capturing a single session's insight or incident record (use `/document`).
|
- Not for capturing a single session's insight or incident record (use `/document`).
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
1. **Discover Present State.** Inspect working-tree status, repository source, tests, configuration, `AGENTS.md`, and existing docs. Build a present-state inventory of components, responsibilities, boundaries, and dependencies.
|
1. **Discover Present State.** Inspect working-tree status, repository source, tests, configuration, `AGENTS.md`, and existing docs. Build a present-state inventory of components, responsibilities, boundaries, and dependencies. Local git/doc reconciliation runs on any repository without requiring a GitHub remote.
|
||||||
2. **Reconstruct History.** Read chronological notes and commit history from the repository (`git log`, `docs/discussions/`, `docs/debug/`, `docs/adr/`, or an optional history path) and, when a Gitea remote exists, read merged PRs and published `code-review` PR comments/reviews via `gt` (using `gt-usage` read-only queries). Extract decisions, accepted trade-offs, mid-slice contract pivots, rejected alternatives, migrations, and incidents.
|
2. **Reconstruct History.** Read chronological notes and commit history (`git log`, `docs/discussions/`, `docs/debug/`, `docs/adr/`, or an optional history path). When `gh repo view --json url` succeeds, also read merged PRs (`gh pr list --state merged`) and published `code-review` PR comments/reviews read-only via `gh api`. Extract decisions, mid-slice contract pivots, rejected alternatives, migrations, and incidents.
|
||||||
3. **Extract Future Intent.** Identify active plans, roadmaps (`ROADMAP.md`, `docs/designs/*.md`), and, when a Gitea remote exists, read open/closed Gitea milestones, issues, and Project Board column placement (`Completed` vs. `Backlog`, `Ready`, `Work in Progress`, `Review`) read-only via `gt`. Classify each item as committed, planned, exploratory, or superseded. Never mutate Gitea issues, PRs, or board cards.
|
3. **Extract Future Intent.** Identify active plans and roadmaps (`ROADMAP.md`, `docs/designs/*.md`). When `gh repo view --json url` succeeds, also read open/closed GitHub milestones (`gh api repos/{owner}/{repo}/milestones`), issues, and Projects v2 Project Board column placement (`Completed` vs. `Backlog`, `Ready`, `Work in Progress`, `Review`) read-only via `gh`. Classify each item as committed, planned, exploratory, or superseded. Never mutate GitHub issues, PRs, or board cards.
|
||||||
4. **Reconcile and Detect Conflicts.** Correlate past claims, present code reality, and future plans using [references/reconciliation-matrix.md](references/reconciliation-matrix.md). Flag contradictions (historical claims contradicted by code, mid-slice spec drift in `docs/designs/*.md`, or `Backlog` plans masquerading as current implementation).
|
4. **Reconcile and Detect Conflicts.** Correlate past claims, present code reality, and future plans using [references/reconciliation-matrix.md](references/reconciliation-matrix.md). Flag contradictions (historical claims contradicted by code, mid-slice spec drift in `docs/designs/*.md`, or `Backlog` plans masquerading as current implementation).
|
||||||
5. **Human Checkpoint.** Present a Reconciliation Report following [references/checkpoint-format.md](references/checkpoint-format.md) listing present architecture, recovered decisions, resolved and unresolved conflicts, and proposed document mutations. Stop for user approval.
|
5. **Human Checkpoint.** Present a Reconciliation Report following [references/checkpoint-format.md](references/checkpoint-format.md) listing present architecture, recovered decisions, resolved and unresolved conflicts, and proposed document mutations. Stop for user approval.
|
||||||
6. **Draft or Update Canonical Docs.** Once approved, generate or update target artifacts following [references/doc-contracts.md](references/doc-contracts.md) in order:
|
6. **Draft or Update Canonical Docs.** Once approved, generate or update target artifacts following [references/doc-contracts.md](references/doc-contracts.md) in order:
|
||||||
@@ -40,5 +40,6 @@ description: >-
|
|||||||
|
|
||||||
## Hands off to
|
## Hands off to
|
||||||
- `git-manager`: for branch setup or committing updated documentation (`Suggested Next Step: /git-manager`).
|
- `git-manager`: for branch setup or committing updated documentation (`Suggested Next Step: /git-manager`).
|
||||||
- `gitea-plan`: when reconciled `ROADMAP.md` or `docs/designs/*.md` require new or updated Gitea milestones, issues, or board reconciliation (`Suggested Next Step: /gitea-plan`).
|
- `projects`: when reconciled `ROADMAP.md` or `docs/designs/*.md` require new or updated GitHub milestones, issues, or board reconciliation (`Suggested Next Step: /projects`).
|
||||||
- Emit one outcome-matched `Suggested Next Step` on standalone turns per [skeleton](../build-skill/references/skeleton.md).
|
- `implement`: when reconciled design specs unblock the next ready vertical slice (`Suggested Next Step: /implement #<issue>`).
|
||||||
|
- Emit one outcome-matched `Suggested Next Step:` on standalone turns; suppress when delegated per [skeleton](../build-skill/references/skeleton.md).
|
||||||
@@ -108,5 +108,5 @@ Only items that represent intentional, validated future trajectory belong here.
|
|||||||
**Core Question**: What is the approved technical specification for an active multi-slice feature or epic?
|
**Core Question**: What is the approved technical specification for an active multi-slice feature or epic?
|
||||||
|
|
||||||
### Contract Invariants
|
### Contract Invariants
|
||||||
- When an earlier slice in a multi-slice milestone intentionally evolves a shared interface, config schema, or error taxonomy on `main` (and codifies it in `AGENTS.md` or PR review comments), update the affected sections of `docs/designs/*.md` so subsequent slices (`implement-slice` Step 1) do not build against stale contracts.
|
- When an earlier slice in a multi-slice milestone intentionally evolves a shared interface, config schema, or error taxonomy on `main` (and codifies it in `AGENTS.md` or PR review comments), update the affected sections of `docs/designs/*.md` so subsequent slices (`implement` preflight) do not build against stale contracts.
|
||||||
- Never modify read-only historical proof-of-concept directories (`docs/poc/`).
|
- Never modify read-only historical proof-of-concept directories (`docs/poc/`).
|
||||||
@@ -9,10 +9,10 @@ Treat each source according to its temporal role and authority:
|
|||||||
| Source | Temporal role | Epistemic authority |
|
| Source | Temporal role | Epistemic authority |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| Chronological records (`git log`, `docs/discussions/`, `docs/debug/`) | Past | Historical evidence. Explains how the system arrived here. |
|
| Chronological records (`git log`, `docs/discussions/`, `docs/debug/`) | Past | Historical evidence. Explains how the system arrived here. |
|
||||||
| Merged PRs & published `code-review` comments (`gt pr`) | Past -> Present | Primary record of slice-level contract evolutions, accepted trade-offs, and deferred nits. |
|
| Merged PRs & published `code-review` comments (`gh pr list --state merged`, `gh api` PR reviews/comments) | Past -> Present | Optional read-only record (when `gh repo view --json url` succeeds) of slice-level contract evolutions, resolved findings, and deferred issues. |
|
||||||
| Repository implementation (code, tests, configuration, `AGENTS.md`) | Present | Canonical technical truth. Determines what the system is right now. |
|
| Repository implementation (code, tests, configuration, `AGENTS.md`) | Present | Canonical technical truth. Determines what the system is right now. |
|
||||||
| Existing repository documentation (`ARCHITECTURE.md`, `docs/designs/*.md`) | Present | Canonical unless contradicted by current implementation. |
|
| Existing repository documentation (`ARCHITECTURE.md`, `docs/designs/*.md`) | Present | Canonical unless contradicted by current implementation. |
|
||||||
| Gitea Milestones & Project Board (`Completed` vs. `Backlog`/`Ready`) | Present -> Future | Read-only delivery state: `Completed` cards are present truth; `Backlog`/`Ready` cards are future intent. |
|
| GitHub Milestones & Projects v2 Board (`gh api` milestones, `Completed` vs. `Backlog`/`Ready`) | Present -> Future | Optional read-only delivery state (when `gh repo view --json url` succeeds): `Completed` cards are present truth; `Backlog`/`Ready` cards are future intent. |
|
||||||
| Active plans (roadmaps, proposals, pending designs) | Future | Planned intent. Describes where the system may go next. |
|
| Active plans (roadmaps, proposals, pending designs) | Future | Planned intent. Describes where the system may go next. |
|
||||||
| ADRs | Past -> Present | Historical decision record that remains valid until superseded. |
|
| ADRs | Past -> Present | Historical decision record that remains valid until superseded. |
|
||||||
| ROADMAP | Future | Intended technical trajectory. |
|
| ROADMAP | Future | Intended technical trajectory. |
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@ description: >-
|
|||||||
- `/tdd` for Mode A (test-first implementation, red-green vertical slices, or failing bug reproduction).
|
- `/tdd` for Mode A (test-first implementation, red-green vertical slices, or failing bug reproduction).
|
||||||
- `/tdd <test-path|branch|PR>` for Mode B (active audit and hardening of existing tests against [seams-and-mocking](references/seams-and-mocking.md) and [test-quality](references/test-quality.md)).
|
- `/tdd <test-path|branch|PR>` for Mode B (active audit and hardening of existing tests against [seams-and-mocking](references/seams-and-mocking.md) and [test-quality](references/test-quality.md)).
|
||||||
- Not for trivial two-line fixes, copy, styling, declarative config, or pure wiring: edit directly instead.
|
- Not for trivial two-line fixes, copy, styling, declarative config, or pure wiring: edit directly instead.
|
||||||
- Not for read-only pre-merge multi-axis diff inspection (`code-review`) or live runtime/browser QA (`verify-slice`).
|
- Not for read-only pre-merge multi-axis diff inspection (`code-review`) or live runtime/browser QA (`verify`).
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
1. **Check applicability and select mode.** Confirm the task tests observable logic at a testable boundary (skip and edit directly for trivial config/copy when `/tdd` was not requested). Read project domain docs (`GLOSSARY.md` or local ADRs) if present. Select **Mode A** when adding new behavior, reproducing a bug, or writing a new test; select **Mode B** when asked to audit/harden existing tests or fix `code-review` Axis 3 findings, and follow the Mode B checklist in [test-quality](references/test-quality.md).
|
1. **Check applicability and select mode.** Confirm the task tests observable logic at a testable boundary (skip and edit directly for trivial config/copy when `/tdd` was not requested). Read project domain docs (`GLOSSARY.md` or local ADRs) if present. Select **Mode A** when adding new behavior, reproducing a bug, or writing a new test; select **Mode B** when asked to audit/harden existing tests or fix `code-review` Axis 3 findings, and follow the Mode B checklist in [test-quality](references/test-quality.md).
|
||||||
@@ -36,7 +36,7 @@ description: >-
|
|||||||
|
|
||||||
## Hands off to
|
## Hands off to
|
||||||
- `code-review`: to inspect the resulting diff, smells, invariants, and Axis 3 test integrity (`Suggested Next Step: /code-review <base>..HEAD`).
|
- `code-review`: to inspect the resulting diff, smells, invariants, and Axis 3 test integrity (`Suggested Next Step: /code-review <base>..HEAD`).
|
||||||
- `verify-slice`: when the slice also needs live runtime, browser DOM, or multi-service verification (`Suggested Next Step: /verify-slice`).
|
- `verify`: when the slice also needs live runtime, browser DOM, or multi-service verification (`Suggested Next Step: /verify`).
|
||||||
- `diagnose`: when an unexpected test or fixture failure needs root-cause investigation (`Suggested Next Step: /diagnose <failing-test>`).
|
- `diagnose`: when an unexpected test or fixture failure needs root-cause investigation (`Suggested Next Step: /diagnose <failing-test>`).
|
||||||
- `git-manager`: for branch isolation or committing cohesive vertical slices.
|
- `git-manager`: for branch isolation or committing cohesive vertical slices.
|
||||||
- Emit one outcome-matched `Suggested Next Step` on standalone turns; suppress when delegated (per [skeleton](../build-skill/references/skeleton.md)).
|
- Emit one outcome-matched `Suggested Next Step` on standalone turns; suppress when delegated (per [skeleton](../build-skill/references/skeleton.md)).
|
||||||
@@ -10,7 +10,7 @@ A **seam** is the public interface where callers observe behavior without reachi
|
|||||||
|
|
||||||
When proposing a new seam to the human owner, state two things in one line:
|
When proposing a new seam to the human owner, state two things in one line:
|
||||||
- **What it catches**: the behavioral contract verified through this boundary.
|
- **What it catches**: the behavioral contract verified through this boundary.
|
||||||
- **What it misses**: the outer integration layer left to `verify-slice` or higher-level tests.
|
- **What it misses**: the outer integration layer left to `verify` or higher-level tests.
|
||||||
|
|
||||||
| Stack | Typical Public Seam | Avoid Testing Directly |
|
| Stack | Typical Public Seam | Avoid Testing Directly |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
---
|
|
||||||
name: verify-slice
|
|
||||||
description: >-
|
|
||||||
Runs risk-proportional verification and pull request review across behavioral,
|
|
||||||
state, security, ergonomic, and regression perspectives using falsifiable
|
|
||||||
assertions. Use when verifying a vertical feature slice, reviewing a pull
|
|
||||||
request before merge, or planning QA checks. Not for root-cause debugging;
|
|
||||||
use diagnose.
|
|
||||||
---
|
|
||||||
|
|
||||||
# Verify Slice
|
|
||||||
|
|
||||||
## Use when
|
|
||||||
- Verifying a vertical feature slice or pull request before human release review.
|
|
||||||
- Building or executing risk-proportional QA checks against acceptance criteria.
|
|
||||||
- Not for investigating an unknown failure from raw symptoms: use `diagnose`.
|
|
||||||
|
|
||||||
## Steps
|
|
||||||
1. **Size checks to risk and evaluate review handshake.** Inspect touched files, boundaries, and failure consequences, then apply the matching minimum check set in [perspectives](references/perspectives.md) (`Lightweight`, `Standard`, or `High-Assurance`) plus only the perspectives warranted by the diff. Reuse a preceding `code-review` report for static provenance only when its status is `Ready` (completed across all four axes, no unresolved blocking findings remain, and covered scope is identified), the reviewed base and head revisions match, and the current relevant working-tree diff is unchanged from the reviewed diff. Proceed directly on routine checks within authorized scope; pause for confirmation only when verification would materially expand scope, require `live-infra` authorization, incur substantial setup or subagent cost, or introduce a trade-off.
|
|
||||||
2. **Write falsifiable assertions.** Convert acceptance criteria, `code-review` Step 6 fenced checks (when present), and selected perspectives into concrete checks with explicit failure conditions (`FAIL if ...`), scope classification (`local` vs. `live-infra`), and required evidence. Never use open-ended observational prompts ("record what happens").
|
|
||||||
3. **Verify runtime behavior.** Execute `local` behavioral, state, and persistence checks against the live system when the tier requires it, confirming mutations via both UI state and authoritative backend reads. Execute `live-infra` checks only when the human owner has explicitly authorized the target environment and operation; otherwise record `BLOCKED (out-of-bounds)` with the preserved command and criteria. Execute directly by default; use a clean subagent (withholding the diff, PR narrative, and author self-audit) only when independent execution is likely to expose blind spots in stateful workflows or `High-Assurance` changes.
|
|
||||||
4. **Inspect the diff (unless handshake invariant holds).** When Step 1 verified a reusable `Ready` review on the exact unchanged diff, bypass static diff re-inspection and cite that review as static provenance (runtime verification provides behavioral evidence and never substitutes for static review). Otherwise (standalone run, non-`Ready` review, revision mismatch, or changed working-tree diff), audit the changed delta or full diff against the selected code-level perspectives (untrusted data and URL sinks, authoritative state reconciliation, scope containment, and test coverage claims).
|
|
||||||
5. **Record dispositions honestly.** Score every check as `PASS`, `FAIL`, `BLOCKED` (`env/fixture` vs. `out-of-bounds`), or `INCONCLUSIVE` with evidence (see [perspectives](references/perspectives.md)). Never rationalize an unexpected result as a design trade-off, treat a missing or `BLOCKED` check as passing, or treat either static provenance or runtime evidence as release approval.
|
|
||||||
6. **Present the evidence packet.** Distinguish static provenance (`diff` audit vs. `code-review` handshake) from runtime evidence, note discrepancies against the implementer's self-audit, separate `BLOCKED (env/fixture)` repairs from `BLOCKED (out-of-bounds)` operator checks, and recommend a disposition without waiving failed criteria.
|
|
||||||
|
|
||||||
## Your call
|
|
||||||
- **Expanded verification scope and `live-infra` authorization**: approve before running `live-infra` operations against privileged or external environments, spinning up costly test setups, or launching isolated subagents outside previously authorized boundaries.
|
|
||||||
- **Handling non-passing checks**: decide whether a `FAIL`, `BLOCKED`, or `INCONCLUSIVE` check triggers a repair loop, an environment fix, an authorized operator window, a tracked follow-up issue, or an explicit waiver.
|
|
||||||
- **Release decision**: decide whether to accept residual risks and merge; neither static review nor runtime verification authorizes release on its own.
|
|
||||||
|
|
||||||
## Done when
|
|
||||||
- Every required check has an evidence-backed disposition (`PASS`, `FAIL`, `BLOCKED (env/fixture)`, `BLOCKED (out-of-bounds)`, or `INCONCLUSIVE`), static provenance and runtime evidence are clearly distinguished, and the human owner has reviewed the packet to decide release or rework.
|
|
||||||
|
|
||||||
## Hands off to
|
|
||||||
- `diagnose`: when a failed or blocked check needs root-cause investigation.
|
|
||||||
- `git-manager`: when committing verified repair changes or managing test branches.
|
|
||||||
- `document`: when verification uncovers a durable architectural insight or decision.
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
# Verification Tiers, Perspectives, and Dispositions
|
|
||||||
|
|
||||||
Reference for `verify-slice`. Keep effort proportional to failure consequences and change uncertainty rather than diff line count alone.
|
|
||||||
|
|
||||||
## 1. Operational Rigor Tiers
|
|
||||||
|
|
||||||
Each tier defines the minimum required checks. Escalate individual perspectives when a small diff touches a high-risk boundary (for example, a two-line auth or URL sanitizer change). When a reusable `Ready` `code-review` handshake covers the exact unchanged base, head, and working-tree diff (see `SKILL.md` Steps 1 and 4), that review satisfies the tier's static diff audit as static provenance while `verify-slice` supplies runtime behavioral evidence; if any relevant file changed post-review, audit at least the changed delta.
|
|
||||||
|
|
||||||
| Tier | Typical Slice | Minimum Required Checks | Execution Mode |
|
|
||||||
| :--- | :--- | :--- | :--- |
|
|
||||||
| **Lightweight** | Copy updates, styling tweaks, isolated low-risk fixes with no new state or untrusted inputs | 1. Run relevant existing automated tests.<br/>2. Targeted smoke/regression check on the touched view.<br/>3. Concise diff check for scope containment. | Direct execution in current session. |
|
|
||||||
| **Standard** | New UI component, ordinary API integration, or modification to an established workflow | 1. Falsifiable assertions for every acceptance criterion.<br/>2. Automated test suite, typecheck, and lint.<br/>3. Runtime check of happy, empty, and error states plus persistence reload.<br/>4. Targeted regression check on shared entrypoints.<br/>5. White-box diff review of untrusted sinks and state updates. | Direct execution by default. Use an isolated black-box subagent only if multi-step workflow bias or author self-audit independence warrants the cost. |
|
|
||||||
| **High-Assurance** | Auth, permissions, payments, destructive actions, sensitive data, concurrent/conflict state, or cross-cutting architecture | All `Standard` checks, plus:<br/>1. Explicit conflict, duplicate-submission, and aggregate-state reconciliation assertions.<br/>2. Source-to-sink security audit with adversarial input tests.<br/>3. Secondary backend/API reads confirming persisted truth after mutations. | Independent black-box subagent for behavioral scenarios paired with separate white-box diff review. |
|
|
||||||
|
|
||||||
## 2. Selectable Review Perspectives
|
|
||||||
|
|
||||||
Select only the perspectives relevant to the slice's risk profile. Give each selected perspective concrete assertions rather than vague instructions ("review security").
|
|
||||||
|
|
||||||
| Perspective | Core Question | Concrete Checks to Construct |
|
|
||||||
| :--- | :--- | :--- |
|
|
||||||
| **Behavioral & Workflow** | Can the user complete the intended end-to-end task across real states? | Verify each required user journey across loading, empty, error/retry, partial, and success states; confirm state survives reload and matches backend reads. |
|
|
||||||
| **State & Concurrency** | Do local UI elements, sibling rows, and aggregate counters stay aligned with authoritative state? | Check duplicate-click guards, timeout/retry recovery, and conflict responses (such as `409`); assert that aggregate counters and sibling items reconcile with authoritative server state rather than drifting via partial local heuristics. |
|
|
||||||
| **Security Boundaries** | Can untrusted data execute code, break attributes, or route to unsafe destinations? | Trace every dynamic value into DOM/template sinks: verify safe DOM APIs or HTML escaping for text and quoted attributes, context-appropriate URL validation for `href`/`src`/`action` (never relying on HTML escaping alone for URLs), and at least one adversarial payload check. |
|
|
||||||
| **Ergonomics & Accessibility** | Is the slice usable on narrow screens, with touch, and via keyboard/assistive tech? | Check narrow mobile viewport (`375px`) for overflow, `>= 44x44px` touch targets, sequential keyboard `Tab` focus, visible `:focus-visible` outlines, and `aria-live` announcements for dynamic feedback. |
|
|
||||||
| **Scope & Regression** | Did the slice disturb adjacent features or smuggle unrelated refactors? | Inspect shared files (`main`, routers, shared types/styles) for minimal additive footprint; run targeted smoke checks on neighboring views/endpoints. |
|
|
||||||
| **Commit & Evidence Hygiene** | Are commits localizable and does claimed test coverage match reality? | Separates two distinct responsibilities: (1) **Static review** (commit structure, diff scope, source and test inspection) is covered by a matching `Ready` review handshake. (2) **Runtime evidence reconciliation** verifies that reported outcomes are supported by executed checks and relevant test assertions substantiate claimed contracts. |
|
|
||||||
|
|
||||||
## 3. Four-State Disposition Contract and Boundary Matrix
|
|
||||||
|
|
||||||
Every required assertion ends in exactly one disposition. `BLOCKED` records an honest execution boundary, never permission to assume correctness or count an unexecuted check as `PASS`:
|
|
||||||
|
|
||||||
| Situation | Disposition | Required Action |
|
|
||||||
| :--- | :--- | :--- |
|
|
||||||
| Check executes (`local`, or `live-infra` explicitly authorized by the human owner) and satisfies expected condition | `PASS` | Attach observable proof (command output, HTTP status, DOM measurement, or screenshot). |
|
|
||||||
| Check executes and contradicts expected behavior | `FAIL` | Record reproducible steps and observed vs. expected output. |
|
|
||||||
| Local fixture, seed, or tool setup prevents execution | `BLOCKED (env/fixture)` | Diagnose and repair the local blocker before judging the implementation (distinct from a product bug). |
|
|
||||||
| `live-infra` check requires permissions or infrastructure (host rebuilds, production migrations, privileged network changes) unavailable or not explicitly authorized for this run | `BLOCKED (out-of-bounds)` | Do not fabricate execution or mark `PASS`; preserve the exact command and pass/fail criteria for an authorized operator run or maintenance window. |
|
|
||||||
| Check executes, but available evidence cannot prove or falsify the assertion | `INCONCLUSIVE` | State what signal is missing and how to make the check deterministically falsifiable. |
|
|
||||||
|
|
||||||
### Authority Separation Invariant
|
|
||||||
- `code-review` establishes **static provenance** for a specific revision range and working-tree diff.
|
|
||||||
- `verify-slice` establishes **runtime behavioral evidence** for selected assertions.
|
|
||||||
- Neither substitutes for the other, and neither grants release approval; only the human owner authorizes release.
|
|
||||||
|
|
||||||
### Anti-Rationalization Rules
|
|
||||||
1. **Expected values before observation**: State the exact pass/fail condition before running the check. If an assertion expects `2` and the system shows `1`, record `FAIL`, never `PASS` with a narrative excuse ("targeted reconciliation trade-off").
|
|
||||||
2. **Separate seed/fixture health from product bugs**: Avoid fragile raw SQL test seeds when domain services or API helpers exist; if a fixture mismatches schema reality, mark `BLOCKED` and fix the fixture.
|
|
||||||
3. **Unique provenance**: When comparing author self-audit, black-box QA, and diff review, label whether each confirmed defect was caught by self-audit, black-box execution, or code inspection so process value stays measurable.
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
---
|
||||||
|
name: verify
|
||||||
|
description: >-
|
||||||
|
Run risk-proportional black-box runtime QA, inspect remote CI checks, promote
|
||||||
|
verified GitHub Draft PRs, and execute human-gated merge closeout with
|
||||||
|
Projects v2 board transitions. Use when verifying a ready-reviewed GitHub PR
|
||||||
|
or aborting an abandoned Draft PR. Not for static diff review (use
|
||||||
|
code-review), debugging (use diagnose), or implementation (use implement).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Verify
|
||||||
|
|
||||||
|
## Use when
|
||||||
|
- Verifying a GitHub PR whose latest `code-review` passed with `verdict=ready`.
|
||||||
|
- Promoting a verified Draft PR to ready-for-review and running merge closeout.
|
||||||
|
- Explicitly aborting an abandoned or superseded Draft PR.
|
||||||
|
- Not for static diff review (`code-review`), debugging (`diagnose`), or writing
|
||||||
|
code / managing `todo.txt` state (`implement`).
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
Precondition: an existing open GitHub PR verified via `gh repo view --json url`
|
||||||
|
per [planning-contract.md](../projects/references/planning-contract.md) (no
|
||||||
|
manual PR fallback; route to `implement` if none exists). `verify` has zero
|
||||||
|
`todo.txt` cleanup responsibility (`implement` owns its checkpoint file).
|
||||||
|
|
||||||
|
1. **Phase 1: Read-Only Runtime QA and CI.** Before running QA checks, read
|
||||||
|
[references/qa-dispositions.md](references/qa-dispositions.md). Confirm the
|
||||||
|
latest `cr-review-meta` matches exact current `head_sha` with
|
||||||
|
`verdict=ready`; if missing, stale, or `needs_rework`, halt and route to
|
||||||
|
`code-review`. Execute `RV-*` checks (sized by risk tier) with explicit
|
||||||
|
dispositions (`PASS`, `FAIL`, `BLOCKED (env/fixture)`,
|
||||||
|
`BLOCKED (out-of-bounds)`, `INCONCLUSIVE`), and inspect `gh pr checks`. On
|
||||||
|
red CI, inspect `gh run view --log-failed` and route to `diagnose` or
|
||||||
|
`implement`.
|
||||||
|
2. **Phase 2: Promotion.** Before posting the ledger, promoting, closing out,
|
||||||
|
or aborting, read
|
||||||
|
[references/closeout-and-abort.md](references/closeout-and-abort.md). When
|
||||||
|
Phase 1 passes (zero `FAIL`, zero unresolved `BLOCKED (env/fixture)` or
|
||||||
|
`INCONCLUSIVE`, green CI), post the final Verification Ledger comment,
|
||||||
|
promote the PR (`gh pr ready`), and move the board card
|
||||||
|
`Work in Progress -> Review` per
|
||||||
|
[github-projects-v2.md](../projects/references/github-projects-v2.md).
|
||||||
|
3. **Phase 3: Human Merge Gate and Closeout.** Present the verification packet
|
||||||
|
(static provenance, runtime dispositions, CI, and `Contract Drift` per
|
||||||
|
[pr-and-drift.md](../implement/references/pr-and-drift.md)) for human merge
|
||||||
|
authorization. On approval: merge the PR, execute `Review -> Completed`
|
||||||
|
directly via `issue.projectItems` per
|
||||||
|
[github-projects-v2.md](../projects/references/github-projects-v2.md), and
|
||||||
|
chain `reconcile-docs` + `projects` when `Contract Drift` != `none`. On
|
||||||
|
rejection: run `gh pr ready --undo` and move `Review -> Work in Progress`.
|
||||||
|
4. **Explicit Draft PR Abort (on request only).** Only when explicitly invoked
|
||||||
|
to close an abandoned/superseded Draft PR, skip Steps 1-3 and follow the
|
||||||
|
abort path in
|
||||||
|
[references/closeout-and-abort.md](references/closeout-and-abort.md)
|
||||||
|
(`gh pr close` + revert board card to `Backlog`).
|
||||||
|
|
||||||
|
## Your call
|
||||||
|
- **`live-infra` authorization**: approve before running `live-infra` checks.
|
||||||
|
- **Non-passing checks**: decide repair, fixture fix, or operator window for
|
||||||
|
`FAIL`, `BLOCKED`, or `INCONCLUSIVE` dispositions.
|
||||||
|
- **Merge or abort authorization**: approve/reject merge at Phase 3, or confirm
|
||||||
|
before aborting a Draft PR (`gh pr close` + `Backlog`).
|
||||||
|
|
||||||
|
## Done when
|
||||||
|
- Merged: PR merged, card in `Completed`, and drift handoff emitted if needed.
|
||||||
|
- Rejected/blocked: PR stays Draft, card in `Work in Progress`, handoff stated.
|
||||||
|
- Aborted: Draft PR closed and card reverted to `Backlog`.
|
||||||
|
|
||||||
|
## Hands off to
|
||||||
|
- `code-review`: missing, stale, or `needs_rework` `cr-review-meta` (`Suggested Next Step: /code-review`).
|
||||||
|
- `implement`: QA or CI requires code fixes (`Suggested Next Step: /implement #<issue>`).
|
||||||
|
- `diagnose`: opaque CI or runtime failure (`Suggested Next Step: /diagnose`).
|
||||||
|
- `reconcile-docs` and `projects`: post-merge when `Contract Drift` != `none` (`Suggested Next Step: /reconcile-docs`).
|
||||||
|
- Emit one outcome-matched `Suggested Next Step:` on standalone turns; suppress
|
||||||
|
when delegated per [skeleton.md](../build-skill/references/skeleton.md).
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
# Verification Ledger, Promotion, Closeout, and Abort
|
||||||
|
|
||||||
|
Reference for `verify` Phase 2 (Promotion), Phase 3 (Human Merge Gate and
|
||||||
|
Closeout), human rejection rollback, and explicit Draft PR abort.
|
||||||
|
|
||||||
|
> **Zero `todo.txt` responsibility**: `verify` never reads, edits, or deletes
|
||||||
|
> `todo.txt` or `implement-state` checkpoint files. `implement` solely owns
|
||||||
|
> checkpoint lifecycle and cleanup.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Verification Ledger Comment Template (Phase 2)
|
||||||
|
|
||||||
|
Post one Verification Ledger comment on the PR only after Phase 1 passes
|
||||||
|
(verified `cr-review-meta` `head_sha` + `verdict=ready`, zero `FAIL`, zero
|
||||||
|
unresolved `BLOCKED (env/fixture)` or `INCONCLUSIVE`, and green CI):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gh pr comment <pr-number> --body-file <verification-ledger.md>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Ledger Template
|
||||||
|
```markdown
|
||||||
|
## Verification Ledger
|
||||||
|
|
||||||
|
- **Reviewed Head SHA**: `<head_sha>`
|
||||||
|
- **Static Provenance**: `code-review` (`verdict=ready`)
|
||||||
|
- **Rigor Tier**: `<Lightweight | Standard | High-Assurance>`
|
||||||
|
- **Remote CI (`gh pr checks`)**: `PASS`
|
||||||
|
- **Contract Drift**: `<none | summary from PR body>`
|
||||||
|
|
||||||
|
### Runtime QA Dispositions
|
||||||
|
|
||||||
|
| Check ID | Scope | Disposition | Evidence |
|
||||||
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| `RV-01` | `local` | `PASS` | `<command / observable proof>` |
|
||||||
|
| `RV-02` | `live-infra` | `BLOCKED (out-of-bounds)` | `<preserved command & criteria>` |
|
||||||
|
|
||||||
|
### Notes / Operator Follow-ups
|
||||||
|
- `<None, or list any BLOCKED (out-of-bounds) checks awaiting operator window>`
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Phase 2: Draft PR Promotion (`Work in Progress -> Review`)
|
||||||
|
|
||||||
|
1. Confirm the Verification Ledger comment is posted on `<pr-number>`.
|
||||||
|
2. Promote the Draft PR to ready-for-review:
|
||||||
|
```bash
|
||||||
|
gh pr ready <pr-number>
|
||||||
|
```
|
||||||
|
3. Move the linked issue card `Work in Progress -> Review` using the
|
||||||
|
`issue.projectItems` single-query resolution and `SINGLE_SELECT` mutation in
|
||||||
|
[github-projects-v2.md](../../projects/references/github-projects-v2.md)
|
||||||
|
(Section 4). Confirm the transition ownership matches
|
||||||
|
[planning-contract.md](../../projects/references/planning-contract.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Phase 3: Human Merge Gate and Post-Merge Closeout
|
||||||
|
|
||||||
|
Present the verification packet to the human owner (static provenance, runtime
|
||||||
|
dispositions, CI status, any `BLOCKED (out-of-bounds)` operator items, and the
|
||||||
|
PR body's `Contract Drift` value per
|
||||||
|
[pr-and-drift.md](../../implement/references/pr-and-drift.md)) and wait for
|
||||||
|
explicit merge authorization.
|
||||||
|
|
||||||
|
### 3a. On Human Approval (Merge + `Review -> Completed`)
|
||||||
|
1. Merge the pull request using the repository's configured merge strategy (for
|
||||||
|
example, squash merge):
|
||||||
|
```bash
|
||||||
|
gh pr merge <pr-number> --squash --delete-branch
|
||||||
|
```
|
||||||
|
2. Move the linked issue card `Review -> Completed` directly via
|
||||||
|
`issue.projectItems` per
|
||||||
|
[github-projects-v2.md](../../projects/references/github-projects-v2.md)
|
||||||
|
(Section 4):
|
||||||
|
- Query `issue.projectItems(first: 20)` filtered by
|
||||||
|
`project.number == $project_number` (from `AGENTS.md`).
|
||||||
|
- Resolve `project_id`, `item_id` (`PVTI_...`), `status_field_id`
|
||||||
|
(`PVTSSF_...`), and the `Completed` `option_id`.
|
||||||
|
- Execute `updateProjectV2ItemFieldValue` with
|
||||||
|
`value: { singleSelectOptionId: $completed_option_id }`.
|
||||||
|
3. **Partial-failure idempotency**: If the PR merge succeeds but the Projects v2
|
||||||
|
mutation fails (network/API error), report the partial state clearly.
|
||||||
|
Re-running `verify` Phase 3 board closeout or `projects` reconciliation
|
||||||
|
safely moves the stranded card `Review -> Completed` without re-merging.
|
||||||
|
4. **Contract Drift chaining**: Read the fixed-format `Contract Drift:` line
|
||||||
|
from the PR body per
|
||||||
|
[pr-and-drift.md](../../implement/references/pr-and-drift.md):
|
||||||
|
- If `Contract Drift: none`: closeout is complete; recommend next ready slice
|
||||||
|
via `projects` or `implement` if applicable.
|
||||||
|
- If `Contract Drift` != `none`: chain `reconcile-docs` first to update
|
||||||
|
canonical docs (`ARCHITECTURE.md`, `ROADMAP.md`, `docs/designs/*.md`),
|
||||||
|
followed by `projects` to align downstream issues and milestones.
|
||||||
|
|
||||||
|
### 3b. On Human Rejection Rollback (`Review -> Work in Progress`)
|
||||||
|
If the human owner rejects the merge or requests rework:
|
||||||
|
1. Convert the PR back to Draft:
|
||||||
|
```bash
|
||||||
|
gh pr ready --undo <pr-number>
|
||||||
|
```
|
||||||
|
2. Move the linked issue card `Review -> Work in Progress` via
|
||||||
|
`issue.projectItems` per
|
||||||
|
[github-projects-v2.md](../../projects/references/github-projects-v2.md)
|
||||||
|
(Section 4).
|
||||||
|
3. Record the human owner's requested changes and route back to `implement`
|
||||||
|
(or `code-review` if only review triage is needed).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Abandoned / Superseded Draft PR Abort Path
|
||||||
|
|
||||||
|
> **Explicit invocation only**: Enter this path ONLY when the user explicitly
|
||||||
|
> asks to abort or close an abandoned/superseded Draft PR. Never trigger this
|
||||||
|
> path automatically from a failed Phase 1 check or Phase 3 rejection.
|
||||||
|
|
||||||
|
1. Verify GitHub repository identity via `gh repo view --json url` and confirm
|
||||||
|
the target PR is an open Draft PR (`gh pr view <pr-number> --json state,isDraft,url`).
|
||||||
|
2. Confirm explicit user approval stating the PR to close and the linked issue
|
||||||
|
card that will revert to `Backlog`.
|
||||||
|
3. Close the Draft PR with an explicit reason comment:
|
||||||
|
```bash
|
||||||
|
gh pr close <pr-number> --comment "Closing abandoned/superseded Draft PR: <reason>"
|
||||||
|
```
|
||||||
|
4. Move the linked issue card back to `Backlog` via `issue.projectItems` per
|
||||||
|
[github-projects-v2.md](../../projects/references/github-projects-v2.md)
|
||||||
|
(Section 4).
|
||||||
|
5. Do not touch `todo.txt` or `implement-state` files; if an orphaned branch
|
||||||
|
checkpoint exists locally, `implement` owns its cleanup.
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
# Runtime QA Perspectives, Tiers, and Dispositions
|
||||||
|
|
||||||
|
Reference for `verify` Phase 1 (Read-Only Runtime QA and CI). Keep verification
|
||||||
|
effort proportional to failure consequences and change uncertainty rather than
|
||||||
|
diff line count alone.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Static Provenance Gate (`cr-review-meta` Check)
|
||||||
|
|
||||||
|
Before running runtime checks, confirm that `code-review` has already audited
|
||||||
|
the exact current PR commit with `verdict=ready`:
|
||||||
|
|
||||||
|
1. Fetch the PR's current head commit SHA:
|
||||||
|
```bash
|
||||||
|
gh pr view <pr-number> --json headRefOid,isDraft,url,body
|
||||||
|
```
|
||||||
|
2. Inspect paginated PR reviews for the latest `cr-review-meta` HTML comment:
|
||||||
|
```bash
|
||||||
|
gh api --paginate --slurp repos/{owner}/{repo}/pulls/<pr-number>/reviews \
|
||||||
|
--jq '[add[] | select((.body // "") | contains("cr-review-meta:"))] | last | .body'
|
||||||
|
```
|
||||||
|
Expected marker format:
|
||||||
|
```html
|
||||||
|
<!-- cr-review-meta: max_id=NN head_sha=<sha> verdict=ready|needs_rework -->
|
||||||
|
```
|
||||||
|
3. **Hard Block Rule**:
|
||||||
|
- If `cr-review-meta` is **missing**, halt Phase 1 and route to `code-review`.
|
||||||
|
- If `head_sha` does **not** match `headRefOid` (stale review after new
|
||||||
|
commits), halt Phase 1 and route to `code-review`.
|
||||||
|
- If `verdict` is `needs_rework` (anything other than `ready`), halt Phase 1
|
||||||
|
and route to `code-review` or `implement`.
|
||||||
|
- Never substitute runtime QA for static code review, and never waive a
|
||||||
|
missing or stale `verdict=ready` marker.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Operational Rigor Tiers
|
||||||
|
|
||||||
|
Select the minimum tier matching the slice's risk profile. Escalate individual
|
||||||
|
perspectives whenever a small diff touches a high-risk boundary (for example,
|
||||||
|
a two-line auth, permission, or URL sanitizer change).
|
||||||
|
|
||||||
|
| Tier | Typical Slice | Minimum Required Runtime & CI Checks | Execution Mode |
|
||||||
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| **Lightweight** | Copy updates, styling tweaks, isolated low-risk fixes with no new state or untrusted inputs | 1. Execute `RV-*` checks from the `code-review` body (if present).<br/>2. Run relevant existing automated tests and a targeted smoke/regression check on the touched view or CLI path.<br/>3. Verify `gh pr checks` is green. | Direct execution in current session. |
|
||||||
|
| **Standard** | New UI component, ordinary API integration, or modification to an established workflow | 1. Execute all `RV-*` checks plus falsifiable assertions for every acceptance criterion.<br/>2. Run automated test suite, typecheck, and lint.<br/>3. Verify happy, empty, and error states plus persistence across reload.<br/>4. Run targeted regression checks on shared entrypoints.<br/>5. Verify `gh pr checks` is green. | Direct execution by default. Use an isolated black-box subagent (withholding diff and author self-audit) only if multi-step workflow bias warrants independence. |
|
||||||
|
| **High-Assurance** | Auth, permissions, payments, destructive actions, sensitive data, concurrent/conflict state, or cross-cutting architecture | All `Standard` checks, plus:<br/>1. Explicit conflict, duplicate-submission, and aggregate-state reconciliation assertions.<br/>2. Adversarial input checks against security boundaries.<br/>3. Secondary backend/API reads confirming persisted truth after mutations. | Independent black-box subagent for behavioral scenarios paired with `gh pr checks` verification. |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Selectable Black-Box QA Perspectives
|
||||||
|
|
||||||
|
Select only the perspectives warranted by the slice's risk profile. Convert
|
||||||
|
every selected perspective and every `RV-*` item into concrete falsifiable
|
||||||
|
checks rather than vague instructions ("check security").
|
||||||
|
|
||||||
|
| Perspective | Core Question | Concrete Runtime Checks to Construct |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| **Behavioral & Workflow** | Can the user complete the intended end-to-end task across real states? | Verify each required user journey across loading, empty, error/retry, partial, and success states; confirm state survives reload and matches authoritative backend reads. |
|
||||||
|
| **State & Concurrency** | Do local UI elements, sibling rows, and aggregate counters stay aligned with authoritative state? | Check duplicate-click guards, timeout/retry recovery, and conflict responses (such as `409`); assert that aggregate counters and sibling items reconcile with authoritative server state rather than drifting via partial local heuristics. |
|
||||||
|
| **Security Boundaries** | Can untrusted data execute code, break attributes, or route to unsafe destinations? | Exercise dynamic values across DOM/template and URL sinks with at least one adversarial payload; verify safe escaping, context-appropriate URL validation (`href`/`src`/`action`), and auth/permission enforcement. |
|
||||||
|
| **Ergonomics & Accessibility** | Is the slice usable on narrow screens, with touch, and via keyboard/assistive tech? | Check narrow mobile viewport (`375px`) for overflow, `>= 44x44px` touch targets, sequential keyboard `Tab` focus, visible `:focus-visible` outlines, and `aria-live` announcements for dynamic feedback. |
|
||||||
|
| **Scope & Regression** | Did the slice disturb adjacent features or shared entrypoints? | Run targeted smoke checks on neighboring views, routes, or CLI subcommands that share modified modules, routers, or schemas. |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Falsifiable Check Format & Scope Boundaries
|
||||||
|
|
||||||
|
Every check must declare its exact failure condition and scope before execution.
|
||||||
|
Never use open-ended observational prompts ("run the command and see what
|
||||||
|
happens").
|
||||||
|
|
||||||
|
```text
|
||||||
|
ID: RV-01 (or QA-01)
|
||||||
|
Scope: local | live-infra
|
||||||
|
Command / Action: <exact reproducible command or UI steps>
|
||||||
|
Assertion: PASS if <observable signal>; FAIL if <contradictory signal>
|
||||||
|
```
|
||||||
|
|
||||||
|
### `local` vs. `live-infra` Boundaries
|
||||||
|
- **`local`**: Runs against local builds, unit/integration suites, ephemeral
|
||||||
|
test fixtures, local dev servers, or sandboxed mocks. Execute directly during
|
||||||
|
Phase 1.
|
||||||
|
- **`live-infra`**: Requires privileged access, host rebuilds, production or
|
||||||
|
staging migrations, live external APIs with side effects, or homelab/cloud
|
||||||
|
infrastructure changes.
|
||||||
|
- Execute `live-infra` checks **only** when the human owner has explicitly
|
||||||
|
authorized the target environment and operation.
|
||||||
|
- Without explicit authorization, do **not** fabricate execution or mark
|
||||||
|
`PASS`; record `BLOCKED (out-of-bounds)` and preserve the exact command and
|
||||||
|
`FAIL if ...` criteria for an authorized operator window.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Five-State Disposition Contract
|
||||||
|
|
||||||
|
Every required check ends in exactly one disposition. `BLOCKED` records an
|
||||||
|
honest execution boundary, never permission to assume correctness or count an
|
||||||
|
unexecuted check as `PASS`.
|
||||||
|
|
||||||
|
| Situation | Disposition | Required Action |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| Check executes (`local`, or explicitly authorized `live-infra`) and satisfies the expected condition | `PASS` | Attach observable proof (exit code, command output, HTTP status, DOM measurement, or screenshot). |
|
||||||
|
| Check executes and triggers its `FAIL if ...` condition | `FAIL` | Record reproducible steps and observed vs. expected output; block Phase 2 promotion. |
|
||||||
|
| Local fixture, seed, dependency, or tool setup prevents execution | `BLOCKED (env/fixture)` | Diagnose and repair the local blocker before judging the implementation (distinct from a product bug); block Phase 2 promotion until resolved. |
|
||||||
|
| `live-infra` check requires permissions or infrastructure unavailable or not explicitly authorized for this run | `BLOCKED (out-of-bounds)` | Preserve exact command and `FAIL if ...` criteria for the human owner; surface explicitly in the Phase 3 packet. |
|
||||||
|
| Check executes, but available evidence cannot prove or falsify the assertion | `INCONCLUSIVE` | State what signal is missing and how to make the check deterministically falsifiable; block Phase 2 promotion until resolved or explicitly decided by the human owner. |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Remote CI Inspection (`gh pr checks`)
|
||||||
|
|
||||||
|
1. Inspect remote CI status for the PR:
|
||||||
|
```bash
|
||||||
|
gh pr checks <pr-number>
|
||||||
|
```
|
||||||
|
2. If all required checks pass, record CI as `PASS` in the Verification Ledger.
|
||||||
|
3. If any check is pending, wait or report pending status before Phase 2
|
||||||
|
promotion.
|
||||||
|
4. If any check fails (red CI):
|
||||||
|
- Fetch failed job logs directly:
|
||||||
|
```bash
|
||||||
|
gh run view <run-id> --log-failed
|
||||||
|
```
|
||||||
|
- Block Phase 2 promotion.
|
||||||
|
- Route root-cause investigation of opaque CI failures to `diagnose`, or
|
||||||
|
clear code/test regressions to `implement`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. Authority Separation & Anti-Rationalization Rules
|
||||||
|
|
||||||
|
- **Authority separation**: `code-review` establishes **static provenance** for
|
||||||
|
a specific `head_sha`; `verify` establishes **runtime behavioral and CI
|
||||||
|
evidence**; neither substitutes for the other, and only the human owner
|
||||||
|
authorizes merge/release.
|
||||||
|
- **Expected values before observation**: State the exact `FAIL if ...`
|
||||||
|
condition before running the check. If an assertion expects `2` and the
|
||||||
|
system returns `1`, record `FAIL`, never `PASS` with a narrative excuse.
|
||||||
|
- **Separate fixture health from product bugs**: If a test seed or fixture
|
||||||
|
mismatches schema reality, mark `BLOCKED (env/fixture)` and fix the fixture
|
||||||
|
rather than misclassifying it as a passing check or a product regression.
|
||||||
Vendored
+9
-7
@@ -18,16 +18,18 @@ echo "--- [1/3] Verifying Skills Installation & Symlinks ---"
|
|||||||
# 2. Run Python deterministic behavioral contracts suite
|
# 2. Run Python deterministic behavioral contracts suite
|
||||||
echo
|
echo
|
||||||
echo "--- [2/3] Running Behavioral Contract & Invariant Tests ---"
|
echo "--- [2/3] Running Behavioral Contract & Invariant Tests ---"
|
||||||
python3 "${SCRIPT_DIR}/test_skills_behavioral_contracts.py" -v
|
python3 -m unittest "${SCRIPT_DIR}/test_skills_behavioral_contracts.py" "${SCRIPT_DIR}/test_build_review.py" -v
|
||||||
|
|
||||||
# 3. Qualitative Dogfood Protocol Verification
|
# 3. Qualitative Dogfood Protocol Verification
|
||||||
echo
|
echo
|
||||||
echo "--- [3/3] Validating Clean-Room Reproducibility & Deviation Protocol ---"
|
echo "--- [3/3] Validating Clean-Room Reproducibility & Contract Protocols ---"
|
||||||
# Verify that gitea-plan references clean-room audit schema
|
# Verify that projects references clean-room audit schema
|
||||||
grep -q "Independent Zero-Context Reproducibility Audit" "${REPO_ROOT}/skills/gitea-plan/references/decomposition-tiers.md"
|
grep -q "Independent Zero-Context Reproducibility Audit" "${REPO_ROOT}/skills/projects/references/tiers-and-audit.md"
|
||||||
grep -q "Auditor Report Schema" "${REPO_ROOT}/skills/gitea-plan/references/decomposition-tiers.md"
|
grep -q "Auditor Report Schema" "${REPO_ROOT}/skills/projects/references/tiers-and-audit.md"
|
||||||
# Verify that implement-slice defines tripartite schema
|
# Verify that implement defines preflight working-tree classification
|
||||||
grep -q "The Tripartite Workflow Contract Schemas" "${REPO_ROOT}/skills/implement-slice/references/handoff-contracts.md"
|
grep -q "CLEAN_BASE" "${REPO_ROOT}/skills/implement/references/preflight.md"
|
||||||
|
# Verify that code-review defines cr-review-meta provenance marker
|
||||||
|
grep -q "cr-review-meta" "${REPO_ROOT}/skills/code-review/references/finding-schema.md"
|
||||||
# Verify that gt-usage defines project column move recipe
|
# Verify that gt-usage defines project column move recipe
|
||||||
grep -q "Move issue card between columns" "${REPO_ROOT}/skills/gt-usage/references/commands.md"
|
grep -q "Move issue card between columns" "${REPO_ROOT}/skills/gt-usage/references/commands.md"
|
||||||
|
|
||||||
|
|||||||
Vendored
+551
@@ -0,0 +1,551 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Unit tests for skills/code-review/scripts/build_review.py.
|
||||||
|
|
||||||
|
Covers:
|
||||||
|
1. --paginate --slurp JSON flattening ([[...]] and [...]) for --reviews and --comments
|
||||||
|
2. Unified diff hunk parsing and validation (LEFT deleted, RIGHT added/modified/context)
|
||||||
|
3. Out-of-hunk, missing-file, and cross-file findings routed to review body
|
||||||
|
4. Monotonic max_id extraction from cr-review-meta and ### CR-NN headings across reviews/comments
|
||||||
|
5. Collapsible RV-* block from rv_checks[] and Triage Summary from triage_closures[]
|
||||||
|
6. Duplicate (head_sha, verdict) exits 2; ready superseding needs_rework on same head_sha exits 0
|
||||||
|
7. 3-rework-cycle cap exits 1 on 4th needs_rework, allows ready
|
||||||
|
8. Invalid JSON, invalid verdict, and missing required fields exit 1
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
REPO_ROOT = Path(__file__).resolve().parent.parent.parent
|
||||||
|
SCRIPT = REPO_ROOT / "skills" / "code-review" / "scripts" / "build_review.py"
|
||||||
|
|
||||||
|
SAMPLE_DIFF = """diff --git a/src/app.py b/src/app.py
|
||||||
|
index 1111111..2222222 100644
|
||||||
|
--- a/src/app.py
|
||||||
|
+++ b/src/app.py
|
||||||
|
@@ -10,4 +10,5 @@ def process(data):
|
||||||
|
x = 1
|
||||||
|
- old_call(data)
|
||||||
|
+ new_call(data)
|
||||||
|
+ extra_check(data)
|
||||||
|
return x
|
||||||
|
diff --git a/src/removed.py b/src/removed.py
|
||||||
|
deleted file mode 100644
|
||||||
|
index 3333333..0000000
|
||||||
|
--- a/src/removed.py
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,2 +0,0 @@
|
||||||
|
-def legacy():
|
||||||
|
- return 0
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class TestBuildReview(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self._tmp = tempfile.TemporaryDirectory()
|
||||||
|
self.tmp = Path(self._tmp.name)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self._tmp.cleanup()
|
||||||
|
|
||||||
|
def _write_file(self, name, content):
|
||||||
|
path = self.tmp / name
|
||||||
|
if isinstance(content, str):
|
||||||
|
path.write_text(content, encoding="utf-8")
|
||||||
|
else:
|
||||||
|
path.write_text(json.dumps(content), encoding="utf-8")
|
||||||
|
return path
|
||||||
|
|
||||||
|
def _run(self, input_data, diff_text=SAMPLE_DIFF, reviews=None, comments=None,
|
||||||
|
head_sha="abc1234def5678", verdict="needs_rework"):
|
||||||
|
input_path = self._write_file("input.json", input_data)
|
||||||
|
diff_path = self._write_file("pr.diff", diff_text)
|
||||||
|
reviews_path = self._write_file("reviews.json", [] if reviews is None else reviews)
|
||||||
|
comments_path = self._write_file("comments.json", [] if comments is None else comments)
|
||||||
|
return subprocess.run(
|
||||||
|
[
|
||||||
|
sys.executable,
|
||||||
|
str(SCRIPT),
|
||||||
|
"--input", str(input_path),
|
||||||
|
"--diff", str(diff_path),
|
||||||
|
"--reviews", str(reviews_path),
|
||||||
|
"--comments", str(comments_path),
|
||||||
|
"--head-sha", head_sha,
|
||||||
|
"--verdict", verdict,
|
||||||
|
],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_valid_anchored_left_and_right_findings_emit_inline_comments(self):
|
||||||
|
payload_in = {
|
||||||
|
"findings": [
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": 11,
|
||||||
|
"side": "LEFT",
|
||||||
|
"severity": "High",
|
||||||
|
"axis": "Defensive Invariants",
|
||||||
|
"title": "Deleted validation call",
|
||||||
|
"body": "Removing old_call drops input validation.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": 12,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Medium",
|
||||||
|
"title": "Unbounded check",
|
||||||
|
"body": "extra_check lacks timeout.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": 10,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Low",
|
||||||
|
"title": "Context line anchor",
|
||||||
|
"body": "Context line inside hunk is valid on RIGHT.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/removed.py",
|
||||||
|
"line": 1,
|
||||||
|
"side": "LEFT",
|
||||||
|
"severity": "Medium",
|
||||||
|
"title": "Deleted file line anchor",
|
||||||
|
"body": "Deleted file line 1 is valid on LEFT.",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
res = self._run(payload_in, head_sha="deadbeef0011", verdict="needs_rework")
|
||||||
|
self.assertEqual(res.returncode, 0, res.stderr)
|
||||||
|
out = json.loads(res.stdout)
|
||||||
|
self.assertEqual(out["commit_id"], "deadbeef0011")
|
||||||
|
self.assertEqual(out["event"], "COMMENT")
|
||||||
|
self.assertEqual(len(out["comments"]), 4)
|
||||||
|
self.assertEqual(out["comments"][0]["path"], "src/app.py")
|
||||||
|
self.assertEqual(out["comments"][0]["line"], 11)
|
||||||
|
self.assertEqual(out["comments"][0]["side"], "LEFT")
|
||||||
|
self.assertTrue(out["comments"][0]["body"].startswith("### CR-01:"))
|
||||||
|
self.assertEqual(out["comments"][1]["side"], "RIGHT")
|
||||||
|
self.assertTrue(out["comments"][1]["body"].startswith("### CR-02:"))
|
||||||
|
self.assertTrue(out["comments"][2]["body"].startswith("### CR-03:"))
|
||||||
|
self.assertEqual(out["comments"][3]["path"], "src/removed.py")
|
||||||
|
self.assertEqual(out["comments"][3]["side"], "LEFT")
|
||||||
|
self.assertTrue(out["comments"][3]["body"].startswith("### CR-04:"))
|
||||||
|
self.assertNotIn("### Findings (Unanchored / Cross-File)", out["body"])
|
||||||
|
self.assertIn(
|
||||||
|
"<!-- cr-review-meta: max_id=04 head_sha=deadbeef0011 verdict=needs_rework -->",
|
||||||
|
out["body"],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_unanchored_out_of_hunk_missing_file_and_cross_file_move_to_body(self):
|
||||||
|
payload_in = {
|
||||||
|
"findings": [
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": 99,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Medium",
|
||||||
|
"title": "Out of hunk line",
|
||||||
|
"body": "Line 99 is not in diff hunk.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": 10,
|
||||||
|
"side": "LEFT",
|
||||||
|
"severity": "Low",
|
||||||
|
"title": "Context line on LEFT rejected",
|
||||||
|
"body": "Context line is not a deleted line on LEFT.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/nonexistent.py",
|
||||||
|
"line": 5,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "High",
|
||||||
|
"title": "Missing file",
|
||||||
|
"body": "File is not in diff.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": None,
|
||||||
|
"line": None,
|
||||||
|
"side": None,
|
||||||
|
"severity": "High",
|
||||||
|
"title": "Cross-file architectural drift",
|
||||||
|
"body": "Multiple modules violate layering.",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
res = self._run(payload_in, head_sha="aaaa1111", verdict="needs_rework")
|
||||||
|
self.assertEqual(res.returncode, 0, res.stderr)
|
||||||
|
out = json.loads(res.stdout)
|
||||||
|
self.assertEqual(out["comments"], [])
|
||||||
|
self.assertIn("### Findings (Unanchored / Cross-File)", out["body"])
|
||||||
|
for idx in ("### CR-01:", "### CR-02:", "### CR-03:", "### CR-04:"):
|
||||||
|
self.assertIn(idx, out["body"])
|
||||||
|
self.assertIn("<!-- cr-review-meta: max_id=04 head_sha=aaaa1111 verdict=needs_rework -->", out["body"])
|
||||||
|
|
||||||
|
def test_slurp_and_flat_pagination_monotonic_max_id_and_three_digit_rollover(self):
|
||||||
|
# Slurped nested pages for reviews: [[...], [...]]
|
||||||
|
slurped_reviews = [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"body": "Prior review\n<!-- cr-review-meta: max_id=05 head_sha=oldsha1 verdict=needs_rework -->"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"body": "### Findings (Unanchored / Cross-File)\n### CR-98: Old unanchored\nBody"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
]
|
||||||
|
# Flat list for comments with CR-99
|
||||||
|
flat_comments = [
|
||||||
|
{"body": "### CR-99: Inline finding\nDetails"}
|
||||||
|
]
|
||||||
|
payload_in = {
|
||||||
|
"findings": [
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": 11,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Medium",
|
||||||
|
"title": "Hundredth finding",
|
||||||
|
"body": "Should roll over to CR-100.",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
res = self._run(
|
||||||
|
payload_in,
|
||||||
|
reviews=slurped_reviews,
|
||||||
|
comments=flat_comments,
|
||||||
|
head_sha="newsha99",
|
||||||
|
verdict="needs_rework",
|
||||||
|
)
|
||||||
|
self.assertEqual(res.returncode, 0, res.stderr)
|
||||||
|
out = json.loads(res.stdout)
|
||||||
|
self.assertEqual(len(out["comments"]), 1)
|
||||||
|
self.assertTrue(out["comments"][0]["body"].startswith("### CR-100:"))
|
||||||
|
self.assertIn(
|
||||||
|
"<!-- cr-review-meta: max_id=100 head_sha=newsha99 verdict=needs_rework -->",
|
||||||
|
out["body"],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_slurped_comments_also_flattened(self):
|
||||||
|
slurped_comments = [
|
||||||
|
[{"body": "### CR-03: First\nDetails"}],
|
||||||
|
[{"body": "### CR-07: Seventh\nDetails"}],
|
||||||
|
]
|
||||||
|
payload_in = {
|
||||||
|
"findings": [
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": 11,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Low",
|
||||||
|
"title": "Next finding",
|
||||||
|
"body": "Should be CR-08.",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
res = self._run(
|
||||||
|
payload_in,
|
||||||
|
reviews=[[]],
|
||||||
|
comments=slurped_comments,
|
||||||
|
head_sha="sha0008",
|
||||||
|
verdict="needs_rework",
|
||||||
|
)
|
||||||
|
self.assertEqual(res.returncode, 0, res.stderr)
|
||||||
|
out = json.loads(res.stdout)
|
||||||
|
self.assertTrue(out["comments"][0]["body"].startswith("### CR-08:"))
|
||||||
|
|
||||||
|
def test_rv_checks_collapsible_block_and_triage_closures_summary(self):
|
||||||
|
payload_in = {
|
||||||
|
"findings": [],
|
||||||
|
"rv_checks": [
|
||||||
|
{
|
||||||
|
"id": "RV-01",
|
||||||
|
"purpose": "Concurrent submission returns 409",
|
||||||
|
"scope": "local",
|
||||||
|
"pass_condition": "HTTP 409 returned",
|
||||||
|
"fail_signal": "FAIL if HTTP 200 or 500",
|
||||||
|
"command": "./scripts/check_conflict.sh",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"triage_closures": [
|
||||||
|
{"id": "CR-01", "exit": "B", "resolution": "Promoted to #45"},
|
||||||
|
{"id": "CR-02", "exit": "C", "resolution": "Dismissed: false positive on fixture"},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
prior_reviews = [
|
||||||
|
{
|
||||||
|
"body": "Prior\n<!-- cr-review-meta: max_id=02 head_sha=sha_same verdict=needs_rework -->"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
# ready superseding needs_rework on same head_sha must exit 0
|
||||||
|
res = self._run(
|
||||||
|
payload_in,
|
||||||
|
reviews=prior_reviews,
|
||||||
|
head_sha="sha_same",
|
||||||
|
verdict="ready",
|
||||||
|
)
|
||||||
|
self.assertEqual(res.returncode, 0, res.stderr)
|
||||||
|
out = json.loads(res.stdout)
|
||||||
|
self.assertEqual(out["comments"], [])
|
||||||
|
self.assertIn("<details>", out["body"])
|
||||||
|
self.assertIn("RV-01", out["body"])
|
||||||
|
self.assertIn("./scripts/check_conflict.sh", out["body"])
|
||||||
|
self.assertIn("FAIL if HTTP 200 or 500", out["body"])
|
||||||
|
self.assertIn("### Triage Summary", out["body"])
|
||||||
|
self.assertIn("CR-01", out["body"])
|
||||||
|
self.assertIn("Promoted to #45", out["body"])
|
||||||
|
self.assertIn("Dismissed: false positive on fixture", out["body"])
|
||||||
|
self.assertIn(
|
||||||
|
"<!-- cr-review-meta: max_id=02 head_sha=sha_same verdict=ready -->",
|
||||||
|
out["body"],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_duplicate_head_sha_and_verdict_exits_2_with_empty_stdout(self):
|
||||||
|
prior_reviews = [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"body": "Already reviewed\n<!-- cr-review-meta: max_id=01 head_sha=dup1234 verdict=ready -->"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
res = self._run({"findings": []}, reviews=prior_reviews, head_sha="dup1234", verdict="ready")
|
||||||
|
self.assertEqual(res.returncode, 2)
|
||||||
|
self.assertEqual(res.stdout.strip(), "")
|
||||||
|
self.assertIn("duplicate", res.stderr.lower())
|
||||||
|
|
||||||
|
def test_rework_cycle_cap_allows_third_needs_rework(self):
|
||||||
|
prior_reviews = [
|
||||||
|
{"body": "<!-- cr-review-meta: max_id=01 head_sha=sha1 verdict=needs_rework -->"},
|
||||||
|
{"body": "<!-- cr-review-meta: max_id=02 head_sha=sha2 verdict=needs_rework -->"},
|
||||||
|
]
|
||||||
|
res = self._run(
|
||||||
|
{"findings": []},
|
||||||
|
reviews=prior_reviews,
|
||||||
|
head_sha="sha3",
|
||||||
|
verdict="needs_rework",
|
||||||
|
)
|
||||||
|
self.assertEqual(res.returncode, 0, res.stderr)
|
||||||
|
out = json.loads(res.stdout)
|
||||||
|
self.assertIn("<!-- cr-review-meta: max_id=02 head_sha=sha3 verdict=needs_rework -->", out["body"])
|
||||||
|
|
||||||
|
def test_rework_cycle_cap_blocks_fourth_needs_rework(self):
|
||||||
|
prior_reviews = [
|
||||||
|
{"body": "<!-- cr-review-meta: max_id=01 head_sha=sha1 verdict=needs_rework -->"},
|
||||||
|
{"body": "<!-- cr-review-meta: max_id=02 head_sha=sha2 verdict=needs_rework -->"},
|
||||||
|
{"body": "<!-- cr-review-meta: max_id=03 head_sha=sha3 verdict=needs_rework -->"},
|
||||||
|
]
|
||||||
|
res_blocked = self._run(
|
||||||
|
{"findings": []},
|
||||||
|
reviews=prior_reviews,
|
||||||
|
head_sha="sha4",
|
||||||
|
verdict="needs_rework",
|
||||||
|
)
|
||||||
|
self.assertEqual(res_blocked.returncode, 1)
|
||||||
|
self.assertEqual(res_blocked.stdout.strip(), "")
|
||||||
|
self.assertIn("3-rework-cycle cap", res_blocked.stderr.lower())
|
||||||
|
|
||||||
|
def test_rework_cycle_cap_allows_ready_after_three_reworks(self):
|
||||||
|
prior_reviews = [
|
||||||
|
{"body": "<!-- cr-review-meta: max_id=01 head_sha=sha1 verdict=needs_rework -->"},
|
||||||
|
{"body": "<!-- cr-review-meta: max_id=02 head_sha=sha2 verdict=needs_rework -->"},
|
||||||
|
{"body": "<!-- cr-review-meta: max_id=03 head_sha=sha3 verdict=needs_rework -->"},
|
||||||
|
]
|
||||||
|
res_ready = self._run(
|
||||||
|
{"findings": []},
|
||||||
|
reviews=prior_reviews,
|
||||||
|
head_sha="sha4",
|
||||||
|
verdict="ready",
|
||||||
|
)
|
||||||
|
self.assertEqual(res_ready.returncode, 0, res_ready.stderr)
|
||||||
|
out = json.loads(res_ready.stdout)
|
||||||
|
self.assertIn("<!-- cr-review-meta: max_id=03 head_sha=sha4 verdict=ready -->", out["body"])
|
||||||
|
|
||||||
|
def test_triage_closure_null_id_defaults_to_placeholder(self):
|
||||||
|
res = self._run(
|
||||||
|
{
|
||||||
|
"findings": [],
|
||||||
|
"triage_closures": [
|
||||||
|
{"id": None, "exit": "C", "resolution": "Dismissed: false positive"}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
head_sha="nullid1",
|
||||||
|
verdict="ready",
|
||||||
|
)
|
||||||
|
self.assertEqual(res.returncode, 0, res.stderr)
|
||||||
|
out = json.loads(res.stdout)
|
||||||
|
self.assertIn("**CR-??**", out["body"])
|
||||||
|
self.assertNotIn("**None**", out["body"])
|
||||||
|
|
||||||
|
def test_invalid_inputs_exit_1(self):
|
||||||
|
cases = [
|
||||||
|
("invalid_json", "{not valid json", "needs_rework"),
|
||||||
|
("invalid_verdict", {"findings": []}, "approved"),
|
||||||
|
("missing_findings_key", {"rv_checks": []}, "needs_rework"),
|
||||||
|
("missing_title", {"findings": [{"severity": "High", "body": "Missing title"}]}, "needs_rework"),
|
||||||
|
(
|
||||||
|
"invalid_side",
|
||||||
|
{
|
||||||
|
"findings": [
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": 11,
|
||||||
|
"side": "CENTER",
|
||||||
|
"severity": "Low",
|
||||||
|
"title": "Bad side",
|
||||||
|
"body": "Invalid side enum.",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"needs_rework",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"non_positive_line_zero",
|
||||||
|
{
|
||||||
|
"findings": [
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": 0,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Low",
|
||||||
|
"title": "Zero line",
|
||||||
|
"body": "Line 0 is invalid.",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"needs_rework",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"boolean_line",
|
||||||
|
{
|
||||||
|
"findings": [
|
||||||
|
{
|
||||||
|
"path": "src/app.py",
|
||||||
|
"line": True,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Low",
|
||||||
|
"title": "Bool line",
|
||||||
|
"body": "Boolean line is invalid.",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"needs_rework",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
for label, payload, verdict in cases:
|
||||||
|
with self.subTest(case=label):
|
||||||
|
res = self._run(payload, verdict=verdict)
|
||||||
|
self.assertEqual(res.returncode, 1, res.stderr)
|
||||||
|
|
||||||
|
def test_new_file_multi_hunk_and_empty_diff_handling(self):
|
||||||
|
new_and_multi_hunk_diff = """diff --git a/src/brand_new.py b/src/brand_new.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..1111111
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/brand_new.py
|
||||||
|
@@ -0,0 +1,3 @@
|
||||||
|
+def greet(name):
|
||||||
|
+ return f"hi {name}"
|
||||||
|
+
|
||||||
|
diff --git a/src/multi.py b/src/multi.py
|
||||||
|
index 1111111..2222222 100644
|
||||||
|
--- a/src/multi.py
|
||||||
|
+++ b/src/multi.py
|
||||||
|
@@ -2,3 +2,4 @@ def first():
|
||||||
|
a = 1
|
||||||
|
+ b = 2
|
||||||
|
return a
|
||||||
|
@@ -20,3 +21,4 @@ def second():
|
||||||
|
c = 3
|
||||||
|
+ d = 4
|
||||||
|
return c
|
||||||
|
"""
|
||||||
|
payload_in = {
|
||||||
|
"findings": [
|
||||||
|
{
|
||||||
|
"path": "src/brand_new.py",
|
||||||
|
"line": 2,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Medium",
|
||||||
|
"title": "New file anchor",
|
||||||
|
"body": "Newly added file line 2 anchors on RIGHT.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/multi.py",
|
||||||
|
"line": 3,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Low",
|
||||||
|
"title": "First hunk anchor",
|
||||||
|
"body": "Added line in hunk 1 anchors on RIGHT.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/multi.py",
|
||||||
|
"line": 22,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Low",
|
||||||
|
"title": "Second hunk anchor",
|
||||||
|
"body": "Added line in hunk 2 anchors on RIGHT.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/multi.py",
|
||||||
|
"line": 12,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "Medium",
|
||||||
|
"title": "Gap between hunks",
|
||||||
|
"body": "Line 12 lies between hunks and must move to body.",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
res = self._run(
|
||||||
|
payload_in,
|
||||||
|
diff_text=new_and_multi_hunk_diff,
|
||||||
|
head_sha="multi1234",
|
||||||
|
verdict="needs_rework",
|
||||||
|
)
|
||||||
|
self.assertEqual(res.returncode, 0, res.stderr)
|
||||||
|
out = json.loads(res.stdout)
|
||||||
|
self.assertEqual(len(out["comments"]), 3)
|
||||||
|
self.assertEqual(
|
||||||
|
[(c["path"], c["line"], c["side"]) for c in out["comments"]],
|
||||||
|
[
|
||||||
|
("src/brand_new.py", 2, "RIGHT"),
|
||||||
|
("src/multi.py", 3, "RIGHT"),
|
||||||
|
("src/multi.py", 22, "RIGHT"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
self.assertIn("### Findings (Unanchored / Cross-File)", out["body"])
|
||||||
|
self.assertIn("### CR-04: Gap between hunks", out["body"])
|
||||||
|
|
||||||
|
# Empty diff routes all findings to body
|
||||||
|
empty_res = self._run(
|
||||||
|
{
|
||||||
|
"findings": [
|
||||||
|
{
|
||||||
|
"path": "src/brand_new.py",
|
||||||
|
"line": 2,
|
||||||
|
"side": "RIGHT",
|
||||||
|
"severity": "High",
|
||||||
|
"title": "Unanchored on empty diff",
|
||||||
|
"body": "Cannot anchor when diff is empty.",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
diff_text="",
|
||||||
|
head_sha="empty0000",
|
||||||
|
verdict="needs_rework",
|
||||||
|
)
|
||||||
|
self.assertEqual(empty_res.returncode, 0, empty_res.stderr)
|
||||||
|
empty_out = json.loads(empty_res.stdout)
|
||||||
|
self.assertEqual(empty_out["comments"], [])
|
||||||
|
self.assertIn("### Findings (Unanchored / Cross-File)", empty_out["body"])
|
||||||
|
self.assertIn("### CR-01: Unanchored on empty diff", empty_out["body"])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
+398
-409
@@ -4,25 +4,21 @@ test_skills_behavioral_contracts.py
|
|||||||
Deterministic behavioral contract test suite for kiskaadee/skills.
|
Deterministic behavioral contract test suite for kiskaadee/skills.
|
||||||
|
|
||||||
Verifies:
|
Verifies:
|
||||||
1. Prerequisite guidance on missing gt binary
|
1. Anti-hallucination resource ID querying rules (projects dynamic GraphQL/REST + gt-usage --json)
|
||||||
2. Anti-hallucination resource ID querying rules
|
2. Review comment publishing ownership (code-review via build_review.py; implement read-only on reviews)
|
||||||
3. Proportionality scaling (lightweight docs vs standard code)
|
3. Project board 5-column reconciliation, fixed GitHub color enums, and transition ownership
|
||||||
4. Feature verification canonical node 5-tuples and dynamic Mermaid projection
|
4. reconcile-docs read-only GitHub ingestion and bidirectional hooks with projects / implement
|
||||||
5. Security invariant verification seams
|
5. Repo-scoped documentation boundaries and vault deprecation
|
||||||
6. Rework routing and execution record transitions
|
6. Polyglot TDD hardening (Mode A/B, 5 languages, 5 empirical invariants) and code-review Axis 3 binding
|
||||||
7. Deviation reporting on skipped checks
|
7. Suggested Next Step soft-chaining and delegated footer suppression
|
||||||
8. Strict dry-run zero-mutation invariants
|
8. Subagent provenance output-slot guards for High-Assurance code-review and projects reproducibility audit
|
||||||
9. Skill inventory, line count (<= 80), em-dash absence, and path portability
|
9. Core GitHub delivery skill contracts (projects, implement, code-review, verify)
|
||||||
10. Review comment publishing ownership (code-review drafts, gitea-pr posts with guards)
|
10. Isolated install.sh check exit codes and repo-scoped dangling-symlink pruning
|
||||||
11. Project board 5-column reconciliation, semantic hex colors, and transition ownership
|
11. Skill inventory, line count (<= 80), em-dash absence, and path portability
|
||||||
12. reconcile-docs read-only Gitea ingestion and bidirectional hooks with gitea-plan / implement-slice
|
|
||||||
13. Polyglot TDD hardening (Mode A/B, 5 languages, 5 empirical invariants), code-review Axis 3 binding, and Suggested Next Step soft-chaining
|
|
||||||
14. Subagent provenance output-slot guards for High-Assurance code-review and gitea-plan reproducibility audit
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
@@ -30,7 +26,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
REPO_ROOT = Path(__file__).resolve().parent.parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent.parent
|
||||||
|
|
||||||
# Canonical Active Portable Skills list from install.sh
|
# Canonical Active Portable Skills list from install.sh (sorted)
|
||||||
EXPECTED_SKILLS = [
|
EXPECTED_SKILLS = [
|
||||||
"build-skill",
|
"build-skill",
|
||||||
"code-review",
|
"code-review",
|
||||||
@@ -38,451 +34,173 @@ EXPECTED_SKILLS = [
|
|||||||
"diagnose",
|
"diagnose",
|
||||||
"document",
|
"document",
|
||||||
"git-manager",
|
"git-manager",
|
||||||
"gitea-plan",
|
"gitea-to-github",
|
||||||
"gitea-pr",
|
|
||||||
"gt-usage",
|
"gt-usage",
|
||||||
"implement-slice",
|
"implement",
|
||||||
"inspect-flake-update",
|
"inspect-flake-update",
|
||||||
"nix-devshell",
|
"nix-devshell",
|
||||||
"practice",
|
"practice",
|
||||||
|
"projects",
|
||||||
"reconcile-docs",
|
"reconcile-docs",
|
||||||
"tdd",
|
"tdd",
|
||||||
|
"verify",
|
||||||
|
]
|
||||||
|
|
||||||
|
RETIRED_LEGACY_SKILLS = [
|
||||||
|
"gitea-plan",
|
||||||
|
"gitea-pr",
|
||||||
|
"implement-slice",
|
||||||
"verify-slice",
|
"verify-slice",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class WorkflowNode:
|
|
||||||
"""Canonical 5-tuple workflow node."""
|
|
||||||
def __init__(self, node_id, claim, method, executor, pass_condition, failure_route=None):
|
|
||||||
self.node_id = node_id
|
|
||||||
self.claim = claim
|
|
||||||
self.method = method
|
|
||||||
self.executor = executor
|
|
||||||
self.pass_condition = pass_condition
|
|
||||||
self.failure_route = failure_route
|
|
||||||
self.status = "planned"
|
|
||||||
self.evidence = None
|
|
||||||
|
|
||||||
def validate_schema(self):
|
|
||||||
assert re.match(r"^[A-Z0-9_-]+$", self.node_id), f"Invalid node_id: {self.node_id}"
|
|
||||||
assert self.claim and isinstance(self.claim, str), "claim must be non-empty string"
|
|
||||||
assert self.method and isinstance(self.method, str), "method must be non-empty string"
|
|
||||||
assert self.executor in [
|
|
||||||
"Implementation Worker",
|
|
||||||
"Independent QA Subagent",
|
|
||||||
"Reviewer Subagent",
|
|
||||||
"Human Owner",
|
|
||||||
"Orchestrator",
|
|
||||||
], f"Invalid executor: {self.executor}"
|
|
||||||
assert self.pass_condition and isinstance(self.pass_condition, str), "pass_condition must be non-empty string"
|
|
||||||
|
|
||||||
def to_dict(self):
|
|
||||||
return {
|
|
||||||
"node_id": self.node_id,
|
|
||||||
"claim": self.claim,
|
|
||||||
"method": self.method,
|
|
||||||
"executor": self.executor,
|
|
||||||
"pass_condition": self.pass_condition,
|
|
||||||
"status": self.status,
|
|
||||||
"evidence": self.evidence,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowEngine:
|
|
||||||
"""
|
|
||||||
Reference model of implement-slice adaptive workflow generator.
|
|
||||||
Encodes rules from orchestration-tiers.md and handoff-contracts.md.
|
|
||||||
"""
|
|
||||||
@staticmethod
|
|
||||||
def plan_slice(title, scope_files, is_security_sensitive=False, is_dry_run=False):
|
|
||||||
nodes = []
|
|
||||||
is_doc_only = all(f.endswith(".md") or f.endswith(".txt") for f in scope_files)
|
|
||||||
|
|
||||||
if is_doc_only:
|
|
||||||
# Proportionality: Lightweight tier
|
|
||||||
nodes.append(WorkflowNode(
|
|
||||||
node_id="TASK-DOC-01",
|
|
||||||
claim=f"Author documentation updates for {title}",
|
|
||||||
method="text editor",
|
|
||||||
executor="Implementation Worker",
|
|
||||||
pass_condition="Files updated matching scope and clean diff",
|
|
||||||
))
|
|
||||||
nodes.append(WorkflowNode(
|
|
||||||
node_id="CHK-FORMAT",
|
|
||||||
claim="Documentation formatting conforms to line caps and style",
|
|
||||||
method="wc -l && grep checks",
|
|
||||||
executor="Implementation Worker",
|
|
||||||
pass_condition="Exit code 0",
|
|
||||||
failure_route="rework in-place",
|
|
||||||
))
|
|
||||||
else:
|
|
||||||
# Standard / High-Assurance tier
|
|
||||||
nodes.append(WorkflowNode(
|
|
||||||
node_id="TASK-IMPL-01",
|
|
||||||
claim=f"Implement core logic for {title}",
|
|
||||||
method="editor & compiler",
|
|
||||||
executor="Implementation Worker",
|
|
||||||
pass_condition="Clean working tree and coherent checkpoint commit",
|
|
||||||
))
|
|
||||||
nodes.append(WorkflowNode(
|
|
||||||
node_id="CHK-UNIT-01",
|
|
||||||
claim="Unit and seam test suites pass",
|
|
||||||
method="test harness",
|
|
||||||
executor="Independent QA Subagent",
|
|
||||||
pass_condition="Exit code 0, 100% assertions green",
|
|
||||||
failure_route="route to existing worker session",
|
|
||||||
))
|
|
||||||
if is_security_sensitive:
|
|
||||||
nodes.append(WorkflowNode(
|
|
||||||
node_id="CHK-SEC-01",
|
|
||||||
claim="Defensive invariants hold: zero cleartext secrets and strict permissions",
|
|
||||||
method="secret scan and stat -c '%a'",
|
|
||||||
executor="Independent QA Subagent",
|
|
||||||
pass_condition="Zero matches for secrets, permissions 0600",
|
|
||||||
failure_route="block commit, sanitize diff",
|
|
||||||
))
|
|
||||||
nodes.append(WorkflowNode(
|
|
||||||
node_id="GATE-REVIEW",
|
|
||||||
claim="Final HEAD 4-axis static and strategic review passed",
|
|
||||||
method="code-review",
|
|
||||||
executor="Reviewer Subagent",
|
|
||||||
pass_condition="Ready disposition matching exact final HEAD",
|
|
||||||
failure_route="rework review comments",
|
|
||||||
))
|
|
||||||
|
|
||||||
mermaid_graph = WorkflowEngine.project_mermaid(nodes)
|
|
||||||
return {
|
|
||||||
"title": title,
|
|
||||||
"is_doc_only": is_doc_only,
|
|
||||||
"is_dry_run": is_dry_run,
|
|
||||||
"nodes": nodes,
|
|
||||||
"mermaid": mermaid_graph,
|
|
||||||
}
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def project_mermaid(nodes):
|
|
||||||
lines = ["flowchart TD"]
|
|
||||||
for node in nodes:
|
|
||||||
lines.append(f' {node.node_id}["{node.node_id}: {node.claim}"]')
|
|
||||||
# Add sequence edges and explicit failure/rework edges
|
|
||||||
for i in range(len(nodes) - 1):
|
|
||||||
lines.append(f" {nodes[i].node_id} --> {nodes[i+1].node_id}")
|
|
||||||
if nodes[i+1].failure_route:
|
|
||||||
lines.append(f' {nodes[i+1].node_id} -.->|Fail / Rework| {nodes[0].node_id}')
|
|
||||||
return "\n".join(lines)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def generate_deviation_report(nodes):
|
|
||||||
skipped = [n for n in nodes if n.status == "skipped"]
|
|
||||||
rework = [n for n in nodes if n.status == "failed"]
|
|
||||||
return {
|
|
||||||
"skipped_checks": [
|
|
||||||
{"node_id": n.node_id, "rationale": n.evidence or "No rationale recorded"}
|
|
||||||
for n in skipped
|
|
||||||
],
|
|
||||||
"rework_count": len(rework),
|
|
||||||
"clean_pass": len(skipped) == 0 and len(rework) == 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class TestSkillsBehavioralContracts(unittest.TestCase):
|
class TestSkillsBehavioralContracts(unittest.TestCase):
|
||||||
|
|
||||||
def test_prerequisite_guidance(self):
|
|
||||||
"""Proves missing gt binary triggers actionable prerequisite instructions."""
|
|
||||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
|
||||||
tmp_bin = Path(tmp_dir) / "bin"
|
|
||||||
tmp_bin.mkdir()
|
|
||||||
git_path = shutil.which("git")
|
|
||||||
self.assertIsNotNone(git_path, "git must exist on host")
|
|
||||||
(tmp_bin / "git").symlink_to(git_path)
|
|
||||||
|
|
||||||
orig_dirs = os.environ.get("PATH", "").split(os.pathsep)
|
|
||||||
new_dirs = [d for d in orig_dirs if not (Path(d) / "gt").exists()]
|
|
||||||
new_dirs.insert(0, str(tmp_bin))
|
|
||||||
|
|
||||||
env = os.environ.copy()
|
|
||||||
env["PATH"] = os.pathsep.join(new_dirs)
|
|
||||||
|
|
||||||
res = subprocess.run(
|
|
||||||
["./install.sh", "check"],
|
|
||||||
cwd=REPO_ROOT,
|
|
||||||
env=env,
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
# Must output actionable warning about gt CLI
|
|
||||||
combined = res.stdout + res.stderr
|
|
||||||
self.assertIn("'gt' CLI not found in PATH", combined)
|
|
||||||
self.assertIn("Gitea skills (gt-usage, gitea-plan, gitea-pr, implement-slice) require the official Gitea CLI", combined)
|
|
||||||
self.assertIn("https://gitea.com/gitea/cli/releases", combined)
|
|
||||||
|
|
||||||
def test_resource_id_querying_rules(self):
|
def test_resource_id_querying_rules(self):
|
||||||
"""Proves milestone/issue planning recipes forbid hardcoded ID guessing and require gt --json."""
|
"""Proves planning recipes forbid hardcoded ID guessing and require dynamic queries."""
|
||||||
gt_usage_cmd = REPO_ROOT / "skills" / "gt-usage" / "references" / "commands.md"
|
gt_usage_cmd = REPO_ROOT / "skills" / "gt-usage" / "references" / "commands.md"
|
||||||
self.assertTrue(gt_usage_cmd.exists())
|
self.assertTrue(gt_usage_cmd.exists())
|
||||||
content = gt_usage_cmd.read_text()
|
gt_content = gt_usage_cmd.read_text()
|
||||||
|
|
||||||
# Must mandate --json for querying IDs
|
# Standalone gt-usage still mandates --json for querying IDs
|
||||||
self.assertIn("gt milestone list --json id,title,state,url", content)
|
self.assertIn("gt milestone list --json id,title,state,url", gt_content)
|
||||||
self.assertIn("gt issue list --json id,number,title,state,url", content)
|
self.assertIn("gt issue list --json id,number,title,state,url", gt_content)
|
||||||
self.assertIn("gt project list --json id,title,state,url", content)
|
self.assertIn("gt project list --json id,title,state,url", gt_content)
|
||||||
|
|
||||||
# Anti-hallucination check: ensure gitea-plan explicitly forbids constructing /milestone/1
|
# Anti-hallucination check: projects explicitly forbids guessing IDs or constructing /milestone/1
|
||||||
gitea_plan = REPO_ROOT / "skills" / "gitea-plan" / "SKILL.md"
|
projects_skill = (REPO_ROOT / "skills" / "projects" / "SKILL.md").read_text()
|
||||||
self.assertIn("never guess sequence numbers or construct `/milestone/1`", gitea_plan.read_text())
|
projects_v2 = (REPO_ROOT / "skills" / "projects" / "references" / "github-projects-v2.md").read_text()
|
||||||
|
self.assertIn("Resolve all IDs dynamically", projects_skill)
|
||||||
def test_proportionality_scaling(self):
|
self.assertIn("/milestone/1", projects_skill)
|
||||||
"""Proves a documentation-only task produces a lightweight workflow without synthetic test ceremony."""
|
self.assertIn("Never hardcode or guess IDs", projects_v2)
|
||||||
doc_slice = WorkflowEngine.plan_slice(
|
self.assertIn("gh api repos/{owner}/{repo}/milestones", projects_v2)
|
||||||
title="Update architecture notes",
|
|
||||||
scope_files=["docs/adr/0001.md", "README.md"],
|
|
||||||
)
|
|
||||||
self.assertTrue(doc_slice["is_doc_only"])
|
|
||||||
# Should have lightweight nodes, no Independent QA Subagent, no unit test harness
|
|
||||||
executors = [n.executor for n in doc_slice["nodes"]]
|
|
||||||
methods = [n.method for n in doc_slice["nodes"]]
|
|
||||||
self.assertNotIn("Independent QA Subagent", executors)
|
|
||||||
self.assertNotIn("test harness", methods)
|
|
||||||
self.assertEqual(len(doc_slice["nodes"]), 2)
|
|
||||||
|
|
||||||
def test_feature_verification_canonical_schema(self):
|
|
||||||
"""Proves a multi-file code slice produces valid canonical 5-tuples and dynamic Mermaid projection."""
|
|
||||||
code_slice = WorkflowEngine.plan_slice(
|
|
||||||
title="Add authentication middleware",
|
|
||||||
scope_files=["src/auth.py", "src/tokens.py"],
|
|
||||||
is_security_sensitive=False,
|
|
||||||
)
|
|
||||||
self.assertFalse(code_slice["is_doc_only"])
|
|
||||||
self.assertGreaterEqual(len(code_slice["nodes"]), 3)
|
|
||||||
|
|
||||||
# Validate canonical schema on each node
|
|
||||||
for node in code_slice["nodes"]:
|
|
||||||
node.validate_schema()
|
|
||||||
|
|
||||||
# Dynamic Mermaid projection validation
|
|
||||||
mermaid = code_slice["mermaid"]
|
|
||||||
self.assertIn("flowchart TD", mermaid)
|
|
||||||
for node in code_slice["nodes"]:
|
|
||||||
self.assertIn(node.node_id, mermaid)
|
|
||||||
# Rework edge exists
|
|
||||||
self.assertIn("Fail / Rework", mermaid)
|
|
||||||
|
|
||||||
def test_security_invariants(self):
|
|
||||||
"""Proves a security-sensitive slice produces explicit defensive verification seams."""
|
|
||||||
sec_slice = WorkflowEngine.plan_slice(
|
|
||||||
title="Update SSH key loader",
|
|
||||||
scope_files=["src/ssh_loader.py"],
|
|
||||||
is_security_sensitive=True,
|
|
||||||
)
|
|
||||||
node_ids = [n.node_id for n in sec_slice["nodes"]]
|
|
||||||
self.assertIn("CHK-SEC-01", node_ids)
|
|
||||||
sec_node = next(n for n in sec_slice["nodes"] if n.node_id == "CHK-SEC-01")
|
|
||||||
sec_node.validate_schema()
|
|
||||||
self.assertIn("defensive invariants", sec_node.claim.lower())
|
|
||||||
self.assertIn("permissions", sec_node.pass_condition.lower())
|
|
||||||
|
|
||||||
def test_rework_routing(self):
|
|
||||||
"""Proves a simulated check failure correctly triggers rework and logs the failure in execution record."""
|
|
||||||
code_slice = WorkflowEngine.plan_slice(
|
|
||||||
title="Add parser",
|
|
||||||
scope_files=["src/parser.py"],
|
|
||||||
)
|
|
||||||
unit_node = next(n for n in code_slice["nodes"] if n.node_id == "CHK-UNIT-01")
|
|
||||||
|
|
||||||
# Simulate failure
|
|
||||||
unit_node.status = "failed"
|
|
||||||
unit_node.evidence = "AssertionError: line 42 expected 'ok' got 'error' (Exit code 1)"
|
|
||||||
self.assertEqual(unit_node.status, "failed")
|
|
||||||
self.assertEqual(unit_node.failure_route, "route to existing worker session")
|
|
||||||
|
|
||||||
# Simulate rework resolution via live worker session
|
|
||||||
unit_node.evidence = "Fixed in commit 1a2b3c4; Exit code 0, 12 passed"
|
|
||||||
unit_node.status = "passed"
|
|
||||||
self.assertEqual(unit_node.status, "passed")
|
|
||||||
|
|
||||||
def test_deviation_reporting(self):
|
|
||||||
"""Proves a skipped check generates an explicit entry with rationale in the deviation report."""
|
|
||||||
code_slice = WorkflowEngine.plan_slice(
|
|
||||||
title="Deploy live monitor",
|
|
||||||
scope_files=["src/monitor.py"],
|
|
||||||
)
|
|
||||||
# Add an optional live-infra check that gets skipped due to missing human authorization
|
|
||||||
live_check = WorkflowNode(
|
|
||||||
node_id="CHK-LIVE-01",
|
|
||||||
claim="Live infrastructure endpoint responds HTTP 200",
|
|
||||||
method="curl https://roadtotech.me",
|
|
||||||
executor="Independent QA Subagent",
|
|
||||||
pass_condition="HTTP 200",
|
|
||||||
)
|
|
||||||
code_slice["nodes"].append(live_check)
|
|
||||||
|
|
||||||
# Mark skipped due to authorization boundary
|
|
||||||
live_check.status = "skipped"
|
|
||||||
live_check.evidence = "BLOCKED (out-of-bounds): live-infra unapproved by human owner"
|
|
||||||
|
|
||||||
report = WorkflowEngine.generate_deviation_report(code_slice["nodes"])
|
|
||||||
self.assertFalse(report["clean_pass"])
|
|
||||||
self.assertEqual(len(report["skipped_checks"]), 1)
|
|
||||||
self.assertEqual(report["skipped_checks"][0]["node_id"], "CHK-LIVE-01")
|
|
||||||
self.assertIn("live-infra unapproved", report["skipped_checks"][0]["rationale"])
|
|
||||||
|
|
||||||
def test_dry_run_zero_mutation(self):
|
|
||||||
"""Proves --dry-run produces complete plans without mutating git status, commits, or files."""
|
|
||||||
# Record initial git status
|
|
||||||
initial_status = subprocess.check_output(
|
|
||||||
["git", "status", "--porcelain"],
|
|
||||||
cwd=REPO_ROOT,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
initial_commit = subprocess.check_output(
|
|
||||||
["git", "rev-parse", "HEAD"],
|
|
||||||
cwd=REPO_ROOT,
|
|
||||||
text=True,
|
|
||||||
).strip()
|
|
||||||
|
|
||||||
# Execute dry-run planning
|
|
||||||
plan = WorkflowEngine.plan_slice(
|
|
||||||
title="Spike feature",
|
|
||||||
scope_files=["src/spike.py"],
|
|
||||||
is_dry_run=True,
|
|
||||||
)
|
|
||||||
self.assertTrue(plan["is_dry_run"])
|
|
||||||
self.assertGreater(len(plan["nodes"]), 0)
|
|
||||||
|
|
||||||
# Verify zero mutations
|
|
||||||
current_status = subprocess.check_output(
|
|
||||||
["git", "status", "--porcelain"],
|
|
||||||
cwd=REPO_ROOT,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
current_commit = subprocess.check_output(
|
|
||||||
["git", "rev-parse", "HEAD"],
|
|
||||||
cwd=REPO_ROOT,
|
|
||||||
text=True,
|
|
||||||
).strip()
|
|
||||||
|
|
||||||
# The only allowed diff is the test file itself if it is running in-tree
|
|
||||||
# But during execution, zero new commits and zero external branch creation
|
|
||||||
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 owns guarded GitHub PR review publishing and implement never publishes reviews."""
|
||||||
cr_dir = REPO_ROOT / "skills" / "code-review"
|
cr_dir = REPO_ROOT / "skills" / "code-review"
|
||||||
|
cr_skill = (cr_dir / "SKILL.md").read_text()
|
||||||
|
cr_schema = (cr_dir / "references" / "finding-schema.md").read_text()
|
||||||
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("inline-comments.json", cr_text)
|
|
||||||
self.assertIn("No non-rejected findings.", cr_text)
|
|
||||||
self.assertIn("read-only regarding the codebase", cr_text)
|
|
||||||
|
|
||||||
schema = (cr_dir / "references" / "finding-schema.md").read_text()
|
self.assertIn("build_review.py", cr_skill)
|
||||||
publish = schema.split("### Publishing via `gt pr review`", 1)[1]
|
self.assertIn("Pending Triage", cr_text)
|
||||||
post_cmd = re.search(r"gt pr review <number> --comment[^\n]*\n[^\n]*", publish).group(0)
|
self.assertIn("Exit A", cr_schema)
|
||||||
# pinned to the reviewed commit, comment-only, no blanket confirmation
|
self.assertIn("Exit B", cr_schema)
|
||||||
self.assertIn("--commit <reviewed-head-sha>", post_cmd)
|
self.assertIn("Exit C", cr_schema)
|
||||||
for forbidden in ("--approve", "--request-changes", "--yes"):
|
self.assertNotIn("Accepted Trade-off", cr_text)
|
||||||
self.assertNotIn(forbidden, post_cmd)
|
self.assertIn("read-only regarding the codebase", cr_schema)
|
||||||
# staleness and duplicate guards precede posting
|
self.assertIn('"event": "COMMENT"', cr_schema)
|
||||||
self.assertLess(publish.index("head_sha"), publish.index(post_cmd))
|
self.assertIn('"commit_id": "<head_sha>"', cr_schema)
|
||||||
self.assertLess(publish.index("gt pr review list"), publish.index(post_cmd))
|
self.assertIn("Never emit `APPROVE` or `REQUEST_CHANGES`", cr_schema)
|
||||||
|
self.assertIn("no open PR was found", cr_skill)
|
||||||
|
|
||||||
# gitea-pr no longer owns PR review block publishing (no duplicate recipe)
|
# implement never publishes PR reviews or inline review comments
|
||||||
pr_skill = (REPO_ROOT / "skills" / "gitea-pr" / "SKILL.md").read_text()
|
impl_skill = (REPO_ROOT / "skills" / "implement" / "SKILL.md").read_text()
|
||||||
pr_pulls = (REPO_ROOT / "skills" / "gitea-pr" / "references" / "gt-pulls.md").read_text()
|
impl_pr = (REPO_ROOT / "skills" / "implement" / "references" / "pr-and-drift.md").read_text()
|
||||||
self.assertNotIn("Publish review findings", pr_skill)
|
self.assertIn("never publish PR review comments", impl_skill)
|
||||||
self.assertNotIn("### Publish a `code-review` Comment Block", pr_pulls)
|
self.assertIn("`code-review` is the sole owner of PR review publishing", impl_pr)
|
||||||
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):
|
def test_project_board_reconciliation_and_card_transitions(self):
|
||||||
"""Proves 5-column board reconciliation, Deep Signal colors, and card transition ownership."""
|
"""Proves 5-column GitHub Projects v2 board schema, fixed color enums, and transition ownership."""
|
||||||
tiers_text = (REPO_ROOT / "skills" / "gitea-plan" / "references" / "decomposition-tiers.md").read_text()
|
contract_text = (REPO_ROOT / "skills" / "projects" / "references" / "planning-contract.md").read_text()
|
||||||
gt_cmds = (REPO_ROOT / "skills" / "gt-usage" / "references" / "commands.md").read_text()
|
v2_text = (REPO_ROOT / "skills" / "projects" / "references" / "github-projects-v2.md").read_text()
|
||||||
impl_skill = (REPO_ROOT / "skills" / "implement-slice" / "SKILL.md").read_text()
|
impl_skill = (REPO_ROOT / "skills" / "implement" / "SKILL.md").read_text()
|
||||||
impl_handoff = (REPO_ROOT / "skills" / "implement-slice" / "references" / "handoff-contracts.md").read_text()
|
impl_pr = (REPO_ROOT / "skills" / "implement" / "references" / "pr-and-drift.md").read_text()
|
||||||
pr_skill = (REPO_ROOT / "skills" / "gitea-pr" / "SKILL.md").read_text()
|
verify_skill = (REPO_ROOT / "skills" / "verify" / "SKILL.md").read_text()
|
||||||
pr_pulls = (REPO_ROOT / "skills" / "gitea-pr" / "references" / "gt-pulls.md").read_text()
|
verify_closeout = (REPO_ROOT / "skills" / "verify" / "references" / "closeout-and-abort.md").read_text()
|
||||||
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"))
|
||||||
|
|
||||||
# 1. Canonical 5 columns and Deep Signal hex colors in gitea-plan
|
# 1. Canonical 5 columns and fixed GitHub color enums in projects (no hex colors)
|
||||||
expected_columns = {
|
expected_columns = {
|
||||||
"Backlog": "#475569",
|
"Backlog": "GRAY",
|
||||||
"Ready": "#1d76db",
|
"Ready": "BLUE",
|
||||||
"Work in Progress": "#d97706",
|
"Work in Progress": "YELLOW",
|
||||||
"Review": "#6d28d9",
|
"Review": "PURPLE",
|
||||||
"Completed": "#15803d",
|
"Completed": "GREEN",
|
||||||
}
|
}
|
||||||
for col_title, hex_color in expected_columns.items():
|
for col_title, color_enum in expected_columns.items():
|
||||||
self.assertIn(col_title, tiers_text)
|
self.assertIn(col_title, contract_text)
|
||||||
self.assertIn(hex_color, tiers_text)
|
self.assertIn(color_enum, contract_text)
|
||||||
self.assertIn("PATCH", tiers_text)
|
self.assertIn(col_title, v2_text)
|
||||||
self.assertIn("PATCH /repos/{owner}/{repo}/projects/<project-id>/columns/<column-id>", gt_cmds)
|
self.assertIn(color_enum, v2_text)
|
||||||
|
self.assertIsNone(
|
||||||
|
re.search(r"#[0-9a-fA-F]{6}\b", contract_text + "\n" + v2_text),
|
||||||
|
"projects must use GitHub color enums rather than Gitea #RRGGBB hex colors",
|
||||||
|
)
|
||||||
|
|
||||||
# 2. Card transition ownership across implement-slice and gitea-pr
|
# 2. Card transition ownership across implement and verify
|
||||||
self.assertIn("Backlog -> Ready", impl_skill)
|
|
||||||
self.assertIn("Ready -> Work in Progress", impl_skill)
|
self.assertIn("Ready -> Work in Progress", impl_skill)
|
||||||
self.assertIn("Work in Progress -> Review", impl_skill)
|
self.assertIn("keep the\n board card in `Work in Progress`", impl_skill)
|
||||||
self.assertIn("Backlog -> Ready", impl_handoff)
|
self.assertIn("Never\n move the card to `Review` here", impl_pr)
|
||||||
self.assertIn("Work in Progress -> Review", pr_skill)
|
self.assertIn("Work in Progress -> Review", verify_skill)
|
||||||
self.assertIn("Review -> Completed", pr_skill)
|
self.assertIn("Review -> Completed", verify_skill)
|
||||||
self.assertIn("/issues/${issue_global_id}/move -F column_id=<completed-col-id>", pr_pulls)
|
self.assertIn("Review -> Work in Progress", verify_skill)
|
||||||
|
self.assertIn("updateProjectV2ItemFieldValue", verify_closeout)
|
||||||
|
|
||||||
# 3. code-review never mutates project boards
|
# 3. code-review never mutates project boards
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
re.search(r"/projects/[^\n]*/move", cr_text),
|
re.search(r"(updateProjectV2ItemFieldValue|/projects/[^\n]*/move)", cr_text),
|
||||||
"code-review must remain read-only and never execute project board card moves",
|
"code-review must remain read-only and never execute project board card moves",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_reconcile_docs_gitea_ingestion_and_hooks(self):
|
def test_reconcile_docs_github_ingestion_and_hooks(self):
|
||||||
"""Proves reconcile-docs ingests Gitea state read-only and hooks into gitea-plan and implement-slice."""
|
"""Proves reconcile-docs ingests GitHub state read-only and hooks into projects and implement."""
|
||||||
rd_dir = REPO_ROOT / "skills" / "reconcile-docs"
|
rd_dir = REPO_ROOT / "skills" / "reconcile-docs"
|
||||||
rd_skill = (rd_dir / "SKILL.md").read_text()
|
rd_skill = (rd_dir / "SKILL.md").read_text()
|
||||||
rd_all = "\n".join(p.read_text() for p in rd_dir.rglob("*.md"))
|
rd_all = "\n".join(p.read_text() for p in rd_dir.rglob("*.md"))
|
||||||
plan_skill = (REPO_ROOT / "skills" / "gitea-plan" / "SKILL.md").read_text()
|
projects_skill = (REPO_ROOT / "skills" / "projects" / "SKILL.md").read_text()
|
||||||
impl_skill = (REPO_ROOT / "skills" / "implement-slice" / "SKILL.md").read_text()
|
verify_skill = (REPO_ROOT / "skills" / "verify" / "SKILL.md").read_text()
|
||||||
|
|
||||||
# 1. reconcile-docs reads Gitea PR comments and board state, and targets docs/designs/*.md
|
# 1. reconcile-docs reads GitHub PRs, milestones, and board state read-only, targeting docs/designs/*.md
|
||||||
self.assertIn("docs/designs/*.md", rd_skill)
|
self.assertIn("docs/designs/*.md", rd_skill)
|
||||||
self.assertIn("Project Board", rd_skill)
|
self.assertIn("Project Board", rd_skill)
|
||||||
self.assertIn("Never mutate Gitea issues, PRs, or board cards", rd_skill)
|
self.assertIn("gh repo view --json url", rd_skill)
|
||||||
|
self.assertIn("gh pr list --state merged", rd_skill)
|
||||||
|
self.assertIn("Never mutate GitHub issues, PRs, or board cards", rd_skill)
|
||||||
self.assertIn("Mid-Slice Spec Drift", rd_all)
|
self.assertIn("Mid-Slice Spec Drift", rd_all)
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
re.search(r"(/projects/[^\n]*/move|gt (issue|pr|project) (create|edit|close|merge))", rd_all),
|
re.search(r"(updateProjectV2ItemFieldValue|gh (issue|pr) (create|edit|close|merge))", rd_all),
|
||||||
"reconcile-docs must never mutate Gitea issues, PRs, or project boards",
|
"reconcile-docs must never mutate GitHub issues, PRs, or project boards",
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2. Bidirectional hooks across reconcile-docs, gitea-plan, and implement-slice
|
# 2. Bidirectional hooks across reconcile-docs, projects, implement, and verify
|
||||||
self.assertIn("gitea-plan", rd_skill)
|
self.assertIn("projects", rd_skill)
|
||||||
self.assertIn("reconcile-docs", plan_skill)
|
self.assertIn("implement", rd_skill)
|
||||||
self.assertIn("reconcile-docs", impl_skill)
|
self.assertIn("reconcile-docs", projects_skill)
|
||||||
|
self.assertIn("reconcile-docs", verify_skill)
|
||||||
|
|
||||||
def test_repo_scoped_documentation_and_vault_deprecation(self):
|
def test_repo_scoped_documentation_and_vault_deprecation(self):
|
||||||
"""Proves ~/Brain, 00-inbox, draft-curation, and journal-builder are deprecated in favor of repo docs/ and .internal/."""
|
"""Proves ~/Brain, 00-inbox, draft-curation, and journal-builder are deprecated in favor of repo docs/ and .internal/."""
|
||||||
doc_dir = REPO_ROOT / "skills" / "document"
|
doc_all = "\n".join(p.read_text() for p in (REPO_ROOT / "skills" / "document").rglob("*.md"))
|
||||||
doc_all = "\n".join(p.read_text() for p in doc_dir.rglob("*.md"))
|
prac_all = "\n".join(p.read_text() for p in (REPO_ROOT / "skills" / "practice").rglob("*.md"))
|
||||||
prac_dir = REPO_ROOT / "skills" / "practice"
|
projects_all = "\n".join(p.read_text() for p in (REPO_ROOT / "skills" / "projects").rglob("*.md"))
|
||||||
prac_all = "\n".join(p.read_text() for p in prac_dir.rglob("*.md"))
|
impl_all = "\n".join(p.read_text() for p in (REPO_ROOT / "skills" / "implement").rglob("*.md"))
|
||||||
profile_agents = (REPO_ROOT / "profile" / "AGENTS.md").read_text()
|
profile_agents = (REPO_ROOT / "profile" / "AGENTS.md").read_text()
|
||||||
install_sh = (REPO_ROOT / "install.sh").read_text()
|
install_sh = (REPO_ROOT / "install.sh").read_text()
|
||||||
|
|
||||||
# 1. No ~/Brain, 00-inbox, or draft-curation in active skills or profile
|
# 1. No ~/Brain, 00-inbox, draft-curation, or journal-builder in active skills or profile
|
||||||
for forbidden in ("~/Brain", "00-inbox", "draft-curation", "journal-builder"):
|
for forbidden in ("~/Brain", "00-inbox", "draft-curation", "journal-builder"):
|
||||||
self.assertNotIn(forbidden, doc_all)
|
self.assertNotIn(forbidden, doc_all)
|
||||||
self.assertNotIn(forbidden, prac_all)
|
self.assertNotIn(forbidden, prac_all)
|
||||||
|
self.assertNotIn(forbidden, projects_all)
|
||||||
|
self.assertNotIn(forbidden, impl_all)
|
||||||
self.assertNotIn(forbidden, profile_agents)
|
self.assertNotIn(forbidden, profile_agents)
|
||||||
|
|
||||||
# 2. Repo-scoped paths present
|
# 2. Repo-scoped paths present
|
||||||
self.assertIn("docs/adr/", doc_all)
|
self.assertIn("docs/adr/", doc_all)
|
||||||
self.assertIn("docs/designs/", doc_all)
|
self.assertIn("docs/designs/", doc_all)
|
||||||
self.assertIn(".internal/practice/", prac_all)
|
self.assertIn(".internal/practice/", prac_all)
|
||||||
|
self.assertIn("docs/designs/*.md", projects_all)
|
||||||
|
self.assertIn(".internal/", projects_all)
|
||||||
|
self.assertIn("docs/designs/*.md", impl_all)
|
||||||
|
self.assertIn(".internal/", impl_all)
|
||||||
self.assertIn("OBSOLETE_SKILLS=(", install_sh)
|
self.assertIn("OBSOLETE_SKILLS=(", install_sh)
|
||||||
self.assertIn("journal-builder", install_sh)
|
self.assertIn("journal-builder", install_sh)
|
||||||
self.assertIn("draft-curation", install_sh)
|
self.assertIn("draft-curation", install_sh)
|
||||||
|
|
||||||
# 3. Vertical per-submodule Red->Green decomposition in gitea-plan and implement-slice
|
# 3. Vertical Submodule TDD Grouping in projects
|
||||||
plan_all = "\n".join(p.read_text() for p in (REPO_ROOT / "skills" / "gitea-plan").rglob("*.md"))
|
self.assertIn("Vertical Submodule TDD Grouping", projects_all)
|
||||||
impl_all = "\n".join(p.read_text() for p in (REPO_ROOT / "skills" / "implement-slice").rglob("*.md"))
|
|
||||||
self.assertIn("Vertical Submodule TDD Grouping", plan_all)
|
|
||||||
self.assertIn("Vertical Submodule TDD Decomposition (Anti-Horizontal Batching)", impl_all)
|
|
||||||
|
|
||||||
def test_tdd_supports_dual_mode_with_mode_b_gates(self):
|
def test_tdd_supports_dual_mode_with_mode_b_gates(self):
|
||||||
"""Proves tdd supports Mode A and Mode B with production-signature Your call and sensitivity Done when gates."""
|
"""Proves tdd supports Mode A and Mode B with production-signature Your call and sensitivity Done when gates."""
|
||||||
@@ -529,18 +247,19 @@ class TestSkillsBehavioralContracts(unittest.TestCase):
|
|||||||
self.assertIn("Suggested Next Step", schema)
|
self.assertIn("Suggested Next Step", schema)
|
||||||
|
|
||||||
def test_skeleton_defines_suggested_next_step_suppression(self):
|
def test_skeleton_defines_suggested_next_step_suppression(self):
|
||||||
"""Proves skeleton.md owns Suggested Next Step suppression and handoff-contracts.md enforces it without en-dash debt."""
|
"""Proves skeleton.md owns Suggested Next Step suppression and implement enforces it on delegated workers."""
|
||||||
skeleton = (REPO_ROOT / "skills" / "build-skill" / "references" / "skeleton.md").read_text()
|
skeleton = (REPO_ROOT / "skills" / "build-skill" / "references" / "skeleton.md").read_text()
|
||||||
handoffs = (REPO_ROOT / "skills" / "implement-slice" / "references" / "handoff-contracts.md").read_text()
|
impl_skill = (REPO_ROOT / "skills" / "implement" / "SKILL.md").read_text()
|
||||||
|
impl_roles = (REPO_ROOT / "skills" / "implement" / "references" / "decomposition-and-roles.md").read_text()
|
||||||
self.assertIn("Suggested Next Step", skeleton)
|
self.assertIn("Suggested Next Step", skeleton)
|
||||||
self.assertIn("Delegated subagent runs omit that footer", skeleton)
|
self.assertIn("Delegated subagent runs omit that footer", skeleton)
|
||||||
self.assertIn("Suppress", handoffs)
|
self.assertIn("suppress\n when delegated", impl_skill)
|
||||||
self.assertNotIn("Steps 4–5", handoffs)
|
self.assertIn("Suppress any standalone `Suggested Next Step:` footer", impl_roles)
|
||||||
|
|
||||||
def test_chained_skills_include_suggested_next_step_routing(self):
|
def test_chained_skills_include_suggested_next_step_routing(self):
|
||||||
"""Proves all 6 chained skills include Suggested Next Step routing and valid relative markdown links."""
|
"""Proves all 7 chained skills include Suggested Next Step routing and valid relative markdown links."""
|
||||||
link_re = re.compile(r"\]\(([^)#]+\.md)(?:#[^)]+)?\)")
|
link_re = re.compile(r"\]\(([^)#]+\.md)(?:#[^)]+)?\)")
|
||||||
for skill_name in ("gitea-plan", "implement-slice", "tdd", "code-review", "gitea-pr", "reconcile-docs"):
|
for skill_name in ("projects", "implement", "tdd", "code-review", "verify", "reconcile-docs", "gitea-to-github"):
|
||||||
skill_path = REPO_ROOT / "skills" / skill_name / "SKILL.md"
|
skill_path = REPO_ROOT / "skills" / skill_name / "SKILL.md"
|
||||||
text = skill_path.read_text()
|
text = skill_path.read_text()
|
||||||
self.assertIn("Suggested Next Step:", text, f"{skill_name} missing Suggested Next Step routing")
|
self.assertIn("Suggested Next Step:", text, f"{skill_name} missing Suggested Next Step routing")
|
||||||
@@ -549,21 +268,210 @@ class TestSkillsBehavioralContracts(unittest.TestCase):
|
|||||||
self.assertTrue(resolved.exists(), f"{skill_name} has broken relative link: {rel_link} -> {resolved}")
|
self.assertTrue(resolved.exists(), f"{skill_name} has broken relative link: {rel_link} -> {resolved}")
|
||||||
|
|
||||||
def test_subagent_provenance_output_slot_guards(self):
|
def test_subagent_provenance_output_slot_guards(self):
|
||||||
"""Proves High-Assurance code-review and Medium/Large gitea-plan require subagent provenance slots in output templates."""
|
"""Proves High-Assurance code-review and Medium/Large projects require subagent provenance slots in output templates."""
|
||||||
cr_skill = (REPO_ROOT / "skills" / "code-review" / "SKILL.md").read_text()
|
cr_skill = (REPO_ROOT / "skills" / "code-review" / "SKILL.md").read_text()
|
||||||
cr_schema = (REPO_ROOT / "skills" / "code-review" / "references" / "finding-schema.md").read_text()
|
cr_schema = (REPO_ROOT / "skills" / "code-review" / "references" / "finding-schema.md").read_text()
|
||||||
impl_tiers = (REPO_ROOT / "skills" / "implement-slice" / "references" / "orchestration-tiers.md").read_text()
|
projects_skill = (REPO_ROOT / "skills" / "projects" / "SKILL.md").read_text()
|
||||||
plan_skill = (REPO_ROOT / "skills" / "gitea-plan" / "SKILL.md").read_text()
|
projects_tiers = (REPO_ROOT / "skills" / "projects" / "references" / "tiers-and-audit.md").read_text()
|
||||||
plan_tiers = (REPO_ROOT / "skills" / "gitea-plan" / "references" / "decomposition-tiers.md").read_text()
|
|
||||||
|
|
||||||
self.assertIn("record both subagent IDs in `Execution Mode`", cr_skill)
|
self.assertIn("record\n both subagent IDs in `Execution Mode`", cr_skill)
|
||||||
self.assertIn("Dedicated Axis 3 Tests subagent `<id>`", cr_schema)
|
self.assertIn("Dedicated Axis 3 Tests subagent `<id>`", cr_schema)
|
||||||
self.assertIn("dedicated Axis 3 `Seam & Test Integrity` subagent + Axes 1/2/4 subagent", impl_tiers)
|
self.assertIn("### Reproducibility Audit:", projects_skill)
|
||||||
self.assertIn("### Reproducibility Audit:", plan_skill)
|
self.assertIn("### Reproducibility Audit:", projects_tiers)
|
||||||
self.assertIn("### Reproducibility Audit:", plan_tiers)
|
|
||||||
|
def test_projects_contract_and_dynamic_graphql_state_machine(self):
|
||||||
|
"""Proves projects defines state-free project_number contract and dynamic owner.projectV2 / issue.projectItems queries."""
|
||||||
|
contract = (REPO_ROOT / "skills" / "projects" / "references" / "planning-contract.md").read_text()
|
||||||
|
v2 = (REPO_ROOT / "skills" / "projects" / "references" / "github-projects-v2.md").read_text()
|
||||||
|
|
||||||
|
self.assertIn("project_number: <int>", contract)
|
||||||
|
self.assertIn("Zero brittle Node IDs", contract)
|
||||||
|
self.assertIn("gh repo view --json url", contract)
|
||||||
|
self.assertIn("owner.projectV2(number: $project_number)", v2)
|
||||||
|
self.assertIn("addProjectV2ItemById", v2)
|
||||||
|
self.assertIn("issue.projectItems", v2)
|
||||||
|
self.assertIn("updateProjectV2ItemFieldValue", v2)
|
||||||
|
self.assertIn("DATE", v2)
|
||||||
|
|
||||||
|
def test_implement_preflight_checkpointing_and_timeout_wrapper(self):
|
||||||
|
"""Proves implement defines preflight classifications, --dry-run, git-common-dir checkpointing without tuxedo, and setsid timeout."""
|
||||||
|
preflight = (REPO_ROOT / "skills" / "implement" / "references" / "preflight.md").read_text()
|
||||||
|
roles = (REPO_ROOT / "skills" / "implement" / "references" / "decomposition-and-roles.md").read_text()
|
||||||
|
|
||||||
|
for classification in (
|
||||||
|
"CLEAN_BASE",
|
||||||
|
"EXISTING_SLICE_BRANCH",
|
||||||
|
"ADOPTABLE_DIFF",
|
||||||
|
"CONFLICTING_STATE",
|
||||||
|
"WRONG_BASE",
|
||||||
|
):
|
||||||
|
self.assertIn(classification, preflight)
|
||||||
|
|
||||||
|
self.assertIn("--dry-run", preflight)
|
||||||
|
self.assertIn("zero mutations", preflight)
|
||||||
|
self.assertIn("git rev-parse --git-common-dir", preflight)
|
||||||
|
self.assertIn("implement-state/${branch_slug}.txt", preflight)
|
||||||
|
self.assertIn("Never\n invoke `tuxedo`", preflight)
|
||||||
|
|
||||||
|
self.assertIn("setsid timeout -k 10 <N>s <cmd> < /dev/null", roles)
|
||||||
|
self.assertIn("CI=true", roles)
|
||||||
|
self.assertIn("GIT_TERMINAL_PROMPT=0", roles)
|
||||||
|
self.assertIn("PAGER=cat", roles)
|
||||||
|
for timeout_tier in ("60s", "180s", "600s"):
|
||||||
|
self.assertIn(timeout_tier, roles)
|
||||||
|
|
||||||
|
def test_code_review_build_review_and_metadata_contract(self):
|
||||||
|
"""Proves code-review integrates build_review.py, monotonic CR-XX, cr-review-meta verdict, RV-* body checks, and local no-PR notice."""
|
||||||
|
build_script = REPO_ROOT / "skills" / "code-review" / "scripts" / "build_review.py"
|
||||||
|
self.assertTrue(build_script.exists(), "build_review.py must exist under skills/code-review/scripts/")
|
||||||
|
|
||||||
|
cr_skill = (REPO_ROOT / "skills" / "code-review" / "SKILL.md").read_text()
|
||||||
|
cr_schema = (REPO_ROOT / "skills" / "code-review" / "references" / "finding-schema.md").read_text()
|
||||||
|
|
||||||
|
self.assertIn("skills/code-review/scripts/build_review.py", cr_skill)
|
||||||
|
self.assertIn("cr-review-meta: max_id=NN head_sha=<sha> verdict=ready|needs_rework", cr_schema)
|
||||||
|
self.assertIn("CR-01", cr_schema)
|
||||||
|
self.assertIn("RV-*", cr_schema)
|
||||||
|
self.assertIn("3-rework-cycle cap", cr_schema)
|
||||||
|
self.assertIn("No open GitHub PR found; findings reported locally.", cr_schema)
|
||||||
|
|
||||||
|
def test_verify_three_phase_flow_and_zero_todo_txt(self):
|
||||||
|
"""Proves verify defines 3-phase flow, zero todo.txt responsibility, gh pr ready -> Review, and post-merge Completed."""
|
||||||
|
verify_skill = (REPO_ROOT / "skills" / "verify" / "SKILL.md").read_text()
|
||||||
|
qa = (REPO_ROOT / "skills" / "verify" / "references" / "qa-dispositions.md").read_text()
|
||||||
|
closeout = (REPO_ROOT / "skills" / "verify" / "references" / "closeout-and-abort.md").read_text()
|
||||||
|
|
||||||
|
self.assertIn("Phase 1: Read-Only Runtime QA and CI", verify_skill)
|
||||||
|
self.assertIn("Phase 2: Promotion", verify_skill)
|
||||||
|
self.assertIn("Phase 3: Human Merge Gate and Closeout", verify_skill)
|
||||||
|
self.assertIn("zero\n`todo.txt` cleanup responsibility", verify_skill)
|
||||||
|
self.assertIn("Zero `todo.txt` responsibility", closeout)
|
||||||
|
|
||||||
|
self.assertIn("cr-review-meta", qa)
|
||||||
|
self.assertIn("verdict=ready", qa)
|
||||||
|
self.assertIn("gh pr checks", qa)
|
||||||
|
for disposition in (
|
||||||
|
"PASS",
|
||||||
|
"FAIL",
|
||||||
|
"BLOCKED (env/fixture)",
|
||||||
|
"BLOCKED (out-of-bounds)",
|
||||||
|
"INCONCLUSIVE",
|
||||||
|
):
|
||||||
|
self.assertIn(disposition, qa)
|
||||||
|
|
||||||
|
self.assertIn("gh pr ready", closeout)
|
||||||
|
self.assertIn("Work in Progress -> Review", closeout)
|
||||||
|
self.assertIn("Review -> Completed", closeout)
|
||||||
|
self.assertIn("gh pr ready --undo", closeout)
|
||||||
|
self.assertIn("gh pr close", closeout)
|
||||||
|
|
||||||
|
def test_install_sh_check_exit_codes_and_dangling_symlink_pruning(self):
|
||||||
|
"""Proves install.sh check exits 1 on missing/obsolete skills, exits 0 when clean, and prunes only repo-scoped dangling symlinks."""
|
||||||
|
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||||
|
tmp_path = Path(tmp_dir)
|
||||||
|
target_skills = tmp_path / "skills"
|
||||||
|
target_agents = tmp_path / "agents"
|
||||||
|
target_profile = tmp_path / "AGENTS.md"
|
||||||
|
target_skills.mkdir()
|
||||||
|
target_agents.mkdir()
|
||||||
|
|
||||||
|
env = os.environ.copy()
|
||||||
|
env["PROFILE_TARGET"] = str(target_profile)
|
||||||
|
env["AGENTS_DIR_TARGET"] = str(target_agents)
|
||||||
|
|
||||||
|
# 1. Empty target must fail check with exit 1
|
||||||
|
res_empty = subprocess.run(
|
||||||
|
["./install.sh", "--target", str(target_skills), "check"],
|
||||||
|
cwd=REPO_ROOT,
|
||||||
|
env=env,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
self.assertEqual(res_empty.returncode, 1, res_empty.stdout + res_empty.stderr)
|
||||||
|
self.assertIn("[MISSING]", res_empty.stdout)
|
||||||
|
|
||||||
|
# 2. Install into isolated temp dir must succeed (exit 0), then check must exit 0
|
||||||
|
res_install = subprocess.run(
|
||||||
|
["./install.sh", "--target", str(target_skills)],
|
||||||
|
cwd=REPO_ROOT,
|
||||||
|
env=env,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
self.assertEqual(res_install.returncode, 0, res_install.stdout + res_install.stderr)
|
||||||
|
|
||||||
|
res_clean = subprocess.run(
|
||||||
|
["./install.sh", "--target", str(target_skills), "check"],
|
||||||
|
cwd=REPO_ROOT,
|
||||||
|
env=env,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
self.assertEqual(res_clean.returncode, 0, res_clean.stdout + res_clean.stderr)
|
||||||
|
self.assertIn("All active skills are present.", res_clean.stdout)
|
||||||
|
|
||||||
|
# 3. Adding an obsolete legacy skill must cause check to exit 1
|
||||||
|
obsolete_link = target_skills / "gitea-plan"
|
||||||
|
obsolete_link.symlink_to(REPO_ROOT / "skills" / "gitea-plan")
|
||||||
|
res_obs = subprocess.run(
|
||||||
|
["./install.sh", "--target", str(target_skills), "check"],
|
||||||
|
cwd=REPO_ROOT,
|
||||||
|
env=env,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
self.assertEqual(res_obs.returncode, 1, res_obs.stdout + res_obs.stderr)
|
||||||
|
self.assertIn("[OBSOLETE PRESENT] gitea-plan", res_obs.stdout)
|
||||||
|
|
||||||
|
# 4. Repo-scoped dangling symlink is pruned on install; unrelated dangling symlink is preserved
|
||||||
|
repo_dangling = target_skills / "stale-repo-skill"
|
||||||
|
repo_dangling.symlink_to(REPO_ROOT / "skills" / "nonexistent-deleted-skill")
|
||||||
|
unrelated_dangling = target_skills / "external-skill"
|
||||||
|
unrelated_dangling.symlink_to(Path("/tmp/nonexistent-unrelated-skill-target"))
|
||||||
|
|
||||||
|
res_reinstall = subprocess.run(
|
||||||
|
["./install.sh", "--target", str(target_skills)],
|
||||||
|
cwd=REPO_ROOT,
|
||||||
|
env=env,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
self.assertEqual(res_reinstall.returncode, 0, res_reinstall.stdout + res_reinstall.stderr)
|
||||||
|
self.assertFalse(obsolete_link.is_symlink(), "Obsolete skill symlink should be backed up and removed")
|
||||||
|
self.assertFalse(repo_dangling.is_symlink(), "Repo-scoped dangling symlink should be pruned")
|
||||||
|
self.assertTrue(unrelated_dangling.is_symlink(), "Unrelated external symlink must be preserved")
|
||||||
|
|
||||||
|
# 5. Clean check passes again after reinstall
|
||||||
|
res_post = subprocess.run(
|
||||||
|
["./install.sh", "--target", str(target_skills), "check"],
|
||||||
|
cwd=REPO_ROOT,
|
||||||
|
env=env,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
self.assertEqual(res_post.returncode, 0, res_post.stdout + res_post.stderr)
|
||||||
|
|
||||||
def test_skill_inventory_and_skeletons(self):
|
def test_skill_inventory_and_skeletons(self):
|
||||||
"""Proves all 16 active skills meet line count (<= 80), em-dash, and path portability rules."""
|
"""Proves all 16 active skills meet line count (<= 80), em-dash, and path portability rules, and legacy skills are retired."""
|
||||||
|
install_sh = (REPO_ROOT / "install.sh").read_text()
|
||||||
|
|
||||||
|
# Verify ACTIVE_PORTABLE_SKILLS matches EXPECTED_SKILLS exactly
|
||||||
|
active_match = re.search(r"ACTIVE_PORTABLE_SKILLS=\(([^)]*)\)", install_sh)
|
||||||
|
self.assertIsNotNone(active_match, "ACTIVE_PORTABLE_SKILLS missing from install.sh")
|
||||||
|
active_skills = active_match.group(1).split()
|
||||||
|
self.assertEqual(active_skills, EXPECTED_SKILLS)
|
||||||
|
|
||||||
|
# Verify all 4 retired legacy skills appear in OBSOLETE_SKILLS and are absent from skills/
|
||||||
|
obsolete_match = re.search(r"OBSOLETE_SKILLS=\(([^)]*)\)", install_sh)
|
||||||
|
self.assertIsNotNone(obsolete_match, "OBSOLETE_SKILLS missing from install.sh")
|
||||||
|
obsolete_skills = obsolete_match.group(1).split()
|
||||||
|
for retired in RETIRED_LEGACY_SKILLS:
|
||||||
|
self.assertIn(retired, obsolete_skills, f"{retired} must be listed in OBSOLETE_SKILLS")
|
||||||
|
self.assertFalse(
|
||||||
|
(REPO_ROOT / "skills" / retired).exists(),
|
||||||
|
f"Retired legacy skill directory still exists: skills/{retired}",
|
||||||
|
)
|
||||||
|
|
||||||
for skill_name in EXPECTED_SKILLS:
|
for skill_name in EXPECTED_SKILLS:
|
||||||
skill_path = REPO_ROOT / "skills" / skill_name / "SKILL.md"
|
skill_path = REPO_ROOT / "skills" / skill_name / "SKILL.md"
|
||||||
self.assertTrue(skill_path.exists(), f"Missing skill file: {skill_path}")
|
self.assertTrue(skill_path.exists(), f"Missing skill file: {skill_path}")
|
||||||
@@ -586,6 +494,87 @@ class TestSkillsBehavioralContracts(unittest.TestCase):
|
|||||||
self.assertIn("name:", content)
|
self.assertIn("name:", content)
|
||||||
self.assertIn("description:", content)
|
self.assertIn("description:", content)
|
||||||
|
|
||||||
|
def test_gitea_to_github_portability_hygiene(self):
|
||||||
|
"""Proves gitea-to-github files contain zero em-dashes, /home/ paths, or private domains."""
|
||||||
|
skill_dir = REPO_ROOT / "skills" / "gitea-to-github"
|
||||||
|
for path in [skill_dir / "SKILL.md", *sorted((skill_dir / "references").glob("*.md"))]:
|
||||||
|
text = path.read_text()
|
||||||
|
self.assertNotIn("—", text, f"{path.name} contains em-dash")
|
||||||
|
self.assertNotIn("/home/", text, f"{path.name} contains /home/ path")
|
||||||
|
self.assertNotIn("roadtotech", text, f"{path.name} contains private domain")
|
||||||
|
|
||||||
|
def test_gitea_to_github_safety_flags(self):
|
||||||
|
"""Proves gitea-to-github enforces dry-run flags, LFS fail-fast, and non-git mktemp provisioning."""
|
||||||
|
skill_dir = REPO_ROOT / "skills" / "gitea-to-github"
|
||||||
|
skill_md = (skill_dir / "SKILL.md").read_text()
|
||||||
|
remote_md = (skill_dir / "references" / "remote-and-mirror.md").read_text()
|
||||||
|
|
||||||
|
self.assertIn("--dry-run", skill_md)
|
||||||
|
self.assertIn("--execute", skill_md)
|
||||||
|
self.assertIn("git lfs ls-files", remote_md)
|
||||||
|
self.assertIn("mktemp -d", remote_md)
|
||||||
|
self.assertIn("--empty --no-mirror --no-clone", remote_md)
|
||||||
|
|
||||||
|
def test_gitea_to_github_archive_precedes_mirror_sync(self):
|
||||||
|
"""Proves gitea-to-github renames the archive before attaching the mirror and verifying sync."""
|
||||||
|
remote_md = (REPO_ROOT / "skills" / "gitea-to-github" / "references" / "remote-and-mirror.md").read_text()
|
||||||
|
archive_idx = remote_md.index("-archive-YYYYMMDDHHMMSS")
|
||||||
|
mirror_idx = remote_md.index("--gitea-mirror")
|
||||||
|
sync_idx = remote_md.index("mirror-sync")
|
||||||
|
self.assertLess(archive_idx, mirror_idx, "Archive rename must precede --gitea-mirror attachment")
|
||||||
|
self.assertLess(mirror_idx, sync_idx, "Mirror attachment must precede mirror-sync verification")
|
||||||
|
|
||||||
|
def test_gitea_to_github_ci_workflow_migration(self):
|
||||||
|
"""Proves ci-and-contracts.md covers .gitea -> .github workflow translation and public self-hosted guard."""
|
||||||
|
ci_md = (REPO_ROOT / "skills" / "gitea-to-github" / "references" / "ci-and-contracts.md").read_text()
|
||||||
|
self.assertIn(".gitea/workflows/", ci_md)
|
||||||
|
self.assertIn(".github/workflows/", ci_md)
|
||||||
|
self.assertIn("self-hosted", ci_md)
|
||||||
|
self.assertIn("ubuntu-latest", ci_md)
|
||||||
|
self.assertIn("`public`", ci_md)
|
||||||
|
|
||||||
|
def test_gitea_to_github_entity_idempotency_marker(self):
|
||||||
|
"""Proves entity-migration.md embeds the immutable gitea-origin deduplication marker."""
|
||||||
|
entity_md = (REPO_ROOT / "skills" / "gitea-to-github" / "references" / "entity-migration.md").read_text()
|
||||||
|
self.assertIn("<!-- gitea-origin: <gitea-host>/<owner>/<repo>#<number> -->", entity_md)
|
||||||
|
|
||||||
|
def test_gitea_to_github_sibling_skill_handoffs(self):
|
||||||
|
"""Proves projects and gt-usage reference gitea-to-github for legacy Gitea migration."""
|
||||||
|
projects_skill = (REPO_ROOT / "skills" / "projects" / "SKILL.md").read_text()
|
||||||
|
projects_contract = (REPO_ROOT / "skills" / "projects" / "references" / "planning-contract.md").read_text()
|
||||||
|
gt_usage_skill = (REPO_ROOT / "skills" / "gt-usage" / "SKILL.md").read_text()
|
||||||
|
|
||||||
|
self.assertIn("/gitea-to-github", projects_skill)
|
||||||
|
self.assertIn("/gitea-to-github", projects_contract)
|
||||||
|
self.assertIn("gitea-to-github", gt_usage_skill)
|
||||||
|
|
||||||
|
def test_profile_agents_gitea_origin_session_check(self):
|
||||||
|
"""Proves profile/AGENTS.md documents Gitea pull mirroring and local session-start check with sovereign opt-out."""
|
||||||
|
profile_agents = (REPO_ROOT / "profile" / "AGENTS.md").read_text()
|
||||||
|
self.assertIn("Gitea pull mirroring", profile_agents)
|
||||||
|
self.assertIn("/gitea-to-github", profile_agents)
|
||||||
|
self.assertIn("forge: gitea", profile_agents)
|
||||||
|
self.assertIn("git config --bool gitea.sovereign", profile_agents)
|
||||||
|
self.assertIn("project_number:", profile_agents)
|
||||||
|
|
||||||
|
def test_practice_project_labs_protocol(self):
|
||||||
|
"""Proves practice links project-labs.md covering Ugly Heartbeat, scratch labs, Predict-Before-Run, and Code-Tracing."""
|
||||||
|
practice_dir = REPO_ROOT / "skills" / "practice"
|
||||||
|
practice_md = (practice_dir / "SKILL.md").read_text()
|
||||||
|
labs_md = (practice_dir / "references" / "project-labs.md").read_text()
|
||||||
|
record_md = (practice_dir / "references" / "practice-record.md").read_text()
|
||||||
|
|
||||||
|
self.assertNotIn("—", labs_md)
|
||||||
|
self.assertNotIn("/home/", labs_md)
|
||||||
|
self.assertIn("references/project-labs.md", practice_md)
|
||||||
|
self.assertIn("Predict-Before-Run", practice_md)
|
||||||
|
self.assertIn("Ugly Heartbeat", labs_md)
|
||||||
|
self.assertIn("scratch/", labs_md)
|
||||||
|
self.assertIn("Read the Raw Spec", labs_md)
|
||||||
|
self.assertIn("Predict-Before-Run", labs_md)
|
||||||
|
self.assertIn("Code-Tracing", labs_md)
|
||||||
|
self.assertIn("Reasoning trap:", record_md)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
Reference in new issue
Block a user