# Lynn V0.79.4 Central Refactor Baseline

Date: 2026-05-25
Branch: `codex/v0794-central-refactor`

This file records the starting point for the V0.79.4 central refactor after the
V0.79.3 notarized package candidate was cut.

## Release Baseline

V0.79.3 was preserved at local branch `codex/v0793-release-candidate`.

Completed gates before starting V0.79.4:

- `npm run typecheck:runtime`
- `npm run typecheck`
- `npm test`: 185 files / 1463 passed / 1 skipped
- `npm run build:server`
- `npm run build:main`
- `npm run build:renderer`
- `npm run test:release`: static 37/37 and live `Failed:0; blocker:0; critical:0`
- `npm run test:release:ui`: home / short / tools / long-code PASS
- macOS Apple Silicon DMG: signed, notarized, stapled, Gatekeeper accepted
- macOS Intel DMG: signed, notarized, stapled, Gatekeeper accepted
- Windows NSIS installer: rebuilt and signed

## Central Files

Line counts at V0.79.4 entry:

| File | Lines | Role |
| --- | ---: | --- |
| `server/routes/chat.js` | 1911 | Chat/WebSocket route shell plus turn behavior |
| `core/engine.js` | 1224 | Runtime composition, agent wiring, tool guard, model services |
| `core/session-coordinator.js` | 2037 | Prompt orchestration, memory relay, tool policy, execution flow |
| `server/routes/providers.js` | 583 | Provider REST state and config surface |
| `server/routes/models.ts` | 239 | Model route state surface |
| `core/provider-registry.ts` | 511 | Provider registry and auth metadata |
| `core/model-manager.js` | 310 | Local model runtime control |
| `desktop/model-downloader.cjs` | 914 | Main-process model download/install path |

Total for the listed center: 7729 lines.

## Known Architecture Debts

Core still imports HTTP-layer i18n directly:

- `core/agent-manager.js`
- `core/bridge-session-manager.js`
- `core/llm-utils.ts`
- `core/engine.js`
- `core/session-coordinator.js`
- `core/channel-manager.js`
- `core/config-coordinator.js`
- `core/model-manager.js`
- `core/execution-router.js`

The V0.79.4 target is to replace these reverse dependencies with injected
translation helpers or a shared i18n boundary. Do not move more server imports
into `core/**`.

## Refactor Guardrails

- Keep V0.79.3 release artifacts and release docs out of central refactor commits.
- Never download model artifacts, BF16, GGUF, datasets, or training packages to
  the local Mac.
- Prefer pure contract/reducer modules first; wire them into routes/UI only after
  parity tests exist.
- Keep public WebSocket event names stable.
- Do not allow explicit user-selected models to silently fall back to another
  provider/model.
- Keep renderer-facing local model state sanitized: no raw secrets and no unsafe
  filesystem authority.

## First Work Lanes

- Provider state machine foundation:
  `shared/provider-state.ts`, `core/provider-state-machine.ts`, pure tests.
- Local model IPC contract:
  `shared/local-model-ipc.ts`, contract tests.
- Chat route minimal split:
  title generation and route context only before moving stream behavior.

