Skip to content

fix: preserve login identity in remote job environments - #8383

Merged
kunchenguid merged 5 commits into
kunchenguid:mainfrom
m-moravcik:fm/pub-fm-remote-job-user-env-20261112
Nov 13, 2026
Merged

kunchenguid merged 5 commits into
kunchenguid:mainfrom
m-moravcik:fm/pub-fm-remote-job-user-env-20261112

Conversation

@m-moravcik

@m-moravcik m-moravcik commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Separate upstream PR: bin/fm-remote-job-lib.sh starts the remote child with env -i and does not pass USER/LOGNAME, so on macOS the remote claude auth status reports not signed in and an fm-on relaunch of a remote mate fails (reproduced 2026-11-12 ~07:4x with the psm moniviox-psm relaunch). Approved upstream contribution limited to this change; no extra widening. Preserve work, no token exposure.

What Changed

  • Pass nonempty USER and LOGNAME from the remote worker to its isolated child environment to fix macOS credential lookups during remote mate relaunches.
  • Document the shared child environment contract and add regression coverage for identity propagation, unset identity variables, and ambient secret isolation.

Risk Assessment

✅ Low: A small, tightly scoped change: the worker passes only USER and LOGNAME to the job, and only when they are set and not empty; no secrets cross over, and tests cover both the set and the unset case.

Testing

Izolované vykonanie skutočného workeru potvrdilo opravu identity, čisté prostredie a zachovanie vstupov aj výsledkov. Dôkazy sú uložené, procesy skončili a zdroje ostali nezmenené. Celkový výsledok obmedzuje už akceptovaná medzera v overení vzdialeného relaunchu.

  • Live validation: ⚠️ inconclusive - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Lokálna vzdialená úloha dostane nezmenené syntetické USER a LOGNAME ✅ pass live identity-transcript.log: baseline, set
Chýbajúca alebo prázdna identita sa nevymyslí a samostatná hodnota ostane doslovná ✅ pass live identity-transcript.log: absent, empty, user-only, logname-only
Pridanie identity neprepustí syntetické tajomstvo a zachová prenos úlohy ✅ pass live identity-transcript.log: všetky prípady
Vzdialený fm-on relaunch uspeje s existujúcim prihlásením Claude ⏸️ untested no Claude CLI je dostupné a jeho skutočný auth status potvrdil existujúce prihlásenie. Izolovaná fronta však používa disposable účet bez prihlasovacích údajov. Úplný relaunch vyžaduje autorizovaný vzdial…
Evidence: Výstupy pôvodného a opraveného vzdialeného spúšťača

CASE baseline
USER=<unset>
LOGNAME=<unset>
secret=
active=1
arg=two words $(never-executed)
stdin=preserved input
probe-stderr
exit=17

CASE set
USER=synthetic-user
LOGNAME=synthetic-login
secret=
active=1
arg=two words $(never-executed)
stdin=preserved input
probe-stderr
exit=17

CASE absent
USER=<unset>
LOGNAME=<unset>
secret=
active=1
arg=two words $(never-executed)
stdin=preserved input
probe-stderr
exit=17

CASE empty
USER=<unset>
LOGNAME=<unset>
secret=
active=1
arg=two words $(never-executed)
stdin=preserved input
probe-stderr
exit=17

CASE user-only
USER=odd user $(literal)
LOGNAME=<unset>
secret=
active=1
arg=two words $(never-executed)
stdin=preserved input
probe-stderr
exit=17

CASE logname-only
USER=<unset>
LOGNAME=odd login ; literal
secret=
active=1
arg=two words $(never-executed)
stdin=preserved input
probe-stderr
exit=17

All worker invocations completed synchronously. Fixture retained as evidence.
Evidence: Reprodukovateľný izolovaný test
#!/bin/bash
set -euo pipefail
ROOT=$PWD
EVIDENCE=~/.no-mistakes/evidence/01M78TZFN5ZR5MPBXCK7B34DBS
FIXTURE=$(mktemp -d "$ROOT/.identity-live.XXXXXX")
trap 'mv "$FIXTURE" "$EVIDENCE/identity-fixture"' EXIT
mkdir -p "$FIXTURE/root/bin" "$FIXTURE/account" "$FIXTURE/home"
cp AGENTS.md "$FIXTURE/root/AGENTS.md"
cp bin/fm-remote-job-lib.sh bin/fm-remote-job-worker.sh "$FIXTURE/root/bin/"
git show bf0f34680a7618aa5baf36464fe77530fa79fa23:bin/fm-remote-job-worker.sh > "$FIXTURE/root/bin/fm-remote-job-baseline.sh"
chmod +x "$FIXTURE/root/bin/fm-remote-job-baseline.sh"
cat > "$FIXTURE/root/bin/fm-identity-probe.sh" <<'SH'
#!/bin/bash
set -eu
printf 'USER=%s\nLOGNAME=%s\n' "${USER-<unset>}" "${LOGNAME-<unset>}"
printf 'secret=%s\n' "${TOP_SECRET+present}"
printf 'active=%s\n' "$FM_REMOTE_JOB_ACTIVE"
printf 'arg=%s\n' "$1"
IFS= read -r line
printf 'stdin=%s\n' "$line"
printf 'probe-stderr\n' >&2
exit 17
SH
chmod +x "$FIXTURE/root/bin/fm-identity-probe.sh"
git -C "$FIXTURE/root" init -q
git -C "$FIXTURE/root" add AGENTS.md bin
export FM_ROOT_OVERRIDE="$FIXTURE/root" FM_REMOTE_JOB_QUEUE_TIMEOUT=60 FM_REMOTE_JOB_TIMEOUT=15
. "$ROOT/bin/fm-remote-job-lib.sh"
run_case() {
  local label=$1 worker=$2 expected_user=$3 expected_logname=$4
  shift 4
  export FM_REMOTE_JOB_STATE_ROOT="$FIXTURE/$label-state"
  printf 'preserved input\n' | fm_remote_job_stage "$FIXTURE/account" "$FIXTURE/root" "$FIXTURE/home" fm-identity-probe.sh 'two words $(never-executed)' > "$FIXTURE/$label-stage.out"
  local job
  job=$(cat "$FIXTURE/$label-stage.out")
  # Stage's public output is a job id; no inherited shell variables required.
  env -u USER -u LOGNAME "$@" TOP_SECRET=synthetic-canary HOME="$FIXTURE/account" "$FIXTURE/root/bin/$worker" --lane "$job"
  fm_remote_job_wait "$FIXTURE/account" "$job"
  printf '\nCASE %s\n' "$label"
  cat "$FM_REMOTE_JOB_STDOUT"
  cat "$FM_REMOTE_JOB_STDERR"
  printf 'exit=%s\n' "$FM_REMOTE_JOB_EXIT"
  [ "$FM_REMOTE_JOB_EXIT" = 17 ]
  diff -u <(printf 'USER=%s\nLOGNAME=%s\nsecret=\nactive=1\narg=two words $(never-executed)\nstdin=preserved input\n' "$expected_user" "$expected_logname") "$FM_REMOTE_JOB_STDOUT"
  diff -u <(printf 'probe-stderr\n') "$FM_REMOTE_JOB_STDERR"
}
run_case baseline fm-remote-job-baseline.sh '<unset>' '<unset>' USER=synthetic-user LOGNAME=synthetic-login
run_case set fm-remote-job-worker.sh 'synthetic-user' 'synthetic-login' USER=synthetic-user LOGNAME=synthetic-login
run_case absent fm-remote-job-worker.sh '<unset>' '<unset>'
run_case empty fm-remote-job-worker.sh '<unset>' '<unset>' USER= LOGNAME=
run_case user-only fm-remote-job-worker.sh 'odd user $(literal)' '<unset>' 'USER=odd user $(literal)'
run_case logname-only fm-remote-job-worker.sh '<unset>' 'odd login ; literal' 'LOGNAME=odd login ; literal'
printf '\nAll worker invocations completed synchronously. Fixture retained as evidence.\n'
Evidence: Redigovaný stav existujúceho prihlásenia Claude
{
  "command": "claude auth status (existing login, no credential changes)",
  "exit": 0,
  "loggedIn": true,
  "authMethod": "claude.ai"
}
  • Outcome: ⚠️ 1 warning across 1 run (3m17s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (3 of 4 scenarios were driven live against the product); untested: Vzdialený fm-on relaunch uspeje s existujúcim prihlásením Claude
  • Live validation: ⚠️ inconclusive - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Lokálna vzdialená úloha dostane nezmenené syntetické USER a LOGNAME ✅ pass live identity-transcript.log: baseline, set
Chýbajúca alebo prázdna identita sa nevymyslí a samostatná hodnota ostane doslovná ✅ pass live identity-transcript.log: absent, empty, user-only, logname-only
Pridanie identity neprepustí syntetické tajomstvo a zachová prenos úlohy ✅ pass live identity-transcript.log: všetky prípady
Vzdialený fm-on relaunch uspeje s existujúcim prihlásením Claude ⏸️ untested no Claude CLI je dostupné a jeho skutočný auth status potvrdil existujúce prihlásenie. Izolovaná fronta však používa disposable účet bez prihlasovacích údajov. Úplný relaunch vyžaduje autorizovaný vzdial…
  • git diff bf0f34680a7618aa5baf36464fe77530fa79fa23 0341f044f0052e4fe58b297f47b999ef07f7c3e9
  • bash ~/.no-mistakes/evidence/01M78TZFN5ZR5MPBXCK7B34DBS/identity-driver.sh - skutočné stage, worker --lane a wait pre pôvodnú verziu a päť hraničných konfigurácií
  • claude auth status - uložené iba návratový kód, loggedIn a authMethod
  • git status --short a kontrola procesov disposable testu - čistý pracovný strom, žiadny zostávajúci worker
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Reviews (2) · Last reviewed commit: "no-mistakes(document): Spresniť odkazy n..." · Reviewed by Greptile

@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 12, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @m-moravcik. I've queued the full suite (full-ci) on d53c131e. I read the whole change: the remote worker's env -i child now also gets USER and LOGNAME when they're set and non-empty, never invented and never empty, and ambient variables still stay out (the test checks that a planted secret is still absent). The no-mistakes attestation binds this head with no skipped steps. The coverage guard and repo invariants pass, Greptile is 5/5, there are no open threads, and it merges cleanly with current main a9ae3c0c. Live validation drove the real worker (stage, --lane, wait, reap) through every identity case. The end-to-end relaunch with a real Claude login is the only part left untested, and it was reasonable not to copy credentials into a throwaway account to test it.

Contract class (my own read): restore. Remote mates on macOS with Claude are a documented supported path (docs/remote-secondmates.md), and the isolated child lost the login identity that Claude's credential lookup needs. VISION.md: every rule aligns. If the suite is green and nothing else changes, this can merge without a separate decision. It's waiting on CI, not on you.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @m-moravcik. The full suite ran on d53c131e (run 43209564223). Every Behavior lane, the coverage guard and the repo invariants pass. One lane fails, and the failure is in this PR's own test file.

Lint 1 (job 131153391222): fm-lint: end tests/fm-remote-job.test.sh reason=findings rc=1. ShellCheck reports 88 SC2031 (info) findings in tests/fm-remote-job.test.sh, starting at line 406, right after the new identity_unset_case fixture. For example:

In tests/fm-remote-job.test.sh line 406:
       ^---------------^ SC2031 (info): FM_REMOTE_JOB_ID was modified in a subshell. That change might be lost.
In tests/fm-remote-job.test.sh line 425:
   ^-----------------^ SC2031 (info): FM_REMOTE_JOB_EXIT was modified in a subshell. That change might be lost.
In tests/fm-remote-job.test.sh line 1520:
SCAN_LANE_PID=$!
              ^-- SC2031 (info): ! was modified in a subshell. That change might be lost.

identity_unset_case() ( ... ) (line 377) is a subshell function. Inside it, the sourced library's fm_remote_job_stage/fm_remote_job_wait set FM_REMOTE_JOB_ID/_ERROR/_EXIT/_PREEMPTED_EXIT, and the & plus pid=$! set $!. So every later top-level read of those names in the file is flagged. The # shellcheck disable=SC2031 on line 382 doesn't cover this. It sits on the export line inside the subshell, and the findings are at the later reads. main lints this file clean, so the findings come from the new fixture. CI runs fm-lint in full mode with --external-sources, which may be why your local lint step passed.

Waiting on you: please make Lint 1 clean for tests/fm-remote-job.test.sh. One option is to keep the identity-unset case out of this shell's analysis scope, for example by running it as a separate bash child. Another is to suppress at the point where the subshell modifies the names, the way the cadence fixture does with SC2030. Then re-raise once with git push no-mistakes. The full-ci label stays on, so the suite re-runs on the new head.

Everything else still holds: the no-mistakes check passes, the attestation binds d53c131e with no skipped steps, Greptile is 5/5, there are no review threads, and it merges cleanly with main. contract-class: restore, unchanged.

@m-moravcik m-moravcik changed the title fix: preserve login identity in remote job children fix: preserve login identity in remote job environments Nov 12, 2026
@kunchenguid
kunchenguid merged commit 07409e7 into kunchenguid:main Nov 13, 2026
25 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @m-moravcik — really appreciate you taking the time on this.

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

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants