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
+89 -14
View File
@@ -19,6 +19,19 @@ module.
Finding resource carries typed `agent`, `agentAnomaly`, `agentSessions`,
`agentDataAccessEvents`, `aiModel` and `vulnerability` members, which are
read into `Finding`.
- Security Command Center administration, `SecurityAdmin` (every v2 method
except the attack exposure engine): mute configs, notification configs and
BigQuery exports (list, get, create, patch, delete), finding state, mute,
patch, security marks, create, external systems, bulk mute, findings export,
sources create/patch and source IAM, asset security marks, organization
operations (get, list, cancel, delete). Attack paths, valued resources,
simulations and resource value configs are excluded on purpose: they are
cloud posture risk scoring, not agent security (`EXCLUDED_RE` in
`tools/check_discovery.py`).
- Agent Threat Detection categories: `AgentCategories` holds the documented
category strings (runtime detectors and control plane detectors) with module
names. Agent Anomaly Detection has no documented category string: its
findings are the ones with the typed `agentAnomaly` member.
- Agent Security dashboard: a console product with no dashboard API.
`AgentSecurityDashboard` is a LOCAL abstraction that aggregates listed
findings (counts by severity, category, class, state, per-asset worst
@@ -40,7 +53,10 @@ env: `GOOGLE_CLOUD_PROJECT`, optional `GOOGLE_CLOUD_LOCATION`.
| File | Concern |
|---|---|
| `caps.h` | Static ceilings (`ArmorCaps`) |
| `calls.h/.cpp` | The ONE table of declared calls, schemas, enums; path matcher |
| `calls.h/.cpp` | The ONE table of declared calls (144 rows: rpc, verb, path, query, request schema, allowed body fields), schemas, enums; path matcher |
| `scc_name.h/.cpp` | `SccName`: a validated SCC resource name; derives the table row (scope, `locations`, `sources`) from the name |
| `security_admin.h/.cpp` | `SecurityAdmin : Service`: every SCC v2 administration method, `SccList`, `SccAvailability` probe |
| `agent_categories.h/.cpp` | `AgentCategories`: documented Agent Platform Threat Detection categories and module names |
| `tools/check_discovery.py` | Fails when `calls.h` and Google's Discovery documents disagree |
| `armor_types.h/.cpp` | `SanitizationResult`, `FilterOutcome`, enums |
| `template.h/.cpp` | `Template`, `FilterConfig`, `TemplateMetadata`, `FloorSetting`, rule sets |
@@ -62,8 +78,8 @@ env: `GOOGLE_CLOUD_PROJECT`, optional `GOOGLE_CLOUD_LOCATION`.
| Labels per template | 64 (63 chars each) |
| Update mask paths | 16 |
| Detail strings per filter result | 50 |
| Findings page size (Google max) / pages / results | 1000 / 10 / 5000 |
| Categories in a filter | 20 |
| Findings page size (Google max) / pages / results | 1000 / 10 / 5000; config and operation lists use 100 / 10 / 5000 and report `truncated` |
| Categories in a filter | 100 (all documented agent categories fit) |
| Dashboard distinct assets | 500 |
## 4. Contracts
@@ -77,8 +93,19 @@ env: `GOOGLE_CLOUD_PROJECT`, optional `GOOGLE_CLOUD_LOCATION`.
`global` (`https://modelarmor.googleapis.com/v1`); templates and sanitize
reject `global`. Security Command Center: `https://securitycenter.googleapis.com/v2`.
- Destructive: `delete_template` is an explicit method; the demo route also
requires `confirm=delete`. Nothing here creates, updates or deletes
findings, sources or any Security Command Center resource.
requires `confirm=delete`. `SecurityAdmin` mutations are explicit methods
(`delete_config`, `bulk_mute`, `set_finding_state`, ...), each checked
against its table row (query parameters, top-level body fields, update mask
roots) before traffic. `bulk_mute` refuses an empty filter and only mutes or
un-mutes (`MUTED`, `UNDEFINED`); its demo route needs `confirm=bulk-mute`.
`cancel_operation` / `delete_operation` read the operation first. Floor
settings are read and written at location `global` on the global host only
(found live, see 6).
- Lists never truncate silently: findings (`FindingPage::truncated`), config
and operation lists (`SccList::truncated` with `next_page_token`).
- Not activated is a state, not a crash: `SecurityAdmin::availability` maps
403 API disabled, 404 on `sources` and 400 `FAILED_PRECONDITION` (SCC enabled
but not activated for the project) to `SccAvailability`.
- `retry ids`: `requestId` is accepted on create, patch and delete as a
non-zero UUID.
- Sanitization results are typed; an unknown or missing `invocationResult`
@@ -97,13 +124,13 @@ env: `GOOGLE_CLOUD_PROJECT`, optional `GOOGLE_CLOUD_LOCATION`.
## 5. Verified against discovery
`python3 -I src/google/armor/tools/check_discovery.py` fetches
`python3 -I src/google/armor/tools/check_discovery.py` (coverage: every method of both Discovery documents is a table row except the excluded attack exposure engine) fetches
`https://modelarmor.googleapis.com/$discovery/rest?version=v1` and
`https://securitycenter.googleapis.com/$discovery/rest?version=v2` and checks
every row of `calls.h`: 31 calls (rpc id, HTTP method, path, query
parameters), 66 schemas (every field this module reads or writes) and 13 enum
value sets. Result on 2026-10-24: `OK: 31 calls, 66 schemas, 13 enums
checked, 0 problems`. Unit tests additionally prove that every request the
every row of `calls.h`: 144 calls (rpc id, HTTP method, path, query
parameters, request schema, request fields), 71 schemas (every field this
module reads or writes) and 17 enum value sets. Result on 2026-10-24: `OK:
144 calls, 71 schemas, 17 enums checked, 0 problems`. Unit tests additionally prove that every request the
client puts on the wire matches a declared call and only uses declared query
parameters, and that every key of every request body built here is a field of
its Discovery schema (nested schemas included).
@@ -122,6 +149,34 @@ and messages, `filterVersionSelector`, `modalities`, `dataResidencyCompliant`;
Date 2026-10-24, project from `GOOGLE_CLOUD_PROJECT`, no resource created,
updated or deleted.
**Re-run after the owner enabled Model Armor and Security Command Center
(service-account token, read-only):**
| Call | Result |
|---|---|
| Model Armor `GET https://modelarmor.us-central1.rep.googleapis.com/v1/projects/P/locations/us-central1/templates` | 200 `{}` (no template exists) |
| `GET https://modelarmor.googleapis.com/v1/projects/P/locations/global/floorSetting` | 200 `{name, createTime, updateTime}` (no filterConfig: enforcement off) |
| `GET .../locations/us-central1/floorSetting` on the regional host | 400 INVALID_ARGUMENT "Malformed name" (floor settings exist only at `global`) |
| `GET https://modelarmor.googleapis.com/v1/projects/P/locations?pageSize=5` | 200, a list of locations (`name`, `locationId`) |
| `GET https://modelarmor.us-central1.rep.googleapis.com/v1/projects/P/locations` | 403 "Read access to project denied" (list is global-host only) |
| `GET .../locations/us-central1` on the regional host / `.../locations/global` on the global host | 200 `{name, locationId}` |
| `GET .../locations/us-central1` on the global host | 403 |
| `sanitizeUserPrompt` against an absent template id | 400 INVALID_ARGUMENT "The template named '...' was not found" (request shape accepted; absent template is 400, not 404) |
| SCC v2 `GET projects/P/sources`, `sources/-/findings`, `sources/-/locations/global/findings` (also v1 sources) | 404 NOT_FOUND "Requested entity was not found." |
| SCC v2 `GET projects/P/muteConfigs`, `.../locations/global/muteConfigs`, `.../locations/global/notificationConfigs`, `.../locations/global/bigQueryExports` | 400 FAILED_PRECONDITION "Precondition check failed." |
| Cloud Resource Manager `GET v3/projects/P` | 403 API not enabled (so the project's organization could not be read) |
Reading: the API is enabled but Security Command Center is not activated for
this project (no organization or SCC tier reachable): sources do not resolve
and every config call fails its precondition. Findings, groups, mute configs,
notification configs, exports and every `SecurityAdmin` happy path are
therefore NOT seen live; they stay Discovery-verified. `SecurityAdmin::availability`
reports `not_activated` for exactly this state, and the opt-in test
`google_live_armor.oauth_token_reads_templates_and_findings` prints it.
Model Armor code fixed from these runs: floor settings now use location
`global` on the global host, `list_locations` uses the global host,
`get_location` the location's own host.
| Call | Credential | Result |
|---|---|---|
| Model Armor `templates.list` | express key (`AQ.`) | 401 UNAUTHENTICATED (API keys are not supported); `google_live_armor.express_key_is_refused` |
@@ -155,8 +210,25 @@ disabled API loudly. Run it once the APIs are enabled.
Nothing neither Discovery nor docs state:
- Finding `category` strings for Agent Threat Detection and Agent Anomaly
Detection: not read; callers pass categories they see in the console.
- Agent Anomaly Detection category strings: neither the anomaly overview page
nor the threat pages name one. Settled by documentation reading
(2026-10-24): Agent Platform Threat Detection (runtime, Preview) and the AI
agent control plane detectors publish the category strings in
`agent_categories.cpp` (module names `AGENT_ENGINE_*`); anomaly findings are
recognised by the typed `agentAnomaly` member, not by category. The pages
disagree on a few spellings (CloudSQL / Cloud SQL, "Evidence of Port
Scanning from AI Agent" / "AI Agent Evidence of Port Scanning", "Remove Bulk
Data From Disk" / "from Disk", "cryptocurrency" / "crypto", "Abuse of Sudo" /
"Attempt to Abuse Sudo"): both are listed and filtered. No finding was ever
seen live, so which spelling Google emits is unverified.
- `SecurityAdmin` response bodies (configs, operations, marks) are returned as
raw Json and were never seen; request fields are checked against Discovery
only. Notification configs and BigQuery exports exist only under
`locations` in v2 (Discovery), mute configs with and without.
- Whether `findings:bulkMute` accepts `UNMUTED` (Discovery's enum for
`BulkMuteFindingsRequest.muteState` is `MUTED`, `UNDEFINED`): only those are sent.
- Sanitize against a floor setting without a template: not possible (a
template name is required); no default template exists.
- That agent assets always contain `reasoningEngines` in `resourceName`
(dashboard default filter; override with `resource_contains`).
- Server-side behavior of the `resourceName:"x"` substring operator (AIP-160
@@ -178,6 +250,9 @@ Nothing neither Discovery nor docs state:
- Streaming sanitize (`streamingMode`, gRPC `StreamSanitize*`) is not
implemented; `GuardedModel` buffers instead.
- No asset inventory (Cloud Asset Inventory is a different API).
- Findings mutation (mute, state), notification configs, BigQuery exports,
mute configs and attack paths are out of scope (read-only module).
- Attack exposure engine (attack paths, valued resources, simulations,
resource value configs) is excluded on purpose (posture risk scoring).
- Security Command Center is not activated for the test project, so no
findings, group, config or admin response was ever seen. Owner: whoever
activates SCC at the organization; tests `google_live_armor.*`.
- Token refresh is the caller's job (foundation gap).