Skip to content

fix: allow co-authored test files in validate_mutation_boundary (#163)#170

Merged
azalio merged 2 commits into
mainfrom
fix/163-test-alongside-scope-boundary
Jun 11, 2026
Merged

fix: allow co-authored test files in validate_mutation_boundary (#163)#170
azalio merged 2 commits into
mainfrom
fix/163-test-alongside-scope-boundary

Conversation

@azalio

@azalio azalio commented Jun 11, 2026

Copy link
Copy Markdown
Owner

What & why

Closes #163.

validate_mutation_boundary distinguished a subtask's scope by exact match against the blueprint's affected_files. The task-decomposer lists only production modules there, so a co-authored test file (test_foo.py beside foo.py, or tests/test_foo.py in the common src/+tests split) was always "outside affected_files". Under a test-alongside policy (validation = pytest green) that produced a spurious Scope warning that hard-stopped the first validate_step 2.4 on essentially every subtask, forcing a redundant second call.

The fix (validator side, deterministic)

Partition out-of-scope paths by test convention:

  • Test-convention paths (test_*.*, *_test.*, *.spec.*, *.test.*, anything under a tests//test//__tests__/ segment, and pytest conftest.py) are implied by the test-alongside policy. They are surfaced in a new allowed_test_files report key and excluded from unexpected — they remain in actual, so reality (and the false-progress check) stays honest.
  • Real production scope leaks are still reported as unexpected (warning / strict violation) exactly as before.

This makes the check independent of decomposer description wording (no magic prose needed), and reuses the existing _is_test_path helper — extended to also recognize conftest.py at any depth (a coherent improvement for its other caller, the cross-subtask regression-risk signal).

Per the repo's single-source invariant, the change was made in src/mapify_cli/templates_src/map/scripts/map_step_runner.py.jinja and propagated via make render-templates; make check-render is byte-clean.

Behavior

out-of-scope file before after
pipeline/test_foo.py (co-authored test) warning → hard-stop clean (in allowed_test_files)
tests/test_foo.py, tests/conftest.py warning clean
b.py (real source leak) warning warning (unchanged)
co-authored test under MAP_STRICT_SCOPE=1 violation clean

Tests

tests/test_map_step_runner.py:

  • co-authored test beside production module → clean, in allowed_test_files, still in actual
  • separate src/ + tests/ tree (incl. conftest.py) → clean
  • real source leak mixed with a test file → source still unexpected, test partitioned into allowed_test_files (the fix does not mask genuine leaks)
  • co-authored test not a violation even under MAP_STRICT_SCOPE=1
  • _is_test_path recognizes conftest.py / python/pipeline/conftest.py, still rejects contest.py

Second commit (test-only, unrelated pre-existing flake)

make check surfaced a pre-existing, local-only failure in test_every_configured_hook_execs_via_shebang: run past its MAP_INVOKED_BY guard, map-memory-finalize.py invokes claude -p (up to its default 50s budget) on a machine where the claude CLI is installed+authenticated, blowing past the probe's 20s cap. It's green on CI (no claude CLI → fast fail). Per the repo's "fix every surfaced error" rule it's bounded here via MAP_MEMORY_FINALIZE_TIMEOUT=5 in the probe env. Production finalize is unchanged (it gets 50s under the 60s SessionStart budget).

Gate

  • make lint ✅ · make check-render ✅ (generated trees match templates_src)
  • pytest2282 passed, 3 skipped

🤖 Generated with Claude Code

azalio and others added 2 commits June 11, 2026 17:51
…on_boundary (#163)

validate_mutation_boundary flagged co-authored test files (test_*.py,
*_test.*, *.spec.*, conftest.py, anything under tests/) as "outside
affected_files", emitting a scope warning that hard-stopped the first
validate_step 2.4 on essentially every subtask under a test-alongside
policy. The decomposer lists only production files in affected_files, so
the accompanying test was always "unexpected".

Fix (validator side, deterministic): partition out-of-scope paths by test
convention. Test-convention paths are surfaced as `allowed_test_files` and
excluded from `unexpected` (they stay in `actual`, keeping the
false-progress check honest); real production scope leaks are still
reported. This makes the check independent of decomposer description
wording. Reuses the existing _is_test_path helper, extended to also
recognize pytest conftest.py at any depth.

Edited the templates_src .jinja single source and re-rendered all generated
trees (make render-templates; check-render byte-clean).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
test_every_configured_hook_execs_via_shebang runs every configured hook
past its MAP_INVOKED_BY guard to assert exec-ability (+x, shebang, no
126/127). map-memory-finalize.py, exec'd that way, calls `claude -p` to
finalize a dirty scratch the loop's earlier memory hooks accumulate in the
shared project. On a machine where the `claude` CLI is installed and
authenticated, that subprocess runs up to its default 50s budget — past the
probe's 20s cap — so the test timed out locally (it passes on CI, which has
no `claude` CLI, so the subprocess fails fast there). Production finalize is
unchanged: it correctly gets 50s under the 60s SessionStart budget.

Bound MAP_MEMORY_FINALIZE_TIMEOUT=5 in the probe's env so the exec check
never blocks on a real finalization. Test-only; no production behavior
change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@azalio azalio merged commit 9d52e2b into main Jun 11, 2026
6 checks passed
@azalio azalio deleted the fix/163-test-alongside-scope-boundary branch June 11, 2026 14:54
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.

Co-authored test files flagged out-of-scope by validate_mutation_boundary despite test-alongside policy

1 participant