For what it's worth, this is something we've struggled with at New Vector (vector.im), the company we set up to keep the core Matrix.org dev team gainfully employed. On one hand, we don't want a nightmare where a rogue employee goes and claims that the work they did on the day job is actually their personal IP and tries to relicense or patent it somehow. On the other hand, 90% of what we do is open source and it's critical to let everyone keep hacking on their personal FOSS projects unencumbered.
The current UK employment contracts try to solve it with this construct: 10.2.1 is a general "everything you do belongs to the company", and then 10.2.2 carves out "...except for stuff you do in your spare time, if it's unrelated to your dayjob work". We (happily) haven't had to try it in anger yet, but hopefully it's a reasonable enough compromise. Pretty much everyone in the UK had unilateral "everything you do belongs to the company" contracts in previous gigs, so in theory it's an improvement.
---
10.2.1 You shall give the Company full written details of all Inventions and of all works embodying Intellectual Property Rights made wholly or partially by you at any time during the course of your employment which relate to, or are reasonably capable of being used in, the business of the Company. You acknowledge that, save as set out below, all Intellectual Property Rights subsisting (or which may in the future subsist) in all such Inventions and works shall automatically, on creation, vest in the Company absolutely. To the extent that they do not vest automatically, you hold them on trust for the Company. You agree promptly to execute all documents and do all acts as may, in the opinion of the Company, be necessary to give effect to this clause 10.2.
10.2.2 The above is subject to it being agreed that Intellectual Property Rights created by you outside the reasonable scope of your work for the Company and not related to the business of the Company (provided in any case that they are created outside working hours) may be retained by you. This policy seeks to strike a balance between providing creative freedom for employees to pursue their own interests outside of work with an understanding that creations and advances which should properly be for the benefit of New Vector or Matrix will be assigned to the relevant one of them.
The problem is "related to the business of the company". For a small company, that may seem reasonable, because the company probably only does one or two things. However, for a large company like Google, that basically means "everything".
In my opinion, the right approach is to instead talk about your work duties at the company. If you work on your own time on something unrelated to your work duties, but related to someone else's at the company, you should still get to keep full rights to your work. If you weren't asked to do that work for your job, why would the company have a right to the result, even if they find they have some interest in it?
The current UK employment contracts try to solve it with this construct: 10.2.1 is a general "everything you do belongs to the company", and then 10.2.2 carves out "...except for stuff you do in your spare time, if it's unrelated to your dayjob work". We (happily) haven't had to try it in anger yet, but hopefully it's a reasonable enough compromise. Pretty much everyone in the UK had unilateral "everything you do belongs to the company" contracts in previous gigs, so in theory it's an improvement.
---
10.2.1 You shall give the Company full written details of all Inventions and of all works embodying Intellectual Property Rights made wholly or partially by you at any time during the course of your employment which relate to, or are reasonably capable of being used in, the business of the Company. You acknowledge that, save as set out below, all Intellectual Property Rights subsisting (or which may in the future subsist) in all such Inventions and works shall automatically, on creation, vest in the Company absolutely. To the extent that they do not vest automatically, you hold them on trust for the Company. You agree promptly to execute all documents and do all acts as may, in the opinion of the Company, be necessary to give effect to this clause 10.2.
10.2.2 The above is subject to it being agreed that Intellectual Property Rights created by you outside the reasonable scope of your work for the Company and not related to the business of the Company (provided in any case that they are created outside working hours) may be retained by you. This policy seeks to strike a balance between providing creative freedom for employees to pursue their own interests outside of work with an understanding that creations and advances which should properly be for the benefit of New Vector or Matrix will be assigned to the relevant one of them.