# Instruction ↔ verifier traceability Every scored entry and every multiplier traces to a sentence of `instruction.md`, listed below in the order of the instruction. The three tab views are found by class name (`ItemsFragment`, `RecentsFragment`, `StorageFragment`, referenced by the main screen's pager), the ViewModels by what they extend (`ViewModel`/`AndroidViewModel`, also through a base class of the solver's own), never by names the solver chooses. The walkthrough (`functional/walk.py`) drives the app by on-screen text and content descriptions only (the search highlight is read from the screenshot inside the result's bounds). Part A is behaviour that must stay as it is, recorded on the untouched start state on the grading emulator (API 36, `system-images;android-36;google_apis;x86_64`, with status and navigation bars), where all of it passes; part B are the improvements the instruction asks for, all failing on the start state. ## Scoring (`spec.toml`, `emit_results.py`) The evaluator counts every validate line of a category once (the `weight` fields in `grade.sh`'s JSON are for diagnosis only); the category score is the mean of its lines. | Category | Weight | Lines | |---|---|---| | `functional` | 0.6 | 10 `functional#walk.`: walkthrough part B | | `regression` | 0.15 | 22 `regression#walk.`: walkthrough part A, including `editor_opens_file` | | `requirements` | 0.15 | `a_viewmodel_behind_each_tab` (/3), `observable_immutable_state`, `tab_views_only_render` (/3), `coroutines_on_injectable_dispatcher`, `viewmodel_unit_tests` (/3), `viewmodel_tests_cover_listed_areas` (/7), `agent_unit_tests_pass` | | `visual` | 0.1 | 7 `visual#…` screens (also the judge's `visual#missing_screenshot_`) | Multipliers (each failing line once): `gate#migration_started` ×0 (no tab migrated: its own ViewModel and a view free of file-system work, sorting/filtering and thread helpers), `cheating#no_prebuilt_binaries` ×0, 6 `constraint#…` ×0.5. Weights follow the acceptance standard for non-UI tasks (the screens stay as they are): functional 0.6, regression 0.15, requirements 0.15, visual 0.1, summing to 1. Functional and requirements lines fail on the start state; regression and visual lines pass there, and `gate#migration_started` ×0 keeps the start state at 0. Grading runs Gradle with `--offline` against the image's dependency cache (`spec.toml` build/unit_test, `grade.sh`). The task lets the answer add libraries, so `test.sh` first resolves the dependencies the answer declares, once, online through the image's repository mirrors (`tests/prefetch.init.gradle`, retried on a network hiccup); no build or test step downloads anything. ## Instruction sentence → checks | # | Instruction sentence (abridged) | Entries | How it is decided | |---|---|---|---| | 1 | "Each tab gets its own AndroidX `ViewModel`" | `requirements#a_viewmodel_behind_each_tab` (/3; a ViewModel shared by tabs counts for none of them); `gate#migration_started` ×0 | `check_requirements.py` step 1: a ViewModel class referenced by the tab view by name, through a property of another class that holds exactly one ViewModel, or through a state type only one ViewModel exposes | | 2 | "and the state the tab shows lives there: what is listed and how (sorting, hidden items, list or grid), the search with its results, the selection, and for Storage the usage per volume and per file type" | `requirements#tab_views_only_render` (row 4); part B (rows 7–9): the state survives rotation and process death | the tab views no longer read the sort, view-type and hidden-items settings (`getFolderSorting`, `getFolderViewType`, `shouldShowHidden`) or query storage volumes/`StorageStatsManager` (`FILE_WORK`) | | 3 | "The views observe that state as immutable UI state and hand user actions to the ViewModel" | `requirements#observable_immutable_state` | each tab's ViewModel (or its base class) exposes a public `StateFlow`/`Flow`/`LiveData` (or `asStateFlow()`/`stateIn`); publicly exposed mutable state halves the score | | 4 | "they no longer touch the file system, sort, filter or decide what to show" | `requirements#tab_views_only_render` (/3); `gate#migration_started` | the three view classes contain none of `FILE_WORK`: `File(`, `listFiles`, the repo's listing helpers (`getItems`, `getRegularItemsOf`, OTG/SAF/root listings, child counts), `MediaStore`/`contentResolver`/`queryCursor`, `sort`/`sortedWith`/`sortWith`, the three settings of row 2, `searchFiles`, storage-stats and volume queries, thread helpers | | 5 | "Background work runs in each ViewModel's coroutines on a dispatcher that tests can replace, instead of the threads and UI-thread callbacks the tabs use today" | `requirements#coroutines_on_injectable_dispatcher`; `gate#migration_started` (no thread helper left in the tab view) | each ViewModel (with its base classes) uses a coroutine scope (`viewModelScope`, `CoroutineScope(`, `MainScope(`, `.launch`), has a dispatcher a test can replace and uses it (`replaceable_dispatchers`): a constructor parameter typed `CoroutineDispatcher`/`CoroutineContext` or as a provider of the project's own (a class or interface exposing such a member), or a ViewModel `var` that is not private or protected (public, internal, `@VisibleForTesting internal`); Main does not count, whether injected as the default or left on viewModelScope and swapped only with `Dispatchers.setMain` (in production both run the background work on the main thread), nor do a hard-coded `Dispatchers.IO`, a global `object` or top-level `val` holding it, or a `private val`; and none of `ensureBackgroundThread`, `Thread(`, `runOnUiThread`, `GlobalScope`, `AsyncTask` (`BAD_THREADING`); any of them left in a tab view gives 0 | | 6 | "For the people using the app the tabs look and work as before" | part A, 22 `regression#walk.*` (regression category, one by one in the table "Row 6" below); 7 `visual#*` (visual category): `files_list`, `files_grid`, `files_selection`, `files_search`, `recents_tab`, `storage_documents`, `files_selection_rotated` | walkthrough (below). Visual: the status bar is pinned by SystemUI demo mode in the reference capture and in grading alike (`pin_system_bars` in `functional/visual.py`, which also pins the palette and three-button navigation); a screenshot pixel-identical to its reference (same size, every pixel equal) scores 1.0 without calling the judge (reasoning prefix `[method=pixel_identical]`), following the official visual_evaluator, which counts a passing native screenshot test as 1.0 and sends only the rest to the LLM; every other screen goes to Gemini against the start state's own screen with the instruction's allowed/required points (`visual_judge.py`), majority of 3 votes; selection screens are taken once the contextual bar has settled and compared with the start state's screen of the same bar layout (`visual/ref/` or `visual/ref-shifted/`, chosen by `validate.sh` from the capture metadata, logged in `visual_refs.txt`; on the API 36 grading emulator the bar settled clear of the breadcrumbs in every capture, so only `visual/ref/` exists and `validate.sh` uses it for both layouts); `files_selection_rotated` (the selection after rotating to landscape and back) uses the `files_selection` references, since rotation must keep the selection with its bar (row 7) | | 7 | "rotating the device keeps the folder, the scroll position, an open search with its query and results, and the current selection with its contextual action bar, including a selection made inside search results" | `functional#walk.selection_survives_rotation`, `selection_actions_survive_rotation`, `search_survives_rotation`, `scroll_position_survives_rotation`, `search_with_selection_survives_rotation` | selection counter "2 / N" in landscape and back; the restored bar deletes exactly the selected file (on disk) and keeps the other; the query in the search field with only matching files listed; the first visible item of a 40-file folder; "1 / N" with the query kept for a selection inside search results. The folder is kept implicitly: every one of these runs inside a sub-folder whose entries must still be listed | | 8 | "on the Recents and Storage tabs it keeps the search and the selection the same way" | `recents_selection_survives_rotation`, `recents_search_survives_rotation`, `storage_search_survives_rotation`, `storage_selection_survives_rotation` | counter "1 / N"; query in the search field and only matching files listed | | 9 | "when Android kills the app in the background and the user comes back to it, the Files tab reopens the same folder and the same search query" | `functional#walk.search_restored_after_process_death` (new); `regression#walk.folder_restored_after_process_death` (already true today) | HOME, `am kill` of the backgrounded process, relaunch: the query in the search field with its results; the same folder. No mechanism is prescribed, so there is no static check for `SavedStateHandle` | | 10 | "Cover the three ViewModels with JVM unit tests (listing, sorting, hidden items, storage usage, search, selection and state restoration) that pass with `./gradlew testFossDebugUnitTest` and do not need a device" | `requirements#viewmodel_unit_tests` (/3, nonempty JVM tests), `viewmodel_tests_cover_listed_areas` (/7), `agent_unit_tests_pass` (passed/total, 0 for no executed tests) | JVM test sources (not `androidTest`) that reference the tabs' ViewModels; an area is covered when a test case of such a file names it or exercises it in its body (a ViewModel call or the setting it is about); storage usage only in tests of the Storage tab's ViewModel | | 11 | "The UI stays View-based (no Compose in this change)" | `constraint#ui_stays_view_based` (×0.5) | no `@Composable` / `setContent {` in app sources | | 12 | "The app still builds in all three flavors (`core`, `foss`, `gplay`), debug and release" | `constraint#all_flavors_build_debug_and_release` (×0.5) | the 6 `assemble…` tasks, score = built/6 | | 13 | "`./gradlew detekt lintFossDebug` still passes" | `constraint#detekt_and_lint_pass` (×0.5) | both tasks, score = passed/2 | | 14 | "`detekt.yml`, `lint.xml` and the detekt and lint baselines stay as they are: new code gets no baseline entries" | `constraint#lint_and_detekt_not_loosened` (×0.5) | `quality.py`: configs equal to the start copies (comments/blank lines ignored), baseline entries a subset of the start baselines, no `ignoreFailures`/`abortOnError=false`/`disable` added to build files | | 15 | "Keep minimum and target SDK, the app id" | `constraint#app_id_and_sdk_levels_unchanged` (×0.5) | `aapt2 dump badging` vs `baseline/meta.json` | | 16 | "and the versions of the libraries the app already uses" | `constraint#existing_dependency_versions_unchanged` (×0.5) | `fossDebugRuntimeClasspath` of the submission vs `baseline/resolved_versions.json` (the start commit's resolved versions) | | 17 | "Work from this repository: don't look up this change in the project's upstream repository, its forks or published source archives" | not checked by this package | compliance cannot be inferred from this package's test results | | — | (no instruction sentence: integrity of the submission) | `cheating#no_prebuilt_binaries` ×0 | `.jar`/`.aar`/`.class`/`.dex`/`.so` files the start state does not have | ### Row 6: "look and work as before", check by check Row 6 covers browsing, breadcrumbs, sorting, view types, hidden items, search, selection and its actions, file operations, pull-to-refresh, Recents and Storage information. Every behavior below is a `regression#walk.` line of the regression category, recorded on the start state, where all pass. Rules shared by all: a menu entry counts only when it was offered and the menu is gone after the tap (`menu_action`), and absence from the list is asserted only while the list itself is showing (`folder_listed`). | Behaviour | `regression#walk.` | How it is decided | |---|---|---| | browsing, breadcrumbs | `browse_and_breadcrumbs` | Files → Internal → Download → the fixture folder lists its six files, its sub-folder and `long`; two folders down `inside.txt` is shown; tapping the fixture folder's crumb goes back up | | sorting | `sort_by_size_descending` | Sort by → Size → Descending: the first four files in size order (sizes chosen so that name and size order differ); name order restored afterwards | | view types | `grid_and_list_view` | Change view type → Grid puts the items in ≥ 2 columns, → List in 1 | | hidden items | `temporarily_show_hidden` | the hidden fixture file is not listed; "Temporarily show hidden" lists it; "Stop showing hidden", offered by the menu after the reload, hides it again | | search | `search_finds_nested_files` | the main search finds `inside.txt` two folders down | | search (results as shown) | `search_highlights_query` | `tabs_shared.search_highlights_query` (shared byte for byte with the Compose task): inside the result name's bounds on one screenshot, the text matching the query is drawn in a colour of its own, different from the background, from the name's normal text colour (read from the name's unmatched end) and from their anti-aliasing blends (±12 per channel); at least 400 such pixels pass (`HIGHLIGHT_MIN`). Colour-independent: which colour is the visual judge's business (a `MaterialTheme.colorScheme.primary` highlight passes). Threshold measured on the grading emulator with the pinned palette: start 859–915, reference 828–941, a colorScheme.primary highlight 798, no highlight 0 (see Reference capture) | | selection, renaming | `selection_rename` | long-press → Rename on the selection bar (content description) → new name: renamed on disk and shown; every other entry still listed, the folders' item counts equal their files on disk, no hidden file shown | | copying | `selection_copy_to_folder` | selection bar overflow → Copy to → sub-folder: the copy is on disk, the original kept | | deleting | `selection_delete` | Delete on the selection bar, confirmation, the file gone on disk and from the list | | moving | `selection_move_to_folder` | overflow → Move to → sub-folder: in the target on disk, gone from the source and from the list | | compressing | `selection_compress` | overflow → Compress → "Compress as" → OK: the `.zip` written and listed, the original kept | | the listing after these operations | `folder_item_counts` | after rename, copy, delete and move each folder's "N items" equals its non-hidden entries on disk | | creating | `create_new_folder` | the create button → name → Folder → OK: the folder exists and is listed | | pull-to-refresh | `pull_to_refresh_shows_external_changes` | a file created outside the app appears after pulling the list down | | the Recents list | `recents_lists_recent_files` | a freshly created file is listed in Recents, and the search inside Recents finds it | | the storage usage per volume and file type | `storage_usage_per_file_type`, `storage_free_space_shown` | all six file types show a size and a 3 MB random `.zip` fixture is counted under Archives; each volume shows its free-space figure with its "free" label | | its links to the file-type lists | `storage_file_type_list_opens` | Storage → Archives lists the fixture `.zip` | | search (Storage tab) | `storage_search_finds_file` | the Storage tab's search lists the fixture `.zip` | | (the folder after process death, row 9) | `folder_restored_after_process_death` | HOME, `am kill`, relaunch: the same folder is open | | opening files | `editor_opens_file` | a text file tapped in the Files tab (Download/bench) opens in the app's editor with its content: the Compose task's judgment, byte for byte (`editor_shared.py`); run last, after every other check. The start state passes it, so it is a multiplier like the rest of part A, not scored | | (nothing breaks) | `no_crash_recorded` | no crash of the app in the crash buffer during the whole walkthrough | Not graded: "hand user actions to the ViewModel" (as method calls or otherwise; no static check), and the opening's diagnosis (testability is graded through row 10). ## Shared modules The Compose and ViewModel tasks use byte-identical `tests/functional/adbui.py` (UI driver), `tests/functional/tabs_shared.py` (hidden items, query highlight, item counts and the listing after rename), `tests/functional/editor_shared.py` (opening a text file in the editor and its helpers), `tests/lib/ktscan.py`, and `environment/`. Each task has its own walkthrough driver, fixtures, check registration and bar selectors. ## Reference capture and measurement basis The reference environment uses `android-36;google_apis` with cached Commons sources and test libraries and Maven mirrors. References come from the untouched start state using the same capture order as grading: a `-wipe-data` boot, `start-emulator.sh`, `functional/visual.py`, then `functional/walk.py`. Material You palette and three-button navigation settings are pinned and read back; the status bar is fixed through SystemUI demo mode (12:00, full battery and Wi-Fi, no notification icons), and the on-screen keyboard is disabled. The resolved system colours must match `EXPECTED_SYSTEM_COLOURS`; otherwise capture ends with an infrastructure error. The preset palette uses seed `7A90C8` and TONAL_SPOT. Three-button navigation uses `navigation_mode` 0 with a 126 px bar on the 1080 × 2400 display. Gesture navigation has a 63 px bar and its anti-aliased handle can vary by 6 pixels at one colour level across boots, so it is unsuitable for exact screenshot comparison. - Reference screenshots are byte-identical in RGBA across four `-wipe-data` boots. `files_selection_rotated.png` copies the selected-state reference because rotation is required to preserve selection and its bar. - On the API 36 emulator the reference bar is clear of the breadcrumbs. The package contains `visual/ref/`; `validate.sh` uses that reference when no shifted layout reference is available. - The start state passes all 22 part A checks and none of the 10 part B checks. Its search highlight measured 840 pixels in this walkthrough. - The shared query-highlight threshold (`tabs_shared.HIGHLIGHT_MIN` = 400) is measured with the pinned palette: start state 859–915 pixels, reference solution 828–941, colorScheme.primary highlight 798, no highlight 0. The Compose task's traceability notes give the channel tolerance and known anti-aliasing limitation. ## Evidence completeness `functional/walk.py` atomically writes `functional.json` at startup and at each check's start and finish; measured results are saved before screenshots. The result records `complete`, `expected_check_ids`, `completed_check_ids`, `active_check`, interruption signals and collection exceptions. `grade.sh` records the walkthrough's process exit code and completeness, and marks unfinished walks with `WALK_INCOMPLETE`. `infra_guard.py` preserves measurements while suppressing a final reward for incomplete evidence. An incomplete walkthrough alone does not establish whether the app or emulator caused termination. Missing functional or screenshot evidence requires device verification and cannot be inferred from the checks that finished. ## Walkthrough time-out `walk.py` has 50 minutes. If it is cut off and, right after, the emulator still answers (`sys.boot_completed=1`, `adb shell` responds) and the walk had already completed at least one check, the app hung inside the active check: `grade.sh` records `app_timeout` in `work/walk-process.json`, the unreached checks stay failed and the run is graded. A time-out with an unresponsive emulator, or before any check completes, is still treated as incomplete evidence and not graded.