Skip to content

fix(auth-sync): push bundles into the worker's agents root, and let a Cursor slot launch find its binary and lease (PHNX-3940) - #3553

Merged
muqsitnawaz merged 3 commits into
mainfrom
fix/worker-secrets-root
Sep 8, 2026
Merged

fix(auth-sync): push bundles into the worker's agents root, and let a Cursor slot launch find its binary and lease (PHNX-3940)#3553
muqsitnawaz merged 3 commits into
mainfrom
fix/worker-secrets-root

Conversation

@muqsitnawaz

Copy link
Copy Markdown
Contributor

Problem

Follow-up to #3551 (merged, released as 1.22.90). Two more seams stopped a worker from running cursor#gmail, both found while proving that release end-to-end on yosemite-m0.

1. The push lands in the wrong root on the worker. agents-cli runs its local secrets under SECRETS_HOME=~/.agents (MIG-1), and the worker daemon reads pushed bundles from that root. The remote half of every bundle push ran the receiving secrets with no env prologue, so it used its own default ~/.secrets:

zion:        auth-sync: pushed __cursor__ (1 key(s)) to yosemite-m0
yosemite-m0: ~/.secrets/.cache/secrets/agents-cli.bundles.__cursor__.enc   (18:05, the push)
             ~/.agents/.cache/secrets/  -> no __cursor__
             auth-sync: 1 registered account(s) have no readable durable key on this box yet

The file store is keyed per root (<SECRETS_HOME>/.secrets-key/passphrase), so the two roots cannot share ciphertext either. Every push call site (auth-sync, accounts sync, fleet apply, mint) goes through the one client wrapper.

2. A Cursor slot launch cannot find its binary or take its lease. The slot launch hands the direct alias HOME=<slot dir> with the real home in AGENTS_REAL_HOME; the alias anchored BINARY on $HOME:

$ agents run cursor#gmail "…"        (yosemite-m0, key present, slot provisioned)
[agents] account 'gmail' · cursor
Running: /home/muqsit/.agents/.cache/shims/cursor-agent@main -f -p …
agents: cursor@main not installed

Under a plain HOME the alias still failed, because cursor's own HOME swap ran before the launch lease and agents __launch-lease (state root $HOME/.agents) then answered No installation directory for cursor@main.

Change

  • secrets-client.ts: withRemoteStateRoot fills remoteSecretsHome: '~/.agents' (REMOTE_USER_AGENTS_DIR) on every pushBundleToHost[Async] unless the caller named a root; PushBundleOptions gains the field. secrets-cli 0.1.2 (feat(push): remoteSecretsHome pins the remote secrets to the consumer state root on every transport secrets-cli#5) applies it to the import, the read-back verify and literal restoration, with a strict path charset before the value reaches the remote shell.
  • shims.ts direct alias (schema 20, regenerated on next sync): every agents-owned path anchors on AGENTS_REAL_HOME; the launch lease runs HOME="$AGENTS_REAL_HOME" before any harness HOME swap; cursor swaps HOME only when $HOME still equals the real home (a spawner-chosen slot HOME is kept).
  • Test pin STANDALONE_SECRETS_VERSION → 0.1.2; doc and CHANGELOG updated.

Verification

  • tsc --noEmit clean.
  • secrets-client.test.ts (withRemoteStateRoot, buildServeEnv): pass. shims.test.ts: 36/36, including the new Cursor and Claude alias cases (real-home anchor, lease before swap, conditional swap) and the Grok fallback path moved to the real home.
  • Remote half proven on yosemite-m0 by hand before the code change: an on-box re-import of the pushed bundle into ~/.agents made the daemon provision the slot (auth-sync: provisioned worker slot(s) for 3dbc408e…); the same was applied to the other eight online workers.
  • The CI test job goes green once 0.1.2 propagates on npm (published, tag on origin).

Tracking: PHNX-3940.

muqsitnawaz and others added 2 commits September 7, 2026 11:35
… Cursor slot launch find its binary and lease (PHNX-3940)

Two seams closed after 1.22.90 delivered the __cursor__ push:

1. The remote half of every bundle push ran the receiving `secrets` under its
   default ~/.secrets while the worker daemon reads ~/.agents (MIG-1 on both
   ends). zion logged "pushed __cursor__ (1 key(s)) to yosemite-m0"; the worker
   kept answering "no readable durable key on this box yet" — the bundle sat in
   ~/.secrets, keyed by a different machine-local passphrase. The one client
   wrapper every push uses now names the remote root (withRemoteStateRoot,
   REMOTE_USER_AGENTS_DIR = '~/.agents'); secrets-cli 0.1.2 applies it to the
   import, the read-back verify and literal restoration (remoteSecretsHome).

2. With the key in place, `agents run cursor#gmail` on the worker still failed:
   the slot launch hands the direct alias HOME=<slot dir> (real home in
   AGENTS_REAL_HOME) and the alias anchored its binary on $HOME, so
   cursor-agent@main said "cursor@main not installed"; under a plain HOME,
   cursor's own HOME swap ran before the launch lease, and `agents
   __launch-lease` (state root $HOME/.agents) failed with "No installation
   directory for cursor@main". The versioned alias (schema 20) now anchors every
   agents-owned path on AGENTS_REAL_HOME, takes the lease under the real home
   before any harness HOME swap, and cursor swaps HOME only when the spawner has
   not already chosen one.

Test pin STANDALONE_SECRETS_VERSION -> 0.1.2. Docs + CHANGELOG.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014qq5fiWVRBmBV9f5KR58dY
…nd scope the bare dispatcher shim out explicitly

Review notes on #3553: 'regenerated on next sync' was wrong — only the daemon
self-heal tick (6 h) or agents doctor --fix / agents view rewrite an alias; and
generateShimScript keeps the $HOME anchor, which is off the slot-launch path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014qq5fiWVRBmBV9f5KR58dY
@muqsitnawaz

Copy link
Copy Markdown
Contributor Author

VERDICT: APPROVE

Non-author review (code-reviewer subagent). Verified by execution and tracing, not just the diff: the generated alias bash under a non-slot env (lease under the real home, then the cursor HOME swap) and a slot env (lease under the real home, HOME stays the slot for exec, AGENT_CLI_CREDENTIAL_STORE=file in both); a native-account run always resolves a version and runs the versioned alias (commands/exec.tsbuildExecCommand), so the reported repro is on the fixed path; every push call site goes through withRemoteStateRoot; secrets-cli 0.1.1 ignores the unknown remoteSecretsHome field (checked against its source), so the field is additive.

Two should-fix notes, addressed in e0cf53d: the CHANGELOG said the schema-20 alias regenerates 'on next sync' — it is the daemon self-heal tick (6 h) or agents doctor --fix / agents view; and the bare dispatcher shim (generateShimScript) keeps its $HOME anchor, now stated as out of scope since slot launches never use it.

Checks: shims.test.ts 36/36, withRemoteStateRoot seam test passes, tsc clean; three pre-existing real-Keychain failures in secrets-client.test.ts on macOS are untouched by this diff.

…and schema 20

CI on #3553: src/lib/__tests__/shims.test.ts and tests/shims.test.ts still
pinned the $HOME anchors and VERSIONED_ALIAS_SCHEMA_VERSION 19.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014qq5fiWVRBmBV9f5KR58dY
@muqsitnawaz
muqsitnawaz merged commit 3fa36ac into main Sep 8, 2026
10 checks passed
muqsitnawaz added a commit that referenced this pull request Sep 8, 2026
…nd scope the bare dispatcher shim out explicitly

Review notes on #3553: 'regenerated on next sync' was wrong — only the daemon
self-heal tick (6 h) or agents doctor --fix / agents view rewrite an alias; and
generateShimScript keeps the $HOME anchor, which is off the slot-launch path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014qq5fiWVRBmBV9f5KR58dY
@muqsitnawaz
muqsitnawaz deleted the fix/worker-secrets-root branch September 8, 2026 03:26
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