Intent
Use deterministic queries to define cleanup actions before applying them.
When to use
- Automations modify external systems or production data.
- You need safe retries without duplicate effects.
- You must prove what changed for audit or compliance.
- Runs are long or high volume and can fail midstream.
Core mechanics
- Fetch current state and compute a desired state.
- Generate a diff and an explicit action plan.
- Apply only the delta with safeguards.
- Record results, errors, and timing for each action.
Implementation checklist
- Define desired state inputs and validation rules.
- Capture current state with stable identifiers.
- Compute a deterministic diff and action plan.
- Provide a dry-run output for review.
- Apply actions with rate limits and retries.
- Write audit logs and summarize outcomes.
Failure modes and mitigations
- Non-idempotent actions -> add guards or uniqueness checks.
- Partial runs -> add checkpointing and resume support.
- API rate limits -> throttle and back off.
- Audit gaps -> log before and after state.
Observability and validation
- Counts: planned vs applied vs failed actions.
- Duration per phase and per record.
- Error rate and top failure reasons.
- Links to audit reports and logs.
Artifacts
- Diff report or action plan.
- Audit log with timestamps and outcomes.
- Summary report for stakeholders.