I managed to resolve my issue to the point where I can at least debug the app. I'm not sure yet if my solution resolves the issue for good, but it's good enough for being able to test.
It was indeed a weird caching issue by macOS.
I'll document it here in hopes that it may help others resolve this issue in the future.
We're developing an app that uses a different target / bundle ID for the developer ID build and the App Store one. Additionally the same applies to the Login Item we're launching, where the same login item has a developer ID target and an App Store target with different bundle IDs.
What caused this issue in the first place?
I believe the trigger for this issue was that when I set up the developer ID build of our App, I added the wrong login item. This caused in our developer ID app being associated with the App Store login item in launchctl.
I changed the agent after realizing the mistake but the App Store Agent would never launch.
How I debugged this
I initially focused on checking the parent app / login item association that you can see by calling:
sfltool dumpbtm
The association returned by that tool was correct, and nothing in it seemed off.
I tried resetting it through sfltool resetbtm, but that didn't work at all.
At some point I started diving deeper into launchctl, and used this command to get a very detailed state report:
launchctl dumpstate > out.txt
And when looking for my agent's bundle ID I realized that launchctl was showing a different association with the wrong parent bundle ID.
The snippet looked more or less like so:
gui/userid/teamid.my.agent.bundle.id = {
active count = 0
path = (submitted by smd.299)
type = Submitted
state = spawn scheduled
program identifier = teamid.my.agent.bundle.id (mode: 1)
parent bundle identifier = developer.id.bundle.id.instead.of.app.store.bundle.id
Resolution:
Once realizing that association was off... I looked at this file:
/var/db/com.apple.xpc.launchd/loginitems.userid.plist
It contains an association between login items and parent bundle IDs.
I manually edited the file to correct parent app bundle ID. Cleaned everything, rebooted, et voila!
Hope it helps.