forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Context
Phase 3b (PR on feature/taskctl-pipeline) implemented the developer→adversarial→commit inner loop in packages/opencode/src/tasks/pulse.ts. The tests in packages/opencode/test/tasks/pipeline.test.ts currently only verify that adversarial verdict data is correctly stored in the task store — they do not test the actual state machine logic.
What's missing
The following pulse.ts functions have no meaningful test coverage:
processAdversarialVerdicts()— APPROVED path should result in task statusclosed+ PM notification fired; ISSUES_FOUND should incrementpipeline.attemptand respawn developer; 3rd failure should set statusfailedand escalatecommitTask()— happy path closes task; failure path callsescalateCommitFailurerespawnDeveloper()— new session created in same worktree, attempt counter incremented, adversarial feedback passed in promptescalateToPM()— task status set tofailed,BackgroundTaskEventpublishedspawnAdversarial()— spawned whenpipeline.stage === 'reviewing', double-spawn prevention viaadversarial-runningstage
Why it's hard
These functions call Session.createNext(), SessionPrompt.prompt(), and Worktree.create/remove — real infrastructure that's difficult to test without a running server. The tests were scoped to Store-level data assertions as a pragmatic choice.
Suggested approach
Mock or stub Session and Worktree at the module boundary. Options:
- Extract the state-transition logic into pure functions that take/return plain objects (easier to test)
- Use Bun's module mock capabilities to stub
Session.createNextandSessionPrompt.prompt - Create a lightweight integration test harness that sets up a minimal in-process session
Acceptance criteria
-
processAdversarialVerdicts: APPROVED → task closed test -
processAdversarialVerdicts: ISSUES_FOUND → attempt incremented, developer respawned test -
processAdversarialVerdicts: 3rd failure → taskfailed+ escalation test - Double-processing prevention: verdict cleared before action (regression test)
-
bun testpasses,bun run typecheckpasses
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request