amilner42/viva-doc

Tag Identity and deletion carry-overs

Opened this issue · 0 comments

Tag Identity and deletion carry-overs

Problem

Carrying over deleted tags without tag identity doesn't seem possible.

Details

At the moment all tag identity (for knowing whether a tag user assessment propagates forward) is done simply with diffs and the line numbers of the file.

If we have a commit structure as follows:

   O (PR HEAD)
  / \ 
0    0 
|   /
|  /
| /    
0

This arises in the pull request branch merging with the base branch.

We now have a different total diff from the PR head against the new BASE branch and we need to calculate what gets carried over for this diff. It's important to note that the path from the HEAD commit to the BASE is no longer is intercepted by the INTERMEDIATE from which we want to propagate carry-overs forward.

The way "identities" were done in the current code is that we simply use the line numbers in the current file. So if a tag [with the annotation on line 17 in the current file] has been modified between the base and the HEAD and has not been modified since the intermediate commit, then we carry over whether it's been approved/rejected.

The issue arises with deleted tags, how do we know if a deleted tag between HEAD and BASE is the same as a deleted tag between HEAD and INTERMEDIATE - there are no current line numbers.
The IDENTITY of the existent tags is always simply there content. If the tag hasn't been modified we carry-over its value even though technically this may not be the same tag (imagine deleting a tag and then re-adding the same tag). This is because if you've approved exactly that code even if it's a different tag you've approved the same value so it should be fine. It's difficult to figure out what is this identity for a deleted tag?

It's actually also a conceptual question because it's asking "what does it mean to approve a deleted tag". When you approve a deleted tag, when do you, as a user, want that to propagate forward.

Solution

Pre-deploy solution

It's too lengthy to do a proper solution, so for now deal it with it in some simple way in another issue [#101].

Post-deploy solution options

Possible Short-term solution
Goal

The key question is how good of a solution can we provide without tracking tags across all commits and doing identity that way. If it's possible to provide a short-term solution that would be great to deploy as this is not a super common case.

Short Term Solution

Perhaps we can provide a solution that doesn't always correctly carry-over deleted tags but does in most situations.

For it to be a carry-over, it must be:

  • Not deleted between the HEAD and INTERMEDIATE.
    • So if we see something deleted between HEAD and INTERMEDIATE that could be that tag, we don't do carry-overs.
      • How to detect "could"?

Otherwise, if we see nothing deleted between HEAD and INTERMEDIATE that could be that tag, we know that it's already been deleted. In which case, we have to figure out what it's possible carry-over value is.

Even if there is only 1 tag that could be that tag given the perspective from the current file line numbers and the insertion of the single line with the removed tag, we don't know that it is the carry-over value because a tag could have been deleted and re-put in that same line. While existant tags get to use the identity from the current file (same line number no difs between all owned lines), it seems that conceptually deleted tags just can't work that way, they have to relate to a specific instance as an identity?!

Long term solution

Ultimately if all the tags had an ID, which we will eventually need anyway, this would be a non-issue. We would keep track of tags across all commits and make sure that we give the same tag the same ID on different branches and then we would check by simply checking was tag with a given ID already deleted.

This seems like a fair bit of work though, because I'll have to start analyzing every commit and also deal with that right when they sign up.

Brainstorm

What if NO tags are deleted between HEAD and INTERMEDIATE. It must be the case then that all the deleted tags have been approved.

Now let us say that a tag IS deleted between HEAD and INTERMEDIATE, does that mean it must have been deleted between HEAD and BASE.

  • No, imagine we added a new tag in the PR and then deleted it on the merge. This deleted tag does not correspond to anything between HEAD and BASE.
    • How can we figure out if they are the same?!