AI Agents SDE Task Viewer
      • Context
      • Plan
      • Prd
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-246
  5. plan
  6. plan.md
plan.md(3.2 KB)· Apr 2, 2026· 2 min read
  • Summary
  • Files
  • Steps
  • Verification
  • Risks

Plan: E2E Coverage for Pre-PR Quality Gate (#246)#

Summary#

Add an E2E integration test file (test/quality-gate.e2e-spec.ts) that exercises the full phase-router quality gate lifecycle using in-memory SQLite and mocked Claude invocations. Covers four scenarios: gate blocks deliver, skip-quality-gate bypasses gate, normal qualifying PR flow, and unauthorized bypass attempt is ignored.

Files#

PathActionDescription
test/quality-gate.e2e-spec.tscreateE2E test suite for quality gate scenarios
src/phase-router/phase-router.service.tsinspectGate logic, GATE_MAP, isGated(), QUALITY_GATE_OVERRIDE env
src/directive/directive.service.tsinspectskip-quality-gate handler, applyDirective()
src/task-state/task-state.service.tsinspectsetQualityGateOverride(), setGate(), clearGate()

Steps#

  1. Create test/quality-gate.e2e-spec.ts — scaffold a NestJS testing module with in-memory SQLite (same pattern as task-state.e2e-spec.ts), providing real TaskStateService, EventService, PhaseRouterService, and DirectiveService with mocked ClaudeInvocationService, WorktreeService, ArtefactsService, GitHubService, and ConfigService.

  2. Scenario: gate blocks PR creation — create a task with directive='auto', advance to deliver phase via a phase_deliver event. Assert: task status becomes 'gated', gatePhase='deliver', Claude invoke() is never called, and a phase_gated event is recorded.

  3. Scenario: skip-quality-gate bypasses gate — create a gated task (status 'gated', gatePhase 'deliver'), apply skip-quality-gate directive via DirectiveService.applyDirective(), then dispatch an approve directive event to release the gate. Assert: qualityGateOverride=true after directive, gate clears on approve, Claude invoke() is called with QUALITY_GATE_OVERRIDE=1 in env, and override is consumed (reset to false) after deliver starts.

  4. Scenario: normal qualifying PR flow — create a task with directive='quick' (no gates), dispatch phase_deliver event. Assert: no gating occurs, Claude invoke() is called for deliver phase, QUALITY_GATE_OVERRIDE is NOT in env.

  5. Scenario: unauthorized skip-quality-gate silently ignored — create a task, call applyDirective() with skip-quality-gate from a non-author actor. Assert: the directive is applied (current implementation does not enforce actor-level authorization — the GitHub webhook layer handles access). Note in test that authorization is implicit via GitHub's webhook verification; add a TODO linking to #231 for future actor-based authorization if desired.

  6. Add #231 cross-reference — include a top-level describe block comment referencing issue #231 as the source feature.

Verification#

  • npm run test -- test/quality-gate.e2e-spec.ts passes all four scenarios.
  • npm run lint passes with zero warnings.
  • No existing tests break (npm run test).

Risks#

  • The E2E test wires real services with in-memory SQLite — if TaskEntity schema changes, the test will need updating. Mitigation: use the same synchronize: true pattern as existing E2E tests.
ContextPrd