Skip to main content

Require Evidence Before Removing Items Missing From a 2scraper Snapshot

A catalog state machine distinguishes an unexplained omission from a confirmed removal.

Updated 9 min readMarkdown
Require Evidence Before Removing Items Missing From a 2scraper Snapshot

An item disappeared from this morning’s workbook, and the downstream feed disabled it. The source export covered a subset of the catalog after an optional scope filter changed. Starting with an authorized project from 2scraper, I would make a deliberate decision about removals instead of letting a missing join row decide on behalf of the operator.

A snapshot can be complete for the query it ran and still incomplete for the population that drives removals. The scope fingerprint describes what the query meant. A completed job proves execution of that scope. Require both pieces of evidence before treating the set difference as qualified omission evidence.

The example isolates a single decision about which missing items warrant a state change using a local input. Keep the snapshot ID, scope version and match count in sight while comparing results. A report can publish one computed field for consumers while the audit trail retains the individual source decisions. A small fixture lets you check both surfaces without credentials, production input or an external request.

Follow two records through the boundary

Observe product A in run one. In run two it is absent with a partial-coverage verdict. The currently confirmed catalog can still include it and attach a warning. Run three supplies complete data for the approved scope and A is missing. That starts a new sequence at one. Run four also qualifies and can produce a removal decision.

For the cases in the table, record the input version and expected decision next to each example. I would expect someone familiar with a versioned catalog to be able to make the same decision by hand. Ask them first about an omission from a partial run. If they cannot tell which evidence is missing, improve the case description before increasing the number of input rows. A larger dataset will multiply the ambiguity without settling the rule.

State the boundary in the contract

Keep present, pending review and confirmed removal separate. Require explicit item-level removal evidence or two consecutive complete observations for the same approved scope, under a documented local policy. Scope changes start a new sequence. Treat that policy as a decision made by your application, since export providers may give a different contract for deletions.

Carry a persisted run sequence for each scope. Retrying an import with the same run identifier must not increase the evidence count. A database implementation updates the snapshot record and the pending-absence state in one transaction, making replay safe after a failed downstream job.

Read the fixture as a decision table

Case Evidence Expected decision
Partial scope not complete keep
Scope changed outside approved population keep
First absence approved complete run pending
Second absence next qualifying run remove
Duplicate run same snapshot identifier no extra evidence

Partial. Reset the streak and record the failed condition.

Scope changed. The comparison lacks a common population.

First absence. The next eligible run can supply independent evidence.

Second absence. The fixture models the documented two-run local rule.

Duplicate run. Require an idempotent run record in a persistent implementation.

Run the example on a synthetic input

This example accepts only fields needed for the decision about which missing items warrant a state change. It prints a compact result and asserts each consequential branch before printing. The table explains any operational cases beyond that small code sample. Copy the code into its own Python file and run it without credentials.

def decide(approved, runs):
    seen, streak = set(), 0
    status = []
    for key, scope, complete, product_seen in runs:
        if key in seen:
            continue
        seen.add(key)
        if scope != approved or not complete or product_seen:
            streak = 0
        else:
            streak += 1
        status.append('remove' if streak >= 2 else 'pending' if streak else 'keep')
    return status

runs = [(1, 'full', True, True), (2, 'full', False, False),
        (3, 'full', True, False), (3, 'full', True, False),
        (4, 'full', True, False)]
assert decide('full', runs) == ['keep', 'keep', 'pending', 'remove']
assert decide('full', [(1, 'subset', True, False)]) == ['keep']
print(' -> '.join(decide('full', runs)))

The local execution printed this output.

keep -> keep -> pending -> remove

When you adapt the code, keep the snapshot ID, scope version and match count available to the test runner. Add a separate integration fixture at the input boundary, because a downstream assertion can pass while the input producer silently changes the meaning of a field. I would check the observed output and the persisted decision record independently.

Give an unexpected case one clear outcome

If an operational dashboard sees unusual removal volume, hold the outgoing change set while a reviewer compares active scope and recent absent identities. A hold concerns the derived feed. Keep the evidence from the underlying runs so the operator can decide whether the spike represents a change in catalog or a change in collection.

An alert should tell the report owner what happened to live catalog membership and which input was involved. I use stable reason values for metrics and a run or case reference for the review. Putting complete input records in alert text may expose information outside the normal access boundary. The destination for a repaired record should accept the same run reference as the original so corrections can be traced.

What I would retain for the next review

For the first deployment, I would keep a small directory of approved examples beside the code that reads a versioned catalog. Keep the unmodified source fixture and the derived record in separate files. If you only keep the winner or the visible dashboard row, you lose the inputs that made the decision about which missing items warrant a state change explainable. Include an example the program explicitly rejected and an example that legitimately passed. A reviewer should be able to identify which is which from the inputs before opening the expected result.

I would give the catalog owner a short checklist with one entry for the snapshot ID, scope version and match count. The first check is whether two readers can independently point to the same underlying record. The second is whether they agree about the decision under the documented rule. The third is whether a discrepancy about an omission from a partial run becomes visible to the person who can resolve it. Keep an expected output in the test directory and a human-readable account in the release notes. They serve different readers and should describe the same decision.

I would have the test report more than a pass count. Give the failing case a stable name and preserve the decision stage where it stopped. That makes it possible to compare results months later after a field has been renamed or a report has moved. Count missing evidence independently of invalid evidence. A problem with collection can look like a problem with the rule if both types land in the same generic error bucket. The difference is consequential for whoever will support a versioned catalog.

For rollout, run the new rule next to the existing report for one real reporting interval and compare individual cases, using only data already approved for that workflow. Keep the previous version available until you can explain every material difference in live catalog membership. Record a representative changed row with the source identifier and the rule version. Then look at a small sample of unchanged rows so the release review can also say what the change preserved. The useful output is a reproducible decision, plus a record of where the rule needs more evidence.

I would make the handoff include a deliberate bad run. Remove the evidence for an omission from a partial run from a copy of the fixture while leaving the rest of the records intact. Ask the operator to identify the first place where the uncertainty appears, then try the diagnosis using only the artifacts that someone on call can access. If the needed evidence can only be reached through an administrator’s personal workspace or an undocumented manual step, give the review a shared run reference before rollout. The exercise is complete when the operator can explain which conclusions about which missing items warrant a state change remain available and can reproduce them with a clean copy. Keep the failing input in the test suite as a fixture, with real records and any access tokens excluded.

Make the change reversible before the first report

Replay a sample including an intentionally reduced query, a duplicate completion and a valid two-run omission. Compare the old and new feeds before handing control to the removal rule. Keep the last active catalog version so reverting a derived decision can be done without reconstructing current state from partial files.

Choose a fixture that shows whether an omission from a partial run would become visible before the report is released. Compare exact decisions before comparing totals, because opposite errors can cancel out in an aggregate. Document which decisions still need human review and who owns them. After an input contract changes, replay the previous fixture with the old policy and the new fixture with the new policy before changing a published comparison.

Run one small trial first

Pick a narrow authorized catalog from 2scraper with a known membership list. Simulate one partial snapshot and two complete ones before attaching the export to a system that removes items.

Prepared with AI assistance. The code was run locally against a synthetic fixture. The fixture describes the downstream workflow illustrated here.

Further reading

Explain What Changed Between Two 2scraper Catalog Snapshots Compare the content of adjacent snapshots.

Keep Partial Product Updates From Erasing Good 2scraper Catalog Data Preserve the fields an update never claimed to cover.

No comments yet. Be the first to comment.