Skip to content
quarry View Ticket
Login

View Ticket

tk: artifacts the store holds are missing from the index and a rebuild does not restore them

Fixedd725bd29c55ed2320a02ae0142222abca12ecefaCreated 104.0 days agoUpdated 67.9 days ago
Description2026-08-19 00:10:04
`tk` is the one store whose index cannot be repaired by a full rebuild. Detection and one-shot repair landed in bd55e3a4; this is the residue that repair does not close.

## What is observed

After `quarry reindex` replays all 69,182 artifacts, the index still holds check-in edges whose parent it does not have — and unlike fossil, tcl, sqlite and libfossil, whose dangling ancestors are genuinely absent from the store (shunned, or an import that began partway down the DAG), **the tk store still holds these artifacts**. Verified per hash with `zit artifact <hash> -R`, which succeeds.

So this is real loss, reproducible across rebuilds:

ingest: tk: 1 artifacts the store holds are missing from the index; rebuilding ingest: tk: STILL 1 artifacts missing after a full rebuild — NOT retrying

The pipeline now stops after one attempt rather than replaying the store every two minutes forever, and reports the count in fleet health.

## Why a rebuild does not fix it

Unknown, and that is the work. Leads, in the order worth trying:

1. **The census outruns the window during the rebuild itself.** ZITEVT is capped (1 GiB, one hour, discard-old) and `flushBytes` bounds one burst at 64 MB, but tk is the largest ticket corpus in the fleet — 12,028 tickets, 69,182 artifacts. If a fold is slow enough that a burst's head ages past MaxAge while its tail is still being written, the head is dropped unacked and never republished. That is the same mechanism that caused the original damage, just reached by time rather than size, and `flushBytes` does not defend against it. 2. **An artifact that fails to parse is skipped silently.** `each` logs "treating as content" and returns nil for a nil parse. If tk holds an artifact shape the parser drops entirely, its edges would dangle forever and no rebuild would help. Check whether the missing hashes parse at all. 3. **A fold error mid-batch.** Fold is one transaction per fetched batch and only acks on success, so this should be safe — but it is worth confirming the specific hashes are not in a batch that consistently errors.

## Where to start

Get the hashes, then ask what they are:

SELECT DISTINCT p.parent FROM checkin_parent p WHERE NOT EXISTS (SELECT 1 FROM checkin WHERE hash = p.parent)

and for each, `zit artifact <hash> -R <store>` to see its type and cards. If they are all one artifact type, lead 2 is the answer.

## Why it matters

A missing check-in is not a cosmetic gap. It orphans the DAG: the timeline draws a second branch rail where there is one branch, and marks a mid-history commit as a leaf. That is how this whole class of bug was found — the fleet page said `ok` while the index was quietly serving an incomplete history as though it were whole.

2026-08-19 15:42:31

Root-caused, and lead 2 was right in an unexpected way: the "missing check-in" is not missing and is not a check-in.

cd4f6a34… is tkMacOSXEvent.c — a plain C source blob. Check-in 2b9302ce… (2011-07-18, CVS-conversion era) carries a P card naming that blob as its parent. This is tk's history as written: fossil's own database records the same plink edge at face value and creates no timeline event for the blob, so fossil's timeline draws the same disconnected segment quarry's does. The index was never wrong; the probe's definition of "repairable" was.

Fix (8a96f742): lostArtifacts now parses each probed artifact and counts only those the store holds AS MANIFESTS. Holding the hash is not holding a check-in — a blob parent is the same category as a shunned ancestor: inherent history, not loss. The regression test folds tk's exact shape (a check-in whose parent is a file blob in a real store) and pins lost == 0.

Effects: tk no longer rebuilds 69,182 artifacts chasing a gap no rebuild can close, no longer reports itself permanently broken on /fleet, and the gap signal is quiet on a healthy boot — so when Gaps is non-zero again it will MEAN loss, which is the whole value of the signal. The timeline's rendering of the 2011 orphan stands, in exact agreement with fossil's.