Repository navigation
feat(dupes): interactive duplicate-person review - #212
Merged
Merged
Conversation
…t-finance) Adds the ct dupes command family: a detector with match classes and tiers, relationship-based suppression, an interactive review with dynamic and static group handling, a local audit log, and an Optigem finance export. Runs against protected envs only in a human terminal session. v1 opens the ChurchTools merge page instead of calling the merge API.
- resolveRelationshipTypes throws instead of falling back to fixed ids - scan keeps earlier dismissed/merged decisions for pairs that still turn up - CT-suggested pairs share one scoring context; dynamic group ids fetched once - merge URL rendered with a function replacer, trailing slash stripped - cleanName keeps letters of any script - review says group changes stay applied when stopping before the merge page
…es, review-loop test
2000game
marked this pull request as draft
November 9, 2026 11:22
…how rejected fields
ChurchTools refuses a merge (403) while both persons share a group. Before the merge, the Duplikat is removed from shared dynamic groups; for other groups the Original's membership takes the chosen values (earlier join date, empty values filled from the Duplikat, conflicts chosen per row) and then the Duplikat is removed. The merge preview's groupsDiff.both is a list of group ids. Verified end to end on a dev instance.
…e page `ct dupes review` now starts a local web server on 127.0.0.1 and opens a page that mirrors ChurchTools' duplicate list and "Dubletten überprüfen" dialog, with the ct dupes additions (tiers, match class, Optigem, shared groups and their membership values). Values are chosen by clicking a side, the confirm box lists every change, and the dialog moves on to the next open pair. `--tui` keeps the terminal view, `--no-open` only prints the URL. The server takes a random token from the URL fragment as a header, refuses foreign Host headers, sends no data with the page, and applies --redact server-side. Merges go through the same executeMerge as the terminal view.
…view As in ChurchTools' dialog, each side with a value gets an arrow button that takes it; the chosen one is outlined. On email rows the arrow includes or excludes the address. Departments get their own Bereich section and show their masterdata names (in the terminal view too) instead of ids.
The dialog already shows every choice, as ChurchTools' own does, so Zusammenführen now merges right away. The terminal view keeps its confirm.
…rchTools' refusal key
…xport; read messageKey on refusals
…and page
- Group cleanup is idempotent (404 on the Duplikat's DELETE counts as done); after a
failed merge that already changed groups the pair is re-read and the dialog reloads it,
and the messages say what was already changed.
- Only a 404 on GET /persons/{id} means "person gone"; recovered merges need a
merge-started entry, a missing loser and a loadable survivor.
- Finance export includes every merge that orphaned an Optigem ID, also when the field
was cleared.
- One GET per person when loading a pair; dynamic group ids cached per client.
- export-finance --out refuses git work trees and writes 0600 files.
- Agent guard checks full ancestor command lines and runtime markers of more tools, and
fails closed when the process check cannot run.
- Web page: dialog cannot close mid-request and never swallows results, token survives
reload via sessionStorage, readable narrow layout, persistent search input, pager
follows the search filter.
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
Adds
ct dupes scan | review | export-finance, an interactive-only workflow for finding and merging duplicate person records.Detector: match classes (exact, nameswap, middlename, firsttoken, shortform, diminutive, fuzzy, ct), tiers T1-T3, vetoes (relationship, placeholder, birthday, sex).
Review in the browser (
ct dupes review, default): a local page modelled on ChurchTools' own duplicate page and "Dubletten überprüfen" dialog. Original (the older person, lower id) vs Duplikat, clickable arrows per field,×to clear, a star for the default email, a pager, and "Keine Dublette". Zusammenführen merges right away, with no extra confirm step. After an action the dialog stays at the same position in the pager.beide).Terminal view (
--tui, Ink, loaded lazily) with the same choices.Merge via the API (
PATCH /persons/{original}/merge/{duplicate}), with a body in the shape ChurchTools' own UI sends. Shared groups are cleaned up first, since ChurchTools refuses the merge otherwise: dynamic groups drop the Duplikat; static groups keep the Original's membership with chosen member values (earlier join date by default).Refusals: the HTTP status, the rejected field names and ChurchTools'
messageKeyare shown, never values. The refusal to merge a person with permissions of their own (error.forbidden.merge-authorized-person) is explained in plain words.Personal-data guard: against protected envs,
ct dupesrequires a TTY on stdin and stdout and no AI-agent session. There is no bypass flag.Local store outside any repo (0700/0600), with a JSONL audit log,
--redact, and no person data in errors.Finance export (
ct-cli.dupes.optigem-merges/1) as CSV and JSON. Each row has:leading), plus the other ID (orphaned).Finance decides which ID stays in Optigem.
Docs: new handbook page
docs/handbuch/dupes.md. README and CONTRIBUTING are updated: structure commands never touch people;ct dupesdoes, explicitly and interactively.Verification
format:check, lint, typecheck, test (1442 passed), build and docs staleness pass locally.
On a dev instance with fictitious persons:
Not verified