refactor: decouple main process modules via interfaces and constructor injection#1402
Merged
refactor: decouple main process modules via interfaces and constructor injection#1402
Conversation
added 28 commits
March 18, 2026 12:00
- Remove legacy fallback paths for create, createWithConversation, remove, and update handlers; conversationService is always provided - Route all WorkerManage.* calls through workerTaskManager (getTask, getOrBuildTask, kill, clear) - Route getDatabase().getConversation() calls through conversationService.getConversation() in get, getRuntime, remove, update, getSlashCommands, and getAssociateConversation handlers - Remove unused imports: WorkerManage, ConversationService, cronService, uuid - Make initConversationBridge parameters non-optional - Add unknown intermediate cast for IAgentManager -> concrete manager type narrowing (required by TypeScript strict mode) Note: getAssociateConversation retains one direct getDatabase() call for getUserConversations() pagination query; IConversationService does not yet expose a list/query method. Flagged for future migration.
…orkerManage conflicts
added 4 commits
March 18, 2026 15:43
…e diagram - Add phase2-design.md: 6-PR plan covering WorkerTaskManager, bridge layer injection, CronService decoupling, channel repository, database/ extensions bridge refactor, and cleanup - Add phase2-decouple-design.html: visual dependency-injection diagram showing all bridge, service, and agent layers after Phase 2 completion
ringringlin
approved these changes
Mar 18, 2026
IceyLiu
approved these changes
Mar 18, 2026
piorpua
pushed a commit
that referenced
this pull request
Mar 18, 2026
- Mark PR #1402 as merged in header metadata - Update branch name to phase2-specific branch - Add two missing coupling entries: applicationBridge and conversationBridge line 125 - PR-A: add listAllConversations to IConversationRepository interface; fix conversationBridge line 125 - PR-B: add applicationBridge.ts decoupling with same injection pattern - PR-F: document channels layer migration targets (SystemActions, ActionExecutor) - Testing: add Test Quality Rules section with behavior-first, risk-first guidelines - Testing: annotate all failure paths with [failure path], reorder CronService tests by risk - Testing: add conversationBridge and applicationBridge to coverage targets
2 tasks
kaizhou-lab
pushed a commit
that referenced
this pull request
Mar 18, 2026
- Mark PR #1402 as merged in header metadata - Update branch name to phase2-specific branch - Add two missing coupling entries: applicationBridge and conversationBridge line 125 - PR-A: add listAllConversations to IConversationRepository interface; fix conversationBridge line 125 - PR-B: add applicationBridge.ts decoupling with same injection pattern - PR-F: document channels layer migration targets (SystemActions, ActionExecutor) - Testing: add Test Quality Rules section with behavior-first, risk-first guidelines - Testing: annotate all failure paths with [failure path], reorder CronService tests by risk - Testing: add conversationBridge and applicationBridge to coverage targets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IConversationRepository,IConversationService,IAgentManager,IAgentFactory,IWorkerTaskManager,IAgentEventEmitter,WorkerProtocolSqliteConversationRepository,ConversationServiceImpl,IpcAgentEventEmitter,AgentFactory,WorkerTaskManagerWorkerManage(switch-based dispatch) withWorkerTaskManager+AgentFactoryIAgentEventEmitterintoBaseAgentManager; remove directipcBridgecalls from agent layerconversationBridge: removetask.typeguards fromstopandsendMessagehandlers, unify dispatch viaIAgentManagerinterfaceForkTask.postMessagewithWorkerProtocoltypesArchitecture
Each layer now depends only on an interface, not a concrete class. Dependencies are passed via constructor injection (no DI framework).
Test Plan
bun run testpasses (691 tests)bunx tsc --noEmitpassesbun run lint:fixproduces no errors on changed filesConversationServiceImplcan be unit-tested by mockingIConversationRepositoryWorkerTaskManagercan be unit-tested by mockingIAgentFactoryBaseAgentManagercan be unit-tested by mockingIAgentEventEmittergetDatabase()calls remain outsideSqliteConversationRepositoryipcBridgecalls remain insideBaseAgentManagergrep -rn "WorkerManage" src/returns no results