v1.0.1 — a failed attempt no longer strands HEAD on a loser
Browse filesAn attempt that raised after its edit was committed left the branch on a commit the loop never scored, so the next baseline read the loser. The champion is restored on the way out — and the restore declines when the tree is dirty outside the editable allowlist, because a `reset --hard` that discards somebody else's work to tidy up after ourselves is worse than the mess.
Also: ui/metrics.py brought in line with the house lint, version bumped in all three places it is declared, NAV points at the new entry, and the accumulated [Unreleased] changelog block is released as part of 1.0.1.
750 tests pass (was 748).
Files changed (8)
5 unmodified lines6789101112131415161718192021222346 unmodified lines7071727374751 unmodified line7778798081825 unmodified lines## [Unreleased]### Changed- **Removed hackathon framing from the public surfaces.** README, `pyproject.toml`description, the package docstring, `CLAUDE.md`, and the active docs (autotune /architecture / development / coach / yaml_schema / HANDOFF / NAV) no longer framemindXtrain as a hackathon submission; deleted `docs/HACKATHON.md` and`docs/hackathon_submission.md`. The frozen `docs/blueprints/` and dated dev-blogposts are preserved unchanged as the historical record. README now leads with thedcoach proof loop.### Added- **dcoach page + prompt-tools + decentralized panel.** New `/coach/dcoach` workflowpage: one-click **Imprint & Prove** (persona/skills + advanced toggles) streams theproof loop live (`POST /coach/api/dcoach/run`, SSE) and shows the classroom before/after46 unmodified lines### Fixed- **Imprint recall now measured under the trained conditioning.** `probe_recall` accepts anoptional `system` prompt and the proof loop passes the persona's system prompt to both thebefore and after probes — matching the system turn the script rows train under. Without it1 unmodified lineimprint; the CPU proof loop now reports a strong positive Δ (e.g. 0.066→0.247) and anAPPROVED verdict.## [1.0.0] — 2026-06-11First production release. **CPU training is active end-to-end**; the GPU5 unmodified lines6789101112131415161718192021222324252627282930313246 unmodified lines7980818283848586878889909192939495969798991001011021031 unmodified line1051061071081091101111121131141151161171181191201211221231245 unmodified lines## [Unreleased]## [1.0.1] — 2026-09-15### Added- **autoresearch — the keep/reset search, shipped whole.** The `research` command hadbeen in the CLI since the Hugging Face fork, but `mindxtrain/research/` was nevercommitted, so `mindxtrain research` raised `ModuleNotFoundError` on every checkout butthe author's. The package now ships: the declarative `AttemptContract`, the git fence(commit-before-measure · editable allowlist · dedup-by-commit), the bounded attemptrunner with process-group teardown, the durable append-only ledger, the keep/resetsearch loop, the Base anchor + `mindx_autoresearch_registry.sol`, the coach's read-onlyobserver page (`/coach/research`), the k8s researcher job, and the `attempt_diff` hashin the provenance manifest — so the *edit* that earned a promotion is hashed into thereceipt, not just the resulting weights.- **The Console and Science rooms' own modules.** `ui/console.py` (Ollama chat, tokenaccounting, error explanations that say what to run) and `ui/reasoning.py` (the claims/ Socratic-questions / contradictions pass, aGLM when importable and an in-housefallback otherwise), both previously uncommitted, both now covered by tests that needno daemon, GPU or optional dependency.- **dcoach page + prompt-tools + decentralized panel.** New `/coach/dcoach` workflowpage: one-click **Imprint & Prove** (persona/skills + advanced toggles) streams theproof loop live (`POST /coach/api/dcoach/run`, SSE) and shows the classroom before/after46 unmodified lines### Fixed- **The default editor corrupted any editable that was not a flat TOML.** Its docstringpromised a no-op; the code stringified a `[table]` into `trainer = "{'lr': 0.001}"`,then committed and measured that. It now checks flatness and declines, and`_write_flat_toml` refuses non-scalars instead of repr-ing them. Strings escape through`json.dumps`, so a value holding a quote or a backslash can no longer emit broken TOML.- **A failed attempt stranded HEAD on a loser.** When an attempt raised after its edit wascommitted, the loop propagated the error and left the branch on a commit it had neverscored — so the next run's baseline read the loser. The champion is restored on the wayout. The restore is `reset --hard`, so it is taken only while the fence still passes: ifthe tree is dirty outside the allowlist that work belongs to someone else, and it is leftexactly where it is.- **`mindxtrain.ui` demanded gradio for stdlib-only code.** The package eagerly imported`.app`, so the optional `ui` extra was needed to reach `console`, `reasoning` or`parse_log` — none of which import anything beyond the standard library. TheGradio-backed exports (`build`, `main`, `VERSION`) resolve lazily via PEP 562; a box thatcannot spare the dependency can still parse a training log and talk to the daemon.- **The contradiction check was asymmetric**, though documented as a truth-table check:it only fired when the negative claim happened to be written first.- **Imprint recall now measured under the trained conditioning.** `probe_recall` accepts anoptional `system` prompt and the proof loop passes the persona's system prompt to both thebefore and after probes — matching the system turn the script rows train under. Without it1 unmodified lineimprint; the CPU proof loop now reports a strong positive Δ (e.g. 0.066→0.247) and anAPPROVED verdict.### Changed- New and touched modules are ruff clean under the house config (unused imports, `typing`modernisation). Pre-existing debt elsewhere is left alone rather than folded into thisrelease.- **Removed hackathon framing from the public surfaces.** README, `pyproject.toml`description, the package docstring, `CLAUDE.md`, and the active docs (autotune /architecture / development / coach / yaml_schema / HANDOFF / NAV) no longer framemindXtrain as a hackathon submission; deleted `docs/HACKATHON.md` and`docs/hackathon_submission.md`. The frozen `docs/blueprints/` and dated dev-blogposts are preserved unchanged as the historical record. README now leads with thedcoach proof loop.## [1.0.0] — 2026-06-11First production release. **CPU training is active end-to-end**; the GPU
163 unmodified lines164165166167168169170171163 unmodified lines- [What's not measured (yet)](benchmarks.md#whats-not-measured-yet)### [CHANGELOG](CHANGELOG.md)Version history (current: v1.0.0).- [[Unreleased]](CHANGELOG.md#unreleased)- [[1.0.0] — 2026-06-11](CHANGELOG.md#100--2026-06-11)- [[0.1.0] — 2026-05-06](CHANGELOG.md#010--2026-05-06)163 unmodified lines164165166167168169170171172163 unmodified lines- [What's not measured (yet)](benchmarks.md#whats-not-measured-yet)### [CHANGELOG](CHANGELOG.md)Version history (current: v1.0.1).- [[Unreleased]](CHANGELOG.md#unreleased)- [[1.0.1] — 2026-09-15](CHANGELOG.md#101--2026-09-15)- [[1.0.0] — 2026-06-11](CHANGELOG.md#100--2026-06-11)- [[0.1.0] — 2026-05-06](CHANGELOG.md#010--2026-05-06)
15 unmodified lines1617181915 unmodified linesbudget/ psutil-derived ResourceBudget (carry-over from aGLM)"""__version__ = "1.0.0"15 unmodified lines1617181915 unmodified linesbudget/ psutil-derived ResourceBudget (carry-over from aGLM)"""__version__ = "1.0.1"
20 unmodified lines2122232425262782 unmodified lines11011111211311411515 unmodified lines13113213313413513613720 unmodified linesfrom mindxtrain.autotune.feedback import suggest_next_paramsfrom mindxtrain.research.attempt import AttemptResult, run_attemptfrom mindxtrain.research.contract import AttemptContractfrom mindxtrain.research.guard import git, repo_rootfrom mindxtrain.research.ledger import LedgerProposeEdit = Callable[[AttemptContract, AttemptResult, Ledger, Path], None]82 unmodified linesreturn Path(log_root) / researcher / f"attempt-{i:03d}"def search(contract: AttemptContract,researcher: str,15 unmodified linespropose_edit(contract, champion, ledger, root)if not _commit_editable(contract.editable, f"attempt {i}", root):break # converged: no new edit proposedresult = run_attempt(contract, researcher, _run_dir(log_root, researcher, i), ledger, root=root)if _improved(result.value, champion.value, contract.mode, contract.min_improvement):champion = resultelse:20 unmodified lines21222324252627282930313282 unmodified lines11511611711811912012112212312412512612712812913013113213313413513613713813914015 unmodified lines15615715815916016116216316416516616716820 unmodified linesfrom mindxtrain.autotune.feedback import suggest_next_paramsfrom mindxtrain.research.attempt import AttemptResult, run_attemptfrom mindxtrain.research.contract import AttemptContractfrom mindxtrain.research.guard import (ResearchAbort,assert_clean_and_committed,git,repo_root,)from mindxtrain.research.ledger import LedgerProposeEdit = Callable[[AttemptContract, AttemptResult, Ledger, Path], None]82 unmodified linesreturn Path(log_root) / researcher / f"attempt-{i:03d}"def _restore_champion(contract: AttemptContract, champion: AttemptResult, root: Path) -> bool:"""Put HEAD back on the champion after a failed attempt. Returns whether it did.An attempt that raises *after* its edit was committed would otherwise leave HEAD parkedon a loser the loop never scored — the opposite of the keep/reset contract, and not whatthe next run's baseline should read.The reset is `--hard`, so it is only taken when the fence still passes. If the tree isdirty outside the editable allowlist that dirt belongs to someone else, and discarding itto tidy up after ourselves would be worse than the mess: we leave everything untouched andlet the caller see the failure with the tree intact."""try:assert_clean_and_committed(contract.editable, root)except ResearchAbort:return Falsegit("reset", "--hard", champion.commit, cwd=root)return Truedef search(contract: AttemptContract,researcher: str,15 unmodified linespropose_edit(contract, champion, ledger, root)if not _commit_editable(contract.editable, f"attempt {i}", root):break # converged: no new edit proposedtry:result = run_attempt(contract, researcher, _run_dir(log_root, researcher, i), ledger, root=root)except Exception:_restore_champion(contract, champion, root) # never strand HEAD on a loserraiseif _improved(result.value, champion.value, contract.mode, contract.min_improvement):champion = resultelse:
35 unmodified lines3637383940414235 unmodified linesfrom .metrics import RunMetrics, parse_log # noqa: F401 (parse_log re-exported for tests)from .theme import CSS, themeVERSION = "1.0.0"HOME = Path(os.environ.get("MINDXTRAIN_HOME") or Path(__file__).resolve().parents[2])RECIPES = HOME / "mindxtrain" / "train" / "recipes"TIERS = ["Basic", "Advanced", "Scientific"]35 unmodified lines3637383940414235 unmodified linesfrom .metrics import RunMetrics, parse_log # noqa: F401 (parse_log re-exported for tests)from .theme import CSS, themeVERSION = "1.0.1"HOME = Path(os.environ.get("MINDXTRAIN_HOME") or Path(__file__).resolve().parents[2])RECIPES = HOME / "mindxtrain" / "train" / "recipes"TIERS = ["Basic", "Advanced", "Scientific"]
22 unmodified lines232425262728292 unmodified lines323334353637382 unmodified lines414243444546472 unmodified lines505152535455565758596061626364656667686970717273747576777879803 unmodified lines848586878889901 unmodified line9293949596979824 unmodified lines12312412512612712812912 unmodified lines14214314414514614714828 unmodified lines17717817918018118218311 unmodified lines19519619719819920020111 unmodified lines2132142152162172182192202212222232242252262272281 unmodified line23023123223323423523639 unmodified lines27627727827928028128222 unmodified linesimport timefrom dataclasses import dataclass, fieldfrom pathlib import Pathfrom typing import Any, Dict, List, Optional_DICT = re.compile(r"\{'(?:loss|eval_loss|train_runtime)'.*?\}")_TQDM = re.compile(r"(?:(?P<label>[A-Za-z][A-Za-z ._-]{2,30}):\s*)?(?P<pct>\d+)%\|[^|]*\|\s*"2 unmodified lines_TOKENIZING = re.compile(r"Tokenizing train dataset:.*?(\d+)/(\d+)")def _secs(hms: str) -> Optional[float]:if not hms or "?" in hms:return Noneparts = [float(x) for x in hms.split(":")]2 unmodified linesreturn parts[0] * 3600 + parts[1] * 60 + parts[2]def _fmt_secs(s: Optional[float]) -> str:if s is None:return "—"s = int(s)2 unmodified lines@dataclassclass RunMetrics:steps: List[Dict[str, float]] = field(default_factory=list)evals: List[Dict[str, float]] = field(default_factory=list)final: Dict[str, float] = field(default_factory=dict)progress: Dict[str, Any] = field(default_factory=dict) # the TRAINING bareval_progress: Dict[str, Any] = field(default_factory=dict) # the evaluation loop's own barthrottle: Dict[str, int] = field(default_factory=dict)warnings: List[str] = field(default_factory=list)phases: List[str] = field(default_factory=list)dataset_rows: Optional[int] = None# ── the few fields other rooms read ──@propertydef last_step(self) -> Optional[int]:return self.progress.get("step") or (len(self.steps) or None)@propertydef train_loss(self) -> Optional[float]:return self.final.get("train_loss") or (self.steps[-1].get("loss") if self.steps else None)@propertydef eval_loss(self) -> Optional[float]:return self.evals[-1].get("eval_loss") if self.evals else None# ── derived, honestly ──def rate(self) -> Dict[str, Optional[float]]:"""Throughput as the trainer reports it — seconds per step, tokens per second, ETA."""s_it = self.progress.get("s_per_it")tok = self.steps[-1].get("num_tokens") if self.steps else None3 unmodified lines"tokens_per_s": (per_step / s_it) if (per_step and s_it) else None,"eta_s": self.progress.get("eta_s"), "elapsed_s": self.progress.get("elapsed_s")}def trend(self, key: str, window: int = 10) -> Optional[float]:"""Change in a metric over the last `window` logged steps (late mean − early mean)."""vals = [s[key] for s in self.steps if key in s and isinstance(s[key], (int, float))]if len(vals) < 4:1 unmodified linew = min(window, len(vals) // 2)return round(sum(vals[-w:]) / w - sum(vals[:w]) / w, 4)def diagnose(self) -> List[str]:"""What an operator would want said out loud. Each line is a fact plus its consequence."""out = list(self.warnings)dl = self.trend("loss")24 unmodified linesreturn out# ── rendering ──def headline(self, running: bool, started: Optional[float] = None) -> str:p = self.progressbar = ""if p.get("total"):12 unmodified linesdiag = "<br>".join("· " + d for d in self.diagnose()[:4])return f"<div class='mx-kiln'>{bar}{' · '.join(bits)}<div class='mx-diag'>{diag}</div></div>"def rows(self, scientific: bool = False) -> List[List[Any]]:"""metric · value · unit · where it came from."""s = self.steps[-1] if self.steps else {}e = self.evals[-1] if self.evals else {}28 unmodified lines]return rowsdef frame(self) -> Dict[str, List[Any]]:"""Long-form rows for the plot: loss, token accuracy, and lr normalised to its own max."""xs, ms, vs = [], [], []lrs = [s.get("learning_rate") for s in self.steps if isinstance(s.get("learning_rate"), (int, float))]11 unmodified linesdef tail(log: Path, n: int = 60) -> str:try:lines = [ln.rstrip() for ln in log.read_text(errors="replace").splitlines() if ln.strip()]except Exception: # noqa: BLE001return ""return "\n".join(ln[-400:] for ln in lines[-n:])11 unmodified linesreturn str(v)def parse_log(log: Optional[Path]) -> RunMetrics:"""Read a training log into metrics. Tolerant by design: a half-written line is skipped, never fatal."""m = RunMetrics()if not log:return mtry:text = Path(log).read_text(errors="replace")except Exception: # noqa: BLE001return mbars: List[Dict[str, Any]] = []for raw in text.splitlines():line = raw.strip()if not line:1 unmodified linefor d in _DICT.findall(line):try:rec = ast.literal_eval(d)except Exception: # noqa: BLE001continuerec = {k: (float(v) if isinstance(v, str) and re.fullmatch(r"[-+0-9.eE]+", v) else v) for k, v in rec.items()}if "train_runtime" in rec:39 unmodified lines# eval bar at the end, because tqdm redraws each eval bar many times. The one that holds is# the CLOCK: the training bar's elapsed runs for the whole run (1:10:00 here) while every eval# bar's elapsed restarts from zero.by_total: Dict[int, float] = {}for b in bars:by_total[b["total"]] = max(by_total.get(b["total"], 0.0), b.get("elapsed_s") or 0.0)train_total = max(by_total, key=lambda t: by_total[t])22 unmodified lines232425262728292 unmodified lines323334353637382 unmodified lines414243444546472 unmodified lines505152535455565758596061626364656667686970717273747576777879803 unmodified lines848586878889901 unmodified line9293949596979824 unmodified lines12312412512612712812912 unmodified lines14214314414514614714828 unmodified lines17717817918018118218311 unmodified lines19519619719819920020111 unmodified lines2132142152162172182192202212222232242252262272281 unmodified line23023123223323423523639 unmodified lines27627727827928028128222 unmodified linesimport timefrom dataclasses import dataclass, fieldfrom pathlib import Pathfrom typing import Any_DICT = re.compile(r"\{'(?:loss|eval_loss|train_runtime)'.*?\}")_TQDM = re.compile(r"(?:(?P<label>[A-Za-z][A-Za-z ._-]{2,30}):\s*)?(?P<pct>\d+)%\|[^|]*\|\s*"2 unmodified lines_TOKENIZING = re.compile(r"Tokenizing train dataset:.*?(\d+)/(\d+)")def _secs(hms: str) -> float | None:if not hms or "?" in hms:return Noneparts = [float(x) for x in hms.split(":")]2 unmodified linesreturn parts[0] * 3600 + parts[1] * 60 + parts[2]def _fmt_secs(s: float | None) -> str:if s is None:return "—"s = int(s)2 unmodified lines@dataclassclass RunMetrics:steps: list[dict[str, float]] = field(default_factory=list)evals: list[dict[str, float]] = field(default_factory=list)final: dict[str, float] = field(default_factory=dict)progress: dict[str, Any] = field(default_factory=dict) # the TRAINING bareval_progress: dict[str, Any] = field(default_factory=dict) # the evaluation loop's own barthrottle: dict[str, int] = field(default_factory=dict)warnings: list[str] = field(default_factory=list)phases: list[str] = field(default_factory=list)dataset_rows: int | None = None# ── the few fields other rooms read ──@propertydef last_step(self) -> int | None:return self.progress.get("step") or (len(self.steps) or None)@propertydef train_loss(self) -> float | None:return self.final.get("train_loss") or (self.steps[-1].get("loss") if self.steps else None)@propertydef eval_loss(self) -> float | None:return self.evals[-1].get("eval_loss") if self.evals else None# ── derived, honestly ──def rate(self) -> dict[str, float | None]:"""Throughput as the trainer reports it — seconds per step, tokens per second, ETA."""s_it = self.progress.get("s_per_it")tok = self.steps[-1].get("num_tokens") if self.steps else None3 unmodified lines"tokens_per_s": (per_step / s_it) if (per_step and s_it) else None,"eta_s": self.progress.get("eta_s"), "elapsed_s": self.progress.get("elapsed_s")}def trend(self, key: str, window: int = 10) -> float | None:"""Change in a metric over the last `window` logged steps (late mean − early mean)."""vals = [s[key] for s in self.steps if key in s and isinstance(s[key], (int, float))]if len(vals) < 4:1 unmodified linew = min(window, len(vals) // 2)return round(sum(vals[-w:]) / w - sum(vals[:w]) / w, 4)def diagnose(self) -> list[str]:"""What an operator would want said out loud. Each line is a fact plus its consequence."""out = list(self.warnings)dl = self.trend("loss")24 unmodified linesreturn out# ── rendering ──def headline(self, running: bool, started: float | None = None) -> str:p = self.progressbar = ""if p.get("total"):12 unmodified linesdiag = "<br>".join("· " + d for d in self.diagnose()[:4])return f"<div class='mx-kiln'>{bar}{' · '.join(bits)}<div class='mx-diag'>{diag}</div></div>"def rows(self, scientific: bool = False) -> list[list[Any]]:"""metric · value · unit · where it came from."""s = self.steps[-1] if self.steps else {}e = self.evals[-1] if self.evals else {}28 unmodified lines]return rowsdef frame(self) -> dict[str, list[Any]]:"""Long-form rows for the plot: loss, token accuracy, and lr normalised to its own max."""xs, ms, vs = [], [], []lrs = [s.get("learning_rate") for s in self.steps if isinstance(s.get("learning_rate"), (int, float))]11 unmodified linesdef tail(log: Path, n: int = 60) -> str:try:lines = [ln.rstrip() for ln in log.read_text(errors="replace").splitlines() if ln.strip()]except Exception:return ""return "\n".join(ln[-400:] for ln in lines[-n:])11 unmodified linesreturn str(v)def parse_log(log: Path | None) -> RunMetrics:"""Read a training log into metrics. Tolerant by design: a half-written line is skipped, never fatal."""m = RunMetrics()if not log:return mtry:text = Path(log).read_text(errors="replace")except Exception:return mbars: list[dict[str, Any]] = []for raw in text.splitlines():line = raw.strip()if not line:1 unmodified linefor d in _DICT.findall(line):try:rec = ast.literal_eval(d)except Exception:continuerec = {k: (float(v) if isinstance(v, str) and re.fullmatch(r"[-+0-9.eE]+", v) else v) for k, v in rec.items()}if "train_runtime" in rec:39 unmodified lines# eval bar at the end, because tqdm redraws each eval bar many times. The one that holds is# the CLOCK: the training bar's elapsed runs for the whole run (1:10:00 here) while every eval# bar's elapsed restarts from zero.by_total: dict[int, float] = {}for b in bars:by_total[b["total"]] = max(by_total.get(b["total"], 0.0), b.get("elapsed_s") or 0.0)train_total = max(by_total, key=lambda t: by_total[t])
123456[project]name = "mindxtrain"version = "1.0.0"description = "Production training framework for fine-tuning open-weight LLMs on AMD MI300X and serving them through an OpenAI-compatible API."requires-python = ">=3.12,<3.13"license = { text = "Apache-2.0" }123456[project]name = "mindxtrain"version = "1.0.1"description = "Production training framework for fine-tuning open-weight LLMs on AMD MI300X and serving them through an OpenAI-compatible API."requires-python = ">=3.12,<3.13"license = { text = "Apache-2.0" }
10 unmodified lines11121314151622 unmodified lines394041424344178 unmodified lines22322422510 unmodified linesimport subprocessimport sysimport tomllibfrom pathlib import Pathimport pytest22 unmodified linessubprocess.run(["git", "-C", str(repo), *args], check=True, capture_output=True, text=True)@pytest.fixturedef repo(tmp_path: Path) -> Path:_git(tmp_path, "init", "-b", "main")178 unmodified linesdef test_flat_toml_refuses_a_nested_value(tmp_path: Path) -> None:with pytest.raises(TypeError, match="not a flat TOML scalar"):_write_flat_toml(tmp_path / "p.toml", {"trainer": {"lr": 0.1}})10 unmodified lines1112131415161722 unmodified lines404142434445464748495051525354555657178 unmodified lines23623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329410 unmodified linesimport subprocessimport sysimport tomllibfrom importlib import import_modulefrom pathlib import Pathimport pytest22 unmodified linessubprocess.run(["git", "-C", str(repo), *args], check=True, capture_output=True, text=True)def _head(repo: Path) -> str:out = subprocess.run(["git", "-C", str(repo), "rev-parse", "HEAD"],check=True, capture_output=True, text=True)return out.stdout.strip()def _status(repo: Path) -> str:out = subprocess.run(["git", "-C", str(repo), "status", "--porcelain"],check=True, capture_output=True, text=True)return out.stdout.strip()@pytest.fixturedef repo(tmp_path: Path) -> Path:_git(tmp_path, "init", "-b", "main")178 unmodified linesdef test_flat_toml_refuses_a_nested_value(tmp_path: Path) -> None:with pytest.raises(TypeError, match="not a flat TOML scalar"):_write_flat_toml(tmp_path / "p.toml", {"trainer": {"lr": 0.1}})# --- a failed attempt must not strand HEAD on a loser ------------------------------------def _raise_after_baseline(monkeypatch, exc: Exception):"""Let the baseline attempt run for real, then fail every attempt after it."""# import_module, not `from mindxtrain.research import search`: the package re-exports the# search *function* under that name, which shadows the submodule.search_mod = import_module("mindxtrain.research.search")real = search_mod.run_attemptcalls = {"n": 0}def flaky(*a, **kw): # type: ignore[no-untyped-def]calls["n"] += 1if calls["n"] == 1:return real(*a, **kw)raise excmonkeypatch.setattr(search_mod, "run_attempt", flaky)return callsdef test_failed_attempt_restores_the_champion(repo: Path, monkeypatch) -> None: # type: ignore[no-untyped-def]"""Regression: the loop used to leave HEAD on the unscored attempt commit."""_raise_after_baseline(monkeypatch, RuntimeError("runner exploded"))head_before = _head(repo)with pytest.raises(RuntimeError, match="runner exploded"):search(_contract(repo), "r", repo / "out", 3, _increasing_edit(1.0), root=repo)assert _head(repo) == head_before # back on the champion, not the loserassert float((repo / "value.txt").read_text()) == 1.0assert not _status(repo) # and the tree is cleandef test_failed_attempt_never_discards_unrelated_work(repo: Path, monkeypatch) -> None: # type: ignore[no-untyped-def]"""`reset --hard` is refused when the dirt outside the allowlist is somebody else's.The stray file lands *during* the attempt — a colleague saving work in the same treewhile the search runs — so the baseline's own fence passes and the refusal is therestore's decision, not an abort on the way in."""_raise_after_baseline(monkeypatch, RuntimeError("runner exploded"))stray = repo / "someone_elses_work.txt"def edit_and_intrude(contract, champion, ledger, root) -> None: # type: ignore[no-untyped-def]path = root / "value.txt"path.write_text(f"{float(path.read_text()) + 1.0}\n", encoding="utf-8")stray.write_text("hours of it\n", encoding="utf-8")with pytest.raises(RuntimeError, match="runner exploded"):search(_contract(repo), "r", repo / "out", 3, edit_and_intrude, root=repo)assert stray.read_text(encoding="utf-8") == "hours of it\n" # untouched by the cleanup
docs/CHANGELOG.md+50-8
docs/NAV.md+2-1
mindxtrain/__init__.py+1-1
mindxtrain/research/search.py+33-2
mindxtrain/ui/app.py+1-1
mindxtrain/ui/metrics.py+27-27
pyproject.toml+1-1
tests/test_research_search.py+69