{"id":8693,"plugin_id":"plugin_asdk_app_6a3ed08a777481919fe5c4b0c1bb9171","kind":"skill","collection_source":null,"comparison_source":null,"observed_at":"2026-09-30T22:53:17.836Z","digest":"c3c6f04a450ca1196d5b59298525a575346136d46d7efb1d7b134683bd713873","against":null,"payload":{"name":"cja-top-movers-watchlist","description":"Identifies which items (pages, campaigns, products, channels, regions) had the biggest increases or decreases for a key metric between two time periods. Use this skill when someone asks \"what's up and what's down,\" \"which campaigns moved the most,\" \"top gainers and losers,\" \"what pages are trending,\" \"show me what changed by channel,\" or any variation of identifying the biggest movers and decliners for a metric.\n","included_files":[{"relative_path":"evals/evals.json","size_in_bytes":1972}],"skill_md_contents":"---\nname: cja-top-movers-watchlist\ndescription: >\n  Identifies which items (pages, campaigns, products, channels, regions) had the\n  biggest increases or decreases for a key metric between two time periods. Use\n  this skill when someone asks \"what's up and what's down,\" \"which campaigns\n  moved the most,\" \"top gainers and losers,\" \"what pages are trending,\" \"show me\n  what changed by channel,\" or any variation of identifying the biggest movers\n  and decliners for a metric.\nlicense: Apache-2.0\nmetadata:\n  author: Adobe\n  version: \"1.0\"\n---\n\n# Top Movers Watchlist (Customer Journey Analytics)\n\nSurface the biggest gainers and decliners for a metric across any dimension in\ntwo time periods. The output tells the user exactly what moved, by how much, and\nwhether items appeared or disappeared entirely — which is often the most\ninteresting signal.\n\nThis skill is a faster, more targeted alternative to a full anomaly triage.\nUse it when the user wants to scan the landscape of changes rather than drill\ninto a single anomaly.\n\n---\n\n## CJA MCP Tools Used\n\n- `describeCja(DATAVIEW_CONTEXT_GUIDE)` — load data view calendar/timezone\n- `findMetrics` — resolve the metric being watched\n- `findCalculatedMetrics` — if the metric is a custom KPI\n- `findDimensions` — resolve the dimension to break down by\n- `runReport` — pull dimension-metric data for both periods\n- `searchDimensionItems` — validate dimension values if user specifies names\n\n---\n\n## Phase 0 — Setup\n\n1. Call `findDataViews` and `setDefaultSessionDataViewId` as needed.\n2. Call `describeCja(\"DATAVIEW_CONTEXT_GUIDE\")` to load data view context.\n   Record the first-day-of-week as `WEEK_START_DOW` and timezone as\n   `TIMEZONE`. If the context guide does not return a week-start value,\n   default to **Monday** (ISO 8601). You will use both in Phase 1.3.\n\n---\n\n## Phase 1 — Clarify Inputs\n\n### 1.1 Metric\n\nIf the user specified a metric, resolve it:\n```\nfindMetrics(search: \"<user's metric name>\")\n```\n\nIf not specified, suggest the top 3 metrics from usage:\n> \"Which metric would you like to track? I can suggest: Sessions, Revenue,\n> Orders based on what your team uses most.\"\n\n### 1.2 Dimension (what to break down by)\n\nCommon dimension choices and their typical use cases:\n\n| Dimension          | Use Case                                |\n|--------------------|-----------------------------------------|\n| Marketing Channel  | \"Which channels moved?\"                 |\n| Page Name          | \"Which pages are trending?\"             |\n| Campaign           | \"Which campaigns improved?\"             |\n| Product            | \"Which products gained/lost traction?\"  |\n| Country / Region   | \"Which markets moved?\"                  |\n| Device Type        | \"Did mobile or desktop shift?\"          |\n| Referring Domain   | \"Which referrers changed?\"              |\n\nIf the user did not specify, ask:\n> \"Which dimension should I break down by — for example, marketing channel,\n> page, campaign, country, or product?\"\n\nCall `findDimensions(search: \"<dimension keyword>\")` to resolve the dimension ID.\n\n### 1.3 Periods\n\nDefine Period A (current) and Period B (comparison). Defaults:\n- **Period A**: this week (or last 7 days)\n- **Period B**: last week (or the 7 days before that)\n\nIf the user specifies \"this month vs last month\" or a custom range, map\naccordingly. Always confirm the periods before running reports:\n> \"I'll compare **this week (Mar 13–19)** vs **last week (Mar 6–12)**. Sound right?\"\n\n**Calendar rule (mandatory):**\n\nUse `WEEK_START_DOW` from Phase 0 to define what \"week\" means. Period A and\nPeriod B MUST use the same first-day-of-week — i.e., both periods'\n`startDate` fall on the same day-of-week, both are exactly equal length,\nand Period B ends immediately before Period A starts. Never mix conventions\n(e.g., a Mon–Sun Period A with a Sun–Sat Period B) within the same run.\nPick the boundary once, then derive both periods from it. For custom date\nranges, compute Period B as the equal-length window ending immediately\nbefore Period A starts.\n\n**Sanity check before calling `runReport`:** confirm `periodA.startDate`\nand `periodB.startDate` are the same day-of-week and that\n`periodA.startDate - periodB.endDate == 1 day`. If not, recompute.\n\n---\n\n## Phase 2 — Pull Data for Both Periods\n\nRun two reports — one per period — with the same dimension breakdown:\n\n```\nrunReport(\n  dimensionIds: \"<dimension id>\",\n  metricIds: \"<metric id>\",\n  startDate: \"<period A start>T00:00:00\",\n  endDate: \"<period A end>T23:59:59\",\n  page: 0,\n  limit: 50\n)\n```\n\n```\nrunReport(\n  dimensionIds: \"<dimension id>\",\n  metricIds: \"<metric id>\",\n  startDate: \"<period B start>T00:00:00\",\n  endDate: \"<period B end>T23:59:59\",\n  page: 0,\n  limit: 50\n)\n```\n\nUse `limit: 50` to capture enough items to surface meaningful movers.\nIf the user's dimension has thousands of values (e.g., page names), limit to\ntop 100 by Period A volume to keep the comparison meaningful.\n\nRow data is in the `rows` array — each row has `value` (dimension item name)\nand `data[0]` (the metric value). There is no limit on dimension cardinality\nbut results default to sorted by metric descending, which is what you want.\n\nAlways verify the dimension ID with `findDimensions(searchQuery: \"<name>\")` \nbefore running — dimension IDs can vary from what you might guess \n(e.g., `variables/marketing_channel` not `variables/marketingchannel`).\n\n---\n\n## Phase 3 — Compute Rankings\n\nBuild a unified table joining both result sets on dimension value:\n\nFor each dimension value present in either period:\n- `valueA` = metric value in Period A (0 if not present)\n- `valueB` = metric value in Period B (0 if not present)\n- `delta` = valueA − valueB\n- `pctChange` = (delta / valueB) × 100 if valueB > 0, else \"New Entry\"\n- `status`:\n  - Present in A but not B → **New Entry** (appeared this period)\n  - Present in B but not A → **Disappeared** (dropped out this period)\n  - Both present → normal mover\n\nSort by:\n1. **Top Gainers**: sort by delta descending (biggest absolute gains first)\n2. **Top Decliners**: sort by delta ascending (biggest absolute drops first)\n3. **% Gainers**: sort by pctChange descending\n4. **% Decliners**: sort by pctChange ascending\n\nLimit each list to **Top 10**. New Entries and Disappeared items get their\nown sections regardless of count (they are always interesting signals).\n\n---\n\n## Phase 4 — Generate HTML Report\n\nGenerate the movers report inline and write to\n`/tmp/cja_top_movers_report_<YYYY-MM-DD_HHMMSS>.html`.\n\n\n### Rendering rules — apply consistently across runs\n\nTwo runs of this skill on the same data view + metric/dimension + period must\nrender identically (modulo the generation timestamp). The rules below pin the\nformatting choices that the AI would otherwise drift on.\n\n#### Number formatting\n\n- **KPI values** (the big number in each summary tile, and per-row mover\n  values) — use full digits with thousands separators (`8,160`, `77,584`,\n  `1,250,000`). Do **NOT** use SI suffixes like `K` or `M`, even for large\n  values. Stakeholders want exact numbers, not abbreviations.\n- **Percent change** (in pills and narrative bullets) — always one decimal\n  place, rounded **half-away-from-zero**. For example, `−23.55%` displays as\n  `−23.6%`, never `−23.5%`. Compute on full-precision values; round only at\n  display time.\n- **Percentage-point change** (for already-percentage metrics like Conversion\n  Rate or Bounce Rate) — same rounding, suffix `pp`. Example: `+0.40 pp`.\n- **Currency** — `$` prefix with thousands separators and no decimals for\n  values ≥ $100 (`$1,240,000`); cents only when value < $100 (`$45.20`).\n\n#### Null / missing data handling\n\nA KPI tile or mover row must reflect what the data view actually returned.\nThe AI must **not** silently substitute a different metric or hide a tile to\nmake the report look cleaner.\n\n- **Both periods return 0 or NULL** for the tracked metric in a summary tile:\n  render the tile with `kpi-value` = `Data unavailable`, pill class `flat`,\n  pill text `⚠ N/A`, and `prior` text = `Both periods returned no data —\n  validate instrumentation`. The tile stays in the grid; do not omit it.\n- **One period returns valid data, the other 0 / NULL**: render the tile with\n  the valid value as `kpi-value`, pill class `flat`, pill text `⚠ N/A`, and\n  `prior` text = `Prior {period_noun}: no data`.\n- **Never** substitute a different metric (e.g., switching from Revenue to\n  Orders because Revenue came back $0). The metric being analyzed MUST be the\n  metric rendered.\n\n\n### HTML Template\n\n```html\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<title>Top Movers &mdash; {ORG_NAME} &mdash; {METRIC_NAME} by {DIMENSION_NAME}</title>\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Inter:wght@400;500;600;700&display=swap\" rel=\"stylesheet\">\n<style>\n  * { box-sizing: border-box; margin: 0; padding: 0; }\n  :root {\n    --bg: #f5f4f1;\n    --surface: #ffffff;\n    --ink: #1a1a1a;\n    --ink-muted: #6b6b6b;\n    --border: #e5e2dc;\n    --header-bg: #0e0e10;\n    --header-warm: #3a1010;\n    --accent-red: #c8312f;\n    --accent-red-bright: #ff6b68;\n    --accent-red-soft: #fdecea;\n    --accent-green: #1f7a4d;\n    --accent-yellow: #d4a017;\n  }\n  body { font-family: \"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n         background: var(--bg); color: var(--ink); line-height: 1.5;\n         -webkit-font-smoothing: antialiased; }\n\n  /* === Header === */\n  header { background: linear-gradient(120deg, var(--header-bg) 0%, #1a0d0d 55%, var(--header-warm) 100%);\n           color: #fff; padding: 56px 56px 44px; position: relative; overflow: hidden; }\n  header::after { content: \"\"; position: absolute; right: -140px; top: -140px;\n                  width: 460px; height: 460px;\n                  background: radial-gradient(circle, rgba(200,49,47,.35) 0%, transparent 70%);\n                  pointer-events: none; }\n  .header-inner { max-width: 1080px; margin: 0 auto; position: relative; z-index: 1; }\n  .eyebrow { display: inline-flex; align-items: center; gap: 8px;\n             padding: 6px 14px; border: 1px solid rgba(255,107,104,.55);\n             border-radius: 999px; color: var(--accent-red-bright);\n             font-size: 11px; font-weight: 600; letter-spacing: 1.2px;\n             text-transform: uppercase; margin-bottom: 24px;\n             background: rgba(200,49,47,.10); }\n  .eyebrow::before { content: \"\"; width: 6px; height: 6px;\n                     background: var(--accent-red-bright); border-radius: 50%; }\n  header h1 { font-family: \"Playfair Display\", Georgia, serif;\n              font-size: 56px; font-weight: 700; letter-spacing: -1.5px;\n              line-height: 1.05; margin-bottom: 14px; color: #fff; }\n  header .lede { font-size: 16px; max-width: 560px;\n                 color: rgba(255,255,255,.80); margin-bottom: 24px;\n                 line-height: 1.55; }\n  header .meta { display: flex; flex-wrap: wrap; gap: 22px;\n                 font-size: 13px; color: rgba(255,255,255,.60); }\n  header .meta span { display: inline-flex; align-items: center; gap: 6px; }\n  header .meta .icon { opacity: .8; }\n\n  /* === Tabs === */\n  nav { background: var(--surface); border-bottom: 1px solid var(--border);\n        padding: 0 56px; display: flex; gap: 28px;\n        position: sticky; top: 0; z-index: 50; }\n  nav a { display: block; padding: 16px 0; font-size: 14px;\n          color: var(--ink); text-decoration: none;\n          border-bottom: 2px solid transparent;\n          transition: border-color .15s ease; }\n  nav a:hover { border-bottom-color: var(--accent-red); }\n\n  /* === Container === */\n  .container { max-width: 1080px; margin: 0 auto; padding: 36px 56px 60px; }\n\n  /* === Section label === */\n  .section-label { font-size: 11px; font-weight: 700;\n                   text-transform: uppercase; letter-spacing: 1.4px;\n                   color: var(--ink-muted); margin-bottom: 14px;\n                   padding-bottom: 10px; border-bottom: 1px solid var(--border); }\n\n  /* === KPI grid === */\n  .kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));\n             gap: 14px; margin-bottom: 36px; }\n  .kpi-tile { background: var(--surface); border-radius: 8px;\n              padding: 22px 22px 20px;\n              border-top: 3px solid #b9b6ae;\n              box-shadow: 0 1px 3px rgba(0,0,0,.05); }\n  .kpi-tile.down { border-top-color: var(--accent-red); }\n  .kpi-tile.up   { border-top-color: var(--accent-green); }\n  .kpi-tile.flat { border-top-color: #b9b6ae; }\n  .kpi-head { display: flex; justify-content: space-between;\n              align-items: center; margin-bottom: 10px; }\n  .kpi-label { font-size: 11px; font-weight: 700;\n               text-transform: uppercase;\n               color: var(--ink-muted); letter-spacing: 1px; }\n  .kpi-value { font-family: \"Playfair Display\", Georgia, serif;\n               font-weight: 700; font-size: 34px;\n               line-height: 1; color: var(--ink);\n               margin-bottom: 12px; }\n  .pill { display: inline-flex; align-items: center; gap: 4px;\n          padding: 3px 9px; border-radius: 4px;\n          font-size: 12px; font-weight: 600; line-height: 1.4; }\n  .pill.down { background: var(--accent-red-soft); color: var(--accent-red); }\n  .pill.up   { background: #ebf5ef; color: var(--accent-green); }\n  .pill.flat { background: #f1efea; color: var(--ink-muted); }\n  .prior { display: block; margin-top: 10px;\n           font-size: 12px; color: var(--ink-muted); }\n\n  /* === Dual risers / fallers panels === */\n  .two-col { display: grid; grid-template-columns: 1fr 1fr;\n             gap: 20px; margin-bottom: 22px; }\n  @media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }\n\n  /* === Sections (collapsible tables) === */\n  .section { background: var(--surface); border-radius: 8px;\n             box-shadow: 0 1px 3px rgba(0,0,0,.04);\n             margin-bottom: 22px; overflow: hidden; }\n  /* Top-border accent on risers/fallers tiles */\n  .section.risers  { border-top: 3px solid var(--accent-green); }\n  .section.fallers { border-top: 3px solid var(--accent-red); }\n  .section-header { padding: 18px 28px; border-bottom: 1px solid var(--border);\n                    display: flex; justify-content: space-between;\n                    align-items: center; cursor: pointer; }\n  .section-header h2 { font-family: \"Playfair Display\", Georgia, serif;\n                       font-size: 18px; font-weight: 700; }\n  .section.risers  .section-header h2 { color: var(--accent-green); }\n  .section.fallers .section-header h2 { color: var(--accent-red); }\n\n  table { width: 100%; border-collapse: collapse; font-size: 13px; }\n  thead th { background: #faf8f4; padding: 12px 22px;\n             text-align: left; font-weight: 600;\n             text-transform: uppercase; letter-spacing: .6px;\n             font-size: 11px; color: var(--ink-muted);\n             border-bottom: 1px solid var(--border); }\n  tbody td { padding: 12px 22px; border-bottom: 1px solid #f4f1eb; }\n  tbody tr:last-child td { border-bottom: none; }\n\n  .delta-up   { color: var(--accent-green); font-weight: 600; }\n  .delta-down { color: var(--accent-red);   font-weight: 600; }\n\n  .badge { display: inline-block; padding: 3px 9px; border-radius: 4px;\n           font-size: 11px; font-weight: 600; }\n  .badge.green  { background: #ebf5ef; color: var(--accent-green); }\n  .badge.red    { background: var(--accent-red-soft); color: var(--accent-red); }\n  .badge.yellow { background: #fef6e3; color: #b67a08; }\n  .badge.blue   { background: #eef2f8; color: #2c4a7a; }\n  .badge.grey   { background: #f1efea; color: var(--ink-muted); }\n\n  .back-top { position: fixed; bottom: 24px; right: 24px;\n              background: var(--accent-red); color: #fff;\n              width: 44px; height: 44px; border-radius: 50%;\n              border: none; font-size: 20px; cursor: pointer;\n              box-shadow: 0 4px 12px rgba(200,49,47,0.30); }\n  footer { text-align: center; padding: 32px 24px;\n           font-size: 12px; color: var(--ink-muted); }\n\n  /* === Print === */\n  @media print {\n    nav { display: none; position: static; }\n    header { padding: 36px 32px 28px; }\n    header h1 { font-size: 42px; }\n    .section-header { cursor: default; }\n    .kpi-row { page-break-inside: avoid; }\n    .kpi-tile, .section {\n      box-shadow: none; border: 1px solid var(--border);\n    }\n    .back-top { display: none; }\n  }\n</style>\n</head>\n<body>\n\n<header>\n  <div class=\"header-inner\">\n    <div class=\"eyebrow\">Top Movers Report</div>\n    <h1>{ORG_NAME} Top Movers</h1>\n    <p class=\"lede\">Biggest gainers and decliners for {METRIC_NAME} by {DIMENSION_NAME}, {PERIOD_A_LABEL} vs {PERIOD_B_LABEL}.</p>\n    <div class=\"meta\">\n      <span><span class=\"icon\">&#128197;</span> {PERIOD_A_LABEL}</span>\n      <span><span class=\"icon\">&#128202;</span> {DATA_VIEW}</span>\n      <span><span class=\"icon\">&#128340;</span> Prepared {GENERATED_DATE}</span>\n    </div>\n  </div>\n</header>\n\n<nav>\n  <a href=\"#summary\">Summary</a>\n  <a href=\"#gainers\">Gainers</a>\n  <a href=\"#decliners\">Decliners</a>\n  <a href=\"#newdisappeared\">New &amp; Gone</a>\n  <a href=\"#fulltable\">Full Table</a>\n</nav>\n\n<div class=\"container\">\n\n  <!-- Summary KPI Tiles -->\n  <div class=\"section-label\">Watchlist Summary</div>\n  <div id=\"summary\" class=\"kpi-row\">\n    <div class=\"kpi-tile flat\">\n      <div class=\"kpi-head\"><div class=\"kpi-label\">Total Items Compared</div></div>\n      <div class=\"kpi-value\">{TOTAL_ITEMS}</div>\n      <span class=\"prior\">Dimension values in scope</span>\n    </div>\n    <div class=\"kpi-tile up\">\n      <div class=\"kpi-head\"><div class=\"kpi-label\">Biggest Gain</div></div>\n      <div class=\"kpi-value\">{TOP_GAINER_VALUE}</div>\n      <span class=\"pill up\">&#9650; {TOP_GAINER_NAME}</span>\n    </div>\n    <div class=\"kpi-tile down\">\n      <div class=\"kpi-head\"><div class=\"kpi-label\">Biggest Drop</div></div>\n      <div class=\"kpi-value\">{TOP_DECLINER_VALUE}</div>\n      <span class=\"pill down\">&#9660; {TOP_DECLINER_NAME}</span>\n    </div>\n    <div class=\"kpi-tile flat\">\n      <div class=\"kpi-head\"><div class=\"kpi-label\">New Entries</div></div>\n      <div class=\"kpi-value\">{NEW_ENTRIES}</div>\n      <span class=\"prior\">Appeared this period</span>\n    </div>\n    <div class=\"kpi-tile flat\">\n      <div class=\"kpi-head\"><div class=\"kpi-label\">Disappeared</div></div>\n      <div class=\"kpi-value\">{DISAPPEARED}</div>\n      <span class=\"prior\">Dropped out this period</span>\n    </div>\n  </div>\n\n  <!-- Gainers + Decliners side by side -->\n  <div class=\"two-col\">\n\n    <div id=\"gainers\" class=\"section risers\">\n      <div class=\"section-header\" onclick=\"toggle('gain-body')\">\n        <h2>&#9650; Top 10 Gainers</h2>\n        <span id=\"gain-body-icon\">&#9662;</span>\n      </div>\n      <div id=\"gain-body\">\n        <table>\n          <thead><tr>\n            <th>Item</th>\n            <th>{PERIOD_A_LABEL}</th>\n            <th>{PERIOD_B_LABEL}</th>\n            <th>Delta</th>\n            <th>% Change</th>\n          </tr></thead>\n          <tbody>\n            <!-- Top 10 gainers, sorted by delta desc -->\n            <!--\n            <tr>\n              <td>{ITEM_NAME}</td>\n              <td>{VALUE_A}</td>\n              <td>{VALUE_B}</td>\n              <td class=\"delta-up\">+{DELTA}</td>\n              <td><span class=\"badge green\">+{PCT}%</span></td>\n            </tr>\n            -->\n          </tbody>\n        </table>\n      </div>\n    </div>\n\n    <div id=\"decliners\" class=\"section fallers\">\n      <div class=\"section-header\" onclick=\"toggle('dec-body')\">\n        <h2>&#9660; Top 10 Decliners</h2>\n        <span id=\"dec-body-icon\">&#9662;</span>\n      </div>\n      <div id=\"dec-body\">\n        <table>\n          <thead><tr>\n            <th>Item</th>\n            <th>{PERIOD_A_LABEL}</th>\n            <th>{PERIOD_B_LABEL}</th>\n            <th>Delta</th>\n            <th>% Change</th>\n          </tr></thead>\n          <tbody>\n            <!-- Top 10 decliners, sorted by delta asc -->\n            <!--\n            <tr>\n              <td>{ITEM_NAME}</td>\n              <td>{VALUE_A}</td>\n              <td>{VALUE_B}</td>\n              <td class=\"delta-down\">&minus;{DELTA}</td>\n              <td><span class=\"badge red\">&minus;{PCT}%</span></td>\n            </tr>\n            -->\n          </tbody>\n        </table>\n      </div>\n    </div>\n\n  </div>\n\n  <!-- New Entries & Disappeared -->\n  <div id=\"newdisappeared\" class=\"section\">\n    <div class=\"section-header\" onclick=\"toggle('nd-body')\">\n      <h2>New Entries &amp; Disappeared Items</h2>\n      <span id=\"nd-body-icon\">&#9662;</span>\n    </div>\n    <div id=\"nd-body\">\n      <table>\n        <thead><tr>\n          <th>Item</th>\n          <th>Status</th>\n          <th>{PERIOD_A_LABEL}</th>\n          <th>{PERIOD_B_LABEL}</th>\n          <th>Notes</th>\n        </tr></thead>\n        <tbody>\n          <!-- New entries: badge blue \"New Entry\" -->\n          <!-- Disappeared: badge grey \"Disappeared\" -->\n        </tbody>\n      </table>\n    </div>\n  </div>\n\n  <!-- Full Table -->\n  <div id=\"fulltable\" class=\"section\">\n    <div class=\"section-header\" onclick=\"toggle('full-body')\">\n      <h2>Full Comparison Table</h2>\n      <span id=\"full-body-icon\">&#9662;</span>\n    </div>\n    <div id=\"full-body\">\n      <table>\n        <thead><tr>\n          <th>Item</th>\n          <th>{PERIOD_A_LABEL}</th>\n          <th>{PERIOD_B_LABEL}</th>\n          <th>Delta</th>\n          <th>% Change</th>\n          <th>Status</th>\n        </tr></thead>\n        <tbody>\n          <!-- All items sorted by absolute delta desc -->\n        </tbody>\n      </table>\n    </div>\n  </div>\n\n</div>\n\n<button class=\"back-top\" onclick=\"window.scrollTo({top:0,behavior:'smooth'})\">&uarr;</button>\n<footer>Top Movers &mdash; {ORG_NAME} &mdash; Generated {GENERATED_DATE}</footer>\n\n<script>\nfunction toggle(id) {\n  var el = document.getElementById(id);\n  var ic = document.getElementById(id + '-icon');\n  if (el.style.display === 'none') { el.style.display=''; ic.textContent='\\u25be'; }\n  else { el.style.display='none'; ic.textContent='\\u25b8'; }\n}\n</script>\n</body></html>\n```\n\n---\n\n## Workflow Summary\n\n1. Confirm metric, dimension, and both time periods.\n2. Run `runReport` for Period A with dimension breakdown (limit 50).\n3. Run `runReport` for Period B with same parameters.\n4. Join on dimension value; compute delta, pctChange, and status.\n5. Sort into: Top 10 Gainers, Top 10 Decliners, New Entries, Disappeared.\n6. Generate HTML report inline, write to `/tmp/cja_top_movers_report_<YYYY-MM-DD_HHMMSS>.html`.\n7. Open with `open /tmp/cja_top_movers_report_<YYYY-MM-DD_HHMMSS>.html`.\n8. Deliver a 3-line inline summary: \"Top gainer: X (+Y%), Top decliner: Z (−W%).\n   N new items entered the top 50; M items disappeared.\"\n\n---\n\n## Important Guardrails\n\n- **Read-only monitoring.** Never modify segments, metrics, or project definitions.\n- **Confirm metric and segment scope** before running. Vague requests (\"watch everything\") need narrowing — ask which dimensions and metrics matter most.\n- **Use consistent comparison windows.** \"Top movers\" must compare equal-length periods; mismatched windows produce false signals.\n- **Distinguish noise from signal.** Very low-traffic dimension values (e.g., a segment with 5 visits) can show 500% swings — apply a minimum threshold (e.g., at least 100 sessions) before flagging as a mover.\n- **Cap the watchlist size.** Surface the top 10–20 movers by default; overwhelming users with 100 dimension items defeats the purpose.\n- **Attribute changes to context.** When possible, note known business events (campaigns, releases, outages) that could explain movements.\n\n## Example Interaction\n\n> \"Which marketing channels moved the most last week vs the week before?\"\n\n1. Metric: Sessions (top usage default)\n2. Dimension: Marketing Channel\n3. Period A: last week, Period B: the week before\n4. Run both reports, join results\n5. Gainers: Paid Social +32%, Organic Search +8%\n6. Decliners: Email −18%, Direct −5%\n7. New: Affiliate (not in top 50 prior week)\n8. Generate and open report\n9. Inline summary: \"Paid Social drove the biggest gain (+32%). Email was\n   the top decliner (−18%). Affiliate channel appeared for the first time\n   in the top rankings.\"\n"},"changes":[],"summary":"First saved snapshot. No earlier version is available for comparison.","summary_kind":"deterministic","summary_metadata":{}}