Framework replacement as an architectural test
Current implementation: Rig 0.44 + Rust on main.
Historical implementation: NVIDIA NeMo Agent Toolkit 1.9, preserved at nat-1.9-final.
Question: what survived when the framework was actually replaced?
This section used to compare two live branches. That experiment is over: the Rig implementation became canonical and the NAT implementation was frozen as history. The result is more useful than the original comparison because the repository itself now demonstrates the claim Part I has been making all along:
Frameworks are replaceable; trust boundaries are architecture.
The migration changed the agent runtime, language, container, guardrail implementation and internal execution model. It did not move the boundaries that decide identity, capability, authority, mutation, audit or evidence.
Same architecture, different framework
flowchart TB
A["Architecture<br/>identity · capability · policy · authority · evidence"]
N["Historical implementation<br/>NAT 1.9 · Python"]
R["Current implementation<br/>Rig 0.44 · Rust"]
P["Stable boundaries<br/>gateway · service contract · MCP · PostgreSQL · approvals · evaluation · OTel"]
A --> N
A --> R
N --> P
R --> P
The educational question is no longer hypothetical:
Can you still recognise the architecture after replacing the framework?
If the answer depends on a framework's class names or configuration vocabulary, you are looking at an implementation detail rather than the architecture.
What stayed invariant
The migration held these properties constant:
| Invariant | Stable owner |
|---|---|
| Browser identity is never trusted directly | Rust gateway + Keycloak |
| The agent receives trusted identity outside model-visible text | gateway → agent contract |
| The model can request only granted capabilities | configured MCP tool list |
| The agent has no direct database route | network topology |
| Tool arguments cross deterministic validation before execution | agent policy + MCP schemas |
| State changes require a human-bound approval | agent approval gate + MCP verifier |
| Mutation policy is re-checked at the point of mutation | MCP server + PostgreSQL transaction |
| Every request is observable without exporting credentials | OpenTelemetry boundary |
| Behaviour is measured with source-controlled cases | evaluation datasets/scorers/gates |
The agent-service contract is the most concrete expression of this portability. The gateway, UI and evaluator speak to an agent service, not to NAT or Rig.
What changed
Replacing NAT with Rig/Rust moved several concerns from framework integration or configuration into ordinary application code.
Agent loop
NAT provided a high-level ReAct workflow. Rig provides a smaller model/tool runner. The current agent drives that runner explicitly and exposes its own execution state:
Received → ScreeningInput → Running ⇄ AwaitingApproval
│ │
▼ ▼
Blocked Completed / Failed / Cancelled
The state model is not valuable because it is Rust. It is valuable because the application names states that matter to its security and lifecycle rather than relying on framework-internal state.
Tool authority
The current implementation centralises model-proposed calls through a
deterministic ToolPolicy. The model proposes a tool and arguments; software
decides whether the call is allowed, approval-gated or denied. Executors check
the policy again, and the MCP service remains authoritative for mutation.
This is the core distinction Part I teaches:
The model proposes; deterministic software decides.
Guardrails
The retired NAT version used NeMo Guardrails and Presidio. The current Rust agent keeps deterministic input rules, a fail-closed semantic self-check, streaming secret blocking and deterministic structured-PII recognisers. This is not perfect parity: the Rust PII detector is narrower than contextual NER. That difference is documented rather than hidden.
The important invariant is that guardrails still do not become authorization. They can refuse content; they cannot grant a capability the deterministic policy does not allow.
Observability
The NAT implementation needed framework-specific integration to join runtime,
Guardrails and application spans into one request trace. The Rust implementation
uses one Rust tracing/OpenTelemetry tree, with Rig spans nested under the
request root. OpenTelemetry remains the boundary, so the trace backend can
change independently of the agent framework.
Packaging
The old NAT agent carried Python, NAT, Guardrails and Presidio. The current agent is a small distroless Rust image. That is a useful operational difference, but it is not the architectural lesson: a smaller image does not make an agent safe. The same trust boundaries are still required.
What the migration deliberately did not prove
A framework replacement is evidence of portability, not proof that every implementation is equivalent.
The current implementation has documented differences and gaps, including:
- deterministic PII recognition is narrower than contextual NER;
workflow.request_timeout_secondsis parsed but not currently enforced;- pending approvals live in memory and are lost on restart;
- only Ollama with
qwen3:8band a fake OpenAI-compatible endpoint are explicitly verified in the current implementation; - live model evaluation remains probabilistic and is intentionally not a deterministic CI gate.
See Limitations and the full framework migration record.
Read the migration as evidence
The imported Framework migration walks concern by concern through what NAT provided, what the Rust implementation provides, and which behaviours became stricter, narrower or simply different. It is the engineering record of the replacement.
Then read Agent internals, which walks through the canonical Rust implementation: model calls, the Rig loop, MCP discovery, schema enforcement, tool policy, streaming, guardrails, identity, execution state, approvals and tracing.
Together they teach two different things:
- Migration record: identify the architecture by what had to survive.
- Internals: see how one current implementation realises those properties.
Exercises
- Name an invariant without framework vocabulary. Choose identity, tool authority, approvals or observability. Describe the guarantee without saying NAT, Rig, middleware, hook or runner. Then point to the current code that enforces it.
- Classify a difference. Read one row of the migration record. Is the Rust behaviour equivalent, stricter, narrower or simply different? Which changes would be acceptable in your own migration?
- Replace another boundary. Imagine replacing Rig with another framework or a managed runtime. List the tests you would keep unchanged before writing any adapter code.
- Distinguish safety from implementation preference. Pick one advantage of the Rust implementation—explicit state, image size, stricter schemas—and explain why it is useful without claiming that Rust itself provides the security property.
The historical implementation is still reproducible
The exact pre-migration NAT tree is preserved at
nat-1.9-final.
The legacy/nat branch points at the same final NAT commit for discoverability.
Use the immutable tag when reproducing historical behaviour.
The current main should be used for all new learning and development. There
is no longer a parallel rust-agent content branch.
Why this matters beyond Part I
Every later CognoKratos project depends on the same distinction between a property and the technology used to realise it. Sophos changes the runtime model. ETF Research changes the decision problem. Arktos moves cryptographic authority into a separate capability service. Tauros expresses domain authority through Ash policies and state machines.
The Part I migration is the smallest concrete example of the general rule:
Choose implementations for the properties they provide, but design the boundaries so implementations can change.