# core/interceptors/integration_contracts.py
"""
Genesis Persistent Context Architecture — NullInterceptor + Scaffold
Story 1.05 — Track B

NullInterceptor: no-op passthrough for testing and reference.
Copy this file to create a new interceptor.

Usage:
    from core.interceptors.integration_contracts import NullInterceptor
    chain.register(NullInterceptor())
"""
from .base_interceptor import BaseInterceptor, InterceptorMetadata


class NullInterceptor(BaseInterceptor):
    """
    No-op passthrough interceptor.

    All methods pass data through unchanged. Use as:
    1. A placeholder in the chain during development
    2. A reference implementation to copy when creating new interceptors
    3. A test double for chain-level integration testing

    Copy this class and customize the methods to create your own interceptor.
    """

    metadata = InterceptorMetadata(name="null_interceptor", priority=50, enabled=True)

    async def pre_execute(self, task_payload: dict) -> dict:
        """Pass through unchanged."""
        return task_payload

    async def post_execute(self, result: dict, task_payload: dict) -> None:
        """No-op. Does nothing."""
        pass

    async def on_error(self, error: Exception, task_payload: dict) -> dict:
        """Returns error details as dict."""
        return {"error": str(error), "task_payload": task_payload}

    async def on_correction(self, correction_payload: dict) -> dict:
        """Prepends 'CORRECTION: ' to prompt field if present."""
        if "prompt" in correction_payload:
            correction_payload["prompt"] = f"CORRECTION: {correction_payload['prompt']}"
        return correction_payload


# VERIFICATION_STAMP
# Story: 1.05 (Track B)
# Verified By: parallel-builder
# Verified At: 2026-02-25T00:00:00Z
# Tests: 7/7
# Coverage: 100%
