Skip to content

Owner account: sign in with your companion, link your nodes, manage their station data #1018

Backlog

Description

@dborup

Problem

Two separate "claim" features exist today:

My Mesh ("Claim your first node" on Home) Antenna and station (owner) on the node page
Proof of ownership None: search for the node and press the button Yes: a code in the node's name, sent in a signed advert
Stored Only in the browser's localStorage (meshcore-my-nodes) In the database, one claim per node
Several nodes Yes, but only in that one browser One code and one advert per node, every time

An owner with many repeaters has to rename and advert each one for every change. Their "My nodes" does not follow them to another device.

Proposal (owner, 2026-11-28): an owner account, signed in with your companion

  1. Sign in with your companion. The identity is the public key of the companion radio you carry. There is no password and no e-mail. Two possible ways:

    • A: the same mechanism as antenna claims. The page gives a code, you put it in the companion's name and send a flood advert, and an observer hears it.
    • B: a direct message with the code to a MeshView node on the mesh. This needs a MeshView companion radio.

    After sign-in the browser gets a signed session, so the read-only server can recognise it without a DB write. All writes go through the ingestor, as for antenna claims.

  2. Link nodes to the account. Each repeater must still be proven once, so an account can never take someone else's node. Ways to make that easier:

    • One account code for many nodes: put the same code in each repeater's name and send an advert from each.
    • A firmware owner field: observers already have set mqtt.owner <pubkey>. If repeaters have, or could have, an owner field carried in signed packets, no renaming would be needed. This must be checked in the firmware, not assumed (AGENTS.md rule 7).
  3. What the account gives:

  4. Privacy:

    • Who owns which nodes is not public. At most it shows "verified owner", or a display name the owner chooses.
    • The companion key is never shown.
    • The account can be deleted, which removes its links. Approved station data stays unless the owner also removes it.

Research first (M0, no code)

  1. Firmware (read firmware/, MeshCore source):
    • whether a companion's adverts can carry the sign-in code (name length, flood vs zero-hop, how often an observer hears them);
    • whether a repeater has, or can be given, an owner field that appears in signed packets;
    • what option B would need.
  2. Session design under the read-only server (bug(db): vacuumOnStartup fails with SQLITE_BUSY when ingestor + server share DB (auto_vacuum migration #919 broken in single-container topology) Kpa-clawbot/CoreScope#1283):
    • a stateless signed token (key handling, expiry, revocation);
    • how account writes flow through the ingestor, as the antenna-claim request queue does.
  3. Data model:
    • accounts, node links and proof records;
    • how the existing antenna claims and station details attach to an account without breaking per-node claims;
    • the migration;
    • retention and deletion.
  4. Security:
    • replay of codes, stolen sessions, an attacker who controls a node temporarily, rate limits;
    • what an account must never be able to do (take a node with a newer proof by its real owner, see contactAdmin).
  5. UI:
    • sign-in at 375×560;
    • "My nodes" with the My Mesh migration;
    • linking a node;
    • bulk station-detail editing.
  6. Plan: milestones (for example M1 sign-in and synced "My nodes", M2 node linking, M3 managing station data for linked nodes), each with tests, perf notes and customizer implications (rule 8).

Related: #789, #898, #1007, #1017, #262 (My Mesh).

🤖 Generated with Claude Code

Activity

  1. dborup commented on Nov 28, 2026

    @dborup
    OwnerAuthor

    Research (M0) — #1018

    Owner account: sign in with your companion, link your nodes, manage their station data.

    This is research only. I wrote no code, made no commits and opened no PR. Nothing was sent to a live instance or a broker.

    Sources and labels

    Source Version Use
    CoreScope origin/master fe32ee49 (2026-11-28), read with git show / git grep claims, queue, schema, read-only invariant, My Mesh
    MeshCore firmware (upstream meshcore-dev/MeshCore) 75b04ef0 (2026-11-14), shallow clone in a scratch directory adverts, companion protocol, repeater owner info, DMs
    MQTT observer firmware fork (agessaman/MeshCore) branch mqtt-observer-plus f35341cf (2026-07-11); cross-checked on mqtt-bridge-implementation 460d254f where set mqtt.owner lives and where the value goes
    Issues #1018, #789 (both M0 reports), #898 (M0), #1007, #1017 (M0), #262 context and earlier decisions

    Labels:

    • [F] I read it in firmware source at the cited file:line (upstream unless the fork is named).
    • [K] I read it in CoreScope origin/master at the cited file:line.
    • [A] Assumption, inference or judgement. Not verified in source.

    1. Conclusions

    1. Option A works for a companion, with one difference from repeaters: the name budget is usually 31 bytes, not 23. [F]

      • The companion app sets the name with CMD_SET_ADVERT_NAME and sends the advert with CMD_SEND_SELF_ADVERT, where byte 1 = 1 means flood and anything else zero-hop (examples/companion_radio/MyMesh.cpp:1259-1265, :1297-1313).
      • A companion advert is a normal signed advert of type ADV_TYPE_CHAT (src/helpers/BaseChatMesh.cpp:21-41), so CoreScope's existing signature check and code matching apply unchanged.
      • A companion shares no position by default (advert_loc_policy = 0 = ADVERT_LOC_NONE, examples/companion_radio/NodePrefs.h:11,33). The name then gets 31 bytes. With position sharing on it gets 23 bytes (src/helpers/AdvertDataHelpers.cpp:4-29, src/MeshCore.h:12).
      • The companion does not advert periodically (the interval prefs are commented out, NodePrefs.h:195-196), and the device's own button sends zero-hop (MyMesh.cpp:2436-2448). The owner must press "flood" in the app.
    2. No upstream repeater or room server has an owner field in any signed or passively observable packet. [F]

      • owner.info (char[120], src/helpers/CommonCLI.h:67) is never put in an advert (CommonCLI.cpp:170-181).
      • It is returned only to a requester: by the anonymous owner request, which must be direct-routed and is rate-limited (examples/simple_repeater/MyMesh.cpp:56,165-182,586-587,869), or after a login (:51,372-373). Both replies are encrypted to the requester.
      • Room servers, sensors and companions have no owner handler at all (grep count 0).
      • set mqtt.owner does not exist upstream. It lives in the MQTT observer fork. The value goes only into the JWT that the observer signs with its own key and uses as its MQTT password (fork: src/helpers/JWTHelper.cpp:77,175-178, src/helpers/bridges/MQTTBridge.cpp:1732-1782). It is never in a mesh packet or a status message. CoreScope never sees broker credentials [K]. So "no renaming per node" is not possible with today's firmware, except for observers on that fork, and only if the broker passes the token on (§2.4).
    3. Option B (a DM to a MeshView companion) is possible, but it is a separate infrastructure project. MeshView would need its own key, a radio on air with RF coverage and a host daemon, plus contact management. The DM's MAC is only 2 bytes. Not for M1 (§2.5).

    4. A third option the issue does not name is stronger than A or B: the companion can sign arbitrary data. [F]

      • CMD_SIGN_START/DATA/FINISH signs up to 8 KiB with the companion's own ed25519 key (MyMesh.cpp:41-43,142,1781-1812; src/Identity.cpp:151-153).
      • A page with Web Bluetooth or Web Serial could sign a login challenge with no rename, no advert and no radio traffic.
      • Limits [A]: browser support (no Web Bluetooth on iOS Safari or Firefox), and the companion accepts one BLE client at a time.
      • I propose it as an optional M1b, not the default.
    5. Sessions fit the read-only server. [K]/[A]

      • The ingestor proves the login (an advert match, the same hook as antenna claims, cmd/ingestor/main.go:1120) and creates the account row.
      • The server then mints a stateless HMAC-signed token in an HttpOnly cookie, with no DB write.
      • The signing key comes from a 0600 key file that the ingestor creates next to the DB. The precedent is the client-RX salt (cmd/ingestor/client_rx_delete.go:169-197).
      • Revocation is a per-account session_gen that the ingestor increments and the server checks with one primary-key read.
    6. Every account write is a command file in a new account-requests/ queue, using the existing channelregistry.Queue.EnqueueValue (internal/channelregistry/queue.go:160). This is the same flow as antenna claims (cmd/server/antenna_claims.go:590-617, cmd/ingestor/antenna_claims.go:555-601).

    7. Linked-node edits reuse the claim lifecycle unchanged, with one rule: a link-based claim's authority time is the time of the advert that proved the link, not the time of the edit.

      • The existing NewerApprovedQuery (internal/channelregistry/antennaclaim/antennaclaim.go:262-270) then guarantees that a newer advert proof by the real owner always beats an account edit.
      • It needs one change: a created_at tie-break, because two edits under one link share the same authority time (§4.4).
    8. contactAdmin stays unreachable. No account response type gets a field for it, exactly like NodeStationResponse today (cmd/server/antenna_claims.go:86-95) [K].

    9. Proposed plan:

      • M1: sign-in (A), session, synced My nodes with the localStorage migration, sign out, delete the account.
      • M2: node linking, with one code for many nodes.
      • M3: station data for linked nodes, including bulk editing.

      Each milestone is gated off by default.


    2. Firmware findings

    2.1 Can a companion advert carry the sign-in code? Yes. [F]

    Question Answer Evidence
    What signs the advert ed25519 over pubkey ‖ timestamp ‖ appdata; the name is inside appdata src/Mesh.cpp:404-437 (sign at :434); receive-side verify :255-289 (cut to 32 bytes :269, verify :280, "forged signature" :287); docs/payloads.md:26-35
    Companion advert type ADV_TYPE_CHAT, with or without a position src/helpers/BaseChatMesh.cpp:21-41; src/helpers/AdvertDataHelpers.h:8
    Name stored up to 31 bytes (node_name[32]), no character check on the companion path MyMesh.cpp:1259-1265; NodePrefs.h:17
    Name on air MAX_ADVERT_DATA_SIZE − i, cut to a valid UTF-8 prefix: 31 bytes without a position, 23 bytes with one (1 flags + 8 lat/lon), 2 fewer per feature word AdvertDataHelpers.cpp:4-29; src/MeshCore.h:12
    Companion default no position (advert_loc_policy = 0, ADVERT_LOC_NONE) → 31-byte budget; ADVERT_LOC_SHARE → 23 NodePrefs.h:11-12,33; MyMesh.cpp:1299-1303
    How the app triggers it CMD_SET_ADVERT_NAME (8), then CMD_SEND_SELF_ADVERT (7) with byte 1 = 1 for flood, otherwise zero-hop MyMesh.cpp:15-16,1259-1265,1297-1313
    Flood scope the flood goes out under the companion's default region scope if one is set, otherwise unscoped MyMesh.cpp:1306-1309,491-500; NodePrefs.h:49
    Periodic advert none on the companion: the interval prefs are commented out; the device button sends zero-hop NodePrefs.h:195-196; MyMesh.cpp:2436-2448

    Consequences for CoreScope:

    • antennaclaim.NameBudget(hasLocation, feat1, feat2) already computes 31 or 23 from the advert's flags [K] (antennaclaim.go:162-177). ContainsCode and SuggestedName can be reused as they are (:179-215).
    • The issue's "23 bytes" is the worst case. The page must use the budget of the companion's last advert (does it have a position?), and fall back to 23 when it does not know.
    • The 6-character Crockford alphabet (antennaclaim.go:106) is plain one-byte ASCII. It survives both the companion path, which validates nothing, and CoreScope's sanitizeName.

    2.2 How likely is it that an observer hears it? [F] mechanism, [A] probability

    • Flood: repeaters relay an advert until the path holds flood_max_advert hashes. The default is 8 on repeaters (examples/simple_repeater/MyMesh.cpp:906-908; src/helpers/RoutingPolicy.h:15-22).
    • Scoped flood: if the companion has a default region scope, a repeater that does not know the region does not forward it (simple_repeater/MyMesh.cpp:434-442,555-567).
      • [A] An observer within direct RF range still hears and uploads it: scope gates relaying, not hearing.
      • So a scope mismatch shortens the reach. It does not hide the advert from a nearby observer.
    • Zero-hop: only radios in direct range hear it. That works only next to an observer.
    • [A] In an area with observers, a flood advert from a companion is heard within seconds in nearly every case. In a remote area with no observer within 8 hops, sign-in by advert cannot work at all.
      • The page must say so, and offer the non-RF route (option C, or the pasted contact card in §2.6) where it is available.
      • We cannot measure the miss rate from our own data, because a missed advert leaves no trace.

    2.3 Is there an owner field in repeater, room or observer packets? [F]

    Where What In a signed or observable packet? Evidence
    Upstream owner.info free text, at most 119 characters No. buildAdvertData passes only the name and position src/helpers/CommonCLI.h:67; CommonCLI.cpp:577-583 (set), :170-181 (advert)
    ANON_REQ_TYPE_OWNER reply node_name \n owner_info Only to the requester: direct-routed only; one shared limiter of 4 per 3 min; the reply is ECDH-encrypted simple_repeater/MyMesh.cpp:56,165-182,586-587,869
    REQ_TYPE_GET_OWNER_INFO firmware version, name and owner info Only to a logged-in client simple_repeater/MyMesh.cpp:51,372-373
    Room, sensor and companion no owner handler — grep count of "owner" = 0 in simple_room_server/MyMesh.cpp, simple_sensor/SensorMesh.cpp and companion_radio/MyMesh.cpp
    Advert feat1/feat2 2 bytes each, reserved // FUTURE, never set They would be signed, but nothing can set them, and 4 bytes cannot hold a key AdvertDataHelpers.h:15-16, AdvertDataHelpers.cpp:12-19
    mqtt.owner (fork only) 64-hex companion key in mqtt_owner_public_key[65] Not in mesh packets. It is only in the observer's JWT §2.4

    2.4 set mqtt.owner (MQTT observer fork). [F] fork, [K]

    • It is absent from upstream: there are 0 hits for mqtt in src/ and examples/.
    • The fork, branch mqtt-observer-plus:
      • set mqtt.owner <64 hex> checks that the value is 64 hex characters and stores it (src/helpers/CommonCLI_Observer.cpp:460-483).
      • get mqtt.owner works over serial only, because of the sender_timestamp == 0 guard (:840-845).
    • Where the value goes:
      • createSlotAuthToken puts it into the JWT payload as owner (src/helpers/JWTHelper.cpp:175-178), next to publicKey, aud, iat and exp.
      • It signs header.payload with the observer's ed25519 key (JWTHelper.cpp:62-80, sign at :77).
      • It uses the token as the MQTT password for preset JWT brokers and for custom slots with an audience (MQTTBridge.cpp:1318-1324,1422-1429,1732-1782).
      • The older mqtt-bridge-implementation branch does the same for two fixed third-party analyzer brokers only (MQTTBridge.cpp:2199-2240).
    • It is not in the observer's status JSON: no owner key outside the JWT helper.
    • CoreScope's ingestor is an MQTT subscriber and never sees publishers' credentials. There is no JWT code in cmd/ or internal/ [K].
    • What it would prove:
      • The observer's controller names a companion key.
      • The companion has not agreed. Anyone can name anyone's key.
    • How it could be used later:
      • Only for observers, and only if a broker that verifies the JWT passes the verified (observer pubkey, owner pubkey) pair to CoreScope.
      • The account must then accept the offered observer, so a stranger cannot push nodes into someone's account. That gives a two-sided binding: the account proved the companion, and the observer's key named the companion.
      • It does not cover repeaters or rooms on upstream firmware.

    2.5 What option B (a DM with the code to a MeshView companion) would need. [F] protocol, [A] operations

    Protocol facts:

    • A DM (TXT_MSG) carries a 1-byte destination hash, a 1-byte source hash, a 2-byte MAC and AES ciphertext (docs/payloads.md:69-78; CIPHER_MAC_SIZE 2, src/MeshCore.h:17).
    • The receiver tries every contact whose key starts with the source hash, at most 4 (src/Mesh.cpp:133-160).
    • The key is the ECDH shared secret, ed25519_key_exchange(other_pub, own_prv) (src/Identity.cpp:155-157). Only the two key holders can compute it.
    • So MeshView can decrypt only DMs from contacts it already knows.
      • The MeshView radio must have the user's full public key: through auto-add of chat adverts (MyMesh.cpp:147-151,305-322), or through CMD_IMPORT_CONTACT (:26) fed from an advert CoreScope stored.
      • The companion contact table holds 100 by default (examples/companion_radio/MyMesh.h:57-58), so it needs overwrite-oldest.
    • The companion hands a received DM to its host with only a 6-byte key prefix (MyMesh.cpp:440-452). The daemon maps it to the full key through its contact list.
    • Proof strength:
      • A valid MAC proves the sender holds the private key behind the source contact.
      • The MAC is 2 bytes, so a random packet passes 1 in 65,536 times. But the attacker cannot choose the plaintext without the secret, so a forged DM cannot carry the code [A].
      • That is weaker than the 64-byte advert signature, but enough for a bound, single-use code.
    • Alternative B′: a MeshView "room" that accepts an ANON_REQ login with the code as the password.
      • It is stronger: the request carries the full sender key, so no contact lookup is needed (docs/payloads.md:214-229; src/Mesh.cpp:197-217).
      • But stock room-server firmware does not expose logins to a host, so it needs custom firmware or a host-side mesh stack.
    • Bonus of the B infrastructure: a transmitting MeshView identity could also send ANON_REQ_TYPE_OWNER to repeaters (direct route, 4 per 3 min per repeater) and read owner.info. An owner could then link a repeater by putting the code in owner.info (set owner.info …, CommonCLI.cpp:577-583) instead of renaming it.

    What MeshView would have to run [A]:

    • a secret ed25519 identity;
    • a radio on air (stock companion firmware over USB) at a site with RF coverage;
    • a daemon that speaks the companion protocol (CMD_SYNC_NEXT_MESSAGE, CMD_IMPORT_CONTACT);
    • a hand-off into the ingestor through its own queue directory, so that the server stays read-only.

    It also transmits (ACKs, path returns), which means airtime and duty-cycle responsibility for the operator. Users outside that radio's reach cannot use it, while option A works anywhere an observer listens. Verdict: not in M1–M3.

    2.6 Two non-RF routes worth knowing. [F] firmware, [A] apps

    • Option C — companion signing.
      • The commands: CMD_SIGN_START returns the maximum length; CMD_SIGN_DATA appends; CMD_SIGN_FINISH returns a 64-byte ed25519 signature over the buffer from self_id.sign (MyMesh.cpp:41-43,142,1781-1812; src/Identity.cpp:151-153).
      • It is not documented in docs/companion_protocol.md, which has no "sign" hits.
      • The signature is raw ed25519 over our bytes, so the challenge needs a fixed domain prefix. Use, for example, MVLOGIN1\n<origin>\n<nonce>\n<issuedAt>. A signed challenge can then never be mistaken for an advert, whose signed message starts with the signer's own 32-byte key [A].
      • The server can verify the signature itself, read-only, with crypto/ed25519, as internal/sigvalidate already does [K]. Only the account row needs the ingestor.
    • The contact card ("biz card").
      • CMD_EXPORT_CONTACT without a key returns the companion's own signed advert as packet bytes (MyMesh.cpp:1379-1395).
      • The text form is meshcore://<hex of the advert packet> (examples/simple_secure_chat/main.cpp:463-473; docs/faq.md:436).
      • If the user's app can export that card as text, they could set the code in the name, export the card and paste it into the page, with no observer needed.
      • [A] I could not check whether the official phone apps expose it. The meshcore://contact/add?… QR format is unsigned (docs/qr_codes.md:20-37), so it proves nothing.

    3. CoreScope findings that the design builds on. [K]

    Area Where Fact
    Claim issuance cmd/server/antenna_claims.go:482-577 Strict 1 KiB body; identical 404 for hidden, unknown or unpositioned nodes; one global SubmissionsPerHour window with refund; code from antennaclaim.NewCode; command via EnqueueValue; 202 with code, budget and suggested name
    Queue internal/channelregistry/queue.go:160 (EnqueueValue) Atomic command files, MaxQueuedRequests, result files, Prune
    Ingest hook cmd/ingestor/main.go:1120; antenna_claims.go:145-171 Only new, signature-valid adverts; O(1) lookup in pending[pubkey] (:117-143); proof stores the ingest time, the hash and the position
    Newest proof wins antennaclaim.go:262-270 (NewerApprovedQuery); used in reviewAntennaClaim (cmd/ingestor/antenna_claims.go:363-427) An approval is refused when a claim proven later is already approved for the same part
    Contacts antennaclaim.go:280-283 (ContactLiveSQL); internal/dbschema/dbschema.go:1497-1505 The admin contact is in its own table; only adminClaimSelect joins it (cmd/server/antenna_claims.go:618-636)
    Schema dbschema.go:1424-1453 (node_antenna_claims), :1475-1500 (#898 parts via ADD COLUMN) The ingestor migrates; the server tolerates a missing table (isMissingClaimsTable, antenna_claims.go:299)
    Read-only invariant cmd/server/readonly_invariant_test.go:22-82 (no RW connection), :93-119 (no write methods on *DB), :126-146 (the connection rejects INSERT), :214-281 (DML regex over the ingestor-owned tables, including node_antenna_claims) New account tables must be added to that regex
    Per-install secret precedent cmd/ingestor/client_rx_delete.go:169-197 The ingestor creates a 32-byte salt file, mode 0600, next to the DB
    Per-IP limiter cmd/server/ip_rate_limit.go:146; config.go:1062-1078 Needs trustedProxies; in the shipped Docker topology the per-IP limits are skipped (config comment), so a global cap is still needed
    Admin auth cmd/server/routes.go:631 (requireAPIKey) One API key; no users, cookies or sessions anywhere in cmd/server (grep)
    Security headers — cmd/server sets no Content-Security-Policy (grep). XSS is therefore the main way to steal a token kept in JS storage. Use an HttpOnly cookie
    My Mesh public/home.js:40-56 meshcore-my-nodes = [{pubkey, name, addedAt}]. Read directly in 6 more places: nodes.js:8,1805,2008, live.js:3765, analytics.js:2642, and customize-v2.js:970,1204 (settings export/import)
    My Mesh cards home.js:330-338 One /health request per card (pre-existing). A synced list that grows makes this worse; GET /api/nodes/bulk-health exists (routes.go:453)
    Queue dirs on non-root images docker/nonroot.sh:56 QUEUE_DIRS must gain account-requests

    4. Design

    4.1 Sign-in flow (option A, recommended for M1)

    1. Choose the companion. The page asks which companion. The user either searches the node list (companions appear once heard) or pastes the public key the app shows.
      • The challenge is bound to that key.
      • [A] Without the binding, anyone who saw the code in a public name could advert it from their own companion first, and sign the victim's browser into the attacker's account (login CSRF). The victim would then link nodes to the attacker's account.
    2. POST /api/account/login. The server answers 202 with a requestId, a code, a redeemSecret (128-bit, shown once), expiresAt, nameBudgetBytes and suggestedName.
      • It enqueues {op:"login", requestId, pubkey, code, redeemHash: sha256(redeemSecret), createdAt}.
      • The code lives 15 minutes. The user is at the device, so 24 h is not needed.
    3. Rename and advert. The user puts the suggested name on the companion and sends a flood advert.
    4. Match in the ingestor. At the existing hook (only new, signature-valid adverts of type chat, Flags.Chat), the code is matched by full pubkey.
      • The challenge becomes proven, with the ingest time and the proof hash.
      • The account row is created if missing, or last_login_at is updated.
    5. Redeem. The browser polls GET /api/account/login/{id} and gets only {status, expiresAt}. When it reads proven, it calls POST /api/account/session {requestId, redeemSecret}.
      • The server checks, read-only, that the challenge is proven, that the redemption is within 10 minutes of the proof, that the hash matches and that the account exists.
      • It then sets the session cookie.
      • Several redemptions inside the window are harmless: only the holder of the secret can redeem.
    6. Finish. The page shows "Signed in as <companion name> (a1b2c3…)", where the user can still back out, and reminds them to restore the name.

    Option C (M1b) replaces steps 3–4. The server checks the ed25519 signature over its challenge itself, then enqueues {op:"login-signed", …} so that the ingestor creates or updates the account.

    4.2 Session token: stateless, read-only. [A] design, [K] precedents

    • Format: base64url(payload) "." base64url(HMAC-SHA256(key, payload)). It uses only the standard library: no JWT dependency and no new modules.
    • Payload (named struct):
    type SessionClaims struct {
    	V         int    `json:"v"`    // 1
    	AccountID string `json:"aid"`  // 32 hex, random, never the companion key
    	Gen       int64  `json:"gen"`  // accounts.session_gen at issue
    	AuthAt    int64  `json:"auth"` // Unix ms of the proof that signed in
    	IssuedAt  int64  `json:"iat"`
    	ExpiresAt int64  `json:"exp"`
    }
    • Key:
      • 32 random bytes in account-session.key, mode 0600, next to the DB.
      • The ingestor creates it on first start, as clientRxLoadOrCreateSalt does. The server only reads it.
      • With no key file, accounts report "unavailable" and the server re-reads the file lazily.
      • Rotating the key means replacing the file and restarting both processes. That signs everyone out, which is the global revocation.
    • Expiry:
      • 30 days. The server re-issues the cookie on use once the token is more than a day old (sliding).
      • Hard cap of 90 days after AuthAt. After that the user signs in again.
    • Revocation:
      • Each authenticated request does one primary-key read: SELECT session_gen FROM accounts WHERE account_id = ?.
      • A token whose gen differs, or whose account is gone, is invalid.
      • "Sign out everywhere" and "delete account" are ingestor ops that increment the generation or delete the row, so they take effect in about 2 s.
      • Plain "sign out" clears the cookie. A stolen copy then stays valid until it expires, unless the user signs out everywhere.
    • Transport:
      • Cookie __Host-mv_session, with HttpOnly; Secure; SameSite=Strict; Path=/.
      • The token never goes in a URL or localStorage.
      • State-changing routes require Content-Type: application/json and a matching Origin (CSRF defence in depth).
    • Commands carry gen:
      • The server copies the token's gen into every account command.
      • The ingestor refuses a command whose gen no longer matches. A command queued just before "sign out everywhere" or a delete therefore never applies.

    4.3 Write path (same shape as antenna claims)

    browser ──POST──▶ server (validates the session + body, applies the rate limits)
                        └─ EnqueueValue(account-requests/cmd-<id>.json)
    ingestor runner (2 s tick): Validate() again → one SQL transaction → result-<id>.json
    browser ──GET───▶ server: read-only SELECT (request status, /api/account)
    

    The ops, in a shared internal/channelregistry/account package:

    • M1: login, login-signed, my-nodes-set (bulk replace, used by the migration), my-node-add, my-node-remove, profile-set (display name), sign-out-all, delete.
    • M2: link, unlink, link-visibility.
    • M3: station (one claim per node through a link).

    Validate() is shared, as antennaclaim.Command.Validate is today (antennaclaim.go:309-335).

    type Command struct {
    	RequestID         string             `json:"requestId"`
    	Op                string             `json:"op"`
    	AccountID         string             `json:"accountId,omitempty"`
    	Gen               int64              `json:"gen,omitempty"`
    	PubKey            string             `json:"pubkey,omitempty"`  // login: the companion; my-node-add/remove, unlink
    	PubKeys           []string           `json:"pubkeys,omitempty"` // my-nodes-set, link (bounded)
    	Code              string             `json:"code,omitempty"`
    	RedeemHash        string             `json:"redeemHash,omitempty"`
    	DisplayName       *string            `json:"displayName,omitempty"`
    	ShowOwner         *bool              `json:"showOwner,omitempty"`
    	Station           *StationEdit       `json:"station,omitempty"` // M3
    	RemoveStationData bool               `json:"removeStationData,omitempty"`
    	CreatedAt         int64              `json:"createdAt"`
    }
    
    // StationEdit is one node's parts (M3). It is the same shape as
    // AntennaClaimRequest, plus the #1017 hardware key inside DetailsInput.
    type StationEdit struct {
    	PubKey       string                     `json:"pubkey"`
    	HeightM      *float64                   `json:"heightM,omitempty"`
    	Clear        bool                       `json:"clear,omitempty"`
    	Details      *antennaclaim.DetailsInput `json:"details,omitempty"`
    	ClearDetails bool                       `json:"clearDetails,omitempty"`
    }

    Public response types (named structs, no map[string]interface{}):

    type LoginIssuedResponse struct {
    	RequestID       string `json:"requestId"`
    	Code            string `json:"code"`
    	RedeemSecret    string `json:"redeemSecret"`
    	ExpiresAt       int64  `json:"expiresAt"`
    	NameBudgetBytes int    `json:"nameBudgetBytes"`
    	SuggestedName   string `json:"suggestedName"`
    }
    type RequestStatusResponse struct {
    	Status    string `json:"status"`
    	ExpiresAt int64  `json:"expiresAt,omitempty"`
    	Error     string `json:"error,omitempty"`
    }
    type AccountResponse struct {
    	DisplayName    string        `json:"displayName,omitempty"`
    	IdentityPrefix string        `json:"identityPrefix"` // 8 hex, shown only to the account itself
    	IdentityName   string        `json:"identityName,omitempty"`
    	SignedInAt     int64         `json:"signedInAt"`
    	MyNodes        []AccountNode `json:"myNodes"`
    	Links          []AccountLink `json:"links"`   // M2
    	Limits         AccountLimits `json:"limits"`
    }
    type AccountNode struct {
    	PubKey  string `json:"pubkey"`
    	Name    string `json:"name"`
    	Role    string `json:"role,omitempty"`
    	AddedAt int64  `json:"addedAt"`
    	Linked  bool   `json:"linked"`
    }
    type AccountLink struct {
    	PubKey    string `json:"pubkey"`
    	Status    string `json:"status"` // pending | linked | expired | superseded | unlinked | revoked
    	ProvenAt  *int64 `json:"provenAt,omitempty"`
    	ExpiresAt int64  `json:"expiresAt"`
    	Stale     bool   `json:"stale,omitempty"`     // moved > staleMoveM since the proof: edits refused
    	Outranked bool   `json:"outranked,omitempty"` // a newer direct proof is in force: re-prove to edit
    	ShowOwner bool   `json:"showOwner"`
    }
    type AccountLimits struct {
    	MaxMyNodes      int `json:"maxMyNodes"`
    	MaxLinkedNodes  int `json:"maxLinkedNodes"`
    	MaxNodesPerCode int `json:"maxNodesPerCode"`
    }

    None of these types has a contact field. The account's view of its station data uses the existing public NodeStationResponse, plus its own pending claims as {parts, status}, never their values for contactAdmin.

    4.4 Data model (ingestor-owned, internal/dbschema)

    CREATE TABLE accounts (
      account_id      TEXT PRIMARY KEY,                 -- crypto/rand, 32 hex
      identity_pubkey TEXT NOT NULL UNIQUE,             -- the companion; never served publicly
      display_name    TEXT NULL CHECK(display_name IS NULL OR length(display_name) BETWEEN 1 AND 32),
      session_gen     INTEGER NOT NULL DEFAULT 1,
      created_at      INTEGER NOT NULL,
      last_login_at   INTEGER NOT NULL
    );
    
    -- One proof record per code: kind 'login' (account_id set on proof) or 'link'.
    CREATE TABLE account_proofs (
      request_id  TEXT PRIMARY KEY,
      kind        TEXT NOT NULL CHECK(kind IN ('login','link')),
      account_id  TEXT NULL REFERENCES accounts(account_id) ON DELETE CASCADE,
      pubkey      TEXT NOT NULL,
      code        TEXT NOT NULL,
      redeem_hash TEXT NULL CHECK((kind = 'login') = (redeem_hash IS NOT NULL)),
      status      TEXT NOT NULL CHECK(status IN ('pending','proven','expired')),
      created_at  INTEGER NOT NULL, expires_at INTEGER NOT NULL,
      proven_at   INTEGER NULL, proof_hash TEXT NULL, proof_lat REAL NULL, proof_lon REAL NULL
    );
    CREATE INDEX idx_account_proofs_pubkey_status ON account_proofs(pubkey, status);
    
    CREATE TABLE account_my_nodes (            -- the synced watch list (no proof, as My Mesh today)
      account_id TEXT NOT NULL REFERENCES accounts(account_id) ON DELETE CASCADE,
      pubkey     TEXT NOT NULL,
      name_hint  TEXT NULL CHECK(name_hint IS NULL OR length(name_hint) <= 64),
      added_at   INTEGER NOT NULL,
      PRIMARY KEY (account_id, pubkey)
    ) WITHOUT ROWID;
    
    CREATE TABLE account_node_links (
      link_id    TEXT PRIMARY KEY,             -- = the proving account_proofs.request_id
      account_id TEXT NOT NULL REFERENCES accounts(account_id) ON DELETE CASCADE,
      pubkey     TEXT NOT NULL,
      status     TEXT NOT NULL CHECK(status IN ('linked','expired','superseded','unlinked','revoked')),
      proven_at  INTEGER NOT NULL,             -- authority time (the advert that proved it)
      proof_lat  REAL NULL, proof_lon REAL NULL,
      expires_at INTEGER NOT NULL,             -- proven_at + linkLifetimeDays
      show_owner INTEGER NOT NULL DEFAULT 0,
      decided_at INTEGER NULL
    );
    CREATE UNIQUE INDEX idx_one_active_link ON account_node_links(pubkey) WHERE status = 'linked';
    CREATE INDEX idx_account_links_account ON account_node_links(account_id, status);

    Proof records. One pending map keyed by pubkey serves both kinds. The matcher already exists in antennaClaimRunner.match.

    • DRY: extract a generic "pending codes by pubkey" type, so the claim runner and the account runner do not fork the logic.
    • The ingest hook calls both runners. Each costs one O(1) map lookup.

    Attaching antenna claims and station details. Per-node claims stay exactly as they are. Three nullable columns are added to node_antenna_claims with the existing self-healing ADD COLUMN pattern (dbschema.go:1525-1540):

    • account_id TEXT NULL: who submitted it. It is set to NULL when the account is deleted. There is no foreign key, so a delete never cascades into claims.
    • via TEXT NULL CHECK(via IS NULL OR via IN ('advert','link')): NULL means legacy, which is the same as advert.
    • link_id TEXT NULL.

    A link-based claim (M3):

    The ingestor refuses it at insert when:

    • the link is not linked, is expired, or belongs to another account;
    • the account's gen does not match;
    • the node moved more than staleMoveM from the link's proof position (the same Limits.Stale rule);
    • or a claim for a part it carries is already approved with proven_at > link.proven_at. That is the NewerApprovedQuery check, moved from approval time to insert time as well.

    Required change to NewerApprovedQuery:

    • Two edits under one link share proven_at, so the strict proven_at > ? would let an older edit, approved late by an admin, undo a newer one.
    • The order key becomes (proven_at, created_at):
    ... AND (proven_at > ?3 OR (proven_at = ?3 AND created_at > ?4)) ...
    • Server and ingestor share the constant, so their 409s stay in agreement. Mutant tests pin it: drop the tie-break and a test must fail.

    Migration:

    • New tables, created by dbschema in the ingestor. The server treats a missing table as "accounts unavailable", the same pattern as isMissingClaimsTable.
    • Add the four new tables to txTableWritePattern (readonly_invariant_test.go:220).
    • Add account-requests to docker/nonroot.sh QUEUE_DIRS.
    • No backfill: legacy claims keep account_id, via and link_id NULL.

    4.5 Retention and deletion

    Data Kept Removed
    account_proofs (login) until proven or expired 24 h after expires_at or redemption
    account_proofs (link) until proven or expired (24 h TTL, as claims) after RetentionDays (default 30)
    account_node_links linked until it expires (lifetime, default 365 d), is unlinked, superseded or revoked finished rows after RetentionDays
    account_my_nodes while the account exists; capped (default 200) with the account (cascade)
    accounts until deleted; optionally auto-deleted after N months without a sign-in (open question 9) delete op
    Queue command and result files ≤ 24 h, via Queue.Prune (call it for this queue too, unlike the old region-scope gap) pruned

    What delete does, in one transaction:

    1. Increment the generation implicitly by deleting the row, so every session dies.
    2. Delete the account, which cascades to My nodes, links and proofs.
    3. Set account_id, link_id = NULL on its claims.
    4. Reject its claims that are still proven (dropping their contacts).
    5. If removeStationData is set, insert for each linked node an owner clear-only claim (approved_by='owner', via='link') for the parts this account put in force. The NewerApprovedQuery guard applies.

    Approved station data stays by default, as the issue says. The same "deletion is logical" caveats about backups, free pages and the WAL apply as in docs/user-guide/antenna-height-claims.md [K]. That doc text should be reused, not rewritten.

    4.6 Linking nodes (M2)

    • Single node: POST /api/account/links {pubkeys:[pk]} issues a code bound to (account, pk). The owner renames the node and sends an advert. The ingestor marks the proof proven and inserts a linked row.
      • If another account held the active link, that link becomes superseded.
      • The partial unique index guarantees one active link per node.
    • One code for many nodes: the same request with up to maxNodesPerCode keys (default 20).
      • The server issues one code and writes one command.
      • The ingestor inserts one proof row per pubkey with the same code.
      • Each node is proven by its own advert, and each link stands alone. The code binds per (pubkey, code), so sharing it across nodes adds no risk.
      • The page lists one set name … / advert pair per node, each within that node's budget (23 bytes with a position).
    • Hidden nodes (Terrain profile: endpoint visibility bypasses hidden observer aliases (privacy) #743): the server refuses to link a hidden node, with the identical 404. My-nodes entries and links of nodes that become hidden are left out when served, and nothing is written.
    • Roles: repeater and room, the same set as claims (CLAIM_ROLES, public/antenna-claims.js:49). An observer is a repeater and is covered. Companions are not linked: their key is an identity.

    4.7 Security

    Threat Mitigation
    Replay of a code Codes come from crypto/rand after issue, are single-use, bound to one pubkey, and expire (15 min for login, 24 h for link). Only new transmissions match (content-hash dedupe). No advert timestamp or observer time is trusted: the same argument as #789 [K] (cmd/ingestor/antenna_claims.go:14-19)
    Someone else uses a code seen on air A login code is useless without the redeemSecret held by the requesting browser. A link code is bound to the requesting account and to the node's key
    Login CSRF / account fixation The challenge is bound to the chosen companion key; the confirmation step shows the identity; the session cookie is SameSite=Strict
    Stolen session HttpOnly cookie (no CSP today, so keep tokens out of JS); 30-day sliding / 90-day hard expiry; "sign out everywhere" through session_gen; the account page shows the last sign-in time. No IP or user agent is stored
    Stolen key file It is equivalent to minting any session. Mode 0600, owned by the service user, excluded from GET /api/backup (verify in M1: the backup is VACUUM INTO of the DB only [K], so the key file is not in it). Rotating it signs everyone out
    Temporary control of a node (a borrowed device, a guessed admin password) The link expires (default 365 d). The real owner takes it back with one advert (supersede). A direct advert claim by the real owner outranks every older link edit (authority time). The admin can revoke a link. Optional public "verified owner since" display lets the owner notice
    The account overriding a newer owner proof Impossible by construction: link claims carry the link's proof time, and NewerApprovedQuery is checked at insert and at approval, with the created_at tie-break
    The account reading contactAdmin No account response type has the field; the account reads only the public /station shape; tested by reflection over every account response type, as NodeStationResponse is today
    Spam and DoS of sign-in A separate budget from claims: per-IP 10 per 10 min (only effective with trustedProxies); a global window (default 120/h); at most 8 pending logins per companion key; at most 512 pending in all; MaxQueuedRequests. An attacker can fill one victim's 8 slots for at most 15 minutes, and only within the global budget
    Linking and edit spam Per account: at most 20 pending links, at most maxLinkedNodes (default 200) and maxMyNodes (200); edits at most 60 node-commands/h, in memory on the server. Edits do not use the public global claim window, so one owner's bulk edit cannot starve anonymous claims
    A stranger pushing a node into an account (the M-later mqtt.owner path) Only an offer; the account must accept it
    Ownership leaking publicly The companion key, the account id and the account–node mapping are never in a public response, OG card, export or the node list. A public "verified owner" badge exists only per link, after opt-in

    4.8 Perf (rule 0) [A] estimates; [K] code paths

    • Ingest hot path: one extra O(1) map lookup per new advert (pending proofs by pubkey). The scan is bounded: at most 8 codes × at most 31 bytes. The same cost as claims today.
    • Server per authenticated request:
      • HMAC verify is O(1).
      • One primary-key SELECT on accounts.
      • /api/account is O(myNodes + links), at most about 400 rows, through two indexed reads.
      • No snapshot is needed.
    • Public "verified owner" badge (M2): a 30 s snapshot map[pubkey]bool, bounded by the number of links, the same pattern as ownerStations (cmd/server/antenna_claims.go:186-260). It is not added to /api/nodes or bulk-health.
    • Runner: a 2 s tick; one transaction per command; a bulk link or station command writes at most 20 nodes per transaction.
    • My nodes page: synced lists can grow, and today every card makes its own /health call [K]. M1 must cap the rendered cards (for example 24, with "show more") or move the grid to bulk-health. Measure both with 200 nodes before merge, as rule 0 requires proof.

    5. UI

    5.1 Routes (deep links)

    Route View
    #/account signed out: the sign-in card; signed in: My nodes
    #/account?tab=nodes / links / station My nodes / linking / station data
    #/account/sign-in?pubkey=<key> sign-in with the companion already chosen (from a node page: "This is my companion → sign in")

    The request id and code are never in the URL. As on the claim page, they live in sessionStorage per request, so a reload keeps them [K] (public/antenna-claims.js:25).

    5.2 Sign-in at 375×560

    One column with a 16 px gutter. Each step fits without horizontal scroll, and the primary button sits at the bottom of the visible area.

    1. Which companion? A search field ("name or public key"), with results limited to companions. A "Paste key" link opens a text field. The privacy note below reads: "Your key is never shown on this site."
    2. Your code. The code is shown large and monospaced, for example 7KX9QM, with Copy name.
      • The suggested name has a byte counter, such as "29 / 31 bytes" (or 23 when the companion shares its position).
      • Steps: "Set this as your companion's name → send a Flood advert."
      • A line about the cost: "Your name is public for a few minutes. Change it back afterwards."
    3. Waiting. The status line is aria-live.
      • It reuses createStatusPoller (public/antenna-claims.js:400-443) with its bounded backoff and the "Check again" end state.
      • After 2 minutes a hint appears: "No observer heard it yet: send the advert again, or try closer to a repeater."
    4. Done. "Signed in as Anna's T-Echo (a1b2c3…)". Two buttons: This is me, and Not me – cancel, which deletes the cookie.

    On desktop the same steps sit in one card about 480 px wide. Option C (M1b) adds a Sign in with Bluetooth / USB button above step 2, shown only when navigator.bluetooth or navigator.serial exists.

    5.3 My nodes and the My Mesh migration

    • Shared module. public/my-nodes.js becomes the one owner of meshcore-my-nodes. It exposes list, add, remove, has and onChange. The 7 direct readers (§3) switch to it (DRY, rule "one implementation").
      • Signed out, it behaves exactly as today.
      • Signed in, the server list is the source of truth, and the module writes it through to localStorage, so that favourites, live, analytics and the settings export keep working unchanged.
    • Migration. On the first sign-in, if localStorage has entries the account does not, a banner says: "This browser has 7 saved nodes. Add them to your account?" with Add all and Not now.
      • Add all sends one my-nodes-set command with the union, deduplicated by lower-case pubkey and capped.
      • Nothing is deleted from localStorage.
      • Not now sets a per-browser flag, so the banner does not nag.
    • Cards. The existing My Mesh grid gets a Verified badge on linked nodes and two actions per repeater or room card: Verify ownership (M2) and Station data (M3, linked only).

    5.4 Linking a node (M2)

    1. Tick nodes in My nodes. Only repeaters and rooms can be ticked.
    2. Get one code.
    3. A list shows one row per node: the name, a set name <suggested> line with Copy, advert, and a status chip (waiting / linked / expired).
    4. The page polls one request id. At 375 px each row stacks as name → command → chip.

    5.5 Bulk station-detail editing (M3)

    • Desktop: a table with one row per linked node and columns height, antenna type, gain, power, installation, hardware (Station details: hardware (official MeshCore list, ESP32/nRF52), TX power, direction, battery/solar and a photo #1017). Each cell has Keep / Set / Remove, with the same rules as the single-node form.
      • "Apply to selected" copies a column value down.
      • The public contact field and the administrator contact field are per row, and the administrator contact is never pre-filled.
    • 375×560: select nodes, then one form (the existing Keep / Set / Remove groups from antenna-claims.js), then a review screen listing the changes per node, then Submit.
      • The result list shows each node's claim status (proven / approved / needs review).
      • There is no per-row table on a phone.

    6. Milestone plan

    All operator settings live in config.json under accounts.*. Defaults:

    • enabled: false; accounts need a strong apiKey, as claims do;
    • sessionDays: 30, sessionMaxDays: 90;
    • loginCodeMinutes: 15;
    • linkLifetimeDays: 365;
    • maxMyNodes: 200, maxLinkedNodes: 200, maxNodesPerCode: 20;
    • loginsPerHour: 120, loginsPer10MinPerIP: 10;
    • retentionDays: 30.

    They are read by exact spelling, like the claim gates.

    Customizer (rule 8): none in M1–M3. These are operator settings, not visitor preferences, as #1007 also concluded. The only visitor-side candidate is "show verified-owner badges", which I would not add until someone asks.

    M1 — sign-in (A) and synced My nodes

    Server:

    • POST /api/account/login;
    • GET /api/account/login/{id};
    • POST /api/account/session;
    • DELETE /api/account/session;
    • GET /api/account;
    • POST /api/account/my-nodes (set / add / remove);
    • POST /api/account/profile;
    • POST /api/account/sign-out-all;
    • DELETE /api/account;
    • GET /api/account/config;
    • OpenAPI entries.

    Ingestor: the account runner, the schema (accounts, account_proofs, account_my_nodes), the key file, and the advert hook for kind='login'.

    Frontend: my-nodes.js, account.js (#/account), the home hero entry ("Sign in with your companion"), and the migration banner.

    Tests:

    • Token: round trip, tamper, wrong key, expiry, hard cap, gen mismatch, deleted account.
    • Ingestor matrix: a chat advert with the code proves; a repeater-type advert does not; wrong pubkey; forged signature; a re-received copy (isNew=false); expired; a code past the 31- or 23-byte budget; a command with a stale gen is refused.
    • Rate limits 429 and queue full 503; cookie flags; Origin check.
    • readonly_invariant_test.go extended, with a sensitivity test for the new tables.
    • Frontend unit tests via vm.createContext: my-nodes.js merge, dedupe, cap, write-through and migration.
    • Playwright at 375×560 and on desktop: sign-in against a fixture-proven challenge; the migration banner. Add the suite to scripts/e2e-shards.json.
    • Mutants: drop the gen check, drop the pubkey binding, drop isNew. Each must fail a test.

    Perf proof: benchmarks for token verify and the /api/account read with 200 my-nodes; the My nodes grid with 200 entries (capped versus bulk-health), timed.

    Browser validation: a real companion sign-in on the staging instance, with screenshots at 375×560 and on desktop.

    M1b (optional): option C (Web Bluetooth/Serial CMD_SIGN_*), with server-side ed25519 verification of a domain-prefixed challenge. Tests use a test key only.

    M2 — node linking

    Server:

    • POST /api/account/links;
    • DELETE /api/account/links/{pubkey};
    • POST /api/account/links/{pubkey}/visibility;
    • admin GET /api/admin/account-links and POST …/{linkId}/revoke behind requireAPIKey;
    • the public "verified owner" snapshot, opt-in only.

    Ingestor: account_node_links, the supersede rule, expiry, and the kind='link' match.

    Frontend: multi-select, one code for many nodes, the per-node rows, and the Verified badge.

    Tests:

    • One code proves N nodes individually; one node missing its advert stays pending.
    • A second account's proof supersedes the first; the partial unique index holds.
    • Hidden node → 404; stale by move; expiry; revoke.
    • Playwright for the linking flow at both sizes.

    Perf: the hook is still O(1); the badge snapshot is bounded and not added to list endpoints.

    M3 — station data for linked nodes

    Server: POST /api/account/station, a batch of at most 20 StationEdits. NeedsReview is computed per node from the cached surface, as in handleAntennaClaimSubmit.

    Ingestor:

    • link-based claim insert (via='link', authority time);
    • the NewerApprovedQuery tie-break;
    • account_id, link_id, via columns;
    • delete with removeStationData.

    Frontend: the bulk editor (§5.5); the admin queue shows "via account link, proven ".

    Tests:

    • An owner's newer direct advert claim beats an older link edit, both at insert and at a late admin approval.
    • The tie-break: two edits under one link, the older approved last, is refused.
    • The autoApproveProven / autoApproveDetails / needs_review matrix applies to link claims unchanged.
    • contactAdmin absent from every account response (reflection).
    • Delete with and without removeStationData.
    • Mutants on the tie-break and on the authority time.

    Perf: a 20-node batch is one command and at most 20 small transactions; there is no change to /station, /api/nodes or the profile path.

    Docs:

    • a new docs/user-guide/owner-account.md;
    • configuration.md, config.example.json;
    • antenna-height-claims.md gets a short "with an account" section.

    7. Open questions for the owner (each with a recommended default)

    1. Sign-in method for M1.
      • Default: A (code in the companion's name, flood advert), with the companion's key chosen first.
      • Add C (Bluetooth/USB signing) as M1b.
      • B (a MeshView DM node) is not planned. It needs a transmitting MeshView radio, a daemon and RF coverage.
    2. Which identities may sign in? Default: companion (chat) adverts only. A repeater or room key cannot become an account.
    3. Session lifetime. Default: 30 days sliding, 90 days hard cap, with "sign out everywhere".
    4. Public display of ownership. Default: nothing public. A per-node opt-in "Verified owner" badge, and an optional display name, also opt-in.
    5. One owner per node, or co-owners? Default: one active link per node; the newest proof wins. Co-owners can share one account, because the account follows the companion.
    6. Link lifetime. Default: 365 days, then prove again with one advert (one code still covers many nodes).
    7. Approval of edits through a link. Default: the same switches as direct claims (autoApproveProven, autoApproveDetails, needs_review). A link grants no extra trust.
    8. Account deletion and station data. Default: station data stays, with an explicit "also remove my station data" checkbox, as the issue proposes.
    9. Inactive accounts. Default: auto-delete after 24 months without a sign-in. Approved station data stays.
    10. Hidden identities (Terrain profile: endpoint visibility bypasses hidden observer aliases (privacy) #743) and sign-in. Default:
      • refuse a blacklisted companion key, with the identical 404;
      • allow a companion hidden only by a name prefix, because the account never makes the key public. The suggested name keeps the prefix, since the code is appended.
    11. Observers via mqtt.owner. Default: defer. It needs the broker that verifies observer JWTs to pass the signed (observer, owner) pair to CoreScope. When it comes, it is offer-and-accept only.
    12. What the administrator sees about accounts. Default: link rows with the account id, the display name and an 8-hex prefix of the companion key for abuse handling. No full key, no list of an account's watch list.
    13. The pasted contact card ("biz card") as an RF-free sign-in. Default: test whether the official apps can export the signed self-advert as text. If they can, add it to M1 as a second route, since the server can verify it locally. If not, drop it.
    14. The My nodes card cost. Default: cap the grid at 24 cards with "show more" in M1, and move it to bulk-health as a follow-up. Today every card makes its own /health request.

    🤖 Generated with Claude Code

  2. dborup commented on Nov 28, 2026

    @dborup
    OwnerAuthor

    Owner decisions on the M0 research (2026-11-28)

    These answer the 14 open questions. Where an answer differs from the research's default, the line says "changed".

    1. Sign-in method:
      • M1: option A, a code in the companion's name and a flood advert.
      • M1b: signing over Web Bluetooth / Web Serial.
      • No DM node.
    2. Who may sign in: companion adverts only. A repeater or room cannot be an account, only linked to one.
    3. Session: 30 days, renewed on use, a 90-day hard cap, plus "sign out everywhere".
    4. Public display: nothing by default. Per node, the owner can opt in to a "Verified owner" badge and an optional display name.
    5. Co-owners: one active link per node, and the newest proof wins.
    6. Link lifetime: changed. A link has no expiry. It lasts until the owner removes it or a newer proof by someone else takes the node (decision 5).
    7. Approval of edits through a link: changed. Edits made through an account link are approved without an administrator. The switches for direct claims (autoApproveProven, autoApproveDetails, the review flag for heights) keep applying to direct per-node claims. (The scope of this for free text and photos is being confirmed; see the next comment.)
    8. Account deletion: station data stays, with an "also remove my station data" checkbox. Contacts are always deleted.
    9. Inactive accounts: deleted after 24 months without a sign-in. Station data stays.
    10. Hidden companions: a blacklisted key is refused with the same response as an unknown node. A node hidden only by the 🚫 name prefix may sign in.
    11. Observers via mqtt.owner: deferred until the broker can pass on the verified pair. Then it is offer-and-accept only.
    12. What the admin sees: changed. The full companion public key, with the account id and display name, on each link row.
    13. Pasted contact card: test whether the official apps can export the companion's signed contact card. If they can, add it to M1 as a sign-in without radio traffic. The card is public, so it must carry a fresh code to prevent replay.
    14. My nodes cost: in M1 the grid is capped at 24 cards with "show more", then moved to bulk-health.

    🤖 Generated with Claude Code

  3. dborup commented on Nov 28, 2026

    @dborup
    OwnerAuthor

    Decision 7, clarified (owner, 2026-11-28): Edits through an account link are approved without an administrator for structured values only:

    Free text and images still go to the administrator, even through an account: contactPublic and the installation photo (#1017).

    🤖 Generated with Claude Code

  4. dborup commented on Nov 29, 2026

    @dborup
    OwnerAuthor

    M1 merged in #1020. Owner decision 2026-11-29 on decision 13: contact-card sign-in (a freshly signed self-advert export, server code in the name, timestamp freshness check) is not part of M1. It becomes a later milestone here, once the official app's export has been tested on a real phone.

  5. dborup commented on Nov 29, 2026

    @dborup
    OwnerAuthor

    Owner decision (2026-11-29): M2 linking — one click in the browser

    Input from a user: claim repeaters by logging in to them (the MeshMapper model), with no manual renaming, and have it work across the user's devices (the account from M1 already gives the cross-device part).

    Approved direction for M2 (node linking): the browser does the whole proof in one click.

    • Like meshguide.dk's remote management, the browser logs in to the repeater as admin through the owner's companion over Web Bluetooth or Web Serial (USB) (companion protocol: CMD_SEND_LOGIN → LOGIN_SUCCESS, then CLI lines as CMD_SEND_TXT_MSG to the repeater).
    • The browser then renames the repeater with the account's link code, sends an advert, waits until MeshView has heard the advert and proven the link, and renames it back.
    • The owner types nothing and renames nothing by hand.
    • It works with the firmware as it is today (75b04ef).
    • Depends on Ingestor: a rename flips back and forth when copies of the old and new advert arrive interleaved (Node Changes logs every flip) #1048 (a rename flips back and forth when copies of the old and new advert arrive interleaved). That fix must land first, or every link would spam Node Changes and could leave the old name.

    Why the proof still goes through an advert: the server cannot observe the admin login itself, and a browser's "I logged in" can be forged. The signed advert heard by the observers is the proof the server can check.

    Not chosen now (possible later): owner.info (120 chars, readable with ANON_REQ_TYPE_OWNER, examples/simple_repeater/MyMesh.cpp:165) would avoid renaming, but the reply is encrypted to the requester, so it needs a MeshView radio on the air that sends the request.

    The M2 plan should cover: Web Bluetooth/Serial support (Chrome, Edge, Brave), the admin password never leaving the browser, failure and rollback if the rename-back fails, radio settings never touched remotely, and the 375×560 flow.

    🤖 Generated with Claude Code

  6. dborup commented on Nov 29, 2026

    @dborup
    OwnerAuthor

    Addendum to the M2 decision above (owner, 2026-11-29): the manual flow stays. The one-click browser flow is an addition, not a replacement.

    • Web Bluetooth and Web Serial only exist in Chrome, Edge and Brave. Safari and Firefox (and so every iPhone) cannot use the one-click flow, and WiFi companions cannot be reached from a browser at all.
    • The manual path, putting the code in the name yourself and sending an advert, must keep working for both sign-in (as in M1) and linking in M2, and the page must offer it whenever the browser cannot do the one-click flow.
    • Both paths end in the same server-side proof (a signed advert carrying the code), so there is one verification rule, not two.

    🤖 Generated with Claude Code

  7. dborup commented on Nov 29, 2026

    @dborup
    OwnerAuthor

    Owner decision (2026-11-29): also support an admin-login claim, as a weaker tier

    After comparing with MeshMapper (its app logs in to the repeater as admin through the companion, asks for the admin-only access list (ACL), and reports "admin login + ACL answered" to its server), the owner wants MeshView to also support that way of linking a repeater, as a separate, weaker tier. The signed-advert proof (manual, or the one-click browser flow) stays the verified way.

    How it works (M2): in Chrome, Edge or Brave the browser logs in to the repeater as admin through the owner's companion over Web Bluetooth or Web Serial (CMD_SEND_LOGIN), requests the ACL, and reports the result to the server. The companion must reach the repeater over the mesh (direct or via repeaters), as in remote management. No renaming.

    Why it is weaker: the server cannot check it. The login reply and the ACL reply are encrypted between the repeater and the companion, so a modified client could report a login that never happened.

    Rules:

    1. Labelled "admin login (self-reported)", never "verified".
    2. A verified owner always wins: a signed-advert proof for the same node replaces a self-reported link at once.
    3. Station data from a self-reported link is never auto-approved: it goes to admin review, even the structured fields that Antenna claims: opt-in auto-approval of station details (autoApproveDetails) #1007 auto-approves for verified owners.
    4. Rate limits per account and per node; every self-reported link is visible to the admin (who, when, which companion).
    5. The admin password never leaves the browser; radio settings are never touched over the mesh.

    The M2 plan should cover the UI wording for both tiers, how a self-reported link is shown on the node page (if at all publicly; ownership stays non-public per decision 4), the admin view, and tests for rule 2 and rule 3.

    🤖 Generated with Claude Code

  8. dborup commented on Nov 29, 2026

    @dborup
    OwnerAuthor

    Owner decision (2026-11-29): default admin passwords and takeovers (M2)

    The weak point is not the proof but the password. A signed advert proves that someone controls the node, not that they own it. Repeater firmware ships with the admin password password (firmware/examples/simple_repeater/MyMesh.cpp:32-33, ADMIN_PASSWORD, and the same in many variants/*/platformio.ini). Anyone within reach of a repeater that still has it can log in through remote management, rename it with a link code, send an advert and pass every proof we have (manual, one-click or self-reported). This applies to every claim method, MeshMapper's included.

    With decision 5 as written ("one owner per node, newest wins"), such a person would take over a node from its real owner.

    Required in M2:

    1. No silent takeover. When an account links a node that another account already owns, the current owner is told (on their account page, and by any channel the account has), and the change waits out a short objection window before it takes effect. During the window the current owner can keep the node with a fresh proof (one-click or manual). Only an uncontested proof takes over. This refines decision 5; "newest wins" applies after the window.
    2. Self-reported links never take over a node with a verified owner (already rule 2 of the admin-login tier above).
    3. Warn about the default password in the linking flow: when the one-click or admin-login flow logs in with password, tell the owner to change it, and link to the guide. Never store or send the password.

    The M2 plan should give the window length, the notification wording, what the node page shows during a contested change, and tests for: takeover with no objection, objection with a fresh proof, and a self-reported link against a verified owner.

    🤖 Generated with Claude Code

  9. dborup commented on Nov 29, 2026

    @dborup
    OwnerAuthor

    Owner decision (2026-11-29): several owners per node (replaces decision 5)

    A user confirmed how MeshMapper links repeaters and pointed out its main advantage: more than one owner can be registered on a repeater. Many Danish repeaters are run by a club or by two or three people together. The owner decided that MeshView follows suit.

    Decision 5 ("one owner per node, newest wins") is replaced by:

    1. Several owners per node, with a cap (default 5, operator config). A new proof adds an owner; it never removes one. This replaces the takeover/objection-window rule above: there is no takeover any more.
    2. Every verified co-owner may change the station data. Each change is logged with which account made it (visible to the owners and the admin).
    3. No owner can remove another owner. Only the admin can, and an owner can always remove themself.
    4. Existing owners are told when a new co-owner is added (account page, plus any channel the account has), and can object; an objection goes to the admin, who decides. This is the protection against a stranger who used the default admin password password.
    5. Self-reported (admin-login) links add a co-owner marked "self-reported". They count towards the cap, cannot change station data without admin review, and are listed separately from verified owners.
    6. Ownership stays non-public (decision 4); the node page may show "N verified owners" at most.

    The M2 plan should cover: the cap and what happens at the cap, the change log, the objection flow and admin view, how the #1017 station-data fields behave with several editors (last write wins, with history), and tests for each rule.

    🤖 Generated with Claude Code

  10. adminopenclaw8-sketch commented on Nov 29, 2026

    @adminopenclaw8-sketch
    Collaborator

    Research (M0) — CS-Macmini #1018 M2

    This is the plan for milestone M2 of #1018: linking repeaters and room servers to an owner account. It is research only. I wrote no code in the repo, made no commits and opened no PR. Nothing was sent to a live instance, a broker or a radio.

    It covers every owner decision from 2026-11-29:

    • the one-click browser flow;
    • the manual flow, which stays;
    • the "admin login (self-reported)" tier;
    • default admin passwords;
    • several owners per node, which replaces decision 5 and with it the takeover and objection-window rule.

    Sources and labels

    Source Version Use
    CoreScope origin/master 4cca61fc, read with git show / git grep M1 accounts (#1020), antenna claims, #1050 advert apply, the read-only invariant
    MeshCore firmware 75b04ef0 (2026-11-14), the local firmware/ clone companion protocol, repeater and room login, CLI, ACL
    meshguide.dk (MG) twinoak/meshguide.dk 9a5d7f5, WTFPL v2 (LICENSE:1-3) browser remote CLI over Web Bluetooth / Web Serial
    meshcore.js (MJ) liamcottle/meshcore.js af77cb0, MIT constants, framing, login, sendBinaryRequest, sign
    MeshMapper app (MM) MeshMapper/MeshMapper_Flutter_App bc1b8d6, MIT; wiki f9528a7 admin login plus the ACL proof; several admins per repeater

    The prior-art repos were cloned into a scratch directory and read only. None of their code was run.

    How to read the tags:

    • [K] I read it in source at the cited file:line. Firmware paths are under firmware/.
    • [T] I ran it.
    • [A] Assumption, inference or judgement.

    1. Conclusions

    1. The one-click flow works on today's firmware with five companion commands. [K]
      • CMD_SEND_LOGIN (26), then CMD_SEND_TXT_MSG (2) to send get name, set name … and advert as remote CLI.
      • CMD_SYNC_NEXT_MESSAGE (10) reads the replies, and CMD_LOGOUT (29) ends the session.
      • The proof is still the repeater's own signed advert carrying the link code. The server keeps one verification rule for the manual and the one-click flow, as the owner asked.
    2. The self-reported tier also works on today's firmware. It uses CMD_SEND_LOGIN plus CMD_SEND_BINARY_REQ (50) with REQ_TYPE_GET_ACCESS_LIST = [0x05, 0, 0]. The repeater answers it only to an admin.
      • Its reply cannot be checked by the server: it is ECDH-encrypted between the repeater and the companion. MeshMapper reports plain booleans for the same reason (MM repeater_admin_models.dart:207-213).
    3. A wrong admin password gets no answer at all, not a "login failed". The repeater returns 0 and sends nothing (examples/simple_repeater/MyMesh.cpp:102-110) [K]. The UI must say "no answer: wrong password, or the repeater is out of reach". It must not say "wrong password".
    4. The admin password goes from the browser to the companion over the local BLE/USB link and nowhere else.
      • The companion encrypts it inside an ANON_REQ to the repeater (src/helpers/BaseChatMesh.cpp:603-621) [K].
      • Only the first 15 bytes are sent (:611-616) [K]. A longer repeater password can never log in remotely, so the page must warn about it.
    5. The rename-back needs a second advert, sent at least 2 s after the first.
    6. Draining the companion's queue eats the owner's other messages. CLI replies arrive in the companion's offline queue (16 entries, FIFO), shared with DMs and channel messages. Whoever calls CMD_SYNC_NEXT_MESSAGE removes them (companion_radio/MyMesh.cpp:440-472,1415-1423; MyMesh.h:61-62) [K]. The browser must show those messages to the owner locally, or they are silently lost to the phone app.
    7. The default password password is real and everywhere. [K]/[T]
      • It is the fallback in simple_repeater/MyMesh.cpp:32-33.
      • [T] grep over variants/*/platformio.ini finds 288 ADMIN_PASSWORD= definitions in 89 files, and every one is "password".
      • A successful admin login also writes the logger into the repeater's ACL persistently as admin (MyMesh.cpp:112-128) [K]. Afterwards that companion can log in with a blank password (:92-99). An intruder keeps access after one login.
    8. With several owners there is no takeover left to defend against. What is left is vandalism and filling the cap. I propose:
      • a cap of 5, counting both tiers;
      • a verified proof at the cap evicts the newest self-reported link;
      • a per-node limit on new co-owners;
      • edits by a new co-owner of an already-owned node go to admin review for 72 h (open question 2);
      • objections go to the admin.
    9. The change log already exists. Every station edit is a row in node_antenna_claims (internal/dbschema/dbschema.go:1434-1449) [K]. Adding account_id, link_id and via to that row is the change log. With several editors, the order key becomes edit time ("last write wins, with history"). M0's "authority time = link proof time" rule existed only to defend a single owner against a takeover, and can be dropped (open question 7).
    10. Milestones:

    2. Firmware: companion protocol and remote admin [K]

    2.1 The commands the browser needs

    Step Frame sent to the companion Answer Evidence
    Who is the companion CMD_APP_START (1) RESP_CODE_SELF_INFO (5): carries the companion's public key companion_radio/MyMesh.cpp:9,80
    Repeater as a contact CMD_ADD_UPDATE_CONTACT (9): pubkey(32) type flags out_path_len …; 0xFF = flood OK, or ERR_CODE_TABLE_FULL (100 contacts, MyMesh.h:57-58) MyMesh.cpp:1328-1348; MG serial.js:365-377. MM never overwrites an existing contact, because "an add would wipe the learned route" (repeater_admin_session.dart:542-564)
    Login CMD_SEND_LOGIN (26): pubkey(32) ‖ password RESP_CODE_SENT (6) [flood, tag(4), est_timeout(4)]; ERR_CODE_NOT_FOUND if not a contact MyMesh.cpp:1577-1597
    Login result push PUSH_CODE_LOGIN_SUCCESS (0x85) [is_admin, prefix(6), server_ts(4), acl_perms, fw_level]; PUSH_CODE_LOGIN_FAIL (0x86) only for a reply in an unexpected shape — MyMesh.cpp:694-722; MM refuses fw_level == 0 (pre-v1.9) (repeater_admin_session.dart:154-158)
    CLI command CMD_SEND_TXT_MSG (2): [txt_type, attempt, ts(4), prefix(6), text] RESP_CODE_SENT MyMesh.cpp:1132-1179
    CLI reply push PUSH_CODE_MSG_WAITING (0x83), then CMD_SYNC_NEXT_MESSAGE (10) → RESP_CODE_CONTACT_MSG_RECV_V3 (16) [snr, r, r, prefix(6), path_len, txt_type=1, ts(4), text] RESP_CODE_NO_MORE_MESSAGES (10) when empty MyMesh.cpp:440-472,1415-1423; MG remote-cli.js:191-213
    ACL CMD_SEND_BINARY_REQ (50): pubkey(32) ‖ [0x05, 0, 0] push PUSH_CODE_BINARY_RESPONSE (0x8C) [0, tag(4), entries…], each entry prefix(6) perms(1) MyMesh.cpp:750-760,1720-1745; MM repeater_admin_models.dart:240-268
    End CMD_LOGOUT (29): pubkey(32) stops the keep-alive connection MyMesh.cpp:37,1748-1750

    Framing:

    • Web Serial: 115200 baud. Outgoing frames are '<' u16le len payload and incoming ones '>' u16le len payload (MG serial.js:86-112,599-601; MJ constants.js:5-8).
    • Web Bluetooth: the Nordic UART service 6e400001-…, with RX …02 for writes and TX …03 for notifications. One GATT write is one frame, with no header (MG ble.js:23-25,44-47,77-81; MJ constants.js:10-14).
    • Starting notifications brings up the OS pairing / PIN dialog (MG ble.js:62).

    2.2 What the repeater does

    Fact Evidence
    A login with the admin password gives PERM_ACL_ADMIN. A wrong password gives no reply. A blank password works for a key already in the ACL simple_repeater/MyMesh.cpp:90-143 (blank at :92-99, wrong at :107-110)
    A successful login puts the companion in the ACL. A non-guest entry is saved to flash :112-128; ACL size 32, oldest evicted (src/helpers/ClientACL.h:44-45, ClientACL.cpp:97-115)
    The login reply carries is_admin ([6]), the permissions ([7]) and FIRMWARE_VER_LEVEL ([12]) :134-143
    Remote CLI is admin only :702
    A CLI message with the same timestamp as the last one is a retry: it is acked, not executed again :710-711,736-739
    A TXT_TYPE_PLAIN CLI message is acked. For CLI_DATA the companion replaces the app's timestamp with its own clock, so every resend executes again :717-731; companion MyMesh.cpp:1149-1151; this is why MG sends CLI as PLAIN (remote-cli.js:16-30)
    set name X: refuses [ ] \ : , ? *, stores 31 bytes, saves, replies OK or Error, bad chars src/helpers/CommonCLI.cpp:22-28,530-537; CommonCLI.h:29
    get name replies > NAME, and works remotely (no serial-only guard) CommonCLI.cpp:716-717
    advert = a flood advert after 1.5 s, under the repeater's default scope; advert.zerohop is checked first CommonCLI.cpp:202-209; MyMesh.cpp:1033-1044
    The password <new> command echoes the new password back over the mesh CommonCLI.cpp:267-272
    Radio settings: set freq is serial-only, but other radio and routing commands (tempradio, repeat, lat/lon, …) work remotely CommonCLI.cpp:607 (freq guard); :252 (tempradio), :538-549 (repeat, lat, lon)
    ACL request: admin only, [0x05, 0, 0]. Every entry with perms != 0 (6-byte prefix plus perms), as many as fit MyMesh.cpp:262-273
    Room server: the same login (the room variant adds sync_since), CLI is admin only, and the ACL reply lists admins only simple_room_server/MyMesh.cpp:202-215,446-472; BaseChatMesh.cpp:610-613

    2.3 Prior art: what is done and what is not

    • meshguide.dk does the remote login and set name. It sends no advert: "the new name spreads at the device's next advert" (MG flow.js:523-572).
      • It makes 3 login attempts with a window of clamp(est_timeout + 3 s, 5 s, 20 s) (MG remote-cli.js:46-48,93-122).
      • It empties the queue before every send (:124-132) and refuses a guest login (app.js:481-485).
      • The password field has no default, and the help text says the factory password is password (index.html:236).
    • meshcore.js has login, sendBinaryRequest and sign. It has no LOGIN_FAIL handler and no ACL parser (MJ connection.js:405-406,1624-1688,1847-1914).
    • MeshMapper treats "admin login and an ACL answer" as the proof (isProven, MM repeater_admin_models.dart:205). It finds its own entry by the companion's key and discards the list, which is "never shown, never uploaded" (repeater_admin_session.dart:220-281).
      • The claim it sends is proof: {login, acl, perms, fw_level} (repeater_admin_models.dart:207-213).
      • Its server has a per-repeater admin cap (too_many_admins, repeater_admin_api.dart:72-73,240-256), but the value is not in the client. The server code is not public, so how MeshMapper verifies a claim is unknown.
    • None of the three sends advert after a rename. The rename-back in §4.3 is new ground.

    3. CoreScope: what M2 builds on [K]

    Area Where Fact
    Proof table internal/dbschema/dbschema.go:1491-1507 account_proofs.kind already allows 'link', and redeem_hash must be NULL for it. No schema change is needed for link codes
    Advert hook cmd/ingestor/accounts.go:124-143; main.go:1139-1142 Only new, signature-valid adverts. Today it returns unless Flags.Chat. M2 adds repeater and room adverts for kind='link'
    Duplicate matcher cmd/ingestor/accounts.go:147-178 vs antenna_claims.go:123-143 Two copies of "pending codes by pubkey". M2a extracts one shared type (DRY)
    Command validation internal/channelregistry/account/account.go:203-261 One shared Validate. New ops go here
    Revocations skip the write budget account.go:58-61 The M2 "remove myself" op should join IsRevocation, so a stolen session cannot lock an owner in
    Claims dbschema.go:1434-1449,1562-1572; antennaclaim.go:61-66,262-276 One row per edit, with status, approved_by ∈ {auto, admin, owner}, per-part ops and the in-force flags. NewerApprovedQuery
    Read-only invariant cmd/server/readonly_invariant_test.go:220 Every new table must join the DML regex
    Queue directories docker/nonroot.sh:56 account-requests already exists, and M2 reuses it
    Headers git grep No Content-Security-Policy and no Permissions-Policy, so a top-level page may use Bluetooth and Serial
    #1017 PR #1047 is open The hardware field does not exist on master yet. M2d depends on it

    4. Design

    4.1 Tiers and wording

    Tier How Label to the owner Label to co-owners Station edits
    verified the node's signed advert carries the account's link code (manual or one-click) "Verified owner" "Verified owner" structured fields auto-approved (decision 7); free text and photos go to admin review
    self_reported the browser says: admin login + ACL answered "Admin login (self-reported)", with the help text "MeshView cannot check this; a signed advert makes you a verified owner" "Admin login (self-reported)" always admin review (rule 3)

    The label never says "verified" for the second tier (rule 1). A verified proof by the same account replaces its own self-reported link, and the link history keeps the old row.

    4.2 Schema (ingestor-owned, internal/dbschema, joins AccountTables)

    CREATE TABLE account_node_links (
      link_id     TEXT PRIMARY KEY,                       -- random 32 hex
      account_id  TEXT NOT NULL REFERENCES accounts(account_id) ON DELETE CASCADE,
      pubkey      TEXT NOT NULL CHECK(length(pubkey) = 64),
      tier        TEXT NOT NULL CHECK(tier IN ('verified','self_reported')),
      method      TEXT NOT NULL CHECK(method IN ('manual','browser','admin_login')),
      status      TEXT NOT NULL CHECK(status IN ('active','left','removed','evicted','upgraded')),
      proof_id    TEXT NULL,          -- account_proofs.request_id (verified)
      proof_hash  TEXT NULL,          -- the advert's content hash (verified)
      reported_perms   INTEGER NULL,  -- self_reported: acl_perms byte from LOGIN_SUCCESS
      reported_fw      INTEGER NULL,  -- self_reported: FIRMWARE_VER_LEVEL
      created_at  INTEGER NOT NULL,
      ended_at    INTEGER NULL,
      ended_by    TEXT NULL CHECK(ended_by IS NULL OR ended_by IN ('owner','admin','verified_at_cap','upgrade')),
      show_public INTEGER NOT NULL DEFAULT 0 CHECK(show_public IN (0,1)),
      CHECK((tier = 'verified') = (proof_hash IS NOT NULL)),
      CHECK((status = 'active') = (ended_at IS NULL))
    );
    CREATE UNIQUE INDEX idx_links_one_active ON account_node_links(account_id, pubkey) WHERE status = 'active';
    CREATE INDEX idx_links_node_active ON account_node_links(pubkey) WHERE status = 'active';
    CREATE INDEX idx_links_account ON account_node_links(account_id, status);
    
    CREATE TABLE account_notices (      -- bounded: 200 per account, pruned after 180 d
      notice_id  TEXT PRIMARY KEY,
      account_id TEXT NOT NULL REFERENCES accounts(account_id) ON DELETE CASCADE,
      kind       TEXT NOT NULL CHECK(kind IN ('co_owner_added','co_owner_left','link_removed_by_admin',
                                              'evicted_at_cap','objection_opened','objection_decided')),
      pubkey     TEXT NOT NULL,
      link_id    TEXT NULL,             -- the other owner's link, never their account id
      tier       TEXT NULL,
      created_at INTEGER NOT NULL,
      read_at    INTEGER NULL
    );
    CREATE INDEX idx_notices_account ON account_notices(account_id, created_at);
    
    CREATE TABLE link_objections (
      objection_id TEXT PRIMARY KEY,
      link_id      TEXT NOT NULL REFERENCES account_node_links(link_id) ON DELETE CASCADE,
      by_account   TEXT NOT NULL REFERENCES accounts(account_id) ON DELETE CASCADE,
      reason       TEXT NOT NULL CHECK(reason IN ('not_an_owner','default_password','other')),
      note         TEXT NULL CHECK(note IS NULL OR length(note) <= 200),   -- admin only
      status       TEXT NOT NULL CHECK(status IN ('open','upheld','dismissed','withdrawn')),
      created_at   INTEGER NOT NULL,
      decided_at   INTEGER NULL
    );
    CREATE UNIQUE INDEX idx_one_open_objection ON link_objections(link_id, by_account) WHERE status = 'open';

    Notes on the schema:

    • The cap is enforced in the ingestor, inside the transaction. It counts status='active' rows for the pubkey with the partial index. SQLite cannot express it as a CHECK.
    • Station edits (M2d) add account_id, link_id and via ∈ {advert, link} as nullable columns on node_antenna_claims, with the existing self-healing ADD COLUMN pattern, as in M0 §4.4.
    • No new map[string]interface{}. Every response is a named struct.

    4.3 Proof paths

    A. Manual verified link (M2a): the same rule as M1 sign-in.

    1. POST /api/account/links {pubkeys:[…≤20]} issues one code. It writes one link command, and the ingestor inserts one account_proofs row per pubkey (kind='link', 24 h TTL).
    2. The page shows per node: set name <suggested> (within that node's budget, usually 23 bytes with a position), then advert, then the old name again.
    3. At ingest, a signature-valid, new, repeater- or room-type advert whose name carries a pending link code for that pubkey is a proof. In one transaction the ingestor runs the cap check (§4.4), inserts the link and writes the notices.

    B. One-click (M2b): the browser types A for the owner.

    The state machine lives in a new public/meshcore-link.js: a pure frame codec plus the flow, with the transport injected.

    1. Detect support. Check window.isSecureContext && ('bluetooth' in navigator || 'serial' in navigator). If neither exists, show only the manual flow (§4.8).
    2. Connect after a user gesture: requestDevice with the NUS filter, or requestPort. Then CMD_APP_START shows "Connected to <name> (a1b2…)".
    3. Make sure the repeater is a contact. Try the login first. On ERR_CODE_NOT_FOUND, add the repeater with CMD_ADD_UPDATE_CONTACT: the key from CoreScope, type repeater or room, out_path_len=0xFF. The page says "adds <node> to your companion's contacts". It never overwrites an existing contact (MM's reason above).
    4. Login. Use <input type=password autocomplete=off>, capped at 15 bytes with a warning.
      • Send CMD_SEND_LOGIN and wait clamp(est+3 s, 5 s, 20 s), up to 3 attempts.
      • No answer: "No answer: wrong password, or out of reach".
      • is_admin=0: "Logged in as guest: admin is needed", then stop.
      • The password variable is overwritten as soon as the SEND_LOGIN frame is written.
      • If the password was password, show the warning (§4.7).
    5. Get the code. POST /api/account/links {pubkeys:[pk], method:"browser"}. The code lives 15 min.
    6. Save the old name. Send get name and parse > NAME. The pendingRestore {pubkey, originalName, code, at} record goes into localStorage before anything changes.
    7. Rename. set name <SuggestedName(original, code, budget)> must return OK. Error, bad chars aborts the flow.
    8. Advert. advert must return OK - Advert sent.
    9. Wait for the proof. Poll the link request with the existing createStatusPoller. After 60 s with no proof, send advert once more. Give up after 3 min.
    10. Always rename back, in a finally, whether the proof came or not. Wait until at least 2 s have passed since the last advert, send set name <original> and expect OK, then send advert.
    11. Log out with CMD_LOGOUT. Clear pendingRestore only after the restore OK.

    Command allowlist (rule: radio settings are never touched):

    • The codec can encode only frame codes {1, 2, 9, 10, 26, 29, 50}.
    • CLI text must match one of ^get name$, ^set name [^\[\]\\:,?*]{1,31}$, ^advert$.
    • Binary requests must be exactly [5, 0, 0].
    • Anything else throws before it reaches the transport. A unit test pins this list, and mutants that widen it must fail.

    CLI sending:

    • CLI goes out as TXT_TYPE_PLAIN with a monotonic timestamp of max(now + companionOffset, last + 1), as MG does. A resend is then a retry and never a second advert (§2.2).
    • Before each command the queue is drained. Non-CLI messages found there go into a local "Messages your companion received meanwhile" list, which is never sent anywhere (§1.6).

    C. Self-reported (M2c). Steps 1–4 of B, then CMD_SEND_BINARY_REQ [5, 0, 0].

    • The browser checks that the ACL reply holds the companion's own 6-byte prefix with (perms & 3) == 3.
    • It then sends POST /api/account/links/self-reported {pubkey, companionPubkey, perms, fwLevel, aclHasCompanion: true}.
    • The server refuses the report unless:
      • companionPubkey equals the account's identity_pubkey (open question 4);
      • fwLevel ≥ 1;
      • perms & 3 == 3;
      • the node is a repeater or room and not hidden;
      • the rate limits allow it.
    • The ACL entries are never uploaded (as MM does).
    • Whether the default password was used is never sent. A server-side list of repeaters with the default password would be a target list (open question 6).

    What happens if the rename-back fails:

    Failure What happens
    BLE or USB drops, or the repeater goes out of reach, after step 7 pendingRestore survives in localStorage. Every page load and #/account shows a banner: "<node> still has the code in its name. Restore name". That reconnects, asks for the password again (it was never stored), then runs steps 10–11
    Another device, or the browser data was cleared The account page derives the warning read-only: the node's current name in nodes still contains a consumed link code of this account. That costs one indexed lookup per active link, and needs no write
    set name refused Show the exact reply, then the manual instructions: set name <original> + advert in the MeshCore app's remote admin
    The proof never came The rename-back still runs. The page offers a retry or the manual flow
    Safety A consumed code never matches again (single use), so a name left with a code is cosmetic only and cannot re-prove anything

    4.4 Co-owner rules (replacing decision 5)

    Rule Mechanism
    Cap: maxOwnersPerNode (default 5), counting both tiers Checked in the proof or report transaction
    A new verified link at the cap Evicts the newest active self-reported link (ended_by='verified_at_cap', with a notice to that account). If there is none, it is refused with "This node already has 5 owners. An owner can leave, or ask the administrator." The check runs when the code is issued and again at proof time (a race)
    A new self-reported link at the cap Refused
    Self-reported never displaces a verified owner By construction: self-reported links can only be added below the cap
    No owner removes another There is no such op. leave (self) and the admin's remove exist. leave counts as a revocation, so it is never budget-blocked
    Same account, verified after self-reported The old row becomes status='upgraded' and a new verified row is added. It does not count twice
    New co-owners per node At most 3 new owners per node per 24 h, and at most 1 self-reported per node per 24 h. This blunts filling the cap with fresh keys
    Probation (open question 2) For 72 h after joining a node that already had owners, the new co-owner's edits all go to admin review
    Hidden nodes (#743 / #1023) Codes are refused with the identical 404. Links to a node that becomes hidden stay but are not served publicly

    4.5 Notices and objections

    • Channels: the account page and a dot on the Home "Account" entry. No other channel exists (M1 has no e-mail, by design). Notices are bounded at 200 per account and 180 days. Marking them read is a notices-read op that carries the latest seen id.
    • Wording (other owners are never named by key):
      • added: "A new co-owner was added to Hilltop on 29 Nov (verified owner / admin login, self-reported). If you don't know who this is, you can object."
      • left: "A co-owner left Hilltop."
      • decided: "The administrator decided your objection about Hilltop: the co-owner was removed / kept."
    • Who may object: verified owners active when the new link was made, within 30 days. One open objection per owner per link, and at most 10 open objections per account. The reason is a fixed choice plus an optional 200-character note, which only the admin sees.
    • While an objection is open: the objected owner's edits go to admin review, the node page shows nothing new publicly, and owners see "Objection open" on the owner card.
    • The admin's decision:
      • Uphold removes the link (ended_by='admin'). It offers "also revoke the station data this link put in force" through the existing per-claim revoke.
      • Dismiss keeps the link.
      • Both write objection_decided notices.

    4.6 Admin view (requireAPIKey)

    Endpoints:

    • GET /api/admin/account-links?status=&tier=&pubkey=&objection=open&limit=100&before=, paginated;
    • POST /api/admin/account-links/{linkId}/remove;
    • POST /api/admin/link-objections/{id}/decide {decision}.

    Each row shows:

    • the node;
    • the account id, the display name and the full companion key (decision 12);
    • the tier and method, and when it was made;
    • for verified links, the proof advert hash linked to #/packets/{hash};
    • for self-reported links, the reported perms and firmware level and "reported from the account's own companion: yes";
    • open objections.

    Placement: a new "Owners" section next to the antenna-claim queue in antenna-claims.js. The same list filtered to tier=self_reported gives rule 4's "every self-reported link visible to the admin".

    4.7 Default password

    • The check is local only: if (password === 'password'), after a successful admin login.
    • The warning text: "This repeater still uses the factory admin password. Anyone in radio range can take control of it. Change it now: in the MeshCore app's remote admin, run password <new> (not set password)." It links to the guide.
    • The flow never sends password <new> itself. The repeater echoes the new password over the mesh (CommonCLI.cpp:267-272), and the owner decision says the password is never handled beyond the login.

    4.8 Browser support

    • Detection is by feature, never by user agent.
    • Web Bluetooth: Chrome and Edge on desktop and Android [A, the usual matrix].
    • Brave: behind brave://flags/#brave-web-bluetooth-api, with the error "Web Bluetooth API globally disabled" special-cased (MG app.js:227-231, flow.js:56-62).
    • Web Serial: Chrome and Edge on desktop [A].
    • Never available: Safari / iOS, Firefox and WiFi companions. These get the manual flow only, with one line: "One-click needs Chrome or Edge with Bluetooth or USB. Use the steps below."
    • One BLE client at a time [A]: the page says "Close the MeshCore app on your phone first".

    4.9 UI

    At 375×560 (one column, 16 px gutter, primary button at the bottom):

    1. Link a node. My nodes lists only repeaters and rooms, with Link with Bluetooth/USB (shown only when supported) and Link by hand.
    2. One-click.
      • Connect, with the companion name shown.
      • The password field, with "never leaves this browser, sent encrypted by your radio".
      • A progress list with one aria-live line per step: Logged in → Code set → Advert sent → Heard by MeshView ✓ → Name restored ✓.
      • Cancel stays visible and always runs the restore.
    3. By hand. The M0 §5.4 list: one row per node with the command, Copy and a status chip.
    4. Owner card per node. "Verified owner" or "Admin login (self-reported)". Co-owners show as "3 co-owners (2 verified, 1 self-reported)", expandable to display names or "Co-owner A/B". Actions: Leave, Object (only on rows that allow it), and for self-reported links Become verified (runs B).

    Desktop: the same steps in one 480 px card. The owner roster is a small table.

    Node page: public content is unchanged unless at least one owner opted in. Then it shows "N verified owners", counting verified links only (decision 4 and rule 6). Self-reported links are never counted publicly.

    Deep links:

    • #/account?tab=links;
    • #/account?tab=links&node=<pubkey> (owner card);
    • #/account?tab=notices.

    4.10 Station data with several editors (M2d)

    • Last write wins by edit time: created_at, then request_id as the tie-break. Every edit is a claim row with account_id, link_id and via='link'.
    • Change log: GET /api/account/nodes/{pubkey}/history, for owners only. Each entry is {at, by: displayName | "Co-owner A" | "advert claim", parts, status}. It never includes contactAdmin, and a reflection test covers that, as in M1.
    • Approval:
      • verified, structured fields: approved_by='auto';
      • contactPublic and the photo go to review (the decision-7 clarification);
      • self-reported, an open objection, or probation: everything goes to review.
    • A direct per-node advert claim stays exactly as it is today.

    4.11 Rate limits (server in-memory, plus ingestor checks inside the transaction)

    Limit Default
    Pending link codes per account 20; per node, all accounts together: 4
    Link code requests per account per hour 30
    Self-reported reports 5 per account per 24 h; 1 per node per 24 h; at most 20 active per account
    New owners per node 3 per 24 h
    Open objections per account 10
    Global the M1 writesPerHour window. leave and notices-read are never charged

    4.12 Perf (rule 0)

    • Ingest: observeAdvert widens from chat to repeater and room adverts. The cost stays one map lookup when anything is pending, and nothing otherwise. The scan per key is bounded (4 codes × 31 bytes). One shared pending map serves claims and accounts.
    • Server:
      • /api/account grows by the account's links, at most 200, read through idx_links_account;
      • the owner count on the node page is a 30 s snapshot map[pubkey]int of opted-in verified links, bounded by the active links, the same pattern as ownerStations. It is not added to /api/nodes or bulk-health;
      • the admin list is paginated.
    • Browser: BLE/USB I/O only during the flow. No polling faster than the existing poller's backoff.
    • Proof before merge:
      • a benchmark of observeAdvert with 0, 500 and 5,000 pending codes;
      • /api/account with 200 links;
      • the snapshot build with 10,000 links.

    5. Milestones and tests

    M2a: verified linking (manual), co-owners, notices, objections, admin view.

    Build:

    • schema §4.2;
    • the shared pending-code matcher;
    • the ops link, leave, link-visibility, notices-read, object, objection-withdraw, and admin remove / decide;
    • the routes from §4.3A, §4.5 and §4.6;
    • the account-page tab and the owner cards.

    Tests:

    • one code proves N nodes separately, and a missing advert stays pending;
    • a chat advert never links, and a forged signature or isNew=false never proves;
    • the cap at 5: the sixth verified link evicts the newest self-reported one, and the sixth with none to evict is refused at issue and at proof (a race test);
    • verified vs self-reported at the cap (rule 2);
    • no op removes another owner (a reflection test over Validate);
    • notices are written for added, left, evicted and decided;
    • objection uphold and dismiss, a second open objection refused, objections closed after 30 days;
    • hidden node → 404;
    • readonly_invariant_test gets the three new tables plus a sensitivity test;
    • Playwright at 375×560 and desktop for the manual link, the owner card and the objection, added to scripts/e2e-shards.json.

    Mutants: drop the cap check, drop the eviction order, let leave take a link id.

    M2b: one-click flow.

    Build: public/meshcore-link.js (codec, transports, flow) with no npm dependency, prior art credited in its header.

    Tests with a fake companion in Node vm and in Playwright that emulates the frames of §2.1 byte for byte:

    • the happy path;
    • no answer to the login, and a guest login;
    • Error, bad chars;
    • the proof times out → the rename-back still runs;
    • the transport drops after the rename → pendingRestore banner → restore;
    • at least 2 s between the two adverts;
    • the allowlist rejects set freq, password, tempradio and CMD 11 (CMD_SET_RADIO_PARAMS);
    • password containment: Playwright watches every request URL, body and header plus localStorage / sessionStorage and asserts the typed password never appears;
    • the default-password warning appears for password only;
    • other queued messages are shown, not dropped.

    Browser validation needs a real companion and repeater (open question 13).

    M2c: self-reported tier.

    Tests:

    • the report is accepted only with the account's own companion, admin perms and fwLevel ≥ 1;
    • station edits from a self-reported link always go to review, even structured fields with autoApproveDetails on (rule 3);
    • a verified proof by the same account upgrades the link;
    • the rate limits;
    • the admin list shows it.

    M2d: station data through links plus the change log (after #1047).

    Tests:

    • last write wins across two co-owners, with the history listing both;
    • probation and objection force review;
    • contactAdmin absent from history (reflection);
    • the tie-break mutant.

    Customizer (rule 8): none. accounts.maxOwnersPerNode, newOwnersPerNodePerDay, probationHours and objectionDays are operator settings in config.json, read by exact key.


    6. Open questions for the owner (each with a recommended default)

    1. Cap. Default 5, both tiers count. A verified proof at the cap evicts the newest self-reported link.
    2. Probation for a new co-owner's edits on an already-owned node. Default 72 h of admin review. Without it, a stranger with the default password can change station data right away, and objections only help afterwards.
    3. Objections. Default: verified owners only, within 30 days. The reason is a fixed choice, with a note only the admin sees.
    4. Self-reported only from the account's own companion (SELF_INFO key = identity_pubkey). Default yes.
    5. Self-reported proof bar. Default: admin login and an ACL answer listing the companion as admin, fw_level ≥ 1 (MeshMapper's isProven).
    6. Default password reported to the server? Default never, a local warning only.
    7. Edit order. Default: last write wins by edit time, dropping M0's "authority time = link proof time" rule.
    8. Public display. Default: "N verified owners" only when at least one owner opts in; self-reported never counted.
    9. CLI text type. Default TXT_TYPE_PLAIN with a monotonic timestamp, as meshguide, so a retry never sends a second advert.
    10. Code reuse. Default: our own small module, crediting MG (WTFPL) and MJ (MIT). No npm dependency (AGENTS.md).
    11. Messages drained from the companion's queue. Default: show them locally in the flow, never upload.
    12. Rename-back advert. Default yes, a flood advert after the restore. Otherwise the coded name can stay visible for up to 47 h.
    13. Hardware validation. I have no radio. Default: the owner (or a tester) runs M2b and M2c against a real companion and repeater on staging before merge, with screenshots at 375×560 and on desktop.
    14. Corroboration from observed ANON_REQ packets (the companion's login request heard on air). Default no: it shows an attempt was made, not that it succeeded.
    15. Room servers. Default yes, the same flows. Their ACL reply lists admins only, which still satisfies question 5.
    16. Order. Default: M2a → M2b → M2c → M2d, with M2d after Station details: the hardware catalogue and the hardware claim field (#1017 M1) #1047 merges.

    🤖 Generated with Claude Code

  11. dborup commented on Nov 29, 2026

    @dborup
    OwnerAuthor

    Owner decisions (2026-11-29) on the M2 plan's 16 open questions

    The M2 plan ("## Research (M0) — CS-Macmini #1018 M2") is approved. The owner went through the questions one by one. 15 defaults stand; question 2 is changed.

    1. Cap: 5 owners per node, both tiers count; a verified proof at the cap evicts the newest self-reported link.
    2. Changed: no probation. A new co-owner of an already-owned node can change station data right away (no 72 h admin review). Protection comes from the notices and objections (3), the change log, and self-reported links never editing without review.
    3. Objections: verified owners only, within 30 days; the reason is a fixed choice, with a note only the admin sees.
    4. Self-reported only from the account's own companion (SELF_INFO key = identity_pubkey).
    5. Self-reported proof bar: admin login and an ACL answer listing the companion as admin, fw_level ≥ 1.
    6. Default password: never reported to the server; a local warning only.
    7. Edit order: last write wins by edit time; every change in the log with who made it.
    8. Public display: "N verified owners" only when at least one owner opts in; self-reported never counted.
    9. CLI text type: TXT_TYPE_PLAIN with a monotonic timestamp, so a retry never sends a second advert.
    10. Code: our own small module, crediting meshguide.dk (WTFPL) and meshcore.js (MIT); no npm dependency.
    11. Messages drained from the companion's queue: shown locally in the flow, never uploaded.
    12. Rename-back advert: yes, a flood advert at least 2 s after the restore.
    13. Hardware validation: M2b and M2c are run against a real companion and repeater on staging before merge, with screenshots at 375×560 and on desktop.
    14. ANON_REQ corroboration: no.
    15. Room servers: yes, the same flows.
    16. Order: M2a → M2b → M2c → M2d (M2d after Station details: the hardware catalogue and the hardware claim field (#1017 M1) #1047 merges).

    M2a (verified manual linking, co-owners, notices, objections, admin view) can start.

  12. 12 remaining items

  13. added a commit that references this issue on Dec 1, 2026
  14. dborup commented on Dec 1, 2026

    @dborup
    OwnerAuthor

    M1b (sign in with a signed nonce over Bluetooth/USB, shared public/companion-link.js) merged in #1070 (841ce7c) after independent reviews and green CI. Owner decision: merged before the full hardware checklist — Chrome + Bluetooth passed on staging; the owner tests the remaining items later. M2b (#1067) is tested on staging before merge.

  15. dborup commented on Dec 2, 2026

    @dborup
    OwnerAuthor

    Owner decision (M2b, after a hardware test): for the one-click link, a successful admin login to the node through the companion is enough proof of ownership. No rename, no code in the name, no advert. The server cannot verify the login itself; this is accepted because ownership is low-stakes (e.g. setting the antenna height). The default and empty admin passwords are refused, the proof kind is recorded (admin-login), and the manual code-in-name flow stays. #1067 is being reworked accordingly, together with a fix for a second login that got no answer right after a failed run.

  16. dborup commented on Dec 2, 2026

    @dborup
    OwnerAuthor

    Owner decision (2026-12-02) for M2c/M2d: owners linked by the one-click admin login (tier self_reported) may write station data too, the same as verified owners. Ease of use comes first; the risk of someone scripting a claim on a node they do not own is accepted. Verified and self-reported owners stay distinguishable in the data (proof kind recorded).

  17. dborup commented on Dec 2, 2026

    @dborup
    OwnerAuthor

    Owner hardware test (2026-12-02): the one-click link by admin login (#1067, M2b) works with a real companion over Bluetooth on staging. #1067 merges once CI is green (the only red job is the known TestHiddenFilterPacketsNoExtraAllocs flake, fix in progress).

  18. added a commit that references this issue on Dec 2, 2026
  19. dborup commented on Dec 2, 2026

    @dborup
    OwnerAuthor

    M2b merged via #1067 (9687204e): one-click linking by admin login (self-reported tier), owner-tested over Bluetooth. Next: M2d (#1095, station data through links) is in review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions