Details documents of non-running nodes may contain "running":true
The "running" field of details documents is not always updated correctly. Example:
https://onionoo.torproject.org/details?fields=running&running=false&limit=10
{"relays_published":"2014-07-18 13:00:00",
"relays":[
{"running":false},
{"running":true},
{"running":true},
{"running":true},
{"running":false},
{"running":false},
{"running":true},
{"running":true},
{"running":false},
{"running":true}
],
"bridges_published":"2014-07-18 12:37:04",
"bridges":[
]}
Here's how this happens: we only write details JSON documents if the node published a descriptor or was listed in a consensus published by the directory authorities. That's the general design for writing JSON documents, and it saves us from updating JSON documents that haven't changed. However, if a node drops out of the consensus, it's not contained in any descriptor, hence we won't rewrite its details JSON document.
I came up with an idea for a new approach that also rewrites the details JSON documents of relays that dropped out of the consensus: all JSON documents are based on the contents of internal status files, and we can keep record of which status files are updated in an execution. If we include whether a node is running in a node status file, we notice when the running state changed and can rewrite the details JSON document. I have a branch with this change, but I'm not brave enough to deploy it, because it has zero unit test coverage. I'll either do another careful review or include this code in unit tests.