Skip to content

Refactor rebuild test harnesses into a shared core with generic and Deep Agents Code profiles #8359

Description

@jyaunches

Objective

Replace two overlapping rebuild harness implementations with one shared core and two named profiles.

Evidence

  • test/helpers/rebuild-flow-harness.ts is 872 lines.
  • test/helpers/rebuild-flow-test-harness.ts is 695 lines.
  • Both load the rebuild graph, create sessions, install overlapping spies, emulate sandbox state, and restore mocks.
  • The older harness owns DCode route and image behavior.
  • The newer harness owns broader generic recovery, credential, messaging, and prepared-image behavior.
  • test/helpers/rebuild-flow-test-support.ts already owns part of the reusable type and session layer.

Scope

  • Extract one core for shared module loading, session creation, common spies, sandbox state, and cleanup.
  • Add only two profiles: generic and Deep Agents Code.
  • Migrate all current harness consumers.
  • Remove the superseded duplicate implementation.
  • Keep DCode-only image and route mocks out of the generic profile.
  • Keep generic credential, messaging, and prepared-image mocks from becoming mandatory DCode setup.
  • Do not change production source, supported behavior, test titles, or assertions.

Relationships

This is not a good first issue: it changes mock lifecycle across the rebuild suite.

Acceptance criteria

  • Common session, environment, module-loading, and mock lifecycle logic has one implementation.
  • Every rebuild suite selects the generic or DCode profile explicitly.
  • Profile-specific mocks remain isolated.
  • Existing test titles and collected-test counts remain unchanged.
  • Repository size, complexity, and project checks pass.
  • The change has a negative net LOC delta.

Validation

npx vitest run --project cli src/lib/actions/sandbox/rebuild*.test.ts
npm run typecheck:cli
npm run checks:repository

Metadata

Metadata

Assignees

Labels

area: architectureArchitecture, design debt, major refactors, or maintainabilityarea: sandboxOpenShell sandbox lifecycle, runtime, config, or recoveryhelp wantedMaintainers welcome external contributionintegration: dcodeLangChain Deep Code integration behavior

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions