Discontinue use of inputs-digest in Gopkg.lock #1496
Description
Gopkg.lock
contains a property called inputs-digest
, which is a hash of the relevant inputs to the solver that were used to generate that Gopkg.lock
. The digest value can be generated by running dep hash-inputs | tr -d “\n” | shasum -a256
. For reference, this is dep hash-inputs
output on dep itself:
-CONSTRAINTS-
github.com/Masterminds/semver
https://github.com/carolynvs/semver.git
b-parse-constraints-with-dash-in-pre
github.com/Masterminds/vcs
svc-^1.11.0
github.com/boltdb/bolt
svc-^1.0.0
github.com/go-yaml/yaml
b-v2
github.com/golang/protobuf
b-master
github.com/jmank88/nuts
svc-^0.2.0
github.com/pelletier/go-toml
b-master
github.com/pkg/errors
svc-^0.8.0
-IMPORTS/REQS-
github.com/Masterminds/semver
github.com/Masterminds/vcs
github.com/armon/go-radix
github.com/boltdb/bolt
github.com/go-yaml/yaml
github.com/golang/protobuf/proto
github.com/jmank88/nuts
github.com/nightlyone/lockfile
github.com/pelletier/go-toml
github.com/pkg/errors
github.com/sdboyer/constext
golang.org/x/sync/errgroup
-IGNORES-
-OVERRIDES-
-ANALYZER-
dep
1
Basically, a list of all the imports, constraints, overrides, requireds, and ignoreds.
There are a few reasons why relying on an explicitly-recorded hash digest for this is suboptimal:
- It's just not saving us a meaningful amount of work. Instead of relying on the inputs-digest to match, we could directly compare the hash inputs against the values recorded
Gopkg.toml
to see if everything lines up. - Moving to a direct check would also allow us to give meaningful feedback when something's out of sync, rather than just complaining of a hash mismatch.
- Relying on hash comparison makes the check unnecessarily brittle. Moving to a direct check would allow, for example, constraint changes to be made in
Gopkg.toml
without triggering a re-solve, so long as what's inGopkg.lock
is still acceptable with respect to those new constraints. (e.g., if we constraint on^1.0.0
but havev1.1.0
locked in, then moving the constraint to^1.1.0
would be fine with a direct-check system, but would trigger a pointless re-solve when relying on hash comparisons). - As it's hard to know what to do when inputs-digest in Gopkg.lock conflicts #1224 outlines, it creates the possibility for spurious merge conflicts that cannot be easily resolved.
To do this, we'll need to write some new general gps functions for checking if a lock is acceptable with respect to an input set, and probably tweak a bunch of our comparison logic. idk the full extent of it right now - i have to dig a bit. But, we need to do this.
To be clear, there's still potential value in these inputs hash digests, mostly around the possibility of pushing some computation to an edge cache, and/or enabling some prefetching or pipelining of data from upstream sources. But using it for this particular local-only check is just bad, and we need to stop.