Skip to content

test(git): one git seam answers tests from recorded git transcripts, with a contract suite that replays them #2146

Closed

Description

@dan-petty

What happened

#2143 records the owner's rule of 2026-10-24: a test of src/ starts no program, and each real tool other than the process runner's children goes to a recorded contract suite or a devops ci row. git is the program that tests start most. The test-suite audit at df8e2ee saw 705 tests start git, with a median of 6 git starts per test and up to 37. A test that starts only git has a median time of 0.194 s, against 0.026 s for a test that starts nothing.

devops-cli has no git fake to move these tests to. git is reached two ways:

  • the process runner, with CONST_GIT_CLI (for example core/repo.py, git/operations.py, git/worktree.py, ai/review/runner.py, roadmap/run.py, ci/fail_to_pass.py, k8s/argocd_gate.py);
  • GitPython, which starts git through its own subprocess.Popen (git/operations.py:18, commands/repos.py:70, ai/research/edges.py:244). The process fake does not see these starts.

What should happen

git is one edge with one seam, one shared fake and one contract suite:

  • The fake answers each git command from a recorded transcript: the arguments, the exit code, the standard output and the standard error.
  • The contract suite replays each transcript through the real seam code over the process fake, and through the git fake, and checks that both give the same result.
  • A devops ci row records the transcripts again with the real git, outside pytest, and fails when a transcript changed. git is installed on the stock runner, so the row needs no install.

Evidence

  • .data/agent/scratch/audit/full_list.txt of the 2026-10-24 audit, section 1.git (705 tests), and the cost summary.
  • git grep -c -E "CONST_GIT_CLI|\[\"git\"" origin/main -- src at b170358: 15 modules.
  • tests/support/fakes/ at b170358 holds no git fake.

Key questions

  • Where is the seam? (proposed) The process runner (core/process.py, ProcessRunner), which already owns every other program. GitPython's three users either move to the runner or reach GitPython through the same seam. The pull request picks one and records why in the ## Feasibility section of its proposal.
  • Which commands are recorded? (proposed) The commands that the follow-up issues need, listed by the migrating issues. A test that needs a command with no transcript adds it with the recording row.

Acceptance criteria

  • Every start of git in src/ goes through one seam. rg -n "subprocess" src/devops_cli shows no start of git outside it.
  • tests/support/fakes/git.py holds the git fake. A fixture installs it through the seam.
  • The transcripts are files under tests/fixtures/git/. Their paths hold no host path, user name or e-mail address (example.com only).
  • The contract suite runs every transcript over the real seam code and over the fake. It starts no program.
  • A devops ci row records the transcripts with the real git and fails when one differs. The row runs on the stock runner and keeps its CI job under 5 minutes, measured in the pull request.
  • tests/test_git_operations.py, tests/test_git_worktree.py and tests/test_core_repo.py use the fake and start no git.
  • uv run devops ci passes.

Follows ADR 0007 as #2143 amends it. Each per-package migration issue of the same audit waits for this item.

Source: #2143

Proposed design

Problem statement

Tests of src/ start real git processes. The 2026-10-24 audit found 705 tests that start git, with a median of 6 starts per test. A test that starts only git takes a median of 0.194 s, against 0.026 s for a test that starts nothing. devops-cli has no git fake in tests/support/fakes/. This issue creates one git fake, one shared seam, and one contract suite so that tests answer git commands from recorded transcripts and start no program.

Acceptance criteria

  • Criterion 1: Every start of git in src/ goes through one seam.
    Verification: Run rg -n "subprocess" src/devops_cli. The output shows no start of git outside the seam.
  • Criterion 2: The git fake lives in tests/support/fakes/git.py and a fixture installs it through the seam.
    Verification: Open tests/support/fakes/git.py. Confirm it holds the fake. Run the test suite. Confirm the fixture installs the fake through the seam.
  • Criterion 3: Transcripts are files under tests/fixtures/git/ and hold no host path, user name, or e-mail address.
    Verification: List tests/fixtures/git/. Search each file for a host path, user name, or e-mail address. The only allowed e-mail domain is example.com.
  • Criterion 4: The contract suite runs every transcript over the real seam code and over the fake, and starts no program.
    Verification: Run the contract suite. Confirm it replays each transcript through both paths. Confirm no subprocess starts during the run.
  • Criterion 5: A devops ci row records the transcripts with the real git and fails when one differs.
    Verification: Run uv run devops ci on the stock runner. Confirm the row records transcripts. Change a transcript and confirm the row fails. Measure the CI job time. It is under 5 minutes.
  • Criterion 6: tests/test_git_operations.py, tests/test_git_worktree.py, and tests/test_core_repo.py use the fake and start no git.
    Verification: Run these three test files. Confirm they use the fake. Confirm no git process starts during the run.
  • Criterion 7: uv run devops ci passes.
    Verification: Run uv run devops ci. The exit code is 0.

Key questions

  • Where is the seam?: The process runner (core/process.py, ProcessRunner). It already owns every other program and already handles CONST_GIT_CLI. GitPython's three users either move to the runner or reach GitPython through the same seam. The pull request picks one and records why in its ## Feasibility section. (proposed) [sources: src/devops_cli/core/process.py:406, src/devops_cli/core/process.py:335, src/devops_cli/config/constants.py:1365]
  • Which commands are recorded?: The commands that the follow-up issues need, listed by the migrating issues. A test that needs a command with no transcript adds it with the recording row. (proposed)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#2143

Activity

  1. added
    source/agent
    type/test
    on Oct 24, 2026
  2. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/test. The candidate proposes changes to test infrastructure including fakes and contract suites.
    • Priority: P2-Medium. This change improves test performance and reliability but is not critical for immediate project needs.
    • Value: High. Improving test performance and reducing reliance on external tools benefits all developers and CI runs.
    • Effort: High. Implementing a comprehensive git fake with contract suite requires significant development effort across multiple modules.
    • Related: test(ci): the suite's slowest tests run on recorded scanner and installer results, not real semgrep, gitleaks, bandit, uv audit, uv pip sync or sudo #1666, which asks for a different change. Both items address test performance by using recorded results instead of real tools, but the candidate uses a git fake while item 1666 uses recorded scanner and installer results.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at bb46660 (see proposed design in issue body).

  4. added
    priority/p2-medium
    status/ready
    effort/high
    value/high
    on Oct 28, 2026
  5. added
    status/in-review
    and removed
    status/ready
    on Oct 30, 2026
  6. removed
    status/in-review
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highpriority/p2-mediumsource/agenttype/testvalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions