Pull in DocumentRule implementation from upstream

I need this to use assetgraph at work