@frankzhang2026/opencode-android-orchestrator 0.7.0 → 0.8.1
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.
- package/CHANGELOG.md +32 -1
- package/README.md +58 -22
- package/THIRD_PARTY_NOTICES.md +15 -11
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/installer/adaptive-templates.d.ts +2 -5
- package/dist/installer/adaptive-templates.d.ts.map +1 -1
- package/dist/installer/adaptive-templates.js.map +1 -1
- package/dist/installer/agents-config.d.ts +5 -0
- package/dist/installer/agents-config.d.ts.map +1 -1
- package/dist/installer/agents-config.js +44 -8
- package/dist/installer/agents-config.js.map +1 -1
- package/dist/installer/index.d.ts +2 -2
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +2 -2
- package/dist/installer/index.js.map +1 -1
- package/dist/installer/opencode-config.d.ts +3 -4
- package/dist/installer/opencode-config.d.ts.map +1 -1
- package/dist/installer/opencode-config.js +1 -3
- package/dist/installer/opencode-config.js.map +1 -1
- package/dist/installer/upgrade.d.ts.map +1 -1
- package/dist/installer/upgrade.js +117 -46
- package/dist/installer/upgrade.js.map +1 -1
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +32 -0
- package/dist/plugin/index.js.map +1 -1
- package/docs/MIGRATION.md +45 -26
- package/docs/SECURITY.md +32 -14
- package/docs/TROUBLESHOOTING.md +31 -9
- package/package.json +3 -1
- package/resources/third-party/superpowers-v6.2.0/LICENSE +21 -0
- package/resources/third-party/superpowers-v6.2.0/PROVENANCE.md +21 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-brainstorming/SKILL.md +43 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/SKILL.md +288 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/references/condition-based-waiting-example.ts +158 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/references/condition-based-waiting.md +115 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/references/defense-in-depth.md +122 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/references/root-cause-tracing.md +169 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-systematic-debugging/scripts/find-polluter.sh +72 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-test-driven-development/SKILL.md +327 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-test-driven-development/references/writing-good-tests.md +197 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-verification-before-completion/SKILL.md +125 -0
- package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-writing-plans/SKILL.md +50 -0
- package/templates/.opencode/agents/scheduled-coder.md +3 -4
- package/templates/.opencode/agents/scheduled-planner.md +5 -5
- package/templates/.opencode/agents/scheduled-reviewer.md +1 -2
- package/templates/.opencode/skills/scheduled-quality-coder/SKILL.md +7 -6
- package/templates/.opencode/skills/scheduled-quality-orchestrator/SKILL.md +2 -1
- package/templates/.opencode/skills/scheduled-quality-reviewer/SKILL.md +1 -1
- package/templates/README.md +6 -2
- package/templates/automation/config.json +6 -9
- package/templates/automation/config.schema.json +2 -11
- package/templates/automation/task-contract.schema.json +7 -7
- package/templates/automation/tasks/TASK-TEMPLATE.json.example +5 -5
- package/templates/scripts/automation/lib.sh +1 -3
- package/templates/scripts/automation/preflight.sh +0 -3
- package/templates/scripts/automation/tests/run-tests.sh +11 -14
- package/templates/scripts/automation/validate-contract.sh +7 -2
package/docs/TROUBLESHOOTING.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Troubleshooting
|
|
2
2
|
|
|
3
3
|
Use this guide for
|
|
4
|
-
`@frankzhang2026/opencode-android-orchestrator@0.
|
|
4
|
+
`@frankzhang2026/opencode-android-orchestrator@0.8.1`.
|
|
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.
|
|
14
|
+
npx @frankzhang2026/opencode-android-orchestrator@0.8.1 doctor . --json
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
If installation never completed, doctor will correctly report a missing or
|
|
@@ -31,6 +31,24 @@ The CLI uses these exit codes:
|
|
|
31
31
|
`init`, `upgrade`, and `uninstall` structures successful results; thrown errors
|
|
32
32
|
remain human-readable on stderr with a stable code such as `[FILE_CONFLICT]`.
|
|
33
33
|
|
|
34
|
+
## Company npm Registry override
|
|
35
|
+
|
|
36
|
+
If `npm config get registry` reports an internal Registry and a request fails
|
|
37
|
+
against that internal hostname, verify and run the public package with a
|
|
38
|
+
command-scoped override:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm --registry=https://registry.npmjs.org/ view \
|
|
42
|
+
@frankzhang2026/opencode-android-orchestrator@0.8.1 version
|
|
43
|
+
npx --yes --registry=https://registry.npmjs.org/ \
|
|
44
|
+
@frankzhang2026/opencode-android-orchestrator@0.8.1 upgrade . --json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This leaves the company's saved npm configuration unchanged. Use the option
|
|
48
|
+
placement shown above; it is also suitable when GitHub is unavailable because
|
|
49
|
+
the package contains its required workflow skills and does not fetch the old
|
|
50
|
+
Git-backed Superpowers plugin at runtime.
|
|
51
|
+
|
|
34
52
|
## Prerequisite and discovery failures
|
|
35
53
|
|
|
36
54
|
| Symptom | Likely cause | Safe response |
|
|
@@ -50,6 +68,8 @@ remain human-readable on stderr with a stable code such as `[FILE_CONFLICT]`.
|
|
|
50
68
|
| 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
69
|
| 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
70
|
| 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. |
|
|
71
|
+
| `Bundled Orchestrator skill is unavailable` | The installed `0.8.1` 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. |
|
|
72
|
+
| 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
73
|
|
|
54
74
|
Version `0.6.0` always passes `--no-configuration-cache` to its temporary
|
|
55
75
|
Gradle task-discovery invocation. This overrides a repository-level
|
|
@@ -62,7 +82,7 @@ least `1800000` milliseconds. A higher timeout already supplied by the caller
|
|
|
62
82
|
is preserved; unrelated Bash commands are unchanged. To configure one hour,
|
|
63
83
|
run `upgrade . --long-command-timeout-ms 3600000` on a healthy installation.
|
|
64
84
|
If a command still reports `120000 ms`, confirm that the project manifest and
|
|
65
|
-
OpenCode plugin reference are both `0.
|
|
85
|
+
OpenCode plugin reference are both `0.8.1`, restart the OpenCode session so the
|
|
66
86
|
plugin reloads, and rerun doctor before attempting recovery.
|
|
67
87
|
|
|
68
88
|
After installation, inspect OpenCode discovery separately:
|
|
@@ -75,8 +95,9 @@ opencode debug agent scheduled-coder
|
|
|
75
95
|
opencode debug agent scheduled-reviewer
|
|
76
96
|
```
|
|
77
97
|
|
|
78
|
-
Then run `./scripts/automation/preflight.sh --source`. It validates
|
|
79
|
-
|
|
98
|
+
Then run `./scripts/automation/preflight.sh --source`. It validates resolved
|
|
99
|
+
configuration, required bundled and project skills, agent permissions, and
|
|
100
|
+
both read-only custom tools.
|
|
80
101
|
If it fails, preserve its exact output. Do not broaden an agent's default-deny
|
|
81
102
|
permissions to make discovery pass.
|
|
82
103
|
|
|
@@ -116,7 +137,7 @@ Common fail-closed codes include:
|
|
|
116
137
|
| `PLUGIN_VERSION_CONFLICT` | The same managed package identity has another reference/version. | Review and remove or migrate only the obsolete entry; never let init silently replace it. |
|
|
117
138
|
| `DUPLICATE_PLUGIN` or `DUPLICATE_PROPERTY` | Configuration identity is ambiguous. | Correct the JSON/JSONC structure without discarding unrelated fields or comments. |
|
|
118
139
|
| `INVALID_JSONC` or `ROOT_NOT_OBJECT` | OpenCode configuration cannot be merged safely. | Repair the user-owned file and validate it before retrying. |
|
|
119
|
-
| `AGENTS_BLOCK_CONFLICT` or `AGENTS_MARKERS_INVALID` |
|
|
140
|
+
| `AGENTS_BLOCK_CONFLICT` or `AGENTS_MARKERS_INVALID` | During `init`, the bounded block was modified; or a lifecycle command found partial, out-of-order, or duplicate markers. | Keep project-specific instructions outside one valid marker pair. `0.8.1 upgrade` preserves marker-external changes and replaces the old managed block; malformed marker structure still requires manual repair. |
|
|
120
141
|
| `FILE_SYMLINK`, `TARGET_SYMLINK`, or `CONFIG_SYMLINK` | A managed target or ancestor is a symbolic link. | Replace it only after understanding ownership and destination. The installer intentionally does not follow it. |
|
|
121
142
|
| `PLAN_STALE` or `TARGET_MODIFIED` | A file changed between planning and application. | Stop concurrent edits, inspect the diff, and rerun from a stable state. |
|
|
122
143
|
|
|
@@ -135,8 +156,8 @@ configuration.
|
|
|
135
156
|
| --- | --- | --- |
|
|
136
157
|
| `MANIFEST_MISSING`, `MANIFEST_INVALID`, or `MANIFEST_STATE` | No trustworthy installed manifest is available. | Do not invent a manifest or copy one from another project. Determine whether this is an uninstalled/manual setup or an interrupted transaction. |
|
|
137
158
|
| `EXISTING_INSTALLATION_DIFFERENT` | `init` found another installed inventory/version. | Use `upgrade` for a healthy older manifest. |
|
|
138
|
-
| `EXISTING_INSTALLATION_INVALID` or `INSTALLATION_INVALID` | Manifest, installed files, or required backups failed validation. | Preserve the project and `.automation-plugin/`; inspect doctor details
|
|
139
|
-
| `INSTALLED_FILES_MODIFIED` | Upgrade found content
|
|
159
|
+
| `EXISTING_INSTALLATION_INVALID` or `INSTALLATION_INVALID` | Manifest, installed files, or required backups failed structural or content validation. In `0.8.0`, this also reported an active manifest whose mode was not exactly `0600`. | Preserve the project and `.automation-plugin/`; use `0.8.1 upgrade` for mode-only drift, and inspect other doctor details or recovery history. |
|
|
160
|
+
| `INSTALLED_FILES_MODIFIED` | Upgrade found content/existence drift in an ordinary managed file or missing/modified backup content. | Move intentional customization out of ordinary managed paths or choose manual recovery. `0.8.1` separately merges user-owned `AGENTS.md` content and does not reject mode-only drift. |
|
|
140
161
|
| `VERSION_DOWNGRADE_REFUSED` | Target package is older than the installed manifest. | Use a newer fixed package version; never edit the manifest version. |
|
|
141
162
|
| `UPGRADE_IN_PROGRESS` or `UNINSTALL_IN_PROGRESS` | `.automation-plugin/upgrade.json` or `uninstall.json` records an unfinished transaction. | Inspect the marker and matching recovery directory. Do not delete the marker merely to retry. |
|
|
142
163
|
| `POST_UPGRADE_VERIFICATION_FAILED` | New resources failed verification. | The implementation attempts a complete old-version rollback; verify the old manifest and inspect upgrade evidence. |
|
|
@@ -146,7 +167,8 @@ configuration.
|
|
|
146
167
|
|
|
147
168
|
Installer control paths are:
|
|
148
169
|
|
|
149
|
-
- active manifest: `.automation-plugin/manifest.json` (
|
|
170
|
+
- active manifest: `.automation-plugin/manifest.json` (new manifests are
|
|
171
|
+
written as `0600`; mode-only drift does not block `0.8.1 upgrade`);
|
|
150
172
|
- first-install/original backups: `.automation-plugin/backups/<id>/`;
|
|
151
173
|
- upgrade marker and snapshots: `.automation-plugin/upgrade.json` and
|
|
152
174
|
`.automation-plugin/upgrades/<id>/`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frankzhang2026/opencode-android-orchestrator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
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.
|
package/resources/third-party/superpowers-v6.2.0/skills/android-orchestrator-brainstorming/SKILL.md
ADDED
|
@@ -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
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Complete implementation of condition-based waiting utilities
|
|
2
|
+
// From: Lace test infrastructure improvements (2025-10-03)
|
|
3
|
+
// Context: Fixed 15 flaky tests by replacing arbitrary timeouts
|
|
4
|
+
|
|
5
|
+
import type { ThreadManager } from '~/threads/thread-manager';
|
|
6
|
+
import type { LaceEvent, LaceEventType } from '~/threads/types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wait for a specific event type to appear in thread
|
|
10
|
+
*
|
|
11
|
+
* @param threadManager - The thread manager to query
|
|
12
|
+
* @param threadId - Thread to check for events
|
|
13
|
+
* @param eventType - Type of event to wait for
|
|
14
|
+
* @param timeoutMs - Maximum time to wait (default 5000ms)
|
|
15
|
+
* @returns Promise resolving to the first matching event
|
|
16
|
+
*
|
|
17
|
+
* Example:
|
|
18
|
+
* await waitForEvent(threadManager, agentThreadId, 'TOOL_RESULT');
|
|
19
|
+
*/
|
|
20
|
+
export function waitForEvent(
|
|
21
|
+
threadManager: ThreadManager,
|
|
22
|
+
threadId: string,
|
|
23
|
+
eventType: LaceEventType,
|
|
24
|
+
timeoutMs = 5000
|
|
25
|
+
): Promise<LaceEvent> {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const startTime = Date.now();
|
|
28
|
+
|
|
29
|
+
const check = () => {
|
|
30
|
+
const events = threadManager.getEvents(threadId);
|
|
31
|
+
const event = events.find((e) => e.type === eventType);
|
|
32
|
+
|
|
33
|
+
if (event) {
|
|
34
|
+
resolve(event);
|
|
35
|
+
} else if (Date.now() - startTime > timeoutMs) {
|
|
36
|
+
reject(new Error(`Timeout waiting for ${eventType} event after ${timeoutMs}ms`));
|
|
37
|
+
} else {
|
|
38
|
+
setTimeout(check, 10); // Poll every 10ms for efficiency
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
check();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Wait for a specific number of events of a given type
|
|
48
|
+
*
|
|
49
|
+
* @param threadManager - The thread manager to query
|
|
50
|
+
* @param threadId - Thread to check for events
|
|
51
|
+
* @param eventType - Type of event to wait for
|
|
52
|
+
* @param count - Number of events to wait for
|
|
53
|
+
* @param timeoutMs - Maximum time to wait (default 5000ms)
|
|
54
|
+
* @returns Promise resolving to all matching events once count is reached
|
|
55
|
+
*
|
|
56
|
+
* Example:
|
|
57
|
+
* // Wait for 2 AGENT_MESSAGE events (initial response + continuation)
|
|
58
|
+
* await waitForEventCount(threadManager, agentThreadId, 'AGENT_MESSAGE', 2);
|
|
59
|
+
*/
|
|
60
|
+
export function waitForEventCount(
|
|
61
|
+
threadManager: ThreadManager,
|
|
62
|
+
threadId: string,
|
|
63
|
+
eventType: LaceEventType,
|
|
64
|
+
count: number,
|
|
65
|
+
timeoutMs = 5000
|
|
66
|
+
): Promise<LaceEvent[]> {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
const startTime = Date.now();
|
|
69
|
+
|
|
70
|
+
const check = () => {
|
|
71
|
+
const events = threadManager.getEvents(threadId);
|
|
72
|
+
const matchingEvents = events.filter((e) => e.type === eventType);
|
|
73
|
+
|
|
74
|
+
if (matchingEvents.length >= count) {
|
|
75
|
+
resolve(matchingEvents);
|
|
76
|
+
} else if (Date.now() - startTime > timeoutMs) {
|
|
77
|
+
reject(
|
|
78
|
+
new Error(
|
|
79
|
+
`Timeout waiting for ${count} ${eventType} events after ${timeoutMs}ms (got ${matchingEvents.length})`
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
setTimeout(check, 10);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
check();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Wait for an event matching a custom predicate
|
|
93
|
+
* Useful when you need to check event data, not just type
|
|
94
|
+
*
|
|
95
|
+
* @param threadManager - The thread manager to query
|
|
96
|
+
* @param threadId - Thread to check for events
|
|
97
|
+
* @param predicate - Function that returns true when event matches
|
|
98
|
+
* @param description - Human-readable description for error messages
|
|
99
|
+
* @param timeoutMs - Maximum time to wait (default 5000ms)
|
|
100
|
+
* @returns Promise resolving to the first matching event
|
|
101
|
+
*
|
|
102
|
+
* Example:
|
|
103
|
+
* // Wait for TOOL_RESULT with specific ID
|
|
104
|
+
* await waitForEventMatch(
|
|
105
|
+
* threadManager,
|
|
106
|
+
* agentThreadId,
|
|
107
|
+
* (e) => e.type === 'TOOL_RESULT' && e.data.id === 'call_123',
|
|
108
|
+
* 'TOOL_RESULT with id=call_123'
|
|
109
|
+
* );
|
|
110
|
+
*/
|
|
111
|
+
export function waitForEventMatch(
|
|
112
|
+
threadManager: ThreadManager,
|
|
113
|
+
threadId: string,
|
|
114
|
+
predicate: (event: LaceEvent) => boolean,
|
|
115
|
+
description: string,
|
|
116
|
+
timeoutMs = 5000
|
|
117
|
+
): Promise<LaceEvent> {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
const startTime = Date.now();
|
|
120
|
+
|
|
121
|
+
const check = () => {
|
|
122
|
+
const events = threadManager.getEvents(threadId);
|
|
123
|
+
const event = events.find(predicate);
|
|
124
|
+
|
|
125
|
+
if (event) {
|
|
126
|
+
resolve(event);
|
|
127
|
+
} else if (Date.now() - startTime > timeoutMs) {
|
|
128
|
+
reject(new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`));
|
|
129
|
+
} else {
|
|
130
|
+
setTimeout(check, 10);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
check();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Usage example from actual debugging session:
|
|
139
|
+
//
|
|
140
|
+
// BEFORE (flaky):
|
|
141
|
+
// ---------------
|
|
142
|
+
// const messagePromise = agent.sendMessage('Execute tools');
|
|
143
|
+
// await new Promise(r => setTimeout(r, 300)); // Hope tools start in 300ms
|
|
144
|
+
// agent.abort();
|
|
145
|
+
// await messagePromise;
|
|
146
|
+
// await new Promise(r => setTimeout(r, 50)); // Hope results arrive in 50ms
|
|
147
|
+
// expect(toolResults.length).toBe(2); // Fails randomly
|
|
148
|
+
//
|
|
149
|
+
// AFTER (reliable):
|
|
150
|
+
// ----------------
|
|
151
|
+
// const messagePromise = agent.sendMessage('Execute tools');
|
|
152
|
+
// await waitForEventCount(threadManager, threadId, 'TOOL_CALL', 2); // Wait for tools to start
|
|
153
|
+
// agent.abort();
|
|
154
|
+
// await messagePromise;
|
|
155
|
+
// await waitForEventCount(threadManager, threadId, 'TOOL_RESULT', 2); // Wait for results
|
|
156
|
+
// expect(toolResults.length).toBe(2); // Always succeeds
|
|
157
|
+
//
|
|
158
|
+
// Result: 60% pass rate → 100%, 40% faster execution
|