Law and Regulation in LLM-based systems: Machine Learning is changing both how software is written and how it makes decisions. Developers now lean on LLMs to generate code, which risks reusing licensed or copyrighted material without proper attribution. Meanwhile, software increasingly embeds ML models as autonomous decision-makers, potentially breaching model terms of use or regulations like the EU AI Act. This PhD project proposes a unified framework to address both risks: licensing violations in LLM-generated code and terms-of-use or regulatory violations in AI-driven decisions. It combines empirical analysis, provenance tracing, and automated repair to help developers and organizations build legally compliant, ML-intensive software.