@@ -81,6 +81,33 @@ def test_cursor_payload_with_claude_code_ide(
8181 assert response == {} # Claude Code allow_prompt returns empty dict
8282
8383
84+ class TestSyntheticPromptSkipsProcessing :
85+ """Tests that verify synthetic (harness-generated) prompts cause early exit without API calls."""
86+
87+ def test_task_notification_prompt_skipped (
88+ self ,
89+ mock_ctx : MagicMock ,
90+ mocker : MockerFixture ,
91+ capsys : pytest .CaptureFixture [str ],
92+ mock_scan_command_deps : dict [str , MagicMock ],
93+ ) -> None :
94+ """Fork/subagent completions arrive as synthetic <task-notification> user turns
95+ that fire UserPromptSubmit in the parent session; they must not be scanned."""
96+ payload = {
97+ 'hook_event_name' : 'UserPromptSubmit' ,
98+ 'session_id' : 'session-123' ,
99+ 'transcript_path' : '/home/user/.claude/projects/transcript.jsonl' ,
100+ 'prompt' : '<task-notification>Task dummy-task-1 completed</task-notification>' ,
101+ }
102+ mocker .patch ('sys.stdin' , StringIO (json .dumps (payload )))
103+
104+ scan_command (mock_ctx , ide = 'claude-code' )
105+
106+ _assert_no_api_calls (mock_scan_command_deps )
107+ response = json .loads (capsys .readouterr ().out )
108+ assert response == {} # Claude Code allow_prompt returns empty dict
109+
110+
84111class TestInvalidPayloadSkipsProcessing :
85112 """Tests that verify invalid payloads cause early exit without API calls."""
86113
0 commit comments