Files
aji/docs/design/contract-runtime-vectors.json

380 lines
11 KiB
JSON

{
"purpose": "Non-normative runtime research: baseline groups are executed current-language programs; context components are unimplemented schema vectors, not compiler output.",
"compiler": "2db752d",
"cli_runs": 16,
"baseline_groups": [
{
"case": "ordinary_call_return",
"suffix": "air",
"source": [
"module contract.runtime",
"air 0",
"lang 0.1",
"features [effects]",
"fn @main() -> u64",
"effects []",
"entry:",
" %v = call @leaf()",
" ret %v",
"fn @leaf() -> u64",
"effects []",
"entry:",
" %v = const.u64 42",
" ret %v"
],
"runs": [
{
"fuel": 0,
"quantum": 1,
"exit_code": 5,
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 0, "steps": 0}
},
{
"fuel": 1,
"quantum": 1,
"exit_code": 5,
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 1, "steps": 1}
},
{
"fuel": 2,
"quantum": 1,
"exit_code": 5,
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 2, "steps": 2}
},
{
"fuel": 3,
"quantum": 1,
"exit_code": 5,
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 3, "steps": 3}
},
{
"fuel": 4,
"quantum": 1,
"exit_code": 0,
"record": {"status": "returned", "value": 42}
}
]
},
{
"case": "helper_trap_last_fuel",
"suffix": "air",
"source": [
"module contract.runtime",
"air 0",
"lang 0.1",
"features [effects]",
"fn @main() -> void",
"effects []",
"entry:",
" call @fail()",
" ret",
"fn @fail() -> void",
"effects []",
"entry:",
" %v = const.bool false",
" assert %v",
" ret"
],
"runs": [
{
"fuel": 2,
"quantum": 1,
"exit_code": 5,
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 2, "steps": 2}
},
{
"fuel": 3,
"quantum": 1,
"exit_code": 4,
"record": {"status": "trapped", "code": "T0002", "kind": "trap.assert", "function": "fail", "block": "entry", "inst": 1}
}
]
},
{
"case": "call_depth_before_next_fuel",
"suffix": "air",
"source": [
"module contract.runtime",
"air 0",
"lang 0.1",
"features [effects]",
"fn @main() -> void",
"effects []",
"entry:",
" call @rec()",
" ret",
"fn @rec() -> void",
"effects []",
"entry:",
" call @rec()",
" ret"
],
"runs": [
{
"fuel": 1023,
"quantum": 1,
"exit_code": 5,
"record": {"status": "limit_exceeded", "kind": "fuel", "limit": 1023, "steps": 1023}
},
{
"fuel": 1024,
"quantum": 1,
"exit_code": 4,
"record": {"status": "trapped", "code": "T0007", "kind": "trap.call_depth", "function": "rec", "block": "entry", "inst": 0}
}
]
},
{
"case": "linear_owner_across_return",
"suffix": "aji",
"source": [
"module contract.runtime",
"fn pass(o: own<u64>) -> own<u64> effects [] { return move o; }",
"fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {",
" let owner = own.new(42u64, heap) or trap;",
" let after = pass(move owner);",
" return own.take(move after);",
"}"
],
"grants": ["heap=mem.alloc:4096"],
"runs": [
{
"fuel": 10000,
"quantum": 1,
"exit_code": 0,
"record": {
"status": "returned",
"value": 42,
"stdout": "",
"stderr": "",
"files": {}
}
}
]
},
{
"case": "mapped_helper_trap",
"suffix": "aji",
"source": ["module contract.runtime", "fn fail() -> void effects [] {", " assert(false);", "}", "fn main() -> void effects [] { fail(); }"],
"runs": [
{
"fuel": 10000,
"quantum": 1,
"exit_code": 4,
"record": {
"status": "trapped",
"code": "T0002",
"kind": "trap.assert",
"function": "fail",
"block": "entry",
"inst": 1,
"source_location": {"file": ".zig-cache/contract-gate/runtime/mapped_helper_trap.aji", "line": 3, "col": 5}
}
}
]
},
{
"case": "child_task_global_trap",
"suffix": "air",
"source": [
"module contract.runtime",
"air 0",
"lang 0.1",
"features [effects, ownership, tasks]",
"fn @main() -> void",
"effects [task.spawn, task.wait]",
"entry:",
" %s = task.scope.begin",
" %t = task.spawn %s, @worker()",
" task.join %t",
" task.scope.end %s",
" ret",
"fn @worker() -> void",
"effects []",
"entry:",
" %v = const.bool false",
" assert %v",
" ret"
],
"runs": [
{
"fuel": 10000,
"quantum": 1,
"schedule_seed": 0,
"exit_code": 4,
"record": {
"status": "trapped",
"code": "T0002",
"kind": "trap.assert",
"function": "worker",
"block": "entry",
"inst": 1,
"schedule": {"seed": 0, "quantum": 1, "choices": 1}
}
},
{
"fuel": 10000,
"quantum": 1,
"schedule_seed": 1,
"exit_code": 4,
"record": {
"status": "trapped",
"code": "T0002",
"kind": "trap.assert",
"function": "worker",
"block": "entry",
"inst": 1,
"schedule": {"seed": 1, "quantum": 1, "choices": 2}
}
},
{
"fuel": 10000,
"quantum": 1,
"schedule_seed": 2,
"exit_code": 4,
"record": {
"status": "trapped",
"code": "T0002",
"kind": "trap.assert",
"function": "worker",
"block": "entry",
"inst": 1,
"schedule": {"seed": 2, "quantum": 1, "choices": 2}
}
},
{
"fuel": 10000,
"quantum": 1,
"schedule_seed": 3,
"exit_code": 4,
"record": {
"status": "trapped",
"code": "T0002",
"kind": "trap.assert",
"function": "worker",
"block": "entry",
"inst": 1,
"schedule": {"seed": 3, "quantum": 1, "choices": 1}
}
},
{
"fuel": 10000,
"quantum": 1,
"schedule_seed": 4,
"exit_code": 4,
"record": {
"status": "trapped",
"code": "T0002",
"kind": "trap.assert",
"function": "worker",
"block": "entry",
"inst": 1,
"schedule": {"seed": 4, "quantum": 1, "choices": 2}
}
}
]
}
],
"gc_baseline": {
"fixtures": 9,
"schedule_cases": 13,
"interpreter_runs": 26,
"quantum": 1,
"child_schedule_seeds": 5,
"normal_vs_collect_every_step": "byte_identical",
"detect_races": true,
"source_headers": "// metadata for .aji; ; metadata for AIR"
},
"context_components": [
{
"case": "false_pre",
"expected_code": "T0011",
"primary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"contract": {
"kind": "pre",
"mode": "runtime",
"phase": "predicate",
"helper": "p",
"task": 0,
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"boundary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"at": {"function": "p", "block": "entry", "inst": 1, "air_line": 21, "air_col": 2}
}
},
{
"case": "false_post",
"expected_code": "T0012",
"primary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"contract": {
"kind": "post",
"mode": "runtime",
"phase": "predicate",
"helper": "p",
"task": 0,
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"boundary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
"at": {"function": "p", "block": "entry", "inst": 1, "air_line": 21, "air_col": 2}
}
},
{
"case": "implicit_post_depth",
"expected_code": "T0007",
"primary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
"contract": {
"kind": "post",
"mode": "runtime",
"phase": "predicate",
"helper": "p",
"task": 0,
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"boundary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
"at": null
}
},
{
"case": "predicate_arithmetic_trap",
"expected_code": "T0003",
"primary": {"function": "descendant", "block": "entry", "inst": 2, "air_line": 27, "air_col": 2},
"contract": {
"kind": "post",
"mode": "runtime",
"phase": "predicate",
"helper": "p",
"task": 0,
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"boundary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
"at": {"function": "descendant", "block": "entry", "inst": 2, "air_line": 27, "air_col": 2}
}
},
{
"case": "callback_fuel_cut",
"expected_status": "limit_exceeded",
"contract": {
"kind": "modify",
"mode": "runtime",
"phase": "callback",
"helper": "update",
"task": 0,
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"boundary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"at": {"function": "update", "block": "loop", "inst": 3, "air_line": 34, "air_col": 2}
}
},
{
"case": "assumed_post_false_in_child",
"expected_code": "T0009",
"primary": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"contract": {
"kind": "post",
"mode": "assume",
"phase": "predicate",
"helper": "p",
"task": 3,
"site": {"function": "f", "block": "entry", "inst": 0, "air_line": 8, "air_col": 2},
"boundary": {"function": "f", "block": "exit", "inst": 2, "air_line": 15, "air_col": 2},
"at": {"function": "p", "block": "entry", "inst": 1, "air_line": 21, "air_col": 2}
}
}
]
}