every time an export csv came in i'd import it and end up with duplicates, because the tracker only knew what my own scripts had sent. content saved from the browser extension or the phone or an older script was invisible to it. the fix was to stop tracking what i sent and start mirroring what's actually there.
before every import the script now pulls the whole library in one cheap call and seeds every existing url into a sqlite ledger. anything already in there from any path gets skipped. the known set went from around four thousand urls to over nine thousand overnight, and the database is now a copy of reality instead of a guess.
there was also a legacy json tracker from an older inbox path with a couple thousand urls that had never touched the database, so i merged it in one time. two scripts had been running on two different tracking stores and could drift apart forever. now they share one ledger and they structurally cannot diverge.
the nicest property is that deleting something in the library is a permanent decision. the ledger marks a url imported and never forgets it, even after the url stops existing in the library. so an old bookmark that comes back through a later export gets skipped forever, which is exactly right when you deleted it because it was useless. one dry-run verified it, no writes made in test, and the edge cases all behave the way you'd want by default.