Karvey Iterate — The Iteration Engine
Afán = don't stop until the result is really achieved. This skill is where that lives: it takes
what testing/QA/real-runtime surfaced and sends each item back to where it belongs, instead of
letting it die at the end of a linear pipeline.
Purpose
The pipeline (0→12) is the happy path. karvey-iterate is the feedback brain that closes the loop. It does ONE thing: read the findings inbox and route each finding to its correct edge. The phase skills (test, qa, browse) only observe and classify; this skill routes. Keeping routing in one place is the whole design.
Read these rules before acting:
karvey/rules/iteration-loop.md — the three feedback edges, findings.md, the spec-revision sub-cycle, convergence.
karvey/rules/incident-tracking.md — the BUG-NN tracker with state history.
karvey/rules/backlog.md — the dual (Markdown + ClickUp) discovery backlog.
karvey/rules/phase-close.md — the close ritual.
When to run it
- After
test / qa / browse produced findings.
- Any time a finding appears mid-flow ("this spec was wrong", "a new bug showed up", "good idea but out of scope").
- The orchestrator routes you here whenever
findings.md has open items.
Execution steps
Step 1 — Load context
Read:
docs/spec/changes/{change-id}/spec.json
docs/spec/changes/{change-id}/findings.md (the inbox; if it doesn't exist, there's nothing to iterate — tell the user and stop)
docs/spec/changes/{change-id}/requirements.md and spec-delta.md (for spec-gap routing)
docs/spec/project.json (management, repos, backlog_list_id)
If --finding F-NN is given, process only that finding. Otherwise process every open finding.
Step 2 — Confirm/correct the classification of each finding
For each open finding, re-judge its type with the litmus test from iteration-loop.md:
- "Spec is right, code is wrong" →
bug
- "If we'd specified this correctly, impl would differ" →
spec-gap
- "Good idea, but a different change" →
emergent
If a finding's type is ambiguous or its routing is irreversible (re-opening requirements, creating a new change), confirm with the user via AskUserQuestion. In --auto mode, route the unambiguous ones and only stop for the ambiguous/irreversible ones.
Step 3 — Route by type
3a · bug → incident tracker + QA micro-loop
- Promote to a
BUG-NN in the repo's docs/bugs_dev_testing.md (continue the incremental counter — read the file first). Fill priority, detection, component, reproduction, actual vs expected, and open the State history at DETECTADO (see incident-tracking.md).
- Mirror to the global index
docs/spec/incidents-index.md.
- If the cause is unclear → recommend/invoke
/karvey-investigate (Iron Law: no fix without investigating); paste its result as Root cause and move the incident to DIAGNOSTICADO.
- The fix itself runs through the existing micro-loop:
/karvey-impl {change-id} (fix) → /karvey-test {change-id} (incl. its regression test, Step 4C) → /karvey-qa {change-id}. The incident reaches RESUELTO only once a regression test exists.
- If
management=clickup, create/link the ClickUp task and record its id on the BUG-NN.
3b · spec-gap → re-open requirements (spec-revision sub-cycle)
- In
spec.json: set approvals.requirements.approved = false, increment iteration_count, append to revision_history (date, finding id, reason).
- Amend only the affected requirement in
requirements.md + spec-delta.md, keeping PRD traceability. Do not rewrite the whole spec.
- Determine the ripple set — which downstream phases the spec change actually invalidates (mockup? design? architecture? tasks? impl?) — and reset their
approvals.*.approved to false only where affected. Leave untouched phases approved.
- Hand back to the user to re-approve requirements (the gate applies), then the orchestrator drives the affected phases forward again.
- Re-run
test/qa for the affected scope.
Be surgical. The point of the ripple set is to avoid redoing the whole pipeline for a one-line spec fix.
3c · emergent → discovery backlog
- Add to
docs/spec/backlog.md as BL-NN (origin = this change + finding id, rough scope, priority). See backlog.md.
- If
management=clickup, also create it in the backlog_list_id list and record the task id.
- Never absorb emergent scope into the current change silently. It is captured, not done now.
Step 4 — Update findings status
For each routed finding, set status: routed and fill routed to (BUG-NN / spec-delta req / BL-NN) in findings.md. A finding becomes closed only when its destination resolves it (incident RESUELTO, requirement re-approved, or backlog item acknowledged).
Step 5 — Phase-close + knowledge sync
Run the phase-close ritual (phase-close.md): comment + status on management, ensure findings/backlog are synced, update spec.json, sync knowledge (knowledge-sync.md).
Step 6 — Report convergence status
🔁 Iteration routed — {change-id} (iteration #{iteration_count})
Findings processed: {N}
→ bug: {N} (BUG-{list}) → QA micro-loop
→ spec-gap: {N} (requirements re-opened; ripple: {phases})
→ emergent: {N} (backlog BL-{list})
Open findings remaining: {N bug/spec-gap blocking · N emergent captured}
Convergence: {CONVERGED — no open bug/spec-gap, all emergent captured → can proceed to deploy/archive}
{NOT YET — {what's left}}
Next step:
- bugs: /karvey-impl {change-id} → /karvey-test → /karvey-qa
- spec-gap: re-approve requirements, then /karvey {change-id} for the next affected phase
- emergent: captured in backlog; promoted to change-ids at /karvey-archive
Convergence rule (the gate)
A change may proceed to deploy/archive only when findings.md has no open bug or spec-gap and all emergent are captured in the backlog (see iteration-loop.md). emergent findings never block — they only need capturing. This is how the loop is guaranteed to be honored instead of optional.
What this skill does NOT do
- It does not apply fixes (that's
impl) or diagnose root cause itself for complex bugs (that's investigate).
- It does not advance
spec.json:phase forward as a phase skill would — except the controlled backward transition of the spec-revision sub-cycle. It is a support skill that orchestrates feedback, not a new pipeline phase.
Part of the Karvey™ Method — © HainTech, by Mauricio Quezada Ibáñez · Apache 2.0 · see karvey/LICENSE and karvey/TRADEMARK.md. Karvey = Afán, an ona/selknam word.
1---2name: karvey-iterate3description: The iteration engine of the Karvey Method. Reads the change's findings inbox, classifies each finding (bug / spec-gap / emergent) and routes it to the right feedback edge — incident tracker + QA micro-loop, spec-revision (re-open requirements), or the discovery backlog. Turns Karvey from a linear pipeline into a spiral so nothing gets dropped. Triggers include "karvey iterate", "iterar", "iterate", "spec cambió", "spec changed", "salió un bug nuevo", "new bug", "qué hago con esto", "triage findings", "route findings", "loop", "reabrir requirements", "reopen spec", "el spec no estaba bien", "feedback loop", "afán".4---56# Karvey Iterate — The Iteration Engine78> **Afán** = don't stop until the result is really achieved. This skill is where that lives: it takes9> what testing/QA/real-runtime surfaced and sends each item back to where it belongs, instead of10> letting it die at the end of a linear pipeline.1112## Purpose1314The pipeline (0→12) is the happy path. `karvey-iterate` is the **feedback brain** that closes the loop. It does ONE thing: read the findings inbox and **route** each finding to its correct edge. The phase skills (`test`, `qa`, `browse`) only **observe and classify**; this skill **routes**. Keeping routing in one place is the whole design.1516Read these rules before acting:17- `karvey/rules/iteration-loop.md` — the three feedback edges, `findings.md`, the spec-revision sub-cycle, convergence.18- `karvey/rules/incident-tracking.md` — the `BUG-NN` tracker with state history.19- `karvey/rules/backlog.md` — the dual (Markdown + ClickUp) discovery backlog.20- `karvey/rules/phase-close.md` — the close ritual.2122## When to run it2324- After `test` / `qa` / `browse` produced findings.25- Any time a finding appears mid-flow ("this spec was wrong", "a new bug showed up", "good idea but out of scope").26- The orchestrator routes you here whenever `findings.md` has `open` items.2728## Execution steps2930### Step 1 — Load context3132Read:33- `docs/spec/changes/{change-id}/spec.json`34- `docs/spec/changes/{change-id}/findings.md` (the inbox; if it doesn't exist, there's nothing to iterate — tell the user and stop)35- `docs/spec/changes/{change-id}/requirements.md` and `spec-delta.md` (for spec-gap routing)36- `docs/spec/project.json` (management, repos, backlog_list_id)3738If `--finding F-NN` is given, process only that finding. Otherwise process every `open` finding.3940### Step 2 — Confirm/correct the classification of each finding4142For each `open` finding, re-judge its type with the litmus test from `iteration-loop.md`:43- "Spec is right, code is wrong" → `bug`44- "If we'd specified this correctly, impl would differ" → `spec-gap`45- "Good idea, but a different change" → `emergent`4647If a finding's type is ambiguous or its routing is irreversible (re-opening requirements, creating a new change), confirm with the user via AskUserQuestion. In `--auto` mode, route the unambiguous ones and only stop for the ambiguous/irreversible ones.4849### Step 3 — Route by type5051#### 3a · `bug` → incident tracker + QA micro-loop521. Promote to a `BUG-NN` in the repo's `docs/bugs_dev_testing.md` (continue the incremental counter — read the file first). Fill priority, detection, component, reproduction, actual vs expected, and open the **State history** at `DETECTADO` (see `incident-tracking.md`).532. Mirror to the global index `docs/spec/incidents-index.md`.543. If the cause is unclear → recommend/invoke `/karvey-investigate` (Iron Law: no fix without investigating); paste its result as Root cause and move the incident to `DIAGNOSTICADO`.554. The fix itself runs through the existing micro-loop: `/karvey-impl {change-id}` (fix) → `/karvey-test {change-id}` (incl. its regression test, Step 4C) → `/karvey-qa {change-id}`. The incident reaches `RESUELTO` only once a regression test exists.565. If `management=clickup`, create/link the ClickUp task and record its id on the `BUG-NN`.5758#### 3b · `spec-gap` → re-open requirements (spec-revision sub-cycle)591. In `spec.json`: set `approvals.requirements.approved = false`, increment `iteration_count`, append to `revision_history` (date, finding id, reason).602. Amend **only the affected requirement** in `requirements.md` + `spec-delta.md`, keeping PRD traceability. Do not rewrite the whole spec.613. Determine the **ripple set** — which downstream phases the spec change actually invalidates (mockup? design? architecture? tasks? impl?) — and reset their `approvals.*.approved` to `false` **only** where affected. Leave untouched phases approved.624. Hand back to the user to re-approve requirements (the gate applies), then the orchestrator drives the affected phases forward again.635. Re-run `test`/`qa` for the affected scope.6465> Be surgical. The point of the ripple set is to avoid redoing the whole pipeline for a one-line spec fix.6667#### 3c · `emergent` → discovery backlog681. Add to `docs/spec/backlog.md` as `BL-NN` (origin = this change + finding id, rough scope, priority). See `backlog.md`.692. If `management=clickup`, also create it in the `backlog_list_id` list and record the task id.703. Never absorb emergent scope into the current change silently. It is captured, not done now.7172### Step 4 — Update findings status7374For each routed finding, set `status: routed` and fill `routed to` (BUG-NN / spec-delta req / BL-NN) in `findings.md`. A finding becomes `closed` only when its destination resolves it (incident `RESUELTO`, requirement re-approved, or backlog item acknowledged).7576### Step 5 — Phase-close + knowledge sync7778Run the phase-close ritual (`phase-close.md`): comment + status on management, ensure findings/backlog are synced, update `spec.json`, sync knowledge (`knowledge-sync.md`).7980### Step 6 — Report convergence status8182```83🔁 Iteration routed — {change-id} (iteration #{iteration_count})8485Findings processed: {N}86 → bug: {N} (BUG-{list}) → QA micro-loop87 → spec-gap: {N} (requirements re-opened; ripple: {phases})88 → emergent: {N} (backlog BL-{list})8990Open findings remaining: {N bug/spec-gap blocking · N emergent captured}9192Convergence: {CONVERGED — no open bug/spec-gap, all emergent captured → can proceed to deploy/archive}93 {NOT YET — {what's left}}9495Next step:96 - bugs: /karvey-impl {change-id} → /karvey-test → /karvey-qa97 - spec-gap: re-approve requirements, then /karvey {change-id} for the next affected phase98 - emergent: captured in backlog; promoted to change-ids at /karvey-archive99```100101## Convergence rule (the gate)102103A change may proceed to `deploy`/`archive` only when `findings.md` has **no `open` `bug` or `spec-gap`** and **all `emergent` are captured** in the backlog (see `iteration-loop.md`). `emergent` findings never block — they only need capturing. This is how the loop is guaranteed to be honored instead of optional.104105## What this skill does NOT do106107- It does not apply fixes (that's `impl`) or diagnose root cause itself for complex bugs (that's `investigate`).108- It does not advance `spec.json:phase` forward as a phase skill would — except the controlled **backward** transition of the spec-revision sub-cycle. It is a support skill that orchestrates feedback, not a new pipeline phase.109110---111*Part of the Karvey™ Method — © HainTech, by Mauricio Quezada Ibáñez · Apache 2.0 · see `karvey/LICENSE` and `karvey/TRADEMARK.md`. Karvey = Afán, an ona/selknam word.*