@1aboveio/skills 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/.codex-plugin/resources.json +157 -154
  3. package/README.md +1 -1
  4. package/package.json +5 -5
  5. package/skills/app-dev/airflow/SKILL.md +1 -1
  6. package/skills/app-dev/android-development/SKILL.md +127 -0
  7. package/skills/app-dev/android-development/references/android-conventions.md +117 -0
  8. package/skills/app-dev/{android-foundation → android-development}/references/ci.md +10 -6
  9. package/skills/app-dev/{android-foundation → android-development}/references/diagnosis.md +44 -15
  10. package/skills/app-dev/android-development/references/feature-work.md +186 -0
  11. package/skills/app-dev/android-development/references/framework-choice.md +88 -0
  12. package/skills/app-dev/{android-foundation → android-development}/references/gotchas.md +43 -6
  13. package/skills/app-dev/android-development/references/init.md +126 -0
  14. package/skills/app-dev/android-development/references/setup.md +389 -0
  15. package/skills/app-dev/android-development/references/workspace.md +156 -0
  16. package/skills/app-dev/android-development/scripts/init.mjs +477 -0
  17. package/skills/app-dev/app-debug/SKILL.md +1 -1
  18. package/skills/app-dev/better-auth/SKILL.md +1 -1
  19. package/skills/app-dev/data-catalog/SKILL.md +53 -16
  20. package/skills/app-dev/data-catalog/scripts/persist-conventions-core.mjs +231 -21
  21. package/skills/app-dev/data-catalog/scripts/persist-conventions.mjs +12 -1
  22. package/skills/app-dev/data-quality/SKILL.md +1 -1
  23. package/skills/app-dev/ios-foundation/SKILL.md +2 -2
  24. package/skills/app-dev/monorepo/SKILL.md +1 -1
  25. package/skills/app-dev/nextjs-fullstack/SKILL.md +1 -1
  26. package/skills/app-dev/prisma-setup/SKILL.md +1 -1
  27. package/skills/app-dev/pyspark/SKILL.md +1 -1
  28. package/skills/app-dev/python-backend/SKILL.md +1 -1
  29. package/skills/app-dev/shadcn/SKILL.md +1 -1
  30. package/skills/app-dev/zod-v4/SKILL.md +1 -1
  31. package/skills/cicd/cloud-build/SKILL.md +1 -1
  32. package/skills/cicd/cloud-debug/SKILL.md +1 -1
  33. package/skills/cicd/cloud-deploy/SKILL.md +1 -1
  34. package/skills/cicd/docker/SKILL.md +1 -1
  35. package/skills/cicd/github-actions/SKILL.md +1 -1
  36. package/skills/cicd/github-flow/SKILL.md +10 -1
  37. package/skills/cicd/github-flow/scripts/persist-conventions-core.mjs +231 -21
  38. package/skills/cicd/github-flow/scripts/persist-conventions.mjs +18 -1
  39. package/skills/cicd/google-cloud/SKILL.md +1 -1
  40. package/skills/cicd/mergify/SKILL.md +1 -1
  41. package/skills/cicd/podman/SKILL.md +1 -1
  42. package/skills/content/article-review/SKILL.md +1 -1
  43. package/skills/content/article-to-image/SKILL.md +1 -1
  44. package/skills/content/flowchart-svg/SKILL.md +1 -1
  45. package/skills/content/image-gen/SKILL.md +1 -1
  46. package/skills/content/mermaid/SKILL.md +1 -1
  47. package/skills/content/wechat-article-writer/SKILL.md +1 -1
  48. package/skills/content/wechat-publisher/SKILL.md +1 -1
  49. package/skills/content/wechat-search/SKILL.md +1 -1
  50. package/skills/content/xai-search/SKILL.md +1 -1
  51. package/skills/core/distill-writing/SKILL.md +7 -1
  52. package/skills/core/doc-to-md/SKILL.md +1 -1
  53. package/skills/core/editorial-review/SKILL.md +1 -1
  54. package/skills/core/house-style/SKILL.md +1 -1
  55. package/skills/core/house-style/references/persistence.md +8 -3
  56. package/skills/core/house-style/scripts/init-guidance.mjs +1 -1
  57. package/skills/core/plain-language/SKILL.md +1 -1
  58. package/skills/core/polish-cn/SKILL.md +1 -1
  59. package/skills/core/reg-parser/SKILL.md +1 -1
  60. package/skills/core/terminology/SKILL.md +1 -1
  61. package/skills/core/terminology/references/init.md +11 -0
  62. package/skills/core/write-doc/SKILL.md +1 -1
  63. package/skills/core/write-report/SKILL.md +1 -1
  64. package/skills/engineering/better-review/SKILL.md +1 -1
  65. package/skills/engineering/e2e-test/SKILL.md +1 -1
  66. package/skills/engineering/engineering/SKILL.md +25 -4
  67. package/skills/engineering/engineering/references/init-scope.md +10 -3
  68. package/skills/engineering/engineering/references/scope-management.md +11 -0
  69. package/skills/engineering/engineering/scripts/init.mjs +65 -17
  70. package/skills/engineering/engineering/scripts/persist-conventions-core.mjs +231 -21
  71. package/skills/engineering/engineering/scripts/persist-conventions.mjs +48 -21
  72. package/skills/engineering/engineering-runtime/SKILL.md +1 -1
  73. package/skills/engineering/engineering-runtime/coherence/workflow.json +13 -13
  74. package/skills/engineering/ensure-coverage/SKILL.md +1 -1
  75. package/skills/engineering/golden-path/SKILL.md +1 -1
  76. package/skills/engineering/harness-runtime/SKILL.md +1 -1
  77. package/skills/engineering/resolve-issues/SKILL.md +1 -1
  78. package/skills/engineering/resolve-issues/references/exploration.md +1 -1
  79. package/skills/engineering/resolve-issues/references/review.md +27 -4
  80. package/skills/engineering/resolve-release/SKILL.md +1 -1
  81. package/skills/engineering/rush-issues/SKILL.md +1 -1
  82. package/skills/engineering/rush-release/SKILL.md +1 -1
  83. package/skills/engineering/test-quality/SKILL.md +3 -1
  84. package/skills/engineering/test-quality/scripts/persist-conventions-core.mjs +231 -21
  85. package/skills/engineering/test-quality/scripts/persist-conventions.mjs +13 -1
  86. package/skills/risk-compliance/compliance-audit/SKILL.md +1 -1
  87. package/skills/risk-compliance/contract-compare/SKILL.md +1 -1
  88. package/skills/risk-compliance/contract-review/SKILL.md +1 -1
  89. package/skills/risk-compliance/doc-authenticity/SKILL.md +1 -1
  90. package/skills/risk-compliance/fraud-detection/SKILL.md +1 -1
  91. package/skills/risk-compliance/payment-analysis/SKILL.md +1 -1
  92. package/skills/risk-compliance/portfolio-payment-analysis/SKILL.md +1 -1
  93. package/skills/risk-compliance/similar-domain/SKILL.md +1 -1
  94. package/skills/risk-compliance/tld-detection/SKILL.md +1 -1
  95. package/skills/app-dev/android-foundation/SKILL.md +0 -248
  96. package/skills/app-dev/android-foundation/references/delivery-focus.md +0 -31
  97. package/skills/app-dev/android-foundation/references/feature-work.md +0 -50
  98. package/skills/app-dev/android-foundation/references/setup.md +0 -188
  99. package/skills/app-dev/android-foundation/references/workspace.md +0 -81
  100. /package/skills/app-dev/{android-foundation → android-development}/LICENSE +0 -0
  101. /package/skills/app-dev/{android-foundation → android-development}/assets/android-ci-job.yml +0 -0
  102. /package/skills/app-dev/{android-foundation → android-development}/release-check.mjs +0 -0
  103. /package/skills/app-dev/{android-foundation → android-development}/scripts/device-run.sh +0 -0
  104. /package/skills/app-dev/{android-foundation → android-development}/scripts/workspace-runtime/bin/workspaces.mjs +0 -0
  105. /package/skills/app-dev/{android-foundation → android-development}/scripts/workspace-runtime/native-workspace.mjs +0 -0
  106. /package/skills/app-dev/{android-foundation → android-development}/scripts/workspace-runtime/workspace-lifecycle.mjs +0 -0
@@ -0,0 +1,389 @@
1
+ # Android setup and device execution
2
+
3
+ Read [setup rules](#setup-rules) and [owned-resource cleanup](#owned-resource-cleanup)
4
+ before these commands. All stages are for fresh setup proof; established workspaces use
5
+ the [validation ladder](../SKILL.md#validation-ladder) and the
6
+ [owned development session](#owned-development-session), and rerun only invalidated stages.
7
+
8
+ Treat the shell blocks as an Expo/pnpm/UiAutomator example, not a required stack. Use the
9
+ repo's verified package manager, native build, bundle/export step and existing test harness.
10
+ Keep ownership, installed-toolchain, deadlines, cleanup and proof requirements mandatory;
11
+ do not install Expo, Python automation or a new harness to make another RN project fit.
12
+
13
+ Replace each `<placeholder>` with the repo's real value. Tool shells do not keep variables,
14
+ functions or traps between calls: step 1 resolves the workspace and writes
15
+ `.cache/android-env.sh`, which also `cd`s into it; every later block starts by sourcing it by
16
+ absolute path, and steps 6–8 run as one command through the bundled `scripts/device-run.sh`.
17
+
18
+ ## Contents
19
+
20
+ - [Fresh setup stages](#1-workspace-and-environment)
21
+ - [Owned development session](#owned-development-session)
22
+ - [Scoped ABI selection](#scoped-abi-selection)
23
+ - [Setup rules](#setup-rules)
24
+ - [Owned-resource cleanup](#owned-resource-cleanup)
25
+ - [Setup evidence](#evidence-record)
26
+
27
+ ## 1. Workspace and environment
28
+
29
+ Workspace precedence is owned by [workspace.md](workspace.md). Do not create a worktree,
30
+ switch branch, fetch or reset when the caller supplied an isolated workspace.
31
+
32
+ ```bash
33
+ set -euo pipefail
34
+ ASSIGNED_WORKSPACE=<assigned-workspace-or-empty>
35
+ CANDIDATE_HEAD=<candidate-head-or-empty>
36
+ WORKSPACE="${ASSIGNED_WORKSPACE:?use the caller assignment or native-start result from workspace.md}"
37
+ test -d "$WORKSPACE"
38
+ git -C "$WORKSPACE" rev-parse --is-inside-work-tree >/dev/null
39
+ cd "$WORKSPACE"
40
+ actual_head="$(git rev-parse HEAD)"
41
+ test -z "$CANDIDATE_HEAD" || test "$actual_head" = "$(git rev-parse "$CANDIDATE_HEAD^{commit}")" || {
42
+ echo "workspace HEAD $actual_head != candidate $CANDIDATE_HEAD; report it; do not switch" >&2
43
+ exit 1
44
+ }
45
+ mkdir -p .cache
46
+ { echo 'set -euo pipefail'; printf 'cd %q\n' "$PWD"; printf 'export ANDROID_SOURCE_HEAD=%q\n' "$actual_head"; } > .cache/android-env.sh
47
+ cat >> .cache/android-env.sh <<'ENV'
48
+
49
+ # Repo-specific names, read from the repo's journey wrapper and device harness.
50
+ export APP_FILTER=<android-workspace-package> # pnpm --filter target
51
+ export DEVICE_PYTHON_DIR=<venv-dir-the-wrapper-reads> # e.g. the default in the wrapper
52
+ export DB_NAME_PREFIX=<db-prefix-the-harness-accepts> # the harness rejects other names
53
+ export DB_URL_VAR=<harness-admin-url-variable> # e.g. SHARD_ADMIN_URL
54
+ export DB_NAME_VAR=<harness-db-name-variable> # e.g. SHARD_DB_NAME
55
+
56
+ # Host paths. Example values are for Apple Silicon with Android Studio.
57
+ export JAVA_HOME=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home
58
+ export ANDROID_HOME="$HOME/Library/Android/sdk"
59
+ export ANDROID_SDK_ROOT="$ANDROID_HOME"
60
+ export SOURCE_AVD="$HOME/.android/avd/<installed-avd>.avd"
61
+ export SEED_GRADLE_HOME="$HOME/.gradle"
62
+ export PATH="$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:$PATH"
63
+
64
+ # Private caches.
65
+ export GRADLE_USER_HOME="$PWD/.cache/gradle"
66
+ export ANDROID_USER_HOME="$PWD/.cache/android-user"
67
+ export ANDROID_AVD_HOME="$PWD/.cache/android-avd"
68
+ export TMPDIR="$PWD/.cache/tmp"
69
+ export npm_config_cache="$PWD/.cache/npm"
70
+ export npm_config_devdir="$PWD/.cache/node-gyp"
71
+ export PNPM_CONFIG_STORE_DIR="$PWD/.cache/pnpm-store"
72
+ export PNPM_CONFIG_CACHE_DIR="$PWD/.cache/pnpm"
73
+ case "${JAVA_TOOL_OPTIONS:-}" in *java.io.tmpdir*) ;; *)
74
+ export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:+$JAVA_TOOL_OPTIONS }-Djava.io.tmpdir=$TMPDIR" ;; esac
75
+
76
+ # Run identifiers: an even console port in 5554-5584 (adb scans only that range),
77
+ # and backend/Metro ports under the names the journey wrapper reads.
78
+ export SETUP_AVD=<new-unique-avd-name>
79
+ export EMULATOR_PORT=<even-port-5554-5584>
80
+ export ANDROID_BACKEND_PORT=<free-port>
81
+ export ANDROID_METRO_PORT=<free-port>
82
+ # Choose the whole-journey deadline; zero disables it and is not suitable for unattended runs.
83
+ export JOURNEY_SECONDS=<positive-journey-timeout-seconds>
84
+ ENV
85
+ source .cache/android-env.sh
86
+ mkdir -p "$TMPDIR" "$npm_config_cache" "$npm_config_devdir" \
87
+ "$ANDROID_USER_HOME" "$ANDROID_AVD_HOME" .cache/logs
88
+
89
+ node --version; pnpm --version; java -version; python3 --version
90
+ adb version; "$ANDROID_HOME/emulator/emulator" -version
91
+ # Versions come from the repo's native config and CI preflight.
92
+ for component in platforms/android-<api> build-tools/<build-tools> ndk/<ndk> cmake/<cmake>; do
93
+ test -d "$ANDROID_HOME/$component" || { echo "Missing SDK: $component" >&2; exit 1; }
94
+ done
95
+ ```
96
+
97
+ The recorded standalone path is reused on retries; verify its lifecycle record names this
98
+ run, branch and base. If an assigned path is missing, is not a Git worktree, or is at another
99
+ revision, stop and report instead of creating another checkout. Never fall back to
100
+ `../<repo>-android-setup`.
101
+
102
+ If the wrapper reads ports or Python under other names, export aliases in
103
+ `android-env.sh` **as well as** the bundled runner's required names. For example,
104
+ `export APP_METRO_PORT="$ANDROID_METRO_PORT"`; both must select the same port. Adapt
105
+ `DB_URL_VAR` and `DB_NAME_VAR` to the actual harness, not its fallback defaults.
106
+
107
+ ## 2. Install and check
108
+
109
+ Run the repo's frozen install, relevant tests and typecheck. Export/bundle using the
110
+ selected framework's supported command; use `expo export` only for an Expo project.
111
+ Create a Python venv and pin UiAutomator only when the existing harness uses them.
112
+ For Yarn/npm or an instrumentation-only harness, substitute its verified commands and
113
+ omit unused pnpm/Python environment settings; do not invent replacements or install tools.
114
+
115
+ ```bash
116
+ source <worktree>/.cache/android-env.sh
117
+ pnpm install --frozen-lockfile --store-dir "$PWD/.cache/pnpm-store"
118
+ pnpm --filter "$APP_FILTER" test
119
+ pnpm --filter "$APP_FILTER" typecheck
120
+ EXPO_PUBLIC_API_URL=https://app.invalid \
121
+ pnpm --filter "$APP_FILTER" exec expo export --platform android
122
+ python3 -m venv "$DEVICE_PYTHON_DIR"
123
+ "$DEVICE_PYTHON_DIR/bin/python3" -m pip install uiautomator2==<harness-pinned-version>
124
+ ```
125
+
126
+ ## 3. Gradle dependencies (pick one)
127
+
128
+ Seed from a trusted Gradle home:
129
+
130
+ ```bash
131
+ source <worktree>/.cache/android-env.sh
132
+ mkdir -p "$GRADLE_USER_HOME/caches/modules-2/files-2.1"
133
+ rsync -r --ignore-existing \
134
+ --exclude='*.lock' --exclude='*.lck' --exclude='*.tmp' \
135
+ "$SEED_GRADLE_HOME/caches/modules-2/files-2.1/" \
136
+ "$GRADLE_USER_HOME/caches/modules-2/files-2.1/"
137
+ ```
138
+
139
+ Or wire a trusted Maven proxy into the private Gradle home. Append the exports to
140
+ `android-env.sh` so the build in step 4 sees them. Route every repository the build uses,
141
+ JitPack included; a route left unset goes straight upstream.
142
+
143
+ If the opted-in proxy fails, stop and fix its routing; never fall back to direct
144
+ downloads or disable TLS checks. The proxy covers Maven repositories only. Route the
145
+ Gradle wrapper ZIP and pnpm as the repo's `CONTRIBUTING.md` requires. Without a seed or
146
+ opted-in proxy, use upstream intentionally and allow for a cold build.
147
+
148
+ ```bash
149
+ source <worktree>/.cache/android-env.sh
150
+ cat >> "$PWD/.cache/android-env.sh" <<'ENV'
151
+ export GRADLE_MAVEN_REPOSITORY=<proxy>/maven/
152
+ export GRADLE_GOOGLE_REPOSITORY=<proxy>/google-maven/
153
+ export GRADLE_PLUGIN_REPOSITORY=<proxy>/gradle-plugins/
154
+ export GRADLE_JITPACK_REPOSITORY=<proxy>/jitpack/
155
+ ENV
156
+ curl --fail --silent --show-error --max-time 10 <proxy-health-url>
157
+ install -d "$GRADLE_USER_HOME/init.d"
158
+ install -m 0644 <path/to/proxy.init.gradle> "$GRADLE_USER_HOME/init.d/proxy.init.gradle"
159
+ ```
160
+
161
+ ## 4. Build
162
+
163
+ ```bash
164
+ source <worktree>/.cache/android-env.sh
165
+ pnpm build:android --max-workers=2 -Dorg.gradle.parallel=false \
166
+ -Pandroid.builder.sdkDownload=false --console=plain --info \
167
+ 2>&1 | tee .cache/logs/gradle.log
168
+ APK=<path/to/app/build/outputs/apk/debug/app-debug.apk>
169
+ shasum -a 256 "$APK" # sha256sum on Linux
170
+ unzip -l "$APK" | grep -E 'lib/[^/]+/libreactnative\.so'
171
+ ```
172
+
173
+ ## 5. Owned emulator
174
+
175
+ Copy only `config.ini`, never user data or snapshots. Verify that `image.sysdir.1` is an
176
+ installed, host-compatible system image and that `target` matches it. Give the guest
177
+ 4 GB to avoid mid-journey ADB drops. A hand-written config needs the hardware keys in
178
+ [gotchas](gotchas.md#a-hand-written-avd-misses-the-screen).
179
+
180
+ ```bash
181
+ source <worktree>/.cache/android-env.sh
182
+ test -f "$SOURCE_AVD/config.ini"
183
+ test ! -e "$ANDROID_AVD_HOME/$SETUP_AVD.ini"
184
+ test ! -e "$ANDROID_AVD_HOME/$SETUP_AVD.avd"
185
+ grep '^image.sysdir.1' "$SOURCE_AVD/config.ini" # must be an installed, host-compatible image
186
+ mkdir "$ANDROID_AVD_HOME/$SETUP_AVD.avd"
187
+ # Copy without the source's RAM size and give the guest 4 GB (gotchas: adb transport drops).
188
+ grep -Ev '^hw\.ramSize[[:space:]]*=' "$SOURCE_AVD/config.ini" > "$ANDROID_AVD_HOME/$SETUP_AVD.avd/config.ini"
189
+ echo 'hw.ramSize=4096' >> "$ANDROID_AVD_HOME/$SETUP_AVD.avd/config.ini"
190
+ printf 'avd.ini.encoding=UTF-8\npath=%s\ntarget=android-<api>\n' \
191
+ "$ANDROID_AVD_HOME/$SETUP_AVD.avd" > "$ANDROID_AVD_HOME/$SETUP_AVD.ini"
192
+ ```
193
+
194
+ ## 6–8. Cleanup, resources and journey: one command
195
+
196
+ ```bash
197
+ source <worktree>/.cache/android-env.sh
198
+ bash <skill-base-dir>/scripts/device-run.sh \
199
+ --drop node <path/to/device-harness.mjs> drop \
200
+ -- bash <path/to/foundation-journey-wrapper.sh>
201
+ ```
202
+
203
+ Pass each command as separate words, not as one quoted string. The script:
204
+
205
+ 1. Registers the cleanup trap before anything starts.
206
+ 2. Refuses an emulator port outside 5554–5584 and any busy port.
207
+ 3. Starts the ADB server, then the emulator (its PID recorded), then `postgres` with
208
+ `--cidfile` on a random loopback port. Override the image with `POSTGRES_IMAGE`.
209
+ 4. Waits for `sys.boot_completed=1` and `pg_isready`. Startup/readiness and cleanup
210
+ commands have a 30-second limit (`BOUNDED_SECONDS`); exit 124 is terminal. The journey
211
+ uses the separate `JOURNEY_SECONDS` deadline. Leave time for cleanup after that deadline.
212
+ 5. Exports `$DB_URL_VAR`, `$DB_NAME_VAR` (`$DB_NAME_PREFIX` plus a unique suffix) and
213
+ `ANDROID_EMULATOR_SERIAL`, then runs the journey.
214
+ 6. Drops the database, stops the emulator PID (`TERM`, then `KILL` after 10 seconds),
215
+ removes the container by its CID, and prints `original_stage_exit=<n> cleanup_exit=<n>`.
216
+ It exits with the journey's status if the journey failed, else the cleanup status.
217
+
218
+ The runner supervises the journey's process group. Journey children must stay in that
219
+ group; a wrapper that deliberately creates detached services must stop those services
220
+ through its own owner. Send TERM to the launcher and allow its cleanup to finish rather
221
+ than killing it immediately. The generic runner inherits the caller's ADB endpoint and
222
+ does not stop that server: use a verified private endpoint on a shared host and close it
223
+ through the caller's owner. Capture the command's exit status and final summary line.
224
+
225
+ Expect every selected scenario's `PASS` marker, screenshots, and backend and Metro logs
226
+ when the selected variant uses those services. Preserve the failed checkpoint's evidence
227
+ before cleanup. A release build with embedded assets does not require Metro by default.
228
+
229
+ ## Owned development session
230
+
231
+ Apply the safety/proof requirements above to a new environment or invalidated setup
232
+ assumptions, using only the repo's applicable stages and verified tools. The example
233
+ commands are not universal requirements or a per-incremental-build checklist. Ordinary iteration runs against the
234
+ owned development session described in [workspace.md](workspace.md): one development emulator
235
+ and ADB endpoint, Metro, one compatible Gradle daemon on the private `GRADLE_USER_HOME`, and
236
+ the workspace's build outputs. Rerun only the stages whose inputs changed, and end the session
237
+ or hand it off before finishing.
238
+
239
+ Keep that fast path fast:
240
+
241
+ - Reuse the compatible Gradle daemon and private outputs where repo policy permits. CI or
242
+ one-shot verification may require `--no-daemon`; do not copy it automatically into a
243
+ local fast path, change global daemon settings or use shared writable caches. Preserve
244
+ the actual host/slot capacity limits and repo JVM constraints in every lane.
245
+ - Add no configuration-cache, parallel, worker or JVM tuning without a measured need. Keep
246
+ the repo's JVM and resource-capacity settings, and keep this recipe's own flags as written.
247
+ - A tracked native project that already builds and installs needs no routine `expo prebuild`
248
+ or `clean`, and no dependency reinstall.
249
+ - Do not rerun the disposable stack from stages 5–8 for an edit. Reuse the existing
250
+ development owner. At L2/L3, follow the gate's fresh-state requirements; an authorized
251
+ fresh install on an existing owned emulator need not boot another guest if data isolation
252
+ is sufficient. The generic runner is not a second owner for an existing session.
253
+ - Verify every Gradle task name against the actual task graph before using it. `assembleDebug`
254
+ and `installDebug` may also package instrumentation or test APKs, so do not treat either as
255
+ app-only proof without checking the packaged artifacts.
256
+
257
+ ### Scoped ABI selection
258
+
259
+ Focused L1 work may build only the ABI of the owned device, where repo policy permits. Ask
260
+ the device instead of guessing, and name its serial so both commands respect the caller's ADB
261
+ endpoint. Give the probe a 30-second command deadline through the existing owner; do not
262
+ wait indefinitely on a lost transport:
263
+
264
+ ```bash
265
+ source <worktree>/.cache/android-env.sh
266
+ adb -s <owned-serial> shell getprop ro.product.cpu.abi | tr -d '\r'
267
+ # The ABIs the native build configures, e.g. the reactNativeArchitectures values.
268
+ grep -n 'reactNativeArchitectures' <native-gradle-properties-file>
269
+ ```
270
+
271
+ The printed ABI must appear in that configured list; stop and report any other value. Then
272
+ scope one command to it, through the same build entry point as step 4, which forwards Gradle
273
+ arguments. Tool shells do not keep variables between calls, so restate the verified value:
274
+
275
+ ```bash
276
+ source <worktree>/.cache/android-env.sh
277
+ DEVICE_ABI=<verified-abi-from-the-previous-command>
278
+ pnpm <repo-build-entry> -PreactNativeArchitectures="$DEVICE_ABI" \
279
+ -Pandroid.builder.sdkDownload=false
280
+ ```
281
+
282
+ Verify that this entry point forwards both properties, and retain the repo's applicable
283
+ capacity and build-safety flags. Flags from an earlier command are not inherited.
284
+
285
+ Do not change the shared checked-in ABI defaults, persist the flag in `gradle.properties`, or
286
+ hardcode `x86` or `x86_64`, and keep the every-configured-ABI build as setup proof and release
287
+ acceptance. An emulator-ABI build proves only that ABI.
288
+
289
+ ## Setup rules
290
+
291
+ - Resolve the workspace first; [workspace.md](workspace.md) owns
292
+ precedence: an assigned isolated workspace and candidate HEAD win, feature work, fixes and
293
+ diagnosis reuse the owned workspace, and standalone setup creates one managed workspace
294
+ only with no usable assignment. Read its actual HEAD; never substitute `origin/main`, a new
295
+ branch or another checkout, mutate a peer's checkout or symlink its writable `node_modules`.
296
+ - Tool shells keep no variables, functions or traps between calls. Write the environment
297
+ to `.cache/android-env.sh` once and source it at the start of every command. Use the
298
+ repo's existing owned-resource launcher. For a new local setup without one, use
299
+ `scripts/device-run.sh` for stages 6–8 in one command. Do not wrap an existing owner
300
+ with a second emulator/database lifecycle.
301
+ - Keep local writable caches private under `.cache/`: Gradle home, Android user/AVD
302
+ homes, temporary files, npm, node-gyp and pnpm. In CI, an already isolated runner slot
303
+ may provide those paths; verify its ownership contract rather than layering another
304
+ cache system on top. Never share writable state across concurrent owners.
305
+ - Read toolchain versions from the repo: the root `packageManager` and `engines`, the
306
+ native Gradle config, and the CI preflight. The repo is the source of truth, not this skill.
307
+ - Check that every required SDK component (platform, build-tools, NDK, CMake,
308
+ platform-tools, emulator, system image) is already installed. If one is missing, stop and
309
+ provision it separately. Never upgrade or install into a shared SDK during a journey;
310
+ build with `-Pandroid.builder.sdkDownload=false`.
311
+ - Install with `--frozen-lockfile`. Do not routinely run `clean`, reinstall dependencies or
312
+ run `expo prebuild`. The native project is tracked, and prebuild needs a reviewed native
313
+ change.
314
+ - Build every configured ABI for setup proof and release acceptance. An emulator-only
315
+ APK proves only that ABI. L1 focused native validation may use the emulator ABI where
316
+ repo policy permits, discovered from the owned device as in
317
+ [scoped ABI selection](#scoped-abi-selection); retain additional checks for affected ABI
318
+ configuration and all required native/ABI CI gates. Do not claim all-ABI proof from one
319
+ incremental build.
320
+ - Determine how the selected build loads code and assets. A typical debug build needs
321
+ Metro; a release build normally embeds its bundle. Do not introduce Metro or debug
322
+ preferences into a release failure without evidence that the build uses them.
323
+ A successful build does not prove execution on a device.
324
+
325
+ Ordinary edits reuse the [owned development session](#owned-development-session) instead of
326
+ repeating these stages. Every stop still follows the cleanup rules below.
327
+
328
+ ## Owned-resource cleanup
329
+
330
+ - Clean up only what this run started: the emulator child PID, the container ID from the
331
+ CID file, and the named database; these are short-lived, unlike the development workspace
332
+ and its private caches. Signal the PID with `TERM`, wait up to 10 seconds, then `KILL`.
333
+ Then `wait` for it and confirm nothing is left. Count wait status 0 or 143 (ended by your
334
+ `TERM`) as a clean stop; count a needed `KILL` or any other status as a failure.
335
+ - The development runtime ends with the session, not after each check. Use its existing
336
+ owner's bounded shutdown, distinguishing supervised children/process groups from
337
+ persistent daemons. Shell `wait` and child exit codes apply only to children of that
338
+ shell; do not use them to attest termination of an adopted service or Gradle daemon.
339
+ The build client's exit does not mean its daemon exited. Record the daemon's own
340
+ identity and private Gradle home/version, not merely the client PID.
341
+ - For a supervised runtime, stop through its harness owner and verify the owned group
342
+ and descendants exited; a Metro wrapper exiting alone is insufficient. For Gradle or
343
+ another daemon, use the verified owner-specific stop with the recorded private home,
344
+ version and endpoint, then verify the original process identity is gone and owned
345
+ endpoints are released where applicable. Never use a shared/global daemon stop,
346
+ `adb kill-server` or a broad kill. If scope or exit cannot be verified, report the
347
+ retained resource and cleanup gap or arrange explicit handoff; do not signal a guessed
348
+ PID or report success. Preserve the bounded-stop and failure-reporting rules below.
349
+ - Never use broad `pkill`, `docker system prune` or a shared `adb kill-server` for cleanup.
350
+ Use the live child's process owner, not an ADB serial that may be reused. A numeric
351
+ PID can also be reused after exit; it is not durable ownership evidence.
352
+ - Give every startup, readiness and cleanup command a 30-second limit that kills the
353
+ command's whole process group. Treat exit 124 (timeout) as a terminal failure, not as
354
+ "not ready yet".
355
+ - Preserve the stage's original non-zero exit status even when cleanup succeeds. Print
356
+ `original_stage_exit=<n> cleanup_exit=<n>`.
357
+ - After SIGKILL or a host crash, verify recorded resources before recovery: process
358
+ start identity, command/run scope and boot identity where available, or container ID
359
+ and ownership labels. Never signal a numeric PID solely because an old record names
360
+ it. If ownership cannot be verified, leave it alone and report the gap. Keep logs.
361
+ - For the local setup flow, point the database URL only at its disposable loopback
362
+ container. An existing isolated remote test flow must use its own disposable data and
363
+ ownership checks. Never use development, production or another worker's database for
364
+ fixture writes or cleanup. A public render-only smoke needs no database.
365
+ - Record existing working changes before tools run. If Expo rewrites `android/tsconfig.json`
366
+ or deletes `android/expo-env.d.ts`, remove only unwanted changes attributable to that tool
367
+ execution. Preserve pre-existing and intentional task edits. If attribution is unclear,
368
+ retain the files and report the conflict; do not restore a whole file merely because
369
+ Expo touched it.
370
+
371
+ ## Evidence record
372
+
373
+ For setup proof only. Record:
374
+
375
+ - Source SHA and the workspace root/path/base/branch/owner from the lifecycle record; host OS
376
+ and architecture, the Expo SDK, and the node, pnpm, JDK, Python and emulator versions.
377
+ - System image API, image type and ABI. The AVD name, serial and ports are run
378
+ identifiers, not shared resources.
379
+ - Each stage's exit status and duration.
380
+ - The APK's SHA-256 (`shasum -a 256` or `sha256sum`) and its per-ABI `lib/` entries
381
+ (`unzip -l`), checked on the APK itself rather than inferred from Gradle flags.
382
+ - The journey's `PASS` markers and the cleanup results: database dropped, emulator exited,
383
+ container removed, no listeners left on the backend or Metro ports.
384
+ - Earlier failed or incomplete attempts. A later pass does not erase them.
385
+
386
+ State what the run does not prove: tablet, accessibility (TalkBack), physical devices,
387
+ signing, distribution, and any feature acceptance beyond the journey. Publish only
388
+ sanitized evidence: no authentication codes, session cookies, customer data or raw
389
+ payment payloads.
@@ -0,0 +1,156 @@
1
+ # Android workspace lifecycle
2
+
3
+ The coordinator or caller owns workspace selection. Resolve it once, before any setup stage,
4
+ and record the result. This reference owns workspace and runtime ownership: which resources
5
+ this run owns, which of them persist across attempts and which are per-run. Cache layout, SDK
6
+ isolation and the concrete stop commands stay in [setup.md](setup.md),
7
+ [Owned development session](setup.md#owned-development-session) and
8
+ [Owned-resource cleanup](setup.md#owned-resource-cleanup).
9
+
10
+ ## Precedence
11
+
12
+ 1. **Assigned workspace and candidate HEAD.** When the caller supplies an isolated workspace
13
+ and a candidate HEAD, use that workspace and that revision. Do not create a worktree or
14
+ branch, fetch, reset or switch revisions. Read `git rev-parse HEAD` and report it as the
15
+ source SHA. If it differs from the candidate HEAD, stop and report the mismatch; never
16
+ switch the workspace to match.
17
+ 2. **Existing owned workspace.** Feature work, fixes and diagnosis reuse the workspace this
18
+ run or unit already owns, with its private caches, venv and AVD profile. Do not make a
19
+ second workspace for a retry, a correction or a read-only investigation.
20
+ 3. **Standalone fresh setup.** Only when the coordinator reports no usable assignment. Create
21
+ one managed workspace at
22
+ `<repo>/.resolve-issues/rush/<run-id>/units/native`. Never create a sibling checkout such
23
+ as `../<repo>-android-setup`, and never add a second managed path for a retry.
24
+
25
+ Android and iOS setup in the same run share that one managed workspace; their private cache
26
+ subdirectories and short-lived processes stay separate.
27
+
28
+ An assigned path that is missing, is not a Git worktree, or is at another revision is not an
29
+ invitation to substitute a fresh checkout: stop and report it. For diagnosis, name the actual
30
+ checkout and HEAD and confirm it contains the failing code; the repository root or another
31
+ checkout may lag the candidate.
32
+
33
+ ## Record before creating
34
+
35
+ The bundled `scripts/workspace-runtime` is generated from the shared lifecycle
36
+ engine and ships with this skill. Only for standalone fresh setup, run:
37
+
38
+ ```bash
39
+ node <skill-base-dir>/scripts/workspace-runtime/bin/workspaces.mjs native-start --repo <canonical-root> \
40
+ --platform android --target <verified-target-branch> --base <candidate-SHA> --json
41
+ ```
42
+
43
+ The command records root, owner, exact base, branch, workspace and disposable cache
44
+ paths before creating anything. Use its returned `workspace` as `ASSIGNED_WORKSPACE`
45
+ and `sourceSha` as `CANDIDATE_HEAD` in setup. Keep `run` and `runId`; repeat with
46
+ `--run-id <returned-run-id>` and the same base, target and kind for retries. Never
47
+ invoke it inside a coordinator-assigned unit. It never substitutes `origin/main`
48
+ for the requested source or resets an existing workspace.
49
+ For a package below the root, pass `--native-dir <package-root-containing-android>`.
50
+ Declare other installs or build directories before use with repeated
51
+ `--disposable <exact-workspace-relative-path>`, including package-local `node_modules`.
52
+
53
+ ## Development workspace, owned session runtime and disposable runs
54
+
55
+ The workspace, its private caches under `.cache/`, its venv and its AVD profile are
56
+ development resources: retain them across retries and fixes, and keep them private to this
57
+ workspace. Never relocate them to a global cache or share them with a concurrent owner.
58
+
59
+ The owned **development session** has one lifecycle per owner. Start it once, record its PID
60
+ identity, serial, ports and log paths, and reuse it across every edit, fix and check attempt
61
+ in the session:
62
+
63
+ - the development emulator and the ADB endpoint it publishes, addressed by its owned serial;
64
+ - Metro, or the repo's development server, on its recorded port;
65
+ - one compatible Gradle daemon on the workspace's private `GRADLE_USER_HOME`, honoring the
66
+ repo's JVM and resource-capacity settings;
67
+ - the build outputs and installed app state under the workspace.
68
+
69
+ Within one session, do not start a second emulator, Metro, daemon or cache home because
70
+ the running one is inconvenient: keep the existing owner, do not create a second lifecycle,
71
+ and do not accumulate abandoned services. Long-lived processes stay under the harness's own
72
+ tracking so their exit is observable. Never `nohup`, `setsid` or `disown` a service into a
73
+ state this run cannot signal, and never leave one with no owner at all.
74
+
75
+ **Disposable acceptance and integration resources** follow their checkpoint's contract.
76
+ The `device-run.sh` emulator child, PostgreSQL container and named database exist for one
77
+ journey and are stopped by that run under [cleanup](setup.md#owned-resource-cleanup).
78
+ Do not start that stack for every edit. A fresh install does not automatically require a
79
+ new AVD or reboot: an existing owned emulator may be used when the gate permits it and
80
+ disposable app/test data can be isolated without destroying development state. Do not
81
+ inherit development authentication/database state as proof, or clear a borrowed device.
82
+
83
+ A session ends when the assignment ends, not when one check passes. Stop the services this
84
+ run started and confirm their exit under the existing cleanup rules, or hand off the ones
85
+ still running with their owner, PID identity, serial, ports, log paths and how to stop them.
86
+ A passing check, a reported result or a review handoff is not a session end.
87
+ The stop must match the resource: use the harness owner for supervised groups and a
88
+ verified private stop for daemons; do not shell-wait a nonchild or treat a wrapper's exit
89
+ as proof that its descendants stopped. Record uncertain cleanup as retained, not success.
90
+
91
+ Fast feedback comes from reuse, not from a fresh environment per attempt:
92
+
93
+ - Go incremental: one bounded edit/check cycle, reading the previous result before the next.
94
+ Build only when changed native or packaged inputs require it; refreshable JS needs no build.
95
+ - Do not recreate state for a clean start: no second emulator boot, Metro restart, `adb
96
+ kill-server`, fresh Gradle daemon, `clean`, dependency reinstall or `expo prebuild` of a
97
+ tracked native project for an ordinary fix.
98
+ - Prefer the cheapest check that proves the change (focused test, relevant typecheck, an app
99
+ that is already running) before scheduling the disposable device stack.
100
+ - Add no new pool, lease manager, snapshot-default AVD, provisioning script or second
101
+ launcher to make reuse work; the existing owner, launcher and cleanup rules are the
102
+ mechanism.
103
+
104
+ A read-only diagnosis does not require a clean environment. Reuse the owned workspace, its
105
+ caches and the session this run still owns; create only the services the observation needs,
106
+ and preserve the failed environment's evidence. Do not rebuild, reinstall or re-provision
107
+ merely because the failure is being investigated.
108
+
109
+ ## Parallel development sessions
110
+
111
+ Assign warm servers by independently changing source/configuration, not by agent count.
112
+ Keep each session warm between its own checks:
113
+
114
+ | Work arrangement | Runtime rule |
115
+ | --- | --- |
116
+ | Independent worktrees, branches or runtime configurations | Use separate Metro instances rooted in their actual workspaces, unique host ports and explicit device mappings. Keep writable caches, build outputs and test data private. |
117
+ | Several readers or intentionally integrated checks on the same source/configuration | Reuse one server under a designated owner. Coordinate edits and check snapshots; record that results cover the combined working state, not isolated candidates. |
118
+ | Limited device/host capacity | Run ready host checks concurrently and schedule conflicting device checks through the existing owner. Do not start excess emulators or create a new pool/lease system. |
119
+
120
+ For example, one emulator may map its device port 8081 to session A's private host port,
121
+ while a different emulator maps its device port 8081 to session B's private host port.
122
+ The host ports must differ; the device-local ports need not. Use the caller-selected ADB
123
+ endpoint and exact owned serial. Verify the app's actual bundle source, not only `/status`.
124
+
125
+ Do not point one Metro at alternating candidate trees or mutate another session's reverse
126
+ mapping, installed app or database. Keep device state exclusive during mutating checks.
127
+ If one device must serve different candidates sequentially, end the previous check and
128
+ let its owner explicitly reassign/reconfigure it and verify the new app/source mapping;
129
+ do not silently switch it while a test is running. Sharing a server does not make concurrent
130
+ writes to the same source tree independent or protect tests from mid-run source changes.
131
+
132
+ Do not assume a shared backend is safe for fixtures: share only when its isolation and
133
+ ownership contract explicitly permit it; otherwise keep candidate test data separate.
134
+ Stop shared services only through their owner after all users release them, or explicitly
135
+ hand them off. Do not kill a shared server because one agent finished its task.
136
+
137
+ ## Completion
138
+
139
+ At the end of the assignment, return the workspace, its cache paths and any retained process
140
+ records to the coordinator for final cleanup. The coordinator owns deletion and retention.
141
+ Register the path with the run's cleanup owner so final cleanup can tell a delivered
142
+ standalone run from unfinished or unpublished work.
143
+
144
+ - A successful, delivered standalone run must not retain an unbounded cache: mark the
145
+ workspace and its disposable caches for final cleanup. After stopping its owned
146
+ services, run `node <skill-base-dir>/scripts/workspace-runtime/bin/workspaces.mjs native-finish --run <run> --json`
147
+ from the owner checkout. This uses the same cleanup engine as issue workflows.
148
+ - Unfinished or unpublished standalone work keeps the workspace and caches for the next
149
+ attempt; report what is retained and why.
150
+
151
+ The parent lifecycle record is authoritative for ownership, retention and final cleanup.
152
+ Before `native-finish`, record the session's end: either the services this run started were
153
+ stopped and their exit confirmed, or the ones still running were handed off explicitly as
154
+ described above.
155
+ An explicit handoff does not authorize removing a workspace or cache still used by the
156
+ receiving owner. Retain it until ownership and delivery cleanup checks permit removal.