Skip to content

fix(ci): tests touch no state outside their temporary directories (#1311) - #1484

Merged
dan-petty merged 1 commit into
release/v0.2.31from
fix/1311-tests-touch-no-state-outside-temp
Oct 9, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.31from
fix/1311-tests-touch-no-state-outside-temp

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Fixes #1311.

Tests touch no state outside their temporary directories:

  • Worker Home Isolation: Each pytest worker process runs with an isolated home under pytest basetemp before devops-cli is imported, giving tests a git identity on example.com and registering worker homes.
  • Temp Directory Isolation: isolate_tempdir autouse fixture sets tempfile.tempdir and temp environment variables (TMPDIR, TEMP, TMP) to tmp_path, ensuring code writing to system temp writes inside tmp_path.
  • User Data Root Resolution: Replaced floor patches of CONST_USER_DATA_ROOT with user_data_root() helper in core/repo.py honoring DEVOPS_CLI_USER_DATA_ROOT across core/repo.py, git/worktree.py, and tools_lock.
  • Config Isolation: Removed floor patch of CONFIG_PATH in tests/conftest.py, allowing the global config layer to read the worker's empty home.
  • Writers Remediated:
    • tests/test_k8s.py passes --tls-dir.
    • Ollama round-robin index in ai/client/network.py resolved under DEVOPS_CLI_DATA_DIR instead of system temp.
    • _ensure_known_host in git/operations.py accepts optional known_hosts path so tests write under tmp_path.
    • Worktree tests in test_git_worktree.py and test_review_worktree_regression.py assert paths stay under tmp_path.
  • Session Tripwire Auditing: The workspace tripwire verifies that worker homes leave no state at CONST_CONFIG_DIR, CONST_USER_DATA_ROOT, DEFAULT_SSH_KEY_DIR, or DEFAULT_LOCAL_BIN_DIR, and fails the session naming any leaked path.
  • Regression Tests: Added unit and pytester regression tests in tests/test_isolation_tripwire.py.

Verification

  • Local uv run devops ci: 14/14 quality gates passed (10,135 passed, 1 skipped, 8 xfailed, 0 failed, 92.38% coverage).

)

Isolate test worker homes, temp directories, user data roots, and configs:
- Configure each pytest worker with an isolated home under basetemp before devops-cli imports, setting git identity on example.com and recording worker homes.
- Add isolate_tempdir fixture setting tempfile.tempdir and temp environment variables to tmp_path.
- Drop floor patches of CONFIG_PATH and CONST_USER_DATA_ROOT in conftest, adding user_data_root() helper honoring DEVOPS_CLI_USER_DATA_ROOT across core, git worktree, and tools_lock.
- Move Ollama round-robin index under DEVOPS_CLI_DATA_DIR instead of system temp.
- Add optional known_hosts parameter to _ensure_known_host.
- Update k8s and worktree tests to stay strictly within tmp_path.
- Expand session workspace tripwire to verify that worker homes leave no state in devops-cli locations, with pytester tests.

Fixes #1311
@dan-petty dan-petty added this to the v0.2.31 milestone Oct 9, 2026
@dan-petty
dan-petty merged commit 8dfb0c1 into release/v0.2.31 Oct 9, 2026
8 checks passed
@dan-petty
dan-petty deleted the fix/1311-tests-touch-no-state-outside-temp branch October 9, 2026 11:51
dan-petty added a commit that referenced this pull request Oct 9, 2026
* fix(ci): tests render CLI help at the same width locally and in github ci (#1041) (#1475)

* fix(cli): docker sandbox and test sandbox dry runs check the workspace as the real run does (#1383) (#1476)

* fix(security): remove git daemon stub and port 9418 from devcontainer (#1122) (#1477)

* test(security): pin the finding fingerprint and run-store digest to literal values (#855) (#1478)

* fix(ai): resolve durable-run store and state files under data directory (#1036) (#1479)

* fix(deps): declare direct dependencies and add deptry gate step (#1120) (#1480)

* fix(docker): the Docker endpoint check covers the endpoint the SDK dials (#1108) (#1481)

* fix(k8s): harden argocd and otel ingress perimeters and add deploy-stack paths (#1371) (#1482)

* perf(ci): test workers start 25% faster by deferring model SDK imports (#1338) (#1483)

* fix(ci): tests touch no state outside their temporary directories (#1311) (#1484)

Isolate test worker homes, temp directories, user data roots, and configs:
- Configure each pytest worker with an isolated home under basetemp before devops-cli imports, setting git identity on example.com and recording worker homes.
- Add isolate_tempdir fixture setting tempfile.tempdir and temp environment variables to tmp_path.
- Drop floor patches of CONFIG_PATH and CONST_USER_DATA_ROOT in conftest, adding user_data_root() helper honoring DEVOPS_CLI_USER_DATA_ROOT across core, git worktree, and tools_lock.
- Move Ollama round-robin index under DEVOPS_CLI_DATA_DIR instead of system temp.
- Add optional known_hosts parameter to _ensure_known_host.
- Update k8s and worktree tests to stay strictly within tmp_path.
- Expand session workspace tripwire to verify that worker homes leave no state in devops-cli locations, with pytester tests.

Fixes #1311

* fix(security): fingerprint v2 and deterministic correlation (#1141) (#1487)

Migrate devops scan and NormalizedFinding to Fingerprint v2 with AST enclosing symbols and 100-character non-whitespace window hashes. Enforce complete linkage in correlation and deterministic representative selection. Closes #1141, absorbs #608.

* fix(security): URL credential masking uses urllib and httpx2 (#1109) (#1488)

* feat(k8s): argo cd image updater keeps the devops application on the digest of service:latest (#1485) (#1489)

* feat(release): v0.2.31

* chore(release): collect the v0.2.31 changelog fragments (#1491)

The Service's cut (4d00b96) bumped v0.2.31 without collecting the 13
fragments (#1450), so CHANGELOG.md's newest section was 0.2.30 and the
release run would fail on main as v0.2.30's did. This moves them into the
[0.2.31] section before release PR #1490 merges.

* chore(release): ignore gh v2.102.0's two Go 1.27.1 stdlib CVEs until 2026-10-23 (#1493)

Trivy fails the v0.2.31 Service image on CVE-2026-78667 (net/http) and
CVE-2026-97031 (crypto/tls) in /usr/local/bin/gh: gh v2.102.0, the newest
release, is built with Go 1.27.1 and both are fixed in Go 1.27.2. Both are
denial-of-service bugs and gh is a client. The entries expire on 2026-10-23;
#1492 bumps gh to a release built with Go 1.27.2 and drops them.

---------

Co-authored-by: Daniel Petty <[email protected]>
Co-authored-by: dan-petty-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant