|
| 1 | +# Stabilisation Sprint Progress |
| 2 | + |
| 3 | +## Completed (2026-03-16) |
| 4 | + |
| 5 | +### 1. Unified Error Handling Module (`src/errors/`) |
| 6 | +- `AppError` base class extending `Error` for backward compatibility |
| 7 | +- 11 domain error classes (NetworkError, PeerError, ConsensusError, etc.) |
| 8 | +- `ErrorCode` constants (~40 codes), `ErrorSource` constants (~40 sources), `ErrorSeverity` enum |
| 9 | +- `tryCatch`/`tryCatchSync` tuple pattern, `handleError` utility, `toErrorResponse` |
| 10 | +- Legacy exceptions in `src/exceptions/` now extend AppError |
| 11 | +- Applied to `src/index.ts` and 14+ files (console.error → handleError) |
| 12 | +- 23 unit tests passing |
| 13 | + |
| 14 | +### 2. Unified Config Module (`src/config/`) |
| 15 | +- `Config` singleton class with typed accessors per domain |
| 16 | +- Domains: server, database, core, tlsnotary, omni, l2ps, metrics, diagnostics, identity, bridges, ipfs |
| 17 | +- `EnvKey` constants, `DEFAULT_CONFIG`, deep-frozen at load |
| 18 | +- `dotenv.config()` in loader.ts for ES module import hoisting |
| 19 | +- Fixed `envStr` bug: `??` → `||` (empty string env vars bypassing defaults) |
| 20 | +- 95 env vars across 33 files migrated to Config.getInstance().* |
| 21 | + |
| 22 | +### 3. File Structure Cleanup — Types/Constants Extraction (7 modules) |
| 23 | +- `utilities/`: 16 constants + Diagnostic types |
| 24 | +- `identity/tools/`: 10 interfaces + 30+ constants |
| 25 | +- `l2ps/`: L2PSBatchPayload type + 7 connection pool constants |
| 26 | +- `tlsnotary/`: 16 types/enums + signing key, port config, token config constants |
| 27 | +- `metrics/`: 3 config interfaces + histogram buckets, default configs |
| 28 | +- `omniprotocol/`: 35 constants (server defaults, TLS, rate limits, error codes) |
| 29 | +- All backward-compatible via re-exports |
| 30 | + |
| 31 | +### 4. Code Structure Refactor — Split Large Files |
| 32 | +- **manageNodeCall.ts** (1007→~20 lines): Split 45 switch cases into `network/handlers/` by domain (blocks, txs, peers, identity, tlsnotary, l2ps, misc) |
| 33 | +- **GCRIdentityRoutines.ts** (2212→~170 lines): Split 19 routines into `routines/` by domain (xm, web2, pqc, ud, rewards, zk, nomis, humanpassport, ethos, tlsn) + shared utils |
| 34 | + |
| 35 | +## Remaining |
| 36 | +- [ ] `chain.ts` (781 lines) → split by concern |
| 37 | +- [ ] `server_rpc.ts` (741 lines) → routes by domain |
| 38 | +- [ ] `endpointHandlers.ts` (891 lines) → handlers by domain |
| 39 | +- [ ] Test environment unification (assigned to another developer) |
| 40 | +- [ ] Migrate remaining magic string error sources to ErrorSource constants |
| 41 | + |
| 42 | +## Key Decisions |
| 43 | +- All refactors are pure file reorganization — no logic changes |
| 44 | +- Backward compatibility maintained via re-exports from original files |
| 45 | +- `this.method()` calls in class methods → standalone exported functions in split files |
| 46 | +- Shared utilities (safeGCRSave, isFirstConnection, normalize*) extracted to `routines/utils.ts` |
| 47 | + |
| 48 | +## Test Baseline |
| 49 | +- 98 pass, 12 fail, 1 error (all failures pre-existing) |
| 50 | +- 0 new TypeScript errors from our changes |
0 commit comments