Orchestrata Ultimate › Tests › Reference › scripts › test_task_context_hook

Tests reference — tests/scripts/test_task_context_hook.py

Module of tests/scripts, split out because the directory page would be too large.

Prose pending.

tests/scripts/test_task_context_hook.py

source · 26 tests · 789 lines

Tests for claude/hooks/task_context_hook.py — the PreToolUse(Agent)

Kind Name Line Description
function test_files_block_paths_win_over_prose_mentions 161 Six prose-mentioned NONEXISTENT .py paths (parent dirs also missing,
function test_project_root_resolves_via_claude_project_dir_from_non_repo_cwd 193 cwd is a directory unrelated to the project (simulating the real
function test_project_root_resolves_via_git_root_when_project_dir_unset 214 No CLAUDE_PROJECT_DIR; cwd is a NESTED subdirectory of a git checkout.
function test_claude_project_dir_takes_priority_over_git_root 235 Both CLAUDE_PROJECT_DIR and a git root would resolve the SAME
function test_new_file_package_resolving_to_home_yields_no_context 263 The caught-red-handed scenario itself: cwd IS $HOME, the brief names
function test_new_file_package_not_in_home_still_renders_sibling_api 289 Regression safety net for the $HOME guard above: a legitimate
function test_falls_back_to_whole_prompt_when_files_block_has_no_py_mention 315
function test_never_blocks_on_malformed_stdin 341 Garbage stdin must never crash the hook or emit a decision that could
function test_structured_deny_when_module_context_tool_is_unreachable 357 Not a never-blocks case (a deny IS a block, by design) -- this proves
function test_non_agent_tool_call_is_silently_ignored 388 Only PreToolUse(Agent) is this hook's business -- any other tool_name
function test_already_enriched_prompt_is_left_alone 401 A prompt that already carries the WORKFLOW METHODOLOGY marker is a
function test_missing_required_field_denies_with_brief_template 416 A brief missing CONSTRAINTS: (one of the five REQUIRED_FIELDS) must be
function test_second_delegation_same_session_skips_already_seen_methodology 435 Same session, same categorized prompt, dispatched twice: the first
function test_unwritable_ledger_directory_never_breaks_the_decision 468 _remember's except OSError: pass -- a real, un-mocked way to
function test_files_block_returns_empty_when_no_files_marker_present 505 _files_block's own match is None branch -- unreachable through
function test_a_render_that_overruns_raises_instead_of_reading_as_empty 514 A timeout is not "this module has nothing to say", and must not say so.
function test_an_edit_whose_render_overruns_says_so_and_stays_retryable 541 The edit path reports the overrun, warms the cache, and does not dedup.
function test_existing_file_that_fails_to_render_is_not_treated_as_new_file 587 module_context_for's second loop: a candidate that IS an existing
function test_an_edit_injects_the_module_context_into_the_main_session 644
function test_the_edit_path_does_not_touch_the_permission_flow 659 Adding context must not decide permissions as a side effect.
function test_a_module_is_injected_once_per_session 676 The same ledger the Agent path uses, so the two routes cannot double up.
function test_a_different_module_in_the_same_session_still_injects 697 The ledger keys on the module, not on "has injected once".
function test_a_non_python_edit_injects_nothing 712
function test_writing_a_new_file_injects_the_package_it_joins 722 No AST yet, so the SIBLING public API — same as the Agent route.
function test_every_tool_the_hook_handles_is_actually_registered_for_it 744 Dead config is worse than dead code, and this hook proved it.
function test_the_agent_route_is_unchanged_by_the_edit_route 782 The brief gate must still fire — the edit path is additive, not a