How can I pass replacement rules to a package-defined function and have it understand their context?

You can make use of Formal Symbols.

BeginPackage["Test`"];
replace::usage = "Returns \[FormalV]/.rules.";

Begin["`Private`"];

 replace[rules_] := \[FormalV] /.rules

End[];
EndPackage[];

Then in the notebook.

replace[\[FormalV] -> 0]
(* 0 *)

enter image description here

Hope this helps.


is there some way to take the call ReplaceAll[var, rules]and make it forget contexts for a minute?

BeginPackage["Test`"];
replace::usage = "Returns var/.rules.";
print;
Begin["`Private`"];
replace[rules_] := ReplaceAll[Symbol[$Context <> "var"], rules]

End[];
EndPackage[];

Not general, but works.


Try

replace[rules_] := ReplaceAll[Global`var, rules]

in your function. Then

replace[var -> 0]
replace[Test`Private`var -> 0]

yields

0
var

as I think you'd like.