Skip to main content

Module google

Module google 

Source
Expand description

Task 10B: trace wiring for the Google Gemini Code Assist transport (broker-proxied v1internal:streamGenerateContent) and the explicit cloud-invoke routes (AWS Bedrock, Azure OpenAI, Google Vertex — all broker-mediated). Mirrors the Anthropic/OpenAI seams:

  • Exact bytes only. The Gemini transport serializes its envelope once via ProxyRequest::post_json_exact; on the local broker those very bytes go on the wire and are the digest preimage. On a remote broker the daemon re-serializes out of process, so records carry wire: None and TransportKind::CloudProxy — never a digest of bytes this process did not send. Cloud-invoke bodies are always serialized behind the broker boundary (provider-specific signing/shapes), so those records carry wire: None unconditionally.
  • One record per actual broker attempt. The Gemini 429 retry loop emits one record per proxy_stream call; a cancellation observed during backoff sleep (no send in flight) emits no extra record. A tool-bearing cloud request fails §5.5 preflight before any broker or network work and emits no attempt record.
  • Honest translation reporting. The Gemini adapter’s known losses — dropped thinking/unknown blocks, dropped internal-only tools, merged text segments, synthesized function-response names — are reported as metadata-only entries (positional IDs, never content). Cloud-invoke routes flatten structured content to text and report the downgrade.
  • Correctness firewall. Everything degrades to no-ops when tracing is disabled or identity is unrepresentable; provider-controlled error text never enters a record.

Constants§

GEMINI_INTERNAL_TOOLS
Tool names the Gemini adapter drops as internal-only (never sent on the Code Assist wire). Shared with runtime::google_gemini::runtime’s wire filter so the trace report can never drift from the actual translation.

Functions§

begin_cloud_invoke_tracer
Begin tracing one explicit cloud invocation (AWS Bedrock, Azure OpenAI, Google Vertex). Always TransportKind::CloudProxy with wire: None: the provider body is serialized and signed behind the broker boundary, so this process never holds the exact bytes sent. Returns None when tracing is disabled or identity is unrepresentable.
begin_gemini_tracer
Begin tracing one Gemini Code Assist request. Delegates to the shared OpenAI-compatible builder (same normalized message walker, no cache section, wire claimed only from exact_sent_bytes). Returns None when tracing is disabled or identity is unrepresentable.
cloud_translation_losses
Cloud-invoke translation report: the broker route is text-only, so any message whose content is not already a plain string is flattened to text (a structural downgrade), reported per message index.
gemini_translation_losses
Metadata-only report of the rewrites the Gemini adapter performs on the normalized (Anthropic-shaped) request. Element IDs are tool stable IDs or positional paths (messages[i], messages[i].blocks[j], tools[k]) — never content.
stop_reason_from_gemini
Normalize a Gemini finishReason into the trace enum. Unknown values collapse to Other — the raw string is never stored.
usage_from_cloud_event
Provider-reported usage from a broker CloudEvent::Usage. The broker event carries exactly input/output totals — nothing else is claimed.
usage_from_gemini
Provider-reported usage from a decoded Gemini stream chunk. Counts the upstream did not report stay None — never fabricated zeros.