Design Distributed Unused-Code Analysis
Analyze a fixed company-wide code snapshot and produce explainable unused-code candidates without mistaking libraries or incomplete analysis for safe deletion.
Problem statement
For this exercise, assume an engineering maintainer submits an immutable manifest of project revisions, an analysis-policy version, and a registry of application entry points, library exports, and declared initialization roots.
The service analyzes code units and their references across that company-wide snapshot, then returns one reproducible report.
Code units have stable project, revision, and symbol identities; the supported language adapters identify references, while unsupported inputs and unresolved dynamic or external uses remain explicit uncertainty.
For this exercise, use three report classes: keep for a unit reached from a registered root by a known reference path; unused-under-model for an unreached unit only when the relevant input and root/reference coverage is complete; and unknown when the available model cannot rule out a use.
A library need not contain a main function to be useful. A build dependency tree or lack of observed runtime activity alone does not establish that code is unused. An unused-under-model result is a review candidate under the declared assumptions, not a proof that deleting it is safe in every real execution.
The maintainer can inspect the evidence and coverage behind each result and produce a removal proposal pinned to the same snapshot and policy. The service never deletes code. A later revision or policy creates a new analysis and proposal; it cannot silently change an earlier report.
Include distributed scanning, cross-project references, graph cycles, worker failures and retries. Keep compiler implementation, running arbitrary project code, repository hosting, automatic deletion, and rollout of a removal outside scope.
What to build
- A maintainer can submit a fixed project-revision manifest and root/reference policy, recover the same analysis after a retry, and inspect its progress.
- The service produces a reproducible keep, unused-under-model, or unknown classification for each code unit, including cross-project references and libraries.
- The maintainer can inspect a known root/reference path or the complete-coverage evidence and uncertainty that justify a classification, with paginated results.
- The maintainer can select unused-under-model units for a reviewable removal proposal bound to the exact report, snapshot and policy, without deleting code.
At scale
- For this exercise, assume up to 10,000 projects, 100 million code units and 1 billion reference edges in one company-wide snapshot; one worker has 4 GiB of memory. The full graph cannot fit in one worker.
- For this exercise, target a sealed report within 24 hours when every declared input is readable and supported. Unreadable or unsupported inputs must be visible and may leave results unknown; the target never licenses guessing completeness.
- For this exercise, expose analysis progress and paginated report reads within one second at p95 under normal capacity. Results and pages must stay pinned to a report revision while background workers continue or retry.
- For this exercise, retain snapshot manifests, coverage evidence, reports and removal proposals for 30 days. Worker or coordinator loss may delay completion, but must not mix revisions, count retry outputs twice, or authorize a proposal from incomplete evidence.