chore(scripts): fuzzy duplicate-search workflow for merge candidates - #243
Draft
mbarlow12 wants to merge 1 commit into
Draft
chore(scripts): fuzzy duplicate-search workflow for merge candidates#243mbarlow12 wants to merge 1 commit into
mbarlow12 wants to merge 1 commit into
Conversation
- Normalizes GEM's "<name> <type> (<location>)" decoration so bare source names match, which exact name+country blocking never does. - Blocks on exact normalized name, token_sort_ratio within country, and geo proximity; vetoes rare-parenthetical and directional-qualifier conflicts. - Emits groups with signals and a null decision for human/AI review, gated to a high-confidence tier by default so passes can be merged then repeated. - Extends create_merge_candidate.py with --from-file/--dry-run and adds a list/approve/deny helper that guards candidates it did not create. - Throwaway tooling: no package, no tests, no lockfile change; rapidfuzz comes from `uv run --with`.
CD summary
|
| service | url | fqdn |
|---|---|---|
| api | open | pr-0243-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io |
| entity-linkage | open | pr-0243-el.purplegrass-c07d0a94.westus2.azurecontainerapps.io |
| frontend | https://witty-mushroom-017a3dc1e-243.westus2.1.azurestaticapps.net | |
| stitch-llm | open | pr-0243-llm.purplegrass-c07d0a94.westus2.azurecontainerapps.io |
Database (1)
| db_name | postgres_host | postgres_port | postgres_db |
|---|---|---|---|
| pr_0243 | stitch-dev.postgres.database.azure.com |
5432 |
pr_0243 |
Jobs (2)
| job | image | postgres_db | api_url | auth_mode |
|---|---|---|---|---|
| db-migrations | ghcr.io/rmi/stitch-api:pr-0243@sha256:591538fbaa81adc5618c7815742ce19d8591921291cf1d1cb945ac44e6530c37 |
pr_0243 |
||
| seed | ghcr.io/rmi/stitch-seed:pr-0243@sha256:5e5d4772db6aac2c37d189f4d1df0601725ba6ad922a00b1bf59176bff807fc1 |
https://pr-0243-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io/api/v1 |
stitch-client-bearer-token |
Images (4)
| build_time | commit_time | git_sha | image | image_digest |
|---|---|---|---|---|
| 2026-08-18T23:36:19Z | 2026-08-18T23:36:03Z | abaf4ef | ghcr.io/rmi/stitch-api:pr-0243 |
ghcr.io/rmi/stitch-api:pr-0243@sha256:591538fbaa81adc5618c7815742ce19d8591921291cf1d1cb945ac44e6530c37 |
| 2026-08-18T23:36:21Z | 2026-08-18T23:36:03Z | abaf4ef | ghcr.io/rmi/stitch-entity-linkage:pr-0243 |
ghcr.io/rmi/stitch-entity-linkage:pr-0243@sha256:8ceef22052337354202b9c7cb0efa1c8c36a76f70adebe3e75e43611312f340d |
| 2026-08-18T23:36:20Z | 2026-08-18T23:36:03Z | abaf4ef | ghcr.io/rmi/stitch-seed:pr-0243 |
ghcr.io/rmi/stitch-seed:pr-0243@sha256:5e5d4772db6aac2c37d189f4d1df0601725ba6ad922a00b1bf59176bff807fc1 |
| 2026-08-18T23:36:22Z | 2026-08-18T23:36:03Z | abaf4ef | ghcr.io/rmi/stitch-stitch-llm:pr-0243 |
ghcr.io/rmi/stitch-stitch-llm:pr-0243@sha256:ac7b26a10ddddf115eed3e198207ca59a4a38ea1186b6bc0bd4aef28b10a9d05 |
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.
Throwaway developer tooling under
scripts/, opened as a Draft because others may find it useful. Not wired into CI, not imported by any package, no lockfile change.Why
entity-linkageblocks onname.strip().casefold()and confirms oncountry.strip().upper()— both exact. On the demo corpus (9,187 resources) that finds zero groups: GEM writesDarquain Oil Field (Iran)while CCR/BC/WM writeDarquain, so the names never collide. The blocking key is the constraint, not the comparison.Normalizing the decoration away finds 273 high-confidence pairs on the same data.
Darquain(IRN, ccr)Darquain Oil Field (Iran)DEEP BASIN(CAN, bc)Deep Basin Gas Field (British Columbia, Canada)Dębowiec Śląski(POL)Dębowiec Śląski Gas Field (Poland)Workflow
The search script proposes and explains, never decides — every group comes out with
"decision": nullplus the signals that justified it. Output is gated to ahighconfidence tier by default; merge that tier, re-fetch, re-run wider. Approving mints a new resource, so snapshots go stale by design.Matching
-split also blocks on each half, but only when that half is the rarest segment on both sides — otherwiseBelmont County - AscentmatchesHarrison County - Ascenton the operator.token_sort_ratio >= 90within a country bucket. Deliberately nottoken_set_ratio: it scoresMARTINagainstMARTIN CREEKat 100 and chains the corpus into one 1,021-member blob.Daqing (Lamadian)vs(Saertu)) and directional qualifiers (Blueberry EastvsWest). Parenthetical rarity is learned from the corpus, so(Iran)is treated as boilerplate.Verified
Run end-to-end against the PR-0242 demo deployment:
Daqing(3 reservoirs) andDalmatian North/Southcorrectly stay apart.ccrandgemrecords. Re-running skipped already-created groups.ruff checkandruff format --checkpass onscripts/.Notes for reviewers
scripts/data/is gitignored — fetched snapshots and review state are per-run and per-deployment._common.pydefaults to the PR-0242 demo URL (inherited from the original helper); that deployment is ephemeral, so setSTITCH_API_BASE_URLin.env. Credentials come fromSTITCH_CLIENT_PRIVILEGED_BEARER_TOKEN; no token is ever printed.entity-linkagehere. If it proves out, that is a separate pre-approved architectural conversation perCONTRIBUTING.md, and it would want the DB-side normalized-name match already tracked as STIT-573.AI assistance
Written with Claude Code. Verification was the ground-truth pass/fail check above plus the live end-to-end run against the demo deployment; the 273-row high-confidence tier was read in full during review, which is where the two held-back groups (
OTHER AREAS, a catch-all bucket, andQasr (Pre-2021), a vintage qualifier) came from.