How do snap channels work

My understanding have been that the install/update process is basically

  • Download the assert
  • Download the snap
  • Ack the assert
  • Install the snap

It seems that the assert does not contain any information about the channels. So how does snapd “know” for subsequent updates which channel it will be tracking.

Does it read from the “sequence” block of a snap in /var/lib/snapd/state.json

In my current store implementation which basically

  • Downloads the assert and snap
  • Acks assert and install snaps

I am looking to implement a way where I can keep a track of which channel my snap is tracking and hence on subsequent updates “know” where to pull the update from.

This information is stored in snapd state:

  "ohmygiraffe": {                    
    "type": "app",                              
    "sequence": [                                                                  
        "name": "ohmygiraffe",                                                                                                                                                                                                                                                                                                                                                                 
        "snap-id": "OZ7LxjGo2W76qWvpNpiklbRtCA4u84L3",                                                                                                                                                                                                                                                                                                                                         
        "revision": "7",                                                                                                                                                                                                                                                                                                                                                                       
        "channel": "latest/stable",                                                                                                                                                                                                                                                                                                                                                            
        "name": "ohmygiraffe",        
        "snap-id": "OZ7LxjGo2W76qWvpNpiklbRtCA4u84L3",
        "revision": "10",                                                          
        "channel": "latest/edge",                                                                                                                                                                                                                                                                                                                                                              
    "active": true,        
    "current": "10",                                  
    "channel": "latest/edge",  <----- this
    "user-id": 1                  

the entries in sequence are just bookkeeping iirc. If you look at the store API, there’s a tracking-channel field included in the request It’s probably easiest if you take a look at snapd source code in the snapstate and store packages.