Skip to content

feat: replace MeaningUnitAspect enum with open-ended str#206

Open
asteier2026 wants to merge 2 commits into
mainfrom
asteier2026/feature/meaning-unit-aspect-str
Open

feat: replace MeaningUnitAspect enum with open-ended str#206
asteier2026 wants to merge 2 commits into
mainfrom
asteier2026/feature/meaning-unit-aspect-str

Conversation

@asteier2026

@asteier2026 asteier2026 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Drops the MeaningUnitAspect enum from EntityDispositionSchema and schemas/__init__.py
  • Changes MeaningUnitSchema.aspect from MeaningUnitAspect to str
  • Updates tests to use string literals instead of enum values

Motivation

The enum was causing record loss: the model returns open-ended aspect values like "goal", "symptom", "diagnosis" that can't be exhaustively enumerated. Validation errors were silently dropping records.

@asteier2026
asteier2026 requested a review from a team as a code owner July 2, 2026 15:51
@greptile-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes the MeaningUnitAspect enum and replaces MeaningUnitSchema.aspect with an open-ended str field, fixing silent record loss caused by validation rejecting LLM-returned values like "goal", "symptom", and "diagnosis" that the enum couldn't represent.

  • rewrite.py: Deletes the 16-value MeaningUnitAspect enum; MeaningUnitSchema.aspect becomes str = Field(min_length=1), and the same min_length guard is added to QualityQAItemSchema.aspect (which previously had none).
  • schemas/__init__.py: Removes MeaningUnitAspect from the re-export list, keeping the public API consistent.
  • test_qa_generation.py: Swaps enum references for equivalent plain string literals; no logic changes.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped, removes a closed enum that was causing record loss, and replaces it with a validated open-ended string.

All three changed files are consistent: the enum is fully deleted, the public re-export list is updated, tests use plain string equivalents, and both aspect fields now carry a min_length=1 guard. No remaining references to MeaningUnitAspect exist anywhere in the repo.

No files require special attention.

Important Files Changed

Filename Overview
src/anonymizer/engine/schemas/rewrite.py Removes MeaningUnitAspect enum; changes MeaningUnitSchema.aspect to str = Field(min_length=1) and adds the same guard to QualityQAItemSchema.aspect. Clean and correct.
src/anonymizer/engine/schemas/init.py Removes MeaningUnitAspect from the import list and __all__, consistent with its deletion from rewrite.py.
tests/engine/test_qa_generation.py Replaces MeaningUnitAspect.ROLE / MeaningUnitAspect.ENVIRONMENT with plain string literals, keeping tests aligned with the new schema.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[LLM returns meaning unit\ne.g. aspect = 'goal'] --> B{Validate aspect}
    
    subgraph Before
        B1["MeaningUnitAspect enum\n(16 fixed values)"] --> C1{aspect in enum?}
        C1 -- No --> D1["ValidationError\n→ record silently dropped"]
        C1 -- Yes --> E1[Record accepted]
    end

    subgraph After
        B2["str = Field(min_length=1)"] --> C2{aspect non-empty?}
        C2 -- No --> D2["ValidationError\n(empty string rejected)"]
        C2 -- Yes --> E2[Record accepted]
    end

    B --> B1
    B --> B2
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[LLM returns meaning unit\ne.g. aspect = 'goal'] --> B{Validate aspect}
    
    subgraph Before
        B1["MeaningUnitAspect enum\n(16 fixed values)"] --> C1{aspect in enum?}
        C1 -- No --> D1["ValidationError\n→ record silently dropped"]
        C1 -- Yes --> E1[Record accepted]
    end

    subgraph After
        B2["str = Field(min_length=1)"] --> C2{aspect non-empty?}
        C2 -- No --> D2["ValidationError\n(empty string rejected)"]
        C2 -- Yes --> E2[Record accepted]
    end

    B --> B1
    B --> B2
Loading

Reviews (3): Last reviewed commit: "fix: add min_length=1 to MeaningUnitSche..." | Re-trigger Greptile

Comment thread src/anonymizer/engine/schemas/rewrite.py Outdated
asteier2026 and others added 2 commits July 10, 2026 14:42
The enum was causing record loss when the model returned values like
"goal" or "symptom" that weren't enumerated. Aspect is now an
unvalidated str to accommodate open-ended LLM output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: asteier2026 <asteier@nvidia.com>
…hema.aspect

Empty strings are structurally valid but semantically meaningless; guard
against them consistently with the other non-id string fields in these schemas.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: asteier2026 <asteier@nvidia.com>
@asteier2026
asteier2026 force-pushed the asteier2026/feature/meaning-unit-aspect-str branch from 1856714 to 212a478 Compare July 10, 2026 21:42
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.

1 participant