@tangle-network/agent-app 0.60.142 → 0.60.144

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.
@@ -1178,6 +1178,46 @@ function formatSignoffLine(report) {
1178
1178
  return `${report.ok ? "signoff PASS" : "signoff FAIL"} ${report.repo.head.slice(0, 12)} \u2014 ${passed}/${report.steps.length} steps, ${ms(report.wallClockMs)} wall (${ms(report.serialMs)} serial), seed ${report.seedBase}, ${report.install.cacheHit ? "warm" : "cold"} store, clean install`;
1179
1179
  }
1180
1180
 
1181
+ // src/signoff/browser-budget.ts
1182
+ var QUIET_CHROMIUM_ARGS = [
1183
+ "--disable-features=Prerender2,SpeculationRules,SpeculationRulesPrefetchProxy,NoStatePrefetch",
1184
+ "--disable-background-networking"
1185
+ ];
1186
+ var REQUEST_BUDGET_PER_10S = 250;
1187
+ var WINDOW_MS = 1e4;
1188
+ function createRequestMeter(budget = REQUEST_BUDGET_PER_10S, sleep = (ms2) => new Promise((done) => setTimeout(done, ms2))) {
1189
+ const stamps = [];
1190
+ let requests = 0;
1191
+ let peak10s = 0;
1192
+ const trim = (now) => {
1193
+ while (stamps.length && now - stamps[0] > WINDOW_MS) stamps.shift();
1194
+ };
1195
+ return {
1196
+ record(now = Date.now()) {
1197
+ requests += 1;
1198
+ stamps.push(now);
1199
+ trim(now);
1200
+ peak10s = Math.max(peak10s, stamps.length);
1201
+ },
1202
+ async pace() {
1203
+ for (; ; ) {
1204
+ const now = Date.now();
1205
+ trim(now);
1206
+ if (stamps.length < budget) return;
1207
+ await sleep(WINDOW_MS - (now - stamps[0]) + 50);
1208
+ }
1209
+ },
1210
+ count: () => ({ requests, peak10s })
1211
+ };
1212
+ }
1213
+ async function meterContext(context, meter) {
1214
+ await context.route("**/cdn-cgi/speculation*", (route) => route.abort());
1215
+ context.on("request", () => meter.record());
1216
+ }
1217
+ function formatNetworkCount(count) {
1218
+ return `network: ${count.requests} requests, busiest 10 s ${count.peak10s} (budget ${REQUEST_BUDGET_PER_10S})`;
1219
+ }
1220
+
1181
1221
  // src/signoff/shell-alignment.ts
1182
1222
  var SHELL_ALIGNMENT_TOLERANCE_PX = 0.5;
1183
1223
  function judgeShellAlignment(sample, tolerancePx = SHELL_ALIGNMENT_TOLERANCE_PX) {
@@ -1282,7 +1322,8 @@ async function checkShellAlignment(options) {
1282
1322
  const { chromium } = await import("playwright");
1283
1323
  const widths = options.widths ?? [1440, 390];
1284
1324
  const themes = options.themes ?? ["light", "dark"];
1285
- const browser = await chromium.launch();
1325
+ const browser = await chromium.launch({ args: [...QUIET_CHROMIUM_ARGS] });
1326
+ const meter = createRequestMeter();
1286
1327
  const samples = [];
1287
1328
  const findings = [];
1288
1329
  try {
@@ -1296,8 +1337,10 @@ async function checkShellAlignment(options) {
1296
1337
  if (options.themeScript) {
1297
1338
  await context.addInitScript({ content: `(() => { const theme = ${JSON.stringify(theme)}; ${options.themeScript} })()` });
1298
1339
  }
1340
+ await meterContext(context, meter);
1299
1341
  const page = await context.newPage();
1300
1342
  for (const route of options.routes) {
1343
+ await meter.pace();
1301
1344
  await page.goto(new URL(route, options.baseUrl).toString(), { waitUntil: "domcontentloaded" });
1302
1345
  await page.waitForSelector(options.readySelector ?? "[data-shell-header]", { state: "visible", timeout: 15e3 }).catch(() => void 0);
1303
1346
  await page.waitForLoadState("networkidle", { timeout: 3e3 }).catch(() => void 0);
@@ -1319,7 +1362,7 @@ async function checkShellAlignment(options) {
1319
1362
  await browser.close();
1320
1363
  }
1321
1364
  const maxOffsetPx = findings.reduce((max, f) => Number.isFinite(f.offsetPx) ? Math.max(max, Math.abs(f.offsetPx)) : max, 0);
1322
- return { samples, findings, maxOffsetPx };
1365
+ return { samples, findings, maxOffsetPx, network: meter.count() };
1323
1366
  }
1324
1367
  function formatShellAlignmentReport(report) {
1325
1368
  const lines = [`shell alignment: ${report.samples.length} pages, ${report.findings.length} misaligned, max offset ${Math.round(report.maxOffsetPx * 100) / 100}px`];
@@ -1437,6 +1480,8 @@ ${shellAlignmentUsage()}
1437
1480
  `);
1438
1481
  }
1439
1482
  process.stdout.write(`${formatShellAlignmentReport(report)}
1483
+ `);
1484
+ if (report.network) process.stdout.write(`${formatNetworkCount(report.network)}
1440
1485
  `);
1441
1486
  return report.findings.length ? 1 : 0;
1442
1487
  }
@@ -1662,7 +1707,8 @@ async function checkSurfaceLadder(options) {
1662
1707
  const { chromium } = await import("playwright");
1663
1708
  const widths = options.widths ?? [1440, 390];
1664
1709
  const themes = options.themes ?? ["light", "dark"];
1665
- const browser = await chromium.launch();
1710
+ const browser = await chromium.launch({ args: [...QUIET_CHROMIUM_ARGS] });
1711
+ const meter = createRequestMeter();
1666
1712
  const samples = [];
1667
1713
  const findings = [];
1668
1714
  try {
@@ -1677,8 +1723,10 @@ async function checkSurfaceLadder(options) {
1677
1723
  if (options.themeScript) {
1678
1724
  await context.addInitScript({ content: `(() => { const theme = ${JSON.stringify(theme)}; ${options.themeScript} })()` });
1679
1725
  }
1726
+ await meterContext(context, meter);
1680
1727
  const page = await context.newPage();
1681
1728
  for (const route of options.routes) {
1729
+ await meter.pace();
1682
1730
  await page.goto(new URL(route, options.baseUrl).toString(), { waitUntil: "domcontentloaded" });
1683
1731
  await page.waitForSelector(options.readySelector ?? "[data-shell-header]", { state: "visible", timeout: 15e3 }).catch(() => void 0);
1684
1732
  await page.waitForLoadState("networkidle", { timeout: 3e3 }).catch(() => void 0);
@@ -1703,7 +1751,7 @@ async function checkSurfaceLadder(options) {
1703
1751
  }
1704
1752
  const countsByRule = { "card-step": 0, "field-step": 0, "field-border": 0, "card-copy": 0 };
1705
1753
  for (const f of findings) countsByRule[f.rule] += 1;
1706
- return { samples, pages: samples.map((s) => summarizeSurfacePage(s, findings)), findings, countsByRule };
1754
+ return { samples, pages: samples.map((s) => summarizeSurfacePage(s, findings)), findings, countsByRule, network: meter.count() };
1707
1755
  }
1708
1756
  function formatSurfaceLadderReport(report) {
1709
1757
  const c = report.countsByRule;
@@ -1842,6 +1890,8 @@ ${surfaceLadderUsage()}
1842
1890
  `);
1843
1891
  }
1844
1892
  process.stdout.write(`${formatSurfaceLadderReport(report)}
1893
+ `);
1894
+ if (report.network) process.stdout.write(`${formatNetworkCount(report.network)}
1845
1895
  `);
1846
1896
  return report.findings.length ? 1 : 0;
1847
1897
  }
@@ -1882,7 +1932,8 @@ function collectWorkspaceSurface() {
1882
1932
  }
1883
1933
  async function checkWorkspaceSurface(options) {
1884
1934
  const { chromium } = await import("playwright");
1885
- const browser = await chromium.launch();
1935
+ const browser = await chromium.launch({ args: [...QUIET_CHROMIUM_ARGS] });
1936
+ const meter = createRequestMeter();
1886
1937
  const samples = [];
1887
1938
  const findings = [];
1888
1939
  try {
@@ -1896,8 +1947,10 @@ async function checkWorkspaceSurface(options) {
1896
1947
  if (options.themeScript) {
1897
1948
  await context.addInitScript({ content: `(() => { const theme = ${JSON.stringify(theme)}; ${options.themeScript} })()` });
1898
1949
  }
1950
+ await meterContext(context, meter);
1899
1951
  const page = await context.newPage();
1900
1952
  for (const route of options.routes) {
1953
+ await meter.pace();
1901
1954
  await page.goto(new URL(route, options.baseUrl).toString(), { waitUntil: "domcontentloaded" });
1902
1955
  await page.waitForSelector(options.readySelector ?? "[data-shell-header]", { state: "visible", timeout: 15e3 }).catch(() => void 0);
1903
1956
  await page.waitForLoadState("networkidle", { timeout: 3e3 }).catch(() => void 0);
@@ -1916,7 +1969,7 @@ async function checkWorkspaceSurface(options) {
1916
1969
  } finally {
1917
1970
  await browser.close();
1918
1971
  }
1919
- return { samples, findings };
1972
+ return { samples, findings, network: meter.count() };
1920
1973
  }
1921
1974
  function formatWorkspaceSurfaceReport(report) {
1922
1975
  const lines = [`workspace surface: ${report.samples.length} pages, ${report.findings.length} off the shared panel`];
@@ -1965,6 +2018,8 @@ ${USAGE}
1965
2018
  `);
1966
2019
  }
1967
2020
  process.stdout.write(`${formatWorkspaceSurfaceReport(report)}
2021
+ `);
2022
+ if (report.network) process.stdout.write(`${formatNetworkCount(report.network)}
1968
2023
  `);
1969
2024
  return report.findings.length ? 1 : 0;
1970
2025
  }
@@ -1977,6 +2032,11 @@ export {
1977
2032
  runSignoff,
1978
2033
  formatSignoffReport,
1979
2034
  formatSignoffLine,
2035
+ QUIET_CHROMIUM_ARGS,
2036
+ REQUEST_BUDGET_PER_10S,
2037
+ createRequestMeter,
2038
+ meterContext,
2039
+ formatNetworkCount,
1980
2040
  SHELL_ALIGNMENT_TOLERANCE_PX,
1981
2041
  judgeShellAlignment,
1982
2042
  collectShellDividers,
@@ -2005,4 +2065,4 @@ export {
2005
2065
  formatWorkspaceSurfaceReport,
2006
2066
  runWorkspaceSurfaceCli
2007
2067
  };
2008
- //# sourceMappingURL=chunk-NK3ZVZPP.js.map
2068
+ //# sourceMappingURL=chunk-XAU3UN32.js.map