| 0 | Dispatch preflight sub-agent | ⛔ You MUST dispatch subagent-preflight.md as a task. ⛔ agent_type: "task" — NEVER "general-purpose". Read the template, then your NEXT action MUST be task. If after reading the template your next action is powershell, view, or anything other than task, STOP — you are executing inline instead of delegating. Writes deploy-checklist.md. view it immediately after return. | deploy-checklist.md | ⛔ You MUST read subagent-preflight.md |
| 1 | Read upstream artifacts | Load prepare-plan.json + scaffold-manifest.json. Check validationResult. Resolve subscription + deployment variables. | — | — |
| 3 | Preflight checks | Auth, mandatory what-if preview, RBAC, RG per deploy-checklist.md § Preflight. | — | ⛔ You MUST read deploy-checklist.md (re-read if compaction occurred) |
| 4 | Deploy approval gate | Present cost + resource summary per deploy-checklist.md § Deploy approval gate format. | — | — |
| 5b | Write deploy-result.json skeleton | ⛔ Read deploy-schemas.ts, write skeleton (status: "in-progress"). Must exist BEFORE first az command. | deploy-result.json | ⛔ You MUST read deploy-schemas.ts |
| 6 | Execute deployment | ⛔ BEFORE az deployment sub create: Generate portal link — $dn="{deploymentName}"; $r="/subscriptions/{subId}/providers/Microsoft.Resources/deployments/$dn"; $l="https://portal.azure.com/#view/Microsoft_Azure_Resources/DeploymentDetails.MenuView/~/overview/id/$($r.Replace('/','%2F'))"; Write-Output "LINK=$l". ⛔ Auto-open link in browser: Start-Process $l 2>$null. Print bare URL in chat (ctrl-clickable).<br>Auto-generate ALL @secure() params (`openssl rand -base64 32 \ | tr -d '/+='), NEVER ask_user for passwords; on retry reuse from deploy-secrets.env` or Key Vault — NEVER regenerate (see deploy-safety.md § Deploy Checklist). THEN deploy IaC. | — | ⛔ You MUST read deploy-checklist.md § Execute deployment |
| 6b | Deploy application code | ⛔ Deploy code for EVERY service in prepare-plan.json.services[]. Follow deploy-checklist.md § Code deploy. | — | ⛔ You MUST read deploy-checklist.md § Code deploy |
| 7 | Health-check + SCM re-disable | HTTP GET per endpoint (max 3 iterations). ⛔ Multi-service apps: Also inspect the response body for error patterns (connection refused, MODULE_NOT_FOUND, localhost, SET-IN-DEPLOY-PHASE) — HTTP 200 alone does not mean functional when the app depends on another service or KV secrets. Then ⛔ for EVERY App Service/Functions app run BOTH commands — no exceptions: az rest --method put --url "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Web/sites/{app}/basicPublishingCredentialsPolicies/scm?api-version=2023-12-01" --headers "Content-Type=application/json" --body '{"properties":{"allow":false}}' then verify: az rest --method get --url "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Web/sites/{app}/basicPublishingCredentialsPolicies/scm?api-version=2023-12-01" --query properties.allow -o tsv (must return false). | deploy-result.json full | ⛔ You MUST read deploy-checklist.md § Health check |
| 8 | Finalize artifacts | ⛔ Read deploy-schemas.ts. ⛔ Re-read deploy-checklist.md § Artifact verification — follow ALL 5 checks. ⛔ No "live"/handoff message until you overwrite the skeleton deploy-result.json — flip status off "in-progress" (→ succeeded/failed) and fill healthStatus, endpoints, completedUtc, deploymentNames, healingAttempts. Write deployment-summary.md (status table + health + portal link(s) + cleanup commands — same content as your handoff message). Update context.json — add "deploy" to completedPhases, currentPhase: null, lastModifiedUtc. Read back to confirm status != "in-progress" and "deploy" ∈ completedPhases. ⛔ Then STOP — return to orchestrator. No further CLI commands. | deploy-result.json final + deployment-summary.md + context.json update | ⛔ You MUST read deploy-schemas.ts + ⛔ Re-read deploy-checklist.md § Artifact verification |
| 9 | Error handling + healing | ⛔ Only if Steps 6/6b/7 returned nonzero exit code or health check failed. Skip entirely on clean deploys. Classify errors, healing loop, PLAN_LEVEL_CHANGE re-approval per deploy-checklist.md § During healing. ⛔ Even on unrecoverable failure: write deploy-result.json with status: "failed" and errorDetails before returning to orchestrator — the artifact must always exist. | — | ⛔ You MUST read error-classification.md |