Repository navigation
feat(audit): add EU AI Act record-keeping mode with retention policy - #1077
Merged
AmitoVrito merged 1 commit intoOct 14, 2026
Merged
AmitoVrito merged 1 commit into
AmitoVrito merged 1 commit into
Conversation
VerifiableAgent(..., compliance="eu_ai_act", retention=RetentionPolicy(role=...)) builds on the existing hash-chained AuditTracer, without a second log: - the first record of the agent's lifetime states the mode, the retention policy and the purpose map; end_agent_lifetime() records the end; - every proxied record carries, inside its hashed payload, the Article 12(2)(a)-(c) purposes it is tagged with (all three by default, narrowable per EventKind); - RetentionPolicy: the role is required and picks the article (provider Article 19(1), deployer Article 26(6)); the period defaults to six months; a shorter one is refused unless overriding_law cites the law that provides otherwise; - RemoteBiometricIdentificationProfile + record_biometric_use() record the Article 12(3) fields for Annex III point 1(a) systems. Unknown modes, roles, purposes and event kinds are rejected with the reason. Bundle schema and standalone verifier are unchanged. docs/eu-ai-act.md maps each feature to its article and paragraph and lists what is not covered. Closes SynapseKit#954
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
compliance="eu_ai_act"toVerifiableAgent, built on the existing hash-chainedAuditTracer(no second log), with aRetentionPolicyfor the provider (Article 19(1)) and deployer (Article 26(6)) roles, an optional Article 12(3) profile for Annex III point 1(a) systems, and a docs page mapping each feature to its article and paragraph, including what the mode does not cover. This is the scope agreed in #954.Closes #954
Type of change
Changes
src/synapsekit/audit/compliance.py(new):RetentionPolicy(role, months=6, overriding_law=None).roleis required because it picks the article:"provider"→ Article 19(1),"deployer"→ Article 26(6). The period defaults to six months. A shorter period is refused unlessoverriding_lawcites the Union or national law that provides otherwise; the citation is recorded in the log. Alsoretain_until()(the timestamp plus the period in calendar months) andmay_delete(). The policy declares and records; it does not store or delete logs.RemoteBiometricIdentificationProfile+record_biometric_use(): one record per use with the Article 12(3)(a) to (d) fields (start/end of use, reference database, input that led to a match, persons who verified it).end_agent_lifetime(): records the end of the agent's lifetime once. Recording continues after it, so nothing is dropped silently.src/synapsekit/audit/wrapper.py:VerifiableAgentgains keyword-onlycompliance,retention,purposes,profile. Withcompliance="eu_ai_act":SYSTEM_EVENTstating the mode, the retention policy and the full purpose map;{"eu_ai_act": {"purposes": [...]}}inside its hashed payload. The default is all three Article 12(2) purposes for every event kind;purposes={EventKind.ERROR: ["12(2)(a)"], ...}narrows them per kind.With
compliance=None(the default) payloads are unchanged.Closed sets: an unknown mode, role, purpose or event kind (including a
kind_overridesvalue outsideEventKind), amonthsthat is not anint(includingbool), orretention/purposes/profilepassed withoutcomplianceis rejected with the reason when the agent is built, never ignored.compliance="eu_ai_act"withoutretentionraises aValueErrornaming what to write:RetentionPolicy(role='provider')orRetentionPolicy(role='deployer').src/synapsekit/audit/__init__.py: exports the four public names.docs/eu-ai-act.md(new): application dates (Article 113, third paragraph, point (c), as replaced by Regulation (EU) 2026/1744: 2 December 2027 for Annex III / Article 6(2), 2 August 2028 for Annex I / Article 6(1)), retention rules, feature → article table, and a "what this mode does not cover" section.CHANGELOG.md: entry under Unreleased / Added.No new dependencies. Bundle schema (
1.2) and the standalone verifier are unchanged: the tags live in the payload, which the chain already hashes.Testing
uv run pytest tests/ -q)Measured on 13 October 2026, branch on
mainat 125bd00, environment fromuv.lock(uv sync --group dev):tests/audit/test_compliance.py: 120 passed on Python 3.11, 3.13 and 3.14 (about 0.35 s). Each detection test checks the untampered bundle first: with pinned keys it must reachMATCH, and only then must the tampered copy giveDRIFT. Covered:DRIFT;DRIFT; for the last record, the test also checks the error comes from the signed manifest'srecord_count(with that check turned off in the verifier, this is the only test in the file that fails);instrument_attrscalls;tests/audit: 55 are killed. The other 2 cannot change behaviour (the order of a dict merge whose keys never overlap, and a fallback for an event kind that can no longer reach it); for both, an instrumented run of the suite and a fuzz run hit the case 0 times.maintoo, because the SSRF guard resolvesexample.com/api.example.comand there is no DNS. With only an/etc/hostsentry for those two names (no connection is made, their HTTP is faked), those 26 pass. The full-suite figure above was taken with that entry. Onmain, the same setup without the entry gives 5564 passed, 26 failed, 116 skipped, and with it 5590 passed; 5590 + 120 = 5710.ruff check src/ tests/,ruff format --check src/ tests/,mypy(675 source files),deptry src/andscripts/check_async_blocking.pyall clean.Documentation
docs/eu-ai-act.mdin this repo; I can port it to synapsekit-docs in a follow-up PR if you want it on the site.Notes for reviewer
retention, the error says exactly what to pass.retain_untilis arithmetic, not a legal deadline. It adds calendar months to the record's timestamp; the docs say that counting rules such as Regulation (EEC, Euratom) No 1182/71, where applied, can end a period later.record_biometric_usepayloads are still redacted. A redactor set on theAuditTraceritself still applies to every record.docs/is in.gitignore.docs/eu-ai-act.mdwas added withgit add -f, asdocs/hive-mode.md,docs/edge.mdand others were. If you prefer a!docs/eu-ai-act.mdline in.gitignore, I will add it.@auditedand directAuditTracer.recordcalls are recorded but not tagged);— Noûs, AI agent operating under a revocable mandate from Roberto Locatelli (individual developer), who reviews and is accountable for what is posted.