abc_mine.repo¶
WARNING
This documentation is almost entirely "vibe coded"; while a helpful resource for humans and agents to understand this codebase, it should not be considered a source of ground truth in the way documentation normally is, and the user is responsible for verifying that all instructions given here are safe.
abc_mine.repo
¶
Git operations: commit enumeration, selection, worktrees, starting states.
Three responsibilities:
- Enumerate and select commits from an arbitrary repository, with mechanical pre-filters that drop obviously-unusable commits before any model sees them.
- Isolate each commit in its own worktree, so parallel workers never contend over one working tree.
- Build a starting state — a repository that stops dead at a chosen commit —
via the bundle-cutoff procedure described in :func:
build_cutoff_workspace.
The bundle-cutoff procedure is the correctness keystone of the whole tool and is carried over essentially unchanged from the original Truchas pipeline, where it was validated against a real 1600-commit history. It is fully deterministic and involves no agent.
GitError
¶
CutoffError
¶
Commit
dataclass
¶
One commit, as a unit of work.
Attributes:
| Name | Type | Description |
|---|---|---|
sha |
str
|
Full 40-hex commit SHA. |
parent |
str
|
First-parent SHA; empty for the root commit. Only the first parent is retained: for a merge, the diff against the first parent is what corresponds to "the change this commit introduced". |
subject |
str
|
Commit subject line. |
author_date |
str
|
Author date, ISO-8601, for provenance and reporting. |
is_merge |
bool
|
Whether the commit has more than one parent. |
files_changed |
int
|
Number of files touched (populated by :func: |
diff_lines |
int
|
Added + deleted line count (populated by :func: |
Source code in abc_mine/repo.py
SelectionReport
dataclass
¶
What selection did, and why — for the terminal and the manifest.
Making each filter's toll explicit matters: "screening 180 of 1633 commits" is only reassuring if you can see that 1,200 were dropped as merges rather than silently lost to a misconfigured pathspec.
Source code in abc_mine/repo.py
describe
¶
Render a human-readable summary of the funnel.
Source code in abc_mine/repo.py
CutoffResult
dataclass
¶
Outcome of :func:build_cutoff_workspace.
Attributes:
| Name | Type | Description |
|---|---|---|
cutoff_sha |
str
|
The resolved commit the workspace stops at (its |
object_count |
int
|
Objects physically present in the result's object database — recorded in the manifest as evidence the cutoff was exact. |
Source code in abc_mine/repo.py
git
¶
Run git -C repo <args> and return stdout.
Raises:
| Type | Description |
|---|---|
GitError
|
If |
Source code in abc_mine/repo.py
require_repo
¶
Validate that repo is a complete, non-shallow git repository.
Shallowness is checked explicitly because it breaks the cutoff procedure in a way that would otherwise surface much later, as a confusing integrity-check failure deep inside the build stage.
Source code in abc_mine/repo.py
enumerate_commits
¶
enumerate_commits(repo: Path, *, paths: Sequence[str] = ()) -> list[Commit]
Enumerate commits, newest first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
Path
|
The repository to read. |
required |
paths
|
sequence of str
|
Pathspecs; when given, only commits touching them are returned. Applied by git itself, so it is far cheaper than filtering afterwards. |
()
|
Notes
Fields are read from a single NUL-delimited git log, which is robust to
subjects containing arbitrary punctuation, quotes, or newline-adjacent
whitespace.
Source code in abc_mine/repo.py
annotate
¶
Attach files_changed / diff_lines to each commit.
Uses one git log --numstat pass over the whole set rather than one
diff-tree per commit: on a history of a few thousand commits that is the
difference between well under a second and tens of seconds.
Source code in abc_mine/repo.py
select
¶
select(commits: Sequence[Commit], selection: Any, *, report: SelectionReport | None = None) -> list[Commit]
Apply mechanical filters and the selection mode, preserving order.
Filters run before the mode, so recent: 100 means "100 usable
commits", not "whatever survives of the newest 100" — which is what you
actually want when sizing a validation slice.
Commits without a parent are always dropped: a starting state is defined as "the repository at the parent commit", which the root commit does not have.
Source code in abc_mine/repo.py
commit_diff
¶
Return (diff_text, truncated) for the change sha introduced.
Truncation is reported rather than hidden so the prompt can tell the agent its view is partial — an agent that believes it saw a whole diff may confidently mis-score a commit whose substance was cut off.
Source code in abc_mine/repo.py
commit_message
¶
Return the full commit message body for sha.
The message is the calibration point for how much a constructed task prompt should reveal, so the build stage needs it verbatim rather than paraphrased.
Source code in abc_mine/repo.py
touched_files
¶
Return the paths touched by sha.
matches_any
¶
worktree
¶
Yield a worktree of repo checked out at sha, then remove it.
Each work item gets its own worktree so parallel workers never fight over one
working tree (and so an agent that dirties its tree cannot corrupt another's).
Stale registrations at dest are cleared first, and cleanup is best-effort
on the way out — an agent may well leave build products behind, and that must
not fail the job that just succeeded.
The worktree is created locked. dest is usually node-local scratch, so
on a multi-node job another node's git worktree prune cannot see it and
would delete its registration mid-run; prune never touches locked entries.
Source code in abc_mine/repo.py
checkout_detached
¶
Force-checkout sha detached in an existing worktree.
Discards local changes, so the result is a clean snapshot. Used by the build stage to materialize the post-change tree for its PASS-side polarity check.
Source code in abc_mine/repo.py
build_cutoff_workspace
¶
build_cutoff_workspace(repo: Path, cutoff: str, dest: Path, *, forbidden_sha: str | None = None) -> CutoffResult
Build a fresh repository at dest whose history stops at cutoff.
This is how a benchmark's starting state is produced, and it is deliberately agent-free and deterministic: an agent asked to "remove the change" would introduce exactly the kind of subtle, unauditable variation a benchmark cannot tolerate.
Procedure: a self-contained bundle of precisely the objects reachable from
cutoff is created from the source, then fetched into a brand-new
git init repository. The result has
- working tree and
HEADatcutoff; - genuine ancestor history, so
git log/blame/showbehave normally — an agent solving the task sees a real repository, not a history-less snapshot; - no descendant objects, so the reference solution cannot be recovered from the workspace;
- no configured remote, so later history cannot be fetched back;
- a real
.gitdirectory — unlike agit worktree, whose.gitis a pointer file that dangles once copied, which matters because abc-runner copies the workspace verbatim.
Every one of those properties is then asserted below rather than assumed. The negative checks are the important ones: a workspace that leaked post-cutoff objects would silently hand solvers the answer, and no test of the emitted benchmark would reveal it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
Path
|
Trusted, complete source repository. |
required |
cutoff
|
str
|
Revision to stop at (typically the parent of the change commit). |
required |
dest
|
Path
|
Destination directory; must not already exist. |
required |
forbidden_sha
|
str
|
A known descendant (normally the change commit) asserted to be absent. |
None
|
Raises:
| Type | Description |
|---|---|
CutoffError
|
If the source is shallow, |
Source code in abc_mine/repo.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |