# Локальный архитектурный план — HMN egress recovery

Версия: **20260711-122712 UTC**

Immutable timestamped-версия.

## Обозначения

- `[x]` — завершено либо окончательно salvaged.
- `[~]` — частично выполнено.
- `[ ]` — не выполнено.
- `[!]` — активный блокер.

## 1. Architecture lock

- [x] STEP_049I — архитектура recovery зафиксирована.
- [x] Slot health отделён от endpoint health.
- [x] Repair записывает endpoint в quarantine.
- [x] Rebalance исключает quarantined endpoints.
- [x] Daily repair counter определён.
- [x] Emergency refresh запускается только после threshold.
- [x] Direct failopen вынесен в отдельный крайний этап.

## 2. Recovery state и реальный repair

- [x] Recovery state helper установлен.
- [x] Helper selftest/mtime исправлен.
- [x] Planner quarantine exclusion доказан.
- [x] Repair wrapper записывает old/new endpoint.
- [x] Repair wrapper увеличивает counter.
- [x] Watcher → dispatcher → adapter repair доказан.
- [x] vpn2:
      `109.248.198.4:37129` →
      `151.236.30.139:33998`.
- [x] Старый endpoint quarantined.
- [x] STEP_050E salvaged через STEP_050E2.

## 3. Emergency skeleton и decision hook

- [x] STEP_050F — skeleton установлен;
      raw STOP позже salvaged.
- [x] STEP_050G — hook установлен, enabled и running.
- [x] STEP_050G raw STOP salvaged через STEP_050G2.
- [x] STEP_050G2 — canonical PASS.
- [x] Production decision:
      `below_threshold_noop`, count=1.
- [x] Temporary threshold decision:
      `would_run_emergency_refresh`, count=5.
- [x] Реальный refresh не запускался.
- [x] Rebalance apply не запускался.
- [x] Direct failopen остаётся disabled.

## 4. Commit guard

- [x] STEP_050H — guard корректно отказал при disabled commit.
- [x] Real commit refused.
- [x] Temp threshold commit refused.
- [x] Temp force commit refused.
- [x] STEP_050H raw STOP salvaged через STEP_050H2.
- [x] STEP_050H2 — canonical PASS.
- [x] Production counter подтверждён:
      **1 → 1** в clean environment.
- [x] Ложные значения 0 классифицированы как temp
      `REG_STATE_DIR` contamination.

## 5. Текущее production-состояние

- [x] vpn1..vpn5 interfaces exist.
- [x] Tables 201..205 default routes exist.
- [x] Strict ping через vpn1..vpn5 — OK.
- [x] Watcher running/enabled и healthy.
- [x] VM100 `wg_paid peer_count=5`.
- [x] VM100 controller running.
- [x] VM121 enabled peers=5.
- [x] VM121 lease rows=5.
- [x] VM121 pending jobs=0.
- [x] Daily repair counter=1.
- [x] Quarantine lines=2.
- [x] Direct failopen disabled.

## 6. Документация и сохранение контекста

- [x] STEP_050H3A — XS Map опубликована.
- [x] STEP_050H3B — documentation-only STOP,
      Python invocation bug; runtime не затронут.
- [x] STEP_050H3B2 — documentation-only STOP,
      overstrict evidence policy; runtime не затронут.
- [x] STEP_050H3B3 — локальный план опубликован.
- [x] STEP_050H3C — точные ссылки G/G2/H/H2
      привязаны к локальному плану.

## 7. Следующий runtime-step

- [ ] `STEP_050I_ENABLE_EMERGENCY_COMMIT_AND_THRESHOLD_DRYRUN_ONLY`.

Обязательные ограничения STEP_050I:

1. Перед production state reads:
   `unset REG_STATE_DIR`.
2. Не запускать реальный HMN refresh.
3. Не запускать rebalance apply.
4. Не включать direct failopen.
5. Снять pre/post fingerprints VM101.
6. Создать rollback.
7. Проверить vpn1..vpn5.
8. Проверить tables 201..205.
9. Проверить strict ping через пять VPN.
10. Проверить watcher.
11. Проверить VM100.
12. Проверить VM121.

## 8. После STEP_050I

- [ ] Reviewed-step реального emergency refresh.
- [ ] Валидация fresh HMN pool.
- [ ] Top5 rebuild/rebalance.
- [ ] DEGRADED_NO_FRESH_POOL.
- [ ] VPN_EXHAUSTED.
- [ ] Direct failopen — отдельный этап.
- [ ] External HMN access recovery.
- [ ] Checkpoint snapshots.
- [ ] Production allocator.
- [ ] Client onboarding/migration.

## Закреплённые ссылки

- Актуальная XS Map:
  https://helena-background-beam-harry.trycloudflare.com/r/e94a0859747d7b96f29c7fdafc2d0351ba603bb0a7e9e5a4/20260711-120734_xs_map_audit_repair_publish/
- Этот локальный архитектурный план:
  https://helena-background-beam-harry.trycloudflare.com/r/e94a0859747d7b96f29c7fdafc2d0351ba603bb0a7e9e5a4/20260711-122712_local_architecture_plan_hmn_egress_recovery_evidence_bound/
- Предыдущий локальный план:
  https://helena-background-beam-harry.trycloudflare.com/r/e94a0859747d7b96f29c7fdafc2d0351ba603bb0a7e9e5a4/20260711-122207_local_architecture_plan_hmn_egress_recovery/
- Исходный architecture lock:
  https://helena-background-beam-harry.trycloudflare.com/r/e94a0859747d7b96f29c7fdafc2d0351ba603bb0a7e9e5a4/20260711-095354_step049i_architecture_lock_hmn_egress_recovery/
- Evidence chain:
  [evidence-chain.md](evidence-chain.md)
