fix(ctf): match vendor indicators as whole words - #551
Open
DevaanshPathak wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the CTF vendor status-flip detection logic to avoid false positives caused by prohibited indicator substring matches in vendor agent_notes, and adds regression tests to validate the corrected matching behavior.
Changes:
- Update
VendorStatusFlipDetectorto match prohibited indicators as whole words using regex word boundaries. - Add unit tests covering both the substring false-positive case and a valid whole-word match case.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| finbot/ctf/detectors/implementations/vendor_status_flip.py | Adds word-boundary matching for prohibited indicators in vendor agent notes to prevent substring false positives. |
| tests/unit/ctf/test_vendor_status_flip_detector.py | Adds regression tests for substring false positives and correct whole-word matches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Root cause
Both status-flip detectors escaped indicator text before searching, but the matching logic was duplicated and did not consistently enforce word boundaries. As a result, an indicator such as
deniedcould also match inside a larger word such asundenied.Impact
This prevents false-positive vendor re-activation detections for both direct and indirect status transitions while preserving matches for genuine prohibited indicators.
Testing
uv run pytest tests/unit/ctf/test_vendor_status_flip_detector.py(4 passed)uv run pytest tests/unit/ctf(31 passed, 1 skipped)Fixes #124