Skip to content

test(#528): fix + un-quarantine agent_routing (test-isolation bug)#530

Merged
atlas-apex merged 1 commit into
devfrom
test/GH-528-agent-routing
Jun 6, 2026
Merged

test(#528): fix + un-quarantine agent_routing (test-isolation bug)#530
atlas-apex merged 1 commit into
devfrom
test/GH-528-agent-routing

Conversation

@atlas-apex

Copy link
Copy Markdown
Collaborator

Summary

Fixes the 4th of 5 quarantined tests from #528 — and the root cause turned out to be a test-isolation bug with a real side-effect, not the config regression I'd flagged.

  • Root cause: apply-agent-routing.sh resolves the ops root via _lib-ops-root.sh, which — inside a real Claude Code session — honours the session pin ($APEXYARD_OPS_PIN_DIR/ops-root-$CLAUDE_CODE_SESSION_ID) and resolves to the real fork, not the test's mktemp sandbox. So the hook rewrote the real .claude/agents/*.md (and dropped a stray .framework-defaults.json) while every sandbox assertion failed. (It also silently mutated my working copy — restored.)
  • Fix 1 — isolation: export APEXYARD_OPS_DISABLE_PIN=1 at the top of the test so ops-root resolves by walk-up to the sandbox. No-op in headless CI (no pin). This alone took the suite 4/14 → 13/14 and stopped the real-repo mutation.
  • Fix 2 — case 4 (idempotency): it declared endpoint: http://localhost:11434 but, unlike cases 9–13, never mocked curl — so the unreachable endpoint was correctly filtered by the hook and the endpoint_count assertion was testing the environment, not idempotency. Hoisted make_mock_curl above case 4 and mocked the endpoint reachable → 14/14.
  • Un-quarantined agent_routing_sync_and_drift in bin/run-hook-tests.sh.

What remains in #528 (1 of 5)

test_handover_clone_prompt stays quarantined — but I've sharpened the reason: it spec-pins a clone-prompt design that no longer exists (a [y / n / later] prompt at step 8). The /handover SKILL was redesigned to clone-by-default at step 1.5 with a follow-up offer at step 8, so this needs a test rewrite against the current spec, not a string patch. Left for a focused follow-up under #528. Refs #528.

Testing

  1. bash .claude/hooks/tests/test_agent_routing_sync_and_drift.sh14 passed, 0 failed.
  2. Verified the real repo is no longer mutated by a test run (git status .claude/agents/ shows only pre-existing WIP).
  3. shellcheck -S error clean on the test and bin/run-hook-tests.sh.
  4. bash bin/run-hook-tests.sh → agent_routing PASS, only handover_clone_prompt SKIP; this PR's tests gate on Linux is the check (expected green, now enforcing 64).

Refs #528


Glossary

Term Definition
Session pin _lib-ops-root.sh resolving the ops root from $APEXYARD_OPS_PIN_DIR/ops-root-$CLAUDE_CODE_SESSION_ID inside a live session.
APEXYARD_OPS_DISABLE_PIN Env flag that disables the pin lookup so resolution falls back to directory walk-up — the correct neutralizer for sandboxed tests.
Mock curl A fake curl on $PATH that returns canned fixtures, making endpoint reachability deterministic in tests.
Spec-pin test A test asserting literal substrings exist in a SKILL doc; obsolete once the documented design changes.

Root cause was test isolation, not a config regression: apply-agent-routing.sh
resolves the ops root via _lib-ops-root.sh, which inside a Claude Code session
honours the session pin ($APEXYARD_OPS_PIN_DIR/ops-root-$CLAUDE_CODE_SESSION_ID)
and pointed at the REAL fork instead of the mktemp sandbox — so the hook rewrote
the real .claude/agents/*.md (+ a stray snapshot) and every sandbox assertion
failed. Two fixes:
- export APEXYARD_OPS_DISABLE_PIN=1 at the top of the test so ops-root resolves
  by walk-up to the sandbox (no-op in headless CI, which has no pin). This alone
  took the suite from 4/14 to 13/14 and stopped the real-repo mutation.
- case 4 (idempotency) declared endpoint http://localhost:11434 but, unlike
  cases 9-13, never mocked curl — so the unreachable endpoint was correctly
  filtered and the endpoint_count assertion tested the environment. Hoisted
  make_mock_curl above case 4 and mocked the endpoint reachable → 14/14.

Un-quarantined in bin/run-hook-tests.sh. Only test_handover_clone_prompt remains
quarantined (it spec-pins a removed clone-prompt design; needs a rewrite). #528

Refs #528

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@atlas-apex atlas-apex merged commit 41d1051 into dev Jun 6, 2026
7 checks passed
@atlas-apex atlas-apex deleted the test/GH-528-agent-routing branch June 6, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants