Official Codebase of 3DCodeVerse
Python
record: 'does the repo have this commit' is Workspace.has_commit only — record/_git.commit_exists ran the same cat-file probe
gaoypenga73fabd09421
diff --git a/harness/codeverse3d/addons/dataset/pairs.py b/harness/codeverse3d/addons/dataset/pairs.pyindex 296a22a6..a6006309 100644--- a/harness/codeverse3d/addons/dataset/pairs.py+++ b/harness/codeverse3d/addons/dataset/pairs.py@@ -179,7 +179,7 @@ def in_round_repair_pairs(ws: Workspace, rec: RunRecord, *, slug: str | None = Nif "repair attempts:" not in rnd.notes or "(fixed)" not in rnd.notes:continuegenerated = _git.commit_by_subject(ws, f"r{rnd.index:02d} {rnd.kind}: generated")- if not generated or generated == rnd.commit or not _git.commit_exists(ws, generated):+ if not generated or generated == rnd.commit or not ws.has_commit(generated):continuetry:raw = _git.read_tree_at(ws, generated)diff --git a/harness/codeverse3d/addons/dataset/sample.py b/harness/codeverse3d/addons/dataset/sample.pyindex 7b11cad0..7c9a4f8f 100644--- a/harness/codeverse3d/addons/dataset/sample.py+++ b/harness/codeverse3d/addons/dataset/sample.py@@ -153,7 +153,7 @@ def exported_round(ws: Workspace, record: RunRecord) -> RoundRecord | None:def code_files_for_round(ws: Workspace, rnd: RoundRecord | None) -> tuple[dict[str, bytes], str]:"""Raw code tree for a round → ``(files, source)`` where source is ``commit``,``deliverable`` (the packaged snapshot of the handed-over round) or ``working_tree``."""- if rnd is not None and rnd.commit and _git.commit_exists(ws, rnd.commit):+ if rnd is not None and rnd.commit and ws.has_commit(rnd.commit):return _git.read_tree_at(ws, rnd.commit), "commit"packaged = _deliverable_code(ws)if packaged:diff --git a/harness/codeverse3d/record/_git.py b/harness/codeverse3d/record/_git.pyindex 258822e7..f954682f 100644--- a/harness/codeverse3d/record/_git.py+++ b/harness/codeverse3d/record/_git.py@@ -62,16 +62,6 @@ def commit_by_subject(ws: Workspace, subject: str) -> str | None:return None-def commit_exists(ws: Workspace, commit: str) -> bool:- if not commit:- return False- try:- _run(ws, "cat-file", "-e", f"{commit}^{{commit}}")- return True- except GitReadError:- return False--def _keep(rel: str) -> bool:parts = Path(rel).partsreturn bool(parts) and parts[0] in CODE_ROOTS and not any(p in _SKIP_PARTS for p in parts)@@ -87,7 +77,7 @@ def read_tree_at(ws: Workspace, commit: str, *, paths: Collection[str] | None =core.attributesFile=/dev/null`` only silences the GLOBAL attributes file; thein-repo ``.gitattributes`` and ``.git/info/attributes`` are still read).``cat-file`` hands back the raw blob and applies no filter unless asked."""- if not commit_exists(ws, commit):+ if not ws.has_commit(commit):raise GitReadError(f"commit {commit!r} not found in {ws.root}")entries: list[tuple[str, str]] = [] # (blob sha, path)out = _run(ws, "ls-tree", "-r", "-z", commit, "--", *CODE_ROOTS).stdoutdiff --git a/harness/codeverse3d/record/deliverable.py b/harness/codeverse3d/record/deliverable.pyindex 9d6aaa2f..eb105229 100644--- a/harness/codeverse3d/record/deliverable.py+++ b/harness/codeverse3d/record/deliverable.py@@ -130,7 +130,7 @@ def _code_tree(ws: Workspace, rnd: RoundRecord | None) -> tuple[dict[str, bytes]"""``src/**`` (+ ``public/**``) at the round's commit, else the working tree."""if rnd is not None and rnd.commit:try:- if _git.commit_exists(ws, rnd.commit):+ if ws.has_commit(rnd.commit):return _git.read_tree_at(ws, rnd.commit), "commit"except _git.GitReadError as e:log.warning("deliverable: git read failed in %s: %s", ws.root, e)diff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.mdindex 23417845..c5c5e500 100644--- a/harness/docs/INTERFACES.md+++ b/harness/docs/INTERFACES.md@@ -634,7 +634,7 @@ from codeverse3d.addons.dataset.refine import build_refine, transitions, RefineT# one row per round i -> i+1 the harness asked to change; outcome improved|regressed|unchanged|unscored# (threshold: pairs.MIN_PREFERENCE_DELTA); dropped rows carry the reason (no_predecessor / no_commit /# predecessor_build_failed / predecessor_unjudged / git_read_failed / duplicate_run)-from codeverse3d.record._git import read_tree_at, diff_between, changed_files_between, commit_exists, GitReadError+from codeverse3d.record._git import read_tree_at, diff_between, changed_files_between, GitReadError# read_tree_at(ws, commit, *, paths=None) -> {path: bytes} via ls-tree + cat-file --batch — NEVER# `git archive`, which renders content through a planted filter.<name>.smudge and has no --no-filters# (tests/flywheel_cli); symlinks (mode 120000) are skipped; `paths` reads only those files@@ -644,7 +644,7 @@ from codeverse3d.record.record import unique_files, SUBRUN_DIRS, BATTERY_MARKERS# one walker behind eval/bench/session_stats.py and eval/bench/coupling_stats.py (costreport.audit.find_runs# skips SUBRUN_DIRS the same way)# diff_between(ws, before, after, *, max_bytes=None) -> (text, untruncated size, was_truncated)- # changed_files_between(ws, before, after) -> [path]; commit_exists(ws, commit) -> bool+ # changed_files_between(ws, before, after) -> [path]; "is the commit there?" is Workspace.has_commit# both under GIT_SAFE_DIFF_FLAGS (--no-ext-diff --no-textconv) on top of workspace.GIT_SAFE_FLAGSfrom codeverse3d.workspace import GIT_SAFE_FLAGS, GIT_SAFE_DIFF_FLAGS, git_safe_env# every read of an agent-written repo goes through these. They do NOT disable .git/config —