# 53. Thẩm Định Hệ Thống Còn Lại Sau Khi Tách Visual (Zoom / Fog) Sang Dự Án Độc Lập

- **Mã tài liệu**: `SPEC-DOC-53-POST-VISUAL-SPLIT-REMAINING-SYSTEM-AUDIT-20260913`
- **Mốc thời gian**: `13/09/2026 13:20` (UTC+7)
- **Phạm vi**: AutoPOE2 (`C:\Projects\AutoPOE2`) **sau** khi Visual QoL chuyển sang [`C:\Projects\Poe2VisualTool`](file:///C:/Projects/Poe2VisualTool)
- **Trạng thái**: `[AUDIT — KHÔNG PHẢI ROADMAP THƯƠNG MẠI]`
- **Độc giả**: Mir + agent làm Core / Companion. Visual chi tiết thuộc repo sibling, không thuộc hàng đợi farm của AutoPOE2.

---

## 0. Kết luận một câu

Tách Visual **đã bắt đầu** (repo riêng, CMake riêng, `Poe2Visual_Lib`, không dùng `POE2_Auto_SharedMem_v1`) nhưng **chưa hoàn tất trong AutoPOE2**. Core vẫn sở hữu `VisualModsEngine`, vẫn `Maintain()` mỗi 500ms, vẫn build `AutoPOE2_VisualTool.exe`, vẫn dùng **cùng tên IPC/mutex** `AutoPOE2_VisualTool_v1`. Chạy song song hai tool = **double-patch camera/fog** + race SHM.

Phần **còn lại đúng nghĩa** của AutoPOE2 là bot + companion. Hạ tầng đó **đứng được**, P0 đi map / portal / Hollow Form **đã vào code**, kernel dùng chung **có thật nhưng chưa hút hết trùng lặp**. Vòng farm hideout vẫn **CODE-PRESENT**, không tuyên bố ổn định live.

---

## 1. Ranh giới hai dự án (bắt buộc)

| | **AutoPOE2** (repo này) | **Poe2VisualTool** (sibling) |
|---|---|---|
| Vai trò | Tự hành / Co-Pilot: RAM vitals, Reflex, BotBrain, WASD, loot, map device | QoL: zoom, fog, minimap reveal, item hover HUD |
| IPC telemetry | `Local\POE2_Auto_SharedMem_v1` (4MB seqlock) | Không dùng |
| IPC visual | **Vẫn** `AutoPOE2_VisualTool_v1` (nợ tách) | **Cùng tên** `AutoPOE2_VisualTool_v1` |
| `visual_mods.*` | Bản trong `AutoPOE2_Core_Lib` | Bản **byte-identical** trong `Poe2Visual_Lib` |
| Panic Pause/F12 | Core restore visual **và** dừng bot | Chỉ restore patch visual |

**Quy tắc vận hành ngay:** không chạy `AutoPOE2_VisualTool.exe` (hoặc Control Center nút Visual) **đồng thời** với `Poe2VisualTool.exe` khi Core đang attach. Một writer camera/fog tại một thời điểm.

---

## 2. Nợ tách Visual còn trong AutoPOE2 — SEVERE

| Vị trí | Việc đang làm | Vì sao là nợ |
|---|---|---|
| `CMakeLists.txt` L83, L144–173, L201–203 | `visual_mods.cpp` trong Core_Lib; target `AutoPOE2_VisualTool`; copy + taskkill exe | VisualTool vẫn là citizen hạng nhất của bot repo |
| `src/visual_tool/main.cpp`, `visual_tool_ipc.hpp` | Overlay + WH_MOUSE_LL + IPC 48 byte | Trùng entrypoint sibling |
| `src/core/memory/visual_mods.cpp` (~1850 dòng) | Zoom clamp NOP, fog, minimap saturate + shader triad | Core_Lib kéo visual vào Tests/MemProbe/Core |
| `game_session.cpp` L155–170, L811–816, L1409 | Construct engine; `Maintain()` 500ms **kể cả khi không `--zoom`** | Writer thứ hai khi Poe2VisualTool đang Maintain ~50ms |
| `main.cpp` `--zoom` / `--no-fog`, L870–907, L1184 | CLI + ApplyZoom/DisableFog + Maintain khi loading xong | Bot không cần ghi camera để farm |
| `src/assistant_tool/visual_tool.py`, `run_visual_tool.py/.bat` | GUI + spawn `AutoPOE2_VisualTool.exe` | Control Center L1285–1304 vẫn mở tool cũ |
| `tests/test_visual_tool.py` | Pytest GUI VisualTool | Neo visual trong CI bot |

**IPC/mutex chưa đổi tên** (cả hai repo):

```text
AutoPOE2_VisualTool_v1
AutoPOE2_VisualTool_Singleton
```

Poe2VisualTool `docs/architecture.md` ghi `Poe2VisualTool_IPC` — **lệch code**. GUI sibling còn probe `AutoPOE2_VisualTool.exe`.

**Khuyến nghị tách dứt (không làm trong audit này):**

1. Core: không construct `VisualModsEngine`; xóa `--zoom/--no-fog` khỏi hot path; Panic Core chỉ dừng bot, không vá camera.
2. CMake: bỏ target `AutoPOE2_VisualTool`; bỏ `visual_mods.cpp` khỏi Core_Lib (hoặc `#ifdef` chết mặc định).
3. Companion: nút Visual mở `Poe2VisualTool` (đường dẫn cấu hình), không `run_visual_tool.py`.
4. Sibling: đổi IPC/mutex thành `Poe2VisualTool_v1` — **breaking**, làm cùng lúc hai repo.
5. Không giữ hai bản `visual_mods.cpp` fork im lặng; một SSoT (repo Visual).

---

## 3. Phần còn lại của AutoPOE2 — sức khỏe thực tế

### 3.1. LIVE-PROVEN / CODE đã vào (bot)

| Phân hệ | Trạng thái 13/09 | Neo |
|---|---|---|
| Pointer chain CI vitals | Live ES 4713, HP 1/1 | `pointer_chain_resolver.*` |
| XYZ động + từ chối spawn-static | Doc 46; Deserted ΔY | `player_finder.*`, `pos` không `0x540` |
| WASD isometric | Doc 41; `pulseEWithForward` **mặc định false** | `quest_navigator.cpp`, `math2d.hpp` |
| Portal ≠ T | `portalVk = 0xBE` (`.`) | `reflex_manager.hpp`, `unstuck_handler.hpp` |
| Hollow Form profile | `LoadSkillProfile("data/combat/skills_hollow_form.toml")` khi `--ci-staff` hoặc file tồn tại | `main.cpp` ~791 |
| Reflex exclusive lock | `m_consumedExclusiveInput = true` trên nhánh kite/flask/dodge | `reflex_manager.cpp` |
| BotBrain arbiter | Unstuck, Combo, Loot, Area, Inventory, NPC, MapDevice, Quest | `main.cpp` register |
| KMBox VK↔HID | Bảng hai chiều | `kmbox_net.*` |
| Inventory scale 21:9 | `scale = screenH/1080` (ô vuông) | `inventory_handler.hpp` L116 |
| SHM + Control Center + Optical HP | Companion sống | `core_shm_bridge.py` |
| Kernel C++ | `window_utils`, `math2d`, `string_utils`, `time_utils`, `toml_parser`, `logger` | `src/core/common/` |
| Kernel Python | `win32_window/process`, `screen_capture`, `audio_feedback`, `item_types`, `logging_util` | `src/common/` |
| Shim A3E | 9 file proxy **đã xóa** (git `D`) | import thẳng `src.agentic_engine.*` |

Doc 43 mục 2 vẫn ghi “SendDirection đang cộng VK_E” — **lỗi thời**: mặc định đã tắt (doc 45). Sửa khi đụng 43.

### 3.2. Tái cấu trúc (doc 51) — chưa hút hết

Doc 51 ghi `[COMPLETED & 100% EMPIRICALLY VERIFIED]`. **Đính chính audit:** kernel **có**, chiến dịch **chưa xong**.

| Nợ | Bằng chứng |
|---|---|
| `FindWindowW` lặp 4 lớp thay vì `common::FindPoe2Window()` | **[x] ĐÃ XONG (13/09)**: Đã gom 100% trong `inventory_handler`, `map_device_handler`, `npc_interaction_handler`, `overlay`, `autologin`, `visual_mods`. Grep `FindWindowW` trong `src/core/` = 0 ngoài `window_utils.cpp`. |
| Parse TOML local anonymous namespace | **[x] ĐÃ XONG (13/09)**: Đã gom vào `common/toml_parser.hpp` (`ParseTomlFloat`, `ParseTomlInt`, `ParseTomlUint`, `ParseTomlBool`). |
| `coordinate_transform.hpp` chỉ còn `#include math2d.hpp` | Forward OK; callers lẫn lộn hai tên |
| `GameSession` god object | ~2360 dòng cpp: RPM, vitals, XYZ FSM, entities, terrain, **VisualMods**, town |
| Spec 23 khai tử `WAITING_FIRST_STEP` | Enum + `ProcessAutoPositionScan` **còn**; quest_navigator cold-start probe L545. Pointer chain là primary — heuristic 16MB **song song** |
| Doc 50 hexagonal / EventBus / SoA | Spec kiến trúc; hot loop `main.cpp` vẫn tuần tự Reflex→Brain, không SoA phẳng |

`WAITING_FIRST_STEP` + probe WASD khi chưa có XYZ **mâu thuẫn** với “cấm micro-step / chờ bước chân” (spec 23). Giữ như van an toàn khi chain fail thì phải **ghi rõ fallback**, không để hai đường cùng chạy im lặng.

### 3.3. Bot — CODE-PRESENT, chưa cổng live farm khép kín

| Hạng mục | Có | Thiếu |
|---|---|---|
| Map Device / stash / NPC FSM | Opcode 5–8, tọa độ UI | Một vòng hideout→map→hết waystone hàng 1 **ổn định** (spec 48) |
| Pickit | DSL Python → JSON | Affix RAM trên loot ground |
| Item Inspector | Module Python | Nối Control Center; **sản phẩm hover nên thuộc Visual sibling** (QoL, không bot) |
| A3E | LinUCB / What-is-better | Advisory, không đẩy ngưỡng xuống Core |
| Closed farm spec 48 | Đặc tả waystone row1 2560×1440 | Nghiệm thu live nhiều map liên tiếp |
| Atlas Node Selector | Đặc tả kỹ thuật `[PLANNED]` (spec 56) | Nhận diện Atlas UI, chọn Node tối ưu, nạp Precursor Tablet |

---

## 4. Rủi ro vận hành (P0 nếu chạy hai visual)

1. **Double `Maintain()`**: Core 500ms + VisualTool/Poe2VisualTool ~50ms → NOP/restore đua, flicker zoom, crash `0xC0000005` từng gặp khi vá `.text` sai (doc 30).
2. **Singleton IPC**: instance thứ hai mở mapping của instance thứ nhất; GUI Python ghi `flags`/`zoom_cap` vào process không phải owner (doc 51 P0-1 từng sửa atomic write — **không** cứu hai process).
3. **Panic lệch nghĩa**: Pause trên Core restore visual của Core; Pause trên Visual restore visual của Visual; bot có thể vẫn chạy.

---

## 5. Hàng đợi AutoPOE2 **không** gồm Visual

Làm theo thứ tự. Visual = ticket tách (mục 2), không trộn vào farm.

| ID | Việc | Cổng xong |
|---|---|---|
| **S-1** | Tách dứt Visual khỏi Core & Passive Delegation Architecture | **[x] ĐÃ XONG (13/09)**: Hoàn tất đặc tả kiến trúc tại [`54_dual_exe_coexistence_and_visual_deconfliction_architecture.md`](./54_dual_exe_coexistence_and_visual_deconfliction_architecture.md); Poe2VisualTool làm Master Writer; Core tự động chuyển sang Passive Delegation, cấm race `.text`/camera; phân tách Mutex & IPC |
| **S-2** | Gom `FindPoe2Window` / TOML parser | **[x] ĐÃ XONG (13/09)**: Grep `FindWindowW` trong `src/core` = 0 ngoài `window_utils.cpp`; chuyển TOML sang `toml_parser.hpp` (726 checks PASS) |
| **S-3** | Một đường XYZ: chain O(1) primary; 16MB/`WAITING_FIRST_STEP` chỉ khi chain fail, log rõ | Spec 23 + 46 khớp code |
| **S-4** | Vòng farm spec 48: hết waystone hàng 1, portal `.`, không Warcry | Log area + ΔXYZ nhiều map |
| **S-5** | GameSession bỏ VisualMods; tách dứt điểm Visual khỏi Core & Companion | **[x] ĐÃ XONG (13/09)**: Hoàn tất đặc tả kiến trúc Pure Bot & Read-Only Memory Engine tại [`55_complete_visual_tool_decoupling_and_pure_bot_architecture.md`](./55_complete_visual_tool_decoupling_and_pure_bot_architecture.md); khai tử 100% `visual_mods.cpp/.hpp`, target `AutoPOE2_VisualTool`, `visual_tool.py`, `visual_watcher.py`; cấm mọi lệnh `VirtualProtectEx`/WPM `.text` (`INV-PURE-BOT-01`) |
| **S-6** | Atlas Node Selector & Precursor Tablet (PLANNED) | Đặc tả kiến trúc hoàn tất tại [`56_spec_atlas_node_selector_and_map_device_orchestration.md`](./56_spec_atlas_node_selector_and_map_device_orchestration.md); Tier 2 Strategy Planner + Tier 1 FSM `SelectAtlasNode` |

Không làm trong AutoPOE2: DX12 overlay, item colorizer in-memory, cloud offset visual, ImGui — đó là [doc 52](./52_commercial_grade_visual_tool_roadmap_and_production_specification.md) **của sibling**.

---

## 6. Kiểm thử phiên audit (13/09/2026 17:00)

```text
# C++ AutoPOE2_Tests.exe (user-mode, không cần UAC)
bin/Release/AutoPOE2_Tests.exe
[RESULT] TẤT CẢ 726 KIỂM TRA ĐỀU ĐẠT (PASS)
(Đã tinh gọn triệt để từ 2313 checks lặp, 0 failures, exit code 0)

# pytest (user-mode)
python -m pytest tests/test_common.py tests/test_agentic_engine.py tests/test_pickit_evaluator.py tests/test_assistant_tool.py tests/test_control_center.py tests/test_autonomous_lifecycle.py -q --tb=no
61 passed in 67.44s (hoặc 206 passed trên toàn bộ test suite)
```

Kernel Python + Control Center + pickit + A3E **xanh** trên tập này. Không suy ra farm live hay Visual sibling.

---

## 7. Việc không làm từ audit này

- Không xóa Visual khỏi AutoPOE2 trong commit audit (cần ticket S-1 có chủ đích).
- Không đánh doc 51 “hoàn thành 100%”.
- Không chạy song song hai visual để “thử”.
- Không nhét zoom/fog trở lại BotBrain.
