Table of Contents

Interface ILegalHoldService

Namespace
Excalibur.Compliance
Assembly
Excalibur.Compliance.Abstractions.dll

Service for managing legal holds that block erasure. Implements GDPR Article 17(3) exceptions.

public interface ILegalHoldService

Remarks

Legal holds prevent erasure when data must be retained for:

  • Legal claims defense
  • Regulatory investigation
  • Litigation holds
  • Legal obligations under EU/Member State law

Methods

CheckHoldsAsync(string, DataSubjectIdType, string?, CancellationToken)

Checks if a data subject has any active legal holds.

Task<LegalHoldCheckResult> CheckHoldsAsync(string dataSubjectId, DataSubjectIdType idType, string? tenantId, CancellationToken cancellationToken)

Parameters

dataSubjectId string

The data subject identifier.

idType DataSubjectIdType

Type of the identifier.

tenantId string

Optional tenant ID.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<LegalHoldCheckResult>

Check result including active holds.

CheckHoldsByHashAsync(string, string?, CancellationToken)

Checks for active holds using an ALREADY-HASHED data-subject identifier.

Task<LegalHoldCheckResult> CheckHoldsByHashAsync(string dataSubjectIdHash, string? tenantId, CancellationToken cancellationToken)

Parameters

dataSubjectIdHash string

The hashed data-subject identifier, exactly as stored.

tenantId string

The tenant, or null to consult every tenant-wide hold.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<LegalHoldCheckResult>

The holds active for that subject, plus any tenant-wide holds.

Remarks

Use this whenever the only identifier you hold is a hash. CheckHoldsAsync(string, DataSubjectIdType, string?, CancellationToken) hashes its argument unconditionally, so passing it a hash queries for a DOUBLE hash against a store keyed on a single one. The hash is HMAC-SHA256 and is not idempotent, so the two can never match and the mismatch is SILENT in the unsafe direction: a subject-specific hold reports as absent and an irreversible erasure proceeds over it.

This is not hypothetical. An erasure retains only the subject HASH once a request is recorded -- the raw identifier is deliberately not kept, because keeping it would defeat the erasure -- so every execute-time hold check has a hash and nothing else. Two members exist so that constraint is visible at the call site instead of being carried in a comment nobody reads.

Both members share one query path, so a hold found by one is found by the other.

CreateHoldAsync(LegalHoldRequest, CancellationToken)

Creates a legal hold for a data subject or tenant.

Task<LegalHold> CreateHoldAsync(LegalHoldRequest request, CancellationToken cancellationToken)

Parameters

request LegalHoldRequest

The legal hold request details.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<LegalHold>

The created legal hold.

GetHoldAsync(Guid, CancellationToken)

Gets a specific legal hold.

Task<LegalHold?> GetHoldAsync(Guid holdId, CancellationToken cancellationToken)

Parameters

holdId Guid

The hold ID.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<LegalHold>

The legal hold, or null if not found.

ListActiveHoldsAsync(string?, CancellationToken)

Lists all active legal holds.

Task<IReadOnlyList<LegalHold>> ListActiveHoldsAsync(string? tenantId, CancellationToken cancellationToken)

Parameters

tenantId string

Optional tenant filter.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<LegalHold>>

List of active legal holds.

ReleaseHoldAsync(Guid, string, string, CancellationToken)

Releases a legal hold.

Task ReleaseHoldAsync(Guid holdId, string reason, string releasedBy, CancellationToken cancellationToken)

Parameters

holdId Guid

The hold ID to release.

reason string

Reason for release.

releasedBy string

Who is releasing the hold.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

Releasing is a read-modify-write, and it refuses to write over a hold that changed underneath it. If the hold was modified between this call reading it and writing the release — most importantly, if its expiry was extended — the release is not applied and LegalHoldConcurrencyException is raised. Re-read the hold and decide again; a hold that is no longer due for release should not be released.

Exceptions

KeyNotFoundException

No hold with that identifier exists, or it was deleted while this call was releasing it.

InvalidOperationException

The hold has already been released.

LegalHoldConcurrencyException

The hold was modified concurrently. Nothing was written.