AI Regulation in Practice: How Compliance Becomes Code
- ShiftQuality Contributor
- Apr 16
- 5 min read
The regulatory environment for AI has shifted from "maybe someday" to "read this or get fined." The EU AI Act entered force in 2024. GDPR's provisions on automated decision-making have been enforced since 2018. The US Executive Order on AI established reporting requirements. China's AI regulations require algorithmic transparency. Brazil's LGPD covers automated profiling.
If you build AI systems that operate across borders — and most software operates across borders — compliance is no longer optional. The question isn't whether regulation will affect your work. It's how to implement it without making your codebase a compliance nightmare.
This post covers the major regulatory frameworks, what they actually require in technical terms, and how engineering teams translate legal requirements into working systems.
The EU AI Act: Risk-Based Regulation
The EU AI Act categorizes AI systems by risk level, with different requirements for each tier.
Unacceptable Risk (Banned)
Some AI applications are prohibited entirely: social scoring by governments, real-time facial recognition in public spaces (with narrow exceptions), and AI systems that manipulate behavior in ways that cause harm.
If your product falls in this category, the technical requirement is simple: don't build it.
High Risk (Heavy Requirements)
AI systems used in critical domains — hiring, credit scoring, education, law enforcement, healthcare diagnostics, critical infrastructure — are classified as high risk and subject to the most stringent requirements.
Technical requirements for high-risk systems:
Risk management system. A documented, ongoing process for identifying and mitigating risks throughout the AI system's lifecycle. This isn't a one-time risk assessment — it's a living process that updates as the system changes and new risks emerge.
In code terms: risk documentation lives alongside the codebase, risk assessments are reviewed at each release, and monitoring systems flag emerging risks.
Data governance. Training data must be relevant, representative, and as free from bias as reasonably achievable. Data provenance must be documented. If you can't explain where your training data came from and why it's appropriate, you can't deploy a high-risk system.
In code terms: data pipeline documentation, bias measurement in the training process, data lineage tracking, and retention policies enforced programmatically.
Technical documentation. Comprehensive documentation of the system's design, development process, capabilities, and limitations. This documentation must be sufficient for regulators to understand how the system works and assess compliance.
In code terms: architecture decision records, model cards, training run documentation, evaluation results, and known limitations — maintained as part of the development process, not written retrospectively.
Record-keeping and logging. High-risk systems must automatically log events relevant to identifying risks and facilitating post-market monitoring. Logs must be retained for an appropriate period.
In code terms: structured logging of all decisions, inputs, and outputs. Audit trails that capture model versions, feature values, and confidence scores for each decision. Retention policies that comply with the regulation's timeframes.
# Example: structured decision logging for compliance
import structlog
logger = structlog.get_logger()
def make_credit_decision(application):
features = extract_features(application)
prediction = model.predict(features)
decision = apply_business_rules(prediction)
logger.info(
"credit_decision",
application_id=application.id,
model_version=model.version,
model_confidence=prediction.confidence,
decision=decision.outcome,
factors=decision.top_factors,
timestamp=datetime.utcnow().isoformat(),
)
return decision
Human oversight. High-risk systems must be designed to allow effective human oversight. This means the system can be interrupted, overridden, or stopped by a human operator.
In code terms: kill switches, manual review queues, override mechanisms, and escalation paths. The system should support, not prevent, human intervention.
Accuracy, robustness, and cybersecurity. The system must meet appropriate levels of accuracy, be resilient to errors and adversarial inputs, and be secured against unauthorized access.
Limited Risk (Transparency Requirements)
AI systems that interact with people — chatbots, deepfake generators, emotion recognition — must disclose that AI is involved. Users must know they're interacting with an AI system, not a human.
In code terms: clear labeling in the UI. "This response was generated by AI." "This image was AI-generated." Not buried in terms of service — visible at the point of interaction.
Minimal Risk (No Special Requirements)
Most AI systems — spam filters, recommendation engines, search ranking — fall here. No special regulatory requirements beyond existing law.
GDPR and Automated Decision-Making
GDPR Article 22 gives individuals the right not to be subject to decisions based solely on automated processing that significantly affect them. This applies today, has been enforced, and has resulted in significant fines.
What this means technically:
Right to human review. If your system makes a decision that significantly affects someone (credit approval, job application screening, insurance pricing), the person can request human review. Your system must support routing decisions to a human reviewer.
Right to explanation. The person has the right to understand the logic involved. "The algorithm decided" is not sufficient. You need explainability — at minimum, the key factors that influenced the decision.
Right to contest. The person can challenge the decision. Your system needs a process for receiving and processing challenges, including re-evaluation.
// Example: GDPR-compliant decision endpoint
[HttpPost("decisions/{id}/request-review")]
public async Task<IActionResult> RequestHumanReview(string id)
{
var decision = await _decisions.FindAsync(id);
if (decision == null) return NotFound();
decision.Status = DecisionStatus.PendingHumanReview;
decision.ReviewRequestedAt = DateTime.UtcNow;
await _reviewQueue.EnqueueAsync(decision);
await _decisions.UpdateAsync(decision);
return Ok(new {
message = "Your request for human review has been received.",
estimatedResponseTime = "5 business days"
});
}
Implementing Compliance Without Losing Velocity
The fear is that compliance requirements will bog down development. It doesn't have to work that way if you build compliance into the process rather than bolting it on afterward.
Model Cards as Standard Practice
A model card documents what a model does, how it was trained, what its limitations are, and how it's been evaluated — including across demographic groups. Making model cards a required artifact for every model deployment isn't compliance overhead. It's engineering discipline that happens to satisfy regulatory requirements.
Automated Bias Testing in CI/CD
If high-risk regulations require bias measurement, build it into your pipeline. Run fairness metrics on every model update, same as you run unit tests. A model that introduces disparate impact fails the pipeline, same as a model that degrades accuracy.
Feature Stores as Data Governance
A feature store tracks the lineage, versioning, and quality of features used in ML models. It's a good engineering practice that also satisfies data governance requirements — you can answer "what data trained this model?" because the feature store records it.
Structured Logging by Default
Log every decision with the context that influenced it. This is useful for debugging, essential for compliance, and trivial to implement if you do it from the start. Adding it after the fact — reconstructing decision context months later for a regulatory inquiry — is expensive and error-prone.
What's Coming
The regulatory landscape is tightening, not loosening. Expect:
Sector-specific regulations. Healthcare AI, financial AI, and hiring AI are attracting targeted regulation beyond the horizontal frameworks.
Mandatory auditing. The EU AI Act requires conformity assessments for high-risk systems. Third-party auditing of AI systems is becoming an industry.
Cross-border enforcement. Like GDPR, AI regulations will have extraterritorial reach. Building for the most restrictive jurisdiction you operate in is the safest strategy.
Liability frameworks. The EU AI Liability Directive proposes rules for who's responsible when AI causes harm. This will affect how teams document decisions and manage risk.
Key Takeaway
AI regulation is here. The EU AI Act categorizes systems by risk level with specific technical requirements. GDPR mandates human review, explanation, and contestation for automated decisions. Compliance becomes manageable when it's built into the development process — model cards, automated bias testing, feature stores, and structured logging. The teams that treat compliance as an engineering practice rather than a legal burden will move fastest.
This completes the AI Governance at Scale learning path. You've covered governance for engineering teams, incident response, continuous auditing, and regulatory compliance. The throughline: AI governance is not a policy document — it's a set of engineering practices that make AI systems accountable, auditable, and trustworthy.



Comments