feat(run): the repository under review is the freeze record's, not the working directory's

A directory can review repositories other than itself: a workbench whose
config, env file and records serve several, freezing each with --repo and
--out. The run took the working directory for the repository under review:
the prompt named it, the calibration was kept under it, and --trees fell
back to it. The run now reads the repository from the artifact's
freeze.json - the prompt names it and the calibration is kept under it -
and --trees defaults to what the record says: the worktree, else the
repository when it is not the working directory, else `.`, the same rule
that builds the printed run line. The working directory keeps its roles:
the config, the env file, the slots, the lens processes' cwd and every
logged path. A damaged record stops the run at preflight.
This commit is contained in:
Jorijn van der Graaf 2026-10-31 21:31:48 +01:00
commit 4fc15fe1c2
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
9 changed files with 133 additions and 14 deletions

View file

@ -170,6 +170,28 @@ int main() {
g({"merge", "-q", "--no-ff", "-m", "merge side", "side"});
const Json r3 = freeze({.base = base, .replace = true});
Check("merge in the range refused", !r3.at("ok").get<bool>() && AnyContains(r3.at("failures"), "merge commit"));
// What a run reads from the record: the repository under review and the
// tree the lenses read (a workbench freezing another repository with
// --repo: the record names it, not the working directory).
const Json withTree = {{"repo", repo.string()}, {"worktree", "x/y"}};
const Json repoOnly = {{"repo", repo.string()}};
Check("TreeOf: the record's worktree, else the repository when it is not the working directory, else `.`",
Freeze::TreeOf(withTree, td) == "x/y" && Freeze::TreeOf(repoOnly, td) == repo.string() && Freeze::TreeOf(repoOnly, repo) == "." && Freeze::TreeOf(Json::object(), td) == ".");
const Freeze::Reviewed byRecord = Freeze::ReviewedBy(out, td);
const fs::path none = td / "no-record";
fs::create_directories(none);
const Freeze::Reviewed byNone = Freeze::ReviewedBy(none, td);
std::ofstream(none / "freeze.json", std::ios::binary) << "{broken";
bool damaged = false;
try {
Freeze::ReviewedBy(none, td);
} catch (const std::runtime_error& e) {
damaged = std::string(e.what()).contains("not a freeze record");
}
Check("ReviewedBy: the record's repository and its tree; no record: the working directory and `.`; a damaged record throws, saying so",
fs::weakly_canonical(byRecord.repo) == fs::weakly_canonical(repo) && byRecord.tree == Dyn::AbsPath(repo.string()) && Freeze::ReviewedBy(out, repo).tree == "." && byNone.repo == td
&& byNone.tree == "." && damaged,
std::format("{} {} {}", byRecord.repo.string(), byRecord.tree, byNone.tree));
g({"worktree", "remove", "--force", wt.string()});
fs::remove_all(td);
return Failures ? 1 : 0;