Phase 2: audit report (P2-10)
- spec 10 §6.1: schema of the format-0 audit report (canonical JSON) - aji report FILE: entry capabilities, per-function effect graph with declared/used/unused effects (fixed point over calls, unsafe stopped at trusted callees), intrinsics, allocations, runtime and proven checks, unsafe operations; capability kinds; unsafe summary - golden unit test; runs over the whole conformance corpus without a crash
This commit is contained in:
1 parent
36e91be84c
commit
b00bac5937
7 files changed
+312
-3
No files matched your search
@@ -57,7 +57,7 @@ src/
|
||||
runtime/ intrinsics: io, fs, net, clock, random (capability-gated)
|
||||
frontend/ .aji lexer, parser, lowering, formatter (P6)
|
||||
backend/llvm/ AIR → LLVM IR (P7)
|
||||
report/ audit artifacts: unsafe, effects, capabilities, contracts
|
||||
report.zig ✓ audit report (spec 10 §6.1)
|
||||
ajid/ long-running agent protocol server (P8)
|
||||
tools/
|
||||
conformance.zig ✓ conformance runner
|
||||
|
||||
@@ -34,7 +34,7 @@ Out: tasks, threads, async I/O (P3); FFI to native code (P7).
|
||||
| P2-7 | done | Unsafe boundary verifier (RFC 0009: assume, borrow.index.unchecked, trusted, unsafe report) | P2-3 | `src/verifier/unsafe.zig` | E6001 accept/reject |
|
||||
| P2-8 | done | Runtime intrinsics in the interpreter; virtual filesystem and loopback network for the `deterministic` profile | P2-2 | `src/runtime/` | intrinsic unit tests pass under both profiles; deterministic profile output identical across runs |
|
||||
| P2-9 | doing | Entry-point capability instantiation (`--grant` done; `aji.toml` `[capabilities]` pending) | P2-5 | `src/runtime/host.zig` | missing grant fails instantiation, not execution (spec 05 §6) |
|
||||
| P2-10 | todo | Reports: effect graph, capability requirements, unsafe sites | P2-4, P2-5, P2-7 | `src/report/` | deterministic JSON report; snapshot test |
|
||||
| P2-10 | done | Reports: effect graph, capability requirements, unsafe sites | P2-4, P2-5, P2-7 | `src/report/` | deterministic JSON report; snapshot test |
|
||||
| P2-11 | done | Reference programs: hello (real `io.write` if deferred from P0), file-copy, tcp-echo (single task) | P2-8 | `tests/programs/` | all three run; cleanup on every error path verified |
|
||||
| P2-8a | done | Hosted profile: real console, files and TCP; run record through `--result-file` (spec 11 §8) | P2-8 | `src/interp/host.zig` | hello, file-copy and tcp-echo run against the real OS in CI |
|
||||
| P2-12 | todo | Phase exit review | all | plan status | exit criterion passes |
|
||||
|
||||
@@ -95,3 +95,46 @@ The toolchain should emit an audit artifact containing:
|
||||
- weak atomic sites;
|
||||
- lock-order findings;
|
||||
- contract status.
|
||||
|
||||
### 6.1 Audit report, format 0
|
||||
|
||||
`aji report FILE` verifies the module and, if it is accepted, prints one canonical JSON document (spec 07a "Canonical record": UTF-8, no whitespace, fixed field order). A rejected module produces its diagnostics and no report. The report is derived from the verified AIR only; it never depends on a run.
|
||||
|
||||
```json
|
||||
{
|
||||
"report": "audit",
|
||||
"air": 0,
|
||||
"module": "<name>",
|
||||
"features": ["…"],
|
||||
"entry": {"function": "main", "capabilities": [{"parameter": "out", "kind": "io.write"}]},
|
||||
"functions": [
|
||||
{
|
||||
"name": "<function>",
|
||||
"trusted": null,
|
||||
"effects_declared": ["…"],
|
||||
"effects_used": ["…"],
|
||||
"effects_unused": ["…"],
|
||||
"calls": ["<callee>", "…"],
|
||||
"intrinsics": ["<intrinsic>", "…"],
|
||||
"allocations": 0,
|
||||
"runtime_checks": {"overflow": 0, "division": 0, "shift": 0, "cast": 0, "bounds": 0, "assert": 0, "guard": 0},
|
||||
"proven_checks": {"bounds": 0},
|
||||
"unsafe_operations": [{"block": "entry", "inst": 0, "op": "borrow.index.unchecked"}]
|
||||
}
|
||||
],
|
||||
"capability_kinds": ["…"],
|
||||
"unsafe": {"trusted_functions": ["…"], "unsafe_functions": ["…"], "operations": 0}
|
||||
}
|
||||
```
|
||||
|
||||
Fields:
|
||||
|
||||
- `entry`: `@main` and its capability parameters in order, or `null` if there is no `@main`.
|
||||
- `effects_used`: the effects the function can actually perform — its intrinsics' effects, `mem.alloc` if it allocates, `unsafe` if it contains unsafe operations, and the `effects_used` of its callees — computed to a fixed point over the call graph. A `trusted` function does not propagate `unsafe` to its callers (spec 13 §6.3); its own `effects_used` does contain `unsafe`, which it discharges. `effects_unused` is `effects_declared` minus `effects_used`: declared authority the code never exercises, a candidate for removal.
|
||||
- `calls`, `intrinsics`: distinct callees and intrinsic names in order of first occurrence; together with `effects_*` this is the effect graph.
|
||||
- `runtime_checks`: instructions whose safety condition is checked at runtime and may trap — `overflow` (checked `add`/`sub`/`mul`, and `div`/`rem` for signed `MIN / -1`), `division` (`div`/`rem` by zero), `shift` (`shl`/`shr`), `cast` (`cast.checked`), `bounds` (`borrow.index`, `slice.sub`, `slice.split`, `slice.copy`), `assert`, `guard`.
|
||||
- `proven_checks.bounds`: `borrow.index.proven` instructions, whose check the verifier eliminated.
|
||||
- `capability_kinds`: distinct capability kinds appearing in any type of the module, sorted.
|
||||
- All lists of names are in order of first occurrence in the module unless stated otherwise; effect lists are sorted.
|
||||
|
||||
Ownership/borrow proof summaries, weak atomic sites, lock-order findings and contract status are added to this document by the phases that introduce them, as new fields; existing fields keep their meaning.
|
||||
Reference in new issue
Block a user