Skip to content

test(guards): add comprehensive unit tests for contradiction guard#454

Open
borjamoskv wants to merge 1 commit into
mainfrom
fix/contradiction-guard-tests-4158951521777795611
Open

test(guards): add comprehensive unit tests for contradiction guard#454
borjamoskv wants to merge 1 commit into
mainfrom
fix/contradiction-guard-tests-4158951521777795611

Conversation

@borjamoskv

Copy link
Copy Markdown
Owner

I've added comprehensive unit tests for cortex/guards/contradiction_guard.py satisfying the 3 tests per public function rule and following the pytest setup with an aiosqlite in-memory database and FTS5 virtual table. I also corrected a structural error in contradiction_guard.py where the database context manager was inside the exception block and causing unhandled exceptions if the database was entirely unreadable.

Tests cover:

  • detect_contradictions: Happy path (clean), rejection (conflict), and boundary (noise / DB error).
  • scan_all_contradictions: Happy path (found pair), boundary (empty DB), and boundary (DB error).

PR created automatically by Jules for task 4158951521777795611 started by @borjamoskv

Added tests for happy path, warnings, boundaries, and db error handling for `detect_contradictions` and `scan_all_contradictions` according to C5-REAL standards. Also fixed a bug in db error handling in `contradiction_guard.py` where a connection error during DB setup was not caught gracefully.

Co-authored-by: borjamoskv <82632764+borjamoskv@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

Copy link
Copy Markdown
Contributor

∞ MÖBIUS — PR Analysis

Metric Value
Files changed 2
Total changes 238 (+/-)
Complexity high
Est. review time 30 min
Has tests?
Has Rust changes? No

Labels applied: security, tests


Generated by MÖBIUS (Clojure/Babashka) — where code IS data

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cortex/guards/contradiction_guard.py 0.00% 11 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant