Skip to content

Instantly share code, notes, and snippets.

@flyingzumwalt
Created June 2, 2017 18:31

Revisions

  1. flyingzumwalt created this gist Jun 2, 2017.
    86 changes: 86 additions & 0 deletions ipld-version-control.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,86 @@
    InterPlanetary Version Control (call it `IPVC`?)
    =======
    > IPLD-based Version History

    This is just a sketch of a possibility. If we just want a git-style toolchain with git version graph, it might be better to just put an ipfs storage adapter behind [go-git](https://github.com/src-d/go-git) -- basically putting IPFS unixfs trees where git usually creates git tree objects. In that case you would have regular git commit objects, not IPLD objects. That would be less reusable beyond the git context but it would fit better with existing git-based tooling.

    Keep in mind: it will be really useful to be able to use IPFS files api to manipulate these trees, allowing you to do things like modify part of a large dataset and commit the changes without ever pulling the whole dataset -- you can just pull the parts that you're changing.

    # Features

    * Cryptographically-tracked version History
    * Metadata (both required and optional) for commits in the version history (author, timestamp, log message, gpg signature)
    * Named Branches and "refs": mutable names that point to commits
    * View log history

    # Commands

    Some commands we need in the version-control toolchain

    ASIDE: What is an MVP here? We don't want to recreate all of git. Just want to provide clear, reliable tools for creating version history layer in IPFS.

    `ipvc repo init <repository-name>` / initialize a new ipvc repo in ipfs & generate an ipns name for it
    `ipvc repo list` / list all local ipvc repositories
    `ipvc clone <repository-hash>` / pull the repo corresponding to `<repository-hash>` onto the local machine
    `ipvc commit <ipfs-hash>` / add <ipfs-hash> as the new head
    `ipvc rebase -r <repository-hash>`
    `ipvc log`

    `ipvc repo add `


    # Implementation Notes

    Version entry (modeled on git commit objects):

    Example of git commit object:
    **TODO: get a real, complete example with gpg info**
    ```
    commit QmUmg7BZC1YP1ca66rRtWKxpXp77WgVHrnv263JtDuvs2k
    Author: Ada Lovelace <ada@lovela.ce>
    Date: Fri June 22 18:15:24 1833 -0000
    ```

    Expressing this information as IPLD:
    ```json
    {
    "commit": {"/":"/ipfs/QmUmg7BZC1YP1ca66rRtWKxpXp77WgVHrnv263JtDuvs2k"},
    "message": "this is a commit message",
    "parent": {"/":"/ipfs/d1c37bcb9f75ac4fba968b47db9dcbd697bd453a"},
    "Author": "Ada Lovelace <ada@lovela.ce>",
    "Date": "Fri June 22 18:15:24 1833 -0000",
    // optional gpg signatuure info
    "signature": { // gpg signature info }
    }
    ```

    imagine that the hash of this is <hash-of-v1>

    Version History:
    ```json
    {
    "head": {"/": "../versions/0"}
    "versions": [
    {"/":<hash-of-v3>},
    {"/":<hash-of-v2>},
    {"/":<hash-of-v1>}
    ]
    }
    }
    ```

    imagine that the hash of this is <hash-of-current-history>

    Make the ipns entry point to <hash-of-current-history>

    Example IPLD paths:

    `/ipns/<ipns-hash/head`

    `/ipns/<ipns-hash/head/commit`

    Equivalent of git cat head^2
    `/ipns/<ipns-hash/2/commit`
    which resolves to the same thing as
    `/ipns/<ipns-hash/1/parent/commit`