In this section
- Releases — Kuiper Shell Page render · globalgrid2050 / kuiper-grid/i0073/releases/003100000000-kuiper-shell/index.html lines 593–826
- Kuiper Card render · globalgrid2050 / kuiper-grid/i0073/releases/003100000000-kuiper-shell/kuiper-card.js lines 1–210
- Kuiper Chrome interaction · globalgrid2050 / kuiper-grid/i0073/releases/003100000000-kuiper-shell/kuiper-chrome.js lines 1–35
- Kuiper Programs interaction · globalgrid2050 / kuiper-grid/i0073/releases/003100000000-kuiper-shell/kuiper-programs.js lines 1–212
Releases — Kuiper Shell Page
A web page in the kuiper grid folder of GlobalGrid2050 that draws programs. Published at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/. It builds link (`buildLink`) and parses link (`parseLink`).
Set aside from the main view: 99% of its lines are the same as kuiper-grid/drawing/renderer.html (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with Renderer; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9885 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/drawing/renderer.html:1-829 e8e2d6ef52f7b28f3ff4e46202e23baed4214907
- sha256 5b59979c093d0713d05e6ab3d2c36395e5edcefaa7e5a0336c9fdb3b7f6e1e30
- target sha256 5ba9e9f8c920be44cd0fca55f14b0ae31b13530e90b44f8c198a7e38446beee5
- group of 3 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
renderglobalgrid2050 / kuiper-grid/i0073/releases/003100000000-kuiper-shell/index.html · lines 593–826 of 826 (continued from section 1326) · Entry point · pattern frameOnce (shared by 6 files)
- What it does
- It draws programs. Defines 34 functions or classes, including buildLink, complaints, parseLink, fmt, day. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage agent_infra (path word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file programs.json; form fields (user input). Out: web page; WebGL/WebGPU drawing.
- Downstream impact
- Used directly by 1 file: Phone (globalgrid2050, https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/phone.html). It is itself an entry point, published at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/.
- What it achieves
- Its `describe` function gives human readable address description from resolved address and repository metadata (VEDIC: explain). It reads `cosmos/programs.json`. It responds to error, webglcontextlost and resize events.
- Why it matters
- Loaded by the Phone page at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/phone.html.
- Application
- globalgrid2050 · kuiper-grid/i0073/releases/003100000000-kuiper-shell · page
- VEDIC
- EXPLAIN (GG2050-VEDIC-000040): Kuiper / Code navigation · Computer science / Interactive visualisation. resolved_address, repository_metadata → human_readable_address_description
- Uses
- Kuiper Card (script src), Kuiper Programs (script src), Kuiper Tests (script src), Kuiper Controls (script src), Kuiper Chrome (script src)
- Used by
- embedded by Phone (iframe)
- Produces
- buildLink, complaints, parseLink, fmt, day, words, prog, U, tsv, boot, appFor, narrow
- Defines here
- issuedBelow, ownerAt, widestRunPx, span, linesByRunningTotals, keyAt, frameOnce, frame, stepFrame, draw, read, edge
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/i0073/releases/003100000000-kuiper-shell/index.html:593-826 · blob 3df8aa20a62f9f3083911a1debe6620f57e1b92a · GitHub at these lines
- State
- achieves: code · context: readme_derived · stage: output · effects: dom, network · domain stage: agent_infra · users: ai_agent · canonical: production_core
// commit that owns k, plus however far into that commit k lies. The fragment shader computes this
// exact expression for every pixel to decide its shade, so if these two ever disagree the picture
// is wrong, and proof 7 is the check that they do not.
function issuedBelow(k){ const c = commits[findBy('k0', k)]; return c.cum + Math.min(Math.max(k - c.k0, 0), c.k1 - c.k0); }
// which repository owns the key at radius r: -1 is silence, -2 is off the wafer
function ownerAt(r){ const kc = r*r; if (!(kc < SPACE)) return -2; const c = commits[findBy('k0', kc)];
return (kc >= c.k0 && kc <= c.k1) ? c.repo : -1; }
// a repository's lines counted through the running totals alone, never by adding its commits up
// HOW WIDE A REPOSITORY IS ON THE SCREEN. A key at radius r sits in a ring of 2 r dr addresses,
// so one pixel holds 2 r / zoom addresses and a commit of L lines is L zoom / 2 r pixels wide.
// Under one pixel, not one pixel centre can fall inside it and the light is invisible. That is a
// fact about the wafer, not a fault in the drawing, and the page says it rather than hiding it.
function widestRunPx(ri, z){
const span = (k0, k1) => (k1 - k0) * z / (2 * Math.sqrt((k0 + k1)/2));
let w = 0, a = -1, b = -1;
for (const c of commits) {
if (c.repo === ri && a >= 0 && c.k0 === b) { b = c.k1; } // no silence between them: one unbroken run
else if (c.repo === ri) { if (a >= 0) w = Math.max(w, span(a, b)); a = c.k0; b = c.k1; }
else if (a >= 0) { w = Math.max(w, span(a, b)); a = -1; }
}
return a >= 0 ? Math.max(w, span(a, b)) : w; }
function linesByRunningTotals(ri){ let t = 0; for (const c of commits) if (c.repo === ri) t += issuedBelow(c.k1) - issuedBelow(c.k0); return t; }
function keyAt(wx, wy){ const r = Math.hypot(wx, wy), kc = Math.round(r*r), span = Math.ceil(6*r + 8); let best = -1, bd = 0.6;
for (let k = Math.max(0, kc - span); k <= Math.min(SPACE-1, kc + span); k++) { const p = keyPlace(k), d = Math.hypot(p[0]-wx, p[1]-wy); if (d < bd) { bd = d; best = k; } }
return best; }
// --------------------------------------------------------------------------------- the frame
const POINTS_FROM = 1.0, MAX_CALLS = 3000;
function frameOnce(){ stepFrame(); }
function frame(){
if (lost) return;
stepFrame();
requestAnimationFrame(frame);
}
function stepFrame(){
if (lost) return;
if (tween) { const u = Math.min(1, (performance.now()-tween.t0)/tween.dur), e = u<0.5 ? 2*u*u : 1-Math.pow(-2*u+2,2)/2;
zoom = Math.exp(Math.log(tween.z0) + (Math.log(tween.z1)-Math.log(tween.z0))*e);
cx = tween.x0 + (tween.x1-tween.x0)*e; cy = tween.y0 + (tween.y1-tween.y0)*e; dirty = true; if (u >= 1) tween = null; }
if (anim) stepAnim();
if (isoAnim) { const u = Math.min(1, (performance.now() - isoAnim.t0) / isoAnim.ms); pulse = isoAnim.R * (u*u*(3-2*u));
if (iso) iso.front = pulse; dirty = true;
if (u >= 1) { isoAnim = null; pulse = -1; if (iso) { iso.front = 1e30;
// THE DARK HAS FALLEN. Now the lit work flies together, by the estate's own rule, and only
// when it has arrived does the tile rise.
// EIGHT SECONDS IS LONG FOR SOMEBODY WHO CAME TO PRESS OPEN. The tile rises as soon as the dark
// has fallen, and the work gathers behind it.
raiseTile(); if (body) bodyMove(0); } } }
if (bodyAnim && body && ASM) { const A = bodyAnim, stt = body.states[A.k];
if (A.phase === 'move') { const t = (performance.now() - A.t0) / ASM.MOVE_MS, e = ASM.ease(t);
ASM.step(A.from, A.home ? body.from : stt.to, t, body.pos); bodyTo(body.pos);
body.gap = A.home ? A.gap0 : A.gap0 + (stt.gap - A.gap0) * e; dirty = true;
if (t >= 1) { if (A.home) { bodyAnim = null; body = null; unisolate(true); home(); }
else { body.k = A.k; body.gap = stt.gap; A.phase = 'hold'; A.t0 = performance.now(); } } }
else if (performance.now() - A.t0 >= (stt.hold || 0)) {
if (A.k + 1 < body.states.length) bodyMove(A.k + 1); else { bodyAnim = null; dirty = true; } }
else dirty = true; }
if (homeAnim && iso && ASM) { const t = (performance.now() - homeAnim.t0) / ASM.MOVE_MS;
ASM.step(homeAnim.from, iso.from, t, iso.pos); sparksTo(iso.pos); iso.g = 1 - ASM.ease(t); dirty = true;
if (t >= 1) { homeAnim = null; unisolate(true); home(); } }
if (gatherAnim && iso && iso.to && ASM) { const t = (performance.now() - gatherAnim.t0) / ASM.MOVE_MS;
ASM.step(iso.from, iso.to, t, iso.pos); sparksTo(iso.pos); iso.g = ASM.ease(t); dirty = true;
if (t >= 1) { gatherAnim = null; iso.g = 1; raiseTile(); } }
if (dirty && N) { draw(); dirty = false; }
}
// WHAT THE WAFER'S OWN CARD BINDS TO: told after every draw, and able to ask where the camera is.
window.__wafer = window.__wafer || { onDraw:new Set(), get view(){ return { x:cx, y:cy, zoom:zoom }; } };
let drawCount = 0;
function draw(){
drawCount++;
queueMicrotask(() => { for (const f of window.__wafer.onDraw) { try { f(); } catch (e) {} } });
const R = Math.sqrt(SPACE), W = cv.width, H = cv.height;
const x0 = cx - W/2/zoom, x1 = cx + W/2/zoom, y0 = cy - H/2/zoom, y1 = cy + H/2/zoom;
const dx = x0 > 0 ? x0 : (x1 < 0 ? -x1 : 0), dy = y0 > 0 ? y0 : (y1 < 0 ? -y1 : 0);
const rmin = Math.hypot(dx, dy), rmax = Math.max(Math.hypot(x0,y0), Math.hypot(x1,y0), Math.hypot(x0,y1), Math.hypot(x1,y1));
const ka = Math.min(SPACE, Math.floor(rmin*rmin)), kb = Math.min(SPACE, Math.ceil(rmax*rmax));
// the screen's radii are a contiguous run of addresses; the issued ones among them are whole commits and two part commits
let i0 = findBy('k0', ka), segs = [], total = 0;
if (zoom >= POINTS_FROM) for (let i = i0; i < commits.length && commits[i].k0 < kb && segs.length <= MAX_CALLS; i++) {
const s0 = Math.max(commits[i].k0, ka), s1 = Math.min(commits[i].k1, kb); if (s1 > s0 && (!iso || iso.set.has(i))) { segs.push([s0, s1, commits[i].repo, i]); total += s1 - s0; } }
const points = zoom >= POINTS_FROM && segs.length <= MAX_CALLS && total < 1.6e9;
gl.useProgram(PF);
gl.uniform2f(U(PF,'u_res'), W, H); gl.uniform2f(U(PF,'u_center'), cx, cy); gl.uniform1f(U(PF,'u_zoom'), zoom);
gl.uniform1f(U(PF,'u_R'), R); gl.uniform1f(U(PF,'u_points'), points ? 1 : 0);
gl.uniform2f(U(PF,'u_litK'), litK[0], litK[1]);
gl.uniform1f(U(PF,'u_pulse'), pulse); gl.uniform1f(U(PF,'u_flash'), flash);
gl.uniform1f(U(PF,'u_newR'), newFrom >= 0 ? Math.sqrt(commits[newFrom].k0) : 1e30);
gl.uniform1i(U(PF,'u_commits'), 0); gl.uniform1i(U(PF,'u_n'), commits.length); gl.uniform1i(U(PF,'u_litRepo'), litRepo);
gl.uniform1i(U(PF,'u_pathf'), 1); gl.uniform1i(U(PF,'u_litPath'), litPath ? 1 : 0); gl.uniform1i(U(PF,'u_iso'), iso ? 1 : 0);
if (iso) { gl.uniform1f(U(PF,'u_front'), iso.front); gl.uniform1f(U(PF,'u_dim'), iso.prog.off.dim);
gl.uniform3f(U(PF,'u_on'), iso.prog.on.colour[0], iso.prog.on.colour[1], iso.prog.on.colour[2]); }
gl.drawArrays(gl.TRIANGLES, 0, 3);
if (selftest && selftest.wantPixels && flash > 0.5 && !points) {
const px = new Uint8Array(4), R0 = Math.sqrt(commits[newFrom].k0), rm = (R0 + R) / 2;
const read = (wx) => { gl.readPixels(Math.round(W/2 + (wx - cx)*zoom), Math.round(H/2 + (0 - cy)*zoom), 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, px); return [px[0], px[1], px[2]]; };
selftest.newBandPixel = read(rm); selftest.pupilPixel = read(0); selftest.wantPixels = false; }
let ms = 0;
if (points) { const t0 = performance.now(); gl.useProgram(PK);
gl.uniform1f(U(PK,'u_zoom'), zoom); gl.uniform2f(U(PK,'u_center'), cx, cy); gl.uniform2f(U(PK,'u_res'), W, H);
for (const [s0, s1, rp, ci] of segs) { gl.uniform1f(U(PK,'u_hot'), (newFrom >= 0 && ci >= newFrom) ? 2 : ((rp === litRepo || (litCi && ci >= litCi[0] && ci < litCi[1])) ? 1 : 0));
for (let off = s0; off < s1; off += 4000000) { // bounded calls; the driver watchdog is real
gl.uniform1ui(U(PK,'u_k0lo'), (off % 4294967296) >>> 0); gl.uniform1f(U(PK,'u_R0'), Math.sqrt(off));
gl.drawArrays(gl.POINTS, 0, Math.min(4000000, s1 - off)); } }
gl.finish(); ms = performance.now() - t0; }
if (iso && body && body.shown && BP) {
gl.useProgram(BP); gl.disable(gl.BLEND);
gl.bindBuffer(gl.ARRAY_BUFFER, bodyBuf); const at = gl.getAttribLocation(BP, 'a_pos');
gl.enableVertexAttribArray(at); gl.vertexAttribPointer(at, 2, gl.FLOAT, false, 0, 0);
gl.uniform2f(U(BP,'u_res'), W, H); gl.uniform2f(U(BP,'u_center'), cx, cy); gl.uniform1f(U(BP,'u_zoom'), zoom);
gl.uniform1f(U(BP,'u_size'), bodyDrawnDiameter());
gl.uniform3f(U(BP,'u_on'), iso.prog.on.colour[0], iso.prog.on.colour[1], iso.prog.on.colour[2]);
gl.drawArrays(gl.POINTS, 0, body.n);
gl.disableVertexAttribArray(at); gl.bindBuffer(gl.ARRAY_BUFFER, null); }
if (iso && glowCount && !glowOff && PG && (iso.prog.on.size || 0) > 0 && !(body && body.shown)) {
// ADDITIVE, so sparks that fall together burn brighter, which is what a lot of work in one place
// should look like. The state is put back exactly as it was found.
gl.useProgram(PG); gl.enable(gl.BLEND); gl.blendFunc(gl.ONE, gl.ONE);
gl.bindBuffer(gl.ARRAY_BUFFER, glowBuf); const at = gl.getAttribLocation(PG, 'a_pos');
gl.enableVertexAttribArray(at); gl.vertexAttribPointer(at, 2, gl.FLOAT, false, 0, 0);
gl.uniform2f(U(PG,'u_res'), W, H); gl.uniform2f(U(PG,'u_center'), cx, cy); gl.uniform1f(U(PG,'u_zoom'), zoom);
gl.uniform1f(U(PG,'u_size'), iso.prog.on.size * (window.devicePixelRatio || 1)); gl.uniform1f(U(PG,'u_front'), iso.front);
gl.uniform3f(U(PG,'u_on'), iso.prog.on.colour[0], iso.prog.on.colour[1], iso.prog.on.colour[2]);
// A DENSE BODY MUST NOT BURN OUT TO WHITE. Light adds, so thousands of sparks packed into a small
// body on a phone summed to a featureless blob. Each spark is turned down by how crowded the body
// is, in step with how far the gathering has gone, so the body keeps its colour and its grain.
{ const sz = iso.prog.on.size * (window.devicePixelRatio || 1), Rp = Math.sqrt(SPACE) * zoom * GATHER_RADIUS;
const crowd = Math.max(1, glowCount * sz * sz * 0.10 / Math.max(1, Math.PI * Rp * Rp));
const g = iso.to ? (iso.g === undefined ? 1 : iso.g) : 0;
gl.uniform1f(U(PG,'u_bright'), (iso.prog.on.bright || 1) / (1 + g * (crowd - 1))); }
gl.drawArrays(gl.POINTS, 0, glowCount);
gl.disableVertexAttribArray(at); gl.bindBuffer(gl.ARRAY_BUFFER, null); gl.disable(gl.BLEND); }
const L = [], D = [];
D.push(points ? 'RESOLVED · every issued key whose radius is in the field, drawn at its own place'
: 'UNRESOLVED · up to ' + words(1/(Math.PI*zoom*zoom)) + ' keys to a pixel · each pixel’s issued count is computed from the law, not drawn');
if (points) D.push(fmt(total) + ' issued keys from ' + fmt(segs.length) + ' commits passed to the GPU in ' + ms.toFixed(0) + ' ms');
D.push('the whole · ' + fmt(N) + ' issued + ' + fmt(SPACE - N) + ' silent = ' + fmt(SPACE) + ' addresses');
if (iso) L.push('ISOLATED \u00b7 ' + iso.app.button + ' \u00b7 ' + fmt(iso.lit) + ' pieces of work lit \u00b7 '
+ fmt(iso.dark) + ' dark \u00b7 ' + day(iso.first) + ' to ' + day(iso.last));
if (litRepo >= 0) { const rt = linesByRunningTotals(litRepo), rr = repos[litRepo];
// the number on screen is the one the shading is made of, not the one the belt declared; if
// they differ the HUD says so rather than picking the prettier of the two
// WHAT IS HIGHLIGHTED, IN WORDS A READER CAME WITH. Whether two running totals agree is how
// this page knows it is not lying, which matters, and belongs where the rest of the working
// is: behind d. What stays on the face is the disagreement itself, if there ever is one,
// because a reader must never be shown a number the page has reason to doubt.
L.push('HIGHLIGHTED · ' + rr.name + ' · ' + fmt(rr.commits) + ' pieces of work · '
+ day(rr.t0) + ' to ' + day(rr.t1));
D.push('running totals ' + (rt === rr.lines ? 'agree with the belt' : 'DISAGREE with the belt'));
if (rt !== rr.lines) L.push('THIS COUNT IS IN DOUBT · two measurements of it disagree, so it is not shown');
const wpx = widestRunPx(litRepo, zoom);
// Said exactly, because 269 pixels of a repository whose widest run is a tenth of a pixel are
// lit: the runs are so close together that pixel centres keep landing inside them. The claim
// is about the run, not about the light.
if (wpx < 1) L.push('TOO SMALL TO SEE AT THIS ZOOM · what is lit is only where this work happens to fall · zoom in to see it whole'); }
D.push(zoom >= 1 ? 'zoom ' + zoom.toFixed(1) + ' px per key spacing' : 'zoom 1 px = ' + words(1/zoom) + ' units');
hud.textContent = (detail ? L.concat(D) : L).join('\n');
// A PANEL DRAWN FOR WORDS THAT ARE NOT THERE. With nothing highlighted the readout is empty, and
// an empty bordered box sat in the corner at 1366 looking like something that had failed to load.
hud.style.display = hud.textContent.trim() ? '' : 'none';
o2.clearRect(0,0,ov.width,ov.height);
{ const x0 = (0 - cx)*zoom + ov.width/2, y0 = ov.height/2 + cy*zoom, M = ['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'];
const a = new Date(commits[0].unix*1000), b = new Date(commits[commits.length-1].unix*1000); let lastPx = -99;
o2.font = '10px ui-monospace,Consolas,monospace'; o2.lineWidth = 1;
for (let y = a.getUTCFullYear(), m = a.getUTCMonth() + 1; y < b.getUTCFullYear() || (y === b.getUTCFullYear() && m <= b.getUTCMonth()); m++) {
if (m > 11) { m = 0; y++; }
const t = Date.UTC(y, m, 1)/1000, i = Math.min(commits.length-1, findBy('unix', t - 1) + 1), rp = Math.sqrt(commits[i].k0)*zoom;
if (rp - lastPx < 26 || rp > 6000) continue; lastPx = rp;
o2.strokeStyle = 'rgba(46,230,230,.30)'; o2.beginPath(); o2.arc(x0, y0, rp, 0, 6.2832); o2.stroke();
o2.fillStyle = 'rgba(46,230,230,.85)'; o2.fillText(M[m] + ' ' + String(y).slice(2), x0 + rp*0.5 + 4, y0 - rp*0.866 - 3); } }
if (target && target.boundary && zoom >= POINTS_FROM) {
// at this zoom the boundary circle is straight across the screen: perpendicular to the radius
const x = (target.x - cx)*zoom + ov.width/2, y = ov.height/2 - (target.y - cy)*zoom, rr = Math.hypot(target.x, target.y) || 1;
const tx = -target.y/rr, ty = target.x/rr, Lp = Math.hypot(ov.width, ov.height);
o2.strokeStyle = 'rgba(255,199,107,.95)'; o2.lineWidth = 2; o2.setLineDash([10,6]); o2.beginPath();
o2.moveTo(x - tx*Lp, y + ty*Lp); o2.lineTo(x + tx*Lp, y - ty*Lp); o2.stroke(); o2.setLineDash([]);
o2.font = '12px ui-monospace,Consolas,monospace'; o2.fillStyle = 'rgba(255,199,107,1)';
// outward is newer, and which way outward points on screen depends on where this key sits, so
// the words are placed along the real radius rather than assumed to read left to right
const ox = target.x/rr, oy = -target.y/rr;
o2.textAlign = 'center';
o2.fillText('NEW CODE', x + ox*110, y + oy*110); o2.fillStyle = 'rgba(213,220,234,.85)';
o2.fillText('older', x - ox*110, y - oy*110); o2.fillStyle = 'rgba(255,199,107,1)';
o2.fillText('the boundary', x + tx*150, y - ty*150 - 8); o2.textAlign = 'start'; }
if (arrow) {
const p = keyPlace(arrow.k);
const fx = (0 - cx)*zoom + ov.width/2, fy = ov.height/2 + cy*zoom; // the middle: where the record begins
const bx = (p[0] - cx)*zoom + ov.width/2, by = ov.height/2 - (p[1] - cy)*zoom;
// WHEN THE BEGINNING IS OFF THE SCREEN, AND AFTER THE CAMERA FLIES IT ALWAYS IS, the arrow keeps
// the true line and starts where that line crosses the edge of the window. Direction is the whole
// of what it says; a stub of a line thousands of screen widths long says nothing at all.
let ax = fx, ay = fy;
{ const W = ov.width, H = ov.height, dx = fx - bx, dy = fy - by;
const far = fx < 0 || fy < 0 || fx > W || fy > H;
if (far && (dx || dy)) {
let t = Infinity;
const edge = (num, den) => { if (den === 0) return; const u = num / den;
if (u > 0 && u < t) { const x = bx + dx*u, y = by + dy*u;
if (x >= -1 && x <= W + 1 && y >= -1 && y <= H + 1) t = u; } };
edge(-bx, dx); edge(W - bx, dx); edge(-by, dy); edge(H - by, dy);
if (t !== Infinity) { ax = bx + dx*t*0.98; ay = by + dy*t*0.98; }
} }
const u = Math.min(1, (performance.now() - arrow.t0) / ARROW_MS), e = 1 - Math.pow(1 - u, 3);
const tx = ax + (bx - ax)*e, ty = ay + (by - ay)*e, th = Math.atan2(by - ay, bx - ax);
o2.strokeStyle = 'rgba(255,43,214,.95)'; o2.lineWidth = 2; o2.beginPath();
o2.moveTo(ax, ay); o2.lineTo(tx, ty);
for (const d of [-0.36, 0.36]) { o2.moveTo(tx, ty); o2.lineTo(tx - 13*Math.cos(th + d), ty - 13*Math.sin(th + d)); }
o2.stroke();
// WHERE THE POINT REALLY IS, not where it was aimed. The page can be asked afterwards, and an
// arrow that lands NEAR the answer is worse than no arrow at all, because it is believed.
arrowTip = { x:tx, y:ty, x0:ax, y0:ay, fromX:fx, fromY:fy, done:u >= 1 };
if (u >= 1 && !arrow.held) arrow.held = performance.now();
if (arrow.held && performance.now() - arrow.held > ARROW_HOLD) arrow = null; // it has said its piece
dirty = true;
}
if (target) { const x = (target.x - cx)*zoom + ov.width/2, y = ov.height/2 - (target.y - cy)*zoom;
o2.strokeStyle = 'rgba(255,43,214,.98)'; o2.lineWidth = 1.5; o2.beginPath();
for (const [a,b,c,d] of [[-16,0,-6,0],[6,0,16,0],[0,-16,0,-6],[0,6,0,16]]) { o2.moveTo(x+a,y+b); o2.lineTo(x+c,y+d); } o2.stroke(); }
}
</script>
<script src="kuiper-card.js"></script>
<script src="kuiper-programs.js"></script>
<script src="kuiper-tests.js"></script>
<script src="kuiper-controls.js"></script>
<script src="kuiper-chrome.js"></script>
<script>
'use strict';
// every part has arrived: load the record and start drawing
boot(); requestAnimationFrame(frame);
</script>
</body>
</html>Kuiper Card
A JavaScript file in the kuiper grid folder of GlobalGrid2050 that converts to world (`toWorld`) and steps anim (`stepAnim`). Served with the page at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/.
renderglobalgrid2050 / kuiper-grid/i0073/releases/003100000000-kuiper-shell/kuiper-card.js · lines 1–210 of 210 · Entry point · pattern linkTo (shared by 14 files)
- What it does
- It draws its content. Defines 14 functions or classes, including toWorld, cardFor, esc, gh, ghLink. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage agent_infra (path word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Downstream impact
- Used directly by 1 file: Releases — Kuiper Shell Page (globalgrid2050, https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/). Reached from 1 other entry point, including Phone (globalgrid2050, https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/phone.html). It is itself an entry point, published at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/.
- What it achieves
- It shows new (`showNew`) and is built from the to world helper (`toWorld`) and the card for helper (`cardFor`). A cartridge of the Kuiper shell. It responds to toggle events.
- Why it matters
- Loaded by the Kuiper Shell page at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/.
- Application
- globalgrid2050 · kuiper-grid/i0073/releases/003100000000-kuiper-shell · script
- VEDIC
- RECENT (GG2050-VEDIC-000041): Kuiper / Code navigation · Computer science / Interactive visualisation. hours, ordered_commits → recent_band_animation_state
- Uses
- none found
- Used by
- loaded by Releases — Kuiper Shell Page (script src)
- Produces
- toWorld, cardFor, esc, gh, ghLink, el, drow, linkTo, show, put, goKey, arriveAt
- Defines here
- toWorld, cardFor, esc, gh, ghLink, el, drow, linkTo, show, put, goKey, arriveAt, showNew, stepAnim
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/i0073/releases/003100000000-kuiper-shell/kuiper-card.js:1-210 · blob 9218b8ad8f4d2013532678f2a634de49b16740f9 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: agent_infra · users: ai_agent · canonical: production_core
'use strict';
// kuiper-card.js - a cartridge of the Kuiper shell. Cut from the whole page with no change of behaviour;
// replaced, when it is, by a newer file the pointer names and the composer checks by its hash.
// ------------------------------------------------------------------------------ the controls
function toWorld(px, py){ return [cx + (px - innerWidth/2)/zoom, cy - (py - innerHeight/2)/zoom]; }
// A KEY THAT LANDS IN A CARRIED FILE SHOWS THE CODE. Until every commit's file list is published a
// browser cannot work out which file a key belongs to, so the answer is worked out beforehand, one
// public file at a time, and the page simply looks it up. Where there is no card the page says what
// it knows and does not pretend otherwise.
function cardFor(k){ return cards.find(c => k >= c.k0 && k < c.k0 + c.lines) || null; }
function esc(t){ return String(t).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); }
const CONTEXT = 10;
// THE ONE RULE THAT MAKES THE ADDRESS OF A LINE ON GITHUB, the same rule tools/cards.py writes
// down, so a change of commit ids can be answered by making every link again from the fields.
// The owner used to be written in here by hand: correct by luck, and wrong the first time a
// carried file came from anywhere else.
// ONE RULE, TWO SHAPES. A whole piece of work is a commit; a line is a path inside it. Nothing in
// this page types a GitHub address: every one of them comes out of here, from data, so when the
// commit ids change they can all be made again by rebuilding the data.
function gh(o){
if (!o || !o.owner || !o.repo || !o.commit) return null;
const base = 'https://github.com/' + o.owner + '/' + o.repo;
if (!o.path) return base + '/commit/' + o.commit;
return base + '/blob/' + o.commit + '/' + o.path + (o.line ? '#L' + o.line : '');
}
function ghLink(c, line){
return gh({ owner:c.owner, repo:c.repo, commit:c.commit, path:c.path, line:line });
}
// ===== THE POP CARD =========================================================================
// The card this estate refined over many iterations, brought over rather than approximated again.
// Grid Atlas's popup look, a state chip with ONE writer, and a code window that is one <pre> with
// one text node: the numbers are part of the text, so copying the code copies what is on the
// screen, and the tapped line is marked by a bar placed from the line height.
function el(tag, cls, text){ const e = document.createElement(tag); if (cls) e.className = cls;
if (text != null) e.textContent = text; return e; }
function drow(dl, k, v){ dl.append(el('dt', null, k)); const d = el('dd', null, v); dl.append(d); return d; }
function linkTo(href, text){ const a = el('a', 'cc-link', text); a.href = href; a.target = '_blank'; a.rel = 'noopener'; return a; }
let cardToken = 0, cardSource = null, PG = null, glowBuf = null, glowCount = 0, glowOff = false;
// THE ESTATE'S ONE GATHERING ANIMATION, used as it stands. If it cannot be read the sparks simply stay
// where the work is: the page is quieter, and nothing is pretended.
function show(a){
cardShown = null;
if (!a) { closeCard(); return; }
if (a.silent) {
const x = a.next, s = sheet('Nothing was recorded here', '');
s.setTag('EMPTY', 'This point falls between two pieces of work, so no line of code has this address.');
if (x) { const p = el('div', 'cc-row');
const go = el('a', 'cc-link', 'Go to the next work: ' + repos[x.repo].name + ', ' + day(x.unix));
// BESIDE THE ADDRESS BAR, NOT BESIDE THE SHELL. Under the composer the page's base is the shell's own
// folder, and a bare ?key= would lead there instead of to the one address that never changes.
go.href = location.pathname + buildLink({ key:x.k0 }); go.setAttribute('data-key', x.k0);
p.append(go); s.body.append(p); }
return;
}
const r = repos[a.c.repo], c = cardFor(a.k);
litRepo = a.c.repo;
const s = sheet('Line ' + fmt(a.k), c ? ' \u00b7 ' + c.path.split('/').pop() : ' \u00b7 ' + r.name);
// THE ORDER OF THE CARD IS THE ORDER OF THE QUESTIONS A PERSON WHO SIGNS ASKS. What is this for,
// and where do I open it; whose is it; what was done and when. How it is made comes last and
// closed, one tap further in, for the engineer who is in the room but does not sign.
{ const found = r.pub ? appFor(r.owner, r.name, c ? c.path : null) : null;
const det = el('details', 'cc-q'); det.append(el('summary', null, 'See the code behind this'));
for (const kid of Array.from(card.children)) if (!kid.classList.contains('cc-x')) det.append(kid);
let top;
// WHERE TO PUT THE VISITOR. A carried file knows its own page; any other piece of work has the
// page its files agreed on. Where that page is the application's own front door, the tile is the
// application's, as before.
const near = r.pub ? ((c && c.page) || pageOfWork[a.c.sha] || null) : null;
const theApp = found && found.app ? found.app : null;
if (near && !(theApp && theApp.live === near.address)) {
top = el('a', 'cc-tile cc-app cc-page'); top.href = near.address; top.target = '_blank'; top.rel = 'noopener';
top.setAttribute('data-app', theApp ? theApp.app : ''); top.setAttribute('data-page', near.address);
if (theApp) top.append(el('div', 'cc-tile-part', 'part of ' + theApp.button));
top.append(el('div', 'cc-tile-name', near.title || near.address.replace(/^https?:\/\//, '')));
top.append(el('span', 'cc-tile-open', 'OPEN THIS PAGE'));
} else if (found && found.app) {
top = el('a', 'cc-tile cc-app'); top.href = found.app.live; top.target = '_blank'; top.rel = 'noopener';
top.setAttribute('data-app', found.app.app);
top.append(el('div', 'cc-tile-name', found.app.button));
if (whatItDoes[found.app.live]) top.append(el('div', 'cc-tile-what', whatItDoes[found.app.live] + '.'));
top.append(el('span', 'cc-tile-open', 'OPEN ' + found.app.button));
} else {
top = el('div', 'cc-notile cc-app');
top.setAttribute('data-app', found && found.unproved ? '?' : '');
top.append(el('div', null, 'This work has no page of its own yet.'));
}
// THE LINKS A CARD CARRIES, IN THE OPEN AND IN AS FEW WORDS AS THEY NEED: the application (above),
// GitHub as one quiet word for those who know what it is, and the site itself whenever there is
// nothing else to offer, so that no card is ever a dead end.
const links = el('div', 'cc-row cc-links');
{ const gu = r.pub ? gh({ owner:r.owner, repo:r.name, commit:a.c.sha }) : null;
if (!near && !(found && found.app)) {
// the front door of the site this work is served from, where it has one; else the main site
const door = (r.pub && frontOfWork[a.c.sha]) || 'https://www.globalgrid2050.com/';
const hl = linkTo(door, door.replace(/^https?:\/\//, '').replace(/\/$/, ''));
hl.classList.add('cc-home'); links.append(hl); }
// GITHUB IS HUMBLE: one small grey word at the very bottom of the code fold, for those who know
// what it is. Never a sentence, and never in the way of a visitor who does not.
if (gu) { const src = el('div', 'cc-source'); const gl = linkTo(gu, 'source'); gl.classList.add('cc-gh');
src.append(gl); det.append(src); cardSource = src; } }
const brand = el('div', 'scada-brand'), inner = el('div');
inner.append(el('div', 'scada-brand-main', 'Ventus'), el('div', 'scada-brand-sub', 'Cables & Connectivity\u00ae'));
brand.append(inner);
const plain = el('div', 'cc-plain', 'Engineering work in ' + r.name + ', done on ' + day(a.c.unix) + '.');
card.append(top, links, brand, plain, det);
det.open = codeOpen;
// ASKED FOR MUST MEAN SEEN. With the tile, the brand and the plain line above it, the code opened
// below the fold of the card on a phone. Opening it brings the window into view, then the line.
det.addEventListener('toggle', () => { if (det.open && cardShown && cardShown.window) revealCode(); dirty = true; }); }
const meta = el('dl', 'cc-dl');
drow(meta, 'work', r.name + ' \u00b7 ' + day(a.c.unix));
const u = r.pub ? gh({ owner:r.owner, repo:r.name, commit:a.c.sha }) : null;
const d = drow(meta, 'history', '');
if (u) { d.append(linkTo(u, 'source')); d.append(' \u00b7 commit ' + a.c.sha.slice(0, 7)); }
else d.textContent = 'not public, so there is no link';
s.body.append(meta);
if (!c) {
s.setTag('EMPTY', 'The code for this line is not carried on this site yet, so nothing around it can be shown.');
return;
}
const j = a.k - c.k0;
s.setTag('LOAD', 'reading the lines around it from this site\u2026');
const put = data => {
if (!s.live()) return;
cardShown = { card:c, line:j, data, sheet:s };
const short = c.commit.slice(0, 7), fileName = c.path.split('/').pop();
// THE ARITHMETIC THIS CARD IS ABOUT TO RELY ON, CHECKED BEFORE IT IS RELIED ON. The pack was
// built from git and every line proved against it when it was built; what can still go wrong
// here is the pack and the list disagreeing about the length of the file, and then every number
// below would be a guess.
if (!c.here || data.lines !== c.lines || data.text.length !== c.lines || !(j >= 0 && j < c.lines)) {
s.setTag('FAIL', !c.here
? 'This file is no longer in the repository, so its neighbours today would not be this line\u2019s neighbours. Nothing around it is shown.'
: 'The record says this file has ' + fmt(c.lines) + ' lines and the text carried for it has '
+ fmt(data.text.length) + ', so the numbering cannot be trusted. Nothing around it is shown.');
const h = el('div', 'cc-codehead');
h.append(c.path + ' \u00b7 ' + c.repo + ' @ ' + short + ' \u00b7 line ' + fmt(j + 1) + ' \u00b7 ');
h.append(linkTo(ghLink(c, j + 1), 'source'));
s.body.append(h);
dirty = true; return;
}
const from = Math.max(1, j + 1 - CONTEXT), to = Math.min(data.text.length, j + 1 + CONTEXT);
const head = el('div', 'cc-codehead');
head.append(c.path + ' \u00b7 ' + c.repo + ' @ ' + short + ' \u00b7 line ' + fmt(j + 1)
+ ' \u00b7 showing ' + fmt(from) + '\u2013' + fmt(to) + ' of ' + fmt(data.text.length) + ' \u00b7 ');
head.append(linkTo(ghLink(c, j + 1), 'source'));
s.body.append(head);
s.body.append(el('div', 'cc-check',
'These lines are carried on this site, read from ' + c.repo + ' at commit ' + short
+ ' when this page was built and checked line for line against it then \u00b7 '
+ fmt(j + 1 - from) + ' above, ' + fmt(to - j - 1) + ' below. Scroll inside the window to see them all;'
+ ' a long line scrolls sideways.'));
const w = codeWindow(data.text, from, to, j + 1);
s.body.append(w.node);
cardShown.window = w;
s.setTag('OK', 'the line and the lines around it, as the file stood that day');
s.body.append(el('div', 'cc-disclaimer',
'Provided as is, without warranty of any kind; a chart, not a design.'));
if (cardSource && cardSource.parentNode) cardSource.parentNode.append(cardSource);
requestAnimationFrame(() => { if (s.live()) revealCode(); });
revealCode();
dirty = true;
};
if (cardCache[c.file]) { put(cardCache[c.file]); return; }
fetch('cosmos/cards/' + c.file).then(x => x.json()).then(dd => { cardCache[c.file] = dd; put(dd); })
.catch(e => s.setTag('FAIL', 'the lines around this one could not be read from this site: ' + (e && e.message || e)));
}
function goKey(k){ endIsolate(); const p = keyPlace(k); target = { x:p[0], y:p[1] }; show(address(k)); flyTo(p[0], p[1], 14); }
// ARRIVING BY SOMEBODY ELSE'S LINK. The view flies, the arrow is shot, the card opens: three things
// in that order, because a card that appears over a picture of nine thousand pieces of work asks to
// be taken on trust, and an arrow from the middle of the record to one dot does not.
function arriveAt(k){
endIsolate();
const a = address(k);
if (!a) return;
const p = keyPlace(k);
target = null; arrow = null; arrowTip = null; card.style.display = 'none';
flyTo(p[0], p[1], Math.max(14, zoom));
setTimeout(() => { arrow = { k, t0:performance.now() }; dirty = true; }, 920);
setTimeout(() => { target = { x:p[0], y:p[1] }; show(a); dirty = true; }, 920 + ARROW_MS);
}
// SHOW NEW CODE. "New" is measured from the newest commit, not from the wall clock, so the same
// page gives the same answer tomorrow. Keys run in time order, so what is new is always one
// contiguous band at the rim: the boundary is a single circle, and that circle is drawn.
function showNew(hours){
endIsolate();
const last = commits[commits.length-1].unix, cut = last - hours*3600;
newFrom = findBy('unix', cut - 1) + (commits[0].unix >= cut ? 0 : 1); if (newFrom >= commits.length) newFrom = commits.length - 1;
litRepo = -1; target = null; card.style.display = 'none'; tween = null;
const R = Math.sqrt(SPACE); cx = 0; cy = 0; zoom = (Math.min(cv.width, cv.height)/2) * 0.80 / R;
anim_hours = hours; anim = { t0:performance.now(), hours, R }; dirty = true;
}
function stepAnim(){
const t = (performance.now() - anim.t0) / 1000; dirty = true;
if (t < 1.6) { const u = t/1.6; pulse = anim.R * (u*u*(3-2*u)); flash = 0; }
else if (t < 2.5) { pulse = -1; flash = 1 - 0.45*((t-1.6)/0.9); if (selftest && selftest.wantPixels === undefined) selftest.wantPixels = true; }
else { const c = commits[newFrom], n = commits.length - newFrom; let lines = 0; for (let i = newFrom; i < commits.length; i++) lines += commits[i].lines;
flash = 0.35; anim = null; const p = keyPlace(c.k0); target = { x:p[0], y:p[1], boundary:true };
card.style.display = 'block';
{ const r0 = repos[c.repo], u0 = r0.pub ? gh({ owner:r0.owner, repo:r0.name, commit:c.sha }) : null;
card.classList.remove('sheet');
card.innerHTML = 'NEW CODE · the last ' + anim_hours + ' hours of work, as a band at the rim'
+ '\n<b>' + fmt(n) + '</b> pieces of work, <b>' + fmt(lines) + '</b> lines added'
+ '\nbegins with <b>' + r0.name + '</b>, ' + day(c.unix)
+ (u0 ? '\n<a class="cc-gh" style="color:#666;font-size:10.5px" href="' + u0 + '" target="_blank" rel="noopener">GitHub</a>' : ''); }
flyTo(p[0], p[1], 14);
if (selftest) finishSelftest(c, n, lines); }
}
let anim_hours = 24;
// THE TESTS, run by the page on itself with ?selftest=new, so the verdict is not an opinion.Kuiper Chrome
A JavaScript file in the kuiper grid folder of GlobalGrid2050. Served with the page at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/. It is built from the set step (`set`).
interactionglobalgrid2050 / kuiper-grid/i0073/releases/003100000000-kuiper-shell/kuiper-chrome.js · lines 1–35 of 35 · Entry point
- What it does
- It draws its content. Defines set. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage agent_infra (path word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Downstream impact
- Used directly by 1 file: Releases — Kuiper Shell Page (globalgrid2050, https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/). Reached from 1 other entry point, including Phone (globalgrid2050, https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/phone.html). It is itself an entry point, published at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/.
- What it achieves
- A cartridge of the Kuiper shell: HOW THE PAGE IS DRESSED. It responds to click and keydown events.
- Why it matters
- Loaded by the Kuiper Shell page at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/.
- Application
- globalgrid2050 · kuiper-grid/i0073/releases/003100000000-kuiper-shell · script
- Uses
- none found
- Used by
- loaded by Releases — Kuiper Shell Page (script src)
- Produces
- set
- Defines here
- set
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/i0073/releases/003100000000-kuiper-shell/kuiper-chrome.js:1-35 · blob d9dc0447ad4c76dbc2422b62760784f6cd573415 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: agent_infra · users: ai_agent · canonical: production_core
'use strict';
// kuiper-chrome.js - a cartridge of the Kuiper shell: HOW THE PAGE IS DRESSED. What sits over the disc,
// and how much of it. The shell is never edited, so the dressing lives here, where it can be changed.
//
// ON A PHONE THE KUIPER IS THE MAIN EVENT. GridAtlas settled this already (v9.43: tools collapse behind
// one chip): the application buttons fold behind ONE chip, the top box is one word, and the disc gets
// the room. Nothing is removed: one tap opens the row, and choosing an application closes it again.
// A desktop has the room and is left as it is. The warranty line is on the screen at every width.
(function(){
const css = document.createElement('style');
css.textContent = `
#appschip{display:none}
@media (max-width:640px){
#use{display:none} #top.open #use{display:block}
#top{padding:5px 10px} #big{font-size:12px}
#appschip{display:inline-block;background:#061018;color:#00ffff;border:1px solid #1d6470;padding:8px 12px;
font:inherit;font-weight:bold;letter-spacing:.08em;cursor:pointer;touch-action:manipulation;margin-bottom:6px}
#appschip.on{background:#00ffff;color:#000}
#apps{display:none} #foot.appsopen #apps{display:flex}
#keys{flex-wrap:nowrap;gap:4px} #keys button{padding:8px 7px;font-size:10px;letter-spacing:.02em;white-space:nowrap}
#foot .short{margin-top:4px;font-size:10px;line-height:1.35}
}`;
document.head.appendChild(css);
const foot = document.getElementById('foot'), apps = document.getElementById('apps');
const chip = document.createElement('button'); chip.id = 'appschip'; chip.type = 'button'; chip.textContent = 'APPS';
chip.setAttribute('aria-expanded', 'false');
foot.insertBefore(chip, apps);
const set = open => { foot.classList.toggle('appsopen', open); chip.setAttribute('aria-expanded', String(open));
if (typeof layout === 'function') layout(); if (typeof atHome !== 'undefined' && atHome && typeof homeCamera === 'function' && SPACE) { const h = homeCamera(); flyTo(h.x, h.y, h.z); } dirty = true; };
chip.addEventListener('click', e => { e.stopPropagation(); set(!foot.classList.contains('appsopen')); });
// choosing an application puts the row away again, so the show has the screen; the chip says which is on
apps.addEventListener('click', e => { const b = e.target.closest ? e.target.closest('button') : null; if (!b) return;
chip.textContent = b.textContent; chip.classList.add('on'); set(false); });
addEventListener('keydown', e => { if (e.key === 'Backspace') { chip.textContent = 'APPS'; chip.classList.remove('on'); } });
})();Kuiper Programs
A JavaScript file in the kuiper grid folder of GlobalGrid2050 that makes body, sets tag, makes app buttons and calculates planar distances. Served with the page at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/.
interactionglobalgrid2050 / kuiper-grid/i0073/releases/003100000000-kuiper-shell/kuiper-programs.js · lines 1–212 of 212 · Entry point · pattern bodyDrawnDiameter (shared by 54 files)
- What it does
- Defines 26 functions or classes, including closestPair, blackSky, nameInLines, makeBody, bodyTo. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage agent_infra (path word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Downstream impact
- Used directly by 1 file: Releases — Kuiper Shell Page (globalgrid2050, https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/). Reached from 1 other entry point, including Phone (globalgrid2050, https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/phone.html). It is itself an entry point, published at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/.
- What it achieves
- It makes body (`makeBody`), sets tag (`setTag`) and makes app buttons (`makeAppButtons`). A cartridge of the Kuiper shell. It responds to click and keydown events.
- Why it matters
- Loaded by the Kuiper Shell page at https://globalgrid2050.com/kuiper-grid/i0073/releases/003100000000-kuiper-shell/.
- Application
- globalgrid2050 · kuiper-grid/i0073/releases/003100000000-kuiper-shell · script
- Uses
- Assemble (dynamic import)
- Used by
- loaded by Releases — Kuiper Shell Page (script src)
- Produces
- closestPair, blackSky, nameInLines, makeBody, bodyTo, bodyJump, bodyMove, bodyDrawnDiameter, bodyDotPx, sheet, setTag, revealCode
- Defines here
- closestPair, blackSky, nameInLines, makeBody, bodyTo, bodyJump, bodyMove, bodyDrawnDiameter, bodyDotPx, sheet, setTag, revealCode, sparksTo, ensureGlow, makeAppButtons, isolateNow, isolate, raiseTile, endIsolate, unisolate, appCard, closeCard, codeWindow, lh, padTop, place
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/i0073/releases/003100000000-kuiper-shell/kuiper-programs.js:1-212 · blob bf02761e950b5b8b9507ced093c94786290ee3e5 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: agent_infra · users: ai_agent · canonical: production_core
'use strict';
// kuiper-programs.js - a cartridge of the Kuiper shell. Cut from the whole page with no change of behaviour;
// replaced, when it is, by a newer file the pointer names and the composer checks by its hash.
let ASM = null, gatherAnim = null, homeAnim = null;
// ===== THE BODY: a smaller Kuiper of one application's own work =====================================
let body = null, bodyAnim = null, BP = null, bodyBuf = null;
const BODY_RADIUS = 0.30, BODY_RADIUS_MAX = 0.92, DOT_MAX_PX = 3.5, DOT_MIN_PX = 1.0;
const VS_BODY = `#version 300 es
precision highp float;
in vec2 a_pos; uniform float u_zoom, u_size; uniform vec2 u_center, u_res;
void main(){ gl_Position = vec4((a_pos - u_center) * u_zoom / (0.5*u_res), 0.0, 1.0); gl_PointSize = u_size; }`;
// A DOT IS A DISC WITH A HARD EDGE, AND IT IS NOT ADDED TO WHAT IS UNDER IT. Light that adds is how
// neighbours merge into a white patch; here a dot covers what it covers and nothing more.
const FS_BODY = `#version 300 es
precision highp float; uniform vec3 u_on; out vec4 o;
void main(){ if (length(gl_PointCoord - 0.5) > 0.5) discard; o = vec4(u_on, 1.0); }`;
// THE GAP, MEASURED. The nearest two centres among the places the module returned, found with a grid
// so a large application costs no more than a small one. Nothing here is judged by eye.
function closestPair(pos){
const m = pos.length / 2; if (m < 2) return Infinity;
let x0 = 1e300, x1 = -1e300, y0 = 1e300, y1 = -1e300;
for (let q = 0; q < pos.length; q += 2) { x0 = Math.min(x0, pos[q]); x1 = Math.max(x1, pos[q]); y0 = Math.min(y0, pos[q+1]); y1 = Math.max(y1, pos[q+1]); }
const cell = Math.max(1e-9, Math.sqrt(Math.max(1e-18, (x1 - x0) * (y1 - y0)) / m)), grid = new Map();
let best = Infinity;
for (let j = 0; j < m; j++) { const gx = Math.floor((pos[2*j] - x0) / cell), gy = Math.floor((pos[2*j+1] - y0) / cell);
for (let dx = -1; dx <= 1; dx++) for (let dy = -1; dy <= 1; dy++) { const cellm = grid.get((gx + dx) + ':' + (gy + dy)); if (!cellm) continue;
for (const k of cellm) { const d = Math.hypot(pos[2*j] - pos[2*k], pos[2*j+1] - pos[2*k+1]); if (d < best) best = d; } }
const key = gx + ':' + gy; (grid.get(key) || grid.set(key, []).get(key)).push(j); }
return best;
}
// THE BLACK SKY RULE, as one question any body can be asked: are all centres at least three dot radii
// apart? It is the same function the page obeys and the test plants a too tight body against.
function blackSky(pos, dotRadius){ const gap = closestPair(pos); return { gap, dotRadius, ok: gap >= 3 * dotRadius * (1 - 1e-4) }; } // exactly a third is allowed; the margin is for rounding, not for squeezing
function nameInLines(words){ const w = String(words).split(' '); if (String(words).length <= 9 || w.length < 2) return String(words);
const half = Math.ceil(w.length / 2); return w.slice(0, half).join(' ') + ' / ' + w.slice(half).join(' '); }
function makeBody(st){
if (!ASM || !st.idx.length) return null;
const seq = (st.prog.on.sequence && st.prog.on.sequence.length) ? st.prog.on.sequence : (st.prog.on.shape ? [{ shape:st.prog.on.shape }] : []);
if (!seq.length) return null;
const m = st.idx.length, R = Math.sqrt(SPACE), from = new Float32Array(2 * m);
// ONE DOT FOR EVERY PIECE OF WORK, IN ORDER OF KEY: the module puts dot j at place j, and place 0 is
// the middle, so the oldest work is the middle of the small Kuiper and the newest is its rim.
st.idx.forEach((ci, j) => { const c0 = commits[ci], p = keyPlace(c0.k0 + Math.floor((c0.k1 - c0.k0) / 2)); from[2*j] = p[0]; from[2*j+1] = p[1]; });
// THE SIZE THE SHOW WILL REALLY BE SEEN AT. On a phone the short tile rises under the picture and the
// disc is refitted smaller above it, so what resolves is decided for THAT size, not for the empty screen.
const zHome = homeCamera().z * (narrow() ? 0.62 : 1), states = [];
for (const step of seq) { const shape = step.shape === 'text' ? 'text:' + nameInLines(st.app.button) : step.shape;
// A NAME NEEDS ENOUGH DOTS TO BE A NAME: about six to a letter. Nine pieces of work cannot spell
// two words, and a scatter that means nothing is worse than the small Kuiper it would replace.
if (step.shape === 'text' && m < 6 * st.app.button.replace(/[^A-Za-z0-9]/g, '').length) continue;
let unit; try { unit = ASM.targets(shape, m); } catch (e) { continue; }
const unitGap = closestPair(unit);
// large enough that a dot a third of the gap wide is at least a pixel; never larger than the disc
let frac = BODY_RADIUS; const need = DOT_MIN_PX * 3 / Math.max(1e-12, unitGap * R * zHome);
if (need > frac) frac = Math.min(BODY_RADIUS_MAX, need);
const to = new Float32Array(unit.length); for (let q = 0; q < unit.length; q++) to[q] = unit[q] * R * frac;
const gap = unitGap * R * frac;
const unresolved = gap * zHome / 3 < DOT_MIN_PX * 0.999;
// WHAT CANNOT BE RESOLVED IS NOT SHOWN AS IF IT COULD. A state that would need dots under a pixel is
// left out, and the show ends on the last state that does resolve: the work gathers and STAYS, it
// is never simply gone from the middle of the disc, which is what a phone showed.
if (unresolved && states.length) continue;
states.push({ shape, to, gap, frac, hold:step.hold_ms || 0, unresolved }); }
if (!states.length) return null;
return { n:m, from, pos:new Float32Array(from), states, k:-1, gap:0, shown:false };
}
function bodyTo(arr){ if (body) body.live = closestPair(arr);
if (!BP) { BP = prog(VS_BODY, FS_BODY); bodyBuf = gl.createBuffer(); }
gl.bindBuffer(gl.ARRAY_BUFFER, bodyBuf); gl.bufferData(gl.ARRAY_BUFFER, arr, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ARRAY_BUFFER, null); }
function bodyJump(k){ if (!body) return; const stt = body.states[k]; body.pos.set(stt.to); body.k = k; body.gap = stt.gap; body.shown = true; bodyAnim = null; bodyTo(body.pos); dirty = true; }
function bodyMove(k){ if (!body) return; bodyAnim = { k, t0:performance.now(), from:new Float32Array(body.pos), gap0:body.shown ? body.gap : body.states[k].gap, phase:'move' };
body.shown = true; dirty = true; }
// the dot's radius ON THE SCREEN, from the measured gap and the zoom of this moment: a third of the
// gap, never more, however the visitor zooms
// THE SIZE FOLLOWS THE CANVAS, NOT THE SCREEN. This canvas is as many pixels as the window is wide, so a
// point size is already in the units the gap is measured in. Multiplying by the screen's pixel ratio
// drew every dot at twice its size on a real screen and at its right size in every test.
function bodyDrawnDiameter(){ return Math.max(1, 2 * bodyDotPx() * (cv.width / Math.max(1, innerWidth))); }
// A THIRD OF THE GAP AS THE DOTS ARE NOW. At rest the gap is the state's own; in flight it is measured
// from where the dots are at that frame, because leaving the rim they are almost on top of one another
// and no resting spacing describes them.
function bodyDotPx(){ const gap = body.live !== undefined ? body.live : body.gap; // measured every time the dots are placed
return Math.max(0.5, Math.min(DOT_MAX_PX, gap * zoom / 3)); }
const asmReady = import('./assemble.mjs').then(m => { ASM = m; }).catch(() => { ASM = null; });
const GATHER_RADIUS = 0.30; // of the record's own radius: a body, with the dark disc still around it
function sheet(title, sub){
const mine = ++cardToken;
card.classList.remove('short');
card.replaceChildren();
card.style.display = 'block';
card.scrollTop = 0;
const x = el('button', 'cc-x', '\u00d7'); x.type = 'button'; x.setAttribute('aria-label', 'close');
x.addEventListener('click', closeCard);
card.append(x, el('span', 'cc-title', title));
if (sub) card.append(el('span', 'cc-grey', sub));
const tagLine = el('div', 'cc-tagline'), tag = el('span', 'cc-tag'), msg = el('span', 'cc-grey');
tagLine.append(tag, msg); card.append(tagLine);
const body = el('div', 'cc-body'); card.append(body);
// THE SINGLE WRITER OF THE STATE. Nothing else touches the chip, and a writer for a card that has
// been replaced does nothing at all.
const setTag = (st, text) => { if (mine !== cardToken) return false;
tag.dataset.s = st; tag.textContent = st; if (text != null) msg.textContent = text; return true; };
dirty = true;
return { mine, body, setTag, live: () => mine === cardToken };
}
function revealCode(){
const w = cardShown && cardShown.window; if (!w) return;
const cr = card.getBoundingClientRect(), pr = w.node.getBoundingClientRect();
if (pr.bottom > cr.bottom - 4) card.scrollTop += pr.bottom - cr.bottom + 8;
else if (pr.top < cr.top) card.scrollTop -= cr.top - pr.top + 8;
w.scrollToTarget();
}
function sparksTo(arr){ ensureGlow(); gl.bindBuffer(gl.ARRAY_BUFFER, glowBuf);
gl.bufferData(gl.ARRAY_BUFFER, arr, gl.DYNAMIC_DRAW); gl.bindBuffer(gl.ARRAY_BUFFER, null); }
function ensureGlow(){ if (!PG) { PG = prog(VS_GLOW, FS_GLOW); glowBuf = gl.createBuffer(); } }
// ===== ISOLATE AN APPLICATION =================================================================
function makeAppButtons(){
const bar = document.getElementById('apps'); bar.replaceChildren();
for (const pr of programs) { const ap = apps.find(x => x.app === pr.select.app);
if (!ap || !(appWork[ap.app] || []).length) continue; // nothing of it on this record: no button
const b = el('button', null, pr.button); b.type = 'button'; b.setAttribute('data-app', pr.name);
b.addEventListener('click', e => { e.stopPropagation(); isolate(pr.name); }); bar.append(b); }
if (typeof layout === 'function') layout();
}
// THE STATE ITSELF, with no animation, so it can be arrived at by a link and asked for by a test.
function isolateNow(name, front){
const prog = programs.find(x => x.name === name); if (!prog) return null;
const ap = apps.find(x => x.app === prog.select.app); if (!ap) return null;
name = ap.app;
const idx = []; for (const sha of (appWork[name] || [])) { const i = bySha.get(sha); if (i !== undefined) idx.push(i); }
idx.sort((x, y) => x - y);
litRepo = -1; litK = [-1,-1]; litCi = null; newFrom = -1; flash = 0; litPath = null; target = null; arrow = null;
iso = { app:ap, prog, front:front === undefined ? 1e30 : front, idx, set:new Set(idx), lit:idx.length, dark:commits.length - idx.length,
first:idx.length ? commits[idx[0]].unix : 0, last:idx.length ? commits[idx[idx.length - 1]].unix : 0 };
raiseFlags(idx);
{ // A FEW SPARKS FOR EVERY PIECE OF WORK, spread through its own lines so a big piece of work is a
// scatter around its ring and a small one a point or two. Never more than the program allows.
const per = Math.max(1, Math.min(24, (prog.on.sparks | 0) || 8)), pts = [];
for (const i of idx) { const c0 = commits[i], len = Math.max(1, c0.k1 - c0.k0), take = Math.min(per, len);
for (let j = 0; j < take; j++) { const p = keyPlace(c0.k0 + Math.floor((j + 0.5) * len / take)); pts.push(p[0], p[1]); } }
ensureGlow();
iso.from = new Float32Array(pts); iso.pos = iso.from; iso.to = null;
glowCount = pts.length / 2; iso.sparks = glowCount; sparksTo(iso.from); }
body = makeBody(iso);
// arrived at by a link, or asked for outright: the END of the program, with no waiting
if (front === undefined && body) bodyJump(body.states.length - 1);
for (const b of document.querySelectorAll('#apps button')) b.classList.toggle('on', b.getAttribute('data-app') === prog.name);
if (front === undefined) raiseTile();
dirty = true;
return iso;
}
// PRESS: the pulse runs out through the record, which on this picture is forward through time, and
// where it has passed the rest goes dark. The pulse is the page's own; nothing new is animated.
function isolate(name){
const prog = programs.find(x => x.name === name); if (!prog) return;
closeCard(); unisolate(true); anim = null; flash = 0; newFrom = -1; target = null; arrow = null;
{ const h = homeCamera(); cx = h.x; cy = h.y; zoom = h.z; tween = null; atHome = true; }
// the selection is made at once and the FRONT starts at the origin with nothing switched; each dot
// switches when the front reaches it, so the darkening is seen to travel
if (!isolateNow(name, 0)) return;
bodyAnim = null; if (body) body.shown = false;
isoAnim = { name, t0:performance.now(), R:Math.sqrt(SPACE), ms:Math.max(200, (prog.pulse.seconds || 1.5) * 1000) }; dirty = true;
}
function raiseTile(){ if (!iso || !(iso.prog.end && iso.prog.end.tile)) return;
appCard(iso); if (atHome) { const h = homeCamera(); flyTo(h.x, h.y, h.z); } dirty = true; }
// ANY OTHER ACTION FIRST ENDS THE ISOLATE. Called by everything that shows something else, before it
// does anything, so the darkening can never outlive the thing it was for.
function endIsolate(){ if (iso || isoAnim || bodyAnim) { unisolate(true); closeCard(); } }
function unisolate(quiet){ iso = null; isoAnim = null; gatherAnim = null; homeAnim = null; body = null; bodyAnim = null; pulse = -1;
for (const b of document.querySelectorAll('#apps button')) b.classList.remove('on');
if (!quiet) dirty = true; }
// THE TILE OF AN ISOLATED APPLICATION: its name, what it does for a project, OPEN. Then how much of
// the record is lit and how much has gone dark, because the two must make the whole.
function appCard(st){
cardToken++; cardShown = null; card.replaceChildren(); card.style.display = 'block'; card.scrollTop = 0;
card.classList.add('short');
const x = el('button', 'cc-x', '\u00d7'); x.type = 'button'; x.setAttribute('aria-label', 'close');
x.addEventListener('click', () => { card.style.display = 'none'; dirty = true; });
const t = el('a', 'cc-tile cc-app'); t.href = st.app.live; t.target = '_blank'; t.rel = 'noopener'; t.setAttribute('data-app', st.app.app);
t.append(el('div', 'cc-tile-name', st.app.button));
if (whatItDoes[st.app.live]) t.append(el('div', 'cc-tile-what', whatItDoes[st.app.live] + '.'));
t.append(el('span', 'cc-tile-open', 'OPEN ' + st.app.button));
const brand = el('div', 'scada-brand'), inner = el('div');
inner.append(el('div', 'scada-brand-main', 'Ventus'), el('div', 'scada-brand-sub', 'Cables & Connectivity\u00ae')); brand.append(inner);
const plain = el('div', 'cc-plain cc-count', fmt(st.lit) + ' pieces of work lit, ' + fmt(st.dark) + ' gone dark, '
+ fmt(st.lit + st.dark) + ' in all \u00b7 ' + day(st.first) + ' to ' + day(st.last));
card.append(x, t, brand, plain);
if (typeof layout === 'function') layout();
}
function closeCard(){ cardToken++; card.style.display = 'none'; card.replaceChildren();
target = null; cardShown = null; dirty = true; }
addEventListener('keydown', e => {
if (e.key === 'Escape' && card.style.display !== 'none') { e.preventDefault(); closeCard(); } });
function codeWindow(lines, a, b, at){
const pre = el('pre', 'cc-code');
pre.setAttribute('aria-label', 'the code around this line');
const bar = el('div', 'cc-hi cc-hi-target');
const out = [];
for (let i = a; i <= b; i++) out.push(String(i).padStart(6) + ' ' + lines[i - 1]);
pre.append(bar, document.createTextNode(out.join('\n')));
const lh = () => parseFloat(getComputedStyle(pre).lineHeight) || 16;
const padTop = () => parseFloat(getComputedStyle(pre).paddingTop) || 0;
const place = () => { bar.style.top = (padTop() + (at - a) * lh()) + 'px'; bar.style.height = lh() + 'px'; };
return { node:pre, bar, place, first:a, last:b, at,
scrollToTarget(){ place(); pre.scrollTop = Math.max(0, (at - a) * lh() - pre.clientHeight/2 + lh()/2); } };
}
// WHAT A TAP OPENS. One way in for every kind of answer: the work and the day it was done, a state
// chip saying how much of it is proved, and, where the code for that line is carried on this site,
// the code itself with the tapped line marked. Nothing here sends a reader to GitHub to READ code;
// the link is there for the detail and the history, which is what GitHub is good for.