Automatic port connection snapping occurs

 const $ = go.GraphObject.make;

      this.diagram = $(go.Diagram, {
        "undoManager.isEnabled": true,
        "grid.visible": this.showGrid,
        "grid.gridCellSize": new go.Size(25, 25),
        model: $(go.GraphLinksModel, {
          linkKeyProperty: "key",

here is my diagram code above

linkFromPortIdProperty: “fromPort”,
linkToPortIdProperty: “toPort”,
i have removed these 2 lines as when i adjust the location of diagram it automatically choses the port based on space and direction, but in that case link object doesnt contain which port its connected
so thats its becoming hard to identify which port its connected

here is my

const activityNodePorts = [
  { portId: "T", align: go.Spot.TopCenter, output: true, input: true },
  { portId: "L", align: go.Spot.LeftCenter, output: true, input: true },
  { portId: "R", align: go.Spot.RightCenter, output: true, input: true },
  { portId: "B", align: go.Spot.BottomCenter, output: true, input: true },

makePort function is mentioned below

$(go.Shape, "Circle", {
      alignment: item.align,
      portId: item.portId,
      fromLinkable: item.output,
      toLinkable: item.input,
      cursor: "pointer",
      fill: "transparent",
      desiredSize: new go.Size(7, 7),
      stroke: null,

My motive is find out which port its conncted to…and also when the user moves the node in all direction its changes its port dynamically for better viewable diagram.

If you have removed the settings of GraphLinksModel.linkFromPortIdProperty and linkToPortIdProperty, then it is assumed that there is only one port on each node and that link data need not remember any port identifiers.

Could you please explain what you mean by “port”? It seems that you want ports to be separate Shapes, yet you don’t want them to be aligned at certain spots. How is the user supposed to know which port is which? The purpose of ports is to provide distinct logical and physical connections to a node, such as shown at:
Logic Circuit
Data Flow Diagram
If you have ports move around, then there are no longer distinct physical connections for links, and you will have to show the distinct logical characteristics some other way.