Surprised nobody has mentioned this yet, but Org-mode for Emacs [1] is just great, and fits very well to the requirements:

- Source of truth: these are text files, so any of git, nextcloud, syncthing etc. will do.

- Consistent interface: using emacs might be tough on mobile, but there are some pretty good web interfaces for it [2]. I personally use Orgzly [3] and syntching on my Android

- Standard protocols: custom scripting does anything. ical is pretty easy to handle, not sure about webdav.

- FOSS: check

- Multiple calendars: yep, via Org agenda [4]

- Subtask support: As deep as you can go

- Custom logic: via emacs scripts (or some creativity if you're using other clients)

- Markdown notes: yes, minimal differences between org mode and markdown

[1] https://orgmode.org/

[2] https://github.com/DanielDe/org-web

[3] https://www.orgzly.com

[4] https://orgmode.org/manual/Agenda-Views.html

Yes. Org mode is fantastic.

However, some limitations/ drawbacks.

- org-agenda is slow and completely unusable if you have hundreds of org files.

- despite multiple half-baked efforts there is still no easy-to-use parser and pretty printer for the lanuguage. I'm not even asking for 100% of the syntax, 20% capability of t he built-in org-element API with good documentatiom will accomplish 80% of the requirements.

- no easy way to integrate calendars and org-agenda with something like a calDav server.

JFYI, there's an excellent package org-ql which works quite nice with many org files. It has org-ql-view built in, which works like org-agenda.

(https://github.com/alphapapa/org-ql)