# Dispatch for worker_chat_m3_2

## 2026-10-01T02:19:05Z

You are worker_chat_m3_2 (worker for Milestone M3: 1M CCU Stress Test & Benchmark Suite).
Your working directory is: c:\Projects\FreeExile\.agents\teamwork\worker_chat_m3_2

## Mandatory Inputs to Read First
1. `c:\Projects\FreeExile\.agents\teamwork\ORIGINAL_REQUEST.md` (specifically section `## 2026-10-01T00:42:05Z`)
2. `c:\Projects\FreeExile\.agents\teamwork\orchestrator_8\plan.md`
3. `c:\Projects\FreeExile\.agents\teamwork\explorer_chat_client_bench_1\handoff.md`
4. `c:\Projects\FreeExile\tests\e2e\test_chat_distributed_system_e2e.py`
5. `c:\Projects\FreeExile\tools/stress/chat_load_benchmark.py`

## MANDATORY INTEGRITY WARNING
DO NOT CHEAT. All implementations must be genuine. DO NOT hardcode test results, create dummy/facade implementations, or circumvent the intended task. A teamwork_preview_auditor will independently verify your work. Integrity violations WILL be detected and your work WILL be rejected.

## File Ownership
You own EXCLUSIVELY:
- `tools/stress/chat_load_benchmark.py`
- `tests/unit/test_chat_load_benchmark.py`

Do NOT touch any files in `client/` or `server/chat/`.

## Mission: Milestone M3 — 1M CCU Stress Test & Benchmark Suite
1. Upgrade `tools/stress/chat_load_benchmark.py`:
   - Enforce Python 3.11+ strict typing (`from __future__ import annotations`), dataclasses with `@dataclass(slots=True, frozen=True)`, and strict line caps (Soft cap <= 350 lines, Hard cap <= 500 lines).
   - Implement concurrent publisher workers using `asyncio.gather` (simulating multiple parallel nodes publishing to shards concurrently).
   - Full 8-channel distribution (World, Zone, Guild, Party, Whisper, System, Recruit, Feedback) testing different fan-out loads.
   - Concurrently stress-test HMAC-SHA256 item snapshot queries via `chat_service.query_item_snapshot` verifying < 2ms latency.
   - Multi-round memory leak regression testing: run multiple rounds (e.g. 3-5 rounds), track memory delta with `tracemalloc`, and verify residual heap growth <= 0.05 MB.
   - Measure and output latency percentiles (p50, p95, p99), verifying SLA p99 < 15.0ms.
   - Support CLI arguments: `--simulated-ccu`, `--active-sample-subscribers`, `--message-count`, `--concurrency`, `--leak-check-rounds`.
2. Implement `tests/unit/test_chat_load_benchmark.py`:
   - Unit tests verifying CLI parsing, percentile calculation math, concurrent publisher logic, memory leak detection logic, and benchmark execution.
   - Run `python -m unittest tests/unit/test_chat_load_benchmark.py`.
3. Run the benchmark tool:
   - Run `python tools/stress/chat_load_benchmark.py --simulated-ccu 1000000 --active-sample-subscribers 5000 --message-count 1000 --concurrency 10 --leak-check-rounds 3`
   - Document latency percentiles, throughput, and memory stats in handoff report.
4. Run Hygiene Lint:
   - Run `python tools/lint/check_code_and_doc_hygiene.py --strict` to verify 0 hard cap violations.

Deliver your report in `c:\Projects\FreeExile\.agents\teamwork\worker_chat_m3_2\handoff.md`.
