Repository navigation
Description
Request: #1130
Problem
From #1130, item 5: an operator "has to leave the console for the CLI" to "change any setting." The console's Settings page shows the daemon's settings, and beside each one a simlock config set command to copy into a terminal on the daemon's machine.
Every change also waits for a restart, and the only way to restart is a terminal (simlock daemon stop, then simlock daemon start). The CLI writes config.json behind the running daemon's back, so nothing shows that a saved value is not yet the one in use.
Who it is for
A developer running one worker for their own coding agents, and an operator running a gateway. Both keep the console open all day and want to change a timeout, an emulator flag or the HTTP port without a terminal.
Outcome
From the console of a worker or a gateway, an operator:
- sees every setting: its value now, the value saved for the next start, its default, and whether a change applies at once or on restart;
- changes any setting but the two that name a program and the four that join a worker to a fleet, checked by the rules of
simlock config set, with the same refusal message for a bad value; - puts a setting back to its default;
- sets or replaces a secret without ever seeing it on the page;
- is asked first before a change that can cut the console off;
- restarts the daemon from the page when a saved change waits for a restart.
simlock config set keeps working, and goes through the running daemon. simlock daemon restart restarts it from a terminal.
How it works for the user
flowchart TD
A[Settings page, Daemon card] --> B[Rows by section: value, default, Live or On restart]
B -->|Edit| C[Dialog: new value, or Use default]
C -->|Save, a key that can cut the console off| D[Confirm naming the risk]
D -->|Keep| C
D -->|Save| E[Daemon checks the whole file]
C -->|Save, other key| E
E -->|refused| F[Error toast; the dialog keeps the typed value]
E -->|live key| G[Saved and applied now]
E -->|restart key| H[Saved; row reads Restart pending]
H --> I[Restart daemon, confirm]
I --> J[Console reconnects and shows the new values]
The CLI, before and after, with the daemon running:
$ simlock config set idle.shutdownAfterMs 300000
Updated idle.shutdownAfterMs in /Users/me/.simlock/config.json; takes effect on daemon restart. (today)
Updated idle.shutdownAfterMs in /Users/me/.simlock/config.json; applied now. (after)
$ simlock config set lease.defaultTtlMs 10m
{"error":{"code":"USAGE","message":"Invalid config after setting lease.defaultTtlMs: ..."}} (today and after, exit 2)
$ simlock daemon restart
{"error":{"code":"USAGE","message":"Unknown daemon command: restart"}} (today, exit 2)
Daemon restarting (after)
With no daemon running, simlock config set writes the file itself and prints what it prints today.
Over HTTP, after:
PATCH /v1/settings { "idle.shutdownAfterMs": 300000, "gateway.label": null }
200 { "rows": [ ... ], "removed": [] }
Examples
What a change does while a worker runs:
| Change | Today (config set, file only) |
After |
|---|---|---|
idle.shutdownAfterMs 300000 |
saved, applies on restart | saved and applied now |
lease.defaultTtlMs 600000 |
saved, applies on restart | saved, row reads Restart pending |
http.port 4800 |
saved | confirm first; saved; the page shows the new address |
gateway.label null, PATCH |
no such call | the key leaves the file; the default (unset) holds after a restart |
gateway.label null, CLI |
refused, exit 2 | refused, exit 2, as today |
| two keys in one PATCH, one bad | no such call | refused, neither saved |
idle and idle.deleteAfterMs in one PATCH |
no such call | refused: Keys overlap: idle and idle.deleteAfterMs |
gateway.token alone |
refused: needs gateway.url |
refused the same way, no value shown |
gateway.admission.command, CLI on the machine |
saved | saved |
gateway.admission.command, PATCH |
no such call | refused 403 |
gateway whole, with another admission.command, PATCH |
no such call | refused 403 |
gateway whole, with the same admission.command, PATCH |
no such call | saved |
warmPool.targets |
saved, applies on restart | the same, from the console too |
idle.shutdownAfterMs "soon" |
refused, exit 2 | refused, 400 or exit 2 |
foo.bar 1 |
refused: unknown key | refused: unknown key |
foo..bar 1 |
refused: Invalid config key: foo..bar |
the same |
__proto__.x 1 |
accepted, and nothing useful is written | refused: Invalid config key: __proto__.x |
mode "gateway" |
refused | refused; no row |
What could go wrong
- A host or port change leaves the console on an address the operator must type. Turning HTTP off ends the console until the CLI turns it on again. The confirm says so.
- A restart that does not come back leaves the console on "Reconnecting"; the reason is in
daemon.log. Likely only after a host or port another program holds. - A hand edit of
config.jsonmade in the same moment as a save can be lost. Rare. - A lease request still waiting when the daemon restarts fails and must be sent again, as with any restart.
Words used
- setting: one key of
config.json, e.g.idle.shutdownAfterMs. - live key: a setting the daemon applies the moment it is saved, e.g.
idle.shutdownAfterMs. - restart key: a setting saved now and applied at the next start, e.g.
http.port. - running value: what the daemon uses now. Saved value: what
config.jsongives at the next start. - pending: a setting whose saved value differs from its running value, e.g.
http.portsaved as 4800 while the daemon listens on 4701. - secret:
gateway.token,gateway.headersorgateway.alerts.destinations; set or replaced, never shown. - program key: a setting that names a program the daemon runs:
gateway.admission.commandorcapabilities.agent-device.command; changed on the machine only. - lock-out key: a setting that can cut the console off:
http.enabled,http.host,http.port,http.proxyAuth. - json row: a setting edited as one JSON value, e.g.
warmPool.targetsorcapacity.
Non-goals
- Changing a worker's settings, or restarting it, through its gateway.
- An unset command in the CLI.
- Making more keys live than the three of I4.
- Changing what
config.get,simlock configandGET /v1/configanswer. (They do show a live key's new value.) - Changing warm targets without a restart (Console: warm the pool up and down, and add a device from the catalog, without a restart #1137).
simlock config seton a remote daemon (--url): refused, as today.- Joining a worker to a fleet from the console.
Completion conditions
- On a worker's console, Settings lists the settings with running value, saved value, default and Live or On restart; secrets read Set or Not set.
- Saving
idle.shutdownAfterMsfrom the console applies it with no restart: an idle device shuts down after the new time. - Saving
http.portasks first, then shows the new console address and Restart pending; after Restart daemon the daemon listens on the new port. - Use default on a key the file sets removes it from the file.
- A bad value is refused with the same message from the console and from
simlock config set, and the file is unchanged. - A program key is refused over HTTP and has no Edit on the page;
simlock config seton the machine sets it. simlock config setwith a daemon running is written by the daemon and emitsconfig.changed, naming the key and the caller and no value.simlock daemon restartrestarts the daemon, and refuses whileconfig.jsondoes not load.- On a gateway's console, Settings lists only the gateway's own settings.
Open questions
none
Decisions
- ADR 0099 — The daemon owns config.json while it runs, and the console edits settings through it (PR docs(adr): 0099 the daemon owns config.json while it runs, and the console edits settings through it (#1151) #1989): one writer,
GETandPATCH /v1/settings, three live keys, write-only secrets, program keys on the machine only, restart through the updater. It replaces the draft ADR 0057 (docs(adr): propose 0057, the daemon owns config.json while it runs (#1151) #1152). - ADR 0042 — Simlock updates itself through a frozen call and a detached updater: the restart reuses its updater process;
daemon.updatedoes not change. - ADR 0037 — The console acts through the HTTP routes: saving and restarting are actions with a confirm and toasts.
- ADR 0044 — The console reads what its page shows, and events mark it stale:
config.changedmarks the settings read. - ADR 0065 — A driver owns its config keys: a driver's and a module's rows come from the values, and no second list of keys is kept.
- Answered by the maintainer: one resource
/v1/settingsbeside/v1/config, changed by PATCH with a body of dotted keys;nullremoves a key; program keys on the machine only; no wait for Console: warm the pool up and down, and add a device from the catalog, without a restart #1137; editing in a dialog. - Decided in the session: the Daemon card of the existing Settings page becomes editable, because a second page would show the same settings twice.
- Decided in the session:
gateway.headersis a secret row, becauseredactConfigmasks it. - Answered by the maintainer after the check: the two capture-program keys are removed; the fleet keys have no Edit; turning HTTP off is the only change of
http.enabledthat asks; a row's default is what a removal gives. - Decided in the session: the dialog starts with the saved value, because the running one would undo a change that waits.
- Decided in the session:
config setanddaemon restartwait at most 30 s for a daemon, because neither may hang and a local call has no limit today. - Decided in the session: the updater passes
--localfor a worker in update mode too, because the same start would fail there. - Decided in the session: a driver or module key with no default has a row only once the file sets it (
android.emulator.cores,capabilities.agent-device.ios.teamId), because its validator does not list its keys; PATCH andconfig setstill take it. - Decided in the session:
daemon.restartrefuses whileconfig.jsondoes not load, because the daemon would stop and not come back. - Decided in the session: a key with a segment
__proto__,prototypeorconstructoris refused, because the daemon now applies keys sent over the network. - Decided in the session: the lock-out confirm for a host or port names no address; the page shows it after the save, as the daemon answered it, because the console may not import the code that builds it.
- Decided in the session: an operation takes
setandunsetapart, and only the HTTP body readsnullas a removal, because the CLI refusesnulltoday and goes on doing so. - Decided in the session: the Copy button stays on program keys only, because every other key has Edit.
Behaviours
| Id | Behaviour (invoker, action, what it sees) | Seam | Cases | Task |
|---|---|---|---|---|
| B1 | An admin reads GET /v1/settings on a worker and gets one row per setting with its kind, running, saved and default values and how it applies |
startDaemon through the admin client, the socket and createHttpApp |
a number key; an enum key with its values; a json key (warmPool.targets, capacity); a driver's key from the values (android.emulator.gpu); a module's key (capabilities.agent-device.command, machineOnly); a drivers.* key at its driver's default; http.proxyAuth as one row; an optional key unset (gateway.label, no values); android.emulator.cores unset (no row) and set (a row); no mode row; a live key; a restart key; a key the file sets (inFile) and one it does not |
#1153 |
| B2 | A secret row says only whether it is set | same | each of gateway.token, gateway.headers, gateway.alerts.destinations set and unset; gateway.token changed in the file after start (set, pending); the answer's text holds none of the values |
#1153 |
| B3 | A row says pending when the file differs from what runs | same | a restart key changed in the file after start (pending); a live key changed by hand (pending); the file no longer loads (fileProblem, no saved, not pending); an unknown key in the file (no fileProblem, as a start only warns); no file (saved is each default); the file unreadable (fileProblem the error's message); a fileProblem over 2000 characters (cut with …) |
#1153 |
| B4 | A gateway lists only its own settings, and an agent is refused | same | gateway: http.port and gateway.disconnectedRetentionMs listed; idle.shutdownAfterMs, gateway.token, gateway.headers and gateway.localLeases not; a module key the gateway ignores not, enabled and capabilities.agent-device.leaseTtlCapMs once set listed; an agent token 403; the call over the socket (getSettings()) |
#1153 |
| B5 | The answer says where the console will be after a restart | same | HTTP on: the address of the saved http values; HTTP off in the file: null; the file does not load: the running address |
#1153 |
| B6 | An admin changes settings with PATCH /v1/settings and the daemon writes the file once and answers the rows |
startDaemon through createHttpApp, a memory filesystem |
a restart key (file changed, running unchanged, pending); a live key (running changed, config.get shows it); a parent key idle; a field inside a json row (http.proxyAuth.header); two keys in one write; null removes a key; null for a key the file does not set (200, file written the same); gateway.url, gateway.token and http.enabled together on a worker; a key a gateway ignores (saved); eventLog.rotateBytes in the file (dropped, listed in removed); other keys and a hand edit kept; file mode 0600; two calls at once both kept |
#1154 |
| B7 | A saved live key is used on the next run of everything that reads it | startDaemon with a fake clock and a ready idle device |
idle.shutdownAfterMs lowered: the reaper, and the warm pool on a never-leased ready device no target keeps; idle.deleteAfterMs lowered; diskPressure.freeBytesThreshold raised over the free disk: the reaper reports pressure, a lease file upload is refused, a seed settle waits; a removed live key goes back to its default now; a live key changed by hand is not applied by a save of another key |
#1154 |
| B8 | A bad change is refused and the file is unchanged | same as B6 | a wrong type; an unknown key; lease.defaultTtlMs over lease.maxTtlMs; mode; one good and one bad key; overlapping keys; a key both set and unset; a bad gateway.token refused with no value in the message; an empty segment; __proto__.x; constructor.x; a __proto__ object inside a value (dropped or refused, nothing inherited); an empty body; 51 keys; a 201-character key; the file not valid JSON; the file not an object; the write fails (500 INTERNAL, no event, the running value unchanged) |
#1154 |
| B9 | A program key changes only over the local socket | same, the socket and acceptSession |
a bad value of the key (still 403); PATCH of the key, of its parent with another value, and null for it: 403 with the message; the parent with the same value: saved; over a remote session and over the uplink: refused; over the socket: saved; capabilities.agent-device.command the same |
#1154 |
| B10 | A change emits config.changed with the keys, how they applied and the caller |
same as B6 | live key; restart key; a live and a restart key together (restart); no event on a refusal; the payload holds no value |
#1154 |
| B11 | simlock config set goes through a running daemon and writes the file itself when none runs |
runCli (src/cli/index-device-config.test.ts) |
daemon running: written by the daemon, applied now. for a live key, takes effect on daemon restart. for another; none running: written by the CLI, no daemon started; --gateway with no gateway present: written by the CLI; null: refused, exit 2, with and without a daemon; __proto__.x refused with no daemon; no admin token: FORBIDDEN, file unchanged; a daemon's BAD_REQUEST prints USAGE and its message, exit 2; eventLog.rotateBytes dropped by the daemon: today's Removed line; a socket file a crashed daemon left: written by the CLI; a daemon that takes the connection and never answers, and one still starting: I16's error after 30 s on a fake clock; one that stops, or speaks another protocol: that error; the CLI writes nothing in any of them, and at the limit the connection is closed, before and after hello |
#1154 |
| B12 | An admin restarts the daemon with POST /v1/restart and the daemon launches the updater once in restart mode |
startDaemon with FakeUpdaterLauncher, the socket and createHttpApp, worker and gateway |
first call 202 and one launch with the pid and the role; a second call 202, no second launch; during an update, waiting included, 503 DAEMON_UPDATING; a new daemon.update during a restart DAEMON_STOPPING, while daemon.update {query} answers as today; config.json does not load: 400 and no launch; the launch throws: 500 INTERNAL and a later call launches again; the updater exits non-zero before the stop: a later call launches again, no daemon.update-failed, no update field set; an agent 403 |
#1155 |
| B13 | The updater in restart mode stops the daemon and starts it again, with no install | runUpdater (src/updater/index.test.ts), NodeUpdaterLauncher (src/ports/updater-launcher.test.ts) |
the launcher's arguments are --restart --pid <pid>, plus --gateway for a gateway; --restart with --from is refused; running at any version: exit 0, no npm call, no backup, no result file; the old pid still alive after 10 minutes: SIGKILL; not started in 2 minutes: one stderr line, exit 1, nothing reinstalled; a worker's start passes --local, in an update too |
#1155 |
| B14 | simlock daemon restart asks the running daemon to restart |
runCli |
running: prints Daemon restarting, --json {"status":"restarting"}; none running: prints Daemon not running, --json {"status":"not-running"}, exit 0, as daemon stop does; a daemon that never answers: I19's error after 30 s, the connection closed; a refusal printed, exit by its code; --url: refused as daemon stop is; --gateway with no gateway: GATEWAY_NOT_PRESENT |
#1155 |
| B15 | An operator opens Settings and sees the Daemon card's rows grouped by section | the model and screen markup, and ui/src/screens/settings/settings.dom.test.tsx |
a value with its default; a pending row adds Saved: <value>; Set and Not set; Live, On restart, Restart pending; a program key with Copy and no Edit; a worker's gateway.url, gateway.token, gateway.headers and gateway.localLeases with no Edit, and gateway.label with it; a removed key with no default (Saved: Not set); a pending secret with no Saved: line; fileProblem above the rows with no Restart daemon; 403 and 404 as today; a gateway's rows |
#1156 |
| B16 | An operator edits a row in a dialog and saves it | ui/src/screens/settings/settings.dom.test.tsx |
boolean, number, string, enum, json; a pending row opens with its saved value; a number or json that does not parse is refused in the dialog and nothing is sent; Use default on an inFile row sends null, and is absent on another; a refusal shows the daemon's message and the dialog keeps the typed value; a lost connection shows The daemon did not answer.; a secret's field starts empty and an empty one cannot be saved; Cancel sends nothing; after a 200 the dialog closes and the answer's rows are shown |
#1156 |
| B17 | A lock-out key asks first and then the page says what the restart does | same | http.port; http.host; http.enabled false; http.enabled true (no confirm); http.proxyAuth; Use default on http.host, http.port, http.proxyAuth (the same confirm) and on http.enabled (a confirm only when its default is false); Keep sends nothing and keeps the dialog; the line above the rows while an http.* row is pending: an address, or HTTP off |
#1156 |
| B18 | An operator restarts the daemon from Settings | same | Restart daemon only with a pending row; confirm, one POST /v1/restart, the success toast; Keep sends nothing; a 503 shows the daemon's message; after the reconnect the rows are read again |
#1156 |
| B20 | drivers.ios.screenCaptureCommand and drivers.ios.deviceCaptureCommand no longer change the capture program |
the driver's index.ts (src/drivers/ios/index-screen-tool-versions.test.ts) |
each set in the config: the packaged program runs | #1154 |
| B19 | config.changed marks the settings read stale |
ui/src/model/stale-keys.test.ts |
config.changed marks ['settings']; lease.granted does not |
#1156 |
Stored state
none
Interfaces
| Id | What | Shape and bounds | Errors and limits | Where | Task | Used by |
|---|---|---|---|---|---|---|
| I1 | A settings row | { key, kind, values?, running?, saved?, default?, inFile, apply, secret, set?, machineOnly, pending }. key 1 to 200 characters. kind boolean, number, string, enum (with values, the enum's strings) or json. A value is any JSON, absent when the key has none there. inFile: the file's own JSON holds the key. apply live or restart. A secret row has set and never running, saved or default; set follows the saved value, or the running one when the file does not load, and an empty list or object is not set. pending: saved and running differ, compared as JSON with object key order ignored; false when the file does not load |
— | contract | #1153 | #1154, #1156 |
| I2 | The rows of a role | Two passes over configSchema and the running, saved and default configs. First the schema: an object recurses, optional ones included, every other field but mode, drivers and capabilities is a row (json for an array, record or union; http.proxyAuth one json row). Then, from the values: every key under drivers and capabilities (a module's enabled included), and every key of ios and android the schema does not name: a plain object recurses, anything else is a row whose kind is its type (json for an array). An empty plain object is no row. Rows in schema order, then by key. A worker lists all. A gateway: the sections of GATEWAY_CONFIG_KEYS, without WORKER_ONLY_GATEWAY_KEYS under gateway, and of a module only enabled and its gatewayKeys |
at most 1000 rows | core, pure: settingsRows({ running, saved, defaults, file, role, modules }) |
#1153 | #1154, #1156 |
| I3 | The three configs of I2 | running: what config.get answers, unmasked. saved: the file read now and loaded by configFromLayers with the options the daemon started with (role, modules, driver sections, host platform, system stats, test overrides). A row's default: the file loaded the same way without that key, so what a removal would give; for a key the file does not set, the saved value; absent when the file without it does not load; from an empty file when the file itself does not load. drivers of each passes driversWithDefaults |
— | src/daemon/settings.ts |
#1153 | #1154 |
| I4 | Live keys | idle.shutdownAfterMs, idle.deleteAfterMs, diskPressure.freeBytesThreshold; every other key is restart |
— | core | #1153 | #1154 |
| I5 | Secret keys | gateway.token, gateway.headers, gateway.alerts.destinations: one list, and a test that redactConfig masks exactly these |
— | core | #1153 | — |
| I6 | Program keys | gateway.admission.command, capabilities.agent-device.command: rows with machineOnly true |
— | core | #1153 | #1154, #1156 |
| I7 | settings.get, GET /v1/settings |
admin, read; input {}; 200 { rows, fileProblem?, consoleUrl }. fileProblem: the loader's or the read's message, at most 2000 characters, cut with …. consoleUrl: consoleUrl() of the saved http values, the running ones when the file does not load, null when HTTP is off or past CONSOLE_URL_MAX_LENGTH. Client getSettings(). settings joins CORE_ROUTE_SEGMENTS. Bumps the protocol by one |
the base errors of an admin route | contract, both dispatchers, socket, client, HTTP | #1153 | #1154, #1156 |
| I8 | The settings handle | createConfigSettings(options) in src/daemon/settings.ts, built in the composition root and passed to both dispatchers as settings: { get() }; each dispatcher declares the interface it takes |
— | src/daemon/settings.ts |
#1153 | #1154, #1155 |
| I9 | settings.set |
admin, write; input { set: record of key to JSON, unset: list of keys }, 1 to 50 keys in all, a key 1 to 200 characters and in one of the two only; output I7's, plus removed: the retired keys the write dropped, at most 10. Client setSettings({ set, unset }). Adds set(input, caller) to I8. Bumps the protocol by one |
below | contract, both dispatchers, socket, client | #1154 | #1156 |
| I10 | PATCH /v1/settings |
body: a JSON object of dotted key to JSON value, 1 to 50 keys; null goes to unset, every other value to set; 200 with I9's output. patch joins the methods a route may declare |
400 BAD_REQUEST for a body of another shape |
HTTP | #1154 | #1156 |
| I11 | Applying a change | In order, one call at a time: check the keys (I12, first group); read the file (absent: {}); drop eventLog.rotateBytes; set and unset each key on a copy of the parsed file, own properties only, a missing parent made for a set and left alone for an unset; check I13; check the whole file (I12, second group); write atomically, 0600, as config set does; swap the live values I14 the call touched; emit I15; answer. The check of the whole file is one core function, checkConfigFile(file, options), which the CLI calls too |
a throw before the write leaves everything as it was | core and src/daemon/settings.ts |
#1154 | — |
| I12 | Refusals of a change | all BAD_REQUEST. First group: Invalid config key: <key> (an empty segment, or a segment __proto__, prototype or constructor); Keys overlap: <a> and <b> (one equals the other, or is a prefix of it at a dot). Second group: Invalid config after setting <keys joined by ", ">: <message>, where the message is the loader's, Invalid JSON in config file: <path>, or the unknown-key warnings joined by ; . No message holds a secret's value |
the CLI prints it as USAGE, exit 2, with and without a daemon |
core | #1154 | — |
| I13 | Refusal of a program key | a session whose via is not socket, and the value at an I6 key differs between the file before and after, absent counted as a value: FORBIDDEN with the message <key> names a program the daemon runs. Set it on the daemon's machine with simlock config set. Checked between I12's two groups; a file that is not valid JSON is refused before it |
HTTP 403 | src/daemon/settings.ts |
#1154 | — |
| I14 | The live holder | the running config's idle and diskPressure are objects whose fields read the current value; every reader takes the object or a function, never a copied number. A call touches a live key when it names it or a parent; the new value is the checked config's |
— | core, daemon composition | #1154 | — |
| I15 | Event config.changed |
{ keys, applied, requesterId }: the call's keys, 1 to 50; applied live when I23 says so, else restart; the session's principal. Module daemon. After the write and the swap. An entry in EVENTS.md, System, and in the website's events reference |
none on a refusal or a file the CLI writes | bus | #1154 | #1156 |
| I16 | CLI lines of config set |
a daemon answered and the key is live by I23: Updated <key> in <path>; applied now.; else today's line. removed prints today's Removed eventLog.rotateBytes from <path>: it is no longer used. on stderr |
connect absent (isEndpointAbsent): the CLI writes the file itself. Any other connect error, or a refusal: printed, and the CLI writes nothing. Connect and call together end 30 s after the connect began, a starting daemon included: DAEMON_CONNECTION_LOST The daemon did not answer in 30 s. The change may still be made: read it with simlock config get, or run the command again., exit 1 |
CLI | #1154 | — |
| I17 | daemon.restart, POST /v1/restart |
admin, write; input {}; 202 { restarting: true }. Client restartDaemon(). restart joins CORE_ROUTE_SEGMENTS. Bumps the protocol by one. Adds restart() to the update coordinator, on its chain of calls, and fileProblem() to I8 |
DAEMON_UPDATING The daemon is updating while an update is in any stage; BAD_REQUEST config.json does not load: <fileProblem>. The daemon was not restarted.; a failed launch is INTERNAL. While a restart runs, a daemon.update that would start one answers DAEMON_STOPPING The daemon is restarting |
contract, both dispatchers, socket, client, HTTP, coordinator | #1155 | #1156 |
| I18 | Updater restart mode | --restart --pid <pid> [--gateway], no other flag. UpdaterLaunch is an update or a restart. stdout: nothing. One stderr line on a failed start: restart failed: <reason> |
daemon.stop 30 s from the call; exit of the old pid and a free socket 10 min from the stop, then SIGKILL of the pid; daemon start 2 min from its spawn, then running 2 min from its exit; else exit 1. In both modes a worker's start is --local daemon start, a gateway's daemon start --gateway as today, so a SIMLOCK_URL left in the daemon's environment does not make it remote |
updater, ports | #1155 | — |
| I19 | simlock daemon restart [--json] |
Daemon restarting or {"status":"restarting"}; with no daemon Daemon not running or {"status":"not-running"}, exit 0. Returns once the daemon answered, not once it is back. In the usage line after stop, and in REMOTE_REFUSED_PATHS |
a refusal as any command prints it. The same 30 s: DAEMON_CONNECTION_LOST The daemon did not answer in 30 s. It may still restart., exit 1 |
CLI | #1155 | — |
| I20 | The Daemon card's words | note: Changes are written to config.json on the daemon's machine.; columns Key (the default under it: default <value>), Value (under it, pending: Saved: <value>), When; pills Live, On restart, Restart pending; secret Set, Not set, pending or not, with no Saved: line; an absent value reads Not set in each place; buttons Edit, Copy (program key with a value), Restart daemon. No Edit on a program key, nor on a worker's I24 keys. Above the rows: config.json does not load: <fileProblem>; while an http.* row is pending After the restart, the console is at <url>. or After the restart, HTTP is off and this console stops. |
a 403 and a 404 as today's card words them | ui/src |
#1156 | — |
| I21 | The edit dialog | title the key; line Applies now. or Applies when the daemon restarts.; field by kind: a switch (boolean), number, text, select (enum), text area (json); the field starts with the saved value, the running one when the file does not load, and empty for a secret or an absent value (a switch off, a select on its first choice); a secret's and a json row's text as JSON unless the kind is string; errors under the field Not a number., Not valid JSON.; buttons Cancel, Use default (inFile only), Save, busy Saving…. Sends one PATCH /v1/settings with one key |
the dialog closes on 200 only | ui/src |
#1156 | — |
| I22 | Toasts and confirms | saved live: Saved <key>, Applied now.; saved restart: Saved <key>, Applies when the daemon restarts.; failed: Couldn't save <key>, the daemon's message. Confirm http.host, http.port: Change <key>?, After the restart, the console moves to the new address.; http.enabled ending false, by Save or by Use default (its row's default): Turn HTTP off?, After the restart, this console stops. Turn it back on with simlock config set http.enabled true.; http.proxyAuth: Change sign-in?, After the restart, the console asks for the new sign-in. A wrong value locks every person out.; buttons Keep, Save, busy Saving…. Restart confirm: Restart the daemon?, Leases are kept. Lease requests still waiting fail and must be sent again., Keep, Restart daemon, busy Restarting…; toast Restarting the daemon, The console reconnects when it is back.; failed Couldn't restart the daemon, the daemon's message |
— | ui/src/model/actions.ts, ui/src/model/settings-rows.ts |
#1156 | — |
| I23 | Live or not | a key is live when at least one row of the role (I2) equals it or lies under it, and every such row is live; a field inside a json row, and a key with no row (one the role ignores), is not. A call is live when every key it names is |
— | core, pure | #1154 | — |
| I24 | Fleet keys | gateway.url, gateway.token, gateway.headers, gateway.localLeases: no Edit on a worker's page, for they are refused one without another and a joined worker has no console. PATCH takes them in one call |
— | ui/src/model/settings-rows.ts |
#1156 | — |
Existing code
Commit 096519b.
Searches: redactConfig in src (3 callers); "config.get" in src (2 handlers, 1 route, the gateway's link, the client); writers of config.json (writeConfigFile: 1 call, src/cli/commands/config.ts); readers of the file (configPath in src: the daemon's start, the CLI's check, read and write); freeBytesThreshold, shutdownAfterMs, deleteAfterMs in src outside tests; launcher.launch (1 call); via in src/daemon; /v1/config in ui (1 read); configSections, setCommand in ui/src; "daemon stop" and config set in website/src/content/docs.
| Id | Code (path:line) | Today | With this feature | Handled by |
|---|---|---|---|---|
| X1 | src/daemon/main.ts:238 |
loads the config once, at start, with the modules, driver sections, role and host platform | the same options are kept for every later load of the file | #1153 |
| X2 | src/core/config.ts:124 |
reads the file, then configFromLayers merges and checks it |
configFromLayers is the check of a read file; a hand editor's half-written file gives fileProblem, not a failure |
#1153, #1154 |
| X3 | src/daemon/worker-composition.ts:528 |
config.get and daemon.started show drivers with each driver's defaults |
the rows show the same values | #1153 |
| X4 | src/core/config.ts:64 |
redactConfig masks the token, the headers and the alert destinations |
unchanged; the secret list is proven equal to it | #1153 |
| X5 | src/daemon/server-requests.ts:24 |
the socket hands only listed operations to the dispatcher | the three new operations are listed | #1153, #1154, #1155 |
| X6 | src/contract/config-schemas.ts:162 |
a platform's section carries its driver's own keys unread | their rows come from the values | #1153 |
| X7 | src/cli/commands/config.ts:49 |
config set reads, changes, checks and writes the file itself |
through the daemon when one answers; else itself, through the same core functions | #1154 |
| X8 | src/cli/environment.ts:514 |
checks the file as overrides over an empty one and refuses on an unknown-key warning | calls checkConfigFile |
#1154 |
| X9 | src/cli/commands/config.ts:100 |
writeConfigValue follows inherited properties (__proto__) |
moved to core; own properties only, the three names refused | #1154 |
| X10 | src/core/reaper.ts:212 |
gives its rules the config, and reads the disk threshold from it on every view | reads the live holder | #1154 |
| X11 | src/core/warm-pool/converger.ts:684 |
reads idle.shutdownAfterMs from the object it was given, on every pass; a pass runs on a tick |
reads the live holder | #1154 |
| X12 | src/core/seed-settle/settler.ts:350 |
reads the disk threshold from the object it was given, at every decision | reads the live holder | #1154 |
| X13 | src/daemon/worker-composition.ts:357 |
hands lease files the threshold as a number | hands a reader of the live holder | #1154 |
| X14 | src/daemon/server-requests.ts:228 |
a session's via is socket, uplink, or a remote session's token or proxy; HTTP sets token or proxy |
I13 reads it; nothing a caller sends changes it | #1154 |
| X15 | src/gateway/dispatcher.ts:408 |
the gateway answers config.get from its own config |
unchanged; its new handlers take I8 as an option, as update is |
#1153, #1154, #1155 |
| X16 | src/http/routes.ts:118 |
a route's method is get, post, put or delete | patch too | #1154 |
| X17 | src/daemon/update-coordinator.ts:134 |
update calls run one at a time; a query never waits |
restart() joins the chain, so an update call already in its version check ends first |
#1155 |
| X18 | src/daemon/update-coordinator.ts:216 |
launches the updater, the one place that does | the restart launch is the second; a flag of its own, apart from the update's state | #1155 |
| X19 | src/updater/index.ts:102 |
install, stop, wait, back up, start, roll back | restart mode runs the stop, wait and start only | #1155 |
| X20 | src/updater/index.ts:206 |
a started daemon counts as running only at version to |
any version in restart mode | #1155 |
| X21 | src/ports/updater-launcher.ts:37 |
builds the updater's arguments for an update | for a restart too | #1155 |
| X22 | src/ports/service-manager.ts:178 |
the service restarts a daemon only after a failed exit | a daemon.stop exits 0, so the service leaves it to the updater's daemon start |
#1155 |
| X23 | src/cli/daemon-service.ts:16 |
daemon stop with none running reports that and exits 0 |
daemon restart reports the same |
#1155 |
| X24 | src/cli/index.ts:264 |
the commands refused with --url |
daemon restart too |
#1155 |
| X25 | ui/src/state/settings.ts:63 |
reads /v1/config for the Daemon card |
reads /v1/settings; the /v1/config read, its TIMES entry and configSections go |
#1156 |
| X26 | ui/src/screens/settings/index.tsx:118 |
the Daemon card is read-only, with Copy per row | I20 | #1156 |
| X27 | ui/src/model/config-view.ts:46 |
setCommand builds the command Copy copies |
kept for program keys | #1156 |
| X28 | ui/src/data/api.ts:106 |
a write is DELETE or POST | PATCH too | #1156 |
| X29 | ui/src/model/actions.ts:40 |
a closed list of action ids; a form is enrol-phone only |
two ids more, and the settings form | #1156 |
| X30 | ui/src/state/actions.ts:76 |
the runner tells its caller nothing about the outcome, and a failed toast offers Retry | it says whether the write succeeded, so the dialog closes on success only; Retry sends nothing while that key's dialog is open | #1156 |
| X31 | ui/src/ds/confirm-dialog.tsx:34 |
one confirm at a time | opens over the edit dialog; Keep returns to it | #1156 |
| X32 | docs/internal/DESIGN.md:311 |
the Daemon card is read-only | describes I20 to I22 | #1156 |
| X33 | website/src/content/docs/docs/worker/change-a-setting.mdx:48 |
config set does not need the daemon and writes the file only |
goes through a running daemon and needs the admin role there | #1154 |
| X35 | src/daemon/worker-composition.ts:596 |
a worker's update coordinator always launches the real updater; only a gateway takes the test's options.updater |
the worker takes it too, so B12 can be driven | #1155 |
| X36 | src/daemon/server.ts:308 |
daemon.started holds the running config by reference, and the ring keeps it |
holds a copy of the values at the start | #1154 |
| X37 | src/drivers/ios/driver-options.ts:88 |
two drivers.ios.* keys name another capture program; nothing in the repo sets them |
removed, with their rows in the configuration reference, the sentence in cli.mdx, and their unit test |
#1154 |
| X38 | src/simlock-client/wire.ts:148 |
a local call has no time limit | the two commands limit their own wait, on the CLI's clock, from the connect; the limit sits where the socket is held (src/cli/environment.ts:389), hello and call included, and at the limit it starts the socket's close without awaiting it, as the startup limit does (src/cli/environment.ts:216), so the process ends |
#1154, #1155 |
| X39 | src/cli/index.ts:235 |
an exported SIMLOCK_URL makes a command remote unless --local or --gateway is given |
the updater gives one | #1155 |
| X34 | #1137, warm targets at runtime, unplanned | — | never writes config.json; it shows its counts over the saved ones, and decides later whether these two rows link to it |
B6 |
Tasks
flowchart LR
A["#1153 read: GET /v1/settings"] --> B["#1154 change: PATCH /v1/settings, CLI through the daemon"]
B --> C["#1155 restart: POST /v1/restart"]
B --> D["#1156 console: edit and restart"]
C --> D
- Settings: read every setting through GET /v1/settings #1153 Settings: read every setting through GET /v1/settings — an admin reads every setting with its running, saved and default values, secrets hidden. Risk: a secret shows on the wire.
- Settings: change settings through the daemon with PATCH /v1/settings, live where it can #1154 Settings: change settings through the daemon with PATCH /v1/settings, live where it can — an admin or the CLI changes settings through the running daemon; three keys apply at once. Risk: a change lost, or an operator token running a program.
- Settings: restart the daemon with POST /v1/restart and simlock daemon restart #1155 Settings: restart the daemon with POST /v1/restart and simlock daemon restart — an admin restarts the daemon without a terminal. Risk: a daemon that stops and does not come back.
- Console: edit settings and restart the daemon from the Settings page #1156 Console: edit settings and restart the daemon from the Settings page — an operator does all of it from the console. Risk: a save that cuts the console off without warning.
Completion conditions:
- The settings with their values and how each applies, secrets Set or Not set: Settings: read every setting through GET /v1/settings #1153 (data), Console: edit settings and restart the daemon from the Settings page #1156 (page).
- Saving
idle.shutdownAfterMsapplies with no restart: Settings: change settings through the daemon with PATCH /v1/settings, live where it can #1154. - Saving
http.portasks first, then the address and Restart pending: Console: edit settings and restart the daemon from the Settings page #1156; the restart: Settings: restart the daemon with POST /v1/restart and simlock daemon restart #1155. - Use default removes the key: Settings: change settings through the daemon with PATCH /v1/settings, live where it can #1154 (PATCH), Console: edit settings and restart the daemon from the Settings page #1156 (button).
- A bad value refused with the same message, file unchanged: Settings: change settings through the daemon with PATCH /v1/settings, live where it can #1154.
- Program keys refused over HTTP and without Edit: Settings: change settings through the daemon with PATCH /v1/settings, live where it can #1154, Console: edit settings and restart the daemon from the Settings page #1156.
config setthrough the daemon andconfig.changed: Settings: change settings through the daemon with PATCH /v1/settings, live where it can #1154.simlock daemon restart, refused while the file does not load: Settings: restart the daemon with POST /v1/restart and simlock daemon restart #1155.- A gateway lists only its own settings: Settings: read every setting through GET /v1/settings #1153, Console: edit settings and restart the daemon from the Settings page #1156.
Open work in the same area:
- Console: warm the pool up and down, and add a device from the catalog, without a restart #1137 (warm targets at runtime; Runtime warm-pool targets: warm.set and warm.list, kept in state.db #1143 to Console: Add device… from the catalog keeps one more warm #1146, all drafts): no Depends on, since warm targets here are ordinary rows. Console: edit the warm pool's targets on a worker's Warm pool tab #1145 widens the same write method of
ui/src/data/api.tsas Console: edit settings and restart the daemon from the Settings page #1156; its own spec session orders the two. - feat(auth): an agent or operator token may carry an expiry #1904 and feat(auth): a lease owner hands one lease to an agent with a scoped credential #1905 (A credential scoped to one lease, dead when the lease ends #1895, lease handover) and Idle leases: a worker ends a lease whose device goes unused #1907 (End a lease after an operator-set time without device use #1899, idle lease end): each bumps the protocol; no dependency, by the maintainer's decision of 2026-12-01. Whichever merges second takes the next number. A new config key of Idle leases: a worker ends a lease whose device goes unused #1907 appears as a row with no change here.
- feat(android): add an AgentDeviceCloud backend #1498 (the AgentDeviceCloud backend, draft): adds config keys; one that names a program must join the closed list of I6, whichever merges second. No Depends on.
Written by an agent.
Activity
leonardoxr commentedon Oct 31, 2026
Spec updated: every section written (Problem through Tasks), with tasks #1153, #1154, #1155 and #1156 and ADR 0057 (draft PR #1152). The feature and all four tasks pass their spec checks (
Verdict: ready).Written by an agent.
docs(adr): propose 0057, the daemon owns config.json while it runs (c…
docs(adr): 0057 says config.get masks secrets since callstackincubato…
V3RON commentedon Nov 27, 2026
A change in #1131 that this feature's tasks rest on. #1135 (Delete device) is closed as not planned, so #1156 lists a closed issue under Depends on. The next spec session on this feature should drop that line.
Written by an agent.
V3RON commentedon Nov 30, 2026
Design posted: rewritten against today's main.
GETandPATCH /v1/settings, program keys on the machine only, reset to default, no wait for #1137, ADR 0099 (#1989) in place of 0057. The four task bodies are stale until the design check passes.Written by an agent.
V3RON commentedon Nov 30, 2026
#1151 Console: see and change the daemon's settings, and restart it: #1151
ADR 0099 (PR #1989): while a daemon runs, only it writes its
config.json;GETandPATCH /v1/settingsread and change settings; keys that name a program are changed on the machine only; a restart goes through the updater. It replaces the draft ADR 0057 (#1152).Decided in the session: the Daemon card of the existing Settings page becomes editable, because a second page would show the same settings twice.
Decided in the session:
gateway.headersis a secret row, becauseredactConfigmasks it.Decided in the session: the dialog starts with the saved value, because the running one would undo a change that waits.
Decided in the session:
config setanddaemon restartwait at most 30 s for a daemon, because neither may hang and a local call has no limit today.Decided in the session: the updater passes
--localfor a worker in update mode too, because the same start would fail there.Decided in the session: a driver or module key with no default has a row only once the file sets it (
android.emulator.cores,capabilities.agent-device.ios.teamId), because its validator does not list its keys; PATCH andconfig setstill take it.Decided in the session:
daemon.restartrefuses whileconfig.jsondoes not load, because the daemon would stop and not come back.Decided in the session: a key with a segment
__proto__,prototypeorconstructoris refused, because the daemon now applies keys sent over the network.Decided in the session: the lock-out confirm for a host or port names no address; the page shows it after the save, as the daemon answered it, because the console may not import the code that builds it.
Decided in the session: an operation takes
setandunsetapart, and only the HTTP body readsnullas a removal, because the CLI refusesnulltoday and goes on doing so.Decided in the session: the Copy button stays on program keys only, because every other key has Edit.
GET /v1/settings)POST /v1/restart,simlock daemon restart)Check: ready
Written by an agent.
V3RON commentedon Nov 30, 2026
Spec updated: the design is approved and ADR 0099 accepted; the bodies of #1153, #1154, #1155 and #1156 are written again from its rows.
Written by an agent.
V3RON commentedon Nov 30, 2026
The tasks are ready.
GET /v1/settings)POST /v1/restart,simlock daemon restart)Decided since the design was settled: #1153 waits for #1907 and #1155 for #1154, because each of them changes the protocol range.
N 1153 Depends on: depends-outside #1907 (open, feature #1899)
chain 4 of 4 tasks
waiting #1153: on #1907 (open, outside this feature)
waiting #1154: on #1153 (no PR)
waiting #1155: on #1153 (no PR), #1154 (no PR)
waiting #1156: on #1153 (no PR), #1154 (no PR), #1155 (no PR)
runnable: none
Written by an agent.
docs(adr): 0099 narrows 0003 §11, scopes the secrets claim, lists the…
V3RON commentedon Dec 1, 2026
Delivery run
Merged: none
Parked: #1154 (PR #2016, draft) — B7's idle cases have no test; the spec's
startDaemonsurface cannot hold the device they need. Its handoff has the two options.Waiting: #1153 (PR #2012) and ADR PR #1989, both reviewed, ready and held in stack #2013. #1155 — on #1154. #1156 — on #1154 and #1155.
Decided: none
Written by an agent.
chore(agents): deliveries stop for a person only when a person is nee…
V3RON commentedon Dec 2, 2026
Delivery run
Merged: none
Parked: #1153 — fast-track hold: its reporter cannot write to the repo, so the maintainer merges PR #2012 and with it the stack #1989 → #2012 → #2016 → #2028 → #2035, all reviewed and ready
Decided: #1154 — how to test B7's idle cases → through
createHarnesswith a seeded device andsettings.setwired; #1156 — Retry of a failed save while a setting dialog is open → sends nothing, as for EnrolWritten by an agent.