Design a package installer system (like a simplified OS/package manager) that installs packages while respecting dependency resolution.
Requirements
-
Input: a request to install package
P
(optionally with a version constraint).
-
Each package may depend on other packages (with version constraints).
-
The system must resolve dependencies and install packages in the correct order.
-
Detect and report errors clearly:
-
missing packages
-
version conflicts
-
dependency cycles
-
Handle partial failure (e.g., installation fails mid-way) safely.
Follow-up
-
What if a package includes a
payload
(configuration/parameters/artifacts) that must be passed into the installation step? How would you model, validate, and deliver that payload securely and reliably?