File size: 1,591 Bytes
61da913
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Architecture

## 分层

- Domain
  - `domain/model.py`
  - `domain/methods.py`
  - `domain/consistency.py`
  - `domain/invariants.py`
  - `src/rlclean/repair/` (detector/ddpm/bandit)
- Application
  - `src/rlclean/pipeline/pipeline_service.py`
  - `src/rlclean/pipeline/cleaner.py`
- Infrastructure
  - `src/rlclean/utils/executor.py`
  - `src/rlclean/utils/registry.py`
- Interface
  - `src/rlclean/cli/main.py`

## 设计意图

- Domain 不依赖脚本细节,只定义方法语义、约束与规则。
- Application 只编排用例,不关心底层命令执行实现。
- Infrastructure 只处理执行、路径、日志落盘。
- Interface 只负责输入配置并触发应用服务。

## 编排模型

- PipelineService 负责阶段顺序:
  - build_dataset
  - detect
  - filter
  - verify_alignment
  - run_cleaners
  - evaluate

- 方法策略:
  - DecoupledDetectorStrategy
  - DDPMCleanerStrategy
  - BanditCleanerStrategy

三者通过统一接口接入 orchestrator,可串行或并行。

## 产物规范

每个 run 按噪声类型独立归档:

```text
runs/<run_name>/<noise_type>/
├── configs/
├── logs/
├── scores/
├── indices/
├── datasets/
├── models/
│   ├── ddpm/
│   └── bandit/
└── eval/
```

## 一致性防线

`domain/consistency.py` + `domain/invariants.py` 对以下关键条件做强校验:

- clean/dirty 分区互斥且覆盖评估核心区间
- 索引不越界
- `pred_mask_s/a/r` 长度与全量 transition 对齐

不满足即中断流程,避免错误数据进入清洗阶段。