fix: false positives in prompt extraction + stream model matching#78
Open
techotaku39 wants to merge 3 commits into
Open
fix: false positives in prompt extraction + stream model matching#78techotaku39 wants to merge 3 commits into
techotaku39 wants to merge 3 commits into
Conversation
added 2 commits
June 24, 2026 11:08
…ted model in stream integrity 1. Normalize Unicode apostrophes (U+2018, U+2019, U+02BC) to ASCII before checking refusal markers. Models often return curly quotes which break 'can\'t provide' style refusal detection. 2. Check refusal markers before flagging strong/weak prompt extraction hits. A response like 'I can\'t provide my system prompt' is a refusal, not a leak. 3. Add expected_model parameter to _check_stream_model/analyze_stream so stream integrity checks compare against the requested model instead of hardcoding 'claude'. Fixes false positives when auditing OpenAI-format relays with --model gpt-5.5.
… extraction - Sync stream_integrity.py: add expected_model parameter - Sync scripts/audit.py: Unicode normalization + refusal-aware extraction - Strong markers (structural + keyword) always flag, even with refusal - Weak markers skip when refusal language is present - Update REPRO_2 test: refusal + weak hits = clean (not contradictory) - All 778 tests pass
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.
Fixes #79
Changes
1. Unicode apostrophe normalization (Step 4 & Step 6)
Models return curly quotes (U+2019
') instead of ASCII apostrophes (U+0027'). Refusal markers likecan't providenever match the curly-quote version, causing false-positive leak detections.Fix: Normalize U+2018/U+2019/U+02BC to ASCII
'before checking markers.2. Refusal-aware prompt extraction (Step 4)
When a model refuses with keywords like
system promptorassistant, old code flagged it as a leak.Fix:
kiro,hidden_prompt): always flag, even with refusal language. Structural patterns like"system prompt is: ..."are real leaks.system prompt,assistant,coding,developer): skip when refusal language is present.3. Stream model matching with expected model (Step 10)
_check_stream_model()hardcodedclaude. Auditing OpenAI relays with--model gpt-5.5always failed because the stream returnedgpt-5.5, notclaude.Fix: Add
expected_modelparam to_check_stream_model/analyze_stream, passclient.model. Falls back toclaudefor backward compat.4. Dual distribution sync
All changes synced across:
audit.py(standalone)scripts/audit.py(modular)api_relay_audit/stream_integrity.py(module)Testing
test_standalone_artifact_generated_from_sourcespasses (standalone rebuilt)leaked: yes->leaked: no(false positive fixed)