Skip to content

fix: bypass ai for singleton-backed viewmodels#13

Merged
gay00ung merged 1 commit into
mainfrom
feature/ai-bypass-guard
Mar 26, 2026
Merged

fix: bypass ai for singleton-backed viewmodels#13
gay00ung merged 1 commit into
mainfrom
feature/ai-bypass-guard

Conversation

@gay00ung

Copy link
Copy Markdown
Owner

Summary

This PR makes AI bypass detection more conservative for ViewModels that depend on direct singleton collaborators.

Included changes

  • update AI bypass logic to inspect the full ViewModel source file, not only the currently selected changed methods
  • keep bypass enabled when:
    • the module does not support kotlinx-coroutines-test
    • and the ViewModel source still contains direct singleton collaborator access
  • add a regression test for the case where:
    • the changed method itself does not reference the singleton
    • but another public method in the same file still does

Why this change

d2t auto --ai narrows analysis to changed methods.

That meant singleton-backed ViewModels could still slip into the AI path when the changed method did not directly contain the singleton access, even though the file as a whole was still not a safe AI target.

This PR fixes that mismatch by treating the full ViewModel source as the bypass boundary.

Expected outcome

After this PR is merged:

  • singleton-backed ViewModels are more likely to use compile-safe heuristic generation
  • auto --ai is less likely to send large unnecessary model requests for unsafe targets
  • Android projects with global singleton collaborators should behave more predictably

Validation

  • ./gradlew --no-daemon :modules:test-generator:test --tests dev.diff2test.android.testgenerator.OpenAiResponsesTestGeneratorTest

Notes

  • this PR does not change provider-specific APIs
  • it only tightens the AI-vs-heuristic decision boundary

@gay00ung gay00ung self-assigned this Mar 26, 2026
@gay00ung gay00ung added the bug Something isn't working label Mar 26, 2026
@gay00ung gay00ung merged commit 03d18a5 into main Mar 26, 2026
1 check passed
@gay00ung gay00ung deleted the feature/ai-bypass-guard branch March 26, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant