Coordinate handoffs

From Fr-e-d/GAAI-framework · View interactive version

Coordinate handoffs is an AI agent skill from the GitHub repository Fr-e-d/GAAI-framework. Validate sub-agent handoff artefacts, sequence phase transitions, and manage retry and escalation logic. Activate after each sub-agent terminates to determine next action.

How to use this skill

Skill file

Coordinate Handoffs

Purpose / When to Activate

Activate after each sub-agent writes its handoff artefact and terminates.

The Orchestrator cannot proceed to the next phase until it has validated the current phase's output. This skill validates artefact structure, interprets verdicts, and returns a clear next-action decision.


Process

After Planning Sub-Agent terminates

  1. Check: does {id}.execution-plan.md exist?
  1. Check: does the execution plan contain required sections? (Implementation Sequence, Edge Cases, Test Checkpoints, Risk Register)
  1. Valid artefact: → PROCEED to Implementation phase

After Implementation Sub-Agent terminates

  1. Check: does {id}.impl-report.md exist?
  1. Check: does impl-report contain required sections? (changes made, criteria mapping, rules applied)
  1. Check: impl-report notes any blocking failures?
  1. Valid artefact: → PROCEED to QA phase

After QA Sub-Agent terminates

  1. Read verdict from {id}.qa-report.md:

1. Rebase on staging (in worktree): git merge staging into story branch

2. Verify build: npx tsc --noEmit in worktree

3. Verify tests: npx vitest run in worktree

3b. Pre-push validation (project-defined commands): detect worker directories with changed source or config files in the story worktree diff, then for each affected worker execute the project-defined pre-push validation commands (see the project's delivery-validation rules in .gaai/project/contexts/rules/infrastructure.rules.md).

4. Push the exact locally admitted Story head to origin.

5. Create or reuse the PR to the configured Delivery target, then bind its repository, PR,

head and base identities to that exact admitted candidate.

6. Immediately persist status: in_progress, phase_status: qa_passed and

pr_status: pending_review, before any hosted observation.

7. Invoke ci-watch-and-fix against the exact bound PR/head/base/run identity.

authority.

publication binding and pending-review persistence for the new exact head.

a retry, push or lifecycle mutation.

8. Wait for an external authority to merge the exact current admitted head. Delivery must not

enable auto-merge, invoke a provider merge mutation or use an admin fallback.

8b. The configured-target watcher verifies that the exact current head landed, then projects

status: done, phase_status: done, pr_status: merged and completed_at. An open or

closed PR, a hosted PASS, local ancestry or remote-branch absence is not terminal evidence.

9. If {id}.memory-delta.md exists in contexts/artefacts/memory-deltas/, validate that the file contains artefact_type: memory-delta in YAML frontmatter AND at least one of the canonical structural sections ## Confirmed Entries, ## Contradicted Entries, ## New Knowledge Candidates. If any check fails: SCHEMA_INVALID — RE-SPAWN QA Sub-Agent with the schema failure appended to the context bundle, up to 2 attempts, then ESCALATE. On ESCALATE after 2 RE-SPAWN attempts: the ESCALATE message MUST include (a) delta path contexts/artefacts/memory-deltas/{id}.memory-delta.md, (b) which check(s) failed — missing artefact_type: memory-delta frontmatter and/or which of the three canonical sections (## Confirmed Entries, ## Contradicted Entries, ## New Knowledge Candidates) were absent, (c) a reference to memory-alignment-check/SKILL.md Outputs section as the canonical schema authority. On PASS: flag the delta in the completion report for Discovery to action via memory-ingest.

9b. (Autonomous triage — daemon wrapper) The daemon wrapper also spawns a bounded Discovery subprocess in draft mode to pre-triage the delta. A new section Memory-Delta Triage (autonomous draft mode) is appended to the wrapper completion output (visible in the delivery log). Fields: drafts_produced, escalated_in_draft, circuit_breaker_tripped (boolean), autonomous_triage_failed (count). If no delta exists or circuit breaker is tripped, the section shows no triage — reason: {no_delta | circuit_breaker_tripped}. This section is additive — it does not replace step 9.

10. Only after the watcher has durably projected the terminal merge may cleanup remove the

worktree or branch. Before then, preserve all resumable state.

NEVER invoke a merge mutation. NEVER treat hosted PASS as merge permission.

After MicroDelivery Sub-Agent terminates (Tier 1)

  1. Read verdict from {id}.micro-delivery-report.md:

Retry Limits

| Phase | Max re-spawns |

|-------|--------------|

| Planning Sub-Agent | 1 retry (2 total) |

| Implementation Sub-Agent | 1 retry per QA cycle (2 total) |

| QA Sub-Agent | Re-runs after each Implementation retry |

| QA FAIL cycles | 2 (before ESCALATE) |

| MicroDelivery Sub-Agent | 1 retry (2 total) |


Escalation Package

When escalating, the Orchestrator surfaces to the human:


Non-Goals

This skill must NOT:


Quality Checks

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.