Thanks very much for the detailed answer, and my apologies for causing you extra work.
the compiler does store the included files and their timestamps in the PPU.
/Aha/, that's something I didn't adequately appreciate.
That's actually an argument that you could probably use when tiresome people (such as, on occasion, myself) opine that there could usefully be an accessible preprocessor stage: it would need some way of annotating the .ppu later produced by the compiler.
I say likely, because if you only change a typo in a comment and that change doesn't lead to a change of the file position for the remainder of the code (meaning for example that you didn't insert or remove a line) then the relevant content of the unit (from the compiler's PoV) is still considered the same and thus the compiler doesn't see the need to recompile Y.
Interesting. Something I'm tinkering with at the moment uses the Linux FAM API, and I noticed an interesting situation where a changed file (containing test data) was always detected if touched etc. but wasn't detected reliably if simply /saved/ by Lazarus. Leaving aside for the moment the potential that the IDE has for not really saving something that hasn't had a significant change (e.g. all changes have been undone), that turned out to mainly be because Lazarus was using the "unix doctrine" of renaming the original and creating a new file.
To come back to your problem: as you see it should work correctly. However we know from past experience that something there is fishy when multiple include files are used, but we've not yet been able to pinpoint the problem. Or maybe it was indeed solved already. That's the problem: we don't have a reproducible case and thus don't know whether the problem has been solved or not.
Bearing that in mind, I think I'll try having separate .itf files when I've next got something I'm building as a library, and will also revisit the project I mentioned a few posts ago where stuff wasn't getting recompiled. I'll report back presently if I can pin a reliable test case down.
MarkMLl