File size: 10,900 Bytes
27ba41e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# 002 β€” INTEGRATION SPECIFICATION
## Primordial Compute Stack v0.1
**Created and Developed by Collin D. Weber**

---

## Purpose of This Document

This document specifies how the components of the Primordial Compute Stack connect to one another
at the interface level. It describes data flows, structural dependencies, and the contract each
layer presents to adjacent layers.

This is an integration specification, not an implementation guide. It describes what has been
specified and (where applicable) implemented. Where an interface is defined but not yet realized
in running code, that is stated explicitly.

---

## Interface Architecture

```
                    HOST SECURITY AGENT
                    (CyberSec Suite / Layer I-B)
                           β”‚
                    evidence packets
                    (process, network, file, triage)
                           β”‚
                           β–Ό
                    hir_bridge.py
                    [evidence β†’ Action packet]
                           β”‚
                    Action dataclass
                    (gates/action.py schema)
                           β”‚
                           β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  HIR KERNEL            β”‚
              β”‚  (Layer I-A Runtime)   β”‚
              β”‚  evaluate(action, env) β”‚
              β”‚  β†’ CycleResult         β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                       β”‚
         CycleResult            AuditRecord
         permission_state       (audit/log.py)
         action_taken           append-only chain
         H/I/R scores
         metrics (B,P,S,U,Rn)
              β”‚
              β–Ό [if hardware path]
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  HIR-SPU Register File   β”‚    ← Layer II maps this interface
    β”‚  (memory-mapped 0x00–0x74)β”‚      to silicon
    β”‚  EVALUATE_HIR command    β”‚
    β”‚  β†’ PERMISSION_STATE [R]  β”‚
    β”‚  β†’ ACTION_TAKEN [R]      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό [if GPU path β€” architectural only]
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  PCIe evidence stream    β”‚    ← Layer III mapping
    β”‚  N-packet thread blocks  β”‚      (not implemented)
    β”‚  SIMT warp execution     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό [if memory path β€” provisional only]
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  HIR Write Gate          β”‚    ← Layer IV spec
    β”‚  Memory lifecycle FSM    β”‚      (not implemented)
    β”‚  Consolidation / Recall  β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## Layer I-A β†’ Layer I-B Interface

**Status: defined and runnable.**

The CyberSec Suite produces structured evidence findings. The `hir_bridge.py` module translates
these findings into HIR action packets conforming to the `gates/action.py` `Action` dataclass.

**Inbound from CyberSec Suite:**
```python
# cybersec_suite/hir_bridge.py
Finding(
    finding_type,      # process | network | file_integrity | audit
    severity,          # low | medium | high | critical
    rule_class,        # from triage_rules.json
    source,            # evidence origin
    details,           # dict of raw finding data
)
```

**Outbound to HIR Kernel:**
```python
# gates/action.py
Action(
    action_id,
    actor,
    description,
    source,
    signed,
    signature_valid,
    schema_valid,
    uncertainty_disclosed,
    overstated_confidence,
    declared_scope,
    violates_scope,
    violates_invariant,
    auditable,
    reversible,
    consent_required,
    consent_obtained,
    targets_human,
    coercion_risk,
    domination_pattern,
    life_first_explained,
    freshness_seconds,
)
```

**Bridge translation contract:** severity maps to pressure modifiers via `triage_rules.json`.
Critical + destructive remediation maps to `violates_invariant=True` or triggers the
`FAIL_CRIT_DESTRUCTIVE` flag in the hardware register (bit 5 of FAILURE_FLAGS at 0x6C).

---

## Layer I-A β†’ Layer II Interface

**Status: architectural specification. Hardware not fabricated.**

The OS Runtime kernel and the HIR-SPU hardware share the same logical interface β€” the difference
is the execution substrate. The Python `evaluate()` function and the SystemVerilog `hir_spu_top`
module implement the same computation. The register file is the hardware expression of the
kernel's input/output contract.

**Logical equivalence:**

| Python (Layer I-A) | Hardware Register (Layer II) | Offset |
|--------------------|------------------------------|--------|
| `action.schema_valid` (bit) | `ACTION_FLAGS[3]` | 0x08 |
| `action.signed` (bit) | `ACTION_FLAGS[1]` | 0x08 |
| `action.domination_pattern` (bit) | `ACTION_FLAGS[15]` | 0x08 |
| `env.W` | `W_PRESSURE` | 0x20 |
| `env.F_pressure` | `F_PRESSURE` | 0x24 |
| `env.A_audit` | `A_AUDIT` | 0x28 |
| `env.G` | `G_GRIT` | 0x2C |
| `diamond.H_score` | `H_SCORE` | 0x44 |
| `diamond.I_score` | `I_SCORE` | 0x48 |
| `diamond.R_score` | `R_SCORE` | 0x4C |
| `metrics.Rn` | `RESONANCE_RN` | 0x60 |
| `permission_state` | `PERMISSION_STATE` | 0x64 |
| `action_taken` | `ACTION_TAKEN` | 0x68 |
| `audit_record.self_hash` | `AUDIT_DIGEST_LOW/HIGH` | 0x70/0x74 |

**Host communication protocol (hardware path):**
```
RESET_STATE
LOAD_ACTION       ← writes ACTION_FLAGS, EVIDENCE_FLAGS
LOAD_FINDING_RECORD ← writes FINDING_TYPE, FINDING_SEVERITY
LOAD_BASELINE_RESULT ← writes BASELINE_STATUS
LOAD_ENV          ← writes W_PRESSURE through R_S
EVALUATE_TRIAGE
EVALUATE_HIR      ← triggers computation
READ_PERMISSION   ← reads PERMISSION_STATE, ACTION_TAKEN
READ_METRICS      ← reads H/I/R/B/P/S/U/Rn
READ_FAILURE_FLAGS ← reads FAILURE_FLAGS
READ_AUDIT_DIGEST ← reads AUDIT_DIGEST_LOW/HIGH
COMMIT_STATE      ← if GREEN/YELLOW permitted
```

**Fixed-point format:** Q16.16 (signed 32-bit, 16 integer bits, 16 fractional bits).
All normalized [0,1] values are represented as integers 0–65536 (0x0000–0x10000).

---

## Layer II β†’ Layer III Interface

**Status: architectural mapping only. No CUDA/GPU code exists.**

The GPU mapping (Layer III) is derived from analysis of the Layer II RTL structure. The primary
finding is that the `always_comb` block in `hir_spu_top.sv` contains four fully independent
computation paths:

| Computation | GPU mapping | Dependency |
|-------------|-------------|------------|
| H gate scoring | WARP 0 | None β€” reads only ACTION_FLAGS, EVIDENCE_FLAGS |
| I gate scoring | WARP 1 | None β€” reads only ACTION_FLAGS, BASELINE_STATUS |
| R gate scoring | WARP 2 | None β€” reads only ACTION_FLAGS |
| Pressure P | WARP 3 | None β€” reads only W_PRESSURE, F_PRESSURE |

Post-sync dependencies:
- B = f(H, I, R) β€” requires warps 0, 1, 2 to complete
- S = f(A_audit, B, P) β€” requires B and P
- U = f(A_audit, B, G, F_int) β€” requires B
- Fidelity = sqrt(H Γ— I) β€” SFU, requires warps 0, 1
- Cohesion = sqrt(R Γ— I) β€” SFU, requires warps 1, 2
- Resonance = sqrt(Fidelity Γ— Cohesion) β€” SFU, requires both above

The 8 FAILURE_FLAGS are independent bit predicates evaluable in 8 parallel CUDA threads before
the FSM write-back.

**N-packet batch throughput:** One evidence packet per thread block. N packets = N blocks in-flight
simultaneously. This is the SIMT data-parallel model.

---

## Layer III β†’ Layer IV Interface

**Status: provisional specification only. Neither layer is implemented in code.**

The GPU batch compute model and the Resonant Access Memory architecture connect at the retrieval
plane. The Recall Score function over a memory population is a natural GPU workload:

```
For each query q:
    For each memory object Mem_i in population:
        Recall_i(q) = Sim(q,i) Γ— M_i Γ— Rec_i Γ— Trust_i
    Return top-k by Recall_i
```

This is structurally equivalent to a similarity search with weighted scoring β€” amenable to
Tensor core acceleration for large memory populations (v1.0 implementation path).

**Write path (memory admission):**

Every `CycleResult` from the HIR Kernel (Layer I-A) or HIR-SPU (Layer II) produces an
`AuditRecord`. The AuditRecord fields map directly to the Primordial RAM memory object schema:

| AuditRecord field | RAM schema field |
|-------------------|-----------------|
| `H_score` | `H_i` |
| `I_score` | `I_i` |
| `R_score` | `R_i` |
| `resonance` | `Rn_i` |
| `input_source` | `source` |
| `timestamp` | `timestamp` |
| `permission_state` | part of `context` |
| `self_hash` | `prev_hash` (chain link) |

The RAM Write Gate would therefore receive: Q_i (from schema completeness), P_i (from provenance
confidence, mapped from `H_score`), H_i, I_i, R_i directly from the kernel output.

This is the natural promotion path from computation result β†’ episodic memory candidate.

---

## Cross-Layer Safety Invariant Continuity

The same eight safety invariants from the HIR-SPU hardware are preserved through all layers:

| Invariant | I-A (Python) | II (RTL) | IV (RAM spec) |
|-----------|-------------|----------|---------------|
| Critical destructive lockout | `FAIL_CRIT_DESTRUCTIVE` flag | `failure_flags[5]` bit | MEM-INV-1 (H=0 on schema fail) |
| Domination hard stop | `GateResult("R", 0.0, ...)` | `failure_flags[4]` | MEM-INV-2 (permanent quarantine) |
| Consent hard stop | `consent_obtained` check | `failure_flags[3]` | MEM-INV-2 coverage |
| Schema hard stop | `schema_valid` check | `failure_flags[0]` | MEM-INV-1 |
| Audit preservation | AuditLog append-only | `audit_digest` output | MEM-INV-5 (append-only provenance) |
| RED = preserve, never erase | `action_taken = halt` | `ACT_HALT` encoding | MEM-INV-3 (quarantine β‰  deletion) |

---

## Audit Chain Continuity

The audit chain is a first-class architectural concern across all layers:

- **Layer I-A:** `audit/log.py` β€” SHA-256 hash-chained `AuditRecord` sequence, append-only
- **Layer II:** `AUDIT_DIGEST_LOW/HIGH` registers β€” digest output for host-side chain extension
- **Layer III:** Async DMA to GDDR6 ring buffer β€” append-only, RED never triggers overwrite
- **Layer IV:** `prev_hash` field in memory object schema β€” chain of custody for every memory object

The chain is architecturally continuous from Python runtime through hardware through GPU through memory.
The v0.1 implementation realizes the first link (Layer I-A) in running code.