mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 08:35:57 +00:00
2.9 KiB
2.9 KiB
issue, issue_title
| issue | issue_title |
|---|---|
| 130 | refactor: replace HandlerDeps with handler classes using narrow constructor injection |
Retro: #130 — replace HandlerDeps with handler classes
Final Retrospective (2026-05-08T02:55:00Z)
Session summary
Replaced the monolithic HandlerDeps interface and free-function handlers with three handler classes (SessionLifecycleHandler, AgentPrepHandler, PermissionGateHandler), each with 2–3 narrow constructor deps.
Absorbed canPrompt/prompt/createPermissionRequestId into PermissionSession, added a ToolRegistry interface, relocated PromptPermissionDetails to permission-prompter.ts, and deleted src/handlers/types.ts.
Released as v5.11.0.
This completes the full handler decomposition series (#126 → #127 → #128 → #129 → #130).
Observations
What went well
- The 8-step incremental plan converted one handler class at a time, keeping the repo green after every commit. Zero rework across all steps.
- The lift-and-shift pattern (introduce new alongside old, migrate, delete old last) worked exactly as designed.
HandlerDepssurvived until step 7, so steps 4–6 could each wire their new class inindex.tsindependently. - Test factory simplification was dramatic:
makeDeps()with 8 unrelated fields replaced bynew Handler(mockSession, ...)with 2–3 typed deps. Noas unknown ascasts needed for the narrow mocks. - Full test suite (1288 tests) passed at every step with no behavioral changes, confirming this was a pure refactor.
- The plan correctly identified that
canPrompt/promptneeded to migrate toPermissionSession(deferred from #129), preventing a gap whenHandlerDepswas deleted.
What caused friction (agent side)
missing-context— Step 7 (deleteHandlerDeps) broketests/permission-prompter.test.tswhich importedPromptPermissionDetailsfrom the deletedsrc/handlers/types.ts. The plan's module-level changes table did not list this test file. Caught bypnpm run build, fixed immediately. Impact: one extra build-fix cycle, no rework.missing-context— StaleHandlerDepsreferences in JSDoc comments acrosssrc/permission-prompter.ts,src/session-logger.ts,src/forwarding-manager.ts, anddocs/architecture/permission-prompter.mdwere not flagged by the plan. Caught during cleanup withgrep. Impact: added friction but no rework — comments were updated in the same commit.other— Autoformat (Biome) reordered imports insrc/index.tsbetween the handler barrel edit and the wiring edit in step 4, causing the secondEditcall to fail onoldTextmismatch. Required re-reading the file to get the new import order. Impact: one extra read + retry, ~10 seconds.
What caused friction (user side)
- No friction observed. The user's plan was well-scoped and the issue body provided exact class signatures, making implementation straightforward.