# Handoff Report — Level 1-100 Piecewise Exponential EXP Curve & Database Schema Survey

**Agent**: `spec_miner_survey_exp_1`  
**Recipient**: `orchestrator_4` (`6f4a2aa2-4315-4660-8cb7-8352a7220c95`)  
**Date**: 2026-10-01  
**Handoff Type**: Hard (Task Complete)  

---

## 1. Observation
1. **Database Schema & Content (`data/game_design_matrix.db`)**:
   - Inspected `progression_benchmarks` table via SQLite:
     ```sql
     CREATE TABLE progression_benchmarks (
         level INTEGER PRIMARY KEY CHECK (level BETWEEN 1 AND 100),
         target_exp INTEGER NOT NULL CHECK (target_exp > 0),
         player_base_hp REAL NOT NULL CHECK (player_base_hp > 0),
         player_benchmark_dps REAL NOT NULL CHECK (player_benchmark_dps > 0),
         monster_base_hp REAL NOT NULL CHECK (monster_base_hp > 0),
         monster_base_dps REAL NOT NULL CHECK (monster_base_dps > 0),
         max_affix_tier_allowed INTEGER NOT NULL CHECK (max_affix_tier_allowed BETWEEN 1 AND 15)
     )
     ```
   - Current rows 1 to 100:
     - Level 1: `(1, 500, 100.0, 20.0, 80.0, 12.0, 15)`
     - Level 2: `(2, 1802, 128.0, 22.4, 88.0, 13.1, 15)`
     - Level 99: `(99, 2459773, 2844.0, 1331668.8, 911114.9, 55844.2, 1)`
     - Level 100: `(100, 2505936, 2872.0, 1491469.0, 1002226.4, 60870.2, 1)`
   - The delta between level 99 and 100 is only $46,163$ EXP ($2,505,936 - 2,459,773$), which is $1.87\%$ of Level 99.

2. **Seeder Logic (`server/world/game_design_matrix_seeder.py:241-256`)**:
   - `target_xp` is generated by `int(500 * (lvl ** 1.85))`.
   - This is a single smooth power curve, lacking the 7 distinct piecewise exponential phases required by `ORIGINAL_REQUEST.md`.

3. **Service Validation & Anti-Drift Engine (`server/world/game_design_matrix_service.py:240-248`)**:
   - `validate_game_design_integrity()` executes:
     `SELECT level, target_exp FROM progression_benchmarks ORDER BY level ASC`
     and records a violation if `r["target_exp"] <= prev_xp`.
   - `tools/lint/verify_game_design_matrix.py` executes successfully with `[PASS]`.

4. **Ascendancy System (`server/world/ascendancy_catalog.py:121-131`, `ascendancy_types.py:95-134`)**:
   - `TRIAL_10_GODHOOD_TRANSCENDENCE` is already defined in catalog with `required_level=100`, `zone_name="Đỉnh Núi Tận Diệt"`, `boss_name="Thượng Cổ Thần Ma Tàn Thể"`.
   - `AscendancyAppliedEffects` in `server/world/ascendancy_types.py` lacks the `avatar_metamorphosis_active: bool = False` attribute.
   - `GODHOOD_AVATAR_METAMORPHOSIS` keystone is not yet defined in `ascendancy_catalog.py`.

5. **Character Runtime Representation (`server/auth/character_service.py:26-44`, `client/webapp/index.html:31-41`)**:
   - Character level and experience are stored in `Character` dataclass (`level: int = 1`, `experience: int = 0`).
   - Client WebApp tracks level in `#txt-char-level` (`Lv.1`) and `player.level`.
   - `LevelProgressionService` (`server/world/level_progression_service.py`) does not yet exist.

---

## 2. Logic Chain
1. **From Observation 1 & 2**: The current `target_exp` progression model violates the requirement that Level 99->100 is a hardcore soft-wall requiring $25-35\%$ of total lifetime EXP and $\ge 30\%$ of Level 1-99 accumulated EXP.
2. **From Observation 3**: The monotonicity gate requires `target_exp` to increase strictly with each level ($L=1..100$). Therefore, `target_exp` must represent cumulative lifetime EXP (not delta EXP, because at Level 100 delta EXP drops to 0, which would fail `target_exp <= prev_xp`).
3. **From Schema Delta Analysis**: To support Level Gap Penalties and Hybrid Tiered Death Penalties without modifying existing query contracts, `progression_benchmarks` must be extended with:
   - `exp_to_next_level INTEGER NOT NULL CHECK (exp_to_next_level >= 0)`
   - `cumulative_exp INTEGER NOT NULL CHECK (cumulative_exp > 0)`
   - `death_penalty_ratio REAL NOT NULL DEFAULT 0.0 CHECK (death_penalty_ratio BETWEEN 0.0 AND 1.0)`
   - `level_gap_safe_range INTEGER NOT NULL DEFAULT 5 CHECK (level_gap_safe_range >= 0)`
   - `level_gap_penalty_exp REAL NOT NULL DEFAULT 0.60 CHECK (level_gap_penalty_exp > 0)`
   - `monster_benchmark_exp INTEGER NOT NULL DEFAULT 25 CHECK (monster_benchmark_exp > 0)`
4. **From Mathematical Simulation**:
   - Using $\Delta \text{EXP}(L) = \lfloor 525 \times L^{2.05} \rfloor$ for $1 \le L \le 20$, Level 1-20 occupies $0.0217\%$ of lifetime EXP ($< 0.1\%$).
   - Using $\Delta \text{EXP}(99) = \lfloor 0.35 \times \sum_{i=1}^{98} \Delta \text{EXP}(i) \rfloor$, the 99->100 jump represents $35.0\%$ of Level 1-99 EXP and $25.93\%$ of total lifetime EXP.
   - Monte-Carlo simulation (1,000 trials, 90-day season, 60 maps/day) proves that a player with a $2\%$ death rate per map has a $0.00\%$ chance of reaching Level 100, while a $0.0-0.1\%$ death rate player has a $100\%$ success rate.
5. **From Observation 4 & 5**: Implementing `LevelProgressionService` will bridge monster kills and death events with character state, and adding `avatar_metamorphosis_active` to `AscendancyAppliedEffects` satisfies Trial 10's Keystone Metamorphosis unlock.

---

## 3. Caveats
- No code in `server/`, `client/`, or `data/` was modified during this survey, strictly adhering to the exploratory read-only constraint.
- The proposed schema addition maintains 100% backward compatibility with `test_level_progression_benchmark`, which queries `target_exp`, `player_base_hp`, and `max_affix_tier_allowed`.

---

## 4. Conclusion
The database schema for `progression_benchmarks` requires 6 additional columns to support piecewise exponential progression, death penalties, and level gap efficiency. A 7-tier piecewise mathematical formula has been formulated and verified via Monte-Carlo simulation to strictly satisfy all directives in `ORIGINAL_REQUEST.md` (§ 2026-10-01T00:40:44Z). All details, tables, and milestone specifications are documented in `c:\Projects\FreeExile\.agents\teamwork\spec_miner_survey_exp_1\report.md`.

---

## 5. Verification Method
1. **Schema and Monotonicity Verification**:
   ```bash
   python tools/lint/verify_game_design_matrix.py --no-sync
   ```
2. **Current Database Inspection**:
   ```bash
   python -c "import sqlite3; conn = sqlite3.connect('data/game_design_matrix.db'); print(conn.execute('SELECT level, target_exp FROM progression_benchmarks WHERE level IN (1, 20, 40, 60, 80, 90, 99, 100)').fetchall())"
   ```
3. **Unit Tests**:
   ```bash
   pytest tests/unit/test_game_design_matrix.py
   ```
4. **Inspection of Deliverable Report**:
   Inspect `c:\Projects\FreeExile\.agents\teamwork\spec_miner_survey_exp_1\report.md` for comprehensive findings and formulas.
