tenseleyflow/sway / c9714b8

Browse files

sway(suite,cli): thread dlm_source spec field through the runner

Authored by espadonne
SHA
c9714b8f321494bb0bf0070f364e41a4823ab87c
Parents
5cf3d2e
Tree
51c9d5e

2 changed files

StatusFile+-
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, ...]:
309309
 
310310
 def _execute_spec(path: Path) -> tuple[SuiteResult, SwayScore]:
311311
     """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."""
313314
     from dlm_sway.backends import build as build_backend
314315
     from dlm_sway.suite.loader import load_spec
315316
     from dlm_sway.suite.runner import run as run_suite
316317
     from dlm_sway.suite.score import compute as compute_score
317318
 
318319
     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
319334
     backend = build_backend(spec.models.ft)
320335
     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)
322337
     finally:
323338
         _close_if_possible(backend)
324339
     score_obj = compute_score(result)
src/dlm_sway/suite/spec.pymodified
@@ -54,6 +54,11 @@ class SwaySpec(BaseModel):
5454
     via :func:`dlm_sway.probes.base.build_probe` so that the set of
5555
     allowed probe kinds is an open registry rather than a closed
5656
     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``."""
5762
 
5863
     def check_version(self) -> None:
5964
         """Raise ``ValueError`` if the spec version is unsupported.