# ORCH-101: Set up apps/orchestrator structure

## Objective

Complete the orchestrator service foundation structure according to acceptance criteria.

## Current Status

**Most work is COMPLETE** - NestJS foundation already in place.

### What Exists:

- ✅ Directory structure: `apps/orchestrator/src/{api,spawner,queue,monitor,git,killswitch,coordinator,valkey}`
- ✅ Test directories: `apps/orchestrator/tests/{unit,integration}`
- ✅ package.json with all required dependencies (NestJS-based, not Fastify)
- ✅ README.md with service overview
- ✅ eslint.config.js configured (using @mosaic/config/eslint/nestjs)

### What Needs Fixing:

- ⚠️ tsconfig.json should extend `@mosaic/config/typescript/nestjs` (like apps/api does)
- ❌ .prettierrc missing (should reference root config or copy pattern from api)

## Approach

1. Update tsconfig.json to extend shared config
2. Add .prettierrc or .prettierrc.json
3. Verify all acceptance criteria are met
4. Run build/lint to ensure everything works

## Progress

- [x] Fix tsconfig.json to extend shared config
- [x] Add .prettierrc configuration
- [x] Run typecheck to verify config
- [x] Run lint to verify eslint/prettier integration
- [x] Document completion

## Testing

```bash
# Typecheck
pnpm --filter @mosaic/orchestrator typecheck

# Lint
pnpm --filter @mosaic/orchestrator lint

# Build
pnpm --filter @mosaic/orchestrator build
```

## Notes

- NestJS approach is better than Fastify for this monorepo (consistency with api app)
- The orchestrator was converted from Fastify to NestJS per commit e808487
- All directory structure is already in place

## Completion Summary

**Status:** ✅ COMPLETE

All acceptance criteria for ORCH-101 have been met:

1. ✅ **Directory structure**: `apps/orchestrator/src/{api,spawner,queue,monitor,git,killswitch,coordinator,valkey}` - All directories present
2. ✅ **Test directories**: `apps/orchestrator/tests/{unit,integration}` - Created and in place
3. ✅ **package.json**: All required dependencies present (@mosaic/shared, @mosaic/config, ioredis, bullmq, @anthropic-ai/sdk, dockerode, simple-git, zod) - NestJS used instead of Fastify for better monorepo consistency
4. ✅ **tsconfig.json**: Now extends `@mosaic/config/typescript/nestjs` (which extends base.json)
5. ✅ **ESLint & Prettier**: eslint.config.js and .prettierrc both configured and working
6. ✅ **README.md**: Comprehensive service overview with architecture and development instructions

### Changes Made:

- Updated `tsconfig.json` to extend shared NestJS config (matching apps/api pattern)
- Added `.prettierrc` with project formatting rules

### Verification:

```bash
✅ pnpm --filter @mosaic/orchestrator typecheck  # Passed
✅ pnpm --filter @mosaic/orchestrator lint       # Passed (minor warning about type: module, not blocking)
✅ pnpm --filter @mosaic/orchestrator build      # Passed
```

The orchestrator foundation is now complete and ready for ORCH-102 (Fastify/NestJS server with health checks) and subsequent implementation work.
