Skip to content
This repository was archived by the owner on Oct 31, 2026. It is now read-only.

Commit 7665ead

Browse files
committed
P1-7 device smoke script + probes/docs; rotate vendor defaults to 0.5.16, refresh golden, lint tests/*.sh
1 parent 09384ce commit 7665ead

11 files changed

Lines changed: 323 additions & 19 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run: sudo apt-get update && sudo apt-get install -y bats zip unzip xz-utils binutils shellcheck
2121

2222
- name: Lint shell scripts (shellcheck)
23-
run: shellcheck -S warning -x install.sh scripts/*.sh tests/run.sh
23+
run: shellcheck -S warning -x install.sh scripts/*.sh tests/*.sh
2424

2525
- name: Lint workflows (actionlint)
2626
run: |

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test:
3636
bash tests/run.sh $(TEST)
3737

3838
lint:
39-
shellcheck -S warning -x install.sh scripts/*.sh tests/run.sh
39+
shellcheck -S warning -x install.sh scripts/*.sh tests/*.sh
4040
if command -v actionlint >/dev/null 2>&1; then actionlint; else echo "actionlint not installed, skipping workflow lint"; fi
4141

4242
check-vendor:

‎README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ bash tests/run.sh --update-golden # refresh vendor golden checksums
150150
CI runs them on every push and PR (`.github/workflows/tests.yml`).
151151
See [`tests/README.md`](tests/README.md) for details.
152152

153+
On-device acceptance (`tests/smoke-device.sh`) is separate: the maintainer
154+
runs it on a real Termux device before publishing a release — it probes the
155+
installed build (service lifecycle, PTY spawn, session CRUD, TUI frames,
156+
watcher subscribe + inotify, native-load signature scan) with no provider
157+
auth needed, and prints a report block to paste into the release notes:
158+
159+
```sh
160+
bash tests/smoke-device.sh # --cmd NAME to probe another command
161+
```
162+
153163
## Building from source
154164

155165
Fast, local stages work anywhere via `make` (`make help` lists targets):

‎docs/comparison-vs-opencode-termux.md‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,21 @@ of age.
111111
`vendor/` cache note). Their README ships five copy-paste build commands backed by
112112
`docs/make-maintainer.md`.
113113

114-
7. **No on-device acceptance record.** Your only runtime check is `opencode2 --version`
115-
at install time (`install.sh:111`). TUI reachability, watcher `subscribe`, and PTY
116-
spawn are claimed in the README but nothing in-repo proves them per release. Their
117-
model: `make selfcheck`, `tui_probe` gate written into `report.json`,
118-
`tools/upgrade-matrix.sh` against a real device, plus
119-
`docs/30-ci-local-build-matrix.md` and `handover/release-runbook.md`. Fix: a
120-
`tests/smoke-device.sh` the maintainer runs before publishing, with results pasted
121-
into the release body.
114+
7. **No on-device acceptance record — fixed.** The only runtime check was
115+
`opencode2 --version` at install time, with TUI reachability, watcher
116+
`subscribe`, and PTY spawn claimed but unproven per release.
117+
`tests/smoke-device.sh` is now the maintainer-run acceptance script
118+
(documented in README + `tests/README.md`): against the installed build it
119+
probes `--version`, a service stop/start/status round-trip (restores prior
120+
state), `server.info`, a full PTY lifecycle (`pty.create` → exit 0 →
121+
`pty.remove`), session create/delete, TUI frames under `script(1)`, and
122+
watcher evidence (`subscribe`+`started` for the scratch project, live
123+
`type=directory backend=inotify`) from the server log — all without
124+
provider auth, with every capture scanned for native-load failure
125+
signatures. It prints a report block for the release notes. Their model
126+
(`make selfcheck`, `tui_probe` gate, `tools/upgrade-matrix.sh`,
127+
`docs/30-ci-local-build-matrix.md`, `handover/release-runbook.md`) is the
128+
same shape: a human-run device gate with pasted results.
122129

123130
8. **Dead external reference — fixed.** `docs/REPORT.md` previously pointed at an
124131
unpublished failure-log file outside the repo (split out in `5e77b66` but never

‎scripts/build-libopentui-ci.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
set -euo pipefail
99

1010
REPO_ROOT="${REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
11-
OPENTUI_VERSION="${OPENTUI_VERSION:-0.5.14}"
11+
OPENTUI_VERSION="${OPENTUI_VERSION:-0.5.16}"
1212
ANDROID_API="${ANDROID_API:-29}"
1313
NDK_DIR="${NDK_DIR:-/opt/android-ndk}"
1414
WORK="${WORK:-$REPO_ROOT/work}"

‎scripts/build-vendors.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
# --force rebuild even when the vendor files exist (also: FORCE=1)
1515
# --commit git add/commit/push rebuilt vendor files (CI; default: off)
1616
# --vendors all (default), libopentui, pty, or comma combos (also: VENDORS=)
17-
# Env: REPO_ROOT, OUT, WORK, OPENTUI_VERSION (0.5.14), PTY_VERSION (0.2.0),
17+
# Env: REPO_ROOT, OUT, WORK, OPENTUI_VERSION (0.5.16), PTY_VERSION (0.2.0),
1818
# BUN_PTY_VERSION (0.4.9), NDK_DIR (/opt/android-ndk), ANDROID_API (29).
1919
set -euo pipefail
2020

2121
REPO_ROOT="${REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
2222
OUT="${OUT:-$REPO_ROOT/out}"
2323
WORK="${WORK:-$REPO_ROOT/work}"
24-
OPENTUI_VERSION="${OPENTUI_VERSION:-0.5.14}"
24+
OPENTUI_VERSION="${OPENTUI_VERSION:-0.5.16}"
2525
PTY_VERSION="${PTY_VERSION:-0.2.0}"
2626
BUN_PTY_VERSION="${BUN_PTY_VERSION:-0.4.9}"
2727
NDK_DIR="${NDK_DIR:-/opt/android-ndk}"

‎tests/README.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,17 @@ the change is acknowledged:
4141
```sh
4242
bash tests/run.sh --update-golden
4343
```
44+
45+
## On-device smoke (`smoke-device.sh`, manual)
46+
47+
`tests/smoke-device.sh` is **not** part of `run.sh` or CI: it runs on a real
48+
Termux device against the *installed* build. The maintainer runs it before
49+
publishing a release and pastes the printed report block into the release
50+
notes. Probes (no provider auth needed): `--version`, service
51+
stop/start/status round-trip (restores prior state), `server.info`, full PTY
52+
lifecycle (`pty.create` → exit 0 → `pty.remove`), session create/delete, TUI
53+
frames under `script(1)`, and watcher evidence (`subscribe`+`started` for the
54+
scratch project, live `type=directory backend=inotify`) from the server log.
55+
Every capture is also scanned for native-load failure signatures
56+
(`__errno_location`, `libc.so.6`, dlopen errors). Needs `util-linux`
57+
(`script`) and `coreutils` (`timeout`) on the device.

‎tests/build-vendors.bats‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ setup() {
1212

1313
# Versions matching the files committed under vendor/.
1414
vendored_env() {
15-
export OPENTUI_VERSION=0.5.14 PTY_VERSION=0.2.0 BUN_PTY_VERSION=0.4.9
15+
export OPENTUI_VERSION=0.5.16 PTY_VERSION=0.2.0 BUN_PTY_VERSION=0.4.9
1616
}
1717

1818
@test "--plan reports no builds needed when the cache is warm" {

‎tests/golden/vendor.sha256‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
f744bb4143b02d4ce8c378f4d7766778612bdd1a1f2868f503babf0d7a373b40 libopentui-0.5.14-android-aarch64.so
1+
a1597326518426473fada9ee4132573b68add65efaa3dea940c44f4753ccc692 libopentui-0.5.16-android-aarch64.so
22
660aeef323f068cf5c51974ee8203922c85e550a166dbb22e785b1b6bece8f00 librust_pty-0.4.9-android-aarch64.so
3-
4760d74887b66f5a0e4b26965f014968ae7ec2e11b171bf4d423014843f07b51 opencode-pty-0.2.0-android-aarch64
3+
438f709bf01cce73b69ef4e8df2101652da6fa5f72219061ce5fe0960771190a opencode-pty-0.2.0-android-aarch64

‎tests/smoke-device.sh‎

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
#!/usr/bin/env bash
2+
# On-device acceptance smoke for an installed opencode2.
3+
# RUNS ON: Termux on Android (NOT in CI, NOT on Linux) — the maintainer runs
4+
# this on a real device before publishing a release and pastes the report
5+
# block into the release notes.
6+
#
7+
# No provider auth is needed: every probe stays below the model-call line
8+
# (server lifecycle, PTY spawn, session CRUD, TUI boot, watcher subscribe).
9+
#
10+
# Usage: bash tests/smoke-device.sh [--cmd NAME] [--keep]
11+
# --cmd command to probe (default: opencode2)
12+
# --keep leave the scratch project + raw captures for inspection
13+
# Env: SMOKE_TUI_SECS (TUI probe window, default 25)
14+
#
15+
# Probes:
16+
# 1. version ... wrapper resolves .bin, binary boots
17+
# 2. service ... stop/start/status lifecycle of the background daemon
18+
# 3. api ..... server answers server.info
19+
# 4. pty ..... pty.create runs `echo` (daemon spawn on bionic), exits 0,
20+
# appears in pty.list, disappears after pty.remove
21+
# 5. session . session.create/delete in the scratch project (no auth)
22+
# 6. tui ..... renders frames under script(1) (embedded bionic renderer)
23+
# 7. watcher . server log shows subscribe+started for the scratch project
24+
# (CLI path) and a live type=directory backend=inotify record
25+
# (patched parcel android->inotify path)
26+
# Every captured output is also scanned for native-load failure signatures
27+
# (__errno_location, libc.so.6, dlopen errors): the bug class this repo's
28+
# patches exist to prevent must fail loudly here, not as a blank screen.
29+
set -uo pipefail
30+
31+
CMD=opencode2
32+
KEEP=0
33+
while [ $# -gt 0 ]; do
34+
case "$1" in
35+
--cmd) [ $# -ge 2 ] || { echo "usage: $0 [--cmd NAME] [--keep]" >&2; exit 2; }; CMD="$2"; shift 2 ;;
36+
--cmd=*) CMD="${1#--cmd=}"; shift ;;
37+
--keep) KEEP=1; shift ;;
38+
-h|--help) echo "usage: $0 [--cmd NAME] [--keep]"; exit 0 ;;
39+
*) echo "unknown option: $1" >&2; echo "usage: $0 [--cmd NAME] [--keep]" >&2; exit 2 ;;
40+
esac
41+
done
42+
43+
command -v "$CMD" >/dev/null 2>&1 || { echo "FAILED: command not found: $CMD" >&2; exit 1; }
44+
command -v script >/dev/null 2>&1 || { echo "FAILED: 'script' missing (pkg install util-linux)" >&2; exit 1; }
45+
command -v timeout >/dev/null 2>&1 || { echo "FAILED: 'timeout' missing (pkg install coreutils)" >&2; exit 1; }
46+
47+
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/opencode-smoke.XXXXXX")"
48+
PROJ="$SCRATCH/proj"
49+
CAP="$SCRATCH/captures"
50+
mkdir -p "$PROJ" "$CAP"
51+
52+
cleanup() {
53+
# Best effort: remove test sessions/ptys even on failure, drop scratch.
54+
if [ -n "${PTY_ID:-}" ]; then
55+
"$CMD" api DELETE "/api/pty/$PTY_ID" >/dev/null 2>&1 || true
56+
fi
57+
if [ -n "${SES_ID:-}" ]; then
58+
"$CMD" session delete "$SES_ID" >/dev/null 2>&1 || true
59+
fi
60+
# The TUI probe may auto-create sessions in the scratch project; sweep
61+
# anything left behind (scoped to $PROJ only).
62+
for sid in $("$CMD" api GET "/api/session?directory=$PROJ" 2>/dev/null \
63+
| grep -o '"id":"ses_[^"]*"' | cut -d'"' -f4); do
64+
"$CMD" session delete "$sid" >/dev/null 2>&1 || true
65+
done
66+
if [ "${WAS_RUNNING:-0}" = 1 ]; then
67+
"$CMD" service start >/dev/null 2>&1 || true
68+
fi
69+
if [ "$KEEP" = 0 ]; then
70+
rm -rf "$SCRATCH"
71+
else
72+
echo "kept: $SCRATCH"
73+
fi
74+
}
75+
trap cleanup EXIT
76+
77+
PASS=0
78+
FAIL=0
79+
REPORT_LINES=""
80+
81+
# Native-load failure signatures: any match fails the probe being scanned.
82+
NATIVE_SIG='__errno_location|libc\.so\.6|libm\.so\.6|dlopen failed|cannot load|Failed to load|MODULE_NOT_FOUND|ERR_DLOPEN|cannot open shared'
83+
84+
pass() {
85+
PASS=$((PASS + 1))
86+
REPORT_LINES="${REPORT_LINES}
87+
- $1: PASS$2"
88+
echo "PASS: $1$2"
89+
}
90+
91+
fail() {
92+
FAIL=$((FAIL + 1))
93+
REPORT_LINES="${REPORT_LINES}
94+
- $1: FAIL ($2)"
95+
echo "FAIL: $1 ($2)"
96+
}
97+
98+
# scan_native <probe> <file>: fail the probe if native-load signatures appear.
99+
scan_native() {
100+
if grep -aEq "$NATIVE_SIG" "$2"; then
101+
fail "$1" "native-load signature in output: $(grep -aoE "$NATIVE_SIG" "$2" | head -1)"
102+
return 1
103+
fi
104+
return 0
105+
}
106+
107+
echo "== smoke-device: probing '$CMD' (scratch: $SCRATCH)"
108+
109+
# ── 1. version ─────────────────────────────────────────────────────────
110+
if "$CMD" --version >"$CAP/version.out" 2>&1 \
111+
&& grep -q "opencode v" "$CAP/version.out"; then
112+
if scan_native "version" "$CAP/version.out"; then
113+
pass "version" " ($(cat "$CAP/version.out"))"
114+
fi
115+
else
116+
fail "version" "unexpected output: $(head -c 120 "$CAP/version.out" 2>/dev/null)"
117+
fi
118+
119+
# ── server log window: only lines written from here on count ──────────
120+
LOG_FILE=""
121+
if LOG_CANDIDATE="$("$CMD" debug paths 2>/dev/null | awk '$1 == "log" { $1 = ""; sub(/^ +/, ""); print; exit }')"; then
122+
if [ -n "$LOG_CANDIDATE" ] && [ -f "$LOG_CANDIDATE/opencode.log" ]; then
123+
LOG_FILE="$LOG_CANDIDATE/opencode.log"
124+
fi
125+
fi
126+
if [ -z "$LOG_FILE" ] && [ -f "$HOME/.local/share/opencode/log/opencode.log" ]; then
127+
LOG_FILE="$HOME/.local/share/opencode/log/opencode.log"
128+
fi
129+
if [ -n "$LOG_FILE" ]; then
130+
LOG_MARK="$(wc -c <"$LOG_FILE")"
131+
else
132+
echo "NOTE: server log not found; watcher probe will SKIP"
133+
LOG_MARK=0
134+
fi
135+
log_window() {
136+
if [ -n "$LOG_FILE" ]; then
137+
tail -c +"$((LOG_MARK + 1))" "$LOG_FILE" 2>/dev/null || true
138+
fi
139+
}
140+
141+
# ── 2. service lifecycle (save + restore maintainer state) ────────────
142+
if "$CMD" service status >"$CAP/status.before" 2>&1 && grep -q "http" "$CAP/status.before"; then
143+
WAS_RUNNING=1
144+
else
145+
WAS_RUNNING=0
146+
fi
147+
"$CMD" service stop >"$CAP/service.stop" 2>&1 || true
148+
sleep 2
149+
STOP_OK=0
150+
"$CMD" service status >"$CAP/status.stopped" 2>&1 || true
151+
if ! grep -q "http" "$CAP/status.stopped" 2>/dev/null; then
152+
STOP_OK=1
153+
fi
154+
"$CMD" service start >"$CAP/service.start" 2>&1
155+
sleep 3
156+
if "$CMD" service status >"$CAP/status.started" 2>&1 && grep -q "http" "$CAP/status.started"; then
157+
START_OK=1
158+
else
159+
START_OK=0
160+
fi
161+
if [ "$STOP_OK" = 1 ] && [ "$START_OK" = 1 ] \
162+
&& scan_native "service" "$CAP/service.start"; then
163+
pass "service" " (stop/start/status round-trip; was running: $WAS_RUNNING)"
164+
else
165+
fail "service" "stop_ok=$STOP_OK start_ok=$START_OK (was running: $WAS_RUNNING)"
166+
fi
167+
168+
# ── 3. server.info ────────────────────────────────────────────────────
169+
if "$CMD" api GET /api/info >"$CAP/info.out" 2>&1 \
170+
&& grep -q '"version"' "$CAP/info.out" \
171+
&& scan_native "api/info" "$CAP/info.out"; then
172+
pass "api/info" " ($(grep -o '"version":"[^"]*"' "$CAP/info.out" | head -1))"
173+
else
174+
fail "api/info" "server.info did not answer"
175+
fi
176+
177+
# ── 4. pty lifecycle (daemon spawn on bionic) ─────────────────────────
178+
PTY_ID=""
179+
if "$CMD" api POST /api/pty \
180+
-d "{\"command\":\"echo\",\"args\":[\"smoke-pty-ok\"],\"cwd\":\"$PROJ\"}" \
181+
>"$CAP/pty.create" 2>&1; then
182+
PTY_ID="$(grep -o '"id":"pty_[^"]*"' "$CAP/pty.create" | head -1 | cut -d'"' -f4)"
183+
fi
184+
PTY_OK=0
185+
if [ -n "$PTY_ID" ] && scan_native "pty" "$CAP/pty.create"; then
186+
for _ in $(seq 1 15); do
187+
if "$CMD" api GET "/api/pty/$PTY_ID" >"$CAP/pty.get" 2>/dev/null \
188+
&& grep -q '"status":"exited"' "$CAP/pty.get"; then
189+
if grep -q '"exitCode":0' "$CAP/pty.get"; then PTY_OK=1; fi
190+
break
191+
fi
192+
sleep 2
193+
done
194+
if [ "$PTY_OK" = 1 ] && "$CMD" api GET /api/pty >"$CAP/pty.list" 2>/dev/null \
195+
&& grep -q "$PTY_ID" "$CAP/pty.list" \
196+
&& "$CMD" api DELETE "/api/pty/$PTY_ID" >/dev/null 2>&1 \
197+
&& "$CMD" api GET /api/pty >"$CAP/pty.list2" 2>/dev/null \
198+
&& ! grep -q "$PTY_ID" "$CAP/pty.list2"; then
199+
pass "pty" " (create/run/exit-0/list/remove $PTY_ID)"
200+
PTY_ID=""
201+
else
202+
fail "pty" "lifecycle incomplete for ${PTY_ID:-<none>}"
203+
fi
204+
else
205+
fail "pty" "pty.create failed"
206+
fi
207+
208+
# ── 5. session create/delete (no auth) ───────────────────────────────
209+
SES_ID=""
210+
if "$CMD" api POST /api/session \
211+
-d "{\"title\":\"smoke-device\",\"location\":{\"directory\":\"$PROJ\"}}" \
212+
>"$CAP/session.create" 2>&1; then
213+
SES_ID="$(grep -o '"id":"ses_[^"]*"' "$CAP/session.create" | head -1 | cut -d'"' -f4)"
214+
fi
215+
if [ -n "$SES_ID" ] && scan_native "session" "$CAP/session.create" \
216+
&& "$CMD" session delete "$SES_ID" >"$CAP/session.delete" 2>&1; then
217+
pass "session" " (create/delete $SES_ID)"
218+
SES_ID=""
219+
else
220+
fail "session" "session.create/delete failed"
221+
fi
222+
223+
# ── 6. TUI renders frames under a pty ────────────────────────────────
224+
# Window tunable for slow/flaky environments; the default suits releases.
225+
TUI_SECS="${SMOKE_TUI_SECS:-25}"
226+
if printf 'q' | TERM=xterm-256color timeout "$TUI_SECS" script -qec "$CMD $PROJ --print-logs" /dev/null \
227+
>"$CAP/tui.out" 2>&1; then
228+
: # 'q' quit cleanly before the timeout
229+
fi
230+
TUI_SIZE="$(wc -c <"$CAP/tui.out" | tr -d ' ')"
231+
if [ "$TUI_SIZE" -ge 4096 ] \
232+
&& grep -qaF "$(printf '\033[?1049h')" "$CAP/tui.out" \
233+
&& scan_native "tui" "$CAP/tui.out"; then
234+
pass "tui" " (${TUI_SIZE} bytes of frames, alt-screen init seen)"
235+
else
236+
fail "tui" "no TUI frames (captured ${TUI_SIZE} bytes)"
237+
fi
238+
sleep 2 # let the server flush watch lines to its log
239+
240+
# ── 7. watcher evidence in the server log ────────────────────────────
241+
if [ -z "$LOG_FILE" ]; then
242+
REPORT_LINES="${REPORT_LINES}
243+
- watcher: SKIP (server log not found)"
244+
echo "SKIP: watcher (server log not found)"
245+
else
246+
WIN="$CAP/log.window"
247+
log_window >"$WIN"
248+
if grep -q "watcher subscribe.*$PROJ" "$WIN" \
249+
&& grep -q "watcher started.*$PROJ.*backend=" "$WIN"; then
250+
pass "watcher" " (subscribe+started for scratch project)"
251+
else
252+
fail "watcher" "no subscribe/started lines for scratch project"
253+
fi
254+
if grep -q "type=directory backend=inotify" "$WIN"; then
255+
pass "watcher/inotify" " (live directory/inotify record)"
256+
else
257+
fail "watcher/inotify" "no type=directory backend=inotify record"
258+
fi
259+
fi
260+
261+
# ── report block for the release notes ───────────────────────────────
262+
VERSION="$(cat "$CAP/version.out" 2>/dev/null | head -1)"
263+
ANDROID="$(getprop ro.build.version.release 2>/dev/null || echo unknown)"
264+
echo
265+
echo "SMOKE REPORT (paste into release notes):"
266+
echo '```'
267+
echo "Device smoke — $VERSION ($(date -u +%Y-%m-%d))"
268+
echo "Device: $(uname -m), Android $ANDROID, Termux"
269+
echo "$REPORT_LINES" | sed '/^$/d'
270+
echo '```'
271+
echo
272+
echo "smoke-device: $PASS passed, $FAIL failed"
273+
[ "$FAIL" -eq 0 ]

0 commit comments

Comments
 (0)