feat(pool): a member's pin reaches its pool, rounded as its owner chose #592

Merged
admin merged 1 commits from feat/share-location into dev 2026-10-21 02:51:26 +00:00
Owner

This is slice 2b of #573. With #586 the owner can save a pin for the node and choose how much of it other members may see. This PR sends that pin to the pool, rounded to the owner's choice and no finer, so other members can place the node.

What changes:

  • The worker's Hello carries an optional shared_location (latitude and longitude). The worker rounds it with geo.Shared before it is sent: unchanged for exact, to 0.01° for about-1km, to 0.1° for city. For country or nothing, or when there is no pin, the field is left out. The exact pin leaves the machine only when the share is exact.
  • When the owner changes or clears the pin through SetNodeLocation, the pool sees it at once, with no reconnection. The local API tells the worker, and the worker sends a heartbeat with a new LocationUpdate. The update holds the new place, or nothing when sharing has stopped. The same notice also reaches the workers this node runs for other nodes it works for. A change made with sisyphusd location set while the node is running is sent the next time the worker connects, and the command now says so.
  • The coordinator keeps the place with the worker and passes it on unchanged in NodeInfo.shared_location (ListNodes, which only clients may call). It checks only that the coordinates are a place on the Earth. Coordinates out of range are treated as no place.
  • The local API maps it to Worker.shared_location in ListWorkers and WatchWorkers. ListWorkers includes it only for a caller that presents the token, the same rule GetNodeInfo uses for the owner's own pin. When the field is absent, the node shares no coordinates.
  • sisyphusd nodes adds a line below its table for each node that shares a place, such as rig: shared place 48.9, 2.4. This follows the existing per-node lines for models and standing.
  • Docs: apps/sisyphusd/README.md describes what is shared and when. docs/user-guide.md has a table of what other members see for each choice. docs/security-model.md has a short "Where a node is" section: other members see the rounded place the owner chose and nothing more, and the place is the worker's own claim.

Backward compatibility: older workers send nothing and are listed with no place, and older coordinators ignore the new fields. A heartbeat without the new field leaves the place as it was. Tests cover an old-style hello and old-style heartbeats.

Not done here: the globe placing other members by their shared place. That is the desktop's next step, after #590. Peer (libp2p peers) is unchanged. The place belongs to pool membership, and peers that are not in the pool are not told.

How it was tested:

  • Worker tests (worker/location_test.go): the hello carries the place, word of a change sends one update and an unchanged place sends nothing, an update when sharing stops carries no place, and a worker with no place or no source says nothing.
  • Raw-protocol tests against a real coordinator (shared_location_test.go): an old-style hello, an out-of-range hello, a heartbeat with no location field, moving, clearing, and an out-of-range update.
  • An end-to-end daemon test: a pin saved with the CLI at city share shows up in ListWorkers rounded to 0.1°, and in sisyphusd nodes. Without the token it is absent. Changing to about-1km, exact, country, city and clearing through the API each reach the pool without a restart.
  • The guest-work test checks that a worker running for another node passes the change on to that node's pool.
  • make cover reports every statement covered. gofmt and go vet are clean, and npm run -s typecheck in apps/sisyphus passes after regenerating the TS client.
This is slice 2b of #573. With #586 the owner can save a pin for the node and choose how much of it other members may see. This PR sends that pin to the pool, rounded to the owner's choice and no finer, so other members can place the node. What changes: - The worker's `Hello` carries an optional `shared_location` (latitude and longitude). The worker rounds it with `geo.Shared` before it is sent: unchanged for exact, to 0.01° for about-1km, to 0.1° for city. For country or nothing, or when there is no pin, the field is left out. The exact pin leaves the machine only when the share is exact. - When the owner changes or clears the pin through `SetNodeLocation`, the pool sees it at once, with no reconnection. The local API tells the worker, and the worker sends a heartbeat with a new `LocationUpdate`. The update holds the new place, or nothing when sharing has stopped. The same notice also reaches the workers this node runs for other nodes it works for. A change made with `sisyphusd location set` while the node is running is sent the next time the worker connects, and the command now says so. - The coordinator keeps the place with the worker and passes it on unchanged in `NodeInfo.shared_location` (`ListNodes`, which only clients may call). It checks only that the coordinates are a place on the Earth. Coordinates out of range are treated as no place. - The local API maps it to `Worker.shared_location` in `ListWorkers` and `WatchWorkers`. `ListWorkers` includes it only for a caller that presents the token, the same rule `GetNodeInfo` uses for the owner's own pin. When the field is absent, the node shares no coordinates. - `sisyphusd nodes` adds a line below its table for each node that shares a place, such as `rig: shared place 48.9, 2.4`. This follows the existing per-node lines for models and standing. - Docs: `apps/sisyphusd/README.md` describes what is shared and when. `docs/user-guide.md` has a table of what other members see for each choice. `docs/security-model.md` has a short "Where a node is" section: other members see the rounded place the owner chose and nothing more, and the place is the worker's own claim. Backward compatibility: older workers send nothing and are listed with no place, and older coordinators ignore the new fields. A heartbeat without the new field leaves the place as it was. Tests cover an old-style hello and old-style heartbeats. Not done here: the globe placing other members by their shared place. That is the desktop's next step, after #590. `Peer` (libp2p peers) is unchanged. The place belongs to pool membership, and peers that are not in the pool are not told. How it was tested: - Worker tests (`worker/location_test.go`): the hello carries the place, word of a change sends one update and an unchanged place sends nothing, an update when sharing stops carries no place, and a worker with no place or no source says nothing. - Raw-protocol tests against a real coordinator (`shared_location_test.go`): an old-style hello, an out-of-range hello, a heartbeat with no location field, moving, clearing, and an out-of-range update. - An end-to-end daemon test: a pin saved with the CLI at city share shows up in `ListWorkers` rounded to 0.1°, and in `sisyphusd nodes`. Without the token it is absent. Changing to about-1km, exact, country, city and clearing through the API each reach the pool without a restart. - The guest-work test checks that a worker running for another node passes the change on to that node's pool. - `make cover` reports every statement covered. gofmt and `go vet` are clean, and `npm run -s typecheck` in `apps/sisyphus` passes after regenerating the TS client.
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Sisyphus/Sisyphus#592