Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8b241b5
feat(gateway): fleet queue, routing, lease + exec forwarding (#118)
claude Sep 7, 2026
c03b9d0
fix(gateway): stop a leaked dispatch mark from parking a waiter forev…
claude Sep 7, 2026
1fb1289
fix(gateway): reconcile lease-index against worker snapshots (C3), re…
claude Sep 7, 2026
8726825
fix(gateway): apply gateway.execTimeoutMs to forwarded device.exec (P5)
claude Sep 7, 2026
795f7fb
fix(gateway): do not trust the worker's echoed ownerId for a fresh gr…
claude Sep 7, 2026
e7dd237
fix(gateway,daemon): stop worker-mode daemon startup pulling in the g…
claude Sep 7, 2026
f8535ec
test(gateway,daemon,http): cover §27a's admin owner gate; make HTTP r…
claude Sep 7, 2026
2f68b65
test(gateway): cover request.dispatched and fix test titles/comments …
claude Sep 7, 2026
517f68e
docs(gateway): fix two docs claims left stale by the fleet queue land…
claude Sep 7, 2026
7b32e43
fix(core): fix the queue timeout budget resetting on every processing…
claude Sep 7, 2026
59bbe07
fix(gateway): reconcile only a worker whose view actually changed (C1…
claude Sep 7, 2026
c9fdc32
fix(gateway,docs): widen request.dispatched back to what EVENTS.md sp…
claude Sep 7, 2026
29c35c0
fix(gateway): defer device.exec's onStarted until the worker's first …
claude Sep 7, 2026
63cad6e
test(gateway): make the §11 first-progress-push test actually exercis…
claude Sep 7, 2026
d659c4d
fix(gateway): stop re-queuing a NO_CAPACITY that arrived after dispat…
claude Sep 7, 2026
990c576
fix(gateway,core): bound the forwarded lease.request against a new ti…
claude Sep 7, 2026
0048bbb
fix(core): never deliver a progress push to an already-settled waiter…
claude Sep 7, 2026
ccb7398
fix(gateway): stop reporting the gateway's own bugs as WORKER_UNREACH…
claude Sep 7, 2026
a17d239
refactor(gateway): extract #attempt's error classification into its o…
claude Sep 7, 2026
063f9fe
fix(daemon,gateway): narrow §27a's owner gate to the gateway's own up…
claude Sep 8, 2026
187cb0c
fix(gateway): detach a forwarded device.exec's onOutput closure on EX…
claude Sep 8, 2026
ce800f0
test(core): make wait-queue's re-arm test prove the mechanism, not ju…
claude Sep 8, 2026
2caf800
fix(gateway): cap #dispatch to one queued waiter per worker per pass …
claude Sep 8, 2026
e01a0c6
fix(gateway): guarantee a next dispatch pass, preserve FIFO order, an…
claude Sep 8, 2026
0330b7f
docs(agent-rules): a rule is enforced in exactly one place
claude Sep 8, 2026
df28c13
fix(gateway,contract,daemon,client): enforce noWait in one place, and…
claude Sep 8, 2026
91f57e1
fix: drop the lockfile artifact that rode along with the previous commit
claude Sep 8, 2026
0f02db9
fix(gateway,contract): make `started` part of protocol 5, not an addi…
claude Sep 8, 2026
17278d1
docs(agent-rules): testing rules, and three more from the review record
claude Sep 8, 2026
a601d5a
fix(contract,gateway,daemon): close round 6's seven findings
claude Sep 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ changes in this repo:

- [architecture.md](docs/agent-rules/architecture.md) — loosely coupled
modules; platform-agnostic core; iOS and Android encapsulated in their own
driver modules; event bus for observers only.
driver modules; event bus for observers only; one place enforces a rule;
bounded cross-process waits; every exit leaves one named state.
- [events.md](docs/agent-rules/events.md) — event naming
(`subject.past-tense-fact`), post-commit emission, payload contracts,
keeping EVENTS.md in sync.
- [safety.md](docs/agent-rules/safety.md) — registry-only destruction, never
touch leased devices, no implicit downloads, ownership proven not inferred,
root validation fails closed.
root validation fails closed, wire input is a claim not a fact.
- [testing.md](docs/agent-rules/testing.md) — a test's title is a claim its
body must prove; every test must be able to fail for the right reason;
untested code is code you can delete with a green suite.

So are the accepted records in [docs/adr/](docs/adr/). An ADR marked
_Accepted — not yet implemented_ means the documentation already describes the
Expand Down
8 changes: 4 additions & 4 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ agent / console ──token auth──> │ HTTP frontend + unix socket
`driver.passthrough` answer `UNSUPPORTED_IN_GATEWAY_MODE` permanently: they
act on one machine's devices, and stay per-worker. The lease lifecycle
(`lease.request`/`renew`/`release`/`cancel`/`release-all`) and `device.exec`
answer the same code until the fleet queue and routing land; reads —
`lease.list`,
`list.get`, `status.get`, `catalog.get`, `events.*` — already answer for the
whole fleet.
are forwarded through the fleet's own queue and routing policy (§10-§19,
`FleetLeaseCoordinator`) rather than answering `UNSUPPORTED_IN_GATEWAY_MODE`;
reads — `lease.list`, `list.get`, `status.get`, `catalog.get`, `events.*` —
answer for the whole fleet the same way.
- **The one piece of persisted gateway state** is the drained set
(`workers.json`, owner-only): drain is an operator's decision about a
machine, not a fact the machine reports, so it must survive both the
Expand Down
12 changes: 8 additions & 4 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ a warning. Inspect the effective, merged configuration at any time with
| `gateway.routing` | **Gateway side.** Which routing policy places a queued request on a worker. `warm-then-free` is the only policy in v1: warm hit first, then the most free running capacity for the platform. See [Routing](ARCHITECTURE.md#routing). | `warm-then-free` |
| `gateway.disconnectedRetentionMs` | **Gateway side.** How long a disconnected worker is kept (greyed, never dispatched to) before the gateway forgets it. The clock is held while the gateway still knows of gateway-issued leases on that worker, and that hold ends when the last of those leases passes its deadline. | `24 hours` |
| `gateway.execTimeoutMs` | **Gateway side.** How long the gateway waits on a proxied `device.exec` before giving up. A backstop for a worker that never answers at all — deliberately longer than the worker's own `exec.timeoutMs`, which is authoritative because that side owns the process and can kill it, so an ordinary timeout surfaces as the worker's `EXEC_TIMEOUT` rather than racing this one. See [ADR 0005](adr/0005-gateway-and-worker-modes.md) §19e. | `11 minutes` |
| `gateway.leaseRequestTimeoutMs` | **Gateway side.** How long the gateway waits on a forwarded `lease.request` before giving up on that worker for this request, answering `WORKER_UNREACHABLE`. Bounds the one uplink call that otherwise had no timeout of its own, so a wedged worker cannot park a request where neither a deadline nor `lease.cancel` could ever reach it again. Generous against a cold device provision-plus-boot; well below `gateway.execTimeoutMs`, since granting a lease should never take as long as a command run against the device afterward. | `5 minutes` |
| `http.enabled` | Master switch for the network-facing HTTP API (see [HTTP-API.md](HTTP-API.md)). Off by default; the daemon binds nothing until this is `true`. A gateway is the fleet's contact point, so it must be `true` there — see [Modes](#modes-gateway-and-worker). | `false` |
| `http.host` | Address the HTTP listener binds. `127.0.0.1` keeps it loopback-only; reaching it remotely is the operator's own tunnel (Tailscale, cloudflared, reverse proxy) — Simlock does no TLS termination in v1. | `127.0.0.1` |
| `http.port` | Port the HTTP listener binds. Must be an integer `1`-`65535`. | `4700` |
Expand All @@ -33,6 +34,7 @@ a warning. Inspect the effective, merged configuration at any time with
| `gateway.label` | **Worker side.** Display name for this worker in the gateway's views. Need not be unique, and is never used to route. | unset (views show the worker's id) |
| `gateway.disconnectedRetentionMs` | **Gateway side.** How long a disconnected worker's view is kept before the gateway forgets it. The clock only applies once every lease on that view has passed its deadline. | `24 hours` |
| `gateway.execTimeoutMs` | **Gateway side.** Backstop on a proxied `device.exec`, deliberately longer than the worker's own `exec.timeoutMs`, which is the authoritative one. | `11 minutes` |
| `gateway.leaseRequestTimeoutMs` | **Gateway side.** Backstop on a forwarded `lease.request` -- expiry answers `WORKER_UNREACHABLE`, freeing the request for the queue's own deadline/cancel handling again. | `5 minutes` |
| `diskPressure.freeBytesThreshold` | Free disk space below which Simlock treats the machine as under disk pressure. | `10 GiB` |
| `eventBuffer.capacity` | Number of business events kept in the in-memory ring buffer (see `simlock events`). | `1000` |
| `health.enabled` | Master switch for leased-device crash detection and recovery. | `true` |
Expand Down Expand Up @@ -61,8 +63,9 @@ must be non-negative numbers (milliseconds and bytes, respectively).
`http.enabled` is a boolean, `http.host` a string, and `http.port` an
integer in `1`-`65535`.
`mode` is `worker` or `gateway`; `gateway.url`, `gateway.token` and
`gateway.label` are strings, and `gateway.disconnectedRetentionMs` and
`gateway.execTimeoutMs` positive numbers.
`gateway.label` are strings, and `gateway.disconnectedRetentionMs`,
`gateway.execTimeoutMs`, and `gateway.leaseRequestTimeoutMs` positive
numbers.
`ios.slim.enabled` is a boolean, `ios.slim.categories` an array of
non-empty strings, and `ios.slim.bootTimeoutMs` a positive number.
`mode` must be exactly `"worker"` or `"gateway"`. `gateway.url` must be an
Expand All @@ -75,7 +78,8 @@ warned about and ignored like every other worker key — a gateway is not
misconfigured by leftovers from the config it was flipped out of.
`gateway.label` is a non-empty string, `gateway.routing` one of the
registered routing policies, and `exec.timeoutMs`, `gateway.execTimeoutMs`,
and `gateway.disconnectedRetentionMs` positive numbers.
`gateway.leaseRequestTimeoutMs`, and `gateway.disconnectedRetentionMs`
positive numbers.
**`mode: "gateway"` with `http.enabled: false` is rejected at load** (ADR 0005 §2), naming the key: a
gateway is the fleet's contact point over HTTP, so one nothing can reach has
no safe reading.
Expand Down Expand Up @@ -180,7 +184,7 @@ does not apply to it. It reads:
| Key group | Why |
|---|---|
| `mode` | to be a gateway at all |
| `gateway.routing`, `gateway.disconnectedRetentionMs`, `gateway.execTimeoutMs` | how to run the fleet |
| `gateway.routing`, `gateway.disconnectedRetentionMs`, `gateway.execTimeoutMs`, `gateway.leaseRequestTimeoutMs` | how to run the fleet |
| `http.*` | it is the fleet's contact point |
| `lease.*` | `defaultTtlMs`/`maxTtlMs` bound what its own clients may ask for, before a request is dispatched — see below |
| `log.*`, `eventBuffer.*` | logging and the event ring buffer, as anywhere |
Expand Down
Loading
Loading