> **Historisch** (Stand DR, unverändert übernommen). Die hier genannten Module `integration_gateway`, `secure_orchestrator`, `telegram_dryrun`, `real_codex` und der `AriaOrchestrator` sind im V3-Kern entfernt; der einzige Ausführungspfad ist `aria_router.gateway.Gateway.handle()`. Aktueller Stand: `../docs/ARCHITEKTUR.md`.

# Aria V3, consolidated offline integration staging

Source: uploaded `aria-v3-merged-77tests.zip`. This archive adds `aria_router/integration_gateway.py` and 10 offline tests. All original source files and tests are retained.

## Verified locally

`python3 -m unittest discover -s tests -v`: 87 tests passed on the authoring environment. Re-run on the target Ubuntu server. No real Codex/Claude requests were made.

## What the new gateway does

- Parses `/auto`, `/codex`, `/claude`, `/status` without registering Telegram commands or starting a bot.
- Canonicalizes the outgoing prompt and memory text and computes SHA-256 over exactly that JSON payload.
- Rejects attachments entirely until actual attachment bytes can be verified, scanned, authorized and sent consistently.
- Requires TWO injected offline policy callbacks to permit the same context and backend. Both policy decisions are intersected before adapter execution.
- Rejects confidential/unknown privacy classifications.
- Supports mocked execution through the existing SecureOrchestrator.

## NOT production ready

- Neither injected policy is an authenticated trust root. A malicious caller can forge approval. A digest is integrity checking, not authorization.
- The gateway is not wired to Telegram, Claude, Supabase, hooks, memory services, or systemd.
- Existing `RealCodexAdapter` is NOT proven safe for actual invocation. The host's AppArmor/bubblewrap sandbox failure remains unresolved.
- CLI subscription usage must be checked against current account/product terms and rate limits. No additional paid usage should be authorized automatically.
- No real model invocations, no filesystem changes outside the staging directory, no service restarts.

## Safe staging deployment

Transfer ZIP to the server from the Mac with scp. On Ubuntu:

```bash
mkdir -p /root/aria-v3-gateway-stage
unzip -oq /root/aria_v3_gateway_staging.zip -d /root/aria-v3-gateway-stage
cd /root/aria-v3-gateway-stage
python3 -m unittest discover -s tests -v
```

## Production gates

1. Review actual `wrapper.sh`, Telegram `server.ts`, service units, all active hook configuration and monitoring dependencies. Do not start a second Telegram poller.
2. Implement authenticated, centrally controlled policy, with exact prompt, memory snapshot, attachment bytes, backend, job ID, expiry and budget reservation bound to approval.
3. Establish a working restrictive OS sandbox with non-root execution. Tool events detected after execution are not a prevention mechanism.
4. Implement genuine Codex and Claude adapters, with bounded output, process cancellation, session continuity, structured errors and no automatic paid overages.
5. Preserve `/status` pairing semantics and Telegram allowlist, Supabase logs, existing hooks and memory; test all with a single polling owner.
6. Run canary and rollback tests. Obtain explicit approval before touching `/home/aria` or `aria.service`.
