Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(replay-vision): remove the unused verify-positives draw (#111432)

Tue Haulundc3627042db2a
diff --git a/products/replay_vision/README.md b/products/replay_vision/README.md
index 4648b30f2b63..71a962a69d79 100644
--- a/products/replay_vision/README.md
+++ b/products/replay_vision/README.md
@@ -16,7 +16,6 @@ A scanner with `emits_signals` also pushes one signal per finding into the Signa
**Observation** — one application of a scanner to a session, unique per (scanner, session).
Created in `pending` when triggered (by the scanner's schedule, the `/observe/` and `/bulk_observe/` actions, or a retry of a failed observation), transitions to `running` while `ApplyScannerWorkflow` executes (rasterize the recording to video → upload to Gemini → multi-turn scan), and lands in `succeeded` (result persisted under `scanner_result.model_output`, then a `$recording_observed` event plus embeddings/tags emitted fail-soft), `failed` (with a `kind:message` `error_reason`), or `ineligible` (the session doesn't qualify — too short, too idle, no recording).
Each observation snapshots the full scanner state (`scanner_snapshot`) that produced it, so subsequent edits to the scanner don't retro-mutate history.
-The snapshot's `verify_positives` mode (default `off`) makes a monitor re-draw its core step over the cached video when the first pass says `yes`. Replay Vision optimizes for precision over recall, so a `yes` stands only when the second draw agrees; a dissent replaces it with the dissenting verdict and reasoning, and no third draw breaks the tie. `shadow` records the draws under `scanner_result.verification` but serves the first pass; `enforce` serves the settled verdict. A draw that fails, or that would run past the activity's timeout, leaves the first pass in place, so verification only ever tightens a scan.
Rows stranded in `pending`/`running` by a dead workflow are failed as `orphaned` by a reaper on the reconciler tick.
Teams rate observations thumbs up/down, with optional written feedback. A scheduled job (`backend/learned_rules.py`) distills new ratings into hidden learned rules, one set for the project and one per scanner, and later scans include them in their prompt. Users never see or approve the rules.
A finding can also be turned into a PostHog Task once (the observation remembers the task it minted).
diff --git a/products/replay_vision/backend/api/observations.py b/products/replay_vision/backend/api/observations.py
index 5bd3b1262cc4..2888e80d2f31 100644
--- a/products/replay_vision/backend/api/observations.py
+++ b/products/replay_vision/backend/api/observations.py
@@ -136,9 +136,6 @@ class ScannerSnapshotSerializer(serializers.Serializer):
scanner_config = serializers.JSONField(
help_text="Scanner-type-specific configuration at run time (prompt, tags, scale, etc.).",
)
- verify_positives = serializers.CharField(
- help_text="How a monitor `yes` was re-checked at run time: `off` (one pass, the default), `shadow` (second draw recorded only), or `enforce` (the `yes` stands only when the second draw agrees).",
- )
variant_sampling_rates = serializers.DictField(
child=serializers.FloatField(),
required=False,
@@ -151,28 +148,6 @@ class ScannerSnapshotSerializer(serializers.Serializer):
)
-class VerificationRecordSerializer(serializers.Serializer):
- """Mirrors `temporal.types.VerificationRecord` for OpenAPI generation."""
-
- mode = serializers.CharField(
- help_text="Verify-positives mode the scan ran with: `shadow` records the second draw only, `enforce` serves the settled verdict.",
- )
- draws = serializers.ListField(
- child=serializers.CharField(),
- help_text="Monitor verdicts in draw order: the pass that triggered verification, then the second draw when it ran.",
- )
- resolved_verdict = serializers.CharField(
- help_text="The verdict verification settled on: the first pass when the second draw agrees, else the dissent.",
- )
- served_verdict = serializers.CharField(
- help_text="The verdict `model_output` carries: the resolved one under `enforce`, the first draw under `shadow`.",
- )
- skipped_reason = serializers.CharField(
- allow_null=True,
- help_text="Why verification stopped early (`no_cache`, `no_budget`, `draw_failed`), leaving the first pass in place. Null when every draw ran.",
- )
-
-
class ScannerResultSerializer(serializers.Serializer):
"""Mirrors `temporal.types.ScannerResult` for OpenAPI generation."""
@@ -183,10 +158,6 @@ class ScannerResultSerializer(serializers.Serializer):
min_value=0,
help_text="Number of PostHog Signals emitted from this observation.",
)
- verification = VerificationRecordSerializer(
- allow_null=True,
- help_text="Extra draws taken to verify a monitor `yes` verdict. Null when the scan did not verify one.",
- )
experiment_variant = serializers.CharField(
required=False,
allow_null=True,
diff --git a/products/replay_vision/backend/temporal/activities/call_scanner_provider.py b/products/replay_vision/backend/temporal/activities/call_scanner_provider.py
index 3364cbca8a47..35c1c6d879d9 100644
--- a/products/replay_vision/backend/temporal/activities/call_scanner_provider.py
+++ b/products/replay_vision/backend/temporal/activities/call_scanner_provider.py
@@ -64,7 +64,6 @@ from products.replay_vision.backend.temporal.metrics import (
record_provider_call,
record_tool_round,
record_unknown_tool_call,
- record_verification_outcome,
)
from products.replay_vision.backend.temporal.network_capture import SessionNetworkPayload
from products.replay_vision.backend.temporal.network_tool import (
@@ -91,7 +90,6 @@ from products.replay_vision.backend.temporal.scanners.base import (
)
from products.replay_vision.backend.temporal.scanners.classifier import ClassifierScanner
from products.replay_vision.backend.temporal.scanners.experiment import ExperimentScanner
-from products.replay_vision.backend.temporal.scanners.monitor import MonitorLlmResponse, MonitorScanner
from products.replay_vision.backend.temporal.state import load_scanner_llm_inputs, load_session_network
from products.replay_vision.backend.temporal.types import (
CallScannerProviderInputs,
@@ -99,7 +97,6 @@ from products.replay_vision.backend.temporal.types import (
ScannerCallOutput,
ScannerLlmInputs,
ScannerSnapshot,
- VerificationRecord,
)
from products.replay_vision.backend.temporal.video_clock import VideoClock, video_clock_from_export_context
@@ -121,10 +118,6 @@ def _tool_budget(model: str) -> int:
return _MAX_TOOL_ITERATIONS_BY_MODEL.get(model.removeprefix("models/"), DEFAULT_MAX_TOOL_ITERATIONS)
-# Snapshot `verify_positives` values that draw; anything else (including a typo) behaves as `off`.
-_VERIFY_MODES = ("shadow", "enforce")
-# Activity time kept free of verify draws, so assembling and returning the result never races the timeout.
-_VERIFY_BUDGET_RESERVE_SECONDS = 60.0
# Cache TTL: a scan is a handful of turns and finishes in minutes; well under this.
_VIDEO_CACHE_TTL = "900s"
@@ -141,11 +134,10 @@ class _StepResult:
@frozen
class _MissionOutcome:
- """What one scan produced: the finalized output, the side-mission findings, and the verify-positives audit."""
+ """What one scan produced: the finalized output and the side-mission findings."""
finalized: BaseScannerOutput
signals: list[SignalFinding]
- verification: VerificationRecord | None = None
thumbnail_video_s: int | None = None
key_moment_video_s: int | None = None
# The core turn's raw answer, for fields the scanner still has to move onto the session clock.
@@ -339,7 +331,6 @@ async def run_scan(
return ScannerCallOutput(
model_output=finalized,
signals=signals,
- verification=outcome.verification,
thumbnail_video_s=outcome.thumbnail_video_s,
# Read off `outcome.signals`, which is still on the video clock; `signals` above is not.
signal_video_spans=[(s.start_time, s.end_time) for s in outcome.signals],
@@ -696,27 +687,8 @@ async def _run_mission(
tools=tools,
on_round=on_round,
)
- verification: VerificationRecord | None = None
try:
step_outputs = await _run_mission_attempts(run=run, cache=cache, model=snapshot.model)
- core = step_outputs.get(STEP_CORE)
- if (
- isinstance(scanner, MonitorScanner)
- and isinstance(core, MonitorLlmResponse)
- and snapshot.verify_positives in _VERIFY_MODES
- and core.verdict == "yes"
- ):
- # Verification re-draws over the cache, so it has to finish before the `finally` below deletes it.
- served, verification = await _verify_positive_verdict(
- scanner=scanner,
- mode=snapshot.verify_positives,
- core_step=next(step for step in steps if step.name == STEP_CORE),
- first=core,
- run=run,
- cache=cache,
- model=snapshot.model,
- )
- step_outputs = {**step_outputs, STEP_CORE: served}
finally:
if cache is not None:
await _delete_video_cache(cache_client, cache.name)
@@ -725,92 +697,12 @@ async def _run_mission(
return _MissionOutcome(
finalized=finalized,
signals=signals,
- verification=verification,
thumbnail_video_s=getattr(step_outputs.get(STEP_CORE), "thumbnail_t", None),
key_moment_video_s=getattr(step_outputs.get(STEP_CORE), "key_moment_t", None),
core_response=step_outputs.get(STEP_CORE),
)
-async def _verify_positive_verdict(
- *,
- scanner: MonitorScanner,
- mode: str,
- core_step: MissionStep,
- first: MonitorLlmResponse,
- run: Any,
- cache: Any | None,
- model: str,
-) -> tuple[MonitorLlmResponse, VerificationRecord]:
- """Re-draw the core step once; a `yes` is served only when the second draw agrees.
-
- Replay Vision optimizes for precision, not recall: a finding it presents must hold up, and a missed one costs
- less than a wrong one. So a single dissenting draw is enough to drop the `yes`, and the dissent (its verdict and
- its reasoning) is what gets served. No third draw breaks the tie in favour of the finding.
-
- Every draw is a fresh conversation over the same cached video and preamble, so it never sees the first pass or
- its reasoning. Verification only ever tightens a scan that already succeeded: without a cache, without time left
- in the activity budget, or when the draw fails for any reason, the first verdict stands and the record says why.
- """
- draws = [first]
- skipped_reason: str | None = None
- if cache is None:
- skipped_reason = "no_cache"
- else:
- # An activity timeout fires outside the `except` below and fails the whole scan, first verdict included.
- # Capping the draw at the remaining budget turns that into a `draw_failed` the first pass survives.
- budget = _remaining_verify_budget_seconds()
- if budget is not None and budget <= 0:
- skipped_reason = "no_budget"
- else:
- verify_step = replace(core_step, name=f"{STEP_CORE}_verify_2")
- try:
- outputs = await asyncio.wait_for(run(steps=[verify_step], cache_name=cache.name), timeout=budget)
- draw = outputs[verify_step.name]
- if not isinstance(draw, MonitorLlmResponse):
- raise TypeError(f"verify draw returned {type(draw).__name__}")
- draws.append(draw)
- except Exception as exc:
- # No traceback or message: a provider error body can quote the prompt, as at the activity boundary.
- logger.warning(
- "replay_vision.call_scanner_provider.verify_draw_failed",
- model=model,
- error_type=type(exc).__name__,
- code=getattr(exc, "code", None),
- status=getattr(exc, "status", None),
- )
- skipped_reason = "draw_failed"
-
- # The dissent, when there is one, is the last draw; otherwise the first pass stands.
- resolved_draw = draws[-1]
- served = resolved_draw if mode == "enforce" else first
- if skipped_reason:
- outcome = skipped_reason
- else:
- outcome = "agreed" if resolved_draw.verdict == first.verdict else "flipped"
- record_verification_outcome(scanner_type=scanner.scanner_type.value, mode=mode, outcome=outcome)
- record = VerificationRecord(
- mode=mode,
- draws=[draw.verdict for draw in draws],
- resolved_verdict=resolved_draw.verdict,
- served_verdict=served.verdict,
- skipped_reason=skipped_reason,
- )
- return served, record
-
-
-def _remaining_verify_budget_seconds() -> float | None:
- """Seconds a verify draw may take before the activity's start-to-close timeout, or None when there is no timeout
- (the eval suite calls `run_scan` outside an activity)."""
- if not activity.in_activity():
- return None
- info = activity.info()
- if info.start_to_close_timeout is None:
- return None
- elapsed = (timezone.now() - info.started_time).total_seconds()
- return info.start_to_close_timeout.total_seconds() - elapsed - _VERIFY_BUDGET_RESERVE_SECONDS
-
-
def _validate_signal_timestamps(output: BaseModel, *, duration_seconds: float | None) -> str | None:
"""`duration_seconds` is the video's length: signals are reported in video time."""
if not isinstance(output, SignalsResponse) or not output.signals:
diff --git a/products/replay_vision/backend/temporal/metrics.py b/products/replay_vision/backend/temporal/metrics.py
index 48a2d70d1324..14cf5135a4dd 100644
--- a/products/replay_vision/backend/temporal/metrics.py
+++ b/products/replay_vision/backend/temporal/metrics.py
@@ -95,12 +95,6 @@ REPLAY_VISION_NETWORK_STATE = Counter(
["scanner_type", "state"],
)
-REPLAY_VISION_VERIFICATION_OUTCOMES = Counter(
- "replay_vision_verification_outcomes_total",
- "Verify-positives results per verified monitor `yes`: agreed, flipped, no_cache, no_budget, draw_failed",
- ["scanner_type", "mode", "outcome"],
-)
-
REPLAY_VISION_QUOTA_EXHAUSTED_SKIPS = Counter(
"replay_vision_quota_exhausted_skips_total",
"Observations skipped because the org's monthly credit quota was exhausted",
@@ -288,12 +282,6 @@ def record_mission_pass(model: str, path: str) -> None:
_otel.record_counter_twin(REPLAY_VISION_MISSION_PASSES, 1, labels)
-def record_verification_outcome(*, scanner_type: str, mode: str, outcome: str) -> None:
- labels = {"scanner_type": scanner_type, "mode": mode, "outcome": outcome}
- REPLAY_VISION_VERIFICATION_OUTCOMES.labels(**labels).inc()
- _otel.record_counter_twin(REPLAY_VISION_VERIFICATION_OUTCOMES, 1, labels)
-
-
def record_quota_exhausted_skip(scanner_type: str) -> None:
REPLAY_VISION_QUOTA_EXHAUSTED_SKIPS.labels(scanner_type=scanner_type).inc()
_otel.record_counter_twin(REPLAY_VISION_QUOTA_EXHAUSTED_SKIPS, 1, {"scanner_type": scanner_type})
diff --git a/products/replay_vision/backend/temporal/snapshots.py b/products/replay_vision/backend/temporal/snapshots.py
index 0316f18b5e30..ccbbb22382b5 100644
--- a/products/replay_vision/backend/temporal/snapshots.py
+++ b/products/replay_vision/backend/temporal/snapshots.py
@@ -39,10 +39,6 @@ class ScannerSnapshot(BaseModel, frozen=True):
# don't read as even traffic ("control sampled at 1.1%, test at 100%"). Set by the tick, not
# `from_scanner`: the rates depend on live rollout shares the scanner row doesn't carry.
variant_sampling_rates: dict[str, float] | None = None
- # How a monitor `yes` verdict is re-checked: `off` (one pass), `shadow` (draw again, record the result, serve the
- # first pass), or `enforce` (serve the `yes` only when the second draw agrees, else the dissent). A plain string
- # so a retired mode never breaks old-row loads.
- verify_positives: str = "off"
# The learned rulesets this scan runs with, frozen at create so retries match. Hidden from every dump, so the
# API never returns them; read back only through `load_for` and `model_validate`.
learned_ruleset_ids: list[str] = Field(default_factory=list, exclude=True)
diff --git a/products/replay_vision/backend/temporal/types.py b/products/replay_vision/backend/temporal/types.py
index 308d6da4038d..088406623ddf 100644
--- a/products/replay_vision/backend/temporal/types.py
+++ b/products/replay_vision/backend/temporal/types.py
@@ -10,7 +10,7 @@ from products.replay_vision.backend.session_limits import MAX_SESSION_ID_LENGTH
from products.replay_vision.backend.temporal.scanners.base import SignalFinding
from products.replay_vision.backend.temporal.scanners.classifier import ClassifierOutput
from products.replay_vision.backend.temporal.scanners.experiment import ExperimentOutput
-from products.replay_vision.backend.temporal.scanners.monitor import MonitorOutput, MonitorVerdict
+from products.replay_vision.backend.temporal.scanners.monitor import MonitorOutput
from products.replay_vision.backend.temporal.scanners.scorer import ScorerOutput
from products.replay_vision.backend.temporal.scanners.summarizer import SummarizerOutput
from products.replay_vision.backend.temporal.snapshots import (
@@ -24,19 +24,6 @@ AnyScannerOutput = Annotated[
]
-class VerificationRecord(BaseModel, frozen=True):
- """Audit of the extra draws taken to verify a monitor `yes` verdict. Absent when no verdict was verified."""
-
- mode: str
- # Verdicts in draw order; the first entry is the pass that triggered verification.
- draws: list[MonitorVerdict]
- # The verdict verification settled on: the first pass when the second draw agrees, else the dissent.
- # `served_verdict` is what `model_output` carries: the same value under `enforce`, the first draw under `shadow`.
- resolved_verdict: MonitorVerdict
- served_verdict: MonitorVerdict
- skipped_reason: str | None = None
-
-
class EmittedSignal(BaseModel, frozen=True):
"""One side-mission finding that reached the Signals product. Carries what a reader needs to name the
finding and what the ranking needs to weigh it, and deliberately not the finding's full description: that
@@ -59,7 +46,6 @@ class ScannerResult(BaseModel, frozen=True):
# and can rank a weak finding below a strong one. Empty on non-signal rows and on rows scanned before
# this shipped; `signal_problem_types` stays because those older rows carry only it.
signal_summaries: list[EmittedSignal] = Field(default_factory=list)
- verification: VerificationRecord | None = None
# Experiment scanners only. The variant comes from the exposure data, never from the model, so
# readouts that group by it cannot disagree with the prompt's framing. Null on rows scanned
# before attribution shipped, which readouts count as unattributed.
@@ -304,7 +290,6 @@ class ScannerCallOutput(BaseModel, frozen=True):
model_output: AnyScannerOutput
# Extracted from the LLM response before `finalize` so per-type output mapping can't drop them.
signals: list[SignalFinding] = Field(default_factory=list)
- verification: VerificationRecord | None = None
# Video seconds the model picked for the thumbnail; None when it skipped the optional pick.
thumbnail_video_s: int | None = None
# Signal spans on the video clock, which `signals` no longer carries once they move to session time.
diff --git a/products/replay_vision/backend/temporal/workflow.py b/products/replay_vision/backend/temporal/workflow.py
index c5b482360ce8..cd6d8b681506 100644
--- a/products/replay_vision/backend/temporal/workflow.py
+++ b/products/replay_vision/backend/temporal/workflow.py
@@ -353,7 +353,7 @@ class ApplyScannerWorkflow(PostHogWorkflow):
),
),
# Multi-turn tool conversation (video + on-demand event lookups) needs more headroom than a single
- # call, and must cover both mission passes plus the one verify-positives draw: a pass that
+ # call, and must cover both mission passes: a pass that
# overruns would surface as a Temporal timeout labeled provider_transient when the real problem is
# the scanner's prompt.
start_to_close_timeout=dt.timedelta(minutes=20),
@@ -422,7 +422,6 @@ class ApplyScannerWorkflow(PostHogWorkflow):
signals_count=signals_count,
signal_problem_types=signal_problem_types,
signal_summaries=signal_summaries,
- verification=call_output.verification,
experiment_variant=(
experiment_resolution.experiment_variant if experiment_resolution is not None else None
),
diff --git a/products/replay_vision/backend/tests/test_call_scanner_provider.py b/products/replay_vision/backend/tests/test_call_scanner_provider.py
index 4c7d95e7b447..a6f541aff860 100644
--- a/products/replay_vision/backend/tests/test_call_scanner_provider.py
+++ b/products/replay_vision/backend/tests/test_call_scanner_provider.py
@@ -1,28 +1,18 @@
-import datetime as dt
-import dataclasses
from collections.abc import Callable
from typing import Any, cast
import pytest
-import time_machine
from unittest.mock import AsyncMock, MagicMock, patch
-from django.utils import timezone
-
import httpx
from google.genai import types
from google.genai.errors import APIError
from pydantic import BaseModel
-from temporalio.testing import ActivityEnvironment
-
-from posthog.dataclasses import frozen
from products.replay_vision.backend.models.replay_scanner import ScannerType
from products.replay_vision.backend.temporal.activities.call_scanner_provider import (
_key_moment_session_ms,
_maybe_create_video_cache,
- _MissionOutcome,
- _remaining_verify_budget_seconds,
_run_mission,
_run_mission_attempts,
_run_pass,
@@ -31,7 +21,6 @@ from products.replay_vision.backend.temporal.activities.call_scanner_provider im
)
from products.replay_vision.backend.temporal.errors import FailureKind, ScannerFailureError
from products.replay_vision.backend.temporal.events_tool import events_tool
-from products.replay_vision.backend.temporal.metrics import REPLAY_VISION_VERIFICATION_OUTCOMES
from products.replay_vision.backend.temporal.scanners.base import (
STEP_MAX_OUTPUT_TOKENS,
MissionStep,
@@ -39,7 +28,7 @@ from products.replay_vision.backend.temporal.scanners.base import (
SignalsResponse,
)
from products.replay_vision.backend.temporal.scanners.monitor import MonitorLlmResponse, MonitorOutput, MonitorScanner
-from products.replay_vision.backend.temporal.types import ScannerSnapshot, VerificationRecord
+from products.replay_vision.backend.temporal.types import ScannerSnapshot
from products.replay_vision.backend.temporal.video_clock import ActiveSpan, VideoClock
_LABELS = {"provider": "gemini", "model": "gemini-3-flash-preview", "scanner_type": "monitor"}
@@ -662,234 +651,6 @@ class TestRunPass:
_MODULE = "products.replay_vision.backend.temporal.activities.call_scanner_provider"
-def _verification_counts() -> dict[tuple[str, str], float]:
- return {
- (sample.labels["mode"], sample.labels["outcome"]): sample.value
- for family in REPLAY_VISION_VERIFICATION_OUTCOMES.collect()
- for sample in family.samples
- if sample.name == "replay_vision_verification_outcomes_total"
- }
-
-
-@frozen
-class _ScanRun:
- outcome: _MissionOutcome
- # Runner calls in order, then the cache deletion.
- calls: list[Any]
- # Verification counter increments during the scan, keyed by (mode, outcome).
- counted: dict[tuple[str, str], float]
-
-
-class TestVerifyPositives:
- class _Cache:
- name = "caches/abc"
-
- @staticmethod
- def _answer(verdict: str) -> MonitorLlmResponse:
- return MonitorLlmResponse(reasoning=f"because {verdict}", verdict=cast(Any, verdict), confidence=0.8)
-
- async def _scan(
- self,
- *,
- mode: str,
- answers: list[str | Exception],
- allow_inconclusive: bool = False,
- cached: bool = True,
- emits_signals: bool = False,
- budget_seconds: float | None = None,
- ) -> _ScanRun:
- # `answers[0]` is the first pass; the rest are the verify draws in order.
- scanner = MonitorScanner(
- prompt="did it happen", allow_inconclusive=allow_inconclusive, emits_signals=emits_signals
- )
- snapshot = ScannerSnapshot(
- name="m",
- scanner_type=ScannerType.MONITOR,
- scanner_version=1,
- model="gemini-3-flash-preview",
- provider="gemini",
- emits_signals=emits_signals,
- scanner_config={"prompt": "did it happen"},
- verify_positives=mode,
- )
- pending = iter(answers)
- calls: list[Any] = []
- unchecked_steps: list[str] = []
-
- async def fake_run_steps(*, steps: list[MissionStep], cache_name: str | None, **_: Any) -> dict[str, BaseModel]:
- calls.append({"steps": [step.name for step in steps], "cache_name": cache_name})
- # Collect rather than assert: the verify draw runs inside an `except Exception` that turns any
- # error into `draw_failed`, so an assertion raised here would pass the test instead of failing it.
- unchecked_steps.extend(step.name for step in steps if step.required and step.validate is None)
- answer = next(pending)
- if isinstance(answer, Exception):
- raise answer
- return {step.name: self._answer(answer) for step in steps if step.required}
-
- async def fake_delete(*_: Any) -> None:
- calls.append("delete_cache")
-
- before = _verification_counts()
- with (
- patch(f"{_MODULE}.genai.AsyncClient"),
- patch(f"{_MODULE}.GoogleGenAIClient"),
- patch(f"{_MODULE}.build_events_index", return_value={}),
- patch(
- f"{_MODULE}._maybe_create_video_cache", new=AsyncMock(return_value=self._Cache() if cached else None)
- ),
- patch(f"{_MODULE}._delete_video_cache", new=fake_delete),
- patch(f"{_MODULE}._run_steps", new=fake_run_steps),
- patch(f"{_MODULE}._remaining_verify_budget_seconds", return_value=budget_seconds),
- ):
- outcome = await _run_mission(
- scanner=scanner,
- snapshot=snapshot,
- video_part=_VIDEO,
- video_clock=_IDENTITY_CLOCK,
- preamble_text="PRE",
- team_id=1,
- llm_inputs=MagicMock(),
- trace_id="trace-1",
- )
- # A verify draw must keep the core step's semantic check, or an `inconclusive` the scanner forbids
- # would count as a vote.
- assert unchecked_steps == []
- counted = {
- key: value - before.get(key, 0.0)
- for key, value in _verification_counts().items()
- if value != before.get(key, 0.0)
- }
- return _ScanRun(outcome=outcome, calls=calls, counted=counted)
-
- @pytest.mark.asyncio
- @pytest.mark.parametrize(
- "mode,answers",
- [
- ("off", ["yes"]),
- ("Enforce", ["yes"]),
- ("enforce", ["no"]),
- ("enforce", ["inconclusive"]),
- ],
- )
- async def test_only_a_positive_under_a_live_mode_is_verified(
- self, mode: str, answers: list[str | Exception]
- ) -> None:
- run = await self._scan(mode=mode, answers=answers, allow_inconclusive=True)
- assert len(run.calls) == 2 # the first pass and the cache deletion
- assert cast(MonitorOutput, run.outcome.finalized).verdict == answers[0]
- assert run.outcome.verification is None
- assert run.counted == {}
-
- @pytest.mark.asyncio
- @pytest.mark.parametrize(
- "mode,draws,allow_inconclusive,resolved,served,outcome_label",
- [
- ("shadow", ["yes", "yes"], False, "yes", "yes", "agreed"),
- ("enforce", ["yes", "yes"], False, "yes", "yes", "agreed"),
- ("enforce", ["yes", "no"], False, "no", "no", "flipped"),
- ("shadow", ["yes", "no"], False, "no", "yes", "flipped"),
- ("enforce", ["yes", "inconclusive"], True, "inconclusive", "inconclusive", "flipped"),
- ],
- )
- async def test_a_yes_stands_only_when_the_second_draw_agrees(
- self,
- mode: str,
- draws: list[str],
- allow_inconclusive: bool,
- resolved: str,
- served: str,
- outcome_label: str,
- ) -> None:
- run = await self._scan(mode=mode, answers=list(draws), allow_inconclusive=allow_inconclusive)
- finalized = cast(MonitorOutput, run.outcome.finalized)
- # `enforce` serves the whole settled draw, reasoning included, not just its verdict.
- assert (finalized.verdict, finalized.reasoning) == (served, f"because {served}")
- assert run.outcome.verification == VerificationRecord(
- mode=mode, draws=cast(Any, draws), resolved_verdict=cast(Any, resolved), served_verdict=cast(Any, served)
- )
- # One first pass, one verify draw, the cache deletion. A dissent never triggers a third draw.
- assert len(run.calls) == 3
- assert run.counted == {(mode, outcome_label): 1.0}
-
- @pytest.mark.asyncio
- @pytest.mark.parametrize(
- "failure",
- [
- ScannerFailureError("rejected", kind=FailureKind.VALIDATION_FAILED),
- APIError(429, {"error": {"message": "quota", "status": "RESOURCE_EXHAUSTED"}}),
- # `asyncio.wait_for` raises this when a draw runs past the activity budget.
- TimeoutError(),
- ],
- )
- async def test_a_failed_draw_keeps_the_first_verdict_and_never_raises(self, failure: Exception) -> None:
- run = await self._scan(mode="enforce", answers=["yes", failure])
- assert cast(MonitorOutput, run.outcome.finalized).verdict == "yes"
- assert run.outcome.verification == VerificationRecord(
- mode="enforce", draws=["yes"], resolved_verdict="yes", served_verdict="yes", skipped_reason="draw_failed"
- )
- assert len(run.calls) == 3
- assert run.counted == {("enforce", "draw_failed"): 1.0}
-
- @pytest.mark.asyncio
- async def test_without_a_cache_the_first_pass_stands(self) -> None:
- # A re-draw without the cache would re-send the whole video; that spend is not worth one extra vote.
- run = await self._scan(mode="enforce", answers=["yes"], cached=False)
- assert len(run.calls) == 1
- assert run.outcome.verification == VerificationRecord(
- mode="enforce", draws=["yes"], resolved_verdict="yes", served_verdict="yes", skipped_reason="no_cache"
- )
- assert run.counted == {("enforce", "no_cache"): 1.0}
-
- @pytest.mark.asyncio
- @pytest.mark.parametrize("budget_seconds,draws_taken", [(0.0, 0), (-5.0, 0), (30.0, 1)])
- async def test_a_draw_never_starts_past_the_activity_budget(self, budget_seconds: float, draws_taken: int) -> None:
- # The activity timeout would fail the whole scan, first verdict included, so a draw with no time left is skipped.
- run = await self._scan(mode="enforce", answers=["yes", "yes"], budget_seconds=budget_seconds)
- assert len(run.calls) == 2 + draws_taken
- assert cast(MonitorOutput, run.outcome.finalized).verdict == "yes"
- if draws_taken == 0:
- assert run.outcome.verification == VerificationRecord(
- mode="enforce", draws=["yes"], resolved_verdict="yes", served_verdict="yes", skipped_reason="no_budget"
- )
- assert run.counted == {("enforce", "no_budget"): 1.0}
- else:
- assert run.counted == {("enforce", "agreed"): 1.0}
-
- @pytest.mark.asyncio
- @pytest.mark.parametrize(
- "start_to_close,elapsed,expected",
- [
- (dt.timedelta(minutes=20), dt.timedelta(minutes=5), 14 * 60.0),
- (dt.timedelta(minutes=20), dt.timedelta(minutes=19, seconds=30), -30.0),
- (None, dt.timedelta(minutes=5), None),
- ],
- )
- async def test_remaining_budget_reads_the_activity_timeout(
- self, start_to_close: dt.timedelta | None, elapsed: dt.timedelta, expected: float | None
- ) -> None:
- now = timezone.now()
- env = ActivityEnvironment()
- env.info = dataclasses.replace(env.info, start_to_close_timeout=start_to_close, started_time=now - elapsed)
-
- async def read_budget() -> float | None:
- return _remaining_verify_budget_seconds()
-
- with time_machine.travel(now, tick=False):
- assert await env.run(read_budget) == expected
-
- def test_remaining_budget_is_unbounded_outside_an_activity(self) -> None:
- assert _remaining_verify_budget_seconds() is None
-
- @pytest.mark.asyncio
- async def test_verify_draws_are_blind_core_only_turns_over_the_live_cache(self) -> None:
- run = await self._scan(mode="enforce", answers=["yes", "no"], emits_signals=True)
- assert run.calls == [
- {"steps": ["core", "signals"], "cache_name": "caches/abc"},
- {"steps": ["core_verify_2"], "cache_name": "caches/abc"},
- "delete_cache",
- ]
-
-
class TestStepConfig:
def test_inline_path_carries_tools_and_no_cache(self) -> None:
config = _step_config(
diff --git a/products/replay_vision/backend/tests/test_temporal.py b/products/replay_vision/backend/tests/test_temporal.py
index 9c469e6fbb86..b4f045a157be 100644
--- a/products/replay_vision/backend/tests/test_temporal.py
+++ b/products/replay_vision/backend/tests/test_temporal.py
@@ -185,7 +185,6 @@ def test_scanner_snapshot_loads_rows_with_retired_model_and_provider_ids() -> No
)
assert snapshot.model == "gemini-1.0-flash-retired-preview"
assert snapshot.provider == "hooli"
- assert snapshot.verify_positives == "off"
def _make_scanner(**overrides) -> ReplayScanner:
diff --git a/products/replay_vision/evals/README.md b/products/replay_vision/evals/README.md
index b8939b88537d..3a9a0720e97c 100644
--- a/products/replay_vision/evals/README.md
+++ b/products/replay_vision/evals/README.md
@@ -40,10 +40,6 @@ hogli evals eval_scanner_quality
`BRAINTRUST_API_KEY` is required by the harness engine even though this private suite only logs locally.
Without `REPLAY_VISION_EVAL_DATASET` the suite logs a warning and runs nothing, so it never breaks a full `hogli evals` run.
Use `--trials N` for variance on Gemini nondeterminism and `--eval <case-substring>` for one case.
-Set `REPLAY_VISION_EVAL_VERIFY_POSITIVES=shadow` or `=enforce` to run monitor cases with verify-positives on.
-Only a first-pass `yes` is verified, so a case that answers `no` keeps `verification: null`, and a `yes` whose second draw cannot run (`no_cache`, `no_budget`, `draw_failed`) keeps the first verdict and records that reason.
-Both modes record the draw, but only `enforce` serves it, so `labeled_outcome` from a shadow run matches a run with the feature off.
-Compare `labeled_outcome` on the thumbs-downed `yes` cases against a run without it to see what the extra draws buy.
## Scorers
diff --git a/products/replay_vision/evals/eval_scanner_quality.py b/products/replay_vision/evals/eval_scanner_quality.py
index db47f0c14e05..eb6fbf648063 100644
--- a/products/replay_vision/evals/eval_scanner_quality.py
+++ b/products/replay_vision/evals/eval_scanner_quality.py
@@ -7,10 +7,8 @@ Edit the templates under backend/temporal/scanners/prompts/ and re-run to compar
in the local logs (this suite is private; nothing is sent to Braintrust).
Requires REPLAY_VISION_EVAL_DATASET (a directory written by collect.py) and GEMINI_API_KEY.
-Set REPLAY_VISION_EVAL_VERIFY_POSITIVES to `shadow` or `enforce` to run monitor cases with verify-positives on.
"""
-import os
import time
import asyncio
from functools import partial
@@ -31,7 +29,6 @@ from products.replay_vision.backend.temporal.activities.call_scanner_provider im
from products.replay_vision.backend.temporal.errors import ScannerFailureError
from products.replay_vision.backend.temporal.gemini import gemini_api_key
from products.replay_vision.backend.temporal.scanners import scanner_from_snapshot
-from products.replay_vision.backend.temporal.snapshots import ScannerSnapshot
from products.replay_vision.backend.temporal.video_clock import VideoClock, video_clock_from_export_context
from products.replay_vision.evals.dataset import (
DATASET_ENV_VAR,
@@ -55,17 +52,6 @@ SUITE_KIND = SuiteKind.ONE_SHOT
logger = structlog.get_logger(__name__)
_MAX_PROCESSING_WAIT_SECONDS = 300
-VERIFY_POSITIVES_ENV_VAR = "REPLAY_VISION_EVAL_VERIFY_POSITIVES"
-
-
-def _eval_snapshot(golden: GoldenCase) -> ScannerSnapshot:
- """The recorded snapshot, with the verify-positives mode overridden when the run asks for one."""
- mode = os.environ.get(VERIFY_POSITIVES_ENV_VAR, "").strip()
- if not mode:
- return golden.snapshot
- if mode not in ("shadow", "enforce"):
- raise ValueError(f"{VERIFY_POSITIVES_ENV_VAR} must be `shadow` or `enforce`, got {mode!r}")
- return golden.snapshot.model_copy(update={"verify_positives": mode})
def build_case(golden: GoldenCase) -> BaseEvalCase:
@@ -163,7 +149,7 @@ async def _scan_task(
try:
try:
result = await run_scan(
- snapshot=_eval_snapshot(golden),
+ snapshot=golden.snapshot,
scanner=scanner,
llm_inputs=llm_inputs,
team_name=golden.team_name,
@@ -196,7 +182,6 @@ async def _scan_task(
"scanner_type": golden.scanner_type,
"signals_count": len(result.signals),
"signals": [signal.model_dump(mode="json") for signal in result.signals],
- "verification": result.verification.model_dump(mode="json") if result.verification else None,
"primary": primary,
"last_message": primary or "",
}
diff --git a/products/replay_vision/evals/test/test_eval_scanner_quality.py b/products/replay_vision/evals/test/test_eval_scanner_quality.py
index c24e75256f20..d5ffd9e629df 100644
--- a/products/replay_vision/evals/test/test_eval_scanner_quality.py
+++ b/products/replay_vision/evals/test/test_eval_scanner_quality.py
@@ -19,12 +19,7 @@ from products.replay_vision.backend.temporal.activities.call_scanner_provider im
from products.replay_vision.backend.temporal.scanners import ClassifierScanner
from products.replay_vision.backend.temporal.scanners.base import SignalFinding
from products.replay_vision.backend.temporal.scanners.monitor import MonitorOutput
-from products.replay_vision.backend.temporal.types import (
- ScannerCallOutput,
- ScannerLlmInputs,
- ScannerSnapshot,
- VerificationRecord,
-)
+from products.replay_vision.backend.temporal.types import ScannerCallOutput, ScannerLlmInputs, ScannerSnapshot
from products.replay_vision.evals import collector, eval_scanner_quality
from products.replay_vision.evals.collector import (
_VideoAsset,
@@ -210,23 +205,12 @@ def test_scan_completed_fails_on_schema_breakage() -> None:
],
ids=["empty", "multiple_findings"],
)
- "verification",
- [
- None,
- VerificationRecord(mode="enforce", draws=["yes", "yes"], resolved_verdict="yes", served_verdict="yes"),
- ],
- ids=["unverified", "verified"],
-)
-def test_scan_task_retains_structured_signals(
- signals: list[dict[str, str | int | float]], verification: VerificationRecord | None, tmp_path: Path
-) -> None:
+def test_scan_task_retains_structured_signals(signals: list[dict[str, str | int | float]], tmp_path: Path) -> None:
golden = _golden("monitor", True, {"verdict": "yes"})
golden = golden.model_copy(update={"snapshot": golden.snapshot.model_copy(update={"emits_signals": True})})
scan_output = ScannerCallOutput(
model_output=MonitorOutput(verdict="yes", reasoning="The book list is covered.", confidence=0.9),
signals=[SignalFinding.model_validate(signal) for signal in signals],
- verification=verification,
)
with (
patch.object(GoldenCase, "load_inputs", return_value=MagicMock(spec=ScannerLlmInputs)),
@@ -255,7 +239,6 @@ def test_scan_task_retains_structured_signals(
"scanner_type": "monitor",
"signals_count": len(signals),
"signals": signals,
- "verification": verification.model_dump(mode="json") if verification else None,
"primary": "Verdict: yes",
"last_message": "Verdict: yes",
}
diff --git a/products/replay_vision/frontend/components/ObservationDockCard.stories.tsx b/products/replay_vision/frontend/components/ObservationDockCard.stories.tsx
index 7964fb0ae12d..3d7dce7c1eda 100644
--- a/products/replay_vision/frontend/components/ObservationDockCard.stories.tsx
+++ b/products/replay_vision/frontend/components/ObservationDockCard.stories.tsx
@@ -27,7 +27,6 @@ const observation = (overrides: Partial<ReplayObservationApi> = {}): ReplayObser
provider: 'google',
emits_signals: true,
scanner_config: { prompt: PROMPT },
- verify_positives: 'off',
},
scanner_result: {
model_output: {
@@ -38,7 +37,6 @@ const observation = (overrides: Partial<ReplayObservationApi> = {}): ReplayObser
'The user entered a coupon code three times, got a validation error each time, then submitted the payment form twice before leaving the page.',
},
signals_count: 1,
- verification: null,
},
prompt_question: 'Did the user struggle to complete checkout?',
triggered_by: 'schedule',
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index 6dcf6221ac0d..79f6c9efccb1 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -658,8 +658,6 @@ export interface ScannerSnapshotApi {
emits_signals: boolean
/** Scanner-type-specific configuration at run time (prompt, tags, scale, etc.). */
scanner_config: unknown
- /** How a monitor `yes` was re-checked at run time: `off` (one pass, the default), `shadow` (second draw recorded only), or `enforce` (the `yes` stands only when the second draw agrees). */
- verify_positives: string
/**
* Experiment scanners with balanced sampling: the 0..1 rate each watched variant was sampled at by the tick that dispatched this scan. Null otherwise, so even per-variant counts can be read against the rates that produced them.
* @nullable
@@ -667,25 +665,6 @@ export interface ScannerSnapshotApi {
variant_sampling_rates?: ScannerSnapshotApiVariantSamplingRates
}
-/**
- * Mirrors `temporal.types.VerificationRecord` for OpenAPI generation.
- */
-export interface VerificationRecordApi {
- /** Verify-positives mode the scan ran with: `shadow` records the second draw only, `enforce` serves the settled verdict. */
- mode: string
- /** Monitor verdicts in draw order: the pass that triggered verification, then the second draw when it ran. */
- draws: string[]
- /** The verdict verification settled on: the first pass when the second draw agrees, else the dissent. */
- resolved_verdict: string
- /** The verdict `model_output` carries: the resolved one under `enforce`, the first draw under `shadow`. */
- served_verdict: string
- /**
- * Why verification stopped early (`no_cache`, `no_budget`, `draw_failed`), leaving the first pass in place. Null when every draw ran.
- * @nullable
- */
- skipped_reason: string | null
-}
-
/**
* Mirrors `temporal.types.ScannerResult` for OpenAPI generation.
*/
@@ -697,8 +676,6 @@ export interface ScannerResultApi {
* @minimum 0
*/
signals_count: number
- /** Extra draws taken to verify a monitor `yes` verdict. Null when the scan did not verify one. */
- verification: VerificationRecordApi | null
/**
* Experiment scanners only: the variant the exposure data attributes this session's person to. Null on the other types and on rows scanned before variant attribution shipped.
* @nullable
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
index 1ef1d34ee7de..48e29196091f 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
@@ -400,7 +400,6 @@ const observation = (overrides: Partial<ReplayObservationApi> = {}): ReplayObser
provider: 'google',
emits_signals: false,
scanner_config: { prompt: 'Summarize this session.', length: 'medium' },
- verify_positives: 'off',
},
scanner_result: {
model_output: {
@@ -548,7 +547,6 @@ const observationDetail = observation({
'The user spent most of the session in checkout, retrying an invalid coupon three times before abandoning the cart at the payment step.',
},
signals_count: 1,
- verification: null,
},
})
@@ -574,7 +572,6 @@ const monitorObservationDetail = observation({
prompt: MONITOR_DETAIL_PROMPT,
allow_inconclusive: true,
},
- verify_positives: 'off',
},
scanner_result: {
model_output: {
@@ -592,7 +589,6 @@ const monitorObservationDetail = observation({
].join('\n'),
},
signals_count: 1,
- verification: null,
},
})
@@ -731,7 +727,6 @@ const meta: Meta = {
provider: 'google',
emits_signals: true,
scanner_config: { prompt: 'Did the user hesitate at checkout?' },
- verify_positives: 'off',
},
scanner_result: {
model_output: {
@@ -747,7 +742,6 @@ const meta: Meta = {
key_moment_ms: 154000,
},
signals_count: 2,
- verification: null,
},
viewed: false,
}),
@@ -766,7 +760,6 @@ const meta: Meta = {
provider: 'google',
emits_signals: false,
scanner_config: { prompt: 'Score this session.', scale: { min: 0, max: 10 } },
- verify_positives: 'off',
},
scanner_result: {
model_output: {
@@ -781,7 +774,6 @@ const meta: Meta = {
],
},
signals_count: 0,
- verification: null,
},
viewed: false,
}),
@@ -808,7 +800,6 @@ const meta: Meta = {
summary: 'Hit an error dialog and filed feedback from the toast.',
},
signals_count: 0,
- verification: null,
},
viewed: true,
}),
@@ -1197,7 +1188,6 @@ const observationDetailFor = (
scanner_result: {
model_output: { scanner_type: scannerResponse.scanner_type, ...output },
signals_count: 0,
- verification: null,
},
})
@@ -1611,7 +1601,6 @@ const inconclusiveObservationDetail = observation({
'The user added two items to the cart and opened the payment step, where the card fields are masked. The recording ends about ten seconds later with the page still loading, so it does not show whether the payment went through or whether the user gave up. There is no retry, error message or backtracking before the recording stops.',
},
signals_count: 0,
- verification: null,
},
})
@@ -1661,7 +1650,6 @@ const inlineScanObservationDetail = observation({
'The user opened the pricing page twice, expanded the plan comparison, and left the app from there both times without starting a checkout.',
},
signals_count: 0,
- verification: null,
},
})
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 85c1e8b30729..bea2c1316f87 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -44338,8 +44338,6 @@ export namespace Schemas {
emits_signals: boolean;
/** Scanner-type-specific configuration at run time (prompt, tags, scale, etc.). */
scanner_config: unknown;
- /** How a monitor `yes` was re-checked at run time: `off` (one pass, the default), `shadow` (second draw recorded only), or `enforce` (the `yes` stands only when the second draw agrees). */
- verify_positives: string;
/**
* Experiment scanners with balanced sampling: the 0..1 rate each watched variant was sampled at by the tick that dispatched this scan. Null otherwise, so even per-variant counts can be read against the rates that produced them.
* @nullable
@@ -44347,25 +44345,6 @@ export namespace Schemas {
variant_sampling_rates?: ScannerSnapshotVariantSamplingRates;
}
- /**
- * Mirrors `temporal.types.VerificationRecord` for OpenAPI generation.
- */
- export interface VerificationRecord {
- /** Verify-positives mode the scan ran with: `shadow` records the second draw only, `enforce` serves the settled verdict. */
- mode: string;
- /** Monitor verdicts in draw order: the pass that triggered verification, then the second draw when it ran. */
- draws: string[];
- /** The verdict verification settled on: the first pass when the second draw agrees, else the dissent. */
- resolved_verdict: string;
- /** The verdict `model_output` carries: the resolved one under `enforce`, the first draw under `shadow`. */
- served_verdict: string;
- /**
- * Why verification stopped early (`no_cache`, `no_budget`, `draw_failed`), leaving the first pass in place. Null when every draw ran.
- * @nullable
- */
- skipped_reason: string | null;
- }
-
/**
* Mirrors `temporal.types.ScannerResult` for OpenAPI generation.
*/
@@ -44377,8 +44356,6 @@ export namespace Schemas {
* @minimum 0
*/
signals_count: number;
- /** Extra draws taken to verify a monitor `yes` verdict. Null when the scan did not verify one. */
- verification: VerificationRecord | null;
/**
* Experiment scanners only: the variant the exposure data attributes this session's person to. Null on the other types and on rows scanned before variant attribution shipped.
* @nullable