Skip to content

[FEATURE] Add Content-Aware Cascade Downgrade for Additive-Only Changes#2130

Merged
Trecek merged 5 commits into
developfrom
add-content-aware-cascade-downgrade-for-additive-only-change/2039
May 7, 2026
Merged

[FEATURE] Add Content-Aware Cascade Downgrade for Additive-Only Changes#2130
Trecek merged 5 commits into
developfrom
add-content-aware-cascade-downgrade-for-additive-only-change/2039

Conversation

@Trecek
Copy link
Copy Markdown
Collaborator

@Trecek Trecek commented May 7, 2026

Summary

Add content-aware diff inspection to the test filter's core module classification path. When a file in _CORE_UNIVERSAL_MODULES has additive-only changes (no removed definitions), subtract a per-stem exclusion set from the cascade instead of triggering the full 17-directory cascade. For non-additive changes (removals, renames), preserve the full cascade as a fail-safe.

Currently, _type_enums triggers all 17 cascade directories on any change. With this feature, additive-only changes to _type_enums will exclude {"hooks", "skills"}, reducing the cascade to 15 directories. The pattern is extensible to other universal modules.

The design follows the established content-aware pattern (_is_only_version_changes_in_diff / check_bucket_a_content_aware) — same git merge-base + git diff --unified=0 subprocess calls, same fail-open error handling, same cwd/base_ref gating.

Requirements

  • REQ-CONTENT-001: Add _CORE_UNIVERSAL_EXCLUSIONS dict mapping stems to excludable test directories
  • REQ-CONTENT-002: Implement _is_additive_only() using git diff against the existing base_sha
  • REQ-CONTENT-003: Integrate into the classification path at tests/_test_filter.py ~line 1131 — when a universal module file has additive-only changes, subtract exclusions from the cascade
  • REQ-CONTENT-004: For non-additive changes, preserve the full cascade (fail-safe)
  • REQ-CONTENT-005: Add tests for the content-aware detection: additive diffs, removal diffs, rename diffs, mixed diffs
  • REQ-CONTENT-006: Follows the existing content-aware pattern (check_bucket_a_content_aware) — the base_ref plumbing already exists
  • REQ-CONTENT-007: All existing tests must continue to pass

Closes #2039

Implementation Plan

Plan file: /home/talon/projects/autoskillit-runs/impl-20260506-224108-709752/.autoskillit/temp/make-plan/add_content_aware_cascade_downgrade_plan_2026-05-06_224600.md

🤖 Generated with Claude Code via AutoSkillit

Token Usage Summary

Step Model count uncached output cache_read peak_ctx turns cache_write time
plan claude-opus-4-6 1 2.8k 16.8k 818.9k 71.0k 63 62.6k 8m 39s
verify claude-opus-4-6 1 58 10.6k 955.0k 60.2k 108 47.2k 6m 30s
implement* MiniMax-M2.7-highspeed 1 859.0k 12.4k 1.3M 58.9k 87 47.6k 5m 50s
prepare_pr* MiniMax-M2.7-highspeed 1 103.2k 4.2k 255.5k 28.7k 28 15.3k 1m 34s
compose_pr* MiniMax-M2.7-highspeed 1 67.2k 1.7k 255.5k 28.7k 19 15.0k 58s
review_pr claude-sonnet-4-6 1 7.0k 28.5k 278.4k 61.8k 78 67.5k 9m 19s
resolve_review claude-opus-4-6 2 119 39.4k 3.4M 98.4k 121 148.8k 20m 54s
Total 1.0M 113.7k 7.2M 98.4k 403.9k 53m 47s

* Step used a non-Anthropic provider; caching behavior may differ.

Token Efficiency

Step LoC Changed cache_read/LoC cache_write/LoC output/LoC
plan 0
verify 0
implement 527 2457.9 90.3 23.6
prepare_pr 0
compose_pr 0
review_pr 0
resolve_review 58 57917.0 2566.2 679.4
Total 585 12338.1 690.5 194.3

Model Usage Breakdown

Model steps uncached output cache_read cache_write time
claude-opus-4-6 3 2.9k 43.9k 3.5M 173.8k 22m 24s
MiniMax-M2.7-highspeed 3 1.0M 18.3k 1.8M 77.9k 8m 22s

Trecek and others added 5 commits May 6, 2026 23:06
…o _type_enums

Add _is_additive_only() that inspects the diff to detect removed definitions
(class/function/UPPER_CASE constants). When a universal core module has an
exclusion entry (_CORE_UNIVERSAL_EXCLUSIONS) and its diff is additive-only,
the cascade excludes the safe-to-skip directories instead of running all 17.

Implementation:
- Add _BREAKING_DEF_RE regex to detect removed definitions
- Add _CORE_UNIVERSAL_EXCLUSIONS dict mapping _type_enums → {"hooks", "skills"}
- Add _is_additive_only() function following the existing content-aware pattern
  (git merge-base + git diff --unified=0, fail-open on error)
- Update classification path (Site 1): initial changed-files loop
- Update classification path (Site 2): re-export closure expansion

Tests:
- TestIsAdditiveOnly: 12 unit tests covering additions, removals, renames,
  mixed diffs, empty diffs, git errors, invalid SHA, indented removals
- TestBuildTestScopeUniversalExclusions: 6 integration tests covering
  narrowed cascade, full cascade fallback scenarios
- TestCoreUniversalExclusions: 6 contract tests for _CORE_UNIVERSAL_EXCLUSIONS

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The tests previously used exact set equality but build_test_scope in
conservative mode adds always-run dirs (arch, contracts) and unconditional
individual files (infra, hooks structural tests). Switch to presence/absence
assertions matching the pattern in test_test_filter_core_cascade.py.
…on guard

- Widen _BREAKING_DEF_RE from [A-Z_]+ to [A-Z_][A-Z0-9_]* to detect
  digit-containing constants (e.g., ENUM_V1); use \s* instead of literal
  space to also catch type-annotated forms (FOO: int = 1).
- Add absolute-path guard to _is_additive_only: return False immediately
  if filepath is absolute to prevent vacuously-additive results from
  empty git diff output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add mock_run.assert_not_called() to test_universal_without_exclusion_entry
  to document that io.py (universal but no exclusion entry) takes the full
  cascade path without calling _is_additive_only.
- Renumber section labels (T1→T3, T2→T4, T3→T5) to avoid collision with
  pre-existing (T1) for TestCheckBucketAContentAware; update module docstring.
- Remove hardcoded '17-dir cascade' count from docstring (stale-prone).
- Remove test_reexport_closure_universal_additive_uses_narrowed: the test
  did not exercise the closure path (source files absent from tmp_path made
  _expand_reexport_closure no-op), making it functionally identical to the
  direct additive-only test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Trecek Trecek added this pull request to the merge queue May 7, 2026
Merged via the queue into develop with commit 012f567 May 7, 2026
2 checks passed
@Trecek Trecek deleted the add-content-aware-cascade-downgrade-for-additive-only-change/2039 branch May 7, 2026 07:39
Trecek added a commit that referenced this pull request May 8, 2026
…es (#2130)

## Summary

Add content-aware diff inspection to the test filter's core module
classification path. When a file in `_CORE_UNIVERSAL_MODULES` has
additive-only changes (no removed definitions), subtract a per-stem
exclusion set from the cascade instead of triggering the full
17-directory cascade. For non-additive changes (removals, renames),
preserve the full cascade as a fail-safe.

Currently, `_type_enums` triggers all 17 cascade directories on any
change. With this feature, additive-only changes to `_type_enums` will
exclude `{"hooks", "skills"}`, reducing the cascade to 15 directories.
The pattern is extensible to other universal modules.

The design follows the established content-aware pattern
(`_is_only_version_changes_in_diff` / `check_bucket_a_content_aware`) —
same `git merge-base` + `git diff --unified=0` subprocess calls, same
fail-open error handling, same `cwd`/`base_ref` gating.

## Requirements

- REQ-CONTENT-001: Add `_CORE_UNIVERSAL_EXCLUSIONS` dict mapping stems
to excludable test directories
- REQ-CONTENT-002: Implement `_is_additive_only()` using git diff
against the existing `base_sha`
- REQ-CONTENT-003: Integrate into the classification path at
`tests/_test_filter.py` ~line 1131 — when a universal module file has
additive-only changes, subtract exclusions from the cascade
- REQ-CONTENT-004: For non-additive changes, preserve the full cascade
(fail-safe)
- REQ-CONTENT-005: Add tests for the content-aware detection: additive
diffs, removal diffs, rename diffs, mixed diffs
- REQ-CONTENT-006: Follows the existing content-aware pattern
(`check_bucket_a_content_aware`) — the `base_ref` plumbing already
exists
- REQ-CONTENT-007: All existing tests must continue to pass

Closes #2039

## Implementation Plan

Plan file:
`/home/talon/projects/autoskillit-runs/impl-20260506-224108-709752/.autoskillit/temp/make-plan/add_content_aware_cascade_downgrade_plan_2026-05-06_224600.md`

🤖 Generated with [Claude Code](https://claude.com/claude-code) via
AutoSkillit
<!-- autoskillit:pipeline-signature
steps=prepare_pr,run_arch_lenses,compose_pr,annotate_pr_diff,review_pr
-->

## Token Usage Summary

| Step | Model | count | uncached | output | cache_read | peak_ctx |
turns | cache_write | time |

|------|-------|-------|----------|--------|------------|----------|-------|-------------|------|
| plan | claude-opus-4-6 | 1 | 2.8k | 16.8k | 818.9k | 71.0k | 63 |
62.6k | 8m 39s |
| verify | claude-opus-4-6 | 1 | 58 | 10.6k | 955.0k | 60.2k | 108 |
47.2k | 6m 30s |
| implement* | MiniMax-M2.7-highspeed | 1 | 859.0k | 12.4k | 1.3M |
58.9k | 87 | 47.6k | 5m 50s |
| fix | claude-opus-4-6 | 1 | 59 | 16.5k | 1.7M | 76.9k | 60 | 64.1k |
7m 13s |
| prepare_pr* | MiniMax-M2.7-highspeed | 1 | 103.2k | 4.2k | 255.5k |
28.7k | 28 | 15.3k | 1m 34s |
| compose_pr* | MiniMax-M2.7-highspeed | 1 | 67.2k | 1.7k | 255.5k |
28.7k | 19 | 15.0k | 58s |
| **Total** | | | 1.0M | 62.2k | 5.3M | 76.9k | | 251.7k | 30m 47s |

\* *Step used a non-Anthropic provider; caching behavior may differ.*

## Token Efficiency

| Step | LoC Changed | cache_read/LoC | cache_write/LoC | output/LoC |
|------|-------------|----------------|-----------------|------------|
| plan | 0 | — | — | — |
| verify | 0 | — | — | — |
| implement | 527 | 2457.9 | 90.3 | 23.6 |
| fix | 135 | 12476.5 | 474.6 | 121.9 |
| prepare_pr | 0 | — | — | — |
| compose_pr | 0 | — | — | — |
| **Total** | **662** | 7952.4 | 380.2 | 94.0 |

## Model Usage Breakdown

| Model | steps | uncached | output | cache_read | cache_write | time |
|-------|-------|----------|--------|------------|-------------|------|
| claude-opus-4-6 | 3 | 2.9k | 43.9k | 3.5M | 173.8k | 22m 24s |
| MiniMax-M2.7-highspeed | 3 | 1.0M | 18.3k | 1.8M | 77.9k | 8m 22s |

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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