# Readiness Scoring Algorithm

> **Used by:** step-00-validate (section 4: Calculate Readiness Score)
> **Purpose:** Evaluate module readiness for handoff based on input acceptance criteria.

---

## Algorithm

For each module, evaluate **input** acceptance criteria (AC-01 to AC-07) from `references/acceptance-criteria.md`.

Output ACs (AC-08 to AC-11) are checked **after** step-01 transform, not here.

### Score Calculation

```javascript
const inputACs = ['AC-01', 'AC-02', 'AC-03', 'AC-04', 'AC-05', 'AC-06', 'AC-07'];

// Count passes
const passed = inputACs.filter(ac => results[ac] === 'PASS').length;
const total = inputACs.length;

// Score
const score = (passed / total) * 100;  // Must be 100%
```

### Gate Rules

| Condition | Action |
|-----------|--------|
| Score = 100% | PASS — module ready for transform |
| Score < 100% | BLOCKING — list failed ACs, require fix |

---

## Output Format

### Per-Module Result

```javascript
{
  moduleCode: "Employees",
  score: 100,
  passed: 7,
  total: 7,
  ready: true,
  failedACs: [],
  details: {
    entities: 2,
    useCases: 6,
    rules: 8,
    screens: 4,
    permissions: 5,
    status: "specified"
  }
}
```

### Readiness Table

```
+--------------+----------+-----------+-------+
| Module       | Status   | Score     | Ready |
+--------------+----------+-----------+-------+
| Employees    | specif.  | 7/7 100%  | YES   |
| Absences     | specif.  | 5/7  71%  | NO    |
+--------------+----------+-----------+-------+
```

### Failure Detail (when blocked)

```
Module "Absences" -- 2 input ACs FAILED:

  FAIL AC-05: screens = 0 (min: 1)
    Recovery: Re-run /business-analyse screen specification

  FAIL AC-06: permissions = 0 (min: 1)
    Recovery: Re-run /business-analyse permission specification
```

---

## Recovery Actions

Each failed AC has a specific recovery action (from `references/acceptance-criteria.md`):

| AC | Recovery |
|----|----------|
| AC-01/02 | Re-run /business-analyse entity specification |
| AC-03 | Re-run /business-analyse use case specification |
| AC-04 | Re-run /business-analyse business rules |
| AC-05 | Re-run /business-analyse screen specification |
| AC-06 | Re-run /business-analyse permission specification |
| AC-07 | Run /business-analyse step-04 consolidation |
