Okay, I acknowledge your search-in/search-for distinction. That makes the current behavior seem even more deviant.
In fact, at the implementation level, searching-for involves searching-in. More generally, a search is always within some context, and the structure of that context (list, tree, DAG, hash table, data base, etc.) bounds and governs the nature of the search and the methodology used. One can choose to ignore that structure and always search "everything" (treating the structure as an unordered set, for example), in general this approach won't be what users expect or what the application should implement. I think you agree with this.
There is a hierarchical relation (abstractly among Gallery/Album/Subalbum/Image, and concretely at the implementation level among Directory/Subdirectory/File), and this permeates the Zenphoto design and implementation. For example, in the admin Search page, you can constrain the search not to return album matches or image matches. But this is all somewhat pedantic. Zenphoto itself can be considered as a high-level data structure (built on more fundamental ones), and perhaps construed in that way some of its more esoteric properties were never formalized at the design stage.
However, always doing a Gallery-wide global search (when searching from any album or subalbum, no matter where it is in the hierarchy) would surely be regarded as bizarre by most, if not all, users. Users want to be able to search clearly identifiable portions of the content, and to do so on the basis of how the content and its organization is represented in the interface. I'm pretty sure you agree with this as well. The current behavior appears to violate this. There's nothing wrong in supporting fully global search from any location, but I think that should not be the only option. I also think it should not be the default, but there's room for argument there.
In fact, your last remark is exactly to the point. I am searching FOR images (or in some cases FOR albums, and more generally FOR "things") that have certain monadic properties. But if I search "from" two different places that should yield identical results, the results are not identical. And the measure of how unintuitive and unexpected this is that it required examining the code to see what was being done and whether there is some way of justifying that. There doesn't seem to be.
(Aside: This could be regarded as an interface issue (though I'm not inclined to do so). The appearance of a search box and button ON a page says -- intuitively, to the user -- search for what I'm going to specify WITHIN what I'm seeing displayed on the current page. If you would want to make the search always global across the Gallery (which I REALLY don't like), then you should either remove the search box/button from the page (and move it to some "tools" area -- which has its own problems), or at the very least change the label from "search" to "gallery search" or something like that. Just some thoughts. I don't recommend it.)
In any event, thanks very much for the effort you've put into this and for your explanations. A very interesting discussion, and informative to me. Whatever Zenphoto decides to do about it (or not), it points me in the direction of how to (from my perspective) "fix" it in accord with my own requirements.