Skip to content

Commit aa5a654

Browse files
committed
test(plugin): add budget and regex tests for standalone clarification gate (#1423)
- Add 5 tests: budget exhaustion, budget decrement, default budget, short snake_case rejection, real identifier matching (65 total)
1 parent 8cef0ed commit aa5a654

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

packages/claude-code-plugin/hooks/lib/test_mode_engine.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,36 @@ def test_vague_intent_question_content(self):
535535
self.assertIn("CLARIFICATION REQUIRED", result)
536536
self.assertIn("concrete change", result)
537537

538+
def test_budget_exhausted_skips_gate(self):
539+
result = self.engine.build_instructions(
540+
"PLAN", prompt="PLAN improve it", question_budget=0
541+
)
542+
self.assertNotIn("CLARIFICATION REQUIRED", result)
543+
self.assertIn("# Mode: PLAN", result)
544+
545+
def test_budget_decrements_in_directive(self):
546+
result = self.engine.build_instructions(
547+
"PLAN", prompt="PLAN improve it", question_budget=2
548+
)
549+
self.assertIn("CLARIFICATION REQUIRED", result)
550+
self.assertIn("Remaining question budget: 1", result)
551+
552+
def test_default_budget_is_three(self):
553+
result = self.engine.build_instructions("PLAN", prompt="PLAN improve it")
554+
self.assertIn("Remaining question budget: 2", result)
555+
556+
def test_snake_case_regex_ignores_short_fragments(self):
557+
"""snake_case pattern requires >=2 chars on each side of underscore."""
558+
result = self.engine.build_instructions("PLAN", prompt="PLAN a_b")
559+
# 'a_b' is too short for the tightened regex; prompt is also short
560+
self.assertIn("CLARIFICATION REQUIRED", result)
561+
562+
def test_snake_case_regex_matches_real_identifiers(self):
563+
result = self.engine.build_instructions(
564+
"PLAN", prompt="PLAN fix the parse_mode function"
565+
)
566+
self.assertNotIn("CLARIFICATION REQUIRED", result)
567+
538568

539569
if __name__ == "__main__":
540570
unittest.main()

0 commit comments

Comments
 (0)