Skip to content

Add captcha task-start and challenge-result events - #332

Open
archandatta wants to merge 6 commits into
mainfrom
archand/kernel-1772/captcha-solve-started-schema
Open

Add captcha task-start and challenge-result events#332
archandatta wants to merge 6 commits into
mainfrom
archand/kernel-1772/captcha-solve-started-schema

Conversation

@archandatta

@archandatta archandatta commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add captcha_solve_started for task acceptance and captcha_challenge_result for the overall visible-challenge outcome
  • share the normalized BrowserCaptchaType across captcha events, including the existing press_and_hold wire value
  • add optional task_id correlation and challenge_id grouping, with challenge_id required on challenge results
  • cover both new event-to-category mappings with regression tests

Contract

captcha_solve_started records that a solver accepted one task. It does not assert that the solve is still running when a consumer receives it: delivery is asynchronous, a start can arrive after its result, and either event can be missing.

When present, task_id correlates one start with its terminal captcha_solve_result. duration_ms on the task result remains the authoritative task timing.

challenge_id groups multiple tasks from one visible challenge, such as image-grid retries, without indicating task ordering or completion. captcha_challenge_result is emitted once for the overall challenge, requires that grouping key, and reports solved or abandoned. A solved challenge issued a response token; it does not prove that the surrounding site flow accepted the token or succeeded.

Existing captcha_solve_result behavior is unchanged apart from the optional grouping field and shared captcha-kind schema.

Rollout

This change defines the schema and generated image API types only. Mirror the two new event types and shared captcha taxonomy into the public API and SDKs before any producer begins publishing them; producer changes follow separately.

Testing

  • go test -race $(go list ./... | grep -v /e2e$) — pass
  • go build ./... — pass
  • go vet ./... — pass
  • OpenAPI down-conversion plus Go generation chain, followed by git diff --exit-code — clean
  • headful and headless Docker CI reruns — blocked in the unchanged FFmpeg download step because the upstream latest checksum manifest no longer contains the pinned ffmpeg-n7.1 archive

Note

Medium Risk
Contract and generated-type changes affect telemetry consumers and future producers; correlation semantics are easy to misuse if mirrored incorrectly in SDKs.

Overview
Extends browser captcha telemetry with captcha_solve_started (solver accepted a task) and captcha_challenge_result (one terminal outcome per visible challenge: solved or abandoned). The OpenAPI spec and generated oapi types wire both into the known telemetry union and map them to the captcha category.

Introduces shared BrowserCaptchaType (including press_and_hold) and BrowserCaptchaChallengeID for grouping retries. captcha_solve_result now uses that shared type, may carry optional challenge_id, and documents that duration_ms is authoritative and task_id pairs with the matching start event when present—not arrival order.

Adds TestCaptchaCategories so captcha_solve_started and captcha_challenge_result resolve to the captcha category. Schema-only in this PR; producers are expected to adopt publishing separately.

Reviewed by Cursor Bugbot for commit 978faed. Bugbot is set up for automated code reviews on this repo. Configure here.

@archandatta
archandatta force-pushed the archand/kernel-1772/captcha-solve-started-schema branch from d38c3e5 to e6ff096 Compare August 18, 2026 13:40
Introduce a captcha_solve_started event in the captcha category, emitted
when a solver accepts a task so consumers can react to a solve in flight
rather than only seeing the terminal captcha_solve_result.

Factor the captcha_type enum into a shared BrowserCaptchaType schema
referenced by both event payloads, and add press_and_hold to it to cover
the in-VM vision solver, which already emits that value.

Schema and regenerated code only; producers land separately.
The captcha events are per solver task, so an image-grid challenge that
retries emits one event per round with nothing tying the rounds together.
challenge_id groups them; task_id stays per task.
captcha_solve_started and captcha_solve_result describe one solver
attempt each, and a single visible challenge takes several: an image
grid retries with a fresh task per round. Nothing in either event says a
challenge is over, and challenge_id only makes the attempts groupable.

captcha_challenge_result is emitted once per challenge by a producer
watching the page, which is the only vantage point that can observe the
response token. status is what the page saw — solved or abandoned — and
solved describes the challenge, not the flow around it, since a site can
still reject a valid token.
@archandatta
archandatta force-pushed the archand/kernel-1772/captcha-solve-started-schema branch from b451071 to 381cc60 Compare August 18, 2026 18:50
@archandatta archandatta changed the title Add captcha_solve_started telemetry event Add captcha task-start and challenge-result events Aug 18, 2026
@Sayan-
Sayan- marked this pull request as ready for review August 18, 2026 19:44

@Sayan- Sayan- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wire format is additive and safe: the new types land in a taxonomy-only union and challenge_id is optional. Two things I'd still fix.

  1. Build break downstream. This deletes BrowserCaptchaSolveResultEventDataCaptchaType and its constants, and renames the status constants from Success/Failure/Timeout/Abandoned to prefixed forms. kernel/kernel uses both in packages/metro-api/lib/capmonsterrelay/relay.go, line 332 for status and line 363 for normalizeCaptchaType's signature and returns. metro-api resolves that import through a replace onto the internal mirror, so it breaks on the next sync plus module bump rather than at merge. Worth a companion PR landed first.

The status rename also looks unintentional. oapi-codegen only dropped the prefix because nothing collided; removing the captcha-type enum changed the collision set.

  1. captcha_challenge_result.status is solved/abandoned only, so a solver hard-failure and a dismissed widget are indistinguishable. Adding failure or timeout later means widening a shipped SDK enum, which is the thing the rest of this PR is careful to avoid.

Nits: data is optional on the event, so required challenge_id isn't enforced. duration_ms is optional here but required on the task result.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants