Implement spec-v2: Exception context, benchmarks, guard bypass tests, mypy fix - #1
Merged
Conversation
Step 1: Update __version__ in proxilion/__init__.py from 0.0.5 to 0.0.6 to match pyproject.toml. Step 2: Ruff lint and format already passing (0 violations). Step 3: Remove 13 stale `# type: ignore[import-not-found]` comments across 9 files. These were leftover from previous refactors where --ignore-missing-imports already suppresses the underlying import errors, making the comments unused. Also fix no-any-return error in pydantic_schema.py line 286. All 89 source files now pass `mypy proxilion/ --ignore-missing-imports`. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Step 4 - CI Pipeline Hardening: - Add Python 3.13 to test matrix - Add --cov-fail-under=85 to pytest command - Expand ruff lint scope to include tests/ directory - Add pip-audit security scanning step to lint job - Install all optional deps in typecheck job ([dev,all]) Step 5 - Secret Key Validation: - Add _validate_secret_key() to intent_capsule.py, memory_integrity.py, and agent_trust.py that raises ConfigurationError if key < 16 chars and logs a warning for common placeholder patterns - Also validate key in IntentGuard.__init__() when secret_key is provided - Update test fixtures to use keys of >= 16 characters - Update README examples to use realistic key "prx_sk_a1b2c3d4e5f6g7h8" with a comment noting production use requires a real key Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…-v2 step 2) Added documenting comments to all catch-all except Exception blocks in the five security modules to make intent auditable: - idor_protection.py: Document that scope loader and extractor catches are intentional catch-alls for user-provided callbacks; add WARNING-level logging to the previously silent extractor exception swallow - cascade_protection.py: Document state listener catch-all as user-provided callback; downgrade log level from error to warning per intent - behavioral_drift.py: Document drift/halt/reset callback catch-alls as user-provided callbacks; downgrade log levels from error to warning - circuit_breaker.py: Document that catch-all is intentional (any exception from protected function counts as circuit failure) - intent_validator.py: Document custom validator catch-all as user-provided callback; downgrade log level from error to warning per intent Zero new ruff violations. Zero mypy errors. All 2354 sync tests pass. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ep 3) The features README referenced MemoryIntegrityChecker which does not exist. The actual class exported by proxilion.security is MemoryIntegrityGuard. Any developer copying the example code would get an ImportError. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The CI pipeline already tests Python 3.13 (added in spec-v1 step 4), but pyproject.toml classifiers only listed 3.10, 3.11, and 3.12. Added "Programming Language :: Python :: 3.13" classifier so PyPI metadata matches the tested and supported Python versions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add optional keyword-only structured context fields to 7 security exception classes so operators can access machine-readable metadata without parsing string messages: - RateLimitExceeded: user_id, limit, current_count, window_seconds, reset_at - CircuitOpenError: already had circuit_name, failure_count, reset_timeout - IDORViolationError: resource_id alias for object_id - GuardViolation/InputGuardViolation/OutputGuardViolation: input_preview - SequenceViolationError: user_id - BudgetExceededError: budget_limit alias for limit - IntentHijackError: tool_name, allowed_tools, user_id All new fields are optional keyword-only arguments defaulting to None, preserving full backward compatibility with existing raise sites. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Create tests/test_exceptions.py with 47 tests covering all 7 enhanced exception classes: RateLimitExceeded, CircuitOpenError, IDORViolationError, GuardViolation (+ InputGuardViolation, OutputGuardViolation), SequenceViolationError, BudgetExceededError, IntentHijackError. Each class gets tests for: default construction, structured field access, ProxilionError inheritance, str() representation, and top-level importability from the proxilion package. Also verifies backward-compatible aliases (resource_id, budget_limit) and cross-cutting properties. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add structured context fields to all exception raise sites: - rate_limiter.py: Add user_id, limit, current_count to RateLimitExceeded raises at global, user, and tool-specific limit checks - decorators.py: Add user_id to RateLimitExceeded and SequenceViolationError; Add current_spend and budget_limit to BudgetExceededError - core.py: Add input_preview to InputGuardViolation and OutputGuardViolation - intent_capsule.py: Add tool_name, allowed_tools, user_id to IntentHijackError; Modify _handle_violation() to accept tool_name parameter These fields enable programmatic alerting and dashboards to access semantic information about violations without parsing exception messages. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit adds comprehensive end-to-end integration tests for the Proxilion authorization pipeline in tests/test_pipeline_integration.py. The tests cover: - Happy path authorization flows (can/check methods) - Input guard rejection via guard_input() method - Rate limit enforcement and capacity exhaustion - Policy denial for unauthorized users - Sequence validation (REQUIRE_BEFORE and FORBID_AFTER rules) - Audit event logging and hash chain integrity verification - Edge cases (missing user context, default deny, sync/async) - Multi-guard coordination patterns Key test classes: - TestFullPipelineHappyPath: 6 tests for successful authorization - TestPipelineInputGuardRejection: 3 tests for input guard - TestPipelineRateLimitRejection: 1 test for rate limiting - TestPipelinePolicyDenial: 2 tests for policy enforcement - TestPipelineSequenceViolation: 3 tests for sequence rules - TestPipelineAuditIntegrity: 4 tests for audit logging - TestPipelineEdgeCases: 4 tests for edge cases - TestPipelineMultipleGuards: 3 tests for multi-guard patterns Total: 26 new integration tests, all passing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix AuditEventData constructor parameters to match actual API - Fix IDORProtector.validate_access parameter name (object_id not resource_id) - Remove unused datetime imports - All 14 benchmark tests now pass Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive test suite for input guard bypass attempts including: - Unicode homoglyph substitution (Cyrillic, Greek, full-width, math symbols) - Whitespace injection (zero-width spaces, ZWNJ, tabs, newlines, BOM) - Case mixing (alternating, all caps, random case) - Delimiter bypass (pipes, dots, underscores, hyphens, slashes) - Encoding bypass (base64, URL encoding, hex) - Comment injection (SQL, HTML, C-style, hash) - Character repetition and stuttering - Leetspeak character substitution - Word boundary evasion - Bidirectional text overrides - Prompt structure evasion (quotes, code blocks, JSON, XML) - Semantic evasion (paraphrasing, synonyms, implicit override) - Multi-language injection (Spanish, French, German) Tests document known limitations using @pytest.mark.xfail markers. Total: 52 tests (23 pass, 29 xfail documenting regex limitations) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Step 11 verification confirms the input guard already has proper case-insensitive matching: - InjectionPattern compiles all regexes with re.IGNORECASE | re.MULTILINE - Most patterns also have inline (?i) flag (redundant but harmless) - All TestCaseMixingBypass tests pass without xfail markers - Alternating case, all caps, and random case patterns are detected No code changes required - the implementation was already correct. Only STATE.md updated to mark step 11 complete. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add type: ignore comments for optional pydantic import fallback assignments and remove unused type: ignore on model_json_schema call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
clay-good
marked this pull request as ready for review
March 18, 2026 21:44
clay-good
added a commit
that referenced
this pull request
Mar 25, 2026
Resolved 11 file conflicts from PR #1's squash-merge of spec-v2. Kept PR #4 branch content (spec-v2 steps 12-18 + spec-v3 steps 1-4) on top of main's state. Fixed formatting in contrib/google.py. All CI checks pass: 0 ruff violations, 158 files formatted, 0 mypy errors, 2633 tests passed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Implements spec-v2 steps 2-11 for the Proxilion SDK:
CI Status
Test plan
🤖 Generated with Claude Code