Skip to content

Use Little Canary SecurityPipeline in injection adapter - #1

Merged
samvitgersappa merged 3 commits into
samvitgersappa:mainfrom
roli-lpci:fix/little-canary-pipeline
Sep 11, 2026
Merged

samvitgersappa merged 3 commits into
samvitgersappa:mainfrom
roli-lpci:fix/little-canary-pipeline

Conversation

@roli-lpci

@roli-lpci roli-lpci commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Use Little Canary's SecurityPipeline in the existing injection adapter. With the original code and installed little-canary 0.3.0 or 0.3.5, importing CanaryDetector raises ImportError; the adapter disables itself and returns (False, None) without screening.

The adapter now runs the synchronous pipeline through asyncio.to_thread in advisory mode. It preserves the existing scan() tuple interface and adds scan_detailed() so callers can distinguish completed, degraded, unavailable, and failed screening. SecurityGuard records degraded, unavailable, or failed screening separately, including when a structural detection also occurs.

Related issue (if any)

Reproduced against the existing adapter; no separate issue.

Changes

  • Require little-canary >=0.3.3 for its explicit degraded verdict; lock 0.3.5.
  • Install the optional security dependency in CI so the adapter regression tests execute.
  • Test the real installed pipeline with deterministic probe results, including failed probes and missing dependencies. No live Ollama/model calls or detection-efficacy evaluation.
  • Remove one unused import and trailing whitespace that prevented the existing Ruff checks from passing.

Checklist

  • uv run pytest: 38 passed with little-canary 0.3.5
  • Declared-minimum check: 14 adapter tests passed with little-canary 0.3.3
  • uv run ruff check src/ and uv run ruff format --check src/ pass
  • uv run mypy src/ passes
  • Architecture documentation updated

Rolando Bosch is the responsible human contributor and provided active oversight and steering. This contribution was selected through Hermes Labs’ autonomous triage and executed through its engineering infrastructure.

Disclosure: Rolando Bosch maintains Little Canary.

@roli-lpci

Copy link
Copy Markdown
Contributor Author

Hi @samvitgersappa — this PR updates the CI security extra now that little-canary 0.3.5 provides a universal wheel, and adds adapter regression coverage. GitHub shows the PR workflow as action_required, so it has not run its checks. If approval is needed to run it, could you approve it when convenient?

@samvitgersappa

Copy link
Copy Markdown
Owner

Approved.

The fix is correct and I verified it end-to-end rather than relying on the description:

  • The core claim checks out against the little-canary source: SecurityPipeline is the real export (CanaryDetector has never existed), PipelineVerdict.degraded exists in >=0.3.3, and the advisory fields/severity values the adapter consumes match the library exactly. SecurityPipeline() construction does no I/O and check() is blocking + stateless, so asyncio.to_thread is the right call and is safe under concurrency.
  • Ran the suite locally: 38 passed (including the 14 new adapter regression tests) on the locked 0.3.5/current 0.3.6, and 14/14 adapter tests on the declared minimum 0.3.3. ruff check, ruff format --check, and mypy are all clean.
  • CI change is sound — little-canary ships a universal py3-none-any wheel, so the old "no Linux wheel" comment was simply wrong, and the adapter tests will now actually run in CI.

Two tradeoffs I'm consciously accepting (flagging for the record, not blocking):

  1. When the optional security extra isn't installed, every input now records a severity-3 screening_degraded event. This shifts the meaning of total_security_events/the security dashboards from "findings" to "screening status" — which is the point, but worth documenting so it doesn't read as a security alert.
  2. prompt_injection severity is now 9/6/3 (high/medium/low) instead of a fixed 9.

Thanks for the thorough regression coverage and the docs update. This fixes a real silent no-op bug.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants