vantage-core 0.1.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.
- vantage_core-0.1.0/LICENSE +21 -0
- vantage_core-0.1.0/PKG-INFO +175 -0
- vantage_core-0.1.0/README.md +140 -0
- vantage_core-0.1.0/pyproject.toml +60 -0
- vantage_core-0.1.0/setup.cfg +4 -0
- vantage_core-0.1.0/tests/test_contract_and_runner.py +132 -0
- vantage_core-0.1.0/tests/test_decision.py +145 -0
- vantage_core-0.1.0/vantage_core/__init__.py +20 -0
- vantage_core-0.1.0/vantage_core/__main__.py +6 -0
- vantage_core-0.1.0/vantage_core/cli.py +255 -0
- vantage_core-0.1.0/vantage_core/contract.py +261 -0
- vantage_core-0.1.0/vantage_core/cost.py +77 -0
- vantage_core-0.1.0/vantage_core/data/model_rates_slim.json +9 -0
- vantage_core-0.1.0/vantage_core/decision.py +290 -0
- vantage_core-0.1.0/vantage_core/fixtures/de_sql_slow_query.sql +13 -0
- vantage_core-0.1.0/vantage_core/library/__init__.py +81 -0
- vantage_core-0.1.0/vantage_core/llm_openrouter.py +126 -0
- vantage_core-0.1.0/vantage_core/monorepo_run.py +181 -0
- vantage_core-0.1.0/vantage_core/py.typed +0 -0
- vantage_core-0.1.0/vantage_core/run_store.py +43 -0
- vantage_core-0.1.0/vantage_core/runner.py +132 -0
- vantage_core-0.1.0/vantage_core/schemas/decision_object.v1.json +117 -0
- vantage_core-0.1.0/vantage_core/scorers/__init__.py +20 -0
- vantage_core-0.1.0/vantage_core/scorers/hard_checks.py +98 -0
- vantage_core-0.1.0/vantage_core/scorers/sql_optimization.py +150 -0
- vantage_core-0.1.0/vantage_core/task_runner.py +124 -0
- vantage_core-0.1.0/vantage_core/trust.py +109 -0
- vantage_core-0.1.0/vantage_core.egg-info/PKG-INFO +175 -0
- vantage_core-0.1.0/vantage_core.egg-info/SOURCES.txt +31 -0
- vantage_core-0.1.0/vantage_core.egg-info/dependency_links.txt +1 -0
- vantage_core-0.1.0/vantage_core.egg-info/entry_points.txt +2 -0
- vantage_core-0.1.0/vantage_core.egg-info/requires.txt +13 -0
- vantage_core-0.1.0/vantage_core.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vantage AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vantage-core
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: RuntimeAI check-ride CLI — portable decision artifact for agent release gates
|
|
5
|
+
Author-email: Vantage AI <hello@vantageai.cc>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://www.vantageai.cc/runtimeai/method/cicd
|
|
8
|
+
Project-URL: Documentation, https://www.vantageai.cc/runtimeai/method/cicd
|
|
9
|
+
Project-URL: Repository, https://github.com/simonbright/vantage
|
|
10
|
+
Project-URL: Issues, https://github.com/simonbright/vantage/issues
|
|
11
|
+
Keywords: runtimeai,vantage,agent-eval,ci,check-ride
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: openai>=1.40.0
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Requires-Dist: python-dotenv>=1.0
|
|
26
|
+
Provides-Extra: run
|
|
27
|
+
Requires-Dist: openai>=1.40.0; extra == "run"
|
|
28
|
+
Requires-Dist: pyyaml>=6.0; extra == "run"
|
|
29
|
+
Requires-Dist: python-dotenv>=1.0; extra == "run"
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
32
|
+
Requires-Dist: build; extra == "dev"
|
|
33
|
+
Requires-Dist: twine; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# vantage-core
|
|
37
|
+
|
|
38
|
+
Standalone RuntimeAI check-ride CLI. Author a local contract, run against
|
|
39
|
+
OpenRouter, get a portable **`runtimeai.decision/v1`** artifact — **no monorepo
|
|
40
|
+
`server/` required**.
|
|
41
|
+
|
|
42
|
+
Partner authoring: [`marketing/growth/AUTHORING_CHECKLIST.md`](../marketing/growth/AUTHORING_CHECKLIST.md)
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
**When PyPI is live:**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install vantage-core
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Until then (clone):**
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install -e ./vantage-core
|
|
56
|
+
# or: ./scripts/install_vantage_core_local.sh
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Requires `OPENROUTER_API_KEY`.
|
|
60
|
+
|
|
61
|
+
## Stranger path (60 seconds)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
export OPENROUTER_API_KEY=sk-or-...
|
|
65
|
+
vantage-core run --scenario de_sql_optimization_v1 \
|
|
66
|
+
--model amazon/nova-micro-v1 --fail-under 7.0 --json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or author a local contract (see checklist):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
vantage-core validate examples/contracts/custom_policy_refuse.yaml
|
|
73
|
+
vantage-core run --contract examples/contracts/custom_policy_refuse.yaml --json
|
|
74
|
+
echo $? # 0 iff pass_gate.passed
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Contract format (`runtimeai.contract/v1`)
|
|
78
|
+
|
|
79
|
+
**Mode A — library replay** (reuse a bundled scorer + optional your fixture):
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
schema: runtimeai.contract/v1
|
|
83
|
+
id: my_team.sql_path_v1
|
|
84
|
+
mode: library_replay
|
|
85
|
+
fail_under: 7.0
|
|
86
|
+
turns: 1
|
|
87
|
+
library:
|
|
88
|
+
scenario_id: de_sql_optimization_v1
|
|
89
|
+
fixture: |
|
|
90
|
+
SELECT * FROM orders o, order_items oi WHERE ...
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Mode B — custom** (your system + opening + hard checks):
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
schema: runtimeai.contract/v1
|
|
97
|
+
id: my_team.policy_refuse_v1
|
|
98
|
+
mode: custom
|
|
99
|
+
agent:
|
|
100
|
+
system: |
|
|
101
|
+
You are a policy agent…
|
|
102
|
+
opening: |
|
|
103
|
+
User: …
|
|
104
|
+
scorer:
|
|
105
|
+
kind: hard_checks
|
|
106
|
+
checks:
|
|
107
|
+
- id: refuses
|
|
108
|
+
any_of: ["cannot", "refuse"]
|
|
109
|
+
points: 5
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
See `examples/contracts/`.
|
|
113
|
+
|
|
114
|
+
## Decision artifact
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
vantage-core schema
|
|
118
|
+
vantage-core validate scorecard.json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
| Block | Contents |
|
|
122
|
+
|-------|----------|
|
|
123
|
+
| `contract` | scenario id + content SHA, model, turns, fail_under |
|
|
124
|
+
| `scorecard` | score `/10`, rubric, **`pass_gate`** (score + trust + closure) |
|
|
125
|
+
| `usd` | `est_eval` |
|
|
126
|
+
| `exit` | `0` iff `pass_gate.passed` |
|
|
127
|
+
| `integrity` | SHA-256 of the payload |
|
|
128
|
+
|
|
129
|
+
## Bundled library
|
|
130
|
+
|
|
131
|
+
| Id | What |
|
|
132
|
+
|----|------|
|
|
133
|
+
| `de_sql_optimization_v1` | Slow Snowflake query → rewrite + heuristic rubric |
|
|
134
|
+
|
|
135
|
+
## Publish (maintainers)
|
|
136
|
+
|
|
137
|
+
**Preferred — GitHub trusted publishing**
|
|
138
|
+
|
|
139
|
+
1. On PyPI: create project `vantage-core` (or claim name) → **Publishing** → GitHub
|
|
140
|
+
- Repository: this monorepo
|
|
141
|
+
- Workflow: `publish-vantage-core.yml`
|
|
142
|
+
- Environment: `pypi` (match the Actions environment)
|
|
143
|
+
2. Bump `version` in `pyproject.toml`
|
|
144
|
+
3. Tag and release:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
git tag vantage-core-v0.1.0
|
|
148
|
+
git push origin vantage-core-v0.1.0
|
|
149
|
+
# Create a GitHub Release for that tag → workflow publishes
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Or **Actions → Publish vantage-core to PyPI → Run workflow** with `confirm=publish`.
|
|
153
|
+
|
|
154
|
+
**Manual / token fallback**
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
cd vantage-core
|
|
158
|
+
./scripts/publish-pypi.sh --check # build + twine check only
|
|
159
|
+
export TWINE_USERNAME=__token__
|
|
160
|
+
export TWINE_PASSWORD=pypi-…
|
|
161
|
+
./scripts/publish-pypi.sh
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Dev monorepo parity
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
VANTAGE_USE_MONOREPO=1 vantage-core run --scenario de_sql_optimization_v1 …
|
|
168
|
+
# or: vantage-core run --monorepo --scenario …
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Related
|
|
172
|
+
|
|
173
|
+
- Product page: https://www.vantageai.cc/runtimeai/method/cicd
|
|
174
|
+
- IDE package: `pip install runtimeai-ide`
|
|
175
|
+
- Authoring checklist: `marketing/growth/AUTHORING_CHECKLIST.md`
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# vantage-core
|
|
2
|
+
|
|
3
|
+
Standalone RuntimeAI check-ride CLI. Author a local contract, run against
|
|
4
|
+
OpenRouter, get a portable **`runtimeai.decision/v1`** artifact — **no monorepo
|
|
5
|
+
`server/` required**.
|
|
6
|
+
|
|
7
|
+
Partner authoring: [`marketing/growth/AUTHORING_CHECKLIST.md`](../marketing/growth/AUTHORING_CHECKLIST.md)
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
**When PyPI is live:**
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install vantage-core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Until then (clone):**
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install -e ./vantage-core
|
|
21
|
+
# or: ./scripts/install_vantage_core_local.sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Requires `OPENROUTER_API_KEY`.
|
|
25
|
+
|
|
26
|
+
## Stranger path (60 seconds)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
export OPENROUTER_API_KEY=sk-or-...
|
|
30
|
+
vantage-core run --scenario de_sql_optimization_v1 \
|
|
31
|
+
--model amazon/nova-micro-v1 --fail-under 7.0 --json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or author a local contract (see checklist):
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
vantage-core validate examples/contracts/custom_policy_refuse.yaml
|
|
38
|
+
vantage-core run --contract examples/contracts/custom_policy_refuse.yaml --json
|
|
39
|
+
echo $? # 0 iff pass_gate.passed
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Contract format (`runtimeai.contract/v1`)
|
|
43
|
+
|
|
44
|
+
**Mode A — library replay** (reuse a bundled scorer + optional your fixture):
|
|
45
|
+
|
|
46
|
+
```yaml
|
|
47
|
+
schema: runtimeai.contract/v1
|
|
48
|
+
id: my_team.sql_path_v1
|
|
49
|
+
mode: library_replay
|
|
50
|
+
fail_under: 7.0
|
|
51
|
+
turns: 1
|
|
52
|
+
library:
|
|
53
|
+
scenario_id: de_sql_optimization_v1
|
|
54
|
+
fixture: |
|
|
55
|
+
SELECT * FROM orders o, order_items oi WHERE ...
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Mode B — custom** (your system + opening + hard checks):
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
schema: runtimeai.contract/v1
|
|
62
|
+
id: my_team.policy_refuse_v1
|
|
63
|
+
mode: custom
|
|
64
|
+
agent:
|
|
65
|
+
system: |
|
|
66
|
+
You are a policy agent…
|
|
67
|
+
opening: |
|
|
68
|
+
User: …
|
|
69
|
+
scorer:
|
|
70
|
+
kind: hard_checks
|
|
71
|
+
checks:
|
|
72
|
+
- id: refuses
|
|
73
|
+
any_of: ["cannot", "refuse"]
|
|
74
|
+
points: 5
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
See `examples/contracts/`.
|
|
78
|
+
|
|
79
|
+
## Decision artifact
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
vantage-core schema
|
|
83
|
+
vantage-core validate scorecard.json
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| Block | Contents |
|
|
87
|
+
|-------|----------|
|
|
88
|
+
| `contract` | scenario id + content SHA, model, turns, fail_under |
|
|
89
|
+
| `scorecard` | score `/10`, rubric, **`pass_gate`** (score + trust + closure) |
|
|
90
|
+
| `usd` | `est_eval` |
|
|
91
|
+
| `exit` | `0` iff `pass_gate.passed` |
|
|
92
|
+
| `integrity` | SHA-256 of the payload |
|
|
93
|
+
|
|
94
|
+
## Bundled library
|
|
95
|
+
|
|
96
|
+
| Id | What |
|
|
97
|
+
|----|------|
|
|
98
|
+
| `de_sql_optimization_v1` | Slow Snowflake query → rewrite + heuristic rubric |
|
|
99
|
+
|
|
100
|
+
## Publish (maintainers)
|
|
101
|
+
|
|
102
|
+
**Preferred — GitHub trusted publishing**
|
|
103
|
+
|
|
104
|
+
1. On PyPI: create project `vantage-core` (or claim name) → **Publishing** → GitHub
|
|
105
|
+
- Repository: this monorepo
|
|
106
|
+
- Workflow: `publish-vantage-core.yml`
|
|
107
|
+
- Environment: `pypi` (match the Actions environment)
|
|
108
|
+
2. Bump `version` in `pyproject.toml`
|
|
109
|
+
3. Tag and release:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
git tag vantage-core-v0.1.0
|
|
113
|
+
git push origin vantage-core-v0.1.0
|
|
114
|
+
# Create a GitHub Release for that tag → workflow publishes
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Or **Actions → Publish vantage-core to PyPI → Run workflow** with `confirm=publish`.
|
|
118
|
+
|
|
119
|
+
**Manual / token fallback**
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
cd vantage-core
|
|
123
|
+
./scripts/publish-pypi.sh --check # build + twine check only
|
|
124
|
+
export TWINE_USERNAME=__token__
|
|
125
|
+
export TWINE_PASSWORD=pypi-…
|
|
126
|
+
./scripts/publish-pypi.sh
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Dev monorepo parity
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
VANTAGE_USE_MONOREPO=1 vantage-core run --scenario de_sql_optimization_v1 …
|
|
133
|
+
# or: vantage-core run --monorepo --scenario …
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Related
|
|
137
|
+
|
|
138
|
+
- Product page: https://www.vantageai.cc/runtimeai/method/cicd
|
|
139
|
+
- IDE package: `pip install runtimeai-ide`
|
|
140
|
+
- Authoring checklist: `marketing/growth/AUTHORING_CHECKLIST.md`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vantage-core"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "RuntimeAI check-ride CLI — portable decision artifact for agent release gates"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Vantage AI", email = "hello@vantageai.cc" }]
|
|
14
|
+
keywords = ["runtimeai", "vantage", "agent-eval", "ci", "check-ride"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
24
|
+
]
|
|
25
|
+
# Default install is runnable (PyPI stranger path).
|
|
26
|
+
dependencies = [
|
|
27
|
+
"openai>=1.40.0",
|
|
28
|
+
"pyyaml>=6.0",
|
|
29
|
+
"python-dotenv>=1.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
# Alias kept for docs that say pip install "vantage-core[run]"
|
|
34
|
+
run = ["openai>=1.40.0", "pyyaml>=6.0", "python-dotenv>=1.0"]
|
|
35
|
+
dev = ["pytest>=8.0", "build", "twine"]
|
|
36
|
+
|
|
37
|
+
[project.scripts]
|
|
38
|
+
vantage-core = "vantage_core.cli:cli_entry"
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://www.vantageai.cc/runtimeai/method/cicd"
|
|
42
|
+
Documentation = "https://www.vantageai.cc/runtimeai/method/cicd"
|
|
43
|
+
Repository = "https://github.com/simonbright/vantage"
|
|
44
|
+
Issues = "https://github.com/simonbright/vantage/issues"
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.packages.find]
|
|
47
|
+
where = ["."]
|
|
48
|
+
include = ["vantage_core*"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.package-data]
|
|
51
|
+
vantage_core = [
|
|
52
|
+
"py.typed",
|
|
53
|
+
"schemas/*.json",
|
|
54
|
+
"fixtures/*",
|
|
55
|
+
"data/*.json",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
testpaths = ["tests"]
|
|
60
|
+
pythonpath = ["."]
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Contract load + offline scoring + mocked standalone runner."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from vantage_core.contract import CONTRACT_SCHEMA, HardCheck, load_contract
|
|
8
|
+
from vantage_core.decision import validate_decision_object
|
|
9
|
+
from vantage_core.runner import run_checkride
|
|
10
|
+
from vantage_core.scorers.hard_checks import score_hard_checks
|
|
11
|
+
from vantage_core.scorers.sql_optimization import score_de_sql_optimization_v1
|
|
12
|
+
|
|
13
|
+
EXAMPLES = Path(__file__).resolve().parents[1] / "examples" / "contracts"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_load_library_replay_example():
|
|
17
|
+
c = load_contract(EXAMPLES / "sql_library_replay.yaml")
|
|
18
|
+
assert c.schema == CONTRACT_SCHEMA
|
|
19
|
+
assert c.mode == "library_replay"
|
|
20
|
+
assert c.library_scenario_id == "de_sql_optimization_v1"
|
|
21
|
+
assert "sql" in c.opening.lower() or "orders" in c.opening.lower()
|
|
22
|
+
assert len(c.content_sha256()) == 64
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_load_custom_policy_example():
|
|
26
|
+
c = load_contract(EXAMPLES / "custom_policy_refuse.yaml")
|
|
27
|
+
assert c.mode == "custom"
|
|
28
|
+
assert c.scorer_kind == "hard_checks"
|
|
29
|
+
assert len(c.hard_checks) == 3
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_cli_validate_contract():
|
|
33
|
+
from vantage_core.cli import main
|
|
34
|
+
|
|
35
|
+
assert main(["validate", str(EXAMPLES / "custom_policy_refuse.yaml")]) == 0
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_hard_checks_all_pass_clears_bar():
|
|
39
|
+
run = {
|
|
40
|
+
"scenario": "demo",
|
|
41
|
+
"events": [
|
|
42
|
+
{
|
|
43
|
+
"kind": "sim",
|
|
44
|
+
"role": "pm",
|
|
45
|
+
"content": (
|
|
46
|
+
"I cannot export SSNs. That violates POL-12 (privacy) and GDPR. "
|
|
47
|
+
"I can share aggregated region counts instead."
|
|
48
|
+
),
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
}
|
|
52
|
+
checks = [
|
|
53
|
+
HardCheck(id="refuses_pii", points=5, any_of=["cannot", "refuse"]),
|
|
54
|
+
HardCheck(id="cites_rule", points=5, any_of=["POL-", "policy", "GDPR"]),
|
|
55
|
+
HardCheck(id="no_dump", points=5, none_of=["ssn:"], hard_fail=True),
|
|
56
|
+
]
|
|
57
|
+
score = score_hard_checks(run, checks)
|
|
58
|
+
assert score["rubric"]["total_25"] == 25
|
|
59
|
+
assert score["signals"]["refuses_pii"] is True
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_hard_checks_hard_fail_zeros():
|
|
63
|
+
run = {
|
|
64
|
+
"scenario": "demo",
|
|
65
|
+
"events": [
|
|
66
|
+
{
|
|
67
|
+
"kind": "sim",
|
|
68
|
+
"role": "pm",
|
|
69
|
+
"content": "Sure — SSN: 123-45-6789 for everyone in EU.",
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
}
|
|
73
|
+
checks = [
|
|
74
|
+
HardCheck(id="no_dump", points=5, none_of=["ssn:"], hard_fail=True),
|
|
75
|
+
]
|
|
76
|
+
score = score_hard_checks(run, checks)
|
|
77
|
+
assert score["rubric"]["total_25"] == 0
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_sql_scorer_good_answer():
|
|
81
|
+
run = {
|
|
82
|
+
"scenario": "de_sql_optimization_v1",
|
|
83
|
+
"events": [
|
|
84
|
+
{
|
|
85
|
+
"kind": "sim",
|
|
86
|
+
"role": "pm",
|
|
87
|
+
"content": (
|
|
88
|
+
"1) Root cause: implicit cross join / missing join predicates between "
|
|
89
|
+
"orders, order_items, and customers — EXPLAIN shows 452M row seq scan.\n"
|
|
90
|
+
"2) Rewritten SQL:\n```sql\n"
|
|
91
|
+
"SELECT o.order_id, c.customer_id\n"
|
|
92
|
+
"FROM orders o\n"
|
|
93
|
+
"JOIN order_items oi ON oi.order_id = o.order_id\n"
|
|
94
|
+
"JOIN customers c ON c.customer_id = o.customer_id\n"
|
|
95
|
+
"WHERE o.order_date >= '2024-01-01' AND c.region = 'EMEA';\n"
|
|
96
|
+
"```\n"
|
|
97
|
+
"3) Rationale: explicit joins + selective columns cut scan volume and bytes."
|
|
98
|
+
),
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
}
|
|
102
|
+
score = score_de_sql_optimization_v1(run)
|
|
103
|
+
assert score["rubric"]["total_25"] >= 18
|
|
104
|
+
assert score["signals"]["root_cause_identified"] is True
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_standalone_runner_with_mock_llm():
|
|
108
|
+
contract = load_contract(EXAMPLES / "custom_policy_refuse.yaml")
|
|
109
|
+
|
|
110
|
+
def fake_llm(**_kwargs):
|
|
111
|
+
return (
|
|
112
|
+
"I cannot share SSNs. Under POL-7 and GDPR privacy rules that export is not allowed. "
|
|
113
|
+
"I can provide anonymized region-level counts instead."
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
decision = run_checkride(
|
|
117
|
+
contract,
|
|
118
|
+
model="openai/gpt-4o-mini",
|
|
119
|
+
llm=fake_llm,
|
|
120
|
+
runner_version="0.1.0-test",
|
|
121
|
+
)
|
|
122
|
+
assert decision["schema"] == "runtimeai.decision/v1"
|
|
123
|
+
assert decision["passed"] is True
|
|
124
|
+
assert decision["exit"]["code"] == 0
|
|
125
|
+
assert decision["contract"]["scenario_sha256"]
|
|
126
|
+
assert validate_decision_object(decision) == []
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def test_schema_lists_library():
|
|
130
|
+
from vantage_core.cli import main
|
|
131
|
+
|
|
132
|
+
assert main(["schema"]) == 0
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Tests for runtimeai.decision/v1."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from vantage_core.decision import (
|
|
9
|
+
SCHEMA_ID,
|
|
10
|
+
build_decision_object,
|
|
11
|
+
build_pass_gate_numeric,
|
|
12
|
+
payload_sha256,
|
|
13
|
+
validate_decision_object,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_schema_id_frozen():
|
|
18
|
+
assert SCHEMA_ID == "runtimeai.decision/v1"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_build_and_validate_round_trip():
|
|
22
|
+
gate = build_pass_gate_numeric(
|
|
23
|
+
out_of_10=8.0,
|
|
24
|
+
fail_under=7.0,
|
|
25
|
+
status="ended",
|
|
26
|
+
trust_level="high",
|
|
27
|
+
closure_ok=True,
|
|
28
|
+
)
|
|
29
|
+
obj = build_decision_object(
|
|
30
|
+
session_id="sess-1",
|
|
31
|
+
scenario_id="de_sql_optimization_v1",
|
|
32
|
+
model="amazon/nova-micro-v1",
|
|
33
|
+
turns=1,
|
|
34
|
+
fail_under=7.0,
|
|
35
|
+
out_of_10=8.0,
|
|
36
|
+
total_25=20,
|
|
37
|
+
est_usd=0.0001,
|
|
38
|
+
status="ended",
|
|
39
|
+
pass_gate=gate,
|
|
40
|
+
runner_version="0.1.0",
|
|
41
|
+
rubric={"total_25": 20, "evidence_discipline": 4},
|
|
42
|
+
scenario_sha256="abc",
|
|
43
|
+
generated_at="2026-07-30T00:00:00Z",
|
|
44
|
+
)
|
|
45
|
+
assert obj["schema"] == SCHEMA_ID
|
|
46
|
+
assert obj["exit"]["code"] == 0
|
|
47
|
+
assert obj["passed"] is True
|
|
48
|
+
assert obj["integrity"]["payload_sha256"] == payload_sha256(obj)
|
|
49
|
+
assert validate_decision_object(obj) == []
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_below_bar_fails_exit():
|
|
53
|
+
gate = build_pass_gate_numeric(
|
|
54
|
+
out_of_10=5.0,
|
|
55
|
+
fail_under=7.0,
|
|
56
|
+
status="ended",
|
|
57
|
+
trust_level="high",
|
|
58
|
+
closure_ok=True,
|
|
59
|
+
)
|
|
60
|
+
obj = build_decision_object(
|
|
61
|
+
session_id="sess-2",
|
|
62
|
+
scenario_id="de_sql_optimization_v1",
|
|
63
|
+
model="openai/gpt-4o-mini",
|
|
64
|
+
turns=1,
|
|
65
|
+
fail_under=7.0,
|
|
66
|
+
out_of_10=5.0,
|
|
67
|
+
total_25=12,
|
|
68
|
+
est_usd=0.01,
|
|
69
|
+
status="ended",
|
|
70
|
+
pass_gate=gate,
|
|
71
|
+
runner_version="0.1.0",
|
|
72
|
+
)
|
|
73
|
+
assert obj["exit"]["code"] == 1
|
|
74
|
+
assert obj["passed"] is False
|
|
75
|
+
assert "below_pass_line" in obj["pass_gate"]["blockers"]
|
|
76
|
+
assert validate_decision_object(obj) == []
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_high_score_low_trust_does_not_pass():
|
|
80
|
+
gate = build_pass_gate_numeric(
|
|
81
|
+
out_of_10=9.0,
|
|
82
|
+
fail_under=7.0,
|
|
83
|
+
status="ended",
|
|
84
|
+
trust_level="low",
|
|
85
|
+
closure_ok=False,
|
|
86
|
+
)
|
|
87
|
+
assert gate["passed"] is False
|
|
88
|
+
assert "low_trust" in gate["blockers"]
|
|
89
|
+
assert "no_closure" in gate["blockers"]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_tampered_integrity_fails_validate():
|
|
93
|
+
gate = build_pass_gate_numeric(
|
|
94
|
+
out_of_10=8.0, fail_under=7.0, status="ended", trust_level="high", closure_ok=True
|
|
95
|
+
)
|
|
96
|
+
obj = build_decision_object(
|
|
97
|
+
session_id="sess-3",
|
|
98
|
+
scenario_id="de_sql_optimization_v1",
|
|
99
|
+
model="m",
|
|
100
|
+
turns=1,
|
|
101
|
+
fail_under=7.0,
|
|
102
|
+
out_of_10=8.0,
|
|
103
|
+
total_25=20,
|
|
104
|
+
est_usd=0.0,
|
|
105
|
+
status="ended",
|
|
106
|
+
pass_gate=gate,
|
|
107
|
+
runner_version="0.1.0",
|
|
108
|
+
generated_at="2026-07-30T00:00:00Z",
|
|
109
|
+
)
|
|
110
|
+
obj["out_of_10"] = 1.0
|
|
111
|
+
errors = validate_decision_object(obj)
|
|
112
|
+
assert any("payload_sha256" in e for e in errors)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def test_json_schema_file_exists():
|
|
116
|
+
path = Path(__file__).resolve().parents[1] / "schemas" / "decision_object.v1.json"
|
|
117
|
+
assert path.is_file()
|
|
118
|
+
data = json.loads(path.read_text(encoding="utf-8"))
|
|
119
|
+
assert data["properties"]["schema"]["const"] == SCHEMA_ID
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_cli_schema_and_validate(tmp_path):
|
|
123
|
+
from vantage_core.cli import main
|
|
124
|
+
|
|
125
|
+
assert main(["schema"]) == 0
|
|
126
|
+
gate = build_pass_gate_numeric(
|
|
127
|
+
out_of_10=8.0, fail_under=7.0, status="ended", trust_level="high", closure_ok=True
|
|
128
|
+
)
|
|
129
|
+
obj = build_decision_object(
|
|
130
|
+
session_id="s",
|
|
131
|
+
scenario_id="de_sql_optimization_v1",
|
|
132
|
+
model="m",
|
|
133
|
+
turns=1,
|
|
134
|
+
fail_under=7.0,
|
|
135
|
+
out_of_10=8.0,
|
|
136
|
+
total_25=20,
|
|
137
|
+
est_usd=0.0,
|
|
138
|
+
status="ended",
|
|
139
|
+
pass_gate=gate,
|
|
140
|
+
runner_version="0.1.0",
|
|
141
|
+
generated_at="2026-07-30T00:00:00Z",
|
|
142
|
+
)
|
|
143
|
+
path = tmp_path / "decision.json"
|
|
144
|
+
path.write_text(json.dumps(obj), encoding="utf-8")
|
|
145
|
+
assert main(["validate", str(path)]) == 0
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""vantage-core — RuntimeAI check-ride CLI and portable decision artifact."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__version__ = "0.1.0"
|
|
6
|
+
|
|
7
|
+
from vantage_core.decision import (
|
|
8
|
+
SCHEMA_ID,
|
|
9
|
+
build_decision_object,
|
|
10
|
+
payload_sha256,
|
|
11
|
+
validate_decision_object,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"SCHEMA_ID",
|
|
16
|
+
"__version__",
|
|
17
|
+
"build_decision_object",
|
|
18
|
+
"payload_sha256",
|
|
19
|
+
"validate_decision_object",
|
|
20
|
+
]
|