feat: complete Epic 1 production foundation
This commit is contained in:
@@ -276,6 +276,17 @@ def run_operation_test(
|
||||
raise safe_error("operation_test", "outcome_not_ok")
|
||||
|
||||
|
||||
def operation_etag(client: Client, workspace_id: str, operation_id: str) -> str:
|
||||
response = client.request_json(
|
||||
"GET",
|
||||
admin_path(workspace_id, f"/operations/{operation_id}"),
|
||||
)
|
||||
etag = response.headers.get("ETag") if response.headers is not None else None
|
||||
if not isinstance(etag, str) or len(etag) > 128 or not etag.startswith('"') or not etag.endswith('"'):
|
||||
raise safe_error("operation_precondition", "invalid_response")
|
||||
return etag
|
||||
|
||||
|
||||
def publish_operation(
|
||||
client: Client,
|
||||
workspace_id: str,
|
||||
@@ -286,6 +297,7 @@ def publish_operation(
|
||||
"POST",
|
||||
admin_path(workspace_id, f"/operations/{operation_id}/publish"),
|
||||
{"version": operation_version},
|
||||
headers={"If-Match": operation_etag(client, workspace_id, operation_id)},
|
||||
).body
|
||||
try:
|
||||
published_version = int(published["published_version"])
|
||||
@@ -314,6 +326,35 @@ def create_agent(client: Client, workspace_id: str, agent_slug: str) -> tuple[st
|
||||
raise safe_error("agent_create", "invalid_response") from error
|
||||
|
||||
|
||||
def edit_and_archive_operation(
|
||||
client: Client,
|
||||
workspace_id: str,
|
||||
operation_id: str,
|
||||
operation_name: str,
|
||||
internal_upstream: str,
|
||||
) -> int:
|
||||
payload = build_operation_payload(operation_name, internal_upstream)
|
||||
payload.pop("name", None)
|
||||
payload.pop("protocol", None)
|
||||
payload["display_name"] = "Internal Health Smoke Edited Draft"
|
||||
updated = client.request_json(
|
||||
"PATCH",
|
||||
admin_path(workspace_id, f"/operations/{operation_id}"),
|
||||
payload,
|
||||
headers={"If-Match": operation_etag(client, workspace_id, operation_id)},
|
||||
).body
|
||||
try:
|
||||
draft_version = int(updated["version"])
|
||||
except (KeyError, TypeError, ValueError) as error:
|
||||
raise safe_error("operation_edit", "invalid_response") from error
|
||||
client.request_json(
|
||||
"POST",
|
||||
admin_path(workspace_id, f"/operations/{operation_id}/archive"),
|
||||
headers={"If-Match": operation_etag(client, workspace_id, operation_id)},
|
||||
)
|
||||
return draft_version
|
||||
|
||||
|
||||
def bind_and_publish_agent(
|
||||
client: Client,
|
||||
workspace_id: str,
|
||||
@@ -407,6 +448,7 @@ def cleanup_smoke_assets(
|
||||
client.request_json(
|
||||
"DELETE",
|
||||
admin_path(workspace_id, f"/operations/{operation_id}"),
|
||||
headers={"If-Match": operation_etag(client, workspace_id, operation_id)},
|
||||
expected=(200, 404),
|
||||
)
|
||||
except SmokeError:
|
||||
@@ -414,6 +456,7 @@ def cleanup_smoke_assets(
|
||||
client.request_json(
|
||||
"POST",
|
||||
admin_path(workspace_id, f"/operations/{operation_id}/archive"),
|
||||
headers={"If-Match": operation_etag(client, workspace_id, operation_id)},
|
||||
expected=(200, 404),
|
||||
)
|
||||
except SmokeError as error:
|
||||
@@ -524,7 +567,15 @@ def build_safe_summary(
|
||||
"command_id": "authenticated-product-smoke",
|
||||
"operation_id": operation_id[:128],
|
||||
"operation_version": operation_version,
|
||||
"stages": ["admin_test", "operation_publish", "agent_publish", "mcp_list", "mcp_call"],
|
||||
"stages": [
|
||||
"admin_test",
|
||||
"operation_publish",
|
||||
"agent_publish",
|
||||
"mcp_list",
|
||||
"mcp_call",
|
||||
"operation_edit_archive",
|
||||
"pinned_mcp_list_call",
|
||||
],
|
||||
"verdict": "pass",
|
||||
}
|
||||
|
||||
@@ -614,6 +665,31 @@ def run(args: argparse.Namespace) -> None:
|
||||
)
|
||||
validate_tool_call_result(result)
|
||||
print("tools/call: ok")
|
||||
edited_draft_version = edit_and_archive_operation(
|
||||
client,
|
||||
workspace_id,
|
||||
operation_id,
|
||||
operation_name,
|
||||
args.internal_upstream,
|
||||
)
|
||||
print(f"operation edited and archived: draft_version={edited_draft_version}")
|
||||
tools = call_mcp(
|
||||
client,
|
||||
mcp_url,
|
||||
api_key,
|
||||
session_id,
|
||||
{"jsonrpc": "2.0", "id": 4, "method": "tools/list", "params": {}},
|
||||
)
|
||||
validate_tools_list(tools, operation_name)
|
||||
pinned_result = call_mcp(
|
||||
client,
|
||||
mcp_url,
|
||||
api_key,
|
||||
session_id,
|
||||
tools_call_payload(operation_name, {"probe": "ok"}),
|
||||
)
|
||||
validate_tool_call_result(pinned_result)
|
||||
print("pinned tools/list and tools/call after Operation archive: ok")
|
||||
summary = build_safe_summary(
|
||||
operation_id, published_operation_version, agent_id, published_agent_version
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user