code: func (p *Plan) Calculate() *Plan {
  	t := newPlanTable()
  
  	for _, current := range filterRecordsForPlan(p.Current) {
  		t.addCurrent(current)
  	}
  	for _, desired := range filterRecordsForPlan(p.Desired) {
  		t.addCandidate(desired)
  	}
  
  	changes := &Changes{}
  	changes.Create = t.getCreates()
  	changes.Delete = t.getDeletes()
  	changes.UpdateNew, changes.UpdateOld = t.getUpdates()
  	for _, pol := range p.Policies {
  		changes = pol.Apply(changes)
  	}
  
  	plan := &Plan{
  		Current: p.Current,
  		Desired: p.Desired,
  		Changes: changes,
  	}
  
  	return plan
  }
docs: // Calculate computes the actions needed to move current state towards desired
  // state. It then passes those changes to the current policy for further
  // processing. It returns a copy of Plan with the changes populated.