Skip to content

docs(ssh): propose Python-free remote deployment and compatibility contract - #83

Merged
abruption merged 1 commit into
mainfrom
docs/23-remote-deployment
Oct 3, 2026
Merged

abruption merged 1 commit into
mainfrom
docs/23-remote-deployment

Conversation

@abruption

@abruption abruption commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Current status (latest)

The sections below are history from earlier checkpoints.

Part of #23. Adds a design-only ADR, docs/design/remote-deployment.md (Status: Proposed), for Python-free remote deployment and version compatibility. Nothing is implemented and SSH behavior is unchanged.

  • Options compared: (a) npm install on each destination, (b) operator-invoked isolated artifact provisioning, (c) a portable bundle or single-executable build. The comparison covers native prebuild coverage ([email protected] ships darwin/linux/win32 x64/arm64 for Node 20–25 inside its tarball; glibc 2.28+, no musl), the npm launcher's PATH Node problem, offline use, integrity and ownership.
  • Decision: (b) is selected. It reuses the published tarball and the locked dependency tarballs, verifies registry integrity, SHA-256, provenance and signatures, uploads over existing SSH trust, and installs offline into a private versioned directory that is never on PATH. That directory gets an ownership marker and a wrapper with an absolute Node path. (a) stays as an unpinned alternative. (c) is rejected for now.
  • Compatibility contract: a wire version and additive capabilities, separate from package SemVer, plus a proposed side-effect-free --capabilities preflight. --version still runs first and an exact match is still accepted. Exact-version refusal stays the only acceptance rule until the follow-ups are implemented and live mismatched-version evidence is recorded.
  • Errors: existing codes are mapped. New codes are proposed: remote_runtime_missing, remote_node_unsupported, remote_platform_unsupported, remote_implementation_mismatch, remote_protocol_incompatible, remote_capability_missing and remote_native_lock_unavailable. Each has an operator message.
  • Operator workflow: 8 steps with integrity checks, ownership rules (never touch Python/pipx/global npm installs or PATH), atomic activation, cleanup and rollback.
  • Non-goals: no implicit install during list/send/doctor, no Python fallback, no host-key relaxation, no overwriting another manager's executable.
  • Follow-ups F1–F6: proposed in the doc. No issues were filed.
  • Links: short localized paragraphs in the EN/KO/JA/zh-CN guides, plus the PARITY SSH and remote-prerequisite rows.
  • Packaging: the ADR ships with the package docs, so relative links from the shipped guides and PARITY still resolve. packageFiles, the package smoke list and the repository link check were updated.

Review fixes (second commit)

  • A. The probe now tests the new install. The wrapper locates its install relative to its own path (POSIX $0 with pwd -P, Windows %~dp0). Step 6 probes the staging install directly, including the native lock resolved from staging. Step 8 adds a mandatory post-activation check: wrapper banner, native probe, marker hash, and a real directory with no symlink. Callers switch only in step 9.
  • B. Activation is a no-replace rename. Activation uses fs.renameSync (rename(2)) on POSIX, after lstat(target) returns ENOENT, and [System.IO.Directory]::Move on Windows. mv, mv -n and Move-Item are explicitly excluded because they nest into an existing directory (reproduced locally with BSD mv). rename(2) replacing an empty directory is documented and guarded. A table defines the outcome per target state: absent, same identity and verified, same identity but failing verification, mismatched hash, different identity, foreign, empty directory, and leftover staging. Rollback of a failed activation is defined.
  • C. Runtime identity is part of the install identity. Directories are <version>-<id16>, a hash over package SHA-256, the release lockfile's dependency integrity, platform, arch, libc, Node major, ABI and the Node realpath. Installs are immutable; any identity change creates a new directory beside the old one.
  • Recommended items:
    • root trust checks: POSIX ancestor lstat, owner and mode; Windows reparse points, owner and DACL;
    • dependency integrity and provenance pinned to the release's exact source commit (0.2.1: a9c42334…, verified locally);
    • preflight round trips reconciled: one, or two for Codex send once F2/F3 ship, never more than two;
    • PARITY.md added to the repository link check (passes).

Review fixes (third commit)

  1. Runtime drift. A same-path Node 22→24 change is now stated as undetected today: the CLI accepts both majors and the loader picks the new binary. A proposed identity-checking launch.mjs would compare the realpath, major, ABI, platform and arch with the marker and refuse with the proposed install_runtime_mismatch (mapped by the client to remote_install_runtime_mismatch, F6). <node> is defined as identity.node, the realpath.
  2. npm invocation. Step 4 runs <node> <npm-cli.js realpath> install … with dirname(<node>) first on PATH. The npm path and version are recorded in step 2, and the run refuses if that npm is absent. The validation notes now say the "no Node on PATH" checks covered only the wrapper.
  3. Activation lock and scope. A cooperative mkdir activation lock is held from lstat through verification. A stale lock is broken only by an explicit operator command, which first rolls back the stale run's unverified target. The guarantee scope is stated: on POSIX, a same-user process that ignores the lock can still have an empty directory replaced (closing that window needs renameat2/renamex_np, out of scope). The marker check is no longer called tamper detection. A per-file SHA-256 manifest now detects corruption and partial installs, but it is not a boundary against a same-user attacker.
  4. F5 stays unmet. Live isolated POSIX and Windows destinations have not been tested, and local stubs do not count toward it.

Also validated locally: npm run via the recorded Node with a minimal PATH; a prototype identity launcher that passes when the identity matches and returns install_runtime_mismatch with exit 2 after the marker was edited; activation lock exclusivity (EEXIST).

Review fixes (fourth commit, documentation only)

  1. Where the run lives. A provisioning run lives on the operator side. Each SSH step is a short-lived remote process, so a remote PID or start time is never used to judge a lock. owner.json holds the runId, an opaque operator label and the creation time; the operator keeps a local run journal. A lock without owner.json, with an unreadable one, or whose owning operator run cannot be confirmed is never judged stale. Only the owning run or an explicit operator break-lock releases it.
  2. Completion receipt. <root>/.receipts/<install-name>.json is written only after every step 8 check passes, and before the lock is released. Break-lock with a matching receipt removes only the lock. Without a receipt it conservatively rolls the target back. An owned target without a receipt is refused rather than reported as "already provisioned".
  3. Complete marker example. The marker example now shows every field: markerVersion, runId, manifestSha256 and provenance (source commit, registry integrity, npm-cli path and version), plus stagedAt. These fields are separate from the identity hash.

No runtime work was done, and F5 (live isolated POSIX and Windows destinations) remains unmet.

Live Linux cell of F5 (fifth commit)

  • What ran: the ADR workflow, by hand, on a user-provided Debian 13 x86_64 (glibc 2.41) host with no Node on PATH. All work was confined to a new, dedicated test directory that was removed afterwards; the host itself is not disposable, using official Node 24.21.0 and 22.23.3 runtimes uploaded by the operator. The redacted record is in VALIDATION.md ("Remote deployment workflow, POSIX cell").
  • Results: step 1 integrity was pinned to a9c42334. Installs ran offline as <node> <npm-cli.js>. Staging and post-activation checks passed. Operator doctor --host returned ok:true, and send --dry-run returned no_reachable_target with submitted:false.
  • Cases exercised: same identity, foreign and empty targets, rename(2) semantics, a Python-style stub (byte-identical before and after), lock contention, a failed-activation rollback, break-lock with and without a receipt, an unowned lock, the same-path Node 24→22 swap (undetected, as documented), rollback to a previous directory, and receipt-guarded retention. The test root was deleted afterwards.
  • Deviations: host egress could not be disabled, so offline install flags were used and nothing was downloaded on the host; the Node SHASUMS256.txt GPG signature was not checked; a test-only isolation shim kept CLI discovery inside the test root; a test harness, not the F6 helper, drove the steps.
  • New ADR note: "already provisioned" is decided only for the name computed from the current runtime.
  • Still Part of design(ssh): define Python-free remote deployment and version compatibility #23: the Windows cell of F5 is unmet. arm64, musl and macOS destinations are also not covered.

Review fixes (sixth and seventh commits, documentation only)

  • Host wording: the Linux host is described as user-provided, not disposable. All work was confined to a new, dedicated test directory that was removed afterwards. Host egress could not be disabled, so offline install flags were used and nothing was downloaded on the host.
  • Unreceipted installs: an explicit, marker-guarded recovery now runs under a fresh activation lock, whether or not a prior lock exists. It first checks that no caller uses the target, then either re-verifies (and writes a new receipt) or rolls back. A missing receipt means verification is insufficient, not that the run never finished.
  • .receipts trust: the directory and each receipt are checked with lstat (no symlink or reparse point, owner, mode or DACL) before any write or delete.
  • Receipt matching: a receipt matches only if runId, identityHash and manifestSha256 all equal the install's values. Corrupt, mismatched or orphan receipts are refused, and cleaned up only explicitly after ownership is confirmed. "Already provisioned" reuses the existing receipt.
  • Order: publish the receipt, then release the lock, then switch callers. The operator override for a lock with no confirmable owner only removes the lock.
  • Validation lists: the "Not validated" list now matches the Linux live record and names what remains unexercised: the Windows cell, and the new recovery and receipt rules.

Type

  • feat
  • fix
  • docs
  • chore / refactor / test / perf (package file list and link check only)

Validation

  • npm ci --ignore-scripts and npm run build
  • SESSION_PEER_PYTHON_ROOT=/path/to/pinned/reference npm test (77 tests: 73 pass, 0 fail, the rest skipped by platform)
  • npm run test:package and npm audit (0 vulnerabilities); node scripts/check-repository.mjs; node scripts/release.mjs pack && node scripts/release.mjs artifact
  • Latest CI release gate passes with an up-to-date base
  • Behavior changes include relevant tests; refused/unknown/queued/ACK remain distinct (no behavior change)
  • README changes are synchronized in EN/KO/JA/zh-CN (README files were not changed; the four guides were updated together)
  • No credentials, real messages, session IDs, agent homes or local evidence in the diff

Tested environments / limitations

These local checks ran on macOS arm64 with Node 24.16.0 and npm 11.15.0. No network destination was contacted; the only network use was registry reads.

  • The [email protected] published tarball's SHA-256 and integrity match the 0.2.1 release record. The fs-ext-extra-prebuilt and nan tarballs match package-lock.json.
  • An offline npm install --prefix ... --offline --ignore-scripts with an empty cache succeeded. A wrapper with an absolute Node path printed --version with no Node on PATH. list and doctor passed with an empty HOME, and the native flock load passed.
  • SSH preflight was exercised through a local ssh stand-in:
    • exact match: success;
    • Python-like banner: remote_version_mismatch;
    • missing executable: remote_cli_missing;
    • Node missing on remote PATH: remote_cli_missing (this is the gap);
    • simulated unsupported Node: ssh_preflight_failed (this is the gap);
    • simulated missing prebuild: --version passes but the native import fails (this is the gap).

Also validated locally after the review fixes:

  • staging probe with no final directory present;
  • renameSync activation, then post-activation banner, native and marker checks;
  • doctor --host through the ssh stand-in;
  • ENOTEMPTY on a second activation;
  • the rename and mv semantics matrix.

These local stubs on one macOS host are not a substitute for the isolated POSIX and Windows destinations that #23 requires.

Not validated:

  • the full workflow against any real POSIX or Windows SSH destination;
  • Windows upload, hashing and the .cmd wrapper;
  • Windows Directory.Move, the %~dp0 wrapper, and the reparse-point and DACL checks;
  • POSIX root trust checks and GNU/Linux rename on a real destination;
  • Linux arm64, Windows arm64 and macOS x64 native loads;
  • Node 22 destinations under this workflow.

The contract and the new error codes are unimplemented. Existing CI package-smoke runs (macOS, Ubuntu and Windows x64 on Node 22/24) and earlier manual live SSH records are cited as evidence; they were not re-run as new live tests. Because of this, issue #23's isolated POSIX/Windows validation criterion remains open. The doc carries it as follow-up F5, which is why this PR uses "Part of" rather than "Closes".

Release impact

There is no runtime, schema or native dependency change, and no automatic release or deployment. The next package tarball gains one documentation file, docs/design/remote-deployment.md.

@abruption abruption added the documentation Improvements or additions to documentation label Oct 2, 2026
…ntract

Add an ADR selecting operator-invoked isolated artifact provisioning over
per-destination npm installs and a portable bundle. It defines an identity-
scoped, immutable install layout with a self-locating wrapper, integrity
pinned to the release commit, a no-replace activation under a cooperative
operator-side lock, completion receipts and marker-guarded recovery,
cleanup and rollback. It also proposes a wire and capability contract
separate from package SemVer while keeping exact-version refusal, plus
actionable remote runtime, Node, platform and native-lock error codes.

Record the live Linux cell of the validation in VALIDATION.md with its
deviations; the Windows cell remains open. Link the ADR from the four guides
and PARITY, ship it with the package docs and link-check it.
@abruption
abruption force-pushed the docs/23-remote-deployment branch from 31ad151 to 8efc77b Compare October 3, 2026 03:07
@abruption
abruption merged commit b910cca into main Oct 3, 2026
12 checks passed
@abruption abruption mentioned this pull request Oct 3, 2026
8 of 11 tasks
@abruption
abruption deleted the docs/23-remote-deployment branch October 3, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant