Description
Part of #1151.
Scope
An admin changes settings through the running daemon with PATCH /v1/settings or settings.set, one or more keys in one write. simlock config set goes through the daemon when one runs. Three keys apply at once. Each change emits config.changed. The two unused keys that name the iOS capture programs go.
If this goes wrong, a change is lost, a live key still waits for a restart, the CLI writes behind a running daemon, a secret lands in a log or an event, or an operator token runs a program of its choice.
Technical spec
Commit 096519b.
Rows
- Behaviours: B6, B7, B8, B9, B10, B11, B20
- Interfaces: I9, I10, I11, I12, I13, I14, I15, I16, I23
- Existing code: X2, X5, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X33, X36, X37, X38, X34
Facts
none
Modules touched
Searches: writeConfigFile, validateConfig, readConfigFile, writeConfigValue, idle.shutdownAfterMs, deleteAfterMs, freeBytesThreshold, diskPressureThreshold, configSnapshot, screenCaptureCommand, deviceCaptureCommand, config set in src, ui, e2e, website and docs/internal.
src/core/settings-rows.ts,src/core/config-change.ts(new),src/core/index.ts: applying a change, its checks, live or not.src/daemon/settings.ts,src/daemon/main.ts,src/daemon/worker-composition.ts,src/daemon/server.ts,src/lease-files/types.ts,src/lease-files/store.ts: the write, the live holder, the start event's copy.src/core/reaper.ts,src/core/create-core.ts,src/core/seed-settle/types.ts,src/core/warm-pool/converger.ts: read the holder; a file that already reads the object on every use does not change.src/contract/operations-admin.ts,src/contract/operations.ts,src/contract/protocol.ts,src/daemon/dispatcher.tsand its parts,src/daemon/server-requests.ts,src/gateway/dispatcher.ts,src/bus/index.ts.src/simlock-client/client-api.ts,src/simlock-client/client-impl.ts,src/simlock-client/client-degraded.ts,src/simlock-client/types.ts,src/admin/index.ts,website/src/content/docs/docs/reference/node-client.mdx:setSettings().src/http/routes.ts,src/http/admin-declarations.ts,src/http/app.ts.src/cli/commands/config.ts,src/cli/connect.ts,src/cli/environment.ts,src/cli/types.ts.src/drivers/ios/driver-options.ts,src/daemon/driver-discovery.ts: the capture keys and the comment that names them.docs/internal/EVENTS.md,website/src/content/docs/docs/reference/events.mdx,website/src/content/docs/docs/reference/cli.mdx,website/src/content/docs/docs/reference/configuration.mdx,website/src/content/docs/docs/worker/change-a-setting.mdx,website/src/content/docs/docs/worker/free-disk.mdx(two live keys need no restart),src/daemon/AGENTS.md,src/cli/AGENTS.md.
flowchart LR
CLI["cli config *"] --> C["client *"]
H["http *"] --> D["dispatchers *"]
C --> D
D --> S["daemon/settings *"]
CLI -.no daemon.-> K["core config-change *"]
S --> K
S --> L["live holder *"]
L --> R["reaper, warm pool, seed settle, lease files"]
S --> B["bus *"]
Rules in play
- ADR 0099 §1 to §5 and §9: one writer, dotted keys, the closed live list, secrets, program keys, one event.
src/contract/AGENTS.md, "Adding an operation": matrices, protocol, both dispatchers, client, HTTP, website.- Events rules (
docs/internal/agent-rules/events.md): a past-tense fact after the commit, in both catalogues;requesterIdis the session's principal. - Architecture rule 11: the CLI's wait is bounded. Architecture rule 8: the CLI decides nothing; the change and its checks are core's.
src/cli/AGENTS.md: the router loads no component for a value;lazy-loading.test.tsholds it.- Documentation rule 9: the CLI, configuration and events references, and Change a setting.
Retired words
takes effect on daemon restart: true of a restart key only; a live key readsapplied now.
Tests
Seam: startDaemon through createHttpApp and the socket with a memory filesystem and a fake clock (model: src/daemon/main-start-daemon.test.ts), runCli (model: src/cli/index-device-config.test.ts), the iOS driver's index.ts (model: src/drivers/ios/index-screen-tool-versions.test.ts).
- B6: An admin changes settings with
PATCH /v1/settingsand the daemon writes the file once and answers the rows: a restart key (file changed, running unchanged, pending); a live key (running changed,config.getshows it); a parent keyidle; a field inside a json row (http.proxyAuth.header); two keys in one write;nullremoves a key;nullfor a key the file does not set (200, file written the same);gateway.url,gateway.tokenandhttp.enabledtogether on a worker; a key a gateway ignores (saved);eventLog.rotateBytesin the file (dropped, listed inremoved); other keys and a hand edit kept; file mode0600; two calls at once both kept - B7: A saved live key is used on the next run of everything that reads it:
idle.shutdownAfterMslowered: the reaper, and the warm pool on a never-leased ready device no target keeps;idle.deleteAfterMslowered;diskPressure.freeBytesThresholdraised 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 - B8: A bad change is refused and the file is unchanged: a wrong type; an unknown key;
lease.defaultTtlMsoverlease.maxTtlMs;mode; one good and one bad key; overlapping keys; a key both set and unset; a badgateway.tokenrefused 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 (500INTERNAL, no event, the running value unchanged) - B9: A program key changes only over the local socket: a bad value of the key (still 403); PATCH of the key, of its parent with another value, and
nullfor 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.commandthe same - B10: A change emits
config.changedwith the keys, how they applied and the caller: live key; restart key; a live and a restart key together (restart); no event on a refusal; the payload holds no value - B11:
simlock config setgoes through a running daemon and writes the file itself when none runs: 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;--gatewaywith no gateway present: written by the CLI;null: refused, exit 2, with and without a daemon;__proto__.xrefused with no daemon; no admin token:FORBIDDEN, file unchanged; a daemon'sBAD_REQUESTprintsUSAGEand its message, exit 2;eventLog.rotateBytesdropped by the daemon: today'sRemovedline; 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 - B20:
drivers.ios.screenCaptureCommandanddrivers.ios.deviceCaptureCommandno longer change the capture program: each set in the config: the packaged program runs
Done when
settings.setis in the role and effect matrices ofsrc/contract/operations.test.ts.config.changedis inEVENT_NAMES,docs/internal/EVENTS.mdand the website's events reference.rg 'screenCaptureCommand|deviceCaptureCommand' src websiteprints no line of production code or docs.- The website build and its HTTP API check pass, and the HTTP reference lists
PATCH /v1/settings.
Out of scope
- Restarting (Settings: restart the daemon with POST /v1/restart and simlock daemon restart #1155) and the console (Console: edit settings and restart the daemon from the Settings page #1156).
- An unset command in the CLI; more live keys.
Depends on
- Settings: read every setting through GET /v1/settings #1153 because: the settings handle, the rows and the closed lists it extends
Written by an agent.
Activity
[-]Settings: change a setting through the daemon, live where it can[/-][+]Settings: change settings through the daemon with PATCH /v1/settings, live where it can[/+]test: a bad change is refused and the file is unchanged (#1154)
feat(settings): a bad change is refused before the write, and a __pro…
test: a program key changes only over the local socket (#1154)
feat(settings): a program key is changed over the local socket only (#…
test: a change emits config.changed with the keys, how they applied a…
feat(settings): a change emits config.changed with the keys, how they…
test: a saved live key is used on the next run of everything that rea…
feat(settings): the three live keys apply as they are saved (#1154)
test: drivers.ios.screenCaptureCommand and deviceCaptureCommand no lo…
14 remaining items
test: a program key is refused over a remote session and over the upl…
test: config set writes the file itself over a stale socket and with …
V3RON commentedon Dec 1, 2026
Handoff
Done
PR #2016 (draft,
task/1154at d8d14b7, stacked on #2012). B6 and B8 to B11 are built and tested; so are B7's pressure cases.Not done
Red on CI:
Fallow, asrunningDaemonsandtemporaryDirectoriesare each exported by two modules; the rest of CI was pending. B7 tests:idle.shutdownAfterMslowered for the reaper and for the warm pool,idle.deleteAfterMslowered. Audit and review.Findings
B7's surface, a daemon through
startDaemon, cannot hold the device: a released virtual device is deleted at release, and a target keeps every device it creates. The second run added only tests of code that already worked, sodeliver-step.mjscounted no cycle.Blocked on
The maintainer: test B7's idle cases (a) through
createHarnessinsrc/daemon/test-server.tswith a seeded device andsettings.setwired (recommended), or (b) as unit tests of the reaper and pool. Thendeliver-step.mjs 2016 --restart --fix "<choice>".Written by an agent.
chore(agents): deliveries stop for a person only when a person is nee…
test: a saved idle.shutdownAfterMs reaches the reaper and the warm po…
test: the settings.set write failure, key bounds, program-key and inp…
fix: config set with no daemon refuses a config.json that is not JSON…
test: the invalid-JSON config set message builds its path with join, …