Skip to content

feat: move data normalization from Python consumers to Rust extractor (#290)#294

Merged
SimplicityGuy merged 13 commits intomainfrom
worktree-290-normalizer
Apr 12, 2026
Merged

feat: move data normalization from Python consumers to Rust extractor (#290)#294
SimplicityGuy merged 13 commits intomainfrom
worktree-290-normalizer

Conversation

@SimplicityGuy
Copy link
Copy Markdown
Owner

Summary

  • Add normalize.rs module to the Rust extractor that transforms XML-shaped JSON (@id, #text, nested containers) into flat, consumer-ready JSON — normalization now runs once at extraction time instead of redundantly in every consumer
  • Simplify common/data_normalizer.py from ~475 lines to ~65 lines — only _parse_year_int() and a thin normalize_record() wrapper remain
  • Remove extract_format_names() from graphinator, replaced with inline list comprehension on the already-flat formats array
  • Pipeline ordering: parse → filters → rules → normalize → hash → publish — rules still operate on XML-shaped data, hash reflects normalized output

Test plan

  • 45 new Rust tests in normalize_tests.rs covering all entity types and edge cases
  • 3,007 Python tests pass (including rewritten normalizer tests and updated consumer fixtures)
  • 1,122 Rust tests pass
  • Ruff + mypy clean
  • Verify next extraction re-processes all records (expected: sha256 changes due to new JSON shape)

Closes #290

🤖 Generated with Claude Code

SimplicityGuy and others added 11 commits April 11, 2026 16:11
…290)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…290)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add strip_at_prefixes, unwrap_container, and ensure_list functions
for transforming XML-style JSON conventions into flat format.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add normalize_item_list helper and normalize_artist function to flatten
members, groups, and aliases from XML container format to flat arrays.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add normalize_label function to handle parentLabel strip_at_prefixes
and sublabels container flattening.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add normalize_string_list helper and normalize_master function to handle
@id stripping, artists container, genres, and styles flattening.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add normalize_release function handling artists, labels, master_id
extraction, genres, styles, extraartists, and formats with @-prefix
stripping. Includes full pipeline integration test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… to Rust extractor

- Gut data_normalizer.py to only retain year parsing and normalize_record()
- Replace extract_format_names with inline list comprehension in graphinator
- Rewrite normalizer tests for simplified module
- Update all test fixtures to flat extractor output format

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…le path resolution

Rules use dot-notation paths like "genres.genre" that match the XML
structure. Moving normalize_record after evaluate_rules ensures rules
operate on the pre-normalized shape while the content hash still
reflects the normalized output consumers see.

Also updates stale comment in tableinator.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 12, 2026

Codecov Report

❌ Patch coverage is 98.74214% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
extractor/src/normalize.rs 98.67% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

SimplicityGuy and others added 2 commits April 11, 2026 17:28
…ze.rs

Covers: non-object inputs to normalizers, string/number items in
normalize_item_list, bare string in unwrap_container, non-object
format items. Raises line coverage from 93.4% to 97.7%.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (chromium)

Totals Coverage
Statements: 47.64% ( 1241 / 2605 )
Lines: 47.64% ( 1241 / 2605 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (webkit)

Totals Coverage
Statements: 47.64% ( 1241 / 2605 )
Lines: 47.64% ( 1241 / 2605 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (firefox)

Totals Coverage
Statements: 47.64% ( 1241 / 2605 )
Lines: 47.64% ( 1241 / 2605 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (webkit - iPhone 15)

Totals Coverage
Statements: 47.64% ( 1241 / 2605 )
Lines: 47.64% ( 1241 / 2605 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (webkit - iPad Pro 11)

Totals Coverage
Statements: 47.64% ( 1241 / 2605 )
Lines: 47.64% ( 1241 / 2605 )

StandWithUkraine

@SimplicityGuy SimplicityGuy merged commit accb054 into main Apr 12, 2026
57 checks passed
@SimplicityGuy SimplicityGuy deleted the worktree-290-normalizer branch April 12, 2026 01:55
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.

Evaluate moving data_normalizer.py logic to extraction rules

1 participant