Import Once, Rebuild Everything: Why a Nightly Apple Health Rebuild Loses Your Deltas

The nightly rebuild is the pipeline everyone writes first. Drop the export, recompute every day, write it out. It is idempotent, it is easy to reason about, and it quietly throws away the one thing a health feed needs: which day changed, and why.

By MetricBridge · Published 26 November 2026 · ~6 min read

AI-assisted, human reviewed. How we use AI

Quick answer

An Apple Health export is not a fixed record, it is a growing one: a watch uploads a workout hours late, a ring syncs overnight, a manual entry lands after the fact. A full rebuild re-reads everything and recomputes every day, so it is correct but blind. An incremental pipeline keeps each day's record and recomputes only the days a late-arriving sample touched, then reports which days changed and which were too old to rebuild. Same numbers, but you can now tell a changed day from a changed pipeline.

Why the full rebuild is the default

It earns its place. A full rebuild is stateless: delete the output, re-derive it, and you get the same answer every time. There is no cache to invalidate, no partial state to repair, and no ordering to get wrong. If your export were immutable, it would be the right answer forever.

The export is not immutable. Late-arriving samples are normal, not an edge case, and that is where the model stops paying for itself.

Where the full rebuild breaks

1. Yesterday's number changes with no record of the change

You read a day's resting heart rate, an agent caches it, and the next rebuild the value is different because a sample landed late. Nothing in a full rebuild says the day was rebuilt, so a corrected day and a broken query look identical. You cannot tell the user "this day was updated," because you never kept that fact.

2. You cannot distinguish data from code

If you also change the aggregation, a full rebuild rewrites every day at once. Now a day that moved because a sample arrived and a day that moved because you changed a formula are the same event. Debugging that is guesswork.

3. The cost scales with the file, not the change

A real export runs to gigabytes. Re-parsing all of it nightly, to recompute days that did not change, is why streaming parsers and columnar stores became an arms race in this space. Most of that work exists to make a full rebuild affordable, which is a lot of machinery for a problem you can avoid.

4. A failed rebuild leaves a silent hole

If the job dies halfway, you either publish a partial day or publish nothing and keep serving the old copy. Both are invisible unless something checks the freshness of each day, not just the file.

What the delta model keeps

The alternative is small. Write a per-day rebuild stamp when a day is recomputed, and only recompute the days a new sample touches. Three things fall out of that one change:

  • A change is a fact, not an inference. "This day was rebuilt at 07:12 because a sample arrived" is queryable.
  • The work scales with the change. A late workout recomputes one day, not the file.
  • Age becomes visible. A day that is too old to rebuild can say so, instead of silently keeping a stale value.

Real output: the recompute block

This is the part worth copying. The health-export-mcp server exposes the delta model through one field on get_mcp_status. Here is the verbatim result from the published server running with --demo (no iPhone needed), which is what a cache with no rebuild stamps reports:

npx -y health-export-mcp --demo   # then call get_mcp_status

"recompute": {
  "supported": null,
  "reason": "This cache has no _meta block (written by an app older
             than 1.2, a LAN receiver, or edited by hand), so whether
             the app rebuilds days after late-arriving samples cannot
             be told from the file. No day in it carries a rebuild stamp.",
  "backfilled_days": 0
}

Read that carefully, because the honest failure is the point. On a cache written by the app, supported is true and the block names the days rebuilt after late-arriving samples, with any day too old to rebuild called out separately. When the file cannot answer the question, the server says supported: null and tells you why, instead of returning backfilled_days: 0 as if nothing had ever changed. A count of zero and an unknown are different answers, and a health feed should never confuse them.

That is the whole test for any pipeline: can it distinguish "no days changed" from "I cannot tell whether days changed"?

Four checks for your own pipeline

  1. Does each day carry a rebuild stamp, or only the file carry a timestamp?
  2. If a sample lands late, does one day recompute, or does the whole file?
  3. Can the tool name the days that changed, and the days too old to rebuild?
  4. When it cannot tell, does it say so, or does it return a confident zero?

If the answer to 3 or 4 is no, you are running a full rebuild and calling it a cache. Related reading on the read side: the silent gaps in an Apple Health export covers the same theme from the data's point of view.

FAQ

Why do Apple Health exports have late-arriving samples?

A device does not always sync when it records. A watch uploads a workout hours later, a ring or scale syncs overnight, and a manual entry lands after the fact. So a day you already read can change, which means the export is not a fixed record but a growing one.

What is the difference between a full rebuild and an incremental rebuild?

A full rebuild throws away the previous result and recomputes every day from the whole export. An incremental rebuild keeps each day's record and recomputes only the days a late-arriving sample touched. The incremental result is the same, but it can also tell you which days changed and which were too old to rebuild.

How can I tell whether my health pipeline rebuilds days?

Ask the tool. MetricBridge's get_mcp_status returns a recompute block that names the days rebuilt after late-arriving samples, and reports supported: null with a reason when the cache carries no rebuild stamps. A pipeline that cannot answer the question at all is a pipeline that silently changes yesterday's number.

Does an incremental rebuild use less memory on a large export?

It can, but that is a side effect, not the point. The reason to go incremental is correctness: knowing which day changed. If you only need to read a slice, a streaming parser that never loads the whole file is the separate fix for memory.

What is a rebuild stamp?

A per-day marker written when a day is recomputed after new samples arrive. It turns a silent number change into a record you can query: this day was rebuilt at this time, for this reason. Without it, a changed day and a changed pipeline look identical.

Read your own export, deltas included

The app writes clean JSON to a folder you pick; the open-source server reads it over stdio and reports freshness and rebuilds per day. No account, no token, no server of ours in the path. Your health data never reaches us or a cloud AI.

Where it goes: the app reads Apple Health read-only and writes JSON to a folder you pick. Nothing reaches us or a cloud AI. What you get: all 194 metrics, 21 tools (19 read-only) and 23 prompts. Setup: about two minutes. Price: $24.99 one time after a 7-day free trial, not a subscription. Your phone: works on any iPhone the app runs on; Apple Intelligence is not needed for the export or MCP.

MetricBridge is a general-wellness app, not a regulated medical device. Nothing here is medical advice. The recompute block above was read live from the published server in demo mode.