Pārlūkot izejas kodu

docs: plan structured incomplete fallback fix

Problem: an explicit incomplete resolver result can bypass mixed-validation guards and trigger an unnecessary LLM fallback.

Risk: the fix must preserve optional-only incomplete fallback and pure required-missing fallback while blocking substantive invalid input.
zhenyu.hu 2 nedēļas atpakaļ
vecāks
revīzija
072ff96c68

+ 37 - 0
docs/plans/todo-45.7-structured-incomplete-mixed-validation.md

@@ -0,0 +1,37 @@
+# Todo 45.7 Structured Incomplete Mixed Validation Plan
+
+**Status:** in_progress
+
+## Goal
+
+Ensure a structured resolver's explicit `complete=False` signal cannot trigger LLM fallback when the resolved arguments also contain substantive validation errors.
+
+## Scope
+
+- Add structured-incomplete regressions for required plus enum, type, and additional-property failures.
+- Compute fallback eligibility before converting optional-schema incomplete results into `INVALID_ARGUMENTS`.
+- Allow fallback only for pure missing-only validation or explicit incomplete with no substantive validation error.
+
+## Files
+
+- Modify: `src/agent_lab/application/events/kernel.py`
+- Modify: `tests/test_event_kernel.py`
+
+## Requirement Execution Loop
+
+### Plan
+
+1. Add RED tests proving `EventArgumentResolution(..., complete=False)` plus mixed substantive errors currently calls fallback.
+2. Separate `fallback_eligible` from the normalized invalid result status.
+3. Preserve optional-only explicit incomplete fallback and pure required-missing fallback.
+4. Run focused/full tests and final bounded reviews.
+
+### Observe / Update
+
+Close Todo 45 only when the named reproductions pass and no Critical/Important findings remain.
+
+## Verification
+
+- `UV_CACHE_DIR=.uv-cache uv run pytest tests/test_event_kernel.py -q`
+- `UV_CACHE_DIR=.uv-cache uv run pytest`
+- `git diff --check`

+ 1 - 0
docs/plans/todos.md

@@ -81,6 +81,7 @@
 | 45.4 | in_progress | `docs/plans/todo-45.4-event-kernel-quality-boundaries.md` | Close reviewed configuration, composed-schema fallback, mutation isolation, registry encapsulation, and payload-serialization gaps. | Default EventAgent config survives omitted overrides; nested required errors can fall back; handlers and callers cannot corrupt audit arguments; validators stay private; non-JSON payloads become `HANDLER_ERROR`. |
 | 45.5 | in_progress | `docs/plans/todo-45.5-composed-schema-and-copy-failures.md` | Prevent unrelated composed-schema branches from triggering fallback and normalize argument snapshot failures without exposing validator internals. | Complete-invalid discriminated unions never call fallback; missing viable branches still can; uncopyable/non-JSON resolver and provider arguments return stable results instead of raising or becoming definition errors. |
 | 45.6 | in_progress | `docs/plans/todo-45.6-mixed-validation-and-handler-snapshot.md` | Require every validation failure to be missing-only before fallback and contain arbitrary handler payload serialization exceptions. | Required plus enum/type/additional-property errors never call fallback; sync/async handler snapshot failures become stable `HANDLER_ERROR` results through ToolRegistry and EventAgent. |
+| 45.7 | in_progress | `docs/plans/todo-45.7-structured-incomplete-mixed-validation.md` | Prevent an explicit structured `complete=False` flag from bypassing substantive validation failures. | Structured incomplete plus enum/type/additional-property errors never calls fallback; optional-only incomplete and pure missing-only input still can. |
 | 46 | pending | `docs/plans/todo-46-configurable-tool-invocation-mode.md` | Add `dual_agent` and `chat_agent_tools` runtime modes on the shared event kernel. | Runtime tests prove mode-specific requests, direct execution, valid provider history, and dual-mode regression safety. |
 | 47 | pending | `docs/plans/todo-47-built-in-event-plugins.md` | Add terminate-session, device-volume, schedule, and web-search as built-in plugins on the generic event kernel. | Plugin contract tests cover valid, ambiguous, invalid, idempotent, and failure results for all four events. |
 | 48 | pending | `docs/plans/todo-48-parallel-event-batches.md` | Execute multiple flat events with bounded parallelism, failure isolation, aggregation, and a terminal barrier. | Runtime tests prove independent concurrency, stable result order, isolated failures, and termination after sibling completion or timeout. |