chore: launch readiness - Biome, tests, docs (#53, #54, #55, #56)#59
chore: launch readiness - Biome, tests, docs (#53, #54, #55, #56)#59
Conversation
- Install @biomejs/biome with noExplicitAny enforcement - Add lint, format, check scripts to package.json - Add Biome check step to CI between typecheck and build - Configure: error in src/, warn in tests/
Mechanical auto-format of all src/ and tests/ files. No logic changes - whitespace and trailing comma adjustments only.
- Replace `as any` casts with proper types across src/:
- cli.ts: generic container.resolve<T>, TaskId() branding, Priority enum
- task-queue.ts: HeapNode interface for typed __insertionOrder access
- queue-handler.ts: typed __correlationId via BaseEvent, typed respond()
- event-bus.ts: respond/respondError on EventBus interface, R=unknown
- errors.ts: narrow error cast to { message: unknown }
- worktree-manager.ts: NodeJS.ErrnoException for error.code
- output-repository.ts: Record<string, unknown>, catch (error: unknown)
- database.ts: catch (error: unknown) with instanceof check
- mcp-adapter.ts: MCPToolResponse interface, Task[] narrowing
- Add __correlationId to BaseEvent for first-class request-response
- Add biome-ignore suppressions for genuine TS limitations (DI container,
EventEmitter compat, DRY helper architecture exception)
- Auto-fix import organization via Biome assist
Mechanical import organization applied by `npx biome check --write tests/`.
New test files (247 tests total): - task-manager.test.ts (49 tests): delegate, getStatus, getLogs, cancel, retry chain tracking, resume with checkpoint enrichment - recovery-manager.test.ts (31 tests): QUEUED re-queuing, stale RUNNING detection, duplicate prevention, error propagation - container.test.ts (42 tests): singleton/transient/value registration, circular dependency detection, async resolution, dispose ordering - autoscaling-manager.test.ts (54 tests): start/stop lifecycle, event handling, checkScaling logic, debounced WorkerKilled, policy variants - event-driven-worker-pool.test.ts (37 tests): spawn with resource checks, worktree creation/fallback, kill lifecycle, timeout guards - worktree-manager.test.ts (34 tests): branch sanitization, merge strategies (PR/auto/manual/patch), auto-commit, safety checks Also: - Fix TaskFactory.build() Object.freeze mutation bug (spread instead of mutating frozen createTask() return value) - Add test:services script and include in test:all chain - Update CLAUDE.md with test:services documentation
) - Remove CLAUDE.md from .gitignore (checked into repo) - Remove duplicate coverage/ entry (already at line 41) - Remove duplicate .memory/ block - Update LICENSE year to 2024-2026 - Add .env.example with all 21 configuration variables and defaults - Add CONTRIBUTING.md with dev setup, test groups, code style, PR process
Root cause: auto-created checkpoints (from TaskCompleted event) and manually-saved test checkpoints could share the same created_at millisecond. Since findLatest uses ORDER BY created_at DESC LIMIT 1, the returned checkpoint was non-deterministic with equal timestamps. Fix: delete auto-created checkpoints before saving test-specific ones, ensuring findLatest always returns the intended checkpoint.
Review Summary by QodoLaunch readiness: Biome integration, comprehensive test coverage, and code quality improvements
WalkthroughsDescription• **Biome linter/formatter integration**: Installed Biome 2.4.4 with strict type checking (noExplicitAny: error for src/, warn for tests/). Applied comprehensive formatting across codebase with ~39 as any casts replaced with proper typing; remaining 4 have documented biome-ignore suppressions. • **Extensive test coverage**: Added 247 new unit tests across 6 previously untested modules (TaskManager, RecoveryManager, Container, AutoscalingManager, EventDrivenWorkerPool, GitWorktreeManager) with comprehensive scenario coverage including error handling and edge cases. • **Code quality improvements**: Reorganized imports alphabetically by type throughout codebase, added trailing commas for consistency, improved multi-line formatting, and enhanced type safety with explicit generic types and interface signatures. • **Documentation and configuration updates**: Created CONTRIBUTING.md and .env.example, fixed .gitignore duplicates, updated LICENSE year to 2024-2026, and added Biome linting step to CI pipeline. • **Bug fixes**: Fixed pre-existing TaskFactory.build() Object.freeze mutation bug and resolved 2 flaky integration tests caused by same-millisecond checkpoint timestamp race conditions. Diagramflowchart LR
A["Source Code"] -->|"Biome Linting"| B["Type Safety"]
A -->|"Auto-formatting"| C["Code Quality"]
D["Test Modules"] -->|"247 New Tests"| E["Test Coverage"]
F["CI Pipeline"] -->|"Add Biome Check"| G["Quality Gates"]
H["Documentation"] -->|"CONTRIBUTING.md<br/>.env.example"| I["Developer Guidance"]
B --> J["Launch Ready"]
C --> J
E --> J
G --> J
I --> J
File Changes1. tests/unit/core/dependency-graph.test.ts
|
Code Review by Qodo
1. as any remains in src
|
| // generic helper call site. This is a TypeScript limitation, not a design flaw. | ||
| // Safety: EventBus.emit() wraps payload in createEvent() which adds eventId/timestamp. | ||
| // The alternative would be no DRY helper at all - this trade-off is acceptable. | ||
| // biome-ignore lint/suspicious/noExplicitAny: TS can't infer payload type from string event type in DRY helper |
There was a problem hiding this comment.
1. as any remains in src 📎 Requirement gap ✓ Correctness
The PR keeps as any casts in src/ (and adds Biome suppressions), violating the requirement to eliminate all as any usage. This undermines the intended type-safety improvements and can reintroduce unsafe runtime behavior.
Agent Prompt
## Issue description
The PR leaves `as any` casts in `src/` and adds Biome suppressions, which violates the requirement that there be zero `as any` occurrences under `src/`.
## Issue Context
`as any` is being used to bypass EventBus typing limitations (string event names and convenience helpers). The goal is to preserve the ergonomics while keeping type safety.
## Fix Focus Areas
- src/core/events/handlers.ts[48-54]
- src/core/events/event-bus.ts[500-555]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // Phase 1: Create and persist tasks | ||
| const database1 = new Database(dbPath); | ||
| const repository1 = new SQLiteTaskRepository(database1); | ||
| const queue1 = new PriorityTaskQueue(logger); |
There was a problem hiding this comment.
2. Queue arg type mismatch 🐞 Bug ✓ Correctness
Multiple integration tests pass a Logger object into new PriorityTaskQueue(logger), but the constructor expects a numeric maxQueueSize. At runtime this coerces to NaN, disabling the queue full check and potentially masking resource-exhaustion behavior in tests.
Agent Prompt
### Issue description
Several integration tests call `new PriorityTaskQueue(logger)` even though `PriorityTaskQueue` expects a numeric `maxQueueSize`. This disables the queue-size guard at runtime due to `NaN` coercion and can mask failures.
### Issue Context
`PriorityTaskQueue` enforces DoS protection via `if (this.heap.length >= this.maxQueueSize)`.
### Fix Focus Areas
- tests/integration/task-persistence.test.ts[24-32]
- tests/integration/event-flow.test.ts[32-41]
- tests/integration/worker-pool-management.test.ts[158-165]
### Expected change
Replace `new PriorityTaskQueue(logger)` with `new PriorityTaskQueue()` (or `new PriorityTaskQueue(<number>)` if the test needs a small limit).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Summary
Completes all remaining items from the launch readiness checklist (#56):
as anyelimination: Installed Biome 2.4.4 withnoExplicitAny: errorforsrc/,warnfortests/. Applied auto-formatting. Replaced ~39as anycasts with proper typing; remaining 4 havebiome-ignoresuppression with documented justification.TaskFactory.build()Object.freeze mutation bug..gitignore(removedCLAUDE.mdentry, duplicatecoverage/, duplicate.memory/). Updated LICENSE year to 2024-2026. Created.env.exampleandCONTRIBUTING.md.Commits
chore: add Biome linter/formatter (#53)— biome.json, scripts, CI stepstyle: apply Biome formatting to existing code— mechanical auto-formatfix: eliminate as-any casts with proper typing (#53)— type fixes + biome-ignorestyle: apply Biome formatting to test files— mechanical import reorderingtest: add tests for 6 untested modules (#54)— 247 new tests + factory fixdocs: add CONTRIBUTING.md, .env.example, fix .gitignore and LICENSE (#55)fix: resolve flaky checkpoint tests— same-millisecond timestamp raceTest plan
npm run typecheckpassesnpm run check(Biome lint+format) passes — 0 errors, 264 warnings (allnoExplicitAnyin tests/, configured aswarn)npm run buildsucceedsnpm run test:core— 317/317npm run test:handlers— 80/80npm run test:services— 168/168 (new)npm run test:repositories— 109/109npm run test:adapters— 40/40npm run test:implementations— 255/255npm run test:cli— 86/86npm run test:scheduling— 73/73npm run test:checkpoints— 36/36npm run test:error-scenarios— 32/32npm run test:integration— 54/54 (3x stable)grep -r 'as any' src/shows only biome-ignore suppressed linesCloses #53, #54, #55, #56