# Hacker Divergents — Fase 20

## Status

**FASE 20 ENCERRADA OFICIALMENTE**

Checkpoint gerado em:

`text
2026-08-27 15:31:21 -03:00
`

## Objetivo consolidado

Centralizar toda movimentacao economica de creditos do jogador no
`CreditLedgerService`, eliminando mutacoes economicas paralelas em
`players.credits` e estabelecendo rastreabilidade, identidade de origem
e idempotencia.

## Garantias aprovadas

- Zero mutacoes diretas de `players.credits` fora do ledger.
- `CreditLedgerService` como autoridade central de credito e debito.
- 16 servicos de producao integrados ao ledger.
- Sources e sinks economicos rastreaveis.
- Identidades economicas preservadas.
- Chaves de idempotencia validadas.
- Replay idempotente validado.
- Conflito de idempotencia bloqueado.
- Saldo insuficiente bloqueado.
- Balance snapshots preservados.
- Testes dedicados da Fase 20 aprovados.
- Regressao economica aprovada.
- Arquivos de backup permanecem fora do fluxo de producao.

## Servicos integrados

- `src\Economy\Application\FragmentMarketplaceService.php`
- `src\Economy\Application\UsedMarketplaceService.php`
- `src\Energy\Application\EnergyBillingService.php`
- `src\Gameplay\Application\OperationalActionEconomyService.php`
- `src\Gameplay\Application\OperationalRewardService.php`
- `src\Hardware\Application\HardwareMaintenanceService.php`
- `src\Hardware\Application\HardwareRebuildService.php`
- `src\Hardware\Application\HardwareSalvageService.php`
- `src\Mining\Application\MiningParasiteRevenueService.php`
- `src\Software\Application\SoftwareConstructionService.php`
- `src\Software\Application\SoftwareDevelopmentService.php`
- `src\Software\Application\SoftwareResearchService.php`
- `src\Software\Application\SoftwareUpgradeService.php`
- `src\World\Application\DynamicMissionBoardService.php`
- `src\World\Application\WorldLootService.php`
- `src\World\Application\WorldMissionService.php`

## Testes executados

- `tests\phase20b-credit-ledger-test.php` — PASS
- `tests\phase20c-dynamic-mission-ledger-test.php` — PASS
- `tests\phase20c-fixed-mission-ledger-test.php` — PASS
- `tests\phase20d1-operation-cost-ledger-test.php` — PASS
- `tests\phase20d2a-energy-billing-ledger-test.php` — PASS
- `tests\phase20d2b-energy-debt-ledger-test.php` — PASS
- `tests\phase20d3a-maintenance-ledger-test.php` — PASS
- `tests\phase20d3b-hardware-rebuild-ledger-test.php` — PASS
- `tests\phase20d4a-software-construction-ledger-test.php` — PASS
- `tests\phase20d4b-software-research-ledger-test.php` — PASS
- `tests\phase20d4c-software-upgrade-ledger-test.php` — PASS
- `tests\phase20e1-used-marketplace-ledger-test.php` — PASS
- `tests\phase20e2-fragment-marketplace-ledger-test.php` — PASS
- `tests\phase20f1-operational-reward-ledger-test.php` — PASS
- `tests\phase20f2-hardware-salvage-ledger-test.php` — PASS
- `tests\phase20f3-software-development-ledger-test.php` — PASS
- `tests\phase20f4-world-loot-ledger-test.php` — PASS
- `tests\phase20f5-mining-parasite-revenue-ledger-test.php` — PASS

## Autoridade economica

`text
src\Economy\Application\CreditLedgerService.php
`

## Regra arquitetural apos a Fase 20

Nenhum novo servico pode alterar `players.credits` diretamente.

Toda entrada ou saida de creditos deve passar pelo
`CreditLedgerService` e possuir:

1. jogador;
2. direcao;
3. valor;
4. source type;
5. source identity;
6. idempotency key;
7. balance before;
8. balance after.

Qualquer excecao futura a essa regra exige uma nova decisao arquitetural
e uma auditoria explicita.

## Resultado final

`text
PLAYERS.CREDITS DIRECT MUTATION...... 0
CREDIT LEDGER SERVICES............... 16
CENTRAL CREDIT LEDGER................ PASS
SOURCE IDENTITY...................... PASS
SINK IDENTITY........................ PASS
IDEMPOTENCY.......................... PASS
INSUFFICIENT BALANCE GUARD........... PASS
ECONOMIC TEST SUITE.................. PASS
PHASE 20............................. CLOSED
`

---

**Checkpoint oficial da economia centralizada do Hacker Divergents.**