Further testing was done, based on the above posts.
Stealth detection DOES require line-of-sight, so you can't safely encase the dog in walls. You can spot through fortifications (tested) and possibly windows (untested).
The game does not appear to give dogs any special detection advantage, though you could mod dogs in your game with [NATURAL_SKILL:SITUATIONAL_AWARENESS:10]. The natural skill tokens are used to give default skills to megabeasts like minotaurs, hydras, and dragons. Hydras, with 7 heads, are now correctly very naturally gifted at stealth detection.
If you are 4 or more z-levels above or below the observer, you can NOT be spotted. You CAN be spotted if you are 3 levels below and 3 tiles northwest of the observer.
If you are grand master in ambusher and your opponent can't observe, you can do this:
You begin sneaking.
You attack Goblin 2 but He jumps away!
You attack Goblin 2 but He jumps away!
You attack Goblin 2 but He jumps away!
You stab Goblin 2 in the lower body with your large iron dagger, tearing the muscle and tearing the pancreas!
An artery has been opened by the attack!
You stab Goblin 2 in the lower body with your large iron dagger, tearing the muscle and tearing the guts!
Goblin 2 looks sick!
Goblin 2 vomits.
Goblin 2 retches.
You charge at Goblin 2!
Goblin 2 looks surprised by the ferocity of Your onslaught!
You slash Goblin 2 in the lower body with your large iron dagger, tearing apart the muscle and spilling his foul guts!
The large iron dagger has lodged firmly in the wound!
You collide with Goblin 2!
You bounce backward!
The Goblin 2 pulls out and releases the large iron dagger.
Goblin 2 retches.
You scratch Goblin 2 in the lower body, tearing apart the muscle and bruising the spleen!
You slash Goblin 2 in the right lower arm with your large iron dagger and the severed part sails off in an arc!
The Goblin 2 is no longer stunned.
You slash Goblin 2 in the right eye with your large iron dagger, tearing it apart!
The large iron dagger has lodged firmly in the wound!
The Goblin 2 pulls out and releases the large iron dagger.
Goblin 2 retches.
Goblin 2 retches.
You slash Goblin 2 in the upper body with your large iron dagger, tearing apart the muscle and tearing apart the liver!
An artery has been opened by the attack!
The large iron dagger has lodged firmly in the wound!
The Goblin 2 pulls out and releases the large iron dagger.
Goblin 2 retches.
You stab Goblin 2 in the lower body with your large iron dagger, tearing apart the muscle!
Goblin 2 retches.
You charge at Goblin 2!
Goblin 2 looks surprised by the ferocity of Your onslaught!
You slash Goblin 2 in the right upper arm with your large iron dagger and the severed part sails off in an arc!
You collide with Goblin 2!
You tangle together and fall over!
You are no longer stunned.
The Goblin 2 is no longer stunned.
You stab Goblin 2 in the left foot with your large iron dagger, tearing the muscle!
A motor nerve has been severed!
The large iron dagger has lodged firmly in the wound!
The Goblin 2 pulls out and releases the large iron dagger.
You stab Goblin 2 in the right foot with your large iron dagger, tearing the muscle!
A motor nerve has been severed!
The large iron dagger has lodged firmly in the wound!
The Goblin 2 pulls out and releases the large iron dagger.
You stab Goblin 2 in the upper body with your large iron dagger, tearing the muscle and fracturing the right true rib!
A tendon in the right true rib has been torn!
Goblin 2 retches.
You slash Goblin 2 in the left hand with your large iron dagger and the severed part sails off in an arc!
Goblin 2 retches.
Goblin 2 has bled to death.
You are no longer in hiding.
You stand up.
The game currently doesn't change the combat targeting menu to respect being undetectable and standing right behind someone. A better technique for now, if you are a legendary ambusher, is to strangle the target unconscious and then one-shot them with your knife. Attacking does not increase the chance of detection over simply standing right next to them!
It also appears that high observer skill trumps high ambush skill - A grand master ambusher was always immediately spotted 3 tiles away from a grand master observer.