plan_builder
plan_builder
¶
Build PII replacement plans from semantic column classifications.
Classes:
| Name | Description |
|---|---|
ColumnClassification |
Semantic classification produced by a heuristic or LLM planner. |
DependencyCandidate |
One proposed dependency edge identified only by dataframe columns. |
Functions:
| Name | Description |
|---|---|
plan_from_classifications |
Build replacement membership from one classification per expected column. |
derive_dependency_candidates |
Return the individually permitted edges for a later selection pass. |
apply_dependencies |
Validate and apply selected dependency edges using classified entity types. |
ColumnClassification
pydantic-model
¶
Bases: BaseModel
Semantic classification produced by a heuristic or LLM planner.
Config:
extra:forbidfrozen:True
Fields:
-
column_name(str) -
entity_type(EntityType | None) -
pattern(str | None)
Validators:
-
_validate_pattern_eligibility
DependencyCandidate(target_column, source_column)
dataclass
¶
One proposed dependency edge identified only by dataframe columns.
Entity types deliberately remain in ColumnClassification as the single
source of truth. apply_dependencies validates this edge against those
classifications and the target plan before constructing the final plan.
plan_from_classifications(classifications, *, expected_columns, protected_columns=frozenset())
¶
Build replacement membership from one classification per expected column.
A classification with entity_type=None records that the column was
examined but does not contain a supported entity. Protected columns must
still be classified, but are omitted from the replacement plan.
Source code in src/nemo_safe_synthesizer/pii_replacer/planning/plan_builder.py
derive_dependency_candidates(classifications, *, expected_columns, protected_columns=frozenset())
¶
Return the individually permitted edges for a later selection pass.
The classifications determine the replacement nodes, including protected column exclusion. This function constructs that node-only plan internally so callers cannot supply a plan that disagrees with the classifications. It intentionally does not filter mutually exclusive candidate groups; exclusivity applies to the set selected in the later dependency pass.
Source code in src/nemo_safe_synthesizer/pii_replacer/planning/plan_builder.py
apply_dependencies(plan, dependencies, *, classifications)
¶
Validate and apply selected dependency edges using classified entity types.