Files
cdsl-cad/backend/engine/cdsl_engine/runtime_base.py
T
ganjihong 871070c440 refactor(cdsl_engine): extract session/extents/pattern_transform from runtime
Phase 2 of the decoupling refactor (behavior-preserving move):
- runtime_base.py: RuntimeExecutionError, FeatureExecutionError, ExtentVector
- session.py: GeometryAdapter protocol + ExecutionSession
- extents.py: end-condition planning (_extent_vectors family)
- pattern_transform.py: translate/mirror/rotate replay parameter algebra
- runtime.py: keeps executors + registry + entry points; re-exports all
  moved names (incl. test-referenced privates) for import stability

No behavior change; verified against baseline (zero new failures).
2026-09-09 13:13:17 +08:00

47 lines
1.5 KiB
Python

"""Shared runtime error types and extent planning values.
These primitives sit below both ``session`` (execution state) and the
executor modules, so geometry-independent helpers can raise the same stable
execution errors without importing the session or any executor.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any
from .topology import RuntimeDiagnostic, Vector3
class RuntimeExecutionError(RuntimeError):
"""A feature execution failure with serializable runtime evidence."""
def __init__(self, diagnostic: RuntimeDiagnostic, selector_resolutions: list[dict[str, Any]]) -> None:
super().__init__(diagnostic.message)
self.diagnostic = diagnostic
self.selector_resolutions = selector_resolutions
class FeatureExecutionError(RuntimeError):
"""An expected feature-level execution rejection with a stable code."""
def __init__(self, code: str, message: str, **detail: Any) -> None:
super().__init__(message)
self.code = code
self.detail = detail
@dataclass(frozen=True)
class ExtentVector:
"""Single-directional extrusion displacement for one profile face.
``trim_to`` stays ``None`` for an exact vector extrusion. When set, the
extent means "extrude until the target face, trimming any profile region
that does not reach it" (up_to_surface trim semantics, issue #5). The
piercing distance is computed inside the adapter, so ``vector`` only
supplies the direction.
"""
vector: Vector3
trim_to: Any | None = None