# Recipe: keep a result current

Catalogue data moves: GP sets are refreshed every two hours, launches and hazard areas daily. A project holds a snapshot: the release that was current when it was put. Results never change under the person's feet.

## See what is stale

`project_open {project}` lists each layer with `provenance` (`catalogue`, `dynamik`, `custom`) and `stale` (a computed layer whose inputs changed), each computation with `state` (`ready`, `computing`, `stale`, `error`), and each program with `state` and, when stale, `stale_reason`. It does not compare catalogue releases.

- For a program, `project_open {project, parts:["programs"]}` gives `newer_data` and, per input, `release`, `latest` and `newer`; the window shows "Newer data available".
- For a layer, read its release with `data_read {project, of:"layer:<id>", limit:0}` (`envelope.provenance.catalogue.retrieved_at`) and compare it with the hit's `refreshed` from `data_find`.

Tell the person what changed and how old their snapshot is before you refresh: an analysis on yesterday's set may be exactly what they want to keep.

## Refresh a program

```json
{"verb":"program_run","args":{"project":"P","program":"<program.id>","refresh":true}}
```
The program's id is in the answer of the run that made it (`program.id`) and in `project_open {project}` under `programs`. This re-holds, at its latest release, each input you declared as a catalogue ref (`inputs:{"fleet":{"ref":{"kind":"satellite-set","id":"<from data_find>"}}}`), writes the new holds, captures the project clock again, then runs the same source. An input declared as a layer id keeps that layer's data: refresh the layer as below, then run `program_run {project, program}`. Declare catalogue inputs as refs when the person will want them kept current. Do not resend the source; do not make a second program. The answer names the release each input was read at (`inputs.<name>.release`), so you can say "rerun on the GP set of 14:00 UTC" without opening the run record.

If every input is already current and the project clock has not moved since the last run, the answer carries `up_to_date: true` and nothing runs; a moved clock reruns the program over the new window.

## Refresh a computation

Put the same ref again under the same id; the write is an upsert, and the layer moves to the latest release:

```json
{"verb":"data_put","args":{"project":"P","items":[{"id":"starlink","ref":{"kind":"satellite-set","id":"<same ref>"}}]}}
```
Interactive computations that read it recompute on their own. Batch computations (coverage, revisit) are run again with `compute {project, id}`.

## Compare before and after

Read the `summary` (or `data_read {stats:true}`) before the refresh, keep the numbers, refresh, read again. Report the difference with both release times. Undo the refresh write to restore the previous snapshot. If you reran a batch computation afterward, undo that write first.

## What never happens

Saved programs never re-run on their own. Interactive computations recompute when an input changes. A refresh is a write by whoever asked for it, attributed to them, undoable like any other.
