agentpath 0.0.0-stage → 0.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +105 -0
- package/README.md +101 -2
- package/THIRD_PARTY_NOTICES +12 -0
- package/apps/demo-site/dist/site.js +92 -0
- package/apps/studio/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/apps/studio/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/apps/studio/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/apps/studio/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/apps/studio/dist/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/apps/studio/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/apps/studio/dist/assets/index-DH4wJPHm.js +67 -0
- package/apps/studio/dist/assets/index-DrnNh2ip.css +1 -0
- package/apps/studio/dist/index.html +14 -0
- package/audit.md +173 -0
- package/autonomous-mode.md +104 -0
- package/ci.md +118 -0
- package/coding-agents.md +143 -0
- package/concepts.md +145 -0
- package/contracts.md +356 -0
- package/examples/tasks/ambiguous.json +98 -0
- package/examples/tasks/assertion-failure.json +98 -0
- package/examples/tasks/broken.json +98 -0
- package/examples/tasks/fixed.json +98 -0
- package/examples/tasks/recovery.json +19 -0
- package/images/compare-recovery-desktop.jpg +0 -0
- package/images/compare-variants-desktop.jpg +0 -0
- package/images/overview-desktop.jpg +0 -0
- package/images/run-autonomous-passed-desktop.jpg +0 -0
- package/images/run-failed-desktop.jpg +0 -0
- package/images/run-failed-mobile.jpg +0 -0
- package/images/run-missing-artifact-desktop.jpg +0 -0
- package/images/task-editor-laptop.jpg +0 -0
- package/installation.md +102 -0
- package/ledger.md +62 -0
- package/licenses/-fontsource-variable-geist-mono.txt +93 -0
- package/licenses/-fontsource-variable-geist.txt +93 -0
- package/licenses/lucide-react.txt +43 -0
- package/licenses/react-dom.txt +21 -0
- package/licenses/react.txt +21 -0
- package/licenses/scheduler.txt +21 -0
- package/licenses/tailwindcss.txt +21 -0
- package/licenses/zod.txt +21 -0
- package/package.json +165 -4
- package/packages/cli/bin/agentpath.js +39 -0
- package/packages/cli/dist/audit-rerun.js +384 -0
- package/packages/cli/dist/audit.js +387 -0
- package/packages/cli/dist/change-summaries.js +87 -0
- package/packages/cli/dist/ci-report.js +88 -0
- package/packages/cli/dist/demo.js +88 -0
- package/packages/cli/dist/doctor.js +265 -0
- package/packages/cli/dist/explain.js +89 -0
- package/packages/cli/dist/git.js +7 -0
- package/packages/cli/dist/inspect.js +118 -0
- package/packages/cli/dist/ledger.js +509 -0
- package/packages/cli/dist/local.js +102 -0
- package/packages/cli/dist/main.js +708 -0
- package/packages/cli/dist/mcp.js +231 -0
- package/packages/cli/dist/paths.js +6 -0
- package/packages/cli/dist/playwright-fixture.js +185 -0
- package/packages/cli/dist/playwright-reporter.js +49 -0
- package/packages/cli/dist/tasks.js +37 -0
- package/packages/cli/dist/test-source.js +283 -0
- package/packages/cli/dist/watch.js +96 -0
- package/packages/contracts/dist/agent-settings.js +18 -0
- package/packages/contracts/dist/agent.js +175 -0
- package/packages/contracts/dist/audit.js +115 -0
- package/packages/contracts/dist/guidance.js +339 -0
- package/packages/contracts/dist/index.js +14 -0
- package/packages/contracts/dist/inspect.js +63 -0
- package/packages/contracts/dist/ledger.js +80 -0
- package/packages/contracts/dist/local.js +171 -0
- package/packages/contracts/dist/outcomes.js +94 -0
- package/packages/contracts/dist/platform.js +105 -0
- package/packages/contracts/dist/playwright-live.js +76 -0
- package/packages/contracts/dist/policy.js +93 -0
- package/packages/contracts/dist/run.js +178 -0
- package/packages/contracts/dist/task-issues.js +39 -0
- package/packages/contracts/dist/task.js +185 -0
- package/packages/contracts/dist/watch.js +57 -0
- package/packages/core/dist/action-feedback.js +103 -0
- package/packages/core/dist/actions.js +160 -0
- package/packages/core/dist/agent-loop.js +122 -0
- package/packages/core/dist/artifacts.js +156 -0
- package/packages/core/dist/assertions.js +120 -0
- package/packages/core/dist/autonomous.js +1 -0
- package/packages/core/dist/browser.js +196 -0
- package/packages/core/dist/compare.js +141 -0
- package/packages/core/dist/control-state.js +62 -0
- package/packages/core/dist/diagnostics.js +134 -0
- package/packages/core/dist/evidence-diff.js +93 -0
- package/packages/core/dist/evidence.js +203 -0
- package/packages/core/dist/index.js +22 -0
- package/packages/core/dist/inspect.js +257 -0
- package/packages/core/dist/integrity.js +176 -0
- package/packages/core/dist/liveness.js +114 -0
- package/packages/core/dist/local-files.js +61 -0
- package/packages/core/dist/locators.js +214 -0
- package/packages/core/dist/model-provider.js +88 -0
- package/packages/core/dist/observation.js +257 -0
- package/packages/core/dist/playwright-live.js +519 -0
- package/packages/core/dist/playwright-results.js +543 -0
- package/packages/core/dist/policy.js +182 -0
- package/packages/core/dist/privacy.js +93 -0
- package/packages/core/dist/recovery.js +54 -0
- package/packages/core/dist/retention.js +204 -0
- package/packages/core/dist/run-index.js +177 -0
- package/packages/core/dist/run-plan.js +28 -0
- package/packages/core/dist/run-repository.js +518 -0
- package/packages/core/dist/runner.js +913 -0
- package/packages/core/dist/storage.js +63 -0
- package/packages/core/dist/task-fingerprint.js +36 -0
- package/packages/core/dist/test-change-rerun.js +84 -0
- package/packages/core/dist/test-changes.js +896 -0
- package/packages/core/dist/timing.js +41 -0
- package/packages/core/dist/watch.js +165 -0
- package/packages/server/dist/index.js +265 -0
- package/packages/server/dist/task-store.js +103 -0
- package/quickstart.md +85 -0
- package/security.md +136 -0
- package/try-on-your-repo.md +54 -0
- package/understanding-results.md +159 -0
- package/writing-tasks.md +196 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The kinds of test change `agentpath audit` reports, fixed in docs/audit.md before any measurement. */
|
|
3
|
+
export const testChangeKindSchema = z.enum([
|
|
4
|
+
"skip-added", "fixme-added", "conditional-skip-added", "fail-added", "only-added", "test-removed",
|
|
5
|
+
"assertion-removed", "assertion-soft", "assertion-made-conditional", "first-added", "action-removed",
|
|
6
|
+
"expected-changed", "negation-changed", "target-changed", "timeout-raised", "action-added",
|
|
7
|
+
"test-added", "assertion-added",
|
|
8
|
+
// Added on 5 December 2026, after the table was fixed (docs/audit.md, docs/decisions.md).
|
|
9
|
+
"target-message-key",
|
|
10
|
+
]);
|
|
11
|
+
export const testChangeEffectSchema = z.enum(["weakens", "changes", "neutral"]);
|
|
12
|
+
const WEAKENS = new Set([
|
|
13
|
+
"skip-added", "fixme-added", "conditional-skip-added", "fail-added", "only-added", "test-removed",
|
|
14
|
+
"assertion-removed", "assertion-made-conditional", "first-added", "action-removed", "target-message-key",
|
|
15
|
+
]);
|
|
16
|
+
const CHANGES = new Set(["expected-changed", "negation-changed", "assertion-soft", "target-changed", "timeout-raised", "action-added"]);
|
|
17
|
+
export function testChangeEffect(kind) {
|
|
18
|
+
return WEAKENS.has(kind) ? "weakens" : CHANGES.has(kind) ? "changes" : "neutral";
|
|
19
|
+
}
|
|
20
|
+
const shortText = z.string().max(2000);
|
|
21
|
+
export const testChangeFindingSchema = z.strictObject({
|
|
22
|
+
kind: testChangeKindSchema,
|
|
23
|
+
effect: testChangeEffectSchema,
|
|
24
|
+
/** One plain sentence. Quoted values come from the repository and are untrusted. */
|
|
25
|
+
detail: shortText,
|
|
26
|
+
baseLine: z.int().positive().optional(),
|
|
27
|
+
headLine: z.int().positive().optional(),
|
|
28
|
+
});
|
|
29
|
+
/** One version of a test in a rerun on the head build: "absent" when that version does not exist. */
|
|
30
|
+
export const rerunSideSchema = z.enum(["passed", "failed", "skipped", "not-run", "absent"]);
|
|
31
|
+
/**
|
|
32
|
+
* `agentpath audit --rerun`: the base version of a flagged test, run against the head build next to the head version.
|
|
33
|
+
* - change-needed: the old version failed at a locator or assertion, again on a second run, and the new version
|
|
34
|
+
* passed; or it was skipped or is gone while an unchanged test of the same old file passed in the same run. The
|
|
35
|
+
* change is what makes the test pass on this build.
|
|
36
|
+
* - not-needed: the old version still passes on this build.
|
|
37
|
+
* - inconclusive: anything else, with a reason (both fail, a failure outside a locator or assertion, a flaky
|
|
38
|
+
* result, not run).
|
|
39
|
+
* - not-applicable: there is no old version (a new test).
|
|
40
|
+
*/
|
|
41
|
+
export const testRerunSchema = z.strictObject({
|
|
42
|
+
outcome: z.enum(["change-needed", "not-needed", "inconclusive", "not-applicable"]),
|
|
43
|
+
old: rerunSideSchema,
|
|
44
|
+
new: rerunSideSchema,
|
|
45
|
+
/** The Playwright project the outcome comes from, when the configuration names one. */
|
|
46
|
+
project: shortText.optional(),
|
|
47
|
+
reason: shortText.optional(),
|
|
48
|
+
/** What explain's engine read from the old version's failure. Page-provided text is quoted and untrusted. */
|
|
49
|
+
statements: z.array(z.strictObject({ pointsTo: z.enum(["task", "site", "unclear"]), statement: shortText })).max(20).optional(),
|
|
50
|
+
});
|
|
51
|
+
export const auditedTestSchema = z.strictObject({
|
|
52
|
+
/** The describe path and title, or a hook label such as "[beforeEach 1]". */
|
|
53
|
+
title: z.array(shortText).min(1).max(64),
|
|
54
|
+
baseLine: z.int().positive().optional(),
|
|
55
|
+
headLine: z.int().positive().optional(),
|
|
56
|
+
findings: z.array(testChangeFindingSchema).max(500),
|
|
57
|
+
/**
|
|
58
|
+
* Where the old test's failure on the new build points, from explain's engine. Set only with a rerun whose
|
|
59
|
+
* outcome is change-needed; never inferred from source.
|
|
60
|
+
*/
|
|
61
|
+
direction: z.enum(["task", "site", "unclear"]).optional(),
|
|
62
|
+
/** Present only with `--rerun`. */
|
|
63
|
+
rerun: testRerunSchema.optional(),
|
|
64
|
+
});
|
|
65
|
+
export const auditedFileSchema = z.strictObject({
|
|
66
|
+
path: shortText,
|
|
67
|
+
previousPath: shortText.optional(),
|
|
68
|
+
status: z.enum(["added", "modified", "deleted", "renamed"]),
|
|
69
|
+
/** Set when the file, at base or head, could not be read or was past a listing limit; then tests lists only what was read. */
|
|
70
|
+
unreadable: shortText.optional(),
|
|
71
|
+
/** Tests whose titles are not literals, by line, at base or head. */
|
|
72
|
+
unreadableTests: z.array(z.strictObject({ side: z.enum(["base", "head"]), line: z.int().positive() })).max(2000),
|
|
73
|
+
tests: z.array(auditedTestSchema).max(2000),
|
|
74
|
+
});
|
|
75
|
+
export const auditReportSchema = z.strictObject({
|
|
76
|
+
schemaVersion: z.literal(1),
|
|
77
|
+
/** The merge base of --base and --head: where head left base. */
|
|
78
|
+
base: z.string().regex(/^[0-9a-f]{40,64}$/),
|
|
79
|
+
head: z.string().regex(/^[0-9a-f]{40,64}$/),
|
|
80
|
+
files: z.array(auditedFileSchema).max(5000),
|
|
81
|
+
/** Changed files near the tests that were not read: page objects, fixtures, playwright.config.* and similar. */
|
|
82
|
+
notExamined: z.array(shortText).max(5000),
|
|
83
|
+
/**
|
|
84
|
+
* Changed files named as tests that import another test runner (vitest, Jest, mocha, node:test and the like) and no
|
|
85
|
+
* Playwright module on every side that exists: base and head. Listed, never read, and never counted by a gate.
|
|
86
|
+
* Optional: reports from before this field have none.
|
|
87
|
+
*/
|
|
88
|
+
otherRunner: z.array(shortText).max(5000).optional(),
|
|
89
|
+
/**
|
|
90
|
+
* With paths given: changed test files outside them, other runners' files left out. Listed, never read or gated, so
|
|
91
|
+
* a path that leaves out a suite shows. Optional: absent without paths or when there are none.
|
|
92
|
+
*/
|
|
93
|
+
outsidePaths: z.array(shortText).max(5000).optional(),
|
|
94
|
+
/** Present only with `--rerun`: facts about the rerun as a whole. */
|
|
95
|
+
rerun: z.strictObject({
|
|
96
|
+
/** Paths whose git status differed after the rerun. Each one makes --fail-on-change-needed exit 3. */
|
|
97
|
+
treeChanged: z.array(shortText).max(200),
|
|
98
|
+
timedOut: z.boolean(),
|
|
99
|
+
}).optional(),
|
|
100
|
+
totals: z.strictObject({
|
|
101
|
+
/** Changed test files, including any past the listing limit. */
|
|
102
|
+
testFiles: z.int().min(0),
|
|
103
|
+
testsChanged: z.int().min(0),
|
|
104
|
+
weakened: z.int().min(0),
|
|
105
|
+
changed: z.int().min(0),
|
|
106
|
+
/** Files and tests not read, including changed test files past the listing limit. */
|
|
107
|
+
unreadable: z.int().min(0),
|
|
108
|
+
/** All changed files near the tests that were not read; `notExamined` lists at most 5000. */
|
|
109
|
+
notExamined: z.int().min(0),
|
|
110
|
+
/** All changed test files of another runner; `otherRunner` lists at most 5000. Optional, as that list is. */
|
|
111
|
+
otherRunner: z.int().min(0).optional(),
|
|
112
|
+
/** All changed test files outside the paths given; `outsidePaths` lists at most 5000. */
|
|
113
|
+
outsidePaths: z.int().min(0).optional(),
|
|
114
|
+
}),
|
|
115
|
+
});
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/** Where a set of findings points: the site if any finding does, else the task if any does, else unclear. */
|
|
2
|
+
export function evidenceDirection(findings) {
|
|
3
|
+
if (findings.some((finding) => finding.pointsTo === "site"))
|
|
4
|
+
return "site";
|
|
5
|
+
return findings.some((finding) => finding.pointsTo === "task") ? "task" : "unclear";
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Findings from failed requests. Only failures the site owns point to the site: a network error, a server error
|
|
9
|
+
* (5xx), or a missing resource (404, 410). A refused sign-in (401, 403, 407) or rate limit (429) usually means the
|
|
10
|
+
* test environment lacks credentials or quota, and other 4xx can answer input the task sent, so those are facts.
|
|
11
|
+
*/
|
|
12
|
+
export function failedRequestFindings(failed) {
|
|
13
|
+
const findings = [];
|
|
14
|
+
const listed = (entries) => entries.slice(0, 3)
|
|
15
|
+
.map((entry) => `${entry.method} ${entry.host}${entry.path} → ${entry.status ?? "network error"}`).join("; ");
|
|
16
|
+
const siteOwned = failed.filter((entry) => entry.status === undefined || entry.status >= 500 || entry.status === 404 || entry.status === 410);
|
|
17
|
+
const refused = failed.filter((entry) => entry.status !== undefined && [401, 403, 407, 429].includes(entry.status));
|
|
18
|
+
const rejected = failed.filter((entry) => !siteOwned.includes(entry) && !refused.includes(entry));
|
|
19
|
+
if (siteOwned.length)
|
|
20
|
+
findings.push({ pointsTo: "site", statement: `Requests to allowed hosts failed: ${listed(siteOwned)}.` });
|
|
21
|
+
if (refused.length) {
|
|
22
|
+
findings.push({ pointsTo: "unclear", statement: `Requests to allowed hosts were refused for sign-in, permission or rate limits: ${listed(refused)}. The test environment may need credentials or quota; this alone does not show the site is broken.` });
|
|
23
|
+
}
|
|
24
|
+
if (rejected.length) {
|
|
25
|
+
findings.push({ pointsTo: "unclear", statement: `Requests to allowed hosts were rejected: ${listed(rejected)}. This can answer input the task sent, or be a site defect.` });
|
|
26
|
+
}
|
|
27
|
+
return findings;
|
|
28
|
+
}
|
|
29
|
+
const quote = (value) => JSON.stringify(value);
|
|
30
|
+
const relationText = {
|
|
31
|
+
"same-name-other-role": "has the same name with a different role",
|
|
32
|
+
"case-or-spacing": "differs only in case, spacing or punctuation",
|
|
33
|
+
"similar-name": "has a similar name",
|
|
34
|
+
"accessible-name-matches-label": "is a control whose accessible name equals the requested label",
|
|
35
|
+
"visible-text-matches": "shows the requested name as its visible text but has a different accessible name",
|
|
36
|
+
};
|
|
37
|
+
const tokens = (value) => value.normalize("NFKC").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
38
|
+
function editDistance(a, b) {
|
|
39
|
+
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
40
|
+
for (let i = 1; i <= a.length; i++) {
|
|
41
|
+
const current = [i];
|
|
42
|
+
for (let j = 1; j <= b.length; j++) {
|
|
43
|
+
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
44
|
+
}
|
|
45
|
+
previous = current;
|
|
46
|
+
}
|
|
47
|
+
return previous[b.length];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* How a similar name differs from the requested one, word by word. A near match that differs by an
|
|
51
|
+
* identifier (a word containing a digit, such as an invoice number), or that drops or replaces a whole
|
|
52
|
+
* requested word, is likely a different record on a page of repeated controls, not a misspelling of the
|
|
53
|
+
* requested one. Words that differ by a small edit (a typo, a plural) pair up and do not count. A name that
|
|
54
|
+
* keeps every requested word and adds words without digits ("Email address" for "Email") is not flagged.
|
|
55
|
+
*/
|
|
56
|
+
export function nameDifference(requested, candidate) {
|
|
57
|
+
// The same letters split differently ("E-mail" and "Email") cannot be a different word, but the same digits
|
|
58
|
+
// grouped differently ("Room 1-23" and "Room 12-3") are a different identifier.
|
|
59
|
+
if (tokens(requested).join("") === tokens(candidate).join("")) {
|
|
60
|
+
const groups = (value) => (value.normalize("NFKC").match(/\p{N}+/gu) ?? []).join(" ");
|
|
61
|
+
return groups(requested) === groups(candidate) ? undefined : "identifier";
|
|
62
|
+
}
|
|
63
|
+
const left = tokens(requested);
|
|
64
|
+
const right = tokens(candidate);
|
|
65
|
+
for (const word of [...left]) {
|
|
66
|
+
const index = right.indexOf(word);
|
|
67
|
+
if (index >= 0) {
|
|
68
|
+
right.splice(index, 1);
|
|
69
|
+
left.splice(left.indexOf(word), 1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
let identifier = false;
|
|
73
|
+
let word = false;
|
|
74
|
+
for (const wanted of left) {
|
|
75
|
+
const index = right.findIndex((other) => editDistance(wanted, other) <= (Math.min(wanted.length, other.length) >= 4 ? 2 : 1));
|
|
76
|
+
if (index < 0) {
|
|
77
|
+
word = true;
|
|
78
|
+
identifier ||= /\p{N}/u.test(wanted);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const [paired] = right.splice(index, 1);
|
|
82
|
+
if (/\p{N}/u.test(wanted) || /\p{N}/u.test(paired))
|
|
83
|
+
identifier = true;
|
|
84
|
+
}
|
|
85
|
+
// Extra words on the page's side keep every requested word (a fuller label, such as "Email address" for
|
|
86
|
+
// "Email"); they count only when they carry an identifier.
|
|
87
|
+
if (right.some((other) => /\p{N}/u.test(other)))
|
|
88
|
+
identifier = true;
|
|
89
|
+
return identifier ? "identifier" : word ? "word" : undefined;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A name shaped like a message key ("settings.update_profile", "auth.login"): lowercase segments joined by
|
|
93
|
+
* dots, with no spaces, and an underscore, a second dot or a long last segment, so a file name such as
|
|
94
|
+
* "main.go" or "index.html" is not one. Shown where a translated name belongs, it may be a missing translation
|
|
95
|
+
* rather than a rename, so it is never suggested in place of a name that is not itself shaped like one. The
|
|
96
|
+
* shape alone cannot tell a key from a file or host name ("vite.config.ts"), so it is reported as a fact.
|
|
97
|
+
*/
|
|
98
|
+
export function messageKey(name) {
|
|
99
|
+
if (!/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/.test(name))
|
|
100
|
+
return false;
|
|
101
|
+
const segments = name.split(".");
|
|
102
|
+
return name.includes("_") || segments.length > 2 || segments.at(-1).length >= 5;
|
|
103
|
+
}
|
|
104
|
+
/** Roles a user operates. A near match outside them cannot stand in for one of them, and the reverse. */
|
|
105
|
+
const WIDGETS = new Set(["button", "checkbox", "combobox", "link", "listbox", "menuitem", "option", "radio", "searchbox", "slider", "spinbutton", "switch", "tab", "textbox"]);
|
|
106
|
+
/** Roles an action that types or chooses can operate; other actions on a control take any widget role. */
|
|
107
|
+
const ACCEPTS = {
|
|
108
|
+
fill: new Set(["textbox", "searchbox", "combobox", "spinbutton"]),
|
|
109
|
+
select: new Set(["combobox", "listbox"]),
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Whether a near match of the given role could replace the requested target in the failed operation. A
|
|
113
|
+
* suggestion to click a form, or to assert on a heading where a button was named, would change what the
|
|
114
|
+
* operation does, not fix its target. A label target always names a control.
|
|
115
|
+
*/
|
|
116
|
+
function canStandIn(where, role) {
|
|
117
|
+
const accepts = where.action ? ACCEPTS[where.action] : undefined;
|
|
118
|
+
if (accepts)
|
|
119
|
+
return accepts.has(role);
|
|
120
|
+
if (where.action === "click" || where.action === "press")
|
|
121
|
+
return WIDGETS.has(role);
|
|
122
|
+
const target = where.target;
|
|
123
|
+
if (!target)
|
|
124
|
+
return true;
|
|
125
|
+
return (target.by === "label" || WIDGETS.has(target.role)) === WIDGETS.has(role);
|
|
126
|
+
}
|
|
127
|
+
export function taskOperation(task, failure) {
|
|
128
|
+
const { location } = failure;
|
|
129
|
+
if (location.phase === "step" && task.mode === "deterministic") {
|
|
130
|
+
const step = task.steps[location.index];
|
|
131
|
+
if (!step)
|
|
132
|
+
return undefined;
|
|
133
|
+
return { path: `/steps/${location.index}`, kind: "step", action: step.action,
|
|
134
|
+
...("target" in step ? { target: step.target } : {}), ...(step.action === "select" ? { optionBy: step.option.by } : {}) };
|
|
135
|
+
}
|
|
136
|
+
if (location.phase === "assertion") {
|
|
137
|
+
const assertion = task.assertions[location.index];
|
|
138
|
+
if (!assertion)
|
|
139
|
+
return undefined;
|
|
140
|
+
return { path: `/assertions/${location.index}`, kind: "assertion", ...("target" in assertion ? { target: assertion.target } : {}) };
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* What a failed assertion asked for, quoted from the task file itself (operator data, not page data).
|
|
146
|
+
* The stored record says only "the configured text" or "the configured pattern", so this is shown only
|
|
147
|
+
* when the task file is at hand, and nothing new is stored.
|
|
148
|
+
*/
|
|
149
|
+
export function configuredExpectation(task, failure) {
|
|
150
|
+
if (failure.location.phase !== "assertion")
|
|
151
|
+
return undefined;
|
|
152
|
+
const assertion = task.assertions[failure.location.index];
|
|
153
|
+
// Text that contains a value the task types is not repeated, as the stored plan does not repeat it.
|
|
154
|
+
const typed = task.mode === "deterministic"
|
|
155
|
+
? task.steps.flatMap((step) => step.action === "fill" && step.value.trim() ? [step.value.trim().toLowerCase()] : []) : [];
|
|
156
|
+
const typesInto = (value) => typed.some((entry) => value.toLowerCase().includes(entry));
|
|
157
|
+
if (assertion?.assert === "text") {
|
|
158
|
+
return typesInto(assertion.contains) ? "Expected text (task file): not shown, because it contains a value the task types."
|
|
159
|
+
: `Expected text (task file): contains ${JSON.stringify(assertion.contains)}`;
|
|
160
|
+
}
|
|
161
|
+
if (assertion?.assert === "url") {
|
|
162
|
+
return typesInto(assertion.pattern) ? "Expected URL (task file): not shown, because it contains a value the task types."
|
|
163
|
+
: `Expected URL (task file): ${JSON.stringify(assertion.pattern)}`;
|
|
164
|
+
}
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
/** The failed operation as a stored run plan recorded it, for guidance on a run whose task file is not at hand. */
|
|
168
|
+
export function planOperation(plan, failure) {
|
|
169
|
+
const { location } = failure;
|
|
170
|
+
if (location.phase !== "step" && location.phase !== "assertion")
|
|
171
|
+
return undefined;
|
|
172
|
+
const entry = location.phase === "step" ? plan?.steps[location.index] : plan?.assertions[location.index];
|
|
173
|
+
const path = `/${location.phase === "step" ? "steps" : "assertions"}/${location.index}`;
|
|
174
|
+
const recorded = entry?.target;
|
|
175
|
+
const target = !recorded || recorded.nameState ? undefined
|
|
176
|
+
: recorded.by === "label" ? { by: "label", label: recorded.name }
|
|
177
|
+
: recorded.role ? { by: "role", role: recorded.role, ...(recorded.name ? { name: recorded.name } : {}) } : undefined;
|
|
178
|
+
return { path, kind: location.phase, ...(location.phase === "step" ? { action: location.action } : {}), ...(target ? { target } : {}) };
|
|
179
|
+
}
|
|
180
|
+
/** Rounds a needed timeout up with headroom: 1.5 times the observed time, in whole half-seconds. */
|
|
181
|
+
export function suggestedTimeout(afterMs, currentMs) {
|
|
182
|
+
return Math.min(60_000, Math.max(currentMs + 500, Math.ceil((afterMs * 1.5) / 500) * 500));
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The suggested changes made applicable to the task file as written. RFC 6902 `replace` needs the member to
|
|
186
|
+
* exist and `add` needs its parent, so a change under a member the file leaves to its default (such as
|
|
187
|
+
* `/browser/timeoutMs` in a file without `browser`) becomes an `add` of the missing member.
|
|
188
|
+
*/
|
|
189
|
+
export function fitChanges(document, changes) {
|
|
190
|
+
const unescape = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
191
|
+
const escape = (segment) => segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
192
|
+
return changes.map((change) => {
|
|
193
|
+
const segments = change.path.split("/").slice(1).map(unescape);
|
|
194
|
+
let node = document;
|
|
195
|
+
let depth = 0;
|
|
196
|
+
for (const segment of segments) {
|
|
197
|
+
if (typeof node !== "object" || node === null || !Object.hasOwn(node, segment))
|
|
198
|
+
break;
|
|
199
|
+
node = node[segment];
|
|
200
|
+
depth++;
|
|
201
|
+
}
|
|
202
|
+
if (depth === segments.length)
|
|
203
|
+
return change;
|
|
204
|
+
if (depth === segments.length - 1)
|
|
205
|
+
return change.op === "add" ? change : { ...change, op: "add" };
|
|
206
|
+
let value = change.value;
|
|
207
|
+
for (let index = segments.length - 1; index > depth; index--)
|
|
208
|
+
value = { [segments[index]]: value };
|
|
209
|
+
return { ...change, op: "add", path: `/${segments.slice(0, depth + 1).map(escape).join("/")}`, value };
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** Guidance for a failure of a task. With the task file as written, its changes apply to that file as they stand. */
|
|
213
|
+
export function failureGuidance(task, failure, browser, document) {
|
|
214
|
+
const guidance = guidanceFor(taskOperation(task, failure), failure, browser, task.browser.timeoutMs);
|
|
215
|
+
return document === undefined ? guidance : { ...guidance, suggestedChanges: fitChanges(document, guidance.suggestedChanges) };
|
|
216
|
+
}
|
|
217
|
+
/** Guidance for an operation described by a task file or by a recorded run plan. */
|
|
218
|
+
export function guidanceFor(where, failure, browser, timeoutMs) {
|
|
219
|
+
const findings = [];
|
|
220
|
+
const suggestedChanges = [];
|
|
221
|
+
const { observation } = failure;
|
|
222
|
+
const target = where?.target;
|
|
223
|
+
if (observation.labelState === "detached" && target?.by === "label") {
|
|
224
|
+
findings.push({ pointsTo: "site", statement: `A <label> with the text ${quote(target.label)} is on the page but is not associated with any control (no matching for= and no nested control). The control lost its accessible label.` });
|
|
225
|
+
}
|
|
226
|
+
const otherRecords = [];
|
|
227
|
+
const cannotStandIn = [];
|
|
228
|
+
const messageKeys = [];
|
|
229
|
+
for (const match of observation.nearMatches ?? []) {
|
|
230
|
+
if (!where)
|
|
231
|
+
break;
|
|
232
|
+
// A similar name that differs by an identifier or a whole word may be another record: a fact, never a fix.
|
|
233
|
+
const requested = match.role === "option" ? undefined : target?.by === "role" ? target.name : target?.label;
|
|
234
|
+
// Names with the same letters (case, spacing or punctuation, or another role) are checked too: their digits can regroup.
|
|
235
|
+
if (match.relation !== "accessible-name-matches-label" && match.relation !== "visible-text-matches" && requested !== undefined &&
|
|
236
|
+
match.name !== requested && nameDifference(requested, match.name)) {
|
|
237
|
+
otherRecords.push(`${match.role} ${quote(match.name)}`);
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (match.role === "option" && where.action === "select" && where.optionBy === "label") {
|
|
241
|
+
suggestedChanges.push({ op: "replace", path: `${where.path}/option/label`, value: match.name,
|
|
242
|
+
because: `The control has the option ${quote(match.name)}, which ${relationText[match.relation]}.` });
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (!target)
|
|
246
|
+
continue;
|
|
247
|
+
if (requested !== undefined && messageKey(match.name) && !messageKey(requested)) {
|
|
248
|
+
messageKeys.push(`${match.role} ${quote(match.name)}`);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (!canStandIn(where, match.role)) {
|
|
252
|
+
cannotStandIn.push(`${match.role} ${quote(match.name)}`);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
const relation = match.relation === "same-name-other-role" && match.name !== requested
|
|
256
|
+
? "has a different role, and a name that differs only in case, spacing or punctuation" : relationText[match.relation];
|
|
257
|
+
const because = `The page has ${match.role} ${quote(match.name)}, which ${relation}.`;
|
|
258
|
+
if (target.by === "label") {
|
|
259
|
+
// Label targets only appear where role targets are also accepted, so the role and name can replace it.
|
|
260
|
+
suggestedChanges.push({ op: "replace", path: `${where.path}/target`, value: { by: "role", role: match.role, name: match.name }, because });
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (match.relation === "same-name-other-role") {
|
|
264
|
+
if (match.name === target.name)
|
|
265
|
+
suggestedChanges.push({ op: "replace", path: `${where.path}/target/role`, value: match.role, because });
|
|
266
|
+
else
|
|
267
|
+
suggestedChanges.push({ op: "replace", path: `${where.path}/target`, value: { by: "role", role: match.role, name: match.name }, because });
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
suggestedChanges.push({ op: "replace", path: `${where.path}/target/name`, value: match.name, because });
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (otherRecords.length) {
|
|
274
|
+
const one = otherRecords.length === 1;
|
|
275
|
+
findings.push({ pointsTo: "unclear", statement: `The page has ${otherRecords.join(", ")}, whose ${one ? "name differs" : "names differ"} from the requested one by an identifier or a whole word. ${one ? "It is" : "They are"} likely ${one ? "a different record" : "different records"}, so ${one ? "it is" : "they are"} not suggested.` });
|
|
276
|
+
}
|
|
277
|
+
if (messageKeys.length) {
|
|
278
|
+
const one = messageKeys.length === 1;
|
|
279
|
+
// A fact, not a direction: a file name or host name can have the same shape as a message key.
|
|
280
|
+
findings.push({ pointsTo: "unclear", statement: `The page has ${messageKeys.join(", ")}, ${one ? "a name" : "names"} shaped like an untranslated message key where a readable name is requested. If ${one ? "it is one" : "they are"}, the page is missing a translation, and changing the target to ${one ? "it" : "them"} would hide that, so ${one ? "it is" : "they are"} not suggested.` });
|
|
281
|
+
}
|
|
282
|
+
if (cannotStandIn.length) {
|
|
283
|
+
const one = cannotStandIn.length === 1;
|
|
284
|
+
const operation = where?.action && where.kind === "step" ? `a ${where.action}` : "the requested target";
|
|
285
|
+
findings.push({ pointsTo: "unclear", statement: `The page has ${cannotStandIn.join(", ")}, with a similar name, but ${one ? "its role cannot" : "their roles cannot"} stand in for ${operation}, so ${one ? "it is" : "they are"} not suggested.` });
|
|
286
|
+
}
|
|
287
|
+
if (suggestedChanges.length && !observation.labelState) {
|
|
288
|
+
findings.push({ pointsTo: "task", statement: "The page has a target close to the requested one. If the page's current naming is intended, the task's target is out of date; if not, the page changed." });
|
|
289
|
+
}
|
|
290
|
+
if (observation.nearMatchesRedacted && !observation.labelState) {
|
|
291
|
+
const one = observation.nearMatchesRedacted === 1;
|
|
292
|
+
findings.push({ pointsTo: "unclear", statement: `${observation.nearMatchesRedacted} similar ${one ? "target was" : "targets were"} on the page, but ${one ? "its name contains" : "their names contain"} a value the task types, so ${one ? "it is" : "they are"} not recorded, even with text capture.` });
|
|
293
|
+
}
|
|
294
|
+
if (observation.nearMatchesWithheld && !observation.labelState) {
|
|
295
|
+
// A fact, not a direction: the names that would say which way it points were not recorded.
|
|
296
|
+
findings.push({ pointsTo: "unclear", statement: `${observation.nearMatchesWithheld} similar ${observation.nearMatchesWithheld === 1 ? "target was" : "targets were"} on the page, but ${observation.nearMatchesWithheld === 1 ? "its name was" : "their names were"} withheld because input had been typed. A run with text capture lists them with typed values redacted.` });
|
|
297
|
+
}
|
|
298
|
+
const late = observation.lateCheck;
|
|
299
|
+
if (late?.outcome === "passed-later" && late.afterMs !== undefined) {
|
|
300
|
+
const timeout = observation.timeoutMs ?? timeoutMs ?? 5_000;
|
|
301
|
+
findings.push({ pointsTo: "task", statement: `The same check passed ${late.afterMs} ms after the operation started, later than the ${timeout} ms operation timeout. The page is slower than the timeout allows.` });
|
|
302
|
+
suggestedChanges.push({ op: "replace", path: "/browser/timeoutMs", value: suggestedTimeout(late.afterMs, timeout),
|
|
303
|
+
because: `The condition held after ${late.afterMs} ms.` });
|
|
304
|
+
}
|
|
305
|
+
else if (late?.outcome === "still-failing") {
|
|
306
|
+
findings.push({ pointsTo: "unclear", statement: `The same check still failed after a further ${late.windowMs} ms of observation without acting. A longer timeout alone is unlikely to fix this.` });
|
|
307
|
+
}
|
|
308
|
+
const blocked = browser?.blockedHosts ?? [];
|
|
309
|
+
if (blocked.length && failure.category !== "NAVIGATION_FAILURE") {
|
|
310
|
+
for (const { host } of blocked.slice(0, 3)) {
|
|
311
|
+
if (host.startsWith("["))
|
|
312
|
+
continue;
|
|
313
|
+
suggestedChanges.push({ op: "add", path: "/allowedHosts/-", value: host,
|
|
314
|
+
because: `The page requested ${quote(host)}, which is outside allowedHosts and was blocked. Add it only if the page needs it.` });
|
|
315
|
+
}
|
|
316
|
+
findings.push({ pointsTo: "unclear", statement: "The page requested hosts outside allowedHosts, and they were blocked. If the page needs them (scripts, styles, APIs), allowedHosts is incomplete." });
|
|
317
|
+
}
|
|
318
|
+
findings.push(...failedRequestFindings(browser?.failedRequests ?? []));
|
|
319
|
+
const alerts = observation.pageMessages?.filter((message) => message.role === "alert") ?? [];
|
|
320
|
+
if (alerts.length) {
|
|
321
|
+
const text = alerts.find((message) => message.text)?.text;
|
|
322
|
+
findings.push({ pointsTo: "unclear", statement: text ? `The page showed an alert at failure: ${quote(text)}.` : "The page showed an alert at failure (its text was not captured)." });
|
|
323
|
+
}
|
|
324
|
+
if (failure.category === "NAVIGATION_FAILURE" && observation.disallowedHost && !observation.disallowedHost.startsWith("[")) {
|
|
325
|
+
findings.push({ pointsTo: "unclear", statement: `The page navigated to ${quote(observation.disallowedHost)}, outside allowedHosts. Either the site redirects somewhere it should not, or allowedHosts is missing a host the flow legitimately uses.` });
|
|
326
|
+
}
|
|
327
|
+
// Keep the list short and free of duplicates; the first changes come from the most specific facts.
|
|
328
|
+
const seen = new Set();
|
|
329
|
+
const unique = suggestedChanges.filter((change) => {
|
|
330
|
+
const key = `${change.op} ${change.path} ${JSON.stringify(change.value)}`;
|
|
331
|
+
if (seen.has(key))
|
|
332
|
+
return false;
|
|
333
|
+
seen.add(key);
|
|
334
|
+
return true;
|
|
335
|
+
}).slice(0, 5);
|
|
336
|
+
// A site defect fact outranks every suggestion: no change is offered when evidence points to the site.
|
|
337
|
+
const siteDefect = findings.some((finding) => finding.pointsTo === "site");
|
|
338
|
+
return { ...(where ? { taskPath: where.path } : {}), findings, suggestedChanges: siteDefect ? [] : unique };
|
|
339
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./task.js";
|
|
2
|
+
export * from "./run.js";
|
|
3
|
+
export * from "./local.js";
|
|
4
|
+
export * from "./platform.js";
|
|
5
|
+
export * from "./agent.js";
|
|
6
|
+
export * from "./policy.js";
|
|
7
|
+
export * from "./outcomes.js";
|
|
8
|
+
export * from "./inspect.js";
|
|
9
|
+
export * from "./guidance.js";
|
|
10
|
+
export * from "./watch.js";
|
|
11
|
+
export * from "./playwright-live.js";
|
|
12
|
+
export * from "./task-issues.js";
|
|
13
|
+
export * from "./audit.js";
|
|
14
|
+
export * from "./ledger.js";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BLOCKED_HOST_LIMIT } from "./local.js";
|
|
3
|
+
import { allowedHostSchema, allowedUrl, httpUrl, semanticRoleSchema } from "./task.js";
|
|
4
|
+
/**
|
|
5
|
+
* `agentpath inspect` output, version 1. Every name and label is page-provided, untrusted text: control and
|
|
6
|
+
* format characters are removed and lengths and counts are bounded before it is reported.
|
|
7
|
+
*/
|
|
8
|
+
export const INSPECTION_VERSION = 1;
|
|
9
|
+
export const INSPECTION_LIMITS = { targets: 200, labels: 100, text: 160, allowedHosts: 50 };
|
|
10
|
+
export const inspectionRequestSchema = z.strictObject({
|
|
11
|
+
url: z.string().min(1).max(2048),
|
|
12
|
+
allowedHosts: z.array(allowedHostSchema).min(1).max(INSPECTION_LIMITS.allowedHosts),
|
|
13
|
+
}).superRefine((request, context) => {
|
|
14
|
+
const url = httpUrl(request.url);
|
|
15
|
+
if (!url)
|
|
16
|
+
context.addIssue({ code: "custom", path: ["url"], message: "Use an absolute HTTP(S) URL without credentials" });
|
|
17
|
+
else if (!allowedUrl(url, request.allowedHosts)) {
|
|
18
|
+
context.addIssue({ code: "custom", path: ["url"], message: `The URL host ${JSON.stringify(url.host)} is not an allowed host. Hosts match exactly, including any port: --allow ${url.host}` });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* How the exact locator AgentPath uses resolved the entry when it was confirmed:
|
|
23
|
+
* `unique` (one match, usable), `ambiguous` (several, a step would fail), `not-matched` (none, for example
|
|
24
|
+
* after control characters were removed from the name) or `unconfirmed` (the inspection deadline ran out first).
|
|
25
|
+
*/
|
|
26
|
+
export const inspectionMatchSchema = z.enum(["unique", "ambiguous", "not-matched", "unconfirmed"]);
|
|
27
|
+
const pageText = z.string().min(1).max(INSPECTION_LIMITS.text);
|
|
28
|
+
const count = z.int().min(0).max(1_000_000);
|
|
29
|
+
export const pageInspectionSchema = z.strictObject({
|
|
30
|
+
schemaVersion: z.literal(INSPECTION_VERSION),
|
|
31
|
+
/** The final page URL as origin and path. Query strings and fragments are never reported. */
|
|
32
|
+
url: z.string().max(4096),
|
|
33
|
+
/** Named elements with a role a task can target, in document order, one entry per role and name pair. */
|
|
34
|
+
targets: z.array(z.strictObject({
|
|
35
|
+
role: semanticRoleSchema,
|
|
36
|
+
name: pageText,
|
|
37
|
+
/** The accessible name was longer than the limit; `name` is its prefix and cannot be used verbatim. */
|
|
38
|
+
nameTruncated: z.literal(true).optional(),
|
|
39
|
+
match: inspectionMatchSchema,
|
|
40
|
+
matches: count.optional(),
|
|
41
|
+
})).max(INSPECTION_LIMITS.targets),
|
|
42
|
+
targetsTruncated: z.boolean(),
|
|
43
|
+
/** Elements with a targetable role and an empty accessible name. They cannot be targeted by name. */
|
|
44
|
+
unnamed: z.array(z.strictObject({
|
|
45
|
+
role: semanticRoleSchema,
|
|
46
|
+
count: count.min(1),
|
|
47
|
+
/** All elements with this role, named or not. A name-less wait or assertion target needs exactly one. */
|
|
48
|
+
roleMatches: count.optional(),
|
|
49
|
+
})).max(semanticRoleSchema.options.length),
|
|
50
|
+
/** Text that labels a form control, usable as `{ "by": "label" }` when its match is `unique`. */
|
|
51
|
+
labels: z.array(z.strictObject({
|
|
52
|
+
label: pageText,
|
|
53
|
+
labelTruncated: z.literal(true).optional(),
|
|
54
|
+
match: inspectionMatchSchema,
|
|
55
|
+
matches: count.optional(),
|
|
56
|
+
})).max(INSPECTION_LIMITS.labels),
|
|
57
|
+
labelsTruncated: z.boolean(),
|
|
58
|
+
/** Child frames on the page. Targets inside frames are neither listed nor searched by runs. */
|
|
59
|
+
embeddedFrames: count,
|
|
60
|
+
/** Hosts outside the allowlist whose requests were blocked, most requested first. */
|
|
61
|
+
blockedHosts: z.array(z.strictObject({ host: z.string().min(1).max(260), requests: z.int().min(1) })).max(BLOCKED_HOST_LIMIT),
|
|
62
|
+
blockedHostsTruncated: z.boolean(),
|
|
63
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const shortText = z.string().max(2000);
|
|
3
|
+
const sha = z.string().regex(/^[0-9a-f]{40,64}$/);
|
|
4
|
+
/** How a test is turned off: test.skip / test.fixme (not run) or test.fail (run, and passes only when it fails). */
|
|
5
|
+
export const disabledHowSchema = z.enum(["skip", "fixme", "fail"]);
|
|
6
|
+
/** One commit on the first-parent history, as far as the ledger reports it. Commit text is repository-provided. */
|
|
7
|
+
export const ledgerCommitSchema = z.strictObject({
|
|
8
|
+
commit: sha,
|
|
9
|
+
/** The committer date, ISO 8601, as git records it. */
|
|
10
|
+
date: z.string().max(64),
|
|
11
|
+
/** The first line of the commit message, control characters replaced. Untrusted. */
|
|
12
|
+
subject: shortText,
|
|
13
|
+
/** The commit's author is a bot account, or a co-author trailer names a bot or noreply address. */
|
|
14
|
+
automated: z.boolean(),
|
|
15
|
+
/** The commit message mentions flakiness ("flaky", "flake", "flakey", "flakiness"). */
|
|
16
|
+
saysFlaky: z.boolean(),
|
|
17
|
+
});
|
|
18
|
+
/** A test turned off at head. */
|
|
19
|
+
export const disabledTestSchema = z.strictObject({
|
|
20
|
+
path: shortText,
|
|
21
|
+
line: z.int().positive(),
|
|
22
|
+
title: z.array(shortText).min(1).max(64),
|
|
23
|
+
how: disabledHowSchema,
|
|
24
|
+
/** "group" when the modifier comes from an enclosing describe or a group-level call, not the test itself. */
|
|
25
|
+
scope: z.enum(["test", "group"]),
|
|
26
|
+
/** The commit that turned it off, when the history read shows one. */
|
|
27
|
+
since: ledgerCommitSchema.optional(),
|
|
28
|
+
/**
|
|
29
|
+
* `since` added the test already turned off: a new or copied file, a new test, or a renamed test whose body also
|
|
30
|
+
* changed. An earlier commit, not paired with this one, may have turned it off.
|
|
31
|
+
*/
|
|
32
|
+
appearedOff: z.boolean().optional(),
|
|
33
|
+
/** Days from `since` to the head commit, by committer dates. */
|
|
34
|
+
ageDays: z.int().min(0).optional(),
|
|
35
|
+
});
|
|
36
|
+
/** A test that was turned off and later turned back on, both inside the window. */
|
|
37
|
+
export const reenabledTestSchema = z.strictObject({
|
|
38
|
+
path: shortText,
|
|
39
|
+
title: z.array(shortText).min(1).max(64),
|
|
40
|
+
how: disabledHowSchema,
|
|
41
|
+
disabled: ledgerCommitSchema,
|
|
42
|
+
/** `disabled` added the test already turned off, so it may have been off before (see appearedOff). */
|
|
43
|
+
disabledAppeared: z.boolean().optional(),
|
|
44
|
+
enabled: ledgerCommitSchema,
|
|
45
|
+
days: z.int().min(0),
|
|
46
|
+
/** Files outside the test suite that the re-enabling commit changed: product code changed with the re-enable. */
|
|
47
|
+
productFiles: z.int().min(0),
|
|
48
|
+
});
|
|
49
|
+
export const ledgerReportSchema = z.strictObject({
|
|
50
|
+
schemaVersion: z.literal(1),
|
|
51
|
+
head: sha,
|
|
52
|
+
/** History events are reported from this date (ISO 8601) to the head commit's date. */
|
|
53
|
+
since: z.string().max(64),
|
|
54
|
+
/**
|
|
55
|
+
* The suite directories read, from each playwright.config.*'s literal testDir (or its directory). Empty when paths
|
|
56
|
+
* were given or the repository has no configuration: then every *.spec.* and *.test.* file in scope is read.
|
|
57
|
+
*/
|
|
58
|
+
suites: z.array(shortText).max(200),
|
|
59
|
+
disabled: z.array(disabledTestSchema).max(5000),
|
|
60
|
+
reenabled: z.array(reenabledTestSchema).max(5000),
|
|
61
|
+
/** Files or history the ledger could not read, with the reason. Untrusted paths. */
|
|
62
|
+
unreadable: z.array(z.strictObject({ path: shortText, reason: shortText })).max(5000),
|
|
63
|
+
totals: z.strictObject({
|
|
64
|
+
testFiles: z.int().min(0),
|
|
65
|
+
tests: z.int().min(0),
|
|
66
|
+
disabled: z.int().min(0),
|
|
67
|
+
/** Tests with a conditional skip or fixme (for example, a browser-specific skip). Counted, not listed. */
|
|
68
|
+
conditional: z.int().min(0),
|
|
69
|
+
/** Turning-off commits that say flaky, or come from a bot or agent. A commit that only added the test already off is not counted. */
|
|
70
|
+
disabledSaysFlaky: z.int().min(0),
|
|
71
|
+
disabledAutomated: z.int().min(0),
|
|
72
|
+
/** Disabled tests whose turning-off commit the history read does not show. */
|
|
73
|
+
disabledSinceUnknown: z.int().min(0),
|
|
74
|
+
/** Disabled tests whose `since` commit added them already turned off (`appearedOff`). Optional: reports written before it was added lack it. */
|
|
75
|
+
disabledAppearedOff: z.int().min(0).optional(),
|
|
76
|
+
reenabled: z.int().min(0),
|
|
77
|
+
reenabledWithProduct: z.int().min(0),
|
|
78
|
+
unreadable: z.int().min(0),
|
|
79
|
+
}),
|
|
80
|
+
});
|