Todo 45.5 Composed Schema and Copy Failures Plan
Status: done
Result
Added immutable validation summaries and conservative branch-aware fallback classification. Uncopyable/non-JSON resolver and provider arguments produce stable results without exception leakage or definition-error misclassification.
Goal
Restore the cost-sensitive fallback contract for composed schemas and ensure argument isolation cannot leak copy exceptions or misclassify input failures as plugin-definition failures.
Scope
- Classify
anyOf/oneOf branches so a missing field in an unrelated branch cannot make complete-invalid input eligible for fallback.
- Preserve fallback for a viable branch that fails only because required data is missing.
- Replace exposed/deep-copied
ValidationError values with registry-owned immutable validation summaries needed by the kernel.
- Normalize strict JSON snapshot failures for deterministic resolver and provider-resolved arguments in both async and sync paths.
Boundaries
- Prefer a conservative fallback decision: no LLM call when branch viability is ambiguous or any candidate failure is substantive rather than missing-only.
- Do not implement a general JSON Schema inference engine or discriminator extension.
- Non-JSON and uncopyable values are invalid event arguments/resolution data; do not coerce them.
- Preserve the four already verified Todo 45.4 behaviors.
Files
- Modify:
src/agent_lab/application/events/kernel.py
- Modify:
src/agent_lab/application/events/registry.py
- Modify:
tests/test_event_kernel.py
- Modify:
tests/test_event_agent.py only if EventAgent integration needs a regression
Requirement Execution Loop
Plan
- Add RED tests for discriminated
anyOf and oneOf: target branch complete-but-wrong-type, unrelated branch missing fields, fallback count zero.
- Add RED tests proving a matching/viable branch with only required fields missing can still call fallback once.
- Add RED tests for argument objects whose
__deepcopy__ raises in resolver and provider-resolved inputs; assert no exception escapes and no DEFINITION_ERROR misclassification.
- Introduce immutable validation issue summaries and branch-aware missing-only classification.
- Use strict JSON snapshots at argument isolation boundaries and normalize failures consistently across sync/async execution.
Act
- Cover both
anyOf and oneOf with discriminator-like const branches.
- Verify complete-invalid input returns
INVALID_ARGUMENTS, used_fallback=False, fallback calls 0.
- Verify a matching branch missing only its required value invokes fallback exactly once; fully ambiguous invalid input remains no-fallback.
- Prove validation summaries cannot mutate registry behavior and do not retain caller-owned instances or schema objects.
- Preserve handler/result mutation isolation for ordinary nested JSON values.
Observe
Confirm the LLM fallback count now reflects genuinely missing information, and malformed argument objects are contained as stable user/resolution failures rather than exceptions or definition errors.
Update
- Re-run Todo 45 specification and quality reviews over the full range.
- Mark Todos 45 through 45.5 done only after fresh verification.
Verification
UV_CACHE_DIR=.uv-cache uv run pytest tests/test_event_kernel.py tests/test_event_agent.py -q
UV_CACHE_DIR=.uv-cache uv run pytest
git diff --check