After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 652660 - Make Individual.id more stable and well-defined
Make Individual.id more stable and well-defined
Status: RESOLVED FIXED
Product: folks
Classification: Platform
Component: libfolks
git master
Other All
: Normal normal
: folks-0.6.0
Assigned To: folks-maint
folks-maint
Depends on:
Blocks: 652807
 
 
Reported: 2011-06-15 15:28 UTC by Philip Withnall
Modified: 2011-06-24 13:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make Individual.id more stable (11.82 KB, patch)
2011-06-15 17:46 UTC, Philip Withnall
needs-work Details | Review
Make Individual.id more stable (attempt 2) (15.16 KB, patch)
2011-06-17 12:02 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2011-06-15 15:28:12 UTC
Change it to be a stable hash of the UIDs of the personas in the individual's persona set.

Advise clients that the ID may change over time if the individual is subsequently linked to another individual. Advise that they should use the most relevant persona's UID instead if they want the link to persist over time (e.g. when tagging photos).
Comment 1 Philip Withnall 2011-06-15 17:46:25 UTC
Created attachment 189995 [details] [review]
Make Individual.id more stable

http://cgit.collabora.com/git/user/pwith/folks/log/?h=652660-individual-id
Comment 2 Travis Reitter 2011-06-16 11:57:54 UTC
Review of attachment 189995 [details] [review]:

+   * instead. For example, if storing references to Individuals who are tagged
+   * in a photo, it may be safer to store the UID of the Persona whose backend
+   * provided the photo (e.g. Facebook).

We should provide a utility function for this. Letting applications run wild with their own heuristic seems like trouble waiting to happen.

(This is the reason for the needs-work review status)

+      default_individuals.add ("1038ba3738014da2e71552e841fa4a15f5863f05");
+      default_individuals.add ("8894dd5bc1f12ca6ecae495b390f80f6c12562d3");
+      default_individuals.add ("d2a1c39becbda75573f343d2d628d27e0ef60e0e");
+      default_individuals.add ("935018a015bfdb325dd19de99ab8544f109def5b");
+      default_individuals.add ("28e811b0e3742a452998ff804d9387a6842841c3");
+      default_individuals.add ("4c95033b91a7d2dd440a73194dd86f2bfd12208b");
+      default_individuals.add ("d7dcc6ab070f45e532a8dfe71301007293ee45cc");
+      default_individuals.add ("5ef41481af6f40038e79afbc304a9fcf5f7b8f2d");

Please define each of these hashes as a reasonably-named symbol (and in other tests where it matters as well).

+              if (i.id != "ad34428954c49db6029d94f58442877ae7167d23")

Define this as well.

+      default_individuals.add ("420e4db98eef7110399bc5978b2a9081e92895b6");
+      default_individuals.add ("1cc40d4f1a878aecb8fefc4f9bf691fc9fc7589d");
...

Same.
Comment 3 Philip Withnall 2011-06-17 08:54:36 UTC
(In reply to comment #2)
> Review of attachment 189995 [details] [review]:
> 
> +   * instead. For example, if storing references to Individuals who are tagged
> +   * in a photo, it may be safer to store the UID of the Persona whose backend
> +   * provided the photo (e.g. Facebook).
> 
> We should provide a utility function for this. Letting applications run wild
> with their own heuristic seems like trouble waiting to happen.
> 
> (This is the reason for the needs-work review status)

Split out as bug #652807.
Comment 4 Travis Reitter 2011-06-17 11:22:42 UTC
As discussed briefly at the hackfest, we're probably best instead making an Individual.id equal to the SHA1 hash of $(most relevant Persona).id

This has the following useful properties:

* should be reasonably stable in most cases
* deterministic
* hashed, so lazy developers won't use it interchangeably with the Persona.id or assume it's static

Some suboptimal properties:

* not human-mappable back to the objects themselves (but sufficient debugging statements should minimize this)
* not perfectly-stable (unsolvable problem, since people don't have UUIDs)
* hashing takes some processing (though this shouldn't approach anything that would be a problem)
Comment 5 Travis Reitter 2011-06-17 11:53:00 UTC
I've decided the strategy below is awful, but I'm writing it down for posterity.

----------------

(In reply to comment #4)
> As discussed briefly at the hackfest, we're probably best instead making an
> Individual.id equal to the SHA1 hash of $(most relevant Persona).id

Alternatively, we could Individuals in a simple ini file with entries like:

[<some hash>]
personas=<persona id 1>;<persona id 2>;...

(or perhaps something a little more efficient, like sqlite just using cross-referencing tables)

We would still be able to suggest new links, allow linking, etc. It'd just get stored explicitly.

Benefits (relative to strategy in comment #4):
* should be more stable. We'd update the set of Persona IDs in-place whenever the links on an Individual change

Anti-benefits:
* Individual IDs would no longer be deterministic
* we'll still have to do all the work to associate implicitly in the aggregator anyhow
* this would end up duplicating most of the state in the primary backend
Comment 6 Philip Withnall 2011-06-17 12:02:58 UTC
Created attachment 190110 [details] [review]
Make Individual.id more stable (attempt 2)

http://cgit.collabora.com/git/user/pwith/folks/log/?h=652660-individual-id

As discussed at the hackfest, it would be better to use the UID of the “most interesting” Persona in the Individual to give the Individual's ID. This means that the ID may remain stable across linking and unlinking (though this can't be guaranteed).

I've updated the branch with patches to fix up the original commit to do this. The new patch is a squashed version of these.
Comment 7 Travis Reitter 2011-06-24 01:01:41 UTC
Review of attachment 190110 [details] [review]:

Looks good.
Comment 8 Philip Withnall 2011-06-24 13:47:33 UTC
Comment on attachment 190110 [details] [review]
Make Individual.id more stable (attempt 2)

commit 6ffb9775808386369c9a1fd45a072f404d410330
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Wed Jun 15 18:44:18 2011 +0100

    Bug 652660 — Make Individual.id more stable and well-defined

 NEWS                                       |    1 +
 folks/individual.vala                      |   60 +++++++++++++++++++++++---
 tests/folks/aggregation.vala               |   64 +++++++++++++++++++---------
 tests/telepathy/individual-properties.vala |   17 ++++----
 tests/telepathy/individual-retrieval.vala  |   37 +++++++++++-----
 5 files changed, 132 insertions(+), 47 deletions(-)