yeah. If g() rely on a setup function but that setup function is “hot swapable”, you should make that an input and have a default maybe. Think count. which by default the by function is identity, this pattern is common.
silently mutating the f() that g() ends up calling is pretty hacky, and hard to undo from the user end if they somehow uses your extension package but want to do the “original” thing – it ends up being a import-order-dependent issue then?