This repo validates behavior with static checks, Vitest contract suites, a deterministic fake OpenCode server, and Playwright flows. It deliberately does not chase broad unit-test coverage.
Back to the validation index · engineering index.
Before creating or amending any commit, run npm run validate:commit. It runs
lint, app and test type-checking, and the full Vitest suite. Add the owning
focused checks from the matrix below; protocol/fake-server work also runs
npm run test:fake-server:self, UI flows run their affected Playwright spec,
and localization work runs the generator and strict i18n test.
If a required check fails or its toolchain is unavailable (wrong Node version, missing package manager or browser), the commit is blocked. Do not commit to let CI discover a preventable local failure. CI remains the integration authority, not the first validator.
| Change | Minimum validation |
|---|---|
| Docs, ADRs, Storybook catalog wiring | npm run test:docs |
| UI copy or translations | npm run gen:i18n, strict i18n test |
| Presentational component or story | npm run build:storybook |
| Provider/session/persistence logic | targeted Vitest, then fake server/E2E if the contract moved |
| Protocol, endpoint, or event | npm run test:fake-server:self, targeted E2E |
| User flow, blocking interaction, SSE, polling | focused Playwright spec or npm run test:e2e:web |
| Native module, keyboard, permissions, release config | npm run build:development:android when an SDK is available; release tag builds authoritatively |
ci.yml is the per-push gate: static checks, Vitest/architecture, fake-server
validation, FOSS preparation, Storybook, E2E budget and critical smoke flows.
release.yml runs the full Playwright suite and native release builds once on a
v* tag. Do not run the complete suite before every push; use the matrix below
to choose focused checks.
Pick the cheapest level that can detect the regression. Extend an existing
scenario before adding a new spec; see ADR 0010.
Use npm run impact -- <source-file> to list the tests that depend on a file
through value imports; it narrows the Vitest run but does not replace the matrix
or the commit gate.
Knip policy: public feature entrypoints (index.ts, runtime.ts), shared UI,
shared contracts, and the public protocol client/types are exported APIs and are
exempt from unused-export checks. Generated i18n resources, test/storybook/config
entries, and the few modules consumed by manual-transpile tests also carry
narrow, reviewed exemptions. Every other production module must have no unused
exports, types or duplicate exports. Prefer a specific path exemption with a
reason over a directory-wide ignore.
| Change | Preferred local test level | CI/release E2E |
|---|---|---|
| Docs, ADRs, repository Markdown | docs test + static | smoke |
| Translations | strict i18n test + static | smoke |
| Pure utility, parser, formatter, selector | targeted Vitest | smoke or affected spec |
| Presentational component or design token | Storybook + static + affected spec | smoke |
| Settings section or row | Storybook + settings.spec.mjs |
smoke |
| Chat, composer, transcript | chat, interactions, diffs specs |
smoke |
| Provider, session, persistence | Vitest integration + affected E2E | smoke on push; full on release |
| Protocol, endpoint, event, service adapter | fake-server self-test + contract Vitest + affected E2E | smoke on push; full on release |
| SSE, polling, reconnect, offline | deterministic Vitest + realtime/network-resilience |
smoke on push; full on release |
| Fake server or E2E infrastructure | self-test + affected E2E + human validation | smoke on push; full on release |
| Native voice, notifications, permissions, widgets | existing targeted tests + device checklist | smoke on push; manual device checks |
| Dependencies, app config, build/CI config | static + affected E2E | smoke on push; full on release |
| Release tag | full validation + ARM64-only native builds + static artifact verification | full |
Run the affected specs locally when the change touches runtime/,
shared/protocol/opencode/, shared/protocol/services/, tests/fake-opencode/, tests/e2e/,
dependencies, app/build configuration, workflows, a root layout, or more than
two domains. The release tag runs the full suite before distribution.
No new test is required for documentation-only changes, behavior-preserving refactors with existing coverage, generated files, or copy covered by locale parity and an existing flow. Agents must explain why existing coverage is sufficient in the PR verification section.
tests/vitest/docs.test.ts (npm run test:docs) enforces the documentation
contract: every doc is reachable from a section README, relative links and
anchors resolve, inline repository paths and npm run scripts exist, ADR
numbering/structure/index are current, the task routing surface and split
indexes are wired, and the Storybook catalog is present. It runs as part of
test:ci:static.
npm run build:storybook builds the web catalog for reusable presentation
components. It is not part of the app or E2E export. See
Storybook.
The browser flows dominate the gate. Static checks are the fast inner loop.
- static checks: roughly 15s warm and 45s cold locally; lint, app and test type-checking, and Vitest
- fake-server self-test: a few seconds
- Storybook catalog build: a few seconds; it is a static web build, not part of the app or E2E export
- full Playwright gate: several minutes in CI, dominated by browser execution
For local iteration:
# Once, to produce the URL-agnostic export
npm run build:web:e2e
# Terminal 1: serve the existing export without rebuilding
npm run serve:web:prebuilt
# Terminal 2: run only the spec you changed
npx playwright test tests/e2e/chat.spec.mjs
npm run test:e2e:smoke # critical flows
npm run test:e2e:last-failed # rerun the previous failures
npm run test:e2e:budget # check the expanded test/spec budgetConcurrent local runs must not share fixed ports. Use the isolated wrapper:
npm run test:e2e:web:isolated -- tests/e2e/realtime.spec.mjs
E2E_SKIP_BUILD=1 npm run test:e2e:web:isolated -- tests/e2e/realtime.spec.mjsWorkers default to 2 locally and 4 in CI. Override with E2E_WORKERS.
npm run validate:fast is an optional focused loop (static, fake-server
self-test, E2E budget and smoke). The full test:e2e:web suite runs on the
release tag and is not required before every push.
Two workflows own validation:
ci.yml— pushes tomain, pull requests, and reusableworkflow_callfromrelease.yml.release.yml—v*tag pushes, plus recovery-only manual dispatch.
ci.yml runs in parallel:
static—npm run test:ci:static(lint, app/test type-checking, Vitest and architecture checks), fake-server self-test, FOSS preparation, E2E budget, Storybook build and Android release-check self-test.e2e— critical@smokePlaywright flows. The release workflow calls the same job withmode: full.
There is no changed-path classifier and no gate job. Required branch-protection
checks are CI / static and CI / e2e.
release.yml verifies the tag, version and build numbers, requires the tag commit
to belong to main, runs full validation once, and builds Android Play, FOSS
Android and signed iOS in parallel. It statically verifies signing, package
identity, version, ARM64-only ABI, native libraries, R8/ProGuard safety, the
WorkManager constructor, FOSS exclusions and 16 KB page-size alignment before
uploading to Google Play internal testing, TestFlight and the GitHub Release.
Static artifact verification cannot guarantee successful device startup. Play internal testing and TestFlight are the real-device validation environments. There is no emulator or self-hosted device job. Release artifacts expire; the permanent copy is the GitHub Release asset or store upload.
For SDK or native dependency changes, use the existing gate above and record acceptance evidence against the exact commit. A successful development build is insufficient to mark a native dependency change ready for release. No additional mandatory CI workflow or native E2E framework is required.
| Target | Existing automated/build checks | Required native/store acceptance |
|---|---|---|
| Web development/E2E | Static, fake-server self-test, browser budget, Storybook, full web E2E; SDK dependency check and clean lockfile install | Human review of changed browser contracts; onboarding, links and update blockers retain work |
| Android Google Play | Development build; production release APK/AAB with R8 and shipping ABIs; inspect manifest, packaged libraries and signing | Play-installed older signed build to newer internal-track build: immediate consent, flexible background download with explicit install, cancel/cooldown, interrupted recovery in both modes and native error/Store fallback; no handoff or install during unsaved work |
| Android F-Droid | Existing FOSS preparation test and release entrypoint; inspect autolinking, Gradle dependencies and packaged APK | No Play Billing, Play updates, install-referrer, ML Kit or Firebase client; manual connection, notifications, widgets, sharing and offline models still work; retain licensing/reproducibility review |
| iOS App Store | Existing iOS prebuild/archive entrypoint, distribution signing, entitlements and packaging; compile all retained modules | Public verified listing/environment and explicit App Store navigation; TestFlight/dev/offline suppressed; Cloud Link purchase/restore and links; no StoreKit update sheet |
| Permissions and voice | Existing voice/runtime tests and voice device checklist | Permission grant/deny/revoke, interruption/background/teardown, microphone exclusivity, optional model install/remove and failed init recovery; no model load at ordinary boot |
| Notifications and widgets | Existing notification/widget tests; release manifest/service/task/receiver inspection | Foreground service start/stop, denied permission, background/process death, notification taps and installed widget refresh/deep links |
| Sharing, keyboard and gestures | Existing owning unit/browser coverage, patched Sharing source checks and minified release build | Multi-item/text/content-URI shares and cleanup; composer/forms/terminal/modals, Back, hardware keyboard, text scaling and screen readers on both platforms |
| Android content capture | Config-plugin exact-order/idempotence test; inspect generated and minified release MainActivity | On supported Android with content capture enabled, exercise large transcripts/catalogs; mitigation stays immediately after superclass creation |
| Cloud Link and secrets | Existing purchase/pairing/recovery tests and full E2E; FOSS exclusion test | Real sandbox/test purchase, restore, cancellation and environment transitions; SecureStore persistence, relaunch and no credentials in captures/logs |
See library decisions, build/signing operations, store-update acceptance and F-Droid requirements. If the signed builds, eligible store accounts or physical devices are unavailable, report those checks as outstanding; mocked or simulator evidence cannot satisfy them. Roll back by reverting the coordinated commits and lockfile, then regenerate native projects. Published versions require a higher-numbered forward release.
Every release job runs scripts/ci/verify-android-release.mjs before upload. It
requires only arm64-v8a, expected native libraries, 16 KB ELF and APK alignment,
a valid signature matching ANDROID_CERT_SHA256, the expected package/version,
a non-empty R8 mapping, the public WorkDatabase_Impl() constructor and the FOSS
exclusions. Both release jobs also run:
python3 tests/native/android-launch.py --self-test
python3 tests/native/android-launch.py --check-apk-only --apk /path/to/app-release.apkThe manual --apk mode remains available for a developer with a connected device:
python3 tests/native/android-launch.py --apk /path/to/opencode-mobile.apk --output output/android-launchIt is not a CI requirement. Google Play internal testing and TestFlight are the real-device validation environments. Static artifact verification cannot guarantee successful startup, rendering or native initialization; a device-only failure is fixed forward with a new version and tag.
Web checks do not establish native frame rate, launch latency, battery use,
memory, physical-device keyboard behavior, camera or microphone permission
flows, screen-reader acceptance, real App Store/Play purchases, full-screen
terminal compatibility, or native TLS trust. Custom CA/self-signed certificate
support must be validated on Android and iOS devices or simulators against a
local HTTPS server, including API, SSE, terminal WebSocket and background
notification reads. Use voice validation for
voice-device checks and known gaps for deferred work.
Changes under tests/e2e/ or tests/fake-opencode/ require explicit human
validation even when every automated check passes.
Cloud Link activation checks cover 3/6/12/15-second backoff, request time within the shared 120-second budget, mixed transient failures, explicit saved-credential retry, permanent failures, general/manual reconnect exclusion, stale results, background suspension and teardown cleanup. Provider-hook coverage verifies foreground recovery does not overlap or restart activation and rescan retains the saved profile. Protocol checks preserve HTML 1033 before SDK parsing and keep 401/403 and TLS/certificate failures immediately actionable.
Recovery classification is pinned by features/connections/__tests__/connection-classification.test.ts
(tunnel-startup, offline, timeout, auth, entitlement, server-incompatible,
unknown, and the retry/auth policies). runtime/__tests__/provider-runtime.test.ts covers
the liveness watchdog (one re-subscription per staleness window, foreground
cycle, no traffic while healthy), the queued full reconcile behind an in-flight
safety poll, auth-failure stream stop with a single provider notification, and
the terminal reconnect on a rotated credential client.
features/cloud-link/__tests__/connect-recovery.test.ts covers single-flight concurrent connects
(one project discovery), same-machine rotation using the soft reset (project
preserved), and data-plane revocation (state cleared once, Cloud Link recovery
reused). features/terminal/__tests__/terminal.test.ts covers jittered bounded reconnect
delays and cursor-preserving reconnect with rotated credentials.
tests/e2e/realtime.spec.mjs adds a silently stalled SSE flow (watchdog
re-subscribes and the released stall reconciles a missed blocker, both
protocols) and a browser offline/online drop that recovers the retained session
without re-submitting the prompt.
tests/e2e/network-resilience.spec.mjs adds deterministic 4G latency and an
offline queued prompt that is delivered once after reconnect. The fake server's
network injector, all E2E additions, and the web offline transitions require
explicit human validation under AGENTS.md.
Device acceptance still needs Wi-Fi/cellular transitions, sleep/wake resume, real revocation, and Cloud Link renewal with a live terminal and editor draft.
The web Cloud Link flows use controlled time and mocked tunnel responses to check waiting beyond 15 seconds without recovery controls, automatic connection, neutral timeout without automatic restart, explicit Retry without replaying claim/access, and regenerated-QR recovery. E2E changes require explicit human validation under AGENTS.md. Real-device acceptance remains outstanding: delayed desktop approval, approval followed by slow DNS/tunnel startup, denial/TTL expiry followed by a regenerated QR, and background/resume during the wait.
Cloud Link subscription checks are described in connect.md. Provider
checks cover rejected/false native initialization and billing failures
during product and existing-purchase queries on both stores. Retry reconnects and
replays initialization while checkout stays disabled; purchase checkpoints retain
their existing recovery path. The V2 inbox E2E resets the shared boot backend
before opening chat so the preceding attachment flow cannot leak its conversation.
Static checks validate claim/secure-write ordering, StoreKit finalization on iOS, and
the backend-owned Google acknowledgement (Android never calls
finishTransaction). Mocked E2E validates explicit Purchase/Restore, silent
unfinished-purchase recovery, pending/cancellation, exact QR continuation,
transient/save retries, existing-machine access, identity mismatch, rotation and
expiry. These do not prove native store acceptance. Native
camera, secure relaunch/locked-device access, real tunnel upgrades, and
revocation still require explicit physical-device validation.
test:connect covers the low-level Cloud Link API, pairing/trust parsing,
credential storage and app-config contract. features/cloud-link/__tests__/connect-recovery.test.ts
is complementary: it exercises the actual provider hooks with deterministic
app-state, time, native store and storage boundaries. It covers healthy reopen,
background expiry and retry cancellation, cold-launch store readiness, shared
credential access, stale recovery success and failure after switching
connections, and renewal with Settings mounted. Profile checks distinguish
machines/environments while preserving manual scope
matching. The live-renewal E2E checks one active saved row, fresh username, panel
close/reopen and selected-session continuity without a document reload.
The service-domain cutover checks reject both legacy control planes before any
request or store proof is sent, preserve isolated legacy secure records, and
discard legacy environment preferences in favor of api.opencodecloud.link.
Cloud Link E2E exercises both old preferences through purchase and pairing on the
new production endpoint, plus the existing production/staging recovery flows.
These E2E edits require explicit human validation under AGENTS.md; mocked
requests do not verify deployment or real store acceptance on the new domain.
The camera-gate component check covers permission request-on-entry, grant, requestable denial, blocked denial, and web bypass. Native validation still needs to confirm the OS prompt and Subscribe/Restore continuation on device.
The following important behaviors are present in code but are not obviously covered by the current documented E2E suite:
- conversation mode state machine
- native speech recognition failures and permission edge cases (the pure recovery policy is covered by
test:voice-errors; the native paths still need device validation) - native TTS playback, on-device model install/prefetch, and the completion watchdog
- notification initialization and background monitoring
- session fork and revert/unrevert
- attachment upload behavior
- attachment capability rejection and the 10 MB local-file limit
- project patch conflict UI and worktree remove
- MCP add/connect/disconnect and OAuth UI completion
- terminal reconnect/termination, ANSI handling, scrollback truncation, and native WebSocket behavior
- auto-approve preference toggling
- model enablement filtering and preference reconciliation
- session summarization fallback behavior
- keep-awake side effects
- working-sound busy/idle transitions
- native SSE transport behavior and real cellular reconnect timing (web missed-event recovery, deterministic backoff, injected 4G latency, and offline queue recovery are covered)
These are useful candidates for future validation if the product depends on them heavily.
Useful local commands documented in the repo:
npm run lint
npm run typecheck
npm run test:vitest
npm run test:fake-server:self
npm run test:e2e:web
npm run validate:fast
npm run test:e2e:smoke
npm run test:e2e:web:isolated
npm run build:development:androidTo debug the fake backend directly:
npm run test:fake-server| Layer | Location | Purpose |
|---|---|---|
| Vitest | tests/vitest/ |
Contract, provider, persistence, formatting, i18n, docs, architecture |
| Fake server | tests/fake-opencode/ |
Deterministic V1/V2 HTTP, SSE, PTY, and scenario fixtures |
| E2E | tests/e2e/ |
Playwright flows over the fake server |
| Native | tests/native/ |
Native-specific checks and fixtures |