---
phase: 10-multi-question-schema
plan: 04
type: execute
wave: 3
depends_on: ["10-02", "10-03"]
files_modified:
  - src/test/e2e/edge-cases.test.ts
  - src/test/e2e/recovery-scenarios.test.ts
autonomous: true
---

<objective>
Update E2E tests to use questions array schema and add multi-question E2E scenario.

Purpose: Prove multi-question flow works end-to-end through dispatch/coordination.
Output: E2E tests pass with new schema, multi-question scenario validated.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/phases/10-multi-question-schema/10-02-SUMMARY.md
@.planning/phases/10-multi-question-schema/10-03-SUMMARY.md

@src/test/e2e/edge-cases.test.ts
@src/test/e2e/recovery-scenarios.test.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Update existing E2E tests for questions array</name>
  <files>src/test/e2e/edge-cases.test.ts, src/test/e2e/recovery-scenarios.test.ts</files>
  <action>
Update all E2E tests that use question scenarios:

1. edge-cases.test.ts:
   - Find all setAgentQuestion calls, update to new signature with id
   - Update any direct scenario setting to use questions array
   - Update assertions checking question data

2. recovery-scenarios.test.ts:
   - Update Q&A flow tests to use questions array format
   - Update resume calls to pass answers as Record<string, string>
   - Update assertions for getPendingQuestions

Replace patterns:
- `harness.setAgentQuestion(name, question)` → `harness.setAgentQuestion(name, 'q1', question)`
- `agentManager.resume(id, answer)` → `agentManager.resume(id, { q1: answer })`
  </action>
  <verify>npm run test:e2e passes</verify>
  <done>Existing E2E tests pass with questions array schema</done>
</task>

<task type="auto">
  <name>Task 2: Add multi-question E2E test</name>
  <files>src/test/e2e/recovery-scenarios.test.ts</files>
  <action>
Add new test in "Agent Q&A extended scenarios" describe block:

```typescript
it('should handle agent asking multiple questions at once', async () => {
  // Setup: agent asks two questions
  harness.setAgentQuestions('worker', [
    { id: 'q1', question: 'Which database?', options: [{ label: 'SQLite' }, { label: 'Postgres' }] },
    { id: 'q2', question: 'Include tests?', options: [{ label: 'Yes' }, { label: 'No' }] },
  ]);

  // Dispatch task
  await harness.dispatchManager.queueTask({ ... });
  await harness.dispatchManager.processQueue();
  await harness.waitForEvent('agent:waiting');

  // Verify both questions present
  const pending = await harness.getPendingQuestions('worker');
  expect(pending?.questions).toHaveLength(2);
  expect(pending?.questions[0].id).toBe('q1');
  expect(pending?.questions[1].id).toBe('q2');

  // Resume with answers for both questions
  harness.setAgentDone('worker');
  const agent = await harness.agentManager.getByName('worker');
  await harness.agentManager.resume(agent!.id, {
    q1: 'SQLite',
    q2: 'Yes',
  });

  // Wait for completion
  await harness.waitForEvent('agent:stopped');

  // Verify task completed
  const task = await harness.taskRepository.findById(...);
  expect(task?.status).toBe('completed');
});
```
  </action>
  <verify>npm run test:e2e passes including new multi-question test</verify>
  <done>Multi-question E2E test validates full flow</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] `npm run test` passes (all unit + E2E tests)
- [ ] Multi-question scenario test exists and passes
- [ ] No references to old single-question format in E2E tests
</verification>

<success_criteria>

- All tasks completed
- All E2E tests updated to questions array format
- New multi-question E2E test validates batched answers
- All tests pass
</success_criteria>

<output>
After completion, create `.planning/phases/10-multi-question-schema/10-04-SUMMARY.md`
</output>
