Skip to content

feat: semantic scanner + benchmark harness + LangGraph adapter (54 tests) - #15

Open
Pranjal0410 wants to merge 1 commit into
c2siorg:mainfrom
Pranjal0410:feat/scanners-v2
Open

feat: semantic scanner + benchmark harness + LangGraph adapter (54 tests)#15
Pranjal0410 wants to merge 1 commit into
c2siorg:mainfrom
Pranjal0410:feat/scanners-v2

Conversation

@Pranjal0410

Copy link
Copy Markdown
Contributor

Rebased on the latest scaffolding pushed by @tharindupr. Supersedes #10 and #12 (which were against the old repo structure).

Semantic fallback scanner (sdk/python/acf/scanners/)

Embedding-based detection for the scan stage — the "semantic fallback" defined in the v0.2 architecture. Compares normalised inputs against a pre-computed library of 49 attack patterns across 6 categories (instruction override, data exfiltration, role hijack, context manipulation, tool abuse, encoding evasion). Pluggable backends: SentenceTransformerBackend for production (~2-4ms), TfidfBackend for CI (<1ms). Only fires after lexical PROCEED — respects the short-circuit model. Output produces risk_score + semantic_hits for the risk aggregator. 22 tests.

Adversarial benchmark harness (sdk/python/acf/benchmarks/)

Scanner-agnostic runner that measures detection quality. 50 curated payloads — 25 malicious across 7 categories + 25 benign including 10 hard negatives containing trigger-like phrases ("ignore previous commits", "system prompt debugging", "override a method in Python"). Reports precision, recall, F1, per-category detection rates, latency percentiles (p50/p95/p99). JSON export for CI. Quality gate exits non-zero if F1 drops. 18 tests.

LangGraph FirewallNode adapter (sdk/python/acf/adapters/langgraph.py)

Implements the empty adapter stub from the scaffolding. Wraps all four v1 hooks as LangGraph-compatible guard nodes:

  • prompt_guard — evaluates user messages via on_prompt
  • context_guard — filters RAG chunks via on_context, drops BLOCK, replaces SANITISE
  • tool_guard — evaluates tool calls via on_tool_call
  • memory_guard — evaluates memory writes via on_memory

BLOCK raises NodeInterrupt. SANITISE replaces content in state. ALLOW passes through. 14 tests (mocked, no langgraph dependency needed).

54 tests passing

…based on v0.2 scaffolding

- Semantic fallback scanner (embedding-based, pluggable backends) — 22 tests
- Adversarial benchmark harness (50 payloads, precision/recall/F1) — 18 tests
- LangGraph FirewallNode adapter (implements empty stub) — 14 tests
- All files under sdk/python/acf/ per v0.2 folder structure
- 54 tests passing
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.

1 participant