fix: resolve 13 pre-existing pytest failures - #15
Merged
Conversation
Root causes and fixes: - PolicyRule.matches() ANDed the flattened `conditions` list on top of `condition_expr`, breaking any rule using OR/NOT (trace boolean conditions, console/legacy DSL rules with OR). `condition_expr` is now the sole source of truth when set; `conditions` remains for introspection only. - Added `extract_condition_atoms()` to flatten AND/OR/NOT expressions into their referenced field atoms, used by the console DSL parser and the legacy `.rules` compat parser to populate `PolicyRule.conditions` for introspection (previously only naive top-level AND-split atoms were captured). - `dsl_compat.parse_legacy_rules` treated "unsupported DSL feature" blocks (history_arg, exists_path, allowlist.*, etc.) as hard errors, failing the whole file even when most rules were valid. Downgraded to warnings so tutorial/example `.rules` files load their supported subset. - `shared.rules.loader.load_rules_file` (and the client-side mirror) assumed `.rules`-suffixed files are always legacy DSL text; now sniffs for JSON content first so JSON rule lists written to a `.rules` path still load. - RuntimeManager could downgrade an already-won `deny` decision back to `human_check` when enqueuing review tickets for non-winning plugin outcomes. Escalation now only happens when the current decision is actually weaker than the ticket being escalated (rank-based comparison). - Ported the shared v3 PolicyRule schema (agent_id, condition_expr, trace_clause, principal/tool/target views) into the client-side agentguard.schemas.policy so client-only rule loading (Guard(policy=...)) supports TRACE clauses, matching the server-side engine. - Removed a stray/misplaced assertion in the llamaindex streaming adapter test that asserted a tool_invoke event which the test explicitly says should never happen (wrap_tools=False), which crashed with "coroutine raised StopIteration" via bare next(). - Updated two llm_dsl_generator tests whose Chinese prompt-section assertions were stale after the prompt templates were translated to English in a prior commit. - Fixed a Windows-only path-separator artifact in `agentguard check` output (Path str uses backslashes on Windows) by printing as_posix(). All 290 tests pass (was 277 passed / 13 failed). No new lint issues in changed files (ruff clean); node --test unaffected (175 passed). Co-authored-by: Cursor <cursoragent@cursor.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.
Background
mainhad 13 pre-existing pytest failures unrelated to the earlier CI or documentation changes. This PR fixes all 13.Changes
PolicyRule.matches()socondition_expris the source of truth when present. This restores correct matching for rules usingORandNOT.extract_condition_atoms()to extract condition fields from nestedAND/OR/NOTexpressions..rulesfiles.RuntimeManagerso weaker review outcomes cannot override stronger decisions such asdeny.PolicyRuleschema with the server v3 implementation, preserving TRACE rule fields.as_posix()for Windows compatibility.Validation
pytest: 290 passed, up from 277 passed / 13 failedruff check: passed for all changed filesnode --test: 175 passed