Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ It is an authoring loop, not part of `verify:pr` or CI.
Read the installed skill/topic, reuse guarded runners/fixtures and keep provider budgets.
`verify:pr` runs the tagged smoke journeys on a Dreamer app diff and the named
parcours for the zones that diff touches (`npm run test:e2e:smoke`,
`npm run test:e2e:parcours`), locally, without a model and without GitHub Actions.
`npm run test:e2e:parcours`), locally, without GitHub Actions, and without a
model unless `OPENAI_API_KEY` is set: the decision model then judges the
parcours the zones leave out ([details](doc_web_interne/docs/repository-operations.md)).
A docs-only diff, or a diff with no web app zone, skips both. A native-only
diff skips the web gate. If a zone is touched and Node 24.22.1, the e2e
install, or Chromium is missing, the check is unavailable and `verify:pr`
Expand Down
18 changes: 17 additions & 1 deletion doc_web_interne/docs/repository-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ coverage and release targets; [verify-local.config.mjs](../../verify-local.confi
is the executable source of truth.

`verify:pr` also runs two local web gates when the diff touches the app, with no
model call and no GitHub Actions minutes. `parcours-touches` maps changed paths
GitHub Actions minutes and, by default, no model call. `parcours-touches` maps changed paths
(`app/`, `components/`, `services/`, and the other roots in `tools/e2e/zones.mjs`)
to e2e tags and test files, then runs `e2e run --changed-since origin/master`.
`smoke-journeys` runs the seven tagged smoke journeys (capture, save, journal,
Expand All @@ -93,6 +93,22 @@ both. A native-only diff exits 0. If a zone is touched and Node 24.22.1,
is incomplete, not passed. Rerun: `npm run test:e2e:parcours`
and `npm run test:e2e:smoke`.

Optional decision model: with an OpenAI key in `OPENAI_API_KEY`,
`parcours-touches` also asks the TesterArmy decision filter (OpenAI's
Decisions API, `gpt-6-luna`, named in `tools/e2e/zones.mjs`) about every
Dreamer and Lucid parcours the zones leave out, on any Dreamer app diff, named
zone or not. The model sees the committed diff and the journey files; a file
only the working tree changes reaches it by name alone. A
parcours runs unless the model rates it under 20% likely affected; the zones
stay the floor, smoke and bug-bash tests keep their own checks, and a parcours
the model cannot judge runs. A lockfile or e2e config change makes it keep
every parcours. If the model cannot answer at all (no route, rejected key),
the zones decide alone and the run's filter note says so. The first verdict for
a commit is kept under `.git/verify-cache/e2e-decision/`, so `e2e list` and
`e2e run` select the same tests and a rerun asks nothing. The proof records
whether the model was on, so a pass without the key is not reused once it is
set. Without the key the gate is unchanged.

Before an app release, run `npm run test:bugbash:prerelease` on Dreamer web in
mock mode (the script refuses a production Supabase ref). Each confirmed bug
becomes a failing test under `tools/e2e/tests/bugbash/`, tagged `bugbash`.
Expand Down
2 changes: 1 addition & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ connects these commands to implementation paths and current runbooks.
| SEO | `seo:gsc:export`, `seo:backlinks:check` | GSC export writes a dated external-data report; backlink check fetches the tracked public referring pages but never rewrites the CSV. |
| Web E2E | `test:e2e:web`, `test:e2e:web:report` | TesterArmy and its pinned Chromium; simulated services. See [the E2E guide](../e2e/README.md). |
| Backend E2E | `test:e2e:backend`, `start:backend-e2e` | Disposable local backend on the native Supabase runtime (no Docker) and browser artifacts; `test:e2e:backend -- --qualify-ti528` adds the six TI528 integration cases to the nine backend scenarios. Linux amd64/arm64 with glibc 2.35+ or macOS 14+ on Apple silicon (`node scripts/check-native-supabase-runtime.cjs`). See [backend qualification](../doc_web_interne/docs/e2e-backend-qualification.md). |
| TesterArmy E2E | `test:testerarmy*`, `test:e2e:parcours`, `test:e2e:smoke`, `test:bugbash:prerelease`, `test:bugbash:repros`, `agent-device:*` | TesterArmy on web, an owned emulator or a named iOS Simulator; native runs need an identified Release build (`build`) and an explicit `E2E_DEVICE`, and take the device lock. `test:e2e:parcours` and `test:e2e:smoke` are the local PR gates (no model). `test:bugbash:prerelease` is the mock-mode explore before an app release; `test:bugbash:repros` is the release check. See [the TesterArmy guide](../tools/e2e/README.md). Maestro and its `test:e2e:*` Android commands were retired on 2026-10-14. |
| TesterArmy E2E | `test:testerarmy*`, `test:e2e:parcours`, `test:e2e:smoke`, `test:bugbash:prerelease`, `test:bugbash:repros`, `agent-device:*` | TesterArmy on web, an owned emulator or a named iOS Simulator; native runs need an identified Release build (`build`) and an explicit `E2E_DEVICE`, and take the device lock. `test:e2e:parcours` and `test:e2e:smoke` are the local PR gates (no model, except the optional decision model of `test:e2e:parcours` when `OPENAI_API_KEY` is set). `test:bugbash:prerelease` is the mock-mode explore before an app release; `test:bugbash:repros` is the release check. See [the TesterArmy guide](../tools/e2e/README.md). Maestro and its `test:e2e:*` Android commands were retired on 2026-10-14. |
| Mobile release | `release:*` | `prepare` writes manifests; `versions:sync` writes local mirrors; `build` starts a remote EAS build and requires explicit authorization. See [the release guide](../doc_web_interne/docs/MOBILE_VERSIONING.md). |
| Android release | `android:gates:*`, `android:release:local`, `build:apk:*` | May require ADB, a physical device, EAS credentials, or local build tooling. `android:gates:strict` requires a qualified TesterArmy run of the `production-apk` candidate under `tools/e2e/.e2e/dreamer-android/` (same commit as the release and its build, clean tree, intact manifest, candidate APK in `QA_ANDROID_RELEASE_APK`, stable and clean source snapshots). The real voice check is an optional manual test (owner decision 2026-10-17). |
| Subscriptions | `subscription:qa:*` | Some commands update local QA evidence; see the RevenueCat runbook before use. |
Expand Down
9 changes: 5 additions & 4 deletions tools/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,11 @@ real journeys and never establish application or physical qualification.

Agent goals can be added with an authorized model provider, one goal per call
and exact critical-outcome assertions. No provider is configured by default.
The optional `@e2e-dev/decision` / Jev setup described in the installed
`docs/decision-models.mdx` additionally requires `ai` 7.0.128 or later. This
package installs neither that executor nor `ai`; exact journeys require no
model dependency, and the upgrade does not enable a provider.
This package pins `@e2e-dev/decision` for one use only: the optional decision
filter of the PR parcours gate (`zones.mjs`, `decision-verdict.mjs`, installed
`docs/filters.mdx`, OpenAI `gpt-6-luna`), which stays off until `OPENAI_API_KEY` is set. Its
`decisionExecutor` for `agent.act` is not configured; exact journeys require no
model dependency.
Use a provider barrier when replay must never call a model; strict cache alone
does not forbid a call on a cache miss. Existing Playwright, backend and
CI checks remain until an explicitly reviewed pipeline change. Still-relevant
Expand Down
21 changes: 21 additions & 0 deletions tools/e2e/decision-verdict.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { TestFilter, TestFilterCandidate, TestFilterContext } from 'e2e';

export const FAILURE_TTL_MS: number;

export function verdictKey(input: {
model: string;
base: string;
head: string;
files: readonly string[];
tests: readonly string[];
}): string;

export function decisionVerdict(
asked: readonly TestFilterCandidate[],
context: TestFilterContext,
options?: {
load?: () => Promise<TestFilter>;
git?: (file: string, args: readonly string[], options: { cwd: string; encoding: 'utf8' }) => string;
now?: () => number;
},
): Promise<{ exclude: Record<string, string>; note?: string }>;
81 changes: 81 additions & 0 deletions tools/e2e/decision-verdict.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* The decision model's verdict on the parcours the zones leave out, through
* the TesterArmy Filters API (`@e2e-dev/decision`, OpenAI's Decisions API).
* run.mjs calls the filters twice, `e2e list` then `e2e run`, and
* checks that the run selected exactly what the list did, so the first answer
* for a commit and a test set is kept in the clone's git directory and reused.
* A rerun of verify:pr on the same commit asks nothing either. A failure is
* kept for a few minutes only: long enough for the run to fall back to the
* zones as its list did, short enough for a later verify:pr to ask again.
*/
import { createHash } from 'node:crypto';
import { execFileSync } from 'node:child_process';
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { DECISION_MODEL } from './zones.mjs';

/** @param {{ model: string, base: string, head: string, files: readonly string[], tests: readonly string[] }} input */
export function verdictKey({ model, base, head, files, tests }) {
return createHash('sha256').update(JSON.stringify({ model, base, head, files: [...files].sort(), tests: [...tests].sort() })).digest('hex');
}

function gitRead(git, root, args) {
return git('git', args, { cwd: root, encoding: 'utf8' }).trim();
}

/** How long a failed answer stands for the same question. */
export const FAILURE_TTL_MS = 10 * 60_000;

function readVerdict(file, now) {
try {
const kept = JSON.parse(readFileSync(file, 'utf8'));
if (kept && typeof kept.failed === 'string' && Number.isFinite(kept.at))
return now - kept.at < FAILURE_TTL_MS ? kept : null;
if (kept && typeof kept.exclude === 'object' && kept.exclude !== null && !Array.isArray(kept.exclude)
&& Object.values(kept.exclude).every(reason => typeof reason === 'string')) return kept;
} catch {}
return null;
}

function keep(file, value) {
mkdirSync(dirname(file), { recursive: true });
writeFileSync(`${file}.${process.pid}`, JSON.stringify(value));
renameSync(`${file}.${process.pid}`, file);
}

async function loadDecisionFilter() {
const [{ decisionFilter }, { openai }] = await Promise.all([import('@e2e-dev/decision'), import('@ai-sdk/openai')]);
// Reads OPENAI_API_KEY. The diff and the journey files go to OpenAI's API.
return decisionFilter({ model: openai.decisionModel(DECISION_MODEL) });
}

/**
* Asks the decision filter about `asked`, or reuses its answer for the same
* commit, base, changed files and tests. Throws when the model cannot answer
* at all (no route, every call failed, past the caller's deadline); the caller
* then keeps the zones alone. An interrupted run keeps no failure.
* @param {readonly import('e2e').TestFilterCandidate[]} asked
* @param {import('e2e').TestFilterContext} context
*/
export async function decisionVerdict(asked, context, { load = loadDecisionFilter, git = execFileSync, now = Date.now } = {}) {
const root = context.changes.root;
const key = verdictKey({
model: DECISION_MODEL, base: context.changes.base, head: gitRead(git, root, ['rev-parse', 'HEAD']),
files: context.changes.files, tests: asked.map(test => test.id),
});
Comment on lines +62 to +65

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include the actual diff contents in the verdict cache key

On a dirty checkout, editing an already-modified file leaves HEAD, the changed-path list, and the test IDs unchanged, so a local rerun reuses the previous verdict even though the model's input diff has changed. For example, after an unrelated edit causes a billing journey to be excluded, a subsequent billing-breaking edit to that same file still excludes it without consulting the model. The local runner explicitly supports working-tree changes (run.mjs, changedFilesSince). Hash the actual diff and relevant journey contents, or bypass persistent verdict reuse for dirty inputs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traced, and I don't think this reproduces, so no change here.

The model's input is fixed by what the key already holds. @e2e-dev/decision (changeDiff in dist/filter.js) diffs base..HEAD only, so the committed diff is fixed by head. A file that only the working tree changes reaches the model by name alone ("not committed, contents not read"). Those names are changes.files, which the key also covers.

The journey files the model reads are the asked tests' files. A test whose file or setup file is in changes.files (uncommitted edits included) runs without asking (touchedBy), so it is never in asked. Every asked file therefore matches its HEAD contents, which head covers.

In the example given, a second edit to an already-modified billing journey leaves the file in changes.files. The billing tests then run without asking, and the cached verdict is not used for them. The same holds for a second edit to an uncommitted app file: the model would only see that file's name again.


Generated by Claude Code

const file = join(gitRead(git, root, ['rev-parse', '--path-format=absolute', '--git-common-dir']), 'verify-cache', 'e2e-decision', `${key}.json`);
const cached = readVerdict(file, now());
if (cached?.failed !== undefined) throw new Error(`${cached.failed} (echec repris)`);
if (cached) return { exclude: cached.exclude, note: ['verdict repris', cached.note].filter(Boolean).join(', ') };
let verdict;
try {
verdict = await (await load()).filter(asked, context);
} catch (error) {
const interrupted = context.signal.aborted && context.signal.reason?.name !== 'TimeoutError';
if (!interrupted) keep(file, { failed: (error instanceof Error ? error.message : String(error)).split('\n')[0], at: now() });
throw error;
}
const kept = { exclude: { ...verdict.exclude }, ...(verdict.note ? { note: verdict.note } : {}) };
keep(file, kept);
return kept;
}
119 changes: 119 additions & 0 deletions tools/e2e/decision-verdict.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { existsSync, mkdirSync, mkdtempSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { test } from 'node:test';
import { decisionFilter } from '@e2e-dev/decision';
import { FAILURE_TTL_MS, decisionVerdict, verdictKey } from './decision-verdict.mjs';

const git = (cwd, ...args) => execFileSync('git', args, { cwd, encoding: 'utf8' }).trim();

/** A repository whose last commit changes one app file the two journeys may or may not reach. */
function repository() {
const root = realpathSync(mkdtempSync(join(tmpdir(), 'decision-verdict-')));
git(root, 'init', '-q', '-b', 'master');
git(root, 'config', 'user.email', 'test@example.com');
git(root, 'config', 'user.name', 'test');
mkdirSync(join(root, 'tests'));
mkdirSync(join(root, 'components'));
writeFileSync(join(root, 'tests/today.web.e2e.ts'), "test('today shows the moon', async () => {});\n");
writeFileSync(join(root, 'tests/billing.web.e2e.ts'), "test('billing opens the paywall', async () => {});\n");
writeFileSync(join(root, 'components/MoonCard.tsx'), 'export const phase = 1;\n');
git(root, 'add', '.');
git(root, 'commit', '-q', '-m', 'base');
const base = git(root, 'rev-parse', 'HEAD');
writeFileSync(join(root, 'components/MoonCard.tsx'), 'export const phase = 2;\n');
git(root, 'commit', '-qam', 'change');
return { root, base };
}

const tests = [
{ id: 'tests/today.web.e2e.ts::today shows the moon', file: 'tests/today.web.e2e.ts', titlePath: ['today shows the moon'], tags: [] },
{ id: 'tests/billing.web.e2e.ts::billing opens the paywall', file: 'tests/billing.web.e2e.ts', titlePath: ['billing opens the paywall'], tags: [] },
];

function context(root, base) {
return {
projectRoot: root, changes: { base, root, files: ['components/MoonCard.tsx'] },
signal: new AbortController().signal, log() {}, redact: text => text,
};
}

/** An offline decision model: the moon journey is likely affected, the billing one is not. */
function fakeModel(calls, fail = false) {
return {
specificationVersion: 'v4', provider: 'fake', modelId: 'fake-decisions', supportedQuestionTypes: ['boolean'],
async doDecide({ questions }) {
calls.push(Object.keys(questions).length);
if (fail) throw new Error('401 invalid key');
return {
answers: Object.fromEntries(Object.entries(questions).map(([id, question]) =>
[id, { type: 'boolean', probability: String(question.instructions).includes('billing') ? 0.05 : 0.9 }])),
usage: { inputTokens: 100, outputTokens: 0 }, warnings: [],
};
},
};
}

test('the real decision filter leaves out the journey the change cannot reach, and the verdict is kept for the run', async () => {
const { root, base } = repository();
try {
const calls = [];
let loads = 0;
const load = async () => { loads += 1; return decisionFilter({ model: fakeModel(calls) }); };
const first = await decisionVerdict(tests, context(root, base), { load });
assert.deepEqual(Object.keys(first.exclude), ['tests/billing.web.e2e.ts::billing opens the paywall']);
assert.match(first.exclude['tests/billing.web.e2e.ts::billing opens the paywall'], /5% likely affected/);
assert.equal(loads, 1);
assert.equal(calls.length, 1);
// `e2e run` after `e2e list`: same commit, change and tests, so the same answer and no call.
const second = await decisionVerdict(tests, context(root, base), { load });
assert.deepEqual(second.exclude, first.exclude);
assert.match(second.note, /^verdict repris/);
assert.equal(loads, 1);
// Another test set is another question.
await decisionVerdict(tests.slice(0, 1), context(root, base), { load });
assert.equal(loads, 2);
assert.equal(readdirSync(join(root, '.git/verify-cache/e2e-decision')).length, 2);
} finally { rmSync(root, { recursive: true, force: true }); }
});

test('a model that cannot answer throws, and the run falls back as its list did until the failure expires', async () => {
const { root, base } = repository();
try {
const calls = [];
let clock = 1_000_000;
const now = () => clock;
const load = async () => decisionFilter({ model: fakeModel(calls, true) });
await assert.rejects(decisionVerdict(tests, context(root, base), { load, now }), /401 invalid key/);
assert.equal(calls.length, 1);
// `e2e run` right after: the same failure, without asking again.
clock += FAILURE_TTL_MS - 1;
await assert.rejects(decisionVerdict(tests, context(root, base), { load, now }), /401 invalid key \(echec repris\)/);
assert.equal(calls.length, 1);
// A later verify:pr asks again.
clock += 1;
await assert.rejects(decisionVerdict(tests, context(root, base), { load, now }), /^Error: 401 invalid key$/);
assert.equal(calls.length, 2);
} finally { rmSync(root, { recursive: true, force: true }); }
});

test('an interrupted run keeps no failure', async () => {
const { root, base } = repository();
try {
const interrupt = new AbortController();
interrupt.abort(new Error('SIGINT'));
const load = async () => ({ name: 'decision', filter: async () => { throw new Error('aborted'); } });
await assert.rejects(decisionVerdict(tests, { ...context(root, base), signal: interrupt.signal }, { load }), /aborted/);
assert.equal(existsSync(join(root, '.git/verify-cache/e2e-decision')), false);
} finally { rmSync(root, { recursive: true, force: true }); }
});

test('a new commit, base, change or model is a new verdict', () => {
const input = { model: 'gpt-6-luna', base: 'a', head: 'b', files: ['x', 'y'], tests: ['t1', 't2'] };
const key = verdictKey(input);
assert.equal(verdictKey({ ...input, files: ['y', 'x'], tests: ['t2', 't1'] }), key);
for (const change of [{ head: 'c' }, { base: 'c' }, { files: ['x'] }, { tests: ['t1'] }, { model: 'gpt-6-sol' }])
assert.notEqual(verdictKey({ ...input, ...change }), key, JSON.stringify(change));
});
29 changes: 29 additions & 0 deletions tools/e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"devDependencies": {
"@ai-sdk/openai": "4.0.96",
"@e2e-dev/decision": "0.3.1",
"@e2e-dev/mobile": "0.12.4",
"@e2e-dev/web": "0.15.3",
"@types/node": "^24.0.0",
Expand Down
Loading