P3: NoIndependentViewModelStateFileScanTest — architecture regression gate

Fails CI if any future VM regresses to the pre-migration pattern of
owning independent MutableStateFlow read-state. Two assertions:

1. every_read_state_vm_accepts_iDataManager_ctor_param
   Scans composeApp/src/commonMain/kotlin/com/tt/honeyDue/viewmodel/ and
   requires every VM to either declare `dataManager: IDataManager` as a
   constructor param or be in WORKFLOW_ONLY_VMS allowlist (currently
   TaskCompletion, Onboarding, PasswordReset).

2. read_state_flows_should_be_derived_not_independent
   Flags any `private val _xxxState = MutableStateFlow(...)` whose
   field-name prefix isn't on the mutation-feedback allowlist (create/
   update/delete/toggle/…). Read-state MUST derive from DataManager via
   .map + .stateIn pattern. AuthViewModel file-level allowlisted
   (every one of its 11 states is legitimate one-shot mutation feedback).

Paired stub in commonTest documents the rule cross-platform; real scan
lives in androidUnitTest where java.io.File works. Runs with
./gradlew :composeApp:testDebugUnitTest --tests "*architecture*".

See docs/parity-gallery.md "Known limitations" for the history of the
Dec 3 2025 partial migration this gate prevents regressing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trey T
2026-04-19 18:51:36 -05:00
parent 42ccbdcbd6
commit 316b1f709d
2 changed files with 149 additions and 0 deletions
@@ -0,0 +1,19 @@
package com.tt.honeyDue.architecture
// Stub — the real enforcement lives in androidUnitTest where
// `java.io.File` is available and the scan can read VM source text
// directly from disk. Keeping a commonTest placeholder documents the
// architectural rule to anyone browsing test code cross-platform.
//
// See:
// composeApp/src/androidUnitTest/kotlin/com/tt/honeyDue/architecture/
// NoIndependentViewModelStateFileScanTest.kt
//
// Rule (enforced by the file-scan test):
// Every ViewModel in commonMain/kotlin/com/tt/honeyDue/viewmodel/ must
// either accept `dataManager: IDataManager = DataManager` as its
// constructor parameter (so read-state can be derived reactively from
// DataManager) or be explicitly allowlisted as a workflow/mutation-only
// VM that has no cached state to mirror.
//
// Context: docs/parity-gallery.md "Known limitations" section.