File size: 3,042 Bytes
ad80727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74f7d41
ad80727
74f7d41
ad80727
74f7d41
 
 
 
 
 
 
 
 
 
ad80727
74f7d41
ad80727
74f7d41
ad80727
 
74f7d41
 
 
 
ad80727
 
74f7d41
 
 
 
 
 
 
ad80727
 
74f7d41
 
 
 
 
 
 
 
 
 
 
ad80727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74f7d41
 
 
ad80727
 
 
 
 
74f7d41
ad80727
74f7d41
 
ad80727
74f7d41
ad80727
 
 
 
 
 
 
 
 
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
---
license: other
library_name: scikit-learn
pipeline_tag: tabular-classification
tags:
  - cybersecurity
  - gatekeeper
  - decision-tree
  - scikit-learn
  - joblib
---

# Agent 3 — Verdict Gatekeeper (Decision Tree)

Decision tree that turns two agent scores into a final verdict using a
consensus + fail-safe policy. Part of a three-agent DevSecOps auditor
(metrics → transformer → gatekeeper).

## Model details

| Field | Value |
|---|---|
| Version | 1.0.0 (initial release) |
| Artifact | `model.joblib` (bundle: `model`, `feature_cols`, `classes`, `policy`, `source_thresholds`) |
| Task | 3-class tabular classification |
| Classes | `FAIL`, `PASS`, `REVIEW` |
| Own threshold | None — uses the upstream agent thresholds |
| Upstream thresholds | Agent 1 **0.3183**, Agent 2 **0.45** |
| Training data | Synthetic policy grid, seed 42 |
| Dataset version | Generator v1 — 45 ratios × 45 ratios × 4 quadrants = 8,100 rows |

`metadata.json` mirrors the policy, features, grid, and thresholds.

## Input features

Four numeric features, **in this exact order**:

```
1. a1_high_risk    # 1.0 if agent1_score >= 0.3183
2. a2_vulnerable   # 1.0 if agent2_score >= 0.45
3. a1_risk_ratio   # agent1_score / 0.3183
4. a2_risk_ratio   # agent2_score / 0.45
```

## Preprocessing

- Compute the two flags with the upstream thresholds above.
- Compute the two ratios as `score / threshold` (1.0 = exactly at the boundary).
- Keep the column order shown above; it must match `b["feature_cols"]`.
- On any error, missing value, or invalid score, output `REVIEW` directly.

## Output

Raw: `predict_proba(x)` returns probabilities for `["FAIL", "PASS", "REVIEW"]`
(the bundle's `classes` order). Take `argmax` for the verdict and `max` for
confidence.

Reference wrapper output:

```json
{"verdict": "FAIL", "confidence": 1.0, "status": "ok", "reason": "both agents flagged risk"}
```

`confidence` is the tree's class probability, **not** calibrated.

## Policy

| Agent 1 | Agent 2 | Verdict |
|---|---|---|
| low risk | not vulnerable | `PASS` |
| high risk | vulnerable | `FAIL` |
| high risk | not vulnerable | `REVIEW` |
| low risk | vulnerable | `REVIEW` |
| any error / missing / invalid input | | `REVIEW` |

The tree is trained on a synthetic grid labelled by this policy, so it encodes
the policy rather than learning from ground truth. The reference wrapper adds a
post-check that forces `REVIEW` on any tree/policy mismatch — keep it if you
deploy this model.

Note: the saved `source_thresholds` fallback still lists Agent 2 as `0.51` from
an earlier run. Pass the current thresholds explicitly (`0.3183` / `0.45`).

## Usage

```python
import joblib

b = joblib.load("model.joblib")

a1_high = a1_score >= 0.3183
a2_high = a2_score >= 0.45
x = [[float(a1_high), float(a2_high),
      a1_score / 0.3183, a2_score / 0.45]]

proba = b["model"].predict_proba(x)[0]
verdict = b["classes"][int(proba.argmax())]
confidence = float(proba.max())
```

## License

Not specified. Update the `license` field before publishing.