aeat.application.diagnostics_telemetry module¶
Remote-telemetry posture reporting and the dry-run-safe flush composition.
Wires the CLI surface promised by 2026-07-04-remote-telemetry-adr (GitHub
issue #407) over the core telemetry package
(telemetry) without re-implementing any of its gate, schema,
or sink logic (composition-service-no-parallel-write-path):
build_telemetry_status_report()projects the currentSettingsposture (opt-in, tier, gestor mode, endpoint) plus whether an emission would currently be permitted, so an operator can inspect the deployment’s telemetry posture without guessing at environment variable names.build_telemetry_flush_preview()aggregates the same local, non-sensitive LLM run-timing signalbuild_run_health_report()already reads (LLMRunTelemetryRecorder) into ONE allowlistedTelemetryEventPayloadviabuild_telemetry_payload(), and reports whether the consent gate (telemetry_emit_permitted()) would currently permit sending it. This function never sends anything: it is the--dry-runpreview surface.build_telemetry_flush_previewis also the payload-construction step the real (non-dry-run) flush reuses, so preview and send can never observe a different payload shape.flush_telemetry()performs the real send: it reuses the identical preview payload, re-checks the consent gate, and – only when both the gate permits AND an endpoint is configured – hands the payload to a realHttpTelemetrySink. When the gate refuses or no endpoint is configured, it is a pure no-op (mirroringemit_telemetry_event()’s own no-op contract), so calling this function is always safe regardless of posture.
No producer here reads transaction content, profile identity, or file
contents; the aggregate is built from the same accounting/timing-only
LLMRunRecord rows the local-only
run-health diagnostics already expose.
See also
telemetryConsent gate, closed payload schema, workspace hash, and optional HTTP sink reused by this application service.
build_run_health_report()Local-only LLM run accounting source aggregated by the flush preview.
_app_diagnostics_telemetryCLI transport that exposes status and dry-run-safe flush commands.
TelemetryEventPayloadClosed allowlisted payload shape built by preview and reused by send.
- class TelemetryStatusReport(**data)[source]¶
Bases:
BaseModelThe deployment’s current remote-telemetry posture.
Projects the raw
Settingstelemetry fields plus the derivedwould_emitverdict a hypothetical fully-acknowledged invocation would currently receive fromtelemetry_emit_permitted(). Never triggers an emission; this is a read-only report.- Parameters:
opt_in (bool)
tier (TelemetryTier)
gestor_mode (bool)
endpoint (str | None)
would_emit_if_acknowledged (bool)
- opt_in: bool¶
- tier: TelemetryTier¶
- gestor_mode: bool¶
- endpoint: str | None¶
- would_emit_if_acknowledged: bool¶
- class TelemetryFlushPreview(**data)[source]¶
Bases:
BaseModelThe payload a flush would send, plus whether it would currently send at all.
payloadis the exact allowlistedTelemetryEventPayloadflush_telemetry()would hand to the sink;gate_permitsandwould_sendare evaluated against the SAMEacknowledgedvalue the caller supplied (never hardcoded toTrue), so a preview built without an acknowledgement honestly reports “would not currently send” even when opt-in, tier, and endpoint are otherwise fully configured.would_sendfolds the consent-gate verdict with whether an endpoint is configured, so a dry-run preview can honestly report “built, but would not transmit” (refused consent, or no endpoint) versus “would transmit”.- Parameters:
payload (TelemetryEventPayload)
gate_permits (bool)
endpoint_configured (bool)
would_send (bool)
- payload: TelemetryEventPayload¶
- gate_permits: bool¶
- endpoint_configured: bool¶
- would_send: bool¶
- build_telemetry_status_report(*, settings=None)[source]¶
Report the current remote-telemetry consent posture.
- Parameters:
settings (
Settings|None) – Resolved deployment settings; defaults toload_settings().- Return type:
- Returns:
The populated
TelemetryStatusReport.
- build_telemetry_flush_preview(*, settings=None, acknowledged=False)[source]¶
Build the allowlisted payload a flush would send, without sending it.
Aggregates every locally recorded LLM run (
LLMRunRecord, read viabuild_run_health_report()) into onediagnostics.llm_runTelemetryEventPayload. This is the sole payload-construction step; both the--dry-runpreview and the realflush_telemetry()call this function so they can never observe a different payload shape.gate_permits/would_sendare evaluated againstacknowledgedexactly as supplied – defaulting toFalse(the honest state of a bare--dry-runinvocation with no acknowledgement flag), never hardcoded toTrue. This mirrorstelemetry_emit_permitted()’s own never-sticky per-invocation acknowledgement contract.- Parameters:
settings (
Settings|None) – Resolved deployment settings; defaults toload_settings().acknowledged (
bool) – Whether the operator acknowledged remote telemetry for this specific invocation. Never sticky.
- Return type:
- Returns:
The populated
TelemetryFlushPreview. Never performs a network call.
- flush_telemetry(*, settings=None, acknowledged)[source]¶
Send the aggregate local telemetry payload, honouring the consent gate.
Reuses
build_telemetry_flush_preview()(with the SAMEacknowledgedvalue) for payload construction and verdict computation, so the returned report always reflects the real invocation’s acknowledgement – never a hardcoded optimistic verdict. Delegates the actual gate check and dispatch toemit_telemetry_event()(composition-service-no-parallel-write-path): this function never re-implements the consent gate or the HTTP transport.A real send requires ALL of: the consent gate permits (deployment opt-in, non-
offtier, gestor mode off) ANDacknowledgedisTruefor THIS invocation (never sticky) ANDsettings.aeat_telemetry_endpointis configured. Any missing condition makes this call a pure no-op – nothing is sent – mirroringemit_telemetry_event()’s own no-op contract.- Parameters:
settings (
Settings|None) – Resolved deployment settings; defaults toload_settings().acknowledged (
bool) – Whether the operator acknowledged remote telemetry for this specific invocation. Never sticky; must be re-affirmed on every call.
- Return type:
- Returns:
The
TelemetryFlushPreviewreflecting exactly what was (or, because a condition was refused, would have been) sent for THIS invocation’sacknowledgedvalue.