Skip to content

refactor(core): remove dead PolicyPatternExtractor code#9

Merged
kschlt merged 2 commits intomainfrom
chore/remove-pattern-extraction
Mar 22, 2026
Merged

refactor(core): remove dead PolicyPatternExtractor code#9
kschlt merged 2 commits intomainfrom
chore/remove-pattern-extraction

Conversation

@kschlt
Copy link
Copy Markdown
Owner

@kschlt kschlt commented Mar 22, 2026

Why

Pattern extraction via regex was dead code — the two-step creation flow (quality gate + policy guidance promptlet) ensures policies are always explicitly constructed in ADR front-matter by the agent. The extract_policy() merge logic that combined natural-language pattern matches with structured front-matter was never exercised in practice, making it maintenance burden with no runtime value.

Approach

Removed PolicyPatternExtractor and all associated regex patterns (~145 lines). Simplified PolicyExtractor.extract_policy() to a direct front-matter read — no merging, no regex scanning. Updated tests to reflect the corrected behavior: natural-language patterns in ADR bodies no longer suppress the structured-policy warning (they were never supposed to). Deleted the fixture that existed solely to exercise the removed extraction path.

No public API surface changed; this is internal to the validation pipeline.

What Was Tested

  • Updated unit tests confirm that ADRs with natural-language policy patterns (but no front-matter policies) correctly emit the structured-policy warning, which was the wrong suppressed before
  • Existing passing tests verified that structured front-matter policies continue to suppress the warning as expected
  • Full quality suite (format + lint + mypy + 186 unit/integration tests) passes clean

Risks

Additive removal only. The deleted code path was verified to be unreachable in normal operation — if any edge case did rely on regex extraction it would have been caught by tests. Low risk.

kschlt and others added 2 commits March 22, 2026 23:16
These files were committed before .agent/ was added to .gitignore.
They are local session state and should never have been tracked.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…extraction

Pattern extraction was dead code: the two-step creation flow (quality gate +
policy guidance promptlet) ensures all policies are explicitly constructed in
front-matter by the agent, never extracted from natural language. The merge
logic in extract_policy() was never exercised in practice.

Removes ~145 lines of regex patterns and extraction methods, simplifying
PolicyExtractor.extract_policy() to a direct front-matter read. Updated tests
to reflect the new correct behavior — natural language patterns no longer
suppress the structured-policy warning. Deleted the fixture that existed solely
to exercise the removed extraction path.
@kschlt kschlt merged commit 21cc4d6 into main Mar 22, 2026
8 checks passed
@kschlt kschlt deleted the chore/remove-pattern-extraction branch March 22, 2026 22:24
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