Files
aji/docs/spec/14-agent-efficiency.md
T
dev 72192c2331 spec: agent efficiency objectives and evaluation protocol
- spec 14: Model Capability Compression, design objectives (correctness
  externalization, small semantic surface, explicit semantics, local
  reasoning, machine repairability, deterministic feedback, bounded
  context / Agent Reference Bundle), economic objective, design review
  requirement, hypotheses H1-H6, non-goals, anti-overfitting rule
- docs/evaluation/protocol.md: Agent Language Evaluation Protocol 0.1
  (tasks T01-T10, maintenance and seeded-bug benchmarks, metrics,
  statistics, stages A-E, success and falsification criteria)
- docs/evaluation/README.md: integrity rules, stage readiness
- RFC process: mandatory Agent complexity impact section
- AGENTS.md: overarching objective and anti-overfitting rule
- plan: evaluation track E0-1..E-1; P8-7 integrates ajid with the
  scaffold; conformance plan points to the protocol
2026-10-04 15:36:32 +03:00

425 lines
9.4 KiB
Markdown

# 14. Agent Efficiency and Model Capability Compression
Status: Normative draft (design objectives)
Applies to: Aji language, AIR, verifier, runtime and agent tooling
This file states design objectives that every other part of the specification, every RFC and every tool is measured against. The empirical protocol that tests them is [`../evaluation/protocol.md`](../evaluation/protocol.md).
## 1. Motivation
Aji is designed for software produced and maintained primarily by AI agents.
Traditional systems languages require the programming agent itself to perform a large fraction of reasoning about:
- ownership;
- lifetime;
- aliasing;
- initialization;
- resource state;
- concurrent access;
- authority;
- side effects;
- failure paths;
- platform behavior.
Aji deliberately moves part of this reasoning from the model into the language, verifier and deterministic runtime.
The project therefore has an additional design objective:
> Aji SHOULD reduce the minimum model capability required to produce correct systems software.
A smaller or less capable model using Aji should be able to approach the correctness of a substantially stronger model using a conventional systems language.
This property is called **Model Capability Compression**.
## 2. Core hypothesis
The Aji project is based on the hypothesis that:
```text
model reasoning
+
language constraints
+
verifier reasoning
+
runtime guarantees
=
effective engineering capability
```
Aji attempts to increase the contribution of:
```text
language constraints
verifier reasoning
runtime guarantees
```
so that less reasoning is required from the model itself.
The intended result is:
```text
weaker model + Aji
≈
stronger model + conventional language
```
for a useful class of systems-programming tasks.
This is an empirical objective and MUST be validated experimentally.
## 3. Design objectives
### 3.1 Correctness externalization
Properties that can be checked mechanically SHOULD not depend on the model remembering them.
Examples:
```text
memory lifetime
initialization
bounds
resource linearity
capability use
effects
task lifetime
data races
atomic ordering constraints
```
The preferred design is:
```text
agent proposes
verifier decides
```
rather than:
```text
agent must reason perfectly
```
### 3.2 Small semantic surface
Aji SHOULD minimize the amount of language semantics an agent must understand simultaneously.
New language features require justification not only in terms of human ergonomics or runtime performance, but also in terms of additional reasoning burden placed on agents.
A feature SHOULD NOT be added when the same capability can be represented through a small combination of existing primitives without materially harming correctness or performance.
### 3.3 Explicit semantics
Hidden behavior increases the reasoning requirement of the model.
Aji therefore prefers:
```text
explicit allocation
explicit move
explicit borrow
explicit resource close
explicit effects
explicit capabilities
explicit synchronization
explicit failure edges
```
over implicit runtime behavior.
### 3.4 Local reasoning
Whenever practical, program validity SHOULD be decidable from local information.
Preferred verifier properties include:
```text
bounded analysis
stable diagnostics
explicit state transitions
local ownership rules
explicit CFG edges
explicit resource state
```
A language feature that requires large-scale inference across the whole program SHOULD justify that complexity.
### 3.5 Machine repairability
Diagnostics are an API consumed by agents.
Every verifier error SHOULD expose:
```text
stable error code
error category
affected value
instruction
source location
relevant previous state
expected state
machine-readable details
```
An agent SHOULD NOT need to infer a semantic error by parsing human prose.
### 3.6 Deterministic feedback
Agent development loops SHOULD be reproducible.
Where possible:
```text
same program
same input
same grants
same seed
same execution profile
same schedule record
```
MUST produce the same observable result.
This reduces the amount of probabilistic debugging the model must perform.
### 3.7 Bounded context requirement
Aji SHOULD be usable effectively without requiring the entire ecosystem to be loaded into the model context.
The project SHOULD maintain a minimal **Agent Reference Bundle** containing:
```text
core language rules
AIR instructions
verifier rules
diagnostic registry
standard intrinsic signatures
feature registry
```
The size of this bundle MUST be measured for every major language version.
Growth of the Agent Reference Bundle is treated as a language complexity metric.
## 4. Model Capability Compression
Model Capability Compression exists when a lower-capability model using Aji reaches the quality of a higher-capability model using another systems language.
Example:
```text
Mid model + Aji
>=
Strong model + Rust
```
under the same language-neutral task specification and acceptance tests.
The project MUST NOT claim Model Capability Compression based on individual examples.
It must be demonstrated across a held-out benchmark suite and multiple independent runs.
## 5. Economic objective
Aji also targets lower:
```text
cost per correct implementation
```
and:
```text
cost per correct modification
```
Cost includes at minimum:
```text
model inference
agent retries
verification iterations
test iterations
tool invocations
```
Hardware execution cost MAY be reported separately.
The important metric is not cost per generated token.
The important metric is:
```text
total cost / accepted solutions
```
including failed attempts.
## 6. Design review requirement
Every RFC introducing a semantic feature SHOULD contain:
```text
## Agent complexity impact
```
covering:
- new concepts the agent must understand;
- new state the verifier must track;
- additional syntax or instructions;
- interaction with existing features;
- expected effect on repairability;
- whether equivalent behavior could use existing primitives.
A feature that simplifies human syntax while increasing semantic ambiguity for agents SHOULD normally be rejected.
## 7. Syntax sugar
Human-facing `.aji` syntax MAY contain conveniences not present in AIR.
Syntax sugar is preferred when it:
- introduces no new semantic concept;
- has one obvious canonical lowering;
- does not hide allocation, authority, synchronization or failure;
- does not make diagnostics ambiguous.
AIR remains the canonical explicit representation.
## 8. Agent-oriented standard library
Standard library APIs SHOULD prefer:
```text
small number of orthogonal operations
explicit ownership transitions
explicit failure modes
bounded allocation behavior
machine-readable contracts
```
over large convenience APIs.
Multiple APIs with nearly identical semantics SHOULD be avoided unless benchmarks demonstrate a meaningful benefit.
## 9. Evaluation obligations
At major language milestones, Aji SHOULD be evaluated across multiple model capability levels.
Minimum classes:
```text
frontier
strong
mid
small/local
```
The exact models are not part of the language specification.
Model versions MUST be recorded with benchmark results.
Aji SHOULD be compared with at least:
```text
Rust
Zig
```
and MAY additionally be compared with:
```text
C
C++
```
where useful.
## 10. Primary hypotheses
The project tracks the following hypotheses.
### H1 — Correctness advantage
Agents produce correct systems programs more frequently in Aji than in conventional systems languages.
### H2 — Repair advantage
Agents require fewer compiler/verifier/test repair cycles to reach a correct program.
### H3 — Context advantage
Agents require less source and documentation context to safely modify an existing program.
### H4 — Model capability compression
Lower-capability models using Aji approach or exceed stronger models using conventional systems languages.
### H5 — Economic advantage
Expected cost per correct implementation or modification is lower with Aji.
### H6 — Maintenance advantage
The correctness advantage remains when modifying existing systems rather than only generating new programs.
## 11. Non-goals
Aji does not claim that:
- weak models always match frontier models;
- verifier acceptance implies functional correctness;
- Aji removes the need for tests;
- Aji eliminates architectural mistakes;
- every programming domain benefits equally;
- reduced model capability is worth arbitrary runtime overhead;
- benchmark-specific language features are acceptable.
## 12. Anti-overfitting rule
Language features MUST NOT be introduced solely to improve a specific benchmark task.
Benchmark tasks are evidence about the language.
They are not part of the language design.
The held-out benchmark corpus MUST remain unavailable to agents used in language development until evaluation.
## 13. Success condition
The strongest evidence for the Aji hypothesis would be a repeated result of the form:
```text
Mid model + Aji
```
being statistically non-inferior to or better than:
```text
Strong model + Rust/Zig
```
for correctness on systems-programming tasks while also requiring lower total inference cost.
A result of:
```text
Frontier model + Aji
>
Frontier model + Rust/Zig
```
is useful but is not by itself sufficient to establish Model Capability Compression.
## 14. Project principle
Aji should not require the agent to be smarter when the language can make the invalid program impossible.
The language, verifier and runtime are part of the reasoning system.