Repository navigation
fix: absence has to be evidenced, not assumed - #8
Merged
Merged
Conversation
`normalizeByKind` returning null became a NotFoundError -- 404, and
negative-cached for TTL_NEGATIVE. But null covers two unrelated
situations: Spotify says the entity is gone, and we recognised nothing on
a page that loaded fine. A live playlist was served as "not found"
because the second was reported as the first, and the negative cache then
kept serving it that way after extraction had recovered.
The obvious discriminator does not work. Measured against the real site,
a dead entity records NO JSON responses at all -- byte-for-byte the
evidence a silent capture leaves:
playlist/zzzzzzzzzzzzzzzzzzzzzz -> {"recorded":0,"statuses":[],"paths":[]}
The navigation status does work, because it is positive evidence rather
than the absence of it. Spotify answers the document itself:
dead track 404 "Page not found"
dead album 404 "Page not found"
dead playlist 400 "Page not available"
live entity 200 the real title
Hence `navStatus >= 400` and never `=== 404`: a dead playlist answers
400, and a rule written against 404 alone would call every dead playlist
a scraper failure.
`recordResponses` now returns a Capture -- the navigation status
alongside the responses -- and stops immediately when the navigation was
not ok, since there is no virtualized list to page through on a "Page not
found" shell. A dead id costs 1040ms instead of 4146ms.
The new ExtractionSilentError covers "loaded fine, matched nothing":
502, never cached, wire code `extraction_silent`, relayed through the
failure codec with its identity intact. It is distinct from
ExtractionEmptyError, which found the entity and saw zero items in it --
a wholesale shape change versus one broken list -- and it is the only
class that fits a track, which has no track list to be empty.
This also closes a monitoring blind spot. `recordFailureMetrics` returns
early for NotFoundError, so while a silent extraction was reported as
absence, TOTAL extraction failure recorded ZERO failures while answering
404 to everything.
crack-sleevenote already models unknown wire codes as
ErrorCode::Unrecognized, so an unupgraded client preserves
`extraction_silent` verbatim rather than breaking; adding the variant
there is a follow-up.
Co-Authored-By: Claude & Lothrop (cycle.five@proton.me)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 2. The rule is not the one we sketched — the probe #7 enabled disproved it, which is exactly why that PR shipped first.
The bug
normalizeByKindreturningnullbecame aNotFoundError→ 404, negative-cached forTTL_NEGATIVE. Butnullcovers two unrelated situations:A live playlist was served as "not found" this morning because (2) was reported as (1) — and the negative cache then kept serving it that way after extraction had recovered.
The discriminator we planned does not work
We agreed on
recorded === 0→ 502. Measured against the real site, a genuinely dead entity records no JSON responses at all — byte-for-byte the evidence a silent capture leaves:Identical. That rule would have classified every dead entity as a scraper failure and stopped negative-caching entirely.
What does work: the navigation status
Positive evidence rather than the absence of it. Spotify answers the document itself:
Hence
navStatus >= 400, never=== 404— a dead playlist answers 400, and a rule written against 404 alone would call every dead playlist a scraper failure.recordResponseswas already discarding this: it filters tocontent-type: json, so the navigation response never survived.Validated end-to-end against the live site with the rule in place:
Three things fall out
Correctness.
ExtractionSilentErrorcovers "loaded fine, matched nothing": 502, never cached, wire codeextraction_silent, relayed through the failure codec with its identity intact. Distinct fromExtractionEmptyError, which found the entity and saw zero items in it — a wholesale shape change versus one broken list. It is also the only class that fits a track, which has no track list to be empty.Speed. A dead entity is rejected straight after navigation, skipping the scroll loop and its 3s settle on a page with no list to page through. 1040ms against 4146ms.
A monitoring blind spot closes.
recordFailureMetricsreturns early forNotFoundError— so while a silent extraction was reported as absence, total extraction failure recorded zero failures while answering 404 to everything. It now incrementsscrape_failures_total{reason="extraction_silent"}.Compatibility
crack-sleevenotealready models unknown wire codes asErrorCode::Unrecognized(String)with#[serde(untagged)], so an unupgraded client preservesextraction_silentverbatim rather than breaking, and cracktunes'error_embedcatch-all handles it. Adding the variant properly is a follow-up in that repo, after #421.Verification
npm test— 109 passed, 9 skipped (was 100). 9 new tests.>= 500fails 4 tests; removing the early bail fails the timing test.npx tsc --noEmitclean. Comment density 446/1297 = 0.34, in band.docs/design-notes.md: "The four extraction failures" → five, plus an "Absence has to be evidenced" section carrying the measurements. Thesrc/extract.tscross-reference to the old heading is updated — no dangling pointer.Version 0.3.0 — a status code changes for a case callers can observe.
🤖 Generated with Claude Code