session-peer 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,867 @@
1
+ # ADR: Python-free remote deployment and version compatibility
2
+
3
+ [Back to the guide](../guide.md) · [Parity matrix](../../PARITY.md) · Issue [#23](https://github.com/abruption/session-peer-ts/issues/23)
4
+
5
+ | Field | Value |
6
+ | --- | --- |
7
+ | Status | **Proposed** (design only; nothing in this document is implemented) |
8
+ | Date | 2026-10-02 |
9
+ | Applies to | `session-peer` 0.2.1 source and later; SSH transport (`--host`) only |
10
+ | Decision owner | Repository maintainer |
11
+ | Supersedes | Nothing. The exact-version preflight stays in force until the follow-ups below are implemented and verified |
12
+
13
+ ## Contents
14
+
15
+ - [Context](#context)
16
+ - [Constraints](#constraints)
17
+ - [Options](#options)
18
+ - [Decision](#decision)
19
+ - [Compatibility contract](#compatibility-contract)
20
+ - [Errors](#errors)
21
+ - [Operator workflow](#operator-workflow)
22
+ - [Non-goals](#non-goals)
23
+ - [Validation](#validation)
24
+ - [Follow-ups](#follow-ups)
25
+ - [Review checklist](#review-checklist)
26
+
27
+ ## Context
28
+
29
+ The Python reference (1.0.2) streams its standalone source to `python3 -` over
30
+ SSH, so a destination needs only a usable Python and a POSIX shell. Its
31
+ `install.sh --host` additionally pushes the program to
32
+ `$HOME/.local/share/session-peer` and links `$HOME/.local/bin/session-peer`.
33
+
34
+ The TypeScript client deliberately does not do that. In 0.2.1 and 0.3.0 the local client
35
+ runs `ssh -T -o BatchMode=yes -o StrictHostKeyChecking=yes -o ConnectTimeout=10`
36
+ and, before any message leaves the machine:
37
+
38
+ 1. runs `<remote-bin> --version` with no message (15 s timeout);
39
+ 2. requires stdout to equal exactly the client's own version line, for example
40
+ `session-peer 0.3.0 (typescript)` (`VERSION_LINE` in `src/protocol.ts`),
41
+ otherwise refuses with a fixed code from `sshPreflightFailure` in `src/cli.ts`;
42
+ 3. sends a `schemaVersion: 1` JSON request on stdin to
43
+ `<remote-bin> --stdio-request` and verifies the `schemaVersion: 1` response
44
+ shape, command, exit code and send status before reporting success.
45
+
46
+ 0.3.0 ([#20](https://github.com/abruption/session-peer-ts/issues/20))
47
+ adds ordered repeated `--host`, an allowlisted `--ssh-opt`, a single-hop
48
+ `--ssh-jump` for POSIX clients, and IPv6 literals. Each destination still gets
49
+ the same message-free, exact-version `--version` preflight before its one
50
+ request, so the deployment gap described here is unchanged.
51
+
52
+ The destination therefore needs an **explicitly installed TS CLI of the same
53
+ version**, a **supported Node** (22.13+ within 22.x, or 24.x; enforced by the
54
+ CLI itself) and a loadable **native lock binary** from `fs-ext-extra-prebuilt`
55
+ 2.2.14. The native module is loaded lazily (`await import` in `probeLock`,
56
+ `src/writer.ts`), so `--version`, `list`, `doctor` and Claude sends work without
57
+ it, but Codex sends cannot prove the writer lock and refuse with
58
+ `active_writer_unverified`.
59
+
60
+ This boundary is intentional and safe, but it leaves operators without a
61
+ documented way to provision a destination, to diagnose a missing runtime, or to
62
+ upgrade one side at a time. Relaxing the exact-version check without a
63
+ replacement contract would let the local verifier accept response shapes it
64
+ does not understand, which is how `submitted:null`/`unknown` outcomes would be
65
+ misreported.
66
+
67
+ ## Constraints
68
+
69
+ ### Native dependency coverage
70
+
71
+ `fs-ext-extra-prebuilt@2.2.14` (registry integrity
72
+ `sha512-V8yXXh7t…pf9pJ48w==`, SLSA provenance and one registry signature) ships
73
+ all of its binaries **inside its own tarball** under `binaries/`. Its `install`
74
+ script only falls back to `node-gyp`; this project always installs with
75
+ `--ignore-scripts`, so the bundled binary is the only path.
76
+
77
+ | Platform | Architectures | Node ABI files | Notes |
78
+ | --- | --- | --- | --- |
79
+ | darwin | x64, arm64 | node 20–25 (one per major) | |
80
+ | linux | x64, arm64 | node 20–25 | glibc build; highest symbol version `GLIBC_2.28`. No musl (Alpine) file |
81
+ | win32 | x64, arm64 | node 20–25 | |
82
+
83
+ The loader picks `fs-ext-<platform>-<arch>-node-<major>.0.0.node`, falling back
84
+ to the highest major **below** the running one. The binaries are NAN addons,
85
+ not Node-API, so that fallback is not ABI-safe for a newer major. The CLI
86
+ already refuses Node outside 22.13–22.x/24.x before loading anything, which is
87
+ what keeps the fallback unreachable. Not covered: 32-bit and other CPU
88
+ architectures, musl libc, glibc older than 2.28 and FreeBSD. Linux arm64,
89
+ Windows arm64 and macOS x64 files are packaged but not exercised by CI.
90
+
91
+ ### Node and the npm launcher
92
+
93
+ `npm` creates `node_modules/.bin/session-peer` as a `#!/usr/bin/env node`
94
+ symlink (POSIX) or a `.cmd`/`.ps1` launcher (Windows). Both select whatever
95
+ `node` is first on the **non-interactive SSH** `PATH`. That is frequently not
96
+ the operator's interactive Node: version managers such as nvm are usually not
97
+ initialized for `ssh host command`, and one recorded destination selected Node
98
+ 26 on its default PATH ([VALIDATION.md](../../VALIDATION.md#real-tui-and-ssh-checks)).
99
+
100
+ ### Ownership
101
+
102
+ The name `session-peer` is shared with the Python implementation (pipx,
103
+ `install.sh`, `$HOME/.local/bin/session-peer`). The guides already forbid
104
+ `--force` and overwriting another manager's files.
105
+
106
+ ### Offline destinations
107
+
108
+ Python works offline because the source travels over SSH. An npm registry
109
+ install needs network access to `registry.npmjs.org` (or a mirror) from the
110
+ destination, plus the transitive `nan` package.
111
+
112
+ ## Options
113
+
114
+ | Criterion | (a) npm install on each destination | (b) Operator-invoked isolated artifact provisioning | (c) Portable remote bundle |
115
+ | --- | --- | --- | --- |
116
+ | Shape | Operator runs `npm install --global --ignore-scripts session-peer@X` on the destination | Operator verifies the release tarball and its locked dependency tarballs locally, uploads them over the existing SSH trust, installs into a private versioned prefix with `--offline --ignore-scripts`, adds a wrapper with an absolute Node path | New release artifact: a single bundled `cli.js` plus per OS/arch native lock binaries (or a Node single-executable application that embeds Node) |
117
+ | New distribution artifact | No | No (reuses the published tarball and the locked dependency tarballs) | Yes, per OS/arch(/libc/Node major); must be built, signed and verified separately from npm |
118
+ | Native/OS/arch/ABI | Same as the package; bundled prebuilds selected at runtime | Same as the package; checked before activation by a native load probe | Must reproduce the platform matrix and ABI selection; SEA additionally needs per-platform Node binaries and macOS/Windows code signing |
119
+ | Node requirement | Destination Node on PATH | Destination Node at an absolute path recorded in the wrapper | Bundle: destination Node. SEA: none, at a much larger artifact size |
120
+ | Offline | No (registry or mirror needed) | Yes (tarballs travel over SSH; verified install with an empty cache) | Yes |
121
+ | Integrity | npm registry integrity and provenance, verified by the destination's npm, but the operator does not see or pin the hash unless done separately | Local check of registry `dist.integrity`, recorded SHA-256 and SLSA provenance before upload; remote SHA-256 re-check after upload; `package-lock.json` integrity in the prefix | Needs a new provenance and signature chain; npm provenance does not cover a derived bundle |
122
+ | Ownership | Global prefix collides with other `session-peer` executables on PATH | Private, versioned directory; never on PATH; ownership marker | Private directory possible, but a new installer must be written and trusted |
123
+ | Rollback | Reinstall an older version globally | Keep the previous version directory; switch `--remote-bin` | Keep previous bundle |
124
+ | Windows | Works with an isolated prefix (recorded live, [VALIDATION.md](../../VALIDATION.md#native-windows-candidate--2026-09-27-kst)) | Same mechanism as the recorded Windows isolated prefix | Unverified |
125
+ | Engineering cost | Documentation only | Documentation now; an optional helper later | High: new build matrix, signing, size, new security review |
126
+
127
+ ### Assessment
128
+
129
+ - **(a)** stays supported for operators who already manage Node and a registry
130
+ connection, but it gives no offline path, does not pin integrity on the
131
+ operator side, and invites PATH conflicts with the Python CLI.
132
+ - **(c)** solves offline and Node absence most completely, but only by creating
133
+ a second, unsigned distribution channel that npm provenance does not cover,
134
+ multiplied by every OS/arch/libc/Node-major cell. The current prebuilt
135
+ matrix already lives in a single dependency tarball, so a separate bundle
136
+ buys little for its cost. Rejected for now; revisit only if destinations
137
+ without any supported Node become a real requirement.
138
+ - **(b)** uses exactly the artifacts the release process already verifies
139
+ (`scripts/release.mjs` records SHA-256 and SHA-512 integrity, and checks
140
+ provenance and registry signatures), works offline, keeps every executable in
141
+ a directory this workflow owns, and has already been exercised manually on
142
+ live Windows and macOS destinations. Package smoke tests in CI already
143
+ install the packed tarball into an isolated prefix and load the native module
144
+ on macOS, Linux and Windows.
145
+
146
+ ## Decision
147
+
148
+ Adopt **(b) operator-invoked isolated artifact provisioning** as the supported
149
+ deployment path, keep **(a)** as an equivalent but unpinned alternative, and do
150
+ not build **(c)**.
151
+
152
+ Concretely:
153
+
154
+ 1. Provisioning is a separate, explicit operator action, never a side effect of
155
+ `list`, `send` or `doctor`.
156
+ 2. Each destination gets one private, immutable directory per **install
157
+ identity** (package version and SHA-256, locked dependency integrity,
158
+ platform, arch, libc, Node major/ABI and Node path), never on `PATH`. The
159
+ directory holds the installed package, its locked dependencies, an ownership
160
+ marker and a self-locating wrapper that runs the recorded absolute Node path.
161
+ Callers select it with an absolute `--remote-bin`.
162
+ 3. Integrity is checked at three points:
163
+ - before upload: the recorded SHA-256, registry integrity, signatures, and
164
+ provenance naming the release's exact source commit, whose lockfile pins
165
+ the dependencies;
166
+ - after upload: the SHA-256 is recomputed on the destination;
167
+ - at install: `--offline` against the locked integrity values.
168
+ 4. Before activation, the staged install is probed for the exact version banner
169
+ and a native lock load. Activation is a directory rename under a cooperative
170
+ lock: it never nests and never replaces a non-empty target. The exact
171
+ guarantee scope is stated below. The activated directory is verified again
172
+ before any caller switches to it.
173
+ 5. The exact-version preflight remains the only acceptance rule until the
174
+ [compatibility contract](#compatibility-contract) is implemented and
175
+ verified; the workflow does not depend on that contract.
176
+
177
+ The workflow is documented below as a manual procedure. A `session-peer deploy`
178
+ helper is a follow-up, not part of this decision.
179
+
180
+ ## Compatibility contract
181
+
182
+ Package SemVer describes the npm artifact. It must not be the wire contract: a
183
+ documentation-only patch release should not break SSH, and a refactor must not
184
+ silently change response verification. The proposed contract separates three
185
+ things.
186
+
187
+ ### 1. Wire protocol version
188
+
189
+ `wire` is a positive integer that names the request/response framing and the
190
+ verification rules in `remote()`:
191
+
192
+ | Wire | Request | Response the client verifies |
193
+ | --- | --- | --- |
194
+ | 1 (current) | stdin JSON `{schemaVersion:1, args:string[]}` to `--stdio-request`; message in `--message=`, plus `--no-from --no-reply-to` for send | `schemaVersion:1`; `command` echoes the request; boolean `ok`; string `host`; exit code 0/1/2 with `ok === (code === 0)`; doctor `diagnosticCompleted`, `ready`, `implementation:"typescript"`, `agents` object; send `consumptionConfirmed:false`, `submitted`/`status` pairs (`validated`/`posted`/`queued`, `refused`, `unknown`) |
195
+
196
+ Any change to these rules, to the 4,100,000-byte stdin bound, or to the meaning
197
+ of an existing field increments `wire`. Adding an optional response field does
198
+ not.
199
+
200
+ ### 2. Capabilities
201
+
202
+ Capabilities are additive string flags for behavior a command depends on, for
203
+ example `list`, `send.claude`, `send.codex`, `doctor`, `codexHome.inactiveOptIn`,
204
+ `nativeLock`. A capability is never removed without incrementing `wire`.
205
+
206
+ ### 3. Capability preflight
207
+
208
+ A new, side-effect-free flag `<remote-bin> --capabilities` prints one JSON line
209
+ and sends nothing:
210
+
211
+ ```json
212
+ {"schemaVersion":1,"implementation":"typescript","version":"0.3.0",
213
+ "wire":{"min":1,"max":1},
214
+ "capabilities":["list","doctor","send.claude","send.codex","codexHome.inactiveOptIn"],
215
+ "runtime":{"node":"24.16.0","modules":"137","platform":"linux","arch":"x64"},
216
+ "nativeLock":"loaded"}
217
+ ```
218
+
219
+ `nativeLock` is `loaded`, `missing` (no matching prebuild) or `failed` (other
220
+ load error). It is determined by importing the module without opening a file.
221
+ The output contains no paths, hostnames, user names or agent state.
222
+
223
+ ### Negotiation rules
224
+
225
+ 1. The client always runs `--version` first, exactly as today. An exact match is
226
+ accepted without version negotiation. Every released client (0.2.x and
227
+ earlier, which can never learn new rules) therefore stays interoperable with
228
+ a correctly provisioned remote.
229
+
230
+ Round trips:
231
+ - `list`, `doctor` and Claude sends need one preflight round trip.
232
+ - Once F2/F3 ship, a Codex send adds a second, message-free
233
+ `--capabilities` round trip, even on an exact match, to check
234
+ `nativeLock` before dispatch. Releases without F2/F3 keep a single round
235
+ trip.
236
+ - A version mismatch with negotiation enabled also uses `--capabilities`
237
+ (rule 2).
238
+ - Preflight never takes more than two message-free round trips.
239
+ 2. Only when the banner is a `typescript` banner of a different version **and**
240
+ negotiation is enabled does the client run `--capabilities`. A remote that
241
+ answers with a refusal (all releases up to 0.2.x answer
242
+ `unsupported_command`) is a legacy remote and is refused with
243
+ `remote_version_mismatch`, exactly as today.
244
+ 3. The client accepts only if the implementation is `typescript`, the
245
+ wire ranges overlap (the highest common value is used), every capability the
246
+ requested command and options need is present, and `nativeLock` is `loaded`
247
+ when the command needs the Codex writer lock.
248
+ 4. Response verification is selected by the negotiated wire version, never by
249
+ the local package version.
250
+ 5. Results gain an optional `remoteVersion` (the verified remote banner version)
251
+ and `wire` field, for parity with Python's remote metadata.
252
+
253
+ ### Retention of exact-version refusal
254
+
255
+ Until follow-ups [F2 and F3](#follow-ups) are merged **and** live POSIX and
256
+ Windows destinations with mismatched versions are recorded in VALIDATION.md,
257
+ the shipped behavior remains: any banner other than the exact local
258
+ `VERSION_LINE` is `remote_version_mismatch` and nothing is sent. Negotiation
259
+ first ships disabled and observational (it may report what it would have
260
+ accepted, but it does not change acceptance). Enabling it by default is a
261
+ separate, reviewed change with its own release note.
262
+
263
+ ## Errors
264
+
265
+ All preflight errors keep today's guarantees: they occur before any message is
266
+ dispatched, report `submitted:false`, `status:"refused"`,
267
+ `retryAllowed:false`, exit code 1, and never echo SSH stderr or remote output.
268
+ Proposed codes are new; neither 0.2.1 nor current source emits them.
269
+
270
+ | Condition | 0.2.1 result | Proposed code | Operator message (text output and docs) |
271
+ | --- | --- | --- | --- |
272
+ | No `ssh` locally | `ssh_unavailable` | unchanged | Install OpenSSH on this machine; session-peer does not bundle an SSH client. |
273
+ | Remote executable not found | `remote_cli_missing` | unchanged | No session-peer at the remote path. Provision this version with the operator workflow and pass its absolute wrapper with `--remote-bin`. |
274
+ | Node missing on the destination (`env: node: No such file or directory`, `node: not found`, `'node' is not recognized`) | `remote_cli_missing` (indistinguishable) | `remote_runtime_missing` | The remote launcher could not find Node. Use the provisioned wrapper, which records an absolute Node 22.13+/24 path. |
275
+ | Destination Node outside 22.13–22.x/24.x (remote prints its own `unsupported_node_version` refusal JSON, exit 2) | `ssh_preflight_failed` | `remote_node_unsupported` (with `remoteNode` major when parseable) | The remote Node version is unsupported. Point the wrapper at Node 22.13+ or 24. |
276
+ | Destination OS not darwin/linux/win32 | `ssh_preflight_failed` | `remote_platform_unsupported` | This destination's OS is not supported by the TypeScript client. |
277
+ | Non-TypeScript banner (for example Python `session-peer 1.0.2`) | `remote_version_mismatch` | `remote_implementation_mismatch` | The remote session-peer is a different implementation. Leave it in place and provision the TypeScript client in its own directory. |
278
+ | TypeScript banner, different version, negotiation disabled or legacy remote | `remote_version_mismatch` | unchanged (add sanitized `remoteVersion`) | Install the same version on both ends, or upgrade the older side. |
279
+ | Wire ranges do not overlap | n/a | `remote_protocol_incompatible` | The two versions share no wire protocol. Upgrade the older side. |
280
+ | Required capability absent | n/a | `remote_capability_missing` (with `capability`) | The remote version cannot perform this command or option. |
281
+ | Native lock module cannot load (no prebuild for OS/arch/Node major, musl, old glibc) | Preflight passes; a Codex send later refuses `active_writer_unverified` | Preflight: `remote_native_lock_unavailable`. Local and remote `doctor`: a `nativeLock` check with `native_lock_unavailable` | No compatible native lock binary for this OS, CPU and Node. Use x64/arm64 with glibc 2.28+ and Node 22/24. |
282
+ | Wrapper's running Node differs from the install identity (realpath, major, ABI, platform, arch) | Not detected within 22.13–22.x/24.x | Remote: `install_runtime_mismatch`; client: `remote_install_runtime_mismatch` (both proposed, F6) | The remote Node changed since this install was provisioned. Provision a new install for the current Node. |
283
+
284
+ `remote_runtime_missing` and `remote_node_unsupported` reuse the existing
285
+ classifier style: a fixed pattern on a failed preflight, or parsing the remote
286
+ CLI's own refusal JSON from stdout. Neither leaks the matched text.
287
+
288
+ ## Operator workflow
289
+
290
+ All steps run on the operator's machine. Each remote step is one `ssh`
291
+ invocation with `BatchMode=yes` and `StrictHostKeyChecking=yes` over trust the
292
+ operator already has; no step accepts a new host key, prompts for a password or
293
+ uses Python. Every remote file operation below runs with the recorded Node
294
+ (`identity.node`, an absolute realpath; Node is already required by the CLI) or
295
+ with a named OS primitive. The workflow never relies on `node` or `npm` being on
296
+ the SSH session's PATH. Generic `mv`,
297
+ `mv -n` and PowerShell `Move-Item` are not used, because each moves the source
298
+ *into* an existing destination directory.
299
+
300
+ ### Install identity
301
+
302
+ The native lock binary is selected per platform, CPU, libc and Node ABI. The
303
+ wrapper also records an absolute Node path. Therefore the package version alone
304
+ is not the identity of an installation. Each install directory is named
305
+ `<version>-<id16>`, where `<id16>` is the first 16 hex digits of the SHA-256 of
306
+ this canonical identity (JSON with the keys in this order):
307
+
308
+ | Key | Source |
309
+ | --- | --- |
310
+ | `package`, `version` | Release being installed |
311
+ | `sha256` | SHA-256 of the verified `session-peer` tarball |
312
+ | `lockIntegrity` | SHA-512 integrity of each dependency tarball, from the release commit's `package-lock.json` |
313
+ | `platform`, `arch` | `process.platform`, `process.arch` of the recorded Node |
314
+ | `libc` | Linux only: `glibc` or `musl` (from `process.report`) |
315
+ | `nodeMajor`, `modules` | Major version and `process.versions.modules` (ABI) of the recorded Node |
316
+ | `node` | `realpath` of the recorded Node executable |
317
+
318
+ The full identity and its hash are stored in `.session-peer-owner.json`.
319
+ Installed directories are **immutable**. Any change to an identity field
320
+ creates a new directory beside the old one; nothing is edited in place. This
321
+ applies to a new release, a different tarball, a different Node path, Node
322
+ major or ABI, and a moved or upgraded Node.
323
+
324
+ **Runtime drift after activation.** An in-place Node replacement at the same
325
+ path changes the runtime without changing the directory name.
326
+
327
+ - **Current limitation (0.2.1):** nothing detects a change within the supported
328
+ range. A same-path 22→24 change is accepted by the CLI's own
329
+ `unsupported_node_version` check, which covers only majors outside
330
+ 22.13–22.x/24.x. The native loader then picks the binary for the new major,
331
+ so the install keeps working while its recorded identity is stale. Only a
332
+ change to an unsupported major (for example 26) is refused today.
333
+ - **Proposed (F6, unimplemented):** the wrapper runs a small launcher,
334
+ `launch.mjs`, written into the install. Before importing
335
+ `node_modules/session-peer/dist/cli.js`, it compares `realpath(process.execPath)`,
336
+ the Node major, `process.versions.modules`, platform and arch with the
337
+ marker's `identity`. On any difference it prints the CLI's refusal JSON with
338
+ the **proposed** code `install_runtime_mismatch` and exits 2. The SSH client
339
+ would map that code to the **proposed** `remote_install_runtime_mismatch`.
340
+ The operator then provisions a new identity; nothing is repaired in place.
341
+ Patch upgrades that keep major, ABI and realpath keep the identity.
342
+
343
+ ### Layout and root trust
344
+
345
+ | Platform | Root (never on PATH) | Install directory |
346
+ | --- | --- | --- |
347
+ | POSIX | `${XDG_DATA_HOME:-$HOME/.local/share}/session-peer-ts` | `<root>/<version>-<id16>/` |
348
+ | Windows | `%LOCALAPPDATA%\session-peer-ts` | `<root>\<version>-<id16>\` |
349
+
350
+ Each install directory contains:
351
+
352
+ - `node_modules/` and the `package.json`/`package-lock.json` written by npm;
353
+ - the wrapper (`session-peer` on POSIX, `session-peer.cmd` on Windows);
354
+ - `.session-peer-manifest.json` (described below);
355
+ - `.session-peer-owner.json`. This complete example shows every field; hashes
356
+ are abbreviated:
357
+
358
+ ```json
359
+ {"manager":"session-peer-ts operator workflow","markerVersion":1,
360
+ "runId":"<128-bit random hex, generated on the operator side>",
361
+ "identityHash":"<64 hex>",
362
+ "identity":{"package":"session-peer","version":"0.2.1",
363
+ "sha256":"6bf3c99d12260ce2e9421909b27326f1663ce6945aa798bc90ca1e17da675e43",
364
+ "lockIntegrity":{"fs-ext-extra-prebuilt":"sha512-V8yX…","nan":"sha512-GlGk…"},
365
+ "platform":"linux","arch":"x64","libc":"glibc","nodeMajor":24,"modules":"137",
366
+ "node":"/absolute/path/to/node"},
367
+ "manifestSha256":"<64 hex of .session-peer-manifest.json>",
368
+ "provenance":{"sourceCommit":"a9c42334da8f7faf83f0b9bb1fe52f1c695dfe8d",
369
+ "registryIntegrity":"sha512-bPjriJZf…5nw0Mg==",
370
+ "npm":{"cli":"/absolute/path/to/npm-cli.js","version":"11.x.y"}},
371
+ "stagedAt":"<UTC ISO 8601>"}
372
+ ```
373
+
374
+ `identity` determines the directory name. `runId`, `manifestSha256`,
375
+ `provenance` and `stagedAt` describe this particular install and are not part
376
+ of the identity hash.
377
+
378
+ The wrapper locates the install **relative to its own path**, so the same file
379
+ works in staging and after activation. It never embeds the final directory.
380
+ Below, `<node>` is always `identity.node`, the absolute realpath recorded in
381
+ step 2:
382
+
383
+ - POSIX: `here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) || exit 127`
384
+ followed by `exec '<node>' "$here/node_modules/session-peer/dist/cli.js" "$@"`.
385
+ - Windows: `"<node>" "%~dp0node_modules\session-peer\dist\cli.js" %*`.
386
+
387
+ With the proposed identity check, the wrapper targets `"$here/launch.mjs"` (or
388
+ `%~dp0launch.mjs`) instead. Only the Node path is fixed, because it is part of
389
+ the identity.
390
+
391
+ `.session-peer-manifest.json` lists the SHA-256 of every regular file in the
392
+ install, except the manifest and the marker; the marker stores the manifest's
393
+ SHA-256. The `identityHash` check proves only that the marker is consistent
394
+ with the directory name. Content checks recompute the manifest. Both files are
395
+ writable by the same user, so this detects corruption, partial installs and
396
+ accidental edits. It is not a security boundary against a same-user attacker,
397
+ who could rewrite both.
398
+
399
+ Before any write, and again before activation, the root must pass trust checks.
400
+ On failure, refuse and change nothing.
401
+
402
+ - **POSIX:** check the root and each component from `$HOME` down with `lstat`.
403
+ No component may be a symlink. Each must be owned by the SSH user, and none
404
+ may be group- or world-writable. The root and each install directory are mode
405
+ `0700`.
406
+ - **Windows:** the root and install directories must not be reparse points
407
+ (symlinks or junctions). The owner must be the SSH user. The DACL may grant
408
+ write access only to that user, `SYSTEM` and `Administrators`, which matches
409
+ the inherited `%LOCALAPPDATA%` default. Refuse if `Everyone`, `Users` or
410
+ `Authenticated Users` can write.
411
+
412
+ The root name differs from Python's `$HOME/.local/share/session-peer` on
413
+ purpose. The workflow never writes `$HOME/.local/bin`, a global npm prefix, a
414
+ PATH entry, a shell profile or a service.
415
+
416
+ ### Steps
417
+
418
+ 1. **Select and verify locally, pinned to the release commit.** Take the
419
+ release's exact source SHA from the release record in VALIDATION.md (0.2.1:
420
+ `a9c42334…`). Fetch `session-peer@X` with `npm pack --ignore-scripts`. Require
421
+ all of the following, and stop on any mismatch:
422
+ - the tarball's SHA-256 equals the recorded SHA-256;
423
+ - its SHA-512 equals `npm view session-peer@X dist.integrity`;
424
+ - the registry SLSA provenance names that same commit and
425
+ `.github/workflows/publish.yml`;
426
+ - `npm audit signatures` passes in a scratch install.
427
+
428
+ Read the dependency versions and integrity from `package-lock.json` **at that
429
+ commit** (`git show <sha>:package-lock.json`), not from a working checkout or
430
+ current main. Fetch those exact dependency tarballs and require their SHA-512
431
+ to match.
432
+ 2. **Inspect the destination read-only.** Check:
433
+ - root trust, as above;
434
+ - the absolute Node path and its `realpath`, version, ABI, platform, arch and
435
+ libc, which together compute the identity;
436
+ - the npm bundled with that Node: its `npm-cli.js` realpath
437
+ (`<node-prefix>/lib/node_modules/npm/bin/npm-cli.js` on POSIX,
438
+ `<node-dir>\node_modules\npm\bin\npm-cli.js` on Windows) and
439
+ `<node> <npm-cli.js> --version`, both recorded in the marker as install
440
+ provenance. If it is absent, refuse; the workflow does not upload npm;
441
+ - any existing `session-peer` on PATH (`command -v`/`type -a`, or
442
+ `Get-Command session-peer -All`);
443
+ - the state of `<root>/<version>-<id16>`.
444
+
445
+ Record other implementations, but never modify them.
446
+ 3. **Upload** the tarballs into a new `<root>/<version>-<id16>.staging-<random>`
447
+ directory, created exclusively (`mkdir` that fails if the path exists, mode
448
+ `0700`). Recompute SHA-256 remotely (`sha256sum`/`shasum -a 256`, or
449
+ `Get-FileHash -Algorithm SHA256`). Stop on mismatch.
450
+ 4. **Install offline:**
451
+ `<node> <npm-cli.js> install --prefix <staging> --offline --ignore-scripts --no-audit --no-fund <three tarballs>`
452
+ with an empty, staging-local cache. Run it with `PATH` set to
453
+ `dirname(<node>)` followed by the system directories, so that any child
454
+ resolving `node` gets the identity Node. `--ignore-scripts` means no package
455
+ scripts run. Compare the `integrity` values in
456
+ `<staging>/package-lock.json` with step 1.
457
+ 5. **Write the wrapper, the manifest and the marker into staging**, in that
458
+ order, so a marker exists only for a complete tree.
459
+ 6. **Probe staging.** Run `<staging>/session-peer --version` (exact banner) and a
460
+ native lock probe that resolves `fs-ext-extra-prebuilt` from
461
+ `<staging>/node_modules` and takes and releases `flock`/`LockFileEx` on a file
462
+ inside staging. Until F2 ships, this is a short script equivalent to
463
+ `test/package-smoke.ts`; afterwards it is `<staging>/session-peer
464
+ --capabilities` reporting `nativeLock:"loaded"`. The probe runs the new code
465
+ only, whatever exists at the final path.
466
+ 7. **Activate** according to the target state (table below), while holding the
467
+ [activation lock](#activation-lock-and-guarantee-scope). The only
468
+ activation operation is a directory rename within `<root>`:
469
+ - **POSIX:** `fs.renameSync(staging, target)` from `<node>`, which is
470
+ `rename(2)`. Run it only after `lstat(target)` returned `ENOENT`.
471
+ `rename(2)` never nests. It fails with `ENOTEMPTY`/`EEXIST` for a non-empty
472
+ directory and with `ENOTDIR` for a file or symlink, changing nothing.
473
+ **It does replace an empty directory.** On GNU systems, `mv -T` has the
474
+ same rename semantics, but it is not available on macOS and is not used.
475
+ - **Windows:** `[System.IO.Directory]::Move(staging, target)`, which is
476
+ documented to throw `IOException` when the target exists and never nests.
477
+ Do not use `Move-Item`, which nests into an existing directory, or
478
+ `MoveFileEx` with `MOVEFILE_REPLACE_EXISTING`.
479
+ 8. **Verify after activation.** Check all of the following:
480
+ - `lstat(target)` is a real directory (no symlink or reparse point) owned by
481
+ the user;
482
+ - the staging path no longer exists;
483
+ - the marker's `identityHash` equals the computed identity and the name;
484
+ - the recomputed manifest equals the one the marker references;
485
+ - `<target>/session-peer --version` prints the exact banner;
486
+ - the native probe passes against `<target>`.
487
+
488
+ Then verify from the operator machine with
489
+ `session-peer doctor --host H --remote-bin <target>/session-peer --json` and a
490
+ `send ... --dry-run`. Never send a live message as a deployment check.
491
+ The order is fixed: **publish the receipt, then release the lock, then
492
+ switch callers (step 9)**.
493
+ 9. **Switch callers.** Only after the receipt is published and the lock is
494
+ released does the operator change any local `--remote-bin` configuration to
495
+ the new target. Until then, existing callers keep using the previous
496
+ install unchanged.
497
+
498
+ ### Activation lock and guarantee scope
499
+
500
+ - **Where the run lives:** a provisioning run is an **operator-side**
501
+ process (the operator's shell session, or the F6 helper) with a lifetime on
502
+ the operator host. Each remote step is a separate, short-lived SSH command
503
+ that exits. A remote PID or process start time therefore identifies no
504
+ running owner and is never used to judge a lock.
505
+ - **Lock:** `<root>/.activate.lock` is created with `mkdir`, which fails with
506
+ `EEXIST` if the path exists. The same remote command then writes
507
+ `owner.json` exclusively (fails if it exists) with:
508
+ - `runId`;
509
+ - an opaque operator label (a random ID the operator side generates once and
510
+ keeps locally; never a hostname or user name);
511
+ - the creation time.
512
+
513
+ The operator side keeps a local run journal with the same `runId`, the
514
+ destination alias and its progress through the steps. The lock is held from
515
+ the pre-activation `lstat` through step 8 and the receipt below, or through
516
+ rollback.
517
+ - **Contention:** if the lock exists, refuse; never wait-and-steal.
518
+ - **Stale lock:** staleness is never decided automatically or on the
519
+ destination. A lock is released only by:
520
+ - the run that owns it (matching `runId` in that operator's journal); or
521
+ - an explicit operator break-lock command, after the operator confirms on
522
+ the owning operator host that the run has ended.
523
+
524
+ A lock without `owner.json`, with an unreadable `owner.json`, or whose owning
525
+ operator run cannot be confirmed is **never** judged stale. It stays until
526
+ an operator breaks it explicitly.
527
+ - **Operator override boundary:** breaking a lock that has no confirmable
528
+ owner requires both an explicit operator command naming the lock and a
529
+ statement that the run has ended. The override only removes the lock. It
530
+ never deletes or rolls back an install; that is done by the recovery below,
531
+ under a new lock.
532
+ - **`.receipts` trust:** before any write to or delete from
533
+ `<root>/.receipts`, `lstat` it (and the receipt file). It must pass the
534
+ same root trust checks: a real directory, not a symlink or reparse point,
535
+ owned by the user, POSIX mode `0700` or the Windows DACL rule. Receipt
536
+ files must be regular files. Otherwise refuse. Nothing is ever written
537
+ outside `<root>` through a link or junction.
538
+ - **Completion receipt:** after every step 8 check passes, the run writes
539
+ `<root>/.receipts/<install-name>.json` exclusively. The receipt copies the
540
+ marker's `runId` (the run that activated the install), its `identityHash`
541
+ and its `manifestSha256` exactly, and adds the verification time. The
542
+ operator journal records the same receipt. If a later run writes the
543
+ receipt, that run's own ID is recorded only in its operator journal, never
544
+ in the receipt.
545
+ - **Receipt matching:** a receipt *matches* an install only if its `runId`,
546
+ `identityHash` and `manifestSha256` all equal the marker's and the
547
+ recomputed manifest's values. Receipts that are corrupt (unparsable),
548
+ mismatched (any field differs) or orphaned (no install directory with that
549
+ name) are refused. They are never deleted blindly. They may be quarantined
550
+ or removed only by an explicit operator cleanup that holds the activation
551
+ lock (exclusive write), after the trust checks, and after ownership is
552
+ confirmed through the marker or the operator journal.
553
+ - **What a missing receipt means:** verification of that install is
554
+ insufficient. It does not prove the run never finished; the run may have
555
+ died after step 8 but before writing the receipt.
556
+ - **Breaking a lock whose owner is confirmed ended:** the operator confirms
557
+ that the run ended, then releases that old lock. It never recovers anything
558
+ under the old lock. A target whose marker carries the old `runId` and has a
559
+ matching receipt is complete. Without a matching receipt, the target is
560
+ handled by the recovery below, which takes a fresh lock.
561
+ - **Recovering an owned target without a matching receipt:** this is an
562
+ explicit operator action by a new run. The run first acquires a fresh
563
+ activation lock with its own `runId`; if the lock already exists
564
+ (`EEXIST`), it refuses. This applies whether or not a prior lock existed.
565
+ The basis for the recovery is the target's existing marker, which must be
566
+ valid and owned by this workflow, plus the trust checks. It is not an
567
+ assumption that the target was absent before some step 7. The recovery
568
+ refuses unless:
569
+ - the target passes the trust checks;
570
+ - its marker is valid and owned;
571
+ - there is no matching receipt.
572
+
573
+ The run then chooses between two outcomes:
574
+ - **re-verify:** run all step 8 checks again, then write a receipt that
575
+ copies the marker's `runId`, `identityHash` and `manifestSha256`. The
576
+ recovery run's own ID goes only into its operator journal.
577
+ - **roll back:** allowed only if the current operator journal positively
578
+ confirms that no local caller is configured for the target. A missing
579
+ receipt is not evidence of that. If the journal cannot confirm it, refuse
580
+ rollback; only re-verify is permitted. A rollback renames the target to a
581
+ `.failed-<random>` name with the no-replace operation, then deletes it.
582
+ - **What is guaranteed:**
583
+ - concurrent runs of *this workflow* are serialized;
584
+ - an existing non-empty directory, file or symlink is never replaced or
585
+ nested into;
586
+ - foreign and empty targets seen before the rename are refused;
587
+ - Windows `Directory.Move` is natively no-replace.
588
+ - **What is not guaranteed on POSIX:** a same-user process that ignores the
589
+ lock can create an *empty* directory at the target between `lstat` and
590
+ `rename(2)`. That directory would be replaced silently and could not be
591
+ detected afterwards. Other users cannot do this, because the root is `0700`
592
+ and owned by the user, and nothing is lost except an empty directory.
593
+ Closing this window needs `renameat2(RENAME_NOREPLACE)` (Linux) or
594
+ `renamex_np(RENAME_EXCL)` (macOS). Node does not expose either, so it would
595
+ require a native helper; this is out of scope.
596
+
597
+ ### Activation outcome by target state
598
+
599
+ | State of `<root>/<version>-<id16>` before step 7 | Outcome |
600
+ | --- | --- |
601
+ | Absent | Rename, then step 8. On failure in step 8, roll back (below). |
602
+ | Owned by this workflow, same `identityHash`, a matching completion receipt, and step 8 checks (including the manifest) pass on the existing directory | Report "already provisioned" and reuse the existing receipt (no new receipt). Delete only this run's staging; no change. |
603
+ | Owned, same `identityHash`, but **no matching receipt** | Verification is insufficient. Refuse. The operator runs the explicit recovery (re-verify or roll back) under the lock, then reruns. |
604
+ | Receipt present but corrupt or mismatched, or a `.receipts` path failing trust checks | Refuse. Explicit, ownership-confirmed cleanup only; never a blind delete. |
605
+ | Owned, same `identityHash`, but step 8 checks fail (manifest mismatch, partial or corrupted) | Refuse with "existing install failed verification". Delete only this run's staging. The operator removes the old directory explicitly (marker-guarded, see retention) and reruns. Never repair in place. |
606
+ | Owned, but `identityHash` does not match the name | Refuse as an inconsistent marker; change nothing but this run's staging. |
607
+ | Different version, tarball or runtime identity | Cannot collide: the name differs, so it installs beside the existing directories. |
608
+ | Foreign: no marker, an unparsable marker, another `manager`, a symlink or reparse point, a file, or another owner | Refuse; never modify; delete only this run's staging. |
609
+ | Empty directory (an aborted manual attempt) | Treated as foreign. Refuse rather than let `rename(2)` replace it. |
610
+ | Leftover `*.staging-*` from an aborted run | Never a candidate target or install. Removed only by explicit cleanup, only if it is inside `<root>`, passes the trust checks and is not this run's staging. |
611
+
612
+ ### Ownership rules
613
+
614
+ - Only paths under `<root>` whose `.session-peer-owner.json` names this
615
+ workflow may be changed or removed. A directory without a valid marker is
616
+ foreign; refuse.
617
+ - Never create, replace or delete a `session-peer` on PATH, the Python install
618
+ directory, pipx venvs or a global npm prefix. Never use `npm --force`.
619
+ - A destination that already has a working global (a) install is left alone;
620
+ (b) installs beside it.
621
+
622
+ ### Cleanup and rollback
623
+
624
+ - **Failure before activation (steps 1–6):** remove only this run's staging
625
+ directory. Nothing else changed.
626
+ - **Failure during or after activation (steps 7–8, same run, no receipt
627
+ yet):** within the run that performed step 7, the target was absent before
628
+ the rename, so the directory now at the target is exactly this run's
629
+ staging. A later run recovering such a target relies on the owned marker
630
+ and trust checks instead (see recovery above). Rename it back to a `.failed-<random>` name with the same no-replace
631
+ operation, then delete it. Previous installs and caller configuration were
632
+ never touched, because step 9 did not run.
633
+ - **Rollback after switching callers:** previous install directories are kept,
634
+ at least the newest prior one per runtime. Rolling back means pointing
635
+ `--remote-bin` at that directory again. While exact versions are enforced,
636
+ the local client must be rolled back to the same version too.
637
+ - **Retention:** remove an old install only on explicit operator request, only
638
+ if its marker is valid and owned, it passes the trust checks, and no local
639
+ caller is configured to use it. Removal is a recursive delete of that one
640
+ directory plus its receipt in `<root>/.receipts/`, and nothing else.
641
+
642
+ ## Non-goals
643
+
644
+ - No implicit remote installation, upgrade or repair during `list`, `send` or
645
+ `doctor`. Preflight failures stay refusals.
646
+ - No Python runtime fallback and no reuse of the Python source-streaming path.
647
+ - No host-key relaxation: no `StrictHostKeyChecking=no`/`accept-new`, no
648
+ `known_hosts` edits, no password prompts, and no new authentication via
649
+ control sockets.
650
+ - No overwriting another manager's `session-peer` executable or files (pipx,
651
+ `install.sh`, a global npm prefix, Homebrew or a manual install).
652
+ - No new distribution artifact (single-file bundle or SEA), no `node-gyp` builds
653
+ on destinations, no musl or 32-bit support.
654
+ - No changes to SSH connection handling. Multi-host commands, `--ssh-opt` and
655
+ `--ssh-jump` are delivered separately by
656
+ [#20](https://github.com/abruption/session-peer-ts/issues/20); provisioning
657
+ runs per destination and adds no SSH options. Service management is out of
658
+ scope.
659
+ - No remote update. The source `update --check` reads npm dist-tags for the
660
+ local installation only. It does not provision or update a destination,
661
+ and this workflow does not change that.
662
+
663
+ ## Validation
664
+
665
+ ### Validated locally (macOS arm64, Node 24.16.0, npm 11.15.0; 2026-10-02)
666
+
667
+ No network destination was contacted. Registry reads (`npm pack`, `npm view`)
668
+ were the only network use. Commands ran in a private 700 scratch directory.
669
+
670
+ | Check | Command (abridged) | Result |
671
+ | --- | --- | --- |
672
+ | Published artifact integrity | `npm pack session-peer@0.2.1 --ignore-scripts`; `shasum -a 256`; `npm view session-peer@0.2.1 dist.integrity` | SHA-256 `6bf3c99d…5e43` and integrity `sha512-bPjriJZf…5nw0Mg==` both equal the [0.2.1 release record](../../VALIDATION.md#public-021--2026-09-29-kst) |
673
+ | Dependency integrity | `npm pack fs-ext-extra-prebuilt@2.2.14 nan@2.29.0`; local SHA-512 | Equal to `package-lock.json` |
674
+ | Offline isolated install | `npm install --prefix <root>/<name>.staging-<pid> --offline --cache <empty> --ignore-scripts --no-audit --no-fund` with the three tarballs | Installed 3 packages; prefix lockfile integrity values equal step 1 |
675
+ | Release pin | `git show a9c42334…:package-lock.json`; registry SLSA provenance payload | Dependency integrity equals the release commit's lockfile; provenance names commit `a9c42334…` and `.github/workflows/publish.yml` |
676
+ | Install identity | Identity JSON computed with the recorded Node (darwin, arm64, Node 24, ABI 137, Node realpath) | Directory `0.2.1-<id16>`; marker holds the full identity and hash |
677
+ | Staging probe | Self-locating POSIX wrapper in `<root>/<name>.staging-<pid>`; `env -i PATH=/usr/bin:/bin <staging>/session-peer --version`; native probe resolved from staging, with **no final directory present** | Exact banner, exit 0; native lock ok. The probe exercised staging, not a final path |
678
+ | Activation | `lstat(target)` is `ENOENT`, then `fs.renameSync(staging, target)` | Renamed; the target is a real directory; staging is gone |
679
+ | Post-activation | `<target>/session-peer --version`, native probe on `<target>`, marker hash check; `doctor --host … --remote-bin <target>/session-peer` through the `ssh` stand-in | Exact banner; native ok; hash matches; `ok:true`, `diagnosticCompleted:true` |
680
+ | Second run onto the activated directory | `fs.renameSync(copy, target)` | `ENOTEMPTY`; target unchanged and not nested |
681
+ | Move semantics (macOS 27, BSD `mv`) | `mv a b` and `mv -n a b` with an existing `b/`; `fs.renameSync` onto non-empty, empty, file, symlink and absent targets | Both `mv` forms nest `a` into `b/a`. `renameSync`: `ENOTEMPTY`, **replaces empty**, `ENOTDIR`, `ENOTDIR`, ok |
682
+ | npm through the recorded Node | `env -i PATH=<dirname(node)>:/usr/bin:/bin <node> <npm-cli.js realpath> install --prefix <staging> --offline …` with an empty cache | npm 11.15.0; installed all three packages |
683
+ | Proposed identity launcher (prototype, not shipped) | Self-locating wrapper → `launch.mjs` compares the marker identity with the running Node; then the marker is edited to `nodeMajor:22`, `modules:"127"` | Matching identity: exact banner, exit 0. Edited identity: `install_runtime_mismatch` refusal JSON, exit 2 |
684
+ | Activation lock | `fs.mkdirSync(<root>/.activate.lock)` twice | First acquired; second `EEXIST` |
685
+ | Installed CLI | `list --json`, `doctor --json` with an empty HOME | `ok:true`, Claude `ok`, Codex `not_installed`; doctor `diagnosticCompleted:true`, `implementation:"typescript"` |
686
+ | Native lock | `flockSync(fd,'exnb')`/`'un'` from the prefix | Loaded the darwin-arm64 node-24 binary (ABI 137) |
687
+ | SSH preflight through a local `ssh` stand-in (drops options, runs the remote command locally) | `list --host dest.example --remote-bin <wrapper> --json` | `ok:true`, `host`/`sshHost` set |
688
+ | Same, dry-run send to an absent PID | `send ... --to 999999 --dry-run` | `no_reachable_target`, `submitted:false` (remote refusal propagated) |
689
+ | Python-like banner | remote prints `session-peer 1.0.2` | `remote_version_mismatch` |
690
+ | Missing executable | `--remote-bin` to a nonexistent path | `remote_cli_missing` |
691
+ | Node missing on remote PATH | `#!/usr/bin/env node` launcher with no Node on PATH | `remote_cli_missing`, confirming the gap behind `remote_runtime_missing` |
692
+ | Unsupported remote Node (simulated: launcher prints the CLI's `unsupported_node_version` refusal, exit 2) | as above | `ssh_preflight_failed`, confirming the gap behind `remote_node_unsupported` |
693
+ | Missing prebuild (simulated: this platform's binaries removed from a copy) | `--version`; dynamic `import('fs-ext-extra-prebuilt')` | `--version` still passes; import fails with "No prebuilt binary found for darwin-arm64". This is the gap behind `remote_native_lock_unavailable` |
694
+
695
+ The fake `ssh` exercises the client's argument construction, preflight
696
+ classification and response verification, not OpenSSH, authentication or a
697
+ real remote shell. The "no Node on PATH" results cover **only the wrapper and
698
+ launcher invocation**. In the earlier install rows, npm ran from the operator's
699
+ PATH. Only the later `npm-cli.js` row ran npm through the recorded Node with a
700
+ minimal PATH. All rows above ran on one local macOS host. **These local
701
+ stubs are not a substitute for the isolated POSIX and Windows destinations
702
+ that issue #23 requires.**
703
+
704
+ ### Live POSIX destination (F5, Linux cell)
705
+
706
+ On 2026-10-02 the workflow was run by hand on a user-provided Debian 13
707
+ x86_64 host (glibc 2.41), with Node 24.21.0 and 22.23.3 and no Node on PATH.
708
+ All work was confined to a new, dedicated test directory that was removed
709
+ afterwards; the host itself is not disposable. Host egress could not be
710
+ disabled, so offline install flags were used and nothing was downloaded on
711
+ the host. The run covered steps 1–9 and selected activation-table, lock,
712
+ receipt, rollback, retention and runtime-swap states. For the states tested,
713
+ the activation, verification, native-lock and lock outcomes matched the rules
714
+ this document had **at that time** (fifth commit of the PR), with an
715
+ operator-check order deviation noted below. This includes the documented
716
+ gaps:
717
+
718
+ - the empty-directory replacement by `rename(2)`;
719
+ - an undetected same-path Node major swap.
720
+
721
+ The details and the deviations from this workflow are in
722
+ [VALIDATION.md](../../VALIDATION.md#remote-deployment-workflow-posix-cell-23-f5--2026-10-02-kst).
723
+ Rules added afterwards remain **unvalidated, on Linux too**:
724
+ - the fresh-lock recovery of an unreceipted target;
725
+ - receipts that copy the marker's `runId`;
726
+ - `.receipts` trust checks;
727
+ - corrupt, mismatched and orphan receipt handling;
728
+ - the journal-confirmed rollback condition;
729
+ - activation-table rows that were not tested (an inconsistent marker, owned
730
+ with failing verification, a corrupt receipt).
731
+
732
+ The earlier break-lock rollback result is kept as recorded under the rule of
733
+ that date. Agreement is partial even for the rules of that time: only install
734
+ A followed the step 8 order (operator checks, then receipt, then lock
735
+ release). For installs B and S the harness wrote the receipt and released the
736
+ lock before the operator checks, and S had no dry-run. Their step 8 evidence
737
+ is therefore partial; see VALIDATION.md.
738
+
739
+ One finding applies to this document: "already provisioned" is decided only
740
+ for the name computed from the *current* runtime in step 2. An existing
741
+ directory whose recorded Node has since changed is not re-examined until the
742
+ proposed identity launcher (F6) exists.
743
+
744
+ ### Existing evidence (not re-run here)
745
+
746
+ - CI `contract` (macOS and Ubuntu, Node 22/24) and `windows-native` (Windows
747
+ x64, Node 22/24) run `npm run test:package`, which packs the tarball,
748
+ installs it into an isolated `--prefix` with `--ignore-scripts`, runs the
749
+ installed CLI (`.cmd` on Windows) and loads the native lock module. This is
750
+ the per-platform basis for steps 4–6 on Linux x64 and Windows x64.
751
+ - Windows CI drives real PowerShell and the `.cmd` launcher through an isolated
752
+ fake SSH endpoint.
753
+ - [VALIDATION.md](../../VALIDATION.md#real-tui-and-ssh-checks): a live Windows
754
+ x64 isolated prefix under the user's Temp (Node 24.16.0) passed SSH preflight
755
+ with an explicit `.cmd` `--remote-bin`; a macOS destination used a
756
+ task-owned wrapper to select Node 24 instead of PATH Node 26; a Linux
757
+ destination with Node 24.16.0 passed real SSH version negotiation. These
758
+ were manual 0.1.x-era runs, not this workflow end to end.
759
+
760
+ ### Not validated
761
+
762
+ - The full workflow against a real **Windows** SSH destination. The Linux
763
+ x86_64/glibc cell was run once (see above); other POSIX cells were not.
764
+ - Windows: upload and hashing (`Get-FileHash`), `[System.IO.Directory]::Move`
765
+ no-replace behavior, the self-locating `.cmd` wrapper (`%~dp0`), reparse
766
+ point and DACL checks, and the `%LOCALAPPDATA%` layout.
767
+ - POSIX root trust checks, `rename(2)` and `libc` detection on anything other
768
+ than the one Debian x86_64 glibc destination.
769
+ - Exercised once on the Linux x86_64 host only (with a test harness, not F6),
770
+ and not on Windows: failed-activation rollback, marker- and receipt-guarded
771
+ retention, lock contention, explicit break-lock with and without a receipt,
772
+ an unowned lock, and the per-file manifest.
773
+ - Not exercised anywhere: the explicit recovery of an unreceipted target under
774
+ a fresh lock, corrupt, mismatched or orphan receipt handling, `.receipts`
775
+ trust checks, and the operator override for unconfirmable lock owners. The
776
+ identity launcher was only compared logically (Linux) and prototyped
777
+ (macOS).
778
+ - The POSIX empty-directory race window. It is documented as unguaranteed and
779
+ was not exercised.
780
+ - Linux arm64, Windows arm64 and macOS x64 native loads; glibc below 2.28 and
781
+ musl (expected to fail).
782
+ - Node 22 destinations under this workflow on Windows, arm64 or macOS (Linux
783
+ x86_64 Node 22.23.3 was exercised).
784
+ - The compatibility contract and the proposed error codes: they are
785
+ unimplemented.
786
+
787
+ Because of these gaps, issue #23's last criterion ("validate the selected
788
+ workflow with isolated POSIX and Windows destinations") is **not** met. The
789
+ POSIX (Linux x86_64) cell of F5 is recorded. **The Windows cell is unmet.**
790
+ Local stubs do not count toward either cell.
791
+
792
+ ## Follow-ups
793
+
794
+ Proposed issues; none has been filed.
795
+
796
+ **F1. docs(ssh): document the operator provisioning workflow in the four guides**
797
+ - EN/KO/JA/zh-CN guides describe steps 1–9 with POSIX and PowerShell commands.
798
+ - States the ownership marker, never-on-PATH root and rollback rules.
799
+ - No code change; `node scripts/check-repository.mjs` passes.
800
+
801
+ **F2. feat(cli): add side-effect-free `--capabilities` and a native lock check**
802
+ - `--capabilities` prints the JSON above, never sends, opens no lock file and
803
+ prints no paths; unsupported Node/platform still produce their refusal JSON.
804
+ - `doctor` (local and SSH) adds a `nativeLock` check with
805
+ `native_lock_unavailable`.
806
+ - Tests cover loaded/missing/failed using a prefix without matching binaries,
807
+ on POSIX and Windows CI.
808
+ - Does not change SSH acceptance.
809
+
810
+ **F3. feat(ssh): classify remote runtime, Node, platform, implementation and native failures**
811
+ - Adds `remote_runtime_missing`, `remote_node_unsupported`,
812
+ `remote_platform_unsupported`, `remote_implementation_mismatch` and
813
+ `remote_native_lock_unavailable`. The last comes from the second,
814
+ message-free `--capabilities` round trip, made only after an exact banner
815
+ match and only for commands that need the lock (Codex send).
816
+ - No stderr or remote stdout is echoed; `submitted:false`; fixed exit code 1.
817
+ - PARITY and guides list the codes; fake-SSH tests for POSIX and PowerShell.
818
+
819
+ **F4. feat(ssh): observational wire/capability negotiation behind a disabled default**
820
+ - Implements the negotiation rules; exact-version remains the acceptance rule.
821
+ - Reports `remoteVersion` and `wire` on verified results.
822
+ - Legacy (0.2.x) remotes are refused exactly as today.
823
+ - Enabling acceptance by default requires a separate PR after F5 records live
824
+ mismatched-version evidence.
825
+
826
+ **F5. test(ssh): live isolated POSIX and Windows provisioning record**
827
+ - One POSIX and one Windows x64 destination provisioned by the workflow with
828
+ existing host trust; recorded in VALIDATION.md with OS, arch, Node, hashes.
829
+ - Covers:
830
+ - offline install, root trust checks, staging probe and no-replace activation;
831
+ - every target state in the activation table, including empty and foreign
832
+ directories;
833
+ - post-activation verification, `doctor --host` and `send --dry-run`;
834
+ - rollback of a failed activation and rollback to the previous directory;
835
+ - marker-guarded cleanup;
836
+ - a Node path or ABI change producing a new identity;
837
+ - with F6, a same-path runtime change refused as `install_runtime_mismatch`;
838
+ - activation-lock contention, a lock without `owner.json`, and explicit
839
+ break-lock with and without a completion receipt.
840
+ - Confirms another manager's `session-peer` remained byte-identical.
841
+
842
+ **F6. feat(cli): `session-peer deploy --host` helper with install integrity**
843
+ - Implements steps 1–9 as an explicit command with `--dry-run` showing every
844
+ remote action; refuses foreign directories; never runs during list/send.
845
+ - Keeps the operator-side run journal and writes the completion receipt.
846
+ - Writes the identity-checking `launch.mjs` (the proposed
847
+ `install_runtime_mismatch` code, mapped by the client to
848
+ `remote_install_runtime_mismatch`), the per-file manifest and the
849
+ `mkdir` activation lock with operator-only stale-lock breaking.
850
+ - Runs npm only as `<node> <npm-cli.js>` with the identity Node first on PATH.
851
+ - Separate security review before merge.
852
+
853
+ ## Review checklist
854
+
855
+ - The negotiation rules keep every released client and remote interoperable or
856
+ refused, never silently accepted.
857
+ - No step weakens host-key checking or writes outside `<root>`.
858
+ - Activation never uses `mv`/`Move-Item`. The POSIX empty-directory replacement
859
+ window is stated as unguaranteed against same-user processes that ignore the
860
+ lock.
861
+ - The marker check is not presented as tamper detection; the manifest detects
862
+ corruption, not same-user attacks.
863
+ - Install identity covers everything the native binary and wrapper depend on.
864
+ - The native coverage table matches the shipped `fs-ext-extra-prebuilt`
865
+ version whenever that dependency changes.
866
+ - Integrity values quoted here are for 0.2.1 and change with every release;
867
+ the workflow reads them from the release record rather than from this file.