Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

kernel: one gate-1 verifier, and the conformance corpus every host runs (K5) (#825)

nyblnet6b9f50420f18
diff --git a/.github/actions/validate-kernel/action.yml b/.github/actions/validate-kernel/action.yml
index 222487bf..a3f91ddb 100644
--- a/.github/actions/validate-kernel/action.yml
+++ b/.github/actions/validate-kernel/action.yml
@@ -97,6 +97,15 @@ runs:
shell: bento-step {0}
run: node scripts/test-release-history.ts
+ - name: gate 1 — the shared verifier against the conformance corpus
+ # bento/connect K5: kernel/src/gate1.ts, the one JavaScript gate-1
+ # verifier, against home/fixtures/gate1/ read from disk as every host
+ # reads it. The served path (one release matches every block, under the
+ # grammar), the strict file:// path (both genuine saves pass, all 16
+ # tampers refuse), anti-rollback, and the CSP a host serves under.
+ shell: bento-step {0}
+ run: node scripts/test-gate1.ts
+
- name: Language pack verification rig
# Packs come off the network, so the signature + hash-pin chain is the
# only thing between a hostile channel and the strings in the UI.
diff --git a/.github/workflows/ci-slides.yml b/.github/workflows/ci-slides.yml
index 70cf0fd1..74bea133 100644
--- a/.github/workflows/ci-slides.yml
+++ b/.github/workflows/ci-slides.yml
@@ -38,9 +38,11 @@ jobs:
node-version: 24
- name: Install browser test runtime
# Pinned outside app packages: browser automation is not shipped in documents.
+ # WebKit too, for the gate-1 oracle: a Chromium-only oracle missed a bypass
+ # that a WebKit oracle found.
run: |
npm install --prefix "$RUNNER_TEMP/bento-browser" --no-package-lock --ignore-scripts [email protected]
- "$RUNNER_TEMP/bento-browser/node_modules/.bin/playwright" install --with-deps chromium
+ "$RUNNER_TEMP/bento-browser/node_modules/.bin/playwright" install --with-deps chromium webkit
echo "PLAYWRIGHT_MODULE=$RUNNER_TEMP/bento-browser/node_modules/playwright/index.mjs" >> "$GITHUB_ENV"
- name: Build the tested standalone documents
run: |
@@ -66,6 +68,15 @@ jobs:
# or on the loader's own lines is reported, and the rig checks WHICH
# refusal was excused, not just how many. A wrong loader pin never boots.
run: node scripts/test-csp-boot-browser.mjs
+ - name: Gate 1 against a browser oracle in Chromium
+ # K5 (security): a differential fuzz can't see a bug the reference and a
+ # port SHARE, and both the "/" attribute separator and the length-changing
+ # case fold were shared. So genuine files are mutated the ways scanners
+ # split, and every mutant gate1 calls GENUINE is loaded with NO CSP, in
+ # Chromium AND WebKit: exactly the loader and the remover may run. A fixed seed, plus a short
+ # random run whose seed is printed for replay. Any failure is written to
+ # home/fixtures/gate1/oracle-failures/ as a corpus row.
+ run: node scripts/test-gate1-oracle.mjs
- name: A sealed slides deck keeps its content out of IndexedDB in Chromium
# The autosave and ⌘S checkpoints write no recovery copy or version for
# a deck sealed by identity; the password menu stays keyed to the
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md
index d2fae44e..c5ff439c 100644
--- a/docs/DECISIONS.md
+++ b/docs/DECISIONS.md
@@ -11791,6 +11791,30 @@ resolves to a `data:` font in the document's own assets, and drops anything
else to the base design's font. It is recorded so that a later change does not
add a web-font fetch.
+## 2026-10-21 — bento/connect K5: one gate-1 verifier, and the corpus every host runs
+
+`kernel/src/gate1.ts` is the ONE gate-1 implementation for every JavaScript
+host (the extension, the hosted runtime) and for the release tooling. The K4
+scripts import its scanner, grammar and host rules rather than carrying copies.
+It hashes with WebCrypto, so it runs in a page, a worker, an extension and node.
+- **`verifyServed(html, history)`** is the PRIMARY path, for a host that serves
+ the bytes it verified (security §17). ONE release must match EVERY block
+ under the grammar (§36 and the 2026-10-21 ruling). The answer carries the CSP
+ to serve under (`hostPolicy`). Unknown never borrows a release's CSP.
+- **`verifyStrict(html, expected)`** is the file:// fallback: vault's strict
+ verifier, signed off in security §15. The final whole-string compare, bound
+ at both ends, is the load-bearing part. Its expectation comes from a genuine
+ saved file of the release (`strictExpectedFrom`). A signed skeleton waits for
+ canonical save, and a file:// result is never grounds for identity (§16).
+- **`home/fixtures/gate1/`** is the conformance corpus: a synthetic app's signed
+ history (with a test key), served rows, the 16 strict tamper rows plus two
+ genuine saves, anti-rollback rows, and an ambiguous-history row. Every row
+ DECLARES its verdict, and the generator refuses to write the corpus if the
+ reference disagrees, so the answers are the rules, not what the JS happens to
+ do. Native hosts (Swift, Kotlin, Rust) port gate 1 and must pass every row.
+ Encodings are stated per field: block pins are sha256 HEX of the block text,
+ `scriptSrc` is `'sha256-'` + BASE64, and the entry `sha256` is HEX of the
+ shell file.
## 2026-10-21 — bento/connect in the extension: Argon2id is @noble/hashes, and the recovery code is generated from kernel
**Argon2id is `@noble/hashes` 2.4.0, vendored, not hash-wasm.** The recovery
diff --git a/home/fixtures/README.md b/home/fixtures/README.md
index 728850d7..5d31d2d1 100644
--- a/home/fixtures/README.md
+++ b/home/fixtures/README.md
@@ -1,5 +1,8 @@
# home/fixtures — the document-indexing contract
+(The gate-1 conformance corpus, for deciding whether a file's runtime is a
+genuine Bento release, is a separate contract in [`gate1/`](gate1/README.md).)
+
Every bento/tray host answers the same questions about a file it did not write:
is this one of ours, what is it called, which app is it, is it encrypted, what
does its first page look like, and what words does it contain.
diff --git a/home/fixtures/gate1/README.md b/home/fixtures/gate1/README.md
new file mode 100644
index 00000000..6b10c1c9
--- /dev/null
+++ b/home/fixtures/gate1/README.md
@@ -0,0 +1,140 @@
+# home/fixtures/gate1 — gate 1: is this runtime a genuine release?
+
+Every host that offers bento/connect identity must first decide whether a
+file's runtime is one of Bento's genuine releases. Several hosts implement that
+in their own languages: the extension and the hosted runtime in JavaScript,
+iOS in Swift, Android in Kotlin, desktop in Rust. **This corpus holds them
+together.** `kernel/src/gate1.ts` is the reference. Every row here declares its
+expected verdict, and every host's verifier must reach it.
+
+The verdicts are the RULES (security §13–§18, §36, and the 2026-10-21 grammar
+ruling). They aren't derived from the reference: the generator
+(`scripts/gen-gate1-corpus.ts`) refuses to write the corpus if the reference
+disagrees with any declared verdict.
+
+| host | rig |
+|---|---|
+| reference (JS, kernel/src/gate1.ts) | `node scripts/test-gate1.ts` |
+| `home/ios` (Swift) | to build |
+| `home/android` (Kotlin) | to build |
+| `home/desktop` (Rust) | to build |
+
+## The files
+
+- `history.json`: the signed release history of a synthetic app, `bento-test`,
+ in the same envelope as the real one (`{ payload, sig }`, ECDSA P-256 SHA-256,
+ IEEE P1363 r‖s, base64). It's signed with a **throwaway test key**, whose
+ public half is `test-public-key.json`. Verify it exactly as you verify the
+ real history with the release key. The signature is random, so regenerating
+ changes it, but no verdict.
+- `served/*.html`: files for the **served path** (`verifyServed`).
+- `strict/*.html` and `strict-expected.json`: the **file:// fallback**
+ (`verifyStrict`).
+- `expected.json`: the answer key, with four sections: `served`, `ambiguous`,
+ `strict` and `history`.
+
+The releases in the history:
+- **1.0.0 and 1.1.0** share a runtime and differ in their loader;
+- **1.2.0** has its own runtime;
+- **0.9.0** is from before previews, so it saves no remover.
+
+## Encodings, per field (never compare across them)
+
+| field | encoding |
+|---|---|
+| `pins.blocks.*` (`bento-rt`, `bento-rt-css`, `loader`, `remover`) | sha256 **HEX**, lowercase, of the block's TEXT (UTF-8) |
+| `pins.scriptSrc[]` | `'sha256-'` + **BASE64** (standard, padded) of the same text: the CSP form |
+| history entry `sha256` | sha256 **HEX** of the release's whole shell FILE (bytes) |
+| `remover` | `null` for a release from before previews |
+
+A block's TEXT is everything between its open tag's `>` and the first `</script`
+or `</style`, in ANY case, as the HTML tokenizer ends it.
+
+Two parsing rules the reference got wrong once, so state them exactly:
+- **Read attributes as a browser does.** Names are separated by whitespace (tab,
+ LF, FF, CR, space) OR by `/`. A quoted value ends an attribute even with no
+ separator after it. A leading `=` is part of a name. Names fold ASCII-only,
+ and the FIRST of duplicate names wins. A `<script>` tag with a duplicate
+ attribute or a `/` is refused outright, because Bento writes neither.
+- **Fold case in ASCII only, never with a length-changing fold.** `toLowerCase()`
+ turns `İ` into two UTF-16 units. Searching a folded copy while slicing the
+ original then drifts: a genuine Turkish document reads as unknown, and a run
+ of `İ` before a `<style>` hides a later script.
+
+## The served path: the rules
+
+A file is a release's only if ONE history entry matches EVERY block:
+1. **Exactly one block per id:** `bento-rt`, `bento-rt-css`, each hash equal to
+ its pin.
+2. **The grammar.** A `<script>` is inert ONLY if its `type` is exactly one of
+ `application/bento+json`, `application/bento+lang`, `bento/deflate-b64` or
+ `bento/deflate-b86`. The match is case-sensitive, and the script must have no
+ `src`. EVERY other script is executable, and each must be exactly the pinned
+ loader or remover by hash. That includes no type, any JavaScript type,
+ `module` in any case, an unknown type, and any `src=`.
+3. **No foreign markup**, anywhere outside a script or style element's own text:
+ - `<iframe>`, `<object>`, `<embed>`, `<base>`;
+ - a `<meta http-equiv>` refresh or CSP;
+ - any `on*=` attribute;
+ - a comment or `<style>` holding `<script`;
+ - a data block containing `<`. Bento's never do: the JSON is escaped and the
+ b64/b86 alphabets exclude it.
+4. **No match, a partial match, or two matching entries:** UNKNOWN.
+
+The verdict comes with the CSP to serve the file under (`hostPolicy`):
+`script-src` is the two pins plus `blob:`, styles are `'unsafe-inline'`, and
+everything else is closed. UNKNOWN never borrows a release's CSP.
+
+The scanner-split rows are the ones scanners have been seen to read
+differently:
+- uppercase `SCRIPT`;
+- `type="Module"`;
+- a NUL in an attribute name;
+- unquoted and single-quoted attributes;
+- `</script >`;
+- tabs and newlines inside a tag;
+- a script inside a comment, `<textarea>`, `<title>` or `<style>`.
+
+Your scanner must agree on every one of them.
+
+## The strict path (file://)
+
+`strict-expected.json` holds a genuine save's SKELETON: the whole file with
+three spans collapsed to placeholders, each type-checked first:
+- the doc block: its exact opening tag, no `<` in its body;
+- the preview: no script, no `on*` and no `javascript:` in its markup, then
+ exactly the release's remover;
+- the `<title>`.
+
+A file passes only if, collapsed the same way, it equals the skeleton **byte
+for byte over the whole string, bound at both ends**. That final compare is
+load-bearing: it's what catches security's adversarial rows (trailing or
+leading bytes, CRLF, `<\tscript>`, uppercase preview scripts).
+
+Both genuine saves pass, and all 16 tamper rows refuse. A file:// result is
+never grounds for identity calls (security §16): only a host that serves the
+bytes it verified may expose identity.
+
+## The browser oracle
+
+`scripts/test-gate1-oracle.mjs` asks a browser, the ground truth for "what runs".
+A differential fuzz between the reference and a port can't see a bug they share,
+and two such bugs were found in the reference: `/` as an attribute separator, and
+a case fold that changed the string's length.
+
+The oracle mutates genuine files the ways scanners disagree. It loads every
+mutant gate1 calls GENUINE with no CSP, in BOTH Chromium and WebKit
+(`ORACLE_ENGINES`), and fails unless exactly the loader and the remover ran. One
+engine isn't enough: a Chromium-only run missed a bypass that a WebKit run found.
+
+Each failure is written to `oracle-failures/` with that release's unsigned
+`history.json`. Every file there is expected UNKNOWN against it. A port can run
+the folder as is; then promote the case into the generator as a declared row. A
+port that lifts the mutant generator should take the text between the
+`// --- a synthetic release` and `// --- the browsers` markers.
+
+## Changing the rules
+
+Change `kernel/src/gate1.ts` and the declared rows in
+`scripts/gen-gate1-corpus.ts`, regenerate, then re-run every host's rig. A host
+that can't match the corpus is the one that's wrong.
diff --git a/home/fixtures/gate1/expected.json b/home/fixtures/gate1/expected.json
new file mode 100644
index 00000000..f66105ec
--- /dev/null
+++ b/home/fixtures/gate1/expected.json
@@ -0,0 +1,1513 @@
+{
+ "note": "gate-1 conformance corpus (bento/connect K5). Every host must reach each verdict. Regenerate with node scripts/gen-gate1-corpus.ts; check with node scripts/test-gate1.ts.",
+ "app": "bento-test",
+ "served": [
+ {
+ "case": "served/genuine-1.0.0.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "a genuine saved file"
+ },
+ {
+ "case": "served/genuine-1.1.0-shared-runtime.html",
+ "verdict": "genuine",
+ "release": "1.1.0",
+ "why": "shares 1.0.0's runtime; the loader tells them apart"
+ },
+ {
+ "case": "served/genuine-1.2.0.html",
+ "verdict": "genuine",
+ "release": "1.2.0",
+ "why": "a genuine saved file"
+ },
+ {
+ "case": "served/genuine-0.9.0-no-remover.html",
+ "verdict": "genuine",
+ "release": "0.9.0",
+ "why": "a release from before previews saves no remover"
+ },
+ {
+ "case": "served/genuine-1.0.0-shell.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "the built shell itself: no preview yet"
+ },
+ {
+ "case": "served/genuine-other-content.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "the document, title and inert preview vary freely"
+ },
+ {
+ "case": "served/src-script.html",
+ "verdict": "unknown",
+ "why": "any src= is executable, and never pinned"
+ },
+ {
+ "case": "served/unknown-type.html",
+ "verdict": "unknown",
+ "why": "an unknown type is executable"
+ },
+ {
+ "case": "served/type-module.html",
+ "verdict": "unknown",
+ "why": "module is executable"
+ },
+ {
+ "case": "served/type-Module-case.html",
+ "verdict": "unknown",
+ "why": "module in any case is executable"
+ },
+ {
+ "case": "served/type-text-JavaScript.html",
+ "verdict": "unknown",
+ "why": "a JS type in mixed case is executable"
+ },
+ {
+ "case": "served/data-type-other-case.html",
+ "verdict": "unknown",
+ "why": "the data allowlist is exact: another case is executable"
+ },
+ {
+ "case": "served/uppercase-SCRIPT.html",
+ "verdict": "unknown",
+ "why": "an uppercase tag is still a script"
+ },
+ {
+ "case": "served/nul-in-type-name.html",
+ "verdict": "unknown",
+ "why": "a NUL makes it another attribute: the script has no type, so it runs"
+ },
+ {
+ "case": "served/extra-plain-script.html",
+ "verdict": "unknown",
+ "why": "an executable script that is neither the loader nor the remover"
+ },
+ {
+ "case": "served/loader-byte-changed.html",
+ "verdict": "unknown",
+ "why": "the loader no longer matches its pin"
+ },
+ {
+ "case": "served/runtime-byte-changed.html",
+ "verdict": "unknown",
+ "why": "the runtime block no longer matches its pin"
+ },
+ {
+ "case": "served/two-runtime-blocks.html",
+ "verdict": "unknown",
+ "why": "exactly one block per id"
+ },
+ {
+ "case": "served/loader-of-another-release.html",
+ "verdict": "unknown",
+ "why": "a partial match (1.0.0 runtime, 1.2.0 loader) is not a release"
+ },
+ {
+ "case": "served/iframe.html",
+ "verdict": "unknown",
+ "why": "<iframe>"
+ },
+ {
+ "case": "served/object.html",
+ "verdict": "unknown",
+ "why": "<object>"
+ },
+ {
+ "case": "served/embed.html",
+ "verdict": "unknown",
+ "why": "<embed>"
+ },
+ {
+ "case": "served/base.html",
+ "verdict": "unknown",
+ "why": "<base>"
+ },
+ {
+ "case": "served/meta-refresh.html",
+ "verdict": "unknown",
+ "why": "a <meta> refresh"
+ },
+ {
+ "case": "served/meta-csp.html",
+ "verdict": "unknown",
+ "why": "a <meta> CSP"
+ },
+ {
+ "case": "served/on-attribute.html",
+ "verdict": "unknown",
+ "why": "an on*= attribute"
+ },
+ {
+ "case": "served/on-attribute-in-preview.html",
+ "verdict": "unknown",
+ "why": "an on*= attribute inside the preview"
+ },
+ {
+ "case": "served/script-in-comment-before-loader.html",
+ "verdict": "unknown",
+ "why": "a comment holding a <script>"
+ },
+ {
+ "case": "served/script-in-textarea.html",
+ "verdict": "unknown",
+ "why": "a <script> inside <textarea>"
+ },
+ {
+ "case": "served/script-in-title.html",
+ "verdict": "unknown",
+ "why": "a <script> inside <title>"
+ },
+ {
+ "case": "served/script-in-style.html",
+ "verdict": "unknown",
+ "why": "a <style> holding a <script>"
+ },
+ {
+ "case": "served/doc-block-raw-lt.html",
+ "verdict": "unknown",
+ "why": "a data block containing \"<\" (Bento always escapes it)"
+ },
+ {
+ "case": "served/doc-block-double-escape.html",
+ "verdict": "unknown",
+ "why": "\"<!--<script\" inside a data block"
+ },
+ {
+ "case": "served/slash-before-js-type.html",
+ "verdict": "unknown",
+ "why": "\"/\" separates attributes: the browser reads the FIRST type, JavaScript, and runs it"
+ },
+ {
+ "case": "served/slash-module-first.html",
+ "verdict": "unknown",
+ "why": "\"/\" right after the tag name: the first type is module, and it runs"
+ },
+ {
+ "case": "served/duplicate-type-js-first.html",
+ "verdict": "unknown",
+ "why": "the FIRST duplicate wins: JavaScript"
+ },
+ {
+ "case": "served/no-separator-after-quoted.html",
+ "verdict": "unknown",
+ "why": "a quoted value ends the attribute with no separator: two types, the first JavaScript"
+ },
+ {
+ "case": "served/form-feed-js-type.html",
+ "verdict": "unknown",
+ "why": "form feed is a separator: a JavaScript type"
+ },
+ {
+ "case": "served/equals-without-value.html",
+ "verdict": "unknown",
+ "why": "type= with no value is the empty type, which runs"
+ },
+ {
+ "case": "served/leading-equals-name.html",
+ "verdict": "unknown",
+ "why": "an attribute NAMED \"=type\" is not type: the script has no type, so it runs"
+ },
+ {
+ "case": "served/entity-encoded-module.html",
+ "verdict": "unknown",
+ "why": "a browser decodes the type to \"module\""
+ },
+ {
+ "case": "served/doc-block-slash-duplicate.html",
+ "verdict": "unknown",
+ "why": "the doc block opened with a JavaScript type first: it runs (home-android)"
+ },
+ {
+ "case": "served/slash-in-data-tag.html",
+ "verdict": "unknown",
+ "why": "Bento never writes \"/\" in a script tag: refused outright, whatever it means"
+ },
+ {
+ "case": "served/form-feed-separators.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "form feed between attributes is whitespace: the same block"
+ },
+ {
+ "case": "served/src-with-loader-body.html",
+ "verdict": "unknown",
+ "why": "the browser runs the src and ignores the body: the genuine loader text is no excuse (home-android)"
+ },
+ {
+ "case": "served/meta-glued-style.html",
+ "verdict": "unknown",
+ "why": "\"<meta<style>\" is one tag: the script after it is real and runs"
+ },
+ {
+ "case": "served/p-glued-script.html",
+ "verdict": "unknown",
+ "why": "a start tag named \"p<script\": Bento writes only plain names"
+ },
+ {
+ "case": "served/div-glued-style.html",
+ "verdict": "unknown",
+ "why": "a start tag named \"div<style\""
+ },
+ {
+ "case": "served/a-glued-comment.html",
+ "verdict": "unknown",
+ "why": "a start tag named \"a<!--\""
+ },
+ {
+ "case": "served/empty-comment-then-script.html",
+ "verdict": "unknown",
+ "why": "\"<!-->\" is a whole comment: the script after it is real"
+ },
+ {
+ "case": "served/empty-comment-alone.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "\"<!-->\" and \"<!--->\" end at once: nothing after them is swallowed"
+ },
+ {
+ "case": "served/empty-comment-in-paragraph.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "\"<!-->\" ends at once: the paragraph after it is markup, not comment"
+ },
+ {
+ "case": "served/style-false-close.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "\"</stylex>\" doesn't end the style: the <b onclick> is style TEXT, not an element"
+ },
+ {
+ "case": "served/title-false-close.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "\"</titlex>\" doesn't end the title: the <b onclick> is title TEXT"
+ },
+ {
+ "case": "served/case-fold-breakout.html",
+ "verdict": "unknown",
+ "why": "a length-changing case fold would skip this script entirely"
+ },
+ {
+ "case": "served/genuine-length-changing-text.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "a genuine document in Turkish (and ß, ffi, Σ) is still genuine"
+ },
+ {
+ "case": "served/single-quoted-attributes.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "single-quoted attributes parse the same"
+ },
+ {
+ "case": "served/unquoted-attributes.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "unquoted attributes parse the same"
+ },
+ {
+ "case": "served/close-tag-with-space.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "\"</script >\" closes a block like \"</script>\""
+ },
+ {
+ "case": "served/tabs-and-newlines-in-tag.html",
+ "verdict": "genuine",
+ "release": "1.0.0",
+ "why": "whitespace between attributes is whitespace"
+ }
+ ],
+ "strict": [
+ {
+ "case": "strict/genuine-save1.html",
+ "ok": true,
+ "why": "a genuine save"
+ },
+ {
+ "case": "strict/genuine-save2.html",
+ "ok": true,
+ "why": "another genuine save: doc, title and preview differ"
+ },
+ {
+ "case": "strict/genuine-save-length-changing-text.html",
+ "ok": true,
+ "why": "a genuine save in Turkish (and ß, ffi)"
+ },
+ {
+ "case": "strict/sec1-transient-script.html",
+ "ok": false,
+ "why": "a script under a stripped selector (§13)"
+ },
+ {
+ "case": "strict/sec2-extra-preview-script.html",
+ "ok": false,
+ "why": "a second remover-shaped script"
+ },
+ {
+ "case": "strict/sec3-loader-byte.html",
+ "ok": false,
+ "why": "one loader byte changed"
+ },
+ {
+ "case": "strict/sec4-plain-script.html",
+ "ok": false,
+ "why": "a plain script"
+ },
+ {
+ "case": "strict/sec5-onclick.html",
+ "ok": false,
+ "why": "onclick on body"
+ },
+ {
+ "case": "strict/v1-doc-executable.html",
+ "ok": false,
+ "why": "the doc block retyped as executable"
+ },
+ {
+ "case": "strict/v2-script-in-preview.html",
+ "ok": false,
+ "why": "a script inside the preview markup"
+ },
+ {
+ "case": "strict/v3-onerror-in-preview.html",
+ "ok": false,
+ "why": "onerror inside the preview markup"
+ },
+ {
+ "case": "strict/v4-second-doc-anchor.html",
+ "ok": false,
+ "why": "a second doc anchor"
+ },
+ {
+ "case": "strict/s1-script-after-html.html",
+ "ok": false,
+ "why": "a trailing script after </html>"
+ },
+ {
+ "case": "strict/s2-trailing-bytes.html",
+ "ok": false,
+ "why": "trailing bytes"
+ },
+ {
+ "case": "strict/s3-leading-bytes.html",
+ "ok": false,
+ "why": "leading bytes before <!DOCTYPE"
+ },
+ {
+ "case": "strict/s4-uppercase-preview-script.html",
+ "ok": false,
+ "why": "an uppercase <SCRIPT DATA-BENTO-PREVIEW>"
+ },
+ {
+ "case": "strict/s5-decoy-preview-div.html",
+ "ok": false,
+ "why": "an attacker preview div placed to shift the span"
+ },
+ {
+ "case": "strict/s6-crlf.html",
+ "ok": false,
+ "why": "CRLF in the skeleton"
+ },
+ {
+ "case": "strict/s7-tab-script.html",
+ "ok": false,
+ "why": "\"<\\tscript>\""
+ }
+ ],
+ "history": [
+ {
+ "name": "first",
+ "held": null,
+ "incoming": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "ok": true,
+ "why": "the first history a host sees"
+ },
+ {
+ "name": "newer-superset",
+ "held": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "incoming": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "ok": true,
+ "why": "a newer history keeping every held entry"
+ },
+ {
+ "name": "same-again",
+ "held": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "incoming": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "ok": true,
+ "why": "the same history again"
+ },
+ {
+ "name": "replayed-older",
+ "held": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "incoming": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "ok": false,
+ "why": "ROLLBACK: a replayed older history"
+ },
+ {
+ "name": "lacks-held-entry",
+ "held": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "incoming": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "ok": false,
+ "why": "ROLLBACK: it lacks an entry the host holds"
+ },
+ {
+ "name": "changed-entry",
+ "held": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "incoming": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "ok": false,
+ "why": "an entry changed"
+ },
+ {
+ "name": "other-app",
+ "held": null,
+ "incoming": {
+ "app": "bento-other",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "ok": false,
+ "why": "another app's history"
+ },
+ {
+ "name": "not-newest-first",
+ "held": null,
+ "incoming": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ }
+ ]
+ },
+ "ok": false,
+ "why": "malformed: not newest first"
+ }
+ ],
+ "ambiguous": [
+ {
+ "case": "served/twin-entries.html",
+ "history": {
+ "app": "bento-test",
+ "v": 1,
+ "releases": [
+ {
+ "version": "1.3.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.2.0",
+ "sha256": "598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d",
+ "bento-rt-css": "2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51",
+ "loader": "aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.1.0",
+ "sha256": "81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "1.0.0",
+ "sha256": "3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e",
+ "bento-rt-css": "b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457",
+ "loader": "ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a",
+ "remover": "960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659"
+ },
+ "scriptSrc": [
+ "sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=",
+ "sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk="
+ ]
+ }
+ },
+ {
+ "version": "0.9.0",
+ "sha256": "c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47",
+ "at": "2026-10-21T00:00:00.000Z",
+ "pins": {
+ "v": 1,
+ "blocks": {
+ "bento-rt": "831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb",
+ "bento-rt-css": "bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d",
+ "loader": "2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7",
+ "remover": null
+ },
+ "scriptSrc": [
+ "sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc="
+ ]
+ }
+ }
+ ]
+ },
+ "verdict": "unknown",
+ "why": "two entries match every block: ambiguous"
+ }
+ ]
+}
diff --git a/home/fixtures/gate1/history.json b/home/fixtures/gate1/history.json
new file mode 100644
index 00000000..99c860fc
--- /dev/null
+++ b/home/fixtures/gate1/history.json
@@ -0,0 +1,4 @@
+{
+ "payload": "{\"app\":\"bento-test\",\"v\":1,\"releases\":[{\"version\":\"1.2.0\",\"sha256\":\"598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e\",\"at\":\"2026-10-21T00:00:00.000Z\",\"pins\":{\"v\":1,\"blocks\":{\"bento-rt\":\"abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d\",\"bento-rt-css\":\"2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51\",\"loader\":\"aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c\",\"remover\":\"960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659\"},\"scriptSrc\":[\"sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=\",\"sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk=\"]}},{\"version\":\"1.1.0\",\"sha256\":\"81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713\",\"at\":\"2026-10-21T00:00:00.000Z\",\"pins\":{\"v\":1,\"blocks\":{\"bento-rt\":\"89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e\",\"bento-rt-css\":\"b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457\",\"loader\":\"0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104\",\"remover\":\"960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659\"},\"scriptSrc\":[\"sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=\",\"sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk=\"]}},{\"version\":\"1.0.0\",\"sha256\":\"3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d\",\"at\":\"2026-10-21T00:00:00.000Z\",\"pins\":{\"v\":1,\"blocks\":{\"bento-rt\":\"89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e\",\"bento-rt-css\":\"b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457\",\"loader\":\"ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a\",\"remover\":\"960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659\"},\"scriptSrc\":[\"sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=\",\"sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk=\"]}},{\"version\":\"0.9.0\",\"sha256\":\"c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47\",\"at\":\"2026-10-21T00:00:00.000Z\",\"pins\":{\"v\":1,\"blocks\":{\"bento-rt\":\"831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb\",\"bento-rt-css\":\"bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d\",\"loader\":\"2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7\",\"remover\":null},\"scriptSrc\":[\"sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc=\"]}}]}",
+ "sig": "n8omewr7M5y01+na7mr9N0Zt7IF8kGHfZ5LUTA3aVA6ZZBRMcme++gVUggysFrSTxePh/Z8YmqHZP/Jmy2ZBbg=="
+}
diff --git a/home/fixtures/gate1/served/a-glued-comment.html b/home/fixtures/gate1/served/a-glued-comment.html
new file mode 100644
index 00000000..79e91813
--- /dev/null
+++ b/home/fixtures/gate1/served/a-glued-comment.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<a<!-- x --></body></html>
diff --git a/home/fixtures/gate1/served/base.html b/home/fixtures/gate1/served/base.html
new file mode 100644
index 00000000..972016a1
--- /dev/null
+++ b/home/fixtures/gate1/served/base.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<base href="https://evil.example/"></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/case-fold-breakout.html b/home/fixtures/gate1/served/case-fold-breakout.html
new file mode 100644
index 00000000..cbd9bdcc
--- /dev/null
+++ b/home/fixtures/gate1/served/case-fold-breakout.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<p>İİİİİİİİİİİİİİİİİİİİ</p><style>a{}</style><script>window.pwned=1</script></body></html>
diff --git a/home/fixtures/gate1/served/close-tag-with-space.html b/home/fixtures/gate1/served/close-tag-with-space.html
new file mode 100644
index 00000000..b87c537a
--- /dev/null
+++ b/home/fixtures/gate1/served/close-tag-with-space.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script >
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/data-type-other-case.html b/home/fixtures/gate1/served/data-type-other-case.html
new file mode 100644
index 00000000..b57c59cd
--- /dev/null
+++ b/home/fixtures/gate1/served/data-type-other-case.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="Application/Bento+JSON" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/div-glued-style.html b/home/fixtures/gate1/served/div-glued-style.html
new file mode 100644
index 00000000..d166814a
--- /dev/null
+++ b/home/fixtures/gate1/served/div-glued-style.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<div<style>a{}</style></body></html>
diff --git a/home/fixtures/gate1/served/doc-block-double-escape.html b/home/fixtures/gate1/served/doc-block-double-escape.html
new file mode 100644
index 00000000..7d9e71c4
--- /dev/null
+++ b/home/fixtures/gate1/served/doc-block-double-escape.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"<!--<script>"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/doc-block-raw-lt.html b/home/fixtures/gate1/served/doc-block-raw-lt.html
new file mode 100644
index 00000000..ecd7feed
--- /dev/null
+++ b/home/fixtures/gate1/served/doc-block-raw-lt.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"<b>"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/doc-block-slash-duplicate.html b/home/fixtures/gate1/served/doc-block-slash-duplicate.html
new file mode 100644
index 00000000..eb051006
--- /dev/null
+++ b/home/fixtures/gate1/served/doc-block-slash-duplicate.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script /type="text/javascript" type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/duplicate-type-js-first.html b/home/fixtures/gate1/served/duplicate-type-js-first.html
new file mode 100644
index 00000000..6696eb0d
--- /dev/null
+++ b/home/fixtures/gate1/served/duplicate-type-js-first.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type="text/javascript" type="application/bento+json">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/embed.html b/home/fixtures/gate1/served/embed.html
new file mode 100644
index 00000000..1154c3a8
--- /dev/null
+++ b/home/fixtures/gate1/served/embed.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<embed src="x"></body></html>
diff --git a/home/fixtures/gate1/served/empty-comment-alone.html b/home/fixtures/gate1/served/empty-comment-alone.html
new file mode 100644
index 00000000..bc3f4c63
--- /dev/null
+++ b/home/fixtures/gate1/served/empty-comment-alone.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<!--><!---><p>after</p></body></html>
diff --git a/home/fixtures/gate1/served/empty-comment-in-paragraph.html b/home/fixtures/gate1/served/empty-comment-in-paragraph.html
new file mode 100644
index 00000000..32d5b84e
--- /dev/null
+++ b/home/fixtures/gate1/served/empty-comment-in-paragraph.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<p><!--></p><p>after</p></body></html>
diff --git a/home/fixtures/gate1/served/empty-comment-then-script.html b/home/fixtures/gate1/served/empty-comment-then-script.html
new file mode 100644
index 00000000..6c7679b9
--- /dev/null
+++ b/home/fixtures/gate1/served/empty-comment-then-script.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<!--><script>window.pwned=4</script></body></html>
diff --git a/home/fixtures/gate1/served/entity-encoded-module.html b/home/fixtures/gate1/served/entity-encoded-module.html
new file mode 100644
index 00000000..1e50c14a
--- /dev/null
+++ b/home/fixtures/gate1/served/entity-encoded-module.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type="&#x6d;odule">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/equals-without-value.html b/home/fixtures/gate1/served/equals-without-value.html
new file mode 100644
index 00000000..1159d99f
--- /dev/null
+++ b/home/fixtures/gate1/served/equals-without-value.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type=>x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/extra-plain-script.html b/home/fixtures/gate1/served/extra-plain-script.html
new file mode 100644
index 00000000..1b1e15ef
--- /dev/null
+++ b/home/fixtures/gate1/served/extra-plain-script.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<script>evil()</script></body></html>
diff --git a/home/fixtures/gate1/served/form-feed-js-type.html b/home/fixtures/gate1/served/form-feed-js-type.html
new file mode 100644
index 00000000..ad12b847
--- /dev/null
+++ b/home/fixtures/gate1/served/form-feed-js-type.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type="text/javascript">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/form-feed-separators.html b/home/fixtures/gate1/served/form-feed-separators.html
new file mode 100644
index 00000000..131e4016
--- /dev/null
+++ b/home/fixtures/gate1/served/form-feed-separators.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/genuine-0.9.0-no-remover.html b/home/fixtures/gate1/served/genuine-0.9.0-no-remover.html
new file mode 100644
index 00000000..327dc205
--- /dev/null
+++ b/home/fixtures/gate1/served/genuine-0.9.0-no-remover.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS0</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT0</script>
+</head><body>
+<script>load0()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/genuine-1.0.0-shell.html b/home/fixtures/gate1/served/genuine-1.0.0-shell.html
new file mode 100644
index 00000000..ddc044ed
--- /dev/null
+++ b/home/fixtures/gate1/served/genuine-1.0.0-shell.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/genuine-1.0.0.html b/home/fixtures/gate1/served/genuine-1.0.0.html
new file mode 100644
index 00000000..5caf5e37
--- /dev/null
+++ b/home/fixtures/gate1/served/genuine-1.0.0.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/genuine-1.1.0-shared-runtime.html b/home/fixtures/gate1/served/genuine-1.1.0-shared-runtime.html
new file mode 100644
index 00000000..c2f769ec
--- /dev/null
+++ b/home/fixtures/gate1/served/genuine-1.1.0-shared-runtime.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load2()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/genuine-1.2.0.html b/home/fixtures/gate1/served/genuine-1.2.0.html
new file mode 100644
index 00000000..62aeb224
--- /dev/null
+++ b/home/fixtures/gate1/served/genuine-1.2.0.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS3</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT3</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load3()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/genuine-length-changing-text.html b/home/fixtures/gate1/served/genuine-length-changing-text.html
new file mode 100644
index 00000000..87b22506
--- /dev/null
+++ b/home/fixtures/gate1/served/genuine-length-changing-text.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>İstanbul ı ß ffi Σ</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"İstanbul ı ß ffi ΣΑΣ İİİİ"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>İİİİ ß ffi Σ</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/genuine-other-content.html b/home/fixtures/gate1/served/genuine-other-content.html
new file mode 100644
index 00000000..d8b8eb8b
--- /dev/null
+++ b/home/fixtures/gate1/served/genuine-other-content.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>Other</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"Other","slides":[{"x":"\u003cb\u003e"}]}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><h1 style="color:red">Other</h1></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/iframe.html b/home/fixtures/gate1/served/iframe.html
new file mode 100644
index 00000000..c7841db4
--- /dev/null
+++ b/home/fixtures/gate1/served/iframe.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<iframe src="https://evil.example/"></iframe></body></html>
diff --git a/home/fixtures/gate1/served/leading-equals-name.html b/home/fixtures/gate1/served/leading-equals-name.html
new file mode 100644
index 00000000..81fce51b
--- /dev/null
+++ b/home/fixtures/gate1/served/leading-equals-name.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script =type="application/bento+json">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/loader-byte-changed.html b/home/fixtures/gate1/served/loader-byte-changed.html
new file mode 100644
index 00000000..bf1b38c4
--- /dev/null
+++ b/home/fixtures/gate1/served/loader-byte-changed.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1( )</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/loader-of-another-release.html b/home/fixtures/gate1/served/loader-of-another-release.html
new file mode 100644
index 00000000..d3227923
--- /dev/null
+++ b/home/fixtures/gate1/served/loader-of-another-release.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load3()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/meta-csp.html b/home/fixtures/gate1/served/meta-csp.html
new file mode 100644
index 00000000..be4c569d
--- /dev/null
+++ b/home/fixtures/gate1/served/meta-csp.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<meta http-equiv='Content-Security-Policy' content="script-src *"></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/meta-glued-style.html b/home/fixtures/gate1/served/meta-glued-style.html
new file mode 100644
index 00000000..5cced216
--- /dev/null
+++ b/home/fixtures/gate1/served/meta-glued-style.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta<style><script>window.pwned=3</script></style> charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/meta-refresh.html b/home/fixtures/gate1/served/meta-refresh.html
new file mode 100644
index 00000000..dd72e41f
--- /dev/null
+++ b/home/fixtures/gate1/served/meta-refresh.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<meta http-equiv="refresh" content="0;url=https://evil.example/"></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/no-separator-after-quoted.html b/home/fixtures/gate1/served/no-separator-after-quoted.html
new file mode 100644
index 00000000..3ba4ec83
--- /dev/null
+++ b/home/fixtures/gate1/served/no-separator-after-quoted.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type="text/javascript"type="application/bento+json">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/nul-in-type-name.html b/home/fixtures/gate1/served/nul-in-type-name.html
new file mode 100644
index 00000000..678ad3e0
Binary files /dev/null and b/home/fixtures/gate1/served/nul-in-type-name.html differ
diff --git a/home/fixtures/gate1/served/object.html b/home/fixtures/gate1/served/object.html
new file mode 100644
index 00000000..51a9d478
--- /dev/null
+++ b/home/fixtures/gate1/served/object.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<object data="x"></object></body></html>
diff --git a/home/fixtures/gate1/served/on-attribute-in-preview.html b/home/fixtures/gate1/served/on-attribute-in-preview.html
new file mode 100644
index 00000000..4a3a41a1
--- /dev/null
+++ b/home/fixtures/gate1/served/on-attribute-in-preview.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><img src=x onerror="evil()"></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/on-attribute.html b/home/fixtures/gate1/served/on-attribute.html
new file mode 100644
index 00000000..0fb6797f
--- /dev/null
+++ b/home/fixtures/gate1/served/on-attribute.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body onload="evil()">
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/p-glued-script.html b/home/fixtures/gate1/served/p-glued-script.html
new file mode 100644
index 00000000..ad7cbee9
--- /dev/null
+++ b/home/fixtures/gate1/served/p-glued-script.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<p<script>x</script></body></html>
diff --git a/home/fixtures/gate1/served/runtime-byte-changed.html b/home/fixtures/gate1/served/runtime-byte-changed.html
new file mode 100644
index 00000000..2a894988
--- /dev/null
+++ b/home/fixtures/gate1/served/runtime-byte-changed.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT2</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/script-in-comment-before-loader.html b/home/fixtures/gate1/served/script-in-comment-before-loader.html
new file mode 100644
index 00000000..13b46b57
--- /dev/null
+++ b/home/fixtures/gate1/served/script-in-comment-before-loader.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<!-- <script>evil()</script> --></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/script-in-style.html b/home/fixtures/gate1/served/script-in-style.html
new file mode 100644
index 00000000..8121c37a
--- /dev/null
+++ b/home/fixtures/gate1/served/script-in-style.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>/* <script>x</script> */body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/script-in-textarea.html b/home/fixtures/gate1/served/script-in-textarea.html
new file mode 100644
index 00000000..eb328817
--- /dev/null
+++ b/home/fixtures/gate1/served/script-in-textarea.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<textarea><script>x</script></textarea></body></html>
diff --git a/home/fixtures/gate1/served/script-in-title.html b/home/fixtures/gate1/served/script-in-title.html
new file mode 100644
index 00000000..96ed3dfd
--- /dev/null
+++ b/home/fixtures/gate1/served/script-in-title.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title><script>x</script></title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/single-quoted-attributes.html b/home/fixtures/gate1/served/single-quoted-attributes.html
new file mode 100644
index 00000000..92373502
--- /dev/null
+++ b/home/fixtures/gate1/served/single-quoted-attributes.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type='bento/deflate-b86' id="bento-rt-css" data-len="4">CSS1</script>
+<script type='bento/deflate-b86' id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/slash-before-js-type.html b/home/fixtures/gate1/served/slash-before-js-type.html
new file mode 100644
index 00000000..56cc31ff
--- /dev/null
+++ b/home/fixtures/gate1/served/slash-before-js-type.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script /type="text/javascript" type="application/bento+json">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/slash-in-data-tag.html b/home/fixtures/gate1/served/slash-in-data-tag.html
new file mode 100644
index 00000000..82922546
--- /dev/null
+++ b/home/fixtures/gate1/served/slash-in-data-tag.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script/type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/slash-module-first.html b/home/fixtures/gate1/served/slash-module-first.html
new file mode 100644
index 00000000..0afd72c1
--- /dev/null
+++ b/home/fixtures/gate1/served/slash-module-first.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script/type="module" type="application/bento+json">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/src-script.html b/home/fixtures/gate1/served/src-script.html
new file mode 100644
index 00000000..cec0528d
--- /dev/null
+++ b/home/fixtures/gate1/served/src-script.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script src="https://evil.example/x.js"></script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/src-with-loader-body.html b/home/fixtures/gate1/served/src-with-loader-body.html
new file mode 100644
index 00000000..f31ad8f5
--- /dev/null
+++ b/home/fixtures/gate1/served/src-with-loader-body.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script src="https://example.invalid/x.js">load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/style-false-close.html b/home/fixtures/gate1/served/style-false-close.html
new file mode 100644
index 00000000..bc36a8f0
--- /dev/null
+++ b/home/fixtures/gate1/served/style-false-close.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<style>a{}</stylex><b onclick=x></style></body></html>
diff --git a/home/fixtures/gate1/served/tabs-and-newlines-in-tag.html b/home/fixtures/gate1/served/tabs-and-newlines-in-tag.html
new file mode 100644
index 00000000..613ba2e0
--- /dev/null
+++ b/home/fixtures/gate1/served/tabs-and-newlines-in-tag.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86"
+id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/title-false-close.html b/home/fixtures/gate1/served/title-false-close.html
new file mode 100644
index 00000000..88fcfdd0
--- /dev/null
+++ b/home/fixtures/gate1/served/title-false-close.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<title>t</titlex><b onclick=x></title></body></html>
diff --git a/home/fixtures/gate1/served/twin-entries.html b/home/fixtures/gate1/served/twin-entries.html
new file mode 100644
index 00000000..5caf5e37
--- /dev/null
+++ b/home/fixtures/gate1/served/twin-entries.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/two-runtime-blocks.html b/home/fixtures/gate1/served/two-runtime-blocks.html
new file mode 100644
index 00000000..223d732e
--- /dev/null
+++ b/home/fixtures/gate1/served/two-runtime-blocks.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type="bento/deflate-b86" id="bento-rt">RT1</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/type-Module-case.html b/home/fixtures/gate1/served/type-Module-case.html
new file mode 100644
index 00000000..cb2c0c43
--- /dev/null
+++ b/home/fixtures/gate1/served/type-Module-case.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type="Module">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/type-module.html b/home/fixtures/gate1/served/type-module.html
new file mode 100644
index 00000000..21601d12
--- /dev/null
+++ b/home/fixtures/gate1/served/type-module.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type="module">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/type-text-JavaScript.html b/home/fixtures/gate1/served/type-text-JavaScript.html
new file mode 100644
index 00000000..d93a40bc
--- /dev/null
+++ b/home/fixtures/gate1/served/type-text-JavaScript.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type="text/JavaScript">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/unknown-type.html b/home/fixtures/gate1/served/unknown-type.html
new file mode 100644
index 00000000..7d4f265a
--- /dev/null
+++ b/home/fixtures/gate1/served/unknown-type.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<script type="text/x-template">x</script></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/unquoted-attributes.html b/home/fixtures/gate1/served/unquoted-attributes.html
new file mode 100644
index 00000000..ccaf10ec
--- /dev/null
+++ b/home/fixtures/gate1/served/unquoted-attributes.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type=bento/deflate-b86 id="bento-rt-css" data-len="4">CSS1</script>
+<script type=bento/deflate-b86 id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/served/uppercase-SCRIPT.html b/home/fixtures/gate1/served/uppercase-SCRIPT.html
new file mode 100644
index 00000000..db4e048c
--- /dev/null
+++ b/home/fixtures/gate1/served/uppercase-SCRIPT.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+<SCRIPT>x</SCRIPT></head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict-expected.json b/home/fixtures/gate1/strict-expected.json
new file mode 100644
index 00000000..0d80e3bc
--- /dev/null
+++ b/home/fixtures/gate1/strict-expected.json
@@ -0,0 +1,4 @@
+{
+ "skeleton": "<!DOCTYPE html>\n<html lang=\"en\"><head>\n<meta charset=\"UTF-8\">\n<title><!--TITLE--></title>\n<style>body{margin:0}</style>\n<!--DOC-->\n<script type=\"bento/deflate-b86\" id=\"bento-rt-css\" data-len=\"4\">CSS1</script>\n<script type=\"bento/deflate-b86\" id=\"bento-rt\" data-len=\"3\">RT1</script>\n</head><body>\n<!--PREVIEW-->\n<script>load1()</script>\n</body></html>\n",
+ "remover": "<script data-bento-preview=\"1\">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>"
+}
diff --git a/home/fixtures/gate1/strict/genuine-save-length-changing-text.html b/home/fixtures/gate1/strict/genuine-save-length-changing-text.html
new file mode 100644
index 00000000..d1be2fef
--- /dev/null
+++ b/home/fixtures/gate1/strict/genuine-save-length-changing-text.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>İstanbul ß</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"İstanbul ı ß ffi"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>İİİİ ffi</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/genuine-save1.html b/home/fixtures/gate1/strict/genuine-save1.html
new file mode 100644
index 00000000..5caf5e37
--- /dev/null
+++ b/home/fixtures/gate1/strict/genuine-save1.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/genuine-save2.html b/home/fixtures/gate1/strict/genuine-save2.html
new file mode 100644
index 00000000..e1ee77c1
--- /dev/null
+++ b/home/fixtures/gate1/strict/genuine-save2.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>Second</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"Second"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><h2>Second deck</h2></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/s1-script-after-html.html b/home/fixtures/gate1/strict/s1-script-after-html.html
new file mode 100644
index 00000000..dc219dae
--- /dev/null
+++ b/home/fixtures/gate1/strict/s1-script-after-html.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
+<script>evil()</script>
\ No newline at end of file
diff --git a/home/fixtures/gate1/strict/s2-trailing-bytes.html b/home/fixtures/gate1/strict/s2-trailing-bytes.html
new file mode 100644
index 00000000..346f623e
--- /dev/null
+++ b/home/fixtures/gate1/strict/s2-trailing-bytes.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
+x
\ No newline at end of file
diff --git a/home/fixtures/gate1/strict/s3-leading-bytes.html b/home/fixtures/gate1/strict/s3-leading-bytes.html
new file mode 100644
index 00000000..c0184fd6
--- /dev/null
+++ b/home/fixtures/gate1/strict/s3-leading-bytes.html
@@ -0,0 +1,12 @@
+x<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/s4-uppercase-preview-script.html b/home/fixtures/gate1/strict/s4-uppercase-preview-script.html
new file mode 100644
index 00000000..2cf96207
--- /dev/null
+++ b/home/fixtures/gate1/strict/s4-uppercase-preview-script.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<SCRIPT DATA-BENTO-PREVIEW>evil()</SCRIPT></body></html>
diff --git a/home/fixtures/gate1/strict/s5-decoy-preview-div.html b/home/fixtures/gate1/strict/s5-decoy-preview-div.html
new file mode 100644
index 00000000..111b2ac6
--- /dev/null
+++ b/home/fixtures/gate1/strict/s5-decoy-preview-div.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><script>evil()</script></div><div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/s6-crlf.html b/home/fixtures/gate1/strict/s6-crlf.html
new file mode 100644
index 00000000..ae07cec3
--- /dev/null
+++ b/home/fixtures/gate1/strict/s6-crlf.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/s7-tab-script.html b/home/fixtures/gate1/strict/s7-tab-script.html
new file mode 100644
index 00000000..c1025240
--- /dev/null
+++ b/home/fixtures/gate1/strict/s7-tab-script.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+< script>evil()</script></body></html>
diff --git a/home/fixtures/gate1/strict/sec1-transient-script.html b/home/fixtures/gate1/strict/sec1-transient-script.html
new file mode 100644
index 00000000..c1d170b6
--- /dev/null
+++ b/home/fixtures/gate1/strict/sec1-transient-script.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<script data-bento-transient>evil()</script></body></html>
diff --git a/home/fixtures/gate1/strict/sec2-extra-preview-script.html b/home/fixtures/gate1/strict/sec2-extra-preview-script.html
new file mode 100644
index 00000000..cdd57e6e
--- /dev/null
+++ b/home/fixtures/gate1/strict/sec2-extra-preview-script.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<script data-bento-preview>evil()</script></body></html>
diff --git a/home/fixtures/gate1/strict/sec3-loader-byte.html b/home/fixtures/gate1/strict/sec3-loader-byte.html
new file mode 100644
index 00000000..bf1b38c4
--- /dev/null
+++ b/home/fixtures/gate1/strict/sec3-loader-byte.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1( )</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/sec4-plain-script.html b/home/fixtures/gate1/strict/sec4-plain-script.html
new file mode 100644
index 00000000..1b1e15ef
--- /dev/null
+++ b/home/fixtures/gate1/strict/sec4-plain-script.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<script>evil()</script></body></html>
diff --git a/home/fixtures/gate1/strict/sec5-onclick.html b/home/fixtures/gate1/strict/sec5-onclick.html
new file mode 100644
index 00000000..f8d09e78
--- /dev/null
+++ b/home/fixtures/gate1/strict/sec5-onclick.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body onclick="x">
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/v1-doc-executable.html b/home/fixtures/gate1/strict/v1-doc-executable.html
new file mode 100644
index 00000000..4dea845d
--- /dev/null
+++ b/home/fixtures/gate1/strict/v1-doc-executable.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="text/javascript" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/v2-script-in-preview.html b/home/fixtures/gate1/strict/v2-script-in-preview.html
new file mode 100644
index 00000000..f6eeaf1a
--- /dev/null
+++ b/home/fixtures/gate1/strict/v2-script-in-preview.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><script>evil()</script><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/v3-onerror-in-preview.html b/home/fixtures/gate1/strict/v3-onerror-in-preview.html
new file mode 100644
index 00000000..4a3a41a1
--- /dev/null
+++ b/home/fixtures/gate1/strict/v3-onerror-in-preview.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><img src=x onerror="evil()"></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+</body></html>
diff --git a/home/fixtures/gate1/strict/v4-second-doc-anchor.html b/home/fixtures/gate1/strict/v4-second-doc-anchor.html
new file mode 100644
index 00000000..4738d5d2
--- /dev/null
+++ b/home/fixtures/gate1/strict/v4-second-doc-anchor.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"><head>
+<meta charset="UTF-8">
+<title>A deck</title>
+<style>body{margin:0}</style>
+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>
+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>
+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>
+</head><body>
+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>
+<script>load1()</script>
+<script id="bento-doc">evil()</script></body></html>
diff --git a/home/fixtures/gate1/test-public-key.json b/home/fixtures/gate1/test-public-key.json
new file mode 100644
index 00000000..68f38af6
--- /dev/null
+++ b/home/fixtures/gate1/test-public-key.json
@@ -0,0 +1,6 @@
+{
+ "kty": "EC",
+ "x": "8UDzn4Mgpqbtk4-ODYShq9ldn96SrxUkpjN9CTy4q-Y",
+ "y": "CvhD30oTPWQEGe9pYwmZXzBYIGEFAnONUjz1kDO7URo",
+ "crv": "P-256"
+}
diff --git a/kernel/src/gate1.ts b/kernel/src/gate1.ts
new file mode 100644
index 00000000..9fa60ba5
--- /dev/null
+++ b/kernel/src/gate1.ts
@@ -0,0 +1,448 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+//
+// GATE 1: is this file's runtime a genuine Bento release? (bento/connect K5,
+// security §13–§18, §36, and the 2026-10-21 grammar ruling.) ONE shared
+// implementation for every JavaScript host (the extension, the hosted runtime,
+// release tooling). Native hosts (Swift, Kotlin, Rust) port it and must agree
+// with it on every row of the conformance corpus in home/fixtures/gate1/.
+//
+// Two paths, by what the host can do:
+// - verifyServed(): for a host that SERVES the bytes it verified (iOS,
+// Android, desktop, the hosted runtime). It checks the file against the
+// signed release history: ONE release must match EVERY code block, under
+// the grammar below. It answers with the CSP to serve the file under. This
+// is the PRIMARY path, immune to serializer drift (security §17).
+// - verifyStrict(): the file:// fallback, where no CSP can be set. An exact
+// string check against a release's saved skeleton (vault's strict verifier,
+// signed off in security §15). It can only ever hold a RESULT: identity is
+// never exposed in a bare file:// tab (security §16).
+//
+// "Unknown" is never "tampered": it means "not provably one of ours", and the
+// host shows the document without identity, or offers an update. It never
+// borrows a pinned CSP for a file it couldn't match.
+//
+// Pure: no DOM, and WebCrypto for hashing, so it runs in a page, a worker, an
+// extension and node alike.
+
+/** A release's pins, as signed into its manifest and its history entry. */
+export interface Pins {
+ v: 1
+ /** sha256 HEX of each code block's text; remover null for releases before the preview */
+ blocks: { 'bento-rt': string; 'bento-rt-css': string; loader: string; remover: string | null }
+ /** CSP form: 'sha256-' + BASE64 of the loader, then the remover */
+ scriptSrc: string[]
+}
+export interface HistoryEntry { version: string; sha256: string; at: string; pins: Pins }
+export interface History { app: string; v: 1; releases: HistoryEntry[] }
+
+// --- the scanner ---------------------------------------------------------------
+
+export interface Block {
+ tag: 'script' | 'style'
+ attrs: string
+ /** the raw text, which ends at the first `</script` / `</style` in any case, as the HTML tokenizer ends it */
+ text: string
+ /** offset of the text's first character in the file */
+ start: number
+ type: string | null
+ id: string | null
+ src: string | null
+ preview: boolean
+ /** the start tag repeats an attribute name, or uses "/" between attributes (Bento writes neither) */
+ duplicate: boolean
+ slash: boolean
+}
+
+/**
+ * A start tag's attributes, read the way the HTML tokenizer reads them (security,
+ * #825 review). Names are separated by whitespace (tab, LF, FF, CR, space) OR by
+ * "/". A quoted value ends the attribute even with no separator after it. Names
+ * are case-insensitive, and the FIRST of duplicate names wins. Reading them any
+ * other way lets `<script/type="module" type="application/bento+json">` look
+ * inert when a browser runs it. `duplicate` and `slash` are reported because
+ * Bento never writes either, so a script tag with either is refused outright
+ * (markupProblems). Values are taken literally: a browser decodes character
+ * references in them, but a literal read can only make a block look EXECUTABLE,
+ * never inert (no data type contains "&").
+ */
+export interface StartTag { name: string; attrs: Map<string, string>; duplicate: boolean; slash: boolean; end: number }
+/**
+ * ASCII-only case fold: the HTML spec's, and LENGTH-PRESERVING. Never use
+ * toLowerCase() on a file and index the original with its offsets: it changes
+ * length ('İ' becomes two UTF-16 units). Every İ before a block then shifts the
+ * offsets, so a genuine Turkish document reads as unknown and, worse, a <style>
+ * close can land late enough to skip over an injected <script>, and a file
+ * carrying foreign code reads as genuine (home-desktop, measured).
+ */
+export const asciiLower = (s: string): string => s.replace(/[A-Z]/g, (c) => String.fromCharCode(c.charCodeAt(0) + 32))
+
+const WS = (c: string | undefined) => c === '\t' || c === '\n' || c === '\f' || c === '\r' || c === ' '
+export function parseStartTag(html: string, i: number): StartTag | null {
+ const m = /^<([a-zA-Z][^\t\n\f\r />]*)/.exec(html.slice(i, i + 256))
+ if (!m) return null
+ const attrs = new Map<string, string>()
+ let duplicate = false, slash = false
+ let j = i + m[0].length
+ while (j < html.length) {
+ const c = html[j]
+ if (WS(c)) { j++; continue }
+ if (c === '/') { slash = true; j++; continue } // a separator, or a self-closing mark
+ if (c === '>') return { name: asciiLower(m[1]), attrs, duplicate, slash, end: j + 1 }
+ // the name: a leading "=" is part of it; it ends at whitespace, "/", ">" or "="
+ let k = j, name = ''
+ if (html[k] === '=') { name = '='; k++ }
+ while (k < html.length && !WS(html[k]) && html[k] !== '/' && html[k] !== '>' && html[k] !== '=') name += html[k++]
+ name = asciiLower(name).replace(/\u0000/g, '�')
+ let value = ''
+ let p = k
+ while (WS(html[p])) p++
+ if (html[p] === '=') {
+ p++
+ while (WS(html[p])) p++
+ if (html[p] === '"' || html[p] === "'") {
+ const close = html.indexOf(html[p], p + 1)
+ if (close < 0) return null
+ value = html.slice(p + 1, close)
+ k = close + 1
+ } else {
+ let e = p
+ while (e < html.length && !WS(html[e]) && html[e] !== '>') e++
+ value = html.slice(p, e)
+ k = e
+ }
+ }
+ if (attrs.has(name)) duplicate = true
+ else attrs.set(name, value)
+ j = k
+ }
+ return null // unterminated
+}
+
+/**
+ * ONE walk over the file, in document order, tag by tag, as a browser's
+ * tokenizer meets them. Both scanBlocks and markupProblems read it, so the
+ * blocks gate1 hashes and the markup it judges come from the SAME reading.
+ * Searching for "<script" or "<style" instead finds them where a browser never
+ * would: inside another tag's name. In `<meta<style><script>…` a browser sees ONE
+ * tag, named "meta<style", and then a real <script> that runs. A search saw a
+ * <style> whose close swallowed the script (home-ios, found by a WebKit oracle).
+ */
+interface Walk { blocks: Block[]; problems: string[] }
+const TAG_NAME = /^[a-z][a-z0-9-]*$/
+/** Elements whose content is TEXT to a browser, never tags, up to their real end tag. */
+const RAW_TEXT = ['script', 'style', 'textarea', 'title']
+
+/**
+ * Where a raw-text element really ends: "</name" (ASCII case-insensitive)
+ * followed by whitespace, "/" or ">", as the tokenizer requires. "</scriptx>"
+ * is text inside the script, not its end. -1 if it never ends.
+ */
+function rawTextEnd(lower: string, name: string, from: number): number {
+ let at = from
+ while ((at = lower.indexOf(`</${name}`, at)) !== -1) {
+ const c = lower[at + 2 + name.length]
+ if (c === undefined || WS(c) || c === '/' || c === '>') return at
+ at += 2
+ }
+ return -1
+}
+function walk(html: string): Walk {
+ const blocks: Block[] = [], problems: string[] = []
+ const lower = asciiLower(html)
+ let i = 0
+ while ((i = html.indexOf('<', i)) !== -1) {
+ if (html.startsWith('<!--', i)) {
+ // "<!-->" and "<!--->" are whole (empty) comments to a browser
+ if (html.startsWith('<!-->', i)) { i += 5; continue }
+ if (html.startsWith('<!--->', i)) { i += 6; continue }
+ const end = html.indexOf('-->', i + 4)
+ if (lower.slice(i + 4, end < 0 ? html.length : end).includes('<script')) problems.push('a comment holds a <script>')
+ if (end < 0) { problems.push('an unterminated comment'); break }
+ i = end + 3; continue
+ }
+ if (html[i + 1] === '/' || html[i + 1] === '!' || html[i + 1] === '?') {
+ // an end tag, a doctype or a bogus comment: no attributes a browser acts on
+ const end = html.indexOf('>', i + 2)
+ if (end < 0) { problems.push('an unterminated tag'); break }
+ i = end + 1; continue
+ }
+ if (!/^<[a-zA-Z]/.test(html.slice(i, i + 2))) { i++; continue } // a "<" that starts no tag is text
+ const tag = parseStartTag(html, i)
+ if (!tag) { problems.push('an unterminated start tag'); break }
+ const name = tag.name
+ // Bento writes only plain tag names. Anything else ("meta<style", a NUL, a
+ // non-ASCII letter) is a tag a scanner and a browser may read differently.
+ if (!TAG_NAME.test(name)) problems.push(`a start tag named ${JSON.stringify(name)}`)
+ if (['iframe', 'object', 'embed', 'base'].includes(name)) problems.push(`a <${name}>`)
+ if (name === 'meta' && /^\s*(refresh|content-security-policy)\s*$/i.test(tag.attrs.get('http-equiv') ?? '')) problems.push('a <meta> refresh or CSP')
+ if ([...tag.attrs.keys()].some((n) => n.startsWith('on'))) problems.push(`an on*= attribute on <${name}>`)
+ if (name === 'script' && (tag.duplicate || tag.slash)) problems.push(`a <script> start tag with a ${tag.duplicate ? 'duplicate attribute' : '"/" between attributes'} (Bento writes neither)`)
+ if (RAW_TEXT.includes(name)) {
+ const close = rawTextEnd(lower, name, tag.end)
+ if (close < 0) { problems.push(`an unterminated <${name}>`); break }
+ // inert to a browser, but a scanner that doesn't treat these as text
+ // would count it: refuse, so every host's scanner reaches the same verdict
+ if (name !== 'script' && lower.slice(tag.end, close).includes('<script')) problems.push(`a <${name}> holds a <script>`)
+ if (name === 'textarea' || name === 'title') { i = close; continue }
+ const get = (n: string) => tag.attrs.has(n) ? tag.attrs.get(n)! : null
+ blocks.push({
+ tag: name as 'script' | 'style', attrs: html.slice(i, tag.end), text: html.slice(tag.end, close), start: tag.end,
+ type: get('type'), id: get('id'), src: get('src'), preview: tag.attrs.has('data-bento-preview'),
+ duplicate: tag.duplicate, slash: tag.slash,
+ })
+ i = close; continue // its end tag is skipped as an end tag
+ }
+ i = tag.end
+ }
+ return { blocks, problems }
+}
+
+/** Every <script> and <style> element in the file, with its raw text, in document order. */
+export function scanBlocks(html: string): Block[] {
+ return walk(html).blocks
+}
+
+// --- the grammar (security, 2026-10-21) ------------------------------------------
+
+/**
+ * A <script> is inert ONLY if its type is exactly one of the data types Bento
+ * writes. Everything else is executable: no type, a JavaScript type, "module",
+ * an unknown type, a differently cased data type, and ANY src=. An executable
+ * script must be exactly the pinned loader or remover by hash, or the file is
+ * UNKNOWN. An allowlist, so a type browsers start running tomorrow can't pass as
+ * data.
+ */
+export const DATA_TYPES: ReadonlySet<string> = new Set(['application/bento+json', 'application/bento+lang', 'bento/deflate-b64', 'bento/deflate-b86'])
+export const isDataScript = (b: Block): boolean => b.tag === 'script' && b.src === null && b.type !== null && DATA_TYPES.has(b.type)
+
+/** Every script that isn't one of Bento's data blocks: each must be the pinned loader or remover. */
+export const executableScripts = (blocks: Block[]): Block[] => blocks.filter((b) => b.tag === 'script' && !isDataScript(b))
+
+/**
+ * Markup a genuine Bento file never carries, anywhere outside a script or style
+ * element's own text:
+ * - <iframe>, <object>, <embed> or <base>;
+ * - a <meta> refresh or CSP;
+ * - any on*= attribute;
+ * - a comment or <style> holding a <script>;
+ * - a data block containing "<".
+ * Bento's data never contains "<": the JSON and language packs escape it, and
+ * the b64/b86 alphabets exclude it. That also closes the "<!--<script"
+ * double-escape state, where a later close tag doesn't end the element.
+ * Returns the problems; [] = none.
+ */
+export function markupProblems(html: string): string[] {
+ const { blocks, problems } = walk(html)
+ for (const b of blocks) if (isDataScript(b) && b.text.includes('<')) problems.push(`the ${b.type} block contains "<"`)
+ return problems
+}
+
+// --- hashing ---------------------------------------------------------------------
+
+const enc = new TextEncoder()
+async function digest(s: string): Promise<Uint8Array> {
+ return new Uint8Array(await crypto.subtle.digest('SHA-256', enc.encode(s) as BufferSource))
+}
+/** sha256 HEX of a string's UTF-8 bytes: the encoding of every `blocks` pin. */
+export async function sha256hex(s: string): Promise<string> {
+ return Array.from(await digest(s), (b) => b.toString(16).padStart(2, '0')).join('')
+}
+/** 'sha256-' + BASE64: the CSP encoding of every `scriptSrc` pin. Never compare it to a hex pin. */
+export async function cspHash(s: string): Promise<string> {
+ let bin = ''
+ for (const b of await digest(s)) bin += String.fromCharCode(b)
+ return `sha256-${btoa(bin)}`
+}
+
+const CODE_IDS = ['bento-rt', 'bento-rt-css'] as const
+
+/**
+ * Check a file against ONE release's pins: no foreign markup, exactly one block
+ * per code id with a matching hash, and every executable script exactly the
+ * pinned loader or remover. Returns the problems; [] = this release's file.
+ */
+export async function checkAgainstPins(html: string, pins: Pins): Promise<string[]> {
+ const problems = [...markupProblems(html)]
+ const blocks = scanBlocks(html)
+ for (const id of CODE_IDS) {
+ const found = blocks.filter((b) => b.id === id)
+ if (found.length !== 1) problems.push(`${found.length} #${id} blocks (exactly one expected)`)
+ else if ((await sha256hex(found[0].text)) !== pins.blocks[id]) problems.push(`#${id} does not match`)
+ }
+ const exec = executableScripts(blocks)
+ const hashes = await Promise.all(exec.map((s) => sha256hex(s.text)))
+ const allowed = new Set([pins.blocks.loader, pins.blocks.remover].filter(Boolean))
+ exec.forEach((s, k) => {
+ if (s.src !== null || !allowed.has(hashes[k])) problems.push(`an executable script that is neither the pinned loader nor the remover (${s.src !== null ? 'src=' + s.src : s.text.length + 'B'})`)
+ })
+ const n = (h: string | null) => hashes.filter((x) => x === h).length
+ if (n(pins.blocks.loader) === 0) problems.push('no pinned loader')
+ if (n(pins.blocks.loader) > 1) problems.push('more than one loader')
+ if (pins.blocks.remover && n(pins.blocks.remover) > 1) problems.push('more than one remover')
+ return problems
+}
+
+// --- the release history --------------------------------------------------------
+
+const SEMVER = /^(\d+)\.(\d+)\.(\d+)$/
+export function cmpVersion(a: string, b: string): number {
+ const x = SEMVER.exec(a), y = SEMVER.exec(b)
+ if (!x || !y) throw new Error(`gate1: not a version: ${!x ? a : b}`)
+ for (let i = 1; i <= 3; i++) { const d = Number(x[i]) - Number(y[i]); if (d) return d }
+ return 0
+}
+const entryOk = (e: HistoryEntry | undefined): e is HistoryEntry => !!e && typeof e.version === 'string' && SEMVER.test(e.version) &&
+ /^[0-9a-f]{64}$/.test(e.sha256 ?? '') && typeof e.at === 'string' && e.pins?.v === 1 && typeof e.pins.blocks === 'object'
+
+/** A history payload's shape problems; [] = well-formed (versions unique, newest first). */
+export function historyProblems(h: History | null | undefined): string[] {
+ const p: string[] = []
+ if (!h || h.v !== 1) p.push(`version ${h?.v} (expected 1)`)
+ if (typeof h?.app !== 'string' || !h.app) p.push('no app')
+ if (!Array.isArray(h?.releases)) { p.push('no releases'); return p }
+ const seen = new Set<string>()
+ h.releases.forEach((e, i) => {
+ if (!entryOk(e)) { p.push(`entry ${i} is malformed`); return }
+ if (seen.has(e.version)) p.push(`version ${e.version} appears twice`)
+ seen.add(e.version)
+ const prev = h.releases[i - 1]
+ if (i > 0 && entryOk(prev) && cmpVersion(prev.version, e.version) <= 0) p.push(`entries are not newest-first at ${e.version}`)
+ })
+ return p
+}
+
+const same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)
+
+/**
+ * A HOST's acceptance of an incoming, already signature-verified history, given
+ * the newest it holds: ANTI-ROLLBACK. It refuses one that lacks a held entry,
+ * changes one, or rolls the newest version back. (With a well-formed history
+ * the last is implied by the first, and is kept as defence in depth.)
+ */
+export function acceptHistory(held: History | null, incoming: History, app: string): { ok: true } | { ok: false; reason: string } {
+ const problems = historyProblems(incoming)
+ if (problems.length) return { ok: false, reason: `malformed: ${problems[0]}` }
+ if (incoming.app !== app) return { ok: false, reason: `for ${incoming.app}, not ${app}` }
+ if (!held) return { ok: true }
+ if (!incoming.releases.length || (held.releases.length && cmpVersion(incoming.releases[0].version, held.releases[0].version) < 0)) {
+ return { ok: false, reason: 'rollback: its newest release is older than the newest already held' }
+ }
+ for (const e of held.releases) {
+ const there = incoming.releases.find((x) => x.version === e.version)
+ if (!there) return { ok: false, reason: `rollback: it lacks ${e.version}, which is already held` }
+ if (!same(there, e)) return { ok: false, reason: `${e.version} changed: a history never changes an entry` }
+ }
+ return { ok: true }
+}
+
+/** The ONE entry matching every block of the file, or null (none, or more than one: UNKNOWN). */
+export async function matchRelease(history: History, html: string): Promise<HistoryEntry | null> {
+ const rt = scanBlocks(html).filter((b) => b.id === 'bento-rt')
+ if (rt.length !== 1) return null
+ const rtHash = await sha256hex(rt[0].text)
+ const full: HistoryEntry[] = []
+ for (const e of history.releases.filter((x) => x.pins.blocks['bento-rt'] === rtHash)) {
+ if ((await checkAgainstPins(html, e.pins)).length === 0) full.push(e)
+ }
+ return full.length === 1 ? full[0] : null
+}
+
+// --- the served path ----------------------------------------------------------------
+
+/**
+ * The CSP a host serves a verified document under (security §17/§18, §36a):
+ * scripts hash-pinned to the release's loader and remover, plus blob: for the
+ * runtime the loader imports; styles 'unsafe-inline' (the sanitizer is the style
+ * control); everything else closed. `frameAncestors` is the host's own value.
+ */
+export function hostPolicy(pins: Pins, frameAncestors = "'none'"): string {
+ return [
+ "default-src 'none'",
+ `script-src ${pins.scriptSrc.map((h) => `'${h}'`).join(' ')} blob:`,
+ "style-src 'unsafe-inline'",
+ 'img-src data: blob: https:',
+ 'media-src data: blob: https:',
+ 'font-src data: blob:',
+ 'connect-src https://bento.page https://sync.bento.page wss://sync.bento.page',
+ 'frame-src https:',
+ "object-src 'none'",
+ "base-uri 'none'",
+ "form-action 'none'",
+ "worker-src 'none'",
+ `frame-ancestors ${frameAncestors}`,
+ ].join('; ')
+}
+
+export type ServedVerdict =
+ | { verdict: 'genuine'; release: HistoryEntry; csp: string }
+ | { verdict: 'unknown'; reason: string }
+
+/**
+ * THE served-path gate: is this file one genuine release's? The history must
+ * already have passed the release-key signature check and acceptHistory().
+ */
+export async function verifyServed(html: string, history: History, opts: { frameAncestors?: string } = {}): Promise<ServedVerdict> {
+ const problems = historyProblems(history)
+ if (problems.length) return { verdict: 'unknown', reason: `the history is malformed: ${problems[0]}` }
+ const release = await matchRelease(history, html)
+ if (!release) {
+ const markup = markupProblems(html)
+ return { verdict: 'unknown', reason: markup.length ? markup[0] : 'no single release matches every block' }
+ }
+ return { verdict: 'genuine', release, csp: hostPolicy(release.pins, opts.frameAncestors) }
+}
+
+// --- the strict file:// fallback (vault's strict verifier; security §15) ------------
+
+const CLOSE = '</' + 'script>'
+const DOC_ANCHOR = ' id="bento-doc"'
+const DOC_OPEN = '<script type="application/bento+json" id="bento-doc">'
+
+/** What the strict check compares against, taken from a GENUINE saved file of a release. */
+export interface StrictExpected {
+ /** the saved file with its variable spans collapsed to placeholders */
+ skeleton: string
+ /** the exact preview remover that release writes (with its tags), or null before previews */
+ remover: string | null
+}
+
+function collapse(h: string, remover: string | null): string | { refuse: string } {
+ const count = (n: string) => h.split(n).length - 1
+ if (count(DOC_ANCHOR) !== 1) return { refuse: `doc anchor count ${count(DOC_ANCHOR)}` }
+ const di = h.indexOf(DOC_ANCHOR), dOpen = h.lastIndexOf('<', di), dTagEnd = h.indexOf('>', di) + 1, dEnd = h.indexOf(CLOSE, di) + CLOSE.length
+ if (h.slice(dOpen, dTagEnd) !== DOC_OPEN) return { refuse: 'doc block opening tag altered' }
+ if (dEnd < CLOSE.length || h.slice(dTagEnd, dEnd - CLOSE.length).includes('<')) return { refuse: '"<" inside the doc block' }
+ h = h.slice(0, dOpen) + '<!--DOC-->' + h.slice(dEnd)
+ if (count('data-bento-preview') > 0) {
+ if (!remover || count('<script data-bento-preview') !== 1 || count(remover) !== 1) return { refuse: 'remover missing, altered or repeated' }
+ const pOpen = h.lastIndexOf('<', h.indexOf('data-bento-preview')), rem = h.indexOf(remover), body = h.slice(pOpen, rem)
+ if (/<script/i.test(body)) return { refuse: 'script inside the preview markup' }
+ if (/\son[a-z]+\s*=/i.test(body) || /javascript:/i.test(body)) return { refuse: 'handler or javascript: in the preview markup' }
+ h = h.slice(0, pOpen) + '<!--PREVIEW-->' + h.slice(rem + remover.length)
+ }
+ return h.replace(/<title>[^<]*<\/title>/, '<title><!--TITLE--></title>')
+}
+
+/** The strict expectation from a GENUINE saved file of a release. */
+export function strictExpectedFrom(genuineSave: string): StrictExpected {
+ const at = genuineSave.indexOf('<script data-bento-preview')
+ const remover = at < 0 ? null : genuineSave.slice(at, genuineSave.indexOf(CLOSE, at) + CLOSE.length)
+ const skeleton = collapse(genuineSave, remover)
+ if (typeof skeleton !== 'string') throw new Error(`gate1: the genuine save fails its own strict check: ${skeleton.refuse}`)
+ return { skeleton, remover }
+}
+
+/**
+ * The strict check: each variable span (the doc block, the preview, the title)
+ * is type-checked to its exact allowed form and collapsed. Then EVERYTHING else
+ * must equal the release's saved skeleton, byte for byte, over the WHOLE string,
+ * bound at both ends. That final compare is what's load-bearing: it caught every
+ * one of security's adversarial rows (§15). The span guards are defence in
+ * depth that let the variable spans legitimately vary.
+ */
+export function verifyStrict(html: string, expected: StrictExpected): { ok: true } | { ok: false; reason: string } {
+ const c = collapse(html, expected.remover)
+ if (typeof c !== 'string') return { ok: false, reason: c.refuse }
+ return c === expected.skeleton ? { ok: true } : { ok: false, reason: 'skeleton differs from the release\'s saved form' }
+}
diff --git a/scripts/backfill-history.mjs b/scripts/backfill-history.mjs
index a378dedd..d80ae19e 100644
--- a/scripts/backfill-history.mjs
+++ b/scripts/backfill-history.mjs
@@ -67,7 +67,7 @@ try {
writeFileSync(path, shell)
const saved = await savedBy(browser, path)
const pins = derivePins(html, saved, { historic: true })
- const self = checkAgainstPins(saved, pins)
+ const self = await checkAgainstPins(saved, pins)
if (self.length) { refused.push(`${payload.version}: its own save does not match its pins (${self[0]})`); continue }
entries.set(payload.version, { version: payload.version, sha256, at: payload.at, pins })
console.log(` ${payload.version.padEnd(8)} pinned (remover ${pins.blocks.remover ? 'yes' : 'none'})`)
diff --git a/scripts/derive-pins.mjs b/scripts/derive-pins.mjs
index 58cdb8bf..1c0d6766 100644
--- a/scripts/derive-pins.mjs
+++ b/scripts/derive-pins.mjs
@@ -44,7 +44,7 @@ try {
const shell = readFileSync(shellPath, 'utf8')
const saved = await savedBy(browser, shellPath)
const pins = derivePins(shell, saved, { historic })
- const self = checkAgainstPins(saved, pins)
+ const self = await checkAgainstPins(saved, pins)
if (self.length) throw new Error(`derive-pins: the saved file does not match its own pins: ${self.join('; ')}`)
console.log(`pins loader ${pins.blocks.loader.slice(0, 12)}… remover ${pins.blocks.remover?.slice(0, 12) ?? '(none: before previews)'} rt ${pins.blocks['bento-rt'].slice(0, 12)}…`)
diff --git a/scripts/gen-gate1-corpus.ts b/scripts/gen-gate1-corpus.ts
new file mode 100644
index 00000000..f82cbf28
--- /dev/null
+++ b/scripts/gen-gate1-corpus.ts
@@ -0,0 +1,223 @@
+#!/usr/bin/env node
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// Generates home/fixtures/gate1/, the gate-1 conformance corpus (bento/connect
+// K5): every host's verifier (JS, Swift, Kotlin, Rust) must reach the stated
+// verdict on every row.
+//
+// node scripts/gen-gate1-corpus.ts
+//
+// Every row DECLARES its expected verdict. The generator then checks the
+// kernel's reference (kernel/src/gate1.ts) against each one and refuses to
+// write the corpus if they disagree. The answers are the rules, not whatever
+// the JS happens to do. The releases are small synthetic files with the real
+// shape: code blocks, a loader, a preview with its remover. The history is
+// signed with a THROWAWAY TEST key whose public half is in the corpus.
+// Signatures are random, so regenerating changes those bytes but no verdict.
+
+import { generateKeyPairSync, sign, createHash } from 'node:crypto'
+import { mkdirSync, rmSync, writeFileSync } from 'node:fs'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { verifyServed, verifyStrict, strictExpectedFrom, acceptHistory, type History, type Pins } from '../kernel/src/gate1.ts'
+
+const OUT = join(dirname(fileURLToPath(import.meta.url)), '..', 'home/fixtures/gate1')
+const S = 'scr' + 'ipt'
+const hex = (s: string) => createHash('sha256').update(s, 'utf8').digest('hex')
+const csp = (s: string) => `sha256-${createHash('sha256').update(s, 'utf8').digest('base64')}`
+
+// --- the synthetic releases ---------------------------------------------------------
+const REMOVER = "(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()"
+interface R { version: string; rt: string; css: string; loader: string; remover: string | null }
+const RELEASES: R[] = [
+ { version: '0.9.0', rt: 'RT0', css: 'CSS0', loader: 'load0()', remover: null }, // before previews
+ { version: '1.0.0', rt: 'RT1', css: 'CSS1', loader: 'load1()', remover: REMOVER },
+ { version: '1.1.0', rt: 'RT1', css: 'CSS1', loader: 'load2()', remover: REMOVER }, // shares 1.0.0's runtime
+ { version: '1.2.0', rt: 'RT3', css: 'CSS3', loader: 'load3()', remover: REMOVER },
+]
+const file = (r: R, o: { title?: string; doc?: string; preview?: string | null } = {}) => {
+ const preview = r.remover && o.preview !== null
+ ? `<div data-bento-preview="1">${o.preview ?? '<p>Page one</p>'}</div><${S} data-bento-preview="1">${r.remover}</${S}>\n`
+ : ''
+ return '<!DOCTYPE html>\n<html lang="en"><head>\n<meta charset="UTF-8">\n' +
+ `<title>${o.title ?? 'A deck'}</title>\n<style>body{margin:0}</style>\n` +
+ `<${S} type="application/bento+json" id="bento-doc">${o.doc ?? '{"format":"bento/test","title":"A deck"}'}</${S}>\n` +
+ `<${S} type="bento/deflate-b86" id="bento-rt-css" data-len="${r.css.length}">${r.css}</${S}>\n` +
+ `<${S} type="bento/deflate-b86" id="bento-rt" data-len="${r.rt.length}">${r.rt}</${S}>\n` +
+ `</head><body>\n${preview}<${S}>${r.loader}</${S}>\n</body></html>\n`
+}
+const pinsOf = (r: R): Pins => ({
+ v: 1,
+ blocks: { 'bento-rt': hex(r.rt), 'bento-rt-css': hex(r.css), loader: hex(r.loader), remover: r.remover ? hex(r.remover) : null },
+ scriptSrc: r.remover ? [csp(r.loader), csp(r.remover)] : [csp(r.loader)],
+})
+const shaOf = (r: R) => hex(file(r, { preview: null }))
+const history: History = {
+ app: 'bento-test', v: 1,
+ releases: [...RELEASES].reverse().map((r) => ({ version: r.version, sha256: shaOf(r), at: '2026-10-21T00:00:00.000Z', pins: pinsOf(r) })),
+}
+
+// --- served rows: does ONE release match EVERY block? -----------------------------
+const [r09, r1, r11, r12] = RELEASES
+const g = file(r1)
+const head = (x: string) => g.replace('</head>', x + '</head>')
+const body = (x: string) => g.replace('</body>', x + '</body>')
+type Served = { name: string; html: string; verdict: 'genuine' | 'unknown'; release?: string; why: string }
+const served: Served[] = [
+ { name: 'genuine-1.0.0', html: g, verdict: 'genuine', release: '1.0.0', why: 'a genuine saved file' },
+ { name: 'genuine-1.1.0-shared-runtime', html: file(r11), verdict: 'genuine', release: '1.1.0', why: 'shares 1.0.0\'s runtime; the loader tells them apart' },
+ { name: 'genuine-1.2.0', html: file(r12), verdict: 'genuine', release: '1.2.0', why: 'a genuine saved file' },
+ { name: 'genuine-0.9.0-no-remover', html: file(r09), verdict: 'genuine', release: '0.9.0', why: 'a release from before previews saves no remover' },
+ { name: 'genuine-1.0.0-shell', html: file(r1, { preview: null }), verdict: 'genuine', release: '1.0.0', why: 'the built shell itself: no preview yet' },
+ { name: 'genuine-other-content', html: file(r1, { title: 'Other', doc: '{"format":"bento/test","title":"Other","slides":[{"x":"\\u003cb\\u003e"}]}', preview: '<h1 style="color:red">Other</h1>' }), verdict: 'genuine', release: '1.0.0', why: 'the document, title and inert preview vary freely' },
+ // the grammar: only Bento's exact data types are inert
+ { name: 'src-script', html: head(`<${S} src="https://evil.example/x.js"></${S}>`), verdict: 'unknown', why: 'any src= is executable, and never pinned' },
+ { name: 'unknown-type', html: head(`<${S} type="text/x-template">x</${S}>`), verdict: 'unknown', why: 'an unknown type is executable' },
+ { name: 'type-module', html: head(`<${S} type="module">x</${S}>`), verdict: 'unknown', why: 'module is executable' },
+ { name: 'type-Module-case', html: head(`<${S} type="Module">x</${S}>`), verdict: 'unknown', why: 'module in any case is executable' },
+ { name: 'type-text-JavaScript', html: head(`<${S} type="text/JavaScript">x</${S}>`), verdict: 'unknown', why: 'a JS type in mixed case is executable' },
+ { name: 'data-type-other-case', html: g.replace('type="application/bento+json"', 'type="Application/Bento+JSON"'), verdict: 'unknown', why: 'the data allowlist is exact: another case is executable' },
+ { name: 'uppercase-SCRIPT', html: head('<SCRIPT>x</SCRIPT>'), verdict: 'unknown', why: 'an uppercase tag is still a script' },
+ { name: 'nul-in-type-name', html: g.replace('type="bento/deflate-b86" id="bento-rt"', 'ty\u0000pe="bento/deflate-b86" id="bento-rt"'), verdict: 'unknown', why: 'a NUL makes it another attribute: the script has no type, so it runs' },
+ { name: 'extra-plain-script', html: body(`<${S}>evil()</${S}>`), verdict: 'unknown', why: 'an executable script that is neither the loader nor the remover' },
+ { name: 'loader-byte-changed', html: g.replace('load1()', 'load1( )'), verdict: 'unknown', why: 'the loader no longer matches its pin' },
+ { name: 'runtime-byte-changed', html: g.replace('>RT1<', '>RT2<'), verdict: 'unknown', why: 'the runtime block no longer matches its pin' },
+ { name: 'two-runtime-blocks', html: head(`<${S} type="bento/deflate-b86" id="bento-rt">RT1</${S}>`), verdict: 'unknown', why: 'exactly one block per id' },
+ { name: 'loader-of-another-release', html: g.replace('load1()', 'load3()'), verdict: 'unknown', why: 'a partial match (1.0.0 runtime, 1.2.0 loader) is not a release' },
+ // markup a genuine file never carries
+ { name: 'iframe', html: body('<iframe src="https://evil.example/"></iframe>'), verdict: 'unknown', why: '<iframe>' },
+ { name: 'object', html: body('<object data="x"></object>'), verdict: 'unknown', why: '<object>' },
+ { name: 'embed', html: body('<embed src="x">'), verdict: 'unknown', why: '<embed>' },
+ { name: 'base', html: head('<base href="https://evil.example/">'), verdict: 'unknown', why: '<base>' },
+ { name: 'meta-refresh', html: head('<meta http-equiv="refresh" content="0;url=https://evil.example/">'), verdict: 'unknown', why: 'a <meta> refresh' },
+ { name: 'meta-csp', html: head(`<meta http-equiv='Content-Security-Policy' content="script-src *">`), verdict: 'unknown', why: 'a <meta> CSP' },
+ { name: 'on-attribute', html: g.replace('<body>', '<body onload="evil()">'), verdict: 'unknown', why: 'an on*= attribute' },
+ { name: 'on-attribute-in-preview', html: g.replace('<p>Page one</p>', '<img src=x onerror="evil()">'), verdict: 'unknown', why: 'an on*= attribute inside the preview' },
+ // scanner-split rows: every host's scanner must agree
+ { name: 'script-in-comment-before-loader', html: g.replace('</head>', `<!-- <${S}>evil()</${S}> --></head>`), verdict: 'unknown', why: 'a comment holding a <script>' },
+ { name: 'script-in-textarea', html: body(`<textarea><${S}>x</${S}></textarea>`), verdict: 'unknown', why: 'a <script> inside <textarea>' },
+ { name: 'script-in-title', html: g.replace('<title>A deck</title>', `<title><${S}>x</${S}></title>`), verdict: 'unknown', why: 'a <script> inside <title>' },
+ { name: 'script-in-style', html: g.replace('<style>body{margin:0}</style>', `<style>/* <${S}>x</${S}> */body{margin:0}</style>`), verdict: 'unknown', why: 'a <style> holding a <script>' },
+ { name: 'doc-block-raw-lt', html: g.replace('"title":"A deck"}', '"title":"<b>"}'), verdict: 'unknown', why: 'a data block containing "<" (Bento always escapes it)' },
+ { name: 'doc-block-double-escape', html: g.replace('"title":"A deck"}', `"title":"<!--<${S}>"}`), verdict: 'unknown', why: '"<!--<script" inside a data block' },
+ // the attribute tokenizer (security and vault, #825): "/" separates attributes,
+ // a quoted value ends one, and the FIRST duplicate wins, as a browser reads them
+ { name: 'slash-before-js-type', html: head(`<${S} /type="text/javascript" type="application/bento+json">x</${S}>`), verdict: 'unknown', why: '"/" separates attributes: the browser reads the FIRST type, JavaScript, and runs it' },
+ { name: 'slash-module-first', html: head(`<${S}/type="module" type="application/bento+json">x</${S}>`), verdict: 'unknown', why: '"/" right after the tag name: the first type is module, and it runs' },
+ { name: 'duplicate-type-js-first', html: head(`<${S} type="text/javascript" type="application/bento+json">x</${S}>`), verdict: 'unknown', why: 'the FIRST duplicate wins: JavaScript' },
+ { name: 'no-separator-after-quoted', html: head(`<${S} type="text/javascript"type="application/bento+json">x</${S}>`), verdict: 'unknown', why: 'a quoted value ends the attribute with no separator: two types, the first JavaScript' },
+ { name: 'form-feed-js-type', html: head(`<${S}\ftype="text/javascript">x</${S}>`), verdict: 'unknown', why: 'form feed is a separator: a JavaScript type' },
+ { name: 'equals-without-value', html: head(`<${S} type=>x</${S}>`), verdict: 'unknown', why: 'type= with no value is the empty type, which runs' },
+ { name: 'leading-equals-name', html: head(`<${S} =type="application/bento+json">x</${S}>`), verdict: 'unknown', why: 'an attribute NAMED "=type" is not type: the script has no type, so it runs' },
+ { name: 'entity-encoded-module', html: head(`<${S} type="&#x6d;odule">x</${S}>`), verdict: 'unknown', why: 'a browser decodes the type to "module"' },
+ { name: 'doc-block-slash-duplicate', html: g.replace(`<${S} type="application/bento+json" id="bento-doc">`, `<${S} /type="text/javascript" type="application/bento+json" id="bento-doc">`), verdict: 'unknown', why: 'the doc block opened with a JavaScript type first: it runs (home-android)' },
+ { name: 'slash-in-data-tag', html: g.replace(`<${S} type="bento/deflate-b86" id="bento-rt"`, `<${S}/type="bento/deflate-b86" id="bento-rt"`), verdict: 'unknown', why: 'Bento never writes "/" in a script tag: refused outright, whatever it means' },
+ { name: 'form-feed-separators', html: g.replace(`<${S} type="bento/deflate-b86" id="bento-rt"`, `<${S}\ftype="bento/deflate-b86"\fid="bento-rt"`), verdict: 'genuine', release: '1.0.0', why: 'form feed between attributes is whitespace: the same block' },
+ { name: 'src-with-loader-body', html: g.replace(`<${S}>load1()</${S}>`, `<${S} src="https://example.invalid/x.js">load1()</${S}>`), verdict: 'unknown', why: 'the browser runs the src and ignores the body: the genuine loader text is no excuse (home-android)' },
+ // tags glued together (home-ios, found by a WebKit oracle): a tag name runs to
+ // whitespace, "/" or ">", so "<meta<style>" is ONE tag and what follows is real
+ { name: 'meta-glued-style', html: g.replace('<meta charset="UTF-8">', `<meta<style><${S}>window.pwned=3</${S}></style> charset="UTF-8">`), verdict: 'unknown', why: '"<meta<style>" is one tag: the script after it is real and runs' },
+ { name: 'p-glued-script', html: body(`<p<${S}>x</${S}>`), verdict: 'unknown', why: 'a start tag named "p<script": Bento writes only plain names' },
+ { name: 'div-glued-style', html: body('<div<style>a{}</style>'), verdict: 'unknown', why: 'a start tag named "div<style"' },
+ { name: 'a-glued-comment', html: body('<a<!-- x -->'), verdict: 'unknown', why: 'a start tag named "a<!--"' },
+ { name: 'empty-comment-then-script', html: body(`<!--><${S}>window.pwned=4</${S}>`), verdict: 'unknown', why: '"<!-->" is a whole comment: the script after it is real' },
+ { name: 'empty-comment-alone', html: body('<!--><!---><p>after</p>'), verdict: 'genuine', release: '1.0.0', why: '"<!-->" and "<!--->" end at once: nothing after them is swallowed' },
+ // the browser's reading must WIN in the genuine direction too (home-desktop):
+ // a walk that ends raw text at any "</name", or doesn't know "<!-->", would
+ // wrongly refuse these, and no unknown row could tell
+ { name: 'empty-comment-in-paragraph', html: body('<p><!--></p><p>after</p>'), verdict: 'genuine', release: '1.0.0', why: '"<!-->" ends at once: the paragraph after it is markup, not comment' },
+ { name: 'style-false-close', html: body('<style>a{}</stylex><b onclick=x></style>'), verdict: 'genuine', release: '1.0.0', why: '"</stylex>" doesn\'t end the style: the <b onclick> is style TEXT, not an element' },
+ { name: 'title-false-close', html: body('<title>t</titlex><b onclick=x></title>'), verdict: 'genuine', release: '1.0.0', why: '"</titlex>" doesn\'t end the title: the <b onclick> is title TEXT' },
+ // the case fold must not change length (home-desktop): toLowerCase() makes 'İ' two units
+ { name: 'case-fold-breakout', html: body('<p>' + 'İ'.repeat(20) + `</p><style>a{}</style><${S}>window.pwned=1</${S}>`), verdict: 'unknown', why: 'a length-changing case fold would skip this script entirely' },
+ { name: 'genuine-length-changing-text', html: file(r1, { title: 'İstanbul ı ß ffi Σ', doc: '{"format":"bento/test","title":"İstanbul ı ß ffi ΣΑΣ İİİİ"}', preview: '<p>İİİİ ß ffi Σ</p>' }), verdict: 'genuine', release: '1.0.0', why: "a genuine document in Turkish (and ß, ffi, Σ) is still genuine" },
+ { name: 'single-quoted-attributes', html: g.replace(/type="bento\/deflate-b86"/g, "type='bento/deflate-b86'"), verdict: 'genuine', release: '1.0.0', why: 'single-quoted attributes parse the same' },
+ { name: 'unquoted-attributes', html: g.replace(/type="bento\/deflate-b86"/g, 'type=bento/deflate-b86'), verdict: 'genuine', release: '1.0.0', why: 'unquoted attributes parse the same' },
+ { name: 'close-tag-with-space', html: g.replace(`>RT1</${S}>`, `>RT1</${S} >`), verdict: 'genuine', release: '1.0.0', why: '"</script >" closes a block like "</script>"' },
+ { name: 'tabs-and-newlines-in-tag', html: g.replace(`<${S} type="bento/deflate-b86" id="bento-rt"`, `<${S}\ttype="bento/deflate-b86"\nid="bento-rt"`), verdict: 'genuine', release: '1.0.0', why: 'whitespace between attributes is whitespace' },
+]
+
+// --- strict rows: the file:// fallback (security §15: both genuine saves pass, all 16 tampers refuse)
+const save1 = file(r1)
+const save2 = file(r1, { title: 'Second', doc: '{"format":"bento/test","title":"Second"}', preview: '<h2>Second deck</h2>' })
+const expected = strictExpectedFrom(save1)
+type Strict = { name: string; html: string; ok: boolean; why: string }
+const at = (h: string, find: string, put: string) => { if (!h.includes(find)) throw new Error(`strict row: ${find} not found`); return h.replace(find, put) }
+const strict: Strict[] = [
+ { name: 'genuine-save1', html: save1, ok: true, why: 'a genuine save' },
+ { name: 'genuine-save2', html: save2, ok: true, why: 'another genuine save: doc, title and preview differ' },
+ { name: 'genuine-save-length-changing-text', html: file(r1, { title: 'İstanbul ß', doc: '{"format":"bento/test","title":"İstanbul ı ß ffi"}', preview: '<p>İİİİ ffi</p>' }), ok: true, why: 'a genuine save in Turkish (and ß, ffi)' },
+ // vault's 9
+ { name: 'sec1-transient-script', html: at(save1, '</body>', `<${S} data-bento-transient>evil()</${S}></body>`), ok: false, why: 'a script under a stripped selector (§13)' },
+ { name: 'sec2-extra-preview-script', html: at(save1, '</body>', `<${S} data-bento-preview>evil()</${S}></body>`), ok: false, why: 'a second remover-shaped script' },
+ { name: 'sec3-loader-byte', html: at(save1, 'load1()', 'load1( )'), ok: false, why: 'one loader byte changed' },
+ { name: 'sec4-plain-script', html: at(save1, '</body>', `<${S}>evil()</${S}></body>`), ok: false, why: 'a plain script' },
+ { name: 'sec5-onclick', html: at(save1, '<body>', '<body onclick="x">'), ok: false, why: 'onclick on body' },
+ { name: 'v1-doc-executable', html: at(save1, 'type="application/bento+json" id="bento-doc"', 'type="text/javascript" id="bento-doc"'), ok: false, why: 'the doc block retyped as executable' },
+ { name: 'v2-script-in-preview', html: at(save1, 'data-bento-preview="1"><p>', `data-bento-preview="1"><${S}>evil()</${S}><p>`), ok: false, why: 'a script inside the preview markup' },
+ { name: 'v3-onerror-in-preview', html: at(save1, '<p>Page one</p>', '<img src=x onerror="evil()">'), ok: false, why: 'onerror inside the preview markup' },
+ { name: 'v4-second-doc-anchor', html: at(save1, '</body>', `<${S} id="bento-doc">evil()</${S}></body>`), ok: false, why: 'a second doc anchor' },
+ // security's 7
+ { name: 's1-script-after-html', html: save1 + `<${S}>evil()</${S}>`, ok: false, why: 'a trailing script after </html>' },
+ { name: 's2-trailing-bytes', html: save1 + 'x', ok: false, why: 'trailing bytes' },
+ { name: 's3-leading-bytes', html: 'x' + save1, ok: false, why: 'leading bytes before <!DOCTYPE' },
+ { name: 's4-uppercase-preview-script', html: at(save1, '</body>', `<SCRIPT DATA-BENTO-PREVIEW>evil()</SCRIPT></body>`), ok: false, why: 'an uppercase <SCRIPT DATA-BENTO-PREVIEW>' },
+ { name: 's5-decoy-preview-div', html: at(save1, '<div data-bento-preview="1">', `<div data-bento-preview="1"><${S}>evil()</${S}></div><div data-bento-preview="1">`), ok: false, why: 'an attacker preview div placed to shift the span' },
+ { name: 's6-crlf', html: save1.replace(/\n/g, '\r\n'), ok: false, why: 'CRLF in the skeleton' },
+ { name: 's7-tab-script', html: at(save1, '</body>', `<\t${S}>evil()</${S}></body>`), ok: false, why: '"<\\tscript>"' },
+]
+if (strict.filter((r) => !r.ok).length !== 16) throw new Error('the strict corpus must carry exactly the 16 tamper rows')
+
+// --- history rows: anti-rollback (acceptHistory) ---------------------------------------
+const without = (h: History, v: string): History => ({ ...h, releases: h.releases.filter((e) => e.version !== v) })
+const older = without(history, '1.2.0')
+const histories: Array<{ name: string; held: History | null; incoming: History; ok: boolean; why: string }> = [
+ { name: 'first', held: null, incoming: history, ok: true, why: 'the first history a host sees' },
+ { name: 'newer-superset', held: older, incoming: history, ok: true, why: 'a newer history keeping every held entry' },
+ { name: 'same-again', held: history, incoming: history, ok: true, why: 'the same history again' },
+ { name: 'replayed-older', held: history, incoming: older, ok: false, why: 'ROLLBACK: a replayed older history' },
+ { name: 'lacks-held-entry', held: history, incoming: without(history, '1.0.0'), ok: false, why: 'ROLLBACK: it lacks an entry the host holds' },
+ { name: 'changed-entry', held: history, incoming: { ...history, releases: history.releases.map((e) => (e.version === '1.0.0' ? { ...e, sha256: 'c'.repeat(64) } : e)) }, ok: false, why: 'an entry changed' },
+ { name: 'other-app', held: null, incoming: { ...history, app: 'bento-other' }, ok: false, why: "another app's history" },
+ { name: 'not-newest-first', held: null, incoming: { ...history, releases: [...history.releases].reverse() }, ok: false, why: 'malformed: not newest first' },
+]
+
+// --- an ambiguous history: two entries with identical blocks (unsigned: it's about the
+// matching rule, not the signature). A file matching both is UNKNOWN, never "the first".
+const twins: History = { ...history, releases: [{ ...history.releases.find((e) => e.version === '1.0.0')!, version: '1.3.0' }, ...history.releases] }
+const ambiguous = [{ name: 'twin-entries', history: twins, html: g, verdict: 'unknown' as const, why: 'two entries match every block: ambiguous' }]
+
+// --- check the reference agrees with every declared verdict, then write -----------------
+const disagree: string[] = []
+for (const r of served) {
+ const v = await verifyServed(r.html, history)
+ const got = v.verdict === 'genuine' ? `genuine ${v.release.version}` : 'unknown'
+ const want = r.verdict === 'genuine' ? `genuine ${r.release}` : 'unknown'
+ if (got !== want) disagree.push(`served ${r.name}: declared ${want}, the reference says ${got}`)
+}
+for (const r of ambiguous) if ((await verifyServed(r.html, r.history)).verdict !== r.verdict) disagree.push(`ambiguous ${r.name}: declared ${r.verdict}`)
+for (const r of strict) if (verifyStrict(r.html, expected).ok !== r.ok) disagree.push(`strict ${r.name}: declared ${r.ok ? 'pass' : 'refuse'}`)
+for (const r of histories) if (acceptHistory(r.held, r.incoming, 'bento-test').ok !== r.ok) disagree.push(`history ${r.name}: declared ${r.ok ? 'accept' : 'refuse'}`)
+if (disagree.length) { console.error(`the reference disagrees with the declared verdicts:\n ${disagree.join('\n ')}`); process.exit(1) }
+
+const { privateKey, publicKey } = generateKeyPairSync('ec', { namedCurve: 'P-256' })
+const payload = JSON.stringify(history)
+const envelope = { payload, sig: sign('sha256', Buffer.from(payload, 'utf8'), { key: privateKey, dsaEncoding: 'ieee-p1363' }).toString('base64') }
+
+// clear only what this generator owns: README.md is written by hand and stays
+for (const d of ['served', 'strict']) rmSync(join(OUT, d), { recursive: true, force: true })
+mkdirSync(join(OUT, 'served'), { recursive: true }); mkdirSync(join(OUT, 'strict'), { recursive: true })
+for (const r of served) writeFileSync(join(OUT, 'served', `${r.name}.html`), r.html)
+for (const r of strict) writeFileSync(join(OUT, 'strict', `${r.name}.html`), r.html)
+writeFileSync(join(OUT, 'history.json'), JSON.stringify(envelope, null, 2) + '\n')
+writeFileSync(join(OUT, 'test-public-key.json'), JSON.stringify(publicKey.export({ format: 'jwk' }), null, 2) + '\n')
+writeFileSync(join(OUT, 'strict-expected.json'), JSON.stringify(expected, null, 2) + '\n')
+writeFileSync(join(OUT, 'expected.json'), JSON.stringify({
+ note: 'gate-1 conformance corpus (bento/connect K5). Every host must reach each verdict. Regenerate with node scripts/gen-gate1-corpus.ts; check with node scripts/test-gate1.ts.',
+ app: 'bento-test',
+ served: served.map((r) => ({ case: `served/${r.name}.html`, verdict: r.verdict, ...(r.release ? { release: r.release } : {}), why: r.why })),
+ strict: strict.map((r) => ({ case: `strict/${r.name}.html`, ok: r.ok, why: r.why })),
+ history: histories.map((r) => ({ name: r.name, held: r.held, incoming: r.incoming, ok: r.ok, why: r.why })),
+ ambiguous: ambiguous.map((r) => { writeFileSync(join(OUT, 'served', `${r.name}.html`), r.html); return { case: `served/${r.name}.html`, history: r.history, verdict: r.verdict, why: r.why } }),
+}, null, 2) + '\n')
+console.log(`wrote ${OUT}: ${served.length} served rows, ${strict.length} strict rows (16 tampers), ${histories.length} history rows`)
diff --git a/scripts/lib/release-history.mjs b/scripts/lib/release-history.mjs
index 77c3f4b2..1b27c0d2 100644
--- a/scripts/lib/release-history.mjs
+++ b/scripts/lib/release-history.mjs
@@ -21,41 +21,19 @@
// releases sharing a runtime can't be confused, and anything partial is
// UNKNOWN: restricted mode or an update offer, never a borrowed pinned CSP.
-import { checkAgainstPins, scanBlocks } from './release-pins.mjs'
-import { createHash } from 'node:crypto'
+// The HOST rules (acceptHistory, matchRelease, historyProblems) are the kernel's
+// gate-1 module, one implementation for every JavaScript host (K5). This file
+// adds only what SIGNING needs: nextHistory().
+import { acceptHistory, matchRelease, historyProblems, cmpVersion } from '../../kernel/src/gate1.ts'
+export { acceptHistory, matchRelease, historyProblems, cmpVersion }
export const HISTORY_V = 1
const SEMVER = /^(\d+)\.(\d+)\.(\d+)$/
-export function cmpVersion(a, b) {
- const x = SEMVER.exec(a), y = SEMVER.exec(b)
- if (!x || !y) throw new Error(`release-history: not a version: ${!x ? a : b}`)
- for (let i = 1; i <= 3; i++) { const d = Number(x[i]) - Number(y[i]); if (d) return d }
- return 0
-}
-
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b)
const entryOk = (e) => e && typeof e.version === 'string' && SEMVER.test(e.version) &&
/^[0-9a-f]{64}$/.test(e.sha256 ?? '') && typeof e.at === 'string' && e.pins?.v === 1 && typeof e.pins.blocks === 'object'
-/** Check a history payload's shape; returns the problems ([] = well-formed). */
-export function historyProblems(h) {
- const p = []
- if (!h || h.v !== HISTORY_V) p.push(`version ${h?.v} (expected ${HISTORY_V})`)
- if (typeof h?.app !== 'string' || !h.app) p.push('no app')
- if (!Array.isArray(h?.releases)) { p.push('no releases'); return p }
- const seen = new Set()
- h.releases.forEach((e, i) => {
- if (!entryOk(e)) p.push(`entry ${i} is malformed`)
- else {
- if (seen.has(e.version)) p.push(`version ${e.version} appears twice`)
- seen.add(e.version)
- if (i > 0 && entryOk(h.releases[i - 1]) && cmpVersion(h.releases[i - 1].version, e.version) <= 0) p.push(`entries are not newest-first at ${e.version}`)
- }
- })
- return p
-}
-
/**
* The next history: `held` (null for the first) plus `entry` for a new release.
* Re-signing the SAME release (same version and sha256 and pins) is a no-op. A
@@ -80,40 +58,3 @@ export function nextHistory(app, held, entry) {
}
return { app, v: HISTORY_V, releases: [entry, ...releases] }
}
-
-/**
- * A HOST's acceptance of an incoming (already signature-verified) history,
- * given the newest it holds. Returns { ok: true } or { ok: false, reason }.
- */
-export function acceptHistory(held, incoming, app) {
- const problems = historyProblems(incoming)
- if (problems.length) return { ok: false, reason: `malformed: ${problems[0]}` }
- if (incoming.app !== app) return { ok: false, reason: `for ${incoming.app}, not ${app}` }
- if (!held) return { ok: true }
- if (!incoming.releases.length || (held.releases.length && cmpVersion(incoming.releases[0].version, held.releases[0].version) < 0)) {
- return { ok: false, reason: 'rollback: its newest release is older than the newest already held' }
- }
- for (const e of held.releases) {
- const there = incoming.releases.find((x) => x.version === e.version)
- if (!there) return { ok: false, reason: `rollback: it lacks ${e.version}, which is already held` }
- if (!same(there, e)) return { ok: false, reason: `${e.version} changed: a history never changes an entry` }
- }
- return { ok: true }
-}
-
-const blockHash = (html, id) => {
- const found = scanBlocks(html).filter((b) => b.id === id)
- return found.length === 1 ? createHash('sha256').update(found[0].text, 'utf8').digest('hex') : null
-}
-
-/**
- * Which release made this file? The ONE entry matching every block; null when
- * none does, or when more than one would (UNKNOWN either way).
- */
-export function matchRelease(history, html) {
- const rt = blockHash(html, 'bento-rt')
- if (!rt) return null
- const candidates = history.releases.filter((e) => e.pins.blocks['bento-rt'] === rt)
- const full = candidates.filter((e) => checkAgainstPins(html, e.pins).length === 0)
- return full.length === 1 ? full[0] : null
-}
diff --git a/scripts/lib/release-pins.mjs b/scripts/lib/release-pins.mjs
index 9c8374d6..a98bd691 100644
--- a/scripts/lib/release-pins.mjs
+++ b/scripts/lib/release-pins.mjs
@@ -20,102 +20,14 @@
// real saved file, and in CI on every PR's build.
import { createHash } from 'node:crypto'
+// ONE implementation of the scanner, the grammar and the host's check: the
+// kernel's gate-1 module, which every JavaScript host runs (K5). This file adds
+// only what a RELEASE needs: deriving the pins in the first place.
+import { scanBlocks, executableScripts, markupProblems, checkAgainstPins, isDataScript, DATA_TYPES } from '../../kernel/src/gate1.ts'
+export { scanBlocks, executableScripts, markupProblems, checkAgainstPins, isDataScript, DATA_TYPES }
const sha256hex = (s) => createHash('sha256').update(s, 'utf8').digest('hex')
const cspHash = (s) => `sha256-${createHash('sha256').update(s, 'utf8').digest('base64')}`
-
-// THE GRAMMAR (security, 2026-10-21): a <script> is inert ONLY if its type is
-// one of the exact data types Bento writes. Everything else is executable: no
-// type, a JavaScript MIME type, "module", an unknown type, a differently cased
-// data type, and ANY src=. An executable script must then be exactly the pinned
-// loader or remover by hash, or the file is UNKNOWN. An allowlist, not a list of
-// JavaScript types: a script type a browser treats as runnable tomorrow can't
-// slip through as "data".
-export const DATA_TYPES = new Set(['application/bento+json', 'application/bento+lang', 'bento/deflate-b64', 'bento/deflate-b86'])
-export const isDataScript = (b) => b.tag === 'script' && b.src === null && b.type !== null && DATA_TYPES.has(b.type)
-
-const attr = (attrs, name) => {
- const m = new RegExp(`(?:^|\\s)${name}(?:\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'>]+)))?(?=\\s|$)`, 'i').exec(attrs)
- if (!m) return null
- return m[1] ?? m[2] ?? m[3] ?? ''
-}
-
-/**
- * Every <script> and <style> element, with its raw text: a script's text ends at
- * the first `</script` (any case), which is how the HTML tokenizer ends it too.
- */
-export function scanBlocks(html) {
- const out = []
- const open = /<(script|style)\b([^>]*)>/gi
- let m
- while ((m = open.exec(html))) {
- const tag = m[1].toLowerCase()
- const start = m.index + m[0].length
- const close = html.toLowerCase().indexOf(`</${tag}`, start)
- if (close < 0) throw new Error(`release-pins: unterminated <${tag}> at ${m.index}`)
- const attrs = m[2]
- out.push({
- tag, attrs, text: html.slice(start, close), start,
- type: attr(attrs, 'type'), id: attr(attrs, 'id'), src: attr(attrs, 'src'),
- preview: attr(attrs, 'data-bento-preview') !== null,
- })
- open.lastIndex = close
- }
- return out
-}
-
-/** Every script that is not one of Bento's data blocks: each must be the pinned loader or remover. */
-export const executableScripts = (blocks) => blocks.filter((b) => b.tag === 'script' && !isDataScript(b))
-
-/**
- * Markup a genuine Bento file never carries (security, 2026-10-21), anywhere
- * outside a script or style element's own text: <iframe>, <object>, <embed>,
- * <base>, a <meta> refresh or CSP, any on*= attribute, and a comment holding a
- * <script>. A data block containing "<" is refused too: Bento's never do (the
- * document JSON and language packs escape it, the b64/b86 alphabets exclude
- * it), and a "<!--<script" inside script text would put the browser's
- * tokenizer in a state where a later close tag doesn't end the element. Returns
- * the problems; [] = none.
- */
-export function markupProblems(html) {
- const problems = []
- const lower = html.toLowerCase()
- let i = 0
- while ((i = html.indexOf('<', i)) !== -1) {
- if (html.startsWith('<!--', i)) {
- const end = html.indexOf('-->', i + 4)
- const body = lower.slice(i + 4, end < 0 ? html.length : end)
- if (body.includes('<script')) problems.push('a comment holds a <script>')
- if (end < 0) { problems.push('an unterminated comment'); break }
- i = end + 3; continue
- }
- const m = /^<([a-zA-Z][a-zA-Z0-9-]*)/.exec(html.slice(i, i + 64))
- if (!m) { i++; continue }
- const name = m[1].toLowerCase()
- // the tag's attributes, quote-aware, up to its closing '>'
- let j = i + m[0].length, q = null
- for (; j < html.length; j++) {
- const c = html[j]
- if (q) { if (c === q) q = null } else if (c === '"' || c === "'") q = c; else if (c === '>') break
- }
- const attrs = html.slice(i + m[0].length, j)
- if (['iframe', 'object', 'embed', 'base'].includes(name)) problems.push(`a <${name}>`)
- if (name === 'meta' && /http-equiv\s*=\s*["']?\s*(refresh|content-security-policy)/i.test(attrs)) problems.push('a <meta> refresh or CSP')
- if (/(^|[\s"'/])on[a-z0-9_-]*\s*=/i.test(attrs)) problems.push(`an on*= attribute on <${name}>`)
- if (name === 'script' || name === 'style') {
- const close = lower.indexOf(`</${name}`, j)
- if (close < 0) { problems.push(`an unterminated <${name}>`); break }
- // inert to a browser, but a scanner that doesn't special-case <style>
- // would count it: refuse, so every host's scanner reaches the same verdict
- if (name === 'style' && lower.slice(j, close).includes('<script')) problems.push('a <style> holds a <script>')
- i = close + 2; continue
- }
- i = j + 1
- }
- for (const b of scanBlocks(html)) if (isDataScript(b) && b.text.includes('<')) problems.push(`the ${b.type} block contains "<"`)
- return problems
-}
-
const CODE_IDS = ['bento-rt', 'bento-rt-css']
/**
@@ -159,25 +71,3 @@ export function derivePins(shellHtml, savedHtml, { historic = false } = {}) {
}
return { v: 1, blocks, scriptSrc: remover === null ? [cspHash(loader)] : [cspHash(loader), cspHash(remover)] }
}
-
-/**
- * Check a file against one release's pins, the way a host must (security §36):
- * exactly one block per code id, each hash equal, and the executable inline
- * scripts exactly the pinned loader and remover. Returns the problems; [] = match.
- */
-export function checkAgainstPins(html, pins) {
- const problems = [...markupProblems(html)]
- const blocks = scanBlocks(html)
- for (const id of CODE_IDS) {
- const found = blocks.filter((b) => b.id === id)
- if (found.length !== 1) problems.push(`${found.length} #${id} blocks (exactly one expected)`)
- else if (sha256hex(found[0].text) !== pins.blocks[id]) problems.push(`#${id} does not match`)
- }
- const exec = executableScripts(blocks)
- const allowed = new Set([pins.blocks.loader, pins.blocks.remover].filter(Boolean))
- for (const s of exec) if (s.src !== null || !allowed.has(sha256hex(s.text))) problems.push(`an executable script that is neither the pinned loader nor the remover (${s.src !== null ? 'src=' + s.src : s.text.length + 'B'})`)
- if (!exec.some((s) => sha256hex(s.text) === pins.blocks.loader)) problems.push('no pinned loader')
- if (exec.filter((s) => sha256hex(s.text) === pins.blocks.loader).length > 1) problems.push('more than one loader')
- if (pins.blocks.remover && exec.filter((s) => sha256hex(s.text) === pins.blocks.remover).length > 1) problems.push('more than one remover')
- return problems
-}
diff --git a/scripts/test-gate1-oracle.mjs b/scripts/test-gate1-oracle.mjs
new file mode 100644
index 00000000..2ada9fc1
--- /dev/null
+++ b/scripts/test-gate1-oracle.mjs
@@ -0,0 +1,189 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+//
+// THE BROWSER ORACLE for gate 1 (security, after #825's two findings). A
+// differential fuzz between the reference and a port can't see a bug they
+// SHARE, and both the "/" separator and the length-changing case fold were
+// shared. A browser is the ground truth for "what runs", so this asks it.
+//
+// Take a genuine file, mutate it the ways scanners disagree:
+// - candidate scripts in disguise: "/", quotes, case, duplicates, NUL, "=",
+// entities, src=, form feed;
+// - a run of length-changing characters before a <style> before a script;
+// - the genuine loader's text behind a src=;
+// - edits to the real blocks' tags;
+// - length-changing characters (İ ß ffi Σ);
+// - wrappers (comments, <style>, <textarea>, <title>).
+// For every mutant gate1 calls GENUINE, load it in the browser with NO CSP and
+// record what ran: the loader and remover push to a log, every candidate pushes
+// its own name, and any data block that executes throws (its text isn't
+// JavaScript), which a window error counter sees. A genuine verdict is only
+// right if exactly the loader and the remover ran. Anything else is a failing
+// row, written to home/fixtures/gate1/oracle-failures/ for every port to run.
+//
+// node scripts/test-gate1-oracle.mjs [--seed N] [--cases N] [--random N]
+//
+// CI runs a fixed seed, plus a short run from a random seed (printed, so a
+// failure can be replayed).
+
+import { mkdirSync, writeFileSync } from 'node:fs'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { createHash } from 'node:crypto'
+import { verifyServed } from '../kernel/src/gate1.ts'
+
+const args = process.argv.slice(2)
+const opt = (n, d) => { const i = args.indexOf(`--${n}`); return i >= 0 ? Number(args[i + 1]) : d }
+const FIXED_SEED = opt('seed', 20261021), CASES = opt('cases', 400), RANDOM = opt('random', 100)
+const OUT = join(dirname(fileURLToPath(import.meta.url)), '..', 'home/fixtures/gate1/oracle-failures')
+
+// --- a synthetic release whose loader and remover REPORT that they ran --------------
+const S = 'scr' + 'ipt'
+const LOADER = "window.__ran.push('loader')"
+const REMOVER = "window.__ran.push('remover');(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()"
+const hex = (s) => createHash('sha256').update(s, 'utf8').digest('hex')
+const csp = (s) => `sha256-${createHash('sha256').update(s, 'utf8').digest('base64')}`
+const genuine = (o = {}) => '<!DOCTYPE html>\n<html lang="en"><head>\n<meta charset="UTF-8">\n' +
+ `<title>${o.title ?? 'A deck'}</title>\n<style>body{margin:0}</style>\n` +
+ `<${S} type="application/bento+json" id="bento-doc">${o.doc ?? '{"format":"bento/test","title":"A deck"}'}</${S}>\n` +
+ `<${S} type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</${S}>\n` +
+ `<${S} type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</${S}>\n` +
+ `</head><body>\n<div data-bento-preview="1">${o.preview ?? '<p>Page one</p>'}</div><${S} data-bento-preview="1">${REMOVER}</${S}>\n` +
+ `<${S}>${LOADER}</${S}>\n</body></html>\n`
+const history = {
+ app: 'bento-oracle', v: 1,
+ releases: [{ version: '1.0.0', sha256: hex(genuine()), at: '2026-10-21T00:00:00.000Z',
+ pins: { v: 1, blocks: { 'bento-rt': hex('RT1'), 'bento-rt-css': hex('CSS1'), loader: hex(LOADER), remover: hex(REMOVER) }, scriptSrc: [csp(LOADER), csp(REMOVER)] } }],
+}
+
+// --- the mutation operators -------------------------------------------------------
+function rng(seed) { let a = seed >>> 0; return () => { a = (a + 0x6d2b79f5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296 } }
+function mutant(r, n) {
+ const pick = (xs) => xs[Math.floor(r() * xs.length)]
+ const sep = () => pick([' ', ' ', '\t', '\n', '\f', '/', ' /', '/ ', '\r'])
+ const q = (v) => pick([`"${v}"`, `'${v}'`, v.includes(' ') ? `"${v}"` : v])
+ const typeName = () => pick(['type', 'type', 'TYPE', 'Type', 'ty\u0000pe', '=type', 'typ', 'type '])
+ const dataType = () => pick(['application/bento+json', 'bento/deflate-b86', 'bento/deflate-b64', 'application/bento+lang'])
+ const runType = () => pick(['', 'text/javascript', 'module', 'Module', 'text/JavaScript', 'application/ecmascript', '&#x6d;odule', 'text/x-unknown', 'application/bento+JSON'])
+ const typeAttr = (v) => `${typeName()}=${q(v)}`
+ const name = `x${n}`
+ const body = `window.__ran.push('${name}')`
+ // a candidate script: zero to three type attributes in some order, maybe src
+ const attrs = []
+ const k = Math.floor(r() * 4)
+ for (let i = 0; i < k; i++) attrs.push(typeAttr(r() < 0.5 ? dataType() : runType()))
+ if (r() < 0.12) attrs.push(`src=${q('data:text/javascript,' + encodeURIComponent(body))}`)
+ if (r() < 0.25) attrs.push(`id=${q(pick(['bento-rt', 'bento-doc', 'bento-rt-css']))}`)
+ if (r() < 0.1) attrs.push('data-bento-preview="1"')
+ const tagName = pick(['script', 'script', 'SCRIPT', 'Script'])
+ const candidate = `<${tagName}${attrs.map((a) => sep() + a).join('')}${pick(['', '', ' ', '/'])}>${body}</${pick(['script', 'SCRIPT', 'script '])}>`
+ const wrapped = pick([candidate, candidate, candidate, `<!-- ${candidate} -->`, `<textarea>${candidate}</textarea>`, `<title>${candidate}</title>`, `<style>/*${candidate}*/</style>`, `<template>${candidate}</template>`])
+ const len = () => pick(['İ', 'ß', 'ffi', 'Σ', 'ı', 'İİİİİİİİİİ', 'İ'.repeat(40)])
+ let h = genuine({
+ title: r() < 0.4 ? `A ${len()} deck` : undefined,
+ doc: r() < 0.4 ? `{"format":"bento/test","title":"${len()}${len()}"}` : undefined,
+ preview: r() < 0.3 ? `<p>${len()}</p>` : undefined,
+ })
+ // where to put it
+ const spots = ['</head>', '</body>', `<${S}>${LOADER}`, '<div data-bento-preview', '<style>', '</title>']
+ const at = pick(spots)
+ if (r() < 0.75) h = h.replace(at, at.startsWith('</') ? wrapped + at : wrapped + at)
+ // a run of length-changing characters, then a <style>, then the candidate: a
+ // case fold that changes length lands the style's close late and skips it
+ if (r() < 0.2) h = h.replace('</body>', `<p>${len()}${len()}</p><style>a{}</style>${candidate}</body>`)
+ // tags glued together: a name runs to whitespace, "/" or ">", so "<meta<style>"
+ // is one tag and what follows is real (home-ios found this with a WebKit oracle)
+ if (r() < 0.2) {
+ const glue = pick([`<${pick(['meta', 'p', 'div', 'a', 'span'])}<style>${candidate}</style>`, `<${pick(['p', 'div', 'b'])}${candidate}`,
+ `<a<!--${candidate}-->`, `<!-->${candidate}`, `<!--->${candidate}`])
+ h = h.replace(pick(['</head>', '</body>', '<meta charset="UTF-8">']), (m) => m === '<meta charset="UTF-8">' ? glue + ' ' + m : glue + m)
+ }
+ // the loader's own text behind a src=: the browser runs the src and ignores it
+ if (r() < 0.1) h = h.replace(`<${S}>${LOADER}`, `<${S}${sep()}src=${q('data:text/javascript,' + encodeURIComponent(body))}>${LOADER}`)
+ // or edit a real block's tag the ways scanners split
+ if (r() < 0.35) {
+ const real = pick([`<${S} type="application/bento+json" id="bento-doc">`, `<${S} type="bento/deflate-b86" id="bento-rt"`, `<${S} type="bento/deflate-b86" id="bento-rt-css"`, `<${S}>${LOADER}`])
+ const edit = pick([
+ (t) => t.replace(`<${S} `, `<${S}/`),
+ (t) => t.replace(`<${S} `, `<${S} type="text/javascript"${sep()}`),
+ (t) => t.replace(`<${S} `, `<${S}${sep()}`),
+ (t) => t.replace(`<${S}`, `<SCRIPT`),
+ (t) => t.replace('type=', 'TYPE='),
+ ])
+ h = h.replace(real, edit(real))
+ }
+ return { html: h, name }
+}
+
+// --- the browsers -----------------------------------------------------------------
+// BOTH engines: a Chromium-only oracle missed the glued-tag bypass that a WebKit
+// oracle found (home-ios). ORACLE_ENGINES=chromium,webkit (the default) or one.
+const pw = await import(process.env.PLAYWRIGHT_MODULE || 'playwright')
+const engines = (process.env.ORACLE_ENGINES || 'chromium,webkit').split(',').map((e) => e.trim()).filter(Boolean)
+const browsers = []
+for (const e of engines) browsers.push({ engine: e, b: await pw[e].launch(e === 'chromium' ? { executablePath: process.env.CHROME_PATH, headless: true } : { headless: true }) })
+let browser = browsers[0].b
+const URL_ = 'https://bento-oracle.test/doc.html'
+async function whatRan(html) {
+ const context = await browser.newContext()
+ await context.route('**/*', (route) => route.request().url() === URL_
+ ? route.fulfill({ status: 200, headers: { 'content-type': 'text/html; charset=utf-8' }, body: html })
+ : route.abort())
+ await context.addInitScript(() => {
+ window.__ran = []; window.__errors = 0
+ addEventListener('error', () => { window.__errors++ }, true)
+ })
+ const page = await context.newPage()
+ try {
+ await page.goto(URL_, { waitUntil: 'load', timeout: 15000 })
+ await page.waitForTimeout(150)
+ return await page.evaluate(() => ({ ran: [...window.__ran], errors: window.__errors }))
+ } finally { await context.close() }
+}
+
+let failures = 0, checks = 0
+const ok = (cond, what) => { checks++; if (cond) console.log(' ok ' + what); else { failures++; console.log(' FAIL ' + what) } }
+/** What ran in EVERY engine; a mutant is clean only if it's clean in all of them. */
+async function whatRanEverywhere(html) {
+ const out = []
+ for (const { engine, b } of browsers) { browser = b; out.push({ engine, ...(await whatRan(html)) }) }
+ return out
+}
+const onlyPinned = (r) => r.errors === 0 && r.ran.length === 2 && r.ran.includes('loader') && r.ran.includes('remover')
+
+try {
+ console.log(`\ncontrols, in each engine (${engines.join(', ')}): the oracle can see both kinds of extra execution`)
+ for (const r of await whatRanEverywhere(genuine())) ok(onlyPinned(r), `${r.engine}: a genuine file runs exactly the loader and the remover (${JSON.stringify(r.ran)}, ${r.errors} errors)`)
+ for (const r of await whatRanEverywhere(genuine().replace('</body>', `<${S}>window.__ran.push('extra')</${S}></body>`))) ok(r.ran.includes('extra'), `${r.engine}: an extra script is SEEN running`)
+ for (const r of await whatRanEverywhere(genuine().replace('type="bento/deflate-b86" id="bento-rt"', 'id="bento-rt"'))) ok(r.errors > 0, `${r.engine}: a data block that executes is SEEN (its text throws)`)
+ ok((await verifyServed(genuine(), history)).verdict === 'genuine', 'gate1 calls the genuine file genuine')
+
+ const runs = [[FIXED_SEED, CASES, 'fixed seed'], [Math.floor(Math.random() * 2 ** 31), RANDOM, 'random seed']]
+ for (const [seed, cases, label] of runs) {
+ console.log(`\n${label} ${seed}: ${cases} mutants`)
+ const r = rng(seed)
+ let genuineCount = 0, bad = 0
+ for (let n = 0; n < cases; n++) {
+ const { html } = mutant(r, n)
+ const v = await verifyServed(html, history)
+ if (v.verdict !== 'genuine') continue
+ genuineCount++
+ const dirty = (await whatRanEverywhere(html)).filter((r) => !onlyPinned(r))
+ if (dirty.length) {
+ bad++
+ mkdirSync(OUT, { recursive: true })
+ // each failure is UNKNOWN against THIS history: written beside it, so a
+ // port can run the folder with nothing else
+ writeFileSync(join(OUT, 'history.json'), JSON.stringify(history, null, 2) + '\n')
+ const file = join(OUT, `seed-${seed}-case-${n}.html`)
+ writeFileSync(file, html)
+ console.log(` FAIL case ${n}: gate1 says GENUINE but ${dirty.map((r) => `${r.engine} ran ${JSON.stringify(r.ran)} (${r.errors} errors)`).join('; ')} → ${file}`)
+ }
+ }
+ ok(bad === 0, `${label}: every one of the ${genuineCount} GENUINE verdicts ran only the loader and remover (${cases - genuineCount} unknown)`)
+ }
+} finally {
+ for (const { b } of browsers) await b.close()
+}
+console.log(`\n${checks - failures}/${checks} checks passed`)
+process.exit(failures ? 1 : 0)
diff --git a/scripts/test-gate1.ts b/scripts/test-gate1.ts
new file mode 100644
index 00000000..90fee609
--- /dev/null
+++ b/scripts/test-gate1.ts
@@ -0,0 +1,83 @@
+#!/usr/bin/env node
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// The JavaScript reference (kernel/src/gate1.ts) against the gate-1 corpus,
+// read from disk exactly as a native host's rig reads it.
+//
+// node scripts/test-gate1.ts
+//
+// Every host's verifier must reach the same verdict on every row:
+// - served: one release matches every block, or UNKNOWN (security §36 and
+// the 2026-10-21 grammar);
+// - strict: the file:// fallback passes both genuine saves and refuses all
+// 16 tampers (security §15);
+// - history: anti-rollback.
+// The history's signature is checked first with the corpus's TEST key, as a
+// host checks the real one with the release key.
+
+import { readFileSync } from 'node:fs'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { createPublicKey, verify } from 'node:crypto'
+import { verifyServed, verifyStrict, acceptHistory, hostPolicy, type History, type StrictExpected } from '../kernel/src/gate1.ts'
+
+let failures = 0
+let checks = 0
+function ok(cond: boolean, msg: string) {
+ checks++
+ if (!cond) { failures++; console.log(` FAIL ${msg}`) }
+ else console.log(` ok ${msg}`)
+}
+
+const DIR = join(dirname(fileURLToPath(import.meta.url)), '..', 'home/fixtures/gate1')
+const read = (p: string) => readFileSync(join(DIR, p), 'utf8')
+const E = JSON.parse(read('expected.json'))
+
+console.log('\nthe signed history (verified with the corpus TEST key, as hosts verify the release key)')
+const envelope = JSON.parse(read('history.json'))
+const pub = createPublicKey({ key: JSON.parse(read('test-public-key.json')), format: 'jwk' })
+const sigOk = verify('sha256', Buffer.from(envelope.payload, 'utf8'), { key: pub, dsaEncoding: 'ieee-p1363' }, Buffer.from(envelope.sig, 'base64'))
+ok(sigOk, 'history.json verifies')
+const tampered = envelope.payload.replace('1.0.0', '1.0.1')
+ok(!verify('sha256', Buffer.from(tampered, 'utf8'), { key: pub, dsaEncoding: 'ieee-p1363' }, Buffer.from(envelope.sig, 'base64')), 'a tampered payload does not')
+const history: History = JSON.parse(envelope.payload)
+
+console.log('\nserved: ONE release must match EVERY block')
+for (const row of E.served) {
+ const v = await verifyServed(read(row.case), history)
+ const got = v.verdict === 'genuine' ? `genuine ${v.release.version}` : 'unknown'
+ const want = row.verdict === 'genuine' ? `genuine ${row.release}` : 'unknown'
+ ok(got === want, `${row.case.replace('served/', '')}: ${want}${v.verdict === 'unknown' ? ` (${v.reason})` : ''}`)
+ if (v.verdict === 'genuine') {
+ const p = v.csp
+ ok(p.includes(`'${v.release.pins.scriptSrc[0]}'`) && !/unsafe-eval|'unsafe-inline'[^;]*script|script-src[^;]*\*/.test(p) && p.startsWith("default-src 'none'"),
+ ` …served under its own pins, with no unsafe-eval or wildcard script source`)
+ }
+}
+
+console.log('\nambiguous: two entries matching every block is UNKNOWN, never "the first"')
+for (const row of E.ambiguous) ok((await verifyServed(read(row.case), row.history)).verdict === row.verdict, `${row.case.replace('served/', '')} under its own history: ${row.verdict} (${row.why})`)
+
+console.log('\nstrict (file://): both genuine saves pass, all 16 tampers refuse')
+const expected: StrictExpected = JSON.parse(read('strict-expected.json'))
+let tampers = 0
+for (const row of E.strict) {
+ const v = verifyStrict(read(row.case), expected)
+ if (!row.ok) tampers++
+ ok(v.ok === row.ok, `${row.case.replace('strict/', '')}: ${row.ok ? 'pass' : `refuse (${v.ok ? 'PASSED' : v.reason})`}`)
+}
+ok(tampers === 16, 'the corpus carries exactly the 16 tamper rows')
+
+console.log('\nhistory: anti-rollback')
+for (const row of E.history) ok(acceptHistory(row.held, row.incoming, E.app).ok === row.ok, `${row.name}: ${row.ok ? 'accept' : 'refuse'} (${row.why})`)
+
+console.log('\nthe CSP a host serves under (security §17 verifies the string)')
+{
+ const p = hostPolicy(history.releases[0].pins)
+ ok(/script-src 'sha256-[A-Za-z0-9+/=]+' 'sha256-[A-Za-z0-9+/=]+' blob:;/.test(p), 'script-src is the two pins plus blob:, nothing else')
+ ok(!p.includes('unsafe-eval') && !/script-src[^;]*unsafe-inline/.test(p), 'no unsafe-eval, no unsafe-inline scripts')
+ ok(p.includes("object-src 'none'") && p.includes("base-uri 'none'") && p.includes("form-action 'none'"), "object-src, base-uri and form-action are 'none'")
+}
+
+console.log(`\n${checks - failures}/${checks} checks passed`)
+process.exit(failures ? 1 : 0)
diff --git a/scripts/test-release-channel.mjs b/scripts/test-release-channel.mjs
index f69291e0..3b1483ec 100644
--- a/scripts/test-release-channel.mjs
+++ b/scripts/test-release-channel.mjs
@@ -166,7 +166,7 @@ ok(payload.pins?.v === 1 && /^sha256-/.test(payload.pins.scriptSrc?.[0] ?? '') &
'the manifest carries the release pins: the CSP script hashes and the code-block hashes')
{
const { checkAgainstPins } = await import('./lib/release-pins.mjs')
- ok(checkAgainstPins(readFileSync(stagedShell, 'utf8'), payload.pins).length === 0,
+ ok((await checkAgainstPins(readFileSync(stagedShell, 'utf8'), payload.pins)).length === 0,
"the staged shell's code blocks and loader match the signed pins")
const historyPath = join(site, `releases/${app.dir}/history.json`)
ok(existsSync(historyPath), `the release signed a history at releases/${app.dir}/history.json`)
diff --git a/scripts/test-release-history.ts b/scripts/test-release-history.ts
index c91bf13e..fe1d4d16 100644
--- a/scripts/test-release-history.ts
+++ b/scripts/test-release-history.ts
@@ -68,21 +68,21 @@ ok(!acceptHistory(null, h3, 'bento-other').ok, "another app's history is refused
ok(!acceptHistory(null, { ...h3, releases: [h3.releases[1], h3.releases[0]] }, 'bento-test').ok, 'a history not newest-first is refused')
console.log('\na file matches ONE release on EVERY block, or is UNKNOWN (matchRelease)')
-ok(matchRelease(h3, r1.saved)?.version === '1.0.0', 'a 1.0.0 file matches 1.0.0')
-ok(matchRelease(h3, r2.saved)?.version === '1.1.0', '1.0.0 and 1.1.0 share a runtime; the loader tells them apart')
-ok(matchRelease(h3, html({ loader: 'loadX()' })) === null, 'a known runtime with an unknown loader is UNKNOWN (a partial match)')
-ok(matchRelease(h3, html({ remover: 'rmX()' })) === null, 'an unknown remover is UNKNOWN')
-ok(matchRelease(h3, html({ css: 'CSSX' })) === null, 'an unknown stylesheet block is UNKNOWN')
-ok(matchRelease(h3, html({ extra: `<${S}>evil()</${S}>` })) === null, 'an extra executable script is UNKNOWN')
-ok(matchRelease(h3, html({ extra: `<${S} type="bento/deflate-b86" id="bento-rt">RT1</${S}>` })) === null, 'two bento-rt blocks are UNKNOWN (exactly one per id)')
-ok(matchRelease(h3, html({ rt: 'RTX' })) === null, 'an unknown runtime is UNKNOWN')
+ok((await matchRelease(h3, r1.saved))?.version === '1.0.0', 'a 1.0.0 file matches 1.0.0')
+ok((await matchRelease(h3, r2.saved))?.version === '1.1.0', '1.0.0 and 1.1.0 share a runtime; the loader tells them apart')
+ok((await matchRelease(h3, html({ loader: 'loadX()' }))) === null, 'a known runtime with an unknown loader is UNKNOWN (a partial match)')
+ok((await matchRelease(h3, html({ remover: 'rmX()' }))) === null, 'an unknown remover is UNKNOWN')
+ok((await matchRelease(h3, html({ css: 'CSSX' }))) === null, 'an unknown stylesheet block is UNKNOWN')
+ok((await matchRelease(h3, html({ extra: `<${S}>evil()</${S}>` }))) === null, 'an extra executable script is UNKNOWN')
+ok((await matchRelease(h3, html({ extra: `<${S} type="bento/deflate-b86" id="bento-rt">RT1</${S}>` }))) === null, 'two bento-rt blocks are UNKNOWN (exactly one per id)')
+ok((await matchRelease(h3, html({ rt: 'RTX' }))) === null, 'an unknown runtime is UNKNOWN')
const twin = { ...h3, releases: [{ ...r1.entry, version: '1.3.0' }, ...h3.releases] }
-ok(matchRelease(twin, r1.saved) === null, 'two entries with identical blocks are ambiguous: UNKNOWN')
+ok((await matchRelease(twin, r1.saved)) === null, 'two entries with identical blocks are ambiguous: UNKNOWN')
console.log('\nthe grammar (security, 2026-10-21): only Bento data types are inert; foreign markup is UNKNOWN')
{
const genuine = r1.saved
- ok(matchRelease(h3, genuine)?.version === '1.0.0', 'control: the genuine file matches')
+ ok((await matchRelease(h3, genuine))?.version === '1.0.0', 'control: the genuine file matches')
const head = (extra: string) => genuine.replace('</head>', extra + '</head>')
const body = (extra: string) => genuine.replace('</body>', extra + '</body>')
const rows: Array<[string, string]> = [
@@ -110,10 +110,10 @@ console.log('\nthe grammar (security, 2026-10-21): only Bento data types are ine
['the document block holding a raw "<"', genuine.replace('id="bento-doc">{}<', 'id="bento-doc">{"x":"<b>"}<')],
['"<!--<script" inside the document block', genuine.replace('id="bento-doc">{}<', `id="bento-doc">{"x":"<!--<${S}>"}<`)],
]
- for (const [name, html] of rows) ok(matchRelease(h3, html) === null, `UNKNOWN: ${name}`)
- ok(matchRelease(h3, genuine.replace(/type="bento\/deflate-b86"/g, "type='bento/deflate-b86'"))?.version === '1.0.0', 'single-quoted attributes parse the same (still matches)')
- ok(matchRelease(h3, genuine.replace(/type="bento\/deflate-b86"/g, 'type=bento/deflate-b86'))?.version === '1.0.0', 'unquoted attributes parse the same (still matches)')
- ok(matchRelease(h3, genuine.replace(`id="bento-rt">RT1</${S}>`, `id="bento-rt">RT1</${S} >`))?.version === '1.0.0', '"</script >" closes a block like "</script>"')
+ for (const [name, html] of rows) ok((await matchRelease(h3, html)) === null, `UNKNOWN: ${name}`)
+ ok((await matchRelease(h3, genuine.replace(/type="bento\/deflate-b86"/g, "type='bento/deflate-b86'")))?.version === '1.0.0', 'single-quoted attributes parse the same (still matches)')
+ ok((await matchRelease(h3, genuine.replace(/type="bento\/deflate-b86"/g, 'type=bento/deflate-b86')))?.version === '1.0.0', 'unquoted attributes parse the same (still matches)')
+ ok((await matchRelease(h3, genuine.replace(`id="bento-rt">RT1</${S}>`, `id="bento-rt">RT1</${S} >`)))?.version === '1.0.0', '"</script >" closes a block like "</script>"')
}
console.log('\nsign-history.mjs, end to end with a TEST key')