GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / AI agents and coordination / neural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead

Leadtest and 4 more files

A JavaScript module in the lead folder of Neural Link Between Agents that works with same order (`sameOrder`) and draws on a canvas, using SHA-256.

666 lines of JavaScript and Shell from neural-link-between-agents, in 5 files. Topic: AI agents and coordination. Section 1632 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. Leadtest render · neural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/leadtest.cjs lines 1–241
  2. Leadtest5 render · neural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/leadtest5.cjs lines 1–241
  3. R2 interaction · neural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/r2/r2.cjs lines 1–13
  4. Block interaction · neural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/src/block.js lines 1–156
  5. Mk automation · neural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/src/mk.sh lines 1–15

Leadtest

A JavaScript module in the lead folder of Neural Link Between Agents that works with same order (`sameOrder`) and draws on a canvas, using SHA-256.

renderneural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/leadtest.cjs · lines 1–241 of 241 · Entry point · pattern sameOrder (shared by 3 files)

What it does
It draws its content. Defines 16 functions or classes, including flag, sleep, sha, probe, rec. Uses libraries playwright, fs, path, crypto, child_process. Side effects: changes the web page (DOM); reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'agents'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
In: JSON file modules.json; JSON file keys.json; command-line arguments. Out: JSON file report.json; JSON file modules.json; canvas drawing.
Downstream impact
It is itself an entry point (JavaScript module); no other file was found loading it.
What it achieves
It is built from the probe step (`probe`), the rec step (`rec`) and the manifest step (`manifest`). Defines `flag`, `sleep`, `sha` and 11 more.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
neural-link-between-agents · FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead · JavaScript module
Uses
playwright, fs, path, crypto, child_process, os
Used by
none found
Produces
flag, sleep, sha, probe, rec, manifest, run, sameOrder, why, net404, add, w
Defines here
flag, sleep, sha, probe, rec, manifest, run, sameOrder, why, net404, add, w, test8, mk, proof, check
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
neural-link-between-agents@598eff3f59afe11738d64cb14cb8befe5e37cdc2 FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/leadtest.cjs:1-241 · blob ea6afc4b54fa1f1255ef9856ab394d171247e6bc · GitHub at these lines
State
achieves: name · context: auto · stage: output · effects: dom, filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: unknown
#!/usr/bin/env node
// test.cjs: NL-010 step 4 "the Kuiper cartridge law", tests 1-9 (ROADMAP.md step 4; team-2/STEPS.md step 4 acceptance).
//
//   node test.cjs <edition-url> <outdir> [--page <patched index.html>] [--devices "Pixel 7,Galaxy S24"]
//
// <edition-url> is http://127.0.0.1:<port>/editions/202611012135/ served from the kuiper-belt root. Until the
// integrator applies handoff/04-loader/index.html.patch, pass --page with the patched file and the test serves it in
// place of index.html (served, not committed). The manifests and every mutated module are served by the test through
// page.route, never written into the repository. Pixel 7 and Galaxy S24 (360 px), real touch (page.touchscreen.tap),
// pageerror 0 in every case; console errors 0 except the browser's own "Failed to load resource" line in the cases that
// serve a 404 on purpose (6 and 7b), which is counted and reported. Test 8 runs tools/edition_check.py (from
// handoff/04-loader/edition_check.py.patch when the tool is not in the repository yet) on a copy. Exit 0 when all pass.
'use strict';
const { chromium, devices } = require('playwright');
const fs = require('fs'), path = require('path'), crypto = require('crypto'), cp = require('child_process'), os = require('os');
const argv = process.argv.slice(2), pos = argv.filter((a, i) => !a.startsWith('--') && !(i && argv[i - 1].startsWith('--')));
const flag = n => { const i = argv.indexOf(n); return i >= 0 ? argv[i + 1] : null; };
if (pos.length < 2) { console.error('usage: node test.cjs <edition-url> <outdir> [--page file] [--devices A,B]'); process.exit(2); }
const BASE = pos[0].replace(/\/?$/, '/'), OUT = path.resolve(pos[1]), PAGE = flag('--page');
const DEVICES = (flag('--devices') || 'Pixel 7,Galaxy S24').split(',').map(s => s.trim());
const HERE = '/home/user/estate/kuiper-belt/editions/202611012135/handoff/04-loader', ED = path.resolve(HERE, '../..'), REPO = path.resolve(ED, '../..');
const sleep = ms => new Promise(r => setTimeout(r, ms));
const sha = b => crypto.createHash('sha256').update(b).digest('hex');
fs.mkdirSync(OUT, { recursive: true });

// ------------------------------------------------------------------------------------------- fixtures
const FIRST = JSON.parse(fs.readFileSync(path.join(HERE, 'modules.json'), 'utf8'));
const HELLO = fs.readFileSync(path.join(ED, FIRST.modules[0].path));
const STAMP = '202611012145';
const HOOKS28 = ['keyPlace', 'address', 'describe', 'findBy', 'flyTo', 'home', 'homeCamera', 'safeBox', 'lightTime', 'showNew',
  'goKey', 'fmt', 'words', 'esc', 'cv', 'ov', 'o2', 'hud', 'big', 'sub', 'card', 'gbox', 'gin', 'SPACE', 'N', 'repos', 'commits', 'wafer'];
function probe(id, requires, body) {           // a test-only module, served by the test, never committed
  return Buffer.from(`/* kuiper module ${id}, generation ${STAMP} (UTC), Apache-2.0 (kuiper-belt) */
// test-only probe of handoff/04-loader/test.cjs; served by the test, never committed
(function () {
  'use strict';
  KY.register({ schema: 'kuiper.module.v1', id: '${id}', generation: '${STAMP}', requires: ${JSON.stringify(requires)}, provides: ['${id}'],
    install(KY) { const h = document.createElement('div'); h.id = 'ky-${id}'; h.hidden = true; document.body.appendChild(h); ${body || 'return { ok: true };'} },
    inspect() { return { id: '${id}' }; } });
})();
`);
}
function rec(id, file, buf, requires, extra) {
  return Object.assign({ id, generation: STAMP, path: 'modules/' + file, sha256: sha(buf), bytes: buf.length, byte_budget: 4096,
    requires, provides: [id], reads: [], writes: ['window.KY.modules.' + id, '#ky-' + id], creates_controls: 'none',
    licence: 'Apache-2.0', team: '04', step: 4, proof: 'handoff/04-loader/' }, extra || {});
}
const PA = probe('probe-a', ['keyPlace', 'cam']), PB = probe('probe-b', ['keyPlace', 'probe-a']);
const PW = probe('probe-w', ['wafer', 'N'], `window.__probeW = { installed_ms: performance.now(), N_at_install: KY.hooks.N };
      return KY.hooks.wafer.then(w => { window.__probeW.resolved_ms = performance.now(); window.__probeW.N = w.N; return { N: w.N }; },
        e => { window.__probeW.rejected = String(e && e.message || e); throw e; });`);
function manifest(mods) { return Object.assign({}, FIRST, { order: mods.map(m => m.id), modules: mods }); }
const R_HELLO = FIRST.modules[0];
const R_PA = rec('probe-a', STAMP + '-probe-a.js', PA, ['keyPlace', 'cam']);
const R_PB = rec('probe-b', STAMP + '-probe-b.js', PB, ['keyPlace', 'probe-a']);
const R_PW = rec('probe-w', STAMP + '-probe-w.js', PW, ['wafer', 'N']);
const THREE = manifest([R_HELLO, R_PA, R_PB]);
const SHELL = fs.readFileSync(path.join(ED, 'modules/202611012143-kuiper-shell.js'));
const R_SHELL = Object.assign(rec('kuiper-shell', '202611012143-kuiper-shell.js', SHELL, ['safeBox', 'card', 'hud', 'big', 'sub', 'cv', 'gbox', 'gin', 'redraw']),
  { generation: '202611012143', provides: ['kuiper-shell', 'menuBar'], byte_budget: 65536, team: '01', step: 1 });
const PP = probe('probe-p', ['panels', 'kuiper-shell'], "KY.panels.add('wafer', h, 'wafer'); window.__probeP = { inShellPanel: h.parentElement === KY.modules['kuiper-shell'].api.panel('wafer') }; return { ok: true };");
const R_PP = rec('probe-p', STAMP + '-probe-p.js', PP, ['panels', 'kuiper-shell']);
const files = { [R_SHELL.path]: SHELL, [R_PP.path]: PP, [R_PA.path]: PA, [R_PB.path]: PB, [R_PW.path]: PW };

// ------------------------------------------------------------------------------------------- one run
async function run(browser, dev, name, o) {
  const ctx = await browser.newContext({ ...devices[dev] }), page = await ctx.newPage();
  const errors = [], consoleErr = [];
  page.on('pageerror', e => errors.push(String(e && e.message || e)));
  page.on('console', m => { if (m.type() === 'error') consoleErr.push(m.text()); });
  if (PAGE) await page.route(u => u.href === BASE || u.href === BASE + 'index.html', r => r.fulfill({ status: 200, contentType: 'text/html; charset=utf-8', body: fs.readFileSync(PAGE) }));
  await page.route(BASE + 'modules.json', r => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(o.manifest) }));
  const served = Object.assign({}, files, o.files || {});
  await page.route(u => u.href.startsWith(BASE + 'modules/'), r => { const p = r.request().url().slice(BASE.length);
    if (served[p] === 404) return r.fulfill({ status: 404, body: 'not found' });
    if (served[p]) return r.fulfill({ status: 200, contentType: 'text/javascript', body: served[p] });
    return r.continue(); });
  let waferAt = null;
  if (o.wafer === '404') await page.route(/cosmos\/wafer\.tsv$/, r => r.fulfill({ status: 404, body: 'not found' }));
  if (o.wafer === 'delay') await page.route(/cosmos\/wafer\.tsv$/, async r => { await sleep(o.delay || 12000); waferAt = Date.now(); await r.continue(); });
  const t0 = Date.now();
  await page.goto(BASE, { waitUntil: 'load', timeout: 120000 });
  await page.waitForFunction(() => window.__KUIPER_EDITION__ && window.__KUIPER_EDITION__.done, null, { timeout: 90000 });
  await sleep(o.settle || 7000);
  const st = await page.evaluate(() => {
    const E = window.__KUIPER_EDITION__, nav = performance.getEntriesByType('navigation')[0], rf = document.getElementById('refuse');
    const rr = rf && rf.getBoundingClientRect();
    return { admitted: E.admitted, refused: E.refused, failures: E.failures, whole: E.whole || null, order: E.order, timings: E.timings,
      bytes: E.bytes, byte_budget: E.byte_budget, load_event_ms: Math.round(nav.loadEventStart), dcl_ms: Math.round(nav.domContentLoadedEventStart),
      refuse: rf ? { text: rf.textContent, role: rf.getAttribute('role'), rect: { left: rr.left, top: rr.top, right: rr.right, bottom: rr.bottom },
        visible: getComputedStyle(rf).display !== 'none' && rr.height > 0, inViewport: rr.left >= 0 && rr.top >= 0 && rr.right <= innerWidth && rr.bottom <= innerHeight } : null,
      hud: document.getElementById('hud').textContent, bar: !!document.getElementById('bar'), vw: innerWidth, vh: innerHeight,
      hosts: [...document.querySelectorAll('[id^="ky-"]')].map(e => e.id), scripts: [...document.querySelectorAll('script[data-ky-module]')].map(s => s.dataset.kyModule),
      N: window.KY ? window.KY.hooks.N : null, probeW: window.__probeW || null, probeP: window.__probeP || null,
      frozen: window.KY ? { KY: Object.isFrozen(window.KY), hooks: Object.isFrozen(KY.hooks), names: Object.isFrozen(KY.names), cam: Object.isFrozen(KY.cam),
        lit: Object.isFrozen(KY.lit), sel: Object.isFrozen(KY.sel), draw: Object.isFrozen(KY.draw), panels: Object.isFrozen(KY.panels) } : null,
      hookKeys: window.KY ? Object.keys(KY.hooks) : null, alias: window.KY ? window.__KUIPER_MODULES__ === KY.modules : null,
      writeThrows: (function () { 'use strict'; try { window.KY.hooks.flyTo = null; return false; } catch (e) { return e instanceof TypeError; } })(),
      helloInspect: window.KY && KY.modules.hello ? KY.modules.hello.inspect() : null };
  });
  // the wafer is drawn: non-black pixels of a CSS-px screenshot, outside the bar and the refusal strip
  const shot = await page.screenshot({ scale: 'css', timeout: 180000 });
  st.wafer = await page.evaluate(async ({ b64, skip }) => { const img = new Image(); img.src = 'data:image/png;base64,' + b64; await img.decode();
    const c = document.createElement('canvas'); c.width = img.width; c.height = img.height; const x = c.getContext('2d', { willReadFrequently: true }); x.drawImage(img, 0, 0);
    const d = x.getImageData(0, 0, c.width, c.height).data, bar = document.getElementById('bar').getBoundingClientRect(); let lit = 0, n = 0;
    for (let y = Math.ceil(bar.bottom) + 2; y < c.height; y += 2) for (let X = 0; X < c.width; X += 2) {
      if (skip && X >= skip.left && X <= skip.right && y >= skip.top && y <= skip.bottom) continue;
      const i = (y * c.width + X) * 4; n++; if (d[i] + d[i + 1] + d[i + 2] > 60) lit++; }
    return { lit_fraction: +(lit / n).toFixed(4), sampled: n }; }, { b64: shot.toString('base64'), skip: st.refuse && st.refuse.rect });
  st.waferDrawn = st.wafer.lit_fraction > 0.01;
  if (o.shot) fs.writeFileSync(path.join(OUT, `${o.shot}-${dev.replace(/ /g, '_')}.png`), shot);
  if (o.touch) st.touch = await o.touch(page);
  st.pageerror = errors; st.console_errors = consoleErr; st.wall_ms = Date.now() - t0; st.wafer_delayed_until_ms = waferAt ? waferAt - t0 : null;
  await ctx.close();
  return st;
}
const sameOrder = (st, ids, m) => st.admitted.length === ids.length && st.admitted.every((a, i) => a.id === ids[i] && a.sha256 === m.modules.find(x => x.id === a.id).sha256);
const why = (st, id) => (st.refused.find(r => r.id === id) || {}).why || '';
const net404 = s => s.every(t => /Failed to load resource.*404/.test(t));

(async () => {
  const browser = await chromium.launch({ args: ['--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'] });
  const report = { url: BASE, page: PAGE || 'served index.html', started: new Date().toISOString(), devices: {}, test8: null };
  let allPass = true;
  for (const dev of DEVICES) {
    const T = {}; report.devices[dev] = T;
    const add = (k, pass, data) => { T[k] = Object.assign({ PASS: !!pass }, data); if (!pass) allPass = false; console.log(dev, k, pass ? 'PASS' : 'FAIL'); };
    let s;
    // 1 every order entry admitted in order with the manifest's sha256; readout lines; real touch opens READOUT
    s = await run(browser, dev, 't1', { manifest: THREE, shot: '1-admitted', touch: async page => {
      const b = await page.$('#bar .gm-title[data-panel="hud"]'); const r = await b.boundingBox();
      await page.touchscreen.tap(r.x + r.width / 2, r.y + r.height / 2); await sleep(1500);
      return page.evaluate(() => ({ open: document.getElementById('hud').classList.contains('gm-open'), lines: document.getElementById('hud').textContent.split('\n').filter(l => / admitted · [0-9a-f]{12}$/.test(l)) })); } });
    add('1', sameOrder(s, ['hello', 'probe-a', 'probe-b'], THREE) && !s.refused.length && !s.refuse && s.touch.open && s.touch.lines.length === 3
      && s.helloInspect && s.helloInspect.frames_drawn > 0 && !s.pageerror.length && !s.console_errors.length, s);
    // 2 one byte changed in a served module: sha256 mismatch, the rest admitted, alert inside the viewport, wafer drawn
    const bad = Buffer.from(HELLO); bad[bad.length - 2] ^= 1;
    s = await run(browser, dev, 't2', { manifest: THREE, files: { [R_HELLO.path]: bad }, shot: '2-sha-mismatch' });
    add('2', why(s, 'hello') === 'sha256 mismatch' && s.admitted.map(a => a.id).join() === 'probe-a,probe-b' && s.refuse && s.refuse.role === 'alert'
      && s.refuse.visible && s.refuse.inViewport && s.waferDrawn && s.bar && !s.hosts.includes('ky-hello') && !s.scripts.includes('hello') && !s.pageerror.length && !s.console_errors.length, s);
    // 3 requires noSuchHook: missing hook; host absent; the module that requires its provides refused too
    s = await run(browser, dev, 't3', { manifest: manifest([R_HELLO, Object.assign({}, R_PA, { requires: ['noSuchHook'] }), R_PB]) });
    add('3', why(s, 'probe-a') === 'missing hook noSuchHook' && why(s, 'probe-b') === 'missing hook probe-a' && s.admitted.map(a => a.id).join() === 'hello'
      && !s.hosts.includes('ky-probe-a') && !s.pageerror.length && !s.console_errors.length, s);
    // 4 renamed stamp: refused in words; renamed without leading digits: admitted (identity is generation + sha256)
    s = await run(browser, dev, 't4a', { manifest: manifest([R_HELLO, Object.assign({}, R_PA, { path: 'modules/202611012146-probe-a.js' })]), files: { 'modules/202611012146-probe-a.js': PA } });
    const s4b = await run(browser, dev, 't4b', { manifest: manifest([R_HELLO, Object.assign({}, R_PA, { path: 'modules/probe-a.js' })]), files: { 'modules/probe-a.js': PA } });
    add('4', why(s, 'probe-a') === 'stamp mismatch: generation 202611012145, file name 202611012146' && s.admitted.map(a => a.id).join() === 'hello'
      && s4b.admitted.map(a => a.id).join() === 'hello,probe-a' && !s.pageerror.length && !s4b.pageerror.length && !s.console_errors.length && !s4b.console_errors.length, { renamed: s, no_digits: s4b });
    // 5 install throws: install threw test, the rest admitted
    const thr = Buffer.from(HELLO.toString().replace('install(KY) {', "install(KY) { throw new Error('test');"));
    s = await run(browser, dev, 't5', { manifest: manifest([Object.assign({}, R_HELLO, { sha256: sha(thr), bytes: thr.length }), R_PA, R_PB]), files: { [R_HELLO.path]: thr } });
    add('5', why(s, 'hello') === 'install threw test' && s.admitted.map(a => a.id).join() === 'probe-a,probe-b' && !s.pageerror.length && !s.console_errors.length, s);
    // 6 file deleted: HTTP 404
    s = await run(browser, dev, 't6', { manifest: THREE, files: { [R_HELLO.path]: 404 } });
    add('6', why(s, 'hello') === 'HTTP 404' && s.admitted.map(a => a.id).join() === 'probe-a,probe-b' && !s.pageerror.length && net404(s.console_errors), s);
    // 7 empty manifest: whole wafer and bar, admitted [], no alert, KY frozen, the 28 hooks, the alias
    s = await run(browser, dev, 't7', { manifest: manifest([]), shot: '7-empty', touch: async page => page.evaluate(() => {
      const r = {}; KY.refuse('probe line', 'probe'); r.shown = (document.getElementById('refuse') || {}).textContent === 'probe line';
      KY.refuse('', 'probe'); r.cleared = !document.getElementById('refuse');
      try { KY.refuse('x', 'engine'); r.reserved = false; } catch (e) { r.reserved = e instanceof TypeError; }
      KY.cam.atHome = false; r.atHomeFalse = KY.cam.atHome === false; KY.cam.atHome = true; r.atHomeTrue = KY.cam.atHome === true;
      r.names36 = KY.names.length === 36 && KY.names.includes('refuse') && KY.names.includes('nav'); return r; }) });
    add('7', Object.values(s.touch).every(Boolean) && s.waferDrawn && s.bar && !s.admitted.length && !s.refused.length && !s.refuse && s.frozen && Object.values(s.frozen).every(Boolean) && s.writeThrows
      && JSON.stringify(s.hookKeys) === JSON.stringify(HOOKS28) && s.alias && !s.pageerror.length && !s.console_errors.length, s);
    // 7b wafer.tsv 404: modules that do not require the wafer admitted, the engine's words in the strip, the wafer module's install rejects in words
    s = await run(browser, dev, 't7b', { manifest: manifest([R_HELLO, R_PA, R_PW]), wafer: '404' });
    add('7b', s.admitted.map(a => a.id).join() === 'hello,probe-a,probe-w' && s.refuse && /did not load\. The wafer will not invent its keys\./.test(s.refuse.text)
      && s.probeW && /did not load/.test(s.probeW.rejected || '') && s.failures.some(f => f.id === 'probe-w') && !s.pageerror.length && net404(s.console_errors), s);
    // 7c wafer.tsv held back 12 s: hello is admitted while the 535,037-byte fetch is still pending
    s = await run(browser, dev, 't7c', { manifest: manifest([R_HELLO, R_PW]), wafer: 'delay', delay: 12000, settle: 16000 });
    const hAd = (s.admitted.find(a => a.id === 'hello') || {}).t_ms;
    add('7c', hAd != null && s.probeW && s.probeW.N_at_install === 0 && s.probeW.resolved_ms > hAd + 5000 && s.N > 0 && !s.pageerror.length && !s.console_errors.length,
      Object.assign(s, { hello_admitted_ms: hAd, wafer_resolved_ms: s.probeW && Math.round(s.probeW.resolved_ms) }));
    // 10 (rev 4) KY.panels.add forwards into the shell's panel once kuiper-shell is admitted (01-shell REQUESTS 2)
    s = await run(browser, dev, 't10', { manifest: manifest([R_HELLO, R_SHELL, R_PP]) });
    add('10', s.admitted.map(a => a.id).join() === 'hello,kuiper-shell,probe-p' && s.probeP && s.probeP.inShellPanel && !s.pageerror.length && !s.console_errors.length, s);
    // 11 (rev 5) KY.nav, the one owner of history: another owner's programmatic back never closes the card; a user back
    // closes only the layer whose entry it removed
    s = await run(browser, dev, 't11', { manifest: manifest([R_HELLO]), touch: async page => {
      const w = ms => page.waitForTimeout(ms), card = () => page.evaluate(() => ({ card: document.getElementById('card').style.display, st: history.state, nav: KY.nav.depth }));
      const r = {}; await page.keyboard.press('e'); await w(2500); r.open = await card();
      await page.evaluate(() => { window.__nb = 0; KY.nav.onBack('probe', () => window.__nb++); KY.nav.push('probe'); }); await w(400);
      await page.evaluate(() => KY.nav.back('probe')); await w(1500); r.afterSelfBack = await card();
      await page.evaluate(() => KY.nav.push('probe')); await w(400); await page.evaluate(() => history.back()); await w(1500); r.afterUserBack1 = await card(); r.probeCalls = await page.evaluate(() => window.__nb);
      await page.evaluate(() => history.back()); await w(1500); r.afterUserBack2 = await card();
      r.reserved = await page.evaluate(() => { try { KY.nav.push('edition'); return false; } catch (e) { return e instanceof TypeError; } });
      return r; } });
    { const t = s.touch; add('11', t.open.card === 'block' && t.open.st && t.open.st.owner === 'edition' && t.afterSelfBack.card === 'block' && t.afterSelfBack.st && t.afterSelfBack.st.owner === 'edition'
        && t.afterUserBack1.card === 'block' && t.probeCalls === 1 && t.afterUserBack2.card === 'none' && t.reserved && !s.pageerror.length && !s.console_errors.length, s); }
    // 9 measured, no threshold: load to last admitted; sum of bytes against sum of byte_budget (from test 1's manifest)
    const t1 = T['1'];
    add('9', t1.timings.last_admitted_ms != null, { nav_to_last_admitted_ms: t1.timings.last_admitted_ms, load_event_ms: t1.load_event_ms,
      load_to_last_admitted_ms: t1.timings.last_admitted_ms - t1.load_event_ms, loader_start_ms: t1.timings.loader_start_ms,
      bytes: t1.bytes, byte_budget: t1.byte_budget, modules: t1.admitted.length, note: 'SwiftShader in Playwright, served from 127.0.0.1; negative load_to_last_admitted means the last module was admitted before the load event' });
  }
  // 8 edition_check.py E1-E8 PASS on the integrated copy, FAIL on each mutation applied to a copy
  report.test8 = test8(); if (!report.test8.PASS) allPass = false; console.log('test 8', report.test8.PASS ? 'PASS' : 'FAIL');
  report.PASS = allPass; report.finished = new Date().toISOString();
  fs.writeFileSync(path.join(OUT, 'report.json'), JSON.stringify(report, null, 1));
  await browser.close();
  console.log('RESULT:', allPass ? 'PASS' : 'FAIL'); process.exit(allPass ? 0 : 1);
})().catch(e => { console.error(e); process.exit(2); });

function test8() {
  const tmp = fs.mkdtempSync(path.join(process.env.KY_TMP || os.tmpdir(), 'ky-t8-')), out = {};
  const mk = name => { const d = path.join(tmp, name), e = path.join(d, 'editions', '202611012135');
    fs.mkdirSync(path.join(e, 'modules'), { recursive: true }); fs.mkdirSync(path.join(d, 'tools'));
    fs.copyFileSync(path.join(REPO, 'editions', 'index.html'), path.join(d, 'editions', 'index.html'));
    fs.cpSync(path.join(REPO, 'editions', '202611012027'), path.join(d, 'editions', '202611012027'), { recursive: true });
    for (const f of ['index.html', 'keys.json', 'README.md']) fs.copyFileSync(path.join(ED, f), path.join(e, f));
    if (PAGE) fs.copyFileSync(PAGE, path.join(e, 'index.html'));   // the page under test, not the moving live file
    for (const f of [R_HELLO.path, FIRST.references[0].file]) fs.copyFileSync(path.join(ED, f), path.join(e, f));
    fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(FIRST, null, 1));
    if (!fs.readFileSync(path.join(e, 'index.html'), 'utf8').includes('KUIPER HOOK TABLE AND LOADER'))
      cp.execFileSync('patch', ['-p1', '-s', '-i', path.join(HERE, 'index.html.patch')], { cwd: d });
    const tool = path.join(REPO, 'tools', 'edition_check.py');
    if (fs.existsSync(tool)) fs.copyFileSync(tool, path.join(d, 'tools', 'edition_check.py'));
    else cp.execFileSync('patch', ['-p1', '-s', '-i', path.join(HERE, 'edition_check.py.patch')], { cwd: d });
    return { d, e }; };
  const proof = e => { const lines = []; const walk = p => { for (const f of fs.readdirSync(p).sort()) { const q = path.join(p, f);
      if (fs.statSync(q).isDirectory()) { if (f !== 'handoff') walk(q); } else if (!q.endsWith('edition-sha256.txt')) lines.push(sha(fs.readFileSync(q)) + '  ./' + path.relative(e, q)); } };
    walk(e); fs.mkdirSync(path.join(e, 'proof'), { recursive: true }); fs.writeFileSync(path.join(e, 'proof', 'edition-sha256.txt'), lines.join('\n') + '\n'); };
  const check = d => { const r = cp.spawnSync('python3', ['tools/edition_check.py', 'editions/202611012135'], { cwd: d, encoding: 'utf8' }); return { rc: r.status, out: r.stdout.trim().split('\n') }; };
  const mut = {
    hash: e => { const p = path.join(e, R_HELLO.path), b = fs.readFileSync(p); b[b.length - 2] ^= 1; fs.writeFileSync(p, b); },
    stamp: e => { fs.renameSync(path.join(e, R_HELLO.path), path.join(e, 'modules/202611012146-hello.js'));
      const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].path = 'modules/202611012146-hello.js'; fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); },
    requires: e => { const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].requires = ['noSuchHook']; fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); },
    stray: e => fs.writeFileSync(path.join(e, 'modules/202611012150-stray.js'), '/* stray */\n'),
    writes: e => { const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].writes.push('#ky-nowhere'); fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); },
    register_twice: e => { const p = path.join(e, R_HELLO.path), t = fs.readFileSync(p, 'utf8') + '// KY.register( again\n'; fs.writeFileSync(p, t);
      const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].sha256 = sha(Buffer.from(t)); m.modules[0].bytes = Buffer.byteLength(t); fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); },
    no_licence: e => { const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].licence = ''; fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); } };
  const c0 = mk('committed'); proof(c0.e); out.integrated = check(c0.d);
  let pass = out.integrated.rc === 0 && ['E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8'].every(k => out.integrated.out.some(l => l.startsWith(k + ' PASS')));
  out.mutations = {};
  for (const [k, f] of Object.entries(mut)) { const c = mk(k); f(c.e); proof(c.e); const r = check(c.d); out.mutations[k] = r; if (r.rc !== 1) pass = false; }
  out.PASS = pass; fs.rmSync(tmp, { recursive: true, force: true });
  return out;
}

Leadtest5

A JavaScript module in the lead folder of Neural Link Between Agents that draws modules first, using SHA-256.

Set aside from the main view: 98% of its lines are the same as FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/leadtest.cjs (neural-link-between-agents), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with Leadtest; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9825 to neural-link-between-agents@598eff3f59afe11738d64cb14cb8befe5e37cdc2 FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/leadtest.cjs:1-241 ea6afc4b54fa1f1255ef9856ab394d171247e6bc
  • sha256 3bc67dd630ccaed992b4f8af42b878771280edb918b81d85f675e25b6e1365e6
  • target sha256 aaf8de7658da60b02d64d3838e875676926c9d421b08de75191f69ef78bb4e66
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

renderneural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/leadtest5.cjs · lines 1–241 of 241 · Entry point · pattern sameOrder (shared by 3 files)

What it does
It draws modules first. Defines 16 functions or classes, including flag, sleep, sha, probe, rec. Uses libraries playwright, fs, path, crypto, child_process. Side effects: changes the web page (DOM); reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'agents'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
In: JSON file modules.first.json; JSON file modules.json; JSON file keys.json; command-line arguments. Out: JSON file report.json; JSON file modules.json; canvas drawing.
Downstream impact
It is itself an entry point (JavaScript module); no other file was found loading it.
What it achieves
It is built from the probe step (`probe`), the rec step (`rec`) and the manifest step (`manifest`). Defines `flag`, `sleep`, `sha` and 11 more.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
neural-link-between-agents · FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead · JavaScript module
Uses
playwright, fs, path, crypto, child_process, os
Used by
none found
Produces
flag, sleep, sha, probe, rec, manifest, run, sameOrder, why, net404, add, w
Defines here
flag, sleep, sha, probe, rec, manifest, run, sameOrder, why, net404, add, w, test8, mk, proof, check
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
neural-link-between-agents@598eff3f59afe11738d64cb14cb8befe5e37cdc2 FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/leadtest5.cjs:1-241 · blob 4328143a6c4f3cc5688da246d9de80e28cae8269 · GitHub at these lines
State
achieves: name · context: auto · stage: output · effects: dom, filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: duplicate_candidate
#!/usr/bin/env node
// test.cjs: NL-010 step 4 "the Kuiper cartridge law", tests 1-9 (ROADMAP.md step 4; team-2/STEPS.md step 4 acceptance).
//
//   node test.cjs <edition-url> <outdir> [--page <patched index.html>] [--devices "Pixel 7,Galaxy S24"]
//
// <edition-url> is http://127.0.0.1:<port>/editions/202611012135/ served from the kuiper-belt root. Until the
// integrator applies handoff/04-loader/index.html.patch, pass --page with the patched file and the test serves it in
// place of index.html (served, not committed). The manifests and every mutated module are served by the test through
// page.route, never written into the repository. Pixel 7 and Galaxy S24 (360 px), real touch (page.touchscreen.tap),
// pageerror 0 in every case; console errors 0 except the browser's own "Failed to load resource" line in the cases that
// serve a 404 on purpose (6 and 7b), which is counted and reported. Test 8 runs tools/edition_check.py (from
// handoff/04-loader/edition_check.py.patch when the tool is not in the repository yet) on a copy. Exit 0 when all pass.
'use strict';
const { chromium, devices } = require('playwright');
const fs = require('fs'), path = require('path'), crypto = require('crypto'), cp = require('child_process'), os = require('os');
const argv = process.argv.slice(2), pos = argv.filter((a, i) => !a.startsWith('--') && !(i && argv[i - 1].startsWith('--')));
const flag = n => { const i = argv.indexOf(n); return i >= 0 ? argv[i + 1] : null; };
if (pos.length < 2) { console.error('usage: node test.cjs <edition-url> <outdir> [--page file] [--devices A,B]'); process.exit(2); }
const BASE = pos[0].replace(/\/?$/, '/'), OUT = path.resolve(pos[1]), PAGE = flag('--page');
const DEVICES = (flag('--devices') || 'Pixel 7,Galaxy S24').split(',').map(s => s.trim());
const HERE = '/home/user/estate/kuiper-belt/editions/202611012135/handoff/04-loader', ED = path.resolve(HERE, '../..'), REPO = path.resolve(ED, '../..');
const sleep = ms => new Promise(r => setTimeout(r, ms));
const sha = b => crypto.createHash('sha256').update(b).digest('hex');
fs.mkdirSync(OUT, { recursive: true });

// ------------------------------------------------------------------------------------------- fixtures
const FIRST = JSON.parse(fs.readFileSync(path.join(HERE, 'rev5', 'modules.first.json'), 'utf8'));
const HELLO = fs.readFileSync(path.join(ED, FIRST.modules[0].path));
const STAMP = '202611012145';
const HOOKS28 = ['keyPlace', 'address', 'describe', 'findBy', 'flyTo', 'home', 'homeCamera', 'safeBox', 'lightTime', 'showNew',
  'goKey', 'fmt', 'words', 'esc', 'cv', 'ov', 'o2', 'hud', 'big', 'sub', 'card', 'gbox', 'gin', 'SPACE', 'N', 'repos', 'commits', 'wafer'];
function probe(id, requires, body) {           // a test-only module, served by the test, never committed
  return Buffer.from(`/* kuiper module ${id}, generation ${STAMP} (UTC), Apache-2.0 (kuiper-belt) */
// test-only probe of handoff/04-loader/test.cjs; served by the test, never committed
(function () {
  'use strict';
  KY.register({ schema: 'kuiper.module.v1', id: '${id}', generation: '${STAMP}', requires: ${JSON.stringify(requires)}, provides: ['${id}'],
    install(KY) { const h = document.createElement('div'); h.id = 'ky-${id}'; h.hidden = true; document.body.appendChild(h); ${body || 'return { ok: true };'} },
    inspect() { return { id: '${id}' }; } });
})();
`);
}
function rec(id, file, buf, requires, extra) {
  return Object.assign({ id, generation: STAMP, path: 'modules/' + file, sha256: sha(buf), bytes: buf.length, byte_budget: 4096,
    requires, provides: [id], reads: [], writes: ['window.KY.modules.' + id, '#ky-' + id], creates_controls: 'none',
    licence: 'Apache-2.0', team: '04', step: 4, proof: 'handoff/04-loader/' }, extra || {});
}
const PA = probe('probe-a', ['keyPlace', 'cam']), PB = probe('probe-b', ['keyPlace', 'probe-a']);
const PW = probe('probe-w', ['wafer', 'N'], `window.__probeW = { installed_ms: performance.now(), N_at_install: KY.hooks.N };
      return KY.hooks.wafer.then(w => { window.__probeW.resolved_ms = performance.now(); window.__probeW.N = w.N; return { N: w.N }; },
        e => { window.__probeW.rejected = String(e && e.message || e); throw e; });`);
function manifest(mods) { return Object.assign({}, FIRST, { order: mods.map(m => m.id), modules: mods }); }
const R_HELLO = FIRST.modules[0];
const R_PA = rec('probe-a', STAMP + '-probe-a.js', PA, ['keyPlace', 'cam']);
const R_PB = rec('probe-b', STAMP + '-probe-b.js', PB, ['keyPlace', 'probe-a']);
const R_PW = rec('probe-w', STAMP + '-probe-w.js', PW, ['wafer', 'N']);
const THREE = manifest([R_HELLO, R_PA, R_PB]);
const SHELL = fs.readFileSync(path.join(ED, 'modules/202611012143-kuiper-shell.js'));
const R_SHELL = Object.assign(rec('kuiper-shell', '202611012143-kuiper-shell.js', SHELL, ['safeBox', 'card', 'hud', 'big', 'sub', 'cv', 'gbox', 'gin', 'redraw']),
  { generation: '202611012143', provides: ['kuiper-shell', 'menuBar'], byte_budget: 65536, team: '01', step: 1 });
const PP = probe('probe-p', ['panels', 'kuiper-shell'], "KY.panels.add('wafer', h, 'wafer'); window.__probeP = { inShellPanel: h.parentElement === KY.modules['kuiper-shell'].api.panel('wafer') }; return { ok: true };");
const R_PP = rec('probe-p', STAMP + '-probe-p.js', PP, ['panels', 'kuiper-shell']);
const files = { [R_SHELL.path]: SHELL, [R_PP.path]: PP, [R_PA.path]: PA, [R_PB.path]: PB, [R_PW.path]: PW };

// ------------------------------------------------------------------------------------------- one run
async function run(browser, dev, name, o) {
  const ctx = await browser.newContext({ ...devices[dev] }), page = await ctx.newPage();
  const errors = [], consoleErr = [];
  page.on('pageerror', e => errors.push(String(e && e.message || e)));
  page.on('console', m => { if (m.type() === 'error') consoleErr.push(m.text()); });
  if (PAGE) await page.route(u => u.href === BASE || u.href === BASE + 'index.html', r => r.fulfill({ status: 200, contentType: 'text/html; charset=utf-8', body: fs.readFileSync(PAGE) }));
  await page.route(BASE + 'modules.json', r => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(o.manifest) }));
  const served = Object.assign({}, files, o.files || {});
  await page.route(u => u.href.startsWith(BASE + 'modules/'), r => { const p = r.request().url().slice(BASE.length);
    if (served[p] === 404) return r.fulfill({ status: 404, body: 'not found' });
    if (served[p]) return r.fulfill({ status: 200, contentType: 'text/javascript', body: served[p] });
    return r.continue(); });
  let waferAt = null;
  if (o.wafer === '404') await page.route(/cosmos\/wafer\.tsv$/, r => r.fulfill({ status: 404, body: 'not found' }));
  if (o.wafer === 'delay') await page.route(/cosmos\/wafer\.tsv$/, async r => { await sleep(o.delay || 12000); waferAt = Date.now(); await r.continue(); });
  const t0 = Date.now();
  await page.goto(BASE, { waitUntil: 'load', timeout: 120000 });
  await page.waitForFunction(() => window.__KUIPER_EDITION__ && window.__KUIPER_EDITION__.done, null, { timeout: 90000 });
  await sleep(o.settle || 7000);
  const st = await page.evaluate(() => {
    const E = window.__KUIPER_EDITION__, nav = performance.getEntriesByType('navigation')[0], rf = document.getElementById('refuse');
    const rr = rf && rf.getBoundingClientRect();
    return { admitted: E.admitted, refused: E.refused, failures: E.failures, whole: E.whole || null, order: E.order, timings: E.timings,
      bytes: E.bytes, byte_budget: E.byte_budget, load_event_ms: Math.round(nav.loadEventStart), dcl_ms: Math.round(nav.domContentLoadedEventStart),
      refuse: rf ? { text: rf.textContent, role: rf.getAttribute('role'), rect: { left: rr.left, top: rr.top, right: rr.right, bottom: rr.bottom },
        visible: getComputedStyle(rf).display !== 'none' && rr.height > 0, inViewport: rr.left >= 0 && rr.top >= 0 && rr.right <= innerWidth && rr.bottom <= innerHeight } : null,
      hud: document.getElementById('hud').textContent, bar: !!document.getElementById('bar'), vw: innerWidth, vh: innerHeight,
      hosts: [...document.querySelectorAll('[id^="ky-"]')].map(e => e.id), scripts: [...document.querySelectorAll('script[data-ky-module]')].map(s => s.dataset.kyModule),
      N: window.KY ? window.KY.hooks.N : null, probeW: window.__probeW || null, probeP: window.__probeP || null,
      frozen: window.KY ? { KY: Object.isFrozen(window.KY), hooks: Object.isFrozen(KY.hooks), names: Object.isFrozen(KY.names), cam: Object.isFrozen(KY.cam),
        lit: Object.isFrozen(KY.lit), sel: Object.isFrozen(KY.sel), draw: Object.isFrozen(KY.draw), panels: Object.isFrozen(KY.panels) } : null,
      hookKeys: window.KY ? Object.keys(KY.hooks) : null, alias: window.KY ? window.__KUIPER_MODULES__ === KY.modules : null,
      writeThrows: (function () { 'use strict'; try { window.KY.hooks.flyTo = null; return false; } catch (e) { return e instanceof TypeError; } })(),
      helloInspect: window.KY && KY.modules.hello ? KY.modules.hello.inspect() : null };
  });
  // the wafer is drawn: non-black pixels of a CSS-px screenshot, outside the bar and the refusal strip
  const shot = await page.screenshot({ scale: 'css', timeout: 180000 });
  st.wafer = await page.evaluate(async ({ b64, skip }) => { const img = new Image(); img.src = 'data:image/png;base64,' + b64; await img.decode();
    const c = document.createElement('canvas'); c.width = img.width; c.height = img.height; const x = c.getContext('2d', { willReadFrequently: true }); x.drawImage(img, 0, 0);
    const d = x.getImageData(0, 0, c.width, c.height).data, bar = document.getElementById('bar').getBoundingClientRect(); let lit = 0, n = 0;
    for (let y = Math.ceil(bar.bottom) + 2; y < c.height; y += 2) for (let X = 0; X < c.width; X += 2) {
      if (skip && X >= skip.left && X <= skip.right && y >= skip.top && y <= skip.bottom) continue;
      const i = (y * c.width + X) * 4; n++; if (d[i] + d[i + 1] + d[i + 2] > 60) lit++; }
    return { lit_fraction: +(lit / n).toFixed(4), sampled: n }; }, { b64: shot.toString('base64'), skip: st.refuse && st.refuse.rect });
  st.waferDrawn = st.wafer.lit_fraction > 0.01;
  if (o.shot) fs.writeFileSync(path.join(OUT, `${o.shot}-${dev.replace(/ /g, '_')}.png`), shot);
  if (o.touch) st.touch = await o.touch(page);
  st.pageerror = errors; st.console_errors = consoleErr; st.wall_ms = Date.now() - t0; st.wafer_delayed_until_ms = waferAt ? waferAt - t0 : null;
  await ctx.close();
  return st;
}
const sameOrder = (st, ids, m) => st.admitted.length === ids.length && st.admitted.every((a, i) => a.id === ids[i] && a.sha256 === m.modules.find(x => x.id === a.id).sha256);
const why = (st, id) => (st.refused.find(r => r.id === id) || {}).why || '';
const net404 = s => s.every(t => /Failed to load resource.*404/.test(t));

(async () => {
  const browser = await chromium.launch({ args: ['--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'] });
  const report = { url: BASE, page: PAGE || 'served index.html', started: new Date().toISOString(), devices: {}, test8: null };
  let allPass = true;
  for (const dev of DEVICES) {
    const T = {}; report.devices[dev] = T;
    const add = (k, pass, data) => { T[k] = Object.assign({ PASS: !!pass }, data); if (!pass) allPass = false; console.log(dev, k, pass ? 'PASS' : 'FAIL'); };
    let s;
    // 1 every order entry admitted in order with the manifest's sha256; readout lines; real touch opens READOUT
    s = await run(browser, dev, 't1', { manifest: THREE, shot: '1-admitted', touch: async page => {
      const b = await page.$('#bar .gm-title[data-panel="hud"]'); const r = await b.boundingBox();
      await page.touchscreen.tap(r.x + r.width / 2, r.y + r.height / 2); await sleep(1500);
      return page.evaluate(() => ({ open: document.getElementById('hud').classList.contains('gm-open'), lines: document.getElementById('hud').textContent.split('\n').filter(l => / admitted · [0-9a-f]{12}$/.test(l)) })); } });
    add('1', sameOrder(s, ['hello', 'probe-a', 'probe-b'], THREE) && !s.refused.length && !s.refuse && s.touch.open && s.touch.lines.length === 3
      && s.helloInspect && s.helloInspect.frames_drawn > 0 && !s.pageerror.length && !s.console_errors.length, s);
    // 2 one byte changed in a served module: sha256 mismatch, the rest admitted, alert inside the viewport, wafer drawn
    const bad = Buffer.from(HELLO); bad[bad.length - 2] ^= 1;
    s = await run(browser, dev, 't2', { manifest: THREE, files: { [R_HELLO.path]: bad }, shot: '2-sha-mismatch' });
    add('2', why(s, 'hello') === 'sha256 mismatch' && s.admitted.map(a => a.id).join() === 'probe-a,probe-b' && s.refuse && s.refuse.role === 'alert'
      && s.refuse.visible && s.refuse.inViewport && s.waferDrawn && s.bar && !s.hosts.includes('ky-hello') && !s.scripts.includes('hello') && !s.pageerror.length && !s.console_errors.length, s);
    // 3 requires noSuchHook: missing hook; host absent; the module that requires its provides refused too
    s = await run(browser, dev, 't3', { manifest: manifest([R_HELLO, Object.assign({}, R_PA, { requires: ['noSuchHook'] }), R_PB]) });
    add('3', why(s, 'probe-a') === 'missing hook noSuchHook' && why(s, 'probe-b') === 'missing hook probe-a' && s.admitted.map(a => a.id).join() === 'hello'
      && !s.hosts.includes('ky-probe-a') && !s.pageerror.length && !s.console_errors.length, s);
    // 4 renamed stamp: refused in words; renamed without leading digits: admitted (identity is generation + sha256)
    s = await run(browser, dev, 't4a', { manifest: manifest([R_HELLO, Object.assign({}, R_PA, { path: 'modules/202611012146-probe-a.js' })]), files: { 'modules/202611012146-probe-a.js': PA } });
    const s4b = await run(browser, dev, 't4b', { manifest: manifest([R_HELLO, Object.assign({}, R_PA, { path: 'modules/probe-a.js' })]), files: { 'modules/probe-a.js': PA } });
    add('4', why(s, 'probe-a') === 'stamp mismatch: generation 202611012145, file name 202611012146' && s.admitted.map(a => a.id).join() === 'hello'
      && s4b.admitted.map(a => a.id).join() === 'hello,probe-a' && !s.pageerror.length && !s4b.pageerror.length && !s.console_errors.length && !s4b.console_errors.length, { renamed: s, no_digits: s4b });
    // 5 install throws: install threw test, the rest admitted
    const thr = Buffer.from(HELLO.toString().replace('install(KY) {', "install(KY) { throw new Error('test');"));
    s = await run(browser, dev, 't5', { manifest: manifest([Object.assign({}, R_HELLO, { sha256: sha(thr), bytes: thr.length }), R_PA, R_PB]), files: { [R_HELLO.path]: thr } });
    add('5', why(s, 'hello') === 'install threw test' && s.admitted.map(a => a.id).join() === 'probe-a,probe-b' && !s.pageerror.length && !s.console_errors.length, s);
    // 6 file deleted: HTTP 404
    s = await run(browser, dev, 't6', { manifest: THREE, files: { [R_HELLO.path]: 404 } });
    add('6', why(s, 'hello') === 'HTTP 404' && s.admitted.map(a => a.id).join() === 'probe-a,probe-b' && !s.pageerror.length && net404(s.console_errors), s);
    // 7 empty manifest: whole wafer and bar, admitted [], no alert, KY frozen, the 28 hooks, the alias
    s = await run(browser, dev, 't7', { manifest: manifest([]), shot: '7-empty', touch: async page => page.evaluate(() => {
      const r = {}; KY.refuse('probe line', 'probe'); r.shown = (document.getElementById('refuse') || {}).textContent === 'probe line';
      KY.refuse('', 'probe'); r.cleared = !document.getElementById('refuse');
      try { KY.refuse('x', 'engine'); r.reserved = false; } catch (e) { r.reserved = e instanceof TypeError; }
      KY.cam.atHome = false; r.atHomeFalse = KY.cam.atHome === false; KY.cam.atHome = true; r.atHomeTrue = KY.cam.atHome === true;
      r.names36 = KY.names.length === 36 && KY.names.includes('refuse') && KY.names.includes('nav'); return r; }) });
    add('7', Object.values(s.touch).every(Boolean) && s.waferDrawn && s.bar && !s.admitted.length && !s.refused.length && !s.refuse && s.frozen && Object.values(s.frozen).every(Boolean) && s.writeThrows
      && JSON.stringify(s.hookKeys) === JSON.stringify(HOOKS28) && s.alias && !s.pageerror.length && !s.console_errors.length, s);
    // 7b wafer.tsv 404: modules that do not require the wafer admitted, the engine's words in the strip, the wafer module's install rejects in words
    s = await run(browser, dev, 't7b', { manifest: manifest([R_HELLO, R_PA, R_PW]), wafer: '404' });
    add('7b', s.admitted.map(a => a.id).join() === 'hello,probe-a,probe-w' && s.refuse && /did not load\. The wafer will not invent its keys\./.test(s.refuse.text)
      && s.probeW && /did not load/.test(s.probeW.rejected || '') && s.failures.some(f => f.id === 'probe-w') && !s.pageerror.length && net404(s.console_errors), s);
    // 7c wafer.tsv held back 12 s: hello is admitted while the 535,037-byte fetch is still pending
    s = await run(browser, dev, 't7c', { manifest: manifest([R_HELLO, R_PW]), wafer: 'delay', delay: 12000, settle: 16000 });
    const hAd = (s.admitted.find(a => a.id === 'hello') || {}).t_ms;
    add('7c', hAd != null && s.probeW && s.probeW.N_at_install === 0 && s.probeW.resolved_ms > hAd + 5000 && s.N > 0 && !s.pageerror.length && !s.console_errors.length,
      Object.assign(s, { hello_admitted_ms: hAd, wafer_resolved_ms: s.probeW && Math.round(s.probeW.resolved_ms) }));
    // 10 (rev 4) KY.panels.add forwards into the shell's panel once kuiper-shell is admitted (01-shell REQUESTS 2)
    s = await run(browser, dev, 't10', { manifest: manifest([R_HELLO, R_SHELL, R_PP]) });
    add('10', s.admitted.map(a => a.id).join() === 'hello,kuiper-shell,probe-p' && s.probeP && s.probeP.inShellPanel && !s.pageerror.length && !s.console_errors.length, s);
    // 11 (rev 5) KY.nav, the one owner of history: another owner's programmatic back never closes the card; a user back
    // closes only the layer whose entry it removed
    s = await run(browser, dev, 't11', { manifest: manifest([R_HELLO]), touch: async page => {
      const w = ms => page.waitForTimeout(ms), card = () => page.evaluate(() => ({ card: document.getElementById('card').style.display, st: history.state, nav: KY.nav.depth }));
      const r = {}; await page.keyboard.press('e'); await w(2500); r.open = await card();
      await page.evaluate(() => { window.__nb = 0; KY.nav.onBack('probe', () => window.__nb++); KY.nav.push('probe'); }); await w(400);
      await page.evaluate(() => KY.nav.back('probe')); await w(1500); r.afterSelfBack = await card();
      await page.evaluate(() => KY.nav.push('probe')); await w(400); await page.evaluate(() => history.back()); await w(1500); r.afterUserBack1 = await card(); r.probeCalls = await page.evaluate(() => window.__nb);
      await page.evaluate(() => history.back()); await w(1500); r.afterUserBack2 = await card();
      r.reserved = await page.evaluate(() => { try { KY.nav.push('edition'); return false; } catch (e) { return e instanceof TypeError; } });
      return r; } });
    { const t = s.touch; add('11', t.open.card === 'block' && t.open.st && t.open.st.owner === 'edition' && t.afterSelfBack.card === 'block' && t.afterSelfBack.st && t.afterSelfBack.st.owner === 'edition'
        && t.afterUserBack1.card === 'block' && t.probeCalls === 1 && t.afterUserBack2.card === 'none' && t.reserved && !s.pageerror.length && !s.console_errors.length, s); }
    // 9 measured, no threshold: load to last admitted; sum of bytes against sum of byte_budget (from test 1's manifest)
    const t1 = T['1'];
    add('9', t1.timings.last_admitted_ms != null, { nav_to_last_admitted_ms: t1.timings.last_admitted_ms, load_event_ms: t1.load_event_ms,
      load_to_last_admitted_ms: t1.timings.last_admitted_ms - t1.load_event_ms, loader_start_ms: t1.timings.loader_start_ms,
      bytes: t1.bytes, byte_budget: t1.byte_budget, modules: t1.admitted.length, note: 'SwiftShader in Playwright, served from 127.0.0.1; negative load_to_last_admitted means the last module was admitted before the load event' });
  }
  // 8 edition_check.py E1-E8 PASS on the integrated copy, FAIL on each mutation applied to a copy
  report.test8 = test8(); if (!report.test8.PASS) allPass = false; console.log('test 8', report.test8.PASS ? 'PASS' : 'FAIL');
  report.PASS = allPass; report.finished = new Date().toISOString();
  fs.writeFileSync(path.join(OUT, 'report.json'), JSON.stringify(report, null, 1));
  await browser.close();
  console.log('RESULT:', allPass ? 'PASS' : 'FAIL'); process.exit(allPass ? 0 : 1);
})().catch(e => { console.error(e); process.exit(2); });

function test8() {
  const tmp = fs.mkdtempSync(path.join(process.env.KY_TMP || os.tmpdir(), 'ky-t8-')), out = {};
  const mk = name => { const d = path.join(tmp, name), e = path.join(d, 'editions', '202611012135');
    fs.mkdirSync(path.join(e, 'modules'), { recursive: true }); fs.mkdirSync(path.join(d, 'tools'));
    fs.copyFileSync(path.join(REPO, 'editions', 'index.html'), path.join(d, 'editions', 'index.html'));
    fs.cpSync(path.join(REPO, 'editions', '202611012027'), path.join(d, 'editions', '202611012027'), { recursive: true });
    for (const f of ['index.html', 'keys.json', 'README.md']) fs.copyFileSync(path.join(ED, f), path.join(e, f));
    if (PAGE) fs.copyFileSync(PAGE, path.join(e, 'index.html'));   // the page under test, not the moving live file
    fs.copyFileSync(path.join(ED, R_HELLO.path), path.join(e, R_HELLO.path)); fs.copyFileSync(path.join(HERE, 'rev5', FIRST.references[0].file), path.join(e, FIRST.references[0].file));
    fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(FIRST, null, 1));
    if (!fs.readFileSync(path.join(e, 'index.html'), 'utf8').includes('KUIPER HOOK TABLE AND LOADER'))
      cp.execFileSync('patch', ['-p1', '-s', '-i', path.join(HERE, 'index.html.patch')], { cwd: d });
    const tool = path.join(REPO, 'tools', 'edition_check.py');
    if (fs.existsSync(tool)) fs.copyFileSync(tool, path.join(d, 'tools', 'edition_check.py'));
    else cp.execFileSync('patch', ['-p1', '-s', '-i', path.join(HERE, 'edition_check.py.patch')], { cwd: d });
    return { d, e }; };
  const proof = e => { const lines = []; const walk = p => { for (const f of fs.readdirSync(p).sort()) { const q = path.join(p, f);
      if (fs.statSync(q).isDirectory()) { if (f !== 'handoff') walk(q); } else if (!q.endsWith('edition-sha256.txt')) lines.push(sha(fs.readFileSync(q)) + '  ./' + path.relative(e, q)); } };
    walk(e); fs.mkdirSync(path.join(e, 'proof'), { recursive: true }); fs.writeFileSync(path.join(e, 'proof', 'edition-sha256.txt'), lines.join('\n') + '\n'); };
  const check = d => { const r = cp.spawnSync('python3', ['tools/edition_check.py', 'editions/202611012135'], { cwd: d, encoding: 'utf8' }); return { rc: r.status, out: r.stdout.trim().split('\n') }; };
  const mut = {
    hash: e => { const p = path.join(e, R_HELLO.path), b = fs.readFileSync(p); b[b.length - 2] ^= 1; fs.writeFileSync(p, b); },
    stamp: e => { fs.renameSync(path.join(e, R_HELLO.path), path.join(e, 'modules/202611012146-hello.js'));
      const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].path = 'modules/202611012146-hello.js'; fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); },
    requires: e => { const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].requires = ['noSuchHook']; fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); },
    stray: e => fs.writeFileSync(path.join(e, 'modules/202611012150-stray.js'), '/* stray */\n'),
    writes: e => { const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].writes.push('#ky-nowhere'); fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); },
    register_twice: e => { const p = path.join(e, R_HELLO.path), t = fs.readFileSync(p, 'utf8') + '// KY.register( again\n'; fs.writeFileSync(p, t);
      const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].sha256 = sha(Buffer.from(t)); m.modules[0].bytes = Buffer.byteLength(t); fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); },
    no_licence: e => { const m = JSON.parse(fs.readFileSync(path.join(e, 'modules.json'))); m.modules[0].licence = ''; fs.writeFileSync(path.join(e, 'modules.json'), JSON.stringify(m)); } };
  const c0 = mk('committed'); proof(c0.e); out.integrated = check(c0.d);
  let pass = out.integrated.rc === 0 && ['E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8'].every(k => out.integrated.out.some(l => l.startsWith(k + ' PASS')));
  out.mutations = {};
  for (const [k, f] of Object.entries(mut)) { const c = mk(k); f(c.e); proof(c.e); const r = check(c.d); out.mutations[k] = r; if (r.rc !== 1) pass = false; }
  out.PASS = pass; fs.rmSync(tmp, { recursive: true, force: true });
  return out;
}

R2

A JavaScript module in the lead folder of Neural Link Between Agents.

interactionneural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/r2/r2.cjs · lines 1–13 of 13 · Not reached from any entry point (candidate for review)

What it does
It loads data. Uses libraries playwright, fs. Side effects: changes the web page (DOM); reads or writes files.
Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'agents'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
In: JSON file modules.json.
What it achieves
It responds to resize events.
Why it matters
No other file in the estate was found to import it.
Application
neural-link-between-agents · FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/r2 · JavaScript module
Uses
playwright, fs
Used by
none found
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
neural-link-between-agents@598eff3f59afe11738d64cb14cb8befe5e37cdc2 FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/r2/r2.cjs:1-13 · blob 22cc686e1094fc9a589bf162f24309a40f1d1261 · GitHub at these lines
State
achieves: name · context: auto · stage: output · effects: dom, filesystem · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
const { chromium, devices } = require('playwright'); const fs = require('fs');
const BASE = 'http://127.0.0.1:8440/editions/202611012135/';
(async () => { const b = await chromium.launch({ args: ['--use-gl=angle','--use-angle=swiftshader','--enable-unsafe-swiftshader','--ignore-gpu-blocklist'] });
  for (const v of ['base', 'touch', 'full']) { const ctx = await b.newContext({ ...devices['Pixel 7'] }), p = await ctx.newPage(); const errs = []; p.on('pageerror', e => errs.push(e.message));
    await p.route(u => u.href === BASE, r => r.fulfill({ status: 200, contentType: 'text/html', body: fs.readFileSync(__dirname + '/' + v + '.html') }));
    await p.route(BASE + 'modules.json', r => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ schema: 'kuiper.modules.v1', edition: '202611012135', hooks: 'kuiper.hooks.v1', order: [], modules: [] }) }));
    await p.goto(BASE); await p.waitForTimeout(7000);
    await p.evaluate(() => { window.__rs = 0; addEventListener('resize', () => window.__rs++); });
    const out = [];
    for (const [w, h] of [[839, 412], [412, 839], [412, 783]]) { await p.setViewportSize({ width: w, height: h }); await p.waitForTimeout(4000);
      out.push(await p.evaluate(() => ({ iw: innerWidth, ih: innerHeight, cw: document.getElementById('c').width, ch: document.getElementById('c').height, vv: visualViewport && [visualViewport.width, visualViewport.height, visualViewport.scale], dw: document.documentElement.clientWidth, rs: window.__rs }))); }
    console.log(v, JSON.stringify(out), errs); await ctx.close(); }
  await b.close(); })();

Block

A JavaScript file in the lead folder of Neural Link Between Agents that works with ky line (`kyLine`) and ky depth (`kyDepth`), using SHA-256.

Set aside from the main view: 95% of its lines are the same as editions/202611012135/handoff/04-loader/rev5/modules/202611020103-loader.js (kuiper-belt), which stays. (near-copy-of, proposed by families.py). 95% of lines shared with Loader; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9503 to kuiper-belt@26fba12ab1b5bab8e71934ab86c58273e5f32682 editions/202611012135/handoff/04-loader/rev5/modules/202611020103-loader.js:1-162 2af3181c8e1d049b6dae33d951df0274957bbbeb
  • sha256 30241a623fcf1d2b5b56d87dee8a4778c2f28faa547c9d7d1cdba56b0536eae0
  • target sha256 db3a00e6615ee47aa2907c9548e70f5d7613da71462b51b250c57fb93d983e22
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

interactionneural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/src/block.js · lines 1–156 of 156 · Not reached from any entry point (candidate for review) · pattern kyNavReconcile (shared by 2 files)

What it does
It draws its content. Defines 13 functions or classes, including kyLine, kyDepth, kyNavReconcile, kyNavPush, kyNavTrim. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'agents'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
In: JSON file modules.json.
What it achieves
It is built from the ky line helper (`kyLine`), the ky depth helper (`kyDepth`) and the ky nav reconcile helper (`kyNavReconcile`). Engine lines this patch changes: the wafer promise (one line after `let N = 0`, and `kyWaferOk`/kyWaferNo at the belt check, after `N = issued` and in the wafer.tsv catch). It reads `modules.json`. It responds to popstate and error events.
Why it matters
No other file in the estate was found to import it.
Application
neural-link-between-agents · FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/src · script
Uses
none found
Used by
none found
Produces
kyLine, kyDepth, kyNavReconcile, kyNavPush, kyNavTrim, kyNavBack, kyNavHas, kyOwner, kyRefuse, kyHex, kyInject, se
Defines here
kyLine, kyDepth, kyNavReconcile, kyNavPush, kyNavTrim, kyNavBack, kyNavHas, kyOwner, kyRefuse, kyHex, kyInject, se, kyAdmit
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
neural-link-between-agents@598eff3f59afe11738d64cb14cb8befe5e37cdc2 FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/src/block.js:1-156 · blob 98c43ef1a724801422f2b262ae6420c389cd63f7 · GitHub at these lines
State
achieves: comment · context: auto · stage: output · effects: dom, network · domain stage: agent_infra · users: ai_agent · canonical: duplicate_candidate
// ======================================== KUIPER HOOK TABLE AND LOADER kuiper.hooks.v1 · begin (Opus team 4, step 4)
// Engine lines this patch changes: the wafer promise (one line after `let N = 0`, and kyWaferOk/kyWaferNo at the belt
// check, after `N = issued` and in the wafer.tsv catch), and the NL-009 round-1 fixes folded in by team 4: 09-robust
// (refuse() for the WebGL, context-lost, belt and wafer.tsv refusals, given slots here) and 04-touch (viewport, tap slop
// and tapUp). Nothing else above is changed. Everything a module
// may reach is in window.KY, built here after every wrap of the edition layer and frozen; the loader admits the
// modules of modules.json in `order`, each only when its bytes hash as recorded and every hook it requires exists,
// and refuses in words while the rest runs. Apache-2.0 (kuiper-belt). The same bytes, between the same two marker
// lines, are modules/202611012145-loader.js (the reviewable reference; it is never fetched). Lessons, cited:
// gridatlas@5ec7f62 atlas/index.html:39-44 (no-store, schema), :65-67 (missing id refused), :78-81 (hash in the
// browser), :82-83 (one blob script per cartridge), :104-114 (one published state); menu-bar.js:37-38 (never twice);
// atlas/modules/202610291043-uk-lightning-overlay.js:393-400 (one frozen API). The anti-lesson: learn-the-kuiper
// modes.html:16-24 skips a missing module silently; this loader says why, on screen.
const KY_EDITION = '202611012135';
const KY_NAMES = Object.freeze(['keyPlace', 'address', 'describe', 'findBy', 'flyTo', 'home', 'homeCamera', 'safeBox',
  'lightTime', 'showNew', 'goKey', 'fmt', 'words', 'esc', 'cv', 'ov', 'o2', 'hud', 'big', 'sub', 'card', 'gbox', 'gin',
  'SPACE', 'N', 'repos', 'commits', 'wafer', 'cam', 'lit', 'sel', 'redraw', 'draw', 'panels', 'refuse', 'nav']);
const kyDraw = [], kyLines = [];
let kyAdmitting = null, kyInstalling = null;
function kyLine(t){ kyLines.push(t); if (!N) hud.textContent += '\n' + t; dirty = true; }
// the one wrap of draw: module painters run after the engine's and the edition's overlay, in ascending order;
// a painter that throws is taken out and named, the frame goes on
{ const _draw = draw; draw = function(){ _draw();
    if (kyLines.length) hud.textContent += '\nMODULES · ' + kyLines.join('\n');
    for (const d of kyDraw.slice()) { try { d.fn(o2, KY); }
      catch (e) { kyDraw.splice(kyDraw.indexOf(d), 1); kyLine(d.id + ' draw threw ' + (e && e.message || e) + ' · painter removed'); } } }; }
// ONE OWNER OF HISTORY (rev 5): every layer that holds a history entry for the Android back gesture pushes it through
// KY.nav (the edition's card and panels as owner 'edition', the shell as 'kuiper-shell'). A back the page starts is
// marked self (event.kuiperSelf) and never read as the user's gesture; a user's back calls the handler of the owner
// whose entry it removed, and nobody else's. An entry is ours when its state carries kuiperDepth; a foreign state is
// left alone (never reconciled), so a module still pushing its own entries degrades to the Edition 4 behaviour.
const kyNav = { stack: [], self: 0, pending: [], handlers: {} };
function kyDepth(){ const s = history.state; return s == null ? 0 : (typeof s.kuiperDepth === 'number' ? s.kuiperDepth : null); }
function kyNavReconcile(){ const d = kyDepth(), lost = []; if (d === null) return lost;
  while (kyNav.stack.length && kyNav.stack[kyNav.stack.length - 1].depth > d) lost.push(kyNav.stack.pop()); return lost; }
function kyNavPush(owner){ if (kyNav.self > 0) { if (!kyNav.pending.includes(owner)) kyNav.pending.push(owner); return true; }
  kyNavReconcile(); const top = kyNav.stack[kyNav.stack.length - 1], depth = Math.max(top ? top.depth : 0, kyDepth() || 0) + 1;
  try { history.pushState({ kuiper: 1, kuiperDepth: depth, owner }, ''); } catch (e) { return false; }
  kyNav.stack.push({ owner, depth, live: true }); return true; }
function kyNavTrim(){ const top = kyNav.stack[kyNav.stack.length - 1];
  if (top && !top.live && kyNav.self === 0 && kyDepth() === top.depth) { kyNav.self++; history.back(); } }
function kyNavBack(owner){ const i = kyNav.pending.indexOf(owner); if (i >= 0) { kyNav.pending.splice(i, 1); return; }
  for (let j = kyNav.stack.length - 1; j >= 0; j--) if (kyNav.stack[j].owner === owner && kyNav.stack[j].live) { kyNav.stack[j].live = false; break; }
  kyNavTrim(); }
function kyNavHas(owner){ kyNavReconcile(); return kyNav.pending.includes(owner) || kyNav.stack.some(x => x.live && x.owner === owner); }
kyNav.handlers.edition = edBack;
addEventListener('popstate', e => { const gone = kyNavReconcile();
  if (kyNav.self > 0) { kyNav.self--; e.kuiperSelf = true;                 // our own back(): close nothing; re-arm what it took by accident
    for (const o of gone.filter(g => g.live).map(g => g.owner).concat(kyNav.pending.splice(0))) kyNavPush(o); }
  else for (const g of gone) if (g.live && kyNav.handlers[g.owner]) { try { kyNav.handlers[g.owner](e); } catch (x) { kyLine(g.owner + ' back handler threw ' + (x && x.message || x)); } }
  kyNavTrim(); });
const kyOwner = o => { if (typeof o !== 'string' || !/^[a-z0-9-]+$/.test(o) || o === 'edition') throw new TypeError('KY.nav: the owner is the module id'); return o; };
const KY_STATE = { schema: 'kuiper.modules.v1', edition: KY_EDITION, hooks: 'kuiper.hooks.v1', order: [], admitted: [],
  refused: [], failures: [], done: false, timings: { loader_start_ms: Math.round(performance.now()) } };
const KY_MODULES = {};
const KY = Object.freeze({
  schema: 'kuiper.hooks.v1', edition: KY_EDITION,
  hooks: Object.freeze({
    keyPlace, address, describe, findBy, flyTo, home, homeCamera, safeBox, lightTime, showNew, goKey, fmt, words, esc,
    cv, ov, o2, hud, big, sub, card, gbox, gin,
    get SPACE(){ return SPACE; }, get N(){ return N; }, get repos(){ return repos; }, get commits(){ return commits; },
    wafer: kyWafer }),
  cam: Object.freeze({ get x(){ return cx; }, get y(){ return cy; }, get zoom(){ return zoom; }, get atHome(){ return atHome; }, set atHome(v){ atHome = !!v; } }),
  lit: Object.freeze({ get repo(){ return litRepo; }, set repo(v){ litRepo = v; dirty = true; },
    get K(){ return litK; }, get Ci(){ return litCi; },
    set period(p){ if (p == null) { litK = [-1, -1]; litCi = null; dirty = true; } else lightTime(+p.y, +p.m || 0, +p.d || 0); } }),
  sel: Object.freeze({ get target(){ return target; }, set target(t){ target = t; dirty = true; } }),
  redraw(){ dirty = true; },
  draw: Object.freeze({ add(fn, order){ if (typeof fn !== 'function') throw new TypeError('KY.draw.add needs a function');
    kyDraw.push({ fn, order: +order || 0, id: kyInstalling || 'module' }); kyDraw.sort((a, b) => a.order - b.order); dirty = true; } }),
  // once the shell (team 1, id kuiper-shell) is admitted the bar and its panels are its own: add() forwards into the
  // shell's panel of that name (handoff/01-shell/REQUESTS.md item 2); a name the shell does not have falls back here
  panels: Object.freeze({ add(name, el, title){ const sh = KY_MODULES['kuiper-shell'], sp = sh && sh.api && typeof sh.api.panel === 'function' ? sh.api.panel(name) : null;
      if (sp) { sp.appendChild(el); KY.redraw(); return el; }
      if (PANELS[name]) throw new Error('panel ' + name + ' exists');
      el.classList.add('gm-panel'); el.setAttribute('role', 'region'); el.setAttribute('aria-label', String(title || name));
      if (!el.isConnected) document.body.appendChild(el); PANELS[name] = el; placePanels(); return el; },
    set: setPanel, place: placePanels }),
  refuse(text, slot){ if (typeof slot !== 'string' || !/^[a-z0-9-]+$/.test(slot) || slot === 'engine' || slot === 'modules')
      throw new TypeError('KY.refuse(text, slot): slot is the module id; engine and modules are the page\'s'); refuse(String(text || ''), slot); },
  nav: Object.freeze({ push(owner){ return kyNavPush(kyOwner(owner)); }, back(owner){ kyNavBack(kyOwner(owner)); },
    onBack(owner, fn){ if (typeof fn !== 'function') throw new TypeError('KY.nav.onBack needs a function'); kyNav.handlers[kyOwner(owner)] = fn; },
    has(owner){ return kyNavHas(kyOwner(owner)); }, isSelf(e){ return !!(e && e.kuiperSelf); }, get depth(){ return kyDepth(); } }),
  names: KY_NAMES,
  register(m){ if (!kyAdmitting) { kyLine('a registration outside admission ignored: ' + (m && m.id)); return false; }
    if (kyAdmitting.reg) { kyAdmitting.twice = true; return false; } kyAdmitting.reg = m; return true; },
  modules: KY_MODULES,
  inspect(){ return JSON.parse(JSON.stringify(KY_STATE)); } });
window.KY = KY; window.__KUIPER_MODULES__ = KY_MODULES; window.__KUIPER_EDITION__ = KY_STATE;
// one strip, role=alert, for refused modules; the engine's own refusals keep their slot in the same strip
function kyRefuse(t){ refuse(t, 'modules'); }
const kyHex = b => [...new Uint8Array(b)].map(x => x.toString(16).padStart(2, '0')).join('');
function kyInject(id, buf){ return new Promise(ok => { const s = document.createElement('script'), u = URL.createObjectURL(new Blob([buf], { type: 'text/javascript' })), st = { loaded: false, error: null };
  const se = e => { if (e.filename === u) { st.error = st.error || String(e.message || 'error').replace(/^Uncaught /, ''); e.preventDefault(); } }, fin = l => { removeEventListener('error', se, true); URL.revokeObjectURL(u); st.loaded = l; ok(st); };
  addEventListener('error', se, true); s.dataset.kyModule = id; s.src = u; s.onload = () => fin(true); s.onerror = () => fin(false); document.head.appendChild(s); }); }   // a module's own script error is its refusal, not the page's error
async function kyAdmit(id, rec, provided){
  if (!rec) return 'in order but not in modules';
  const path = String(rec.path || ''), file = path.split('/').pop();
  if (!/^modules\/[a-z0-9][a-z0-9.-]*\.js$/.test(path) || path.includes('..')) return 'bad path ' + path;
  if (!/^\d{12}$/.test(rec.generation || '')) return 'generation ' + rec.generation + ' is not twelve digits';
  const fd = file.match(/^(\d{12})-/); if (fd && fd[1] !== rec.generation) return 'stamp mismatch: generation ' + rec.generation + ', file name ' + fd[1];
  if (!/^[0-9a-f]{64}$/.test(rec.sha256 || '')) return 'sha256 is not 64 hex';
  if (!String(rec.licence || '').trim()) return 'no licence'; for (const f of ['requires', 'provides']) if (rec[f] != null && !Array.isArray(rec[f])) return f + ' is not a list';
  for (const r of rec.requires || []) if (!provided.has(r)) return 'missing hook ' + r;
  let res; try { res = await fetch(path, { cache: 'no-store' }); } catch (e) { return 'fetch failed ' + (e && e.message || e); }
  if (!res.ok) return 'HTTP ' + res.status;
  const buf = await res.arrayBuffer(), sha = kyHex(await crypto.subtle.digest('SHA-256', buf));
  if (sha !== rec.sha256) return 'sha256 mismatch';
  if (buf.byteLength !== rec.bytes) return 'bytes ' + buf.byteLength + ' ≠ manifest ' + rec.bytes;
  if (rec.byte_budget && buf.byteLength > rec.byte_budget) return 'over byte_budget ' + buf.byteLength + ' > ' + rec.byte_budget;
  const head = new TextDecoder().decode(buf.slice(0, 200)).split('\n')[0].match(/^\/\* kuiper module ([a-z0-9-]+), generation (\d{12}) \(UTC\),/);
  if (!head) return 'no header line'; if (head[1] !== id) return 'header names ' + head[1] + ' ≠ ' + id;
  if (head[2] !== rec.generation) return 'stamp mismatch: generation ' + rec.generation + ', header ' + head[2];
  kyAdmitting = { id }; let reg, twice;
  let inj; try { inj = await kyInject(id, buf); } finally { reg = kyAdmitting.reg; twice = kyAdmitting.twice; kyAdmitting = null; } if (!inj.loaded) return 'script did not load'; if (inj.error) return 'script error: ' + inj.error;
  if (!reg) return 'no registration';
  if (twice) return 'registered twice';
  if (reg.schema !== 'kuiper.module.v1') return 'schema ' + reg.schema;
  if (reg.id !== id) return 'id ' + reg.id + ' ≠ ' + id; for (const f of ['requires', 'provides']) if (reg[f] != null && !Array.isArray(reg[f])) return 'registration ' + f + ' is not a list';
  if (reg.generation !== rec.generation) return 'stamp mismatch: generation ' + rec.generation + ', registration ' + reg.generation;
  for (const r of reg.requires || []) { if (!(rec.requires || []).includes(r)) return 'requires ' + r + ' not in the manifest'; if (!provided.has(r)) return 'missing hook ' + r; }
  if (typeof reg.install !== 'function') return 'no install';
  let api; kyInstalling = id;
  try { api = reg.install(KY); } catch (e) { return 'install threw ' + (e && e.message || e); } finally { kyInstalling = null; }
  const ready = Promise.resolve(api);
  ready.catch(e => { KY_STATE.failures.push({ id, why: 'install rejected ' + (e && e.message || e) }); kyLine(id + ' install rejected: ' + (e && e.message || e)); });
  Object.defineProperty(KY_MODULES, id, { enumerable: true, value: Object.freeze({ id, generation: rec.generation, sha256: sha,
    api: (api && typeof api.then === 'function') ? undefined : api, ready, inspect: typeof reg.inspect === 'function' ? reg.inspect : () => ({}) }) });
  for (const p of [id, ...(reg.provides || []), ...(rec.provides || [])]) provided.add(p);
  return null;
}
(async function kyLoad(){
  let m;
  try { const r = await fetch('modules.json', { cache: 'no-store' }); if (!r.ok) throw new Error('modules.json HTTP ' + r.status); m = await r.json(); if (!m || typeof m !== 'object') throw new Error('modules.json is not an object'); }
  catch (e) { m = { error: e && e.message || String(e) }; }
  const shape = m.error ? m.error : m.schema !== 'kuiper.modules.v1' ? 'schema ' + m.schema : m.hooks !== 'kuiper.hooks.v1' ? 'hooks ' + m.hooks
    : m.edition !== KY_EDITION ? 'edition ' + m.edition + ' ≠ page ' + KY_EDITION : !Array.isArray(m.order) || !Array.isArray(m.modules) ? 'order and modules must be lists'
    : !crypto.subtle ? 'no crypto.subtle (not a secure context)' : null;
  if (shape) { KY_STATE.whole = shape; KY_STATE.done = true; kyRefuse('MODULES NOT ADMITTED: ' + shape + ' · the wafer is unchanged'); kyLine('modules not admitted: ' + shape); return; }
  KY_STATE.order = m.order.slice();
  const provided = new Set(KY_NAMES), seen = new Set();
  for (const id of m.order) {
    let why; try { why = seen.has(id) ? 'in order twice' : await kyAdmit(id, m.modules.find(x => x && x.id === id), provided); } catch (e) { kyAdmitting = kyInstalling = null; why = 'loader error ' + (e && e.message || e); }
    const t = Math.round(performance.now()); seen.add(id);
    if (why) { KY_STATE.refused.push({ id, why, t_ms: t }); kyLine(id + ' refused: ' + why); }
    else { KY_STATE.admitted.push({ id, sha256: KY_MODULES[id].sha256, t_ms: t }); kyLine(id + ' admitted · ' + KY_MODULES[id].sha256.slice(0, 12)); }
  }
  KY_STATE.timings.last_admitted_ms = KY_STATE.admitted.length ? KY_STATE.admitted[KY_STATE.admitted.length - 1].t_ms : null;
  KY_STATE.timings.loader_end_ms = Math.round(performance.now());
  KY_STATE.bytes = m.modules.filter(x => x && KY_MODULES[x.id]).reduce((a, x) => a + (x.bytes || 0), 0);
  KY_STATE.byte_budget = m.modules.filter(x => x && KY_MODULES[x.id]).reduce((a, x) => a + (x.byte_budget || 0), 0);
  KY_STATE.done = true; for (const k of ['order', 'admitted', 'refused', 'timings']) Object.freeze(KY_STATE[k]);   // KY.modules stays open: the shell publishes .menuBar there (01-shell REQUESTS 2)
  if (KY_STATE.refused.length) kyRefuse(KY_STATE.refused.length + ' module' + (KY_STATE.refused.length > 1 ? 's' : '') + ' refused: '
    + KY_STATE.refused.map(x => x.id + ' (' + x.why + ')').join('; ') + ' · the wafer, the bar and every admitted module keep working');
})();
// ======================================== KUIPER HOOK TABLE AND LOADER kuiper.hooks.v1 · end

Mk

A shell script in the lead folder of Neural Link Between Agents that uses SHA-256.

automationneural-link-between-agents / FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/src/mk.sh · lines 1–15 of 15 · Entry point

What it does
Side effects: starts processes.
Why it exists in the grid workflow
Domain stage agent_infra (repository name word 'agents'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Downstream impact
It is itself an entry point (shell script); no other file was found loading it.
What it achieves
No statement of purpose was found in the file, a README line naming it, or its name.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
neural-link-between-agents · FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/src · shell script
Uses
none found
Used by
none found
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
neural-link-between-agents@598eff3f59afe11738d64cb14cb8befe5e37cdc2 FIXES/NL-010/tools/evidence/nl010-opus/team-4/lead/src/mk.sh:1-15 · blob cdce613931456a8c34032932c3feefa9aff1d442 · GitHub at these lines
State
achieves: name · context: auto · stage: unknown · effects: process · domain stage: agent_infra · users: ai_agent · canonical: unknown
#!/bin/bash
# rebuild: patched page, loader reference, the patch, MODULE.sha256
set -e
L=/tmp/nl010-opus/team-4/lead; E=/home/user/estate/kuiper-belt/editions/202611012135; H=$E/handoff/04-loader
python3 $L/src/build.py $L/work/patched.html
awk '/<script type="module">/{f=1;next} /<\/script>/{f=0} f' $L/work/patched.html > $L/work/page.mjs; node --check $L/work/page.mjs
{ head -6 $E/modules/202611012145-loader.js; cat $L/src/block.js; } > $L/work/loader.js && mv $L/work/loader.js $E/modules/202611012145-loader.js
node --check $E/modules/202611012145-loader.js 2>/dev/null || true
cd /home/user/estate/kuiper-belt
cp $L/work/patched.html $L/work/b.html
diff -u --label a/editions/202611012135/index.html --label b/editions/202611012135/index.html editions/202611012135/index.html $L/work/patched.html > $H/index.html.patch || true
git apply --check $H/index.html.patch && echo PATCH_APPLIES
(cd $E && sha256sum modules/202611012145-hello.js modules/202611012145-loader.js) > $H/MODULE.sha256
sha256sum $H/index.html.patch | sed "s#$H/##" >> $H/MODULE.sha256
cat $H/MODULE.sha256