Term Expansion issue when consult is called from a Module (was: How to get "Consult('Test.pl'), predicateFromInsideTest." to run)

Turns out I think the issue is related to the issue described in this thread.

The server is running in a module called “prologServer”:

% PrologServer.pl
:- module(prologServer,
          [ ... ]).
...
serve_loop(ReadStream) :-
    read_term(ReadStream, Command, []),
    call(Command),
    serve_loop(ReadStream).
...

I first ask the server to consult("TermExpansion.pl") which defines a term expansion:

% TermExpansion.pl
term_expansion(expandMe(X), [(writeMe(X) :- (writeln(X)))]).

Then I then ask the server to consult("ExpandedTerms") which defines a term to expand. This file is a module and exports the term that is created by expansion:

% ExpandedTerms.pl
:- module(expandedTerms,
          [ writeMe/1
          ]).
expandMe(X).

The error I get when I run that sequence is: “ERROR: Exported procedure expandedTerms:writeMe/1 is not defined”.

I believe that when the code in the prologServer module processes consult("TermExpansion.pl"), the term_expansion/2 term is not being loaded into the user: module. I suspect it is loaded into the prologServer module? Since that is where the code that does call(Command) is? Maybe?

If I simply consult the two files from the Prolog top level, it works fine, since the term_expansion/2 term is put in the user: module and found.
[edit: also note that moving the server code out of a module also fixes it…]

Adding user: in front of term_expansion/2 fixed it when running in the server. Like this:

% TermExpansion.pl
user:term_expansion(expandMe(X), [(writeMe(X) :- (writeln(X)))]).

Does consult/1 process files differently based on where it is called from? Or is there some other explanation here?