AeroDx Ships a Medical AI That Admits It's Fake

Inside a lung-disease triage API where the model returns random diagnoses, every result says so in writing, and the swap-in seam is the entire point.

8 min read • View on GitHub • More from Kamalpegu

A wide interior scene of a hospital triage consultation desk drawn in black crosshatched ink. Behind the desk sits a wooden artist's mannequin in a white coat, holding up a hand-lettered placard that reads 'I AM A MANNEQUIN.' A patient file and stethoscope rest on the desk. The illustration captures the article's central idea: a system performing a medical role while openly declaring it is not real.
AeroDx performs the entire clinical workflow while telling every consumer, in the data itself, that the brain is missing.
Key Takeaways

The Diagnosis That Snitches on Itself

Run a CT scan through AeroDx and you get a result. A label. A confidence of 0.94. A probability vector that sums to 1.0 and looks exactly like softmax output. Everything a frontend needs to render a believable clinical triage screen.

Then you read the payload and the illusion collapses. The result carries model_version="stub-v0.1". Its recommendation field reads, verbatim: "This is a STUB result. Integrate real model before clinical use." The label was drawn with random.choice(list(DiseaseLabel)). The confidence came from a uniform draw between 0.70 and 0.99.

The system is lying, and it wants you to know. That is the whole idea.

Most prototypes bury their placeholders. A hardcoded return "Normal" hides in a corner of the codebase and leaks into a demo the moment someone forgets. AeroDx takes the opposite approach: the placeholder status lives inside the response object, at the same level as the diagnosis it is qualifying. In a regulated domain, that is a design discipline worth studying.

Four Endpoints, One Missing Brain

The main.py docstring lays out the intended workflow in four steps. Upload a scan. Analyze it. Ask questions about the result. Download a PDF report. Each step maps to a real endpoint, and each endpoint works end to end.

Four real endpoints, one shared schema, and a predict() call that returns random labels. The API shape is finished; the inference is not.

The layering is clean. routes handles HTTP and almost nothing else. services holds the behavior. models/schemas.py defines the shared vocabulary that both layers speak. When a route needs a scan, it asks scan_service. When analysis is required, scan_service asks ml_service. Every dependency points one direction.

That structure is what makes the missing brain survivable. Because predict() returns a fully typed AnalysisResult, nothing upstream cares whether the object came from a neural network or a coin flip. The schema is the contract, and the stub honors it.

The Seam Is the Product

Three files are marked for replacement, each with explicit instructions in its module docstring. ModelLoader.load() for loading weights. MLService.predict() for inference. chat_service._generate_reply() for wiring in an LLM. The docstring is not a comment; it is a handoff document.

The claim that "everything else needs zero changes" is credible because predict() returns a typed object, not a dict, not a tuple, not a loose bag of primitives. Swap the body of the function and every downstream consumer keeps working, from the chat router to the PDF generator.

But the most interesting part of the seam is what does not get replaced. The result stamp, the version field, the recommendation string: those survive the swap. They belong to the contract, not the stub. A real model inherits the honesty machinery even after it stops needing it.

Pydantic as the Single Source of Truth

The schemas do work the model would otherwise have to do. Bounds, enums, and length limits are enforced at every boundary, so malformed data cannot enter the pipeline regardless of what produces it.

class DiseaseLabel(str, Enum):
    NORMAL = "Normal"
    COVID19 = "COVID-19"
    PNEUMONIA = "Pneumonia"
    TUBERCULOSIS = "Tuberculosis"
    LUNG_CANCER = "Lung Cancer"
    PULMONARY_FIBROSIS = "Pulmonary Fibrosis"
    UNKNOWN = "Unknown"

class Finding(BaseModel):
    region: str
    description: str
    confidence: float = Field(..., ge=0.0, le=1.0)

class AnalysisResult(BaseModel):
    predicted_label: DiseaseLabel
    confidence: float = Field(..., ge=0.0, le=1.0)
    severity: SeverityLevel
    findings: list[Finding]
    recommendations: str
    model_version: str
    raw_probabilities: Optional[list[float]] = None

class ChatRequest(BaseModel):
    message: str = Field(..., min_length=1, max_length=4000)
    scan_id: Optional[str] = None

Two details stand out. The six-label taxonomy is broader than the sibling covid_detector_package suggests, and the UNKNOWN label is a sensible escape hatch for a model that has not been trained yet. And the 4000-character cap on chat messages is a genuine defense against prompt-stuffing if an LLM is later wired into _generate_reply(). That is the kind of constraint you only add if you are planning ahead.

The confidence field is bounded to [0.0, 1.0] on every object that carries one. So even the random draw from [0.70, 0.99] is guaranteed to land inside the range a real model would produce. The stub is not just random; it is random within the shape of a valid result.

Where the Scaffold Leaks

A close-up macro illustration of a single precision-machined gear sitting in an empty threaded socket, with a paper tag tied to its axle reading 'STUB v0.1.' The socket around it is fully threaded with bolt holes and alignment pins drawn in fine stippled detail. A second gear, half-visible at the frame edge, is still wrapped in protective paper. The image shows the swap-in seam as engineered hardware: the empty seat is built to receive a real part.
The empty socket is not improvised. It is threaded, aligned, and waiting for a gear that already exists in a sibling package.

The scaffold is honest about its own gaps. The scan_service stores live in module-level dictionaries with an inline comment that reads, in effect, replace with SQLAlchemy, MongoDB, or Redis in production. Restart the process and every scan vanishes.

None of these are failures. They are the expected shape of a proof of concept, and the code comments say so. The scaffold knows it is a scaffold.

What a Stub-First API Buys You

AeroDx (stub stage)Typical demo scaffoldProduction medical AI
InferenceRandom labels, honest version stampRandom or hardcoded, unlabeledValidated model, versioned weights
PersistenceIn-memory dicts, lost on restartOften noneDatabase with audit log
AuthNoneNoneRequired, role-scoped
Audit trailPDF metadata table onlyUsually absentFull request and model provenance
Placeholder honestyExplicit in the result payloadImplicitNot applicable

AeroDx loses to a production system on every operational axis. It loses to a typical demo scaffold on nothing, and it beats both alternatives on exactly one thing: it never lets you forget the model is fake. That single property is what makes the rest of the scaffold safe to ship to a frontend team before the weights exist.

The Next Commit

The sibling directory covid_detector_package already contains a full training pipeline: prepare_dataset.py, train.py, covid_model.py, and predict.py, with its own README and requirements. The backend loader never references it. ML_MODELS_DIR expects a single artifact that nothing currently parses.

So the project sits at a specific and familiar place: a trained-or-trainable model exists in one corner of the repository, a designed socket exists in another, and the two have not been joined. The next commit is the handoff between a data scientist and a backend engineer. Everything the backend needs is already in place. The only question is whether the model file that lands in /ml_models/ arrives before someone forgets why the stub was honest in the first place.