From 940f8fb79de59de495a6cdaf4b5483c85932cc55 Mon Sep 17 00:00:00 2001 From: Trecek Date: Sun, 25 Oct 2026 23:15:56 -0700 Subject: [PATCH 01/17] refactor: colocate plan-set admission with verifier adapter --- .../server/recipe/_plan_set_preflight.py | 68 +++++++++++++++++++ .../server/recipe/_recipe_execution.py | 60 ++-------------- 2 files changed, 72 insertions(+), 56 deletions(-) diff --git a/src/autoskillit/server/recipe/_plan_set_preflight.py b/src/autoskillit/server/recipe/_plan_set_preflight.py index 96893f4e3f..fa7f7c060d 100644 --- a/src/autoskillit/server/recipe/_plan_set_preflight.py +++ b/src/autoskillit/server/recipe/_plan_set_preflight.py @@ -2,16 +2,84 @@ from __future__ import annotations +from collections.abc import Mapping from pathlib import Path +from typing import TYPE_CHECKING from autoskillit.core import ( + BoundScalar, + InstalledRecipeExecution, + InvocationTemplate, PlanSetBindingMode, + PlanSetPreflightEvidence, PlanSetPreflightRequest, PlanSetVerification, + PreflightKind, RecipeExecutionId, verify_plan_set_authority, ) +if TYPE_CHECKING: + from autoskillit.pipeline import ToolContext + + +class RecipeExecutionAdmissionError(RuntimeError): + """Stable pre-launch attested-execution rejection.""" + + def __init__(self, code: str, message: str) -> None: + super().__init__(message) + self.code = code + + +def _resolve_plan_set_preflight( + tool_ctx: ToolContext, + installed: InstalledRecipeExecution, + bound_input_map: Mapping[str, BoundScalar], + execution_id: str, + step_name: str, + template: InvocationTemplate, + allowed_root: Path | None, + kind: PreflightKind, +) -> PlanSetPreflightEvidence | None: + authority_path = bound_input_map.get("plan_set_authority_path") + if authority_path in (None, ""): + return None + stage_scope = kind is PreflightKind.PLAN_SET_STAGE_OBLIGATIONS + plan_path = None if stage_scope else bound_input_map.get("plan_path") + if not isinstance(authority_path, str) or (not stage_scope and not isinstance(plan_path, str)): + raise RecipeExecutionAdmissionError( + "recipe_execution_preflight_input", + "plan-set preflight requires bound string plan_path and authority path", + ) + if allowed_root is None: + raise RecipeExecutionAdmissionError( + "recipe_execution_preflight_input", "plan-set preflight requires an allowed root" + ) + if installed.plan_set_preflight_resolver is None: + raise RecipeExecutionAdmissionError( + "recipe_execution_preflight_unavailable", + "plan-set preflight resolver is unavailable", + ) + verification = installed.plan_set_preflight_resolver.resolve( + PlanSetPreflightRequest( + execution_generation=execution_id, + expected_kitchen_id=tool_ctx.kitchen_id, + step_name=step_name, + skill_name=template.invocation.skill_name or "", + plan_path=plan_path if isinstance(plan_path, str) else None, + plan_set_authority_path=authority_path, + allow_part_drift=stage_scope, + ), + allowed_root=allowed_root, + ) + if not verification.accepted: + reason = verification.reason.value if verification.reason else "rejected" + raise RecipeExecutionAdmissionError( + f"input_preflight_plan_set_{reason}", + "; ".join(verification.detail), + ) + return verification.evidence + class DefaultPlanSetPreflightResolver: """Verify a bound authority without allowing recipe code to read its bytes.""" diff --git a/src/autoskillit/server/recipe/_recipe_execution.py b/src/autoskillit/server/recipe/_recipe_execution.py index 6bc716d1ff..5b79977a6c 100644 --- a/src/autoskillit/server/recipe/_recipe_execution.py +++ b/src/autoskillit/server/recipe/_recipe_execution.py @@ -23,7 +23,6 @@ InventoryAdmissionDecision, InvocationTemplate, PlanSetPreflightEvidence, - PlanSetPreflightRequest, PreflightEvidence, PreflightKind, RecipeBindingProjection, @@ -55,6 +54,10 @@ compute_skill_contract_identity, ) from autoskillit.server._misc import clear_run_skill_state +from autoskillit.server.recipe._plan_set_preflight import ( + RecipeExecutionAdmissionError, + _resolve_plan_set_preflight, +) if TYPE_CHECKING: from autoskillit.core import ( @@ -86,14 +89,6 @@ ] -class RecipeExecutionAdmissionError(RuntimeError): - """Stable pre-launch attested-execution rejection.""" - - def __init__(self, code: str, message: str) -> None: - super().__init__(message) - self.code = code - - class DefaultInputPreflightResolver: """Verify audit-cycle input provenance before any child construction.""" @@ -591,53 +586,6 @@ def _resolve_audit_preflight( return audit -def _resolve_plan_set_preflight( - tool_ctx: ToolContext, - installed: InstalledRecipeExecution, - bound_input_map: Mapping[str, BoundScalar], - execution_id: str, - step_name: str, - template: InvocationTemplate, - allowed_root: Path | None, - kind: PreflightKind, -) -> PlanSetPreflightEvidence | None: - authority_path = bound_input_map.get("plan_set_authority_path") - if authority_path in (None, ""): - return None - stage_scope = kind is PreflightKind.PLAN_SET_STAGE_OBLIGATIONS - plan_path = None if stage_scope else bound_input_map.get("plan_path") - if not isinstance(authority_path, str) or (not stage_scope and not isinstance(plan_path, str)): - raise _build_preflight_input_error( - "plan-set preflight requires bound string plan_path and authority path", - ) - if allowed_root is None: - raise _build_preflight_input_error("plan-set preflight requires an allowed root") - if installed.plan_set_preflight_resolver is None: - raise RecipeExecutionAdmissionError( - "recipe_execution_preflight_unavailable", - "plan-set preflight resolver is unavailable", - ) - verification = installed.plan_set_preflight_resolver.resolve( - PlanSetPreflightRequest( - execution_generation=execution_id, - expected_kitchen_id=tool_ctx.kitchen_id, - step_name=step_name, - skill_name=template.invocation.skill_name or "", - plan_path=plan_path if isinstance(plan_path, str) else None, - plan_set_authority_path=authority_path, - allow_part_drift=stage_scope, - ), - allowed_root=allowed_root, - ) - if not verification.accepted: - reason = verification.reason.value if verification.reason else "rejected" - raise RecipeExecutionAdmissionError( - f"input_preflight_plan_set_{reason}", - "; ".join(verification.detail), - ) - return verification.evidence - - def resolve_attested_input_preflight( tool_ctx: ToolContext, installed: InstalledRecipeExecution, From 92895b3300a434d1263a99ecbaae3c3ad8ed43bc Mon Sep 17 00:00:00 2001 From: Trecek Date: Sun, 25 Oct 2026 23:23:56 -0700 Subject: [PATCH 02/17] test: reproduce clone-to-worktree plan-set admission failures --- ...test_bundled_recipes_pipeline_structure.py | 15 +- tests/server/test_plan_set_materializer.py | 81 ++++- tests/server/test_plan_set_preflight.py | 128 +++++++- .../test_plan_set_preflight_implement.py | 288 +++++++++++++++++- .../test_recipe_execution_preflight_list.py | 45 ++- tests/server/test_tools_plan_set.py | 5 + 6 files changed, 536 insertions(+), 26 deletions(-) diff --git a/tests/recipe/test_bundled_recipes_pipeline_structure.py b/tests/recipe/test_bundled_recipes_pipeline_structure.py index 28d1c00adb..05c57c67a6 100644 --- a/tests/recipe/test_bundled_recipes_pipeline_structure.py +++ b/tests/recipe/test_bundled_recipes_pipeline_structure.py @@ -1307,10 +1307,23 @@ def test_create_impl_worktree_precedes_implement(self, recipe) -> None: def test_implement_uses_worktree_path_as_cwd(self, recipe) -> None: impl_step = recipe.steps["implement"] cwd = impl_step.with_args.get("cwd", "") - assert "context.worktree_path" in cwd, ( + assert cwd == "${{ context.worktree_path }}", ( f"implement step cwd must reference context.worktree_path, got {cwd!r}" ) + def test_implement_retains_clone_plan_set_bindings(self, recipe) -> None: + skill_inputs = recipe.steps["implement"].with_args["skill_inputs"] + assert skill_inputs["plan_path"] == "${{ context.plan_path }}" + assert skill_inputs["plan_set_authority_path"] == "${{ context.plan_set_authority_path }}" + + def test_retry_uses_worktree_and_retained_plan_set_bindings(self, recipe) -> None: + retry = recipe.steps["retry_worktree"] + assert retry.with_args["cwd"] == "${{ context.worktree_path }}" + skill_inputs = retry.with_args["skill_inputs"] + assert skill_inputs["plan_path"] == "${{ context.plan_path }}" + assert skill_inputs["plan_set_authority_path"] == "${{ context.plan_set_authority_path }}" + assert skill_inputs["worktree_path"] == "${{ context.worktree_path }}" + # --------------------------------------------------------------------------- # Recipe cmd quoting — bundled recipes must not have shell expansion diff --git a/tests/server/test_plan_set_materializer.py b/tests/server/test_plan_set_materializer.py index 53eb3dc43f..9e1d2ef1e1 100644 --- a/tests/server/test_plan_set_materializer.py +++ b/tests/server/test_plan_set_materializer.py @@ -4,6 +4,7 @@ import json from dataclasses import replace +from datetime import UTC, datetime from pathlib import Path import pytest @@ -27,6 +28,12 @@ _GitHub = PlanSetGitHub +class _FrozenDatetime: + @staticmethod + def now(_zone: object) -> datetime: + return datetime(2026, 10, 25, tzinfo=UTC) + + def _plan_part( allocation_rows: str, *, @@ -105,6 +112,53 @@ async def test_sealed_binding_writes_content_addressed_authority(tmp_path: Path) assert Path(result.plan_set_authority_path).is_file() +@pytest.mark.parametrize("case", ("new", "existing", "unchanged_parent")) +@pytest.mark.asyncio +async def test_successful_recipe_bind_records_lookup_binding( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, case: str +) -> None: + monkeypatch.setattr(materializer_module, "datetime", _FrozenDatetime) + fixture = _FIXTURES / "split_r1_r2" + parts = tuple(tmp_path / name for name in ("part_a.md", "part_b.md")) + for part in parts: + part.write_text((fixture / part.name).read_text(), encoding="utf-8") + request = PlanSetBindRequest( + plan_parts_raw="\n".join(str(part) for part in parts), + allowed_root=tmp_path, + issue_url="owner/repo#1", + parent_authority_path="", + seal=True, + step_name="bind", + execution_generation="raw-execution-id", + kitchen_id="kitchen", + dispatch_id="", + binding_mode=PlanSetBindingMode.RECIPE, + ) + initial = None + if case != "new": + initial = await DefaultPlanSetMaterializer(_GitHub()).bind(request) + assert initial.success + if case == "unchanged_parent": + request = replace(request, parent_authority_path=initial.plan_set_authority_path) + + materializer = DefaultPlanSetMaterializer(_GitHub()) + lookup_path = initial.plan_set_authority_path if initial is not None else "missing.json" + assert materializer.lookup_binding("raw-execution-id", lookup_path) is None + + result = await materializer.bind(request) + + assert result.success + if case == "unchanged_parent": + assert initial is not None + assert result.plan_set_authority_path == initial.plan_set_authority_path + assert result.plan_set_authority_digest == initial.plan_set_authority_digest + authority = Path(result.plan_set_authority_path) + dotted_path = f"{authority.parent}/./{authority.name}" + expected = (tmp_path.resolve(), result.plan_set_authority_digest) + assert materializer.lookup_binding("raw-execution-id", dotted_path) == expected + assert materializer.lookup_binding("other-execution-id", dotted_path) is None + + def _coverage_failure_case( case: str, ) -> tuple[tuple[str, ...], str, tuple[str, ...], tuple[str, ...], tuple[str, ...]]: @@ -271,6 +325,10 @@ async def test_failed_seal_preserves_open_parent_for_gap_replan(tmp_path: Path) materializer = DefaultPlanSetMaterializer(_GitHub()) parent = await materializer.bind(request) assert parent.success + parent_binding = materializer.lookup_binding( + request.execution_generation, parent.plan_set_authority_path + ) + assert parent_binding == (tmp_path.resolve(), parent.plan_set_authority_digest) before = set((tmp_path / "plan-set-authority").rglob("*.json")) failed = await materializer.bind( @@ -291,6 +349,10 @@ async def test_failed_seal_preserves_open_parent_for_gap_replan(tmp_path: Path) assert "R2 [unassigned]" in failed.coverage_gaps assert failed.plan_set_authority_path == parent.plan_set_authority_path assert failed.plan_set_authority_digest == parent.plan_set_authority_digest + assert ( + materializer.lookup_binding(request.execution_generation, parent.plan_set_authority_path) + == parent_binding + ) assert set((tmp_path / "plan-set-authority").rglob("*.json")) == before @@ -606,6 +668,10 @@ async def test_renewal_rebinds_walkthrough_edits_before_implementation(tmp_path: materializer = DefaultPlanSetMaterializer(_GitHub()) initial = await materializer.bind(request) assert initial.success + assert materializer.lookup_binding("generation", initial.plan_set_authority_path) == ( + tmp_path.resolve(), + initial.plan_set_authority_digest, + ) parts[0].write_text( parts[0] .read_text() @@ -645,6 +711,14 @@ def verify(path: str): ) assert renewed.success assert renewed.plan_set_authority_digest != initial.plan_set_authority_digest + assert materializer.lookup_binding("generation", initial.plan_set_authority_path) == ( + tmp_path.resolve(), + initial.plan_set_authority_digest, + ) + assert materializer.lookup_binding("generation", renewed.plan_set_authority_path) == ( + tmp_path.resolve(), + renewed.plan_set_authority_digest, + ) admitted = verify(renewed.plan_set_authority_path) assert admitted.accepted assert admitted.authority is not None and admitted.authority.revision == 2 @@ -685,8 +759,13 @@ async def test_verifier_rejects_foreign_kitchen_and_standalone_binding(tmp_path: dispatch_id="", binding_mode=PlanSetBindingMode.STANDALONE, ) - bound = await DefaultPlanSetMaterializer(_GitHub()).bind(request) + materializer = DefaultPlanSetMaterializer(_GitHub()) + bound = await materializer.bind(request) assert bound.success + assert ( + materializer.lookup_binding(request.execution_generation, bound.plan_set_authority_path) + is None + ) foreign = verify_plan_set_authority( bound.plan_set_authority_path, allowed_root=tmp_path, diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index 00723e5267..347799e19b 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -28,12 +28,15 @@ pytestmark = [pytest.mark.layer("server"), pytest.mark.anyio, pytest.mark.medium] -async def _authority(tmp_path: Path, *, sealed: bool = True) -> tuple[str, Path]: +async def _authority( + tmp_path: Path, *, sealed: bool = True +) -> tuple[str, Path, DefaultPlanSetMaterializer]: fixture = _FIXTURES / "split_r1_r2" parts = (tmp_path / "part_a.md", tmp_path / "part_b.md") for part in parts: part.write_text((fixture / part.name).read_text(), encoding="utf-8") - bound = await DefaultPlanSetMaterializer(_GitHub()).bind( + materializer = DefaultPlanSetMaterializer(_GitHub()) + bound = await materializer.bind( PlanSetBindRequest( plan_parts_raw="\n".join(str(part) for part in parts), allowed_root=tmp_path, @@ -48,12 +51,12 @@ async def _authority(tmp_path: Path, *, sealed: bool = True) -> tuple[str, Path] ) ) assert bound.success - return bound.plan_set_authority_path, parts[0] + return bound.plan_set_authority_path, parts[0], materializer async def test_sealed_resolver_and_prompt_emit_assigned_subset(tmp_path: Path) -> None: assert PreflightKind("plan_set_coverage") is PreflightKind.PLAN_SET_COVERAGE - path, part = await _authority(tmp_path) + path, part, _ = await _authority(tmp_path) resolver = DefaultPlanSetPreflightResolver(RecipeExecutionId("generation"), "kitchen") verified = resolver.resolve( PlanSetPreflightRequest( @@ -80,7 +83,7 @@ async def test_sealed_resolver_and_prompt_emit_assigned_subset(tmp_path: Path) - async def test_unsealed_authority_is_rejected(tmp_path: Path) -> None: - path, part = await _authority(tmp_path, sealed=False) + path, part, _ = await _authority(tmp_path, sealed=False) result = DefaultPlanSetPreflightResolver(RecipeExecutionId("generation"), "kitchen").resolve( PlanSetPreflightRequest( execution_generation="generation", @@ -98,10 +101,11 @@ async def test_unsealed_authority_is_rejected(tmp_path: Path) -> None: async def test_absent_authority_omits_evidence_and_kitchen_error_is_namespaced( tmp_path: Path, ) -> None: - path, part = await _authority(tmp_path) + path, part, materializer = await _authority(tmp_path) resolver = DefaultPlanSetPreflightResolver(RecipeExecutionId("generation"), "kitchen") tool_ctx = SimpleNamespace( kitchen_id="other-kitchen", + plan_set_materializer=materializer, skill_contract_resolver=lambda _command: SimpleNamespace( input_preflight=("plan_set_coverage",) ), @@ -134,13 +138,87 @@ async def test_absent_authority_omits_evidence_and_kitchen_error_is_namespaced( assert exc_info.value.code == "input_preflight_plan_set_kitchen_mismatch" +def test_plan_only_preflight_uses_issued_root_without_invocation_root(tmp_path: Path) -> None: + issued_root = tmp_path / "producer" + issued_digest = "sha256:issued" + seen_roots: list[Path] = [] + + def resolve(_request, *, allowed_root): + seen_roots.append(allowed_root) + return SimpleNamespace( + accepted=True, + evidence=SimpleNamespace(plan_set_authority_digest=issued_digest), + ) + + resolved = resolve_attested_input_preflight( + SimpleNamespace( + kitchen_id="kitchen", + plan_set_materializer=SimpleNamespace( + lookup_binding=lambda execution_id, authority_path: ( + issued_root, + issued_digest, + ) + ), + skill_contract_resolver=lambda _: SimpleNamespace( + input_preflight=("plan_set_coverage",) + ), + ), + SimpleNamespace(plan_set_preflight_resolver=SimpleNamespace(resolve=resolve)), + skill_command="/autoskillit:dry-walkthrough", + execution_id="generation", + step_name="verify", + template=SimpleNamespace(invocation=SimpleNamespace(skill_name="dry-walkthrough")), + bound_inputs=(("plan_path", "plan.md"), ("plan_set_authority_path", "authority.json")), + allowed_root=None, + ) + + assert resolved.plan_set is not None + assert seen_roots == [issued_root] + + +def test_accepted_plan_set_verification_without_evidence_fails_closed(tmp_path: Path) -> None: + digest = "sha256:issued" + with pytest.raises(RecipeExecutionAdmissionError) as exc_info: + resolve_attested_input_preflight( + SimpleNamespace( + kitchen_id="kitchen", + plan_set_materializer=SimpleNamespace( + lookup_binding=lambda execution_id, authority_path: (tmp_path, digest) + ), + skill_contract_resolver=lambda _: SimpleNamespace( + input_preflight=("plan_set_coverage",) + ), + ), + SimpleNamespace( + plan_set_preflight_resolver=SimpleNamespace( + resolve=lambda request, *, allowed_root: SimpleNamespace( + accepted=True, + evidence=None, + ) + ) + ), + skill_command="/autoskillit:dry-walkthrough", + execution_id="generation", + step_name="verify", + template=SimpleNamespace(invocation=SimpleNamespace(skill_name="dry-walkthrough")), + bound_inputs=( + ("plan_path", "plan.md"), + ("plan_set_authority_path", "authority.json"), + ), + allowed_root=None, + ) + + assert exc_info.value.code == "recipe_execution_preflight_unavailable" + + async def _publication_authority(tmp_path: Path, *, sealed: bool = True): from tests.server._plan_set_test_helpers import PlanSetGitHub fixture = _FIXTURES / "publication_pr" part = tmp_path / "part.md" part.write_text((fixture / "part_a.md").read_text()) - bound = await DefaultPlanSetMaterializer(PlanSetGitHub(fixture_dir=fixture)).bind( + materializer = DefaultPlanSetMaterializer(PlanSetGitHub(fixture_dir=fixture)) + bound = await materializer.bind( PlanSetBindRequest( plan_parts_raw=str(part), allowed_root=tmp_path, @@ -157,13 +235,21 @@ async def _publication_authority(tmp_path: Path, *, sealed: bool = True): ) ) assert bound.success, bound - return bound, part + return bound, part, materializer -def _audit_preflight(tmp_path, path, *, kitchen="kitchen", generation="generation"): +def _audit_preflight( + tmp_path, + path, + materializer=None, + *, + kitchen="kitchen", + generation="generation", +): return resolve_attested_input_preflight( SimpleNamespace( kitchen_id=kitchen, + plan_set_materializer=materializer, skill_contract_resolver=lambda _: SimpleNamespace( input_preflight=("plan_set_stage_obligations",) ), @@ -183,8 +269,8 @@ def _audit_preflight(tmp_path, path, *, kitchen="kitchen", generation="generatio async def test_audit_scope_has_stage_outcomes_while_implementer_scope_has_only_code(tmp_path): - bound, part = await _publication_authority(tmp_path) - evidence = _audit_preflight(tmp_path, bound.plan_set_authority_path).plan_set + bound, part, materializer = await _publication_authority(tmp_path) + evidence = _audit_preflight(tmp_path, bound.plan_set_authority_path, materializer).plan_set assert evidence is not None assert evidence.part_key is None assert evidence.assigned_requirements == () @@ -212,7 +298,10 @@ async def test_audit_scope_has_stage_outcomes_while_implementer_scope_has_only_c ] assert "stage_obligations" not in implementation.evidence.to_dict() part.write_text(part.read_text() + "\nImplementation changed this part.\n") - assert _audit_preflight(tmp_path, bound.plan_set_authority_path).plan_set == evidence + assert ( + _audit_preflight(tmp_path, bound.plan_set_authority_path, materializer).plan_set + == evidence + ) def test_audit_without_authority_preserves_existing_scope(tmp_path): @@ -230,12 +319,21 @@ def test_audit_without_authority_preserves_existing_scope(tmp_path): async def test_audit_rejects_foreign_or_unsealed_authority( tmp_path, sealed, kitchen, generation, reason ): - bound, _ = await _publication_authority(tmp_path, sealed=sealed) + bound, _, materializer = await _publication_authority(tmp_path, sealed=sealed) with pytest.raises(RecipeExecutionAdmissionError) as exc_info: _audit_preflight( - tmp_path, bound.plan_set_authority_path, kitchen=kitchen, generation=generation + tmp_path, + bound.plan_set_authority_path, + materializer, + kitchen=kitchen, + generation=generation, ) - assert exc_info.value.code == f"input_preflight_plan_set_{reason}" + expected = ( + "recipe_execution_preflight_unavailable" + if generation != "generation" + else f"input_preflight_plan_set_{reason}" + ) + assert exc_info.value.code == expected def test_audit_contract_declares_authenticated_stage_scope(): diff --git a/tests/server/test_plan_set_preflight_implement.py b/tests/server/test_plan_set_preflight_implement.py index 95d03c681e..b40c11ecea 100644 --- a/tests/server/test_plan_set_preflight_implement.py +++ b/tests/server/test_plan_set_preflight_implement.py @@ -3,7 +3,9 @@ from __future__ import annotations import json +import subprocess from pathlib import Path +from typing import Any import pytest @@ -13,16 +15,22 @@ PlanSetPreflightRequest, PlanSetRejectReason, RecipeExecutionId, + canonical_json_bytes, + compute_canonical_hash, resolve_temp_dir, ) +from autoskillit.core.planset import verifier as plan_set_verifier from autoskillit.pipeline import ReadyRecipe +from autoskillit.recipe.io import builtin_scripts_dir from autoskillit.server._plan_set_materializer import DefaultPlanSetMaterializer from autoskillit.server.lifecycle._guards import _check_dry_walkthrough_plan from autoskillit.server.recipe._plan_set_preflight import DefaultPlanSetPreflightResolver from autoskillit.server.recipe._recipe_execution import install_recipe_execution from autoskillit.server.tools.tools_execution import run_skill -from tests.server._helpers import _ready_recipe_segment_step +from tests.fakes import InMemoryHeadlessExecutor +from tests.server._helpers import _ready_recipe_segment_step, _skill_ok from tests.server._pipeline_test_helpers import _write_tracker +from tests.server._plan_set_test_helpers import write_plan_set_parts from tests.server.test_plan_set_materializer import _FIXTURES, _GitHub pytestmark = [pytest.mark.layer("server"), pytest.mark.anyio, pytest.mark.medium] @@ -37,6 +45,7 @@ async def _bind( seal: bool = True, parent: str = "", write_parts: bool = True, + materializer: DefaultPlanSetMaterializer | None = None, ): root.mkdir(parents=True, exist_ok=True) fixture = _FIXTURES / "split_r1_r2" @@ -44,7 +53,7 @@ async def _bind( if write_parts: for part in parts: part.write_text((fixture / part.name).read_text(), encoding="utf-8") - materializer = DefaultPlanSetMaterializer(_GitHub()) + materializer = materializer or DefaultPlanSetMaterializer(_GitHub()) bound = await materializer.bind( PlanSetBindRequest( plan_parts_raw="\n".join(str(part) for part in parts), @@ -63,6 +72,64 @@ async def _bind( return bound, parts, materializer +def _consumer_args( + step: dict[str, Any], + credential: dict[str, Any], + *, + step_name: str, + worktree: Path, + plan: Path, + authority_path: str, +) -> dict[str, Any]: + with_args = step["with"] + assert isinstance(with_args, dict) + skill_inputs = { + "plan_path": str(plan), + "plan_set_authority_path": authority_path, + } + if step_name == "retry_worktree": + skill_inputs["worktree_path"] = str(worktree) + digests = credential["invocation_template_digests"] + assert isinstance(digests, dict) + return { + "skill_command": with_args["skill_command"], + "cwd": str(worktree), + "step_name": step_name, + "output_dir": with_args["output_dir"], + "recipe_execution_id": credential["execution_id"], + "invocation_template_digest": digests[step_name], + "skill_inputs": skill_inputs, + } + + +def _bound_payload(command: str) -> dict[str, Any]: + marker = "AUTOSKILLIT_BOUND_INVOCATION_V1\n" + assert marker in command + payload = json.loads(command.split(marker, 1)[1]) + assert isinstance(payload, dict) + return payload + + +def _create_impl_worktree(clone: Path, temp_dir: str) -> Path: + completed = subprocess.run( + [ + "bash", + str(builtin_scripts_dir() / "create_impl_worktree.sh"), + "impl-plan-set-handoff", + temp_dir, + ], + cwd=clone, + check=True, + capture_output=True, + text=True, + timeout=30, + ) + token = next( + line for line in completed.stdout.splitlines() if line.startswith("worktree_path=") + ) + return Path(token.split("=", 1)[1]).resolve() + + def _preflight( authority_path: str, plan: Path, @@ -192,6 +259,218 @@ async def unexpected_bind(_request: object) -> None: assert admitted.accepted +@pytest.mark.parametrize( + "tool_ctx_ready_recipe", + [ + ( + "implementation", + "implement", + {"issue_url": "https://github.com/TalonT-Org/AutoSkillit/issues/4261", "task": "test"}, + ) + ], + indirect=True, +) +async def test_clone_authority_admits_implement_and_retry_from_fresh_sibling_worktree( + tool_ctx_ready_recipe, + git_checkout: Path, + monkeypatch: pytest.MonkeyPatch, +) -> None: + from autoskillit.server.tools.tools_plan_set import bind_plan_set + + ready = tool_ctx_ready_recipe + tool_ctx = ready.tool_ctx + _, part_a, part_b = write_plan_set_parts(git_checkout, tool_ctx, monkeypatch) + plan_parts = f"{part_a}\n{part_b}" + initial = json.loads( + await bind_plan_set( + plan_parts=plan_parts, + cwd=str(git_checkout), + issue_url="https://github.com/TalonT-Org/AutoSkillit/issues/4261", + step_name="bind_plan_set", + ) + ) + assert initial["success"] is True, initial + part_a.write_text("Dry-walkthrough verified = TRUE\n" + part_a.read_text()) + renewed = json.loads( + await bind_plan_set( + plan_parts=plan_parts, + cwd=str(git_checkout), + parent_authority_path=initial["plan_set_authority_path"], + step_name="renew_plan_set", + ) + ) + assert renewed["success"] is True, renewed + assert renewed["plan_set_authority_digest"] != initial["plan_set_authority_digest"] + + worktree = _create_impl_worktree(git_checkout, str(tool_ctx.config.workspace.temp_dir)) + worktree_temp = resolve_temp_dir(worktree, tool_ctx.config.workspace.temp_dir) + assert not worktree_temp.exists() + authority_path = Path(renewed["plan_set_authority_path"]) + assert part_a.is_file() and authority_path.is_file() + common_git_dir = Path( + subprocess.run( + ["git", "rev-parse", "--path-format=absolute", "--git-common-dir"], + cwd=git_checkout, + check=True, + capture_output=True, + text=True, + timeout=10, + ).stdout.strip() + ) + exclude_path = common_git_dir / "info" / "exclude" + exclude_before = exclude_path.read_bytes() + + executor = InMemoryHeadlessExecutor( + default_result=_skill_ok(f"worktree_path = {worktree}\nhas_implementation_progress = true") + ) + monkeypatch.setattr(tool_ctx, "executor", executor) + _write_tracker( + tool_ctx.project_dir, + "AB", + { + "implement": {"status": "pending"}, + "retry_worktree": {"status": "pending"}, + }, + {}, + kitchen_id=tool_ctx.kitchen_id, + ) + + for step_name in ("implement", "retry_worktree"): + step, credential = _ready_recipe_segment_step(tool_ctx, step_name) + before = len(executor.calls) + response = json.loads( + await run_skill( + **_consumer_args( + step, + credential, + step_name=step_name, + worktree=worktree, + plan=part_a, + authority_path=str(authority_path), + ) + ) + ) + assert response["success"] is True, response + assert len(executor.calls) == before + 1 + call = executor.calls[-1] + assert Path(call.cwd) == worktree + payload = _bound_payload(call.skill_command) + evidence = payload["verified_plan_set_preflight"] + assert evidence["plan_set_authority_digest"] == renewed["plan_set_authority_digest"] + assert [row["requirement_id"] for row in evidence["assigned_requirements"]] == ["R1"] + assert exclude_path.read_bytes() == exclude_before + assert not worktree_temp.exists() + assert part_a.is_file() and authority_path.is_file() + + materializer = tool_ctx.plan_set_materializer + assert materializer is not None + execution_id = ready.receipt["recipe_execution"]["execution_id"] + assert materializer.lookup_binding(execution_id, initial["plan_set_authority_path"]) == ( + resolve_temp_dir(git_checkout, tool_ctx.config.workspace.temp_dir).resolve(), + initial["plan_set_authority_digest"], + ) + assert materializer.lookup_binding(execution_id, str(authority_path)) == ( + resolve_temp_dir(git_checkout, tool_ctx.config.workspace.temp_dir).resolve(), + renewed["plan_set_authority_digest"], + ) + + +@pytest.mark.parametrize("case", ["unissued", "rewritten", "other_execution"]) +@pytest.mark.parametrize( + "tool_ctx_ready_recipe", + [ + ( + "implementation", + "implement", + {"issue_url": "https://github.com/TalonT-Org/AutoSkillit/issues/4261", "task": "test"}, + ) + ], + indirect=True, +) +async def test_attested_implementation_rejects_untrusted_authority_provenance( + case: str, + tool_ctx_ready_recipe, + git_checkout: Path, + monkeypatch: pytest.MonkeyPatch, +) -> None: + from autoskillit.server.tools.tools_plan_set import bind_plan_set + + ready = tool_ctx_ready_recipe + tool_ctx = ready.tool_ctx + root, part_a, part_b = write_plan_set_parts(git_checkout, tool_ctx, monkeypatch) + part_a.write_text("Dry-walkthrough verified = TRUE\n" + part_a.read_text()) + execution_id = ready.receipt["recipe_execution"]["execution_id"] + materializer = tool_ctx.plan_set_materializer + assert isinstance(materializer, DefaultPlanSetMaterializer) + + if case == "unissued": + foreign = DefaultPlanSetMaterializer(_GitHub()) + bound, _, _ = await _bind( + root, + kitchen=tool_ctx.kitchen_id, + generation=execution_id, + write_parts=False, + materializer=foreign, + ) + authority_path = bound.plan_set_authority_path + expected_code = "input_preflight_plan_set_authority_invalid" + elif case == "other_execution": + bound, _, _ = await _bind( + root, + kitchen=tool_ctx.kitchen_id, + generation="other-execution", + write_parts=False, + materializer=materializer, + ) + authority_path = bound.plan_set_authority_path + expected_code = "input_preflight_plan_set_authority_invalid" + else: + bound = json.loads( + await bind_plan_set( + plan_parts=f"{part_a}\n{part_b}", + cwd=str(git_checkout), + issue_url="https://github.com/TalonT-Org/AutoSkillit/issues/4261", + step_name="bind_plan_set", + ) + ) + assert bound["success"] is True, bound + authority_path = bound["plan_set_authority_path"] + payload = json.loads(Path(authority_path).read_text()) + payload["dispatch_id"] = "self-consistent-rewrite" + unsigned = dict(payload) + unsigned.pop("authority_digest") + payload["authority_digest"] = compute_canonical_hash( + unsigned, domain=plan_set_verifier.PLAN_SET_AUTHORITY_DOMAIN + ) + Path(authority_path).write_bytes(canonical_json_bytes(payload)) + expected_code = "input_preflight_plan_set_authority_digest" + + executor = InMemoryHeadlessExecutor(default_result=_skill_ok("unexpected dispatch")) + monkeypatch.setattr(tool_ctx, "executor", executor) + _write_tracker( + tool_ctx.project_dir, + "AB", + {"implement": {"status": "pending"}}, + {}, + kitchen_id=tool_ctx.kitchen_id, + ) + step, credential = _ready_recipe_segment_step(tool_ctx, "implement") + response = json.loads( + await run_skill( + **_consumer_args( + step, + credential, + step_name="implement", + worktree=git_checkout, + plan=part_a, + authority_path=authority_path, + ) + ) + ) + assert expected_code in json.dumps(response) + assert executor.calls == [] + + async def test_marker_gate_precedes_digest_admission(tmp_path: Path, tool_ctx) -> None: root = tmp_path / "make-plan" bound, parts, _ = await _bind(root) @@ -224,17 +503,20 @@ async def test_marker_gate_precedes_digest_admission(tmp_path: Path, tool_ctx) - indirect=True, ) async def test_attested_marker_precedes_plan_set_digest_preflight( - tool_ctx_ready_recipe, git_checkout: Path + tool_ctx_ready_recipe, git_checkout: Path, monkeypatch: pytest.MonkeyPatch ) -> None: ready = tool_ctx_ready_recipe assert ready.tool_ctx.config.safety.require_dry_walkthrough step, credential = _ready_recipe_segment_step(ready.tool_ctx, "implement") work_dir = git_checkout allowed_root = resolve_temp_dir(work_dir, ready.tool_ctx.config.workspace.temp_dir) + materializer = DefaultPlanSetMaterializer(_GitHub()) + monkeypatch.setattr(ready.tool_ctx, "plan_set_materializer", materializer) bound, parts, _ = await _bind( allowed_root / "make-plan", kitchen=ready.tool_ctx.kitchen_id, generation=credential["execution_id"], + materializer=materializer, ) _write_tracker( ready.tool_ctx.project_dir, diff --git a/tests/server/test_recipe_execution_preflight_list.py b/tests/server/test_recipe_execution_preflight_list.py index a0ad43324a..7a43545499 100644 --- a/tests/server/test_recipe_execution_preflight_list.py +++ b/tests/server/test_recipe_execution_preflight_list.py @@ -20,9 +20,11 @@ class _AuditResolver: def __init__(self, calls: list[str], status: AdmissionStatus) -> None: self.calls = calls self.status = status + self.allowed_root: Path | None = None def resolve(self, _request: object, *, allowed_root: Path): self.calls.append("audit") + self.allowed_root = allowed_root return SimpleNamespace( decision=SimpleNamespace( status=self.status, @@ -34,34 +36,62 @@ def resolve(self, _request: object, *, allowed_root: Path): class _PlanSetResolver: - def __init__(self, calls: list[str]) -> None: + def __init__(self, calls: list[str], digest: str) -> None: self.calls = calls + self.digest = digest + self.allowed_root: Path | None = None def resolve(self, _request: object, *, allowed_root: Path): self.calls.append("plan_set") - return SimpleNamespace(accepted=True, evidence=SimpleNamespace(to_dict=lambda: {})) + self.allowed_root = allowed_root + return SimpleNamespace( + accepted=True, + evidence=SimpleNamespace( + plan_set_authority_digest=self.digest, + to_dict=lambda: {}, + ), + ) + + +class _PlanSetMaterializer: + def __init__(self, calls: list[str], root: Path, digest: str) -> None: + self.calls = calls + self.root = root + self.digest = digest + + def lookup_binding(self, execution_id: str, authority_path: str) -> tuple[Path, str] | None: + self.calls.append("lookup") + assert execution_id == "generation" + assert authority_path == "authority.json" + return self.root, self.digest @pytest.mark.parametrize( ("status", "expected_calls"), [ (AdmissionStatus.REJECT, ["audit"]), - (AdmissionStatus.PASS, ["audit", "plan_set"]), + (AdmissionStatus.PASS, ["audit", "lookup", "plan_set"]), ], ) def test_preflights_run_in_contract_order( tmp_path: Path, status: AdmissionStatus, expected_calls: list[str] ) -> None: calls: list[str] = [] + invocation_root = tmp_path / "invocation" + bind_root = tmp_path / "bind" + digest = "sha256:issued" + audit_resolver = _AuditResolver(calls, status) + plan_set_resolver = _PlanSetResolver(calls, digest) context = SimpleNamespace( kitchen_id="kitchen", + plan_set_materializer=_PlanSetMaterializer(calls, bind_root, digest), skill_contract_resolver=lambda _command: SimpleNamespace( input_preflight=("audit_cycle_inventory", "plan_set_coverage") ), ) installed = SimpleNamespace( - input_preflight_resolver=_AuditResolver(calls, status), - plan_set_preflight_resolver=_PlanSetResolver(calls), + input_preflight_resolver=audit_resolver, + plan_set_preflight_resolver=plan_set_resolver, ) template = SimpleNamespace(invocation=SimpleNamespace(skill_name="dry-walkthrough")) kwargs = dict( @@ -73,7 +103,7 @@ def test_preflights_run_in_contract_order( ("plan_path", str(tmp_path / "plan.md")), ("plan_set_authority_path", "authority.json"), ), - allowed_root=tmp_path, + allowed_root=invocation_root, ) if status is AdmissionStatus.REJECT: with pytest.raises(RecipeExecutionAdmissionError, match="inventory rejected"): @@ -82,3 +112,6 @@ def test_preflights_run_in_contract_order( resolved = resolve_attested_input_preflight(context, installed, **kwargs) assert resolved.audit is not None and resolved.plan_set is not None assert calls == expected_calls + assert audit_resolver.allowed_root == invocation_root + if status is AdmissionStatus.PASS: + assert plan_set_resolver.allowed_root == bind_root diff --git a/tests/server/test_tools_plan_set.py b/tests/server/test_tools_plan_set.py index 9767bdd446..dae0370ad6 100644 --- a/tests/server/test_tools_plan_set.py +++ b/tests/server/test_tools_plan_set.py @@ -43,6 +43,11 @@ async def bind(self, request: PlanSetBindRequest) -> PlanSetBindResult: self.request = request return await self.delegate.bind(request) + def lookup_binding( + self, execution_generation: str, authority_path: str + ) -> tuple[Path, str] | None: + return self.delegate.lookup_binding(execution_generation, authority_path) + async def test_headless_bind_writes_snapshot_and_tracks_response( tmp_path: Path, tool_ctx, monkeypatch: pytest.MonkeyPatch From 42a3dc1ac7120fcd5572882486f0e5c1198590e4 Mon Sep 17 00:00:00 2001 From: Trecek Date: Sun, 25 Oct 2026 23:34:59 -0700 Subject: [PATCH 03/17] fix: admit plan sets using server-recorded bind provenance --- docs/glossary.md | 18 ++++++++-- src/autoskillit/core/planset/AGENTS.md | 6 +++- .../types/protocols/_type_protocols_infra.py | 6 +++- src/autoskillit/pipeline/context.py | 3 +- .../server/_plan_set_materializer.py | 17 +++++++++- .../server/recipe/_plan_set_preflight.py | 31 ++++++++++++----- .../server/recipe/_recipe_execution.py | 1 - .../tools_execution/_run_skill_admission.py | 20 +++++------ .../server/tools/tools_execution/_state.py | 2 +- tests/_test_filter.py | 1 + tests/server/test_plan_set_preflight.py | 33 +++++++++++++++++++ .../test_plan_set_preflight_implement.py | 24 +++++++++++--- 12 files changed, 132 insertions(+), 30 deletions(-) diff --git a/docs/glossary.md b/docs/glossary.md index d009c353c5..410d99c7af 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -11,8 +11,22 @@ inventory to ordered hashed plan parts, their allocation rows, and aggregate coverage. `bind_plan_set` records hashed content evidence rather than command lines; aggregate coverage is decided only by the server-side `plan_set_coverage` preflight. Consumers receive verified preflight evidence, -never the artifact itself, and the sealed state is authenticated inside the -canonical authority digest. +never the artifact itself. The canonical authority digest is an unkeyed integrity +hash covering the sealed state; it does not establish server issuance. + +For recipe admission, the context-owned materializer retains each successful +bind's root and issued digest for that execution and authority path. Admission +verifies the original path beneath its recorded bind root and compares the +verified digest with that issuance record. Audit inputs retain their invocation +cwd root; standalone binding retains cwd containment and creates no recipe record. + +Records live in the server process, survive same-context execution reinstalls, +and are retained for its lifetime, including obsolete executions. Fresh contexts, +including fleet-side contexts, require their own successful recipe bind. +This boundary trusts the server process, its records, and the supplied root and +its ancestors. The recorded root is a path, without a retained directory handle +or bind-time inode identity; replacing it or an ancestor can change later path +resolution. A sibling worktree does not provide OS-level isolation. ### arch-lens diff --git a/src/autoskillit/core/planset/AGENTS.md b/src/autoskillit/core/planset/AGENTS.md index db6b149b95..5c217a65da 100644 --- a/src/autoskillit/core/planset/AGENTS.md +++ b/src/autoskillit/core/planset/AGENTS.md @@ -1 +1,5 @@ -The IL-0 plan-set domain owns deterministic regex-only requirement extraction, allocation parsing, aggregate coverage, and verification; the server owns fetching and persistence. `plan_set_coverage` is an in-process server-side aggregate inspection, not a decision made by a child skill. Unsupported Markdown is recorded as a fail-closed marker, `text_digest` covers exact raw item spans rather than normalized text, and skills never open authority artifacts. Part commands are evidence only: the authenticated authority carries the hashed parts and coverage result. Its `state` is included in the canonical payload authenticated by `authority_digest`; admission requires both a matching recomputed digest and `state == sealed`. +The IL-0 plan-set domain owns deterministic regex-only requirement extraction, allocation parsing, aggregate coverage, and verification; the server owns fetching and persistence. `plan_set_coverage` is an in-process server-side aggregate inspection, not a decision made by a child skill. Unsupported Markdown is recorded as a fail-closed marker, `text_digest` covers exact raw item spans rather than normalized text, and skills never open authority artifacts. Part commands are evidence only: the authority carries the hashed parts and coverage result. Its `state` is included in the canonical payload covered by the unkeyed integrity hash `authority_digest`; admission requires both a matching recomputed digest and `state == sealed`. + +Recipe admission also requires server-held issuance provenance: the existing materializer records each successful recipe bind's resolved root and digest by execution ID and authority path. Admission verifies the original caller path under that recorded root, then compares the verified digest with the issued digest. Standalone binds keep cwd-rooted containment and create no recipe record; audit inputs retain their invocation-cwd root. + +Records remain in memory for the server process lifetime, including obsolete executions. Reinstalling an execution on the same context preserves them; fresh contexts, including fleet-side contexts, need their own successful recipe bind. This trusts the server process, its records, and the supplied root and its ancestors. The root is a path rather than a retained directory descriptor or bind-time inode identity, so replacing the root or its ancestors can change later resolution. The digest pin does not protect directory identity, and a sibling worktree does not establish OS-level isolation. diff --git a/src/autoskillit/core/types/protocols/_type_protocols_infra.py b/src/autoskillit/core/types/protocols/_type_protocols_infra.py index b46768aa26..6ae4720c63 100644 --- a/src/autoskillit/core/types/protocols/_type_protocols_infra.py +++ b/src/autoskillit/core/types/protocols/_type_protocols_infra.py @@ -236,10 +236,14 @@ def __call__(self, project_dir: Path) -> frozenset[str]: ... @runtime_checkable class PlanSetMaterializer(Protocol): - """Server-owned binder for a content-addressed plan-set authority.""" + """Server-owned plan-set binder and successful recipe-bind provenance lookup.""" async def bind(self, request: PlanSetBindRequest) -> PlanSetBindResult: ... + def lookup_binding( + self, execution_generation: str, authority_path: str + ) -> tuple[Path, str] | None: ... + @dataclass(frozen=True, slots=True) class QuotaPolicy: diff --git a/src/autoskillit/pipeline/context.py b/src/autoskillit/pipeline/context.py index 2c8ee835a2..fde463827f 100644 --- a/src/autoskillit/pipeline/context.py +++ b/src/autoskillit/pipeline/context.py @@ -229,7 +229,8 @@ class ToolContext: into server-owned canonical audit authority artifacts. plan_set_materializer: PlanSetMaterializer — binds ordered plan parts to server-owned - plan-set authority artifacts. + plan-set authority artifacts and retains successful recipe-bind + roots and digests for server-held provenance lookup. committed_disposition_resolver: CommittedDispositionResolver — resolves only disposition paths backed by the durable audit-admission ledger. diff --git a/src/autoskillit/server/_plan_set_materializer.py b/src/autoskillit/server/_plan_set_materializer.py index 4abc8fd6f5..9a1b090f3b 100644 --- a/src/autoskillit/server/_plan_set_materializer.py +++ b/src/autoskillit/server/_plan_set_materializer.py @@ -2,6 +2,7 @@ from __future__ import annotations +import os from collections.abc import Sequence from datetime import UTC, datetime from pathlib import Path @@ -21,6 +22,7 @@ IssueSnapshotRef, PlanPartRef, PlanSetAuthority, + PlanSetBindingMode, PlanSetBindRequest, PlanSetBindResult, PlanSetRejectReason, @@ -169,6 +171,12 @@ class DefaultPlanSetMaterializer: def __init__(self, github_client: GitHubFetcher | None) -> None: self._github_client = github_client + self._bindings: dict[tuple[str, str], tuple[Path, str]] = {} + + def lookup_binding( + self, execution_generation: str, authority_path: str + ) -> tuple[Path, str] | None: + return self._bindings.get((execution_generation, os.path.abspath(authority_path))) async def bind(self, request: PlanSetBindRequest) -> PlanSetBindResult: predecessor: PlanSetAuthority | None = None @@ -224,7 +232,7 @@ async def bind(self, request: PlanSetBindRequest) -> PlanSetBindResult: parent_path = str(Path(request.parent_authority_path).resolve()) if predecessor is parent: predecessor_path = parent_path - return await self._bind( + result = await self._bind( request, root, parent, @@ -233,6 +241,13 @@ async def bind(self, request: PlanSetBindRequest) -> PlanSetBindResult: predecessor_path, predecessor_digest, ) + if result.success and request.binding_mode is PlanSetBindingMode.RECIPE: + key = ( + request.execution_generation, + os.path.abspath(result.plan_set_authority_path), + ) + self._bindings[key] = (root, result.plan_set_authority_digest) + return result except Exception as exc: logger.error("plan-set binding failed", exc_info=True) return _failure( diff --git a/src/autoskillit/server/recipe/_plan_set_preflight.py b/src/autoskillit/server/recipe/_plan_set_preflight.py index fa7f7c060d..ef3179a47e 100644 --- a/src/autoskillit/server/recipe/_plan_set_preflight.py +++ b/src/autoskillit/server/recipe/_plan_set_preflight.py @@ -13,6 +13,7 @@ PlanSetBindingMode, PlanSetPreflightEvidence, PlanSetPreflightRequest, + PlanSetRejectReason, PlanSetVerification, PreflightKind, RecipeExecutionId, @@ -38,7 +39,6 @@ def _resolve_plan_set_preflight( execution_id: str, step_name: str, template: InvocationTemplate, - allowed_root: Path | None, kind: PreflightKind, ) -> PlanSetPreflightEvidence | None: authority_path = bound_input_map.get("plan_set_authority_path") @@ -51,15 +51,19 @@ def _resolve_plan_set_preflight( "recipe_execution_preflight_input", "plan-set preflight requires bound string plan_path and authority path", ) - if allowed_root is None: + materializer = tool_ctx.plan_set_materializer + if materializer is None or installed.plan_set_preflight_resolver is None: raise RecipeExecutionAdmissionError( - "recipe_execution_preflight_input", "plan-set preflight requires an allowed root" + "recipe_execution_preflight_unavailable", + "plan-set materializer or preflight resolver is unavailable", ) - if installed.plan_set_preflight_resolver is None: + binding = materializer.lookup_binding(execution_id, authority_path) + if binding is None: raise RecipeExecutionAdmissionError( - "recipe_execution_preflight_unavailable", - "plan-set preflight resolver is unavailable", + f"input_preflight_plan_set_{PlanSetRejectReason.AUTHORITY_INVALID.value}", + "authority was not bound by this server for the current recipe execution", ) + bind_root, issued_digest = binding verification = installed.plan_set_preflight_resolver.resolve( PlanSetPreflightRequest( execution_generation=execution_id, @@ -70,7 +74,7 @@ def _resolve_plan_set_preflight( plan_set_authority_path=authority_path, allow_part_drift=stage_scope, ), - allowed_root=allowed_root, + allowed_root=bind_root, ) if not verification.accepted: reason = verification.reason.value if verification.reason else "rejected" @@ -78,7 +82,18 @@ def _resolve_plan_set_preflight( f"input_preflight_plan_set_{reason}", "; ".join(verification.detail), ) - return verification.evidence + evidence = verification.evidence + if evidence is None: + raise RecipeExecutionAdmissionError( + "recipe_execution_preflight_unavailable", + "accepted plan-set verification did not provide evidence", + ) + if evidence.plan_set_authority_digest != issued_digest: + raise RecipeExecutionAdmissionError( + "input_preflight_plan_set_authority_digest", + "verified authority digest differs from its server-issued binding", + ) + return evidence class DefaultPlanSetPreflightResolver: diff --git a/src/autoskillit/server/recipe/_recipe_execution.py b/src/autoskillit/server/recipe/_recipe_execution.py index 5b79977a6c..5a563e70b6 100644 --- a/src/autoskillit/server/recipe/_recipe_execution.py +++ b/src/autoskillit/server/recipe/_recipe_execution.py @@ -622,7 +622,6 @@ def resolve_attested_input_preflight( execution_id, step_name, template, - allowed_root, PreflightKind(preflight_name), ) else: diff --git a/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py b/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py index 9073bb4e9a..c65997ec7c 100644 --- a/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py +++ b/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py @@ -226,7 +226,7 @@ def _prepare_audit_reservation( ) -> None: """Prepare and reserve the audit slot for an attested publication.""" assert state._audit_publication is not None - assert state._clone_allowed_root is not None + assert state._invocation_temp_root is not None assert state._installed_execution is not None state._slot_intent_digest = compute_audit_slot_intent_digest( execution_id=state.recipe_execution_id, @@ -245,14 +245,14 @@ def _prepare_audit_reservation( if isinstance(prior_path, str) and prior_path: prior_authority = load_current_prior_authority( prior_path, - allowed_root=state._clone_allowed_root, + allowed_root=state._invocation_temp_root, ledger=state.tool_ctx.audit_admission_ledger, recipe_execution_id=state._recipe_execution_key, ) state._audited_plan_refs = ( normalize_audited_plan_refs( str(state._bound_input_map.get("all_plan_paths") or ""), - allowed_root=state._clone_allowed_root, + allowed_root=state._invocation_temp_root, ) if state._bound_input_map.get("all_plan_paths") else prior_authority.audited_plan_refs @@ -264,7 +264,7 @@ def _prepare_audit_reservation( else: state._audited_plan_refs = normalize_audited_plan_refs( str(state._bound_input_map.get("all_plan_paths") or ""), - allowed_root=state._clone_allowed_root, + allowed_root=state._invocation_temp_root, ) state._cycle_id, state._scope_id, state._part_id = derive_initial_lifecycle_ids( recipe_execution_id=state._recipe_execution_key, @@ -294,7 +294,7 @@ def _prepare_audit_reservation( cycle_id=state._cycle_id, scope_id=state._scope_id, part_id=state._part_id, - allowed_root=state._clone_allowed_root, + allowed_root=state._invocation_temp_root, parent_authority_digest=state._parent_digest, retry_after_audit_attempt_id=( AuditAttemptId(state.retry_after_audit_attempt_id) @@ -328,7 +328,7 @@ def _handle_audit_reservation_decision(state: _RunSkillDispatchState) -> str | N """Construct the dispatch prompt or return an audit reservation terminal result.""" assert state._reservation_outcome is not None assert state._audited_plan_refs is not None - assert state._clone_allowed_root is not None + assert state._invocation_temp_root is not None match state._reservation_outcome.decision: case ReservationDecision.DISPATCH_NEW | ReservationDecision.REDISPATCH_OPEN: assert state._reservation_outcome.reservation is not None @@ -402,7 +402,7 @@ def _handle_audit_reservation_decision(state: _RunSkillDispatchState) -> str | N ) case ReservationDecision.PUBLISHED_PENDING_FINALIZATION: assert state._reservation_outcome.reservation is not None - state._authority = AuditCycleVerifier(state._clone_allowed_root).load_authority( + state._authority = AuditCycleVerifier(state._invocation_temp_root).load_authority( state._reservation_outcome.reservation.authority_path ) state._published = AuditMaterializationResult( @@ -479,7 +479,7 @@ def _admit_recipe_execution(state: _RunSkillDispatchState) -> str | None: if state._target_contract is None: raise SkillContractError("audit output contract is unavailable") select_audit_output_contract(state._target_contract, state._audit_output_mode) - # Resolve the clone-local containment anchor before every publication branch (#4387). + # Resolve the invocation-cwd temp root for audit inputs and publication (#4387). # Only active recipe executions consume it, so only they require a non-empty cwd. if state._installed_execution is not None and not state.cwd: return json.dumps( @@ -489,7 +489,7 @@ def _admit_recipe_execution(state: _RunSkillDispatchState) -> str | None: retriable=False, ) ) - state._clone_allowed_root = resolve_temp_dir( + state._invocation_temp_root = resolve_temp_dir( Path(state.cwd), state.tool_ctx.config.workspace.temp_dir ) if state._dynamic_recipe_call: @@ -598,7 +598,7 @@ def _admit_attested_recipe_invocation(state: _RunSkillDispatchState) -> str | No step_name=state.step_name, template=state._invocation_template, bound_inputs=state._bound_recipe_inputs, - allowed_root=state._clone_allowed_root, + allowed_root=state._invocation_temp_root, ) state._preflight_result = resolved_preflights.audit state._plan_set_preflight = resolved_preflights.plan_set diff --git a/src/autoskillit/server/tools/tools_execution/_state.py b/src/autoskillit/server/tools/tools_execution/_state.py index 02db0c2d7c..0cedf3c405 100644 --- a/src/autoskillit/server/tools/tools_execution/_state.py +++ b/src/autoskillit/server/tools/tools_execution/_state.py @@ -190,7 +190,7 @@ class _RunSkillDispatchState: _claims_recipe_execution: bool = False _dynamic_recipe_call: bool = False _audit_output_mode: AuditOutputMode | None = None - _clone_allowed_root: Path | None = None + _invocation_temp_root: Path | None = None _slot_intent_digest: str | None = None _bound_input_map: dict[str, BoundScalar] | None = None _prior_input_field: str | None = None diff --git a/tests/_test_filter.py b/tests/_test_filter.py index e14485a094..aba4f83fbf 100644 --- a/tests/_test_filter.py +++ b/tests/_test_filter.py @@ -1352,6 +1352,7 @@ class SourceMapRejection(enum.StrEnum): "hooks/test_recipe_contract_freshness.py", "migration", # Server file-level entries importing autoskillit.recipe: + "server/test_plan_set_preflight_implement.py", "server/test_stage_obligation_pipeline.py", "server/test_tools_plan_set.py", "server/test_run_skill_delegated_output_write.py", diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index 347799e19b..91cd663295 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -3,6 +3,7 @@ from __future__ import annotations import json +import os from pathlib import Path from types import SimpleNamespace @@ -138,6 +139,38 @@ async def test_absent_authority_omits_evidence_and_kitchen_error_is_namespaced( assert exc_info.value.code == "input_preflight_plan_set_kitchen_mismatch" +@pytest.mark.parametrize("kind", ("symlink", "hardlink")) +async def test_recorded_authority_still_rejects_file_links(tmp_path: Path, kind: str) -> None: + authority_path, part, materializer = await _authority(tmp_path) + path = Path(authority_path) + original = path.rename(path.with_suffix(".original")) + if kind == "symlink": + path.symlink_to(original) + else: + os.link(original, path) + with pytest.raises(RecipeExecutionAdmissionError) as exc_info: + resolve_attested_input_preflight( + SimpleNamespace( + kitchen_id="kitchen", + plan_set_materializer=materializer, + skill_contract_resolver=lambda _: SimpleNamespace( + input_preflight=("plan_set_coverage",) + ), + ), + SimpleNamespace( + plan_set_preflight_resolver=DefaultPlanSetPreflightResolver( + RecipeExecutionId("generation"), "kitchen" + ) + ), + skill_command="/autoskillit:dry-walkthrough", + execution_id="generation", + step_name="verify", + template=SimpleNamespace(invocation=SimpleNamespace(skill_name="dry-walkthrough")), + bound_inputs=(("plan_path", str(part)), ("plan_set_authority_path", authority_path)), + ) + assert exc_info.value.code == f"input_preflight_plan_set_{kind}" + + def test_plan_only_preflight_uses_issued_root_without_invocation_root(tmp_path: Path) -> None: issued_root = tmp_path / "producer" issued_digest = "sha256:issued" diff --git a/tests/server/test_plan_set_preflight_implement.py b/tests/server/test_plan_set_preflight_implement.py index b40c11ecea..d29a3dbda5 100644 --- a/tests/server/test_plan_set_preflight_implement.py +++ b/tests/server/test_plan_set_preflight_implement.py @@ -72,6 +72,14 @@ async def _bind( return bound, parts, materializer +def _implementation_parts(clone: Path, tool_ctx, monkeypatch: pytest.MonkeyPatch): + root, *parts = write_plan_set_parts(clone, tool_ctx, monkeypatch) + plan_root = root / "make-plan" + plan_root.mkdir() + moved = tuple(part.rename(plan_root / part.name) for part in parts) + return plan_root, *moved + + def _consumer_args( step: dict[str, Any], credential: dict[str, Any], @@ -233,7 +241,13 @@ async def test_resumed_execution_consumes_original_authority_without_rebinding( original_execution = state.installed_execution original_id = original_execution.snapshot.execution_id kitchen = ready.tool_ctx.kitchen_id - bound, parts, _ = await _bind(tmp_path, kitchen=kitchen, generation=original_id) + materializer = ready.tool_ctx.plan_set_materializer + assert isinstance(materializer, DefaultPlanSetMaterializer) + bound, parts, _ = await _bind( + tmp_path, kitchen=kitchen, generation=original_id, materializer=materializer + ) + pin = (tmp_path.resolve(), bound.plan_set_authority_digest) + assert materializer.lookup_binding(original_id, bound.plan_set_authority_path) == pin async def unexpected_bind(_request: object) -> None: raise AssertionError("resume must not re-bind an existing authority") @@ -244,6 +258,8 @@ async def unexpected_bind(_request: object) -> None: assert isinstance(resumed_state, ReadyRecipe) resumed_execution = resumed_state.installed_execution assert resumed_execution.snapshot.execution_id == original_id + assert materializer.lookup_binding(original_id, bound.plan_set_authority_path) == pin + assert materializer.lookup_binding("other-execution", bound.plan_set_authority_path) is None assert resumed_execution.plan_set_preflight_resolver is not None admitted = resumed_execution.plan_set_preflight_resolver.resolve( PlanSetPreflightRequest( @@ -279,7 +295,7 @@ async def test_clone_authority_admits_implement_and_retry_from_fresh_sibling_wor ready = tool_ctx_ready_recipe tool_ctx = ready.tool_ctx - _, part_a, part_b = write_plan_set_parts(git_checkout, tool_ctx, monkeypatch) + _, part_a, part_b = _implementation_parts(git_checkout, tool_ctx, monkeypatch) plan_parts = f"{part_a}\n{part_b}" initial = json.loads( await bind_plan_set( @@ -350,7 +366,7 @@ async def test_clone_authority_admits_implement_and_retry_from_fresh_sibling_wor ) ) ) - assert response["success"] is True, response + assert response["success"] is True, json.dumps(response) assert len(executor.calls) == before + 1 call = executor.calls[-1] assert Path(call.cwd) == worktree @@ -397,7 +413,7 @@ async def test_attested_implementation_rejects_untrusted_authority_provenance( ready = tool_ctx_ready_recipe tool_ctx = ready.tool_ctx - root, part_a, part_b = write_plan_set_parts(git_checkout, tool_ctx, monkeypatch) + root, part_a, part_b = _implementation_parts(git_checkout, tool_ctx, monkeypatch) part_a.write_text("Dry-walkthrough verified = TRUE\n" + part_a.read_text()) execution_id = ready.receipt["recipe_execution"]["execution_id"] materializer = tool_ctx.plan_set_materializer From 579bb3f46e523546be3003ea1006cfafbdea1211 Mon Sep 17 00:00:00 2001 From: Trecek Date: Sun, 25 Oct 2026 23:50:12 -0700 Subject: [PATCH 04/17] test: complete admission fixtures through result acknowledgement --- tests/server/test_plan_set_preflight.py | 2 +- tests/server/test_plan_set_preflight_implement.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index 91cd663295..fe9f358772 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -362,7 +362,7 @@ async def test_audit_rejects_foreign_or_unsealed_authority( generation=generation, ) expected = ( - "recipe_execution_preflight_unavailable" + "input_preflight_plan_set_authority_invalid" if generation != "generation" else f"input_preflight_plan_set_{reason}" ) diff --git a/tests/server/test_plan_set_preflight_implement.py b/tests/server/test_plan_set_preflight_implement.py index d29a3dbda5..d53ab6c90f 100644 --- a/tests/server/test_plan_set_preflight_implement.py +++ b/tests/server/test_plan_set_preflight_implement.py @@ -5,6 +5,7 @@ import json import subprocess from pathlib import Path +from types import SimpleNamespace from typing import Any import pytest @@ -27,6 +28,7 @@ from autoskillit.server.recipe._plan_set_preflight import DefaultPlanSetPreflightResolver from autoskillit.server.recipe._recipe_execution import install_recipe_execution from autoskillit.server.tools.tools_execution import run_skill +from autoskillit.server.tools.tools_pipeline_tracker import complete_run_skill_result from tests.fakes import InMemoryHeadlessExecutor from tests.server._helpers import _ready_recipe_segment_step, _skill_ok from tests.server._pipeline_test_helpers import _write_tracker @@ -243,6 +245,7 @@ async def test_resumed_execution_consumes_original_authority_without_rebinding( kitchen = ready.tool_ctx.kitchen_id materializer = ready.tool_ctx.plan_set_materializer assert isinstance(materializer, DefaultPlanSetMaterializer) + monkeypatch.setattr(materializer, "_github_client", _GitHub()) bound, parts, _ = await _bind( tmp_path, kitchen=kitchen, generation=original_id, materializer=materializer ) @@ -377,6 +380,17 @@ async def test_clone_authority_admits_implement_and_retry_from_fresh_sibling_wor assert exclude_path.read_bytes() == exclude_before assert not worktree_temp.exists() assert part_a.is_file() and authority_path.is_file() + # Direct tool calls model delivery before the next orchestrator invocation. + completion = tool_ctx.run_skill_completion + assert completion is not None + receipt = completion.publish(response["receipt_id"]) + acknowledgement = json.loads( + await complete_run_skill_result( + receipt.receipt_id, + ctx=SimpleNamespace(session_id=receipt.request_session_id), + ) + ) + assert acknowledgement["success"] is True, acknowledgement materializer = tool_ctx.plan_set_materializer assert materializer is not None From e3b27e38b5fbea667972498ce317e7f5bc0fe889 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:50:02 -0700 Subject: [PATCH 05/17] fix(review): share recipe admission errors across preflight paths --- src/autoskillit/server/recipe/_admission.py | 9 +++++++++ src/autoskillit/server/recipe/_plan_set_preflight.py | 9 +-------- src/autoskillit/server/recipe/_recipe_execution.py | 3 +-- src/autoskillit/server/recipe/_recipe_initialization.py | 2 +- .../server/tools/tools_execution/_run_skill_admission.py | 2 +- tests/server/test_attestation_delivery_reachability.py | 2 +- tests/server/test_attested_admission_replay.py | 2 +- tests/server/test_kitchen_lifecycle.py | 2 +- tests/server/test_plan_set_preflight.py | 2 +- tests/server/test_recipe_execution_preflight_list.py | 2 +- tests/server/test_recipe_initialization.py | 2 +- 11 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 src/autoskillit/server/recipe/_admission.py diff --git a/src/autoskillit/server/recipe/_admission.py b/src/autoskillit/server/recipe/_admission.py new file mode 100644 index 0000000000..beb123e494 --- /dev/null +++ b/src/autoskillit/server/recipe/_admission.py @@ -0,0 +1,9 @@ +"""Shared recipe execution admission failures.""" + + +class RecipeExecutionAdmissionError(RuntimeError): + """Stable pre-launch attested-execution rejection.""" + + def __init__(self, code: str, message: str) -> None: + super().__init__(message) + self.code = code diff --git a/src/autoskillit/server/recipe/_plan_set_preflight.py b/src/autoskillit/server/recipe/_plan_set_preflight.py index ef3179a47e..628154ad76 100644 --- a/src/autoskillit/server/recipe/_plan_set_preflight.py +++ b/src/autoskillit/server/recipe/_plan_set_preflight.py @@ -19,19 +19,12 @@ RecipeExecutionId, verify_plan_set_authority, ) +from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError if TYPE_CHECKING: from autoskillit.pipeline import ToolContext -class RecipeExecutionAdmissionError(RuntimeError): - """Stable pre-launch attested-execution rejection.""" - - def __init__(self, code: str, message: str) -> None: - super().__init__(message) - self.code = code - - def _resolve_plan_set_preflight( tool_ctx: ToolContext, installed: InstalledRecipeExecution, diff --git a/src/autoskillit/server/recipe/_recipe_execution.py b/src/autoskillit/server/recipe/_recipe_execution.py index 5a563e70b6..f32bd469d3 100644 --- a/src/autoskillit/server/recipe/_recipe_execution.py +++ b/src/autoskillit/server/recipe/_recipe_execution.py @@ -54,8 +54,8 @@ compute_skill_contract_identity, ) from autoskillit.server._misc import clear_run_skill_state +from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._plan_set_preflight import ( - RecipeExecutionAdmissionError, _resolve_plan_set_preflight, ) @@ -72,7 +72,6 @@ __all__ = [ "DefaultInputPreflightResolver", - "RecipeExecutionAdmissionError", "bind_attested_runtime_invocation", "build_bound_child_prompt", "build_recipe_execution_snapshot", diff --git a/src/autoskillit/server/recipe/_recipe_initialization.py b/src/autoskillit/server/recipe/_recipe_initialization.py index 53c1ca7b29..51504efe21 100644 --- a/src/autoskillit/server/recipe/_recipe_initialization.py +++ b/src/autoskillit/server/recipe/_recipe_initialization.py @@ -34,8 +34,8 @@ start_recipe_initialization, ) from autoskillit.server.lifecycle._state import _get_ctx_or_none +from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( - RecipeExecutionAdmissionError, install_recipe_execution, prepare_recipe_execution, ready_recipe_execution_state, diff --git a/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py b/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py index c65997ec7c..d1b2660a08 100644 --- a/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py +++ b/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py @@ -39,8 +39,8 @@ ) from autoskillit.server._tracker_authority import _restore_reserved_tracker_authority from autoskillit.server.lifecycle._guards import _check_dry_walkthrough_plan +from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( - RecipeExecutionAdmissionError, bind_attested_runtime_invocation, build_bound_child_prompt, build_standalone_child_invocation, diff --git a/tests/server/test_attestation_delivery_reachability.py b/tests/server/test_attestation_delivery_reachability.py index f05ded015d..873f8d12d1 100644 --- a/tests/server/test_attestation_delivery_reachability.py +++ b/tests/server/test_attestation_delivery_reachability.py @@ -26,6 +26,7 @@ ) from autoskillit.execution import CODEX_RECIPE_DELIVERY_BUDGET from autoskillit.pipeline import ReadyRecipe +from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_delivery import ( load_recipe_artifact, persist_recipe_artifact, @@ -33,7 +34,6 @@ ) from autoskillit.server.recipe._recipe_delivery_helpers import _attested_render from autoskillit.server.recipe._recipe_execution import ( - RecipeExecutionAdmissionError, bind_attested_runtime_invocation, get_recipe_execution, install_recipe_execution, diff --git a/tests/server/test_attested_admission_replay.py b/tests/server/test_attested_admission_replay.py index e21fb65bbc..2d218bbbd4 100644 --- a/tests/server/test_attested_admission_replay.py +++ b/tests/server/test_attested_admission_replay.py @@ -22,8 +22,8 @@ from autoskillit.core.io import load_yaml from autoskillit.recipe import load_and_validate from autoskillit.recipe.schema import RecipeKind +from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( - RecipeExecutionAdmissionError, bind_attested_runtime_invocation, build_recipe_execution_snapshot, ) diff --git a/tests/server/test_kitchen_lifecycle.py b/tests/server/test_kitchen_lifecycle.py index 5e0b93b209..a9640167fd 100644 --- a/tests/server/test_kitchen_lifecycle.py +++ b/tests/server/test_kitchen_lifecycle.py @@ -355,8 +355,8 @@ async def test_same_campaign_reopen_issues_fresh_recipe_authority( write_initial_state, ) from autoskillit.pipeline import ReadyRecipe + from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( - RecipeExecutionAdmissionError, bind_attested_runtime_invocation, ) from autoskillit.server.tools.tools_kitchen import open_kitchen diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index fe9f358772..7d14763a2c 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -18,9 +18,9 @@ RecipeExecutionId, ) from autoskillit.server._plan_set_materializer import DefaultPlanSetMaterializer +from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._plan_set_preflight import DefaultPlanSetPreflightResolver from autoskillit.server.recipe._recipe_execution import ( - RecipeExecutionAdmissionError, build_bound_child_prompt, resolve_attested_input_preflight, ) diff --git a/tests/server/test_recipe_execution_preflight_list.py b/tests/server/test_recipe_execution_preflight_list.py index 7a43545499..b04ddfc58a 100644 --- a/tests/server/test_recipe_execution_preflight_list.py +++ b/tests/server/test_recipe_execution_preflight_list.py @@ -8,8 +8,8 @@ import pytest from autoskillit.core import AdmissionStatus +from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( - RecipeExecutionAdmissionError, resolve_attested_input_preflight, ) diff --git a/tests/server/test_recipe_initialization.py b/tests/server/test_recipe_initialization.py index 123ea29a81..0b203dfd54 100644 --- a/tests/server/test_recipe_initialization.py +++ b/tests/server/test_recipe_initialization.py @@ -27,8 +27,8 @@ record_initialization_page, ) from autoskillit.server._factory import make_recipe_execution +from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( - RecipeExecutionAdmissionError, build_recipe_execution_snapshot, install_recipe_execution, prepare_recipe_execution, From ffb023c2ef2daf89f081a7d56b2538267418d6b7 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:51:56 -0700 Subject: [PATCH 06/17] docs(review): clarify recipe-only binding lookup --- src/autoskillit/server/_plan_set_materializer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/autoskillit/server/_plan_set_materializer.py b/src/autoskillit/server/_plan_set_materializer.py index 9a1b090f3b..c376dcde6d 100644 --- a/src/autoskillit/server/_plan_set_materializer.py +++ b/src/autoskillit/server/_plan_set_materializer.py @@ -176,6 +176,7 @@ def __init__(self, github_client: GitHubFetcher | None) -> None: def lookup_binding( self, execution_generation: str, authority_path: str ) -> tuple[Path, str] | None: + """Return successful recipe-bind provenance; standalone binds have no record.""" return self._bindings.get((execution_generation, os.path.abspath(authority_path))) async def bind(self, request: PlanSetBindRequest) -> PlanSetBindResult: From 7409f76a4a5066ac21302134c35c8e33c66f3493 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:53:15 -0700 Subject: [PATCH 07/17] docs(review): state invocation root containment role --- src/autoskillit/server/tools/tools_execution/_state.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/autoskillit/server/tools/tools_execution/_state.py b/src/autoskillit/server/tools/tools_execution/_state.py index 0cedf3c405..2bb9b66903 100644 --- a/src/autoskillit/server/tools/tools_execution/_state.py +++ b/src/autoskillit/server/tools/tools_execution/_state.py @@ -190,6 +190,7 @@ class _RunSkillDispatchState: _claims_recipe_execution: bool = False _dynamic_recipe_call: bool = False _audit_output_mode: AuditOutputMode | None = None + # Invocation-cwd temp root used as the audit containment boundary. _invocation_temp_root: Path | None = None _slot_intent_digest: str | None = None _bound_input_map: dict[str, BoundScalar] | None = None From 9ac900775ff3c541e663bfa49c5ea6a16cc1388e Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:54:22 -0700 Subject: [PATCH 08/17] docs(review): explain plan-set admission code namespaces --- src/autoskillit/server/recipe/_plan_set_preflight.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/autoskillit/server/recipe/_plan_set_preflight.py b/src/autoskillit/server/recipe/_plan_set_preflight.py index 628154ad76..4450be721d 100644 --- a/src/autoskillit/server/recipe/_plan_set_preflight.py +++ b/src/autoskillit/server/recipe/_plan_set_preflight.py @@ -34,6 +34,10 @@ def _resolve_plan_set_preflight( template: InvocationTemplate, kind: PreflightKind, ) -> PlanSetPreflightEvidence | None: + """Use recipe_execution_preflight_* for input or service failures. + + Authority and verifier rejections use input_preflight_plan_set_* codes. + """ authority_path = bound_input_map.get("plan_set_authority_path") if authority_path in (None, ""): return None From b10f48a6497944ecab69d77b3db9f200531fae17 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:55:35 -0700 Subject: [PATCH 09/17] docs(review): name the plan-set materializer service consistently --- docs/glossary.md | 6 ++++-- src/autoskillit/core/planset/AGENTS.md | 2 +- .../core/types/protocols/_type_protocols_infra.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/glossary.md b/docs/glossary.md index 410d99c7af..5aa27f5d09 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -14,8 +14,10 @@ lines; aggregate coverage is decided only by the server-side never the artifact itself. The canonical authority digest is an unkeyed integrity hash covering the sealed state; it does not establish server issuance. -For recipe admission, the context-owned materializer retains each successful -bind's root and issued digest for that execution and authority path. Admission +For recipe admission, the `PlanSetMaterializer` service held by `ToolContext` +retains each successful bind's root and issued digest for that execution and +authority path. The default implementation, `DefaultPlanSetMaterializer`, stores +these records in memory. Admission verifies the original path beneath its recorded bind root and compares the verified digest with that issuance record. Audit inputs retain their invocation cwd root; standalone binding retains cwd containment and creates no recipe record. diff --git a/src/autoskillit/core/planset/AGENTS.md b/src/autoskillit/core/planset/AGENTS.md index 5c217a65da..af6d8fd2bc 100644 --- a/src/autoskillit/core/planset/AGENTS.md +++ b/src/autoskillit/core/planset/AGENTS.md @@ -1,5 +1,5 @@ The IL-0 plan-set domain owns deterministic regex-only requirement extraction, allocation parsing, aggregate coverage, and verification; the server owns fetching and persistence. `plan_set_coverage` is an in-process server-side aggregate inspection, not a decision made by a child skill. Unsupported Markdown is recorded as a fail-closed marker, `text_digest` covers exact raw item spans rather than normalized text, and skills never open authority artifacts. Part commands are evidence only: the authority carries the hashed parts and coverage result. Its `state` is included in the canonical payload covered by the unkeyed integrity hash `authority_digest`; admission requires both a matching recomputed digest and `state == sealed`. -Recipe admission also requires server-held issuance provenance: the existing materializer records each successful recipe bind's resolved root and digest by execution ID and authority path. Admission verifies the original caller path under that recorded root, then compares the verified digest with the issued digest. Standalone binds keep cwd-rooted containment and create no recipe record; audit inputs retain their invocation-cwd root. +Recipe admission also requires server-held issuance provenance: the `PlanSetMaterializer` service held by `ToolContext` records each successful recipe bind's resolved root and digest by execution ID and authority path. Its default implementation is `DefaultPlanSetMaterializer`. Admission verifies the original caller path under that recorded root, then compares the verified digest with the issued digest. Standalone binds keep cwd-rooted containment and create no recipe record; audit inputs retain their invocation-cwd root. Records remain in memory for the server process lifetime, including obsolete executions. Reinstalling an execution on the same context preserves them; fresh contexts, including fleet-side contexts, need their own successful recipe bind. This trusts the server process, its records, and the supplied root and its ancestors. The root is a path rather than a retained directory descriptor or bind-time inode identity, so replacing the root or its ancestors can change later resolution. The digest pin does not protect directory identity, and a sibling worktree does not establish OS-level isolation. diff --git a/src/autoskillit/core/types/protocols/_type_protocols_infra.py b/src/autoskillit/core/types/protocols/_type_protocols_infra.py index 6ae4720c63..77cb9db396 100644 --- a/src/autoskillit/core/types/protocols/_type_protocols_infra.py +++ b/src/autoskillit/core/types/protocols/_type_protocols_infra.py @@ -236,7 +236,7 @@ def __call__(self, project_dir: Path) -> frozenset[str]: ... @runtime_checkable class PlanSetMaterializer(Protocol): - """Server-owned plan-set binder and successful recipe-bind provenance lookup.""" + """Context-held plan-set binding and successful recipe-bind provenance service.""" async def bind(self, request: PlanSetBindRequest) -> PlanSetBindResult: ... From 619ae295fe8a6e53d55c2e751148691bc0bebe90 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:56:40 -0700 Subject: [PATCH 10/17] test(review): share dry-walkthrough preflight setup --- tests/server/test_plan_set_preflight.py | 80 +++++++++---------------- 1 file changed, 29 insertions(+), 51 deletions(-) diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index 7d14763a2c..8053f0f9ba 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -139,6 +139,24 @@ async def test_absent_authority_omits_evidence_and_kitchen_error_is_namespaced( assert exc_info.value.code == "input_preflight_plan_set_kitchen_mismatch" +def _plan_preflight(materializer, resolver, bound_inputs): + return resolve_attested_input_preflight( + SimpleNamespace( + kitchen_id="kitchen", + plan_set_materializer=materializer, + skill_contract_resolver=lambda _: SimpleNamespace( + input_preflight=("plan_set_coverage",) + ), + ), + SimpleNamespace(plan_set_preflight_resolver=resolver), + skill_command="/autoskillit:dry-walkthrough", + execution_id="generation", + step_name="verify", + template=SimpleNamespace(invocation=SimpleNamespace(skill_name="dry-walkthrough")), + bound_inputs=bound_inputs, + ) + + @pytest.mark.parametrize("kind", ("symlink", "hardlink")) async def test_recorded_authority_still_rejects_file_links(tmp_path: Path, kind: str) -> None: authority_path, part, materializer = await _authority(tmp_path) @@ -149,23 +167,9 @@ async def test_recorded_authority_still_rejects_file_links(tmp_path: Path, kind: else: os.link(original, path) with pytest.raises(RecipeExecutionAdmissionError) as exc_info: - resolve_attested_input_preflight( - SimpleNamespace( - kitchen_id="kitchen", - plan_set_materializer=materializer, - skill_contract_resolver=lambda _: SimpleNamespace( - input_preflight=("plan_set_coverage",) - ), - ), - SimpleNamespace( - plan_set_preflight_resolver=DefaultPlanSetPreflightResolver( - RecipeExecutionId("generation"), "kitchen" - ) - ), - skill_command="/autoskillit:dry-walkthrough", - execution_id="generation", - step_name="verify", - template=SimpleNamespace(invocation=SimpleNamespace(skill_name="dry-walkthrough")), + _plan_preflight( + materializer, + DefaultPlanSetPreflightResolver(RecipeExecutionId("generation"), "kitchen"), bound_inputs=(("plan_path", str(part)), ("plan_set_authority_path", authority_path)), ) assert exc_info.value.code == f"input_preflight_plan_set_{kind}" @@ -183,26 +187,12 @@ def resolve(_request, *, allowed_root): evidence=SimpleNamespace(plan_set_authority_digest=issued_digest), ) - resolved = resolve_attested_input_preflight( + resolved = _plan_preflight( SimpleNamespace( - kitchen_id="kitchen", - plan_set_materializer=SimpleNamespace( - lookup_binding=lambda execution_id, authority_path: ( - issued_root, - issued_digest, - ) - ), - skill_contract_resolver=lambda _: SimpleNamespace( - input_preflight=("plan_set_coverage",) - ), + lookup_binding=lambda execution_id, authority_path: (issued_root, issued_digest) ), - SimpleNamespace(plan_set_preflight_resolver=SimpleNamespace(resolve=resolve)), - skill_command="/autoskillit:dry-walkthrough", - execution_id="generation", - step_name="verify", - template=SimpleNamespace(invocation=SimpleNamespace(skill_name="dry-walkthrough")), + SimpleNamespace(resolve=resolve), bound_inputs=(("plan_path", "plan.md"), ("plan_set_authority_path", "authority.json")), - allowed_root=None, ) assert resolved.plan_set is not None @@ -212,28 +202,16 @@ def resolve(_request, *, allowed_root): def test_accepted_plan_set_verification_without_evidence_fails_closed(tmp_path: Path) -> None: digest = "sha256:issued" with pytest.raises(RecipeExecutionAdmissionError) as exc_info: - resolve_attested_input_preflight( + _plan_preflight( SimpleNamespace( - kitchen_id="kitchen", - plan_set_materializer=SimpleNamespace( - lookup_binding=lambda execution_id, authority_path: (tmp_path, digest) - ), - skill_contract_resolver=lambda _: SimpleNamespace( - input_preflight=("plan_set_coverage",) - ), + lookup_binding=lambda execution_id, authority_path: (tmp_path, digest) ), SimpleNamespace( - plan_set_preflight_resolver=SimpleNamespace( - resolve=lambda request, *, allowed_root: SimpleNamespace( - accepted=True, - evidence=None, - ) + resolve=lambda request, *, allowed_root: SimpleNamespace( + accepted=True, + evidence=None, ) ), - skill_command="/autoskillit:dry-walkthrough", - execution_id="generation", - step_name="verify", - template=SimpleNamespace(invocation=SimpleNamespace(skill_name="dry-walkthrough")), bound_inputs=( ("plan_path", "plan.md"), ("plan_set_authority_path", "authority.json"), From 45e5b29e415b2af8b335848cc915aaa60e20bd5c Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:57:27 -0700 Subject: [PATCH 11/17] test(review): remove obsolete helper argument --- tests/server/test_plan_set_preflight.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index 8053f0f9ba..17f0994f96 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -216,7 +216,6 @@ def test_accepted_plan_set_verification_without_evidence_fails_closed(tmp_path: ("plan_path", "plan.md"), ("plan_set_authority_path", "authority.json"), ), - allowed_root=None, ) assert exc_info.value.code == "recipe_execution_preflight_unavailable" From 25aa3b6b3f75b377ebc3d9f4791297fdc0af5489 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:58:28 -0700 Subject: [PATCH 12/17] test(review): reuse implementation fixture parameters --- .../test_plan_set_preflight_implement.py | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/server/test_plan_set_preflight_implement.py b/tests/server/test_plan_set_preflight_implement.py index d53ab6c90f..305897e4e0 100644 --- a/tests/server/test_plan_set_preflight_implement.py +++ b/tests/server/test_plan_set_preflight_implement.py @@ -37,6 +37,12 @@ pytestmark = [pytest.mark.layer("server"), pytest.mark.anyio, pytest.mark.medium] +_IMPLEMENTATION_READY_CASE = ( + "implementation", + "implement", + {"issue_url": "https://github.com/TalonT-Org/AutoSkillit/issues/4261", "task": "test"}, +) + async def _bind( root: Path, @@ -280,13 +286,7 @@ async def unexpected_bind(_request: object) -> None: @pytest.mark.parametrize( "tool_ctx_ready_recipe", - [ - ( - "implementation", - "implement", - {"issue_url": "https://github.com/TalonT-Org/AutoSkillit/issues/4261", "task": "test"}, - ) - ], + [_IMPLEMENTATION_READY_CASE], indirect=True, ) async def test_clone_authority_admits_implement_and_retry_from_fresh_sibling_worktree( @@ -408,13 +408,7 @@ async def test_clone_authority_admits_implement_and_retry_from_fresh_sibling_wor @pytest.mark.parametrize("case", ["unissued", "rewritten", "other_execution"]) @pytest.mark.parametrize( "tool_ctx_ready_recipe", - [ - ( - "implementation", - "implement", - {"issue_url": "https://github.com/TalonT-Org/AutoSkillit/issues/4261", "task": "test"}, - ) - ], + [_IMPLEMENTATION_READY_CASE], indirect=True, ) async def test_attested_implementation_rejects_untrusted_authority_provenance( From 4a23f6b2a16945a7b8132daf427ab8b7f6148522 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:59:13 -0700 Subject: [PATCH 13/17] test(review): cover issued authority digest mismatch directly --- tests/server/test_plan_set_preflight.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index 17f0994f96..b0c453b022 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -221,6 +221,26 @@ def test_accepted_plan_set_verification_without_evidence_fails_closed(tmp_path: assert exc_info.value.code == "recipe_execution_preflight_unavailable" +def test_accepted_plan_set_digest_must_match_issued_digest(tmp_path: Path) -> None: + with pytest.raises(RecipeExecutionAdmissionError) as exc_info: + _plan_preflight( + SimpleNamespace( + lookup_binding=lambda execution_id, authority_path: (tmp_path, "sha256:issued") + ), + SimpleNamespace( + resolve=lambda request, *, allowed_root: SimpleNamespace( + accepted=True, + evidence=SimpleNamespace(plan_set_authority_digest="sha256:different"), + ) + ), + bound_inputs=( + ("plan_path", "plan.md"), + ("plan_set_authority_path", "authority.json"), + ), + ) + assert exc_info.value.code == "input_preflight_plan_set_authority_digest" + + async def _publication_authority(tmp_path: Path, *, sealed: bool = True): from tests.server._plan_set_test_helpers import PlanSetGitHub From a453008551cdb1dcd2c0349f4ef7d0a17be2f301 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 10:59:56 -0700 Subject: [PATCH 14/17] test(review): assert the admission error code in its error field --- tests/server/test_plan_set_preflight_implement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/server/test_plan_set_preflight_implement.py b/tests/server/test_plan_set_preflight_implement.py index 305897e4e0..e1fe513cdc 100644 --- a/tests/server/test_plan_set_preflight_implement.py +++ b/tests/server/test_plan_set_preflight_implement.py @@ -491,7 +491,7 @@ async def test_attested_implementation_rejects_untrusted_authority_provenance( ) ) ) - assert expected_code in json.dumps(response) + assert response["error"].startswith(f"RECIPE EXECUTION REJECTED [{expected_code}]:") assert executor.calls == [] From d5c623ab034fe018ab63058ed78f28fa2ae2ebe9 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 11:00:49 -0700 Subject: [PATCH 15/17] test(review): verify execution-scoped authority lookup arguments --- tests/server/test_plan_set_preflight.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index b0c453b022..bc393576af 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -179,6 +179,11 @@ def test_plan_only_preflight_uses_issued_root_without_invocation_root(tmp_path: issued_root = tmp_path / "producer" issued_digest = "sha256:issued" seen_roots: list[Path] = [] + seen_lookups: list[tuple[str, str]] = [] + + def lookup_binding(execution_id, authority_path): + seen_lookups.append((execution_id, authority_path)) + return issued_root, issued_digest def resolve(_request, *, allowed_root): seen_roots.append(allowed_root) @@ -188,15 +193,14 @@ def resolve(_request, *, allowed_root): ) resolved = _plan_preflight( - SimpleNamespace( - lookup_binding=lambda execution_id, authority_path: (issued_root, issued_digest) - ), + SimpleNamespace(lookup_binding=lookup_binding), SimpleNamespace(resolve=resolve), bound_inputs=(("plan_path", "plan.md"), ("plan_set_authority_path", "authority.json")), ) assert resolved.plan_set is not None assert seen_roots == [issued_root] + assert seen_lookups == [("generation", "authority.json")] def test_accepted_plan_set_verification_without_evidence_fails_closed(tmp_path: Path) -> None: From cb90cff133896501c89346351ec3112c51a564b1 Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 11:01:31 -0700 Subject: [PATCH 16/17] test(review): cover missing plan-set materializer admission --- tests/server/test_plan_set_preflight.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index bc393576af..dc21469ef3 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -275,7 +275,7 @@ async def _publication_authority(tmp_path: Path, *, sealed: bool = True): def _audit_preflight( tmp_path, path, - materializer=None, + materializer, *, kitchen="kitchen", generation="generation", @@ -339,7 +339,13 @@ async def test_audit_scope_has_stage_outcomes_while_implementer_scope_has_only_c def test_audit_without_authority_preserves_existing_scope(tmp_path): - assert _audit_preflight(tmp_path, "").plan_set is None + assert _audit_preflight(tmp_path, "", None).plan_set is None + + +def test_audit_with_authority_requires_materializer(tmp_path): + with pytest.raises(RecipeExecutionAdmissionError) as exc_info: + _audit_preflight(tmp_path, "authority.json", None) + assert exc_info.value.code == "recipe_execution_preflight_unavailable" @pytest.mark.parametrize( From 95900c3f58d73ce2213954ce496ca5f2c0b6585b Mon Sep 17 00:00:00 2001 From: Trecek Date: Mon, 26 Oct 2026 11:19:27 -0700 Subject: [PATCH 17/17] fix(review): keep shared admission errors within package layout limits --- .../server/{recipe/_admission.py => _recipe_admission.py} | 2 +- src/autoskillit/server/recipe/_plan_set_preflight.py | 2 +- src/autoskillit/server/recipe/_recipe_execution.py | 2 +- src/autoskillit/server/recipe/_recipe_initialization.py | 2 +- .../server/tools/tools_execution/_run_skill_admission.py | 2 +- tests/server/test_attestation_delivery_reachability.py | 2 +- tests/server/test_attested_admission_replay.py | 2 +- tests/server/test_kitchen_lifecycle.py | 2 +- tests/server/test_plan_set_preflight.py | 2 +- tests/server/test_recipe_execution_preflight_list.py | 2 +- tests/server/test_recipe_initialization.py | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) rename src/autoskillit/server/{recipe/_admission.py => _recipe_admission.py} (73%) diff --git a/src/autoskillit/server/recipe/_admission.py b/src/autoskillit/server/_recipe_admission.py similarity index 73% rename from src/autoskillit/server/recipe/_admission.py rename to src/autoskillit/server/_recipe_admission.py index beb123e494..c89cbd1134 100644 --- a/src/autoskillit/server/recipe/_admission.py +++ b/src/autoskillit/server/_recipe_admission.py @@ -1,4 +1,4 @@ -"""Shared recipe execution admission failures.""" +"""Recipe execution admission failures shared by server recipe and tool code.""" class RecipeExecutionAdmissionError(RuntimeError): diff --git a/src/autoskillit/server/recipe/_plan_set_preflight.py b/src/autoskillit/server/recipe/_plan_set_preflight.py index 4450be721d..4f90f248e3 100644 --- a/src/autoskillit/server/recipe/_plan_set_preflight.py +++ b/src/autoskillit/server/recipe/_plan_set_preflight.py @@ -19,7 +19,7 @@ RecipeExecutionId, verify_plan_set_authority, ) -from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError +from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError if TYPE_CHECKING: from autoskillit.pipeline import ToolContext diff --git a/src/autoskillit/server/recipe/_recipe_execution.py b/src/autoskillit/server/recipe/_recipe_execution.py index f32bd469d3..017b287a2d 100644 --- a/src/autoskillit/server/recipe/_recipe_execution.py +++ b/src/autoskillit/server/recipe/_recipe_execution.py @@ -54,7 +54,7 @@ compute_skill_contract_identity, ) from autoskillit.server._misc import clear_run_skill_state -from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError +from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._plan_set_preflight import ( _resolve_plan_set_preflight, ) diff --git a/src/autoskillit/server/recipe/_recipe_initialization.py b/src/autoskillit/server/recipe/_recipe_initialization.py index 51504efe21..39fec4cfb5 100644 --- a/src/autoskillit/server/recipe/_recipe_initialization.py +++ b/src/autoskillit/server/recipe/_recipe_initialization.py @@ -33,8 +33,8 @@ record_initialization_page, start_recipe_initialization, ) +from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError from autoskillit.server.lifecycle._state import _get_ctx_or_none -from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( install_recipe_execution, prepare_recipe_execution, diff --git a/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py b/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py index d1b2660a08..9f97fd5f89 100644 --- a/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py +++ b/src/autoskillit/server/tools/tools_execution/_run_skill_admission.py @@ -37,9 +37,9 @@ load_current_prior_authority, normalize_audited_plan_refs, ) +from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError from autoskillit.server._tracker_authority import _restore_reserved_tracker_authority from autoskillit.server.lifecycle._guards import _check_dry_walkthrough_plan -from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( bind_attested_runtime_invocation, build_bound_child_prompt, diff --git a/tests/server/test_attestation_delivery_reachability.py b/tests/server/test_attestation_delivery_reachability.py index 873f8d12d1..c19f8f3c17 100644 --- a/tests/server/test_attestation_delivery_reachability.py +++ b/tests/server/test_attestation_delivery_reachability.py @@ -26,7 +26,7 @@ ) from autoskillit.execution import CODEX_RECIPE_DELIVERY_BUDGET from autoskillit.pipeline import ReadyRecipe -from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError +from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_delivery import ( load_recipe_artifact, persist_recipe_artifact, diff --git a/tests/server/test_attested_admission_replay.py b/tests/server/test_attested_admission_replay.py index 2d218bbbd4..447db29960 100644 --- a/tests/server/test_attested_admission_replay.py +++ b/tests/server/test_attested_admission_replay.py @@ -22,7 +22,7 @@ from autoskillit.core.io import load_yaml from autoskillit.recipe import load_and_validate from autoskillit.recipe.schema import RecipeKind -from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError +from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( bind_attested_runtime_invocation, build_recipe_execution_snapshot, diff --git a/tests/server/test_kitchen_lifecycle.py b/tests/server/test_kitchen_lifecycle.py index a9640167fd..a13fb93d09 100644 --- a/tests/server/test_kitchen_lifecycle.py +++ b/tests/server/test_kitchen_lifecycle.py @@ -355,7 +355,7 @@ async def test_same_campaign_reopen_issues_fresh_recipe_authority( write_initial_state, ) from autoskillit.pipeline import ReadyRecipe - from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError + from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( bind_attested_runtime_invocation, ) diff --git a/tests/server/test_plan_set_preflight.py b/tests/server/test_plan_set_preflight.py index dc21469ef3..32d1408a9b 100644 --- a/tests/server/test_plan_set_preflight.py +++ b/tests/server/test_plan_set_preflight.py @@ -18,7 +18,7 @@ RecipeExecutionId, ) from autoskillit.server._plan_set_materializer import DefaultPlanSetMaterializer -from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError +from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._plan_set_preflight import DefaultPlanSetPreflightResolver from autoskillit.server.recipe._recipe_execution import ( build_bound_child_prompt, diff --git a/tests/server/test_recipe_execution_preflight_list.py b/tests/server/test_recipe_execution_preflight_list.py index b04ddfc58a..c78363e0ae 100644 --- a/tests/server/test_recipe_execution_preflight_list.py +++ b/tests/server/test_recipe_execution_preflight_list.py @@ -8,7 +8,7 @@ import pytest from autoskillit.core import AdmissionStatus -from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError +from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( resolve_attested_input_preflight, ) diff --git a/tests/server/test_recipe_initialization.py b/tests/server/test_recipe_initialization.py index 0b203dfd54..7c004e04a2 100644 --- a/tests/server/test_recipe_initialization.py +++ b/tests/server/test_recipe_initialization.py @@ -27,7 +27,7 @@ record_initialization_page, ) from autoskillit.server._factory import make_recipe_execution -from autoskillit.server.recipe._admission import RecipeExecutionAdmissionError +from autoskillit.server._recipe_admission import RecipeExecutionAdmissionError from autoskillit.server.recipe._recipe_execution import ( build_recipe_execution_snapshot, install_recipe_execution,