Skip to content

fix(tests): make dtu tool-composition test portable and collection-safe#30

Merged
colombod merged 1 commit into
mainfrom
fix/dtu-test-portable-path
Jun 4, 2026
Merged

fix(tests): make dtu tool-composition test portable and collection-safe#30
colombod merged 1 commit into
mainfrom
fix/dtu-test-portable-path

Conversation

@colombod
Copy link
Copy Markdown
Collaborator

@colombod colombod commented Jun 4, 2026

Delivered — merged to main. Related: #29 (the graph-query params/docs work this was split out from).

Problem

tests/dtu/test_tool_delegate_composition.py hardcoded an absolute, root-owned cache path and ran its checks at import time:

cache = Path("/root/.amplifier/cache/amplifier-bundle-context-intelligence-ecd41f3e6fa67bd2")
...
facilitator_fm, _ = load_frontmatter("agents/...")   # module-level
...
sys.exit(1)                                            # module-level on failure

On any environment other than that exact DTU container this raised PermissionError: [Errno 13] Permission denied: '/root/.amplifier/cache/...' during pytest collection, which aborted collection for the whole tests/ tree (1 error, 0 tests run from the top-level suite).

Fix

  • Resolve the bundle root relative to the test file: BUNDLE_ROOT = Path(__file__).resolve().parents[2]. The agent and mode files under test (agents/context-intelligence-design-facilitator.md, agents/context-intelligence-tool-designer.md, modes/context-intelligence.md) ship in this repo, so the repo root is the correct, portable source — works in a checkout, in CI, and inside a DTU alike.
  • Move the validation into a real def test_tool_delegate_composition() that asserts on failures instead of sys.exit(1), so collection no longer executes the body. Retained an if __name__ == "__main__" runner so the file still works as a standalone DTU script. All 14 Group-D checks are unchanged.

Test Plan

  • tests/dtu/test_tool_delegate_composition.py: 1 passed (was a collection error)
  • Full top-level suite now collects and runs clean: 657 passed (previously aborted at collection)
  • ruff lint + format clean

tests/dtu/test_tool_delegate_composition.py hardcoded an absolute, root-owned path
/root/.amplifier/cache/amplifier-bundle-context-intelligence-ecd41f3e6fa67bd2 and executed
its validation logic (including sys.exit(1)) at MODULE/import level. On any machine that
isn't that exact DTU container, this raised PermissionError during pytest collection and
aborted the ENTIRE tests/ collection.

Fix: resolve the bundle root relative to the test file (Path(__file__).resolve().parents[2])
— the agent/mode files under test are shipped in this repo — and move the logic into a
proper def test_tool_delegate_composition() function that asserts instead of sys.exit.
Kept an if __name__ == "__main__" runner so it still works as a standalone DTU script.
No behavioral change to the 14 checks.
@colombod colombod merged commit 583b469 into main Jun 4, 2026
9 checks passed
@colombod colombod deleted the fix/dtu-test-portable-path branch June 4, 2026 14:25
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