Home / Wiki / Aequora Sync — Part 14

Aequora Sync — Part 14

Data Governance, Retention, Legal Hold, Erasure, and Lifecycle Architecture

Repository status (2026-08-21): Complete at the reusable framework boundary. See docs/data-governance-retention-erasure-completion.md for code, lifecycle verification, adapter, operational, and deployment evidence.

1. Purpose

Aequora is designed for long-lived business systems.

Over time, synchronized data accumulates across:

authoritative databases
client replicas
journal history
operation ledgers
audit trails
snapshots
repair artifacts
imports
exports
blob storage
cold archives

A mature system must answer:

How long should each class of data exist?
When may it be deleted?
What if an offline client has not seen a tombstone yet?
What if a legal hold blocks deletion?
How should a tenant be offboarded?
How should privacy erasure work without corrupting financial/audit history?
How do we prove cleanup was safe?

This requires an explicit lifecycle architecture.

The central rule is:

Data deletion is a coordinated distributed lifecycle transition, not a simple SQL DELETE.


2. Goals

The governance subsystem should provide:

retention policies
legal hold
safe tombstone garbage collection
privacy erasure
tenant offboarding
scope-aware deletion
snapshot/archive lifecycle
operation-ledger retention
audit retention
blob lifecycle
client cleanup
proof of safe purge
operator tooling

3. Non-Goals

Aequora core should not hardcode:

country-specific legal retention durations
industry-specific compliance durations
tax retention periods
medical record law

Those belong to application/tenant policy.

Aequora provides the mechanics.


4. Data Classes

At minimum distinguish:

AuthoritativeBusinessData
JournalHistory
OperationLedger
AuditTrail
ConflictRecords
Tombstones
Snapshots
ReplayArtifacts
ImportArtifacts
RepairArtifacts
Blobs
ClientReplicaData
DerivedCaches

Each has different lifecycle semantics.


5. RetentionClass

Define:

pub struct RetentionClassId(u16);

Application registry maps domain objects to retention classes.


6. RetentionPolicy

Conceptually:

pub struct RetentionPolicy {
    pub class: RetentionClassId,
    pub minimum_retention: DurationPolicy,
    pub maximum_retention: Option<DurationPolicy>,
    pub deletion_mode: DeletionMode,
    pub legal_hold_eligible: bool,
    pub archive_before_delete: bool,
}

7. DeletionMode

pub enum DeletionMode {
    HardDeleteWhenSafe,
    TombstoneThenGc,
    Pseudonymize,
    CryptographicErase,
    PermanentByPolicy,
}

8. PermanentByPolicy

Use sparingly.

Examples may include legally required immutable evidence.

Even then, policy may permit:

PII minimization
pseudonymization

while preserving business evidence.


9. Lifecycle States

A governed record may move through:

Active
SoftDeleted
Tombstoned
Archived
Held
ErasurePending
Purged

Not every data class uses every state.


10. Tombstone Purpose

A tombstone is a synchronization artifact.

It tells replicas:

this entity existed
it is now deleted
do not resurrect stale state

Tombstones must survive long enough for relevant clients.


11. Safe Tombstone GC

Never delete tombstone solely because:

30 days passed

if offline clients may still legitimately reconnect with old state.

Need a safety condition.


12. Device Watermarks

Track per device/scope:

last acknowledged cursor
last seen at
status

This helps determine which clients have crossed a deletion boundary.


13. Tombstone GC Condition

Conceptually safe when:

all active retained client watermarks > tombstone sequence
OR
those clients have been retired/revoked
AND
snapshot/bootstrap policy guarantees stale clients cannot resume below retained floor

14. Retired Device

A device can be marked:

Retired
Revoked
Expired

Such devices no longer block tombstone GC.

If they reconnect:

must rebootstrap

15. Device Retention Horizon

Define policy:

if device inactive > X
    mark requires rebootstrap

Then it no longer pins old journal/tombstones indefinitely.


16. Rebootstrap Floor

Server maintains per scope/generation:

minimum resumable cursor

Below that:

ResyncRequired

This is a key lifecycle control.


17. Journal Retention

Journal need not be infinite.

Retention determined by:

active client cursors
snapshot availability
legal/audit needs
replay needs
storage budget

18. Journal GC Rule

Delete journal events only when:

no valid client needs them
AND
snapshot/bootstrap can recover clients below floor
AND
no governance hold requires them

19. Operation Ledger Retention

Operation ledger supports:

idempotency
retry ambiguity
support
replay

Do not delete entries too soon.


20. Idempotency Horizon

Define a minimum ledger retention at least covering:

maximum legitimate retry window
offline duration policy
client resurrection window

21. Old Operation Retry

If ledger entry is gone and an ancient client retries old OperationId:

server must not blindly execute

Possible:

OperationTooOld
RebootstrapRequired
UnsupportedRetryWindow

22. Ledger Compaction

Old ledger records may be compacted to:

OperationId
semantic payload hash
final outcome code
committed sequence

instead of retaining large response payloads forever.


23. Audit Retention

Audit retention is separate from journal retention.

Business audit may need to outlive sync journal by years.


24. Audit vs Erasure Tension

Privacy erasure may request removal of personal data while accounting/audit evidence must remain.

Solution is often:

remove nonessential PII
pseudonymize identity
retain required business evidence

rather than deleting all records indiscriminately.


25. Legal Hold

Define:

pub struct LegalHoldId(Uuid);

Legal hold prevents governed deletion for matching records.


26. LegalHold

Conceptually:

pub struct LegalHold {
    pub hold_id: LegalHoldId,
    pub tenant_id: TenantId,
    pub selector: HoldSelector,
    pub reason_code: HoldReasonCode,
    pub created_at: Timestamp,
    pub created_by: PrincipalId,
    pub state: HoldState,
}

27. HoldSelector

May target:

entity
aggregate
user
case
date range
audit category
tenant
custom legal matter

28. Hold Application

Before purge:

retention worker checks active holds

Held records transition to:

Held

or are simply excluded from deletion.


29. Hold Immutability

Creating/releasing a legal hold is itself:

security/admin audited

30. Hold Release

Release requires:

authorized action
reason
audit event

Then normal retention evaluation resumes.


31. Erasure Request

Define:

pub struct ErasureRequestId(Uuid);

State machine:

Requested
↓
Validated
↓
Planned
↓
BlockedByHold / Ready
↓
Executing
↓
Verified
↓
Completed

32. Erasure Is Not Immediate Blind Delete

First determine:

what data belongs to subject
what must be retained
what can be anonymized
what blobs exist
what replicas exist
what legal holds apply

33. Erasure Planner

Produces explicit:

pub struct ErasurePlan {
    pub request_id: ErasureRequestId,
    pub subject: DataSubjectRef,
    pub actions: Vec<ErasureAction>,
    pub blockers: Vec<ErasureBlocker>,
}

34. ErasureAction

pub enum ErasureAction {
    DeleteEntity,
    PseudonymizeFields,
    RemoveBlob,
    RevokeScope,
    PurgeReplayArtifact,
    CompactAuditIdentity,
    RotateEncryptionKey,
}

35. Pseudonymization

Example:

StudentName = "Deleted User 7F2A"
phone = null
email = null

while retaining:

invoice amount
ledger evidence
transaction dates

where policy requires.


36. Stable Pseudonym

Use a deterministic or managed pseudonymous identifier where cross-record linkage must remain.

Avoid reversible mapping unless policy requires.


37. Cryptographic Erasure

For encrypted data grouped under subject/tenant key:

destroy encryption key

can render data unrecoverable.

Useful for:

large blob sets
archives

38. Cryptographic Erasure Caveat

Only valid if:

no plaintext copies
no duplicate unencrypted backup
no shared key with retained data

Key architecture must support proper isolation.


39. Blob Lifecycle

Blob references need separate governance.

When entity deleted:

blob may still be referenced elsewhere

Use reference tracking.


40. Blob GC

Delete blob only when:

reference count / reachability = zero
AND
retention elapsed
AND
no legal hold

41. Content-Addressed Blob Dedup

If same blob is referenced by multiple tenants/users:

physical dedup complicates erasure

Need per-owner encryption/key wrapping or logical reference accounting.


42. Safer Multi-Tenant Blob Policy

Prefer:

tenant-scoped encryption
tenant-scoped object namespace

even if physical dedup is reduced.

Governance simplicity often outweighs maximum dedup.


43. Snapshot Lifecycle

Snapshots can contain deleted/erased data.

Therefore snapshot retention must participate in governance.


44. Snapshot Purge

If erasure requires removing data from retained snapshots:

Options:

expire old snapshot
build sanitized replacement
cryptographic erase snapshot key

45. Immutable Snapshot Problem

Object-storage snapshots are immutable by design.

Therefore either:

short retention
encrypted per retention domain
or
allow governance-triggered object deletion

must be planned.


46. Backup Tension

Backups may contain erased data.

Application/legal policy decides whether:

backups expire naturally
restore procedure reapplies erasure ledger

This is common and practical.


47. Erasure Ledger

Maintain durable record of completed erasure subjects.

After PITR restore:

replay erasure ledger

before restoring service.


48. Erasure Ledger Content

Store minimal:

ErasureRequestId
subject pseudonymous ref
completion time
policy version

Do not preserve erased PII.


49. Restore Safety

After restore from old backup:

system enters restricted mode
↓
reapply post-backup erasures/revocations
↓
verify
↓
serve traffic

50. Tenant Offboarding

Tenant lifecycle:

Active
Suspended
ReadOnly
ExportPending
DeletionScheduled
Held
Purging
Purged

51. Offboarding Flow

disable new writes
↓
allow/export tenant data
↓
revoke clients/devices
↓
wait grace period
↓
apply legal holds
↓
purge live data
↓
purge snapshots/blobs
↓
purge credentials
↓
retain permitted audit evidence
↓
verify

52. Read-Only Grace Period

Useful before deletion.

Tenant can:

export
review
settle billing

without creating new state.


53. Device Revocation

Before tenant purge:

revoke all devices/scopes

Offline devices may still physically contain local copies.


54. Offline Client Data

Server cannot remotely guarantee immediate deletion on an offline uncontrolled device.

Mitigations:

local encryption
credential expiry
app local purge on reconnect
remote wipe integration
OS-managed storage

Document this limitation honestly.


55. Local Purge Command

On reconnect after revocation:

server returns PurgeRequired

client removes affected local scope/store according to policy.


56. Local Purge Proof

Client may send:

PurgeAcknowledgement

after successful deletion.

Useful operationally, but not absolute proof against malicious devices.


57. Scope Contraction

Part 07 scope eviction is a data lifecycle event.

If data no longer authorized:

evict from local replica

even if server entity remains active.


58. Scope Cache TTL

Inactive authorized scope may be cached.

Revoked scope should follow stronger purge policy.


59. Derived Cache Lifecycle

Derived caches can usually be deleted aggressively.

They do not block legal retention because source data remains authoritative.


60. Conflict Record Retention

Conflicts may contain stale sensitive values.

After resolution:

retain minimal metadata
purge full payload after configured period

unless audit/legal policy requires longer.


61. Repair Artifact Retention

Repair bundles can contain canonical data.

Default:

short retention

and strong access controls.


62. Replay Artifact Retention

Part 12 replay bundles may duplicate sensitive state.

Apply:

windowed retention
encryption
legal hold
erasure

63. Import Artifact Retention

Part 09 source files/quarantine rows may contain PII.

Delete once:

migration verified
retention window elapsed
no legal hold

64. Export Lifecycle

Exports are high-risk because they create copies outside primary database.

Track:

who exported
where stored
expiry
deletion status

65. Export Expiry

Generated export URLs/files should have:

short TTL

unless explicitly archived.


66. Data Copy Registry

High-assurance mode can track governed copies:

Snapshot
Export
ReplayBundle
ImportSource
ColdArchive

This improves erasure planning.


67. CopyRef

Conceptually:

pub struct GovernedCopyRef {
    pub kind: GovernedCopyKind,
    pub location: OpaqueStorageRef,
    pub retention_class: RetentionClassId,
}

68. Avoid Absolute File Paths in Domain Metadata

Use opaque storage references.


69. Retention Evaluation

A background worker periodically evaluates eligible data.

Pipeline:

select candidate
↓
check minimum retention
↓
check hold
↓
check client watermark / sync safety
↓
check references
↓
plan delete/archive/pseudonymize
↓
execute
↓
verify

70. Retention Worker Is Durable Job

Do not run large purge synchronously in API request.

Part 23 will formalize durable background work.


71. Retention Checkpoint

Large purge job stores progress.

Restart-safe.


72. Deletion Idempotency

Deleting same candidate twice should be harmless.

Use:

stable purge action IDs

where needed.


73. PurgePlan

pub struct PurgePlan {
    pub purge_id: PurgeId,
    pub policy_version: RetentionPolicyVersion,
    pub candidates: Vec<PurgeCandidate>,
}

74. Dry Run

CLI should support:

aequora retention plan --dry-run

Show:

records eligible
records held
journal floor impact
snapshots affected
blobs affected

75. RetentionPolicyVersion

Define:

pub struct RetentionPolicyVersion(u32);

Every purge records which policy caused it.


76. Policy Changes

Changing retention policy must not retroactively purge immediately without evaluation.

Use:

plan
preview
execute

for destructive changes.


77. Shortening Retention

Potentially high-risk.

Require:

admin authorization
dry-run
audit

78. Lengthening Retention

Safer, but increases storage and legal exposure.

Also audit policy change.


79. Legal Hold Precedence

Rule:

active legal hold > normal retention deletion

80. Erasure vs Legal Hold

If erasure request conflicts with legal hold:

block or partially pseudonymize according to policy

Never silently violate either requirement.


81. ErasureBlocker

Examples:

LegalHold
RequiredFinancialRetention
OpenDispute
PendingExport
ActiveMigration

82. Human Review

Some erasure plans may require manual approval.

Architecture should support:

ReadyForApproval

state.


83. Automatic Erasure

Simple low-risk data classes can be automated after validation.


84. Data Subject Mapping

Need to know which records belong to a person.

Applications should define:

pub trait DataSubjectResolver {
    async fn resolve(
        &self,
        subject: DataSubjectRef,
    ) -> Result<DataSubjectGraph, GovernanceError>;
}

85. DataSubjectGraph

Contains:

owned entities
referenced entities
shared entities
blobs
audit refs
exports

with action policy per relation.


86. Shared Entity

Example:

invoice references student

Cannot delete invoice if retention requires it.

Instead:

pseudonymize student-identifying fields
retain invoice

87. Ownership Semantics

Do not infer ownership from foreign keys generically.

Application defines governance relationship.


88. GovernanceRelation

pub enum GovernanceRelation {
    Owned,
    Referenced,
    Shared,
    Derived,
    AuditOnly,
}

89. Cascades

Avoid uncontrolled DB ON DELETE CASCADE for governed erasure if it can delete records whose retention differs.

Use explicit purge planning.


90. Hard Delete

Hard delete is final physical removal.

Use only after:

sync safety
hold check
retention check
reference check

91. Tombstone Then GC

For synced entities:

business delete
↓
tombstone
↓
clients observe delete
↓
watermark floor advances
↓
tombstone eligible for GC

92. Tombstone Metadata

Include:

entity
version
deletion sequence
deletion time
retention class

93. Resurrection Guard After GC

If tombstone removed, stale client must not be allowed to upload old update as resurrection.

Mechanisms:

minimum client generation
entity identity retirement registry
operation age/cursor checks

94. Retired Entity Identity

For high-risk domains, keep compact:

RetiredEntityId

record longer than full tombstone.

This prevents accidental reuse/resurrection.


95. Identity Reuse Rule

Never reuse old EntityId for a new logical entity.


96. Deletion Epoch

Optional:

EntityDeletionEpoch

or generation can help detect stale resurrection attempts.


97. Journal Floor

Maintain:

pub struct JournalFloor {
    pub scope_id: ScopeId,
    pub generation: ScopeGeneration,
    pub min_sequence: Sequence,
}

98. Client Below Floor

Response:

CursorExpired
ResyncRequired

Never try to continue incrementally.


99. Snapshot Floor Coordination

Before raising journal floor:

ensure valid bootstrap snapshot exists

for active scope generation.


100. Retention and Snapshot Lease

Part 10 active snapshot lease pins required journal range.

GC must respect it.


101. Retention and Anti-Entropy

Part 03 anti-entropy may require historical tombstone/identity metadata.

GC policy should preserve enough to distinguish:

missing
deleted
never existed

within supported horizon.


102. Retention and Replay

Part 12 replay retention policy may pin:

operation ledger
handler metadata
pre-state artifacts

103. Retention and Audit

Part 13 audit retention may be much longer than business entity retention.

Audit record can survive after entity deletion with pseudonymized subject.


104. Audit Subject After Erasure

Use:

stable pseudonymous subject ref

instead of raw personal identifier.


105. Retention and Live Sync

Part 08 live hints have no durable retention requirement.


106. Retention and Multi-Process

Part 05 local coordinator manages local purge jobs.

Only leader executes governed local cleanup for shared store.


107. Local Store Retention

Client may locally retain less data than server.

Policy examples:

30 days recent
current academic year
active scopes only

108. Local Retention vs Scope

Local cache policy cannot override security revocation.


109. Local Purge State Machine

Planned
↓
WaitingForSafePoint
↓
Purging
↓
RebuildingIndexes
↓
Complete

110. Pending Operations

Do not purge local entity needed by pending operation without explicit handling.


111. Pending Operation Erasure

If subject erasure requires removing pending local intent:

cancel/quarantine operation

according to policy.

If operation may already have reached server:

must reconcile authoritative result first

112. Client Offline Erasure

If device remains offline forever, server cannot guarantee purge.

Therefore enterprise policy may:

expire device credentials
require encrypted local store
mark device noncompliant

113. Encryption at Rest

Strong local encryption supports:

account logout purge
device revocation
cryptographic erase

especially on mobile/desktop.


114. Per-Tenant/Per-Account Keys

Prefer isolated encryption domains.

Destroying one tenant/account key should not affect others.


115. Key Rotation

Governance may trigger:

key rotation

after employee departure/security incident.

Part 15 will define cryptographic key architecture.


116. Archive Lifecycle

Cold archive may retain:

audit
historic finance
closed academic years

while removing from hot DB.


117. Archive Manifest

Store:

archive ID
tenant
retention class
boundary
record counts
hashes
encryption key reference

118. Archive Query

Do not make cold archive transparently writable.

Read through dedicated archive service/tool.


119. Restore From Archive

If record must become active again:

explicit restore operation

with audit/provenance.


120. Archive Does Not Mean Deleted

Retention semantics distinguish:

not in hot DB
but still retained

121. Tenant Purge Verification

After offboarding, verify absence from:

primary DB
journal above required evidence
snapshots
blobs
exports
replay artifacts
import quarantine
cache

except intentionally retained audit/legal evidence.


122. Purge Verification Report

pub struct PurgeVerificationReport {
    pub purge_id: PurgeId,
    pub completed_at: Timestamp,
    pub verified_stores: Vec<StoreVerification>,
    pub retained_exceptions: Vec<RetentionException>,
}

123. Proof Limitations

Verification proves configured stores were checked.

It cannot prove destruction of:

unknown manual copies
external screenshots
malicious device copies

Do not overstate.


124. Governance Inventory

Maintain registry of all known storage surfaces.

Examples:

PrimaryPostgres
ObjectStorage
AuditArchive
SnapshotStore
ExportStore
ClientReplica

125. StorageSurfaceId

pub struct StorageSurfaceId(u16);

126. Governance Adapter

Each storage surface should implement:

pub trait GovernanceStore {
    async fn plan(
        &self,
        request: &GovernanceRequest,
    ) -> Result<StorePlan, GovernanceError>;

    async fn execute(
        &self,
        plan: &StorePlan,
    ) -> Result<StoreResult, GovernanceError>;

    async fn verify(
        &self,
        plan: &StorePlan,
    ) -> Result<StoreVerification, GovernanceError>;
}

127. Fail Closed

If one required storage surface is unreachable:

erasure not marked Complete

unless policy explicitly permits partial completion.


128. Partial Completion

State:

PartiallyCompleted

with outstanding surfaces.


129. Retry

Governance jobs are retryable and idempotent.


130. Governance Correlation

All actions in one erasure/offboarding job share:

CorrelationId

Part 02 lineage links sub-actions.


131. Audit

Every destructive governance action generates administrative/security audit.


132. No Business Audit Explosion

Deleting millions of rows during tenant purge should not necessarily generate one human audit event per row.

Instead:

PurgeJob summary
+
detailed machine manifest

unless legal policy requires item-level records.


133. Retention Manifest

Large purge can produce canonical manifest:

candidate counts
hashes
range IDs
policy
exceptions

134. Tamper Evidence

Governance manifests can be BLAKE3-hashed and optionally signed.


135. Data Minimization

Best governance strategy is to avoid collecting data not needed.

Aequora should encourage:

minimal synchronized fields
minimal audit values
short-lived diagnostics

136. Scope Projection Minimization

Part 07 field projection can prevent unnecessary PII from reaching clients at all.

This reduces erasure surface.


137. Replay Minimization

Part 12 replay policies should prefer digests over full sensitive payload when possible.


138. Logging Minimization

Operational logs should never become hidden long-term PII archives.


139. Metrics

Never place personal IDs or raw data in metric labels.


140. Retention Scheduler

Part 06 QoS:

routine cleanup = Maintenance
security erasure = Critical/Admin

141. Backpressure

Large purge jobs should be throttled to avoid production DB overload.


142. Chunked Purge

Delete in bounded batches.

Example:

1000 records/transaction

depending on DB.


143. Avoid Long Locks

Do not purge millions of rows in one transaction.


144. Index Maintenance

Large deletes can create bloat.

Database-specific adapter/runbook may schedule:

VACUUM
reindex
partition drop

where applicable.

Core governance API stays DB-agnostic.


145. Partition Drop Optimization

If entire historical partition is eligible and unheld:

drop partition

can be efficient.

Only if retention semantics align exactly.


146. Tenant-Partitioned Storage

For SaaS with large tenants, tenant partitioning can simplify offboarding.

But do not redesign schema solely for deletion unless scale justifies it.


147. Cold Storage Encryption

Each archive segment should have:

key reference

so cryptographic erasure is possible where required.


148. Backup Strategy

Backups should have:

finite retention
encryption
restore erasure replay procedure

149. PITR

Point-in-time restore can reintroduce deleted data.

Run governance reconciliation before reopening traffic.


150. Governance Reconciliation

After restore:

load erasure ledger
load revocation ledger
load legal holds
reapply post-restore governance changes
verify

151. Revocation Ledger

Similar to erasure ledger for:

devices
scopes
credentials

if restore could resurrect revoked access.


152. Legal Hold Restore

Legal hold state must be restored before retention worker resumes.


153. Disaster Recovery Order

Recommended:

restore DB
↓
restore governance metadata
↓
reapply erasures/revocations
↓
verify audit/hold state
↓
resume service

154. Policy Registry

Aequora should expose:

retention class
legal hold eligibility
erasure behavior
archive behavior

per aggregate/field.


155. Field-Level Governance

Some fields can be erased independently.

Example:

phone/email

while entity remains.

Define:

FieldGovernancePolicy

156. FieldGovernancePolicy

pub struct FieldGovernancePolicy {
    pub retention_class: RetentionClassId,
    pub erasure: FieldErasureMode,
}

157. FieldErasureMode

pub enum FieldErasureMode {
    Null,
    ReplaceWithPseudonym,
    Hash,
    KeepRequired,
}

158. Schema Migration

If field governance policy changes, migration may be required.

Example:

previously stored raw phone in audit
now hash-only

Need cleanup of historical audit values where legally allowed.


159. Governance CI

Generate report of:

aggregate
field
retention class
audit policy
erasure mode
legal-hold eligibility

160. Missing Policy

Production startup/CI should reject sensitive domain fields with no governance classification if application opts into strict mode.


161. Strict Governance Mode

GovernanceMode::Strict

requires explicit classification for:

synchronized business fields
audit values
blobs

162. Default Governance Mode

For general library usability:

Standard

with conservative defaults.


163. Admin CLI

Suggested:

aequora retention plan
aequora retention execute
aequora legal-hold create
aequora legal-hold release
aequora erasure plan
aequora erasure execute
aequora erasure verify
aequora tenant offboard
aequora governance inventory

164. Dry Run Everywhere

Destructive commands should support:

--dry-run

and show affected counts/surfaces.


165. Confirmation

High-risk destructive admin operations should require explicit operator confirmation at CLI/API level.


166. Admin API

Large destructive tasks create durable job and return:

job ID

rather than blocking request.


167. Authorization

Separate permissions:

Retention.Plan
Retention.Execute
LegalHold.Manage
Erasure.Execute
Tenant.Offboard
Governance.Verify

168. Separation of Duties

Enterprise deployments may require:

one person requests
another approves

for legal hold release or mass purge.

Architecture should support optional approval workflow.


169. Approval State

PendingApproval
Approved
Rejected

before execution.


170. Governance Job State Machine

Requested
↓
Planned
↓
AwaitingApproval
↓
Executing
↓
Verifying
↓
Completed

Alternative branches:

Blocked
Failed
PartiallyCompleted
Canceled

171. Cancellation

Before destructive execution:

cancel safely

After partial execution:

cannot necessarily restore deleted data

State this clearly.


172. Irreversible Boundary

Governance plan should mark:

point of no return

for destructive actions.


173. Archive-Before-Delete

Optional policy:

export immutable archive
↓
verify archive
↓
delete hot data

174. Archive Is Still Retention

If privacy erasure demands deletion:

archive cannot be used as loophole

Erasure planner includes archives.


175. Legal Hold Copy

If legal hold requires preservation before source deletion:

create protected held copy

only if policy permits.


176. Held Copy Security

Encrypt and restrict heavily.


177. Client-Side Governance Metadata

Client stores:

scope revocation state
local purge state
retention policy generation

where necessary.


178. Policy Generation

Define:

pub struct GovernancePolicyGeneration(u32);

Clients need not understand all server retention law, but may need new purge behavior after generation change.


179. Server-Controlled Purge Directive

Protocol message:

pub struct PurgeDirective {
    pub directive_id: PurgeDirectiveId,
    pub scope_id: ScopeId,
    pub reason: PurgeReason,
    pub minimum_store_generation: Option<LocalStoreGeneration>,
}

180. Purge Directive Idempotency

Client records processed directive IDs.

Repeated directive is safe.


181. Purge Ack

pub struct PurgeAck {
    pub directive_id: PurgeDirectiveId,
    pub completed_at: Timestamp,
}

182. Local Purge Failure

If local DB cannot purge due corruption/disk error:

client enters restricted state

for revoked sensitive scope.

Do not continue exposing stale unauthorized data if policy can prevent it.


183. App-Level Lock

If purge cannot complete:

lock affected account/store

until repair/reinitialization.


184. Local Encryption Key Delete

For account logout/offboarding:

destroy local account encryption key

may be strongest fast purge mechanism, followed by physical cleanup.


185. Storage Adapter Requirements

Local adapter should support:

scope purge
generation replacement
tombstone GC
enumeration for verification

Server adapter should support:

bounded deletion
hold-aware selection
journal floor management

186. Governance Capability

pub struct GovernanceCapabilities {
    pub hard_delete: bool,
    pub transactional_batch_delete: bool,
    pub generation_drop: bool,
    pub cryptographic_erase: bool,
}

187. Certification

Tier-A adapters should pass lifecycle tests.


188. Property Tests

Generate:

devices at different cursors
tombstones
revocations
holds
retention changes

Assert no unsafe tombstone deletion.


189. Tombstone GC Test

Client A cursor > delete. Client B cursor < delete.

Expected:

tombstone retained

After B retired:

eligible

190. Resurrection Test

GC tombstone then stale retired client reconnects.

Expected:

rebootstrap required
old update cannot resurrect entity

191. Legal Hold Test

Record retention expired but hold active.

Expected:

not purged

192. Erasure Test

Subject has:

profile
invoice
blob
audit

Expected:

profile deleted/pseudonymized
invoice retained with minimized identity
blob removed if unreferenced
audit pseudonymized according to policy

193. Restore Test

Restore backup predating erasure.

Expected:

erasure ledger reapplied before traffic

194. Scope Revocation Test

Offline client reconnects after scope revoked.

Expected:

no new data
purge directive
local scope removed

195. Partial Failure Test

Primary DB purge succeeds. Object storage unavailable.

Expected:

job PartiallyCompleted
not Completed
retry outstanding surface

196. Governance Invariants

Add:

A tombstone is not garbage-collected while any valid retained client can still legally resume from before its deletion boundary.

A client below the retained journal floor must rebootstrap rather than continue incrementally.

Active legal hold prevents normal retention purge of covered governed data.

Erasure never silently deletes records that policy requires to retain; it uses explicit pseudonymization/minimization where necessary.

Governance job is not marked complete until all required storage surfaces report successful execution and verification.

Tenant offboarding revokes authoritative write access before destructive purge begins.

197. Additional Invariants

Restore procedures reapply post-backup erasure and revocation state before normal service resumes.

A stale retired client cannot resurrect a physically purged entity using obsolete state.

Sensitive governed copies such as exports, replay bundles, and snapshots participate in erasure/retention planning when registered as governed storage surfaces.

198. Metrics

retention_candidates_total
retention_purged_total
retention_held_total
erasure_jobs_total
erasure_blocked_total
erasure_partial_total
legal_holds_active
journal_floor_sequence
tombstone_gc_total

Avoid subject IDs as metric labels.


199. Logs

Structured:

retention_plan_created
legal_hold_applied
erasure_started
erasure_surface_completed
tenant_purge_completed
tombstone_gc_advanced
journal_floor_advanced

200. Alerting

Alert on:

governance job stuck
erasure verification failed
unexpected held-data growth
journal floor unable to advance
snapshot store purge failure
restore governance reconciliation failure

201. Recommended Modules

aequora-governance/
├── policy.rs
├── retention.rs
├── legal_hold.rs
├── erasure.rs
├── subject_graph.rs
├── purge_plan.rs
├── journal_floor.rs
├── tombstone_gc.rs
├── offboarding.rs
├── inventory.rs
└── verify.rs

Client:

aequora-client/
└── governance/
    ├── purge_directive.rs
    ├── local_purge.rs
    └── ack.rs

202. Governance Store Registry

Server:

GovernanceRegistry::new()
    .register(primary_db)
    .register(snapshot_store)
    .register(blob_store)
    .register(export_store)
    .register(replay_store);

203. Plug-and-Play Default

Developers classify domain data once.

Aequora handles:

journal floors
tombstone safety
retention scheduling
scope purge
governance job state

without application code manipulating sync metadata directly.


204. School ERP Examples

Possible classifications:

Student contact details
    erasure/pseudonymization eligible

Attendance history
    long retention by school policy

Fee/payment ledger
    long-term immutable evidence

Temporary generated report
    short retention

Uploaded document
    retention by document category

Audit/security history
    independent retention class

Aequora should not decide the durations; the ERP policy layer does.


205. Finance Example

A payment cannot simply be deleted because user requests account erasure.

Instead:

retain payment/ledger evidence
remove unnecessary personal fields
replace subject reference with pseudonymous archival ID

subject to application/legal policy.


206. Local-First Reality

A local-first system increases governance complexity because data exists on devices.

Therefore deployment policy should combine:

scope minimization
local encryption
credential expiry
purge directives
device retirement
rebootstrap floors

207. Completion Criteria

Part 14 is complete when:

[x] retention classes defined
[x] deletion modes defined
[x] legal hold model defined
[x] erasure planner defined
[x] data-subject graph defined
[x] tombstone GC safety defined
[x] journal floor defined
[x] stale-client resurrection prevention defined
[x] operation-ledger retention defined
[x] snapshot/blob/export/replay lifecycle integrated
[x] tenant offboarding workflow defined
[x] backup/PITR erasure replay defined
[x] client purge directive defined
[x] governance storage registry defined
[x] dry-run/approval/audit model defined
[x] lifecycle correctness tests defined

208. Final Architecture

                     GOVERNANCE POLICY
                            │
             ┌──────────────┼───────────────┐
             ▼              ▼               ▼
         Retention       Legal Hold       Erasure
             │              │               │
             └──────────────┼───────────────┘
                            ▼
                      Governance Planner
                            │
                 discover affected copies
                            │
         ┌──────────────────┼──────────────────┐
         ▼                  ▼                  ▼
     Primary DB        Snapshot/Blob       Client Scope
         │                  │                  │
         ▼                  ▼                  ▼
   purge/pseudonymize   delete/archive     purge directive
         │                  │                  │
         └──────────────────┼──────────────────┘
                            ▼
                       Verification
                            │
                            ▼
                         Complete

Tombstone lifecycle:

Business Delete
      │
      ▼
   Tombstone
      │
      ▼
Client Watermarks + Journal Floor
      │
      ▼
All valid old clients crossed boundary
or are retired/rebootstrap-only
      │
      ▼
Safe Tombstone GC

The architectural principle is:

Aequora should retain data only as long as synchronization correctness, business policy, audit obligations, legal holds, or recovery requirements actually need it—and should make every destructive transition explicit, verifiable, restartable, and safe for offline replicas.

This gives Aequora a complete lifecycle model for enterprise retention, privacy erasure, legal hold, offboarding, tombstone cleanup, snapshots, blobs, backups, and local client copies without weakening synchronization correctness.