refactor(core): remove dead PolicyPatternExtractor code#9
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
PolicyPatternExtractorand all associated regex patterns (~145 lines). SimplifiedPolicyExtractor.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
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.