Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
rudevolution/src/types.rs at main · ruvnet/rudevolution · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
ruvnet
rudevolution
Repository navigation
Code
Issues
2
(2)
Pull requests
2
(2)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
rudevolution
/
src
/
types.rs
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
199 lines (184 loc) · 6.4 KB
main
Breadcrumbs
rudevolution
/
src
/
types.rs
Copy path
Top
File metadata and controls
Code
Blame
199 lines (184 loc) · 6.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//! Core domain types for the decompiler.
use
std
::
path
::
PathBuf
;
use
serde
::
{
Deserialize
,
Serialize
}
;
/// The kind of a top-level declaration.
#
[
derive
(
Debug
,
Clone
,
Copy
,
PartialEq
,
Eq
,
Hash
,
Serialize
,
Deserialize
)
]
pub
enum
DeclKind
{
/// `var x = ...`
Var
,
/// `let x = ...`
Let
,
/// `const x = ...`
Const
,
/// `function x(...) { ... }`
Function
,
/// `class x { ... }`
Class
,
}
impl
std
::
fmt
::
Display
for
DeclKind
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'
_
>
)
-> std
::
fmt
::
Result
{
match
self
{
Self
::
Var
=>
write
!
(
f
,
"var"
)
,
Self
::
Let
=>
write
!
(
f
,
"let"
)
,
Self
::
Const
=>
write
!
(
f
,
"const"
)
,
Self
::
Function
=>
write
!
(
f
,
"function"
)
,
Self
::
Class
=>
write
!
(
f
,
"class"
)
,
}
}
}
/// A top-level declaration extracted from the minified bundle.
#
[
derive
(
Debug
,
Clone
,
Serialize
,
Deserialize
)
]
pub
struct
Declaration
{
/// The minified name (e.g., `a`, `b`, `_0x1a2b`).
pub
name
:
String
,
/// Declaration kind.
pub
kind
:
DeclKind
,
/// Byte range `(start, end)` in the original bundle.
pub
byte_range
:
(
usize
,
usize
)
,
/// String literals found within this declaration's body.
pub
string_literals
:
Vec
<
String
>
,
/// Property names accessed (e.g., `.name`, `.permission`).
pub
property_accesses
:
Vec
<
String
>
,
/// Names of other declarations referenced by this one.
pub
references
:
Vec
<
String
>
,
}
/// A reconstructed module extracted from the bundle.
#
[
derive
(
Debug
,
Clone
,
Serialize
,
Deserialize
)
]
pub
struct
Module
{
/// Inferred module name.
pub
name
:
String
,
/// Index of this module in the decompilation output.
pub
index
:
usize
,
/// Declarations belonging to this module.
pub
declarations
:
Vec
<
Declaration
>
,
/// Beautified source code for this module.
pub
source
:
String
,
/// Byte range in the original bundle that this module covers.
pub
byte_range
:
(
usize
,
usize
)
,
}
/// An inferred name mapping from minified to reconstructed.
#
[
derive
(
Debug
,
Clone
,
Serialize
,
Deserialize
)
]
pub
struct
InferredName
{
/// The original minified name.
pub
original
:
String
,
/// The inferred human-readable name.
pub
inferred
:
String
,
/// Confidence score from 0.0 (guess) to 1.0 (certain).
pub
confidence
:
f64
,
/// Evidence strings explaining why this name was inferred.
pub
evidence
:
Vec
<
String
>
,
}
/// Confidence thresholds for name inference.
#
[
derive
(
Debug
,
Clone
,
Copy
)
]
pub
enum
Confidence
{
/// Direct string match, confidence > 0.9.
High
,
/// Contextual inference, confidence 0.6 -- 0.9.
Medium
,
/// Structural guess only, confidence < 0.6.
Low
,
}
impl
Confidence
{
/// Returns the minimum confidence value for this level.
pub
fn
min_value
(
self
)
->
f64
{
match
self
{
Self
::
High
=>
0.9
,
Self
::
Medium
=>
0.6
,
Self
::
Low
=>
0.0
,
}
}
}
/// A node in the decompiled folder tree.
///
/// The tree structure emerges from Louvain community hierarchy:
/// - Level 0 (leaves): individual declarations assigned to modules
/// - Level 1 (folders): modules grouped by first Louvain pass
/// - Level 2+ (subfolders): recursive aggregation of large communities
#
[
derive
(
Debug
,
Clone
,
Serialize
,
Deserialize
)
]
pub
struct
ModuleTree
{
/// Folder name (inferred from graph context, not hardcoded).
pub
name
:
String
,
/// Full path like "tools/mcp".
pub
path
:
String
,
/// Leaf modules in this folder.
pub
modules
:
Vec
<
Module
>
,
/// Subfolders.
pub
children
:
Vec
<
ModuleTree
>
,
/// Depth in the tree (0 = root).
pub
depth
:
usize
,
}
/// The full result of a decompilation run.
#
[
derive
(
Debug
,
Clone
,
Serialize
,
Deserialize
)
]
pub
struct
DecompileResult
{
/// Reconstructed modules.
pub
modules
:
Vec
<
Module
>
,
/// Hierarchical module tree (graph-derived folder structure).
pub
module_tree
:
Option
<
ModuleTree
>
,
/// All inferred name mappings.
pub
inferred_names
:
Vec
<
InferredName
>
,
/// Source maps (one JSON string per module).
pub
source_maps
:
Vec
<
String
>
,
/// Witness chain for cryptographic provenance.
pub
witness
:
WitnessChainData
,
}
/// Serializable witness chain data.
#
[
derive
(
Debug
,
Clone
,
Serialize
,
Deserialize
)
]
pub
struct
WitnessChainData
{
/// Hex-encoded SHA3-256 hash of the original bundle.
pub
source_hash
:
String
,
/// Per-module witness entries.
pub
module_witnesses
:
Vec
<
ModuleWitnessData
>
,
/// Hex-encoded Merkle root of all module hashes.
pub
chain_root
:
String
,
}
/// Per-module witness data.
#
[
derive
(
Debug
,
Clone
,
Serialize
,
Deserialize
)
]
pub
struct
ModuleWitnessData
{
/// Module name.
pub
module_name
:
String
,
/// Byte range in the original bundle.
pub
byte_range
:
(
usize
,
usize
)
,
/// Hex-encoded SHA3-256 hash of the module content.
pub
content_hash
:
String
,
/// Hex-encoded SHA3-256 hash of the inferred names.
pub
inferred_names_hash
:
String
,
}
/// Configuration for the decompiler pipeline.
#
[
derive
(
Debug
,
Clone
)
]
pub
struct
DecompileConfig
{
/// Target number of modules to reconstruct. If `None`, auto-detect.
pub
target_modules
:
Option
<
usize
>
,
/// Minimum confidence threshold for including inferred names.
pub
min_confidence
:
f64
,
/// Whether to generate source maps.
pub
generate_source_maps
:
bool
,
/// Whether to generate witness chains.
pub
generate_witness
:
bool
,
/// The filename to use in source map output.
pub
output_filename
:
String
,
/// Path to trained deobfuscation model (GGUF or RVF).
/// When set and the `neural` feature is enabled, the decompiler will
/// attempt neural name inference before falling back to pattern-based.
pub
model_path
:
Option
<
PathBuf
>
,
/// Generate hierarchical folder structure from graph (default: true).
pub
hierarchical_output
:
Option
<
bool
>
,
/// Maximum folder depth (default: 3).
pub
max_depth
:
Option
<
usize
>
,
/// Minimum modules per folder to create subfolder (default: 3).
pub
min_folder_size
:
Option
<
usize
>
,
}
impl
Default
for
DecompileConfig
{
fn
default
(
)
->
Self
{
Self
{
target_modules
:
None
,
min_confidence
:
0.0
,
generate_source_maps
:
true
,
generate_witness
:
true
,
output_filename
:
"bundle.js"
.
to_string
(
)
,
model_path
:
None
,
hierarchical_output
:
Some
(
true
)
,
max_depth
:
Some
(
3
)
,
min_folder_size
:
Some
(
3
)
,
}
}
}
You can’t perform that action at this time.