Repository navigation
fix: close audit gaps — MCP isError, ingestion events, pins wiring (#786, #774, #777) - #797
Conversation
, #774, #777) - #786: _safe_call now raises PolylogueError on failure so FastMCP sets isError=True with proper integer JSON-RPC error codes. - #774: Emit ingestion_batch daemon events after each batch completes in process_ingest_batch, with throughput and record count metadata. - #777: Thread pins parameter through the full annotation call chain (schema_builder -> support -> semantic_relations -> select_best_roles). Load pins.json for each provider during schema generation. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis pull request makes three independent changes: refactoring error handling in MCP safe-call wrappers to raise exceptions instead of returning JSON payloads, adding pin-based constraint support to the schema generation pipeline, and emitting daemon events for batch ingestion metrics. ChangesMCP Error Handling Refactor
Schema Generation Pin Support
Batch Ingestion Daemon Events
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Pull request overview
Closes audit gaps across MCP error signaling, ingest telemetry, and schema pin propagation to ensure safer MCP responses, better daemon observability, and consistent schema annotation behavior.
Changes:
- MCP
_safe_call/_async_safe_callnow raisePolylogueErrorso FastMCP can mark responses withisError=True. - Ingest pipeline emits
ingestion_batchdaemon events with batch summary metrics. - Schema generation threads pin data into semantic-role selection (via
pinspassed through generation/annotation layers).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/security/test_mcp_security.py | Updates MCP safety tests to expect raised PolylogueError instead of JSON error strings. |
| tests/unit/mcp/test_mcp_edge_cases.py | Updates MCP edge-case tests to expect raised PolylogueError and checks for no traceback in surfaced error text. |
| polylogue/mcp/server_support.py | Changes _safe_call / _async_safe_call to raise PolylogueError on unexpected exceptions. |
| polylogue/pipeline/services/ingest_batch/_core.py | Emits ingestion_batch daemon events after processing batches. |
| polylogue/schemas/generation/schema_builder.py | Loads pins and passes them into semantic-role annotation during schema generation. |
| polylogue/schemas/generation/support.py | Extends annotation support wrapper to accept and forward pins. |
| polylogue/schemas/generation/semantic_relations.py | Extends semantic+relational annotation to accept pins and pass them to role selection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| except Exception: | ||
| pass |
| def _load_pins_safe(provider: str) -> dict[str, set[str]]: | ||
| try: | ||
| pins = load_pins(provider) | ||
| rejected: dict[str, set[str]] = {} | ||
| for pin in pins.pins: | ||
| if pin.action == "reject": | ||
| rejected.setdefault(pin.path, set()).add(pin.role) |
| except Exception as exc: | ||
| logger.exception("MCP tool %s failed", fn_name) | ||
| return _json_payload(_exception_error_payload(fn_name, exc), exclude_none=True) | ||
| raise PolylogueError(f"{fn_name}: {type(exc).__name__}: {exc}") from exc |
|
|
||
| with pytest.raises(PolylogueError) as exc: | ||
| _safe_call("test_tool", failing) | ||
| assert "Traceback" not in str(exc.value) |
| try: | ||
| from polylogue.daemon.events import emit_daemon_event | ||
|
|
||
| emit_daemon_event( | ||
| "ingestion_batch", | ||
| payload={ | ||
| "elapsed_s": round(batch_summary.elapsed_s, 2), | ||
| "records": batch_summary.raw_record_count, | ||
| "blob_mb": round(batch_summary.total_blob_mb, 1), | ||
| "conversations": batch_summary.total_convos, | ||
| "messages": batch_summary.total_msgs, | ||
| "changed_conversations": len(batch_summary.changed_conversation_ids), | ||
| "workers": batch_summary.worker_count, | ||
| }, | ||
| ) |
| rejected: dict[str, set[str]] = {} | ||
| for pin in pins.pins: | ||
| if pin.action == "reject": | ||
| rejected.setdefault(pin.path, set()).add(pin.role) | ||
| return rejected |
| try: | ||
| pins = load_pins(provider) | ||
| rejected: dict[str, set[str]] = {} | ||
| for pin in pins.pins: | ||
| if pin.action == "reject": | ||
| rejected.setdefault(pin.path, set()).add(pin.role) | ||
| return rejected | ||
| except Exception: | ||
| return {} |
, #774, #777) (#797) Fix 3 gaps found by adversarial audit: MCP _safe_call now raises PolylogueError so FastMCP sets isError=True; emit ingestion_batch events from ingest pipeline; thread pins through annotation call chain. Co-authored-by: Claude Opus 4.7 <[email protected]>
Fix 3 gaps found by adversarial audit: MCP _safe_call now raises PolylogueError so FastMCP sets isError=True; emit ingestion_batch events from ingest pipeline; thread pins through annotation call chain.
Summary by CodeRabbit
New Features
Bug Fixes
Tests