TheFocus.AI · Internal Architecture Walkthrough 01 / 12
Architecture + Delivery Playbook

Building & Shipping Durable Client Agents

How we take a client engagement from a hand-tuned QuickBooks sandbox to a versioned domain ontology, isolate it inside a two-plane Client Environment on GCP with proxy-level audit & tracing, and expose it over A2A 1.0.

01 · Connect & Tune

Wire QuickBooks safely through a credential proxy, sit with the SME, fork tricky turns.

02 · Build Ontology

Turn tribal accounting definitions into GLOSSARY.md, rules, and probes.

03 · Verify & Deploy

Lock invariants via verify-deploy; deploy the two-container Client Env to GCP.

04 · Expose via A2A

Serve traced A2A 1.0 + /.well-known/agent-card.json to Pi, Slack, and peers.

High-Level Architecture 02 / 12

Four Layers, Split Cleanly Across a Trusted Client Perimeter

Rethinking GaiaHost as a Client Environment: LLM + HTTP proxying, credentials, and wire-level audit live on the perimeter — never inside the agent runtime.

LAYER 4 · PERIMETER & PROTOCOLS (@umwelten/protocols, Client Gateway) A2A v1.0 Auth & Trace Minting · Hybrid HTTP/MCP Egress Proxy · Audit Ledger LAYER 3 · ZERO-SECRET HABITAT RUNTIME (internal: true network) DurableHabitat (node:sqlite) · Owned/Mounted Repo Guards · Cron Wakes Turn Fan-out Probes · Session Explorations & FACTS.md · Zero Internet Route LAYER 2 · CLIENT-LOCAL MYCEL (@umwelten/mycel, @umwelten/supplier) Perimeter LLM Proxy & Wire Tracer · Micro-Dollar Metering · Local GPU Dial-In LAYER 1 · FOUNDATION (@earendil-works/pi-ai & @umwelten/pi) Uncapped models.stream() · Structured Outputs · Frontier Cloud + Local GPUs

Two Planes, Zero Shared Secrets

The Perimeter Gateway holds keys, routes LLM/HTTP traffic, and logs traces; Habitat Runtime has no direct internet and zero upstream credentials.

Correlated Wire Audit

Every inbound A2A request mints one trace_id carried across Mycel LLM completions and QuickBooks/MCP egress calls.

Testable Offline First

Swap real providers for fauxProvider + mock upstreams locally (`examples/client-env/`) to test ACLs, redaction, and traces in milliseconds.

Runtime Foundation 03 / 12

Why DurableHabitat Beats Stateless Agent Scripts

Built directly on @earendil-works/pi-durable's transactional Harness and Node 24's built-in node:sqlite.

What Usually Breaks in Production

Typical Ephemeral Agent Wrapper

  • In-memory chat arrays lost on deploy or process crash.
  • Unbounded workspace file access when tools are enabled.
  • No safe way to branch from Turn 7 and test a prompt fix.
  • Cron jobs live in external scripts disconnected from session context.
  • Single global conversation leaks across callers or channels.
What DurableHabitat Gives Us

Transactional Habitat Store (habitat.sqlite)

  • Crash-safe resume: Commit turns atomically; harness.resume() recovers cleanly across restarts.
  • Zero-copy fork(entryId): Test fixes against real client state without mutating history.
  • Scoped execution: Omit ExecutionEnv (API-only) or enforce Owned R/W vs. Mounted R/O roots.
  • Armed sleep/wake: Durable HabitatCronTask stays scheduled even when idle Harnesses evict after 10m.
Storage Engine
node:sqlite

Zero external DB required per agent.

Idle Eviction
10 min

Cold on disk, auto-reopened on request.

Post-Turn Probes
Turn Fan-out

ConversationAnnotationsDoc flags.

Human Surfaces
ui:// DataPart

Rich HTML without bloating LLM context.

Part 01 · Client Delivery Walkthrough 04 / 12
01

Connect QuickBooks, Hand-Tune & Build the Ontology

Walkthrough scenario: a client wants an internal Finance & Ops agent over their QuickBooks Online ledger — answering A/R questions, spotting uncategorized spend, and preparing month-end variance briefs.

Step 1 · Safe Boundary

QuickBooks OAuth 2.0 stays in mcp-serve / bearer proxy — zero secrets inside the Habitat.

Step 2 · Hand-Tuning

Engineer + Controller test live queries via Pi, fork edge cases, promote FACTS.md.

Step 3–4 · Ontology + Gate

Commit GLOSSARY.md + GL mappings, extract specs, freeze Evals before GCP.

Step 01 · Hybrid Credential & Audit Proxy 05 / 12

Hybrid Proxy: Named Egress Routes + Correlated LLM Tracing

The Habitat holds zero QuickBooks OAuth tokens or LLM keys — every request crosses the Perimeter carrying x-trace-id.

UNTRUSTED HABITAT RUNTIME QuickBooks DurableHabitat • Holds ONLY scoped habitat token • Calls /egress/quickbooks/* + /llm/v1 • Optional HTTP_PROXY for CodingTools Zero direct internet · Zero secrets HYBRID HTTP/MCP PROXY + VAULT Named /egress/quickbooks + MCP Routes Injects Intuit OAuth · GET-only ACL · Scrubs leaks + Optional CA forward proxy when bash runs CLIENT-LOCAL MYCEL EXCHANGE Injects LLM Key + Meters Micro-Dollars Captures full prompt/tool/completion trace UPSTREAM DATA + AUDIT QuickBooks Online Read-only Invoices / A/R / P&L CORRELATED LEDGER traces.jsonl + Mycel trace_id joins LLM + HTTP spans

1. Hybrid Egress Control

Named /egress/quickbooks & /egress/mcp routes enforce GET-only ACLs with zero TLS CA setup; optional CA forward proxy covers shell tools.

2. Wire-Level Traceability

Even if the agent stays silent, the proxy records every URL queried, method blocked (403), secret scrubbed, and micro-dollar spent.

3. ui:// Keeps Context Slim

Large 200-row aging schedules travel in _uiResources for the human while the LLM receives a 20-token summary.

Step 02 · Interactive Hand-Tuning 06 / 12

Hand-Tune with the Client SME Before Automating Anything

Sit next to the bookkeeper using pi + DurableHabitat: turn messy edge cases into durable memory, not one huge brittle prompt.

Turn 1 · Probe

Run Real Questions

"What was net SaaS margin in Q3 excluding AWS pass-through?" Watch real tool queries against sandbox/R-O QBO.

Turn 2 · Spot Drift

Catch Domain Quirks

Agent treated Account 4120 ("Setup Fees") as recurring ARR or missed vendor alias AMZN MKTP.

Turn 3 · Fork & Compare

fork(entryId) A/B

Fork right before the mistake. Test refined instructions or swap frontier vs. local models cleanly.

Turn 4 · Promote

PromotionRouter

Distill confirmed rules with umwelten_promote_knowledge straight into FACTS.md & AGENTS.md.

Real Session Beat → Promoted Knowledge

Session Discovery: Customer "Acme Corp (Legacy)" and "Acme Holdings LLC" share one parent billing contract in QBO notes, and GL 6410 is reimbursable client hardware — never include in internal COGS.

umwelten sessions explorations
→ FACTS.md + docs/ontology/
Step 03 · Domain Ontology 07 / 12

Crystallize Tribal Accounting Knowledge into a Mounted Ontology

Raw QuickBooks tables do not know how the client defines ARR, COGS, or entity rollups. Version that meaning in Git.

RAW QUICKBOOKS ENTITIES Account (4000–6999) Customer & SubCustomer Vendor (raw bank memos) Invoice + Payment + Class Ambiguous names, legacy codes, unmapped pass-through lines. DISTILL MOUNTED R/O REPO: client-finops-ontology/ GLOSSARY.md Canonical definitions: Booked ARR vs Recognized Rev ontology/gl-buckets.json Exact QBO Account IDs -> COGS / OpEx / Pass-Through ontology/entity-aliases.yaml Parent customer rollups & canonical vendor map docs/adr/ + checkbooks/ Signed policy decisions & close verification steps Protected by createRepoScopeExtension (R/O)
"The model is interchangeable. The versioned client ontology and deterministic checks running alongside durable state are the real asset."

Mounted Read-Only Guard

The Habitat can always read updated rules from /ontology, but write/edit calls are rejected so runtime chats never silently corrupt client policy.

Automatic Drift Detection

TurnAnnotationProbe inspects every completed turn and flags new unmapped GL codes or split invoices in ConversationAnnotationsDoc for human review.

Step 04 · Spec & Verification Gate 08 / 12

Graduate Prototype Sessions via spec-extract & verify-deploy

Turn conversation discoveries and SME quirks into verifiable contracts before pushing a container to GCP.

1 · Extract Intent & Rules

spec-extract

Distills code diff + conversation transcript into modular packs:

  • docs/specs/agent/quickbooks-ops.md
  • [zero-secret-habitat-runtime] invariant
  • [perimeter-correlated-audit-trace]
  • docs/decisions.jsonl (D-1..N why-log)
2 · Freeze Edge Cases

EvalSuite + Matrix

Turns gnarly client scenarios into repeatable regression checks:

  • Accrual vs. cash cutoff test tasks
  • Pass-through GL exclusion accuracy
  • Benchmark fable vs. hydrogen vs. local qwen4
  • Zero-cost offline fauxProvider contract gate
3 · Gate Release

verify-deploy

No green verdict from prose — proves every invariant with live & sandbox checks:

  • Mode 1: read-only SQLite + trace ledger audit
  • Mode 2: 403 egress block + secret scrub drill
  • Writes immutable docs/runs/<ts>_<sha>/verdicts.jsonl
pnpm run specs:check && pnpm exec vitest run specs:check PASS · Immutable Audit Written to docs/runs/
Part 02 · Client GCP & A2A Ecosystem 09 / 12
02

Deploy the Client Environment to GCP & Expose via A2A 1.0

Two containers on an internal: true Docker network inside the client's GCP VM: a trusted Perimeter Gateway (dedicated Mycel LLM tracer + Hybrid HTTP/MCP proxy + secrets + audit ledger) isolating a zero-secret Habitat Runtime.

Step 05 · GCP Client Environment Topology 10 / 12

Two-Container Client Environment Inside Client GCP

habitat-runtime sits on an internal: true network with zero internet route and zero secrets; perimeter-gateway owns Mycel + proxies + audit.

CLIENT GCP PROJECT · GCE VM (Caddy TLS · 4G swap · Ops Agent -> Cloud Monitoring · Traces stay in /opt/client-env) CONTAINER 1 · perimeter-gateway (HOLDS SECRETS + INTERNET) Ingress Auth (JWT/Bearer) -> mints x-trace-id Client-Local Mycel LLM proxy + micro-$ tracer Hybrid HTTP/MCP Proxy Named + optional CA forward Unified Audit Ledger (/opt/client-env/audit/traces.jsonl) Correlates a2a.inbound -> llm.completion -> http.egress internal: true NO INTERNET CONTAINER 2 · habitat-runtime DurableHabitats • ZERO LLM or SaaS secrets • Only scoped habitat token • SQLite: /opt/client-env/data • Mounted R/O /ontology • Idle evict + armed crons Calls /llm/v1 + /egress/* only OUTBOUND INFERENCE Vertex · Anthropic OpenAI · GPU Suppliers OUTBOUND SAAS / MCP QuickBooks · MCP Credentials injected here

Zero-Secret Execution Plane

Even with CodingTools shell enabled, habitat-runtime has no route past the Docker internal net and zero Intuit or Anthropic keys in env.

Complete Client Auditability

Client-local Mycel + HTTP proxy log every prompt, completion, QuickBooks query, and blocked verb under one shared trace_id.

Safe CI/CD Rollback

redeploy.sh snapshots habitat:previous, verifies /health + 401 + A2A Card + trace write, and rolls back automatically on failure.

Step 06 · Traced A2A 1.0 Ecosystem Exposure 11 / 12

One Verified & Audited A2A 1.0 Endpoint Powers Every Consumer

Inbound POST /a2a authenticates at the perimeter, mints x-trace-id, dispatches to habitat-runtime, and records the full tree.

TRACED A2A 1.0 PERIMETER QuickBooks Client Env /.well-known/agent-card.json POST /a2a (jwt+bearer -> trace_id) • Per-(tenant, userId) SQLite isolation • Traceable LLM + QBO spans per task • Text answer + ui:// DataPart cards 1. Internal Analysts & Engineers (Pi CLI) ~/.pi/a2a/agents.json -> /a2a send quickbooks · a2a_send + live progress widget 2. Peer Habitats (CFO Forecast · RevOps · Audit Viewer) createA2ATools({ self }) · directional peer bearer tokens · trace_id propagated 3. Client Portals & Slack / Chat Surfaces @leocavalcante/pi-a2a/client · OIDC JWT speaker identity · renders ui:// cards 4. MCP-Only Hosts (Cursor · Claude Desktop) Thin A2A -> mcp-serve Bridge exposing skills as MCP tools + EmbeddedResource
Full forensic trail for every caller: click any A2A taskId to inspect the exact Mycel model cost, prompt, and QuickBooks API spans it triggered.
Summary · Repeatable Delivery Cadence 12 / 12
From Prototype to Production

The 5-Day Client Agent Playbook

Day 1 · Connect

Zero-Secret Boundary

Wrap QuickBooks in hybrid OAuth MCP / bearer proxy; verify 403 & response scrubbing.

Days 2–3 · Ontology

Tune with the SME

Sit with Finance, fork() wrong answers, lock GLOSSARY.md + GL maps + probes.

Day 4 · Spec Gate

Lock Invariants

Run spec-extract, freeze QBO edge cases in EvalSuite, pass verify-deploy Mode 2.

Day 5 · GCP & A2A

Client Env + Mesh

Deploy two-container Client Env (Mycel + HTTP proxy + zero-secret runtime) on GCE, hand out A2A Card.

Try It Locally Today

Client Env demo: pnpm run demo:client-env · Multi-A2A: pnpm run demo:multi-a2a · Prompt Labs: examples/labs/README.md

Decision D-11 · Deploy Ref: deploy/gaia/README.md
All Slides (Click to Jump · Press Esc to Close)