Skip to content

Settings: change settings through the daemon with PATCH /v1/settings, live where it can #1154

In review

Description

@leonardoxr

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.ts and 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 *"]
Loading

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; requesterId is 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.ts holds 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 reads applied 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/settings and the daemon writes the file once and answers the rows: 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
  • B7: A saved live key is used on the next run of everything that reads it: 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
  • B8: A bad change is refused and the file is unchanged: 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)
  • 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 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
  • B10: A change emits config.changed with 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 set goes 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; --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
  • B20: drivers.ios.screenCaptureCommand and drivers.ios.deviceCaptureCommand no longer change the capture program: each set in the config: the packaged program runs

Done when

  • settings.set is in the role and effect matrices of src/contract/operations.test.ts.
  • config.changed is in EVENT_NAMES, docs/internal/EVENTS.md and the website's events reference.
  • rg 'screenCaptureCommand|deviceCaptureCommand' src website prints 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

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 5, 2026
  2. changed the title [-]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[/+] on Nov 30, 2026
  3. added
    task:ready
    and removed
    task:draft
    on Nov 30, 2026
  4. self-assigned this
    on Dec 1, 2026
  5. 14 remaining items

  6. V3RON commented on Dec 1, 2026

    @V3RON
    Contributor

    Handoff

    Done

    PR #2016 (draft, task/1154 at 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, as runningDaemons and temporaryDirectories are each exported by two modules; the rest of CI was pending. B7 tests: idle.shutdownAfterMs lowered for the reaper and for the warm pool, idle.deleteAfterMs lowered. 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, so deliver-step.mjs counted no cycle.

    Blocked on

    The maintainer: test B7's idle cases (a) through createHarness in src/daemon/test-server.ts with a seeded device and settings.set wired (recommended), or (b) as unit tests of the reaper and pool. Then deliver-step.mjs 2016 --restart --fix "<choice>".

    Written by an agent.

  7. added
    task:blocked
    and removed
    task:ready
    on Dec 1, 2026
  8. removed their assignment
    on Dec 1, 2026
  9. added
    task:ready
    and removed
    task:blocked
    on Dec 2, 2026
  10. self-assigned this
    on Dec 2, 2026
  11. removed their assignment
    on Dec 2, 2026
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

    task:ready

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions