Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-11722): scout hollow act-observe outcome recording (#7031)
Andrew Neilson1c5ec09f9a55
diff --git a/skyvern/forge/sdk/copilot/agent.py b/skyvern/forge/sdk/copilot/agent.pyindex 8a3cbf0b4..d425c9868 100644--- a/skyvern/forge/sdk/copilot/agent.py+++ b/skyvern/forge/sdk/copilot/agent.py@@ -763,6 +763,10 @@ def _recorded_build_test_outcome_prompt(ctx: CopilotContext | None) -> str:]if outcome.missing_requested_output_facts:lines.append("missing_requested_output_facts:")+ lines.append(+ "Use the exact output_path values in goal_value_paths and returned output; "+ "output_root is diagnostic grouping only."+ )for fact in outcome.missing_requested_output_facts[:8]:if not isinstance(fact, dict):continuediff --git a/skyvern/forge/sdk/copilot/build_test_outcome.py b/skyvern/forge/sdk/copilot/build_test_outcome.pyindex 43abffe8d..9c09eac2d 100644--- a/skyvern/forge/sdk/copilot/build_test_outcome.py+++ b/skyvern/forge/sdk/copilot/build_test_outcome.py@@ -48,6 +48,7 @@ BuildTestOutcomeReasonCode = Literal["unchanged_after_recorded_outcome","metadata_reject","output_policy_reject",+ "scout_act_observe_hollow_after_interaction",]_STRUCTURAL_KEY_VERSION = "recorded_build_test_outcome:v1"@@ -172,6 +173,8 @@ def latest_recorded_build_test_outcome_repeated(ctx: object) -> bool | None:for previous in reversed(history[:-1]):if not isinstance(previous, dict):continue+ if previous.get("phase") == "scout_evaluate":+ continueprevious_key = previous.get("structural_key")if isinstance(previous_key, str):return previous_key == latest["structural_key"]@@ -287,6 +290,56 @@ def recorded_outcome_from_loaded_result_evidence()+def recorded_outcome_from_scout_act_observe_hollow(+ *,+ interaction_tool: str,+ selector: str,+ current_url: str,+ source_url: str | None,+ page_evidence: Mapping[str, object] | None,+ recapture_attempted: bool,+ recapture_result: str,+) -> RecordedBuildTestOutcome:+ shape = _hollow_page_shape(page_evidence)+ source_origin = _origin_ref(source_url)+ current_origin = _origin_ref(current_url)+ bounded_recapture_result = _bounded_ref(recapture_result)+ structural_payload = {+ "interaction_tool": _bounded_ref(interaction_tool),+ "selector": _bounded_ref(selector),+ "source_origin": source_origin,+ "current_origin": current_origin,+ "shape": shape,+ "recapture_attempted": recapture_attempted,+ "recapture_result": bounded_recapture_result,+ }+ page_refs = list(dict.fromkeys(ref for ref in (source_origin, current_origin) if ref))+ page_refs.extend(+ [+ f"forms:{shape['form_count']}",+ f"navigation_targets:{shape['navigation_target_count']}",+ f"result_containers:{shape['result_container_count']}",+ f"clickable_controls:{shape['clickable_control_count']}",+ f"recapture_attempted:{str(recapture_attempted).lower()}",+ f"recapture_result:{bounded_recapture_result}",+ ]+ )+ return RecordedBuildTestOutcome(+ phase="scout_evaluate",+ attempted_tool="scout_interaction",+ attempted_target=_bounded_ref(selector),+ verdict="repairable_failure",+ reason_code="scout_act_observe_hollow_after_interaction",+ structural_failure_identity="scout_act_observe:" + _stable_hash(structural_payload),+ page_evidence_refs=page_refs,+ observed_evidence_summary="Scout interaction reached the page, but bounded page evidence stayed hollow.",+ key_provenance={+ "structural_failure_identity": "scout interaction identity and bounded hollow page shape",+ "page_evidence_refs": "scout interaction source/current URL origins and structural counts",+ },+ )++def recorded_outcome_from_run_blocks_result(result: Mapping[str, object],*,@@ -663,6 +716,27 @@ def _origin_ref(value: object) -> str:return f"origin:{parsed.scheme}://{parsed.netloc}"+def _hollow_page_shape(page_evidence: Mapping[str, object] | None) -> dict[str, object]:+ evidence = page_evidence or {}+ challenge_state = evidence.get("challenge_state")+ return {+ "page_title_present": bool(_safe_str(evidence.get("page_title"))),+ "schema_empty_page": evidence.get("schema_empty_page") is True,+ "body_has_markup": bool(_safe_str(evidence.get("body")) or _safe_str(evidence.get("html"))),+ "visible_text_present": bool(_safe_str(evidence.get("visible_text")) or _safe_str(evidence.get("bodyText"))),+ "form_count": _bounded_len(evidence.get("forms")),+ "navigation_target_count": _bounded_len(evidence.get("navigation_targets")),+ "result_container_count": _bounded_len(evidence.get("result_containers")),+ "clickable_control_count": _bounded_len(evidence.get("clickable_controls")),+ "modal_overlay_count": _bounded_len(evidence.get("modal_overlays")),+ "challenge_detected": isinstance(challenge_state, Mapping) and challenge_state.get("detected") is True,+ }+++def _bounded_len(value: object) -> int:+ return len(value) if isinstance(value, list) else 0++def _page_refs_from_authoring_context(repair_context: CodeAuthoringRepairContext) -> list[str]:refs: list[str] = []if repair_context.current_origin:diff --git a/skyvern/forge/sdk/copilot/enforcement.py b/skyvern/forge/sdk/copilot/enforcement.pyindex e351cdfd4..56442ad01 100644--- a/skyvern/forge/sdk/copilot/enforcement.py+++ b/skyvern/forge/sdk/copilot/enforcement.py@@ -2180,6 +2180,55 @@ def _should_block_mutating_tool_after_synthesized_offer(ctx: Any, tool_name: strreturn (getattr(ctx, "synthesized_block_offered_trajectory_len", 0) or 0) == len(trajectory)+def _ambiguous_bare_selector_repair_context(ctx: Any) -> Any | None:+ repair_context = getattr(ctx, "last_code_authoring_repair_context", None)+ if getattr(repair_context, "reason_code", None) != "ambiguous_bare_selector":+ return None+ if getattr(repair_context, "workflow_run_id", None):+ return None+ if getattr(ctx, "last_run_blocks_workflow_run_id", None):+ return None+ return repair_context+++def _ambiguous_bare_selector_rescout_key(ctx: Any) -> str | None:+ repair_context = _ambiguous_bare_selector_repair_context(ctx)+ if repair_context is None:+ return None+ if getattr(repair_context, "refiner_selector", None):+ return None+ selector_alternatives = getattr(repair_context, "selector_alternatives", None)+ if isinstance(selector_alternatives, list) and selector_alternatives:+ return None+ payload = {+ "block_label": str(getattr(repair_context, "block_label", "") or ""),+ "selector": str(getattr(repair_context, "selector", "") or ""),+ "source_url": str(getattr(repair_context, "source_url", "") or ""),+ }+ return json.dumps(payload, sort_keys=True, separators=(",", ":"))+++def _ambiguous_bare_selector_rescout_signal_state(ctx: Any, tool_name: str) -> str | None:+ if tool_name != "evaluate":+ return None+ repair_context = _ambiguous_bare_selector_repair_context(ctx)+ if repair_context is None:+ return None+ if getattr(repair_context, "refiner_selector", None):+ return "block"+ selector_alternatives = getattr(repair_context, "selector_alternatives", None)+ if isinstance(selector_alternatives, list) and selector_alternatives:+ return "block"+ key = _ambiguous_bare_selector_rescout_key(ctx)+ if key is None:+ return None+ if getattr(ctx, "ambiguous_bare_selector_rescout_context_key", None) == key:+ return "block"+ # Track the one allowed same-page rescout for this author-time repair context.+ ctx.ambiguous_bare_selector_rescout_context_key = key+ return "allow"++def _should_block_mutating_tool_after_unresolved_recorded_outcome(ctx: Any, tool_name: str) -> bool:if tool_name not in _SYNTHESIZED_BLOCK_PERSISTENCE_MUTATING_TOOLS:return False@@ -2200,6 +2249,9 @@ def _should_block_mutating_tool_after_unresolved_recorded_outcome(ctx: Any, tooldef synthesized_block_persistence_signal(ctx: Any, tool_name: str) -> CopilotToolBlockerSignal | None:if tool_name in _SYNTHESIZED_BLOCK_PERSISTENCE_ALLOWED_TOOLS:return None+ ambiguous_selector_rescout_state = _ambiguous_bare_selector_rescout_signal_state(ctx, tool_name)+ if ambiguous_selector_rescout_state == "allow":+ return Noneif _should_block_mutating_tool_after_unresolved_recorded_outcome(ctx, tool_name):return CopilotToolBlockerSignal(blocker_kind="tool_error",@@ -2217,8 +2269,10 @@ def synthesized_block_persistence_signal(ctx: Any, tool_name: str) -> CopilotTooblocked_tool=tool_name,extra={"recorded_outcome_reason_code": "outcome_not_demonstrated"},)- if not _should_force_synthesized_block_persistence(ctx) and not _should_block_mutating_tool_after_synthesized_offer(- ctx, tool_name+ if (+ ambiguous_selector_rescout_state != "block"+ and not _should_force_synthesized_block_persistence(ctx)+ and not _should_block_mutating_tool_after_synthesized_offer(ctx, tool_name)):return Nonereturn CopilotToolBlockerSignal(diff --git a/skyvern/forge/sdk/copilot/runtime.py b/skyvern/forge/sdk/copilot/runtime.pyindex 9e7f777d6..34e874164 100644--- a/skyvern/forge/sdk/copilot/runtime.py+++ b/skyvern/forge/sdk/copilot/runtime.py@@ -210,6 +210,9 @@ class AgentContext:consecutive_no_progress_interaction_count: int = 0last_scout_act_observe_outcome: str | None = Nonelast_scout_act_observe_packet: dict[str, Any] | None = None+ last_scout_act_observe_recapture_attempted: bool = False+ last_scout_act_observe_recapture_result: str = ""+ ambiguous_bare_selector_rescout_context_key: str | None = Nonepending_code_authoring_runtime_repair_context: CodeAuthoringRepairContext | None = Nonelast_code_authoring_repair_context: CodeAuthoringRepairContext | None = Nonechallenge_gated_proxy_retry_count: int = 0diff --git a/skyvern/forge/sdk/copilot/tools/scouting.py b/skyvern/forge/sdk/copilot/tools/scouting.pyindex 11729299d..997bb4502 100644--- a/skyvern/forge/sdk/copilot/tools/scouting.py+++ b/skyvern/forge/sdk/copilot/tools/scouting.py@@ -15,6 +15,7 @@ from skyvern.forge import appfrom skyvern.forge.sdk.copilot.build_test_outcome import (record_build_test_outcome,recorded_outcome_from_loaded_result_evidence,+ recorded_outcome_from_scout_act_observe_hollow,)from skyvern.forge.sdk.copilot.composition_browser_expressions import (scout_accessible_role_name_expression as _scout_accessible_role_name_expression,@@ -370,34 +371,71 @@ def _record_scouted_interaction(_ACT_OBSERVE_TOOLS = frozenset({"click"})+def _scout_act_observe_capture_outcome(parsed: dict[str, Any] | None, *, started: float, timeout_seconds: float) -> str:+ if parsed is None:+ return "timeout" if time.monotonic() - started >= timeout_seconds else "error"+ if has_bounded_page_schema(parsed):+ return "attached"+ return "hollow"+++def _scout_act_observe_no_payload_result(*, started: float, timeout_seconds: float) -> str:+ return "timeout" if time.monotonic() - started >= timeout_seconds else "no_payload"++async def _scout_act_observe_page_evidence(ctx: AgentContext, *, url: str) -> dict[str, Any] | None:"""Run the bounded page-side extractor right after a scout interaction.- Degrades to None on timeout, error, or a hollow parse so the interaction- result is never blocked or failed by capture problems."""+ Degrades to None on timeout or error so the interaction result is never+ blocked or failed by capture problems. Hollow packets still return so an+ interaction-proven hollow page can be recorded as a typed outcome."""if getattr(ctx, "discovery_mcp_server", None) is None:return Nonetimeout_seconds = settings.COPILOT_SCOUT_ACT_OBSERVE_TIMEOUT_SECONDSstarted = time.monotonic()+ ctx.last_scout_act_observe_recapture_attempted = False+ ctx.last_scout_act_observe_recapture_result = ""parsed: dict[str, Any] | None = Nonetry:parsed = await _composition_get_structured_evidence(ctx, inspected_url=url, current_url=url, timeout_seconds=timeout_seconds)- if parsed is not None and has_bounded_page_schema(parsed):- outcome = "attached"- elif parsed is not None and has_actionable_steer_content(parsed):- # Standalone clickable controls are steer-able grounding but not forward progress:- # keep parsed for the steer while the hollow outcome still climbs the no-progress counter.- outcome = "hollow"- elif parsed is not None:- outcome = "hollow"- parsed = None- else:- outcome = "timeout" if time.monotonic() - started >= timeout_seconds else "error"except Exception:parsed = Noneoutcome = "error"+ else:+ outcome = _scout_act_observe_capture_outcome(parsed, started=started, timeout_seconds=timeout_seconds)+ if outcome == "hollow" and parsed is not None:+ first_hollow = parsed+ remaining_seconds = timeout_seconds - (time.monotonic() - started)+ if remaining_seconds <= 0:+ ctx.last_scout_act_observe_recapture_result = "not_attempted_no_budget"+ else:+ ctx.last_scout_act_observe_recapture_attempted = True+ try:+ recaptured = await _composition_get_structured_evidence(+ ctx, inspected_url=url, current_url=url, timeout_seconds=remaining_seconds+ )+ except Exception:+ parsed = first_hollow+ outcome = "hollow"+ ctx.last_scout_act_observe_recapture_result = (+ "timeout" if time.monotonic() - started >= timeout_seconds else "error"+ )+ else:+ if recaptured is None:+ parsed = first_hollow+ outcome = "hollow"+ ctx.last_scout_act_observe_recapture_result = _scout_act_observe_no_payload_result(+ started=started, timeout_seconds=timeout_seconds+ )+ else:+ recaptured_outcome = _scout_act_observe_capture_outcome(+ recaptured, started=started, timeout_seconds=timeout_seconds+ )+ parsed = recaptured+ outcome = recaptured_outcome+ ctx.last_scout_act_observe_recapture_result = recaptured_outcomectx.last_scout_act_observe_outcome = outcomectx.last_scout_act_observe_packet = parsedLOG.info(@@ -405,6 +443,8 @@ async def _scout_act_observe_page_evidence(ctx: AgentContext, *, url: str) -> dioutcome=outcome,duration_ms=int((time.monotonic() - started) * 1000),url=url,+ recapture_attempted=ctx.last_scout_act_observe_recapture_attempted,+ recapture_result=ctx.last_scout_act_observe_recapture_result,)return parsed@@ -438,6 +478,19 @@ async def _register_scout_interaction_observation(# The schema is already attached; leaving the marker set would let a# later evaluate/inspect mint a second interaction credit for one click._clear_pending_browser_interaction_observation(ctx)+ elif parsed is not None and ctx.last_scout_act_observe_outcome == "hollow":+ record_build_test_outcome(+ ctx,+ recorded_outcome_from_scout_act_observe_hollow(+ interaction_tool=tool_name,+ selector=selector,+ current_url=url,+ source_url=source_url,+ page_evidence=parsed,+ recapture_attempted=ctx.last_scout_act_observe_recapture_attempted,+ recapture_result=ctx.last_scout_act_observe_recapture_result,+ ),+ )step = _append_flow_evidence(ctx, evidence, reached_via="interaction")return step, page_evidencediff --git a/skyvern/forge/sdk/copilot/tools/workflow_update.py b/skyvern/forge/sdk/copilot/tools/workflow_update.pyindex ddcde437c..14fbcb510 100644--- a/skyvern/forge/sdk/copilot/tools/workflow_update.py+++ b/skyvern/forge/sdk/copilot/tools/workflow_update.py@@ -1282,6 +1282,17 @@ def _metadata_output_path_roots(raw_metadata: object) -> list[str]:def _metadata_output_path_roots_by_label(raw_metadata: object) -> dict[str, list[str]]:roots_by_label: dict[str, set[str]] = {}+ for label, paths in _metadata_output_paths_by_label(raw_metadata).items():+ roots = roots_by_label.setdefault(label, set())+ for path in paths:+ root = _top_level_path_segment(path)+ if root:+ roots.add(root)+ return {label: sorted(roots) for label, roots in sorted(roots_by_label.items()) if roots}+++def _metadata_output_paths_by_label(raw_metadata: object) -> dict[str, list[str]]:+ paths_by_label: dict[str, set[str]] = {}unlabeled_index = 0for raw_item in _code_artifact_metadata_items(raw_metadata):item = _raw_metadata_item_mapping(raw_item)@@ -1291,23 +1302,30 @@ def _metadata_output_path_roots_by_label(raw_metadata: object) -> dict[str, listif not label:unlabeled_index += 1label = f"<unlabeled:{unlabeled_index}>"- roots = roots_by_label.setdefault(label, set())- roots.update(_metadata_item_output_path_roots(item))- return {label: sorted(roots) for label, roots in sorted(roots_by_label.items()) if roots}+ paths = paths_by_label.setdefault(label, set())+ paths.update(_metadata_item_output_paths(item))+ return {label: sorted(paths) for label, paths in sorted(paths_by_label.items()) if paths}def _metadata_item_output_path_roots(item: Mapping[str, Any]) -> set[str]:roots: set[str] = set()+ for path in _metadata_item_output_paths(item):+ root = _top_level_path_segment(path)+ if root:+ roots.add(root)+ return roots+++def _metadata_item_output_paths(item: Mapping[str, Any]) -> set[str]:+ """Return declared output paths plus schema property roots used for static root matching."""+ paths: set[str] = set()for field_name in ("claimed_outcomes", "terminal_verifier_expectations"):for row in _artifact_rows(item.get(field_name)):- for path in _artifact_string_list(row.get("goal_value_paths")):- root = path.split(".", 1)[0].split("[", 1)[0].strip()- if root:- roots.add(root)+ paths.update(_artifact_goal_value_paths(row.get("goal_value_paths")))schema = _parse_extraction_schema(row.get("extraction_schema"))if schema is not None:- roots.update(_schema_property_roots(schema))- return roots+ paths.update(_schema_property_roots(schema))+ return pathsdef _metadata_reject_code_block_output_status(@@ -1404,16 +1422,16 @@ def _recorded_outcome_requires_output_candidate(ctx: AgentContext) -> bool:return not verification.is_fully_satisfied()-def _recorded_outcome_missing_output_roots(ctx: AgentContext) -> set[str]:+def _recorded_outcome_missing_output_paths(ctx: AgentContext) -> set[str]:latest = ctx.latest_recorded_build_test_outcome- roots: set[str] = set()+ paths: set[str] = set()if isinstance(latest, RecordedBuildTestOutcome) and latest.reason_code == "outcome_not_demonstrated":for fact in latest.missing_requested_output_facts:- root = str(fact.get("output_root") or "").strip()- if root:- roots.add(root)- if roots:- return roots+ path = str(fact.get("output_path") or fact.get("output_root") or "").strip()+ if path:+ paths.add(path)+ if paths:+ return pathsverification = getattr(ctx, "completion_verification_result", None)if verification is None or getattr(verification, "status", None) != "evaluated":return set()@@ -1421,37 +1439,39 @@ def _recorded_outcome_missing_output_roots(ctx: AgentContext) -> set[str]:if getattr(verdict, "satisfied", False):continueoutput_path = str(getattr(verdict, "output_path", "") or "").strip()- root = output_path.split(".", 1)[0].split("[", 1)[0].strip()- if root:- roots.add(root)- return roots+ if output_path:+ paths.add(output_path)+ return paths-def _candidate_missing_required_output_roots(+def _candidate_missing_required_output_paths(workflow_yaml: str,code_artifact_metadata: object,*,- required_roots: set[str],+ required_paths: set[str],) -> list[str]:- if not required_roots:+ if not required_paths:return []- declared_roots_by_label = {- label: set(roots) for label, roots in _metadata_output_path_roots_by_label(code_artifact_metadata).items()+ required_paths = {path for path in (str(item).strip() for item in required_paths) if path}+ declared_paths_by_label = {+ label: set(paths) for label, paths in _metadata_output_paths_by_label(code_artifact_metadata).items()}produced_by_label = _workflow_yaml_produced_output_roots_by_label(workflow_yaml)- covered_roots: set[str] = set()- abstained_declared_roots: set[str] = set()- for label, declared_roots in declared_roots_by_label.items():+ covered_paths: set[str] = set()+ abstained_declared_paths: set[str] = set()+ for label, declared_paths in declared_paths_by_label.items():produced = produced_by_label.get(label)if produced is None:continue- covered_roots.update(declared_roots & produced.roots)+ for required_path in required_paths & declared_paths:+ if _top_level_path_segment(required_path) in produced.roots:+ covered_paths.add(required_path)if produced.abstained:- abstained_declared_roots.update(declared_roots)- missing_roots = required_roots - covered_roots- if missing_roots:- missing_roots -= abstained_declared_roots- return sorted(missing_roots)+ abstained_declared_paths.update(required_paths & declared_paths)+ missing_paths = required_paths - covered_paths+ if missing_paths:+ missing_paths -= abstained_declared_paths+ return sorted(missing_paths)class _ProducedOutputRoots(NamedTuple):@@ -5250,15 +5270,15 @@ async def _update_workflow(data=_code_repair_progress_data(),)- recorded_output_roots_required = _recorded_outcome_requires_output_candidate(ctx)- recorded_missing_output_roots = (- _recorded_outcome_missing_output_roots(ctx) if recorded_output_roots_required else set()+ recorded_output_paths_required = _recorded_outcome_requires_output_candidate(ctx)+ recorded_missing_output_paths = (+ _recorded_outcome_missing_output_paths(ctx) if recorded_output_paths_required else set())- unresolved_recorded_output_roots = recorded_missing_output_roots+ unresolved_recorded_output_paths = recorded_missing_output_pathsoutput_empty_labels = (_output_empty_code_block_labels(workflow_yaml, getattr(ctx, "code_artifact_metadata", None))- if recorded_output_roots_required and (not recorded_missing_output_roots or unresolved_recorded_output_roots)+ if recorded_output_paths_required and (not recorded_missing_output_paths or unresolved_recorded_output_paths)else [])if output_empty_labels:@@ -5289,28 +5309,35 @@ async def _update_workflow(data=_code_repair_progress_data(),)- missing_output_roots = (- _candidate_missing_required_output_roots(+ missing_output_paths = (+ _candidate_missing_required_output_paths(workflow_yaml,getattr(ctx, "code_artifact_metadata", None),- required_roots=unresolved_recorded_output_roots,+ required_paths=unresolved_recorded_output_paths,)- if recorded_output_roots_required+ if recorded_output_paths_requiredelse [])- if missing_output_roots:+ if missing_output_paths:authored_structure_signature = authored_structure_signature_from_workflow(workflow_yaml,getattr(ctx, "code_artifact_metadata", None),)block_labels = sorted(_workflow_yaml_code_blocks_by_label(workflow_yaml))+ missing_output_roots = sorted(+ {root for path in missing_output_paths if (root := _top_level_path_segment(path))}+ )_record_author_time_reject_outcome(ctx,reason_code="metadata_reject",- summary="Submitted workflow does not cover the missing requested output roots from the last recorded test outcome.",+ summary=(+ "Submitted workflow does not cover the missing requested output paths "+ "from the last recorded test outcome."+ ),structural_payload={"reason_code": "recorded_outcome_missing_output_coverage","authored_structure_signature": authored_structure_signature,+ "missing_output_paths": missing_output_paths,"missing_output_roots": missing_output_roots,"block_labels": block_labels,"recorded_reason_code": "outcome_not_demonstrated",@@ -5319,19 +5346,21 @@ async def _update_workflow(block_labels=block_labels,missing_requested_output_facts=[{- "output_path": root,- "output_root": root,+ "output_path": path,+ "output_root": _top_level_path_segment(path),"reason_code": "recorded_outcome_missing_output_coverage","value_status": "no_typed_value",}- for root in missing_output_roots+ for path in missing_output_paths],)_record_code_authoring_guardrail_reject(ctx)+ missing_path_text = ", ".join(missing_output_paths[:8])return reject(error=(- "Submitted workflow does not cover the missing requested output roots from the last recorded test "- "outcome. Declare and produce structured output for those roots before testing again."+ "Submitted workflow does not cover the missing requested output paths from the last recorded test "+ f"outcome: {missing_path_text}. Declare those exact output_path values in goal_value_paths and "+ "produce matching structured output before testing again; output_root is diagnostic only."),user_facing_summary=_compiled_authoring_user_summary(),data=_code_repair_progress_data(),diff --git a/tests/unit/test_copilot_agent_helpers.py b/tests/unit/test_copilot_agent_helpers.pyindex 859e14734..6893fc622 100644--- a/tests/unit/test_copilot_agent_helpers.py+++ b/tests/unit/test_copilot_agent_helpers.py@@ -910,6 +910,33 @@ workflow_definition:assert "page_evidence_refs: form:Search #search, result:#results rows=unknown" in promptassert "Do not re-emit the same plan against the same structural key" in prompt+ def test_recorded_build_test_outcome_prompt_renders_exact_missing_output_paths(self) -> None:+ ctx = _ctx(+ block_authoring_policy=BlockAuthoringPolicy.CODE_ONLY_BROWSER,+ latest_recorded_build_test_outcome=RecordedBuildTestOutcome(+ phase="persisted_block_run",+ attempted_tool="update_and_run_blocks",+ verdict="repairable_failure",+ reason_code="outcome_not_demonstrated",+ structural_failure_identity="completion:unsatisfied-output",+ missing_requested_output_facts=[+ {+ "output_path": "output.confirmation_number",+ "output_root": "output",+ "value_status": "no_typed_value",+ "reason_code": "no_evidence",+ }+ ],+ ),+ )++ prompt = agent_module._recorded_build_test_outcome_prompt(ctx)++ assert "output_path=output.confirmation_number" in prompt+ assert "output_root=output" in prompt+ assert "Use the exact output_path values in goal_value_paths and returned output" in prompt+ assert "output_root is diagnostic grouping only" in prompt+class TestVerifiedWorkflowOrNone:"""SKY-9143 strict invariant: a proposal surfaces only after a passing test this turn."""diff --git a/tests/unit/test_copilot_build_test_outcome.py b/tests/unit/test_copilot_build_test_outcome.pyindex b95178b9e..ca2a485ff 100644--- a/tests/unit/test_copilot_build_test_outcome.py+++ b/tests/unit/test_copilot_build_test_outcome.py@@ -5,11 +5,13 @@ from types import SimpleNamespacefrom skyvern.forge.sdk.copilot.build_test_outcome import (RecordedBuildTestOutcome,authored_structure_signature_from_workflow,+ latest_recorded_build_test_outcome_repeated,record_build_test_outcome,recorded_outcome_from_author_time_reject,recorded_outcome_from_authoring_repair_context,recorded_outcome_from_loaded_result_evidence,recorded_outcome_from_run_blocks_result,+ recorded_outcome_from_scout_act_observe_hollow,)from skyvern.forge.sdk.copilot.code_block_preflight import SANDBOX_UNRESOLVED_NAME_REASON_CODEfrom skyvern.forge.sdk.copilot.completion_verification import CompletionVerificationResult, CriterionVerdict@@ -111,6 +113,39 @@ def test_structural_key_does_not_require_fixture_slug_or_raw_transcript_text() -assert "synthetic transcript excerpt" not in str(key_payload)+def test_scout_act_observe_hollow_outcome_is_structural_and_privacy_bounded() -> None:+ outcome = recorded_outcome_from_scout_act_observe_hollow(+ interaction_tool="click",+ selector="#search",+ current_url="https://example.com/customers/acme-inc/results?token=secret",+ source_url="https://example.com/accounts/claim-123/search?name=customer",+ page_evidence={+ "page_title": "Private Account Search",+ "forms": [],+ "navigation_targets": [],+ "result_containers": [],+ "clickable_controls": [],+ "visible_text": "Customer name should not persist",+ "body": "<main></main>",+ "schema_empty_page": True,+ },+ recapture_attempted=True,+ recapture_result="timeout",+ )++ dumped = outcome.model_dump(mode="json")+ key_payload = outcome.structural_key_payload++ assert outcome.reason_code == "scout_act_observe_hollow_after_interaction"+ assert outcome.structural_key is not None+ assert outcome.is_authoritative is True+ assert "recapture_attempted:true" in outcome.page_evidence_refs+ assert "recapture_result:timeout" in outcome.page_evidence_refs+ for sensitive in ("token=secret", "name=customer", "acme-inc", "claim-123", "Customer name", "Private Account"):+ assert sensitive not in str(dumped)+ assert sensitive not in str(key_payload)++def test_prose_or_label_only_typed_outcome_is_not_authoritative() -> None:outcome = RecordedBuildTestOutcome(phase="author_time_reject",@@ -146,6 +181,51 @@ def test_record_none_clears_stale_latest_outcome() -> None:assert ctx.latest_recorded_build_test_outcome is None+def test_repeated_outcome_ignores_intervening_scout_evaluate_history() -> None:+ ctx = SimpleNamespace(latest_recorded_build_test_outcome=None, recorded_build_test_outcome_history=[])+ author_reject = RecordedBuildTestOutcome(+ phase="author_time_reject",+ verdict="authoring_rejected",+ reason_code="metadata_reject",+ structural_failure_identity="author:missing-output",+ )+ scout_hollow = RecordedBuildTestOutcome(+ phase="scout_evaluate",+ verdict="repairable_failure",+ reason_code="scout_act_observe_hollow_after_interaction",+ structural_failure_identity="scout:hollow",+ )++ record_build_test_outcome(ctx, author_reject)+ record_build_test_outcome(ctx, scout_hollow)+ record_build_test_outcome(ctx, author_reject)++ assert latest_recorded_build_test_outcome_repeated(ctx) is True+++def test_repeated_outcome_still_detects_different_author_reject_after_scout_evaluate() -> None:+ ctx = SimpleNamespace(latest_recorded_build_test_outcome=None, recorded_build_test_outcome_history=[])+ first_reject = RecordedBuildTestOutcome(+ phase="author_time_reject",+ verdict="authoring_rejected",+ reason_code="metadata_reject",+ structural_failure_identity="author:missing-output",+ )+ scout_hollow = RecordedBuildTestOutcome(+ phase="scout_evaluate",+ verdict="repairable_failure",+ reason_code="scout_act_observe_hollow_after_interaction",+ structural_failure_identity="scout:hollow",+ )+ second_reject = first_reject.model_copy(update={"structural_failure_identity": "author:different-output"})++ record_build_test_outcome(ctx, first_reject)+ record_build_test_outcome(ctx, scout_hollow)+ record_build_test_outcome(ctx, second_reject)++ assert latest_recorded_build_test_outcome_repeated(ctx) is False++def test_authored_structure_signature_is_stable_and_excludes_raw_code_or_prose() -> None:workflow_yaml = """title: Registry lookup@@ -466,6 +546,8 @@ def test_outcome_not_demonstrated_keeps_missing_fact_for_absent_requested_output"grounding_mode": "missing",}]+ assert outcome.structural_key_payload is not None+ assert "output.top_post" in str(outcome.structural_key_payload)def test_authoring_repair_context_produces_structural_recorded_outcome() -> None:diff --git a/tests/unit/test_copilot_code_block_persist_seam.py b/tests/unit/test_copilot_code_block_persist_seam.pyindex 95f98d213..e4d62d85e 100644--- a/tests/unit/test_copilot_code_block_persist_seam.py+++ b/tests/unit/test_copilot_code_block_persist_seam.py@@ -1477,12 +1477,123 @@ class TestCodeRepairProgressClassification:result = await _update_workflow({"workflow_yaml": partial_yaml}, ctx, allow_missing_credentials=True)assert result["ok"] is False- assert "does not cover the missing requested output roots" in result["error"]+ assert "does not cover the missing requested output paths" in result["error"]assert ctx.has_staged_proposal is Falseassert ctx.latest_recorded_build_test_outcome is not Noneassert ctx.latest_recorded_build_test_outcome.reason_code == "metadata_reject"assert ctx.latest_recorded_build_test_outcome.is_authoritative is True+ @pytest.mark.asyncio+ async def test_authoritative_outcome_not_demonstrated_accepts_canonical_output_path_candidate_with_sibling(+ self, monkeypatch: pytest.MonkeyPatch+ ) -> None:+ _stub_successful_update(monkeypatch)+ ctx = _code_only_ctx()+ label = "submit_form_and_extract_confirmation"+ ctx.code_artifact_metadata = {+ label: {+ "block_label": label,+ "claimed_outcomes": [{"goal_value_paths": ["output.confirmation_number"]}],+ "terminal_verifier_expectations": [{"goal_value_paths": ["output.confirmation_number"]}],+ }+ }+ ctx.workflow_verification_evidence.code_artifact_metadata = dict(ctx.code_artifact_metadata)+ ctx.latest_recorded_build_test_outcome = RecordedBuildTestOutcome(+ phase="persisted_block_run",+ attempted_tool="update_and_run_blocks",+ verdict="repairable_failure",+ reason_code="outcome_not_demonstrated",+ structural_failure_identity="completion:unsatisfied-output",+ authored_structure_signature="authored:previous-failed-candidate",+ missing_requested_output_facts=[+ {+ "output_path": "output.confirmation_number",+ "output_root": "output",+ "value_status": "no_typed_value",+ },+ ],+ )+ candidate_yaml = _yaml(+ f"""+ title: Form submission+ workflow_definition:+ blocks:+ - block_type: code+ label: {label}+ code: |+ return {{"output": {{"confirmation_number": "ABC-123", "account_number": "100245"}}}}+ """+ )++ result = await _update_workflow({"workflow_yaml": candidate_yaml}, ctx, allow_missing_credentials=True)++ assert result["ok"] is True+ assert ctx.workflow_yaml == candidate_yaml+ assert ctx.latest_recorded_build_test_outcome is not None+ assert ctx.latest_recorded_build_test_outcome.reason_code == "outcome_not_demonstrated"++ @pytest.mark.asyncio+ async def test_authoritative_outcome_not_demonstrated_rejects_flat_candidate_for_canonical_output_path(+ self, monkeypatch: pytest.MonkeyPatch+ ) -> None:+ _stub_successful_update(monkeypatch)+ ctx = _code_only_ctx()+ label = "submit_form_and_extract_confirmation"+ ctx.code_artifact_metadata = {+ label: {+ "block_label": label,+ "claimed_outcomes": [{"goal_value_paths": ["confirmation_number"]}],+ "terminal_verifier_expectations": [{"goal_value_paths": ["confirmation_number"]}],+ }+ }+ ctx.workflow_verification_evidence.code_artifact_metadata = dict(ctx.code_artifact_metadata)+ ctx.latest_recorded_build_test_outcome = RecordedBuildTestOutcome(+ phase="persisted_block_run",+ attempted_tool="update_and_run_blocks",+ verdict="repairable_failure",+ reason_code="outcome_not_demonstrated",+ structural_failure_identity="completion:unsatisfied-output",+ authored_structure_signature="authored:previous-failed-candidate",+ missing_requested_output_facts=[+ {+ "output_path": "output.confirmation_number",+ "output_root": "output",+ "value_status": "no_typed_value",+ },+ ],+ )+ candidate_yaml = _yaml(+ f"""+ title: Form submission+ workflow_definition:+ blocks:+ - block_type: code+ label: {label}+ code: |+ return {{"confirmation_number": "ABC-123"}}+ """+ )++ result = await _update_workflow({"workflow_yaml": candidate_yaml}, ctx, allow_missing_credentials=True)++ assert result["ok"] is False+ assert "output.confirmation_number" in result["error"]+ assert "Declare those exact output_path values" in result["error"]+ assert "output_root is diagnostic only" in result["error"]+ outcome = ctx.latest_recorded_build_test_outcome+ assert outcome is not None+ assert outcome.reason_code == "metadata_reject"+ assert outcome.missing_requested_output_facts == [+ {+ "output_path": "output.confirmation_number",+ "output_root": "output",+ "reason_code": "recorded_outcome_missing_output_coverage",+ "value_status": "no_typed_value",+ }+ ]+ rendered = agent_module._recorded_build_test_outcome_prompt(ctx)+ assert "output_path=output.confirmation_number" in rendered+def test_required_output_roots_ignore_nested_debug_output_root_without_declared_root(self) -> None:label = "extract_provider_profile"metadata = {label: {"block_label": label, "claimed_outcomes": [{"goal_value_paths": ["debug_output"]}]}}@@ -1498,10 +1609,10 @@ class TestCodeRepairProgressClassification:""")- assert workflow_update_module._candidate_missing_required_output_roots(+ assert workflow_update_module._candidate_missing_required_output_paths(candidate_yaml,metadata,- required_roots={"npi"},+ required_paths={"npi"},) == ["npi"]def test_required_output_roots_ignore_same_label_undeclared_static_root(self) -> None:@@ -1519,10 +1630,10 @@ class TestCodeRepairProgressClassification:""")- assert workflow_update_module._candidate_missing_required_output_roots(+ assert workflow_update_module._candidate_missing_required_output_paths(candidate_yaml,metadata,- required_roots={"npi"},+ required_paths={"npi"},) == ["npi"]def test_required_output_roots_ignore_static_root_without_label_metadata(self) -> None:@@ -1539,10 +1650,10 @@ class TestCodeRepairProgressClassification:""")- assert workflow_update_module._candidate_missing_required_output_roots(+ assert workflow_update_module._candidate_missing_required_output_paths(candidate_yaml,{},- required_roots={"npi"},+ required_paths={"npi"},) == ["npi"]def test_required_output_roots_accept_same_label_declared_static_root(self) -> None:@@ -1561,10 +1672,10 @@ class TestCodeRepairProgressClassification:)assert (- workflow_update_module._candidate_missing_required_output_roots(+ workflow_update_module._candidate_missing_required_output_paths(candidate_yaml,metadata,- required_roots={"npi"},+ required_paths={"npi"},)== [])@@ -1938,7 +2049,7 @@ class TestCodeRepairProgressClassification:result = await _update_workflow({"workflow_yaml": candidate_yaml}, ctx, allow_missing_credentials=True)assert result["ok"] is False- assert "does not cover the missing requested output roots" in result["error"]+ assert "does not cover the missing requested output paths" in result["error"]outcome = ctx.latest_recorded_build_test_outcomeassert outcome is not Noneassert outcome.reason_code == "metadata_reject"@@ -2000,7 +2111,7 @@ class TestCodeRepairProgressClassification:result = await _update_workflow({"workflow_yaml": candidate_yaml}, ctx, allow_missing_credentials=True)assert result["ok"] is False- assert "does not cover the missing requested output roots" in result["error"]+ assert "does not cover the missing requested output paths" in result["error"]outcome = ctx.latest_recorded_build_test_outcomeassert outcome is not Noneassert outcome.reason_code == "metadata_reject"@@ -2058,7 +2169,7 @@ class TestCodeRepairProgressClassification:result = await _update_workflow({"workflow_yaml": candidate_yaml}, ctx, allow_missing_credentials=True)assert result["ok"] is False- assert "does not cover the missing requested output roots" in result["error"]+ assert "does not cover the missing requested output paths" in result["error"]outcome = ctx.latest_recorded_build_test_outcomeassert outcome is not Noneassert outcome.reason_code == "metadata_reject"@@ -2112,7 +2223,7 @@ class TestCodeRepairProgressClassification:result = await _update_workflow({"workflow_yaml": candidate_yaml}, ctx, allow_missing_credentials=True)assert result["ok"] is False- assert "does not cover the missing requested output roots" in result["error"]+ assert "does not cover the missing requested output paths" in result["error"]outcome = ctx.latest_recorded_build_test_outcomeassert outcome is not Noneassert outcome.reason_code == "metadata_reject"@@ -2222,7 +2333,7 @@ class TestCodeRepairProgressClassification:result = await _update_workflow({"workflow_yaml": candidate_yaml}, ctx, allow_missing_credentials=True)assert result["ok"] is False- assert "does not cover the missing requested output roots" in result["error"]+ assert "does not cover the missing requested output paths" in result["error"]outcome = ctx.latest_recorded_build_test_outcomeassert outcome is not Noneassert outcome.reason_code == "metadata_reject"@@ -2385,7 +2496,7 @@ class TestCodeRepairProgressClassification:result = await _update_workflow({"workflow_yaml": candidate_yaml}, ctx, allow_missing_credentials=True)assert result["ok"] is False- assert "does not cover the missing requested output roots" in result["error"]+ assert "does not cover the missing requested output paths" in result["error"]outcome = ctx.latest_recorded_build_test_outcomeassert outcome is not Noneassert outcome.reason_code == "metadata_reject"diff --git a/tests/unit/test_copilot_enforcement_pruning.py b/tests/unit/test_copilot_enforcement_pruning.pyindex 5e06b5c05..d71955100 100644--- a/tests/unit/test_copilot_enforcement_pruning.py+++ b/tests/unit/test_copilot_enforcement_pruning.py@@ -21,7 +21,7 @@ from skyvern.forge.sdk.copilot.build_test_outcome import RecordedBuildTestOutcomfrom skyvern.forge.sdk.copilot.code_block_synthesis import SynthesizedCodeBlockfrom skyvern.forge.sdk.copilot.completion_verification import CompletionVerificationResult, CriterionVerdictfrom skyvern.forge.sdk.copilot.config import SYNTHESIZED_OFFER_REFRESH_STEP_THRESHOLD, BlockAuthoringPolicy-from skyvern.forge.sdk.copilot.context import CopilotContext+from skyvern.forge.sdk.copilot.context import CodeAuthoringRepairContext, CopilotContextfrom skyvern.forge.sdk.copilot.enforcement import (KEEP_RECENT_TOOL_OUTPUTS,POST_SUSPICIOUS_SUCCESS_NUDGE,@@ -295,6 +295,74 @@ class TestSynthesizedOfferPersistenceGate:assert signal.cleared_by_tools == frozenset({"update_and_run_blocks"})assert signal.renders_final_reply is False+ def test_prerun_ambiguous_bare_selector_repair_allows_one_evaluate(self) -> None:+ ctx = _Ctx()+ ctx.turn_intent = TurnIntent(+ mode=TurnIntentMode.BUILD,+ authority=TurnIntentAuthority(may_update_workflow=True, may_run_blocks=True),+ )+ ctx.block_authoring_policy = BlockAuthoringPolicy.CODE_ONLY_BROWSER+ ctx.synthesized_block_offered = True+ ctx.synthesized_block_offered_trajectory_len = 1+ ctx.synthesized_block_offered_goal_complete = True+ ctx.scout_trajectory = [{"tool_name": "click", "selector": "button"}]+ ctx.last_code_authoring_repair_context = CodeAuthoringRepairContext(+ block_label="lookup",+ reason_code="ambiguous_bare_selector",+ selector="button",+ source_url="https://example.com",+ )++ assert synthesized_block_persistence_signal(ctx, "evaluate") is None++ def test_repeated_ambiguous_bare_selector_context_blocks_second_evaluate(self) -> None:+ ctx = _Ctx()+ ctx.turn_intent = TurnIntent(+ mode=TurnIntentMode.BUILD,+ authority=TurnIntentAuthority(may_update_workflow=True, may_run_blocks=True),+ )+ ctx.block_authoring_policy = BlockAuthoringPolicy.CODE_ONLY_BROWSER+ ctx.synthesized_block_offered = True+ ctx.synthesized_block_offered_trajectory_len = 1+ ctx.synthesized_block_offered_goal_complete = True+ ctx.scout_trajectory = [{"tool_name": "click", "selector": "button"}]+ ctx.last_code_authoring_repair_context = CodeAuthoringRepairContext(+ block_label="lookup",+ reason_code="ambiguous_bare_selector",+ selector="button",+ source_url="https://example.com",+ )++ assert synthesized_block_persistence_signal(ctx, "evaluate") is None+ signal = synthesized_block_persistence_signal(ctx, "evaluate")++ assert isinstance(signal, CopilotToolBlockerSignal)+ assert signal.internal_reason_code == SYNTHESIZED_BLOCK_PERSISTENCE_REASON_CODE++ def test_ambiguous_bare_selector_with_stable_alternative_still_requires_persistence(self) -> None:+ ctx = _Ctx()+ ctx.turn_intent = TurnIntent(+ mode=TurnIntentMode.BUILD,+ authority=TurnIntentAuthority(may_update_workflow=True, may_run_blocks=True),+ )+ ctx.block_authoring_policy = BlockAuthoringPolicy.CODE_ONLY_BROWSER+ ctx.synthesized_block_offered = True+ ctx.synthesized_block_offered_trajectory_len = 1+ ctx.synthesized_block_offered_goal_complete = True+ ctx.scout_trajectory = [{"tool_name": "click", "selector": "button"}]+ ctx.last_code_authoring_repair_context = CodeAuthoringRepairContext(+ block_label="lookup",+ reason_code="ambiguous_bare_selector",+ selector="button",+ source_url="https://example.com",+ selector_alternatives=[{"tool_name": "click", "selector": 'role=button[name="Search"]'}],+ )++ signal = synthesized_block_persistence_signal(ctx, "evaluate")++ assert isinstance(signal, CopilotToolBlockerSignal)+ assert signal.internal_reason_code == SYNTHESIZED_BLOCK_PERSISTENCE_REASON_CODE+@pytest.mark.parametrize("tool_name",["update_and_run_blocks", "update_workflow", "fill_credential_field"],diff --git a/tests/unit/test_copilot_scout_act_observe.py b/tests/unit/test_copilot_scout_act_observe.pyindex d6afa5cd5..e0b9029d6 100644--- a/tests/unit/test_copilot_scout_act_observe.py+++ b/tests/unit/test_copilot_scout_act_observe.py@@ -26,9 +26,12 @@ from skyvern.forge.sdk.copilot.enforcement import ()from skyvern.forge.sdk.copilot.runtime import AgentContextfrom skyvern.forge.sdk.copilot.tools import _click_post_hook+from skyvern.forge.sdk.copilot.tools import scouting as scouting_modulefrom skyvern.forge.sdk.copilot.tools.scouting import (_consume_pending_browser_interaction_observation,_mark_pending_browser_interaction_observation,+ _register_scout_interaction_observation,+ _scout_act_observe_page_evidence,account_no_progress_interaction_click,)@@ -91,6 +94,27 @@ def _server_returning(payload: dict[str, Any]) -> SimpleNamespace:return server+def _server_returning_sequence(payloads: list[dict[str, Any] | None | BaseException]) -> SimpleNamespace:+ server = SimpleNamespace()+ side_effects = [+ payload if isinstance(payload, BaseException) else {"ok": True, "data": {"result": payload}}+ for payload in payloads+ ]+ server.call_internal_tool = AsyncMock(side_effect=side_effects)+ return server+++def _monotonic_sequence(values: list[float]) -> Any:+ calls = {"n": 0}++ def fake() -> float:+ index = calls["n"]+ calls["n"] += 1+ return values[index] if index < len(values) else values[-1]++ return fake++async def _run_click(ctx: SimpleNamespace) -> dict[str, Any]:return await _click_post_hook({"ok": True, "data": {"selector": "#open-details"}},@@ -152,6 +176,106 @@ class TestActObserveSuccess:class TestActObserveDegrade:+ @pytest.mark.asyncio+ async def test_first_hollow_then_bounded_recapture_attaches_schema(self) -> None:+ ctx = _ctx(+ server=_server_returning_sequence([{"page_title": "Loading", "forms": []}, _bounded_extractor_payload()])+ )++ result = await _run_click(ctx)++ assert ctx.last_scout_act_observe_outcome == "attached"+ assert result["ok"] is True+ assert "page" in result["data"]+ assert ctx.flow_evidence[0]["had_bounded_schema"] is True+ assert ctx.flow_evidence[0]["evidence"]["forms"][0]["fields"][0]["label"] == "NPI number"+ assert not hasattr(ctx, "latest_recorded_build_test_outcome")++ @pytest.mark.asyncio+ async def test_persistent_post_interaction_hollow_records_build_test_outcome(self) -> None:+ payload = {"page_title": "Loading", "forms": [], "body": "<main></main>", "visible_text": "Still loading"}+ ctx = _ctx(+ server=_server_returning_sequence([payload, payload]), source_url="https://example.com/path?secret=1"+ )++ result = await _run_click(ctx)++ outcome = ctx.latest_recorded_build_test_outcome+ assert ctx.last_scout_act_observe_outcome == "hollow"+ assert result["ok"] is True+ assert "page" not in result["data"]+ assert ctx.flow_evidence[0]["had_bounded_schema"] is False+ assert outcome.reason_code == "scout_act_observe_hollow_after_interaction"+ assert outcome.verdict == "repairable_failure"+ assert outcome.is_authoritative is True+ assert outcome.attempted_tool == "scout_interaction"+ assert outcome.attempted_target == "#open-details"+ assert "secret" not in str(outcome.structural_key_payload)+ assert "recapture_attempted:true" in outcome.page_evidence_refs+ assert "recapture_result:hollow" in outcome.page_evidence_refs+ assert ctx.recorded_build_test_outcome_history[-1]["reason_code"] == outcome.reason_code++ @pytest.mark.asyncio+ async def test_first_hollow_with_no_recapture_budget_records_outcome(self, monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.setattr(settings, "COPILOT_SCOUT_ACT_OBSERVE_TIMEOUT_SECONDS", 1.0)+ monkeypatch.setattr(scouting_module.time, "monotonic", _monotonic_sequence([0.0, 2.0, 2.0]))+ payload = {"page_title": "Loading", "forms": [], "body": "<main></main>"}+ ctx = _ctx(server=_server_returning_sequence([payload]))++ result = await _run_click(ctx)++ outcome = ctx.latest_recorded_build_test_outcome+ assert result["ok"] is True+ assert ctx.last_scout_act_observe_outcome == "hollow"+ assert ctx.flow_evidence[0]["had_bounded_schema"] is False+ assert outcome.reason_code == "scout_act_observe_hollow_after_interaction"+ assert outcome.is_authoritative is True+ assert "recapture_attempted:false" in outcome.page_evidence_refs+ assert "recapture_result:not_attempted_no_budget" in outcome.page_evidence_refs++ @pytest.mark.asyncio+ async def test_first_hollow_with_recapture_none_records_outcome(self) -> None:+ payload = {"page_title": "Loading", "forms": [], "body": "<main></main>"}+ ctx = _ctx(server=_server_returning_sequence([payload, None]))++ result = await _run_click(ctx)++ outcome = ctx.latest_recorded_build_test_outcome+ assert result["ok"] is True+ assert ctx.last_scout_act_observe_outcome == "hollow"+ assert ctx.flow_evidence[0]["had_bounded_schema"] is False+ assert outcome.reason_code == "scout_act_observe_hollow_after_interaction"+ assert outcome.is_authoritative is True+ assert "recapture_attempted:true" in outcome.page_evidence_refs+ assert "recapture_result:no_payload" in outcome.page_evidence_refs++ @pytest.mark.asyncio+ async def test_first_hollow_with_recapture_error_records_outcome(self, monkeypatch: pytest.MonkeyPatch) -> None:+ payload = {"page_title": "Loading", "forms": [], "body": "<main></main>"}+ calls = {"n": 0}++ async def fake_extract(+ _ctx: Any, *, inspected_url: str, current_url: str, timeout_seconds: float+ ) -> dict[str, Any] | None:+ calls["n"] += 1+ if calls["n"] == 1:+ return payload+ raise RuntimeError("browser gone")++ monkeypatch.setattr(scouting_module, "_composition_get_structured_evidence", fake_extract)+ ctx = _ctx(server=SimpleNamespace())++ result = await _run_click(ctx)++ outcome = ctx.latest_recorded_build_test_outcome+ assert result["ok"] is True+ assert ctx.last_scout_act_observe_outcome == "hollow"+ assert ctx.flow_evidence[0]["had_bounded_schema"] is False+ assert outcome.reason_code == "scout_act_observe_hollow_after_interaction"+ assert outcome.is_authoritative is True+ assert "recapture_attempted:true" in outcome.page_evidence_refs+ assert "recapture_result:error" in outcome.page_evidence_refs+@pytest.mark.asyncioasync def test_timeout_degrades_to_schema_less_packet_and_keeps_marker(self, monkeypatch: pytest.MonkeyPatch@@ -183,6 +307,7 @@ class TestActObserveDegrade:assert ctx.pending_browser_interaction_observation is not Noneassert ctx.pending_browser_interaction_observation.tool_name == "click"assert ctx.pending_browser_interaction_observation.url == _LANDING_URL+ assert not hasattr(ctx, "latest_recorded_build_test_outcome")@pytest.mark.asyncioasync def test_hollow_parse_degrades_to_schema_less_packet(self) -> None:@@ -195,6 +320,7 @@ class TestActObserveDegrade:assert ctx.flow_evidence[0]["had_bounded_schema"] is Falseassert set(ctx.flow_evidence[0]["evidence"].keys()) == _SCHEMA_LESS_PACKET_KEYSassert ctx.pending_browser_interaction_observation is not None+ assert ctx.latest_recorded_build_test_outcome.reason_code == "scout_act_observe_hollow_after_interaction"@pytest.mark.asyncioasync def test_extractor_error_never_fails_the_click(self) -> None:@@ -207,6 +333,32 @@ class TestActObserveDegrade:assert result["ok"] is Trueassert "page" not in result["data"]assert ctx.flow_evidence[0]["had_bounded_schema"] is False+ assert not hasattr(ctx, "latest_recorded_build_test_outcome")++ @pytest.mark.asyncio+ async def test_initial_none_without_first_hollow_does_not_record_outcome(self) -> None:+ ctx = _ctx(server=_server_returning_sequence([None]))++ result = await _run_click(ctx)++ assert result["ok"] is True+ assert ctx.flow_evidence[0]["had_bounded_schema"] is False+ assert not hasattr(ctx, "latest_recorded_build_test_outcome")++ @pytest.mark.asyncio+ async def test_hollow_without_interaction_proof_does_not_record_outcome(self) -> None:+ ctx = _ctx(server=_server_returning({"page_title": "Loading", "forms": []}))++ parsed = await _scout_act_observe_page_evidence(ctx, url=_LANDING_URL)+ step, page_evidence = await _register_scout_interaction_observation(+ ctx, tool_name="click", selector="", source_url=_SOURCE_URL, url=_LANDING_URL+ )++ assert parsed is not None+ assert not has_bounded_page_schema(parsed)+ assert step is None+ assert page_evidence is None+ assert not hasattr(ctx, "latest_recorded_build_test_outcome")class TestActObserveNoRace: