What limits supercurrents in high temperature superconductors? A microscopic model of cuprate grain boundaries