An image viewer sits in front of a vault service and builds its default screen by listing every asset ID, excluding screenshots, then paging through what remains. The listing was capped: sixty pages of five hundred, so 30,000 IDs at most. The vault had 33,904.

Ascending order plus a ceiling

IDs are assigned in increasing order and never reused. The scan went from the lowest up. So when the cap cut the list, what it cut was always the top end, which is always the newest material. The default screen showed 26,695 items and its first entry was an ID in the thirty-thousands, with the 3,904 most recent assets simply absent. The listing API did return a truncated flag. The screen received it and displayed nothing.

The fix removed the page cap as a limit and kept it only as a runaway guard, raised to a level the real vault could not hit. The end of the scan is now decided by the vault returning a short page, and a cursor that does not advance stops the loop. The screen says so when a list is partial. After the change the default query returned 30,599 items, which matched the expected figure of 33,904 total minus 3,305 screenshots, and its first entry was the actual newest ID.

Making the rescan cheap

Previously any change in the vault's count triggered a full rescan from zero. Because IDs only grow, the viewer now fetches from the last known ID forward and appends, but only trusts that if the appended count equals the vault's total; otherwise it falls back to a full scan. A tail catch-up measured at three vault calls and 0.17 seconds against a full scan of 71 calls and 3.0 seconds.

The two refresh paths, a command-line sync and an HTTP endpoint, had done different things. They were merged into one routine with a file lock, since the service and the nightly job are separate processes. Two simultaneous requests returned one 200 and one 409. The old index is no longer dropped before the new one is built, so a vault outage mid-scan leaves the last good answer in place. A second reviewer confirmed the 30,599 figure and the cleared truncated flag in a browser. What had not been seen was the refresh button with a real gap behind it, because the gap had been closed during testing before anyone looked.