Skip to content

test(taskctl): integration test for full Pulse happy path — developing→reviewing→adversarial #257

@randomm

Description

@randomm

Goal

Write an in-process integration test that drives the complete Pulse happy path without a live binary, using TDD to fix the stuck-at-developing bug.

Why

The pipeline consistently stalls at stage: developing after the developer session completes. Rather than debugging through the live binary, this test will:

  1. Prove exactly where the transition fails
  2. Drive the fix via TDD
  3. Prevent regression

Happy Path to Test

scheduleReadyTasks → spawnDeveloper → SessionPrompt.prompt() completes
    → next Pulse tick → heartbeatActiveAgents detects idle session
    → stage: reviewing
    → scheduleReadyTasks → spawnAdversarial → SessionPrompt.prompt() completes
    → processAdversarialVerdicts → APPROVED → commitTask → stage: done

Key Observations

  • spawnDeveloper sets assignee_pid: process.pid (Pulse's own PID) — so isPidAlive is always true while running
  • await SessionPrompt.prompt() blocks the tick until developer completes
  • After prompt returns, SessionStatus for the dev session should be idle (set by defer(() => cancel()) in loop.ts)
  • The NEXT Pulse tick should then see sessionAlive=false, pidAlive=true, alive=false → transition to reviewing
  • Something is preventing this next tick from firing or the sessionAlive check from returning false

Suggested Approach

Mock SessionPrompt.prompt to return immediately (simulating developer completing), then run Pulse ticks manually via the exported tick functions or by directly calling heartbeatActiveAgents and scheduleReadyTasks.

Use Instance.provide + tmpdir fixture pattern from existing pipeline tests.

Export the internal tick functions (heartbeatActiveAgents, scheduleReadyTasks, processAdversarialVerdicts) if not already exported, so they can be called directly in tests.

Acceptance Criteria

  • Test creates a job + task in open state
  • Test calls scheduleReadyTasks → task becomes in_progress, stage: developing
  • Test simulates developer session completing (mock SessionPrompt, clear SessionStatus)
  • Test calls heartbeatActiveAgents → task becomes stage: reviewing
  • Test calls scheduleReadyTasks → adversarial session spawned (stage: adversarial-running)
  • Test simulates APPROVED verdict → task becomes closed, stage: done
  • bun test passes, bun run typecheck passes
  • If any step reveals a real bug, fix it as part of this issue (TDD)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions