feat: add manual mappings and ignore system#49
Merged
Conversation
Add support for user-defined AniList↔MAL mappings and ignore rules via mappings.yaml file. Includes ManualMappingStrategy as the first strategy in the chain, ignore filtering by AniList ID and title, and configurable mappings file path.
Refactor updater into resolve → deduplicate → process phases. Detect N:1 conflicts when multiple sources map to the same target and resolve by strategy priority. Add FindTargetWithMeta for match metadata, strategy name constants, and DuplicateConflict reporting in global summary.
Pre-allocate `resolved` and `kept` slices in updater.go with known capacity to avoid unnecessary reallocations.
Add CLI command 'unmapped' to view and manage entries that could not be mapped during sync. Supports --fix for interactive resolution and --ignore-all to bulk-ignore. Saves unmapped state between runs and displays unmapped summary in global sync report.
Add manual mappings and ignore rules documentation, unmapped command reference, MAPPINGS_FILE_PATH env var, and updated strategy chains with ManualMappingStrategy.
Add MALIDs field and malMeta map to IgnoreConfig for reverse sync ignore support. Add IsIgnoredByMALID() and AddIgnoreByMALID() methods. Previously, the ignore system only stored AniList IDs, making it impossible to ignore entries when syncing MAL → AniList.
Extract buildIgnoreIDsNode helper to avoid code duplication between anilist_ids and mal_ids sections. Update MarshalYAML to emit mal_ids with inline comments, matching the existing anilist_ids format.
Add SyncDirectionForward/SyncDirectionReverse constants and Direction field to UnmappedEntry. Set direction in trackUnmapped based on the reverseDirection flag during sync. This allows the unmapped command to distinguish forward vs reverse entries without relying on the reverseDirection flag (which is always false when unmapped runs).
Forward updaters (AniList→MAL) now use ignoreAniListIDs, while reverse updaters (MAL→AniList) use ignoreMALIDs. Previously all updaters shared the same AniList-only ignore map, which meant isIgnored() compared AniList IDs against MAL source IDs in reverse sync and never matched.
Use entry.Direction instead of *reverseDirection flag (which is always false when unmapped runs separately from sync). Forward entries ignore by AniList ID and map to MAL ID; reverse entries ignore by MAL ID and map to AniList ID. Extract helpers: isReverseEntry, addIgnoreEntry, logIgnoredEntry, applyIgnoreAction, applyMapAction, promptID.
Add SaveAndLoad_WithMALIDs and MarshalYAML_CombinedIgnore tests for mappings round-trip with both AniList and MAL ignore IDs. Add DirectionField and MixedDirections tests for unmapped state JSON serialization with forward and reverse entries.
Strategy chains now show all 4 direction-specific variants, main components table includes all .go files (hato, jikan, logger, service, cmd_* files), logging section documents the Logger struct instead of deprecated DPrintf, and dependencies list is complete.
feat: add unmapped entries management CLI command
feat: add duplicate target detection and 3-phase updater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MappingsConfigwith manual AniList↔MAL ID mappings and ignore rules viamappings.yamlManualMappingStrategyas the first strategy in the chain for user-defined overridesMappingsFilePathconfig field with env varMAPPINGS_FILE_PATHTest plan
go build ./...compilesgo test ./... -vpasses (7 new ManualMappingStrategy tests + mappings_test.go)make lint— 0 issues