Skip to content

Implementation Plan: Hook-Based Recipe Reload Guard — Block Duplicate Recipe Loads#3939

Merged
Trecek merged 5 commits into
developfrom
hook-based-recipe-reload-guard-block-duplicate-recipe-loads/3912
Jun 8, 2026
Merged

Implementation Plan: Hook-Based Recipe Reload Guard — Block Duplicate Recipe Loads#3939
Trecek merged 5 commits into
developfrom
hook-based-recipe-reload-guard-block-duplicate-recipe-loads/3912

Conversation

@Trecek

@Trecek Trecek commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add a timing-based guard that structurally blocks duplicate open_kitchen(name=...) calls after the recipe initialization phase completes. A new PostToolUse hook (recipe_confirmed_post_hook.py) writes a {session_id}_recipe_confirmed.json marker to kitchen_state/ after the first successful run_skill completes. The existing open_kitchen_guard.py PreToolUse hook is extended to read this marker and deny recipe-loading open_kitchen calls when it exists. Gate-only opens (no name), ingredients_only=True calls, and all calls during the initialization phase (before any pipeline step executes) remain allowed.

Closes #3912

Implementation Plan

Plan file: /home/talon/projects/autoskillit-runs/impl-20260608-102437-791030/.autoskillit/temp/make-plan/recipe_reload_guard_plan_2026-06-08_103500.md

🤖 Generated with Claude Code via AutoSkillit

Trecek and others added 5 commits June 8, 2026 11:45
Add a new PostToolUse hook for run_skill that writes a
{session_id}_recipe_confirmed.json marker to kitchen_state/ after
the first successful run_skill completes. This marker is read by
open_kitchen_guard to block mid-run recipe reloads (the recipe is
instructions, not runtime state — re-loading cannot change pipeline
behavior).

The marker is scoped by session_id so stale markers from crashed
sessions do not affect new sessions. Idempotent: skips writing if
the marker already exists. Fails open on all error paths.

Files:
- New hook: src/autoskillit/hooks/recipe_confirmed_post_hook.py
- New test: tests/hooks/test_recipe_confirmed_post_hook.py (T1-1 to T1-6)
- Arch exemption: tests/arch/_rules.py _BROAD_EXCEPT_EXEMPT
- Docs: hooks/AGENTS.md, tests/hooks/AGENTS.md, docs/safety/hooks.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…e starts

Extend open_kitchen_guard with _check_recipe_reload_block(): on the
permit path, block open_kitchen(name=...) if a recipe-confirmed
marker exists for the current session. Gate-only opens (no name)
and ingredients_only=True calls remain allowed.

This enforces that the recipe is instructions, not runtime state:
mid-run reloads cannot change pipeline behavior. To re-open the
kitchen gate without loading a recipe, callers can call open_kitchen()
without a name parameter.

Tests (T2-1 to T2-7):
- test_reload_blocked_after_confirmed_marker
- test_gate_only_open_allowed_after_confirmed
- test_ingredients_only_allowed_after_confirmed
- test_different_session_id_not_blocked
- test_no_confirmed_marker_allows_load
- test_corrupted_confirmed_marker_fails_open
- test_reload_denied_in_headless_orchestrator_after_confirmed

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add recipe_confirmed_post_hook.py to the existing run_skill PostToolUse
HookDef's scripts list. Update Codex compatibility table to mark
recipe_confirmed_post_hook as works-as-is. Regenerate registry.sha256
with the new hash (e16b7355310b925a6937aee8e0d6028f4dbe6c475d14c8d8f487923601ab8702)
so test_committed_registry_hash_matches_live_registry passes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ecipe_confirmed_post_hook

Bump hooks/ file-count exemption from 13→14 and add recipe_confirmed_post_hook
to the dispatcher logical-name allowlist.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…post_hook

Bare `except Exception` silently swallowed disk-full or permission errors,
leaving the recipe-confirmed marker unwritten so the reload guard never fired.
Capture the exception and write to stderr before cleanup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Trecek Trecek force-pushed the hook-based-recipe-reload-guard-block-duplicate-recipe-loads/3912 branch from c33b17c to a1119e4 Compare June 8, 2026 18:45
@Trecek Trecek added this pull request to the merge queue Jun 8, 2026
Merged via the queue into develop with commit 480167c Jun 8, 2026
3 checks passed
@Trecek Trecek deleted the hook-based-recipe-reload-guard-block-duplicate-recipe-loads/3912 branch June 8, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant