wip: shield index relations, dev evaluation tasks, Q-063 audit notes

Verifier borrow/provenance work, new phase3 shield_index conformance cases,
dev-intervals/dev-lru/dev-shards tasks with evaluate.py harness, and agent skill/hook config.
This commit is contained in:
dev committed 2026-10-17 12:30:37 +03:00
1 parent 2d750a0525
commit e3fc896a0a
68 files changed
+2132 -37

No files matched your search

@@ -0,0 +1,20 @@
; expect: reject E4305
; phase: 3
; spec: docs/spec/04-concurrency-and-atomics.md §37.3
module test.shield_index
air 0
lang 0.1
features [cancellation, effects, ownership, tasks]
fn @main() -> void
effects []
entry:
%a = task.shield.begin
%b = task.shield.begin
%c = task.shield.begin
task.shield.end %c
%d = task.shield.begin
task.shield.end %a
task.shield.end %d
task.shield.end %b
ret
@@ -0,0 +1,21 @@
; expect: reject E3002 E4305
; phase: 3
; spec: docs/spec/04-concurrency-and-atomics.md §37.3
module test.shield_index
air 0
lang 0.1
features [cancellation, effects, ownership, tasks]
fn @main() -> void
effects []
entry:
%a = task.shield.begin
%b = task.shield.begin
%c = task.shield.begin
%condition = const.bool true
cbr %condition, @joined(%a, %b, %c), @joined(%b, %a, %c)
joined(%x: shield, %y: shield, %z: shield):
task.shield.end %z
task.shield.end %y
task.shield.end %x
ret
@@ -0,0 +1,23 @@
; expect: run
; phase: 3
; spec: docs/spec/04-concurrency-and-atomics.md §37.3
; schedules: 32
; result: 42
module test.shield_index
air 0
lang 0.1
features [cancellation, effects, ownership, tasks]
fn @main() -> u8
effects []
entry:
%a = task.shield.begin
%b = task.shield.begin
%c = task.shield.begin
br @next(%c, %a, %b)
next(%inner: shield, %outer: shield, %middle: shield):
task.shield.end %inner
task.shield.end %middle
task.shield.end %outer
%answer = const.u8 42
ret %answer
@@ -0,0 +1,23 @@
; expect: run
; phase: 3
; spec: docs/spec/04-concurrency-and-atomics.md §37.3
; schedules: 32
; result: 42
module test.shield_index
air 0
lang 0.1
features [cancellation, effects, ownership, tasks]
fn @main() -> u8
effects []
entry:
%a = task.shield.begin
%b = task.shield.begin
%c = task.shield.begin
task.shield.end %c
%d = task.shield.begin
task.shield.end %d
task.shield.end %b
task.shield.end %a
%answer = const.u8 42
ret %answer
@@ -0,0 +1,14 @@
// expect: run
// result: 42
// schedules: 32
// phase: 6
// spec: docs/spec/04-concurrency-and-atomics.md §37.3; docs/spec/15-source-language.md §7
module test.shield_index
fn main() -> u64 effects [] {
var x: u64 = 0u64;
shield {
shield { shield { x = x + 1u64; } shield { x = x + 1u64; } }
shield { x = x + 40u64; }
}
return x;
}
+90
View File
@@ -0,0 +1,90 @@
#!/usr/bin/env python3
"""Q-063: stable shield conflicts, handoff, slot reuse and cancellation."""
import json
from pathlib import Path
import re
import subprocess
import tempfile
REPO = Path(__file__).resolve().parents[2]
AJI = REPO / 'zig-out/bin/aji'
CORPUS = REPO / 'tests/conformance'
checks = 0
def cli(*args, code=0):
global checks
p = subprocess.run([str(AJI), *map(str, args)], capture_output=True)
checks += 1
assert p.returncode == code and not p.stderr, (args, p.returncode, p.stdout, p.stderr)
return p.stdout
def location(path, text):
rows = [(i + 1, line.index(text) + 1) for i, line in enumerate(path.read_text().splitlines()) if text in line]
assert len(rows) == 1, rows
return rows[0]
with tempfile.TemporaryDirectory(prefix='aji-shield-relations-') as directory:
root = Path(directory)
first = CORPUS / 'phase3/reject/shield_index_first_conflict.air'
joined = CORPUS / 'phase3/reject/shield_index_join_priority.air'
for path in (first, joined):
output = cli('check', path, code=1)
ds = [json.loads(line) for line in output.splitlines()]
assert [d['code'] for d in ds] == (['E4305'] if path == first else ['E3002', 'E4305']), ds
conflict = ds[-1]
if path == first:
expected = ('%a', '%b', 'entry', 5)
site = 'task.shield.end %a'
else:
expected = ('%y', '%x', 'joined', 1)
site = 'task.shield.end %y'
assert ds[0]['resource'] == '%x' and (ds[0]['line'], ds[0]['col']) == location(path, 'joined(%x:')
assert (conflict['borrow'], conflict['inner'], conflict['block'], conflict['inst']) == expected, conflict
assert (conflict['line'], conflict['col']) == location(path, site), conflict
assert all(d['file'] == str(path) for d in ds), ds
for command in ('check', 'run', 'report', 'explore'):
assert cli(command, path, code=1) == output
source = CORPUS / 'source/layer8/shield_index_reuse.aji'
canonical = cli('lower', source)
formatted = root / source.name
formatted.write_bytes(cli('fmt', source))
assert cli('fmt', formatted) == formatted.read_bytes()
assert cli('lower', formatted) == canonical
lowered = root / 'shield_index_reuse.air'
lowered.write_bytes(canonical)
cli('check', lowered)
positives = [
CORPUS / 'phase3/run/shield_index_handoff.air',
CORPUS / 'phase3/run/shield_index_reuse.air',
source, lowered,
CORPUS / 'phase3/run/cancel_shield.air',
CORPUS / 'source/layer8/cancel_shield.aji',
]
for path in positives:
cli('check', path)
grants = re.findall(r'^[;/]+ grant: (.+)$', path.read_text(), re.M)
args = [argument for grant in grants for argument in ('--grant', grant)]
expected = 105 if path.stem == 'cancel_shield' else 42
for quantum in (1, 5):
for seed in (0, 7, 31):
for fuel in (0, 1, 4, 16, 64, 256, 10000):
p = subprocess.run([str(AJI), 'run', '--fuel', str(fuel), '--quantum', str(quantum),
'--schedule-seed', str(seed), *args, str(path)], capture_output=True)
checks += 1
assert p.returncode in (0, 5) and not p.stderr, (path, p)
record = json.loads(p.stdout)
assert record['status'] == ('returned' if p.returncode == 0 else 'limit_exceeded'), record
if p.returncode == 0:
assert record['value'] == expected, (path, record)
if fuel == 10000:
assert p.returncode == 0, (path, record)
result = root / 'hosted.json'
for seed in (0, 7, 31):
cli('run', '--profile', 'hosted', '--result-file', result, '--fuel', '10000',
'--quantum', '1', '--schedule-seed', str(seed), *args, path)
assert json.loads(result.read_text())['value'] == expected
print(f'shield relations passed ({checks} CLI checks)')