Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/recipes/composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ declared `on_success` continuation.
When the gate ingredient is `"true"`, the sub-recipe's steps are **merged inline** at
the attachment point, with step names prefixed to avoid collisions. The sub-recipe's
kitchen rules are merged with the parent's kitchen rules.
When names are prefixed, a composed step's key and its `with.step_name` are prefixed
together.
Incoming routes and the ordered entry attachment target the first prefixed child
step. This gate rewrite is separate from optional-step pruning and does not use
`on_skip` as a runtime event.
Expand Down
10 changes: 7 additions & 3 deletions src/autoskillit/core/_tool_registry_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ def _tool(
param,
wire_type=declared_wire_types.get(param, ToolWireType.SCALAR),
required=param in required_set,
role=declared_roles.get(param, ToolParamRole.CHILD_INPUT),
role=declared_roles.get(
param,
ToolParamRole.STEP_IDENTITY
if param == "step_name"
else ToolParamRole.CHILD_INPUT,
),
)
for param in params
),
Expand Down Expand Up @@ -301,7 +306,6 @@ def _verify_review_receipt() -> ToolDef:
"post_state": ToolWireType.STRING,
"step_name": ToolWireType.STRING,
},
roles={"step_name": ToolParamRole.PROTOCOL},
recovery_recipe_delivery=True,
)

Expand All @@ -315,7 +319,7 @@ def _verify_review_receipt() -> ToolDef:
"skill_command": ToolParamRole.CHILD_INPUT,
"cwd": ToolParamRole.CHILD_INPUT,
"model": ToolParamRole.EXECUTION_TUNING,
"step_name": ToolParamRole.PROTOCOL,
"step_name": ToolParamRole.STEP_IDENTITY,
"recipe_execution_id": ToolParamRole.PROTOCOL,
"invocation_template_digest": ToolParamRole.PROTOCOL,
"step_provider": ToolParamRole.EXECUTION_TUNING,
Expand Down
7 changes: 6 additions & 1 deletion src/autoskillit/core/tool_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,12 @@ def food_truck_visibility_tags(packs: Collection[str] | None) -> tuple[str, ...]
wire_types={"offset": ToolWireType.INTEGER, "page_size": ToolWireType.INTEGER},
),
_tool("reload_session"),
_tool("record_pipeline_step", ("pipeline_id", "op", "dependencies", "step_name")),
# step_name identifies the tracked target step being marked.
_tool(
"record_pipeline_step",
("pipeline_id", "op", "dependencies", "step_name"),
roles={"step_name": ToolParamRole.CHILD_INPUT},
),
_tool("get_pr_reviews", ("pr_number", "cwd", "repo"), required=("pr_number", "cwd")),
_verify_review_receipt(),
_tool(
Expand Down
24 changes: 13 additions & 11 deletions src/autoskillit/core/types/recipe/_type_recipe_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,16 @@ class ToolInitializationOperation(StrEnum):


class ToolParamRole(StrEnum):
"""The classification authority for what a tool parameter is for.

The runtime gate's always-admit set and ``RecipeStep`` execution-tuning
fallback obligations derive from this field; kwarg membership comes
from ``ToolDef.mcp_kwarg_names``. The
per-role runtime-admission *policy* is declared once, alongside this
enum, in ``RUNTIME_ADMISSION_BY_ROLE`` — see ``runtime_exempt_param_names``
(core/tool_registry.py) and ``bind_runtime_skill_invocation``
(recipe/_binding.py) for its consumers.
"""Parameter purposes governing runtime admission and RecipeStep tuning.
MCP membership comes from ToolDef.mcp_kwarg_names; admission policy lives
in RUNTIME_ADMISSION_BY_ROLE, consumed by runtime_exempt_param_names.
"""

PROTOCOL = "protocol"
"""Attestation identity (step_name, recipe_execution_id, invocation_template_digest);
always admitted."""
"""Attestation credentials and step guard values; always admitted."""

STEP_IDENTITY = "step_identity"
"""The invoking step's YAML key; declared values must match; always admitted."""

CHILD_INPUT = "child_input"
"""Child-skill inputs; admitted iff with:-compiled."""
Expand All @@ -128,6 +124,7 @@ class RuntimeAdmission(StrEnum):
RUNTIME_ADMISSION_BY_ROLE: Mapping[ToolParamRole, RuntimeAdmission] = MappingProxyType(
{
ToolParamRole.PROTOCOL: RuntimeAdmission.ALWAYS,
ToolParamRole.STEP_IDENTITY: RuntimeAdmission.ALWAYS,
ToolParamRole.ORCHESTRATOR_SCOPING: RuntimeAdmission.ALWAYS,
ToolParamRole.CHILD_INPUT: RuntimeAdmission.WITH_DECLARED_ONLY,
ToolParamRole.EXECUTION_TUNING: RuntimeAdmission.WITH_DECLARED_ONLY,
Expand Down Expand Up @@ -251,6 +248,11 @@ def _validate_recipe_delivery_outcome(self) -> None:
def param_names(self) -> tuple[str, ...]:
return tuple(param.name for param in self.params)

@property
def step_identity_params(self) -> tuple[ToolParamDef, ...]:
"""Parameters carrying the invoking recipe step's YAML key."""
return tuple(param for param in self.params if param.role is ToolParamRole.STEP_IDENTITY)

@property
def param_set(self) -> frozenset[str]:
return frozenset(self.param_names)
Expand Down
28 changes: 28 additions & 0 deletions src/autoskillit/migrations/0.10.1288-to-0.10.1291.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from_version: "0.10.1288"
to_version: "0.10.1291"
description: Require each recipe step's with.step_name to match its YAML key.
changes:
- id: step-name-equals-step-key
description: |
Per-variant model.step_overrides and providers.* pins now match
analyze_pipeline_health_* variants by their own YAML keys (#4706).
Recipe declarations on telemetry-only tools also require the invoking
YAML key; free-form cross-step grouping labels are not valid
with.step_name values. Distinct analyze_pipeline_health_* keys now use
separate token and timing rows, so the former family-level aggregation
is lost; no additional label parameter is introduced.
instruction: |
Every with.step_name on a recipe step (any tool except record_pipeline_step)
must equal that step's YAML key; set it to the key or remove it.
example_before: |
steps:
decompose_phases:
tool: run_skill
with:
step_name: decompose
example_after: |
steps:
decompose_phases:
tool: run_skill
with:
step_name: decompose_phases
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from autoskillit.recipe.ingredients._recipe_raw_repair import _resolve_skip_guards_in_content
from autoskillit.recipe.registry import RuleFinding as _RuleFinding
from autoskillit.recipe.rules.rules_plan_set_gate import STAGE_OBLIGATION_GATE_DOMINANCE_RULE
from autoskillit.recipe.rules.rules_tools import STEP_IDENTITY_MISMATCH_RULE
from autoskillit.recipe.schema import Recipe, RecipeStep

__all__ = ["_record_pipeline_error", "_run_validation_pipeline"]
Expand Down Expand Up @@ -84,21 +85,24 @@ def _reconcile_semantic_findings(
message=finding.message,
)

gate_skip_findings = [
retained_pre_prune_findings = [
finding
for finding in pre_prune_findings
if finding.rule == STAGE_OBLIGATION_GATE_DOMINANCE_RULE
and "cannot declare skip_when_false" in finding.message
if finding.rule == STEP_IDENTITY_MISMATCH_RULE
or (
finding.rule == STAGE_OBLIGATION_GATE_DOMINANCE_RULE
and "cannot declare skip_when_false" in finding.message
)
]
retained_keys = {
(finding.rule, finding.step_name, finding.message) for finding in semantic_findings
}
semantic_findings.extend(
finding
for finding in gate_skip_findings
for finding in retained_pre_prune_findings
if (finding.rule, finding.step_name, finding.message) not in retained_keys
)
if gate_skip_findings:
if retained_pre_prune_findings:
semantic_suggestions = _orch.findings_to_dicts(semantic_findings)

if recipe_name in (suppressed or ()):
Expand Down
18 changes: 18 additions & 0 deletions src/autoskillit/recipe/ingredients/_recipe_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
SKILL_TOOLS,
RecipeFlowEdge,
YAMLError,
get_tool_def,
load_yaml,
)
from autoskillit.core import (
Expand Down Expand Up @@ -380,6 +381,23 @@ def rewrite(target: str | None) -> str | None:
)


def _rekey_composed_step(
step: RecipeStep, old_key: str, new_key: str, redirects: dict[str, str]
) -> RecipeStep:
rewritten = _rewrite_step_routes(step, redirects)
with_args = dict(rewritten.with_args)
declared_with_args = dict(rewritten.declared_with_args or {})
tool_def = get_tool_def(step.tool) if step.tool else None
if tool_def is not None:
for param in tool_def.step_identity_params:
for args in (with_args, declared_with_args):
if args.get(param.name) == old_key:
args[param.name] = new_key
return dataclasses.replace(
rewritten, name=new_key, with_args=with_args, declared_with_args=declared_with_args
)


def _resolve_skip_redirects(
steps: dict[str, RecipeStep], resolutions: dict[str, bool | None]
) -> dict[str, str]:
Expand Down
6 changes: 5 additions & 1 deletion src/autoskillit/recipe/ingredients/_recipe_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def _merge_sub_recipe(parent: Any, placeholder_name: str, sub: Any) -> Any:
Algorithm:
1. Compute a safe name prefix from the sub-recipe name.
2. For each step in sub, create a prefixed copy with routing fixed:
- Key, name and invoking-step identity parameter are prefixed together
- Routes to "done" → parent placeholder's on_success
- Routes to "escalate" → parent placeholder's on_failure
- Routes to other sub-recipe step names → add prefix
Expand All @@ -44,6 +45,7 @@ def _merge_sub_recipe(parent: Any, placeholder_name: str, sub: Any) -> Any:
"""
# Lazy import to break the ``_recipe_composition`` ↔ ``_recipe_merge`` cycle.
from autoskillit.recipe.ingredients._recipe_composition import (
_rekey_composed_step,
_rewrite_step_routes,
)

Expand All @@ -69,7 +71,9 @@ def _merge_sub_recipe(parent: Any, placeholder_name: str, sub: Any) -> Any:
prefixed_steps: dict[str, Any] = {}
for sub_step_name, sub_step in sub.steps.items():
new_name = prefix + sub_step_name
prefixed_steps[new_name] = _rewrite_step_routes(sub_step, redirects)
prefixed_steps[new_name] = _rekey_composed_step(
sub_step, sub_step_name, new_name, redirects
)

# Assemble new steps dict: sub-recipe steps injected in place of placeholder
new_steps: dict[str, Any] = {}
Expand Down
34 changes: 34 additions & 0 deletions src/autoskillit/recipe/rules/rules_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
logger = get_logger(__name__)

_ALL_TOOLS: frozenset[str] = frozenset(TOOL_REGISTRY)
STEP_IDENTITY_MISMATCH_RULE = "step-identity-mismatch"

# Registry of context variables that are captured upstream and MUST be forwarded
# to any tool step that accepts them. Each entry maps a tool name to the set of
Expand Down Expand Up @@ -203,6 +204,39 @@ def _check_dead_with_params(ctx: ValidationContext) -> list[RuleFinding]:
return findings


@semantic_rule(
name=STEP_IDENTITY_MISMATCH_RULE,
description="A step's with: identity parameter must equal its YAML step key",
severity=Severity.ERROR,
)
def _check_step_identity(ctx: ValidationContext) -> list[RuleFinding]:
findings: list[RuleFinding] = []
for key, step in ctx.recipe.steps.items():
tool_def = get_tool_def(step.tool) if step.tool else None
if tool_def is None:
continue
for param in tool_def.step_identity_params:
mismatches = [
f"{name}[{param.name!r}]={args[param.name]!r}"
for name, args in (
("with_args", step.with_args),
("declared_with_args", step.declared_with_args or {}),
)
if args.get(param.name, key) != key
]
if mismatches:
findings.append(
make_finding(
rule_name=STEP_IDENTITY_MISMATCH_RULE,
step_name=key,
message=f"step '{key}': {'; '.join(mismatches)} must equal "
f"the YAML step key '{key}'",
remedy="set with.step_name to the step's YAML key, or remove it",
)
)
return findings


@semantic_rule(
name="rebase-then-push-requires-force",
description=(
Expand Down
2 changes: 1 addition & 1 deletion src/autoskillit/recipes/diagrams/implementation-groups.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- autoskillit-recipe-hash: sha256:7dc92fbbc92dea21f5f370bf6b1183689f0fba1a63b56e6f7e277e3605525311 -->
<!-- autoskillit-recipe-hash: sha256:d12be083522e9a8562d18d6af3a87445d22e8fb4a7ba5218f4cfa987ecbd7602 -->
<!-- autoskillit-diagram-format: v7 -->
## implementation-groups

Expand Down
2 changes: 1 addition & 1 deletion src/autoskillit/recipes/diagrams/implementation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- autoskillit-recipe-hash: sha256:842360fb4a0abd1c55e01e91abb6270353ea8c122bf18eb88e73b8bc5435c43b -->
<!-- autoskillit-recipe-hash: sha256:6f4126255fa60dbfe82b0a047b5467378249668da3c0986bb3071fe82df27dfc -->
<!-- autoskillit-diagram-format: v7 -->
## implementation

Expand Down
2 changes: 1 addition & 1 deletion src/autoskillit/recipes/diagrams/merge-prs.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- autoskillit-recipe-hash: sha256:41e46ff502e0a7b7f35e7ef9f8a77c7d5a3f0a7f5859384b1380a7d3734b6227 -->
<!-- autoskillit-recipe-hash: sha256:ec3b13fe1f2f2b9c252f0aab2a42cd3a8586d10b2fc4e7494ae81bf1d778832e -->
<!-- autoskillit-diagram-format: v7 -->
## merge-prs
Merge multiple PRs into an integration branch with conflict resolution and CI gates.
Expand Down
2 changes: 1 addition & 1 deletion src/autoskillit/recipes/diagrams/remediation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- autoskillit-recipe-hash: sha256:ce746f1fb6e24780bbd5415063b5ed93da47d974acf92cac77e84fe7e86659dc -->
<!-- autoskillit-recipe-hash: sha256:fe72de8859984febee90ea408fed20d7acdd4ab0c45f744227dc99ad561a5a78 -->
<!-- autoskillit-diagram-format: v7 -->
## remediation

Expand Down
10 changes: 5 additions & 5 deletions src/autoskillit/recipes/implementation-groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"source_dir": "${{ inputs.source_dir }}",
"run_name": "${{ inputs.run_name }}",
"base_branch": "${{ inputs.base_branch }}",
"step_name": "bootstrap_clone"
"step_name": "clone"
},
"capture": {
"work_dir": "${{ result.work_dir }}",
Expand Down Expand Up @@ -191,7 +191,7 @@
"issue_number": "${{ context.issue_number }}",
"work_dir": "${{ context.work_dir }}",
"remote_url": "${{ context.remote_url }}",
"step_name": "create_and_publish_branch"
"step_name": "create_and_publish"
},
"capture": {
"merge_target": "${{ result.merge_target }}"
Expand Down Expand Up @@ -2209,7 +2209,7 @@
"diagnostics_log_dir": "${{ inputs.diagnostics_log_dir }}"
},
"cwd": "${{ context.work_dir }}",
"step_name": "analyze_pipeline_health"
"step_name": "analyze_pipeline_health_no_ci"
},
"on_success": "escalate_stop_no_ci",
"on_failure": "escalate_stop_no_ci",
Expand Down Expand Up @@ -3237,7 +3237,7 @@
"diagnostics_log_dir": "${{ inputs.diagnostics_log_dir }}"
},
"cwd": "${{ context.work_dir }}",
"step_name": "analyze_pipeline_health"
"step_name": "analyze_pipeline_health_unconfirmed"
},
"on_success": "done_unconfirmed",
"on_failure": "done_unconfirmed",
Expand Down Expand Up @@ -3449,7 +3449,7 @@
"diagnostics_log_dir": "${{ inputs.diagnostics_log_dir }}"
},
"cwd": "${{ context.work_dir }}",
"step_name": "analyze_pipeline_health"
"step_name": "analyze_pipeline_health_error"
},
"on_success": "escalate_stop",
"on_failure": "escalate_stop",
Expand Down
10 changes: 5 additions & 5 deletions src/autoskillit/recipes/implementation-groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ steps:
source_dir: ${{ inputs.source_dir }}
run_name: ${{ inputs.run_name }}
base_branch: ${{ inputs.base_branch }}
step_name: bootstrap_clone
step_name: clone
capture:
work_dir: ${{ result.work_dir }}
remote_url: ${{ result.remote_url }}
Expand Down Expand Up @@ -191,7 +191,7 @@ steps:
issue_number: ${{ context.issue_number }}
work_dir: ${{ context.work_dir }}
remote_url: ${{ context.remote_url }}
step_name: create_and_publish_branch
step_name: create_and_publish
capture:
merge_target: ${{ result.merge_target }}
on_success: group
Expand Down Expand Up @@ -1851,7 +1851,7 @@ steps:
dispatch_id: ${{ inputs.dispatch_id }}
diagnostics_log_dir: ${{ inputs.diagnostics_log_dir }}
cwd: ${{ context.work_dir }}
step_name: analyze_pipeline_health
step_name: analyze_pipeline_health_no_ci
on_success: escalate_stop_no_ci
on_failure: escalate_stop_no_ci
on_context_limit: escalate_stop_no_ci
Expand Down Expand Up @@ -2711,7 +2711,7 @@ steps:
dispatch_id: ${{ inputs.dispatch_id }}
diagnostics_log_dir: ${{ inputs.diagnostics_log_dir }}
cwd: ${{ context.work_dir }}
step_name: analyze_pipeline_health
step_name: analyze_pipeline_health_unconfirmed
on_success: done_unconfirmed
on_failure: done_unconfirmed
on_context_limit: done_unconfirmed
Expand Down Expand Up @@ -2920,7 +2920,7 @@ steps:
dispatch_id: ${{ inputs.dispatch_id }}
diagnostics_log_dir: ${{ inputs.diagnostics_log_dir }}
cwd: ${{ context.work_dir }}
step_name: analyze_pipeline_health
step_name: analyze_pipeline_health_error
on_success: escalate_stop
on_failure: escalate_stop
on_context_limit: escalate_stop
Expand Down
Loading
Loading