How does IPNS work?

My first guess is it’s something along these lines:

Your client locally stores a pointer to an updatable hash and is programmed to look up the hash when queried. Where in the code could I examine its current state? I’d like to examine it in either the Go or the Node implementations.

I could not find any complete spec on how it is actually implemented. I’ve been trying to navigate the implementations and figure out the code structure, and I figured this was probably best left as a community question. I’d greatly appreciate a pointer to name query and resolution is in Go or Node implementations.

Is there an example implementation in Node?

This discussion contains some info regarding how IPNS currently works and what its limitations are.

I have been looking at the go implementation, since that is what we use. The ipns stuff can be found in https://github.com/ipfs/go-ipfs/tree/master/namesys

not sure about the js impl, but the package structure should be similar.