A resource is known to be not running if it has a resource history in the CIB status section that evaluates that way. A resource has unknown status if it has no resource history (whether at cluster start-up or after a cleanup).
This likely has numerous spots in code that are related, and may need to spin off smaller projects as they are found. Finding them will likely be the most time consuming part. Status displays (such as via crm_mon) will likely be the problematic part; the actual scheduling code should hopefully do the right thing already.
One problem is the pcmk__resource_private_t:active_nodes member. The code that uses it presumes that it lists all nodes where the resource is active. However it actually lists all nodes where the resource is known to be active. If a node has no history for the resource, it might or might not be active there.
See also:
- RHEL-68674: the particular case where crm_resource --locate returns NOT running for a resource that is actually running but has no history.