Skip to content

test: review-only integration candidate for #84 + #86 + #85 (do not merge) - #88

Closed
abruption wants to merge 21 commits into
mainfrom
integration/030-candidate
Closed

abruption wants to merge 21 commits into
mainfrom
integration/030-candidate

Conversation

@abruption

@abruption abruption commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

REVIEW-ONLY INTEGRATION CANDIDATE. DO NOT MERGE. This draft exists so CI and CodeQL run on the combined changes. Each change still lands through its own PR (#84, #86, #85). This PR will be closed, not merged.

Refs #20 #21 #22

This branch combines:

It excludes #75, #79, and #83.

Commit Content
8519197 Merge commit; parents 63eec74 and 8677caf
9359f90 Multi-host and update-notice integration test
0e96c41 Review fixes: clientUpdate is client-local, the failure policy is pinned, and a Windows notice+array case is added

Conflict resolutions

Integration contracts

  • Array output. When repeated --host returns a JSON array, the array keeps request order and every element keeps its exact shape. No clientUpdate is added to elements, and no wrapper object is introduced.
  • Flat output. A flat result (local, or a single --host) gets the additive clientUpdate. This also applies when that per-host result failed or is unknown.
  • Failures and text. Top-level parse errors and local caught failures never carry the notice. Text output gets one stderr line per invocation. The advisory never changes status, exit code, submitted, consumptionConfirmed, or retryAllowed.
  • clientUpdate is client-local. Any clientUpdate in a verified receiver response is dropped. A --stdio-request receiver never reads or refreshes the cache and never produces a notice.
  • One refresh per invocation. The notice is computed at a single call site, once per invocation. The evidence is indirect: with the single-flight cache lock, the fixture registry sees one request for three hosts and zero from receivers. The call itself is not instrumented.

Type

  • feat
  • fix
  • docs
  • chore / refactor / test / perf

Validation

  • npm ci --ignore-scripts and npm run build
  • SESSION_PEER_PYTHON_ROOT=/path/to/pinned/reference npm test: 121 tests, 116 pass, 0 fail, 5 skipped. All 5 skips are Windows-only tests that are skipped on macOS; one comes from feat(ssh): support ordered multi-host commands and constrained connection options #84 (ssh-hosts).
  • npm run test:package: pass. npm audit: 0. node scripts/check-repository.mjs: OK. Release pack/artifact: validated.
  • CI (run 36977473190) and CodeQL (run 36977470835) passed on 0e96c41, including windows-native 22/24, where the Windows SSH subtest that holds the new notice case passed
  • Behavior changes include relevant tests; refused/unknown/queued/ACK remain distinct
  • Guides are updated in EN/KO/JA/zh-CN; README is unchanged
  • No credentials, real messages, session IDs, agent homes or local evidence in the diff

New tests in test/integration-multihost-updates.test.ts (4 tests; POSIX fake ssh, local fixture registry, temp caches):

  • Array shape is identical to the opt-out run; text has one stderr line; a flat single host carries the field.
  • One registry request per invocation for three hosts; receivers never create their cache.
  • Failure policy: a single-host preflight failure has the same status and exit code plus the field. A mixed array is unchanged, with one stderr line. Parse and local refusals never carry it.
  • A forged remote clientUpdate is dropped: no key in array elements, no key with --no-update-notice, and the flat result shows only the locally computed value.

Tested environments / limitations

  • Run locally on macOS arm64 with Node 24.16.0.
  • Windows: test/windows-contract.test.ts adds one opted-in case through the encoded PowerShell fake SSH: a repeated --host array with no element field, one text stderr line, and a flat single-host field. The refresh count, the failure policy, and the forged-field cases are covered only on POSIX and are unverified on Windows.
  • POSIX results are not Windows evidence.

Release impact

None. This is a review-only candidate. It must not be merged, published, or used to retarget other PRs.

…tion options

Accept repeated --host for list, send and doctor. One host keeps the flat
result; several return an ordered array whose elements keep schemaVersion,
ok, host and command. Each destination gets one preflight and at most one
request, and a refused or unknown host never triggers a retry or failover.

Validate every host, option and message before any ssh process starts and
refuse duplicate destinations. Add an allowlisted --ssh-opt (-p, -l, -i,
-o Port/User/IdentityFile/IdentitiesOnly, -4, -6) re-emitted after the fixed
BatchMode/StrictHostKeyChecking options; ProxyJump and every other option
are refused. Accept bare and bracketed IPv6 literals and report
sshUser/sshUserSource like Python.

Closes #20
Add `session-peer update --check`, which reads the npm dist-tags for
session-peer (latest by default, or preview) with one bounded request and
reports current/latest/channel/source plus a package-manager-specific upgrade
command derived from the resolved CLI path. `update` without --check never
replaces npm-owned files and refuses with self_update_unsupported and guidance.
Update is local only: --host and the SSH wire are refused.

Cached client notices on list/send/doctor are opt-in via
SESSION_PEER_UPDATE_NOTICE and honor --no-update-notice and
SESSION_PEER_NO_UPDATE_NOTICE. The cache is private and atomic, refreshes run
once in a detached single-flight child with a 3 s timeout, failures back off,
and notices never change results, exit codes or wire responses.

Refs #22
…ust boundaries

Collect --host values before other validation so any pre-dispatch refusal
with two or more hosts, including unknown options and missing values, is a
per-host array; fewer hosts stay one flat object. Keep the user lookup inside
per-host handling so a lookup failure leaves other results intact.

Document that sshUser runs a bounded local ssh -G which evaluates the user's
ssh configuration, separate the command-line allowlist from trusted user
configuration, state that duplicate detection is syntactic, keep typed jump
routing visible as open, and describe the lost-response fixture as an
unknown classification case.
Emit an upgrade command only for a positively identified owner: an npm global
prefix whose own launcher targets this package (default, Homebrew, nvm,
nvm-windows, fnm), pnpm/Yarn/Bun global stores whose manifest declares
session-peer, Volta or npx. Project installs, source checkouts and unknown
layouts get no command and a guidance sentence instead.

The refresh lock now holds a per-acquisition token inherited by the detached
child. Release and stale takeover run under a short O_EXCL mutex and re-read
the token, so a foreign generation is never deleted, and a takeover renames a
new lock over the exact stale generation so only one taker can win.

Document opt-out as suppressing background notices only, and that the local
client adds its notice to results obtained over SSH while a --stdio-request
receiver never produces one.
Background cache publication now runs under the takeover mutex and only while
the worker's token is the current lock generation, and never replaces a cache
record written after the refresh started. A refresh without a token does
nothing. The mutex is itself token-owned; releasing it or reclaiming a stale
one renames the file aside, keeps it only if it is the holder's token or the
exact inode and mtime judged stale, and otherwise restores it with link().

Add `guidance` to the documented clientUpdate fields and report "no update
needed" guidance for up_to_date/ahead results.
…oxyCommand

Route every SSH call for every --host through one jump host given as
USER@HOST[:PORT]. Instead of -J, whose hop receives no command-line
BatchMode or StrictHostKeyChecking, build a fixed ProxyCommand: the
shell-quoted and %-escaped ssh path with batch mode, strict host keys, no
host-key updates, bounded connection attempts, no further proxy, control
socket, agent or port forwarding, and no local command, then -W to the
target. Validate the hop strictly, refuse it with --ssh-control-path and on
Windows clients, report sshJump, and keep -J/ProxyJump/ProxyCommand refused
in --ssh-opt.
With --ssh-jump, also fix ControlMaster=no, ControlPath=none and
ProxyUseFdpass=no on the outer ssh before user options, so an existing master
or fd-passing setting in ssh_config cannot skip or alter the hop. Verified
with ssh -G against a fixture configuration.
…he writes

Remove stale-lock takeover and the takeover mutex. A single O_EXCL lock with a
random token now guards every cache write: the background refresh inherits the
token from the invocation that created it, and an explicit `update --check`
acquires the same lock around its write. Writers replace only records older
than their own start. No code path moves or deletes a lock it did not create;
an existing lock of any age skips the background refresh, and `update --check`
reports why the cache was not written (new `cache` field). A crashed holder's
lock must be removed by hand, as documented.
On POSIX, start every external command in its own process group. A timeout,
an output overflow or SIGINT/SIGTERM/SIGHUP to the CLI kills that group,
including a jump ProxyCommand that keeps the pipes open, and the call
completes after the exit plus a short grace instead of waiting for the pipes.
On Windows only the child is killed and the call returns at the deadline.
Timeout classification is unchanged. Document the verified ProxyCommand
shells and that --ssh-opt values are not passed to the jump hop.

Closes #87
If writing the token fails right after the O_EXCL create, remove only that
same inode before rethrowing. Report an unverifiable lock during an explicit
check as `cache: "failed"` instead of the internal `not_owner`. Keep
writeCache internal, narrow the PARITY guarantee to foreign locks, temporary
files and resources, and document that manual lock removal can also follow
I/O or release failures.
Register a detached child's group synchronously when spawn() returns a PID,
keeping the spawn event as a fallback, so a signal that arrives before that
event still reaps the group. Document that detached children run in a new
session without a controlling terminal and that cleanup covers that group
only.
…diagnostics

Detect the sender from bounded evidence: the inherited inbox socket variable
must match exactly one live registered session, and the Codex thread/session
variable must be a valid UUID. Nested, conflicting or absent evidence gives no
identity. Generate inert session-peer://v1/reply routes with host precedence
--reply-to, SESSION_PEER_REPLY_HOST, CC_PEER_REPLY_HOST, then the tailnet
address, and report replyRoute/addressResolution like the Python reference.

Use tailscale status only as a routing hint with exact Online states: keep
the SSH alias, add HostName for known online peers and HostKeyAlias only when
ssh_config sets none, refuse known offline or ambiguous peers before SSH, and
leave everything else as ordinary SSH. Normalize a reply URI to local only for
this user on this machine. Add doctor --check-return-route as an explicit,
bounded, noninteractive reverse SSH probe that stays bound to the origin and
is never inferred from forward reachability.

Closes #21
…eiver names from the login user

Treat every numeric IPv4 form accepted by inet_aton (127.1, 2130706433,
0x7f.1, 0177.0.0.1, 0) and IPv4-mapped or compatible IPv6 as loopback or
unspecified, without DNS. Decide whether a host names the receiver with a
helper that ignores the login user, so an unusable local username cannot
turn the receiver's own host name into a verified remote route.
A jump host implies SSH, so a reply URI naming this user on this machine is
normalized to a local route only when neither --host, an SSH option nor
--ssh-jump was given.
Split the host predicates. Return and reply hosts that might name a machine
are refused without guessing resolver behavior: localhost names, canonical
loopback and unspecified addresses, their mapped forms, IPv4-compatible IPv6
and every non-canonical numeric form. Local normalization accepts only exact
localhost, canonical 127.x.y.z, ::1 and canonical mapped loopback, never a
non-canonical numeric or an IPv4-compatible address.
State that the receiver refuses a known self name or an unprovable numeric
form, that known names are only the exact OS host name and Tailscale self
names and addresses, and that remote sends refuse loopback and non-canonical
numeric reply hosts. Add regressions for a private return host and for an
unusable login name.
Conflict resolutions keep each change's semantics:
- src/cli.ts: #84/#86 parsing, repeated --host and reply routing are kept;
  `update`, `--check` and `--channel` are added. `update` refuses --host and
  --ssh-opt and is refused over the wire. The notice hook runs once per
  invocation and adds `clientUpdate` only to a flat result; a repeated
  --host JSON array keeps its exact shape, and text output gets one stderr line.
  The failure envelope still spreads update guidance.
- src/help.ts, src/output.ts: both help texts and both render branches.
- package.json, scripts/release.mjs, test/package-smoke.ts: union of test
  lists and packaged files (replies, ssh, updates).
- PARITY.md and guides: both sections; the update notice scope documents the
  multi-host array contract.
Drop any clientUpdate supplied by a remote receiver before a verified SSH
response is shown. Document that a flat per-host result, including a failed or
unknown one, may carry the advisory while top-level parse and local caught
failures never do, and that the advisory never changes status, exit code or
retry decisions. Add POSIX regressions for the failure policy and a forged
remote field, and a Windows fake-SSH case for the notice with a repeated
--host array.
@abruption

Copy link
Copy Markdown
Owner Author

Closing without merging: this review-only integration candidate (head 448be73dd5193e9a836d92dc22c978dc7fbd64d9) was ported into #85. On #85 head efe4bbbca45a59b90446f6b56c5a687ad8f35d90, git diff 448be73..efe4bbb contains exactly the #79 change (VALIDATION.md, src/windows.ts, test/windows-inspection.test.ts), byte-identical to the #79 patch, and no other tree difference. #85 passed CI and CodeQL on that head and was merged as 64b98b93ce7c04009f18257ec02b1c84c0fe1c48.

@abruption abruption closed this Oct 3, 2026
@abruption
abruption deleted the integration/030-candidate 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant