1
-- Agent treasury eval preflight.
2
-- One pinned base state, one product branch per candidate, one stable run decision readout.
3
CREATE OR REPLACE TEMP TABLE pinned_block AS
4
SELECT number AS block_number, hash AS block_hash
5
FROM get_block($transport, 21000000);
6
7
CREATE OR REPLACE TEMP TABLE route_base AS
8
SELECT evm_create_sim_at(
9
1::UBIGINT,
10
block_number::UBIGINT,
11
block_hash::BYTES32,
12
'treasury_agent_preflight_base',
13
'cancun'::EVM_VERSION
14
) AS sim_id
15
FROM pinned_block;
16
17
CREATE OR REPLACE TEMP TABLE route_workflow AS
18
SELECT evm_execute_candidate_bundle(
19
'[
20
{
21
"source_label":"agent_original_stale_quote",
22
"member":{"role":"subject"},
23
"branch":{"role":"candidate","label":"agent_original_stale_quote"},
24
"steps":[{"payload_kind":"bytecode","payload":{"address":"0x1111111111111111111111111111111111111111","bytecode":"0x00"}}]
25
},
26
{
27
"source_label":"agent_repair_denylisted_hop",
28
"member":{"role":"alternative"},
29
"branch":{"role":"candidate","label":"agent_repair_denylisted_hop"},
30
"steps":[{"payload_kind":"bytecode","payload":{"address":"0x2222222222222222222222222222222222222222","bytecode":"0x00"}}]
31
},
32
{
33
"source_label":"agent_repair_safe_direct",
34
"member":{"role":"alternative"},
35
"branch":{"role":"candidate","label":"agent_repair_safe_direct"},
36
"steps":[{"payload_kind":"bytecode","payload":{"address":"0x3333333333333333333333333333333333333333","bytecode":"0x00"}}]
37
}
38
]'::JSON,
39
(
40
'{"base_sim_id":' ||
41
(SELECT sim_id::VARCHAR FROM route_base) ||
42
',"selected_state_policy":{},"label":"treasury-agent-preflight"}'
43
)::JSON,
44
$route_policy::JSON,
45
'{"execution":{"gas":500000}}'::JSON
46
) AS result;
47
48
CREATE OR REPLACE TEMP TABLE route_scores AS
49
SELECT *
50
FROM (VALUES
51
-- 33 more lines load when JavaScript runs