|
| 1 | +# Current Improvements Todo |
| 2 | + |
| 3 | +Execution checklist for `docs/refactors/2026-04-current-improvements.md`. |
| 4 | + |
| 5 | +## Phase 0 — Baseline & safety net |
| 6 | +- [x] Run `gleam format`; keep formatter churn isolated. |
| 7 | +- [x] Run `gleam test`; record baseline pass count and timing. |
| 8 | +- [x] Add CI guard for `should.equal`, `io.debug`, raw `todo` in `src/`. |
| 9 | +- [x] Add end-to-end integration test covering `POST /agent-runs` -> SSE replay/read-back -> event-log read-back. |
| 10 | + |
| 11 | +## Phase 1 — Low-risk polish |
| 12 | +- [x] 1.1 Replace hand-rolled list reversal in `src/lummy_agent/app/config.gleam` with `list.reverse`. |
| 13 | +- [x] 1.2 Qualify dict imports in `src/lummy_agent/session/session_manager.gleam` and `src/lummy_agent/runtime/event_bus.gleam`. |
| 14 | +- [x] 1.3 Replace `panic as` expectation branches in key Result-based tests with `let assert Error(_)` patterns. |
| 15 | +- [x] 1.4 Make memory writeback failures observable via session events. |
| 16 | +- [x] 1.5 Centralize actor call timeouts in `session_actor.gleam` and `session_manager.gleam`; add longer model-adjacent timeouts. |
| 17 | +- [x] 1.6 Document `CollectorMessage` wrapper reason in `session_actor.gleam`. |
| 18 | + |
| 19 | +## Phase 2 — Flatten config validator |
| 20 | +- [x] Extract `require_non_blank`, `require_summary_mode`, `require_tool_risk`, `require_secret_key_length` helpers. |
| 21 | +- [x] Rewrite `validate/1` with flat `result.try` flow. |
| 22 | +- [x] Add direct tests for validator helpers. |
| 23 | + |
| 24 | +## Phase 3 — Split config into sub-configs |
| 25 | +- [x] Define `ServerConfig`, `StorageConfig`, `ProviderConfig`, `AgentConfig`, `ToolsConfig`. |
| 26 | +- [x] Update `defaults/0` and `from_env/1` to populate sub-configs. |
| 27 | +- [x] Migrate config consumers to nested fields. |
| 28 | +- [x] Narrow function signatures to smaller sub-configs where practical (`prompt_builder`, `planner`, `memory_*`, provider registry/adapters, tool runtime helpers). |
| 29 | +- [x] Remove flat config fields. |
| 30 | + |
| 31 | +## Phase 4 — Fix snapshot list direction |
| 32 | +- [x] Make `Snapshot.messages`, `Snapshot.runs`, `Snapshot.events` internally chronological. |
| 33 | +- [x] Remove `public_snapshot/1` and `chronological_messages/1`. |
| 34 | +- [x] Update call sites to append chronologically. |
| 35 | +- [x] Verify event-log ordering and replay ordering stay stable. |
| 36 | + |
| 37 | +## Phase 5 — Extract transaction pipeline in `session_actor` |
| 38 | +- [x] Define `SessionTransaction` and `RunActorSync`. |
| 39 | +- [x] Add transaction builders, `commit_and_apply`, `fold_into_snapshot`, `apply_run_actor_syncs`. |
| 40 | +- [x] Migrate `append_message`. |
| 41 | +- [x] Migrate `start_run_impl`. |
| 42 | +- [x] Migrate `start_tool_call_impl`. |
| 43 | +- [x] Migrate `succeed_tool_call_impl`. |
| 44 | +- [x] Migrate `fail_tool_call_impl`. |
| 45 | +- [x] Migrate `apply_tool_result_impl`. |
| 46 | +- [x] Migrate `execute_model_turn_impl` adjunct flow (`maybe_update_run_plan`, chunk event handling where applicable). |
| 47 | +- [x] Migrate `transition_run_impl`. |
| 48 | +- [x] Migrate `complete_run_impl`. |
| 49 | +- [x] Migrate `complete_run_with_assistant_message_impl`. |
| 50 | +- [x] Migrate `fail_run_impl`. |
| 51 | +- [x] Migrate `cancel_run_impl`. |
| 52 | +- [x] Delete superseded pre-transaction helper paths. |
| 53 | + |
| 54 | +## Phase 6 — Record spread consistency |
| 55 | +- [x] Replace remaining manual `State(...)` rebuilds with record spread where clearer. |
| 56 | + |
| 57 | +## Phase 7 — Repository pattern decision |
| 58 | +- [x] Document repository pattern decision; keep record-of-functions for now (`docs/adr/0001-repository-pattern.md`). |
| 59 | + |
| 60 | +## Phase 8 — Cleanup & validation |
| 61 | +- [x] Re-run `gleam format`. |
| 62 | +- [x] Re-run full test suite. |
| 63 | +- [x] Audit line counts. |
| 64 | + - target: `session_actor < 1200`; actual: `1776` |
| 65 | + - target: `config < 400`; actual: `564` |
| 66 | +- [x] Update `docs/session-runtime.md` for transaction pipeline. |
| 67 | +- [x] Update `CHANGELOG.md` with refactor + writeback observability note. |
| 68 | +- [x] Move `CURRENT_IMPROVEMENTS_PLAN.md` to `docs/refactors/2026-04-current-improvements.md`. |
| 69 | + |
| 70 | +## Baseline notes |
| 71 | +- [x] Baseline recorded. |
| 72 | + - Pass count: `98` |
| 73 | + - Test timing: `15.213s` |
| 74 | + |
| 75 | +## Final validation |
| 76 | +- [x] Final `gleam check` |
| 77 | +- [x] Final `gleam test` |
| 78 | + - Pass count: `101` |
0 commit comments