style: format workflow output binding slice

This commit is contained in:
lda
2026-07-26 21:35:37 +07:00 Verified
parent b65f11e2da
commit 0f11773611
4 changed files with 23 additions and 35 deletions
+2 -6
View File
@@ -620,8 +620,7 @@ class WorkflowDraftAuthoringApi:
) )
if not schema_path_exists(projected, target_parts): if not schema_path_exists(projected, target_parts):
raise ValueError( raise ValueError(
f"bindings[{index}].target {str(binding.target)!r} " f"bindings[{index}].target {str(binding.target)!r} is not declared"
"is not declared"
) )
validate_json_value_at_schema_path( validate_json_value_at_schema_path(
schema=projected, schema=projected,
@@ -632,10 +631,7 @@ class WorkflowDraftAuthoringApi:
) )
payload = [binding.model_dump(mode="json") for binding in bindings] payload = [binding.model_dump(mode="json") for binding in bindings]
if ( if workspace.draft.get("output", []) == payload and projected == output_schema:
workspace.draft.get("output", []) == payload
and projected == output_schema
):
return summarize_draft_workspace(workspace) return summarize_draft_workspace(workspace)
patch: list[dict[str, Any]] = [] patch: list[dict[str, Any]] = []
+18 -20
View File
@@ -3834,12 +3834,12 @@ async def test_set_workflow_output_bindings_projects_nested_paths_and_literals(
{"path": "state.report.title", "target": "audit.title"}, {"path": "state.report.title", "target": "audit.title"},
{"value": "markdown", "target": "format"}, {"value": "markdown", "target": "format"},
] ]
assert inspected["draft"]["output_schema"]["properties"]["report"][ assert inspected["draft"]["output_schema"]["properties"]["report"]["properties"][
"properties" "title"
]["title"] == {"type": "string"} ] == {"type": "string"}
assert inspected["draft"]["output_schema"]["properties"]["audit"][ assert inspected["draft"]["output_schema"]["properties"]["audit"]["properties"][
"properties" "title"
]["title"] == {"type": "string"} ] == {"type": "string"}
cleared = await authoring.set_workflow_output_bindings( cleared = await authoring.set_workflow_output_bindings(
workspace_id="report", workspace_id="report",
@@ -3894,9 +3894,9 @@ async def test_set_workflow_output_bindings_projects_input_and_whole_state(
output_schema = inspected["draft"]["output_schema"]["properties"] output_schema = inspected["draft"]["output_schema"]["properties"]
assert output_schema["input_title"] == {"type": "string"} assert output_schema["input_title"] == {"type": "string"}
assert output_schema["snapshot"]["properties"]["report"]["properties"][ assert output_schema["snapshot"]["properties"]["report"]["properties"]["title"] == {
"title" "type": "string"
] == {"type": "string"} }
@pytest.mark.asyncio @pytest.mark.asyncio
@@ -4110,14 +4110,14 @@ async def test_set_workflow_output_bindings_validates_root_literal_complete_sche
r"bindings\[0\]\.path 'state\.missing' is not declared", r"bindings\[0\]\.path 'state\.missing' is not declared",
), ),
( (
[ [
InputPathBinding( InputPathBinding(
path=GraphSourcePath.state("report"), path=GraphSourcePath.state("report"),
target=LocalPath.of("format"), target=LocalPath.of("format"),
) )
], ],
r"bindings\[0\]\.target 'format' cannot receive source " r"bindings\[0\]\.target 'format' cannot receive source "
r"'state\.report'", r"'state\.report'",
), ),
( (
[ [
@@ -4274,9 +4274,7 @@ async def test_cleared_workflow_output_bindings_preserve_state_fallback(
first = await authoring.set_workflow_output_bindings( first = await authoring.set_workflow_output_bindings(
workspace_id="report", workspace_id="report",
revision=1, revision=1,
bindings=[ bindings=[InputValueBinding(target=LocalPath.of("echoed"), value="explicit")],
InputValueBinding(target=LocalPath.of("echoed"), value="explicit")
],
) )
await authoring.set_workflow_output_bindings( await authoring.set_workflow_output_bindings(
workspace_id="report", workspace_id="report",
+2 -6
View File
@@ -153,9 +153,7 @@ async def test_registered_workflow_output_bindings_tool_preserves_union_order(
def __init__(self) -> None: def __init__(self) -> None:
self.calls: list[dict[str, Any]] = [] self.calls: list[dict[str, Any]] = []
async def set_workflow_output_bindings( async def set_workflow_output_bindings(self, **kwargs: Any) -> dict[str, Any]:
self, **kwargs: Any
) -> dict[str, Any]:
self.calls.append(kwargs) self.calls.append(kwargs)
return { return {
"workspace_id": kwargs["workspace_id"], "workspace_id": kwargs["workspace_id"],
@@ -204,9 +202,7 @@ async def test_registered_workflow_output_bindings_tool_preserves_union_order(
call = recorder.calls[0] call = recorder.calls[0]
assert isinstance(call["bindings"][0], InputPathBinding) assert isinstance(call["bindings"][0], InputPathBinding)
assert isinstance(call["bindings"][1], InputValueBinding) assert isinstance(call["bindings"][1], InputValueBinding)
assert [ assert [binding.model_dump(mode="json") for binding in call["bindings"]] == [
binding.model_dump(mode="json") for binding in call["bindings"]
] == [
{"path": "state.report.title", "target": "report.title"}, {"path": "state.report.title", "target": "report.title"},
{"value": "markdown", "target": "format"}, {"value": "markdown", "target": "format"},
] ]
+1 -3
View File
@@ -347,9 +347,7 @@ def test_set_workflow_output_bindings_request_preserves_union_order() -> None:
assert isinstance(request.bindings[0], InputPathBinding) assert isinstance(request.bindings[0], InputPathBinding)
assert isinstance(request.bindings[1], InputValueBinding) assert isinstance(request.bindings[1], InputValueBinding)
assert [ assert [binding.model_dump(mode="json") for binding in request.bindings] == [
binding.model_dump(mode="json") for binding in request.bindings
] == [
{"path": "state.report.title", "target": "report.title"}, {"path": "state.report.title", "target": "report.title"},
{"value": "markdown", "target": "format"}, {"value": "markdown", "target": "format"},
] ]