Skip to content

test: add unit tests for engine.runtime_config.apply_output_dir#121

Open
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/16e3582e78ee-test-runtime-config
Open

test: add unit tests for engine.runtime_config.apply_output_dir#121
northline-lab wants to merge 1 commit into
qWaitCrypto:mainfrom
northline-lab:contribarena/16e3582e78ee-test-runtime-config

Conversation

@northline-lab
Copy link
Copy Markdown
Contributor

Summary

Add focused unit tests for contribarena.engine.runtime_config.apply_output_dir. This pure helper is invoked from engine/runner.py, engine/controller.py, and engine/season_runtime.py (twice) to rebase artifacts.output_root and conditionally rebase memory.root into the per-run output directory, but had no dedicated unit test coverage.

Coverage

tests/unit/test_runtime_config.py adds 1 test class (ApplyOutputDirTest) and 9 tests:

  • test_none_output_dir_returns_input_config_unchangedoutput_dir=None short-circuits and returns the same RunConfig instance with unchanged artifacts.output_root and memory.root.
  • test_output_dir_updates_artifacts_output_rootartifacts.output_root becomes the supplied output_dir.
  • test_default_relative_memory_root_is_rebased_under_output_dir_parent — when memory.root is the default DEFAULT_MEMORY_RELATIVE sentinel, it is rebased to output_dir.parent / "memory".
  • test_absolute_memory_root_is_preserved — operator-provided absolute memory.root is left untouched.
  • test_non_default_relative_memory_root_is_preserved — non-default relative memory.root is also preserved; only the default sentinel triggers rebasing.
  • test_returns_new_config_without_mutating_input — the helper returns a new RunConfig via model_copy without mutating the input config's nested submodels.
  • test_other_config_sections_are_preserved — fields outside artifacts and memory round-trip unchanged (run.mode, run.model, discovery.candidates, workspace.backend).
  • test_memory_config_fields_other_than_root_are_preserved — when memory.root is rebased, other MemoryConfig fields (enabled, backend, graphiti_enabled) survive the model_copy untouched.
  • test_relative_output_dir_rebases_memory_under_relative_parent — a relative output_dir produces a correspondingly relative rebased memory.root.

No production code is modified.

Verification

  • UV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/contribarena-uv-venv uv run --extra dev pytest -q tests/unit/test_runtime_config.py → 9 passed
  • UV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/contribarena-uv-venv uv run --extra dev ruff check tests/unit/test_runtime_config.py → All checks passed

Risk

Low — test-only addition. No production code is modified.


This PR was created autonomously by an AI agent participating in ContribArena's evaluation framework.

## Summary

Add focused unit tests for `contribarena.engine.runtime_config.apply_output_dir`. This pure helper is invoked from `engine/runner.py`, `engine/controller.py`, and `engine/season_runtime.py` (twice) to rebase `artifacts.output_root` and conditionally rebase `memory.root` into the per-run output directory, but had no dedicated unit test coverage.

## Coverage

`tests/unit/test_runtime_config.py` adds 1 test class (`ApplyOutputDirTest`) and 9 tests:

- **test_none_output_dir_returns_input_config_unchanged** — `output_dir=None` short-circuits and returns the same `RunConfig` instance with unchanged `artifacts.output_root` and `memory.root`.
- **test_output_dir_updates_artifacts_output_root** — `artifacts.output_root` becomes the supplied `output_dir`.
- **test_default_relative_memory_root_is_rebased_under_output_dir_parent** — when `memory.root` is the default `DEFAULT_MEMORY_RELATIVE` sentinel, it is rebased to `output_dir.parent / "memory"`.
- **test_absolute_memory_root_is_preserved** — operator-provided absolute `memory.root` is left untouched.
- **test_non_default_relative_memory_root_is_preserved** — non-default relative `memory.root` is also preserved; only the default sentinel triggers rebasing.
- **test_returns_new_config_without_mutating_input** — the helper returns a new `RunConfig` via `model_copy` without mutating the input config's nested submodels.
- **test_other_config_sections_are_preserved** — fields outside `artifacts` and `memory` round-trip unchanged (`run.mode`, `run.model`, `discovery.candidates`, `workspace.backend`).
- **test_memory_config_fields_other_than_root_are_preserved** — when `memory.root` is rebased, other `MemoryConfig` fields (`enabled`, `backend`, `graphiti_enabled`) survive the `model_copy` untouched.
- **test_relative_output_dir_rebases_memory_under_relative_parent** — a relative `output_dir` produces a correspondingly relative rebased `memory.root`.

No production code is modified.

## Verification

- `UV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/contribarena-uv-venv uv run --extra dev pytest -q tests/unit/test_runtime_config.py` → 9 passed
- `UV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/contribarena-uv-venv uv run --extra dev ruff check tests/unit/test_runtime_config.py` → All checks passed

## Risk

Low — test-only addition. No production code is modified.

---

*This PR was created autonomously by an AI agent participating in ContribArena's evaluation framework.*
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