qnx-blueprint 0.3.1__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 (89) hide show
  1. qnx_blueprint-0.3.1/LICENSE +202 -0
  2. qnx_blueprint-0.3.1/PKG-INFO +460 -0
  3. qnx_blueprint-0.3.1/README.md +445 -0
  4. qnx_blueprint-0.3.1/blueprint/__init__.py +3 -0
  5. qnx_blueprint-0.3.1/blueprint/__main__.py +433 -0
  6. qnx_blueprint-0.3.1/blueprint/api.py +87 -0
  7. qnx_blueprint-0.3.1/blueprint/checks.py +865 -0
  8. qnx_blueprint-0.3.1/blueprint/contract.py +146 -0
  9. qnx_blueprint-0.3.1/blueprint/explain.py +316 -0
  10. qnx_blueprint-0.3.1/blueprint/init_contract.py +151 -0
  11. qnx_blueprint-0.3.1/blueprint/ipc.py +292 -0
  12. qnx_blueprint-0.3.1/blueprint/junit.py +56 -0
  13. qnx_blueprint-0.3.1/blueprint/kev.py +208 -0
  14. qnx_blueprint-0.3.1/blueprint/mcp_server.py +93 -0
  15. qnx_blueprint-0.3.1/blueprint/perfetto.py +142 -0
  16. qnx_blueprint-0.3.1/blueprint/record.py +207 -0
  17. qnx_blueprint-0.3.1/blueprint/report.py +320 -0
  18. qnx_blueprint-0.3.1/blueprint/review.py +155 -0
  19. qnx_blueprint-0.3.1/blueprint/secpol.py +287 -0
  20. qnx_blueprint-0.3.1/blueprint/snapshot.py +57 -0
  21. qnx_blueprint-0.3.1/blueprint/topology.py +144 -0
  22. qnx_blueprint-0.3.1/blueprint/tpcompare.py +138 -0
  23. qnx_blueprint-0.3.1/demo/cockpit/blueprint.yaml +25 -0
  24. qnx_blueprint-0.3.1/demo/cockpit/cockpit.c +492 -0
  25. qnx_blueprint-0.3.1/demo/cockpit/explanations/1247da03a8127c2282f39f13.json +37 -0
  26. qnx_blueprint-0.3.1/demo/cockpit/explanations/2fc13323554255438fb52870.json +32 -0
  27. qnx_blueprint-0.3.1/demo/cockpit/explanations/336136a17a0c4329a02d493e.json +35 -0
  28. qnx_blueprint-0.3.1/demo/cockpit/explanations/3805bbea5dcada3ae3007eb1.json +35 -0
  29. qnx_blueprint-0.3.1/demo/cockpit/explanations/54ecfeec905968bba208cc5a.json +33 -0
  30. qnx_blueprint-0.3.1/demo/cockpit/explanations/645efe5c9e716b1394259fb0.json +30 -0
  31. qnx_blueprint-0.3.1/demo/cockpit/explanations/81e5161819f6f102afd79be8.json +27 -0
  32. qnx_blueprint-0.3.1/demo/cockpit/explanations/972e363d237cd9e7de73612c.json +45 -0
  33. qnx_blueprint-0.3.1/demo/cockpit/explanations/9af9777a63c1e7fde6eb33aa.json +33 -0
  34. qnx_blueprint-0.3.1/demo/cockpit/explanations/a3dc76bd69d185207996fc8d.json +36 -0
  35. qnx_blueprint-0.3.1/demo/cockpit/explanations/a66343f3e072684ffc2dd071.json +30 -0
  36. qnx_blueprint-0.3.1/demo/cockpit/explanations/b523c3a8de75f88d5276d0af.json +25 -0
  37. qnx_blueprint-0.3.1/demo/cockpit/explanations/d0b5769577f44c92cf49692b.json +37 -0
  38. qnx_blueprint-0.3.1/demo/cockpit/explanations/e7212c61ede9f30b5ce2c44c.json +39 -0
  39. qnx_blueprint-0.3.1/demo/cockpit/explanations/review-2afbbe620663f031df031c96.json +82 -0
  40. qnx_blueprint-0.3.1/demo/cockpit/realtime.yaml +32 -0
  41. qnx_blueprint-0.3.1/demo/cockpit/scenarios.yaml +59 -0
  42. qnx_blueprint-0.3.1/demo/cockpit/traces/backdoor.kev +0 -0
  43. qnx_blueprint-0.3.1/demo/cockpit/traces/camera-dies-fixed.kev +0 -0
  44. qnx_blueprint-0.3.1/demo/cockpit/traces/camera-dies.kev +0 -0
  45. qnx_blueprint-0.3.1/demo/cockpit/traces/camera-hang-fixed.kev +0 -0
  46. qnx_blueprint-0.3.1/demo/cockpit/traces/camera-hang-late.kev +0 -0
  47. qnx_blueprint-0.3.1/demo/cockpit/traces/camera-hang-late.pidin +118 -0
  48. qnx_blueprint-0.3.1/demo/cockpit/traces/camera-hang.kev +0 -0
  49. qnx_blueprint-0.3.1/demo/cockpit/traces/deadlock-late.kev +0 -0
  50. qnx_blueprint-0.3.1/demo/cockpit/traces/deadlock-late.pidin +118 -0
  51. qnx_blueprint-0.3.1/demo/cockpit/traces/deadlock.kev +0 -0
  52. qnx_blueprint-0.3.1/demo/cockpit/traces/ok-late.kev +0 -0
  53. qnx_blueprint-0.3.1/demo/cockpit/traces/ok-late.pidin +118 -0
  54. qnx_blueprint-0.3.1/demo/cockpit/traces/ok.kev +0 -0
  55. qnx_blueprint-0.3.1/demo/cockpit/traces/prio-inversion-fixed.kev +0 -0
  56. qnx_blueprint-0.3.1/demo/cockpit/traces/prio-inversion-fixed.pidin +119 -0
  57. qnx_blueprint-0.3.1/demo/cockpit/traces/prio-inversion.kev +0 -0
  58. qnx_blueprint-0.3.1/demo/cockpit/traces/prio-inversion.pidin +120 -0
  59. qnx_blueprint-0.3.1/demo/cockpit/traces/resmgr-backdoor.kev +0 -0
  60. qnx_blueprint-0.3.1/demo/cockpit/traces/resmgr-backdoor.pidin +121 -0
  61. qnx_blueprint-0.3.1/demo/cockpit/traces/resmgr-ok.kev +0 -0
  62. qnx_blueprint-0.3.1/demo/cockpit/traces/resmgr-ok.pidin +121 -0
  63. qnx_blueprint-0.3.1/demo/cockpit/traces/slow-reply.kev +0 -0
  64. qnx_blueprint-0.3.1/pyproject.toml +29 -0
  65. qnx_blueprint-0.3.1/qnx_blueprint.egg-info/PKG-INFO +460 -0
  66. qnx_blueprint-0.3.1/qnx_blueprint.egg-info/SOURCES.txt +87 -0
  67. qnx_blueprint-0.3.1/qnx_blueprint.egg-info/dependency_links.txt +1 -0
  68. qnx_blueprint-0.3.1/qnx_blueprint.egg-info/entry_points.txt +2 -0
  69. qnx_blueprint-0.3.1/qnx_blueprint.egg-info/requires.txt +7 -0
  70. qnx_blueprint-0.3.1/qnx_blueprint.egg-info/top_level.txt +1 -0
  71. qnx_blueprint-0.3.1/setup.cfg +4 -0
  72. qnx_blueprint-0.3.1/tests/test_aarch64.py +41 -0
  73. qnx_blueprint-0.3.1/tests/test_breakdown.py +45 -0
  74. qnx_blueprint-0.3.1/tests/test_checks.py +238 -0
  75. qnx_blueprint-0.3.1/tests/test_cockpit.py +56 -0
  76. qnx_blueprint-0.3.1/tests/test_cycles.py +45 -0
  77. qnx_blueprint-0.3.1/tests/test_explain.py +72 -0
  78. qnx_blueprint-0.3.1/tests/test_init.py +153 -0
  79. qnx_blueprint-0.3.1/tests/test_junit.py +40 -0
  80. qnx_blueprint-0.3.1/tests/test_kernel_denied.py +51 -0
  81. qnx_blueprint-0.3.1/tests/test_mcp.py +43 -0
  82. qnx_blueprint-0.3.1/tests/test_msgdemo.py +57 -0
  83. qnx_blueprint-0.3.1/tests/test_outputs.py +75 -0
  84. qnx_blueprint-0.3.1/tests/test_qpp.py +69 -0
  85. qnx_blueprint-0.3.1/tests/test_record.py +160 -0
  86. qnx_blueprint-0.3.1/tests/test_review.py +73 -0
  87. qnx_blueprint-0.3.1/tests/test_secpol.py +162 -0
  88. qnx_blueprint-0.3.1/tests/test_socketcan.py +74 -0
  89. qnx_blueprint-0.3.1/tests/test_traceprinter.py +32 -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,460 @@
1
+ Metadata-Version: 2.4
2
+ Name: qnx-blueprint
3
+ Version: 0.3.1
4
+ Summary: Architecture contracts for QNX 8.0 systems, checked against kernel traces
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: PyYAML>=6
10
+ Provides-Extra: explain
11
+ Requires-Dist: anthropic>=2.5; extra == "explain"
12
+ Provides-Extra: mcp
13
+ Requires-Dist: mcp>=2.3; extra == "mcp"
14
+ Dynamic: license-file
15
+
16
+ # Blueprint
17
+
18
+ [![ci](https://github.com/DmitriyTopka/qnx-blueprint/actions/workflows/ci.yml/badge.svg)](https://github.com/DmitriyTopka/qnx-blueprint/actions/workflows/ci.yml)
19
+
20
+ One contract, two enforcers: Blueprint checks a QNX 8.0 system against its
21
+ message architecture in CI, and turns the same file into a security policy
22
+ the kernel enforces.
23
+
24
+ A QNX system is a set of processes that talk through synchronous messages. The
25
+ design usually lives in someone's head or on a whiteboard: display asks nav,
26
+ nav asks gps, nobody calls back up the chain, and a dead camera must not take
27
+ the screen with it. Blueprint lets you write that design down in a few lines of
28
+ YAML, the contract.
29
+
30
+ - **Before release** it checks a real kernel trace against the contract. When
31
+ the system does something the design does not allow, the build fails and
32
+ the report says which process did what, with the trace events to prove it.
33
+ - **After release** the same file becomes the channel rules of a QNX security
34
+ policy. Booted in secure mode, the kernel refuses a connection the contract
35
+ does not allow: `cockpit: cannot open cockpit-gps: Operation not permitted`.
36
+
37
+ System Profiler shows you a trace. Blueprint knows what the trace should look
38
+ like and tells you where it does not.
39
+
40
+ **See it without installing anything:** the reports for every recorded
41
+ scenario and the codelab are at
42
+ [dmitriytopka.github.io/qnx-blueprint](https://dmitriytopka.github.io/qnx-blueprint/).
43
+ A 2:53 video of all of it: [youtu.be/rqJFxPH5Bjs](https://youtu.be/rqJFxPH5Bjs).
44
+
45
+ ## For judges
46
+
47
+ Links point at release v0.3.0, so the lines stay where they are.
48
+
49
+ | Criterion | Where to look | What it shows |
50
+ |---|---|---|
51
+ | Technological Implementation | [`kev.py`](https://github.com/DmitriyTopka/qnx-blueprint/blob/v0.3.0/blueprint/kev.py), [`ipc.py`](https://github.com/DmitriyTopka/qnx-blueprint/blob/v0.3.0/blueprint/ipc.py), [`checks.py`](https://github.com/DmitriyTopka/qnx-blueprint/blob/v0.3.0/blueprint/checks.py), [docs/TRACEPRINTER.md](https://github.com/DmitriyTopka/qnx-blueprint/blob/v0.3.0/docs/TRACEPRINTER.md) | the trace format read from scratch and compared with QNX's `traceprinter`: 1,071,509 events in 25 traces, none missing or different; 137 tests |
52
+ | Design | `blueprint demo`, [the reports](https://dmitriytopka.github.io/qnx-blueprint/), [`action.yml`](https://github.com/DmitriyTopka/qnx-blueprint/blob/v0.3.0/action.yml) | one command with no target, an HTML report, JUnit XML and a GitHub Action for CI |
53
+ | Potential Impact | [demo/external/qpp](https://github.com/DmitriyTopka/qnx-blueprint/tree/v0.3.0/demo/external/qpp), [demo/external/socketcan](https://github.com/DmitriyTopka/qnx-blueprint/tree/v0.3.0/demo/external/socketcan) | two BlackBerry systems we did not write: a stopped server found, and eight weak spots in Blueprint fixed on their traces |
54
+ | Innovation & AI Creativity | [`explain.py`](https://github.com/DmitriyTopka/qnx-blueprint/blob/v0.3.0/blueprint/explain.py), [`review.py`](https://github.com/DmitriyTopka/qnx-blueprint/blob/v0.3.0/blueprint/review.py), [`mcp_server.py`](https://github.com/DmitriyTopka/qnx-blueprint/blob/v0.3.0/blueprint/mcp_server.py) | Claude explains and reviews but never judges; an event id it cites that the trace does not have is dropped |
55
+ | Codelab bonus | [the contract codelab](https://dmitriytopka.github.io/qnx-blueprint/codelab/), [the secure-image codelab](https://dmitriytopka.github.io/qnx-blueprint/codelab/secure-image/) | a secure QNX 8.0 image from a policy you can check, with [a recorded live run](https://youtu.be/OHoixOUmPH8) |
56
+ | QNX-specific bonus | [demo/cockpit/secpol/evidence](https://github.com/DmitriyTopka/qnx-blueprint/tree/v0.3.0/demo/cockpit/secpol/evidence) | `mkqnximage --secpol=secure` on x86_64 and aarch64: serial logs, the compiled policy matching `/proc/boot/secpol.bin`, the kernel saying `Operation not permitted` |
57
+
58
+ ## Try it in one minute
59
+
60
+ No QNX target, SDP or API key needed. The repository ships traces recorded on
61
+ QNX 8.0 (x86_64, QEMU) from the demo system in `demo/cockpit`.
62
+
63
+ ```
64
+ python3 -m venv .venv && . .venv/bin/activate # or any Python 3.10+ environment
65
+ python3 -m pip install .
66
+ blueprint demo
67
+ ```
68
+
69
+ Without a clone, `pip install git+https://github.com/DmitriyTopka/qnx-blueprint`
70
+ in the same environment installs the same recorded traces with the package,
71
+ and `blueprint demo` runs from any directory. Use a virtual environment on
72
+ Ubuntu 22.04: its system pip installs the package as an empty `UNKNOWN`
73
+ without an error.
74
+
75
+ ```
76
+ scenario expected got checks story
77
+ ok pass pass - The system as designed.
78
+ deadlock fail fail unexpected-edge, wait-cycle gps asks nav for a hint while nav is waiting on gps.
79
+ backdoor fail fail unexpected-edge display reads gps directly, bypassing nav.
80
+ camera-hang fail fail isolation The camera stops answering; display has no protection and freezes.
81
+ camera-hang-fixed pass pass - Same stuck camera, display reads it from its own thread.
82
+ ...
83
+ ```
84
+
85
+ Open `out/deadlock.html` for the report, or load `out/deadlock.perfetto.json`
86
+ at [ui.perfetto.dev](https://ui.perfetto.dev) to see every message as an arrow
87
+ between threads.
88
+
89
+ A step-by-step tutorial in the QNX codelab format is in
90
+ [docs/codelab](docs/codelab/blueprint-architecture-contracts.md), and answers
91
+ to the usual questions (overhead, false alarms, what Claude sees, what is not
92
+ covered) are in [docs/FAQ.md](docs/FAQ.md).
93
+
94
+ ## The contract
95
+
96
+ ```yaml
97
+ system: cockpit
98
+ processes: [gps, nav, camera, logger, display]
99
+ allow: # who may send messages to whom
100
+ - display -> nav
101
+ - display -> camera
102
+ - display -> logger
103
+ - nav -> gps
104
+ - nav -> logger
105
+ reply_budget_ms: # how long a server may keep a client waiting
106
+ nav: 50
107
+ default: 20
108
+ isolation: # when camera dies or hangs, display keeps working
109
+ camera:
110
+ must_survive: [display]
111
+ min_progress: 3
112
+ priority_inversion_ms: 2 # experimental: time a waiting client may lose
113
+ # to lower priority work
114
+ cycle_ms: # real-time loops, from the client's side:
115
+ display -> nav: 100 # display needs a route from nav at least every 100 ms
116
+ ```
117
+
118
+ `reply_budget_ms` is the server's promise, `cycle_ms` the client's deadline:
119
+ display draws a frame about every 55 ms and needs nav's answer for each one.
120
+ The demo's `realtime.yaml` is `blueprint.yaml` plus that line.
121
+
122
+ To start from a system that already runs, record a trace and let Blueprint
123
+ write the first draft:
124
+
125
+ ```
126
+ blueprint init run.kev --system cockpit -o blueprint.yaml
127
+ ```
128
+
129
+ It lists the application processes that message each other (QNX services
130
+ such as procnto, devb-* and io-sock are left out, `--only` picks them by
131
+ hand), every edge it saw with its message count, and reply budgets at four
132
+ times the slowest reply in that trace. A draft taken from a trace with a
133
+ backdoor contains the backdoor, so read it and delete what you did not
134
+ design.
135
+
136
+ `--review` asks Claude to read the draft with you. For every edge it gets
137
+ the message count, the first sends and what they carried, who else talks to
138
+ the same server, and the source you pass with `--source`, and it marks the
139
+ edges worth a question as comments in the draft. On the backdoor trace, with
140
+ no source passed, it marked one edge of six:
141
+
142
+ ```
143
+ allow:
144
+ - display -> camera # 50 messages
145
+ # review (SUSPICIOUS): Display reads gps directly, bypassing nav, which already queries gps every cycle. Display sends the same 0x01 request as nav, a few tenths of a millisecond after nav's query; confirm this direct path was designed and is not a leftover shortcut. Events 57138, 57457, 58999, 57029, 57363, 58905.
146
+ - display -> gps # 50 messages
147
+ - display -> logger # 50 messages
148
+ ```
149
+
150
+ That answer cost about 0.03 USD (2,075 input and 905 output tokens) and is
151
+ cached in `demo/cockpit/explanations`, so
152
+ `blueprint init demo/cockpit/traces/backdoor.kev --system cockpit --review --offline --cache demo/cockpit/explanations`
153
+ prints it again without a key. It needs `pip install 'qnx-blueprint[explain]'`.
154
+
155
+ Nothing is removed. An edge Claude names that is not in the draft, and an
156
+ event id it was not given, are dropped; a mark with no evidence left says
157
+ unverified. Reviews are cached like explanations.
158
+
159
+ ## Checks
160
+
161
+ | Check | Fails when |
162
+ |---|---|
163
+ | `unexpected-edge` | a process sends messages to a server the contract does not allow |
164
+ | `wait-cycle` | threads end the trace waiting on each other in a loop (deadlock) |
165
+ | `stuck-reply` | a server took a message and never replied |
166
+ | `reply-budget` | a server replied, but slower than its budget |
167
+ | `cycle-overrun` | a client went longer than its `cycle_ms` without an answer, or its loop stopped |
168
+ | `kernel-denied` | the kernel refused a connection with EPERM: a security policy at work |
169
+ | `isolation` | a process died or stopped answering and took a protected process down with it |
170
+ | `no-traffic` | the trace shows no answered message at all, so it proves nothing |
171
+ | `trace-loss` | kernel buffers are missing from the trace (a gap in the per-CPU buffer sequence), so no verdict on it can be trusted |
172
+ | `priority-inversion` | a client waits on a lower priority server while threads with a priority in between use the CPU (experimental, on when the contract sets `priority_inversion_ms`) |
173
+
174
+ A `read()` that waits in the server for data (a socket, a device, a pipe) is
175
+ the client waiting for input, not the server's latency: when the thread that
176
+ took it spent the wait parked (CONDVAR, SEM, back in MsgReceive), it counts
177
+ neither against `reply_budget_ms` nor as a stuck reply. If the data must come
178
+ in time, give the client a `cycle_ms`.
179
+
180
+ Every finding lists the trace events it is based on. Exit code 0 means pass,
181
+ 1 means the contract is violated, 2 means bad input.
182
+
183
+ ### Where the time went
184
+
185
+ A slow reply or a missed cycle comes with a breakdown of its worst case,
186
+ read from the thread states in the trace. The parts add up to the whole:
187
+
188
+ ```
189
+ FAIL [reply-budget] logger answers display too slowly
190
+ 15 of 31 replies from logger to display took longer than 20 ms; worst 52.6 ms. ...
191
+ where: worst 52.6 ms: server preempted 50.4 ms (mostly media at priority 20, 50.3 ms), server running 2.0 ms, ...
192
+ FAIL [cycle-overrun] display -> nav cycle missed its period: worst gap 114 ms against 100 ms
193
+ where: in the longest gap (113.8 ms) display spent: sleeping (NANOSLEEP) 55.3 ms,
194
+ waiting on logger 48.5 ms (there: server preempted 46.6 ms (mostly media at priority 20, 45.1 ms)), ...
195
+ ```
196
+
197
+ Queued behind another client, preempted (by which thread, at what priority,
198
+ wall time), running, sleeping, or waiting on its own call to another server,
199
+ followed one level into that server. The HTML report draws it as a bar.
200
+
201
+ ## Record on your target, with faults
202
+
203
+ If the target runs sshd, one command records and checks:
204
+
205
+ ```
206
+ blueprint record root@192.168.1.20 -c blueprint.yaml --inject camera@1.5 -d 5 \
207
+ -o run.kev --html report.html
208
+ ```
209
+
210
+ This starts a wide trace on the running system, kills `camera` with SIGKILL
211
+ 1.5 seconds in, saves `pidin` when the trace stops, copies `run.kev` and
212
+ `run.pidin` back and checks them against the contract. Nothing is installed on
213
+ the target: it only needs `tracelogger`, `pidin`, `slay` and `sleep` from a
214
+ stock QNX 8.0 image. `--inject` takes any process from the contract and can be
215
+ repeated; `--inject qpp@1.5:stop` freezes it with SIGSTOP instead of killing it,
216
+ and continues it after `pidin` has seen it stopped. When two instances of one
217
+ binary run, `--inject 'io-sock[prefix=/can]@2:stop'` picks the one whose
218
+ command line contains `prefix=/can` and leaves the other alone. `--start "..."` launches the system inside the trace instead of
219
+ attaching to one that is already up, and `--ssh "..."` replaces the ssh command
220
+ (for a jump host or a VM in a container). A kill that finds no such process is
221
+ reported, so a test that never broke anything cannot pass by accident.
222
+
223
+ Recorded on QNX 8.0 in QEMU against the demo system:
224
+
225
+ ```
226
+ $ blueprint record root@localhost -c demo/cockpit/blueprint.yaml --inject camera@1.5 -d 4
227
+ inject camera: killed 1 process(es)
228
+ FAIL [isolation] camera died and took display down with it
229
+ camera died; display died 38 ms later.
230
+ FAIL: cockpit 1 error, 0 warnings
231
+ ```
232
+
233
+ The same command against the fixed display passes.
234
+
235
+ Without ssh, record by hand and copy the files:
236
+
237
+ ```
238
+ tracelogger -w -s 5 -f /tmp/run.kev # -w: wide mode, see Limits
239
+ pidin > /tmp/run.pidin # thread states when the trace stopped
240
+ ```
241
+
242
+ ```
243
+ blueprint check run.kev --contract blueprint.yaml --html report.html --perfetto run.perfetto.json
244
+ ```
245
+
246
+ `--junit results.xml` writes JUnit XML with one test per check, for GitLab,
247
+ Jenkins or any other CI that reads test results.
248
+
249
+ The `.pidin` file next to the trace is picked up automatically. It matters when
250
+ the system was already stuck before tracing started: blocked threads produce no
251
+ events, and only `pidin` shows who waits on whom.
252
+
253
+ ## Let the kernel enforce it
254
+
255
+ A trace shows what the system did. A QNX security policy decides what it may
256
+ do. Blueprint writes the channel rules of a policy from the contract:
257
+
258
+ ```
259
+ blueprint secpol -c blueprint.yaml --attach nav=/dev/name/local/cockpit-nav ... -o cockpit.secpol
260
+ ```
261
+
262
+ ```
263
+ type display_t;
264
+ allow_attach nav_t /dev/name/local/cockpit-nav;
265
+ # display -> nav
266
+ allow display_t nav_t:channel connect;
267
+ ```
268
+
269
+ The output compiles with `secpolcompile`. It covers only the processes in the
270
+ contract, so merge it into the policy for the whole system.
271
+
272
+ It also works the other way. `secpolgenerate` learns a policy by watching the
273
+ system, and it learns whatever happened, a bad build included. Check what it
274
+ learned before you ship it:
275
+
276
+ ```
277
+ $ blueprint secpol -c blueprint.yaml --check learned.secpol
278
+ FAIL [secpol] policy lets display connect to gps, which the contract forbids
279
+ learned.secpol line 202 allows display_t to connect to gps_t. ...
280
+ ```
281
+
282
+ `blueprint check run.kev --secpol learned.secpol` runs the same comparison
283
+ next to the trace checks. On QNX 8.0 (x86_64 and aarch64) booted in fully
284
+ secure mode with a policy that matches the contract, the backdoor build fails in the kernel:
285
+ `cockpit: cannot open cockpit-gps: Operation not permitted`, and so does
286
+ `open()` on the gps resource manager. How the demo
287
+ policies were made is in [demo/cockpit/secpol](demo/cockpit/secpol/README.md). A codelab walks through all of it from scratch:
288
+ [Lock a QNX 8.0 system to its design](https://dmitriytopka.github.io/qnx-blueprint/codelab/secure-image/).
289
+
290
+ The refusal is in the trace too. A `ConnectAttach` the policy denies exits
291
+ with `ret_val:-1, errno:1`, and a trace recorded on the secure image fails with
292
+
293
+ ```
294
+ FAIL [kernel-denied] the kernel refused display's connection to gps, which the contract forbids
295
+ ConnectAttach from display to gps failed 140 time(s) with EPERM: the security policy
296
+ blocked the path the contract leaves out. The build still tries it, ...
297
+ ```
298
+
299
+ A refused edge that the contract allows means the policy and the contract
300
+ disagree, or the process was started without its type. The secure-mode traces
301
+ are in `tests/data/secure/`, and the serial logs and sessions of both secure
302
+ images in [demo/cockpit/secpol/evidence](demo/cockpit/secpol/evidence/README.md).
303
+
304
+ ## Explanations by Claude
305
+
306
+ ```
307
+ export ANTHROPIC_API_KEY=...
308
+ blueprint check run.kev -c blueprint.yaml --explain --source src/display.c --html report.html
309
+ ```
310
+
311
+ The checks decide what is wrong. Claude is only asked to explain one finding at
312
+ a time: it gets the trace events behind it (each with an id), the contract and
313
+ the source you pass, and returns the cause, the QNX call at fault and a patch.
314
+ Event ids it did not receive are removed, and an explanation left with no real
315
+ evidence is marked unverified. Answers are cached next to the contract, so the
316
+ demo and CI runs work offline. One explanation costs about 0.06 USD with
317
+ `claude-opus-5-5`.
318
+
319
+ ## For coding assistants (MCP)
320
+
321
+ ```
322
+ python3 -m pip install "qnx-blueprint[mcp] @ git+https://github.com/DmitriyTopka/qnx-blueprint"
323
+ blueprint mcp
324
+ ```
325
+
326
+ `blueprint mcp` is an MCP server on stdio with five tools: `check_trace`,
327
+ `draft_contract`, `write_policy`, `check_policy` and `list_demo_traces`. Add it
328
+ to your assistant's MCP configuration (command `blueprint`, argument `mcp`)
329
+ and it can check a trace, read where the time went and propose a fix in one
330
+ conversation. The tools read local files only; recording a trace over ssh
331
+ stays a command you run yourself.
332
+
333
+ ## In CI
334
+
335
+ ```yaml
336
+ - uses: DmitriyTopka/qnx-blueprint@v0.3.0
337
+ with:
338
+ trace: traces/nightly.kev
339
+ contract: blueprint.yaml
340
+ ```
341
+
342
+ The action writes `report.html`, `report.json`, `junit.xml` (one test per
343
+ check, for any CI test view) and a Perfetto trace to `blueprint-report/`, adds a summary to the job page and fails the job on any
344
+ violation.
345
+
346
+ ## What it uses from QNX
347
+
348
+ | File | QNX feature | Why |
349
+ |---|---|---|
350
+ | `blueprint/kev.py` | kernel trace file format, instrumented kernel `procnto-smp-instr` | reads `tracelogger` output on any host, no SDP needed |
351
+ | `blueprint/ipc.py` | `MsgSendv`, `MsgSendvnc`, `MsgReceivev`, `MsgReplyv`, `MsgError` kernel calls; COMM `SND_MESSAGE`, `REPLY_MESSAGE`; `ConnectAttach`, `ChannelCreate` | rebuilds every message transaction with client, server, channel and timing |
352
+ | `blueprint/ipc.py` | resource manager protocol (`_IO_CONNECT`, `_IO_READ`, ...) | `open()` and `read()` on a device are messages too, so edges to resource managers are checked the same way |
353
+ | `blueprint/ipc.py` | thread states `SEND`, `RECEIVE`, `REPLY` | knows who is blocked on whom when the trace ends |
354
+ | `blueprint/checks.py` | thread state events with priority, `_NTO_CHF_FIXED_PRIORITY` from `ChannelCreate` | priority inversion: who ran while a waiting client's server sat READY |
355
+ | `blueprint/snapshot.py` | `pidin` blocked-on column | sees waits that started before the trace |
356
+ | `blueprint/secpol.py` | security policy language: `type`, `allow_attach`, `channel connect`, the `channel_connect` ability; `secpolcompile`, `secpolgenerate`, `on -T` | turns the contract into kernel-enforced channel rules and checks a learned policy against it |
357
+ | `blueprint/record.py` | `tracelogger -w`, `slay -s KILL`, `pidin` on the target over ssh | kills a process while the trace runs, so its death and the reaction of its clients are both in the trace |
358
+ | `blueprint/checks.py` | synchronous message passing semantics | deadlock, stuck server, reply budget, isolation |
359
+ | `demo/cockpit/cockpit.c` | `name_attach`, `name_open`, `MsgSend`, `MsgReceive`, `MsgReply`, pulses, `_NTO_CHF_UNBLOCK`, `_NTO_CHF_FIXED_PRIORITY`; gps as a resource manager (`resmgr_attach`, `iofunc_*`, `dispatch_*`) | a five-process system with realistic faults |
360
+
361
+ One thing the demo shows that surprises people: a `TimerTimeout` on `MsgSend`
362
+ does not protect a client from a server that stopped answering. Channels created by
363
+ `name_attach()` have `_NTO_CHF_UNBLOCK` set, so a REPLY-blocked client that
364
+ times out stays blocked until the server handles the unblock pulse. The fixed
365
+ display reads the camera from its own thread instead.
366
+
367
+ ## On a system we didn't write
368
+
369
+ `demo/stock` is a trace of a QNX image with none of our processes running,
370
+ only QNX's own services. `blueprint init --all` drafts its map (the shell,
371
+ the process manager, devb-eide, io-sock, pipe, io-usb-otg, eight message
372
+ paths) and the check against that draft passes. See
373
+ [demo/stock/README.md](demo/stock/README.md).
374
+
375
+ `demo/external/qpp` is BlackBerry's open-source
376
+ [QNX POSIX Publish Subscribe](https://github.com/qnx/qnx-posix-publish-subscribe)
377
+ service, built unchanged and traced healthy, with its server stopped and
378
+ with its server killed. Blueprint names the stopped server and the client
379
+ left REPLY-blocked on it, and the run found four weak spots in Blueprint
380
+ itself, now fixed. See [demo/external/qpp/README.md](demo/external/qpp/README.md).
381
+
382
+ `demo/external/socketcan` is BlackBerry's
383
+ [SocketCAN for io-sock](https://github.com/qnx/socketcan) on a virtual CAN
384
+ bus, with the CAN stack stopped and killed under its clients. Its blocking
385
+ reads made Blueprint fail a healthy system; that and three more weak spots
386
+ are fixed. The prebuilt module needed a small shim of ours to load, see
387
+ [demo/external/socketcan/README.md](demo/external/socketcan/README.md).
388
+
389
+ ## Is the parser right?
390
+
391
+ Every trace in the repository was also printed with QNX's own `traceprinter`
392
+ on the target and compared with Blueprint's reading, event by event: 1,071,509
393
+ events on x86_64 and aarch64, with and without wide mode and in secure mode, and not one missing,
394
+ extra or different. The table is in [docs/TRACEPRINTER.md](docs/TRACEPRINTER.md),
395
+ and `python -m blueprint.tpcompare run.kev run.tp` does the same for your own
396
+ trace.
397
+
398
+ ## Limits
399
+
400
+ - Times come from the trace clock. Under QEMU emulation they are inflated, so
401
+ budgets in the demo are generous. Measure absolute latencies on hardware.
402
+ - A trace that lost kernel buffers fails with `trace-loss` instead of being
403
+ checked as if it were complete. We detect the loss from gaps in the buffer
404
+ sequence numbers; we could not make QEMU drop a buffer, so the check is
405
+ tested on a real trace with one buffer cut out.
406
+ - Size: a 2 MB trace (51,000 events) takes about 0.4 s and 70 MB of memory.
407
+ The parser keeps the whole trace in memory, so memory grows with the trace;
408
+ a trace of a few hundred megabytes would need several gigabytes (an
409
+ estimate, not measured). Record a few seconds around the behaviour you check.
410
+ - A read that was already waiting when the trace started shows only in
411
+ `pidin`, without its message, so Blueprint cannot tell a reader waiting for
412
+ data from a stuck server and reports it. Start the system inside the trace
413
+ (`record --start`) when its clients block in `read()`.
414
+ - Two instances of one binary (two io-sock) are one process in a contract.
415
+ - Record with `tracelogger -w`. Without wide mode the trace still shows who
416
+ sent to whom and who was blocked (on the healthy demo it gave the same five
417
+ edges), but thread priorities and message contents are missing. Blueprint
418
+ then warns (`trace-mode`), and fails if the contract asks for the priority
419
+ inversion check, rather than skip that check quietly.
420
+ - The priority inversion check is experimental. A QNX server normally takes
421
+ its client's priority while it handles the message, so the check does not
422
+ look for "server priority lower than client". It looks at what the kernel
423
+ actually scheduled: the server READY at a lower priority while threads
424
+ between the two priorities run. On a normal channel that should not happen;
425
+ it shows up with `_NTO_CHF_FIXED_PRIORITY` channels. It has no false alarms
426
+ on the recorded demo traces, but it has not seen many real systems yet.
427
+
428
+ ## Building the demo system
429
+
430
+ `demo/cockpit` builds with `qcc` from QNX SDP 8.0 and runs in a QEMU image made
431
+ with `mkqnximage`, on x86_64 or on aarch64 (`--arch=aarch64le`, which needs the
432
+ `com.qnx.qnx800.target.qemuvirt` and `com.qnx.qnx800.target.driver.virtio.startup`
433
+ packages). The same scenarios give the same results on both. On the virt board
434
+ the block device has to come first on the QEMU command line, since virtio-mmio
435
+ addresses follow the order of the devices:
436
+
437
+ ```
438
+ qemu-system-aarch64 -machine virt-4.2 -cpu cortex-a57 -smp 2 -m 1G \
439
+ -drive file=output/disk-qemu.vmdk,if=none,id=drv0 -device virtio-blk-device,drive=drv0 \
440
+ -netdev user,id=net0,hostfwd=tcp::2223-:22 -device virtio-net-device,netdev=net0 \
441
+ -kernel output/ifs.bin -display none -serial file:serial.log
442
+ ```
443
+ `demo/cockpit/cockpit-run.sh` records one scenario on the
444
+ target. No SDP files, headers or images are included in this repository.
445
+
446
+ ## How it was built
447
+
448
+ Dmytro Topka built Blueprint for the QNX Global Hackathon, starting on
449
+ November 3, 2026, with Claude Code (Anthropic) as the coding agent. The idea was
450
+ picked after two rounds of review against the judging criteria and the other
451
+ entries. Every claim about QNX was checked on a running QNX 8.0 target
452
+ before it went into the code or the docs, and several first guesses did not
453
+ survive that: the pid in a send event, what a send timeout does on a
454
+ name_attach channel, which errno a denied connection gets, why a learned
455
+ policy had no rules. The commit history shows the work as it happened.
456
+
457
+ ## License
458
+
459
+ Apache-2.0. QNX is a trademark of BlackBerry Limited. This project is not
460
+ affiliated with or endorsed by BlackBerry.