@plune-ai/cairn 0.6.0 → 0.8.0
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/README.md +3 -1
- package/dist/agent/finalize.d.ts +4 -0
- package/dist/agent/finalize.d.ts.map +1 -1
- package/dist/agent/finalize.js +8 -1
- package/dist/agent/finalize.js.map +1 -1
- package/dist/agent/graph.d.ts +9 -0
- package/dist/agent/graph.d.ts.map +1 -1
- package/dist/agent/graph.js +9 -1
- package/dist/agent/graph.js.map +1 -1
- package/dist/agent/index.d.ts +9 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +93 -34
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/repair-loop.d.ts +17 -1
- package/dist/agent/repair-loop.d.ts.map +1 -1
- package/dist/agent/repair-loop.js +88 -5
- package/dist/agent/repair-loop.js.map +1 -1
- package/dist/agent/summary.d.ts +3 -0
- package/dist/agent/summary.d.ts.map +1 -1
- package/dist/agent/summary.js +5 -0
- package/dist/agent/summary.js.map +1 -1
- package/dist/api/cases.d.ts +4 -0
- package/dist/api/cases.d.ts.map +1 -1
- package/dist/api/cases.js.map +1 -1
- package/dist/artifacts/contract.d.ts +62 -0
- package/dist/artifacts/contract.d.ts.map +1 -0
- package/dist/artifacts/contract.js +58 -0
- package/dist/artifacts/contract.js.map +1 -0
- package/dist/artifacts/report.d.ts +9 -0
- package/dist/artifacts/report.d.ts.map +1 -1
- package/dist/artifacts/report.js +26 -0
- package/dist/artifacts/report.js.map +1 -1
- package/dist/artifacts/testcase-md.d.ts +2 -0
- package/dist/artifacts/testcase-md.d.ts.map +1 -1
- package/dist/artifacts/testcase-md.js +8 -1
- package/dist/artifacts/testcase-md.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +35 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +101 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/schema.d.ts +10 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +2 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/core/config.d.ts +7 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +4 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/modalities/api.d.ts.map +1 -1
- package/dist/core/modalities/api.js +10 -1
- package/dist/core/modalities/api.js.map +1 -1
- package/dist/core/modalities/explore.d.ts.map +1 -1
- package/dist/core/modalities/explore.js +7 -1
- package/dist/core/modalities/explore.js.map +1 -1
- package/dist/decider/capabilities.d.ts +15 -0
- package/dist/decider/capabilities.d.ts.map +1 -0
- package/dist/decider/capabilities.js +87 -0
- package/dist/decider/capabilities.js.map +1 -0
- package/dist/decider/client-http.d.ts +27 -0
- package/dist/decider/client-http.d.ts.map +1 -0
- package/dist/decider/client-http.js +134 -0
- package/dist/decider/client-http.js.map +1 -0
- package/dist/decider/guarded.d.ts +18 -0
- package/dist/decider/guarded.d.ts.map +1 -0
- package/dist/decider/guarded.js +48 -0
- package/dist/decider/guarded.js.map +1 -0
- package/dist/decider/index.d.ts +61 -0
- package/dist/decider/index.d.ts.map +1 -0
- package/dist/decider/index.js +191 -0
- package/dist/decider/index.js.map +1 -0
- package/dist/decider/redact.d.ts +6 -0
- package/dist/decider/redact.d.ts.map +1 -0
- package/dist/decider/redact.js +265 -0
- package/dist/decider/redact.js.map +1 -0
- package/dist/decider/types.d.ts +139 -0
- package/dist/decider/types.d.ts.map +1 -0
- package/dist/decider/types.js +21 -0
- package/dist/decider/types.js.map +1 -0
- package/dist/decider/uses/coverage.d.ts +37 -0
- package/dist/decider/uses/coverage.d.ts.map +1 -0
- package/dist/decider/uses/coverage.js +63 -0
- package/dist/decider/uses/coverage.js.map +1 -0
- package/dist/decider/uses/locator-heal.d.ts +69 -0
- package/dist/decider/uses/locator-heal.d.ts.map +1 -0
- package/dist/decider/uses/locator-heal.js +216 -0
- package/dist/decider/uses/locator-heal.js.map +1 -0
- package/dist/decider/uses/repair-triage.d.ts +40 -0
- package/dist/decider/uses/repair-triage.d.ts.map +1 -0
- package/dist/decider/uses/repair-triage.js +94 -0
- package/dist/decider/uses/repair-triage.js.map +1 -0
- package/dist/design/critique.d.ts.map +1 -1
- package/dist/design/critique.js +3 -0
- package/dist/design/critique.js.map +1 -1
- package/dist/design/index.d.ts.map +1 -1
- package/dist/design/index.js +4 -0
- package/dist/design/index.js.map +1 -1
- package/dist/design/schema.d.ts +3 -0
- package/dist/design/schema.d.ts.map +1 -1
- package/dist/design/schema.js.map +1 -1
- package/dist/eval/gap-cases.d.ts.map +1 -1
- package/dist/eval/gap-cases.js +2 -0
- package/dist/eval/gap-cases.js.map +1 -1
- package/dist/eval/judge.d.ts +12 -0
- package/dist/eval/judge.d.ts.map +1 -1
- package/dist/eval/judge.js +51 -0
- package/dist/eval/judge.js.map +1 -1
- package/dist/flow/crawl.d.ts +5 -0
- package/dist/flow/crawl.d.ts.map +1 -1
- package/dist/flow/crawl.js +0 -0
- package/dist/flow/crawl.js.map +1 -1
- package/dist/llm/cost.d.ts +2 -1
- package/dist/llm/cost.d.ts.map +1 -1
- package/dist/llm/cost.js +3 -2
- package/dist/llm/cost.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +2 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +8 -7
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +9 -2
- package/dist/mcp/tools.js.map +1 -1
- package/dist/telemetry/index.d.ts +23 -0
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +44 -1
- package/dist/telemetry/index.js.map +1 -1
- package/dist/tui/screens/summary-screen.d.ts.map +1 -1
- package/dist/tui/screens/summary-screen.js +10 -1
- package/dist/tui/screens/summary-screen.js.map +1 -1
- package/dist/validate/runner.d.ts.map +1 -1
- package/dist/validate/runner.js +19 -1
- package/dist/validate/runner.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* locator-heal (spec §6.6, ADR-0022), v1: after a test fails on a locator, propose a verified replacement in the
|
|
3
|
+
* repair hint. The generated spec stays plain `@playwright/test` — healing happens after the failure, never inside
|
|
4
|
+
* the code. Code reads the broken locator out of Playwright's error and narrows the page's elements to the ones a
|
|
5
|
+
* healer may offer — the same or a compatible role, never a destructive one; the decider only picks among them, and
|
|
6
|
+
* its pick counts only when the browser finds exactly one such element.
|
|
7
|
+
*/
|
|
8
|
+
import type { BrowserGateway } from "../../browser/gateway.js";
|
|
9
|
+
import type { ElementRef } from "../../browser/types.js";
|
|
10
|
+
import type { TestResult } from "../../validate/index.js";
|
|
11
|
+
import type { Decider } from "../types.js";
|
|
12
|
+
import type { TriageResult } from "./repair-triage.js";
|
|
13
|
+
export interface BrokenLocator {
|
|
14
|
+
role: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
/** The `getByRole(…)` text as the error printed it — what the repair hint tells the LLM to replace. */
|
|
17
|
+
source: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The locator a failing test waited for. Nothing to heal from a CSS locator, a regex name, or a chained scope
|
|
21
|
+
* (`getByRole('dialog').getByRole(…)`): a candidate from the whole page may sit outside the scope, and `verify`
|
|
22
|
+
* counts matches on the whole page. A trailing `.first()`, `.last()` or `.nth(i)` is kept out of `source`.
|
|
23
|
+
* Only the first locator in the error counts: a strict-mode violation goes on to list each element it resolved to,
|
|
24
|
+
* with an `aka getByRole(…)` hint that is not the locator that failed.
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseBrokenLocator(error: string): BrokenLocator | undefined;
|
|
27
|
+
export declare function compatibleRoles(role: string): ReadonlySet<string>;
|
|
28
|
+
/**
|
|
29
|
+
* The elements a healer may offer for a broken locator: interactive, named, of a compatible role, one per role and
|
|
30
|
+
* name. Never one the crawler would refuse to click (`DESTRUCTIVE`) or that reads as deleting data — safety rules
|
|
31
|
+
* are not optional (spec §3.5), so the decider is never even asked about them.
|
|
32
|
+
*/
|
|
33
|
+
export declare function healCandidates(aria: string, broken: BrokenLocator): ElementRef[];
|
|
34
|
+
/** The exact locator the repair hint proposes: `getByRole('button', { name: 'Save', exact: true })`. */
|
|
35
|
+
export declare function locatorText(el: {
|
|
36
|
+
role: string;
|
|
37
|
+
name: string;
|
|
38
|
+
}): string;
|
|
39
|
+
/** All a healer does with a browser: load the page, count matches. */
|
|
40
|
+
export type HealGateway = Pick<BrowserGateway, "observe" | "verify">;
|
|
41
|
+
/**
|
|
42
|
+
* A gateway opened on first use and closed with the run: `automate` has no browser of its own, and most runs never
|
|
43
|
+
* heal anything. A browser that fails to open fails that heal (a fallback), never the run's final `close`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function lazyGateway(open: () => Promise<BrowserGateway>): HealGateway & {
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
};
|
|
48
|
+
/** A proposal for the repair hint: the broken locator and a replacement verified to match one element. */
|
|
49
|
+
export interface HealRecord {
|
|
50
|
+
test: string;
|
|
51
|
+
/** The broken `getByRole(…)`, as the error printed it. */
|
|
52
|
+
from: string;
|
|
53
|
+
to: string;
|
|
54
|
+
confidence: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The healer (spec §6.6). Candidates come from the page as it loads now, not as it was when the test failed: a
|
|
58
|
+
* locator reachable only mid-scenario finds no candidate, or none the decider picks, and goes to repair as today.
|
|
59
|
+
* No verdict, no parse, the cli backend, no candidate, a doubt, a pick that does not match exactly one element, or
|
|
60
|
+
* any failure → undefined, and repair runs as it would have without a decider. Shadow mode asks and verifies,
|
|
61
|
+
* records, and proposes nothing.
|
|
62
|
+
*/
|
|
63
|
+
export declare function makeHeal(opts: {
|
|
64
|
+
decider: Decider;
|
|
65
|
+
/** The lib backend's. The cli one counts no matches (`count -1`), so there a heal asks nothing. */
|
|
66
|
+
gateway: HealGateway;
|
|
67
|
+
url: string;
|
|
68
|
+
}): (failure: TestResult, triage: TriageResult) => Promise<HealRecord | undefined>;
|
|
69
|
+
//# sourceMappingURL=locator-heal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locator-heal.d.ts","sourceRoot":"","sources":["../../../src/decider/uses/locator-heal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,OAAO,EAAY,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAExE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uGAAuG;IACvG,MAAM,EAAE,MAAM,CAAC;CAChB;AAYD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAQ3E;AASD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,UAAU,EAAE,CAYhF;AAID,wGAAwG;AACxG,wBAAgB,WAAW,CAAC,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEtE;AAED,sEAAsE;AACtE,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;AAErE;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,GAAG,WAAW,GAAG;IAAE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAazG;AAED,0GAA0G;AAC1G,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAqBD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,mGAAmG;IACnG,OAAO,EAAE,WAAW,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmHjF"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { DESTRUCTIVE } from "../../flow/crawl.js";
|
|
2
|
+
import { parseAriaSnapshot } from "../../observe/parse-aria.js";
|
|
3
|
+
import { isDeletionIntent } from "../../safety/guardrails.js";
|
|
4
|
+
import { checkCaps } from "../capabilities.js";
|
|
5
|
+
/** `getByRole('role')` or `getByRole('role', { name: 'Name'[, exact: true] })`, with ' or " quotes. */
|
|
6
|
+
const GET_BY_ROLE = /getByRole\((['"])([a-z]+)\1(?:,\s*\{\s*name:\s*(['"])((?:\\.|(?!\3)[^\\\n])*)\3(?:,\s*exact:\s*(?:true|false))?\s*\})?\)/;
|
|
7
|
+
/** Playwright colours its output; the codes are not part of what it says. */
|
|
8
|
+
const plain = (error) => error.replace(/\u001b\[[0-9;]*m/g, "");
|
|
9
|
+
/** A locator expression. The first one in an error is the one that failed. */
|
|
10
|
+
const ANY_LOCATOR = /\b(?:getBy[A-Z]\w*|locator|frameLocator)\(/;
|
|
11
|
+
/**
|
|
12
|
+
* The locator a failing test waited for. Nothing to heal from a CSS locator, a regex name, or a chained scope
|
|
13
|
+
* (`getByRole('dialog').getByRole(…)`): a candidate from the whole page may sit outside the scope, and `verify`
|
|
14
|
+
* counts matches on the whole page. A trailing `.first()`, `.last()` or `.nth(i)` is kept out of `source`.
|
|
15
|
+
* Only the first locator in the error counts: a strict-mode violation goes on to list each element it resolved to,
|
|
16
|
+
* with an `aka getByRole(…)` hint that is not the locator that failed.
|
|
17
|
+
*/
|
|
18
|
+
export function parseBrokenLocator(error) {
|
|
19
|
+
const text = plain(error);
|
|
20
|
+
const m = GET_BY_ROLE.exec(text);
|
|
21
|
+
if (!m || ANY_LOCATOR.exec(text)?.index !== m.index)
|
|
22
|
+
return undefined;
|
|
23
|
+
const after = text.slice(m.index + m[0].length);
|
|
24
|
+
if (/^\.(?!first\(\)|last\(\)|nth\()/.test(after))
|
|
25
|
+
return undefined; // a scope before it is a first locator already
|
|
26
|
+
const name = m[4]?.replace(/\\(.)/g, "$1");
|
|
27
|
+
return { role: m[2], ...(name !== undefined ? { name } : {}), source: m[0] };
|
|
28
|
+
}
|
|
29
|
+
/** Roles one element can be swapped for without changing what the step does. */
|
|
30
|
+
const ROLE_FAMILIES = [
|
|
31
|
+
["textbox", "searchbox", "combobox"],
|
|
32
|
+
["checkbox", "switch"],
|
|
33
|
+
["menuitem", "menuitemcheckbox", "menuitemradio"],
|
|
34
|
+
];
|
|
35
|
+
export function compatibleRoles(role) {
|
|
36
|
+
return new Set(ROLE_FAMILIES.find((f) => f.includes(role)) ?? [role]);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The elements a healer may offer for a broken locator: interactive, named, of a compatible role, one per role and
|
|
40
|
+
* name. Never one the crawler would refuse to click (`DESTRUCTIVE`) or that reads as deleting data — safety rules
|
|
41
|
+
* are not optional (spec §3.5), so the decider is never even asked about them.
|
|
42
|
+
*/
|
|
43
|
+
export function healCandidates(aria, broken) {
|
|
44
|
+
const roles = compatibleRoles(broken.role);
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
return parseAriaSnapshot(aria).filter((e) => {
|
|
47
|
+
const name = e.name?.trim();
|
|
48
|
+
if (!e.interactive || !name || !roles.has(e.role))
|
|
49
|
+
return false;
|
|
50
|
+
if (DESTRUCTIVE.test(name) || isDeletionIntent(name))
|
|
51
|
+
return false;
|
|
52
|
+
const key = `${e.role}\n${name}`;
|
|
53
|
+
if (seen.has(key))
|
|
54
|
+
return false;
|
|
55
|
+
seen.add(key);
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const quote = (s) => `'${s.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
60
|
+
/** The exact locator the repair hint proposes: `getByRole('button', { name: 'Save', exact: true })`. */
|
|
61
|
+
export function locatorText(el) {
|
|
62
|
+
return `getByRole(${quote(el.role)}, { name: ${quote(el.name)}, exact: true })`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A gateway opened on first use and closed with the run: `automate` has no browser of its own, and most runs never
|
|
66
|
+
* heal anything. A browser that fails to open fails that heal (a fallback), never the run's final `close`.
|
|
67
|
+
*/
|
|
68
|
+
export function lazyGateway(open) {
|
|
69
|
+
let gw;
|
|
70
|
+
const get = () => (gw ??= open());
|
|
71
|
+
return {
|
|
72
|
+
observe: async (o) => (await get()).observe(o),
|
|
73
|
+
verify: async (els) => (await get()).verify(els),
|
|
74
|
+
close: async () => {
|
|
75
|
+
await gw?.then((g) => g.close(), () => undefined);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Only what triage called a locator failure is healed (spec §6.6 step 1). */
|
|
80
|
+
const HEALABLE = new Set(["locator-missing", "locator-ambiguous"]);
|
|
81
|
+
const NONE = "none-of-these";
|
|
82
|
+
const PICK_INSTRUCTIONS = "Which element on the page did the failing locator mean?";
|
|
83
|
+
const SCORE_LEVELS = ["Unrelated to the failing step", "Plausible", "Clearly the element the step meant"];
|
|
84
|
+
/** The failure in one line. With a question of at most 400 chars (laya) it stays inside every provider's input cap. */
|
|
85
|
+
const MAX_STATE_CHARS = 500;
|
|
86
|
+
/** The two-stage path (spec §6.6, laya): at most the ten best-scored candidates go into the final choice. */
|
|
87
|
+
const MAX_FINALISTS = 10;
|
|
88
|
+
const clip = (s, n) => (s.length <= n ? s : `${s.slice(0, n - 1)}…`);
|
|
89
|
+
/**
|
|
90
|
+
* The healer (spec §6.6). Candidates come from the page as it loads now, not as it was when the test failed: a
|
|
91
|
+
* locator reachable only mid-scenario finds no candidate, or none the decider picks, and goes to repair as today.
|
|
92
|
+
* No verdict, no parse, the cli backend, no candidate, a doubt, a pick that does not match exactly one element, or
|
|
93
|
+
* any failure → undefined, and repair runs as it would have without a decider. Shadow mode asks and verifies,
|
|
94
|
+
* records, and proposes nothing.
|
|
95
|
+
*/
|
|
96
|
+
export function makeHeal(opts) {
|
|
97
|
+
const { decider, gateway, url } = opts;
|
|
98
|
+
const { caps } = decider;
|
|
99
|
+
// ponytail: room for labels up to "c999: " — a page with more candidates would still be refused whole, by checkCaps.
|
|
100
|
+
const room = caps.maxOptionChars - 6;
|
|
101
|
+
const choice = (offered) => ({
|
|
102
|
+
type: "choice",
|
|
103
|
+
instructions: PICK_INSTRUCTIONS,
|
|
104
|
+
options: { ...Object.fromEntries(offered.map((o) => [o.label, o.text])), [NONE]: "the element it meant is not in this list" },
|
|
105
|
+
});
|
|
106
|
+
const fits = (state, q) => {
|
|
107
|
+
try {
|
|
108
|
+
checkCaps(caps, state, { pick: q });
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
/** Too many candidates for one choice: score each, in calls of at most `maxQuestionsPerCall`, keep the best that fit. */
|
|
116
|
+
const shortlist = async (state, offered) => {
|
|
117
|
+
const score = new Map();
|
|
118
|
+
for (let i = 0; i < offered.length; i += caps.maxQuestionsPerCall) {
|
|
119
|
+
const chunk = offered.slice(i, i + caps.maxQuestionsPerCall);
|
|
120
|
+
const questions = Object.fromEntries(chunk.map((o) => [
|
|
121
|
+
o.label,
|
|
122
|
+
{ type: "score", instructions: `How well does ${o.text} match the element the failing locator meant?`, levels: SCORE_LEVELS },
|
|
123
|
+
]));
|
|
124
|
+
const answers = await decider.decide("locator-heal", state, questions);
|
|
125
|
+
for (const o of chunk) {
|
|
126
|
+
const a = answers[o.label];
|
|
127
|
+
if (a?.type === "score")
|
|
128
|
+
score.set(o.label, a.value);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const ranked = [...offered].sort((a, b) => (score.get(b.label) ?? -1) - (score.get(a.label) ?? -1)); // stable: ties keep page order
|
|
132
|
+
const finalists = [];
|
|
133
|
+
for (const o of ranked) {
|
|
134
|
+
if (finalists.length === MAX_FINALISTS || !fits(state, choice([...finalists, o])))
|
|
135
|
+
break;
|
|
136
|
+
finalists.push(o);
|
|
137
|
+
}
|
|
138
|
+
return finalists;
|
|
139
|
+
};
|
|
140
|
+
/** One broken locator, asked about for the first test that failed on it. */
|
|
141
|
+
const heal = async (failure, ambiguous, broken) => {
|
|
142
|
+
const input = { state: "", candidates: [] };
|
|
143
|
+
// The decider's time alone, as the other use points record it: opening the page and the check are not in it.
|
|
144
|
+
let asked = 0;
|
|
145
|
+
let answered = 0;
|
|
146
|
+
// A no-op for an active decider, so every path below returns through it.
|
|
147
|
+
const record = (d, confidence) => {
|
|
148
|
+
decider.shadow?.record({
|
|
149
|
+
use: "locator-heal",
|
|
150
|
+
input,
|
|
151
|
+
current: "repair",
|
|
152
|
+
decider: d,
|
|
153
|
+
...(confidence !== undefined ? { confidence } : {}),
|
|
154
|
+
latencyMs: asked ? (answered || Date.now()) - asked : 0,
|
|
155
|
+
});
|
|
156
|
+
return undefined;
|
|
157
|
+
};
|
|
158
|
+
try {
|
|
159
|
+
const what = ambiguous ? "matched several elements" : "matched no element";
|
|
160
|
+
// The locator first: a clip cuts the tail, and a long test name must not cut what the decider picks by.
|
|
161
|
+
input.state = clip(decider.scrub(`Locator ${broken.source} ${what} in Playwright test "${failure.test}".`), MAX_STATE_CHARS);
|
|
162
|
+
const { ariaSnapshot, capturedBy } = await gateway.observe({ url });
|
|
163
|
+
if (capturedBy !== "lib")
|
|
164
|
+
return undefined; // the cli backend counts no matches: no pick could be checked
|
|
165
|
+
const offered = healCandidates(ariaSnapshot, broken).map((el, i) => ({ el, label: `c${i + 1}`, text: clip(decider.scrub(`${el.role} "${el.name}"`), room) }));
|
|
166
|
+
if (offered.length === 0)
|
|
167
|
+
return undefined; // nothing to ask about
|
|
168
|
+
input.candidates = offered.map((o) => o.text);
|
|
169
|
+
asked = Date.now();
|
|
170
|
+
const finalists = fits(input.state, choice(offered)) ? offered : await shortlist(input.state, offered);
|
|
171
|
+
const a = (await decider.decide("locator-heal", input.state, { pick: choice(finalists) })).pick;
|
|
172
|
+
answered = Date.now();
|
|
173
|
+
if (a?.type !== "choice")
|
|
174
|
+
throw new Error("an answer of the wrong type");
|
|
175
|
+
if (a.value === NONE)
|
|
176
|
+
return record({ to: null, confidence: a.confidence }, a.confidence);
|
|
177
|
+
const chosen = finalists.find((o) => o.label === a.value);
|
|
178
|
+
if (!chosen)
|
|
179
|
+
throw new Error(`an answer outside the offered candidates: '${a.value}'`); // never trust an unoffered label
|
|
180
|
+
if (!decider.shadow && a.confidence < decider.minConfidence)
|
|
181
|
+
return undefined;
|
|
182
|
+
const [v] = await gateway.verify([chosen.el]);
|
|
183
|
+
const to = locatorText({ role: chosen.el.role, name: chosen.el.name ?? "" });
|
|
184
|
+
if (decider.shadow)
|
|
185
|
+
return record({ to, confidence: a.confidence, verified: v?.count === 1 }, a.confidence);
|
|
186
|
+
return v?.count === 1 ? { to, confidence: a.confidence } : undefined;
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
return record({ unavailable: e instanceof Error ? e.message : String(e) });
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
// A named element that went missing (renamed, say) is the same element for every test that asked for it, so those
|
|
193
|
+
// tests share one heal: one question, check and answer (a renamed login button can fail every test). Which of
|
|
194
|
+
// several matches a test meant, or which unnamed element, depends on the test: asked per test.
|
|
195
|
+
// ponytail: a single heal still costs ceil(candidates / maxQuestionsPerCall) + 1 calls on a page too big for one
|
|
196
|
+
// choice; DECIDER_MAX_CALLS bounds the run, cap the candidates if pilots meet such pages.
|
|
197
|
+
const heals = new Map();
|
|
198
|
+
return async (failure, triage) => {
|
|
199
|
+
if (!HEALABLE.has(triage.category))
|
|
200
|
+
return undefined;
|
|
201
|
+
const broken = parseBrokenLocator(failure.error ?? "");
|
|
202
|
+
if (!broken)
|
|
203
|
+
return undefined;
|
|
204
|
+
// Several matches or none is what Playwright's error says, not what triage (a model) called it — a wrong verdict
|
|
205
|
+
// must not make a heal shared. The key is what the question is built from.
|
|
206
|
+
const ambiguous = /strict mode violation/.test(plain(failure.error ?? ""));
|
|
207
|
+
const shared = !ambiguous && broken.name !== undefined;
|
|
208
|
+
const key = `${ambiguous}\n${broken.source}${shared ? "" : `\n${failure.test}`}`;
|
|
209
|
+
let proposal = heals.get(key);
|
|
210
|
+
if (!proposal)
|
|
211
|
+
heals.set(key, (proposal = heal(failure, ambiguous, broken)));
|
|
212
|
+
const p = await proposal;
|
|
213
|
+
return p && { test: failure.test, from: broken.source, ...p };
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=locator-heal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locator-heal.js","sourceRoot":"","sources":["../../../src/decider/uses/locator-heal.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAW/C,uGAAuG;AACvG,MAAM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OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAChE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { TestResult } from "../../validate/index.js";
|
|
2
|
+
import type { Decider, Question } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* repair-triage (spec §6.1, ADR-0022): why did a generated test fail? A confident "the app is broken" or
|
|
5
|
+
* "the environment is broken" keeps the test out of the repair hint — repairing test code cannot fix
|
|
6
|
+
* either — and the run reports it instead. Every other confident category only tags the hint.
|
|
7
|
+
*/
|
|
8
|
+
export type FailureCategory = "locator-ambiguous" | "locator-missing" | "timing" | "wrong-assertion" | "app-bug" | "env-or-session";
|
|
9
|
+
/**
|
|
10
|
+
* label → when it applies. Sent as the choice's criteria: the descriptions are what the model decides by.
|
|
11
|
+
* Short on purpose — the whole question must fit laya's 400-character question cap (capabilities.ts). A
|
|
12
|
+
* "wrong result" belongs to wrong-assertion only: when it is unclear whose fault it is, repair it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const FAILURE_CATEGORIES: Record<FailureCategory, string>;
|
|
15
|
+
export declare const TRIAGE_QUESTION: Question;
|
|
16
|
+
export interface TriageResult {
|
|
17
|
+
test: string;
|
|
18
|
+
category: FailureCategory;
|
|
19
|
+
confidence: number;
|
|
20
|
+
/** true → left out of the repair hint and reported as not repaired. */
|
|
21
|
+
exclude: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The test's name and its error, colour codes stripped, scrubbed, THEN clipped to fit `maxChars` whole — clipping
|
|
25
|
+
* first could cut a secret in half, and the half left would no longer match what the scrubber looks for.
|
|
26
|
+
*/
|
|
27
|
+
export declare function triageState(r: TestResult, maxChars: number, scrub: (text: string) => string): string;
|
|
28
|
+
/**
|
|
29
|
+
* One call per failed test, each over its own state, run concurrently (a hanging server costs one timeout,
|
|
30
|
+
* not one per test; the per-run ceiling still holds). Only a confident answer counts; a failure or a doubt
|
|
31
|
+
* leaves the test in the hint exactly as today. Shadow mode records each answer next to "repair" and
|
|
32
|
+
* returns nothing — so the loop runs as it would have without a decider.
|
|
33
|
+
*
|
|
34
|
+
* `next` — shadow mode only: the use point that acts on triage's verdict (locator-heal). Returning nothing,
|
|
35
|
+
* triage leaves the loop no verdict to hand on, so it asks `next` itself on every verdict it would have given,
|
|
36
|
+
* at any confidence (the pilot calibrates the threshold), one at a time (they share one browser page). An
|
|
37
|
+
* active loop asks `next` itself.
|
|
38
|
+
*/
|
|
39
|
+
export declare function makeTriage(decider: Decider, next?: (failure: TestResult, verdict: TriageResult) => Promise<unknown>): (failed: TestResult[]) => Promise<TriageResult[]>;
|
|
40
|
+
//# sourceMappingURL=repair-triage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair-triage.d.ts","sourceRoot":"","sources":["../../../src/decider/uses/repair-triage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAU,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,QAAQ,GAAG,iBAAiB,GAAG,SAAS,GAAG,gBAAgB,CAAC;AAEpI;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAO9D,CAAC;AAQF,eAAO,MAAM,eAAe,EAAE,QAI7B,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAKpG;AAgBD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,GACtE,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,OAAO,CAAC,YAAY,EAAE,CAAC,CA6CnD"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { questionChars } from "../capabilities.js";
|
|
2
|
+
/**
|
|
3
|
+
* label → when it applies. Sent as the choice's criteria: the descriptions are what the model decides by.
|
|
4
|
+
* Short on purpose — the whole question must fit laya's 400-character question cap (capabilities.ts). A
|
|
5
|
+
* "wrong result" belongs to wrong-assertion only: when it is unclear whose fault it is, repair it.
|
|
6
|
+
*/
|
|
7
|
+
export const FAILURE_CATEGORIES = {
|
|
8
|
+
"locator-ambiguous": "locator matched several elements (strict mode)",
|
|
9
|
+
"locator-missing": "locator found no element, or it was hidden",
|
|
10
|
+
timing: "page not ready yet: navigation, data, animation",
|
|
11
|
+
"wrong-assertion": "page worked, but a different result was expected",
|
|
12
|
+
"app-bug": "the app failed: server error, crash, error page",
|
|
13
|
+
"env-or-session": "environment failed: session expired, server unreachable",
|
|
14
|
+
};
|
|
15
|
+
/** Categories a confident answer keeps out of repair — the only direction a decider may push (ADR-0020). */
|
|
16
|
+
const NOT_REPAIRABLE = new Set(["app-bug", "env-or-session"]);
|
|
17
|
+
/** Playwright's own call log follows the cause; beyond this the tokens buy nothing (and cost money on jev). */
|
|
18
|
+
const MAX_STATE_CHARS = 2000;
|
|
19
|
+
export const TRIAGE_QUESTION = {
|
|
20
|
+
type: "choice",
|
|
21
|
+
instructions: "Why did this Playwright test fail?",
|
|
22
|
+
options: FAILURE_CATEGORIES,
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The test's name and its error, colour codes stripped, scrubbed, THEN clipped to fit `maxChars` whole — clipping
|
|
26
|
+
* first could cut a secret in half, and the half left would no longer match what the scrubber looks for.
|
|
27
|
+
*/
|
|
28
|
+
export function triageState(r, maxChars, scrub) {
|
|
29
|
+
const head = `Playwright test "${r.test}" failed.\nError:\n`;
|
|
30
|
+
const error = (r.error ?? "(no error message)").replace(/\u001b\[[0-9;]*m/g, "").trim();
|
|
31
|
+
const full = scrub(head + error);
|
|
32
|
+
return full.length <= maxChars ? full : `${full.slice(0, maxChars - 1)}…`;
|
|
33
|
+
}
|
|
34
|
+
function asCategory(a) {
|
|
35
|
+
if (a?.type !== "choice" || !Object.hasOwn(FAILURE_CATEGORIES, a.value))
|
|
36
|
+
return undefined; // never trust an unoffered label
|
|
37
|
+
return { category: a.value, confidence: a.confidence };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One call per failed test, each over its own state, run concurrently (a hanging server costs one timeout,
|
|
41
|
+
* not one per test; the per-run ceiling still holds). Only a confident answer counts; a failure or a doubt
|
|
42
|
+
* leaves the test in the hint exactly as today. Shadow mode records each answer next to "repair" and
|
|
43
|
+
* returns nothing — so the loop runs as it would have without a decider.
|
|
44
|
+
*
|
|
45
|
+
* `next` — shadow mode only: the use point that acts on triage's verdict (locator-heal). Returning nothing,
|
|
46
|
+
* triage leaves the loop no verdict to hand on, so it asks `next` itself on every verdict it would have given,
|
|
47
|
+
* at any confidence (the pilot calibrates the threshold), one at a time (they share one browser page). An
|
|
48
|
+
* active loop asks `next` itself.
|
|
49
|
+
*/
|
|
50
|
+
export function makeTriage(decider, next) {
|
|
51
|
+
// The provider reads the state together with the question: the error gets what the question leaves.
|
|
52
|
+
const maxChars = Math.min(decider.caps.maxInputChars - questionChars(TRIAGE_QUESTION), MAX_STATE_CHARS);
|
|
53
|
+
return async (failed) => {
|
|
54
|
+
const asked = await Promise.all(failed.map(async (r) => {
|
|
55
|
+
const t0 = Date.now();
|
|
56
|
+
let state = "";
|
|
57
|
+
try {
|
|
58
|
+
state = triageState(r, maxChars, decider.scrub); // inside the try: a scrubbing failure is a fallback
|
|
59
|
+
const answers = await decider.decide("repair-triage", state, { cause: TRIAGE_QUESTION });
|
|
60
|
+
const c = asCategory(answers.cause);
|
|
61
|
+
return { r, state, latencyMs: Date.now() - t0, ...(c ? { c } : { reason: "an answer outside the offered categories" }) };
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
return { r, state, latencyMs: Date.now() - t0, reason: e instanceof Error ? e.message : String(e) };
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
const confident = (c) => c.confidence >= decider.minConfidence;
|
|
68
|
+
if (decider.shadow) {
|
|
69
|
+
for (const a of asked) {
|
|
70
|
+
decider.shadow.record({
|
|
71
|
+
use: "repair-triage",
|
|
72
|
+
input: a.state,
|
|
73
|
+
current: "repair",
|
|
74
|
+
decider: a.c
|
|
75
|
+
? { category: a.c.category, confidence: a.c.confidence, wouldExclude: confident(a.c) && NOT_REPAIRABLE.has(a.c.category) }
|
|
76
|
+
: { unavailable: a.reason },
|
|
77
|
+
...(a.c ? { confidence: a.c.confidence } : {}),
|
|
78
|
+
latencyMs: a.latencyMs,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
for (const a of asked) {
|
|
82
|
+
if (!a.c || !next)
|
|
83
|
+
continue;
|
|
84
|
+
const verdict = { test: a.r.test, ...a.c, exclude: confident(a.c) && NOT_REPAIRABLE.has(a.c.category) };
|
|
85
|
+
await next(a.r, verdict).catch(() => undefined); // shadow bookkeeping never throws into the run
|
|
86
|
+
}
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
return asked.flatMap((a) => a.c && confident(a.c)
|
|
90
|
+
? [{ test: a.r.test, category: a.c.category, confidence: a.c.confidence, exclude: NOT_REPAIRABLE.has(a.c.category) }]
|
|
91
|
+
: []);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# source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,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC;IAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CAAC,CAkDtD"}
|
package/dist/design/critique.js
CHANGED
|
@@ -2,6 +2,7 @@ import { HumanMessage } from "@langchain/core/messages";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { DesignedCaseSchema, TestTechniqueSchema } from "./schema.js";
|
|
4
4
|
import { dedupCases } from "./dedup.js";
|
|
5
|
+
import { designedCaseStableId } from "../artifacts/contract.js";
|
|
5
6
|
/** The 6 × ISO/IEC/IEEE 29119-4 techniques (single source: the schema enum). */
|
|
6
7
|
const ALL_TECHNIQUES = TestTechniqueSchema.options;
|
|
7
8
|
/** What the worker returns: which cases to drop + which new cases to add. */
|
|
@@ -38,6 +39,8 @@ export async function critiqueCases(input, deps) {
|
|
|
38
39
|
const toppedUpCases = result.add.map((c) => ({
|
|
39
40
|
...c,
|
|
40
41
|
id: "tc-pending",
|
|
42
|
+
// The re-id below rewrites `id`; identity must be minted here, from the case's own substance.
|
|
43
|
+
stableId: designedCaseStableId(c),
|
|
41
44
|
elementRefs: c.elementRefs.filter((r) => known.has(r)),
|
|
42
45
|
}));
|
|
43
46
|
// Re-id + re-dedup the combined set, mirroring designTestCases' tail (one source of truth for dedup).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"critique.js","sourceRoot":"","sources":["../../src/design/critique.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAiB,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"critique.js","sourceRoot":"","sources":["../../src/design/critique.ts"],"names":[],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c,CAAC,MAAM;YAC9D,eAAe;SAChB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/design/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/design/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIhE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6GAA6G;IAC7G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,yDAAyD;IACzD,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAqC/F"}
|
package/dist/design/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { HumanMessage } from "@langchain/core/messages";
|
|
|
2
2
|
import { formatTransitions } from "../probe/index.js";
|
|
3
3
|
import { DesignResultSchema } from "./schema.js";
|
|
4
4
|
import { dedupCases } from "./dedup.js";
|
|
5
|
+
import { designedCaseStableId } from "../artifacts/contract.js";
|
|
5
6
|
export { DesignedCaseSchema, DesignResultSchema, TestTechniqueSchema, TestPrioritySchema, } from "./schema.js";
|
|
6
7
|
/**
|
|
7
8
|
* Generate test cases from the page using the ISO 29119-4 methodology.
|
|
@@ -31,6 +32,9 @@ export async function designTestCases(input, deps) {
|
|
|
31
32
|
const grounded = result.testCases.map((c, i) => ({
|
|
32
33
|
...c,
|
|
33
34
|
id: `tc-${i + 1}`,
|
|
35
|
+
// Substance, not position: the same case keeps this id across runs even when the run designs a
|
|
36
|
+
// different number of cases and `id` shifts under it.
|
|
37
|
+
stableId: designedCaseStableId(c),
|
|
34
38
|
elementRefs: c.elementRefs.filter((r) => known.has(r)),
|
|
35
39
|
}));
|
|
36
40
|
return dedupCases(grounded).merged; // #58: merge high-confidence near-duplicates (reduced count is the report)
|
package/dist/design/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/design/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKxD,OAAO,EAAE,iBAAiB,EAAmB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAiB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/design/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKxD,OAAO,EAAE,iBAAiB,EAAmB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAiB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AA4BrB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,KAAkB,EAAE,IAAgB;IACxE,MAAM,WAAW,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC,CAAC,IAAI,CAAC;IACnF,MAAM,GAAG,GACP,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC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;IAEtF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/C,GAAG,CAAC;QACJ,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE;QACjB,+FAA+F;QAC/F,sDAAsD;QACtD,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC;QACjC,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACvD,CAAC,CAAC,CAAC;IACJ,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,2EAA2E;AACjH,CAAC"}
|
package/dist/design/schema.d.ts
CHANGED
|
@@ -104,7 +104,10 @@ export declare const DesignResultSchema: z.ZodObject<{
|
|
|
104
104
|
}, z.core.$strip>;
|
|
105
105
|
/** Final test case with an assigned id. */
|
|
106
106
|
export interface TestCase extends DesignedCase {
|
|
107
|
+
/** Position WITHIN this run (`tc-1`, `tc-2`, …) — it moves when the run designs a different set. */
|
|
107
108
|
id: string;
|
|
109
|
+
/** Content-derived identity, stable ACROSS runs — see `artifacts/contract.ts`. Dedup on this one. */
|
|
110
|
+
stableId: string;
|
|
108
111
|
}
|
|
109
112
|
/**
|
|
110
113
|
* One step of a multi-page journey (#59): which page it runs on, the action, and the element refs it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/design/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,uCAAuC;AACvC,eAAO,MAAM,mBAAmB;;;;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,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"gap-cases.d.ts","sourceRoot":"","sources":["../../src/eval/gap-cases.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,IAAI,EAAE,WAAW,EAAE,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAoBhG"}
|
package/dist/eval/gap-cases.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HumanMessage } from "@langchain/core/messages";
|
|
2
2
|
import { DesignResultSchema } from "../design/schema.js";
|
|
3
|
+
import { designedCaseStableId } from "../artifacts/contract.js";
|
|
3
4
|
/**
|
|
4
5
|
* #61 — suggest test cases for the top untested surface (worker tier). Returned cases are clearly
|
|
5
6
|
* marked as SUGGESTIONS via a `gap-` id prefix and grounded to the gap refs (anti-hallucination).
|
|
@@ -21,6 +22,7 @@ export async function designGapCases(input, deps) {
|
|
|
21
22
|
return result.testCases.map((c, i) => ({
|
|
22
23
|
...c,
|
|
23
24
|
id: `gap-${i + 1}`,
|
|
25
|
+
stableId: designedCaseStableId(c),
|
|
24
26
|
elementRefs: c.elementRefs.filter((r) => known.has(r)),
|
|
25
27
|
}));
|
|
26
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gap-cases.js","sourceRoot":"","sources":["../../src/eval/gap-cases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAiB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"gap-cases.js","sourceRoot":"","sources":["../../src/eval/gap-cases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAiB,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAchE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAAmB,EAAE,IAAiB;IACzE,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI;SACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,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