Skip to content

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

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

Add captcha task-start and challenge-result events#332
archandatta wants to merge 7 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 task-level captcha_solve_started and challenge-level captcha_challenge_result telemetry
  • distinguish challenge outcomes as solved, failure, timeout, or abandoned
  • require data on both new events and duration_ms on challenge results
  • preserve the existing generated captcha type and solve-result status symbols for downstream Go consumers

Contract

captcha_solve_started records that a solver accepted one task. task_id pairs that start with its terminal captcha_solve_result, while challenge_id groups every task from one visible challenge. Delivery remains best-effort and unordered, so event arrival or absence does not indicate current solve state.

captcha_challenge_result is emitted once for the visible challenge. failure means the producer reached an explicit terminal solver failure or exhausted its attempts while the challenge remained. timeout is reserved for an actual challenge-level wait budget. abandoned covers observation ending without either a solved signal or an explicit terminal solver outcome.

The shared captcha taxonomy keeps the legacy generated BrowserCaptchaSolveResultEventDataCaptchaType name and constants through a schema alias. Existing relay code therefore compiles unchanged when it updates this module.

Rollout

Schema and generated image API types only; no producer behavior changes here. The public API schema and extension producer are updated in their corresponding PRs before consumers rely on the new challenge event.

Testing

  • go test ./lib/oapi ./lib/events/... — pass, including generated-symbol and required-field compatibility coverage
  • go build ./... — pass
  • go vet ./... — pass
  • OpenAPI generation run twice — byte-identical generated output
  • go test ./lib/capmonsterrelay on kernel/kernel#3432 with this module replacement — pass without relay changes
  • GitHub test-server-e2e — all cases except TestReplayRecordingIncludesAudioTrack; that unrelated test failed twice because the generated audio track ended 0.38s / 1.29s before its recording-duration threshold. The base branch has a green full e2e run on the same base commit.

@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.

@masnwilliams masnwilliams 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.

this now models the lifecycle correctly:

  • captcha_solve_result remains task-level and may occur once per image-grid round.
  • task_id correlates each task start/result pair.
  • challenge_id groups those task attempts.
  • captcha_challenge_result provides the once-per-visible-challenge terminal signal, with solved, failure, timeout, and abandoned.

the latest revision also preserves the existing generated Go API, requires data on the new events, requires challenge duration, and adds compatibility coverage. no remaining structural code-quality blockers from me.

this PR is schema-only, so the behavior is not complete until the producer and consumer changes land: kernel-images-private #339, kernel #3418, and managed-auth-cua-concept #55.

the remaining red e2e check is the unrelated recording-audio-duration assertion; the relevant unit, build, vet, generation, BugBot, and image-build checks pass.

@archandatta
archandatta requested a review from Sayan- August 19, 2026 18:58

@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.

Confirming all feedback addressed. Thanks for iterating!

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.

3 participants