#!/usr/bin/env python3
"""Consolidate the predecessor branch-state execution/persistence gap."""
from __future__ import annotations

import argparse
import html
import json
from pathlib import Path
from typing import Any


ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT / "out"
PREDECESSOR_BRANCH_STATE_POLL = "runtime_selected_pointer_predecessor_direction_sweep_branch_state_poll.json"
PREDECESSOR_LEFT_OVERRUN_ACTIVATION_BRANCH_STATE_POLL = (
    "runtime_selected_pointer_predecessor_left_overrun_activation_branch_state_poll.json"
)
PREDECESSOR_NEAREST_EXIT_BRANCH_STATE_POLL = (
    "runtime_selected_pointer_predecessor_nearest_exit_branch_state_poll.json"
)
PREDECESSOR_RECIPROCAL_EXIT_BRANCH_STATE_POLL = (
    "runtime_selected_pointer_predecessor_reciprocal_exit_branch_state_poll.json"
)
PREDECESSOR_COORDINATE_BRANCH_STATE_POLL = (
    "runtime_selected_pointer_predecessor_coordinate_branch_state_poll.json"
)
PREDECESSOR_TRAIL_START_BRANCH_STATE_POLL = (
    "runtime_selected_pointer_predecessor_trail_start_branch_state_poll.json"
)
PREDECESSOR_TRAIL_LEFT_OVERRUN_BRANCH_STATE_POLL = (
    "runtime_selected_pointer_predecessor_trail_left_overrun_branch_state_poll.json"
)
PREDECESSOR_HIGHFREQ_BRANCH_STATE_POLL = (
    "runtime_selected_pointer_predecessor_highfreq_branch_state_poll.json"
)
PREDECESSOR_FILL_STATE_HEXES = ["0x01", "0x01"] + ["0x00"] * 10
BRANCH_STATE_EXECUTION_GATE_EVIDENCE = [
    (
        "fill-execution-order-proof",
        "predecessor fill-site execution/order before the current 0x00542b0c reader",
    ),
    (
        "fill-site-execution-context",
        "fill-site execution context tying public predecessor observation to the fill stream",
    ),
    (
        "normal-route-order",
        "normal route execution order showing selector 1:0 before selector 2:0",
    ),
    (
        "vm-bytecode-reset-scope-ruled-out",
        "VM bytecode/reset path proof before the current reader",
    ),
    (
        "runtime-branch-state-fill-observed",
        "route-relevant runtime branch-state values matching the predecessor fill hypothesis",
    ),
    (
        "selector-merge-closed",
        "closed selector merge between source 0:0, predecessor 1:0, and current 2:0",
    ),
    (
        "strict-source-hotspot",
        "strict map1_01a source coordinate or hotspot",
    ),
]
BRANCH_STATE_EXECUTION_EVIDENCE_REFS = [
    {
        "path": "out/save_selector_predecessor_fill_execution_order_gap.json",
        "fields": [
            "proofFound",
            "failedPredecessorFillOrderGateIds",
            "missingEvidence",
            "predecessorFillProofGateRows",
        ],
    },
    {
        "path": "out/save_selector_predecessor_fill_site_execution_context.json",
        "fields": [
            "proofFound",
            "failedPredecessorFillGateIds",
            "missingEvidence",
            "fillSiteExecutionContextProven",
        ],
    },
    {
        "path": "out/save_selector_secondary_global_reset_gap.json",
        "fields": [
            "globalResetRuledOut",
            "openRuntimeOrderOrBytecodeGap",
            "remainingProofs",
        ],
    },
    {
        "path": "out/save_selector_predecessor_route_order.json",
        "fields": [
            "routeOrderProven",
            "selectorMergeGapOpen",
            "remainingProofs",
        ],
    },
    {
        "path": "out/save_selector_merge_gap.json",
        "fields": [
            "selectorMergeGapOpen",
            "sourceToCurrentBridgeHitCount",
            "targetToCurrentBridgeHitCount",
        ],
    },
    {
        "path": f"out/{PREDECESSOR_BRANCH_STATE_POLL}",
        "fields": [
            "observedSelectors",
            "observedPublicSaveSelectors",
            "observedWatchValues",
            "anyReachedRouteSelectorContext",
        ],
    },
    {
        "path": f"out/{PREDECESSOR_HIGHFREQ_BRANCH_STATE_POLL}",
        "fields": [
            "pollIntervalSeconds",
            "observedSelectors",
            "observedPublicSaveSelectors",
            "observedWatchValues",
            "anyReachedRouteSelectorContext",
        ],
    },
    {
        "path": "out/map1_01a_hotspot_gap.json",
        "fields": [
            "strictHotspotFound",
            "eventTransitionCount",
            "manifestPointPromotableSourceCount",
        ],
    },
]


def bool_text(value: Any) -> str:
    return str(bool(value))


def list_text(values: list[Any] | None) -> str:
    return ",".join(str(value) for value in values or []) or "-"


def watch_value_summary(poll: dict | None) -> str:
    parts = []
    for name, rows in sorted(((poll or {}).get("observedWatchValues") or {}).items()):
        rendered = ",".join(
            f"{row.get('valueHex')}x{row.get('count')}"
            for row in rows or []
            if row.get("valueHex") is not None
        )
        parts.append(f"{name}={rendered or '-'}")
    return "; ".join(parts) or "-"


def stable_watch_hex(poll: dict | None, name: str) -> str | None:
    rows = ((poll or {}).get("observedWatchValues") or {}).get(name) or []
    if len(rows) != 1:
        return None
    return rows[0].get("valueHex")


def stable_secondary_branch_state_hexes(poll: dict | None) -> list[str]:
    values = []
    for index in range(12):
        value = stable_watch_hex(poll, f"secondaryBranchState{index}")
        if value is None:
            return []
        values.append(value)
    return values


def selected_pointer_poll_input_quality(poll: dict | None) -> dict:
    rows = (poll or {}).get("rows") or []
    pressed_offsets = set()
    pressed_event_count = 0
    sequence_with_observed_press = 0
    key_write_ok_count = 0
    sequence_with_key_writes = 0
    for row in rows:
        writes = row.get("writes") or []
        row_write_ok = any((write.get("write") or {}).get("writeOk") is True for write in writes)
        if row_write_ok:
            sequence_with_key_writes += 1
        key_write_ok_count += sum(1 for write in writes if (write.get("write") or {}).get("writeOk") is True)
        row_has_press = False
        for event in row.get("events") or []:
            offsets = event.get("pressedKeyOffsets") or []
            if offsets:
                row_has_press = True
                pressed_event_count += 1
                pressed_offsets.update(offset for offset in offsets if isinstance(offset, int))
        if row_has_press:
            sequence_with_observed_press += 1
    return {
        "sequenceCount": len(rows),
        "sequenceWithPidCount": sum(1 for row in rows if row.get("linuxPid")),
        "sequenceWithLoadedBaseCount": sum(1 for row in rows if row.get("loadedBaseHex")),
        "sequenceWithFocusedWindowCount": sum(1 for row in rows if row.get("focusedWindows")),
        "sequenceWithKeyWritesCount": sequence_with_key_writes,
        "keyWriteOkCount": key_write_ok_count,
        "sequenceWithObservedKeyPressCount": sequence_with_observed_press,
        "pressedEventCount": pressed_event_count,
        "observedPressedKeyOffsets": sorted(pressed_offsets),
        "inputObservedInAllSequences": bool(rows) and sequence_with_observed_press == len(rows),
    }


def input_quality_brief(quality: dict | None) -> str:
    if not quality:
        return "-"
    offsets = ",".join(str(offset) for offset in quality.get("observedPressedKeyOffsets") or []) or "-"
    return (
        f"pid={quality.get('sequenceWithPidCount')}/{quality.get('sequenceCount')} "
        f"base={quality.get('sequenceWithLoadedBaseCount')}/{quality.get('sequenceCount')} "
        f"keyWrites={quality.get('sequenceWithKeyWritesCount')}/{quality.get('sequenceCount')} "
        f"pressedSeq={quality.get('sequenceWithObservedKeyPressCount')}/{quality.get('sequenceCount')} "
        f"pressedEvents={quality.get('pressedEventCount')} offsets={offsets}"
    )


def compact_predecessor_progress_poll(poll: dict | None) -> dict:
    if not poll:
        return {"available": False}
    route_hit_count = sum(int(row.get("routeSelectorHitCount") or 0) for row in poll.get("rows") or [])
    current_hit_count = sum(int(row.get("currentRootHitCount") or 0) for row in poll.get("rows") or [])
    input_quality = selected_pointer_poll_input_quality(poll)
    return {
        "available": True,
        "sequenceCount": poll.get("sequenceCount"),
        "sampleCount": poll.get("sampleCount"),
        "startupWaitSeconds": poll.get("startupWaitSeconds"),
        "prelude": poll.get("prelude"),
        "caseAliasesEnabled": (poll.get("caseAliases") or {}).get("enabled"),
        "publicSaveSelectors": poll.get("publicSaveSelectors") or [],
        "observedSelectors": poll.get("observedSelectors") or [],
        "observedPublicSaveSelectors": poll.get("observedPublicSaveSelectors") or [],
        "anyReachedPublicSaveSelector": poll.get("anyReachedPublicSaveSelector"),
        "anyReachedCurrentRoot": poll.get("anyReachedCurrentRoot"),
        "anyReachedRouteSelectorContext": poll.get("anyReachedRouteSelectorContext"),
        "routeSelectorHitCount": route_hit_count,
        "currentRootHitCount": current_hit_count,
        "watchValues": watch_value_summary(poll),
        "inputQuality": input_quality,
        "promotionStatus": poll.get("promotionStatus"),
    }


def compact_predecessor_direction_sweep_poll(poll: dict | None) -> dict:
    compact = compact_predecessor_progress_poll(poll)
    if not compact.get("available"):
        return compact
    compact["stagedSaveKind"] = poll.get("stagedSaveKind")
    compact["sequenceNames"] = [row.get("name") for row in poll.get("rows") or [] if row.get("name")]
    return compact


def compact_predecessor_branch_state_poll(poll: dict | None) -> dict:
    compact = compact_predecessor_direction_sweep_poll(poll)
    if not compact.get("available"):
        return compact
    branch_state_hexes = stable_secondary_branch_state_hexes(poll)
    compact["activeSelectionFlagHex"] = stable_watch_hex(poll, "activeSelectionFlag")
    compact["secondaryBranchStateHexes"] = branch_state_hexes
    compact["secondaryBranchStateStable"] = len(branch_state_hexes) == 12
    compact["secondaryBranchStateAllZero"] = bool(branch_state_hexes) and all(
        value == "0x00" for value in branch_state_hexes
    )
    compact["matchesPredecessorFillHypothesis"] = branch_state_hexes == PREDECESSOR_FILL_STATE_HEXES
    compact["predecessorFillHypothesisHexes"] = PREDECESSOR_FILL_STATE_HEXES
    compact["targetedExitCandidates"] = poll.get("targetedExitCandidates") or []
    return compact


def compact_predecessor_highfreq_branch_state_poll(poll: dict | None) -> dict:
    compact = compact_predecessor_branch_state_poll(poll)
    if not compact.get("available"):
        return compact
    compact["pollIntervalSeconds"] = poll.get("pollIntervalSeconds")
    return compact


def compact_predecessor_coordinate_branch_state_poll(poll: dict | None) -> dict:
    compact = compact_predecessor_branch_state_poll(poll)
    if not compact.get("available"):
        return compact
    coordinate_analysis = poll.get("coordinateAnalysis") or {}
    coordinate_rows = []
    for row in coordinate_analysis.get("rows") or []:
        best_slot = row.get("bestActorSlot") or {}
        coordinate_rows.append({
            "name": row.get("name"),
            "candidateTile": row.get("candidateTile") or {},
            "candidateSide": row.get("candidateSide"),
            "sampleCount": row.get("sampleCount"),
            "movementObservedByActorSlots": row.get("movementObservedByActorSlots") or [],
            "startObservedByActorSlots": row.get("startObservedByActorSlots") or [],
            "targetObservedByActorSlots": row.get("targetObservedByActorSlots") or [],
            "bestActorSlot": {
                "slot": best_slot.get("slot"),
                "plannedPathHitCount": best_slot.get("plannedPathHitCount"),
                "plannedPathPointCount": best_slot.get("plannedPathPointCount"),
                "minManhattanDistanceToTarget": best_slot.get("minManhattanDistanceToTarget"),
            },
            "branchStateAllZero": row.get("branchStateAllZero"),
            "activeActorCountValues": row.get("activeActorCountValues") or [],
            "cameraTilePairs": row.get("cameraTilePairs") or [],
        })
    compact["coordinateAnalysisClassification"] = coordinate_analysis.get("classification")
    compact["coordinateAnyStartTileObserved"] = coordinate_analysis.get("anyStartTileObserved")
    compact["coordinateAnyTargetTileObserved"] = coordinate_analysis.get("anyTargetTileObserved")
    compact["coordinateRows"] = coordinate_rows
    compact["coordinateBranchStateSplit"] = poll.get("coordinateBranchStateSplit") or {}
    compact["coordinateWatchModel"] = poll.get("coordinateWatchModel") or {}
    return compact


def compact_best_slot(best_slot: dict | None) -> dict:
    best_slot = best_slot or {}
    return {
        "slot": best_slot.get("slot"),
        "plannedPathHitCount": best_slot.get("plannedPathHitCount"),
        "plannedPathPointCount": best_slot.get("plannedPathPointCount"),
        "minManhattanDistanceToTarget": best_slot.get("minManhattanDistanceToTarget"),
    }


def compact_predecessor_trail_start_branch_state_poll(poll: dict | None) -> dict:
    compact = compact_predecessor_branch_state_poll(poll)
    if not compact.get("available"):
        return compact
    analysis = poll.get("trailStartCoordinateAnalysis") or {}
    rows = []
    for row in analysis.get("rows") or []:
        rows.append({
            "name": row.get("name"),
            "candidateTile": row.get("candidateTile") or {},
            "candidateSide": row.get("candidateSide"),
            "sampleCount": row.get("sampleCount"),
            "actorStartSlots": row.get("actorStartSlots") or [],
            "actorTargetSlots": row.get("actorTargetSlots") or [],
            "actorMovementSlots": row.get("actorMovementSlots") or [],
            "actorPathSlots": row.get("actorPathSlots") or [],
            "actorBestSlot": compact_best_slot(row.get("actorBestSlot")),
            "trailStartSlots": row.get("trailStartSlots") or [],
            "trailTargetSlots": row.get("trailTargetSlots") or [],
            "trailMovementSlots": row.get("trailMovementSlots") or [],
            "trailPathSlots": row.get("trailPathSlots") or [],
            "trailBestSlot": compact_best_slot(row.get("trailBestSlot")),
            "branchStateAllZero": row.get("branchStateAllZero"),
            "activeActorCountValues": row.get("activeActorCountValues") or [],
            "cameraTilePairs": row.get("cameraTilePairs") or [],
        })
    compact["trailStartClassification"] = analysis.get("classification")
    compact["trailStartTile"] = analysis.get("startTile") or poll.get("trailStartTile") or {}
    compact["trailAnyActorStartTileObserved"] = analysis.get("anyActorStartTileObserved")
    compact["trailAnyActorTargetTileObserved"] = analysis.get("anyActorTargetTileObserved")
    compact["trailAnyTrailStartTileObserved"] = analysis.get("anyTrailStartTileObserved")
    compact["trailAnyTrailTargetTileObserved"] = analysis.get("anyTrailTargetTileObserved")
    compact["trailAnyActorMovementObserved"] = analysis.get("anyActorMovementObserved")
    compact["trailAnyTrailMovementObserved"] = analysis.get("anyTrailMovementObserved")
    compact["trailAnyStartTileObserved"] = analysis.get("anyStartTileObserved")
    compact["trailAnyTargetTileObserved"] = analysis.get("anyTargetTileObserved")
    compact["trailRows"] = rows
    compact["trailStartBranchStateSplit"] = poll.get("trailStartBranchStateSplit") or {}
    return compact


def compact_predecessor_trail_left_overrun_branch_state_poll(poll: dict | None) -> dict:
    compact = compact_predecessor_branch_state_poll(poll)
    if not compact.get("available"):
        return compact
    analysis = poll.get("trailLeftOverrunAnalysis") or {}
    rows = []
    for row in analysis.get("rows") or []:
        rows.append({
            "name": row.get("name"),
            "sampleCount": row.get("sampleCount"),
            "selectors": [
                item.get("selector") if isinstance(item, dict) else item
                for item in row.get("selectors") or []
            ],
            "targetTile": row.get("targetTile") or {},
            "outsideTile": row.get("outsideTile") or {},
            "cameraPairs": row.get("cameraPairs") or [],
            "cameraTargetObserved": row.get("cameraTargetObserved"),
            "cameraOutsideObserved": row.get("cameraOutsideObserved"),
            "actorTargetSlots": row.get("actorTargetSlots") or [],
            "actorOutsideSlots": row.get("actorOutsideSlots") or [],
            "trailTargetSlots": row.get("trailTargetSlots") or [],
            "trailOutsideSlots": row.get("trailOutsideSlots") or [],
            "actorMovementSlots": row.get("actorMovementSlots") or [],
            "trailMovementSlots": row.get("trailMovementSlots") or [],
            "branchStateAllZero": row.get("branchStateAllZero"),
        })
    compact["trailLeftOverrunClassification"] = analysis.get("classification")
    compact["trailLeftOverrunTargetTile"] = analysis.get("targetTile") or {}
    compact["trailLeftOverrunOutsideTile"] = analysis.get("outsideTile") or {}
    compact["trailLeftOverrunAnyCameraTargetObserved"] = analysis.get("anyCameraTargetObserved")
    compact["trailLeftOverrunAnyCameraOutsideObserved"] = analysis.get("anyCameraOutsideObserved")
    compact["trailLeftOverrunAnyActorTargetObserved"] = analysis.get("anyActorTargetObserved")
    compact["trailLeftOverrunAnyTrailTargetObserved"] = analysis.get("anyTrailTargetObserved")
    compact["trailLeftOverrunRows"] = rows
    compact["trailLeftOverrunBranchStateSplit"] = poll.get("trailLeftOverrunBranchStateSplit") or {}
    return compact


def compact_predecessor_fill_execution_order_gap(gap: dict | None) -> dict:
    if not gap:
        return {"available": False}
    encoded_scan = gap.get("encodedFillEntryCandidateScan") or {}
    root_tail = gap.get("rootTailIsolationScan") or {}
    immediate = root_tail.get("immediatePredecessorRow") or {}
    return {
        "available": True,
        "predecessorSelector": gap.get("predecessorSelector"),
        "currentSelector": gap.get("currentSelector"),
        "currentReaderHex": gap.get("currentReaderHex"),
        "fillSites": gap.get("fillSites") or [],
        "localFillTraceStartHex": gap.get("localFillTraceStartHex"),
        "localFillTraceStopHex": gap.get("localFillTraceStopHex"),
        "localFillTraceStopReason": gap.get("localFillTraceStopReason"),
        "localFillTraceStopHandlerHex": gap.get("localFillTraceStopHandlerHex"),
        "localFillTraceContainsAllFillSites": gap.get("localFillTraceContainsAllFillSites"),
        "localFillTraceReachesCurrentReader": gap.get("localFillTraceReachesCurrentReader"),
        "rootEntryFixedTraversalFillSitesReachable": gap.get(
            "rootEntryFixedTraversalFillSitesReachable"
        ),
        "directFillSiteRefCounts": gap.get("directFillSiteRefCounts") or {},
        "encodedFillEntryClassification": gap.get("encodedFillEntryClassification")
        or encoded_scan.get("classification"),
        "encodedFillEntryRawScalarCandidateCount": gap.get(
            "encodedFillEntryRawScalarCandidateCount"
        ),
        "encodedFillEntryRootTailRawScalarCandidateCount": gap.get(
            "encodedFillEntryRootTailRawScalarCandidateCount"
        ),
        "encodedFillEntryBranchAttachedEncodedFieldCount": gap.get(
            "encodedFillEntryBranchAttachedEncodedFieldCount"
        ),
        "encodedFillEntryModeledControlFlowCandidateCount": gap.get(
            "encodedFillEntryModeledControlFlowCandidateCount"
        ),
        "encodedFillEntryPromotingCandidateCount": gap.get(
            "encodedFillEntryPromotingCandidateCount"
        ),
        "encodedRawScalarRejectionClassification": gap.get(
            "encodedRawScalarRejectionClassification"
        ),
        "encodedRawScalarAllScalarOnly": gap.get("encodedRawScalarAllScalarOnly"),
        "encodedRawScalarNoFixedAdvanceCount": gap.get("encodedRawScalarNoFixedAdvanceCount"),
        "encodedRawScalarNoBranchJumpCount": gap.get("encodedRawScalarNoBranchJumpCount"),
        "encodedRawScalarBranchAttachedCount": gap.get("encodedRawScalarBranchAttachedCount"),
        "encodedRawScalarScalarOnlyCount": gap.get("encodedRawScalarScalarOnlyCount"),
        "encodedRawScalarKindCounts": gap.get("encodedRawScalarKindCounts") or {},
        "encodedRawScalarHandlerSectionCounts": gap.get(
            "encodedRawScalarHandlerSectionCounts"
        ) or {},
        "rootTailDistanceHex": root_tail.get("distanceHex"),
        "rootTailDwordCount": root_tail.get("dwordCount"),
        "rootTailDescriptorIsolated": gap.get("rootTailDescriptorIsolated"),
        "rootTailBranchToFillFragmentCount": gap.get("rootTailBranchToFillFragmentCount"),
        "rootTailFixedFallthroughToFillCount": gap.get("rootTailFixedFallthroughToFillCount"),
        "rootTailBranchClosureClassification": gap.get("rootTailBranchClosureClassification"),
        "rootTailBranchClosureNodeCount": gap.get("rootTailBranchClosureNodeCount"),
        "rootTailBranchClosureBranchSeedCount": gap.get(
            "rootTailBranchClosureBranchSeedCount"
        ),
        "rootTailBranchClosureEdgeCount": gap.get("rootTailBranchClosureEdgeCount"),
        "rootTailBranchClosureTailNodeReachFillCount": gap.get(
            "rootTailBranchClosureTailNodeReachFillCount"
        ),
        "rootTailBranchClosureTailNodeReachCurrentReaderCount": gap.get(
            "rootTailBranchClosureTailNodeReachCurrentReaderCount"
        ),
        "rootTailBranchClosureBranchSeedReachFillCount": gap.get(
            "rootTailBranchClosureBranchSeedReachFillCount"
        ),
        "rootTailBranchClosureBranchSeedReachCurrentReaderCount": gap.get(
            "rootTailBranchClosureBranchSeedReachCurrentReaderCount"
        ),
        "rootTailBranchClosureProofFound": gap.get("rootTailBranchClosureProofFound"),
        "rootTailBranchClosureOutsideSuccessorCount": gap.get(
            "rootTailBranchClosureOutsideSuccessorCount"
        ),
        "rootTailBranchClosureOutsideSuccessorClassCounts": gap.get(
            "rootTailBranchClosureOutsideSuccessorClassCounts"
        )
        or {},
        "rootTailBranchClosureOutsideSuccessorSectionCounts": gap.get(
            "rootTailBranchClosureOutsideSuccessorSectionCounts"
        )
        or {},
        "rootTailBranchClosureOutsideSuccessorSampleRows": gap.get(
            "rootTailBranchClosureOutsideSuccessorSampleRows"
        )
        or [],
        "rootTailImmediatePredecessorHandlerSection": immediate.get("handlerSection"),
        "rootTailImmediatePredecessorHandlerHex": immediate.get("handlerVaHex"),
        "predecessorDispatchTableProofFound": gap.get("predecessorDispatchTableProofFound"),
        "predecessorDispatchTableFailedGateIds": gap.get(
            "predecessorDispatchTableFailedGateIds"
        )
        or [],
        "predecessorDispatchTableMissingEvidence": gap.get(
            "predecessorDispatchTableMissingEvidence"
        )
        or [],
        "predecessorDispatchTableEvidenceRefCount": gap.get(
            "predecessorDispatchTableEvidenceRefCount"
        ),
        "predecessorDispatchSliceRuntimeProofFound": gap.get(
            "predecessorDispatchSliceRuntimeProofFound"
        ),
        "predecessorDescriptorDependsOnSaveSelectorSliceModel": gap.get(
            "predecessorDescriptorDependsOnSaveSelectorSliceModel"
        ),
        "predecessorDispatchSliceRowCount": gap.get("predecessorDispatchSliceRowCount"),
        "predecessorDispatchSliceDataDescriptorCount": gap.get(
            "predecessorDispatchSliceDataDescriptorCount"
        ),
        "predecessorDispatchRawGeneralCodeCount": gap.get(
            "predecessorDispatchRawGeneralCodeCount"
        ),
        "predecessorDispatchRawGeneralDiffersFromSliceCount": gap.get(
            "predecessorDispatchRawGeneralDiffersFromSliceCount"
        ),
        "predecessorDispatchSliceGenericByteReachableCount": gap.get(
            "predecessorDispatchSliceGenericByteReachableCount"
        ),
        "predecessorDispatchSliceRequiresTableBaseSwitchCount": gap.get(
            "predecessorDispatchSliceRequiresTableBaseSwitchCount"
        ),
        "predecessorDispatchDynamicIndexedDispatchRowCount": gap.get(
            "predecessorDispatchDynamicIndexedDispatchRowCount"
        ),
        "predecessorDispatchDynamicDwordScaledDispatchRowCount": gap.get(
            "predecessorDispatchDynamicDwordScaledDispatchRowCount"
        ),
        "predecessorDispatchDynamicScopeTableCallbackCount": gap.get(
            "predecessorDispatchDynamicScopeTableCallbackCount"
        ),
        "predecessorDispatchDynamicScopeTableCallbackSites": gap.get(
            "predecessorDispatchDynamicScopeTableCallbackSites"
        ) or [],
        "predecessorDispatchDynamicScopeTableCallbackRows": gap.get(
            "predecessorDispatchDynamicScopeTableCallbackRows"
        ) or [],
        "predecessorDispatchDynamicSaveSelectorTableImmediateNearCount": gap.get(
            "predecessorDispatchDynamicSaveSelectorTableImmediateNearCount"
        ),
        "predecessorDispatchDynamicSaveSelectorTableBaseCandidateCount": gap.get(
            "predecessorDispatchDynamicSaveSelectorTableBaseCandidateCount"
        ),
        "predecessorDispatchDynamicSaveSelectorTableBaseCandidateSites": gap.get(
            "predecessorDispatchDynamicSaveSelectorTableBaseCandidateSites"
        ) or [],
        "predecessorDispatchDynamicSaveSelectorTableBaseCandidateRows": gap.get(
            "predecessorDispatchDynamicSaveSelectorTableBaseCandidateRows"
        ) or [],
        "predecessorDispatchDynamicSaveSelectorTableBaseSwitchStaticCandidateFound": gap.get(
            "predecessorDispatchDynamicSaveSelectorTableBaseSwitchStaticCandidateFound"
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticRowCount": gap.get(
            "predecessorDispatchSaveSelectorTableBaseArithmeticRowCount"
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateCount": gap.get(
            "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateCount"
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateFound": gap.get(
            "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateFound"
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateRows": gap.get(
            "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateRows"
        )
        or [],
        "predecessorDispatchTableBaseRejectionClassification": gap.get(
            "predecessorDispatchTableBaseRejectionClassification"
        ),
        "rawGenericCallGraphClassification": gap.get("rawGenericCallGraphClassification"),
        "rawGenericCallGraphProofFound": gap.get("rawGenericCallGraphProofFound"),
        "rawGenericCallGraphMaxDepth": gap.get("rawGenericCallGraphMaxDepth"),
        "rawGenericCallGraphReachableFunctionCount": gap.get(
            "rawGenericCallGraphReachableFunctionCount"
        ),
        "rawGenericCallGraphDirectCallEdgeCount": gap.get(
            "rawGenericCallGraphDirectCallEdgeCount"
        ),
        "rawGenericCallGraphRouteImmediateHitCount": gap.get(
            "rawGenericCallGraphRouteImmediateHitCount"
        ),
        "rawGenericCallGraphFillImmediateHitCount": gap.get(
            "rawGenericCallGraphFillImmediateHitCount"
        ),
        "rawGenericCallGraphCurrentImmediateHitCount": gap.get(
            "rawGenericCallGraphCurrentImmediateHitCount"
        ),
        "rawGenericCallGraphSelectedPointerImmediateHitCount": gap.get(
            "rawGenericCallGraphSelectedPointerImmediateHitCount"
        ),
        "rawGenericCallGraphBranchStateImmediateHitCount": gap.get(
            "rawGenericCallGraphBranchStateImmediateHitCount"
        ),
        "rawGenericCallGraphRouteDirectTransferHitCount": gap.get(
            "rawGenericCallGraphRouteDirectTransferHitCount"
        ),
        "rawGenericCallGraphFillDirectTransferHitCount": gap.get(
            "rawGenericCallGraphFillDirectTransferHitCount"
        ),
        "rawGenericCallGraphDepthSensitivityMaxDepthChecked": gap.get(
            "rawGenericCallGraphDepthSensitivityMaxDepthChecked"
        ),
        "rawGenericCallGraphDepthSensitivityProofAbsentAcrossCheckedDepths": gap.get(
            "rawGenericCallGraphDepthSensitivityProofAbsentAcrossCheckedDepths"
        ),
        "rawGenericCallGraphDepthSensitivityCountsStableAtAndBeyondDefaultDepth": gap.get(
            "rawGenericCallGraphDepthSensitivityCountsStableAtAndBeyondDefaultDepth"
        ),
        "predecessorFillProofGateRows": gap.get("predecessorFillProofGateRows") or [],
        "predecessorFillProofGateCount": gap.get("predecessorFillProofGateCount"),
        "predecessorFillProofGatePassCount": gap.get("predecessorFillProofGatePassCount"),
        "predecessorFillProofGateBlockedCount": gap.get("predecessorFillProofGateBlockedCount"),
        "predecessorFillProofGateBlockedIds": gap.get("predecessorFillProofGateBlockedIds") or [],
        "predecessorFillAllProofGatesBlocked": gap.get("predecessorFillAllProofGatesBlocked"),
        "failedPredecessorFillOrderGateIds": gap.get("failedPredecessorFillOrderGateIds") or [],
        "missingEvidence": gap.get("missingEvidence") or [],
        "routeOrderProven": gap.get("routeOrderProven"),
        "selectorMergeGapOpen": gap.get("selectorMergeGapOpen"),
        "proofFound": gap.get("proofFound"),
        "promotionStatus": gap.get("promotionStatus"),
    }


def compact_predecessor_fill_site_execution_context(context: dict | None) -> dict:
    if not context:
        return {"available": False}
    field_entry = context.get("fieldEntrySequenceContext") or {}
    coordinate_source = context.get("coordinateSourceContext") or {}
    return {
        "available": True,
        "predecessorSelector": context.get("predecessorSelector"),
        "currentSelector": context.get("currentSelector"),
        "currentReaderHex": context.get("currentReaderHex"),
        "fillSites": context.get("fillSites") or [],
        "branchStatePollCount": context.get("branchStatePollCount"),
        "branchStatePollSequenceCount": context.get("branchStatePollSequenceCount"),
        "branchStatePollSampleCount": context.get("branchStatePollSampleCount"),
        "branchStatePollPublicPredecessorHitCount": context.get(
            "branchStatePollPublicPredecessorHitCount"
        ),
        "branchStatePollCurrentRootHitCount": context.get("branchStatePollCurrentRootHitCount"),
        "branchStatePollRouteSelectorHitCount": context.get(
            "branchStatePollRouteSelectorHitCount"
        ),
        "branchStatePollAllZeroCount": context.get("branchStatePollAllZeroCount"),
        "branchStatePollFillMatchCount": context.get("branchStatePollFillMatchCount"),
        "branchStatePollTargetObservationStatus": context.get(
            "branchStatePollTargetObservationStatus"
        ),
        "branchStatePollTargetObservationCount": context.get(
            "branchStatePollTargetObservationCount"
        ),
        "branchStatePollTargetObservationSampleCount": context.get(
            "branchStatePollTargetObservationSampleCount"
        ),
        "branchStatePollTargetObservationFillMatchCount": context.get(
            "branchStatePollTargetObservationFillMatchCount"
        ),
        "branchStatePollTargetObservationCurrentRootHitCount": context.get(
            "branchStatePollTargetObservationCurrentRootHitCount"
        ),
        "branchStatePollTargetObservationRouteSelectorHitCount": context.get(
            "branchStatePollTargetObservationRouteSelectorHitCount"
        ),
        "branchStatePollCameraOnlyTargetCount": context.get(
            "branchStatePollCameraOnlyTargetCount"
        ),
        "branchStatePollActorOrTrailTargetCount": context.get(
            "branchStatePollActorOrTrailTargetCount"
        ),
        "rootEntryFixedTraversalFillSitesReachable": context.get(
            "rootEntryFixedTraversalFillSitesReachable"
        ),
        "encodedFillEntryClassification": context.get("encodedFillEntryClassification"),
        "encodedFillEntryRawScalarCandidateCount": context.get(
            "encodedFillEntryRawScalarCandidateCount"
        ),
        "encodedFillEntryRootTailRawScalarCandidateCount": context.get(
            "encodedFillEntryRootTailRawScalarCandidateCount"
        ),
        "encodedFillEntryPromotingCandidateCount": context.get(
            "encodedFillEntryPromotingCandidateCount"
        ),
        "encodedRawScalarRejectionClassification": context.get(
            "encodedRawScalarRejectionClassification"
        ),
        "encodedRawScalarAllScalarOnly": context.get("encodedRawScalarAllScalarOnly"),
        "encodedRawScalarNoFixedAdvanceCount": context.get("encodedRawScalarNoFixedAdvanceCount"),
        "encodedRawScalarNoBranchJumpCount": context.get("encodedRawScalarNoBranchJumpCount"),
        "encodedRawScalarBranchAttachedCount": context.get("encodedRawScalarBranchAttachedCount"),
        "encodedRawScalarScalarOnlyCount": context.get("encodedRawScalarScalarOnlyCount"),
        "encodedRawScalarKindCounts": context.get("encodedRawScalarKindCounts") or {},
        "encodedRawScalarHandlerSectionCounts": context.get(
            "encodedRawScalarHandlerSectionCounts"
        ) or {},
        "rootTailDescriptorIsolated": context.get("rootTailDescriptorIsolated"),
        "rootTailBranchToFillFragmentCount": context.get("rootTailBranchToFillFragmentCount"),
        "rootTailFixedFallthroughToFillCount": context.get("rootTailFixedFallthroughToFillCount"),
        "rootTailBranchClosureClassification": context.get(
            "rootTailBranchClosureClassification"
        ),
        "rootTailBranchClosureNodeCount": context.get("rootTailBranchClosureNodeCount"),
        "rootTailBranchClosureBranchSeedCount": context.get(
            "rootTailBranchClosureBranchSeedCount"
        ),
        "rootTailBranchClosureEdgeCount": context.get("rootTailBranchClosureEdgeCount"),
        "rootTailBranchClosureTailNodeReachFillCount": context.get(
            "rootTailBranchClosureTailNodeReachFillCount"
        ),
        "rootTailBranchClosureTailNodeReachCurrentReaderCount": context.get(
            "rootTailBranchClosureTailNodeReachCurrentReaderCount"
        ),
        "rootTailBranchClosureBranchSeedReachFillCount": context.get(
            "rootTailBranchClosureBranchSeedReachFillCount"
        ),
        "rootTailBranchClosureBranchSeedReachCurrentReaderCount": context.get(
            "rootTailBranchClosureBranchSeedReachCurrentReaderCount"
        ),
        "rootTailBranchClosureProofFound": context.get("rootTailBranchClosureProofFound"),
        "rootTailBranchClosureOutsideSuccessorCount": context.get(
            "rootTailBranchClosureOutsideSuccessorCount"
        ),
        "rootTailBranchClosureOutsideSuccessorClassCounts": context.get(
            "rootTailBranchClosureOutsideSuccessorClassCounts"
        )
        or {},
        "rootTailBranchClosureOutsideSuccessorSectionCounts": context.get(
            "rootTailBranchClosureOutsideSuccessorSectionCounts"
        )
        or {},
        "rootTailBranchClosureOutsideSuccessorSampleRows": context.get(
            "rootTailBranchClosureOutsideSuccessorSampleRows"
        )
        or [],
        "descriptorBridgeProofFound": context.get("descriptorBridgeProofFound"),
        "descriptorEdgeRejectionClassification": context.get(
            "descriptorEdgeRejectionClassification"
        ),
        "descriptorEdgeAllTargetSectionsData": context.get("descriptorEdgeAllTargetSectionsData"),
        "descriptorEdgeDescriptorTargetEdgeCount": context.get(
            "descriptorEdgeDescriptorTargetEdgeCount"
        ),
        "descriptorEdgeRouteExecutionTargetEdgeCount": context.get(
            "descriptorEdgeRouteExecutionTargetEdgeCount"
        ),
        "descriptorEdgeRootRouteExecutionTargetEdgeCount": context.get(
            "descriptorEdgeRootRouteExecutionTargetEdgeCount"
        ),
        "descriptorEdgeFillRouteExecutionTargetEdgeCount": context.get(
            "descriptorEdgeFillRouteExecutionTargetEdgeCount"
        ),
        "predecessorDispatchDynamicSaveSelectorTableBaseCandidateCount": context.get(
            "predecessorDispatchDynamicSaveSelectorTableBaseCandidateCount"
        ),
        "predecessorDispatchDynamicScopeTableCallbackSites": context.get(
            "predecessorDispatchDynamicScopeTableCallbackSites"
        ) or [],
        "predecessorDispatchDynamicSaveSelectorTableBaseCandidateSites": context.get(
            "predecessorDispatchDynamicSaveSelectorTableBaseCandidateSites"
        ) or [],
        "predecessorDispatchSaveSelectorTableBaseArithmeticRowCount": context.get(
            "predecessorDispatchSaveSelectorTableBaseArithmeticRowCount"
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateCount": context.get(
            "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateCount"
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateFound": context.get(
            "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateFound"
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateRows": context.get(
            "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateRows"
        )
        or [],
        "predecessorDispatchTableBaseRejectionClassification": context.get(
            "predecessorDispatchTableBaseRejectionClassification"
        ),
        "rawGenericCallGraphClassification": context.get("rawGenericCallGraphClassification"),
        "rawGenericCallGraphProofFound": context.get("rawGenericCallGraphProofFound"),
        "rawGenericCallGraphMaxDepth": context.get("rawGenericCallGraphMaxDepth"),
        "rawGenericCallGraphReachableFunctionCount": context.get(
            "rawGenericCallGraphReachableFunctionCount"
        ),
        "rawGenericCallGraphDirectCallEdgeCount": context.get(
            "rawGenericCallGraphDirectCallEdgeCount"
        ),
        "runtimeFillObserved": context.get("runtimeFillObserved"),
        "branchGateSameTableAndOffset": context.get("branchGateSameTableAndOffset"),
        "branchGateSameSelectionBufferOffsetHex": context.get(
            "branchGateSameSelectionBufferOffsetHex"
        ),
        "branchGatePostWriterSameOffsetWriteCount": context.get(
            "branchGatePostWriterSameOffsetWriteCount"
        ),
        "branchGatePostWriterSameOffsetReadCount": context.get(
            "branchGatePostWriterSameOffsetReadCount"
        ),
        "branchGatePostWriterOtherOffsetWriteCount": context.get(
            "branchGatePostWriterOtherOffsetWriteCount"
        ),
        "branchGatePostWriterOtherOffsetWriteOffsetsHex": context.get(
            "branchGatePostWriterOtherOffsetWriteOffsetsHex"
        )
        or [],
        "branchGateInvalidSecondaryFillOffsetsHex": context.get(
            "branchGateInvalidSecondaryFillOffsetsHex"
        )
        or [],
        "branchGateKnownOpcodeStatePreservationStatus": context.get(
            "branchGateKnownOpcodeStatePreservationStatus"
        ),
        "branchGateSlotPreservedByKnownOpcodes": context.get(
            "branchGateSlotPreservedByKnownOpcodes"
        ),
        "branchGateBranchStateValueStillRuntimeDependent": context.get(
            "branchGateBranchStateValueStillRuntimeDependent"
        ),
        "fieldEntrySequenceContext": {
            "sequenceCount": field_entry.get("sequenceCount"),
            "snapshotCount": field_entry.get("snapshotCount"),
            "fieldEntryCandidateCount": field_entry.get("fieldEntryCandidateCount"),
            "snapshotRouteCandidateCount": field_entry.get("snapshotRouteCandidateCount"),
            "finalSelectorCounts": field_entry.get("finalSelectorCounts") or {},
            "snapshotSelectorCounts": field_entry.get("snapshotSelectorCounts") or {},
            "proofFound": field_entry.get("proofFound"),
            "predecessorFieldEntryProofFound": field_entry.get(
                "predecessorFieldEntryProofFound"
            ),
            "fieldEntryRouteCandidateFound": field_entry.get("fieldEntryRouteCandidateFound"),
            "failedPredecessorFieldEntryGateIds": field_entry.get(
                "failedPredecessorFieldEntryGateIds"
            )
            or [],
            "missingEvidence": field_entry.get("missingEvidence") or [],
            "evidenceRefs": field_entry.get("evidenceRefs") or [],
            "evidenceRefCount": field_entry.get("evidenceRefCount"),
            "promotionStatus": field_entry.get("promotionStatus"),
        },
        "coordinateSourceContext": {
            "classification": coordinate_source.get("classification"),
            "promotionStatus": coordinate_source.get("promotionStatus"),
            "finalSelector": coordinate_source.get("finalSelector"),
            "coordinateSourceRejectionClassification": coordinate_source.get(
                "coordinateSourceRejectionClassification"
            ),
            "pairHitSummaryRows": coordinate_source.get("pairHitSummaryRows") or [],
            "publicSaveStartPointerTableTileHitCount": coordinate_source.get(
                "publicSaveStartPointerTableTileHitCount"
            ),
            "publicSaveStartStaticBaseHitCount": coordinate_source.get(
                "publicSaveStartStaticBaseHitCount"
            ),
            "publicSaveStartTrailRingHitCount": coordinate_source.get(
                "publicSaveStartTrailRingHitCount"
            ),
            "publicSaveStartImageHitCount": coordinate_source.get(
                "publicSaveStartImageHitCount"
            ),
            "publicSaveStartKnownGlobalImageHitCount": coordinate_source.get(
                "publicSaveStartKnownGlobalImageHitCount"
            ),
            "observedTrailPointerTableTileHitCount": coordinate_source.get(
                "observedTrailPointerTableTileHitCount"
            ),
            "observedTrailStaticBaseHitCount": coordinate_source.get(
                "observedTrailStaticBaseHitCount"
            ),
            "observedTrailTrailRingHitCount": coordinate_source.get(
                "observedTrailTrailRingHitCount"
            ),
            "observedTrailImageHitCount": coordinate_source.get("observedTrailImageHitCount"),
            "observedTrailKnownGlobalImageHitCount": coordinate_source.get(
                "observedTrailKnownGlobalImageHitCount"
            ),
            "reciprocalPointerTableTileHitCount": coordinate_source.get(
                "reciprocalPointerTableTileHitCount"
            ),
            "reciprocalStaticBaseHitCount": coordinate_source.get(
                "reciprocalStaticBaseHitCount"
            ),
            "reciprocalTrailRingHitCount": coordinate_source.get(
                "reciprocalTrailRingHitCount"
            ),
            "reciprocalImageHitCount": coordinate_source.get("reciprocalImageHitCount"),
        },
        "requiredProofGateCount": context.get("requiredProofGateCount"),
        "requiredProofGatePassCount": context.get("requiredProofGatePassCount"),
        "requiredProofGateFailCount": context.get("requiredProofGateFailCount"),
        "requiredProofGateStatusOrder": context.get("requiredProofGateStatusOrder") or [],
        "requiredProofGateStatuses": context.get("requiredProofGateStatuses") or {},
        "requiredProofGateFailIds": context.get("requiredProofGateFailIds") or [],
        "requiredProofGateAllBlocked": context.get("requiredProofGateAllBlocked"),
        "fillSiteExecutionContextProven": context.get("fillSiteExecutionContextProven"),
        "proofFound": context.get("proofFound"),
        "failedPredecessorFillGateIds": context.get("failedPredecessorFillGateIds") or [],
        "missingEvidence": context.get("missingEvidence") or [],
        "evidenceRefs": context.get("evidenceRefs") or [],
        "evidenceRefCount": context.get("evidenceRefCount"),
        "promotionStatus": context.get("promotionStatus"),
    }


def build_summary(
    predecessor_persistence_gap: dict,
    predecessor_state_effect: dict,
    predecessor_tail_reset: dict,
    secondary_reset_scope: dict,
    secondary_global_reset_gap: dict,
    predecessor_route_order: dict,
    merge_gap: dict,
    hotspot_gap: dict,
    predecessor_progress_poll: dict | None = None,
    predecessor_direction_sweep_poll: dict | None = None,
    predecessor_branch_state_poll: dict | None = None,
    predecessor_left_overrun_activation_branch_state_poll: dict | None = None,
    predecessor_nearest_exit_branch_state_poll: dict | None = None,
    predecessor_reciprocal_exit_branch_state_poll: dict | None = None,
    predecessor_coordinate_branch_state_poll: dict | None = None,
    predecessor_trail_start_branch_state_poll: dict | None = None,
    predecessor_trail_left_overrun_branch_state_poll: dict | None = None,
    predecessor_highfreq_branch_state_poll: dict | None = None,
    predecessor_fill_execution_order_gap: dict | None = None,
    predecessor_fill_site_execution_context: dict | None = None,
) -> dict:
    progress_poll = compact_predecessor_progress_poll(predecessor_progress_poll)
    direction_sweep_poll = compact_predecessor_direction_sweep_poll(predecessor_direction_sweep_poll)
    branch_state_poll = compact_predecessor_branch_state_poll(predecessor_branch_state_poll)
    left_overrun_activation_branch_state_poll = compact_predecessor_branch_state_poll(
        predecessor_left_overrun_activation_branch_state_poll
    )
    nearest_exit_branch_state_poll = compact_predecessor_branch_state_poll(
        predecessor_nearest_exit_branch_state_poll
    )
    reciprocal_exit_branch_state_poll = compact_predecessor_branch_state_poll(
        predecessor_reciprocal_exit_branch_state_poll
    )
    coordinate_branch_state_poll = compact_predecessor_coordinate_branch_state_poll(
        predecessor_coordinate_branch_state_poll
    )
    trail_start_branch_state_poll = compact_predecessor_trail_start_branch_state_poll(
        predecessor_trail_start_branch_state_poll
    )
    trail_left_overrun_branch_state_poll = compact_predecessor_trail_left_overrun_branch_state_poll(
        predecessor_trail_left_overrun_branch_state_poll
    )
    highfreq_branch_state_poll = compact_predecessor_highfreq_branch_state_poll(
        predecessor_highfreq_branch_state_poll
    )
    fill_execution_order_gap = compact_predecessor_fill_execution_order_gap(
        predecessor_fill_execution_order_gap
    )
    fill_site_execution_context = compact_predecessor_fill_site_execution_context(
        predecessor_fill_site_execution_context
    )
    secondary = secondary_reset_scope.get("secondaryBranchState") or {}
    helper = secondary_reset_scope.get("helper") or {}
    route_scope = secondary_reset_scope.get("routeScope") or {}
    predecessor_fill_would_pass = (
        predecessor_state_effect.get("allStartsPassReader") is True
        and predecessor_persistence_gap.get("predecessorFillWouldPassCurrentReader") is True
    )
    predecessor_local_tail_closed = (
        predecessor_tail_reset.get("tailOpcode10RowCount") == 0
        and predecessor_tail_reset.get("tailValidSecondaryFillCount") == 0
        and predecessor_tail_reset.get("localTailResetFound") is False
    )
    static_reset_scope_closed = (
        secondary_global_reset_gap.get("closedStaticResetScope") is True
        and secondary_global_reset_gap.get("directGlobalSecondaryWriterCount") == 0
        and secondary_global_reset_gap.get("unresolvedGlobalSecondaryRefCount") == 0
        and secondary_global_reset_gap.get("helperOnlyCalledInsideOpcode10Handler") is True
    )
    selector_order_reset_closed = secondary_global_reset_gap.get("selectorOrderResetGapClosed") is True
    route_order_proven = predecessor_route_order.get("routeOrderProven") is True
    selector_merge_gap_open = (
        predecessor_persistence_gap.get("selectorMergeGapOpen") is True
        or predecessor_route_order.get("selectorMergeGapOpen") is True
        or merge_gap.get("selectorMergeGapOpen") is True
    )
    strict_hotspot_found = hotspot_gap.get("strictHotspotFound") is True
    global_reset_ruled_out = secondary_global_reset_gap.get("globalResetRuledOut") is True
    runtime_order_gap_open = (
        secondary_global_reset_gap.get("openRuntimeOrderOrBytecodeGap") is True
        or not route_order_proven
        or selector_merge_gap_open
        or (
            fill_execution_order_gap.get("available")
            and fill_execution_order_gap.get("proofFound") is not True
        )
        or (
            fill_site_execution_context.get("available")
            and fill_site_execution_context.get("fillSiteExecutionContextProven") is not True
        )
        or (
            branch_state_poll.get("available")
            and branch_state_poll.get("matchesPredecessorFillHypothesis") is not True
        )
        or (
            left_overrun_activation_branch_state_poll.get("available")
            and left_overrun_activation_branch_state_poll.get("matchesPredecessorFillHypothesis") is not True
        )
        or (
            nearest_exit_branch_state_poll.get("available")
            and nearest_exit_branch_state_poll.get("matchesPredecessorFillHypothesis") is not True
        )
        or (
            reciprocal_exit_branch_state_poll.get("available")
            and reciprocal_exit_branch_state_poll.get("matchesPredecessorFillHypothesis") is not True
        )
        or (
            coordinate_branch_state_poll.get("available")
            and coordinate_branch_state_poll.get("matchesPredecessorFillHypothesis") is not True
        )
        or (
            trail_start_branch_state_poll.get("available")
            and trail_start_branch_state_poll.get("matchesPredecessorFillHypothesis") is not True
        )
        or (
            trail_left_overrun_branch_state_poll.get("available")
            and trail_left_overrun_branch_state_poll.get("matchesPredecessorFillHypothesis") is not True
        )
        or (
            highfreq_branch_state_poll.get("available")
            and highfreq_branch_state_poll.get("matchesPredecessorFillHypothesis") is not True
        )
    )
    runtime_fill_observed = (
        branch_state_poll.get("matchesPredecessorFillHypothesis") is True
        or left_overrun_activation_branch_state_poll.get("matchesPredecessorFillHypothesis") is True
        or nearest_exit_branch_state_poll.get("matchesPredecessorFillHypothesis") is True
        or reciprocal_exit_branch_state_poll.get("matchesPredecessorFillHypothesis") is True
        or coordinate_branch_state_poll.get("matchesPredecessorFillHypothesis") is True
        or trail_start_branch_state_poll.get("matchesPredecessorFillHypothesis") is True
        or trail_left_overrun_branch_state_poll.get("matchesPredecessorFillHypothesis") is True
        or highfreq_branch_state_poll.get("matchesPredecessorFillHypothesis") is True
    )
    branch_state_execution_proof_found = (
        predecessor_fill_would_pass
        and predecessor_local_tail_closed
        and static_reset_scope_closed
        and selector_order_reset_closed
        and global_reset_ruled_out
        and route_order_proven
        and not selector_merge_gap_open
        and (
            not fill_execution_order_gap.get("available")
            or fill_execution_order_gap.get("proofFound") is True
        )
        and (
            not fill_site_execution_context.get("available")
            or fill_site_execution_context.get("fillSiteExecutionContextProven") is True
        )
        and (
            (
                not branch_state_poll.get("available")
                and not left_overrun_activation_branch_state_poll.get("available")
                and not nearest_exit_branch_state_poll.get("available")
                and not reciprocal_exit_branch_state_poll.get("available")
                and not coordinate_branch_state_poll.get("available")
                and not trail_start_branch_state_poll.get("available")
                and not trail_left_overrun_branch_state_poll.get("available")
                and not highfreq_branch_state_poll.get("available")
            )
            or runtime_fill_observed
        )
    )
    branch_state_execution_gate_pass = {
        "fill-execution-order-proof": (
            not fill_execution_order_gap.get("available")
            or fill_execution_order_gap.get("proofFound") is True
        ),
        "fill-site-execution-context": (
            not fill_site_execution_context.get("available")
            or fill_site_execution_context.get("fillSiteExecutionContextProven") is True
        ),
        "normal-route-order": route_order_proven,
        "vm-bytecode-reset-scope-ruled-out": global_reset_ruled_out,
        "runtime-branch-state-fill-observed": runtime_fill_observed,
        "selector-merge-closed": not selector_merge_gap_open,
        "strict-source-hotspot": strict_hotspot_found,
    }
    failed_branch_state_execution_gate_ids = [
        gate_id
        for gate_id, _missing_evidence in BRANCH_STATE_EXECUTION_GATE_EVIDENCE
        if branch_state_execution_gate_pass.get(gate_id) is not True
    ]
    branch_state_execution_missing_evidence = [
        missing_evidence
        for gate_id, missing_evidence in BRANCH_STATE_EXECUTION_GATE_EVIDENCE
        if branch_state_execution_gate_pass.get(gate_id) is not True
    ]
    persistence_promotable = branch_state_execution_proof_found and strict_hotspot_found
    public_predecessor_reached = (
        branch_state_poll.get("available")
        and branch_state_poll.get("anyReachedPublicSaveSelector") is True
        and predecessor_persistence_gap.get("predecessorSelector")
        in (branch_state_poll.get("observedPublicSaveSelectors") or [])
    )
    observed_fill_matches = branch_state_poll.get("matchesPredecessorFillHypothesis")
    runtime_split_classification = (
        "public-predecessor-reached-fill-not-observed"
        if public_predecessor_reached
        and observed_fill_matches is False
        and branch_state_poll.get("secondaryBranchStateAllZero") is True
        else "not-classified"
    )
    runtime_branch_state_split = {
        "classification": runtime_split_classification,
        "publicPredecessorReached": bool(public_predecessor_reached),
        "publicRouteReached": branch_state_poll.get("anyReachedRouteSelectorContext") is True,
        "observedStateHexes": branch_state_poll.get("secondaryBranchStateHexes") or [],
        "expectedFillHexes": branch_state_poll.get("predecessorFillHypothesisHexes") or [],
        "observedMatchesFill": observed_fill_matches,
        "observedAllZero": branch_state_poll.get("secondaryBranchStateAllZero"),
        "activeSelectionFlagHex": branch_state_poll.get("activeSelectionFlagHex"),
        "staticNoLocalTailReset": predecessor_local_tail_closed,
        "staticNoDirectGlobalSecondaryWriter": secondary_global_reset_gap.get("directGlobalSecondaryWriterCount") == 0,
        "staticHelperOpcode10Only": secondary_global_reset_gap.get("helperOnlyCalledInsideOpcode10Handler") is True,
        "staticResetScopeClosed": static_reset_scope_closed,
        "selectorOrderResetGapClosed": selector_order_reset_closed,
        "routeOrderProven": route_order_proven,
        "selectorMergeGapOpen": selector_merge_gap_open,
        "fillExecutionOrderProofFound": fill_execution_order_gap.get("proofFound"),
        "fillSiteExecutionContextProven": fill_site_execution_context.get(
            "fillSiteExecutionContextProven"
        ),
        "nextProofFocus": "fill-site execution/order before current reader",
    }
    left_overrun_activation_runtime_split = {
        "classification": (
            "left-overrun-activation-fill-not-observed"
            if left_overrun_activation_branch_state_poll.get("available")
            and left_overrun_activation_branch_state_poll.get("anyReachedPublicSaveSelector") is True
            and left_overrun_activation_branch_state_poll.get("secondaryBranchStateAllZero") is True
            else "not-classified"
        ),
        "publicPredecessorReached": (
            left_overrun_activation_branch_state_poll.get("anyReachedPublicSaveSelector") is True
        ),
        "publicRouteReached": left_overrun_activation_branch_state_poll.get("anyReachedRouteSelectorContext") is True,
        "observedStateHexes": left_overrun_activation_branch_state_poll.get("secondaryBranchStateHexes") or [],
        "expectedFillHexes": left_overrun_activation_branch_state_poll.get("predecessorFillHypothesisHexes") or [],
        "observedMatchesFill": left_overrun_activation_branch_state_poll.get("matchesPredecessorFillHypothesis"),
        "observedAllZero": left_overrun_activation_branch_state_poll.get("secondaryBranchStateAllZero"),
        "activeSelectionFlagHex": left_overrun_activation_branch_state_poll.get("activeSelectionFlagHex"),
        "nextProofFocus": "decoded fill-fragment entry or a route-relevant selector 2:0 runtime trace",
    }
    nearest_exit_runtime_split = {
        "classification": (
            "nearest-exit-fill-not-observed"
            if nearest_exit_branch_state_poll.get("available")
            and nearest_exit_branch_state_poll.get("anyReachedPublicSaveSelector") is True
            and nearest_exit_branch_state_poll.get("secondaryBranchStateAllZero") is True
            else "not-classified"
        ),
        "publicPredecessorReached": nearest_exit_branch_state_poll.get("anyReachedPublicSaveSelector") is True,
        "publicRouteReached": nearest_exit_branch_state_poll.get("anyReachedRouteSelectorContext") is True,
        "observedStateHexes": nearest_exit_branch_state_poll.get("secondaryBranchStateHexes") or [],
        "expectedFillHexes": nearest_exit_branch_state_poll.get("predecessorFillHypothesisHexes") or [],
        "observedMatchesFill": nearest_exit_branch_state_poll.get("matchesPredecessorFillHypothesis"),
        "observedAllZero": nearest_exit_branch_state_poll.get("secondaryBranchStateAllZero"),
        "activeSelectionFlagHex": nearest_exit_branch_state_poll.get("activeSelectionFlagHex"),
        "targetedExitCandidates": nearest_exit_branch_state_poll.get("targetedExitCandidates") or [],
        "nextProofFocus": "captured selector 2:0 save, watchpoint trace, or decoded non-linear VM path",
    }
    reciprocal_exit_runtime_split = {
        "classification": (
            "reciprocal-exits-fill-not-observed"
            if reciprocal_exit_branch_state_poll.get("available")
            and reciprocal_exit_branch_state_poll.get("anyReachedPublicSaveSelector") is True
            and reciprocal_exit_branch_state_poll.get("secondaryBranchStateAllZero") is True
            else "not-classified"
        ),
        "publicPredecessorReached": reciprocal_exit_branch_state_poll.get("anyReachedPublicSaveSelector") is True,
        "publicRouteReached": reciprocal_exit_branch_state_poll.get("anyReachedRouteSelectorContext") is True,
        "observedStateHexes": reciprocal_exit_branch_state_poll.get("secondaryBranchStateHexes") or [],
        "expectedFillHexes": reciprocal_exit_branch_state_poll.get("predecessorFillHypothesisHexes") or [],
        "observedMatchesFill": reciprocal_exit_branch_state_poll.get("matchesPredecessorFillHypothesis"),
        "observedAllZero": reciprocal_exit_branch_state_poll.get("secondaryBranchStateAllZero"),
        "activeSelectionFlagHex": reciprocal_exit_branch_state_poll.get("activeSelectionFlagHex"),
        "targetedExitCandidates": reciprocal_exit_branch_state_poll.get("targetedExitCandidates") or [],
        "nextProofFocus": "captured selector 2:0 save, watchpoint trace, or decoded non-linear VM path",
    }
    coordinate_runtime_split = {
        "classification": (
            "coordinate-target-not-observed"
            if coordinate_branch_state_poll.get("available")
            and coordinate_branch_state_poll.get("anyReachedPublicSaveSelector") is True
            and coordinate_branch_state_poll.get("coordinateAnyTargetTileObserved") is False
            else coordinate_branch_state_poll.get("coordinateAnalysisClassification") or "not-classified"
        ),
        "publicPredecessorReached": coordinate_branch_state_poll.get("anyReachedPublicSaveSelector") is True,
        "publicRouteReached": coordinate_branch_state_poll.get("anyReachedRouteSelectorContext") is True,
        "observedStateHexes": coordinate_branch_state_poll.get("secondaryBranchStateHexes") or [],
        "expectedFillHexes": coordinate_branch_state_poll.get("predecessorFillHypothesisHexes") or [],
        "observedMatchesFill": coordinate_branch_state_poll.get("matchesPredecessorFillHypothesis"),
        "observedAllZero": coordinate_branch_state_poll.get("secondaryBranchStateAllZero"),
        "activeSelectionFlagHex": coordinate_branch_state_poll.get("activeSelectionFlagHex"),
        "coordinateAnyStartTileObserved": coordinate_branch_state_poll.get("coordinateAnyStartTileObserved"),
        "coordinateAnyTargetTileObserved": coordinate_branch_state_poll.get("coordinateAnyTargetTileObserved"),
        "coordinateRows": coordinate_branch_state_poll.get("coordinateRows") or [],
        "nextProofFocus": "find the runtime gameplay object/position source or capture a real selector 2:0 save",
    }
    trail_start_runtime_split = {
        "classification": trail_start_branch_state_poll.get("trailStartClassification") or "not-classified",
        "publicPredecessorReached": trail_start_branch_state_poll.get("anyReachedPublicSaveSelector") is True,
        "publicRouteReached": trail_start_branch_state_poll.get("anyReachedRouteSelectorContext") is True,
        "observedStateHexes": trail_start_branch_state_poll.get("secondaryBranchStateHexes") or [],
        "expectedFillHexes": trail_start_branch_state_poll.get("predecessorFillHypothesisHexes") or [],
        "observedMatchesFill": trail_start_branch_state_poll.get("matchesPredecessorFillHypothesis"),
        "observedAllZero": trail_start_branch_state_poll.get("secondaryBranchStateAllZero"),
        "activeSelectionFlagHex": trail_start_branch_state_poll.get("activeSelectionFlagHex"),
        "trailAnyStartTileObserved": trail_start_branch_state_poll.get("trailAnyStartTileObserved"),
        "trailAnyTargetTileObserved": trail_start_branch_state_poll.get("trailAnyTargetTileObserved"),
        "trailAnyActorMovementObserved": trail_start_branch_state_poll.get("trailAnyActorMovementObserved"),
        "trailAnyTrailMovementObserved": trail_start_branch_state_poll.get("trailAnyTrailMovementObserved"),
        "trailRows": trail_start_branch_state_poll.get("trailRows") or [],
        "nextProofFocus": "selector 2:0/current-root observation or branch-state fill on the moving trail/camera path",
    }
    trail_left_overrun_runtime_split = {
        "classification": (
            trail_left_overrun_branch_state_poll.get("trailLeftOverrunClassification") or "not-classified"
        ),
        "publicPredecessorReached": trail_left_overrun_branch_state_poll.get("anyReachedPublicSaveSelector") is True,
        "publicRouteReached": trail_left_overrun_branch_state_poll.get("anyReachedRouteSelectorContext") is True,
        "observedStateHexes": trail_left_overrun_branch_state_poll.get("secondaryBranchStateHexes") or [],
        "expectedFillHexes": trail_left_overrun_branch_state_poll.get("predecessorFillHypothesisHexes") or [],
        "observedMatchesFill": trail_left_overrun_branch_state_poll.get("matchesPredecessorFillHypothesis"),
        "observedAllZero": trail_left_overrun_branch_state_poll.get("secondaryBranchStateAllZero"),
        "activeSelectionFlagHex": trail_left_overrun_branch_state_poll.get("activeSelectionFlagHex"),
        "cameraTargetObserved": trail_left_overrun_branch_state_poll.get(
            "trailLeftOverrunAnyCameraTargetObserved"
        ),
        "cameraOutsideObserved": trail_left_overrun_branch_state_poll.get(
            "trailLeftOverrunAnyCameraOutsideObserved"
        ),
        "actorTargetObserved": trail_left_overrun_branch_state_poll.get(
            "trailLeftOverrunAnyActorTargetObserved"
        ),
        "trailTargetObserved": trail_left_overrun_branch_state_poll.get(
            "trailLeftOverrunAnyTrailTargetObserved"
        ),
        "trailLeftOverrunRows": trail_left_overrun_branch_state_poll.get("trailLeftOverrunRows") or [],
        "nextProofFocus": "watch the edge-overrun transition producer or capture selector 2:0/current-root",
    }
    highfreq_runtime_split = {
        "classification": (
            "high-frequency-fill-not-observed"
            if highfreq_branch_state_poll.get("available")
            and highfreq_branch_state_poll.get("anyReachedPublicSaveSelector") is True
            and highfreq_branch_state_poll.get("secondaryBranchStateAllZero") is True
            else "not-classified"
        ),
        "publicPredecessorReached": highfreq_branch_state_poll.get("anyReachedPublicSaveSelector") is True,
        "publicRouteReached": highfreq_branch_state_poll.get("anyReachedRouteSelectorContext") is True,
        "observedStateHexes": highfreq_branch_state_poll.get("secondaryBranchStateHexes") or [],
        "expectedFillHexes": highfreq_branch_state_poll.get("predecessorFillHypothesisHexes") or [],
        "observedMatchesFill": highfreq_branch_state_poll.get("matchesPredecessorFillHypothesis"),
        "observedAllZero": highfreq_branch_state_poll.get("secondaryBranchStateAllZero"),
        "activeSelectionFlagHex": highfreq_branch_state_poll.get("activeSelectionFlagHex"),
        "pollIntervalSeconds": highfreq_branch_state_poll.get("pollIntervalSeconds"),
        "nextProofFocus": "fill-site execution/order before selected-pointer reader",
    }
    evidence = [
        {
            "kind": "predecessor-fill-effect",
            "status": "would-pass-current-reader" if predecessor_fill_would_pass else "not-proven",
            "detail": (
                f"fill={predecessor_state_effect.get('fillValueHex')} "
                f"sites={list_text(predecessor_state_effect.get('predecessorFillVas'))}; "
                f"allStartsPassReader={predecessor_state_effect.get('allStartsPassReader')}"
            ),
        },
        {
            "kind": "predecessor-dispatch-slice-dependency",
            "status": (
                "slice-runtime-proof-missing"
                if fill_execution_order_gap.get("predecessorDispatchSliceRuntimeProofFound") is False
                and fill_execution_order_gap.get("predecessorDescriptorDependsOnSaveSelectorSliceModel") is True
                else "review-required"
            ),
            "detail": (
                f"sliceRuntimeProof={fill_execution_order_gap.get('predecessorDispatchSliceRuntimeProofFound')}; "
                f"dispatchTableProof={fill_execution_order_gap.get('predecessorDispatchTableProofFound')}; "
                "dispatchFailedGates="
                f"{list_text(fill_execution_order_gap.get('predecessorDispatchTableFailedGateIds'))}; "
                "dispatchMissingEvidenceCount="
                f"{len(fill_execution_order_gap.get('predecessorDispatchTableMissingEvidence') or [])}; "
                f"dispatchEvidenceRefs={fill_execution_order_gap.get('predecessorDispatchTableEvidenceRefCount')}; "
                f"descriptorDependsOnSlice={fill_execution_order_gap.get('predecessorDescriptorDependsOnSaveSelectorSliceModel')}; "
                f"rows={fill_execution_order_gap.get('predecessorDispatchSliceRowCount')}; "
                f"sliceData={fill_execution_order_gap.get('predecessorDispatchSliceDataDescriptorCount')}; "
                f"rawCode={fill_execution_order_gap.get('predecessorDispatchRawGeneralCodeCount')}; "
                f"rawDiffers={fill_execution_order_gap.get('predecessorDispatchRawGeneralDiffersFromSliceCount')}; "
                f"byteReachable={fill_execution_order_gap.get('predecessorDispatchSliceGenericByteReachableCount')}; "
                f"requiresTableBase={fill_execution_order_gap.get('predecessorDispatchSliceRequiresTableBaseSwitchCount')}; "
                f"dynamicDispatches={fill_execution_order_gap.get('predecessorDispatchDynamicIndexedDispatchRowCount')}/"
                f"{fill_execution_order_gap.get('predecessorDispatchDynamicScopeTableCallbackCount')}/"
                f"{fill_execution_order_gap.get('predecessorDispatchDynamicSaveSelectorTableImmediateNearCount')}; "
                f"dynamicTableBaseCandidate="
                f"{fill_execution_order_gap.get('predecessorDispatchDynamicSaveSelectorTableBaseSwitchStaticCandidateFound')}; "
                "tableBaseArithmeticRows="
                f"{fill_execution_order_gap.get('predecessorDispatchSaveSelectorTableBaseArithmeticRowCount')}; "
                "tableBaseArithmeticCandidates="
                f"{fill_execution_order_gap.get('predecessorDispatchSaveSelectorTableBaseArithmeticCandidateCount')}"
            ),
        },
        {
            "kind": "predecessor-raw-generic-callgraph",
            "status": fill_execution_order_gap.get("rawGenericCallGraphClassification")
            or "not-available",
            "detail": (
                f"depth={fill_execution_order_gap.get('rawGenericCallGraphMaxDepth')}; "
                "functions/edges="
                f"{fill_execution_order_gap.get('rawGenericCallGraphReachableFunctionCount')}/"
                f"{fill_execution_order_gap.get('rawGenericCallGraphDirectCallEdgeCount')}; "
                "route/fill/currentImm="
                f"{fill_execution_order_gap.get('rawGenericCallGraphRouteImmediateHitCount')}/"
                f"{fill_execution_order_gap.get('rawGenericCallGraphFillImmediateHitCount')}/"
                f"{fill_execution_order_gap.get('rawGenericCallGraphCurrentImmediateHitCount')}; "
                "selected/branchImm="
                f"{fill_execution_order_gap.get('rawGenericCallGraphSelectedPointerImmediateHitCount')}/"
                f"{fill_execution_order_gap.get('rawGenericCallGraphBranchStateImmediateHitCount')}; "
                "route/fillTransfers="
                f"{fill_execution_order_gap.get('rawGenericCallGraphRouteDirectTransferHitCount')}/"
                f"{fill_execution_order_gap.get('rawGenericCallGraphFillDirectTransferHitCount')}; "
                "depthSensitivity="
                f"{fill_execution_order_gap.get('rawGenericCallGraphDepthSensitivityMaxDepthChecked')}/"
                f"{fill_execution_order_gap.get('rawGenericCallGraphDepthSensitivityProofAbsentAcrossCheckedDepths')}/"
                f"{fill_execution_order_gap.get('rawGenericCallGraphDepthSensitivityCountsStableAtAndBeyondDefaultDepth')}; "
                f"proof={fill_execution_order_gap.get('rawGenericCallGraphProofFound')}"
            ),
        },
        {
            "kind": "predecessor-local-tail",
            "status": "no-local-reset" if predecessor_local_tail_closed else "tail-reset-open",
            "detail": (
                f"tailRange={predecessor_tail_reset.get('tailRangeHex')}; "
                f"tailOpcode10={predecessor_tail_reset.get('tailOpcode10RowCount')}; "
                f"tailValidSecondary={predecessor_tail_reset.get('tailValidSecondaryFillCount')}; "
                f"localTailResetFound={predecessor_tail_reset.get('localTailResetFound')}"
            ),
        },
        {
            "kind": "static-secondary-reset-scope",
            "status": "static-scope-closed" if static_reset_scope_closed else "static-scope-open",
            "detail": (
                f"secondary={secondary_global_reset_gap.get('secondaryRangeHex')}; "
                f"directGlobalWriters={secondary_global_reset_gap.get('directGlobalSecondaryWriterCount')}; "
                f"unresolvedRefs={secondary_global_reset_gap.get('unresolvedGlobalSecondaryRefCount')}; "
                f"helperOpcode10Only={secondary_global_reset_gap.get('helperOnlyCalledInsideOpcode10Handler')}"
            ),
        },
        {
            "kind": "selector-order-reset-window",
            "status": "closed-in-selector-order" if selector_order_reset_closed else "open",
            "detail": (
                f"selectorAdjacent={predecessor_persistence_gap.get('selectorAdjacent')}; "
                f"intermediateSelectors={predecessor_persistence_gap.get('intermediateSelectorCount')}; "
                f"currentBeforeFrontierFills={route_scope.get('currentRootValidBeforeFrontierFillCount')}; "
                f"predecessorTailFills={route_scope.get('predecessorTailValidSecondaryFillCount')}"
            ),
        },
        {
            "kind": "runtime-execution-order",
            "status": "open" if runtime_order_gap_open else "proven",
            "detail": (
                f"routeOrderProven={route_order_proven}; "
                f"sourcePrevious={predecessor_route_order.get('sourceRoutePreviousSelector')}; "
                f"sourceOverlap={list_text(predecessor_route_order.get('sourceRoutePreviousConfirmedOverlap'))}; "
                f"predecessorTargetOnly={predecessor_route_order.get('predecessorIsTargetSideOnly')}; "
                f"globalResetRuledOut={global_reset_ruled_out}"
            ),
        },
        {
            "kind": "bounded-predecessor-progress-poll",
            "status": (
                "public-predecessor-observed-route-not-reached"
                if progress_poll.get("available")
                and progress_poll.get("anyReachedPublicSaveSelector") is True
                and progress_poll.get("anyReachedRouteSelectorContext") is False
                else "not-available"
            ),
            "detail": (
                "not run"
                if not progress_poll.get("available")
                else (
                    f"seq={progress_poll.get('sequenceCount')} samples={progress_poll.get('sampleCount')} "
                    f"prelude={progress_poll.get('prelude')} caseAliases={progress_poll.get('caseAliasesEnabled')} "
                    f"public={list_text(progress_poll.get('publicSaveSelectors'))} "
                    f"observed={list_text(progress_poll.get('observedSelectors'))} "
                    f"observedPublic={list_text(progress_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(progress_poll.get('inputQuality'))} "
                    f"publicHit={progress_poll.get('anyReachedPublicSaveSelector')} "
                    f"currentRoot={progress_poll.get('anyReachedCurrentRoot')} "
                    f"route2:0={progress_poll.get('anyReachedRouteSelectorContext')} "
                    f"routeHits={progress_poll.get('routeSelectorHitCount')} "
                    f"watch={progress_poll.get('watchValues')}"
                )
            ),
        },
        {
            "kind": "bounded-predecessor-direction-sweep-poll",
            "status": (
                "public-predecessor-direction-sweep-route-not-reached"
                if direction_sweep_poll.get("available")
                and direction_sweep_poll.get("anyReachedPublicSaveSelector") is True
                and direction_sweep_poll.get("anyReachedRouteSelectorContext") is False
                else "not-available"
            ),
            "detail": (
                "not run"
                if not direction_sweep_poll.get("available")
                else (
                    f"kind={direction_sweep_poll.get('stagedSaveKind')}; "
                    f"seq={direction_sweep_poll.get('sequenceCount')} "
                    f"samples={direction_sweep_poll.get('sampleCount')} "
                    f"prelude={direction_sweep_poll.get('prelude')} "
                    f"caseAliases={direction_sweep_poll.get('caseAliasesEnabled')} "
                    f"public={list_text(direction_sweep_poll.get('publicSaveSelectors'))} "
                    f"observed={list_text(direction_sweep_poll.get('observedSelectors'))} "
                    f"observedPublic={list_text(direction_sweep_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(direction_sweep_poll.get('inputQuality'))} "
                    f"publicHit={direction_sweep_poll.get('anyReachedPublicSaveSelector')} "
                    f"currentRoot={direction_sweep_poll.get('anyReachedCurrentRoot')} "
                    f"route2:0={direction_sweep_poll.get('anyReachedRouteSelectorContext')} "
                    f"routeHits={direction_sweep_poll.get('routeSelectorHitCount')} "
                    f"watch={direction_sweep_poll.get('watchValues')}"
                )
            ),
        },
        {
            "kind": "bounded-predecessor-branch-state-poll",
            "status": (
                "public-predecessor-branch-state-all-zero-route-not-reached"
                if branch_state_poll.get("available")
                and branch_state_poll.get("secondaryBranchStateAllZero") is True
                and branch_state_poll.get("anyReachedRouteSelectorContext") is False
                else "not-available"
            ),
            "detail": (
                "not run"
                if not branch_state_poll.get("available")
                else (
                    f"kind={branch_state_poll.get('stagedSaveKind')}; "
                    f"seq={branch_state_poll.get('sequenceCount')} "
                    f"samples={branch_state_poll.get('sampleCount')} "
                    f"prelude={branch_state_poll.get('prelude')} "
                    f"caseAliases={branch_state_poll.get('caseAliasesEnabled')} "
                    f"observed={list_text(branch_state_poll.get('observedSelectors'))} "
                    f"observedPublic={list_text(branch_state_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(branch_state_poll.get('inputQuality'))} "
                    f"activeFlag={branch_state_poll.get('activeSelectionFlagHex')} "
                    f"secondaryState={list_text(branch_state_poll.get('secondaryBranchStateHexes'))} "
                    f"expectedFill={list_text(branch_state_poll.get('predecessorFillHypothesisHexes'))} "
                    f"matchesFill={branch_state_poll.get('matchesPredecessorFillHypothesis')} "
                    f"allZero={branch_state_poll.get('secondaryBranchStateAllZero')} "
                    f"route2:0={branch_state_poll.get('anyReachedRouteSelectorContext')} "
                    f"watch={branch_state_poll.get('watchValues')}"
                )
            ),
        },
        {
            "kind": "bounded-predecessor-left-overrun-activation-branch-state-poll",
            "status": (
                "left-overrun-activation-public-predecessor-all-zero-route-not-reached"
                if left_overrun_activation_branch_state_poll.get("available")
                and left_overrun_activation_branch_state_poll.get("secondaryBranchStateAllZero") is True
                and left_overrun_activation_branch_state_poll.get("anyReachedRouteSelectorContext") is False
                else "not-available"
            ),
            "detail": (
                "not run"
                if not left_overrun_activation_branch_state_poll.get("available")
                else (
                    f"kind={left_overrun_activation_branch_state_poll.get('stagedSaveKind')}; "
                    f"seq={left_overrun_activation_branch_state_poll.get('sequenceCount')} "
                    f"samples={left_overrun_activation_branch_state_poll.get('sampleCount')} "
                    f"prelude={left_overrun_activation_branch_state_poll.get('prelude')} "
                    f"caseAliases={left_overrun_activation_branch_state_poll.get('caseAliasesEnabled')} "
                    f"observed={list_text(left_overrun_activation_branch_state_poll.get('observedSelectors'))} "
                    "observedPublic="
                    f"{list_text(left_overrun_activation_branch_state_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(left_overrun_activation_branch_state_poll.get('inputQuality'))} "
                    f"activeFlag={left_overrun_activation_branch_state_poll.get('activeSelectionFlagHex')} "
                    f"secondaryState={list_text(left_overrun_activation_branch_state_poll.get('secondaryBranchStateHexes'))} "
                    "expectedFill="
                    f"{list_text(left_overrun_activation_branch_state_poll.get('predecessorFillHypothesisHexes'))} "
                    f"matchesFill={left_overrun_activation_branch_state_poll.get('matchesPredecessorFillHypothesis')} "
                    f"allZero={left_overrun_activation_branch_state_poll.get('secondaryBranchStateAllZero')} "
                    f"route2:0={left_overrun_activation_branch_state_poll.get('anyReachedRouteSelectorContext')} "
                    f"watch={left_overrun_activation_branch_state_poll.get('watchValues')}"
                )
            ),
        },
        {
            "kind": "bounded-predecessor-nearest-exit-branch-state-poll",
            "status": (
                "nearest-exit-public-predecessor-all-zero-route-not-reached"
                if nearest_exit_branch_state_poll.get("available")
                and nearest_exit_branch_state_poll.get("secondaryBranchStateAllZero") is True
                and nearest_exit_branch_state_poll.get("anyReachedRouteSelectorContext") is False
                else "not-available"
            ),
            "detail": (
                "not run"
                if not nearest_exit_branch_state_poll.get("available")
                else (
                    f"kind={nearest_exit_branch_state_poll.get('stagedSaveKind')}; "
                    f"seq={nearest_exit_branch_state_poll.get('sequenceCount')} "
                    f"samples={nearest_exit_branch_state_poll.get('sampleCount')} "
                    f"prelude={nearest_exit_branch_state_poll.get('prelude')} "
                    f"caseAliases={nearest_exit_branch_state_poll.get('caseAliasesEnabled')} "
                    f"observed={list_text(nearest_exit_branch_state_poll.get('observedSelectors'))} "
                    "observedPublic="
                    f"{list_text(nearest_exit_branch_state_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(nearest_exit_branch_state_poll.get('inputQuality'))} "
                    f"activeFlag={nearest_exit_branch_state_poll.get('activeSelectionFlagHex')} "
                    f"secondaryState={list_text(nearest_exit_branch_state_poll.get('secondaryBranchStateHexes'))} "
                    "expectedFill="
                    f"{list_text(nearest_exit_branch_state_poll.get('predecessorFillHypothesisHexes'))} "
                    f"matchesFill={nearest_exit_branch_state_poll.get('matchesPredecessorFillHypothesis')} "
                    f"allZero={nearest_exit_branch_state_poll.get('secondaryBranchStateAllZero')} "
                    f"route2:0={nearest_exit_branch_state_poll.get('anyReachedRouteSelectorContext')} "
                    f"targets={nearest_exit_branch_state_poll.get('targetedExitCandidates')}"
                )
            ),
        },
        {
            "kind": "bounded-predecessor-reciprocal-exit-branch-state-poll",
            "status": (
                "reciprocal-exits-public-predecessor-all-zero-route-not-reached"
                if reciprocal_exit_branch_state_poll.get("available")
                and reciprocal_exit_branch_state_poll.get("secondaryBranchStateAllZero") is True
                and reciprocal_exit_branch_state_poll.get("anyReachedRouteSelectorContext") is False
                else "not-available"
            ),
            "detail": (
                "not run"
                if not reciprocal_exit_branch_state_poll.get("available")
                else (
                    f"kind={reciprocal_exit_branch_state_poll.get('stagedSaveKind')}; "
                    f"seq={reciprocal_exit_branch_state_poll.get('sequenceCount')} "
                    f"samples={reciprocal_exit_branch_state_poll.get('sampleCount')} "
                    f"prelude={reciprocal_exit_branch_state_poll.get('prelude')} "
                    f"caseAliases={reciprocal_exit_branch_state_poll.get('caseAliasesEnabled')} "
                    f"observed={list_text(reciprocal_exit_branch_state_poll.get('observedSelectors'))} "
                    "observedPublic="
                    f"{list_text(reciprocal_exit_branch_state_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(reciprocal_exit_branch_state_poll.get('inputQuality'))} "
                    f"activeFlag={reciprocal_exit_branch_state_poll.get('activeSelectionFlagHex')} "
                    f"secondaryState={list_text(reciprocal_exit_branch_state_poll.get('secondaryBranchStateHexes'))} "
                    "expectedFill="
                    f"{list_text(reciprocal_exit_branch_state_poll.get('predecessorFillHypothesisHexes'))} "
                    f"matchesFill={reciprocal_exit_branch_state_poll.get('matchesPredecessorFillHypothesis')} "
                    f"allZero={reciprocal_exit_branch_state_poll.get('secondaryBranchStateAllZero')} "
                    f"route2:0={reciprocal_exit_branch_state_poll.get('anyReachedRouteSelectorContext')} "
                    f"targets={reciprocal_exit_branch_state_poll.get('targetedExitCandidates')}"
                )
            ),
        },
        {
            "kind": "bounded-predecessor-coordinate-branch-state-poll",
            "status": (
                "coordinate-target-not-observed"
                if coordinate_branch_state_poll.get("available")
                and coordinate_branch_state_poll.get("coordinateAnyTargetTileObserved") is False
                else "not-available"
            ),
            "detail": (
                "not run"
                if not coordinate_branch_state_poll.get("available")
                else (
                    f"kind={coordinate_branch_state_poll.get('stagedSaveKind')}; "
                    f"seq={coordinate_branch_state_poll.get('sequenceCount')} "
                    f"samples={coordinate_branch_state_poll.get('sampleCount')} "
                    f"prelude={coordinate_branch_state_poll.get('prelude')} "
                    f"caseAliases={coordinate_branch_state_poll.get('caseAliasesEnabled')} "
                    f"observed={list_text(coordinate_branch_state_poll.get('observedSelectors'))} "
                    "observedPublic="
                    f"{list_text(coordinate_branch_state_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(coordinate_branch_state_poll.get('inputQuality'))} "
                    f"activeFlag={coordinate_branch_state_poll.get('activeSelectionFlagHex')} "
                    f"secondaryState={list_text(coordinate_branch_state_poll.get('secondaryBranchStateHexes'))} "
                    f"matchesFill={coordinate_branch_state_poll.get('matchesPredecessorFillHypothesis')} "
                    f"allZero={coordinate_branch_state_poll.get('secondaryBranchStateAllZero')} "
                    f"route2:0={coordinate_branch_state_poll.get('anyReachedRouteSelectorContext')} "
                    f"coordinateClass={coordinate_branch_state_poll.get('coordinateAnalysisClassification')} "
                    f"startObserved={coordinate_branch_state_poll.get('coordinateAnyStartTileObserved')} "
                    f"targetObserved={coordinate_branch_state_poll.get('coordinateAnyTargetTileObserved')} "
                    f"rows={coordinate_branch_state_poll.get('coordinateRows')}"
                )
            ),
        },
        {
            "kind": "bounded-predecessor-trail-start-branch-state-poll",
            "status": (
                trail_start_branch_state_poll.get("trailStartClassification") or "not-available"
                if trail_start_branch_state_poll.get("available")
                else "not-available"
            ),
            "detail": (
                "not run"
                if not trail_start_branch_state_poll.get("available")
                else (
                    f"kind={trail_start_branch_state_poll.get('stagedSaveKind')}; "
                    f"seq={trail_start_branch_state_poll.get('sequenceCount')} "
                    f"samples={trail_start_branch_state_poll.get('sampleCount')} "
                    f"prelude={trail_start_branch_state_poll.get('prelude')} "
                    f"caseAliases={trail_start_branch_state_poll.get('caseAliasesEnabled')} "
                    f"observed={list_text(trail_start_branch_state_poll.get('observedSelectors'))} "
                    "observedPublic="
                    f"{list_text(trail_start_branch_state_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(trail_start_branch_state_poll.get('inputQuality'))} "
                    f"activeFlag={trail_start_branch_state_poll.get('activeSelectionFlagHex')} "
                    f"secondaryState={list_text(trail_start_branch_state_poll.get('secondaryBranchStateHexes'))} "
                    f"matchesFill={trail_start_branch_state_poll.get('matchesPredecessorFillHypothesis')} "
                    f"allZero={trail_start_branch_state_poll.get('secondaryBranchStateAllZero')} "
                    f"route2:0={trail_start_branch_state_poll.get('anyReachedRouteSelectorContext')} "
                    f"trailClass={trail_start_branch_state_poll.get('trailStartClassification')} "
                    f"trailStartObserved={trail_start_branch_state_poll.get('trailAnyStartTileObserved')} "
                    f"trailTargetObserved={trail_start_branch_state_poll.get('trailAnyTargetTileObserved')} "
                    f"actorMove={trail_start_branch_state_poll.get('trailAnyActorMovementObserved')} "
                    f"trailMove={trail_start_branch_state_poll.get('trailAnyTrailMovementObserved')} "
                    f"rows={trail_start_branch_state_poll.get('trailRows')}"
                )
            ),
        },
        {
            "kind": "bounded-predecessor-trail-left-overrun-branch-state-poll",
            "status": (
                trail_left_overrun_branch_state_poll.get("trailLeftOverrunClassification") or "not-available"
                if trail_left_overrun_branch_state_poll.get("available")
                else "not-available"
            ),
            "detail": (
                "not run"
                if not trail_left_overrun_branch_state_poll.get("available")
                else (
                    f"kind={trail_left_overrun_branch_state_poll.get('stagedSaveKind')}; "
                    f"seq={trail_left_overrun_branch_state_poll.get('sequenceCount')} "
                    f"samples={trail_left_overrun_branch_state_poll.get('sampleCount')} "
                    f"prelude={trail_left_overrun_branch_state_poll.get('prelude')} "
                    f"caseAliases={trail_left_overrun_branch_state_poll.get('caseAliasesEnabled')} "
                    f"observed={list_text(trail_left_overrun_branch_state_poll.get('observedSelectors'))} "
                    "observedPublic="
                    f"{list_text(trail_left_overrun_branch_state_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(trail_left_overrun_branch_state_poll.get('inputQuality'))} "
                    f"activeFlag={trail_left_overrun_branch_state_poll.get('activeSelectionFlagHex')} "
                    f"secondaryState="
                    f"{list_text(trail_left_overrun_branch_state_poll.get('secondaryBranchStateHexes'))} "
                    f"matchesFill={trail_left_overrun_branch_state_poll.get('matchesPredecessorFillHypothesis')} "
                    f"allZero={trail_left_overrun_branch_state_poll.get('secondaryBranchStateAllZero')} "
                    f"route2:0={trail_left_overrun_branch_state_poll.get('anyReachedRouteSelectorContext')} "
                    "overrunClass="
                    f"{trail_left_overrun_branch_state_poll.get('trailLeftOverrunClassification')} "
                    "cameraTarget="
                    f"{trail_left_overrun_branch_state_poll.get('trailLeftOverrunAnyCameraTargetObserved')} "
                    "cameraOutside="
                    f"{trail_left_overrun_branch_state_poll.get('trailLeftOverrunAnyCameraOutsideObserved')} "
                    "actorTarget="
                    f"{trail_left_overrun_branch_state_poll.get('trailLeftOverrunAnyActorTargetObserved')} "
                    "trailTarget="
                    f"{trail_left_overrun_branch_state_poll.get('trailLeftOverrunAnyTrailTargetObserved')} "
                    f"rows={trail_left_overrun_branch_state_poll.get('trailLeftOverrunRows')}"
                )
            ),
        },
        {
            "kind": "high-frequency-predecessor-branch-state-poll",
            "status": (
                "high-frequency-public-predecessor-all-zero-route-not-reached"
                if highfreq_branch_state_poll.get("available")
                and highfreq_branch_state_poll.get("secondaryBranchStateAllZero") is True
                and highfreq_branch_state_poll.get("anyReachedRouteSelectorContext") is False
                else "not-available"
            ),
            "detail": (
                "not run"
                if not highfreq_branch_state_poll.get("available")
                else (
                    f"kind={highfreq_branch_state_poll.get('stagedSaveKind')}; "
                    f"interval={highfreq_branch_state_poll.get('pollIntervalSeconds')} "
                    f"seq={highfreq_branch_state_poll.get('sequenceCount')} "
                    f"samples={highfreq_branch_state_poll.get('sampleCount')} "
                    f"prelude={highfreq_branch_state_poll.get('prelude')} "
                    f"caseAliases={highfreq_branch_state_poll.get('caseAliasesEnabled')} "
                    f"observed={list_text(highfreq_branch_state_poll.get('observedSelectors'))} "
                    "observedPublic="
                    f"{list_text(highfreq_branch_state_poll.get('observedPublicSaveSelectors'))} "
                    f"input={input_quality_brief(highfreq_branch_state_poll.get('inputQuality'))} "
                    f"activeFlag={highfreq_branch_state_poll.get('activeSelectionFlagHex')} "
                    f"secondaryState={list_text(highfreq_branch_state_poll.get('secondaryBranchStateHexes'))} "
                    "expectedFill="
                    f"{list_text(highfreq_branch_state_poll.get('predecessorFillHypothesisHexes'))} "
                    f"matchesFill={highfreq_branch_state_poll.get('matchesPredecessorFillHypothesis')} "
                    f"allZero={highfreq_branch_state_poll.get('secondaryBranchStateAllZero')} "
                    f"route2:0={highfreq_branch_state_poll.get('anyReachedRouteSelectorContext')} "
                    f"watch={highfreq_branch_state_poll.get('watchValues')}"
                )
            ),
        },
        {
            "kind": "fill-site-execution-context",
            "status": (
                "blocked"
                if fill_execution_order_gap.get("available")
                and fill_site_execution_context.get("available")
                and fill_site_execution_context.get("fillSiteExecutionContextProven") is not True
                else "not-available"
            ),
            "detail": (
                "not run"
                if not fill_execution_order_gap.get("available")
                or not fill_site_execution_context.get("available")
                else (
                    f"localTrace={fill_execution_order_gap.get('localFillTraceStartHex')}->"
                    f"{fill_execution_order_gap.get('localFillTraceStopHex')} "
                    f"reason={fill_execution_order_gap.get('localFillTraceStopReason')} "
                    f"handler={fill_execution_order_gap.get('localFillTraceStopHandlerHex')}; "
                    f"rootEntryReach={fill_execution_order_gap.get('rootEntryFixedTraversalFillSitesReachable')}; "
                    f"encoded={fill_execution_order_gap.get('encodedFillEntryClassification')} "
                    f"raw={fill_execution_order_gap.get('encodedFillEntryRawScalarCandidateCount')} "
                    f"rootTailRaw={fill_execution_order_gap.get('encodedFillEntryRootTailRawScalarCandidateCount')} "
                    f"promoting={fill_execution_order_gap.get('encodedFillEntryPromotingCandidateCount')} "
                    "rawScalarReject="
                    f"{fill_execution_order_gap.get('encodedRawScalarRejectionClassification')} "
                    "rawScalarNoFixed/noBranch/branchAttached/scalarOnly="
                    f"{fill_execution_order_gap.get('encodedRawScalarNoFixedAdvanceCount')}/"
                    f"{fill_execution_order_gap.get('encodedRawScalarNoBranchJumpCount')}/"
                    f"{fill_execution_order_gap.get('encodedRawScalarBranchAttachedCount')}/"
                    f"{fill_execution_order_gap.get('encodedRawScalarScalarOnlyCount')}; "
                    "proofGates="
                    f"{fill_execution_order_gap.get('predecessorFillProofGateBlockedCount')}/"
                    f"{fill_execution_order_gap.get('predecessorFillProofGateCount')} "
                    f"pass={fill_execution_order_gap.get('predecessorFillProofGatePassCount')} "
                    f"allBlocked={fill_execution_order_gap.get('predecessorFillAllProofGatesBlocked')} "
                    "blockedIds="
                    f"{list_text(fill_execution_order_gap.get('predecessorFillProofGateBlockedIds'))}; "
                    f"polls={fill_site_execution_context.get('branchStatePollCount')}/"
                    f"{fill_site_execution_context.get('branchStatePollSequenceCount')}/"
                    f"{fill_site_execution_context.get('branchStatePollSampleCount')} "
                    f"public={fill_site_execution_context.get('branchStatePollPublicPredecessorHitCount')} "
                    f"currentRoot={fill_site_execution_context.get('branchStatePollCurrentRootHitCount')} "
                    f"route2:0={fill_site_execution_context.get('branchStatePollRouteSelectorHitCount')} "
                    f"fillMatches={fill_site_execution_context.get('branchStatePollFillMatchCount')} "
                    f"allZero={fill_site_execution_context.get('branchStatePollAllZeroCount')} "
                    f"targetStatus={fill_site_execution_context.get('branchStatePollTargetObservationStatus')} "
                    "descriptorEdgeReject="
                    f"{fill_site_execution_context.get('descriptorEdgeRejectionClassification')} "
                    "descriptorRouteEdges="
                    f"{fill_site_execution_context.get('descriptorEdgeRootRouteExecutionTargetEdgeCount')}/"
                    f"{fill_site_execution_context.get('descriptorEdgeFillRouteExecutionTargetEdgeCount')} "
                    "tableBaseReject="
                    f"{fill_site_execution_context.get('predecessorDispatchTableBaseRejectionClassification')} "
                    "tableBaseArithmeticRows="
                    f"{fill_site_execution_context.get('predecessorDispatchSaveSelectorTableBaseArithmeticRowCount')} "
                    "tableBaseArithmeticCandidates="
                    f"{fill_site_execution_context.get('predecessorDispatchSaveSelectorTableBaseArithmeticCandidateCount')} "
                    f"fieldEntryCandidates={(fill_site_execution_context.get('fieldEntrySequenceContext') or {}).get('fieldEntryCandidateCount')} "
                    f"snapshotRouteCandidates={(fill_site_execution_context.get('fieldEntrySequenceContext') or {}).get('snapshotRouteCandidateCount')} "
                    "branchGatePreserve="
                    f"{fill_site_execution_context.get('branchGateKnownOpcodeStatePreservationStatus')} "
                    "branchGateSameOffset="
                    f"{fill_site_execution_context.get('branchGateSameTableAndOffset')}/"
                    f"{fill_site_execution_context.get('branchGateSameSelectionBufferOffsetHex')} "
                    "branchGateSameOffsetWriteRead="
                    f"{fill_site_execution_context.get('branchGatePostWriterSameOffsetWriteCount')}/"
                    f"{fill_site_execution_context.get('branchGatePostWriterSameOffsetReadCount')} "
                    "branchGateOtherWrites="
                    f"{fill_site_execution_context.get('branchGatePostWriterOtherOffsetWriteCount')}@"
                    f"{list_text(fill_site_execution_context.get('branchGatePostWriterOtherOffsetWriteOffsetsHex'))} "
                    "branchGateInvalidFillOffsets="
                    f"{list_text(fill_site_execution_context.get('branchGateInvalidSecondaryFillOffsetsHex'))} "
                    "coordinateReject="
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('coordinateSourceRejectionClassification')} "
                    "coordinateStartPtrStaticTrailImage="
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('publicSaveStartPointerTableTileHitCount')}/"
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('publicSaveStartStaticBaseHitCount')}/"
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('publicSaveStartTrailRingHitCount')}/"
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('publicSaveStartImageHitCount')} "
                    "coordinateTrailPtrStaticTrailImage="
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('observedTrailPointerTableTileHitCount')}/"
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('observedTrailStaticBaseHitCount')}/"
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('observedTrailTrailRingHitCount')}/"
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('observedTrailImageHitCount')} "
                    "coordinateReciprocalPtrStaticTrailImage="
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('reciprocalPointerTableTileHitCount')}/"
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('reciprocalStaticBaseHitCount')}/"
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('reciprocalTrailRingHitCount')}/"
                    f"{(fill_site_execution_context.get('coordinateSourceContext') or {}).get('reciprocalImageHitCount')} "
                    f"proof={fill_site_execution_context.get('fillSiteExecutionContextProven')}"
                )
            ),
        },
        {
            "kind": "runtime-branch-state-split",
            "status": (
                "fill-not-observed-after-public-predecessor"
                if runtime_split_classification == "public-predecessor-reached-fill-not-observed"
                else "not-classified"
            ),
            "detail": (
                f"classification={runtime_branch_state_split['classification']} "
                f"publicPredecessorReached={runtime_branch_state_split['publicPredecessorReached']} "
                f"activeFlag={runtime_branch_state_split['activeSelectionFlagHex']} "
                f"observed={list_text(runtime_branch_state_split['observedStateHexes'])} "
                f"expected={list_text(runtime_branch_state_split['expectedFillHexes'])} "
                f"matchesFill={runtime_branch_state_split['observedMatchesFill']} "
                f"allZero={runtime_branch_state_split['observedAllZero']} "
                f"staticNoLocalTailReset={runtime_branch_state_split['staticNoLocalTailReset']} "
                f"staticNoDirectGlobalSecondaryWriter={runtime_branch_state_split['staticNoDirectGlobalSecondaryWriter']} "
                f"staticHelperOpcode10Only={runtime_branch_state_split['staticHelperOpcode10Only']} "
                f"staticResetScopeClosed={runtime_branch_state_split['staticResetScopeClosed']} "
                f"next={runtime_branch_state_split['nextProofFocus']}"
            ),
        },
        {
            "kind": "selector-merge",
            "status": "open" if selector_merge_gap_open else "closed",
            "detail": (
                f"samePreviousContainsRoutePair={predecessor_route_order.get('samePreviousContainsRoutePair')}; "
                f"sourceCurrentBridge={merge_gap.get('sourceToCurrentBridgeHitCount')}/"
                f"{merge_gap.get('currentToSourceBridgeHitCount')}; "
                f"targetCurrentBridge={merge_gap.get('targetToCurrentBridgeHitCount')}/"
                f"{merge_gap.get('currentToTargetBridgeHitCount')}"
            ),
        },
        {
            "kind": "strict-hotspot",
            "status": "found" if strict_hotspot_found else "missing",
            "detail": (
                f"strictHotspotFound={strict_hotspot_found}; "
                f"eventTransitions={hotspot_gap.get('eventTransitionCount')}; "
                f"manifestPromotableSource={hotspot_gap.get('manifestPointPromotableSourceCount')}"
            ),
        },
    ]
    remaining_proofs = branch_state_execution_missing_evidence
    conclusion = (
        "The predecessor branch-state candidate is now narrow but still non-promoting: "
        "1:0's fill would make the current reader pass, the predecessor root does not locally reset it, "
        "and the known static secondary reset scope is closed. A public predecessor branch-state poll observed "
        "selector 1:0 but kept secondaryBranchState[0..11] all zero, and a targeted nearest-exit poll aimed at "
        "the closest map2_02d -> map1_01a geometry hint kept the same branch-state bytes all zero. "
        "The longer reciprocal-exit paths to the remaining map2_02d target-side hints also kept the same "
        "branch-state bytes all zero. The coordinate-qualified repeat did not observe any actor slot reaching "
        "the planned reciprocal target tiles, so the geometry-path negative evidence is now explicitly "
        "qualified by a runtime-position gap. A follow-up trail-start poll used the observed party trail "
        "(15,26) as the start source and saw trail/camera movement but no target actor/trail tile, no "
        "branch-state fill, and no selector 2:0/current-root hit; a left-edge overrun variant reached camera "
        "(1,14) without producing selector 2:0 or nonzero branch state. A 5ms high-frequency predecessor "
        "poll also reached public selector 1:0 while keeping secondaryBranchState[0..11] all zero. "
        "The remaining gap is execution, not static value math: "
        "selector-table adjacency still does not prove that the normal route executes 1:0 then 2:0, the selector "
        "merge shape remains open, and no strict map1_01a source hotspot has been found."
    )
    return {
        "source": "map1_01a",
        "target": "map2_02d",
        "predecessorSelector": predecessor_persistence_gap.get("predecessorSelector"),
        "predecessorRootHex": predecessor_persistence_gap.get("predecessorRootHex"),
        "currentSelector": predecessor_persistence_gap.get("currentSelector"),
        "currentRootHex": predecessor_persistence_gap.get("currentRootHex"),
        "secondaryBranchStateRangeHex": secondary_global_reset_gap.get("secondaryRangeHex")
        or secondary.get("rangeHex"),
        "predecessorFillValueHex": predecessor_state_effect.get("fillValueHex"),
        "predecessorFillVas": predecessor_state_effect.get("predecessorFillVas") or [],
        "predecessorFillWouldPassCurrentReader": predecessor_fill_would_pass,
        "predecessorTailRangeHex": predecessor_tail_reset.get("tailRangeHex"),
        "predecessorTailOpcode10RowCount": predecessor_tail_reset.get("tailOpcode10RowCount"),
        "predecessorTailValidSecondaryFillCount": predecessor_tail_reset.get("tailValidSecondaryFillCount"),
        "predecessorLocalTailResetFound": predecessor_tail_reset.get("localTailResetFound"),
        "directGlobalSecondaryWriterCount": secondary_global_reset_gap.get("directGlobalSecondaryWriterCount"),
        "unresolvedGlobalSecondaryRefCount": secondary_global_reset_gap.get("unresolvedGlobalSecondaryRefCount"),
        "helperOnlyCalledInsideOpcode10Handler": secondary_global_reset_gap.get(
            "helperOnlyCalledInsideOpcode10Handler"
        ),
        "helperDirectCallCount": helper.get("directCallCount"),
        "closedStaticResetScope": secondary_global_reset_gap.get("closedStaticResetScope"),
        "selectorOrderResetGapClosed": selector_order_reset_closed,
        "openRuntimeOrderOrBytecodeGap": runtime_order_gap_open,
        "globalResetRuledOut": global_reset_ruled_out,
        "predecessorDispatchTableProofFound": fill_execution_order_gap.get(
            "predecessorDispatchTableProofFound"
        ),
        "predecessorDispatchTableFailedGateIds": fill_execution_order_gap.get(
            "predecessorDispatchTableFailedGateIds"
        )
        or [],
        "predecessorDispatchTableMissingEvidence": fill_execution_order_gap.get(
            "predecessorDispatchTableMissingEvidence"
        )
        or [],
        "predecessorDispatchTableEvidenceRefCount": fill_execution_order_gap.get(
            "predecessorDispatchTableEvidenceRefCount"
        ),
        "predecessorDispatchSliceRuntimeProofFound": fill_execution_order_gap.get(
            "predecessorDispatchSliceRuntimeProofFound"
        ),
        "predecessorDescriptorDependsOnSaveSelectorSliceModel": fill_execution_order_gap.get(
            "predecessorDescriptorDependsOnSaveSelectorSliceModel"
        ),
        "predecessorDispatchSliceRowCount": fill_execution_order_gap.get(
            "predecessorDispatchSliceRowCount"
        ),
        "predecessorDispatchSliceDataDescriptorCount": fill_execution_order_gap.get(
            "predecessorDispatchSliceDataDescriptorCount"
        ),
        "predecessorDispatchRawGeneralCodeCount": fill_execution_order_gap.get(
            "predecessorDispatchRawGeneralCodeCount"
        ),
        "predecessorDispatchRawGeneralDiffersFromSliceCount": fill_execution_order_gap.get(
            "predecessorDispatchRawGeneralDiffersFromSliceCount"
        ),
        "predecessorDispatchSliceGenericByteReachableCount": fill_execution_order_gap.get(
            "predecessorDispatchSliceGenericByteReachableCount"
        ),
        "predecessorDispatchSliceRequiresTableBaseSwitchCount": fill_execution_order_gap.get(
            "predecessorDispatchSliceRequiresTableBaseSwitchCount"
        ),
        "predecessorDispatchDynamicIndexedDispatchRowCount": fill_execution_order_gap.get(
            "predecessorDispatchDynamicIndexedDispatchRowCount"
        ),
        "predecessorDispatchDynamicDwordScaledDispatchRowCount": fill_execution_order_gap.get(
            "predecessorDispatchDynamicDwordScaledDispatchRowCount"
        ),
        "predecessorDispatchDynamicScopeTableCallbackCount": fill_execution_order_gap.get(
            "predecessorDispatchDynamicScopeTableCallbackCount"
        ),
        "predecessorDispatchDynamicScopeTableCallbackSites": fill_execution_order_gap.get(
            "predecessorDispatchDynamicScopeTableCallbackSites"
        ) or [],
        "predecessorDispatchDynamicScopeTableCallbackRows": fill_execution_order_gap.get(
            "predecessorDispatchDynamicScopeTableCallbackRows"
        ) or [],
        "predecessorDispatchDynamicSaveSelectorTableImmediateNearCount": fill_execution_order_gap.get(
            "predecessorDispatchDynamicSaveSelectorTableImmediateNearCount"
        ),
        "predecessorDispatchDynamicSaveSelectorTableBaseCandidateCount": (
            fill_execution_order_gap.get(
                "predecessorDispatchDynamicSaveSelectorTableBaseCandidateCount"
            )
        ),
        "predecessorDispatchDynamicSaveSelectorTableBaseCandidateSites": (
            fill_execution_order_gap.get(
                "predecessorDispatchDynamicSaveSelectorTableBaseCandidateSites"
            )
            or []
        ),
        "predecessorDispatchDynamicSaveSelectorTableBaseCandidateRows": (
            fill_execution_order_gap.get(
                "predecessorDispatchDynamicSaveSelectorTableBaseCandidateRows"
            )
            or []
        ),
        "predecessorDispatchDynamicSaveSelectorTableBaseSwitchStaticCandidateFound": (
            fill_execution_order_gap.get(
                "predecessorDispatchDynamicSaveSelectorTableBaseSwitchStaticCandidateFound"
            )
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticRowCount": (
            fill_execution_order_gap.get(
                "predecessorDispatchSaveSelectorTableBaseArithmeticRowCount"
            )
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateCount": (
            fill_execution_order_gap.get(
                "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateCount"
            )
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateFound": (
            fill_execution_order_gap.get(
                "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateFound"
            )
        ),
        "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateRows": (
            fill_execution_order_gap.get(
                "predecessorDispatchSaveSelectorTableBaseArithmeticCandidateRows"
            )
            or []
        ),
        "predecessorDispatchTableBaseRejectionClassification": fill_execution_order_gap.get(
            "predecessorDispatchTableBaseRejectionClassification"
        ),
        "rawGenericCallGraphClassification": fill_execution_order_gap.get(
            "rawGenericCallGraphClassification"
        ),
        "rawGenericCallGraphProofFound": fill_execution_order_gap.get(
            "rawGenericCallGraphProofFound"
        ),
        "rawGenericCallGraphMaxDepth": fill_execution_order_gap.get(
            "rawGenericCallGraphMaxDepth"
        ),
        "rawGenericCallGraphReachableFunctionCount": fill_execution_order_gap.get(
            "rawGenericCallGraphReachableFunctionCount"
        ),
        "rawGenericCallGraphDirectCallEdgeCount": fill_execution_order_gap.get(
            "rawGenericCallGraphDirectCallEdgeCount"
        ),
        "rawGenericCallGraphRouteImmediateHitCount": fill_execution_order_gap.get(
            "rawGenericCallGraphRouteImmediateHitCount"
        ),
        "rawGenericCallGraphFillImmediateHitCount": fill_execution_order_gap.get(
            "rawGenericCallGraphFillImmediateHitCount"
        ),
        "rawGenericCallGraphCurrentImmediateHitCount": fill_execution_order_gap.get(
            "rawGenericCallGraphCurrentImmediateHitCount"
        ),
        "rawGenericCallGraphSelectedPointerImmediateHitCount": fill_execution_order_gap.get(
            "rawGenericCallGraphSelectedPointerImmediateHitCount"
        ),
        "rawGenericCallGraphBranchStateImmediateHitCount": fill_execution_order_gap.get(
            "rawGenericCallGraphBranchStateImmediateHitCount"
        ),
        "rawGenericCallGraphRouteDirectTransferHitCount": fill_execution_order_gap.get(
            "rawGenericCallGraphRouteDirectTransferHitCount"
        ),
        "rawGenericCallGraphFillDirectTransferHitCount": fill_execution_order_gap.get(
            "rawGenericCallGraphFillDirectTransferHitCount"
        ),
        "rawGenericCallGraphDepthSensitivityMaxDepthChecked": fill_execution_order_gap.get(
            "rawGenericCallGraphDepthSensitivityMaxDepthChecked"
        ),
        "rawGenericCallGraphDepthSensitivityProofAbsentAcrossCheckedDepths": (
            fill_execution_order_gap.get(
                "rawGenericCallGraphDepthSensitivityProofAbsentAcrossCheckedDepths"
            )
        ),
        "rawGenericCallGraphDepthSensitivityCountsStableAtAndBeyondDefaultDepth": (
            fill_execution_order_gap.get(
                "rawGenericCallGraphDepthSensitivityCountsStableAtAndBeyondDefaultDepth"
            )
        ),
        "predecessorFillExecutionOrderGap": fill_execution_order_gap,
        "predecessorFillSiteExecutionContext": fill_site_execution_context,
        "predecessorProgressPoll": progress_poll,
        "predecessorDirectionSweepPoll": direction_sweep_poll,
        "predecessorBranchStatePoll": branch_state_poll,
        "predecessorLeftOverrunActivationBranchStatePoll": left_overrun_activation_branch_state_poll,
        "predecessorNearestExitBranchStatePoll": nearest_exit_branch_state_poll,
        "predecessorReciprocalExitBranchStatePoll": reciprocal_exit_branch_state_poll,
        "predecessorCoordinateBranchStatePoll": coordinate_branch_state_poll,
        "predecessorTrailStartBranchStatePoll": trail_start_branch_state_poll,
        "predecessorTrailLeftOverrunBranchStatePoll": trail_left_overrun_branch_state_poll,
        "predecessorHighFrequencyBranchStatePoll": highfreq_branch_state_poll,
        "runtimePredecessorFillObserved": runtime_fill_observed,
        "publicPredecessorBranchStateAllZero": branch_state_poll.get("secondaryBranchStateAllZero"),
        "runtimeBranchStateSplit": runtime_branch_state_split,
        "leftOverrunActivationRuntimeBranchStateSplit": left_overrun_activation_runtime_split,
        "nearestExitRuntimeBranchStateSplit": nearest_exit_runtime_split,
        "reciprocalExitRuntimeBranchStateSplit": reciprocal_exit_runtime_split,
        "coordinateRuntimeBranchStateSplit": coordinate_runtime_split,
        "trailStartRuntimeBranchStateSplit": trail_start_runtime_split,
        "trailLeftOverrunRuntimeBranchStateSplit": trail_left_overrun_runtime_split,
        "highFrequencyRuntimeBranchStateSplit": highfreq_runtime_split,
        "selectorAdjacent": predecessor_persistence_gap.get("selectorAdjacent"),
        "intermediateSelectorCount": predecessor_persistence_gap.get("intermediateSelectorCount"),
        "routeOrderProven": route_order_proven,
        "sourceRoutePreviousSelector": predecessor_route_order.get("sourceRoutePreviousSelector"),
        "sourceRoutePreviousConfirmedOverlap": predecessor_route_order.get(
            "sourceRoutePreviousConfirmedOverlap"
        )
        or [],
        "predecessorIsTargetSideOnly": predecessor_route_order.get("predecessorIsTargetSideOnly"),
        "selectorMergeGapOpen": selector_merge_gap_open,
        "fillExecutionOrderProofFound": fill_execution_order_gap.get("proofFound"),
        "fillSiteExecutionContextProven": fill_site_execution_context.get(
            "fillSiteExecutionContextProven"
        ),
        "branchGateSameTableAndOffset": fill_site_execution_context.get(
            "branchGateSameTableAndOffset"
        ),
        "branchGateSameSelectionBufferOffsetHex": fill_site_execution_context.get(
            "branchGateSameSelectionBufferOffsetHex"
        ),
        "branchGatePostWriterSameOffsetWriteCount": fill_site_execution_context.get(
            "branchGatePostWriterSameOffsetWriteCount"
        ),
        "branchGatePostWriterSameOffsetReadCount": fill_site_execution_context.get(
            "branchGatePostWriterSameOffsetReadCount"
        ),
        "branchGatePostWriterOtherOffsetWriteCount": fill_site_execution_context.get(
            "branchGatePostWriterOtherOffsetWriteCount"
        ),
        "branchGatePostWriterOtherOffsetWriteOffsetsHex": fill_site_execution_context.get(
            "branchGatePostWriterOtherOffsetWriteOffsetsHex"
        )
        or [],
        "branchGateInvalidSecondaryFillOffsetsHex": fill_site_execution_context.get(
            "branchGateInvalidSecondaryFillOffsetsHex"
        )
        or [],
        "branchGateKnownOpcodeStatePreservationStatus": fill_site_execution_context.get(
            "branchGateKnownOpcodeStatePreservationStatus"
        ),
        "branchGateSlotPreservedByKnownOpcodes": fill_site_execution_context.get(
            "branchGateSlotPreservedByKnownOpcodes"
        ),
        "branchGateBranchStateValueStillRuntimeDependent": fill_site_execution_context.get(
            "branchGateBranchStateValueStillRuntimeDependent"
        ),
        "strictHotspotFound": strict_hotspot_found,
        "proofFound": branch_state_execution_proof_found,
        "failedBranchStateExecutionGateIds": failed_branch_state_execution_gate_ids,
        "missingEvidence": branch_state_execution_missing_evidence,
        "branchStateExecutionGatePass": branch_state_execution_gate_pass,
        "branchStateExecutionMissingEvidence": branch_state_execution_missing_evidence,
        "branchStateExecutionProofFound": branch_state_execution_proof_found,
        "persistencePromotable": persistence_promotable,
        "promotionStatus": "blocked" if not persistence_promotable else "ready-for-review",
        "evidenceRefs": BRANCH_STATE_EXECUTION_EVIDENCE_REFS,
        "evidenceRefCount": len(BRANCH_STATE_EXECUTION_EVIDENCE_REFS),
        "evidence": evidence,
        "remainingProofs": remaining_proofs,
        "conclusion": conclusion,
    }


def markdown(summary: dict) -> str:
    lines = [
        "# Save Selector Predecessor Branch-State Execution Gap",
        "",
        summary["conclusion"],
        "",
        f"- route: `{summary['source']} -> {summary['target']}`",
        f"- predecessor: `{summary['predecessorSelector']}` root `{summary['predecessorRootHex']}`",
        f"- current: `{summary['currentSelector']}` root `{summary['currentRootHex']}`",
        f"- predecessor fill would pass current reader: {summary['predecessorFillWouldPassCurrentReader']}",
        f"- predecessor local tail reset found: {summary['predecessorLocalTailResetFound']}",
        f"- direct global secondary writers: {summary['directGlobalSecondaryWriterCount']}",
        f"- unresolved global secondary refs: {summary['unresolvedGlobalSecondaryRefCount']}",
        f"- helper opcode10-only: {summary['helperOnlyCalledInsideOpcode10Handler']}",
        f"- closed static reset scope: {summary['closedStaticResetScope']}",
        f"- selector-order reset gap closed: {summary['selectorOrderResetGapClosed']}",
        f"- runtime order/bytecode gap open: {summary['openRuntimeOrderOrBytecodeGap']}",
        (
            "- predecessor fill execution/order gap: "
            f"proofFound={(summary.get('predecessorFillExecutionOrderGap') or {}).get('proofFound')} "
            f"localTrace={(summary.get('predecessorFillExecutionOrderGap') or {}).get('localFillTraceStartHex')}->"
            f"{(summary.get('predecessorFillExecutionOrderGap') or {}).get('localFillTraceStopHex')} "
            f"reason={(summary.get('predecessorFillExecutionOrderGap') or {}).get('localFillTraceStopReason')} "
            f"rootEntryReach={(summary.get('predecessorFillExecutionOrderGap') or {}).get('rootEntryFixedTraversalFillSitesReachable')} "
            f"encoded={(summary.get('predecessorFillExecutionOrderGap') or {}).get('encodedFillEntryClassification')} "
            f"raw={(summary.get('predecessorFillExecutionOrderGap') or {}).get('encodedFillEntryRawScalarCandidateCount')} "
            f"rootTailRaw={(summary.get('predecessorFillExecutionOrderGap') or {}).get('encodedFillEntryRootTailRawScalarCandidateCount')} "
            f"promoting={(summary.get('predecessorFillExecutionOrderGap') or {}).get('encodedFillEntryPromotingCandidateCount')} "
            f"rawScalarReject={(summary.get('predecessorFillExecutionOrderGap') or {}).get('encodedRawScalarRejectionClassification')}"
        ),
        (
            "- predecessor dispatch slice dependency: "
            f"sliceRuntimeProof={summary.get('predecessorDispatchSliceRuntimeProofFound')} "
            f"dispatchTableProof={summary.get('predecessorDispatchTableProofFound')} "
            f"dispatchFailedGates={list_text(summary.get('predecessorDispatchTableFailedGateIds'))} "
            f"dispatchMissingEvidenceCount={len(summary.get('predecessorDispatchTableMissingEvidence') or [])} "
            f"dispatchEvidenceRefs={summary.get('predecessorDispatchTableEvidenceRefCount')} "
            f"descriptorDependsOnSlice={summary.get('predecessorDescriptorDependsOnSaveSelectorSliceModel')} "
            f"rows={summary.get('predecessorDispatchSliceRowCount')} "
            f"sliceData={summary.get('predecessorDispatchSliceDataDescriptorCount')} "
            f"rawDiffers={summary.get('predecessorDispatchRawGeneralDiffersFromSliceCount')} "
            f"byteReachable={summary.get('predecessorDispatchSliceGenericByteReachableCount')} "
            f"requiresTableBase={summary.get('predecessorDispatchSliceRequiresTableBaseSwitchCount')} "
            f"dynamicDispatches={summary.get('predecessorDispatchDynamicIndexedDispatchRowCount')}/"
            f"{summary.get('predecessorDispatchDynamicScopeTableCallbackCount')}/"
            f"{summary.get('predecessorDispatchDynamicSaveSelectorTableImmediateNearCount')} "
            f"dynamicScopeSites={list_text(summary.get('predecessorDispatchDynamicScopeTableCallbackSites'))} "
            f"dynamicTableBaseCandidate="
            f"{summary.get('predecessorDispatchDynamicSaveSelectorTableBaseSwitchStaticCandidateFound')} "
            f"dynamicTableBaseCandidateSites={list_text(summary.get('predecessorDispatchDynamicSaveSelectorTableBaseCandidateSites'))} "
            f"tableBaseArithmeticRows={summary.get('predecessorDispatchSaveSelectorTableBaseArithmeticRowCount')} "
            f"tableBaseArithmeticCandidates={summary.get('predecessorDispatchSaveSelectorTableBaseArithmeticCandidateCount')} "
            f"tableBaseReject={summary.get('predecessorDispatchTableBaseRejectionClassification')}"
        ),
        (
            "- predecessor raw generic call graph: "
            f"{summary.get('rawGenericCallGraphClassification')} "
            f"depth={summary.get('rawGenericCallGraphMaxDepth')} "
            f"functions/edges={summary.get('rawGenericCallGraphReachableFunctionCount')}/"
            f"{summary.get('rawGenericCallGraphDirectCallEdgeCount')} "
            "route/fill/currentImm="
            f"{summary.get('rawGenericCallGraphRouteImmediateHitCount')}/"
            f"{summary.get('rawGenericCallGraphFillImmediateHitCount')}/"
            f"{summary.get('rawGenericCallGraphCurrentImmediateHitCount')} "
            "selected/branchImm="
            f"{summary.get('rawGenericCallGraphSelectedPointerImmediateHitCount')}/"
            f"{summary.get('rawGenericCallGraphBranchStateImmediateHitCount')} "
            "route/fillTransfers="
            f"{summary.get('rawGenericCallGraphRouteDirectTransferHitCount')}/"
            f"{summary.get('rawGenericCallGraphFillDirectTransferHitCount')} "
            "depthSensitivity="
            f"{summary.get('rawGenericCallGraphDepthSensitivityMaxDepthChecked')}/"
            f"{summary.get('rawGenericCallGraphDepthSensitivityProofAbsentAcrossCheckedDepths')}/"
            f"{summary.get('rawGenericCallGraphDepthSensitivityCountsStableAtAndBeyondDefaultDepth')} "
            f"proof={summary.get('rawGenericCallGraphProofFound')}"
        ),
        (
            "- predecessor fill-site execution context: "
            f"polls={(summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollCount')}/"
            f"{(summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollSequenceCount')}/"
            f"{(summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollSampleCount')} "
            f"public={(summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollPublicPredecessorHitCount')} "
            f"currentRoot={(summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollCurrentRootHitCount')} "
            f"route2:0={(summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollRouteSelectorHitCount')} "
            f"fillMatches={(summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollFillMatchCount')} "
            f"allZero={(summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollAllZeroCount')} "
            f"targetStatus={(summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollTargetObservationStatus')} "
            f"descriptorEdgeReject={(summary.get('predecessorFillSiteExecutionContext') or {}).get('descriptorEdgeRejectionClassification')} "
            "descriptorRouteEdges="
            f"{(summary.get('predecessorFillSiteExecutionContext') or {}).get('descriptorEdgeRootRouteExecutionTargetEdgeCount')}/"
            f"{(summary.get('predecessorFillSiteExecutionContext') or {}).get('descriptorEdgeFillRouteExecutionTargetEdgeCount')} "
            f"tableBaseReject={(summary.get('predecessorFillSiteExecutionContext') or {}).get('predecessorDispatchTableBaseRejectionClassification')} "
            f"fieldEntryCandidates={((summary.get('predecessorFillSiteExecutionContext') or {}).get('fieldEntrySequenceContext') or {}).get('fieldEntryCandidateCount')} "
            f"snapshotRouteCandidates={((summary.get('predecessorFillSiteExecutionContext') or {}).get('fieldEntrySequenceContext') or {}).get('snapshotRouteCandidateCount')} "
            f"coordinateReject={((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('coordinateSourceRejectionClassification')} "
            "coordinateStartPtrStaticTrailImage="
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('publicSaveStartPointerTableTileHitCount')}/"
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('publicSaveStartStaticBaseHitCount')}/"
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('publicSaveStartTrailRingHitCount')}/"
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('publicSaveStartImageHitCount')} "
            "coordinateTrailPtrStaticTrailImage="
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('observedTrailPointerTableTileHitCount')}/"
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('observedTrailStaticBaseHitCount')}/"
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('observedTrailTrailRingHitCount')}/"
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('observedTrailImageHitCount')} "
            "coordinateReciprocalPtrStaticTrailImage="
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('reciprocalPointerTableTileHitCount')}/"
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('reciprocalStaticBaseHitCount')}/"
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('reciprocalTrailRingHitCount')}/"
            f"{((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('reciprocalImageHitCount')} "
            f"proof={(summary.get('predecessorFillSiteExecutionContext') or {}).get('fillSiteExecutionContextProven')}"
        ),
        f"- predecessor progress poll: seq={summary.get('predecessorProgressPoll', {}).get('sequenceCount')} samples={summary.get('predecessorProgressPoll', {}).get('sampleCount')} observed={list_text(summary.get('predecessorProgressPoll', {}).get('observedSelectors'))} input={input_quality_brief(summary.get('predecessorProgressPoll', {}).get('inputQuality'))} publicHit={summary.get('predecessorProgressPoll', {}).get('anyReachedPublicSaveSelector')} route2:0={summary.get('predecessorProgressPoll', {}).get('anyReachedRouteSelectorContext')}",
        f"- predecessor direction sweep poll: seq={summary.get('predecessorDirectionSweepPoll', {}).get('sequenceCount')} samples={summary.get('predecessorDirectionSweepPoll', {}).get('sampleCount')} observed={list_text(summary.get('predecessorDirectionSweepPoll', {}).get('observedSelectors'))} input={input_quality_brief(summary.get('predecessorDirectionSweepPoll', {}).get('inputQuality'))} publicHit={summary.get('predecessorDirectionSweepPoll', {}).get('anyReachedPublicSaveSelector')} route2:0={summary.get('predecessorDirectionSweepPoll', {}).get('anyReachedRouteSelectorContext')}",
        f"- predecessor branch-state poll: seq={summary.get('predecessorBranchStatePoll', {}).get('sequenceCount')} samples={summary.get('predecessorBranchStatePoll', {}).get('sampleCount')} observed={list_text(summary.get('predecessorBranchStatePoll', {}).get('observedSelectors'))} input={input_quality_brief(summary.get('predecessorBranchStatePoll', {}).get('inputQuality'))} state={list_text(summary.get('predecessorBranchStatePoll', {}).get('secondaryBranchStateHexes'))} matchesFill={summary.get('predecessorBranchStatePoll', {}).get('matchesPredecessorFillHypothesis')} allZero={summary.get('predecessorBranchStatePoll', {}).get('secondaryBranchStateAllZero')} route2:0={summary.get('predecessorBranchStatePoll', {}).get('anyReachedRouteSelectorContext')}",
        f"- predecessor nearest-exit branch-state poll: seq={summary.get('predecessorNearestExitBranchStatePoll', {}).get('sequenceCount')} samples={summary.get('predecessorNearestExitBranchStatePoll', {}).get('sampleCount')} observed={list_text(summary.get('predecessorNearestExitBranchStatePoll', {}).get('observedSelectors'))} input={input_quality_brief(summary.get('predecessorNearestExitBranchStatePoll', {}).get('inputQuality'))} state={list_text(summary.get('predecessorNearestExitBranchStatePoll', {}).get('secondaryBranchStateHexes'))} matchesFill={summary.get('predecessorNearestExitBranchStatePoll', {}).get('matchesPredecessorFillHypothesis')} allZero={summary.get('predecessorNearestExitBranchStatePoll', {}).get('secondaryBranchStateAllZero')} route2:0={summary.get('predecessorNearestExitBranchStatePoll', {}).get('anyReachedRouteSelectorContext')}",
        f"- predecessor reciprocal-exit branch-state poll: seq={summary.get('predecessorReciprocalExitBranchStatePoll', {}).get('sequenceCount')} samples={summary.get('predecessorReciprocalExitBranchStatePoll', {}).get('sampleCount')} observed={list_text(summary.get('predecessorReciprocalExitBranchStatePoll', {}).get('observedSelectors'))} input={input_quality_brief(summary.get('predecessorReciprocalExitBranchStatePoll', {}).get('inputQuality'))} state={list_text(summary.get('predecessorReciprocalExitBranchStatePoll', {}).get('secondaryBranchStateHexes'))} matchesFill={summary.get('predecessorReciprocalExitBranchStatePoll', {}).get('matchesPredecessorFillHypothesis')} allZero={summary.get('predecessorReciprocalExitBranchStatePoll', {}).get('secondaryBranchStateAllZero')} route2:0={summary.get('predecessorReciprocalExitBranchStatePoll', {}).get('anyReachedRouteSelectorContext')}",
        f"- predecessor coordinate branch-state poll: seq={summary.get('predecessorCoordinateBranchStatePoll', {}).get('sequenceCount')} samples={summary.get('predecessorCoordinateBranchStatePoll', {}).get('sampleCount')} observed={list_text(summary.get('predecessorCoordinateBranchStatePoll', {}).get('observedSelectors'))} input={input_quality_brief(summary.get('predecessorCoordinateBranchStatePoll', {}).get('inputQuality'))} state={list_text(summary.get('predecessorCoordinateBranchStatePoll', {}).get('secondaryBranchStateHexes'))} matchesFill={summary.get('predecessorCoordinateBranchStatePoll', {}).get('matchesPredecessorFillHypothesis')} allZero={summary.get('predecessorCoordinateBranchStatePoll', {}).get('secondaryBranchStateAllZero')} route2:0={summary.get('predecessorCoordinateBranchStatePoll', {}).get('anyReachedRouteSelectorContext')} coordinateClass={summary.get('predecessorCoordinateBranchStatePoll', {}).get('coordinateAnalysisClassification')} startObserved={summary.get('predecessorCoordinateBranchStatePoll', {}).get('coordinateAnyStartTileObserved')} targetObserved={summary.get('predecessorCoordinateBranchStatePoll', {}).get('coordinateAnyTargetTileObserved')}",
        f"- predecessor trail-start branch-state poll: seq={summary.get('predecessorTrailStartBranchStatePoll', {}).get('sequenceCount')} samples={summary.get('predecessorTrailStartBranchStatePoll', {}).get('sampleCount')} observed={list_text(summary.get('predecessorTrailStartBranchStatePoll', {}).get('observedSelectors'))} input={input_quality_brief(summary.get('predecessorTrailStartBranchStatePoll', {}).get('inputQuality'))} state={list_text(summary.get('predecessorTrailStartBranchStatePoll', {}).get('secondaryBranchStateHexes'))} matchesFill={summary.get('predecessorTrailStartBranchStatePoll', {}).get('matchesPredecessorFillHypothesis')} allZero={summary.get('predecessorTrailStartBranchStatePoll', {}).get('secondaryBranchStateAllZero')} route2:0={summary.get('predecessorTrailStartBranchStatePoll', {}).get('anyReachedRouteSelectorContext')} trailClass={summary.get('predecessorTrailStartBranchStatePoll', {}).get('trailStartClassification')} startObserved={summary.get('predecessorTrailStartBranchStatePoll', {}).get('trailAnyStartTileObserved')} targetObserved={summary.get('predecessorTrailStartBranchStatePoll', {}).get('trailAnyTargetTileObserved')} trailMove={summary.get('predecessorTrailStartBranchStatePoll', {}).get('trailAnyTrailMovementObserved')}",
        f"- predecessor trail-left-overrun branch-state poll: seq={summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('sequenceCount')} samples={summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('sampleCount')} observed={list_text(summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('observedSelectors'))} input={input_quality_brief(summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('inputQuality'))} state={list_text(summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('secondaryBranchStateHexes'))} matchesFill={summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('matchesPredecessorFillHypothesis')} allZero={summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('secondaryBranchStateAllZero')} route2:0={summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('anyReachedRouteSelectorContext')} overrunClass={summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('trailLeftOverrunClassification')} cameraTarget={summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('trailLeftOverrunAnyCameraTargetObserved')} cameraOutside={summary.get('predecessorTrailLeftOverrunBranchStatePoll', {}).get('trailLeftOverrunAnyCameraOutsideObserved')}",
        f"- predecessor high-frequency branch-state poll: interval={summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('pollIntervalSeconds')} seq={summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('sequenceCount')} samples={summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('sampleCount')} observed={list_text(summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('observedSelectors'))} public={list_text(summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('observedPublicSaveSelectors'))} input={input_quality_brief(summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('inputQuality'))} state={list_text(summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('secondaryBranchStateHexes'))} matchesFill={summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('matchesPredecessorFillHypothesis')} allZero={summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('secondaryBranchStateAllZero')} route2:0={summary.get('predecessorHighFrequencyBranchStatePoll', {}).get('anyReachedRouteSelectorContext')}",
        (
            "- runtime branch-state split: "
            f"{(summary.get('runtimeBranchStateSplit') or {}).get('classification')} "
            f"publicPredecessorReached={(summary.get('runtimeBranchStateSplit') or {}).get('publicPredecessorReached')} "
            f"observed={list_text((summary.get('runtimeBranchStateSplit') or {}).get('observedStateHexes'))} "
            f"expected={list_text((summary.get('runtimeBranchStateSplit') or {}).get('expectedFillHexes'))} "
            f"next={(summary.get('runtimeBranchStateSplit') or {}).get('nextProofFocus')}"
        ),
        (
            "- nearest-exit runtime split: "
            f"{(summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('classification')} "
            f"publicPredecessorReached={(summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')} "
            f"observed={list_text((summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('observedStateHexes'))} "
            f"expected={list_text((summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('expectedFillHexes'))} "
            f"next={(summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('nextProofFocus')}"
        ),
        (
            "- reciprocal-exit runtime split: "
            f"{(summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('classification')} "
            f"publicPredecessorReached={(summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')} "
            f"observed={list_text((summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('observedStateHexes'))} "
            f"expected={list_text((summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('expectedFillHexes'))} "
            f"next={(summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('nextProofFocus')}"
        ),
        (
            "- coordinate runtime split: "
            f"{(summary.get('coordinateRuntimeBranchStateSplit') or {}).get('classification')} "
            f"publicPredecessorReached={(summary.get('coordinateRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')} "
            f"startObserved={(summary.get('coordinateRuntimeBranchStateSplit') or {}).get('coordinateAnyStartTileObserved')} "
            f"targetObserved={(summary.get('coordinateRuntimeBranchStateSplit') or {}).get('coordinateAnyTargetTileObserved')} "
            f"next={(summary.get('coordinateRuntimeBranchStateSplit') or {}).get('nextProofFocus')}"
        ),
        (
            "- trail-start runtime split: "
            f"{(summary.get('trailStartRuntimeBranchStateSplit') or {}).get('classification')} "
            f"publicPredecessorReached={(summary.get('trailStartRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')} "
            f"startObserved={(summary.get('trailStartRuntimeBranchStateSplit') or {}).get('trailAnyStartTileObserved')} "
            f"targetObserved={(summary.get('trailStartRuntimeBranchStateSplit') or {}).get('trailAnyTargetTileObserved')} "
            f"actorMove={(summary.get('trailStartRuntimeBranchStateSplit') or {}).get('trailAnyActorMovementObserved')} "
            f"trailMove={(summary.get('trailStartRuntimeBranchStateSplit') or {}).get('trailAnyTrailMovementObserved')} "
            f"next={(summary.get('trailStartRuntimeBranchStateSplit') or {}).get('nextProofFocus')}"
        ),
        (
            "- trail-left-overrun runtime split: "
            f"{(summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('classification')} "
            f"publicPredecessorReached={(summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')} "
            f"cameraTarget={(summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('cameraTargetObserved')} "
            f"cameraOutside={(summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('cameraOutsideObserved')} "
            f"actorTarget={(summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('actorTargetObserved')} "
            f"trailTarget={(summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('trailTargetObserved')} "
            f"next={(summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('nextProofFocus')}"
        ),
        (
            "- high-frequency runtime split: "
            f"{(summary.get('highFrequencyRuntimeBranchStateSplit') or {}).get('classification')} "
            f"publicPredecessorReached={(summary.get('highFrequencyRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')} "
            f"observedFill={(summary.get('highFrequencyRuntimeBranchStateSplit') or {}).get('observedMatchesFill')} "
            f"allZero={(summary.get('highFrequencyRuntimeBranchStateSplit') or {}).get('observedAllZero')} "
            f"interval={(summary.get('highFrequencyRuntimeBranchStateSplit') or {}).get('pollIntervalSeconds')} "
            f"routeReached={(summary.get('highFrequencyRuntimeBranchStateSplit') or {}).get('publicRouteReached')} "
            f"next={(summary.get('highFrequencyRuntimeBranchStateSplit') or {}).get('nextProofFocus')}"
        ),
        f"- route order proven: {summary['routeOrderProven']}",
        f"- selector merge gap open: {summary['selectorMergeGapOpen']}",
        f"- fill execution/order proof found: {summary.get('fillExecutionOrderProofFound')}",
        f"- fill-site execution context proven: {summary.get('fillSiteExecutionContextProven')}",
        (
            "- branch gate preservation via fill context: "
            f"`{summary.get('branchGateKnownOpcodeStatePreservationStatus')}` "
            f"same-offset {summary.get('branchGateSameTableAndOffset')}/"
            f"{summary.get('branchGateSameSelectionBufferOffsetHex')} "
            "write/read "
            f"{summary.get('branchGatePostWriterSameOffsetWriteCount')}/"
            f"{summary.get('branchGatePostWriterSameOffsetReadCount')} "
            "other "
            f"{summary.get('branchGatePostWriterOtherOffsetWriteCount')}@"
            f"{list_text(summary.get('branchGatePostWriterOtherOffsetWriteOffsetsHex'))} "
            f"invalid {list_text(summary.get('branchGateInvalidSecondaryFillOffsetsHex'))}"
        ),
        f"- global reset ruled out: {summary['globalResetRuledOut']}",
        f"- strict hotspot found: {summary['strictHotspotFound']}",
        f"- proof found: {summary.get('proofFound')}",
        (
            "- failed branch-state execution gates: "
            f"{list_text(summary.get('failedBranchStateExecutionGateIds'))}"
        ),
        f"- missing evidence count: {len(summary.get('missingEvidence') or [])}",
        f"- evidence refs: {summary.get('evidenceRefCount')}",
        f"- branch-state execution proof found: {summary['branchStateExecutionProofFound']}",
        f"- persistence promotable: {summary['persistencePromotable']}",
        f"- promotion status: `{summary['promotionStatus']}`",
        "",
        "## Evidence",
        "",
        "| kind | status | detail |",
        "| --- | --- | --- |",
    ]
    for row in summary["evidence"]:
        lines.append(f"| {row['kind']} | {row['status']} | {row['detail']} |")
    lines.extend(["", "## Remaining Proofs", ""])
    lines.extend(f"- {item}" for item in summary["remainingProofs"])
    lines.append("")
    return "\n".join(lines)


def html_page(summary: dict) -> str:
    evidence_rows = "\n".join(
        "<tr>"
        f"<td>{html.escape(row['kind'])}</td>"
        f"<td>{html.escape(row['status'])}</td>"
        f"<td>{html.escape(row['detail'])}</td>"
        "</tr>"
        for row in summary["evidence"]
    )
    proof_items = "\n".join(f"<li>{html.escape(item)}</li>" for item in summary["remainingProofs"])
    return "\n".join(
        [
            "<!doctype html>",
            '<html lang="en">',
            "<head>",
            '  <meta charset="utf-8">',
            "  <title>Save Selector Predecessor Branch-State Execution Gap</title>",
            "  <style>body{font-family:system-ui,sans-serif;margin:24px;line-height:1.45;max-width:1200px}table{border-collapse:collapse;width:100%;margin:16px 0}td,th{border:1px solid #ddd;padding:6px 8px;text-align:left;vertical-align:top}th{background:#f5f5f5}code{white-space:nowrap}</style>",
            "</head>",
            "<body>",
            "  <h1>Save Selector Predecessor Branch-State Execution Gap</h1>",
            f"  <p>{html.escape(summary['conclusion'])}</p>",
            (
                "  <p><b>Route:</b> "
                f"<code>{html.escape(summary['source'])} -> {html.escape(summary['target'])}</code>; "
                f"predecessor <code>{html.escape(str(summary['predecessorSelector']))}</code> "
                f"root <code>{html.escape(str(summary['predecessorRootHex']))}</code>; "
                f"current <code>{html.escape(str(summary['currentSelector']))}</code> "
                f"root <code>{html.escape(str(summary['currentRootHex']))}</code>.</p>"
            ),
            (
                "  <p><b>Proof:</b> "
                f"fillPass={bool_text(summary['predecessorFillWouldPassCurrentReader'])}; "
                f"staticClosed={bool_text(summary['closedStaticResetScope'])}; "
                f"routeOrder={bool_text(summary['routeOrderProven'])}; "
                f"selectorMergeOpen={bool_text(summary['selectorMergeGapOpen'])}; "
                f"fillOrderProof={bool_text(summary.get('fillExecutionOrderProofFound'))}; "
                f"fillContextProof={bool_text(summary.get('fillSiteExecutionContextProven'))}; "
                "rawGenericCallGraph="
                f"<code>{html.escape(str(summary.get('rawGenericCallGraphClassification')))}</code>; "
                "rawGenericCallGraph depth/functions/edges "
                f"{html.escape(str(summary.get('rawGenericCallGraphMaxDepth')))}/"
                f"{html.escape(str(summary.get('rawGenericCallGraphReachableFunctionCount')))}/"
                f"{html.escape(str(summary.get('rawGenericCallGraphDirectCallEdgeCount')))}; "
                "rawGenericCallGraph proof "
                f"{bool_text(summary.get('rawGenericCallGraphProofFound'))}; "
                f"runtimeFillObserved={bool_text(summary.get('runtimePredecessorFillObserved'))}; "
                f"strictHotspot={bool_text(summary['strictHotspotFound'])}; "
                f"promotion <code>{html.escape(summary['promotionStatus'])}</code>.</p>"
            ),
            (
                "  <p><b>fill-site execution context:</b> "
                f"order proof {html.escape(str(summary.get('fillExecutionOrderProofFound')))}; "
                f"context proof {html.escape(str(summary.get('fillSiteExecutionContextProven')))}; "
                "polls "
                f"{html.escape(str((summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollCount')))}"
                "/"
                f"{html.escape(str((summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollSequenceCount')))}"
                "/"
                f"{html.escape(str((summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollSampleCount')))}; "
                "branch gate preserve "
                f"<code>{html.escape(str(summary.get('branchGateKnownOpcodeStatePreservationStatus')))}</code>; "
                "same-offset/write-read/other/invalid "
                f"{html.escape(str(summary.get('branchGateSameTableAndOffset')))}/"
                f"{html.escape(str(summary.get('branchGateSameSelectionBufferOffsetHex')))} "
                f"{html.escape(str(summary.get('branchGatePostWriterSameOffsetWriteCount')))}/"
                f"{html.escape(str(summary.get('branchGatePostWriterSameOffsetReadCount')))} "
                f"{html.escape(str(summary.get('branchGatePostWriterOtherOffsetWriteCount')))}@"
                f"{html.escape(list_text(summary.get('branchGatePostWriterOtherOffsetWriteOffsetsHex')))} "
                f"invalid {html.escape(list_text(summary.get('branchGateInvalidSecondaryFillOffsetsHex')))}; "
                f"encoded <code>{html.escape(str((summary.get('predecessorFillExecutionOrderGap') or {}).get('encodedFillEntryClassification')))}</code>; "
                f"target status <code>{html.escape(str((summary.get('predecessorFillSiteExecutionContext') or {}).get('branchStatePollTargetObservationStatus')))}</code>; "
                "coordinate reject "
                f"<code>{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('coordinateSourceRejectionClassification')))}</code>; "
                "coordinate start/trail/reciprocal ptr-static-trail-image "
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('publicSaveStartPointerTableTileHitCount')))}/"
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('publicSaveStartStaticBaseHitCount')))}/"
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('publicSaveStartTrailRingHitCount')))}/"
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('publicSaveStartImageHitCount')))} "
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('observedTrailPointerTableTileHitCount')))}/"
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('observedTrailStaticBaseHitCount')))}/"
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('observedTrailTrailRingHitCount')))}/"
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('observedTrailImageHitCount')))} "
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('reciprocalPointerTableTileHitCount')))}/"
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('reciprocalStaticBaseHitCount')))}/"
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('reciprocalTrailRingHitCount')))}/"
                f"{html.escape(str(((summary.get('predecessorFillSiteExecutionContext') or {}).get('coordinateSourceContext') or {}).get('reciprocalImageHitCount')))}.</p>"
            ),
            (
                "  <p>branch-state execution proof found: "
                f"{bool_text(summary['branchStateExecutionProofFound'])}; "
                "proof found: "
                f"{bool_text(summary.get('proofFound'))}; "
                "failed branch-state execution gates: "
                f"<code>{html.escape(list_text(summary.get('failedBranchStateExecutionGateIds')))}</code>; "
                "missing evidence: "
                f"{html.escape(str(len(summary.get('missingEvidence') or [])))}; "
                "evidence refs: "
                f"{html.escape(str(summary.get('evidenceRefCount')))}; "
                "persistence promotable: "
                f"{bool_text(summary['persistencePromotable'])}; "
                "promotion status: "
                f"<code>{html.escape(summary['promotionStatus'])}</code>.</p>"
            ),
            (
                "  <p><b>runtime branch-state split:</b> "
                f"{html.escape(str((summary.get('runtimeBranchStateSplit') or {}).get('classification')))}; "
                f"public predecessor reached {html.escape(str((summary.get('runtimeBranchStateSplit') or {}).get('publicPredecessorReached')))}; "
                f"observed <code>{html.escape(list_text((summary.get('runtimeBranchStateSplit') or {}).get('observedStateHexes')))}</code>; "
                f"expected <code>{html.escape(list_text((summary.get('runtimeBranchStateSplit') or {}).get('expectedFillHexes')))}</code>; "
                f"next {html.escape(str((summary.get('runtimeBranchStateSplit') or {}).get('nextProofFocus')))}.</p>"
            ),
            (
                "  <p><b>nearest-exit runtime split:</b> "
                f"{html.escape(str((summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('classification')))}; "
                f"public predecessor reached {html.escape(str((summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')))}; "
                f"observed <code>{html.escape(list_text((summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('observedStateHexes')))}</code>; "
                f"expected <code>{html.escape(list_text((summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('expectedFillHexes')))}</code>; "
                f"next {html.escape(str((summary.get('nearestExitRuntimeBranchStateSplit') or {}).get('nextProofFocus')))}.</p>"
            ),
            (
                "  <p><b>reciprocal-exit runtime split:</b> "
                f"{html.escape(str((summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('classification')))}; "
                f"public predecessor reached {html.escape(str((summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')))}; "
                f"observed <code>{html.escape(list_text((summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('observedStateHexes')))}</code>; "
                f"expected <code>{html.escape(list_text((summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('expectedFillHexes')))}</code>; "
                f"next {html.escape(str((summary.get('reciprocalExitRuntimeBranchStateSplit') or {}).get('nextProofFocus')))}.</p>"
            ),
            (
                "  <p><b>coordinate runtime split:</b> "
                f"{html.escape(str((summary.get('coordinateRuntimeBranchStateSplit') or {}).get('classification')))}; "
                f"public predecessor reached {html.escape(str((summary.get('coordinateRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')))}; "
                f"start observed {html.escape(str((summary.get('coordinateRuntimeBranchStateSplit') or {}).get('coordinateAnyStartTileObserved')))}; "
                f"target observed {html.escape(str((summary.get('coordinateRuntimeBranchStateSplit') or {}).get('coordinateAnyTargetTileObserved')))}; "
                f"next {html.escape(str((summary.get('coordinateRuntimeBranchStateSplit') or {}).get('nextProofFocus')))}.</p>"
            ),
            (
                "  <p><b>trail-start runtime split:</b> "
                f"{html.escape(str((summary.get('trailStartRuntimeBranchStateSplit') or {}).get('classification')))}; "
                f"public predecessor reached {html.escape(str((summary.get('trailStartRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')))}; "
                f"start observed {html.escape(str((summary.get('trailStartRuntimeBranchStateSplit') or {}).get('trailAnyStartTileObserved')))}; "
                f"target observed {html.escape(str((summary.get('trailStartRuntimeBranchStateSplit') or {}).get('trailAnyTargetTileObserved')))}; "
                f"trail movement {html.escape(str((summary.get('trailStartRuntimeBranchStateSplit') or {}).get('trailAnyTrailMovementObserved')))}; "
                f"next {html.escape(str((summary.get('trailStartRuntimeBranchStateSplit') or {}).get('nextProofFocus')))}.</p>"
            ),
            (
                "  <p><b>trail-left-overrun runtime split:</b> "
                f"{html.escape(str((summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('classification')))}; "
                f"public predecessor reached {html.escape(str((summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('publicPredecessorReached')))}; "
                f"camera target {html.escape(str((summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('cameraTargetObserved')))}; "
                f"camera outside {html.escape(str((summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('cameraOutsideObserved')))}; "
                f"route reached {html.escape(str((summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('publicRouteReached')))}; "
                f"next {html.escape(str((summary.get('trailLeftOverrunRuntimeBranchStateSplit') or {}).get('nextProofFocus')))}.</p>"
            ),
            "  <h2>Evidence</h2>",
            f"  <table><thead><tr><th>kind</th><th>status</th><th>detail</th></tr></thead><tbody>{evidence_rows}</tbody></table>",
            "  <h2>Remaining Proofs</h2>",
            f"  <ul>{proof_items}</ul>",
            "</body>",
            "</html>",
            "",
        ]
    )


def write_outputs(summary: dict, out_dir: Path = OUT) -> None:
    out_dir.mkdir(parents=True, exist_ok=True)
    (out_dir / "save_selector_predecessor_branch_state_execution_gap.json").write_text(
        json.dumps(summary, ensure_ascii=False, indent=2) + "\n",
        encoding="utf-8",
    )
    (out_dir / "save_selector_predecessor_branch_state_execution_gap.html").write_text(
        html_page(summary),
        encoding="utf-8",
    )


def load_json(path: Path) -> dict:
    return json.loads(path.read_text(encoding="utf-8"))


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--predecessor-persistence-gap", type=Path, default=OUT / "save_selector_predecessor_persistence_gap.json")
    parser.add_argument("--predecessor-state-effect", type=Path, default=OUT / "save_selector_predecessor_state_effect.json")
    parser.add_argument("--predecessor-tail-reset", type=Path, default=OUT / "save_selector_predecessor_tail_reset.json")
    parser.add_argument("--secondary-reset-scope", type=Path, default=OUT / "save_selector_secondary_reset_scope.json")
    parser.add_argument("--secondary-global-reset-gap", type=Path, default=OUT / "save_selector_secondary_global_reset_gap.json")
    parser.add_argument("--predecessor-route-order", type=Path, default=OUT / "save_selector_predecessor_route_order.json")
    parser.add_argument("--merge-gap", type=Path, default=OUT / "save_selector_merge_gap.json")
    parser.add_argument("--hotspot-gap", type=Path, default=OUT / "map1_01a_hotspot_gap.json")
    parser.add_argument("--predecessor-progress-poll", type=Path, default=OUT / "runtime_selected_pointer_predecessor_progress_poll.json")
    parser.add_argument("--predecessor-direction-sweep-poll", type=Path, default=OUT / "runtime_selected_pointer_predecessor_direction_sweep_poll.json")
    parser.add_argument("--predecessor-branch-state-poll", type=Path, default=OUT / PREDECESSOR_BRANCH_STATE_POLL)
    parser.add_argument(
        "--predecessor-left-overrun-activation-branch-state-poll",
        type=Path,
        default=OUT / PREDECESSOR_LEFT_OVERRUN_ACTIVATION_BRANCH_STATE_POLL,
    )
    parser.add_argument(
        "--predecessor-nearest-exit-branch-state-poll",
        type=Path,
        default=OUT / PREDECESSOR_NEAREST_EXIT_BRANCH_STATE_POLL,
    )
    parser.add_argument(
        "--predecessor-reciprocal-exit-branch-state-poll",
        type=Path,
        default=OUT / PREDECESSOR_RECIPROCAL_EXIT_BRANCH_STATE_POLL,
    )
    parser.add_argument(
        "--predecessor-coordinate-branch-state-poll",
        type=Path,
        default=OUT / PREDECESSOR_COORDINATE_BRANCH_STATE_POLL,
    )
    parser.add_argument(
        "--predecessor-trail-start-branch-state-poll",
        type=Path,
        default=OUT / PREDECESSOR_TRAIL_START_BRANCH_STATE_POLL,
    )
    parser.add_argument(
        "--predecessor-trail-left-overrun-branch-state-poll",
        type=Path,
        default=OUT / PREDECESSOR_TRAIL_LEFT_OVERRUN_BRANCH_STATE_POLL,
    )
    parser.add_argument(
        "--predecessor-highfreq-branch-state-poll",
        type=Path,
        default=OUT / PREDECESSOR_HIGHFREQ_BRANCH_STATE_POLL,
    )
    parser.add_argument(
        "--predecessor-fill-execution-order-gap",
        type=Path,
        default=OUT / "save_selector_predecessor_fill_execution_order_gap.json",
    )
    parser.add_argument(
        "--predecessor-fill-site-execution-context",
        type=Path,
        default=OUT / "save_selector_predecessor_fill_site_execution_context.json",
    )
    parser.add_argument("--out-dir", type=Path, default=OUT)
    args = parser.parse_args()
    summary = build_summary(
        load_json(args.predecessor_persistence_gap),
        load_json(args.predecessor_state_effect),
        load_json(args.predecessor_tail_reset),
        load_json(args.secondary_reset_scope),
        load_json(args.secondary_global_reset_gap),
        load_json(args.predecessor_route_order),
        load_json(args.merge_gap),
        load_json(args.hotspot_gap),
        load_json(args.predecessor_progress_poll) if args.predecessor_progress_poll.exists() else {},
        load_json(args.predecessor_direction_sweep_poll) if args.predecessor_direction_sweep_poll.exists() else {},
        load_json(args.predecessor_branch_state_poll) if args.predecessor_branch_state_poll.exists() else {},
        load_json(args.predecessor_left_overrun_activation_branch_state_poll)
        if args.predecessor_left_overrun_activation_branch_state_poll.exists()
        else {},
        load_json(args.predecessor_nearest_exit_branch_state_poll)
        if args.predecessor_nearest_exit_branch_state_poll.exists()
        else {},
        load_json(args.predecessor_reciprocal_exit_branch_state_poll)
        if args.predecessor_reciprocal_exit_branch_state_poll.exists()
        else {},
        load_json(args.predecessor_coordinate_branch_state_poll)
        if args.predecessor_coordinate_branch_state_poll.exists()
        else {},
        load_json(args.predecessor_trail_start_branch_state_poll)
        if args.predecessor_trail_start_branch_state_poll.exists()
        else {},
        load_json(args.predecessor_trail_left_overrun_branch_state_poll)
        if args.predecessor_trail_left_overrun_branch_state_poll.exists()
        else {},
        load_json(args.predecessor_highfreq_branch_state_poll)
        if args.predecessor_highfreq_branch_state_poll.exists()
        else {},
        load_json(args.predecessor_fill_execution_order_gap)
        if args.predecessor_fill_execution_order_gap.exists()
        else {},
        load_json(args.predecessor_fill_site_execution_context)
        if args.predecessor_fill_site_execution_context.exists()
        else {},
    )
    write_outputs(summary, args.out_dir)
    print(
        "wrote predecessor branch-state execution gap -> "
        f"{args.out_dir / 'save_selector_predecessor_branch_state_execution_gap.html'}"
    )


if __name__ == "__main__":
    main()
