Retention auto-apply rules

Map a docType pattern to a retention class — Kodori auto-suggests the right class for every NDA, invoice, 1099, etc. Acceptance is still human; the rule never auto-mutates retention.

Updated 2026-04-25

Manually setting a retention class on every uploaded document is the work that doesn't get done — until an audit hits and you discover half the workspace has no retention class at all. Auto-apply rules close the gap.

A rule maps a **docType pattern** (case-insensitive substring) to a **retention class**. When the auto-classifier (or the deterministic doc-type matcher) labels a new document with a docType that contains your pattern, Kodori adds a "Suggested by Kodori — Retention" row to the document's suggestion panel with the matching class and reasoning ("Auto-apply rule: docType matches 'invoice' → AP — 7 years").

Two design choices:

1. **Suggestions, never auto-mutations.** Retention is governance state; a wrong auto-apply has compounding cost (premature disposal, audit finding). The agent's suggestion panel shows the proposed class with the triggering rule; the human accepts or dismisses. Same pattern as sensitivity / collection / keywords proposals. 2. **Substring match, not regex.** Patterns are case-insensitive substrings — `invoice` matches "invoice", "vendor invoice", and "AP invoice"; `1099` matches "Form 1099", "1099-NEC", and "1099-MISC". Aliases ride on separate rule rows. We chose this over regex because most operators are not regex-fluent and the false-positive rate of plain substring matching is low for canonical doc-type vocabulary.

Manage rules at the bottom of /retention. Common starter rules:

- `invoice` → "AP records (7 years)" - `nda` → "NDA archive (10 years)" - `engagement letter` → "Client matter (10 years)" - `1099` → "Tax records (7 years)" - `w-9` → "Vendor records (7 years)" - `rfi` → "Project closeout (10 years)"

Rules archive (rather than hard-delete) so the audit trail of which rule fired on which document remains queryable. Archived rules stop matching new uploads but historical rule-derived suggestions stay attributable.