{
  "filename": "src/useOrderFeed.js",
  "rule": "- name: feed-scope-disposes-resources\n  where: \"src/useOrderFeed.js\"\n  ensure: >-\n    onScopeDispose must unsubscribe from the order feed and close the connection when the composable scope ends.",
  "corrected": "import { ref, onScopeDispose } from \"vue\";\n\nexport function useOrderFeed(connect) {\n  const updates = ref([]);\n  const connection = connect();\n  let stopped = false;\n  const unsubscribe = connection.subscribe(update => {\n    if (!stopped) updates.value = [...updates.value, update];\n  });\n  onScopeDispose(() => {\n    stopped = true;\n    unsubscribe();\n    connection.close();\n  });\n  return updates;\n}\n",
  "broken": "import { ref, onScopeDispose } from \"vue\";\n\nexport function useOrderFeed(connect) {\n  const updates = ref([]);\n  const connection = connect();\n  let stopped = false;\n  const unsubscribe = connection.subscribe(update => {\n    if (!stopped) updates.value = [...updates.value, update];\n  });\n  onScopeDispose(() => {\n    stopped = true;\n    // Subscription and socket are accidentally retained.\n  });\n  return updates;\n}\n",
  "regression": [
    "    unsubscribe();\n    connection.close();",
    "    // Subscription and socket are accidentally retained."
  ],
  "test_scenarios": [
    [
      "Component remains mounted",
      "Updates appended"
    ],
    [
      "Scope disposed",
      "Unsubscribe and close called once"
    ],
    [
      "Queued update arrives after disposal",
      "Ignored"
    ],
    [
      "Shared transport",
      "Adapter releases only this ownership share"
    ]
  ],
  "test_source": null,
  "test_command": "npx vitest run src/useOrderFeed.test.js"
}