Relevant anecdata because I've burned many a Claude sessions on this.
If you're using Claude Code, then it's in the harness. At the close of many sessions, I would start a meta conversation over why the LLM would consistently break certain rules. What it found when debugging itself is that some of the "contradicting" rules that I had were in fact, not from my rules. Instead, the instructions from its own harness had phrases telling it to do things like that. When something contradicts, its own instructions would outweigh any custom ones you write. Every rule variant I had tested (including the one that says it overrides the harness instructions - and yes, I've actually tested all the ideas in your comment too) has ultimately been unsuccessful due to this according to the LLM.
I have found that asking the agent why it did X or Y is an essential part of iterating on its harness. It was non-obvious to me, probably because I'm used to having to reverse-engineer why a system does something, but that's not usually necessary with LLMs, unless the harness is complicated and you have to hunt for the instruction it tells you about.
This is one of the reasons I use Pi. Pi’s minimal system prompt avoids contradiction between what the harness writer thinks is best and what the user thinks is best. The user specifies what the user wants and that’s pretty much the end of it.
Does the harness apply when you sue Claude model in third party IDE? like Opencode, or third party adds their harness on top, not replacing it?
You can't trust it's account on why it did something, it does not "remember". It will just make up something plausible sounding.