Skip to content

MAINT: Migrate SeedOrigin to StrEnum (P311-17) - #4126

Merged
Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
GouthamMahesh:maint/p311-17-seed-origin-strenum
Nov 10, 2026
Merged

Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
GouthamMahesh:maint/p311-17-seed-origin-strenum

Conversation

@GouthamMahesh

Copy link
Copy Markdown
Contributor

Description

Part of #3166 (P311-17), following #3850. Reservation.

Use Python 3.11's StrEnum for SeedOrigin so str(SeedOrigin.LOCAL) and formatting return local instead of SeedOrigin.LOCAL, matching the values already used in storage and JSON. No repository consumer was found relying on the qualified form.

  • Preserve all five values, equality, hashing, repr, value lookup, JSON, schema behavior, and existing stored seeds. Storage already writes .value and reads with SeedOrigin(raw_value), so no database migration is needed.
  • Add focused tests for string behavior, serialization, and schemas. Also verify raw stored origins and SeedRecord reconstruction in the existing SQLite round-trip tests.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 03:24

Copilot AI left a comment

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.

🟢 Approval recommended

No active review issues were identified for the SeedOrigin migration to StrEnum.

No open issues 🎉

What changed in this PR

Migrates SeedOrigin to Python 3.11’s StrEnum as part of #3166, following #3850. String conversion now returns values such as local, while preserving existing serialization and storage contracts without a database migration.

Changes:

  • Replace (str, Enum) with StrEnum, retaining all five origin values.
  • Add coverage for string behavior, equality, hashing, JSON serialization, and schemas.
  • Extend SQLite round-trip tests to verify stored values and SeedRecord reconstruction.
File Description
tests/​unit/​models/​test_seed_origin.py Adds string, serialization, and schema compatibility tests.
tests/​unit/​memory/​test_seed_origin.py Checks raw stored origins and reconstructed records.
pyrit/​models/​seeds/​seed_origin.py Changes SeedOrigin to inherit from StrEnum.

Review effort: Balanced

@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 10, 2026
Merged via the queue into microsoft:main with commit 9cbec1d Nov 10, 2026
87 of 88 checks passed
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.

3 participants