Skip to content

fix(export): gate tagged_nodes/coverage stats on embed_hierarchy_attributes#329

Merged
xieofxie merged 2 commits into
mainfrom
hualxie/fix-bug-D
Apr 15, 2026
Merged

fix(export): gate tagged_nodes/coverage stats on embed_hierarchy_attributes#329
xieofxie merged 2 commits into
mainfrom
hualxie/fix-bug-D

Conversation

@xieofxie

Copy link
Copy Markdown
Contributor

Summary

  • Add _update_tag_stats(total_nodes) helper on HTPExporter that centralises the embed-aware calculation: tagged_nodes and coverage_percentage report 0 when embed_hierarchy_attributes=False (i.e. wmk export --no-hierarchy).
  • Replace the two duplicated inline stat-calculation blocks in export() and _apply_hierarchy_tags() with calls to _update_tag_stats().

Test plan

  • TestHTPExporterTaggedNodesStats::test_tagged_nodes_zero_when_hierarchy_disabled
  • TestHTPExporterTaggedNodesStats::test_coverage_zero_when_hierarchy_disabled
  • TestHTPExporterTaggedNodesStats::test_tagged_nodes_nonzero_when_hierarchy_enabled (control)

Extracted from #209 (Bug D only).

🤖 Generated with Claude Code

hualxie and others added 2 commits April 14, 2026 10:43
…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>
@xieofxie xieofxie requested a review from a team as a code owner April 14, 2026 02:49

@tezheng tezheng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-293 still receives raw non-gated values while _export_stats gets gated zeros when embed=False — worth a comment if intentional.
  • Consider adding a test for empty/whitespace tag counting (empty_tags cardinal rule path).

@xieofxie xieofxie merged commit 7694638 into main Apr 15, 2026
9 checks passed
@xieofxie xieofxie deleted the hualxie/fix-bug-D branch April 15, 2026 02:07
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