Skip to content

chore(ai): gate verbose AI logging to avoid emitting user data in release builds #1194

Description

@HankYuLinksys

Description

The AI Assistant logs a large amount of diagnostic detail unconditionally, including router state and conversation content. This is useful during development but should not run in production builds.

Current behaviour

lib/ai/orchestrator/router_chat_controller.dart:

  • Logs the full router context on construction: _log('Router context:\n$routerContext')
  • Logs assistant message previews: textContent.substring(0, ...clamp(0, 200))
  • Logs user message content verbatim

lib/ai/providers/usp_command_provider.dart:

  • _getConnectedDevices() iterates every device and logs name, IP, connection type and signal strength
  • Mesh extender names and MAC addresses are logged
  • buildRouterContext() logs model name, firmware version, WAN IP and per-band SSIDs

generative_ui's AwsContentGenerator additionally debugPrints the request body preview (up to 500 chars), which includes the system prompt and conversation.

Why this matters

Device names, IP/MAC addresses, SSIDs and conversation content are user data. Logging them unconditionally is a privacy concern in shipped builds.

Proposed approach

  • Gate the verbose [AI] logging behind kDebugMode (or an existing project-level log-level mechanism if one is preferred — worth checking what the logger already supports)
  • Keep structural / lifecycle logs (loop iteration, tool name, success/failure, token counts) since they are useful and non-sensitive
  • Drop or redact: full router context dump, message content previews, per-device identifiers
  • The debugPrint calls inside generative_ui need a separate change in the UI kit repo — track separately if it turns out to be needed

Acceptance criteria

  • Verbose content logging is disabled in release builds
  • Device identifiers (IP / MAC / hostname) and SSIDs are not logged unconditionally
  • Conversation content is not logged unconditionally
  • Non-sensitive diagnostic logs (loop progress, tool names, token usage) are retained
  • flutter analyze clean

Context

Follow-up to #929.

Metadata

Metadata

Assignees

Labels

2.xLabeled for 2.x versionUIenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions