Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-18
skip_specs: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Design

## Decisions
- The code's git gets the same isolation as the git that builds the repository: `GIT_CONFIG_NOSYSTEM=1` and `GIT_CONFIG_GLOBAL=os.devnull`. Then no host file changes a recording.
- The three new tests lock the behavior: the environment, the recorded complexity fact, and the idempotence of the recorder.

## Rejected alternatives
- Record again on each host: the file would differ between the devcontainer, the runner image and CI, so the `git` row would fail on one of them.
- Record inside the container image only: the devcontainer and the runner image still record on their own hosts, so the drift stays.
- Change the code to give the recorded commands: no source shows that the code is wrong, and the recorded order does not match the code.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Proposal: #4865

## Why

The git transcript of `review_window` (`tests/fixtures/git/review_window.json`) did not match the code: the two contract cases of `review_window` failed and the `git` row of `devops ci` reported a difference. The code's git read the system configuration file of the host (`/etc/gitconfig`), because `Workspace.environment()` set `HOME`, `LC_ALL` and `DEVOPS_CLI_USER_DATA_ROOT` only, while the git that builds the repository sets `GIT_CONFIG_NOSYSTEM` and `GIT_CONFIG_GLOBAL`. A recording was therefore not the same on every host. Closes #4865.

## What Changes

- `Workspace.environment()` in `tests/support/git_scenarios.py` sets `GIT_CONFIG_NOSYSTEM` at `1` and `GIT_CONFIG_GLOBAL` at `os.devnull`, as `setup_env` does for the git that builds the repository.
- `tests/core/test_git_recording.py` gains a test of that environment, a test that the `review_window` transcript holds `lizard.complexity` with status `ok` and three files, and a test that two recordings of the scenario give the same text.
- The change alters no behavior a consumer observes: it edits the test harness and its tests, so it sets `skip_specs: true`.

## Capabilities

None. The change is test infrastructure and adds no capability.

## Impact

- A recording of `review_window` is the same on every host, and the `git` row passes.
- The change fits one pull request.

## Feasibility

- Read 2026-11-18 with git 2.55.0 and lizard 1.26.1: `uv run pytest tests/core/test_git_contract.py -k review_window` passes, and `uv run python -c "import sys; from tests.support.git_recording import main; sys.exit(main(['--check']))"` reports that the 20 transcripts match.
- The committed transcript already holds `lizard.complexity` with status `ok` and three files; a recording without the review extra records `skipped` and drops the `cat-file blob` exchanges, which the new test refuses.

## Existing Tool Considered

No open, maintained tool covers the need. The repository's own git fake and recorder (`tests/support/git_scenarios.py`, `tests/support/git_recording.py`) own it, and `git` itself gives the isolation with `GIT_CONFIG_NOSYSTEM` and `GIT_CONFIG_GLOBAL`. The change edits the harness and adds three tests.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Tasks

## 1. Behavior

- [x] 1.1 Write the failing tests for the environment, the recorded fact and the recorder
- Verification: `$ uv run devops ci test tests/core/test_git_recording.py`
- [x] 1.2 Isolate the code's git from the host configuration in `Workspace.environment()`
- Verification: `$ uv run devops ci test tests/core/test_git_contract.py`

## 2. Recording

- [x] 2.1 Record the transcripts again and confirm the `git` row passes
- Verification: `$ uv run devops ci --check --only git`
57 changes: 56 additions & 1 deletion tests/core/test_git_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

from __future__ import annotations

import os
from pathlib import Path

import pytest

from tests.support.git_recording import RecordingRunner
from tests.support.git_recording import (
RecordingRunner,
load_transcript,
record_scenario,
render,
)
from tests.support.git_scenarios import Workspace


Expand All @@ -30,3 +36,52 @@ def test_the_recording_reads_no_git_configuration_file_of_the_host(
for line in listed.stdout.splitlines()
if line.startswith(("global", "system", "pull.", "core.autocrlf"))
] == []


def test_the_code_runs_with_no_git_configuration_of_the_host(tmp_path: Path) -> None:
"""The environment of the code's git holds `GIT_CONFIG_NOSYSTEM` at `1` and
`GIT_CONFIG_GLOBAL` at `os.devnull`, so the code reads no host configuration and the recording
is the same on every host (#4865)."""
ws = Workspace(tmp_path / "ws", recording=False)

with ws.environment():
assert (os.environ["GIT_CONFIG_NOSYSTEM"], os.environ["GIT_CONFIG_GLOBAL"]) == (
"1",
os.devnull,
)


def test_the_review_window_transcript_holds_the_complexity_fact() -> None:
"""The committed transcript of `review_window` holds `lizard.complexity` with status `ok` and
three files in both fact lists, and no fact failed (#4865). A recording without the review
extra would drop the `cat-file blob` exchanges and record a `skipped` fact."""
result = load_transcript("review_window")["result"]
lists = {"version_facts": result["version_facts"], "period_facts": result["period_facts"]}
complexity = {
name: [
(fact["id"], fact["status"], fact["n"])
for fact in facts
if fact["id"] == "lizard.complexity"
]
for name, facts in lists.items()
}

assert complexity == {
"version_facts": [("lizard.complexity", "ok", 3)],
"period_facts": [("lizard.complexity", "ok", 3)],
}
assert [
(name, fact["id"])
for name, facts in lists.items()
for fact in facts
if fact["status"] != "ok"
] == []


def test_two_recordings_of_one_scenario_are_the_same() -> None:
"""The recorder is idempotent, so a second recording of `review_window` gives the same text
(#4865)."""
first = render(record_scenario("review_window"))
second = render(record_scenario("review_window"))

assert first == second
4 changes: 3 additions & 1 deletion tests/support/git_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ def git(self, rel_dir: str, *args: str, date: str = COMMIT_DATE) -> None:
@contextmanager
def environment(self) -> Iterator[None]:
"""The process environment that the code of `src/` runs in: its own home and data root,
and the C locale."""
the C locale, and no git configuration of the host (#4865)."""
wanted = {
"HOME": str(self.root / ".home"),
"LC_ALL": "C",
"DEVOPS_CLI_USER_DATA_ROOT": str(self.root / "user-data"),
"GIT_CONFIG_NOSYSTEM": "1",
"GIT_CONFIG_GLOBAL": os.devnull,
}
saved = {key: os.environ.get(key) for key in wanted}
os.environ.update(wanted)
Expand Down
Loading