Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
84ba35f
refactor(utils): remove unused createChildAbortController
echoVic Sep 16, 2026
8bcd269
refactor(tools): consolidate subagent delegation deps into a container
echoVic Sep 16, 2026
8b2d4ea
refactor: remove unused subsystems and dependencies
echoVic Sep 16, 2026
d5beaa4
refactor(runtime): remove obsolete compatibility and context layers
echoVic Sep 16, 2026
d537362
refactor(session): unify metadata update event construction
echoVic Sep 16, 2026
e700747
refactor(session): share local and remote fork projection
echoVic Sep 16, 2026
0efea96
refactor(ui): deduplicate shared theme tokens
echoVic Sep 16, 2026
99d2dee
refactor(shell): encode read-only flags declaratively
echoVic Sep 16, 2026
32e7cb0
refactor(subagents): remove deprecated global tool registry
echoVic Sep 16, 2026
db31cb0
refactor(test): make shell safety cases table driven
echoVic Sep 16, 2026
b3b1875
docs: define codebase simplification budget
echoVic Sep 16, 2026
b6a2083
refactor(test): unify provider recovery trajectories
echoVic Sep 16, 2026
76af381
refactor(test): unify provider admission web trajectories
echoVic Sep 16, 2026
0f2e0f5
refactor(test): share async process utilities
echoVic Sep 16, 2026
ce07581
refactor(test): centralize polling utilities
echoVic Sep 16, 2026
7d74d9c
refactor(test): centralize Blade ACP harness lifecycle
echoVic Sep 16, 2026
891423c
refactor(test): consolidate coordinator and cursor fixtures
echoVic Sep 16, 2026
407e95b
refactor(test): unify provider admission ACP runner
echoVic Sep 16, 2026
7f8c454
refactor(test): share real API GUI fixture launcher
echoVic Sep 16, 2026
60fcd53
refactor(test): reuse GUI fixture lifecycle
echoVic Sep 16, 2026
33d899a
refactor(test): share durable GUI fixture lifecycle
echoVic Sep 16, 2026
3de8834
refactor(test): remove unused GUI launchers
echoVic Sep 16, 2026
a2bcef5
refactor(test): remove orphan qualification fixtures
echoVic Sep 16, 2026
b34865a
refactor(test): remove unreachable support modules
echoVic Sep 16, 2026
c61d9e6
refactor(test): retain release-blocking real API suite
echoVic Sep 16, 2026
03689a4
refactor(runtime): remove unused management APIs
echoVic Sep 16, 2026
41eda61
refactor(runtime): prune unused extension APIs
echoVic Sep 16, 2026
6e0e4aa
refactor(runtime): remove unused compatibility surfaces
echoVic Sep 16, 2026
83cf09b
refactor(test): centralize session route requests
echoVic Sep 16, 2026
e7d064d
refactor(test): compress structured output scenarios
echoVic Sep 16, 2026
66169c0
refactor(test): centralize ACP resume wake fixtures
echoVic Sep 16, 2026
ec80b94
refactor(test): share background task runtime fixtures
echoVic Sep 16, 2026
8e49e33
refactor(test): centralize event dispatcher harness
echoVic Sep 16, 2026
02caafe
refactor(test): share remote mutation outcome matrix
echoVic Sep 16, 2026
953e6a6
refactor(session): reuse metadata projection
echoVic Sep 16, 2026
38c4e89
refactor(test): generalize provider failure injection
echoVic Sep 16, 2026
4fd09d5
refactor(server): centralize session event projection
echoVic Sep 16, 2026
a723cc9
refactor(acp): reuse session event projection
echoVic Sep 16, 2026
57e944a
refactor(test): share loop test fixtures
echoVic Sep 16, 2026
d11cf86
refactor(test): centralize loop execution harness
echoVic Sep 16, 2026
ef2f3f8
refactor(test): unify loop generator execution
echoVic Sep 16, 2026
1e26552
refactor(test): reuse loop response builders
echoVic Sep 16, 2026
55df96f
refactor(test): centralize loop completion responses
echoVic Sep 16, 2026
8baf8f9
refactor(test): centralize ACP text prompts
echoVic Sep 16, 2026
e867f66
refactor: consolidate session runtime test fixtures
echoVic Sep 16, 2026
38070ee
refactor: unify session route test harnesses
echoVic Sep 16, 2026
3663b17
refactor(test): share real api runner utilities
echoVic Sep 16, 2026
ff5d553
refactor(test): centralize ACP child harness
echoVic Sep 16, 2026
fc9df49
refactor(test): unify PTY runner lifecycle
echoVic Sep 16, 2026
877db51
refactor(test): centralize Web driver lifecycle
echoVic Sep 16, 2026
5c0b67c
refactor: unify compaction and resume state
echoVic Sep 16, 2026
89ba9af
refactor(test): focus release qualification matrix
echoVic Sep 16, 2026
5a36aaf
refactor(test): replace oversized regression matrices
echoVic Sep 16, 2026
c214641
refactor(server): separate session run lifecycle
echoVic Sep 16, 2026
7a4dbee
docs: record simplification architecture
echoVic Sep 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 0 additions & 16 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 103 additions & 0 deletions docs/design/codebase-simplification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Codebase Simplification

## Objective

Reduce tracked TypeScript/TSX/JavaScript LOC by at least 30% while preserving
the supported runtime surfaces and making ownership easier to follow.

Baseline at `8bcd2696`:

- Tracked TypeScript/TSX/JavaScript LOC: 593,930
- Target maximum: 415,751 LOC
- Required net reduction: 178,179 LOC

The metric excludes generated output, dependencies, Markdown, JSON, and
lockfiles. It compares the same tracked extensions at the baseline and
candidate commits.

## Guardrails

- Preserve CLI, Web, ACP, MCP, browser, LSP, task, team, goal, and provider
behavior unless a surface is unused or explicitly deprecated.
- Keep deterministic state-machine tests for durable storage, permissions,
compaction, scheduling, tool execution, and protocol boundaries.
- Keep a focused paid qualification matrix for behavior that cannot be proven
without a real Provider or production surface.
- Keep one authoritative state machine per behavior. Surfaces project state;
they do not reimplement it.
- Remove deprecated compatibility paths instead of retaining aliases.
- Prefer data-driven routing and named boundaries over nested conditionals.
- Keep each independently verifiable reduction in its own commit.
- Do not use git worktrees.

## Implemented Changes

### Runtime

- Removed unused subsystems, compatibility APIs, global registries, and
management surfaces.
- Unified Session metadata updates, local/remote fork projection, event
projection, compaction telemetry, and inputless resume state.
- Replaced repeated shell and tool policy branches with declarative metadata.
- Split Session run ownership out of the Hono controller.

### Test Architecture

- Centralized Provider, ACP, PTY, Web, Agent loop, and Session fixture
lifecycles before deleting their repeated consumers.
- Removed source-string gates and tests whose subject was another test harness.
- Replaced broad cross-layer matrices with focused state-machine tests.
- Reduced paid release qualification to nine high-value production paths.

## Resulting Boundaries

### Session Run Lifecycle

- `server/routes/session.ts` owns HTTP/SSE routing, projection residency, and
controller shutdown.
- `server/routes/sessionRunState.ts` owns active/recent run registration,
cancellation, pending permission lookup, and mutable Session task projection.
- `server/routes/sessionRunExecutor.ts` owns Agent creation, loop event
projection, pending-resume evidence, terminal task state, and resource
release.

The executor depends on the run-state module. Neither extracted module depends
on the Hono controller.

### Test Pyramid

The default deterministic suite remains the primary regression authority. The
production real-API release matrix is limited to:

1. Production Agent edit and verification
2. Structured output
3. Durable interaction recovery
4. Cross-surface release coding
5. Agent Team task coordination
6. Cross-Provider fallback
7. Goal completion
8. Native Browser tools
9. ACP remote filesystem

Provider admission, retry, compaction, queueing, Session identity, event
projection, and resource cleanup remain covered by deterministic unit and
integration tests instead of repeated paid surface grids.

## Result

Representative commits:

| Phase | Commits |
| --- | --- |
| Dead code and compatibility | `8b2d4ea0` through `6e0e4aa6` |
| Runtime unification | `d5373627`, `e7007472`, `953e6a67`, `5c0b67ca` |
| Harness consolidation | `b6a20834` through `877db51d` |
| Qualification focus | `89ba9afd` |
| Regression matrix reduction | `5a36aaf7` |
| Session decomposition | `c214641e` |

At `c214641e`, tracked TypeScript/TSX/JavaScript is 413,082 lines:

- Net reduction: 180,848 lines
- Reduction from baseline: 30.45%
- Margin beyond the required reduction: 2,669 lines
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@
"devDependencies": {
"@biomejs/biome": "2.5.7",
"@types/node": "^25.5.0",
"@types/react": "19.2.10",
"@types/react-dom": "19.2.3",
"knip": "^5.80.0",
"react": "19.2.4",
"react-dom": "19.2.4",
"typescript": "^5.9.2"
},
"trustedDependencies": [
Expand Down
49 changes: 5 additions & 44 deletions packages/cli/scripts/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,53 +27,13 @@ export const testTypes = {
files: [
'tests/integration/real-api/agent-trajectory.test.ts',
'tests/integration/real-api/structured-output-trajectory.test.ts',
'tests/integration/real-api/code-review-trajectory.test.tsx',
'tests/integration/real-api/durable-interaction-recovery-trajectory.test.ts',
'tests/integration/real-api/acp-session-fork-trajectory.test.ts',
'tests/integration/real-api/release-coding-trajectory.test.ts',
'tests/integration/real-api/task-list-team-trajectory.test.ts',
'tests/integration/real-api/provider-retry-trajectory.test.ts',
'tests/integration/real-api/cross-provider-fallback-trajectory.test.ts',
'tests/integration/real-api/provider-attempt-deadline-web-trajectory.test.ts',
'tests/integration/real-api/prompt-cache-surface-trajectory.test.ts',
'tests/integration/real-api/action-stationarity-trajectory.test.ts',
'tests/integration/real-api/goal-mode-trajectory.test.ts',
'tests/integration/real-api/root-turn-auto-resume-trajectory.test.ts',
'tests/integration/real-api/goal-finalization-handoff-trajectory.test.ts',
'tests/integration/real-api/subagent-result-adoption-trajectory.test.ts',
'tests/integration/real-api/background-subagent-completion-trajectory.test.ts',
'tests/integration/real-api/durable-task-unread-trajectory.test.ts',
'tests/integration/real-api/tui-task-attention-trajectory.test.ts',
'tests/integration/real-api/foreground-bounded-output-trajectory.test.ts',
'tests/integration/real-api/foreground-command-handoff-trajectory.test.ts',
'tests/integration/real-api/token-budget-handoff-trajectory.test.ts',
'tests/integration/real-api/browser-preview-trajectory.test.ts',
'tests/integration/real-api/browser-tool-trajectory.test.ts',
'tests/integration/real-api/large-prompt-offload-trajectory.test.ts',
'tests/integration/real-api/compaction-rich-media-trajectory.test.ts',
'tests/integration/real-api/foreground-provider-recovery-trajectory.test.ts',
'tests/integration/real-api/provider-rate-limit-cooldown-trajectory.test.ts',
'tests/integration/real-api/turn-activity-surface-trajectory.test.ts',
'tests/integration/real-api/provider-request-admission-acp-trajectory.test.ts',
'tests/integration/real-api/provider-request-admission-web-trajectory.test.ts',
'tests/integration/real-api/acp-remote-filesystem-trajectory.test.ts',
'tests/integration/real-api/weighted-provider-admission-acp-trajectory.test.ts',
'tests/integration/real-api/weighted-provider-admission-web-trajectory.test.ts',
'tests/integration/real-api/weighted-task-admission-acp-trajectory.test.ts',
'tests/integration/real-api/weighted-task-admission-web-trajectory.test.ts',
'tests/integration/real-api/keyed-coordination-reclamation-trajectory.test.ts',
'tests/integration/real-api/session-runtime-residency-acp-trajectory.test.ts',
'tests/integration/real-api/session-runtime-residency-controls-trajectory.test.ts',
'tests/integration/real-api/session-runtime-residency-web-trajectory.test.ts',
'tests/integration/real-api/graceful-shutdown-trajectory.test.ts',
'tests/integration/real-api/tool-admission-trajectory.test.ts',
'tests/integration/real-api/side-conversation-trajectory.test.ts',
'tests/integration/real-api/follow-up-queue-trajectory.test.ts',
'tests/integration/real-api/compaction-memory-consolidation-trajectory.test.ts',
'tests/integration/real-api/goal-execution-host-failure-trajectory.test.ts',
'tests/integration/real-api/goal-turn-lineage-trajectory.test.ts',
'tests/integration/real-api/goal-paused-usage-trajectory.test.ts',
'tests/integration/real-api/textual-tool-call-trajectory.test.ts',
],
env: {
REAL_API_TEST: '1',
Expand All @@ -92,15 +52,16 @@ export const testTypes = {
timeout: 120_000,
requiresProductionBuild: true,
files: [
'tests/unit/cli/headless.test.ts',
'tests/unit/cli/headless-events.test.ts',
'tests/integration/cli/blade-help.test.ts',
'tests/unit/agent-runtime/context/jsonl-recovery.test.ts',
'tests/unit/agent-runtime/agent/active-turn-mailbox.test.ts',
'tests/unit/agent-runtime/agent/session-lease.test.ts',
'tests/unit/agent-runtime/agent/session-runtime.test.ts',
'tests/unit/agent-runtime/agent/completion-policy.test.ts',
'tests/unit/agent-runtime/agent/subagent-registry.test.ts',
'tests/unit/agent-runtime/server/session-routes.test.ts',
'tests/unit/agent-runtime/acp/session.test.ts',
'tests/unit/agent-runtime/server/task-routes.test.ts',
'tests/unit/agent-runtime/acp/bladeAgent.test.ts',
'tests/unit/services/session-interaction-recovery.test.ts',
],
},
e2e: {
Expand Down
6 changes: 0 additions & 6 deletions packages/cli/src/acp/AcpFileRequestCoordinator.contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,3 @@ export function createAcpRemoteConnectionPathIdentity(
.update(remotePath.collisionIdentity)
.digest('hex')}`;
}

export function isAcpRemoteMutationRecoveryLease(
lease: AcpRemoteMutationLease | AcpRemoteMutationRecoveryLease | undefined
): lease is AcpRemoteMutationRecoveryLease {
return lease !== undefined && 'finish' in lease;
}
14 changes: 0 additions & 14 deletions packages/cli/src/acp/AcpFileSystemService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,20 +397,6 @@ export class AcpFileSystemService implements FileSystemService {
.digest('hex')}`;
}

async readTextFileIfExists(
filePath: string,
options?: {
signal?: AbortSignal;
deadlineAt?: number;
purpose?: AcpRemoteFileRequestPurpose;
userReadPermit?: AcpRemoteUserReadPermit;
lease?: AcpRemoteMutationLease | AcpRemoteMutationRecoveryLease;
}
): Promise<{ exists: false } | { exists: true; content: string }> {
const remotePath = this.parsePath(filePath);
return this.readTextFileIfExistsForParsedPath(remotePath, options);
}

async readTextFileIfExistsForParsedPath(
remotePath: AcpRemotePath,
options?: {
Expand Down
Loading