-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentinel_api.h
More file actions
278 lines (209 loc) · 8.5 KB
/
sentinel_api.h
File metadata and controls
278 lines (209 loc) · 8.5 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/*
sentinel_api.h
Unified public API for all Sentinel systems.
Matches sentinel_api.c exactly.
*/
#ifndef SENTINEL_API_H
#define SENTINEL_API_H
/* -------------------------------------------------------------
Core Types
------------------------------------------------------------- */
typedef int SenBool;
typedef int SenStatus;
#define SEN_TRUE 1
#define SEN_FALSE 0
#define SEN_STATUS_OK 0
#define SEN_STATUS_ERROR_INVALID_ARGUMENT -1
#define SEN_STATUS_ERROR_INTERNAL -2
typedef struct SenString {
const char* data;
int length;
} SenString;
typedef struct SenDirectory SenDirectory;
typedef struct SentinelContext SentinelContext;
/* Repo types */
typedef enum SenRepoType {
SEN_REPO_TYPE_UNKNOWN = 0,
SEN_REPO_TYPE_CORE,
SEN_REPO_TYPE_LANGUAGE,
SEN_REPO_TYPE_TOOLING,
SEN_REPO_TYPE_EXAMPLE,
SEN_REPO_TYPE_EXPERIMENT
} SenRepoType;
/* -------------------------------------------------------------
Boot
------------------------------------------------------------- */
typedef struct SentinelBoot {
SentinelContext ctx;
SenBool ready;
} SentinelBoot;
SenStatus sentinel_boot_system(SentinelBoot* boot, const char* repo_root);
void sentinel_shutdown_system(SentinelBoot* boot);
/* -------------------------------------------------------------
Robot Protocol
------------------------------------------------------------- */
typedef struct SentinelRobotProtocol {
const char** traversal;
int traversal_count;
const char** search;
int search_count;
SenBool active;
} SentinelRobotProtocol;
SenStatus sentinel_robot_protocol_activate(SentinelContext* ctx);
void sentinel_robot_protocol_shutdown(SentinelContext* ctx);
SenStatus sentinel_robot_locate(SentinelContext* ctx,
const char* repo_name,
SenDirectory** out_dir);
SenStatus sentinel_robot_return_home(SentinelContext* ctx,
SenDirectory** out_dir);
SenStatus sentinel_get_traversal_order(SentinelContext* ctx,
const char*** out_names,
int* out_count);
SenStatus sentinel_get_search_order(SentinelContext* ctx,
const char*** out_patterns,
int* out_count);
SenStatus sentinel_resolve_repo(SentinelContext* ctx,
const char* repo_name,
SenDirectory** out_dir);
/* -------------------------------------------------------------
Training
------------------------------------------------------------- */
typedef struct SentinelKnowledgeRepo {
SenString name;
SenString path;
int file_count_estimate;
} SentinelKnowledgeRepo;
typedef struct SentinelKnowledge {
SentinelKnowledgeRepo* repos;
int repo_count;
SenBool trained;
} SentinelKnowledge;
SenStatus sentinel_train_begin(SentinelBoot* boot,
SentinelKnowledge* knowledge);
SenStatus sentinel_train_walk_traversal(SentinelBoot* boot,
SentinelKnowledge* knowledge);
SenStatus sentinel_train_scan_search(SentinelBoot* boot,
SentinelKnowledge* knowledge);
SenStatus sentinel_train_commit(SentinelBoot* boot,
SentinelKnowledge* knowledge);
/* -------------------------------------------------------------
Self-Search
------------------------------------------------------------- */
typedef struct SentinelSelfSearchPattern {
SenString pattern;
} SentinelSelfSearchPattern;
typedef struct SentinelSelfSearchSet {
SentinelSelfSearchPattern* items;
int count;
} SentinelSelfSearchSet;
SenStatus sentinel_selfsearch_get_patterns_for_type(SenRepoType type,
SentinelSelfSearchSet* out_set);
void sentinel_selfsearch_free_patterns(SentinelSelfSearchSet* set);
SenStatus sentinel_selfsearch_repo(SentinelBoot* boot,
SentinelKnowledge* knowledge,
const char* repo_name);
/* -------------------------------------------------------------
Autoscan
------------------------------------------------------------- */
SenStatus sentinel_autoscan_all(SentinelBoot* boot,
SentinelKnowledge* knowledge);
/* -------------------------------------------------------------
Memory Graph
------------------------------------------------------------- */
typedef struct SenGraphNode {
SenString name;
SenRepoType type;
} SenGraphNode;
typedef struct SenGraphEdge {
SenString from;
SenString to;
SenString relation;
} SenGraphEdge;
typedef struct SenGraph {
SenGraphNode* nodes;
int node_count;
SenGraphEdge* edges;
int edge_count;
} SenGraph;
SenStatus sentinel_graph_init(SenGraph* graph);
SenStatus sentinel_graph_add_node(SenGraph* graph,
const char* name,
SenRepoType type);
SenStatus sentinel_graph_add_edge(SenGraph* graph,
const char* from,
const char* to,
const char* relation);
void sentinel_graph_free(SenGraph* graph);
SenStatus sentinel_graph_build(SenGraph* graph);
/* -------------------------------------------------------------
AI Reasoning
------------------------------------------------------------- */
typedef struct SentinelAI {
SenBool active;
} SentinelAI;
SenStatus sentinel_ai_activate(SentinelAI* ai);
SenStatus sentinel_ai_infer_edges(SentinelAI* ai, SenGraph* graph);
SenStatus sentinel_ai_detect_anomalies(SentinelAI* ai, SenGraph* graph);
SenStatus sentinel_ai_optimize_traversal(SentinelAI* ai, SenGraph* graph);
SenStatus sentinel_ai_selfheal(SentinelAI* ai, SenGraph* graph);
/* -------------------------------------------------------------
AI-CORE
------------------------------------------------------------- */
typedef enum SenAIAction {
SEN_AI_ACTION_NONE = 0,
SEN_AI_ACTION_SCAN,
SEN_AI_ACTION_REPAIR,
SEN_AI_ACTION_INFER,
SEN_AI_ACTION_OPTIMIZE,
SEN_AI_ACTION_CLASSIFY,
SEN_AI_ACTION_EXPAND,
SEN_AI_ACTION_ALERT
} SenAIAction;
typedef struct SentinelAICore {
SenBool active;
} SentinelAICore;
SenStatus sentinel_aicore_activate(SentinelAICore* core);
SenAIAction sentinel_aicore_decide(SentinelAICore* core,
SenGraph* graph,
SentinelKnowledge* knowledge);
SenStatus sentinel_aicore_execute(SentinelAICore* core,
SenAIAction action,
SentinelBoot* boot,
SenGraph* graph,
SentinelKnowledge* knowledge);
/* -------------------------------------------------------------
Sentinel Prime
------------------------------------------------------------- */
typedef struct SentinelPrime {
SentinelBoot boot;
SentinelKnowledge knowledge;
SenGraph graph;
SentinelAI ai;
SentinelAICore core;
SenBool active;
} SentinelPrime;
SenStatus sentinel_prime_activate(SentinelPrime* prime,
const char* repo_root);
SenStatus sentinel_prime_loop(SentinelPrime* prime);
/* -------------------------------------------------------------
Sentinel Overmind
------------------------------------------------------------- */
typedef struct SentinelMicro {
SentinelPrime prime;
SenString repo_name;
} SentinelMicro;
typedef struct SentinelOvermind {
SentinelMicro* micros;
int micro_count;
SenBool active;
} SentinelOvermind;
SenStatus sentinel_overmind_activate(SentinelOvermind* om,
const char** repo_names,
int repo_count,
const char* root);
SenStatus sentinel_overmind_sync(SentinelOvermind* om);
SenStatus sentinel_overmind_collective_decide(SentinelOvermind* om,
SenAIAction* out_action);
SenStatus sentinel_overmind_collective_execute(SentinelOvermind* om,
SenAIAction action);
#endif /* SENTINEL_API_H */