1pub const TIMEOUT_RESULT_V1: &str =
60 "https://schemas.3leaps.dev/sysprims/timeout/v1.0.0/timeout-result.schema.json";
61
62pub const TIMEOUT_RESULT_V1_1: &str =
64 "https://schemas.3leaps.dev/sysprims/timeout/v1.1.0/timeout-result.schema.json";
65
66pub const PROCESS_INFO_V1: &str =
72 "https://schemas.3leaps.dev/sysprims/process/v1.1.0/process-info.schema.json";
73
74pub const PROCESS_INFO_SAMPLED_V1: &str =
81 "https://schemas.3leaps.dev/sysprims/process/v1.1.0/process-info-sampled.schema.json";
82
83pub const PROC_FILTER_V1: &str =
90 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/process-filter.schema.json";
91
92pub const PORT_BINDINGS_V1: &str =
98 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/port-bindings.schema.json";
99
100pub const PORT_FILTER_V1: &str =
107 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/port-filter.schema.json";
108
109pub const FD_SNAPSHOT_V1: &str =
113 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/fd-snapshot.schema.json";
114
115pub const FD_FILTER_V1: &str =
119 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/fd-filter.schema.json";
120
121pub const WAIT_PID_RESULT_V1: &str =
127 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/wait-pid-result.schema.json";
128
129pub const BATCH_KILL_RESULT_V1: &str =
135 "https://schemas.3leaps.dev/sysprims/signal/v1.0.0/batch-kill-result.schema.json";
136
137pub const TERMINATE_TREE_CONFIG_V1: &str =
141 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/terminate-tree-config.schema.json";
142
143pub const TERMINATE_TREE_RESULT_V1: &str =
147 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/terminate-tree-result.schema.json";
148
149pub const SPAWN_IN_GROUP_CONFIG_V1: &str =
153 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/spawn-in-group-config.schema.json";
154
155pub const SPAWN_IN_GROUP_RESULT_V1: &str =
159 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/spawn-in-group-result.schema.json";
160
161pub const RUN_SETSID_CONFIG_V1: &str =
165 "https://schemas.3leaps.dev/sysprims/session/v1.0.0/run-setsid-config.schema.json";
166
167pub const RUN_NOHUP_CONFIG_V1: &str =
171 "https://schemas.3leaps.dev/sysprims/session/v1.0.0/run-nohup-config.schema.json";
172
173pub const SESSION_SPAWN_RESULT_V1: &str =
177 "https://schemas.3leaps.dev/sysprims/session/v1.0.0/session-spawn-result.schema.json";
178
179pub const DESCENDANTS_RESULT_V1: &str =
185 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/descendants-result.schema.json";
186
187pub const DESCENDANTS_RESULT_SAMPLED_V1: &str =
194 "https://schemas.3leaps.dev/sysprims/process/v1.1.0/descendants-result-sampled.schema.json";
195
196pub const GUARD_EVENT_V1: &str =
202 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/guard-event.schema.json";
203
204pub const ANCESTORS_RESULT_V1: &str =
210 "https://schemas.3leaps.dev/sysprims/process/v1.0.0/ancestors-result.schema.json";
211
212pub const SCHEMA_HOST: &str = "https://schemas.3leaps.dev";
218
219pub const SCHEMA_MODULE: &str = "sysprims";
221
222#[cfg(test)]
223mod tests {
224 use super::*;
225
226 #[test]
227 fn test_schema_ids_are_valid_urls() {
228 assert!(TIMEOUT_RESULT_V1.starts_with("https://"));
230 assert!(TIMEOUT_RESULT_V1_1.starts_with("https://"));
231 assert!(PROCESS_INFO_V1.starts_with("https://"));
232 assert!(PROCESS_INFO_SAMPLED_V1.starts_with("https://"));
233 assert!(PROC_FILTER_V1.starts_with("https://"));
234 assert!(PORT_BINDINGS_V1.starts_with("https://"));
235 assert!(PORT_FILTER_V1.starts_with("https://"));
236 assert!(FD_SNAPSHOT_V1.starts_with("https://"));
237 assert!(FD_FILTER_V1.starts_with("https://"));
238 assert!(WAIT_PID_RESULT_V1.starts_with("https://"));
239 assert!(BATCH_KILL_RESULT_V1.starts_with("https://"));
240 assert!(TERMINATE_TREE_CONFIG_V1.starts_with("https://"));
241 assert!(TERMINATE_TREE_RESULT_V1.starts_with("https://"));
242 assert!(SPAWN_IN_GROUP_CONFIG_V1.starts_with("https://"));
243 assert!(SPAWN_IN_GROUP_RESULT_V1.starts_with("https://"));
244 assert!(RUN_SETSID_CONFIG_V1.starts_with("https://"));
245 assert!(RUN_NOHUP_CONFIG_V1.starts_with("https://"));
246 assert!(SESSION_SPAWN_RESULT_V1.starts_with("https://"));
247 assert!(DESCENDANTS_RESULT_V1.starts_with("https://"));
248 assert!(DESCENDANTS_RESULT_SAMPLED_V1.starts_with("https://"));
249 assert!(GUARD_EVENT_V1.starts_with("https://"));
250 assert!(ANCESTORS_RESULT_V1.starts_with("https://"));
251 }
252
253 #[test]
254 fn test_schema_ids_use_3leaps_host() {
255 let expected_prefix = "https://schemas.3leaps.dev/sysprims/";
257
258 assert!(
259 TIMEOUT_RESULT_V1.starts_with(expected_prefix),
260 "Expected 3leaps.dev host"
261 );
262 assert!(
263 PROCESS_INFO_V1.starts_with(expected_prefix),
264 "Expected 3leaps.dev host"
265 );
266 assert!(
267 PROCESS_INFO_SAMPLED_V1.starts_with(expected_prefix),
268 "Expected 3leaps.dev host"
269 );
270 assert!(
271 PROC_FILTER_V1.starts_with(expected_prefix),
272 "Expected 3leaps.dev host"
273 );
274 assert!(
275 PORT_BINDINGS_V1.starts_with(expected_prefix),
276 "Expected 3leaps.dev host"
277 );
278 assert!(
279 PORT_FILTER_V1.starts_with(expected_prefix),
280 "Expected 3leaps.dev host"
281 );
282 assert!(
283 FD_SNAPSHOT_V1.starts_with(expected_prefix),
284 "Expected 3leaps.dev host"
285 );
286 assert!(
287 FD_FILTER_V1.starts_with(expected_prefix),
288 "Expected 3leaps.dev host"
289 );
290 assert!(
291 WAIT_PID_RESULT_V1.starts_with(expected_prefix),
292 "Expected 3leaps.dev host"
293 );
294 assert!(
295 BATCH_KILL_RESULT_V1.starts_with(expected_prefix),
296 "Expected 3leaps.dev host"
297 );
298 assert!(
299 TERMINATE_TREE_CONFIG_V1.starts_with(expected_prefix),
300 "Expected 3leaps.dev host"
301 );
302 assert!(
303 TERMINATE_TREE_RESULT_V1.starts_with(expected_prefix),
304 "Expected 3leaps.dev host"
305 );
306 assert!(
307 SPAWN_IN_GROUP_CONFIG_V1.starts_with(expected_prefix),
308 "Expected 3leaps.dev host"
309 );
310 assert!(
311 SPAWN_IN_GROUP_RESULT_V1.starts_with(expected_prefix),
312 "Expected 3leaps.dev host"
313 );
314 assert!(
315 RUN_SETSID_CONFIG_V1.starts_with(expected_prefix),
316 "Expected 3leaps.dev host"
317 );
318 assert!(
319 RUN_NOHUP_CONFIG_V1.starts_with(expected_prefix),
320 "Expected 3leaps.dev host"
321 );
322 assert!(
323 SESSION_SPAWN_RESULT_V1.starts_with(expected_prefix),
324 "Expected 3leaps.dev host"
325 );
326 assert!(
327 DESCENDANTS_RESULT_V1.starts_with(expected_prefix),
328 "Expected 3leaps.dev host"
329 );
330 assert!(
331 DESCENDANTS_RESULT_SAMPLED_V1.starts_with(expected_prefix),
332 "Expected 3leaps.dev host"
333 );
334 assert!(
335 GUARD_EVENT_V1.starts_with(expected_prefix),
336 "Expected 3leaps.dev host"
337 );
338 assert!(
339 ANCESTORS_RESULT_V1.starts_with(expected_prefix),
340 "Expected 3leaps.dev host"
341 );
342 }
343
344 #[test]
345 fn test_schema_ids_follow_canonical_uri_pattern() {
346 assert!(TIMEOUT_RESULT_V1.ends_with(".schema.json"));
350 assert!(PROCESS_INFO_V1.ends_with(".schema.json"));
351 assert!(PROCESS_INFO_SAMPLED_V1.ends_with(".schema.json"));
352 assert!(PROC_FILTER_V1.ends_with(".schema.json"));
353 assert!(PORT_BINDINGS_V1.ends_with(".schema.json"));
354 assert!(PORT_FILTER_V1.ends_with(".schema.json"));
355 assert!(FD_SNAPSHOT_V1.ends_with(".schema.json"));
356 assert!(FD_FILTER_V1.ends_with(".schema.json"));
357 assert!(WAIT_PID_RESULT_V1.ends_with(".schema.json"));
358 assert!(BATCH_KILL_RESULT_V1.ends_with(".schema.json"));
359 assert!(TERMINATE_TREE_CONFIG_V1.ends_with(".schema.json"));
360 assert!(TERMINATE_TREE_RESULT_V1.ends_with(".schema.json"));
361 assert!(SPAWN_IN_GROUP_CONFIG_V1.ends_with(".schema.json"));
362 assert!(SPAWN_IN_GROUP_RESULT_V1.ends_with(".schema.json"));
363 assert!(RUN_SETSID_CONFIG_V1.ends_with(".schema.json"));
364 assert!(RUN_NOHUP_CONFIG_V1.ends_with(".schema.json"));
365 assert!(SESSION_SPAWN_RESULT_V1.ends_with(".schema.json"));
366 assert!(DESCENDANTS_RESULT_V1.ends_with(".schema.json"));
367 assert!(DESCENDANTS_RESULT_SAMPLED_V1.ends_with(".schema.json"));
368 assert!(GUARD_EVENT_V1.ends_with(".schema.json"));
369 assert!(ANCESTORS_RESULT_V1.ends_with(".schema.json"));
370
371 assert!(PROCESS_INFO_V1.contains("/v1.1.0/"));
373 assert!(PROCESS_INFO_SAMPLED_V1.contains("/v1.1.0/"));
374 assert!(DESCENDANTS_RESULT_SAMPLED_V1.contains("/v1.1.0/"));
375
376 assert!(TIMEOUT_RESULT_V1.contains("/v1.0.0/"));
378 assert!(PROC_FILTER_V1.contains("/v1.0.0/"));
379 assert!(PORT_BINDINGS_V1.contains("/v1.0.0/"));
380 assert!(PORT_FILTER_V1.contains("/v1.0.0/"));
381 assert!(FD_SNAPSHOT_V1.contains("/v1.0.0/"));
382 assert!(FD_FILTER_V1.contains("/v1.0.0/"));
383 assert!(WAIT_PID_RESULT_V1.contains("/v1.0.0/"));
384 assert!(BATCH_KILL_RESULT_V1.contains("/v1.0.0/"));
385 assert!(TERMINATE_TREE_CONFIG_V1.contains("/v1.0.0/"));
386 assert!(TERMINATE_TREE_RESULT_V1.contains("/v1.0.0/"));
387 assert!(SPAWN_IN_GROUP_CONFIG_V1.contains("/v1.0.0/"));
388 assert!(SPAWN_IN_GROUP_RESULT_V1.contains("/v1.0.0/"));
389 assert!(RUN_SETSID_CONFIG_V1.contains("/v1.0.0/"));
390 assert!(RUN_NOHUP_CONFIG_V1.contains("/v1.0.0/"));
391 assert!(SESSION_SPAWN_RESULT_V1.contains("/v1.0.0/"));
392 assert!(DESCENDANTS_RESULT_V1.contains("/v1.0.0/"));
393 assert!(GUARD_EVENT_V1.contains("/v1.0.0/"));
394 assert!(ANCESTORS_RESULT_V1.contains("/v1.0.0/"));
395 }
396
397 #[test]
398 fn test_schema_ids_have_correct_topics() {
399 assert!(
401 TIMEOUT_RESULT_V1.contains("/timeout/"),
402 "timeout schema should have timeout topic"
403 );
404 assert!(
405 PROCESS_INFO_V1.contains("/process/"),
406 "process-info schema should have process topic"
407 );
408 assert!(
409 PROCESS_INFO_SAMPLED_V1.contains("/process/"),
410 "process-info-sampled schema should have process topic"
411 );
412 assert!(
413 PROC_FILTER_V1.contains("/process/"),
414 "process-filter schema should have process topic"
415 );
416 assert!(
417 PORT_BINDINGS_V1.contains("/process/"),
418 "port-bindings schema should have process topic"
419 );
420 assert!(
421 PORT_FILTER_V1.contains("/process/"),
422 "port-filter schema should have process topic"
423 );
424 assert!(
425 FD_SNAPSHOT_V1.contains("/process/"),
426 "fd-snapshot schema should have process topic"
427 );
428 assert!(
429 FD_FILTER_V1.contains("/process/"),
430 "fd-filter schema should have process topic"
431 );
432 assert!(
433 WAIT_PID_RESULT_V1.contains("/process/"),
434 "wait-pid-result schema should have process topic"
435 );
436 assert!(
437 BATCH_KILL_RESULT_V1.contains("/signal/"),
438 "batch-kill-result schema should have signal topic"
439 );
440 assert!(
441 TERMINATE_TREE_CONFIG_V1.contains("/process/"),
442 "terminate-tree-config schema should have process topic"
443 );
444 assert!(
445 TERMINATE_TREE_RESULT_V1.contains("/process/"),
446 "terminate-tree-result schema should have process topic"
447 );
448 assert!(
449 SPAWN_IN_GROUP_CONFIG_V1.contains("/process/"),
450 "spawn-in-group-config schema should have process topic"
451 );
452 assert!(
453 SPAWN_IN_GROUP_RESULT_V1.contains("/process/"),
454 "spawn-in-group-result schema should have process topic"
455 );
456 assert!(
457 RUN_SETSID_CONFIG_V1.contains("/session/"),
458 "run-setsid-config schema should have session topic"
459 );
460 assert!(
461 RUN_NOHUP_CONFIG_V1.contains("/session/"),
462 "run-nohup-config schema should have session topic"
463 );
464 assert!(
465 SESSION_SPAWN_RESULT_V1.contains("/session/"),
466 "session-spawn-result schema should have session topic"
467 );
468 assert!(
469 DESCENDANTS_RESULT_V1.contains("/process/"),
470 "descendants-result schema should have process topic"
471 );
472 assert!(
473 DESCENDANTS_RESULT_SAMPLED_V1.contains("/process/"),
474 "descendants-result-sampled schema should have process topic"
475 );
476 assert!(
477 GUARD_EVENT_V1.contains("/process/"),
478 "guard-event schema should have process topic"
479 );
480 assert!(
481 ANCESTORS_RESULT_V1.contains("/process/"),
482 "ancestors-result schema should have process topic"
483 );
484 }
485
486 #[test]
487 fn test_schema_ids_are_unique() {
488 let ids = [
489 TIMEOUT_RESULT_V1,
490 PROCESS_INFO_V1,
491 PROCESS_INFO_SAMPLED_V1,
492 PROC_FILTER_V1,
493 PORT_BINDINGS_V1,
494 PORT_FILTER_V1,
495 FD_SNAPSHOT_V1,
496 FD_FILTER_V1,
497 WAIT_PID_RESULT_V1,
498 BATCH_KILL_RESULT_V1,
499 TERMINATE_TREE_CONFIG_V1,
500 TERMINATE_TREE_RESULT_V1,
501 SPAWN_IN_GROUP_CONFIG_V1,
502 SPAWN_IN_GROUP_RESULT_V1,
503 RUN_SETSID_CONFIG_V1,
504 RUN_NOHUP_CONFIG_V1,
505 SESSION_SPAWN_RESULT_V1,
506 DESCENDANTS_RESULT_V1,
507 DESCENDANTS_RESULT_SAMPLED_V1,
508 GUARD_EVENT_V1,
509 ANCESTORS_RESULT_V1,
510 ];
511
512 for (i, a) in ids.iter().enumerate() {
514 for (j, b) in ids.iter().enumerate() {
515 if i != j {
516 assert_ne!(a, b, "Schema IDs must be unique");
517 }
518 }
519 }
520 }
521
522 #[test]
523 fn test_schema_host_constants() {
524 assert_eq!(SCHEMA_HOST, "https://schemas.3leaps.dev");
525 assert_eq!(SCHEMA_MODULE, "sysprims");
526
527 let prefix = format!("{}/{}/", SCHEMA_HOST, SCHEMA_MODULE);
529 assert!(TIMEOUT_RESULT_V1.starts_with(&prefix));
530 assert!(PROCESS_INFO_V1.starts_with(&prefix));
531 assert!(PROCESS_INFO_SAMPLED_V1.starts_with(&prefix));
532 assert!(PROC_FILTER_V1.starts_with(&prefix));
533 assert!(PORT_BINDINGS_V1.starts_with(&prefix));
534 assert!(PORT_FILTER_V1.starts_with(&prefix));
535 assert!(FD_SNAPSHOT_V1.starts_with(&prefix));
536 assert!(FD_FILTER_V1.starts_with(&prefix));
537 assert!(WAIT_PID_RESULT_V1.starts_with(&prefix));
538 assert!(BATCH_KILL_RESULT_V1.starts_with(&prefix));
539 assert!(TERMINATE_TREE_CONFIG_V1.starts_with(&prefix));
540 assert!(TERMINATE_TREE_RESULT_V1.starts_with(&prefix));
541 assert!(SPAWN_IN_GROUP_CONFIG_V1.starts_with(&prefix));
542 assert!(SPAWN_IN_GROUP_RESULT_V1.starts_with(&prefix));
543 assert!(RUN_SETSID_CONFIG_V1.starts_with(&prefix));
544 assert!(RUN_NOHUP_CONFIG_V1.starts_with(&prefix));
545 assert!(SESSION_SPAWN_RESULT_V1.starts_with(&prefix));
546 assert!(DESCENDANTS_RESULT_V1.starts_with(&prefix));
547 assert!(DESCENDANTS_RESULT_SAMPLED_V1.starts_with(&prefix));
548 assert!(GUARD_EVENT_V1.starts_with(&prefix));
549 assert!(ANCESTORS_RESULT_V1.starts_with(&prefix));
550 }
551}