@@ -199,3 +199,108 @@ def test_sync_parse_tests_md_preserves_letter_suffix(self, tmp_path: Path) -> No
199199 assert "TEST-NN-002a" in ids
200200 assert "TEST-NN-002b" in ids
201201 assert "TEST-NN-002" not in ids # must not be truncated
202+
203+
204+ # ---------------------------------------------------------------------------
205+ # REQ-357: accepted_warnings suppression
206+ # ---------------------------------------------------------------------------
207+
208+
209+ class TestAcceptedWarningsSuppression :
210+ """Tests for REQ-357 — accepted_warnings suppression in auditor."""
211+
212+ def test_accepted_warnings_suppresses_type_mismatch (self , tmp_path : Path ) -> None :
213+ """scaffold_type_mismatch alias should suppress the type-mismatch check."""
214+ # Set up a minimal project with a type that will mismatch detection
215+ (tmp_path / "AGENTS.md" ).write_text ("# AGENTS\n Short.\n " , encoding = "utf-8" )
216+ (tmp_path / "LEDGER.md" ).write_text ("# Ledger\n Done.\n " , encoding = "utf-8" )
217+ docs = tmp_path / "docs"
218+ docs .mkdir ()
219+ (docs / "TESTS.md" ).write_text ("# Tests\n " , encoding = "utf-8" )
220+ # Use a type that differs from what detect_project will infer.
221+ # "backend-frontend" is unlikely to match a near-empty tmp project.
222+ (tmp_path / "scaffold.yml" ).write_text (
223+ "name: test\n "
224+ "type: backend-frontend\n "
225+ "spec_version: 0.10.1\n "
226+ "vcs_platform: github\n "
227+ "accepted_warnings:\n "
228+ " - scaffold_type_mismatch\n " ,
229+ encoding = "utf-8" ,
230+ )
231+
232+ report = run_audit (tmp_path )
233+
234+ # Find the type-mismatch result
235+ tm_results = [r for r in report .results if r .name == "type-mismatch" ]
236+ if tm_results :
237+ assert tm_results [0 ].suppressed is True
238+ assert tm_results [0 ].passed is True
239+ # The suppressed result must not count as a failure
240+ type_mismatch_failures = [
241+ r for r in report .results if r .name == "type-mismatch" and not r .passed
242+ ]
243+ assert len (type_mismatch_failures ) == 0
244+
245+ def test_ledger_line_threshold_suppresses_ledger_size (self , tmp_path : Path ) -> None :
246+ """ledger_line_threshold alias should suppress ledger-size check."""
247+ (tmp_path / "AGENTS.md" ).write_text ("# AGENTS\n Short.\n " , encoding = "utf-8" )
248+ big_ledger = "# Ledger\n " + "\n " .join (f"Line { i } " for i in range (600 ))
249+ (tmp_path / "LEDGER.md" ).write_text (big_ledger , encoding = "utf-8" )
250+ (tmp_path / "scaffold.yml" ).write_text (
251+ "name: test\n "
252+ "type: cli-python\n "
253+ "spec_version: 0.10.1\n "
254+ "vcs_platform: github\n "
255+ "accepted_warnings:\n "
256+ " - ledger_line_threshold\n " ,
257+ encoding = "utf-8" ,
258+ )
259+
260+ report = run_audit (tmp_path )
261+
262+ size_results = [r for r in report .results if r .name == "ledger-size" ]
263+ assert len (size_results ) == 1
264+ assert size_results [0 ].suppressed is True
265+ assert size_results [0 ].passed is True
266+ # Should not count toward failures
267+ assert all (
268+ r .passed or r .name != "ledger-size" for r in report .results
269+ )
270+
271+ def test_audit_suppressions_backward_compat (self , tmp_path : Path ) -> None :
272+ """Old audit_suppressions: [ledger_size] field should still suppress ledger-size."""
273+ (tmp_path / "AGENTS.md" ).write_text ("# AGENTS\n Short.\n " , encoding = "utf-8" )
274+ big_ledger = "# Ledger\n " + "\n " .join (f"Line { i } " for i in range (600 ))
275+ (tmp_path / "LEDGER.md" ).write_text (big_ledger , encoding = "utf-8" )
276+ (tmp_path / "scaffold.yml" ).write_text (
277+ "name: test\n "
278+ "type: cli-python\n "
279+ "spec_version: 0.10.1\n "
280+ "vcs_platform: github\n "
281+ "audit_suppressions:\n "
282+ " - ledger_size\n " ,
283+ encoding = "utf-8" ,
284+ )
285+
286+ report = run_audit (tmp_path )
287+
288+ size_results = [r for r in report .results if r .name == "ledger-size" ]
289+ assert len (size_results ) == 1
290+ assert size_results [0 ].suppressed is True
291+ assert size_results [0 ].passed is True
292+
293+ def test_suppressed_count_property (self , tmp_path : Path ) -> None :
294+ """AuditReport.suppressed_count should reflect the number of suppressed results."""
295+ from specsmith .auditor import AuditReport , AuditResult , _apply_accepted_warnings
296+
297+ report = AuditReport (results = [
298+ AuditResult (name = "ledger-size" , passed = False , message = "too big" , fixable = True ),
299+ AuditResult (name = "type-mismatch" , passed = False , message = "mismatch" ),
300+ AuditResult (name = "other-check" , passed = True , message = "ok" ),
301+ ])
302+ _apply_accepted_warnings (report , ["ledger_line_threshold" , "scaffold_type_mismatch" ])
303+
304+ assert report .suppressed_count == 2
305+ assert report .failed == 0
306+ assert report .healthy is True
0 commit comments