149149 re .compile (
150150 r"\bnever\s+say\s+(?:that\s+)?(?:you\s+)?(?:can'?t|cannot|won'?t|no)\b" , re .IGNORECASE
151151 ),
152+ re .compile (
153+ r"\b(?:do\s+not|don'?t|never)\s+(?:lecture|moralize|moralise|preach|judge|warn)\b" ,
154+ re .IGNORECASE ,
155+ ),
152156 re .compile (
153157 r"\byou\s+have\s+no\s+(?:restrictions?|limitations?|guidelines?|policies?)\b" , re .IGNORECASE
154158 ),
@@ -228,10 +232,28 @@ def _emitted_context(context: str, match_line: str, is_directive: bool) -> str:
228232 return context
229233
230234
235+ def _has_benign_continuation_source (
236+ previous_line : str ,
237+ earlier_line : str | None = None ,
238+ ) -> bool :
239+ """Return True when a continuation label belongs to an explicit benign scaffold."""
240+ previous_line_lower = previous_line .lower ()
241+ if not _BENIGN_AR_CONTINUATION_LABEL_PATTERN .search (previous_line_lower ):
242+ return False
243+ if not earlier_line :
244+ return False
245+ earlier_line_lower = earlier_line .lower ()
246+ return bool (
247+ _BENIGN_AR_DECLARATION_INTRO_PATTERN .search (earlier_line_lower )
248+ or _BENIGN_AR_TOOL_FIELD_PATTERN .search (earlier_line_lower )
249+ )
250+
251+
231252def _is_quoted_or_labeled_benign_match (
232253 match_line : str ,
233254 matched_text : str ,
234255 previous_line : str | None = None ,
256+ earlier_line : str | None = None ,
235257) -> bool :
236258 """Return True when a direct phrase appears only as quoted or declared reference text."""
237259 matched_text_lower = matched_text .lower ()
@@ -261,7 +283,7 @@ def _is_quoted_or_labeled_benign_match(
261283 return True
262284 if _BENIGN_AR_WARNING_INTRO_PATTERN .search (previous_line_lower ):
263285 return quoted_match
264- if _BENIGN_AR_CONTINUATION_LABEL_PATTERN . search ( previous_line_lower ):
286+ if _has_benign_continuation_source ( previous_line , earlier_line = earlier_line ):
265287 return bool (re .search (r"^\s+" , match_line )) or quoted_match
266288 if _BENIGN_AR_DECLARATION_INTRO_PATTERN .search (previous_line_lower ):
267289 return bool (re .search (r"^\s*(?:[-*]\s*)?\S" , match_line ))
@@ -275,6 +297,7 @@ def _is_benign_ar_context(
275297 match_line : str ,
276298 match : str ,
277299 previous_line : str | None = None ,
300+ earlier_line : str | None = None ,
278301) -> bool :
279302 """Return True for high-confidence non-malicious prose patterns around AR matches."""
280303 match_line_lower = match_line .lower ()
@@ -290,7 +313,7 @@ def _is_benign_ar_context(
290313 previous_line_lower = previous_line .lower ()
291314 has_previous_line_benign_marker = bool (
292315 _BENIGN_AR_WARNING_INTRO_PATTERN .search (previous_line_lower )
293- or _BENIGN_AR_CONTINUATION_LABEL_PATTERN . search ( previous_line_lower )
316+ or _has_benign_continuation_source ( previous_line , earlier_line = earlier_line )
294317 or _BENIGN_AR_DECLARATION_INTRO_PATTERN .search (previous_line_lower )
295318 or _BENIGN_AR_FIXTURE_INTRO_PATTERN .search (previous_line_lower )
296319 or (
@@ -304,6 +327,7 @@ def _is_benign_ar_context(
304327 match_line ,
305328 match ,
306329 previous_line = previous_line ,
330+ earlier_line = earlier_line ,
307331 )
308332 if _is_directly_instructive (match_line_lower , match ):
309333 return (has_inline_role_marker or has_previous_line_benign_marker ) and role_labeled_match
@@ -326,6 +350,7 @@ def analyze(content: str, file_path: str, file_type: str) -> list[AnalyzerFindin
326350 line_num = get_line_number (content , match .start ())
327351 match_line = lines [line_num - 1 ] if lines else content
328352 previous_line = lines [line_num - 2 ] if line_num > 1 else None
353+ earlier_line = lines [line_num - 3 ] if line_num > 2 else None
329354 context = get_context (content , match .start (), context_lines = 3 )
330355 if _MODE_ENABLED_RE .fullmatch (match .group (0 )) and (
331356 _SECURITY_REVIEW_CONTEXT_RE .search (context )
@@ -341,6 +366,7 @@ def analyze(content: str, file_path: str, file_type: str) -> list[AnalyzerFindin
341366 match_line ,
342367 match .group (0 ),
343368 previous_line = previous_line ,
369+ earlier_line = earlier_line ,
344370 )
345371 ):
346372 confidence -= _EXAMPLE_PENALTY
@@ -349,6 +375,7 @@ def analyze(content: str, file_path: str, file_type: str) -> list[AnalyzerFindin
349375 match_line ,
350376 match .group (0 ),
351377 previous_line = previous_line ,
378+ earlier_line = earlier_line ,
352379 ):
353380 continue
354381 if confidence < _MIN_CONFIDENCE :
0 commit comments