# EU AI Act → LeanCTX mapping matrix (GL #424, H3 Epic A).
#
# Scope: requirements that govern the CONTEXT FLOW between repositories/data
# sources and AI models, from the perspective of a DEPLOYER using LeanCTX as
# the context pipeline. Provider-side obligations (conformity assessment,
# CE marking, registration) are out of scope and listed as gaps where
# adjacent.
#
# Honesty rules: `coverage = "full"` is only claimed where a technical
# mechanism ENFORCES the requirement and a CI test proves the enforcement
# (AC 2). Organisational duties are `none` — documented, not hidden.
# Legal sign-off of this scoping is an open human task (AC 3).

framework = "eu-ai-act"
title = "EU AI Act — Regulation (EU) 2024/1689"
version_pin = "OJ L 2024/1689, 12 July 2024"
pinned_on = "2026-06-11"
review_cycle_months = 6
disclaimer = "LeanCTX is tooling support for compliance work — not legal advice. 'Aligned' is a technical statement about enforceable controls, not a certification or a legal conformity claim."
reference_pack = "eu-ai-act-deployer"

[[controls]]
id = "AIA-12.1"
clause = "Art. 12(1)"
requirement = "The system technically allows automatic recording of events (logs) over its lifetime"
mechanism = "audit_event"
leanctx = "Every tool call is appended to a hash-chained audit trail (core/audit_trail.rs); logging is always-on, not opt-in"
evidence = "audit trail JSONL; chain verifiable offline (OCP Part 4)"
coverage = "full"
test = "aia_12_1_logging_is_automatic_and_chained"

[[controls]]
id = "AIA-12.1-integrity"
clause = "Art. 12(1) + Art. 15(5)"
requirement = "Recorded logs are protected against tampering"
mechanism = "audit_event"
leanctx = "SHA-256 hash chain + Ed25519 signature per entry; any modification breaks verification"
evidence = "chain verification result (total/valid/first_invalid_at)"
coverage = "full"
test = "aia_12_1_tampered_log_fails_verification"

[[controls]]
id = "AIA-12.2a"
clause = "Art. 12(2)(a)"
requirement = "Traceability: situations that may present risks are identifiable from the records"
mechanism = "audit_event"
leanctx = "Risk-relevant event types are first-class: tool_denied, path_jail_violation, budget_exceeded, security_violation, secret_detected, rate_limited, cross_project_access"
evidence = "typed audit entries filterable by event_type"
coverage = "full"
test = "aia_12_2a_risk_event_types_are_recorded"

[[controls]]
id = "AIA-26.6"
clause = "Art. 26(6)"
requirement = "Deployers keep automatically generated logs at least six months"
mechanism = "pack_rule"
leanctx = "Policy pack declares audit_retention_days >= 180; hosted plane enforces plan retention windows"
evidence = "resolved pack value + org audit log retention (org-audit-log-v1)"
coverage = "full"
test = "aia_26_6_reference_pack_declares_six_month_retention"

[[controls]]
id = "AIA-10.5"
clause = "Art. 10(5)"
requirement = "Special categories of personal data are subject to appropriate safeguards when processed"
mechanism = "pack_rule"
leanctx = "Sender-side redaction of regulated identifiers (SSN, DOB, IBAN, payment card) before content enters model context"
evidence = "redaction patterns in resolved pack; redaction fixtures matched in CI"
coverage = "full"
test = "aia_10_5_regulated_identifiers_are_redacted"

[[controls]]
id = "AIA-15.5-secrets"
clause = "Art. 15(5)"
requirement = "Cybersecurity: the system is resilient against attempts to exploit it (credential leakage into model context)"
mechanism = "pack_rule"
leanctx = "Credential classes (private keys, cloud keys, API tokens, bearer tokens) are redacted before context assembly"
evidence = "credential fixtures matched by resolved redaction patterns"
coverage = "full"
test = "aia_15_5_credentials_never_reach_context"

[[controls]]
id = "AIA-15.5-access"
clause = "Art. 15(5)"
requirement = "Unauthorized use of capabilities is technically prevented"
mechanism = "pack_rule"
leanctx = "Capability gate (default-deny per role) + pack deny_tools; violations emit tool_denied audit events"
evidence = "capability check results (OCP Part 2) + denied-tool audit entries"
coverage = "full"
test = "aia_15_5_unauthorized_tool_use_is_blocked"

[[controls]]
id = "AIA-14.4a"
clause = "Art. 14(4)(a)"
requirement = "Human overseers can understand relevant capacities and limitations of the system"
mechanism = "evidence_export"
leanctx = "Capability grant sets per role are exportable and human-readable; Context-IR shows what actually entered context"
evidence = "grant-set JSON (OCP Part 2) + Context-IR document (OCP Part 1)"
coverage = "full"
test = "aia_14_4a_capabilities_are_inspectable"

[[controls]]
id = "AIA-14.4e"
clause = "Art. 14(4)(e)"
requirement = "Human overseers can intervene or interrupt the operation"
mechanism = "pack_rule"
leanctx = "Hard budget caps (max_context_tokens) stop runaway context assembly; budget_exhausted events fire before exhaustion via budget_warning"
evidence = "pack cap + budget event stream"
coverage = "full"
test = "aia_14_4e_budget_caps_bound_operation"

[[controls]]
id = "AIA-13.1"
clause = "Art. 13(1)"
requirement = "Operation is sufficiently transparent to enable interpretation of the output"
mechanism = "evidence_export"
leanctx = "Context-IR records every item that entered context with source attribution, token counts and verification hashes"
evidence = "Context-IR v1 document (bounded, redacted, hashable)"
coverage = "full"
test = "aia_13_1_context_ir_attributes_every_item"

[[controls]]
id = "AIA-12.2-traceability"
clause = "Art. 12(2)"
requirement = "Level of traceability appropriate to the intended purpose"
mechanism = "evidence_export"
leanctx = "Per-item source attribution (kind/tool/path/command/pattern + agent_id) in Context-IR; per-action attribution in audit trail"
evidence = "IR source objects + audit entries with agent_id and role"
coverage = "full"
test = "aia_12_2_actions_attribute_agent_and_role"

[[controls]]
id = "AIA-10.2"
clause = "Art. 10(2)"
requirement = "Data governance practices: relevance, representativeness, bias examination of training/validation data"
mechanism = "none"
leanctx = "LeanCTX governs runtime context flow, not training-data curation; bias examination is a human/ML-pipeline duty"
evidence = "n/a"
coverage = "none"
gap = "Training-data governance is outside the context-pipeline boundary; pair LeanCTX evidence with ML-pipeline tooling"

[[controls]]
id = "AIA-26.2"
clause = "Art. 26(2)"
requirement = "Deployers assign human oversight to competent persons"
mechanism = "none"
leanctx = "Organisational duty; LeanCTX supports it (owner field on agent identities) but cannot enforce competence"
evidence = "n/a"
coverage = "none"
gap = "Organisational measure — document in the deployer's AI governance handbook"

[[controls]]
id = "AIA-4"
clause = "Art. 4"
requirement = "AI literacy of staff dealing with operation and use"
mechanism = "none"
leanctx = "Training obligation, not technically enforceable"
evidence = "n/a"
coverage = "none"
gap = "Organisational measure"
