Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
Make three rigs run, and one of them notice (#399)
nyblnet48945fb68ba6
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex e598f17a..7869b551 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -233,6 +233,19 @@ jobs:# mistakes is made in the source.run: node scripts/test-spaces-model.ts+ - name: spaces rig manifest+ # Bookkeeping, not a ninth run of the eight steps above. scripts/+ # test-spaces.mjs is the local entry point for the spaces suite (two of+ # those rigs cannot be handed to node directly, and running one by hand+ # produces a stack trace that reads like a broken product); this asserts+ # its list is still complete in both directions — every test-spaces-*+ # file on disk is listed there, and every rig it lists has a step in+ # this workflow. Both omissions are invisible: an unlisted rig never+ # runs locally, an unregistered one never runs here, and neither looks+ # like anything but green. test-spaces.mjs itself was unregistered from+ # the day it was written, which is how this check came to exist.+ run: node scripts/test-spaces.mjs --manifest+# dash: the data app — same pipeline, same gate.- name: Install (dash)working-directory: dash@@ -401,6 +414,16 @@ jobs:# a Mac. That is the payoff for keeping UIKit out of that file.run: node scripts/test-tray-index.mjs+ - name: document index conformance corpus+ # home/fixtures/ is the corpus all three hosts answer — the JS reference+ # here, the Kotlin port under Gradle, the Swift port in the rig above.+ # This is the JS side of it, and it is the reference the other two are+ # diffed against, so a break here is a break in the thing they agree+ # with. It went unregistered and then unnoticed: the tray→home rename+ # left it importing ../tray/doc-index.mjs, and a rig nobody runs cannot+ # report its own import failure.+ run: node scripts/test-doc-index.mjs+- name: home/ios release verifier rig# Starter decks are not bundled; a new document is FETCHED from the# signed release channel and written to disk as an executable page. The@@ -711,6 +734,18 @@ jobs:# is the regression.run: node scripts/test-layouts.ts+ - name: slides store rig+ # The editor's undo/redo, selection and whole-deck replacement, at the+ # store level rather than through the DOM. Bundled first for the same+ # reason the spaces rigs are: store.ts imports './model' without an+ # extension, which node's strip-only TypeScript loader will not follow,+ # so run by hand it fails with ERR_MODULE_NOT_FOUND and looks like a+ # broken product. It had never been registered here.+ run: |+ slides/node_modules/.bin/esbuild scripts/test-slide-store.ts --bundle --platform=node --format=esm \+ --outfile="$RUNNER_TEMP/test-slide-store.mjs"+ node "$RUNNER_TEMP/test-slide-store.mjs"+# bento/type: the word processor. Same pipeline, same gate.- name: Install (type)working-directory: typediff --git a/scripts/test-doc-index.mjs b/scripts/test-doc-index.mjsindex 893e6323..038ede4b 100644--- a/scripts/test-doc-index.mjs+++ b/scripts/test-doc-index.mjs@@ -3,7 +3,7 @@// Copyright (c) 2026 The Bento authors//// Conformance rig for the document indexer — the JS side of the contract in-// tray/fixtures/. The Kotlin port runs the same corpus from+// home/fixtures/. The Kotlin port runs the same corpus from// `./gradlew :app:testDebugUnitTest`, and a Swift port will do the same.//// node scripts/test-doc-index.mjs@@ -13,10 +13,10 @@ import { createHash } from 'node:crypto'import { dirname, join } from 'node:path'import { fileURLToPath } from 'node:url'-import { describe, TEXT_BUDGET, SNIFF_BYTES, HEAD_BYTES } from '../tray/doc-index.mjs'+import { describe, TEXT_BUDGET, SNIFF_BYTES, HEAD_BYTES } from '../home/doc-index.mjs'const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const dir = join(root, 'tray/fixtures')+const dir = join(root, 'home/fixtures')const expected = JSON.parse(readFileSync(join(dir, 'expected.json'), 'utf8'))const sha = (s) => createHash('sha256').update(s, 'utf8').digest('hex').slice(0, 16)diff --git a/scripts/test-home-bridge.ts b/scripts/test-home-bridge.tsindex 6e5baa79..8ca207cd 100644--- a/scripts/test-home-bridge.ts+++ b/scripts/test-home-bridge.ts@@ -18,8 +18,9 @@// The functions are EXTRACTED FROM THE REAL SOURCE rather than copied here, so// this cannot pass against a stale duplicate of code that has since regressed.// It fails against the pre-fix EditorViewController.swift: safeFileName did not-// exist, the encoder escaped only '"', and an export whose suggested name-// reduced onto the open file's name routed to the in-place overwrite.+// exist, the encoder escaped only '"', an export whose suggested name reduced+// onto the open file's name routed to the in-place overwrite, and exportCopy+// appended the page's name straight onto the temp directory.//// Two halves. The SHAPE checks read the source and always run, so a Linux CI// runner still catches the call sites drifting back. The BEHAVIOUR checks@@ -90,6 +91,26 @@ ok(!/return\s+"\\""\\""/.test(swift) && /else\s*{\s*return\s+"null"\s*}/.test(swok(!/private var pendingExportName/.test(swift),'no stored property shadows the export name the page was handed')+// exportCopy is the WRITE — the step that cannot be taken back, and the one the+// arbitrary-write finding was actually about: a page-chosen `../Documents/…`+// landed on another deck inside the container BEFORE the export picker appeared.+// It cannot be compiled into the harness below (it presents a+// UIDocumentPickerViewController), so it is pinned by shape instead. It was+// pinned by nothing at all until now: this rig passed 52/52 against a tree with+// both of exportCopy's guards deleted, which is the defect these four checks+// close. The harness's `name` mode evaluates the containment property on the+// real URL machinery — that only proves anything while exportCopy still ASKS it.+const exportCopy = slice(swift, 'private func exportCopy(')+ok(!/appendingPathComponent\(name\)/.test(exportCopy),+ 'exportCopy never appends the page-supplied name raw')+ok(/safeFileName\(name\)/.test(exportCopy) && /appendingPathComponent\(safe\)/.test(exportCopy),+ 'exportCopy appends the FILTERED name, not the one it was handed')+ok(/hasPrefix\(dir\.standardizedFileURL\.path \+ "\/"\)/.test(exportCopy),+ 'exportCopy re-proves the resolved path is inside the temp directory')+ok(exportCopy.includes('hasPrefix(') && exportCopy.includes('safeFileName(name)')+ && exportCopy.indexOf('write(to: tmp)') > exportCopy.indexOf('hasPrefix('),+ 'both guards come before the write — the ordering is the property, not their presence')+if (spawnSync('swiftc', ['--version']).status !== 0) {console.log(' skip no Swift toolchain on this machine — behaviour checks not run')console.log(`\n${checks - failures}/${checks} checks passed`)diff --git a/scripts/test-sanitize.ts b/scripts/test-sanitize.tsindex 11f8ba95..cdb935df 100644--- a/scripts/test-sanitize.ts+++ b/scripts/test-sanitize.ts@@ -478,8 +478,40 @@ if (location.pathname === '/meta.html') {!!art.querySelector('feColorMatrix')!.getAttribute('values'))check('viewBox and preserveAspectRatio survive the parser round-trip',art.querySelector('svg')!.getAttribute('viewBox') === '0 0 1280 720')- check('the svg <style> is kept — scopeCss is what stops it leaking',- (art.querySelector('style')?.textContent ?? '').includes('.dot{fill:url(#bp-ga-am)}'))+ // The <style> INSIDE the markup is kept because removing it breaks real+ // decks, and its content is filtered by sanitizeSvgCss. This check asserts+ // only that the RULES SURVIVE — deliberately NOT whether they are scoped,+ // because that is changing underneath it: on main the markup sheet is+ // unscoped (scopeCss's one call site takes el.css, not the markup), and+ // PR #402 scopes it. Claiming either state here would make this rig a+ // hostage to that PR's merge order.+ //+ // Hence the whitespace squash, which is the whole reason this is not a plain+ // includes(): scopeCss emits the scope, a space, the selector, then a space+ // before the brace — so scoping rewrites '.dot{fill:...}' as+ // '[data-el-id="..."] .dot {fill:...}' and a literal substring test fails on+ // ONE INSERTED SPACE while the rules are perfectly intact. Measured both+ // ways. The two checks below cover the scoping question properly, on el.css,+ // which is the field scopeCss actually guards.+ //+ // NOTE, and this cost a build: everything here is inside probeSource's+ // template literal. A backtick or a dollar-brace in a COMMENT is still code+ // to the parser and ends the template early.+ // NOTE the DOUBLED backslash: this line lives inside probeSource's template+ // literal, where a single backslash-s is an escape that collapses to a bare+ // 's' — the regex became /s+/g and stripped the letter s out of the markup+ // (the element id 'sv1' came back as 'v1', which is how it was caught).+ const squash = (css) => css.replace(/\\s+/g, '')+ check('the svg <style> inside the markup is kept, with its rules intact',+ squash(art.querySelector('style')?.textContent ?? '').includes(squash('.dot{fill:url(#bp-ga-am)}')))++ const scoped = draw('<svg viewBox="0 0 20 20"><rect id="sc" width="10" height="10"/></svg>',+ '.z{fill:red}@keyframes k{to{opacity:0}}')+ const elSheet = scoped.querySelector('svg > style')?.textContent ?? ''+ check('el.css IS scoped to the element — this is what keeps one diagram out of another',+ elSheet.includes('[data-el-id="sv1"] .z') && elSheet.trim().indexOf('.z') !== 0)+ check('and @keyframes stays top-level — a prefixed keyframes name resolves to nothing',+ elSheet.includes('@keyframes k') && !elSheet.includes('[data-el-id="sv1"] @keyframes'))const sloppy = draw('<svg viewBox="0 0 20 20"><rect width="10" height="10"><circle cx="5" cy="5" r="2"/></svg>')check('an unclosed tag still draws — text/html, not the fatal xml parser',diff --git a/scripts/test-spaces.mjs b/scripts/test-spaces.mjsindex ebc89738..ae197b89 100755--- a/scripts/test-spaces.mjs+++ b/scripts/test-spaces.mjs@@ -4,6 +4,7 @@// Run every bento/spaces rig the way CI runs it.//// node scripts/test-spaces.mjs [name…] # all, or just the ones named+// node scripts/test-spaces.mjs --manifest # only check the list is complete//// WHY THIS EXISTS. Two of the spaces rigs cannot be handed to node directly:// store.ts imports './model' without an extension and the kernel transport uses@@ -17,8 +18,17 @@// So the fix is not to bend the app's imports around node. It is to give the// suite one local entry point that does what CI does, and to make the failure// legible when it is real.+//+// WHY CI RUNS `--manifest` AND NOT THE WHOLE RUNNER. Every rig below already has+// its own CI step, with its own timezone matrix; running the runner there would+// execute all of them a second time and prove nothing new. What CI cannot get+// anywhere else is the BOOKKEEPING this file does — that a spaces rig on disk is+// listed here, and that it is registered in the workflow. Both failures are+// silent: an unlisted rig never runs locally, an unregistered one never runs in+// CI, and neither shows up as anything but green. `test-spaces.mjs` itself was+// unregistered for weeks, which is the case in point.import { spawnSync } from 'node:child_process'-import { existsSync, mkdtempSync, rmSync, readdirSync } from 'node:fs'+import { existsSync, mkdtempSync, readFileSync, rmSync, readdirSync } from 'node:fs'import { tmpdir } from 'node:os'import { join, dirname } from 'node:path'import { fileURLToPath } from 'node:url'@@ -56,7 +66,55 @@ if (missing.length) {process.exit(2)}-const only = process.argv.slice(2)+// --- the manifest check ------------------------------------------------------+// A rig listed here but absent from the workflow runs locally and never in CI —+// the same silence from the other side. The workflow is read as TEXT on purpose:+// the rigs are invoked several different ways (plain, under a TZ loop, bundled+// through esbuild first), and every one of them names the file.+//+// REGISTRATION IS `--manifest`'s ENTIRE JOB AND NO PART OF THE FULL RUNNER'S,+// so it is asked only in that mode. Both halves of that sentence were wrong here+// once, and each wrong half had its own symptom:+//+// * With no workflow to read, this printed a warning on stderr and then a+// success line on stdout claiming all eight rigs were "registered in+// .github/workflows/ci.yml" — naming the file it had just failed to find.+// A mode that cannot see the workflow has not done half its job; it has done+// none of it, so it fails.+// * The check used to run BEFORE the argv parse, so an unregistered rig exited+// 2 in full-runner mode too — before a single rig ran. A bookkeeping gap+// withheld all eight rigs from someone who asked for the rigs and never+// mentioned CI, and told them about CI registration instead. Measured: zero+// rig-output lines. Found by bento-team-home-ios.+const WORKFLOW = '.github/workflows/ci.yml'+const argv = process.argv.slice(2)++if (argv.includes('--manifest')) {+ // The list must be live. If RIGS ever emptied, `unregistered` would be [] and+ // this mode would report a pass over nothing. The on-disk check above already+ // catches that from the other side (every file becomes unlisted), but only+ // while files exist — this makes the floor explicit rather than emergent.+ if (!RIGS.length) {+ console.error('RIGS is empty — this check would pass vacuously. That is the bug, not a pass.')+ process.exit(2)+ }+ if (!existsSync(join(root, WORKFLOW))) {+ console.error(`${WORKFLOW} not found, so registration cannot be checked — and checking it is`)+ console.error('the whole of what --manifest does. Run it from a full checkout.')+ process.exit(2)+ }+ const ci = readFileSync(join(root, WORKFLOW), 'utf8')+ const unregistered = RIGS.filter((r) => !ci.includes(r.file.replace(/^scripts\//, '')))+ if (unregistered.length) {+ console.error(`these spaces rigs are not registered in ${WORKFLOW}: ${unregistered.map((r) => r.name).join(', ')}`)+ console.error('A rig nobody runs is not a rig. Add a step for each, or remove it from RIGS.')+ process.exit(2)+ }+ console.log(`manifest ok — ${RIGS.length} spaces rigs, all listed here and all registered in ${WORKFLOW}`)+ process.exit(0)+}++const only = argvconst picked = only.length ? RIGS.filter((r) => only.includes(r.name)) : RIGSconst unknown = only.filter((n) => !RIGS.some((r) => r.name === n))if (unknown.length) {diff --git a/scripts/test-tray-index.mjs b/scripts/test-tray-index.mjsindex 1534d6e4..4632a711 100644--- a/scripts/test-tray-index.mjs+++ b/scripts/test-tray-index.mjs@@ -312,7 +312,7 @@ function runSwift(bin, files) {// `library.js`'s describe() ALWAYS returns a title, falling back to the// file's base name, because its caller has already sniffed and it never// faces a non-document. The Swift port answers all the questions in one- // call (the shared contract in tray/fixtures) so it returns nil, and the+ // call (the shared contract in home/fixtures) so it returns nil, and the// listing supplies the file name. Same behaviour, different seam — the// fallback is applied here so the two are compared like for like.title: row.title ?? basename(row.path)@@ -407,18 +407,55 @@ const real = files.length - generated - (EXTRA_CORPUS ? 0 : 0)/* ── the shared corpus ────────────────────────────────────────────────────── *//**- * `tray/fixtures/` is the corpus all three hosts answer, with `expected.json`- * as the answer key and `tray/doc-index.mjs` as the reference. It is a DIFFERENT+ * `home/fixtures/` is the corpus all three hosts answer, with `expected.json`+ * as the answer key and `home/doc-index.mjs` as the reference. It is a DIFFERENT* guarantee from the diff above and worth having both: that one proves this port* tracks the extension as it moves, this one proves all three hosts agree on one* frozen set of answers — including Kotlin, which nothing on this machine can run.*- * Skipped, not failed, when the directory is absent: it arrives with the Android- * work, and a rig that fails until an unrelated branch lands is a rig people- * learn to ignore.+ * It used to SKIP when the directory was absent, because it arrived with the+ * Android work and a rig that fails until an unrelated branch lands is a rig+ * people learn to ignore. It has landed, so the skip now protects nothing and+ * costs the whole check: the tray→home rename moved the corpus, this kept+ * reading `tray/fixtures`, and for weeks the rig printed "absent, skipped" in+ * green while eleven cases went untested. A path that is supposed to exist is+ * a FAILURE when it does not.*/+/**+ * Any `expected.json` sitting in a fixtures directory elsewhere in the tree, so a+ * MOVED corpus is told apart from a genuinely absent one. Cheap: two shallow+ * levels, no full walk. (Written without the glob it describes: a literal+ * star-slash in this comment would close it early.)+ *+ * This DECIDES nothing. The policy above is absolute — absent is a failure+ * either way — and this only enriches the message, because "MISSING" sends a+ * reader looking for a deleted corpus while "MISSING, and one is sitting at X"+ * sends them to fix a path. Its ancestor in PR #405 threw instead, which aborted+ * the run before the Swift-diff summary printed and left a raw stack trace as+ * the last thing on screen — the rig read as crashed rather than stale-pathed.+ * Diagnosis belongs in the message, not in the control flow.+ *+ * From bento-team-home-ios (PR #405); `tray` dropped from the probe roots, the+ * rename having landed.+ */+function strayCorpus() {+ for (const top of ['home', 'scripts', '.']) {+ const base = join(ROOT, top)+ let entries+ try { entries = readdirSync(base, { withFileTypes: true }) } catch { continue }+ for (const e of entries) {+ if (!e.isDirectory()) continue+ for (const probe of [join(base, e.name, 'expected.json'),+ join(base, e.name, 'fixtures', 'expected.json')]) {+ try { readFileSync(probe); return probe.replace(ROOT + '/', '') } catch { /* keep looking */ }+ }+ }+ }+ return null+}+function sharedCorpus() {- const dir = join(ROOT, 'tray/fixtures')+ const dir = join(ROOT, 'home/fixtures')let expectedtry { expected = JSON.parse(readFileSync(join(dir, 'expected.json'), 'utf8')) } catch { return null }@@ -470,10 +507,20 @@ if (known.length) {}if (shared) {- console.log(` shared corpus (tray/fixtures): ${shared.count} cases` ++ console.log(` shared corpus (home/fixtures): ${shared.count} cases` +(shared.bad.length ? ` — ${shared.bad.length} DISAGREE` : ' — all agree'))} else {- console.log(' shared corpus (tray/fixtures): absent, skipped — arrives with home/android')+ console.error(' shared corpus (home/fixtures): MISSING — expected.json did not load.')+ console.error(' This corpus has landed; absent means a moved or broken path, not "not yet".')+ const stray = strayCorpus()+ if (stray) {+ console.error(` It IS at ${stray} — this rig's path is stale. Update the path;`)+ console.error(' do not restore the skip that hid this for weeks.')+ }+ // exitCode, not exit(): the Swift-diff summary above has already printed and+ // the disagreement report below still needs to. A stale path must not withhold+ // the other half of the rig from the reader.+ process.exitCode = 1}if (failures.length || shared?.bad.length) {@@ -482,7 +529,7 @@ if (failures.length || shared?.bad.length) {console.error(failures.join('\n\n'))}if (shared?.bad.length) {- console.error('\nDisagreements with the shared corpus (tray/fixtures/expected.json):\n')+ console.error('\nDisagreements with the shared corpus (home/fixtures/expected.json):\n')console.error(shared.bad.join('\n'))}process.exit(1)