cortex-runtime 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 (76) hide show
  1. cortex_runtime-0.2.0/.gitignore +35 -0
  2. cortex_runtime-0.2.0/LICENSE +201 -0
  3. cortex_runtime-0.2.0/PKG-INFO +220 -0
  4. cortex_runtime-0.2.0/README.md +181 -0
  5. cortex_runtime-0.2.0/cortex/__init__.py +51 -0
  6. cortex_runtime-0.2.0/cortex/__main__.py +13 -0
  7. cortex_runtime-0.2.0/cortex/client.py +263 -0
  8. cortex_runtime-0.2.0/cortex/compat.py +20 -0
  9. cortex_runtime-0.2.0/cortex/exceptions.py +57 -0
  10. cortex_runtime-0.2.0/cortex/plugin.py +50 -0
  11. cortex_runtime-0.2.0/cortex/py.typed +1 -0
  12. cortex_runtime-0.2.0/cortex/schema/__init__.py +29 -0
  13. cortex_runtime-0.2.0/cortex/schema/events.py +127 -0
  14. cortex_runtime-0.2.0/cortex/tools/__init__.py +3 -0
  15. cortex_runtime-0.2.0/cortex/tools/cli/__init__.py +3 -0
  16. cortex_runtime-0.2.0/cortex/tools/cli/main.py +139 -0
  17. cortex_runtime-0.2.0/cortex/tools/cli/runner.py +94 -0
  18. cortex_runtime-0.2.0/cortex/tools/cli/scaffolder.py +109 -0
  19. cortex_runtime-0.2.0/cortex/tools/gen_test_bin.py +35 -0
  20. cortex_runtime-0.2.0/cortex/tools/kernel/__init__.py +3 -0
  21. cortex_runtime-0.2.0/cortex/tools/kernel/actors/__init__.py +3 -0
  22. cortex_runtime-0.2.0/cortex/tools/kernel/actors/executor.py +44 -0
  23. cortex_runtime-0.2.0/cortex/tools/kernel/actors/planner.py +38 -0
  24. cortex_runtime-0.2.0/cortex/tools/kernel/context.py +22 -0
  25. cortex_runtime-0.2.0/cortex/tools/kernel/drivers/__init__.py +3 -0
  26. cortex_runtime-0.2.0/cortex/tools/kernel/drivers/mock_robot.py +84 -0
  27. cortex_runtime-0.2.0/cortex/tools/kernel/drivers/rtl_verilator.py +49 -0
  28. cortex_runtime-0.2.0/cortex/tools/kernel/graph/__init__.py +3 -0
  29. cortex_runtime-0.2.0/cortex/tools/kernel/graph/analyzer.py +52 -0
  30. cortex_runtime-0.2.0/cortex/tools/kernel/graph/execution_graph.py +44 -0
  31. cortex_runtime-0.2.0/cortex/tools/kernel/mailbox.py +35 -0
  32. cortex_runtime-0.2.0/cortex/tools/kernel/plugin/__init__.py +3 -0
  33. cortex_runtime-0.2.0/cortex/tools/kernel/plugin/loader.py +87 -0
  34. cortex_runtime-0.2.0/cortex/tools/kernel/plugin/manifest.py +53 -0
  35. cortex_runtime-0.2.0/cortex/tools/kernel/registry.py +36 -0
  36. cortex_runtime-0.2.0/cortex/tools/kernel/schema/__init__.py +3 -0
  37. cortex_runtime-0.2.0/cortex/tools/kernel/schema/contract.py +16 -0
  38. cortex_runtime-0.2.0/cortex/tools/kernel/schema/event.py +54 -0
  39. cortex_runtime-0.2.0/cortex/tools/kernel/schema/message.py +105 -0
  40. cortex_runtime-0.2.0/cortex/tools/kernel/schema/workflow.py +38 -0
  41. cortex_runtime-0.2.0/cortex/tools/kernel/services/__init__.py +3 -0
  42. cortex_runtime-0.2.0/cortex/tools/kernel/services/event_store.py +25 -0
  43. cortex_runtime-0.2.0/cortex/tools/kernel/services/execution_intelligence.py +49 -0
  44. cortex_runtime-0.2.0/cortex/tools/kernel/services/graph_builder.py +81 -0
  45. cortex_runtime-0.2.0/cortex/tools/kernel/services/replay.py +50 -0
  46. cortex_runtime-0.2.0/cortex/tools/kernel/services/verification.py +85 -0
  47. cortex_runtime-0.2.0/cortex/tools/kernel/transport.py +50 -0
  48. cortex_runtime-0.2.0/cortex/tools/run_phase2_verification.sh +20 -0
  49. cortex_runtime-0.2.0/cortex/tools/verification/__init__.py +5 -0
  50. cortex_runtime-0.2.0/cortex/tools/verification/adapters/__init__.py +3 -0
  51. cortex_runtime-0.2.0/cortex/tools/verification/adapters/base.py +14 -0
  52. cortex_runtime-0.2.0/cortex/tools/verification/adapters/coq.py +73 -0
  53. cortex_runtime-0.2.0/cortex/tools/verification/adapters/rtl.py +77 -0
  54. cortex_runtime-0.2.0/cortex/tools/verification/adapters/rust.py +72 -0
  55. cortex_runtime-0.2.0/cortex/tools/verification/archive.py +58 -0
  56. cortex_runtime-0.2.0/cortex/tools/verification/bus.py +28 -0
  57. cortex_runtime-0.2.0/cortex/tools/verification/contract.py +70 -0
  58. cortex_runtime-0.2.0/cortex/tools/verification/engine.py +121 -0
  59. cortex_runtime-0.2.0/cortex/tools/verification/generator/__init__.py +3 -0
  60. cortex_runtime-0.2.0/cortex/tools/verification/generator/composer.py +36 -0
  61. cortex_runtime-0.2.0/cortex/tools/verification/generator/program.py +46 -0
  62. cortex_runtime-0.2.0/cortex/tools/verification/generator/state.py +54 -0
  63. cortex_runtime-0.2.0/cortex/tools/verification/invariants/__init__.py +3 -0
  64. cortex_runtime-0.2.0/cortex/tools/verification/invariants/capability.py +62 -0
  65. cortex_runtime-0.2.0/cortex/tools/verification/metrics/__init__.py +3 -0
  66. cortex_runtime-0.2.0/cortex/tools/verification/metrics/base.py +18 -0
  67. cortex_runtime-0.2.0/cortex/tools/verification/metrics/opcode.py +25 -0
  68. cortex_runtime-0.2.0/cortex/tools/verification/metrics/state_space.py +26 -0
  69. cortex_runtime-0.2.0/cortex/tools/verification/metrics/trap.py +26 -0
  70. cortex_runtime-0.2.0/cortex/tools/verification/mutation.py +48 -0
  71. cortex_runtime-0.2.0/cortex/tools/verification/oracle.py +164 -0
  72. cortex_runtime-0.2.0/cortex/tools/verification/schema/__init__.py +44 -0
  73. cortex_runtime-0.2.0/cortex/tools/verification/schema/event.py +44 -0
  74. cortex_runtime-0.2.0/cortex/tools/verification/shrink.py +26 -0
  75. cortex_runtime-0.2.0/cortex/tools/verify.py +64 -0
  76. cortex_runtime-0.2.0/pyproject.toml +82 -0
@@ -0,0 +1,35 @@
1
+ # Python & Build
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .eggs/
8
+
9
+ # Cortex Local Execution & Traces
10
+ .cortex/
11
+ *.trace.json
12
+ canonical_trace.json
13
+ rtl_trace.json
14
+ tmp_*.json
15
+ test_app/
16
+
17
+ # Rust & Emulator Build Artifacts
18
+ cortex-emulator/target/
19
+ target/
20
+ obj_dir/
21
+
22
+ # Verification & Temporary Output
23
+ artifacts/temp/
24
+ tools/verification/temp
25
+
26
+ # Environments & IDEs
27
+ .venv/
28
+ .uv-venv/
29
+ .uv/
30
+ uv.lock
31
+ venv/
32
+ .vscode/
33
+ .idea/
34
+ .clangd
35
+ .ruff_cache/
@@ -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.
@@ -0,0 +1,220 @@
1
+ Metadata-Version: 2.4
2
+ Name: cortex-runtime
3
+ Version: 0.2.0
4
+ Summary: Spatiotemporal authority and semantic verification framework for autonomous workflows
5
+ Project-URL: Homepage, https://github.com/Iradukunda-Fils/Cortex
6
+ Project-URL: Documentation, https://github.com/Iradukunda-Fils/Cortex#readme
7
+ Project-URL: Repository, https://github.com/Iradukunda-Fils/Cortex.git
8
+ Project-URL: Issues, https://github.com/Iradukunda-Fils/Cortex/issues
9
+ Author: Iradukunda Fils
10
+ License: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: agents,architecture,capability-security,sandbox,spatiotemporal,verification,workflow
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Security
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: System :: Distributed Computing
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: pydantic<3.0.0,>=2.0.0
26
+ Requires-Dist: pyyaml<7.0.0,>=6.0.0
27
+ Requires-Dist: typing-extensions>=4.5.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: build>=1.0.0; extra == 'dev'
30
+ Requires-Dist: pyright>=1.1.0; extra == 'dev'
31
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
32
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
33
+ Requires-Dist: twine>=4.0.0; extra == 'dev'
34
+ Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
35
+ Provides-Extra: docs
36
+ Requires-Dist: mkdocs-material>=9.0.0; extra == 'docs'
37
+ Requires-Dist: mkdocs>=1.5.0; extra == 'docs'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # Cortex Platform: Spatiotemporal Authority & Semantic Verification Framework
41
+
42
+ [![PyPI Version](https://img.shields.io/pypi/v/cortex-runtime.svg)](https://pypi.org/project/cortex-runtime/)
43
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
44
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
45
+ [![Type Checked: Pyright](https://img.shields.io/badge/type--checking-pyright-brightgreen.svg)](https://github.com/microsoft/pyright)
46
+
47
+ > **Cortex** is a spatiotemporal authority and semantic verification framework designed to enforce execution integrity, capability-negotiated sandboxing, and post-facto deterministic verification across autonomous software runtimes and AI agent architectures.
48
+
49
+ ---
50
+
51
+ ## 📖 Narrative Arc: Why Cortex Exists
52
+
53
+ ### 1. The Problem at Scale
54
+ Traditional security systems rely on static user identities (POSIX permissions, IAM roles, cgroups). However, **autonomous AI agents and non-deterministic software break traditional security models**:
55
+ * **Ambient Authority Leakage**: Agents executing inside shell environments inherit full ambient process permissions, allowing unintended file access or dynamic execution.
56
+ * **Subshell Script Bypasses**: Malicious or miscalibrated agents can invoke shell scripts (`.sh`), subprocesses, or eval blocks to bypass high-level application checks.
57
+ * **Non-Deterministic State Drift**: Without causal trace verification, auditing *why* an autonomous agent performed an action after a failure or security breach is impossible.
58
+
59
+ ### 2. The Cortex Value Proposition
60
+ Cortex replaces ambient authority with a **3-Layer Security Boundary**:
61
+ 1. **Static Capability Negotiation**: Manifests declare required permissions before plugins access the kernel bus (`CapabilityNegotiator`).
62
+ 2. **Runtime Sandbox Proxy**: Guarded resource drivers evaluate capability tokens before firing raw I/O system calls (`PluginContext`).
63
+ 3. **Deterministic Replay Audit**: Post-execution trace verification validates $P1$–$P4$ invariants and causal lineage graphs (`cortex workflow replay`).
64
+
65
+ ### 3. Dual-Layer Framing: Non-Technical Analogy vs. Technical Mechanics
66
+
67
+ ```mermaid
68
+ graph TD
69
+ subgraph Layer 1: Passport Control
70
+ M[Plugin Manifest] --> N[CapabilityNegotiator]
71
+ N -->|Match Policy| G[ACTIVE Plugin]
72
+ N -->|Policy Mismatch| R[REJECTED Plugin]
73
+ end
74
+
75
+ subgraph Layer 2: Boarding Scanner
76
+ G --> C[PluginContext]
77
+ C --> D[Guarded Drivers: File / Net / Exec]
78
+ D -->|has_capability?| E[Execute Action]
79
+ D -->|Missing Token| V[CAPABILITY_VIOLATION Event]
80
+ end
81
+
82
+ subgraph Layer 3: Flight Blackbox
83
+ E --> S[Immutable Event Store]
84
+ V --> S
85
+ S --> RE[Deterministic Replay Engine]
86
+ RE --> INV[P1-P4 Invariant Checks]
87
+ end
88
+ ```
89
+
90
+ | Security Layer | Non-Technical Analogy | Technical Mechanics |
91
+ | :--- | :--- | :--- |
92
+ | **Layer 1: Static Negotiation** | **Passport & Visa Check**<br/>Validates passport and visa credentials before granting entry into the country. | `CapabilityNegotiator.negotiate()` evaluates `PluginManifest.required_capabilities` against `platform_capabilities`. |
93
+ | **Layer 2: Runtime Sandbox Proxy** | **Boarding Gate Scanner**<br/>Ensures passengers present a valid boarding pass for that specific door before entering the aircraft. | `PluginContext.has_capability()` validates tokens before Guarded Resource Drivers fire I/O system calls. |
94
+ | **Layer 3: Verification & Trace Replay** | **Flight Blackbox Recorder**<br/>Records all flight telemetry in a tamper-evident blackbox for post-flight accident investigation. | `DeterministicReplayEngine` re-simulates event streams (`.cortex/events/*.json`), validating $P1$–$P4$ invariants. |
95
+
96
+ ---
97
+
98
+ ## 🚀 Quickstart & Developer Experience
99
+
100
+ ### 1. Installation
101
+
102
+ Install via PyPI or fast package manager `uv`:
103
+
104
+ ```bash
105
+ # Standard pip
106
+ pip install cortex-runtime
107
+
108
+ # Fast installation with Astral uv
109
+ uv pip install cortex-runtime
110
+
111
+ # Or run directly with uv tool
112
+ uvx cortex-runtime --help
113
+ ```
114
+
115
+ ### 2. Scaffold a New Project
116
+
117
+ ```bash
118
+ cortex init my_app --type app
119
+ cd my_app
120
+ ```
121
+
122
+ ### 3. Execute, Inspect, and Replay Workflows
123
+
124
+ ```bash
125
+ # Execute workflow
126
+ cortex workflow run workflow.json
127
+
128
+ # Inspect causal execution graph
129
+ cortex workflow inspect .cortex/events/<workflow_id>.json
130
+
131
+ # Perform 100% deterministic replay audit
132
+ cortex workflow replay .cortex/events/<workflow_id>.json
133
+ ```
134
+
135
+ ---
136
+
137
+ ## 📚 Developer Portal & Quick Links
138
+
139
+ - 🚀 **[Developer Quickstart Guide](docs/quickstart.md)**: Install `cortex-runtime`, build workflows, and run plugins.
140
+ - 💻 **[CLI Reference Documentation](docs/cli.md)**: Standard CLI command usage (`init`, `workflow run`, `inspect`, `replay`).
141
+ - 🏛️ **[Architecture & Security Model](docs/architecture.md)**: 3-layer security boundary, dual-layer framing, and threat neutralization.
142
+ - 🔐 **[Capability Manifest Specification](docs/manifest_spec.md)**: `PluginManifest` schema and negotiation rules.
143
+ - 🔬 **[Research Documentation](Research/)**: Formal whitepapers, mathematical invariants ($P1$–$P4$), and CS literature taxonomy.
144
+ - 📐 **[Coq Proof Substrate](coq/)**: Interactive formal verification proof scripts.
145
+ - ⚡ **[Rust Emulator Engine](cortex-emulator/)**: Hardware state machine emulator.
146
+
147
+ ---
148
+
149
+ ## 🔬 Adversarial Systems Research: Working Hypothesis ($H_{\text{prop}}$)
150
+
151
+ This repository houses a rigorous, peer-reviewed adversarial falsification program for autonomous systems. The primary function of this research is to validate the **Working Hypothesis ($H_{\text{prop}}$)**:
152
+
153
+ > **Does an existing semantic preservation relation characterize when the externally observable effects of an execution remain within the authority constraints delegated to that execution under the stated threat model?**
154
+ >
155
+ > *We posit this may be expressible as a relational hyperproperty over operational traces, but leave its classification strictly open pending empirical literature analysis.*
156
+
157
+ If adversarial analysis reveals that a composition of existing CS frameworks satisfies all safety properties under $H_{\text{prop}}$, no new semantic layer is required. If the analysis exposes an irreducible semantic gap, that gap defines the formal requirements for a new candidate specification.
158
+
159
+ ---
160
+
161
+ ## 🛡️ The Safety Properties Catalog ($P1$–$P4$)
162
+
163
+ Every composition is evaluated against four orthogonal, non-overlapping safety properties under the **Generalized Semantic Transition Relation ($\Sigma; \Lambda \vdash I \Longrightarrow e$)** mapping input streams ($I$) to terminal target actions ($e$) through intermediate **Operational Artifacts ($\mathcal{A}$)**:
164
+
165
+ $$\frac{\Sigma; \Lambda \vdash I \xrightarrow{\text{derive}} \mathcal{A} \quad \quad \mathcal{A} \in \text{Adm}(\Lambda) \quad \quad \Sigma; \Lambda \vdash \mathcal{A} \xrightarrow{\text{enact}} e}{\Sigma; \Lambda \vdash I \Longrightarrow e}$$
166
+
167
+ * **P1 — Authority Soundness:** Bounded authority must be delegable and attenuable across downstream context shifts such that a principal cannot execute or delegate permissions beyond its initial envelope.
168
+ * **P2 — Execution Integrity:** The byte-level parameter state of an executed action must remain structurally unaltered between the generation boundary and the interface enforcement perimeters under the stated threat model.
169
+ * **P3 — Semantic Consequence Preservation:** Every externally observable, irreversible effect must be demonstrably and traceably derivable from the active delegation constraints: $\Sigma \models \text{Preserves}(\Lambda, e)$.
170
+ * **P4 — Independent Verifiability:** An external, post-facto verifier must be capable of establishing the validity of P3 without trusting the execution runtime beyond the boundaries of an explicitly declared Trusted Computing Base (TCB).
171
+
172
+ ---
173
+
174
+ ## 🔬 Literature Taxonomy (21 Disciplines)
175
+
176
+ The research program maps system interactions across 21 distinct computer science areas:
177
+ 1. **Capability Security** (Confinement & Ambient Authority Elimination)
178
+ 2. **Programming Languages** (Type Safety, Scoped-Use Semantics)
179
+ 3. **Delegated Authorization** (Offline-Verifiable Attenuation)
180
+ 4. **Authorization Engines** (Relationship Graphs & Relational Logic)
181
+ 5. **Data Provenance** (Platform-Independent Derived Lineage)
182
+ 6. **Whole-System Provenance** (Kernel-Level Telemetry Interception)
183
+ 7. **Systemic Accountability** (Tamper-Evident Non-Repudiation Logs)
184
+ 8. **Distributed Transactions** (Atomicity & Consistency Guarantees)
185
+ 9. **Workflow Systems** (Durability & State Checkpointing)
186
+ 10. **Formal Methods** (Process Calculi & Temporal Logic Modelling)
187
+ 11. **Formal Verification** (Mathematical Correctness Proofs)
188
+ 12. **Information Flow Control** (Integrity Boundaries & Labels)
189
+ 13. **Trusted Computing** (Hardware Enclave Isolation)
190
+ 14. **Language-Based Security** (Non-Interference & Secure Compilation)
191
+ 15. **Operational Semantics** (Structural Operational Semantics, Evaluation Relations)
192
+ 16. **Program Logics** (Hoare Logic, Separation Logic, Refinement Calculi)
193
+ 17. **Static Analysis** (Abstract Interpretation, Monadic Effects)
194
+ 18. **Proof-Producing Computation** (SMT Solvers, Certified Abstract Interpretation)
195
+ 19. **Secure Compilation** (Robust Safety/Hyperproperty Preservation)
196
+ 20. **Algebraic & Rewriting Frameworks** (Institution Theory, Maude, K Framework)
197
+ 21. **Runtime Verification** (Online Trace Compliance & Enforcement Monitors)
198
+
199
+ ---
200
+
201
+ ## 📊 Evaluation Status Matrix
202
+
203
+ Evaluating candidate compositions over safety properties P1–P4 led to the lock phase, which confirmed the need for a unified spatiotemporal semantic layer incorporating versioned epochs and step-indexing. This has been formalized as the **Cortex Spatiotemporal Mechanics** (FC_01–FC_09):
204
+
205
+ | ID | Composition Structure | P1 | P2 | P3 | P4 | Verdict / Current Status |
206
+ | --- | --- | :---: | :---: | :---: | :---: | :---: |
207
+ | **CC-01** | Whole-System Provenance + Capability Security | **✓** | **✓** | **✗** | **✗** | **Complete (Partially Covered)** |
208
+ | **CC-04** | Capability Security + Program Logics | **✓** | **✓** | **~** | **✗** | **Complete (Partially Covered)** |
209
+ | **CC-05** | Language-Based Security + Trusted Computing | - | - | - | - | **FROZEN (Identified Semantic Gaps)** |
210
+ | **CC-08** | Runtime Verification + Capability Security | - | - | - | - | **FROZEN (Identified Semantic Gaps)** |
211
+ | **Cortex** | Spatiotemporal Preorders + Epoch-Indexed Value/Trace Relations | **✓** | **✓** | **✓** | **✓** | **FORMALLY PROVEN & ROADMAPPED** |
212
+
213
+ *Legend: **✓** (Success) | **✗** (Failed) | **~** (Partial Success) | **-** (Not yet evaluated / Frozen)*
214
+
215
+ ---
216
+
217
+ ## 🛠️ Repository Rules & Governance
218
+
219
+ 1. **LOCKED State:** Foundational survey, model, and formal construction documents are frozen once complete to maintain strict control over confirmation bias.
220
+ 2. **No Marketing Syntax:** Language remains strictly technical, quantitative, and neutral.
@@ -0,0 +1,181 @@
1
+ # Cortex Platform: Spatiotemporal Authority & Semantic Verification Framework
2
+
3
+ [![PyPI Version](https://img.shields.io/pypi/v/cortex-runtime.svg)](https://pypi.org/project/cortex-runtime/)
4
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
5
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
6
+ [![Type Checked: Pyright](https://img.shields.io/badge/type--checking-pyright-brightgreen.svg)](https://github.com/microsoft/pyright)
7
+
8
+ > **Cortex** is a spatiotemporal authority and semantic verification framework designed to enforce execution integrity, capability-negotiated sandboxing, and post-facto deterministic verification across autonomous software runtimes and AI agent architectures.
9
+
10
+ ---
11
+
12
+ ## 📖 Narrative Arc: Why Cortex Exists
13
+
14
+ ### 1. The Problem at Scale
15
+ Traditional security systems rely on static user identities (POSIX permissions, IAM roles, cgroups). However, **autonomous AI agents and non-deterministic software break traditional security models**:
16
+ * **Ambient Authority Leakage**: Agents executing inside shell environments inherit full ambient process permissions, allowing unintended file access or dynamic execution.
17
+ * **Subshell Script Bypasses**: Malicious or miscalibrated agents can invoke shell scripts (`.sh`), subprocesses, or eval blocks to bypass high-level application checks.
18
+ * **Non-Deterministic State Drift**: Without causal trace verification, auditing *why* an autonomous agent performed an action after a failure or security breach is impossible.
19
+
20
+ ### 2. The Cortex Value Proposition
21
+ Cortex replaces ambient authority with a **3-Layer Security Boundary**:
22
+ 1. **Static Capability Negotiation**: Manifests declare required permissions before plugins access the kernel bus (`CapabilityNegotiator`).
23
+ 2. **Runtime Sandbox Proxy**: Guarded resource drivers evaluate capability tokens before firing raw I/O system calls (`PluginContext`).
24
+ 3. **Deterministic Replay Audit**: Post-execution trace verification validates $P1$–$P4$ invariants and causal lineage graphs (`cortex workflow replay`).
25
+
26
+ ### 3. Dual-Layer Framing: Non-Technical Analogy vs. Technical Mechanics
27
+
28
+ ```mermaid
29
+ graph TD
30
+ subgraph Layer 1: Passport Control
31
+ M[Plugin Manifest] --> N[CapabilityNegotiator]
32
+ N -->|Match Policy| G[ACTIVE Plugin]
33
+ N -->|Policy Mismatch| R[REJECTED Plugin]
34
+ end
35
+
36
+ subgraph Layer 2: Boarding Scanner
37
+ G --> C[PluginContext]
38
+ C --> D[Guarded Drivers: File / Net / Exec]
39
+ D -->|has_capability?| E[Execute Action]
40
+ D -->|Missing Token| V[CAPABILITY_VIOLATION Event]
41
+ end
42
+
43
+ subgraph Layer 3: Flight Blackbox
44
+ E --> S[Immutable Event Store]
45
+ V --> S
46
+ S --> RE[Deterministic Replay Engine]
47
+ RE --> INV[P1-P4 Invariant Checks]
48
+ end
49
+ ```
50
+
51
+ | Security Layer | Non-Technical Analogy | Technical Mechanics |
52
+ | :--- | :--- | :--- |
53
+ | **Layer 1: Static Negotiation** | **Passport & Visa Check**<br/>Validates passport and visa credentials before granting entry into the country. | `CapabilityNegotiator.negotiate()` evaluates `PluginManifest.required_capabilities` against `platform_capabilities`. |
54
+ | **Layer 2: Runtime Sandbox Proxy** | **Boarding Gate Scanner**<br/>Ensures passengers present a valid boarding pass for that specific door before entering the aircraft. | `PluginContext.has_capability()` validates tokens before Guarded Resource Drivers fire I/O system calls. |
55
+ | **Layer 3: Verification & Trace Replay** | **Flight Blackbox Recorder**<br/>Records all flight telemetry in a tamper-evident blackbox for post-flight accident investigation. | `DeterministicReplayEngine` re-simulates event streams (`.cortex/events/*.json`), validating $P1$–$P4$ invariants. |
56
+
57
+ ---
58
+
59
+ ## 🚀 Quickstart & Developer Experience
60
+
61
+ ### 1. Installation
62
+
63
+ Install via PyPI or fast package manager `uv`:
64
+
65
+ ```bash
66
+ # Standard pip
67
+ pip install cortex-runtime
68
+
69
+ # Fast installation with Astral uv
70
+ uv pip install cortex-runtime
71
+
72
+ # Or run directly with uv tool
73
+ uvx cortex-runtime --help
74
+ ```
75
+
76
+ ### 2. Scaffold a New Project
77
+
78
+ ```bash
79
+ cortex init my_app --type app
80
+ cd my_app
81
+ ```
82
+
83
+ ### 3. Execute, Inspect, and Replay Workflows
84
+
85
+ ```bash
86
+ # Execute workflow
87
+ cortex workflow run workflow.json
88
+
89
+ # Inspect causal execution graph
90
+ cortex workflow inspect .cortex/events/<workflow_id>.json
91
+
92
+ # Perform 100% deterministic replay audit
93
+ cortex workflow replay .cortex/events/<workflow_id>.json
94
+ ```
95
+
96
+ ---
97
+
98
+ ## 📚 Developer Portal & Quick Links
99
+
100
+ - 🚀 **[Developer Quickstart Guide](docs/quickstart.md)**: Install `cortex-runtime`, build workflows, and run plugins.
101
+ - 💻 **[CLI Reference Documentation](docs/cli.md)**: Standard CLI command usage (`init`, `workflow run`, `inspect`, `replay`).
102
+ - 🏛️ **[Architecture & Security Model](docs/architecture.md)**: 3-layer security boundary, dual-layer framing, and threat neutralization.
103
+ - 🔐 **[Capability Manifest Specification](docs/manifest_spec.md)**: `PluginManifest` schema and negotiation rules.
104
+ - 🔬 **[Research Documentation](Research/)**: Formal whitepapers, mathematical invariants ($P1$–$P4$), and CS literature taxonomy.
105
+ - 📐 **[Coq Proof Substrate](coq/)**: Interactive formal verification proof scripts.
106
+ - ⚡ **[Rust Emulator Engine](cortex-emulator/)**: Hardware state machine emulator.
107
+
108
+ ---
109
+
110
+ ## 🔬 Adversarial Systems Research: Working Hypothesis ($H_{\text{prop}}$)
111
+
112
+ This repository houses a rigorous, peer-reviewed adversarial falsification program for autonomous systems. The primary function of this research is to validate the **Working Hypothesis ($H_{\text{prop}}$)**:
113
+
114
+ > **Does an existing semantic preservation relation characterize when the externally observable effects of an execution remain within the authority constraints delegated to that execution under the stated threat model?**
115
+ >
116
+ > *We posit this may be expressible as a relational hyperproperty over operational traces, but leave its classification strictly open pending empirical literature analysis.*
117
+
118
+ If adversarial analysis reveals that a composition of existing CS frameworks satisfies all safety properties under $H_{\text{prop}}$, no new semantic layer is required. If the analysis exposes an irreducible semantic gap, that gap defines the formal requirements for a new candidate specification.
119
+
120
+ ---
121
+
122
+ ## 🛡️ The Safety Properties Catalog ($P1$–$P4$)
123
+
124
+ Every composition is evaluated against four orthogonal, non-overlapping safety properties under the **Generalized Semantic Transition Relation ($\Sigma; \Lambda \vdash I \Longrightarrow e$)** mapping input streams ($I$) to terminal target actions ($e$) through intermediate **Operational Artifacts ($\mathcal{A}$)**:
125
+
126
+ $$\frac{\Sigma; \Lambda \vdash I \xrightarrow{\text{derive}} \mathcal{A} \quad \quad \mathcal{A} \in \text{Adm}(\Lambda) \quad \quad \Sigma; \Lambda \vdash \mathcal{A} \xrightarrow{\text{enact}} e}{\Sigma; \Lambda \vdash I \Longrightarrow e}$$
127
+
128
+ * **P1 — Authority Soundness:** Bounded authority must be delegable and attenuable across downstream context shifts such that a principal cannot execute or delegate permissions beyond its initial envelope.
129
+ * **P2 — Execution Integrity:** The byte-level parameter state of an executed action must remain structurally unaltered between the generation boundary and the interface enforcement perimeters under the stated threat model.
130
+ * **P3 — Semantic Consequence Preservation:** Every externally observable, irreversible effect must be demonstrably and traceably derivable from the active delegation constraints: $\Sigma \models \text{Preserves}(\Lambda, e)$.
131
+ * **P4 — Independent Verifiability:** An external, post-facto verifier must be capable of establishing the validity of P3 without trusting the execution runtime beyond the boundaries of an explicitly declared Trusted Computing Base (TCB).
132
+
133
+ ---
134
+
135
+ ## 🔬 Literature Taxonomy (21 Disciplines)
136
+
137
+ The research program maps system interactions across 21 distinct computer science areas:
138
+ 1. **Capability Security** (Confinement & Ambient Authority Elimination)
139
+ 2. **Programming Languages** (Type Safety, Scoped-Use Semantics)
140
+ 3. **Delegated Authorization** (Offline-Verifiable Attenuation)
141
+ 4. **Authorization Engines** (Relationship Graphs & Relational Logic)
142
+ 5. **Data Provenance** (Platform-Independent Derived Lineage)
143
+ 6. **Whole-System Provenance** (Kernel-Level Telemetry Interception)
144
+ 7. **Systemic Accountability** (Tamper-Evident Non-Repudiation Logs)
145
+ 8. **Distributed Transactions** (Atomicity & Consistency Guarantees)
146
+ 9. **Workflow Systems** (Durability & State Checkpointing)
147
+ 10. **Formal Methods** (Process Calculi & Temporal Logic Modelling)
148
+ 11. **Formal Verification** (Mathematical Correctness Proofs)
149
+ 12. **Information Flow Control** (Integrity Boundaries & Labels)
150
+ 13. **Trusted Computing** (Hardware Enclave Isolation)
151
+ 14. **Language-Based Security** (Non-Interference & Secure Compilation)
152
+ 15. **Operational Semantics** (Structural Operational Semantics, Evaluation Relations)
153
+ 16. **Program Logics** (Hoare Logic, Separation Logic, Refinement Calculi)
154
+ 17. **Static Analysis** (Abstract Interpretation, Monadic Effects)
155
+ 18. **Proof-Producing Computation** (SMT Solvers, Certified Abstract Interpretation)
156
+ 19. **Secure Compilation** (Robust Safety/Hyperproperty Preservation)
157
+ 20. **Algebraic & Rewriting Frameworks** (Institution Theory, Maude, K Framework)
158
+ 21. **Runtime Verification** (Online Trace Compliance & Enforcement Monitors)
159
+
160
+ ---
161
+
162
+ ## 📊 Evaluation Status Matrix
163
+
164
+ Evaluating candidate compositions over safety properties P1–P4 led to the lock phase, which confirmed the need for a unified spatiotemporal semantic layer incorporating versioned epochs and step-indexing. This has been formalized as the **Cortex Spatiotemporal Mechanics** (FC_01–FC_09):
165
+
166
+ | ID | Composition Structure | P1 | P2 | P3 | P4 | Verdict / Current Status |
167
+ | --- | --- | :---: | :---: | :---: | :---: | :---: |
168
+ | **CC-01** | Whole-System Provenance + Capability Security | **✓** | **✓** | **✗** | **✗** | **Complete (Partially Covered)** |
169
+ | **CC-04** | Capability Security + Program Logics | **✓** | **✓** | **~** | **✗** | **Complete (Partially Covered)** |
170
+ | **CC-05** | Language-Based Security + Trusted Computing | - | - | - | - | **FROZEN (Identified Semantic Gaps)** |
171
+ | **CC-08** | Runtime Verification + Capability Security | - | - | - | - | **FROZEN (Identified Semantic Gaps)** |
172
+ | **Cortex** | Spatiotemporal Preorders + Epoch-Indexed Value/Trace Relations | **✓** | **✓** | **✓** | **✓** | **FORMALLY PROVEN & ROADMAPPED** |
173
+
174
+ *Legend: **✓** (Success) | **✗** (Failed) | **~** (Partial Success) | **-** (Not yet evaluated / Frozen)*
175
+
176
+ ---
177
+
178
+ ## 🛠️ Repository Rules & Governance
179
+
180
+ 1. **LOCKED State:** Foundational survey, model, and formal construction documents are frozen once complete to maintain strict control over confirmation bias.
181
+ 2. **No Marketing Syntax:** Language remains strictly technical, quantitative, and neutral.