Undestanding sentinel info docs

I’m trying to figure out the sentinel role in the cht ecosystem
I had in mind that sentinel is listening to the couchdb _changes feed and if a transition is set to react to a given change sentinel reacts like with outbound tasks or death_reportin transition

but now I notice that sentinel reacts to all docs, even if a transition is not configured for this doc and for every created doc, sentinel produces an info doc with the initial replication date, and last replication date to the same value, but if the doc is edited, what does sentinel do ?

Sentinel edits the same info doc and set the last_replication_date to the date at which the doc was edited ?

is this right ? is this done to log all changes in the database for every doc?

thank you

sentinel is listening to the couchdb _changes feed and if a transition is set to react to a given change sentinel reacts like with outbound tasks or death_reportin transition

All 100% correct.

sentinel reacts to all docs, even if a transition is not configured for this doc

So, each individual transition in Sentinel defines what kind of documents it should executed on. If the filter function on a transition returns true, then Sentinel will pass the doc to the transitions onMatch function. So, yes, Sentinel “reacts to all docs” in the sense that it has to take every incoming change and pass the doc to the filter function of each enabled transition (to see if the transition should be applied for that doc). However, the doc is only passed to the onMatch function if filter returns true.

for every created doc, sentinel produces an info doc with the initial replication date, and last replication date to the same value, but if the doc is edited, what does sentinel do ?

Sentinel edits the same info doc and set the last_replication_date to the date at which the doc was edited ?

Yes, this is also correct. Additionally, in that info doc, Sentinel records all the transitions executed for that doc and the last_rev which is the _rev of the doc the last time the transition was executed for that doc. All this data allows transitions to easily include logic in their filter method to prevent re-executing the transition when it has already been run for that doc.

is this done to log all changes in the database for every doc?

Not really. It is true that the changes in the feed result in changes to the Sentinel info docs, but the way I understand it, the data in the info docs is a close-to-real-time record of just the latest change for each doc (and associated transition run data). The Sentinel info docs are NOT a longitudinal record of doc changes over time.

I hope that helps a bit, but let me know your follow up questions!

1 Like

THank you @jkuester for your time, your answer does really make sense to me.

1 Like