Skip to content

Implementation Plan: T5-P5-A4-WP1 — Result Validation Helper with Fail-Closed Envelope#4144

Merged
Trecek merged 3 commits into
developfrom
t5-p5-a4-wp1-provide-a-single-reusable-result-validation-hel/4036
Jun 28, 2026
Merged

Implementation Plan: T5-P5-A4-WP1 — Result Validation Helper with Fail-Closed Envelope#4144
Trecek merged 3 commits into
developfrom
t5-p5-a4-wp1-provide-a-single-reusable-result-validation-hel/4036

Conversation

@Trecek

@Trecek Trecek commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add a _validate_result function to src/autoskillit/server/tools/_types.py that enforces output shape invariants on MCP tool result dicts before serialization. The function checks required-key presence, non-None values, success==True when present, and non-empty content when present. On violation it returns a json.dumps-serialized ToolFailureEnvelope (fail-closed); on pass it returns None. Wire this validator into open_kitchen (normal named-recipe branch only — deferred-recall branch exempted per acceptance criteria) and load_recipe (unified exit, gated on result validity) with structured logging at each fail-closed site.

Closes #4036

Implementation Plan

Plan file: /home/talon/projects/autoskillit-runs/impl-20260628-093915-207021/.autoskillit/temp/make-plan/t5-p5-a4-wp1-validate-result-helper_plan_2026-06-28_094800.md

🤖 Generated with Claude Code via AutoSkillit

Token Usage Summary

Step Model count uncached output cache_read peak_ctx turns cache_write time
plan* opus[1m] 1 843 26.4k 985.6k 97.6k 44 86.5k 14m 10s
verify* sonnet 1 60 11.9k 304.3k 62.3k 22 43.8k 6m 34s
implement* MiniMax-M3 1 76.2k 10.9k 2.4M 0 93 0 5m 31s
fix* sonnet 1 438 51.6k 5.1M 147.2k 140 129.2k 18m 44s
audit_impl* sonnet 1 1.3k 15.2k 223.8k 57.0k 16 42.3k 8m 35s
prepare_pr* MiniMax-M3 1 44.1k 2.2k 232.2k 0 16 0 1m 40s
compose_pr* MiniMax-M3 1 37.2k 1.8k 177.0k 0 13 0 31s
review_pr* sonnet 1 110 36.9k 823.0k 92.9k 42 76.4k 10m 10s
resolve_review* sonnet 1 287 23.1k 2.6M 95.4k 81 77.6k 9m 48s
Total 160.6k 179.9k 12.8M 147.2k 455.7k 1h 15m

* Step used a non-Anthropic provider; caching behavior may differ.

Token Efficiency

Step LoC Changed cache_read/LoC cache_write/LoC output/LoC
plan 0
verify 0
implement 193 12177.9 0.0 56.4
fix 309 16587.2 418.0 166.9
audit_impl 0
prepare_pr 0
compose_pr 0
review_pr 0
resolve_review 4 638656.0 19391.5 5773.0
Total 506 25249.6 900.6 355.5

Model Usage Breakdown

Model steps uncached output cache_read cache_write time
opus[1m] 1 843 26.4k 985.6k 86.5k 14m 10s
sonnet 5 2.2k 138.7k 9.0M 369.2k 53m 53s
MiniMax-M3 3 157.5k 14.9k 2.8M 0 7m 43s

Trecek and others added 3 commits June 28, 2026 10:06
…and load_recipe

Implements T5-P5-A4-WP1: adds _validate_result helper to server/tools/_types.py
that enforces output shape invariants (required keys, non-None, success==True,
non-empty content) before serialization. Wires validator into open_kitchen (named-
recipe branch only) and load_recipe (unified exit, gated on result.valid). Returns
serialized ToolFailureEnvelope on violation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Bump tools_kitchen.py line-limit exemption 1290→1310 for new validator block
- Update _LEGACY_JSON_WRITES allowlist with shifted json.dumps line numbers
- Fix open_kitchen fail-closed tests: use correct patch targets
  (autoskillit.server._get_ctx / autoskillit.server.logger), add
  _apply_triage_gate mock, fix assertions to match recipe_validation path
- Fix load_recipe fail-closed tests: use object-form monkeypatch to avoid
  arch re-export bypass violation, fix _LOAD_CACHE import to _api_cache,
  add _apply_triage_gate mock so _validate_result is reached

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

test_open_kitchen_fail_closed_empty_content and
test_open_kitchen_fail_closed_missing_content previously only checked
`kitchen == "failed"` without verifying the error key exists or contains
meaningful content. Adding assertions on `parsed["error"]` makes the tests
more robust against regressions in the failure response schema.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Trecek Trecek added this pull request to the merge queue Jun 28, 2026
Merged via the queue into develop with commit 4204cba Jun 28, 2026
3 checks passed
@Trecek Trecek deleted the t5-p5-a4-wp1-provide-a-single-reusable-result-validation-hel/4036 branch June 28, 2026 18:04
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