Elnor Repo Reader

DOC11_External_Agent_Engine_Adapter_Proposal_Prompt.md

Active Working and Red Team/Instructions and Prompts/DOC11_External_Agent_Engine_Adapter_Proposal_Prompt.md

Short text page f2b836efbd35. Generated 2026-06-09T01:23:58.539Z from commit dbaa25962edc11ab30e8d4ca1715f9ae5bf77331. Worktree: clean.

Open readable HTML page · Open raw txt · Open path URL

ELNOR REPO READER TEXT MIRROR
Original path: Active Working and Red Team/Instructions and Prompts/DOC11_External_Agent_Engine_Adapter_Proposal_Prompt.md
Source repo: /Users/OpenClaw1/Elnor/Elnor Specs
Git branch: main
Git commit: dbaa25962edc11ab30e8d4ca1715f9ae5bf77331
Generated: 2026-06-09T01:23:58.539Z

---

# DOC11 — External Agent Engine Adapter — Proposal Drafting Commission

**Repository:** github.com/wbrody/Elnor-Specs — branch `main` · **Date issued:** 2026-06-04 · **Architect:** Will Brody
**You are:** drafting a **PROPOSAL** (not an operative edit) extending DOC11 with the **External Agent Engine Adapter** capability — ELNOR driving external coding/review agents (Claude Agent SDK / Claude Code engine; OpenAI Codex CLI+SDK; optional Gemini CLI) headlessly on the architect's subscriptions, with engine routing, model/think controls, billing-path discipline, telemetry, and EC policy gating. The capability is **operationally proven** (2026-06-04, full headless loop on subscription auth) — your job is to spec it to DOC11's standard.

## 1. Read first (repo paths)

1. `OP-A and Operations and Trackers/CAPABILITY_NOTE_EXTERNAL_AGENT_CLI_ADAPTERS.md` — **the brief.** §1 engines/interfaces (verified versions), §2 governance hooks, §3 auth checklist, §5 engine tiers + the three hard rules (auth-precedence gotcha, queueing, Phase-2 multi-principal), §6 the seen-in-ELNOR stub. Everything you spec must trace here or to the docs below.
2. `Current Specs/DOC11/DOC11_OPENCLAW_GATEWAY_MODEL_CONTROLS_AND_EC_INTEGRATION_R14.md` — the operative DOC11. Match its conventions exactly: schema/route/read-model style, event payload minima, runtime-truth + usage-telemetry patterns, anti-ghost implementation rules.
3. `Current Specs/DOC11/DOC11_R15_OPENCLAW_RELEASE_ALIGNMENT_AMENDMENT_PROPOSAL_R3.md` — the pending R15 proposal. Your proposal must state compatibility with **both** operative R14 and pending R15 (flag any collision explicitly rather than silently resolving it).
4. Egress/delegation ground truth (reference, NEVER redefine): `Memory Rebuild Docs/Stage_6_Charters/E0_DOC80_Core/DOC80_Core_Charter_Draft.md` §22 (`E0OutboundDestinationClass` — `cloud_api`, `agent_messaging`) + §3.3 (`DelegationMFC`); `Memory Rebuild Docs/Stage_6_Charters/E1_E2_DOC81_Scope_Policy/DOC81_Scope_Policy_Charter_Draft.md` (R2) — the send-time gate, destination-specific decisions, and §4.0 internal-use-permissive posture.
5. Seam awareness (do not edit; list cross-doc obligations instead): DOC13 (Costs — billing tiers/usage), DOC12 (Inter-Agent Communication/ACP — if external agents surface as room participants), DOC20 (the Engines settings panel render), EC Core (policy evaluator socket).

## 2. Deliverable

One file: **`Current Specs/DOC11/DOC11_PROPOSAL_EXTERNAL_AGENT_ENGINE_ADAPTER.md`** (no version suffix — git is the version record). Status header: `proposal — for architect review + red team; not operative`. If you cannot write to the repo, return the complete file inline for the architect to save.

**Required content (DOC11-grade, paste-ready schemas):**
1. **Engine registry + adapter contracts** — engine descriptor (kind: `claude_agent_sdk | codex_cli | codex_sdk | gemini_cli | raw_api | local`; version pinning + drift check; auth source; health/login-status probe); invocation contracts for one-shot, resumed-session, and embedded-SDK-session runs; working-directory + sandbox-flag discipline (least-privilege defaults: read-only for review/audit roles, scoped write for report-writers).
2. **Per-role routing** — agent role → engine tier (T1 subscription-SDK default / T2 raw-API overflow / T3 local per the note §5), model, think level (thinking-token budget), permission mode, tool allowlist; routing is policy-respecting (EC consulted) and architect-overridable per run.
3. **Billing-path discipline** — the adapter asserts the expected billing path before every run (the `ANTHROPIC_API_KEY`-silently-wins gotcha, note §5 rule 1); lint `engine.billing_path_mismatch`; plan-window queueing (concurrency 1–2, stalls surfaced); spill-to-T2 only via explicit policy toggle with a recorded reason.
4. **Run provenance + telemetry** — every run record stamps engine/model/think-level/billing-path/sandbox-flags/session-id, integrated with DOC11's usage-telemetry and runtime-truth read-models; Inspector-renderable.
5. **EC integration** — SDK permission hooks as the EC policy-evaluator socket; delegation-egress hook: an external-agent invocation that carries memory content is an egress event (E0 §22 destination classes + `DelegationMFC`; DOC81 R2 send-time gate) — **bind by reference**; file-bus contract (commission in repo → agent runs against working dir → report to designated folder) as the durable exchange pattern.
6. **Failure/unhappy paths per contract** — auth expired/revoked (re-login flow, never silent API fallback), version drift, rate-limit stall, sandbox violation, network loss mid-run, orphaned sessions, report-not-written.
7. **Cross-doc obligations table** — DOC13 (cost rows), DOC12 (ACP seam if applicable), DOC20 (Engines panel), EC (hook contract), OP-A rows to create.
8. **Phase-2 note** — multi-principal rule (note §5 rule 3; DOC81 R-5): per-user auth or T2; never the architect's subscription.

## 3. Constraints

No-phantom: every contract/field/lint traces to the capability note, DOC11 R14/R15, E0/DOC81, or is flagged `OPEN_FOR_ARCHITECT_REVIEW` (≤5). Do not modify any existing file. Do not re-declare E0/DOC81/EC-owned contracts. Match DOC11's terminology (gateway, runtime truth, read-models, anti-ghost). Quality bar: A-grade, red-team-ready — a coding agent should be able to implement the adapter from your proposal without guessing.