GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / AI agents and coordination / spiders / species/seer-spider/estate-menu

Estate Menu Proof and 2 more files

A JavaScript module in the seer spider folder of Spiders that reads cables. It loads Playwright (`loadPlaywright`), runs structural checks (`runStructuralChecks`) and labels URL (`labelFromUrl`).

685 lines of JavaScript and HTML from spiders, in 3 files. Topic: AI agents and coordination. Section 1651 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Estate Menu render · spiders / species/seer-spider/estate-menu/estate-menu.js lines 701–942
  2. Estate Menu Proof render · spiders / species/seer-spider/estate-menu/estate-menu.proof.mjs lines 1–436
  3. Species — Seer Spider Page render · spiders / species/seer-spider/index.html lines 1–7

Estate Menu

A JavaScript file in the seer spider folder of Spiders covering cables and uses data from the GridAtlas, data-federation-map-for-GlobalGrid2050-all-repos and Ventus Grid Engine repositories.

renderspiders / species/seer-spider/estate-menu/estate-menu.js · lines 701–942 of 942 (continued from section 1650) · Entry point · pattern labelFromUrl (shared by 2 files)

What it does
It draws cables. Defines 41 functions or classes, including array, cleanText, sortByLabel, el, normaliseUrl. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage agent_infra (path word 'spider'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). Domain terms in the code: cables. README: "One self-contained JavaScript module — `estate-menu.js` — that renders the shared FILE / EDIT / VIEW / SCOPE / GRID / ABOUT menu bar so a human, an AI or a developer can navigate the whole GlobalGrid2050 estate from any page: the homepage, Pipeline News, GridAtlas, the federation map, the grid engine receiver, or the spider species lab."
Inputs & outputs
In: data source: gridatlas data; data source: data-federation-map-for-globalgrid2050-all-repos data; data source: ventus-grid-engine data; data source: cvaa data; data source: data-grid-gb data; data source: grid-distance-maths data; data source: pipelinenews data; JSON file current.json.
Downstream impact
Used directly by 9 files: Demo with Host Bar (spiders, https://ventusltd.github.io/spiders/species/seer-spider/estate-menu/demo-with-host-bar.html); Demo (spiders, https://ventusltd.github.io/spiders/species/seer-spider/estate-menu/demo.html); Spider — V1 Click Fix Page (testcode); Spider — V2 Badges Labels Alsoin Page (testcode); and 5 more. Reached from 48 other entry points, including Grid Engine — Compute Against Charging Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060324-compute-against-charging/); Grid Engine — Connection Cap Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060212-connection-cap/); Grid Engine — Corridor Estimate Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060237-corridor-estimate/).
What it achieves
It cleans text (`cleanText`), sorts label (`sortByLabel`) and normalises URL (`normaliseUrl`). VENTUS Estate Menu — shared FILE / EDIT / VIEW / SCOPE / GRID / ABOUT bar. It responds to click, keydown and resize events.
Why it matters
Loaded by the Demo with Host Bar page at https://ventusltd.github.io/spiders/species/seer-spider/estate-menu/demo-with-host-bar.html and 8 other pages.
Application
spiders · species/seer-spider/estate-menu · script
Uses
UK Renewables Pipeline — V9 7 Page (estate URL), UK Renewables Pipeline — V9 6 2 Page (estate URL), UK Renewables Pipeline — V9 6 1 Page (estate URL), UK Renewables Pipeline — V9 6 Page (estate URL), UK Renewables Pipeline — V9 5 1 Page (estate URL), UK Renewables Pipeline — V9 5 Page (estate URL), UK Renewables Pipeline — V9 4 Page (estate URL), UK Renewables Pipeline — V9 Page (estate URL), and 5 more
Used by
loaded by Demo with Host Bar (script src), loaded by Demo (script src), loaded by Spider — V1 Click Fix Page (script src), loaded by Spider — V2 Badges Labels Alsoin Page (script src), loaded by Spider — V3 Bundles Derived Links Page (script src), loaded by Spider — V4 Three Roads Page (script src), loaded by Spider — V5 Linkify Frontdoor Brandfaithful Page (script src), loaded by Spider Sandbox (script src), and 1 more
Produces
array, cleanText, sortByLabel, el, normaliseUrl, isCurrentUrl, isHttpUrl, menuBlock, fileEntries, labelFromUrl, editEntries, viewEntries
Defines here
renderEdit, renderView, renderScope, renderGrid, renderAbout, renderMenus, applyClearance, documentClickCloser, mountInternal, mount, resolveManifestURL, loadManifest, start
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
spiders@78fc0f90bd5ca73f3d5d7c0e0b7b5712cfe781e5 species/seer-spider/estate-menu/estate-menu.js:701-942 · blob 90e34593252924305a1d43e75fe0bae49aa78581 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: agent_infra · users: ai_agent · canonical: unknown
    /* NOT alphabetised — see the EXCEPTION on sortByLabel() above: these
       are version lists, kept newest-first with the current build leading. */
    fileEntries().forEach(function (item) {
      appendGroup(panel, item.label);
      if (item.current) {
        var surfaceLabel = surfaceUrls[item.current.url];
        if (surfaceLabel) {
          panel.appendChild(makeRow(item.current.label + ' — current', 'linked once, under VIEW → ' + surfaceLabel, item.verified || null));
        } else {
          panel.appendChild(makeLink(item.current.label + ' — current', item.current.url, {
            meta: item.verified || null,
            current: isCurrentUrl(item.current.url)
          }));
        }
      }
      if (item.superseded && item.superseded.length) {
        var details = document.createElement('details');
        details.className = 'gm-disclosure';
        var summary = document.createElement('summary');
        summary.textContent = 'Superseded (' + item.superseded.length + ')';
        details.appendChild(summary);
        item.superseded.forEach(function (s) {
          details.appendChild(makeLink(s.label, s.url, { current: isCurrentUrl(s.url) }));
        });
        panel.appendChild(details);
      }
      if (item.pinned_pattern || item.ledger) {
        appendNote(panel, [
          item.pinned_pattern ? ('Pinned generations follow ' + item.pinned_pattern) : null,
          item.ledger ? ('Ledger: ' + item.ledger) : null
        ].filter(Boolean).join(' — '));
      }
    });
  }

  function renderEdit(panel) {
    panel.innerHTML = '';
    appendNote(panel, (menuBlock('EDIT') || {}).purpose || '');
    sortByLabel(editEntries()).forEach(function (item) {
      panel.appendChild(makeRow(item.label, item.path, item.detail));
    });
  }

  function renderView(panel) {
    panel.innerHTML = '';
    var data = viewEntries();
    appendGroup(panel, 'Surfaces');
    sortByLabel(data.surfaces).forEach(function (item) {
      panel.appendChild(makeLink(item.label + (item.isCurrent ? ' — you are here' : ''), item.url, {
        meta: item.title || null,
        current: item.isCurrent
      }));
    });
    if (data.proofs.length) {
      appendGroup(panel, 'Proofs (run from the spiders’ own tooling, not a link)');
      sortByLabel(data.proofs).forEach(function (item) {
        panel.appendChild(makeRow(item.label, item.tool, null));
      });
    }
  }

  function renderScope(panel) {
    panel.innerHTML = '';
    appendGroup(panel, 'Scope');
    appendNote(panel, scopeEntries()[0].note);
  }

  function renderGrid(panel) {
    panel.innerHTML = '';
    appendGroup(panel, 'Grid');
    appendNote(panel, gridEntries()[0].note);
  }

  function renderAbout(panel) {
    panel.innerHTML = '';
    appendGroup(panel, 'Genome');
    sortByLabel(aboutEntries()).forEach(function (item) {
      if (item.url) {
        panel.appendChild(makeLink(item.label, item.url, { current: isCurrentUrl(item.url) }));
      } else {
        panel.appendChild(makeRow(item.label, item.source, item.status));
      }
    });
  }

  function renderMenus() {
    if (!panels.File) return;
    renderFile(panels.File);
    renderEdit(panels.Edit);
    renderView(panels.View);
    renderScope(panels.Scope);
    renderGrid(panels.Grid);
    renderAbout(panels.About);
  }

  /* -----------------------------------------------------------------------
     Clearance — pushes the host page's own content down by the bar's own
     rendered height, via --gridatlas-menu-bar-clear (reusing the exact
     variable name gridatlas's own module uses for the same purpose against
     its map-attribution credit — menu-bar.js lines 370-386). This module
     measures the ORIGINAL padding-top of the mount target before adding to
     it, once, so a host page's own top spacing is preserved rather than
     overwritten. */
  function applyClearance(doc, target) {
    if (!bar || typeof bar.getBoundingClientRect !== 'function') return;
    var rect = bar.getBoundingClientRect();
    var height = Math.ceil(rect.height) || 36;
    var clearance = height + 8;
    var root = doc.documentElement;
    if (root && root.style && typeof root.style.setProperty === 'function') {
      root.style.setProperty(CLEAR_VAR, clearance + 'px');
    }
    if (target !== doc.body) return;   // only auto-push body flow when we own the whole page
    var body = doc.body;
    if (!body) return;
    var ATTR = 'data-ventus-estate-menu-original-padding-top';
    if (!body.hasAttribute(ATTR)) {
      var cs = (doc.defaultView || window).getComputedStyle(body);
      body.setAttribute(ATTR, String(parseFloat(cs.paddingTop) || 0));
    }
    var original = parseFloat(body.getAttribute(ATTR)) || 0;
    body.style.paddingTop = (original + clearance) + 'px';
  }

  /* -----------------------------------------------------------------------
     mount()
     -------------------------------------------------------------------- */
  function documentClickCloser(event) {
    if (!bar) return;
    if (!bar.contains(event.target)) closeAll();
  }

  function mountInternal(target) {
    var doc = document;
    target = target || doc.body;
    if (!target) return { mounted: false, reason: 'no document.body available yet' };

    if (doc.getElementById(HOST_BAR_ID)) {
      state.mounted = false;
      state.reason = 'host bar present';
      return { mounted: false, reason: 'host bar present' };
    }

    if (bar && doc.getElementById(BAR_ID)) {
      /* Already mounted by this module — idempotent. */
      applyClearance(doc, target);
      return { mounted: true, bar: bar };
    }

    installStyle(doc);
    bar = buildBar(doc);
    renderMenus();

    target.insertBefore(bar, target.firstChild);
    doc.documentElement.classList.add(HOSTED_CLASS);
    applyClearance(doc, target);

    if (typeof ResizeObserver === 'function') {
      var ro = new ResizeObserver(function () {
        applyClearance(doc, target);
        if (openPanelRefs) clampPanel(openPanelRefs.menu, openPanelRefs.panel);
      });
      ro.observe(bar);
    } else if (window.addEventListener) {
      window.addEventListener('resize', function () {
        applyClearance(doc, target);
        if (openPanelRefs) clampPanel(openPanelRefs.menu, openPanelRefs.panel);
      });
    }

    doc.addEventListener('click', documentClickCloser);

    state.mounted = true;
    state.reason = null;
    NS._installedByThisModule = true;
    return { mounted: true, bar: bar };
  }

  function mount(target) {
    return mountInternal(target);
  }

  NS.mount = mount;

  /* -----------------------------------------------------------------------
     Manifest loading — fetch first (relative to this module's own script
     location), inline fallback second. entries()/mount() both work
     immediately from the inline copy; if the fetch succeeds, the manifest
     is upgraded in place and any already-rendered panel content is rebuilt
     from it.
     -------------------------------------------------------------------- */
  function resolveManifestURL() {
    try {
      var cs = document.currentScript;
      if (cs && cs.src) return new URL('estate-menu-manifest.json', cs.src).href;
    } catch (e) { /* fall through */ }
    try {
      var scripts = document.getElementsByTagName('script');
      for (var i = 0; i < scripts.length; i++) {
        var src = scripts[i].src || '';
        if (/estate-menu\.js(\?.*)?$/.test(src)) {
          return new URL('estate-menu-manifest.json', src).href;
        }
      }
    } catch (e2) { /* fall through */ }
    return 'estate-menu-manifest.json';
  }

  function loadManifest() {
    if (typeof fetch !== 'function') return;
    var url = resolveManifestURL();
    fetch(url, { cache: 'no-cache' }).then(function (r) {
      if (!r.ok) throw new Error('http ' + r.status);
      return r.json();
    }).then(function (data) {
      if (!data || !data.menus) throw new Error('malformed manifest');
      state.manifest = data;
      state.manifest_source = 'fetch:' + url;
      NS.manifest = state.manifest;
      renderMenus();
    }).catch(function () {
      state.manifest_source = 'inline-fallback';
    });
  }

  /* -----------------------------------------------------------------------
     Auto-run — mirrors the gridatlas idiom (menu-bar.js lines 884-918): on
     a page with no host bar, install; on a page that already has one,
     publish the contract only.
     -------------------------------------------------------------------- */
  function start() {
    mountInternal(document.body);
  }

  loadManifest();

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', start, { once: true });
  } else {
    start();
  }
}());

Estate Menu Proof

A JavaScript module in the seer spider folder of Spiders that reads cables. It loads Playwright (`loadPlaywright`), runs structural checks (`runStructuralChecks`) and labels URL (`labelFromUrl`).

renderspiders / species/seer-spider/estate-menu/estate-menu.proof.mjs · lines 1–436 of 436 · Entry point · pattern labelFromUrl (shared by 2 files)

What it does
It loads cables. Defines 16 functions or classes, including loadPlaywright, fileUrl, record, manifestUrlList, withPage. Uses libraries node:url, node:path, node:fs, playwright. Side effects: changes the web page (DOM); reads or writes files.
Why it exists in the grid workflow
Domain stage agent_infra (path word 'spider'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). Domain terms in the code: cables. README: "`estate-menu.proof.mjs` — the automated proof."
Inputs & outputs
In: JSON file estate-menu-manifest.json.
Downstream impact
It is itself an entry point (JavaScript module); no other file was found loading it.
What it achieves
Each check below is a plain-English sentence.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
spiders · species/seer-spider/estate-menu · JavaScript module
Uses
Spiders — Index Page (estate URL), node:url, node:path, node:fs, playwright
Used by
none found
Produces
loadPlaywright, fileUrl, record, manifestUrlList, withPage, runStructuralChecks, labelFromUrl, isAlphabetical, runOrderingAndBrandChecks, panelForTitle, bucketsOf, expectedSuperseded
Defines here
loadPlaywright, fileUrl, record, manifestUrlList, withPage, runStructuralChecks, labelFromUrl, isAlphabetical, runOrderingAndBrandChecks, panelForTitle, bucketsOf, expectedSuperseded, runCurrentSurfaceCheck, runFederationOverlapCheck, screenshotDemoAndPipeline, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
spiders@78fc0f90bd5ca73f3d5d7c0e0b7b5712cfe781e5 species/seer-spider/estate-menu/estate-menu.proof.mjs:1-436 · blob f1b7d178cd6cfd742a4067d7ca28d7e0fe9c7ebc · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: agent_infra · users: ai_agent · canonical: unknown
#!/usr/bin/env node
/* estate-menu.proof.mjs
   ======================================================================
   Each check below is a plain-English sentence. Failures accumulate; the
   process exits non-zero if any failed. This mirrors the estate's own
   proof idiom (gridatlas/tools/proofs/run-current.mjs) rather than a
   generic test framework.

   PLAYWRIGHT RESOLUTION
   ----------------------
   This directory does not ship its own node_modules. The task that built
   this proof was told a specific, already-provisioned Playwright install
   to use:

     C:\Users\vikra\AppData\Local\Temp\claude\C--Users-vikra\
       82e00a22-a262-414e-b7f4-edfed1c86a66\scratchpad\node_modules

   That path is session-specific (it is a Claude Code scratchpad, not part
   of any repository) and WILL NOT exist in another environment. Two ways
   to point this proof at a real Playwright install elsewhere:

     1. Set PLAYWRIGHT_MODULE_PATH to the absolute path of a
        `playwright/index.mjs` (or any module exporting `chromium` and
        `webkit`) before running this file, e.g.:
          PLAYWRIGHT_MODULE_PATH=C:/path/to/node_modules/playwright/index.mjs node estate-menu.proof.mjs
     2. Otherwise this script falls back to the scratchpad path above,
        then to a plain `import('playwright')` (works if this directory,
        or an ancestor, ever gains its own node_modules).

   Screenshots and any other proof artefacts are written to the notes
   directory named in this task's brief, never into this repository:
     C:\Users\vikra\AppData\Local\Temp\claude\C--Users-vikra\
       82e00a22-a262-414e-b7f4-edfed1c86a66\scratchpad\genome\estate-menu\
   ====================================================================== */

import { fileURLToPath, pathToFileURL } from 'node:url';
import path from 'node:path';
import fs from 'node:fs';

const HERE = path.dirname(fileURLToPath(import.meta.url));
const SCRATCHPAD_PLAYWRIGHT =
  'C:/Users/vikra/AppData/Local/Temp/claude/C--Users-vikra/82e00a22-a262-414e-b7f4-edfed1c86a66/scratchpad/node_modules/playwright/index.mjs';
const NOTES_DIR =
  'C:/Users/vikra/AppData/Local/Temp/claude/C--Users-vikra/82e00a22-a262-414e-b7f4-edfed1c86a66/scratchpad/genome/estate-menu';
const SCREENSHOT_DIR = path.join(NOTES_DIR, 'screenshots');
const TEST_COPIES_DIR = path.join(NOTES_DIR, 'test-copies');

fs.mkdirSync(SCREENSHOT_DIR, { recursive: true });

async function loadPlaywright() {
  const candidates = [
    process.env.PLAYWRIGHT_MODULE_PATH,
    SCRATCHPAD_PLAYWRIGHT,
  ].filter(Boolean);
  for (const candidate of candidates) {
    if (fs.existsSync(candidate)) {
      const mod = await import(pathToFileURL(candidate).href);
      if (mod.chromium && mod.webkit) return mod;
    }
  }
  // Last resort: an ordinary resolvable import, for an environment where
  // this directory (or an ancestor) has its own Playwright install.
  return import('playwright');
}

function fileUrl(p) { return pathToFileURL(p).href; }

const DEMO_HTML = fileUrl(path.join(HERE, 'demo.html'));
const DEMO_HOST_HTML = fileUrl(path.join(HERE, 'demo-with-host-bar.html'));
const FEDERATION_TEST_COPY = fileUrl(path.join(TEST_COPIES_DIR, 'federation-map/dashboard/sandbox/spider_full_po_test.html'));
const PIPELINE_TEST_COPY = fileUrl(path.join(TEST_COPIES_DIR, 'pipelinenews/index.html'));
const ESTATE_MENU_JS_SOURCE = fs.readFileSync(path.join(HERE, 'estate-menu.js'), 'utf8');
const MANIFEST = JSON.parse(fs.readFileSync(path.join(HERE, 'estate-menu-manifest.json'), 'utf8'));

const VIEWPORTS = [
  { name: '393x852', width: 393, height: 852 },
  { name: '1400x900', width: 1400, height: 900 },
];

const results = [];
function record(sentence, ok, detail) {
  results.push({ sentence, ok, detail: detail || null });
  const mark = ok ? 'PASS' : 'FAIL';
  console.log('[' + mark + '] ' + sentence + (detail ? '  (' + detail + ')' : ''));
}

function manifestUrlList() {
  const urls = [];
  const file = MANIFEST.menus.FILE.entries;
  file.forEach((e) => {
    if (e.current) urls.push(e.current);
    (e.superseded || []).forEach((u) => urls.push(u));
  });
  MANIFEST.menus.VIEW.surfaces.forEach((s) => urls.push(s.url));
  MANIFEST.menus.ABOUT.entries.forEach((e) => {
    if (/^https?:\/\//i.test(e.source || '')) urls.push(e.source);
  });
  return Array.from(new Set(urls));
}

async function withPage(browser, viewport, url, fn) {
  const context = await browser.newContext({ viewport: { width: viewport.width, height: viewport.height } });
  const page = await context.newPage();
  try {
    await page.goto(url, { waitUntil: 'load' });
    await page.waitForTimeout(150); // manifest fetch / fallback settle
    return await fn(page);
  } finally {
    await context.close();
  }
}

async function runStructuralChecks(browser, engineName, viewport) {
  const tag = engineName + '@' + viewport.name;

  await withPage(browser, viewport, DEMO_HTML, async (page) => {
    // Six titles, in order.
    const titleTexts = await page.$$eval('#ventus-estate-menu-bar .gm-title', (els) => els.map((e) => e.textContent.trim()));
    record(tag + ': the six menu titles read File, Edit, View, Scope, Grid, About, in that order',
      JSON.stringify(titleTexts) === JSON.stringify(['File', 'Edit', 'View', 'Scope', 'Grid', 'About']),
      JSON.stringify(titleTexts));

    // Brand slot carries the VENTUS wordmark.
    const brandText = await page.$eval('#ventus-estate-menu-bar .gm-brand-slot .ventus-main', (e) => e.textContent.trim()).catch(() => null);
    record(tag + ': the brand slot at the centre of the bar reads VENTUS', brandText === 'VENTUS', String(brandText));

    // Every manifest URL appears exactly once across the rendered panels.
    const hrefs = await page.$$eval('#ventus-estate-menu-bar a[href]', (els) => els.map((e) => e.getAttribute('href')));
    const wanted = manifestUrlList();
    const missing = [];
    const duplicated = [];
    wanted.forEach((u) => {
      const count = hrefs.filter((h) => h === u).length;
      if (count === 0) missing.push(u);
      else if (count > 1) duplicated.push(u + ' x' + count);
    });
    record(tag + ': every manifest URL renders exactly once in the bar',
      missing.length === 0 && duplicated.length === 0,
      'missing=' + missing.length + ' duplicated=' + duplicated.length +
        (missing.length ? ' e.g. ' + missing[0] : '') + (duplicated.length ? ' e.g. ' + duplicated[0] : ''));

    // Keyboard: Escape closes an open panel.
    await page.click('#ventus-estate-menu-bar .gm-title:has-text("File")');
    const openedExpanded = await page.$eval('#ventus-estate-menu-bar .gm-title:has-text("File")', (e) => e.getAttribute('aria-expanded'));
    await page.keyboard.press('Escape');
    const closedExpanded = await page.$eval('#ventus-estate-menu-bar .gm-title:has-text("File")', (e) => e.getAttribute('aria-expanded'));
    record(tag + ': clicking File opens its panel (aria-expanded=true) and Escape closes it again',
      openedExpanded === 'true' && closedExpanded === 'false',
      'opened=' + openedExpanded + ' afterEscape=' + closedExpanded);

    // Keyboard: ArrowRight moves focus across titles.
    await page.focus('#ventus-estate-menu-bar .gm-title:has-text("File")');
    await page.keyboard.press('ArrowRight');
    const focusedAfterArrow = await page.evaluate(() => document.activeElement && document.activeElement.textContent.trim());
    record(tag + ': ArrowRight from File moves focus to the next title, Edit',
      focusedAfterArrow === 'Edit', 'focused=' + focusedAfterArrow);

    // 44px touch targets on every clickable row, at this viewport.
    await page.click('#ventus-estate-menu-bar .gm-title:has-text("View")');
    const heights = await page.$$eval('#ventus-estate-menu-bar .gm-panel:not([hidden]) a, #ventus-estate-menu-bar .gm-panel:not([hidden]) button',
      (els) => els.map((e) => e.getBoundingClientRect().height));
    const short = heights.filter((h) => h < 43.5);
    record(tag + ': every clickable row in an open panel is at least 44px tall',
      heights.length > 0 && short.length === 0,
      'rows=' + heights.length + ' under44=' + short.length + (short.length ? ' min=' + Math.min(...short).toFixed(1) : ''));
  });

  // Refusal when a host bar is present.
  await withPage(browser, viewport, DEMO_HOST_HTML, async (page) => {
    const ourBar = await page.$('#ventus-estate-menu-bar');
    const mountResult = await page.evaluate(() => window.__VENTUS_ESTATE_MENU__ && window.__VENTUS_ESTATE_MENU__.mount());
    const contractPresent = await page.evaluate(() => !!(window.__VENTUS_ESTATE_MENU__ && window.__VENTUS_ESTATE_MENU__.schema));
    record(tag + ': on a page with #gridatlas-menu-bar already present, the contract is published but no second bar is rendered',
      contractPresent && ourBar === null, 'contractPresent=' + contractPresent + ' secondBarPresent=' + (ourBar !== null));
    record(tag + ': mount() on that page returns {mounted:false, reason:"host bar present"}',
      !!mountResult && mountResult.mounted === false && mountResult.reason === 'host bar present',
      JSON.stringify(mountResult));
  });
}

/* Same regex the module's own labelFromUrl() uses (estate-menu.js), copied
   here rather than imported so this proof has no dependency on the module's
   internals beyond the source text it already reads for other checks. */
function labelFromUrl(u) {
  let m = /\/v(\d[\w.]*)\/?$/.exec(u || '');
  if (m) return 'v' + m[1];
  m = /\/(\d{10,14})\/?$/.exec(u || '');
  if (m) return m[1];
  return u;
}

function isAlphabetical(labels) {
  const sorted = labels.slice().sort((a, b) => a.localeCompare(b, 'en-GB', { sensitivity: 'base' }));
  return JSON.stringify(sorted) === JSON.stringify(labels);
}

/* Checks added for the alphabetical-ordering task (2026-09-04):
     (1) every non-version group renders alphabetically
     (2) version groups (FILE) render current-first, superseded newest-first
     (3) the wordmark stays centred to the pixel, brand-slot centre == viewport centre
     (4) the sub-line reads exactly "Cables & Connectivity®" from source, uppercased by CSS
     (5) no visible text in the bar or its panels contains the word "estate" */
async function runOrderingAndBrandChecks(browser, engineName, viewport) {
  const tag = engineName + '@' + viewport.name;

  await withPage(browser, viewport, DEMO_HTML, async (page) => {
    // (1) Non-version groups: EDIT, VIEW (Surfaces, Proofs), ABOUT — each
    // panel's own group buckets, extracted in DOM order, must already be
    // alphabetical (case-insensitive, locale en-GB) without this proof
    // re-sorting anything itself.
    const buckets = await page.evaluate(() => {
      function panelForTitle(name) {
        const titles = Array.from(document.querySelectorAll('#ventus-estate-menu-bar .gm-title'));
        const title = titles.find((t) => t.textContent.trim() === name);
        if (!title) return null;
        return document.getElementById(title.getAttribute('aria-controls'));
      }
      function bucketsOf(panel) {
        const out = {};
        let group = '__root__';
        out[group] = [];
        if (!panel) return out;
        Array.from(panel.children).forEach((node) => {
          if (node.classList.contains('gm-group')) {
            group = node.textContent.trim();
            out[group] = out[group] || [];
            return;
          }
          if (node.tagName === 'A' || node.classList.contains('gm-row')) {
            const span = node.querySelector('span') || node;
            out[group].push(span.textContent.trim());
          }
        });
        return out;
      }
      return {
        Edit: bucketsOf(panelForTitle('Edit')),
        View: bucketsOf(panelForTitle('View')),
        About: bucketsOf(panelForTitle('About')),
      };
    });

    Object.keys(buckets).forEach((panelName) => {
      Object.keys(buckets[panelName]).forEach((groupName) => {
        const raw = buckets[panelName][groupName];
        if (!raw.length) return;
        // Strip the "— you are here" / " — current" render-time suffixes
        // before comparing, since those are appended after the real label.
        const labels = raw.map((s) => s.replace(/\s+—\s+(you are here|current)$/i, ''));
        record(tag + ': ' + panelName + ' → "' + groupName + '" renders its entries alphabetically (case-insensitive, en-GB): ' + JSON.stringify(labels),
          isAlphabetical(labels), JSON.stringify(labels));
      });
    });

    // (2) FILE stays newest-first, current leading — never alphabetised.
    const fileOrder = await page.evaluate(() => {
      const titles = Array.from(document.querySelectorAll('#ventus-estate-menu-bar .gm-title'));
      const title = titles.find((t) => t.textContent.trim() === 'File');
      const panel = document.getElementById(title.getAttribute('aria-controls'));
      const groups = [];
      let current = null;
      Array.from(panel.children).forEach((node) => {
        if (node.classList.contains('gm-group')) {
          current = { label: node.textContent.trim(), firstText: null, supersededLabels: [] };
          groups.push(current);
          return;
        }
        if (!current) return;
        if (current.firstText === null && (node.tagName === 'A' || node.classList.contains('gm-row'))) {
          current.firstText = node.textContent.trim();
          return;
        }
        if (node.tagName === 'DETAILS') {
          Array.from(node.querySelectorAll('a')).forEach((a) => current.supersededLabels.push(a.textContent.trim()));
        }
      });
      return groups;
    });
    const pipelineGroup = fileOrder.find((g) => g.label === 'Pipeline News versions');
    const expectedSuperseded = (MANIFEST.menus.FILE.entries.find((e) => e.label === 'Pipeline News versions').superseded || []).map(labelFromUrl);
    record(tag + ': FILE → each version group\'s first row names the current release ("— current"), never alphabetised',
      fileOrder.every((g) => /—\s*current/i.test(g.firstText || '')),
      JSON.stringify(fileOrder.map((g) => g.firstText)));
    record(tag + ': FILE → "Pipeline News versions" superseded disclosure stays newest-first, in the manifest\'s own order',
      JSON.stringify(pipelineGroup && pipelineGroup.supersededLabels) === JSON.stringify(expectedSuperseded),
      JSON.stringify(pipelineGroup && pipelineGroup.supersededLabels) + ' vs expected ' + JSON.stringify(expectedSuperseded));

    // (3) The wordmark's brand slot stays centred on the viewport, to the pixel.
    const brandCentre = await page.evaluate(() => {
      const slot = document.querySelector('#ventus-estate-menu-bar .gm-brand-slot');
      const rect = slot.getBoundingClientRect();
      return { centre: rect.left + rect.width / 2, viewport: window.innerWidth };
    });
    const offset = Math.abs(brandCentre.centre - brandCentre.viewport / 2);
    record(tag + ': the brand slot is centred to the pixel (viewport ' + brandCentre.viewport + 'px, slot centre ' + brandCentre.centre.toFixed(1) + 'px)',
      offset <= 1, 'offset=' + offset.toFixed(2) + 'px');

    // (4) The sub-line's SOURCE text, and that CSS (not the source string) uppercases it.
    const sub = await page.evaluate(() => {
      const el = document.querySelector('#ventus-estate-menu-bar .gm-brand-slot .ventus-sub');
      return { text: el.textContent, transform: getComputedStyle(el).textTransform };
    });
    record(tag + ': the sub-line reads exactly "Cables & Connectivity®" in source',
      sub.text === 'Cables & Connectivity®', JSON.stringify(sub.text));
    record(tag + ': the sub-line is uppercased by CSS (text-transform:uppercase), not by the source string',
      sub.transform === 'uppercase', sub.transform);

    // (5) No visible text anywhere in the bar or its panels says "estate".
    const barText = await page.$eval('#ventus-estate-menu-bar', (e) => e.textContent);
    const hasEstate = /estate/i.test(barText);
    record(tag + ': no visible text in the bar or its panels contains the word "estate"',
      !hasEstate, hasEstate ? 'found "estate" in bar text' : 'clean');
  });
}

async function runCurrentSurfaceCheck(browser, engineName) {
  const tag = engineName;
  const context = await browser.newContext({ viewport: { width: 1400, height: 900 } });
  const page = await context.newPage();
  try {
    const targetUrl = 'https://ventusltd.github.io/spiders/'; // a manifest VIEW surface, verified 200
    const html = '<!doctype html><html><head><meta charset="utf-8">'
      + '<title>current-surface check</title></head><body>'
      + '<script>' + ESTATE_MENU_JS_SOURCE + '</script>'
      + '</body></html>';
    await page.route(targetUrl, (route) => route.fulfill({ status: 200, contentType: 'text/html', body: html }));
    await page.goto(targetUrl, { waitUntil: 'load' });
    await page.waitForTimeout(150);
    await page.click('#ventus-estate-menu-bar .gm-title:has-text("View")');
    const current = await page.$$eval('#ventus-estate-menu-bar .gm-panel:not([hidden]) a.gm-current',
      (els) => els.map((e) => ({ href: e.getAttribute('href'), ariaCurrent: e.getAttribute('aria-current') })));
    const ok = current.length === 1 && current[0].href === targetUrl && current[0].ariaCurrent === 'page';
    record(tag + ': loaded at a manifest-listed surface URL (' + targetUrl + '), that surface — and only that one — is marked current in the VIEW panel',
      ok, JSON.stringify(current));
  } finally {
    await context.close();
  }
}

async function runFederationOverlapCheck(browser, engineName, viewport) {
  const tag = engineName + '@' + viewport.name;
  await withPage(browser, viewport, FEDERATION_TEST_COPY, async (page) => {
    await page.waitForSelector('#ventus-estate-menu-bar', { timeout: 5000 }).catch(() => {});
    await page.waitForSelector('.top .bar', { timeout: 5000 }).catch(() => {});
    const rects = await page.evaluate(() => {
      const bar = document.getElementById('ventus-estate-menu-bar');
      const host = document.querySelector('.top .bar');
      const clear = getComputedStyle(document.documentElement).getPropertyValue('--gridatlas-menu-bar-clear');
      return {
        bar: bar ? bar.getBoundingClientRect().toJSON() : null,
        host: host ? host.getBoundingClientRect().toJSON() : null,
        clearVar: clear.trim(),
      };
    });
    const bothVisible = !!(rects.bar && rects.host && rects.bar.height > 0 && rects.host.height > 0);
    const noOverlap = bothVisible && rects.bar.bottom <= rects.host.top + 1; // 1px rounding tolerance
    const neitherClipped = bothVisible && rects.bar.top >= 0 && rects.host.bottom <= viewport.height + 1;
    record(tag + ': on the federation-map test copy, the estate bar and the page\'s own "The Spider Sandbox" header are both visible and do not overlap',
      bothVisible && noOverlap && neitherClipped,
      'clearVar=' + rects.clearVar + ' bar=' + JSON.stringify(rects.bar) + ' host=' + JSON.stringify(rects.host));

    const shotPath = path.join(SCREENSHOT_DIR, 'federation-map-' + engineName + '-' + viewport.name + '.png');
    await page.screenshot({ path: shotPath });
    console.log('  screenshot: ' + shotPath);
  });
}

async function screenshotDemoAndPipeline(browser, engineName, viewport) {
  await withPage(browser, viewport, DEMO_HTML, async (page) => {
    const shotPath = path.join(SCREENSHOT_DIR, 'demo-' + engineName + '-' + viewport.name + '.png');
    await page.screenshot({ path: shotPath });
    console.log('  screenshot: ' + shotPath);
  });
  await withPage(browser, viewport, PIPELINE_TEST_COPY, async (page) => {
    const rects = await page.evaluate(() => {
      const bar = document.getElementById('ventus-estate-menu-bar');
      const header = document.querySelector('.main .header');
      return {
        bar: bar ? bar.getBoundingClientRect().toJSON() : null,
        header: header ? header.getBoundingClientRect().toJSON() : null,
      };
    });
    const bothVisible = !!(rects.bar && rects.header && rects.bar.height > 0 && rects.header.height > 0);
    const noOverlap = bothVisible && rects.bar.bottom <= rects.header.top + 1;
    const vp = page.viewportSize();
    record(engineName + '@' + vp.width + 'x' + vp.height + ': on the Pipeline News v9.7 test copy, the estate bar does not overlap the page\'s own "UK RENEWABLES PIPELINE V9.7" header',
      bothVisible && noOverlap, JSON.stringify(rects));

    const shotPath = path.join(SCREENSHOT_DIR, 'pipelinenews-v97-' + engineName + '-' + viewport.name + '.png');
    await page.screenshot({ path: shotPath });
    console.log('  screenshot: ' + shotPath);
  });
}

async function main() {
  const pw = await loadPlaywright();
  const engines = [
    { name: 'chromium', launcher: pw.chromium },
    { name: 'webkit', launcher: pw.webkit },
  ];

  for (const engine of engines) {
    let browser;
    try {
      browser = await engine.launcher.launch();
    } catch (e) {
      record(engine.name + ': browser launched', false, String(e && e.message || e));
      continue;
    }
    try {
      for (const viewport of VIEWPORTS) {
        await runStructuralChecks(browser, engine.name, viewport);
        await runOrderingAndBrandChecks(browser, engine.name, viewport);
        await runFederationOverlapCheck(browser, engine.name, viewport);
        await screenshotDemoAndPipeline(browser, engine.name, viewport);
      }
      await runCurrentSurfaceCheck(browser, engine.name);
    } finally {
      await browser.close();
    }
  }

  const failed = results.filter((r) => !r.ok);
  console.log('');
  console.log(results.length + ' checks, ' + failed.length + ' failed.');
  if (failed.length) {
    console.log('Failures:');
    failed.forEach((f) => console.log('  - ' + f.sentence + (f.detail ? '  (' + f.detail + ')' : '')));
    process.exitCode = 1;
  }
}

main().catch((e) => {
  console.error(e && e.stack || e);
  process.exitCode = 1;
});

Species — Seer Spider Page

A web page in Spiders. Published at https://ventusltd.github.io/spiders/species/seer-spider/.

renderspiders / species/seer-spider/index.html · lines 1–7 of 7 · Entry point

What it does
It draws its content. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage agent_infra (path word 'spider'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
Out: web page.
Downstream impact
Used directly by 2 files: Spiders — Index Page (spiders, https://ventusltd.github.io/spiders/); Root Index — V Page (spiders, https://ventusltd.github.io/spiders/site_versions/root_index/v20260704/). Reached from 270 other entry points, including Iterations — 43 Registry Growth Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/43-registry-growth/); Iterations — 47 Federation Honesty Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/47-federation-honesty/); GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html). It is itself an entry point, published at https://ventusltd.github.io/spiders/species/seer-spider/.
What it achieves
No statement of purpose was found in the file, a README line naming it, or its name.
Why it matters
Loaded by the Spiders page at https://ventusltd.github.io/spiders/ and 1 other page.
Application
spiders · species/seer-spider · page
Uses
Spiders — Index Page (link)
Used by
linked from Spiders — Index Page (link), linked from Root Index — V Page (link)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
spiders@78fc0f90bd5ca73f3d5d7c0e0b7b5712cfe781e5 species/seer-spider/index.html:1-7 · blob 4bd97685598cbe8c9fd77e13eab7df3e52686c1e · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: agent_infra · users: ai_agent · canonical: unknown
<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Seer Spider</title></head>
<body style="margin:0;min-height:100vh;background:#0b0d12;color:#eef2fb;font-family:system-ui;display:flex;align-items:center;justify-content:center;padding:24px">
<main style="max-width:720px"><p style="letter-spacing:.22em;text-transform:uppercase;color:#00e5ff">Ventus · Spiders</p><h1>Seer Spider</h1><p style="color:#9aa3b5;line-height:1.5">Reserved future species. This Spider will see and route between all other Spider species.</p><p><a style="color:#00e5ff" href="../../">Back to Spiders</a></p></main>
</body>
</html>