# Dispatch Assignment: Explorer M2 Fix 1 (Chunk Sizing & Cache Capacity)

**Assigned Agent:** `explorer_m2_fix_1`  
**Role:** Chunk Sizing & Cache Capacity Explorer  
**Working Directory:** `c:\Projects\FreeExile\.agents\teamwork\explorer_m2_fix_1`  
**Project Scope:** `c:\Projects\FreeExile\.agents\teamwork\orchestrator_11\PROJECT.md`  
**Authoritative Request:** `c:\Projects\FreeExile\.agents\teamwork\ORIGINAL_REQUEST.md` (specifically section `## 2026-10-01T19:19:13Z` - R2)  

## Previous Failure Output & Feedback
Reviewer M2-2 and Challenger M2-1 reported:
- In `tile_map_renderer.js`, `MAX_SLOTS = 4` causes severe LRU cache thrashing across 80% of open-world map coordinates (e.g. at (30, 30)), where 6 to 8 chunks are simultaneously visible on a mobile viewport ($390 \times 844$).
- On a static camera, 3 to 5 chunks are evicted and re-baked on EVERY single frame, directly violating the acceptance criterion: *"Chunk OffscreenCanvas không bị re-render mỗi frame (chỉ re-render khi dirty)"*.
- Challenger harness: `tools/perf/stress_test_lru_cache.js` reproduces 250 bakes over 50 stationary frames.
- Reports:
  - `c:\Projects\FreeExile\.agents\teamwork\reviewer_m2_2\handoff.md`
  - `c:\Projects\FreeExile\.agents\teamwork\challenger_m2_1\handoff.md`

## Mission
Analyze chunk sizing, slot capacity, and RAM budget:
1. Evaluate $8 \times 8$ tile chunks vs $16 \times 16$ tile chunks:
   - For $8 \times 8$ chunks: canvas size is $512 \times 256\text{ px} = 131,072\text{ px} = 524,288\text{ bytes} = 0.5\text{ MB}$.
   - A pool of 12 to 14 slots consumes $14 \times 0.5\text{ MB} = 7.0\text{ MB} \le 8.0\text{ MB}$ total canvas RAM!
   - How many $8 \times 8$ chunks are visible on a $390 \times 844$ screen? Will 12–14 slots prevent thrashing with a comfortable buffer?
2. Or evaluate $16 \times 16$ chunks with expanded slots or tighter culling:
   - If $16 \times 16$ chunks are kept ($2.0\text{ MB}$ each), how can we stay $\le 8.0\text{ MB}$ while avoiding thrashing if $\ge 6$ chunks are visible?
3. Formulate the exact, mathematically sound recommendation for Worker M2:
   - Chunk size (`CHUNK_SIZE`)
   - Max slots (`MAX_SLOTS`)
   - Canvas pixel dimensions (`CHUNK_CANVAS_W`, `CHUNK_CANVAS_H`)
   - Memory calculation in `getMemoryUsage()`
   - Strict guarantee of 0 re-bakes on static camera while keeping canvas RAM $\le 8.0\text{ MB}$.

Write report.md and handoff.md in your directory and notify parent when complete.

## 2026-10-01T20:26:41Z
You are Chunk Sizing & Cache Capacity Explorer.
Your working directory is: c:\Projects\FreeExile\.agents\teamwork\explorer_m2_fix_1
Your dispatch assignment is: c:\Projects\FreeExile\.agents\teamwork\explorer_m2_fix_1\DISPATCH.md
MANDATORY: Read the authoritative user request at:
c:\Projects\FreeExile\.agents\teamwork\ORIGINAL_REQUEST.md (specifically section ## 2026-10-01T19:19:13Z - R2).
Also consult c:\Projects\FreeExile\.agents\teamwork\reviewer_m2_2\handoff.md and c:\Projects\FreeExile\.agents\teamwork\challenger_m2_1\handoff.md.

Analyze chunk sizing and slot capacity:
1. Compare 8x8 chunks (512x256 px, 0.5 MB each, 12-14 slots = 6-7 MB RAM) vs 16x16 chunks.
2. Determine how to completely eliminate LRU cache thrashing across all 120x90 coordinates on mobile viewport (390x844).
3. Guarantee RAM <= 8.0 MB and 0 re-bakes on static camera.

Write report.md and handoff.md in your directory and notify parent when complete.

