"""
Genesis Persistent Context Architecture — BaseInterceptor
Story 1.01 — Track B

Abstract base class defining the 4 integration contracts:
1. pre_execute  — Enrich input with context before dispatch
2. post_execute — Capture state delta from output (side-effects only)
3. on_error     — Classify failure, return correction payload
4. on_correction— Re-inject with CORRECTION: prefix
"""
from abc import ABC, abstractmethod
from dataclasses import dataclass


@dataclass
class InterceptorMetadata:
    """Metadata for an interceptor in the chain."""
    name: str
    priority: int  # 0 = first, 100 = last
    enabled: bool = True


class BaseInterceptor(ABC):
    """Abstract base for all Genesis interceptors."""

    metadata: InterceptorMetadata

    @abstractmethod
    async def pre_execute(self, task_payload: dict) -> dict:
        """
        Enrich input with context before dispatch.
        MUST return enriched dict (not None).
        """
        ...

    @abstractmethod
    async def post_execute(self, result: dict, task_payload: dict) -> None:
        """
        Capture state delta from output.
        Side-effects only — no return value.
        """
        ...

    @abstractmethod
    async def on_error(self, error: Exception, task_payload: dict) -> dict:
        """
        Classify failure, return correction payload.
        """
        ...

    @abstractmethod
    async def on_correction(self, correction_payload: dict) -> dict:
        """
        Re-inject with CORRECTION: prefix.
        Returns re-injected payload.
        """
        ...


# VERIFICATION_STAMP
# Story: 1.01 (Track B)
# Verified By: parallel-builder
# Verified At: 2026-02-25T00:00:00Z
# Tests: 7/7
# Coverage: 100%
