# Import-boundary contracts for the tolokaforge plug-in seams.
#
# The engine exposes five entry-point registered plug-in seams (grader,
# runtime backends, service-readiness probes, turn policies, external
# harnesses). Each seam exists so a downstream package can replace a
# component without touching engine code. Contracts here guard the
# *negative-space* of those seams: what the seam consumer must NOT
# reach. A forbidden import surfaces as a lint failure in seconds
# rather than after a full test run.
#
# See ADR-0038 § Design Drivers ("Import-linter, not just Protocol
# discipline") for the rationale, and the individual contract-name
# comments below for the seam each contract guards.
#
# Contracts start narrow and grow as each seam's implementation lands
# — better to scaffold the tool now and tighten as seams stabilise
# than to write contracts against half-migrated code and churn.

[importlinter]
root_packages =
    tolokaforge


# Grader-detach seam (ADR-0038, milestone: grader detachment).
#
# The orchestration surface (orchestrator / conductor / trial-executor)
# reaches the grader plug-in only through the ``TrialGrader`` Protocol
# in ``tolokaforge.core.trial_grader``. Importing ``core.grading.*``
# (the pure evaluator) or ``runner.service`` (the runner-side grade
# RPC) directly from the orchestration surface would silently
# re-collapse the seam ADR-0014, ADR-0022, and ADR-0038 built.
[importlinter:contract:grader-detach]
name = Orchestration surface holds the grader plug-in seam
type = forbidden
source_modules =
    tolokaforge.core.orchestrator
    tolokaforge.core.conductor
    tolokaforge.core.trial_executor
forbidden_modules =
    tolokaforge.core.grading
    tolokaforge.runner.service
allow_indirect_imports = true


# Sub-component seam invariants (ADR-0040).
#
# composite.py is the topology-neutral dispatch above the substrate. It
# must reach every sub-component through its Protocol via a resolved
# instance, never through a direct import of the reference-impl module.
# A direct import would silently re-collapse the seam and force every
# substrate + evaluator to co-locate with the composite.
#
# Six sub-component seams; six forbidden targets. The four ``default_*.py``
# modules were carved out explicitly so this contract can fence them at
# module granularity — a downstream can never accidentally reach through
# composite into a reference impl. Protocol / Context / FactoryAlias
# modules (rubric_evaluator, judge_model_provider, transcript_rule_matcher,
# state_check_backend, trace_check_operator) are IMPLICIT-ALLOW — composite
# legitimately imports the Protocol types under TYPE_CHECKING.
# ``check_runner`` stays implicit-allow because composite has never
# imported CheckRunner / InMemoryCheckExecutor directly (a resolved-
# instance kwarg is the sole route).
[importlinter:contract:composite-sub-component-seams]
name = Composite dispatch holds every sub-component plug-in seam
type = forbidden
source_modules =
    tolokaforge.core.grading.composite
forbidden_modules =
    tolokaforge.core.grading.judge
    tolokaforge.core.llm.client
    tolokaforge.core.grading.default_rubric_evaluator
    tolokaforge.core.grading.default_judge_model_provider
    tolokaforge.core.grading.default_transcript_rule_matcher
    tolokaforge.core.grading.default_state_check_backends
allow_indirect_imports = true
