ADR: Agentic MLOps control plane for Apizr 0.5.0
This is a proposed architecture for Apizr 0.5.0, which is in development. Apizr 0.4.6 is the published release. Architecture proposal #370.
The first implementation defines four versioned contracts for experiment requests, operator authority, approvals and decisions. Its Python API validates proposals offline and returns a decision bound to the request and operator policy. Durable jobs, execution through a controller and agent-facing MCP operations remain planned. Experiment request contracts #415.
Context
Apizr 0.4.6 compiles Python capabilities into governed REST and MCP services and can record experiments as immutable evidence. Agents (LangGraph, Codex, Claude and similar) can already read that evidence through a read-only MCP surface. They cannot yet propose a bounded training or evaluation run, and Apizr has no durable record of such a run between its approval and its outcome.
The risk in closing that gap is giving an agent a general command runner. The 0.5.0 goal is the opposite: an agent proposes a typed, declarative request; Apizr validates it against operator policy, admits or refuses it, records immutable evidence, and delegates execution to a separately qualified worker.
What 0.4.6 already provides
These surfaces are reused, not replaced:
| Surface | Role in 0.5.0 |
|---|---|
| Experiment Plan and Run (v1, v2), immutable store, history, diff | Canonical evidence. New records reference existing identities instead of duplicating them. |
| Read-only MCP tools and opt-in delivery tools | Existing agent entry point; new operations stay opt-in and policy-gated. |
| Analysis session and operator policy | Pattern for operator-owned authority that the agent cannot choose. |
| Execution backends (direct, local process, OCI) and the subprocess guard | Qualified workers. The controller delegates to them and never spawns processes itself. |
Schemas under specs/ |
Independent contract versioning; schema versions do not follow the package version. |
Decision
Apizr becomes an agent-native control plane with four separately owned domains. Each concern has exactly one owner.
| Domain | Owner | Responsibility | Not responsible for |
|---|---|---|---|
| Agent orchestration | The agent framework (LangGraph, Codex, Claude, others) | Planning, conversation, choosing what to propose | Authority, policy, evidence, execution |
| Control, admission and evidence | Apizr | Request validation, approval state, admission, job lifecycle, immutable evidence, refusal codes | Running the workload, hosting a model registry |
| Tracking and registry | Optional MLflow, or any external system, by reference | Metrics, artifacts, model registry the operator already runs | Admission decisions; Apizr records references, never trusts them as proof |
| Training and serving backends | Qualified workers (local first; OCI; later others) | Executing an admitted job, serving an approved model | Deciding what is admitted |
Lifecycle and ownership
Each object has one writer and a fail-closed transition table. Unknown fields, capabilities or constraints are refused, never ignored.
| Object | Created by | Authoritative writer | Terminal states |
|---|---|---|---|
| Experiment request | Agent (proposal only) | Apizr validates; the agent cannot mutate it afterwards | refused, expired |
| Approval | Operator or operator-owned policy | Apizr | granted, denied, revoked |
| Job | Apizr, from an approved request | Apizr controller | succeeded, failed, cancelled |
| Evaluation | Worker output, verified by Apizr | Apizr | recorded, rejected |
| Model reference | Operator or Apizr from a verified run | Apizr (immutable reference) | superseded |
| Promotion decision | Operator | Apizr | candidate, rejected |
| Serving proposal | Agent (proposal only) | Apizr, then operator approval | approved, refused |
A job also has a non-terminal unknown state. After a restart the controller
reconciles in-flight jobs against the worker. It never marks a job succeeded
without the corresponding Run evidence.
Trust boundaries
- The agent is untrusted. It cannot choose the policy path, credentials, project root, executable, network permission or budget, and it cannot approve its own request.
- Apizr and the operator policy are the trusted authority. Approval is a separate transition from proposal.
- The worker is trusted only for the workload it was qualified for. Resource controls (timeout, memory, CPU/GPU, network) are enforced only where the backend proves they are available; otherwise the request is refused rather than silently weakened.
- External systems (MLflow, model hubs) are referenced by immutable identity. A model is referenced by revision and digest, never by a mutable name.
Sequence: propose, admit, execute
sequenceDiagram
autonumber
participant A as Agent (untrusted)
participant M as Apizr MCP/CLI
participant C as Apizr control plane
participant O as Operator policy
participant W as Qualified worker
participant E as Evidence store
A->>M: propose ExperimentRequest (declarative)
M->>C: validate offline
alt unknown field, capability or broader authority
C-->>A: structured refusal code
else valid
C->>E: record request identity
C->>O: ask for approval
O-->>C: granted or denied
alt denied
C-->>A: refusal, nothing executed
else granted
C->>E: record admitted job
C->>W: delegate exact approved workload
W-->>C: progress and outcome
C->>E: write Run evidence and job outcome
C-->>A: job reference and result summary
end
end
Sequence: restart and reconciliation
sequenceDiagram
autonumber
participant C as Apizr controller
participant S as Job store
participant W as Qualified worker
participant E as Evidence store
C->>S: load jobs in running state
loop each in-flight job
C->>W: query actual state
alt worker confirms completion with Run evidence
C->>E: link existing Run, mark succeeded or failed
else worker has no record
C->>S: mark unknown, require explicit decision
end
end
Reference journey: OuterSpace Code Retriever
The release is qualified with a genuine open-source Code Retriever research model. The path is: trusted experiments, an agent-proposed bounded experiment, verified execution and evaluation, an explicit model-candidate decision, then REST/MCP inference.
The Code Retriever research code and model live in an external repository. Apizr OSS ships only the generic engine: contracts, controller, evidence, references and serving. The model is consumed by immutable reference. Heavy ML dependencies stay out of the core wheel, and neural retrieval is an optional provider.
Alternatives and tradeoffs
- Give agents a command or notebook runner. Fastest to integrate, but it removes the admission boundary and every 0.4.6 guarantee. Rejected.
- Build a general agent runtime inside Apizr. Duplicates mature frameworks and widens the attack surface. Rejected; agents stay external.
- Make MLflow the system of record. Convenient, but evidence would depend on a mutable external service and a mandatory dependency. Rejected; MLflow is an optional reference target.
- Couple the controller to Kubernetes or a GPU vendor. Locks the core to one platform. Rejected; one local worker first, behind a backend extension point.
Compatibility with 0.4.6
- Existing Plan and Run v1/v2 records, stores and history stay readable without migration. New schemas are independently versioned and reference existing identities.
- Existing plugins and MCP tools keep their names and behavior. New operations are additive and opt-in.
- A 0.5.0 store opened by 0.4.6 must be refused or ignored, not misread.
- No version bump or implementation is part of this ADR.
Non-goals
- No arbitrary shell or process access for agents.
- No general agent runtime or workflow engine.
- No autonomous production deployment; promotion and serving require explicit operator decisions.
- No broad automatic code recomposition across projects. Cross-project slicing is a research spike (#381) with a ship, narrow or defer decision, not a release promise.
- No claim that a resource control is enforced when the backend cannot prove it.
Consequences
- Seven follow-up contracts can be built independently because ownership is fixed: requests and approvals (#371), controller and jobs (#372), idempotency and recovery (#373), evaluation (#374), model references (#375), promotion (#376) and serving (#377), plus the MCP surface (#378).
- Every new refusal is a structured code, so agents can react without parsing prose.
- Operators carry the approval decision. That is intentional friction; it keeps authority out of the agent.
- Adversarial security testing (#382) runs against each wave rather than once at the end.