Databases
AuraScore 81/100

Legal Hold Discovery Index Sync and Purge Automation

Author a transactional database sync and purge script for legal hold management and document indexing.

Use this template when building scheduled maintenance scripts to synchronize legal discovery records into search engines while purging non-retained evidence past retention periods.

Template

Role: Senior Legal Operations Database Architect specializing in regulatory e-discovery pipelines and statutory compliance.

Context

  • Primary transactional database: {{source_rdbms}}
  • Destination discovery search index: {{target_index}}
  • Active legal matter identifier: {{discovery_case_id}}
  • Jurisdiction data retention limit in days: {{jurisdiction_retention_days}}
  • Excluded legal hold tag identifiers: {{excluded_hold_tags}}
  • Processing batch size limit: {{batch_size}}

Task

Build an idempotent database synchronization and regulatory purge script that extracts active matter records for {{discovery_case_id}} from {{source_rdbms}}, syncs them into {{target_index}}, and safely purges unindexed records exceeding {{jurisdiction_retention_days}} days unless protected by {{excluded_hold_tags}}.

Method

  1. Define connection and session isolation parameters for {{source_rdbms}} to avoid locking active litigation matter tables.
  2. Construct cursor-based pagination logic using {{batch_size}} to process discovery records incrementally.
  3. Implement filter logic isolating records matching {{discovery_case_id}} for replication to {{target_index}}.
  4. Design a strict protective check verifying records containing any tag in {{excluded_hold_tags}} are marked immutable.
  5. Write the batch purge deletion statement targeting expired records older than {{jurisdiction_retention_days}} days without active hold tags.
  6. Add audit log insertion statements capturing timestamp, deleted row count, and matter ID per batch execution.
  7. Wrap synchronization and deletion sequences in explicit transactional savepoints with exception hooks.

Constraints

  • MUST NOT delete or modify any record associated with {{excluded_hold_tags}} under any execution branch.
  • MUST execute mutations in batches limited strictly to {{batch_size}} rows to prevent lock escalation.
  • Script syntax must be directly executable against {{source_rdbms}}.
  • Error handlers must log failed record identifiers without terminating the entire batch cycle.

Output format

  • Section 1: Transaction and Lock Management Strategy (bulleted overview, under 100 words).
  • Section 2: Complete Executable Maintenance Script (fully formatted SQL or PL/SQL script).
  • Section 3: Audit Trail Verification Query (SQL statements to check compliance logging).
  • Section 4: Dry-Run and Safety Verification Instructions (step-by-step checklist).

Self-review

  • Verify that {{excluded_hold_tags}} bypasses all destructive DELETE and UPDATE operations.
  • Ensure batch looping correctly handles the {{batch_size}} parameter without infinite loop conditions.
  • Confirm retention calculations accurately convert {{jurisdiction_retention_days}} against UTC timestamps.
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-databases
research-productivity-operations
legal
ediscovery
compliance