feat(clients): models+runtime: close gaps (all Discovery methods wrapped, live re-verification)
models: EndpointAdmin and PublisherAdmin wrap every remaining method of the owned resources (84 call table rows, 132 Discovery methods covered, v1beta1 twins, IAM, operations, responses, export, config, enableModel); planner rejects undeclared body keys; VertexModel::TurnBuilder replays model turns with every thoughtSignature; Lyria WAV mime from bytes; veo-3.1 default. runtime: v1beta1 feedbackEntries, A2A gateway (40 rpcs), a2aTasks, task store records, scoped operations, beta twin flag (103 rows, 214 methods covered); checker verifies twins, a2aEndpoint patterns and coverage. example: admin routes for both parts. SPECs: live results moved from Unverified to Verified live (Veo, Lyria, thought signatures, v1beta1 routes). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,19 @@ differs, or a request body field, query parameter or schema field we use is
|
||||
not in the discovery document. Python 3 stdlib only, no credentials needed.
|
||||
|
||||
python3 -I src/google/runtime/tools/check_discovery.py
|
||||
|
||||
Besides the rows it checks three more things:
|
||||
twin every v1 row also exists in v1beta1 with the same HTTP method,
|
||||
path (v1beta1 prefix), rpc id, query parameters and body fields
|
||||
(selected in code with AgentRuntime's beta flag);
|
||||
alias the project-less form `aiplatform.reasoningEngines.X` of a covered
|
||||
`aiplatform.projects.locations.reasoningEngines.X` has the same
|
||||
HTTP method and request schema (it is only another URL for the
|
||||
same RPC, so the row covers it);
|
||||
coverage every Discovery method under reasoningEngines (and taskStores,
|
||||
the A2A task record store) is a row, an alias, or belongs to a
|
||||
resource owned by another module (OTHER_MODULES). A new Discovery
|
||||
method fails the check until it is wrapped or excluded on purpose.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
@@ -16,6 +29,12 @@ import urllib.request
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
CALLS = os.path.join(HERE, "..", "calls.cpp")
|
||||
URL = "https://aiplatform.googleapis.com/$discovery/rest?version=%s"
|
||||
OWNED = ("aiplatform.projects.locations.reasoningEngines.",
|
||||
"aiplatform.projects.locations.taskStores.",
|
||||
"aiplatform.reasoningEngines.")
|
||||
# sub-resources of reasoningEngines wrapped by other modules (src/google/sessions,
|
||||
# src/google/sandbox); they are not this module's gaps.
|
||||
OTHER_MODULES = ("sessions", "memories", "sandboxEnvironment") # incl. Snapshots, Templates
|
||||
PREFIX = {"v1": "GoogleCloudAiplatformV1", "v1beta1": "GoogleCloudAiplatformV1beta1"}
|
||||
|
||||
ROW = re.compile(r'^\s*\{(.*)\},?\s*$')
|
||||
@@ -83,13 +102,80 @@ def main():
|
||||
for f in fields.split(","):
|
||||
if f not in props:
|
||||
bad.append("schema %s.%s absent" % (name, f))
|
||||
covered = {(v, rpc) for _, _, v, rpc, _, _ in calls}
|
||||
# twin: every v1 row exists in v1beta1
|
||||
for http, path, version, rpc, body, query in calls:
|
||||
if version != "v1":
|
||||
continue
|
||||
m = index["v1beta1"].get(rpc)
|
||||
if not m:
|
||||
bad.append("twin: %s absent in v1beta1" % rpc)
|
||||
continue
|
||||
covered.add(("v1beta1", rpc))
|
||||
if m["httpMethod"] != http or m["path"] != path.replace("v1/", "v1beta1/", 1):
|
||||
bad.append("twin: %s differs in v1beta1 (%s %s)" % (rpc, m["httpMethod"], m["path"]))
|
||||
params = m.get("parameters", {})
|
||||
for q in filter(None, query.split(",")):
|
||||
if q not in params or params[q].get("location") != "query":
|
||||
bad.append("twin: %s query param %s absent in v1beta1" % (rpc, q))
|
||||
ref = m.get("request", {}).get("$ref")
|
||||
props = docs["v1beta1"]["schemas"].get(ref, {}).get("properties", {})
|
||||
for f in filter(None, body.split(",")):
|
||||
if f not in props:
|
||||
bad.append("twin: %s body field %s absent in v1beta1" % (rpc, f))
|
||||
# a2aEndpoint: the tail the code builds for an op must match Discovery's pattern
|
||||
shapes = {"card": "card", "extendedAgentCard": "extendedAgentCard", "tasks": "tasks",
|
||||
"tasks.a2aGetReasoningEngine": "tasks/[^/]+",
|
||||
"tasks.pushNotificationConfigs": "tasks/[^/]+/pushNotificationConfigs",
|
||||
"tasks.pushNotificationConfigs.a2aGetReasoningEngine":
|
||||
"tasks/[^/]+/pushNotificationConfigs/[^/]+",
|
||||
"tasks.cancel": "tasks/[^/]+", "tasks.subscribe": "tasks/[^/]+",
|
||||
"message.send": "message", "message.stream": "message"}
|
||||
a2a_rows = 0
|
||||
for http, path, version, rpc, body, query in calls:
|
||||
if "{+a2aEndpoint}" not in path:
|
||||
continue
|
||||
a2a_rows += 1
|
||||
rest = rpc.split("reasoningEngines.", 1)[1].replace("runtimeRevisions.", "", 1)
|
||||
rest = rest[len("a2a."):]
|
||||
pre = ""
|
||||
if rest.startswith("v1."):
|
||||
pre, rest = "v1/", rest[3:]
|
||||
want = "^" + pre + shapes.get(rest, "?") + "$"
|
||||
got = index[version][rpc].get("parameters", {}).get("a2aEndpoint", {}).get("pattern")
|
||||
if got != want:
|
||||
bad.append("a2aEndpoint pattern of %s is %s, code builds %s" % (rpc, got, want))
|
||||
if a2a_rows != 40:
|
||||
bad.append("expected 40 A2A gateway rows, table has %d" % a2a_rows)
|
||||
# coverage and alias
|
||||
owned = 0
|
||||
for v in ("v1", "v1beta1"):
|
||||
for rpc, m in index[v].items():
|
||||
if not rpc.startswith(OWNED):
|
||||
continue
|
||||
tail = rpc.split("reasoningEngines.", 1)[-1] if "reasoningEngines." in rpc else rpc
|
||||
if tail.startswith(OTHER_MODULES):
|
||||
continue
|
||||
owned += 1
|
||||
if (v, rpc) in covered:
|
||||
continue
|
||||
if rpc.startswith("aiplatform.reasoningEngines."):
|
||||
twin = "aiplatform.projects.locations.reasoningEngines." + tail
|
||||
tm = index[v].get(twin)
|
||||
if tm and (v, twin) in covered and tm["httpMethod"] == m["httpMethod"] \
|
||||
and tm.get("request", {}).get("$ref") == m.get("request", {}).get("$ref"):
|
||||
continue
|
||||
bad.append("alias %s %s differs from or lacks a covered %s" % (v, rpc, twin))
|
||||
continue
|
||||
bad.append("unwrapped discovery method %s %s" % (v, rpc))
|
||||
revs = {v: docs[v].get("revision") for v in docs}
|
||||
if bad:
|
||||
print("DISCOVERY CHECK FAILED (revisions %s)" % revs)
|
||||
for b in bad:
|
||||
print(" " + b)
|
||||
return 1
|
||||
print("discovery ok: %d calls, %d schemas, revisions %s" % (len(calls), len(schemas), revs))
|
||||
print("discovery ok: %d calls, %d schemas, %d owned discovery methods covered, revisions %s"
|
||||
% (len(calls), len(schemas), owned, revs))
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user