-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Review and Refactor of git/utils.ts
for Serving Vault Git Repositories
#298
Comments
Something else I forgot to mention was this: https://github.com/MatrixAI/js-polykey/pull/266/files#r743402477 As a general comment from what I have seen, when cloning and pulling isomorphic-git searched for the
|
Comment about how isomorphic-git library is only intended for client-side usage. We need to address this comment #266 (comment) in order to refactor and good documentation and understanding of how our git server actually works. |
@tegefaulkes based on our discussions and review of the git utilities in #266, can you link all those discussions and reviews in this issue? |
I'm going to copy relevant information here rather than link to every comment. But the original thread is here. #266 (comment) SummaryThere are 3 main functions here.
This is all handled by the top level functions
Useful technical documentationhttps://www.git-scm.com/docs/http-protocol
|
@tegefaulkes It's important also to write up how we realised that isogit is a client-only/focused library, which means it does not provide functionality useful for the server-side of git logic. The Therefore what we need to do is clean up Try to provide a summary that explains the WHY as well (not just WHAT or HOW). |
From: #266 (comment)
|
Details of this issue should be collated up top, and the issue description should have a fleshed out spec so we know what to do. |
Relevant issue here: isomorphic-git/isomorphic-git#1071 regarding some of the work on isomorphic git server side and initial discussion about his here: #43 |
git/utils.ts
git/utils.ts
for the Git Server
git/utils.ts
for the Git Servergit/utils.ts
for Serving Vault Git Repositories
@tegefaulkes with the new RPC system. What changed with respect to this? #298 (comment) |
Mostly just the handlers for the RPC were converted. I think this is still WIP as it's not fully tested yet. |
Yea the server side and client side need a deep review.
|
So right now the
|
I'm not entirely sure how to restructure this. It already mostly conforms to how we'd structure things. Except maybe renaming |
You should setup:
I believe within the git system there's stuff that corresponds to internal state those should become classes to create. |
All those magic strings and magic data should all become constants put into Look into functional decomposition of streaming, batching, and turn into using WebStreams in the same way I've done that for QUIC. Like the creation of |
Consider this a discovery/prototyping phase, then diagram out a few different alternatives, but when reading the code, it should be obvious what the structure of a clone operation is, what a pull operation is. Also what are the main data structures - whether external or internal that should exist? Make them explicit. Are there maps we need to consult, are there arrays to keep indexed, are there just stream constructs? |
There's alot we can do. |
The whole clone and pull which uses HTTP streams - because we are now using JS-rpc, and we have our own muxing and demuxing protocol, I'm thinking that you would want to preserve the HTTP protocol and properly write a wrapping and unwrapping functions. That way in the future we could maintain compatibility with real git protocols, while wrapping them into our js-rpc system. It should be made as simple and as fast as possible - benchmarks should be created for these in our From a haskell perspective, always try to think in terms of symmetry and reflexivity. |
Almost every single object - whether packs, refs or all other primitive concepts that we're using should all be given their own type in An OOP style would create things like |
|
Moving forward I'm going to do the following.
|
This is a very old spec. I won't modify it too much besides changing the task list and adding a footnote. |
Why reopen this? IS there another PRs targeting this? |
I didn't? Might be some linear weirdness but I haven't done anything besides merge this and then rebase some other PRs. |
Linear had the PR as non-closing since I only referenced it with the I'm closing it again. |
I'm not sure the linear sync is working properly. The linear issue didn't auto close after I closed this. This is a little frustrating. |
I didn't reference any PRs in my issues. Not sure if that is thing that is causing problems. |
Specification
The underlying workings of
git/utils.ts
is largely a mystery to our team. We want to perform a deep dive into the workings of this code, and remove/refactor any of our own implementation, potentially also replacing their usage in favour of theisomorphic-git/internal-apis
. There seems to be some overlap with what our git utils perform, and whatiso-git
provides.To clarify... we use git in 2 ways: as a client and as a server.
When using isogit, it only provides the primitives to use git as a client. It does not provide the primitives to use git as a server.
Why do we use git as a client and server? Well our entire secrets management system is built as a stack, from bottom to top:
pk secrets *
Polykey-CLI#32 (this is what creates "vault operations")As you can see, the "Virtual Git plus Filesystem" layer makes use of isogit. A virtual git repository is created on the virtual filesystem. This is how we are able to then stack unix operations with roughly similar semantics later, in order to maintain API consistency with what developers are used to.
Now the issue is that isogit by itself can act like a git client. That means it can clone/pull repositories, it can create repositories, it can create commits, it can manage the git objects... etc.
However isogit cannot "serve" the repositories. And this is essential to be able to share our vaults.
To serve our repositories we need to know how to act like a "git server" when we use isogit or something were to use git to try and clone/pull our vaults.
So a long time ago, we developed the git server primitives and put them all into
git/utils.ts
. However this code has not been heavily tested, nor has it gone through any refactoring since then. And since then we have forgotten how it all works, and it's not in the programming style that we have developed over the last few years working on Polykey.So the
git/utils.ts
needs to go under review, and most likely some heavy refactoring with the addition of tests, to ensure that acting like a git server makes sense here.Now there is definitely cross over between isogit and the
git/utils.ts
. However we aren't aware of what these are. And there probably should be a bunch of "shared types" and similar constructs. We just need to get into it, and get it done.How this was addressed
After reviewing the code as it was, we ended up just cleaning it up by refactoring the
http
response to be streamed using an async generator. Most of the utility functions were removed in favour of using theisomorphic-git
plumbing functions for interacting with the git data structure.Ultimately this didn't speed things up very much, however, it did significantly reduce the complexity of the git domain. So it is much easier to follow along with what is happening. There is also a slight improvement with pulling a repo. We use the
haves
provided by the client to only grab the minimum objects required for the pull.Additional context
Tasks
The text was updated successfully, but these errors were encountered: