refactor(agent): complete layered runtime migration#1952
Conversation
|
Important Review skippedToo many files! This PR contains 422 files, which is 272 over the limit of 150. To get a review, narrow the scope: Upgrade to a paid plan to raise the limit. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (422)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ered-runtime-docs # Conflicts: # docs/architecture/agent-scoped-extensions/plan.md # src/main/presenter/agentRepository/index.ts # src/main/presenter/agentRuntimePresenter/index.ts # test/main/presenter/agentRepository.test.ts # test/main/presenter/agentRuntimePresenter/agentRuntimePresenter.test.ts
…ered-runtime-docs # Conflicts: # test/memory-test-scope.json
Context
The main-process agent runtime mixed catalog management, app-session storage, DeepChat session state, ACP execution, provider/tool loop control, Tape writes, and Memory orchestration across Presenter classes and legacy compatibility abstractions. That made ownership unclear and allowed invalid agent kinds to enter ambiguous fallback paths.
This PR completes the full ASLR-000..092 layered-runtime plan. It preserves existing product behavior and storage contracts while making manager, instance, loop, ACP, Tape, observability, and Memory boundaries explicit and guarded.
Design and final evidence:
docs/architecture/agent-system-layered-runtime/.Before / after
Before
IAgentImplementationand reflection-based legacy backends.After
AgentManagerperforms executable descriptor lookup and explicitkindrouting only.AppSessionService; DeepChat and ACP repositories have separate ownership.LoopRun.DeepChatLoopEngineowns fixed lifecycle points: provider consumption, output update, tool execution, awaited round persistence, and terminal settlement.kind=acpsessions useAcpAgentRuntime/AcpAgentInstanceand never enter the DeepChat loop.kind=deepchat + providerId=acpremains supported through the ACP provider compatibility adapter.TapeRecorder.appendToolFact, preserving message-before-Tape order, call-before-result order, provenance, idempotency, pending exclusion, and fail-open behavior.MemoryRuntimeCoordinatoris the sole runtime owner of extraction chains/epochs/cooldown/access dedupe/cursor orchestration; prompt contribution and ingestion observation are explicit lifecycle ports.IAgentImplementation, the reflection legacy backend, fake registry resolution, manager-levellegacy/direct runtimeKind, andsrc/main/lib/agentRuntimeare retired.Detailed scope
Control plane and shared data — ASLR-003, 010..034
src/main/agent/acp.lib/agentRuntimehelpers to explicit process, workspace, storage, resource, and tool owners.DeepChat instance — ASLR-040..046
DeepChatAgentRuntime.getOrHydrate()and non-creatinggetHydrated()access.Loop engineering — ASLR-050..057
LoopRunand narrow provider, tool, output, Tape, context, prompt, and observer ports.DeepChatLoopEnginewith awaited lifecycle callbacks.Direct ACP backend — ASLR-070..073
Observability and Memory — ASLR-080..081, 059..062
MemoryRuntimeCoordinatorowner.MemoryPromptContributorandMemoryIngestionObserverwith explicit MEM-13/MEM-14 outcome contracts.Retirement and convergence — ASLR-090..092
Compatibility and expected impact
pnpm run buildrefreshes tracked upstream data by repository policy.Review risks
Validation performed
All required local gates passed:
pnpm run formatpnpm run i18npnpm run lintpnpm run typecheckpnpm run lint:architecturepnpm run lint:agent-cleanupgit diff --check1.0, MRR@100.95, nDCG@100.9630929753571458pnpm run buildpnpm run e2e:smoke:ci: 2/209-main-ipc-boundary,17-acp-readonly-route,26-deepchat-agent-crud: 3/3Credential-required
02-chat-basicand03-session-persistencewere not configured and were not run.Final contract checks:
origin/devis an ancestor of the branch.origin/dev...HEADhas no route/event diff.DEEPCHAT_MEMORY_INGESTION_PROJECTION_VERSIONremains1.Recommended review and test plan
P0 — automated
build-check (x64)andmemory-native-validationpass on the final commit.P0 — DeepChat manual smoke
P1 — ACP manual smoke
P2 — package/platform
Rollback
The migration is split into task-scoped commits. Manager/catalog, instance state, Loop Engine, direct ACP, observability, Memory ports, retirement, and final baseline changes can be reverted at task boundaries. No persistence rollback is required because the refactor adds no data migration.