Files
aji/build.zig
T
dev 89c63c306b cli: add standard hashes and propose owning map contract
Embed std.hash with four ordinary safe byte functions: FNV-1a 64 and
Castagnoli CRC-32C, each with fresh and numeric continuation forms.
Specify exact constants, empty/chunk semantics, arbitrary continuation
states, target-independent numeric results and explicit serialization.
No heap allocation, authority, AIR, verifier or runtime change.

Propose the next U64Map<V> contract: exact key equality, bounded insert,
returned replacement/full ownership, tombstones, moving drain and
failure-preserving peak-charged rehash. Keep general HashMap<K,V> key
hash/equality policy open as Q-037. A checked slot prerequisite confirms
read-only Copy key/state fields over Option<V>, with explicit accounting
for both tags and owning payload cleanup; no map module is registered.

Validation: unit tests, 797 full conformance cases, 12 new fixtures;
all 11 hash cases with per-instruction collection and 12 schedule seeds
across four quanta, plus owning slot collection; 84 source/AIR, package
and hosted CLI checks; independent forward-polynomial CRC and arbitrary
precision FNV oracles for 286 inputs / 1144 results; 95/95 source coverage;
Zig formatting, whitespace and reference generation. Published vectors
come from RFC 9923 and RFC 3720, with explicit numeric/wire conventions.

Reference cost: source excluding AIR 53,993 -> 55,281 cl100k (+2.4%);
Quick Reference 7,747 -> 7,806 (+0.8%); AIR remains 175,736 bytes.
Map design remains outside both bundles. No empirical MCC or native
throughput claim; CRC initially uses eight bit steps per byte.
2026-10-07 00:53:50 +03:00

112 lines
5.2 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Library: verifier, AIR, interpreter. Everything the TCB contains lives here.
const mod = b.addModule("aji", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
// The error-code registry in docs/ is the source of truth; a test keeps
// src/diag.zig in sync with it.
mod.addAnonymousImport("error_codes_md", .{
.root_source_file = b.path("docs/reference/error-codes.md"),
});
mod.addAnonymousImport("air_features_md", .{
.root_source_file = b.path("docs/reference/air-features.md"),
});
mod.addAnonymousImport("effects_md", .{
.root_source_file = b.path("docs/reference/effects.md"),
});
mod.addAnonymousImport("capabilities_md", .{
.root_source_file = b.path("docs/reference/capabilities.md"),
});
mod.addAnonymousImport("intrinsics_md", .{
.root_source_file = b.path("docs/reference/intrinsics.md"),
});
mod.addAnonymousImport("std_bytes_aji", .{ .root_source_file = b.path("std/bytes.aji") });
mod.addAnonymousImport("std_deque_aji", .{ .root_source_file = b.path("std/deque.aji") });
mod.addAnonymousImport("std_encoding_base64_aji", .{ .root_source_file = b.path("std/encoding/base64.aji") });
mod.addAnonymousImport("std_encoding_hex_aji", .{ .root_source_file = b.path("std/encoding/hex.aji") });
mod.addAnonymousImport("std_fmt_aji", .{ .root_source_file = b.path("std/fmt.aji") });
mod.addAnonymousImport("std_hash_aji", .{ .root_source_file = b.path("std/hash.aji") });
mod.addAnonymousImport("std_math_aji", .{ .root_source_file = b.path("std/math.aji") });
mod.addAnonymousImport("std_option_aji", .{ .root_source_file = b.path("std/option.aji") });
mod.addAnonymousImport("std_result_aji", .{ .root_source_file = b.path("std/result.aji") });
mod.addAnonymousImport("std_utf8_aji", .{ .root_source_file = b.path("std/utf8.aji") });
mod.addAnonymousImport("std_vec_aji", .{ .root_source_file = b.path("std/vec.aji") });
// CLI: `aji`.
const exe = b.addExecutable(.{
.name = "aji",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "aji", .module = mod }},
}),
});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
run_cmd.addPassthruArgs();
b.step("run", "Run the aji CLI").dependOn(&run_cmd.step);
// Unit tests.
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mod })).step);
// Long-running tests kept out of `zig build test` (CI: a separate job).
const extended = b.addTest(.{ .root_module = b.createModule(.{
.root_source_file = b.path("tests/extended/memory.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "aji", .module = mod }},
}) });
b.step("test-extended", "Run long-running tests (interpreter memory at millions of steps)").dependOn(&b.addRunArtifact(extended).step);
test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = exe.root_module })).step);
// Conformance suite runner (tests/conformance).
const conformance = b.addExecutable(.{
.name = "aji-conformance",
.root_module = b.createModule(.{
.root_source_file = b.path("tools/conformance.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "aji", .module = mod }},
}),
});
const run_conformance = b.addRunArtifact(conformance);
run_conformance.addArg("tests/conformance");
run_conformance.addPassthruArgs();
b.step("conformance", "Run the conformance suite").dependOn(&run_conformance.step);
test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = conformance.root_module })).step);
// Agent Reference Bundle (spec 14 §3.7): zig-out/agent/{reference-bundle.md,report.json}.
const bundle = b.addExecutable(.{
.name = "aji-agent-bundle",
.root_module = b.createModule(.{
.root_source_file = b.path("tools/agent_bundle.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "aji", .module = mod }},
}),
});
const run_bundle = b.addRunArtifact(bundle);
run_bundle.setCwd(b.path("."));
run_bundle.addArgs(&.{ ".", "zig-out/agent" });
run_bundle.has_side_effects = true;
b.step("agent-reference", "Build the Agent Reference Bundle and report its size").dependOn(&run_bundle.step);
test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = bundle.root_module })).step);
// Every Quick Reference example is an excerpt of a checked program.
const check_quickref = b.addRunArtifact(bundle);
check_quickref.setCwd(b.path("."));
check_quickref.addArgs(&.{ "--check", "." });
check_quickref.has_side_effects = true;
test_step.dependOn(&check_quickref.step);
}