Skip to content

fix(ai): the durable-run store resolves under the data directory, so tests never write .data/durable_runs.db into the checkout #1036

Closed

Description

@dan-petty

Problem

A full pytest run writes .data/durable_runs.db into the working tree. Found while reviewing #950: after a full-suite run (7259 passed), the file appeared in a worktree where only pytest had run; deleting it and running each durable-related test file alone with -n0 showed that only tests/test_pydantic_ai_durable.py recreates it. devops ai benchmark --dry-run does not.

The cause is the store path: ai.durable.store_path defaults to a path relative to the working directory (src/devops_cli/config/defaults.py:120, at 79e1e93) and is not resolved through resolve_data_path or DEVOPS_CLI_DATA_DIR. The autouse isolate_data_dir fixture (tests/conftest.py) sets DEVOPS_CLI_DATA_DIR for every test, so any path that honoured the data directory would land in the test's tmp directory instead.

Effects: a gate run leaves an untracked file in the checkout, a durable run started from a worktree or a subdirectory writes its store somewhere other than the shared data directory (#553), and tests can see each other's runs through the shared file.

Acceptance criteria

  • The durable-run store path resolves under the data directory (resolve_data_path, so DEVOPS_CLI_DATA_DIR and data.dir move it), unless the configured path is absolute.
  • A test with DEVOPS_CLI_DATA_DIR set to a tmp directory asserts the store opens under it and nothing is created in the working directory.
  • After uv run pytest -p no:cacheprovider -q -n 6 tests, git status --porcelain --ignored .data/durable_runs.db in the checkout shows nothing new (checked by a person, or by a test that runs the durable tests in a subprocess with a scratch cwd if that stays well under 1 s).
  • changelog.d/1036.md records the fix under ### Fixed. CHANGELOG.md is not edited.
  • uv run devops ci passes.

Key questions

  • Fix the test instead (use tmp_path)? (proposed) No. The store ignoring the data directory is the defect; the test only exposes it. Fixing the path fixes every caller.

Depends on: none.
Order: any time.
Related: #553 (one data directory across worktrees), #950 (where it was found).

Consolidated from #810

Problem (added). The durable store is one of several defaults built from a .data path relative to the working directory and never resolved under the data directory. Checked at 14e5da1:

Correction to the first criterion above: resolve_data_path alone does not honour DEVOPS_CLI_DATA_DIR or data.dir. It places a relative path under the main worktree (core/repo.py:267), and only settings.data.dir applies the override (config/settings.py:762-764). The consistent form is resolve_data_path(<settings>.data.dir / <name>).

Acceptance criteria (added).

Key questions (added).

Placement. Both items were P2 in the backlog, so this item stays P2 in the backlog. Effort goes from Low to Low-Medium. #811 now depends on this item in place of #810. Related: #1014 (the response cache under data.dir, same helper), #553.

Update 2026-10-08: refinement

github/graphql.py was deleted in v0.2.26, and no ETag cache remains, so that key question no longer applies. The other sites hold (k8s/port_forward_daemon.py:21, ai/library/docs_ingester.py:193, :241, config/defaults.py:125); if #1331 deletes the durable store first, that site goes with it. #1014's response cache uses this helper; whichever lands second moves the other onto it.

Activity

  1. added
    type/bug
    scope/ai
    priority/p2-medium
    scope/ci
    on Oct 3, 2026
  2. added this to the v0.2.31 milestone on Oct 8, 2026
  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.31 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: finding identity v2, URL credential masking, tests that leave no state, the Docker endpoint check and the Argo CD/OTel perimeters. Position 6 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  4. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1479, merged into release/v0.2.31 as a01fdac.

    Summary

    Resolves #1036.

    Routes the default paths for the durable-run store (durable_runs.db), Kubernetes port-forward daemon state file (k8s/port_forwards.json), and docs ingestion directory (docs_ingest) through resolve_store_path under the repository data directory (resolve_data_path(data.dir / ...)). This ensures DEVOPS_CLI_DATA_DIR and data.dir settings are consistently honoured across secondary worktrees and test runners.

    11 file(s) changed.

    How it was verified

    Check runs at f44e5fd:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1036-durable-run-store-data-dir.md:

    • One helper resolves a store's default path: data.dir joined with the store's name, then resolve_data_path. The durable store, the port-forward state file and the docs-ingest directory use it. A path passed explicitly (state_file=, output_dir=, an absolute configured path) is used as given.
    • The durable-run store path resolves under the data directory (resolve_data_path, so DEVOPS_CLI_DATA_DIR and data.dir move it), unless the configured path is absolute.
    • An invariant test fails on any Path built from a .data literal or from DEFAULT_DATA_DIR in src/ outside config/defaults.py that does not go through the helper. It finds nothing after this change.
    • From fix(k8s): resolve the port-forward state file under the repo data root #810: the test suite leaves no .data/k8s/port_forwards.json in the checkout.
    • From fix(k8s): resolve the port-forward state file under the repo data root #810: a forward record saved with the working directory at the repo root is listed by a manager constructed with the working directory in a subdirectory.
    • From fix(k8s): resolve the port-forward state file under the repo data root #810: the symlink guard (port_forward_daemon.py:139, :155) still refuses a symlinked state file. How forwards start and stop does not change.
    • Tests spawn no kubectl and touch no network.
    • A test with DEVOPS_CLI_DATA_DIR set to a tmp directory asserts the store opens under it and nothing is created in the working directory.
    • After uv run pytest -p no:cacheprovider -q -n 6 tests, git status --porcelain --ignored .data/durable_runs.db in the checkout shows nothing new.
    • changelog.d/1036.md records the fix under ### Fixed. CHANGELOG.md is not edited.
    • uv run devops ci passes.
  5. added a commit that references this issue on Oct 9, 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

    priority/p2-mediumscope/aiscope/citype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions