@frankzhang2026/opencode-android-orchestrator 0.7.0 → 0.8.0

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 (54) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +47 -16
  3. package/THIRD_PARTY_NOTICES.md +15 -11
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/installer/adaptive-templates.d.ts +2 -5
  9. package/dist/installer/adaptive-templates.d.ts.map +1 -1
  10. package/dist/installer/adaptive-templates.js.map +1 -1
  11. package/dist/installer/index.d.ts +1 -1
  12. package/dist/installer/index.d.ts.map +1 -1
  13. package/dist/installer/index.js +1 -1
  14. package/dist/installer/index.js.map +1 -1
  15. package/dist/installer/opencode-config.d.ts +3 -4
  16. package/dist/installer/opencode-config.d.ts.map +1 -1
  17. package/dist/installer/opencode-config.js +1 -3
  18. package/dist/installer/opencode-config.js.map +1 -1
  19. package/dist/plugin/index.d.ts +2 -0
  20. package/dist/plugin/index.d.ts.map +1 -1
  21. package/dist/plugin/index.js +32 -0
  22. package/dist/plugin/index.js.map +1 -1
  23. package/docs/MIGRATION.md +21 -10
  24. package/docs/SECURITY.md +16 -7
  25. package/docs/TROUBLESHOOTING.md +8 -5
  26. package/package.json +3 -1
  27. package/resources/third-party/superpowers-v6.2.0/LICENSE +21 -0
  28. package/resources/third-party/superpowers-v6.2.0/PROVENANCE.md +21 -0
  29. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-brainstorming/SKILL.md +43 -0
  30. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/SKILL.md +288 -0
  31. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/references/condition-based-waiting-example.ts +158 -0
  32. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/references/condition-based-waiting.md +115 -0
  33. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/references/defense-in-depth.md +122 -0
  34. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/references/root-cause-tracing.md +169 -0
  35. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/scripts/find-polluter.sh +72 -0
  36. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-test-driven-development/SKILL.md +327 -0
  37. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-test-driven-development/references/writing-good-tests.md +197 -0
  38. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-verification-before-completion/SKILL.md +125 -0
  39. package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-writing-plans/SKILL.md +50 -0
  40. package/templates/.opencode/agents/scheduled-coder.md +3 -4
  41. package/templates/.opencode/agents/scheduled-planner.md +5 -5
  42. package/templates/.opencode/agents/scheduled-reviewer.md +1 -2
  43. package/templates/.opencode/skills/scheduled-quality-coder/SKILL.md +7 -6
  44. package/templates/.opencode/skills/scheduled-quality-orchestrator/SKILL.md +2 -1
  45. package/templates/.opencode/skills/scheduled-quality-reviewer/SKILL.md +1 -1
  46. package/templates/README.md +6 -2
  47. package/templates/automation/config.json +6 -9
  48. package/templates/automation/config.schema.json +2 -11
  49. package/templates/automation/task-contract.schema.json +7 -7
  50. package/templates/automation/tasks/TASK-TEMPLATE.json.example +5 -5
  51. package/templates/scripts/automation/lib.sh +1 -3
  52. package/templates/scripts/automation/preflight.sh +0 -3
  53. package/templates/scripts/automation/tests/run-tests.sh +11 -14
  54. package/templates/scripts/automation/validate-contract.sh +7 -2
package/docs/MIGRATION.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Migration guide
2
2
 
3
3
  This guide covers migration to
4
- `@frankzhang2026/opencode-android-orchestrator@0.7.0`. Pin the exact version and
4
+ `@frankzhang2026/opencode-android-orchestrator@0.8.0`. Pin the exact version and
5
5
  prove the migration in a disposable clone before changing a long-lived
6
6
  repository.
7
7
 
@@ -9,9 +9,9 @@ repository.
9
9
 
10
10
  | Current state | Correct command after release | Important distinction |
11
11
  | --- | --- | --- |
12
- | No orchestrator files or manifest | `npx @frankzhang2026/opencode-android-orchestrator@0.7.0 init .` | Normal new installation; all detected Android modules and registered debug verification tasks are discovered automatically. |
12
+ | No orchestrator files or manifest | `npx @frankzhang2026/opencode-android-orchestrator@0.8.0 init .` | Normal new installation; all detected Android modules and registered debug verification tasks are discovered automatically. |
13
13
  | Published `0.1.0` scaffold only | Remove any project-local `@0.1.0` plugin reference after review, then run `init`. | `0.1.0` did not create a usable managed installation and cannot be upgraded. |
14
- | Healthy `0.2.0` through `0.6.1` manifest-managed installation | Run the fixed `0.7.0` doctor, then `upgrade`. | Existing module scope, verification tasks, and policy values are preserved. Pre-`0.6.1` configurations receive the 30-minute long-command timeout default. |
14
+ | Healthy `0.2.0` through `0.7.0` manifest-managed installation | Run the fixed `0.8.0` doctor, then `upgrade`. | Existing module scope, verification tasks, and policy values are preserved. The old managed Superpowers plugin reference is replaced by bundled skills. Pre-`0.6.1` configurations receive the 30-minute long-command timeout default. |
15
15
  | Manually copied V3 files, no `.automation-plugin/manifest.json` | Finish active tasks, preserve historical evidence separately, then run `init`. | Exact files can be reused; differing managed files fail as conflicts. |
16
16
  | Healthy older manifest-managed installation | Run `doctor`, then the fixed target version's `upgrade`. | `upgrade` requires a valid installed manifest and intact original backups. |
17
17
  | Healthy current-version manifest | Run `doctor`; repeated `init` or same-version `upgrade` is verification-only and byte-idempotent. | Do not reinstall or delete the manifest. |
@@ -36,7 +36,7 @@ removes unchanged plugin-created files, and retains drift for manual review.
36
36
  5. If a managed manifest already exists, run:
37
37
 
38
38
  ```sh
39
- npx @frankzhang2026/opencode-android-orchestrator@0.7.0 doctor . --json
39
+ npx @frankzhang2026/opencode-android-orchestrator@0.8.0 doctor . --json
40
40
  ```
41
41
 
42
42
  Do not proceed with `upgrade` unless the installation checks pass.
@@ -52,14 +52,14 @@ scaffold, not as an older managed installation.
52
52
  If the project OpenCode configuration contains an exact
53
53
  `@frankzhang2026/opencode-android-orchestrator@0.1.0` entry, save the file and
54
54
  remove only that obsolete entry in a reviewed Git change before running
55
- `0.7.0 init`. The merger deliberately rejects a different version of the same
55
+ `0.8.0 init`. The merger deliberately rejects a different version of the same
56
56
  managed package; it will not silently replace the reference. A global npm
57
57
  installation of `0.1.0` alone does not require project-file cleanup.
58
58
 
59
59
  After release, initialize with the fixed version:
60
60
 
61
61
  ```sh
62
- npx @frankzhang2026/opencode-android-orchestrator@0.7.0 init .
62
+ npx @frankzhang2026/opencode-android-orchestrator@0.8.0 init .
63
63
  ```
64
64
 
65
65
  New installations default to all-module scope, so multiple application modules
@@ -105,8 +105,8 @@ installer to guess which customization should survive.
105
105
  Use the lifecycle command selected by the active manifest:
106
106
 
107
107
  ```sh
108
- npx @frankzhang2026/opencode-android-orchestrator@0.7.0 doctor . --json
109
- npx @frankzhang2026/opencode-android-orchestrator@0.7.0 upgrade . --json
108
+ npx @frankzhang2026/opencode-android-orchestrator@0.8.0 doctor . --json
109
+ npx @frankzhang2026/opencode-android-orchestrator@0.8.0 upgrade . --json
110
110
  ```
111
111
 
112
112
  `upgrade` verifies the installed manifest, every managed file, and every
@@ -133,6 +133,15 @@ configurations receive `unitTestsEnabled: true` and `lintEnabled: false`.
133
133
  After migration, change only those two values in place and commit the
134
134
  configuration; there are no `init` or `upgrade` flags for these policies.
135
135
 
136
+ Upgrading a healthy `0.7.0` installation removes the exact managed Superpowers
137
+ v6.2.0 plugin reference that the older Orchestrator added. Upgrade rebuilds the
138
+ OpenCode merge from the verified original pre-install file, so ownership stays
139
+ bounded: if that exact reference was already present before Orchestrator was
140
+ installed, it remains user-owned and is preserved. Other Superpowers versions,
141
+ plugin entries, options, comments, and configuration fields are not silently
142
+ removed. Version `0.8.0` instead registers its five package-local,
143
+ `android-orchestrator-*` workflow skills through the OpenCode `config` hook.
144
+
136
145
  The command refuses:
137
146
 
138
147
  - a downgrade or malformed semantic version;
@@ -150,8 +159,9 @@ the source of drift and use the recorded recovery data.
150
159
  Run all checks from the detected Git root:
151
160
 
152
161
  ```sh
153
- npx @frankzhang2026/opencode-android-orchestrator@0.7.0 doctor .
162
+ npx @frankzhang2026/opencode-android-orchestrator@0.8.0 doctor .
154
163
  opencode debug config
164
+ opencode debug skill
155
165
  opencode debug agent scheduled-planner
156
166
  opencode debug agent scheduled-coder
157
167
  opencode debug agent scheduled-reviewer
@@ -163,7 +173,8 @@ opencode debug agent scheduled-reviewer
163
173
  Verify all of the following before switching normal work to the plugin:
164
174
 
165
175
  - doctor has no failed check;
166
- - all three agents, five commands, and required skills are discoverable;
176
+ - all three agents, five commands, three scheduled-quality skills, and five
177
+ `android-orchestrator-*` workflow skills are discoverable;
167
178
  - both read-only custom tools resolve for the scheduled agents;
168
179
  - the Shell suite ends with `1..44`;
169
180
  - shadow output contains `"mutationPerformed": false`;
package/docs/SECURITY.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Security model
2
2
 
3
3
  This document describes the security properties of
4
- `@frankzhang2026/opencode-android-orchestrator@0.7.0`. The lifecycle foundation
4
+ `@frankzhang2026/opencode-android-orchestrator@0.8.0`. The lifecycle foundation
5
5
  completed the real OpenCode `1.14.22` and `1.15.13` release matrix in `0.2.0`;
6
- `0.7.0` retains that compatibility boundary.
6
+ `0.8.0` retains that compatibility boundary.
7
7
 
8
8
  ## Security goals and non-goals
9
9
 
@@ -53,7 +53,7 @@ modify local files; this package does not claim to protect against that actor.
53
53
 
54
54
  OpenCode permission prompts are also not semantic workflow approval. They can
55
55
  be accepted for the remainder of a session and may be auto-approved. For that
56
- reason `0.7.0` exposes only `android_orchestrator_status` and
56
+ reason `0.8.0` exposes only `android_orchestrator_status` and
57
57
  `android_orchestrator_doctor` as custom tools. State-changing wrappers remain a
58
58
  NO-GO until a one-use, non-model-forgeable receipt can bind the approval kind,
59
59
  task, session/message, sealed SHA or branch, time, and nonce.
@@ -91,6 +91,13 @@ value is an integer from `120000` through `7200000` milliseconds, defaults to
91
91
  `1800000`, never shortens a larger caller timeout, and does not rewrite the
92
92
  command or authorize a state change.
93
93
 
94
+ The five namespaced bundled workflow skills are loaded from a fixed directory
95
+ inside the installed npm package. The compatible `config` hook only appends
96
+ that directory to `skills.paths`, and plugin startup verifies that every
97
+ expected `SKILL.md` is a regular file. The package omits the upstream
98
+ `using-superpowers` bootstrap, localhost/browser companion, remote branding,
99
+ telemetry, and unrelated skills.
100
+
94
101
  ## Filesystem and configuration safety
95
102
 
96
103
  The installer never follows a symbolic link at a managed file or required
@@ -196,14 +203,16 @@ surface. Review them before running a workflow in an untrusted project.
196
203
 
197
204
  ## Dependencies and network behavior
198
205
 
199
- Use fixed package references. The installer adds the exact orchestrator
200
- version and the configured pinned Superpowers Git tag; it does not use
201
- `latest`. The package is compiled against `@opencode-ai/plugin@1.14.22` and
206
+ Use fixed package references. The installer adds only the exact Orchestrator
207
+ version; it does not use `latest` or install a GitHub-backed Superpowers
208
+ plugin. The five required Superpowers-derived skills and their supporting
209
+ files are part of the reviewed npm tarball with the upstream MIT license and
210
+ provenance. The package is compiled against `@opencode-ai/plugin@1.14.22` and
202
211
  declares the bounded peer range `>=1.14.22 <1.16.0`.
203
212
 
204
213
  The orchestrator does not contain a telemetry uploader and the deterministic
205
214
  Shell flow forbids Git push. Network activity can still occur outside that
206
- code when npm/npx downloads a package, OpenCode resolves a pinned plugin,
215
+ code when npm/npx downloads a package, OpenCode resolves another configured plugin,
207
216
  OpenCode contacts the configured model provider, or project build/test tooling
208
217
  uses the network. Apply the host organization's normal npm, Git, OpenCode,
209
218
  provider, proxy, certificate, and dependency-review policy.
@@ -1,7 +1,7 @@
1
1
  # Troubleshooting
2
2
 
3
3
  Use this guide for
4
- `@frankzhang2026/opencode-android-orchestrator@0.7.0`.
4
+ `@frankzhang2026/opencode-android-orchestrator@0.8.0`.
5
5
 
6
6
  ## Start with read-only evidence
7
7
 
@@ -11,7 +11,7 @@ From the repository root, capture:
11
11
  git status --short --branch
12
12
  git rev-parse HEAD
13
13
  opencode --version
14
- npx @frankzhang2026/opencode-android-orchestrator@0.7.0 doctor . --json
14
+ npx @frankzhang2026/opencode-android-orchestrator@0.8.0 doctor . --json
15
15
  ```
16
16
 
17
17
  If installation never completed, doctor will correctly report a missing or
@@ -50,6 +50,8 @@ remain human-readable on stderr with a stable code such as `[FILE_CONFLICT]`.
50
50
  | Invalid `--long-command-timeout-ms` | The value is not an integer from `120000` through `7200000`. | Use the `1800000` ms default or pass an intentional bounded value to `init`/`upgrade`; do not edit the generated config directly. |
51
51
  | Android SDK failure | No valid explicit SDK, `ANDROID_HOME`, `ANDROID_SDK_ROOT`, or `local.properties` `sdk.dir` was found. | Configure one real SDK root containing `platforms/` and `build-tools/`. Do not publish `local.properties`. |
52
52
  | Missing `git`, `jq`, `rg`, `shasum`, or Java | Required deterministic command is unavailable on `PATH`. | Install or restore the missing command, record its version, and rerun the read-only checks. |
53
+ | `Bundled Orchestrator skill is unavailable` | The installed `0.8.0` package is incomplete, damaged, or loaded from an unsupported partial copy. | Reinstall the exact package, inspect its `resources/third-party/superpowers-v6.2.0/skills/` entries, restart OpenCode, and rerun `opencode debug skill`. Do not add an external Superpowers plugin as a fallback. |
54
+ | The exact Superpowers v6.2.0 plugin remains after upgrade | That entry existed in the verified pre-install OpenCode file and is therefore user-owned. | Leave it in place or remove it as a separate reviewed configuration change. Upgrade only removes the old Orchestrator-managed entry. |
53
55
 
54
56
  Version `0.6.0` always passes `--no-configuration-cache` to its temporary
55
57
  Gradle task-discovery invocation. This overrides a repository-level
@@ -62,7 +64,7 @@ least `1800000` milliseconds. A higher timeout already supplied by the caller
62
64
  is preserved; unrelated Bash commands are unchanged. To configure one hour,
63
65
  run `upgrade . --long-command-timeout-ms 3600000` on a healthy installation.
64
66
  If a command still reports `120000 ms`, confirm that the project manifest and
65
- OpenCode plugin reference are both `0.7.0`, restart the OpenCode session so the
67
+ OpenCode plugin reference are both `0.8.0`, restart the OpenCode session so the
66
68
  plugin reloads, and rerun doctor before attempting recovery.
67
69
 
68
70
  After installation, inspect OpenCode discovery separately:
@@ -75,8 +77,9 @@ opencode debug agent scheduled-coder
75
77
  opencode debug agent scheduled-reviewer
76
78
  ```
77
79
 
78
- Then run `./scripts/automation/preflight.sh --source`. It validates pinned
79
- plugins, required skills, agent permissions, and both read-only custom tools.
80
+ Then run `./scripts/automation/preflight.sh --source`. It validates resolved
81
+ configuration, required bundled and project skills, agent permissions, and
82
+ both read-only custom tools.
80
83
  If it fails, preserve its exact output. Do not broaden an agent's default-deny
81
84
  permissions to make discovery pass.
82
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frankzhang2026/opencode-android-orchestrator",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Reusable OpenCode orchestration for Android projects",
5
5
  "license": "MIT",
6
6
  "author": "frankzhang2026",
@@ -31,6 +31,7 @@
31
31
  "files": [
32
32
  "dist/",
33
33
  "docs/",
34
+ "resources/",
34
35
  "templates/",
35
36
  "README.md",
36
37
  "CHANGELOG.md",
@@ -45,6 +46,7 @@
45
46
  "build": "tsc -p tsconfig.json",
46
47
  "typecheck": "tsc -p tsconfig.json --noEmit",
47
48
  "test": "npm run build && node --test tests/*.test.mjs",
49
+ "test:offline-discovery": "npm run build && node --test tests/offline-skill-discovery.integration.mjs",
48
50
  "pack:check": "npm pack --dry-run",
49
51
  "prepack": "npm run build"
50
52
  },
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jesse Vincent
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ # Bundled Superpowers-derived resources
2
+
3
+ - Upstream: https://github.com/obra/superpowers
4
+ - Upstream version: v6.2.0
5
+ - Upstream copyright: Copyright (c) 2025 Jesse Vincent
6
+ - License: MIT; see `LICENSE` in this directory.
7
+
8
+ This directory contains a curated, Orchestrator-specific derivative of five
9
+ upstream workflow skills. Names are prefixed with `android-orchestrator-` to
10
+ avoid collisions with independently installed skills.
11
+
12
+ Intentional changes:
13
+
14
+ - removed the `using-superpowers` bootstrap dependency;
15
+ - removed brainstorming's visual companion, localhost server, browser launch,
16
+ remote branding, and telemetry resources;
17
+ - replaced Superpowers plan execution handoffs with the sealed Android
18
+ Orchestrator contract/Coder/Reviewer workflow;
19
+ - moved optional supporting documents under `references/` and scripts under
20
+ `scripts/`;
21
+ - rewrote cross-skill references to the bundled namespaced skill IDs.
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: android-orchestrator-brainstorming
3
+ description: Refine one Android Orchestrator coding request into a bounded observable behavior proposal before plan and contract creation
4
+ license: MIT
5
+ compatibility: opencode
6
+ metadata:
7
+ upstream: obra/superpowers@v6.2.0
8
+ workflow: scheduled-coding
9
+ ---
10
+
11
+ # Android Orchestrator brainstorming
12
+
13
+ Turn a rough request into one small, testable behavior change. This is an
14
+ interactive planning aid; it never edits product code, creates planning files,
15
+ starts execution, or grants approval.
16
+
17
+ ## Workflow
18
+
19
+ 1. Inspect the relevant repository code, tests, and project instructions.
20
+ 2. Summarize current observable behavior and the requested behavior.
21
+ 3. Identify ambiguity in scope, acceptance behavior, edge cases, or test
22
+ strategy. Ask one focused question at a time only when the answer changes
23
+ the proposal.
24
+ 4. Consider two or three approaches when a meaningful tradeoff exists. Lead
25
+ with the recommended approach and explain the material tradeoff.
26
+ 5. Converge on exactly one bounded behavior change with:
27
+ - observable acceptance criteria;
28
+ - important edge cases;
29
+ - exact allowed implementation and test paths;
30
+ - maximum changed-file count;
31
+ - focused test filter and device-test policy;
32
+ - protected paths and explicit non-goals.
33
+ 6. Hand the proposal back to `scheduled-quality-orchestrator` for its formal
34
+ `方案确认` boundary.
35
+
36
+ ## Boundaries
37
+
38
+ - Never treat discussion or agreement in prose as approval.
39
+ - Never broaden a request merely to make the implementation cleaner.
40
+ - Never propose dependency, build-system, automation-rule, push, merge, or
41
+ worktree changes unless the user explicitly put them in scope.
42
+ - Use text-only interaction. This bundled skill contains no localhost server,
43
+ browser launcher, remote image, or telemetry path.
@@ -0,0 +1,288 @@
1
+ ---
2
+ name: android-orchestrator-systematic-debugging
3
+ description: Diagnose the root cause of an Android Orchestrator task failure before the single permitted repair loop
4
+ license: MIT
5
+ compatibility: opencode
6
+ metadata:
7
+ upstream: obra/superpowers@v6.2.0
8
+ workflow: scheduled-coding
9
+ ---
10
+
11
+ # Systematic Debugging
12
+
13
+ ## Overview
14
+
15
+ **Core principle:** ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
16
+
17
+ **Violating the letter of this process is violating the spirit of debugging.**
18
+
19
+ ## The Iron Law
20
+
21
+ ```
22
+ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
23
+ ```
24
+
25
+ If you haven't completed Phase 1, you cannot propose fixes.
26
+
27
+ ## When to Use
28
+
29
+ Use for ANY technical issue:
30
+ - Test failures
31
+ - Bugs in production
32
+ - Unexpected behavior
33
+ - Performance problems
34
+ - Build failures
35
+ - Integration issues
36
+
37
+ **Use this ESPECIALLY when:**
38
+ - Under time pressure (emergencies make guessing tempting)
39
+ - "Just one quick fix" seems obvious
40
+ - You've already tried multiple fixes
41
+ - Previous fix didn't work
42
+ - You don't fully understand the issue
43
+
44
+ **Don't skip when:**
45
+ - Issue seems simple (simple bugs have root causes too)
46
+ - You're in a hurry (rushing guarantees rework)
47
+ - Manager wants it fixed NOW (systematic is faster than thrashing)
48
+
49
+ ## The Four Phases
50
+
51
+ You MUST complete each phase before proceeding to the next.
52
+
53
+ ### Phase 1: Root Cause Investigation
54
+
55
+ **BEFORE attempting ANY fix:**
56
+
57
+ 1. **Read Error Messages Carefully**
58
+ - Don't skip past errors or warnings
59
+ - They often contain the exact solution
60
+ - Read stack traces completely
61
+ - Note line numbers, file paths, error codes
62
+
63
+ 2. **Reproduce Consistently**
64
+ - Can you trigger it reliably?
65
+ - What are the exact steps?
66
+ - Does it happen every time?
67
+ - If not reproducible → gather more data, don't guess
68
+
69
+ 3. **Check Recent Changes**
70
+ - What changed that could cause this?
71
+ - Git diff, recent commits
72
+ - New dependencies, config changes
73
+ - Environmental differences
74
+
75
+ 4. **Gather Evidence in Multi-Component Systems**
76
+
77
+ **WHEN system has multiple components (CI → build → signing, API → service → database):**
78
+
79
+ **BEFORE proposing fixes, add diagnostic instrumentation:**
80
+ ```
81
+ For EACH component boundary:
82
+ - Log what data enters component
83
+ - Log what data exits component
84
+ - Verify environment/config propagation
85
+ - Check state at each layer
86
+
87
+ Run once to gather evidence showing WHERE it breaks
88
+ THEN analyze evidence to identify failing component
89
+ THEN investigate that specific component
90
+ ```
91
+
92
+ **Example (multi-layer system):**
93
+ ```bash
94
+ # Layer 1: Workflow
95
+ echo "=== Secrets available in workflow: ==="
96
+ echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
97
+
98
+ # Layer 2: Build script
99
+ echo "=== Env vars in build script: ==="
100
+ env | grep IDENTITY || echo "IDENTITY not in environment"
101
+
102
+ # Layer 3: Signing script
103
+ echo "=== Keychain state: ==="
104
+ security list-keychains
105
+ security find-identity -v
106
+
107
+ # Layer 4: Actual signing
108
+ codesign --sign "$IDENTITY" --verbose=4 "$APP"
109
+ ```
110
+
111
+ **This reveals:** Which layer fails (secrets → workflow ✓, workflow → build ✗)
112
+
113
+ 5. **Trace Data Flow**
114
+
115
+ **WHEN error is deep in call stack:**
116
+
117
+ See `references/root-cause-tracing.md` for the complete backward tracing technique.
118
+
119
+ **Quick version:**
120
+ - Where does bad value originate?
121
+ - What called this with bad value?
122
+ - Keep tracing up until you find the source
123
+ - Fix at source, not at symptom
124
+
125
+ ### Phase 2: Pattern Analysis
126
+
127
+ **Find the pattern before fixing:**
128
+
129
+ 1. **Find Working Examples**
130
+ - Locate similar working code in same codebase
131
+ - What works that's similar to what's broken?
132
+
133
+ 2. **Compare Against References**
134
+ - If implementing pattern, read reference implementation COMPLETELY
135
+ - Don't skim - read every line
136
+ - Understand the pattern fully before applying
137
+
138
+ 3. **Identify Differences**
139
+ - What's different between working and broken?
140
+ - List every difference, however small
141
+ - Don't assume "that can't matter"
142
+
143
+ 4. **Understand Dependencies**
144
+ - What other components does this need?
145
+ - What settings, config, environment?
146
+ - What assumptions does it make?
147
+
148
+ ### Phase 3: Hypothesis and Testing
149
+
150
+ **Scientific method:**
151
+
152
+ 1. **Form Single Hypothesis**
153
+ - State clearly: "I think X is the root cause because Y"
154
+ - Write it down
155
+ - Be specific, not vague
156
+
157
+ 2. **Test Minimally**
158
+ - Make the SMALLEST possible change to test hypothesis
159
+ - One variable at a time
160
+ - Don't fix multiple things at once
161
+
162
+ 3. **Verify Before Continuing**
163
+ - Did it work? Yes → Phase 4
164
+ - Didn't work? Form NEW hypothesis
165
+ - DON'T add more fixes on top
166
+
167
+ 4. **When You Don't Know**
168
+ - Say "I don't understand X"
169
+ - Don't pretend to know
170
+ - Ask for help
171
+ - Research more
172
+
173
+ ### Phase 4: Implementation
174
+
175
+ **Fix the root cause, not the symptom:**
176
+
177
+ 1. **Create Failing Test Case**
178
+ - Simplest possible reproduction
179
+ - Automated test if possible
180
+ - One-off test script if no framework
181
+ - MUST have before fixing
182
+ - Use `android-orchestrator-test-driven-development` for proper failing tests
183
+
184
+ 2. **Implement Single Fix**
185
+ - Address the root cause identified
186
+ - ONE change at a time
187
+ - No "while I'm here" improvements
188
+ - No bundled refactoring
189
+
190
+ 3. **Verify Fix**
191
+ - Test passes now?
192
+ - No other tests broken?
193
+ - Issue actually resolved?
194
+ - Use `android-orchestrator-verification-before-completion` before claiming success
195
+
196
+ 4. **If Fix Doesn't Work**
197
+ - STOP
198
+ - Count: How many fixes have you tried?
199
+ - If < 3: Return to Phase 1, re-analyze with new information
200
+ - **If ≥ 3: STOP and question the architecture (step 5 below)**
201
+ - DON'T attempt Fix #4 without architectural discussion
202
+
203
+ 5. **If 3+ Fixes Failed: Question Architecture**
204
+
205
+ **Pattern indicating architectural problem:**
206
+ - Each fix reveals new shared state/coupling/problem in different place
207
+ - Fixes require "massive refactoring" to implement
208
+ - Each fix creates new symptoms elsewhere
209
+
210
+ **STOP and question fundamentals:**
211
+ - Is this pattern fundamentally sound?
212
+ - Are we "sticking with it through sheer inertia"?
213
+ - Should we refactor architecture vs. continue fixing symptoms?
214
+
215
+ **Discuss with your human partner before attempting more fixes**
216
+
217
+ This is NOT a failed hypothesis - this is a wrong architecture.
218
+
219
+ ## Red Flags - STOP and Follow Process
220
+
221
+ If you catch yourself thinking:
222
+ - "Quick fix for now, investigate later"
223
+ - "Just try changing X and see if it works"
224
+ - "Add multiple changes, run tests"
225
+ - "Skip the test, I'll manually verify"
226
+ - "It's probably X, let me fix that"
227
+ - "I don't fully understand but this might work"
228
+ - "Pattern says X but I'll adapt it differently"
229
+ - "Here are the main problems: [lists fixes without investigation]"
230
+ - Proposing solutions before tracing data flow
231
+ - **"One more fix attempt" (when already tried 2+)**
232
+ - **Each fix reveals new problem in different place**
233
+
234
+ **ALL of these mean: STOP. Return to Phase 1.**
235
+
236
+ **If 3+ fixes failed:** Question the architecture (see Phase 4.5)
237
+
238
+ ## your human partner's Signals You're Doing It Wrong
239
+
240
+ **Watch for these redirections:**
241
+ - "Is that not happening?" - You assumed without verifying
242
+ - "Will it show us...?" - You should have added evidence gathering
243
+ - "Stop guessing" - You're proposing fixes without understanding
244
+ - "Ultra-think this" - Question fundamentals, not just symptoms
245
+ - "We're stuck?" (frustrated) - Your approach isn't working
246
+
247
+ **When you see these:** STOP. Return to Phase 1.
248
+
249
+ ## Common Rationalizations
250
+
251
+ | Excuse | Reality |
252
+ |--------|---------|
253
+ | "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
254
+ | "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
255
+ | "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
256
+ | "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
257
+ | "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
258
+ | "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
259
+ | "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
260
+ | "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
261
+
262
+ ## Quick Reference
263
+
264
+ | Phase | Key Activities | Success Criteria |
265
+ |-------|---------------|------------------|
266
+ | **1. Root Cause** | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
267
+ | **2. Pattern** | Find working examples, compare | Identify differences |
268
+ | **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |
269
+ | **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |
270
+
271
+ ## When Process Reveals "No Root Cause"
272
+
273
+ If systematic investigation reveals issue is truly environmental, timing-dependent, or external:
274
+
275
+ 1. You've completed the process
276
+ 2. Document what you investigated
277
+ 3. Implement appropriate handling (retry, timeout, error message)
278
+ 4. Add monitoring/logging for future investigation
279
+
280
+ **But:** 95% of "no root cause" cases are incomplete investigation.
281
+
282
+ ## Supporting Techniques
283
+
284
+ These techniques are part of systematic debugging and available in this directory:
285
+
286
+ - **`references/root-cause-tracing.md`** - Trace bugs backward through call stack to find original trigger
287
+ - **`references/defense-in-depth.md`** - Add validation at multiple layers after finding root cause
288
+ - **`references/condition-based-waiting.md`** - Replace arbitrary timeouts with condition polling