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: 1 addition & 1 deletion docs/execution/tool-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ tag abbreviations are defined in the glossary above.
| `finalize_review_audit` | AS, K, HL, KC | `server/tools/tools_review_audit/_handlers.py` |
| `post_pr_review` | AS, HL, GH | `server/tools/tools_pr_ops.py` |
| `delegate_evidence_reader` | AS, K, HL, KC | `server/tools/tools_evidence_reader.py` |
| `inspect_session_logs` | AS, K, HL, KC | `server/tools/tools_session_logs.py` |

### AUTHENTICATED EVIDENCE READER

Expand Down Expand Up @@ -284,7 +285,6 @@ batch, assignment, source artifact, and digest.
| `write_telemetry_files` | AS, K, KC, TL | `server/tools/tools_status.py` |
| `read_db` | AS, K, KC | `server/tools/tools_status.py` |
| `analyze_tool_sequences` | AS, K, KC, TL | `server/tools/tools_status.py` |
| `inspect_session_logs` | AS, K, KC | `server/tools/tools_session_logs.py` |

### KITCHEN — Recipes

Expand Down
22 changes: 12 additions & 10 deletions docs/recipes/authoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,18 @@ contract card. The Haiku verdict is one of `FRESH`, `STALE`, or `UNCERTAIN`;

When a recipe declares an `autoskillit_version` older than the running
package, the migration engine in `migration/engine.py` walks the migration
notes under `src/autoskillit/migrations/` and applies them in order. Each
note is a 7-step sequence:

1. Read current YAML.
2. Validate it parses.
3. Apply the note's transformer.
4. Validate the transformed YAML.
5. Diff old vs new.
6. Write the new YAML atomically.
7. Record the new `autoskillit_version`.
notes under `src/autoskillit/migrations/` and applies them in order:

1. The service selects the applicable migration notes.
2. It launches the `migrate-recipes` headless skill once.
3. The host requires the expected output file and the target `autoskillit_version` stamp.
4. The host validates the candidate with the same `validate_from_path` entry and configured
temp placeholder as the `validate_recipe` tool. Candidate structure, semantics, contracts,
and binding projection are compared by full finding identity against the original recipe,
while contract lookup remains anchored beside the original. Validator and metadata
exceptions fail normally; if original validation raised, the candidate must be fully valid.
5. The engine writes the accepted candidate atomically and retains a `.yaml.bak` backup.
6. The service clears a prior failure on success or records the rejected migration.

Failures are recorded in `migration/store.py:FailureStore` (atomic JSON
writes) so the next `autoskillit migrate` run can resume.
4 changes: 2 additions & 2 deletions docs/skills/visibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ validated before session initialization or filesystem writes.

The selected canonical documents are then projected into an exact, content-keyed
plugin artifact. Machine-only authority (`uses_capabilities`, `execution_role`,
`activate_deps`, and retired `backend_requirements`) stays in AutoSkillit's private
contract and is omitted from every model-facing `SKILL.md`. Claude Code receives the
`activate_deps`, `interactive_only`, and retired `backend_requirements`) stays in
AutoSkillit's private contract and is omitted from every model-facing `SKILL.md`. Claude Code receives the
sanitized projection through the same launch binding whose shared descriptor reaches
the child, rather than a raw `skills_extended/` directory. Exact
ORCHESTRATOR-role entries such as `process-issues` remain excluded from the L1 catalog,
Expand Down
6 changes: 0 additions & 6 deletions src/autoskillit/core/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,17 @@ from .audit.audit_cycle_verifier import VerifiedAuditCycle as VerifiedAuditCycle
from .audit.audit_semantic_codec import PRESCRIPTIVE_MECHANISM_CUES as PRESCRIPTIVE_MECHANISM_CUES
from .audit.audit_semantic_codec import SUBSTITUTION_MARKERS as SUBSTITUTION_MARKERS
from .audit.audit_semantic_codec import AuditSemanticCodecError as AuditSemanticCodecError
from .audit.audit_semantic_codec import ProbedRequirement as ProbedRequirement
from .audit.audit_semantic_codec import SubstitutionFinding as SubstitutionFinding
from .audit.audit_semantic_codec import SubstitutionTrigger as SubstitutionTrigger
from .audit.audit_semantic_codec import (
canonical_full_reference_records_match as canonical_full_reference_records_match,
)
from .audit.audit_semantic_codec import (
evaluate_diff_mock_of_prescribed_symbol as evaluate_diff_mock_of_prescribed_symbol,
)
from .audit.audit_semantic_codec import (
evaluate_rationale_contradiction as evaluate_rationale_contradiction,
)
from .audit.audit_semantic_codec import load_audit_semantic_result as load_audit_semantic_result
from .audit.audit_semantic_codec import (
load_standalone_audit_evidence as load_standalone_audit_evidence,
)
from .audit.audit_semantic_codec import probe_substitutions as probe_substitutions
from .audit.closure_hashing import HASH_RE as HASH_RE
from .audit.closure_hashing import canonical_json_bytes as canonical_json_bytes
from .audit.closure_hashing import compute_bytes_hash as compute_bytes_hash
Expand Down
8 changes: 0 additions & 8 deletions src/autoskillit/core/audit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,11 @@
PRESCRIPTIVE_MECHANISM_CUES,
SUBSTITUTION_MARKERS,
AuditSemanticCodecError,
ProbedRequirement,
SubstitutionFinding,
SubstitutionTrigger,
canonical_full_reference_records_match,
evaluate_diff_mock_of_prescribed_symbol,
evaluate_rationale_contradiction,
load_audit_semantic_result,
load_standalone_audit_evidence,
probe_substitutions,
)
from autoskillit.core.audit.closure_hashing import (
HASH_RE,
Expand Down Expand Up @@ -89,10 +85,8 @@ def __getattr__(name: str):
"HASH_RE",
"InventoryAdmissionEvaluator",
"PRESCRIPTIVE_MECHANISM_CUES",
"ProbedRequirement",
"SUBSTITUTION_MARKERS",
"SubstitutionFinding",
"SubstitutionTrigger",
"VerificationResult",
"VerifiedAuditCycle",
"canonical_full_reference_records_match",
Expand All @@ -103,12 +97,10 @@ def __getattr__(name: str):
"compute_report_hash",
"compute_request_hash",
"compute_row_hash",
"evaluate_diff_mock_of_prescribed_symbol",
"evaluate_rationale_contradiction",
"load_audit_semantic_result",
"load_standalone_audit_evidence",
"parse_canonical_json_bytes",
"probe_substitutions",
"verify_closure_report",
]

Expand Down
93 changes: 0 additions & 93 deletions src/autoskillit/core/audit/audit_semantic_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from collections.abc import Sequence
from dataclasses import dataclass
from datetime import date
from enum import StrEnum
from pathlib import Path
from typing import Any, Literal, Protocol

Expand Down Expand Up @@ -41,16 +40,12 @@
__all__ = [
"AuditSemanticCodecError",
"PRESCRIPTIVE_MECHANISM_CUES",
"ProbedRequirement",
"SUBSTITUTION_MARKERS",
"SubstitutionFinding",
"SubstitutionTrigger",
"canonical_full_reference_records_match",
"evaluate_diff_mock_of_prescribed_symbol",
"evaluate_rationale_contradiction",
"load_audit_semantic_result",
"load_standalone_audit_evidence",
"probe_substitutions",
]

_DEFAULT_MAX_SIZE_BYTES = 10_000_000
Expand Down Expand Up @@ -122,25 +117,11 @@
)

_TOKEN_RE = re.compile(r"[a-z0-9]+")
_IDENTIFIER_RE = re.compile(r"(?<![A-Za-z0-9_])[A-Za-z_][A-Za-z0-9_]*(?![A-Za-z0-9_])")


class SubstitutionTrigger(StrEnum):
RATIONALE_CONTRADICTION = "RATIONALE_CONTRADICTION"
DIFF_MOCK_OF_PRESCRIBED_SYMBOL = "DIFF_MOCK_OF_PRESCRIBED_SYMBOL"


@dataclass(frozen=True, slots=True)
class ProbedRequirement:
requirement_id: str
requirement_text: str
evidence_summary: str


@dataclass(frozen=True, slots=True)
class SubstitutionFinding:
requirement_id: str
trigger: SubstitutionTrigger
matched_marker: str
matched_prescription: str

Expand All @@ -161,25 +142,6 @@ def _first_matching_term(value: str, terms: frozenset[str]) -> str | None:
return None


def _added_diff_text(diff_text: str) -> str:
"""Return the joined text of added unified-diff lines.

Strips the leading ``+`` marker and skips the ``+++`` file header. The
``\\ No newline at end of file`` escape (always prefixed with a single
space, never with ``+``) is filtered incidentally because it does not
start with ``+``. The result is a corpus suitable for term and
identifier matching, not a structural reconstruction of the diff.
"""
chunks: list[str] = []
for line in diff_text.splitlines():
if not line.startswith("+"):
continue
if line.startswith("+++"):
continue
chunks.append(line[1:])
return "\n".join(chunks)


def evaluate_rationale_contradiction(
requirement_id: str,
requirement_text: str,
Expand All @@ -193,66 +155,11 @@ def evaluate_rationale_contradiction(
return None
return SubstitutionFinding(
requirement_id=requirement_id,
trigger=SubstitutionTrigger.RATIONALE_CONTRADICTION,
matched_marker=marker,
matched_prescription=cue,
)


def evaluate_diff_mock_of_prescribed_symbol(
requirement_id: str,
requirement_text: str,
diff_text: str,
) -> SubstitutionFinding | None:
"""Detect added diff lines that mock an identifier named by a requirement."""

identifiers = {
match.group(0).casefold()
for match in _IDENTIFIER_RE.finditer(requirement_text)
if "_" in match.group(0)
}
if not identifiers:
return None
added_text = _added_diff_text(diff_text)
marker = _first_matching_term(added_text, SUBSTITUTION_MARKERS)
added_identifiers = {
match.group(0).casefold() for match in _IDENTIFIER_RE.finditer(added_text)
}
matches = sorted(identifiers & added_identifiers)
if marker is not None and matches:
return SubstitutionFinding(
requirement_id=requirement_id,
trigger=SubstitutionTrigger.DIFF_MOCK_OF_PRESCRIBED_SYMBOL,
matched_marker=marker,
matched_prescription=matches[0],
)
return None


def probe_substitutions(
requirements: tuple[ProbedRequirement, ...],
diff_text: str,
) -> tuple[SubstitutionFinding, ...]:
"""Apply both deterministic substitution rules to each requirement."""

findings: list[SubstitutionFinding] = []
for requirement in requirements:
candidates = (
evaluate_rationale_contradiction(
requirement.requirement_id,
requirement.requirement_text,
requirement.evidence_summary,
),
evaluate_diff_mock_of_prescribed_symbol(
requirement.requirement_id,
requirement.requirement_text,
diff_text,
),
)
findings.extend(candidate for candidate in candidates if candidate is not None)
return tuple(dict.fromkeys(findings))


AuditSemanticCodecReason = Literal[
"artifact_read_failed",
"invalid_canonical_json",
Expand Down
2 changes: 0 additions & 2 deletions src/autoskillit/core/types/constants/_type_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,10 @@ def _render_stop_step_evidence_doctrine(indent: str = "") -> str:
"output_dir",
"workspace",
"diagnostics_log_dir",
"diff_path",
"investigation_path",
"raw_output_artifact_path",
"current_authority_path",
"prior_authority_path",
"requirements_path",
}
)
RUN_PYTHON_SENTINEL_KEYS: frozenset[str] = frozenset(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@
"submit_exploration_query",
"get_exploration_page",
"resume_exploration_context",
"inspect_session_logs",
"read_authorized_artifact",
"get_authorized_artifact_page",
}
Expand All @@ -191,6 +190,7 @@
"delegate_evidence_reader",
"fetch_github_issue",
"get_issue_title",
"inspect_session_logs",
"test_check",
"unlock_agent_pack",
"commit_files",
Expand Down
1 change: 1 addition & 0 deletions src/autoskillit/core/types/launch/_type_skill_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"activate_deps",
"execution_role",
"exploration_vectors",
"interactive_only",
"requires_resources",
"semantic_version",
"semantic_requirements",
Expand Down
36 changes: 23 additions & 13 deletions src/autoskillit/core/types/results/_type_results_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,29 @@ class RecipePathValidationReport(TypedDict):
quality: dict[str, object]
findings: list[dict[str, str]]
contracts: list[dict[str, Any]]
binding_projection_failures: list[dict[str, str]]


RecipePathValidationResult = RecipePathValidationInputError | RecipePathValidationReport


def _is_string_dict_list(value: object) -> bool:
return isinstance(value, list) and all(
isinstance(item, dict)
and all(
isinstance(key, str) and isinstance(item_value, str)
for key, item_value in item.items()
)
for item in value
)


def _is_string_key_dict_list(value: object) -> bool:
return isinstance(value, list) and all(
isinstance(item, dict) and all(isinstance(key, str) for key in item) for item in value
)


def is_recipe_path_validation_report(
result: object,
) -> TypeGuard[RecipePathValidationReport]:
Expand All @@ -288,6 +306,7 @@ def is_recipe_path_validation_report(
"quality",
"findings",
"contracts",
"binding_projection_failures",
}:
return False

Expand All @@ -296,25 +315,16 @@ def is_recipe_path_validation_report(
quality = result["quality"]
findings = result["findings"]
contracts = result["contracts"]
binding_projection_failures = result["binding_projection_failures"]
return (
isinstance(valid, bool)
and isinstance(errors, list)
and all(isinstance(error, str) for error in errors)
and isinstance(quality, dict)
and all(isinstance(key, str) for key in quality)
and isinstance(findings, list)
and all(
isinstance(finding, dict)
and all(
isinstance(key, str) and isinstance(value, str) for key, value in finding.items()
)
for finding in findings
)
and isinstance(contracts, list)
and all(
isinstance(contract, dict) and all(isinstance(key, str) for key in contract)
for contract in contracts
)
and _is_string_dict_list(findings)
and _is_string_key_dict_list(contracts)
and _is_string_dict_list(binding_projection_failures)
)


Expand Down
Loading
Loading