Data Governance & Privacy Operations
This guide describes the operational controls shipped with IMCore Ultimate: a reviewed data inventory, access/export and erasure request workflows, legal holds, configurable retention, audit evidence, and a fail-closed execution mode.
It is a capability and operations guide, not a certification or legal opinion. A self-hosted operator normally determines the purposes and means of processing in its deployment and remains responsible for notices, lawful bases, request authentication, processor contracts, cross-border transfers, retention choices, incident response, and local legal review.
Capability map
| Area | Purpose | Primary storage | Subject lookup | Built-in action |
|---|---|---|---|---|
| Profiles and directory | Display identity and enterprise directory | chat_user_profiles, enterprise_members |
user_id |
Export; delete |
| Social graph | Friends, blocks, whitelist and memberships | relationship, group and community tables | participant/user columns | Export; delete |
| Messages | DM, room, group and community delivery/history | message tables | indexed sender columns | Export authored rows; pseudonymise authorship |
| Device delivery | Push delivery and retries | push_devices, push_tasks |
user_id |
Redacted export; delete; timed retention |
| Moderation | Safety decisions and incident review | chat_moderation_logs |
user_id, target_user_id |
Export; delete; timed retention |
| AI usage | Message/tool audit and memory | AI audit/memory tables | user_id |
Export; delete; timed retention |
| Administrator evidence | Accountability and incident review | admin_audit_logs |
target metadata | Timed retention |
| Governance evidence | Requests, holds and retention runs | data_subject_requests, data_legal_holds, data_retention_runs |
subject_user_id |
Case history and run evidence |
The admin console shows the same code-reviewed catalogue at System → Data Governance. Reconcile it with deployment-specific systems that IMCore cannot discover, including object-storage buckets, CDN caches, database replicas, backups, log platforms, analytics stores, support tools and downstream processors.
Safe deployment
-
Apply
20260710_create_data_governance.sqland20260818_complete_data_governance.sqlwith the migration runner:make migrate bin/migrate -status bin/migrateThe completion migration creates scoped message-retention policies, archive manifests, erasure markers, legal-hold scopes, and immutable audit-chain state/triggers. Apply the matching file from
migrations/mysql/ormigrations/postgres/.The migration backfills sender indexes for historical DM and both room-history copies. On large message tables, back up first, estimate locking/runtime and use a maintenance window; pass
bin/migrate -timeout 1h(or a reviewed value) when the default 10-minute migration timeout is insufficient. -
Grant
governance:readonly to reviewers andgovernance:writeonly to authorised privacy/security operators. Built-in superadmins have both; an operations role does not receive them automatically. -
Keep destructive execution disabled while policies and the runbook are reviewed:
governance: execution_enabled: false pseudonym_salt: "" requests: default_due_days: 30 retention: scheduler_enabled: false interval_hours: 24 batch_size: 1000 -
Store the stable pseudonym key outside source control, for example
IMCORE_GOVERNANCE_PSEUDONYM_SALT. Losing or changing it makes pseudonyms inconsistent; exposing it weakens pseudonym separation. Back it up as a production secret and rotate only through a reviewed migration plan. -
Run retention previews, sample the eligible records, test restoration and downstream deletion, and obtain policy/legal approval.
-
Only then set
IMCORE_GOVERNANCE_EXECUTION_ENABLED=true. EnableIMCORE_GOVERNANCE_RETENTION_SCHEDULER_ENABLED=trueseparately after manual runs are accepted.
Both erasure and retention are fail-closed. Erasure requires the execution flag and pseudonym salt. Scheduled deletion requires both the scheduler and execution flags. The scheduler does not run immediately at startup.
Subject-request workflow
- Intake and identity verification: authenticate the requester outside IMCore; register an
accessorerasurecase with its source, reason and due date. Do not place identity documents in the free-text reason field. - Review: confirm scope, identity, legal basis/approval authority, exceptions and active disputes. Approval requires a legal-basis/authority note; rejection requires a review note.
- Legal hold check: create a subject legal hold before review if litigation, investigation, fraud, security or another preservation duty may apply. An active, unexpired hold blocks erasure and excludes subject-linked rows from retention.
- Execute: first deactivate the source business account and revoke its client tokens so data cannot be recreated, then type the exact subject user ID. Access builds a fresh structured JSON export. Erasure force-logs-out current IMCore sessions, deletes directly owned records and replaces retained message authorship/conversation identifiers with a deterministic pseudonym.
- Deliver and close: transfer exports through an authenticated, time-limited channel outside IMCore. Record delivery, decision correspondence and any residual-system work in the organisation’s case system.
Exports set Cache-Control: no-store, redact push credentials, and include an
attachment manifest (object_key, thumbnail) without presigned URLs. The
export endpoint is still sensitive: reverse proxies, browser downloads and
operator workstations must enforce suitable controls.
Erasure boundaries
Built-in erasure covers the database tables listed in the inventory, records a
durable data_erasure_markers row for every discovered attachment, deletes
objects through the configured object store, and makes a best-effort Redis
cache purge. Failed object deletions remain replayable with
governance -command replay-erasure. It deliberately does not perform
substring replacement inside free-form message text because doing so could
corrupt other participants’ records and produce false matches.
Before closing a case, separately account for:
- attachments, thumbnails and recordings in S3/OSS/MinIO/local object storage;
- database replicas, search indexes, data warehouses, analytics and log/SIEM systems;
- broker queues, dead-letter queues and offline exports;
- backups and snapshots, including the point at which data ages out and how restoration re-applies tombstones;
- downstream processors, integrations and customer business systems;
- external identity/account systems and any credential that could reconnect and recreate the subject;
- free-form content in which another person mentioned the subject;
- statutory or contractual records retained under a documented exception.
A practical backup policy is to prevent normal access to erased data, expire it on the documented backup schedule, restrict restores to authorised incidents, and re-run approved erasure tombstones immediately after a restore.
Retention policies
Message retention, archive and restore
Message policy scope is version, session, or group; scene can narrow it
to DM, room, group, community, or all messages. The active version is selected
by governance.message_retention.version (default default). A matching
session/group policy overrides the version policy. Rows older than hot_days
are serialized to governance/message-archives/ in the configured object
store with SHA-256 manifests before hot rows are deleted. Set
governance.archive.enabled=true for execution and use archive.storage_class
for the provider’s cold-tier class. Related group audiences, community
mentions and message receipts are included in v2 archive envelopes.
Use governance -command retention for JSON evidence and
governance -command restore-archive -archive-id <id> for a controlled restore.
The example defaults are deployment templates, not legal recommendations:
| Policy key | Default | Scope |
|---|---|---|
admin_audit_days |
365 days | Admin audit logs |
moderation_logs_days |
180 days | Moderation evidence |
ai_message_audit_days |
180 days | AI message audit |
ai_tool_audit_days |
90 days | AI tool-call audit |
push_tasks_days |
30 days | Push task history |
governance_requests_days |
1095 days | Finalised subject-request evidence |
legal_holds_days |
1095 days | Released or expired legal-hold evidence; effective holds are never eligible |
retention_runs_days |
1095 days | Completed retention-run evidence |
Set a policy to 0 to disable it. Every manual or scheduled run records its policy snapshot, mode, status, summary, actor and timestamps in data_retention_runs. Always preview after policy or schema changes. Legal holds protect only policies with a configured subject column; infrastructure-wide audit evidence may require separate case tagging and preservation procedures.
API and audit surface
The admin JWT and RBAC-protected endpoints live under /admin/api/governance:
GET /overviewGET|POST /requests,GET /requests/{id}POST /requests/{id}/review,POST /requests/{id}/execute,GET /requests/{id}/exportGET|POST /legal-holds,POST /legal-holds/{id}/releasePOST /retention/runGET|PUT /message-retention-policies,DELETE /message-retention-policies/{id}GET /message-archives,POST /message-archives/{id}/restore
Audit integrity is available at GET /admin/api/audit-logs/integrity and via
governance -command verify-audit. It reports signed, legacy and failed-chain
evidence; database triggers reject audit UPDATE/DELETE.
The complete request/response contract is embedded in controllers/openapi/service.openapi.yaml and served by the service at /openapi.yaml and /openapi.json. Mutations and subject exports pass through admin audit capture. Keep audit access independent from request execution where staffing permits.
Regulatory capability mapping
This mapping helps a reviewer locate product controls; it does not determine applicability or prove compliance.
- China’s Personal Information Protection Law provides rights and processing obligations around access/copy, correction, deletion and convenient request mechanisms in Articles 45–50. IMCore’s access/export, reviewed erasure, due dates and evidence workflow support the access and deletion portions; correction still uses the existing profile/business-system APIs under the operator’s case process. See the official CAC text.
- GDPR Article 5 includes data minimisation, storage limitation and accountability; the inventory, retention previews and run evidence support those operational principles. See official Article 5.
- GDPR Article 15 addresses access and copies, which the structured export can support. See official Article 15.
- GDPR Article 17 defines erasure rights and exceptions; the approval, legal-hold and pseudonymisation workflow supports implementation without deciding whether a request must be granted. See official Article 17.
Release and incident checklist
- Review the inventory whenever a table, message field, storage provider or processor is added.
- Run
make secret-check; keep real keys out of tracked files and build artifacts. - Rotate any credential that was ever committed. Removing it from the current tree does not revoke it or remove it from Git history; coordinated history rewriting is a separate operation.
- Test access, hold, erasure and retention paths in a production-like environment with synthetic users.
- Verify permissions, audit records, TLS, proxy caching, download handling and operator endpoint security.
- Document backup expiry, restore-time tombstone replay, processor notifications and incident ownership.
- Have counsel/privacy reviewers approve the final policy values, notices and exception handling for each deployment.