# 08. Verifier ## 1. Role The verifier is part of Aji's language semantics, not an optional lint pass. A safe module that fails verification is not an executable Aji program. ## 2. Required passes A conforming verifier performs, directly or equivalently: 1. type verification; 2. SSA/control-flow verification; 3. initialization verification; 4. ownership verification; 5. borrow/alias verification; 6. region lifetime and generation verification; 7. island closure verification; 8. linear-resource verification; 9. effect verification; 10. capability verification; 11. `Send`/`Share` verification; 12. task-scope verification; 13. synchronization and atomic-ordering validation; 14. range/bounds verification; 15. unsafe-boundary verification. ## 3. Per-value abstract state The verifier may track: ```text type initialization state ownership state borrow state provenance region and generation bounds alignment integer range Send/Share/Local properties task scope resource state ``` ## 4. Ownership state machine Representative states: ```text AVAILABLE MOVED BORROWED_SHARED(n) BORROWED_MUT CONSUMED ``` Transitions are instruction-defined. A moved or consumed value cannot be reused unless a later operation returns a distinct new value. ## 5. Path sensitivity The verifier propagates facts through branches. Example: ```aji if i < len(data) { let x = data[i]; } ``` Inside the branch, `i < len(data)` is available as a proof fact. ## 6. Guards `guard condition` records a verifier-recognized condition on the continuing path. It may justify elimination of later runtime checks. ## 7. Bounded analysis Verifier algorithms must have deterministic resource budgets. If verification exceeds the spec-defined complexity bounds, the verifier emits a stable failure (`E5101`) rather than silently weakening checks. Bounds are fixed by this specification, not configurable: a configurable bound would let a flag change which programs are accepted. Format version 0 defines: | Limit | Value | |---|---| | functions per module | 65 536 | | type declarations per module | 65 536 | | fields per struct, variants per enum, payload values per variant | 256 | | parameters per function or block, arguments per call or branch | 64 | | blocks per function | 16 384 | | instructions per function | 262 144 | | cases per `switch` | 4 096 | The `E5101` diagnostic carries the fields `limit` (name of the limit), `max` and `found`. ## 8. Contracts Contracts may be classified as: ```text PROVEN_STATICALLY CHECKED_AT_RUNTIME ASSUMED_UNSAFE UNPROVEN ``` A high-assurance profile may reject `UNPROVEN` or `ASSUMED_UNSAFE` results. ## 9. Concurrency verification The verifier must reject: - task lifetime escape; - transfer of non-`Send` values to migratable tasks/threads; - concurrent mutable aliases not proven disjoint; - sharing non-`Share` values through concurrent immutable access; - use of moved channel messages; - accessing async I/O buffers while an outstanding operation owns/borrows them; - illegal atomic memory orders. ## 10. Diagnostics Every normative verifier rejection has a stable machine-readable code. Diagnostics should include enough structured state for an agent to repair the program without parsing prose.