Repository navigation
Description
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, soDEVOPS_CLI_DATA_DIRanddata.dirmove it), unless the configured path is absolute. - A test with
DEVOPS_CLI_DATA_DIRset 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.dbin 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.mdrecords the fix under### Fixed.CHANGELOG.mdis not edited. -
uv run devops cipasses.
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:
k8s/port_forward_daemon.py:21:_DEFAULT_STATE_FILE = Path(".data/k8s/port_forwards.json")(fix(k8s): resolve the port-forward state file under the repo data root #810).devops k8s port-forward-statusrun from a subdirectory reads a different, usually missing, file, andtests/test_k8s.pyleaves the file in the checkout, outside fix(test): tests never write to the project config, data or tracked files #749's guarantee.ai/library/docs_ingester.py:190and:238:Path(".data/docs_ingest")(not filed).github/graphql.py:668: the ETag cache is built fromDEFAULT_DATA_DIR(not filed).
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).
- One helper resolves a store's default path:
data.dirjoined with the store's name, thenresolve_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. - An invariant test fails on any
Pathbuilt from a.dataliteral or fromDEFAULT_DATA_DIRinsrc/outsideconfig/defaults.pythat 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.jsonin 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.
Key questions (added).
- Resolve at construction or at import? (proposed, from fix(k8s): resolve the port-forward state file under the repo data root #810) At construction, so a changed working directory and test fixtures are honoured.
- Migrate existing state files? (proposed, from fix(k8s): resolve the port-forward state file under the repo data root #810) No. In the usual case the old relative path, taken from the repo root, is the same file.
- Do the 12 hand-written
os.environ.get("DEVOPS_CLI_DATA_DIR")reads (for examplesandbox/registry.py:26,ci/cache.py:81,core/audit.py:91) move onto the helper here? (proposed) No. Several are in modules the review redesign freezes, or that refactor(github): the github session owns transport, ledger, error classes and link pagination #983 rewrites (github/rate_limiter.py:1314-1317). This item's invariant covers path literals only. A follow-up can bring them under the helper. - The ETag cache at
github/graphql.py:668? (proposed) In scope here unless refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (v0.2.28) has already moved it onto the session. Whichever lands second rebases. - If refactor(ai): the durable resolver offers only the engines that work, and the unread
ai.durablesettings are removed #1121 removesai.durablefirst? The "unless the configured path is absolute" wording applies to the resolver'sstore_pathargument instead.
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
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.
fix(ai): resolve durable-run store and state files under data directo…
dan-petty-bot commentedon Oct 9, 2026
What changed
#1479, merged into
release/v0.2.31as a01fdac.11 file(s) changed.
How it was verified
Check runs at f44e5fd:
Acceptance Criteria of
docs/agent/tasks/task-1036-durable-run-store-data-dir.md:data.dirjoined with the store's name, thenresolve_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.resolve_data_path, soDEVOPS_CLI_DATA_DIRanddata.dirmove it), unless the configured path is absolute.Pathbuilt from a.dataliteral or fromDEFAULT_DATA_DIRinsrc/outsideconfig/defaults.pythat does not go through the helper. It finds nothing after this change..data/k8s/port_forwards.jsonin the checkout.port_forward_daemon.py:139,:155) still refuses a symlinked state file. How forwards start and stop does not change.DEVOPS_CLI_DATA_DIRset to a tmp directory asserts the store opens under it and nothing is created in the working directory.uv run pytest -p no:cacheprovider -q -n 6 tests,git status --porcelain --ignored .data/durable_runs.dbin the checkout shows nothing new.changelog.d/1036.mdrecords the fix under### Fixed.CHANGELOG.mdis not edited.uv run devops cipasses.feat(release): v0.2.31 (#1490)