feat(clients): sessions+registry+optimize+armor: close gaps, loud list truncation, shared Gemini adapter

sessions: operations get/list/cancel/delete/wait for engine, session, memory and
serving profile; servingProfiles CRUD. registry: ListResult with truncated flag,
v1alpha twins, gateway/policy operations, authz IAM, deny policy update, boundary
patch/bindings. optimize: make_gemini_model over models::VertexModel (DirectModel
removed), generateSyntheticData, online evaluator operations, trace/log writers.
armor: SecurityAdmin for all SCC v2 methods (attack exposure excluded), documented
agent threat categories, floor settings fixed to location global after live run.
check_discovery.py of all four enforce coverage.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 05:43:13 +02:00
co-authored by Claude Sonnet 5.5
parent 29d775a923
commit a3396bfc68
83 changed files with 5020 additions and 378 deletions
+142
View File
@@ -9,6 +9,7 @@
#include "google/sessions/caps.h"
#include "google/sessions/calls.h"
#include "google/sessions/memory_bank.h"
#include "google/sessions/serving_profile.h"
#include "google/sessions/sessions.h"
namespace molo::example::app {
@@ -52,6 +53,15 @@ Every call below is a JSON POST (or DELETE) and answers 503
<tr><td>DELETE /agent/sessions/memories/memory</td><td>query: engine, id</td></tr>
<tr><td>POST /agent/sessions/memories/profiles</td><td>engine, scope_key, scope_value</td></tr>
<tr><td>POST /agent/sessions/memories/purge</td><td>engine, filter, force?, confirm? (dry run by default)</td></tr>
<tr><td>POST /agent/sessions/operations/list</td><td>engine, parent? (engine, session or memory name), filter?</td></tr>
<tr><td>POST /agent/sessions/operations/get</td><td>engine, name</td></tr>
<tr><td>POST /agent/sessions/operations/wait</td><td>engine, name, timeout_seconds (server-side wait, 1..60)</td></tr>
<tr><td>POST /agent/sessions/operations/cancel</td><td>engine, name</td></tr>
<tr><td>DELETE /agent/sessions/operations/operation</td><td>query: engine, name</td></tr>
<tr><td>POST /agent/sessions/serving-profiles/list</td><td>location? (id or projects/P/locations/L)</td></tr>
<tr><td>POST /agent/sessions/serving-profiles/get</td><td>location?, profile_id</td></tr>
<tr><td>POST /agent/sessions/serving-profiles/create</td><td>location?, profile_id, display_name, scope, description?</td></tr>
<tr><td>DELETE /agent/sessions/serving-profiles/profile</td><td>query: location?, id</td></tr>
</tbody>
</table>
</div>
@@ -106,6 +116,29 @@ class SessionsRoutes {
return gs::MemoryBank(client_, engine_of(engine));
}
// A full "projects/P/locations/L" name, or a location id (project from
// GOOGLE_CLOUD_PROJECT, empty: GOOGLE_CLOUD_LOCATION or us-central1).
gs::LocationName location_of(const std::string& value) const {
if (value.rfind("projects/", 0) == 0) return gs::LocationName(value);
google::CloudContext ctx = google::CloudContext::from_env();
if (!value.empty()) ctx.location = value;
return gs::LocationName(ctx.parent());
}
gs::ServingProfiles profiles(const std::string& location) const {
return gs::ServingProfiles(client_, location_of(location));
}
static GJson operation_json(const google::Operation& op) {
GJson o = GJson::object();
o.set("name", GJson(op.name));
o.set("done", GJson(op.done));
if (op.failed()) {
o.set("error_code", GJson(op.error_code));
o.set("error_message", GJson(op.error_message));
}
return o;
}
static gs::StringMap scope_of(const Flat& in) {
gs::StringMap scope;
if (!field(in, "scope_key").empty() || !field(in, "scope_value").empty())
@@ -147,6 +180,8 @@ void register_agent_sessions_demo(fw::Router& router, Services& services) {
caps.set("max_session_id_chars", GJson(static_cast<int>(gs::SessionsCaps::kMaxIdChars)));
caps.set("max_list_items", GJson(static_cast<int>(gs::SessionsCaps::kMaxListItems)));
caps.set("max_top_k", GJson(gs::MemoryCaps::kMaxTopK));
caps.set("max_server_wait_seconds",
GJson(static_cast<int>(gs::SessionsCaps::kMaxServerWaitSeconds)));
caps.set("max_fact_chars", GJson(static_cast<int>(gs::MemoryCaps::kMaxFactChars)));
out.set("caps", caps);
return answer(out);
@@ -355,6 +390,113 @@ void register_agent_sessions_demo(fw::Router& router, Services& services) {
return answer(out);
});
});
// Operations (engine, session, memory) -----------------------------------
router.post("/agent/sessions/operations/list", "agent-sessions-operations-list",
[routes](fw::Request req) {
Flat in = fw::parse_json_object_flat(req.body);
return guarded([&] {
gs::OperationListOptions options;
options.filter = field(in, "filter");
GJson arr = GJson::array();
for (const google::Operation& op :
routes->sessions(field(in, "engine")).list_operations(field(in, "parent"), options))
arr.push(SessionsRoutes::operation_json(op));
GJson out = GJson::object();
out.set("operations", arr);
return answer(out);
});
});
router.post("/agent/sessions/operations/get", "agent-sessions-operations-get",
[routes](fw::Request req) {
Flat in = fw::parse_json_object_flat(req.body);
return guarded([&] {
return answer(routes->sessions(field(in, "engine")).operation(field(in, "name")));
});
});
// One server-side wait (POST :wait); done=false when the timeout passed first.
router.post("/agent/sessions/operations/wait", "agent-sessions-operations-wait",
[routes](fw::Request req) {
Flat in = fw::parse_json_object_flat(req.body);
return guarded([&] {
int seconds = field(in, "timeout_seconds").empty()
? 30
: std::atoi(field(in, "timeout_seconds").c_str());
return answer(SessionsRoutes::operation_json(
routes->sessions(field(in, "engine")).wait_server(field(in, "name"), seconds)));
});
});
router.post("/agent/sessions/operations/cancel", "agent-sessions-operations-cancel",
[routes](fw::Request req) {
Flat in = fw::parse_json_object_flat(req.body);
return guarded([&] {
routes->sessions(field(in, "engine")).cancel_operation(field(in, "name"));
GJson out = GJson::object();
out.set("cancel_requested", GJson(true));
return answer(out);
});
});
router.del("/agent/sessions/operations/operation", "agent-sessions-operations-delete",
[routes](fw::Request req) {
return guarded([&] {
routes->sessions(req.query_or("engine", "")).delete_operation(req.query_or("name", ""));
GJson out = GJson::object();
out.set("deleted", GJson(true));
return answer(out);
});
});
// Serving profiles (location level) ---------------------------------------
router.post("/agent/sessions/serving-profiles/list", "agent-serving-profiles-list",
[routes](fw::Request req) {
Flat in = fw::parse_json_object_flat(req.body);
return guarded([&] {
GJson arr = GJson::array();
for (const gs::ServingProfile& p : routes->profiles(field(in, "location")).list())
arr.push(p.to_json());
GJson out = GJson::object();
out.set("serving_profiles", arr);
return answer(out);
});
});
router.post("/agent/sessions/serving-profiles/get", "agent-serving-profiles-get",
[routes](fw::Request req) {
Flat in = fw::parse_json_object_flat(req.body);
return guarded([&] {
return answer(
routes->profiles(field(in, "location")).get(field(in, "profile_id")).to_json());
});
});
router.post("/agent/sessions/serving-profiles/create", "agent-serving-profiles-create",
[routes](fw::Request req) {
Flat in = fw::parse_json_object_flat(req.body);
return guarded([&] {
gs::ServingProfileSpec spec;
spec.profile_id = field(in, "profile_id");
spec.display_name = field(in, "display_name");
spec.description = field(in, "description");
spec.scope = gs::serving_scope_from(field(in, "scope"));
return answer(routes->profiles(field(in, "location")).create(spec).to_json(), 201);
});
});
router.del("/agent/sessions/serving-profiles/profile", "agent-serving-profiles-delete",
[routes](fw::Request req) {
return guarded([&] {
routes->profiles(req.query_or("location", "")).remove(req.query_or("id", ""));
GJson out = GJson::object();
out.set("deleted", GJson(true));
return answer(out);
});
});
}
} // namespace molo::example::app