Heuristic:1broseidon Ketch JS Shell Detection
| Knowledge Sources | |
|---|---|
| Domains | Extraction, Heuristic_Detection, Optimization |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
A two-phase HTML classifier that labels a static fetch as static, likely_shell, or ambiguous, keeping browser renders bounded by requiring corroborating signals before escalating.
The Insight (Rule of Thumb)
- Action: Run a cheap single-pass text scan (Phase 1); escalate to a browser render only on explicit corroborators (Phase 2). Never escalate on a single signal.
- Value: Visible text ≥ 200 chars ⇒ static unless (a) the text says "loading" + requires JavaScript, or (b) a strong client-render marker AND script bytes > 8× visible text. Below 200 chars with > 2 meaningful blocks ⇒ ambiguous; below that, escalate only if a cheap DOM corroborator (noscript JS hint, body "enable javascript", framework shell marker) or script bytes > 3× visible text.
- Trade-off: Each escalation costs a full browser render (hundreds of ms + a Chromium process), so the gates are deliberately conservative: false negatives return shell garbage, false positives burn a render. The conjunction of two noisy signals (marker + payload ratio) keeps both bounded.
- Compatibility: Operator-configured `spa_markers` are folded in on top of the built-in framework list; a stray empty marker is dropped so it can never match every page.
Reasoning
The detector runs on the fast HTTP path of every fetch and every crawl page, so it must be O(page) cheap. Most pages short-circuit in Phase 1 without touching `<script>`/`<noscript>`. The expensive full-source lowercase match against framework markers is deferred to Phase 2 and only paid for on low-text pages.
The 8× threshold for the high-text override is deliberately stricter than the 3× low-text corroborator: most pages with > 200 chars of visible text are genuinely static, so a higher bar is needed before trusting a hydration marker enough to pay for a render. Legacy roots like `id="__next"` are excluded from the "content is client-rendered" marker set because they also appear on fully server-rendered pages and would over-trigger.
Per the comment on `clientRenderedPayload` (`extract/detect.go:186-192`): the script/JSON payload must dwarf the visible text by a wide margin, and each gate alone is too noisy, and every escalation costs a browser render, so the conjunction keeps false positives (and Chrome renders) bounded.