-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Task Description
PR #179 (commit fbeb585ea) fixed the async task result delivery bug by adding parent_session_id to TaskMetadata and routing results via parent session ID. However, no regression test was added for this specific routing logic.
If someone swaps parent_session_id back to session_id in getAndClearCompletedTasks() or hasUndeliveredCompletedTasks(), no test would catch it.
What to Test
File: packages/opencode/test/session/async-tasks.test.ts (new file, or add to existing test)
-
Result retrieval by parent session ID: Call
trackBackgroundTask()with a child session ID as 3rd arg andparent_session_idset to a different parent ID in metadata. Then callgetAndClearCompletedTasks(parentID)— should find the result. Call withgetAndClearCompletedTasks(childID)— should NOT find it. -
hasUndeliveredCompletedTasks routing: Same setup —
hasUndeliveredCompletedTasks(parentID)should return true,hasUndeliveredCompletedTasks(childID)should return false. -
Event bus parentSessionID: When task completes, the
BackgroundTaskEvent.Completedevent should haveparentSessionIDmatching theparent_session_idfrom metadata, NOTsession_id. -
Cleanup uses child session_id:
cleanupSessionMaps(childID)should clean up the task.cleanupSessionMaps(parentID)should NOT clean up the child's task.
Key Files
packages/opencode/src/session/async-tasks.ts— functions under testpackages/opencode/test/tool/check_task.test.ts— existing task tests for reference
Quality Gates (Non-Negotiable)
- TDD: Tests written to fail if routing reverts to session_id
- Coverage: Cover all 4 scenarios above
- Linting: All code passes project linting rules
- Local Verification:
bun testpasses
Acceptance Criteria
- New test file or test block that specifically validates parent_session_id routing
- Tests fail if
parent_session_idis swapped back tosession_idin retrieval functions - All existing tests continue to pass