Man, that sure sounds like some kinda flakey problem. Normally, I'd think it was hardware related, but the intermittent nature of it doesn't support it being a hardware problem very well.
In my case, I think I'm gonna start tracking information from the command line airport utility via my script, to see if there's something else at play -- signal strength, etc. I am seeing a ton of ARPT AWDL Sync Enabled 0 and ARPT AWDL Sync Enabled 1 messages in the logs. They may have been there for a while, but they're Airport messages, and that's where I'm seeing this problem. Dunno if that's a factor or not, but I see some chatter that AWDL (which is a peer-to-peer connection across the wifi for AirDrop) may be a factor for why some are seeing weirdness with their wifi. You can turn it off (sudo ifconfig awdl0 down) at the cost of losing at least AirDrop, but I've done no testing to see if that improves my situation, and I don't know if there are further consequences than just to the AirDrop functionality.
Here's what happens in my logs when the script does a recover. This was from an actual failure this morning. I don't know if this'll tell you much, but it does give you something to compare against.
2/1/15 7:40:44.507 AM Wifiscript[13020]: dig attempt via 172.16.1.12
2/1/15 7:40:47.522 AM Wifiscript[13024]: *** WIFI ERROR #1 DETECTED -- Trying again ***
2/1/15 7:40:47.526 AM Wifiscript[13026]: dig attempt via 172.16.1.12
2/1/15 7:40:50.536 AM Wifiscript[13030]: *** WIFI ERROR #2 DETECTED ***
2/1/15 7:40:50.538 AM Wifiscript[13031]: ---> Bringing en2 down and waiting five seconds
2/1/15 7:40:50.000 AM kernel[0]: AirPort: Link Down on en2. Reason 8 (Disassociated because station leaving).
2/1/15 7:40:50.000 AM kernel[0]: en2::IO80211Interface::postMessage bssid changed
2/1/15 7:40:50.000 AM kernel[0]: ARPT: 390649.621324: AWDL Sync Enabled 1
2/1/15 7:40:50.000 AM kernel[0]: ARPT: 390649.621333: Failed to set AWDL Sync Enabled state (1), error code -4
2/1/15 7:40:50.000 AM kernel[0]: IO80211AWDLPeerManager::failToEnable
2/1/15 7:40:50.000 AM kernel[0]: IO80211AWDLPeerManager::interfaceStateChange can t enable awdl!
2/1/15 7:40:50.000 AM kernel[0]: en2: 802.11d country code set to 'X0'.
2/1/15 7:40:50.000 AM kernel[0]: en2: Supported channels 1 2 3 4 5 6 7 8 9 10 11 12 13 36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140 144 149 153 157 161 165
2/1/15 7:40:50.000 AM kernel[0]: IO80211AWDLPeerManager::doDisable source [handleSIOCSIFFLAGS]
2/1/15 7:40:50.000 AM kernel[0]: AirPort: Link Down on awdl0. Reason 1 (Unspecified).
2/1/15 7:40:50.000 AM kernel[0]: IO80211AWDLPeerManager::doDisable source [setLinkState]
2/1/15 7:40:50.560 AM airportd[33]: _handleLinkEvent: WiFi is not powered. Resetting state variables.
2/1/15 7:40:50.813 AM UserEventAgent[19]: Captive: CNPluginHandler en2: Inactive
2/1/15 7:40:50.814 AM configd[28]: network changed: v4(en0:172.16.1.10, en2-:172.16.1.12) DNS* Proxy SMB
2/1/15 7:40:50.815 AM discoveryd[52]: Basic Bonjour stop listening on awdl0
2/1/15 7:40:50.815 AM discoveryd[52]: Basic Bonjour stop listening on en2
2/1/15 7:40:55.570 AM Wifiscript[13035]: ---> Turning off Airport and waiting five seconds
2/1/15 7:41:00.659 AM Wifiscript[13040]: ---> Turning on Airport and waiting five seconds
2/1/15 7:41:01.000 AM kernel[0]: en2: channel changed to 1
2/1/15 7:41:01.000 AM kernel[0]: AirPort: Link Up on awdl0
2/1/15 7:41:01.000 AM kernel[0]: IO80211AWDLPeerManager::configure Dynamic country code not supported on this device
2/1/15 7:41:01.000 AM kernel[0]: ARPT: 390660.297020: AWDL Sync Enabled 1
2/1/15 7:41:01.000 AM kernel[0]: en2: channel changed to 1
2/1/15 7:41:01.000 AM kernel[0]: IO80211AWDLPeerManager::setAwdlOperatingMode Setting the AWDL operation mode from AUTO to SUSPENDED
2/1/15 7:41:01.000 AM kernel[0]: IO80211AWDLPeerManager::setAwdlSuspendedMode() Suspending AWDL, enterQuietMode(true)
2/1/15 7:41:01.000 AM kernel[0]: ARPT: 390660.410860: AWDL Sync Enabled 0
2/1/15 7:41:01.000 AM kernel[0]: en2: 802.11d country code set to 'US'.
2/1/15 7:41:01.000 AM kernel[0]: en2: Supported channels 1 2 3 4 5 6 7 8 9 10 11 36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140 144 149 153 157 161 165
2/1/15 7:41:01.000 AM kernel[0]: ARPT: 390660.539133: MacAuthEvent en2 Auth result for: 00:26:bb:75:fd:fe MAC AUTH succeeded
2/1/15 7:41:01.000 AM kernel[0]: AirPort: Link Up on en2
2/1/15 7:41:01.000 AM kernel[0]: en2: BSSID changed to 00:26:bb:75:fd:fe
2/1/15 7:41:01.000 AM kernel[0]: en2: channel changed to 161,-1
2/1/15 7:41:01.000 AM kernel[0]: en2::IO80211Interface::postMessage bssid changed
2/1/15 7:41:01.487 AM configd[28]: arp_client_transmit(en2) failed, Network is down (50)
2/1/15 7:41:01.487 AM configd[28]: [bootp_transmit.c:213] bootp_transmit(): bpf_write(en2) failed: Network is down (50)
2/1/15 7:41:01.487 AM configd[28]: DHCP en2: INIT-REBOOT transmit failed
2/1/15 7:41:01.487 AM configd[28]: DHCP en2: ARP detect ROUTER failed, arp_client_transmit(en2) failed, Network is down (50)
2/1/15 7:41:01.878 AM discoveryd[52]: Basic DNSResolver Error 9 on socket - this might be a closed socket
2/1/15 7:41:03.559 AM configd[28]: arp_client_transmit(en2) failed, Network is down (50)
2/1/15 7:41:03.560 AM configd[28]: [bootp_transmit.c:213] bootp_transmit(): bpf_write(en2) failed: Network is down (50)
2/1/15 7:41:03.560 AM configd[28]: DHCP en2: INIT-REBOOT transmit failed
2/1/15 7:41:03.560 AM configd[28]: DHCP en2: ARP detect ROUTER failed, arp_client_transmit(en2) failed, Network is down (50)
2/1/15 7:41:03.640 AM discoveryd[52]: AwdlD2d AwdlD2dStartAdvertisingPair: 'bagel-warmer' Advertising service started
2/1/15 7:41:03.641 AM discoveryd[52]: AwdlD2d AwdlD2dStartAdvertisingPair: 'bagel-warmer' Advertising service started
2/1/15 7:41:03.643 AM discoveryd[52]: AwdlD2d AwdlD2dStartAdvertisingPair: '2aafbaefff98728200000000000008efip6arpa' Advertising service started
2/1/15 7:41:04.439 AM locationd[58]: NETWORK: requery, 0, 0, 0, 0, 1, items, fQueryRetries, 0, fLastRetryTimestamp, 444450276.8
2/1/15 7:41:05.000 AM kernel[0]: AirPort: Link Down on en2. Reason 8 (Disassociated because station leaving).
2/1/15 7:41:05.000 AM kernel[0]: en2: channel changed to 1
2/1/15 7:41:05.000 AM kernel[0]: en2::IO80211Interface::postMessage bssid changed
2/1/15 7:41:05.000 AM kernel[0]: en2: 802.11d country code set to 'X0'.
2/1/15 7:41:05.000 AM kernel[0]: en2: Supported channels 1 2 3 4 5 6 7 8 9 10 11 12 13 36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140 144 149 153 157 161 165
2/1/15 7:41:06.000 AM kernel[0]: ARPT: 390665.114201: MacAuthEvent en2 Auth result for: 00:26:bb:75:fd:fe MAC AUTH succeeded
2/1/15 7:41:06.000 AM kernel[0]: AirPort: Link Up on en2
2/1/15 7:41:06.000 AM kernel[0]: en2: BSSID changed to 00:26:bb:75:fd:fe
2/1/15 7:41:06.000 AM kernel[0]: en2: channel changed to 161,-1
2/1/15 7:41:06.000 AM kernel[0]: en2::IO80211Interface::postMessage bssid changed
2/1/15 7:41:06.061 AM configd[28]: arp_client_transmit(en2) failed, Network is down (50)
2/1/15 7:41:06.061 AM configd[28]: [bootp_transmit.c:213] bootp_transmit(): bpf_write(en2) failed: Network is down (50)
2/1/15 7:41:06.061 AM configd[28]: DHCP en2: INIT-REBOOT transmit failed
2/1/15 7:41:06.061 AM configd[28]: DHCP en2: ARP detect ROUTER failed, arp_client_transmit(en2) failed, Network is down (50)
2/1/15 7:41:06.000 AM kernel[0]: en2: 802.11d country code set to 'US'.
2/1/15 7:41:06.000 AM kernel[0]: en2: Supported channels 1 2 3 4 5 6 7 8 9 10 11 36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140 144 149 153 157 161 165
2/1/15 7:41:06.207 AM Wifiscript[13044]: ---> Bringing en2 up and waiting five seconds
2/1/15 7:41:06.000 AM kernel[0]: en2: BSSID changed to 00:26:bb:75:fd:fe
2/1/15 7:41:06.000 AM kernel[0]: en2: channel changed to 161,-1
2/1/15 7:41:06.000 AM kernel[0]: en2: BSSID changed to 00:26:bb:75:fd:fe
2/1/15 7:41:06.000 AM kernel[0]: en2: channel changed to 161,-1
2/1/15 7:41:07.000 AM kernel[0]: AirPort: RSN handshake complete on en2
2/1/15 7:41:07.000 AM kernel[0]: IO80211AWDLPeerManager::setAwdlOperatingMode Setting the AWDL operation mode from SUSPENDED to AUTO
2/1/15 7:41:07.000 AM kernel[0]: IO80211AWDLPeerManager::setAwdlAutoMode Resuming AWDL
2/1/15 7:41:07.000 AM kernel[0]: ARPT: 390666.480957: AWDL Sync Enabled 1
2/1/15 7:41:07.420 AM configd[28]: network changed: v4(en0:172.16.1.10) DNS* Proxy SMB
2/1/15 7:41:07.421 AM UserEventAgent[19]: Captive: [CNInfoNetworkActive:1709] en2: SSID 'MY_WIFI_NETWORK_NAME' making interface primary (cache indicates network not captive)
2/1/15 7:41:07.421 AM UserEventAgent[19]: Captive: CNPluginHandler en2: Evaluating
2/1/15 7:41:07.423 AM UserEventAgent[19]: Captive: en2: Not probing 'MY_WIFI_NETWORK_NAME' (cache indicates not captive)
2/1/15 7:41:07.423 AM UserEventAgent[19]: Captive: CNPluginHandler en2: Authenticated
2/1/15 7:41:07.426 AM configd[28]: network changed: v4(en0:172.16.1.10, en2!:172.16.1.12) DNS Proxy SMB
2/1/15 7:41:07.000 AM kernel[0]: en2: BSSID changed to 00:26:bb:75:fd:fe
2/1/15 7:41:07.000 AM kernel[0]: en2: channel changed to 161,-1
2/1/15 7:41:11.218 AM Wifiscript[13048]: *** WIFI RECOVERY ATTEMPT COMPLETED ***
2/1/15 7:41:34.000 AM kernel[0]: ARPT: 390693.679416: AWDL Sync Enabled 0
2/1/15 7:46:11.214 AM Wifiscript[13056]: dig attempt via 172.16.1.12