wlbs-scan 0.5.0__tar.gz
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.
- wlbs_scan-0.5.0/LICENSE +89 -0
- wlbs_scan-0.5.0/PKG-INFO +436 -0
- wlbs_scan-0.5.0/README.md +409 -0
- wlbs_scan-0.5.0/pyproject.toml +34 -0
- wlbs_scan-0.5.0/setup.cfg +4 -0
- wlbs_scan-0.5.0/setup.py +40 -0
- wlbs_scan-0.5.0/wlbs_scan.egg-info/PKG-INFO +436 -0
- wlbs_scan-0.5.0/wlbs_scan.egg-info/SOURCES.txt +10 -0
- wlbs_scan-0.5.0/wlbs_scan.egg-info/dependency_links.txt +1 -0
- wlbs_scan-0.5.0/wlbs_scan.egg-info/entry_points.txt +2 -0
- wlbs_scan-0.5.0/wlbs_scan.egg-info/top_level.txt +1 -0
- wlbs_scan-0.5.0/wlbs_scan.py +1299 -0
wlbs_scan-0.5.0/LICENSE
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Licensor: Zhongchang Huang (黄中常)
|
|
4
|
+
Licensed Work: wlbs-scan
|
|
5
|
+
The Licensed Work is (c) 2026 Zhongchang Huang (黄中常)
|
|
6
|
+
Additional Use Grant: You may use the Licensed Work in production for
|
|
7
|
+
non-commercial purposes and for internal evaluation,
|
|
8
|
+
research, and educational use free of charge.
|
|
9
|
+
Commercial use in a product or service offered to
|
|
10
|
+
third parties requires a separate commercial license
|
|
11
|
+
from the Licensor.
|
|
12
|
+
Change Date: 2029-01-01
|
|
13
|
+
Change License: Apache License, Version 2.0
|
|
14
|
+
|
|
15
|
+
-----------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
For information about alternative licensing arrangements, contact:
|
|
18
|
+
Zhongchang Huang (黄中常) <val1813@users.noreply.github.com>
|
|
19
|
+
|
|
20
|
+
-----------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
Business Source License 1.1
|
|
23
|
+
|
|
24
|
+
Terms
|
|
25
|
+
|
|
26
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
27
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
28
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
29
|
+
production use.
|
|
30
|
+
|
|
31
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
32
|
+
available distribution of a specific version of the Licensed Work under this
|
|
33
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
34
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
35
|
+
above terminate.
|
|
36
|
+
|
|
37
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
38
|
+
currently in effect as described in this License, you must purchase a
|
|
39
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
40
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
41
|
+
|
|
42
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
43
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
44
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
45
|
+
for each version of the Licensed Work released by Licensor.
|
|
46
|
+
|
|
47
|
+
You must conspicuously display this License on each original or modified copy
|
|
48
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
49
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
50
|
+
License apply to your use of that work.
|
|
51
|
+
|
|
52
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
53
|
+
terminate your rights under this License for the current and all other
|
|
54
|
+
versions of the Licensed Work.
|
|
55
|
+
|
|
56
|
+
This License does not grant you any right in any trademark or logo of
|
|
57
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
58
|
+
Licensor as expressly required by this License).
|
|
59
|
+
|
|
60
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
61
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
62
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
63
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
64
|
+
TITLE.
|
|
65
|
+
|
|
66
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
67
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
68
|
+
as long as you comply with the Covenants of Licensor below.
|
|
69
|
+
|
|
70
|
+
Covenants of Licensor
|
|
71
|
+
|
|
72
|
+
In consideration of the right to use this License's text and the "Business
|
|
73
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to
|
|
74
|
+
all recipients of the licensed work to be provided by Licensor:
|
|
75
|
+
|
|
76
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
77
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
78
|
+
where "compatible" means that software provided under the Change License can
|
|
79
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
80
|
+
later version. Licensor may specify additional Change Licenses without
|
|
81
|
+
limitation.
|
|
82
|
+
|
|
83
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
84
|
+
impose any additional restriction on the right granted in this License, as
|
|
85
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
86
|
+
|
|
87
|
+
3. To specify a Change Date.
|
|
88
|
+
|
|
89
|
+
4. Not to modify this License in any other way.
|
wlbs_scan-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wlbs-scan
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: WLBS Behavior Graph Scanner — static + dynamic curvature analysis for Python/JS codebases
|
|
5
|
+
Home-page: https://github.com/val1813/wlbs-cli
|
|
6
|
+
Author: Zhongchang Huang (黄中常)
|
|
7
|
+
Author-email: valhuang@kaiwucl.com
|
|
8
|
+
License: BSL-1.1
|
|
9
|
+
Project-URL: Homepage, https://github.com/val1813/wlbs-cli
|
|
10
|
+
Project-URL: Issues, https://github.com/val1813/wlbs-cli/issues
|
|
11
|
+
Keywords: static analysis,behavior graph,curvature,world-line,code quality,fault localization,MoE
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: License :: Other/Proprietary License
|
|
16
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
17
|
+
Classifier: Topic :: Software Development :: Testing
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: requires-python
|
|
27
|
+
|
|
28
|
+
# wlbs-scan v0.5
|
|
29
|
+
|
|
30
|
+
**[English](#english) | [中文](#中文)**
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
<a name="english"></a>
|
|
35
|
+
|
|
36
|
+
## English
|
|
37
|
+
|
|
38
|
+
**Static + dynamic behavior graph scanner based on the World-Line Behavior Space (WLBS) framework.**
|
|
39
|
+
|
|
40
|
+
Learns from your failures. Gets smarter over time. Zero dependencies beyond Python 3.8+.
|
|
41
|
+
|
|
42
|
+
[]()
|
|
43
|
+
[](LICENSE)
|
|
44
|
+
[](validation/VALIDATION_RESULTS.md)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### Install
|
|
49
|
+
|
|
50
|
+
**Option 1 — from GitHub (no PyPI needed):**
|
|
51
|
+
```bash
|
|
52
|
+
pip install git+https://github.com/val1813/wlbs-cli.git
|
|
53
|
+
wlbs-scan --help
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Option 2 — clone and install locally:**
|
|
57
|
+
```bash
|
|
58
|
+
git clone https://github.com/val1813/wlbs-cli.git
|
|
59
|
+
cd wlbs-cli
|
|
60
|
+
pip install -e .
|
|
61
|
+
wlbs-scan --help
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Option 3 — run directly without installing:**
|
|
65
|
+
```bash
|
|
66
|
+
python wlbs_scan.py <path>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### Commands
|
|
72
|
+
|
|
73
|
+
| Command | What it does |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `wlbs-scan .` | Scan + show risk map |
|
|
76
|
+
| `wlbs-scan . --record-failure rbac` | Record a test failure (teaches the system) |
|
|
77
|
+
| `wlbs-scan . --record-fix roles` | Record a fix (updates curvature down) |
|
|
78
|
+
| `wlbs-scan . --pytest tests/` | Auto-run pytest + record all results into world-lines |
|
|
79
|
+
| `wlbs-scan . --history` | View what the system has learned |
|
|
80
|
+
| `wlbs-scan . --diff` | Curvature delta since last scan |
|
|
81
|
+
| `wlbs-scan . --suggest` | Actionable fix recommendations for high-risk nodes |
|
|
82
|
+
| `wlbs-scan . --moe` | MoE expert routing map (WLBS-guided activation weights) |
|
|
83
|
+
| `wlbs-scan . --blame` | Git blame on high-curvature nodes (line-range attribution) |
|
|
84
|
+
| `wlbs-scan . --export-html report.html` | Full HTML visualization report |
|
|
85
|
+
| `wlbs-scan . --badges` | README shield badge markdown |
|
|
86
|
+
| `wlbs-scan . --ci --fail-above 0.85` | CI mode — exit 1 if threshold exceeded |
|
|
87
|
+
| `wlbs-scan . --init-hook` | Install as git pre-commit hook |
|
|
88
|
+
| `wlbs-scan . --watch --pytest tests/` | Watch files + auto-rerun tests on change |
|
|
89
|
+
| `wlbs-scan src/ --lang js` | Scan JavaScript / TypeScript projects |
|
|
90
|
+
| `wlbs-scan . --json` | JSON output for CI/CD pipelines |
|
|
91
|
+
| `wlbs-scan . --dist roles rbac` | Behavioral distance between two nodes |
|
|
92
|
+
| `wlbs-scan . --reset` | Clear all learned history |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### How curvature κ is computed
|
|
97
|
+
|
|
98
|
+
Curvature κ(n) ∈ [0, 1] for each node (function / class / module):
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
If world-line history exists (failure_count > 0):
|
|
102
|
+
bonus = 0.40 × history_signal + 0.15 × git_signal
|
|
103
|
+
κ(n) = static_curvature + bonus # additive — failures only raise κ
|
|
104
|
+
Else if git history exists:
|
|
105
|
+
κ(n) = 0.45 × static + 0.55 × git
|
|
106
|
+
Else:
|
|
107
|
+
κ(n) = static_curvature
|
|
108
|
+
|
|
109
|
+
static_curvature = 0.35×(complexity/max_c) + 0.25×(import_count/max_i)
|
|
110
|
+
+ 0.10×(line_count/max_l) + 0.15×(no_exception_handling)
|
|
111
|
+
|
|
112
|
+
history_signal = recent_failure_rate × 0.8 + (failure_count/20) × 0.2
|
|
113
|
+
× discount (0.7 if last event was a fix, else 1.0)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Aporia / Backpropagation** — when a node with `failure_count > 0` reaches κ ≥ 0.5,
|
|
117
|
+
its failure signal propagates upstream along dependency edges with exponential decay:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
Δκ(dep) = κ(seed) × 0.5^depth (paper §3.2: Δκ = α·λ^d)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This allows the system to identify **root-cause modules** that have no direct failures
|
|
124
|
+
but are depended upon by failing nodes.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### Singularity detection
|
|
129
|
+
|
|
130
|
+
A **singularity** is a high-curvature node (κ ≥ 0.55) that:
|
|
131
|
+
- Has at least one caller (`called_by > 0`) or is imported by other modules
|
|
132
|
+
- Has structural complexity > 2
|
|
133
|
+
|
|
134
|
+
Singularities are upstream root-cause candidates — the place to look when a failure
|
|
135
|
+
manifests downstream.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### Validated claims (paper § cross-reference)
|
|
140
|
+
|
|
141
|
+
All claims below are reproduced by running `python validation/run_validation.py`.
|
|
142
|
+
See [`validation/VALIDATION_RESULTS.md`](validation/VALIDATION_RESULTS.md) for the full run log.
|
|
143
|
+
|
|
144
|
+
| Paper Section | Claim | Result | Measured |
|
|
145
|
+
|---|---|---|---|
|
|
146
|
+
| §4 Impl | Graph construction speed | ✅ | avg 95–100 ms (3-file demo project) |
|
|
147
|
+
| §3.1 Def 2 | Behavioral distance d(roles, rbac) = 1 hop | ✅ | d = 1 |
|
|
148
|
+
| §3.2 | rbac κ rises after recording failures | ✅ | 0.820 → 1.000 (+0.180) |
|
|
149
|
+
| §3.2 | Aporia: roles κ rises via backprop (no direct failure) | ✅ | 0.405 → 0.905 (+0.500) |
|
|
150
|
+
| §3.1 Def 4 | Singularity detected after cross-file failures | ✅ | singularities=[rbac] |
|
|
151
|
+
| §3.1 Def 4 | roles identified via backprop (κ > static) | ✅ | κ=0.905, static=0.405 |
|
|
152
|
+
| §3 General | World-line accumulation: κ non-decreasing | ✅ | monotone series confirmed |
|
|
153
|
+
| §4 Impl | --pytest auto-records pass/fail into world-lines | ✅ | 2 events written |
|
|
154
|
+
|
|
155
|
+
> **Reproduce:** `python validation/run_validation.py` — rewrites `VALIDATION_RESULTS.md` with live data.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### Demo project (roles.py → rbac.py)
|
|
160
|
+
|
|
161
|
+
The `demo/` directory mirrors the paper's Figure 1 concrete failure scenario:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
demo/
|
|
165
|
+
roles.py # root-cause module — 'admin' key missing in PERMISSIONS
|
|
166
|
+
rbac.py # downstream — imports roles.get_permissions(), crashes on 'admin'
|
|
167
|
+
tests/
|
|
168
|
+
test_rbac.py # 4 pass / 2 intentional fail (test_admin_access, test_grant_permissions)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Run the demo:
|
|
172
|
+
```bash
|
|
173
|
+
cd demo
|
|
174
|
+
python ../wlbs_scan.py . --pytest tests/
|
|
175
|
+
python ../wlbs_scan.py . --history
|
|
176
|
+
python ../wlbs_scan.py . --dist roles rbac
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### MoE integration
|
|
182
|
+
|
|
183
|
+
`--moe` shows how a Mixture-of-Experts system routes gate decisions using curvature as activation weight:
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
p(expert_n) = κ(n) / Σκ
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
High-curvature nodes activate specialized experts (LoRA adapters in a full system).
|
|
190
|
+
Singularities are targeted first when failure signals propagate upstream.
|
|
191
|
+
|
|
192
|
+
See: *World-Line Behavior Space* (Huang, 2026) · CN 2026103746505 · CN 2026103756225
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
### Memory
|
|
197
|
+
|
|
198
|
+
All history is stored in `.wlbs/world_lines.json` in your project root.
|
|
199
|
+
The file accumulates across sessions — the longer you use wlbs-scan, the more accurate its curvature estimates become.
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
wlbs-scan . --history # see everything it has learned
|
|
203
|
+
wlbs-scan . --reset # start over
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
### Roadmap
|
|
209
|
+
|
|
210
|
+
| Feature | Status |
|
|
211
|
+
|---|---|
|
|
212
|
+
| Python AST graph + curvature | ✅ v0.5 |
|
|
213
|
+
| World-line persistence | ✅ v0.5 |
|
|
214
|
+
| Aporia backpropagation (Δκ = α·λ^d) | ✅ v0.5 |
|
|
215
|
+
| Singularity detection | ✅ v0.5 |
|
|
216
|
+
| --pytest auto-record | ✅ v0.5 |
|
|
217
|
+
| --blame line-range git attribution | ✅ v0.5 |
|
|
218
|
+
| --export-html visualization | ✅ v0.5 |
|
|
219
|
+
| --watch file change detection | ✅ v0.5 |
|
|
220
|
+
| JS/TS support (--lang js) | ✅ v0.5 |
|
|
221
|
+
| CI mode + pre-commit hook | ✅ v0.5 |
|
|
222
|
+
| LLM-guided repair suggestions (--suggest reasoning chain) | 🔲 v0.6 |
|
|
223
|
+
| Cross-repo world-line sharing | 🔲 v0.6 |
|
|
224
|
+
| Java / Go / Rust AST parsers | 🔲 v0.6 |
|
|
225
|
+
| VS Code extension | 🔲 v0.7 |
|
|
226
|
+
| GitHub Actions official action | 🔲 v0.7 |
|
|
227
|
+
| Online dashboard (world-line cloud sync) | 🔲 v0.8 |
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### Theory
|
|
232
|
+
|
|
233
|
+
> *World-Line Behavior Space: A Unified Framework for Continual Learning and Spatial Root-Cause Attribution in AI-Driven Autonomous Systems*
|
|
234
|
+
> Zhongchang Huang, 2026
|
|
235
|
+
> CN Patent Applications 2026103746505 · 2026103756225
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### License
|
|
240
|
+
|
|
241
|
+
**Business Source License 1.1 (BSL 1.1)**
|
|
242
|
+
|
|
243
|
+
- Free for non-commercial use, research, and internal evaluation
|
|
244
|
+
- Commercial use in third-party products/services requires a separate license
|
|
245
|
+
- Automatically converts to **Apache 2.0** on **2029-01-01**
|
|
246
|
+
|
|
247
|
+
See [`LICENSE`](LICENSE) for full terms.
|
|
248
|
+
Patent protection: CN 2026103746505 · CN 2026103756225
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
### Contact / 联系作者
|
|
253
|
+
|
|
254
|
+
**Zhongchang Huang (黄中常)**
|
|
255
|
+
Email: valhuang@kaiwucl.com
|
|
256
|
+
WeChat: val001813
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
<a name="中文"></a>
|
|
262
|
+
|
|
263
|
+
## 中文
|
|
264
|
+
|
|
265
|
+
**基于世界线行为空间(WLBS)框架的静态+动态行为图扫描工具。**
|
|
266
|
+
|
|
267
|
+
从你的失败中学习,越用越准。除 Python 3.8+ 外零依赖。
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
### 安装
|
|
272
|
+
|
|
273
|
+
**方式一 — 直接从 GitHub 安装(无需发布到 PyPI):**
|
|
274
|
+
```bash
|
|
275
|
+
pip install git+https://github.com/val1813/wlbs-cli.git
|
|
276
|
+
wlbs-scan --help
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**方式二 — clone 后本地安装:**
|
|
280
|
+
```bash
|
|
281
|
+
git clone https://github.com/val1813/wlbs-cli.git
|
|
282
|
+
cd wlbs-cli
|
|
283
|
+
pip install -e .
|
|
284
|
+
wlbs-scan --help
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**方式三 — 无需安装,直接运行:**
|
|
288
|
+
```bash
|
|
289
|
+
python wlbs_scan.py <路径>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### 命令一览
|
|
295
|
+
|
|
296
|
+
| 命令 | 功能 |
|
|
297
|
+
|---|---|
|
|
298
|
+
| `wlbs-scan .` | 扫描并显示风险图谱 |
|
|
299
|
+
| `wlbs-scan . --record-failure rbac` | 记录测试失败(训练系统) |
|
|
300
|
+
| `wlbs-scan . --record-fix roles` | 记录修复成功(曲率下调) |
|
|
301
|
+
| `wlbs-scan . --pytest tests/` | 自动运行 pytest 并将结果写入世界线 |
|
|
302
|
+
| `wlbs-scan . --history` | 查看系统已学习的内容 |
|
|
303
|
+
| `wlbs-scan . --diff` | 与上次扫描对比曲率变化 |
|
|
304
|
+
| `wlbs-scan . --suggest` | 高风险节点的修复建议 |
|
|
305
|
+
| `wlbs-scan . --moe` | MoE 专家路由权重图(WLBS 引导) |
|
|
306
|
+
| `wlbs-scan . --blame` | 高曲率节点的 git blame(行级归因) |
|
|
307
|
+
| `wlbs-scan . --export-html report.html` | 导出 HTML 可视化报告 |
|
|
308
|
+
| `wlbs-scan . --badges` | 生成 README 徽章 markdown |
|
|
309
|
+
| `wlbs-scan . --ci --fail-above 0.85` | CI 模式,超阈值退出码非零 |
|
|
310
|
+
| `wlbs-scan . --init-hook` | 安装为 git pre-commit hook |
|
|
311
|
+
| `wlbs-scan . --watch --pytest tests/` | 监听文件变化并自动重跑测试 |
|
|
312
|
+
| `wlbs-scan src/ --lang js` | 扫描 JavaScript / TypeScript 项目 |
|
|
313
|
+
| `wlbs-scan . --json` | JSON 输出,接入 CI/CD 流水线 |
|
|
314
|
+
| `wlbs-scan . --dist roles rbac` | 计算两个节点间的行为距离 |
|
|
315
|
+
| `wlbs-scan . --reset` | 清空所有学习历史 |
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
### 曲率 κ 计算方式
|
|
320
|
+
|
|
321
|
+
每个节点(函数/类/模块)的曲率 κ(n) ∈ [0, 1]:
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
若有世界线历史(failure_count > 0):
|
|
325
|
+
bonus = 0.40 × history_signal + 0.15 × git_signal
|
|
326
|
+
κ(n) = static_curvature + bonus # 加法型:失败只会提升 κ
|
|
327
|
+
若仅有 git 历史:
|
|
328
|
+
κ(n) = 0.45 × static + 0.55 × git
|
|
329
|
+
否则:
|
|
330
|
+
κ(n) = static_curvature
|
|
331
|
+
|
|
332
|
+
static_curvature = 0.35×(复杂度/最大) + 0.25×(被引入数/最大)
|
|
333
|
+
+ 0.10×(行数/最大) + 0.15×(无异常处理)
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**Aporia / 曲率反向传播** — 当 `failure_count > 0` 且 κ ≥ 0.5 的节点存在时,
|
|
337
|
+
失败信号沿依赖边向上游传播,按指数衰减:
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
Δκ(dep) = κ(seed) × 0.5^depth (论文 §3.2: Δκ = α·λ^d)
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
这让系统能识别**没有直接失败记录、但被失败节点依赖的根因模块**。
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
### 验证数据(论文声明对照)
|
|
348
|
+
|
|
349
|
+
所有数据均通过 `python validation/run_validation.py` 真实测量,
|
|
350
|
+
完整记录见 [`validation/VALIDATION_RESULTS.md`](validation/VALIDATION_RESULTS.md)。
|
|
351
|
+
|
|
352
|
+
| 论文章节 | 声明 | 结果 | 实测数据 |
|
|
353
|
+
|---|---|---|---|
|
|
354
|
+
| §4 实现 | 行为图构建速度 | ✅ | avg 95–100 ms(3 文件 demo 项目) |
|
|
355
|
+
| §3.1 定义 2 | 行为距离 d(roles, rbac) = 1 跳 | ✅ | d = 1 |
|
|
356
|
+
| §3.2 | rbac κ 在记录失败后上升 | ✅ | 0.820 → 1.000(+0.180) |
|
|
357
|
+
| §3.2 | Aporia:roles κ 经反向传播上升(无直接失败) | ✅ | 0.405 → 0.905(+0.500) |
|
|
358
|
+
| §3.1 定义 4 | 跨文件失败后检测到奇点 | ✅ | singularities=[rbac] |
|
|
359
|
+
| §3.1 定义 4 | roles 被反向传播识别(κ > static) | ✅ | κ=0.905, static=0.405 |
|
|
360
|
+
| §3 总体 | 世界线累积:κ 单调不递减 | ✅ | 单调序列已验证 |
|
|
361
|
+
| §4 实现 | --pytest 自动记录通过/失败到世界线 | ✅ | 2 个事件已写入 |
|
|
362
|
+
|
|
363
|
+
> **复现方法:** `python validation/run_validation.py`
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
### Demo 项目(roles.py → rbac.py)
|
|
368
|
+
|
|
369
|
+
`demo/` 目录复现了论文图 1 的具体失败场景:
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
demo/
|
|
373
|
+
roles.py # 根因模块 — PERMISSIONS 中缺少 'admin' 键
|
|
374
|
+
rbac.py # 下游模块 — 导入 roles.get_permissions(),访问 'admin' 时崩溃
|
|
375
|
+
tests/
|
|
376
|
+
test_rbac.py # 4 通过 / 2 故意失败
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
cd demo
|
|
381
|
+
python ../wlbs_scan.py . --pytest tests/
|
|
382
|
+
python ../wlbs_scan.py . --history
|
|
383
|
+
python ../wlbs_scan.py . --dist roles rbac
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
### 路线图
|
|
389
|
+
|
|
390
|
+
| 功能 | 状态 |
|
|
391
|
+
|---|---|
|
|
392
|
+
| Python AST 图 + 曲率计算 | ✅ v0.5 |
|
|
393
|
+
| 世界线持久化 | ✅ v0.5 |
|
|
394
|
+
| Aporia 反向传播(Δκ = α·λ^d) | ✅ v0.5 |
|
|
395
|
+
| 奇点(Singularity)检测 | ✅ v0.5 |
|
|
396
|
+
| --pytest 自动记录 | ✅ v0.5 |
|
|
397
|
+
| --blame 行级 git 归因 | ✅ v0.5 |
|
|
398
|
+
| --export-html 可视化报告 | ✅ v0.5 |
|
|
399
|
+
| --watch 文件变化监听 | ✅ v0.5 |
|
|
400
|
+
| JS/TS 支持(--lang js) | ✅ v0.5 |
|
|
401
|
+
| CI 模式 + pre-commit hook | ✅ v0.5 |
|
|
402
|
+
| LLM 引导的修复建议(推理链) | 🔲 v0.6 |
|
|
403
|
+
| 跨仓库世界线共享 | 🔲 v0.6 |
|
|
404
|
+
| Java / Go / Rust AST 解析器 | 🔲 v0.6 |
|
|
405
|
+
| VS Code 扩展 | 🔲 v0.7 |
|
|
406
|
+
| GitHub Actions 官方 Action | 🔲 v0.7 |
|
|
407
|
+
| 在线 Dashboard(世界线云同步) | 🔲 v0.8 |
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
### 理论基础
|
|
412
|
+
|
|
413
|
+
> *世界线行为空间:AI 驱动自主系统中持续学习与空间根因归因的统一框架*
|
|
414
|
+
> 黄中常,2026
|
|
415
|
+
> 中国专利申请 2026103746505 · 2026103756225
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
### 许可证
|
|
420
|
+
|
|
421
|
+
**Business Source License 1.1 (BSL 1.1)**
|
|
422
|
+
|
|
423
|
+
- 非商业用途、科研、内部评估免费使用
|
|
424
|
+
- 面向第三方的商业产品/服务需向作者申请商业授权
|
|
425
|
+
- **2029-01-01** 自动转为 **Apache 2.0**
|
|
426
|
+
|
|
427
|
+
完整条款见 [`LICENSE`](LICENSE)。
|
|
428
|
+
WLBS 方法论受专利保护:CN 2026103746505 · CN 2026103756225
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
### 联系作者
|
|
433
|
+
|
|
434
|
+
**黄中常 (Zhongchang Huang)**
|
|
435
|
+
邮箱:valhuang@kaiwucl.com
|
|
436
|
+
微信:val001813
|