sway(suite,cli): thread dlm_source spec field through the runner
- SHA
c9714b8f321494bb0bf0070f364e41a4823ab87c- Parents
-
5cf3d2e - Tree
51c9d5e
c9714b8
c9714b8f321494bb0bf0070f364e41a4823ab87c5cf3d2e
51c9d5e| Status | File | + | - |
|---|---|---|---|
| M |
src/dlm_sway/cli/commands.py
|
17 | 2 |
| M |
src/dlm_sway/suite/spec.py
|
5 | 0 |
src/dlm_sway/cli/commands.pymodified@@ -309,16 +309,31 @@ def _load_prompts(path: Path) -> tuple[str, ...]: | ||
| 309 | 309 | |
| 310 | 310 | def _execute_spec(path: Path) -> tuple[SuiteResult, SwayScore]: |
| 311 | 311 | """Load a spec, build a backend, run the suite, fold scores. Shared |
| 312 | - by ``run`` and ``gate``.""" | |
| 312 | + by ``run`` and ``gate``. Picks up .dlm-derived sections when the | |
| 313 | + spec's ``dlm_source`` is set.""" | |
| 313 | 314 | from dlm_sway.backends import build as build_backend |
| 314 | 315 | from dlm_sway.suite.loader import load_spec |
| 315 | 316 | from dlm_sway.suite.runner import run as run_suite |
| 316 | 317 | from dlm_sway.suite.score import compute as compute_score |
| 317 | 318 | |
| 318 | 319 | spec = load_spec(path) |
| 320 | + sections = None | |
| 321 | + doc_text = None | |
| 322 | + if spec.dlm_source is not None: | |
| 323 | + import importlib | |
| 324 | + | |
| 325 | + try: | |
| 326 | + resolver = importlib.import_module("dlm_sway.integrations.dlm.resolver") | |
| 327 | + handle = resolver.resolve_dlm(Path(spec.dlm_source)) | |
| 328 | + sections = handle.sections | |
| 329 | + doc_text = handle.doc_text | |
| 330 | + except ImportError: | |
| 331 | + # Honoring dlm_source is best-effort — probes that need | |
| 332 | + # sections will SKIP with a pointer at the extra. | |
| 333 | + sections = None | |
| 319 | 334 | backend = build_backend(spec.models.ft) |
| 320 | 335 | try: |
| 321 | - result = run_suite(spec, backend, spec_path=str(path)) | |
| 336 | + result = run_suite(spec, backend, spec_path=str(path), sections=sections, doc_text=doc_text) | |
| 322 | 337 | finally: |
| 323 | 338 | _close_if_possible(backend) |
| 324 | 339 | score_obj = compute_score(result) |
src/dlm_sway/suite/spec.pymodified@@ -54,6 +54,11 @@ class SwaySpec(BaseModel): | ||
| 54 | 54 | via :func:`dlm_sway.probes.base.build_probe` so that the set of |
| 55 | 55 | allowed probe kinds is an open registry rather than a closed |
| 56 | 56 | discriminated union.""" |
| 57 | + dlm_source: str | None = None | |
| 58 | + """Optional path to a ``.dlm`` file. When present, the runner asks | |
| 59 | + :mod:`dlm_sway.integrations.dlm.resolver` for typed sections and | |
| 60 | + hands them to probes via :attr:`RunContext.sections`. Auto-populated | |
| 61 | + by ``dlm-sway autogen``.""" | |
| 57 | 62 | |
| 58 | 63 | def check_version(self) -> None: |
| 59 | 64 | """Raise ``ValueError`` if the spec version is unsupported. |