{
  "$schema": "https://farmslot.io/schemas/recipe-v1.schema.json",
  "title": "Extension navigation retained-memory audit",
  "description": "Measures post-GC retained nodes and listeners across eight representative Extension screens, verifies detached DOM does not grow, and separates navigation-attributable listener growth from an equal-duration idle control.",
  "proofTargets": [
    {
      "id": "screen-slopes",
      "claim": "Eight representative Extension screens remain within separate post-GC retained-node and listener growth bounds during navigation churn."
    },
    {
      "id": "detached-dom",
      "claim": "Detached DOM retained after forced garbage collection does not grow beyond the declared bound."
    },
    {
      "id": "idle-control",
      "claim": "Navigation-attributable listener growth remains within its declared bound after subtracting an equal-duration idle control."
    }
  ],
  "workflow": {
    "entry": "require-cdp",
    "nodes": {
      "require-cdp": {
        "action": "cdp.target",
        "required": true,
        "require_reachable": true,
        "intent": "Confirm the live Extension CDP target is reachable before measuring retained memory.",
        "next": "ensure-unlocked"
      },
      "ensure-unlocked": {
        "action": "metamask.wallet.ensure_unlocked",
        "intent": "Ensure the representative screens are reachable from an unlocked wallet.",
        "next": "market-detail"
      },
      "market-detail": {
        "action": "metamask.performance.measure_navigation_memory",
        "screen_hash": "#/perps/market/ETH",
        "screen_test_id": "perps-market-detail-page",
        "return_hash": "#/",
        "cycles": 8,
        "timeout_ms": 400000,
        "max_nodes_per_cycle": 2,
        "max_listeners_per_cycle": 4,
        "intent": "Measure the post-GC navigation slope for Perps market detail.",
        "proves": ["screen-slopes"],
        "next": "order-entry"
      },
      "order-entry": {
        "action": "metamask.performance.measure_navigation_memory",
        "screen_hash": "#/perps/trade/ETH?direction=long&mode=new",
        "screen_test_id": "perps-order-entry-page",
        "return_hash": "#/",
        "cycles": 6,
        "timeout_ms": 400000,
        "max_nodes_per_cycle": 2,
        "max_listeners_per_cycle": 4,
        "intent": "Measure the post-GC navigation slope for Perps order entry.",
        "proves": ["screen-slopes"],
        "next": "perps-home"
      },
      "perps-home": {
        "action": "metamask.performance.measure_navigation_memory",
        "screen_hash": "#/perps-home",
        "screen_test_id": "perps-home-page",
        "return_hash": "#/",
        "cycles": 6,
        "timeout_ms": 400000,
        "max_nodes_per_cycle": 2,
        "max_listeners_per_cycle": 4,
        "intent": "Measure the post-GC navigation slope for Perps home.",
        "proves": ["screen-slopes"],
        "next": "market-list"
      },
      "market-list": {
        "action": "metamask.performance.measure_navigation_memory",
        "screen_hash": "#/perps/market-list",
        "screen_test_id": "market-list-view",
        "return_hash": "#/",
        "cycles": 6,
        "timeout_ms": 400000,
        "max_nodes_per_cycle": 2,
        "max_listeners_per_cycle": 4,
        "intent": "Measure the post-GC navigation slope for the Perps market list.",
        "proves": ["screen-slopes"],
        "next": "perps-activity"
      },
      "perps-activity": {
        "action": "metamask.performance.measure_navigation_memory",
        "screen_hash": "#/perps/activity",
        "screen_test_id": "perps-activity-page",
        "return_hash": "#/",
        "cycles": 6,
        "timeout_ms": 400000,
        "max_nodes_per_cycle": 2,
        "max_listeners_per_cycle": 4,
        "intent": "Measure the post-GC navigation slope for Perps activity.",
        "proves": ["screen-slopes"],
        "next": "asset-details"
      },
      "asset-details": {
        "action": "metamask.performance.measure_navigation_memory",
        "screen_hash": "#/asset/0x1/",
        "screen_test_id": "asset-price-chart",
        "return_hash": "#/",
        "cycles": 6,
        "timeout_ms": 400000,
        "max_nodes_per_cycle": 2,
        "max_listeners_per_cycle": 4,
        "intent": "Measure the post-GC navigation slope for asset details.",
        "proves": ["screen-slopes"],
        "next": "swaps-bridge"
      },
      "swaps-bridge": {
        "action": "metamask.performance.measure_navigation_memory",
        "screen_hash": "#/cross-chain/swaps/prepare-bridge-page",
        "screen_test_id": "bridge-source-button",
        "return_hash": "#/",
        "cycles": 6,
        "timeout_ms": 400000,
        "max_nodes_per_cycle": 2,
        "max_listeners_per_cycle": 4,
        "intent": "Measure the post-GC navigation slope for Swaps and Bridge.",
        "proves": ["screen-slopes"],
        "next": "settings-control"
      },
      "settings-control": {
        "action": "metamask.performance.measure_navigation_memory",
        "screen_hash": "#/settings",
        "screen_test_id": "settings-tab-bar-grouped",
        "return_hash": "#/",
        "cycles": 6,
        "timeout_ms": 400000,
        "max_nodes_per_cycle": 2,
        "max_listeners_per_cycle": 4,
        "intent": "Measure a non-Perps control screen with the same retained-memory gate.",
        "proves": ["screen-slopes"],
        "next": "detached-market-detail"
      },
      "detached-market-detail": {
        "action": "metamask.performance.measure_detached_dom",
        "screen_hash": "#/perps/market/ETH",
        "screen_test_id": "perps-market-detail-page",
        "return_hash": "#/",
        "cycles": 5,
        "timeout_ms": 400000,
        "max_detached_growth": 50,
        "intent": "Compare retained detached DOM before and after market-detail navigation churn.",
        "proves": ["detached-dom"],
        "next": "idle-control-market-detail"
      },
      "idle-control-market-detail": {
        "action": "metamask.performance.compare_idle_navigation_memory",
        "screen_hash": "#/perps/market/ETH",
        "screen_test_id": "perps-market-detail-page",
        "return_hash": "#/",
        "rounds": 8,
        "round_duration_ms": 10000,
        "timeout_ms": 400000,
        "max_attributable_listeners_per_cycle": 2,
        "intent": "Subtract equal-duration idle growth from the market-detail navigation slope.",
        "proves": ["idle-control"],
        "next": "return-home"
      },
      "return-home": {
        "action": "ui.navigate",
        "page": "home",
        "intent": "Leave the Extension on a known screen after the audit.",
        "next": "done"
      },
      "done": {
        "action": "end",
        "status": "pass"
      }
    }
  }
}
