Design a Versioned Package Download Service
Resolve an exact package version and its dependencies, then download only missing verified artifacts without mixing versions during retries.
Problem statement
For this exercise, assume a developer requests a package at an exact version for one target platform. An approved catalog supplies immutable package-version manifests and artifact bytes. Each manifest identifies its artifact by digest and size and lists exact dependency versions for that same platform.
Design a service that finds the complete transitive dependency closure and identifies the artifacts missing from a supplied local inventory. A different version or digest does not satisfy an exact requirement.
Different versions of one package may coexist in separate local directories; this service downloads files and does not install them.
A successful plan names one catalog revision, the complete closure, each artifact's digest and size, and an expiry. It must not silently return a partial closure when a manifest is missing, the dependency graph contains a cycle, access is denied, or the graph exceeds the stated limits.
A catalog update must not change a plan already being resolved or used. Equivalent retries of a plan request return the same plan identity; conflicting reuse of the request identity is rejected.
The caller supplies an inventory of exact coordinates and digests it has verified locally. It verifies reused and newly downloaded bytes against the plan before declaring its local download complete. If local state changes, it can recompute the missing set against the same unexpired closure.
The server's ready plan is evidence of successful resolution, not proof of the caller's local files or an installation.
Allow resumable downloads of the same immutable artifacts. Check access to every closure member before plan success and check current access again when issuing or renewing a download grant. A grant lasts at most five minutes and never outlives its plan.
Revocation denies new grants; already issued grants may remain usable until their expiry, and bytes already received cannot be recalled. Plans remain valid for 24 hours.
Ordinary garbage collection retains their referenced metadata and bytes through expiry, but a storage failure, integrity failure or access denial must remain explicit rather than silently substituting another version.
Explain version lookup, graph resolution, inventory comparison, plan persistence, caching, authorization, byte delivery, retries, expiry and recovery. The approved catalog and artifact store are supplied boundaries.
Publishing or scanning releases, installing or executing packages, build execution, semantic-version constraint solving and multi-region active-active operation are outside scope.
What to build
- A caller can resolve an exact root package and platform into a complete, authorized dependency plan pinned to one catalog revision, with explicit invalid, denied, unavailable or oversized outcomes.
- A caller can compare verified local inventory with the plan and fetch only missing exact artifacts through resumable, authorized downloads with end-to-end digest verification.
- A caller can recover an equivalent plan request, renew eligible download grants and reconcile local changes against an unexpired plan without changing its versions or falsely declaring local completion.
At scale
- For this exercise, assume one million package-version/platform records, at most 50 direct dependencies per manifest, and accepted closure limits of 1,000 distinct coordinates and 5,000 dependency edges. Reject larger requests explicitly.
- For this exercise, serve 500 new plan requests per second and complete healthy, accepted planning requests within 500 milliseconds at p95. Popular roots can be requested repeatedly, but local inventories and access permissions differ by caller.
- For this exercise, support 10,000 concurrent artifact downloads, with artifacts from 1 MB to 1 GB. Begin an eligible byte response within one second at p95 under healthy conditions; this is not a whole-file transfer deadline.
- For this exercise, keep plans usable for 24 hours and retain their referenced metadata and bytes through ordinary cleanup. Acknowledged plan metadata and referenced artifacts must survive one availability-zone loss; access revocation and explicit integrity or storage failures remain visible exceptions to successful delivery.