wp_insert_post generated mixed permalinks

Permalinks in WP do not actually have anything to do with wp_posts.guid any more. I believe that historically they did, and have been left in because of RSS feeds – I.e. changing them would cause peoples feeds to think that the posts had not been read.

Your permalink structure is stored within your wp_options table (add echo '<pre>'; print_r($wp_rewrite); echo '</pre>'; to your code to see the rules).

get_permalink() should be used within The Loop, unless you are parsing a page ID to it (get_permalink(15)), so that may be causing the issue.

May I also suggest that you reset your permalinks to default, save them, then set them to ‘Day and name’, save them, and see if that works. The reason for this is to flush your rules, and then create some correct rules. I suggest ‘Day and name’ as there is an issue in the current version on WP (3.3.1) where setting permalinks to ‘Postname’ do not correctly create the rules.

If the above gives you working rules then try your custom structure and it should work.