made using Leaflet

tangled: shared-stacks proposal

This is a proposal to address tangled's current stacked-PR situation.

The original discussion can be find on discord thread

High Level Problems

Can't stack the group of stacked PRs

See #393 as an example.

Currently a PR is a minimal reviewable object and there isn't any bigger (or smaller) object than it.

Can't review the entire stack group

With non-stacked PR, we can review the entire stack of changes but not individuals. With stacked PR, we can review individual changes as PRs but not the whole stack (submitted feature.)

Due to this limitation, it's pretty common to explain or request a review for entire stack in discord.

Can't share same stack between PRs

Current stacked PRs are more similar to GitHub's commit review where you can review in context of specific commit. In Graphite style stacked PR workflow, multiple PRs can stack on top of same PR constructing a tree of PR stacks.

Low Level Problems

So why that happened?

Because we are basically trying to atprotate the git commit history as list of patches. Commits are self-signed and linear. The commit history itself is already a stack (or a tree which allows sharing same parent commit). The commit-id and change-id are technically some form of decentralized ID. We don't need to make 1:1 clone of git commits

Solution

Reintroduce PR as a pointer to HEAD commit

A PR is a submittable object pointing specific commit-hash.

We don't need a record to represent individual commits/changes/stacks. They are already decentralized as git commits. AppView might cache them for easy reference, but we don't need to decentralize them again.

Although commit-id is not part of atproto, we can still use it as a soft-link between git-objects and atproto records. Similar to how blob-ids link between atproto records and blobs. This is why I made git-objects proposal redefining Knot as an external blob store for git objects.

Fig 2. git-objects proposal

Round only exists for PRs, not stacks

There wasn't any issue on current design, but if we start sharing stacks (AAA from Fig 1-1), the evolog of a stack is not linear anymore. See Fig 1-2. Change BBB diverged to BBB' and BBB'' when PR#124 is resubmitted.

Fig 1-1. User edit change BBB and resubmit #123 as round 1. And then create a new PR #124 on top of #123/1
Fig 1-2. user edit change BBB' and resubmit #124 as round 1 (#123 remains on BBB')

The concept of rounds (linear evolution log over a PR) can only exist for actual PR HEADs. When a user resubmits a PR, they only update the PR's HEAD and not update every individual commits included in that PR (that is how we handle PR resubmits; resubmitting every PRs included in same stack.)

My guess over current design choice is to handle resubmitted stack only with history change in future. When interdiff is empty, we want to preserve the previous discussions. I'll address this problem later in this post.

Submit Message instead of PR message

The author might resubmit with messages like "Hey, I addressed your review. plz review it again", or provide a new context over updated commit history. This message will serve similar role to 0th patch message in Mailing List Workflow.

I've considered making this as a separate dependent proposal, but considering it's pretty small, I think it's fine to include here.

Comments referencing commit-id instead of at-uri

Although we can submit a stacked PR and track the evolution using change-id and commit-id, change review comments should point the target 'change'. Well, as I said, the commit-id is already a decentralized identifier. Nothing is stopping us from using it as a reference to the change.

So feature review comment will reference the specific PR with at-uri, and change review comment will reference the specific commit with commit-id.

See the summary below for detailed lexicons.

More notes

Change review page should depend on PR context

Fig 1-3. user edit change BBB and resubmit #123 as round 2
Fig 1-4. evolog of change BBB from Fig 1-1 to 1-3

See Fig 1-3 and Fig 1-4. BBB' has been diverged to BBB'' for PR#124/1 and BBB''' for PR#123/2. This is really rare case and shouldn't even happen imo, but theoretically possible. So AppView should be able to handle this kind of evolog.

For PR#123's perspective, BBB'' is useless. Therefore, page /pull/123/change/BBB should ignore the BBB''. In other words, Change review page should ignore evolog from other PR.

Mailing-List Workflow vs Shared-Stacks

Fig 3. Mailing-list workflow vs Shared stacks

With shared stacks design, we can have near identical review flow to mailing list workflow.

review-bubble-up behavior

In Fig 1-2, change CCC and DDD remained unchanged but their commit hash changed. We don't want to loose previous unresolved discussions due to history changes. So I'm introducing review-bubble-up behavior for AppView.

Fig 4. review bubble-up behavior

The AppView will basically 'bubble up' the old reviews from change's evolog if the interdiff is empty.

Summary

PR only holds a HEAD of a submission (no atproto representation for commit history)

User can resubmit a PR to update the HEAD

User can comment to specific PR submission(round), same as before.

User can comment to specific change inside the submission by referencing with commit-id instead of PR's at-uri.

Updated atproto lexicons

Fig 5. New PR-related atproto lexicons

sh.tangled.repo.pull represents mergeable object like PR #123 It holds metadata like target, source, title and body but does not represent the exact PR content

sh.tangled.repo.pull.submit represents each PR submissions. It is atprotated PR round holding the actual PR content which is the HEAD commit hash. Actual commit is stored in author's knot (see git-objects proposal.)

sh.tangled.repo.pull.comment represents a feature-review comment. It targets to specific PR round with at-uri

sh.tangled.repo.pull.change.comment represents a change-review comment. It targets to specific change with commit hash and might include pull.submit at-uri as a context.

We might want to merge pull.comment and pull.change.comment lexicons but I'm separating them here for clarity.

Updated AppView Router

pull/123

feature review page

Same as current non-stacked PRs. Individual review thread for each submissions. We might not collapse those threads or at least the 0th round to show entire review history.

pull/123/change/BBB

change review page

closer to current stacked-PRs where maintainers can review each commits separately. Round number follows the resubmission of parent PR.


made using Leaflet