# `GeoGenius.Pipeline.Artifacts`
[🔗](https://github.com/agoodway/geo_genius/blob/main/lib/geo_genius/pipeline/artifacts.ex#L1)

The import phases that obtain a release's files: `download/1` and
`validate/1`.

This is the only part of the pipeline that touches the cache, the
downloader, or a checksum. Every artifact is resolved the same way -- look
in the cache first, download a miss, hash whatever came back, and record
that observation -- so a cached copy and a fresh download reach
`record_artifact_observation/5` through the same check.

**A cache hit is hashed on every run**, including one whose artifact row
already carries a `validated_at`. Trusting that column would mean a
corrupted or swapped cache entry is never noticed again: every later run
would import it, and the release it produced would pass verification on
bytes nobody reviewed.

# `download`

```elixir
@spec download(GeoGenius.Pipeline.State.t()) :: GeoGenius.Pipeline.State.result()
```

Resolves every artifact the release composes to a local file, recording what
each one hashed to.

Measures `"artifacts"`, `"downloaded"`, `"cached"`, and `"bytes"`, and
carries each artifact's local path and attributed source release forward on
the state.

# `validate`

```elixir
@spec validate(GeoGenius.Pipeline.State.t()) :: GeoGenius.Pipeline.State.result()
```

Checks that every required artifact carries a `validated_at`, and counts the
optional ones nothing could obtain.

Re-reads the artifacts rather than trusting what `download/1` collected:
`validated_at` is set by PostgreSQL, and reading it back is what makes this
a check rather than a restatement of what the previous phase believed.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
