In fact I think v2 already is a completely satisfactory implementation
the project-local file history feature.
It seems like there are two incompatible behaviors here and you and Juri
want. One is to filter by current project, and another to be able to reuse
previous inputs freely.
If forced to choose, I would be slightly inclined toward the latter (which
could be implemented using text properties, although the concept is
a little awkward). But both are reasonable.
I think we should install one of them and then later (on master) add a user
option to switch to the other behavior.
I agree with Augusto that filtering that implements project-local history
should be the default behavior for emacs-29. I tried your second patch
and it nicely handles even such sequences as `C-x p f' and `C-x p F'.
(and in the opposite direction from `C-x p F' to `C-x p f' it
filters out external files, that is expected and consistent.)
OTOH, `C-x p f M-p' in another project is not my primary workflow.
But if someone wants to keep a plain history, this could be added
later in master, e.g. by a new value of project-read-file-name-function
and a function that is mostly a copy of project--read-file-cpd-relative.
BTW, in a fresh emacs -Q `C-x p f' raises:
Debugger entered--Lisp error: (void-function cl-find-if)
But not sure how important is this case since usually `C-x p f'
is invoked on a project's file when project.el with cl is loaded.