The text that fits this description is the Manusmriti, which is a Sanskrit text compiled between c. 200 BCE and 200 CE. It is a significant ancient Indian text that outlines a comprehensive code of laws and offers guidelines on various aspects of social life, including duties, ethics, and governance.
The Ramayana, Upanishads, and Vedas do not meet all of these criteria, particularly the emphasis on a legal code and social guidelines as the Manusmriti does.