Program: 158278
Project: 158278
Buggy source:
@Override public Permanent copyPermanent(Duration duration,Permanent copyFromPermanent,UUID copyToPermanentId,Ability source,ApplyToPermanent applier){
  Permanent newBluePrint=null;
  for (  Effect effect : getState().getContinuousEffects().getLayeredEffects(this)) {
    if (effect instanceof CopyEffect) {
      CopyEffect copyEffect=(CopyEffect)effect;
      if (copyEffect.getSourceId().equals(copyFromPermanent.getId())) {
        MageObject oldBluePrint=((CopyEffect)effect).getTarget();
        if (oldBluePrint instanceof Permanent) {
          newBluePrint=((Permanent)oldBluePrint).copy();
        }
      }
    }
  }
  if (newBluePrint == null) {
    newBluePrint=copyFromPermanent.copy();
    newBluePrint.reset(this);
    if (copyFromPermanent.isMorphed() || copyFromPermanent.isManifested()) {
      MorphAbility.setPermanentToFaceDownCreature(newBluePrint);
    }
    newBluePrint.assignNewId();
    if (copyFromPermanent.isTransformed()) {
      TransformAbility.transform(newBluePrint,copyFromPermanent.getSecondCardFace(),this);
    }
  }
  if (applier != null) {
    applier.apply(this,newBluePrint);
  }
  CopyEffect newEffect=new CopyEffect(duration,newBluePrint,copyToPermanentId);
  newEffect.newId();
  newEffect.setApplier(applier);
  Ability newAbility=source.copy();
  newEffect.init(newAbility,this);
  state.addEffect(newEffect,newAbility);
  return newBluePrint;
}

Fixed version (ground truth):
@Override public Permanent copyPermanent(Duration duration,Permanent copyFromPermanent,UUID copyToPermanentId,Ability source,ApplyToPermanent applier){
  Permanent newBluePrint=null;
  for (  Effect effect : getState().getContinuousEffects().getLayeredEffects(this)) {
    if (effect instanceof CopyEffect) {
      CopyEffect copyEffect=(CopyEffect)effect;
      if (copyEffect.getSourceId().equals(copyFromPermanent.getId())) {
        MageObject oldBluePrint=((CopyEffect)effect).getTarget();
        if (oldBluePrint instanceof Permanent) {
          newBluePrint=((Permanent)oldBluePrint).copy();
        }
      }
    }
  }
  if (newBluePrint == null) {
    newBluePrint=copyFromPermanent.copy();
    newBluePrint.reset(this);
    if (copyFromPermanent.isMorphed() || copyFromPermanent.isManifested()) {
      MorphAbility.setPermanentToFaceDownCreature(newBluePrint);
    }
    newBluePrint.assignNewId();
    if (copyFromPermanent.isTransformed()) {
      TransformAbility.transform(newBluePrint,copyFromPermanent.getSecondCardFace(),this);
    }
  }
  if (applier != null) {
    applier.apply(this,newBluePrint);
  }
  CopyEffect newEffect=new CopyEffect(duration,newBluePrint,copyToPermanentId);
  newEffect.newId();
  newEffect.setApplier(applier);
  Ability newAbility=source.copy();
  newEffect.init(newAbility,this);
  if (Duration.Custom.equals(duration)) {
    for (    Effect effect : getState().getContinuousEffects().getLayeredEffects(this)) {
      if (effect instanceof CopyEffect) {
        CopyEffect copyEffect=(CopyEffect)effect;
        if (copyEffect.getSourceId().equals(copyToPermanentId) && copyEffect.getDuration().equals(Duration.Custom)) {
          copyEffect.discard();
        }
      }
    }
  }
  state.addEffect(newEffect,newAbility);
  return newBluePrint;
}