Skip to content

Agent Mesh

mobile: labels are declared in the config file, not with --labels

Tomas Tormoe06f56da8f25
diff --git a/mobile/sam-node-ffi/ffi/ffi.go b/mobile/sam-node-ffi/ffi/ffi.go
index a4d8ac1c..0f6f8fcf 100644
--- a/mobile/sam-node-ffi/ffi/ffi.go
+++ b/mobile/sam-node-ffi/ffi/ffi.go
@@ -56,8 +56,8 @@ type MobileConfig struct {
LogLevel string `json:"logLevel"`
DiscoveryInterval string `json:"discoveryInterval"`
ListenAddrs string `json:"listenAddrs"` // comma-separated
- // Labels are comma-separated key=value claims (same syntax as the CLI
- // --labels flag); they are attested only at enrollment.
+ // Labels are comma-separated key=value claims, the wire format of the
+ // config file's labels map; they are attested only at enrollment.
Labels string `json:"labels"`
AllowLoopback bool `json:"allowLoopback"`
EnableRelay bool `json:"enableRelay"`
@@ -336,7 +336,7 @@ func GetNodeID() string {
}
// labelsFile keeps the enrolled labels in the app's data directory. The CLI
-// has no equivalent: --labels is passed on every run.
+// has no equivalent: it re-reads them from its config file on every run.
const labelsFile = "labels"
func loadEnrolledLabels(dataDir string) (map[string]string, error) {
@@ -350,7 +350,7 @@ func loadEnrolledLabels(dataDir string) (map[string]string, error) {
return api.ParseLabels(string(raw))
}
-// EnrollNode enrolls a node. Labels use the CLI --labels syntax and are
+// EnrollNode enrolls a node. Labels are comma-separated key=value claims,
// minted into the node's Biscuit here — changing them requires re-enrolling.
func EnrollNode(dataDir string, controlPlaneURL string, jwt string, allowLoopback bool, labels string) error {
parsedLabels, err := api.ParseLabels(labels)
diff --git a/site/content/docs/development/mobile.md b/site/content/docs/development/mobile.md
index ecb9839a..bceead30 100644
--- a/site/content/docs/development/mobile.md
+++ b/site/content/docs/development/mobile.md
@@ -41,7 +41,7 @@ To run `sam-node` on mobile with near-zero codebase maintenance, we avoid rewrit
1. **Go FFI Binding Package (`mobile/sam-node-ffi/`)**: Contains CGO-exported functions (`StartNode`, `StopNode`, `EnrollNode`, `GetNodeID`, `FreeString`) which compile into a C-shared library (`.so`) or static archive (`.a`).
2. **Flutter App (`mobile/sam-node-app/`)**: A cross-platform app containing:
- `lib/sam_ffi.dart`: The Dart FFI wrapper loading the Go library and exposing Dart methods.
- - `lib/main.dart`: Simple control UI to enroll and start/stop the background node. The enrollment screen accepts optional labels (comma-separated `key=value`, same syntax as the CLI `--labels` flag). The control plane mints them into the node's Biscuit at enrollment; the app keeps a copy in its data directory and sends it again on every start and Biscuit renewal, so changing labels means re-enrolling. Unlike the CLI, where `sam-node run --labels` has to be passed on every run, the app remembers them. The Attenuation tab accepts local Datalog rules, policies and checks (one statement per line) in place of the CLI's `sam-node.yaml` `attenuation` block; the app stores them as `attenuation.json` in the same data directory and sends them on every start, and the FFI parses them with the same code path the config file uses.
+ - `lib/main.dart`: Simple control UI to enroll and start/stop the background node. The enrollment screen accepts optional labels (comma-separated `key=value`, the wire format of the `labels` map in `sam-node.yaml`). The control plane mints them into the node's Biscuit at enrollment; the app keeps a copy in its data directory and sends it again on every start and Biscuit renewal, so changing labels means re-enrolling. Unlike the CLI, which re-reads them from its config file on every run, the app remembers them. The Attenuation tab accepts local Datalog rules, policies and checks (one statement per line) in place of the CLI's `sam-node.yaml` `attenuation` block; the app stores them as `attenuation.json` in the same data directory and sends them on every start, and the FFI parses them with the same code path the config file uses.
3. **Local Loopback Communication**:
- The Flutter Dart environment controls the node lifecycle (construction, starting, stopping) via FFI.
- Any actual tool registration, discovery, or mesh API queries are performed using standard HTTP JSON-RPC calls over local loopback (`127.0.0.1`) to the `sam-node` sidecar API.