# Ultimate Optical Reliability Bundle Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Achieve a 98–100% optical camera scan recognition rate by calibrating QR versions (Versions 10, 12, 15), Error Correction Level M (15% error tolerance), 7 FPS shutter-synchronized presets, and expanded 400px/450px display sizing.

**Architecture:** Update `transmitter.html` with Level M `safeRawCapacityMap`, update default version dropdowns to include Version 12 & 15, set default FPS slider/presets to 7 FPS, and expand QR container size options up to 450px. Update test suites and documentation.

**Tech Stack:** Vanilla JavaScript (ES6+), HTML5 Canvas, `easy.qrcode.min.js`, `qr-scanner`, Node.js.

## Global Constraints
- Pure client-side JavaScript execution in browser.
- Backward-compatible binary packet layout and Base64 string encoding.
- Zero external runtime server dependencies.

---

### Task 1: Update Transmitter UI and Parameter Calibration

**Files:**
- Modify: `transmitter.html`

**Interfaces:**
- Consumes: `easy.qrcode.min.js`, `LTEngine`

- [ ] **Step 1: Update `getChunkSizeForVersion()` and Error Correction Level in `transmitter.html`**

In `transmitter.html`:
1. Update `getChunkSizeForVersion()`:
   ```javascript
   function getChunkSizeForVersion(version) {
       const safeRawCapacityMap = {
           1:  12,   // Base64 = 16 chars (Max QR V1 Level M = 14 B)
           5:  60,   // Base64 = 80 chars (Max QR V5 Level M = 84 B)
           10: 158,  // Base64 = 212 chars (Max QR V10 Level M = 213 B)
           12: 204,  // Base64 = 272 chars (Max QR V12 Level M = 272 B)
           15: 272   // Base64 = 364 chars (Max QR V15 Level M = 367 B)
       };
       let rawCapacity = 158; // Default for Auto mode (Version 10)
       if (version && safeRawCapacityMap[version]) {
           rawCapacity = safeRawCapacityMap[version];
       } else if (version && version !== 'auto') {
           if (version < 5) rawCapacity = 12;
           else if (version < 10) rawCapacity = 60;
           else if (version < 12) rawCapacity = 158;
           else if (version < 15) rawCapacity = 204;
           else rawCapacity = 272;
       }
       const headerLen = 16;
       return Math.max(1, rawCapacity - headerLen);
   }
   ```
2. Set `correctLevel: QRCode.CorrectLevel.M` in offscreen QRCode options.
3. Update Version select options in HTML:
   - `<option value="auto" selected>Auto (Version 10 - Optimal)</option>`
   - `<option value="10">Version 10 (57x57)</option>`
   - `<option value="12">Version 12 (65x65)</option>`
   - `<option value="15">Version 15 (77x77)</option>`
4. Update Speed Presets in UI:
   - **Standard (5 FPS)**
   - **🚀 High Speed (7 FPS - Mobile Sweet Spot)**
   - **⚡ Ultra Speed (10 FPS)**
   Set default FPS slider value to `7`.
5. Add Display Size options to dropdown:
   - `<option value="400">Huge (400x400)</option>`
   - `<option value="450">Max (450x450)</option>`

- [ ] **Step 2: Verify pre-rendered generation in browser**

Run `python3 server.py 8443`, select Auto (Version 10) or Version 12, click **Generate Movie**, and verify pre-rendered frames render with Level M error correction and 7 FPS default speed.

- [ ] **Step 3: Commit**

```bash
git add transmitter.html
git commit -m "feat: calibrate transmitter for Level M error correction, Version 10/12/15, 7 FPS presets, and 450px display size"
```

---

### Task 2: Update Integration Test Suite and Verification

**Files:**
- Modify: `test_receiver_integration.js`

- [ ] **Step 1: Update `test_receiver_integration.js` for Level M capacities**

Update `test_receiver_integration.js` to slice source blocks using $L = 142$ bytes (Level M Version 10 capacity).

- [ ] **Step 2: Run unit and integration tests**

Run: `node test_lt_engine.js && node test_receiver_integration.js`
Expected: PASS with "ALL RECEIVER INTEGRATION TESTS PASSED!"

- [ ] **Step 3: Commit**

```bash
git add test_receiver_integration.js
git commit -m "test: update integration tests for Level M Version 10 capacities"
```

---

### Task 3: Update Documentation and ADRs

**Files:**
- Modify: `README.md`
- Modify: `README.ko.md`
- Modify: `docs/adr/0001-animated-qr-code-frame-streaming.md`

- [ ] **Step 1: Update README and README.ko.md**

Update version options, Level M error correction notes, 7 FPS sweet spot preset documentation, and capacity benchmark tables in English & Korean README files.

- [ ] **Step 2: Update ADR 0001**

Document Level M error correction and Version 10/12/15 optical density calibration.

- [ ] **Step 3: Commit**

```bash
git add README.md README.ko.md docs/adr/
git commit -m "docs: update README and ADRs for ultimate optical reliability bundle"
```
