HANDOFF NOTE: project "importer" (only this project's requirements are included)

1. Task
Implement evaluate(payload) -> {records:[{id,fields}], audit:[string]}. Events have: id (string), version (integer), deleted (boolean), fields (JSON object). The payload carries the events and the settings. Only the settings listed below have been given for importer so far.

2. Current settings (after Updates 1-5)
- duplicate_policy = "first" (Update 1)
- fold_case = true (Update 1)
- tombstone_wins = true (Update 1)
- trim_ids = true (Update 1)
- list_merge = "replace" (Update 5; supersedes "unique" from Update 2)
- nested_merge = true (Update 4; supersedes false from Update 2)
- null_mode = "ignore" (Update 4; supersedes "delete" from Update 2)
- version_floor = 2 (Update 5; supersedes 3 from Update 2)
- audit_all = true (Update 3)
- empty_id = "skip" (Update 3)
- order = "input" (Update 5)
- unknown_fields = "drop" (Update 5)

All 12 settings are resolved. No unresolved items. There are no importer-specific exceptions beyond the algorithm contract below.

Note on order = "input": the contract only defines order=id explicitly, and says any other value sorts by first processed index and then id. So "input" means records are sorted by first processed index, then id.

3. Algorithm contract (fixed)
1. Normalize id: trim if trim_ids, then ASCII case folding iff fold_case. An empty normalized id is skipped or raises ValueError, per empty_id.
2. Do the normalization and empty-id check before discarding events whose version is below version_floor.
3. Deduplicate by normalized (id, version). The group keeps the insertion position of its first occurrence, but the selected event is the first or last one per duplicate_policy. Sorting uses the selected event's actual original index.
4. Process events ordered by (version, selected original index).
5. Record each normalized id's first processed index.
6. Deletion removes the record. With tombstone_wins, a deletion also installs a permanent sticky tombstone that blocks later non-deletions.
7. A deletion is applied only if a record existed or it installs a new sticky tombstone. Redundant deletions are blocked (no change).
8. Non-deletion: merge fields, creating {} if needed.
   - A null value is ignored or deletes the existing key per null_mode (current: ignore).
   - With nested_merge, two objects merge recursively; otherwise the new object replaces the old.
   - Two arrays: replace, or with list_merge=unique, append new-array items not structurally JSON-equal to any item in the old array. New-array items are not deduplicated among themselves. (Current: replace.)
   - Other types are replaced.
9. If unknown_fields=drop, filter top-level fields to name, tags, meta only (current: drop).
10. Audit: with audit_all, one entry per processed event; otherwise only applied events. Format is normalized_id:version:applied or normalized_id:version:blocked. Audit order is processing order.
11. Records are sorted lexically by normalized id when order=id, otherwise by first processed index and then id.
12. Do not mutate the input (deep-copy as needed).

4. Discarded
All "archive-*" project records were unrelated to importer and are ignored. Only the five importer updates above are authoritative. Later updates replace earlier values only for the keys they name.