Skip to content

Add tag-based filtering to debug() / HL_DEBUG_CODEGEN - #9381

Open
alexreinking wants to merge 2 commits into
mainfrom
alexreinking/debug-tag-filter
Open

Add tag-based filtering to debug() / HL_DEBUG_CODEGEN#9381
alexreinking wants to merge 2 commits into
mainfrom
alexreinking/debug-tag-filter

Conversation

@alexreinking

Copy link
Copy Markdown
Member

Summary

  • Add an optional stable tag to debug() call sites (debug(verbosity, "my-tag")), selectable via a new HL_DEBUG_CODEGEN=tag:name[,name...] rule that fires regardless of the configured verbosity — a way to select a specific print without relying on file/line ranges that drift as code changes.
  • Apply the new tag to the two diagnostics that most benefit from a stable selector: the "failed to prove, but could not find a counter-example" dump in Simplify.cpp (tag:counterexample) and the "expression is non-monotonic" warning in SimplifyCorrelatedDifferences.cpp (tag:non-monotonic).
  • Update the HL_DEBUG_CODEGEN grammar documentation in README.md and the malformed-entry warning message in Debug.cpp.

The debug(n) macro is now variadic; C++ overload resolution on argument count picks between the untagged and tagged debug_is_active_impl overloads, so none of the ~1000 existing untagged call sites need any changes.

Test plan

  • ctest --test-dir build -R correctness_debug_helpers — new unit tests for tag matching, non-matching, comma-separated tag lists, empty-entry tolerance, and malformed tag:/tag:, entries.
  • ctest --test-dir build -R correctness_simplify and correctness_debug_log_file pass.
  • Manual check: HL_DEBUG_CODEGEN=tag:counterexample (and the comma-separated form) surfaces the counter-example diagnostic from correctness_simplify without needing a line-range guess; silent by default and with a non-matching tag.
  • pre-commit run --all-files passes.

🤖 Generated with Claude Code

Selecting a specific debug() print via HL_DEBUG_CODEGEN currently
requires naming a file and line range, which drifts as soon as the
surrounding code changes. A call site can now be given a stable tag
(debug(verbosity, "my-tag")) selectable via a new tag:name[,name...]
rule that fires regardless of verbosity. Applied to the two prints
that most benefit from a stable selector: the Simplify.cpp
counter-example dump and the SimplifyCorrelatedDifferences.cpp
non-monotonic warning.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@alexreinking
alexreinking requested a review from abadams August 24, 2026 20:24
A shell that already has HL_DEBUG_CODEGEN set to a tag-only rule (e.g.
while exercising the new tag-filter feature) silently suppresses the
test's untagged debug(0) call, and any inherited HL_DEBUG_CODEGEN_LOG_FILE
would fight with the values the test sets per scenario. Clear both at
the top of each role (HL_DEBUG_CODEGEN unconditionally; the log file
only in the parent, before it starts overriding it).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mcourteaux

Copy link
Copy Markdown
Contributor

I'm thinking this debug logging filtering spec should probably also be explained in CLAUDE.md.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.06%. Comparing base (c049b16) to head (1fad681).

Files with missing lines Patch % Lines
src/Simplify.cpp 0.00% 0 Missing and 1 partial ⚠️
src/SimplifyCorrelatedDifferences.cpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9381      +/-   ##
==========================================
+ Coverage   70.03%   70.06%   +0.02%     
==========================================
  Files         261      261              
  Lines       79223    79243      +20     
  Branches    19312    19317       +5     
==========================================
+ Hits        55487    55522      +35     
- Misses      17923    17926       +3     
+ Partials     5813     5795      -18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants