reqthread 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. reqthread-0.2.0/LICENSE +202 -0
  2. reqthread-0.2.0/MANIFEST.in +6 -0
  3. reqthread-0.2.0/PKG-INFO +148 -0
  4. reqthread-0.2.0/README.md +118 -0
  5. reqthread-0.2.0/docs/EVIDENCE_PACKAGE_SPEC.md +290 -0
  6. reqthread-0.2.0/docs/FORMATS.md +185 -0
  7. reqthread-0.2.0/examples/reference/bundle.json +133 -0
  8. reqthread-0.2.0/examples/reference/requirements/SSR-001.req.md +18 -0
  9. reqthread-0.2.0/examples/reference/requirements/SSR-002.req.md +18 -0
  10. reqthread-0.2.0/examples/reference/requirements/SSR-003.req.md +18 -0
  11. reqthread-0.2.0/examples/reference/requirements/SYS-004.req.md +15 -0
  12. reqthread-0.2.0/examples/wb55-ref/.gitignore +1 -0
  13. reqthread-0.2.0/examples/wb55-ref/README.md +33 -0
  14. reqthread-0.2.0/examples/wb55-ref/architecture/ARCH-RX.arch.md +8 -0
  15. reqthread-0.2.0/examples/wb55-ref/causes/FM-001.cause.md +10 -0
  16. reqthread-0.2.0/examples/wb55-ref/causes/UCA-001.cause.md +10 -0
  17. reqthread-0.2.0/examples/wb55-ref/causes/UCA-002.cause.md +10 -0
  18. reqthread-0.2.0/examples/wb55-ref/causes/UCA-003.cause.md +10 -0
  19. reqthread-0.2.0/examples/wb55-ref/ci-out/coverage.lcov +80 -0
  20. reqthread-0.2.0/examples/wb55-ref/ci-out/coverage.xml +3 -0
  21. reqthread-0.2.0/examples/wb55-ref/ci-out/flawfinder.sarif +119 -0
  22. reqthread-0.2.0/examples/wb55-ref/ci-out/junit-fault.xml +1 -0
  23. reqthread-0.2.0/examples/wb55-ref/ci-out/junit-module.xml +1 -0
  24. reqthread-0.2.0/examples/wb55-ref/design/DD-AUTH.design.md +8 -0
  25. reqthread-0.2.0/examples/wb55-ref/design/DD-TIMEOUT.design.md +8 -0
  26. reqthread-0.2.0/examples/wb55-ref/deviations.yaml +9 -0
  27. reqthread-0.2.0/examples/wb55-ref/hazards/HAZ-001.hazard.md +8 -0
  28. reqthread-0.2.0/examples/wb55-ref/make_fixtures.sh +25 -0
  29. reqthread-0.2.0/examples/wb55-ref/pytest.ini +3 -0
  30. reqthread-0.2.0/examples/wb55-ref/reqthread.yaml +61 -0
  31. reqthread-0.2.0/examples/wb55-ref/requirements/SSR-001.req.md +19 -0
  32. reqthread-0.2.0/examples/wb55-ref/requirements/SSR-002.req.md +19 -0
  33. reqthread-0.2.0/examples/wb55-ref/requirements/SSR-003.req.md +19 -0
  34. reqthread-0.2.0/examples/wb55-ref/requirements/SYS-004.req.md +15 -0
  35. reqthread-0.2.0/examples/wb55-ref/src/frame_auth.c +48 -0
  36. reqthread-0.2.0/examples/wb55-ref/src/frame_auth.h +27 -0
  37. reqthread-0.2.0/examples/wb55-ref/src/main.c +10 -0
  38. reqthread-0.2.0/examples/wb55-ref/src/supervisor.c +32 -0
  39. reqthread-0.2.0/examples/wb55-ref/src/supervisor.h +19 -0
  40. reqthread-0.2.0/examples/wb55-ref/tests/fault/test_faults.py +106 -0
  41. reqthread-0.2.0/examples/wb55-ref/tests/hil/test_link_drop.py +15 -0
  42. reqthread-0.2.0/examples/wb55-ref/tests/module/conftest.py +9 -0
  43. reqthread-0.2.0/examples/wb55-ref/tests/module/test_frame_auth.py +34 -0
  44. reqthread-0.2.0/examples/wb55-ref/tests/module/test_supervisor.py +36 -0
  45. reqthread-0.2.0/pyproject.toml +47 -0
  46. reqthread-0.2.0/setup.cfg +4 -0
  47. reqthread-0.2.0/src/reqthread/__init__.py +4 -0
  48. reqthread-0.2.0/src/reqthread/__main__.py +5 -0
  49. reqthread-0.2.0/src/reqthread/build.py +467 -0
  50. reqthread-0.2.0/src/reqthread/cli.py +256 -0
  51. reqthread-0.2.0/src/reqthread/formats.py +337 -0
  52. reqthread-0.2.0/src/reqthread/gates.py +138 -0
  53. reqthread-0.2.0/src/reqthread/ingest.py +221 -0
  54. reqthread-0.2.0/src/reqthread/report.py +224 -0
  55. reqthread-0.2.0/src/reqthread/scan.py +345 -0
  56. reqthread-0.2.0/src/reqthread/schema/architecture.schema.json +13 -0
  57. reqthread-0.2.0/src/reqthread/schema/bundle.schema.json +1149 -0
  58. reqthread-0.2.0/src/reqthread/schema/cause.schema.json +74 -0
  59. reqthread-0.2.0/src/reqthread/schema/config.schema.json +368 -0
  60. reqthread-0.2.0/src/reqthread/schema/design.schema.json +17 -0
  61. reqthread-0.2.0/src/reqthread/schema/deviations.schema.json +32 -0
  62. reqthread-0.2.0/src/reqthread/schema/hazard.schema.json +29 -0
  63. reqthread-0.2.0/src/reqthread/schema/requirement.schema.json +88 -0
  64. reqthread-0.2.0/src/reqthread/schema/standard-data.schema.json +138 -0
  65. reqthread-0.2.0/src/reqthread.egg-info/PKG-INFO +148 -0
  66. reqthread-0.2.0/src/reqthread.egg-info/SOURCES.txt +75 -0
  67. reqthread-0.2.0/src/reqthread.egg-info/dependency_links.txt +1 -0
  68. reqthread-0.2.0/src/reqthread.egg-info/entry_points.txt +2 -0
  69. reqthread-0.2.0/src/reqthread.egg-info/requires.txt +2 -0
  70. reqthread-0.2.0/src/reqthread.egg-info/top_level.txt +1 -0
  71. reqthread-0.2.0/standards/demo-std.yaml +55 -0
  72. reqthread-0.2.0/standards/iec61508-3.skeleton.yaml +68 -0
  73. reqthread-0.2.0/tests/test_build_cli.py +204 -0
  74. reqthread-0.2.0/tests/test_formats.py +231 -0
  75. reqthread-0.2.0/tests/test_hazards.py +166 -0
  76. reqthread-0.2.0/tests/test_ingest.py +143 -0
  77. reqthread-0.2.0/tests/test_scan.py +248 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ graft docs
2
+ graft examples
3
+ graft standards
4
+ graft tests
5
+ prune examples/wb55-ref/build
6
+ global-exclude __pycache__ *.py[cod]
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: reqthread
3
+ Version: 0.2.0
4
+ Summary: Requirements traceability and certification evidence for safety-critical embedded software.
5
+ Author: James Watson
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/eggheadengineer/reqthread
8
+ Project-URL: Documentation, https://github.com/eggheadengineer/reqthread/blob/main/docs/FORMATS.md
9
+ Project-URL: Issues, https://github.com/eggheadengineer/reqthread/issues
10
+ Keywords: traceability,functional safety,IEC 61508,embedded,requirements,certification,evidence,zephyr
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Embedded Systems
22
+ Classifier: Topic :: Software Development :: Quality Assurance
23
+ Classifier: Topic :: Software Development :: Testing
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: PyYAML>=6
28
+ Requires-Dist: jsonschema>=4.10
29
+ Dynamic: license-file
30
+
31
+ # reqthread
32
+
33
+ > The golden thread from requirement to evidence.
34
+
35
+ Traceability and certification evidence for safety-critical embedded software. It reads what your repo
36
+ already has — requirements as files, `@satisfies` / `@verifies` annotations in code and tests, and the
37
+ JUnit, coverage, and SARIF output your CI already produces — and builds a hashed evidence bundle, checks
38
+ it against gate rules, and writes a standalone HTML report.
39
+
40
+ It fails your pipeline when a requirement loses its test, a test verifying a safety requirement fails or
41
+ never runs, code traces to nothing, or a static-analysis finding is open. With a baseline, it fails only
42
+ on **new** gaps, so a team with existing gaps can adopt it today.
43
+
44
+ Standard-agnostic by design: integrity levels, test levels, tool classes, and package sections come from
45
+ a **standard-data file you load from your own licensed copy**. The tool ships no standard text. A
46
+ structure-only IEC 61508-3 skeleton is in `standards/`.
47
+
48
+ ## Install
49
+
50
+ ```
51
+ pip install git+https://github.com/eggheadengineer/reqthread
52
+ ```
53
+
54
+ Python 3.10 or later. Two dependencies: PyYAML and jsonschema. A PyPI release (`pip install reqthread`) is coming.
55
+
56
+ ## Quick start
57
+
58
+ ```
59
+ git clone https://github.com/eggheadengineer/reqthread && cd reqthread
60
+ pip install .
61
+ reqthread check -c examples/wb55-ref/reqthread.yaml --html report.html
62
+ ```
63
+
64
+ `examples/wb55-ref/` is a real reference project — a black-channel heartbeat receiver in C, tested from
65
+ pytest, with real gcov coverage and real flawfinder SARIF. It has three genuine gaps; the report shows them.
66
+
67
+ ## Annotate code and tests
68
+
69
+ ```c
70
+ /* @satisfies SSR-001
71
+ * @implements DD-TIMEOUT */
72
+ bool hb_supervise(hb_state_t *s, uint32_t now_ms) { … }
73
+ ```
74
+
75
+ ```python
76
+ def test_trip_after_300ms(lib):
77
+ """@verifies SSR-001"""
78
+ ```
79
+
80
+ A tag applies to the function it is inside, or the function directly below it. A block containing
81
+ `@file` applies to the whole file. Anything ambiguous is an **error**, never a guess. Zephyr `ZTEST`,
82
+ GoogleTest `TEST`, Unity `test_*`, and pytest tests are recognised.
83
+
84
+ ## Commands
85
+
86
+ | Command | Does | Exit |
87
+ | --- | --- | --- |
88
+ | `reqthread check` | build, evaluate gates, optionally ratchet with `--baseline`; write `-o` bundle, `--html`, `--json` | 0 pass · 1 error · 2 gaps |
89
+ | `reqthread build` | build and write a bundle (`--previous` chains hashes) | 0 · 1 |
90
+ | `reqthread report` | render HTML from a bundle | 0 · 1 |
91
+ | `reqthread hazards` | hazard analysis on its own: validate hazard and cause files, print the hazard matrix | 0 · 1 · 2 gaps |
92
+ | `reqthread validate` | validate standard data, requirement files, or a hand-written bundle | 0 · 1 |
93
+
94
+ ## Gate rules
95
+
96
+ 1. Every software safety requirement has a verifying test at each declared test level.
97
+ 2. Every software safety requirement derives from a system-level requirement.
98
+ 3. Every code unit traces to a requirement or design element, or is marked `@infrastructure` with a reason.
99
+ 4. Every test verifying a safety requirement **passed** at baseline and failed nowhere — skipped or never-run doesn't count.
100
+ 7. Every static-analysis finding is fixed or covered by an unexpired, approved deviation.
101
+ 11. Every hazard is mitigated by at least one requirement, directly or through one of its causes.
102
+ 12. Every cause (STPA unsafe control action or FMEA failure mode) is mitigated by a requirement, or its residual risk is formally accepted.
103
+ 13. Every requirement that mitigates a hazard is a safety requirement with an integrity level.
104
+
105
+ ## Hazard analysis
106
+
107
+ Hazards and causes live in the repo as files too, so the trace runs from hazard to cause to requirement to test to CI result. In the reference project, HAZ-001 (machine keeps moving after a stop command) traces through three unsafe control actions to SSR-001..003, and a fourth cause, a stuck-high output driver, has no mitigating requirement. The hazard analysis found a gap the requirements never knew about.
108
+
109
+ ```
110
+ reqthread hazards --hazards hazards/ --causes causes/ --requirements requirements/
111
+ ```
112
+
113
+ That command needs no project config, standard data, or CI output, so a safety engineer can start with hazard analysis alone and add the rest later.
114
+
115
+ ## CI
116
+
117
+ - **GitHub:** `ci/github/action.yml` (composite action)
118
+
119
+ ```yaml
120
+ permissions: { contents: read, actions: read } # actions: read lets PR runs fetch the baseline
121
+ jobs:
122
+ traceability:
123
+ runs-on: ubuntu-latest
124
+ steps:
125
+ - uses: actions/checkout@v7
126
+ - uses: eggheadengineer/reqthread/ci/github@main # pin a release tag once v0.1.0 is out
127
+ with:
128
+ config: reqthread.yaml
129
+ ```
130
+ - **GitLab:** `templates/reqthread.yml` (CI/CD component)
131
+
132
+ Both record the default branch's bundle as the baseline and fail merge requests only on new gaps.
133
+ The GitHub Action has been exercised end to end on GitHub-hosted runners; the GitLab component has not run yet.
134
+
135
+ ## Docs
136
+
137
+ - `docs/FORMATS.md` — file formats, annotations, bundle model
138
+ - `docs/EVIDENCE_PACKAGE_SPEC.md` — what an IEC 61508-3 assessor expects, and what this automates
139
+
140
+ ## Tests
141
+
142
+ ```
143
+ PYTHONPATH=src python3 -m unittest discover -s tests
144
+ ```
145
+
146
+ ## License
147
+
148
+ Apache-2.0. See `LICENSE`.
@@ -0,0 +1,118 @@
1
+ # reqthread
2
+
3
+ > The golden thread from requirement to evidence.
4
+
5
+ Traceability and certification evidence for safety-critical embedded software. It reads what your repo
6
+ already has — requirements as files, `@satisfies` / `@verifies` annotations in code and tests, and the
7
+ JUnit, coverage, and SARIF output your CI already produces — and builds a hashed evidence bundle, checks
8
+ it against gate rules, and writes a standalone HTML report.
9
+
10
+ It fails your pipeline when a requirement loses its test, a test verifying a safety requirement fails or
11
+ never runs, code traces to nothing, or a static-analysis finding is open. With a baseline, it fails only
12
+ on **new** gaps, so a team with existing gaps can adopt it today.
13
+
14
+ Standard-agnostic by design: integrity levels, test levels, tool classes, and package sections come from
15
+ a **standard-data file you load from your own licensed copy**. The tool ships no standard text. A
16
+ structure-only IEC 61508-3 skeleton is in `standards/`.
17
+
18
+ ## Install
19
+
20
+ ```
21
+ pip install git+https://github.com/eggheadengineer/reqthread
22
+ ```
23
+
24
+ Python 3.10 or later. Two dependencies: PyYAML and jsonschema. A PyPI release (`pip install reqthread`) is coming.
25
+
26
+ ## Quick start
27
+
28
+ ```
29
+ git clone https://github.com/eggheadengineer/reqthread && cd reqthread
30
+ pip install .
31
+ reqthread check -c examples/wb55-ref/reqthread.yaml --html report.html
32
+ ```
33
+
34
+ `examples/wb55-ref/` is a real reference project — a black-channel heartbeat receiver in C, tested from
35
+ pytest, with real gcov coverage and real flawfinder SARIF. It has three genuine gaps; the report shows them.
36
+
37
+ ## Annotate code and tests
38
+
39
+ ```c
40
+ /* @satisfies SSR-001
41
+ * @implements DD-TIMEOUT */
42
+ bool hb_supervise(hb_state_t *s, uint32_t now_ms) { … }
43
+ ```
44
+
45
+ ```python
46
+ def test_trip_after_300ms(lib):
47
+ """@verifies SSR-001"""
48
+ ```
49
+
50
+ A tag applies to the function it is inside, or the function directly below it. A block containing
51
+ `@file` applies to the whole file. Anything ambiguous is an **error**, never a guess. Zephyr `ZTEST`,
52
+ GoogleTest `TEST`, Unity `test_*`, and pytest tests are recognised.
53
+
54
+ ## Commands
55
+
56
+ | Command | Does | Exit |
57
+ | --- | --- | --- |
58
+ | `reqthread check` | build, evaluate gates, optionally ratchet with `--baseline`; write `-o` bundle, `--html`, `--json` | 0 pass · 1 error · 2 gaps |
59
+ | `reqthread build` | build and write a bundle (`--previous` chains hashes) | 0 · 1 |
60
+ | `reqthread report` | render HTML from a bundle | 0 · 1 |
61
+ | `reqthread hazards` | hazard analysis on its own: validate hazard and cause files, print the hazard matrix | 0 · 1 · 2 gaps |
62
+ | `reqthread validate` | validate standard data, requirement files, or a hand-written bundle | 0 · 1 |
63
+
64
+ ## Gate rules
65
+
66
+ 1. Every software safety requirement has a verifying test at each declared test level.
67
+ 2. Every software safety requirement derives from a system-level requirement.
68
+ 3. Every code unit traces to a requirement or design element, or is marked `@infrastructure` with a reason.
69
+ 4. Every test verifying a safety requirement **passed** at baseline and failed nowhere — skipped or never-run doesn't count.
70
+ 7. Every static-analysis finding is fixed or covered by an unexpired, approved deviation.
71
+ 11. Every hazard is mitigated by at least one requirement, directly or through one of its causes.
72
+ 12. Every cause (STPA unsafe control action or FMEA failure mode) is mitigated by a requirement, or its residual risk is formally accepted.
73
+ 13. Every requirement that mitigates a hazard is a safety requirement with an integrity level.
74
+
75
+ ## Hazard analysis
76
+
77
+ Hazards and causes live in the repo as files too, so the trace runs from hazard to cause to requirement to test to CI result. In the reference project, HAZ-001 (machine keeps moving after a stop command) traces through three unsafe control actions to SSR-001..003, and a fourth cause, a stuck-high output driver, has no mitigating requirement. The hazard analysis found a gap the requirements never knew about.
78
+
79
+ ```
80
+ reqthread hazards --hazards hazards/ --causes causes/ --requirements requirements/
81
+ ```
82
+
83
+ That command needs no project config, standard data, or CI output, so a safety engineer can start with hazard analysis alone and add the rest later.
84
+
85
+ ## CI
86
+
87
+ - **GitHub:** `ci/github/action.yml` (composite action)
88
+
89
+ ```yaml
90
+ permissions: { contents: read, actions: read } # actions: read lets PR runs fetch the baseline
91
+ jobs:
92
+ traceability:
93
+ runs-on: ubuntu-latest
94
+ steps:
95
+ - uses: actions/checkout@v7
96
+ - uses: eggheadengineer/reqthread/ci/github@main # pin a release tag once v0.1.0 is out
97
+ with:
98
+ config: reqthread.yaml
99
+ ```
100
+ - **GitLab:** `templates/reqthread.yml` (CI/CD component)
101
+
102
+ Both record the default branch's bundle as the baseline and fail merge requests only on new gaps.
103
+ The GitHub Action has been exercised end to end on GitHub-hosted runners; the GitLab component has not run yet.
104
+
105
+ ## Docs
106
+
107
+ - `docs/FORMATS.md` — file formats, annotations, bundle model
108
+ - `docs/EVIDENCE_PACKAGE_SPEC.md` — what an IEC 61508-3 assessor expects, and what this automates
109
+
110
+ ## Tests
111
+
112
+ ```
113
+ PYTHONPATH=src python3 -m unittest discover -s tests
114
+ ```
115
+
116
+ ## License
117
+
118
+ Apache-2.0. See `LICENSE`.