Skip to content

Commit 868caed

Browse files
committed
Update UEPS protocol documentation and add Threat-Score Monitor
Renamed sections for clarity, added a detailed TLV field table for the UEPS protocol, and introduced a new Threat-Score Monitor section with Go code for threat metric calculation. Removed duplicate TLV table and relocated the ThreatMetrics code to improve documentation structure.
1 parent da4822a commit 868caed

File tree

1 file changed

+43
-39
lines changed

1 file changed

+43
-39
lines changed

docs/web3/labs/gateway.md

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ So, there you go, simply put, Lethean Gateway is just a fancy router into and ou
3030

3131
\* not a typo, encryption, not just encrypted.
3232

33-
### Autonomy RuleSet
33+
### Unified Ethical Protocol Stack (UEPS) a.k.a Autonomy RuleSet
3434

3535
Using an Computational Ethics framework [Axioms of Life](https://github.com/Snider/ai-ethics), we can create ethically
3636
aligned context windows within todays LLM's; below is how the Gateway implements each axiom.
@@ -79,7 +79,7 @@ aligned context windows within todays LLM's; below is how the Gateway implements
7979
The work proposes nothing less than a universal meta-ethics for conscious beings.
8080

8181

82-
## Universal Ethical Protocol Suite (UEPS) Protocol Stack
82+
## UEPS Network Protocol
8383

8484
A protocol stack that can be layered on top of any physical transport (RF, fiber, quantum‑photonic).
8585
It provides a standardized language for expressing the axioms during communication.
@@ -95,6 +95,19 @@ It provides a standardized language for expressing the axioms during communicati
9595

9696
Because the suite is substrate‑agnostic, it can be implemented on classical IP, a quantum‑topological mesh, or on any future “null‑routable” medium that emerges from material‑science breakthroughs.
9797

98+
## TLV
99+
100+
| Type (1 byte) | Length (1 byte) | Value (variable) |
101+
|---------------|-----------------|--------------------------------------------------------------------------------------|
102+
| `0x01` | 1 | Version (e.g., `0x09` for IPv9) |
103+
| `0x02` | 1 | Current Layer (0-9) |
104+
| `0x03` | 1 | Target Layer (where the packet should end up) |
105+
| `0x04` | 1 | Intent ID (Layer 9 semantic token) |
106+
| `0x05` | 2 | Threat-Score (uint16, 0-65535) |
107+
| `0x06` | 32 | HMAC-SHA256 over the entire header + payload, keyed by the current gateway’s secret. |
108+
| `0xFF` | variable | Payload (original TCP segment) |
109+
110+
98111
### Diagram
99112
The linear progression of a packet as it moves through the UEPS protocol, ending at the remote endpoint.
100113

@@ -109,16 +122,6 @@ flowchart LR
109122
L5 --> DEST["Remote Endpoint"]
110123
```
111124

112-
| Type (1 byte) | Length (1 byte) | Value (variable) |
113-
|---------------|-----------------|--------------------------------------------------------------------------------------|
114-
| `0x01` | 1 | Version (e.g., `0x09` for IPv9) |
115-
| `0x02` | 1 | Current Layer (0-9) |
116-
| `0x03` | 1 | Target Layer (where the packet should end up) |
117-
| `0x04` | 1 | Intent ID (Layer 9 semantic token) |
118-
| `0x05` | 2 | Threat-Score (uint16, 0-65535) |
119-
| `0x06` | 32 | HMAC-SHA256 over the entire header + payload, keyed by the current gateway’s secret. |
120-
| `0xFF` | variable | Payload (original TCP segment) |
121-
122125
### Explanation of the flow
123126

124127
- **L0** – Your application’s payload enters the stack.
@@ -187,6 +190,34 @@ flowchart LR
187190
GW_C -->|Score Update| SCORE
188191
189192
```
193+
## Threat-Score Monitor
194+
195+
``` golang
196+
type ThreatMetrics struct {
197+
IDSAlerts int // count of alerts per minute
198+
PacketLoss float64 // % loss observed
199+
LatencyMs float64 // avg RTT
200+
Reputation float64 // external feed score (0‑1)
201+
}
202+
203+
// Simple weighted formula
204+
func ComputeScore(m ThreatMetrics) uint16 {
205+
const (
206+
wIDS = 0.4
207+
wLoss = 0.2
208+
wLat = 0.3
209+
wRep = 0.1
210+
)
211+
raw := wIDS*float64(m.IDSAlerts) +
212+
wLoss*m.PacketLoss*10 + // scale loss to 0‑10
213+
wLat*m.LatencyMs/10 + // scale latency
214+
wRep*(1-m.Reputation)*100 // invert reputation
215+
// Clamp to 0‑65535
216+
if raw < 0 { raw = 0 }
217+
if raw > 65535 { raw = 65535 }
218+
return uint16(raw)
219+
}
220+
```
190221

191222
## Consent‑Gate Flow
192223

@@ -216,33 +247,6 @@ flowchart LR
216247
DECIDE -->|No| DEFER[Defer / Re‑negotiate]
217248
```
218249

219-
``` golang
220-
type ThreatMetrics struct {
221-
IDSAlerts int // count of alerts per minute
222-
PacketLoss float64 // % loss observed
223-
LatencyMs float64 // avg RTT
224-
Reputation float64 // external feed score (0‑1)
225-
}
226-
227-
// Simple weighted formula
228-
func ComputeScore(m ThreatMetrics) uint16 {
229-
const (
230-
wIDS = 0.4
231-
wLoss = 0.2
232-
wLat = 0.3
233-
wRep = 0.1
234-
)
235-
raw := wIDS*float64(m.IDSAlerts) +
236-
wLoss*m.PacketLoss*10 + // scale loss to 0‑10
237-
wLat*m.LatencyMs/10 + // scale latency
238-
wRep*(1-m.Reputation)*100 // invert reputation
239-
// Clamp to 0‑65535
240-
if raw < 0 { raw = 0 }
241-
if raw > 65535 { raw = 65535 }
242-
return uint16(raw)
243-
}
244-
```
245-
246250
## Prime‑Guard + Rehab‑Loop (Protection & Intervention)
247251

248252
### Diagram

0 commit comments

Comments
 (0)