Architecture & session-spec-verify Ledger

Ten Packages on
Pi & Pi Durable

Rebasing Umwelten onto @earendil-works/pi-ai, pi-coding-agent, pi-mcp, and pi-durable eliminated ~107,000 lines of bespoke cognition, provider wrappers, Vercel AI SDK adapters, and custom agent containers — leaving only what extends Pi.

52,823 workspace LoC (−67%) −247 npm packages removed 39/39 spec rules verified Run: 2026-11-21T03-05-00Z_9e9ff12-dirty
39/39
Spec Rules Passing
session-spec-verify
10
Acyclic Packages
zero circular seams
−93%
Habitat LoC Cut
59,492 → 4,099 on pi-durable
0
Vercel SDK Deps
raw models.stream() only
Interactive Slide Deck · 12 Slides
Building & Shipping Durable Client Agents
01 Stack 04 QuickBooks Tuning 06 Ontology 08 Client Env (D-11) 11 GCP Rollout 12 A2A Mesh
Presentation · End-to-End Architecture

From hand-tuned QuickBooks ontology to zero-secret GCP Client Environments

Walks through the two-plane Client Environment rethink (perimeter-gateway with client-local Mycel + credential-injecting HTTP/MCP proxy vs. zero-secret habitat-runtime), interactive ontology extraction, and A2A 1.0 service exposure.

01 — Workspace Package Matrix

What Pi owns vs. what each Umwelten package adds

Package Layer LoC What It Adds Beyond Pi Rebase Delta
@umwelten/pi Sensemaking & Pi Bridge 1,393 Installable pi-package extension (session search, promotion, /umwelten-explorations) + uncapped runPiTurn / runPiStructuredObject over models.stream() + Mycel wire. Replaced packages/core cognition, Stimulus, Interaction, and 19 custom provider wrappers with Pi builtinModels() + ~/.pi/agent/models.json.
@umwelten/sessions Sensemaking & Pi Bridge 8,980 Read-only session adapters for Pi JSONL v3, Pi Durable SQLite, Claude Code, and Cursor; Exploration projection; ripgrep search; FACTS.md / AGENTS.md promotion. Pi stores single-harness JSONL; Umwelten correlates across harnesses and promotes durable knowledge.
@umwelten/evaluation Benchmarking & Calibration 9,075 Declarative EvalSuite, VerifyTask, uncapped Zod JudgeTask, disk EvaluationCache, PairwiseRanker Elo, 5-dim combiner, and Jev Brier/RPS/ECE probability calibration. Calls @umwelten/pi runPiTurn directly — zero Vercel AI SDK dependencies.
@umwelten/habitat Durable Agents & Hosts 4,099 Host-agnostic DurableHabitat & multi-tenant HabitatHost over pi-durable Storage/ExecutionEnv, Owned/Mounted ToolTask path guards, Turn Fan-out, and Gaia provisioner. Cut from 59,492 LoC to 4,099 LoC (-93%) by delegating state, SQLite/Postgres journals, and tool loops to @earendil-works/pi-durable.
@umwelten/protocols Protocols & UI Resources 2,600 RemoteMcpClient preserving MCP Apps ui:// _meta.ui.resourceUri, mcp-serve server, and A2A 1.0 Agent Card + JSON-RPC adapters. Cut from 10,230 LoC to 2,600 LoC (-75%) by adopting @leocavalcante/pi-a2a and @earendil-works/pi-mcp.
@umwelten/mycel Token Exchange 11,850 Authenticated OpenAI-compatible Token Exchange with outbound Supplier WebSockets, Guarantee-filtered dispatch, and integer micro-dollar ledger. Orthogonal marketplace layer; consumed by @umwelten/pi over standard HTTP without package coupling.
@umwelten/supplier Local GPU Agent 3,820 Probes local Ollama, llama-swap, and vLLM capability + concurrency Headroom and dials outbound to a Mycel Exchange. Turns local Apple Silicon & DGX boxes into metered, Guarantee-tagged Pi endpoints.
@umwelten/substrate Shared Visualization 1,410 Zero-dependency canvas/topology primitives shared by the Mycel Exchange landing shell. Pure leaf package at the root of the Exchange subgraph.
@umwelten/cli Operator CLI 6,240 umwelten eval, sessions, models, supplier, and habitat subcommands. Focused strictly on multi-model evals, cross-harness sessions, Habitats, and Mycel.
umwelten Published Umbrella 3,356 Single publishable npm package bundling the CLI binary and public TypeScript entrypoints. Ships clean ESM dist without transitive Vercel AI SDK bloat (-247 npm packages).
02 — Architectural Decisions (docs/decisions.jsonl)

Ratified rebase & boundary invariants

D-1 2026-11-20

Replace the entire Vercel AI SDK stack with @earendil-works/pi-ai, pi-schema, pi-telemetry, and pi-mcp

Pi provides maintained multi-provider streaming, local llama.cpp/vLLM dialect controls, eval-free JSON Schema validation, telemetry, and Streamable HTTP MCP without bespoke AI SDK glue.

D-2 2026-11-20

Keep Pi Durable Habitat orchestration generic across Storage and ExecutionEnv rather than coupling to Cloudflare Workers

A generic Harness runs identically on laptops, single-process Node hosts multiplexing dozens of Habitats, containers, or Postgres without edge-isolate restrictions.

D-3 2026-11-20

Call pi-ai models.stream() directly instead of streamSimple() so benchmarks never receive a default maxTokens clamp

pi-ai's streamSimple() calls buildBaseOptions(), which always injects clampMaxTokensToContext() and would violate Umwelten's uncapped benchmark invariant.

D-4 2026-11-20

Project Pi JSONL trees and Pi Durable SQLite stores into Umwelten Explorations and package Umwelten tools as @umwelten/pi

Lets Pi Durable own live transactional transcripts and forks while Umwelten focuses on cross-session sensemaking, reflection, and evaluation.

D-5 2026-11-20

Enforce Owned vs. Mounted repository write guards via ToolTask hooks and preserve ui:// EmbeddedResources across MCP and A2A

Replaces custom file tool wrappers and FileTaskStore while keeping MCP-UI widgets intact for web rooms and UI-capable MCP hosts.

D-6 2026-11-20

Preserve Mycel's zero-core boundary, micro-dollar metering, and outbound Supplier dial-in protocol

Prevents dependency cycles and Postgres dependencies on GPU hosts while guaranteeing policy compliance and accurate billing on interrupted streams.

D-7 2026-11-20

Archive the legacy VitePress docs to docs-archive/ and adopt session-spec-verify for active specifications

Replaces drifted prose docs with cold-rebuild-complete, machine-validated specifications while deferring website redesign.

D-8 2026-11-20

Eliminate core/providers, custom Umwelten Pi provider shims, legacy AI SDK shims, schema/memory/rate-limit modules, subprocess runners, and custom MCP client

Removes every parallel Umwelten provider/schema/MCP/subprocess layer so Pi's native builtinModels() + ~/.pi/agent/models.json + pi-mcp + pi-durable own runtime plumbing while Umwelten focuses strictly on evaluations, session sensemaking, DurableHabitats, and Mycel.

D-9 2026-11-21

Eliminate packages/core, packages/ui, cognition/Stimulus/Interaction, legacy Docker Habitat, redundant unit tests, and pre-Pi examples

Focuses Umwelten strictly on what is not built into Pi — multi-model evaluations/Elo/Jev, cross-harness session Explorations and promotion, DurableHabitats on pi-durable + A2A 1.0, OAuth 2.1 mcp-serve, and the Mycel Token Exchange — cutting workspace size by ~78% and test runtime from 103s to 22s.

D-10 2026-11-21

Replace Docker-out-of-Docker Gaia orchestrator with single-container pi-durable GaiaHost

Multiplexing SQLite DurableHabitats in one process removes host Docker daemon privilege exposure and multi-image deploy complexity while preserving Caddy TLS ingress, comma-separated GAIA_API_KEY auth, per-speaker GAIA_JWKS_URL JWT isolation, and declarative /api/habitats persistence.

D-11 2026-11-24

Rethink GaiaHost as a two-container Client Environment with perimeter LLM/HTTP proxying and correlated audit tracing

Forces every LLM completion and external API/MCP call across a tamper-proof perimeter carrying (trace_id, habitat_id, speaker_id), preventing agent secret exfiltration even with bash tools enabled while giving clients complete wire-level auditability inside their own VPC.

03 — Live Verification Verdicts (2026-11-21T03-05-00Z_9e9ff12-dirty)

Every invariant & acceptance criterion checked against code and live runs

Verdict Spec Pack Rule ID Kind Verified Evidence
pass standards/per-speaker-agent-identity signed-speaker-grant invariant Verified in DurableHabitat.createA2ASurface per-(tenant,userId) conversation isolation (packages/habitat/src/durable/durable-habitat.ts) and durable-habitat.test.ts.
pass standards/per-speaker-agent-identity end-user-exchange-attribution invariant Verified in createMycelAI & LOCAL_AND_EXCHANGE_ENDPOINTS.mycel stamping X-Mycel-End-User (packages/pi/src/models.ts, models.test.ts, examples/mycel-e2e/run.ts).
pass standards/portable-agent-skills kebab-skill-identity invariant Verified .agents/skills/{spec-extract,spec-refactor,verify-deploy}/SKILL.md pass check-specs.ts.
pass standards/portable-agent-skills self-contained-skill-scripts invariant Verified check-specs.ts runs under node --experimental-strip-types with zero npm dependencies.
pass standards/uncapped-benchmark-generation no-default-output-token-cap invariant Verified in runPiTurn (packages/pi/src/models.ts) invoking raw models.stream() with maxTokens omitted unless explicitly set (models.test.ts).
pass standards/uncapped-benchmark-generation explicit-task-cap-only invariant Verified in packages/pi/src/models.test.ts (seenMaxTokens === [undefined, 250]).
pass exchange/mycel-and-suppliers hard-guarantee-and-capability-filtering invariant Verified in packages/mycel/src/dispatch.test.ts and dispatch-selection.test.ts.
pass exchange/mycel-and-suppliers integer-micro-dollar-boundary-metering invariant Verified in packages/mycel/src/metering/{counter.test.ts,balances.test.ts}.
pass exchange/mycel-and-suppliers acyclic-exchange-boundary invariant Verified in packages/pi/package.json and packages/supplier/package.json (zero @umwelten/mycel imports).
pass exchange/mycel-and-suppliers supplier-dial-in-liveness criterion Verified in packages/supplier/src/{serve-connection.test.ts,offers.test.ts,headroom.test.ts,discover.test.ts}.
pass exchange/mycel-and-suppliers mid-stream-balance-enforcement criterion Verified in packages/mycel/src/buyer/handler.test.ts and metering/counter.test.ts.
pass foundation/pi-model-runtime zero-vercel-ai-sdk invariant Verified zero AI SDK dependencies or imports across all 10 workspace packages and examples.
pass foundation/pi-model-runtime no-bespoke-provider-or-cognition-layer invariant Verified packages/core and packages/ui are completely removed; @umwelten/pi calls @earendil-works/pi-ai builtinModels() + models.json directly.
pass foundation/pi-model-runtime stream-error-fidelity invariant Verified in packages/pi/src/models.ts surfacing pi-ai event.error.errorMessage and assistantMsg.errorMessage verbatim.
pass foundation/pi-model-runtime multi-step-tool-and-structured-execution criterion Verified in packages/pi/src/models.test.ts and live EvalSuite (post-cut-pi-verify: 10/10 across mycel:deepseek/deepseek-v4.1-flash and mycel:z-ai/glm-5.3-flash).
pass foundation/pi-model-runtime local-runtime-dialect-controls criterion Verified llamaswap-nothink/llamabarn-nothink/ollama payload controls in packages/pi/src/models.ts and VllmAuthError in packages/supplier/src/discover.test.ts.
pass foundation/substrate-composition zero-dependency-substrate invariant Verified in packages/substrate/package.json and packages/substrate/src/*.test.ts.
pass foundation/substrate-composition foreign-component-sandbox invariant Verified in packages/substrate/src/isolation.test.ts and packages/habitat/src/ui-resources.ts.
pass foundation/substrate-composition transactional-component-lifecycle criterion Verified in packages/substrate/src/{component.test.ts,services.test.ts,loader.test.ts}.
pass foundation/substrate-composition dual-transport-ui-projection criterion Verified in packages/habitat/src/ui-resources.ts and durable-habitat.test.ts (ConversationUIResourcesDoc).
pass interfaces/protocols-and-extensions preserve-mcp-ui-embedded-resources invariant Verified in packages/protocols/src/mcp/client/remote.ts preserving ui:// EmbeddedResources in _uiResources.
pass interfaces/protocols-and-extensions no-custom-mcp-jsonrpc-client invariant Verified hand-rolled JSON-RPC MCP client is deleted; RemoteMcpClient delegates to @earendil-works/pi-mcp.
pass interfaces/protocols-and-extensions self-contained-published-cli invariant Verified pnpm -r build + node packages/umwelten/dist/cli/entry.js --help + packages/umwelten/src/manifest.test.ts.
pass interfaces/protocols-and-extensions durable-a2a-v1-endpoint criterion Verified in packages/habitat/src/durable/durable-habitat.test.ts and live examples/durable-habitat/host.ts (TASK_STATE_COMPLETED over A2A 1.0).
pass interfaces/protocols-and-extensions installable-pi-extension-package criterion Verified in packages/pi/src/extension.test.ts and live examples/pi-extension/demo.ts.
pass orchestration/durable-habitats mounted-repo-read-only-boundary invariant Verified in packages/habitat/src/durable/durable-habitat.test.ts (Owned R/W allowed, Mounted R/O blocked).
pass orchestration/durable-habitats zero-container-api-habitats invariant Verified in packages/habitat/src/durable/durable-habitat.ts (CodingTools omitted when env is undefined).
pass orchestration/durable-habitats sqlite-recovery-and-zero-copy-fork criterion Verified in packages/habitat/src/durable/durable-habitat.test.ts.
pass orchestration/durable-habitats multiplexed-host-eviction-and-wake criterion Verified in packages/habitat/src/durable/durable-habitat.test.ts and HabitatHost.createHttpHandler.
pass orchestration/durable-habitats durable-turn-fanout-and-cron criterion Verified in packages/habitat/src/durable/durable-habitat.test.ts (ConversationAnnotationsDoc + HabitatCronTask).
pass orchestration/evaluation-and-ranking watchdog-abort-propagation invariant Verified in packages/evaluation/src/evaluation/llm-eval/index.test.ts and EvalSuite taskAbort signal forwarding.
pass orchestration/evaluation-and-ranking cached-deterministic-and-judged-suites criterion Verified in packages/evaluation/src/evaluation/suite.test.ts and live post-cut-pi-verify EvalSuite.
pass orchestration/evaluation-and-ranking elo-pairwise-tournaments criterion Verified in packages/evaluation/src/evaluation/ranking/pairwise-ranker.test.ts.
pass orchestration/evaluation-and-ranking calibrated-probability-judgments criterion Verified in packages/evaluation/src/evaluation/judgment/{judgment.test.ts,metrics.test.ts,pilot.test.ts} and examples/jev/run.ts.
pass orchestration/evaluation-and-ranking combined-dimension-reporting criterion Verified in packages/evaluation/src/evaluation/combine/ and examples/model-showdown/.
pass orchestration/explorations-and-reflection non-destructive-source-ingestion invariant Verified in packages/sessions/src/adapters/pi-durable-adapter.ts (mode: read-only sqlite_master precheck) and pi-durable-adapter.test.ts.
pass orchestration/explorations-and-reflection pi-and-durable-exploration-projection criterion Verified in packages/sessions/src/{adapters/pi-adapter.test.ts,adapters/pi-durable-adapter.test.ts,projection/projection.test.ts} and examples/pi-extension/demo.ts.
pass orchestration/explorations-and-reflection ripgrep-session-search criterion Verified in packages/sessions/src/search/searcher.test.ts.
pass orchestration/explorations-and-reflection reflection-promotion-routing criterion Verified in packages/pi/src/extension.test.ts and examples/pi-extension/demo.ts (FACTS.md written).