File size: 1,635 Bytes
6993919
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- RMI v5.0 ClickHouse Schema (T07)
-- Apply: docker exec rmi-clickhouse clickhouse-client < infra/clickhouse_schema.sql
-- Idempotent: all CREATE statements use IF NOT EXISTS.

CREATE DATABASE IF NOT EXISTS rmi;

USE rmi;

CREATE TABLE IF NOT EXISTS x402_revenue (
    tx_hash       String,
    tool_id       String,
    agent_id      String,
    amount_usd    Float64,
    chain         String,
    paid_at       DateTime,
    tier          String
) ENGINE = MergeTree() ORDER BY paid_at;

CREATE TABLE IF NOT EXISTS mcp_calls (
    call_id       String,
    tool_id       String,
    agent_id      String,
    latency_ms    UInt32,
    success       UInt8,
    called_at     DateTime
) ENGINE = MergeTree() ORDER BY called_at;

CREATE TABLE IF NOT EXISTS indexer_lag (
    chain         String,
    block_lag     UInt32,
    last_block    UInt64,
    updated_at    DateTime
) ENGINE = MergeTree() ORDER BY (chain, updated_at);

CREATE TABLE IF NOT EXISTS reputation_deltas (
    deployer_id   String,
    old_alpha     UInt32,
    old_beta      UInt32,
    new_alpha     UInt32,
    new_beta      UInt32,
    event_type    String,
    updated_at    DateTime
) ENGINE = MergeTree() ORDER BY (deployer_id, updated_at);

CREATE TABLE IF NOT EXISTS cost_attribution (
    ts                    DateTime,
    tool_id               String,
    agent_id              String,
    llm_tokens_cents      UInt32,
    rpc_requests_cents    UInt32,
    storage_reads_cents   UInt32,
    compute_cents         UInt32,
    price_charged_cents   UInt32
) ENGINE = MergeTree()
      ORDER BY (ts, tool_id, agent_id)
      PARTITION BY toYYYYMM(ts);