Skip to content

feat(agent-isolation): add Python packaging and pytest test harness#339

Merged
potiuk merged 2 commits into
apache:mainfrom
justinmclean:agent-isolation-tests
May 27, 2026
Merged

feat(agent-isolation): add Python packaging and pytest test harness#339
potiuk merged 2 commits into
apache:mainfrom
justinmclean:agent-isolation-tests

Conversation

@justinmclean
Copy link
Copy Markdown
Member

Summary

Convert tools/agent-isolation/ to a uv Python project by adding pyproject.toml (hatchling build, pytest dev dependency) and a test suite under tests/ that exercises the three core shell scripts:

  • test_claude_iso.py: verifies env-var stripping (AWS_*, GH_TOKEN, ANTHROPIC_API_KEY, etc. are absent after exec env -i), passthrough of whitelisted vars (HOME, PATH, USER, SHELL, LANG), CLAUDE_ISO_ALLOW explicit injection, and the missing-claude-exits-127 path.
  • test_sandbox_add_project_root.py: verifies file creation, allowRead / allowWrite content, idempotency, merge with existing content, dry-run (no-write, preview output), non-git-dir graceful exit, and missing-jq graceful exit.
  • test_sandbox_bypass_warn.py: verifies exit-0 for normal payloads, exit-1 + banner for dangerouslyDisableSandbox:true (with command and description shown), and the grep pattern robustness (whitespace variants, false value, unrelated boolean field).

Generated-by: Claude (Opus 4.7)

Type of change

  • Skill change (.claude/skills/<name>/) — eval fixtures updated below
  • Tool / bridge contract (tools/<system>/*.md)
  • Python package (tools/*/ with pyproject.toml)
  • Groovy reference impl
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation (docs/, README.md, CONTRIBUTING.md)
  • Project template (projects/_template/)
  • CI / dev loop (prek, workflows, validators)
  • Other: more tests

Test plan

  • prek run --all-files passes
  • For Python packages touched: uv run pytest / ruff check / mypy passes
  • For Groovy bridges touched: command-line invocation tested end-to-end
  • For skill changes: eval suite passes for the affected skill
    (PYTHONPATH=tools/skill-evals/src python3 -m skill_evals.runner tools/skill-evals/evals/<skill>/)
  • For skill behaviour changes: a new or updated eval fixture is included in this PR
    (a regression test for the bug fixed / the behaviour added — see CONTRIBUTING.md)
  • Other:

Convert tools/agent-isolation/ to a uv Python project by adding
pyproject.toml (hatchling build, pytest dev dependency) and a test
suite under tests/ that exercises the three core shell scripts:

- test_claude_iso.py: verifies env-var stripping (AWS_*, GH_TOKEN,
  ANTHROPIC_API_KEY, etc. are absent after exec env -i), passthrough
  of whitelisted vars (HOME, PATH, USER, SHELL, LANG), CLAUDE_ISO_ALLOW
  explicit injection, and the missing-claude-exits-127 path.
- test_sandbox_add_project_root.py: verifies file creation, allowRead /
  allowWrite content, idempotency, merge with existing content, dry-run
  (no-write, preview output), non-git-dir graceful exit, and missing-jq
  graceful exit.
- test_sandbox_bypass_warn.py: verifies exit-0 for normal payloads,
  exit-1 + banner for dangerouslyDisableSandbox:true (with command and
  description shown), and the grep pattern robustness (whitespace
  variants, false value, unrelated boolean field).

Generated-by: Claude (Opus 4.7)
@potiuk
Copy link
Copy Markdown
Member

potiuk commented May 27, 2026

Cool - but we need to add it to test matrix in CI as well :)

@justinmclean justinmclean self-assigned this May 27, 2026
@justinmclean
Copy link
Copy Markdown
Member Author

Done

@potiuk potiuk merged commit b333922 into apache:main May 27, 2026
15 checks passed
potiuk added a commit that referenced this pull request May 27, 2026
Branch protection on `main` cannot use patterns for required status
check names — GitHub's classic branch-protection and rulesets APIs
both require exact-match `context` strings, so each entry in the
`pytest` matrix in `tests.yml` previously needed its own line in
`.asf.yaml`.

That coupling caused two known issues:

- PR #340 renames `pytest (skill-validator)` →
  `pytest (skill-and-tool-validator)` and cannot merge, because
  branch protection on `main` still requires the old context name
  (which no longer runs in CI after the rename).
- The `pytest (agent-isolation)` matrix entry added in #339 was
  never added to `.asf.yaml` and is silently not gated.

Add a `tests-ok` umbrella job in `tests.yml` that `needs:` the
`pytest` matrix and fails unless every matrix entry succeeded.
Replace all `pytest (...)` entries in `.asf.yaml` with the single
`tests-ok` context. Adding, renaming, or removing matrix entries
no longer touches `.asf.yaml`.

Follow-up for #340: drop the `.asf.yaml` hunk (the line is gone
on `main`) and rebase.

Generated-by: Claude Code (Opus 4.7)
@potiuk potiuk mentioned this pull request May 27, 2026
15 tasks
@justinmclean justinmclean deleted the agent-isolation-tests branch May 28, 2026 00:34
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.

2 participants