fix(cli): select the remote connection record and provider once before authentication
Merged
TH
7d ago+575+575+012345678901234567890123456789-232-232-012345678901234567890123456789
Summary
Resolve the effective state directory and session before authentication. Select the saved connection record once. Admission uses its provider, with the profile as fallback. Lease materialization receives the same record. A redirected local record keeps its local route unless the caller supplies a daemon override.
Saved-connection credential binding is deferred to #4973.
Closes #4858
Before / after
Directory A points to a profile that selects directory B. B’s saved session uses Limrun, and the plugin is absent.
$ AGENT_DEVICE_STATE_DIR=A agent-device apps --session ci --json
Before: UNAUTHORIZED
After: UNSUPPORTED_OPERATION (plugin-not-installed)
agent-device plugins add @agent-device/limrun …
Validation
- The original regressions cover the missing-plugin repro, authentication and materialization on B, and one record read. The added edited-profile URL case failed before the route fix and passed afterward. An explicit URL and token still take precedence.
- Focused rebase validation passed 1,197 tests and the production-export audit. The full affected gate passed on
6725e91df7againste02e1f7dc2, including build, lint, format, typecheck, and Fallow.

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