You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9ac01fa
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: rust/contracts/remote-workspace-protocol-v1.md
+70-8Lines changed: 70 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ clients. Design rationale lives in
13
13
| --- | --- |
14
14
|`lithe-remote-server --stdio`| Ends with the connection, terminating everything it started. |
15
15
|`lithe-remote-server --connect <key> [--state-dir <dir>]`| Persistent: relays to the daemon of session `<key>`, starting it if needed. |
16
+
|`lithe-remote-server --target-identity --state-dir <dir>`| Prints the non-secret identity of the final account's server state before a client chooses a session key. |
16
17
17
18
`<key>` is 1–64 characters from `[A-Za-z0-9._-]`. The daemon keeps its
18
19
socket, lock and log under `<dir>` (default `$HOME/.lithe-server`) in
@@ -50,6 +51,11 @@ Other clients should do the same.
50
51
bytes of UTF-8 JSON. Frames larger than 16 MiB are rejected.
51
52
3. Closing the client-to-server stream is a disconnect.
52
53
54
+
The reference server bounds response serialization to the frame limit. A result
55
+
that exceeds it becomes a `TOO_LARGE` error for that request, and subsequent
56
+
responses remain usable. Event producers bound their own batches; events cannot
57
+
be replaced by a request error and are never silently discarded by the writer.
58
+
53
59
All traffic, including tunnels, uses this stream. The server listens on a
54
60
network port only for a forwarding rule the user added (`listener.open`, see
55
61
"Listeners"); such a port belongs to the connection that opened it and
@@ -126,7 +132,7 @@ subscribe before creating the resource.
126
132
|`fs.stat`|`path`| metadata of the path itself (links not followed) |
127
133
|`fs.readDir`|`path`|`entries` sorted by name byte order, `skippedNonUtf8`|
128
134
|`fs.readFile`|`path`, `offset`, `length` (≤ 8 MiB) |`data`, `eof`, `metadata`; only a regular file is read |
129
-
|`fs.writeFile`|`path`, `data` (≤ 8 MiB), `expected?`, `overwrite`, `createParents`| metadata after the write |
135
+
|`fs.writeFile`|`path`, `data` (≤ 8 MiB), `expected?`, `overwrite`, `createParents`, `root?`| metadata after the write |
130
136
|`fs.createDir`|`path`, `recursive`, `mode?` (at most `0o7777`) |`null`|
131
137
|`fs.remove`|`path`, `recursive`|`null`; links are removed, never followed |
132
138
|`fs.rename`|`from`, `to`, `overwrite`|`null`|
@@ -168,6 +174,15 @@ subscribe before creating the resource.
168
174
opened file, so a FIFO without a writer never holds the request and a path
169
175
replaced between `fs.stat` and the read is still checked. A directory fails
170
176
with `IS_A_DIRECTORY`; sockets, FIFOs and devices fail with `UNSUPPORTED`.
177
+
Metadata includes optional `revision`, an opaque identity incorporating the
178
+
host's file identity, size and precise modification/change timestamps. Clients
179
+
compare it exactly and return it in `expected`; they must not interpret its
180
+
encoding. Older servers may omit it.
181
+
182
+
`fs.readDir` examines at most 20,000 directory entries, including names that are
183
+
not UTF-8, and bounds serialized entries below the frame limit with space for
184
+
the response envelope. Exceeding either budget returns `TOO_LARGE` rather than
185
+
a successful partial listing. Recursive indexes should use `walk.start`.
171
186
172
187
`fs.copy` refuses, with `INVALID_REQUEST`, to copy a file onto itself —
173
188
directly, through a symbolic link in either direction or onto a hard link —
@@ -184,13 +199,36 @@ the remote account, never to the client placeholder or installation. A host
184
199
without usable trash storage returns an error and retains the original entry;
185
200
it does not fall back to permanent deletion.
186
201
187
-
`fs.writeFile` replaces the file atomically through a temporary sibling and
188
-
writes through symbolic links. With `expected` (`size`, `modifiedMs`) it fails
189
-
with `CONFLICT` unless the file still matches; without it, an existing file is
190
-
only replaced when `overwrite` is set. A write with neither `expected` nor
191
-
`overwrite` only creates: when two such writes race, exactly one succeeds and
192
-
the other fails with `ALREADY_EXISTS`. When a file is replaced, the temporary
193
-
file never has broader permissions than the original.
202
+
`fs.writeFile` replaces the file atomically through a temporary sibling. With
203
+
`expected` (`size`, `modifiedMs`, optional `revision`) it fails with `CONFLICT`
204
+
unless the file still matches; without it, an existing file is only replaced
205
+
when `overwrite` is set. The revision catches an inode replacement or precise
206
+
timestamp change even when size and millisecond modification time are unchanged.
207
+
A write with neither `expected` nor `overwrite` publishes by atomic no-replace
208
+
linking: a concurrently created destination is retained and the write fails
209
+
with `ALREADY_EXISTS`. A replacement's temporary file is created with permissions
210
+
no broader than the original, before any content is written.
211
+
212
+
The optional `root` requires the `guardedWrites` feature. Editor clients send
213
+
their workspace root and refuse an older server instead of retrying without the
214
+
boundary. The requested path must be lexically below that root with no `..`
215
+
components. The server resolves the root, opens it through directory handles,
216
+
and opens each descendant directory without following symbolic links. The leaf
217
+
must not be a symbolic link either. Missing descendants are created only with
218
+
`createParents` and are reopened without following links. Staging and publication
219
+
use the same parent handle; refused boundary or symlink crossings return
220
+
`PERMISSION_DENIED`. Without `root`, explicit general host writes retain their
221
+
ability to write outside a workspace and through an existing leaf link.
222
+
223
+
Cooperating Lithe daemons serialize writes to the same directory with a
224
+
five-second advisory-lock deadline. The server rechecks the version after
225
+
staging and syncing, immediately before publication. POSIX rename provides no
226
+
version-based compare-and-swap: an external writer that ignores this lock can
227
+
still change a file between that final check and replacement. Directory handles
228
+
also do not sandbox a hostile same-user process that moves an already-open
229
+
directory outside the root. These are limits of conflict and path protection,
230
+
not guarantees of isolation from the remote account itself. Failed saves reclaim
231
+
their temporary files; a crash can leave one behind.
194
232
195
233
Hosts advertising `features: ["upload", ...]` accept staged uploads without
196
234
increasing the frame limit. Upload IDs are server-assigned and owned by the
@@ -274,6 +312,15 @@ environment and caches it for the session. `process.spawn` with
274
312
275
313
`watch.changed` batches are coalesced and sorted by path. With `overflow`
276
314
changes were lost and the client must rescan the watched tree.
315
+
The reference backend queue retains at most 2,048 changes and 1 MiB of raw
316
+
path bytes without blocking the native watcher. Pressure clears those changes
317
+
and preserves an overflow marker, watch-limit notice and root-removal notice.
318
+
Coalesced batches hold at most 5,000 distinct changes and 1 MiB of path bytes
319
+
before JSON escaping; a larger batch becomes an empty overflow batch.
320
+
321
+
`walk.entries` batches hold at most 2,000 entries and 1 MiB of relative-path
322
+
bytes before JSON escaping. A single path beyond that budget ends the walk with
323
+
`truncated: true`; it is not sent as an oversized event.
277
324
278
325
## Listeners
279
326
@@ -390,6 +437,21 @@ than reaching an older one.
390
437
391
438
## Server identity
392
439
440
+
`--target-identity --state-dir <dir>` prints 64 hexadecimal characters derived
441
+
from a random marker, the current numeric user ID and the canonical state root.
442
+
The marker is `target-identity-v1` in the private state directory, created as
443
+
an owner-only regular file without following symbolic links and published
444
+
without replacing another launcher's marker. Later launches validate ownership,
445
+
permissions and length before reading it. This is persistent account-local
446
+
state, not a secret or hardware identity: copying the marker to a clone with
447
+
the same account and path also copies that identity.
448
+
449
+
The reference bootstrap prints `LITHE-TARGET <identity>` after installation
450
+
and waits for a session key on the same authenticated stream before executing
451
+
`--connect`. The client combines this marker with the actual OpenSSH identity
452
+
and explicit route before selecting any previously stored key or token. The
453
+
marker does not replace SSH host-key authentication.
454
+
393
455
`lithe-remote-server --identity` prints one JSON line with `serverVersion`,
394
456
`protocolVersion` and `sha256` of the executable itself. A binary is never
395
457
trusted to report its own hash: bootstrappers reuse an installed server only
@@ -6261,12 +6279,31 @@ gone. Requests over it take `sessionId`:
6261
6279
| `remote.endPrograms` | `{ sessionId, programs? }` | `{ ended }`: every running process gets `SIGTERM` for its process session and every terminal hangs up, or only those `programs` (`[{ kind, id }]` as `remote.runningPrograms` listed them) names; one that ended in the meantime or is not running is not counted, one that ignores the signal is still listed |
6262
6280
6263
6281
`remote.writeFile` replaces the file atomically on the host. With
6264
-
`expected` (`{ size, modifiedMs }` from the read) a changed file is a
6282
+
`expected` (`{ size, modifiedMs, revision? }` from the read) a changed file is a
6265
6283
`conflict`; without it the file must not exist yet. A missing path is
6266
6284
`workspace_not_found`, a denied one `permission_denied`. A broken connection
6267
6285
fails with `connection_closed` and is forgotten, so the host reconnects; an
6268
6286
unknown or closed `sessionId` is also `connection_closed`.
6269
6287
6288
+
Editor saves send `root`, the workspace's absolute host root. The host must
6289
+
advertise `guardedWrites`; otherwise Core returns `not_supported` without
6290
+
sending an unscoped write. Descendant directory and leaf symlinks, path escapes
6291
+
and `..` are refused. General explicit host writes without `root` retain their
6292
+
existing outside-workspace and leaf-link behavior. The opaque `revision` is
6293
+
returned unchanged from the opened host file and compared exactly. Cooperating
6294
+
Lithe daemons serialize saves and recheck after staging; an external writer
6295
+
that ignores their advisory lock still has the final check-to-rename window.
6296
+
See the [remote protocol](remote-workspace-protocol-v1.md) for the path and
6297
+
conflict-protection limits.
6298
+
6299
+
`remote.readFile` applies a cumulative 16 MiB decoded-content limit and a
6300
+
120-second overall read deadline, with each chunk limited to 30 seconds.
6301
+
Cancellation is checked between chunks and at most every 50 ms while waiting
6302
+
for a reply; dropping a pending chunk withdraws unsent work and ignores late
6303
+
replies without closing the connection. The read validates chunk progress, EOF
6304
+
and file revisions, rejecting a changed file instead of returning mixed content.
6305
+
It does not perform a preliminary uncancellable `stat` outside that deadline.
6306
+
6270
6307
`remote.hostRequest` accepts finite filesystem, environment and port queries,
6271
6308
`server.state` (what still runs, with the `label` given at start, so the host
6272
6309
can ask before closing a window), plus controls of existing processes and
@@ -6451,12 +6488,15 @@ one is (see "Global SDK registrations without an open project"), but its
6451
6488
decisions are separate and never carry over. They are keyed by the
6452
6489
connection's **target** and the workspace's **real path** on the host:
6453
6490
6454
-
- The target is `{ hops, userId? }`. Each hop keeps only what chooses where
6491
+
- The target is `{ hops, userId?, identity? }`. Each hop keeps only what chooses where
message:"Remote identity could not authorize automatic session recovery",
1550
+
fields:&[
1551
+
FieldMetadata{name:"error",field_type:FieldType::Error,required:true,description:"Controlled identity category without host names, fingerprints or credentials",reason:None},
1552
+
FieldMetadata{name:"stage",field_type:FieldType::Token,required:true,description:"Identity validation or resume binding stage",reason:None},
0 commit comments