Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
Merge remote-tracking branch 'origin/main' into claude/i18n-pack-gate
nyblnetd66efa853d6d
diff --cc docs/DECISIONS.mdindex d3e9ceed,80cc83ae..e40311f8--- a/docs/DECISIONS.md+++ b/docs/DECISIONS.md@@@ -14,54 -14,59 +14,107 @@@ Decision. Why. Pointers---+## 2026-07-26 — A language pack lives in the FILE and nowhere else++No browser-local install. A "keep it on this computer" option (localStorage)+was **built and then removed**, because `localStorage` is scoped per ORIGIN+and that is fatally misaligned with how Bento is used: the download comes from+`bento.page` (an https origin) and the file is then opened from disk (a+`file://` origin). A language added on the website was therefore GONE the+moment the user saved the deck and reopened it locally — the exact journey the+product encourages, and "I added Korean and it vanished" is not a bug a user+can diagnose.++One home also matches the platform: the file *is* the software, so a language+belongs to the deck. The trade — adding a language requires saving the file —+is stated plainly in the UI ("Added when you next save") rather than hidden.+Adding is staged on click and written on the next save because on browsers+without File System Access, writing on click means silently downloading a+second copy of the user's deck.++Corollary: anything that remembers pack *content* outside the file+reintroduces this. Viewer *preferences* (locale, reduce-motion) stay+browser-local on purpose; that asymmetry is deliberate. Details:+`docs/i18n-packs.md`, `slides/src/packs.ts`.++## 2026-07-26 — The pack carrier is generic; pack POLICY is not. This is not a plugin system.++The kernel mechanism is already extension-agnostic and should stay that way:+`registerShellBlocks` / `readShellBlocks` (`kernel/src/save.ts`) carry+arbitrary typed blocks in the shell and know nothing about languages, and+`registerUpdatePrepare` (`kernel/src/update.ts`) is a generic "refresh+version-bound extras" hook. Signature verification and hash pinning are being+made generic in the kernel too (branch `claude/i18n-pack-verify`). Reuse all+of that freely.++**Do not generalize the policy.** Language packs are DATA and their worst case+is bounded — a tampered or stale pack shows wrong or English words. That bound+is why degrade-per-string, keep-on-refresh-failure, and auto-refresh on update+are the right rules *for packs*.++Anything carrying CODE is categorically different: unbounded failure (it would+hold the document, the file handle, and the collab keys), and it breaks the+property that makes self-update trustworthy — that the shell only ever runs+bytes from a signed release. Such a thing would need its own policy (pinned at+install, never auto-refreshed) and must not inherit the pack rules by reusing+the pack machinery.++So: reuse the carrier and the crypto; do not treat "we have packs" as evidence+that a plugin system is designed or wanted. It is not.++ ## 2026-07-26 — Side-loaded artifacts: sign the index, pin the bytes, fail closed++ Language packs are fetched over the network, so they get the **same two-step+ the app shell's own update already gets**: an envelope signed with the release+ key (`{payload, sig}`, ECDSA P-256 / SHA-256) whose payload pins each+ artifact's `sha256`, and a download that is accepted only if its bytes hash to+ that pin. Signature over the pin, pin over the bytes. **No second key and no+ second trust root** — `PUBLIC_KEY_JWK` in `kernel/src/update.ts` is it.++ The mechanism lives in the kernel (`verifySigned`, `fetchPinned`) because it is+ the same for anything side-loaded; the *policy* stays in the app+ (`slides/src/packs.ts`). Keep that boundary: the kernel helpers verify BYTES,+ they do not decide what is safe to use. Packs are DATA with a bounded failure+ mode (wrong words on screen), which is why a pack that fails a refresh is kept+ at its existing version rather than dropped. Anything side-loaded that ever+ carries CODE needs stricter policy — pinned at install, never auto-refreshed —+ and must not inherit the pack rules by reusing the same fetch.++ **Fail closed, no legacy path.** An unsigned or unpinned index yields no+ listings at all. Nothing is published yet, so there is no permissive fallback+ to keep — and one added later would mean whoever answers for the channel picks+ the strings in the UI.++ **A pack already inside a file is NOT re-verified** (`readPacksFromShell`). It+ was verified at the door, and once spliced it carries exactly the trust the+ document does — anyone who can rewrite that block can rewrite the checking+ code too. Re-verifying would need the network at boot, which breaks offline+ use. Proof rig: `node scripts/test-packs.ts` (throwaway key, real crypto).++ ## 2026-07-26 — Language packs are published under a SIGNED INDEX, separate from the manifest++ Amends the "Signing and release" paragraph of `docs/i18n-packs.md`, which said+ the update manifest would gain a `packs` array. It does not.++ `release.mjs` emits the packs and signs **one index** over all of them at+ `releases/slides/packs.json` — the same `{payload, sig}` envelope, the same+ offline key, and literally the same signing code as the manifest (extracted to+ `scripts/sign-payload.mjs`). Each listing pins its pack's `sha256`; individual+ packs are not separately signed. Clients verify the index once, then hash each+ download against its signed hash.++ Why not inside the manifest: shipped files ignore a manifest that is not+ strictly newer than themselves (downgrade-replay protection), so pack hashes+ carried there could never be corrected **between** app releases — and a fixed+ translation is not a new app version. A separate index is re-issuable any day,+ and `manifest.json` keeps meaning exactly one thing: here is the app shell.+ Signed code and signed data stay two artifacts.++ Still one key, still local-only signing, and `publish-site.mjs` now gates the+ index the way it already gates the shell (indexed pack missing, hash drifted,+ or packs staged with no index = refuse to publish). Details and the exact+ payload shape: `docs/i18n-packs.md` §"Signing and release"; `scripts/sign-packs.mjs`.+## 2026-07-25 — i18n: a bundled core of 9 languages, everything else a signed packThe 7 non-English catalogs cost **115,572 B** of the shell even after key-oncediff --cc docs/i18n-packs.mdindex 2b80ab1d,2003db97..d4081767--- a/docs/i18n-packs.md+++ b/docs/i18n-packs.md@@@ -103,45 -101,66 +103,97 @@@ Per-language maps, not the bundled posiand reviewed as one language, and positional arrays would couple every pack toa column order.- ### Signing and release+ ### Signing and release — the signed pack index- Packs reuse the existing release machinery **exactly** — ECDSA P-256 over the- sha256, verified against the `PUBLIC_KEY_JWK` already embedded in every shell- (`PLATFORM.md` §6). The private key stays offline; `release.mjs` emits and- signs packs beside the shell, and the manifest gains a `packs` array listing- `{lang, version, sha256, url}`. No new trust root, no second key.+ Packs reuse the existing release machinery **exactly** — ECDSA P-256 /+ SHA-256, verified against the `PUBLIC_KEY_JWK` already embedded in every shell+ (`PLATFORM.md` §6). The private key stays offline and `release.mjs` runs+ locally. No new trust root, no second key.++ **The INDEX is signed; individual packs are not.** `release.mjs` emits the+ packs and then signs one index over all of them:++ ```+ https://bento.page/releases/slides/+ manifest.json signed — the app shell+ packs.json signed — the pack index+ packs/bento-slides-1.0.11-ko.pack.json the packs themselves+ ```++ `packs.json` is the same envelope as the manifest, produced by the same code+ (`scripts/sign-payload.mjs`, shared by `sign-release.mjs` and `sign-packs.mjs`):++ ```json+ { "payload": "<the exact json string that was signed>", "sig": "<base64>" }+ ```++ and the payload is++ ```json+ { "app": "bento-slides", "version": "1.0.11", "at": "<iso>",+ "packs": [ { "lang": "ko", "label": "한국어", "version": "1.0.11",+ "url": "packs/bento-slides-1.0.11-ko.pack.json",+ "sha256": "<hex, lowercase>", "bytes": 60114 } ] }+ ```++ `sig` is ECDSA P-256 / SHA-256 over `payload`'s **UTF-8 string bytes**, IEEE+ P1363 (raw r‖s), base64 — byte-identical in construction to the manifest, so+ the client verifies both with the same handful of lines.++ The client's job is therefore the same two-step the shell already performs for+ its own update: **verify the index signature once, then hash each downloaded+ pack against its signed `sha256`.** A pack that does not match its pinned hash+ is refused. `url` is relative to the channel unless absolute — so a dev+ channel (`localStorage 'bento-packs-url'`) serves its own packs rather than+ silently reaching back to bento.page.++ Two reasons this is a separate artifact from `manifest.json` rather than a+ `packs` array inside it:++ - **Packs publish on their own clock.** A corrected translation is not a new+ app version — but shipped files ignore a manifest that is not strictly+ *newer* than themselves (downgrade-replay protection), so a hash carried in+ the manifest could never be corrected *between* releases. A separate index is+ re-issuable any day.+ - **The manifest keeps meaning one thing:** here is the app shell. The update+ channel ships signed *code*; the pack channel ships signed *data*.++ `publish-site.mjs` gates on this before pushing: every indexed pack must exist+ and match its signed hash, no published pack may be missing from the index, and+ staged packs without an index refuse to publish at all. Signed bytes are served+ bytes — for the index exactly as for the shell.+### Verification: what is checked, and what deliberately is not++> **Landing separately.** The design below is settled; the client-side+> implementation is on branch `claude/i18n-pack-verify`. Until that merges,+> `fetchPack` validates *shape* only (`lang`, `strings`, matching `app`) — do+> not read this section as describing shipped behaviour.++Two rules, and the asymmetry between them is the point.++- **A pack fetched from the network is verified.** The pack *index* is signed+ with the release key; each entry pins its pack by sha256. So a client+ verifies the index signature once, then checks the bytes it downloaded+ against the signed hash — the same two-step the shell itself goes through on+ self-update. You cannot substitute a pack without breaking its hash, and you+ cannot fix the hash without breaking the signature. A pack that fails is+ refused, not degraded: a *wrong* pack is worse than no pack, and there is a+ working English fallback right there.+- **A pack already embedded in a file is NOT re-verified.** It carries exactly+ the same trust as the document it travels with: someone who can rewrite a+ block in your `.bento.html` can rewrite the document, the CRDT state and the+ collab keys in the same file, so re-checking one block buys nothing.+ Re-verification would also mean a *network round trip to open a deck*, which+ breaks the property the whole format exists for — a file that works offline,+ forever, from `file://`. The blast radius is bounded in a way that makes+ this an easy trade: a pack is DATA, and its worst case is wrong words on+ screen.++That bound is load-bearing and does not transfer. See `docs/DECISIONS.md` —+the carrier is generic, the policy is not, and nothing carrying **code** may+inherit these rules.+### Loading`registerI18n` already accepts a packed table (kernel). Pack loading adds a@@@ -291,34 -259,34 +387,52 @@@ turns native review into a continuous pself-contained? Slides, Spaces and Dash have overlapping but distinct stringsets.- Should a saved deck record which packs it carries, for the People/About UI?+ (Partly answered: the Languages dialog reads them straight out of the shell,+ so nothing needs recording in the *document*.)+- Should a spliced pack be compressed? It is written as plaintext JSON today,+ which is simple and keeps the splice contract trivially checkable; the shell+ already has deflate+base64 payload blocks that would roughly halve it, at+ the cost of a second block shape for the gate to reason about.- ## Status+ ## Splicing a pack into a file — compress it++ Measured on the Korean pack: **56.8 KB raw JSON, 26.4 KB** through the+ deflate+base64 pipeline the shell already uses for its runtime payloads.- Answered: **is this shipped?** Anything marked *branch* is designed and- written but not merged — do not describe it as shipped.+ Leave the artifact on the CDN **uncompressed** — GitHub Pages gzips it in+ transit anyway (17–20 KB on the wire), and a readable `.json` is worth keeping+ for translators. But the splice step MUST compress, because a spliced pack+ lives in every saved copy of that file forever: **30 KB per file, per+ language, permanently**, and unfixable once files are in the wild. Reuse+ `postbuild-compress.mjs`'s existing block format rather than inventing a+ second one.++ ## Status- - [x] Key-once packing of the bundled catalogs (PR #75) — the prerequisite:- it shrank the core, and its kernel change (`registerI18n` accepting a- packed table) is the loading path packs reuse.- - [x] Portuguese catalog, bundled (PR #79)- - [x] Pack format + `build-i18n.mjs --packs` emission, Korean first (PR #81)- - [x] Runtime loading: `addPack`/`removePack`, per-string fallback- (`kernel/src/i18n.ts`)-- [x] Key-once packing of the bundled catalogs — #75++Answered: **is this shipped?** Anything marked *branch* is written and green++but not yet on `main` — do not describe it as shipped.++++- [x] Key-once packing of the bundled catalogs — #75. The prerequisite: it++ shrank the core, and its kernel change (`registerI18n` accepting a packed++ table) is the loading path packs reuse.+ - [x] Portuguese catalog, bundled — #79-- [x] Pack format + `build-i18n.mjs --packs` emitting them — #81-- [x] Kernel `addPack()` loading path — #81-- [x] Korean, the first pack (662/662) — #81-- [x] `release.mjs` emits packs and publishes `packs.json`, a **signed index**- pinning each pack's sha256 — same envelope, same offline key, no second- trust root. Gated at publish time.-- [ ] Client: verify the index signature + each pack's pinned hash- (`slides/src/packs.ts` — the shape it must expect is specified above)-- [ ] In-app "Add language…" (fetch → verify → splice, compressed)-- [ ] **Update carries packs forward**-- [ ] Shell smoke check covers a pack-carrying shell (note: `shell-gate.mjs`- deliberately checks only the splice contract — it passed a build with a- silently corrupted stylesheet, so it is the wrong place for this)++- [x] Pack format + `build-i18n.mjs --packs` emission, Korean first — #81++- [x] Kernel loading path: `addPack`/`removePack`, per-string fallback — #81++- [x] `release.mjs` emits packs at release time — #91++- [x] **Signed pack index** (`packs.json`) published to the channel, pinning++ each pack's sha256 — same envelope, same offline key, no second trust++ root; gated at publish time — #93+- [x] In-app "Add language…" / "Remove", staged and written on the next save- — *branch `claude/i18n-pack-ui`, PR #86*- - [x] **Update carries packs forward** + `refreshPacksForVersion` — same branch- - [x] Per-pack staleness note from `packCoverage` — same branch- - [x] `shell-gate.mjs` covers a pack-carrying shell — *branch- `claude/i18n-pack-gate`, stacked on #86*- - [ ] `release.mjs` publishing packs + the signed manifest `packs` array —- *branch `claude/i18n-pack-release`*- - [ ] Client-side signature/hash verification of fetched packs —- *branch `claude/i18n-pack-verify`*- - [ ] A published pack index at the release channel (`packs.json`), so- "Available to add" is non-empty in the wild++ — #86++- [x] Update carries packs forward (`refreshPacksForVersion`) — #86++- [x] Per-pack staleness note from `packCoverage` — #86++- [x] Client verifies the index signature and each pack's pinned hash, fails++ closed; proof rig `scripts/test-packs.ts` — #94++- [x] `shell-gate.mjs` covers a pack-carrying shell, including an adversarial++ block both below AND above `#bento-doc`; mutation-tested — *branch++ `claude/i18n-pack-gate`, PR #95*++- [x] Removing a file's LAST pack now actually sticks — *PR #96*++- [x] Hebrew (he), 683/683 — the first RTL language — *PR #100*++- [ ] A pack index live on the channel in the wild — needs an actual release++ cut, so "Available to add" stays empty until then.++- [ ] Native-speaker review of the Hebrew pack before it is published.