I'm going to expound in light of David... It's becoming more clear to me, but in the mean time, I'm actually expounding on what you are saying from a different angle in the Law vs Grace feed.
So, to expound on this with scripture would take a book.
I'm going to free hand this and challenge any to Scripture check my work.
David, a man after God's heart............
David was a man of faith above all things.
David was a man who fought against oppressive people's to free the merciful from the clutches of the merciless.
David was a sinner.
David Loved God's law, but placed His faith on The Rock.
The rock is the biggest OT reference to Christ.
1 Corinthians 10Holman Christian Standard Bible (HCSB)
Warnings from Israel’s Past
10 Now I want you to know, brothers, that our fathers were all under the cloud, all passed through the sea, 2 and all were baptized into Moses in the cloud and in the sea. 3 They all ate the same spiritual food, 4 and all drank the same spiritual drink. For they drank from a spiritual rock that followed them, and that rock was Christ. 5 But God was not pleased with most of them, for they were struck down in the wilderness.
David refers to the Rock prolifically in the Psalms.
David was so bloody in his dealings with other nations that he was revoked from building the temple.
David was a man given unto lust. Blood lust and lust of beauty.
One word for this.....
Bathsheba.
Not to be crude, but only his son Solomon exceeded his weak spot for the female form. Yes Solomon married to extend his borders, but it was clear he wanted more than just peace within his borders.
David trusted that God would slay Goliath by his faith.
He used a Rock to do this.
Think of Goliath as the devil and the rock as Jesus.
So how did this imperfect man find favor in Jesus/YHWH?
By relinquishing his faith in himself and exalting God as his friend in such a manner that he knew Gods decisions were good, Gods corrections were good, but only God was good.
David drew His strength from the goodness of God and gave all glory to God for anything good in His life. He even trusted God when things were bad.
David drew his strength from love, grace and the goodness of God. David knew God as if He had met Jesus in physical form and succeeded by this and this alone.
David was a man that admitted he was a man, and found grace in God to sustain his deep purpose in Gods plan.
For The Rock, Jesus, manifested Himself through a lineage that went through his adopted father Joseph and his biological mother Mary.
David is the picture of fallen man clinging to the exalted Rock, or stone that the builders rejected.
Note that Absolam was David's son that eventually lusted after David's kingdom and sought to overthrow his kingdom, yet David wept at Absolams death!!!!