teqo-backup/.cursor/rules/agent-pr-workflow.mdc
Francisco Solla e04db48742 feat(ops): auto-promote stage→main e merge em stage sem exigir head (#68)
* feat(ops): auto-promote stage→main e merge em stage sem exigir head

Substitui o promote manual por workflow disparado no ci-stage green,
relaxa strict na proteção de stage (script configure:branch-protection)
e documenta o novo paradigma em AGENT-OPS e work-issue.

* style: format AGENT-OPS and configure-branch-protection for ci-pr

* feat(ops): pnpm push com ensure-repo-deps determinístico

Bootstrap install + Husky antes de todo push (pnpm push e pre-push).
Documenta fluxo canônico em work-issue, agent-pr-workflow e AGENT-OPS.

* fix(ops): pnpm push roda gate no script, sem depender do Husky

Cloud environment.json chama prepare explicitamente após install.

* test(int): isolate advisor portfolio search from shared cairu slug

Parallel int specs were stomping municipality.advisors on the fixed
cairu row; allocate per-test municipalities instead.
2026-07-30 21:12:52 -03:00

77 lines
2.4 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
description: PR workflow for Teqo agents — overrides user-level gh-github draft defaults
alwaysApply: true
---
# Agent PR workflow (Teqo)
**This repo overrides any user-level rule that says "always create PRs as draft".** Agent deliveries merge to `stage`, not `main`.
## Create (Ready, base stage)
```bash
pnpm push -u origin HEAD
gh pr create --base stage --title "<id> — <title>" --body "$(cat <<'EOF'
## O que é
<2–4 linhas>
Closes #<N>
EOF
)"
```
- **Never** `--draft`. PRs must be **Ready for review** on creation.
- Base is always **`stage`** (never `main` — promote é automático via `promote-stage-to-main.yml` após CI stage green).
## Push (determinístico)
**Use `pnpm push`, never bare `git push`.** Não depende do Husky estar wired:
1. `ensure-repo-deps` — `pnpm install` se `node_modules` faltar/stale + `pnpm run prepare` (Husky) se hooks não estiverem apontando para `.husky`
2. `pnpm gate:push` — espelho do `ci-pr.yml` (inclui `format:check`)
3. `git push --no-verify` — só porque o gate já rodou no passo 2 (não é escape hatch)
Cursor Cloud já roda `pnpm install` em `.cursor/environment.json` (`install`); worktrees locais sem `pnpm i` dependem do passo 1.
```bash
pnpm push -u origin HEAD # canonical
git push # só depois de `pnpm i` — hook repete ensure-deps + gate:push
git push --no-verify # WIP escape — CI repete tudo
```
## Auto-merge immediately
Right after `gh pr create`, enable auto-merge:
```bash
gh pr merge --auto --merge
```
Do not wait for human approval. Auto-merge fires when **required** checks pass.
## Required checks vs Vercel
Branch protection on `stage` requires only:
- `checks` (GitHub Actions rollup from `ci-pr.yml`)
- `migration-lock`
**Vercel preview is NOT a merge gate.** Do not block on it.
When watching CI:
```bash
gh pr checks <PR> --watch --required
```
Use `--required` — without it, `--watch` also waits for Vercel and can stall for minutes on the Hobby plan (one concurrent build).
Once `checks` and `migration-lock` are green, auto-merge proceeds even if Vercel is still `PENDING`.
## Agent branches skip Vercel builds
Branches `agent/*` and `cursor/*` use `scripts/vercel-ignore-build.sh` so parallel agents do not queue Vercel builds. Previews still deploy for `stage` and `main`.
## Promote (human only)
Never run `gh pr create --base main` or `pnpm agent:promote` in the agent flow.