From 15312b25a105dc85371401cb9758571ca3f25c92 Mon Sep 17 00:00:00 2001 From: Sathishkumar Duraisamy Date: Tue, 21 Apr 2026 13:26:46 +0200 Subject: [PATCH 1/4] Updated project directory structure Signed-off-by: Sathishkumar Duraisamy --- .gitignore | 2 + Cargo.lock | 415 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 8 + build.rs | 3 + src/lib.rs | 3 + src/main.rs | 8 + src/safeaction.rs | 0 src/safeappdb.rs | 2 + src/safeappdb/appsdb.rs | 0 src/safeappdb/global.rs | 23 +++ src/safeinstrument.rs | 0 src/safemonitor.rs | 0 12 files changed, 464 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 build.rs create mode 100644 src/lib.rs create mode 100644 src/main.rs create mode 100644 src/safeaction.rs create mode 100644 src/safeappdb.rs create mode 100644 src/safeappdb/appsdb.rs create mode 100644 src/safeappdb/global.rs create mode 100644 src/safeinstrument.rs create mode 100644 src/safemonitor.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef862 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target/ +.idea/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..eeb5f26 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,415 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "annotate-snippets" +version = "0.12.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92570a3f9c98e7e84df84b71d0965ac99b1871fcd75a3773a3bd1bad13f64cf7" +dependencies = [ + "anstyle", + "memchr", + "unicode-width", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "encoding_rs_io" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83" +dependencies = [ + "encoding_rs", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "js-sys" +version = "0.3.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e04e2ef80ce82e13552136fabeef8a5ed1f985a96805761cbb9a2c34e7664d9" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.184" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "safetyguard" +version = "0.1.0" +dependencies = [ + "serde-saphyr", +] + +[[package]] +name = "saphyr-parser-bw" +version = "0.0.611" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dec0c833db75dc98957956b303fe447ffc5eb13f2325ef4c2350f7f3aa69e3" +dependencies = [ + "arraydeque", + "smallvec", + "thiserror", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde-saphyr" +version = "0.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fbdfe7a27a1b1633dfc0c4c8e65940b8d819c5ddb9cca48ebc3223b00c8b14" +dependencies = [ + "ahash", + "annotate-snippets", + "base64", + "encoding_rs_io", + "getrandom", + "nohash-hasher", + "num-traits", + "regex", + "saphyr-parser-bw", + "serde", + "smallvec", + "zmij", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0551fc1bb415591e3372d0bc4780db7e587d84e2a7e79da121051c5c4b89d0b0" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fbdf9a35adf44786aecd5ff89b4563a90325f9da0923236f6104e603c7e86be" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dca9693ef2bab6d4e6707234500350d8dad079eb508dca05530c85dc3a529ff2" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39129a682a6d2d841b6c429d0c51e5cb0ed1a03829d8b3d1e69a011e62cb3d3b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" + +[[package]] +name = "zerocopy" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e26c1df --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "safetyguard" +version = "0.1.0" +edition = "2024" + +[dependencies] +serde-saphyr = "0.0.23" + diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..cf74f49 --- /dev/null +++ b/build.rs @@ -0,0 +1,3 @@ +fn main() { + +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..56a27a4 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,3 @@ +#![forbid(unsafe_code)] + +pub mod safeappdb; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..aac9ce3 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,8 @@ +mod safemonitor; +mod safeaction; +mod safeinstrument; +mod safeappdb; + +fn main() { + println!("Hello, world!"); +} \ No newline at end of file diff --git a/src/safeaction.rs b/src/safeaction.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/safeappdb.rs b/src/safeappdb.rs new file mode 100644 index 0000000..059665b --- /dev/null +++ b/src/safeappdb.rs @@ -0,0 +1,2 @@ +mod appsdb; +pub mod global; \ No newline at end of file diff --git a/src/safeappdb/appsdb.rs b/src/safeappdb/appsdb.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/safeappdb/global.rs b/src/safeappdb/global.rs new file mode 100644 index 0000000..87a0d83 --- /dev/null +++ b/src/safeappdb/global.rs @@ -0,0 +1,23 @@ + + +pub enum LogLevel { + debug, + info, + warn, + error, +} + +pub enum Mode { + debug, + release, +} +pub struct Global { + pub loglevel: LogLevel, + pub log_file: String, + pub state_file: String, + pub config_file: String, + pub config_file_gen: String, + pub mode: Mode, + pub endpoint: String, +} + diff --git a/src/safeinstrument.rs b/src/safeinstrument.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/safemonitor.rs b/src/safemonitor.rs new file mode 100644 index 0000000..e69de29 From 4324c254811f3ab79f54194818f906986a3e3ef1 Mon Sep 17 00:00:00 2001 From: Sathishkumar Duraisamy Date: Tue, 21 Apr 2026 13:27:50 +0200 Subject: [PATCH 2/4] Updated UML digram for Application heartbeat update Signed-off-by: Sathishkumar Duraisamy --- doc/config.yaml | 94 +++++ doc/designdecision.md | 0 doc/papyrus_uml/.project | 11 + doc/papyrus_uml/SafeGuard.aird | 534 +++++++++++++++++++++++++++++ doc/papyrus_uml/SafeGuard.di | 2 + doc/papyrus_uml/SafeGuard.notation | 364 ++++++++++++++++++++ doc/papyrus_uml/SafeGuard.uml | 64 ++++ 7 files changed, 1069 insertions(+) create mode 100644 doc/config.yaml create mode 100644 doc/designdecision.md create mode 100644 doc/papyrus_uml/.project create mode 100644 doc/papyrus_uml/SafeGuard.aird create mode 100644 doc/papyrus_uml/SafeGuard.di create mode 100644 doc/papyrus_uml/SafeGuard.notation create mode 100644 doc/papyrus_uml/SafeGuard.uml diff --git a/doc/config.yaml b/doc/config.yaml new file mode 100644 index 0000000..1738998 --- /dev/null +++ b/doc/config.yaml @@ -0,0 +1,94 @@ +# ========================= +# SafetyGuard Configuration +# +# All config parameter are lower case seperated by "_" if required. +# ========================= + +config_version: 1 + +global: + log_level: INFO + check_interval_ms: 500 # cyclic time to check states of apps + state_file: /var/lib/safetyguard/state.yaml + log_file: /var/log/safetyguard.log + init_file: /etc/safetygurad/config.yaml + init_file_gen: /var/lib/safetyguard/gen_config.yaml + mode: production # Can be development. In case of development, the app configuration + # will be generated which can act as guidance, for example heartbeat_interval_ms as average heartbeat + endpoint: /tmp/safetyguard.sock + +watchdog: + device: /dev/watchdog + timeout_sec: 10 + pretimeout_sec: 5 + kick_interval_ms: 3000 + +recovery: + system_reset_on_failure: true + max_global_failures: 5 + +system_apps: + - name: systemd + timeout_ms: 5000 + safemonitor: + - heartbeat: + heartbeat_update_interval_ms: 500 # Interval it is expected update the heartbeat to safetyguard. It should be less then heartbeat Intervals of threads. Ideally half of the minimum heartbeat interval threads. + threads: + - main: + heartbeat_interval_ms: 1000 + safeaction: + - coresystem: + restart: true + wait_time_ms: 1000 + wait_for_reboot_accept: true # for example, safeapp sends this info or user accepts reboot + - safestate: + - app_name: safeapp + manager: systemd + systemd: + - service_name: safeapp # Runs this app, till system is safe. + +apps: + - name: app_a + timeout_ms: 3000 + max_retries: 3 + critical: true + manager: systemd + systemd: + - service_name: app_a # unit file name. + safeaction: + - systemd: + restart: true + - coresystem: # If not present, system will not rebooted. + restart: true #Upon all retries failure. + - safestate: + - app_name: safeapp + manager: systemd + systemd: + - service_name: safeapp # Runs this app, till system is safe. + safemonitor: + - heartbeat: + threads: + heartbeat_update_interval_ms: 300 + - main: + heartbeat_interval_ms: 1000 + - thread_b: + heartbeat_interval_ms: 500 + - memory: + max_mem: 10kb + + - name: app_b + timeout_ms: 2000 + max_retries: 5 + critical: false + manager: docker # Can be another runtime + docker: + - container_name: app_b + safeaction: + - container: + restart: true + safemonitor: + - heartbeat: + threads: + - main: + heartbeat_interval_ms: 500 + diff --git a/doc/designdecision.md b/doc/designdecision.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/papyrus_uml/.project b/doc/papyrus_uml/.project new file mode 100644 index 0000000..e452601 --- /dev/null +++ b/doc/papyrus_uml/.project @@ -0,0 +1,11 @@ + + + SafeGuard + + + + + + + + diff --git a/doc/papyrus_uml/SafeGuard.aird b/doc/papyrus_uml/SafeGuard.aird new file mode 100644 index 0000000..880d4a8 --- /dev/null +++ b/doc/papyrus_uml/SafeGuard.aird @@ -0,0 +1,534 @@ + + + + SafeGuard.uml + pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml + pathmap://UML_PROFILES/Ecore.profile.uml + pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml + pathmap://UML_PROFILES/Standard.profile.uml + pathmap://UML_METAMODELS/UML.metamodel.uml + pathmap://UML_METAMODELS/Ecore.metamodel.uml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/papyrus_uml/SafeGuard.di b/doc/papyrus_uml/SafeGuard.di new file mode 100644 index 0000000..8c549ee --- /dev/null +++ b/doc/papyrus_uml/SafeGuard.di @@ -0,0 +1,2 @@ + + diff --git a/doc/papyrus_uml/SafeGuard.notation b/doc/papyrus_uml/SafeGuard.notation new file mode 100644 index 0000000..d5ffa5d --- /dev/null +++ b/doc/papyrus_uml/SafeGuard.notation @@ -0,0 +1,364 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/papyrus_uml/SafeGuard.uml b/doc/papyrus_uml/SafeGuard.uml new file mode 100644 index 0000000..3974966 --- /dev/null +++ b/doc/papyrus_uml/SafeGuard.uml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Enable security measures + + + + + + + + + + + + + + + + + + + + + + + Enable security aspects as required. + + + + + + + + + + + + From 93c18638c7e82efee85fbbf9af3417f9793c9306 Mon Sep 17 00:00:00 2001 From: Sathishkumar Duraisamy Date: Wed, 22 Apr 2026 08:32:21 +0200 Subject: [PATCH 3/4] Updated safetyguard activity diagram Signed-off-by: Sathishkumar Duraisamy --- doc/designdecision.md | 7 + doc/papyrus_uml/SafeGuard.notation | 370 ++++++++++++++++++++++++++++- doc/papyrus_uml/SafeGuard.uml | 42 +++- 3 files changed, 417 insertions(+), 2 deletions(-) diff --git a/doc/designdecision.md b/doc/designdecision.md index e69de29..cbc8c89 100644 --- a/doc/designdecision.md +++ b/doc/designdecision.md @@ -0,0 +1,7 @@ +Control loop: +* No memory allocation is allowed. The various IPC in linux involves memory allocation, where as shared memory doesn't. So shared memory is good for the use-case. Also, it is better to be lock-free. So Single producer and signle consumer queue with shared memory will be use as communication mechanism between apps and safetygurad. +* The application will update the shared memory and then send event via eventfd to indicate new data available in the shared memory. The safety guard will update the app specific details in the safetyguard. +* Also, there is timerfd in the control loop of safety guard. With this the state of all apps will be evaluvated. Such as heartbeats, memory-consuption details, or safeinstruments of the entire system. The timerfd is also responsible for update the watchdog of the system based on the monitored data. +* + + diff --git a/doc/papyrus_uml/SafeGuard.notation b/doc/papyrus_uml/SafeGuard.notation index d5ffa5d..51045df 100644 --- a/doc/papyrus_uml/SafeGuard.notation +++ b/doc/papyrus_uml/SafeGuard.notation @@ -142,7 +142,7 @@ - + @@ -204,6 +204,16 @@ + + + + + + + + + + @@ -361,4 +371,362 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/papyrus_uml/SafeGuard.uml b/doc/papyrus_uml/SafeGuard.uml index 3974966..3ff29cb 100644 --- a/doc/papyrus_uml/SafeGuard.uml +++ b/doc/papyrus_uml/SafeGuard.uml @@ -22,12 +22,22 @@ - + + + Enable security measures + + Threads update the datestore via API which is part of client library + + + + Heartbeat update are based on heartbeat_update_interval. +Either use threaded model or can call API as part of client library + @@ -61,4 +71,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5a0e7b4316a0f2937bfb56fca8bf40afd9956b72 Mon Sep 17 00:00:00 2001 From: Sathishkumar Duraisamy Date: Mon, 4 May 2026 22:31:24 +0200 Subject: [PATCH 4/4] Updated sequence diagram in UML file Signed-off-by: Sathishkumar Duraisamy --- doc/papyrus_uml/SafeGuard.notation | 262 ++++++++++++++++++++++++++--- doc/papyrus_uml/SafeGuard.uml | 87 +++++++++- 2 files changed, 323 insertions(+), 26 deletions(-) diff --git a/doc/papyrus_uml/SafeGuard.notation b/doc/papyrus_uml/SafeGuard.notation index 51045df..5b4a9c4 100644 --- a/doc/papyrus_uml/SafeGuard.notation +++ b/doc/papyrus_uml/SafeGuard.notation @@ -544,29 +544,6 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -729,4 +706,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/papyrus_uml/SafeGuard.uml b/doc/papyrus_uml/SafeGuard.uml index 3ff29cb..1a9109d 100644 --- a/doc/papyrus_uml/SafeGuard.uml +++ b/doc/papyrus_uml/SafeGuard.uml @@ -72,7 +72,6 @@ Either use threaded model or can call API as part of client library - @@ -88,8 +87,8 @@ Either use threaded model or can call API as part of client library - - + + @@ -101,4 +100,86 @@ Either use threaded model or can call API as part of client library + + + Creates /var/safetyguard.sock + + + Creates eventfd +Creates shared memory + + + Application's normal work + + + Enqueue heartbeat/data (SPSC) + + + Identifies app +Dequeues data +Update heartbeat + + + epoll waits + + + epoll waits + + + Check heartbeat state +Check memory consumption +Check safeinstrument state + + + SafeInstrument monitors instrumented logic + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +