Spaces:
Sleeping
Sleeping
ShadowOps Deploy commited on
Commit Β·
f93577c
1
Parent(s): 22f7966
π FINAL FIX: Included api module and __init__ for backend imports
Browse files- backend-ml/api/__init__.py +0 -0
- backend-ml/api/__pycache__/models.cpython-313.pyc +0 -0
- backend-ml/api/__pycache__/models.cpython-313.pyc.1440387183152 +0 -0
- backend-ml/api/__pycache__/models.cpython-313.pyc.1898636194352 +0 -0
- backend-ml/api/__pycache__/models.cpython-313.pyc.1986305570096 +0 -0
- backend-ml/api/__pycache__/models.cpython-313.pyc.1996419363376 +0 -0
- backend-ml/api/__pycache__/models.cpython-314.pyc +0 -0
- backend-ml/api/models.py +119 -0
- docs/SUBMISSION_README_DRAFT.md +12 -0
backend-ml/api/__init__.py
ADDED
|
File without changes
|
backend-ml/api/__pycache__/models.cpython-313.pyc
ADDED
|
Binary file (6.32 kB). View file
|
|
|
backend-ml/api/__pycache__/models.cpython-313.pyc.1440387183152
ADDED
|
Binary file (6.32 kB). View file
|
|
|
backend-ml/api/__pycache__/models.cpython-313.pyc.1898636194352
ADDED
|
Binary file (6.32 kB). View file
|
|
|
backend-ml/api/__pycache__/models.cpython-313.pyc.1986305570096
ADDED
|
Binary file (6.32 kB). View file
|
|
|
backend-ml/api/__pycache__/models.cpython-313.pyc.1996419363376
ADDED
|
Binary file (6.32 kB). View file
|
|
|
backend-ml/api/__pycache__/models.cpython-314.pyc
ADDED
|
Binary file (9.15 kB). View file
|
|
|
backend-ml/api/models.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""api/models.py β Pydantic contracts matching schema_contract.json v3"""
|
| 2 |
+
|
| 3 |
+
from pydantic import BaseModel, Field
|
| 4 |
+
from typing import Any, Dict, List, Optional
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
# ββ Inbound βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 8 |
+
|
| 9 |
+
class WorkerActionIn(BaseModel):
|
| 10 |
+
intent: str
|
| 11 |
+
raw_payload: str
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class InboundMessage(BaseModel):
|
| 15 |
+
domain: str
|
| 16 |
+
action: WorkerActionIn
|
| 17 |
+
actor: str = "unknown"
|
| 18 |
+
session_id: str = "default"
|
| 19 |
+
service: str = ""
|
| 20 |
+
environment: str = "production"
|
| 21 |
+
provided_evidence: List[str] = Field(default_factory=list)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# ββ Outbound sub-models βββββββββββββββββββββββββββββββββββββββ
|
| 25 |
+
|
| 26 |
+
class WorkerActionOut(BaseModel):
|
| 27 |
+
intent: str
|
| 28 |
+
raw_payload: str
|
| 29 |
+
is_malicious: bool
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class SupervisorDecision(BaseModel):
|
| 33 |
+
action_taken: str # ALLOW | BLOCK | FORK | QUARANTINE
|
| 34 |
+
risk_vector: List[float] = Field(..., min_length=16, max_length=16) # 16-dim risk feature vector
|
| 35 |
+
ambiguity_score: float # [0,1] β how close to 0.5 risk midpoint
|
| 36 |
+
quarantine_steps_remaining: int # 0 if no active hold
|
| 37 |
+
decision: Optional[str] = None
|
| 38 |
+
confidence: Optional[float] = None
|
| 39 |
+
uncertainty: Optional[float] = None
|
| 40 |
+
risk_score: Optional[float] = None
|
| 41 |
+
cumulative_risk_score: Optional[float] = None
|
| 42 |
+
missing_evidence: List[str] = Field(default_factory=list)
|
| 43 |
+
required_evidence: List[str] = Field(default_factory=list)
|
| 44 |
+
explanation: Optional[str] = None
|
| 45 |
+
safe_outcome: Optional[str] = None
|
| 46 |
+
policy_name: Optional[str] = None
|
| 47 |
+
domain: Optional[str] = None
|
| 48 |
+
mitre_tactic: Optional[str] = None
|
| 49 |
+
mitre_technique: Optional[str] = None
|
| 50 |
+
evidence_plan: List[Dict[str, Any]] = Field(default_factory=list)
|
| 51 |
+
structured_safe_outcome: Dict[str, Any] = Field(default_factory=dict)
|
| 52 |
+
decision_trace: Dict[str, Any] = Field(default_factory=dict)
|
| 53 |
+
memory_context: Dict[str, Any] = Field(default_factory=dict)
|
| 54 |
+
cumulative_risk_reason: Optional[str] = None
|
| 55 |
+
risk_indicators: List[str] = Field(default_factory=list)
|
| 56 |
+
safe_indicators: List[str] = Field(default_factory=list)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class EnvironmentState(BaseModel):
|
| 60 |
+
is_shadow_active: bool
|
| 61 |
+
domain_data: Dict[str, Any]
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class MitreInfo(BaseModel):
|
| 65 |
+
tactic: str
|
| 66 |
+
technique_id: str
|
| 67 |
+
technique_name: str
|
| 68 |
+
confidence: float
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
class IncidentReport(BaseModel):
|
| 72 |
+
report_id: str
|
| 73 |
+
timestamp: str
|
| 74 |
+
domain: str
|
| 75 |
+
intent: str
|
| 76 |
+
severity: str
|
| 77 |
+
confidence: float
|
| 78 |
+
mitre: MitreInfo
|
| 79 |
+
blast_radius: Dict[str, Any]
|
| 80 |
+
cloudtrail: List[Dict[str, Any]]
|
| 81 |
+
recommendation: str
|
| 82 |
+
payload_snippet: str
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
class ForensicEvent(BaseModel):
|
| 86 |
+
domain: str
|
| 87 |
+
intent: str
|
| 88 |
+
payload: str
|
| 89 |
+
step: int
|
| 90 |
+
timestamp: str
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
class QuarantineHoldStatus(BaseModel):
|
| 94 |
+
"""Per-domain quarantine hold observable state β sent to frontend every step."""
|
| 95 |
+
active: bool
|
| 96 |
+
steps_remaining: int # 0-3
|
| 97 |
+
context_signals: List[Dict[str, Any]] # signals emitted during hold
|
| 98 |
+
latest_signal: Optional[Dict[str, Any]] = None
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
class DomainQuarantineStatus(BaseModel):
|
| 102 |
+
"""Combines domain-level auto-quarantine + action-level hold."""
|
| 103 |
+
domain_quarantined: bool # auto-quarantine after 3 consecutive hits
|
| 104 |
+
hold_active: bool # QUARANTINE action hold in progress
|
| 105 |
+
hold_steps_remaining: int # 0 if no hold
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
class OutboundMessage(BaseModel):
|
| 109 |
+
domain: str
|
| 110 |
+
worker_action: WorkerActionOut
|
| 111 |
+
supervisor_decision: SupervisorDecision
|
| 112 |
+
environment_state: EnvironmentState
|
| 113 |
+
health_scores: Dict[str, float]
|
| 114 |
+
# quarantine_status: one entry per domain with full observable state
|
| 115 |
+
quarantine_status: Dict[str, Any]
|
| 116 |
+
# quarantine_hold: only populated when decision == QUARANTINE
|
| 117 |
+
quarantine_hold: Optional[QuarantineHoldStatus] = None
|
| 118 |
+
forensic_log: List[Dict[str, Any]] = Field(default_factory=list)
|
| 119 |
+
incident_report: Optional[IncidentReport] = None
|
docs/SUBMISSION_README_DRAFT.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# ShadowOps OpenEnv Submission Draft
|
| 2 |
|
| 3 |
## What ShadowOps Is
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: ShadowOps Guardian
|
| 3 |
+
emoji: π‘οΈ
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: gray
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# π‘οΈ ShadowOps: Predictive Quarantine & Reality Forking for AI Agents
|
| 12 |
+
**Team DuoXCode | Meta PyTorch OpenEnv Hackathon**
|
| 13 |
# ShadowOps OpenEnv Submission Draft
|
| 14 |
|
| 15 |
## What ShadowOps Is
|