---
name: step-04c-decide
description: Final client approval, write consolidation, proceed to handoff
model: opus
next_step: steps/step-05a-handoff.md
---

> **Context files:** `_shared.md`

# Step 4c: Decide - Final Approval & Consolidation Write

## MANDATORY EXECUTION RULES
- Final client approval is BLOCKING before handoff
- ALWAYS write consolidation section before proceeding
- ALWAYS update workflow state for resume support

## YOUR TASK
Obtain final client approval for the complete application specification, write the consolidation section to feature.json, and prepare for handoff.

---

## EXECUTION SEQUENCE

### 8. Final Client Approval (BLOCKING)

Ask via AskUserQuestion:
```
question: "La spécification complète de l'application est prête. Validez-vous l'ensemble ?"
header: "Approbation"
options:
  - label: "Approuvé"
    description: "Passer au handoff pour la phase d'implémentation"
  - label: "Réviser un module"
    description: "Retourner à la spécification d'un module spécifique"
  - label: "Modifier les interactions"
    description: "Ajuster les interactions cross-module"
```

IF "Réviser un module":
  Ask which module → set currentModuleIndex to that module → load step-03a1-setup.md

IF "Modifier les interactions":
  Re-enter step-04a-collect.md (sections 2-4)

### 9. Write Consolidation

> **STRUCTURE CARD: consolidation** — Must match `application-schema.json`. Follow this structure exactly.

```
ba-writer.enrichSection({
  featureId: {feature_id},
  section: "consolidation",
  data: {
    crossModuleInteractions: [
      {
        "fromModule": "Orders",
        "toModule": "Customers",
        "interactionType": "FK-reference|event-publish|event-subscribe|shared-lookup|cascade-delete|cascade-update",
        "description": "Order references customer via FK",
        "entities": ["Order→Customer"]
      }
    ],
    sharedEntities: [
      {
        "entity": "Customer",
        "ownerModule": "Customers",
        "referencedBy": ["Orders", "Invoices"],
        "sharedFields": ["code", "name"]
      }
    ],
    permissionCoherence: {
      "rolesConsistent": true,
      "pathFormatConsistent": true,
      "hierarchyRespected": true,
      "conflicts": [],
      "warnings": []
    },
    e2eFlows: [
      {
        "name": "Order to Invoice",
        "modules": ["Customers", "Orders", "Invoices"],
        "steps": [
          { "module": "Orders", "action": "Create order", "permission": "sales.orders.create", "dataFlow": "Customer → Order" }
        ]
      }
    ],
    globalRiskAssessment: [
      {
        "risk": "Cross-module coupling complexity",
        "category": "coupling|complexity|dependency-chain|security|scope",
        "severity": "critical|high|medium|low",
        "mitigation": "Event-driven communication instead of direct FK"
      }
    ],
    semanticChecks: [
      { "check": "permission-orpheline", "status": "PASS|WARNING|ERROR", "details": "..." },
      { "check": "uc-sans-fr", "status": "PASS|WARNING|ERROR", "details": "..." },
      { "check": "wireframe-coverage", "status": "PASS|WARNING|ERROR", "details": "..." }
    ],
    decision: {
      "approved": true,
      "reason": "All cross-module validations passed",
      "approvedBy": "Client",
      "approvedAt": "{ISO timestamp}"
    }
  }
})

ba-writer.updateStatus({feature_id}, "consolidated")
```

> **STRUCTURE DIFFERENCES FROM OLD FORMAT:**
> - `crossModuleInteractions` is a FLAT ARRAY (not `{fkReferences, sharedEntities, events}` nested object)
> - `sharedEntities` is TOP-LEVEL (not nested inside crossModuleInteractions)
> - `decision` is an OBJECT with `approved`, `reason`, `approvedBy`, `approvedAt` (not `clientApproval` string)
> - `globalRiskAssessment` is an ARRAY of risk objects (not `{totalEntities: {value, threshold}}`)

Add changelog entry:
```json
{
  "step": "step-04-consolidation",
  "timestamp": "...",
  "changes": [
    "Cross-module interactions: X FK, Y events, Z shared entities",
    "Permission coherence: validated ({count} paths, {conflicts} conflicts resolved)",
    "E2E flows: {count} identified",
    "Global risk: {level}",
    "Client approval: APPROVED"
  ]
}
```

### 10. Workflow State Save (for resume support)

After consolidation approval, update workflow state to enable resume if context is exhausted during handoff steps:

```
ba-writer.enrichSection({
  featureId: {feature_id},
  section: "metadata.workflow",
  data: {
    lastCompletedStep: "step-04-consolidation",
    readyForHandoff: true
  }
})
```

> **Why:** Steps 05a-05b arrive late in the conversation when context may be near exhaustion.
> If BA is interrupted during handoff, the user can resume with `/business-analyse` which will
> detect `lastCompletedStep: "step-04-consolidation"` and resume directly at step-05a.

---

## SINGLE-MODULE MODE

When only 1 module:
1. Auto-approve (no cross-module concerns)
2. Write minimal consolidation section
3. Display: "Module unique - consolidation automatique ✓"
4. Proceed to step-05a-handoff.md

---

## CONTEXT MANAGEMENT

| Loaded | Not Loaded |
|--------|------------|
| _shared.md | Full module feature.json files |
| consolidation data (from steps 04a-04b) | Questionnaires |
| Master feature.json | Templates |

---

## SUCCESS CRITERIA

- Client approval obtained (or auto-approved for single module)
- Consolidation section written to master feature.json
- Status updated to "consolidated"
- Workflow state saved for resume support
- Ready to proceed to handoff phase

---

## NEXT STEP

Load: `./step-05a-handoff.md`
