the ones that might be relevant to social/break-related things being "TIME_SINCE_BREAK" and "ON_BREAK". In lua, these counters (and a lot more) can be found in the unit's status.misc_traits (provided they're active/whatever)
Hm, I can try those, although I'm not sure they're used any more in the current game version; in my fort of 112 citizens, not a single one has a misc_trait with id 16 (TimeSinceBreak) or 17 (OnBreak). Also, the problem I'm having isn't just with dwarves aborting my forced social activity for an actual job (teal text); they'll take a few steps pathing toward my activity and then stop and switch to a different idle activity (i.e. stop walking to the temple and instead go to Individual Combat Drill or to the library to read). That's why I was hoping to figure out the criteria for Purple! idle activities, to maybe get them to stick with what I assigned and not switch to something else.
The strength of a need can be modified in the unit's status.personality.current_soul.personality.needs, by changing its focus level. I know that a value of 400 is what it's set to when the need is met, and I believe that the value lowers as they get less focused, into the negatives. The numbers listed on the wiki are probably right for reference. You might be able to get dwarves having purple needs by just setting the focus value super low.
Yes, those are the focus level values that I'm scanning for dwarves with severely unmet needs (for example I had a military dwarf with -200000 PrayOrMedidate, which I think is the lower limit, because he would always drill in his idle time and never pray).
After some experimentation though, I'm pretty sure the Purple! indicator isn't really very meaningful. I just compared the need data for a bunch of dwarves currently engaged in purple "Socialize!"/"Pray!" and green "Socialize"/"Pray" activities, and the determining factor seems to be whether the dwarf has Socialize, PrayOrMedidate, BeCreative, Excitement or AdmireArt focus levels of -10000 or lower, but there was no link between the activity and the actual urgent need -- a dwarf with -10k Socialize and +10k PrayOrMedidate would still show "Pray!", a dwarf with -10k BeCreative and +10k everything else would still "Socialize!", etc.