This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri-v2-mobile-zerocopy-ipc-protocol

Tauri 2.0 Mobile Zero-Copy Binary IPC Buffer Transfer Protocol

Enforces zero-copy binary ArrayBuffer transfers over Tauri 2.0 mobile IPC boundaries to eliminate JSON serialization and GC pauses during high-throughput edge inference and raw audio streaming. Mandates typed array memory pooling and binary protocol handlers over WKWebView and Android WebView bridge layers.

Prohibited Anti-Pattern: Serializing High-Frequency Tensor or PCM Audio Buffers to JSON or Base64 Across Tauri Mobile IPC

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Zero-Copy Binary IPC Buffer Transfer Protocol - Enforces zero-copy binary ArrayBuffer transfers over Tauri 2.0 mobile IPC boundaries to eliminate JSON serialization and GC pauses during high-throughput edge inference and raw audio streaming. Mandates typed array memory pooling and binary protocol handlers over WKWebView and Android WebView bridge layers.
globs: src/**/*.{ts,tsx}, src-tauri/src/**/*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-mobile-zerocopy-ipc-protocol"
---

# Tauri 2.0 Mobile Zero-Copy Binary IPC Buffer Transfer Protocol

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Serializing High-Frequency Tensor or PCM Audio Buffers to JSON or Base64 Across Tauri Mobile IPC

## System Constraints
You are a Principal Mobile Systems Architect enforcing Tauri 2.0 zero-copy binary IPC standards. You must eliminate all JSON, string, and Base64 serialization when streaming raw audio PCM frames or edge machine learning inference tensors across the WebView-to-Rust native boundary.

## Strict Guidelines
- Engineers MUST ALWAYS transfer raw continuous binary payloads (PCM audio, camera frames, ML tensors) using Tauri 2.0 raw binary IPC (`invoke` with binary `Uint8Array` bodies or `tauri::ipc::Response`) rather than structured JSON.
- Engineers MUST NOT convert TypedArrays (`Float32Array`, `Uint8Array`) to generic JavaScript arrays (`Array.from()`) or Base64 strings prior to crossing the IPC boundary.
- Code SHOULD pre-allocate reusable ring buffers or `ArrayBuffer` pools inside Web Workers to avoid triggering V8/JavaScriptCore garbage collection cycles on mobile devices during stream processing.
- Services MUST validate buffer memory alignment and byte lengths on the Rust side before casting pointers into typed native slices (`bytemuck` or SIMD vector types).
- Components NEVER execute raw binary IPC transformations or audio/tensor decoding directly on the main UI thread; all IPC buffer consumption must execute within dedicated Web Workers or AudioWorklet processors.

## Bad vs Good Implementations
### Edge Inference Frame Transfer over Mobile IPC

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Converting a high-dimensional TypedArray to a standard JavaScript Array forces the engine to box every float into an object, creating hundreds of thousands of heap allocations. Serializing this to JSON string across WKWebView/Android WebView IPC introduces fatal frame drops and thermal throttling.
```typescript
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Serializing 512x512x3 float tensor to JSON causes massive GC spikes and thread stall
export async function runMobileInference(tensorData: Float32Array): Promise<Float32Array> {
  const payload = Array.from(tensorData); // Catastrophic memory ballooning in WebView
  const rawResult = await invoke<number[]>('run_inference_json', {
    tensor: payload,
  });
  return new Float32Array(rawResult);
}
```

#### Production Standard (Correct)
> **Standard**: Operates entirely over contiguous byte boundaries using raw binary IPC in Tauri 2.0. The native layer consumes the raw byte buffer via `tauri::ipc::Request` directly into native memory, bypassing JSON parsing and reducing GC pressure to zero.
```typescript
import { invoke } from '@tauri-apps/api/core';

// PRODUCTION INVARIANT: Zero-copy raw byte transfer via Tauri 2.0 binary IPC
export async function runMobileInference(tensorData: Float32Array): Promise<Float32Array> {
  // Wrap backing ArrayBuffer view without cloning
  const rawBytes = new Uint8Array(
    tensorData.buffer,
    tensorData.byteOffset,
    tensorData.byteLength
  );

  // Invoke binary-compatible Tauri 2.0 native endpoint returning Response bytes
  const responseBytes = await invoke<Uint8Array>('run_inference_binary', rawBytes, {
    headers: {
      'content-type': 'application/octet-stream',
    },
  });

  // Zero-copy reinterpret response buffer into typed floating-point tensor
  return new Float32Array(
    responseBytes.buffer,
    responseBytes.byteOffset,
    responseBytes.byteLength / Float32Array.BYTES_PER_ELEMENT
  );
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Mobile Zero-Copy Binary IPC Buffer Transfer Protocol

Tauri 2.0 Mobile Zero-Copy Binary IPC Buffer Transfer Protocol defines an industrial-grade behavioral standard for mobile engineering. Enforces zero-copy binary ArrayBuffer transfers over Tauri 2.0 mobile IPC boundaries to eliminate JSON serialization and GC pauses during high-throughput edge inference and raw audio streaming. Mandates typed array memory pooling and binary protocol handlers over WKWebView and Android WebView bridge layers. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Serializing High-Frequency Tensor or PCM Audio Buffers to JSON or Base64 Across Tauri Mobile IPC Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftSerializing High-Frequency Tensor or PCM Audio Buffers to JSON or Base64 Across Tauri Mobile IPCCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS transfer raw continuous binary payloads (PCM audio, camera frames, ML tensors) using Tauri 2.0 raw binary IPC (`invoke` with binary `Uint8Array` bodies or `tauri

Engineers MUST ALWAYS transfer raw continuous binary payloads (PCM audio, camera frames, ML tensors) using Tauri 2.0 raw binary IPC (`invoke` with binary `Uint8Array` bodies or `tauri::ipc::Response`) rather than structured JSON.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NOT convert TypedArrays (`Float32Array`, `Uint8Array`) to generic JavaScript arrays (`Array.from()`) or Base64 strings prior to crossing the IPC boundary.

Engineers MUST NOT convert TypedArrays (`Float32Array`, `Uint8Array`) to generic JavaScript arrays (`Array.from()`) or Base64 strings prior to crossing the IPC boundary.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Code SHOULD pre-allocate reusable ring buffers or `ArrayBuffer` pools inside Web Workers to avoid triggering V8/JavaScriptCore garbage collection cycles on mobile devices during stream processing.

Code SHOULD pre-allocate reusable ring buffers or `ArrayBuffer` pools inside Web Workers to avoid triggering V8/JavaScriptCore garbage collection cycles on mobile devices during stream processing.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Services MUST validate buffer memory alignment and byte lengths on the Rust side before casting pointers into typed native slices (`bytemuck` or SIMD vector types).

Services MUST validate buffer memory alignment and byte lengths on the Rust side before casting pointers into typed native slices (`bytemuck` or SIMD vector types).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Components NEVER execute raw binary IPC transformations or audio/tensor decoding directly on the main UI thread

Components NEVER execute raw binary IPC transformations or audio/tensor decoding directly on the main UI thread; all IPC buffer consumption must execute within dedicated Web Workers or AudioWorklet processors.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Tauri 2.0 Mobile Zero-Copy Binary IPC Buffer Transfer Protocol critical for AI coding assistants?

Enforces zero-copy binary ArrayBuffer transfers over Tauri 2.0 mobile IPC boundaries to eliminate JSON serialization and GC pauses during high-throughput edge inference and raw audio streaming. Mandates typed array memory pooling and binary protocol handlers over WKWebView and Android WebView bridge layers. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Serializing High-Frequency Tensor or PCM Audio Buffers to JSON or Base64 Across Tauri Mobile IPC) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

Related MOBILE Rules

View all rules →
1 Rule in Stack

Tauri