@decocms/parity 0.35.33 → 0.35.34
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/AGENTS.md +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/cli.js +245 -16
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -163,7 +163,7 @@ Hard caps already in place:
|
|
|
163
163
|
- **A page that was never captured (status 0) is not a status divergence.** `http-status-parity` files one inconclusive `http-status:not-captured:<page>` finding, the run gets a `cand-pages-not-captured` (or `prod-…`) caveat listing the paths, and the check is `warn`. A real 404/500 stays critical. Re-run against a warm server before reading the score.
|
|
164
164
|
- **`[hydration]` console errors are React's own hydration messages only.** A section that threw and was caught by an error boundary is `[section-crash]` (same severity); its `file:line` positions come from the candidate's build at capture time and may be stale against the working tree.
|
|
165
165
|
- **`Issue.page` is the `path::viewport` key**, never a URL; the URL is in `details`.
|
|
166
|
-
- **A local dev candidate (`--cand http://localhost:…`) is cold on its first request to each route.** A run started right after the server came up, or after adding routes, can time out on pages the server would answer in milliseconds once requested. `parity run` primes the candidate's pages one at a time and retries a never-answered capture once; if it still prints "warm-up/priming loads never answered" or a `cand-cold` caveat, the server was not ready: request the routes yourself (or wait) and re-run, and do not read the "status divergente: cand=0" findings as defects. Flows' own PLP/PDP navigations are not primed. `--no-prime-cand` turns priming off.
|
|
166
|
+
- **A local dev candidate (`--cand http://localhost:…`) is cold on its first request to each route.** A run started right after the server came up, or after adding routes, can time out on pages the server would answer in milliseconds once requested. `parity run` primes the candidate's pages one at a time and retries a never-answered capture once; if it still prints "warm-up/priming loads never answered" or a `cand-cold` caveat, the server was not ready: request the routes yourself (or wait) and re-run, and do not read the "status divergente: cand=0" findings as defects. A server can also go bad DURING the run (a dev server's loader de-duplication wedges after aborted requests): `parity run` re-requests the primed URLs after the passes and, when they or several captures show a collapsed document / no answer / a new 5xx, adds a `cand-degraded` caveat and marks the captures with their own evidence `candDegraded`; `runAllChecks` withholds those pairs from every check (`withHealthyCand`) as inconclusive. Do not read pages missing sections or a "section crashed" console error from such a run as defects: restart the server and re-run. A check's own fetch probes against a local URL must not use a short timeout (use `probeTimeoutMs`): the abort is what wedges it. Flows' own PLP/PDP navigations are not primed (so cannot be judged degraded). `--no-prime-cand` turns priming off.
|
|
167
167
|
- **`parity run` doesn't apply schema changes from old runs** — if you change `src/types/schema.ts`, old `report.json` files won't parse. Delete `parity-output/` or re-run.
|
|
168
168
|
|
|
169
169
|
## Files agents should and should not write
|
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
* **`parity run` notices a local candidate that degrades mid-run.** Priming records each URL's
|
|
13
|
+
status, document bytes and time; after the passes the same URLs are re-requested once, in order,
|
|
14
|
+
and compared (tolerances in `TOLERANCES.candHealth`). When the server is found degraded, a
|
|
15
|
+
`cand-degraded` run caveat names the URLs with before/after numbers, one summary line is printed,
|
|
16
|
+
`report.json.candHealth` records it, and every candidate capture that carries its own evidence
|
|
17
|
+
(`PageCapture.candDegraded`, also in recordings) is withheld from all checks as `inconclusive`
|
|
18
|
+
(`withHealthyCand`, applied in `runAllChecks`, so `parity replay` agrees). Captures without such
|
|
19
|
+
evidence are judged live, and a consistent 404/500 is never treated as degradation. A local
|
|
20
|
+
candidate also gets 2 simultaneous capture contexts in the extra-vitals and visual passes (prod
|
|
21
|
+
keeps 4), and the link/SSR probes of `nav-links-health`, `footer-links-health`, `ssr-no-js`,
|
|
22
|
+
`favicon-parity`, `plp-sorting` and `plp-pagination` wait 60s on a local URL instead of aborting
|
|
23
|
+
after 8-15s, since an aborted request is what wedges a dev server's loader de-duplication.
|
|
24
|
+
|
|
12
25
|
* **`first-viewport-ssr` check (html module)** answers "is what the user sees in the first viewport
|
|
13
26
|
already in the server response, or does it arrive later?". A deferred header (a skeleton in the
|
|
14
27
|
server HTML that client JS fills in) passed `ssr-no-js` (the rest of the page carried the text)
|
package/dist/cli.js
CHANGED
|
@@ -76806,6 +76806,38 @@ var TOLERANCES = {
|
|
|
76806
76806
|
note: "A page-height difference at or above this is `high`: a block of content is missing or extra."
|
|
76807
76807
|
}
|
|
76808
76808
|
},
|
|
76809
|
+
candHealth: {
|
|
76810
|
+
bytesCollapseRatio: {
|
|
76811
|
+
value: 0.25,
|
|
76812
|
+
unit: "ratio (0-1) of the primed document bytes",
|
|
76813
|
+
basis: "assumed",
|
|
76814
|
+
note: "A local candidate's document smaller than this share of what the same URL weighed at priming is a degraded answer (a wedged dev server returned 245 KB for a ~1.9 MB page, 13%). Deliberately far below 1: mobile and desktop SSR, A/B copy and a different cart state move a document by tens of percent, not by 4x."
|
|
76815
|
+
},
|
|
76816
|
+
slowRatio: {
|
|
76817
|
+
value: 5,
|
|
76818
|
+
unit: "x primed response time",
|
|
76819
|
+
basis: "assumed",
|
|
76820
|
+
note: "A re-request this many times slower than the priming load counts as slow, subject to slowFloorMs. The priming load is the cold compile, so a warm server is expected to be FASTER than it; slower by this much is not jitter."
|
|
76821
|
+
},
|
|
76822
|
+
slowFloorMs: {
|
|
76823
|
+
value: 5000,
|
|
76824
|
+
unit: "ms",
|
|
76825
|
+
basis: "assumed",
|
|
76826
|
+
note: "A response under this is never slow, whatever the ratio: 20 ms to 150 ms is 7x and means nothing."
|
|
76827
|
+
},
|
|
76828
|
+
slowMinUrls: {
|
|
76829
|
+
value: 2,
|
|
76830
|
+
unit: "count",
|
|
76831
|
+
basis: "assumed",
|
|
76832
|
+
note: "Slowness alone needs this many URLs to agree before the candidate is called degraded; one slow request is a GC pause, a compile or a busy machine. Hard evidence (no answer, a 5xx the prime did not see, collapsed bytes) is enough on one URL."
|
|
76833
|
+
},
|
|
76834
|
+
collapsedCapturesMin: {
|
|
76835
|
+
value: 2,
|
|
76836
|
+
unit: "count",
|
|
76837
|
+
basis: "assumed",
|
|
76838
|
+
note: "Without a failing re-request, this many captures with a collapsed document is what it takes to call the run degraded from the captures alone (the server may have recovered by the end of the run)."
|
|
76839
|
+
}
|
|
76840
|
+
},
|
|
76809
76841
|
clickProbe: {
|
|
76810
76842
|
gridCols: {
|
|
76811
76843
|
value: 5,
|
|
@@ -79020,6 +79052,14 @@ function hasDialogLikeMarkup(page) {
|
|
|
79020
79052
|
|
|
79021
79053
|
// src/checks/favicon-parity.ts
|
|
79022
79054
|
init_esm10();
|
|
79055
|
+
|
|
79056
|
+
// src/checks/lib/probe-timeout.ts
|
|
79057
|
+
var LOCAL_PROBE_TIMEOUT_MS = 60000;
|
|
79058
|
+
function probeTimeoutMs(url, remoteMs) {
|
|
79059
|
+
return isLocalhost(url) ? Math.max(remoteMs, LOCAL_PROBE_TIMEOUT_MS) : remoteMs;
|
|
79060
|
+
}
|
|
79061
|
+
|
|
79062
|
+
// src/checks/favicon-parity.ts
|
|
79023
79063
|
async function faviconParity(ctx) {
|
|
79024
79064
|
const start = Date.now();
|
|
79025
79065
|
const issues = [];
|
|
@@ -79098,7 +79138,7 @@ async function hashUrl(href, base) {
|
|
|
79098
79138
|
return null;
|
|
79099
79139
|
}
|
|
79100
79140
|
try {
|
|
79101
|
-
const res = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(8000) });
|
|
79141
|
+
const res = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(probeTimeoutMs(url, 8000)) });
|
|
79102
79142
|
if (!res.ok)
|
|
79103
79143
|
return null;
|
|
79104
79144
|
const buf = await res.arrayBuffer();
|
|
@@ -79398,7 +79438,7 @@ async function probeLinks(urls) {
|
|
|
79398
79438
|
const res = await fetch(url, {
|
|
79399
79439
|
method: "HEAD",
|
|
79400
79440
|
redirect: "follow",
|
|
79401
|
-
signal: AbortSignal.timeout(8000)
|
|
79441
|
+
signal: AbortSignal.timeout(probeTimeoutMs(url, 8000))
|
|
79402
79442
|
});
|
|
79403
79443
|
return { url, status: res.status, durationMs: Date.now() - t };
|
|
79404
79444
|
} catch {
|
|
@@ -79949,6 +79989,39 @@ function extractSectionIds(entries) {
|
|
|
79949
79989
|
return out;
|
|
79950
79990
|
}
|
|
79951
79991
|
|
|
79992
|
+
// src/checks/lib/cand-degraded.ts
|
|
79993
|
+
function withHealthyCand(check) {
|
|
79994
|
+
const guarded = async (ctx) => {
|
|
79995
|
+
const bad = new Map;
|
|
79996
|
+
for (const p of ctx.candPages)
|
|
79997
|
+
if (p.candDegraded)
|
|
79998
|
+
bad.set(captureKey(p), p);
|
|
79999
|
+
if (bad.size === 0)
|
|
80000
|
+
return check(ctx);
|
|
80001
|
+
const keep = (pages) => pages.filter((p) => !bad.has(captureKey(p)));
|
|
80002
|
+
const result = await check({ ...ctx, prodPages: keep(ctx.prodPages), candPages: keep(ctx.candPages) });
|
|
80003
|
+
const issues = [...bad].map(([key, page]) => ({
|
|
80004
|
+
id: `${result.name}:cand-degraded:${key}`,
|
|
80005
|
+
severity: "low",
|
|
80006
|
+
inconclusive: true,
|
|
80007
|
+
category: "functional",
|
|
80008
|
+
page: key,
|
|
80009
|
+
check: result.name,
|
|
80010
|
+
summary: `${key}: captured while the candidate was degraded; re-run against a warm/healthy server — not compared by ${result.name}`,
|
|
80011
|
+
details: `The local candidate server degraded during this run (${page.candDegraded}). A page captured in that state is truncated, so judging it reports the server's condition as the site's. Not a finding about the page.`
|
|
80012
|
+
}));
|
|
80013
|
+
const pairKeys = new Set(pairCaptures(ctx.prodPages, ctx.candPages).pairs.map((p) => p.key));
|
|
80014
|
+
const withheld = [...bad.keys()].filter((k) => pairKeys.has(k)).length;
|
|
80015
|
+
return addWithheld({
|
|
80016
|
+
...result,
|
|
80017
|
+
status: result.status === "pass" ? "warn" : result.status,
|
|
80018
|
+
issues: [...result.issues, ...issues]
|
|
80019
|
+
}, withheld);
|
|
80020
|
+
};
|
|
80021
|
+
Object.defineProperty(guarded, "name", { value: check.name });
|
|
80022
|
+
return guarded;
|
|
80023
|
+
}
|
|
80024
|
+
|
|
79952
80025
|
// src/checks/lib/html-snapshot.ts
|
|
79953
80026
|
function htmlUnread(page) {
|
|
79954
80027
|
return page.htmlSnapshotFailed === true || !page.html;
|
|
@@ -80409,7 +80482,7 @@ async function probeRoutes(links, base) {
|
|
|
80409
80482
|
const res = await fetch(url, {
|
|
80410
80483
|
method: "HEAD",
|
|
80411
80484
|
redirect: "follow",
|
|
80412
|
-
signal: AbortSignal.timeout(8000)
|
|
80485
|
+
signal: AbortSignal.timeout(probeTimeoutMs(url, 8000))
|
|
80413
80486
|
});
|
|
80414
80487
|
return { path, status: res.status };
|
|
80415
80488
|
} catch {
|
|
@@ -81726,7 +81799,7 @@ async function fetchPlpProducts(url) {
|
|
|
81726
81799
|
headers: {
|
|
81727
81800
|
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1"
|
|
81728
81801
|
},
|
|
81729
|
-
signal: AbortSignal.timeout(15000)
|
|
81802
|
+
signal: AbortSignal.timeout(probeTimeoutMs(url, 15000))
|
|
81730
81803
|
});
|
|
81731
81804
|
if (res.status !== 200) {
|
|
81732
81805
|
return { status: res.status, productPaths: [] };
|
|
@@ -81806,7 +81879,7 @@ async function discoverPlpFromHome(homeUrl) {
|
|
|
81806
81879
|
headers: {
|
|
81807
81880
|
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1"
|
|
81808
81881
|
},
|
|
81809
|
-
signal: AbortSignal.timeout(15000)
|
|
81882
|
+
signal: AbortSignal.timeout(probeTimeoutMs(homeUrl, 15000))
|
|
81810
81883
|
});
|
|
81811
81884
|
if (!res.ok)
|
|
81812
81885
|
return null;
|
|
@@ -81979,7 +82052,7 @@ async function fetchOrderedHrefs(url) {
|
|
|
81979
82052
|
headers: {
|
|
81980
82053
|
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1"
|
|
81981
82054
|
},
|
|
81982
|
-
signal: AbortSignal.timeout(15000)
|
|
82055
|
+
signal: AbortSignal.timeout(probeTimeoutMs(url, 15000))
|
|
81983
82056
|
});
|
|
81984
82057
|
if (res.status !== 200)
|
|
81985
82058
|
return { status: res.status, hrefs: [] };
|
|
@@ -83566,7 +83639,7 @@ async function ssrNoJs(ctx) {
|
|
|
83566
83639
|
}
|
|
83567
83640
|
async function fetchSsrText(url) {
|
|
83568
83641
|
try {
|
|
83569
|
-
const res = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(15000) });
|
|
83642
|
+
const res = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(probeTimeoutMs(url, 15000)) });
|
|
83570
83643
|
if (!res.ok)
|
|
83571
83644
|
return null;
|
|
83572
83645
|
const html = await res.text();
|
|
@@ -91148,7 +91221,7 @@ async function runAllChecks(ctx, outResults, checkFilter) {
|
|
|
91148
91221
|
await Promise.all(checksToRun.map(async (check, i) => {
|
|
91149
91222
|
const start = Date.now();
|
|
91150
91223
|
try {
|
|
91151
|
-
const r = await check(ctx);
|
|
91224
|
+
const r = await withHealthyCand(check)(ctx);
|
|
91152
91225
|
push({ ...r, durationMs: r.durationMs || Date.now() - start }, i);
|
|
91153
91226
|
} catch (err) {
|
|
91154
91227
|
push({
|
|
@@ -91491,6 +91564,7 @@ var PageCapture = z2.object({
|
|
|
91491
91564
|
pass: z2.enum(["extra", "visual"]).optional(),
|
|
91492
91565
|
variant: VariantFingerprint.optional(),
|
|
91493
91566
|
retried: z2.boolean().optional(),
|
|
91567
|
+
candDegraded: z2.string().optional(),
|
|
91494
91568
|
clickProbe: ClickProbe.optional(),
|
|
91495
91569
|
firstViewport: FirstViewportProbe.optional()
|
|
91496
91570
|
});
|
|
@@ -91845,6 +91919,17 @@ var Run = z2.object({
|
|
|
91845
91919
|
partial: z2.boolean().optional(),
|
|
91846
91920
|
partialReason: z2.string().optional(),
|
|
91847
91921
|
caveats: z2.array(RunCaveat).optional(),
|
|
91922
|
+
candHealth: z2.object({
|
|
91923
|
+
degraded: z2.boolean(),
|
|
91924
|
+
baselined: z2.number(),
|
|
91925
|
+
captures: z2.number(),
|
|
91926
|
+
evidence: z2.array(z2.object({
|
|
91927
|
+
url: z2.string(),
|
|
91928
|
+
kind: z2.enum(["no-answer", "server-error", "bytes-collapsed", "slow"]),
|
|
91929
|
+
before: z2.object({ status: z2.number(), bytes: z2.number().nullable(), ms: z2.number() }),
|
|
91930
|
+
after: z2.object({ status: z2.number(), bytes: z2.number().nullable(), ms: z2.number() })
|
|
91931
|
+
}))
|
|
91932
|
+
}).optional(),
|
|
91848
91933
|
pinned: z2.object({
|
|
91849
91934
|
prod: z2.object({ cookies: z2.array(z2.string()), headers: z2.array(z2.string()) }),
|
|
91850
91935
|
cand: z2.object({ cookies: z2.array(z2.string()), headers: z2.array(z2.string()) })
|
|
@@ -119480,7 +119565,7 @@ async function primeSequentially(urls, primed, prime) {
|
|
|
119480
119565
|
}
|
|
119481
119566
|
return { attempted: urls.length, failed, totalMs: Date.now() - start };
|
|
119482
119567
|
}
|
|
119483
|
-
async function primeCandUrls(browser, urls, primed, ctxOpts) {
|
|
119568
|
+
async function primeCandUrls(browser, urls, primed, ctxOpts, baselines) {
|
|
119484
119569
|
if (urls.length === 0)
|
|
119485
119570
|
return { attempted: 0, failed: [], totalMs: 0 };
|
|
119486
119571
|
const ctx = await newContext(browser, { cohortCookieValue: "control", ...ctxOpts });
|
|
@@ -119488,7 +119573,12 @@ async function primeCandUrls(browser, urls, primed, ctxOpts) {
|
|
|
119488
119573
|
return await primeSequentially(urls, primed, async (url) => {
|
|
119489
119574
|
const page = await ctx.newPage();
|
|
119490
119575
|
try {
|
|
119491
|
-
|
|
119576
|
+
const t = Date.now();
|
|
119577
|
+
const res = await page.goto(url, { waitUntil: "domcontentloaded", timeout: PRIME_TIMEOUT_MS });
|
|
119578
|
+
if (baselines && res) {
|
|
119579
|
+
const bytes = await res.body().then((b) => b.byteLength, () => null);
|
|
119580
|
+
baselines.set(url, { url, status: res.status(), bytes, ms: Date.now() - t });
|
|
119581
|
+
}
|
|
119492
119582
|
await page.waitForLoadState("load", { timeout: PRIME_LOAD_MS }).catch(() => {
|
|
119493
119583
|
return;
|
|
119494
119584
|
});
|
|
@@ -119546,6 +119636,17 @@ function detectRunCaveats(input) {
|
|
|
119546
119636
|
detail: "Pages that did not answer are missing from this run or were measured cold, so counts, vitals and status findings of the affected routes are not a fair comparison. Wait for the candidate to finish starting, or request each route once, then re-run."
|
|
119547
119637
|
});
|
|
119548
119638
|
}
|
|
119639
|
+
if (input.candHealth?.degraded) {
|
|
119640
|
+
const h = input.candHealth;
|
|
119641
|
+
const kb = (n) => n === null ? "?" : `${Math.round(n / 1024)} KB`;
|
|
119642
|
+
const what = (e) => `${e.url} (${kb(e.before.bytes)} / ${e.before.status} / ${Math.round(e.before.ms)} ms at priming, ${kb(e.after.bytes)} / ${e.after.status} / ${Math.round(e.after.ms)} ms after the passes)`;
|
|
119643
|
+
out.push({
|
|
119644
|
+
id: "cand-degraded",
|
|
119645
|
+
level: "warn",
|
|
119646
|
+
summary: `The candidate server degraded during the run — ${h.captures} capture(s) were withheld as inconclusive`,
|
|
119647
|
+
detail: `A local dev server can wedge mid-run (aborted requests leave loaders that never settle), after which pages come back truncated. ${h.captures} candidate capture(s) carrying their own evidence of it (document collapsed against the priming baseline, no answer after a good prime, a 5xx priming did not see) were not judged by any check; the score does not include them, so it is optimistic by exactly those pages. Captures without that evidence were judged normally. Restart the server and re-run (or use a production build). Re-request after the passes: ${h.evidence.length > 0 ? h.evidence.map(what).join("; ") : "answered like at priming (the degradation was seen in the captures)"}.`
|
|
119648
|
+
});
|
|
119649
|
+
}
|
|
119549
119650
|
if (isLocalhost(input.prodUrl)) {
|
|
119550
119651
|
out.push({
|
|
119551
119652
|
id: "prod-dev-server",
|
|
@@ -119697,6 +119798,113 @@ function describePin(pin) {
|
|
|
119697
119798
|
].join(", ");
|
|
119698
119799
|
}
|
|
119699
119800
|
|
|
119801
|
+
// src/engine/cand-health.ts
|
|
119802
|
+
var T2 = TOLERANCES.candHealth;
|
|
119803
|
+
function judgeProbe(before, after) {
|
|
119804
|
+
if (before.status === 0)
|
|
119805
|
+
return null;
|
|
119806
|
+
if (after.status === 0)
|
|
119807
|
+
return "no-answer";
|
|
119808
|
+
if (after.status >= 500 && before.status < 500)
|
|
119809
|
+
return "server-error";
|
|
119810
|
+
if (after.status !== before.status && after.status >= 400 && before.status < 400) {
|
|
119811
|
+
return "server-error";
|
|
119812
|
+
}
|
|
119813
|
+
if (before.bytes !== null && after.bytes !== null && before.bytes > 0 && after.bytes < before.bytes * T2.bytesCollapseRatio.value) {
|
|
119814
|
+
return "bytes-collapsed";
|
|
119815
|
+
}
|
|
119816
|
+
if (after.ms >= Math.max(before.ms * T2.slowRatio.value, T2.slowFloorMs.value))
|
|
119817
|
+
return "slow";
|
|
119818
|
+
return null;
|
|
119819
|
+
}
|
|
119820
|
+
function judgeRecheck(baselines, after) {
|
|
119821
|
+
const evidence = [];
|
|
119822
|
+
for (const [url, before] of baselines) {
|
|
119823
|
+
const now = after.get(url);
|
|
119824
|
+
if (!now)
|
|
119825
|
+
continue;
|
|
119826
|
+
const kind = judgeProbe(before, now);
|
|
119827
|
+
if (kind)
|
|
119828
|
+
evidence.push({ url, kind, before, after: now });
|
|
119829
|
+
}
|
|
119830
|
+
const hard = evidence.some((e) => e.kind !== "slow");
|
|
119831
|
+
const slow = evidence.filter((e) => e.kind === "slow").length;
|
|
119832
|
+
return { degraded: hard || slow >= T2.slowMinUrls.value, evidence };
|
|
119833
|
+
}
|
|
119834
|
+
function documentEntry(cap) {
|
|
119835
|
+
const docs = cap.network.filter((n) => n.resourceType === "document" && n.method === "GET");
|
|
119836
|
+
return docs.find((n) => n.url === cap.url || n.url === cap.finalUrl) ?? docs[0];
|
|
119837
|
+
}
|
|
119838
|
+
function captureDegradation(cap, baselines) {
|
|
119839
|
+
if (cap.side !== "cand")
|
|
119840
|
+
return null;
|
|
119841
|
+
const before = baselines.get(cap.url);
|
|
119842
|
+
if (!before || before.status === 0)
|
|
119843
|
+
return null;
|
|
119844
|
+
if (cap.status === 0) {
|
|
119845
|
+
return { kind: "no-answer", text: `no answer (the priming load answered ${before.status})` };
|
|
119846
|
+
}
|
|
119847
|
+
const doc = documentEntry(cap);
|
|
119848
|
+
const kind = judgeProbe(before, {
|
|
119849
|
+
status: cap.status,
|
|
119850
|
+
bytes: doc?.bytes ?? null,
|
|
119851
|
+
ms: doc?.durationMs ?? 0
|
|
119852
|
+
});
|
|
119853
|
+
if (!kind)
|
|
119854
|
+
return null;
|
|
119855
|
+
const kb = (n) => n === null ? "?" : `${Math.round(n / 1024)} KB`;
|
|
119856
|
+
const text = kind === "bytes-collapsed" ? `document ${kb(doc?.bytes ?? null)} against ${kb(before.bytes)} at priming` : kind === "slow" ? `document took ${Math.round((doc?.durationMs ?? 0) / 1000)}s against ${Math.round(before.ms / 1000)}s at priming` : `answered ${cap.status} where priming got ${before.status}`;
|
|
119857
|
+
return { kind, text };
|
|
119858
|
+
}
|
|
119859
|
+
function markDegradedCaptures(candPages, baselines, recheck) {
|
|
119860
|
+
if (baselines.size === 0)
|
|
119861
|
+
return { degraded: false, marked: 0 };
|
|
119862
|
+
const own = candPages.map((cap) => ({ cap, d: captureDegradation(cap, baselines) }));
|
|
119863
|
+
const collapsed = own.filter((o) => o.d?.kind === "bytes-collapsed").length;
|
|
119864
|
+
const degraded = recheck.degraded || collapsed >= T2.collapsedCapturesMin.value;
|
|
119865
|
+
if (!degraded)
|
|
119866
|
+
return { degraded: false, marked: 0 };
|
|
119867
|
+
let marked = 0;
|
|
119868
|
+
for (const { cap, d } of own) {
|
|
119869
|
+
if (!d)
|
|
119870
|
+
continue;
|
|
119871
|
+
cap.candDegraded = d.text;
|
|
119872
|
+
marked++;
|
|
119873
|
+
}
|
|
119874
|
+
return { degraded: true, marked };
|
|
119875
|
+
}
|
|
119876
|
+
async function recheckCand(urls, opts = {}) {
|
|
119877
|
+
const out = new Map;
|
|
119878
|
+
for (const url of urls) {
|
|
119879
|
+
const t = Date.now();
|
|
119880
|
+
try {
|
|
119881
|
+
const res = await fetch(url, {
|
|
119882
|
+
redirect: "follow",
|
|
119883
|
+
headers: opts.headers,
|
|
119884
|
+
signal: AbortSignal.timeout(opts.timeoutMs ?? 90000)
|
|
119885
|
+
});
|
|
119886
|
+
const body = await res.arrayBuffer();
|
|
119887
|
+
out.set(url, { status: res.status, bytes: body.byteLength, ms: Date.now() - t });
|
|
119888
|
+
} catch {
|
|
119889
|
+
out.set(url, { status: 0, bytes: null, ms: Date.now() - t });
|
|
119890
|
+
}
|
|
119891
|
+
}
|
|
119892
|
+
return out;
|
|
119893
|
+
}
|
|
119894
|
+
function buildCandHealthReport(baselines, recheck, marking) {
|
|
119895
|
+
return {
|
|
119896
|
+
degraded: marking.degraded,
|
|
119897
|
+
baselined: baselines.size,
|
|
119898
|
+
captures: marking.marked,
|
|
119899
|
+
evidence: recheck.evidence.map((e) => ({
|
|
119900
|
+
url: e.url,
|
|
119901
|
+
kind: e.kind,
|
|
119902
|
+
before: { status: e.before.status, bytes: e.before.bytes, ms: e.before.ms },
|
|
119903
|
+
after: e.after
|
|
119904
|
+
}))
|
|
119905
|
+
};
|
|
119906
|
+
}
|
|
119907
|
+
|
|
119700
119908
|
// src/util/timing.ts
|
|
119701
119909
|
async function withTiming(fn) {
|
|
119702
119910
|
const start = performance.now();
|
|
@@ -120271,6 +120479,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
120271
120479
|
}
|
|
120272
120480
|
const primeEnabled = opts.primeCand !== false && isLocalhost(opts.cand);
|
|
120273
120481
|
const primed = new Set;
|
|
120482
|
+
const candBaselines = new Map;
|
|
120274
120483
|
const primeAcc = { attempted: 0, failed: [], totalMs: 0 };
|
|
120275
120484
|
const candRetry = { retried: 0, recovered: 0 };
|
|
120276
120485
|
const retrying = new Set;
|
|
@@ -120297,7 +120506,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
120297
120506
|
viewport: viewports[0],
|
|
120298
120507
|
cookies: pins.cand.cookies,
|
|
120299
120508
|
headers: pins.cand.headers
|
|
120300
|
-
});
|
|
120509
|
+
}, candBaselines);
|
|
120301
120510
|
primeAcc.attempted += r.attempted;
|
|
120302
120511
|
primeAcc.failed.push(...r.failed);
|
|
120303
120512
|
primeAcc.totalMs += r.totalMs;
|
|
@@ -120600,7 +120809,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
120600
120809
|
extraSpinner.text = `[vitals extras] ${done}/${tasks.length} (último: ${task.path})`;
|
|
120601
120810
|
}
|
|
120602
120811
|
};
|
|
120603
|
-
await
|
|
120812
|
+
await runCapturePool(tasks, opts.cand, runTask);
|
|
120604
120813
|
await retryColdCand("extra", tasks, runTask);
|
|
120605
120814
|
vitalsHb.stop();
|
|
120606
120815
|
extraSpinner.succeed(`+${extraPaths.length} página(s) com vitals`);
|
|
@@ -120697,7 +120906,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
120697
120906
|
visualSpinner.text = `[visual] ${done}/${tasks.length} (último: ${task.path})`;
|
|
120698
120907
|
}
|
|
120699
120908
|
};
|
|
120700
|
-
await
|
|
120909
|
+
await runCapturePool(tasks, opts.cand, runTask);
|
|
120701
120910
|
await retryColdCand("visual", tasks, runTask);
|
|
120702
120911
|
visualHb.stop();
|
|
120703
120912
|
visualSpinner.succeed(`Visual diff: ${tasks.length} screenshot(s) capturado(s)`);
|
|
@@ -120749,6 +120958,15 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
120749
120958
|
viewports,
|
|
120750
120959
|
candIsProduction: opts.candIsProduction
|
|
120751
120960
|
};
|
|
120961
|
+
let candHealth;
|
|
120962
|
+
if (primeEnabled && candBaselines.size > 0) {
|
|
120963
|
+
const recheck = judgeRecheck(candBaselines, await recheckCand([...candBaselines.keys()], { headers: pinFetchHeaders(pins.cand) }));
|
|
120964
|
+
const marking = markDegradedCaptures(checkCtx.candPages, candBaselines, recheck);
|
|
120965
|
+
candHealth = buildCandHealthReport(candBaselines, recheck, marking);
|
|
120966
|
+
if (marking.degraded) {
|
|
120967
|
+
console.log(chalk34.yellow(` ! the candidate server degraded during the run — ${marking.marked} capture(s) withheld as inconclusive (restart it and re-run)`));
|
|
120968
|
+
}
|
|
120969
|
+
}
|
|
120752
120970
|
let recordedOk = false;
|
|
120753
120971
|
let goldenStale = [];
|
|
120754
120972
|
if (opts.record) {
|
|
@@ -120901,8 +121119,10 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
120901
121119
|
llmEnabled: llmStillAvailable,
|
|
120902
121120
|
candIsProduction: opts.candIsProduction,
|
|
120903
121121
|
prodPinned: !isEmptyPin(pins.prod),
|
|
120904
|
-
warmLoads: warmLoadsNow()
|
|
121122
|
+
warmLoads: warmLoadsNow(),
|
|
121123
|
+
candHealth
|
|
120905
121124
|
})),
|
|
121125
|
+
candHealth,
|
|
120906
121126
|
pinned: isEmptyPin(pins.prod) && isEmptyPin(pins.cand) ? undefined : { prod: pinNames(pins.prod), cand: pinNames(pins.cand) },
|
|
120907
121127
|
pagePairs,
|
|
120908
121128
|
golden: goldenRec ? goldenReportField(resolve21(opts.golden), goldenRec.meta, goldenStale) : undefined
|
|
@@ -121124,6 +121344,15 @@ function formatPagePairTable(rows) {
|
|
|
121124
121344
|
}).join(`
|
|
121125
121345
|
`);
|
|
121126
121346
|
}
|
|
121347
|
+
var LOCAL_CAND_CAPTURES = 2;
|
|
121348
|
+
async function runCapturePool(tasks, candBase, fn) {
|
|
121349
|
+
if (!isLocalhost(candBase))
|
|
121350
|
+
return runWithConcurrency2(tasks, 4, fn);
|
|
121351
|
+
await Promise.all([
|
|
121352
|
+
runWithConcurrency2(tasks.filter((t) => t.side !== "cand"), 4, fn),
|
|
121353
|
+
runWithConcurrency2(tasks.filter((t) => t.side === "cand"), LOCAL_CAND_CAPTURES, fn)
|
|
121354
|
+
]);
|
|
121355
|
+
}
|
|
121127
121356
|
async function runWithConcurrency2(items, workers, fn) {
|
|
121128
121357
|
let next = 0;
|
|
121129
121358
|
await Promise.all(Array.from({ length: workers }, async () => {
|
|
@@ -123418,11 +123647,11 @@ function L2(pt, en, lang) {
|
|
|
123418
123647
|
const initial = lang === "pt" ? pt : en;
|
|
123419
123648
|
return `<span class="i18n" data-pt="${esc3(pt)}" data-en="${esc3(en)}">${esc3(initial)}</span>`;
|
|
123420
123649
|
}
|
|
123421
|
-
function
|
|
123650
|
+
function T3(text, lang) {
|
|
123422
123651
|
return L2(text.pt, text.en, lang);
|
|
123423
123652
|
}
|
|
123424
123653
|
function tiles(items, lang) {
|
|
123425
|
-
const cells = items.map((t) => `<div class="tile"><div class="tile-val ${TONE_CLASS[t.tone]}">${esc3(t.value)}</div><div class="tile-label">${
|
|
123654
|
+
const cells = items.map((t) => `<div class="tile"><div class="tile-val ${TONE_CLASS[t.tone]}">${esc3(t.value)}</div><div class="tile-label">${T3(t.label, lang)}</div>${t.sub ? `<div class="tile-sub">${T3(t.sub, lang)}</div>` : ""}</div>`).join("");
|
|
123426
123655
|
return `<div class="stat-grid">${cells}</div>`;
|
|
123427
123656
|
}
|
|
123428
123657
|
function page(eyebrow, title, body, note) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.34",
|
|
4
4
|
"description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with a ranked HTML report.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|