fix(export): gate tagged_nodes/coverage stats on embed_hierarchy_attributes#329
Merged
Conversation
…attributes Add _update_tag_stats() to centralise the embed-aware calculation, so tagged_nodes and coverage_percentage report 0 when hierarchy tagging is disabled via --no-hierarchy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…PORT_STATS - Move empty_tags calculation into _update_tag_stats so it is consistently zeroed when embed_hierarchy_attributes=False, matching tagged_nodes and coverage_percentage. - Remove now-redundant standalone empty_tags blocks from export() and _apply_hierarchy_tags(). - Add per-field comments to DEFAULT_EXPORT_STATS explaining each stat. - Merge the two redundant disabled-hierarchy tests into one; drop "Bug D:" from class docstring. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tezheng
approved these changes
Apr 14, 2026
tezheng
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Code is correct — _update_tag_stats() properly gates stats on embed_hierarchy_attributes and eliminates the duplication between export() and _apply_hierarchy_tags(). Ruff clean.
Minor notes (non-blocking):
- Monitor at
exporter.py:283-293still receives raw non-gated values while_export_statsgets gated zeros when embed=False — worth a comment if intentional. - Consider adding a test for empty/whitespace tag counting (
empty_tagscardinal rule path).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_update_tag_stats(total_nodes)helper onHTPExporterthat centralises the embed-aware calculation:tagged_nodesandcoverage_percentagereport0whenembed_hierarchy_attributes=False(i.e.wmk export --no-hierarchy).export()and_apply_hierarchy_tags()with calls to_update_tag_stats().Test plan
TestHTPExporterTaggedNodesStats::test_tagged_nodes_zero_when_hierarchy_disabledTestHTPExporterTaggedNodesStats::test_coverage_zero_when_hierarchy_disabledTestHTPExporterTaggedNodesStats::test_tagged_nodes_nonzero_when_hierarchy_enabled(control)Extracted from #209 (Bug D only).
🤖 Generated with Claude Code