From 72192c23311d164193e69253460fb3e6ca0840d9 Mon Sep 17 00:00:00 2001 From: "A.Shakhmatov" Date: Sun, 4 Oct 2026 15:36:32 +0300 Subject: [PATCH] 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 --- AGENTS.md | 8 + README.md | 2 + docs/README.md | 2 + docs/evaluation/README.md | 26 + docs/evaluation/protocol.md | 1599 +++++++++++++++++++++++++++ docs/plan/README.md | 21 +- docs/plan/conformance-suite.md | 20 +- docs/plan/phase-8-agent-protocol.md | 2 +- docs/rfcs/0000-template.md | 11 + docs/rfcs/README.md | 3 +- docs/spec/14-agent-efficiency.md | 424 +++++++ docs/spec/README.md | 1 + 12 files changed, 2097 insertions(+), 22 deletions(-) create mode 100644 docs/evaluation/README.md create mode 100644 docs/evaluation/protocol.md create mode 100644 docs/spec/14-agent-efficiency.md diff --git a/AGENTS.md b/AGENTS.md index fc673f1..02d71c1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,6 +16,10 @@ Aji is a small, typed, verifiable systems language intended primarily for AI-gen Human ergonomics matter, but they are secondary to verifier clarity and agent reliability. +Overarching objective (spec 14): **Model Capability Compression** — Aji SHOULD reduce the minimum model capability required to produce correct systems software, by moving reasoning about ownership, lifetime, aliasing, resources, authority, effects and concurrency from the model into the language, verifier and deterministic runtime. "Agent proposes, verifier decides." Every semantic feature is judged by the reasoning burden it adds for agents; the hypothesis is tested empirically by `docs/evaluation/protocol.md`. + +Anti-overfitting (spec 14 §12): never add or shape a language feature to improve a specific benchmark task, and never seek out or use the private held-out benchmark corpus. + ## Non-negotiable principles Do not introduce: @@ -105,6 +109,10 @@ Any change involving ownership, aliasing, atomics, tasks, cancellation, resource 7. deterministic interpreter behavior; 8. backward-compatibility impact. +## RFCs + +Every RFC introducing a semantic feature includes `## Agent complexity impact` (spec 14 §6): new concepts, new verifier state, new syntax or instructions, interactions, effect on repairability, and whether existing primitives suffice. + ## Changes to AIR AIR instructions must have explicit: diff --git a/README.md b/README.md index 231d96b..0b50d69 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,8 @@ AI agent → verified executable system The source representation therefore prioritizes semantic explicitness, bounded complexity, deterministic repair loops and mechanically enforceable invariants over convenience features designed primarily for manual authoring. +The overarching objective is **Model Capability Compression** ([spec 14](docs/spec/14-agent-efficiency.md)): by moving reasoning about ownership, lifetimes, resources, authority, effects and concurrency into the language, verifier and deterministic runtime, Aji should let a weaker model produce systems software as correct as a stronger model writes in Rust or Zig, at lower total cost. This is a hypothesis, tested by the [evaluation protocol](docs/evaluation/protocol.md); negative results are reported too. + ## Reference implementation direction The proposed reference implementation is written primarily in Zig and should be implemented in this order: diff --git a/docs/README.md b/docs/README.md index 25a022f..5bb887b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,6 +9,7 @@ | [`reference/`](reference/) | Normative registries | Grammar, error codes, intrinsics, type properties, litmus tests, glossary | | [`design/`](design/) | Non-normative | Short design decisions and the open-questions log | | [`plan/`](plan/) | Non-normative | Implementation plan, per-phase task breakdowns, conformance plan | +| [`evaluation/`](evaluation/) | Non-normative | Empirical evaluation of the Aji hypothesis (spec 14): protocol, stages, integrity rules | | [`dev/`](dev/) | Non-normative | How the reference implementation is built and tested | ## Precedence @@ -35,6 +36,7 @@ RFCs are not in this list: accepting an RFC integrates its rules into `spec/` in | a small decision with a one-paragraph reason | `design/decisions.md` as the next `DD-NNN` | | a gap or ambiguity you found but cannot resolve now | `design/open-questions.md` as the next `Q-NNN` | | tasks, milestones, sequencing | `plan/` | +| benchmark tasks, evaluation methodology (public dev material only) | `evaluation/`; hidden tests go to the private benchmark repository | | implementation architecture, conventions, test how-to | `dev/` | ## Reading order diff --git a/docs/evaluation/README.md b/docs/evaluation/README.md new file mode 100644 index 0000000..600b161 --- /dev/null +++ b/docs/evaluation/README.md @@ -0,0 +1,26 @@ +# Evaluation + +Non-normative. Empirical validation of the Aji hypothesis stated in [spec 14](../spec/14-agent-efficiency.md): that the language, verifier and runtime take over enough reasoning for weaker models to write correct systems software at lower cost (Model Capability Compression). + +| Document | Purpose | +|---|---| +| [protocol.md](protocol.md) | Agent Language Evaluation Protocol 0.1: variables, tasks T01–T10, maintenance and seeded-bug benchmarks, metrics, statistics, stages A–E, success and falsification criteria | + +## Integrity rules (protocol §7, §29; spec 14 §12) + +- This public repository contains only the protocol and **dev** material. Hidden tests, evaluators and reference implementations of the **validation** and **test** sets live in a separate private benchmark repository. +- Agents used to develop the language (including the agent working in this repository) MUST NOT see the held-out corpus. +- Language features MUST NOT be introduced to improve a specific benchmark task; benchmark failures are classified first (protocol §38). +- Negative results are kept and reported (protocol §37). + +## Stages and language milestones + +| Stage | Tasks | Requires | Status | +|---|---|---|---| +| A — Phase 2 validation | T01–T04 | Phase 2 (heap, regions, resources, capabilities, effects, deterministic I/O) | language ready; infrastructure pending (plan E0) | +| B — Phase 3 validation | T05–T07 | Phase 3 (structured concurrency, schedule exploration) | blocked on Phase 3 | +| C — Atomic validation | T08, litmus repair | Phase 5 (atomics, memory model) | blocked on Phase 5 | +| D — Systems integration | T09, T10 | Phases 3–5; stable features | blocked | +| E — Maintenance campaign | M1–M8 on T03, T07, T09, T10 | D | blocked | + +Until the source language (Phase 6) exists, an Aji run means an agent writing text AIR directly. Stage A therefore measures AIR as the agent-facing language; results must say so. diff --git a/docs/evaluation/protocol.md b/docs/evaluation/protocol.md new file mode 100644 index 0000000..ce2ca73 --- /dev/null +++ b/docs/evaluation/protocol.md @@ -0,0 +1,1599 @@ +# Aji Agent Language Evaluation Protocol + +Version: 0.1 +Status: Proposed +Purpose: empirical validation of the Aji language hypothesis (spec 14) + +# 1. Goal + +The benchmark answers five primary questions: + +```text +Does Aji increase correctness? + +Does Aji reduce repair work? + +Does Aji allow weaker models to perform like stronger models? + +Does the advantage survive maintenance and refactoring? + +Does this reduce the economic cost of correct software? +``` + +Performance of generated binaries is measured separately. + +The benchmark is not intended to show that Aji can merely implement the test programs. + +--- + +# 2. Experimental variables + +Three dimensions are varied independently. + +## Language + +Primary comparison: + +```text +Aji +Rust +Zig +``` + +Secondary comparison: + +```text +C +``` + +C is useful as a low-level baseline but is not required for every experiment. + +## Model capability + +At least four capability classes: + +```text +F — frontier +S — strong +M — mid +L — small/local +``` + +Model classes are assigned before Aji evaluation. + +Parameter count alone MUST NOT determine capability class. + +At least one locally runnable model SHOULD be included. + +## Task + +Tasks cover: + +```text +memory safety +binary parsing +resource ownership +persistent storage +networking +regions +concurrency +synchronization +atomics +maintenance +``` + +--- + +# 3. Experimental unit + +One experimental run is: + +```text +one model ++ +one language ++ +one task ++ +one fresh repository ++ +one fresh agent context +``` + +Runs share no conversation state. + +The model cannot inspect another run. + +--- + +# 4. Agent environment + +All languages receive equivalent facilities: + +```text +repository access +editor +compiler +test runner +local language documentation +shell +benchmark runner +``` + +The agent may not: + +```text +access hidden tests +access another language's reference implementation +modify the evaluator +access previous benchmark runs +use the public internet during the run +``` + +Aji receives its released Agent Reference Bundle. + +Rust and Zig receive pinned local official/reference documentation appropriate to the tested version. + +--- + +# 5. Agent scaffold + +The same agent loop SHOULD be used wherever technically possible. + +The scaffold controls: + +```text +repository inspection +file editing +compiler execution +test execution +termination +token budget +tool-call budget +``` + +Language-specific instructions may explain how to invoke the toolchain but MUST NOT contain solution hints. + +Scaffold tuning occurs only on the development set. + +The test set is not used for scaffold tuning. + +--- + +# 6. Repetition + +Development experiments: + +```text +3 runs per cell +``` + +Full evaluation: + +```text +>= 6 independent runs per +model × language × task +``` + +Headline comparisons SHOULD be repeated: + +```text +>= 12 runs per cell +``` + +when cost permits. + +--- + +# 7. Benchmark corpus + +The benchmark has three sets. + +```text +dev +validation +test +``` + +## dev + +Visible to Aji developers. + +Used for: + +```text +tooling development +scaffold tuning +benchmark debugging +``` + +## validation + +Used before releases. + +Tasks are visible, hidden tests are not. + +## test + +Private held-out corpus. + +Neither task solutions nor hidden tests are used during language design. + +A task is retired from the hidden set after public disclosure. + +--- + +# 8. Task acceptance review + +Every benchmark task must pass human review before entering the test set. + +Reviewers verify: + +- requirements are unambiguous; +- more than one valid implementation is possible; +- hidden tests test the stated requirements; +- tests do not require unspecified behavior; +- one language is not given an accidental structural advantage; +- acceptance criteria are deterministic; +- baseline solutions exist in all compared languages. + +Broken tasks are removed before results are examined. + +--- + +# 9. Task classes + +## T01 — Binary Frame Decoder + +Purpose: + +```text +bounds +initialization +integer handling +slices +malformed input +``` + +### Task + +Implement a streaming decoder for this binary frame: + +```text +magic u32 little-endian +version u8 +flags u8 +payload_len u32 little-endian +payload payload_len bytes +checksum u32 +``` + +Requirements: + +- maximum payload: 1 MiB; +- truncated input returns an error; +- invalid magic returns an error; +- unsupported version returns an error; +- payload length must never cause out-of-bounds access; +- arbitrary input must never crash or trap; +- decoder may receive a frame in arbitrary chunks; +- successful decoding must reproduce the exact payload. + +Hidden evaluation: + +```text +valid corpus +truncation at every byte boundary +oversized lengths +integer edge cases +100k+ generated malformed inputs +round-trip tests +``` + +Mutation tasks: + +```text +add optional extension field +support two protocol versions +reduce allowed scratch memory +``` + +--- + +## T02 — Region-Bound Tree Processor + +Requires Aji regions/heap milestone. + +Purpose: + +```text +Own +Region +allocation budget +borrowing +lifetime +``` + +### Task + +Read a sequence of tree-building commands and construct an in-memory tree. + +Operations: + +```text +NODE parent value +RESET +SUM node +DEPTH node +``` + +Requirements: + +- nodes between RESET operations must use region storage; +- RESET releases the entire current tree; +- no reference from an old tree may survive RESET; +- memory grant: 4 MiB; +- allocation failure must be handled; +- processing continues after a reset. + +Hidden evaluation: + +```text +deep trees +wide trees +repeated resets +near-budget allocation +budget exhaustion +invalid parent identifiers +``` + +Mutations: + +```text +add subtree deletion +return a computed immutable snapshot +change value from scalar to structure +``` + +--- + +## T03 — Durable Append Log + +Purpose: + +```text +resources +I/O +failure paths +bounded memory +recovery +``` + +### Task + +Implement an append-only record log. + +Record: + +```text +sequence +length +checksum +payload +``` + +Requirements: + +- monotonically increasing sequence; +- max payload 64 KiB; +- append; +- sync; +- reopen; +- recovery; +- torn final record must not make previous records unreadable; +- corrupted completed record must be reported; +- working memory <= 2 MiB. + +Hidden evaluator injects interruption after selected write boundaries. + +Mutations: + +```text +add log rotation +add record type +add batch append +change checksum algorithm +``` + +--- + +## T04 — Framed TCP Relay + +Purpose: + +```text +network resources +partial I/O +resource closing +capabilities +protocol parsing +``` + +### Task + +Implement a TCP service using a length-prefixed request protocol. + +For every request: + +```text +u32 length +payload +``` + +server returns: + +```text +u32 length +transformed payload +``` + +Requirements: + +- fragmented receives; +- fragmented sends; +- maximum frame size; +- clean disconnect; +- malformed client isolation; +- every listener and stream consumed exactly once. + +Deterministic loopback network is used in the primary evaluation. + +Mutations: + +```text +add request identifier +add connection limit +add graceful shutdown +``` + +--- + +## T05 — Bounded Processing Pipeline + +Requires structured concurrency. + +Purpose: + +```text +tasks +channels +backpressure +cancellation +linear resources +``` + +### Task + +Create three stages: + +```text +reader + ↓ +parser + ↓ +writer +``` + +All queues are bounded. + +Requirements: + +- no unbounded allocation; +- configurable queue capacity; +- downstream failure cancels upstream work; +- all tasks terminate; +- no resource leaks; +- output ordering is defined by the task specification. + +Hidden evaluator varies: + +```text +queue capacity +producer speed +consumer speed +failure point +cancellation point +schedule +``` + +Mutations: + +```text +add fourth stage +change ordering requirement +add retryable failure +``` + +--- + +## T06 — Parallel Histogram + +Purpose: + +```text +safe parallelism +disjoint memory +structured tasks +determinism +``` + +### Task + +Compute a 256-bin histogram over a large byte buffer using N worker tasks. + +Requirements: + +- N is configurable; +- input is immutable; +- mutable state may not be unsafely shared; +- result must equal sequential reference implementation; +- task completion must be structured; +- output must be identical for every scheduler interleaving. + +Mutations: + +```text +support u16 symbols +dynamic worker count +process data in chunks +``` + +--- + +## T07 — Concurrent Sharded KV Store + +Purpose: + +```text +shared mutable state +mutexes +lock ordering +resource lifetime +concurrent APIs +``` + +Operations: + +```text +GET +PUT +DELETE +COMPARE_AND_SWAP +``` + +Requirements: + +- configurable shard count; +- concurrent clients; +- operations on the same key behave linearly; +- no data races; +- no deadlocks in tested schedules; +- bounded memory. + +Hidden evaluation includes concurrent operation histories. + +Mutations: + +```text +add TTL +change shard function +add snapshot +reduce memory budget +``` + +--- + +## T08 — Atomic SPSC Ring Buffer + +Purpose: + +```text +atomics +memory ordering +weak-memory reasoning +``` + +### Task + +Implement a bounded single-producer/single-consumer ring buffer. + +Restrictions: + +```text +no mutex +no channel +fixed capacity +``` + +Requirements: + +- no lost values; +- no duplicated values; +- FIFO ordering; +- wrap-around correctness; +- deterministic interleaving exploration must find no invalid history. + +The task intentionally tests whether Aji's atomic model and verifier reduce reasoning errors. + +Mutations: + +```text +batch push +batch pop +64-bit sequence counters +``` + +MPMC is NOT part of the initial task. + +--- + +## T09 — Mini Message Broker + +Purpose: + +```text +networking +tasks +bounded queues +backpressure +resource ownership +cancellation +``` + +Features: + +```text +publish +subscribe +bounded topic queue +multiple clients +disconnect cleanup +``` + +Requirements: + +- bounded memory; +- slow consumers create backpressure according to specification; +- disconnect cannot leak resources; +- one failed client cannot terminate unrelated clients; +- deterministic execution must be replayable. + +Mutations: + +```text +multiple topics +consumer groups +queue retention limit +``` + +--- + +## T10 — Mini Storage Engine + +This is the final integration benchmark. + +Components: + +```text +TCP protocol +KV API +memtable +WAL +immutable segments +recovery +concurrent clients +``` + +Required operations: + +```text +GET +PUT +DELETE +SYNC +``` + +Requirements: + +- bounded memory; +- recovery after interruption; +- concurrent clients; +- deterministic test execution; +- valid resource ownership; +- no unsafe code unless explicitly permitted by the track. + +Later variants add: + +```text +compaction +snapshots +background maintenance +``` + +This task is not used until the required Aji features are stable. + +--- + +# 10. Maintenance benchmark + +Generation from scratch is insufficient. + +Every core program receives modification tasks. + +Primary modification categories: + +## M1 — Feature addition + +Add externally visible functionality without breaking previous behavior. + +## M2 — API migration + +Change an internal interface used by multiple modules. + +## M3 — Memory constraint + +Reduce allowed memory without changing observable behavior. + +## M4 — Concurrency conversion + +Convert sequential processing to parallel/concurrent processing. + +## M5 — Capability reduction + +Reduce authority granted to one component while preserving functionality. + +## M6 — Fault handling + +Introduce a new failure mode and ensure complete cleanup. + +## M7 — Bug repair + +Provide a failing public reproduction but keep regression tests hidden. + +## M8 — Structural refactor + +Change storage/layout/ownership representation while preserving behavior. + +--- + +# 11. Independent vs cumulative maintenance + +Two modes are measured. + +## Independent + +Every mutation begins from the same known-good baseline. + +Measures: + +```text +ability to perform one change +``` + +## Cumulative + +Mutations are applied sequentially: + +```text +v1 +↓ +M1 +↓ +M2 +↓ +M3 +↓ +... +``` + +Measures: + +```text +architectural degradation +context growth +regression accumulation +long-term maintainability +``` + +--- + +# 12. Seeded bug benchmark + +Canonical implementations receive deliberately inserted defects. + +Bug classes: + +```text +out-of-bounds access +use-after-move +resource leak +double close +lifetime escape +allocation budget bypass +authority misuse +missing error edge +deadlock +incorrect atomic ordering +``` + +The agent receives only: + +```text +repository +bug report +observable failure when appropriate +``` + +Metrics measure whether the defect is: + +```text +caught before execution +correctly diagnosed +correctly repaired +repaired without regression +``` + +Aji verifier-detected bugs and test-detected bugs are reported separately. + +--- + +# 13. Primary correctness metric + +A run is accepted only if all mandatory gates pass: + +```text +compiler/verifier accepts +public tests pass +hidden functional tests pass +hidden regression tests pass +fuzz corpus passes +resource checks pass +required deterministic runs agree +``` + +For concurrency tasks: + +```text +schedule exploration passes +``` + +For tasks with resource limits: + +```text +memory/fuel limits pass +``` + +There is no partial success in the primary metric. + +Primary result: + +```text +Verified Success Rate += +accepted runs / all runs +``` + +--- + +# 14. First-generation metric + +Record the state before the first compiler-driven repair. + +Metrics: + +```text +first check accepted +first build accepted +first public test pass +first hidden test pass +``` + +This separates: + +```text +generation quality +``` + +from: + +```text +repair-loop quality +``` + +--- + +# 15. Repair metrics + +For every run record: + +```text +compiler/verifier invocations +failed verifier cycles +failed test cycles +number of patches +total generated tokens +total context tokens +tool calls +elapsed agent time +``` + +Key metric: + +```text +Repair Cycles to Accepted Solution +``` + +--- + +# 16. Context efficiency + +For maintenance tasks measure: + +```text +repository tokens inspected +documentation tokens inspected +files opened +functions inspected +``` + +Aji's context hypothesis is supported if correct modifications require materially less context. + +--- + +# 17. Economic metrics + +For API models: + +```text +input cost +output cost +cached-input cost +tool/model cost +``` + +For local models: + +```text +GPU-seconds +energy if available +wall time +generated tokens +``` + +Primary economic measure: + +```text +Expected Cost per Correct Solution += +total cost of all runs +/ +number of accepted runs +``` + +Failed attempts therefore contribute to cost. + +This prevents cheap but unreliable models from appearing artificially inexpensive. + +--- + +# 18. Model Capability Compression metric + +Primary evidence is direct cross-tier comparison. + +Example: + +```text +M + Aji +versus +S + Rust + +M + Aji +versus +S + Zig +``` + +A **one-tier compression result** occurs when the lower-tier Aji configuration is non-inferior in Verified Success Rate to the higher-tier baseline configuration. + +Recommended non-inferiority margin: + +```text +5 percentage points +``` + +Stronger evidence: + +```text +M + Aji >= F + baseline +``` + +or: + +```text +L + Aji >= S + baseline +``` + +--- + +# 19. Capability curves + +For each language, fit: + +```text +P(success) += +f(model capability, task difficulty) +``` + +The important observation is horizontal shift. + +Conceptually: + +```text +success +1.0 | Aji + | / + | / + | Rust/ + | / / + | Zig / / +0.0 +----------------- + model capability +``` + +If Aji's curve is consistently shifted toward weaker models, the Model Capability Compression hypothesis is supported. + +--- + +# 20. Statistical analysis + +Report at minimum: + +```text +success proportion +95% confidence interval +median repair cycles +median cost +cost per accepted solution +``` + +Task-level bootstrap SHOULD be used for aggregate confidence intervals. + +A mixed-effects logistic model MAY be used: + +```text +success +~ +language +* model ++ task-family random effect +``` + +No headline metric should rely on one task family. + +--- + +# 21. Fixed-budget track + +Each configuration receives the same execution envelope: + +```text +maximum agent turns +maximum tool calls +maximum wall-clock duration +``` + +This measures engineering capability under comparable operational constraints. + +--- + +# 22. Economic track + +Each configuration instead receives the same maximum monetary or compute budget. + +Example: + +```text +$1 +$5 +$20 +``` + +or equivalent local-compute budget. + +Question: + +> Which language/model pair produces the highest probability of a correct solution per unit cost? + +This is the main track for testing Aji's economic hypothesis. + +--- + +# 23. Unconstrained diagnostic track + +A smaller experiment allows the agent to continue until: + +```text +success +or +hard safety limit +``` + +This is used to understand failure modes and repair convergence. + +It is not the main leaderboard. + +--- + +# 24. Runtime performance + +Correct implementations are subsequently benchmarked for: + +```text +throughput +latency +peak memory +binary size +startup time +``` + +Runtime performance is secondary to correctness during early Aji development. + +An incorrect program receives no performance score. + +--- + +# 25. Unsafe code + +Report separately: + +```text +unsafe blocks +unsafe instructions +FFI boundaries +raw memory operations +``` + +A baseline solution using unsafe facilities is not automatically invalid, but the amount of unsafe code is recorded. + +Aji tasks MAY define: + +```text +unsafe forbidden +``` + +when testing safe-language guarantees. + +--- + +# 26. Negative controls + +Include tasks where Aji should have little structural advantage: + +```text +pure arithmetic +simple transformation +straightforward sorting +small deterministic algorithms +``` + +If Aji appears dramatically superior on every negative-control task, investigate benchmark or scaffold bias. + +--- + +# 27. Failure classification + +Every failed run receives one primary category: + +```text +SPEC_UNDERSTANDING +SYNTAX +TYPE +OWNERSHIP +BORROW +RESOURCE +BOUNDS +FUNCTIONAL +CONCURRENCY +DEADLOCK +ATOMIC_ORDERING +PERFORMANCE +BUDGET +TIMEOUT +AGENT_GAVE_UP +TOOL_FAILURE +``` + +For Aji additionally record: + +```text +caught_by_verifier +caught_by_runtime +caught_by_test +``` + +This measures where reasoning was externalized. + +--- + +# 28. Reproducibility record + +Every run stores: + +```text +task id/version +hidden evaluator hash +language +compiler version/commit +model exact identifier +provider +model parameters +agent scaffold commit +system prompt hash +task prompt hash +token limits +tool limits +hardware +seed +all tool calls +all patches +all compiler diagnostics +all test results +final repository +cost +``` + +--- + +# 29. Benchmark integrity + +The hidden test corpus must not be committed into the public Aji repository. + +Store: + +```text +task spec +evaluator +reference implementation +hidden tests +``` + +in a separate private benchmark repository. + +Published results include evaluator hashes. + +When a test set is disclosed, it is retired and replaced. + +--- + +# 30. Stage A — Phase 2 validation + +Run after: + +```text +heap +regions +resources +capabilities +effects +deterministic I/O +``` + +Tasks: + +```text +T01 Binary Frame Decoder +T02 Region-Bound Tree +T03 Durable Append Log +T04 Framed TCP Relay +``` + +Primary hypotheses: + +```text +H1 correctness +H2 repair +H4 early model compression +``` + +No claims about concurrency yet. + +--- + +# 31. Stage B — Phase 3 validation + +After structured concurrency: + +```text +T05 Pipeline +T06 Parallel Histogram +T07 Concurrent KV +``` + +Add: + +```text +schedule exploration +cancellation tests +deadlock analysis +``` + +This is the first serious test of Aji's concurrency thesis. + +--- + +# 32. Stage C — Atomic validation + +After the atomic memory model is stable: + +```text +T08 SPSC Ring +``` + +Also run small litmus-test repair tasks. + +Do not add complex lock-free reclamation until Aji has explicit support for it. + +--- + +# 33. Stage D — Systems integration + +Run: + +```text +T09 Message Broker +T10 Mini Storage Engine +``` + +These become the primary end-to-end language benchmark. + +--- + +# 34. Stage E — Maintenance campaign + +For T03, T07, T09 and T10 run all M1–M8 mutation classes. + +This stage is more important than additional greenfield examples. + +A language for AI development must remain effective when an agent changes code it did not create in the current context. + +--- + +# 35. Initial success criteria + +Before running the private test set, freeze these thresholds. + +## Evidence for H1 + +For mid and small models: + +```text +Aji Verified Success Rate +>= +best Rust/Zig baseline + 15 percentage points +``` + +on safety-heavy tasks. + +## Evidence for H2 + +Median repair cycles: + +```text +Aji <= 70% of best baseline +``` + +## Evidence for H3 + +For successful maintenance runs: + +```text +median context consumed by Aji +<= 70% of best baseline +``` + +## Evidence for H4 + +At least one lower model tier using Aji is non-inferior within 5 percentage points to the next higher model tier using Rust or Zig across the aggregate test set. + +Strong evidence requires this to hold across multiple task families. + +## Evidence for H5 + +Expected Cost per Correct Solution: + +```text +Aji lower-tier model +<= 50% +``` + +of the higher-tier baseline model it matches in correctness. + +## Evidence for H6 + +Aji's correctness advantage remains positive on the independent and cumulative maintenance tracks. + +--- + +# 36. Strong confirmation criterion + +The core Aji thesis is strongly supported if all are observed: + +```text +Mid + Aji +>= +Strong + Rust/Zig +``` + +for correctness, + +while: + +```text +cost(Mid + Aji) +< +cost(Strong + Rust/Zig) +``` + +and the advantage persists on: + +```text +greenfield +maintenance +concurrency +fault repair +``` + +tasks. + +--- + +# 37. Falsification criteria + +The hypothesis should be considered weakened if: + +- Aji only helps frontier models; +- weaker models repeatedly fail to understand Aji-specific semantics; +- verifier errors cause long repair loops; +- Aji advantage disappears on maintenance tasks; +- benefits only occur on examples already present in the specification; +- correctness gains require substantially more inference cost; +- language complexity grows until the Agent Reference Bundle approaches conventional language complexity. + +A negative result must be retained and reported. + +--- + +# 38. Decision rules for language development + +Benchmark failures SHOULD be classified before changing the language. + +Possible causes: + +```text +model limitation +documentation problem +diagnostic problem +tooling problem +language semantic complexity +missing abstraction +benchmark defect +``` + +A language feature should be added only when repeated failures show that the semantic model itself is responsible. + +Do not add syntax or instructions merely because one model struggled with one task. + +--- + +# 39. First concrete experiment + +As soon as RFC 0008 is implemented, run a pilot: + +```text +tasks: +T01 +T02 +T03 +T04 + +languages: +Aji +Zig +Rust + +models: +1 frontier +1 mid +1 small/local + +runs: +3 per cell +``` + +Total: + +```text +4 × 3 × 3 × 3 += +108 runs +``` + +Purpose: + +```text +debug benchmark +estimate effect size +identify impossible/ambiguous tasks +measure cost +validate instrumentation +``` + +Do not use this pilot as headline evidence. + +--- + +# 40. First confirmatory experiment + +After fixing the benchmark based only on the pilot: + +```text +8 held-out tasks +3 languages +4 model classes +6 independent runs +``` + +Total: + +```text +576 runs +``` + +This should be the first meaningful published Aji language evaluation. + +--- + +# 41. Central benchmark question + +The most important table produced by the project should eventually look like: + +| Model class | Zig | Rust | Aji | +|---|---:|---:|---:| +| Frontier | success % | success % | success % | +| Strong | success % | success % | success % | +| Mid | success % | success % | success % | +| Small/local | success % | success % | success % | + +Immediately beside it: + +| Model + language | Cost / correct solution | Repair cycles | Context consumed | +|---|---:|---:|---:| +| Frontier + Rust | … | … | … | +| Mid + Aji | … | … | … | +| Small + Aji | … | … | … | + +That comparison directly tests the Aji thesis. + +--- + +# 42. Final principle + +The benchmark does not ask: + +> Can an AI write Aji? + +It asks: + +> How much model intelligence does Aji make unnecessary while preserving correctness? + +That is the primary experimental question of the project. diff --git a/docs/plan/README.md b/docs/plan/README.md index 85cb7ae..5d41273 100644 --- a/docs/plan/README.md +++ b/docs/plan/README.md @@ -33,7 +33,7 @@ Non-normative. The order in which the Zig reference implementation is built, and | P5 | [phase-5-atomics-and-memory-model.md](phase-5-atomics-and-memory-model.md) | Atomics, orderings, fences, weak-memory interpreter, schedule exploration, replay | atomic publication litmus/conformance tests | Q-015, Q-017 | | P6 | [phase-6-source-language.md](phase-6-source-language.md) | `.aji` parser, lowering, generics, contracts, formatter | all reference programs authored primarily as `.aji` | — | | P7 | [phase-7-native-backend.md](phase-7-native-backend.md) | LLVM lowering, native runtime, three targets, ABI tests | interpreted and native executions pass the same corpus | — | -| P8 | [phase-8-agent-protocol.md](phase-8-agent-protocol.md) | `ajid`, inspect/trace, verification report, benchmark | external agent implements/repairs a reference task using only protocol + spec | — | +| P8 | [phase-8-agent-protocol.md](phase-8-agent-protocol.md) | `ajid`, inspect/trace, verification report; benchmark harness per the evaluation protocol | external agent implements/repairs a reference task using only protocol + spec | — | ## Dependency graph @@ -86,6 +86,25 @@ These run through all phases rather than belonging to one. | Features | Every phase from P1 publishes its feature bundles (`../reference/air-features.md`) when their semantics are specified, and adds them to `supported` when implemented. `aji features` is the discovery interface for agents. | | Packages | Minimal `aji.toml` reading for capabilities in P2; dependencies, lockfile and sandboxed build extensions in P8 (spec 12). | +## Evaluation track (spec 14, `../evaluation/protocol.md`) + +Evaluation runs alongside the phases; each stage starts when the language features it needs are implemented. + +| ID | Status | Task | Depends | Done when | +|---|---|---|---|---| +| E0-1 | todo | Define the Agent Reference Bundle (spec 14 §3.7) and a deterministic size measurement (bytes and tokens) recorded per release | — | bundle manifest in the repository; size reported in CI | +| E0-2 | todo | Private benchmark repository: task specs, evaluators, reference implementations, hidden tests for T01–T04; dev/validation/test split | — | evaluator hashes published; nothing hidden in this repository | +| E0-3 | todo | Language-neutral agent scaffold and run recorder (protocol §5, §28) | — | identical loop drives Aji, Rust and Zig; every run record complete | +| E0-4 | todo | Rust and Zig baseline solutions and pinned local documentation | E0-2 | baselines pass the hidden tests | +| E-A | todo | Stage A pilot: T01–T04 × Aji/Rust/Zig × 3 model classes × 3 runs = 108 runs (protocol §39); not headline evidence | E0-1…E0-4, Phase 2 | pilot report: effect size, broken tasks, cost, instrumentation | +| E-B | todo | Stage B: T05–T07 | Phase 3 | stage report | +| E-C | todo | Stage C: T08, litmus repair | Phase 5 | stage report | +| E-D | todo | Stage D: T09, T10 | Phases 3–5, stable features | stage report | +| E-E | todo | Stage E: maintenance campaign M1–M8 | E-D | stage report | +| E-1 | todo | First confirmatory experiment: 8 held-out tasks × 3 languages × 4 model classes × 6 runs = 576 runs (protocol §40); thresholds frozen beforehand (§35) | E-A fixes | published evaluation | + +Until Phase 6 delivers the source language, agents write text AIR directly; Stage A results must state this. + ## Task conventions - IDs are `P-` and never reused. A task split later becomes `P1-4a`, `P1-4b`. diff --git a/docs/plan/conformance-suite.md b/docs/plan/conformance-suite.md index 27966f7..d0d2ced 100644 --- a/docs/plan/conformance-suite.md +++ b/docs/plan/conformance-suite.md @@ -91,22 +91,4 @@ I/O completion reordering ## Agent benchmark -Compare Aji, Zig, Rust and C under the same task specifications and agent model. - -Primary metric: - -```text -P(correct program | one generation/repair iteration) -``` - -Secondary metrics: - -- iterations to verified solution; -- tokens consumed; -- verifier/compiler repair loops; -- runtime defects; -- memory/concurrency bugs; -- regression rate after change; -- context required to modify the system; -- runtime speed; -- binary size. +Superseded by the Agent Language Evaluation Protocol: [`../evaluation/protocol.md`](../evaluation/protocol.md) (spec 14). diff --git a/docs/plan/phase-8-agent-protocol.md b/docs/plan/phase-8-agent-protocol.md index 56bedf5..3ada90f 100644 --- a/docs/plan/phase-8-agent-protocol.md +++ b/docs/plan/phase-8-agent-protocol.md @@ -18,6 +18,6 @@ Non-normative. Part of the [implementation plan](README.md). | P8-4 | todo | `explain` and repair-candidate coverage for every registry code | P8-2 | `src/diag.zig`, spec 10 | every code has structured fields and at least one repair candidate kind | | P8-5 | todo | Verification report artifact (spec 10 §6) combining all `src/report/` outputs | P8-2 | `aji report` | single deterministic JSON document; schema documented | | P8-6 | todo | Packages: dependencies, lockfile, content addressing, sandboxed declared build extensions | — | spec 12, `src/pkg/` | dependency resolution is deterministic; unsafe dependencies reported separately | -| P8-7 | todo | Benchmark harness: Aji vs Zig, Rust, C on shared task specs | P8-2 | `bench/` | records P(correct \| one iteration), iterations, tokens, defects | +| P8-7 | todo | Integrate `ajid` with the evaluation scaffold (E0-3) so Aji runs use the agent protocol | P8-2, E0-3 | scaffold adapter | scaffold drives Aji through `ajid`; protocol §28 records complete | | P8-8 | todo | External agent trial on a reference task | P8-2…P8-5 | trial report in `docs/plan/` | exit criterion passes | | P8-9 | todo | Phase exit review; Aji 0.1 release-candidate checklist | all | plan status | all phases done; spec status updated | diff --git a/docs/rfcs/0000-template.md b/docs/rfcs/0000-template.md index dcb9ff8..e54196d 100644 --- a/docs/rfcs/0000-template.md +++ b/docs/rfcs/0000-template.md @@ -58,6 +58,17 @@ Files and sections of `docs/spec/` and `docs/reference/` that receive the normat Which AIR format version is affected. A change to the meaning of an existing construct requires a new format version (spec 07 §8.7). +## Agent complexity impact + +Required for semantic features (spec 14 §6): + +- New concepts the agent must understand: +- New state the verifier must track: +- Additional syntax or instructions: +- Interaction with existing features: +- Expected effect on repairability: +- Could existing primitives express it? + ## Alternatives considered ## Unresolved questions diff --git a/docs/rfcs/README.md b/docs/rfcs/README.md index adb2cfd..4846066 100644 --- a/docs/rfcs/README.md +++ b/docs/rfcs/README.md @@ -43,6 +43,7 @@ An RFC that changes memory safety, concurrency, effects/capabilities, AIR or uns - rejected example; - diagnostics impact; - migration/compatibility notes, including the AIR format version affected (spec 07 §8.7); -- alternatives considered. +- alternatives considered; +- **agent complexity impact** (spec 14 §6): new concepts the agent must understand, new state the verifier must track, additional syntax or instructions, interaction with existing features, expected effect on repairability, and whether equivalent behavior could use existing primitives. A feature that simplifies human syntax while increasing semantic ambiguity for agents should normally be rejected. Template: [`0000-template.md`](0000-template.md). diff --git a/docs/spec/14-agent-efficiency.md b/docs/spec/14-agent-efficiency.md new file mode 100644 index 0000000..607680f --- /dev/null +++ b/docs/spec/14-agent-efficiency.md @@ -0,0 +1,424 @@ +# 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. diff --git a/docs/spec/README.md b/docs/spec/README.md index 3b769a5..6833d01 100644 --- a/docs/spec/README.md +++ b/docs/spec/README.md @@ -23,6 +23,7 @@ The specification is split by semantic domain. Rationale for major decisions liv | [11-determinism-and-replay.md](11-determinism-and-replay.md) | Normative draft | Deterministic testing/replay | | [12-packages-and-build.md](12-packages-and-build.md) | Normative draft | Manifest/build model | | [13-contracts-and-unsafe.md](13-contracts-and-unsafe.md) | Normative draft | Contracts, proof status and unsafe boundaries | +| [14-agent-efficiency.md](14-agent-efficiency.md) | Normative draft (design objectives) | Agent efficiency, Model Capability Compression, design review requirement | ## Reading order