From 1e2c5a09fbf4225de6acfd0a447bddd488671bf4 Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 02:40:06 +0100 Subject: [PATCH 1/2] Keep check transcripts concise Co-Authored-By: Codex --- docs/ARCHITECTURE.md | 9 ++-- src/loopzero/cli.py | 102 +++++++++++++++++++--------------------- src/loopzero/sandbox.py | 6 ++- tests/test_cli.py | 100 +++++++++++++++++++++++++++++++++++++++ tests/test_sandbox.py | 10 ++-- 5 files changed, 164 insertions(+), 63 deletions(-) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 42d721ba..2cb113b0 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -72,10 +72,12 @@ The [CLI](../src/loopzero/cli.py) implements the contract's focused tests start early. `check` runs deterministic checks in a read-only source sandbox. Its simple-command preflight catches missing local scripts, prepares recognized uv dependency groups offline in that sandbox and prints - progress before each command, metadata-only stage heartbeats every 30 seconds - (including silent children), and exit code/duration immediately after each stage. + progress before each command, metadata-only stage heartbeats after 30 seconds + and every five minutes thereafter (including silent children), and exit + code/duration immediately after each stage. Heartbeats stop on completion or cancellation and never supply a verdict; child - streams remain captured for the existing final report and failing output tail. + streams remain captured for the final report. Oversized failure output gets a + terminal preview and keeps its diagnostic tail in the check receipt. Trusted-base commands remain authoritative; stale task trees need integration only when prerequisites are missing, preserving source-preserving queue eligibility for behind branches. @@ -111,6 +113,7 @@ The [CLI](../src/loopzero/cli.py) implements the contract's that requested changes also requires resolved findings at the reviewed head. After its own draft-to-ready write, `ready --wait` revalidates through the same waiter and original deadline. + The shared check waiter reports initial blockers and subsequent changes. This is best-effort observation: an immediate green read may precede asynchronous CI scheduling, there is no unconditional delay, and merge admission checks readiness again. Missing-run diagnosis keeps its two-minute diff --git a/src/loopzero/cli.py b/src/loopzero/cli.py index 20b73319..fc9a9144 100644 --- a/src/loopzero/cli.py +++ b/src/loopzero/cli.py @@ -575,44 +575,48 @@ def cmd_start(args: argparse.Namespace) -> int: return 0 +def _check_failure_preview(tail: str, limit: int = 1536) -> str: + if len(tail.encode()) <= limit: + return tail + readable = "\n".join(line for line in tail.splitlines() if len(line.encode()) <= limit // 2) + return (readable or tail).encode()[-limit:].decode(errors="ignore") + + def cmd_check(args: argparse.Namespace) -> int: wt, config = _context(args, pin_checks=True) if not config.checks: raise config_mod.ConfigError("checks.commands must list at least one command to run checks") try: report = sandbox.run_checks(config, wt, progress=lambda command: print( - f"running: {command}", flush=True), - status=lambda message: print(message, flush=True), - checkpoint=lambda partial: _save_report(wt, partial)) + f"running: {command}", flush=True), status=partial(print, flush=True), + checkpoint=partial(_save_report, wt)) except sandbox.SandboxUnavailable as exc: print(f"sandbox unavailable: {exc}", file=sys.stderr) return 2 + shortened = False for result in report.results: if result.exit_code != 0: print(f"--- {result.command} (exit {result.exit_code}) ---", file=sys.stderr) tail = _proc.tail(result.tail) - print(tail, file=sys.stderr) + preview = _check_failure_preview(tail) + shortened |= preview != tail + print(preview, file=sys.stderr) if not config.network and (result.command.startswith("uv sync --offline --locked") or OFFLINE_FAILURE_RE.search(tail)): - env = { - **sandbox.SANDBOX_ENV, - **_proc.build_env(config.env_allowlist), - **dict(config.env), - } + env = sandbox.SANDBOX_ENV | _proc.build_env(config.env_allowlist) | dict(config.env) print( "\nThe sandbox has no network because `[checks] network = false`; " f"the effective UV_CACHE_DIR inside the sandbox is {env['UV_CACHE_DIR']}. " - "To prepare offline, run UV_CACHE_DIR= uv sync --group dev " - "(use the groups your checks require) on the host, or the same commands, so the cache " - "under `[checks] writable` is warm, or set `[checks] env` UV_CACHE_DIR to " - "that cache.", - file=sys.stderr, + "Run UV_CACHE_DIR= uv sync --group dev on the host " + "(use the required groups) so the cache under `[checks] writable` is warm, " + "or set `[checks] env` UV_CACHE_DIR to a warm cache.", file=sys.stderr, ) - current_head = _save_report(wt, report) - if current_head is not None: + if (current_head := _save_report(wt, report)) is not None: print(f"check result discarded: checked HEAD {report.head}, current HEAD {current_head}", file=sys.stderr) return 1 + if shortened: + print(f"Full diagnostic tail: {CHECKS_FILE} (head {report.head})", file=sys.stderr) if report.ok and not report.dirty: _print_receipt(wt, report, "produced") _refresh_pr_checks(wt, config) @@ -1161,9 +1165,7 @@ def cmd_ready(args: argparse.Namespace) -> int: print(f"marked ready; waiting for required checks: {', '.join(waiting)}{pending}; {NEXT_WAIT}") return 3 print("marked ready; " + "; ".join(readiness.reasons)) - if args.wait is not None and ( - waiting or _pending_checks(config, pr, readiness, allow_skipped=not pr.is_draft) - ): + if args.wait is not None and (waiting or _pending_checks(config, pr, readiness, allow_skipped=not pr.is_draft)): waited = _wait_with_deadline(wt, config, pr, args.wait, kicked=kicked, started=started, shown=readiness.reasons if kicked else (), args=args, allow_skipped=True, initial=None if kicked else readiness) @@ -1209,14 +1211,10 @@ def _draft_checks_waiting( def _pending_checks( config: Config, pr: github.PR, readiness: github.Readiness, *, allow_skipped: bool = False ) -> tuple[str, ...]: - """Reasons worth waiting on: mergeability or required checks can still settle. - - An explicit ready wait can observe a skipped result left over from draft CI. - """ + """Wait for mergeability and required checks, including allowed draft skips.""" states = [f"missing on {pr.head_sha[:12]}", "is pending", *(["is skipped"] if allow_skipped else [])] waitable = {f"required check '{n}' {state}" for n in config.required_ci for state in states} - waitable.update(readiness.waitable_failures) - waitable.add(MERGEABILITY_PENDING) + waitable.update(readiness.waitable_failures, (MERGEABILITY_PENDING,)) reasons = readiness.reasons return reasons if reasons and all(r in waitable for r in reasons) else () @@ -1251,14 +1249,13 @@ def _poll_until(started: float, timeout: float, *, bounded: bool = False) -> Ite def _wait_with_deadline( wt: Path, config: Config, pr: github.PR, timeout: float, *, kicked: bool, - started: float | None = None, shown: tuple[str, ...] = (), args: argparse.Namespace, + started: float, shown: tuple[str, ...] = (), args: argparse.Namespace, allow_merged: bool = False, allow_skipped: bool = False, initial: github.Readiness | None = None, ) -> tuple[github.PR, github.Readiness | None, bool] | None: - started = time.monotonic() if started is None else started + observe = partial(_wait_for_checks, wt, config, pr, timeout, kicked=kicked, started=started, + shown=shown, args=args, allow_merged=allow_merged, allow_skipped=allow_skipped, initial=initial) if timeout == 0: - return _wait_for_checks(wt, config, pr, timeout, kicked=kicked, started=started, - shown=shown, args=args, allow_merged=allow_merged, - allow_skipped=allow_skipped, initial=initial) + return observe() deadline = started + timeout if time.monotonic() >= deadline: _print_check_wait_timeout(pr) @@ -1266,9 +1263,7 @@ def _wait_with_deadline( reported_timeout = False try: with github.bounded_reads(deadline, token=None, retry=True): - waited = _wait_for_checks(wt, config, pr, timeout, kicked=kicked, started=started, - shown=shown, args=args, bounded=True, allow_merged=allow_merged, - allow_skipped=allow_skipped, initial=initial) + waited = observe(bounded=True) reported_timeout = waited is None except github.ReadDeadline: if not reported_timeout: @@ -1278,10 +1273,8 @@ def _wait_with_deadline( def _print_check_wait_timeout(pr: github.PR) -> None: - if pr.mergeable == "UNKNOWN": - print(f"timed out waiting for GitHub to compute mergeability on {pr.head_sha[:12]}") - else: - print(f"timed out waiting for required checks on {pr.head_sha[:12]}") + reason = "GitHub to compute mergeability" if pr.mergeable == "UNKNOWN" else "required checks" + print(f"timed out waiting for {reason} on {pr.head_sha[:12]}") def _verify_wait_snapshot( @@ -1303,13 +1296,22 @@ def _verify_wait_snapshot( raise CliError(f"{changed} changed while waiting; retry with the current settings") +def _print_wait_changes(shown: tuple[str, ...], pending: tuple[str, ...]) -> None: + def by_check(reasons: tuple[str, ...]) -> dict[str, str]: + return {reason.rpartition("' ")[0] or reason: reason for reason in reasons} + previous, current = by_check(shown), by_check(pending) + if changed := [reason for key, reason in current.items() if previous.get(key) != reason]: + print("waiting: " + "; ".join(changed)) + if cleared := [key.removeprefix("required check '") for key in previous if key not in current]: + print("cleared: " + "; ".join(cleared)) + + def _wait_for_checks( wt: Path, config: Config, pr: github.PR, timeout: float, *, kicked: bool, started: float | None = None, shown: tuple[str, ...] = (), args: argparse.Namespace | None = None, bounded: bool = False, allow_merged: bool = False, allow_skipped: bool = False, initial: github.Readiness | None = None, ) -> tuple[github.PR, github.Readiness | None, bool] | None: - """Poll the same head until it settles, omitting readiness for an allowed merge.""" grace_started = time.monotonic() started = grace_started if started is None else started current = pr @@ -1335,24 +1337,19 @@ def _wait_for_checks( pending = _pending_checks( config, current, readiness, allow_skipped=kicked or (allow_skipped and not current.is_draft), ) + if pending or readiness.ready: + _print_wait_changes(shown, pending) if not pending: return current, readiness, kicked - if pending != shown: - print("waiting: " + "; ".join(pending)) - shown = pending + shown = pending elapsed = time.monotonic() - grace_started if readiness.stale_verdicts and not stale_notice: - print( - "waiting: required check verdict predates the review; awaiting refresh: " - + ", ".join(readiness.stale_verdicts) - ) + print("waiting: required check verdict predates the review; awaiting refresh: " + + ", ".join(readiness.stale_verdicts)) stale_notice = True - # Missing check runs do not prove that no workflow was scheduled. Diagnose only - # when no visible pending check explains why the required jobs have not appeared. - if ( - elapsed >= MISSING_RUN_GRACE - and all(" missing on " in r for r in pending) - and not readiness.has_pending_checks + # Diagnose missing runs only when no visible check is still pending. + if elapsed >= MISSING_RUN_GRACE and not readiness.has_pending_checks and all( + " missing on " in reason for reason in pending ): raise CliError( f"{'; '.join(pending)} after {elapsed:.0f}s: inspect workflow scheduling, " @@ -1539,8 +1536,7 @@ def cmd_merge(args: argparse.Namespace) -> int: # --wait=0 observes once; a positive budget also bounds merge or queue admission. admit_by = deadline if args.wait else None if readiness is not None and args.wait is not None and _pending_checks(config, pr, readiness): - # One waiter and one deadline span source checks and landing: a check created - # by the ready transition must not end the turn between `ready` and the queue. + # Share the merge deadline with checks scheduled after readiness. waited = _wait_with_deadline(wt, config, pr, args.wait, kicked=False, started=started, args=args, allow_merged=True, initial=readiness) if waited is None: diff --git a/src/loopzero/sandbox.py b/src/loopzero/sandbox.py index a358d56f..fd610532 100644 --- a/src/loopzero/sandbox.py +++ b/src/loopzero/sandbox.py @@ -32,7 +32,7 @@ TIMEOUT_EXIT = 124 CHECK_SHELL = ("/bin/bash", "--posix", "-o", "pipefail", "-c") CHECK_TAIL_BYTES = 16 * 1024 -HEARTBEAT_INTERVAL = 30.0 +FIRST_HEARTBEAT_DELAY = 30.0 SANDBOX_HOME = "/tmp/home" # Only these system directories are exposed read-only by default; home tool paths # require explicit `[checks] ro_paths`. Host homes, sockets and processes stay hidden. @@ -344,9 +344,11 @@ def _stage_status(status: Callable[[str], None] | None, ordinal: int, total: int started = time.monotonic() def heartbeat(): - while not stopped.wait(HEARTBEAT_INTERVAL): + delay = FIRST_HEARTBEAT_DELAY + while not stopped.wait(delay): status(f"stage {ordinal}/{total}: running " f"({time.monotonic() - started:.1f}s elapsed)") + delay = 300.0 reporter = threading.Thread(target=heartbeat, daemon=True) if status else None if reporter: diff --git a/tests/test_cli.py b/tests/test_cli.py index dfc31abb..764c3fac 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -264,6 +264,105 @@ def run(capsys, *argv: str) -> tuple[int, str, str]: return code, captured.out, captured.err +# Transcript size regressions +@pytest.mark.parametrize("command", ["ready", "merge"]) +@pytest.mark.parametrize("stable", [False, True]) +def test_wait_reports_only_check_changes(wt, gh, head, capsys, monkeypatch, stable, command): + names = ["checks"] + [f"verify deployment / integration shard {n:02d}" for n in range(23)] + cfg = cli.dataclasses.replace(config.load(wt / "workflow.toml"), required_ci=tuple(names)) + monkeypatch.setattr(cli, "_context", lambda *a, **k: (wt, cfg)) + monkeypatch.setattr(cli, "_verify_wait_snapshot", lambda *a: None) + monkeypatch.setattr(cli, "WAIT_INTERVAL", 0.1) + monkeypatch.setattr(github, "time", SimpleNamespace(monotonic=lambda: clock[0])) + arm_approved_pr_with_check_result(gh, head, wt, "pending", isDraft=False) + runs = [ + [{"name": name, "status": "completed", "conclusion": "success"} + if i < cleared else {"name": name, "status": "in_progress"} + for i, name in enumerate(names)] + for cleared in ([0] if stable else [0, *range(25)]) + ] + arm_check_runs(gh, head, *runs) + clock = [0.0] + monkeypatch.setattr(cli, "time", SimpleNamespace(monotonic=lambda: clock[0])) + monkeypatch.setattr(cli, "_sleep", lambda seconds: clock.__setitem__(0, clock[0] + seconds)) + if command == "merge": + monkeypatch.setattr(github, "merge", lambda *a: "c" * 40) + monkeypatch.setattr(cli, "_cleanup_remote_refs", lambda *a: None) + monkeypatch.setattr(cli, "_cleanup", lambda *a: None) + code, out, err = run(capsys, command, "--wait=1" if stable else "--wait=1800") + assert len((out + err).encode()) < 3200 and out.count("waiting:") == 1 + assert not err and all(f"required check '{name}' is pending" in out for name in names) + if stable: + assert code == 3 and f"timed out waiting for required checks on {head[:12]}" in out + assert "cleared:" not in out + else: + assert code == 0 and out.endswith(f"ready: {URL}\n" if command == "ready" else "c" * 40 + "\n") + assert all(f"cleared: {name}\n" in out for name in names) + + +@pytest.mark.parametrize("receipt", ["saved", "head moved", "write failed"]) +def test_check_bounds_large_failure_and_preserves_receipt(wt, head, capsys, monkeypatch, receipt): + tail = 'TEST_FAILURES={"detail":"' + "é" * 7500 + '","error":"Failed to fetch package"}\n' + tail += "migration failed: relation widgets already exists" + monkeypatch.setattr(cli.sandbox, "run_checks", lambda *a, **k: CheckReport( + "a" * 40 if receipt == "head moved" else head, False, + (CheckResult("apply migrations", 7, 0.1, tail),), + )) + if receipt == "write failed": + monkeypatch.setattr(cli, "_save_report", Mock(side_effect=PermissionError("receipt write denied"))) + code, out, err = run(capsys, "check") + assert len((out + err).encode()) < 2500 + assert code == 1 and "apply migrations (exit 7)" in err + assert "migration failed: relation widgets already exists" in err + assert "uv sync --group dev" in err + if receipt == "saved": + assert out.endswith("FAIL\n") and ".loopzero/checks.json" in err and head in err + assert json.loads((wt / ".loopzero/checks.json").read_text())["results"][0]["tail"] == tail + else: + assert ".loopzero/checks.json" not in err + assert ("current HEAD" if receipt == "head moved" else "receipt write denied") in err + + +def test_check_hour_long_stage_transcript(wt, head, gh, capsys, monkeypatch): + sandbox = cli.sandbox + clock = [0.0] + limit = [0.0] + + def wait(seconds): + clock[0] += seconds + return clock[0] >= limit[0] + + monkeypatch.setattr(sandbox, "threading", SimpleNamespace( + Event=lambda: SimpleNamespace(wait=wait, set=lambda: None), + Thread=lambda *, target, daemon: SimpleNamespace(start=target, join=lambda: None), + )) + monkeypatch.setattr(sandbox, "time", SimpleNamespace(monotonic=lambda: clock[0])) + + def run_checks(cfg, path, *, progress, status, checkpoint): + results = [] + for ordinal in range(1, 25): + command = f"run tool {ordinal:02d}" + duration = 3600.0 if ordinal == 1 else 0.1 + limit[0] = clock[0] + duration + progress(command) + with sandbox._stage_status(status, ordinal, 24): + pass + status(f"stage {ordinal}/24: exit 0 ({duration:.1f}s)") + results.append(CheckResult(command, 0, duration, "")) + return CheckReport(head, False, tuple(results)) + + monkeypatch.setattr(sandbox, "run_checks", run_checks) + code, out, err = run(capsys, "check") + assert len((out + err).encode()) < 2400 + assert (code, err, gh.calls) == (0, "", []) and out.endswith("PASS\n") + assert f"receipt produced: head={head}" in out and "stage 24/24: exit 0" in out + assert out.count("running: run tool") == 24 + assert [float(seconds) for seconds in re.findall(r"running \(([\d.]+)s elapsed\)", out)] == list( + range(30, 3600, 300) + ) + assert out.rindex("s elapsed)") < out.index("stage 1/24: exit 0 (3600.0s)") + + # --- start / check -------------------------------------------------------------------- @@ -2329,6 +2428,7 @@ def test_ready_wait_reports_initial_draft_blocker_once(wt, gh, capsys, monkeypat assert without_accepted_receipt(out).splitlines() == [ "marked ready; required check 'checks' is skipped", "waiting: required check 'checks' is pending", + "cleared: checks", f"ready: {URL}", ] diff --git a/tests/test_sandbox.py b/tests/test_sandbox.py index 5e805278..e64f9e1e 100644 --- a/tests/test_sandbox.py +++ b/tests/test_sandbox.py @@ -519,7 +519,7 @@ def test_silent_stage_reports_live_metadata_then_completion( import re import threading - monkeypatch.setattr(sandbox, "HEARTBEAT_INTERVAL", 0.03) + monkeypatch.setattr(sandbox, "FIRST_HEARTBEAT_DELAY", 0.03) observed, events, reporters = threading.Event(), [], set() monkeypatch.setenv("LZ_KEEP", "credential-value") command = f'echo "$LZ_KEEP"; echo private-stderr >&2; exit {exit_code}' @@ -563,7 +563,7 @@ def status(event): def test_early_failure_reports_actual_exit_without_heartbeat(git_repo, bwrap_log, monkeypatch): - monkeypatch.setattr(sandbox, "HEARTBEAT_INTERVAL", 30.0) + monkeypatch.setattr(sandbox, "FIRST_HEARTBEAT_DELAY", 30.0) events = [] report = sandbox.run_checks( make_config(checks=("echo secret; exit 17", "echo never")), git_repo, @@ -577,7 +577,7 @@ def test_early_failure_reports_actual_exit_without_heartbeat(git_repo, bwrap_log def test_timeout_stops_heartbeat_and_retains_failure_tail(git_repo, bwrap_log, monkeypatch): import threading - monkeypatch.setattr(sandbox, "HEARTBEAT_INTERVAL", 0.03) + monkeypatch.setattr(sandbox, "FIRST_HEARTBEAT_DELAY", 0.03) observed, events, reporters = threading.Event(), [], [] def status(message): @@ -605,7 +605,7 @@ def wait_for_heartbeat(): def test_cancellation_stops_heartbeat_without_reporting_verdict(git_repo, bwrap_log, monkeypatch): import threading - monkeypatch.setattr(sandbox, "HEARTBEAT_INTERVAL", 0.03) + monkeypatch.setattr(sandbox, "FIRST_HEARTBEAT_DELAY", 0.03) observed, events, reporters = threading.Event(), [], [] def heartbeat(message): @@ -677,7 +677,7 @@ def status(message): if mode == "blocked-heartbeat": threading.Event().wait() -sandbox.HEARTBEAT_INTERVAL = 0.03 +sandbox.FIRST_HEARTBEAT_DELAY = 0.03 repo = Path.cwd() command = "echo complete" if mode in {"dispatch", "removal"} else "exec sleep 30" report = sandbox.run_checks(make_config(checks=(command,)), repo, status=status) From 1579e6aaae78f043a516f2900d93bafeb3b27510 Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 02:46:48 +0100 Subject: [PATCH 2/2] Preserve the final error in bounded check previews Architecture-Review: unchanged; the bounded preview now marks truncation and keeps excerpts of long lines Co-Authored-By: Codex --- src/loopzero/cli.py | 11 +++++++++-- src/loopzero/sandbox.py | 3 ++- tests/test_cli.py | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/loopzero/cli.py b/src/loopzero/cli.py index fc9a9144..c18e26a9 100644 --- a/src/loopzero/cli.py +++ b/src/loopzero/cli.py @@ -578,8 +578,15 @@ def cmd_start(args: argparse.Namespace) -> int: def _check_failure_preview(tail: str, limit: int = 1536) -> str: if len(tail.encode()) <= limit: return tail - readable = "\n".join(line for line in tail.splitlines() if len(line.encode()) <= limit // 2) - return (readable or tail).encode()[-limit:].decode(errors="ignore") + edge = limit // 8 + lines = (line.encode() for line in tail.splitlines()) + preview = b"\n".join( + line if len(line) <= 2 * edge else line[:edge] + b" [...] " + line[-edge:] + for line in lines + ) + if len(preview) > limit: + preview = b"[...]\n" + preview[6 - limit:] + return preview.decode(errors="ignore") def cmd_check(args: argparse.Namespace) -> int: diff --git a/src/loopzero/sandbox.py b/src/loopzero/sandbox.py index fd610532..44a31810 100644 --- a/src/loopzero/sandbox.py +++ b/src/loopzero/sandbox.py @@ -33,6 +33,7 @@ CHECK_SHELL = ("/bin/bash", "--posix", "-o", "pipefail", "-c") CHECK_TAIL_BYTES = 16 * 1024 FIRST_HEARTBEAT_DELAY = 30.0 +HEARTBEAT_INTERVAL = 300.0 SANDBOX_HOME = "/tmp/home" # Only these system directories are exposed read-only by default; home tool paths # require explicit `[checks] ro_paths`. Host homes, sockets and processes stay hidden. @@ -348,7 +349,7 @@ def heartbeat(): while not stopped.wait(delay): status(f"stage {ordinal}/{total}: running " f"({time.monotonic() - started:.1f}s elapsed)") - delay = 300.0 + delay = HEARTBEAT_INTERVAL reporter = threading.Thread(target=heartbeat, daemon=True) if status else None if reporter: diff --git a/tests/test_cli.py b/tests/test_cli.py index 764c3fac..290cd025 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -303,7 +303,7 @@ def test_wait_reports_only_check_changes(wt, gh, head, capsys, monkeypatch, stab @pytest.mark.parametrize("receipt", ["saved", "head moved", "write failed"]) def test_check_bounds_large_failure_and_preserves_receipt(wt, head, capsys, monkeypatch, receipt): tail = 'TEST_FAILURES={"detail":"' + "é" * 7500 + '","error":"Failed to fetch package"}\n' - tail += "migration failed: relation widgets already exists" + tail += "migration failed: relation widgets already exists\nAssertionError: assert " + "x" * 1000 monkeypatch.setattr(cli.sandbox, "run_checks", lambda *a, **k: CheckReport( "a" * 40 if receipt == "head moved" else head, False, (CheckResult("apply migrations", 7, 0.1, tail),), @@ -313,7 +313,7 @@ def test_check_bounds_large_failure_and_preserves_receipt(wt, head, capsys, monk code, out, err = run(capsys, "check") assert len((out + err).encode()) < 2500 assert code == 1 and "apply migrations (exit 7)" in err - assert "migration failed: relation widgets already exists" in err + assert all(text in err for text in ("migration failed: relation widgets already exists", "AssertionError: assert", "[...]")) assert "uv sync --group dev" in err if receipt == "saved": assert out.endswith("FAIL\n") and ".loopzero/checks.json" in err and head in err