Tighten sanity checks, part XXXIII.

- Check whether the artifacts in a child list actually appears in their
  products' artifact list.
- Do sanity checking right before storing the build graph. This makes
  sure that a corrupted build graph never gets written to disk.

Change-Id: I06b02b97c3621ecdc1f6dae8e6ce818519f9736e
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>