Why separate `src` and `lib`?

Why are there separate src and lib folders for code?

This structure used to work for me:

/ProjectDir/src/main.cpp
/ProjectDir/src/Foo/Bar.cpp
/ProjectDir/src/Foo/Bar.h

It used to work for me, because – now that I want to start unit–testing – apparently files from Foo dir are NOT available when running pio test -e native.

OK, the instruction is in the docs: Shared Code — PlatformIO v6.1 documentation

So I moved my files like this and the Unity tests started working:

/ProjectDir/src/main.cpp
/ProjectDir/lib/Foo/src/Foo/Bar.cpp
/ProjectDir/lib/Foo/src/Foo/Bar.h

The question is WHY? The Bar class is not a “library”, it is just a file with a class that is INTERNAL to the project. It is part of the project sources, I thought src dir is for that… [?]

I’m kinda new to C/C++ in general, but I guess there would be a historical reason to put “external” files [“library”/“vendor”] into the lib dir. Nowadays we have dependency managers that download such code. PlatformIO does it. But it does not put external dependencies to lib dir, but rather hides it inside .pio [that’s ok for me].

The only logical reason for me to use lib dir would be to download external lib “by hand” and put it into my project “by hand” to the lib dir to keep it separate from my source files.

So… the question, to sum up, is… why am I required to put my source files in the lib dir?