# File Allocation Rules

> **Critical reference:** Defines which validation data belongs in `consolidation.json` vs `validation.json`.
> Mixing contents across files is a BLOCKING ERROR.

## Strict Allocation Table

```
+==============================================================================+
|  FILE ALLOCATION REFERENCE — MANDATORY                                       |
+==============================================================================+
|                                                                              |
|  consolidation.json contient UNIQUEMENT :                                    |
|    - crossModuleInteractions                                                 |
|    - sharedEntities                                                          |
|    - permissionCoherence                                                     |
|    - e2eFlows                                                                |
|    - decision (approval)                                                     |
|                                                                              |
|  validation.json contient UNIQUEMENT :                                       |
|    - semanticChecks                                                          |
|    - contractChecks                                                          |
|    - namingAudit                                                             |
|    - acceptanceCriteria                                                      |
|    - globalRiskAssessment                                                    |
|                                                                              |
|  INTERDICTION de melanger les contenus entre les deux fichiers.              |
|  Toute cle ecrite dans le mauvais fichier = ERREUR BLOQUANTE.               |
|                                                                              |
+==============================================================================+
```

## Data Structures

### consolidation.json structure

```javascript
{
  crossModuleInteractions: [
    {
      fromModule: string,
      toModule: string,
      interactionType: "FK-reference|event|shared-lookup",
      description: string,
      entities: string[]
    }
  ],
  sharedEntities: [
    {
      entity: string,
      ownerModule: string,
      referencedBy: string[],
      sharedFields: string[]
    }
  ],
  permissionCoherence: {
    rolesConsistent: boolean,
    pathFormatConsistent: boolean,
    hierarchyRespected: boolean,
    conflicts: any[],
    warnings: any[]
  },
  e2eFlows: [
    {
      name: string,
      modules: string[],
      steps: object[]
    }
  ],
  decision: {
    approved: boolean,
    reason: string,
    approvedBy: string,
    approvedAt: string
  }
}
```

### validation.json structure

```javascript
{
  semanticChecks: [
    {
      check: string,
      status: "PASS|WARNING|ERROR",
      details: string[]
    }
  ],
  contractChecks: [
    {
      module: string,
      check: string,
      details: string
    }
  ],
  namingAudit: {
    auditedAt: string,
    issues: object[],
    approved: boolean,
    renames: object[]
  },
  acceptanceCriteria: [
    {
      module: string,
      criteria: string,
      type: "functional|business-rule|performance|security"
    }
  ],
  globalRiskAssessment: [
    {
      risk: string,
      severity: "low|medium|high",
      mitigation?: string
    }
  ]
}
```

## Data Writing Pattern

Write consolidation.json:
```javascript
ba-writer.enrichSection({
  featureId: {feature_id},
  section: "consolidation",
  data: {
    crossModuleInteractions: [...],
    sharedEntities: [...],
    permissionCoherence: {...},
    e2eFlows: [...],
    decision: {...}
  }
});
```

Write validation.json:
```javascript
ba-writer.enrichSection({
  featureId: {feature_id},
  section: "validation",
  data: {
    semanticChecks: [...],
    contractChecks: [...],
    namingAudit: {...},
    acceptanceCriteria: [...],
    globalRiskAssessment: [...]
  }
});
```

## Validation Checklist

Before writing either file, verify:

- ✓ No keys from consolidation.json appear in validation.json
- ✓ No keys from validation.json appear in consolidation.json
- ✓ All cross-module FK references are in consolidation.json (not validation.json)
- ✓ All semantic check results are in validation.json (not consolidation.json)
- ✓ All naming audit results are in validation.json (not consolidation.json)
- ✓ Client approval decision is in consolidation.json (not validation.json)
- ✓ Risk assessment is in validation.json (not consolidation.json)
