mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-30 20:04:15 +01:00
First-use check catches cut-off and overlapping text on crowded web screens (GST-4152) (#4893)
A web build's first-use check now measures its most crowded screens (most players, longest names, widest numbers) in a real browser and refuses to send the try-it message while text there is cut off or painted over other text. Why: a party game passed a friendly three-player check, then shipped names cut short and a badge on top of the score once eight people joined. Reader action: a web play spec now needs a `full_house` fixture, or `"none: "`. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/red-team#2 reader=red-team Review-Finding: p2/outside-voice#1 reader=outside-voice Review-Finding: p2/outside-voice#2 reader=outside-voice Review-Finding: p2/outside-voice#3 reader=outside-voice Review-Finding: p2/outside-voice#5 reader=outside-voice Review-Finding: p2/adversarial-native#1 reader=adversarial-native Review-Finding: p2/adversarial-native#2 reader=adversarial-native Review-Finding: p2/adversarial-native#4 reader=adversarial-native
This commit is contained in:
1 parent
0b7af8acfd
commit
b2e9522b2f
17 files changed
+603
-36
No files matched your search
@@ -3,12 +3,13 @@
|
||||
// and /design-review. Static tier over .html .css .jsx .tsx .vue .svelte .astro
|
||||
// (Tailwind class strings included); --render measures the page in gstack's own
|
||||
// browser (Aside first, the browse daemon otherwise). --scope app is the
|
||||
// render-only app profile: five spacing rules inside one --within section.
|
||||
// render-only app profile: five spacing rules inside one --within section;
|
||||
// --full-house adds text-clipped and text-overlap for screens filled to their limits.
|
||||
//
|
||||
// Usage: gstack-design-lint <file-or-dir ...> [--render] [--url <http://…>]
|
||||
// [--scope page|component] [--job <job>] [--json] [--rules]
|
||||
// gstack-design-lint --scope app (--url <http://…> ... | --state-file <states.json>) --within <selector>
|
||||
// [--viewport WxH ...] [--wait-for <selector>] [--waivers <file>] [--json] [--verbose]
|
||||
// [--viewport WxH ...] [--wait-for <selector>] [--waivers <file>] [--full-house] [--json] [--verbose]
|
||||
//
|
||||
// Prints one "LINT: <blocks|ask|polish|waived> <rule-id> <file>:<line> <evidence> | fix: <fix>"
|
||||
// line per finding, then "LINT_SUMMARY: blocks=N ask=N waived=N polish=N render=<ran|skipped: reason>".
|
||||
@@ -21,7 +22,7 @@ import { appMain, renderUnavailable, type AppCliArgs } from '../lib/design-lint/
|
||||
import { ruleTable } from '../lib/design-lint/report';
|
||||
|
||||
const USAGE = 'usage: gstack-design-lint <file-or-dir ...> [--render] [--url <http://…>] [--scope page|component] [--job <job>] [--json] [--rules]\n'
|
||||
+ ' gstack-design-lint --scope app (--url <http://…> ... | --state-file <states.json>) --within <selector> [--viewport WxH ...] [--wait-for <selector>] [--waivers <file>] [--json] [--verbose]';
|
||||
+ ' gstack-design-lint --scope app (--url <http://…> ... | --state-file <states.json>) --within <selector> [--viewport WxH ...] [--wait-for <selector>] [--waivers <file>] [--full-house] [--json] [--verbose]';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const opts: LintOptions & { json: boolean; rules: boolean } = { render: false, urls: [], scope: 'page', job: null, json: false, rules: false };
|
||||
@@ -49,6 +50,7 @@ for (; i < args.length; i++) {
|
||||
else if (a === '--wait-for') { appFlags.push(a); app.waitFor = take(a); }
|
||||
else if (a === '--waivers') { appFlags.push(a); app.waivers = take(a); }
|
||||
else if (a === '--state-file') { appFlags.push(a); app.stateFile = take(a); }
|
||||
else if (a === '--full-house') { appFlags.push(a); app.fullHouse = true; }
|
||||
else if (a === '--help' || a === '-h') { console.log(USAGE); process.exit(0); }
|
||||
else if (a.startsWith('--')) { console.error(`unknown flag ${a}`); console.error(USAGE); process.exit(3); }
|
||||
else paths.push(a);
|
||||
|
||||
+20
-2
@@ -10,6 +10,7 @@
|
||||
* --account <text> --target <text> --by <model> [--needs-lookup <text>] [--notice <text>] [--json]
|
||||
* gstack-first-use predict --run <dir> --score <1-10> --why <text> --by <model> [--json]
|
||||
* gstack-first-use links --run <dir> --account <owner-equivalent account> --device-class ios|android|web [--json]
|
||||
* gstack-first-use layout --run <dir> [--json]
|
||||
* gstack-first-use check --run <dir> --platform … --commit … (--testflight … | --deploy …) [--json]
|
||||
* gstack-first-use message --run <dir> --platform … --commit … (--testflight … | --deploy …)
|
||||
* gstack-first-use score --run <dir> --score <1-10> --words "<owner's exact words>" --by <who relayed them> [--json]
|
||||
@@ -29,7 +30,9 @@ import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
|
||||
import { buildLabel, checkLinks, decide, ownerScore, predict, readManifest, recordResult, recordRoot, startRun, type BuildId, type FirstUseError } from '../lib/first-use';
|
||||
import { runLayout } from '../lib/first-use-layout';
|
||||
import { renderBrief, renderPlayMessage } from '../lib/first-use-message';
|
||||
import { APP_CODE_FIX, appCodeAnchor, type AppCode } from '../lib/design-lint/render-app';
|
||||
import { resultLine } from '../lib/result-codes';
|
||||
|
||||
const HELP = `gstack-first-use — a cold first-use check: the owner's exact try-it steps, run on the real target before the owner is asked (docs/first-use-check.md)
|
||||
@@ -43,6 +46,8 @@ const HELP = `gstack-first-use — a cold first-use check: the owner's exact try
|
||||
--target <text> --by <model> [--needs-lookup <text>] [--notice <text>]
|
||||
predict --run <dir> --score <1-10> --why <text> --by <model>
|
||||
links --run <dir> --account <text> --device-class ios|android|web|macos|server check every play link now, as the owner-equivalent audience
|
||||
layout --run <dir> measure the play spec's crowded screens (full_house) with no model:
|
||||
exit 0 clean, 1 cut-off or overlapping text, 4 a state was not measured, 3 nothing to measure
|
||||
check --run <dir> --platform … --commit … (--testflight … | --deploy …) FIRST_USE: pass, or refused
|
||||
message --run <dir> --platform … --commit … (--testflight … | --deploy …) the try-it message, only after a pass
|
||||
score --run <dir> --score <1-10> --words "<owner's exact words>" --by <who relayed them>
|
||||
@@ -75,13 +80,14 @@ function cmdStart(a: string[], json: boolean): number {
|
||||
if ('error' in root) return refuse('start', root.error);
|
||||
let play: unknown;
|
||||
try { play = JSON.parse(fs.readFileSync(flag(a, '--play')!, 'utf8')); } catch { return refuse('start', { code: 'FIRST_USE_PLAY_SPEC_INCOMPLETE', detail: `${flag(a, '--play')} is not a readable JSON play spec` }); }
|
||||
const r = startRun({ root: root.root, app: flag(a, '--app')!, planPath: flag(a, '--plan')!, build: buildArgs(a), phoneBuild: flag(a, '--phone-build'), play, holding: { build: flag(a, '--holding'), defects: flag(a, '--holding-defects') }, builder: flag(a, '--builder')!, checker: flag(a, '--checker')! });
|
||||
const r = startRun({ root: root.root, app: flag(a, '--app')!, planPath: flag(a, '--plan')!, build: buildArgs(a), phoneBuild: flag(a, '--phone-build'), play, playDir: path.dirname(path.resolve(flag(a, '--play')!)), holding: { build: flag(a, '--holding'), defects: flag(a, '--holding-defects') }, builder: flag(a, '--builder')!, checker: flag(a, '--checker')! });
|
||||
if ('error' in r) return refuse('start', r.error);
|
||||
const m = r.manifest;
|
||||
if (json) { say(JSON.stringify({ run: r.dir, steps: m.steps.length, actions: m.actions.length, quotes: m.quotes.length, rows_sha256: m.source.rows_sha256, try_sha256: m.try_sha256, target: m.play.target, build: m.build })); return EXIT.ok; }
|
||||
say(`FIRST_USE_RUN: ${r.dir}`);
|
||||
say(`FIRST_USE_FROZEN: ${m.steps.length} steps (${m.actions.length} day-one actions) quotes=${m.quotes.length} rows=${m.source.rows_sha256.slice(0, 12)} try=${m.try_sha256.slice(0, 12)} target=${m.play.target.kind}:${m.play.target.name} build=${buildLabel(m.build)} checker=${m.checker.model}`);
|
||||
m.steps.forEach(x => say(` ${x.n}. ${x.text}${x.writes === 'none' ? '' : ` (writes: ${x.writes})`}`));
|
||||
if (m.full_house) say(`NEXT: gstack-first-use layout --run "${r.dir}" (measures the crowded screens: ${m.full_house.limits})`);
|
||||
say(`NEXT: gstack-first-use brief --run "${r.dir}" (give it to one fresh agent on ${m.checker.model}, never a ${m.builder.family} model)`);
|
||||
return EXIT.ok;
|
||||
}
|
||||
@@ -108,7 +114,7 @@ async function main(argv: string[]): Promise<number> {
|
||||
const json = a.includes('--json');
|
||||
if (cmd === 'root') { const r = recordRoot(); if ('error' in r) return refuse('root', r.error); say(`FIRST_USE_ROOT: ${r.root}`); return EXIT.ok; }
|
||||
if (cmd === 'start') return cmdStart(a, json);
|
||||
if (!['brief', 'record', 'predict', 'links', 'check', 'message', 'score', 'show'].includes(cmd)) { process.stderr.write(`gstack-first-use: unknown command ${cmd}\n${HELP}\n`); return EXIT.usage; }
|
||||
if (!['brief', 'record', 'predict', 'links', 'layout', 'check', 'message', 'score', 'show'].includes(cmd)) { process.stderr.write(`gstack-first-use: unknown command ${cmd}\n${HELP}\n`); return EXIT.usage; }
|
||||
const dir = runDir(cmd, a);
|
||||
if (typeof dir === 'number') return dir;
|
||||
if (cmd === 'show') return cmdShow(dir, json);
|
||||
@@ -139,6 +145,18 @@ async function main(argv: string[]): Promise<number> {
|
||||
say(json ? JSON.stringify({ score: r.owner.score, at: r.owner.at }) : `FIRST_USE_OWNER_SCORE: ${r.owner.score} recorded in the private record`);
|
||||
return EXIT.ok;
|
||||
}
|
||||
if (cmd === 'layout') {
|
||||
const r = await runLayout(dir);
|
||||
if ('error' in r) { const code = refuse(cmd, r.error); return r.nothing ? 3 : code; }
|
||||
const x = r.receipt;
|
||||
if (json) say(JSON.stringify(x));
|
||||
else {
|
||||
say(`FIRST_USE_LAYOUT: ${x.verdict} code=${x.code} open=${x.open} waived=${x.waived} viewports=${x.viewports.join(',')} within=${x.within} receipt=${r.file}`);
|
||||
for (const f of x.findings) say(`LAYOUT_FINDING: ${f.rule} ${f.evidence}${f.waiver ? ` (waived: ${f.waiver})` : ''}`);
|
||||
for (const s of x.incomplete) say(`LAYOUT_INCOMPLETE: state=${s.state} viewport=${s.viewport} code=${s.code} ${s.detail} | fix: ${APP_CODE_FIX[s.code as AppCode] ?? 'rerun'} (${appCodeAnchor(s.code as AppCode)})`);
|
||||
}
|
||||
return x.verdict === 'clean' ? EXIT.ok : x.verdict === 'open' ? EXIT.fail : 4;
|
||||
}
|
||||
if (cmd === 'links') {
|
||||
const r = await checkLinks(dir, { account: flag(a, '--account'), device_class: flag(a, '--device-class') as BuildId['platform'] });
|
||||
if ('error' in r) return refuse(cmd, r.error);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
bump: minor
|
||||
---
|
||||
**The first-use check now measures a web build's most crowded screens for cut-off and overlapping text before the owner is asked to try it.** A friendly playtest with three people never fills a screen with eight players, long names and big negative scores, so names got cut short and a badge sat on top of a score with nobody noticing. Now a web build's play spec either names a fixture that fills its screens to their limits or says why it has none, `gstack-first-use layout` measures those screens in a real browser with no model, and `check` and `message` refuse until that measurement is clean. The same measurement is available on its own as `gstack-design-lint --scope app --full-house`, which adds two rules, `text-clipped` and `text-overlap`. It doesn't yet catch text cut off vertically, `line-clamp`, or native app screens.
|
||||
+16
-5
@@ -314,7 +314,7 @@ threw on a page, ask: the page is not a pass until the lint has read it).
|
||||
|
||||
```
|
||||
gstack-design-lint --scope app (--url <url> ... | --state-file <states.json>) --within <selector>
|
||||
[--viewport WxH ...] [--wait-for <selector>] [--waivers <file>] [--json] [--verbose]
|
||||
[--viewport WxH ...] [--wait-for <selector>] [--waivers <file>] [--full-house] [--json] [--verbose]
|
||||
```
|
||||
|
||||
The page and component profiles grade a whole page against hallmark's gates.
|
||||
@@ -322,8 +322,8 @@ The app profile measures one section of an app screen while it is being
|
||||
built, for the spacing defects qm#3186 shipped (two-line rows crowding the next
|
||||
row, help copy flush under a list, a status note at full weight inside a row)
|
||||
and small hit areas. It is render-only (no static tier, and paths are a usage
|
||||
error), reports only its five rules, and the page and component profiles never
|
||||
report them. Its scheduler (`lib/design-lint/render-app.ts`) and probes
|
||||
error), reports only its five rules (seven with `--full-house`), and the page
|
||||
and component profiles never report them. Its scheduler (`lib/design-lint/render-app.ts`) and probes
|
||||
(`lib/design-lint/render-probe-app.ts`, installed on
|
||||
`window.__gstackLintApp`) are separate from the page tier's, which is
|
||||
unchanged.
|
||||
@@ -352,8 +352,17 @@ unchanged.
|
||||
replaces them. Width 320 to 3840, height 480 to 2400, `^\d{3,4}x\d{3,4}$`;
|
||||
anything else exits 3. One page load per state, one measurement per
|
||||
viewport.
|
||||
- `--within`, `--viewport`, `--wait-for`, `--waivers` and `--state-file`
|
||||
without `--scope app` exit 3 (`APP_ONLY: <flag> only with --scope app`).
|
||||
- **`--full-house`** adds `text-clipped` and `text-overlap`, for a screen
|
||||
filled to its limits: the most players, the longest names, the widest
|
||||
numbers. Point the URLs at a state that seeds those limits (a fixture route
|
||||
such as `?fixture=full-house`), because an empty screen hides both bugs. It
|
||||
needs `--wait-for` naming a selector that matches only once the crowded state
|
||||
has rendered (the last item, say), since a crowded screen may hold no list;
|
||||
without one it exits 3 (`FULL_HOUSE_NEEDS_WAIT`). It measures horizontal
|
||||
cuts only: text cut off vertically, lines hidden by `line-clamp` and a
|
||||
number that wraps onto a second line are not reported.
|
||||
- `--within`, `--viewport`, `--wait-for`, `--waivers`, `--state-file` and
|
||||
`--full-house` without `--scope app` exit 3 (`APP_ONLY: <flag> only with --scope app`).
|
||||
`--verbose` is accepted under every scope; under `--scope app` it prints a
|
||||
failed probe's stack.
|
||||
|
||||
@@ -370,6 +379,8 @@ finding a waiver did not answer makes the section open.
|
||||
| `note-in-row-weight` | ask | in a list of rows, a note with no icon and no surface of its own, OKLCH lightness within 0.15 of the name's and size 0.9 or more of it; or, at 1200px and wider, a note of three lines or more | mute the note, or give it an icon or a callout |
|
||||
| `small-hit-area` | ask | at 480px and narrower, a control inside a list row under 32px in either dimension (an input's label counts toward its box; a link inside a run of text is exempt) | a 32px target that keeps the glyph its size |
|
||||
| `section-overflow` | ask | an element inside the section whose right edge passes the viewport (outside any scroller), or a non-scrolling element whose content is wider than its box | wrap or shrink it, or give it a scroller |
|
||||
| `text-clipped` | ask | `--full-house` only: an element that hides its horizontal overflow (`overflow-x` hidden or clip, ellipsis included) holds text wider than its box by more than 1px; boxes under 4px and visually hidden text (`clip` or `clip-path`, the screen-reader-only pattern) are skipped, and only the innermost of nested clippers reports. The evidence says how much of the text shows | let the text wrap, shrink it to fit, or give the box room for the longest value |
|
||||
| `text-overlap` | ask | `--full-house` only: two text runs from different elements (an absolutely or fixed positioned child counts against its parent's own text), whose line boxes (glyph rows trimmed to the line height and cut to any clipping ancestor) overlap by more than 2px in both directions. The pair is skipped only when an opaque surface on one side, at least four times the other run's area and painted above it (positioned, or on its own layer, and topmost at the overlap), hides that run's whole line (a dialog over the page), sits in a fixed overlay (a toast or callout floating over the page), or is a sticky bar. A badge with its own background over part of a score, and text spilling into the next row's background, still report. Up to 50 findings per rule and screen, so waivers can't hide an unwaived one | put the badge or label in the flow beside the text, or reserve space for it |
|
||||
|
||||
How it reads the page, with no test hooks (no `data-testid`, no attribute at
|
||||
all): a **list** is two or more adjacent siblings of one tag and class list,
|
||||
|
||||
+14
-5
@@ -54,9 +54,13 @@ Run these from the thread that owns the build (on Capy, a Captain or the agent b
|
||||
|
||||
Platforms are `ios`, `android`, `web`, `macos` (a Mac app or helper) and `server` (software on the owner's box); give `--deploy <version>` for anything not on TestFlight. An ios or android check also needs `--phone-build <id>`: the 26-character id of Capy's mobile build (`tools.mobile.build`) of the same commit. The cloud phone installs only that kind of build, never a TestFlight or store number, so `start` refuses a phone build without it. gstack can't check that this build is the same code TestFlight ships. The builder names it, and the brief records which one the checker installed. `--holding none --holding-defects none` marks a first build. `start` freezes the owner's quotes, the play spec's numbered steps followed by the five day-one actions, and the try-it text into a write-once `manifest.json`, with a hash over the rows and the text of every quote, and prints `FIRST_USE_RUN: <dir>`. It refuses a plan whose table or quotes are missing or malformed, a play spec that misses a part, and a checker from the builder's model family.
|
||||
|
||||
2. **Hand the checker its brief.** `gstack-first-use brief --run <dir>` prints everything the checker gets: the target and its rules, the exact try-it message, and each step with what it writes and the commands to record it. Give it to one fresh agent on the `--checker` model and nothing else about the build: no plan, no code, no notes. On Capy, start a subagent with that model on `machine: "fresh"`. For a phone build it attaches a cloud phone (`tools.capy.phone`), installs the `--phone-build` build on it and points it at the target; for a Mac build on the owner's own Mac it drives Aside over Tailscale; for a server build it works over the box's shell. It runs its own gstack install check first.
|
||||
2. **Measure the crowded screens (web builds).** `gstack-first-use layout --run <dir>` opens each state in the play spec's `full_house` state file and runs gstack-design-lint's app profile under `--full-house`, with no model: it reports text that is cut off (`text-clipped`) or painted on top of other text (`text-overlap`) inside `within`, at each viewport (1440x900 and 375x812 unless the play spec names others). It prints `FIRST_USE_LAYOUT: <clean|open|incomplete> …`, one `LAYOUT_FINDING:` per finding and one `LAYOUT_INCOMPLETE:` per state it couldn't measure, with the fix, and writes a write-once receipt under `layout/` bound to the build and to the state and waiver files as `start` froze them. Exit 0 clean, 1 open, 4 incomplete, 3 when the run has no crowded screens to measure. Only those two rules decide the receipt; the app profile's spacing rules are left to the builder's own lint runs. Fix the screen and rerun `layout`; the newest receipt counts.
|
||||
|
||||
3. **The checker records each step and predicts the score.**
|
||||
A checker playing with three friends never sees eight players with long names and a big negative score, so the builder declares the app's limits and seeds them. Give the app a fixture route (for example `?fixture=full-house`) that fills the screen to those limits: the most players, the longest names, a mix of wide and narrow numbers (one widest number alone can wrap and hide an overlap), and every badge that can show at once. The state file is the app profile's (`{"version":1,"states":[{"name":"eight players","url":"http://127.0.0.1:3000/?fixture=full-house"}]}`, [design-lint](design-lint.md#app-profile---scope-app)), and `wait_for` is a selector that matches only once the last item has rendered.
|
||||
|
||||
3. **Hand the checker its brief.** `gstack-first-use brief --run <dir>` prints everything the checker gets: the target and its rules, the exact try-it message, and each step with what it writes and the commands to record it. Give it to one fresh agent on the `--checker` model and nothing else about the build: no plan, no code, no notes. On Capy, start a subagent with that model on `machine: "fresh"`. For a phone build it attaches a cloud phone (`tools.capy.phone`), installs the `--phone-build` build on it and points it at the target; for a Mac build on the owner's own Mac it drives Aside over Tailscale; for a server build it works over the box's shell. It runs its own gstack install check first.
|
||||
|
||||
4. **The checker records each step and predicts the score.**
|
||||
|
||||
```bash
|
||||
gstack-first-use record --run <dir> --step 3 --verdict useful --line "three plants show with their names" \
|
||||
@@ -67,11 +71,11 @@ Run these from the thread that owns the build (on Capy, a Captain or the agent b
|
||||
|
||||
A verdict is `useful` (does what he asked, well), `thin` (works but does little), `wrong` (does something other than what he asked) or `broken` (fails). `--needs-lookup <what>` marks a step that asks the owner for something an agent could look up or do; `--notice <text>` marks a system notice or prompt the message doesn't warn about. Evidence is a screenshot, short video or terminal capture (PNG, JPEG, GIF, WebP, HEIC, MP4, MOV, WebM, TXT or LOG, up to 100 MB), copied into the run with its hash. Only the checker's family may record, and `--account` and `--target` must match the play spec exactly. The checker's text is kept to one plain line. Replaying a step adds a new result; the newest one counts.
|
||||
|
||||
4. **Check the links right before sending.** `gstack-first-use links --run <dir> --account "<the play spec's account>" --device-class ios` opens every link and writes a dated receipt bound to that audience. A link passes on a 2xx or 3xx answer; a 401 or 403 passes only when the play spec marks it `"login_gated": true`.
|
||||
5. **Check the links right before sending.** `gstack-first-use links --run <dir> --account "<the play spec's account>" --device-class ios` opens every link and writes a dated receipt bound to that audience. A link passes on a 2xx or 3xx answer; a 401 or 403 passes only when the play spec marks it `"login_gated": true`.
|
||||
|
||||
5. **Print the message.** `gstack-first-use message --run <dir> --platform ios --commit <sha> --testflight 17` prints the try-it message only when every check below passes, and refuses otherwise, printing nothing on stdout. It opens with the owner's quotes and what this version does with each, then the ten play parts with the numbered steps, then "What you'll notice" (every thin step and notice), "The build on your device now" (its known defects, or that this is his first build) and one verdict line per step. Send it as it is. For a "v1 is ready" report, run `gstack-first-use check` with the same flags and paste its `FIRST_USE: pass …` line.
|
||||
6. **Print the message.** `gstack-first-use message --run <dir> --platform ios --commit <sha> --testflight 17` prints the try-it message only when every check below passes, and refuses otherwise, printing nothing on stdout. It opens with the owner's quotes and what this version does with each, then the ten play parts with the numbered steps, then "What you'll notice" (every thin step and notice), "The build on your device now" (its known defects, or that this is his first build) and one verdict line per step. Send it as it is. For a "v1 is ready" report, run `gstack-first-use check` with the same flags and paste its `FIRST_USE: pass …` line.
|
||||
|
||||
6. **Save the owner's reaction.** When the owner replies, `gstack-first-use score --run <dir> --score 4 --words "4, Talk is slow" --by "<who relayed it>"`. `gstack-first-use show --run <dir>` prints each step's verdict, the predicted score, the owner's score and words, and the gap between them.
|
||||
7. **Save the owner's reaction.** When the owner replies, `gstack-first-use score --run <dir> --score 4 --words "4, Talk is slow" --by "<who relayed it>"`. `gstack-first-use show --run <dir>` prints each step's verdict, the predicted score, the owner's score and words, and the gap between them.
|
||||
|
||||
## What the gate refuses
|
||||
|
||||
@@ -84,6 +88,7 @@ Run these from the thread that owns the build (on Capy, a Captain or the agent b
|
||||
- No day-one action is `thin` (`step_<n>_thin`): each one comes from his words. A thin play step passes and is named in the message.
|
||||
- Every link has a live receipt from the last 15 minutes (`link_unchecked`, `link_down`, `link_stale`).
|
||||
- The checker predicted a score (`no_predicted_score`).
|
||||
- When the play spec names crowded screens, the newest layout receipt for this build and these frozen files exists (`full_house_unchecked`), measured every state at every viewport (`full_house_incomplete`) and found no cut-off or overlapping text a waiver didn't answer (`full_house_open`). The try-it message then says the limits were checked, and lists each waived cut under "What you'll notice".
|
||||
|
||||
The message never shows the predicted score, so it can't anchor the owner's own.
|
||||
|
||||
@@ -104,6 +109,7 @@ Every ask to play or try a build carries full play instructions in the same mess
|
||||
| 8. How to report back | `report` | the message adds "a score from 1 to 10 and one line" |
|
||||
| 9. Known quirks | `quirks` | "none" is fine; empty isn't |
|
||||
| 10. Reply word | `reply_word` | one word |
|
||||
| Crowded screens | `full_house` | required on a `web` build, optional elsewhere. Either `"none: <reason>"` (a single static page, say) or `{ "states", "within", "wait_for", "limits", "viewports"?, "waivers"? }`: `states` and `waivers` are file paths relative to the play spec, in the app profile's formats; `limits` says the limits in words ("8 players, 12-character names, scores to -$99,999"). `start` reads, checks and hashes both files, and refuses a missing or malformed one |
|
||||
|
||||
On the owner's real setup the checker only reads: the brief forbids sending anything as the owner, writing to his setup except an approved write, and raising a prompt on his machine while he is using it. It also tells the checker that what it reads goes to its model provider.
|
||||
|
||||
@@ -122,3 +128,6 @@ With a handful of builds, this is a case series, not an eval. For each first ver
|
||||
- It doesn't prove the target is real: the checker declares it, as it declares the account, and the record names it.
|
||||
- It doesn't dispatch the checker by itself; the thread that owns the build starts it with the brief.
|
||||
- It doesn't check the wording of other messages sent to the owner.
|
||||
- The crowded-screen check measures only horizontal cuts and overlapping text on web pages. It doesn't catch text cut off vertically, a `line-clamp` that hides lines, a number that wraps onto a second line, a screen the fixture doesn't seed, or native iOS, Android and Mac screens.
|
||||
- The crowded-screen measurement trusts the fixture URL: it doesn't check that the server there runs the build being sent (the record lists the origins it opened). It measures only text that paints on screen, so text marked `aria-hidden` still counts when it is visible. It waits for `wait_for` once before measuring each viewport rather than at each one, and compares at most 2000 line boxes per screen.
|
||||
- It doesn't push a build through rough play (idling past a timer, a wrong answer, a dropped player). A pilot of that check caught the bug it was aimed at in 1 of 3 tries, so it was left out.
|
||||
@@ -2379,7 +2379,7 @@ whose Plan line differs from the PR body's current line.
|
||||
<a id="first-use-play-spec-incomplete"></a>
|
||||
### `gstack-first-use start: ... (FIRST_USE_PLAY_SPEC_INCOMPLETE)`
|
||||
|
||||
**Meaning.** The play spec JSON misses one of the ten parts every ask to play or try a build carries (links, device and setup with its `target`, what it is, how to start with its numbered `steps`, controls, how long, what we want to learn, how to report back, known quirks, reply word), or a step writes on the owner's real setup with no `approved_write` naming his approval. The line names each missing part and field. Exit 3. **Fix.** Fill them in ([first-use-check.md](first-use-check.md#play-spec)); "none" is a fine value for known quirks and for a step's writes. Run a step that writes on a realistic copy, or get the owner's lettered approval for that write first.
|
||||
**Meaning.** The play spec JSON misses one of the ten parts every ask to play or try a build carries (links, device and setup with its `target`, what it is, how to start with its numbered `steps`, controls, how long, what we want to learn, how to report back, known quirks, reply word), or a step writes on the owner's real setup with no `approved_write` naming his approval, or a web build's `full_house` is missing, malformed, or names a state or waiver file that can't be read or parsed (paths are relative to the play spec). The line names each missing part and field. Exit 3. **Fix.** Fill them in ([first-use-check.md](first-use-check.md#play-spec)); "none" is a fine value for known quirks and for a step's writes. Run a step that writes on a realistic copy, or get the owner's lettered approval for that write first.
|
||||
|
||||
<a id="first-use-same-family"></a>
|
||||
### `gstack-first-use start|record|predict: ... (FIRST_USE_SAME_FAMILY)`
|
||||
@@ -2399,7 +2399,7 @@ whose Plan line differs from the PR body's current line.
|
||||
<a id="first-use-refused"></a>
|
||||
### `gstack-first-use check|message: ... (FIRST_USE_REFUSED)`
|
||||
|
||||
**Meaning.** The build has not cleared its first-use check, so `message` prints no try-it message and `check` prints no `FIRST_USE: pass` line. The detail lists every reason: `build_mismatch`, `source_changed` (the day-one rows or the owner's quotes changed), `source_missing`, `try_text_changed`, `step_<n>_not_played`, `step_<n>_broken`, `step_<n>_wrong`, `step_<n>_needs_lookup` (the step asks the owner for something an agent could look up or do), `step_<n>_thin` (only for a day-one action, which comes from the owner's words), `step_<n>_evidence_stale`, `link_unchecked`, `link_down`, `link_stale` (over 15 minutes old), `no_predicted_score`, `record_unreadable`. Exit 3. **Fix.** Fix the build or the step and replay it, rerun `links` right before sending, or start a new run for a new build, changed day-one rows or changed quotes.
|
||||
**Meaning.** The build has not cleared its first-use check, so `message` prints no try-it message and `check` prints no `FIRST_USE: pass` line. The detail lists every reason: `build_mismatch`, `source_changed` (the day-one rows or the owner's quotes changed), `source_missing`, `try_text_changed`, `step_<n>_not_played`, `step_<n>_broken`, `step_<n>_wrong`, `step_<n>_needs_lookup` (the step asks the owner for something an agent could look up or do), `step_<n>_thin` (only for a day-one action, which comes from the owner's words), `step_<n>_evidence_stale`, `link_unchecked`, `link_down`, `link_stale` (over 15 minutes old), `no_predicted_score`, `record_unreadable`, and for a play spec with crowded screens `full_house_unchecked` (no layout receipt for this build and these frozen state and waiver files), `full_house_open` (cut-off or overlapping text at the declared limits) and `full_house_incomplete` (a state or viewport wasn't measured; the reason names its app-profile code). Exit 3. **Fix.** Fix the build or the step and replay it, rerun `links` right before sending, run `gstack-first-use layout --run <dir>` after fixing a crowded screen, or start a new run for a new build, changed day-one rows or changed quotes.
|
||||
|
||||
## /gstack-ship token budget and fresh-context handoffs (gstack-ship-budget)
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface AppCliArgs {
|
||||
waitFor?: string;
|
||||
waivers?: string;
|
||||
stateFile?: string;
|
||||
fullHouse?: boolean;
|
||||
verbose: boolean;
|
||||
json: boolean;
|
||||
}
|
||||
@@ -44,6 +45,7 @@ export function planApp(a: AppCliArgs): { states: AppState[]; notes: string[]; w
|
||||
if (!a.within) throw new AppUsageError('NO_WITHIN', '--scope app needs --within <selector>', 'pass --within with the selector of the section you are building');
|
||||
checkSelector('--within', a.within);
|
||||
if (a.waitFor !== undefined) checkSelector('--wait-for', a.waitFor);
|
||||
if (a.fullHouse && a.waitFor === undefined) throw new AppUsageError('FULL_HOUSE_NEEDS_WAIT', '--full-house needs --wait-for <selector>: a crowded screen may hold no list, so readiness is the selector that appears once every item has loaded', 'pass --wait-for with a selector that matches only when the crowded state has rendered');
|
||||
if (a.urls.length && a.stateFile) throw new AppUsageError('BOTH_TARGETS', '--url and --state-file are two ways to name the states; pass one', 'put every URL in the state file, or drop it');
|
||||
if (!a.urls.length && !a.stateFile) throw new AppUsageError('NO_TARGET', '--scope app needs --url <url> or --state-file <states.json>', 'pass the URL of each state to measure');
|
||||
const bad = a.urls.find((u) => !/^https?:\/\/[^/]/.test(u));
|
||||
@@ -67,7 +69,7 @@ export async function appMain(a: AppCliArgs, io: Io, deps: AppDeps = {}): Promis
|
||||
io.err(usageLine(e));
|
||||
return 3;
|
||||
}
|
||||
const r = await lintApp({ states: plan.states, within: plan.within, viewports: plan.viewports, waitFor: a.waitFor, waivers: plan.waivers, ...deps });
|
||||
const r = await lintApp({ states: plan.states, within: plan.within, viewports: plan.viewports, waitFor: a.waitFor, waivers: plan.waivers, fullHouse: a.fullHouse, ...deps });
|
||||
r.app.notes.unshift(...plan.notes);
|
||||
for (const line of r.stderr) io.err(line);
|
||||
if (a.verbose) for (const c of r.app.states) if (c.trace) { try { io.err(`gstack-design-lint: trace ${c.trace}:\n${fs.readFileSync(c.trace, 'utf8')}`); } catch (e) { io.err(`gstack-design-lint: trace ${c.trace} could not be read: ${(e as Error).message}`); } }
|
||||
|
||||
@@ -57,6 +57,8 @@ export interface AppOptions {
|
||||
readyMs?: number;
|
||||
/** How long the engine waits for the section (or --wait-for) to match; 15000 by default. */
|
||||
sectionWaitMs?: number;
|
||||
/** --full-house: the states are crowded to the app's declared limits, so text-clipped and text-overlap run too. */
|
||||
fullHouse?: boolean;
|
||||
}
|
||||
|
||||
export interface AppCoverage { name: string; url: string; viewport: string; status: 'measured' | 'incomplete'; code: AppCode | 'OK'; matched: number; detail?: string; trace?: string }
|
||||
@@ -165,7 +167,7 @@ async function lintState(state: AppState, opts: AppOptions, run: Runner, viewpor
|
||||
}
|
||||
const first = viewports[0];
|
||||
const sized = (expression: string, v: Viewport, maxInline = 400_000): RenderStep => ({ kind: 'eval', expression, width: v.width, height: v.height, deviceScaleFactor: 1, mobile: false, maxInline });
|
||||
const args = (v: Viewport) => JSON.stringify({ within, expect: state.expect ?? null, explicitWait: !!opts.waitFor, readyMs: opts.readyMs ?? READY_MS });
|
||||
const args = (v: Viewport) => JSON.stringify({ within, expect: state.expect ?? null, explicitWait: !!opts.waitFor, readyMs: opts.readyMs ?? READY_MS, fullHouse: !!opts.fullHouse, waitFor: opts.fullHouse ? opts.waitFor ?? null : null });
|
||||
const steps: RenderStep[] = [sized(appInstallScript(), first, 10), sized(appProbeScript('P.setup(P)'), first), ...viewports.map((v) => sized(appProbeScript(`P.measure(P, ${args(v)})`), v))];
|
||||
const sectionWait = opts.sectionWaitMs ?? SECTION_WAIT_MS;
|
||||
const waitFor = { expression: composedWaitExpression(opts.waitFor ?? within, opts.waitFor ? null : sectionWait), timeoutMs: sectionWait + (opts.waitFor ? 0 : 1_000) };
|
||||
|
||||
@@ -34,7 +34,7 @@ export interface AppProbeResult {
|
||||
|
||||
export interface AppSetupReport { lostSheets: string[]; lostFonts: string[] }
|
||||
|
||||
export interface AppMeasureArgs { within: string; expect: string | null; explicitWait: boolean; readyMs: number }
|
||||
export interface AppMeasureArgs { within: string; expect: string | null; explicitWait: boolean; readyMs: number; fullHouse?: boolean; waitFor?: string | null }
|
||||
|
||||
interface Run { node: Text; el: Element; block: Element; rects: DOMRect[]; top: number; bottom: number; left: number; lineTop: number; lineBottom: number }
|
||||
|
||||
@@ -334,6 +334,139 @@ export function glAppOverflow(P: AppProbes, root: Element, vw: number): AppProbe
|
||||
return inner.slice(0, 3).map((h) => ({ rule: 'section-overflow', sentence: h.sentence + ' (over 1px)', locator: locOf(h.el), measured: h.m, threshold: 1 }));
|
||||
}
|
||||
|
||||
/** The visible text inside root, controls included: each text node with its host element and line boxes. */
|
||||
export function glAppText(P: AppProbes, root: Element): Array<{ host: Element; text: string; rects: DOMRect[] }> {
|
||||
const { kids, cparent, shown } = P.H;
|
||||
const out: Array<{ host: Element; text: string; rects: DOMRect[] }> = [];
|
||||
const go = (n: Node): void => {
|
||||
for (const c of kids(n)) {
|
||||
if (c.nodeType === 3) {
|
||||
const text = (c.textContent || '').replace(/\s+/g, ' ').trim();
|
||||
const host = cparent(c);
|
||||
if (!text || !host) continue;
|
||||
const rg = document.createRange(); rg.selectNodeContents(c);
|
||||
const rects = Array.from(rg.getClientRects()).filter((q) => q.width > 0 && q.height > 0);
|
||||
if (rects.length) out.push({ host, text, rects });
|
||||
} else if (c.nodeType === 1) {
|
||||
const e = c as Element;
|
||||
if (/^(SCRIPT|STYLE|TEMPLATE|NOSCRIPT)$/.test(e.tagName) || e.tagName === 'svg' || !shown(e)) continue;
|
||||
go(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
go(root);
|
||||
return out;
|
||||
}
|
||||
|
||||
/** text-clipped (--full-house only): inside root, an element that clips horizontally (overflow-x hidden or clip) and paints part of its own text past its edge; a visually hidden box (under 4px, or a clip or clip-path) is screen-reader text, never a cut. The innermost 50, so waivers applied later can't hide an unwaived cut behind three waived ones. */
|
||||
export function glAppClipped(P: AppProbes, root: Element): AppProbeFinding[] {
|
||||
const { desc, vis, locOf, px, inside } = P.H;
|
||||
const hits: Array<{ el: Element; sentence: string; m: number }> = [];
|
||||
for (const el of desc(root)) {
|
||||
if (!vis(el)) continue;
|
||||
const cs = getComputedStyle(el);
|
||||
if (!/hidden|clip/.test(cs.overflowX) || el.scrollWidth <= el.clientWidth + 1) continue;
|
||||
if (el.clientWidth < 4 || el.clientHeight < 4 || cs.clip !== 'auto' || cs.clipPath !== 'none') continue;
|
||||
const b = el.getBoundingClientRect();
|
||||
const left = b.left + el.clientLeft, right = left + el.clientWidth;
|
||||
let total = 0, hidden = 0;
|
||||
const words: string[] = [];
|
||||
for (const t of P.text(P, el)) {
|
||||
words.push(t.text);
|
||||
for (const q of t.rects) { total += q.width; hidden += Math.min(q.width, Math.max(0, q.right - right) + Math.max(0, left - q.left)); }
|
||||
}
|
||||
if (!total) continue;
|
||||
const cut = Math.max(hidden, cs.textOverflow === 'ellipsis' ? el.scrollWidth - el.clientWidth : 0);
|
||||
if (cut <= 1) continue;
|
||||
const shownPct = Math.max(0, Math.round(100 * (1 - cut / Math.max(total, el.scrollWidth))));
|
||||
hits.push({ el, sentence: el.tagName.toLowerCase() + ' cuts off its text: ' + shownPct + '% of "' + words.join(' ').slice(0, 40) + '" shows, ' + px(cut) + 'px hidden', m: px(cut) });
|
||||
}
|
||||
const inner = hits.filter((h) => !hits.some((o) => o !== h && inside(o.el, h.el)));
|
||||
return inner.slice(0, 50).map((h) => ({ rule: 'text-clipped', sentence: h.sentence + ' (over 1px)', locator: locOf(h.el), measured: h.m, threshold: 1 }));
|
||||
}
|
||||
|
||||
/** text-overlap (--full-house only): inside root, the line boxes (a glyph box trimmed to its line-height) of two elements, neither inside the other, intersecting by over 2px both ways, where no opaque surface between them hides one. Clipped-away text never counts. A positioned child painted over its parent's own text counts. First 50 pairs, so waivers applied later can't hide an unwaived one. */
|
||||
export function glAppOverlap(P: AppProbes, root: Element): AppProbeFinding[] {
|
||||
const { cparent, inside, locOf, px, rgb } = P.H;
|
||||
const clipBox = (el: Element): { l: number; t: number; r: number; b: number } => {
|
||||
let l = -Infinity, t = -Infinity, r = Infinity, b = Infinity;
|
||||
for (let e: Element | null = el; e && e !== document.documentElement; e = cparent(e)) {
|
||||
const cs = getComputedStyle(e);
|
||||
if (cs.overflowX === 'visible' && cs.overflowY === 'visible') continue;
|
||||
const q = e.getBoundingClientRect();
|
||||
const x0 = q.left + e.clientLeft, y0 = q.top + e.clientTop;
|
||||
if (cs.overflowX !== 'visible') { l = Math.max(l, x0); r = Math.min(r, x0 + e.clientWidth); }
|
||||
if (cs.overflowY !== 'visible') { t = Math.max(t, y0); b = Math.min(b, y0 + e.clientHeight); }
|
||||
}
|
||||
return { l, t, r, b };
|
||||
};
|
||||
const boxes: Array<{ host: Element; text: string; l: number; t: number; r: number; b: number }> = [];
|
||||
for (const tb of P.text(P, root)) {
|
||||
const c = clipBox(tb.host);
|
||||
const lh = parseFloat(getComputedStyle(tb.host).lineHeight);
|
||||
for (const q of tb.rects) {
|
||||
const pad = Number.isFinite(lh) && lh < q.height ? (q.height - lh) / 2 : 0;
|
||||
const box = { host: tb.host, text: tb.text, l: Math.max(q.left, c.l), t: Math.max(q.top + pad, c.t), r: Math.min(q.right, c.r), b: Math.min(q.bottom - pad, c.b) };
|
||||
if (box.r - box.l > 1 && box.b - box.t > 1) boxes.push(box);
|
||||
}
|
||||
if (boxes.length > 2000) break;
|
||||
}
|
||||
boxes.sort((a, b) => a.l - b.l);
|
||||
const covers = (top: Element, stop: Element, o: { l: number; t: number; r: number; b: number }, x: number, y: number): boolean => {
|
||||
for (let e: Element | null = top; e && e !== stop; e = cparent(e)) {
|
||||
const cs = getComputedStyle(e);
|
||||
if (rgb(cs.backgroundColor)[3] < 0.9 && cs.backgroundImage === 'none') continue;
|
||||
const q = e.getBoundingClientRect();
|
||||
if (q.left > o.r || q.right < o.l || q.top > o.b || q.bottom < o.t) continue;
|
||||
const overlay = !!fixedFrom(e, stop);
|
||||
if (!overlay && q.width * q.height < 4 * (o.r - o.l) * (o.b - o.t)) continue;
|
||||
const whole = q.left <= o.l + 1 && q.right >= o.r - 1 && q.top <= o.t + 1 && q.bottom >= o.b - 1;
|
||||
if (!whole && !overlay && cs.position !== 'sticky') continue;
|
||||
if (!layered(e, stop)) continue;
|
||||
const hit = document.elementFromPoint(x, y);
|
||||
if (!hit || hit === e || inside(hit, e)) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const fixedFrom = (e: Element, stop: Element): Element | null => {
|
||||
for (let n: Element | null = e; n && n !== stop; n = cparent(n)) if (getComputedStyle(n).position === 'fixed') return n;
|
||||
return null;
|
||||
};
|
||||
const layered = (e: Element, stop: Element): boolean => {
|
||||
for (let n: Element | null = e; n && n !== stop; n = cparent(n)) {
|
||||
const cs = getComputedStyle(n);
|
||||
if (cs.position !== 'static' || cs.transform !== 'none' || cs.filter !== 'none' || cs.isolation === 'isolate' || parseFloat(cs.opacity) < 1) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const positionedBetween = (inner: Element, outer: Element): boolean => {
|
||||
for (let e: Element | null = inner; e && e !== outer; e = cparent(e)) if (/^(absolute|fixed)$/.test(getComputedStyle(e).position)) return true;
|
||||
return false;
|
||||
};
|
||||
const lca = (a: Element, b: Element): Element => { for (let e: Element | null = a; e; e = cparent(e)) if (inside(b, e)) return e; return root; };
|
||||
const out: AppProbeFinding[] = [];
|
||||
const seen = new Set<string>();
|
||||
for (let i = 0; i < boxes.length && out.length < 50; i++) {
|
||||
const a = boxes[i];
|
||||
for (let j = i + 1; j < boxes.length && boxes[j].l < a.r && out.length < 50; j++) {
|
||||
const b = boxes[j];
|
||||
if (a.host === b.host) continue;
|
||||
if (inside(a.host, b.host) && !positionedBetween(a.host, b.host)) continue;
|
||||
if (inside(b.host, a.host) && !positionedBetween(b.host, a.host)) continue;
|
||||
const w = Math.min(a.r, b.r) - Math.max(a.l, b.l), h = Math.min(a.b, b.b) - Math.max(a.t, b.t);
|
||||
if (w <= 2 || h <= 2) continue;
|
||||
const x = Math.max(a.l, b.l) + w / 2, y = Math.max(a.t, b.t) + h / 2;
|
||||
const common = lca(a.host, b.host);
|
||||
if (covers(a.host, common, b, x, y) || covers(b.host, common, a, x, y)) continue;
|
||||
const key = locOf(a.host) + '|' + locOf(b.host);
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
out.push({ rule: 'text-overlap', sentence: '"' + a.text.slice(0, 24) + '" and "' + b.text.slice(0, 24) + '" are painted on top of each other (' + px(w) + 'x' + px(h) + 'px, over 2px)', locator: locOf(a.host), measured: px(Math.min(w, h)), threshold: 2 });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** One state at one viewport: wait for the section and a list (or the caller's --wait-for), check the state's expect selector, then every app rule. */
|
||||
export async function glAppMeasure(P: AppProbes, a: AppMeasureArgs): Promise<AppProbeResult> {
|
||||
const { qAll, inside, roots, desc } = P.H;
|
||||
@@ -342,6 +475,7 @@ export async function glAppMeasure(P: AppProbes, a: AppMeasureArgs): Promise<App
|
||||
let matches: Element[] = [];
|
||||
let lists: AppList[] = [];
|
||||
let expectOk = true;
|
||||
let waitOk = true;
|
||||
let host: Element | undefined;
|
||||
const closed = (scope: Element[]): Element | undefined =>
|
||||
scope.flatMap((s) => desc(s)).find((e) => e.tagName.includes('-') && !e.shadowRoot && !e.children.length && !(e.textContent || '').trim() && e.getBoundingClientRect().height >= 40);
|
||||
@@ -349,8 +483,9 @@ export async function glAppMeasure(P: AppProbes, a: AppMeasureArgs): Promise<App
|
||||
matches = outermost(qAll(a.within));
|
||||
lists = matches.flatMap((m) => P.lists(P, m));
|
||||
expectOk = !a.expect || qAll(a.expect).length > 0;
|
||||
waitOk = !a.waitFor || qAll(a.waitFor).length > 0;
|
||||
host = matches.length && !lists.length ? closed(matches) : undefined;
|
||||
if (host || (matches.length && (lists.length || a.explicitWait) && expectOk) || Date.now() - t0 > a.readyMs) break;
|
||||
if (host || (matches.length && (lists.length || a.explicitWait) && expectOk && waitOk) || Date.now() - t0 > a.readyMs) break;
|
||||
await new Promise((r) => setTimeout(r, 150));
|
||||
}
|
||||
const matched = qAll(a.within).length;
|
||||
@@ -363,15 +498,16 @@ export async function glAppMeasure(P: AppProbes, a: AppMeasureArgs): Promise<App
|
||||
}
|
||||
if (host) return { ...base, status: 'incomplete', code: 'CLOSED_SHADOW', detail: '<' + host.tagName.toLowerCase() + '> inside ' + a.within + ' renders a closed shadow root the lint cannot read' };
|
||||
if (!lists.length && !a.explicitWait) return { ...base, status: 'incomplete', code: 'NOT_READY', detail: 'no list of two or more rows appeared inside ' + a.within + ' within ' + Math.round(a.readyMs / 1000) + 's' };
|
||||
if (!waitOk) return { ...base, status: 'incomplete', code: 'NOT_READY', detail: 'the --wait-for selector ' + a.waitFor + ' stopped matching at this viewport' };
|
||||
if (!expectOk) return { ...base, status: 'incomplete', code: 'STATE_MISMATCH', detail: 'the state\'s expect selector ' + a.expect + ' matched nothing after readiness' };
|
||||
const vw = innerWidth;
|
||||
const findings: AppProbeFinding[] = [];
|
||||
for (const l of lists) findings.push(...P.rows(P, l, vw), ...P.after(P, l, matches.find((m) => inside(l.container, m)) || l.container));
|
||||
for (const m of matches) findings.push(...P.overflow(P, m, vw));
|
||||
for (const m of matches) findings.push(...P.overflow(P, m, vw), ...(a.fullHouse ? [...P.clipped(P, m), ...P.overlap(P, m)] : []));
|
||||
return { ...base, status: 'measured', findings };
|
||||
}
|
||||
|
||||
const APP_FNS = { setup: glAppSetup, lists: glAppLists, rows: glAppRows, after: glAppAfter, overflow: glAppOverflow, measure: glAppMeasure };
|
||||
const APP_FNS = { setup: glAppSetup, lists: glAppLists, rows: glAppRows, after: glAppAfter, overflow: glAppOverflow, text: glAppText, clipped: glAppClipped, overlap: glAppOverlap, measure: glAppMeasure };
|
||||
|
||||
export interface AppProbes extends AppFns { H: AppHelpers }
|
||||
type AppFns = typeof APP_FNS;
|
||||
|
||||
@@ -178,6 +178,8 @@ export const RULES: Record<string, RuleMeta> = {
|
||||
'note-in-row-weight': { tier: 'ask', gate: 'app', title: 'a note inside a row at the name\'s weight (no icon, no surface of its own, lightness within 0.15 and size 0.9 or more of the name\'s), or a note of three lines or more at 1200px and wider', fix: 'mute the note (a lighter ink and a smaller size than the name), or give it an icon or a callout of its own', render: true, app: true },
|
||||
'small-hit-area': { tier: 'ask', gate: 'app', title: 'a control inside a list row under 32px in either dimension at a phone width (480px or less)', fix: 'make the target 32px or more (padding with a negative margin, or an inset ::before) and keep the visible glyph its size', render: true, app: true },
|
||||
'section-overflow': { tier: 'ask', gate: 'app', title: 'an element inside the measured section runs past the viewport, or a non-scrolling element overflows its own box', fix: 'let it wrap or shrink (min-width: 0, overflow-wrap: anywhere), or give it a scrolling container', render: true, app: true },
|
||||
'text-clipped': { tier: 'ask', gate: 'app', title: 'with --full-house, an element that clips sideways (overflow-x hidden or clip) paints part of its own text past its edge, as an ellipsis or a cut', fix: 'let the text wrap or shrink to fit the crowded state, give it a shorter form on purpose, or waive an intended truncation', render: true, app: true },
|
||||
'text-overlap': { tier: 'ask', gate: 'app', title: 'with --full-house, the painted text of two elements, neither inside the other, overlaps by over 2px both ways with no opaque surface hiding one', fix: 'put the badge or label in the layout flow, or give each item room at the declared limit', render: true, app: true },
|
||||
// ── The lint's own bookkeeping ──
|
||||
'waiver': { tier: 'ask', gate: 'waiver', title: 'a waiver the lint refused', fix: 'fix the finding, or waive it with the rule id and a reason about this page' },
|
||||
'house-style': { tier: 'polish', gate: 'waiver', title: 'more than three rules waived on one page', fix: 'lock the choices into DESIGN.md so later pages inherit them instead of re-arguing them' },
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* first-use-layout — `gstack-first-use layout`: measures the play spec's crowded screens (its full_house state file, frozen
|
||||
* at start) with gstack-design-lint's app profile under --full-house, so text-clipped and text-overlap run with no model,
|
||||
* and writes one write-once receipt bound to the build and the frozen files (docs/first-use-check.md). Only those two
|
||||
* rules decide the receipt's verdict; the app profile's spacing rules stay advice for the builder's own lint runs. decide() in
|
||||
* first-use.ts only reads the receipts; this module is the only part of the first-use check that starts a browser.
|
||||
*/
|
||||
import * as crypto from 'node:crypto';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { parseViewport } from './design-lint/app-input';
|
||||
import { lintApp, type AppOptions } from './design-lint/render-app';
|
||||
import { readManifest, type FirstUseError, type LayoutReceipt } from './first-use';
|
||||
|
||||
const VERSION_FILE = path.resolve(import.meta.dir, '..', 'VERSION');
|
||||
export const FULL_HOUSE_RULES = ['text-clipped', 'text-overlap'];
|
||||
|
||||
export async function runLayout(dir: string, deps: Pick<AppOptions, 'engine' | 'run' | 'reach'> = {}, now: () => Date = () => new Date()): Promise<{ receipt: LayoutReceipt; file: string } | { error: FirstUseError; nothing?: true }> {
|
||||
const read = readManifest(dir);
|
||||
if ('error' in read) return read;
|
||||
const m = read.manifest, fh = m.full_house;
|
||||
if (!fh) return { nothing: true, error: { code: 'FIRST_USE_RECORD_INVALID', detail: `this run's play spec has no crowded screens to measure (full_house: ${typeof m.play.full_house === 'string' ? m.play.full_house : 'none'})` } };
|
||||
const viewports = fh.viewports?.map(parseViewport);
|
||||
const r = await lintApp({ states: fh.states_parsed, within: fh.within, waitFor: fh.wait_for, viewports, waivers: fh.waivers_parsed, fullHouse: true, ...deps });
|
||||
let version = 'unknown';
|
||||
try { version = fs.readFileSync(VERSION_FILE, 'utf8').trim(); } catch { /* not a checkout */ }
|
||||
const ours = r.findings.filter(f => f.app && FULL_HOUSE_RULES.includes(f.rule));
|
||||
const open = ours.filter(f => !f.waiver).length;
|
||||
const verdict = r.app.verdict === 'incomplete' ? 'incomplete' : open ? 'open' : 'clean';
|
||||
const at = now();
|
||||
const receipt: LayoutReceipt = {
|
||||
schema_version: 1, kind: 'first-use-layout', at: at.toISOString(), build_fingerprint: m.build.fingerprint, states_sha256: fh.states_sha256, waivers_sha256: fh.waivers_sha256,
|
||||
viewports: r.app.viewports, within: fh.within, origins: [...new Set(fh.states_parsed.map(s => { try { return new URL(s.url).origin; } catch { return s.url; } }))], gstack_version: version,
|
||||
verdict, code: verdict === 'incomplete' ? r.app.code : open ? 'OPEN' : 'OK', open, waived: ours.length - open,
|
||||
findings: ours.map(f => ({ rule: f.rule, evidence: f.evidence, ...(f.app ? { locator: f.app.locator } : {}), ...(f.waiver ? { waiver: f.waiver } : {}) })),
|
||||
incomplete: r.app.states.filter(s => s.status === 'incomplete').map(s => ({ state: s.name, viewport: s.viewport, code: s.code, detail: s.detail ?? '' })),
|
||||
};
|
||||
const file = path.join(dir, 'layout', `${at.toISOString().replace(/[-:]/g, '')}-${crypto.randomBytes(3).toString('hex')}.json`);
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
fs.writeFileSync(file, JSON.stringify(receipt, null, 2) + '\n', { flag: 'wx' });
|
||||
} catch (e) { return { error: { code: 'FIRST_USE_RECORD_INVALID', detail: `cannot write ${file}: ${(e as Error).message}` } }; }
|
||||
return { receipt, file };
|
||||
}
|
||||
@@ -17,9 +17,15 @@ export interface PlayStep { text: string; writes: string; approved_write?: strin
|
||||
export type ActionWrites = Omit<PlayStep, 'text'>;
|
||||
/** Where the steps run: the owner's real setup, or a copy loaded with realistic data (the default), named exactly. */
|
||||
export interface PlayTarget { kind: 'real' | 'realistic-copy'; name: string; data?: string }
|
||||
/**
|
||||
* The crowded screens gstack measures with no model (`gstack-first-use layout`): a design-lint state file whose URLs render
|
||||
* each screen at the app's declared limits, the section to measure, the selector that appears once it has rendered, the
|
||||
* limits in one line, and optional viewports and waivers (paths relative to the play spec). `"none: <reason>"` opts out.
|
||||
*/
|
||||
export interface FullHouse { states: string; within: string; wait_for: string; limits: string; viewports?: string[]; waivers?: string }
|
||||
export interface PlaySpec {
|
||||
links: PlayLink[]; device: string; setup: string; account: string; target: PlayTarget; what: string; start: string; steps: PlayStep[]; action_writes?: ActionWrites[];
|
||||
controls: string; minutes: number; learn: string; report: string; quirks: string; reply_word: string;
|
||||
controls: string; minutes: number; learn: string; report: string; quirks: string; reply_word: string; full_house?: FullHouse | string;
|
||||
}
|
||||
/** R47's ten parts in order, with the play-spec fields each one reads. */
|
||||
export const PLAY_PARTS: Array<{ part: string; fields: Array<keyof PlaySpec> }> = [
|
||||
@@ -42,7 +48,22 @@ const str = (v: unknown) => (typeof v === 'string' ? v.trim() : '');
|
||||
* empty field is not. A step that writes on the owner's real setup needs `approved_write` naming his approval, and on that
|
||||
* setup `action_writes` says what each of the five day-one actions writes, under the same rule.
|
||||
*/
|
||||
export function checkPlaySpec(raw: unknown): { spec: PlaySpec } | { error: FirstUseError } {
|
||||
/**
|
||||
* The play spec's `full_house`: required on a web build (a state file of crowded screens, or `"none: <reason>"`), and
|
||||
* optional on other platforms, since the layout check reads a DOM; left out, the spec carries none.
|
||||
*/
|
||||
function checkFullHouse(v: unknown, platform: string | undefined): { value: FullHouse | string } | { bad: string } {
|
||||
if (v === undefined) return platform === 'web' ? { bad: 'a web build names its crowded screens (states, within, wait_for, limits) or says "none: <reason>"' } : { value: 'none: not given' };
|
||||
if (typeof v === 'string') return /^none:\s*\S/i.test(v.trim()) ? { value: v.trim() } : { bad: 'a string full_house must read "none: <reason>"' };
|
||||
const o = (v && typeof v === 'object' ? v : {}) as Record<string, unknown>;
|
||||
const missing = (['states', 'within', 'wait_for', 'limits'] as const).filter(k => !str(o[k]));
|
||||
if (missing.length) return { bad: `needs ${missing.join(', ')}` };
|
||||
if (o.viewports !== undefined && !(Array.isArray(o.viewports) && o.viewports.length && o.viewports.every(x => typeof x === 'string' && /^\d{3,4}x\d{3,4}$/.test(x)))) return { bad: 'viewports must be a list like ["1920x1080"]' };
|
||||
if (o.waivers !== undefined && !str(o.waivers)) return { bad: 'waivers must be a path' };
|
||||
return { value: { states: str(o.states), within: str(o.within), wait_for: str(o.wait_for), limits: str(o.limits), ...(o.viewports ? { viewports: o.viewports as string[] } : {}), ...(str(o.waivers) ? { waivers: str(o.waivers) } : {}) } };
|
||||
}
|
||||
|
||||
export function checkPlaySpec(raw: unknown, platform?: string): { spec: PlaySpec } | { error: FirstUseError } {
|
||||
const o = (raw && typeof raw === 'object' ? raw : {}) as Record<string, unknown>;
|
||||
const bad = new Set<keyof PlaySpec>();
|
||||
for (const f of TEXT_FIELDS) if (!str(o[f])) bad.add(f);
|
||||
@@ -59,8 +80,10 @@ export function checkPlaySpec(raw: unknown): { spec: PlaySpec } | { error: First
|
||||
if (!steps.length || !steps.every(s => !!str(s?.text) && !!str(s?.writes))) bad.add('steps');
|
||||
const acts = o.action_writes === undefined ? undefined : Array.isArray(o.action_writes) ? o.action_writes as Array<Record<string, unknown>> : [];
|
||||
if (acts ? acts.length !== 5 || !acts.every(a => !!str(a?.writes)) : kind === 'real') bad.add('action_writes');
|
||||
if (bad.size) {
|
||||
const fullHouse = checkFullHouse(o.full_house, platform);
|
||||
if (bad.size || 'bad' in fullHouse) {
|
||||
const parts = PLAY_PARTS.filter(p => p.fields.some(f => bad.has(f))).map(p => `${p.part} (${p.fields.filter(f => bad.has(f)).join(', ')})`);
|
||||
if ('bad' in fullHouse) parts.push(`Full-house layout (full_house: ${fullHouse.bad})`);
|
||||
return { error: { code: 'FIRST_USE_PLAY_SPEC_INCOMPLETE', detail: `missing or invalid: ${parts.join('; ')}` } };
|
||||
}
|
||||
const writesUnapproved = (s: Record<string, unknown>) => !/^none$/i.test(str(s.writes)) && !str(s.approved_write);
|
||||
@@ -73,6 +96,7 @@ export function checkPlaySpec(raw: unknown): { spec: PlaySpec } | { error: First
|
||||
target: { kind: kind as PlayTarget['kind'], name: str(t.name), ...(str(t.data) ? { data: str(t.data) } : {}) },
|
||||
steps: steps.map(s => ({ text: str(s.text), ...writesOf(s) })),
|
||||
...(acts ? { action_writes: acts.map(writesOf) } : {}),
|
||||
...(o.full_house !== undefined ? { full_house: fullHouse.value } : {}),
|
||||
...Object.fromEntries(TEXT_FIELDS.map(f => [f, str(o[f])])) as Omit<PlaySpec, 'links' | 'minutes' | 'target' | 'steps' | 'action_writes'>,
|
||||
};
|
||||
return { spec };
|
||||
@@ -111,7 +135,9 @@ export function renderPlayMessage(d: Decision, now: Date = new Date()): string {
|
||||
const oldest = Math.min(...d.links.map(l => Date.parse(l.checked_at)));
|
||||
const ago = Math.max(0, Math.round((now.getTime() - oldest) / 60_000));
|
||||
const notice = [...d.verdicts.filter(v => v.verdict === 'thin').map(v => `- Step ${v.n} is thin: ${v.line}`),
|
||||
...d.verdicts.filter(v => v.notice).map(v => `- At step ${v.n} you'll see: ${v.notice}`)];
|
||||
...d.verdicts.filter(v => v.notice).map(v => `- At step ${v.n} you'll see: ${v.notice}`),
|
||||
...(d.layout?.findings ?? []).filter(x => x.waiver).map(x => `- On a crowded screen, ${x.rule === 'text-overlap' ? 'overlapping on purpose' : 'cut short on purpose'}: ${x.locator && x.evidence.endsWith(` at ${x.locator}`) ? x.evidence.slice(0, -` at ${x.locator}`.length) : x.evidence} (the builder's reason: ${x.waiver})`)];
|
||||
const limits = d.layout && m.full_house ? [`**Checked at the limits:** the builder declared them as ${m.full_house.limits}; gstack measured those screens at ${d.layout.viewports.join(' and ')} and found no cut-off or overlapping text${d.layout.waived ? ` beyond the ${d.layout.waived} left on purpose above` : ''}.`, ''] : [];
|
||||
const held = /^none$/i.test(m.holding.build) ? 'none yet: this is your first build of it.'
|
||||
: `${m.holding.build}. Known defects in it: ${m.holding.defects}.`;
|
||||
return [
|
||||
@@ -119,6 +145,7 @@ export function renderPlayMessage(d: Decision, now: Date = new Date()): string {
|
||||
`Every link was checked live at ${new Date(oldest).toISOString().slice(11, 16)} UTC, ${ago} min before this message.`, '',
|
||||
`**What you'll notice:**`, ...(notice.length ? notice : ['- nothing beyond the known quirks above']), '',
|
||||
`**The build on your device now:** ${held}`, '',
|
||||
...limits,
|
||||
`**Checked before it reached you:** an agent from another model family (${m.checker.model}) followed these exact steps on ${targetLabel(m.play.target)}, on a ${platformName[m.build.platform]} ${m.build.platform === 'ios' || m.build.platform === 'android' ? 'device' : 'setup'} like yours. One line per step:`,
|
||||
...d.verdicts.map(v => `- ${v.n} (${v.verdict}): ${v.line}`),
|
||||
'',
|
||||
@@ -153,6 +180,10 @@ export function renderBrief(m: Manifest, dir: string): string {
|
||||
"- Never send anything as the owner (no messages, mail or posts), and never write to the owner's real setup: a step that writes runs on the copy, except one whose approved_write below names his approval.",
|
||||
"- Never raise a prompt, a permission dialog or a sign-in on the owner's own machine while he is at it.",
|
||||
`- What you read is sent to your model provider (${m.checker.family}); stay inside the steps.`, '',
|
||||
...(m.full_house ? ['## The crowded screens', '',
|
||||
`The builder declared the app's limits as ${m.full_house.limits}. gstack measures those screens itself for cut-off and overlapping text, so you don't.${m.full_house.waivers_parsed.length ? ' Text the builder leaves cut short or overlapping on purpose (waived):' : ''}`,
|
||||
...m.full_house.waivers_parsed.map(w => `- ${w.rule} at "${w.locator}": ${w.reason}`),
|
||||
...(m.full_house.waivers_parsed.length ? ['', 'If one of these leaves the owner unable to tell what is going on when you meet it, say so in that step\'s verdict.'] : []), ''] : []),
|
||||
'## The exact message the owner will get', '',
|
||||
'~~~markdown', m.try_text.trimEnd(), '~~~', '',
|
||||
`## The ${m.steps.length} steps you check (frozen ${m.created_at.slice(0, 10)})`, '',
|
||||
|
||||
+50
-7
@@ -22,7 +22,9 @@ import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { lineText, parseDayOne, parseOwnerWords, quoteGaps, quoteWhen } from './autoplan-owner-text';
|
||||
import { resolveStateRoot } from './state-root';
|
||||
import { checkPlaySpec, renderTryText, type PlaySpec } from './first-use-message';
|
||||
import { checkPlaySpec, renderTryText, type FullHouse, type PlaySpec } from './first-use-message';
|
||||
import { AppUsageError, parseStateFile, parseViewport, parseWaiverFile, type AppStateInput, type AppWaiver } from './design-lint/app-input';
|
||||
import { ruleMeta } from './design-lint/rules/ids';
|
||||
|
||||
export const FIRST_USE_ACTIONS = 5;
|
||||
export const LINK_FRESH_MS = 15 * 60 * 1000;
|
||||
@@ -46,11 +48,19 @@ export interface FrozenAction { n: number; action: string; frequency: string; fe
|
||||
export interface FrozenStep { n: number; kind: 'step' | 'action'; text: string; writes: string; approved_write?: string; check?: string; quote?: number }
|
||||
export interface BuildId { platform: typeof PLATFORMS[number]; commit: string; testflight?: string; deploy?: string }
|
||||
export interface Holding { build: string; defects: string }
|
||||
/** The play spec's crowded screens as frozen at start: the parsed states and waivers with the hash of each file's bytes. */
|
||||
export interface FrozenFullHouse extends FullHouse { states_parsed: AppStateInput[]; waivers_parsed: AppWaiver[]; states_sha256: string; waivers_sha256: string | null }
|
||||
/** One `gstack-first-use layout` run: design-lint's --full-house verdict on the frozen states, bound to the build and the frozen files. */
|
||||
export interface LayoutReceipt {
|
||||
schema_version: 1; kind: 'first-use-layout'; at: string; build_fingerprint: string; states_sha256: string; waivers_sha256: string | null;
|
||||
viewports: string[]; within: string; origins: string[]; gstack_version: string; verdict: 'clean' | 'open' | 'incomplete'; code: string; open: number; waived: number;
|
||||
findings: Array<{ rule: string; evidence: string; locator?: string; waiver?: string }>; incomplete: Array<{ state: string; viewport: string; code: string; detail: string }>;
|
||||
}
|
||||
export interface Manifest {
|
||||
schema_version: 2; kind: 'first-use-manifest'; app: string; created_at: string;
|
||||
source: { path: string; rows_sha256: string }; quotes: FrozenQuote[]; actions: FrozenAction[]; steps: FrozenStep[];
|
||||
try_text: string; try_sha256: string; build: BuildId & { fingerprint: string }; phone_build?: string; play: PlaySpec; holding: Holding;
|
||||
builder: { model: string; family: string }; checker: { model: string; family: string };
|
||||
builder: { model: string; family: string }; checker: { model: string; family: string }; full_house?: FrozenFullHouse;
|
||||
}
|
||||
export interface StepResult {
|
||||
schema_version: 2; kind: 'first-use-result'; step: number; step_text: string; step_kind: FrozenStep['kind']; build_fingerprint: string; at: string;
|
||||
@@ -162,7 +172,27 @@ function checkHolding(h: Partial<Holding> | undefined): Result<{ holding: Holdin
|
||||
return { holding: { build, defects } };
|
||||
}
|
||||
|
||||
export interface StartInput { root: string; app: string; planPath: string; build: Partial<BuildId>; phoneBuild?: string; play: unknown; holding: Partial<Holding>; builder: string; checker: string; now?: Date }
|
||||
/** Reads and parses the play spec's state file and waivers (relative to the play spec), so the layout check measures exactly what start saw. */
|
||||
function freezeFullHouse(fh: FullHouse, playDir: string): Result<{ frozen: FrozenFullHouse }> {
|
||||
const read = (rel: string, what: string): Result<{ text: string }> => {
|
||||
try { return { text: fs.readFileSync(path.resolve(playDir, rel), 'utf8') }; } catch { return fail('FIRST_USE_PLAY_SPEC_INCOMPLETE', `full_house.${what} ${rel} can't be read (paths are relative to the play spec)`); }
|
||||
};
|
||||
const states = read(fh.states, 'states');
|
||||
if ('error' in states) return states;
|
||||
const waivers = fh.waivers ? read(fh.waivers, 'waivers') : undefined;
|
||||
if (waivers && 'error' in waivers) return waivers;
|
||||
try {
|
||||
(fh.viewports ?? []).forEach(parseViewport);
|
||||
const parsed = parseStateFile(states.text);
|
||||
const waived = waivers ? parseWaiverFile(waivers.text, id => !!ruleMeta(id)?.app) : [];
|
||||
return { frozen: { ...fh, states_parsed: parsed.states, waivers_parsed: waived, states_sha256: sha256(states.text), waivers_sha256: waivers ? sha256(waivers.text) : null } };
|
||||
} catch (e) {
|
||||
if (e instanceof AppUsageError) return fail('FIRST_USE_PLAY_SPEC_INCOMPLETE', `full_house: ${e.code}: ${e.message} | fix: ${e.fix}`);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
export interface StartInput { root: string; app: string; planPath: string; build: Partial<BuildId>; phoneBuild?: string; play: unknown; playDir?: string; holding: Partial<Holding>; builder: string; checker: string; now?: Date }
|
||||
/** Freezes the owner's quotes, the steps and the try-it text, and writes the run's manifest once; returns the run directory. */
|
||||
export function startRun(o: StartInput): Result<{ dir: string; manifest: Manifest }> {
|
||||
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(o.app)) return fail('FIRST_USE_RECORD_INVALID', '--app must be a lowercase slug like ghome');
|
||||
@@ -170,8 +200,11 @@ export function startRun(o: StartInput): Result<{ dir: string; manifest: Manifes
|
||||
try { planText = fs.readFileSync(o.planPath, 'utf8'); } catch { return fail('FIRST_USE_PLAN_UNREADY', `cannot read ${o.planPath}`); }
|
||||
const frozen = freezeActions(planText);
|
||||
if ('error' in frozen) return frozen;
|
||||
const play = checkPlaySpec(o.play);
|
||||
const play = checkPlaySpec(o.play, o.build.platform);
|
||||
if ('error' in play) return play;
|
||||
const fh = play.spec.full_house;
|
||||
const fullHouse = fh && typeof fh === 'object' ? freezeFullHouse(fh, o.playDir ?? process.cwd()) : undefined;
|
||||
if (fullHouse && 'error' in fullHouse) return fullHouse;
|
||||
const build = buildFingerprint(o.build);
|
||||
if ('error' in build) return build;
|
||||
const phone = build.platform === 'ios' || build.platform === 'android';
|
||||
@@ -188,7 +221,8 @@ export function startRun(o: StartInput): Result<{ dir: string; manifest: Manifes
|
||||
];
|
||||
const base = { schema_version: 2 as const, kind: 'first-use-manifest' as const, app: o.app, created_at: now.toISOString(),
|
||||
source: { path: path.resolve(o.planPath), rows_sha256: frozen.rows_sha256 }, quotes: frozen.quotes, actions: frozen.actions, steps,
|
||||
build, ...(phone ? { phone_build: o.phoneBuild } : {}), play: play.spec, holding: holding.holding, builder: { model: o.builder, family: builder }, checker: { model: o.checker, family: checker } };
|
||||
build, ...(phone ? { phone_build: o.phoneBuild } : {}), play: play.spec, holding: holding.holding, builder: { model: o.builder, family: builder }, checker: { model: o.checker, family: checker },
|
||||
...(fullHouse ? { full_house: fullHouse.frozen } : {}) };
|
||||
const try_text = renderTryText(base);
|
||||
const manifest: Manifest = { ...base, try_text, try_sha256: sha256(try_text) };
|
||||
const dir = path.join(o.root, o.app, `${stamp(now)}-${build.fingerprint.slice(0, 8)}`);
|
||||
@@ -327,7 +361,7 @@ function readDir<T>(dir: string): { rows: T[]; unreadable: string[] } {
|
||||
const newest = <T extends { at?: string; checked_at?: string }>(rows: T[]) => [...rows].sort((a, b) => (a.at ?? a.checked_at ?? '').localeCompare(b.at ?? b.checked_at ?? '')).at(-1);
|
||||
|
||||
export interface StepVerdict { n: number; kind: FrozenStep['kind']; text: string; verdict: Verdict; line: string; notice?: string }
|
||||
export interface Decision { ok: boolean; reasons: string[]; manifest?: Manifest; passed: number; verdicts: StepVerdict[]; links: LinkReceipt[]; prediction?: Prediction; owner?: OwnerScore }
|
||||
export interface Decision { ok: boolean; reasons: string[]; manifest?: Manifest; passed: number; verdicts: StepVerdict[]; links: LinkReceipt[]; prediction?: Prediction; owner?: OwnerScore; layout?: LayoutReceipt }
|
||||
/**
|
||||
* Whether this run clears the build about to be sent: the same build, unchanged day-one rows and quotes, a newest result
|
||||
* with intact evidence for every step on the play spec's target, none wrong, broken or needing something an agent could
|
||||
@@ -377,8 +411,17 @@ export function decide(dir: string, build: Partial<BuildId>, now: Date = new Dat
|
||||
if (r.verdict !== 'live') reasons.push(`link_down: ${link.url} (status ${r.status || r.error || 'none'})`);
|
||||
else if (now.getTime() - Date.parse(r.checked_at) > LINK_FRESH_MS) reasons.push(`link_stale: ${link.url} was checked at ${r.checked_at}, over 15 minutes ago`);
|
||||
}
|
||||
const fh = m.full_house;
|
||||
const layoutDir = fh ? readDir<LayoutReceipt>(path.join(dir, 'layout')) : undefined;
|
||||
if (layoutDir?.unreadable.length) reasons.push(`record_unreadable: layout/${layoutDir.unreadable.join(', layout/')}`);
|
||||
const layout = fh && layoutDir ? newest(layoutDir.rows.filter(x => x.kind === 'first-use-layout' && x.build_fingerprint === m.build.fingerprint
|
||||
&& x.states_sha256 === fh.states_sha256 && x.waivers_sha256 === fh.waivers_sha256)) : undefined;
|
||||
if (fh && !layout) reasons.push(`full_house_unchecked: measure the crowded screens (${fh.limits}) with gstack-first-use layout --run <dir>`);
|
||||
else if (layout?.verdict === 'open') reasons.push(`full_house_open: ${layout.open} cut-off or overlapping text at the declared limits; first: ${layout.findings.find(x => !x.waiver)?.evidence ?? 'see gstack-first-use layout'}`);
|
||||
else if (layout?.verdict === 'incomplete') reasons.push(`full_house_incomplete: ${layout.code}: ${layout.incomplete[0] ? `${layout.incomplete[0].state} at ${layout.incomplete[0].viewport} was not measured (${layout.incomplete[0].detail})` : 'nothing was measured'}`);
|
||||
else if (layout && layout.verdict !== 'clean') reasons.push(`full_house_unchecked: the newest layout record has no clean, open or incomplete verdict (${String(layout.verdict)}); rerun gstack-first-use layout --run <dir>`);
|
||||
const prediction = readJson<Prediction>(path.join(dir, 'prediction.json'));
|
||||
if (!prediction) reasons.push('no_predicted_score');
|
||||
const owner = newest(readDir<OwnerScore>(path.join(dir, 'owner')).rows);
|
||||
return { ok: reasons.length === 0, reasons, manifest: m, passed, verdicts, links, prediction, owner };
|
||||
return { ok: reasons.length === 0, reasons, manifest: m, passed, verdicts, links, prediction, owner, ...(layout ? { layout } : {}) };
|
||||
}
|
||||
@@ -521,6 +521,7 @@ export const KNOWN_WINDOWS_INCOMPATIBLE: Array<{ file: string; reason: string }>
|
||||
file: 'browse/test/address-guard.test.ts',
|
||||
reason: 'Bun crashes on windows-latest (bun.report, KERNEL32) while the public-only guard relays its SOCKS5 test connections (PR #4888 windows-scoped-shard, run 46198225599); public-only mode targets Linux and macOS like its e2e file, which skips Windows',
|
||||
},
|
||||
{ file: 'test/design-lint-full-house.test.ts', reason: 'measures the app profile in a real browser, and windows-latest has neither Aside nor a built browse binary, so the file fails at load in CI (windows-scoped-shard, run 46232928005); the app profile tier runs on Linux and macOS, like test/design-lint-app-profile.test.ts' },
|
||||
];
|
||||
|
||||
// Force-include overrides: files a WINDOWS_FRAGILE_PATTERNS regex excludes for
|
||||
|
||||
@@ -403,7 +403,7 @@ describe('app profile contract: no browser and the scope guard (T15, T20, T33)',
|
||||
});
|
||||
|
||||
test('app rules are app-only: tier ask, render, never reported by a page or component reporter; nothing else carries the marker', () => {
|
||||
expect(APP_IDS.sort()).toEqual(['copy-flush-under-list', 'note-in-row-weight', 'row-crowding', 'section-overflow', 'small-hit-area']);
|
||||
expect(APP_IDS.sort()).toEqual(['copy-flush-under-list', 'note-in-row-weight', 'row-crowding', 'section-overflow', 'small-hit-area', 'text-clipped', 'text-overlap']);
|
||||
for (const id of APP_IDS) expect([id, RULES[id].tier, RULES[id].render]).toEqual([id, 'ask', true]);
|
||||
for (const scope of ['page', 'component'] as const) expect(new Reporter(scope).report('row-crowding', 'x.html', 1, 'e')).toBeNull();
|
||||
expect(new Reporter('app').report('row-crowding', 'x.html', 1, 'e')?.rule).toBe('row-crowding');
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* The --full-house rules (GSTA-908, from JEOP-1): text-clipped and text-overlap, measured on a
|
||||
* crowded state at the app's declared limits. The replica is a public-safe score bar modelled on
|
||||
* the 8-player party-game bug (one flex cell per player, ellipsis names, an absolutely placed
|
||||
* badge over the score); the fixed copy and the negative controls (a clipped tail, a modal, hidden
|
||||
* text, a 1px touch, the rules off without --full-house) must stay clean. Skipped with a named
|
||||
* reason when no browser is available, except in CI, where a missing browser fails.
|
||||
*/
|
||||
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { pickEngine, resolveBrowseBin, type EngineChoice } from '../lib/aside-render';
|
||||
import { planApp } from '../lib/design-lint/app-cli';
|
||||
import { AppUsageError, parseViewport } from '../lib/design-lint/app-input';
|
||||
import { lintApp, type AppOptions } from '../lib/design-lint/render-app';
|
||||
import { asideAvailable } from './helpers/aside-available';
|
||||
import { browserAvailable, NO_BROWSER_REASON } from './helpers/browser-available';
|
||||
|
||||
const hasBrowser = browserAvailable();
|
||||
if (!hasBrowser && process.env.CI) throw new Error('design-lint-full-house: CI needs a browser for the app profile tier: ' + NO_BROWSER_REASON);
|
||||
if (!hasBrowser) process.stderr.write('design-lint-full-house: SKIPPED — ' + NO_BROWSER_REASON + '\n');
|
||||
|
||||
const engine = (): EngineChoice => {
|
||||
if (asideAvailable()) return pickEngine(true);
|
||||
const bin = resolveBrowseBin();
|
||||
return bin ? { engine: 'browse', bin } : { engine: null, probe: { ok: false, reason: 'NEEDS_ASIDE', detail: NO_BROWSER_REASON }, error: NO_BROWSER_REASON };
|
||||
};
|
||||
|
||||
const gen = fs.mkdtempSync(path.join(os.tmpdir(), 'design-lint-full-house-'));
|
||||
let base = '';
|
||||
let server: ReturnType<typeof Bun.serve> | null = null;
|
||||
|
||||
beforeAll(() => {
|
||||
if (!hasBrowser) return;
|
||||
server = Bun.serve({
|
||||
hostname: '127.0.0.1', port: 0,
|
||||
fetch(req) {
|
||||
const file = path.join(gen, decodeURIComponent(new URL(req.url).pathname).slice(1));
|
||||
if (!file.startsWith(gen + path.sep) || !fs.existsSync(file)) return new Response('not found', { status: 404 });
|
||||
return new Response(Bun.file(file));
|
||||
},
|
||||
});
|
||||
base = 'http://127.0.0.1:' + server.port;
|
||||
});
|
||||
afterAll(() => { server?.stop(true); fs.rmSync(gen, { recursive: true, force: true }); });
|
||||
|
||||
const page = (name: string, css: string, body: string): string => {
|
||||
fs.writeFileSync(path.join(gen, name), '<!doctype html><html lang="en"><head><meta charset="utf-8"><title>' + name + '</title><style>* { box-sizing: border-box } body { margin: 0; font: 16px/20px sans-serif; background: #111; color: #eee } ' + css + '</style></head><body>' + body + '</body></html>');
|
||||
return name;
|
||||
};
|
||||
|
||||
const NAMES = ['STEPHANIE KO', 'UNCLE BOBBY', 'CHRISTOPHER', 'GRANDMA JUNE', 'MARGARET LEE', 'ALEXANDRA P', 'NICHOLAS VAN', 'ELIZABETH Q'];
|
||||
const PADS_CSS = '.pads { position: absolute; left: 0; right: 0; bottom: 0; height: 48px; display: flex; gap: 4px; padding: 4px; background: #000 } '
|
||||
+ '.pad { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 12px; background: #151515; border: 0; color: #eee; font: inherit } '
|
||||
+ '.pad-score { font: 700 20px/20px sans-serif } .pad-screw { position: absolute; top: 2px; right: 6px; font: 700 11px/12px sans-serif; color: #f40 } ';
|
||||
const pads = (screw: string, nameClass = 'pad-name'): string => '<footer class="pads">' + NAMES.map((n) => '<button class="pad"><span class="' + nameClass + '">' + n + '</span><span class="pad-score">-$99,999</span>' + screw + '</button>').join('') + '</footer>';
|
||||
const REPLICA_CSS = PADS_CSS + '.pad-name { font: 20px/20px sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }';
|
||||
const VIEW = [parseViewport('1280x720')];
|
||||
|
||||
async function measure(name: string, more: Partial<AppOptions> = {}) {
|
||||
const r = await lintApp({ states: [{ name, url: base + '/' + name }], within: 'body', waitFor: '.probe-ready, footer, main', viewports: VIEW, engine, traceDir: gen, fullHouse: true, ...more });
|
||||
const open = r.findings.filter((f) => f.grade !== 'waived');
|
||||
return { r, open, ids: [...new Set(open.map((f) => f.rule))].sort() };
|
||||
}
|
||||
|
||||
describe('--full-house input checks (no browser)', () => {
|
||||
test('--full-house without --wait-for is a usage error naming the fix', () => {
|
||||
let err: unknown;
|
||||
try { planApp({ paths: [], urls: ['http://127.0.0.1:1/x'], within: 'main', viewports: [], fullHouse: true, verbose: false, json: false }); } catch (e) { err = e; }
|
||||
expect(err).toBeInstanceOf(AppUsageError);
|
||||
expect((err as AppUsageError).code).toBe('FULL_HOUSE_NEEDS_WAIT');
|
||||
});
|
||||
});
|
||||
|
||||
describe.skipIf(!hasBrowser)('--full-house: the 8-player score bar replica', () => {
|
||||
test('a horizontal row with no list is measured, and reports text-clipped on the names and text-overlap of the badge on the score', async () => {
|
||||
const { r, ids, open } = await measure(page('replica.html', REPLICA_CSS, pads('<span class="pad-screw">SCREW</span>')));
|
||||
expect([r.app.verdict, r.exitCode, r.app.states.map((s) => s.status)]).toEqual(['open', 1, ['measured']]);
|
||||
expect(ids).toEqual(['text-clipped', 'text-overlap']);
|
||||
const clipped = open.find((f) => f.rule === 'text-clipped')!;
|
||||
expect(clipped.evidence).toMatch(/span cuts off its text: \d+% of "[A-Z ]+" shows/);
|
||||
expect(clipped.app!.locator).toContain('span.pad-name');
|
||||
const overlap = open.find((f) => f.rule === 'text-overlap')!;
|
||||
expect(overlap.evidence).toMatch(/"-\$99,999" and "SCREW" are painted on top of each other|"SCREW" and "-\$99,999" are painted on top of each other/);
|
||||
}, 60_000);
|
||||
|
||||
test('a badge with its own opaque background painted over part of the score is still an overlap', async () => {
|
||||
const css = PADS_CSS + '.pad-name { font: 13px/16px sans-serif; overflow-wrap: anywhere } .pad-screw { top: 14px; right: 30px; background: #e33; color: #fff; padding: 0 2px }';
|
||||
const { ids, open } = await measure(page('opaque-badge.html', css, pads('<span class="pad-screw">SCREW</span>')));
|
||||
expect(ids).toContain('text-overlap');
|
||||
expect(open.find((f) => f.rule === 'text-overlap')!.evidence).toContain('SCREW');
|
||||
}, 60_000);
|
||||
|
||||
test('a positioned badge nested inside the score, a sticky opaque badge, and text spilling into the next opaque row are overlaps', async () => {
|
||||
const nested = PADS_CSS + '.pad-name { font: 13px/16px sans-serif; overflow-wrap: anywhere } .pad-score { position: relative } .pad-score .pad-screw { top: 4px; right: 20px }';
|
||||
const nestedPads = '<footer class="pads">' + NAMES.map((n) => '<button class="pad"><span class="pad-name">' + n + '</span><span class="pad-score">-$99,999<span class="pad-screw">MVP</span></span></button>').join('') + '</footer>';
|
||||
expect((await measure(page('nested-badge.html', nested, nestedPads))).ids).toContain('text-overlap');
|
||||
const sticky = PADS_CSS + '.pad-name { font: 13px/16px sans-serif; overflow-wrap: anywhere } .pad-screw { position: sticky; margin-left: -60px; background: #e33; color: #fff }';
|
||||
expect((await measure(page('sticky-badge.html', sticky, pads('<span class="pad-screw">SCREW</span>')))).ids).toContain('text-overlap');
|
||||
const rows = '.row { height: 40px; width: 400px; padding: 10px; background: #222 } .nm, .sc { display: block; font: 20px/20px sans-serif }';
|
||||
const body = '<main>' + ['ALEXANDRA<br>JR', 'BOB', 'CAROL'].map((n) => '<div class="row"><span class="nm">' + n + '</span><span class="sc">-$99,999</span></div>').join('') + '</main>';
|
||||
expect((await measure(page('overflow-opaque-row.html', rows, body))).ids).toContain('text-overlap');
|
||||
}, 60_000);
|
||||
|
||||
test('waivers on the first three cut names cannot hide a fourth unwaived cut', async () => {
|
||||
const css = 'main { padding: 24px } .c { display: block; width: 80px; margin: 0 0 8px; white-space: nowrap; overflow: hidden; font: 20px/20px sans-serif }';
|
||||
const body = '<main>' + ['a', 'b', 'c', 'd'].map((k) => '<span class="c c-' + k + '">WIDE NAME NUMBER ' + k + '</span>').join('') + '</main>';
|
||||
const waivers = ['a', 'b', 'c'].map((k) => ({ rule: 'text-clipped', locator: 'span.c.c-' + k, reason: 'short form on purpose for this cell' }));
|
||||
const { r, open } = await measure(page('four-cuts.html', css, body), { waivers });
|
||||
expect([r.app.verdict, open.filter((f) => f.rule === 'text-clipped').map((f) => f.app!.locator)]).toEqual(['open', [expect.stringContaining('c-d')]]);
|
||||
}, 60_000);
|
||||
|
||||
test('a screen that drops its crowded state at a later viewport is incomplete there, never measured empty', async () => {
|
||||
const body = '<main><div class="probe-ready">eight players</div></main><script>addEventListener("resize", () => { if (innerWidth < 600) document.querySelector(".probe-ready")?.remove(); });</script>';
|
||||
const { r } = await measure(page('shell-on-mobile.html', '', body), { waitFor: '.probe-ready', viewports: [parseViewport('1280x720'), parseViewport('375x812')] });
|
||||
expect(r.app.states.map((s) => [s.viewport, s.status, s.code])).toEqual([['1280x720', 'measured', 'OK'], ['375x812', 'incomplete', 'NOT_READY']]);
|
||||
}, 60_000);
|
||||
|
||||
test('without --full-house the same page reports neither rule (the rules are opt-in)', async () => {
|
||||
const { ids } = await measure('replica.html', { fullHouse: false });
|
||||
expect(ids.filter((i) => i === 'text-clipped' || i === 'text-overlap')).toEqual([]);
|
||||
}, 60_000);
|
||||
|
||||
test('the fixed copy (names wrap, the badge sits in the flow) is clean', async () => {
|
||||
const css = PADS_CSS + '.pads { height: auto } .pad { flex-direction: column; align-items: flex-start; padding: 4px 8px } .pad-name { font: 13px/16px sans-serif; overflow-wrap: anywhere } .pad-screw { position: static }';
|
||||
const { r, open } = await measure(page('fixed.html', css, pads('<span class="pad-screw">SCREW</span>')));
|
||||
expect([open, r.app.verdict]).toEqual([[], 'clean']);
|
||||
}, 60_000);
|
||||
|
||||
test('a waiver answers an intended truncation', async () => {
|
||||
const { r, open } = await measure(page('waived.html', REPLICA_CSS, pads('')), { waivers: [{ rule: 'text-clipped', locator: 'span.pad-name', reason: 'names show in full on the phones; the bar shows a short form on purpose' }] });
|
||||
expect([open, r.app.verdict, r.app.waived > 0]).toEqual([[], 'clean', true]);
|
||||
}, 60_000);
|
||||
});
|
||||
|
||||
describe.skipIf(!hasBrowser)('--full-house: negative controls for text-overlap', () => {
|
||||
test("a clipped name's hidden tail running under the score is text-clipped only, never an overlap", async () => {
|
||||
const css = PADS_CSS + '.pad { justify-content: flex-start } .pad-name { font: 20px/20px sans-serif; white-space: nowrap; overflow: hidden; flex: 0 0 60px } .pad-score { margin-left: 4px }';
|
||||
const { ids } = await measure(page('tail.html', css, pads('')));
|
||||
expect(ids).toEqual(['text-clipped']);
|
||||
}, 60_000);
|
||||
|
||||
test('a modal with an opaque panel over a line of the content, hidden overlay text and a 1px touch are clean', async () => {
|
||||
const css = 'main { padding: 24px } p { margin: 0 0 8px } .modal { position: fixed; inset: 0; display: grid; place-items: center } .panel { background: #222; padding: 24px; width: 400px } '
|
||||
+ '.ghost { position: absolute; top: 24px; left: 24px; opacity: 0 } .aria { position: absolute; top: 24px; left: 24px; visibility: hidden } .touch { position: absolute; top: 200px; left: 24px; font: 20px/20px sans-serif } .touch + .touch { left: 0; top: 219px } .behind { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); white-space: nowrap }';
|
||||
const body = '<main><p>Score summary for the room</p><p>Round two starts in a moment</p><span class="ghost">Hidden label over the text</span><span class="aria">Invisible text over the text</span>'
|
||||
+ '<span class="touch">first line</span><span class="touch">second line</span><span class="behind">Board under the dialog</span></main><div class="modal"><div class="panel"><p>Leave the game?</p><p>Your score is kept.</p></div></div>';
|
||||
const { r, open } = await measure(page('controls.html', css, body));
|
||||
expect([open, r.app.verdict]).toEqual([[], 'clean']);
|
||||
}, 60_000);
|
||||
});
|
||||
+111
-1
@@ -15,6 +15,7 @@ import * as path from 'node:path';
|
||||
import { DAY_ONE_COLUMNS, DAY_ONE_TITLES } from '../lib/autoplan-owner-text';
|
||||
import { buildFingerprint, checkLinks, decide, freezeActions, modelFamily, ownerScore, plainLine, predict, readManifest, recordResult, recordRoot, startRun, type Fetcher } from '../lib/first-use';
|
||||
import { checkPlaySpec, PLAY_PARTS, renderBrief, renderPlayMessage } from '../lib/first-use-message';
|
||||
import { runLayout } from '../lib/first-use-layout';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const FIX = path.join(ROOT, 'test', 'fixtures', 'first-use');
|
||||
@@ -464,7 +465,7 @@ describe('the gate', () => {
|
||||
const android = startRun({ ...base, root: fresh('root'), build: { platform: 'android', commit: COMMIT, deploy: '1.0.3' }, phoneBuild: PHONE_BUILD });
|
||||
if ('error' in android) throw new Error(android.error.detail);
|
||||
expect(renderBrief(android.manifest, android.dir)).toContain(`build_id "${PHONE_BUILD}", the mobile build service's build of commit ${COMMIT.slice(0, 12)}, which version 1.0.3 ships`);
|
||||
const web = startRun({ ...base, root: fresh('root'), build: { platform: 'web', commit: COMMIT, deploy: 'web-12' } });
|
||||
const web = startRun({ ...base, root: fresh('root'), build: { platform: 'web', commit: COMMIT, deploy: 'web-12' }, play: playWith(1, { full_house: 'none: a single static page' }) });
|
||||
expect('error' in web ? web.error.detail : web.manifest.phone_build).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -482,6 +483,92 @@ describe('the gate', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('the full-house layout gate (GSTA-908)', () => {
|
||||
const WEB = { platform: 'web' as const, commit: COMMIT, deploy: 'web-12' };
|
||||
const STATES = JSON.stringify({ version: 1, states: [{ name: 'eight players', url: 'http://127.0.0.1:1/?fixture=full-house' }] });
|
||||
const WAIVERS = JSON.stringify({ version: 1, waivers: [{ rule: 'text-clipped', locator: 'span.pad-name', reason: 'names show in full on each phone' }] });
|
||||
const FH = { states: 'states.json', within: '.pads', wait_for: '.pads .pad:nth-child(8)', limits: '8 players, 12-character names, scores to -$99,999' };
|
||||
const webRun = (fh: unknown = FH, files: Record<string, string> = { 'states.json': STATES }) => {
|
||||
const work = fresh('fh'), planPath = path.join(work, 'plan.md');
|
||||
fs.writeFileSync(planPath, AUTOPLAN);
|
||||
for (const [name, body] of Object.entries(files)) fs.writeFileSync(path.join(work, name), body);
|
||||
const r = startRun({ root: fresh('root'), app: 'partygame', planPath, build: WEB, play: playWith(1, { full_house: fh }), playDir: work, holding: HOLDING, builder: 'anthropic/claude-fable-5-2', checker: CHECKER, now: T0 });
|
||||
return { r, work };
|
||||
};
|
||||
const receipt = (dir: string, m: { build: { fingerprint: string }; full_house?: { states_sha256: string; waivers_sha256: string | null } }, o: Record<string, unknown> = {}) => {
|
||||
fs.mkdirSync(path.join(dir, 'layout'), { recursive: true });
|
||||
fs.writeFileSync(path.join(dir, 'layout', `${++n}.json`), JSON.stringify({ schema_version: 1, kind: 'first-use-layout', at: T0.toISOString(), build_fingerprint: m.build.fingerprint,
|
||||
states_sha256: m.full_house!.states_sha256, waivers_sha256: m.full_house!.waivers_sha256, viewports: ['1920x1080'], within: '.pads', origins: ['http://127.0.0.1:1'], gstack_version: 'test',
|
||||
verdict: 'clean', code: 'OK', open: 0, waived: 0, findings: [], incomplete: [], ...o }));
|
||||
};
|
||||
const fhReasons = (dir: string) => decide(dir, WEB, T0).reasons.filter(x => x.startsWith('full_house'));
|
||||
|
||||
test('a web play spec names its crowded screens or says none; other platforms may leave it out', () => {
|
||||
expect(checkPlaySpec(PLAY, 'web')).toMatchObject({ error: { code: 'FIRST_USE_PLAY_SPEC_INCOMPLETE', detail: expect.stringContaining('Full-house layout (full_house: a web build names its crowded screens') } });
|
||||
const none = checkPlaySpec({ ...PLAY, full_house: 'none: one static page with no lists' }, 'web');
|
||||
expect('spec' in none && none.spec.full_house).toBe('none: one static page with no lists');
|
||||
expect(checkPlaySpec({ ...PLAY, full_house: 'skip it' }, 'web')).toMatchObject({ error: { detail: expect.stringContaining('must read "none: <reason>"') } });
|
||||
expect(checkPlaySpec({ ...PLAY, full_house: { states: 's.json', within: 'main' } }, 'web')).toMatchObject({ error: { detail: expect.stringContaining('needs wait_for, limits') } });
|
||||
expect(checkPlaySpec({ ...PLAY, full_house: { ...FH, viewports: ['wide'] } }, 'web')).toMatchObject({ error: { detail: expect.stringContaining('viewports must be a list') } });
|
||||
const ios = checkPlaySpec(PLAY, 'ios');
|
||||
expect('spec' in ios && 'full_house' in ios.spec).toBe(false);
|
||||
});
|
||||
|
||||
test('start freezes the state file and waivers by hash, relative to the play spec, and refuses an unreadable or malformed one', () => {
|
||||
const { r } = webRun({ ...FH, waivers: 'waivers.json' }, { 'states.json': STATES, 'waivers.json': WAIVERS });
|
||||
if ('error' in r) throw new Error(r.error.detail);
|
||||
expect(r.manifest.full_house).toMatchObject({ limits: FH.limits, states_parsed: [{ name: 'eight players' }], waivers_parsed: [{ rule: 'text-clipped' }], states_sha256: expect.stringMatching(/^[0-9a-f]{64}$/), waivers_sha256: expect.stringMatching(/^[0-9a-f]{64}$/) });
|
||||
expect(webRun(FH, {}).r).toMatchObject({ error: { code: 'FIRST_USE_PLAY_SPEC_INCOMPLETE', detail: expect.stringContaining("full_house.states states.json can't be read") } });
|
||||
expect(webRun(FH, { 'states.json': '{"version":1,"states":[]}' }).r).toMatchObject({ error: { code: 'FIRST_USE_PLAY_SPEC_INCOMPLETE', detail: expect.stringContaining('BAD_STATE_FILE') } });
|
||||
const brief = renderBrief(r.manifest, r.dir);
|
||||
expect(brief).toContain('## The crowded screens');
|
||||
expect(brief).toContain('- text-clipped at "span.pad-name": names show in full on each phone');
|
||||
});
|
||||
|
||||
test('check refuses until a clean layout receipt for this build and these frozen files exists', () => {
|
||||
const { r } = webRun();
|
||||
if ('error' in r) throw new Error(r.error.detail);
|
||||
expect(fhReasons(r.dir)).toEqual([`full_house_unchecked: measure the crowded screens (${FH.limits}) with gstack-first-use layout --run <dir>`]);
|
||||
receipt(r.dir, r.manifest, { states_sha256: 'f'.repeat(64) });
|
||||
expect(fhReasons(r.dir)[0]).toStartWith('full_house_unchecked');
|
||||
receipt(r.dir, r.manifest, { verdict: 'open', code: 'OPEN', open: 2, findings: [{ rule: 'text-overlap', evidence: '[eight players 1920px] "$1,200" and "SCREW" are painted on top of each other' }] });
|
||||
expect(fhReasons(r.dir)).toEqual(['full_house_open: 2 cut-off or overlapping text at the declared limits; first: [eight players 1920px] "$1,200" and "SCREW" are painted on top of each other']);
|
||||
receipt(r.dir, r.manifest);
|
||||
expect(fhReasons(r.dir)).toEqual([]);
|
||||
receipt(r.dir, r.manifest, { verdict: 'maybe' });
|
||||
expect(fhReasons(r.dir)).toEqual(['full_house_unchecked: the newest layout record has no clean, open or incomplete verdict (maybe); rerun gstack-first-use layout --run <dir>']);
|
||||
receipt(r.dir, r.manifest);
|
||||
fs.writeFileSync(path.join(r.dir, 'layout', 'zz-half-written.json'), '{"schema_version": 1, "verdict": "op');
|
||||
expect(decide(r.dir, WEB, T0).reasons).toContain('record_unreadable: layout/zz-half-written.json');
|
||||
});
|
||||
|
||||
test('the try-it message names the checked limits and every waived cut', () => {
|
||||
const { r } = webRun();
|
||||
if ('error' in r) throw new Error(r.error.detail);
|
||||
receipt(r.dir, r.manifest, { waived: 2, findings: [
|
||||
{ rule: 'text-clipped', evidence: '[eight players 1920px] span cuts off its text: 40% of "Meet at noon" shows at footer > span', locator: 'footer > span', waiver: 'names show in full on each phone' },
|
||||
{ rule: 'text-overlap', evidence: '[eight players 1920px] "HOST" and "-$800" are painted on top of each other (20x10px, over 2px) at span.badge', locator: 'span.badge', waiver: 'the host badge is a sticker by design' }] });
|
||||
const d = decide(r.dir, WEB, T0);
|
||||
const msg = renderPlayMessage({ ...d, links: [{ checked_at: T0.toISOString() } as never] }, T0);
|
||||
expect(msg).toContain(`**Checked at the limits:** the builder declared them as ${FH.limits}; gstack measured those screens at 1920x1080 and found no cut-off or overlapping text beyond the 2 left on purpose above.`);
|
||||
expect(msg).toContain("- On a crowded screen, cut short on purpose: [eight players 1920px] span cuts off its text: 40% of \"Meet at noon\" shows (the builder's reason: names show in full on each phone)");
|
||||
expect(msg).toContain("- On a crowded screen, overlapping on purpose: [eight players 1920px] \"HOST\" and \"-$800\" are painted on top of each other (20x10px, over 2px) (the builder's reason: the host badge is a sticker by design)");
|
||||
});
|
||||
|
||||
test('layout with no browser writes an incomplete receipt that check refuses, and a run with none has nothing to measure', async () => {
|
||||
const { r } = webRun();
|
||||
if ('error' in r) throw new Error(r.error.detail);
|
||||
const out = await runLayout(r.dir, { engine: () => ({ engine: null, probe: { ok: false, reason: 'NEEDS_ASIDE', detail: 'test' }, error: 'no browser available (test)' }) as never }, () => T0);
|
||||
if ('error' in out) throw new Error(out.error.detail);
|
||||
expect([out.receipt.verdict, out.receipt.code, out.receipt.incomplete[0]?.code]).toEqual(['incomplete', 'NO_BROWSER', 'NO_BROWSER']);
|
||||
expect(fhReasons(r.dir)[0]).toStartWith('full_house_incomplete: NO_BROWSER: eight players at ');
|
||||
const none = webRun('none: one static page');
|
||||
if ('error' in none.r) throw new Error(none.r.error.detail);
|
||||
expect(fhReasons(none.r.dir)).toEqual([]);
|
||||
expect(await runLayout(none.r.dir)).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID', detail: expect.stringContaining('none: one static page') } });
|
||||
});
|
||||
});
|
||||
|
||||
describe('gstack-first-use (CLI, temporary HOME and drive)', () => {
|
||||
const BIN = path.join(ROOT, 'bin', 'gstack-first-use');
|
||||
const realDrive = path.join(os.homedir(), '.capy', 'drive');
|
||||
@@ -503,6 +590,29 @@ describe('gstack-first-use (CLI, temporary HOME and drive)', () => {
|
||||
return { stdout, stderr, code };
|
||||
};
|
||||
|
||||
test('layout prints its verdict lines and exits 4 when a crowded screen was not measured, 3 when there is nothing to measure', async () => {
|
||||
const work = fresh('cli-layout');
|
||||
const plan = path.join(work, 'plan.md');
|
||||
fs.writeFileSync(plan, AUTOPLAN);
|
||||
fs.writeFileSync(path.join(work, 'states.json'), JSON.stringify({ version: 1, states: [{ name: 'eight players', url: 'http://127.0.0.1:1/?fixture=full-house' }] }));
|
||||
const begin = async (fullHouse: unknown) => {
|
||||
const play = path.join(work, `play-${++n}.json`);
|
||||
fs.writeFileSync(play, JSON.stringify(playWith(server.port!, { full_house: fullHouse })));
|
||||
const r = await cli('start', '--app', 'partygame', '--plan', plan, '--play', play, '--platform', 'web', '--commit', COMMIT, '--deploy', 'web-12', '--holding', 'none', '--holding-defects', 'none', '--builder', 'anthropic/claude-opus-5-5', '--checker', CHECKER);
|
||||
expect(r.code).toBe(0);
|
||||
return /^FIRST_USE_RUN: (.+)$/m.exec(r.stdout)![1]!;
|
||||
};
|
||||
const dir = await begin({ states: 'states.json', within: '.pads', wait_for: '.pads .pad:nth-child(8)', limits: '8 players', viewports: ['1280x720'] });
|
||||
const out = await cli('layout', '--run', dir);
|
||||
expect(out.code).toBe(4);
|
||||
expect(out.stdout).toMatch(/^FIRST_USE_LAYOUT: incomplete code=[A-Z_]+ open=0 waived=0 viewports=1280x720 within=\.pads receipt=/m);
|
||||
expect(out.stdout).toMatch(/^LAYOUT_INCOMPLETE: state=eight players viewport=1280x720 code=[A-Z_]+ .* \| fix: .*\(docs\/design-lint\.md#app-code-/m);
|
||||
const check = await cli('check', '--run', dir, '--platform', 'web', '--commit', COMMIT, '--deploy', 'web-12');
|
||||
expect([check.code, check.stdout + check.stderr]).toEqual([3, expect.stringContaining('full_house_incomplete')]);
|
||||
const none = await cli('layout', '--run', await begin('none: one static page'));
|
||||
expect([none.code, none.stderr]).toEqual([3, expect.stringContaining('no crowded screens to measure')]);
|
||||
}, 60_000);
|
||||
|
||||
test('start, brief, record, predict, links, message, score and show in the owner\'s private drive', async () => {
|
||||
const work = fresh('cli');
|
||||
const plan = path.join(work, 'plan.md'), play = path.join(work, 'play.json');
|
||||
|
||||
Reference in new issue
Block a user