Skip to content

Add a generator evaluator for web detection runs that suspend - #3236

Draft
GuiltyDolphin wants to merge 4 commits into
gd-c-web-detection-observefrom
gd-c-web-detection-generator-evaluator
Draft

GuiltyDolphin wants to merge 4 commits into
gd-c-web-detection-observefrom
gd-c-web-detection-generator-evaluator

Conversation

@GuiltyDolphin

@GuiltyDolphin GuiltyDolphin commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Asana Task/Github Issue: https://app.asana.com/1/137249556945/task/1220838326064413

Description

Builds on #3235.

wait (next PR) pauses a run partway through an expression and resumes it in a later task. This adds the evaluator that can do that, without changing how runs that never pause evaluate:

  • a source can be marked suspends. Its read gives what the run waits on, and the run resumes with the value passed to next
  • at compile, markSuspensions marks the expressions from actions down to each source that suspends, through the elements of a sequence, an if's condition and branches, expr, the value beside using, and the values of define, done, fireEvent and breakageReportData. A source that suspends anywhere else (under any or sum, in a list, a using operand, a source body, a predicate, or match) is a parse error, so predicates and sources stay synchronous
  • evaluateSteps and occurrenceSteps evaluate marked expressions as generators, and hand unmarked ones to the synchronous evaluate. The logic after each value (is, define, done, sending a payload) is shared between the two
  • runDetectorSteps runs a detector that can suspend as a generator. runDetector keeps the synchronous path for every other detector, and throws for one that can suspend, as it has no scheduler

No source suspends yet, so nothing in config reaches the generator path.

The design has wait anywhere an expression goes in actions. This limits it to the positions above, which cover each example in the design (an if condition, a define value, a payload, an action of its own). The privacy-configuration validator for wait will need the same rule.

On a small detector with no page reads, runDetector takes the same time as on #3235 (about 1.6 µs a run in Node), and the Apple isolated bundle (unminified) grows by about 6 KB.

Testing Steps

  • unit tests use an api source marked suspends to cover suspending and resuming in a define, in sources reached in order, in an if condition and only in the branch taken, in a payload value, beside using and in done, a failure and an error after resuming, a resumed value of the wrong type for its position (an object or undefined in an if condition) failing, as it would when read synchronously, run names bound before suspending, which expressions are marked, runDetector for detectors that can and can't suspend, and the parse error in each rejected position

Checklist

Please tick all that apply:

  • I have tested this change locally
  • I have tested this change locally in all supported browsers
  • This change will be visible to users
  • I have added automated tests that cover this change
  • I have ensured the change is gated by config
  • This change was covered by a ship review
  • This change was covered by a tech design
  • Any dependent config has been merged

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Build Branch

Branch pr-releases/gd-c-web-detection-generator-evaluator
Commit dfa8de8fe1
Updated November 30, 2026 at 12:58:10 PM UTC

Static preview entry points

QR codes (mobile preview)
Entry point QR code
Docs QR for docs preview
Static pages QR for static pages preview
Integration pages QR for integration pages preview

Integration commands

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#pr-releases/gd-c-web-detection-generator-evaluator

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", branch: "pr-releases/gd-c-web-detection-generator-evaluator")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/gd-c-web-detection-generator-evaluator
git -C submodules/content-scope-scripts checkout origin/pr-releases/gd-c-web-detection-generator-evaluator
Pin to exact commit

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#dfa8de8fe129ce2d856830f411eb602a3479d98e

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", revision: "dfa8de8fe129ce2d856830f411eb602a3479d98e")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/gd-c-web-detection-generator-evaluator
git -C submodules/content-scope-scripts checkout dfa8de8fe129ce2d856830f411eb602a3479d98e

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

[Beta] Generated file diff

Time updated: Mon, 30 Nov 2026 12:59:31 GMT

Android
    - android/adsjsContentScope.js
  • android/contentScope.js

File has changed

Apple
    - apple/contentScopeIsolated.js

File has changed

Chrome-mv3
    - chrome-mv3/inject.js

File has changed

Firefox
    - firefox/inject.js

File has changed

Integration
    - integration/contentScope.js

File has changed

Windows
    - windows/contentScope.js

File has changed

@github-actions github-actions Bot added the semver-patch Bug fix / internal — no release needed label Nov 23, 2026
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-generator-evaluator branch 3 times, most recently from 7bd0558 to ede1c66 Compare November 25, 2026 13:28
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-generator-evaluator branch from ede1c66 to 1c41f0c Compare November 25, 2026 17:46
@github-actions github-actions Bot added semver-minor New feature — triggers minor version bump semver-patch Bug fix / internal — no release needed and removed semver-patch Bug fix / internal — no release needed semver-minor New feature — triggers minor version bump labels Nov 25, 2026
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-generator-evaluator branch from 1c41f0c to e70df8d Compare November 25, 2026 19:18
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-generator-evaluator branch from e70df8d to 2377061 Compare November 25, 2026 20:50
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-generator-evaluator branch from 2377061 to 389587c Compare November 25, 2026 21:54
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-generator-evaluator branch from 389587c to aa2b74d Compare November 25, 2026 22:29
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-generator-evaluator branch from aa2b74d to 851a32c Compare November 30, 2026 10:47
@github-actions github-actions Bot added semver-minor New feature — triggers minor version bump and removed semver-patch Bug fix / internal — no release needed labels Nov 30, 2026
This marks the expressions a run can suspend in at compile time, from actions down to each source that suspends, and evaluates only those as generators. Runs with no source that suspends evaluate synchronously as before, ending in the first step of runDetectorSteps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GuiltyDolphin and others added 3 commits November 30, 2026 12:28
A value of the wrong type now fails rather than errors, so the spec for an error after a run resumes uses an invalid selector instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generator evaluator dropped the failure checkType returns, so a suspended value of the wrong type was used as it was. A run now fails there, as it does for the same value read synchronously.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An invalid selector now fails as aborted, so this test made the run's reads throw after resuming instead, which is how an error from this code arises.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-generator-evaluator branch from 851a32c to 4064635 Compare November 30, 2026 12:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-minor New feature — triggers minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant