apache / apache/maka

refactor(runtime-host): decompose execution-composition.ts (1840 lines, 40+ imports)

Open
#3,911 1 comment 0 reactions 1 assignee Claimed by @WangzJi View on GitHub
Dominant language
TypeScript
Stars
5.4k
Forks
502
Avg merge
1d 2h
Merged PRs (30d)
715

Description

## Summary

`packages/runtime-host/src/server/execution-composition.ts` (1,840 lines) is the single composition root that wires 40+ runtime imports. Every new runtime module extracted or renamed requires editing this file, creating a maintenance bottleneck.

## Evidence

- `packages/runtime-host/src/server/execution-composition.ts:31-100` — imports 40+ symbols from `@maka/runtime/*` sub-exports in one file
- The file wires SessionManager, BackendRegistry, tools, sandboxes, filesystem workers, agent graph, goals, skills, and more
- Changes to any runtime module often require corresponding edits here

## Proposed Decomposition

Split into domain-specific composition files:
1. **`tool-composition.ts`** — tool registration and tool pipeline wiring
2. **`agent-graph-composition.ts`** — agent graph scheduling and coordination
3. **`sandbox-composition.ts`** — sandbox boundary and filesystem worker wiring
4. **`history-composition.ts`** — history compaction and event log wiring
5. **`execution-composition.ts`** — orchestration that composes the above

Each domain composition would be a function that receives the kernel and returns its configured subsystem.

## Acceptance Criteria

- [ ] `execution-composition.ts` is under 500 lines
- [ ] Each domain composition is independently testable
- [ ] No new cross-module cycles introduced
- [ ] All existing tests pass
- [ ] Runtime Host boot sequence is unchanged

## Labels

refactor, help wanted

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.