<think>
Okay, I need to implement the shelf_fit function. Let's see the requirements. The function takes a list of widths and a shelf width, and returns the number of books that fit on the shelf in order. The key points are that books are added in arrival order, and once a book doesn't fit, even if a later one could, the process stops. Also, need to validate the inputs.

First, input validation. The widths must be a list. If it's not, raise ValueError. Each width in the list must be a positive integer. If any is not, error. Shelf must be a non-negative integer. If not, error. So, in the function, I need to check these first.

Then, the logic. We need to iterate through each book in order. For each book, check if adding it to the current total width exceeds the shelf. If adding it doesn't exceed, add it. If it does, break. The count is the number of books added before the break.

Wait, but the first book is checked. If the first book is wider than the shelf, then zero. So, the initial total is zero. For each book in widths:

Initialize total_width to 0. Count starts at 0.

For each width in widths:

Check if total_width + current width is <= shelf. If yes, add to total, increment count. Else, break.

So, the steps are:

Check if widths is a list. If not, error.

Check each width in widths is a positive integer. If any is not, error.

Check shelf is a non-negative integer. If not, error.

Then, iterate through each width in order, accumulating the total. If at any point adding the next book would exceed shelf, break. The count is the number of books added.

So, code steps:

def shelf_fit(widths: list, shelf: int) -> int:

First, check if widths is a list. If not, raise ValueError.

Then, check each element in widths is a positive integer. For example, for each w in widths, if not isinstance(w, int) or w <=0, raise ValueError.

Then check if shelf is a non-negative integer. If not, raise ValueError.

Then, initialize total = 0, count = 0.

Loop through each w in widths:

if total + w > shelf: break

else: total +=w, count +=1

return count.

Wait, but what if the shelf is zero? Well, the problem says shelf is a non-negative integer. So if shelf is zero, then any book with width >=1 would make total +w >0. So the count would be zero.

But the problem says that the shelf is strictly in arrival order. So even if a later book is thinner, once a book doesn't fit, the process stops.

So the code seems correct.

Now, let's think about edge cases.

Test case 1: empty widths. Then return 0. Correct.

Test case 2: widths is [5, 5], shelf is 10. Total is 5+5=10, so count is 2.

Test case 3: widths [5, 6], shelf 10. First book 5 fits. Total 5. Next 6: 5+6=11>10. So count is 1.

Test case 4: first book is 11, shelf 10. Then count is 0.

Test case 5: shelf is 0. All books are 1, so total +1 would be 1>0. So count is 0.

Another case: shelf is 5, widths [3, 2].