Skip to content

Decision import: only execute groups that agree with the rules - #536

Merged
markusressel merged 1 commit into
masterfrom
immich-import-sanity-check
Oct 31, 2026
Merged

markusressel merged 1 commit into
masterfrom
immich-import-sanity-check

Conversation

@markusressel

Copy link
Copy Markdown
Owner

Summary

Importing decisions from another tool (POST /api/decisions/import-discarded, POST /api/integrations/immich/import-trash) no longer executes every group where all but one member were discarded. The former decided outcome is split:

  • agrees_with_rules: the remaining file is the rule keeper. Same as before: it becomes the user keeper and the daemon moves the other files.
  • disagrees_with_rules: nothing is executed and no user keeper is set. The group goes to review (status=review, needs_review, reason like Immich kept <path>, the rules keep <path>). The other tool's choice is stored as a suggestion in the new columns groups.suggested_keep_path / suggestion_source (immich / import).

Details:

  • Suggestions survive new runs: record_group keeps such groups in review and combines the suggestion reason with a weak-rule reason without duplicating it. The deduplicator holds them as long as the rules keep another file, regardless of hold_ambiguous_groups. Once the rules agree, the hold ends.
  • Re-imports are idempotent: they only refresh the suggestion, and the preview marks such groups already_suggested. Groups decided by the user, ignored or resolved are not changed (same as before).
  • The response has per-outcome counts, agreeing and disagreeing. For each disagreement it lists both keep paths, pixel count, file size and EXIF tag count of both files, and decided_by.
  • Schema: new columns are added to existing databases (_ADDED_COLUMNS, ALTER TABLE ADD COLUMN if missing), SCHEMA_VERSION 2.
  • UI:
    • Immich card: the preview shows agreeing groups (moved) and disagreeing groups (go to review), with an expandable table linking to /groups/<id>. The apply button and text make clear that only agreeing groups are executed.
    • Group detail: shows "Immich keeps " with an "Accept suggestion" button (= POST /api/groups/{id}/keep).
    • Groups list: new "suggestion" filter (has_suggestion, also in the bulk filter).
  • Docs: README (import + Immich section) and AGENTS.md.

Test plan

  • poetry run pytest (153 passed): store tests for both outcomes, preview vs. apply, idempotence, persistence across rule runs, migration of an old database; deduplicator hold test; API preview/apply test
  • npm --prefix web run lint, npm --prefix web run build

🤖 Generated with Claude Code

Importing discarded paths (Immich trash) used to make the remaining file
the user keeper for every group where all but one member were discarded.
Now the outcome is split:

- agrees_with_rules: the remaining file is the rule keeper, executed as before
- disagrees_with_rules: nothing is executed, the group goes to review with the
  other tool's choice stored as suggestion (groups.suggested_keep_path /
  suggestion_source), which can be accepted with one click in the group view

Suggestions survive new runs (record_group keeps the group in review and the
deduplicator holds it while the rules keep another file), re-imports only
refresh them. The preview lists the disagreeing groups with resolution, file
size and EXIF tag count of both files and the deciding rule. The groups list
can be filtered by groups with a suggestion. New columns are added to existing
state databases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@markusressel
markusressel merged commit 37116d5 into master Oct 31, 2026
9 checks passed
@markusressel
markusressel deleted the immich-import-sanity-check branch October 31, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant