English
sofia-engine
edge-ai
industrial-ai
scientific-computing
embedded-ai
signal-processing
digital-signal-processing
predictive-maintenance
condition-monitoring
vibration-analysis
anomaly-detection
industrial-iot
iiot
telemetry
edge-computing
tinyml
on-device-learning
embedded-systems
machine-health
time-series
python
typescript
c
Commit ·
876458a
1
Parent(s): 0278a72
release: publish Sofia Engine 3.0.0a1 artifacts, manifests, and documentation
Browse files- LICENSE +201 -0
- NOTICE +30 -0
- README.md +200 -0
- artifacts/README.md +28 -0
- benchmarks/README.md +28 -0
- benchmarks/benchmark-schema.json +55 -0
- config.json +27 -0
- docs/ARCHITECTURE.md +51 -0
- docs/LIMITATIONS.md +24 -0
- docs/SCIENTIFIC_VALIDATION.md +51 -0
- docs/SECURITY.md +30 -0
- examples/basic_inference.py +103 -0
- examples/edge_runtime.py +144 -0
- examples/signal_analysis.py +92 -0
- model_manifest.json +24 -0
- releases/README.md +23 -0
- runtime_manifest.json +44 -0
- schemas/feature-vector.schema.json +62 -0
- schemas/model.schema.json +62 -0
LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
NOTICE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sofia Engine
|
| 2 |
+
Copyright 2026 Rootcastle Engineering & Innovation
|
| 3 |
+
Project home: https://github.com/rootcastleco/sofia-ai
|
| 4 |
+
|
| 5 |
+
This product includes software developed by the Rootcastle Engineering &
|
| 6 |
+
Innovation team.
|
| 7 |
+
|
| 8 |
+
========================================================================
|
| 9 |
+
Third-party notices
|
| 10 |
+
========================================================================
|
| 11 |
+
|
| 12 |
+
Sofia Engine depends at runtime on NumPy, and optionally on third-party
|
| 13 |
+
packages for integrations (MQTT, Modbus, serial, ONNX Runtime, PyTorch,
|
| 14 |
+
FastAPI/uvicorn, and the MkDocs documentation toolchain). Their respective
|
| 15 |
+
license and copyright notices apply:
|
| 16 |
+
|
| 17 |
+
- NumPy — BSD 3-Clause
|
| 18 |
+
- paho-mqtt / pymodbus / pyserial — their respective licenses
|
| 19 |
+
- ONNX Runtime — MIT
|
| 20 |
+
- PyTorch — BSD 3-Clause
|
| 21 |
+
- FastAPI / uvicorn — MIT
|
| 22 |
+
- MkDocs — BSD 2-Clause
|
| 23 |
+
|
| 24 |
+
The embedded C reference implementation (embedded/) is original work and is
|
| 25 |
+
released under the same Apache-2.0 license as the rest of the project.
|
| 26 |
+
|
| 27 |
+
The test suite makes use of pytest, pytest-cov, Hypothesis, ruff and mypy,
|
| 28 |
+
which are licensed under their respective permissive licenses.
|
| 29 |
+
|
| 30 |
+
No vendored copies of third-party source code are shipped in this repository.
|
README.md
CHANGED
|
@@ -1,3 +1,203 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
doi: 10.57967/hf/10549
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
tags:
|
| 7 |
+
- edge-ai
|
| 8 |
+
- industrial-ai
|
| 9 |
+
- scientific-computing
|
| 10 |
+
- embedded-ai
|
| 11 |
+
- signal-processing
|
| 12 |
+
- digital-signal-processing
|
| 13 |
+
- predictive-maintenance
|
| 14 |
+
- condition-monitoring
|
| 15 |
+
- vibration-analysis
|
| 16 |
+
- anomaly-detection
|
| 17 |
+
- industrial-iot
|
| 18 |
+
- iiot
|
| 19 |
+
- telemetry
|
| 20 |
+
- edge-computing
|
| 21 |
+
- tinyml
|
| 22 |
+
- on-device-learning
|
| 23 |
+
- embedded-systems
|
| 24 |
+
- machine-health
|
| 25 |
+
- time-series
|
| 26 |
+
- python
|
| 27 |
+
- typescript
|
| 28 |
+
- c
|
| 29 |
+
library_name: sofia-engine
|
| 30 |
---
|
| 31 |
+
|
| 32 |
+
# Sofia Engine — Scientific & Edge Intelligence Runtime
|
| 33 |
+
|
| 34 |
+
Developed by **Rootcastle Engineering & Innovation**
|
| 35 |
+
Canonical Source Repository: [github.com/rootcastleco/sofia-ai](https://github.com/rootcastleco/sofia-ai)
|
| 36 |
+
Project Homepage: [rootcastle.com](https://rootcastle.com/)
|
| 37 |
+
DOI: [10.57967/hf/10549](https://doi.org/10.57967/hf/10549)
|
| 38 |
+
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
+
## 1. Overview
|
| 42 |
+
|
| 43 |
+
**Sofia Engine** is an open-source scientific and edge intelligence runtime developed by Rootcastle Engineering & Innovation for deterministic physical telemetry processing, industrial signal analysis, machine-health diagnostics, bounded edge inference, and safety-gated technical automation.
|
| 44 |
+
|
| 45 |
+
Operating under the engineering principle **"Evidence beats claims"**, Sofia Engine combines:
|
| 46 |
+
- **Scientific DSP**: FFT, Welch PSD, Hilbert analytic amplitude envelope, and Fortescue 3-phase symmetrical components.
|
| 47 |
+
- **Physical Telemetry Ingestion**: Bounded, unit-bearing telemetry frames with quality status (`GOOD`, `DEGRADED`, `SATURATED`).
|
| 48 |
+
- **Versioned Feature Extraction**: 14+ statistical and spectral features packaged in ordered, reproducible `FeatureVector` contracts (Schema v3.0).
|
| 49 |
+
- **Evidence-Based Diagnostics**: Noisy-OR evidence aggregation and machine health scoring with explicit uncertainty bands ($0-100 \pm \Delta$).
|
| 50 |
+
- **Embedded & Edge Execution**: Hardened virtual machine (`SofiaAsmVM`), C99 zero-allocation microcontroller implementation, and experimental in-situ backpropagation.
|
| 51 |
+
- **Safety & Policy Gating**: Strict default-DENY policy engine, Nonce + TTL replay protection, and an **actuation firewall that strictly isolates external LLMs from physical machinery**.
|
| 52 |
+
|
| 53 |
+
> [!NOTE]
|
| 54 |
+
> **Canonical Pretrained Checkpoint Status:**
|
| 55 |
+
> No canonical pretrained Sofia checkpoint is distributed in this release. This repository provides the Sofia model/runtime specification, machine-readable manifests, reproducible examples, and future checkpoint distribution interfaces. When pre-trained foundation models are released, they will be published with complete training datasets, evaluation reports, and SHA-256 digests.
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
## 2. Subsystem Maturity Table
|
| 60 |
+
|
| 61 |
+
Maturity levels are assigned strictly based on verifiable implementation and test coverage:
|
| 62 |
+
|
| 63 |
+
| Subsystem | Status | Verification & Evidence |
|
| 64 |
+
| :--- | :--- | :--- |
|
| 65 |
+
| **Scientific DSP** | **Stable** | Parseval energy conservation verified; exact amplitude recovery to $< 10^{-14}$; 5 golden vector tests passed. |
|
| 66 |
+
| **Telemetry Runtime** | **Stable** | Memory capacity ceilings ($\le 65536$), timestamp plausibility, unit alias normalization, IEEE 754 non-finite rejection. |
|
| 67 |
+
| **Diagnostic Engine** | **Stable** | Deterministic Noisy-OR fusion; dynamic uncertainty intervals; quality attenuation on degraded signals. |
|
| 68 |
+
| **Policy Engine & Replay Guard** | **Stable** | Default-DENY posture; Nonce + TTL monotonic replay protection; LLM actuation firewall; secret scrubbing. |
|
| 69 |
+
| **Embedded C99 Runtime** | **Stable** | Zero dynamic heap allocation post-init (`malloc` prohibited); Q16.16 fixed-point arithmetic; static ceilings. |
|
| 70 |
+
| **Sofia Assembly VM** | **Beta** | Memory and register bounds checking; cycle ceilings; structured execution result (`VMExecutionResult`). |
|
| 71 |
+
| **In-Situ Neural Training** | **Experimental** | 2-layer analytical backpropagation in virtual assembly; validated against finite differences ($< 10^{-5}$ error). |
|
| 72 |
+
| **Cross-Language Conformance** | **Beta** | Python, TypeScript SDK (`@rootcastle/sofia-engine`), and C99 verified against identical golden vectors. |
|
| 73 |
+
| **LLM Copilot Integration** | **Optional** | Strictly advisory technical assistance; isolated from deterministic control core and physical actuators. |
|
| 74 |
+
| **Quantum Emulation** | **Experimental** | Educational statevector simulation and VQE parameter exploration. |
|
| 75 |
+
| **Native Code Generation** | **Experimental** | Preliminary x86_64 AVX2, ARM Cortex-M Thumb-2, and WebAssembly emission stubs. |
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## 3. Architecture & Data Flow
|
| 80 |
+
|
| 81 |
+
```mermaid
|
| 82 |
+
flowchart LR
|
| 83 |
+
S["Physical Sensors"] --> I["Telemetry Ingestion"]
|
| 84 |
+
I --> Q["Validation & Signal Quality"]
|
| 85 |
+
Q --> B["Bounded Buffers"]
|
| 86 |
+
B --> D["Scientific DSP"]
|
| 87 |
+
D --> F["Versioned Feature Vector"]
|
| 88 |
+
F --> M["Inference Backends"]
|
| 89 |
+
M --> E["Evidence Fusion"]
|
| 90 |
+
E --> H["Diagnostics & Health"]
|
| 91 |
+
H --> P["Policy Engine"]
|
| 92 |
+
P --> O["Advisory / Controlled Output"]
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
**Key Architectural Invariant:** External LLMs (OpenAI, NVIDIA NIM, OpenRouter) operate exclusively as optional copilots at Layer 10. They have no read or write access to the deterministic signal processing or policy enforcement layers.
|
| 96 |
+
|
| 97 |
+
---
|
| 98 |
+
|
| 99 |
+
## 4. Scientific Scope & Calculations
|
| 100 |
+
|
| 101 |
+
Sofia Engine implements calculations relevant to industrial engineering standards:
|
| 102 |
+
|
| 103 |
+
- **Mechanical Vibration:** Implements calculations relevant to ISO 10816 / ISO 20816 vibration severity evaluation (RMS, peak, crest factor, kurtosis, skewness).
|
| 104 |
+
- **Spectral Analysis:** Discrete Fourier Transform (one-sided FFT magnitude), Welch's averaged periodogram with window gain corrections, spectral centroid, spectral entropy, and spectral flatness.
|
| 105 |
+
- **Envelope Demodulation:** Hilbert transform analytic signal for bearing defect and gear-mesh modulation extraction.
|
| 106 |
+
- **Electrical Power Quality:** Implements calculations relevant to IEEE 519 and IEC 61000-4-30 analysis, including True RMS, Active/Reactive/Apparent Power, Total Harmonic Distortion (THD), and Fortescue 3-phase symmetrical components ($V_0, V_1, V_2, \text{VUF}$).
|
| 107 |
+
- **Process Telemetry:** Thermal rates of change ($dT/dt$), pulsation peak-to-peak, and fluid pressure crest factors.
|
| 108 |
+
|
| 109 |
+
*Note: Software implementation does not constitute formal laboratory certification. Operational deployment requires qualified engineering calibration.*
|
| 110 |
+
|
| 111 |
+
---
|
| 112 |
+
|
| 113 |
+
## 5. Installation
|
| 114 |
+
|
| 115 |
+
### Core Runtime (NumPy Only)
|
| 116 |
+
```bash
|
| 117 |
+
pip install sofia-engine
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
### Industrial Telemetry Integrations (MQTT, Modbus, Serial)
|
| 121 |
+
```bash
|
| 122 |
+
pip install "sofia-engine[industrial]"
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
### From Canonical Source
|
| 126 |
+
```bash
|
| 127 |
+
git clone https://github.com/rootcastleco/sofia-ai.git
|
| 128 |
+
cd sofia-ai
|
| 129 |
+
pip install -e .
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
---
|
| 133 |
+
|
| 134 |
+
## 6. Reproducible Examples
|
| 135 |
+
|
| 136 |
+
Executable scripts are maintained in the [`examples/`](https://huggingface.co/rootcastleengineering/sofia/tree/main/examples) directory:
|
| 137 |
+
|
| 138 |
+
- [`examples/basic_inference.py`](https://huggingface.co/rootcastleengineering/sofia/raw/main/examples/basic_inference.py): Signal window packaging, 14-feature extraction, threshold anomaly detection, and evidence-based health scoring.
|
| 139 |
+
- [`examples/signal_analysis.py`](https://huggingface.co/rootcastleengineering/sofia/raw/main/examples/signal_analysis.py): FFT magnitude, Welch PSD with Parseval energy conservation check, Hilbert analytic envelope, and Fortescue symmetrical components.
|
| 140 |
+
- [`examples/edge_runtime.py`](https://huggingface.co/rootcastleengineering/sofia/raw/main/examples/edge_runtime.py): Bounded `SignalFrame`, Sofia Assembly VM execution, in-situ neural training step, and safe `sofia.model.v1` serialization.
|
| 141 |
+
|
| 142 |
+
To execute the basic inference example:
|
| 143 |
+
```bash
|
| 144 |
+
python examples/basic_inference.py
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
+
---
|
| 148 |
+
|
| 149 |
+
## 7. Model Manifests & Checkpoint Policy
|
| 150 |
+
|
| 151 |
+
Hugging Face distribution files are machine-readable and schema-validated:
|
| 152 |
+
|
| 153 |
+
- [`config.json`](https://huggingface.co/rootcastleengineering/sofia/raw/main/config.json): Runtime capabilities, Python version, and dependency requirements.
|
| 154 |
+
- [`model_manifest.json`](https://huggingface.co/rootcastleengineering/sofia/raw/main/model_manifest.json): Conforms to [`schemas/model.schema.json`](https://huggingface.co/rootcastleengineering/sofia/raw/main/schemas/model.schema.json).
|
| 155 |
+
- [`runtime_manifest.json`](https://huggingface.co/rootcastleengineering/sofia/raw/main/runtime_manifest.json): Exact Git commit SHA, dependency versions, latency budgets, and subsystem maturity.
|
| 156 |
+
|
| 157 |
+
### Checkpoint Policy
|
| 158 |
+
- **Zero-Pickle Invariant:** Model weights must be distributed in `.safetensors` or `.npz` format. Python `pickle` is strictly prohibited.
|
| 159 |
+
- **Cryptographic Verification:** Every model artifact must declare its lowercase SHA-256 parameter digest.
|
| 160 |
+
- See [`artifacts/README.md`](https://huggingface.co/rootcastleengineering/sofia/raw/main/artifacts/README.md) for full details.
|
| 161 |
+
|
| 162 |
+
---
|
| 163 |
+
|
| 164 |
+
## 8. Empirical Performance Benchmarks
|
| 165 |
+
|
| 166 |
+
Measured on Profile A hardware (Intel64 x86_64, Windows 11, Python 3.12.10 CPython) across $N = 100$ iterations:
|
| 167 |
+
|
| 168 |
+
| Metric | Measured $p_{50}$ | Target Budget | Result |
|
| 169 |
+
| :--- | :--- | :--- | :--- |
|
| 170 |
+
| **FFT / Welch PSD (1024 samples)** | **$307.6\,\mu\text{s}$** | $\le 500\,\mu\text{s}$ | **PASS** |
|
| 171 |
+
| **FFT / Welch PSD (4096 samples)** | **$387.4\,\mu\text{s}$** | $\le 2000\,\mu\text{s}$ | **PASS** |
|
| 172 |
+
| **Analytic Envelope (2048 samples)** | **$127.8\,\mu\text{s}$** | $\le 1000\,\mu\text{s}$ | **PASS** |
|
| 173 |
+
| **Symmetrical Components (Fortescue)** | **$55.5\,\mu\text{s}$** | $\le 1500\,\mu\text{s}$ | **PASS** |
|
| 174 |
+
| **Peak Memory Consumption** | **$7.14\text{ MB}$** | $\le 32\text{ MB}$ | **PASS** |
|
| 175 |
+
|
| 176 |
+
Complete benchmark reports and JSON schema are available in [`benchmarks/`](https://huggingface.co/rootcastleengineering/sofia/tree/main/benchmarks).
|
| 177 |
+
|
| 178 |
+
---
|
| 179 |
+
|
| 180 |
+
## 9. Safety & Limitations
|
| 181 |
+
|
| 182 |
+
- **Engineering Judgment:** Sofia Engine outputs are diagnostic aids. They do not replace physical inspection or qualified engineering sign-off.
|
| 183 |
+
- **Physical Safety Interlocks:** Under no circumstance should AI or diagnostic outputs directly control machinery without external, hardware-certified safety interlocks (e.g. SIL relays).
|
| 184 |
+
- **Sensor Calibration:** Diagnostic accuracy is bounded by sensor fidelity, mounting configuration, and signal acquisition quality.
|
| 185 |
+
- Read [`docs/LIMITATIONS.md`](https://huggingface.co/rootcastleengineering/sofia/raw/main/docs/LIMITATIONS.md) and [`docs/SECURITY.md`](https://huggingface.co/rootcastleengineering/sofia/raw/main/docs/SECURITY.md) for detailed boundaries.
|
| 186 |
+
|
| 187 |
+
---
|
| 188 |
+
|
| 189 |
+
## 10. Citation
|
| 190 |
+
|
| 191 |
+
To cite Sofia Engine in scientific software, publications, or engineering documentation:
|
| 192 |
+
|
| 193 |
+
```bibtex
|
| 194 |
+
@software{sofia_engine_2026,
|
| 195 |
+
author = {{Rootcastle Engineering \& Innovation}},
|
| 196 |
+
title = {Sofia Engine: Scientific \& Edge Intelligence Runtime},
|
| 197 |
+
year = {2026},
|
| 198 |
+
version = {3.0.0a1},
|
| 199 |
+
publisher = {Hugging Face},
|
| 200 |
+
doi = {10.57967/hf/10549},
|
| 201 |
+
url = {https://huggingface.co/rootcastleengineering/sofia}
|
| 202 |
+
}
|
| 203 |
+
```
|
artifacts/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sofia Engine Checkpoint & Artifact Registry
|
| 2 |
+
|
| 3 |
+
This directory defines the distribution and security policy for future trained Sofia model checkpoints and parameter sets.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 1. Current Checkpoint Status
|
| 8 |
+
|
| 9 |
+
> **Canonical Pretrained Checkpoint:** *Not yet released.*
|
| 10 |
+
>
|
| 11 |
+
> Sofia Engine 3.0.0a1 provides the runtime engine, feature extraction contracts, assembly virtual machine, and safe serialization interfaces. No pre-trained foundation model weights are shipped in this release.
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
## 2. Checkpoint Release Policy
|
| 16 |
+
|
| 17 |
+
Every future checkpoint published under this repository must satisfy the following technical requirements:
|
| 18 |
+
|
| 19 |
+
1. **Safe Serialization Formats**:
|
| 20 |
+
- Primary: `.safetensors` or validated `.npz` (via `np.savez`).
|
| 21 |
+
- **Prohibited:** Python `pickle` (`.pkl`, `.pickle`, `.pt` containing arbitrary executable code) is strictly forbidden.
|
| 22 |
+
2. **Cryptographic Integrity**:
|
| 23 |
+
- Every artifact file must be accompanied by its lowercase SHA-256 digest (`parameters_sha256`).
|
| 24 |
+
- Manifests are verified before weights are mapped into memory.
|
| 25 |
+
3. **Declared Feature Schema**:
|
| 26 |
+
- The checkpoint manifest must explicitly declare its input `feature_schema` (e.g., `vibration-v3`, `power-quality-v1`) to prevent feature order mismatches.
|
| 27 |
+
4. **Transparent Provenance**:
|
| 28 |
+
- Public release notes must specify training dataset origin, sample count, evaluation metrics, and runtime version compatibility.
|
benchmarks/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sofia Engine Empirical Performance Benchmarks
|
| 2 |
+
|
| 3 |
+
All benchmark metrics published below represent real measurements executed on physical test hardware using `benchmarks/run_benchmarks.py`. **No metrics are fabricated or estimated.**
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 1. Hardware Profile A Reference Measurements
|
| 8 |
+
|
| 9 |
+
- **OS / Platform:** Windows 11 (AMD64)
|
| 10 |
+
- **CPU:** Intel64 Family 6 Model 165 (x86_64)
|
| 11 |
+
- **Python Version:** 3.12.10 CPython
|
| 12 |
+
- **Timestamp:** 2026-09-21 23:56:41 UTC
|
| 13 |
+
|
| 14 |
+
### Latency Percentiles ($N = 100$ iterations)
|
| 15 |
+
|
| 16 |
+
| Benchmark Task | Target Budget | Mean | $p_{50}$ (Median) | $p_{95}$ | $p_{99}$ | Budget Status |
|
| 17 |
+
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|
| 18 |
+
| **Package Import Time** | $\le 500\text{ ms}$ | $342.8\text{ ms}$ | — | — | — | **PASS** |
|
| 19 |
+
| **FFT / Welch PSD (1024 samples)** | $\le 500\,\mu\text{s}$ | $319.2\,\mu\text{s}$ | **$307.6\,\mu\text{s}$** | $362.8\,\mu\text{s}$ | $445.5\,\mu\text{s}$ | **PASS** |
|
| 20 |
+
| **FFT / Welch PSD (4096 samples)** | $\le 2000\,\mu\text{s}$ | $430.3\,\mu\text{s}$ | **$387.4\,\mu\text{s}$** | $597.3\,\mu\text{s}$ | $713.1\,\mu\text{s}$ | **PASS** |
|
| 21 |
+
| **Analytic Envelope (2048 samples)** | $\le 1000\,\mu\text{s}$ | $141.0\,\mu\text{s}$ | **$127.8\,\mu\text{s}$** | $200.2\,\mu\text{s}$ | $237.9\,\mu\text{s}$ | **PASS** |
|
| 22 |
+
| **Symmetrical Components (Fortescue)**| $\le 1500\,\mu\text{s}$ | $60.7\,\mu\text{s}$ | **$55.5\,\mu\text{s}$** | $93.0\,\mu\text{s}$ | $102.7\,\mu\text{s}$ | **PASS** |
|
| 23 |
+
| **14-Feature Extraction (1024 samples)**| $\le 10000\,\mu\text{s}$| $2521.5\,\mu\text{s}$| **$2415.5\,\mu\text{s}$**| $3304.8\,\mu\text{s}$| $3491.0\,\mu\text{s}$| **PASS** |
|
| 24 |
+
| **Sofia VM Forward Inference (4→8→1)**| $\le 5000\,\mu\text{s}$| $1751.2\,\mu\text{s}$| **$1675.8\,\mu\text{s}$**| $2210.2\,\mu\text{s}$| $2457.1\,\mu\text{s}$| **PASS** |
|
| 25 |
+
| **Sofia VM Training Step (analytical backprop)**| $\le 20000\,\mu\text{s}$| $6609.7\,\mu\text{s}$| **$6442.9\,\mu\text{s}$**| $7483.0\,\mu\text{s}$| $9051.6\,\mu\text{s}$| **PASS** |
|
| 26 |
+
|
| 27 |
+
### Memory Consumption
|
| 28 |
+
- Peak traced memory during benchmark suite: **$7.14\text{ MB}$** ($\le 32\text{ MB}$ budget for Profile A gateways).
|
benchmarks/benchmark-schema.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
| 3 |
+
"$id": "https://huggingface.co/rootcastleengineering/sofia/raw/main/benchmarks/benchmark-schema.json",
|
| 4 |
+
"title": "SofiaBenchmarkReport",
|
| 5 |
+
"description": "Schema for Sofia Engine empirical benchmark execution reports.",
|
| 6 |
+
"type": "object",
|
| 7 |
+
"properties": {
|
| 8 |
+
"timestamp_utc": { "type": "string", "format": "date-time" },
|
| 9 |
+
"environment": {
|
| 10 |
+
"type": "object",
|
| 11 |
+
"properties": {
|
| 12 |
+
"os": { "type": "string" },
|
| 13 |
+
"machine": { "type": "string" },
|
| 14 |
+
"processor": { "type": "string" },
|
| 15 |
+
"python_version": { "type": "string" }
|
| 16 |
+
},
|
| 17 |
+
"required": ["os", "python_version"]
|
| 18 |
+
},
|
| 19 |
+
"benchmarks": {
|
| 20 |
+
"type": "object",
|
| 21 |
+
"properties": {
|
| 22 |
+
"import_time_ms": { "type": "number" },
|
| 23 |
+
"fft_psd_1024": { "$ref": "#/$defs/stat_record" },
|
| 24 |
+
"fft_psd_4096": { "$ref": "#/$defs/stat_record" },
|
| 25 |
+
"analytic_envelope_2048": { "$ref": "#/$defs/stat_record" },
|
| 26 |
+
"feature_extraction_1024": { "$ref": "#/$defs/stat_record" },
|
| 27 |
+
"electrical_symmetrical_components": { "$ref": "#/$defs/stat_record" }
|
| 28 |
+
},
|
| 29 |
+
"required": ["import_time_ms"]
|
| 30 |
+
},
|
| 31 |
+
"memory": {
|
| 32 |
+
"type": "object",
|
| 33 |
+
"properties": {
|
| 34 |
+
"current_traced_kb": { "type": "number" },
|
| 35 |
+
"peak_traced_kb": { "type": "number" }
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"required": ["timestamp_utc", "environment", "benchmarks"],
|
| 40 |
+
"$defs": {
|
| 41 |
+
"stat_record": {
|
| 42 |
+
"type": "object",
|
| 43 |
+
"properties": {
|
| 44 |
+
"n_iterations": { "type": "integer" },
|
| 45 |
+
"mean_us": { "type": "number" },
|
| 46 |
+
"p50_us": { "type": "number" },
|
| 47 |
+
"p95_us": { "type": "number" },
|
| 48 |
+
"p99_us": { "type": "number" },
|
| 49 |
+
"min_us": { "type": "number" },
|
| 50 |
+
"max_us": { "type": "number" }
|
| 51 |
+
},
|
| 52 |
+
"required": ["n_iterations", "mean_us", "p50_us"]
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "sofia-engine",
|
| 3 |
+
"architecture": "scientific-edge-runtime",
|
| 4 |
+
"library_name": "sofia-engine",
|
| 5 |
+
"runtime": {
|
| 6 |
+
"version": "3.0.0a1",
|
| 7 |
+
"python": ">=3.11",
|
| 8 |
+
"core_dependency": "numpy>=1.24",
|
| 9 |
+
"offline_first": true,
|
| 10 |
+
"deterministic": true
|
| 11 |
+
},
|
| 12 |
+
"capabilities": {
|
| 13 |
+
"scientific_signal_processing": true,
|
| 14 |
+
"industrial_telemetry": true,
|
| 15 |
+
"machine_health_diagnostics": true,
|
| 16 |
+
"embedded_c_runtime": true,
|
| 17 |
+
"assembly_virtual_machine": "beta",
|
| 18 |
+
"on_device_learning": "experimental",
|
| 19 |
+
"quantum_emulation": "experimental",
|
| 20 |
+
"llm_copilot": "optional"
|
| 21 |
+
},
|
| 22 |
+
"publisher": {
|
| 23 |
+
"organization": "Rootcastle Engineering & Innovation",
|
| 24 |
+
"website": "https://rootcastle.com/",
|
| 25 |
+
"source_repository": "https://github.com/rootcastleco/sofia-ai"
|
| 26 |
+
}
|
| 27 |
+
}
|
docs/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sofia Engine Runtime Architecture
|
| 2 |
+
|
| 3 |
+
Sofia Engine is structured as a unidirectional, 10-layer deterministic pipeline designed for scientific telemetry processing, machine condition monitoring, and bounded edge intelligence.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 1. Unidirectional Data Flow
|
| 8 |
+
|
| 9 |
+
The runtime enforces strict layer boundaries. Dependencies only point downwards; higher-level diagnostics or advisory copilots never feed uncontrolled state back into deterministic signal processing.
|
| 10 |
+
|
| 11 |
+
```mermaid
|
| 12 |
+
flowchart LR
|
| 13 |
+
S["Physical Sensors"] --> I["Telemetry Ingestion"]
|
| 14 |
+
I --> Q["Validation & Signal Quality"]
|
| 15 |
+
Q --> B["Bounded Buffers"]
|
| 16 |
+
B --> D["Scientific DSP"]
|
| 17 |
+
D --> F["Versioned Feature Vector"]
|
| 18 |
+
F --> M["Inference Backends"]
|
| 19 |
+
M --> E["Evidence Fusion"]
|
| 20 |
+
E --> H["Diagnostics & Health"]
|
| 21 |
+
H --> P["Policy Engine"]
|
| 22 |
+
P --> O["Advisory / Controlled Output"]
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
## 2. Layer Definitions
|
| 28 |
+
|
| 29 |
+
| Layer | Component | Responsibility | Contracts & Invariants |
|
| 30 |
+
| :--- | :--- | :--- | :--- |
|
| 31 |
+
| **0** | **Physical Sensors** | Piezoelectric accelerometers, voltage/current transducers, RTDs, pressure sensors | Raw electrical quantities ($V, mA, mV/g$) |
|
| 32 |
+
| **1** | **Telemetry Ingestion** | Packaging time-series samples into bounded frames | `SignalMetadata`, `SignalFrame` ($\le 65536$ capacity ceiling) |
|
| 33 |
+
| **2** | **Validation & Quality** | Quality flagging (`GOOD`, `DEGRADED`, `UNCERTAIN`, `INVALID`, `SATURATED`) | IEEE 754 non-finite check; timestamp plausibility |
|
| 34 |
+
| **3** | **Bounded Buffers** | Deterministic circular ring buffers | Static allocation; zero dynamic growth post-init |
|
| 35 |
+
| **4** | **Scientific DSP** | FFT, Welch PSD, Hilbert analytic envelope, Fortescue symmetrical components | Parseval energy conservation; frequency axis from $f_s$, not wall-clock |
|
| 36 |
+
| **5** | **Feature Extraction** | Statistical, spectral, and domain feature extraction | `FeatureVector` (Schema v3.0, ordered fixed tuple, unit-bearing) |
|
| 37 |
+
| **6** | **Inference Backends** | Anomaly detectors, linear models, Assembly Neural Network | `ModelBackend` interface, manifest checksum enforcement |
|
| 38 |
+
| **7** | **Evidence Fusion** | Combining detection signals into versioned evidence bundles | `EvidenceBundle`, Noisy-OR confidence aggregation |
|
| 39 |
+
| **8** | **Diagnostics & Health** | Machine health evaluation, uncertainty interval calculation | `HealthScore` ($0-100 \pm \Delta$), `DiagnosticEngine` |
|
| 40 |
+
| **9** | **Safety & Policy** | Command authorization, replay protection, interlock gating | Default DENY posture, Nonce + TTL replay guard |
|
| 41 |
+
| **10** | **Advisory Output** | Diagnostic reports, telemetry export, advisory LLM copilot | **LLMs are strictly advisory; isolated from machine actuation** |
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
## 3. Cross-Language Conformance
|
| 46 |
+
|
| 47 |
+
Sofia Engine maintains verified mathematical consistency across three target implementations:
|
| 48 |
+
|
| 49 |
+
1. **Python (`sofia_ai`)**: Reference scientific implementation for gateways, edge servers, and cloud pipelines (NumPy-based, zero heavy framework dependencies).
|
| 50 |
+
2. **TypeScript (`@rootcastle/sofia-engine`)**: Edge gateway, industrial browser, and Node.js runtimes with identical statistical contracts.
|
| 51 |
+
3. **C99 Embedded (`embedded/`)**: Microcontroller target (ARM Cortex-M, RISC-V) featuring zero heap allocation post-init (`malloc` prohibited) and Q16.16 fixed-point arithmetic.
|
docs/LIMITATIONS.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sofia Engine Operating Boundaries & Transparent Limitations
|
| 2 |
+
|
| 3 |
+
In accordance with our engineering principle **"Evidence beats claims"**, the following boundaries and limitations apply to Sofia Engine 3.0.0a1:
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 1. Checkpoint Distribution Status
|
| 8 |
+
- **No Canonical Pretrained Foundation Model:**
|
| 9 |
+
Sofia Engine 3.0.0a1 is a **Scientific & Edge Intelligence Runtime**, not a foundation model. No pre-trained neural checkpoint is distributed in this initial release.
|
| 10 |
+
Future trained checkpoints (e.g. bearing fault classifiers, transformer-based time-series anomaly models) will be distributed with explicit training provenance, evaluation reports, and SHA-256 digests.
|
| 11 |
+
|
| 12 |
+
## 2. Hardware & Fixed-Point Numerical Differences
|
| 13 |
+
- **C99 vs. Python Floating-Point:**
|
| 14 |
+
The Python runtime operates in IEEE 754 double precision (64-bit float). The C99 embedded reference engine supports both single precision (32-bit float) and Q16.16 fixed-point arithmetic. Fixed-point computations have a finite resolution of $\approx 1.526 \times 10^{-5}$ and may exhibit small truncation differences compared to 64-bit float baselines.
|
| 15 |
+
|
| 16 |
+
## 3. Standards Compliance Scope
|
| 17 |
+
- **Relevance vs. Formal Certification:**
|
| 18 |
+
Sofia Engine implements calculations relevant to industrial standards (e.g., ISO 10816/20816 vibration severity zones, IEEE 519 harmonic limits, IEC 61000-4-30 power quality concepts). **Software implementation does not constitute formal device or system-level certification.** Certified deployments require end-to-end hardware calibration and formal test laboratory certification.
|
| 19 |
+
|
| 20 |
+
## 4. Operational Safety Notice
|
| 21 |
+
- **Non-Replacement of Qualified Engineering Judgment:**
|
| 22 |
+
Diagnostic outputs (Health Scores, Severity classifications, Anomaly events) are mathematical inferences based strictly on incoming sensor telemetry. They do not replace certified human inspection or qualified engineering judgment.
|
| 23 |
+
- **Physical Safety Interlocks:**
|
| 24 |
+
Sofia Engine outputs must never be connected directly to emergency stops, circuit breakers, or critical plant actuators without independent, hardwired, safety-certified physical interlocks (e.g. SIL-rated safety relays).
|
docs/SCIENTIFIC_VALIDATION.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sofia Engine Scientific Validation
|
| 2 |
+
|
| 3 |
+
All algorithms in Sofia Engine are backed by deterministic mathematical verification, golden test vectors, and physical conservation laws.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 1. Digital Signal Processing Correctness
|
| 8 |
+
|
| 9 |
+
### Parseval Energy Conservation
|
| 10 |
+
For discrete signals, Parseval's theorem dictates that total energy in the time domain must equal total energy in the frequency domain:
|
| 11 |
+
$$\sum_{n=0}^{N-1} |x[n]|^2 = \frac{1}{N} \sum_{k=0}^{N-1} |X[k]|^2$$
|
| 12 |
+
|
| 13 |
+
When applying window functions $w[n]$, energy is attenuated by the noise power bandwidth gain:
|
| 14 |
+
$$S_2 = \sum_{n=0}^{N-1} w[n]^2$$
|
| 15 |
+
|
| 16 |
+
Sofia's `welch_psd` implementation normalizes power spectral density by $S_2$ and frequency resolution $\Delta f = f_s / N$. Energy conservation across Hann, Hamming, and Blackman windows is continuously verified in `tests/unit/test_dsp_golden.py`:
|
| 17 |
+
$$\left| \frac{\int \text{PSD}(f)\,df}{\text{Var}(x)} - 1.0 \right| < 0.05$$
|
| 18 |
+
|
| 19 |
+
### Exact Amplitude Recovery
|
| 20 |
+
For unwindowed integer-bin tones ($f_0 = k \cdot f_s / N$), the one-sided FFT magnitude recovers the exact continuous amplitude $A$:
|
| 21 |
+
$$\hat{A} = \frac{2}{N} |X[k]|$$
|
| 22 |
+
Sofia verifies peak tone amplitude recovery to machine precision ($< 10^{-14}$ relative error).
|
| 23 |
+
|
| 24 |
+
### 3-Phase Symmetrical Components (Fortescue Transformation)
|
| 25 |
+
Unbalanced 3-phase voltages $V_a, V_b, V_c$ are decomposed using the complex operator $a = e^{j 120^\circ} = -\frac{1}{2} + j \frac{\sqrt{3}}{2}$:
|
| 26 |
+
$$\begin{bmatrix} V_0 \\ V_1 \\ V_2 \end{bmatrix} = \frac{1}{3} \begin{bmatrix} 1 & 1 & 1 \\ 1 & a & a^2 \\ 1 & a^2 & a \end{bmatrix} \begin{bmatrix} V_a \\ V_b \\ V_c \end{bmatrix}$$
|
| 27 |
+
$$\text{VUF} = \frac{|V_2|}{|V_1|} \times 100\%$$
|
| 28 |
+
Golden vectors generated in `tests/golden/dsp_golden.json` assert that positive ($V_1$), negative ($V_2$), and zero ($V_0$) sequence components match theoretical values within $10^{-5}$ tolerance across Python, TypeScript, and C99 runtimes.
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## 2. In-Situ Neural Training & Gradient Verification
|
| 33 |
+
|
| 34 |
+
Sofia's virtual assembly neural network (`AssemblyNeuralNetwork`) implements 2-layer analytical backpropagation directly in virtual bytecode:
|
| 35 |
+
$$\frac{\partial L}{\partial W_2} = \frac{\partial L}{\partial \hat{y}} \cdot h^T, \quad \frac{\partial L}{\partial B_2} = \frac{\partial L}{\partial \hat{y}}$$
|
| 36 |
+
$$\frac{\partial L}{\partial h} = W_2^T \cdot \frac{\partial L}{\partial \hat{y}}, \quad \frac{\partial L}{\partial z_1} = \frac{\partial L}{\partial h} \odot \mathbb{I}(z_1 > 0)$$
|
| 37 |
+
$$\frac{\partial L}{\partial W_1} = \frac{\partial L}{\partial z_1} \cdot x^T, \quad \frac{\partial L}{\partial B_1} = \frac{\partial L}{\partial z_1}$$
|
| 38 |
+
|
| 39 |
+
Analytical gradients computed in virtual registers are validated against central finite differences:
|
| 40 |
+
$$\frac{\partial L}{\partial \theta_i} \approx \frac{L(\theta_i + \epsilon) - L(\theta_i - \epsilon)}{2\epsilon}, \quad \epsilon = 10^{-5}$$
|
| 41 |
+
The relative error $\frac{\|\nabla_{\text{analytical}} - \nabla_{\text{numerical}}\|}{\|\nabla_{\text{analytical}}\| + \|\nabla_{\text{numerical}}\|}$ is proven to be $< 10^{-5}$ in `tests/unit/test_neural_gradients.py`.
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
## 3. Microcontroller Fixed-Point Conformance
|
| 46 |
+
|
| 47 |
+
The C99 embedded runtime (`embedded/src/sofia_features.c`) implements Q16.16 fixed-point arithmetic:
|
| 48 |
+
- Fixed-point resolution: $1/65536 \approx 1.526 \times 10^{-5}$
|
| 49 |
+
- Dynamic range: $[-32768.0, +32767.99998]$
|
| 50 |
+
- Zero heap allocation: no calls to `malloc`, `calloc`, or `free` post-initialization.
|
| 51 |
+
- Compile-time static ceilings: `SOFIA_MAX_FFT_LEN = 1024`, `SOFIA_N_STAT_FEATURES = 14`.
|
docs/SECURITY.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sofia Engine Security Architecture & Threat Model
|
| 2 |
+
|
| 3 |
+
Sofia Engine is designed under the assumption that edge and industrial environments operate under adversarial and untrusted network conditions.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 1. Core Security Invariants
|
| 8 |
+
|
| 9 |
+
1. **Default DENY Posture**:
|
| 10 |
+
The `PolicyEngine` rejects all incoming actuation commands by default. An explicit, cryptographically authenticated rule must permit execution.
|
| 11 |
+
2. **Replay Protection**:
|
| 12 |
+
All commands require a unique Nonce, monotonic Sequence Number, and Time-To-Live (TTL). Replayed commands or expired timestamps are immediately rejected.
|
| 13 |
+
3. **LLM Actuation Firewall**:
|
| 14 |
+
External AI models (e.g. OpenAI, Anthropic, NVIDIA NIM, local LLMs) are strictly categorized as **Advisory Copilots**. Under no circumstance can an LLM directly trigger an edge actuator or override safety interlocks.
|
| 15 |
+
4. **Zero-Pickle Artifacts**:
|
| 16 |
+
Sofia models are serialized exclusively as JSON manifests + NPZ/safetensors weight archives with SHA-256 parameter hashing. Arbitrary Python pickle files are strictly rejected.
|
| 17 |
+
5. **Secret Scrubbing**:
|
| 18 |
+
All tokens, API keys, credentials, and sensitive headers are redacted from debug logs and telemetry exports using pattern-matched redaction filters.
|
| 19 |
+
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
## 2. Threat Mitigations
|
| 23 |
+
|
| 24 |
+
| Threat | Impact | Sofia Runtime Mitigation |
|
| 25 |
+
| :--- | :--- | :--- |
|
| 26 |
+
| **Command Injection / Replay** | Unauthorized machine actuation | `ReplayGuard` with Nonce cache, monotonic timestamp validation, and TTL eviction |
|
| 27 |
+
| **Model Tampering** | Adversarial parameter alteration | Mandatory SHA-256 parameter hash verification in `ModelManifest` prior to loading |
|
| 28 |
+
| **Sensor Saturation / Clipping** | Corrupted diagnostic assessment | `DataQuality.SATURATED` flag automatically attenuates diagnostic confidence to $\le 0.20$ |
|
| 29 |
+
| **Memory Exhaustion** | Gateway denial-of-service | Static capacity ceilings ($\le 65536$ frame size, fixed circular buffers, zero dynamic allocation in C99) |
|
| 30 |
+
| **Hostile Telemetry Metadata** | Buffer overflow or script injection | Strict identifier sanitization (`^[a-zA-Z0-9_\-\.]{1,64}$`) on all channels and device IDs |
|
examples/basic_inference.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Basic Inference Example for Sofia Engine.
|
| 2 |
+
|
| 3 |
+
Demonstrates deterministic telemetry feature extraction, statistical anomaly
|
| 4 |
+
detection, and evidence-based diagnostic health scoring.
|
| 5 |
+
|
| 6 |
+
Run:
|
| 7 |
+
python examples/basic_inference.py
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
|
| 14 |
+
from sofia_ai.core.contracts import DataQuality, FeatureVector, SignalWindow
|
| 15 |
+
from sofia_ai.diagnostics.engine import (
|
| 16 |
+
DiagnosticEngine,
|
| 17 |
+
HealthEvent,
|
| 18 |
+
HealthScore,
|
| 19 |
+
compute_health_score,
|
| 20 |
+
)
|
| 21 |
+
from sofia_ai.diagnostics.rules import RuleContext
|
| 22 |
+
from sofia_ai.features import extract_from_array
|
| 23 |
+
from sofia_ai.inference.detectors import ThresholdDetector, build_manifest_for
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def run_basic_inference() -> None:
|
| 27 |
+
print("=== Sofia Engine: Basic Inference Example ===")
|
| 28 |
+
|
| 29 |
+
# 1. Synthesize 1 second of vibration telemetry (fs = 1000 Hz, 25 Hz shaft rotation)
|
| 30 |
+
fs = 1000.0
|
| 31 |
+
t = np.arange(1000) / fs
|
| 32 |
+
rng = np.random.default_rng(42)
|
| 33 |
+
# 25 Hz fundamental + 50 Hz harmonic + Gaussian background noise
|
| 34 |
+
raw_signal = (
|
| 35 |
+
0.45 * np.sin(2 * np.pi * 25.0 * t)
|
| 36 |
+
+ 0.15 * np.sin(2 * np.pi * 50.0 * t)
|
| 37 |
+
+ 0.05 * rng.normal(size=len(t))
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
print(f"Input Signal: {len(raw_signal)} samples @ {fs} Hz ({len(raw_signal)/fs:.2f} s)")
|
| 41 |
+
|
| 42 |
+
# 2. Package into a validated SignalWindow
|
| 43 |
+
window = SignalWindow(
|
| 44 |
+
values=raw_signal,
|
| 45 |
+
sample_rate=fs,
|
| 46 |
+
device_id="pump-motor-01",
|
| 47 |
+
channel="vibration_de",
|
| 48 |
+
unit="m/s^2",
|
| 49 |
+
quality=DataQuality.GOOD,
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
# 3. Extract versioned feature vector (14 statistical + spectral metrics)
|
| 53 |
+
features: FeatureVector = extract_from_array(
|
| 54 |
+
window.values,
|
| 55 |
+
window.sample_rate,
|
| 56 |
+
channel=window.channel,
|
| 57 |
+
quality=window.quality,
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# 4. Verify feature schema version (v3.0)
|
| 61 |
+
features.validate_schema("3.0")
|
| 62 |
+
print(f"Extracted FeatureVector (schema {features.schema_version}): {len(features.names)} features")
|
| 63 |
+
for name, val in list(zip(features.names, features.values, strict=True))[:5]:
|
| 64 |
+
print(f" - {name}: {val:.4f}")
|
| 65 |
+
|
| 66 |
+
# 5. Anomaly detection via ThresholdDetector (monitoring vibration RMS)
|
| 67 |
+
detector = ThresholdDetector(feature="rms", high=0.45)
|
| 68 |
+
manifest = build_manifest_for(detector, model_id="rms_threshold_v1", version="1.0.0")
|
| 69 |
+
detector.load(manifest)
|
| 70 |
+
inference_result = detector.infer(features)
|
| 71 |
+
|
| 72 |
+
print("\n--- Inference Result (Threshold Detector) ---")
|
| 73 |
+
print(f"Monitored Feature: 'rms' = {inference_result.score:.4f} m/s^2 (high limit = 0.45)")
|
| 74 |
+
print(f"Outcome: {inference_result.outcome.name}")
|
| 75 |
+
print(f"Confidence: {inference_result.confidence:.2%}")
|
| 76 |
+
|
| 77 |
+
# 6. Diagnostic Engine: Convert inference into evidence-backed health event
|
| 78 |
+
diag_engine = DiagnosticEngine()
|
| 79 |
+
context = RuleContext(
|
| 80 |
+
device_id=window.device_id,
|
| 81 |
+
channel=window.channel,
|
| 82 |
+
score=inference_result.score,
|
| 83 |
+
confidence=inference_result.confidence,
|
| 84 |
+
unit="z-score",
|
| 85 |
+
)
|
| 86 |
+
event: HealthEvent | None = diag_engine.evaluate(context)
|
| 87 |
+
|
| 88 |
+
events = [event] if event else []
|
| 89 |
+
health_score: HealthScore = compute_health_score(events)
|
| 90 |
+
|
| 91 |
+
print("\n--- Health Assessment ---")
|
| 92 |
+
print(f"Health Score: {health_score.score:.1f} / 100.0")
|
| 93 |
+
print(f"Credible Interval: [{health_score.lower:.1f}, {health_score.upper:.1f}]")
|
| 94 |
+
print(f"Uncertainty: ±{health_score.uncertainty:.2%}")
|
| 95 |
+
if event:
|
| 96 |
+
print(f"Health Event: {event.event_type} (Severity: {event.severity.name})")
|
| 97 |
+
print(f"Recommendation: {event.recommendation}")
|
| 98 |
+
else:
|
| 99 |
+
print("Status: Nominal operating condition.")
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
if __name__ == "__main__":
|
| 103 |
+
run_basic_inference()
|
examples/edge_runtime.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Edge Runtime Example for Sofia Engine.
|
| 2 |
+
|
| 3 |
+
Demonstrates:
|
| 4 |
+
1. Memory-bounded SignalFrame telemetry packaging
|
| 5 |
+
2. Hardened Sofia Assembly VM bytecode execution
|
| 6 |
+
3. In-situ neural network forward pass & analytical backpropagation
|
| 7 |
+
4. Safe, zero-pickle model serialization (JSON manifest + NPZ + SHA-256)
|
| 8 |
+
|
| 9 |
+
Run:
|
| 10 |
+
python examples/edge_runtime.py
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from __future__ import annotations
|
| 14 |
+
|
| 15 |
+
import tempfile
|
| 16 |
+
import time
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
import numpy as np
|
| 19 |
+
|
| 20 |
+
from sofia_ai.core.contracts import DataQuality, Sample, SignalFrame, SignalMetadata
|
| 21 |
+
from sofia_ai.learning.asm import AssemblyNeuralNetwork
|
| 22 |
+
from sofia_ai.learning.asm.vm import (
|
| 23 |
+
AsmInstruction,
|
| 24 |
+
OpCode,
|
| 25 |
+
Register,
|
| 26 |
+
SofiaAsmVM,
|
| 27 |
+
VMStatus,
|
| 28 |
+
)
|
| 29 |
+
from sofia_ai.learning.manifest import load_assembly_model, save_assembly_model
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def run_edge_runtime() -> None:
|
| 33 |
+
print("=== Sofia Engine: Edge Runtime & Embedded VM ===")
|
| 34 |
+
|
| 35 |
+
# -------------------------------------------------------------------------
|
| 36 |
+
# 1. Bounded SignalFrame Telemetry Packaging
|
| 37 |
+
# -------------------------------------------------------------------------
|
| 38 |
+
fs = 1000.0
|
| 39 |
+
meta = SignalMetadata(
|
| 40 |
+
sample_rate=fs,
|
| 41 |
+
channel_name="vibration_radial",
|
| 42 |
+
physical_unit="m/s^2",
|
| 43 |
+
sensor_id="piezo_accel_42",
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# Telemetry buffer strictly respects runtime capacity ceilings (<= 65536)
|
| 47 |
+
base_time = time.time()
|
| 48 |
+
samples = tuple(
|
| 49 |
+
Sample(
|
| 50 |
+
timestamp=base_time + i / fs,
|
| 51 |
+
device_id="edge-gateway-42",
|
| 52 |
+
channel="vibration_radial",
|
| 53 |
+
value=float(np.sin(2 * np.pi * 10.0 * (i / fs))),
|
| 54 |
+
unit="m/s^2",
|
| 55 |
+
quality=DataQuality.GOOD,
|
| 56 |
+
)
|
| 57 |
+
for i in range(256)
|
| 58 |
+
)
|
| 59 |
+
frame = SignalFrame(samples=samples, metadata=meta)
|
| 60 |
+
|
| 61 |
+
print(f"\n[1] SignalFrame Ingested: {frame.size} samples, Quality={frame.samples[0].quality.name}")
|
| 62 |
+
print(f" Channel: {frame.metadata.channel_name}, Sensor: {frame.metadata.sensor_id}")
|
| 63 |
+
|
| 64 |
+
# -------------------------------------------------------------------------
|
| 65 |
+
# 2. Hardened Sofia Assembly Virtual Machine
|
| 66 |
+
# -------------------------------------------------------------------------
|
| 67 |
+
print("\n[2] Sofia Assembly Virtual Machine Execution")
|
| 68 |
+
vm = SofiaAsmVM(memory_size=1024)
|
| 69 |
+
|
| 70 |
+
# Assemble a bounded test program:
|
| 71 |
+
# R1 = 12.5, R2 = 3.5, R1 = R1 + R2 (16.0), Mem[100] = R1, HALT
|
| 72 |
+
program = [
|
| 73 |
+
AsmInstruction(OpCode.LOAD_CONST, Register.R1, imm=12.5),
|
| 74 |
+
AsmInstruction(OpCode.LOAD_CONST, Register.R2, imm=3.5),
|
| 75 |
+
AsmInstruction(OpCode.ADD, Register.R1, Register.R2),
|
| 76 |
+
AsmInstruction(OpCode.LOAD_CONST, Register.R3, imm=100.0),
|
| 77 |
+
AsmInstruction(OpCode.STORE_MEM, Register.R3, Register.R1),
|
| 78 |
+
AsmInstruction(OpCode.HALT),
|
| 79 |
+
]
|
| 80 |
+
|
| 81 |
+
result = vm.run(program, max_cycles=1000)
|
| 82 |
+
print(f" VM Status: {result.status.value}")
|
| 83 |
+
print(f" Executed Cycles: {result.cycles}")
|
| 84 |
+
print(f" Register R1: {vm.registers[Register.R1]:.2f}")
|
| 85 |
+
print(f" Memory[100]: {vm.memory[100]:.2f}")
|
| 86 |
+
assert result.status == VMStatus.HALTED
|
| 87 |
+
assert vm.memory[100] == 16.0
|
| 88 |
+
|
| 89 |
+
# -------------------------------------------------------------------------
|
| 90 |
+
# 3. In-Situ Neural Training with Analytical Backpropagation
|
| 91 |
+
# -------------------------------------------------------------------------
|
| 92 |
+
print("\n[3] In-Situ Neural Network (2-Layer Bytecode Backpropagation)")
|
| 93 |
+
input_dim, hidden_dim, output_dim = 4, 8, 1
|
| 94 |
+
net = AssemblyNeuralNetwork(
|
| 95 |
+
input_dim=input_dim,
|
| 96 |
+
hidden_dim=hidden_dim,
|
| 97 |
+
output_dim=output_dim,
|
| 98 |
+
learning_rate=0.05,
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
# Synthetic training sample (e.g. 4 normalized vibration features -> target health)
|
| 102 |
+
x = np.array([0.25, 0.40, 0.10, 0.60], dtype=np.float64)
|
| 103 |
+
target = np.array([0.85], dtype=np.float64)
|
| 104 |
+
|
| 105 |
+
initial_pred = net.forward(x)
|
| 106 |
+
initial_loss = float(np.mean((initial_pred - target) ** 2))
|
| 107 |
+
print(f" Initial Prediction: {initial_pred[0]:.4f} (Target: {target[0]:.4f}, Loss: {initial_loss:.4f})")
|
| 108 |
+
|
| 109 |
+
# Perform 15 in-situ gradient update steps
|
| 110 |
+
for _ in range(15):
|
| 111 |
+
net.train_step(x, target)
|
| 112 |
+
|
| 113 |
+
final_pred = net.forward(x)
|
| 114 |
+
final_loss = float(np.mean((final_pred - target) ** 2))
|
| 115 |
+
print(f" Updated Prediction: {final_pred[0]:.4f} (Target: {target[0]:.4f}, Loss: {final_loss:.4f})")
|
| 116 |
+
assert final_loss < initial_loss, "Loss should decrease after training steps"
|
| 117 |
+
|
| 118 |
+
# -------------------------------------------------------------------------
|
| 119 |
+
# 4. Safe Model Manifest Export & SHA-256 Checksum Verification
|
| 120 |
+
# -------------------------------------------------------------------------
|
| 121 |
+
print("\n[4] Safe Model Serialization (Zero-Pickle sofia.model.v1)")
|
| 122 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
| 123 |
+
manifest_path = save_assembly_model(
|
| 124 |
+
model=net,
|
| 125 |
+
destination_dir=tmpdir,
|
| 126 |
+
model_name="edge_demo_model",
|
| 127 |
+
feature_schema="vibration-v3",
|
| 128 |
+
extra_metadata={"trained_on": "synthetic_edge_sample"},
|
| 129 |
+
)
|
| 130 |
+
print(f" Saved Manifest: {manifest_path.name}")
|
| 131 |
+
|
| 132 |
+
# Reload model and verify SHA-256 parameter integrity
|
| 133 |
+
loaded_net, loaded_manifest = load_assembly_model(manifest_path)
|
| 134 |
+
print(f" Verified SHA-256: {loaded_manifest.parameters_sha256[:16]}... (Valid)")
|
| 135 |
+
|
| 136 |
+
reloaded_pred = loaded_net.forward(x)
|
| 137 |
+
print(f" Reloaded Model Prediction: {reloaded_pred[0]:.4f}")
|
| 138 |
+
assert np.isclose(reloaded_pred[0], final_pred[0]), "Reloaded model must match original weights"
|
| 139 |
+
|
| 140 |
+
print("\nAll edge runtime checks passed successfully.")
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
if __name__ == "__main__":
|
| 144 |
+
run_edge_runtime()
|
examples/signal_analysis.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Scientific Signal Analysis Example for Sofia Engine.
|
| 2 |
+
|
| 3 |
+
Demonstrates deterministic digital signal processing across mechanical vibration
|
| 4 |
+
and industrial electrical domains:
|
| 5 |
+
1. FFT magnitude spectrum & peak detection
|
| 6 |
+
2. Welch power spectral density & Parseval energy conservation
|
| 7 |
+
3. Hilbert transform analytic amplitude envelope
|
| 8 |
+
4. Fortescue 3-phase symmetrical components & Voltage Unbalance Factor (VUF)
|
| 9 |
+
|
| 10 |
+
Run:
|
| 11 |
+
python examples/signal_analysis.py
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from __future__ import annotations
|
| 15 |
+
|
| 16 |
+
import numpy as np
|
| 17 |
+
|
| 18 |
+
from sofia_ai.signal.electrical import compute_symmetrical_components
|
| 19 |
+
from sofia_ai.signal.envelope import amplitude_envelope
|
| 20 |
+
from sofia_ai.signal.spectral import peak_frequency, rfft_magnitude, welch_psd
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def run_signal_analysis() -> None:
|
| 24 |
+
print("=== Sofia Engine: Scientific Signal Analysis ===")
|
| 25 |
+
|
| 26 |
+
# -------------------------------------------------------------------------
|
| 27 |
+
# 1. Vibration Spectral Analysis (FFT & Welch PSD)
|
| 28 |
+
# -------------------------------------------------------------------------
|
| 29 |
+
fs = 2000.0 # 2 kHz sampling rate
|
| 30 |
+
n = 2000 # 1 second duration
|
| 31 |
+
t = np.arange(n) / fs
|
| 32 |
+
|
| 33 |
+
# Synthesize multi-tone machine vibration:
|
| 34 |
+
# 50 Hz shaft rotation (0.8 m/s^2) + 250 Hz gear-mesh tone (0.3 m/s^2)
|
| 35 |
+
tone_50 = 0.8 * np.sin(2 * np.pi * 50.0 * t)
|
| 36 |
+
tone_250 = 0.3 * np.sin(2 * np.pi * 250.0 * t)
|
| 37 |
+
noise = 0.05 * np.random.default_rng(123).normal(size=n)
|
| 38 |
+
signal = tone_50 + tone_250 + noise
|
| 39 |
+
|
| 40 |
+
print(f"\n[1] Vibration Telemetry ({n} samples @ {fs} Hz)")
|
| 41 |
+
|
| 42 |
+
# Compute FFT magnitude spectrum
|
| 43 |
+
spec = rfft_magnitude(signal, fs, window="hann", detrend_mean=True)
|
| 44 |
+
f_peak = peak_frequency(spec.frequencies, spec.values)
|
| 45 |
+
mag_peak = float(np.max(spec.values))
|
| 46 |
+
print(f" FFT Peak Frequency: {f_peak:.1f} Hz (Magnitude: {mag_peak:.4f})")
|
| 47 |
+
|
| 48 |
+
# Compute Welch PSD
|
| 49 |
+
psd = welch_psd(signal, fs, segment_length=512, overlap=0.5, window="hann")
|
| 50 |
+
# Parseval check: integral of PSD approx equals variance of signal
|
| 51 |
+
signal_variance = float(np.var(signal))
|
| 52 |
+
psd_total_power = psd.total_power
|
| 53 |
+
parseval_ratio = psd_total_power / max(signal_variance, 1e-12)
|
| 54 |
+
|
| 55 |
+
print(f" Welch PSD Total Power: {psd_total_power:.4f}")
|
| 56 |
+
print(f" Time-Domain Variance: {signal_variance:.4f}")
|
| 57 |
+
print(f" Parseval Energy Ratio: {parseval_ratio:.4f} (expected ~1.0)")
|
| 58 |
+
|
| 59 |
+
# -------------------------------------------------------------------------
|
| 60 |
+
# 2. Bearing Fault Envelope Demodulation (Hilbert Transform)
|
| 61 |
+
# -------------------------------------------------------------------------
|
| 62 |
+
print("\n[2] Amplitude Demodulation (Hilbert Analytic Envelope)")
|
| 63 |
+
# Amplitude modulated signal: 200 Hz carrier modulated at 15 Hz fault pass frequency
|
| 64 |
+
carrier_freq = 200.0
|
| 65 |
+
mod_freq = 15.0
|
| 66 |
+
envelope_true = 1.0 + 0.6 * np.cos(2 * np.pi * mod_freq * t)
|
| 67 |
+
am_signal = envelope_true * np.cos(2 * np.pi * carrier_freq * t)
|
| 68 |
+
|
| 69 |
+
env = amplitude_envelope(am_signal)
|
| 70 |
+
env_spec = rfft_magnitude(env - np.mean(env), fs, window="hann")
|
| 71 |
+
env_peak_f = peak_frequency(env_spec.frequencies, env_spec.values)
|
| 72 |
+
print(f" Extracted Modulation Frequency: {env_peak_f:.1f} Hz (expected {mod_freq:.1f} Hz)")
|
| 73 |
+
|
| 74 |
+
# -------------------------------------------------------------------------
|
| 75 |
+
# 3. 3-Phase Symmetrical Components (Fortescue Transformation)
|
| 76 |
+
# -------------------------------------------------------------------------
|
| 77 |
+
print("\n[3] 3-Phase Symmetrical Components (IEC / IEEE 519 analysis)")
|
| 78 |
+
# Unbalanced 3-phase voltages (Va=230V @ 0°, Vb=220V @ -125°, Vc=215V @ 115°)
|
| 79 |
+
sym = compute_symmetrical_components(
|
| 80 |
+
va_amp=230.0, va_phase_deg=0.0,
|
| 81 |
+
vb_amp=220.0, vb_phase_deg=-125.0,
|
| 82 |
+
vc_amp=215.0, vc_phase_deg=115.0,
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
print(f" Positive Sequence (V1): {sym.v1_pos_seq_v:.2f} V")
|
| 86 |
+
print(f" Negative Sequence (V2): {sym.v2_neg_seq_v:.2f} V")
|
| 87 |
+
print(f" Zero Sequence (V0): {sym.v0_zero_seq_v:.2f} V")
|
| 88 |
+
print(f" Voltage Unbalance Factor (VUF): {sym.vuf_percent:.2f}%")
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
if __name__ == "__main__":
|
| 92 |
+
run_signal_analysis()
|
model_manifest.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://huggingface.co/rootcastleengineering/sofia/raw/main/schemas/model.schema.json",
|
| 3 |
+
"schema": "sofia.model-manifest.v1",
|
| 4 |
+
"name": "Sofia Engine",
|
| 5 |
+
"publisher": "Rootcastle Engineering & Innovation",
|
| 6 |
+
"license": "Apache-2.0",
|
| 7 |
+
"source_repository": "https://github.com/rootcastleco/sofia-ai",
|
| 8 |
+
"artifact_type": "scientific-edge-runtime",
|
| 9 |
+
"version": "3.0.0a1",
|
| 10 |
+
"checkpoint": null,
|
| 11 |
+
"feature_schema": "3.0",
|
| 12 |
+
"parameters_sha256": null,
|
| 13 |
+
"training": {
|
| 14 |
+
"trained": false,
|
| 15 |
+
"dataset": null,
|
| 16 |
+
"metrics": null,
|
| 17 |
+
"note": "No canonical pretrained checkpoint is distributed with this runtime release."
|
| 18 |
+
},
|
| 19 |
+
"provenance": {
|
| 20 |
+
"git_commit": "3f1d5e85f8ab66870168f185a74bc80790926214",
|
| 21 |
+
"release": "3.0.0a1",
|
| 22 |
+
"timestamp_utc": "2026-09-22T00:03:00Z"
|
| 23 |
+
}
|
| 24 |
+
}
|
releases/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sofia Engine Release Provenance
|
| 2 |
+
|
| 3 |
+
Every artifact distributed on Hugging Face is linked to a deterministic release commit on GitHub.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## Current Release: `3.0.0a1`
|
| 8 |
+
|
| 9 |
+
- **Release Date:** 2026-09-22
|
| 10 |
+
- **Canonical Repository:** [rootcastleco/sofia-ai](https://github.com/rootcastleco/sofia-ai)
|
| 11 |
+
- **Git Branch:** `feature/sofia-runtime-v3`
|
| 12 |
+
- **Git Commit SHA:** `3f1d5e85f8ab66870168f185a74bc80790926214`
|
| 13 |
+
- **PyPI Distribution Package:** `sofia-engine == 3.0.0a1`
|
| 14 |
+
- **npm TypeScript SDK Package:** `@rootcastle/sofia-engine @ 3.0.0a1`
|
| 15 |
+
- **DOI:** `10.57967/hf/10549`
|
| 16 |
+
- **Feature Vector Schema Version:** `3.0`
|
| 17 |
+
- **Model Manifest Schema Version:** `sofia.model-manifest.v1`
|
| 18 |
+
- **Quality Gates Passed:**
|
| 19 |
+
- `pytest`: 898 passed, 1 skipped (`torch` optional), 0 failed
|
| 20 |
+
- `node --test`: 4 passed, 0 failed
|
| 21 |
+
- `ruff`: 0 errors
|
| 22 |
+
- `mypy`: 0 errors (strict mode across 91 files)
|
| 23 |
+
- `verification-matrix.md`: 49 / 49 requirements PASS
|
runtime_manifest.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "sofia.runtime-manifest.v1",
|
| 3 |
+
"name": "Sofia Engine",
|
| 4 |
+
"version": "3.0.0a1",
|
| 5 |
+
"release_date": "2026-09-22",
|
| 6 |
+
"provenance": {
|
| 7 |
+
"git_commit": "3f1d5e85f8ab66870168f185a74bc80790926214",
|
| 8 |
+
"repository": "https://github.com/rootcastleco/sofia-ai",
|
| 9 |
+
"branch": "feature/sofia-runtime-v3"
|
| 10 |
+
},
|
| 11 |
+
"runtime_environment": {
|
| 12 |
+
"python": ">=3.11",
|
| 13 |
+
"dependencies": {
|
| 14 |
+
"core": ["numpy>=1.24"],
|
| 15 |
+
"optional_industrial": ["paho-mqtt>=1.6", "pymodbus>=3.0", "pyserial>=3.5"],
|
| 16 |
+
"optional_ml": ["onnxruntime>=1.15", "torch>=2.0"],
|
| 17 |
+
"optional_copilot": ["openai>=1.0"]
|
| 18 |
+
},
|
| 19 |
+
"supported_architectures": ["x86_64", "arm64", "armv7l", "c99-embedded"]
|
| 20 |
+
},
|
| 21 |
+
"contracts": {
|
| 22 |
+
"feature_vector_schema": "3.0",
|
| 23 |
+
"model_manifest_schema": "sofia.model-manifest.v1",
|
| 24 |
+
"vm_bytecode_version": "1.0",
|
| 25 |
+
"embedded_q_format": "Q16.16"
|
| 26 |
+
},
|
| 27 |
+
"performance_budgets": {
|
| 28 |
+
"fft_1024_us_ceiling": 500,
|
| 29 |
+
"fft_4096_us_ceiling": 2000,
|
| 30 |
+
"envelope_2048_us_ceiling": 1000,
|
| 31 |
+
"symmetrical_components_us_ceiling": 1500
|
| 32 |
+
},
|
| 33 |
+
"subsystem_maturity": {
|
| 34 |
+
"scientific_dsp": "stable",
|
| 35 |
+
"telemetry_runtime": "stable",
|
| 36 |
+
"diagnostics_engine": "stable",
|
| 37 |
+
"policy_engine": "stable",
|
| 38 |
+
"embedded_c99": "stable",
|
| 39 |
+
"assembly_vm": "beta",
|
| 40 |
+
"in_situ_learning": "experimental",
|
| 41 |
+
"quantum_emulation": "experimental",
|
| 42 |
+
"llm_copilot": "optional"
|
| 43 |
+
}
|
| 44 |
+
}
|
schemas/feature-vector.schema.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
| 3 |
+
"$id": "https://huggingface.co/rootcastleengineering/sofia/raw/main/schemas/feature-vector.schema.json",
|
| 4 |
+
"title": "SofiaFeatureVector",
|
| 5 |
+
"description": "Schema for Sofia Engine ordered, named, unit-bearing feature vectors (Schema v3.0).",
|
| 6 |
+
"type": "object",
|
| 7 |
+
"properties": {
|
| 8 |
+
"schema_version": {
|
| 9 |
+
"type": "string",
|
| 10 |
+
"enum": ["3.0"]
|
| 11 |
+
},
|
| 12 |
+
"extractor_id": {
|
| 13 |
+
"type": "string"
|
| 14 |
+
},
|
| 15 |
+
"extractor_version": {
|
| 16 |
+
"type": "string"
|
| 17 |
+
},
|
| 18 |
+
"source_channel": {
|
| 19 |
+
"type": "string"
|
| 20 |
+
},
|
| 21 |
+
"sample_rate": {
|
| 22 |
+
"type": "number",
|
| 23 |
+
"minimum": 0
|
| 24 |
+
},
|
| 25 |
+
"quality": {
|
| 26 |
+
"type": "string",
|
| 27 |
+
"enum": ["GOOD", "DEGRADED", "UNCERTAIN", "INVALID", "STALE", "SATURATED"]
|
| 28 |
+
},
|
| 29 |
+
"names": {
|
| 30 |
+
"type": "array",
|
| 31 |
+
"items": { "type": "string" }
|
| 32 |
+
},
|
| 33 |
+
"values": {
|
| 34 |
+
"type": "array",
|
| 35 |
+
"items": { "type": "number" }
|
| 36 |
+
},
|
| 37 |
+
"uncertainties": {
|
| 38 |
+
"type": "array",
|
| 39 |
+
"items": { "type": "number", "minimum": 0 }
|
| 40 |
+
},
|
| 41 |
+
"features": {
|
| 42 |
+
"type": "array",
|
| 43 |
+
"items": {
|
| 44 |
+
"type": "object",
|
| 45 |
+
"properties": {
|
| 46 |
+
"name": { "type": "string" },
|
| 47 |
+
"value": { "type": "number" },
|
| 48 |
+
"unit": { "type": "string" },
|
| 49 |
+
"uncertainty": { "type": "number", "minimum": 0 },
|
| 50 |
+
"quality": { "type": "string" },
|
| 51 |
+
"algorithm": { "type": "string" },
|
| 52 |
+
"algorithm_version": { "type": "string" }
|
| 53 |
+
},
|
| 54 |
+
"required": ["name", "value", "unit"]
|
| 55 |
+
}
|
| 56 |
+
},
|
| 57 |
+
"metadata": {
|
| 58 |
+
"type": "object"
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
"required": ["schema_version", "extractor_id", "extractor_version", "names", "values"]
|
| 62 |
+
}
|
schemas/model.schema.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
| 3 |
+
"$id": "https://huggingface.co/rootcastleengineering/sofia/raw/main/schemas/model.schema.json",
|
| 4 |
+
"title": "SofiaModelManifest",
|
| 5 |
+
"description": "Schema for Sofia Engine model artifacts, checkpoints, and parameter archives.",
|
| 6 |
+
"type": "object",
|
| 7 |
+
"properties": {
|
| 8 |
+
"schema": {
|
| 9 |
+
"type": "string",
|
| 10 |
+
"enum": ["sofia.model-manifest.v1"]
|
| 11 |
+
},
|
| 12 |
+
"name": {
|
| 13 |
+
"type": "string"
|
| 14 |
+
},
|
| 15 |
+
"publisher": {
|
| 16 |
+
"type": "string"
|
| 17 |
+
},
|
| 18 |
+
"license": {
|
| 19 |
+
"type": "string"
|
| 20 |
+
},
|
| 21 |
+
"source_repository": {
|
| 22 |
+
"type": "string",
|
| 23 |
+
"format": "uri"
|
| 24 |
+
},
|
| 25 |
+
"artifact_type": {
|
| 26 |
+
"type": "string",
|
| 27 |
+
"enum": ["scientific-edge-runtime", "neural-checkpoint", "linear-model"]
|
| 28 |
+
},
|
| 29 |
+
"version": {
|
| 30 |
+
"type": "string"
|
| 31 |
+
},
|
| 32 |
+
"checkpoint": {
|
| 33 |
+
"type": ["string", "null"]
|
| 34 |
+
},
|
| 35 |
+
"feature_schema": {
|
| 36 |
+
"type": ["string", "null"]
|
| 37 |
+
},
|
| 38 |
+
"parameters_sha256": {
|
| 39 |
+
"type": ["string", "null"],
|
| 40 |
+
"pattern": "^[a-fA-F0-9]{64}$"
|
| 41 |
+
},
|
| 42 |
+
"training": {
|
| 43 |
+
"type": "object",
|
| 44 |
+
"properties": {
|
| 45 |
+
"trained": { "type": "boolean" },
|
| 46 |
+
"dataset": { "type": ["string", "null"] },
|
| 47 |
+
"metrics": { "type": ["object", "null"] },
|
| 48 |
+
"note": { "type": "string" }
|
| 49 |
+
},
|
| 50 |
+
"required": ["trained"]
|
| 51 |
+
},
|
| 52 |
+
"provenance": {
|
| 53 |
+
"type": "object",
|
| 54 |
+
"properties": {
|
| 55 |
+
"git_commit": { "type": ["string", "null"] },
|
| 56 |
+
"release": { "type": ["string", "null"] },
|
| 57 |
+
"timestamp_utc": { "type": ["string", "null"] }
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
"required": ["schema", "name", "publisher", "license", "source_repository", "artifact_type", "version", "training"]
|
| 62 |
+
}
|