# APOPHIS Task Breakdown ## Completed (v1.1) ### Phase 1: Core Extension Points - [x] Add `headers` field to `ApophisExtension` interface - [x] Implement `getExtensionHeaders()` in ExtensionRegistry - [x] Update parser to accept extension headers - [x] Verify evaluator supports extension predicates - [x] Add 14 tests ### Phase 2A: Multipart Uploads - [x] Add `MultipartFile` and `MultipartPayload` types - [x] Implement multipart schema-to-arbitrary handler - [x] Update request builder for multipart payloads - [x] Add multipart support to HTTP executor - [x] Add `request_files` and `request_fields` parser operations - [x] Add multipart operations to evaluator - [x] File arrays: `maxCount > 1` generates arrays of files - [x] Add 9 tests ### Phase 2B: Streaming / NDJSON - [x] Add `chunks` and `streamDurationMs` to EvalContext.response - [x] Add streaming config extraction from schema - [x] Implement NDJSON parsing in HTTP executor - [x] Add `stream_chunks` and `stream_duration` parser operations - [x] Add streaming operations to evaluator - [x] Integration tests with Fastify NDJSON routes - [x] Add 7 tests ### Phase 2C: Extension System Polish - [x] Update contract-validation.ts with extension headers - [x] Update substitutor.ts with extension header support - [x] Add integration tests for extension registration - [x] Add 5 tests ### Phase 3A: SSE Extension - [x] Create `src/extensions/sse/` module - [x] Implement SSE format parser - [x] Implement `sse_events` predicate - [x] Add response transformer hook - [x] Integration tests with Fastify SSE routes - [x] Add 7 tests ### Phase 3B: Serializers Extension - [x] Create `src/extensions/serializers/` module - [x] Implement `SerializerRegistry` - [x] Implement request/response transformers - [x] Create `createSerializerExtension()` factory - [x] Integration tests for request body transformation - [x] Add 4 tests ### Phase 3C: WebSockets Extension - [x] Create `src/extensions/websocket/` module - [x] Implement `ws_message` and `ws_state` predicates - [x] Add `onSuiteStart` pre-validation hook - [x] Implement `runWebSocketTests()` runner - [x] State transition validation - [x] Add 5 tests ### Phase 4: TypeScript Strict Mode - [x] Fix `src/domain/request-builder.ts`: multipart files type - [x] Fix `src/extension/registry.ts`: type safety - [x] Fix `src/extensions/sse/transformer.ts`: SSEEvent type - [x] Fix `src/extensions/sse/test.ts`: predicate assertions - [x] Fix `src/extensions/websocket/test.ts`: predicate assertions - [x] Fix `src/formula/evaluator.ts`: accessor undefined checks, restore exports - [x] Fix all extension tests: predicate return type narrowing - [x] Fix all test helpers: HttpMethod casting - [x] `npx tsc --noEmit` passes with zero errors - [x] All 468 tests passing ### Phase 5: Extension System Hardening - [x] Dependency ordering: `dependsOn` with topological sort - [x] Async boot: `onSuiteStart` hooks run in dependency order - [x] Health checks: `healthCheck` field with `runHealthChecks()` - [x] State isolation with `Object.freeze()` - [x] Redaction of sensitive data before passing to extensions - [x] Timeout guards on all hooks - [x] Prototype pollution prevention in accessor resolution - [x] `validateFormula()`: error messages with suggestions ### Phase 7: Schema-to-Contract Inference - [x] Create `src/domain/schema-to-contract.ts` module - [x] Infer `!= null` from `required` fields - [x] Infer `>=` / `<=` from `minimum` / `maximum` bounds - [x] Infer `matches` from `pattern` regexes - [x] Infer `==` from `const` values - [x] Infer `==` / `||` chains from small `enum` sets - [x] Recurse into nested objects and arrays - [x] Merge inferred + explicit contracts in `extractContract()` - [x] Deduplicate inferred against explicit `x-ensures` - [x] Add 15 tests for inference logic - [x] Add integration tests for `extractContract` merging - [x] Build passes with 0 TypeScript errors - [x] 482 tests passing ### Phase 6: Code Cleanup - [x] Evaluator deduplication: operation lookup table, shared `resolveAccessor()` - [x] Error suggestions: imperative if-chain to pattern matchers - [x] Extension registry: `handleHookError()` utility - [x] Shared test utilities: `src/test/helpers.ts` - [x] Shared runner utilities: `src/test/runner-utils.ts` - [x] Test deduplication: convert test files to shared helpers - [x] Remove duplicate `scope auto-discovery` test - [x] Shared security utilities: `src/infrastructure/security.ts` - [x] Deduplicate error handling: `getErrorMessage()` replaces 19 instances - [x] Deduplicate path param extraction: shared `extractPathParams()` ## Release Criteria - [x] TypeScript strict mode passes - [x] All integration tests pass - [x] Performance benchmarks within 5% of v1.0 - [x] Documentation complete - [x] CHANGELOG.md updated - [x] README.md updated - [x] Version bumped in package.json