The purpose of this thread is to discuss the basics of what it means to attain character trait, what it means to have a character trait, and then to understand what the Bible specifically says about the trait of righteousness in a way that does not depart from the simplicity of that framework.
Character traits are not earned as the result of our works but rather they are embodied through our works. The one and only way to attain a character trait is through faith apart from being required to have first done enough works in order to earn it as the result, but what it means to attain a character trait is to become a doer of works that embody that trait, so it would contradictory for to attain a character trait apart from becoming a doer of that trait. More specifically, the faith by which a character trait is attained is the belief that we ought have our lives directed at being a doer of works that embody that trait.
We embody what we believe to be true about who God is through our works, such as with James 2:18 saying that he would show his faith through his works. In other words, the way to believe in God is by believing that we ought to have our lives directed at embody His likeness through being a doer of His character traits. For example, by being a doer of good works in obedience to God we are embodying His goodness, which is why our good works bring glory to Him (Matthew 5:16), and by embodying God's goodness we are also expressing the belief that God is good. Likewise, the way to believe that God is compassionate is by being compassionate, the way to believe that God is a doer of justice is by being a doer of justice, the way to believe that God is holy is by being a doer of His instructions for how to be holy as He is holy, and so forth. This is exactly the way to believe in the Son, who is the radiance of God's glory and the exact likeness of His character (Hebrews 1:3), which he embodied through his works by setting an example for us to follow of how to walk in obedience to God's law, and it is by that faith alone that we attain the character traits of God.
While it is true that Abraham believed God, so he was declared righteous (Genesis 15:6), it is also true that he believed God, so he was a doer of righteous works (Genesis 18:19), so the faith by which he was declared righteous was also embodied through his works, but he did not earn his righteousness as the result of his works (Romans 4:1-5). In James 2:21-24, it quotes Genesis 15:6 to support saying that Abraham was declared righteous by his works when he offered Isaac, that his faith was active along with his works, and his faith completed his works, so he was declared righteous by his works insofar as they embodied his faith but not insofar as they were earning a wage. In 1 John 3:7, everyone who is a doer of righteous works is righteous even as they are righteous, so while we do not earn our righteousness as the result of our works, there is is no such thing as someone being righteous apart from being a doer of righteous works, but rather the content of the gift of being imputed with the righteousness of God is getting to become a doer of righteous works.