Skip to content

refactor(loop): extract loop module into dedicated service layer#12

Open
chriswritescode-dev wants to merge 68 commits into
mainfrom
v0.4.0
Open

refactor(loop): extract loop module into dedicated service layer#12
chriswritescode-dev wants to merge 68 commits into
mainfrom
v0.4.0

Conversation

@chriswritescode-dev
Copy link
Copy Markdown
Owner

Extracts loop logic into a dedicated service layer with improvements to workspace management, sandbox handling, session lifecycle, and comprehensive test coverage.

Changes

Loop Module Extraction

  • Extract loop logic into dedicated src/loop/ module with runtime, service, state, transitions, and prompts
  • Consolidate execution service with rollback handling and type safety
  • Improve audit session tracking and session title management

Workspace & Sandbox Improvements

  • Add worktree-only mode allowing loops without Docker sandbox
  • Preserve branches and worktrees on non-completed termination for restart
  • Add sandbox environment context to loop prompts to reduce path/tool mismatch issues

Testing & Refactoring

  • Extensive test coverage across loop hooks, services, and utilities (~60+ new/updated test files)
  • Remove deprecated CLI commands (cancel, graph, restart, status, upgrade)
  • Remove graph system components (cache, client, database, RPC)
  • Simplify session title formatting

Files

  • src/loop/ — New dedicated loop module directory (runtime, service, state, transitions, prompts, etc.)
  • src/services/execution.ts — Major refactoring with improved rollback and type safety
  • src/hooks/loop.ts — Simplified hook implementation
  • test/hooks/*.test.ts — New comprehensive test suite for loop behaviors
  • docs/architecture.md — Updated architecture documentation
  • package.json, bun.lock, pnpm-lock.yaml — Dependency updates and version bumps

…tic logging

- Thread forge logger into createLoopWorkspace and bindSessionToWorkspace
  to enable observability in forge.log for workspace creation failures
- Remove workspace routing parameter from session.create to avoid
  MissingWorkspace errors when workspace hasn't reconciled
- Remove explicit id field from workspace.create to preserve the host's
  WorkspaceID.ascending() ID generation invariant
- Add comprehensive tests for workspace creation logging and session
  binding behavior
- Update plan-approval test to expect server-generated workspace ID
# Conflicts:
#	package.json
#	pnpm-lock.yaml
- Make reconcileStale selective with optional isSandboxLive probe
- Add isLiveByName for Docker-only liveness check in sandbox manager
- Reorder boot sequence: init sandboxManager before reconcileStale
- Remove activeSandboxLoops snapshot and explicit restore loop
- Add boot integration tests for sandbox preservation
- Extend unit tests for reconcileStale selectivity and isLiveByName
- Test now uses two loops: alpha (cancelled) and beta (preserved)
- Verifies reconcileSandboxes calls restore for beta (preserved loop)
- Satisfies Phase 4 acceptance criteria: reconcileSandboxes restores container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant