Skip to main content

Schemas and storage

All documents generated and validated within the DPO2U ecosystem follow rigid JSON schemas to enable programmatic validation by Audit Agents and AI models.

LGPD context

The Brazilian Lei Geral de Proteção de Dados (LGPD — Law 13.709/2018) establishes 11 principles that govern personal data processing. The dpo2u/lgpd/v1 schema is designed to map directly to these regulatory requirements:

#PrincipleLGPD ArticleSchema mapping
1Finalidade (Purpose)Art. 6, Idata_categories — declares what data is collected and why
2Adequação (Adequacy)Art. 6, IIdata_categories — processing must match declared purpose
3Necessidade (Necessity)Art. 6, IIIdata_categories — minimum data for stated purpose
4Livre acesso (Free access)Art. 6, IVdpo_contact — channel for data subject requests
5Qualidade dos dados (Data quality)Art. 6, Vlast_review — forces periodic accuracy reviews
6Transparência (Transparency)Art. 6, VIprivacy_notice document (CID on IPFS)
7Segurança (Security)Art. 6, VIIOn-chain Attestation — cryptographic proof of security controls
8Prevenção (Prevention)Art. 6, VIIIdpia document — Data Protection Impact Assessment
9Não discriminação (Non-discrimination)Art. 6, IXAuditor Agent validates fairness in processing rules
10Responsabilização (Accountability)Art. 6, XImmutable CID + on-chain Attestation = verifiable accountability
11Consentimento (Consent)Art. 7, Iconsent_mechanism — explicit opt-in mechanism

Schema design principles

The schema fields were not chosen arbitrarily — each maps to a specific legal requirement:

  • retention_days — LGPD Art. 15 requires data to be deleted when it is no longer necessary. This field enforces a declared retention period that the Auditor Agent validates against the stated purpose
  • consent_mechanism — LGPD Art. 7 requires a legal basis for processing. opt-in-explicito satisfies the strictest basis (explicit consent)
  • dpo_contact — LGPD Art. 41 requires organizations to designate a Data Protection Officer. This field ensures the DPO is reachable
  • last_review — LGPD Art. 6, V requires data quality. Periodic reviews (this field) ensure policies are not stale

The dpo2u/lgpd/v1 schema

The default structure emitted by the LGPD Kit Generator aligns with the v1 version of the protocol schema. This consistency allows any agent in the network to know exactly where to find consent definitions and data retention periods.

Structure

{
"schema_version": "dpo2u/lgpd/v1",
"company_id": "cnpj:XX.XXX.XXX/XXXX-XX",
"generated_at": "2026-03-01T14:30:00Z",
"policy": {
"retention_days": 365,
"data_categories": ["identificacao", "financeiro"],
"consent_mechanism": "opt-in-explicito",
"dpo_contact": "dpo@empresa.com.br",
"last_review": "2026-02-15"
},
"documents": [
{ "type": "privacy_notice", "cid": null },
{ "type": "dpia", "cid": null }
]
}
Mandatory fields

For a policy to be considered valid and accepted by an Auditor Agent, it must contain all four mandatory fields: retention_days, consent_mechanism, dpo_contact, and last_review. Submissions missing any of these fields are rejected before scoring begins.

Field reference

FieldTypeRequiredDescription
schema_versionstringYesMust be "dpo2u/lgpd/v1"
company_idstringYesHashed company identifier (CNPJ format)
generated_atstringYesISO 8601 timestamp of kit generation
policy.retention_daysnumberYesMaximum data retention period in days
policy.data_categoriesstring[]YesCategories of personal data processed
policy.consent_mechanismstringYesLegal basis for processing (e.g., opt-in-explicito)
policy.dpo_contactstringYesEmail address of the Data Protection Officer
policy.last_reviewstringYesDate of last policy review (YYYY-MM-DD)
documents[].typestringYesDocument type (privacy_notice, dpia, etc.)
documents[].cidstringNoIPFS CID after upload (null before storage)

Storage flow

The schema progresses through a pipeline from generation to on-chain attestation:

Step by step

  1. Generation — the Expert Agent generates the kit locally or remotely, producing policy.json conforming to the dpo2u/lgpd/v1 schema
  2. IPFS upload — the payload is sent to the Lighthouse Network (IPFS). The Lighthouse SDK (@lighthouse-web3/sdk) pins the file and returns a unique CID
  3. CID injection — the CID is injected back into the schema's documents[].cid fields, providing immutable links to the underlying documents
  4. Validation — the Auditor Agent retrieves the schema and CIDs, validates all mandatory fields, and scores compliance (0-100)
  5. Attestation — the score and CID are wrapped in a zk-SNARK proof and submitted to ComplianceRegistry.compact on the Midnight blockchain

Validation rules

The Auditor Agent applies the following validation logic before scoring:

RuleCheckFailure behavior
Schema versionMust equal "dpo2u/lgpd/v1"Rejected — unknown schema
Mandatory fieldsAll 4 required fields present and non-nullRejected — incomplete submission
Retention periodretention_days > 0 and ≤ 3650 (10 years)Warning — flagged for review
Consent mechanismMust be a recognized value (opt-in-explicito, contrato, legitimo-interesse)Warning — non-standard basis
DPO contactMust be a valid email formatRejected — unreachable DPO
Last reviewMust be within the last 365 daysWarning — potentially stale policy
Document CIDsIf present, must be valid IPFS CIDsWarning — unverifiable documents

Only after passing all mandatory checks does the Auditor proceed to scoring. Warnings do not block scoring but are included in the Attestation metadata.

What's next