You can rely on dbclient_writer to have forward declared (or included the headers for) anything in the interface. But you should add forward declarations in this file for things in your private implementation. So add fwd decl for BSONObjBuilder in this file.

Also in other writer.