Skip to content

feat(skills): expand fuzz_has_formatting_variation to cover all formatting properties (#1143)#1296

Open
PratikWayase wants to merge 8 commits intomicrosoft:mainfrom
PratikWayase:feat/fuzz-formatting-variation-1143
Open

feat(skills): expand fuzz_has_formatting_variation to cover all formatting properties (#1143)#1296
PratikWayase wants to merge 8 commits intomicrosoft:mainfrom
PratikWayase:feat/fuzz-formatting-variation-1143

Conversation

@PratikWayase
Copy link
Copy Markdown
Contributor

Description

Expanded the fuzz_has_formatting_variation fuzz target to cover all formatting properties used by _has_formatting_variation.

Previously, the fuzz harness only exercised:

  • font.name
  • font.bold
  • font.italic

This PR adds coverage for:

  • font.underline
  • font.color.rgb
  • font.size

Also added corpus seed files under tests/corpus/ to improve fuzzing effectiveness and broaden input coverage.


Related Issue(s)

Fixes #1143


Type of Change

Select all that apply:

Code & Documentation:

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update

Infrastructure & Configuration:

  • GitHub Actions workflow
  • Linting configuration (markdown, PowerShell, etc.)
  • Security configuration
  • DevContainer configuration
  • Dependency update

AI Artifacts:

  • Reviewed contribution with prompt-builder agent and addressed all feedback
  • Copilot instructions (.github/instructions/*.instructions.md)
  • Copilot prompt (.github/prompts/*.prompt.md)
  • Copilot agent (.github/agents/*.agent.md)
  • Copilot skill (.github/skills/*/SKILL.md)

Other:

  • Script/automation (.py)
  • Other (please describe):

Testing

  • Ran:

    uv run pytest .github/skills/experimental/powerpoint/tests/fuzz_harness.py -v
  • All tests passing (28/28)

  • Verified coverage for:

    • underline variation
    • color.rgb variation
    • size variation
  • Confirmed fuzz harness works in pytest mode and is compatible with Atheris fuzzing


Checklist

Required Checks

  • Documentation is updated (if applicable)
  • Files follow existing naming conventions
  • Changes are backwards compatible (if applicable)
  • Tests added for new functionality (if applicable)

AI Artifact Contributions

  • Used /prompt-analyze to review contribution
  • Addressed all feedback from prompt-builder review
  • Verified contribution follows common standards and type-specific requirements

Required Automated Checks

  • Markdown linting: npm run lint:md
  • Spell checking: npm run spell-check
  • Frontmatter validation: npm run lint:frontmatter
  • Skill structure validation: npm run validate:skills
  • Link validation: npm run lint:md-links
  • PowerShell analysis: npm run lint:ps
  • Plugin freshness: npm run plugin:generate

Security Considerations

  • This PR does not contain any sensitive or NDA information
  • Any new dependencies have been reviewed for security issues
  • Security-related scripts follow the principle of least privilege

Additional Notes


@PratikWayase PratikWayase requested a review from a team as a code owner April 4, 2026 06:13
PratikWayase and others added 4 commits April 4, 2026 11:48
…iles

- fix _has_formatting_variation dict-style branch to handle string colors
- remove tracked .bin seed files and add corpus .gitignore
- add dict-style test infrastructure to fuzz_harness
- fix PS1 indentation and EOF newlines

🐛 - Generated by Copilot
- add *.bin pattern to root .gitignore for project-wide coverage
- remove local corpus-specific .gitignore

🧹 - Generated by Copilot
Copy link
Copy Markdown
Contributor

@katriendg katriendg left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution. Expanding fuzz coverage for _has_formatting_variation is valuable work and aligns well with the deferred item from PR #1102. We appreciate the thoroughness of the new test cases covering all 6 formatting properties and the effort to add both object-style and dict-style test paths.

That said, we require some changes before this PR is ready to merge. Please review our PR Review comments.

@@ -394,23 +394,40 @@ def extract_child_shape(


def _has_formatting_variation(runs: list) -> bool:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment 1 (Lines 397 through 430)

  • Category: Functional Correctness
  • Severity: ❌ Blocker

The refactored _has_formatting_variation changes behavior for dict-style inputs. The original compares only among runs that have a given key — missing keys are skipped. The new tuple-based comparison treats missing keys as None, causing false-positive variation when runs have different key sets (a normal production scenario from extract_font_info()).

This change is also out of scope — issue #1143 asks to expand the fuzz harness, not rewrite the production function.

Suggested Change: Revert to the original implementation on main.

@@ -81,27 +84,44 @@ def fuzz_max_severity(data):
with suppress(KeyError):
max_severity(results)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment 2 (Lines 84 through 124)

  • Category: Functional Correctness
  • Severity: ❌ Blocker

The fuzz target on main already covers all 6 dict properties (font, size, color, bold, italic, underline). The issue description was inaccurate when it stated only 3 were exercised. This PR replaces the working dict-based target with MockRun objects that exercise a code path production never uses. Revert to the original dict-based implementation.

The valuable addition from this PR is the new deterministic pytest tests (test_underline_variation, test_size_variation, test_color_rgb_variation, etc.) — those should be kept since main only had 4 basic assertions. Adjust them to use dict-style helpers matching production data shapes (see item 5).

Suggested Change: Revert fuzz_has_formatting_variation to its original implementation on main. Remove MockRun, MockFont, and MockFontColor classes.

from contextlib import suppress
from unittest.mock import MagicMock

sys.modules["cairosvg"] = MagicMock()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment 3 (Lines 7 through 10)

  • Category: Code Quality
  • Severity: 💡 Suggestion

sys.modules["cairosvg"] = MagicMock() at module level is a global side effect. Consider moving this to conftest.py or guarding with a conditional import check.

@@ -0,0 +1,38 @@
"""Generate corpus seeds for fuzz targets."""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment 4 (Lines 1 through 38)

  • Category: Conventions
  • Severity: ⚠️ Required

Module-level write_seed() calls execute on import, creating files as a side effect. Existing corpus files are committed directly without a generator. Either remove this file and commit seeds directly using the existing extensionless naming convention, or wrap all calls in if __name__ == "__main__":.

Comment thread .gitignore
[Ll]ogs/

# Binary seed / corpus files
*.bin
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment 5 (Lines 43 through 45)

  • Category: Conventions
  • Severity: ⚠️ Required

*.bin is overly broad — it matches any .bin file anywhere in the repo. More importantly, it prevents the PR's own corpus seed files from being committed. The existing corpus uses extensionless files, so this rule is unnecessary if seeds follow the established convention.

Suggested Change: Remove the *.bin addition. Use extensionless corpus file names matching existing convention.

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.

feat(skills): expand fuzz_has_formatting_variation to cover all formatting properties

2 participants