Add reviewable person identities that survive re-indexing (#85) - #149
Open
ik020 wants to merge 2 commits into
Open
Add reviewable person identities that survive re-indexing (#85)#149ik020 wants to merge 2 commits into
ik020 wants to merge 2 commits into
Conversation
- PersonRecord/PersonAlias/PersonReference/PersonClusterLink domain models - CRUD layer in sql_catalog.py, schema version bumped to 5 - Alembic migration 20260803_01 for existing/Postgres catalogs - Regression tests covering reindex-survival and non-destructive delete - Update test_database_cli.py and test_media_catalog.py for new head/schema version - Fix database_cli.py to ensure local directories exist before migrating
Fresh environments hit 'unable to open database file' because upgrade_database() assumes the target directory tree already exists.
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.
Closes #85
What this does
Adds a repository-level "reviewed person" identity that is independent of
any single index generation. A
PersonRecordis a durable, user-approvedidentity; a
PersonClusterLinkis evidence tying that person to a specificanonymous actor cluster produced by one media item + one index generation.
This is the core guarantee the issue asked for: when a video is re-indexed
and produces a brand-new anonymous cluster ID under a new generation ID,
the person, their aliases, and their reference images all survive untouched,
and lookup by the new cluster still resolves to the same person.
What's included
core/people.py,core/identifiers.py):PersonRecord,PersonAlias,PersonReference,PersonClusterLink, plusPersonId/PersonReferenceId.people,person_aliases,person_references,person_cluster_linkstables, registered inlocal_catalog.py. Schemaversion bumped 4 → 5.
infrastructure/sql_catalog.py): put/get/list/delete for people,add/remove/list for aliases and reference images, link/unlink/query for
cluster links.
20260803_01_reviewed_people.py): brings anexisting SQLite catalog or a PostgreSQL deployment up to the same schema,
for anyone not creating a catalog fresh via
LocalCatalog.create_all().Verified column-for-column against the actual read/write code in
sql_catalog.pybefore merging, not just against the tableCREATEstatements.
tests/test_people_catalog.py, 12 cases), including:test_cluster_links_survive_reindexing_with_a_new_generation— thescenario from the issue: link a person to a cluster, re-index (new
generation, new cluster ID), confirm the person and old link survive,
confirm the new link resolves correctly.
test_deleting_a_person_cascades_aliases_references_and_links_only—confirms removing a person cleans up only their own aliases/references/
links, and never touches the underlying video/media/index data.
test_unlink_cluster_corrects_an_accidental_merge_without_touching_media— confirms a bad cluster link can be corrected without side effects.
tests/test_database_cli.pyandtests/test_media_catalog.py,which hardcoded the previous migration head and schema version.
database_cli.py:upgrade_database()previously assumed itstarget directory already existed and failed with
unable to open database fileon a fresh environment. It now callssettings.layout.ensure_local_directories()first.Verification
pytest tests/test_people_catalog.py tests/test_database_cli.py tests/test_media_catalog.py— all green.20260803_01end-to-end against a real local SQLite catalog(not just an in-memory test DB) and confirmed the resulting tables and
alembic_versionby inspection.pytestsuite run for regressions outside the touched area: theonly failures are pre-existing, unrelated missing optional dependencies
in this dev environment (
chromadb,uvicorn,PIL,av,mcp,fastapi,streamlit,srt,cryptography) — confirmed by reproducingthe same failures with this branch's changes stashed out.
Not yet verified - needs reviewer follow-up
This PR was validated entirely against the local SQLite path
(
ApplicationMode.local). The PostgreSQL /ApplicationMode.serverpath has not been exercised - I don't have network access to the
bundled Postgres service from this environment. Someone with access to
that deployment should run the migration there and confirm it applies
cleanly before this is considered fully verified end-to-end.