Skip to main content

Android Agent Harness

Deterministic Android Engineering for the AI Era

Turn AI coding assistants into an uncompromising senior Android engineering team.
Deterministic local governance • Tamper-evident verification • Zero Python runtime dependencies

Release Python License Zero Dependencies Platform Tests

Guarantees • Why This Exists • What This Is Not • Quickstart • Pipeline • Real-World Example • Why Not Just Rules? • Android Guardians • Supported Hosts • CLI Reference


Core Guarantees

  1. Deterministic Human Authority: AI agents are strictly restricted to read-only discovery and planning. Implementation cannot begin without explicit developer approval recorded in plan.json.
  2. Zero Autonomous Git Mutations: In client Android applications, the agent never stages, commits, resets, or pushes code. All modifications remain unstaged for the developer to inspect and commit.
  3. Deterministic Multi-Label Surface Classification: Inspects Git diffs across 15+ Android-specific surfaces (ROOM_SCHEMA, COMPOSE_UI, XML_UI, NAVIGATION, BILLING, AUTH, CRYPTO, BUILD_CONFIG, MANIFEST_PERMISSION, etc.). Unclassified delivery-relevant changes are tagged UNKNOWN to prevent masking.
  4. Proportional Adaptive Review & Token Protection: Eliminates runaway LLM costs. Micro-changes (simple docs, localized strings) bypass semantic reviewers. High and critical changes trigger up to five core specialist reviewer agents (plus a conditional test-quality reviewer) within a strict caller budget.
  5. Tamper-Evident Snapshot-Bound Evidence Store: Build results, test executions, and reviews produce append-only, tamper-evident evidence bound to the exact delivery_snapshot_sha256, repository identity, run ID, and Git branch.
  6. Unified APK Artifact-Set Integrity: Multi-APK and split-APK builds are verified as a single cohesive artifact set. The exact hash is enforced across assemble, install, and device launch.
  7. Attributed Test Execution: Separates newly introduced regressions from pre-existing baseline test failures, preventing false-positive gate failures.
  8. Zero Python Runtime Dependencies: 100% Python standard library (pathlib, json, hashlib, subprocess, argparse). No pip install, zero third-party package supply-chain risks, and seamless operation across Windows, macOS, and Linux.

Why This Exists: The Problem with Raw AI Agents

AI coding assistants (Claude Code, Gemini CLI, Cursor, Windsurf, Roo Code) are powerful, but when let loose on production Android codebases, they present recurring failure modes:

Failure Mode in Raw AI Agents How Android Agent Harness Solves It
Silent Database Corruption
Agents modify Room entity fields without declaring migrations or testing schema compatibility.
Deterministic Room Guard recursively parses @Database, entities, and @Embedded classes across files, blocking delivery unless valid migration paths are proven.
Masked Regressions via Mixed Diffs
An agent touches a critical class and a doc file simultaneously, tricking naive classifiers into treating the change as low-risk.
Full-Coverage Classifier inspects every delivery-relevant file. Any unclassified file is tagged UNKNOWN, forcing human decision rather than auto-approval.
Runaway Token Costs
Dispatching 5+ reviewer agents on a trivial one-line string update wastes millions of tokens.
Adaptive Policy Matrix dynamically selects reviewers based on actual change severity (Micro, Low, Medium, High, Critical).
Git History Destruction
Agents perform unexpected git reset, create untracked commits, or rebase active branches.
Host Enforcement Hooks block autonomous git add, git commit, git push, and git reset commands in client applications.
Stale / Cross-Run Evidence Forgery
An agent re-uses previous test output or verifies code on branch A that was built on branch B.
Snapshot-Bound Evidence ties all evidence to repository identity, snapshot SHA-256, active branch, and single-use nonces.
Device & Emulator Inconsistencies
Agents install an APK to one device/user and launch on another, or launch outdated builds.
Device Chain Verifier ensures exact matching of artifact SHA-256, device serial SHA-256, and numeric Android user ID.

What This Is Not

Android Agent Harness is not:

  • A replacement for Android Studio or Gradle: It works alongside your existing Android toolchain (gradlew, Android SDK, ADB).
  • An AI model or provider: It does not bundle proprietary LLMs; it runs locally to govern whatever host AI assistant you use.
  • A generic autonomous coding framework: It does not mandate complex subagent swarms or perpetual background daemons.
  • A universal dogmatic TDD framework: It routes TDD where meaningful seams exist, without forcing ceremony on mechanical changes.
  • A CI/CD platform: It is a local developer governance layer ensuring changes are verified before they ever reach Git HEAD or CI.

Quickstart

Prerequisites

  • Python 3.10 or newer (standard library only).
  • Android project managed by Git with a root Gradle Wrapper (gradlew or gradlew.bat).
  • Android SDK and JDK (only when build or test gates are executed).

Chat installation (recommended)

Open your Android project in your AI coding agent (Antigravity, Gemini CLI, Claude Code, Cursor, Windsurf, or Roo Code), and paste:

Read https://raw.githubusercontent.com/rabee-elkholy/android-agent-harness/v1.0.21/docs/install-or-update-prompt.md and follow all instructions.

The agent will:

  1. Discover your project structure in read-only mode.
  2. Ask interactive configuration questions in chat.
  3. Present a non-interference installation plan.
  4. Wait for your approval, then provision the pinned kit into ~/.android-harness/kit.
  5. Run doctor to confirm that zero project source files were altered.

Terminal installation (alternative)

Run directly from your command line:

# Clone the pinned harness release
git clone --depth 1 --branch v1.0.21 --single-branch https://github.com/rabee-elkholy/android-agent-harness.git ~/.android-harness/kit

# Initialize inside your Android project
python ~/.android-harness/kit/harness_cli.py init --repo /path/to/android-project --kit ~/.android-harness/kit

# Verify configuration and environment health
python ~/.android-harness/kit/harness_cli.py doctor --repo /path/to/android-project

The installer configures .agents in your project and registers .git/info/exclude so that harness state never pollutes your repository's Git tracking.


Deterministic Android Delivery Pipeline

The harness operates as a deterministic finite state machine governing the interaction between the developer and the AI agent:

stateDiagram-v2
    [*] --> AWAITING_DEVELOPER_APPROVAL: workflow.py draft
    AWAITING_DEVELOPER_APPROVAL --> IMPLEMENTING: workflow.py approve + begin
    IMPLEMENTING --> VERIFYING: workflow.py prepare-verification
    VERIFYING --> BLOCKED: Findings or Test Failure
    BLOCKED --> IMPLEMENTING: workflow.py resume (same scope)
    VERIFYING --> READY_FOR_DELIVERY: workflow.py verify + complete
    READY_FOR_DELIVERY --> [*]: Developer commits & merges

Pipeline Stages

  1. discovery-and-scoping — Activates before writing code. Interrogates project architecture in read-only mode, explores alternatives, and binds exact target modules and surfaces.
  2. plan-authority-and-approval — Activates with drafted plan. Hashes scope, risks, and tests into an immutable contract. Implementation authority remains deterministically locked by local harness enforcement until explicit developer approval.
  3. mutation-guard-and-isolation — Activates upon approval. Enforces deterministic host-level interception: blocks raw Gradle/ADB commands, protects generated source directories, and leaves Git staging to the developer.
  4. adaptive-skill-routing — Activates on code changes. Classifies 15+ Android surfaces (Room, Compose, Coroutines, Security) and routes specialized engineering skills with token-budget protection.
  5. test-driven-development — Activates during implementation. Applies policy-routed TDD for meaningful behavioral changes, isolates new regressions from pre-existing baseline test failures, and verifies unit test evidence.
  6. specialist-reviewer-squad — Activates during verification. Dispatches up to 5 isolated specialist subagents (plus test-quality when policy dictates) scoped strictly to modified diffs.
  7. tamper-evident-verification — Activates when work completes. Re-verifies Git branch, repository identity, and APK artifact-set hashes against append-only cryptographic evidence.

Deterministic state machines, not prompt suggestions. Proof before delivery.

Execution Sequence

# 1. Draft a task plan (Read-Only)
python .agents/scripts/workflow.py draft --repo . --task-id TASK-101 \
  --outcome "Implement user biometric authentication" \
  --expected-surfaces AUTH,CRYPTO,UI \
  --expected-modules :app

# 2. Developer approves the plan
python .agents/scripts/workflow.py approve --repo . --task-id TASK-101 \
  --source conversation --proof-reference MSG-4892 --enforcement-tier RULE_ENFORCED

# 3. Consume approval nonce and begin implementation
python .agents/scripts/workflow.py begin --repo . --task-id TASK-101

# ... AI agent implements code changes ...

# 4. Prepare verification (freezes delivery snapshot and policy)
python .agents/scripts/workflow.py prepare-verification --repo . --task-id TASK-101

# 5. For sensitive surfaces (auth/crypto/billing), developer confirms final snapshot
python .agents/scripts/workflow.py approve-sensitive --repo . --task-id TASK-101 \
  --source conversation --proof-reference CONFIRM-8391 --enforcement-tier RULE_ENFORCED

# 6. Execute gates and reviewers dictated by current-run.json
# e.g., run assemble, unit tests, room schema checks, or specialist reviews

# 7. Final read-only verification
python .agents/scripts/workflow.py verify --repo . --task-id TASK-101

# 8. Mark ready for delivery
python .agents/scripts/workflow.py complete --repo . --task-id TASK-101

Once marked READY_FOR_DELIVERY, the developer reviews the unstaged changes using standard Git tools (git diff, git status) and commits the work.


Real-World Example: Room Schema Migration

Here is how the harness deterministically prevents data corruption during a real Android database change:

1. Agent edits UserEntity.kt (adds @ColumnInfo val avatarUrl: String?)
   ↓
2. change_classifier.py tags the diff: ROOM_SCHEMA, PERSISTENCE (Severity: HIGH)
   ↓
3. room_guard.py recursively inspects AppDatabase.kt:
   - Detects database version bumped from 3 to 4.
   - Verifies that an explicit Migration(3, 4) is declared and added to addMigrations().
   - Confirms fallbackToDestructiveMigration() is NOT present in production builds.
   ↓
4. unit_tests gate runs targeted Room migration tests (:core:database:testDebugUnitTest).
   ↓
5. Adaptive reviewers (Bug Reviewer, Regression Reviewer) inspect the migration SQL.
   ↓
6. run_device.py verifies APK assemble and upgrade data retention on the test device.
   ↓
7. final_verifier.py independently checks that all evidence hashes match the final snapshot.
   ↓
8. Result: Zero silent crashes, zero wiped user databases, zero unreviewed SQL.

Why Not Just AGENTS.md / .cursorrules?

Prompt rules files provide suggestions; Android Agent Harness provides deterministic enforcement:

Capability Raw Prompt Rules (AGENTS.md, .cursorrules) Android Agent Harness
Enforcement Model Model can drift, ignore, or hallucinate around rules Local deterministic hooks & Python gates block unauthorized mutations
Evidence Freshness Agent can report tests passed without running them Cryptographically hashed evidence bound to active snapshot SHA-256
APK & Device Binding Agent may test old APK or mix up emulators/users Exact SHA-256 artifact matching across assemble, install, and launch
Android Semantic Awareness Generic code reasoning without domain checks Specialized guards for Room schemas, resource strings, and ANR risks
Token Budget & Reviews Spawns redundant reviewers on trivial changes Adaptive reviewer policy routing only required specialist leaves
Legacy Regressions Fails on existing broken tests in old codebases Automated baseline attribution isolates new regressions from pre-existing debt

Deterministic Android Quality Guardians

Beyond LLM reviews, the harness equips your workflow with purpose-built, deterministic static analyzers, hardware bridges, and diagnostics specifically engineered for Android development:

1. Adaptive Localization & String Guard (check_strings.py)

  • Diff-Scoped Resource Inspection: Analyzes touched string resources across all locale directories (values/strings.xml, values-ar/, values-es/, etc.).
  • Placeholder Parity: Catches subtle format-string mismatches (e.g., base defines Hello %s (%d) while a translated string has %d (%s)), preventing runtime UnknownFormatConversionException crashes.
  • Key Synchronization & Plural Parity: Detects missing translated keys and plural quantity mismatches (zero, one, two, few, many, other).
  • Hardcoded String Detection: Flags raw unextracted strings introduced in layout XML or Compose UI.

2. Room Database & Schema Migration Guard (room_guard.py)

  • Deep Recursive Schema Traversal: Parses @Database declarations and resolves all entity classes, relations, and nested @Embedded data classes across separate files.
  • Strict Migration Enforcement: When entities change, verifies that an explicit Migration(start, end) or AutoMigration path is declared and registered in addMigrations().
  • Destructive Migration Shield: Blocks silent data wipes caused by accidental fallbackToDestructiveMigration() calls in production code.

3. Smart Test Regression Isolation (baseline_capture.py & run_tests_gate.py)

  • Baseline vs. Regression Disambiguation: In real-world enterprise codebases, some legacy tests may already be broken. The harness captures a pre-task baseline of existing failures.
  • Zero-Block Progress: The gate fails only if the AI agent's changes introduce a new test regression or compilation error, preventing legacy technical debt from paralyzing modern agentic development.

4. Performance & ANR Risk Analyzer (perf_guard.py)

  • Main-Thread I/O Detection: Scans modified code for synchronous disk access, SQLite operations, SharedPreferences commits, or network calls executing on the UI thread.
  • Dispatcher Governance: Enforces structured concurrency guidelines (Dispatchers.IO, Dispatchers.Default) and catches unconfined or global CoroutineScope antipatterns.
  • Compose Recomposition Safeguards: Identifies unstable parameters, un-remembered state allocations, and infinite recomposition loops.

5. Intelligent Compiler Diagnostics (gradle_error_parser.py)

  • Actionable Diagnostic Extraction: Filters hundreds of lines of Gradle and Kotlin daemon noise to pinpoint the exact failure: file path, line number, and error message.
  • Annotation Processor & KSP Awareness: Accurately parses complex Dagger/Hilt missing dependency injection bindings and Room KSP schema generation failures into clear guidance for the AI agent.

6. Hardware Observability & Visual Evidence (capture_screen.py & logcat_doctor.py)

  • Automated Visual UI Snapshots: Automatically captures screenshots from physical devices or emulators upon task completion and saves them as review artifacts.
  • Live Crash & ANR Capture: Monitors Android Logcat during app launch and device testing, extracting fatal exception stack traces, uncaught exceptions, and native tombstone traces directly into the verification report.
  • Physical Device Priority: Automatically resolves connected hardware, prioritizing physical test devices over emulators to validate real-world Android performance.

7. Topology-Aware Multi-Module Project Graph (project_graph.py)

  • Topology-Aware Scoping: Discovers module dependencies across modern multi-module architectures (:core:network, :feature:auth, :app).
  • Targeted Build Execution: Directs Gradle to compile and test only the modules affected by the current change, saving minutes of build time on large projects.

8. Native Slash Command Packs (.agents/command-packs/)

  • Pre-installed prompt commands for all major AI coding hosts (Claude Code, OpenAI Codex, GitHub Copilot, and Gemini CLI):
    • /deliver — End-to-end implementation with verification.
    • /debug — Hypothesis-driven defect reproduction and fix.
    • /doctor — Instant environment and toolchain diagnosis.
    • /preflight — Rapid static lint, strings, and Room check.
    • /perf-audit — Dedicated ANR and memory leak inspection.

9. Project Management & Issue Tracker Governance (pm_policy.py)

  • Zoho Sprints & GitHub Projects Integration: Provides agents with structured, read-only context on active tasks and sprints.
  • Zero Rogue Mutations: Ticket status updates, comments, and time-logging mutations are locked behind explicit --external-write authorization and human confirmation.

Supported AI Hosts & Enforcement Tiers

The harness is host-agnostic and adapts to the security model of your coding environment:

AI Host Integration Mechanism Enforcement Level Protection Capabilities
Google Antigravity / Gemini CLI Native agents/hooks.json Hard Enforced Pre-command execution interceptor blocks unauthorized commands, raw Gradle/ADB, and Git mutations.
Claude Code Custom Tool Hooks & Settings Hard Enforced Native pre-tool execution hooks intercept file modifications and bash commands before execution.
GitHub Copilot .github/prompts & PreToolUse bridge Hard Enforced (where hook supported) Native prompt command packs with pre-tool mutation guards.
OpenAI Codex AGENTS.md, CODEX.md, .codex/prompts Rule Enforced Native slash-command prompt packs and instruction-enforced boundaries blocking unauthorized mutations and raw Gradle.
Cursor & Windsurf System Rules (.cursorrules / .windsurfrules) Rule Enforced Behavioral policy constraints prevent unauthorized mutations; verified at final delivery gate.
Roo Code / Cline Custom Modes & Instructions Rule Enforced Constrained persona workflows with policy gate enforcement.
Terminal / CI Native Python CLI Deterministic Full deterministic command-line validation and policy verification.

CLI Reference

harness_cli.py manages the harness engine lifecycle across target repositories:

# Initialize harness into an Android project
python harness_cli.py init --repo /path/to/project --kit /path/to/kit

# Atomically upgrade an existing project to a newer kit version
python harness_cli.py update --repo /path/to/project --kit /path/to/new-kit

# Run diagnostic health check
python harness_cli.py doctor --repo /path/to/project --json

# Dry-run harness uninstallation
python harness_cli.py uninstall --repo /path/to/project

# Apply clean uninstallation (restores pre-install files safely)
python harness_cli.py uninstall --repo /path/to/project --apply

# Run the complete deterministic selftest suite
python harness_cli.py selftest --kit .

Project Philosophy

Stricter proof, not heavier workflow.

Real Android production value > complexity + token cost + workflow friction + regression risk.

Stability first.

  • No Vanity Metrics: We do not assign arbitrary scores or bloat workflows with bureaucratic checkpoints.
  • Fail-Closed Safety: If a device serial cannot be confirmed, a migration path cannot be verified, or an unknown surface is touched, the system halts and asks the developer.
  • Respect the Repository: Your application code and Git tree belong to you. The harness never commits without permission and never touches files outside its designated boundaries.

Verification & Selftest

Every commit and release is validated by a 150+ test deterministic suite running on pure Python standard library:

# Run full deterministic test suite
python harness_cli.py selftest

# Run critical safety selftest suite
python agents/scripts/_critical_safety_selftest.py

# Validate release checksums and metadata
python scripts_dev/validate_release.py

Contributing & Community

Contributions that preserve the stability-first principles, zero-dependency runtime, and deterministic verification model are welcome.

  1. Review Architecture Guidelines and Threat Model.
  2. Ensure runtime code remains Python standard-library only.
  3. Verify that all 150+ tests pass via python harness_cli.py selftest.
  4. Open a pull request with clear rationale and regression coverage.

License

This project is licensed under the MIT License. Copyright © 2026 Rabee Elkholy.

Release files for android-agent-harness 1.0.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for android-agent-harness 1.0.21
File Size Uploaded
android_agent_harness-1.0.21.tar.gz 355.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for android-agent-harness 1.0.21
File Interpreter ABI Platform
android_agent_harness-1.0.21-py3-none-any.whl Python 3 none any Details

Total release size: 775.4 kB

Release files / android_agent_harness-1.0.21.tar.gz

Download URL android_agent_harness-1.0.21.tar.gz
Size 355.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4bed9297873017d9fcc996b2396553be3413f97d0436b97be4b2a7795c831b0d
BLAKE2b-256 checksum
How to use checksums
9be0f2075974c78f5137c5a03daf8d644fc085a6a74541210aca95da82006b23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / android_agent_harness-1.0.21-py3-none-any.whl

Download URL android_agent_harness-1.0.21-py3-none-any.whl
Size 420.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
265cf696a303581138387e00c3973f4e3213839cf009ef171d0baf8d72fc4a0d
BLAKE2b-256 checksum
How to use checksums
9d4182f076c83b9c65f6bac0cec4048477ce5fc2b4f94bbefe8438b602779947
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.0

2 release files

1.0.60

2 release files

1.0.59

2 release files

1.0.58

2 release files

1.0.57

2 release files

1.0.56

2 release files

1.0.55

2 release files

1.0.54

2 release files

1.0.53

2 release files

1.0.52

2 release files

1.0.51

2 release files

1.0.50

2 release files

1.0.48

2 release files

1.0.47

2 release files

1.0.46

2 release files

1.0.45

2 release files

1.0.44

2 release files

1.0.43

2 release files

1.0.42

2 release files

1.0.41

2 release files

1.0.40

2 release files

1.0.39

2 release files

1.0.38

2 release files

1.0.37

2 release files

1.0.36

2 release files

1.0.35

2 release files

1.0.34

2 release files

1.0.33

2 release files

1.0.32

2 release files

1.0.31

2 release files

1.0.30

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.26

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

This release

1.0.21 This release

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page