networkmanager: the watcher names no node; the bundle fills in its own

The node-engine gives the watcher's process no MESH_NODE, so the watcher refused to
start and crash-looped on g14. It needs none: a kept change holds its event, its
sequence and its body, and the bundle fills its own node into the subject, the message
id <node>.<event>.<sequence> and the body when it publishes, the same at every publish.

Builds: design 08 sign-in-page §11, §12, §20; lead answer L-3 (hq 09c9a3e3)
This commit is contained in:
jochen
2026-11-25 14:32:03 +01:00
parent 17e1bfb6d3
commit e539cf6e99
8 changed files with 151 additions and 58 deletions
@@ -180,13 +180,10 @@ func newWatcher(f Folder) *Watcher {
// watch is `uplink-tools watch`: the watcher, until its process is stopped.
func watch([]string) error {
f, err := theFolder()
f, err := accountFolder()
if err != nil {
return err
}
if f.Node == "" {
return errors.New("no node named: the node-engine names it in MESH_NODE")
}
if err := os.MkdirAll(f.Dir, 0o700); err != nil {
return err
}
@@ -410,7 +407,7 @@ func (w *Watcher) asked(r Rating) {
now := w.Now()
w.ask = &openAsk{Network: r.Network, Link: r.Link, Since: now, connection: r.Connection, address: r.CheckURI}
w.state.AsksOpened++
w.keep(eventAsked, nodeuplink.SignInAsked{Node: w.Folder.Node, Link: r.Link, Network: r.Network, Address: r.CheckURI,
w.keep(eventAsked, nodeuplink.SignInAsked{Link: r.Link, Network: r.Network, Address: r.CheckURI,
At: stamp(now)})
w.present(nil, r.Network, r.CheckURI)
}
@@ -421,7 +418,7 @@ func (w *Watcher) ended(link, network, why string) {
w.state.AsksEnded++
}
w.ask = nil
w.keep(eventEnded, nodeuplink.SignInEnded{Node: w.Folder.Node, Link: link, Network: network, At: stamp(w.Now()), Why: why})
w.keep(eventEnded, nodeuplink.SignInEnded{Link: link, Network: network, At: stamp(w.Now()), Why: why})
}
// stamp is a time as the events say it: RFC 3339 in UTC, to the second.
@@ -429,12 +426,12 @@ func stamp(t time.Time) string { return t.UTC().Truncate(time.Second).Format(tim
// keep writes one event into pending/ and holds the folder to its bound, the oldest dropped with a journal line.
func (w *Watcher) keep(event string, body any) {
k, err := w.Folder.keep(event, eventSubject(event, w.Folder.Node), body)
k, err := w.Folder.keep(event, body)
if err != nil {
journal("keeping %s failed: %v", event, err)
return
}
journal("kept %s as %s", event, k.MessageID)
journal("kept %s", k.Name())
kept, err := w.Folder.pending()
if err != nil {
journal("reading the kept events failed: %v", err)
@@ -442,11 +439,11 @@ func (w *Watcher) keep(event string, body any) {
}
for i := 0; len(kept)-i > keptBound; i++ {
if err := w.Folder.drop(kept[i]); err != nil {
journal("dropping the kept event %s past the bound of %d failed: %v", kept[i].MessageID, keptBound, err)
journal("dropping the kept event %s past the bound of %d failed: %v", kept[i].Name(), keptBound, err)
continue
}
w.state.DroppedPastBound++
journal("dropped the kept event %s past the bound of %d", kept[i].MessageID, keptBound)
journal("dropped the kept event %s past the bound of %d", kept[i].Name(), keptBound)
}
}