fix: harden canonical output binding projection
This commit is contained in:
@@ -525,17 +525,11 @@ class WorkflowDraftAuthoringApi:
|
||||
spec.output_schema_contract or spec.output_model.model_json_schema()
|
||||
)
|
||||
|
||||
targets = [str(binding.target) for binding in bindings]
|
||||
if has_overlapping_paths(targets):
|
||||
raise _overlapping_output_targets_error(bindings)
|
||||
|
||||
projected_state = _draft_schema(workspace.draft, "state_schema")
|
||||
for index, binding in enumerate(bindings):
|
||||
source_parts = binding.source.parts
|
||||
try:
|
||||
schema_fragment_at_path(
|
||||
capability_schema,
|
||||
source_parts,
|
||||
binding.source.parts,
|
||||
label="capability output schema",
|
||||
)
|
||||
except ValueError as exc:
|
||||
@@ -544,6 +538,13 @@ class WorkflowDraftAuthoringApi:
|
||||
f"is not declared by capability {capability_name!r}: {exc}"
|
||||
) from exc
|
||||
|
||||
targets = [str(binding.target) for binding in bindings]
|
||||
if has_overlapping_paths(targets):
|
||||
raise _overlapping_output_targets_error(bindings)
|
||||
|
||||
projected_state = _draft_schema(workspace.draft, "state_schema")
|
||||
for index, binding in enumerate(bindings):
|
||||
source_parts = binding.source.parts
|
||||
target_parts = binding.target.parts
|
||||
try:
|
||||
projected_state = project_schema_path_to_schema_path(
|
||||
|
||||
@@ -110,8 +110,18 @@ def project_schema_path_to_schema_path(
|
||||
raise ValueError(
|
||||
f"schema path {'.'.join(target_parts[: index + 1])!r} is not an object"
|
||||
)
|
||||
_ensure_object_schema(child, ".".join(target_parts[: index + 1]))
|
||||
parent = child
|
||||
target_label = ".".join(target_parts[: index + 1])
|
||||
# Mutate the referenced definition rather than adding sibling schema
|
||||
# keywords beside $ref, which path lookup intentionally does not merge.
|
||||
resolved_child = _resolve_local_reference(
|
||||
projected,
|
||||
child,
|
||||
label=target_label,
|
||||
)
|
||||
if not isinstance(resolved_child, dict):
|
||||
raise ValueError(f"schema path {target_label!r} is not mutable")
|
||||
_ensure_object_schema(resolved_child, target_label)
|
||||
parent = resolved_child
|
||||
|
||||
properties = _properties_for_object(
|
||||
parent, ".".join(target_parts[:-1]) or "target_schema"
|
||||
|
||||
Reference in New Issue
Block a user