Resolve the effective git author name and email for a merge commit.
Falls back to the agent identity when the caller supplies empty or
all-stripped strings. Sanitization runs BEFORE the emptiness check
so that inputs like “\n” correctly fall back to the agent identity.
Strip null bytes from strings before protobuf/JSON serialization.
Tree-sitter AST parsing can produce null bytes from lossy UTF-8 conversion;
these break protobuf string fields and JSON encoding.