cli: add explicit package source modules
Link manifest-selected source graphs with module-local names, qualified structs/enums/functions and task workers through ordinary AIR verification. Keep source inputs bounded, reject source symlinks and preserve explicit grants, diagnostics and deterministic canonical lowering. Integrate spec 12/15, RFC 0021, source reference budgets, roadmap, examples and CI coverage. Validate 579 conformance tests, unit tests, 76 source constructs, hosted smoke, 36 package CLI checks and task schedule stress.
This commit is contained in:
81 files changed
+1419
-234
No files matched your search
+17
-3
@@ -39,6 +39,8 @@ const Outcome = enum { pass, fail, pending };
|
||||
/// runs always use a limit).
|
||||
const default_fuel: u64 = 1_000_000;
|
||||
|
||||
const ModuleBinding = struct { name: []const u8, path: []const u8 };
|
||||
|
||||
const Header = struct {
|
||||
expect: Expect,
|
||||
fuel: u64,
|
||||
@@ -57,6 +59,7 @@ const Header = struct {
|
||||
/// `.aji` only: a reference AIR program (relative to the conformance
|
||||
/// root) whose observable run must equal this one's.
|
||||
equivalent: ?[]const u8 = null,
|
||||
modules: []const ModuleBinding = &.{},
|
||||
};
|
||||
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
@@ -151,10 +154,15 @@ const stress_quanta = [_]u64{ 1, 2, 7 };
|
||||
fn runSource(arena: std.mem.Allocator, io: std.Io, dir: std.Io.Dir, rel: []const u8, path: []const u8, source: []const u8) !Result {
|
||||
const header = parseHeader(arena, source) catch |err|
|
||||
return .{ .outcome = .fail, .detail = try std.fmt.allocPrint(arena, "bad header: {t}", .{err}) };
|
||||
const report = try aji.check.checkFile(arena, path, source);
|
||||
var modules: std.ArrayList(aji.frontend.modules.Source) = .empty;
|
||||
for (header.modules) |binding| {
|
||||
const text = dir.readFileAlloc(io, binding.path, arena, .limited(64 << 20)) catch |err| return .{ .outcome = .fail, .detail = try std.fmt.allocPrint(arena, "module {s}: {t}", .{ binding.path, err }) };
|
||||
try modules.append(arena, .{ .name = binding.name, .file = binding.path, .source = text });
|
||||
}
|
||||
const report = try aji.check.checkWithModules(arena, path, source, modules.items);
|
||||
if (report.status == .unimplemented) return .{ .outcome = .pending, .detail = report.missing_stage };
|
||||
if (report.lowered) |lowered| {
|
||||
const again = try aji.frontend.compile(arena, path, source);
|
||||
const again = try aji.frontend.compileWithModules(arena, path, source, modules.items);
|
||||
if (again != .ok or !std.mem.eql(u8, again.ok.air, lowered.air)) return .{ .outcome = .fail, .detail = "lowering is not deterministic" };
|
||||
const parsed = try aji.air.parse.parse(arena, path, lowered.air);
|
||||
if (parsed.module) |m| {
|
||||
@@ -452,7 +460,7 @@ fn formatExpect(e: Expect, w: *std.Io.Writer) std.Io.Writer.Error!void {
|
||||
}
|
||||
}
|
||||
|
||||
const HeaderError = error{ BadGrant, MissingExpect, MissingPhase, MissingSpec, MissingRunResult, UnknownKey, UnknownCode, BadExpect, OutOfMemory, InvalidCharacter, Overflow };
|
||||
const HeaderError = error{ BadModule, BadGrant, MissingExpect, MissingPhase, MissingSpec, MissingRunResult, UnknownKey, UnknownCode, BadExpect, OutOfMemory, InvalidCharacter, Overflow };
|
||||
|
||||
fn parseHeader(arena: std.mem.Allocator, source: []const u8) HeaderError!Header {
|
||||
var expect: ?Expect = null;
|
||||
@@ -470,6 +478,7 @@ fn parseHeader(arena: std.mem.Allocator, source: []const u8) HeaderError!Header
|
||||
var want_stderr: ?[]const u8 = null;
|
||||
var spec: ?[]const u8 = null;
|
||||
var equivalent: ?[]const u8 = null;
|
||||
var modules: std.ArrayList(ModuleBinding) = .empty;
|
||||
|
||||
var lines = std.mem.splitScalar(u8, source, '\n');
|
||||
while (lines.next()) |line| {
|
||||
@@ -549,6 +558,10 @@ fn parseHeader(arena: std.mem.Allocator, source: []const u8) HeaderError!Header
|
||||
phase = try std.fmt.parseInt(u8, value, 10);
|
||||
} else if (std.mem.eql(u8, key, "spec")) {
|
||||
spec = value;
|
||||
} else if (std.mem.eql(u8, key, "module")) {
|
||||
const eq = std.mem.indexOfScalar(u8, value, '=') orelse return error.BadModule;
|
||||
if (eq == 0 or eq + 1 == value.len) return error.BadModule;
|
||||
try modules.append(arena, .{ .name = value[0..eq], .path = value[eq + 1 ..] });
|
||||
} else if (std.mem.eql(u8, key, "equivalent")) {
|
||||
equivalent = value;
|
||||
} else return error.UnknownKey;
|
||||
@@ -574,6 +587,7 @@ fn parseHeader(arena: std.mem.Allocator, source: []const u8) HeaderError!Header
|
||||
.phase = phase orelse return error.MissingPhase,
|
||||
.spec = spec orelse return error.MissingSpec,
|
||||
.equivalent = equivalent,
|
||||
.modules = modules.items,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user