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

Plan: Integration Test — BLOCKED:PERSISTENT → Gated → Refine Eligibility#

Summary#

Add an integration test that validates the end-to-end state-machine handoff: BLOCKED:PERSISTENT transitions a task to status=gated, a gated task is accepted by DirectiveService.applyDirective('refine'), a non-gated task is rejected, and re-firing BLOCKED:PERSISTENT on an already-gated task is idempotent. This bridges the gap between the isolated unit tests in internal-adapter.service.spec.ts and directive.service.spec.ts.

Files#

FileActionDescription
test/integration/blocked-persistent-gated-refine.integration.spec.tscreateNew integration test covering the BLOCKED:PERSISTENT → gated → refine flow
test/integration/integration-test.utils.tsinspectReuse existing test module factory pattern
src/internal-adapter/internal-adapter.service.tsinspecthandleSignal() and handlePersistentBlock() under test
src/directive/directive.service.tsinspectapplyDirective('refine') pre-validation under test
src/database/entities/task.entity.tsinspectTaskEntity schema for status/gate columns

Steps#

  1. S1: Create integration test file — Create test/integration/blocked-persistent-gated-refine.integration.spec.ts using the same in-memory SQLite + real TypeOrmModule pattern from internal-adapter.service.spec.ts. Wire both InternalAdapterService and DirectiveService with real TaskEntity repositories but mock external I/O (GitHub API calls, job queue, dispatch).

  2. S2: Implement test cases — Write four test cases: (a) BLOCKED:PERSISTENT sets status=gated, gatePhase, and gateReason; (b) applyDirective('refine') on that gated task succeeds — calls clearGate and enqueues the refine phase; (c) applyDirective('refine') on an active (non-gated) task is rejected with a comment; (d) re-firing BLOCKED:PERSISTENT on an already-gated task remains status=gated with no duplicate side effects. Each test includes inline comments referencing #243 and #237.

  3. S3: Verify tests pass — Run npm run test -- --testPathPattern=blocked-persistent-gated-refine and npm run lint to confirm green.

Verification#

  • npm run test -- --testPathPattern=blocked-persistent-gated-refine passes with 4 test cases
  • npm run lint reports zero warnings
  • Each test case includes traceability comments linking to #243 and #237

Risks#

  • DirectiveService has multiple dependencies (GitHub API, TaskStateService, etc.) that need careful mocking — mitigation: use the same mock patterns already established in directive.service.spec.ts, keeping real DB access for TaskEntity only.
ContextPrd