From 9065b2a890dd842b141963efb367b6dbce988d10 Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Wed, 18 Nov 2026 12:07:53 +0000 Subject: [PATCH 1/2] fix(roadmap): Isolate the review window git transcript from the host (#4865) --- .../.openspec.yaml | 3 + .../design.md | 10 ++++ .../proposal.md | 29 ++++++++++ .../tasks.md | 13 +++++ tests/core/test_git_recording.py | 57 ++++++++++++++++++- tests/support/git_scenarios.py | 4 +- 6 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/.openspec.yaml create mode 100644 openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/design.md create mode 100644 openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/proposal.md create mode 100644 openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/tasks.md diff --git a/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/.openspec.yaml b/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/.openspec.yaml new file mode 100644 index 0000000000..96358f7ad8 --- /dev/null +++ b/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/.openspec.yaml @@ -0,0 +1,3 @@ +schema: spec-driven +created: 2026-11-18 +skip_specs: true diff --git a/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/design.md b/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/design.md new file mode 100644 index 0000000000..4d0973f144 --- /dev/null +++ b/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/design.md @@ -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. diff --git a/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/proposal.md b/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/proposal.md new file mode 100644 index 0000000000..ab35836b61 --- /dev/null +++ b/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/proposal.md @@ -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. diff --git a/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/tasks.md b/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/tasks.md new file mode 100644 index 0000000000..345dc628de --- /dev/null +++ b/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/tasks.md @@ -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` diff --git a/tests/core/test_git_recording.py b/tests/core/test_git_recording.py index daf25da8b3..4ea8f43956 100644 --- a/tests/core/test_git_recording.py +++ b/tests/core/test_git_recording.py @@ -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 @@ -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 diff --git a/tests/support/git_scenarios.py b/tests/support/git_scenarios.py index 7d35c02bdc..3c696f23a8 100644 --- a/tests/support/git_scenarios.py +++ b/tests/support/git_scenarios.py @@ -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) From 5cd0fcb1c4479b5d7571657a257c1a8c8874d85d Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Wed, 18 Nov 2026 12:08:29 +0000 Subject: [PATCH 2/2] chore(openspec): Archive the review window git transcript change (#4865) --- .../.openspec.yaml | 0 .../design.md | 0 .../proposal.md | 0 .../tasks.md | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename openspec/changes/{4865-the-review-window-git-transcript-does-not-match-the-code => archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code}/.openspec.yaml (100%) rename openspec/changes/{4865-the-review-window-git-transcript-does-not-match-the-code => archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code}/design.md (100%) rename openspec/changes/{4865-the-review-window-git-transcript-does-not-match-the-code => archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code}/proposal.md (100%) rename openspec/changes/{4865-the-review-window-git-transcript-does-not-match-the-code => archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code}/tasks.md (100%) diff --git a/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/.openspec.yaml b/openspec/changes/archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code/.openspec.yaml similarity index 100% rename from openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/.openspec.yaml rename to openspec/changes/archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code/.openspec.yaml diff --git a/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/design.md b/openspec/changes/archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code/design.md similarity index 100% rename from openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/design.md rename to openspec/changes/archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code/design.md diff --git a/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/proposal.md b/openspec/changes/archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code/proposal.md similarity index 100% rename from openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/proposal.md rename to openspec/changes/archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code/proposal.md diff --git a/openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/tasks.md b/openspec/changes/archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code/tasks.md similarity index 100% rename from openspec/changes/4865-the-review-window-git-transcript-does-not-match-the-code/tasks.md rename to openspec/changes/archive/2026-11-18-4865-the-review-window-git-transcript-does-not-match-the-code/tasks.md