cortex-runtime 0.2.0__py3-none-any.whl

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/__init__.py +51 -0
  2. cortex/__main__.py +13 -0
  3. cortex/client.py +263 -0
  4. cortex/compat.py +20 -0
  5. cortex/exceptions.py +57 -0
  6. cortex/plugin.py +50 -0
  7. cortex/py.typed +1 -0
  8. cortex/schema/__init__.py +29 -0
  9. cortex/schema/events.py +127 -0
  10. cortex/tools/__init__.py +3 -0
  11. cortex/tools/cli/__init__.py +3 -0
  12. cortex/tools/cli/main.py +139 -0
  13. cortex/tools/cli/runner.py +94 -0
  14. cortex/tools/cli/scaffolder.py +109 -0
  15. cortex/tools/gen_test_bin.py +35 -0
  16. cortex/tools/kernel/__init__.py +3 -0
  17. cortex/tools/kernel/actors/__init__.py +3 -0
  18. cortex/tools/kernel/actors/executor.py +44 -0
  19. cortex/tools/kernel/actors/planner.py +38 -0
  20. cortex/tools/kernel/context.py +22 -0
  21. cortex/tools/kernel/drivers/__init__.py +3 -0
  22. cortex/tools/kernel/drivers/mock_robot.py +84 -0
  23. cortex/tools/kernel/drivers/rtl_verilator.py +49 -0
  24. cortex/tools/kernel/graph/__init__.py +3 -0
  25. cortex/tools/kernel/graph/analyzer.py +52 -0
  26. cortex/tools/kernel/graph/execution_graph.py +44 -0
  27. cortex/tools/kernel/mailbox.py +35 -0
  28. cortex/tools/kernel/plugin/__init__.py +3 -0
  29. cortex/tools/kernel/plugin/loader.py +87 -0
  30. cortex/tools/kernel/plugin/manifest.py +53 -0
  31. cortex/tools/kernel/registry.py +36 -0
  32. cortex/tools/kernel/schema/__init__.py +3 -0
  33. cortex/tools/kernel/schema/contract.py +16 -0
  34. cortex/tools/kernel/schema/event.py +54 -0
  35. cortex/tools/kernel/schema/message.py +105 -0
  36. cortex/tools/kernel/schema/workflow.py +38 -0
  37. cortex/tools/kernel/services/__init__.py +3 -0
  38. cortex/tools/kernel/services/event_store.py +25 -0
  39. cortex/tools/kernel/services/execution_intelligence.py +49 -0
  40. cortex/tools/kernel/services/graph_builder.py +81 -0
  41. cortex/tools/kernel/services/replay.py +50 -0
  42. cortex/tools/kernel/services/verification.py +85 -0
  43. cortex/tools/kernel/transport.py +50 -0
  44. cortex/tools/run_phase2_verification.sh +20 -0
  45. cortex/tools/verification/__init__.py +5 -0
  46. cortex/tools/verification/adapters/__init__.py +3 -0
  47. cortex/tools/verification/adapters/base.py +14 -0
  48. cortex/tools/verification/adapters/coq.py +73 -0
  49. cortex/tools/verification/adapters/rtl.py +77 -0
  50. cortex/tools/verification/adapters/rust.py +72 -0
  51. cortex/tools/verification/archive.py +58 -0
  52. cortex/tools/verification/bus.py +28 -0
  53. cortex/tools/verification/contract.py +70 -0
  54. cortex/tools/verification/engine.py +121 -0
  55. cortex/tools/verification/generator/__init__.py +3 -0
  56. cortex/tools/verification/generator/composer.py +36 -0
  57. cortex/tools/verification/generator/program.py +46 -0
  58. cortex/tools/verification/generator/state.py +54 -0
  59. cortex/tools/verification/invariants/__init__.py +3 -0
  60. cortex/tools/verification/invariants/capability.py +62 -0
  61. cortex/tools/verification/metrics/__init__.py +3 -0
  62. cortex/tools/verification/metrics/base.py +18 -0
  63. cortex/tools/verification/metrics/opcode.py +25 -0
  64. cortex/tools/verification/metrics/state_space.py +26 -0
  65. cortex/tools/verification/metrics/trap.py +26 -0
  66. cortex/tools/verification/mutation.py +48 -0
  67. cortex/tools/verification/oracle.py +164 -0
  68. cortex/tools/verification/schema/__init__.py +44 -0
  69. cortex/tools/verification/schema/event.py +44 -0
  70. cortex/tools/verification/shrink.py +26 -0
  71. cortex/tools/verify.py +64 -0
  72. cortex_runtime-0.2.0.dist-info/METADATA +220 -0
  73. cortex_runtime-0.2.0.dist-info/RECORD +76 -0
  74. cortex_runtime-0.2.0.dist-info/WHEEL +4 -0
  75. cortex_runtime-0.2.0.dist-info/entry_points.txt +2 -0
  76. cortex_runtime-0.2.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,164 @@
1
+ """
2
+ Structured Verification Oracle for 3-Way Trace Equivalence
3
+ """
4
+
5
+ from typing import Any
6
+
7
+ from cortex.tools.verification.schema import CanonicalState
8
+
9
+
10
+ class VerificationOracle:
11
+ def __init__(self, version: str = "v2.1.0", strict_trap_matching: bool = True):
12
+ self.version = version
13
+ self.strict_trap_matching = strict_trap_matching
14
+
15
+ def evaluate_equivalence(
16
+ self,
17
+ coq_trace: list[CanonicalState],
18
+ rust_trace: list[CanonicalState],
19
+ rtl_trace: list[CanonicalState] | None = None
20
+ ) -> dict[str, Any]:
21
+ """
22
+ Evaluates step-by-step equivalence across CanonicalState objects.
23
+ Returns structured diagnostic object.
24
+ """
25
+ # 1. Length check
26
+ if len(coq_trace) != len(rust_trace):
27
+ return {
28
+ "status": "FAIL",
29
+ "error_type": "LengthMismatch",
30
+ "message": f"Coq emitted {len(coq_trace)} steps, Rust emitted {len(rust_trace)} steps",
31
+ "observed_divergence": {"coq_len": len(coq_trace), "rust_len": len(rust_trace)}
32
+ }
33
+
34
+ if rtl_trace and len(rust_trace) != len(rtl_trace):
35
+ return {
36
+ "status": "FAIL",
37
+ "error_type": "LengthMismatch",
38
+ "message": f"Rust emitted {len(rust_trace)} steps, RTL emitted {len(rtl_trace)} steps",
39
+ "observed_divergence": {"rust_len": len(rust_trace), "rtl_len": len(rtl_trace)}
40
+ }
41
+
42
+ # 2. Frame-by-frame field evaluation
43
+ num_steps = len(coq_trace)
44
+ for idx in range(num_steps):
45
+ c_step = coq_trace[idx]
46
+ e_step = rust_trace[idx]
47
+ step_num = idx + 1
48
+
49
+ # HEC match
50
+ if c_step.reg_hec != e_step.reg_hec:
51
+ return {
52
+ "status": "FAIL",
53
+ "error_type": "StateDivergence",
54
+ "failing_step": step_num,
55
+ "mismatched_field": "reg_hec",
56
+ "canonical_expected": {"coq": c_step.reg_hec},
57
+ "observed_divergence": {"rust": e_step.reg_hec}
58
+ }
59
+
60
+ # Trap status match
61
+ if c_step.trap.triggered != e_step.trap.triggered:
62
+ return {
63
+ "status": "FAIL",
64
+ "error_type": "TrapStatusMismatch",
65
+ "failing_step": step_num,
66
+ "mismatched_field": "trap.triggered",
67
+ "canonical_expected": {"coq": c_step.trap.triggered},
68
+ "observed_divergence": {"rust": e_step.trap.triggered}
69
+ }
70
+
71
+ # STCR file match
72
+ for r in range(32):
73
+ c_stcr = c_step.stcr[r]
74
+ e_stcr = e_step.stcr[r]
75
+
76
+ if c_stcr.valid != e_stcr.valid:
77
+ return {
78
+ "status": "FAIL",
79
+ "error_type": "StateDivergence",
80
+ "failing_step": step_num,
81
+ "mismatched_field": f"stcr[{r}].valid",
82
+ "canonical_expected": {"coq": c_stcr.valid},
83
+ "observed_divergence": {"rust": e_stcr.valid}
84
+ }
85
+ if c_stcr.valid:
86
+ if c_stcr.permissions != e_stcr.permissions:
87
+ return {
88
+ "status": "FAIL",
89
+ "error_type": "StateDivergence",
90
+ "failing_step": step_num,
91
+ "mismatched_field": f"stcr[{r}].permissions",
92
+ "canonical_expected": {"coq": c_stcr.permissions},
93
+ "observed_divergence": {"rust": e_stcr.permissions}
94
+ }
95
+ if c_stcr.epoch != e_stcr.epoch:
96
+ return {
97
+ "status": "FAIL",
98
+ "error_type": "StateDivergence",
99
+ "failing_step": step_num,
100
+ "mismatched_field": f"stcr[{r}].epoch",
101
+ "canonical_expected": {"coq": c_stcr.epoch},
102
+ "observed_divergence": {"rust": e_stcr.epoch}
103
+ }
104
+
105
+ # RTL 3-way check if RTL trace present
106
+ if rtl_trace:
107
+ r_step = rtl_trace[idx]
108
+ if e_step.reg_hec != r_step.reg_hec:
109
+ return {
110
+ "status": "FAIL",
111
+ "error_type": "StateDivergence",
112
+ "failing_step": step_num,
113
+ "mismatched_field": "reg_hec",
114
+ "canonical_expected": {"rust": e_step.reg_hec},
115
+ "observed_divergence": {"rtl": r_step.reg_hec}
116
+ }
117
+ if e_step.trap.triggered != r_step.trap.triggered:
118
+ return {
119
+ "status": "FAIL",
120
+ "error_type": "TrapStatusMismatch",
121
+ "failing_step": step_num,
122
+ "mismatched_field": "trap.triggered",
123
+ "canonical_expected": {"rust": e_step.trap.triggered},
124
+ "observed_divergence": {"rtl": r_step.trap.triggered}
125
+ }
126
+
127
+ for r in range(32):
128
+ e_stcr = e_step.stcr[r]
129
+ r_stcr = r_step.stcr[r]
130
+ if e_stcr.valid != r_stcr.valid:
131
+ return {
132
+ "status": "FAIL",
133
+ "error_type": "StateDivergence",
134
+ "failing_step": step_num,
135
+ "mismatched_field": f"stcr[{r}].valid",
136
+ "canonical_expected": {"rust": e_stcr.valid},
137
+ "observed_divergence": {"rtl": r_stcr.valid}
138
+ }
139
+ if e_stcr.valid:
140
+ if e_stcr.permissions != r_stcr.permissions:
141
+ return {
142
+ "status": "FAIL",
143
+ "error_type": "StateDivergence",
144
+ "failing_step": step_num,
145
+ "mismatched_field": f"stcr[{r}].permissions",
146
+ "canonical_expected": {"rust": e_stcr.permissions},
147
+ "observed_divergence": {"rtl": r_stcr.permissions}
148
+ }
149
+ if e_stcr.epoch != r_stcr.epoch:
150
+ return {
151
+ "status": "FAIL",
152
+ "error_type": "StateDivergence",
153
+ "failing_step": step_num,
154
+ "mismatched_field": f"stcr[{r}].epoch",
155
+ "canonical_expected": {"rust": e_stcr.epoch},
156
+ "observed_divergence": {"rtl": r_stcr.epoch}
157
+ }
158
+
159
+ return {
160
+ "status": "PASS",
161
+ "evaluated_steps": num_steps,
162
+ "targets_checked": 3 if rtl_trace else 2,
163
+ "message": "1:1 State Equivalence Confirmed Across Evaluated Targets"
164
+ }
@@ -0,0 +1,44 @@
1
+ """
2
+ Typed Verification Schemas Package
3
+ """
4
+
5
+ from dataclasses import asdict, dataclass
6
+
7
+
8
+ @dataclass
9
+ class CanonicalSTCR:
10
+ index: int
11
+ valid: bool
12
+ permissions: int
13
+ base_address: int
14
+ epoch: int
15
+
16
+ def to_dict(self) -> dict[str, object]:
17
+ return asdict(self)
18
+
19
+ @dataclass
20
+ class CanonicalTrap:
21
+ triggered: bool
22
+ cause_code: int
23
+ cause_name: str
24
+ trap_val: int
25
+
26
+ def to_dict(self) -> dict[str, object]:
27
+ return asdict(self)
28
+
29
+ @dataclass
30
+ class CanonicalState:
31
+ step: int
32
+ pc: int
33
+ instruction: str
34
+ privilege_mode: str
35
+ reg_hec: int
36
+ registers: dict[str, str]
37
+ stcr: list[CanonicalSTCR]
38
+ trap: CanonicalTrap
39
+
40
+ def to_dict(self) -> dict[str, object]:
41
+ d = asdict(self)
42
+ d["stcr"] = [s.to_dict() for s in self.stcr]
43
+ d["trap"] = self.trap.to_dict()
44
+ return d
@@ -0,0 +1,44 @@
1
+ """
2
+ Frozen CommitEventV1 Schema for Architectural Retirement Events
3
+ """
4
+
5
+ from dataclasses import asdict, dataclass
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class PureArchitecturalStateV1:
10
+ pc: str
11
+ instruction: str
12
+ privilege_mode: str
13
+ registers: dict[str, str]
14
+ stcr: list[dict[str, object]]
15
+ trap: dict[str, object]
16
+ memory_commit: dict[str, object] | None = None
17
+
18
+ def to_dict(self) -> dict[str, object]:
19
+ return asdict(self)
20
+
21
+ @dataclass(frozen=True)
22
+ class ObservationMetadataV1:
23
+ step: int
24
+ cycle: int
25
+ timestamp_ns: int
26
+ target_name: str
27
+ commit_id: str
28
+ adapter_version: str
29
+
30
+ def to_dict(self) -> dict[str, object]:
31
+ return asdict(self)
32
+
33
+ @dataclass(frozen=True)
34
+ class CommitEventV1:
35
+ schema_version: int = 1
36
+ architectural: PureArchitecturalStateV1 | None = None
37
+ observation: ObservationMetadataV1 | None = None
38
+
39
+ def to_dict(self) -> dict[str, object]:
40
+ return {
41
+ "schema_version": self.schema_version,
42
+ "architectural": self.architectural.to_dict() if self.architectural else {},
43
+ "observation": self.observation.to_dict() if self.observation else {}
44
+ }
@@ -0,0 +1,26 @@
1
+ """
2
+ Semantic Delta-Debugging Shrinker for Minimizing Failing Scenarios
3
+ """
4
+
5
+ from typing import Any
6
+
7
+
8
+ class SemanticShrinker:
9
+ def __init__(self, max_shrunk_steps: int = 50):
10
+ self.max_shrunk_steps = max_shrunk_steps
11
+
12
+ def shrink_scenario(self, scenario: dict[str, Any], failing_step: int) -> dict[str, Any]:
13
+ """
14
+ Reduces program instructions down to failing step minimum reproducer.
15
+ """
16
+ program = scenario.get("program", [])
17
+ # Truncate instruction stream up to failing step
18
+ shrunk_program = program[:failing_step]
19
+
20
+ return {
21
+ "seed": scenario.get("seed", "0x00000000"),
22
+ "original_steps": len(program),
23
+ "shrunk_steps": len(shrunk_program),
24
+ "initial_state": scenario.get("initial_state", {}),
25
+ "program": shrunk_program
26
+ }
cortex/tools/verify.py ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Cortex Contract-Driven Formal Verification CLI Entry Point
4
+ """
5
+
6
+ import argparse
7
+ import sys
8
+
9
+ from cortex.tools.verification.contract import VerificationContract
10
+ from cortex.tools.verification.engine import VerificationEngine
11
+
12
+
13
+ def main():
14
+ parser = argparse.ArgumentParser(description="Cortex Contract-Driven Formal Verification Tool")
15
+ parser.add_argument("--contract", required=True, help="Path to verification contract YAML")
16
+ parser.add_argument("--seed", default=None, help="Hex seed for random generation (e.g. 0x4A91C3F8)")
17
+ parser.add_argument("--iterations", type=int, default=None, help="Override total fuzzing iterations")
18
+ parser.add_argument("--inject-failure", default=None, help="Phase 3A.5 mutation fault vector to inject")
19
+
20
+ args = parser.parse_args()
21
+
22
+ contract = VerificationContract.load(args.contract)
23
+
24
+ # Determine seed
25
+ seed_str = args.seed or contract.fuzzing_parameters.get("default_seed", "0x4A91C3F8")
26
+ seed_val = int(seed_str, 16) if seed_str.startswith("0x") else int(seed_str)
27
+
28
+ iterations = args.iterations or contract.fuzzing_parameters.get("total_iterations", 100)
29
+
30
+ print("================================================================================")
31
+ print(" Cortex Verification Platform Engine ")
32
+ print("================================================================================")
33
+ print(f" Contract ID: {contract.contract_id}")
34
+ print(f" Seed: 0x{seed_val:08X}")
35
+ print(f" Target Iterations: {iterations}")
36
+ print(f" Oracle Version: {contract.oracle.get('version', 'v2.1.0')}")
37
+ if args.inject_failure:
38
+ print(f" Injecting Fault: {args.inject_failure}")
39
+ print("--------------------------------------------------------------------------------")
40
+
41
+ engine = VerificationEngine(contract, seed_val)
42
+ result = engine.run_verification(iterations=iterations, inject_failure=args.inject_failure)
43
+
44
+ if result.get("status") == "FAIL":
45
+ print("\n[!] VERIFICATION MISMATCH DETECTED!")
46
+ print(f" Iteration: {result.get('iteration')}")
47
+ print(f" Seed: {result.get('seed')}")
48
+ print(f" Error Type: {result['diagnostic'].get('error_type')}")
49
+ print(f" Failing Step: {result['diagnostic'].get('failing_step')}")
50
+ print(f" Mismatched Field: {result['diagnostic'].get('mismatched_field')}")
51
+ print(f" Counterexample Hash: {result.get('counterexample_hash')}")
52
+ print("================================================================================")
53
+ sys.exit(1)
54
+ else:
55
+ print("\n[✓] SUCCESS: Contract-Driven Verification Passed Across All Targets!")
56
+ print(f" Steps Evaluated: {result.get('total_steps_evaluated')}")
57
+ print(f" Opcode Coverage: {result['metrics']['opcode_coverage']['coverage_percentage']}%")
58
+ print(f" Trap Path Coverage: {result['metrics']['trap_coverage']['coverage_percentage']}%")
59
+ print(f" Unique States: {result['metrics']['state_space_explored']['unique_states_explored']}")
60
+ print("================================================================================")
61
+ sys.exit(0)
62
+
63
+ if __name__ == "__main__":
64
+ main()
@@ -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,76 @@
1
+ cortex/__init__.py,sha256=ayyrrKRJj5LIwIGUUkvtHWMnOxRMXcP64mvmhofrQxI,1229
2
+ cortex/__main__.py,sha256=LtCpUXpZXkUo4lEIB93tDOmynS9rQOXwJtf4_9G1qP4,273
3
+ cortex/client.py,sha256=hSrlUTIFrS8jSe_gwzstbHK5AacKDbjRKMewVVLfFIo,10538
4
+ cortex/compat.py,sha256=sg-IFdQZkUtLOHEeH-oz6pfb7xjpPI1nVfI7hBbYMpM,511
5
+ cortex/exceptions.py,sha256=1QDrlro5SZjWY8-S-Et6cug5A46zZk0Gig_hwbFSpoc,1406
6
+ cortex/plugin.py,sha256=u1ybQsfNKEIIXBnLobKzGKxH4KTt6E-txh92zpaeGaw,1535
7
+ cortex/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
8
+ cortex/schema/__init__.py,sha256=zcDHMgeotqDxWC6uLQjHijRfqp_5QpqbgeQgGUnGvUo,536
9
+ cortex/schema/events.py,sha256=VTyhVCEugkgDRgjcAyCnBe50x7Myu4dqSnwlGCOpr9U,5701
10
+ cortex/tools/__init__.py,sha256=Eez_GptaErId1Uz_fEUA4ct-bBg5w0_KfjjbH-HxbHg,65
11
+ cortex/tools/gen_test_bin.py,sha256=qZsLSBFcvmJLKK-eJ9l_LCebX_LaGZ2N0mfkkEyZf3g,1640
12
+ cortex/tools/run_phase2_verification.sh,sha256=Vk6iVAZTe4es8hEMNFX30ePvS7xVlcqBlrAFonU3Pqk,641
13
+ cortex/tools/verify.py,sha256=QIbZakSzZVVqucdKChNgsx6IOUNz6dpEEm5bZWw5X_w,3363
14
+ cortex/tools/cli/__init__.py,sha256=e3zZVwAQ9XTioRj-8hQtuDydaUk0KBrqXXehEzmsY_A,37
15
+ cortex/tools/cli/main.py,sha256=nYUM16MqbuEFthH3dDeZpHysKFtUv0qtJ1IOrRz0xD4,5729
16
+ cortex/tools/cli/runner.py,sha256=2IIjMxA3che4MslRjNhpKItYCLazL5MY73P-dhstCWM,3739
17
+ cortex/tools/cli/scaffolder.py,sha256=rHW5PexfOq38gnKB068A_cI7WPgnwQRAxlLwjqi-P5I,3827
18
+ cortex/tools/kernel/__init__.py,sha256=3lXheH5-p6HxmP7R4g8KlepCjwThWJaOsUgPN95jtMY,35
19
+ cortex/tools/kernel/context.py,sha256=fQHGHLUSvje2tACpRNJxw71yLrpPTnbGEBcEcIDilmw,600
20
+ cortex/tools/kernel/mailbox.py,sha256=bEJt7n1vP2FrON54tHVGGJxD8MF6ZedKxhbG8thBOAc,847
21
+ cortex/tools/kernel/registry.py,sha256=covAAh3HOvgo-OE7nkm03Eds33JA0gkSDl5D5sJ6azk,892
22
+ cortex/tools/kernel/transport.py,sha256=bOU5vpEVvs9YOt2HID46Gtrl971F4fI_Z6HQFHazEqA,1519
23
+ cortex/tools/kernel/actors/__init__.py,sha256=5XQuuKUE2oQydRTMAbt50uBAQS_Xw-ULPsVxJQ_Bn_A,37
24
+ cortex/tools/kernel/actors/executor.py,sha256=kcDc0P9d6xModUX9fIwtzm_gzMAMsQHSbS_Z8KfJM_w,1523
25
+ cortex/tools/kernel/actors/planner.py,sha256=zyyLeY6GTQOGXhsqpldiHl6pZ44R8Rxcb9iVCYo4vbg,1221
26
+ cortex/tools/kernel/drivers/__init__.py,sha256=9RoqcBTsXb_khbmhJGn9jNfBL92F7cbJjjuciW5Bako,34
27
+ cortex/tools/kernel/drivers/mock_robot.py,sha256=O9wJbJ28tH2bACAIcrrBlkblrjCU7sG708Y2zBzTY60,2960
28
+ cortex/tools/kernel/drivers/rtl_verilator.py,sha256=BhVYoi6c2hJk8KogvjcwiTbp47NI0jizQkqs6QsX7qM,1743
29
+ cortex/tools/kernel/graph/__init__.py,sha256=vKpUKReH5-hoiHI-uKYBwZgFlWBl5qRS9VMYGrGlwKI,45
30
+ cortex/tools/kernel/graph/analyzer.py,sha256=Noimtv15VugE1RkOJu9HlLl_BX1OzTQdWXXYzDN52LU,2105
31
+ cortex/tools/kernel/graph/execution_graph.py,sha256=AEF9brXw7oERepqaKQ6KFUr6_PlMGzrf2jm-HSJVdsQ,1531
32
+ cortex/tools/kernel/plugin/__init__.py,sha256=MUSbSDelur4b2G1vnttUJ36MJBm6UpKaBefC-ET64gc,55
33
+ cortex/tools/kernel/plugin/loader.py,sha256=ue0u0M9epZwMKz_8Nwkp92P1kgOT3I2uWKOl1pcWjao,2974
34
+ cortex/tools/kernel/plugin/manifest.py,sha256=t5MDNFPwyhZBCgjYkcq889tpKiiDuRo4pyPkgJYy98M,1919
35
+ cortex/tools/kernel/schema/__init__.py,sha256=p4MHk7QTeEKbjdLiYINl_vsOVqX5gVyhH9BWEPhvjn0,47
36
+ cortex/tools/kernel/schema/contract.py,sha256=AYn6ggqaVUuF8pnjXfV6vwv0aStIViRzC0_Zu001jJU,434
37
+ cortex/tools/kernel/schema/event.py,sha256=JMtJVoCdj8dLqJrf6Qfibp7gD2ab1QHtUbeq5xg_PAg,1683
38
+ cortex/tools/kernel/schema/message.py,sha256=K2OIYmnDQW8wKEuPi3NOuuaiH0_0hA7rMfTwrjkT7Mw,3579
39
+ cortex/tools/kernel/schema/workflow.py,sha256=z7nUqMEOdIfaxSRPyLCGkYYV8RDfLHxhyLyr51GToS0,1006
40
+ cortex/tools/kernel/services/__init__.py,sha256=fyG3gOP4OFD7AuMad57Zcs_58s8oe-2xQhh7zJsuG1g,30
41
+ cortex/tools/kernel/services/event_store.py,sha256=zagzioOFIEFIbfnewYZ3ubkWe5mXF0lPSjT9dcOThqc,574
42
+ cortex/tools/kernel/services/execution_intelligence.py,sha256=vQSjxAZoDMM7-RZlLr10luhWXfbnBsYz2jBO9nlalEg,1821
43
+ cortex/tools/kernel/services/graph_builder.py,sha256=Blirz3X1yVAoamV87MtH1YQX46lhdvxtWNAZA_pv0Hc,2923
44
+ cortex/tools/kernel/services/replay.py,sha256=3GbgrICub2_lyhy4a0Zs9ZwL_LYqP6FC0wkF9ZIjNHw,1886
45
+ cortex/tools/kernel/services/verification.py,sha256=KDK1-smFd9ZoWTbPnL6IaDh51W4LM6xgt7x5v2Oo1Js,3219
46
+ cortex/tools/verification/__init__.py,sha256=BAvpX6Gr3Q_OvHV1Z9R_IFau9NbeHkLV1KDMCRywQpc,73
47
+ cortex/tools/verification/archive.py,sha256=MgC4_IPwnIVdc1HXersFvLp5L3g2XmKpWxQ_anctoPI,1863
48
+ cortex/tools/verification/bus.py,sha256=TkFgvTdPD6vWLPtQ7GDc7TfptZWWA5hwCiFujltklCQ,809
49
+ cortex/tools/verification/contract.py,sha256=JKDmSSXBVrx6LzFarYqz1R_dOOSTnQ_6iLGsGlVuMxc,2536
50
+ cortex/tools/verification/engine.py,sha256=8rwFyifsfdb_2gqgreDqvEnvduSXdXLgAZ1_5CKWeVs,4851
51
+ cortex/tools/verification/mutation.py,sha256=bU-ZBsdGWqybuoLUXN98iYZfPMzyaOnnYhFpR7HNUQA,1633
52
+ cortex/tools/verification/oracle.py,sha256=4e9tvZzncjnSlS-O_Co7pO_92axvvLedvwiAhAoJ0KY,7275
53
+ cortex/tools/verification/shrink.py,sha256=S6p2v1Z3P8qMN4nNhhmiRSF_JV7HeQ4nwO4Dlmwp7lw,853
54
+ cortex/tools/verification/adapters/__init__.py,sha256=A2Pr-RSwZy11einluN5h1vrLWMz3U-QEMwLU7_bKgH8,74
55
+ cortex/tools/verification/adapters/base.py,sha256=LUxhPxI4Ou1M0GH__8UalNiJzM2mhM0r_h49WKxD3mg,375
56
+ cortex/tools/verification/adapters/coq.py,sha256=Vt9nIPXkSRYiTifYn1eWl24nx_gm_X7uR8IAnh-tTQk,2427
57
+ cortex/tools/verification/adapters/rtl.py,sha256=iJJK3jjBPO-WWxyJWlxiFxyJDWj-zcKvMLTG8pxP_jE,2469
58
+ cortex/tools/verification/adapters/rust.py,sha256=KvWKSS9HfH1_McxRRrQubArIbaNbDviVUVVAridtmuU,2376
59
+ cortex/tools/verification/generator/__init__.py,sha256=1jx--GkqubKHWMHXkB4JD-0z2po5XZh5iU_k1C0HdNU,44
60
+ cortex/tools/verification/generator/composer.py,sha256=XtdPy15_9V5ic46j93ZUq33ZhkbZqbUppVHzlM6Ro4I,1201
61
+ cortex/tools/verification/generator/program.py,sha256=CQw3I7tUAAFJf7Nd2AZHSKQWoPoV1ASHMCoZ4l30UFo,1478
62
+ cortex/tools/verification/generator/state.py,sha256=-kFtv0aaSYBSuW8PMO9S1Y8nVri2iuiuUpJuH5qc2bo,1639
63
+ cortex/tools/verification/invariants/__init__.py,sha256=itl3usAJj0jqBhXKYwd9i4RBaC0MUUpDxmVppqI8ZSw,50
64
+ cortex/tools/verification/invariants/capability.py,sha256=5Pvg97oeGXxMp9yIhGvSjBcDKaJjhZUAAZKbZM2tNxw,2662
65
+ cortex/tools/verification/metrics/__init__.py,sha256=TEvMngj6FQRb1cgZBZPZbxhMvcR6T3ZjbodoBUB-wRY,41
66
+ cortex/tools/verification/metrics/base.py,sha256=x4_w8ZeXOcPWWFkujuHpJdxdSt6QRYY90JVarT8qxjE,344
67
+ cortex/tools/verification/metrics/opcode.py,sha256=Yk0SSge9LAzhx4OJ401YfyNT-ePNMvgUn2Su10jnglw,703
68
+ cortex/tools/verification/metrics/state_space.py,sha256=NvWJPR49b2CyDHudE_0li8dUeeubKe9u4HUaAotn8FY,746
69
+ cortex/tools/verification/metrics/trap.py,sha256=g_baDirgHZUIDibCPX9SJKbCapysZaN6sTMvypCH3Qw,783
70
+ cortex/tools/verification/schema/__init__.py,sha256=TsRgOXw80B5dcxXWayot2D_RPOqgapZXfjUXpyv_CdI,852
71
+ cortex/tools/verification/schema/event.py,sha256=3PnHTr6zf8AscW5AHJiSnrTo-ZEhp-rsXviVepBtZ-4,1168
72
+ cortex_runtime-0.2.0.dist-info/METADATA,sha256=8utR49w9-dj2TgQjzuNeysHnvjGuWAQnSRD7LBefLrg,12723
73
+ cortex_runtime-0.2.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
74
+ cortex_runtime-0.2.0.dist-info/entry_points.txt,sha256=Hnet-6HKhpZG1vmd0I5n3g8SvyVNnKoQqnjRMc0d9Nc,64
75
+ cortex_runtime-0.2.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
76
+ cortex_runtime-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cortex = cortex.tools.cli.main:cli_entrypoint