GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Maps, GIS and field navigation / gridatlas / tools/satnav

SatNav Browser and 3 more files

A Python module in the tools folder of GridAtlas covering postcodes, the Renewable Energy Planning Database (REPD) register and substations, and uses data from postcodes.io and the SatNav repository.

573 lines of Python and JavaScript from gridatlas, in 4 files. Topic: Maps, GIS and field navigation. Section 671 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. SatNav Browser render · gridatlas / tools/satnav/browser.py lines 1–405
  2. SatNav Build Line Preview storage · gridatlas / tools/satnav/build-line-preview.mjs lines 1–35
  3. SatNav Build Unified Agent1 CI automation · gridatlas / tools/satnav/build-unified-agent1-ci.mjs lines 1–73
  4. SatNav Build storage · gridatlas / tools/satnav/build.mjs lines 1–60

SatNav Browser

A Python module in the tools folder of GridAtlas covering postcodes, the Renewable Energy Planning Database (REPD) register and substations, and uses data from postcodes.io and the SatNav repository.

rendergridatlas / tools/satnav/browser.py · lines 1–405 of 405 · Not reached from any entry point (candidate for review) · pattern selected (shared by 5 files)

What it does
It draws postcodes, the REPD register and substations. Defines 13 functions or classes, including load_map, click_launcher, open_satnav, check_launcher_during_search_reflow, ready. Uses libraries json, math, os, urllib.parse, playwright.sync_api. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work. Domain terms in the code: postcodes, the REPD register, substations.
What it achieves
It checks launcher during search reflow (`check_launcher_during_search_reflow`) and is built from the ready step (`ready`) and the choose compass helper (`choose_compass`). Defines `load_map`, `click_launcher`, `open_satnav` and 10 more.
Why it matters
No other file in the estate was found to import it.
Application
gridatlas · tools/satnav · Python module
Uses
json, math, os, urllib.parse, playwright.sync_api
Used by
none found
Produces
load_map, click_launcher, open_satnav, check_launcher_during_search_reflow, ready, choose_compass, open_native_card, open_card, click_uncovered_map, pick_search_result, stale_project_refused, postcode_handoff
Defines here
load_map, click_launcher, open_satnav, check_launcher_during_search_reflow, ready, choose_compass, open_native_card, open_card, click_uncovered_map, pick_search_result, stale_project_refused, postcode_handoff, selected
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/browser.py:1-405 · blob 9d6e511787803f9affcbca3739efbb4c479ba314 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: unreached_review
import json
import math
import os
from urllib.parse import parse_qs, urlencode, urlparse

from playwright.sync_api import TimeoutError as PlaywrightTimeoutError, sync_playwright

BASE = f"http://127.0.0.1:{os.environ.get('SATNAV_PORT', '8768')}/"
DEMO = BASE + 'atlas/v/satnav-native-m1/'
COMPASS = 'https://ventusltd.github.io/satnav/preview/9698781539e549deaa6ecaa4a2b34610c1f9fd29/nav/'
CARD = DEMO + '?' + urlencode({
    'repd_ref': 12588, 'latitude': 51.8132088, 'longitude': -1.3489728,
    'project': 'Botley West', 'technology': 'solar', 'journey': 'vicinity',
    'origin_type': 'repd', 'origin_id': 'repd:12588', 'radius_km': 10,
})
MOCK_GPS = '''
    window.__gpsRequests = 0;
    Object.defineProperty(navigator, 'geolocation', {configurable: true, value: {
        watchPosition() { window.__gpsRequests++; return 1; }, clearWatch() {},
    }});
'''
POSTCODE = 'SW1A 2AA'
POSTCODE_ENDPOINT = 'https://api.postcodes.io/postcodes/SW1A2AA'
POSTCODE_POINT = [-0.12767, 51.503541]
PANEL = '#gridatlas-satnav-satnav'
TOGGLE = '#gridatlas-satnav-toggle'
CONFIRM = '#gridatlas-satnav-confirm'
VICINITY = '#gridatlas-satnav-vicinity'
PICK = '#gridatlas-satnav-pick'
USE_SEARCH_RESULT = '#gridatlas-satnav-planned'


def load_map(page, url):
    page.goto(url, wait_until='domcontentloaded')
    page.wait_for_function("document.querySelector('#gridatlas-satnav-pick:not(:disabled)')", timeout=45000)


def click_launcher(page):
    hit = page.locator(TOGGLE).evaluate('''async button => {
        await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
        window.__satnavTapEvents = [];
        const types = ['pointerdown', 'pointerup', 'pointercancel', 'touchstart',
            'touchend', 'touchcancel', 'click', 'fullscreenchange'];
        window.__satnavTapTrace?.abort();
        window.__satnavTapTrace = new AbortController();
        const record = event => {
            const point = event.changedTouches?.[0] || event;
            window.__satnavTapEvents.push({
                type: event.type, target: event.target.id || event.target.tagName,
                x: point.clientX, y: point.clientY,
                launcherTop: button.getBoundingClientRect().top,
                expanded: button.getAttribute('aria-expanded'),
            });
        };
        for (const type of types) {
            window.addEventListener(type, record, {capture: true, signal: window.__satnavTapTrace.signal});
        }
        const rect = button.getBoundingClientRect();
        const x = rect.left + rect.width / 2;
        const y = rect.top + rect.height / 2;
        const target = document.elementFromPoint(x, y);
        return {
            x, y, width: rect.width, height: rect.height,
            inViewport: rect.left >= 0 && rect.top >= 0 &&
                rect.right <= innerWidth && rect.bottom <= innerHeight,
            reachable: button.contains(target),
            coveredBy: target && (target.id || target.className || target.tagName),
            viewport: {
                width: innerWidth, height: innerHeight, scale: visualViewport.scale,
                offsetLeft: visualViewport.offsetLeft, offsetTop: visualViewport.offsetTop,
                fullscreen: Boolean(document.fullscreenElement),
            },
        };
    }''')
    assert hit['width'] >= 44 and hit['height'] >= 44, hit
    assert hit['inViewport'] and hit['reachable'], hit
    scroll = page.evaluate('[scrollX, scrollY]')
    if page.evaluate("navigator.maxTouchPoints > 0"):
        page.touchscreen.tap(hit['x'], hit['y'])
    else:
        page.mouse.click(hit['x'], hit['y'])
    assert page.evaluate('[scrollX, scrollY]') == scroll
    return hit


def open_satnav(page):
    hit = click_launcher(page)
    try:
        page.locator(PANEL).wait_for(state='visible', timeout=5000)
    except PlaywrightTimeoutError:
        print(json.dumps({
            'missedLauncherTap': hit,
            'events': page.evaluate('window.__satnavTapEvents'),
            'expanded': page.locator(TOGGLE).get_attribute('aria-expanded'),
        }), flush=True)
        page.screenshot(path='launcher-missed.png')
        raise


def check_launcher_during_search_reflow(page):
    top = page.locator(TOGGLE).evaluate('button => button.getBoundingClientRect().top')
    wrapper = page.locator('.search-bar-wrapper')
    old_top = wrapper.evaluate('element => element.style.top')
    try:
        # Exercise the two native search positions observed during mobile boot.
        for search_top in ['164px', '72px']:
            wrapper.evaluate('(element, top) => { element.style.top = top; }', search_top)
            page.wait_for_timeout(350)
            assert page.locator(TOGGLE).evaluate('button => button.getBoundingClientRect().top') == top
    finally:
        wrapper.evaluate('(element, top) => { element.style.top = top; }', old_top)


def ready(page, url):
    load_map(page, url)
    open_satnav(page)


def choose_compass(page, name, point):
    page.locator('#gridatlas-satnav-confirm').click()
    page.wait_for_url(COMPASS + '?*')
    assert page.locator('#destination').inner_text() == name
    query = parse_qs(urlparse(page.url).query)
    assert query['mode'] == ['compass']
    assert set(query) == {'latitude', 'longitude', 'name', 'mode'}
    assert math.isclose(float(query['longitude'][0]), point[0], abs_tol=1e-6)
    assert math.isclose(float(query['latitude'][0]), point[1], abs_tol=1e-6)
    assert page.evaluate('window.__gpsRequests') == 0
    assert page.locator('#start').is_enabled()


def open_native_card(page):
    load_map(page, CARD)
    page.locator('#gridatlas-pipeline-vicinity-button').click(timeout=45000)
    page.wait_for_function('''() => {
        const card = window.__GRIDATLAS_MODULES__.ukOfftakers.state.pp;
        return card?.__vicFocus?.origin === true && card.swipe?.entries?.length >= 2;
    }''', timeout=45000)


def open_card(page):
    open_native_card(page)
    open_satnav(page)


def click_uncovered_map(page):
    point = page.evaluate('''() => {
        const canvas = window.__GRIDATLAS_V9_MAP__.getCanvas();
        const rect = canvas.getBoundingClientRect();
        for (const [fx, fy] of [[.55, .40], [.60, .55], [.46, .68]]) {
            const x = rect.left + fx * rect.width;
            const y = rect.top + fy * rect.height;
            if (document.elementFromPoint(x, y) === canvas) return [x, y];
        }
        return null;
    }''')
    assert point is not None, 'Expected a genuinely uncovered canvas point'
    page.mouse.click(*point)


def pick_search_result(page, query, result_selector):
    search = page.locator('#search-input')
    search.fill(query)
    search.press('Enter')
    page.locator(result_selector).click(timeout=45000)


def stale_project_refused(page, action):
    ready(page, DEMO)
    map_search = page.locator('#gridatlas-satnav-map-search')
    map_search.click()
    pick_search_result(page, '12588', '#search-results [data-repd-ref="12588"]')
    open_satnav(page)
    page.locator(USE_SEARCH_RESULT).click()
    assert page.locator(CONFIRM).is_visible()

    map_search.click()
    pick_search_result(page, '10603', '#search-results [data-repd-ref="10603"]')
    open_satnav(page)
    url = page.url
    page.locator(action).click()
    assert 'selection changed' in page.locator(PANEL + ' [role=status]').inner_text()
    assert page.url == url
    assert not page.evaluate("Boolean(window.__GRIDATLAS_MODULES__.ukOfftakers.state.pp?.project)")
    assert page.locator(CONFIRM).is_hidden()
    assert page.locator(VICINITY).is_hidden()


def postcode_handoff(page, use_live_provider):
    if not use_live_provider:
        page.route(POSTCODE_ENDPOINT, lambda route: route.fulfill(
            headers={'Access-Control-Allow-Origin': '*'},
            json={'status': 200, 'result': {
                'postcode': POSTCODE, 'longitude': POSTCODE_POINT[0], 'latitude': POSTCODE_POINT[1],
                'admin_district': 'Westminster', 'region': 'London',
            }},
        ))
    ready(page, DEMO)
    page.locator('#gridatlas-satnav-map-search').click()
    assert page.locator(PANEL).is_hidden()
    assert page.locator('#search-input').evaluate('(input) => document.activeElement === input')
    pick_search_result(page, POSTCODE, '#search-results [data-location-kind="postcode"]')
    location = page.evaluate('window.__GRIDATLAS_PLACE_SEARCH__.last_location_selection')
    assert location['label'] == POSTCODE and location['mapped'] is True, location
    point = [location['longitude'], location['latitude']]
    if not use_live_provider:
        assert point == POSTCODE_POINT
    open_satnav(page)
    page.locator(USE_SEARCH_RESULT).click()
    choose_compass(page, POSTCODE, point)
    source = 'live Postcodes.io' if use_live_provider else 'deterministic Postcodes.io response'
    print(f'PASS postcode handoff through GridAtlas search ({source})', flush=True)


def selected(page, kind):
    return page.evaluate('''kind => {
        const card = window.__GRIDATLAS_MODULES__.ukOfftakers.state.pp;
        if (kind === 'origin') return { name:card.r.n, at:card.r.a };
        const entry = card.swipe.entries[card.swipe.index];
        return { name:entry.name, at:entry.at };
    }''', kind)


with sync_playwright() as playwright:
    browser = playwright.chromium.launch(headless=True, args=[
        '--enable-webgl', '--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader',
    ])
    for width, height, is_mobile, card_open in [
        (1440, 900, False, False),
        (390, 844, True, True),
        (844, 390, True, False),
        (320, 568, True, False),
    ]:
        hit_page = browser.new_page(
            viewport={'width': width, 'height': height}, is_mobile=is_mobile, has_touch=is_mobile,
        )
        if card_open:
            open_native_card(hit_page)
        else:
            load_map(hit_page, DEMO)
        if width == 320:
            check_launcher_during_search_reflow(hit_page)
            print('PASS narrow launcher position stays stable as native search reflows', flush=True)
        open_satnav(hit_page)
        print(f'PASS launcher screen hit {width}x{height}, vicinity card open={card_open}', flush=True)
        hit_page.close()

    context = browser.new_context(viewport={'width': 1024, 'height': 740})
    context.add_init_script(MOCK_GPS)
    page = context.new_page()

    ready(page, DEMO)
    for use_close_button in [True, False]:
        page.locator(PICK).click()
        assert page.locator(PICK).get_attribute('aria-pressed') == 'true'
        if use_close_button:
            page.locator('#gridatlas-satnav-close').click()
        else:
            click_launcher(page)
        page.locator(PANEL).wait_for(state='hidden', timeout=5000)
        assert page.locator(PICK).get_attribute('aria-pressed') == 'false'
        click_uncovered_map(page)
        open_satnav(page)
        assert page.locator(CONFIRM).is_hidden()
        assert page.locator(VICINITY).is_hidden()
    print('PASS both panel close actions disarm map selection and prevent hidden staging', flush=True)

    ready(page, DEMO)
    page.locator('#gridatlas-satnav-map-search').click()
    pick_search_result(page, '10603', '#search-results [data-repd-ref="10603"]')
    unmapped = page.evaluate('window.__GRIDATLAS_PLACE_SEARCH__.last_selection')
    assert str(unmapped['repd_ref']) == '10603' and unmapped['mapped'] is False, unmapped
    open_satnav(page)
    page.locator(USE_SEARCH_RESULT).click()
    assert 'has no mapped location' in page.locator(PANEL + ' [role=status]').inner_text()
    assert page.locator(CONFIRM).is_hidden()
    assert page.locator(VICINITY).is_hidden()
    assert page.locator(PICK).is_enabled()
    assert page.url.startswith(DEMO)
    print('PASS genuine unmapped REPD 10603 refused for SatNav and Vicinity with pin fallback', flush=True)

    stale_project_refused(page, CONFIRM)
    stale_project_refused(page, VICINITY)
    print('PASS both confirmations refuse stale mapped project after selection changes to unmapped 10603', flush=True)

    postcode_page = context.new_page()
    postcode_handoff(postcode_page, use_live_provider=False)
    postcode_page.close()
    if os.environ.get('SATNAV_LIVE_POSTCODE') == '1':
        postcode_page = context.new_page()
        postcode_handoff(postcode_page, use_live_provider=True)
        postcode_page.close()

    tile_responses = []
    page.on('response', lambda response: tile_responses.append(response.status)
            if 'World_Imagery/MapServer/tile/' in response.url else None)
    ready(page, DEMO)
    page.evaluate("window.__GRIDATLAS_V9_MAP__.jumpTo({center:[-2.1,53.4], zoom:9})")
    canvas = page.locator('.maplibregl-canvas').first.bounding_box()
    x, y = round(canvas['x'] + canvas['width'] * .58), round(canvas['y'] + canvas['height'] * .39)
    page.locator('#gridatlas-satnav-pick').click()
    page.wait_for_function("window.__GRIDATLAS_V9_MAP__.getLayoutProperty('l-sat','visibility') === 'visible'")
    page.wait_for_function("window.__GRIDATLAS_V9_MAP__.isSourceLoaded('sat-s')", timeout=45000)
    page.wait_for_timeout(1200)  # Allow the native raster fade-in before capturing the map.
    page.mouse.click(x, y)
    page.locator('#gridatlas-satnav-confirm:visible').wait_for()
    assert page.url == DEMO
    page.locator('#gridatlas-satnav-cancel').click()
    page.mouse.click(x, y)
    assert page.locator('#gridatlas-satnav-confirm').is_hidden()
    assert page.url == DEMO
    page.locator('#gridatlas-satnav-pick').click()
    expected = page.evaluate('''([x,y]) => {
        const map = window.__GRIDATLAS_V9_MAP__;
        const rect = map.getCanvas().getBoundingClientRect();
        return map.unproject([x-rect.left, y-rect.top]).toArray();
    }''', [x, y])
    page.mouse.click(x, y)
    page.locator('#gridatlas-satnav-confirm:visible').wait_for()
    assert page.evaluate('window.__gpsRequests') == 0
    pin_name = 'Future substation field point'
    page.locator('#gridatlas-satnav-pin-label input').fill(pin_name)
    page.screenshot(path='satellite-selection.png')
    assert 200 in tile_responses
    print(json.dumps({'satelliteTileResponses': tile_responses, 'nativeLayerVisible': True}), flush=True)
    choose_compass(page, pin_name, expected)
    print('PASS native satellite click, cancel, named pin, signed compass handoff and GPS opt-in', flush=True)

    ready(page, DEMO)
    page.locator('#gridatlas-satnav-manual-details summary').click()
    page.locator('#gridatlas-satnav-latitude').fill('51.5')
    page.locator('#gridatlas-satnav-longitude').fill('-0.4')
    page.locator('#gridatlas-satnav-label').fill('Manual field point')
    page.locator('#gridatlas-satnav-manual').click()
    page.locator('#gridatlas-satnav-latitude').fill('invalid')
    page.locator('#gridatlas-satnav-manual').click()
    assert page.locator('#gridatlas-satnav-confirm').is_visible()
    choose_compass(page, 'Manual field point', [-0.4, 51.5])
    print('PASS signed manual destination and invalid edit retains pending selection', flush=True)

    ready(page, DEMO)
    page.locator('#gridatlas-satnav-manual-details summary').click()
    page.locator('#gridatlas-satnav-latitude').fill('51.5')
    page.locator('#gridatlas-satnav-longitude').fill('-0.4')
    page.locator('#gridatlas-satnav-manual').click()
    page.locator('#gridatlas-satnav-vicinity').click()
    page.wait_for_function('''() => {
      const c=window.__GRIDATLAS_MODULES__.ukOfftakers.state.pp;
      return c?.project && c.r.a[0]===-0.4 && !c.r.p.repd_ref;
    }''')
    assert page.locator('[data-vicinity-focus-title]').inner_text() == 'Manual coordinate point'
    print('PASS anonymous plain-point native Vicinity without fabricated REPD reference', flush=True)

    for source_id, point in [
        ('grid_substations:212', [-0.4978855, 51.5434023]),
        ('grid_substations:213', [-0.4973463, 51.5416778]),
    ]:
        ready(page, DEMO)
        page.locator('#gridatlas-satnav-station-details summary').click()
        page.get_by_label('Existing substation name or source ID').fill('Iver')
        page.locator('#gridatlas-satnav-search').click()
        page.get_by_role('button', name=f'Iver Substation · {source_id}', exact=False).click(timeout=30000)
        choose_compass(page, 'Iver Substation', point)
    print('PASS same-name Iver substations open the compass at their distinct mapped points', flush=True)

    open_card(page)
    page.wait_for_function('''() => {
      const s=window.__GRIDATLAS_PLACE_SEARCH__;
      return s?.last_selection && s.last_results.some(r=>r.repd_ref===s.last_selection.repd_ref);
    }''',timeout=45000)
    planned_record=page.evaluate('''() => {
      const s=window.__GRIDATLAS_PLACE_SEARCH__;
      return s.last_results.find(r=>r.repd_ref===s.last_selection.repd_ref);
    }''')
    page.locator('#gridatlas-satnav-planned').click()
    choose_compass(page,planned_record['name'],[planned_record['longitude'],planned_record['latitude']])
    print('PASS exact native selected project record handoff with source status and coordinates',flush=True)

    open_card(page)
    origin = selected(page, 'origin')
    assert page.locator('#gridatlas-satnav-asset').is_disabled()
    page.locator('#gridatlas-satnav-origin').click()
    choose_compass(page, origin['name'], origin['at'])
    print('PASS existing project Vicinity origin', flush=True)

    open_card(page)
    next_asset = page.get_by_role('button', name='Next vicinity point')
    page.locator('#gridatlas-satnav-close').click()
    next_asset.click()
    first = selected(page, 'asset')
    assert first['at'] != origin['at']
    open_satnav(page)
    page.locator('#gridatlas-satnav-asset').click()
    page.locator('#gridatlas-satnav-close').click()
    next_asset.click()
    current = selected(page, 'asset')
    assert current['at'] != first['at']
    open_satnav(page)
    page.locator('#gridatlas-satnav-confirm').click()
    assert 'selection changed' in page.locator('#gridatlas-satnav-satnav [role=status]').inner_text()
    assert page.url.startswith(DEMO)
    page.locator('#gridatlas-satnav-asset').click()
    choose_compass(page, current['name'], current['at'])
    print('PASS existing highlighted Vicinity asset and stale selection refusal', flush=True)
    browser.close()

SatNav Build Line Preview

A JavaScript module in the tools folder of GridAtlas that uses SHA-256.

storagegridatlas / tools/satnav/build-line-preview.mjs · lines 1–35 of 35 · Entry point

What it does
It loads data. Defines read, write, hash. Uses libraries node:assert/strict, node:crypto, node:fs. Side effects: reads or writes files.
Why it exists in the grid workflow
Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
Inputs & outputs
In: JSON file current.json.
Downstream impact
Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
What it achieves
Defines `read`, `write` and `hash`. It reads `current.json` and writes `index.html`.
Why it matters
Run by GridAtlas PR File Size Guard Workflow.
Application
gridatlas · tools/satnav · JavaScript module
Uses
GridAtlas — Index Page (new URL import.meta.url), node:assert/strict, node:crypto, node:fs
Used by
run by GridAtlas PR File Size Guard Workflow (workflow run)
Produces
read, write, hash
Defines here
read, write, hash
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/build-line-preview.mjs:1-35 · blob bbca68359d62f2ba12cc3fab749c9310aaa0dda2 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';

const root = new URL('../../', import.meta.url);
const read = path => readFileSync(new URL(path, root), 'utf8').replace(/\r\n/g, '\n');
const write = (path, text) => {
  const output = new URL(path, root);
  mkdirSync(new URL('.', output), { recursive: true });
  writeFileSync(output, text);
};
const currentPreview = 'atlas/v/satnav-native-m1/';
const route = 'atlas/v/satnav-line-preview/';
const manifest = JSON.parse(read(currentPreview + 'current.json'));
const oldId = 'satnav-handoff';
const id = 'satnav-practice-line';
const entry = manifest.cartridges.find(cartridge => cartridge.id === oldId);
assert.ok(entry?.preview_only && manifest.cartridge_order.includes(oldId), 'Expected the existing isolated SatNav composition');

// Agent 24's exact Apache-2.0 follower from SatNav PR1.
const follower = read('tools/satnav/line/route-follower.mjs');
const hash = text => createHash('sha256').update(text).digest('hex');
assert.equal(hash(follower), '6b60f8481d5ff72c2b17bb41b61a9c318dbad375974029f2dbefc617a3581c5c');

const module = '202611242248-satnav-practice-line.js';
const source = read('tools/satnav/line/preview.js');
Object.assign(entry, { id, path: '../../modules/' + module, sha256: hash(source), bytes: Buffer.byteLength(source) });
manifest.cartridge_order[manifest.cartridge_order.indexOf(oldId)] = id;
manifest.generation = '202611242248';
manifest.composition_id = 'satnav-practice-line-preview';
manifest.composition_note = 'Isolated practice-line field positioning. Section drawn by the user.';
write('atlas/modules/' + module, source);
write(route + 'index.html', read(currentPreview + 'index.html'));
write(route + 'current.json', JSON.stringify(manifest, null, 1) + '\n');
console.log('Candidate /' + route + ' overlay SHA256 ' + entry.sha256);

SatNav Build Unified Agent1 CI

A JavaScript module in the tools folder of GridAtlas that reads composition, using SHA-256. It is built from the read step (`read`) and the sha step (`sha`).

automationgridatlas / tools/satnav/build-unified-agent1-ci.mjs · lines 1–73 of 73 · Entry point

What it does
It loads composition. Defines read, sha. Uses libraries node:assert/strict, node:crypto, node:fs, node:url, node:path. Side effects: reads or writes files.
Why it exists in the grid workflow
Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
Inputs & outputs
In: JSON file current.json; JSON file -composition.json; command-line arguments. Out: JSON file current.json.
Downstream impact
Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
What it achieves
Build an isolated, disposable CI composition; never change production or a released generation.
Why it matters
Run by GridAtlas PR File Size Guard Workflow.
Application
gridatlas · tools/satnav · JavaScript module
Uses
GridAtlas — Index Page (new URL import.meta.url), node:assert/strict, node:crypto, node:fs, node:url, node:path
Used by
run by GridAtlas PR File Size Guard Workflow (workflow run)
Produces
read, sha
Defines here
read, sha
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/build-unified-agent1-ci.mjs:1-73 · blob 4a7c31864679f286b9fd6691b0b09cfdfdad640f · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
// Build an isolated, disposable CI composition; never change production or a released generation.
import assert from 'node:assert/strict';
import {createHash} from 'node:crypto';
import {readFileSync,writeFileSync,mkdirSync,existsSync} from 'node:fs';
import {fileURLToPath} from 'node:url';
import {resolve,dirname} from 'node:path';
const root=fileURLToPath(new URL('../../',import.meta.url));
const base=resolve(root,'atlas/v/202612012118');
const [generation,sourceSha]=process.argv.slice(2);
const numbered=generation!==undefined;
if(numbered){assert.match(generation,/^\d{12}$/);assert.match(sourceSha||'',/^[a-f0-9]{40}$/);}
const out=resolve(root,'atlas/v',generation||'satnav-unified-agent1-ci');
const read=p=>readFileSync(p);
const sha=b=>createHash('sha256').update(b).digest('hex');
const manifest=JSON.parse(read(resolve(base,'current.json')));
assert.equal(manifest.composition_version,'v9.200');
assert.equal(manifest.generation,'202612012118');
const old=manifest.cartridges.find(c=>c.id==='satnav-waypoint-map');
assert.ok(old);
const modulePath='../../modules/satnav-unified-waypoint-map-agent1.js';
const bytes=read(resolve(out,modulePath));
Object.assign(old,{path:modulePath,sha256:sha(bytes),bytes:bytes.length,source:'Agent 1 unified shell derivative'});
// Reuse native search via a new derivative; never modify the historical cartridge.
const search=manifest.cartridges.find(c=>c.id==='uk-gazetteer-flyto');
assert.ok(search);
const searchPath='../../modules/unified-native-gazetteer.js';
const searchBytes=read(resolve(out,searchPath));
Object.assign(search,{path:searchPath,sha256:sha(searchBytes),bytes:searchBytes.length,source:'V9.201 native gazetteer derivative'});
// Dynamic ES modules are pinned dependencies, not classic-script cartridges.
for(const path of ["atlas/modules/unified-layer-catalogue.mjs","atlas/modules/unified-layer-search-ui.mjs","atlas/modules/unified-destination-contract.mjs","tools/satnav/vendor/9698781539e549deaa6ecaa4a2b34610c1f9fd29/vendor/grid-distance-maths/src/geodesy.mjs","tools/satnav/vendor/9698781539e549deaa6ecaa4a2b34610c1f9fd29/nav/compass.mjs","tools/satnav/line/position-overlay.mjs","tools/satnav/wayp  … [line shortened here: 501 characters; full line on GitHub]
 const b=read(resolve(root,path));
 assert.ok(!manifest.runtime_dependency_pins.some(p=>p.path===path));
 manifest.runtime_dependency_pins.push({path,sha256:sha(b),bytes:b.length});
}
// The standalone field curtain hijacks the native dashboard. In unified mode
// retain the original GridAtlas dashboard and fullscreen layer bridge.
assert.ok(manifest.cartridge_order.includes('satnav-field-layers'));
manifest.cartridges=manifest.cartridges.filter(c=>c.id!=='satnav-field-layers');
manifest.cartridge_order=manifest.cartridge_order.filter(id=>id!=='satnav-field-layers');
const seen=new Set();
for(const id of manifest.cartridge_order){
 const entry=manifest.cartridges.find(c=>c.id===id);
 assert.ok(entry&&!seen.has(id),id);
 if(entry.slot==='after-cartridge')assert.ok(seen.has(entry.after),id+' anchor');
 const b=read(resolve(out,entry.path));
 assert.equal(sha(b),entry.sha256,id+' SHA-256');
 if(entry.bytes!==undefined)assert.equal(b.length,entry.bytes,id+' bytes');
 seen.add(id);
}
for(const pin of manifest.runtime_dependency_pins||[]){
 const b=read(resolve(root,pin.path));
 assert.equal(sha(b),pin.sha256,pin.path);
 assert.equal(b.length,pin.bytes,pin.path);
}
manifest.generation='satnav-unified-agent1-ci';
manifest.previous_generation='202612012118';
manifest.composition_id='satnav-unified-agent1-ci';
manifest.composition_note='Unpublished Agent 1 integration test; original native shell and collapsible SatNav.';
manifest.owner_test_mode='ci-only';
delete manifest.composition_manifest;
if(numbered){
 for(const c of [old,search]){c.generation=generation;c.version='v9.201';if(c.assembled_from){c.historical_assembled_from=c.assembled_from;delete c.assembled_from;}}
 ((m,g,ref)=>{Object.assign(m,{generation:g,previous_generation:"202612012118",composition_id:g+"-gridatlas-v9.201",composition_version:"v9.201",composition_note:"Unified GridAtlas/SatNav owner-test candidate; production pointer unchanged.",owner_test_mode:"unified",composition_manifest:"../../manifests/"+g+"-composition.json",source_revisions:{...m.source_revisions,integration:ref}});return m;})(  … [line shortened here: 431 characters; full line on GitHub]
 const ledger=((m,g)=>{const l=JSON.parse(JSON.stringify(m),(k,x)=>typeof x==="string"&&x.startsWith("../../")?(x.slice(6).startsWith("../")?x.slice(6):"./"+x.slice(6)):x);return Object.assign(l,{parent_generation:"202612012118",version:"v9.201",note:"Owner-test candidate; production pointer unchanged.",acceptance:{status:"pending_exact_revision_browser_acceptance",physical_iphone_safari:"unverifi  … [line shortened here: 597 characters; full line on GitHub]
 const ledgerPath=resolve(root,'atlas/manifests',generation+'-composition.json');
 assert.ok(!existsSync(out)&&!existsSync(ledgerPath),'Refusing to overwrite existing release');
 writeFileSync(ledgerPath,JSON.stringify(ledger,null,1)+'\n',{flag:'wx'});
}
assert.ok(!existsSync(out),'Refusing to overwrite existing candidate');
mkdirSync(out,{recursive:true});
writeFileSync(resolve(out,'index.html'),read(resolve(base,'index.html')));
writeFileSync(resolve(out,'current.json'),JSON.stringify(manifest,null,1)+'\n');
console.log('Verified '+seen.size+' cartridge hashes and created '+out);

SatNav Build

A JavaScript module in the tools folder of GridAtlas that reads the Renewable Energy Planning Database (REPD) register, using SHA-256.

storagegridatlas / tools/satnav/build.mjs · lines 1–60 of 60 · Entry point

What it does
It loads the REPD register. Defines read, hash, write. Uses libraries node:fs, node:path, node:crypto, node:url. Side effects: reads or writes files.
Why it exists in the grid workflow
Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work. Domain terms in the code: the REPD register.
Inputs & outputs
In: JSON file current.json.
Downstream impact
Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
What it achieves
Defines `read`, `hash` and `write`. It reads `atlas/current.json` and writes `index.html`.
Why it matters
Run by GridAtlas PR File Size Guard Workflow.
Application
gridatlas · tools/satnav · JavaScript module
Uses
GridAtlas — Release (import), node:fs, node:path, node:crypto, node:url
Used by
run by GridAtlas PR File Size Guard Workflow (workflow run)
Produces
read, hash, write
Defines here
read, hash, write
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/build.mjs:1-60 · blob 56116f22eb98890edfcdd376f79f4d138a33c399 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
import fs from 'node:fs';
import path from 'node:path';
import {createHash} from 'node:crypto';
import {fileURLToPath} from 'node:url';
import {rerootForPreview} from '../release/lib.mjs';
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'../..');
const read=p=>fs.readFileSync(path.join(root,p),'utf8').replace(/\r\n/g,'\n');
const hash=s=>createHash('sha256').update(s).digest('hex');
const write=(p,s)=>{fs.mkdirSync(path.dirname(path.join(root,p)),{recursive:true});fs.writeFileSync(path.join(root,p),s);};
const composition=JSON.parse(read('atlas/current.json'));
if(composition.generation!=='202611222343')throw Error('Re-review a changed live baseline before building');
let engine=read('atlas/modules/202611222000-uk-offtakers-overlay.js');
if(hash(engine)!==composition.cartridges.find(x=>x.id==='uk-offtakers-overlay').sha256)throw Error('Engine source differs from live composition pin');
const insertion=`function openPointVicinity(input){
 if(!input||!Array.isArray(input.at)||input.at.length!==2||!input.at.every(Number.isFinite)||Math.abs(input.at[0])>180||Math.abs(input.at[1])>90||input.at.every(v=>v===0))return false;
 const map=mh();if(!map||typeof NS.gridScope?.scope!=='function')return false;
 const name=String(input.name||'Chosen map point').slice(0,180);
 const record={sources:[],status:String(input.status||'not stated'),origin_kind:input.kind||'map'};
 if(input.repdRef&&/^[1-9]\\d{0,11}$/.test(input.repdRef))record.repd_ref=String(input.repdRef);
 const card=dcc(map,{k:'c',t:'un',dc:0,n:name,op:'',a:input.at.slice(),p:record},15,{project:true});
 card.dataset.satnavOriginKind=record.origin_kind;return true;
}
`;
if(!engine.includes('function openProjectVicinity(input){'))throw Error('Missing reviewed engine seam');
engine=engine.replace('function openProjectVicinity(input){',insertion+'function openProjectVicinity(input){');
engine=engine.replace('install:ins,setOn:so,openProjectVicinity','install:ins,setOn:so,openProjectVicinity,openPointVicinity');
engine=engine.replace("project?`${NM(r)} · REPD ${cs(p.repd_ref)}`","project?`${NM(r)}${p.repd_ref?' · REPD '+cs(p.repd_ref):' · chosen source point'}`");
engine=engine.replace("c.project?'REPD project':'data-centre'","c.project?(c.r.p.repd_ref?'REPD project':'chosen point'):'data-centre'");
engine=engine.replace("c.project?'REPD project':'data centre'","c.project?(c.r.p.repd_ref?'REPD project':'chosen point'):'data centre'");
engine=engine.replace("project?'Project vicinity (screening)'", "project?(p.repd_ref?'Project vicinity (screening)':'Point vicinity (screening)')");
engine=engine.replace("project?'REPD project vicinity. Distances are straight-line; connectivity and capacity unknown.'", "project?(p.repd_ref?'REPD project vicinity. Distances are straight-line; connectivity and capacity unknown.':'Chosen-point vicinity. No asset identity or connection is inferred.')");
// Generic origins remain anonymous in CSV; no synthetic data-centre identity.
engine=engine.replace("['data centre',0,NM(r),id,'data centre',sl", "[c.project?(r.p.repd_ref?'REPD project':'chosen point'):'data centre',0,NM(r),id,c.project?'source point':'data centre',sl");
engine=engine.replace("c.project?'PipelineNews map origin'", "c.project?(r.p.repd_ref?'REPD source point':'Explicitly selected '+(r.p.origin_kind||'map')+' point')");
engine=engine.replace("c.project?'REPD (DESNZ)'", "c.project?(r.p.repd_ref?'REPD (DESNZ)':'not applicable to chosen point')");
engine=engine.replace("c.project?'# REPD project context from PipelineNews MAP URL; MW does not establish connection capacity.'", "c.project?(r.p.repd_ref?'# REPD source point; not a confirmed entrance or connection.':'# Explicit chosen point; no asset identity, capacity or entrance is inferred.')");
const enginePath='atlas/modules/202611242030-satnav-point-vicinity.js';write(enginePath,engine);
const engineEntry=composition.cartridges.find(x=>x.id==='uk-offtakers-overlay');
engineEntry.path='./modules/'+path.basename(enginePath);engineEntry.sha256=hash(engine);engineEntry.bytes=Buffer.byteLength(engine);
let focus=read('atlas/modules/202611222130-vicinity-focus.js');
if(hash(focus)!==composition.cartridges.find(x=>x.id==='vicinity-focus').sha256)throw Error('Focus source differs from live composition pin');
focus=focus.replace("kind:'REPD project (origin)'", "kind:p.repd_ref?'REPD project (origin)':'Chosen source point (origin)'");
focus=focus.replace("source:'PipelineNews MAP arrival parameters; a location is not a declared grid connection'", "source:p.repd_ref?'REPD source point; entrance and connection unverified':'Explicit '+(p.origin_kind||'map')+' point; no asset identity inferred'");
focus=focus.replace("['REPD reference',safely(p.repd_ref)]", "[p.repd_ref?'REPD reference':'Asset identity',p.repd_ref?safely(p.repd_ref):'not asserted']");
// If the native swipe ran before focus was attached, keep its existing highlight.
focus=focus.replace("signature:null,origin:true", "signature:null,origin:!s.marker");
focus=focus.replace("s.label.style.visibility='hidden';", "s.label.style.visibility=card.__vicFocus.origin?'hidden':'';");
const focusPath='atlas/modules/202611242030-satnav-origin-focus.js';write(focusPath,focus);
const focusEntry=composition.cartridges.find(x=>x.id==='vicinity-focus');focusEntry.path='./modules/'+path.basename(focusPath);focusEntry.sha256=hash(focus);focusEntry.bytes=Buffer.byteLength(focus);
const source=read('tools/satnav/handoff.js'),modulePath='atlas/modules/202611242030-satnav-handoff.js';write(modulePath,source);
composition.cartridge_order.push('satnav-handoff');
composition.cartridges.push({id:'satnav-handoff',type:'script',slot:'after-cartridge',after:'vicinity-controls-rescue',path:'./modules/'+path.basename(modulePath),sha256:hash(source),preview_only:true});
composition.generation='202611242030';composition.composition_id='satnav-native-m1-candidate';
composition.composition_note='Isolated M1 candidate. No live selection, release or acceptance.';
// The existing geodesy module supplies the station index canonical geometry.
if(!read('atlas/modules/202609011950-geodesy.js'))throw Error('Missing geodesy');
const loader=read('atlas/index.html');
const route='atlas/v/satnav-native-m1/';
write(route+'index.html',loader);write(route+'current.json',rerootForPreview(JSON.stringify(composition,null,1))+'\n');
console.log('Candidate /atlas/v/satnav-native-m1/; handoff SHA256 '+hash(source));