advanced24 min studyLesson 431 in Engineering

Lock a resolved dependency graph without confusing it with trust

Distinguish version constraints, concrete resolution, artifact integrity, and availability when assembling AI software environments.

On this page

What you’ll understand

  • Separate a manifest’s allowed versions from one resolved graph.
  • Explain what hashes and frozen-install modes establish.
  • Identify platform, build-step, and availability inputs outside a lockfile’s promise.

An inference service installs successfully on Monday and breaks when rebuilt on Friday. Its top-level requirements did not change, but a transitive package or platform-specific artifact did. A lockfile records a concrete resolution so later installation can avoid silently choosing a different graph. That is useful control over inputs, not a certification that the selected code is safe, available forever, or sufficient to reproduce every byte of the final container.

Resolution turns constraints into particular choices

A manifest can permit a range of package versions while several dependencies impose overlapping constraints. The resolver chooses concrete versions and graph edges according to the ecosystem's rules, registry state, target, and configuration. npm, pip, and Cargo do not share one universal resolution model. Peer dependencies, optional features, environment markers, and platform wheels can change which artifacts are relevant. Record the installer and target context required by your project instead of assuming a top-level version list describes every package that installation will use.

A lockfile captures a selected result and usually additional source or integrity information according to its format. npm package-lock records a dependency tree; Cargo.lock records resolved package choices. Review lock changes as changes to executable inputs, including newly introduced transitive packages and source locations. A frozen installation mode should fail when the manifest and lock cannot satisfy its contract rather than quietly update the lock in deployment. In npm's documented ci workflow, consistency and installation flags matter; copying a lock without the matching relevant configuration is not an adequate release definition.

Vallowed=⋂j=1mVjV_{\mathrm{allowed}}=\bigcap_{j=1}^{m}V_j
This illustrative set intersection describes compatible version constraints for one package before ecosystem-specific resolution. Sets contain version identities, not probabilities; an empty intersection requires a resolution or dependency change.↔ Scroll wide equations horizontally.

Integrity pins bytes, while review decides whether to trust them

A recorded artifact hash can detect that retrieved bytes differ from the approved expected bytes, assuming the hash and its trusted recording are sound. It does not tell you whether those expected bytes contain a defect or malicious build script. pip's hash-checking mode requires hashes across the requirements and their dependencies under its documented restrictions; a partial set does not establish a complete integrity boundary. Different acceptable wheels or source archives may require several approved hashes. Name which artifact variants are permitted and why instead of treating one package version string as one universal byte sequence.

Installation can execute code, compile native extensions, or download additional inputs. A source distribution hash pins that source archive, not every compiler, build dependency, or later network fetch it invokes. An AI package may compile a kernel using the host toolkit or fetch a model outside the package resolver. Inventory those steps separately. Registry access controls and encrypted transport help govern where bytes come from, while integrity checks compare those bytes with a trusted expectation. Neither mechanism replaces review of the selected dependency or containment of build-time execution.

integrity match⁡  ⟺  H(retrieved bytes)=hexpected\operatorname{integrity\ match}\iff H(\mathrm{retrieved\ bytes})=h_{\mathrm{expected}}
The hash algorithm and expected digest must be trusted and applicable to the selected artifact. Equality provides content-integrity evidence under collision assumptions, not availability, authorization, or semantic correctness.↔ Scroll wide equations horizontally.

Retain the approved inputs and update deliberately

A locked download can disappear, become inaccessible, or require a credential that expires. Availability needs an approved retention or mirror strategy and a tested restoration path. Avoid silently substituting another artifact when retrieval fails; a replacement belongs in an explicit update and verification workflow. Record the base image, interpreter, compiler, installer version, and target architecture needed to interpret the lock. When upgrading, inspect the graph delta, run relevant compatibility checks, and regenerate provenance and inventory for the actual resulting artifact rather than reuse yesterday's supporting documents.

The modular lab illustrates only why rotating labels are poor immutable identities. Reset, set both modulus m=4 and step a=1, predict the return to label zero, then Play or Step through four additions. A later state can reuse an earlier label even though its history differs. This is not a dependency resolver or hash function. A real release should retain the concrete package and artifact identities needed for its target, rather than rely on a mutable tag or a human-friendly version alias as if it could never move.

Count shared transitive packages once

A fictional application directly uses packages A and B. A depends on C and D; B depends on the same resolved C and on E. Assume each letter names one concrete package-version-artifact identity, with no other dependencies.

  1. The application has two direct package identities, A and B. Traversing their edges adds C, D, E as three distinct transitive identities.

  2. The closure therefore contains five distinct dependencies, not six: the two references to the same resolved C do not make two different package identities.

  3. A lock review must still retain both dependency relationships and the concrete sources or hashes. If A and B instead resolve different versions of C, those would be distinct identities and the count would change.

The result

The specified closure contains five concrete dependencies. Counts and graph edges answer different inventory questions, and neither count certifies the code’s trustworthiness.

Explore the model

Interactive lab

Interactive lab · modular

A reused label is not a pinned package artifact

Reset, set both m=4 and additive step a=1, predict the fourth addition, then Play or Step. The residue returns to zero. This models label reuse only, not package resolution, version semantics, or cryptographic hashes.

A reused label is not a pinned package artifactAddition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Current readings: Residue r0: 0; Orbit period · m/gcd(m,a): 12; Distinct residues visited: 1 of 12. All parameters are adjustable with the labeled controls below.Repeated addition modulo 12: the current residue is 0, and the orbit period is 12.01234567891011+ 5mod 12An additive orbitn = 0rₙ = 0Period = 12Cycle starts at 0:0 → 5 → 10 → 3 →8 → 1 → 6 → 11 →4 → 9 → 2 → 7 → 0Exact residues · two additions per second
Additive orbitCurrent residue / next edge
Residue r0
0
Orbit period · m/gcd(m,a)
12
Distinct residues visited
1 of 12
t = 0 s

Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forPin the concrete artifact identities and target configuration. A mutable discovery label cannot supply an immutable release-input contract.

Check your understanding

A locked artifact passes its expected hash check. What does that establish?

Try it yourself

A release has 40 distinct locked dependencies. Three approved binary variants are needed for each of four packages; each other package needs one artifact. How many artifact variants must the inventory distinguish?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Count variants, not dependency edges or top-level package names.

Compare with the solution

The four multi-variant packages require 12 artifacts and the remaining 36 require 36, giving 48 artifact variants. Each applicable platform choice and trusted integrity value must be represented;40 package identities alone does not describe all permitted bytes.

Take it with you

  • A lock captures a concrete resolution under ecosystem and target rules.
  • Trusted hashes bind expected bytes, while review, isolation, and availability need separate mechanisms.
  • The complete AI release includes toolchains and downloads outside ordinary package resolution.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.