cli: inspect source linear queries iteratively
This commit is contained in:
1 parent
232f93f188
commit
c1bf99af83
4 files changed
+126
-13
No files matched your search
@@ -178,3 +178,11 @@ Complete checks of structs with 16,384 and 65,536 array levels now accept withou
|
||||
The confirmed Ty.eql failure is repaired with two type cursors and no allocation or mutation. Tag checks still precede descent, each array length is checked before its element, integer/capability names compare string contents, and nominal types compare declaration indices without expanding their graph. All wrapper and leaf identities are unchanged. An independent shallow copy of the old comparator covers every pair of leaf/array/wrapper shapes, including equal names in different storage and zero/max-u64 lengths. Separate 65,536-level mixed trees test equality in both directions and differences at the leaf, interior array length, interior wrapper and outer tag.
|
||||
|
||||
Units/format checks and all 1,791 conformance cases pass with exact corpus coverage; all 1,421 public source checks and 506 accepted lowerings preserve exact old/new exit/stdout/stderr. Complete return-equality checks now accept at 16,384 and 65,536 array levels without output. Changing the deep return leaf to u16 yields exactly one E7005 at 2:655407, with independently verified full found/expected types (655,362/655,363 bytes) and no stderr. A separate deep Copy-array move probe yields E7006/move_copy at 65,536 levels with its complete type; no native failure is observed in that query path. Only child core capture is disabled; no timeout ends a probe. Closing source-query inventory and Q-060 validation remain open, as do the independent Phase 6 gates. No normative/bundle/feature/code, runtime/effect/ownership or accepted-depth limit changes; no fresh Claude review is claimed.
|
||||
|
||||
## Remaining source linear queries
|
||||
|
||||
Call-path inspection finds native recursion in Lowerer.isLinear's array descent and needsLinearType's signature feature scan. The latter's existing guard depends on module cardinality (types.len + 32), so it is not a constant stack bound. Both now use explicit cursors without allocation. Whole-value linearity still follows arrays only and stops at a prepared nominal-cache entry or the original terminal classification. Feature discovery retains its exact guard, named-leaf handling, qualifying wrapper set and content-query-before-depth-increment order. This is an inspection-driven robustness change: the preceding 65,536-level Copy-move CLI probe did not reproduce a native failure in either query.
|
||||
|
||||
An independent shallow copy of both old queries covers all leaves/wrappers, array lengths, mixed shapes and initial depths around the guard. Deep helper tests traverse 65,536 arrays ending in Copy/linear nominal leaves and 65,536 ref edges under a complete property snapshot of 65,536 declarations. The feature scan retains true at initial depth 32 and false at 33, pinning its inclusive boundary. This constructed snapshot tests the helper stage, not complete CLI acceptance of that module. Units/format checks, source linear/nominal CLI integration (49/110) and all 1,791 conformance cases pass with exact corpus coverage. All 1,421 public source checks and 506 accepted lowerings preserve exact old/new exit/stdout/stderr.
|
||||
|
||||
The closing inventory separately confirms source SSA zero generation as a remaining failure: at 16,384 array levels above a Plain record, a var initialized with zero aborts with 10,001 Lowerer.zeroValue frames, exit -6 and no JSON (82,026 input bytes). Its current source rule should report E7006/zero_not_zeroable; AIR's broader zeroability and Q-056 are separate. Only child core capture is disabled; no timeout ends the probe. Source zero emission and the remaining specialization/call-path inventory keep Q-059 open; Q-060 validation and Phase 6 gates remain separate. No normative/bundle/feature/code, ownership/runtime/effect or accepted-depth limit changes; no fresh Claude review is claimed.
|
||||
@@ -491,6 +491,8 @@ The [source-to-AIR conversion increment](air-type-depth-audit.md#source-to-air-t
|
||||
|
||||
The [source equality increment](air-type-depth-audit.md#source-type-equality) repairs Ty.eql with allocation-free cursors preserving structural identity. Deep equal returns accept and unequal leaves yield one factual E7005 with complete types. A deep move-on-Copy query produces E7006/move_copy without a native failure. Closing source-query inventory keeps Q-059 open; Q-060 and Phase 6 gates remain separate. No semantic rule or accepted-depth limit changes.
|
||||
|
||||
The [remaining source linear-query increment](air-type-depth-audit.md#remaining-source-linear-queries) replaces array descent and signature feature scanning with allocation-free loops, preserving prepared nominal reads and the module-sized depth guard exactly. No preceding CLI failure in these queries is claimed. The closing inventory independently confirms Lowerer.zeroValue stack exhaustion on 16,384 arrays above a non-zeroable source record. Source zero emission and specialization/call-path inspection keep Q-059 open; this does not resolve Q-056 or change zeroability.
|
||||
|
||||
## Q-060 — Native recursion while materializing runtime values
|
||||
|
||||
The [executed runtime audit](runtime-value-depth-audit.md) confirms that a verified one-byte value with 32,768 length-one nested arrays aborts inside zeroValue under `aji run --fuel 8`, rather than producing a run record. The instruction has not exhausted fuel. Iterative runtime traversal must preserve initialization, value shape, allocator/root lifetimes, collection safety and instruction accounting; adding a depth trap/acceptance limit needs a normative decision. At that baseline, recursive copying, value sizing, collection and serialization were additional audit candidates with unverified failure paths; the increment below records subsequent executed failures. Compiler type repairs in Q-059 do not resolve Q-060.
|
||||
|
||||
@@ -494,3 +494,7 @@ Units/format checks, nominal/Copy-content/static-function integration (110/119/2
|
||||
## Source type equality (2026-10-10)
|
||||
|
||||
The [Q-059 equality increment](../design/air-type-depth-audit.md#source-type-equality) removes native recursion from Ty.eql without allocation or changed type identity. Independent shallow pair comparisons and separate deep trees cover equal contents and outer/interior/leaf differences. Complete 65,536-level equal returns accept; unequal leaves return one E7005 with exact full types and source position. Units/format checks and all 1,791 conformance cases pass with exact coverage; all 1,421 source checks and 506 accepted lowerings retain exact old/new exit/stdout/stderr. Closing source-query inventory, Q-060 validation and the independent Phase 6 gates remain open. No normative/bundle/feature/code or accepted-depth limit changes; no fresh Claude review is claimed.
|
||||
|
||||
## Remaining source linear queries (2026-10-10)
|
||||
|
||||
The [Q-059 query increment](../design/air-type-depth-audit.md#remaining-source-linear-queries) makes array linearity and signature feature discovery iterative, retaining the existing module-sized guard and prepared cache contract. Independent shallow comparisons, deep helper snapshots, units/format checks, source linear/nominal CLI integration (49/110) and all 1,791 conformance cases with exact coverage pass. All 1,421 source checks and 506 accepted lowerings retain exact old/new exit/stdout/stderr. A separate 16,384-level source zero probe confirms remaining Lowerer.zeroValue stack exhaustion where the current source rule requires E7006/zero_not_zeroable. Zero emission, specialization/call-path inventory, Q-060 validation and Phase 6 gates remain open. No source zeroability, normative/bundle/feature/code or accepted-depth limit changes; no fresh Claude review is claimed.
|
||||
+112
-13
@@ -346,24 +346,30 @@ const Lowerer = struct {
|
||||
/// Count witness visits in unit tests, never used to accept/reject source.
|
||||
property_visits: usize = 0,
|
||||
|
||||
fn needsLinearType(l: *Lowerer, t: Ty, depth: usize) bool {
|
||||
if (depth > l.m.types.len + 32) return false;
|
||||
if (t == .named) return l.isLinear(t);
|
||||
if (t.inner()) |inner| {
|
||||
fn needsLinearType(l: *Lowerer, initial: Ty, initial_depth: usize) bool {
|
||||
var t = initial;
|
||||
var depth = initial_depth;
|
||||
while (true) {
|
||||
if (depth > l.m.types.len + 32) return false;
|
||||
if (t == .named) return l.isLinear(t);
|
||||
const inner = t.inner() orelse return false;
|
||||
if ((t == .array or t == .own or t == .own_array or t == .slice or t == .slice_mut) and l.isLinear(inner)) return true;
|
||||
return l.needsLinearType(inner, depth + 1);
|
||||
t = inner;
|
||||
depth += 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
fn isLinear(l: *Lowerer, t: Ty) bool {
|
||||
fn isLinear(l: *Lowerer, initial: Ty) bool {
|
||||
// Signatures/declarations resolve before checkRequirements; all
|
||||
// structural ownership queries run after its immutable snapshot.
|
||||
if (t.isLinear()) return true;
|
||||
return switch (t) {
|
||||
.array => |a| l.isLinear(a.elem),
|
||||
.named => |i| l.property_module.?.nominal_properties.?[i].linear,
|
||||
else => false,
|
||||
};
|
||||
var t = initial;
|
||||
while (true) {
|
||||
if (t.isLinear()) return true;
|
||||
switch (t) {
|
||||
.array => |a| t = a.elem,
|
||||
.named => |i| return l.property_module.?.nominal_properties.?[i].linear,
|
||||
else => return false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fail(l: *Lowerer, comptime code: []const u8, span: Span, message: []const u8, fields: []const Problem.Field) Error {
|
||||
@@ -4949,3 +4955,96 @@ test "source equality traverses deep trees and detects leaf, interior and outer
|
||||
try std.testing.expect(!different.eql(left));
|
||||
}
|
||||
}
|
||||
|
||||
const ReferenceSourceLinear = struct {
|
||||
fn isLinear(l: *Lowerer, t: Ty) bool {
|
||||
if (t.isLinear()) return true;
|
||||
return switch (t) {
|
||||
.array => |a| isLinear(l, a.elem),
|
||||
.named => |i| l.property_module.?.nominal_properties.?[i].linear,
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
fn needsLinearType(l: *Lowerer, t: Ty, depth: usize) bool {
|
||||
if (depth > l.m.types.len + 32) return false;
|
||||
if (t == .named) return isLinear(l, t);
|
||||
if (t.inner()) |inner| {
|
||||
if ((t == .array or t == .own or t == .own_array or t == .slice or t == .slice_mut) and isLinear(l, inner)) return true;
|
||||
return needsLinearType(l, inner, depth + 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
fn expectSourceLinearMatches(l: *Lowerer, t: Ty) !void {
|
||||
try std.testing.expectEqual(ReferenceSourceLinear.isLinear(l, t), l.isLinear(t));
|
||||
for ([_]usize{ 0, 31, 32, 33, 34, 35, 64 }) |depth| try std.testing.expectEqual(ReferenceSourceLinear.needsLinearType(l, t, depth), l.needsLinearType(t, depth));
|
||||
}
|
||||
|
||||
test "source linear queries preserve shallow classification and guard order" {
|
||||
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
|
||||
defer arena.deinit();
|
||||
const a = arena.allocator();
|
||||
var l: Lowerer = .{ .arena = a, .m = (try parse_mod.parse(a, "module t\nstruct Plain { x: u8 }\nstruct Linear { x: own<u8> }\nfn main() -> void effects [] {}\n")).ok };
|
||||
try l.checkRequirements();
|
||||
var leaves: std.ArrayList(Ty) = .empty;
|
||||
for (int_types) |name| try leaves.append(a, .{ .int = name });
|
||||
try leaves.appendSlice(a, &.{ .bool, .void, .never, .region, .scope, .shield, .{ .named = 0 }, .{ .named = 1 } });
|
||||
for (authority.kinds) |kind| try leaves.append(a, .{ .cap = kind.name });
|
||||
inline for (@typeInfo(authority.Builtin).@"enum".field_names) |name| try leaves.append(a, .{ .builtin = @field(authority.Builtin, name) });
|
||||
inline for (@typeInfo(authority.Resource).@"enum".field_names) |name| try leaves.append(a, .{ .resource = @field(authority.Resource, name) });
|
||||
for (leaves.items) |leaf| {
|
||||
try expectSourceLinearMatches(&l, leaf);
|
||||
for ([_]u64{ 0, 1, @as(u64, 1) << 32, std.math.maxInt(u64) }) |length| try expectSourceLinearMatches(&l, try l.arrayOf(leaf, length));
|
||||
inline for (@typeInfo(Ty).@"union".field_names, @typeInfo(Ty).@"union".field_types) |name, FieldType| if (comptime FieldType == *const Ty) {
|
||||
const tag = @field(std.meta.Tag(Ty), name);
|
||||
try expectSourceLinearMatches(&l, try l.wrap(tag, leaf));
|
||||
try expectSourceLinearMatches(&l, try l.arrayOf(try l.wrap(tag, leaf), 123));
|
||||
try expectSourceLinearMatches(&l, try l.wrap(tag, try l.arrayOf(leaf, 456)));
|
||||
};
|
||||
var chain = leaf;
|
||||
for (0..41) |_| {
|
||||
try expectSourceLinearMatches(&l, chain);
|
||||
chain = try l.wrap(.ref, chain);
|
||||
}
|
||||
}
|
||||
// Guard before a named leaf; a qualifying parent's content query still
|
||||
// precedes advancing the guard, even if that child would exceed it.
|
||||
try std.testing.expect(l.needsLinearType(.{ .named = 1 }, 34));
|
||||
try std.testing.expect(!l.needsLinearType(.{ .named = 1 }, 35));
|
||||
try std.testing.expect(l.needsLinearType(try l.arrayOf(.{ .named = 1 }, 1), 34));
|
||||
try std.testing.expect(!l.needsLinearType(try l.arrayOf(.{ .named = 1 }, 1), 35));
|
||||
try std.testing.expect(!l.needsLinearType(try l.wrap(.own, .{ .int = "u8" }), 0));
|
||||
}
|
||||
|
||||
test "source linear queries walk deep arrays and module-sized feature guards" {
|
||||
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
|
||||
defer arena.deinit();
|
||||
const a = arena.allocator();
|
||||
const initial = (try parse_mod.parse(a, "module t\nstruct Plain { x: u8 }\nstruct Linear { x: own<u8> }\nfn main() -> void effects [] {}\n")).ok;
|
||||
const count = 65_536;
|
||||
const declarations = try a.alloc(ast.TypeDecl, count);
|
||||
@memcpy(declarations[0..2], initial.types);
|
||||
for (declarations[2..], 2..) |*d, i| d.* = .{ .name = try std.fmt.allocPrint(a, "Padding{d}", .{i}), .span = initial.types[0].span, .kind = .{ .@"struct" = &.{} } };
|
||||
var m = initial;
|
||||
m.types = declarations;
|
||||
var l: Lowerer = .{ .arena = a, .m = m };
|
||||
// Construct a complete immutable property snapshot, not a forged cache.
|
||||
// This is a helper-stage fixture, not a complete CLI acceptance claim.
|
||||
try l.checkRequirements();
|
||||
var plain: Ty = .{ .named = 0 };
|
||||
var linear: Ty = .{ .named = 1 };
|
||||
var borrowed: Ty = .{ .named = 1 };
|
||||
for (0..count) |_| {
|
||||
plain = try l.arrayOf(plain, 1);
|
||||
linear = try l.arrayOf(linear, 1);
|
||||
borrowed = try l.wrap(.ref, borrowed);
|
||||
}
|
||||
try std.testing.expect(!l.isLinear(plain));
|
||||
try std.testing.expect(l.isLinear(linear));
|
||||
try std.testing.expect(!l.isLinear(borrowed));
|
||||
try std.testing.expect(l.needsLinearType(borrowed, 0));
|
||||
try std.testing.expect(l.needsLinearType(borrowed, 32));
|
||||
try std.testing.expect(!l.needsLinearType(borrowed, 33));
|
||||
try std.testing.expect(!l.needsLinearType(.{ .named = 1 }, count + 33));
|
||||
}
|
||||
Reference in new issue
Block a user