Skip to content

feat: community-detection auto-albums over the entity graph (P13e-1)#148

Merged
blokzdev merged 1 commit into
mainfrom
claude/p13e1-community-albums
Jun 3, 2026
Merged

feat: community-detection auto-albums over the entity graph (P13e-1)#148
blokzdev merged 1 commit into
mainfrom
claude/p13e1-community-albums

Conversation

@blokzdev
Copy link
Copy Markdown
Owner

@blokzdev blokzdev commented Jun 3, 2026

P13e-1 — Community-detection auto-albums

First PR of P13e (advanced graph analytics). Groups library items into thematic "Discovered" albums via deterministic label propagation over the entity graph — items linked through a web of shared signals (uploader / playlist / tag + co-download) that no single-facet smart album captures. The looser, thematic cousin of the P10 "Suggested" similarity albums (whose tight clusterer explicitly deferred this to P13).

Every-device — pulls from Cozo (Datalog) and clusters in pure Dart, no embedder/RAM gate (maintainer call; semantic-similarity + tier enhancements → BACKLOG). No schema change, no deps.

How it works

  • cozo_query.dartentityMembershipScript() (global [mediaId, kind, key] projection for uploader/playlist/tag; site excluded as too coarse) + coDownloadPairsScript() ([a, b]).
  • community_clustering.dart (new, pure — mirrors near_duplicate_clustering.dart)detectCommunities(...): builds an item graph from shared buckets (dropping over-generic buckets > maxGroupSize, the "discard blobs" rule) + co-download edges, runs deterministic label propagation (sequential, ties → smallest label), returns communities with minSize ≤ size ≤ maxSize, largest-first, each with its dominant tag.
  • GraphQueryService.communityClusters() — decodes the two scripts → the clusterer; [] when the store is unavailable.
  • clusteredAlbumsProvider + clusterLabel — hydrate to MediaItems and label by dominant shared signal (tag → uploader → site → newest-title fallback), reusing the existing SuggestedAlbum model + /suggested-album screen (MediaGrid + Save as collection).
  • Collections → Albums gains a "Discovered" section beside "Suggested".

Tests (CI; native Cozo is APK-verified)

  • community_clustering_test — entity-bucket splitting, web-merge across signals, co-download edges, minSize filtering, maxGroupSize pruning, dominant-tag (support ≥ 2, tie → smallest), and determinism (a single bridge edge correctly does not merge two dense clusters).
  • cozo_query_test — both new script strings; graph_query_service_testcommunityClusters() decode + unavailable; clustered_albums_test — provider hydrate/label + clusterLabel truth table + empty-when-unavailable; collections_screen_test — the Discovered section renders.
  • Full suite green (892 tests), dart format + flutter analyze clean.

Docs

  • P13-PLAN.md — e-1 [~] + parent P13e [~] (1 of 3); GRAPH-SPEC.md §7 — clustered-albums row realized at e-1 over the entity graph; VERIFICATION.md — P13e-1 checklist; BACKLOG.md — semantic-similarity/tier enhancements + richer labels/caching.

Verification

  • ✅ CI gates green locally (format · analyze · 892 tests).
  • APK spot-check owed (native Cozo): Discovered groups are coherent on a real library and appear on a low-end device; Save as collection works; the section is absent when the graph is off.

Next: e-2 centrality "Rediscover", then e-3 path/bridge + graph-view polish.

https://claude.ai/code/session_013JoYmLCosYt5tQ8qwdbL1T


Generated by Claude Code

Group library items into thematic "Discovered" albums via deterministic label
propagation over the entity graph (shared uploader/playlist/tag + co-download)
— items linked through a web of signals that no single-facet smart album
captures. Every-device (pure Datalog pull + Dart clustering; no embedder).
Surfaced in Collections → Albums beside "Suggested", labeled by dominant shared
signal (tag → uploader → site → title), with one-tap Save as collection
(reuses the SuggestedAlbum model + screen). No schema, no deps.

https://claude.ai/code/session_013JoYmLCosYt5tQ8qwdbL1T
@blokzdev blokzdev merged commit d9df761 into main Jun 3, 2026
1 check passed
@blokzdev blokzdev deleted the claude/p13e1-community-albums branch June 3, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants