# Rubric, Canvas Decomposition

Phase 2 of [loop-protocol.md](loop-protocol.md). Evaluates the quality of the
decomposition itself (screenshot + DOM walk → decomposed file), not the
quality of the generated output (that is [rubric-score.md](rubric-score.md)).
Output: score 0–100 + findings.

---

## §Thresholds

| Level | Score | Meaning |
| --- | --- | --- |
| **Excellence** | 85–100 | Complete outside-in decomposition; every element named with its correct primitive |
| **Acceptable** | 65–84 | One level missed or one element misidentified |
| **Failing** | 0–64 | Root container or a major child missed |

**Phase gate: ≥ 65.** A failing decomposition invalidates the Phase 3 score.

---

## §Decomposition Protocol (outside-in, in order)

1. **Root container**, outermost rendered component node (canvas-ui →
   a2ui-root are shells, skipped by the lookup).
2. **Layout strategy**, flex? grid? col-ui? row-ui? raw block?
3. **Primary regions**, header / body / footer, named card slots, panes.
4. **Content regions**, the primitives filling each region.
5. **Leaf nodes**, text, icon, button leaves.
6. **Data binding**, content-carrying attrs (`text=`, `label=`, `value=`,
   `icon=`).

Per level record: element tag, key attrs observed, slot placement if slotted.
Primitive naming comes from `TAG_TO_COMPONENT` in the decompose script, a
lookup, never interpretation.

---

## §Dimensions (0–20 each, total 100)

### D1, Root container identification

| Score | Description |
| --- | --- |
| 18–20 | Correct tag + key attrs recorded |
| 13–17 | Tag correct, attrs incomplete |
| 8–12 | Tag partially correct ("some card element") |
| 0–7 | Root not identified or wrong |

### D2, Layout strategy accuracy

| Score | Description |
| --- | --- |
| 18–20 | Layout primitive named with direction + gap where applicable |
| 13–17 | Layout type correct, gap or direction missing |
| 8–12 | "stacked"/"column" without naming the primitive |
| 0–7 | Layout not described or incorrect |

### D3, Region completeness

Proportional credit for key regions identified (card header, body section,
footer must all be named when present).

### D4, Primitive identification accuracy

`button-ui` not "a button"; `field-ui` not "div with label"; `badge-ui` not
"small colored text". Deduct 3 per misidentified primitive. Floor 0.

Native tags in the tree map to `Native*` names (NativeHeader, NativeH3, …), their presence is itself a quality signal (e.g. `NativeLink` where `link-ui`
belongs).

### D5, Data binding capture

Content attrs (`text=`, `label=`, `value=`, `icon=`, `heading=`) + structural
attrs (`variant=`, `size=`, `gap=`, `columns=`). Deduct 4 per visible attr
missed. Floor 0.

---

## §Screenshot Requirements

- [ ] Taken AFTER canvas settle (the script waits ≥2.5s per prompt).
- [ ] Clip is exactly the `.gallery-canvas-wrap` bounding box.
- [ ] Saved to the cycle's `screenshots/<slug>.png`.
- [ ] Canvas height < 50px → RENDER_FAILURE, skip Phase 3.

---

## §Findings Format

Observations, not judgments:

```json
[
  "Root: card-ui (no size or variant attrs visible)",
  "Layout: col-ui gap=3 inside section slot",
  "Missing: no footer slot populated; actions appear inline in body",
  "D5: button-ui text attr absent, label rendered via ::after pseudo, not captured"
]
```
