···124124 - Added small docs and `#[must_use]` on relevant fns; marked a few helpers `const` where safe.
125125 - Cargo metadata filled in to silence cargo_common_metadata; clippy now passes with `-D warnings` across all targets.
126126 - Ran `cargo fmt`, `cargo clippy --all-targets --all-features -D warnings`, and `cargo test`: all green.
127127+ - Conducted a full code review of the `tic80_rust` crate. Findings are positive; suggestions for minor refactorings have been logged in `docs/roadmap/todos_code_review.md` and a summary added to `docs/adr/codereviews/001.md`.
128128+ - Performed a second code review. The summary is located at `docs/adr/codereviews/002_ai_review.md` and actionable suggestions are in `docs/roadmap/todos_from_ai_review.md`.
127129128130**Docs Index**
129131- Start here: `docs/README.md`
+3
docs/README.md
···77- `docs/roadmap/gui_first.md`: Combined GUI-first kickoff + milestones for `winit + pixels` and `cls/pix`.
88- `docs/roadmap/editor_livecoding.md`: Livecoding editor plan (TIC‑80 UI vibes): CODE + CONSOLE only.
99 - `docs/roadmap/todos_code_review.md`: Rolling TODOs from code review (high/medium/low priority) with checkboxes.
1010+ - `docs/roadmap/todos_from_ai_review.md`: Rolling TODOs from AI code review (2025-08-27).
10111112## Specs
1213- `docs/specs/memory_map.md`: Canonical pointer to the root `MEMORY_MAP.md` and usage notes.
···3031- `docs/adr/0001-winit-pixels.md`: Windowing/presentation stack decision.
3132- `docs/adr/0002-mlua-lua54-compat.md`: Lua 5.4 choice (superseded).
3233- `docs/adr/0003-lua53-with-compat.md`: Lua 5.3 with 5.1/5.2 compatibility.
3434+- `docs/adr/codereviews/001.md`: Code review summary (2025-08-27).
3535+- `docs/adr/codereviews/002_ai_review.md`: AI-generated code review summary (2025-08-27).
33363437Notes
3538- `MEMORY_MAP.md` at repo root remains the canonical reference for layout. Specs here link to it rather than duplicating.
+20
docs/adr/codereviews/002_ai_review.md
···11+# Code Review Summary (AI Agent, 2025-08-27)
22+33+This document contains the summary of a comprehensive code review performed by an AI agent on the `tic80_rust` crate.
44+55+## Overall Assessment
66+77+The project is in excellent condition. It is built on a solid architectural foundation, follows exemplary documentation and testing practices, and demonstrates a clear focus on achieving parity with TIC-80's behavior. The code quality is consistently high.
88+99+## Key Strengths
1010+1111+- **Documentation-First Culture:** The project's most significant asset is its comprehensive and well-maintained documentation, including a clear roadmap, detailed specifications, and diligent use of ADRs.
1212+- **Robust Testing Strategy:** The test suite is thorough, covering graphics, memory, the Lua API, and audio analysis. The use of deterministic frame hashing is particularly effective.
1313+- **High Code Quality:** The codebase is clean, idiomatic, and adheres to a strict linting policy.
1414+- **Focus on Parity:** The implementation shows careful attention to replicating TIC-80's specific behaviors, from VRAM memory layout to API semantics.
1515+1616+## Actionable Suggestions
1717+1818+A short list of minor, non-critical suggestions for improvement has been compiled. There are **no high-priority issues** requiring immediate attention. The suggestions primarily focus on minor refactoring opportunities to reduce code duplication and enhance clarity.
1919+2020+These suggestions have been logged in a separate document: `docs/roadmap/todos_from_ai_review.md`.
+22
docs/roadmap/todos_from_ai_review.md
···11+# Code Review TODOs (from AI Review 2025-08-27)
22+33+This is a prioritized list of actionable suggestions generated from the AI code review on 2025-08-27. The full summary can be found in `docs/adr/codereviews/002_ai_review.md`.
44+55+## Medium Priority
66+77+- **[ ] [VQT] Consolidate VQT API implementation:** In `script/lua_runner.rs`, the 12 VQT-related Lua functions (`vqt`, `vqts`, `vqtr`, etc.) are implemented as separate closures. This creates significant code repetition.
88+ - **Suggestion:** Refactor this into a single helper function or macro that takes query parameters (e.g., bin, smoothing, raw, whitened) to dispatch to the correct buffer in `VQTState`. This would improve maintainability.
99+1010+- **[ ] [main] Refine `AudioState` struct:** The `AudioState` struct in `main.rs` has accumulated numerous fields for debugging and statistics (`fx_fft_acc_ns`, `last_pushed`, `ema_samples_per_tick`, etc.).
1111+ - **Suggestion:** Group related statistics fields into dedicated sub-structs (e.g., `FxStats`, `RingBufferStats`). This would make `AudioState` cleaner and the associated logic more modular.
1212+1313+## Low Priority / Nitpicks
1414+1515+- **[ ] [FFT/VQT] Clarify `get_global_*` pattern:** The use of `OnceLock` for the global `FFTState` and `VQTState` is a pragmatic solution for accessing audio data from single-threaded Lua callbacks.
1616+ - **Suggestion:** Add a small comment to the `FFT_SHARED` and `VQT_SHARED` static declarations explaining *why* this pattern is used (e.g., "Global state for easy access from Lua callbacks, which don't easily accommodate passing user data through C boundaries.").
1717+1818+- **[ ] [main] Redundant `help` check:** In `main.rs`, the `if args.help` block appears twice consecutively. The second instance is unreachable.
1919+ - **Suggestion:** Remove the duplicate block.
2020+2121+- **[ ] [docs] Add a diagram:** The documentation is excellent, but a high-level component diagram could enhance its accessibility.
2222+ - **Suggestion:** Consider adding a simple Mermaid diagram to `docs/architecture/runtime.md` showing the interaction between the main components (`main loop`, `winit`, `pixels`, `cpal`, `ring buffer`, `FFT/VQT State`, `LuaRunner`).