Skip to content

feat(fleet): implement the SSH leg of the laptop-agent ladder (#10796) - #12795

Open
dezren39 wants to merge 2 commits into
mainfrom
xaltha/10796-ssh-leg
Open

dezren39 wants to merge 2 commits into
mainfrom
xaltha/10796-ssh-leg

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Refs #10796

What this is

The SSH leg of the fleet binary's laptop-agent ladder — the last of the four legs (broker → Cloudflare → Tailscale → SSH) to land as real code. PR #11122 merged the domain with the SSH leg as a named stub; this PR replaces the stub in pkgs/fleet/crates/fleet-laptop-agent/src/legs.rs with the implementation that was proven live in the 2026-11-17 parity shift (forced-leg-down harness: health and exec answered by SSH after broker, Cloudflare, and Tailscale were made to fail; evidence recorded on #10796).

The SshLeg shells out to the laptop-ssh script with the Python client's fallback semantics: the request is flattened into a remote shell program (ssh_inner + sh_quote), job paths are validated through job_segment, replies are size-capped (cap_tail), and fetch payloads ride base64 (b64_decode). The leg reports Absent when the script is missing, so the ladder degrades exactly as it does for a missing broker socket.

Recovery fix (second commit)

The recovered commit 75ddb67ef carried the leg's tests and call sites but not the helper definitions they use — the crate did not compile (20 errors: json_reply, sh_quote, ssh_inner, query_u64, job_segment, cap_tail, b64_decode, find_subslice all undefined). Commit f1f3678ae restores that section verbatim from the proven staged implementation preserved in the parity shift's laptop worktree, reformatted with cargo fmt. No behaviour change beyond compiling as intended.

Verification (laptop, this branch)

  • cargo test -p fleet-laptop-agent (from pkgs/fleet): 24 passed, 0 failed — including the six SSH-leg tests: sh_quote_matches_shlex, ssh_inner_flattens_env_cwd_and_argv, b64_decode_round_trips_and_tolerates_noise, ssh_leg_is_absent_without_the_script, ssh_leg_carries_no_other_surfaces, ssh_health_answers_through_a_fake_script.
  • cargo fmt -p fleet-laptop-agent -- --check: clean.
  • Clippy: not run — the laptop's rustup has no clippy component configured (rustup could not choose a version of cargo-clippy), so CI is the first clippy run. This is a pre-existing laptop toolchain gap, unrelated to this change.

Scope / follow-ups


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

dezren39 and others added 2 commits November 22, 2026 21:55
Replace the named SshLeg stub with the full leg, mirroring the Python
client's SSH fallback (code#2879): gate on LAPTOP_AGENT_NO_SSH_FALLBACK
and ~/tools/laptop-ssh-real.sh, run the daemon's request surface over
real SSH (health synthesised from /proc, exec/run/poll/kill/jobs with
sshfb- ids spooled under ~/.local/state/laptop-agent/sshfb-jobs/),
magic-line proof that the remote shell started, per-op timeouts
(exec timeout_s+15, poll 60s, others 30s), 1 MiB/stream tail cap, and
the process-group kill on local timeout.

The implementation recovers the staged, test-green SSH leg from the
2026-11-17 parity shift on PR #11122 (queue/20682-muse-send worktree),
which was never committed before that PR merged; the only change here
is a saturating_add for the exec timeout so an absurd timeout_s cannot
overflow. Other paths (incl. /file) stay Absent.

Refs #10796
…overy

The recovered commit 75ddb67 carried the SshLeg tests and call sites
but not the helper definitions they use (job_segment, json_reply,
find_subslice, query_u64, cap_tail, sh_quote, ssh_inner, b64_decode),
so the crate did not compile. The definitions are restored verbatim
from the proven staged implementation preserved in the queue-20682
laptop worktree (live parity proofs recorded on #10796), reformatted
with cargo fmt. No behaviour change beyond compiling as intended.
@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 03:03
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fb78281f-92d0-4dc4-8d54-ab38a32c790f
Commits

Reviewing files that changed from the base of the PR and between f8e14e0 and f1f3678.

Files selected for processing: 1

  • pkgs/fleet/crates/fleet-laptop-agent/src/legs.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant