-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
120 lines (110 loc) · 3.83 KB
/
schema.sql
File metadata and controls
120 lines (110 loc) · 3.83 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
-- 82ch MCP Observer Database - 간단한 초기화 스크립트
-- 1. 원시 이벤트 (mcpTag, serverName 추가)
CREATE TABLE IF NOT EXISTS raw_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ts BIGINT NOT NULL,
producer TEXT NOT NULL,
pid INTEGER,
pname TEXT,
event_type TEXT NOT NULL,
mcpTag TEXT,
data TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_raw_ts ON raw_events(ts);
CREATE INDEX IF NOT EXISTS idx_raw_event_type ON raw_events(event_type);
CREATE INDEX IF NOT EXISTS idx_raw_mcpTag ON raw_events(mcpTag);
-- 2. RPC 이벤트
CREATE TABLE IF NOT EXISTS rpc_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
mcptype TEXT NOT NULL,
mcptag TEXT NOT NULL,
raw_event_id INTEGER,
ts BIGINT NOT NULL,
direction TEXT NOT NULL,
method TEXT,
message_id TEXT,
params TEXT,
result TEXT,
error TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (raw_event_id) REFERENCES raw_events(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_rpc_direction ON rpc_events(direction);
CREATE INDEX IF NOT EXISTS idx_rpc_method ON rpc_events(method);
-- 3. 파일 이벤트
CREATE TABLE IF NOT EXISTS file_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
raw_event_id INTEGER,
ts BIGINT NOT NULL,
pid INTEGER,
pname TEXT,
operation TEXT,
file_path TEXT,
old_path TEXT,
new_path TEXT,
size INTEGER,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (raw_event_id) REFERENCES raw_events(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_file_path ON file_events(file_path);
-- 4. 프로세스 이벤트
CREATE TABLE IF NOT EXISTS process_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
raw_event_id INTEGER,
ts BIGINT NOT NULL,
pid INTEGER NOT NULL,
pname TEXT,
parent_pid INTEGER,
command_line TEXT,
operation TEXT,
exit_code INTEGER,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (raw_event_id) REFERENCES raw_events(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_proc_pid ON process_events(pid);
-- 5. 엔진 결과
CREATE TABLE IF NOT EXISTS engine_results (
id INTEGER PRIMARY KEY AUTOINCREMENT,
raw_event_id INTEGER,
engine_name TEXT NOT NULL,
serverName TEXT,
producer TEXT,
severity TEXT,
score INTEGER,
detail TEXT,
tool_name TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (raw_event_id) REFERENCES raw_events(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_engine_name ON engine_results(engine_name);
CREATE INDEX IF NOT EXISTS idx_serverName ON engine_results(serverName);
CREATE INDEX IF NOT EXISTS idx_tool_name ON engine_results(tool_name);
-- 6. 시스템 메타데이터
CREATE TABLE IF NOT EXISTS system_metadata (
key TEXT PRIMARY KEY,
value TEXT NOT NULL,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
INSERT OR IGNORE INTO system_metadata (key, value) VALUES ('db_version', '1.0');
INSERT OR IGNORE INTO system_metadata (key, value) VALUES ('created_at', datetime('now'));
-- -- 7. MCPL(tools/call)
Create table if not exists mcpl (
mcpTag TEXT NOT NULL , -- mcpTag
producer TEXT NOT NULL , -- producer
tool TEXT NOT NULL , -- name
tool_title TEXT , -- title
tool_description TEXT , -- description
tool_parameter TEXT , -- inputschema
annotations TEXT , -- annotations
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tool, tool_description)
);
-- -- MCPL Schema(chiled table)
-- Create table if not exists mcpl_schemas (
-- tool text PRIMARY key,
-- schema_tyep text not null, -- e.g., object
-- properties text,
-- created_at DATATIME DEFAULT CURRENT_TIMESTAMP
-- FOREIGN KEY (tool) REFERENCES mcpl_event(tool) ON DELETE CASCADE
-- );