sdboyer / gps

your dependencies have arrived
MIT License
270 stars 24 forks source link

Expand `ProjectName` concept to encompass URI and URL concepts #10

Closed sdboyer closed 8 years ago

sdboyer commented 8 years ago

Right now, ProjectName - which is assumed to be a universal-style import path - is a URI that is assumed to be independently sufficient for locating the underlying repository resource. Of course, that's a bad assumption...it's a URI, not a URL. Now, we have sort-of-passable algorithms that infer a URL from the URI, but that's not really the problem. Actually, there are a couple problems.

First and foremost, we have to allow the user to specify the URL. Inference can still be applied if the user doesn't supply the URL, of course. But in situations where that simple inference would be wrong (e.g., the inference will always try git over https, but you want/need to specify ssh), an override must be possible. Allowing such overrides, though, creates new problems:

The first problem is easily addressed: logic, like this, can be written that effectively normalizes all equivalent URLs into a single, canonical form.

The second problem is a bit trickier because of its adjacency to another issue: aliasing. First, though, what we do know is that on any given solver run, we encounter URI/URL combos describing projects. If, at any point, we re-encounter a URI and the new normalized URL is not the same as the existing normalized URL, then we have incompatible sources, which fails one of the solver's satisfiability conditions (aka, we'll enforce this in *solver.satisfiable()).

Conceptually, this means that all projects involved in the solution (root and non-root) have equal "say" on what a URI is - and they all must agree.

Aliasing - where we transparently swap in one repository source at another's URI/import path - needs to function differently: it should be global. That is, rather than being something on which all projects can express a viewpoint and the solver must maintain satisfiability, aliases are a transformation that are allowed by only one project (the root), and are applied globally.

Aliases (necessarily) supercede URL declarations. But, because they both deal with the URL property, the significant question is whether having an alias applied to a particular URI/ProjectName is reason to suspend the satisfiability condition that all participant projects must agree on the URL for that URI.

The easy answer is "yes, suspend that satisfiability condition" - because we know the URL is going to end up being the same for that URI, it doesn't matter if everyone agrees. The problem with that, though, is that it's really just masking a potentially significant disagreement within your depgraph, and reconciling disagreement is not the purpose of what I think of as an alias. Aliases are about changing a name, GIVEN agreement on what that name refers to. The practical effect of this would be that aliases would be used to force agreement on URLs...and we'd see absurd things like projects aliased to themselves in order to make things work, and of having aliases propagate up dependency chains.

Instead - and since we know we need a concept of overrides in general, anyway - I'd prefer to see that forcing of agreement done via an override. They also operate globally (and thus are used root-only), but their intent is more clear in the name.

sdboyer commented 8 years ago

I've reflected on this more...and what I initially outlined is probably mostly wrong. Will update when I return to it and figure out the better approach.

sdboyer commented 8 years ago

So, seems like my initial thoughts were sorta-right, sorta-wrong. I jotted down some more things:

Import path is an expression of intent to rely on something that exists at that address - which must ultimately be a local filesystem address, but may also be a network address.

sdboyer commented 8 years ago

19 takes care of the basic local/network naming distinction. next up is global/root-level aliasing...though we can leave that out for a bit, as it's less urgent.

sdboyer commented 8 years ago

This kinda just doesn't apply anymore. I don't have the energy to type up another analogous issue right now, but the issues here have migrated a bit since firming up static analysis and the notion of ProjectRoot.