@tangle-network/agent-app 0.63.37 → 0.63.39

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.
@@ -1688,6 +1688,20 @@ async function runSignoff(options = {}) {
1688
1688
  options.onEvent?.({ kind: "cache-prune", ...result });
1689
1689
  }
1690
1690
  };
1691
+ let report;
1692
+ let primaryError;
1693
+ let primaryFailed = false;
1694
+ let workspaceRetained = options.keepWorkspace ?? false;
1695
+ const cleanupErrors = [];
1696
+ const cleanup = async (operation, action) => {
1697
+ try {
1698
+ await action();
1699
+ return true;
1700
+ } catch (error) {
1701
+ cleanupErrors.push(`${operation}: ${error instanceof Error ? error.message : String(error)}`);
1702
+ return false;
1703
+ }
1704
+ };
1691
1705
  try {
1692
1706
  await prune(cacheDir);
1693
1707
  tree = materializeCleanTree({ repoDir: repoRoot, dest: treePath(), source });
@@ -1759,7 +1773,7 @@ async function runSignoff(options = {}) {
1759
1773
  const host = hostFacts(tree.path, nodeRequirement);
1760
1774
  const seedBase = options.seed ?? newSeedBase();
1761
1775
  if (installResult.exitCode !== 0) {
1762
- return finish({
1776
+ report = finish({
1763
1777
  ok: false,
1764
1778
  startedAt,
1765
1779
  wallStart,
@@ -1784,64 +1798,83 @@ async function runSignoff(options = {}) {
1784
1798
  source,
1785
1799
  options
1786
1800
  });
1787
- }
1788
- assertNodeTypesVersion(tree.path, nodeRequirement);
1789
- const workerDefaults = checkDefaults ? [runWorkerDefaults(tree.path, config.workerConfigs, options)] : [];
1790
- const treeRoot = tree.path;
1791
- const outcomes = await runGraph({
1792
- nodes: config.steps,
1793
- maxParallel: options.maxParallel ?? config.maxParallel ?? availableParallelism(),
1794
- keepGoing: options.keepGoing ?? false,
1795
- run: async (step, signal) => {
1796
- const attempts = [];
1797
- for (const plan of planAttempts(step, seedBase, options.shuffleRuns)) {
1798
- options.onEvent?.({ kind: "step-start", name: step.name, command: plan.command, seed: plan.seed });
1799
- const result = await runCommand({
1800
- command: plan.command,
1801
- cwd: join9(treeRoot, step.cwd ?? "."),
1802
- env: buildEnv(sharedEnv, [step.env]),
1803
- timeoutMs: step.timeoutMs,
1804
- signal
1805
- });
1806
- const ok = result.exitCode === 0;
1807
- attempts.push(toAttempt(result, plan.seed, ok));
1808
- if (!ok) {
1809
- emitStepEnd(options, step.name, "failed", attempts);
1810
- return { ok: false, value: attempts };
1801
+ } else {
1802
+ assertNodeTypesVersion(tree.path, nodeRequirement);
1803
+ const workerDefaults = checkDefaults ? [runWorkerDefaults(tree.path, config.workerConfigs, options)] : [];
1804
+ const treeRoot = tree.path;
1805
+ const outcomes = await runGraph({
1806
+ nodes: config.steps,
1807
+ maxParallel: options.maxParallel ?? config.maxParallel ?? availableParallelism(),
1808
+ keepGoing: options.keepGoing ?? false,
1809
+ run: async (step, signal) => {
1810
+ const attempts = [];
1811
+ for (const plan of planAttempts(step, seedBase, options.shuffleRuns)) {
1812
+ options.onEvent?.({ kind: "step-start", name: step.name, command: plan.command, seed: plan.seed });
1813
+ const result = await runCommand({
1814
+ command: plan.command,
1815
+ cwd: join9(treeRoot, step.cwd ?? "."),
1816
+ env: buildEnv(sharedEnv, [step.env]),
1817
+ timeoutMs: step.timeoutMs,
1818
+ signal
1819
+ });
1820
+ const ok = result.exitCode === 0;
1821
+ attempts.push(toAttempt(result, plan.seed, ok));
1822
+ if (!ok) {
1823
+ emitStepEnd(options, step.name, "failed", attempts);
1824
+ return { ok: false, value: attempts };
1825
+ }
1811
1826
  }
1827
+ emitStepEnd(options, step.name, "passed", attempts);
1828
+ return { ok: true, value: attempts };
1812
1829
  }
1813
- emitStepEnd(options, step.name, "passed", attempts);
1814
- return { ok: true, value: attempts };
1815
- }
1816
- });
1817
- const appDefaults = checkDefaults ? [runAppDefaults(tree.path, config, options)] : [];
1818
- const steps = [...outcomes.map(toStepResult), ...workerDefaults, ...appDefaults];
1819
- return finish({
1820
- ok: steps.every((step) => step.status === "passed"),
1821
- startedAt,
1822
- wallStart,
1823
- tree,
1824
- origin,
1825
- selection,
1826
- host,
1827
- install,
1828
- steps,
1829
- seedBase,
1830
- keepGoing: options.keepGoing ?? false,
1831
- workspaceRetained: options.keepWorkspace ?? false,
1832
- source,
1833
- options
1834
- });
1830
+ });
1831
+ const appDefaults = checkDefaults ? [runAppDefaults(tree.path, config, options)] : [];
1832
+ const steps = [...outcomes.map(toStepResult), ...workerDefaults, ...appDefaults];
1833
+ report = finish({
1834
+ ok: steps.every((step) => step.status === "passed"),
1835
+ startedAt,
1836
+ wallStart,
1837
+ tree,
1838
+ origin,
1839
+ selection,
1840
+ host,
1841
+ install,
1842
+ steps,
1843
+ seedBase,
1844
+ keepGoing: options.keepGoing ?? false,
1845
+ workspaceRetained: options.keepWorkspace ?? false,
1846
+ source,
1847
+ options
1848
+ });
1849
+ }
1850
+ } catch (error) {
1851
+ primaryFailed = true;
1852
+ primaryError = error;
1835
1853
  } finally {
1836
- try {
1837
- if (tree && !options.keepWorkspace && existsSync9(tree.path)) removeCleanTree(tree);
1838
- } finally {
1839
- for (const active of sessions) {
1840
- await active.close();
1841
- await prune(active.cacheDir, options.keepWorkspace && tree ? [tree.path] : []);
1854
+ if (tree && !options.keepWorkspace && existsSync9(tree.path)) {
1855
+ workspaceRetained = !await cleanup("remove workspace", () => removeCleanTree(tree));
1856
+ }
1857
+ for (const active of sessions) {
1858
+ if (await cleanup(`close cache session ${active.cacheDir}`, () => active.close())) {
1859
+ await cleanup(`prune cache ${active.cacheDir}`, () => prune(active.cacheDir, workspaceRetained && tree ? [tree.path] : []));
1842
1860
  }
1843
1861
  }
1844
1862
  }
1863
+ if (primaryFailed) {
1864
+ if (cleanupErrors.length) throw new AggregateError(
1865
+ [primaryError, ...cleanupErrors.map((message) => new Error(message))],
1866
+ `${primaryError instanceof Error ? primaryError.message : String(primaryError)}; cleanup failed: ${cleanupErrors.join("; ")}`,
1867
+ { cause: primaryError }
1868
+ );
1869
+ throw primaryError;
1870
+ }
1871
+ return {
1872
+ ...report,
1873
+ ok: report.ok && cleanupErrors.length === 0,
1874
+ workspaceRetained,
1875
+ wallClockMs: Date.now() - wallStart,
1876
+ ...cleanupErrors.length ? { cleanupErrors } : {}
1877
+ };
1845
1878
  }
1846
1879
  function runWorkerDefaults(treeRoot, workerConfigs, options) {
1847
1880
  const command = `agent-app-signoff ${WORKER_DEFAULTS_STEP}`;
@@ -2059,13 +2092,14 @@ function formatSignoffReport(report) {
2059
2092
  lines.push(`not judged: ${blocked.map((step) => `${step.name} (${step.status})`).join(", ")}`);
2060
2093
  lines.push("");
2061
2094
  }
2095
+ if (report.cleanupErrors?.length) lines.push(BAR, "cleanup FAILED", BAR, ...report.cleanupErrors, "");
2062
2096
  lines.push(`reproduce: ${report.reproduce}`);
2063
2097
  return lines.join("\n");
2064
2098
  }
2065
2099
  function formatSignoffLine(report) {
2066
2100
  const passed = report.steps.filter((step) => step.status === "passed").length;
2067
2101
  const scope = report.phase && report.phase !== "all" ? `${report.phase.toUpperCase()} ` : "";
2068
- return `signoff ${scope}${report.ok ? "PASS" : "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`;
2102
+ return `signoff ${scope}${report.ok ? "PASS" : "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` + (report.cleanupErrors?.length ? `; ${report.cleanupErrors.length} cleanup failure(s)` : "");
2069
2103
  }
2070
2104
 
2071
2105
  // src/signoff/browser-budget.ts
@@ -2976,4 +3010,4 @@ export {
2976
3010
  formatWorkspaceSurfaceReport,
2977
3011
  runWorkspaceSurfaceCli
2978
3012
  };
2979
- //# sourceMappingURL=chunk-XBUZ43VQ.js.map
3013
+ //# sourceMappingURL=chunk-F25HBFAM.js.map