context loading, path resolution, form state, dynamic rules, and provider-neutral assessment runner/cache boundary

This commit is contained in:
2026-05-04 13:52:29 +02:00
parent eccf1874fb
commit 8361f9ea45
29 changed files with 2809 additions and 65 deletions

View File

@@ -25,6 +25,7 @@ from markitect_tool.query import (
extract_document_with_engine,
query_document_with_engine,
)
from markitect_tool.runtime import evaluate_form_state, load_runtime_context_file
from markitect_tool.template import MissingTemplateVariable, TemplateError, render_template
@@ -322,6 +323,8 @@ class WorkflowRunner:
return self._step_contract_stub(step)
if kind == "contract_check":
return self._step_contract_check(step)
if kind == "form_state":
return self._step_form_state(step)
if kind == "assisted":
return self._step_assisted(step)
raise WorkflowError(f"Unsupported workflow step kind `{kind}`")
@@ -404,9 +407,28 @@ class WorkflowRunner:
def _step_contract_check(self, step: dict[str, Any]) -> dict[str, Any]:
document_path = _safe_input_path(self.base_dir, step.get("document"))
contract_path = _safe_input_path(self.base_dir, step.get("contract"))
result = check_markdown_file(document_path, contract_path)
context_path = (
_safe_input_path(self.base_dir, step.get("context"))
if step.get("context")
else None
)
result = check_markdown_file(document_path, contract_path, context_path=context_path)
return result.to_dict() | {"kind": "contract_check"}
def _step_form_state(self, step: dict[str, Any]) -> dict[str, Any]:
document_path = _safe_input_path(self.base_dir, step.get("document"))
contract_path = _safe_input_path(self.base_dir, step.get("contract"))
context_path = (
_safe_input_path(self.base_dir, step.get("context"))
if step.get("context")
else None
)
document = parse_markdown_file(document_path)
contract = load_contract_file(contract_path)
context = load_runtime_context_file(context_path) if context_path else None
result = evaluate_form_state(document, contract, context)
return result.to_dict() | {"kind": "form_state"}
def _step_assisted(self, step: dict[str, Any]) -> dict[str, Any]:
optional = bool(step.get("optional", True))
if self.assisted_hook is None: