spec: single normative source, accept RFC 0004, freeze AIR format 0, fuel
Owner decisions after the Phase 0 review: - precedence: docs/spec/ is the single normative source; RFCs are decision records whose accepted rules are integrated into the spec in the same change (AGENTS.md, docs/README.md, rfcs/README.md, DD-011) - RFC 0004 Accepted (scope: AIR format 0, language 0.1) - AIR format 0 frozen as the semantic baseline; spec 07 §8.7 defines the only permitted additive changes, everything else needs `air 1` (DD-012) - Q-019 resolved: deterministic instruction fuel (spec 11 §7). Outcome `limit_exceeded` is a runner outcome, not a trap; `aji run --fuel N`, exit code 5; conformance runs always use fuel (default 1 000 000, `fuel:` header); fuel/schedule budget/quantum kept separate for P3 (DD-013)
This commit is contained in:
1 parent
dc36b5cfc0
commit
03dda1245a
24 files changed
+268
-63
No files matched your search
+12
-3
@@ -25,8 +25,13 @@ const Expect = union(enum) {
|
||||
|
||||
const Outcome = enum { pass, fail, pending };
|
||||
|
||||
/// Fuel for run tests without a `fuel:` header (spec 11 §7.1: conformance
|
||||
/// runs always use a limit).
|
||||
const default_fuel: u64 = 1_000_000;
|
||||
|
||||
const Header = struct {
|
||||
expect: Expect,
|
||||
fuel: u64,
|
||||
phase: u8,
|
||||
spec: []const u8,
|
||||
};
|
||||
@@ -142,7 +147,7 @@ fn runOne(arena: std.mem.Allocator, path: []const u8, source: []const u8) !Resul
|
||||
switch (header.expect) {
|
||||
.accept => if (report.status == .accepted) return .{ .outcome = .pass },
|
||||
.reject => |want| if (report.status == .rejected and eqlCodes(want, got.items)) return .{ .outcome = .pass },
|
||||
.run => |want| if (report.status == .accepted) return runModule(arena, report.module.?, want),
|
||||
.run => |want| if (report.status == .accepted) return runModule(arena, report.module.?, want, header.fuel),
|
||||
}
|
||||
return .{ .outcome = .fail, .detail = try std.fmt.allocPrint(arena, "expected {f}, got {t} {s}", .{
|
||||
fmtExpect(header.expect), report.status, try std.mem.join(arena, " ", got.items),
|
||||
@@ -151,11 +156,11 @@ fn runOne(arena: std.mem.Allocator, path: []const u8, source: []const u8) !Resul
|
||||
|
||||
/// Runs the module twice and requires byte-identical run records (spec 11)
|
||||
/// before comparing against the expectation.
|
||||
fn runModule(arena: std.mem.Allocator, module: aji.air.Module, want: Expect.Run) !Result {
|
||||
fn runModule(arena: std.mem.Allocator, module: aji.air.Module, want: Expect.Run, fuel: u64) !Result {
|
||||
var records: [2][]const u8 = undefined;
|
||||
var outcome: aji.interp.Outcome = undefined;
|
||||
for (&records) |*rec| {
|
||||
outcome = aji.interp.run(arena, module, "main") catch |err| switch (err) {
|
||||
outcome = aji.interp.run(arena, module, "main", .{ .fuel = fuel }) catch |err| switch (err) {
|
||||
error.EntryNotFound => return .{ .outcome = .fail, .detail = "module has no parameterless @main" },
|
||||
else => |e| return e,
|
||||
};
|
||||
@@ -217,6 +222,7 @@ fn parseHeader(arena: std.mem.Allocator, source: []const u8) HeaderError!Header
|
||||
var expect: ?Expect = null;
|
||||
var run_result: ?Expect.Run = null;
|
||||
var phase: ?u8 = null;
|
||||
var fuel: u64 = default_fuel;
|
||||
var spec: ?[]const u8 = null;
|
||||
|
||||
var lines = std.mem.splitScalar(u8, source, '\n');
|
||||
@@ -254,6 +260,8 @@ fn parseHeader(arena: std.mem.Allocator, source: []const u8) HeaderError!Header
|
||||
const code = aji.diag.lookup(value) orelse return error.UnknownCode;
|
||||
if (code.id[0] != 'T') return error.UnknownCode;
|
||||
run_result = .{ .trap = value };
|
||||
} else if (std.mem.eql(u8, key, "fuel")) {
|
||||
fuel = try std.fmt.parseInt(u64, value, 10);
|
||||
} else if (std.mem.eql(u8, key, "phase")) {
|
||||
phase = try std.fmt.parseInt(u8, value, 10);
|
||||
} else if (std.mem.eql(u8, key, "spec")) {
|
||||
@@ -266,6 +274,7 @@ fn parseHeader(arena: std.mem.Allocator, source: []const u8) HeaderError!Header
|
||||
};
|
||||
return .{
|
||||
.expect = expect orelse return error.MissingExpect,
|
||||
.fuel = fuel,
|
||||
.phase = phase orelse return error.MissingPhase,
|
||||
.spec = spec orelse return error.MissingSpec,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user